Перейти к содержанию

Нужна помощь с Dll инжектором


Рекомендуемые сообщения

Вот весь код инжектора. Компилирую на Delphi xe5

 InjectDLL(PAnsiChar(GetCurrentDir+'hack.dll'), StrToInt(EpiD)); // В ЭТОЙ СТРОКЕ ОШИБКА

 

unit Unit1;interfaceuses  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,  Dialogs, TlHelp32, Buttons, StdCtrls, jpeg, ExtCtrls, sSkinManager,  sEdit, sGauge, sButton, sLabel, ComCtrls, sTrackBar, sPanel, sSpeedButton,  sStatusBar, ShellAPI, sCheckBox, sGroupBox, sBitBtn;type  TForm1 = class(TForm)    sSkinManager1: TsSkinManager;    Button1: TButton;    Button2: TButton;    Timer1: TTimer;    Timer2: TTimer;    sLabel2: TsLabel;    procedure FormCreate(Sender: TObject);    procedure Button2Click(Sender: TObject);    procedure Timer1Timer(Sender: TObject);    procedure Timer2Timer(Sender: TObject);  private    { Private declarations }  public    { Public declarations }  end;var  Form1: TForm1;implementation{$R *.dfm}function processExists(exeFileName: string): Boolean;//Функция поиска процессаvar  ContinueLoop: BOOL;  FSnapshotHandle: THandle;  FProcessEntry32: TProcessEntry32;begin  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);  Result := False;  while Integer(ContinueLoop) <> 0 do  begin    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =      UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =      UpperCase(ExeFileName))) then    begin      Result := True;    end;    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);  end;  CloseHandle(FSnapshotHandle);end;function GetOSVersion: Cardinal;//Проверка версии Windowsvar  OSVersionInfo: TOSVersionInfo;begin  Result := 0;  FillChar(OSVersionInfo, Sizeof(OSVersionInfo), 0);  OSVersionInfo.dwOSVersionInfoSize := SizeOf(OSVersionInfo);  if GetVersionEx(OSVersionInfo) then  begin    if OSVersionInfo.dwPlatformId = VER_PLATFORM_WIN32_NT then    begin      if OSVersionInfo.dwMajorVersion = 5 then      begin        if OSVersionInfo.dwMinorVersion = 0 then          Result := 50//Windows 2000        else if OSVersionInfo.dwMinorVersion = 2 then          Result := 52//Windows 2003        else if OSVersionInfo.dwMinorVersion = 1 then          Result := 51//Windows XP      end;      if OSVersionInfo.dwMajorVersion = 6 then      begin        if OSVersionInfo.dwMinorVersion = 0 then          Result := 60//Windows Vista        else if OSVersionInfo.dwMinorVersion = 1 then          Result := 61;//Windows 7      end;    end;  end;end;function InjectDLL(dwPID: DWORD; DLLPath: pwidechar): integer;vardwThreadID: Cardinal;hProc, hThread, hKernel: NativeUInt;BytesWritten: NativeUInt;pRemoteBuffer, pLoadLibrary: Pointer;begintryhProc := OpenProcess(PROCESS_ALL_ACCESS, False, dwPID);if hProc = 0 thenbeginResult := 0;Exit;end;pRemoteBuffer := VirtualAllocEx(hProc, nil, Length(DLLPath) + 1, MEM_COMMIT,PAGE_READWRITE);if pRemoteBuffer = nil thenbeginResult := 0;Exit;end;if WriteProcessMemory(hProc, Pointer(pRemoteBuffer), lpvoid(DLLPath),Length(DLLPath) + 1, BytesWritten) = False thenbeginResult := 0;Exit;end;hKernel := GetModuleHandle(pwidechar('kernel32.dll'));pLoadLibrary := (GetProcAddress(hKernel, pansichar('LoadLibraryA')));hThread := CreateRemoteThread(hProc, Pointer(nil), 0, Pointer(pLoadLibrary),Pointer(pRemoteBuffer), 0, dwThreadID);WaitForSingleObject(hThread, INFINITE);VirtualFreeEx(hProc, Pointer(pRemoteBuffer), Length(DLLPath) + 1,MEM_RELEASE);CloseHandle(hThread);CloseHandle(hProc);// ShowMessage(IntToStr(hThread)+' '+ inttostr(dwThreadID));Result := 1;excepton d: exception dobeginend;end;end;procedure TForm1.Button1Click(Sender: TObject);var  hSnap:THandle;  pe:TProcessEntry32;  pid: DWORD;  EpiD: string;beginif not processExists('hl.exe') then   //Проверка процесса   begin   //Если не найден   ShowMessage('Сначала игру');   end   else   begin   //Запущен:   //1. Поиск процесса   pe.dwSize:=SizeOf(pe);   hSnap:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);   If Process32First(hSnap,pe) then    While Process32Next(hSnap,pe) do      if ExtractFileName(pe.szExeFile)='hl.exe' then     EpiD:=IntToStr(pe.th32ProcessID);   //2. Внедрение DLL     begin         if FileExists(GetCurrentDir+'hack.dll') then       begin       InjectDLL(PAnsiChar(GetCurrentDir+'hack.dll'), StrToInt(EpiD)); // В ЭТОЙ СТРОКЕ ОШИБКА       ShowMessage('Чит запущен,Свернуть-Развернуть меню чита на кнопку HOME');       Application.Terminate;       end       else       begin       ShowMessage('Ошибка!');       Application.Terminate;       end;     end;   end;end;
Изменено пользователем Xipho
большие куски кода убираем под спойлер.
Ссылка на комментарий
Поделиться на другие сайты

  • 3 недели спустя...

GetCurrentDir;

Пример кода : Получение текущей директории

vardir : string;begin// Получаем текущую директориюdir := GetCurrentDir]GetCurrentDir;ShowMessage('Current directory = '+dir);end;
Текущая директория = C:\Program Files\Borland\Delphi7\Projects
Значит ты не поставил маленький знак "\" - обратный слеш (обратная косая черта)

 

      if FileExists(GetCurrentDir+'\hack.dll') then       begin       InjectDLL(PAnsiChar(GetCurrentDir+'\hack.dll'), StrToInt(EpiD));       ShowMessage('Чит запущен,Свернуть-Развернуть меню чита на кнопку HOME');       Application.Terminate;      end
Ссылка на комментарий
Поделиться на другие сайты

  • 4 недели спустя...
×
×
  • Создать...

Важная информация

Находясь на нашем сайте, Вы автоматически соглашаетесь соблюдать наши Условия использования.