Some terribleness to make updating work on windows
Squirrel doesn't handle the executable changing name, as hopefully explained in comments
This commit is contained in:
51
build/rebrand_stub/rebrand_stub.c
Normal file
51
build/rebrand_stub/rebrand_stub.c
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <tchar.h>
|
||||
|
||||
/*
|
||||
* This just runs 'Element (Riot).exe' with the same args as
|
||||
* this process was invoked with. This gets around the fact that
|
||||
* squirrel always tries to run an executable with the same name,
|
||||
* so fails to restart if the app's name has changed.
|
||||
*/
|
||||
void _tmain( int argc, TCHAR *argv[] )
|
||||
{
|
||||
LPSTR myCmdLine = GetCommandLineA();
|
||||
char cmdLine[32767];
|
||||
|
||||
LPSTR cmdLinePos = cmdLine;
|
||||
LPSTR toRun = "\"Element (Riot).exe\" ";
|
||||
strncpy(cmdLinePos, toRun, strlen(toRun));
|
||||
cmdLinePos += strlen(toRun);
|
||||
|
||||
if (myCmdLine[0] == '"') ++myCmdLine;
|
||||
myCmdLine += strlen(argv[0]);
|
||||
if (myCmdLine[0] == '"') ++myCmdLine;
|
||||
if (myCmdLine[0] == ' ') ++myCmdLine;
|
||||
|
||||
strncpy(cmdLinePos, myCmdLine, (cmdLine + 32767) - cmdLinePos);
|
||||
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
ZeroMemory(&pi, sizeof(pi));
|
||||
|
||||
if (!CreateProcess(NULL,
|
||||
cmdLine, // Command line
|
||||
NULL, // Process handle not inheritable
|
||||
NULL, // Thread handle not inheritable
|
||||
FALSE, // Set handle inheritance to FALSE
|
||||
0, // No creation flags
|
||||
NULL, // Use parent's environment block
|
||||
NULL, // Use parent's starting directory
|
||||
&si, // Pointer to STARTUPINFO structure
|
||||
&pi ) // Pointer to PROCESS_INFORMATION structure
|
||||
)
|
||||
{
|
||||
printf("CreateProcess failed (%d).\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
}
|
||||
BIN
build/rebrand_stub/rebrand_stub.exe
Normal file
BIN
build/rebrand_stub/rebrand_stub.exe
Normal file
Binary file not shown.
Reference in New Issue
Block a user