Skip to content

Instantly share code, notes, and snippets.

@W4RH4WK
Created November 7, 2024 12:04
Show Gist options
  • Save W4RH4WK/7c3a2c30a722ccf9d035536bfdc72074 to your computer and use it in GitHub Desktop.
Save W4RH4WK/7c3a2c30a722ccf9d035536bfdc72074 to your computer and use it in GitHub Desktop.
Win11 SDK Debug Configuration Crash
// Build this program with a Windows 11 SDK (e.g. 10.0.22621.0) in debug
// configuration, using Multi-threaded Debug DLL (/MDd).
#include <Windows.h>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
// This causes ucrtbase.dll (release version) to be loaded, which might cause
// the issue below. There is no debug version of xapobase available in the
// Windows SDKs.
#pragma comment(lib, "xapobase.lib")
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
const char* file_path = "main.cpp";
HANDLE hFile = CreateFile(file_path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
return 1;
}
int fd = _open_osfhandle((intptr_t)hFile, _O_RDONLY | _O_TEXT);
if (fd == -1) {
return 1;
}
FILE* fh = _fdopen(fd, "rt");
if (!fh) {
return 1;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment