Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 11:17

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Help] Delphi + ReadProcessMemory

Discussion on [Help] Delphi + ReadProcessMemory within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2006
Posts: 70
Received Thanks: 6
[Help] Delphi + ReadProcessMemory

I cant seem to get read process memory working in delphi i dont know why at all either, ive googled it for like 2 hours the other night and know luck. so i figured ima try here

this is my source currently
thanks in advance for help

PHP Code:
unit Unit1;

interface

uses
  Windows
MessagesSysUtilsVariantsClassesGraphicsControlsForms,
  
DialogsRegistrytlhelp32StdCtrls;

type
  TForm1 
= class(TForm)
    
Label1TLabel;
    
procedure FormCreate(SenderTObject);
  private
    { Private 
declarations }
  public
    { Public 
declarations }
  
end;

var
  
Form1TForm1;
  
cFolderstring;
  
PidPidhandleNewValueDataInteger;
  
AddressWrittenCardinal;

Const
  
process 'conquer.exe';

implementation

{$R *.dfm}

// Get Process ID
//  Example
// Pidhandle := OpenProcess(PROCESS_ALL_ACCESS,False,Pid);
function GetID(Const ExeFileNamestring; var ProcessIdinteger): boolean;
var
  
ContinueLoopBOOL;
    
FSnapshotHandleTHandle;
  
FProcessEntry32TProcessEntry32;
begin
  result 
:= false;
    
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS0);
    
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
  
ContinueLoop := Process32First(FSnapshotHandleFProcessEntry32);
  while 
integer(ContinueLoop) <> do begin
    
if (StrIComp(PChar(ExtractFileName(FProcessEntry32.szExeFile)), PChar(ExeFileName)) = 0)
       or (
StrIComp(FProcessEntry32.szExeFilePChar(ExeFileName)) = 0)  then begin
        ProcessId
:= FProcessEntry32.th32ProcessID;
         
result := true;
       break;
    
end;
      
ContinueLoop := Process32Next(FSnapshotHandleFProcessEntry32);
  
end;
    
CloseHandle(FSnapshotHandle);
end;

// Example
//  cFolder:=(GetRegistryData(HKEY_LOCAL_MACHINE,'\software\valve\steam\', 'InstallPath'));
// ShowMessage(sFolder+'\steamapps\'+Edit1.text+'\insurgency\insurgency\')
function GetRegistryData(RootKeyHKEYKeyValuestring): variant;
var
  
RegTRegistry;
    
RegDataTypeTRegDataType;
  
DataSizeLeninteger;
  
sstring;
label cantread;
begin
  Reg 
:= nil;
  try
    
Reg := TRegistry.Create(KEY_QUERY_VALUE);
    
Reg.RootKey := RootKey;
    if 
Reg.OpenKeyReadOnly(Keythen begin
      
try
        
RegDataType := Reg.GetDataType(Value);
        if (
RegDataType rdString) or
           (
RegDataType rdExpandStringthen
          Result 
:= Reg.ReadString(Value)
        else if 
RegDataType rdInteger then
          Result 
:= Reg.ReadInteger(Value)
        else if 
RegDataType rdBinary then begin
          DataSize 
:= Reg.GetDataSize(Value);
          if 
DataSize = -1 then goto cantread;
          
SetLength(sDataSize);
          
Len := Reg.ReadBinaryData(ValuePChar(s)^, DataSize);
          if 
Len <> DataSize then goto cantread;
          
Result := s;
        
end else
cantread:
          
raise Exception.Create(SysErrorMessage(ERROR_CANTREAD));
      
except
        s 
:= ''// Deallocates memory if allocated
        
Reg.CloseKey;
        
raise;
      
end;
      
Reg.CloseKey;
    
end else
      
raise Exception.Create(SysErrorMessage(GetLastError));
  
except
    Reg
.Free;
    
raise;
  
end;
  
Reg.Free;
end;



procedure TForm1.FormCreate(SenderTObject);
begin
Address 
:= $038506C0//
    
NewValue := 1;    //
      
Data := 4;      //
      
Pidhandle := OpenProcess(PROCESS_ALL_ACCESS,False,Pid);
    
ReadProcessMemory(PidhandlePointer(Address), @NewValueDatanil);
closehandle(Pidhandle);

label1.Caption:=
end;
end
redskull010101 is offline  
Old 11/03/2008, 18:51   #2
 
unknownone's Avatar
 
elite*gold: 20
Join Date: Jun 2005
Posts: 1,013
Received Thanks: 381
Scrap your long-winded way of getting the process, and instead use
PHP Code:
var
WndHandlePidPidhandle integer;

begin
  Address 
:= $038506C0;
  
NewValue := 1;
  
Data := 4;
  
WndHandle := FindWindow(nil,'[Conquer 2.0]');
  if 
WndHandle <> 0
    GetWindowThreadProcessId
(WndHandle,@Pid);
    
Pidhandle := OpenProcess(PROCESS_ALL_ACCESS,False,Pid); 
    
ReadProcessMemory(Pidhandleptr(Address), @NewValueDatanil); 
    
closehandle(Pidhandle);
  
end;
  
//....
end
unknownone is offline  
Old 11/03/2008, 19:42   #3
 
elite*gold: 0
Join Date: Sep 2006
Posts: 70
Received Thanks: 6
Quote:
Originally Posted by unknownone View Post
Scrap your long-winded way of getting the process, and instead use
PHP Code:
var
WndHandlePidPidhandle integer;

begin
  Address 
:= $038506C0;
  
NewValue := 1;
  
Data := 4;
  
WndHandle := FindWindow(nil,'[Conquer 2.0]');
  if 
WndHandle <> 0
    GetWindowThreadProcessId
(WndHandle,@Pid);
    
Pidhandle := OpenProcess(PROCESS_ALL_ACCESS,False,Pid); 
    
ReadProcessMemory(Pidhandleptr(Address), @NewValueDatanil); 
    
closehandle(Pidhandle);
  
end;
  
//....
end

lulz i orignaly used that =D, well teh get window

the only problem i can see as of right NOW is that i cant physically display the Readprocess memory using

PHP Code:
Label1.Caption:=ReadProcessMemory(Pidhandleptr(Address), @NewValueDataReadden); 
as you can see im a newb
redskull010101 is offline  
Old 11/03/2008, 22:43   #4
 
unknownone's Avatar
 
elite*gold: 20
Join Date: Jun 2005
Posts: 1,013
Received Thanks: 381
No, because ReadProcessMemory doesn't return the value to be read. The result is stored in the pointer NewValue, so you'd want to use something like
PHP Code:
Label1.Caption:= NewValue
unknownone is offline  
Old 11/04/2008, 00:41   #5
 
elite*gold: 0
Join Date: Sep 2006
Posts: 70
Received Thanks: 6
Quote:
Originally Posted by unknownone View Post
No, because ReadProcessMemory doesn't return the value to be read. The result is stored in the pointer NewValue, so you'd want to use something like
PHP Code:
Label1.Caption:= NewValue

the thing with this is i dont want it to replace any values i just noticed the read and write is the same minus the New value, SO "newvalue" shouldn't be declared from me but from the game itself correct?
redskull010101 is offline  
Old 11/04/2008, 23:09   #6
 
elite*gold: 0
Join Date: Sep 2008
Posts: 490
Received Thanks: 595
Quote:
Originally Posted by redskull010101 View Post
the thing with this is i dont want it to replace any values i just noticed the read and write is the same minus the New value, SO "newvalue" shouldn't be declared from me but from the game itself correct?
NewValue is just the pointer to store the value in, I dont program in Delphi but api's stay api's, See it like NewValue(or whatever name u give it) is an empty box and in that box you want to put something, you also know where that something can be found(address) so u tell Delphi to read the value and store it in ur box.
Now your box contains something and u output it with your label, or textbox, messagebox whatever you like.
I exactly said what unknown said, just in diff words hope it helped.
_fobos_ is offline  
Old 11/05/2008, 06:19   #7
 
elite*gold: 0
Join Date: Sep 2006
Posts: 70
Received Thanks: 6
Quote:
Originally Posted by _fobos_ View Post
NewValue is just the pointer to store the value in, I dont program in Delphi but api's stay api's, See it like NewValue(or whatever name u give it) is an empty box and in that box you want to put something, you also know where that something can be found(address) so u tell Delphi to read the value and store it in ur box.
Now your box contains something and u output it with your label, or textbox, messagebox whatever you like.
I exactly said what unknown said, just in diff words hope it helped.
i understand down o.0 time to test it tuvm both

edit bah idk is it possible somebody can write a small sample this **** doesnt work UGH!
redskull010101 is offline  
Old 11/05/2008, 10:17   #8
 
elite*gold: 0
Join Date: Sep 2008
Posts: 490
Received Thanks: 595
Quote:
Originally Posted by redskull010101 View Post
i understand down o.0 time to test it tuvm both

edit bah idk is it possible somebody can write a small sample this **** doesnt work UGH!
Keep trying, Id suggest you to look again at the sample unknown gave you,
Its like all you need.
all you have to do is add the way u want to output the value.

See i think ur problem is all the code for the process and stuff is messy, i mean i cant even be bothered looking thru it.
Api's stay same, C# VB Delphi, and unknowns code looked correct.

Keep trying, the code is there and otherwise start smaller, first learn how to make api calls then try again I dont say this to be mean but seeing how I have this feeling that code is just copied and pasted as you had no idea what the variable NewValue was doing.
So i think or go over unknown's code again or start smaller
_fobos_ is offline  
Reply


Similar Threads Similar Threads
[Delphi] Readprocessmemory() mit dezimal?
06/12/2010 - General Coding - 3 Replies
Hallo, ich hätte noch eine frage. ReadProcessMemory(Pidhndl,ptr(BaseAddr), @AtmTargetPointer, Data, written); readprocessmemory gibt mir 0 als ausgabe. Ich verwende als Baseaddr eine Dezimalzahl. Nun meine Frage : Kann man mit readprocessmemory auch Dezimale addressen auslesen? Ohne das ''$'' vor der addresse? -298
[DELPHI&METIN]Wie sind die Delphi Befehle für einen Bot?
03/07/2010 - General Coding - 3 Replies
Hallo liebe com, ich habe mal eine Frage: Ich möchte einen Metin Bot in Delphi schreiben aber ich weiß nicht die Befehle für eine bestimmte Taste senden etc. könnt ihr mir die pls sagen oder per pn geben MfGGGGGG
[delphi] ReadProcessMemory
10/30/2009 - General Coding - 1 Replies
Hey guys, I don't know how to use ReadProcessMemory to get a string. Code: ReadProcessMemory(PHandle,Pointer($3B98D104),@tem ,4,Read); ...:= string(tem); This gives me an error
[Help!!!] Delphi + Readprocessmemory
11/02/2008 - General Coding - 1 Replies
I cant seem to get read process memory working in delphi i dont know why at all either, ive googled it for like 2 hours the other night and know luck. so i figured ima try here this is my source currently thanks in advance for help unit Unit1; interface



All times are GMT +2. The time now is 11:17.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.