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 


How does CE get specific registers?

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

Joined: 19 Dec 2011
Posts: 23

PostPosted: Fri Feb 17, 2012 7:45 pm    Post subject: How does CE get specific registers? Reply with quote

Hi. I tried to get specific registers(like CE, Find out what write -- ).
so I wrote :


function DebugActiveProcessStop(dwProcessId: DWORD): BOOL; stdcall;
external kernel32 name 'DebugActiveProcessStop';

procedure CreateProcessDebugEvent_(DBG_EVENT:Debug_Event);
begin
Con.ContextFlags:=CONTEXT_DEBUG_REGISTERS;
GetThreadContext(DBG_EVENT.CreateProcessInfo.hThread, Con);

Form1.Label1.Caption:='EAX - '+IntToHex(Con.Eax, 8);
Form1.Label2.Caption:='EBX - '+IntToHex(Con.Ebx, 8);
Form1.Label3.Caption:='ECX - '+IntToHex(Con.Ecx, 8);
Form1.Label4.Caption:='EDX - '+IntToHex(Con.Edx, 8);
end;

function ThreadFunc:BOOLEAN; stdcall;
var Devent:Debug_event;
begin
//CreateProcessDebugEvent_(Devent);

while (WaitForDebugEvent(Devent, Infinite)) do
begin
if Devent.dwDebugEventCode = Create_Process_Debug_Event then
begin
CreateProcessDebugEvent_(Devent);
end
else
if Devent.dwDebugEventCode = Exception_Debug_Event then
begin
CreateProcessDebugEvent_(Devent);
end
else
if Devent.dwDebugEventCode = Exit_Process_Debug_Event then
begin
Break;
end;
ContinueDebugEvent(Devent.dwProcessId, Devent.dwThreadId, DBG_CONTINUE);
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var con:Context;
ProcessId:THandle;
ThreadHandle, TID:THandle;
begin
ProcessId:=GetProcessIdByName('Pinball.exe'); // This is my function to get ProcessId
if ProcessId = 0 then
begin
Raise Exception.Create('Can''t get ProcessId. Check your process name.');
exit;
end;

if not DebugActiveProcess(ProcessId) then
begin
Raise Exception.Create('failed debug process.');
exit;
end;

ThreadHandle:=CreateThread(nil, 0, @ThreadFunc, 0, TID);
end;

--------

But It returns 00000000.
eax , ebx, ecx, edx are 00000000..
so I tried to attach that process by CE.
CE Gets Specific Registers. (not like 00000000..)
I want to get the specific registers(LIKE CE!!).
Is there anyone to know??
please answer to me.
thanks for the reading.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 475

Joined: 09 May 2003
Posts: 25976
Location: The netherlands

PostPosted: Fri Feb 17, 2012 8:03 pm    Post subject: Reply with quote

the Debug_Event structure you get for breakpoints and other exceptions do not contain a thread handle. Only a thread id.
You need to look up the handle if you stored it, or reopen the thread using the thread id

_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
JWP Programs
Newbie cheater
Reputation: 0

Joined: 19 Dec 2011
Posts: 23

PostPosted: Fri Feb 17, 2012 8:44 pm    Post subject: Thanks!! Reply with quote

Thanks for the fast answering!
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