mirror of
https://github.com/moonlight-stream/Internet-Hosting-Tool.git
synced 2025-07-03 00:06:11 +00:00
Don't redirect stdout for standalone exe invocation
This commit is contained in:
parent
ac850e79d8
commit
53246bd4c5
@ -805,13 +805,15 @@ void NETIOAPI_API_ IpInterfaceChangeNotificationCallback(PVOID context, PMIB_IPI
|
|||||||
SetEvent((HANDLE)context);
|
SetEvent((HANDLE)context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetLogFile()
|
void ResetLogFile(bool standaloneExe)
|
||||||
{
|
{
|
||||||
char oldLogFilePath[MAX_PATH + 1];
|
|
||||||
char currentLogFilePath[MAX_PATH + 1];
|
|
||||||
char timeString[MAX_PATH + 1] = {};
|
char timeString[MAX_PATH + 1] = {};
|
||||||
SYSTEMTIME time;
|
SYSTEMTIME time;
|
||||||
|
|
||||||
|
if (!standaloneExe) {
|
||||||
|
char oldLogFilePath[MAX_PATH + 1];
|
||||||
|
char currentLogFilePath[MAX_PATH + 1];
|
||||||
|
|
||||||
ExpandEnvironmentStringsA("%ProgramData%\\MISS\\miss-old.log", oldLogFilePath, sizeof(oldLogFilePath));
|
ExpandEnvironmentStringsA("%ProgramData%\\MISS\\miss-old.log", oldLogFilePath, sizeof(oldLogFilePath));
|
||||||
ExpandEnvironmentStringsA("%ProgramData%\\MISS\\miss-current.log", currentLogFilePath, sizeof(currentLogFilePath));
|
ExpandEnvironmentStringsA("%ProgramData%\\MISS\\miss-current.log", currentLogFilePath, sizeof(currentLogFilePath));
|
||||||
|
|
||||||
@ -824,6 +826,7 @@ void ResetLogFile()
|
|||||||
|
|
||||||
// Redirect stdout to this new file
|
// Redirect stdout to this new file
|
||||||
freopen(currentLogFilePath, "w", stdout);
|
freopen(currentLogFilePath, "w", stdout);
|
||||||
|
}
|
||||||
|
|
||||||
// Print a log header
|
// Print a log header
|
||||||
printf("Moonlight Internet Streaming Service v" VER_VERSION_STR NL);
|
printf("Moonlight Internet Streaming Service v" VER_VERSION_STR NL);
|
||||||
@ -860,13 +863,13 @@ DWORD WINAPI GameStreamStateChangeThread(PVOID Context)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Run()
|
int Run(bool standaloneExe)
|
||||||
{
|
{
|
||||||
HANDLE ifaceChangeEvent = CreateEvent(nullptr, true, false, nullptr);
|
HANDLE ifaceChangeEvent = CreateEvent(nullptr, true, false, nullptr);
|
||||||
HANDLE gsChangeEvent = CreateEvent(nullptr, true, false, nullptr);
|
HANDLE gsChangeEvent = CreateEvent(nullptr, true, false, nullptr);
|
||||||
HANDLE events[2] = { ifaceChangeEvent, gsChangeEvent };
|
HANDLE events[2] = { ifaceChangeEvent, gsChangeEvent };
|
||||||
|
|
||||||
ResetLogFile();
|
ResetLogFile(standaloneExe);
|
||||||
|
|
||||||
// Bump the process priority class to above normal. The UDP relay threads will
|
// Bump the process priority class to above normal. The UDP relay threads will
|
||||||
// further raise their own thread priorities to avoid preemption by other activity.
|
// further raise their own thread priorities to avoid preemption by other activity.
|
||||||
@ -899,7 +902,7 @@ int Run()
|
|||||||
ULONGLONG beforeSleepTime = GetTickCount64();
|
ULONGLONG beforeSleepTime = GetTickCount64();
|
||||||
DWORD ret = WaitForMultipleObjects(ARRAYSIZE(events), events, false, POLLING_DELAY_SEC * 1000);
|
DWORD ret = WaitForMultipleObjects(ARRAYSIZE(events), events, false, POLLING_DELAY_SEC * 1000);
|
||||||
if (ret == WAIT_OBJECT_0) {
|
if (ret == WAIT_OBJECT_0) {
|
||||||
ResetLogFile();
|
ResetLogFile(standaloneExe);
|
||||||
|
|
||||||
printf("Woke up for interface change notification after %lld seconds" NL,
|
printf("Woke up for interface change notification after %lld seconds" NL,
|
||||||
(GetTickCount64() - beforeSleepTime) / 1000);
|
(GetTickCount64() - beforeSleepTime) / 1000);
|
||||||
@ -908,13 +911,13 @@ int Run()
|
|||||||
Sleep(10000);
|
Sleep(10000);
|
||||||
}
|
}
|
||||||
else if (ret == WAIT_OBJECT_0 + 1) {
|
else if (ret == WAIT_OBJECT_0 + 1) {
|
||||||
ResetLogFile();
|
ResetLogFile(standaloneExe);
|
||||||
|
|
||||||
printf("Woke up for GameStream state change notification after %lld seconds" NL,
|
printf("Woke up for GameStream state change notification after %lld seconds" NL,
|
||||||
(GetTickCount64() - beforeSleepTime) / 1000);
|
(GetTickCount64() - beforeSleepTime) / 1000);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ResetLogFile();
|
ResetLogFile(standaloneExe);
|
||||||
|
|
||||||
printf("Woke up for periodic refresh" NL);
|
printf("Woke up for periodic refresh" NL);
|
||||||
}
|
}
|
||||||
@ -975,7 +978,7 @@ ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv)
|
|||||||
SetServiceStatus(ServiceStatusHandle, &ServiceStatus);
|
SetServiceStatus(ServiceStatusHandle, &ServiceStatus);
|
||||||
|
|
||||||
// Start the service
|
// Start the service
|
||||||
err = Run();
|
err = Run(false);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
|
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
|
||||||
ServiceStatus.dwWin32ExitCode = err;
|
ServiceStatus.dwWin32ExitCode = err;
|
||||||
@ -998,7 +1001,7 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 2 && !strcmp(argv[1], "exe")) {
|
if (argc == 2 && !strcmp(argv[1], "exe")) {
|
||||||
Run();
|
Run(true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user