简体   繁体   English

在窗口 7 中移植 32 位到 64 位 MFC 应用程序

[英]Porting 32-bit to 64-bit MFC application in window 7

I am porting 32-bit application to 64-bit which is built in VC++.net 2003 .我正在将 32 位应用程序移植到VC++.net 2003 中内置的64位应用程序。 I have built this application in VS2010 sp1 successfully in 32-bit and 64-bit platform.我已经在32 位64 位平台上成功地在VS2010 sp1 中构建了这个应用程序。 But I am facing application crash issues in 64-bit platform(x64) application but not in 32-bit platform(win32) .但是我在64-bit platform(x64)应用程序中面临应用程序崩溃问题,但在32-bit platform(win32) 中没有 Crashing is happening at belowcode line崩溃发生在下面的代码行

char *pSls = (char*)SendMessage( ::GetParent( ::GetParent( GetParen() ) ),
                                              m_uMessageID,
                                              L_SOM_CHANNEL, nChannel );

In win32 *pSls get data in it but in 64-bit , Expression doesn't evaluate.win32 *pSls 中获取数据,但在64 位中,表达式不计算。 I have observed return type of SendMessage is LRESULT which is a LONG_PTR and LONG_PTR is long in Win32 and _int64 in 64-bit platform.我观察到 SendMessage 的返回类型是 LRESULT,它是一个 LONG_PTR,LONG_PTR 在Win32 中是 long,在 64 位平台中是_int64 Could anyone please help to resolve issue?有人可以帮忙解决问题吗?

Actual error which is displaiying: Expression: !IsBadReadPtr((const void )(pszString), sizeof( (pszString)))显示的实际错误:表达式:!IsBadReadPtr((const void )(pszString), sizeof( (pszString)))

Please find more code:请查找更多代码:

int CMNEditInputTab::GetChanIndx( const int nChannel )
{
   MEMBERASSERT();
   char *pSls = (char *)SendMessage( ::GetParent( ::GetParent( GetParent() ) ),
                                              m_uMessageID,
                                              L_SOM_CHANNEL, nChannel );

   if ( *pSls == NULL )
      return 0;

   int nIndex = GetSignalList().FindString( -1, pSls );

   if ( nIndex != LB_ERR )
      return nIndex;

   return 0;
}
int SN_ListBox::FindString( int nStartIndex, LPCTSTR pszString )
{
   MEMBERASSERT();
   RPTRASSERT(pszString);

   SN_REQUIRES_HWND( SN_ListBox::FindString );

   if ( m_hWnd )
      return ListBox_FindString(m_hWnd, nStartIndex, pszString);
   else
      return 0;
}
void MDCDBG_assert(char *pszExp, char *pszFile, int nLine)
{
#ifdef _DEBUG
   MDCDBG_Initialize();
#ifndef _WIN32_WCE
   int nResponse = _CrtDbgReport(_CRT_ASSERT, pszFile, nLine, NULL, "%s", pszExp);
   if (nResponse == 1)
      _CrtDbgBreak();
#endif

#endif
}

In dbgrpt.c file:在 dbgrpt.c 文件中:

_CRTIMP int __cdecl _CrtDbgReportT(
        int nRptType,
        const TCHAR * szFile,
        int nLine,
        const TCHAR * szModule,
        const TCHAR * szFormat,
        ...
        )
{
    int retval;
    va_list arglist;

    va_start(arglist,szFormat);

    retval = _CrtDbgReportTV(nRptType, szFile, nLine, szModule, szFormat, arglist);//Fails here

    va_end(arglist);

    return retval;
}

Observation: *pSls is not getting data in x64 mode but this variable gets data in win32 mode观察:*pSls 没有在 x64 模式下获取数据,但此变量在 win32 模式下获取数据

There's not enough information to determine the cause.没有足够的信息来确定原因。 If I'm allowed to speculate, I have seen issues like this before.如果允许我推测,我以前见过这样的问题。 It looks like the return of your SendMessage() returns a LPCTSTR?看起来您的 SendMessage() 的返回返回一个 LPCTSTR?

My hunch... You have some string...我的预感......你有一些绳子......

LPCTSTR lpszRet  = "abcdef"; // ignore error that this string might be on the stack
return (DWORD) lpszRet; // DWORD, or LONG, etc..., but error is here with pointer truncation

instead use,而是使用,

return (DWORD_PTR) lpszRet; // or LONG_PTR, etc  ... pointer not truncated

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Windows(7个64位)计算机上表现异常的MFC应用程序(32位)(GetScrollPosition()函数结果中的垃圾值) - MFC application (32-bit) behaving strangly on windows (7 64-bit) machine (garabage value from GetScrollPosition() function results) 使用AssocQueryString从32位应用程序获取64位应用程序命令,但不起作用 - Using AssocQueryString to get 64-bit application command from 32-bit application, but not working 为什么32位和64位系统上的“对齐”相同? - Why is the “alignment” the same on 32-bit and 64-bit systems? 从32位升级到64位 - Going from 32-bit to 64-bit 64位MFC应用程序(AppTranslator)的本地化 - Localization of a 64-bit MFC application (AppTranslator) 将32位项目升级到64位后,启动应用程序失败,错误代码0xc000007b - Launching application fails with error code 0xc000007b after upgrading 32-bit project to 64-bit 32位OS中的16位和64位OS中的32位是什么数据类型? - What data type is 16 bits in 32-bit OS and 32bits in 64-bit OS? 澄清:移植32到64位 - Clarification: Porting 32 to 64 bit 从32位移植到64位 - porting from 32 bit to 64 bit 是否可以在不重新启动Visual Studio的情况下编译32位和64位配置? - Is it possible to compile both 32-bit and 64-bit configurations without restarting Visual Studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM