The MASM Forum

General => The Campus => Topic started by: ragdog on August 18, 2012, 07:14:39 PM

Title: Create a Lib
Post by: ragdog on August 18, 2012, 07:14:39 PM
Hi

My question is how i can create a Lib from a exe

I have a exe this have a export table for plugins how i can create a lib to writing a plugin?
Give for it a dump utiliti?

Greets,
Title: Re: Create a Lib
Post by: Vortex on August 18, 2012, 07:27:31 PM
Hi ragdog,

You cannot create a library from an executable. I guess you want to create an EXE exporting functions. You could use this EXE like a DLL, right?

You need to search the old forum for some examples :

http://www.masmforum.com/board/index.php?topic=6331.0
Title: Re: Create a Lib
Post by: ufo on August 19, 2012, 07:36:17 AM
I guess you're after the dynamic lib for the latest ollydbg.exe.

1) Open a Visual Studio Command Prompt
2) dumpbin /exports ollydbg.exe > ollydbg.def
3) Open ollydbg.def in a text editor
4) Delete everything except of the function names
5) Insert EXPORTS at the top
6) lib /def:ollydbg.def /OUT:ollydbg.lib

PS: http://adrianhenke.wordpress.com/2008/12/05/create-lib-file-from-dll/
Title: Re: Create a Lib
Post by: ragdog on August 19, 2012, 05:10:55 PM
Hi Ufo  :biggrin:

You here ?

No i have a other project what i need this lib.

You now i have translate the Ollydbg2 plugin in to Masm32
and have written a new plugin with many new function but now wait i
of the final version of Ollydbg. ;)

Thanks for your help und this nice link
It help  :t

Regards,

Title: Re: Create a Lib
Post by: Farabi on August 29, 2012, 08:29:42 PM
I remind me to NTOSKernel.exe that had an export for the function it contains.
Title: Re: Create a Lib
Post by: hfheatherfox07 on August 30, 2012, 04:59:02 AM
Quote from: ufo on August 19, 2012, 07:36:17 AM
I guess you're after the dynamic lib for the latest ollydbg.exe.

1) Open a Visual Studio Command Prompt
2) dumpbin /exports ollydbg.exe > ollydbg.def
3) Open ollydbg.def in a text editor
4) Delete everything except of the function names
5) Insert EXPORTS at the top
6) lib /def:ollydbg.def /OUT:ollydbg.lib

PS: http://adrianhenke.wordpress.com/2008/12/05/create-lib-file-from-dll/


You can use the dumpbin in masm with a batch file :

@echo off
\masm32\bin\dumpbin.exe  /exports ollydbg.exe > ollydbg.def

Pause


But with :

@echo off
\masm32\bin\lib /def:ollydbg.def /OUT:ollydbg.lib


I always seem to get error:
LINK : warning LNK4068: /MACHINE not specified; defaulting to IX86
So My ollydbg.lib is 294 KB

I don't know  how you Got a lib that is only 88.2 KB ?

you can define a subsystem when you build a dll and a lib at the same time from dll.asm with no errors
Don't know how to define "/MACHINE"  with building lib from def only?
Title: Re: Create a Lib
Post by: Vortex on August 30, 2012, 05:26:52 AM
Hi hfheatherfox07,

\masm32\bin\lib /def:ollydbg.def /OUT:ollydbg.lib /machine:IX86
Title: Re: Create a Lib
Post by: hfheatherfox07 on August 30, 2012, 05:47:10 AM
Quote from: Vortex on August 30, 2012, 05:26:52 AM
Hi hfheatherfox07,

\masm32\bin\lib /def:ollydbg.def /OUT:ollydbg.lib /machine:IX86

:t
Thank you That Did it ...

But Why am I still Getting a 294 KB ollydbg.lib
And the lib in the attachment is only 88.2 KB ?

Only for learning purposes ...I do not need a ollydbg.lib
Title: Re: Create a Lib
Post by: hfheatherfox07 on August 30, 2012, 06:00:59 AM
Quote from: Vortex on August 30, 2012, 05:26:52 AM
Hi hfheatherfox07,

\masm32\bin\lib /def:ollydbg.def /OUT:ollydbg.lib /machine:IX86

Just for the sake Of learning .....

If I put that batch file and that def in a folder it works!

If I put This batch file and that def in a folder with : lib.exe,link.exe,mspdb50.dll

@echo off

lib.exe /def:ollydbg.def /OUT:ollydbg.lib

Pause
if exist ollydbg.exp del ollydbg.exp


It works!!!! but I get the error LINK : warning LNK4068: /MACHINE not specified; defaulting to IX86

How ever if I add "/machine:IX86"

So the batch file :
@echo off

lib.exe /def:ollydbg.def /OUT:ollydbg.lib /machine:IX86

Pause
if exist ollydbg.exp del ollydbg.exp


I Get this Error (And It Does not work):

LINK : fatal error LNK1117: syntax error in option "mac"

Why ? that is strange ?
Title: Re: Create a Lib
Post by: dedndave on August 30, 2012, 07:16:28 AM
>lib /?

Microsoft (R) Library Manager Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

usage: LIB [options] [files]

   options:

      /CONVERT
      /DEBUGTYPE:CV
      /DEF[:filename]
      /EXPORT:symbol
      /EXTRACT:membername
      /INCLUDE:symbol
      /LIBPATH:dir
      /LIST[:filename]
      /MACHINE:{ALPHA|ARM|IX86|MIPS|MIPS16|MIPSR41XX|PPC|SH3|SH4}
      /NAME:filename
      /NODEFAULTLIB[:library]
      /NOLOGO
      /OUT:filename
      /REMOVE:membername
      /SUBSYSTEM:{NATIVE|WINDOWS|CONSOLE|WINDOWSCE|POSIX}[,#[.##]]
      /VERBOSE


try placing the options before the files
Title: Re: Create a Lib
Post by: dedndave on August 30, 2012, 01:08:13 PM
a couple more thoughts....

the lib program is a stub into the linker, so....
LINK /LIB
might work

and, i remember many of the older ms command line programs accept shortened versions of switch names
so, you might try....
LIB /MA:IX86
LIB /MAC:IX86
on some of the older ones, if the switch name was long enough to remove any ambiguities, it would work
Title: Re: Create a Lib
Post by: hfheatherfox07 on August 30, 2012, 02:59:16 PM
Actually non of that .....

If I had that folder on my desk top it works ,
but If I put i in another folder or yet even in a another
That gives me that error

So strange..... I will leave it at that