[英]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.