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 


Need Help with Socket Commands for Utilizing ceserver

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

Joined: 27 May 2023
Posts: 4

PostPosted: Sat May 27, 2023 4:24 am    Post subject: Need Help with Socket Commands for Utilizing ceserver Reply with quote

I want to use ceserver from my app, but I don't know the socket commands for it. If anyone can help me with the following commands: reading the data from an address, and writing the data to an address.
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: Sat May 27, 2023 2:50 pm    Post subject: Reply with quote

You can find the full source code to CEServer here:
https://github.com/cheat-engine/cheat-engine/tree/master/Cheat%20Engine/ceserver

More specifically, the list of commands and their ids here:
https://github.com/cheat-engine/cheat-engine/blob/master/Cheat%20Engine/ceserver/ceserver.h#L15

In that same header you will find all the structure definitions for what each command can return in the given buffer etc.

For reading memory, you can find how that is handled here:
https://github.com/cheat-engine/cheat-engine/blob/master/Cheat%20Engine/ceserver/ceserver.c#L808

Which shows that it makes use of a 'CeReadProcessMemoryInput' structure read from the socket which can be found/defined here:
https://github.com/cheat-engine/cheat-engine/blob/master/Cheat%20Engine/ceserver/ceserver.h#L147

Then do similar for each other entry you need to work with.

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

Joined: 27 May 2023
Posts: 4

PostPosted: Sun May 28, 2023 12:56 am    Post subject: Reply with quote

I appreciate your help, but I can't seem to make it work, though. Here is the sample code
Code:

import socket
import struct

ceserver_host = '127.0.0.1'
ceserver_port = 52736
pid = 2888
try:
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((ceserver_host, ceserver_port))

    # Send CMD_OPENPROCESS command
    command = 3
    s.send(struct.pack('<I', command))
    s.send(struct.pack('<I', pid))

    response = s.recv(4)
    process_handle = struct.unpack('<I', response)[0]
    print('Process handle:', process_handle)

finally:
    s.close()

# ceserver debug_log
OpenProcess(1207959552)
processhandle=0
Error: recv returned 0

Based on the source code
Code:
debug_log("OpenProcess(%d)\n", pid);
I think it should have printed the pid of 2888 because that's what I have passed
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sun May 28, 2023 3:20 am    Post subject: Reply with quote

Ensure you have the correct notation for the PID, it could be hex or decimal.
Back to top
View user's profile Send private message
Doraneko
Newbie cheater
Reputation: 1

Joined: 22 Jul 2018
Posts: 10
Location: Japan Tokyo

PostPosted: Sun May 28, 2023 6:41 am    Post subject: Reply with quote

The ceserver command is exactly 1 byte.

s.send(struct.pack("<B", command))
Back to top
View user's profile Send private message
MightySabu
How do I cheat?
Reputation: 0

Joined: 27 May 2023
Posts: 4

PostPosted: Sun May 28, 2023 7:19 am    Post subject: Reply with quote

Doraneko wrote:
The ceserver command is exactly 1 byte.

s.send(struct.pack("<B", command))


yes thank you Surprised
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