GetOpenFileName 共通ダイアログを使用してユーザーにファイルを選択させる C アプリケーションがあります。Windows2008R2 でクラッシュが発生しています。アプリケーションに DEP 例外を設定すると、クラッシュが停止することがわかりました。
しかし、何が間違っているのか、そもそもクラッシュを止めるために何ができるのかわかりません。コードを以下に配置しました。
typedef struct {
OPENFILENAME ofn;
COUNT nInternal;
COUNT nExternal;
char szDirName[_MAX_DIR];
char szFile[_MAX_PATH];
char szFileTitle[_MAX_PATH];
char szFilter[128];
} OPENFILENAMEINFO;
typedef OPENFILENAMEINFO FAR *LPOPENFILENAMEINFO;
LPOPENFILENAMEINFO RequestFileNameEx(HWND hDlg, LPSTR lpExt, BOOL bSave, LPSTR lpInit)
{
LPOPENFILENAMEINFO lpFileNameInfo;
int i;
DWORD dwError;
DWORD dwSize;
LPSTR lpDir;
LPSTR lpDrive;
lpFileNameInfo = (LPOPENFILENAMEINFO)mballc(1,sizeof(OPENFILENAMEINFO));
strcpy(lpFileNameInfo->szFilter,lpExt);
for (i=0; lpFileNameInfo->szFilter[i] != '\0'; i++) {
if (lpFileNameInfo->szFilter[i] == '|')
lpFileNameInfo->szFilter[i] = '\0';
}
memset(&lpFileNameInfo->ofn, 0, sizeof(OPENFILENAME));
lpFileNameInfo->ofn.lStructSize = sizeof(OPENFILENAME);
lpFileNameInfo->ofn.hwndOwner = hDlg;
lpFileNameInfo->ofn.lpstrFilter = lpFileNameInfo->szFilter;
lpFileNameInfo->ofn.nFilterIndex = 1;
lpFileNameInfo->ofn.lpstrFile = lpFileNameInfo->szFile;
lpFileNameInfo->ofn.nMaxFile = sizeof(lpFileNameInfo->szFile);
lpFileNameInfo->ofn.lpstrFileTitle = lpFileNameInfo->szFileTitle;
lpFileNameInfo->ofn.nMaxFileTitle = sizeof(lpFileNameInfo->szFileTitle);
lpFileNameInfo->ofn.lpstrInitialDir = _getcwd(lpFileNameInfo->szDirName, _MAX_DIR);
if (bSave) {
lpFileNameInfo->ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR;
dwError = GetSaveFileName(&lpFileNameInfo->ofn);
} else {
lpFileNameInfo->ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | (bDir==FALSE?OFN_FILEMUSTEXIST:0) | OFN_NOCHANGEDIR;
dwError = GetOpenFileName(&lpFileNameInfo->ofn);
}
if (!dwError) {
dwError = CommDlgExtendedError();
if (dwError)
ResourceHandleError(GETOPENFAIL, dwError);
mbfree(lpFileNameInfo);
return(NULL);
}
return(lpFileNameInfo);
}
クラッシュ ダンプのスタック トレースは次のようになります
0023:73E61FFF (0x080D7974 0x080D7970 0x078B62F0 0x00000000) msxml6.dll
0023:73E68165 (0x080D7970 0x080D78F0 0x078B62F0 0x080D78F0) msxml6.dll, DllCanUnloadNow()+22084 byte(s)
0023:73E67D08 (0x078B62F0 0x080D7970 0x00000000 0x080D78F0) msxml6.dll, DllCanUnloadNow()+20967 byte(s)
0023:73E6827A (0x080D78F0 0x080D7970 0x080D7950 0x59E489BA) msxml6.dll, DllCanUnloadNow()+22361 byte(s)
0023:73E68241 (0x080D7970 0x080D7950 0x59E489BA 0x00000000) msxml6.dll, DllCanUnloadNow()+22304 byte(s)
0023:73E69DDF (0x00000000 0x080D7950 0x00000000 0x0762FAE0) msxml6.dll, DllCanUnloadNow()+29374 byte(s)
0023:73E6BF9F (0x080D7970 0x080D7950 0x71932915 0x078B5E90) msxml6.dll, DllGetClassObject()+5125 byte(s)
0023:73E6BF83 (0x73E81B38 0x080D39C0 0x080D39C0 0x080D3980) msxml6.dll, DllGetClassObject()+5097 byte(s)
0023:73E6C318 (0x71932881 0x06148CB8 0x06148CB8 0x00000000) msxml6.dll, DllGetClassObject()+6014 byte(s)
0023:73E6CD18 (0x720B35A0 0x0762FBD8 0x06148CB8 0x0762FD68) msxml6.dll, DllGetClassObject()+8574 byte(s)
0023:73E78671 (0x720B35A0 0x0762FBD8 0x0762FD68 0x00000000) msxml6.dll, DllGetClassObject()+56023 byte(s)
0023:73E6AAE5 (0x73E6AC28 0x00000000 0x720B35A0 0x0762FBD8) msxml6.dll, DllCanUnloadNow()+32708 byte(s)
0023:74B0A0E1 (0x00000000 0x00000000 0x00000000 0x00000001) ole32.dll, CoCreateInstanceEx()+0915 byte(s)
0023:74B09FA1 (0x720B3614 0x00000000 0x00000017 0x00000000) ole32.dll, CoCreateInstanceEx()+0595 byte(s)
0023:74B09E25 (0x720B3614 0x00000000 0x00000017 0x00000000) ole32.dll, CoCreateInstanceEx()+0215 byte(s)
0023:74B09D86 (0x720B3614 0x00000000 0x00000017 0x00000000) ole32.dll, CoCreateInstanceEx()+0056 byte(s)
0023:74B09D3F (0x720B3614 0x00000000 0x00000017 0x720B35A0) ole32.dll, CoCreateInstance()+0052 byte(s)
0023:720B352B (0x0553A7C0 0x00000000 0x0070E2DC 0x0070E288) FunDisc.dll
0023:720B9470 (0x0553A7C0 0x00000000 0x00000001 0x00000001) FunDisc.dll, DllGetClassObject()+21871 byte(s)
0023:720C3B69 (0x00000001 0x0070E288 0x8007000E 0x00000000) FunDisc.dll, DllUnregisterServer()+20504 byte(s)
0023:720B75AA (0x73751590 0x00000000 0x00000001 0x00000000) FunDisc.dll, DllGetClassObject()+13993 byte(s)
0023:720B1CE9 (0x73751590 0x00000000 0x00000001 0x055874F8) FunDisc.dll
0023:720B1C39 (0x00709310 0x73751590 0x00000000 0x00000001) FunDisc.dll
0023:73752F84 (0x055E2F28 0x00709310 0x73751590 0x00000000) NetworkItemFactory.dll
0023:737530A5 (0x055E2F28 0x0762FF88 0x763643C0 0x055E2F28) NetworkItemFactory.dll
0023:73753144 (0x055E2F28 0x00000000 0x00000000 0x03EDFB9C) NetworkItemFactory.dll
0023:763643C0 (0x03EDFB9C 0x0762FFD4 0x77029EF2 0x03EDFB9C) SHLWAPI.dll, IUnknown_QueryService()+0346 byte(s)
0023:74C9339A (0x03EDFB9C 0x13BB74FB 0x00000000 0x00000000) kernel32.dll, BaseThreadInitThunk()+0018 byte(s)
0023:77029EF2 (0x763642ED 0x03EDFB9C 0xFFFFFFFF 0x770B736F) ntdll.dll, RtlInitializeExceptionChain()+0099 byte(s)
0023:77029EC5 (0x00000000 0x00000000 0x00000000 0x00000000) ntdll.dll, RtlInitializeExceptionChain()+0054 byte(s)