News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Automation the creation of inc-, def- and lib-files

Started by Mikl__, July 10, 2017, 03:42:47 PM

Previous topic - Next topic

Mikl__

#30
And finally (Ba dum tss) inc_def.bat @echo off
cls
set masm64_path=\masm55\
set FileName=user32
%masm64_path%bin\dumpbin.exe /EXPORTS %windir%\System32\%FileName%.dll /OUT:%FileName%.txt
@echo EXPORTS >> %FileName%.def
for /f "skip=16 tokens=1-4" %%a in (%FileName%.txt) do (
if "%%a"=="Summary" exit
if "%%d"=="" @echo extern __imp_%FileName%_ordinal%%a:qword >> %FileName%.inc
if "%%d"=="" @echo %FileName%_ordinal%%a TEXTEQU ^<__imp_%FileName%_ordinal%%a^> >> %FileName%.inc
if "%%d"=="" @echo %FileName%_ordinal%%a=ordinal%%a @%%a NONAME >> %FileName%.def
if not "%%d"=="" @echo extern __imp_%%d:qword >> %FileName%.inc
if not "%%d"=="" @echo %%d TEXTEQU ^<__imp_%%d^> >> %FileName%.inc
if not "%%d"=="" @echo %%d=__imp_%%d >> %FileName%.def
)

Mikl__

#31
@echo off
cls
set masm64_path=\masm55\
set FileName=user32
if exist %FileName%.inc del %FileName%.inc
if exist %FileName%.def del %FileName%.def
%masm64_path%bin\dumpbin.exe /EXPORTS %windir%\System32\%FileName%.dll /OUT:%FileName%.txt
@echo EXPORTS >> %FileName%.def
for /f "skip=16 tokens=1-4" %%a in (%FileName%.txt) do ( if "%%a"=="Summary" goto :exit
if "%%d"=="" ( @echo extern __imp_%FileName%_ordinal%%a:qword >> %FileName%.inc
@echo %FileName%_ordinal%%a TEXTEQU ^<__imp_%FileName%_ordinal%%a^> >> %FileName%.inc
@echo %FileName%_ordinal%%a=ordinal%%a @%%a NONAME >> %FileName%.def
) else ( if not "%%d"=="(forwarded" ( @echo extern __imp_%%d:qword >> %FileName%.inc
@echo %%d TEXTEQU ^<__imp_%%d^> >> %FileName%.inc
@echo %%d=__imp_%%d >> %FileName%.def )))
:exit
%masm64_path%bin\link -lib /DEF:%FileName%.def /OUT:%FileName%.lib /MACHINE:X64

fearless

I took a look at that expdef tool that AW posted a link to: http://purefractalsolutions.com/show.php?a=utils/expdef

Created a Dll2Def command line utility based on that: https://github.com/mrfearless/Dll2Def - download release: https://github.com/mrfearless/Dll2Def/releases/download/1.0.0.0/Dll2Def.zip

I was going to add in switches for handling using filename vs internal module name and remove underscores etc, but in the end didn't add those.

TimoVJL

A simple PE export to def in C language.
I didn't test it much.
May the source be with you