Why can't I hook CreateFile
This commit is contained in:
parent
607e1a21c1
commit
87767e3066
@ -4,6 +4,7 @@
|
||||
#include "MinHook.h"
|
||||
#include <Utility/Hooking.Patterns.h>
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
#ifdef _M_AMD64
|
||||
#pragma optimize("", off)
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
@ -260,6 +261,62 @@ static unsigned int Hook_hasp_write(int hasp_handle, int hasp_fileid, unsigned i
|
||||
return HASP_STATUS_OK;
|
||||
}
|
||||
|
||||
typedef HANDLE(WINAPI* CreateFileA_t)(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
|
||||
static CreateFileA_t pCreateFileA = NULL;
|
||||
|
||||
static HANDLE WINAPI Hook_CreateFileA(
|
||||
LPCSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile
|
||||
)
|
||||
{
|
||||
MessageBoxW(NULL, L"CreateFileA", L"fuck", MB_OK | MB_ICONASTERISK);
|
||||
|
||||
printf("MT6_CreateFile:: filename=\"%s\" acc=%d mod=%d\n", lpFileName, dwDesiredAccess, dwShareMode);
|
||||
|
||||
return pCreateFileA(
|
||||
lpFileName,
|
||||
dwDesiredAccess,
|
||||
dwShareMode,
|
||||
lpSecurityAttributes,
|
||||
dwCreationDisposition,
|
||||
dwFlagsAndAttributes,
|
||||
hTemplateFile
|
||||
);
|
||||
}
|
||||
|
||||
typedef HANDLE(WINAPI* CreateFileW_t)(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
|
||||
static CreateFileW_t pCreateFileW = NULL;
|
||||
|
||||
static HANDLE WINAPI Hook_CreateFileW(
|
||||
LPCWSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile
|
||||
)
|
||||
{
|
||||
MessageBoxW(NULL, L"CreateFileW", L"fuck", MB_OK | MB_ICONASTERISK);
|
||||
|
||||
printf("MT6_CreateFile:: filename=\"%S\" acc=%d mod=%d\n", lpFileName, dwDesiredAccess, dwShareMode);
|
||||
|
||||
return pCreateFileW(
|
||||
lpFileName,
|
||||
dwDesiredAccess,
|
||||
dwShareMode,
|
||||
lpSecurityAttributes,
|
||||
dwCreationDisposition,
|
||||
dwFlagsAndAttributes,
|
||||
hTemplateFile
|
||||
);
|
||||
}
|
||||
|
||||
typedef int (WINAPI* BIND)(SOCKET, CONST SOCKADDR*, INT);
|
||||
static BIND pbind = NULL;
|
||||
|
||||
@ -728,6 +785,27 @@ static __int64 __fastcall MileageFix(__int64 a1)
|
||||
|
||||
static InitFunction Wmmt6Func([]()
|
||||
{
|
||||
// Alloc debug console
|
||||
FreeConsole();
|
||||
AllocConsole();
|
||||
SetConsoleTitle(L"Maxitune6 Console");
|
||||
|
||||
FILE* pNewStdout = nullptr;
|
||||
FILE* pNewStderr = nullptr;
|
||||
FILE* pNewStdin = nullptr;
|
||||
|
||||
::freopen_s(&pNewStdout, "CONOUT$", "w", stdout);
|
||||
::freopen_s(&pNewStderr, "CONOUT$", "w", stderr);
|
||||
::freopen_s(&pNewStdin, "CONIN$", "r", stdin);
|
||||
std::cout.clear();
|
||||
std::cerr.clear();
|
||||
std::cin.clear();
|
||||
std::wcout.clear();
|
||||
std::wcerr.clear();
|
||||
std::wcin.clear();
|
||||
|
||||
puts("hello there, maxitune");
|
||||
|
||||
// folder for path redirections
|
||||
CreateDirectoryA(".\\TP", nullptr);
|
||||
|
||||
@ -770,9 +848,19 @@ static InitFunction Wmmt6Func([]()
|
||||
MH_CreateHookApi(L"WS2_32", "bind", Hook_bind, reinterpret_cast<LPVOID*>(&pbind));
|
||||
MH_CreateHook((void*)(imageBase + 0x35AAC0), MileageFix, (void**)&g_origMileageFix);
|
||||
|
||||
// Hook createfilea
|
||||
if (MH_CreateHookApi(L"kernel32", "CreateFileA", Hook_CreateFileA, reinterpret_cast<LPVOID*>(&pCreateFileA)) != MH_OK)
|
||||
{
|
||||
puts("failed to hook CreateFileA");
|
||||
}
|
||||
if (MH_CreateHook(&CreateFileW, Hook_CreateFileW, reinterpret_cast<LPVOID*>(&pCreateFileW)) != MH_OK)
|
||||
{
|
||||
puts("failed to hook CreateFileW");
|
||||
}
|
||||
|
||||
GenerateDongleData(isTerminal);
|
||||
|
||||
// wtf is this??
|
||||
// resolves a system error
|
||||
injector::WriteMemory<uint8_t>(hook::get_pattern("0F 94 C0 84 C0 0F 94 C0 84 C0 75 05 45 32 ? EB", 0x13), 0, true);
|
||||
|
||||
// Skip weird camera init that stucks entire pc on certain brands. TESTED ONLY ON 05!!!!
|
||||
@ -782,20 +870,31 @@ static InitFunction Wmmt6Func([]()
|
||||
}
|
||||
|
||||
// wtf is this?
|
||||
injector::MakeNOP(hook::get_pattern("45 33 C0 BA 65 09 00 00 48 8D 4D B0 E8 ? ? ? ? 48 8B 08", 12), 5);
|
||||
//injector::MakeNOP(hook::get_pattern("45 33 C0 BA 65 09 00 00 48 8D 4D B0 E8 ? ? ? ? 48 8B 08", 12), 5);
|
||||
|
||||
auto location = hook::get_pattern<char>("48 83 EC 28 33 D2 B9 70 00 02 00 E8 ? ? ? ? 85 C0 79 06");
|
||||
injector::WriteMemory<uint8_t>(location + 0x12, 0xEB, true);
|
||||
//injector::WriteMemory<uint8_t>(location + 0x12, 0xEB, true);
|
||||
|
||||
// First auth error skip
|
||||
//injector::WriteMemory<BYTE>(imageBase + 0x6A0077, 0xEB, true);
|
||||
injector::WriteMemory<BYTE>(imageBase + 0x6A0077, 0xEB, true);
|
||||
|
||||
if (isTerminal)
|
||||
{
|
||||
// I don't know what these do but they stop the game from
|
||||
// throwing a fit on the dongle error
|
||||
// so I'm leaving them in here.
|
||||
|
||||
// Dongle error?
|
||||
//safeJMP(hook::get_pattern("0F B6 41 05 2C 30 3C 09 77 04 0F BE C0 C3 83 C8 FF C3"), ReturnTrue);
|
||||
|
||||
// More dongle error shit?
|
||||
safeJMP(hook::get_pattern("8B 01 0F B6 40 78 C3 CC CC CC CC"), ReturnTrue);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Terminal on same machine check.
|
||||
injector::MakeNOP(hook::get_pattern("74 ? 80 7B 31 00 75 ? 48 8B 43 10 80 78 31 00 75 1A 48 8B D8 48 8B 00 80 78 31 00 75 ? 48 8B D8"), 2);
|
||||
|
||||
/*
|
||||
injector::WriteMemory<WORD>(imageBase + 0x6A0C87, 0x00D1, true);
|
||||
injector::WriteMemory<BYTE>(imageBase + 0x20B88A, 0x90, true);
|
||||
|
@ -1,20 +1,20 @@
|
||||
#include <StdInc.h>
|
||||
#include <Utility/InitFunction.h>
|
||||
#include "Global.h"
|
||||
#include "Utility/GameDetect.h"
|
||||
#include "Utility/Hooking.Patterns.h"
|
||||
#include <StdInc.h>
|
||||
#include <Utility/InitFunction.h>
|
||||
#include "Global.h"
|
||||
#include "Utility/GameDetect.h"
|
||||
#include "Utility/Hooking.Patterns.h"
|
||||
#include <shlwapi.h>
|
||||
#include <Windows.h>
|
||||
#include "Utility/Helper.h"
|
||||
#include <TlHelp32.h>
|
||||
|
||||
#pragma comment(lib,"shlwapi.lib")
|
||||
#pragma comment(lib,"Winmm.lib")
|
||||
|
||||
#pragma optimize("", off)
|
||||
|
||||
#pragma comment(lib,"shlwapi.lib")
|
||||
#pragma comment(lib,"Winmm.lib")
|
||||
|
||||
#pragma optimize("", off)
|
||||
|
||||
static DWORD xdbg;
|
||||
static HWND g_HWND = NULL;
|
||||
static HWND g_HWND = NULL;
|
||||
static DWORD ProcessID;
|
||||
static bool DisableGhosting;
|
||||
static bool EnableSuspend;
|
||||
@ -25,45 +25,45 @@ static char SuspendBuf[MAX_PATH];
|
||||
static char PauseKeyChar[256];
|
||||
static char ExitKeyChar[256];
|
||||
static int PauseKeyValue;
|
||||
static int ExitKeyValue;
|
||||
|
||||
extern void PauseGameFixes(Helpers* helpers);
|
||||
extern void ResetPauseGameFixes(Helpers* helpers);
|
||||
|
||||
void *__cdecl memcpy_0(void *a1, const void *a2, size_t a3)
|
||||
{
|
||||
__try
|
||||
{
|
||||
memcpy(a1, a2, a3);
|
||||
}
|
||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static HMODULE blaster;
|
||||
|
||||
// used in SR3 and Ford Racing
|
||||
BOOL WINAPI ReadFileHooked(_In_ HANDLE hFile, _Out_writes_bytes_to_opt_(nNumberOfBytesToRead, *lpNumberOfBytesRead) __out_data_source(FILE) LPVOID lpBuffer, _In_ DWORD nNumberOfBytesToRead, _Out_opt_ LPDWORD lpNumberOfBytesRead, _Inout_opt_ LPOVERLAPPED lpOverlapped)
|
||||
{
|
||||
static HANDLE file = CreateFileA("\\\\.\\pipe\\TeknoParrotPipe", GENERIC_READ, 0, nullptr, OPEN_EXISTING, 0, NULL);
|
||||
|
||||
ReadFile(file, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
std::wstring utf8_decode(const std::string &str)
|
||||
{
|
||||
if (str.empty()) return std::wstring();
|
||||
int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
|
||||
std::wstring wstrTo(size_needed, 0);
|
||||
MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
|
||||
return wstrTo;
|
||||
}
|
||||
|
||||
static int ExitKeyValue;
|
||||
|
||||
extern void PauseGameFixes(Helpers* helpers);
|
||||
extern void ResetPauseGameFixes(Helpers* helpers);
|
||||
|
||||
void *__cdecl memcpy_0(void *a1, const void *a2, size_t a3)
|
||||
{
|
||||
__try
|
||||
{
|
||||
memcpy(a1, a2, a3);
|
||||
}
|
||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static HMODULE blaster;
|
||||
|
||||
// used in SR3 and Ford Racing
|
||||
BOOL WINAPI ReadFileHooked(_In_ HANDLE hFile, _Out_writes_bytes_to_opt_(nNumberOfBytesToRead, *lpNumberOfBytesRead) __out_data_source(FILE) LPVOID lpBuffer, _In_ DWORD nNumberOfBytesToRead, _Out_opt_ LPDWORD lpNumberOfBytesRead, _Inout_opt_ LPOVERLAPPED lpOverlapped)
|
||||
{
|
||||
static HANDLE file = CreateFileA("\\\\.\\pipe\\TeknoParrotPipe", GENERIC_READ, 0, nullptr, OPEN_EXISTING, 0, NULL);
|
||||
|
||||
ReadFile(file, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
std::wstring utf8_decode(const std::string &str)
|
||||
{
|
||||
if (str.empty()) return std::wstring();
|
||||
int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
|
||||
std::wstring wstrTo(size_needed, 0);
|
||||
MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
|
||||
return wstrTo;
|
||||
}
|
||||
|
||||
static void QuitGame()
|
||||
{
|
||||
if (GameDetect::currentGame == GameID::Daytona3)
|
||||
@ -225,141 +225,141 @@ DWORD WINAPI GlobalGameThread(__in LPVOID lpParameter)
|
||||
Sleep(16);
|
||||
}
|
||||
}
|
||||
|
||||
/* WINDOW HOOKS */
|
||||
|
||||
DWORD g_windowStyle;
|
||||
|
||||
int g_x = 0;
|
||||
int g_y = 0;
|
||||
|
||||
int g_width = 0;
|
||||
int g_height = 0;
|
||||
|
||||
HWND hwndWindowA;
|
||||
HWND hwndWindowW;
|
||||
|
||||
HWND WINAPI CreateWindowExAHk(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "CreateWindowExAHk called");
|
||||
#endif
|
||||
if (lpWindowName)
|
||||
{
|
||||
dwStyle = g_windowStyle;
|
||||
}
|
||||
|
||||
/* WINDOW HOOKS */
|
||||
|
||||
DWORD g_windowStyle;
|
||||
|
||||
int g_x = 0;
|
||||
int g_y = 0;
|
||||
|
||||
int g_width = 0;
|
||||
int g_height = 0;
|
||||
|
||||
HWND hwndWindowA;
|
||||
HWND hwndWindowW;
|
||||
|
||||
HWND WINAPI CreateWindowExAHk(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "CreateWindowExAHk called");
|
||||
#endif
|
||||
if (lpWindowName)
|
||||
{
|
||||
dwStyle = g_windowStyle;
|
||||
}
|
||||
if (lpWindowName == NULL)
|
||||
{
|
||||
lpWindowName = lpClassName;
|
||||
dwStyle = g_windowStyle;
|
||||
}
|
||||
}
|
||||
// Make window pos centered
|
||||
g_x = (GetSystemMetrics(SM_CXSCREEN) - nWidth) / 2;
|
||||
g_y = (GetSystemMetrics(SM_CYSCREEN) - nHeight) / 2;
|
||||
|
||||
HWND thisWindow = CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, g_x, g_y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
|
||||
|
||||
if (lpWindowName)
|
||||
{
|
||||
hwndWindowA = thisWindow;
|
||||
}
|
||||
|
||||
return thisWindow;
|
||||
}
|
||||
|
||||
HWND WINAPI CreateWindowExWHk(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "CreateWindowExWHk called");
|
||||
#endif
|
||||
g_y = (GetSystemMetrics(SM_CYSCREEN) - nHeight) / 2;
|
||||
|
||||
HWND thisWindow = CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, g_x, g_y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
|
||||
|
||||
if (lpWindowName)
|
||||
{
|
||||
hwndWindowA = thisWindow;
|
||||
}
|
||||
|
||||
return thisWindow;
|
||||
}
|
||||
|
||||
HWND WINAPI CreateWindowExWHk(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "CreateWindowExWHk called");
|
||||
#endif
|
||||
// Calculate window pos centered
|
||||
g_x = (GetSystemMetrics(SM_CXSCREEN) - nWidth) / 2;
|
||||
g_y = (GetSystemMetrics(SM_CYSCREEN) - nHeight) / 2;
|
||||
|
||||
|
||||
if (GameDetect::currentGame == GameID::SF4 && x != 0 && y != 0)
|
||||
{
|
||||
dwStyle = g_windowStyle;
|
||||
return CreateWindowExW(dwExStyle, lpClassName, L"OpenParrot - Street Fighter IV", dwStyle, x, y, 1280, 720, hWndParent, hMenu, hInstance, lpParam);
|
||||
}
|
||||
else if (GameDetect::currentGame == GameID::SF4 && x == 0 && y == 0)
|
||||
{
|
||||
return CreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
|
||||
}
|
||||
|
||||
if (lpWindowName)
|
||||
{
|
||||
dwStyle = g_windowStyle;
|
||||
}
|
||||
g_y = (GetSystemMetrics(SM_CYSCREEN) - nHeight) / 2;
|
||||
|
||||
|
||||
if (GameDetect::currentGame == GameID::SF4 && x != 0 && y != 0)
|
||||
{
|
||||
dwStyle = g_windowStyle;
|
||||
return CreateWindowExW(dwExStyle, lpClassName, L"OpenParrot - Street Fighter IV", dwStyle, x, y, 1280, 720, hWndParent, hMenu, hInstance, lpParam);
|
||||
}
|
||||
else if (GameDetect::currentGame == GameID::SF4 && x == 0 && y == 0)
|
||||
{
|
||||
return CreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
|
||||
}
|
||||
|
||||
if (lpWindowName)
|
||||
{
|
||||
dwStyle = g_windowStyle;
|
||||
}
|
||||
if (lpWindowName == NULL)
|
||||
{
|
||||
lpWindowName = lpClassName;
|
||||
dwStyle = g_windowStyle;
|
||||
}
|
||||
|
||||
HWND thisWindow = CreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, g_x, g_y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
|
||||
|
||||
if (lpWindowName)
|
||||
{
|
||||
hwndWindowW = thisWindow;
|
||||
}
|
||||
|
||||
return thisWindow;
|
||||
}
|
||||
|
||||
BOOL WINAPI AdjustWindowRectHk(LPRECT lpRect, DWORD dwStyle, BOOL bMenu)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "AdjustWindowRectHk called");
|
||||
#endif
|
||||
dwStyle = g_windowStyle;
|
||||
|
||||
return AdjustWindowRect(lpRect, dwStyle, bMenu);
|
||||
}
|
||||
|
||||
BOOL WINAPI AdjustWindowRectExHk(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "AdjustWindowRectExHk called");
|
||||
#endif
|
||||
dwStyle = g_windowStyle;
|
||||
dwExStyle = 0;
|
||||
|
||||
return AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle);
|
||||
}
|
||||
|
||||
BOOL WINAPI SetWindowPosHk(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "SetWindowPosHk called");
|
||||
#endif
|
||||
}
|
||||
|
||||
HWND thisWindow = CreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, g_x, g_y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
|
||||
|
||||
if (lpWindowName)
|
||||
{
|
||||
hwndWindowW = thisWindow;
|
||||
}
|
||||
|
||||
return thisWindow;
|
||||
}
|
||||
|
||||
BOOL WINAPI AdjustWindowRectHk(LPRECT lpRect, DWORD dwStyle, BOOL bMenu)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "AdjustWindowRectHk called");
|
||||
#endif
|
||||
dwStyle = g_windowStyle;
|
||||
|
||||
return AdjustWindowRect(lpRect, dwStyle, bMenu);
|
||||
}
|
||||
|
||||
BOOL WINAPI AdjustWindowRectExHk(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "AdjustWindowRectExHk called");
|
||||
#endif
|
||||
dwStyle = g_windowStyle;
|
||||
dwExStyle = 0;
|
||||
|
||||
return AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle);
|
||||
}
|
||||
|
||||
BOOL WINAPI SetWindowPosHk(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "SetWindowPosHk called");
|
||||
#endif
|
||||
// Make window pos centered
|
||||
int xPos = (GetSystemMetrics(SM_CXSCREEN) - cx) / 2;
|
||||
int yPos = (GetSystemMetrics(SM_CYSCREEN) - cy) / 2;
|
||||
|
||||
if (hwndWindowA == hWnd || hwndWindowW == hWnd)
|
||||
{
|
||||
X = xPos;
|
||||
Y = yPos;
|
||||
}
|
||||
int yPos = (GetSystemMetrics(SM_CYSCREEN) - cy) / 2;
|
||||
|
||||
if (hwndWindowA == hWnd || hwndWindowW == hWnd)
|
||||
{
|
||||
X = xPos;
|
||||
Y = yPos;
|
||||
}
|
||||
if (hWndInsertAfter == HWND_TOPMOST)
|
||||
{
|
||||
hWndInsertAfter = HWND_TOP;
|
||||
}
|
||||
|
||||
return SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
|
||||
}
|
||||
|
||||
LONG __stdcall ChangeDisplaySettingsHk(DEVMODEA *lpDevMode, DWORD dwFlags)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "ChangeDisplaySettingsHk called");
|
||||
#endif
|
||||
lpDevMode = NULL; // retain original changes instead of applying modified values
|
||||
|
||||
return ChangeDisplaySettingsA(lpDevMode, dwFlags);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
|
||||
}
|
||||
|
||||
LONG __stdcall ChangeDisplaySettingsHk(DEVMODEA *lpDevMode, DWORD dwFlags)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "ChangeDisplaySettingsHk called");
|
||||
#endif
|
||||
lpDevMode = NULL; // retain original changes instead of applying modified values
|
||||
|
||||
return ChangeDisplaySettingsA(lpDevMode, dwFlags);
|
||||
}
|
||||
|
||||
LONG __stdcall ChangeDisplaySettingsExWHk(LPCWSTR lpszDeviceName, DEVMODEW* lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
@ -368,85 +368,85 @@ LONG __stdcall ChangeDisplaySettingsExWHk(LPCWSTR lpszDeviceName, DEVMODEW* lpDe
|
||||
lpDevMode = NULL; // retain original changes instead of applying modified values
|
||||
|
||||
return ChangeDisplaySettingsExW(lpszDeviceName, lpDevMode, hwnd, dwflags, lParam);
|
||||
}
|
||||
|
||||
BOOL WINAPI UpdateWindowHk(HWND hWnd)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOL WINAPI UpdateWindowHk(HWND hWnd)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL WINAPI ClipCursorHk(const RECT* lpRect)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOL WINAPI SetCursorPosHk(int X, int Y)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void init_windowHooks(windowHooks* data)
|
||||
{
|
||||
g_windowStyle = WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
|
||||
|
||||
int rx, ry;
|
||||
GetDesktopResolution(rx, ry);
|
||||
|
||||
g_x = (rx / 2) - (g_width / 2);
|
||||
g_y = (ry / 2) - (g_height / 2);
|
||||
|
||||
if (data->createWindowExA != NULL)
|
||||
{
|
||||
*(HWND*)data->createWindowExA = (HWND)CreateWindowExAHk;
|
||||
}
|
||||
|
||||
if (data->createWindowExW != NULL)
|
||||
{
|
||||
*(HWND*)data->createWindowExW = (HWND)CreateWindowExWHk;
|
||||
}
|
||||
|
||||
if (data->adjustWindowRect != NULL)
|
||||
{
|
||||
*(BOOL*)data->adjustWindowRect = (BOOL)AdjustWindowRectHk;
|
||||
}
|
||||
|
||||
if (data->adjustWindowRectEx != NULL)
|
||||
{
|
||||
*(BOOL*)data->adjustWindowRectEx = (BOOL)AdjustWindowRectExHk;
|
||||
}
|
||||
|
||||
if (data->setWindowPos != NULL)
|
||||
{
|
||||
*(BOOL*)data->setWindowPos = (BOOL)SetWindowPosHk;
|
||||
}
|
||||
|
||||
if (data->changeDisplaySettings != NULL)
|
||||
{
|
||||
*(LONG*)data->changeDisplaySettings = (LONG)ChangeDisplaySettingsHk;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOL WINAPI SetCursorPosHk(int X, int Y)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void init_windowHooks(windowHooks* data)
|
||||
{
|
||||
g_windowStyle = WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
|
||||
|
||||
int rx, ry;
|
||||
GetDesktopResolution(rx, ry);
|
||||
|
||||
g_x = (rx / 2) - (g_width / 2);
|
||||
g_y = (ry / 2) - (g_height / 2);
|
||||
|
||||
if (data->createWindowExA != NULL)
|
||||
{
|
||||
*(HWND*)data->createWindowExA = (HWND)CreateWindowExAHk;
|
||||
}
|
||||
|
||||
if (data->createWindowExW != NULL)
|
||||
{
|
||||
*(HWND*)data->createWindowExW = (HWND)CreateWindowExWHk;
|
||||
}
|
||||
|
||||
if (data->adjustWindowRect != NULL)
|
||||
{
|
||||
*(BOOL*)data->adjustWindowRect = (BOOL)AdjustWindowRectHk;
|
||||
}
|
||||
|
||||
if (data->adjustWindowRectEx != NULL)
|
||||
{
|
||||
*(BOOL*)data->adjustWindowRectEx = (BOOL)AdjustWindowRectExHk;
|
||||
}
|
||||
|
||||
if (data->setWindowPos != NULL)
|
||||
{
|
||||
*(BOOL*)data->setWindowPos = (BOOL)SetWindowPosHk;
|
||||
}
|
||||
|
||||
if (data->changeDisplaySettings != NULL)
|
||||
{
|
||||
*(LONG*)data->changeDisplaySettings = (LONG)ChangeDisplaySettingsHk;
|
||||
}
|
||||
|
||||
if (data->changeDisplaySettingsExW != NULL)
|
||||
{
|
||||
*(LONG*)data->changeDisplaySettingsExW = (LONG)ChangeDisplaySettingsExWHk;
|
||||
}
|
||||
|
||||
if (data->updateWindow != NULL)
|
||||
{
|
||||
*(BOOL*)data->updateWindow = (BOOL)UpdateWindowHk;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (data->updateWindow != NULL)
|
||||
{
|
||||
*(BOOL*)data->updateWindow = (BOOL)UpdateWindowHk;
|
||||
}
|
||||
|
||||
if (data->clipCursor != NULL)
|
||||
{
|
||||
*(BOOL*)data->clipCursor = (BOOL)ClipCursorHk;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (data->setCursorPos != NULL)
|
||||
{
|
||||
*(BOOL*)data->setCursorPos = (BOOL)SetCursorPosHk;
|
||||
}
|
||||
}
|
||||
/* END WINDOW HOOKS */
|
||||
|
||||
}
|
||||
}
|
||||
/* END WINDOW HOOKS */
|
||||
|
||||
DWORD FetchDwordInformation(const char* setting, const char* subkey, DWORD defaultValue)
|
||||
{
|
||||
try
|
||||
@ -464,12 +464,12 @@ DWORD FetchDwordInformation(const char* setting, const char* subkey, DWORD defau
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
static InitFunction globalFunc([]()
|
||||
{
|
||||
hook::pattern::InitializeHints();
|
||||
|
||||
}
|
||||
|
||||
static InitFunction globalFunc([]()
|
||||
{
|
||||
hook::pattern::InitializeHints();
|
||||
|
||||
GetPrivateProfileStringA("GlobalHotkeys", "PauseKey", "", PauseKeyChar, 256, ".\\teknoparrot.ini");
|
||||
GetPrivateProfileStringA("GlobalHotkeys", "ExitKey", "", ExitKeyChar, 256, ".\\teknoparrot.ini");
|
||||
|
||||
@ -489,8 +489,8 @@ static InitFunction globalFunc([]()
|
||||
|
||||
ProcessID = MyGetProcessId(tchar);
|
||||
|
||||
CreateThread(NULL, 0, GlobalGameThread, NULL, 0, NULL);
|
||||
|
||||
CreateThread(NULL, 0, GlobalGameThread, NULL, 0, NULL);
|
||||
|
||||
if (ToBool(config["General"]["Enable Outputs"]))
|
||||
{
|
||||
blaster = LoadLibraryA("OutputBlaster.dll");
|
||||
@ -533,6 +533,6 @@ static InitFunction globalFunc([]()
|
||||
{
|
||||
printf("Failed to load Score Submission!");
|
||||
}
|
||||
}
|
||||
}, GameID::Global);
|
||||
}
|
||||
}, GameID::Global);
|
||||
#pragma optimize("", on)
|
Loading…
Reference in New Issue
Block a user