Hi friends,

Working on import libraries, I found a very easy way to add static code to an import library. Pelle's librarian polib has the capacity do this :

\masm32\bin\ml /c /coff \masm32\m32lib\StdOut.asm
\masm32\bin\ml /c /coff \masm32\m32lib\StrLen.asm

\masm32\bin\polib /OUT:kernel32.lib /DEF:kernel32.def /MACHINE:IX86
\masm32\bin\polib /OUT:mixed.lib kernel32.lib StdOut.obj StrLen.obj


kernel32.lib is created from kernel32.def and the the library is updated with the addition of two functions from masm32.lib

You use the resulting import library to link your object files :

.386 
.model flat, stdcall
option casemap:none

include    \masm32\include\kernel32.inc
include    \masm32\include\masm32.inc

includelib  mixed.lib

.data
message    db 'Hello from mixed lib!',0

.code

start:

invoke      StdOut,ADDR message
invoke      ExitProcess,0

END start
Attachments:
Posted on 2006-07-18 05:52:16 by Vortex
I should admit that, that's a very nice trick; however, pointless :)
Posted on 2006-07-19 16:43:04 by Dite

I should admit that, that's a very nice trick; however, pointless :)


Not entirely. Some import libraries, like the kind Vortex utilizes, are there just for the assembler/linker to check against. This works flawlessly for import libs produced from dynamic library (.dll) files, but causes problems from actual static library (.lib) files, as the export list is actually an array of pointers to internal code (.lib), rather than simple function declarations (.dll).
Posted on 2006-07-19 19:53:00 by SpooK

I should admit that, that's a very nice trick; however, pointless :)


Do you know that some import libraries like uuid.lib are containing static code? I am trying to learn if it's possible to create an uuid.lib mixed with it's own specific static code.
Posted on 2006-07-20 03:24:09 by Vortex


I should admit that, that's a very nice trick; however, pointless :)


Do you know that some import libraries like uuid.lib are containing static code? I am trying to learn if it's possible to create an uuid.lib mixed with it's own specific static code.


It is possible, might require a custom tool, though :|
Posted on 2006-07-20 03:34:44 by SpooK