flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Borsuc 29 Nov 2009, 02:52
I suggest you don't mess with the file alignment and keep it at 512. I don't get what you mean with "generate the file the same way yourself" though.
|
|||
![]() |
|
Artlav 29 Nov 2009, 09:34
Borsuc wrote: I don't get what you mean with "generate the file the same way yourself" though. In essence, if a section with higher address is followed by a section with lower address, the file refuses to run. I.E. data at 1000h, code at 2000h, but in the file code is section 0, and data is section 1. |
|||
![]() |
|
Borsuc 29 Nov 2009, 19:35
I have to be honest and flat out say I never used that way (decrementing addresses)... but why would that be important, just make them incrementing to be more compatible, even if it might work on some versions of Windows with decrementing addresses. (I said maybe, I don't know)
|
|||
![]() |
|
DOS386 30 Nov 2009, 06:49
Check also this one:
http://board.flatassembler.net/topic.php?t=10887 (FASM formatter limitations) and this one: http://board.flatassembler.net/topic.php?t=10872 (PE brewing) and: ??? (not yet) BTW, can you brew a valid and working DLL of just 1 KiB size ??? I can ![]() |
|||
![]() |
|
hopcode 01 Dec 2009, 04:02
try this
for me it works, only 1024 bytes, very interesting Code: format PE GUI 4.0 entry start include 'win32a.inc' section '.idata' import data readable writeable executable library kernel32,'KERNEL32.DLL',\ user32 ,'USER32.DLL' import kernel32,ExitProcess,'ExitProcess' import user32 ,MessageBox ,'MessageBoxA' align 4 ;<----- start: push 0 call l1 db "Win32 Assembly generator",0 l1: call l2 db "Hi! I'm the example output program!",0 l2: push 0 call [MessageBox] push 0 call [ExitProcess] Regards, hopcode |
|||
![]() |
|
hopcode 01 Dec 2009, 07:16
the most interesting...
Who said that DLL must have .reloc to works ? ![]() Who said that EXE cannot be used as DLL ? ![]() try this, interesting ;1) compile this as "artlav_testC.asm" Code: ;[Dienstag] - 01.Dezember.2009 - 07:51:31 ;--- hopcode [mrk] ---------------------- ;- Example of an exe file without (unuseful) relocation table ;- that acts as an EXE and as a DLL. ;- It could be launched as .exe on the command line ;- or with LoadLibrary from the "artlav_calldll.exe" ;- See it in debugger ;- WARNING: POSSIBLE CRASHES!!!!!! format PE GUI 4.0 entry start include 'win32a.inc' section '.idata' import data readable writeable executable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL' import kernel32,ExitProcess,'ExitProcess',\ GetModuleHandle,"GetModuleHandle" import user32,MessageBox ,'MessageBoxA' align 4 myfunc: mov eax,[esp+4] mov dword[MessageBox],eax push 3 push 2 push 1 call start ret 4 align 4 start: push 0 call l1 db "Win32 Assembly generator",0 l1: call l2 db "Hi! I'm the example output program!",0 l2: push 0 call [MessageBox] xor eax,eax inc eax ret 12 section '.edata' export data readable export 'artlav_testC.exe',\ myfunc,'myfunc' ;2) then compile this as "artlav_calldll.asm" Code: ;[Dienstag] - 01.Dezember.2009 - 07:51:31 ;--- hopcode [mrk] ---------------------------------- ;- In this exe importing a function from "artlav_testC.exe" ;- See it in debugger ;- WARNING: POSSIBLE CRASHES!!!!!! format PE GUI 4.0 entry start include 'win32a.inc' section '.idata' import data readable writeable executable library kernel32,"KERNEL32.DLL",\ user32 ,'USER32.DLL' ; import artlav_testC,"artlav_testC.exe",myfunc,'myfunc' ;EDIT not needed tip import kernel32,ExitProcess,'ExitProcess',\ LoadLibrary,'LoadLibraryA',\ FreeLibrary,"FreeLibrary",\ GetProcAddress,"GetProcAddress" import user32,MessageBox ,'MessageBoxA' align 4 start: push 0 call lab1 db "myfunc",0 lab1: call lab2 db "artlav_testC.exe",0 lab2: call [LoadLibrary] mov ebx,eax xchg eax,dword[esp] xchg dword[esp+4],eax call [GetProcAddress] push dword[MessageBox] ;<-- i pass *THIS* function address to call eax ;<-- our exported function that uses a MessageBox in push ebx ; the code call [FreeLibrary] push 0 call [ExitProcess] 3) Now run in debugger the first ... and then the second. Regards, hopcode |
|||
![]() |
|
f0dder 01 Dec 2009, 07:34
hopcode wrote: Who said that DLL must have .reloc to works ? Nobody, but you're screwed if your base address isn't available. hopcode wrote: Who said that EXE cannot be used as DLL ? Nobody, but don't try this on Win9x ![]() |
|||
![]() |
|
hopcode 01 Dec 2009, 07:54
f0dder wrote:
Surely, doesnt belong to me this style of coding... it was only an innocent playing... ![]() btw, iirc, it was possible on win98... or probably not |
|||
![]() |
|
f0dder 01 Dec 2009, 08:05
Yes and no - it's been a few years, but as I recall you can do LoadLibrary on an exe on Win9x, but relocations aren't applied... so you could modify .exe resources, but you couldn't call exported methods. So much for avoiding dealing with VERSIONINFO resources and just calling a getVersion() export
![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.