Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[delphi] how can i display binary location in exe ??

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
extra
Newbie cheater
Reputation: 0

Joined: 29 May 2011
Posts: 10

PostPosted: Wed Jun 08, 2011 12:28 pm    Post subject: [delphi] how can i display binary location in exe ?? Reply with quote

i mak an app to search a text in exe
it works fine


you type your string
press search
open dialog come up
select
then you have the correct address

my request to read another location realative to this location
say
this location + 20
for example the adress is 100
i want to display the address 110 in the edit 3 box
by the way
this new location contain normal characters in any hex editor
how can i apply that to that code
how can 1 display the new location contents in the "edit3" box as picture ??

Code:
unit search;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
 
function ScanFile(const FileName: string;
  const forString: string;
  caseSensitive: Boolean): Longint;
const
  BufferSize = $8001;  { 32K+1 bytes }
var
  pBuf, pEnd, pScan, pPos: PChar;
  filesize: LongInt;
  bytesRemaining: LongInt;
  bytesToRead: Integer;
  F: file;
  SearchFor: PChar;
  oldMode: Word;
begin
  { assume failure }
  Result := -1;
  if (Length(forString) = 0) or (Length(FileName) = 0) then Exit;
  SearchFor := nil;
  pBuf      := nil;
  { open file as binary, 1 byte recordsize }
  AssignFile(F, FileName);
  oldMode  := FileMode;
  FileMode := 0;    { read-only access }
  Reset(F, 1);
  FileMode := oldMode;
  try { allocate memory for buffer and pchar search string }
    SearchFor := StrAlloc(Length(forString) + 1);
    StrPCopy(SearchFor, forString);
    if not caseSensitive then  { convert to upper case }
      AnsiUpper(SearchFor);
    GetMem(pBuf, BufferSize);
    filesize       := System.Filesize(F);
    bytesRemaining := filesize;
    pPos           := nil;
    while bytesRemaining > 0 do
    begin
      { calc how many bytes to read this round }
      if bytesRemaining >= BufferSize then
        bytesToRead := Pred(BufferSize)
      else
        bytesToRead := bytesRemaining;
      { read a buffer full and zero-terminate the buffer }
      BlockRead(F, pBuf^, bytesToRead, bytesToRead);
      pEnd  := @pBuf[bytesToRead];
      pEnd^ := #0;
      pScan := pBuf;
      while pScan < pEnd do
      begin
        if not caseSensitive then { convert to upper case }
          AnsiUpper(pScan);
        pPos := StrPos(pScan, SearchFor);  { search for substring }
        if pPos <> nil then
        begin { Found it! }
          Result := FileSize - bytesRemaining +
            Longint(pPos) - Longint(pBuf);
          Break;
        end;
        pScan := StrEnd(pScan);
        Inc(pScan);
      end;
      if pPos <> nil then Break;
      bytesRemaining := bytesRemaining - bytesToRead;
      if bytesRemaining > 0 then
      begin
        Seek(F, FilePos(F) - Length(forString));
        bytesRemaining := bytesRemaining + Length(forString);
      end;
    end; { While }
  finally
    CloseFile(F);
    if SearchFor <> nil then StrDispose(SearchFor);
    if pBuf <> nil then FreeMem(pBuf, BufferSize);
  end;
end; { ScanFile }

procedure TForm1.Button1Click(Sender: TObject);
var
  openDialog : TOpenDialog;
     Position: integer;
begin
      openDialog := TOpenDialog.Create(self);
 openDialog.InitialDir := 'c:\';
         openDialog.Options := [ofFileMustExist];
       openDialog.Filter :=
    'EXE FILE|*.EXE|ANY FILE|*.*';
    openDialog.FilterIndex := 2;
  if openDialog.Execute
  then ShowMessage(openDialog.FileName)
  else ShowMessage('Open file was cancelled');
                    Position := ScanFile(openDialog.FileName, edit1.text, False);
  edit2.Text:=(IntToStr(Position));
    openDialog.Free;
   
    end;

end.



search.jpg
 Description:
 Filesize:  11.09 KB
 Viewed:  4515 Time(s)

search.jpg


Back to top
View user's profile Send private message
extra
Newbie cheater
Reputation: 0

Joined: 29 May 2011
Posts: 10

PostPosted: Thu Jun 09, 2011 1:55 am    Post subject: Reply with quote

i can do it so easy in vb6
but vb6 search in slow
so i just want to display the location content
to apper in edit3 box

ok i open search the file
any idia to show the content of any location in the edit3 box
by knowing its posetion ??

is this imposable or it hard ???
Back to top
View user's profile Send private message
extra
Newbie cheater
Reputation: 0

Joined: 29 May 2011
Posts: 10

PostPosted: Sun Jun 12, 2011 7:16 pm    Post subject: Reply with quote

any idea ???
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites