Hi friends,

How would be to use some assemblers with MS Link? The main problem are the
decorated names.The libs for masm32 contains all the imported functions with underscores:

__imp__MessageBox@16

So,how to get import libs without undecorated names? The principle is based on an article of Iczelion about
making import libs for Masm32. Two differences,we need to use the syscall naming convention to
avoid underscores and we don't need to know how many parameters are required for an API call.

I coded a simple dll2def utility which produces module definition files and asm source files to
"re-build" the system DLLs.For us,just the new import libs are usefull,by-products of the utility,
the DLLs and exp files can be deleted safely.Just run the buildlib batch file,and you will get
new import libraries. :)

You need these libs to use Fasm/GoASM/Tasm/Sphinx C-- with MS Link.
The advantages for of this method:
*Use many asm source files with the assemblers/compilers mentioned,
*Significant decrease of final EXE file lenght for Tasm users.
Posted on 2003-06-12 02:06:14 by Vortex
This is pretty interesting. I need to look at it a little more to figure out how it will change my life.:)

I am wondering how to automate the .asm files (such as the gdi32.asm, kernel32.asm, and user32.asm) that you supplied. This would, with a little creative programming (maybe just a fancy batch file), make linking dlls directly (like GoLink does) possible with MS Link. Then we would have much of the best of both GoLink and MS Link.:alright:

Greg
Posted on 2003-06-12 11:40:16 by bushpilot
Bushpilot,

Yes,you are right.Instead of using a batch file,it's possible to have an utility which will output
directly the import libs.Check the source code (dll2def.asm),you can add this feature.Such a tool
would be similar to Hutch's include to library tool.(inc2l.exe)
Posted on 2003-06-12 11:59:48 by Vortex
BushPilot,

Here is the completely automated tool renamed to dll2lib. :)

*More efficient code
*Removal of "by-product" files dll,exp,asm,def,obj



Example:

dll2lib kernel32.dll


And you have kernel32.lib containing undecorated names.
Posted on 2003-06-14 06:52:20 by Vortex
From Version 0.44 GoAsm has the /ms switch, which decorates the API calls in the object file if you use INVOKE. For example:-

INVOKE MessageBoxA, ,'Click OK','Hello',40h

Then GoAsm will insert the called function in the object file as

_MessageBoxA@16

which is enough for the MS linker.

This is possible because GoAsm can look ahead at the API call and count the number of parameters. It does not work with PUSH .... and then CALL.

You also need to ensure that the label giving the start address starts with an underline character. But omit this underline character when telling the MS linker what the label is.
Posted on 2003-06-16 10:25:18 by jorgon
Thanks jorgon
Posted on 2003-06-16 11:40:38 by Vortex
Here is a better version with new examples for Sphinx C-- and Tasm.
Posted on 2003-07-19 04:46:16 by Vortex
oh lol...

i bin trying to figure that out also every since i saw the APIHook Lib... the best way i found it.. and i know it cant be the best way but.. before it compiles to lib i patch the obj file to remove the @16 and stuff... the __IMP__ i have not tryed to since i can use xWin32 now with the marcos ... reason why i patch the obj is because it only has on set of the names and when you link/lib it... the extra bytes are removed..
Posted on 2003-07-21 03:50:33 by devilsclaw
i create my libs with
@ml -nologo -c -coff -Cp DCPatchV2.apm
@lib %1.obj /out:%1.lib -nologo
@rem link -dll "-noentry" "-def:%1.def" "-subsystem:windows" "%1.obj"
@pause
@del *.exp
@del *.obj

the out put looks like this in the lib..

_Hello_World@16
_ABHDW@4

so i dont have __imp_ in mine anymore took me a while to the right combo

and with the EliZES Macros i only have to do xWin32 after i edit out the @16 @4 stuff either in the lib or in the obj before i make it into a lib..

sorry i think im rabling... on meds just got my tonsils taken out and dizzy as can be...
Posted on 2003-07-21 04:00:28 by devilsclaw
Hi friends,

Here is the new version 2.0 creating smaller import libraries. It uses Pelle's polink to create the libs.You can download Pelle's C compiler package from:

http://www.smorgasbordet.com/pellesc
Posted on 2003-12-20 11:16:39 by Vortex
With Pelle's library manager Polib, It's possible to create import libraries which can be used directly with Macro Assembler. All what you need after is to run polink to link your object files.



polib /out:kernel32.lib \windows\system\kernel32.dll
polib /out:user32.lib \windows\system\user32.dll
polib /out:gdi32.lib \windows\system\gdi32.dll



\masm32\bin\ml /c /coff Paint.asm
\masm32\bin\polink /SUBSYSTEM:WINDOWS Paint.obj


The attachment contains an example.
Posted on 2003-12-21 09:32:39 by Vortex
Smaller import libs = smaller exe?
Posted on 2003-12-21 10:01:33 by Odyssey
Odyssey,

Polink creates smaller executables because it uses a PE header of 512 bytes. The size of the final executable doesn't depend on the size of import libraries. Now,beside Hutch's inc2l tool, we have also polib creating import libs for Masm.
Posted on 2003-12-21 12:02:30 by Vortex
Same trial with MS Link,the size of import libraries jumped up. :)



dll2def kernel32.dll
dll2def user32.dll
dll2def gdi32.dll
\masm32\bin\lib /machine:IX86 /def:kernel32.def /out:kernel32.lib
\masm32\bin\lib /machine:IX86 /def:user32.def /out:user32.lib
\masm32\bin\lib /machine:IX86 /def:gdi32.def /out:gdi32.lib


Polink accepts also these libs.

Finally, Compared to MS Link, it looks like that Polink is much more usefull and flexible. MS Link doesn't accept at all these libraries.
Posted on 2003-12-22 04:58:14 by Vortex
Here is version 2.12 of my tool dll2lib.

-Support of full path names
-Fixed bug with function names which are also reserved MASM keywords.
Posted on 2004-01-24 13:57:40 by Vortex