From 4b891ff24f5e87239aa09e0d01bdd9b81110c7db Mon Sep 17 00:00:00 2001 From: NukedBart Date: Mon, 24 Feb 2025 21:36:59 +0800 Subject: [PATCH] Initial code push. --- launcher/install.reg | 12 +++ launcher/launcher.vcxproj | 142 ++++++++++++++++++++++++++++++ launcher/launcher.vcxproj.filters | 30 +++++++ launcher/main.cpp | 84 ++++++++++++++++++ launcher/main.h | 5 ++ webhelper.sln | 28 ++++++ 6 files changed, 301 insertions(+) create mode 100755 launcher/install.reg create mode 100755 launcher/launcher.vcxproj create mode 100755 launcher/launcher.vcxproj.filters create mode 100755 launcher/main.cpp create mode 100755 launcher/main.h create mode 100755 webhelper.sln diff --git a/launcher/install.reg b/launcher/install.reg new file mode 100755 index 0000000..b389825 --- /dev/null +++ b/launcher/install.reg @@ -0,0 +1,12 @@ +Windows Registry Editor Version 5.00 + +[HKEY_CLASSES_ROOT\pubggame] +@="URL:OGPUBG Protocol" +"URL Protocol"="" + +[HKEY_CLASSES_ROOT\pubggame\shell] + +[HKEY_CLASSES_ROOT\pubggame\shell\open] + +[HKEY_CLASSES_ROOT\pubggame\shell\open\command] +@="\"C:\\Path\\To\\helper.exe\" \"%1\"" \ No newline at end of file diff --git a/launcher/launcher.vcxproj b/launcher/launcher.vcxproj new file mode 100755 index 0000000..aba7fd0 --- /dev/null +++ b/launcher/launcher.vcxproj @@ -0,0 +1,142 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {44618ef3-32c8-458d-a90f-91f5d130d1a2} + launcher + 10.0 + helper + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/launcher/launcher.vcxproj.filters b/launcher/launcher.vcxproj.filters new file mode 100755 index 0000000..22cbae7 --- /dev/null +++ b/launcher/launcher.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + + + 源文件 + + + + + + \ No newline at end of file diff --git a/launcher/main.cpp b/launcher/main.cpp new file mode 100755 index 0000000..9debdb8 --- /dev/null +++ b/launcher/main.cpp @@ -0,0 +1,84 @@ +#include "main.h" +#include +#include +#include + +#define MAX_ARGS 256 +#define MAX_PATH_LENGTH 1024 + +void start(const char* conn, char* args) { + char command[MAX_PATH_LENGTH]; + snprintf(command, sizeof(command), "TslGame.exe %s %s", conn, args ? args : ""); + + STARTUPINFOA startup = { sizeof(STARTUPINFOA) }; + PROCESS_INFORMATION process; + + BOOL success = CreateProcessA( + NULL, + command, + NULL, + NULL, + FALSE, + CREATE_NO_WINDOW, + NULL, + NULL, + &startup, + &process + ); + + if (success) { + CloseHandle(process.hProcess); + CloseHandle(process.hThread); + } + else { + printf("Failed to execute command: %d\n", GetLastError()); + } +} + +void parse_url(const char* url, char* conn, size_t conn_size) { + const char* prefix = "pubggame://"; + size_t prefix_len = strlen(prefix); + + if (_strnicmp(url, prefix, prefix_len) != 0) { + conn[0] = '\0'; + return; + } + + const char* params = url + prefix_len; + const char* slash = strchr(params, '/'); + + size_t len = slash ? (slash - params) : strlen(params); + + if (len >= conn_size) { + len = conn_size - 1; + } + + strncpy_s(conn, conn_size, params, len); + conn[len] = '\0'; +} + +int main(int argc, char* argv[]) { + if (argc < 2) { + printf("Usage: %s \n", argv[0]); +#ifdef _DEBUG + for (;;)Sleep(1000); +#endif // _DEBUG + return 1; + } + + char conn[MAX_PATH_LENGTH] = { 0 }; + char args[256] = "-AllowJoinAnyMatchState -NoVerifyGC -NoEAC -NoBattleEye"; + + parse_url(argv[1], conn, sizeof(conn)); + + if (strlen(conn) > 0) { + start(conn, args); + return 0; + } + + printf("Invalid URL format\n"); +#ifdef _DEBUG + for (;;)Sleep(1000); +#endif // _DEBUG + return 1; +} \ No newline at end of file diff --git a/launcher/main.h b/launcher/main.h new file mode 100755 index 0000000..a52f67c --- /dev/null +++ b/launcher/main.h @@ -0,0 +1,5 @@ +#pragma once +class main +{ +}; + diff --git a/webhelper.sln b/webhelper.sln new file mode 100755 index 0000000..fce3fb9 --- /dev/null +++ b/webhelper.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "launcher", "launcher\launcher.vcxproj", "{44618EF3-32C8-458D-A90F-91F5D130D1A2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {44618EF3-32C8-458D-A90F-91F5D130D1A2}.Debug|x64.ActiveCfg = Debug|x64 + {44618EF3-32C8-458D-A90F-91F5D130D1A2}.Debug|x64.Build.0 = Debug|x64 + {44618EF3-32C8-458D-A90F-91F5D130D1A2}.Debug|x86.ActiveCfg = Debug|Win32 + {44618EF3-32C8-458D-A90F-91F5D130D1A2}.Debug|x86.Build.0 = Debug|Win32 + {44618EF3-32C8-458D-A90F-91F5D130D1A2}.Release|x64.ActiveCfg = Release|x64 + {44618EF3-32C8-458D-A90F-91F5D130D1A2}.Release|x64.Build.0 = Release|x64 + {44618EF3-32C8-458D-A90F-91F5D130D1A2}.Release|x86.ActiveCfg = Release|Win32 + {44618EF3-32C8-458D-A90F-91F5D130D1A2}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal