summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormilo24x7@gmail.com <milo24x7@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544>2013-07-07 22:54:52 +0000
committermilo24x7@gmail.com <milo24x7@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544>2013-07-07 22:54:52 +0000
commit593090fd39087c9cf142c93baec8dd0c29ad9ff6 (patch)
treee1b98617fb4acd3cb00663dcad5b89bb94a2f6ba
parentd17521c8b9085a91d08fecfd0b51bbbf7b1dccac (diff)
downloadstarshatter-593090fd39087c9cf142c93baec8dd0c29ad9ff6.zip
starshatter-593090fd39087c9cf142c93baec8dd0c29ad9ff6.tar.gz
starshatter-593090fd39087c9cf142c93baec8dd0c29ad9ff6.tar.bz2
Removed unused Authorization class.
-rw-r--r--Stars45/Authorization.cpp203
-rw-r--r--Stars45/Authorization.h30
2 files changed, 0 insertions, 233 deletions
diff --git a/Stars45/Authorization.cpp b/Stars45/Authorization.cpp
deleted file mode 100644
index ca9b864..0000000
--- a/Stars45/Authorization.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/* Project Starshatter 4.5
- Destroyer Studios LLC
- Copyright © 1997-2004. All Rights Reserved.
-
- SUBSYSTEM: Stars.exe
- FILE: Authorization.cpp
- AUTHOR: John DiCamillo
-
-
- OVERVIEW
- ========
- Authorization Sprite animation class
-*/
-
-#include "MemDebug.h"
-#include "Authorization.h"
-
-#include "Game.h"
-#include "Text.h"
-
-// +--------------------------------------------------------------------+
-
-static Text GetCDKeyFromRegistry()
-{
- Text cdkey;
- BYTE cdbuf[64];
- DWORD cdlen = 0;
- HKEY hkey = 0;
-
- ZeroMemory(cdbuf, sizeof(cdbuf));
-
- RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- "SOFTWARE\\Matrix Games\\Starshatter",
- 0,
- KEY_QUERY_VALUE,
- &hkey);
-
- if (hkey) {
- cdlen = 64;
-
- LONG result =
- RegQueryValueEx(hkey,
- "authorized",
- NULL,
- NULL,
- cdbuf,
- &cdlen);
-
- if (result == ERROR_SUCCESS && cdlen > 0)
- cdkey = (const char*) cdbuf;
-
- RegCloseKey(hkey);
- }
-
- return cdkey;
-}
-
-static Text GetCDKeyFromIniFile()
-{
- Text cdkey;
- char cdbuf[256];
-
- ZeroMemory(cdbuf, sizeof(cdbuf));
-
- FILE* f;
- fopen_s(&f, "maga.mg", "r");
- if (f) {
- bool found_section = false;
-
- while (fgets(cdbuf, sizeof(cdbuf)-1, f)) {
- Text line = Text(cdbuf).trim();
- line.setSensitive(false);
-
- if (line == "[SerialNumber]")
- found_section = true;
-
- if (found_section) {
- if (line.indexOf("serial") == 0) {
- // found the proper line in the proper section,
- // now we need to parse the 'name = value' sentence:
-
- const char* p = line.data();
-
- // find the equal sign:
- while (p && *p && *p != '=')
- p++;
-
- // skip the equal sign:
- p++;
-
- // find the string after the equal sign:
- while (p && *p && isspace(*p))
- p++;
-
- if (p && *p) {
- // deal with quoted strings:
- int cutoff = sizeof(cdbuf)-1;
-
- if (*p == '"') {
- char* s = cdbuf;
- p++;
-
- while (*p && *p != '"' && cutoff-- > 0) {
- *s++ = *p++;
- }
-
- *s = 0;
- }
-
- // and unquoted strings:
- else {
- char* s = cdbuf;
-
- while (*p && cutoff-- > 0) {
- *s++ = *p++;
- }
-
- *s = 0;
- }
-
- cdkey = cdbuf;
- }
- }
- }
- }
-
- fclose(f);
- }
-
- return cdkey;
-}
-
-// +--------------------------------------------------------------------+
-
-static char serial_number[64];
-int execRegistrationProgram();
-
-bool
-Authorization::IsUserAuthorized()
-{
- // XXX DEBUG ONLY!
- // return true;
-
- int authcode = execRegistrationProgram();
- if (authcode != 1) {
- ::Print("Authorization failed, code = %d\n", authcode);
- }
-
- return (authcode == 1);
-}
-
-// +--------------------------------------------------------------------+
-
-const char*
-Authorization::GetSerialNumber()
-{
- return serial_number;
-}
-
-// +--------------------------------------------------------------------+
-
-int execRegistrationProgram()
-{
- int result = 999;
- char cmdline[256];
- strcpy_s(cmdline, "SS2rez");
-
- STARTUPINFO s;
- ZeroMemory(&s, sizeof(s));
- s.cb = sizeof(s);
-
- PROCESS_INFORMATION pi;
- ZeroMemory(&pi, sizeof(pi));
-
- if (CreateProcess("SS2rez.exe", cmdline, 0, 0, 0, 0, 0, 0, &s, &pi)) {
- DWORD exitcode = STILL_ACTIVE;
-
- WaitForSingleObject(pi.hProcess, 20000);
- GetExitCodeProcess(pi.hProcess, &exitcode);
-
- if (exitcode != STILL_ACTIVE)
- result = exitcode;
-
- CloseHandle(pi.hProcess);
- CloseHandle(pi.hThread);
- }
- else {
- TCHAR message[256];
- DWORD errcode = GetLastError();
-
- ::Print(" WARN: Failed to create authorization process: %08X.\n", errcode);
-
- if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, errcode, 0, message, 256, 0)) {
- ::Print(" ");
- ::Print(message);
- ::Print("\n");
- }
- }
-
- return result;
-}
-
-
diff --git a/Stars45/Authorization.h b/Stars45/Authorization.h
deleted file mode 100644
index 309f227..0000000
--- a/Stars45/Authorization.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Project Starshatter 4.5
- Destroyer Studios LLC
- Copyright © 1997-2004. All Rights Reserved.
-
- SUBSYSTEM: Stars.exe
- FILE: Authorization.h
- AUTHOR: John DiCamillo
-
-
- OVERVIEW
- ========
- Authorization Sprite class
-*/
-
-#ifndef Authorization_h
-#define Authorization_h
-
-#include "Types.h"
-
-// +--------------------------------------------------------------------+
-
-class Authorization
-{
-public:
- static bool IsUserAuthorized();
- static const char* GetSerialNumber();
-};
-
-#endif Authorization_h
-