23 static Text GetCDKeyFromRegistry()
30 ZeroMemory(cdbuf,
sizeof(cdbuf));
32 RegOpenKeyEx(HKEY_LOCAL_MACHINE,
33 "SOFTWARE\\Matrix Games\\Starshatter",
49 if (result == ERROR_SUCCESS && cdlen > 0)
50 cdkey = (
const char*) cdbuf;
58 static Text GetCDKeyFromIniFile()
63 ZeroMemory(cdbuf,
sizeof(cdbuf));
66 fopen_s(&f,
"maga.mg",
"r");
68 bool found_section =
false;
70 while (fgets(cdbuf,
sizeof(cdbuf)-1, f)) {
74 if (line ==
"[SerialNumber]")
78 if (line.
indexOf(
"serial") == 0) {
82 const char* p = line.
data();
85 while (p && *p && *p !=
'=')
92 while (p && *p && isspace(*p))
97 int cutoff =
sizeof(cdbuf)-1;
103 while (*p && *p !=
'"' && cutoff-- > 0) {
114 while (*p && cutoff-- > 0) {
135 static char serial_number[64];
146 ::Print(
"Authorization failed, code = %d\n", authcode);
149 return (authcode == 1);
157 return serial_number;
166 strcpy_s(cmdline,
"SS2rez");
169 ZeroMemory(&s,
sizeof(s));
172 PROCESS_INFORMATION pi;
173 ZeroMemory(&pi,
sizeof(pi));
175 if (CreateProcess(
"SS2rez.exe", cmdline, 0, 0, 0, 0, 0, 0, &s, &pi)) {
176 DWORD exitcode = STILL_ACTIVE;
178 WaitForSingleObject(pi.hProcess, 20000);
179 GetExitCodeProcess(pi.hProcess, &exitcode);
181 if (exitcode != STILL_ACTIVE)
184 CloseHandle(pi.hProcess);
185 CloseHandle(pi.hThread);
189 DWORD errcode = GetLastError();
191 ::Print(
" WARN: Failed to create authorization process: %08X.\n", errcode);
193 if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, errcode, 0, message, 256, 0)) {