[Project64] remove windows.h from plugin handling
This commit is contained in:
parent
92e617d284
commit
e8468687ac
|
@ -1,13 +1,61 @@
|
|||
#include "stdafx.h"
|
||||
#include "Util.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <Tlhelp32.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
pjutil::DynLibHandle pjutil::DynLibOpen(const char *pccLibraryPath, bool ShowErrors)
|
||||
{
|
||||
if (pccLibraryPath == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
UINT LastErrorMode = SetErrorMode(ShowErrors ? 0 : SEM_FAILCRITICALERRORS);
|
||||
pjutil::DynLibHandle lib = (pjutil::DynLibHandle)LoadLibrary(pccLibraryPath);
|
||||
SetErrorMode(LastErrorMode);
|
||||
return lib;
|
||||
}
|
||||
|
||||
void * pjutil::DynLibGetProc(pjutil::DynLibHandle LibHandle, const char * ProcedureName)
|
||||
{
|
||||
if (ProcedureName == NULL)
|
||||
return NULL;
|
||||
|
||||
return GetProcAddress((HMODULE)LibHandle, ProcedureName);
|
||||
}
|
||||
|
||||
void pjutil::DynLibClose(pjutil::DynLibHandle LibHandle)
|
||||
{
|
||||
FreeLibrary((HMODULE)LibHandle);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static void EmptyThreadFunction(void)
|
||||
{
|
||||
}
|
||||
|
||||
void pjutil::DynLibCallDllMain(void)
|
||||
{
|
||||
//jabo had a bug so I call CreateThread so the dllmain in the plugins will get called again with thread attached
|
||||
DWORD ThreadID;
|
||||
HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)EmptyThreadFunction, NULL, 0, &ThreadID);
|
||||
CloseHandle(hthread);
|
||||
}
|
||||
#endif
|
||||
|
||||
void pjutil::Sleep(uint32_t timeout)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
::Sleep(timeout);
|
||||
#else
|
||||
sleep(timeout);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
bool pjutil::TerminatedExistingExe()
|
||||
{
|
||||
bool bTerminated = false;
|
||||
|
@ -59,4 +107,5 @@ bool pjutil::TerminatedExistingExe()
|
|||
CloseHandle(nSearch);
|
||||
}
|
||||
return bTerminated;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,6 +4,14 @@
|
|||
class pjutil
|
||||
{
|
||||
public:
|
||||
typedef void * DynLibHandle;
|
||||
|
||||
static DynLibHandle DynLibOpen(const char *pccLibraryPath, bool ShowErrors = true);
|
||||
static void * DynLibGetProc(DynLibHandle LibHandle, const char * ProcedureName);
|
||||
static void DynLibClose(DynLibHandle LibHandle);
|
||||
#ifdef _WIN32
|
||||
static void DynLibCallDllMain(void);
|
||||
#endif
|
||||
static void Sleep(uint32_t timeout);
|
||||
static bool TerminatedExistingExe();
|
||||
|
||||
|
|
|
@ -15,15 +15,17 @@
|
|||
#include <Project64-core/N64System/Mips/RegisterClass.h>
|
||||
#include <Project64-core/N64System/N64Class.h>
|
||||
#include "AudioPlugin.h"
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
CAudioPlugin::CAudioPlugin() :
|
||||
AiLenChanged(NULL),
|
||||
AiReadLength(NULL),
|
||||
ProcessAList(NULL),
|
||||
m_hAudioThread(NULL),
|
||||
AiUpdate(NULL),
|
||||
AiDacrateChanged(NULL)
|
||||
AiLenChanged(NULL),
|
||||
AiReadLength(NULL),
|
||||
ProcessAList(NULL),
|
||||
m_hAudioThread(NULL),
|
||||
AiUpdate(NULL),
|
||||
AiDacrateChanged(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -36,7 +38,7 @@ CAudioPlugin::~CAudioPlugin()
|
|||
bool CAudioPlugin::LoadFunctions(void)
|
||||
{
|
||||
// Find entries for functions in DLL
|
||||
void(__cdecl *InitiateAudio) (void);
|
||||
void(CALL *InitiateAudio)(void);
|
||||
LoadFunction(InitiateAudio);
|
||||
LoadFunction(AiDacrateChanged);
|
||||
LoadFunction(AiLenChanged);
|
||||
|
@ -85,11 +87,11 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window)
|
|||
uint32_t * AI__DACRATE_REG;
|
||||
uint32_t * AI__BITRATE_REG;
|
||||
|
||||
void(__cdecl *CheckInterrupts)(void);
|
||||
void(CALL *CheckInterrupts)(void);
|
||||
};
|
||||
|
||||
//Get Function from DLL
|
||||
int32_t(__cdecl *InitiateAudio)(AUDIO_INFO Audio_Info);
|
||||
int32_t(CALL *InitiateAudio)(AUDIO_INFO Audio_Info);
|
||||
LoadFunction(InitiateAudio);
|
||||
if (InitiateAudio == NULL) { return false; }
|
||||
|
||||
|
@ -137,10 +139,9 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window)
|
|||
|
||||
m_Initialized = InitiateAudio(Info) != 0;
|
||||
|
||||
//jabo had a bug so I call CreateThread so his dllmain gets called again
|
||||
DWORD ThreadID;
|
||||
HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
|
||||
CloseHandle(hthread);
|
||||
#ifdef _WIN32
|
||||
//jabo had a bug so I call CreateThread so his dllmain gets called again
|
||||
pjutil::DynLibCallDllMain();
|
||||
|
||||
if (System != NULL)
|
||||
{
|
||||
|
@ -151,6 +152,7 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window)
|
|||
WriteTrace(TraceAudioPlugin, TraceDebug, "Terminate Audio Thread");
|
||||
TerminateThread(m_hAudioThread, 0);
|
||||
}
|
||||
DWORD ThreadID;
|
||||
m_hAudioThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)AudioThread, (LPVOID)this, 0, &ThreadID);
|
||||
}
|
||||
|
||||
|
@ -159,6 +161,7 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window)
|
|||
DacrateChanged(System->SystemType());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return m_Initialized;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,16 +13,15 @@
|
|||
#include <Project64-core/N64System/N64RomClass.h>
|
||||
#include <Project64-core/N64System/Mips/RegisterClass.h>
|
||||
#include "ControllerPlugin.h"
|
||||
#include <Windows.h>
|
||||
|
||||
CControl_Plugin::CControl_Plugin(void) :
|
||||
WM_KeyDown(NULL),
|
||||
WM_KeyUp(NULL),
|
||||
RumbleCommand(NULL),
|
||||
GetKeys(NULL),
|
||||
ReadController(NULL),
|
||||
ControllerCommand(NULL),
|
||||
m_AllocatedControllers(false)
|
||||
WM_KeyDown(NULL),
|
||||
WM_KeyUp(NULL),
|
||||
RumbleCommand(NULL),
|
||||
GetKeys(NULL),
|
||||
ReadController(NULL),
|
||||
ControllerCommand(NULL),
|
||||
m_AllocatedControllers(false)
|
||||
{
|
||||
memset(&m_PluginControllers, 0, sizeof(m_PluginControllers));
|
||||
memset(&m_Controllers, 0, sizeof(m_Controllers));
|
||||
|
@ -37,7 +36,7 @@ CControl_Plugin::~CControl_Plugin()
|
|||
bool CControl_Plugin::LoadFunctions(void)
|
||||
{
|
||||
// Find entries for functions in DLL
|
||||
void(__cdecl *InitiateControllers)(void);
|
||||
void(CALL *InitiateControllers)(void);
|
||||
LoadFunction(InitiateControllers);
|
||||
LoadFunction(ControllerCommand);
|
||||
LoadFunction(GetKeys);
|
||||
|
@ -65,60 +64,60 @@ bool CControl_Plugin::LoadFunctions(void)
|
|||
|
||||
bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window)
|
||||
{
|
||||
CONTROL_INFO ControlInfo;
|
||||
uint8_t Buffer[100];
|
||||
|
||||
for (int32_t i = 0; i < 4; i++)
|
||||
{
|
||||
m_PluginControllers[i].Present = FALSE;
|
||||
m_PluginControllers[i].RawData = FALSE;
|
||||
m_PluginControllers[i].Present = false;
|
||||
m_PluginControllers[i].RawData = false;
|
||||
m_PluginControllers[i].Plugin = PLUGIN_NONE;
|
||||
}
|
||||
|
||||
if (m_PluginInfo.Version >= 0x0101)
|
||||
{
|
||||
ControlInfo.Controls = m_PluginControllers;
|
||||
ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress());
|
||||
ControlInfo.hinst = GetModuleHandle(NULL);
|
||||
ControlInfo.hMainWindow = Window ? (HWND)Window->GetWindowHandle() : NULL;
|
||||
ControlInfo.MemoryBswaped = TRUE;
|
||||
}
|
||||
|
||||
// Test Plugin version
|
||||
if (m_PluginInfo.Version == 0x0100)
|
||||
{
|
||||
//Get Function from DLL
|
||||
void(__cdecl *InitiateControllers_1_0)(HWND hMainWindow, CONTROL Controls[4]);
|
||||
InitiateControllers_1_0 = (void(__cdecl *)(HWND, CONTROL *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers");
|
||||
void(CALL *InitiateControllers_1_0)(void * hMainWindow, CONTROL Controls[4]);
|
||||
_LoadFunction("InitiateControllers",InitiateControllers_1_0);
|
||||
if (InitiateControllers_1_0 == NULL) { return false; }
|
||||
InitiateControllers_1_0((HWND)Window->GetWindowHandle(), m_PluginControllers);
|
||||
InitiateControllers_1_0(Window->GetWindowHandle(), m_PluginControllers);
|
||||
m_Initialized = true;
|
||||
}
|
||||
else if (m_PluginInfo.Version == 0x0101)
|
||||
else if (m_PluginInfo.Version >= 0x0101)
|
||||
{
|
||||
//Get Function from DLL
|
||||
void(__cdecl *InitiateControllers_1_1)(CONTROL_INFO ControlInfo);
|
||||
InitiateControllers_1_1 = (void(__cdecl *)(CONTROL_INFO))GetProcAddress((HMODULE)m_hDll, "InitiateControllers");
|
||||
if (InitiateControllers_1_1 == NULL) { return false; }
|
||||
CONTROL_INFO ControlInfo;
|
||||
ControlInfo.Controls = m_PluginControllers;
|
||||
ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress());
|
||||
ControlInfo.hinst = Window ? Window->GetModuleInstance() : NULL;
|
||||
ControlInfo.hMainWindow = Window ? Window->GetWindowHandle() : NULL;
|
||||
ControlInfo.MemoryBswaped = true;
|
||||
|
||||
InitiateControllers_1_1(ControlInfo);
|
||||
m_Initialized = true;
|
||||
}
|
||||
else if (m_PluginInfo.Version >= 0x0102)
|
||||
{
|
||||
//Get Function from DLL
|
||||
void(__cdecl *InitiateControllers_1_2)(CONTROL_INFO * ControlInfo);
|
||||
InitiateControllers_1_2 = (void(__cdecl *)(CONTROL_INFO *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers");
|
||||
if (InitiateControllers_1_2 == NULL) { return false; }
|
||||
if (m_PluginInfo.Version == 0x0101)
|
||||
{
|
||||
//Get Function from DLL
|
||||
void(CALL *InitiateControllers_1_1)(CONTROL_INFO ControlInfo);
|
||||
_LoadFunction("InitiateControllers",InitiateControllers_1_1);
|
||||
if (InitiateControllers_1_1 == NULL) { return false; }
|
||||
|
||||
InitiateControllers_1_2(&ControlInfo);
|
||||
m_Initialized = true;
|
||||
InitiateControllers_1_1(ControlInfo);
|
||||
m_Initialized = true;
|
||||
}
|
||||
else if (m_PluginInfo.Version >= 0x0102)
|
||||
{
|
||||
//Get Function from DLL
|
||||
void(CALL *InitiateControllers_1_2)(CONTROL_INFO * ControlInfo);
|
||||
_LoadFunction("InitiateControllers",InitiateControllers_1_2);
|
||||
if (InitiateControllers_1_2 == NULL) { return false; }
|
||||
|
||||
InitiateControllers_1_2(&ControlInfo);
|
||||
m_Initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
//jabo had a bug so I call CreateThread so his dllmain gets called again
|
||||
DWORD ThreadID;
|
||||
HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
|
||||
CloseHandle(hthread);
|
||||
#ifdef _WIN32
|
||||
//jabo had a bug so I call CreateThread so his dllmain gets called again
|
||||
pjutil::DynLibCallDllMain();
|
||||
#endif
|
||||
|
||||
return m_Initialized;
|
||||
}
|
||||
|
@ -178,7 +177,7 @@ void CControl_Plugin::SetControl(CControl_Plugin const * const Plugin)
|
|||
}
|
||||
|
||||
CCONTROL::CCONTROL(int32_t &Present, int32_t &RawData, int32_t &PlugType) :
|
||||
m_Present(Present), m_RawData(RawData), m_PlugType(PlugType)
|
||||
m_Present(Present), m_RawData(RawData), m_PlugType(PlugType)
|
||||
{
|
||||
m_Buttons.Value = 0;
|
||||
}
|
||||
|
|
|
@ -14,25 +14,24 @@
|
|||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Mips/RegisterClass.h>
|
||||
#include "GFXPlugin.h"
|
||||
#include <Windows.h>
|
||||
|
||||
CGfxPlugin::CGfxPlugin() :
|
||||
CaptureScreen(NULL),
|
||||
ChangeWindow(NULL),
|
||||
DrawScreen(NULL),
|
||||
DrawStatus(NULL),
|
||||
MoveScreen(NULL),
|
||||
ProcessDList(NULL),
|
||||
ProcessRDPList(NULL),
|
||||
ShowCFB(NULL),
|
||||
UpdateScreen(NULL),
|
||||
ViStatusChanged(NULL),
|
||||
ViWidthChanged(NULL),
|
||||
SoftReset(NULL),
|
||||
GetRomBrowserMenu(NULL),
|
||||
OnRomBrowserMenuItem(NULL),
|
||||
GetDebugInfo(NULL),
|
||||
InitiateDebugger(NULL)
|
||||
CaptureScreen(NULL),
|
||||
ChangeWindow(NULL),
|
||||
DrawScreen(NULL),
|
||||
DrawStatus(NULL),
|
||||
MoveScreen(NULL),
|
||||
ProcessDList(NULL),
|
||||
ProcessRDPList(NULL),
|
||||
ShowCFB(NULL),
|
||||
UpdateScreen(NULL),
|
||||
ViStatusChanged(NULL),
|
||||
ViWidthChanged(NULL),
|
||||
SoftReset(NULL),
|
||||
GetRomBrowserMenu(NULL),
|
||||
OnRomBrowserMenuItem(NULL),
|
||||
GetDebugInfo(NULL),
|
||||
InitiateDebugger(NULL)
|
||||
{
|
||||
memset(&m_GFXDebug, 0, sizeof(m_GFXDebug));
|
||||
}
|
||||
|
@ -46,7 +45,7 @@ CGfxPlugin::~CGfxPlugin()
|
|||
bool CGfxPlugin::LoadFunctions(void)
|
||||
{
|
||||
// Find entries for functions in DLL
|
||||
int32_t(__cdecl *InitiateGFX) (void * Gfx_Info);
|
||||
int32_t(CALL *InitiateGFX) (void * Gfx_Info);
|
||||
LoadFunction(InitiateGFX);
|
||||
LoadFunction(ChangeWindow);
|
||||
LoadFunction(DrawScreen);
|
||||
|
@ -94,8 +93,9 @@ bool CGfxPlugin::LoadFunctions(void)
|
|||
}
|
||||
|
||||
if (GetDebugInfo != NULL)
|
||||
{
|
||||
GetDebugInfo(&m_GFXDebug);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -108,8 +108,8 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window)
|
|||
|
||||
typedef struct
|
||||
{
|
||||
HWND hWnd; /* Render window */
|
||||
HWND hStatusBar; /* if render window does not have a status bar then this is NULL */
|
||||
void * hWnd; /* Render window */
|
||||
void * hStatusBar; /* if render window does not have a status bar then this is NULL */
|
||||
|
||||
int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre
|
||||
// bswap on a dword (32 bits) boundry
|
||||
|
@ -148,19 +148,19 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window)
|
|||
uint32_t * VI__X_SCALE_REG;
|
||||
uint32_t * VI__Y_SCALE_REG;
|
||||
|
||||
void(__cdecl *CheckInterrupts)(void);
|
||||
void(CALL *CheckInterrupts)(void);
|
||||
} GFX_INFO;
|
||||
|
||||
//Get Function from DLL
|
||||
int32_t(__cdecl *InitiateGFX)(GFX_INFO Gfx_Info);
|
||||
InitiateGFX = (int32_t(__cdecl *)(GFX_INFO))GetProcAddress((HMODULE)m_hDll, "InitiateGFX");
|
||||
int32_t(CALL *InitiateGFX)(GFX_INFO Gfx_Info);
|
||||
_LoadFunction("InitiateGFX",InitiateGFX);
|
||||
if (InitiateGFX == NULL) { return false; }
|
||||
|
||||
GFX_INFO Info = { 0 };
|
||||
|
||||
Info.MemoryBswaped = TRUE;
|
||||
Info.hWnd = (HWND)Window->GetWindowHandle();
|
||||
Info.hStatusBar = (HWND)Window->GetStatusBar();
|
||||
Info.MemoryBswaped = true;
|
||||
Info.hWnd = Window->GetWindowHandle();
|
||||
Info.hStatusBar = Window->GetStatusBar();
|
||||
Info.CheckInterrupts = DummyCheckInterrupts;
|
||||
|
||||
// We are initializing the plugin before any rom is loaded so we do not have any correct
|
||||
|
@ -224,20 +224,20 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window)
|
|||
|
||||
m_Initialized = InitiateGFX(Info) != 0;
|
||||
|
||||
//jabo had a bug so I call CreateThread so his dllmain gets called again
|
||||
DWORD ThreadID;
|
||||
HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
|
||||
CloseHandle(hthread);
|
||||
#ifdef _WIN32
|
||||
//jabo had a bug so I call CreateThread so his dllmain gets called again
|
||||
pjutil::DynLibCallDllMain();
|
||||
#endif
|
||||
|
||||
return m_Initialized;
|
||||
}
|
||||
|
||||
void CGfxPlugin::UnloadPluginDetails(void)
|
||||
{
|
||||
if (m_hDll != NULL)
|
||||
if (m_LibHandle != NULL)
|
||||
{
|
||||
FreeLibrary((HMODULE)m_hDll);
|
||||
m_hDll = NULL;
|
||||
pjutil::DynLibClose(m_LibHandle);
|
||||
m_LibHandle = NULL;
|
||||
}
|
||||
memset(&m_GFXDebug, 0, sizeof(m_GFXDebug));
|
||||
|
||||
|
|
|
@ -10,21 +10,20 @@
|
|||
****************************************************************************/
|
||||
#include "stdafx.h"
|
||||
#include "PluginBase.h"
|
||||
#include <Windows.h>
|
||||
|
||||
CPlugin::CPlugin() :
|
||||
DllAbout(NULL),
|
||||
DllConfig(NULL),
|
||||
CloseDLL(NULL),
|
||||
RomOpen(NULL),
|
||||
RomClosed(NULL),
|
||||
PluginOpened(NULL),
|
||||
SetSettingInfo(NULL),
|
||||
SetSettingInfo2(NULL),
|
||||
SetSettingInfo3(NULL),
|
||||
m_hDll(NULL),
|
||||
m_Initialized(false),
|
||||
m_RomOpen(false)
|
||||
DllAbout(NULL),
|
||||
DllConfig(NULL),
|
||||
CloseDLL(NULL),
|
||||
RomOpen(NULL),
|
||||
RomClosed(NULL),
|
||||
PluginOpened(NULL),
|
||||
SetSettingInfo(NULL),
|
||||
SetSettingInfo2(NULL),
|
||||
SetSettingInfo3(NULL),
|
||||
m_LibHandle(NULL),
|
||||
m_Initialized(false),
|
||||
m_RomOpen(false)
|
||||
{
|
||||
memset(&m_PluginInfo, 0, sizeof(m_PluginInfo));
|
||||
}
|
||||
|
@ -37,31 +36,21 @@ CPlugin::~CPlugin()
|
|||
bool CPlugin::Load(const char * FileName)
|
||||
{
|
||||
// Already loaded, so unload first.
|
||||
if (m_hDll != NULL)
|
||||
if (m_LibHandle != NULL)
|
||||
{
|
||||
UnloadPlugin();
|
||||
}
|
||||
|
||||
// Try to load the plugin DLL
|
||||
//Try to load the DLL library
|
||||
if (bHaveDebugger())
|
||||
{
|
||||
m_hDll = LoadLibrary(FileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
UINT LastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
|
||||
m_hDll = LoadLibrary(FileName);
|
||||
SetErrorMode(LastErrorMode);
|
||||
}
|
||||
|
||||
if (m_hDll == NULL)
|
||||
m_LibHandle = pjutil::DynLibOpen(FileName, bHaveDebugger());
|
||||
if (m_LibHandle == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get DLL information
|
||||
void(__cdecl *GetDllInfo) (PLUGIN_INFO * PluginInfo);
|
||||
void(CALL *GetDllInfo) (PLUGIN_INFO * PluginInfo);
|
||||
LoadFunction(GetDllInfo);
|
||||
if (GetDllInfo == NULL) { return false; }
|
||||
|
||||
|
@ -69,14 +58,14 @@ bool CPlugin::Load(const char * FileName)
|
|||
if (!ValidPluginVersion(m_PluginInfo)) { return false; }
|
||||
if (m_PluginInfo.Type != type()) { return false; }
|
||||
|
||||
CloseDLL = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "CloseDLL");
|
||||
RomOpen = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "RomOpen");
|
||||
RomClosed = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "RomClosed");
|
||||
PluginOpened = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "PluginLoaded");
|
||||
DllConfig = (void(__cdecl *)(void *)) GetProcAddress((HMODULE)m_hDll, "DllConfig");
|
||||
DllAbout = (void(__cdecl *)(void *)) GetProcAddress((HMODULE)m_hDll, "DllAbout");
|
||||
LoadFunction(CloseDLL);
|
||||
LoadFunction(RomOpen);
|
||||
LoadFunction(RomClosed);
|
||||
_LoadFunction("PluginLoaded", PluginOpened);
|
||||
LoadFunction(DllConfig);
|
||||
LoadFunction(DllAbout);
|
||||
|
||||
SetSettingInfo3 = (void(__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo3");
|
||||
LoadFunction(SetSettingInfo3);
|
||||
if (SetSettingInfo3)
|
||||
{
|
||||
PLUGIN_SETTINGS3 info;
|
||||
|
@ -84,7 +73,7 @@ bool CPlugin::Load(const char * FileName)
|
|||
SetSettingInfo3(&info);
|
||||
}
|
||||
|
||||
SetSettingInfo2 = (void(__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo2");
|
||||
LoadFunction(SetSettingInfo2);
|
||||
if (SetSettingInfo2)
|
||||
{
|
||||
PLUGIN_SETTINGS2 info;
|
||||
|
@ -92,7 +81,7 @@ bool CPlugin::Load(const char * FileName)
|
|||
SetSettingInfo2(&info);
|
||||
}
|
||||
|
||||
SetSettingInfo = (void(__cdecl *)(PLUGIN_SETTINGS *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo");
|
||||
LoadFunction(SetSettingInfo);
|
||||
if (SetSettingInfo)
|
||||
{
|
||||
PLUGIN_SETTINGS info;
|
||||
|
@ -114,7 +103,9 @@ bool CPlugin::Load(const char * FileName)
|
|||
}
|
||||
|
||||
if (RomClosed == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!LoadFunctions())
|
||||
{
|
||||
|
@ -150,7 +141,9 @@ void CPlugin::RomOpened()
|
|||
void CPlugin::RomClose()
|
||||
{
|
||||
if (!m_RomOpen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
WriteTrace(PluginTraceType(), TraceDebug, "Before Rom Close");
|
||||
RomClosed();
|
||||
|
@ -186,11 +179,11 @@ void CPlugin::UnloadPlugin()
|
|||
{
|
||||
WriteTrace(PluginTraceType(), TraceDebug, "(%s): unloading", PluginType());
|
||||
memset(&m_PluginInfo, 0, sizeof(m_PluginInfo));
|
||||
if (m_hDll != NULL)
|
||||
if (m_LibHandle != NULL)
|
||||
{
|
||||
UnloadPluginDetails();
|
||||
FreeLibrary((HMODULE)m_hDll);
|
||||
m_hDll = NULL;
|
||||
pjutil::DynLibClose(m_LibHandle);
|
||||
m_LibHandle = NULL;
|
||||
}
|
||||
|
||||
DllAbout = NULL;
|
||||
|
@ -256,5 +249,5 @@ bool CPlugin::ValidPluginVersion(PLUGIN_INFO & PluginInfo)
|
|||
if (PluginInfo.Version == 0x0102) { return true; }
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
|
@ -12,7 +12,8 @@
|
|||
|
||||
#include <Project64-core/Settings/DebugSettings.h>
|
||||
#include <Project64-core/TraceModulesProject64.h>
|
||||
#include "PluginClass.h"
|
||||
#include <Project64-core/Plugins/PluginClass.h>
|
||||
#include <Common/Util.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define CALL __cdecl
|
||||
|
@ -60,17 +61,18 @@ protected:
|
|||
void(CALL *SetSettingInfo2) (PLUGIN_SETTINGS2 *);
|
||||
void(CALL *SetSettingInfo3) (PLUGIN_SETTINGS3 *);
|
||||
|
||||
void * m_hDll;
|
||||
bool m_Initialized, m_RomOpen;
|
||||
pjutil::DynLibHandle m_LibHandle;
|
||||
bool m_Initialized, m_RomOpen;
|
||||
PLUGIN_INFO m_PluginInfo;
|
||||
|
||||
// Loads a function pointer from the currently loaded DLL
|
||||
template <typename T>
|
||||
void _LoadFunction(const char * szFunctionName, T & functionPointer) {
|
||||
functionPointer = (T)GetProcAddress((HMODULE)m_hDll, szFunctionName);
|
||||
void _LoadFunctionVoid(const char * szFunctionName, void ** functionPointer)
|
||||
{
|
||||
*functionPointer = pjutil::DynLibGetProc(m_LibHandle, szFunctionName);
|
||||
}
|
||||
|
||||
// Simple wrapper around _LoadFunction() to avoid having to specify the same two arguments
|
||||
// i.e. _LoadFunction("CloseDLL", CloseDLL);
|
||||
#define LoadFunction(functionName) _LoadFunction(#functionName, functionName)
|
||||
#define LoadFunction(functionName) _LoadFunctionVoid(#functionName, (void **)&functionName)
|
||||
#define _LoadFunction(functionName,function) _LoadFunctionVoid(functionName, (void **)&function)
|
||||
};
|
||||
|
|
|
@ -11,17 +11,17 @@
|
|||
#include "stdafx.h"
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/N64Class.h>
|
||||
#include <Project64-core/Plugins/PluginClass.h>
|
||||
#include <Common/path.h>
|
||||
#include "PluginClass.h"
|
||||
|
||||
CPlugins::CPlugins(const stdstr & PluginDir) :
|
||||
m_MainWindow(NULL),
|
||||
m_SyncWindow(NULL),
|
||||
m_PluginDir(PluginDir),
|
||||
m_Gfx(NULL),
|
||||
m_Audio(NULL),
|
||||
m_RSP(NULL),
|
||||
m_Control(NULL)
|
||||
m_MainWindow(NULL),
|
||||
m_SyncWindow(NULL),
|
||||
m_PluginDir(PluginDir),
|
||||
m_Gfx(NULL),
|
||||
m_Audio(NULL),
|
||||
m_RSP(NULL),
|
||||
m_Control(NULL)
|
||||
{
|
||||
CreatePlugins();
|
||||
g_Settings->RegisterChangeCB(Plugin_RSP_Current, this, (CSettings::SettingChangedFunc)PluginChanged);
|
||||
|
@ -288,7 +288,7 @@ bool CPlugins::Reset(CN64System * System)
|
|||
if (m_Gfx && bGfxChange)
|
||||
{
|
||||
WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Starting");
|
||||
if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; }
|
||||
if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; }
|
||||
WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Done");
|
||||
}
|
||||
if (m_Audio && bAudioChange)
|
||||
|
@ -306,7 +306,7 @@ bool CPlugins::Reset(CN64System * System)
|
|||
if (m_RSP && bRspChange)
|
||||
{
|
||||
WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Starting");
|
||||
if (!m_RSP->Initiate(this, System)) { return false; }
|
||||
if (!m_RSP->Initiate(this, System)) { return false; }
|
||||
WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Done");
|
||||
}
|
||||
WriteTrace(TracePlugins, TraceDebug, "Done");
|
||||
|
|
|
@ -90,6 +90,7 @@ __interface RenderWindow
|
|||
virtual bool ResetPluginsInUiThread(CPlugins * plugins, CN64System * System) = 0;
|
||||
virtual void * GetWindowHandle(void) const = 0;
|
||||
virtual void * GetStatusBar(void) const = 0;
|
||||
virtual void * GetModuleInstance(void) const = 0;
|
||||
};
|
||||
|
||||
class CPlugins :
|
||||
|
|
|
@ -15,16 +15,15 @@
|
|||
#include "RSPPlugin.h"
|
||||
#include "GFXPlugin.h"
|
||||
#include "AudioPlugin.h"
|
||||
#include <Windows.h>
|
||||
|
||||
void DummyFunc1(int a) { a += 1; }
|
||||
|
||||
CRSP_Plugin::CRSP_Plugin(void) :
|
||||
DoRspCycles(NULL),
|
||||
EnableDebugging(NULL),
|
||||
m_CycleCount(0),
|
||||
GetDebugInfo(NULL),
|
||||
InitiateDebugger(NULL)
|
||||
DoRspCycles(NULL),
|
||||
EnableDebugging(NULL),
|
||||
m_CycleCount(0),
|
||||
GetDebugInfo(NULL),
|
||||
InitiateDebugger(NULL)
|
||||
{
|
||||
memset(&m_RSPDebug, 0, sizeof(m_RSPDebug));
|
||||
}
|
||||
|
@ -38,7 +37,7 @@ CRSP_Plugin::~CRSP_Plugin()
|
|||
bool CRSP_Plugin::LoadFunctions(void)
|
||||
{
|
||||
// Find entries for functions in DLL
|
||||
void(__cdecl *InitiateRSP)(void);
|
||||
void(CALL *InitiateRSP)(void);
|
||||
LoadFunction(InitiateRSP);
|
||||
LoadFunction(DoRspCycles);
|
||||
_LoadFunction("GetRspDebugInfo", GetDebugInfo);
|
||||
|
@ -59,8 +58,9 @@ bool CRSP_Plugin::LoadFunctions(void)
|
|||
|
||||
// Get debug info if able
|
||||
if (GetDebugInfo != NULL)
|
||||
{
|
||||
GetDebugInfo(&m_RSPDebug);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
|
|||
|
||||
typedef struct
|
||||
{
|
||||
HINSTANCE hInst;
|
||||
void * hInst;
|
||||
int MemoryBswaped; /* If this is set to TRUE, then the memory has been pre
|
||||
bswap on a dword (32 bits) boundry */
|
||||
uint8_t * RDRAM;
|
||||
|
@ -101,21 +101,21 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
|
|||
uint32_t * DPC__PIPEBUSY_REG;
|
||||
uint32_t * DPC__TMEM_REG;
|
||||
|
||||
void(__cdecl *CheckInterrupts)(void);
|
||||
void(__cdecl *ProcessDlist)(void);
|
||||
void(__cdecl *ProcessAlist)(void);
|
||||
void(__cdecl *ProcessRdpList)(void);
|
||||
void(__cdecl *ShowCFB)(void);
|
||||
void(CALL *CheckInterrupts)(void);
|
||||
void(CALL *ProcessDlist)(void);
|
||||
void(CALL *ProcessAlist)(void);
|
||||
void(CALL *ProcessRdpList)(void);
|
||||
void(CALL *ShowCFB)(void);
|
||||
} RSP_INFO_1_1;
|
||||
|
||||
RSP_INFO_1_1 Info = { 0 };
|
||||
|
||||
Info.hInst = GetModuleHandle(NULL);
|
||||
Info.hInst = Plugins->MainWindow()->GetModuleInstance();
|
||||
Info.CheckInterrupts = DummyCheckInterrupts;
|
||||
Info.MemoryBswaped = (System == NULL); // only true when the system's not yet loaded
|
||||
|
||||
//Get Function from DLL
|
||||
void(__cdecl *InitiateRSP) (RSP_INFO_1_1 Audio_Info, uint32_t * Cycles);
|
||||
void(CALL *InitiateRSP) (RSP_INFO_1_1 Audio_Info, uint32_t * Cycles);
|
||||
LoadFunction(InitiateRSP);
|
||||
if (InitiateRSP == NULL) { return false; }
|
||||
|
||||
|
@ -193,10 +193,10 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
|
|||
InitiateRSP(Info, &m_CycleCount);
|
||||
m_Initialized = true;
|
||||
|
||||
//jabo had a bug so I call CreateThread so his dllmain gets called again
|
||||
DWORD ThreadID;
|
||||
HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
|
||||
CloseHandle(hthread);
|
||||
#ifdef _WIN32
|
||||
//jabo had a bug so I call CreateThread so his dllmain gets called again
|
||||
pjutil::DynLibCallDllMain();
|
||||
#endif
|
||||
return m_Initialized;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
#include "../stdafx.h"
|
|
@ -24,14 +24,14 @@ LRESULT CALLBACK MainGui_Proc(HWND WndHandle, DWORD uMsg, DWORD wParam, DWORD lP
|
|||
extern BOOL set_about_field(HWND hDlg, int nIDDlgItem, const wchar_t * config_string, const wchar_t * language_string);
|
||||
|
||||
CMainGui::CMainGui(bool bMainWindow, const char * WindowTitle) :
|
||||
CRomBrowser(m_hMainWindow, m_hStatusWnd),
|
||||
m_ThreadId(GetCurrentThreadId()),
|
||||
m_bMainWindow(bMainWindow),
|
||||
m_Created(false),
|
||||
m_AttachingMenu(false),
|
||||
m_MakingVisible(false),
|
||||
m_ResetPlugins(false),
|
||||
m_ResetInfo(NULL)
|
||||
CRomBrowser(m_hMainWindow, m_hStatusWnd),
|
||||
m_ThreadId(GetCurrentThreadId()),
|
||||
m_bMainWindow(bMainWindow),
|
||||
m_Created(false),
|
||||
m_AttachingMenu(false),
|
||||
m_MakingVisible(false),
|
||||
m_ResetPlugins(false),
|
||||
m_ResetInfo(NULL)
|
||||
{
|
||||
m_Menu = NULL;
|
||||
|
||||
|
@ -273,6 +273,11 @@ void CMainGui::ChangeWinSize(long width, long height)
|
|||
MoveWindow(m_hMainWindow, wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top, rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE);
|
||||
}
|
||||
|
||||
void * CMainGui::GetModuleInstance(void) const
|
||||
{
|
||||
return GetModuleHandle(NULL);
|
||||
}
|
||||
|
||||
void CMainGui::AboutBox(void)
|
||||
{
|
||||
DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_About), m_hMainWindow, (DLGPROC)AboutBoxProc, (LPARAM)this);
|
||||
|
|
|
@ -89,6 +89,7 @@ public:
|
|||
//Get Window Handle
|
||||
void * GetWindowHandle(void) const { return m_hMainWindow; }
|
||||
void * GetStatusBar(void) const { return m_hStatusWnd; }
|
||||
void * GetModuleInstance(void) const;
|
||||
|
||||
private:
|
||||
CMainGui(void); // Disable default constructor
|
||||
|
|
Loading…
Reference in New Issue