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

📄 formmemorymodifier.pas.svn-base

📁 这是一段游戏修改工具的源代码.ring3功能由dephi开发,驱动是C开发.希望对大家有帮助
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
unit formMemoryModifier;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Menus, ExtDlgs, ComCtrls, Buttons, ExtCtrls,shellapi,tlhelp32,
  cefuncproc,ExtraTrainerComponents;

const trainerversion=7;

type TcodeEntry = record
  address: dword;
  modulename: string;
  moduleoffset: dword;
  originalopcode: array of byte;
end;

type TAddressEntry = record
  address: dword;
  interpretableaddress: string;
  ispointer: boolean;
  pointers: array of TCEPointer;
  bit: byte;
  memtyp: integer;
  frozen: boolean;
  frozendirection: byte;
  setvalue: boolean;
  userinput: boolean;
  value: string;
  autoassemblescript: string;         
end;

type Ttrainerdata = record
  description: string;
  hotkeytext: string;
  hotkey: TKeyCombo;
  hasedit: boolean;
  editvalue: string;

  codeentrys: array of TCodeEntry;
  addressentrys: array of TAddressEntry;
end;

type
  TfrmMemoryModifier = class(TForm)
    Button1: TButton;
    Button2: TButton;
    lblWidthHeight: TLabel;
    OpenPictureDialog1: TOpenPictureDialog;
    SaveDialog1: TSaveDialog;
    Panel1: TPanel;
    Label1: TLabel;
    spbUp: TSpeedButton;
    spbDown: TSpeedButton;
    recordview: TListView;
    PopupMenu1: TPopupMenu;
    Delete1: TMenuItem;
    OpenDialog1: TOpenDialog;
    Button3: TButton;
    Icon: TImage;
    Label4: TLabel;
    Button5: TButton;
    editTitle: TEdit;
    OpenDialog2: TOpenDialog;
    Edit2: TEdit;
    Label2: TLabel;
    ComboBox1: TComboBox;
    Label3: TLabel;
    LoadButton: TSpeedButton;
    Button4: TButton;
    Button6: TButton;
    OpenDialog3: TOpenDialog;
    CheckBox1: TCheckBox;
    EditHotkey: TEdit;
    Button7: TButton;
    CheckBox2: TCheckBox;
    Memo1: TMemo;
    editFreezeInterval: TEdit;
    Label5: TLabel;
    Label6: TLabel;
    cbPreventReopening: TCheckBox;
    Button8: TButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure recordviewClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure editTitleChange(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure spbUpClick(Sender: TObject);
    procedure spbDownClick(Sender: TObject);
    procedure LoadButtonClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure EditHotkeyKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure CheckBox1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure EditHotkeyKeyPress(Sender: TObject; var Key: Char);
    procedure recordviewDblClick(Sender: TObject);
    procedure Button8Click(Sender: TObject);
  private
    { Private declarations }
    procedure changeicon(filename: string);
  public
    { Public declarations }
    trainerdata: array of TTrainerdata;
    changed: boolean;
    popuphotkey: tkeycombo;
    dontshowdefault:boolean;
  end;

var
  frmMemoryModifier: TfrmMemoryModifier;

implementation

uses formMemoryTrainerUnit, formMemoryTrainerAddEntry, MainUnit,
  MemoryTrainerDesignUnit;

{$R *.dfm}

procedure TfrmMemoryModifier.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  action:=cafree;
  frmMemoryModifier:=nil;
  frmMemoryTrainerPreview.Close;
  frmMemoryTrainerPreview.free;
  frmMemoryTrainerPreview:=nil;
end;

procedure TfrmMemoryModifier.Button2Click(Sender: TObject);
begin
  if openpicturedialog1.execute then
  begin
    if uppercase(extractfileext(openpicturedialog1.filename))<>'.BMP' then
      raise exception.create ('Sorry, but I cant use this filetype');

    frmMemorytrainerpreview.Image1.Picture.Bitmap.LoadFromFile(openpicturedialog1.filename);
    changed:=true;
  end;
end;

procedure TfrmMemoryModifier.Button4Click(Sender: TObject);
begin
  FrmMemoryTrainerAddEntry:=tFrmMemoryTrainerAddEntry.create(self);
  FrmMemoryTrainerAddEntry.showmodal;

  frmMemoryTrainerPreview.UpdateScreen;
  if frmTrainerDesigner<>nil then
    frmTrainerDesigner.UpdateCheats;
end;

procedure TfrmMemoryModifier.changeicon(filename: string);
var resh: thandle;
    s: tmemorystream;
begin
{    resh:=BeginUpdateResource(pchar(filename),false);
    if (resh<>0) then
    begin
      try
        // icon.p
        s:=tmemorystream.Create;
        try
          writeicon2(s, icon.Picture.Icon.Handle, false);

          if not updateResource(resh,pchar(RT_ICON),pchar(1),1033, @(s.Memory), s.size) then
            showmessage('Error changing the icon');
        finally
          s.Free;
        end;
      finally
        EndUpdateResource(resh,false);
      end;
    end;
   }
end;

procedure TfrmMemoryModifier.recordviewClick(Sender: TObject);
begin
  if recordview.ItemIndex<>-1 then
  begin
    spbUp.Enabled:=recordview.itemindex>0;
    spbDown.enabled:=recordview.itemindex<(recordview.Items.Count-1);
  end
  else
  begin
    spbUp.Enabled:=false;
    spbDown.enabled:=false;
  end;
end;

procedure TfrmMemoryModifier.Button1Click(Sender: TObject);
var res: TResourceStream;
    trainer,iconstream,imagestream: TMemorystream;
    searcher: ^char;
    scanstring: string;
    i,j,k,l: integer;
    iconbuf,x: pchar;
    temp: dword;
    tempi: integer;
    tempb: boolean;
    temps: string;

    protect: boolean;
begin
  protect:=cbPreventReopening.checked;
  if combobox1.Text='' then raise exception.Create('At least fill in a processname');

  if savedialog1.execute then
  begin
    //exctract exe
    res:=TResourceStream.Create(hinstance,'TRAINER','CEINCEXE');

    trainer:=TMemorystream.Create;
    res.SaveToStream(trainer);
    res.free;

    //search for the icon
    searcher:=trainer.memory;
    scanstring:='And so, Dark Byte, wrote the text into the icon, So he could find it back...';

    i:=0;
    j:=1;
    while (i<trainer.size) do
    begin
      if searcher^=scanstring[j] then
      begin
        if j=length(scanstring) then
        begin
//          dec(searcher,j);
          dec(i,j+199);
          break;
        end;
        inc(j);
      end else j:=1;

      inc(searcher);
      inc(i);
    end;

    if j<length(scanstring) then raise exception.create('Please, dont mess with the exe!');

    //replace it
    iconstream:=TMemorystream.Create;
    icon.Picture.Icon.SaveToStream(iconstream);

    getmem(iconbuf,744);

    iconstream.Position:=22;
    iconstream.ReadBuffer(iconbuf^,744);

    iconstream.Free;

    trainer.Position:=i;
    trainer.WriteBuffer(iconbuf^,744);

    freemem(iconbuf);
    //append the settingsdata behind that file

    temp:=trainer.Size;
    trainer.position:=80;
    trainer.Writebuffer(temp,4);

    //write the trainerdata to the end of the file
    trainer.position:=trainer.size;

    if protect then
      temp:=$22322
    else
      temp:=$22222;  //kind of trainer
      
    trainer.WriteBuffer(temp,4);

    temp:=trainerversion;
    trainer.WriteBuffer(temp,4);

    temp:=length(trainerdata);   //point to start of trainerdata

    trainer.WriteBuffer(temp,4);

    for i:=0 to length(trainerdata)-1 do
    begin
      temp:=length(trainerdata[i].description);
      trainer.WriteBuffer(temp,4);

      x:=pchar(trainerdata[i].description);
      trainer.WriteBuffer(pointer(x)^,temp);

      temp:=length(trainerdata[i].hotkeytext);
      trainer.WriteBuffer(temp,4);

      x:=pchar(trainerdata[i].hotkeytext);
      trainer.WriteBuffer(pointer(x)^,temp);

      trainer.WriteBuffer(trainerdata[i].hotkey,sizeof(trainerdata[i].hotkey));

      temp:=length(Trainerdata[i].codeEntrys);
      trainer.WriteBuffer(temp,4);
      for j:=0 to length(trainerdata[i].codeentrys)-1 do
      begin
        //address
        temp:=trainerdata[i].codeentrys[j].address;
        if protect then temp:=temp xor $11221122;

        trainer.WriteBuffer(temp,4);

        //modulename
        temp:=length(trainerdata[i].codeentrys[j].modulename);
        trainer.WriteBuffer(temp,4);

        x:=pchar(trainerdata[i].codeentrys[j].modulename);
        trainer.WriteBuffer(pointer(x)^,temp);

        temp:=trainerdata[i].codeentrys[j].moduleoffset;
        if protect then temp:=temp xor $22112211;
        trainer.WriteBuffer(temp,4);



        //original opcode
        temp:=length(trainerdata[i].codeentrys[j].originalopcode);

⌨️ 快捷键说明

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