Fix console crash
This commit is contained in:
parent
4428c063d7
commit
951acbb889
2
deps/protobuf
vendored
2
deps/protobuf
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 71f4a9c6f35007609ef423ab643c05c1f88731ce
|
Subproject commit f0c1492ef6a6ad17ef62d49cd671980742729783
|
@ -21,6 +21,8 @@ namespace Components
|
|||||||
|
|
||||||
std::thread Console::ConsoleThread;
|
std::thread Console::ConsoleThread;
|
||||||
|
|
||||||
|
Game::SafeArea Console::OriginalSafeArea;
|
||||||
|
|
||||||
char** Console::GetAutoCompleteFileList(const char *path, const char *extension, Game::FsListBehavior_e behavior, int *numfiles, int allocTrackType)
|
char** Console::GetAutoCompleteFileList(const char *path, const char *extension, Game::FsListBehavior_e behavior, int *numfiles, int allocTrackType)
|
||||||
{
|
{
|
||||||
if (path == reinterpret_cast<char*>(0xBAADF00D) || path == reinterpret_cast<char*>(0xCDCDCDCD) || IsBadReadPtr(path, 1)) return nullptr;
|
if (path == reinterpret_cast<char*>(0xBAADF00D) || path == reinterpret_cast<char*>(0xCDCDCDCD) || IsBadReadPtr(path, 1)) return nullptr;
|
||||||
@ -431,6 +433,41 @@ namespace Components
|
|||||||
ExitProcess(1);
|
ExitProcess(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) Console::DrawSolidConsoleStub()
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
pushad
|
||||||
|
call Console::StoreSafeArea
|
||||||
|
popad
|
||||||
|
|
||||||
|
// We need esi preserved here, so we have to backup 'all' registers when storing the safearea
|
||||||
|
call Game::Con_DrawSolidConsole
|
||||||
|
|
||||||
|
call Console::RestoreSafeArea
|
||||||
|
retn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Console::StoreSafeArea()
|
||||||
|
{
|
||||||
|
// Backup the original safe area
|
||||||
|
Console::OriginalSafeArea = *Game::safeArea;
|
||||||
|
|
||||||
|
// Apply new safe area and border
|
||||||
|
float border = 6.0f;
|
||||||
|
Game::safeArea->top = border;
|
||||||
|
Game::safeArea->left = border;
|
||||||
|
Game::safeArea->bottom = static_cast<float>(Renderer::Height()) - border;
|
||||||
|
Game::safeArea->right = static_cast<float>(Renderer::Width()) - border;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Console::RestoreSafeArea()
|
||||||
|
{
|
||||||
|
// Restore the initial safe area
|
||||||
|
*Game::safeArea = Console::OriginalSafeArea;
|
||||||
|
}
|
||||||
|
|
||||||
Console::Console()
|
Console::Console()
|
||||||
{
|
{
|
||||||
// Console '%s: %s> ' string
|
// Console '%s: %s> ' string
|
||||||
@ -441,25 +478,7 @@ namespace Components
|
|||||||
Utils::Hook(0x4F65A5, Console::ToggleConsole, HOOK_JUMP).Install()->Quick();
|
Utils::Hook(0x4F65A5, Console::ToggleConsole, HOOK_JUMP).Install()->Quick();
|
||||||
|
|
||||||
// Patch safearea for ingame-console
|
// Patch safearea for ingame-console
|
||||||
Utils::Hook(0x5A50EF, [] ()
|
Utils::Hook(0x5A50EF, Console::DrawSolidConsoleStub, HOOK_CALL).Install()->Quick();
|
||||||
{
|
|
||||||
// Backup the original safe area
|
|
||||||
Game::SafeArea safeAreaBackup;
|
|
||||||
safeAreaBackup = *Game::safeArea;
|
|
||||||
|
|
||||||
// Apply new safe area and border
|
|
||||||
float border = 6.0f;
|
|
||||||
Game::safeArea->top = border;
|
|
||||||
Game::safeArea->left = border;
|
|
||||||
Game::safeArea->bottom = static_cast<float>(Renderer::Height()) - border;
|
|
||||||
Game::safeArea->right = static_cast<float>(Renderer::Width()) - border;
|
|
||||||
|
|
||||||
// Draw the console
|
|
||||||
Game::Con_DrawSolidConsole();
|
|
||||||
|
|
||||||
// Restore the initial safe area
|
|
||||||
*Game::safeArea = safeAreaBackup;
|
|
||||||
}, HOOK_CALL).Install()->Quick();
|
|
||||||
|
|
||||||
// Check for bad food ;)
|
// Check for bad food ;)
|
||||||
Utils::Hook(0x4CB9F4, Console::GetAutoCompleteFileList, HOOK_CALL).Install()->Quick();
|
Utils::Hook(0x4CB9F4, Console::GetAutoCompleteFileList, HOOK_CALL).Install()->Quick();
|
||||||
|
@ -35,6 +35,8 @@ namespace Components
|
|||||||
|
|
||||||
static std::thread ConsoleThread;
|
static std::thread ConsoleThread;
|
||||||
|
|
||||||
|
static Game::SafeArea OriginalSafeArea;
|
||||||
|
|
||||||
static void ShowPrompt();
|
static void ShowPrompt();
|
||||||
static void RefreshStatus();
|
static void RefreshStatus();
|
||||||
static void RefreshOutput();
|
static void RefreshOutput();
|
||||||
@ -50,5 +52,9 @@ namespace Components
|
|||||||
static void StdOutError(const char* format, ...);
|
static void StdOutError(const char* format, ...);
|
||||||
|
|
||||||
static void ConsoleRunner();
|
static void ConsoleRunner();
|
||||||
|
|
||||||
|
static void DrawSolidConsoleStub();
|
||||||
|
static void StoreSafeArea();
|
||||||
|
static void RestoreSafeArea();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user