mmozeiko
You'll need to change win32_pe structure to support 32-bit header. And change code line that gets TEB structure, on 32-bit its done differently. Otherwise the logic stays the same.
1 | __readfsdword(0x18); |
1 | windowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); |
mmozeiko
Why do you this is the line that makes RegisterClassA to fail?
Have you checked return value of GetStockObject? Even if it fails and returns NULL, that is completely valid value for hbrBackground member.
My guess is that you have set some other member to invalid value.
1 2 3 4 5 6 7 | void __stdcall WinMainCRTStartup() {
HMODULE Kernel32 = GetKernel32Module();
DynamicLink(Kernel32);
int result = WinMain(Kernel32, 0, 0, 0);
ExitProcess(0);
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine , int nCmdShow) {
WNDCLASSA windowClass = {};
windowClass.style = CS_HREDRAW | CS_VREDRAW ;
windowClass.lpfnWndProc = WndProc;
windowClass.hInstance = hInstance;
windowClass.lpszClassName = "NoLibrariesWindowClass";
windowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
if (RegisterClassA(&windowClass))
{
HWND WindowHandle = CreateWindowExA(
0, "NoLibrariesWindowClass", "Greetings",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, hInstance, 0
);
if (WindowHandle)
{
MSG Message;
while (GetMessageA(&Message, NULL, 0, 0))
{
TranslateMessage(&Message);
DispatchMessageA(&Message);
}
}
}
return 0;
}
|