From d5f17dbe6d0b33e1d4e9c6ffc1e528a0ed725c20 Mon Sep 17 00:00:00 2001 From: Emmet Young Date: Sat, 14 Feb 2015 22:17:45 +1100 Subject: [PATCH] Strip out Validate binary and beta release code. No longer needed, validate binary code could of been used for version testing but be cleaner to write it fresh. --- Project64.vs2013.sln | 12 +- Source/Project64/N64 System/N64 Class.cpp | 6 - Source/Project64/Project64.vcproj | 112 ----- Source/Project64/Project64.vcxproj | 16 - Source/Project64/Project64.vcxproj.filters | 6 - Source/Project64/Settings.h | 10 - Source/Project64/Settings/Settings Class.cpp | 10 - Source/Project64/User Interface/Gui Class.cpp | 138 ------ Source/Project64/User Interface/Gui Class.h | 5 +- .../User Interface/Main Menu Class.cpp | 10 - Source/Project64/Validate Binary.h | 20 - Source/Project64/ValidateBinary.cpp | 428 ------------------ Source/Project64/main.cpp | 18 +- Source/Project64/stdafx.h | 1 - 14 files changed, 10 insertions(+), 782 deletions(-) delete mode 100644 Source/Project64/Validate Binary.h delete mode 100644 Source/Project64/ValidateBinary.cpp diff --git a/Project64.vs2013.sln b/Project64.vs2013.sln index 3f0ebf5a9..5cf1ed910 100644 --- a/Project64.vs2013.sln +++ b/Project64.vs2013.sln @@ -1,6 +1,8 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3rd Party", "3rd Party", "{AA8F7F8E-5377-4911-859D-8A8817B0DB26}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wxWidgets", "wxWidgets", "{1379F817-7E3D-4F58-9C22-7E364E46E842}" @@ -52,8 +54,8 @@ Global {B4A4B994-9111-42B1-93C2-6F1CA8BC4421}.Debug|Win32.Build.0 = Debug|Win32 {B4A4B994-9111-42B1-93C2-6F1CA8BC4421}.Release|Win32.ActiveCfg = Release|Win32 {B4A4B994-9111-42B1-93C2-6F1CA8BC4421}.Release|Win32.Build.0 = Release|Win32 - {7E534C8E-1ACE-4A88-8807-39A11ED4DA18}.Beta Release|Win32.ActiveCfg = Beta Release|Win32 - {7E534C8E-1ACE-4A88-8807-39A11ED4DA18}.Beta Release|Win32.Build.0 = Beta Release|Win32 + {7E534C8E-1ACE-4A88-8807-39A11ED4DA18}.Beta Release|Win32.ActiveCfg = Release|Win32 + {7E534C8E-1ACE-4A88-8807-39A11ED4DA18}.Beta Release|Win32.Build.0 = Release|Win32 {7E534C8E-1ACE-4A88-8807-39A11ED4DA18}.Debug|Win32.ActiveCfg = Debug|Win32 {7E534C8E-1ACE-4A88-8807-39A11ED4DA18}.Debug|Win32.Build.0 = Debug|Win32 {7E534C8E-1ACE-4A88-8807-39A11ED4DA18}.Release|Win32.ActiveCfg = Release|Win32 @@ -149,12 +151,12 @@ Global {3326E128-33AF-422C-BB7C-67CC6B915610} = {AA8F7F8E-5377-4911-859D-8A8817B0DB26} {4BC6906B-213E-40D7-9FC7-1A93E228393D} = {AA8F7F8E-5377-4911-859D-8A8817B0DB26} {731BD205-2826-4631-B7AF-117658E88DBC} = {AA8F7F8E-5377-4911-859D-8A8817B0DB26} + {A4D13408-A794-4199-8FC7-4A9A32505005} = {9FE699A5-41C3-4441-92AB-639B3D77DE26} {93447136-FACD-4740-8F35-FC46FB4A9E82} = {1379F817-7E3D-4F58-9C22-7E364E46E842} {427F1DCD-3BED-4010-9322-077A4C06D871} = {1379F817-7E3D-4F58-9C22-7E364E46E842} {93CFEDF3-9A75-4484-B169-D9D8074F5AC2} = {1379F817-7E3D-4F58-9C22-7E364E46E842} {05B9CB11-12D1-47CD-8E4A-88E12162119B} = {1379F817-7E3D-4F58-9C22-7E364E46E842} {25A25249-C284-4C5A-8DC2-26FC3EB13703} = {1379F817-7E3D-4F58-9C22-7E364E46E842} - {A4D13408-A794-4199-8FC7-4A9A32505005} = {9FE699A5-41C3-4441-92AB-639B3D77DE26} {462C2608-182F-452C-944F-AF201E19300B} = {9FE699A5-41C3-4441-92AB-639B3D77DE26} {2DADDAA5-0F57-46ED-A974-747908DDC7F3} = {9FE699A5-41C3-4441-92AB-639B3D77DE26} EndGlobalSection diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 3246112b6..a910ff498 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -331,12 +331,6 @@ void CN64System::StartEmulation2 ( bool NewThread ) } g_Notify->MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop)); -#ifdef BETA_RELEASE - if (!g_Settings->LoadBool(Beta_IsValidExe)) - { - return; - } -#endif ThreadInfo * Info = new ThreadInfo; HANDLE * hThread = new HANDLE; diff --git a/Source/Project64/Project64.vcproj b/Source/Project64/Project64.vcproj index 600617864..beeb8d63d 100644 --- a/Source/Project64/Project64.vcproj +++ b/Source/Project64/Project64.vcproj @@ -135,65 +135,6 @@ Name="VCPostBuildEventTool" /> - - - - - - - - - - - - - - - - - - - @@ -225,14 +166,6 @@ UsePrecompiledHeader="1" /> - - - - - - - - - - - - - - - @@ -896,15 +793,6 @@ AdditionalIncludeDirectories="User Interface" /> - - - - - Beta Release - Win32 - Debug Win32 @@ -26,10 +22,6 @@ - - - - @@ -49,18 +41,12 @@ - - - BETA_RELEASE;%(PreprocessorDefinitions) - - Create - @@ -189,7 +175,6 @@ - User Interface;%(AdditionalIncludeDirectories) User Interface;%(AdditionalIncludeDirectories) User Interface;%(AdditionalIncludeDirectories) @@ -202,7 +187,6 @@ - diff --git a/Source/Project64/Project64.vcxproj.filters b/Source/Project64/Project64.vcxproj.filters index a9ca22038..70ef1bf15 100644 --- a/Source/Project64/Project64.vcxproj.filters +++ b/Source/Project64/Project64.vcxproj.filters @@ -114,9 +114,6 @@ Source Files - - Source Files - Source Files\Settings Files @@ -488,9 +485,6 @@ Header Files - - Header Files - Header Files diff --git a/Source/Project64/Settings.h b/Source/Project64/Settings.h index a1d31cf85..e13297b6a 100644 --- a/Source/Project64/Settings.h +++ b/Source/Project64/Settings.h @@ -219,16 +219,6 @@ enum SettingID { Debugger_ShowDListAListCount, Debugger_ShowRecompMemSize, -#ifdef BETA_RELEASE - //Beta Information - Beta_IsBetaVersion, - Beta_UserName, - Beta_UserNameMD5, - Beta_EmailAddress, - Beta_EmailAddressMD5, - Beta_IsValidExe, -#endif - //Plugins Plugin_RSP_Current, Plugin_RSP_CurVer, diff --git a/Source/Project64/Settings/Settings Class.cpp b/Source/Project64/Settings/Settings Class.cpp index 1cf6d56bd..a9baa97af 100644 --- a/Source/Project64/Settings/Settings Class.cpp +++ b/Source/Project64/Settings/Settings Class.cpp @@ -289,16 +289,6 @@ void CSettings::AddHowToHandleSetting () AddHandler(Debugger_AppLogFlush, new CSettingTypeApplication("Logging","Log Auto Flush",(DWORD)false)); AddHandler(Debugger_GenerateLogFiles, new CSettingTypeApplication("Debugger","Generate Log Files", false)); - -#ifdef BETA_RELEASE - AddHandler(Beta_IsBetaVersion, new CSettingTypeTempBool(true)); - AddHandler(Beta_UserName, new CSettingTypeTempString("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")); - AddHandler(Beta_EmailAddress, new CSettingTypeTempString("????????????????????????????????????????????????????????????????????????????????")); - AddHandler(Beta_UserNameMD5, new CSettingTypeTempString("CBBABA8D2262FF1F7A47CEAD87FC4304")); - AddHandler(Beta_EmailAddressMD5, new CSettingTypeTempString("47A3D7CBF1DA291D5EB30DCAAF21B9F8")); - AddHandler(Beta_IsValidExe, new CSettingTypeTempBool(true)); -#endif - //Plugin AddHandler(Plugin_RSP_Current, new CSettingTypeApplication("Plugin","RSP Dll", "RSP\\RSP 1.7.dll")); AddHandler(Plugin_GFX_Current, new CSettingTypeApplication("Plugin","Graphics Dll", "GFX\\Jabo_Direct3D8.dll")); diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index 1a7ce4a84..e4ad8a7de 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -29,17 +29,6 @@ CMainGui::CMainGui (bool bMainWindow, const char * WindowTitle ) : m_AttachingMenu(false), m_MakingVisible(false) { -#ifdef BETA_RELEASE - m_hacked = false; - if (g_Settings) - { - if (MD5(g_Settings->LoadString(Beta_UserName)).hex_digest() != g_Settings->LoadString(Beta_UserNameMD5) || - MD5(g_Settings->LoadString(Beta_EmailAddress)).hex_digest() != g_Settings->LoadString(Beta_EmailAddressMD5)) - { - m_hacked = true; - } - } -#endif m_Menu = NULL; m_hMainWindow = 0; @@ -52,10 +41,6 @@ CMainGui::CMainGui (bool bMainWindow, const char * WindowTitle ) : m_SaveRomBrowserTop = 0; m_SaveRomBrowserLeft = 0; -#ifdef BETA_RELEASE - m_InvalidExeMsg = RegisterWindowMessage("Invalid"); -#endif - if (m_bMainWindow) { g_Settings->RegisterChangeCB(RomBrowser_Enabled,this,(CSettings::SettingChangedFunc)RomBowserEnabledChanged); @@ -509,10 +494,6 @@ DWORD CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DWOR CMainGui * _this = (CMainGui *)lpcs->lpCreateParams; SetProp((HWND)hWnd,"Class",_this); -#if defined(BETA_RELEASE) || defined(VALIDATE_BIN_LOCAL) - TestValidBinary(); - SetTimer((HWND)hWnd,0,10000,NULL); -#endif _this->m_hMainWindow = hWnd; _this->CreateStatusBar(); @@ -525,12 +506,6 @@ DWORD CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DWOR _this->ChangeWinSize(640,480); -#ifdef BETA_RELEASE - if (_this->m_hacked) - { - MessageBox(NULL,"Exe has been corrupted","Stopping",MB_OK|MB_ICONEXCLAMATION); - } -#endif } break; case WM_SYSCOMMAND: @@ -620,28 +595,6 @@ DWORD CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DWOR _this->SaveWindowLoc(); break; } -#ifdef BETA_RELEASE - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - static DWORD CallCount = 0; - if (!g_Settings->LoadBool(Beta_IsValidExe)) - { - if (CallCount == 0) - { - CallCount = 1; - PostMessage((HWND)hWnd,_this->m_InvalidExeMsg,0,0); - } - } - if (CallCount > 0) - { - if (CallCount == 9) - { - PostQuitMessage(0); - } - CallCount++; - } - } -#endif break; case WM_SIZE: { @@ -931,20 +884,6 @@ DWORD CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DWOR WriteTrace(TraceDebug,__FUNCTION__ ": WM_DESTROY - Done"); break; default: -#ifdef BETA_RELEASE - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - if (_this) - { - if (uMsg == _this->m_InvalidExeMsg) - { - g_BaseSystem->CloseCpu(); - MessageBox((HWND)hWnd,GS(MSG_INVALID_EXE),GS(MSG_INVALID_EXE_TITLE),MB_OK|MB_ICONERROR); - PostQuitMessage(0); - } - } - } -#endif return DefWindowProc((HWND)hWnd,uMsg,wParam,lParam); } return TRUE; @@ -984,75 +923,6 @@ DWORD CALLBACK AboutBoxCancelProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lP return CallWindowProc(pfnWndAboutBoxCancelProc, hWnd, uMsg, wParam, lParam); } -#ifdef BETA_RELEASE -LPSTR ValidateDecryptString (LPSTR String, int Len); -LPSTR ValidateEncryptString (LPSTR String, int Len); - -LPSTR ValidateDecryptString2 (LPSTR String, int Len) -{ - BYTE PreviousChar = 0xAA; - for (int x = 0; x < Len; x++) - { - String[x] ^= (PreviousChar + x) & 0xFF; - PreviousChar = String[x]; - } - return String; -} - -DWORD CALLBACK AboutUserProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD /*lParam*/) -{ - static char UserInfo[] = "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"; - - switch (uMsg) { - case WM_INITDIALOG: - { - char WindowTitleLabel[] = "\xff\x26\x16\x17\x52\x69\x27\x08\x09"; // "User Info"; - ValidateDecryptString(WindowTitleLabel,sizeof(WindowTitleLabel) - 1); - SetWindowText(hWnd,WindowTitleLabel); - - char UserIdLabel[] = "\xff\x26\x16\x17\x52\x69\x0d\x7e"; // "User ID:"; - ValidateDecryptString(UserIdLabel,sizeof(UserIdLabel) - 1); - SetWindowText(GetDlgItem(hWnd,IDC_LABEL1),UserIdLabel); - - char UserNameLabel[] = "\xff\x26\x16\x17\x52\x6e\x2f\x0c\x08\x5f"; // "User Name:"; - ValidateDecryptString(UserNameLabel,sizeof(UserNameLabel) - 1); - SetWindowText(GetDlgItem(hWnd,IDC_LABEL2),UserNameLabel); - - char UserEmailLabel[] = "\xef\x28\x0c\x08\x05\x56"; // "Email:"; - ValidateDecryptString(UserEmailLabel,sizeof(UserEmailLabel) - 1); - SetWindowText(GetDlgItem(hWnd,IDC_LABEL3),UserEmailLabel); - - typedef struct { - BYTE UserID[10]; - BYTE UserName[80]; - BYTE Email[80]; - } USER_INFO; - - USER_INFO * info = (USER_INFO *)UserInfo; - ValidateDecryptString2(UserInfo,sizeof(UserInfo) - 1); - info->UserID[sizeof(info->UserID) - 1] = 0; - info->UserName[sizeof(info->UserName) - 1] = 0; - info->Email[sizeof(info->Email) - 1] = 0; - SetWindowText(GetDlgItem(hWnd,IDC_INFO1),(char *)info->UserID); - SetWindowText(GetDlgItem(hWnd,IDC_INFO2),(char *)info->UserName); - SetWindowText(GetDlgItem(hWnd,IDC_INFO3),(char *)info->Email); - - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDOK: - case IDCANCEL: - EndDialog(hWnd,0); - break; - } - default: - return FALSE; - } - return TRUE; -} -#endif - DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) { static HBITMAP hbmpBackgroundTop = NULL; @@ -1271,14 +1141,6 @@ DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) break; case WM_COMMAND: switch (LOWORD(wParam)) { -#ifdef BETA_RELEASE - case IDC_VERSION: - if ((GetKeyState(VK_CONTROL) & 0x80)) - { - DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_About_UserInfo), (HWND)hWnd, (DLGPROC)AboutUserProc); - } - break; -#endif case IDOK: case IDCANCEL: if (hbmpBackgroundTop) diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index eacd85c1a..0958e37e8 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -109,10 +109,7 @@ private: HWND m_hMainWindow, m_hStatusWnd; DWORD m_ThreadId; -#ifdef BETA_RELEASE - bool m_hacked; - DWORD m_InvalidExeMsg; -#endif + const bool m_bMainWindow; bool m_Created; bool m_AttachingMenu; diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index 8d4f5dd68..52f397cde 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -1128,16 +1128,6 @@ void CMainMenu::FillOutMenu ( HMENU hMenu ) { /* Help Menu ****************/ MenuItemList HelpMenu; -#ifdef BETA_RELEASE - if (g_Settings->LoadBool(Beta_IsBetaVersion)) - { - stdstr_f User("Beta For: %s",g_Settings->LoadString(Beta_UserName).c_str()); - stdstr_f Email("Email: %s",g_Settings->LoadString(Beta_EmailAddress).c_str()); - HelpMenu.push_back(MENU_ITEM(NO_ID, EMPTY_STRING,EMPTY_STDSTR,NULL,User )); - HelpMenu.push_back(MENU_ITEM(NO_ID, EMPTY_STRING,EMPTY_STDSTR,NULL,Email )); - HelpMenu.push_back(MENU_ITEM(SPLITER )); - } -#endif HelpMenu.push_back(MENU_ITEM(ID_HELP_CONTENTS, MENU_USER_MAN )); HelpMenu.push_back(MENU_ITEM(ID_HELP_GAMEFAQ, MENU_GAME_FAQ )); diff --git a/Source/Project64/Validate Binary.h b/Source/Project64/Validate Binary.h deleted file mode 100644 index 63399029e..000000000 --- a/Source/Project64/Validate Binary.h +++ /dev/null @@ -1,20 +0,0 @@ -/**************************************************************************** -* * -* Project 64 - A Nintendo 64 emulator. * -* http://www.pj64-emu.com/ * -* Copyright (C) 2012 Project64. All rights reserved. * -* * -* License: * -* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * -* * -****************************************************************************/ -#pragma once - -#define VALIDATE_BIN_APP "PJ64" -//#define VALIDATE_BIN_APP "GFX DLL" - -//#define VALIDATE_BIN_LOCAL -//#define VALIDATE_DEBUG - -void TestValidBinary ( ); - diff --git a/Source/Project64/ValidateBinary.cpp b/Source/Project64/ValidateBinary.cpp deleted file mode 100644 index 4d5b3fc7c..000000000 --- a/Source/Project64/ValidateBinary.cpp +++ /dev/null @@ -1,428 +0,0 @@ -#include "stdafx.h" -#ifdef BETA_RELEASE - -#include -#pragma comment(lib, "Wininet.lib") - -LPSTR ValidateDecryptString (LPSTR String, int Len) -{ - BYTE PreviousChar = 0xAA; - for (int x = 0; x < Len; x++) - { - String[x] ^= PreviousChar; - PreviousChar = String[x]; - } - return String; -} - -LPSTR ValidateEncryptString (LPSTR String, int Len) -{ - BYTE EncryptChar = 0xAA; - for (int x = 0; x < Len; x++) - { - BYTE PreviousChar = String[x]; - String[x] ^= EncryptChar; - EncryptChar = PreviousChar; - } - return String; -} - -void TestValidBinaryThread ( ) -{ - typedef struct - { - BYTE File_md5[16]; - int RunTimes; - } INVALID_RUN_ITEM; - - enum { MAX_BAD_DATA = 50, FAILED_CHECK = 0x7FFFFFFF }; - - AUTO_PTR RunData; - INVALID_RUN_ITEM * RunItems = NULL; - int RunItemCount = 0; - bool DefaultResult = true; - - CPath ModuleFileName(CPath::MODULE_FILE); - MD5 File_md5(ModuleFileName); -#ifdef VALIDATE_DEBUG - WriteTraceF(TraceValidate,"v1: %s",File_md5.hex_digest()); -#endif - - // see if already invalid - char Subkey[] = "\x84\x5E\x1A\x5C\x02\x4E"; // ".pj64z"; - ValidateDecryptString(Subkey,sizeof(Subkey) - 1); - - char Subkey2[] = "\xF9\x1C\x09\x12\x03\x16\x13\x17\x19\x0C\x1A\x7C\x02"; // "SOFTWARE\PJ64"; - ValidateDecryptString(Subkey2,sizeof(Subkey2) - 1); - - CRegistry Registry; - BOOL bRes = Registry.Open(HKEY_LOCAL_MACHINE,Subkey2,KEY_ALL_ACCESS,true); - DWORD Length = 0; - if (bRes) - { - Length = Registry.GetValueSize("data"); - - if (Length == -1) - { - Length = 0; - bRes = false; - } - - if (bRes && Length > 0) - { - DWORD Type; - RunData.reset(new BYTE[Length]); - bRes = Registry.GetValue("data",RunData.get(),Length,&Type); - if (!bRes && Type != REG_BINARY) - { - bRes = false; - } - } - } - - if (!bRes) - { - bRes = Registry.Open(HKEY_CLASSES_ROOT,Subkey,KEY_ALL_ACCESS,true); - if (bRes) - { - Length = Registry.GetValueSize("data"); - - if (Length == -1) - { - Length = 0; - bRes = false; - } - - if (bRes) - { - DWORD Type; - RunData.reset(new BYTE[Length]); - bRes = Registry.GetValue("data",RunData.get(),Length,&Type); - if (!bRes && Type != REG_BINARY) - { - bRes = false; - } - } - } - } - - if (bRes && Length > 0) - { - RunItems = (INVALID_RUN_ITEM *)RunData.get(); - RunItemCount = Length / sizeof(INVALID_RUN_ITEM); - - for (int i = 0; i < RunItemCount; i ++) - { - if (memcmp(RunItems[i].File_md5,File_md5.raw_digest(),sizeof(RunItems[i].File_md5)) == 0) - { -#ifdef VALIDATE_DEBUG - WriteTraceF(TraceValidate,"v2: %d",RunItems[i].RunTimes); -#endif - if (RunItems[i].RunTimes >= MAX_BAD_DATA) - { - DefaultResult = false; - } - break; - } - } - } - - - //test to see if file has already been disabled - HINTERNET hSession = InternetOpen("project64", INTERNET_OPEN_TYPE_PRECONFIG,NULL, NULL, NULL); - if (hSession == NULL) - { -#ifdef VALIDATE_DEBUG - WriteTrace(TraceValidate,"v3"); -#endif - g_Settings->SaveBool(Beta_IsValidExe,DefaultResult); - return; - } - -#ifdef VALIDATE_BIN_LOCAL - char Site[] = { "www.local.pj64-emu.com" }; - ValidateEncryptString(Site,sizeof(Site) - 1); -#else - char Site[] = { "\xDD\x00\x00\x59\x5e\x1a\x5c\x02\x19\x48\x08\x18\x5b\x4d\x0c\x02" }; //"www.pj64-emu.com" -#endif - ValidateDecryptString(Site,sizeof(Site) - 1); - HINTERNET hConnect = InternetConnect(hSession, Site, 80, "", "", INTERNET_SERVICE_HTTP, 0, (LPARAM)0); - - if (hConnect == NULL) - { -#ifdef VALIDATE_DEBUG - WriteTrace(TraceValidate,"v4"); -#endif - g_Settings->SaveBool(Beta_IsValidExe,DefaultResult); - InternetCloseHandle (hSession); - hSession = NULL; - return; - } - - char AcceptText[] = "\xDE\x11\x1D\x0C\x5B\x05"; // "text/*"; - ValidateDecryptString(AcceptText,sizeof(AcceptText) - 1); - - LPCTSTR lpszAcceptTypes[] = - { - AcceptText, - NULL - }; - - char szPost[] = { "\xFA\x1F\x1C\x07" }; // "POST" - ValidateDecryptString(szPost,sizeof(szPost) - 1); - - // "index.php?option=com_validate_pj64" - char SiteLoc[] = { "\xc3\x07\x0a\x01\x1d\x56\x5e\x18\x18\x4f\x50\x1f\x04\x1d\x06\x01\x53\x5e\x0c\x02\x32\x29\x17\x0d\x05\x0d\x05\x15\x11\x3a\x2f\x1a\x5c\x02" }; -// char SiteLoc[] = { "index.php?option=com_validate_pj64" }; - -// ValidateEncryptString(SiteLoc,sizeof(SiteLoc) - 1); - ValidateDecryptString(SiteLoc,sizeof(SiteLoc) - 1); - - - HINTERNET hRequest = HttpOpenRequest(hConnect, szPost, SiteLoc, NULL, NULL, lpszAcceptTypes, INTERNET_FLAG_PRAGMA_NOCACHE, (LPARAM)0); - if (hRequest == NULL) - { -#ifdef VALIDATE_DEBUG - WriteTrace(TraceValidate,"v5"); -#endif - g_Settings->SaveBool(Beta_IsValidExe,DefaultResult); - InternetCloseHandle (hRequest); - return; - } - - stdstr ComputerName; - Length = 260; - ComputerName.resize(Length); - GetComputerName((char *)ComputerName.c_str(),&Length); - - ComputerName.ToLower(); - - stdstr_f PostInfo("1,%s,%s,%s,%s,%s,%s",VALIDATE_BIN_APP,File_md5.hex_digest(),ComputerName.c_str(),VersionInfo(VERSION_PRODUCT_VERSION).c_str(),g_Settings->LoadString(Beta_UserName).c_str(),g_Settings->LoadString(Beta_EmailAddress).c_str()); - - //"Content-Type: application/x-www-form-urlencoded" - char ContentType[] = { "\xE9\x2C\x01\x1A\x11\x0B\x1A\x59\x79\x2D\x09\x15\x5F\x1A\x41\x11\x00\x1C\x05\x0A\x02\x15\x1D\x06\x01\x41\x57\x55\x5A\x00\x00\x5A\x4B\x09\x1D\x1F\x40\x58\x07\x1E\x09\x0B\x0D\x0C\x0B\x01\x01" }; - ValidateDecryptString(ContentType,sizeof(ContentType) - 1); - - - //encrypt PostData - stdstr_f PostData("%s=","Data"); - BYTE * Input = (BYTE *)PostInfo.c_str(); - BYTE PreviousChar = 0xAA; - for (size_t x = 0; x < PostInfo.size(); x++) - { - PostData += stdstr_f("%02X",(BYTE)(Input[x] ^ PreviousChar)); - PreviousChar = Input[x]; - } - - BOOL Success = HttpSendRequest(hRequest, ContentType, sizeof(ContentType) - 1, (LPVOID)PostData.c_str(), PostData.length()); - if (!Success) - { -#ifdef VALIDATE_DEBUG - WriteTrace(TraceValidate,"v6"); -#endif - g_Settings->SaveBool(Beta_IsValidExe,DefaultResult); - InternetCloseHandle (hRequest); - return; - } - - -#ifdef VALIDATE_DEBUG - { - bool bGotHeaders = true; - DWORD dwBufferLength = 300; - std::auto_ptr Headers(new BYTE[dwBufferLength]); - if (!HttpQueryInfo(hRequest,HTTP_QUERY_RAW_HEADERS,Headers.get(),&dwBufferLength,NULL)) - { - if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) - { - Headers.reset(new BYTE[dwBufferLength]); - if (!HttpQueryInfo(hRequest,HTTP_QUERY_RAW_HEADERS,Headers.get(),&dwBufferLength,NULL)) - { - bGotHeaders = false; - } - } - } - - if (bGotHeaders) - { - for (LPCTSTR Header = (LPCTSTR)Headers.get(); Header != NULL && Header[0] != 0; Header += strlen(Header) + 1) - { - WriteTraceF(TraceValidate,"v6a: Header: %s",Header); - } - } else { - WriteTrace(TraceValidate,"v6b: Failed to get headers"); - } - } -#endif - - std::auto_ptr WebSiteData; - DWORD dwRead = 0; - ULONG DataLen = 0; - do{ - BYTE SiteData[0x1000]; - memset(SiteData,0,sizeof(SiteData)); - if (!InternetReadFile(hRequest,SiteData,sizeof(SiteData),&dwRead)) - { -#ifdef VALIDATE_DEBUG - WriteTrace(TraceValidate,"v7"); -#endif - g_Settings->SaveBool(Beta_IsValidExe,DefaultResult); - InternetCloseHandle (hRequest); - return; - } - - if (dwRead == 0) - { - break; - } - - std::auto_ptr NewSiteData(new BYTE[DataLen + dwRead + 1]); - if (DataLen > 0) - { - memcpy(NewSiteData.get(),WebSiteData.get(),DataLen); - } - memcpy(NewSiteData.get() + DataLen,SiteData,dwRead); - NewSiteData.get()[DataLen + dwRead] = 0; - WebSiteData = NewSiteData; - DataLen += dwRead; - - } while (dwRead > 0); - -#ifdef VALIDATE_DEBUG - WriteTraceF(TraceValidate,"v8: %s",WebSiteData.get()); -#endif - - MD5 Result_md5(WebSiteData.get(),DataLen); - - int LastRunItem = -1; - bool bSaveRunInfo = false; - for (int run = 0; run < RunItemCount; run ++) - { - if (memcmp(RunItems[run].File_md5,File_md5.raw_digest(),sizeof(RunItems[run].File_md5)) == 0) - { - LastRunItem = run; - break; - } - } - -#ifdef VALIDATE_DEBUG - WriteTraceF(TraceValidate,"v9: %s",Result_md5.hex_digest()); -#endif - //if good MD5 - if (_stricmp(Result_md5.hex_digest(),"FB2CDD258756A5472BD24BABF2EC9F66") == 0) // Good Md5 - { - if (LastRunItem > 0) - { - for (int i = (LastRunItem + 1); i < RunItemCount; i++) - { - memcpy(&RunItems[i - 1],&RunItems[i],sizeof(RunItems[i])); - } - RunItemCount -= 1; - bSaveRunInfo = true; - } - DefaultResult = true; - } - else if (_stricmp(Result_md5.hex_digest(),"9030FF575A9B687DC868B966CB7C02D4") == 0) // Bad MD5 - { - if (LastRunItem > 0) - { - if (RunItems[LastRunItem].RunTimes != FAILED_CHECK) - { - RunItems[LastRunItem].RunTimes = FAILED_CHECK; - bSaveRunInfo = true; - } - } else { - AUTO_PTR NewRunData(new BYTE[(RunItemCount + 1) * sizeof(INVALID_RUN_ITEM)]); - INVALID_RUN_ITEM * NewRunItems = (INVALID_RUN_ITEM *)NewRunData.get(); - for (int i = 0; i < RunItemCount; i++) - { - NewRunItems[i] = RunItems[i]; - } - LastRunItem = RunItemCount; - memcpy(NewRunItems[LastRunItem].File_md5,File_md5.raw_digest(),sizeof(NewRunItems[LastRunItem].File_md5)); - NewRunItems[LastRunItem].RunTimes = FAILED_CHECK; - - RunData = NewRunData; - RunItems = (INVALID_RUN_ITEM *)RunData.get(); - RunItemCount += 1; - bSaveRunInfo = true; - } - DefaultResult = false; - } - else - { - if (LastRunItem >= 0) - { - if (RunItems[LastRunItem].RunTimes != FAILED_CHECK) - { - RunItems[LastRunItem].RunTimes += 1; - if (RunItems[LastRunItem].RunTimes >= MAX_BAD_DATA) - { - DefaultResult = false; - RunItems[LastRunItem].RunTimes = MAX_BAD_DATA; - } - bSaveRunInfo = true; - } - } else { - AUTO_PTR NewRunData(new BYTE[(RunItemCount + 1) * sizeof(INVALID_RUN_ITEM)]); - INVALID_RUN_ITEM * NewRunItems = (INVALID_RUN_ITEM *)NewRunData.get(); - for (int i = 0; i < RunItemCount; i++) - { - NewRunItems[i] = RunItems[i]; - } - LastRunItem = RunItemCount; - memcpy(NewRunItems[LastRunItem].File_md5,File_md5.raw_digest(),sizeof(NewRunItems[LastRunItem].File_md5)); - NewRunItems[LastRunItem].RunTimes = 1; - - RunData = NewRunData; - RunItems = (INVALID_RUN_ITEM *)RunData.get(); - RunItemCount += 1; - bSaveRunInfo = true; - } - if (RunItems[LastRunItem].RunTimes >= MAX_BAD_DATA) - { - DefaultResult = false; - } - - } - - bSaveRunInfo = true; - if (bSaveRunInfo) - { - bRes = Registry.Open(HKEY_CLASSES_ROOT,Subkey,KEY_ALL_ACCESS,true); - if (bRes) - { - bRes = Registry.SetValue("data",(BYTE *)RunData.get(),RunItemCount * sizeof(INVALID_RUN_ITEM),REG_BINARY); - } - - if (bRes) - { - bRes = Registry.Open(HKEY_LOCAL_MACHINE,Subkey2,KEY_ALL_ACCESS); - if (bRes) - { - Registry.DeleteValue("data"); - } - }else { - bRes = Registry.Open(HKEY_LOCAL_MACHINE,Subkey2,KEY_ALL_ACCESS,true); - if (bRes) - { - bRes = Registry.SetValue("data",(BYTE *)RunData.get(),RunItemCount * sizeof(INVALID_RUN_ITEM),REG_BINARY); - } - } - } - g_Settings->SaveBool(Beta_IsValidExe,DefaultResult); -} - -void TestValidBinary ( ) -{ -#if defined(BETA_RELEASE) || defined(VALIDATE_BIN_LOCAL) - static DWORD ThreadID = 0; - if (ThreadID == 0) - { - HANDLE hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)TestValidBinaryThread,(LPVOID)NULL,0,&ThreadID); - CloseHandle(hThread); - } -#endif -} - -#endif diff --git a/Source/Project64/main.cpp b/Source/Project64/main.cpp index b105b7b2c..bcbd90e76 100644 --- a/Source/Project64/main.cpp +++ b/Source/Project64/main.cpp @@ -225,28 +225,14 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR / //Create the main window with Menu WriteTrace(TraceDebug,__FUNCTION__ ": Create Main Window"); stdstr WinTitle(AppName()); -#ifdef BETA_RELEASE - WinTitle.Format("Project64 %s (%s)",VersionInfo(VERSION_PRODUCT_VERSION).c_str(),g_Settings->LoadString(Beta_UserName).c_str()); -#else + WinTitle.Format("Project64 %s",VersionInfo(VERSION_PRODUCT_VERSION).c_str()); -#endif + CMainGui MainWindow(true,WinTitle.c_str()), HiddenWindow(false); CMainMenu MainMenu(&MainWindow); g_Plugins->SetRenderWindows(&MainWindow,&HiddenWindow); g_Notify->SetMainWindow(&MainWindow); -#ifdef BETA_RELEASE - { - stdstr_f User("%s",g_Settings->LoadString(Beta_UserName).c_str()); - stdstr_f Email("%s",g_Settings->LoadString(Beta_EmailAddress).c_str()); - - if (MD5(User).hex_digest() != g_Settings->LoadString(Beta_UserNameMD5) || - MD5(Email).hex_digest() != g_Settings->LoadString(Beta_EmailAddressMD5)) - { - return false; - } - } -#endif if (__argc > 1) { WriteTraceF(TraceDebug,__FUNCTION__ ": Cmd line found \"%s\"",__argv[1]); MainWindow.Show(true); //Show the main window diff --git a/Source/Project64/stdafx.h b/Source/Project64/stdafx.h index bd245397a..48cd25920 100644 --- a/Source/Project64/stdafx.h +++ b/Source/Project64/stdafx.h @@ -23,7 +23,6 @@ #include "Support.h" #include #include -#include "Validate Binary.h" #include #include "3rd Party/Zip.h"