flat assembler
Message board for the users of flat assembler.
Index
> Windows > DLL x64 CreateThread issue |
Author |
|
l_inc 04 Nov 2015, 18:58
nanasemaru
Each thread goes through the dll entry point during its initialization process. In your case this leads to creation of yet another thread. What you wrote is therefore an infinite recursion. You can find the correct prototype of the dll entry point in the fasm package in "examples\dll\errormsg.asm". Create the new thread only if fdwReason is DLL_PROCESS_ATTACH . Btw. the thread entry point has also a different prototype. If you don't consider that the stack will get unbalanced, unless you do smth. uncommon such as ExitProcess in your case. _________________ Faith is a superposition of knowledge and fallacy |
|||
04 Nov 2015, 18:58 |
|
nanasemaru 04 Nov 2015, 19:15
Thx for the input
Changed it but its still not creating the thread Code: format PE64 DLL entry etest include 'win64a.inc' section '.text' code readable executable ;........................................................ proc ethread invoke MessageBoxA,0,str1,str2,0 invoke ExitProcess,0 endp proc etest hinstDLL,fdwReason,lpvReserved cmp dword[fdwReason],1 jne @f invoke CreateThread,0,0,ethread,0,0,0 @@: mov rax,1 ret endp ;........................................................ section '.bss' data readable writeable str1 db 'Hallo',0 str2 db 'Test Thread',0 ;........................................................ section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',user32,'USER32.DLL' include 'api/kernel32.inc' include 'api/user32.inc' ;........................................................ section '.reloc' fixups data readable discardable if $=$$ dd 0,8 end if (it compiles fine and it gets loaded) |
|||
04 Nov 2015, 19:15 |
|
l_inc 04 Nov 2015, 20:04
nanasemaru
Well, the prototype of a thread entry is proc ethread lpParameter, but that's not the problem. The problem is that you can't access the first four arguments on the stack unless you stored those from the registers (see the last paragraph in the section 1.4 Procedures (64-bit)) . So your fdwReason value is invalid. You should also remove the dword cast. _________________ Faith is a superposition of knowledge and fallacy |
|||
04 Nov 2015, 20:04 |
|
nanasemaru 04 Nov 2015, 20:24
Perfect \ :v / thank you l_inc - now it works
(Only used inline fasm before :>) Code: cmp rdx,1;<< jne @f invoke CreateThread,0,0,ethread,0,0,0 @@: mov rax,1 |
|||
04 Nov 2015, 20:24 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.