Skip to content

Commit 4c43dcf

Browse files
committed
Add more funcs in memory module
1 parent 6240b42 commit 4c43dcf

File tree

3 files changed

+73
-4
lines changed

3 files changed

+73
-4
lines changed

PyLoader/pch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
#include <frameobject.h>
88
#include "plugin.h"
99

10-
constexpr const char* plugin_ver = "0.01";
10+
constexpr const char* plugin_ver = "0.02";
1111
extern size_t game_ticks;
1212
extern std::ofstream flog;

PyLoader/sdk/PyMemory.cpp

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,64 @@ PyObject* PyMemory::WriteFloat(PyObject* self, PyObject* args)
8585
plugin::patch::Set<float>(addr, val, vp);
8686

8787
return PyBool_FromLong(1);
88-
}
88+
}
89+
90+
PyObject* PyMemory::Nop(PyObject* self, PyObject* args)
91+
{
92+
int addr = NULL;
93+
int size = NULL;
94+
int vp = NULL;
95+
96+
if (!PyArg_ParseTuple(args, "iii", &addr, &size, &vp))
97+
return PyBool_FromLong(0);
98+
99+
plugin::patch::Nop(addr, size, vp);
100+
101+
return PyBool_FromLong(1);
102+
}
103+
104+
PyObject* PyMemory::PutRetn(PyObject* self, PyObject* args)
105+
{
106+
int addr = NULL;
107+
int size = NULL;
108+
int pop_bytes = NULL;
109+
int vp = NULL;
110+
111+
if (!PyArg_ParseTuple(args, "iiii", &addr, &size, &pop_bytes, &vp))
112+
return PyBool_FromLong(0);
113+
114+
plugin::patch::PutRetn(addr, pop_bytes, vp);
115+
116+
return PyBool_FromLong(1);
117+
}
118+
119+
PyObject* PyMemory::GetRaw(PyObject* self, PyObject* args)
120+
{
121+
int addr = NULL;
122+
int size = NULL;
123+
int vp = NULL;
124+
char* data = nullptr;
125+
126+
if (!PyArg_ParseTuple(args, "iiii", &addr, &size, &vp))
127+
return PyBool_FromLong(0);
128+
129+
plugin::patch::GetRaw(addr, data, size, vp);
130+
131+
return Py_BuildValue("s", data);
132+
}
133+
134+
PyObject* PyMemory::SetRaw(PyObject* self, PyObject* args)
135+
{
136+
int addr = NULL;
137+
int size = NULL;
138+
char* data = NULL;
139+
int vp = NULL;
140+
141+
if (!PyArg_ParseTuple(args, "isii", &addr, &data , &size, &vp))
142+
return PyBool_FromLong(0);
143+
144+
plugin::patch::SetRaw(addr, data, size, vp);
145+
146+
return PyBool_FromLong(1);
147+
}
148+

PyLoader/sdk/PyMemory.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,24 @@
44
class PyMemory
55
{
66
private:
7+
static PyObject* GetRaw(PyObject* self, PyObject* args);
8+
static PyObject* Nop(PyObject* self, PyObject* args);
9+
static PyObject* PutRetn(PyObject* self, PyObject* args);
710
static PyObject* ReadFloat(PyObject* self, PyObject* args);
8-
static PyObject* WriteFloat(PyObject* self, PyObject* args);
911
static PyObject* ReadMemory(PyObject *self, PyObject *args);
12+
static PyObject* SetRaw(PyObject* self, PyObject* args);
13+
static PyObject* WriteFloat(PyObject* self, PyObject* args);
1014
static PyObject* WriteMemory(PyObject *self, PyObject *args);
15+
1116
static inline PyMethodDef Methods[] =
1217
{
18+
{"get_raw", GetRaw, METH_VARARGS},
19+
{"nop", Nop, METH_VARARGS},
20+
{"put_retn", PutRetn, METH_VARARGS},
1321
{"read_float", ReadFloat, METH_VARARGS},
14-
{"write_float", WriteFloat, METH_VARARGS},
1522
{"read_memory", ReadMemory, METH_VARARGS},
23+
{"set_raw", SetRaw, METH_VARARGS},
24+
{"write_float", WriteFloat, METH_VARARGS},
1625
{"write_memory", WriteMemory, METH_VARARGS},
1726
{} // sentinel
1827
};

0 commit comments

Comments
 (0)