Re: static and dynamic library ?
Posted: Mon Oct 04, 2010 3:05 pm
.
The Place to Start for Operating System Developers
https://f.osdev.org/
Well, no. Just function names and what looks like ordinal numbers (even though they are all off by exactly two), the rest is just blanks:bontanu wrote:The DLL "import libs" contain information about the function names and parameters/calling conventions for the functions inside an DLL but they do not contain any kind of code other than a small stub for a jump to IAT.
Code: Select all
(...)
SYMBOL TABLE:
[ 0](sec 0)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$4
[ 1](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$5
[ 2](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$6
[ 3](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .text
[ 4](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __imp__CancelDC
[ 5](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _CancelDC
[ 6](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __IMPORT_DESCRIPTOR_GDI32
Contents of section .idata$4:
0000 00000000 ....
Contents of section .idata$5:
0000 00000000 ....
Contents of section .idata$6:
0000 15000000 00000000 00000000 000000 ...............
Contents of section .text:
0000 ff250000 00009090 .%......
Disassembly of section .text:
00000000 <_CancelDC>:
0: ff 25 00 00 00 00 jmp *0x0
2: dir32 __imp__CancelDC
6: 90 nop
7: 90 nop
(...)
I did, and as shown above, only the jmp [relocation] exists. There's no second object containing your apparent function either.IF you would have LOOKED you would have noticed that the import LIB contains 2 symbols for each function. One of them refers to the E8 xx xx xx xx smaller call to an intermediate table that contains the JMP [IAT.Dll.FUnction] aka FF 25 xx xx xx xx. This one is "more indirect but smaller because E8 xx xx xx xx is only 5 bytes and this adds when you call many APIs from an DLL.
No, he is referring to how those symbols are called. For the function CancelDC, there is a symbol _CancelDC@4, which is used as a direct call target, and a symbol __imp__CancelDC@4, which is used as an indirect target. The first symbol resides in an object module, which contains an indirect call to the second symbol. The second symbol is not defined in an object module, but in something called an AR import header. This maps the linker symbol __imp__CancelDC@4 to the the exported entry CancelDC from gdi32.dll. In the final executable, __imp__CancelDC@4 refers to an entry in the Import Address Table, which is filled in by Windows as the executable is being loaded.I did, and as shown above, only the jmp [relocation] exists. There's no second object containing your apparent function either.
Nonsense. That's what name mangling is for: the compiler gives the linker the function signature on a silver platter.As for header files: It would be overkill to have the linker try to parse C header files to figure out what calling conventions are used. The source might not even have been written in C.
I really dislike it when people delete the contents of their posts. I'm not certain about what I think I know about Windows dll/lib files but I am fairly certain as this mental model has helped me so far. I would have liked to know what the contents of your second post were...bontanu wrote:.