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 


[Plugin] Using OpenProcess hook

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
tawnix
How do I cheat?
Reputation: 0

Joined: 04 Jan 2024
Posts: 3

PostPosted: Fri Jan 05, 2024 9:54 pm    Post subject: [Plugin] Using OpenProcess hook Reply with quote

Hello everyone,


I have a question about cheat engines OpenProcess function that is used to grab a handle with i believe is query information.


I'm attempting to open a process, but that process will strip handles or simply deny a handle creation of ANY kind. Which results in cheat engines functionality breaking, I already have a RPM / WPM / VirtualQueryEx hooks in place that will use a driver instead of the win32 api.


Is there an equivalent method of OpenProcess in kernel that CE will be happy with the result?


CheatEngine expects a HANDLE to be returned in OpenProcess, I've tried simply just returning 1 to bypass a null check but then this questionable fix will break cheat engines memory viewer, scanning, etc.

I don't need a handle to the game as im doing everything through kernel, is there a simple way to achieve CE functionality without needing a real handle to a process?


Anyone have some ideas?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4721

PostPosted: Sat Jan 06, 2024 12:23 am    Post subject: Reply with quote

Do the CE kernel routines in Edit -> Settings -> Extra work?
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
tawnix
How do I cheat?
Reputation: 0

Joined: 04 Jan 2024
Posts: 3

PostPosted: Sat Jan 06, 2024 2:41 am    Post subject: Reply with quote

ParkourPenguin wrote:
Do the CE kernel routines in Edit -> Settings -> Extra work?


Don't want CE's driver loaded, but I found this in cheat engine source code on github.(Can't post links but look for the file "cheatengine/DBKKernel/IOPLDispatcher.c" Line 386.

So I just hook the OpenProcess and do the kernel equivalent to OpenProcess.


If anyone runs into this post in future, hook the OpenProcess function in CE SDK, and just do this in your driver.

Code:
auto HandleOpenProcess = [&]() {
    OpenProcessRequest* Request = reinterpret_cast<OpenProcessRequest*>(Irp->AssociatedIrp.SystemBuffer);

    HANDLE hTargetHandle{ 0 };
    PEPROCESS TargetProcess{ 0 };
    if (NT_SUCCESS(PsLookupProcessByProcessId(Request->ProcessID, &TargetProcess))) {
        if (!NT_SUCCESS(ObOpenObjectByPointer(TargetProcess, NULL, NULL, PROCESS_ALL_ACCESS, *PsProcessType, KernelMode, &hTargetHandle))) {
           
            Status = STATUS_UNSUCCESSFUL;
            return;
        }

        RtlCopyMemory(Request->pOutProcessHandle, &hTargetHandle, sizeof(hTargetHandle));
    }

    Irp->IoStatus.Information = sizeof(STATUS_SUCCESS);
   
    Status = STATUS_SUCCESS;
    };
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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