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 


C++ use dbk for WriteProcessMemory API

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

Joined: 29 Oct 2021
Posts: 3

PostPosted: Fri Oct 29, 2021 7:35 am    Post subject: C++ use dbk for WriteProcessMemory API Reply with quote

Hello,
Trying to edit memory which guarding with Game guard game.
I can't edit memory when default settings with C.E.
But When I change the Debugging Options->Use windows debugger to use kernelmode driver (Requires DBVM), I can successfully change the memory.

I want to code in C++.
WriteProcessMemory fails, GetLastError returns 5 which is ACCESS_DENIED.

So I want to use dbk32.sys (Cheat Engine's file) to write memory.

But GetProcAddress returns 0.

Need Help, Thanks.

My C++ Code:
Code:

typedef   HANDLE(__stdcall* OPfunc)(DWORD dwDesiredAccess, BOOL  bInheritHandle, DWORD dwProcessId);
typedef   bool(__stdcall* WPMfunc)(HANDLE  hProcess, LPVOID  lpBaseAddress, LPCVOID lpBuffer, SIZE_T  nSize, SIZE_T* lpNumberOfBytesWritten);


HINSTANCE ce_hDLL = LoadLibrary("C:\\Program Files\\Cheat Engine 7.3\\dbk32.sys");   
   if (ce_hDLL == NULL) { // there is no error, loads sys file successfully
      MessageBoxA(0, "Error! Couldnt Load dbk32.dll! Quiting.", "ERROR!", MB_ICONINFORMATION);
      return 7;
   }

   OPfunc OP;
   OP = (OPfunc)GetProcAddress(ce_hDLL, "OP"); // HERE IS THE FAIL. 0

         WPMfunc WPM;
   WPM = (WPMfunc)GetProcAddress(ce_hDLL, "WPM"); // THIS TOO 0
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Fri Oct 29, 2021 5:47 pm    Post subject: Reply with quote

Drivers are not loaded with LoadLibrary. You also do not use GetProcAddress with them to call their functions, you use the DeviceIoControl API.

https://docs.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-deviceiocontrol

For loading/unloading the driver, you need to use the Windows service manager:
- OpenSCManager
- CreateService / OpenService
- ChangeServiceConfig (if needed for your specific setup)
- StartService

and so on. All service related functions can be found on MSDN as well here:
https://docs.microsoft.com/en-us/windows/win32/services/service-functions

There are other means of loading a driver, but I'd suggest not digging into those until you understand what you're doing with the basics of using one first.

You can find the needed IOCTL info for CE's driver here:
https://github.com/cheat-engine/cheat-engine/blob/master/Cheat%20Engine/dbk32/DBK32functions.pas

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
emmmre
How do I cheat?
Reputation: 0

Joined: 29 Oct 2021
Posts: 3

PostPosted: Sun Oct 31, 2021 2:18 pm    Post subject: Reply with quote

atom0s wrote:
Drivers are not loaded with LoadLibrary...

Thank you very much, I fixed issue with creating my own driver.
Back to top
View user's profile Send private message
syevale123
How do I cheat?
Ban
Reputation: 0

Joined: 28 Jan 2023
Posts: 2

PostPosted: Mon Apr 10, 2023 12:50 am    Post subject: Thanks Reply with quote

Your suggestion is very important for me. It is useful for my work . Thanks a lot.
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