mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Light cleanup + Improvements
* Cleanup unused stuff * Make codeblock segmentation bigger * Overlay improvements
This commit is contained in:
parent
62a0b5cebb
commit
6700343e2e
@ -9,14 +9,14 @@ void RemoveDXHooks();
|
||||
void ShowGameConsole(bool* p_open);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Utility
|
||||
static int Stricmp(const char* s1, const char* s2) { int d; while ((d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; }return d; }
|
||||
static int Strnicmp(const char* s1, const char* s2, int n) { int d = 0; while (n > 0 && (d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; n--; }return d; }
|
||||
static char* Strdup(const char* s) { IM_ASSERT(s); size_t len = strlen(s) + 1; void* buf = malloc(len); IM_ASSERT(buf); if (buf != NULL) { return (char*)memcpy(buf, (const void*)s, len); } }
|
||||
static void Strtrim(char* s) { char* str_end = s + strlen(s); while (str_end > s && str_end[-1] == ' ') str_end--; *str_end = 0; }
|
||||
// Internals
|
||||
int Stricmp(const char* s1, const char* s2);
|
||||
int Strnicmp(const char* s1, const char* s2, int n);
|
||||
char* Strdup(const char* s);
|
||||
void Strtrim(char* s);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Globals
|
||||
inline ImVector<char*> Items;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -36,15 +36,6 @@ namespace
|
||||
DWORD64 p_NET_SendDatagram = FindPattern("r5apex.exe", (const unsigned char*)"\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x57\x41\x56\x41\x57\x48\x81\xEC\x00\x05\x00\x00", "xxxxxxxxxxxxxxxxxxxxxxx?xxx");
|
||||
unsigned int (*NET_SendDatagram)(SOCKET s, const char* buf, int len, int flags) = (unsigned int (*)(SOCKET, const char*, int, int))p_NET_SendDatagram; /*48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 41 56 41 57 48 81 EC ?? 05 00 00*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* ==== WINAPI ========================================================================================================================================================== */
|
||||
DWORD64 p_SetCursorPosition = FindPattern("r5apex.exe", (const unsigned char*)"\x48\x85\xD2\x0F\x00\x00\x00\x00\x00\x48\x89\x6C\x24\x00\x56\x48\x83\xEC\x40\x4C", "xxxx?????xxxx?xxxxxx"); // Uncomment for anything that is not between S1 build 525 and S4 build 856
|
||||
//DWORD64 p_SetCursorPosition = FindPattern("r5apex.exe", "\x48\x89\x6C\x24\x18\x48\x89\x74\x24\x20\x57\x48\x83\xEC\x40\x48\x8B\xF9", "xxxxxxxxxxxxxxxxxx"); // Uncomment for anything that is between S1 build 525 and S4 build 856
|
||||
void (*SetCursorPosition)(INT64 nFlag, LONG posX, LONG posY) = (void (*)(INT64, LONG, LONG))p_SetCursorPosition; /*48 85 D2 0F ?? ?? ?? ?? ?? 48 89 6C 24 ?? 56 48 83 EC 40 4C*/
|
||||
|
||||
//DWORD64 p_GameWindowProc = FindPattern("r5apex.exe", (const unsigned char*)"\x48\x89\x4C\x24\x00\x56\x41\x54\x41\x56\x41\x57\x48\x83\xEC\x48", "xxxx?xxxxxxxxxxx");
|
||||
//unsigned int (*GameWindowProc)(int game, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) = (unsigned int (*)(int, HWND, UINT, WPARAM, LPARAM))p_GameWindowProc; /*48 89 4C 24 ?? 56 41 54 41 56 41 57 48 83 EC 48*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* ==== ------- ========================================================================================================================================================= */
|
||||
|
||||
@ -62,9 +53,6 @@ namespace
|
||||
std::cout << "| p_NET_ReceiveDatagram : " << std::hex << p_NET_ReceiveDatagram << std::endl;
|
||||
std::cout << "| p_NET_SendDatagram : " << std::hex << p_NET_SendDatagram << std::endl;
|
||||
std::cout << "+--------------------------------------------------------+" << std::endl;
|
||||
std::cout << "| p_SetCursorPosition : " << std::hex << p_SetCursorPosition << std::endl;
|
||||
//std::cout << "| p_GameWindowProc : " << std::hex << p_GameWindowProc << std::endl;
|
||||
std::cout << "+--------------------------------------------------------+" << std::endl;
|
||||
|
||||
// TODO implement error handling when sigscan fails or result is 0
|
||||
}
|
||||
|
@ -10,9 +10,11 @@
|
||||
#include "console.h"
|
||||
#include "patterns.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------------------------------------------------------------------------
|
||||
// Init
|
||||
//---------------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SetupConsole()
|
||||
{
|
||||
@ -28,8 +30,8 @@ void SetupConsole()
|
||||
// Set the window title
|
||||
FILE* sBuildTxt;
|
||||
CHAR sBuildBuf[1024] = { 0 };
|
||||
fopen_s(&sBuildTxt, "build.txt", "r");
|
||||
|
||||
fopen_s(&sBuildTxt, "build.txt", "r");
|
||||
if (sBuildTxt)
|
||||
{
|
||||
while (fgets(sBuildBuf, sizeof(sBuildBuf), sBuildTxt) != NULL)
|
||||
@ -59,9 +61,11 @@ void SetupConsole()
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------------------------------------------------------------------------
|
||||
// Hooks
|
||||
//---------------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool Hook_ConVar_IsFlagSet(int** cvar, int flag)
|
||||
{
|
||||
@ -71,7 +75,6 @@ bool Hook_ConVar_IsFlagSet(int** cvar, int flag)
|
||||
printf("--------------------------------------------------\n");
|
||||
printf(" Flaged: %08X\n", real_flags);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Mask off FCVAR_CHEATS and FCVAR_DEVELOPMENTONLY
|
||||
real_flags &= 0xFFFFBFFD;
|
||||
if (g_bDebugConsole)
|
||||
@ -94,7 +97,6 @@ bool Hook_ConCommand_IsFlagSet(int* cmd, int flag)
|
||||
printf("--------------------------------------------------\n");
|
||||
printf(" Flaged: %08X\n", real_flags);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Mask off FCVAR_CHEATS and FCVAR_DEVELOPMENTONLY
|
||||
real_flags &= 0xFFFFBFFD;
|
||||
if (g_bDebugConsole)
|
||||
@ -109,9 +111,11 @@ bool Hook_ConCommand_IsFlagSet(int* cmd, int flag)
|
||||
else { return false; }
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------------------------------------------------------------------------
|
||||
// Worker
|
||||
//---------------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DWORD __stdcall ProcessConsoleWorker(LPVOID)
|
||||
{
|
||||
|
@ -8,9 +8,11 @@
|
||||
#include "console.h"
|
||||
#include "utility.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------------------------------------------------------------------------
|
||||
// Init
|
||||
//---------------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void InitializeR5Dev()
|
||||
{
|
||||
@ -29,9 +31,11 @@ void TerminateR5Dev()
|
||||
FreeConsole();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------------------------------------------------------------------------
|
||||
// Entry
|
||||
//---------------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
|
@ -11,9 +11,11 @@
|
||||
#include "overlay.h"
|
||||
#include "hooks.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------------------------------------------------------------------------
|
||||
// Netchan
|
||||
//---------------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool Hook_NET_ReceiveDatagram(int sock, void* inpacket, bool raw)
|
||||
{
|
||||
@ -44,9 +46,11 @@ unsigned int Hook_NET_SendDatagram(SOCKET s, const char* buf, int len, int flags
|
||||
return result;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------------------------------------------------------------------------
|
||||
// SquirrelVM
|
||||
//---------------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void* Hook_SQVM_Print(void* sqvm, char* fmt, ...)
|
||||
{
|
||||
@ -102,9 +106,11 @@ bool Hook_SQVM_LoadScript(void* sqvm, const char* script_path, const char* scrip
|
||||
return SQVM_LoadScript(sqvm, script_path, script_name, flag);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------------------------------------------------------------------------
|
||||
// Management
|
||||
//---------------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void InstallHooks()
|
||||
{
|
||||
@ -150,9 +156,11 @@ void RemoveHooks()
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------------------------------------------------------------------------
|
||||
// Toggles
|
||||
//---------------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ToggleNetHooks()
|
||||
{
|
||||
|
@ -163,12 +163,11 @@ public:
|
||||
Filter.Draw("Filter [\"-incl,-excl\"] [\"error\"]", 180);
|
||||
ImGui::Separator();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Reserve enough left-over height for 1 separator + 1 input text
|
||||
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), true, ImGuiWindowFlags_None);
|
||||
ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), true, ImGuiWindowFlags_AlwaysVerticalScrollbar);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 4.f, 6.f });
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
@ -335,7 +334,6 @@ public:
|
||||
reclaim_focus = true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Auto-focus on window apparition
|
||||
ImGui::SetItemDefaultFocus();
|
||||
if (reclaim_focus) { ImGui::SetKeyboardFocusHere(-1); }// Auto focus previous widget
|
||||
@ -437,7 +435,47 @@ public:
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//-----------------------------------------------------------------------------
|
||||
// Internals
|
||||
//-----------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int Stricmp(const char* s1, const char* s2)
|
||||
{
|
||||
int d;
|
||||
while ((d = toupper(*s2) - toupper(*s1)) == 0 && *s1)
|
||||
{
|
||||
s1++; s2++;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
int Strnicmp(const char* s1, const char* s2, int n)
|
||||
{
|
||||
int d = 0; while (n > 0 && (d = toupper(*s2) - toupper(*s1)) == 0 && *s1)
|
||||
{
|
||||
s1++; s2++; n--;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
char* Strdup(const char* s)
|
||||
{
|
||||
IM_ASSERT(s); size_t len = strlen(s) + 1; void* buf = malloc(len); IM_ASSERT(buf); if (buf != NULL)
|
||||
{
|
||||
return (char*)memcpy(buf, (const void*)s, len);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void Strtrim(char* s)
|
||||
{
|
||||
char* str_end = s + strlen(s); while (str_end > s && str_end[-1] == ' ') str_end--; *str_end = 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//-----------------------------------------------------------------------------
|
||||
// Entry
|
||||
//-----------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ShowGameConsole(bool* p_open)
|
||||
{
|
||||
static CGameConsole console;
|
||||
|
Loading…
x
Reference in New Issue
Block a user