Author Topic: Automation the creation of inc-, def- and lib-files  (Read 1179 times)

Mikl__

  • Member
  • ****
  • Posts: 556
Re: Automation the creation of inc-, def- and lib-files
« Reply #30 on: July 22, 2017, 03:35:19 PM »
And finally (Ba dum tss) inc_def.bat
Code: [Select]
@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
)
« Last Edit: July 22, 2017, 07:01:44 PM by Mikl__ »

Mikl__

  • Member
  • ****
  • Posts: 556
Re: Automation the creation of inc-, def- and lib-files
« Reply #31 on: July 24, 2017, 10:47:04 PM »
Code: [Select]
@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
« Last Edit: July 25, 2017, 12:12:49 AM by Mikl__ »