NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: mcamember on September 09, 2007, 02:49:00 AM
-
NASM 0.98.39 *seems* to build o.k. in Win98 (no errors)
but the executable crashes. RegisterClassEx and CreateWindowEx
return EAX=0. (The Demos which invoke CreateWindowEx don't work in Win98 either.)
Do I need an earlier version of NASM ?
Thanks in advance.
-
Ahhh, no you shouldn't need an earlier version of Nasm. 0.98.39 has been around a while. There *are* bugs in it, but not as you describe. You say you built it but "the executable crashes". Nasm crashes, or the executable you assembled with Nasm crashes? Sounds like the latter, when you mention what RegisterClassEX and CreateWindowEX return. Which demo(s) are we talking about? Where does it crash?
You might need different demos, you might need to do something different (what command line? for example), you *probably* don't need a different version of Nasm. Remotely possible that downloading the pre-compiled executable would help, but I doubt it.
Tell us more about exactly what you did to get this crash...
Best,
Frank
-
Hi Frank,
The applications crash - NOT NASM.
During compile NASM reports no errors.
Both my app and the demo file were compiled in Win98
using 0.98.39.
( Both my project and DEMO3 compile and run correctly
in Win2kPro but neither one runs correctly in Win98
*regardless* of the OS used to compile it.)
The demo is \DEMOS\WIN32\DEMO3\DEMO3.ASM.
I built the executable using its own DEMO3.BAT.
When the app is run, there's only a brief flash of what
*might* be the titlebar and then it disappears. The biggest
problem, however, is that the app stays in memory and needs
to be removed manually by CTL/ALT/DEL - KillProcess.
The above is true for both my application and the
DEMO3.ASM file.
However, for DEMO3.EXE the debugger (OLLYDBG v1.07a) reports an error when loading -
"Module 'DEMO3' has entry point outside the
code (as specified in the PE header). Maybe
this file is self-extracting or self-modifying.
Please keep it in mind when setting the break-
points."
During debug, OLLY reports no red-flagged error messages
but both functions (RegisterClassEx and CreateWindowEx)
return zero in EAX (no class identifier ATOM for RegisterClassEx
and no window handle for CreateWindowEx).
I took screenshots of the Olly debugger at various stages but
the only way I knew to save them was via Wordpad. Will Wordpad
screens upload correctly to the forum ? And if so, would they
help ? They're very big in .doc format.
;------------------------------------------------------------------
I'm sorry for the lack of information in the first post. My
usual fault is the opposite - I write a novel where a sentence
would suffice.
I figured that I was doing something so * obviously * stupid that it would be a red flag to you guys immediately.
Thanks for the attention to all of this.
Austin
-
Sorry. I forgot to include the source for DEMO3.ASM
DEMO3.ASM
;-------------------------------------------------------------------
%include '..\..\..\inc\win32\windows.inc'
%include '..\..\..\inc\win32\kernel32.inc'
%include '..\..\..\inc\win32\user32.inc'
%include '..\..\..\inc\nasm32.inc'
entry demo3
[section .code]
proc demo3
invoke GetModuleHandleA, dword NULL
mov [hInstance], eax
invoke WinMain, dword hInstance, dword NULL, dword NULL, dword SW_SHOWNORMAL
invoke ExitProcess, dword NULL
ret
endproc
proc WinMain
hinst argd ; Current instance handle
hpinst argd ; Previous instance handle
cmdln argd ; Command line arguments
dwshow argd ; Display style
invoke LoadIconA, dword NULL, dword IDI_APPLICATION
mov edx, eax
mov eax, dword argv(hinst)
mov ebx, dword szClass
mov ecx, dword WndProc
mov [wc + WNDCLASSEX.hInstance], eax
mov [wc + WNDCLASSEX.lpszClassName], ebx
mov [wc + WNDCLASSEX.lpfnWndProc], ecx
mov [wc + WNDCLASSEX.hIcon], edx
mov [wc + WNDCLASSEX.hIconSm], edx
invoke RegisterClassExA, dword wc
invoke CreateWindowExA, dword WS_EX_TOOLWINDOW, dword szClass, dword szTitle, dword WS_CAPTION + WS_SYSMENU + WS_VISIBLE, dword 100, dword 120, dword 100, dword 50, dword NULL, dword NULL, dword [wc + WNDCLASSEX.hInstance], dword NULL
mov [hWnd], eax
invoke ShowWindow, dword hWnd, dword argv(dwshow)
invoke UpdateWindow, dword hWnd
.msgloop:
invoke GetMessageA, dword message, dword NULL, dword NULL, dword NULL
cmp eax, dword 0
je .exit
invoke TranslateMessage, dword message
invoke DispatchMessageA, dword message
jmp .msgloop
.exit:
mov eax, dword [message + MSG.wParam]
ret
endproc
proc WndProc
hwnd argd ; Window handle
umsg argd ; Window message
wparam argd ; wParam
lparam argd ; lParam
.wm_create:
cmp argv(umsg), dword WM_CREATE
jnz .wm_command
invoke GetClientRect, dword argv(hwnd), dword rct
invoke CreateWindowExA, dword NULL, dword szButton, dword szString, dword WS_CHILD + WS_VISIBLE, dword 0, dword 0, dword [rct + RECT.right], dword [rct + RECT.bottom], dword argv(hwnd), dword 500, dword [wc + WNDCLASSEX.hInstance], dword NULL
jmp .wm_default
.wm_command:
cmp argv(umsg), dword WM_COMMAND
jnz .wm_destroy
cmp argv(wparam), dword 500
jne .wm_default
invoke MessageBoxA, dword NULL, dword szContent, dword szTitle, dword MB_OK
jmp .exit
.wm_destroy:
cmp argv(umsg), dword WM_DESTROY
jnz .wm_default
invoke PostQuitMessage, dword NULL
.wm_default:
invoke DefWindowProcA, dword argv(hwnd), dword argv(umsg), dword argv(wparam), dword argv(lparam)
.exit:
ret
endproc
[section .bss]
hInstance: resd 1
hWnd: resd 1
[section .data]
szButton: db "BUTTON", 0x0
szString: db "Click Me!", 0x0
szContent: db "Win32Nasm Demo #3", 0x0
szTitle: db "Demo3", 0x0
szClass: db "Demo3Class", 0x0
wc:
istruc WNDCLASSEX
at WNDCLASSEX.cbSize, dd WNDCLASSEX_size
at WNDCLASSEX.style, dd CS_VREDRAW + CS_HREDRAW
at WNDCLASSEX.lpfnWndProc, dd NULL
at WNDCLASSEX.cbClsExtra, dd NULL
at WNDCLASSEX.cbWndExtra, dd NULL
at WNDCLASSEX.hInstance, dd NULL
at WNDCLASSEX.hIcon, dd NULL
at WNDCLASSEX.hCursor, dd NULL
at WNDCLASSEX.hbrBackground, dd COLOR_BTNFACE + 1
at WNDCLASSEX.lpszMenuName, dd NULL
at WNDCLASSEX.lpszClassName, dd NULL
at WNDCLASSEX.hIconSm, dd NULL
iend
message:
istruc MSG
at MSG.hwnd, dd NULL
at MSG.message, dd NULL
at MSG.wParam, dd NULL
at MSG.lParam, dd NULL
at MSG.time, dd NULL
at MSG.pt, dd NULL
iend
rct:
istruc RECT
at RECT.left, dd NULL
at RECT.top, dd NULL
at RECT.right, dd NULL
at RECT.bottom, dd NULL
iend
;--------------------------------------------------------
Austin