⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmautoinjectunit.pas.svn-base

📁 这是一段游戏修改工具的源代码.ring3功能由dephi开发,驱动是C开发.希望对大家有帮助
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
      add('');
      add('originalcode'+inttostr(injectnr)+':');
      for i:=0 to length(originalcode)-1 do
        add(originalcode[i]);
      add('');
      add('exit'+inttostr(injectnr)+':');
      add('jmp returnhere'+inttostr(injectnr)+'');


    end;

  end;

{$endif}
end;

procedure TfrmAutoInject.Panel1Resize(Sender: TObject);
begin
  button1.Left:=panel1.Width div 2-button1.Width div 2;
end;


procedure TfrmAutoInject.CheatTablecompliantcodee1Click(Sender: TObject);
begin
  assemblescreen.Lines.Insert(0,'[ENABLE]');
  assemblescreen.Lines.Insert(1,'//code from here to ''[DISABLE]'' will be used to enable the cheat');
  assemblescreen.Lines.Insert(2,'');

  assemblescreen.Lines.Add(' ');
  assemblescreen.Lines.Add(' ');
  assemblescreen.Lines.Add('[DISABLE]');
  assemblescreen.Lines.Add('//code from here till the end of the code will be used to disable the cheat');
end;

procedure TfrmAutoInject.assemblescreenChange(Sender: TObject);
{$ifndef standalonetrainerwithassembler}
var
  TempMS: TMemoryStream;
  FSyntax: TpsvAARTF;
  FSyntax2: TpsvCppRTF;
  pos, top: Integer;
  OnChange: TNotifyEvent;
{$endif}
begin
{$ifndef standalonetrainerwithassembler}
  undotimer.enabled:=false;
  undotimer.enabled:=true; //if no change for 2 seconds the script gets stored

  if (Length(assemblescreen.Text) <= 0) then
    exit;


  assemblescreen.Lines.BeginUpdate;
  pos := assemblescreen.selstart;
  top := SendMessage(assemblescreen.Handle, EM_GETFIRSTVISIBLELINE, 0, 0);
  OnChange := assemblescreen.OnChange;
  TempMS := TMemoryStream.Create;

  assemblescreen.OnChange := nil;



  try
    if fcplusplus then
      FSyntax2 := TpsvCppRTF.Create
    else
      FSyntax := TpsvAARTF.Create;
      
    try

      try

        if cplusplus then
        begin
          FSyntax2.SetText(assemblescreen.Text);
          FSyntax2.ConvertToRTFStream(TempMS);
        end
        else
        begin
          FSyntax.SetText(assemblescreen.Text);
          FSyntax.ConvertToRTFStream(TempMS);
        end;

        TempMS.Position := 0;
        assemblescreen.PlainText := False;


        assemblescreen.Lines.LoadFromStream(TempMS);
        SendMessage(assemblescreen.Handle, EM_LINESCROLL, 0, top);
        
      finally
        if fcplusplus then
          fsyntax2.free
        else
          FSyntax.Free;
      end;


    except
      assemblescreen.SelAttributes := assemblescreen.DefAttributes;
    end;

  finally
    assemblescreen.PlainText := True;
    assemblescreen.SelStart := Pos;

    TempMS.Free;
    assemblescreen.Lines.EndUpdate;
    assemblescreen.OnChange := OnChange;
  end;
{$endif}
end;



procedure TfrmAutoInject.Assigntocurrentcheattable1Click(Sender: TObject);
var a,b: integer;
    aa:TCEAllocArray;
begin
{$ifndef standalonetrainerwithassembler}
  {$ifndef net}
  setlength(aa,1);
  getenableanddisablepos(assemblescreen.Lines,a,b);
  if (a=-1) and (b=-1) then raise exception.create('The code needs a [ENABLE] and a [DISABLE] section if you want to add it to a table');

  if autoassemble(assemblescreen.lines,false,true,true,false,aa) and
     autoassemble(assemblescreen.lines,false,false,true,false,aa) then
  begin
    //add a entry with type 255
    mainform.AddAutoAssembleScript(assemblescreen.text);


  end
  else showmessage('Failed to add to table. Not all code is injectable');
  {$endif}
  {$endif}
end;

procedure Getjumpandoverwrittenbytes(address,addressto: dword; jumppart,originalcodepart: tstrings);
//pre: jumppart and originalcodepart are declared objects
var x,y: dword;
    z: string;
    i: integer;
begin
{$ifndef standalonetrainerwithassembler}
  x:=address;
  y:=address;

  while x-y<5 do
  begin
    z:=disassemble(x);
    z:=copy(z,pos('-',z)+1,length(z));
    z:=copy(z,pos('-',z)+1,length(z));

    originalcodepart.add(z);
  end;

  jumppart.Add('jmp '+inttohex(addressto,8));

  for i:=5 to x-y-1 do
    jumppart.Add('nop');
{$endif}
end;


procedure TfrmAutoInject.APIHook1Click(Sender: TObject);
function inttostr(i:int64):string;
begin
  if i=0 then result:='' else result:=sysutils.IntToStr(i);
end;

var address: string;
    addressdw: dword;
    originalcode: array of string;
    codesize: integer;
    a,b,c: dword;
    x: string;
    i,j,k: integer;
    prev_usesymbols: boolean;
    injectnr: integer;

begin
{$ifndef standalonetrainerwithassembler}
  a:=memorybrowser.dselected;

  address:=inttohex(a,8);

  with tfrmapihooktemplatesettings.create(self) do
//  if inputquery('Give the address of the api you want to hook',address) and inputquery('Give the address of the replacement function',address) then
  begin
    try
      edit1.text:=address;
      if showmodal<>mrok then exit;

      try
        a:=strtoint('$'+edit1.text);
      except
        a:=symhandler.getaddressfromname(edit1.text);
      end;

      try
        b:=strtoint('$'+edit2.text);
      except
        b:=symhandler.getaddressfromname(edit2.text);
      end;

      if edit3.text<>'' then
      begin
        try
          c:=strtoint('$'+edit3.text);
        except
          c:=symhandler.getaddressfromname(edit3.text);
        end;
      end;



      b:=a;

      injectnr:=0;
      for i:=0 to assemblescreen.Lines.Count-1 do
      begin
        j:=pos('alloc(newmem',lowercase(assemblescreen.lines[i]));
        if j<>0 then
        begin
          x:=copy(assemblescreen.Lines[i],j+12,length(assemblescreen.Lines[i]));
          x:=copy(x,1,pos(',',x)-1);
          try
            k:=strtoint(x);
            if injectnr<=k then
              injectnr:=k+1;
          except
            inc(injectnr);
          end;
        end;
      end;


      //disassemble the old code
      setlength(originalcode,0);
      codesize:=0;


      while codesize<5 do
      begin
        setlength(originalcode,length(originalcode)+1);
        originalcode[length(originalcode)-1]:=disassemble(a,x);
        i:=posex('-',originalcode[length(originalcode)-1]);
        i:=posex('-',originalcode[length(originalcode)-1],i+1);
        originalcode[length(originalcode)-1]:=copy(originalcode[length(originalcode)-1],i+2,length(originalcode[length(originalcode)-1]));
        codesize:=a-b;
      end;


      with assemblescreen.lines do
      begin
        add('alloc(originalcall'+inttostr(injectnr)+',2048) //2kb should be enough');
        add('label(returnhere'+inttostr(injectnr)+')');
        add('');
        add(edit1.text+':');
        add('jmp '+edit2.text);
        while codesize>5 do
        begin
          add('nop');
          dec(codesize);
        end;

        add('returnhere'+inttostr(injectnr)+':');
        add('');
        add('originalcall'+inttostr(injectnr)+':');

        for i:=0 to length(originalcode)-1 do
          add(originalcode[i]);
        add('jmp returnhere'+inttostr(injectnr)+'');

        add('');
        if edit3.text<>'' then
        begin
          add(edit3.text+':');
          add('dd originalcall');
        end;


      end;

    finally
      free;
    end;
  end;

{$endif}
end;

procedure TfrmAutoInject.SaveAs1Click(Sender: TObject);
begin
  if savedialog1.Execute then
    save1.Click;    
end;

procedure TfrmAutoInject.FormShow(Sender: TObject);
begin
{$ifndef standalonetrainerwithassembler}
  if editscript then button1.Caption:=strOK;

  assemblescreen.SetFocus;
{$endif}
end;

procedure TfrmAutoInject.assemblescreenKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
   if (ssCtrl in Shift) and (key=ord('A'))  then
   begin
     TMemo(Sender).SelectAll;
     Key := 0;
   end;
end;

procedure TfrmAutoInject.Coderelocation1Click(Sender: TObject);
var starts,stops: string;
    start,stop,current,x: dword;
    i,j: integer;

    labels: tstringlist;
    output: tstringlist;
    s: string;

    a,b: string;
    prev: dword;

    ok: boolean;

begin
{$ifndef standalonetrainerwithassembler}
  starts:=inttohex(memorybrowser.dselected,8);
  stops:=inttohex(memorybrowser.dselected+128,8);

  if inputquery('Start address:','Code relocation template',starts) then
  begin
    start:=strtoint('$'+starts);
    if inputquery('End address (last bytes are included if necesary)','Code relocation template',stops) then
    begin
      stop:=strtoint('$'+stops);

      output:=tstringlist.Create;
      labels:=tstringlist.create;
      labels.Duplicates:=dupIgnore;
      labels.Sorted:=true;
      
      output.add('alloc(newmem,'+inttostr(abs(integer(stop-start))*2)+')');
      output.add('');
      output.add('newmem:');


      try
        current:=start;

        while current<stop do
        begin
          prev:=current;
          s:=disassemble(current);
          i:=posex('-',s);
          i:=posex('-',s,i+1);
          s:=copy(s,i+2,length(s));

          i:=pos(' ',s);
          a:=copy(s,1,i-1);
          b:=copy(s,i+1,length(s));


          if length(a)>1 then
          begin
            if (lowercase(a)='loop') or (lowercase(a[1])='j') or (lowercase(a)='call') then
            begin
              try
                x:=symhandler.getAddressFromName(b);
                if (x>=start) and (x<=stop) then
                begin
                  labels.Add('orig_'+inttohex(x,8));
                  s:=a+' orig_'+inttohex(x,8);
                end;
              except
                //nolabel
              end;
            end;
          end;

          output.add('orig_'+inttohex(prev,8)+':');
          output.add(s);
        end;

        labels.Sort;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -