Advertisement
Ham62

ExeLoaderDll

Apr 23rd, 2018
942
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define fbc -dll -x "LoadExe.dll"
  2. #include "crt.bi"
  3. #include "windows.bi"
  4.  
  5. Dim Shared exeEntryPoint as Sub(hInstance as HINSTANCE, hPrevInstance as HINSTANCE, szCmdLine as PSTR, iCmdShow as Integer)
  6.  
  7. extern "windows-ms"
  8. sub LauncherMain(hwnd as HWND, hinst as HINSTANCE, szCmdLine as zstring, nCmdShow as integer) export
  9.     AllocConsole()
  10.     print szCmdLine
  11.    
  12.     if open(szCmdLine for binary access read as #1) then
  13.         MessageBox(NULL, "Could not open file  """+szCmdLine+"""", "ERROR", MB_ICONERROR)
  14.         system
  15.     end if
  16.        
  17.     dim as ubyte ptr exeBuff
  18.     exeBuff = malloc(lof(1)) ' Allocate buffer for exe
  19.     get #1,, *exeBuff, lof(1)
  20.  
  21.     Dim as IMAGE_OPTIONAL_HEADER PEHeader
  22.     memcpy(exeBuff, @PEHeader, sizeof(IMAGE_OPTIONAL_HEADER))
  23.    
  24.     exeEntryPoint = cast(any ptr, PEHeader.AddressOfEntryPoint)
  25.    
  26.     sleep
  27.     exeEntryPoint(hinst, NULL, szCmdLine, nCmdShow)
  28.    
  29.     sleep
  30. end sub
  31. end extern
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement