├── .gitattributes
├── .gitignore
├── CEServerPS4.sln
├── CEServerPS4
├── App.config
├── CEServerPS4.csproj
├── CheatEngineConstants.cs
├── CheatEnginePackets
│ ├── Architecture.cs
│ ├── C2S
│ │ ├── CheatEngineCommand.cs
│ │ ├── CloseHandleCommand.cs
│ │ ├── CommandEnum.cs
│ │ ├── ContinueForDebugEventCommand.cs
│ │ ├── CreateToolHelp32SnapshotCommand.cs
│ │ ├── Exceptions
│ │ │ └── CommandNotInitializedException.cs
│ │ ├── GetABICommand.cs
│ │ ├── GetArchitectureCommand.cs
│ │ ├── GetSymbolsFromFileCommand.cs
│ │ ├── GetThreadContextCommand.cs
│ │ ├── GetVersionCommand.cs
│ │ ├── ICheatEngineCommand.cs
│ │ ├── Module32FirstCommand.cs
│ │ ├── Module32NextCommand.cs
│ │ ├── OpenProcessCommand.cs
│ │ ├── Process32FirstCommand.cs
│ │ ├── Process32NextCommand.cs
│ │ ├── ReadProcessMemoryCommand.cs
│ │ ├── RemoveBreakPointCommand.cs
│ │ ├── ResumeThreadCommand.cs
│ │ ├── SetBreakPointCommand.cs
│ │ ├── StartDebugCommand.cs
│ │ ├── StopDebugCommand.cs
│ │ ├── SuspendThreadCommand.cs
│ │ ├── VirtualQueryExCommand.cs
│ │ ├── VirtualQueryExFullCommand.cs
│ │ ├── WaitForDebugEventCommand.cs
│ │ └── WriteProcessMemoryCommand.cs
│ ├── MissingCommandHandlerException.cs
│ ├── PacketManager.cs
│ └── S2C
│ │ ├── CloseHandleResponse.cs
│ │ ├── ContinueForDebugEventResponse.cs
│ │ ├── GetABIResponse.cs
│ │ ├── GetArchitectureResponse.cs
│ │ ├── GetSymbolsFromFileResponse.cs
│ │ ├── GetVersionResponse.cs
│ │ ├── HandleResponse.cs
│ │ ├── ICheatEngineResponse.cs
│ │ ├── Module32Response.cs
│ │ ├── Process32Response.cs
│ │ ├── ReadProcessMemoryResponse.cs
│ │ ├── ThreadContextResponse.cs
│ │ ├── VirtualQueryExFullResponse.cs
│ │ ├── VirtualQueryExResponse.cs
│ │ ├── WaitForDebugEventResponse.cs
│ │ └── WriteProcessMemoryResponse.cs
├── CheatEngineServer.cs
├── EventHandler
│ ├── DebugEventHandler.cs
│ ├── Event
│ │ ├── ContinueDebugEvent.cs
│ │ ├── DebugThreadEvent.cs
│ │ ├── ProcessReumeEvent.cs
│ │ ├── RemoveBreakPointEvent.cs
│ │ ├── RemoveWatchPointEvent.cs
│ │ ├── ResumeThreadEvent.cs
│ │ ├── SetBreakPointEvent.cs
│ │ ├── SetWatchPointEvent.cs
│ │ ├── SuspendThreadEvent.cs
│ │ └── ThreadContextEvent.cs
│ ├── Handler.cs
│ └── Request
│ │ ├── ContinueDebugEventRequest.cs
│ │ ├── RemoveBreakPointRequest.cs
│ │ ├── RemoveWatchPointRequest.cs
│ │ ├── ResumeThreadRequest.cs
│ │ ├── SetBreakPointRequest.cs
│ │ ├── SetWatchPointRequest.cs
│ │ ├── SuspendThreadRequest.cs
│ │ └── ThreadContextRequest.cs
├── PS4API
│ ├── DebugAPI.cs
│ ├── MemoryAPI.cs
│ ├── PS4APIWrapper.cs
│ ├── PS4DedugAPIWrapper.cs
│ ├── PS4Static.cs
│ └── ToolHelp.cs
├── PS4CEServerWindows.Designer.cs
├── PS4CEServerWindows.cs
├── PS4CEServerWindows.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── RJToggleButton.cs
├── lib
│ └── libdebug.dll
└── packages.config
├── LICENSE
├── README.md
└── libdebug.dll
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | bld/
24 | [Bb]in/
25 | [Oo]bj/
26 | [Ll]og/
27 |
28 | # Visual Studio 2015/2017 cache/options directory
29 | .vs/
30 | # Uncomment if you have tasks that create the project's static files in wwwroot
31 | #wwwroot/
32 |
33 | # Visual Studio 2017 auto generated files
34 | Generated\ Files/
35 |
36 | # MSTest test Results
37 | [Tt]est[Rr]esult*/
38 | [Bb]uild[Ll]og.*
39 |
40 | # NUNIT
41 | *.VisualState.xml
42 | TestResult.xml
43 |
44 | # Build Results of an ATL Project
45 | [Dd]ebugPS/
46 | [Rr]eleasePS/
47 | dlldata.c
48 |
49 | # Benchmark Results
50 | BenchmarkDotNet.Artifacts/
51 |
52 | # .NET Core
53 | project.lock.json
54 | project.fragment.lock.json
55 | artifacts/
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_h.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *_wpftmp.csproj
81 | *.log
82 | *.vspscc
83 | *.vssscc
84 | .builds
85 | *.pidb
86 | *.svclog
87 | *.scc
88 |
89 | # Chutzpah Test files
90 | _Chutzpah*
91 |
92 | # Visual C++ cache files
93 | ipch/
94 | *.aps
95 | *.ncb
96 | *.opendb
97 | *.opensdf
98 | *.sdf
99 | *.cachefile
100 | *.VC.db
101 | *.VC.VC.opendb
102 |
103 | # Visual Studio profiler
104 | *.psess
105 | *.vsp
106 | *.vspx
107 | *.sap
108 |
109 | # Visual Studio Trace Files
110 | *.e2e
111 |
112 | # TFS 2012 Local Workspace
113 | $tf/
114 |
115 | # Guidance Automation Toolkit
116 | *.gpState
117 |
118 | # ReSharper is a .NET coding add-in
119 | _ReSharper*/
120 | *.[Rr]e[Ss]harper
121 | *.DotSettings.user
122 |
123 | # JustCode is a .NET coding add-in
124 | .JustCode
125 |
126 | # TeamCity is a build add-in
127 | _TeamCity*
128 |
129 | # DotCover is a Code Coverage Tool
130 | *.dotCover
131 |
132 | # AxoCover is a Code Coverage Tool
133 | .axoCover/*
134 | !.axoCover/settings.json
135 |
136 | # Visual Studio code coverage results
137 | *.coverage
138 | *.coveragexml
139 |
140 | # NCrunch
141 | _NCrunch_*
142 | .*crunch*.local.xml
143 | nCrunchTemp_*
144 |
145 | # MightyMoose
146 | *.mm.*
147 | AutoTest.Net/
148 |
149 | # Web workbench (sass)
150 | .sass-cache/
151 |
152 | # Installshield output folder
153 | [Ee]xpress/
154 |
155 | # DocProject is a documentation generator add-in
156 | DocProject/buildhelp/
157 | DocProject/Help/*.HxT
158 | DocProject/Help/*.HxC
159 | DocProject/Help/*.hhc
160 | DocProject/Help/*.hhk
161 | DocProject/Help/*.hhp
162 | DocProject/Help/Html2
163 | DocProject/Help/html
164 |
165 | # Click-Once directory
166 | publish/
167 |
168 | # Publish Web Output
169 | *.[Pp]ublish.xml
170 | *.azurePubxml
171 | # Note: Comment the next line if you want to checkin your web deploy settings,
172 | # but database connection strings (with potential passwords) will be unencrypted
173 | *.pubxml
174 | *.publishproj
175 |
176 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
177 | # checkin your Azure Web App publish settings, but sensitive information contained
178 | # in these scripts will be unencrypted
179 | PublishScripts/
180 |
181 | # NuGet Packages
182 | *.nupkg
183 | # The packages folder can be ignored because of Package Restore
184 | **/[Pp]ackages/*
185 | # except build/, which is used as an MSBuild target.
186 | !**/[Pp]ackages/build/
187 | # Uncomment if necessary however generally it will be regenerated when needed
188 | #!**/[Pp]ackages/repositories.config
189 | # NuGet v3's project.json files produces more ignorable files
190 | *.nuget.props
191 | *.nuget.targets
192 |
193 | # Microsoft Azure Build Output
194 | csx/
195 | *.build.csdef
196 |
197 | # Microsoft Azure Emulator
198 | ecf/
199 | rcf/
200 |
201 | # Windows Store app package directories and files
202 | AppPackages/
203 | BundleArtifacts/
204 | Package.StoreAssociation.xml
205 | _pkginfo.txt
206 | *.appx
207 |
208 | # Visual Studio cache files
209 | # files ending in .cache can be ignored
210 | *.[Cc]ache
211 | # but keep track of directories ending in .cache
212 | !*.[Cc]ache/
213 |
214 | # Others
215 | ClientBin/
216 | ~$*
217 | *~
218 | *.dbmdl
219 | *.dbproj.schemaview
220 | *.jfm
221 | *.pfx
222 | *.publishsettings
223 | orleans.codegen.cs
224 |
225 | # Including strong name files can present a security risk
226 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
227 | #*.snk
228 |
229 | # Since there are multiple workflows, uncomment next line to ignore bower_components
230 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
231 | #bower_components/
232 |
233 | # RIA/Silverlight projects
234 | Generated_Code/
235 |
236 | # Backup & report files from converting an old project file
237 | # to a newer Visual Studio version. Backup files are not needed,
238 | # because we have git ;-)
239 | _UpgradeReport_Files/
240 | Backup*/
241 | UpgradeLog*.XML
242 | UpgradeLog*.htm
243 | ServiceFabricBackup/
244 | *.rptproj.bak
245 |
246 | # SQL Server files
247 | *.mdf
248 | *.ldf
249 | *.ndf
250 |
251 | # Business Intelligence projects
252 | *.rdl.data
253 | *.bim.layout
254 | *.bim_*.settings
255 | *.rptproj.rsuser
256 |
257 | # Microsoft Fakes
258 | FakesAssemblies/
259 |
260 | # GhostDoc plugin setting file
261 | *.GhostDoc.xml
262 |
263 | # Node.js Tools for Visual Studio
264 | .ntvs_analysis.dat
265 | node_modules/
266 |
267 | # Visual Studio 6 build log
268 | *.plg
269 |
270 | # Visual Studio 6 workspace options file
271 | *.opt
272 |
273 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
274 | *.vbw
275 |
276 | # Visual Studio LightSwitch build output
277 | **/*.HTMLClient/GeneratedArtifacts
278 | **/*.DesktopClient/GeneratedArtifacts
279 | **/*.DesktopClient/ModelManifest.xml
280 | **/*.Server/GeneratedArtifacts
281 | **/*.Server/ModelManifest.xml
282 | _Pvt_Extensions
283 |
284 | # Paket dependency manager
285 | .paket/paket.exe
286 | paket-files/
287 |
288 | # FAKE - F# Make
289 | .fake/
290 |
291 | # JetBrains Rider
292 | .idea/
293 | *.sln.iml
294 |
295 | # CodeRush personal settings
296 | .cr/personal
297 |
298 | # Python Tools for Visual Studio (PTVS)
299 | __pycache__/
300 | *.pyc
301 |
302 | # Cake - Uncomment if you are using it
303 | # tools/**
304 | # !tools/packages.config
305 |
306 | # Tabs Studio
307 | *.tss
308 |
309 | # Telerik's JustMock configuration file
310 | *.jmconfig
311 |
312 | # BizTalk build output
313 | *.btp.cs
314 | *.btm.cs
315 | *.odx.cs
316 | *.xsd.cs
317 |
318 | # OpenCover UI analysis results
319 | OpenCover/
320 |
321 | # Azure Stream Analytics local run output
322 | ASALocalRun/
323 |
324 | # MSBuild Binary and Structured Log
325 | *.binlog
326 |
327 | # NVidia Nsight GPU debugger configuration file
328 | *.nvuser
329 |
330 | # MFractors (Xamarin productivity tool) working folder
331 | .mfractor/
332 |
333 | # Local History for Visual Studio
334 | .localhistory/
335 |
--------------------------------------------------------------------------------
/CEServerPS4.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30104.148
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CEServerPS4", "CEServerPS4\CEServerPS4.csproj", "{91218BB6-DF7E-406C-8CC2-EFD5FFF732EC}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {91218BB6-DF7E-406C-8CC2-EFD5FFF732EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {91218BB6-DF7E-406C-8CC2-EFD5FFF732EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {91218BB6-DF7E-406C-8CC2-EFD5FFF732EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {91218BB6-DF7E-406C-8CC2-EFD5FFF732EC}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {BBA8FFB4-D264-486E-BBC5-80AA6D6D7FB8}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/CEServerPS4/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
58 |
--------------------------------------------------------------------------------
/CEServerPS4/CEServerPS4.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | AnyCPU
8 | {91218BB6-DF7E-406C-8CC2-EFD5FFF732EC}
9 | WinExe
10 | CEServerPS4
11 | CEServerPS4
12 | v4.7.2
13 | 512
14 | true
15 | true
16 | false
17 | publish\
18 | true
19 | Disk
20 | false
21 | Foreground
22 | 7
23 | Days
24 | false
25 | false
26 | true
27 | 0
28 | 1.0.0.%2a
29 | false
30 | true
31 |
32 |
33 |
34 |
35 | AnyCPU
36 | true
37 | full
38 | false
39 | bin\Debug\
40 | TRACE;DEBUG
41 | prompt
42 | 4
43 |
44 |
45 | AnyCPU
46 | pdbonly
47 | true
48 | bin\Release\
49 | TRACE;DEBUG
50 | prompt
51 | 4
52 | true
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | lib\libdebug.dll
61 |
62 |
63 |
64 | ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
65 |
66 |
67 |
68 |
69 |
70 | ..\packages\System.Threading.Tasks.Dataflow.6.0.2-mauipre.1.22102.15\lib\net461\System.Threading.Tasks.Dataflow.dll
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 | Form
132 |
133 |
134 | PS4CEServerWindows.cs
135 |
136 |
137 | Component
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 | False
174 | Microsoft .NET Framework 4.7.2 %28x86 and x64%29
175 | true
176 |
177 |
178 | False
179 | .NET Framework 3.5 SP1
180 | false
181 |
182 |
183 |
184 |
185 | PS4CEServerWindows.cs
186 |
187 |
188 |
189 |
190 |
191 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
192 |
193 |
194 |
195 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEngineConstants.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Net;
6 | using System.Net.Sockets;
7 | using System.Text;
8 | using CEServerPS4.CheatEnginePackets.C2S;
9 | using System.IO;
10 | using System.Threading.Tasks;
11 | using System.Threading;
12 |
13 | namespace CEServerPS4
14 | {
15 | public static class CheatEngineConstants
16 | {
17 | public static bool isCustomCheatEngine
18 | {
19 | get; set;
20 | }
21 |
22 | }
23 |
24 | public enum ConnectType
25 | {
26 | INIT,
27 | SUCCESS,
28 | FAILED
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/Architecture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace CEServerPS4.CheatEnginePackets
7 | {
8 | //https://github.com/cheat-engine/cheat-engine/blob/master/Cheat%20Engine/ceserver/ceserver.c#L137-L153
9 | public enum Architecture
10 | {
11 | i386 = 0,
12 | x86_64 = 1,
13 | arm = 2,
14 | aarch = 3
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/CheatEngineCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using CEServerPS4.CheatEnginePackets.S2C;
6 |
7 | namespace CEServerPS4.CheatEnginePackets.C2S
8 | {
9 | public abstract class CheatEngineCommand : ICheatEngineCommand where T : ICheatEngineResponse
10 | {
11 | public bool initialized { get; internal set; }
12 |
13 |
14 |
15 | /**
16 | * Initializes a command from a binary reader
17 | */
18 | public abstract void Initialize(System.IO.BinaryReader reader);
19 | public abstract CommandType CommandType { get; }
20 |
21 |
22 | public abstract T Process();
23 |
24 |
25 | public byte[] ProcessAndGetBytes()
26 | {
27 | T output = this.Process();
28 | return output.Serialize();
29 | }
30 |
31 | public void Unintialize()
32 | {
33 | this.initialized = false;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/CloseHandleCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class CloseHandleCommand : CheatEngineCommand
11 | {
12 | public IntPtr Handle;
13 | public override CommandType CommandType => CommandType.CMD_CLOSEHANDLE;
14 |
15 | public CloseHandleCommand()
16 | {
17 |
18 | }
19 | public CloseHandleCommand(IntPtr handle)
20 | {
21 | this.Handle = handle;
22 | this.initialized = true;
23 | }
24 |
25 | public override void Initialize(BinaryReader reader)
26 | {
27 | this.Handle = (IntPtr)reader.ReadUInt32();
28 | this.initialized = true;
29 | }
30 |
31 | public override CloseHandleResponse Process()
32 | {
33 | return new CloseHandleResponse(PS4API.ToolHelp.CloseHandle(this.Handle));
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/CommandEnum.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace CEServerPS4
8 | {
9 | public enum CommandType : byte
10 | {
11 | CMD_GETVERSION = 0,
12 | CMD_CLOSECONNECTION = 1,
13 | CMD_TERMINATESERVER = 2,
14 | CMD_OPENPROCESS = 3,
15 | CMD_CREATETOOLHELP32SNAPSHOT = 4,
16 | CMD_PROCESS32FIRST = 5,
17 | CMD_PROCESS32NEXT = 6,
18 | CMD_CLOSEHANDLE = 7,
19 | CMD_VIRTUALQUERYEX = 8,
20 | CMD_READPROCESSMEMORY = 9,
21 | CMD_WRITEPROCESSMEMORY = 10,
22 | CMD_STARTDEBUG = 11,
23 | CMD_STOPDEBUG = 12,
24 | CMD_WAITFORDEBUGEVENT = 13,
25 | CMD_CONTINUEFROMDEBUGEVENT = 14,
26 | CMD_SETBREAKPOINT = 15,
27 | CMD_REMOVEBREAKPOINT = 16,
28 | CMD_SUSPENDTHREAD = 17,
29 | CMD_RESUMETHREAD = 18,
30 | CMD_GETTHREADCONTEXT = 19,
31 | CMD_SETTHREADCONTEXT = 20,
32 | CMD_GETARCHITECTURE = 21,
33 | CMD_MODULE32FIRST = 22,
34 | CMD_MODULE32NEXT = 23,
35 | CMD_GETSYMBOLLISTFROMFILE = 24,
36 | CMD_LOADEXTENSION = 25,
37 | CMD_ALLOC = 26,
38 | CMD_FREE = 27,
39 | CMD_CREATETHREAD = 28,
40 | CMD_LOADMODULE = 29,
41 | CMD_SPEEDHACK_SETSPEED = 30,
42 | CMD_VIRTUALQUERYEXFULL = 31,
43 | CMD_GETREGIONINFO = 32,
44 | CMD_COMMANDLIST2 = 255,
45 | CMD_GETABI =33,
46 | CMD_SETWATCHPOINT = 115,
47 | CMD_REMOVEWATCHPOINT = 116
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/ContinueForDebugEventCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class ContinueForDebugEventCommand : CheatEngineCommand
11 | {
12 | public override CommandType CommandType => CommandType.CMD_CONTINUEFROMDEBUGEVENT;// throw new NotImplementedException();
13 | public IntPtr handle;
14 | public uint tid;
15 | public uint ignore;
16 | public ContinueForDebugEventCommand()
17 | {
18 |
19 | }
20 |
21 | public ContinueForDebugEventCommand(IntPtr handle,uint tid,uint ignore)
22 | {
23 | this.handle = handle;
24 | this.tid = tid;
25 | this.ignore = ignore;
26 | this.initialized = true;
27 | }
28 |
29 | public override void Initialize(BinaryReader reader)
30 | {
31 | this.handle = (IntPtr)reader.ReadInt32();
32 | this.tid = reader.ReadUInt32();
33 | this.ignore = reader.ReadUInt32();
34 | this.initialized = true;
35 | }
36 |
37 | public override ContinueForDebugEventResponse Process()
38 | {
39 | IntPtr hande = PS4API.DebugAPI.ContinueForDebugEvent(handle, tid, ignore);
40 |
41 | return new ContinueForDebugEventResponse(hande);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/CreateToolHelp32SnapshotCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using CEServerPS4.PS4API;
8 |
9 | namespace CEServerPS4.CheatEnginePackets.C2S
10 | {
11 | public class CreateToolHelp32SnapshotCommand : CheatEngineCommand
12 | {
13 | public PS4API.ToolHelp.SnapshotFlags SnapshotFlags;
14 | public uint ProcessID;
15 |
16 | public sealed override CommandType CommandType => CommandType.CMD_CREATETOOLHELP32SNAPSHOT;// throw new NotImplementedException();
17 |
18 | public CreateToolHelp32SnapshotCommand()
19 | {
20 |
21 | }
22 | public CreateToolHelp32SnapshotCommand(PS4API.ToolHelp.SnapshotFlags snapshotFlags, uint pid)
23 | {
24 | this.SnapshotFlags = snapshotFlags;
25 | this.ProcessID = pid;
26 | this.initialized = true;
27 | }
28 |
29 | public override HandleResponse Process()
30 | {
31 | if (!this.initialized)
32 | {
33 | throw new Exceptions.CommandNotInitializedException();
34 | }
35 | IntPtr handle = ToolHelp.CreateToolhelp32Snapshot(this.SnapshotFlags, this.ProcessID);
36 |
37 | return new HandleResponse(handle);
38 | }
39 |
40 | public override void Initialize(BinaryReader reader)
41 | {
42 | this.SnapshotFlags = (PS4API.ToolHelp.SnapshotFlags)reader.ReadUInt32();
43 | this.ProcessID = reader.ReadUInt32();
44 | this.initialized = true;
45 |
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/Exceptions/CommandNotInitializedException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace CEServerPS4.CheatEnginePackets.C2S.Exceptions
7 | {
8 | class CommandNotInitializedException : Exception
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/GetABICommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class GetABICommand : CheatEngineCommand
11 | {
12 | public override CommandType CommandType => CommandType.CMD_GETABI;
13 |
14 | public GetABICommand()
15 | {
16 | this.initialized = true;
17 | }
18 | public override void Initialize(BinaryReader reader)
19 | {
20 | this.initialized = true;
21 | }
22 |
23 | public override GetABIResponse Process()
24 | {
25 | //https://github.com/cheat-engine/cheat-engine/blob/master/Cheat%20Engine/ceserver/ceserver.c#L137-L153
26 | return new GetABIResponse();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/GetArchitectureCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class GetArchitectureCommand : CheatEngineCommand
11 | {
12 | public override CommandType CommandType => CommandType.CMD_GETARCHITECTURE;
13 |
14 | public GetArchitectureCommand()
15 | {
16 | this.initialized = true;
17 | }
18 | public override void Initialize(BinaryReader reader)
19 | {
20 | this.initialized = true;
21 | }
22 |
23 | public override GetArchitectureResponse Process()
24 | {
25 | //https://github.com/cheat-engine/cheat-engine/blob/master/Cheat%20Engine/ceserver/ceserver.c#L137-L153
26 | return new GetArchitectureResponse(Architecture.x86_64);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/GetSymbolsFromFileCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace CEServerPS4.CheatEnginePackets.C2S
10 | {
11 | public class GetSymbolsFromFileCommand : CheatEngineCommand
12 | {
13 |
14 | public string SymbolsFile;
15 | public override CommandType CommandType => CommandType.CMD_GETSYMBOLLISTFROMFILE;// throw new NotImplementedException();
16 |
17 | public GetSymbolsFromFileCommand() { }
18 |
19 | public GetSymbolsFromFileCommand(string path)
20 | {
21 | SymbolsFile = path;
22 | this.initialized = true;
23 | }
24 |
25 | public override void Initialize(BinaryReader reader)
26 | {
27 | int size = reader.ReadInt32();
28 | this.SymbolsFile = Encoding.UTF8.GetString( reader.ReadBytes(size));
29 | this.initialized = true;
30 | }
31 |
32 | public override GetSymbolsFromFileResponse Process()
33 | {
34 | return new GetSymbolsFromFileResponse(new byte[0]);
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/GetThreadContextCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class GetThreadContextCommand : CheatEngineCommand
11 | {
12 | public IntPtr Handle;
13 | public uint tid;
14 | public int type;
15 |
16 | public override CommandType CommandType => CommandType.CMD_GETTHREADCONTEXT;
17 |
18 | public GetThreadContextCommand() { }
19 |
20 | public GetThreadContextCommand(IntPtr handle, uint tid, int type)
21 | {
22 | this.Handle = handle;
23 | this.tid = tid;
24 | this.type = type;
25 | this.initialized = true;
26 | }
27 |
28 | public override void Initialize(BinaryReader reader)
29 | {
30 | Handle = (IntPtr)reader.ReadInt32();
31 | tid = reader.ReadUInt32();
32 | type = reader.ReadInt32();
33 | this.initialized = true;
34 | }
35 |
36 | public override ThreadContextResponse Process()
37 | {
38 |
39 | IntPtr ptr = PS4API.DebugAPI.GetThreadContext(Handle, tid, out PS4API.DebugAPI.CONTEXT Context, type);
40 | return new ThreadContextResponse(Context.regs, ptr);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/GetVersionCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using CEServerPS4.CheatEnginePackets.S2C;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class GetVersionCommand : CheatEngineCommand
11 | {
12 | public sealed override CommandType CommandType => CommandType.CMD_GETVERSION;
13 |
14 | public GetVersionCommand()
15 | {
16 | this.initialized = true;
17 | }
18 |
19 | public sealed override void Initialize(BinaryReader reader)
20 | {
21 | this.initialized = true;
22 | }
23 |
24 | public override GetVersionResponse Process()
25 | {
26 | if(!this.initialized)
27 | {
28 | throw new Exceptions.CommandNotInitializedException();
29 | }
30 | return new GetVersionResponse();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/ICheatEngineCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace CEServerPS4.CheatEnginePackets.C2S
7 | {
8 | public interface ICheatEngineCommand
9 | {
10 | bool initialized { get; }
11 |
12 | void Initialize(System.IO.BinaryReader reader);
13 |
14 | void Unintialize();
15 | CommandType CommandType { get; }
16 | byte[] ProcessAndGetBytes();
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/Module32FirstCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class Module32FirstCommand : CheatEngineCommand
11 | {
12 | public override CommandType CommandType => CommandType.CMD_MODULE32FIRST;
13 |
14 | public IntPtr Handle;
15 | public Module32FirstCommand()
16 | {
17 | }
18 |
19 | public Module32FirstCommand(IntPtr handle)
20 | {
21 | this.Handle = handle;
22 | this.initialized = true;
23 | }
24 |
25 | public sealed override void Initialize(BinaryReader reader)
26 | {
27 | this.Handle = (IntPtr)reader.ReadUInt32();
28 | this.initialized = true;
29 | }
30 |
31 | public override S2C.Module32Response Process()
32 | {
33 | PS4API.ToolHelp.MODULEENTRY32 moduleEntry = new PS4API.ToolHelp.MODULEENTRY32();
34 | moduleEntry.dwSize = (uint)Marshal.SizeOf(moduleEntry);
35 |
36 | var result = PS4API.ToolHelp.Module32First(this.Handle, ref moduleEntry);
37 |
38 | return new S2C.Module32Response(result, moduleEntry);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/Module32NextCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class Module32NextCommand : Module32FirstCommand
11 | {
12 | public override CommandType CommandType => CommandType.CMD_MODULE32NEXT;
13 |
14 | public override Module32Response Process()
15 | {
16 | PS4API.ToolHelp.MODULEENTRY32 moduleEntry = new PS4API.ToolHelp.MODULEENTRY32();
17 | moduleEntry.dwSize = (uint)Marshal.SizeOf(moduleEntry);
18 |
19 | var result = PS4API.ToolHelp.Module32Next(this.Handle, ref moduleEntry);
20 |
21 | return new Module32Response(result, moduleEntry);
22 | }
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/OpenProcessCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class OpenProcessCommand : CheatEngineCommand
11 | {
12 | public override CommandType CommandType => CommandType.CMD_OPENPROCESS;// throw new NotImplementedException();
13 | public int ProcessID;
14 | public OpenProcessCommand()
15 | {
16 |
17 | }
18 |
19 | public OpenProcessCommand(int pid)
20 | {
21 | this.ProcessID = pid;
22 | this.initialized = true;
23 | }
24 |
25 | public override void Initialize(BinaryReader reader)
26 | {
27 | this.ProcessID = reader.ReadInt32();
28 | this.initialized = true;
29 | }
30 |
31 | public override HandleResponse Process()
32 | {
33 | IntPtr handle = PS4API.ToolHelp.OpenProcess(
34 | PS4API.ToolHelp.ProcessAccessFlags.VirtualMemoryRead |
35 | PS4API.ToolHelp.ProcessAccessFlags.VirtualMemoryWrite |
36 | PS4API.ToolHelp.ProcessAccessFlags.QueryInformation,
37 | false, this.ProcessID);
38 |
39 | return new HandleResponse(handle);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/Process32FirstCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 | using CEServerPS4.CheatEnginePackets.S2C;
8 |
9 | namespace CEServerPS4.CheatEnginePackets.C2S
10 | {
11 | public class Process32FirstCommand : CheatEngineCommand
12 | {
13 | public override CommandType CommandType => CommandType.CMD_PROCESS32FIRST;
14 |
15 | public IntPtr Handle;
16 | public Process32FirstCommand()
17 | {
18 | }
19 |
20 | public Process32FirstCommand(IntPtr handle)
21 | {
22 | this.Handle = handle;
23 | this.initialized = true;
24 | }
25 |
26 | public sealed override void Initialize(BinaryReader reader)
27 | {
28 | this.Handle = (IntPtr)reader.ReadUInt32();
29 | this.initialized = true;
30 | }
31 |
32 | public override Process32Response Process()
33 | {
34 | PS4API.ToolHelp.PROCESSENTRY32 processEntry = new PS4API.ToolHelp.PROCESSENTRY32();
35 | processEntry.dwSize = (uint)Marshal.SizeOf(processEntry);
36 |
37 | var result = PS4API.ToolHelp.Process32First(this.Handle, ref processEntry);
38 |
39 | return new Process32Response(result, processEntry);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/Process32NextCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class Process32NextCommand : Process32FirstCommand
11 | {
12 | public override CommandType CommandType => CommandType.CMD_PROCESS32NEXT;
13 |
14 | public override Process32Response Process()
15 | {
16 | PS4API.ToolHelp.PROCESSENTRY32 processEntry = new PS4API.ToolHelp.PROCESSENTRY32();
17 | processEntry.dwSize = (uint)Marshal.SizeOf(processEntry);
18 |
19 | var result = PS4API.ToolHelp.Process32Next(this.Handle, ref processEntry);
20 |
21 | return new Process32Response(result, processEntry);
22 | }
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/ReadProcessMemoryCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class ReadProcessMemoryCommand : CheatEngineCommand
11 | {
12 | public IntPtr Handle;
13 | public ulong Address;
14 | public int Size;
15 | public bool Compress;
16 |
17 | public override CommandType CommandType => CommandType.CMD_READPROCESSMEMORY;
18 |
19 | public ReadProcessMemoryCommand() { }
20 |
21 | public ReadProcessMemoryCommand(IntPtr handle, UInt64 address, int size, bool compress)
22 | {
23 | this.Handle = handle;
24 | this.Address = address;
25 | this.Size = size;
26 | this.Compress = compress;
27 | this.initialized = true;
28 | }
29 |
30 | public override void Initialize(BinaryReader reader)
31 | {
32 | Handle = (IntPtr)reader.ReadInt32();
33 | Address = reader.ReadUInt64();
34 | Size = reader.ReadInt32();
35 | Compress = reader.ReadByte() == 0 ? false : true;
36 | this.initialized = true;
37 | }
38 |
39 | public override ReadProcessMemoryResponse Process()
40 | {
41 | var data = new byte[this.Size];
42 | IntPtr dataRead;
43 | PS4API.MemoryAPI.ReadProcessMemory(this.Handle, this.Address, out data, this.Size, out dataRead);
44 | if((int)dataRead < this.Size)
45 | {
46 | var data2 = new byte[(int)dataRead];
47 | Array.Copy(data, 0, data2, 0, data2.Length);
48 | data = data2;
49 | }
50 |
51 | return new ReadProcessMemoryResponse(data, this.Compress);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/RemoveBreakPointCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class RemoveBreakPointCommand : CheatEngineCommand
11 | {
12 | public IntPtr Handle;
13 | public int bid;
14 | public IntPtr debugregister;
15 | public ulong Address;
16 | public int wasbp;
17 |
18 | public override CommandType CommandType => CommandType.CMD_REMOVEBREAKPOINT;
19 |
20 | public RemoveBreakPointCommand() { }
21 |
22 | public RemoveBreakPointCommand(IntPtr handle, int bid, IntPtr debugregister, UInt64 address, int wasbp)
23 | {
24 | this.Handle = handle;
25 | this.bid = bid;
26 | this.debugregister = debugregister;
27 | this.Address = address;
28 | this.wasbp = wasbp;
29 | this.initialized = true;
30 | }
31 |
32 | public override void Initialize(BinaryReader reader)
33 | {
34 | Handle = (IntPtr)reader.ReadInt32();
35 | bid = reader.ReadInt32();
36 | debugregister = (IntPtr)reader.ReadInt32();
37 | if (CheatEngineConstants.isCustomCheatEngine)
38 | {
39 | Address = reader.ReadUInt64();
40 | }
41 |
42 | wasbp = reader.ReadInt32();
43 | this.initialized = true;
44 | }
45 |
46 | public override HandleResponse Process()
47 | {
48 |
49 | IntPtr o = PS4API.DebugAPI.RemoveBreakpoint(this.Handle, this.bid, this.debugregister,this.Address, this.wasbp);
50 |
51 |
52 | return new HandleResponse(o);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/ResumeThreadCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class ResumeThreadCommand : CheatEngineCommand
11 | {
12 | public override CommandType CommandType => CommandType.CMD_RESUMETHREAD;// throw new NotImplementedException();
13 | public IntPtr handle;
14 | public uint ThreadId;
15 | public ResumeThreadCommand()
16 | {
17 |
18 | }
19 |
20 | public ResumeThreadCommand(IntPtr handle,uint ThreadId)
21 | {
22 | this.handle = handle;
23 | this.ThreadId = ThreadId;
24 | this.initialized = true;
25 | }
26 |
27 | public override void Initialize(BinaryReader reader)
28 | {
29 | this.handle = (IntPtr)reader.ReadInt32();
30 | this.ThreadId = reader.ReadUInt32();
31 | this.initialized = true;
32 | }
33 |
34 | public override HandleResponse Process()
35 | {
36 | IntPtr hande = PS4API.DebugAPI.ResumeThread(handle, ThreadId);
37 |
38 | return new HandleResponse(hande);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/SetBreakPointCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class SetBreakPointCommand : CheatEngineCommand
11 | {
12 | public IntPtr Handle;
13 | public int bid;
14 | public IntPtr debugregister;
15 | public ulong Address;
16 | public int bptype;
17 | public int bpsize;
18 |
19 | public override CommandType CommandType => CommandType.CMD_SETBREAKPOINT;
20 |
21 | public SetBreakPointCommand() { }
22 |
23 | public SetBreakPointCommand(IntPtr handle, int bid, IntPtr debugregister, UInt64 address, int bptype, int bpsize)
24 | {
25 | this.Handle = handle;
26 | this.bid = bid;
27 | this.debugregister = debugregister;
28 | this.Address = address;
29 | this.bptype = bptype;
30 | this.bpsize = bpsize;
31 | this.initialized = true;
32 | }
33 |
34 | public override void Initialize(BinaryReader reader)
35 | {
36 | Handle = (IntPtr)reader.ReadInt32();
37 | bid = reader.ReadInt32();
38 | debugregister = (IntPtr)reader.ReadInt32();
39 | Address = reader.ReadUInt64();
40 | bptype = reader.ReadInt32();
41 | bpsize = reader.ReadInt32();
42 | this.initialized = true;
43 | }
44 |
45 | public override HandleResponse Process()
46 | {
47 |
48 | IntPtr o = PS4API.DebugAPI.SetBreakpoint(this.Handle, this.bid, this.debugregister, this.Address, this.bptype,this.bpsize);
49 |
50 | return new HandleResponse(o);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/StartDebugCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class StartDebugCommand : CheatEngineCommand
11 | {
12 | public override CommandType CommandType => CommandType.CMD_STARTDEBUG;// throw new NotImplementedException();
13 | public IntPtr handle;
14 | public StartDebugCommand()
15 | {
16 |
17 | }
18 |
19 | public StartDebugCommand(IntPtr handle)
20 | {
21 | this.handle = handle;
22 | this.initialized = true;
23 | }
24 |
25 | public override void Initialize(BinaryReader reader)
26 | {
27 | this.handle = (IntPtr)reader.ReadInt32();
28 | this.initialized = true;
29 | }
30 |
31 | public override HandleResponse Process()
32 | {
33 | IntPtr hande = PS4API.DebugAPI.StartDebug(handle);
34 |
35 | return new HandleResponse(hande);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/StopDebugCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class StopDebugCommand : CheatEngineCommand
11 | {
12 | public override CommandType CommandType => CommandType.CMD_STOPDEBUG;// throw new NotImplementedException();
13 | public IntPtr handle;
14 | public StopDebugCommand()
15 | {
16 |
17 | }
18 |
19 | public StopDebugCommand(IntPtr handle)
20 | {
21 | this.handle = handle;
22 | this.initialized = true;
23 | }
24 |
25 | public override void Initialize(BinaryReader reader)
26 | {
27 | this.handle = (IntPtr)reader.ReadInt32();
28 | this.initialized = true;
29 | }
30 |
31 | public override HandleResponse Process()
32 | {
33 | IntPtr hande = PS4API.DebugAPI.StopDebug(handle);
34 |
35 | return new HandleResponse(hande);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/SuspendThreadCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class SuspendThreadCommand : CheatEngineCommand
11 | {
12 | public override CommandType CommandType => CommandType.CMD_SUSPENDTHREAD;// throw new NotImplementedException();
13 | public IntPtr handle;
14 | public uint ThreadId;
15 | public SuspendThreadCommand()
16 | {
17 |
18 | }
19 |
20 | public SuspendThreadCommand(IntPtr handle,uint ThreadId)
21 | {
22 | this.handle = handle;
23 | this.ThreadId = ThreadId;
24 | this.initialized = true;
25 | }
26 |
27 | public override void Initialize(BinaryReader reader)
28 | {
29 | this.handle = (IntPtr)reader.ReadInt32();
30 | this.ThreadId = reader.ReadUInt32();
31 | this.initialized = true;
32 | }
33 |
34 | public override HandleResponse Process()
35 | {
36 | IntPtr hande = PS4API.DebugAPI.SuspendThread(handle, ThreadId);
37 |
38 | return new HandleResponse(hande);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/VirtualQueryExCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Runtime.InteropServices;
7 | using System.Text;
8 |
9 | namespace CEServerPS4.CheatEnginePackets.C2S
10 | {
11 | public class VirtualQueryExCommand : CheatEngineCommand
12 | {
13 |
14 | public IntPtr Handle;
15 | public UInt64 Address;
16 |
17 | public override CommandType CommandType => CommandType.CMD_VIRTUALQUERYEX;// throw new NotImplementedException();
18 |
19 | public VirtualQueryExCommand() { }
20 |
21 | public VirtualQueryExCommand(IntPtr handle, UInt64 address)
22 | {
23 | this.Handle = handle;
24 | this.Address = address;
25 | this.initialized = true;
26 | }
27 |
28 | public override void Initialize(BinaryReader reader)
29 | {
30 | this.Handle = (IntPtr)reader.ReadInt32();
31 | this.Address = reader.ReadUInt64();
32 | this.initialized = true;
33 | }
34 |
35 | public override VirtualQueryExResponse Process()
36 | {
37 | PS4API.MemoryAPI.MEMORY_BASIC_INFORMATION mbi = new PS4API.MemoryAPI.MEMORY_BASIC_INFORMATION();
38 | int ret = PS4API.MemoryAPI.VirtualQueryEx(Handle, Address, out mbi, (uint)Marshal.SizeOf(mbi));
39 |
40 | return new VirtualQueryExResponse(ret, mbi);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/VirtualQueryExFullCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Runtime.InteropServices;
7 | using System.Text;
8 |
9 | namespace CEServerPS4.CheatEnginePackets.C2S
10 | {
11 | public class VirtualQueryExFullCommand : CheatEngineCommand
12 | {
13 |
14 | public IntPtr Handle;
15 |
16 | public override CommandType CommandType => CommandType.CMD_VIRTUALQUERYEXFULL;// throw new NotImplementedException();
17 |
18 | public VirtualQueryExFullCommand() { }
19 |
20 | public VirtualQueryExFullCommand(IntPtr handle)
21 | {
22 | this.Handle = handle;
23 | this.initialized = true;
24 | }
25 |
26 | public override void Initialize(BinaryReader reader)
27 | {
28 | this.Handle = (IntPtr)reader.ReadInt32();
29 | reader.ReadByte();//Cheat engine/linux specific flags?
30 | this.initialized = true;
31 | }
32 |
33 | public override VirtualQueryExFullResponse Process()
34 | {
35 | var regions = new List();
36 | ulong currentAddress = 0;
37 | int ret = 0;
38 | while(true)
39 | {
40 | PS4API.MemoryAPI.MEMORY_BASIC_INFORMATION mbi = new PS4API.MemoryAPI.MEMORY_BASIC_INFORMATION();
41 | try
42 | {
43 | ret = PS4API.MemoryAPI.VirtualQueryEx(Handle, currentAddress, out mbi, (uint)Marshal.SizeOf(mbi));
44 | if (ret == 0)
45 | break;
46 | }catch(Exception e)
47 | {
48 | Console.WriteLine(currentAddress);
49 | }
50 |
51 | currentAddress = (ulong)mbi.BaseAddress+(ulong)mbi.RegionSize;
52 | regions.Add(mbi);
53 | }
54 |
55 | return new VirtualQueryExFullResponse(regions);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/WaitForDebugEventCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class WaitForDebugEventCommand : CheatEngineCommand
11 | {
12 | public override CommandType CommandType => CommandType.CMD_WAITFORDEBUGEVENT;// throw new NotImplementedException();
13 | public IntPtr handle;
14 | public int timeout;
15 | public WaitForDebugEventCommand()
16 | {
17 |
18 | }
19 |
20 | public WaitForDebugEventCommand(IntPtr handle,int timeout)
21 | {
22 | this.handle = handle;
23 | this.timeout = timeout;
24 | this.initialized = true;
25 | }
26 |
27 | public override void Initialize(BinaryReader reader)
28 | {
29 | this.handle = (IntPtr)reader.ReadInt32();
30 | this.timeout = reader.ReadInt32();
31 | this.initialized = true;
32 | }
33 |
34 | public override WaitForDebugEventResponse Process()
35 | {
36 | IntPtr hande = PS4API.DebugAPI.WaitForDebugEvent(handle, timeout,out object evt);
37 | return new WaitForDebugEventResponse(hande,evt);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/C2S/WriteProcessMemoryCommand.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.S2C;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.C2S
9 | {
10 | public class WriteProcessMemoryCommand : CheatEngineCommand
11 | {
12 | public IntPtr Handle;
13 | public ulong Address;
14 | public int Size;
15 | public byte[] data;
16 |
17 | public override CommandType CommandType => CommandType.CMD_WRITEPROCESSMEMORY;
18 |
19 | public WriteProcessMemoryCommand() { }
20 |
21 | public WriteProcessMemoryCommand(IntPtr handle, UInt64 address, int size, byte[] data)
22 | {
23 | this.Handle = handle;
24 | this.Address = address;
25 | this.Size = size;
26 | this.data = data;
27 | this.initialized = true;
28 | }
29 |
30 | public override void Initialize(BinaryReader reader)
31 | {
32 | Handle = (IntPtr)reader.ReadInt32();
33 | Address = reader.ReadUInt64();
34 | Size = reader.ReadInt32();
35 | data = reader.ReadBytes(Size);
36 | this.initialized = true;
37 | }
38 |
39 | public override WriteProcessMemoryResponse Process()
40 | {
41 |
42 | IntPtr dataWriten;
43 | PS4API.MemoryAPI.WriteMemory(this.Handle, this.Address, data, this.Size, out dataWriten);
44 |
45 | return new WriteProcessMemoryResponse(this.Size);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/MissingCommandHandlerException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace CEServerPS4.CheatEnginePackets
7 | {
8 | class MissingCommandHandlerException : Exception
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/PacketManager.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets.C2S;
2 | using CEServerPS4.CheatEnginePackets.S2C;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Diagnostics;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Text;
9 |
10 | namespace CEServerPS4.CheatEnginePackets
11 | {
12 | /**
13 | * This classes parses incoming commands
14 | * It's possible to register commands to parse with the RegisterCommand method
15 | *
16 | * The instance passed is utilized to write the data to, no copying is made!
17 | * This is because Cheat Engine always waits for a response to the requested command so parellism/async is handling is not necessary.
18 | * To solve this you could get the type of the passed command and instanciate a new one through reflection but some performance would be lost with this.
19 | * Because of this one server can only server one client at a time, maybe on a future release add this support?
20 | */
21 | public class PacketManager
22 | {
23 |
24 | private Dictionary commandHandler = new Dictionary();
25 |
26 |
27 | public void RegisterCommand(ICheatEngineCommand command)
28 | {
29 | if (commandHandler.ContainsKey(command.CommandType))
30 | commandHandler.Remove(command.CommandType);
31 | commandHandler.Add(command.CommandType, command);
32 | }
33 |
34 | public ICheatEngineCommand ReadNextCommand(BinaryReader reader)
35 | {
36 | CommandType type = (CommandType)reader.ReadByte();
37 |
38 | ICheatEngineCommand command;
39 | if(!commandHandler.TryGetValue(type, out command))
40 | {
41 | //Unoptimal solution if multiple commands can be sent at once
42 | //But if that were the case knowledge of all commands would be necessary
43 | //As the protocol doesn't provide a way to know the 'size' of the incoming message
44 | //this.consumeAll(reader);
45 | Trace.WriteLine(type);
46 | throw new MissingCommandHandlerException();
47 | }
48 | command = (ICheatEngineCommand)Activator.CreateInstance(command.GetType());
49 | command.Initialize(reader);
50 |
51 | return command;
52 |
53 | }
54 |
55 | public byte[] ProcessAndGetBytes(ICheatEngineCommand command)
56 | {
57 | if(!command.initialized)
58 | {
59 | throw new C2S.Exceptions.CommandNotInitializedException();
60 | }
61 | var ret = command.ProcessAndGetBytes();
62 | command.Unintialize();
63 | return ret;
64 | }
65 |
66 | private byte[] consumeAll(BinaryReader reader)
67 | {
68 | byte[] all;
69 |
70 | byte[] data = new byte[1024];
71 | using (MemoryStream ms = new MemoryStream())
72 | {
73 |
74 | int numBytesRead;
75 | while ((numBytesRead = reader.Read(data, 0, data.Length)) > 0)
76 | {
77 | ms.Write(data, 0, numBytesRead);
78 | if (numBytesRead < data.Length)
79 | break;
80 |
81 | }
82 | all = ms.ToArray();
83 | }
84 | return all;
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/CloseHandleResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace CEServerPS4.CheatEnginePackets.S2C
8 | {
9 | public class CloseHandleResponse : ICheatEngineResponse
10 | {
11 |
12 | public bool Result;
13 | public CloseHandleResponse(bool result)
14 | {
15 | this.Result = result;
16 | }
17 |
18 | public byte[] Serialize()
19 | {
20 | MemoryStream ms = new MemoryStream();
21 | BinaryWriter br = new BinaryWriter(ms);
22 | br.Write(Result ? 1 : 0);
23 |
24 | br.Close();
25 | return ms.ToArray();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/ContinueForDebugEventResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Runtime.Serialization.Formatters.Binary;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.S2C
9 | {
10 | public class ContinueForDebugEventResponse : ICheatEngineResponse
11 | {
12 | private IntPtr handle;
13 |
14 |
15 | public ContinueForDebugEventResponse(IntPtr handle)
16 | {
17 | this.handle = handle;
18 | }
19 |
20 | public byte[] Serialize()
21 | {
22 | MemoryStream ms = new MemoryStream();
23 | BinaryWriter br = new BinaryWriter(ms);
24 |
25 | br.Write((int)handle);
26 | br.Close();
27 | return ms.ToArray();
28 | }
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/GetABIResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace CEServerPS4.CheatEnginePackets.S2C
7 | {
8 | public class GetABIResponse : ICheatEngineResponse
9 | {
10 |
11 | public GetABIResponse( )
12 | {
13 |
14 | }
15 |
16 | public byte[] Serialize()
17 | {
18 | return new byte[] { (byte)1 };
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/GetArchitectureResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace CEServerPS4.CheatEnginePackets.S2C
7 | {
8 | public class GetArchitectureResponse : ICheatEngineResponse
9 | {
10 | public Architecture Architecture;
11 |
12 | public GetArchitectureResponse(Architecture arch)
13 | {
14 | this.Architecture = arch;
15 | }
16 |
17 | public byte[] Serialize()
18 | {
19 | return new byte[] { (byte)Architecture };
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/GetSymbolsFromFileResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.S2C
9 | {
10 | public class GetSymbolsFromFileResponse : ICheatEngineResponse
11 | {
12 | public byte[] Data;
13 |
14 | public GetSymbolsFromFileResponse(byte[] data)
15 | {
16 | this.Data = data;
17 | }
18 | public byte[] Serialize()
19 | {
20 | MemoryStream ms = new MemoryStream();
21 | BinaryWriter br = new BinaryWriter(ms);
22 | br.Write(0L);
23 |
24 | br.Close();
25 | return ms.ToArray();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/GetVersionResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace CEServerPS4.CheatEnginePackets.S2C
8 | {
9 | public class GetVersionResponse : ICheatEngineResponse
10 | {
11 | public const string VERSION = "CHEATENGINE Network 2.1";
12 | public const string VER = "CH";
13 | public string version;
14 |
15 | public GetVersionResponse()
16 | {
17 | this.version = VERSION;
18 | }
19 |
20 | public GetVersionResponse(string version)
21 | {
22 | this.version = version;
23 | }
24 |
25 | public byte[] Serialize()
26 | {
27 | MemoryStream ms = new MemoryStream();
28 | BinaryWriter br = new BinaryWriter(ms);
29 | br.Write(version.Length);
30 | br.Write((byte)2);
31 | br.Write(Encoding.UTF8.GetBytes(VER));
32 | br.Close();
33 | return ms.ToArray();
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/HandleResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace CEServerPS4.CheatEnginePackets.S2C
8 | {
9 | public class HandleResponse : ICheatEngineResponse
10 | {
11 | public IntPtr Handle;
12 |
13 | public HandleResponse(IntPtr handle)
14 | {
15 | this.Handle = handle;
16 | }
17 |
18 | public byte[] Serialize()
19 | {
20 | MemoryStream ms = new MemoryStream();
21 | BinaryWriter br = new BinaryWriter(ms);
22 |
23 | br.Write((int)this.Handle);
24 | br.Close();
25 | return ms.ToArray();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/ICheatEngineResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace CEServerPS4.CheatEnginePackets.S2C
7 | {
8 | public interface ICheatEngineResponse
9 | {
10 | byte[] Serialize();
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/Module32Response.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace CEServerPS4.CheatEnginePackets.S2C
8 | {
9 | public class Module32Response : ICheatEngineResponse
10 | {
11 | public bool Result;
12 | public PS4API.ToolHelp.MODULEENTRY32 ModuleEntry;
13 |
14 | public Module32Response(bool result, PS4API.ToolHelp.MODULEENTRY32 moduleEntry)
15 | {
16 | this.Result = result;
17 | this.ModuleEntry = moduleEntry;
18 | }
19 |
20 | public byte[] Serialize()
21 | {
22 | MemoryStream ms = new MemoryStream();
23 | BinaryWriter br = new BinaryWriter(ms);
24 |
25 | br.Write((int)(this.Result ? 1 : 0));
26 | if (this.Result)
27 | {
28 | br.Write((long)ModuleEntry.modBaseAddr);
29 | br.Write(ModuleEntry.GlblcntUsage);
30 | br.Write(ModuleEntry.modBaseSize);
31 | br.Write(ModuleEntry.szModule.Length);
32 | br.Write(Encoding.UTF8.GetBytes(ModuleEntry.szModule));
33 | }
34 | else
35 | {
36 | br.Write(0L);//Base Address
37 | br.Write(0);//part
38 | br.Write(0);//Mod Size
39 | br.Write(0);//str Size
40 | }
41 |
42 | br.Close();
43 | return ms.ToArray();
44 | }
45 | }
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/Process32Response.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace CEServerPS4.CheatEnginePackets.S2C
8 | {
9 | public class Process32Response : ICheatEngineResponse
10 | {
11 | public bool Result;
12 | public PS4API.ToolHelp.PROCESSENTRY32 ProcessEntry;
13 |
14 | public Process32Response(bool result, PS4API.ToolHelp.PROCESSENTRY32 processEntry)
15 | {
16 | this.Result = result;
17 | this.ProcessEntry = processEntry;
18 | }
19 |
20 | public byte[] Serialize()
21 | {
22 | MemoryStream ms = new MemoryStream();
23 | BinaryWriter br = new BinaryWriter(ms);
24 |
25 | br.Write((int)(this.Result ? 1 : 0));
26 | if (this.Result)
27 | {
28 | br.Write((int)ProcessEntry.th32ProcessID);
29 | br.Write((int)ProcessEntry.szExeFile.Length);
30 | br.Write(Encoding.UTF8.GetBytes(ProcessEntry.szExeFile));
31 | }
32 | else
33 | {
34 | br.Write((int)0);
35 | br.Write((int)0);
36 | }
37 |
38 | br.Close();
39 | return ms.ToArray();
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/ReadProcessMemoryResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace CEServerPS4.CheatEnginePackets.S2C
8 | {
9 | public class ReadProcessMemoryResponse : ICheatEngineResponse
10 | {
11 | public byte[] Data;
12 | public bool Compression;
13 | public ReadProcessMemoryResponse(byte[] data, bool compression)
14 | {
15 | this.Data = data;
16 | this.Compression = compression;
17 | }
18 |
19 | public byte[] Serialize()
20 | {
21 | if(this.Compression)
22 | throw new NotImplementedException("Compression is not implemented");
23 |
24 | MemoryStream ms = new MemoryStream();
25 | BinaryWriter br = new BinaryWriter(ms);
26 | br.Write(Data.Length);
27 | br.Write(Data);
28 | br.Close();
29 | return ms.ToArray();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/ThreadContextResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Runtime.Serialization.Formatters.Binary;
7 | using System.Runtime.InteropServices;
8 | using System.Diagnostics;
9 |
10 | namespace CEServerPS4.CheatEnginePackets.S2C
11 | {
12 | public class ThreadContextResponse : ICheatEngineResponse
13 | {
14 | public PS4API.DebugAPI.CONTEXT_REGS rgs;
15 | public IntPtr handle;
16 |
17 | public ThreadContextResponse(PS4API.DebugAPI.CONTEXT_REGS regs, IntPtr handle)
18 | {
19 | this.rgs = regs;
20 | this.handle = handle;
21 | }
22 |
23 | public byte[] Serialize()
24 | {
25 | MemoryStream ms = new MemoryStream();
26 | BinaryWriter br = new BinaryWriter(ms);
27 | if ((int)handle == 0)
28 | {
29 | br.Write(0);
30 | br.Close();
31 | return ms.ToArray();
32 | }
33 |
34 | br.Write(1);
35 | br.Write(Marshal.SizeOf(typeof(PS4API.DebugAPI.CONTEXT_REGS)));
36 | writeregs(br);
37 | br.Close();
38 | return ms.ToArray();
39 | }
40 |
41 | public void writeregs(BinaryWriter br)
42 | {
43 | br.Write(rgs.r15);
44 |
45 | br.Write(rgs.r14);
46 |
47 | br.Write(rgs.r13);
48 |
49 | br.Write(rgs.r12);
50 |
51 | br.Write(rgs.rbp);
52 |
53 | br.Write(rgs.rbx);
54 |
55 | br.Write(rgs.r11);
56 |
57 | br.Write(rgs.r10);
58 |
59 | br.Write(rgs.r9);
60 |
61 | br.Write(rgs.r8);
62 |
63 | br.Write(rgs.rax);
64 |
65 | br.Write(rgs.rcx);
66 |
67 | br.Write(rgs.rdx);
68 |
69 | br.Write(rgs.rsi);
70 |
71 | br.Write(rgs.rdi);
72 |
73 | br.Write(rgs.orig_rax);
74 |
75 | br.Write(rgs.rip);
76 |
77 | Trace.WriteLine("adress:"+rgs.rip);
78 |
79 | br.Write(rgs.cs);
80 |
81 | br.Write(rgs.eflags);
82 |
83 | br.Write(rgs.rsp);
84 |
85 | br.Write(rgs.ss);
86 |
87 | br.Write(rgs.fs_base);
88 |
89 | br.Write(rgs.gs_base);
90 |
91 | br.Write(rgs.ds);
92 |
93 | br.Write(rgs.es);
94 |
95 | br.Write(rgs.fs);
96 |
97 | br.Write(rgs.gs);
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/VirtualQueryExFullResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace CEServerPS4.CheatEnginePackets.S2C
8 | {
9 | public class VirtualQueryExFullResponse : ICheatEngineResponse
10 | {
11 |
12 | public IList Regions;
13 | public VirtualQueryExFullResponse(IList regions)
14 | {
15 | this.Regions = regions;
16 | }
17 |
18 | public byte[] Serialize()
19 | {
20 |
21 | MemoryStream ms = new MemoryStream();
22 | BinaryWriter br = new BinaryWriter(ms);
23 | br.Write(Regions.Count);
24 | //The number of bytes return by VirtualQueryEx is the number of bytes written to mbi, if it's 0 it failed
25 | //But in Cheat engise server 1 is success and 0 is failed
26 | foreach (var region in Regions)
27 | {//Yes this is reversed from VirtualQueryEx....
28 | br.Write(region.BaseAddress);
29 | br.Write(region.RegionSize);
30 | br.Write((int)region.AllocationProtect); // Or Protect
31 | br.Write((int)region.Type);
32 | }
33 |
34 | br.Close();
35 | return ms.ToArray();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/VirtualQueryExResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace CEServerPS4.CheatEnginePackets.S2C
8 | {
9 | public class VirtualQueryExResponse : ICheatEngineResponse
10 | {
11 | public int Result;
12 | public PS4API.MemoryAPI.MEMORY_BASIC_INFORMATION MemoryBasicInformation;
13 |
14 | public VirtualQueryExResponse(int result, PS4API.MemoryAPI.MEMORY_BASIC_INFORMATION mbi)
15 | {
16 | this.Result = result;
17 | this.MemoryBasicInformation = mbi;
18 | }
19 |
20 | public byte[] Serialize()
21 | {
22 |
23 | MemoryStream ms = new MemoryStream();
24 | BinaryWriter br = new BinaryWriter(ms);
25 | //The number of bytes return by VirtualQueryEx is the number of bytes written to mbi, if it's 0 it failed
26 | //But in Cheat engise server 1 is success and 0 is failed
27 | if (Result > 0)
28 | br.Write((byte)1);
29 | else
30 | br.Write((byte)0);
31 | //Yes this is reversed from VirtualQueryExFull....
32 | br.Write((int)MemoryBasicInformation.AllocationProtect);
33 | br.Write((int)MemoryBasicInformation.Type);
34 | br.Write((Int64)MemoryBasicInformation.BaseAddress);
35 | br.Write((Int64)MemoryBasicInformation.RegionSize);
36 |
37 | br.Close();
38 | return ms.ToArray();
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/WaitForDebugEventResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Runtime.Serialization.Formatters.Binary;
7 |
8 | namespace CEServerPS4.CheatEnginePackets.S2C
9 | {
10 | public class WaitForDebugEventResponse : ICheatEngineResponse
11 | {
12 | private IntPtr handle;
13 | private object et;
14 |
15 |
16 | public WaitForDebugEventResponse(IntPtr handle,object et)
17 | {
18 | this.et = et;
19 | this.handle = handle;
20 | }
21 |
22 | public byte[] Serialize()
23 | {
24 | MemoryStream ms = new MemoryStream();
25 | BinaryWriter br = new BinaryWriter(ms);
26 | br.Write((int)handle);
27 | if ((int)handle > 0)
28 | {
29 | set(ref br);
30 | }
31 | br.Close();
32 | return ms.ToArray();
33 | }
34 |
35 | private void set(ref BinaryWriter br)
36 | {
37 |
38 | if(et is PS4API.DebugAPI.CreateDebugEvent)
39 | {
40 | PS4API.DebugAPI.CreateDebugEvent bf = (PS4API.DebugAPI.CreateDebugEvent)et;
41 | br.Write(bf.debugevent);
42 | br.Write(bf.threadid);
43 | br.Write((ulong)0);
44 | }
45 | else if(et is PS4API.DebugAPI.ProcessEvent)
46 | {
47 | PS4API.DebugAPI.ProcessEvent pe = (PS4API.DebugAPI.ProcessEvent)et;
48 | br.Write(pe.debugevent);
49 | br.Write(pe.threadid);
50 | br.Write(pe.maxBreakpointCount);
51 | br.Write(pe.maxWatchpointCount);
52 | br.Write(pe.maxSharedBreakpoints);
53 | br.Write((int)0);
54 | br.Write((sbyte)0);
55 | }
56 | else
57 | {
58 | PS4API.DebugAPI.DebugEvent de = (PS4API.DebugAPI.DebugEvent)et;
59 | br.Write(de.debugevent);
60 | br.Write(de.threadid);
61 | br.Write(de.address);
62 | }
63 |
64 |
65 | }
66 |
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEnginePackets/S2C/WriteProcessMemoryResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace CEServerPS4.CheatEnginePackets.S2C
8 | {
9 | public class WriteProcessMemoryResponse : ICheatEngineResponse
10 | {
11 | public Int32 Data;
12 | public WriteProcessMemoryResponse(Int32 data)
13 | {
14 | this.Data = data;
15 | }
16 |
17 | public byte[] Serialize()
18 | {
19 | MemoryStream ms = new MemoryStream();
20 | BinaryWriter br = new BinaryWriter(ms);
21 | br.Write(Data);
22 | br.Close();
23 | return ms.ToArray();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/CEServerPS4/CheatEngineServer.cs:
--------------------------------------------------------------------------------
1 | using CEServerPS4.CheatEnginePackets;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Net;
6 | using System.Net.Sockets;
7 | using System.Text;
8 | using CEServerPS4.CheatEnginePackets.C2S;
9 | using System.IO;
10 | using System.Threading.Tasks;
11 | using System.Threading;
12 | using System.Diagnostics;
13 |
14 | namespace CEServerPS4
15 | {
16 | public class CheatEngineServer : IDisposable
17 | {
18 | private TcpListener _tcpListener;
19 | private PacketManager packetManager;
20 | private CancellationTokenSource _tokenSource;
21 |
22 | private bool isDisposed
23 | {
24 | get;set;
25 | }
26 | public static bool islistening
27 | {
28 | get; set;
29 | }
30 |
31 | public static ConnectType isConnected
32 | {
33 | get; set;
34 | }
35 | private CancellationToken _token;
36 |
37 |
38 | public CheatEngineServer(string ip,ushort port = 52736) : this(port, new PacketManager())
39 | {
40 | PS4API.PS4Static.IP = ip;
41 | PS4API.PS4APIWrapper.Connect();
42 | this.RegisterDefaultHandlers();
43 | isConnected = ConnectType.INIT;
44 | }
45 |
46 | public CheatEngineServer(PacketManager pm) : this(52736, pm)
47 | {
48 |
49 | }
50 |
51 | public CheatEngineServer(ushort port, PacketManager pm)
52 | {
53 | _tcpListener = new TcpListener(IPAddress.Any, port);
54 | this.packetManager = pm;
55 | }
56 |
57 | private void HandleReceivedClient(TcpClient client)
58 | {
59 |
60 | var clientStream = client.GetStream();
61 | var reader = new BinaryReader(clientStream);
62 | var writer = new BinaryWriter(clientStream);
63 | while (true)
64 | {
65 | try
66 | {
67 |
68 | var command = this.packetManager.ReadNextCommand(reader);
69 | var output = this.packetManager.ProcessAndGetBytes(command);
70 |
71 | writer.Write(output);
72 | writer.Flush();
73 |
74 | }
75 | catch(EndOfStreamException)
76 | {
77 | client.Close();
78 | break;
79 | }
80 | catch (Exception e)
81 | {
82 | Trace.WriteLine(e + ": "+ e.Message);
83 | Trace.WriteLine(e.StackTrace);
84 | client.Close();
85 | Dispose();
86 | break;
87 | }
88 |
89 | }
90 | }
91 |
92 | public async Task StartAsync(CancellationToken? token = null)
93 | {
94 | _tokenSource = CancellationTokenSource.CreateLinkedTokenSource(token ?? new CancellationToken());
95 | _token = _tokenSource.Token;
96 | try
97 | {
98 | _tcpListener.Start();
99 | isConnected = ConnectType.SUCCESS;
100 | islistening = true;
101 | isDisposed = false;
102 | while (!_token.IsCancellationRequested)
103 | {
104 | if (islistening)
105 | {
106 | var tcpClientTask = _tcpListener.AcceptTcpClientAsync();
107 | var result = await tcpClientTask;
108 | _ = Task.Run(() =>
109 | {
110 | HandleReceivedClient(result);
111 | }, _token);
112 | }
113 |
114 | }
115 | }
116 | finally
117 | {
118 | if (islistening)
119 | {
120 | _tcpListener.Stop();
121 | islistening = false;
122 | }
123 | if (!ConnectType.SUCCESS.Equals(isConnected))
124 | {
125 | isConnected = ConnectType.FAILED;
126 | }
127 | Dispose();
128 | }
129 | }
130 |
131 | public void Stop()
132 | {
133 | _tokenSource?.Cancel();
134 | }
135 |
136 | public void Dispose()
137 | {
138 | if (!isDisposed)
139 | {
140 | isDisposed = true;
141 | Stop();
142 | if (islistening)
143 | {
144 | _tcpListener.Stop();
145 | islistening = false;
146 | }
147 | PS4API.PS4DedugAPIWrapper.dettachDebugger();
148 | PS4API.PS4APIWrapper.Disconnect();
149 | }
150 |
151 | }
152 |
153 | private void RegisterDefaultHandlers()
154 | {
155 | this.RegisterCommandHandler(new CreateToolHelp32SnapshotCommand());
156 | this.RegisterCommandHandler(new GetVersionCommand());
157 | this.RegisterCommandHandler(new Module32FirstCommand());
158 | this.RegisterCommandHandler(new Module32NextCommand());
159 | this.RegisterCommandHandler(new Process32FirstCommand());
160 | this.RegisterCommandHandler(new Process32NextCommand());
161 | this.RegisterCommandHandler(new CloseHandleCommand());
162 | this.RegisterCommandHandler(new OpenProcessCommand());
163 | this.RegisterCommandHandler(new GetArchitectureCommand());
164 | this.RegisterCommandHandler(new VirtualQueryExCommand());
165 | this.RegisterCommandHandler(new VirtualQueryExFullCommand());
166 | this.RegisterCommandHandler(new ReadProcessMemoryCommand());
167 | this.RegisterCommandHandler(new GetSymbolsFromFileCommand());
168 | this.RegisterCommandHandler(new StartDebugCommand());
169 | this.RegisterCommandHandler(new ResumeThreadCommand());
170 | this.RegisterCommandHandler(new SuspendThreadCommand());
171 | this.RegisterCommandHandler(new SetBreakPointCommand());
172 | this.RegisterCommandHandler(new RemoveBreakPointCommand());
173 | this.RegisterCommandHandler(new GetThreadContextCommand());
174 | this.RegisterCommandHandler(new WaitForDebugEventCommand());
175 | this.RegisterCommandHandler(new ContinueForDebugEventCommand());
176 | this.RegisterCommandHandler(new WriteProcessMemoryCommand());
177 | this.RegisterCommandHandler(new GetABICommand());
178 | }
179 |
180 | public void RegisterCommandHandler(ICheatEngineCommand command)
181 | {
182 | this.packetManager.RegisterCommand(command);
183 | }
184 |
185 | }
186 | }
187 |
--------------------------------------------------------------------------------
/CEServerPS4/EventHandler/DebugEventHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.Concurrent;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 | using System.Threading;
8 | using libdebug;
9 | using System.Threading.Tasks.Dataflow;
10 | using System.Threading.Tasks;
11 | using CEServerPS4.EventHandler.Event;
12 | using CEServerPS4.CheatEnginePackets;
13 | using System.Diagnostics;
14 |
15 | namespace CEServerPS4.EventHandler
16 | {
17 | public static class DebugEventHandler
18 | {
19 |
20 | private static BlockingCollection