flat assembler
Message board for the users of flat assembler.
Index
> Windows > My program linked to kernel32 crashes, why? |
Author |
|
f0dder 26 Oct 2006, 18:50
Try disassembling the executable. It would seem to me you use a weird import library, or are calling the wrong symbol. Are you, per chance, using import libraries from mingw32 or other GNU tools?
|
|||
26 Oct 2006, 18:50 |
|
Plue 26 Oct 2006, 19:23
I don't know where I got the import library , but I tried with another import library (which should be good) and now I get an undefined reference to _ExitProcess. So there maybe is something with the import libraries, but I can't figure out what.
|
|||
26 Oct 2006, 19:23 |
|
Plue 26 Oct 2006, 19:25
I replaced _ExitProcess with _ExitProcess@4 and then it linked against the other import library (which I'm sure is not broken, although it could be in the wrong format), but the program still crashes at the same offset.
Edit: The above applies only to polink (which I think made this import library) and not to ld, which tells me there's an undefined reference to ExitProcess@4. Edit: Tried yet another import library (from the windows xp DDK) and the behaviour is exactly the same as with the polink library. Last edited by Plue on 26 Oct 2006, 19:31; edited 1 time in total |
|||
26 Oct 2006, 19:25 |
|
f0dder 26 Oct 2006, 19:28
Ah, on closer glance: "_mainCRTStartup dd start" looks suspicious to me... Add a "_mainCRTStartup" right after/before your "start" label instead. Have a look at your disassembly to see why
Code: .flat:00401000 _flat segment para public 'CODE' use32 .flat:00401000 ;org 401000h .flat:00401000 assume es:nothing, ss:nothing, ds:nothing, fs:nothing, gs:nothing .flat:00401000 6A 00 push 0 .flat:00401002 E8 F9 0F 00 00 call ExitProcess .flat:00401007 .flat:00401007 start: .flat:00401007 00 10 add [eax], dl .flat:00401009 40 inc eax .flat:004011FE _flat ends |
|||
26 Oct 2006, 19:28 |
|
Plue 26 Oct 2006, 19:38
Thank you, I now think I understand why it breaks, but I don't know how to fix it. How can I create a "public label"?
Edit: Got it: Code: public _mainCRTStartup
_mainCRTStartup: Thanks a lot for helping me. |
|||
26 Oct 2006, 19:38 |
|
vid 26 Oct 2006, 20:01
also try to go without kernel32.lib. Something like this:
Code: format MS COFF extrn "__imp__ExitProcess@4" as ExitProcess:dword public _mainCRTStartup _mainCRTStartup: push 0 call [ExitProcess] |
|||
26 Oct 2006, 20:01 |
|
Plue 27 Oct 2006, 14:21
That looks good, is the performance the same? (Something tells me it's one extra memory reference?)
|
|||
27 Oct 2006, 14:21 |
|
Goplat 27 Oct 2006, 18:54
actually if you do "call _ExitProcess@4", that calls a stub function that does "jmp [__imp__ExitProcess@4]". So you actually save a memory access by doing the indirect call directly.
|
|||
27 Oct 2006, 18:54 |
|
Plue 27 Oct 2006, 20:01
Thank you, then I will do it indirectly directly. (Whatever!)
|
|||
27 Oct 2006, 20:01 |
|
vid 27 Oct 2006, 21:05
Quote: indirectly directly hehe, well said :] |
|||
27 Oct 2006, 21:05 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.