Anyway, I was trying to make a c++ plugin for scar, and it didn't work. So I went through the trouble of making a plugin that would manualy inject a c++ dll into scar, only to find out that I had messed up an address for a pointer... Needless to say its easier than memory injection Ask questions, etc.
Code:
#include <windows.h>
#define Export _declspec(dllexport)
#define DelphiExport extern "C" Export
HINSTANCE inst;
Export BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID checks) {
switch(reason) {
case DLL_PROCESS_ATTACH:
//Do you're init here, but don't change anything else (besides cleanup)
inst = instance;
case DLL_THREAD_ATTACH:
return true;
case DLL_PROCESS_DETACH:
//Do you're cleanup here, but don't change anything else (besides init)
FreeLibrary(inst);
case DLL_THREAD_DETACH:
return true;
}
return false;
}
//Add in your functions
DelphiExport void __stdcall Test(void) {
//Shows a message box.
MessageBox(NULL, "Testing 1 2 3", "DLL", MB_OK);
}
//Export name changed in def file
DelphiExport int __stdcall GetFunctionCount(void) {
return 1; //Change depending on number to export
}
//Export name changed in def file
DelphiExport int __stdcall GetFunctionInfo(int x, void*& address, char*& def) {
switch (x) {
case 0:
address = GetProcAddress(inst,"_Test@0"); //Remember C naming scheme?
strcpy(def,"procedure DllTest;"); //Have to strcpy, how you want it to be called
return x;
}
return -1;
}
Plus the REQUIRED def file:
Code:
LIBRARY ScarPlugin
EXPORTS
GetFunctionInfo = _GetFunctionInfo@12
GetFunctionCount = _GetFunctionCount@0