flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Roman 10 Dec 2024, 14:25
I found this (revolution writed)
Code: macro link objfile { virtual at 0 theobj:: file objfile end virtual ;linker code goes here ;what is mean ? I must write realization? ;... } format ... mov eax,0x12345678 invoke DoWhatIWantWhenIWant,eax invoke ExitProcess,0x87654321 link 'MyUberObj.obj' |
|||
![]() |
|
revolution 10 Dec 2024, 14:34
Roman wrote: ;what is mean ? I must write realization? |
|||
![]() |
|
Roman 10 Dec 2024, 14:36
ok. I compiled this obj file:
Code: format MS COFF extrn '__imp__MessageBoxA@16' as MessageBox:dword section '.text' code readable executable public demo demo: push 0 push _caption push _message push 0 call [MessageBox] ;MessageBox empty value = 0 ret section '.data' data readable writeable _caption db 'Win32 assembly',0 _message db 'Coffee time!',0 When I do link obj file in my main program. How I put in [MessageBox] correct address from my pe gui 4.0 program ? |
|||
![]() |
|
revolution 10 Dec 2024, 15:01
If you want to support recursive linking then there are entire books that have been written to explain all the various complications and problems that you might encounter.
For simple leaf non-recursive linking, you can parse the DLL file at assembly time within fasm quite easily. The "real" solution is just to use the normal external linker program, that is its job, that is what it is for. And you make your code linkable instead of executable. Last edited by revolution on 10 Dec 2024, 15:41; edited 1 time in total |
|||
![]() |
|
Roman 10 Dec 2024, 15:38
ok.
load can in macro find text '__imp__MessageBoxA@16' ? |
|||
![]() |
|
revolution 10 Dec 2024, 15:43
Roman wrote: ok. |
|||
![]() |
|
Roman 10 Dec 2024, 15:55
Ok.
How I understood linker do steps: 1)find text '__imp__' 2)load library and GetProcAddress MessageBoxA 3) put address to '__imp__' |
|||
![]() |
|
revolution 10 Dec 2024, 15:58
Erm. Are you doing runtime linking, or compile time linking?
I thought you wanted to to static linking at compile time. But now you are asking about runtime linking. ![]() |
|||
![]() |
|
Roman 10 Dec 2024, 16:05
compile time linking
|
|||
![]() |
|
revolution 10 Dec 2024, 16:36
Then you shouldn't be trying to link the system DLLs. Things like MessageBox should be linked at runtime.
|
|||
![]() |
|
Roman 10 Dec 2024, 16:45
obj or lib file its compiled code.
In this files not exist text 'call [MessageBox]'. Exist asm opcodes. And I must something put address MessageBox from section import dll in pe gui 4.0 main code, to lib data. This is my problem. |
|||
![]() |
|
macomics 10 Dec 2024, 16:56
Then you need to refer to the name of this function, which the linker will provide to it after the import is formed. This name is __imp__MessageBoxA.
Or you can create your own lib file that will export other names for the imported functions from the dll file. |
|||
![]() |
|
Roman 10 Dec 2024, 19:57
if I do
Code: macro link objfile { virtual at 0 theobj:: file objfile end virtual ;linker code goes here ;what is mean ? I must write realization? ;... } Start: call fun1 fun1: link 'mscoff.obj' IDA Pro show dd 77h dup(0) in fun1 |
|||
![]() |
|
macomics 10 Dec 2024, 20:00
Roman wrote: if I do |
|||
![]() |
|
Roman 10 Dec 2024, 21:46
Code: macro link objfile { virtual at 0 theobj:: file objfile end virtual ;linker code goes here ;what is mean ? I must write realization? load q word from theobj:100 store word q at fun1 ;fasm error value out of range } Start: call fun0 invoke ExitProcess, 0 align 4 link 'l.obj' fun0: fun1: dd 0 |
|||
![]() |
|
Roman 10 Dec 2024, 22:06
Code: macro link objfile { virtual at 0 theobj:: file objfile end virtual ;linker code goes here ;what is mean ? I must write realization? load q word from theobj:100 ;store q at fun1:0 dw q load q byte from theobj:102 db q load q dword from theobj:103 dd $+q } Start: call fun1 invoke ExitProcess, 0 fun1: link 'l.obj' |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.