flat assembler
Message board for the users of flat assembler.
Index
> Windows > DLL (need help, thanks) |
Author |
|
LocoDelAssembly 20 Jan 2012, 22:23
http://board.flatassembler.net/topic.php?t=13751
Your code should look like this: Code: format PE GUI 4.0 DLL entry DllEntryPoint include 'WIN32a.INC' section '.code' code readable executable ;----------------------------------------------------- proc DllEntryPoint hinstDLL,fdwReason,lpvReserved mov eax,TRUE ret endp ;----------------------------------------------------- proc myF2 varA2:dword push ebx mov ebx,[varA2] pop ebx ret endp ;----------------------------------------------------- section '.idata' export data readable export 'my_DLL.dll',myF2,'myF2' section '.reloc' data discardable ; revolution's idea data fixups if ~ $-$$ dd 0,8 ;empty fixups section iff no other fixups end if end data |
|||
20 Jan 2012, 22:23 |
|
ouadji 20 Jan 2012, 22:35
it works ! (thank you loco) but i don't understand why it works. why "dd 0,8" ? |
|||
20 Jan 2012, 22:35 |
|
ouadji 21 Jan 2012, 00:24
http://board.flatassembler.net/topic.php?p=33087#33087 Quote: @leo : But why "0,8" and not "0,7" or "x,y" ??? |
|||
21 Jan 2012, 00:24 |
|
LocoDelAssembly 21 Jan 2012, 04:20
Well, if I understood the PE specs correctly, the 8 must be there because it is the size of both dwords. The first number I'm not sure it is actually needed to be exactly 0, but probably would be safer to just use it since it works (and probably Microsoft's compilers do the same thing when no relocations are needed for DLLs).
The "0,8" is the base relocation block header, and it says that zero must be added to the relocation offsets coming next and 8 is the total size of both the header and the relocation entries (none since 8 eight only covers the header itself) |
|||
21 Jan 2012, 04:20 |
|
Overflowz 21 Jan 2012, 08:38
EDIT:
sorry, posted mistakely. |
|||
21 Jan 2012, 08:38 |
|
ouadji 21 Jan 2012, 08:58
thank you Loco for this clarification! |
|||
21 Jan 2012, 08:58 |
|
Tomasz Grysztar 23 Jan 2012, 11:41
That ".reloc" section definition can be shortened this way:
Code: section '.reloc' data discardable fixups if ~ $-$$ dd 0,8 ;empty fixups section iff no other fixups end if |
|||
23 Jan 2012, 11:41 |
|
SFeLi 23 Jan 2012, 12:40
Tomasz Grysztar, btw, is it ok that the following code doesn't trigger an error?
Code: virtual data fixups ; (any data directory entry actually) end data end virtual |
|||
23 Jan 2012, 12:40 |
|
Tomasz Grysztar 23 Jan 2012, 13:13
No, it is not OK - that is probably a bug.
|
|||
23 Jan 2012, 13:13 |
|
LocoDelAssembly 27 Jan 2012, 00:17
Tomasz,
This problem is very recurring ultimately. Is there any legitimate reason for using empty relocs? Windows 7 is not accepting empty relocs and this OS is getting more and more popular, so it should be considered if fasm should be adding "dd 0,8" if it detects that the final output will end up with empty relocs (if the user manually added something in the relocs, then fasm should do nothing in that case). |
|||
27 Jan 2012, 00:17 |
|
Tomasz Grysztar 27 Jan 2012, 08:34
Windows 7 does accept empty relocations, as any other NT does (I just checked it now on 64-bit Win7 to be sure). It was Windows 9x that had problem with empty relocations directory.
What Windows 7 and other NT-based systems do not accept is an empty section, and the reasons to not include any workaround were discussed here: http://board.flatassembler.net/topic.php?p=33207#33207 We can, however, provide some macro in standard Windows headers, which would generate .reloc section in such a way, that it would work with most of the Windows versions. |
|||
27 Jan 2012, 08:34 |
|
LocoDelAssembly 27 Jan 2012, 15:12
Sorry, you're right, I thought I also had problems with data fixups/end data but it actually works.
|
|||
27 Jan 2012, 15:12 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.