Some fixes and changes

This commit is contained in:
fed 2023-10-11 01:19:23 +02:00
parent 973721636d
commit de761f61fc
No known key found for this signature in database
GPG Key ID: 1D2C630F04722996
6 changed files with 30 additions and 30 deletions

View File

@ -34,7 +34,7 @@ LUI.MenuBuilder.registerType("achievements_menu", function(root, controller)
local currentbackground = nil local currentbackground = nil
local changebackground = function(background, isvideobg) local changebackground = function(background, isvideobg)
if (currentbackground == background) then if (not Engine.InFrontend() or currentbackground == background) then
return return
end end

View File

@ -33,7 +33,7 @@ namespace fps
game::dvar_t* cg_draw_game_time = nullptr; game::dvar_t* cg_draw_game_time = nullptr;
game::dvar_t* com_accurate_fps = nullptr; game::dvar_t* com_accurate_max_fps = nullptr;
float fps_color_good[4] = {0.6f, 1.0f, 0.0f, 1.0f}; float fps_color_good[4] = {0.6f, 1.0f, 0.0f, 1.0f};
float fps_color_ok[4] = {1.0f, 0.7f, 0.3f, 1.0f}; float fps_color_ok[4] = {1.0f, 0.7f, 0.3f, 1.0f};
@ -363,7 +363,7 @@ namespace fps
void r_process_workers_with_timeout_stub(void* a1, void* a2) void r_process_workers_with_timeout_stub(void* a1, void* a2)
{ {
if (com_accurate_fps->current.enabled) if (com_accurate_max_fps->current.enabled)
{ {
return; return;
} }
@ -373,7 +373,7 @@ namespace fps
void com_frame_stub() void com_frame_stub()
{ {
if (!com_accurate_fps->current.enabled) if (!com_accurate_max_fps->current.enabled)
{ {
return com_frame_hook.invoke<void>(); return com_frame_hook.invoke<void>();
} }
@ -434,7 +434,7 @@ namespace fps
cg_draw_game_time = dvars::register_bool("cg_drawGameTime", false, game::DVAR_FLAG_SAVED, "Draw game time"); cg_draw_game_time = dvars::register_bool("cg_drawGameTime", false, game::DVAR_FLAG_SAVED, "Draw game time");
// Make fps capping accurate // Make fps capping accurate
com_accurate_fps = dvars::register_bool("com_accurateFps", false, game::DVAR_FLAG_SAVED, "Accurate fps capping"); com_accurate_max_fps = dvars::register_bool("com_accurateMaxFps", false, game::DVAR_FLAG_SAVED, "Accurate fps capping");
utils::hook::call(0x1405A38B9, r_process_workers_with_timeout_stub); utils::hook::call(0x1405A38B9, r_process_workers_with_timeout_stub);
com_frame_hook.create(0x1405A3740, com_frame_stub); com_frame_hook.create(0x1405A3740, com_frame_stub);
} }

View File

@ -289,7 +289,7 @@ namespace gsc
void g_model_index_no_cache_error_stub(const char* model) void g_model_index_no_cache_error_stub(const char* model)
{ {
scr_error(true, "model \"%s\" must be precached", model); scr_error(false, "model \"%s\" must be precached", model);
} }
} }

View File

@ -15,12 +15,6 @@ namespace patches
utils::hook::detour gscr_set_save_dvar_hook; utils::hook::detour gscr_set_save_dvar_hook;
utils::hook::detour dvar_register_float_hook; utils::hook::detour dvar_register_float_hook;
void* sub_46148()
{
static uint64_t off_11C52460 = 0x140AD0C58;
return &off_11C52460;
}
DECLSPEC_NORETURN void quit_stub() DECLSPEC_NORETURN void quit_stub()
{ {
utils::hook::invoke<void>(0x1408B1BA0); utils::hook::invoke<void>(0x1408B1BA0);
@ -79,10 +73,10 @@ namespace patches
public: public:
void post_unpack() override void post_unpack() override
{ {
// Fix startup crashes // Disable battle net game service
utils::hook::set(0x140272F70, 0xC301B0); utils::hook::set<std::uint32_t>(0x140272F70, 0xC301B0);
utils::hook::jump(0x140046148, sub_46148); // 'Fix' tls index conflict crash
utils::hook::set<std::uint8_t>(0x140046166, 0xEB);
// Fix shutdown crash // Fix shutdown crash
utils::hook::jump(0x1408B1CD0, 0x1408B1BA0); utils::hook::jump(0x1408B1CD0, 0x1408B1BA0);

View File

@ -931,13 +931,18 @@ namespace ui_scripting
utils::hook::jump(0x14031E700, 0x1402D86E0); utils::hook::jump(0x14031E700, 0x1402D86E0);
utils::hook::jump(0x1402BFCC0, removed_function_stub); // io utils::hook::jump(0x1402BFCC0, removed_function_stub); // io
utils::hook::jump(0x14017EE60, removed_function_stub); // profile
utils::hook::jump(0x1402C0150, removed_function_stub); // os utils::hook::jump(0x1402C0150, removed_function_stub); // os
utils::hook::jump(0x14017F730, removed_function_stub); // serialize utils::hook::jump(0x1402C1020, removed_function_stub); // serialize
utils::hook::jump(0x1402C0FF0, removed_function_stub); // hks utils::hook::jump(0x1402C0FF0, removed_function_stub); // hks
utils::hook::jump(0x14017EC60, removed_function_stub); // debug utils::hook::jump(0x1402C0470, removed_function_stub); // debug
utils::hook::nop(0x1402BFC48, 5); // coroutine utils::hook::nop(0x1402BFC48, 5); // coroutine
// profile
utils::hook::jump(0x1402B6250, removed_function_stub);
utils::hook::jump(0x1402B6260, removed_function_stub);
utils::hook::jump(0x1402B6270, removed_function_stub);
utils::hook::jump(0x1402B6330, removed_function_stub);
utils::hook::jump(0x1402B7FD0, removed_function_stub); utils::hook::jump(0x1402B7FD0, removed_function_stub);
utils::hook::jump(0x1402B7C40, removed_function_stub); utils::hook::jump(0x1402B7C40, removed_function_stub);
utils::hook::jump(0x1402BAC30, removed_function_stub); utils::hook::jump(0x1402BAC30, removed_function_stub);

View File

@ -180,24 +180,25 @@ void loader::load_tls(const utils::nt::library& target, const utils::nt::library
{ {
if (source.get_optional_header()->DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].Size) if (source.get_optional_header()->DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].Size)
{ {
auto* target_tls = tls::allocate_tls_index(); const auto target_tls = tls::allocate_tls_index();
/* target_tls = reinterpret_cast<PIMAGE_TLS_DIRECTORY>(library.get_ptr() + library.get_optional_header()
->DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress); */ const auto source_tls = reinterpret_cast<PIMAGE_TLS_DIRECTORY>(target.get_ptr() + source.get_optional_header()
auto* const source_tls = reinterpret_cast<PIMAGE_TLS_DIRECTORY>(target.get_ptr() + source.get_optional_header()
->DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress); ->DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress);
const auto tls_size = source_tls->EndAddressOfRawData - source_tls->StartAddressOfRawData; const auto tls_size = source_tls->EndAddressOfRawData - source_tls->StartAddressOfRawData;
const auto tls_index = *reinterpret_cast<DWORD*>(target_tls->AddressOfIndex); const auto tls_index = *reinterpret_cast<DWORD*>(target_tls->AddressOfIndex);
utils::hook::set<DWORD>(source_tls->AddressOfIndex, tls_index); utils::hook::set<DWORD>(source_tls->AddressOfIndex, tls_index);
DWORD old_protect; const auto target_start = PVOID(target_tls->StartAddressOfRawData);
VirtualProtect(PVOID(target_tls->StartAddressOfRawData), const auto source_start = PVOID(source_tls->StartAddressOfRawData);
source_tls->EndAddressOfRawData - source_tls->StartAddressOfRawData, PAGE_READWRITE,
&old_protect);
auto* const tls_base = *reinterpret_cast<LPVOID*>(__readgsqword(0x58) + 8ull * tls_index); DWORD old_protect;
std::memmove(tls_base, PVOID(source_tls->StartAddressOfRawData), tls_size); VirtualProtect(target_start, tls_size, PAGE_READWRITE, &old_protect);
std::memmove(PVOID(target_tls->StartAddressOfRawData), PVOID(source_tls->StartAddressOfRawData), tls_size);
const auto tls_base = *reinterpret_cast<LPVOID*>(__readgsqword(0x58) + 8ull * tls_index);
std::memmove(tls_base, source_start, tls_size);
std::memmove(target_start, source_start, tls_size);
VirtualProtect(target_tls, sizeof(*target_tls), PAGE_READWRITE, &old_protect); VirtualProtect(target_tls, sizeof(*target_tls), PAGE_READWRITE, &old_protect);
*target_tls = *source_tls; *target_tls = *source_tls;