diff --git a/example_plugin/main.cpp b/example_plugin/main.cpp new file mode 100644 index 00000000..ff37c057 --- /dev/null +++ b/example_plugin/main.cpp @@ -0,0 +1,13 @@ +#include "pdk.h" + +#define EXPORT extern "C" __declspec( dllexport ) + +EXPORT void GBE_Load() +{ + +} + +EXPORT void GBE_UnLoad() +{ + +} diff --git a/generate_win_premake.bat b/generate_win_premake.bat new file mode 100644 index 00000000..2e637eef --- /dev/null +++ b/generate_win_premake.bat @@ -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 \ No newline at end of file diff --git a/pdk/pdk.cpp b/pdk/pdk.cpp index 32f000f5..1819579f 100644 --- a/pdk/pdk.cpp +++ b/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"); +} -/// -/// Registering from the Maker -/// -/// -/// -/// 0 for success, 1 if failed 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; } -/// -/// Unregistering from the Maker -/// -/// -/// 0 for success, 1 if failed 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) { diff --git a/pdk/pdk.h b/pdk/pdk.h index 983316ce..5c3c408a 100644 --- a/pdk/pdk.h +++ b/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 interfaceMap; + + + static void LoadPlugin(HMODULE handle); + static void UnloLoadPlugin(HMODULE handle); public: + /// + /// Registering from the Maker + /// + /// + /// + /// 0 for success, 1 if failed static int RegisterInterface(InterfaceMaker interfaceMakePtr, const char* interfaceVersion); + + /// + /// Unregistering from the Maker + /// + /// + /// 0 for success, 1 if failed static int UnRegisterInterface(InterfaceMaker interfaceMakePtr); + + /// + /// Make Registered interface + /// + /// + /// + /// + /// nullptr if not found, a vaild pointer to the interface static void* MakeInterface(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* interfaceVersion); + + /// + /// Get PDK Version + /// + /// + static int GetPDKVersion(); }; diff --git a/premake5.lua b/premake5.lua index fe54bddc..a7f36db6 100644 --- a/premake5.lua +++ b/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