- better PluginInformation structure (normal callback definitions)

This commit is contained in:
Mr. eXoDia 2014-03-11 15:57:17 +01:00
parent b4ca7616c9
commit 8adda5ee1e
3 changed files with 32 additions and 43 deletions

View File

@ -8,17 +8,13 @@ static std::vector<PluginInformation> Plugin;
// Global.Engine.Extension.Functions: // Global.Engine.Extension.Functions:
void ExtensionManagerPluginReleaseCallBack() void ExtensionManagerPluginReleaseCallBack()
{ {
typedef void(TITCALL *fPluginReleaseExec)();
fPluginReleaseExec myPluginReleaseExec;
for(unsigned int i = 0; i < Plugin.size(); i++) for(unsigned int i = 0; i < Plugin.size(); i++)
{ {
__try __try
{ {
if(Plugin.at(i).TitanReleasePlugin != NULL) if(Plugin.at(i).TitanReleasePlugin != NULL)
{ {
myPluginReleaseExec = (fPluginReleaseExec)Plugin.at(i).TitanReleasePlugin; Plugin.at(i).TitanReleasePlugin();
myPluginReleaseExec();
} }
} }
__except(EXCEPTION_EXECUTE_HANDLER) __except(EXCEPTION_EXECUTE_HANDLER)
@ -30,18 +26,13 @@ void ExtensionManagerPluginReleaseCallBack()
void ExtensionManagerPluginResetCallBack() void ExtensionManagerPluginResetCallBack()
{ {
typedef void(TITCALL *fPluginResetExec)();
fPluginResetExec myPluginResetExec;
for(unsigned int i = 0; i < Plugin.size(); i++) for(unsigned int i = 0; i < Plugin.size(); i++)
{ {
__try __try
{ {
if(Plugin.at(i).TitanResetPlugin != NULL) if(Plugin.at(i).TitanResetPlugin != NULL)
{ {
myPluginResetExec = (fPluginResetExec)Plugin.at(i).TitanResetPlugin; Plugin.at(i).TitanResetPlugin();
myPluginResetExec();
} }
} }
__except(EXCEPTION_EXECUTE_HANDLER) __except(EXCEPTION_EXECUTE_HANDLER)
@ -53,9 +44,6 @@ void ExtensionManagerPluginResetCallBack()
void ExtensionManagerPluginDebugCallBack(LPDEBUG_EVENT debugEvent, int CallReason) void ExtensionManagerPluginDebugCallBack(LPDEBUG_EVENT debugEvent, int CallReason)
{ {
typedef void(TITCALL *fPluginDebugExec)(LPDEBUG_EVENT debugEvent, int CallReason);
fPluginDebugExec myPluginDebugExec;
for(unsigned int i = 0; i < Plugin.size(); i++) for(unsigned int i = 0; i < Plugin.size(); i++)
{ {
__try __try
@ -64,8 +52,7 @@ void ExtensionManagerPluginDebugCallBack(LPDEBUG_EVENT debugEvent, int CallReaso
{ {
if(Plugin.at(i).TitanDebuggingCallBack != NULL) if(Plugin.at(i).TitanDebuggingCallBack != NULL)
{ {
myPluginDebugExec = (fPluginDebugExec)Plugin.at(i).TitanDebuggingCallBack; Plugin.at(i).TitanDebuggingCallBack(debugEvent, CallReason);
myPluginDebugExec(debugEvent, CallReason);
} }
} }
} }
@ -78,7 +65,6 @@ void ExtensionManagerPluginDebugCallBack(LPDEBUG_EVENT debugEvent, int CallReaso
void EngineInitPlugins(wchar_t* szEngineFolder) void EngineInitPlugins(wchar_t* szEngineFolder)
{ {
bool MoreFiles = true; bool MoreFiles = true;
bool NameHasBeenRegistered = false; bool NameHasBeenRegistered = false;
PluginInformation myPluginInfo = {}; PluginInformation myPluginInfo = {};
@ -87,7 +73,6 @@ void EngineInitPlugins(wchar_t* szEngineFolder)
#else #else
wchar_t* szPluginFolder = L"\\plugins\\x86\\"; wchar_t* szPluginFolder = L"\\plugins\\x86\\";
#endif #endif
typedef bool(TITCALL *fPluginRegister)(char* szPluginName, LPDWORD titanPluginMajorVersion, LPDWORD titanPluginMinorVersion);
wchar_t szPluginSearchString[MAX_PATH] = {}; wchar_t szPluginSearchString[MAX_PATH] = {};
wchar_t szPluginFullPath[MAX_PATH] = {}; wchar_t szPluginFullPath[MAX_PATH] = {};
fPluginRegister myPluginRegister; fPluginRegister myPluginRegister;
@ -107,10 +92,10 @@ void EngineInitPlugins(wchar_t* szEngineFolder)
myPluginInfo.PluginBaseAddress = LoadLibraryW(szPluginFullPath); myPluginInfo.PluginBaseAddress = LoadLibraryW(szPluginFullPath);
if(myPluginInfo.PluginBaseAddress != NULL) if(myPluginInfo.PluginBaseAddress != NULL)
{ {
myPluginInfo.TitanResetPlugin = (void*)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanResetPlugin"); myPluginInfo.TitanResetPlugin = (fPluginResetExec)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanResetPlugin");
myPluginInfo.TitanReleasePlugin = (void*)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanReleasePlugin"); myPluginInfo.TitanReleasePlugin = (fPluginReleaseExec)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanReleasePlugin");
myPluginInfo.TitanRegisterPlugin = (void*)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanRegisterPlugin"); myPluginInfo.TitanRegisterPlugin = (fPluginRegister)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanRegisterPlugin");
myPluginInfo.TitanDebuggingCallBack = (void*)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanDebuggingCallBack"); myPluginInfo.TitanDebuggingCallBack = (fPluginDebugExec)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanDebuggingCallBack");
myPluginRegister = (fPluginRegister)myPluginInfo.TitanRegisterPlugin; myPluginRegister = (fPluginRegister)myPluginInfo.TitanRegisterPlugin;
if(myPluginRegister != NULL) if(myPluginRegister != NULL)
{ {
@ -176,7 +161,6 @@ __declspec(dllexport) bool TITCALL ExtensionManagerIsPluginLoaded(char* szPlugin
__declspec(dllexport) bool TITCALL ExtensionManagerIsPluginEnabled(char* szPluginName) __declspec(dllexport) bool TITCALL ExtensionManagerIsPluginEnabled(char* szPluginName)
{ {
for(unsigned int i = 0; i < Plugin.size(); i++) for(unsigned int i = 0; i < Plugin.size(); i++)
{ {
if(lstrcmpiA(Plugin.at(i).PluginName, szPluginName) == NULL) if(lstrcmpiA(Plugin.at(i).PluginName, szPluginName) == NULL)
@ -196,7 +180,6 @@ __declspec(dllexport) bool TITCALL ExtensionManagerIsPluginEnabled(char* szPlugi
__declspec(dllexport) bool TITCALL ExtensionManagerDisableAllPlugins() __declspec(dllexport) bool TITCALL ExtensionManagerDisableAllPlugins()
{ {
for(unsigned int i = 0; i < Plugin.size(); i++) for(unsigned int i = 0; i < Plugin.size(); i++)
{ {
Plugin.at(i).PluginDisabled = true; Plugin.at(i).PluginDisabled = true;
@ -206,7 +189,6 @@ __declspec(dllexport) bool TITCALL ExtensionManagerDisableAllPlugins()
__declspec(dllexport) bool TITCALL ExtensionManagerDisablePlugin(char* szPluginName) __declspec(dllexport) bool TITCALL ExtensionManagerDisablePlugin(char* szPluginName)
{ {
for(unsigned int i = 0; i < Plugin.size(); i++) for(unsigned int i = 0; i < Plugin.size(); i++)
{ {
if(lstrcmpiA(Plugin.at(i).PluginName, szPluginName) == NULL) if(lstrcmpiA(Plugin.at(i).PluginName, szPluginName) == NULL)
@ -220,7 +202,6 @@ __declspec(dllexport) bool TITCALL ExtensionManagerDisablePlugin(char* szPluginN
__declspec(dllexport) bool TITCALL ExtensionManagerEnableAllPlugins() __declspec(dllexport) bool TITCALL ExtensionManagerEnableAllPlugins()
{ {
for(unsigned int i = 0; i < Plugin.size(); i++) for(unsigned int i = 0; i < Plugin.size(); i++)
{ {
Plugin.at(i).PluginDisabled = false; Plugin.at(i).PluginDisabled = false;
@ -230,7 +211,6 @@ __declspec(dllexport) bool TITCALL ExtensionManagerEnableAllPlugins()
__declspec(dllexport) bool TITCALL ExtensionManagerEnablePlugin(char* szPluginName) __declspec(dllexport) bool TITCALL ExtensionManagerEnablePlugin(char* szPluginName)
{ {
for(unsigned int i = 0; i < Plugin.size(); i++) for(unsigned int i = 0; i < Plugin.size(); i++)
{ {
if(lstrcmpiA(Plugin.at(i).PluginName, szPluginName) == NULL) if(lstrcmpiA(Plugin.at(i).PluginName, szPluginName) == NULL)
@ -244,7 +224,6 @@ __declspec(dllexport) bool TITCALL ExtensionManagerEnablePlugin(char* szPluginNa
__declspec(dllexport) bool TITCALL ExtensionManagerUnloadAllPlugins() __declspec(dllexport) bool TITCALL ExtensionManagerUnloadAllPlugins()
{ {
for(unsigned int i = 0; i < Plugin.size(); i++) for(unsigned int i = 0; i < Plugin.size(); i++)
{ {
if(FreeLibrary(Plugin.at(i).PluginBaseAddress)) if(FreeLibrary(Plugin.at(i).PluginBaseAddress))
@ -257,8 +236,6 @@ __declspec(dllexport) bool TITCALL ExtensionManagerUnloadAllPlugins()
__declspec(dllexport) bool TITCALL ExtensionManagerUnloadPlugin(char* szPluginName) __declspec(dllexport) bool TITCALL ExtensionManagerUnloadPlugin(char* szPluginName)
{ {
typedef void(TITCALL *fPluginReleaseExec)();
fPluginReleaseExec myPluginReleaseExec; fPluginReleaseExec myPluginReleaseExec;
for(unsigned int i = 0; i < Plugin.size(); i++) for(unsigned int i = 0; i < Plugin.size(); i++)

View File

@ -1,6 +1,31 @@
#ifndef _GLOBAL_ENGINE_EXTENSION_H #ifndef _GLOBAL_ENGINE_EXTENSION_H
#define _GLOBAL_ENGINE_EXTENSION_H #define _GLOBAL_ENGINE_EXTENSION_H
#include "definitions.h"
#define PLUGCALL TITCALL
//typedefs
typedef void(PLUGCALL *fPluginDebugExec)(LPDEBUG_EVENT debugEvent, int CallReason);
typedef bool(PLUGCALL *fPluginRegister)(char* szPluginName, LPDWORD titanPluginMajorVersion, LPDWORD titanPluginMinorVersion);
typedef void(PLUGCALL *fPluginReleaseExec)();
typedef void(PLUGCALL *fPluginResetExec)();
//structs
typedef struct
{
char PluginName[64];
DWORD PluginMajorVersion;
DWORD PluginMinorVersion;
HMODULE PluginBaseAddress;
fPluginDebugExec TitanDebuggingCallBack;
fPluginRegister TitanRegisterPlugin;
fPluginReleaseExec TitanReleasePlugin;
fPluginResetExec TitanResetPlugin;
bool PluginDisabled;
} PluginInformation, *PPluginInformation;
//functions
void ExtensionManagerPluginReleaseCallBack(); void ExtensionManagerPluginReleaseCallBack();
void ExtensionManagerPluginResetCallBack(); void ExtensionManagerPluginResetCallBack();
void ExtensionManagerPluginDebugCallBack(LPDEBUG_EVENT debugEvent, int CallReason); void ExtensionManagerPluginDebugCallBack(LPDEBUG_EVENT debugEvent, int CallReason);

View File

@ -49,19 +49,6 @@
#define UE_OPTION_IMPORTER_RETURN_NEAREST_APINAME 12 #define UE_OPTION_IMPORTER_RETURN_NEAREST_APINAME 12
#define UE_OPTION_IMPORTER_RETURN_API_ORDINAL_NUMBER 13 #define UE_OPTION_IMPORTER_RETURN_API_ORDINAL_NUMBER 13
typedef struct
{
char PluginName[64];
DWORD PluginMajorVersion;
DWORD PluginMinorVersion;
HMODULE PluginBaseAddress;
void* TitanDebuggingCallBack;
void* TitanRegisterPlugin;
void* TitanReleasePlugin;
void* TitanResetPlugin;
bool PluginDisabled;
} PluginInformation, *PPluginInformation;
typedef struct typedef struct
{ {
ULONG_PTR BreakPointAddress; ULONG_PTR BreakPointAddress;