Skip to content

Commit cae12bb

Browse files
authored
compile fix?
1 parent 0a6700a commit cae12bb

File tree

1 file changed

+31
-52
lines changed

1 file changed

+31
-52
lines changed

patches/Y2K38Patcher/Y2K38Patcher/Y2K38Patcher.cpp

Lines changed: 31 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,6 @@
55
#include <ctime>
66
#include <string>
77

8-
bool IsUser AnAdmin() {
9-
BOOL isAdmin = FALSE;
10-
PSID administratorsGroup = NULL;
11-
12-
SID_IDENTIFIER_AUTHORITY ntAuthority = SECURITY_NT_AUTHORITY;
13-
if (AllocateAndInitializeSid(&ntAuthority, 2,
14-
SECURITY_BUILTIN_DOMAIN_RID,
15-
DOMAIN_ALIAS_RID_ADMINS,
16-
0, 0, 0, 0, 0, 0,
17-
&administratorsGroup)) {
18-
if (!CheckTokenMembership(NULL, administratorsGroup, &isAdmin)) {
19-
isAdmin = FALSE;
20-
}
21-
FreeSid(administratorsGroup);
22-
}
23-
return isAdmin;
24-
}
25-
26-
void ShowAdminWarning() {
27-
MessageBox(NULL, TEXT("This application requires administrative rights to change the system time."), TEXT("Warning"), MB_OK | MB_ICONWARNING);
28-
}
29-
308
// Function to find the process ID of a given process name
319
DWORD GetProcessId(const TCHAR* processName) {
3210
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
@@ -54,33 +32,18 @@ DWORD GetProcessId(const TCHAR* processName) {
5432
}
5533

5634
int main() {
57-
// Check if the application is running with administrative rights
58-
if (!IsUser AnAdmin()) {
59-
ShowAdminWarning();
60-
return 1; // Exit if not running as admin
61-
}
62-
6335
// Get the current system time
6436
SYSTEMTIME originalSysTime;
6537
GetLocalTime(&originalSysTime);
6638

6739
// Emulate the year 2022
6840
SYSTEMTIME sysTime;
41+
GetLocalTime(&sysTime);
6942
sysTime.wYear = 2022;
70-
sysTime.wMonth = 1; // January
71-
sysTime.wDay = 1; // 1st
72-
sysTime.wHour = 0; // 00:00:00
73-
sysTime.wMinute = 0;
74-
sysTime.wSecond = 0;
75-
sysTime.wMilliseconds = 0;
76-
77-
// Set the system time to the specified date
78-
if (!SetLocalTime(&sysTime)) {
79-
std::cerr << "Failed to set system time. Error: " << GetLastError() << std::endl;
80-
return 1;
81-
}
43+
SetSystemTime(&sysTime);
8244

83-
const TCHAR* exeName = TEXT("Loader7.exe");
45+
const TCHAR* loaderExeName = TEXT("Loader7.exe");
46+
const TCHAR* devExeName = TEXT("Dev7VM.EXE");
8447

8548
// Get the directory path of the current executable
8649
TCHAR exePath[MAX_PATH];
@@ -89,32 +52,48 @@ int main() {
8952
if (lastBackslash != NULL)
9053
*lastBackslash = '\0'; // Null-terminate at the last backslash
9154

92-
// Construct full path to setup.exe
93-
TCHAR setupExePath[MAX_PATH];
94-
_stprintf_s(setupExePath, MAX_PATH, TEXT("%s\\%s"), exePath, exeName);
55+
// Construct full path to Loader7.exe
56+
TCHAR loaderExePath[MAX_PATH];
57+
_stprintf_s(loaderExePath, MAX_PATH, TEXT("%s\\%s"), exePath, loaderExeName);
9558

96-
// Execute the setup.exe process
59+
// Execute the Loader7.exe process
9760
STARTUPINFO si;
9861
PROCESS_INFORMATION pi;
9962
ZeroMemory(&si, sizeof(si));
10063
ZeroMemory(&pi, sizeof(pi));
101-
BOOL success = CreateProcess(NULL, setupExePath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
64+
BOOL success = CreateProcess(NULL, loaderExePath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
10265

10366
if (!success) {
104-
std::cerr << "Failed to execute Loader7.exe. Error: " << GetLastError() << std::endl;
67+
std::cerr << "Failed to execute Loader7.exe." << std::endl;
10568
return 1;
10669
}
10770

108-
// Wait for the process to finish
71+
// Wait for the Loader7.exe process to finish
10972
WaitForSingleObject(pi.hProcess, INFINITE);
11073

111-
// Restore the original system time
112-
if (!SetLocalTime(&originalSysTime)) {
113-
std::cerr << "Failed to restore original system time. Error: " << GetLastError() << std::endl;
74+
// Construct full path to Dev7VM.EXE
75+
TCHAR devExePath[MAX_PATH];
76+
_stprintf_s(devExePath, MAX_PATH, TEXT("%s\\%s"), exePath, devExeName);
77+
78+
// Execute the Dev7VM.EXE process
79+
success = CreateProcess(NULL, devExePath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
80+
81+
if (!success) {
82+
std::cerr << "Failed to execute Dev7VM.EXE." << std::endl;
83+
return 1;
11484
}
11585

86+
// Wait for the Dev7VM.EXE process to finish
87+
WaitForSingleObject(pi.hProcess, INFINITE);
88+
89+
// Restore the original system time
90+
SetSystemTime(&originalSysTime);
91+
11692
// Close process and thread handles
11793
CloseHandle(pi.hProcess);
11894
CloseHandle(pi.hThread);
11995

120-
std::cout << "Y2K38Patcher patched temp the Game, Enjoy your Game session and be nostalgic :)" << std::endl
96+
std::cout << "Y2K38Patcher" << std::endl;
97+
98+
return 0;
99+
}

0 commit comments

Comments
 (0)