Initial commit
This commit is contained in:
commit
576b217f30
9 changed files with 735 additions and 0 deletions
84
launcher/main.cpp
Executable file
84
launcher/main.cpp
Executable file
|
@ -0,0 +1,84 @@
|
|||
#include "main.h"
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#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 <pubggame://IP:port>\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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue