C – Damage to the use of CreateWindowexwwW

I have some heap corruption issues. Warnings can be observed when using the CreateWindowExW function. I know this is usually a memory error, but how can I search for it in this case? There is no new variable before calling CreateWindowExW and I cannot enter this function. Here is the code.

HWND GetMainWnd(HINSTANCE hInstance){
static HWND hWnd = NULL;
if (hWnd)
return hWnd;

RETURN_AT_ERROR(hInstance, NULL);

WNDCLASSEX wcex = {sizeof(WNDCLASSEX) };
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = MainWndProc;
wcex.hInstance = hInstance;
wcex.hCursor = ::LoadCursorW(NULL, IDC_ARROW);< br />wcex.lpszClassName = g_config->GetWndClass();

ATOM atom = ::RegisterClassExW(&wcex);
RETURN_AT_ERROR(atom != 0, NULL);

hWnd = ::CreateWindowExW(WS_EX_LEFT, g_config->GetWndClass(), 0, WS_POPUP | WS_MINIMIZEBOX | WS_CLIPCHILDREN, 0, 0, 0, 0, 0, 0, hInstance, 0);

return hWnd;}

On this string

hWnd = ::CreateWindowExW(WS_EX_LEFT, g_config->GetWndClass(), 0, WS_POPUP | WS_MINIMIZEBOX | WS_CLIPCHILDREN, 0, 0, 0, 0, 0, 0, hInstance, 0);

There is a warning message box

Windows has triggered a breakpoint in drm.exe. This may be due to a
corruption of the heap, which indicates a bug in drm.exe or any of the
DLLs it has loaded. This may also be due to the user pressing F12
while drm.exe has focus. The output window may have more diagnostic
information.

I press “Continue” and it displays

Unhandled exception at 0x77dae753 in app.exe: 0xC0000374: A heap has been corrupted.

However, CreateWindowExW returns a non-zero value and creates the window , Because it should…

As mentioned above, load some of the After the actual corruption of the DLL/module has occurred, the heap corruption is usually detected. From your post it looks like this issue is specific to the Windows platform, so I suggest you use WinDBG/Pageheap and find out where the actual memory corruption occurs. About A very good article on heap memory corruption analysis can be found in the book “Advanced Windows Debugging, Author: Mario Hewardt; Daniel Pravat”.

http://advancedwindowsdebugging.com /ch06.pdf

I have some heap corruption issues. Warnings can be observed when using the CreateWindowExW function. I know this is usually a memory error, but how can I Search it in this case? There is no new variable before calling CreateWindowExW and I cannot enter this function. Here is the code.

HWND GetMainWnd(HINSTANCE hInstance){
static HWND hWnd = NULL;
if (hWnd)
return hWnd;

RETURN_AT_ERROR(hInstance, NULL);

WNDCLASSEX wcex = {sizeof(WNDCLASSEX) };
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = MainWndProc;
wcex.hInstance = hInstance;
wcex.hCursor = ::LoadCursorW(NULL, IDC_ARROW);< br />wcex.lpszClassName = g_config->GetWndClass();

ATOM atom = ::RegisterClassExW(&wcex);
RETURN_AT_ERROR(atom != 0, NULL);

hWnd = ::CreateWindowExW(WS_EX_LEFT, g_config->GetWndClass(), 0, WS_POPUP | WS_MINIMIZEBOX | WS_CLIPCHILDREN, 0, 0, 0, 0, 0, 0, hInstance, 0);

return hWnd;}

On this string

hWnd = ::CreateWindowExW(WS_EX_LEFT, g_config->GetWndClass(), 0, WS_POPUP | WS_MINIMIZEBOX | WS_CLIPCHILDREN, 0, 0, 0, 0, 0, 0, hInstance, 0);

There is a warning message box

Wi ndows has triggered a breakpoint in drm.exe. This may be due to a
corruption of the heap, which indicates a bug in drm.exe or any of the
DLLs it has loaded. This may also be due to the user pressing F12
while drm.exe has focus. The output window may have more diagnostic
information.

I press “Continue” and it displays

< p>

Unhandled exception at 0x77dae753 in app.exe: 0xC0000374: A heap has been corrupted.

However, CreateWindowExW returns a non-zero value and creates the window because it should…

As mentioned above, after some DLLs/modules loaded in your process have actually become corrupted, heap corruption is usually detected. From Your post looks like this problem is specific to the Windows platform, so I suggest you use WinDBG/Pageheap and find out where the actual memory corruption occurs. A very good article on heap memory corruption analysis can be found in “Advanced Windows Debugging , Author: Author: Mario Hewardt; Daniel Pravat” found in the book.

http://advancedwindowsdebugging.com/ch06.pdf

Leave a Comment

Your email address will not be published.