mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2025-06-07 01:35:55 +02:00
add simple example plugin
This commit is contained in:
parent
7a5bae58ec
commit
af46e8c0e8
5 changed files with 104 additions and 12 deletions
13
example_plugin/main.cpp
Normal file
13
example_plugin/main.cpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
#include "pdk.h"
|
||||
|
||||
#define EXPORT extern "C" __declspec( dllexport )
|
||||
|
||||
EXPORT void GBE_Load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
EXPORT void GBE_UnLoad()
|
||||
{
|
||||
|
||||
}
|
2
generate_win_premake.bat
Normal file
2
generate_win_premake.bat
Normal file
|
@ -0,0 +1,2 @@
|
|||
set "CMAKE_GENERATOR=Visual Studio 17 2022"
|
||||
call "third-party\common\win\premake\premake5.exe" --file="premake5.lua" --genproto --dosstub --winrsrc --winsign --os=windows vs2022
|
32
pdk/pdk.cpp
32
pdk/pdk.cpp
|
@ -1,11 +1,22 @@
|
|||
#include "pdk.h"
|
||||
#include "dll/client_known_interfaces.h"
|
||||
|
||||
typedef void (*__cdecl PluginCall)();
|
||||
|
||||
void PDK::LoadPlugin(HMODULE handle)
|
||||
{
|
||||
PluginCall load = (PluginCall)GetProcAddress(handle, "GBE_Load");
|
||||
load();
|
||||
PRINT_DEBUG("Loaded crack file");
|
||||
}
|
||||
|
||||
void PDK::UnloLoadPlugin(HMODULE handle)
|
||||
{
|
||||
PluginCall load = (PluginCall)GetProcAddress(handle, "GBE_UnLoad");
|
||||
load();
|
||||
PRINT_DEBUG("Loaded crack file");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registering from the Maker
|
||||
/// </summary>
|
||||
/// <param name="interfaceMakePtr"></param>
|
||||
/// <param name="interfaceVersion"></param>
|
||||
/// <returns>0 for success, 1 if failed</returns>
|
||||
int PDK::RegisterInterface(InterfaceMaker interfaceMakePtr, const char* interfaceVersion)
|
||||
{
|
||||
if (interfaceMakePtr == NULL)
|
||||
|
@ -18,11 +29,6 @@ int PDK::RegisterInterface(InterfaceMaker interfaceMakePtr, const char* interfac
|
|||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregistering from the Maker
|
||||
/// </summary>
|
||||
/// <param name="interfaceMakePtr"></param>
|
||||
/// <returns>0 for success, 1 if failed</returns>
|
||||
int PDK::UnRegisterInterface(InterfaceMaker interfaceMakePtr)
|
||||
{
|
||||
if (interfaceMakePtr == NULL)
|
||||
|
@ -45,6 +51,10 @@ void* PDK::MakeInterface(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const cha
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
int PDK::GetPDKVersion()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void* TestCreate(HSteamUser hSteamUser, HSteamPipe hSteamPipe)
|
||||
{
|
||||
|
|
32
pdk/pdk.h
32
pdk/pdk.h
|
@ -2,18 +2,48 @@
|
|||
#define PDK_INCLUDE_H
|
||||
|
||||
#include "dll/base.h"
|
||||
#include "dll/client_known_interfaces.h"
|
||||
|
||||
typedef void* (__cdecl* InterfaceMaker)(HSteamUser hSteamUser, HSteamPipe hSteamPipe);
|
||||
|
||||
|
||||
class PDK
|
||||
{
|
||||
static inline std::map<void* /* interfaceMaker */, const char* /* interfaceVersion */> interfaceMap;
|
||||
|
||||
|
||||
static void LoadPlugin(HMODULE handle);
|
||||
static void UnloLoadPlugin(HMODULE handle);
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Registering from the Maker
|
||||
/// </summary>
|
||||
/// <param name="interfaceMakePtr"></param>
|
||||
/// <param name="interfaceVersion"></param>
|
||||
/// <returns>0 for success, 1 if failed</returns>
|
||||
static int RegisterInterface(InterfaceMaker interfaceMakePtr, const char* interfaceVersion);
|
||||
|
||||
/// <summary>
|
||||
/// Unregistering from the Maker
|
||||
/// </summary>
|
||||
/// <param name="interfaceMakePtr"></param>
|
||||
/// <returns>0 for success, 1 if failed</returns>
|
||||
static int UnRegisterInterface(InterfaceMaker interfaceMakePtr);
|
||||
|
||||
/// <summary>
|
||||
/// Make Registered interface
|
||||
/// </summary>
|
||||
/// <param name="hSteamUser"></param>
|
||||
/// <param name="hSteamPipe"></param>
|
||||
/// <param name="interfaceVersion"></param>
|
||||
/// <returns>nullptr if not found, a vaild pointer to the interface</returns>
|
||||
static void* MakeInterface(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* interfaceVersion);
|
||||
|
||||
/// <summary>
|
||||
/// Get PDK Version
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
static int GetPDKVersion();
|
||||
};
|
||||
|
||||
|
||||
|
|
37
premake5.lua
37
premake5.lua
|
@ -1577,4 +1577,41 @@ project "test_crash_printer_sa_sigaction"
|
|||
end
|
||||
-- End LINUX ONLY TARGETS
|
||||
|
||||
-- Project example_plugin
|
||||
project "example_plugin"
|
||||
kind "SharedLib"
|
||||
location "%{wks.location}/%{prj.name}"
|
||||
targetdir("build/" .. os_iden .. "/%{_ACTION}/%{cfg.buildcfg}/example_plugin")
|
||||
targetname "example_plugin_%{cfg.platform}"
|
||||
|
||||
-- include dir
|
||||
---------
|
||||
-- common include dir
|
||||
-- x32 include dir
|
||||
filter { "platforms:x32", }
|
||||
includedirs {
|
||||
x32_deps_include,
|
||||
}
|
||||
|
||||
-- x64 include dir
|
||||
filter { "platforms:x64", }
|
||||
includedirs {
|
||||
x64_deps_include,
|
||||
}
|
||||
|
||||
|
||||
-- common source & header files
|
||||
---------
|
||||
filter {} -- reset the filter and remove all active keywords
|
||||
files { -- added to all filters, later defines will be appended
|
||||
-- dll/
|
||||
--"dll/dll/*.h",
|
||||
-- pdk
|
||||
"pdk/*.h",
|
||||
'example_plugin/**'
|
||||
}
|
||||
|
||||
|
||||
-- End example_plugin
|
||||
|
||||
-- End Workspace
|
||||
|
|
Loading…
Add table
Reference in a new issue