Skip to content

Commit

Permalink
Add more funcs in memory module
Browse files Browse the repository at this point in the history
  • Loading branch information
user-grinch committed May 8, 2021
1 parent 6240b42 commit 4c43dcf
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
2 changes: 1 addition & 1 deletion PyLoader/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
#include <frameobject.h>
#include "plugin.h"

constexpr const char* plugin_ver = "0.01";
constexpr const char* plugin_ver = "0.02";
extern size_t game_ticks;
extern std::ofstream flog;
62 changes: 61 additions & 1 deletion PyLoader/sdk/PyMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,64 @@ PyObject* PyMemory::WriteFloat(PyObject* self, PyObject* args)
plugin::patch::Set<float>(addr, val, vp);

return PyBool_FromLong(1);
}
}

PyObject* PyMemory::Nop(PyObject* self, PyObject* args)
{
int addr = NULL;
int size = NULL;
int vp = NULL;

if (!PyArg_ParseTuple(args, "iii", &addr, &size, &vp))
return PyBool_FromLong(0);

plugin::patch::Nop(addr, size, vp);

return PyBool_FromLong(1);
}

PyObject* PyMemory::PutRetn(PyObject* self, PyObject* args)
{
int addr = NULL;
int size = NULL;
int pop_bytes = NULL;
int vp = NULL;

if (!PyArg_ParseTuple(args, "iiii", &addr, &size, &pop_bytes, &vp))
return PyBool_FromLong(0);

plugin::patch::PutRetn(addr, pop_bytes, vp);

return PyBool_FromLong(1);
}

PyObject* PyMemory::GetRaw(PyObject* self, PyObject* args)
{
int addr = NULL;
int size = NULL;
int vp = NULL;
char* data = nullptr;

if (!PyArg_ParseTuple(args, "iiii", &addr, &size, &vp))
return PyBool_FromLong(0);

plugin::patch::GetRaw(addr, data, size, vp);

return Py_BuildValue("s", data);
}

PyObject* PyMemory::SetRaw(PyObject* self, PyObject* args)
{
int addr = NULL;
int size = NULL;
char* data = NULL;
int vp = NULL;

if (!PyArg_ParseTuple(args, "isii", &addr, &data , &size, &vp))
return PyBool_FromLong(0);

plugin::patch::SetRaw(addr, data, size, vp);

return PyBool_FromLong(1);
}

13 changes: 11 additions & 2 deletions PyLoader/sdk/PyMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@
class PyMemory
{
private:
static PyObject* GetRaw(PyObject* self, PyObject* args);
static PyObject* Nop(PyObject* self, PyObject* args);
static PyObject* PutRetn(PyObject* self, PyObject* args);
static PyObject* ReadFloat(PyObject* self, PyObject* args);
static PyObject* WriteFloat(PyObject* self, PyObject* args);
static PyObject* ReadMemory(PyObject *self, PyObject *args);
static PyObject* SetRaw(PyObject* self, PyObject* args);
static PyObject* WriteFloat(PyObject* self, PyObject* args);
static PyObject* WriteMemory(PyObject *self, PyObject *args);

static inline PyMethodDef Methods[] =
{
{"get_raw", GetRaw, METH_VARARGS},
{"nop", Nop, METH_VARARGS},
{"put_retn", PutRetn, METH_VARARGS},
{"read_float", ReadFloat, METH_VARARGS},
{"write_float", WriteFloat, METH_VARARGS},
{"read_memory", ReadMemory, METH_VARARGS},
{"set_raw", SetRaw, METH_VARARGS},
{"write_float", WriteFloat, METH_VARARGS},
{"write_memory", WriteMemory, METH_VARARGS},
{} // sentinel
};
Expand Down

0 comments on commit 4c43dcf

Please sign in to comment.