View Single Post
  #10  
Old 02-05-2021, 17:37
GautamGreat GautamGreat is offline
Friend
 
Join Date: Jul 2019
Posts: 8
Rept. Given: 0
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 2
Thanks Rcvd at 29 Times in 6 Posts
GautamGreat Reputation: 0
Quote:
Originally Posted by mcr4ck View Post
how do use this
https://github.com/GautamGreat/LoaderEngine

please example
here is a example code I wrote for a target long ago

Code:
program Project1;

{$APPTYPE GUI}

uses
  Winapi.Windows, System.SysUtils,
  Loader_Engine in '..\..\..\..\..\Coding-and-Programming\Delphi_Projects\Loader_Engine.pas';

const
  patchAddrRVA = $05234536;

var
  patchAsm : array[0..24] of Byte = ($9C, $52, $89, $2C, $24, $3E, $8B, $44, $24, $F4, $8B, $00, $C6, $00, $01, $B8, $FF, $FF, $FF, $FF, $E9, $00, $00, $00, $00);
  lE : TLoaderEngine;
  newMem : Pointer;
  patchAddr : DWORD;
  jmp_byte : Byte = $E9;
  jmp_write : DWORD;

function jmpCalc(src, dst : DWORD) : DWORD;
begin
  Result := dst - src - 5;
end;

begin

  try
    lE := TLoaderEngine.Create('test_program.exe', True, False);
    try
      if lE.WaitTillFirstWindow(1000) then
      begin

        lE.SuspendPThread;
        newMem := le.AllocMemory($1000);
        patchAddr := patchAddrRVA + lE.GetModuleBaseAddress;

        jmp_write := jmpCalc(patchAddr, DWORD(newMem));
        lE.WriteMemory(DWORD(newMem), patchAsm[0], Length(patchAsm));
        lE.WriteMemory(patchAddr, jmp_byte, 1);
        lE.WriteMemory(patchAddr+1, jmp_write, 4);

        jmp_write := jmpCalc(DWORD(newMem)+$14, patchAddr+5);
        lE.WriteMemory(DWORD(newMem)+$15, jmp_write, 4);
        lE.ResumePThread;

      end
      else
        MessageBox(0, 'Failed to detect Windows', 'Error', MB_ICONERROR);
    finally
      lE.Destroy;
    end;
  except
    on E:exception do
      MessageBox(0, PChar(E.Message), PChar(E.ClassName), MB_ICONERROR);

  end;

end.
Reply With Quote
The Following 2 Users Say Thank You to GautamGreat For This Useful Post:
countryboy (09-22-2021), niculaita (02-06-2021)