GHA
This commit is contained in:
parent
674dd69cc6
commit
5c071fb14a
233
OpenParrot/src/Functions/Games/Other/GHA.cpp
Normal file
233
OpenParrot/src/Functions/Games/Other/GHA.cpp
Normal file
@ -0,0 +1,233 @@
|
||||
#include <StdInc.h>
|
||||
#include "Utility/InitFunction.h"
|
||||
#include "Functions/Global.h"
|
||||
#include "Functions/GlobalRegHooks.h"
|
||||
#include "Utility\Hooking.Patterns.h"
|
||||
#include <atlstr.h>
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <shlobj.h>
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
#include "Functions/XInputEmu.h"
|
||||
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
|
||||
DWORD BaseAddress6 = 0x00400000;
|
||||
int horizontal6 = 0;
|
||||
int vertical6 = 0;
|
||||
HWND hWndRT6 = 0;
|
||||
|
||||
extern int* ffbOffset;
|
||||
extern int* ffbOffset3;
|
||||
extern int* ffbOffset4;
|
||||
|
||||
// hooks ori
|
||||
BOOL(__stdcall *original_SetWindowPos6)(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
|
||||
BOOL(__stdcall *original_CreateWindowExA6)(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam);
|
||||
BOOL(__stdcall *original_DefWindowProcA6)(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
BOOL(__stdcall *original_SetCursorPosRT6)(int X, int Y);
|
||||
BOOL(__stdcall *original_SetWindowTextWRT6)(HWND hWnd, LPCWSTR lpString);
|
||||
BOOL(__stdcall *original_XInputGetStateGHA)(DWORD dwUserIndex, XINPUT_STATE* pState);
|
||||
|
||||
DWORD WINAPI InputRT6(LPVOID lpParam)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
// ESCAPE QUITS GAME
|
||||
if (GetAsyncKeyState(VK_ESCAPE) & 0x8000)
|
||||
{
|
||||
WinExec("taskkill /f /im GHA.exe", SW_HIDE);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI WindowRT6(LPVOID lpParam)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
// RIGHT-CLICK MINIMIZES WINDOW
|
||||
if (GetAsyncKeyState(VK_RBUTTON) & 0x8000)
|
||||
{
|
||||
HWND hWndTMP = GetForegroundWindow();
|
||||
if (hWndRT6 == 0)
|
||||
{
|
||||
hWndRT6 = FindWindowA(NULL, "Guitar Hero Arcade");
|
||||
}
|
||||
if (hWndTMP == hWndRT6)
|
||||
{
|
||||
RECT rect;
|
||||
GetWindowRect(hWndRT6, &rect);
|
||||
int currentwidth = rect.right - rect.left;
|
||||
int currentheight = rect.bottom - rect.top;
|
||||
original_SetWindowPos6(hWndRT6, HWND_BOTTOM, 0, 0, 1360, 768, SWP_NOSIZE);
|
||||
ShowWindow(hWndRT6, SW_MINIMIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DWORD WINAPI DefWindowProcART6(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static int xClick;
|
||||
static int yClick;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
SetCapture(hWnd);
|
||||
xClick = LOWORD(lParam);
|
||||
yClick = HIWORD(lParam);
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
ReleaseCapture();
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
if (GetCapture() == hWnd)
|
||||
{
|
||||
RECT rcWindow;
|
||||
GetWindowRect(hWnd, &rcWindow);
|
||||
int xMouse = LOWORD(lParam);
|
||||
int yMouse = HIWORD(lParam);
|
||||
int xWindow = rcWindow.left + xMouse - xClick;
|
||||
int yWindow = rcWindow.top + yMouse - yClick;
|
||||
if (xWindow >= (horizontal6 - 100))
|
||||
xWindow = 0;
|
||||
if (yWindow >= (vertical6 - 100))
|
||||
yWindow = 0;
|
||||
original_SetWindowPos6(hWnd, NULL, xWindow, yWindow, 1360, 768, SWP_NOSIZE | SWP_NOZORDER);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return original_DefWindowProcA6(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
DWORD WINAPI CreateWindowExART6(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam)
|
||||
{
|
||||
return original_CreateWindowExA6(dwExStyle, lpClassName, "Guitar Hero Arcade", 0x94000000, X, Y, 1360, 768, hWndParent, hMenu, hInstance, lpParam);
|
||||
}
|
||||
|
||||
DWORD WINAPI SetCursorPosRT6(int X, int Y)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
DWORD WINAPI SetWindowPosRT6(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
DWORD WINAPI SetWindowTextWRT6(HWND hWnd, LPCWSTR lpString)
|
||||
{
|
||||
return original_SetWindowTextWRT6(hWnd, CStringW("Guitar Hero Arcade"));
|
||||
}
|
||||
|
||||
static InitFunction GHAFunc([]()
|
||||
{
|
||||
init_GlobalRegHooks();
|
||||
GetDesktopResolution(horizontal6, vertical6);
|
||||
|
||||
// CONFIG FILE HANDLING
|
||||
char working_directory[MAX_PATH + 1];
|
||||
GetCurrentDirectoryA(sizeof(working_directory), working_directory);
|
||||
std::string s7 = working_directory;
|
||||
std::string s8 = s7 + "\\AspyrConfig.xml";
|
||||
|
||||
ofstream file;
|
||||
file.open(s8.c_str());
|
||||
|
||||
string strXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<r>\n <s id=\"Video.Width\">";
|
||||
|
||||
std::string h = std::to_string(horizontal6);
|
||||
std::string v = std::to_string(vertical6);
|
||||
|
||||
if (ToBool(config["General"]["Windowed"]))
|
||||
{
|
||||
strXML += "1360";
|
||||
}
|
||||
else if (ToBool(config["General"]["HDPatch"]))
|
||||
{
|
||||
strXML += h;
|
||||
}
|
||||
else
|
||||
{
|
||||
strXML += "1360";
|
||||
}
|
||||
|
||||
strXML += "</s>\n <s id=\"Video.Height\">";
|
||||
|
||||
if (ToBool(config["General"]["Windowed"]))
|
||||
{
|
||||
strXML += "768";
|
||||
}
|
||||
else if (ToBool(config["General"]["HDPatch"]))
|
||||
{
|
||||
strXML += v;
|
||||
}
|
||||
else
|
||||
{
|
||||
strXML += "768";
|
||||
}
|
||||
|
||||
strXML += "</s> \n <s id=\"Options.GraphicsQuality\">0</s>\n <s id=\"Options.Crowd\">1</s>\n <s id=\"Options.Physics\">1</s>\n <s id=\"Options.Flares\">1</s>\n <s id=\"Options.FrontRowCamera\">0</s>\n <s id=\"6f1d2b61d5a011cfbfc7444553540000\">328 221 340 343 267 264 999 219 235 331 304 999 310</s>\n</r>\n";
|
||||
file << strXML;
|
||||
file.close();
|
||||
|
||||
char user[MAX_PATH];
|
||||
SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, user);
|
||||
std::string s11 = user;
|
||||
std::string s12 = s11 + "\\Aspyr\\Guitar Hero III\\AspyrConfig.xml";
|
||||
SetFileAttributesA(s12.c_str(), FILE_ATTRIBUTE_NORMAL);
|
||||
Sleep(100);
|
||||
CopyFileA(s8.c_str(), s12.c_str(), FALSE);
|
||||
Sleep(100);
|
||||
SetFileAttributesA(s12.c_str(), FILE_ATTRIBUTE_READONLY);
|
||||
Sleep(100);
|
||||
|
||||
// UNLOCK MAIN MENU
|
||||
std::string s21 = s7 + "\\DATA\\PAK\\qb.pab.xen";
|
||||
std::string s22 = s7 + "\\DATA\\PAK\\qb.pak.xen";
|
||||
std::string s23 = s7 + "\\DATA\\PAK\\qb.pab.ATTRACTv4.xen";
|
||||
std::string s24 = s7 + "\\DATA\\PAK\\qb.pak.ATTRACTv4.xen";
|
||||
std::string s25 = s7 + "\\DATA\\PAK\\qb.pab.MENUv4.xen";
|
||||
std::string s26 = s7 + "\\DATA\\PAK\\qb.pak.MENUv4.xen";
|
||||
|
||||
if (ToBool(config["General"]["UnlockMainMenu"]))
|
||||
{
|
||||
CopyFileA(s25.c_str(), s21.c_str(), FALSE);
|
||||
CopyFileA(s26.c_str(), s22.c_str(), FALSE);
|
||||
Sleep(100);
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyFileA(s23.c_str(), s21.c_str(), FALSE);
|
||||
CopyFileA(s24.c_str(), s22.c_str(), FALSE);
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
CreateThread(NULL, 0, InputRT6, NULL, 0, NULL);
|
||||
|
||||
MH_Initialize();
|
||||
MH_CreateHookApi(L"user32.dll", "SetWindowPos", &SetWindowPosRT6, (void**)&original_SetWindowPos6);
|
||||
MH_CreateHookApi(L"user32.dll", "SetWindowTextW", &SetWindowTextWRT6, (void**)&original_SetWindowTextWRT6);
|
||||
MH_EnableHook(MH_ALL_HOOKS);
|
||||
|
||||
if (ToBool(config["General"]["Windowed"]))
|
||||
{
|
||||
CreateThread(NULL, 0, WindowRT6, NULL, 0, NULL);
|
||||
|
||||
MH_Initialize();
|
||||
MH_CreateHookApi(L"user32.dll", "CreateWindowExA", &CreateWindowExART6, (void**)&original_CreateWindowExA6);
|
||||
MH_CreateHookApi(L"user32.dll", "DefWindowProcA", &DefWindowProcART6, (void**)&original_DefWindowProcA6);
|
||||
MH_CreateHookApi(L"user32.dll", "SetCursorPos", &SetCursorPosRT6, NULL);
|
||||
MH_EnableHook(MH_ALL_HOOKS);
|
||||
}
|
||||
|
||||
}, GameID::GHA);
|
@ -1,15 +1,20 @@
|
||||
#include <StdInc.h>
|
||||
#include "Functions/Types.h"
|
||||
#include "Utility/InitFunction.h"
|
||||
#include "Functions/Global.h"
|
||||
#include "Utility\Hooking.Patterns.h"
|
||||
#include <objbase.h>
|
||||
#include "Utility/GameDetect.h"
|
||||
#include <string>
|
||||
#include <atlstr.h>
|
||||
#include <windows.h>
|
||||
|
||||
LSTATUS (__stdcall *orig_RegOpenKeyExA)(
|
||||
LSTATUS(__stdcall *orig_RegOpenKeyExA)(
|
||||
HKEY hKey,
|
||||
LPCSTR lpSubKey,
|
||||
DWORD ulOptions,
|
||||
REGSAM samDesired,
|
||||
PHKEY phkResult
|
||||
);
|
||||
);
|
||||
|
||||
LSTATUS __stdcall RegOpenKeyExAGlobalWrap(
|
||||
HKEY hKey,
|
||||
@ -22,13 +27,13 @@ LSTATUS __stdcall RegOpenKeyExAGlobalWrap(
|
||||
return orig_RegOpenKeyExA(hKey, lpSubKey, ulOptions, samDesired, phkResult);
|
||||
}
|
||||
|
||||
LSTATUS (__stdcall *orig_RegOpenKeyExW)(
|
||||
LSTATUS(__stdcall *orig_RegOpenKeyExW)(
|
||||
HKEY hKey,
|
||||
LPCWSTR lpSubKey,
|
||||
DWORD ulOptions,
|
||||
REGSAM samDesired,
|
||||
PHKEY phkResult
|
||||
);
|
||||
);
|
||||
|
||||
LSTATUS __stdcall RegOpenKeyExWGlobalWrap(
|
||||
HKEY hKey,
|
||||
@ -38,10 +43,17 @@ LSTATUS __stdcall RegOpenKeyExWGlobalWrap(
|
||||
PHKEY phkResult
|
||||
)
|
||||
{
|
||||
if (GameDetect::currentGame == GameID::GHA)
|
||||
{
|
||||
if (_wcsicmp(lpSubKey, L"SOFTWARE\\Aspyr\\Guitar Hero III") == 0)
|
||||
{
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
return orig_RegOpenKeyExW(hKey, lpSubKey, ulOptions, samDesired, phkResult);
|
||||
}
|
||||
|
||||
LSTATUS (__stdcall *orig_RegCreateKeyExA)(
|
||||
LSTATUS(__stdcall *orig_RegCreateKeyExA)(
|
||||
HKEY hKey,
|
||||
LPCSTR lpSubKey,
|
||||
DWORD Reserved,
|
||||
@ -51,7 +63,7 @@ LSTATUS (__stdcall *orig_RegCreateKeyExA)(
|
||||
CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
PHKEY phkResult,
|
||||
LPDWORD lpdwDisposition
|
||||
);
|
||||
);
|
||||
|
||||
LSTATUS __stdcall RegCreateKeyExAGlobalWrap(
|
||||
HKEY hKey,
|
||||
@ -68,7 +80,7 @@ LSTATUS __stdcall RegCreateKeyExAGlobalWrap(
|
||||
return orig_RegCreateKeyExA(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition);
|
||||
}
|
||||
|
||||
LSTATUS (__stdcall *orig_RegCreateKeyExW)(
|
||||
LSTATUS(__stdcall *orig_RegCreateKeyExW)(
|
||||
HKEY hKey,
|
||||
LPCWSTR lpSubKey,
|
||||
DWORD Reserved,
|
||||
@ -78,7 +90,7 @@ LSTATUS (__stdcall *orig_RegCreateKeyExW)(
|
||||
CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
PHKEY phkResult,
|
||||
LPDWORD lpdwDisposition
|
||||
);
|
||||
);
|
||||
|
||||
LSTATUS __stdcall RegCreateKeyExWGlobalWrap(
|
||||
HKEY hKey,
|
||||
@ -95,14 +107,14 @@ LSTATUS __stdcall RegCreateKeyExWGlobalWrap(
|
||||
return orig_RegCreateKeyExW(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition);
|
||||
}
|
||||
|
||||
LSTATUS (__stdcall *orig_RegSetValueExA)(
|
||||
LSTATUS(__stdcall *orig_RegSetValueExA)(
|
||||
HKEY hKey,
|
||||
LPCSTR lpValueName,
|
||||
DWORD Reserved,
|
||||
DWORD dwType,
|
||||
CONST BYTE* lpData,
|
||||
DWORD cbData
|
||||
);
|
||||
);
|
||||
|
||||
LSTATUS __stdcall RegSetValueExAGlobalWrap(
|
||||
HKEY hKey,
|
||||
@ -116,14 +128,14 @@ LSTATUS __stdcall RegSetValueExAGlobalWrap(
|
||||
return orig_RegSetValueExA(hKey, lpValueName, Reserved, dwType, lpData, cbData);
|
||||
}
|
||||
|
||||
LSTATUS (__stdcall *orig_RegSetValueExW)(
|
||||
LSTATUS(__stdcall *orig_RegSetValueExW)(
|
||||
HKEY hKey,
|
||||
LPCWSTR lpValueName,
|
||||
DWORD Reserved,
|
||||
DWORD dwType,
|
||||
CONST BYTE* lpData,
|
||||
DWORD cbData
|
||||
);
|
||||
);
|
||||
|
||||
LSTATUS __stdcall RegSetValueExWGlobalWrap(
|
||||
HKEY hKey,
|
||||
@ -137,14 +149,14 @@ LSTATUS __stdcall RegSetValueExWGlobalWrap(
|
||||
return orig_RegSetValueExW(hKey, lpValueName, Reserved, dwType, lpData, cbData);
|
||||
}
|
||||
|
||||
LSTATUS (__stdcall *orig_RegQueryValueExA)(
|
||||
LSTATUS(__stdcall *orig_RegQueryValueExA)(
|
||||
HKEY hKey,
|
||||
LPCSTR lpValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
__out_data_source(REGISTRY)LPBYTE lpData,
|
||||
LPDWORD lpcbData
|
||||
);
|
||||
);
|
||||
|
||||
LSTATUS __stdcall RegQueryValueExAGlobalWrap(
|
||||
HKEY hKey,
|
||||
@ -158,14 +170,14 @@ LSTATUS __stdcall RegQueryValueExAGlobalWrap(
|
||||
return orig_RegQueryValueExA(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData);
|
||||
}
|
||||
|
||||
LSTATUS (__stdcall *orig_RegQueryValueExW)(
|
||||
LSTATUS(__stdcall *orig_RegQueryValueExW)(
|
||||
HKEY hKey,
|
||||
LPCWSTR lpValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
__out_data_source(REGISTRY)LPBYTE lpData,
|
||||
LPDWORD lpcbData
|
||||
);
|
||||
);
|
||||
|
||||
LSTATUS __stdcall RegQueryValueExWGlobalWrap(
|
||||
HKEY hKey,
|
||||
@ -176,6 +188,29 @@ LSTATUS __stdcall RegQueryValueExWGlobalWrap(
|
||||
LPDWORD lpcbData
|
||||
)
|
||||
{
|
||||
if (GameDetect::currentGame == GameID::GHA)
|
||||
{
|
||||
if (_wcsicmp(lpValueName, L"Language") == 0)
|
||||
{
|
||||
*lpcbData = 3;
|
||||
memcpy(lpData, (LPCWSTR)("en\0"), 3);
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
else if (_wcsicmp(lpValueName, L"Path") == 0)
|
||||
{
|
||||
wchar_t working_directory[MAX_PATH + 1];
|
||||
GetCurrentDirectory(sizeof(working_directory), working_directory);
|
||||
std::wstring path = working_directory;
|
||||
path += _T("\\");
|
||||
path += _T("\0");
|
||||
CStringW PathString = (path.c_str());
|
||||
|
||||
*lpcbData = MAX_PATH + 1;
|
||||
memcpy(lpData, (LPCWSTR)PathString, MAX_PATH + 1);
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return orig_RegQueryValueExW(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -56,5 +56,6 @@ enum class GameID
|
||||
FNFSC,
|
||||
FNF,
|
||||
FNFSB,
|
||||
FNFSB2
|
||||
FNFSB2,
|
||||
GHA
|
||||
};
|
Loading…
Reference in New Issue
Block a user