Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C++ Plugin header File(updated to reflect DarkByte's post)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Source -> Plugin development
View previous topic :: View next topic  
Author Message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Fri Jan 23, 2009 5:24 pm    Post subject: C++ Plugin header File(updated to reflect DarkByte's post) Reply with quote

Many Thanks to DarkByte For original Files and the plugin SDK .. i chose a happy medium between 2.0 and 1.0
Code:

#include <windows.h>
#define CESDK_VERSION 2

typedef enum {ptAddressList, ptMemoryView, ptOnDebugEvent, ptProcesswatcherEvent, ptFunctionPointerchange, ptMainMenu} PluginType;

typedef struct _PluginVersion
{
  unsigned int version; //write here the minimum version this dll is compatible with (Current supported version: 1 and 2: this SDK only describes 2)
  char *pluginname;  //make this point to a 0-terminated string (allocated memory or static addressin your dll, not stack)
} PluginVersion, *PPluginVersion;

typedef struct _PLUGINTYPE0_RECORD
{
  char *interpretedaddress; //pointer to a 255 bytes long string (0 terminated)
  ULONG address;//this is a read-only representaion of the address. Change interpretedaddress if you want to change this
  BOOL ispointer; //readonly
  int countoffsets; //readonly
  ULONG *offsets; //array of dwords ranging from 0 to countoffsets-1 (readonly)
  char *description; //pointer to a 255 bytes long string
  char valuetype; //0=byte, 1=word, 2=dword, 3=float, 4=double, 5=bit, 6=int64, 7=string
  char size; //stringlength or bitlength;
} PLUGINTYPE0_RECORD, ADDRESSLIST_RECORD, *PPLUGINTYPE0_RECORD, *PADDRESSLIST_RECORD;

//callback routines efinitions for registered plugin functions:
typedef BOOL (__stdcall *CEP_PLUGINTYPE0)(PPLUGINTYPE0_RECORD SelectedRecord);
typedef BOOL (__stdcall *CEP_PLUGINTYPE1)(ULONG *disassembleraddress, ULONG *selected_disassembler_address, ULONG *hexviewaddress);
typedef int (__stdcall *CEP_PLUGINTYPE2)(LPDEBUG_EVENT DebugEvent);
typedef void (__stdcall *CEP_PLUGINTYPE3)(ULONG processid, ULONG peprocess, BOOL Created);
typedef void (__stdcall *CEP_PLUGINTYPE4)(int reserved);
typedef void (__stdcall *CEP_PLUGINTYPE5)(void);

typedef struct _PLUGINTYPE0_INIT
{
  char* name; //0 terminated string describing the name for the user's menu item
  CEP_PLUGINTYPE0 callbackroutine; //pointer to a callback routine of the type 0 plugin 
} PLUGINTYPE0_INIT, ADDRESSLISTPLUGIN_INIT, *PPLUGINTYPE0_INIT, *PADDRESSLISTPLUGIN_INIT;

typedef struct _PLUGINTYPE1_INIT
{
  char* name; //0 terminated string describing the name for the user's menu item
  CEP_PLUGINTYPE1 callbackroutine; //pointer to a callback routine of the type 1 plugin
  char* shortcut; //0 terminated string containing the shortcut in textform. CE will try it's best to parse it to a valid shortcut
} PLUGINTYPE1_INIT, MEMORYVIEWPLUGIN_INIT, *PPLUGINTYPE1_INIT, *PMEMORYVIEWPLUGIN_INIT;

typedef struct _PLUGINTYPE2_INIT
{
  CEP_PLUGINTYPE2 callbackroutine; //pointer to a callback routine of the type 2 plugin
} PLUGINTYPE2_INIT, DEBUGEVENTPLUGIN_INIT, *PPLUGINTYPE2_INIT, *PDEBUGEVENTPLUGIN_INIT;

typedef struct _PLUGINTYPE3_INIT
{
  CEP_PLUGINTYPE3 callbackroutine; //pointer to a callback routine of the type 3 plugin
} PLUGINTYPE3_INIT, PROCESSWATCHERPLUGIN_INIT, *PPLUGINTYPE3_INIT, *PPROCESSWATCHERPLUGIN_INIT;

typedef struct _PLUGINTYPE4_INIT
{
  CEP_PLUGINTYPE4 callbackroutine; //pointer to a callback routine of the type 3 plugin
} PLUGINTYPE4_INIT, POINTERREASSIGNMENTPLUGIN_INIT, *PPLUGINTYPE4_INIT, *PPOINTERREASSIGNMENTPLUGIN_INIT;

typedef struct _PLUGINTYPE5_INIT
{
  char* name; //0 terminated string describing the name for the user's menu item
  CEP_PLUGINTYPE5 callbackroutine; //pointer to a callback routine of the type 1 plugin
  char* shortcut; //0 terminated string containing the shortcut in textform. CE will try it's best to parse it to a valid shortcut
} PLUGINTYPE5_INIT, MAINMENUPLUGIN_INIT, *PPLUGINTYPE5_INIT, *PMAINMENUPLUGIN_INIT;


typedef struct _REGISTERMODIFICATIONINFO
{
  ULONG address; //addres to break on
  BOOL change_eax;
  BOOL change_ebx;
  BOOL change_ecx;
  BOOL change_edx;
  BOOL change_esi;
  BOOL change_edi;
  BOOL change_ebp;
  BOOL change_esp;
  BOOL change_eip;
  BOOL change_cf;
  BOOL change_pf;
  BOOL change_af;
  BOOL change_zf;
  BOOL change_sf;
  BOOL change_of;
  ULONG new_eax;
  ULONG new_ebx;
  ULONG new_ecx;
  ULONG new_edx;
  ULONG new_esi;
  ULONG new_edi;
  ULONG new_ebp;
  ULONG new_esp;
  ULONG new_eip;
  BOOL new_cf;
  BOOL new_pf;
  BOOL new_af;
  BOOL new_zf;
  BOOL new_sf;
  BOOL new_of;
} REGISTERMODIFICATIONINFO, *PREGISTERMODIFICATIONINFO;

//the __stdcall stuff isn't really needed since I've set compiler options to force stdcall, but this makes it clear that stdcall is used to the reader
typedef void (__stdcall *CEP_SHOWMESSAGE)(char* message);
typedef int (__stdcall *CEP_REGISTERFUNCTION) (int pluginid, PluginType functiontype, PVOID init);
typedef BOOL (__stdcall *CEP_UNREGISTERFUNCTION) (int pluginid, int functionid);
typedef HANDLE (__stdcall *CEP_GETMAINWINDOWHANDLE) (void);
typedef BOOL (__stdcall *CEP_AUTOASSEMBLE) (char *script);
typedef BOOL (__stdcall *CEP_ASSEMBLER) (ULONG address, char* instruction, BYTE *output, int maxlength, int *returnedsize);
typedef BOOL (__stdcall *CEP_DISASSEMBLER) (ULONG address, char* output, int maxsize);
typedef BOOL (__stdcall *CEP_CHANGEREGATADDRESS) (ULONG address,PREGISTERMODIFICATIONINFO changereg);
typedef BOOL (__stdcall *CEP_INJECTDLL) (char *dllname, char *functiontocall);
typedef int (__stdcall *CEP_FREEZEMEM) (ULONG address, int size);
typedef BOOL (__stdcall *CEP_UNFREEZEMEM) (int freezeID);
typedef BOOL (__stdcall *CEP_FIXMEM) (void);
typedef BOOL (__stdcall *CEP_PROCESSLIST) (char *listbuffer, int listsize);
typedef BOOL (__stdcall *CEP_RELOADSETTINGS) (void);
typedef DWORD (__stdcall *CEP_GETADDRESSFROMPOINTER) (ULONG baseaddress, int offsetcount, int* offsets); 
typedef BOOL (__stdcall *CEP_GENERATEAPIHOOKSCRIPT) (char *address, char *addresstojumpto, char *addresstogetnewcalladdress, char *script, int maxscriptsize);
typedef BOOL (__stdcall *CEP_ADDRESSTONAME) (DWORD address, char *name, int maxnamesize);
typedef BOOL (__stdcall *CEP_NAMETOADDRESS) (char *name, DWORD *address);


typedef BOOL   (__stdcall *ReadProc)(HANDLE hProcess,LPCVOID lpBaseAddress,LPVOID Buffer,SIZE_T nSize,SIZE_T *lpNumberOfBytesRead);
typedef BOOL   (__stdcall *WriteProc)(HANDLE hProcess,LPCVOID lpBaseAddress,LPVOID Buffer,SIZE_T nSize,SIZE_T *lpNumberOfBytesWritten);
typedef BOOL   (__stdcall *GetContext)(HANDLE hThread,LPCONTEXT lpContext);
typedef BOOL   (__stdcall *SetContext)(HANDLE hThread,CONTEXT *lpContext);
typedef DWORD  (__stdcall *ThreadSuspend)(HANDLE hThread);
typedef DWORD  (__stdcall *ThreadResume)(HANDLE hThread);
typedef HANDLE (__stdcall *ProcessOpen)(DWORD DesiredAccess,BOOL InheritHandle,DWORD ProcessId);
typedef BOOL   (__stdcall *WaitDbg)(LPDEBUG_EVENT lpDebugEvent,DWORD dwMilliSeconds);
typedef BOOL   (__stdcall *ContinueDbg)(DWORD ProcessId,DWORD ThreadId,DWORD ContinueStatus);
typedef BOOL   (__stdcall *DbgActive)(DWORD ProcessId);
typedef BOOL   (__stdcall *VirtProtect)(LPVOID lpAddress,SIZE_T dwSize,DWORD flNewProtect,PDWORD lpflOldProtect);
typedef BOOL   (__stdcall *VirtProtectEx)(HANDLE hProcess,LPVOID lpAddress,SIZE_T dwSize,DWORD flNewProtect,PDWORD lpdlOldProtect);
typedef SIZE_T (__stdcall *VirtQueryEx)(HANDLE hProcess,LPCVOID lpAddress,PMEMORY_BASIC_INFORMATION,SIZE_T dwLength);
typedef LPVOID (__stdcall *VirtAllocEx)(HANDLE hProcess,LPVOID lpAddress,SIZE_T dwSize,DWORD flAllocationType,DWORD flProtect);
typedef HANDLE (__stdcall *CreateRemote)(HANDLE hProcess,LPSECURITY_ATTRIBUTES lpThreadAttibutes,SIZE_T dwStackSize,LPTHREAD_START_ROUTINE lpStartAddress,LPVOID lpParameter,DWORD dwCreationFlags,LPDWORD lpThreadId);
typedef HANDLE (__stdcall *ThreadOpen)(DWORD dwDesiredAccess,BOOL InheritHandle,DWORD ThreadId);
typedef HANDLE (__stdcall *CreateSnapshot)(DWORD dwFlags,DWORD ProcessId);
typedef BOOL   (__stdcall *ProcFirst)(HANDLE hSnap,LPPROCESSENTRY32 lppe);
typedef BOOL   (__stdcall *ProcNext)(HANDLE hSnap,LPPROCESSENTRY32 lppe);
typedef BOOL   (__stdcall *ThreadFirst)(HANDLE hSnap,LPTHREADENTRY32 lpte);
typedef BOOL   (__stdcall *ThreadNext)(HANDLE hSnap,LPTHREADENTRY32 lpte);
typedef BOOL   (__stdcall *ModuleFirst)(HANDLE hSnap,LPMODULEENTRY32 lpme);
typedef BOOL   (__stdcall *ModuleNext)(HANDLE hSnap,LPMODULEENTRY32 lpme);
typedef BOOL   (__stdcall *HeapFirst)(HANDLE hSnap,LPHEAPENTRY32 lphe);
typedef BOOL   (__stdcall *HeapNext)(HANDLE hSnap,LPHEAPENTRY32 lphe);
typedef DWORD  (__stdcall *GetProc)(DWORD ProcessId);
typedef DWORD  (__stdcall *GetThread)(DWORD Threadid);
typedef DWORD  (__stdcall *GetDbgOffset)(void);
typedef DWORD  (__stdcall *GetNameOffset)(void);
typedef DWORD  (__stdcall *GetThreadsOffset)(void);
typedef DWORD  (__stdcall *GetThreadListOffset)(void);
typedef BOOL   (__stdcall *SetDbgState)(BOOL state);
typedef BOOL   (__stdcall *GetAddress)(HANDLE hProcess,LPVOID lpBaseAddress,DWORD Address);
typedef BOOL   (__stdcall *Protect)(DWORD ProtectedProcessID,BOOL denylist,BOOL globaldenylist,char*list,DWORD listsize);
typedef DWORD  (__stdcall *GCR4)(void);
typedef BOOL   (__stdcall *GCR3)(HANDLE hProc,DWORD*CR3);
typedef BOOL   (__stdcall *SCR3)(HANDLE hProc,DWORD CR3);
typedef DWORD  (__stdcall *GCR0)(void);
typedef DWORD  (__stdcall *GSDT)(void);
typedef DWORD  (__stdcall *GSDTShadow)(void);
typedef BOOL   (__stdcall *SetDbgMethod)(DWORD int1apihook,DWORD OriginalInt1handler);
typedef BOOL   (__stdcall *GetDbgMethod)(void);
typedef BOOL   (__stdcall *ChangeReg)(DWORD Processid,DWORD address,int debugreg,BOOL changeEAX,BOOL changeEBX,BOOL changeECX,BOOL changeEDX,BOOL changeESI,BOOL changeEDI,BOOL changeEBP,BOOL changeESP,BOOL changeEIP,BOOL changeCF,BOOL changePF,BOOL changeAF,BOOL changeZF,BOOL changeSF,BOOL changeOF,DWORD newEAX,DWORD newEBX,DWORD newECX,DWORD newEDX,DWORD newESI,DWORD newEDI,DWORD newEBP,DWORD newESP,DWORD newEIP, BOOL newCF,BOOL newPF,BOOL newAF,BOOL newZF,BOOL newSF,BOOL newOF);
typedef BOOL   (__stdcall *DbgProcess)(DWORD processid,DWORD address,BYTE size, BYTE debugtype);
typedef int    (__stdcall *RetrieveDbgData)(DWORD *Buffer);
typedef int    (__stdcall *GetNameFromID)(DWORD processid,char* buffer,DWORD buffersize);
typedef int    (__stdcall *GetNameFromPEProcess)(DWORD peprocess,char* buffer,DWORD buffersize);
typedef BOOL   (__stdcall *StartWatch)(void);
typedef DWORD  (__stdcall *WaitListData)(DWORD *processpointer,DWORD *threadpointer,DWORD timeout);
typedef BOOL   (__stdcall *IsValid)(HANDLE hProcess);
typedef DWORD  (__stdcall *GetIDTThread)(void);
typedef int    (__stdcall *GIDTs)(DWORD *idtstore,int maxidts);
typedef BOOL   (__stdcall *MkWritable)(DWORD Address,DWORD Size,BOOL copyonwrite);
typedef BOOL   (__stdcall *GetState)(void);
typedef BOOL   (__stdcall *Test)(void);
typedef BOOL   (__stdcall *DBKSus)(DWORD ThreadID);
typedef BOOL   (__stdcall *DBKRes)(DWORD ThreadID);
typedef BOOL   (__stdcall *DBKSusProcess)(DWORD ProcessID);
typedef BOOL   (__stdcall *DBKResProcess)(DWORD ProcessID);
typedef LPVOID (__stdcall *KAlloc)(DWORD size);
typedef LPVOID (__stdcall *GetKAddress)(WCHAR *s);



struct CALLTABLE
{
  ReadProc ReadProcessMemory;         //pointer of ReadProcessMemory
  WriteProc WriteProcessMemory;         //pointer of WriteProcessMemory
  GetContext GetThreadContext;         //   ...
  SetContext SetThreadContext;         //   ...
  ThreadSuspend SuspendThread;            //   ...
  ThreadResume ResumeThread;            //   ...
  ProcessOpen OpenProcess;            //   ...
  WaitDbg WaitForDebugEvent;         //   ...
  ContinueDbg ContinueDebugEvent;         //   ...
  DbgActive DebugActiveProcess;         //   ...
  PVOID StopDebugging;            //   ...
  PVOID StopRegisterChange;         //   ...
  VirtProtect VirtualProtect;            //   ...
  VirtProtectEx VirtualProtectEx;         //   ...
  VirtQueryEx VirtualQueryEx;            //   ...
  VirtAllocEx VirtualAllocEx;            //   ...
  CreateRemote CreateRemoteThread;         //   ...
  ThreadOpen OpenThread;               //   ...
  GetProc GetPEProcess;            //   ...
  GetThread GetPEThread;            //   ...
  GetThreadsOffset GetThreadsProcessOffset;   //   ...
  GetThreadListOffset GetThreadListEntryOffset;   //   ...
  GetNameOffset GetProcessnameOffset;      //   ...
  GetDbgOffset GetDebugportOffset;         //   ...
  GetAddress GetPhysicalAddress;         //   ...
  Protect ProtectMe;               //   ...
  GCR4 GetCR4;                  //   ...
  GCR3 GetCR3;                  //   ...
  SCR3 SetCR3;                  //   ...
  GSDT GetSDT;                  //   ...
  GSDTShadow GetSDTShadow;            //   ...
  SetDbgMethod setAlternateDebugMethod;   //   ...
  GetDbgMethod getAlternateDebugMethod;   //   ...
  DbgProcess DebugProcess;            //   ...
  ChangeReg ChangeRegOnBP;            //   ...
  RetrieveDbgData RetrieveDebugData;         //   ...
  StartWatch StartProcessWatch;         //   ...
  WaitListData WaitForProcessListData;      //   ...
  GetNameFromID GetProcessNameFromID;      //   ...
  GetNameFromPEProcess GetProcessNameFromPEProcess;//   ...
  ProcessOpen KernelOpenProcess;         //   ...
  ReadProc KernelReadProcessMemory;   //   ...
  WriteProc KernelWriteProcessMemory;   //   ...
  VirtAllocEx KernelVirtualAllocEx;      //   ...
  IsValid IsValidHandle;            //   ...
  GetIDTThread GetIDTCurrentThread;      //   ...
  GIDTs GetIDTs;               //   ...
  MkWritable MakeWritable;            //   ...
  GetState GetLoadedState;            //   ...
  DBKSus DBKSuspendThread;         //   ...
  DBKRes DBKResumeThread;         //   ...
  DBKSusProcess DBKSuspendProcess;         //   ...
  DBKResProcess DBKResumeProcess;         //   ...
  KAlloc KernelAlloc;            //   ...
  GetKAddress GetKProcAddress;         //   ...
  CreateSnapshot CreateToolhelp32Snapshot;   //   ...
  ProcFirst Process32First;             //   ...
  ProcNext Process32Next;              //   ...
  ThreadFirst Thread32First;              //   ...
  ThreadNext Thread32Next;               //   ...
  ModuleFirst Module32First;              //   ...
  ModuleNext Module32Next;               //   ...
  HeapFirst Heap32ListFirst;            //   ...
  HeapNext Heap32ListNext;             //   ...
};


struct ExportedFunctions
{
  int sizeofExportedFunctions;
  CEP_SHOWMESSAGE ShowMessage; //Pointer to the ce showmessage function
  CEP_REGISTERFUNCTION RegisterFunction; //Use this to register a specific type of plugin
  CEP_UNREGISTERFUNCTION UnregisterFunction; //unregisters a function registered with registerfunction
  PULONG OpenedProcessID; //pointer to the currently selected processid
  PHANDLE OpenedProcessHandle; //pointer to the currently selected processhandle

  CEP_GETMAINWINDOWHANDLE GetMainWindowHandle; //returns the handle of the main window (for whatever reason, it is recommended to use delphi to make a real userinterface upgrade)
  CEP_AUTOASSEMBLE AutoAssemble; //Pointer to the AutoAssemble function
  CEP_ASSEMBLER Assembler; //pointer to the assembler function
  CEP_DISASSEMBLER Disassembler; //pointer to the disassembler function
  CEP_CHANGEREGATADDRESS ChangeRegistersAtAddress; //pointer to the ChangeRegAtBP function
  CEP_INJECTDLL InjectDLL; //pointer to ce's Inject DLL function
  CEP_FREEZEMEM FreezeMem; //pointer to the FreezeMem routine
  CEP_UNFREEZEMEM UnfreezeMem; //pointer to the UnfreezeMem routine (use this to undo freezes with FreezeMem)
  CEP_FIXMEM FixMem; //pointer to the fixmem routine
  CEP_PROCESSLIST ProcessList; //pointer to the processlist routine
  CEP_RELOADSETTINGS ReloadSettings; //pointer to the ReloadSettings routine
  CEP_GETADDRESSFROMPOINTER GetAddressFromPointer; //pointer to the GetAddressFromPointer routine

  //pointers to the address that contains the pointers to the functions
  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  PVOID ReadProcessMemory;         //pointer to the pointer of ReadProcessMemory (Change it to hook that api, or use it yourself)
  PVOID WriteProcessMemory;         //pointer to the pointer of WriteProcessMemory (Change it to hook that api, or use it yourself)
  PVOID GetThreadContext;         //   ...
  PVOID SetThreadContext;         //   ...
  PVOID SuspendThread;            //   ...
  PVOID ResumeThread;            //   ...
  PVOID OpenProcess;            //   ...
  PVOID WaitForDebugEvent;         //   ...
  PVOID ContinueDebugEvent;         //   ...
  PVOID DebugActiveProcess;         //   ...
  PVOID StopDebugging;            //   ...
  PVOID StopRegisterChange;         //   ...
  PVOID VirtualProtect;            //   ...
  PVOID VirtualProtectEx;         //   ...
  PVOID VirtualQueryEx;            //   ...
  PVOID VirtualAllocEx;            //   ...
  PVOID CreateRemoteThread;         //   ...
  PVOID OpenThread;               //   ...
  PVOID GetPEProcess;            //   ...
  PVOID GetPEThread;            //   ...
  PVOID GetThreadsProcessOffset;   //   ...
  PVOID GetThreadListEntryOffset;   //   ...
  PVOID GetProcessnameOffset;      //   ...
  PVOID GetDebugportOffset;         //   ...
  PVOID GetPhysicalAddress;         //   ...
  PVOID ProtectMe;               //   ...
  PVOID GetCR4;                  //   ...
  PVOID GetCR3;                  //   ...
  PVOID SetCR3;                  //   ...
  PVOID GetSDT;                  //   ...
  PVOID GetSDTShadow;            //   ...
  PVOID setAlternateDebugMethod;   //   ...
  PVOID getAlternateDebugMethod;   //   ...
  PVOID DebugProcess;            //   ...
  PVOID ChangeRegOnBP;            //   ...
  PVOID RetrieveDebugData;         //   ...
  PVOID StartProcessWatch;         //   ...
  PVOID WaitForProcessListData;      //   ...
  PVOID GetProcessNameFromID;      //   ...
  PVOID GetProcessNameFromPEProcess;//   ...
  PVOID KernelOpenProcess;         //   ...
  PVOID KernelReadProcessMemory;   //   ...
  PVOID KernelWriteProcessMemory;   //   ...
  PVOID KernelVirtualAllocEx;      //   ...
  PVOID IsValidHandle;            //   ...
  PVOID GetIDTCurrentThread;      //   ...
  PVOID GetIDTs;               //   ...
  PVOID MakeWritable;            //   ...
  PVOID GetLoadedState;            //   ...
  PVOID DBKSuspendThread;         //   ...
  PVOID DBKResumeThread;         //   ...
  PVOID DBKSuspendProcess;         //   ...
  PVOID DBKResumeProcess;         //   ...
  PVOID KernelAlloc;            //   ...
  PVOID GetKProcAddress;         //   ...
  PVOID CreateToolhelp32Snapshot;   //   ...
  PVOID Process32First;             //   ...
  PVOID Process32Next;              //   ...
  PVOID Thread32First;              //   ...
  PVOID Thread32Next;               //   ...
  PVOID Module32First;              //   ...
  PVOID Module32Next;               //   ...
  PVOID Heap32ListFirst;            //   ...
  PVOID Heap32ListNext;             //   ...
  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  //advanced for delphi 7 enterprise dll programmers only
  PVOID mainform; //pointer to the Tmainform object. (main window) Compatible with TFORM of D7 Enterprise
  PVOID memorybrowser; //pointer to the TMemoryBrowser object (memory view windows), same as mainform

  //Plugin Version 2+
  CEP_GENERATEAPIHOOKSCRIPT sym_nameToAddress;
  CEP_ADDRESSTONAME sym_addressToName;
  CEP_NAMETOADDRESS sym_generateAPIHookScript;

};

struct ExportedFunctions Exported;
struct CALLTABLE CECT;

BOOL __stdcall GetVersion(struct PluginVersion *pv , int sizeofpluginversion);
BOOL __stdcall InitializePlugin(struct ExportedFunctions *ef , int pluginid);
BOOL __stdcall DisablePlugin(void);


also this should be placed in InitializePlugin
Code:

      CECT.ChangeRegOnBP = *(ChangeReg*)Exported.ChangeRegOnBP;
        CECT.ContinueDebugEvent = *(ContinueDbg*)Exported.ContinueDebugEvent;
      CECT.CreateToolhelp32Snapshot = *(CreateSnapshot*)Exported.CreateToolhelp32Snapshot;
      CECT.CreateRemoteThread = *(CreateRemote*)Exported.CreateRemoteThread;
      CECT.DBKResumeProcess = *(DBKResProcess*)Exported.DBKResumeProcess;
      CECT.DBKResumeThread = *(DBKRes*)Exported.DBKResumeThread;
      CECT.DBKSuspendProcess = *(DBKSusProcess*)Exported.DBKSuspendProcess;
      CECT.DBKSuspendThread = *(DBKSus*)Exported.DBKSuspendThread;
      CECT.DebugActiveProcess = *(DbgActive*)Exported.DebugActiveProcess;
      CECT.DebugProcess = *(DbgProcess*)Exported.DebugProcess;
      CECT.getAlternateDebugMethod = *(GetDbgMethod*)Exported.getAlternateDebugMethod;
      CECT.GetCR3 = *(GCR3*)Exported.GetCR3;
      CECT.GetCR4 = *(GCR4*)Exported.GetCR4;
      CECT.GetDebugportOffset = *(GetDbgOffset*)Exported.GetDebugportOffset;
      CECT.GetIDTCurrentThread = *(GetIDTThread*)Exported.GetIDTCurrentThread;
      CECT.GetIDTs = *(GIDTs*)Exported.GetIDTs;
      CECT.GetKProcAddress = *(GetKAddress*)Exported.GetKProcAddress;
      CECT.GetLoadedState = *(GetState*)Exported.GetLoadedState;
      CECT.GetPEProcess = *(GetProc*)Exported.GetPEProcess;
      CECT.GetPEThread = *(GetThread*)Exported.GetPEThread;
      CECT.GetPhysicalAddress = *(GetAddress*)Exported.GetPhysicalAddress;
      CECT.GetProcessNameFromID = *(GetNameFromID*)Exported.GetProcessNameFromID;
      CECT.GetProcessNameFromPEProcess = *(GetNameFromPEProcess*)Exported.GetProcessNameFromPEProcess;
      CECT.GetProcessnameOffset = *(GetNameOffset*)Exported.GetProcessnameOffset;
      CECT.GetSDT = *(GSDT*)Exported.GetSDT;
      CECT.GetSDTShadow = *(GSDTShadow*)Exported.GetSDTShadow;
      CECT.GetThreadContext = *(GetContext*)Exported.GetThreadContext;
      CECT.GetThreadListEntryOffset = *(GetThreadListOffset*)Exported.GetThreadListEntryOffset;
      CECT.GetThreadsProcessOffset = *(GetThreadsOffset*)Exported.GetThreadsProcessOffset;
      CECT.Heap32ListFirst = *(HeapFirst*)Exported.Heap32ListFirst;
      CECT.Heap32ListNext = *(HeapNext*)Exported.Heap32ListNext;
      CECT.IsValidHandle = *(IsValid*)Exported.IsValidHandle;
      CECT.KernelAlloc = *(KAlloc*)Exported.KernelAlloc;
      CECT.KernelOpenProcess = *(ProcessOpen*)Exported.KernelOpenProcess;
      CECT.KernelReadProcessMemory = *(ReadProc*)Exported.KernelReadProcessMemory;
      CECT.KernelVirtualAllocEx = *(VirtAllocEx*)Exported.KernelVirtualAllocEx;
      CECT.KernelWriteProcessMemory = *(WriteProc*)Exported.KernelWriteProcessMemory;
      CECT.MakeWritable = *(MkWritable*)Exported.MakeWritable;
      CECT.Module32First = *(ModuleFirst*)Exported.Module32First;
      CECT.Module32Next = *(ModuleNext*)Exported.Module32Next;
      CECT.OpenProcess = *(ProcessOpen*)Exported.OpenProcess;
      CECT.OpenThread = *(ThreadOpen*)Exported.OpenThread;
      CECT.Process32First = *(ProcFirst*)Exported.Process32First;
      CECT.Process32Next = *(ProcNext*)Exported.Process32Next;
      CECT.ProtectMe = *(Protect*)Exported.ProtectMe;
      CECT.ReadProcessMemory = *(ReadProc*)Exported.ReadProcessMemory;
      CECT.ResumeThread = *(ThreadResume*)Exported.ResumeThread;
      CECT.RetrieveDebugData = *(RetrieveDbgData*)Exported.RetrieveDebugData;
      CECT.setAlternateDebugMethod = *(SetDbgMethod*)Exported.setAlternateDebugMethod;
      CECT.SetCR3 = *(SCR3*)Exported.SetCR3;
      CECT.SetThreadContext = *(SetContext*)Exported.SetThreadContext;
      CECT.StartProcessWatch = *(StartWatch*)Exported.StartProcessWatch;
      CECT.StopDebugging = *(PVOID*)Exported.StopDebugging;
      CECT.StopRegisterChange = *(PVOID*)Exported.StopRegisterChange;
      CECT.SuspendThread = *(ThreadSuspend*)Exported.SuspendThread;
      CECT.Thread32First = *(ThreadFirst*)Exported.Thread32First;
      CECT.Thread32Next = *(ThreadNext*)Exported.Thread32Next;
      CECT.VirtualAllocEx = *(VirtAllocEx*)Exported.VirtualAllocEx;
      CECT.VirtualProtect = *(VirtProtect*)Exported.VirtualProtect;
      CECT.VirtualProtectEx = *(VirtProtectEx*)Exported.VirtualProtectEx;
      CECT.VirtualQueryEx = *(VirtQueryEx*)Exported.VirtualQueryEx;
      CECT.WaitForDebugEvent = *(WaitDbg*)Exported.WaitForDebugEvent;
      CECT.WaitForProcessListData = *(WaitListData*)Exported.WaitForProcessListData;
      CECT.WriteProcessMemory = *(WriteProc*)Exported.WriteProcessMemory;


please if you see a error in the declarations of functions PLEASE post them here .. (im not perfect) :}


Last edited by BanMe on Fri Jan 30, 2009 4:05 pm; edited 3 times in total
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25253
Location: The netherlands

PostPosted: Fri Jan 23, 2009 5:46 pm    Post subject: Reply with quote

You used the header file from the plugin example showing how to use Version 1 plugins

(C:\Program Files\Cheat Engine\Plugins\example-c\plugin.h should have newer one)
It's mostly the same, except there's a new plugintype, and 3 new exports ( and it contains a nice PluginType enum to make it easier to read)

Also, not sure, but I think the declaration of the items like ReadProcessMemory might be wrong. It's a pointer to a pointer to ReadProcessMemory, you've declared it as a pointer to readprocessmemory (main point is to hook those api's in ce easier, calling them is just secondary)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Fri Jan 23, 2009 6:11 pm    Post subject: Reply with quote

Embarassed

IC what you are saying code such as this would be required to call a function from that table

Code:

*Exported.DBKTest();


ill clean that up and include a new structure CALLTABLE in the next posting that reads the ExportedFunctions pointers.

Thank you for your quick reply..

regards BanMe
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Source -> Plugin development All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites