1
0
mirror of synced 2025-02-01 12:17:55 +01:00

Merge pull request #38 from 00C0FFEE/FNFfixes2

Fn ffixes2
This commit is contained in:
Reaver 2019-05-21 20:30:22 +03:00 committed by GitHub
commit 836495565e
2 changed files with 271 additions and 157 deletions

View File

@ -14,8 +14,8 @@ DWORD BaseAddress3 = 0x00400000;
int horizontal3 = 0; int horizontal3 = 0;
int vertical3 = 0; int vertical3 = 0;
HWND hWndRT3 = 0; HWND hWndRT3 = 0;
bool movable = false; bool movable3 = false;
bool polling = false; bool polling3 = false;
static bool previousLeft = false; static bool previousLeft = false;
static bool previousRight = false; static bool previousRight = false;
@ -23,6 +23,10 @@ static bool previousUp = false;
static bool previousDown = false; static bool previousDown = false;
static bool gaspressed = false; static bool gaspressed = false;
static bool brakepressed = false; static bool brakepressed = false;
static bool button1pressed = false;
static bool button2pressed = false;
static bool button3pressed = false;
static bool button4pressed = false;
// controls // controls
extern int* ffbOffset; extern int* ffbOffset;
@ -43,52 +47,47 @@ DWORD WINAPI DefWindowProcART3(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
switch (message) switch (message)
{ {
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
// CURSOR NOT HIDDEN ShowCursor(TRUE);
injector::WriteMemory<BYTE>((0x4BF1F + BaseAddress3), 0x01, true); movable3 = true;
SetCapture(hWnd);
xClick = LOWORD(lParam); xClick = LOWORD(lParam);
yClick = HIWORD(lParam); yClick = HIWORD(lParam);
movable = true;
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
ReleaseCapture(); ShowCursor(NULL);
movable = false; movable3 = false;
break; break;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
{ {
if (movable == true) if ((movable3 == true) && (ToBool(config["General"]["Windowed"])))
{
if (GetCapture() == hWnd)
{ {
ShowCursor(TRUE);
RECT rcWindow; RECT rcWindow;
GetWindowRect(hWnd, &rcWindow); GetWindowRect(hWnd, &rcWindow);
int width = rcWindow.right - rcWindow.left;
int height = rcWindow.bottom - rcWindow.top;
int xMouse = LOWORD(lParam); int xMouse = LOWORD(lParam);
int yMouse = HIWORD(lParam); int yMouse = HIWORD(lParam);
int xWindow = rcWindow.left + xMouse - xClick; int xWindow = rcWindow.left + xMouse - xClick;
int yWindow = rcWindow.top + yMouse - yClick; int yWindow = rcWindow.top + yMouse - yClick;
original_SetWindowPos3(hWnd, HWND_TOP, xWindow, yWindow, 0, 0, SWP_NOSIZE | SWP_NOZORDER); if (xWindow >= (horizontal3 - 100))
} xWindow = 0;
break; if (yWindow >= (vertical3 - 100))
yWindow = 0;
original_SetWindowPos3(hWnd, NULL, xWindow, yWindow, width, height, SWP_NOSIZE | SWP_NOZORDER);
return 0;
} }
else else
{ {
if (polling == false) if (polling3 == false)
{ {
ShowCursor(NULL);
return 0; return 0;
} }
if (polling == true) if (polling3 == true)
{ {
RECT rect; ShowCursor(FALSE);
GetWindowRect(hWndRT3, &rect);
int width = rect.right - rect.left;
int iWheel0 = (((float)*ffbOffset2) - 128);
float wheel = (iWheel0 * 0.0078125f);
int iWheel = (int)(horizontal3 * 0.5 * wheel);
int xPad = (int)(iWheel + (horizontal3 * 0.5));
lParam = MAKELPARAM(xPad, (vertical3 * 0.5));
break; break;
} }
} }
@ -102,7 +101,6 @@ DWORD WINAPI InputRT3(LPVOID lpParam)
int deltaTimer = 16; int deltaTimer = 16;
INT_PTR keyboardBuffer = (0x31B6988 + BaseAddress3); INT_PTR keyboardBuffer = (0x31B6988 + BaseAddress3);
while (true) while (true)
{ {
// ESCAPE QUITS GAME // ESCAPE QUITS GAME
@ -111,13 +109,6 @@ DWORD WINAPI InputRT3(LPVOID lpParam)
exit(0); exit(0);
} }
if (hWndRT3 == 0)
{
hWndRT3 = FindWindowA(NULL, "Fast n Furious");
}
HWND hWndTMP = GetForegroundWindow();
if (hWndTMP == hWndRT3)
{
// buttons see bitwise values in TPui//RawThrills.cs // buttons see bitwise values in TPui//RawThrills.cs
// START // START
if (*ffbOffset & 0x08) if (*ffbOffset & 0x08)
@ -131,9 +122,20 @@ DWORD WINAPI InputRT3(LPVOID lpParam)
} }
// NITRO ( = START too) // NITRO ( = START too)
if (*ffbOffset & 0x100) if (*ffbOffset & 0x100)
{
if (button1pressed == false)
{ {
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_N), 2, true); injector::WriteMemory<BYTE>((keyboardBuffer + DIK_N), 2, true);
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_SPACE), 2, true); injector::WriteMemory<BYTE>((keyboardBuffer + DIK_SPACE), 2, true);
button1pressed = true;
}
}
else
{
if (button1pressed == true)
{
button1pressed = false;
}
} }
// SHIFT DOWN // SHIFT DOWN
if (*ffbOffset & 0x2000) if (*ffbOffset & 0x2000)
@ -170,20 +172,57 @@ DWORD WINAPI InputRT3(LPVOID lpParam)
// BUTTON 1/ VIEW 1 // BUTTON 1/ VIEW 1
if (*ffbOffset & 0x200) if (*ffbOffset & 0x200)
{ {
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_F1), 2, true); if (button2pressed == false)
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_A), 2, true); {
injector::MakeNOP((0x35BA5 + BaseAddress3), 2);
keybd_event(0x70, MapVirtualKey(0x70, MAPVK_VK_TO_VSC), 0, 0);
button2pressed = true;
}
}
else
{
if (button2pressed == true)
{
injector::WriteMemoryRaw((0x35BA5 + BaseAddress3), "\x74\x46", 2, true);
keybd_event(0x70, MapVirtualKey(0x70, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
button2pressed = false;
}
} }
// BUTTON 2/ VIEW 2 // BUTTON 2/ VIEW 2
if (*ffbOffset & 0x400) if (*ffbOffset & 0x400)
if (button3pressed == false)
{
{ {
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_F2), 2, true);
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_B), 2, true); injector::WriteMemory<BYTE>((keyboardBuffer + DIK_B), 2, true);
keybd_event(0x71, MapVirtualKey(0x71, MAPVK_VK_TO_VSC), 0, 0);
button3pressed = true;
}
}
else
{
if (button3pressed == true)
{
keybd_event(0x70, MapVirtualKey(0x71, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
button3pressed = false;
}
} }
// BUTTON 3/ VIEW 3 // BUTTON 3/ VIEW 3
if (*ffbOffset & 0x800) if (*ffbOffset & 0x800)
{
if (button4pressed == false)
{ {
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_E), 2, true); injector::WriteMemory<BYTE>((keyboardBuffer + DIK_E), 2, true);
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_W), 2, true); keybd_event(0x73, MapVirtualKey(0x73, MAPVK_VK_TO_VSC), 0, 0);
button4pressed = true;
}
}
else
{
if (button4pressed == true)
{
keybd_event(0x73, MapVirtualKey(0x73, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
button4pressed = false;
}
} }
// MENU LEFT // MENU LEFT
if (*ffbOffset & 0x4000) if (*ffbOffset & 0x4000)
@ -218,21 +257,32 @@ DWORD WINAPI InputRT3(LPVOID lpParam)
} }
} }
if (movable == false) // then poll ugly mouse input RECT rect;
GetWindowRect(hWndRT3, &rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
int windowcenterx = (rect.left + (width * 0.5));
int windowcentery = (rect.top + (height * 0.5));
// WHEEL
int iWheel0 = (((float)*ffbOffset2) - 128);
float wheel = (iWheel0 * 0.0078125f);
int iWheel = (int)((width - 20) * 0.5 * wheel);
double fx = (float)((wheel) * (65535.0f / horizontal3));
if (movable3 == false) // then poll ugly mouse input
{ {
polling = true; polling3 = true;
mouse_event(MOUSEEVENTF_MOVE, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_MOVE, fx, 0, 0, 0);
polling = false; polling3 = false;
} }
WORD vkey;
// GAS // GAS
vkey = 0x51; // Q key (qwerty A)
if (*ffbOffset3 >= 5) if (*ffbOffset3 >= 5)
{ {
if (gaspressed == false) if (gaspressed == false)
{ {
keybd_event(vkey, MapVirtualKey(vkey, MAPVK_VK_TO_VSC), 0, 0); keybd_event(0x51, MapVirtualKey(0x51, MAPVK_VK_TO_VSC), 0, 0); // Q key (qwerty A)
keybd_event(0x41, MapVirtualKey(0x41, MAPVK_VK_TO_VSC), 0, 0); // A key
gaspressed = true; gaspressed = true;
} }
} }
@ -240,18 +290,19 @@ DWORD WINAPI InputRT3(LPVOID lpParam)
{ {
if (gaspressed == true) if (gaspressed == true)
{ {
keybd_event(vkey, MapVirtualKey(vkey, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0); keybd_event(0x51, MapVirtualKey(0x51, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
keybd_event(0x41, MapVirtualKey(0x41, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
gaspressed = false; gaspressed = false;
} }
} }
// BRAKE // BRAKE
vkey = 0x57; // W key (qwerty Z)
if (*ffbOffset4 >= 5) if (*ffbOffset4 >= 5)
{ {
if (brakepressed == false) if (brakepressed == false)
{ {
keybd_event(vkey, MapVirtualKey(vkey, MAPVK_VK_TO_VSC), 0, 0); keybd_event(0x57, MapVirtualKey(0x57, MAPVK_VK_TO_VSC), 0, 0); // W key (qwerty Z)
keybd_event(0x5A, MapVirtualKey(0x5A, MAPVK_VK_TO_VSC), 0, 0); // Z key
brakepressed = true; brakepressed = true;
} }
} }
@ -259,7 +310,8 @@ DWORD WINAPI InputRT3(LPVOID lpParam)
{ {
if (brakepressed == true) if (brakepressed == true)
{ {
keybd_event(vkey, MapVirtualKey(vkey, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0); keybd_event(0x57, MapVirtualKey(0x57, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
keybd_event(0x5A, MapVirtualKey(0x5A, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
brakepressed = false; brakepressed = false;
} }
} }
@ -270,7 +322,6 @@ DWORD WINAPI InputRT3(LPVOID lpParam)
Sleep(deltaTimer); Sleep(deltaTimer);
} }
}
return 0; return 0;
} }
@ -289,7 +340,6 @@ DWORD WINAPI WindowRT3(LPVOID lpParam)
if (hWndTMP == hWndRT3) if (hWndTMP == hWndRT3)
{ {
ShowCursor(TRUE); ShowCursor(TRUE);
movable = true;
original_SetWindowPos3(hWndRT3, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE); original_SetWindowPos3(hWndRT3, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE);
ShowWindow(hWndRT3, SW_MINIMIZE); ShowWindow(hWndRT3, SW_MINIMIZE);
} }
@ -304,13 +354,7 @@ DWORD WINAPI CreateWindowExART3(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWi
DWORD WINAPI SetCursorPosRT3(int X, int Y) DWORD WINAPI SetCursorPosRT3(int X, int Y)
{ {
RECT rect; return 0;
GetWindowRect(hWndRT3, &rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
int windowcenterx = (rect.left + (width * 0.5));
int windowcentery = (rect.top + (height * 0.5));
return original_SetCursorPosRT3(windowcenterx, windowcentery);
} }
DWORD WINAPI SetWindowPosRT3(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags) DWORD WINAPI SetWindowPosRT3(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
@ -322,6 +366,15 @@ static InitFunction FNFFunc([]()
{ {
GetDesktopResolution(horizontal3, vertical3); GetDesktopResolution(horizontal3, vertical3);
// BUTTON VIEW 1 HACK
injector::WriteMemory<BYTE>((0x35B9A + BaseAddress3), DIK_F1, true);
// BUTTON VIEW 3 HACK
injector::WriteMemory<BYTE>((0x83739 + BaseAddress3), DIK_F4, true);
// DISABLE CURSOR RESET
injector::WriteMemory<BYTE>((0x4C489 + BaseAddress3), 0xEB, true);
// REMOVE ERROR MESSAGEBOX ON CLOSE // REMOVE ERROR MESSAGEBOX ON CLOSE
injector::WriteMemory<BYTE>((0x4CC2A + BaseAddress3), 0xEB, true); injector::WriteMemory<BYTE>((0x4CC2A + BaseAddress3), 0xEB, true);
@ -338,21 +391,24 @@ static InitFunction FNFFunc([]()
MH_Initialize(); MH_Initialize();
MH_CreateHookApi(L"user32.dll", "SetCursorPos", &SetCursorPosRT3, (void**)&original_SetCursorPosRT3); MH_CreateHookApi(L"user32.dll", "SetCursorPos", &SetCursorPosRT3, (void**)&original_SetCursorPosRT3);
MH_CreateHookApi(L"user32.dll", "DefWindowProcA", &DefWindowProcART3, (void**)&original_DefWindowProcA3); MH_CreateHookApi(L"user32.dll", "DefWindowProcA", &DefWindowProcART3, (void**)&original_DefWindowProcA3);
MH_CreateHookApi(L"user32.dll", "SetWindowPos", &SetWindowPosRT3, (void**)&original_SetWindowPos3);
MH_EnableHook(MH_ALL_HOOKS); MH_EnableHook(MH_ALL_HOOKS);
CreateThread(NULL, 0, InputRT3, NULL, 0, NULL); CreateThread(NULL, 0, InputRT3, NULL, 0, NULL);
if (ToBool(config["General"]["Windowed"])) if (ToBool(config["General"]["Windowed"]))
{ {
// CURSOR NOT HIDDEN
//injector::WriteMemory<BYTE>((0x4BF1F + BaseAddress3), 0x01, true);
CreateThread(NULL, 0, WindowRT3, NULL, 0, NULL); CreateThread(NULL, 0, WindowRT3, NULL, 0, NULL);
MH_Initialize(); MH_Initialize();
MH_CreateHookApi(L"user32.dll", "CreateWindowExA", &CreateWindowExART3, (void**)&original_CreateWindowExA3); MH_CreateHookApi(L"user32.dll", "CreateWindowExA", &CreateWindowExART3, (void**)&original_CreateWindowExA3);
MH_CreateHookApi(L"user32.dll", "SetWindowPos", &SetWindowPosRT3, (void**)&original_SetWindowPos3);
MH_EnableHook(MH_ALL_HOOKS); MH_EnableHook(MH_ALL_HOOKS);
} }
// else
// {
// // BROKEN RESOLUTION PATCH WHEN FULLSCREEN
// injector::WriteMemory<DWORD>((0x135954 + BaseAddress3), horizontal3, true);
// injector::WriteMemory<DWORD>((0x135958 + BaseAddress3), vertical3, true);
// }
}, GameID::FNF); }, GameID::FNF);

View File

@ -21,6 +21,10 @@ static bool previousUp = false;
static bool previousDown = false; static bool previousDown = false;
static bool gaspressed = false; static bool gaspressed = false;
static bool brakepressed = false; static bool brakepressed = false;
static bool button1pressed = false;
static bool button2pressed = false;
static bool button3pressed = false;
static bool button4pressed = false;
// controls // controls
extern int* ffbOffset; extern int* ffbOffset;
@ -41,32 +45,47 @@ DWORD WINAPI DefWindowProcART4(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
switch (message) switch (message)
{ {
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
injector::WriteMemory<BYTE>((0x576CF + BaseAddress4), 0x01, true); ShowCursor(TRUE);
movable4 = true; movable4 = true;
xClick = LOWORD(lParam);
yClick = HIWORD(lParam);
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
injector::WriteMemory<BYTE>((0x576CF + BaseAddress4), 0x00, true); ShowCursor(NULL);
movable4 = false; movable4 = false;
break; break;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
{ {
if (movable4 == true) if ((movable4 == true) && (ToBool(config["General"]["Windowed"])))
{ {
injector::WriteMemory<BYTE>((0x576CF + BaseAddress4), 0x01, true); ShowCursor(TRUE);
RECT rcWindow;
GetWindowRect(hWnd, &rcWindow);
int width = rcWindow.right - rcWindow.left;
int height = rcWindow.bottom - rcWindow.top;
int xMouse = LOWORD(lParam);
int yMouse = HIWORD(lParam);
int xWindow = rcWindow.left + xMouse - xClick;
int yWindow = rcWindow.top + yMouse - yClick;
if (xWindow >= (horizontal4 - 100))
xWindow = 0;
if (yWindow >= (vertical4 - 100))
yWindow = 0;
original_SetWindowPos4(hWnd, NULL, xWindow, yWindow, width, height, SWP_NOSIZE | SWP_NOZORDER);
return 0; return 0;
} }
else else
{ {
if (polling4 == false) if (polling4 == false)
{ {
injector::WriteMemory<BYTE>((0x576CF + BaseAddress4), 0x01, true); ShowCursor(NULL);
return 0; return 0;
} }
if (polling4 == true) if (polling4 == true)
{ {
injector::WriteMemory<BYTE>((0x576CF + BaseAddress4), 0x00, true); ShowCursor(NULL);
break; break;
} }
} }
@ -79,10 +98,6 @@ DWORD WINAPI InputRT4(LPVOID lpParam)
{ {
int deltaTimer = 16; int deltaTimer = 16;
INT_PTR keyboardBuffer = (0x31943C8 + BaseAddress4); INT_PTR keyboardBuffer = (0x31943C8 + BaseAddress4);
bool previousLeft = false;
bool previousRight = false;
bool previousUp = false;
bool previousDown = false;
while (true) while (true)
{ {
@ -106,28 +121,107 @@ DWORD WINAPI InputRT4(LPVOID lpParam)
} }
// NITRO ( = START too) // NITRO ( = START too)
if (*ffbOffset & 0x100) if (*ffbOffset & 0x100)
{
if (button1pressed == false)
{ {
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_N), 2, true); injector::WriteMemory<BYTE>((keyboardBuffer + DIK_N), 2, true);
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_SPACE), 2, true); injector::WriteMemory<BYTE>((keyboardBuffer + DIK_SPACE), 2, true);
button1pressed = true;
}
}
else
{
if (button1pressed == true)
{
button1pressed = false;
}
}
// SHIFT DOWN
if (*ffbOffset & 0x2000)
{
if (previousDown == false)
{
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_DOWN), 2, true);
previousDown = true;
}
}
else
{
if (previousDown == true)
{
previousDown = false;
}
}
// SHIFT UP
if (*ffbOffset & 0x1000)
{
if (previousUp == false)
{
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_UP), 2, true);
previousUp = true;
}
}
else
{
if (previousUp == true)
{
previousUp = false;
}
} }
// BUTTON 1/ VIEW 1 // BUTTON 1/ VIEW 1
if (*ffbOffset & 0x200) if (*ffbOffset & 0x200)
{ {
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_F1), 2, true); if (button2pressed == false)
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_A), 2, true); {
injector::MakeNOP((0x35BA5 + BaseAddress4), 2);
keybd_event(0x70, MapVirtualKey(0x70, MAPVK_VK_TO_VSC), 0, 0);
button2pressed = true;
}
}
else
{
if (button2pressed == true)
{
injector::WriteMemoryRaw((0x35BA5 + BaseAddress4), "\x74\x46", 2, true);
keybd_event(0x70, MapVirtualKey(0x70, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
button2pressed = false;
}
} }
// BUTTON 2/ VIEW 2 // BUTTON 2/ VIEW 2
if (*ffbOffset & 0x400) if (*ffbOffset & 0x400)
if (button3pressed == false)
{
{ {
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_F2), 2, true);
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_B), 2, true); injector::WriteMemory<BYTE>((keyboardBuffer + DIK_B), 2, true);
keybd_event(0x71, MapVirtualKey(0x71, MAPVK_VK_TO_VSC), 0, 0);
button3pressed = true;
}
}
else
{
if (button3pressed == true)
{
keybd_event(0x70, MapVirtualKey(0x71, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
button3pressed = false;
}
} }
// BUTTON 3/ VIEW 3 // BUTTON 3/ VIEW 3
if (*ffbOffset & 0x800) if (*ffbOffset & 0x800)
{
if (button4pressed == false)
{ {
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_E), 2, true); injector::WriteMemory<BYTE>((keyboardBuffer + DIK_E), 2, true);
injector::WriteMemory<BYTE>((keyboardBuffer + DIK_W), 2, true); keybd_event(0x73, MapVirtualKey(0x73, MAPVK_VK_TO_VSC), 0, 0);
button4pressed = true;
}
}
else
{
if (button4pressed == true)
{
keybd_event(0x73, MapVirtualKey(0x73, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
button4pressed = false;
}
} }
// MENU LEFT // MENU LEFT
if (*ffbOffset & 0x4000) if (*ffbOffset & 0x4000)
@ -181,14 +275,13 @@ DWORD WINAPI InputRT4(LPVOID lpParam)
polling4 = false; polling4 = false;
} }
WORD vkey;
// GAS // GAS
vkey = 0x51; // Q key (qwerty A)
if (*ffbOffset3 >= 5) if (*ffbOffset3 >= 5)
{ {
if (gaspressed == false) if (gaspressed == false)
{ {
keybd_event(vkey, MapVirtualKey(vkey, MAPVK_VK_TO_VSC), 0, 0); keybd_event(0x51, MapVirtualKey(0x51, MAPVK_VK_TO_VSC), 0, 0); // Q key (qwerty A)
keybd_event(0x41, MapVirtualKey(0x41, MAPVK_VK_TO_VSC), 0, 0); // A key
gaspressed = true; gaspressed = true;
} }
} }
@ -196,18 +289,19 @@ DWORD WINAPI InputRT4(LPVOID lpParam)
{ {
if (gaspressed == true) if (gaspressed == true)
{ {
keybd_event(vkey, MapVirtualKey(vkey, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0); keybd_event(0x51, MapVirtualKey(0x51, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
keybd_event(0x41, MapVirtualKey(0x41, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
gaspressed = false; gaspressed = false;
} }
} }
// BRAKE // BRAKE
vkey = 0x57; // W key (qwerty Z)
if (*ffbOffset4 >= 5) if (*ffbOffset4 >= 5)
{ {
if (brakepressed == false) if (brakepressed == false)
{ {
keybd_event(vkey, MapVirtualKey(vkey, MAPVK_VK_TO_VSC), 0, 0); keybd_event(0x57, MapVirtualKey(0x57, MAPVK_VK_TO_VSC), 0, 0); // W key (qwerty Z)
keybd_event(0x5A, MapVirtualKey(0x5A, MAPVK_VK_TO_VSC), 0, 0); // Z key
brakepressed = true; brakepressed = true;
} }
} }
@ -215,7 +309,8 @@ DWORD WINAPI InputRT4(LPVOID lpParam)
{ {
if (brakepressed == true) if (brakepressed == true)
{ {
keybd_event(vkey, MapVirtualKey(vkey, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0); keybd_event(0x57, MapVirtualKey(0x57, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
keybd_event(0x5A, MapVirtualKey(0x5A, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
brakepressed = false; brakepressed = false;
} }
} }
@ -244,50 +339,11 @@ DWORD WINAPI WindowRT4(LPVOID lpParam)
} }
if (hWndTMP == hWndRT4) if (hWndTMP == hWndRT4)
{ {
injector::WriteMemory<BYTE>((0x576CF + BaseAddress4), 0x01, true); ShowCursor(TRUE);
movable4 = true;
original_SetWindowPos4(hWndRT4, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE); original_SetWindowPos4(hWndRT4, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE);
ShowWindow(hWndRT4, SW_MINIMIZE); ShowWindow(hWndRT4, SW_MINIMIZE);
} }
} }
// LEFT-CLICK MOVES WINDOW FROM TOP-LEFT CORNER
if (GetAsyncKeyState(VK_LBUTTON) & 0x8000)
{
HWND hWndTMP = GetForegroundWindow();
if (hWndRT4 == 0)
{
hWndRT4 = FindWindowA(NULL, "Fast n Furious SuperBikes");
}
if (hWndTMP == hWndRT4)
{
injector::WriteMemory<BYTE>((0x576CF + BaseAddress4), 0x01, true);
movable4 = true;
POINT point;
GetCursorPos(&point);
RECT rect;
GetWindowRect(hWndRT4, &rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
LPARAM blah = MAKELPARAM(point.x, point.y);
int xClick = LOWORD(blah) +10;
int yClick = HIWORD(blah) +10;
if ((xClick + width) > horizontal4)
{
xClick = ((horizontal4 - width) + 10);
}
if ((yClick + height) > vertical4)
{
yClick = ((vertical4 - height)+10);
}
original_SetWindowPos4(hWndRT4, HWND_TOP, xClick, yClick, width, height, SWP_NOSIZE);
SetForegroundWindow(hWndRT4);
}
}
else
{
injector::WriteMemory<BYTE>((0x576CF + BaseAddress4), 0x00, true);
movable4 = false;
}
} }
} }
@ -297,22 +353,9 @@ DWORD WINAPI CreateWindowExART4(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWi
} }
DWORD WINAPI SetCursorPosRT4(int X, int Y) DWORD WINAPI SetCursorPosRT4(int X, int Y)
{
if ((movable4 == false) && (polling4 == false))
{
RECT rect;
GetWindowRect(hWndRT4, &rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
int windowcenterx = (rect.left + (width * 0.5));
int windowcentery = (rect.top + (height * 0.5));
return original_SetCursorPosRT4(windowcenterx, windowcentery);
}
else
{ {
return 0; return 0;
} }
}
DWORD WINAPI SetWindowPosRT4(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags) DWORD WINAPI SetWindowPosRT4(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
{ {
@ -323,6 +366,15 @@ static InitFunction FNFSBFunc([]()
{ {
GetDesktopResolution(horizontal4, vertical4); GetDesktopResolution(horizontal4, vertical4);
// BUTTON VIEW 1 HACK
injector::WriteMemory<BYTE>((0x3A51E + BaseAddress4), DIK_F1, true);
// BUTTON VIEW 3 HACK
injector::WriteMemory<BYTE>((0xB7BC9 + BaseAddress4), DIK_F4, true);
// DISABLE CURSOR RESET
injector::WriteMemory<BYTE>((0x57C19 + BaseAddress4), 0xEB, true);
// REMOVE ERROR MESSAGEBOX ON CLOSE // REMOVE ERROR MESSAGEBOX ON CLOSE
injector::WriteMemory<BYTE>((0x584AA + BaseAddress4), 0xEB, true); injector::WriteMemory<BYTE>((0x584AA + BaseAddress4), 0xEB, true);
@ -340,6 +392,7 @@ static InitFunction FNFSBFunc([]()
MH_Initialize(); MH_Initialize();
MH_CreateHookApi(L"user32.dll", "SetCursorPos", &SetCursorPosRT4, (void**)&original_SetCursorPosRT4); MH_CreateHookApi(L"user32.dll", "SetCursorPos", &SetCursorPosRT4, (void**)&original_SetCursorPosRT4);
MH_CreateHookApi(L"user32.dll", "DefWindowProcA", &DefWindowProcART4, (void**)&original_DefWindowProcA4); MH_CreateHookApi(L"user32.dll", "DefWindowProcA", &DefWindowProcART4, (void**)&original_DefWindowProcA4);
MH_CreateHookApi(L"user32.dll", "SetWindowPos", &SetWindowPosRT4, (void**)&original_SetWindowPos4);
MH_EnableHook(MH_ALL_HOOKS); MH_EnableHook(MH_ALL_HOOKS);
CreateThread(NULL, 0, InputRT4, NULL, 0, NULL); CreateThread(NULL, 0, InputRT4, NULL, 0, NULL);
@ -350,8 +403,13 @@ static InitFunction FNFSBFunc([]()
MH_Initialize(); MH_Initialize();
MH_CreateHookApi(L"user32.dll", "CreateWindowExA", &CreateWindowExART4, (void**)&original_CreateWindowExA4); MH_CreateHookApi(L"user32.dll", "CreateWindowExA", &CreateWindowExART4, (void**)&original_CreateWindowExA4);
MH_CreateHookApi(L"user32.dll", "SetWindowPos", &SetWindowPosRT4, (void**)&original_SetWindowPos4);
MH_EnableHook(MH_ALL_HOOKS); MH_EnableHook(MH_ALL_HOOKS);
} }
// else
// {
// // BROKEN RESOLUTION PATCH WHEN FULLSCREEN
// injector::WriteMemory<DWORD>((0x1522F8 + BaseAddress3), horizontal3, true);
// injector::WriteMemory<DWORD>((0x1522FC + BaseAddress3), vertical3, true);
// }
}, GameID::FNFSB); }, GameID::FNFSB);