flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
james
And what happens if you copy the example DLL that comes with FASM ?
|
|||
![]() |
|
Aster!x
if it compiling in masm dll work fine
Code: .486 .model flat, stdcall option casemap:none include \masm32\include\windows.inc .CODE ; DllEntry proc hInst:DWORD, reason:DWORD, reserved1:DWORD DllEntry: xor eax, eax inc eax retn 4*3 End DllEntry |
|||
![]() |
|
Tomasz Grysztar
You've got an empty .reloc section here, because you don't have any relocations. Windows doesn't accept PE files with empty sectinos - see http://board.flatassembler.net/topic.php?t=2330
Thus you should remove the .reloc section here, or use "data fixups" instead. Last edited by Tomasz Grysztar on 14 Dec 2005, 17:59; edited 1 time in total |
|||
![]() |
|
bogrus
This sample normal work(with LoadLibrary) if default dll imagebase (0x00400000) not used in process (no need reloc), but LoadLibrary error if 0x00400000 used by main module (exe), uncomment dd 0,8 and this work ...
Code: ;================================= format pe gui dll entry start include '%fasminc%\win32a.inc' ;================================= start: xor eax,eax inc eax ret 0x0c ;================================= data fixups ; dd 0,8 end data ;================================= |
|||
![]() |
|
Aster!x
Tomasz Grysztar
it's masm compiled DLL with empty reloc section, but it work, because reloc directory should be present
|
|||||||||||
![]() |
|
Tomasz Grysztar
There's no reloc directory there, since it's not needed (the "relocs stripped" flag in characteristics set to 0 is enough in this case), however the ".reloc" section (as a section, not directory - remember those are two different things) is not empty as made with MASM. You can put some own padding to the ".reloc" section to make it be not empty with fasm too, or remove it at all.
|
|||
![]() |
|
Aster!x
|
|||
![]() |
|
Tomasz Grysztar
I will try explain once more, maybe I will succeed to be more clear this time: the main problem here is what was discussed in the other thread (I linked to), not the relocations itself. When you write:
Code: section '.reloc' fixups data discardable ; ... it's just the shortcut for writing the: Code: section '.reloc' data discardable data fixups ; ... end data Code: section '.reloc' data discardable which just generates empty section and... see the other thread. Note: the fact that the section is called '.reloc' has nothing to do with the fact it does contain the fixups directory or not; you can call the section any name you want. You can replace '.reloc' with '.data' in all the above code samples if it misleads you. |
|||
![]() |
|
leo
Tomasz Grysztar
Quote: There's no reloc directory there, since it's not needed (the "relocs stripped" flag in characteristics set to 0 is enough in this case) I think, you are not quite right ![]() It's enough for NT, but Win 9x requires reloc directory to be present anyway and its size cannot be zero. If it is zero 9x regards it as relocs are stripped and cannot load dll on different image base. So for compatibility with 9x, masm uses this trick: via dd 0,8 it creates valid reloc directory with no real relocs |
|||
![]() |
|
Tomasz Grysztar
You're right, it puts there a dummy block with no actual fixups (haven't noticed that earlier). If you need such fix, you can just add this dummy entry "dd 0,8" to the fixups data yourself. Really 9x has such bug? (Can't check it now, I might have known about it back when I was using W95, but forgot now...
![]() Last edited by Tomasz Grysztar on 16 Dec 2005, 18:30; edited 1 time in total |
|||
![]() |
|
Tomasz Grysztar
PS. That's kind of funny - on Win9x the empty sections are accepted, but empty relocation directory for DLLs is not. Now on XP the empty sections are rejected, but empty relocs are OK.
Well, the safest would be to put the "dummy" entries everywhere just to ensure no zero-size things that would threat the Win PE loader. But it seems some people wouldn't like it - well, you can always put the "dummies" there yourself. fasm's rules to try making as small executable as possible prevails here. |
|||
![]() |
|
halyavin
But can you add some directive to assembler (or macro library) for those people who prefer reliability? Dummies for relocations isn't obvious. Without this forum I will never create correct dll without relocations.
|
|||
![]() |
|
vid
i don't think it is good to add some bloat to FASM just because of M$ bug. Just add it to FAQ, everyone should read FAQ first.
|
|||
![]() |
|
Tomasz Grysztar
Added it to Windows FAQ for now.
|
|||
![]() |
|
Aster!x
Maybe the correct decision was add the message
about a error in case of compilation such DLL ? |
|||
![]() |
|
Tomasz Grysztar
But this is not an error, since this doesn't violate the PE specification, and thus you might really want to generate such executable - note that some people use PE format for their own OSes etc. Thus this is rather problem of the target OS you want to use your PE executable on and thus you should correct your sources accordingly - fasm itself just generates the PE file as you tell it to.
|
|||
![]() |
|
Aster!x
Tomasz Grysztar
But for example masm in many cases all the same warns the user - it is good practice |
|||
![]() |
|
wildtollwut
Aster!x wrote: Tomasz Grysztar windows also warns you 5 times before disabling the firewall, or some other fancy feature - it's a well known microsoft affliction ![]() _________________ when i want to jump in counter-strike, i simply enter "+jump" in the console |
|||
![]() |
|
vid
warning: You shouldn't create PE file with empty sections because Microsoft Windows has bug with such sections will causing process to crash.
|
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.