Following up on my previous question (
Is getopenfilenname interacting badly with VS now?[
^]), I have reproduced the issue with just about the simplest window possible. In VS 2019 I create a minimal Windows project and only add a 'commdlg.h' include and the
OpenFileDialog
code to the default template code VS generates. When I execute it, I get the same exceptions thrown on the
OpenFileDialog
call as I previously obtained.
Any ideas as to what could cause this issue? I believe this rules out any memory overruns on my part, because it's all MS's default code except for the
OpenFileDialog
stuff.
The exception text: Exception thrown at 0x77E7436F (ntdll.dll) in WindowsProject1.exe: 0xC0000005: Access violation reading location 0xFFFFFFFC.
Like before, I can continue the execution and don't see any immediate problems. I'm leaning towards the only solution being a Windows reinstallation, but I pray I'm overlooking something obvious.
Thanks,
David
#include "commdlg.h"
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
TCHAR filePtrC[MAX_PATH] = { 0 };
OPENFILENAME tofn = { 0 };
tofn.lStructSize = sizeof(tofn);
tofn.hwndOwner = NULL;
tofn.lpstrFile = filePtrC;
tofn.nMaxFile = MAX_PATH;
tofn.lpstrFilter = L"All\0*.*\0Text\0*.TXT\0";
tofn.nFilterIndex = 1;
tofn.lpstrFileTitle = NULL;
tofn.nMaxFileTitle = 0;
tofn.lpstrInitialDir = NULL;
tofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
GetOpenFileName(&tofn);
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadStringW(hInstance, IDC_WINDOWSPROJECT1, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WINDOWSPROJECT1));
MSG msg;
while (GetMessage(&msg, nullptr, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
What I have tried:
A lot more cussing. Creating the simplest solution in the world to replicate the issue. Followed by a big wtf when it failed.