The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Vortex on July 18, 2006, 10:03:22 AM

Title: Adding static code to an import library
Post by: Vortex on July 18, 2006, 10:03:22 AM
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

[attachment deleted by admin]
Title: Re: Adding static code to an import library
Post by: zooba on July 18, 2006, 11:32:02 PM
Very nice :U
Title: Re: Adding static code to an import library
Post by: hutch-- on July 19, 2006, 03:31:20 AM
Erol,

This is well done and very useful.  :U
Title: Re: Adding static code to an import library
Post by: Vortex on July 19, 2006, 10:58:17 AM
Zooba, Hutch,

Thanks for your kind words.

Here is another version of the mixed library. I merged kernel32.lib, user32.lib, gdi32.lib and masm32.lib to build mrt.lib ( Masm run-time library )

\masm32\bin\polib /OUT:kernel32.lib /DEF:def\kernel32.def /MACHINE:IX86
\masm32\bin\polib /OUT:user32.lib /DEF:def\user32.def /MACHINE:IX86
\masm32\bin\polib /OUT:gdi32.lib /DEF:def\gdi32.def /MACHINE:IX86

\masm32\bin\polib /OUT:mrt.lib kernel32.lib user32.lib gdi32.lib \masm32\lib\masm32.lib


A small demo using mrt.lib :

include mrt.inc

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

.code

start:

invoke      StdOut,ADDR message
invoke      ExitProcess,0

END start



http://vortex.masmcode.com/files/mrt1.zip
Title: Re: Adding static code to an import library
Post by: PBrennick on July 19, 2006, 04:13:43 PM
Vortex,
I really like that one!  VERY useful.  We should do something like that.

Paul
Title: Re: Adding static code to an import library
Post by: Mark Jones on July 20, 2006, 12:39:57 AM
I was thinking to myself how convenient it would be for a newcomer to just include one file and not have to worry about any other includes... so why not build a master include library?
Title: Re: Adding static code to an import library
Post by: PBrennick on July 20, 2006, 01:23:51 AM
Mark,
You have read my mind.  Master.inc and Master.lib, coming soon to a project near you!

Paul
Title: Re: Adding static code to an import library
Post by: Vortex on July 20, 2006, 07:53:56 AM
Paul, what about renaming the library to GSmrt.lib?

GSmrt.lib = GeneSys master run-time library