Click here to Skip to main content
15,885,767 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Running a c++ program Pin
Richard MacCutchan23-May-11 1:30
mveRichard MacCutchan23-May-11 1:30 
GeneralRe: Running a c++ program Pin
tasumisra23-May-11 1:33
tasumisra23-May-11 1:33 
GeneralRe: Running a c++ program [modified] Pin
Legor23-May-11 1:45
Legor23-May-11 1:45 
GeneralRe: Running a c++ program Pin
tasumisra23-May-11 1:52
tasumisra23-May-11 1:52 
GeneralRe: Running a c++ program Pin
Legor23-May-11 2:40
Legor23-May-11 2:40 
GeneralRe: Running a c++ program Pin
Richard MacCutchan23-May-11 2:40
mveRichard MacCutchan23-May-11 2:40 
AnswerRe: Running a c++ program Pin
David Crow24-May-11 6:43
David Crow24-May-11 6:43 
Question64-bit strange issue, SetupDiEnumDeviceInfo Pin
Maxwell Chen22-May-11 20:01
Maxwell Chen22-May-11 20:01 
I have been working on SetupDi API functions with VC++ 2010 during these couple days. It works well with 32-bit and 64-bit debug-build, but not the 64-bit release-build. I added some AfxMessageBox'es to narrow down where the problem was. It failed in the API SetupDiEnumDeviceInfo.

But when I formatted a CString in the error handling block after the SetupDiEnumDeviceInfo call, the problem was gone. It looks like some memory alignment issue (well, I guess). Anyone knows the correct way to resolve this kind of issue?

(1) The below code fails.
bool SetupDi::EnumDevInfo(DWORD dwIndex, SP_DEVINFO_DATA* pDeviceInfoData)
{
	if(!m_hDevInfo) {
		TRACE(_T("SetupDi::EnumDevInfo, m_hDevInfo is NULL. \n"));
		return false;
	}
	if(!pDeviceInfoData) {
		TRACE(_T("SetupDi::EnumDevInfo, pDeviceInfoData is NULL. \n"));
		return false;
	}
	memset(pDeviceInfoData, 0, sizeof(SP_DEVINFO_DATA));
	pDeviceInfoData->cbSize = sizeof(SP_DEVINFO_DATA);
	BOOL bRet = SetupDiEnumDeviceInfo(m_hDevInfo, dwIndex, pDeviceInfoData);
	if(!bRet) {
		TRACE(_T("SetupDi::EnumDevInfo, SetupDiEnumDeviceInfo(index: %d) failed (0x%08X). \n"),
			dwIndex, GetLastError());
	}
	return (TRUE == bRet);
}


(2) The below code works well.
bool SetupDi::EnumDevInfo(DWORD dwIndex, SP_DEVINFO_DATA* pDeviceInfoData)
{
	if(!m_hDevInfo) {
		TRACE(_T("SetupDi::EnumDevInfo, m_hDevInfo is NULL. \n"));
		return false;
	}
	if(!pDeviceInfoData) {
		TRACE(_T("SetupDi::EnumDevInfo, pDeviceInfoData is NULL. \n"));
		return false;
	}
	memset(pDeviceInfoData, 0, sizeof(SP_DEVINFO_DATA));
	pDeviceInfoData->cbSize = sizeof(SP_DEVINFO_DATA);
	BOOL bRet = SetupDiEnumDeviceInfo(m_hDevInfo, dwIndex, pDeviceInfoData);
	if(!bRet) {
		TRACE(_T("SetupDi::EnumDevInfo, SetupDiEnumDeviceInfo(index: %d) failed (0x%08X). \n"),
			dwIndex, GetLastError());

		// BEGIN: We just need this to make it work under x64. Memory alignment issue.
		CString s;
		s.Format(_T("SetupDi::EnumDevInfo, SetupDiEnumDeviceInfo(index: %d) failed (0x%08X). \n"),
			dwIndex, GetLastError());
		// END: We just need this to make it work under x64. Memory alignment issue.

		//AfxMessageBox(s);
	}
	return (TRUE == bRet);
}

  Maxwell Chen

QuestionRe: 64-bit strange issue, SetupDiEnumDeviceInfo Pin
CPallini23-May-11 0:42
mveCPallini23-May-11 0:42 
AnswerRe: 64-bit strange issue, SetupDiEnumDeviceInfo Pin
Maxwell Chen23-May-11 0:45
Maxwell Chen23-May-11 0:45 
GeneralRe: 64-bit strange issue, SetupDiEnumDeviceInfo Pin
CPallini23-May-11 1:00
mveCPallini23-May-11 1:00 
GeneralRe: 64-bit strange issue, SetupDiEnumDeviceInfo Pin
Maxwell Chen23-May-11 1:01
Maxwell Chen23-May-11 1:01 
QuestionRe: 64-bit strange issue, SetupDiEnumDeviceInfo Pin
CPallini23-May-11 1:28
mveCPallini23-May-11 1:28 
AnswerRe: 64-bit strange issue, SetupDiEnumDeviceInfo Pin
Maxwell Chen23-May-11 4:08
Maxwell Chen23-May-11 4:08 
GeneralRe: 64-bit strange issue, SetupDiEnumDeviceInfo Pin
CPallini23-May-11 4:12
mveCPallini23-May-11 4:12 
GeneralRe: 64-bit strange issue, SetupDiEnumDeviceInfo Pin
Maxwell Chen23-May-11 4:29
Maxwell Chen23-May-11 4:29 
QuestionRe: 64-bit strange issue, SetupDiEnumDeviceInfo Pin
CPallini23-May-11 4:32
mveCPallini23-May-11 4:32 
AnswerRe: 64-bit strange issue, SetupDiEnumDeviceInfo Pin
Maxwell Chen23-May-11 4:47
Maxwell Chen23-May-11 4:47 
GeneralRe: 64-bit strange issue, SetupDiEnumDeviceInfo Pin
CPallini23-May-11 6:03
mveCPallini23-May-11 6:03 
GeneralRe: 64-bit strange issue, SetupDiEnumDeviceInfo Pin
Maxwell Chen23-May-11 6:07
Maxwell Chen23-May-11 6:07 
GeneralRe: 64-bit strange issue, SetupDiEnumDeviceInfo Pin
Maxwell Chen25-May-11 1:33
Maxwell Chen25-May-11 1:33 
AnswerRe: 64-bit strange issue, SetupDiEnumDeviceInfo [Resolved] Pin
Maxwell Chen25-May-11 1:31
Maxwell Chen25-May-11 1:31 
GeneralRe: 64-bit strange issue, SetupDiEnumDeviceInfo [Resolved] Pin
CPallini25-May-11 1:45
mveCPallini25-May-11 1:45 
QuestionNetServerEnum Function in Windows 2008 domains Pin
CADITC_CODER22-May-11 14:21
CADITC_CODER22-May-11 14:21 
AnswerRe: NetServerEnum Function in Windows 2008 domains Pin
barneyman22-May-11 19:05
barneyman22-May-11 19:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.