Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. TITLE Compiling: m0d_s0beit_sa hook loader
  3. COLOR 1F
  4. :: header text
  5. echo -----------------------------------------------------------
  6. echo -----------------------------------------------------------
  7. echo make.bat for m0d_s0beit_sa hook's ASM loader    by nuckfuts
  8. echo -----------------------------------------------------------
  9.  
  10.  
  11. :: init our batch environment
  12. SETLOCAL EnableDelayedExpansion
  13. :: check for config file
  14. IF EXIST .\make_settings.cfg GOTO cfg_init
  15. echo make_settings.cfg not found.
  16. :cfg_new1
  17. IF EXIST .\make_settings.cfg DEL .\make_settings.cfg
  18. echo Creating a new make_settings.cfg...
  19. :cfg_msm1
  20. :: MASM32 installation search
  21. echo Searching for MASM32 install...
  22. FOR %%F IN ("%path:;=" "%") DO (
  23.     SET msm_dir=%%~F
  24.     IF EXIST "!msm_dir!\ml.exe" IF EXIST "!msm_dir!\rc.exe" IF EXIST "!msm_dir!\cvtres.exe" IF EXIST "!msm_dir!\link.exe" GOTO cfg_msm2
  25. )
  26. ::
  27. :: possibly here will go a hard-drive scanning feature to find MASM when it's not in path
  28. ::
  29. :: MASM32 not found, show error
  30. GOTO err_msm1
  31. :cfg_msm2
  32. SET msm_dir="%msm_dir:~0,-4%"
  33. echo msm_dir;%msm_dir%>>.\make_settings.cfg
  34. echo MASM32 installation found at: %msm_dir%
  35. :: return if called as sub
  36. IF NOT '%RETURN%'=='' SET tmp=%RETURN% & SET RETURN= & GOTO !tmp!
  37. :cfg_new9
  38. :: config creation done, no need to init from file, done
  39. echo make_settings.cfg creation complete.
  40. GOTO cfg_done
  41.  
  42.  
  43. :cfg_init
  44. :: init from config file
  45. FOR /F "eol= tokens=1,2* delims=;" %%i IN (.\make_settings.cfg) DO (
  46.     IF NOT '%%i'=='' SET %%i=%%j
  47. )
  48. :chk_msm
  49. IF '%msm_dir%'=='' echo MASM32 directory not found in config. & SET RETURN=chk_msm & GOTO cfg_msm1
  50.  
  51.  
  52. :chk_done
  53. :: done checking the config file
  54. :cfg_done
  55. :: configuration totally done
  56. :init_end
  57. :: final init procedure
  58. SET bin_dir=%msm_dir:~1,-1%\bin
  59. SET lib_dir=%msm_dir:~1,-1%\lib
  60. SET inc_dir=%msm_dir:~1,-1%\include
  61.  
  62.  
  63. :src_chk
  64. :: check for needed source files
  65. IF EXIST .\m0d_s0beit_sa.asm IF EXIST .\m0d_s0beit_sa_rsrc.rc IF EXIST .\image.inc IF EXIST .\image.lib IF EXIST .\UacSucks.manifest GOTO src_ok
  66. GOTO err_src1
  67. :src_ok
  68. :: source code is ok
  69.  
  70.  
  71. :: compiling resource, Pelles Resource Compiler is preferred and auto-detected
  72. echo.
  73. echo -----------------------------------------------------------
  74. echo Compiling resources...
  75. echo -----------------------------------------------------------
  76. IF EXIST "%bin_dir%\porc.exe" echo Pelles Resource Compiler & echo Copyright (c) Pelle Orinius & echo. & "%bin_dir%\porc.exe" /v m0d_s0beit_sa_rsrc.rc & echo.
  77. IF ERRORLEVEL 1 GOTO errasm
  78. IF NOT EXIST "%bin_dir%\porc.exe" "%bin_dir%\rc.exe" m0d_s0beit_sa_rsrc.rc
  79. IF ERRORLEVEL 1 GOTO errasm
  80.  
  81.  
  82. :: compiling executable, the latest JWasm with MASM32 v10+ files is prefered and auto-detected
  83. echo -----------------------------------------------------------
  84. echo Compiling executable...
  85. echo -----------------------------------------------------------
  86. IF EXIST "%bin_dir%\jwasm.exe" "%bin_dir%\jwasm.exe" /c /coff /Cp /I"%inc_dir%" m0d_s0beit_sa.asm
  87. IF ERRORLEVEL 1 GOTO errasm
  88. IF NOT EXIST "%bin_dir%\jwasm.exe" "%bin_dir%\ml.exe" /c /coff /Cp /I"%inc_dir%" m0d_s0beit_sa.asm
  89. IF ERRORLEVEL 1 GOTO errasm
  90.  
  91.  
  92. :: linking executable, the latest Pelles Linker with MASM32 v10+ files is preferred and auto-detected
  93. echo.
  94. echo -----------------------------------------------------------
  95. echo Linking executable...
  96. echo -----------------------------------------------------------
  97. IF EXIST "%bin_dir%\polink.exe" echo Pelles Linker & echo Copyright (c) Pelle Orinius & echo. & "%bin_dir%\polink.exe" /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 /LIBPATH:"%lib_dir%" /OUT:"m0d_s0beit_sa.exe" m0d_s0beit_sa.obj m0d_s0beit_sa_rsrc.res
  98. IF ERRORLEVEL 1 GOTO errlink
  99. IF NOT EXIST "%bin_dir%\polink.exe" "%bin_dir%\link.exe" /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 /LIBPATH:"%lib_dir%" /OUT:"..\..\..\bin\m0d_s0beit_sa.exe" m0d_s0beit_sa.obj m0d_s0beit_sa_rsrc.res
  100. IF ERRORLEVEL 1 GOTO errlink
  101. GOTO :put_bin
  102.  
  103.  
  104. :err_src1
  105. echo -----------------------------------------------------------
  106. echo ERROR: Source code not found or incomplete.
  107. IF NOT EXIST .\m0d_s0beit_sa.asm echo m0d_s0beit_sa.asm not found.
  108. IF NOT EXIST .\m0d_s0beit_sa_rsrc.rc echo m0d_s0beit_sa_rsrc.rc not found.
  109. IF NOT EXIST .\image.inc echo image.inc not found.
  110. IF NOT EXIST .\image.lib echo image.lib not found.
  111. IF NOT EXIST .\UacSucks.manifest echo UacSucks.manifest not found.
  112. echo -----------------------------------------------------------
  113. GOTO end
  114. :err_msm1
  115. echo -----------------------------------------------------------
  116. echo ERROR: MASM32 not fully installed / not in PATH.
  117. IF NOT EXIST "%msm_dir%\ml.exe" echo ml.exe not found.
  118. IF NOT EXIST "%msm_dir%\rc.exe" echo rc.exe not found.
  119. IF NOT EXIST "%msm_dir%\cvtres.exe" echo cvtres.exe not found.
  120. IF NOT EXIST "%msm_dir%\link.exe" echo link.exe not found.
  121. echo -----------------------------------------------------------
  122. goto end
  123. :errasm
  124. echo -----------------------------------------------------------
  125. echo ERROR: Compiling failed.
  126. echo -----------------------------------------------------------
  127. GOTO end
  128. :errlink
  129. echo -----------------------------------------------------------
  130. echo ERROR: Linking failed.
  131. echo -----------------------------------------------------------
  132. GOTO end
  133.  
  134.  
  135. :put_bin
  136. del .\m0d_s0beit_sa_rsrc.res
  137. del .\m0d_s0beit_sa.obj
  138. echo -----------------------------------------------------------
  139. echo The project has been built successfully.
  140. echo -----------------------------------------------------------
  141.  
  142.  
  143. :end
  144. pause
  145. cls
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement