Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 80 additions & 77 deletions IMG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,205 +9,208 @@

*/

#include <Python.h>
#include "pin.H"
#include <strings.h>
namespace SPPY
{
#include <Python.h>
}
#include <string.h>
#include <stdlib.h>
#include "IMG.h"

PyObject* Python_IMG_Next(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_Next(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);

IMG* img_object = (IMG*) malloc(sizeof(IMG));
*img_object = IMG_Next(*(IMG*)PyInt_AsLong(img));
return Py_BuildValue("k", img_object);
return SPPY::Py_BuildValue("k", img_object);
}

PyObject* Python_IMG_Prev(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_Prev(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);

IMG* img_object = (IMG*) malloc(sizeof(IMG));
*img_object = IMG_Prev(*(IMG*)PyInt_AsLong(img));
return Py_BuildValue("k", img_object);
return SPPY::Py_BuildValue("k", img_object);
}

PyObject* Python_IMG_Invalid(PyObject* self, PyObject* args) {
SPPY::PyObject* Python_IMG_Invalid(SPPY::PyObject* self, SPPY::PyObject* args) {
IMG* img_object = (IMG*) malloc(sizeof(IMG));
*img_object = IMG_Invalid();
return Py_BuildValue("k", img_object);
return SPPY::Py_BuildValue("k", img_object);
}

PyObject* Python_IMG_Valid(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_Valid(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
if (IMG_Valid(img_object)) {
return Py_BuildValue("O", Py_True);
return SPPY::Py_BuildValue("O", ((SPPY::PyObject *) &SPPY::_Py_TrueStruct));
}

return Py_BuildValue("O", Py_False);
return SPPY::Py_BuildValue("O", ((SPPY::PyObject *) &SPPY::_Py_ZeroStruct));
}

PyObject* Python_IMG_SecHead(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_SecHead(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
SEC* sec = (SEC*) malloc(sizeof(SEC));
*sec = IMG_SecHead(img_object);
return Py_BuildValue("k", sec);
return SPPY::Py_BuildValue("k", sec);
}

PyObject* Python_IMG_SecTail(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_SecTail(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
SEC* sec = (SEC*) malloc(sizeof(SEC));
*sec = IMG_SecTail(img_object);
return Py_BuildValue("k", sec);
return SPPY::Py_BuildValue("k", sec);
}

PyObject* Python_IMG_RegsymHead(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_RegsymHead(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
// IMG img_object = *(IMG*)PyInt_AsLong(img);
return Py_BuildValue("O", Py_True);
return SPPY::Py_BuildValue("O", ((SPPY::PyObject *) &SPPY::_Py_TrueStruct));
}

PyObject* Python_IMG_Entry(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_Entry(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
return Py_BuildValue("k", IMG_Entry(img_object));
return SPPY::Py_BuildValue("k", IMG_Entry(img_object));
}

PyObject* Python_IMG_Name(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_Name(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
return Py_BuildValue("s", IMG_Name(img_object).c_str());
return SPPY::Py_BuildValue("s", IMG_Name(img_object).c_str());
}

PyObject* Python_IMG_Gp(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_Gp(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
return Py_BuildValue("k", IMG_Gp(img_object));
return SPPY::Py_BuildValue("k", IMG_Gp(img_object));
}

PyObject* Python_IMG_LoadOffset(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_LoadOffset(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
return Py_BuildValue("k", IMG_LoadOffset(img_object));
return SPPY::Py_BuildValue("k", IMG_LoadOffset(img_object));
}

PyObject* Python_IMG_LowAddress(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_LowAddress(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
return Py_BuildValue("k", IMG_LowAddress(img_object));
return SPPY::Py_BuildValue("k", IMG_LowAddress(img_object));
}

PyObject* Python_IMG_HighAddress(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_HighAddress(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
return Py_BuildValue("k", IMG_HighAddress(img_object));
return SPPY::Py_BuildValue("k", IMG_HighAddress(img_object));
}

PyObject* Python_IMG_StartAddress(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_StartAddress(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
return Py_BuildValue("k", IMG_StartAddress(img_object));
return SPPY::Py_BuildValue("k", IMG_StartAddress(img_object));
}

PyObject* Python_IMG_SizeMapped(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_SizeMapped(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
return Py_BuildValue("k", IMG_SizeMapped(img_object));
return SPPY::Py_BuildValue("k", IMG_SizeMapped(img_object));
}

PyObject* Python_IMG_Type(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_Type(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
return Py_BuildValue("k", IMG_Type(img_object));
return SPPY::Py_BuildValue("k", IMG_Type(img_object));
}

PyObject* Python_IMG_IsMainExecutable(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_IsMainExecutable(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
if (IMG_IsMainExecutable(img_object)) {
return Py_BuildValue("O", Py_True);
return SPPY::Py_BuildValue("O", ((SPPY::PyObject *) &SPPY::_Py_TrueStruct));
}

return Py_BuildValue("O", Py_False);
return SPPY::Py_BuildValue("O", ((SPPY::PyObject *) &SPPY::_Py_ZeroStruct));
}

PyObject* Python_IMG_IsStaticExecutable(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_IsStaticExecutable(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
if (IMG_IsStaticExecutable(img_object)) {
return Py_BuildValue("O", Py_True);
return SPPY::Py_BuildValue("O", ((SPPY::PyObject *) &SPPY::_Py_TrueStruct));
}

return Py_BuildValue("O", Py_False);
return SPPY::Py_BuildValue("O", ((SPPY::PyObject *) &SPPY::_Py_ZeroStruct));
}

PyObject* Python_IMG_Id(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_Id(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
return Py_BuildValue("k", IMG_Id(img_object));
return SPPY::Py_BuildValue("k", IMG_Id(img_object));
}

PyObject* Python_IMG_FindImgById(PyObject* self, PyObject* args) {
PyObject* id;
SPPY::PyObject* Python_IMG_FindImgById(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* id;
PyArg_ParseTuple(args, "O", &id);
IMG* img = (IMG*) malloc(sizeof(IMG));
*img = IMG_FindImgById((UINT32) PyInt_AsLong(id));
return Py_BuildValue("k", img);
return SPPY::Py_BuildValue("k", img);
}

PyObject* Python_IMG_FindByAddress(PyObject* self, PyObject* args) {
PyObject* address;
SPPY::PyObject* Python_IMG_FindByAddress(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* address;
PyArg_ParseTuple(args, "O", &address);
IMG* img = (IMG*) malloc(sizeof(IMG));
*img = IMG_FindByAddress((ADDRINT) PyInt_AsLong(address));
return Py_BuildValue("k", img);
return SPPY::Py_BuildValue("k", img);
}

PyObject* Python_IMG_Open(PyObject* self, PyObject* args) {
PyObject* filename;
SPPY::PyObject* Python_IMG_Open(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* filename;
PyArg_ParseTuple(args, "O", &filename);
IMG* img = (IMG*) malloc(sizeof(IMG));
*img = IMG_Open(PyString_AsString(filename));
return Py_BuildValue("k", img);
return SPPY::Py_BuildValue("k", img);
}

PyObject* Python_IMG_Close(PyObject* self, PyObject* args) {
PyObject* img;
SPPY::PyObject* Python_IMG_Close(SPPY::PyObject* self, SPPY::PyObject* args) {
SPPY::PyObject* img;
PyArg_ParseTuple(args, "O", &img);
IMG img_object = *(IMG*)PyInt_AsLong(img);
IMG_Close(img_object);
return Py_BuildValue("O", Py_True);
return SPPY::Py_BuildValue("O", ((SPPY::PyObject *) &SPPY::_Py_TrueStruct));
}

PyObject* Python_APP_ImgHead(PyObject* self, PyObject* args) {
SPPY::PyObject* Python_APP_ImgHead(SPPY::PyObject* self, SPPY::PyObject* args) {
IMG* img = (IMG*) malloc(sizeof(IMG));
*img = APP_ImgHead();
return Py_BuildValue("k", img);
return SPPY::Py_BuildValue("k", img);
}

PyObject* Python_APP_ImgTail(PyObject* self, PyObject* args) {
SPPY::PyObject* Python_APP_ImgTail(SPPY::PyObject* self, SPPY::PyObject* args) {
IMG* img = (IMG*) malloc(sizeof(IMG));
*img = APP_ImgTail();
return Py_BuildValue("k", img);
return SPPY::Py_BuildValue("k", img);
}

62 changes: 31 additions & 31 deletions IMG.h
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
#ifndef A_H
#define A_H

// void add_hook(PyObject*** hooks, PyObject* new_hook);
// PyObject** hooks_list = *hooks;
// void add_hook(SPPY::PyObject*** hooks, SPPY::PyObject* new_hook);
// SPPY::PyObject** hooks_list = *hooks;
// if (hooks_list == NULL) {
// hooks_list = (PyObject**) malloc(sizeof(PyObject*)*2);
// hooks_list = (SPPY::PyObject**) malloc(sizeof(SPPY::PyObject*)*2);
// hooks_list[0] = new_hook;
// hooks_list[1] = NULL;
// } else {
// int hook_count;
// for(hook_count=0; hooks_list[hook_count]; hook_count++);
// hooks_list = (PyObject**) realloc(hooks_list, sizeof(PyObject*)*(hook_count+2));
// hooks_list = (SPPY::PyObject**) realloc(hooks_list, sizeof(SPPY::PyObject*)*(hook_count+2));
// hooks_list[hook_count] = new_hook;
// hooks_list[hook_count+1] = NULL;
// }

// *hooks = hooks_list;
// }
// ------------------- auto generated
PyObject* Python_IMG_Next(PyObject* self, PyObject* args);
PyObject* Python_IMG_Prev(PyObject* self, PyObject* args);
PyObject* Python_IMG_Invalid(PyObject* self, PyObject* args);
PyObject* Python_IMG_Valid(PyObject* self, PyObject* args);
PyObject* Python_IMG_SecHead(PyObject* self, PyObject* args);
PyObject* Python_IMG_SecTail(PyObject* self, PyObject* args);
PyObject* Python_IMG_RegsymHead(PyObject* self, PyObject* args);
PyObject* Python_IMG_Entry(PyObject* self, PyObject* args);
PyObject* Python_IMG_Name(PyObject* self, PyObject* args) ;
PyObject* Python_IMG_Gp(PyObject* self, PyObject* args) ;
PyObject* Python_IMG_LoadOffset(PyObject* self, PyObject* args) ;
PyObject* Python_IMG_LowAddress(PyObject* self, PyObject* args);
PyObject* Python_IMG_HighAddress(PyObject* self, PyObject* args);
PyObject* Python_IMG_StartAddress(PyObject* self, PyObject* args);
PyObject* Python_IMG_SizeMapped(PyObject* self, PyObject* args);
PyObject* Python_IMG_Type(PyObject* self, PyObject* args);
PyObject* Python_IMG_IsMainExecutable(PyObject* self, PyObject* args);
PyObject* Python_IMG_IsStaticExecutable(PyObject* self, PyObject* args);
PyObject* Python_IMG_Id(PyObject* self, PyObject* args);
PyObject* Python_IMG_FindImgById(PyObject* self, PyObject* args);
PyObject* Python_IMG_FindByAddress(PyObject* self, PyObject* args);
PyObject* Python_IMG_AddInstrumentFunction(PyObject* self, PyObject* args);
PyObject* Python_IMG_AddUnloadFunction(PyObject* self, PyObject* args);
PyObject* Python_IMG_Open(PyObject* self, PyObject* args);
PyObject* Python_IMG_Close(PyObject* self, PyObject* args);
PyObject* Python_APP_ImgHead(PyObject* self, PyObject* args);
PyObject* Python_APP_ImgTail(PyObject* self, PyObject* args);
SPPY::PyObject* Python_IMG_Next(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_Prev(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_Invalid(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_Valid(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_SecHead(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_SecTail(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_RegsymHead(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_Entry(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_Name(SPPY::PyObject* self, SPPY::PyObject* args) ;
SPPY::PyObject* Python_IMG_Gp(SPPY::PyObject* self, SPPY::PyObject* args) ;
SPPY::PyObject* Python_IMG_LoadOffset(SPPY::PyObject* self, SPPY::PyObject* args) ;
SPPY::PyObject* Python_IMG_LowAddress(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_HighAddress(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_StartAddress(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_SizeMapped(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_Type(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_IsMainExecutable(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_IsStaticExecutable(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_Id(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_FindImgById(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_FindByAddress(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_AddInstrumentFunction(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_AddUnloadFunction(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_Open(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_IMG_Close(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_APP_ImgHead(SPPY::PyObject* self, SPPY::PyObject* args);
SPPY::PyObject* Python_APP_ImgTail(SPPY::PyObject* self, SPPY::PyObject* args);

#endif
Loading