I have written the folowing NASM program:


extern ExitProcess
import ExitProcess kernel32.dll
extern MessageBoxA
import MessageBoxA user32.dll
extern CreateThread
import CreateThread kernel32.dll
extern GetExitCodeThread
import GetExitCodeThread kernel32.dll

SECTION text USE32 CLASS=CODE

WinMain:
..start:

push dword threadId
push dword 0
push dword parameter
push dword ThreadProc
push dword 0
push dword 0
call
cmp eax, 0
je .error_exit

jmp .exit

.error_exit:
push dword 0
push dword error
push dword error
push dword 0
call

.exit:
push dword 0
call

ThreadProc:
enter 0, 0

push dword 0
push dword msg
push dword msg
push dword 0
call

leave
ret 04h

SECTION data USE32 CLASS=DATA

threadId: dd 0
parameter: dd 0
exitCode: dd 0

error: db "Error!",0
msg: db "Hello!", 0


But it doesn't work, the thread isn't executed!
What I'm doing wrong
:confused:
Posted on 2002-06-07 12:41:26 by jonsson
When you exit the process you also kill the thread. Try to add a Sleep(1000) after you create the thread.
Posted on 2002-06-07 12:45:28 by Dr. Manhattan
I think the program jumps to .exit: before the thread has a chance to do anything.
also I do not know about NASM syntax but are you sure your passing the address of the Threadproc and not the value stored at that address?
Posted on 2002-06-07 12:48:09 by Kudos
Thanks it works now:)
Posted on 2002-06-07 13:09:24 by jonsson