flat assembler
Message board for the users of flat assembler.
Index
> Windows > CreateThread with Parameters |
Author |
|
cod3b453 13 May 2010, 16:13
Something like this should do it (sorry can't test on this machine):
Code: ; Data section struct MY_STRUCT a dd ? b dd ? ends mystruct MY_STRUCT threadID dd ? ; Code section ;... invoke CreateThread,NULL,NULL,myproc,mystruct,NULL,threadID ; threadID can be NULL ;... proc myproc,lpParam push esi mov esi,[lpParam] mov eax,[esi+MY_STRUCT.b] ;... pop esi ret endp Hope that helps |
|||
13 May 2010, 16:13 |
|
Nameless 13 May 2010, 16:18
thanks
will try that now |
|||
13 May 2010, 16:18 |
|
Nameless 29 Jun 2010, 16:33
im sorry to popup an old thread, but, the thread is created, but it crashes when using the code to read parameters
is threre any other way to read parameters? |
|||
29 Jun 2010, 16:33 |
|
Picnic 29 Jun 2010, 17:15
hi, i did a quick run:
Code: mov dword [mystruct.a], 20 mov dword [mystruct.b], 30 invoke CreateThread,NULL,NULL,myproc,mystruct,NULL,threadID ; threadID can be NULL Code: mov esi,[lpParam] mov eax,[esi+MY_STRUCT.a] add eax,[esi+MY_STRUCT.b] ; eax = 50 cod3b453's example looks good to me, better to post some of your code Nameless. |
|||
29 Jun 2010, 17:15 |
|
Nameless 29 Jun 2010, 20:45
Code: struct MY_STRUCT szFilePath dw MAX_PATH dup (?) ends proc Test, lpParam locals Buffer rb 1024 endl push esi mov esi, [lpParam] invoke lstrcpy, addr Buffer, [esi+MY_STRUCT.szFilePath] invoke MessageBox, 0, addr Buffer, "s test", MB_OK pop esi ret endp |
|||
29 Jun 2010, 20:45 |
|
Picnic 29 Jun 2010, 21:13
Code: struct MY_STRUCT szFilePath db MAX_PATH dup (?) ends Use LEA instruction to transfer the offset. Code: mov esi, [lpParam] lea edi, [esi+MY_STRUCT.szFilePath] invoke lstrcpy, addr Buffer, edi invoke MessageBox, 0, addr Buffer, "s test", MB_OK |
|||
29 Jun 2010, 21:13 |
|
LocoDelAssembly 29 Jun 2010, 21:14
Protecting ultra expensive intellectual property Nameless? The code you provided cannot possibly be a fragment of your real code because you could never been able to compile a proc called "test".
This will work... Code: include 'win32wxp.inc' struct MY_STRUCT szFilePath du MAX_PATH dup (?) ends .code start: invoke CreateThread,NULL,NULL,TestProc,mystruct,NULL,threadID ; threadID can be NULL invoke Sleep, 5000 invoke ExitProcess, 0 proc TestProc, lpParam locals Buffer rb 1024 endl push esi mov esi, [lpParam] invoke lstrcpy, addr Buffer, addr esi+MY_STRUCT.szFilePath invoke MessageBox, 0, addr Buffer, "s test", MB_OK pop esi ret endp .data mystruct MY_STRUCT <"Hello world", 0> threadID dd ? .end start |
|||
29 Jun 2010, 21:14 |
|
Nameless 29 Jun 2010, 21:28
@Picnic: thanks alot . worked like a charm, but can u tell me why u used lea?
@LocoDeAssemblt: the original function name is in my native language |
|||
29 Jun 2010, 21:28 |
|
Picnic 29 Jun 2010, 21:48
consider a structure mystruct of type MY_STRUCT with various members, lpParam holds mystruct first member offset address.
Code: struct MY_STRUCT a dd ? b dd ? szFilePath db MAX_PATH dup (?) ends mov esi, [lpParam] ; now esi holds mystruct first member offset address ; dword [esi] --> value of a ; dword [esi+MY_STRUCT.a] --> value of a ; dword [esi+MY_STRUCT.b] --> value of b ; lea edi, [esi+MY_STRUCT.szFilePath] --> edi address of szFilePath ; addr esi+MY_STRUCT.szFilePath --> address of szFilePath |
|||
29 Jun 2010, 21:48 |
|
Nameless 29 Jun 2010, 22:09
thanks alot
either things are getting easier by the time, or ur good at explaining or worse xD, my questions are getting dumber |
|||
29 Jun 2010, 22:09 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.