mirror of https://github.com/x64dbg/TitanEngine
more refactoring
This commit is contained in:
parent
a1134258a5
commit
215358f19d
|
|
@ -0,0 +1,304 @@
|
|||
#include "stdafx.h"
|
||||
#include "definitions.h"
|
||||
#include "Global.Engine.Extension.h"
|
||||
#include <vector>
|
||||
|
||||
static std::vector<PluginInformation> Plugin;
|
||||
|
||||
// Global.Engine.Extension.Functions:
|
||||
void ExtensionManagerPluginReleaseCallBack()
|
||||
{
|
||||
typedef void(TITCALL *fPluginReleaseExec)();
|
||||
fPluginReleaseExec myPluginReleaseExec;
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
__try
|
||||
{
|
||||
if(Plugin.at(i).TitanReleasePlugin != NULL)
|
||||
{
|
||||
myPluginReleaseExec = (fPluginReleaseExec)Plugin[i].TitanReleasePlugin;
|
||||
myPluginReleaseExec();
|
||||
}
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExtensionManagerPluginResetCallBack()
|
||||
{
|
||||
|
||||
typedef void(TITCALL *fPluginResetExec)();
|
||||
fPluginResetExec myPluginResetExec;
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
__try
|
||||
{
|
||||
if(Plugin.at(i).TitanResetPlugin != NULL)
|
||||
{
|
||||
myPluginResetExec = (fPluginResetExec)Plugin[i].TitanResetPlugin;
|
||||
myPluginResetExec();
|
||||
}
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
__try
|
||||
{
|
||||
if(!Plugin.at(i).PluginDisabled)
|
||||
{
|
||||
if(Plugin.at(i).TitanDebuggingCallBack != NULL)
|
||||
{
|
||||
myPluginDebugExec = (fPluginDebugExec)Plugin[i].TitanDebuggingCallBack;
|
||||
myPluginDebugExec(debugEvent, CallReason);
|
||||
}
|
||||
}
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EngineInitPlugins(wchar_t* szEngineFolder)
|
||||
{
|
||||
|
||||
bool MoreFiles = true;
|
||||
bool NameHasBeenRegistered = false;
|
||||
PluginInformation myPluginInfo = {};
|
||||
#if defined (_WIN64)
|
||||
wchar_t* szPluginFolder = L"plugins\\x64\\";
|
||||
#else
|
||||
wchar_t* szPluginFolder = L"plugins\\x86\\";
|
||||
#endif
|
||||
typedef bool(TITCALL *fPluginRegister)(char* szPluginName, LPDWORD titanPluginMajorVersion, LPDWORD titanPluginMinorVersion);
|
||||
wchar_t szPluginSearchString[MAX_PATH] = {};
|
||||
wchar_t szPluginFullPath[MAX_PATH] = {};
|
||||
fPluginRegister myPluginRegister;
|
||||
WIN32_FIND_DATAW FindData;
|
||||
HANDLE CurrentFile;
|
||||
|
||||
lstrcpyW(szPluginSearchString, szEngineFolder);
|
||||
lstrcatW(szPluginSearchString, szPluginFolder);
|
||||
lstrcatW(szPluginSearchString, L"*.dll");
|
||||
CurrentFile = FindFirstFileW(szPluginSearchString, &FindData);
|
||||
while(MoreFiles)
|
||||
{
|
||||
lstrcpyW(szPluginFullPath, szEngineFolder);
|
||||
lstrcatW(szPluginFullPath, szPluginFolder);
|
||||
lstrcatW(szPluginFullPath, FindData.cFileName);
|
||||
RtlZeroMemory(&myPluginInfo, sizeof PluginInformation);
|
||||
myPluginInfo.PluginBaseAddress = LoadLibraryW(szPluginFullPath);
|
||||
if(myPluginInfo.PluginBaseAddress != NULL)
|
||||
{
|
||||
myPluginInfo.TitanResetPlugin = (void*)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanResetPlugin");
|
||||
myPluginInfo.TitanReleasePlugin = (void*)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanReleasePlugin");
|
||||
myPluginInfo.TitanRegisterPlugin = (void*)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanRegisterPlugin");
|
||||
myPluginInfo.TitanDebuggingCallBack = (void*)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanDebuggingCallBack");
|
||||
myPluginRegister = (fPluginRegister)myPluginInfo.TitanRegisterPlugin;
|
||||
if(myPluginRegister != NULL)
|
||||
{
|
||||
__try
|
||||
{
|
||||
if(myPluginRegister((char*)&myPluginInfo.PluginName[0], &myPluginInfo.PluginMajorVersion, &myPluginInfo.PluginMinorVersion))
|
||||
{
|
||||
if(lstrlenA(myPluginInfo.PluginName) <= 64)
|
||||
{
|
||||
NameHasBeenRegistered = false;
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, myPluginInfo.PluginName) == NULL)
|
||||
{
|
||||
NameHasBeenRegistered = true;
|
||||
}
|
||||
}
|
||||
if(!NameHasBeenRegistered)
|
||||
{
|
||||
Plugin.push_back(myPluginInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
FreeLibrary(myPluginInfo.PluginBaseAddress);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FreeLibrary(myPluginInfo.PluginBaseAddress);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FreeLibrary(myPluginInfo.PluginBaseAddress);
|
||||
}
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
FreeLibrary(myPluginInfo.PluginBaseAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!FindNextFileW(CurrentFile, &FindData))
|
||||
{
|
||||
MoreFiles = false;
|
||||
}
|
||||
}
|
||||
FindClose(CurrentFile);
|
||||
}
|
||||
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerIsPluginLoaded(char* szPluginName)
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, szPluginName) == NULL)
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerIsPluginEnabled(char* szPluginName)
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, szPluginName) == NULL)
|
||||
{
|
||||
if(!Plugin[i].PluginDisabled)
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerDisableAllPlugins()
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
Plugin[i].PluginDisabled = true;
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerDisablePlugin(char* szPluginName)
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, szPluginName) == NULL)
|
||||
{
|
||||
Plugin[i].PluginDisabled = true;
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerEnableAllPlugins()
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
Plugin[i].PluginDisabled = false;
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerEnablePlugin(char* szPluginName)
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, szPluginName) == NULL)
|
||||
{
|
||||
Plugin[i].PluginDisabled = false;
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerUnloadAllPlugins()
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(FreeLibrary(Plugin[i].PluginBaseAddress))
|
||||
{
|
||||
Plugin.erase(Plugin.begin() + i);
|
||||
}
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerUnloadPlugin(char* szPluginName)
|
||||
{
|
||||
|
||||
typedef void(TITCALL *fPluginReleaseExec)();
|
||||
fPluginReleaseExec myPluginReleaseExec;
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, szPluginName) == NULL)
|
||||
{
|
||||
__try
|
||||
{
|
||||
if(Plugin[i].TitanReleasePlugin != NULL)
|
||||
{
|
||||
myPluginReleaseExec = (fPluginReleaseExec)Plugin[i].TitanReleasePlugin;
|
||||
myPluginReleaseExec();
|
||||
if(FreeLibrary(Plugin[i].PluginBaseAddress))
|
||||
{
|
||||
Plugin.erase(Plugin.begin() + i);
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
if(FreeLibrary(Plugin[i].PluginBaseAddress))
|
||||
{
|
||||
Plugin.erase(Plugin.begin() + i);
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void* TITCALL ExtensionManagerGetPluginInfo(char* szPluginName)
|
||||
{
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, szPluginName) == NULL)
|
||||
{
|
||||
return(&Plugin[i]);
|
||||
}
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef _GLOBAL_ENGINE_EXTENSION_H
|
||||
#define _GLOBAL_ENGINE_EXTENSION_H
|
||||
|
||||
void ExtensionManagerPluginReleaseCallBack();
|
||||
void ExtensionManagerPluginResetCallBack();
|
||||
void ExtensionManagerPluginDebugCallBack(LPDEBUG_EVENT debugEvent, int CallReason);
|
||||
void EngineInitPlugins(wchar_t* szEngineFolder);
|
||||
|
||||
#endif //_GLOBAL_ENGINE_EXTENSION_H
|
||||
|
|
@ -12,83 +12,12 @@ char engineFoundDLLName[512];
|
|||
char engineFoundAPIName[512];
|
||||
char engineExtractedFileName[512];
|
||||
wchar_t engineExtractedFileNameW[512];
|
||||
std::vector<PluginInformation> Plugin;
|
||||
HMODULE engineHandle;
|
||||
bool engineCheckForwarders = true;
|
||||
bool engineAlowModuleLoading = false;
|
||||
bool engineCreatePathForFiles = true; // hardcoded
|
||||
|
||||
// Global.Engine.functions:
|
||||
void EngineExecutePluginReleaseCallBack()
|
||||
{
|
||||
typedef void(TITCALL *fPluginReleaseExec)();
|
||||
fPluginReleaseExec myPluginReleaseExec;
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
__try
|
||||
{
|
||||
if(Plugin.at(i).TitanReleasePlugin != NULL)
|
||||
{
|
||||
myPluginReleaseExec = (fPluginReleaseExec)Plugin[i].TitanReleasePlugin;
|
||||
myPluginReleaseExec();
|
||||
}
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EngineExecutePluginResetCallBack()
|
||||
{
|
||||
|
||||
typedef void(TITCALL *fPluginResetExec)();
|
||||
fPluginResetExec myPluginResetExec;
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
__try
|
||||
{
|
||||
if(Plugin.at(i).TitanResetPlugin != NULL)
|
||||
{
|
||||
myPluginResetExec = (fPluginResetExec)Plugin[i].TitanResetPlugin;
|
||||
myPluginResetExec();
|
||||
}
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EngineExecutePluginDebugCallBack(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++)
|
||||
{
|
||||
__try
|
||||
{
|
||||
if(!Plugin.at(i).PluginDisabled)
|
||||
{
|
||||
if(Plugin.at(i).TitanDebuggingCallBack != NULL)
|
||||
{
|
||||
myPluginDebugExec = (fPluginDebugExec)Plugin[i].TitanDebuggingCallBack;
|
||||
myPluginDebugExec(debugEvent, CallReason);
|
||||
}
|
||||
}
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool EngineIsThereFreeHardwareBreakSlot(LPDWORD FreeRegister)
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -11,13 +11,7 @@ extern HMODULE engineHandle;
|
|||
extern bool engineAlowModuleLoading;
|
||||
extern bool engineCheckForwarders;
|
||||
|
||||
extern std::vector<PluginInformation> Plugin;
|
||||
|
||||
|
||||
//Global.Engine.Functions
|
||||
void EngineExecutePluginReleaseCallBack();
|
||||
void EngineExecutePluginResetCallBack();
|
||||
void EngineExecutePluginDebugCallBack(LPDEBUG_EVENT debugEvent, int CallReason);
|
||||
bool EngineIsThereFreeHardwareBreakSlot(LPDWORD FreeRegister);
|
||||
bool EngineFileExists(char* szFileName);
|
||||
char* EngineExtractPath(char* szFileName);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "Global.Engine.h"
|
||||
#include "Global.Handle.h"
|
||||
#include "Global.Mapping.h"
|
||||
#include "Global.Engine.Extension.h"
|
||||
|
||||
#define TE_VER_MAJOR 2
|
||||
#define TE_VER_MIDDLE 1
|
||||
|
|
@ -170,7 +171,6 @@ void* CwpBuffPatchedEntry;
|
|||
void* buffPatchedEntry;
|
||||
std::vector<HOOK_ENTRY> hookEntry;
|
||||
|
||||
|
||||
// Global.Engine.Hash:
|
||||
unsigned long Crc32Table[256];
|
||||
|
||||
|
|
@ -14037,11 +14037,11 @@ __declspec(dllexport) void TITCALL DebugLoop()
|
|||
RtlZeroMemory(&DBGEvent, sizeof DEBUG_EVENT);
|
||||
RtlZeroMemory(&TerminateDBGEvent, sizeof DEBUG_EVENT);
|
||||
RtlZeroMemory(&DLLDebugFileName, 512);
|
||||
EngineExecutePluginResetCallBack();
|
||||
ExtensionManagerPluginResetCallBack();
|
||||
engineFileIsBeingDebugged = true;
|
||||
if(engineExecutePluginCallBack)
|
||||
{
|
||||
EngineExecutePluginDebugCallBack(&DBGEvent, UE_PLUGIN_CALL_REASON_PREDEBUG);
|
||||
ExtensionManagerPluginDebugCallBack(&DBGEvent, UE_PLUGIN_CALL_REASON_PREDEBUG);
|
||||
}
|
||||
|
||||
while(!BreakDBG) //actual debug loop
|
||||
|
|
@ -14049,7 +14049,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
|
|||
WaitForDebugEvent(&DBGEvent, engineWaitForDebugEventTimeOut);
|
||||
if(engineExecutePluginCallBack)
|
||||
{
|
||||
EngineExecutePluginDebugCallBack(&DBGEvent, UE_PLUGIN_CALL_REASON_EXCEPTION);
|
||||
ExtensionManagerPluginDebugCallBack(&DBGEvent, UE_PLUGIN_CALL_REASON_EXCEPTION);
|
||||
}
|
||||
if(engineFindOEPCallBack != NULL)
|
||||
{
|
||||
|
|
@ -15727,7 +15727,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
|
|||
engineFileIsBeingDebugged = false;
|
||||
if(engineExecutePluginCallBack)
|
||||
{
|
||||
EngineExecutePluginDebugCallBack(&DBGEvent, UE_PLUGIN_CALL_REASON_POSTDEBUG);
|
||||
ExtensionManagerPluginDebugCallBack(&DBGEvent, UE_PLUGIN_CALL_REASON_POSTDEBUG);
|
||||
}
|
||||
}
|
||||
__declspec(dllexport) void TITCALL SetDebugLoopTimeOut(DWORD TimeOut)
|
||||
|
|
@ -24805,141 +24805,6 @@ __declspec(dllexport) void TITCALL EngineAddUnpackerWindowLogMessage(char* szLog
|
|||
cSelect--;
|
||||
SendMessageA(EngineBoxHandle, LB_SETCURSEL, (WPARAM)cSelect, NULL);
|
||||
}
|
||||
// Global.Engine.Extension.Functions:
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerIsPluginLoaded(char* szPluginName)
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, szPluginName) == NULL)
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerIsPluginEnabled(char* szPluginName)
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, szPluginName) == NULL)
|
||||
{
|
||||
if(!Plugin[i].PluginDisabled)
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerDisableAllPlugins()
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
Plugin[i].PluginDisabled = true;
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerDisablePlugin(char* szPluginName)
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, szPluginName) == NULL)
|
||||
{
|
||||
Plugin[i].PluginDisabled = true;
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerEnableAllPlugins()
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
Plugin[i].PluginDisabled = false;
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerEnablePlugin(char* szPluginName)
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, szPluginName) == NULL)
|
||||
{
|
||||
Plugin[i].PluginDisabled = false;
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerUnloadAllPlugins()
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(FreeLibrary(Plugin[i].PluginBaseAddress))
|
||||
{
|
||||
Plugin.erase(Plugin.begin() + i);
|
||||
}
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
__declspec(dllexport) bool TITCALL ExtensionManagerUnloadPlugin(char* szPluginName)
|
||||
{
|
||||
|
||||
typedef void(TITCALL *fPluginReleaseExec)();
|
||||
fPluginReleaseExec myPluginReleaseExec;
|
||||
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, szPluginName) == NULL)
|
||||
{
|
||||
__try
|
||||
{
|
||||
if(Plugin[i].TitanReleasePlugin != NULL)
|
||||
{
|
||||
myPluginReleaseExec = (fPluginReleaseExec)Plugin[i].TitanReleasePlugin;
|
||||
myPluginReleaseExec();
|
||||
if(FreeLibrary(Plugin[i].PluginBaseAddress))
|
||||
{
|
||||
Plugin.erase(Plugin.begin() + i);
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
if(FreeLibrary(Plugin[i].PluginBaseAddress))
|
||||
{
|
||||
Plugin.erase(Plugin.begin() + i);
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
__declspec(dllexport) void* TITCALL ExtensionManagerGetPluginInfo(char* szPluginName)
|
||||
{
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, szPluginName) == NULL)
|
||||
{
|
||||
return(&Plugin[i]);
|
||||
}
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// Global.Garbage.functions:
|
||||
bool CreateGarbageItem(void* outGargabeItem, int MaxGargabeStringSize)
|
||||
|
|
@ -25084,90 +24949,7 @@ void EmptyGarbage()
|
|||
RemoveGarbageItem(engineSzEngineGarbageFolder, false);
|
||||
}
|
||||
// Global.Engine.Functions:
|
||||
void EngineInitPlugins(wchar_t* szEngineFolder)
|
||||
{
|
||||
|
||||
bool MoreFiles = true;
|
||||
bool NameHasBeenRegistered = false;
|
||||
PluginInformation myPluginInfo = {};
|
||||
#if defined (_WIN64)
|
||||
wchar_t* szPluginFolder = L"plugins\\x64\\";
|
||||
#else
|
||||
wchar_t* szPluginFolder = L"plugins\\x86\\";
|
||||
#endif
|
||||
typedef bool(TITCALL *fPluginRegister)(char* szPluginName, LPDWORD titanPluginMajorVersion, LPDWORD titanPluginMinorVersion);
|
||||
wchar_t szPluginSearchString[MAX_PATH] = {};
|
||||
wchar_t szPluginFullPath[MAX_PATH] = {};
|
||||
fPluginRegister myPluginRegister;
|
||||
WIN32_FIND_DATAW FindData;
|
||||
HANDLE CurrentFile;
|
||||
|
||||
lstrcpyW(szPluginSearchString, szEngineFolder);
|
||||
lstrcatW(szPluginSearchString, szPluginFolder);
|
||||
lstrcatW(szPluginSearchString, L"*.dll");
|
||||
CurrentFile = FindFirstFileW(szPluginSearchString, &FindData);
|
||||
while(MoreFiles)
|
||||
{
|
||||
lstrcpyW(szPluginFullPath, szEngineFolder);
|
||||
lstrcatW(szPluginFullPath, szPluginFolder);
|
||||
lstrcatW(szPluginFullPath, FindData.cFileName);
|
||||
RtlZeroMemory(&myPluginInfo, sizeof PluginInformation);
|
||||
myPluginInfo.PluginBaseAddress = LoadLibraryW(szPluginFullPath);
|
||||
if(myPluginInfo.PluginBaseAddress != NULL)
|
||||
{
|
||||
myPluginInfo.TitanResetPlugin = (void*)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanResetPlugin");
|
||||
myPluginInfo.TitanReleasePlugin = (void*)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanReleasePlugin");
|
||||
myPluginInfo.TitanRegisterPlugin = (void*)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanRegisterPlugin");
|
||||
myPluginInfo.TitanDebuggingCallBack = (void*)GetProcAddress(myPluginInfo.PluginBaseAddress, "TitanDebuggingCallBack");
|
||||
myPluginRegister = (fPluginRegister)myPluginInfo.TitanRegisterPlugin;
|
||||
if(myPluginRegister != NULL)
|
||||
{
|
||||
__try
|
||||
{
|
||||
if(myPluginRegister((char*)&myPluginInfo.PluginName[0], &myPluginInfo.PluginMajorVersion, &myPluginInfo.PluginMinorVersion))
|
||||
{
|
||||
if(lstrlenA(myPluginInfo.PluginName) <= 64)
|
||||
{
|
||||
NameHasBeenRegistered = false;
|
||||
for(unsigned int i = 0; i < Plugin.size(); i++)
|
||||
{
|
||||
if(lstrcmpiA(Plugin[i].PluginName, myPluginInfo.PluginName) == NULL)
|
||||
{
|
||||
NameHasBeenRegistered = true;
|
||||
}
|
||||
}
|
||||
if(!NameHasBeenRegistered)
|
||||
{
|
||||
Plugin.push_back(myPluginInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
FreeLibrary(myPluginInfo.PluginBaseAddress);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FreeLibrary(myPluginInfo.PluginBaseAddress);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FreeLibrary(myPluginInfo.PluginBaseAddress);
|
||||
}
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
FreeLibrary(myPluginInfo.PluginBaseAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!FindNextFileW(CurrentFile, &FindData))
|
||||
{
|
||||
MoreFiles = false;
|
||||
}
|
||||
}
|
||||
FindClose(CurrentFile);
|
||||
}
|
||||
void EngineInit()
|
||||
{
|
||||
|
||||
|
|
@ -25229,7 +25011,7 @@ bool APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
|||
case DLL_PROCESS_DETACH:
|
||||
if(lpReserved != NULL)
|
||||
{
|
||||
EngineExecutePluginReleaseCallBack();
|
||||
ExtensionManagerPluginReleaseCallBack();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,6 +216,7 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Global.Engine.cpp" />
|
||||
<ClCompile Include="Global.Engine.Extension.cpp" />
|
||||
<ClCompile Include="Global.Handle.cpp" />
|
||||
<ClCompile Include="Global.Mapping.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
|
|
@ -232,6 +233,7 @@
|
|||
<ClInclude Include="aplib.h" />
|
||||
<ClInclude Include="definitions.h" />
|
||||
<ClInclude Include="distorm.h" />
|
||||
<ClInclude Include="Global.Engine.Extension.h" />
|
||||
<ClInclude Include="Global.Engine.h" />
|
||||
<ClInclude Include="Global.Handle.h" />
|
||||
<ClInclude Include="Global.Mapping.h" />
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@
|
|||
<ClCompile Include="Global.Engine.cpp">
|
||||
<Filter>Source Files\TitanEngine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Global.Engine.Extension.cpp">
|
||||
<Filter>Source Files\TitanEngine</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h">
|
||||
|
|
@ -92,6 +95,9 @@
|
|||
<ClInclude Include="Global.Engine.h">
|
||||
<Filter>Header Files\TitanEngine</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Global.Engine.Extension.h">
|
||||
<Filter>Header Files\TitanEngine</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="TitanEngine.rc">
|
||||
|
|
|
|||
Loading…
Reference in New Issue