diff options
author | Emma Miler <27428383+emma-miler@users.noreply.github.com> | 2022-03-04 00:16:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-03 23:16:01 +0000 |
commit | 13dcc7d9307b160131ed80832efda99001aa6c6d (patch) | |
tree | ff7e021c2927f7d3e0ee0bb84642c6ee1c9b24ab /LauncherInjector/main.cpp | |
parent | 62e137b32ad7c601b2db37e69b9f435a7dbc730d (diff) | |
download | NorthstarLauncher-13dcc7d9307b160131ed80832efda99001aa6c6d.tar.gz NorthstarLauncher-13dcc7d9307b160131ed80832efda99001aa6c6d.zip |
Add launcher code for plugin support (#93)
* rpc
* RPC
* Undoing broken shit
* temp
* Revert "temp"
This reverts commit 4875b5aca2b0d6b03183d220120c03df28759a95.
* Include a whole bunch of new stuff
* fix id
* Added manifest and added some verification
* Fixed my oopsies
* Safety commit
* Moved over to new plugin abi
* Small docs changes and made plugin loading use ABI_VERSION
* Moving discord rpc plugin stuff to a separate repo
* Add some comments to `plugins.cpp`
* Moved internal structs from `plugin_abi.h` to `plugins.cpp`
* Add CLA `-noplugins`
* Code formatting changes so clang-format doesn't scream at me
* i hate clang-format
* why does this fail to build now wtf
* Update plugins.cpp
* Merged and updated to new convar system
* Implemented changes requested in review
* Removed a few more of those nasty comments
* Removed extra build configs
Co-authored-by: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
Diffstat (limited to 'LauncherInjector/main.cpp')
-rw-r--r-- | LauncherInjector/main.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/LauncherInjector/main.cpp b/LauncherInjector/main.cpp index f262730d..02f82342 100644 --- a/LauncherInjector/main.cpp +++ b/LauncherInjector/main.cpp @@ -5,6 +5,7 @@ #include <sstream> #include <fstream> #include <Shlwapi.h> +#include <iostream> namespace fs = std::filesystem; @@ -21,6 +22,8 @@ HMODULE hTier0Module; wchar_t exePath[4096]; wchar_t buffer[8192]; +bool noLoadPlugins = false; + DWORD GetProcessByName(std::wstring processName) { HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); @@ -222,8 +225,21 @@ bool LoadNorthstar() return false; } } - ((bool (*)())Hook_Init)(); + + FARPROC LoadPlugins = nullptr; + if (!noLoadPlugins) + { + LoadPlugins = GetProcAddress(hHookModule, "LoadPlugins"); + if (!hHookModule || LoadPlugins == nullptr) + { + printf("Failed to get function pointer to LoadPlugins of Northstar.dll\n"); + LibraryLoadError(GetLastError(), L"Northstar.dll", buffer); + return false; + } + ((bool (*)())LoadPlugins)(); + } + return true; } @@ -242,6 +258,7 @@ HMODULE LoadDediStub(const char* name) int main(int argc, char* argv[]) { + if (!GetExePathWide(exePath, sizeof(exePath))) { MessageBoxA( @@ -261,9 +278,13 @@ int main(int argc, char* argv[]) dedicated = true; else if (!strcmp(argv[i], "-nostubs")) nostubs = true; + else if (!strcmp(argv[i], "-noplugins")) + noLoadPlugins = true; if (!noOriginStartup && !dedicated) + { EnsureOriginStarted(); + } if (dedicated && !nostubs) { @@ -364,6 +385,7 @@ int main(int argc, char* argv[]) 0); // auto result = ((__int64(__fastcall*)())LauncherMain)(); // auto result = ((signed __int64(__fastcall*)(__int64))LauncherMain)(0i64); + return ((int(/*__fastcall*/*)(HINSTANCE, HINSTANCE, LPSTR, int))LauncherMain)( NULL, NULL, NULL, 0); // the parameters aren't really used anyways } |