From f28242869eb98a4d38c3cf9397e3ad041e758f1d Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 7 Nov 2024 04:50:54 +0300 Subject: [PATCH] [CKPE] FO4: - 983.1 Refuse BSPointerHandle support 64mln ref's only 8mln, stable +-. --- .../BGSRenderWindowReferenceEditModule.cpp | 40 + .../FO4/BGSRenderWindowReferenceEditModule.h | 1 + .../Editor API/FO4/BSPointerHandleManager.h | 13 +- .../Editor API/FO4/TESObjectREFR.h | 49 + .../Patches/FO4/AddChangeRefF4.cpp | 7 +- .../Patches/FO4/FakeMoveLight.cpp | 8 +- .../ReplaceBSPointerHandleAndManagerF4.cpp | 1139 +++++++++-------- .../Patches/Windows/FO4/MainWindowF4.cpp | 4 +- .../Version/build_version.txt | Bin 12 -> 12 bytes .../Version/resource_version2.h | Bin 2004 -> 2004 bytes ...itPlatformExtended_FO4_1_10_982_3.database | Bin 25389 -> 25401 bytes .../ReplaceBSPointerHandleAndManager.relb | 1 + Stuffs/FO4/CreationKitPlatformExtended.ini | 2 +- rc2json/version/build_version.txt | Bin 10 -> 10 bytes rc2json/version/resource_version2.h | Bin 2002 -> 2002 bytes 15 files changed, 710 insertions(+), 554 deletions(-) diff --git a/Creation Kit Platform Extended Core/Editor API/FO4/BGSRenderWindowReferenceEditModule.cpp b/Creation Kit Platform Extended Core/Editor API/FO4/BGSRenderWindowReferenceEditModule.cpp index a6d4ccf4..16161068 100644 --- a/Creation Kit Platform Extended Core/Editor API/FO4/BGSRenderWindowReferenceEditModule.cpp +++ b/Creation Kit Platform Extended Core/Editor API/FO4/BGSRenderWindowReferenceEditModule.cpp @@ -52,6 +52,46 @@ namespace CreationKitPlatformExtended } } + void BGSRenderWindowReferenceEditModule::MoveSelectObjectsExtremlyNG(NiPoint3* NewPosition, int32_t Unk) + { + auto Picker = _Renderer->GetPickHandler(); + if (!Picker || !Picker->Count) return; + // Reset var the relative grid offset + if (_TempPosition == ZERO_P3) + MoveSnapObjectIntermediate = ZERO_P3; + // If the offset is too small, then it is not needed + /*if (NewPosition->Magnitude2() >= 0.001f) + return;*/ + // Increase the offset while pull the mouse, this offset cannot be touched, it seems to be used to restore the cursor + _TempPosition += *NewPosition; + // Also for the relative grid + MoveSnapObjectIntermediate += *NewPosition; + + auto It = Picker->Items->First; + for (uint32_t i = 0; i < Picker->Count; i++, It = It->Next) + { + // Get a REFR to object and increase the counter + auto FormRef = BGSUniqueObjectRef((TESObjectREFR_Extremly_NG*)It->GetRef()); + if (FormRef.Empty()) continue; + // I have no idea what for, but it is used in the original, also incrementing the counter + auto NodeRef = FormRef->GetFadeNode(); + if (NodeRef.Empty()) continue; + + auto ObjectPosition = FormRef->GetPosition(); + if (BGSRenderWindow::HasSnapToGrid() || BGSRenderWindow::HasSnapToConnectPoints()) + { + NiPoint3 NewPos; + if (ComputeGridOrConnectPoint(ObjectPosition, *NewPosition, NewPos, i, Picker->Count)) + FormRef->SetPosition(FormRef.Get(), &NewPos); + } + else + { + ObjectPosition += *NewPosition; + FormRef->SetPosition(FormRef.Get(), &ObjectPosition); + } + } + } + void BGSRenderWindowReferenceEditModule::MoveSelectObjectsExtremly(NiPoint3* NewPosition, int32_t Unk) { auto Picker = _Renderer->GetPickHandler(); diff --git a/Creation Kit Platform Extended Core/Editor API/FO4/BGSRenderWindowReferenceEditModule.h b/Creation Kit Platform Extended Core/Editor API/FO4/BGSRenderWindowReferenceEditModule.h index 99a429f8..fb37fbf7 100644 --- a/Creation Kit Platform Extended Core/Editor API/FO4/BGSRenderWindowReferenceEditModule.h +++ b/Creation Kit Platform Extended Core/Editor API/FO4/BGSRenderWindowReferenceEditModule.h @@ -18,6 +18,7 @@ namespace CreationKitPlatformExtended void MoveSelectObjects(NiPoint3* NewPosition, int32_t Unk = 0); void MoveSelectObjectsExtremly(NiPoint3* NewPosition, int32_t Unk = 0); + void MoveSelectObjectsExtremlyNG(NiPoint3* NewPosition, int32_t Unk = 0); bool ComputeGridOrConnectPoint(const NiPoint3& Position, NiPoint3& OffsetInstant, NiPoint3& NewPosition, uint32_t Index, uint32_t Count) const; diff --git a/Creation Kit Platform Extended Core/Editor API/FO4/BSPointerHandleManager.h b/Creation Kit Platform Extended Core/Editor API/FO4/BSPointerHandleManager.h index 45c15494..a0262a98 100644 --- a/Creation Kit Platform Extended Core/Editor API/FO4/BSPointerHandleManager.h +++ b/Creation Kit Platform Extended Core/Editor API/FO4/BSPointerHandleManager.h @@ -108,6 +108,7 @@ namespace CreationKitPlatformExtended static_assert(sizeof(IBSUntypedPointerHandle) == 0x4); typedef IBSUntypedPointerHandle BSUntypedPointerHandle_Original; + typedef IBSUntypedPointerHandle BSUntypedPointerHandle_Extended_NG; typedef IBSUntypedPointerHandle BSUntypedPointerHandle_Extended; template @@ -145,10 +146,13 @@ namespace CreationKitPlatformExtended typedef IBSPointerHandleManagerEntry BSPointerHandleManagerEntry_Original; + typedef IBSPointerHandleManagerEntry BSPointerHandleManagerEntry_Extended_NG; typedef IBSPointerHandleManagerEntry BSPointerHandleManagerEntry_Extended; static_assert(sizeof(BSPointerHandleManagerEntry_Original) == 0x10); + static_assert(sizeof(BSPointerHandleManagerEntry_Extended_NG) == 0x10); static_assert(sizeof(BSPointerHandleManagerEntry_Extended) == 0x10); template @@ -223,6 +227,8 @@ namespace CreationKitPlatformExtended typedef IBSPointerHandleManager BSPointerHandleManager_Original; + typedef IBSPointerHandleManager BSPointerHandleManager_Extended_NG; typedef IBSPointerHandleManager BSPointerHandleManager_Extended; @@ -242,6 +248,7 @@ namespace CreationKitPlatformExtended }; typedef IBSHandleManager HandleManager_Original; + typedef IBSHandleManager HandleManager_Extended_NG; typedef IBSHandleManager HandleManager_Extended; template @@ -452,7 +459,9 @@ namespace CreationKitPlatformExtended typedef IBSPointerHandleManagerInterface BSPointerHandleManagerInterface_Original; - + typedef IBSPointerHandleManagerInterface + BSPointerHandleManagerInterface_Extended_NG; typedef IBSPointerHandleManagerInterface BSPointerHandleManagerInterface_Extended; @@ -468,6 +477,8 @@ namespace CreationKitPlatformExtended { case 1: return BSPointerHandleManagerInterface_Extended::GetPointer(UniqueId); + case 2: + return BSPointerHandleManagerInterface_Extended_NG::GetPointer(UniqueId); default: return BSPointerHandleManagerInterface_Original::GetPointer(UniqueId); } diff --git a/Creation Kit Platform Extended Core/Editor API/FO4/TESObjectREFR.h b/Creation Kit Platform Extended Core/Editor API/FO4/TESObjectREFR.h index 55f352c6..786ce04e 100644 --- a/Creation Kit Platform Extended Core/Editor API/FO4/TESObjectREFR.h +++ b/Creation Kit Platform Extended Core/Editor API/FO4/TESObjectREFR.h @@ -37,6 +37,7 @@ namespace CreationKitPlatformExtended }; typedef TESObjectREFR_base TESObjectREFR_base_Original; + typedef TESObjectREFR_base TESObjectREFR_base_Extremly_NG; typedef TESObjectREFR_base TESObjectREFR_base_Extremly; static_assert(sizeof(TESObjectREFR_base_Original) == 0x40); @@ -90,6 +91,54 @@ namespace CreationKitPlatformExtended }; static_assert(sizeof(TESObjectREFR_Original) == 0x140); + class TESObjectREFR_Extremly_NG : public TESObjectREFR_base_Extremly_NG + { + public: + constexpr static uint8_t TYPE_ID = FormType::ftReference; + enum SpecialFlagsForm { + // https://github.com/shadeMe/Construction-Set-Extender/blob/master/EditorAPI/TESObjectREFR.h + fs3DInvisible = 1 << 31, + fsChildren3DInvisible = 1 << 30, + fsFrozen = 1 << 29, + }; + protected: + BSTEventSink _unkEventSink02; // 0x040 + BSTEventSink _unkEventSink03; // 0x048 + BSTEventSink _unkEventSink04; // 0x050 + char _pad0[0x70]; // 0x058 + TESObjectCELL* _parentCell; // 0x0C8 + NiPoint3 _rotate; // 0x0D0, 0x0D4, 0x0D8 + float _unkDC; // 0x0DC + NiPoint3 _position; // 0x0E0, 0x0E4, 0x0E8 + float _unkEC; // 0x0EC + TESForm* _baseForm; // 0x0F0 + void* _unkE8; // 0x0F8 + void* _unk100; // 0x100 + void* _unk108; // 0x108 + void* _extraData; // 0x110 + uint16_t _scale; // 0x118 + char _pad118[0x26]; // 0x11A + public: + inline NiPoint3 GetPosition() const { return _position; } + inline NiPoint3 GetRotate() const { return _rotate; } + inline void SetRotate(const NiPoint3& val) { _rotate = val; } + inline uint16_t GetScale() const { return _scale; } + inline void SetScale(uint16_t val) { _scale = val; } + inline float GetScaleFloat() const { return ((float)_scale / 100); } + inline void SetScaleFloat(float val) { _scale = uint16_t(val * 100); } + inline bool IsInvisible() const { return (_FormFlags & SpecialFlagsForm::fs3DInvisible); } + inline bool IsChildrenInvisible() const { return (_FormFlags & SpecialFlagsForm::fsChildren3DInvisible); } + inline bool IsFrozen() const { return (_FormFlags & SpecialFlagsForm::fsFrozen); } + + READ_PROPERTY2(TESObjectCELL*, ParentCell, _parentCell); + READ_PROPERTY2(TESForm*, Parent, _baseForm); + PROPERTY(GetPosition, SetPosition) NiPoint3 Position; + PROPERTY(GetRotate, SetRotate) NiPoint3 Rotate; + PROPERTY(GetScale, SetScale) uint16_t Scale; + PROPERTY(GetScaleFloat, SetScaleFloat) float ScaleFloat; + }; + static_assert(sizeof(TESObjectREFR_Extremly_NG) == 0x140); + class TESObjectREFR_Extremly : public TESObjectREFR_base_Extremly { public: diff --git a/Creation Kit Platform Extended Core/Patches/FO4/AddChangeRefF4.cpp b/Creation Kit Platform Extended Core/Patches/FO4/AddChangeRefF4.cpp index 6fdfe939..fdc66847 100644 --- a/Creation Kit Platform Extended Core/Patches/FO4/AddChangeRefF4.cpp +++ b/Creation Kit Platform Extended Core/Patches/FO4/AddChangeRefF4.cpp @@ -59,10 +59,9 @@ namespace CreationKitPlatformExtended { lpRelocator->DetourCall(lpRelocationDatabaseItem->At(0), (uintptr_t)&HKInsertMenuA); - *(uintptr_t*)&EditorAPI::Fallout4::TESObjectREFR::SetParentWithRedraw = - lpRelocator->Rav2Off(lpRelocationDatabaseItem->At(1)); - *(uintptr_t*)&EditorAPI::Fallout4::TESObjectREFR_Extremly::SetParentWithRedraw = - lpRelocator->Rav2Off(lpRelocationDatabaseItem->At(1)); + *(uintptr_t*)&EditorAPI::Fallout4::TESObjectREFR::SetParentWithRedraw = _RELDATA_ADDR(1); + *(uintptr_t*)&EditorAPI::Fallout4::TESObjectREFR_Extremly_NG::SetParentWithRedraw = _RELDATA_ADDR(1); + *(uintptr_t*)&EditorAPI::Fallout4::TESObjectREFR_Extremly::SetParentWithRedraw = _RELDATA_ADDR(1); return true; } diff --git a/Creation Kit Platform Extended Core/Patches/FO4/FakeMoveLight.cpp b/Creation Kit Platform Extended Core/Patches/FO4/FakeMoveLight.cpp index 3b02a1d7..79ff5e35 100644 --- a/Creation Kit Platform Extended Core/Patches/FO4/FakeMoveLight.cpp +++ b/Creation Kit Platform Extended Core/Patches/FO4/FakeMoveLight.cpp @@ -71,9 +71,15 @@ namespace CreationKitPlatformExtended if (!BSPointerHandleManagerCurrent::PointerHandleManagerCurrentId) lpRelocator->DetourJump(_RELDATA_RAV(0), &BGSRenderWindowReferenceEditModule::MoveSelectObjects); else - lpRelocator->DetourJump(_RELDATA_RAV(0), &BGSRenderWindowReferenceEditModule::MoveSelectObjectsExtremly); + { + if (GlobalEnginePtr->GetEditorVersion() == EDITOR_FALLOUT_C4_1_10_162_0) + lpRelocator->DetourJump(_RELDATA_RAV(0), &BGSRenderWindowReferenceEditModule::MoveSelectObjectsExtremly); + else + lpRelocator->DetourJump(_RELDATA_RAV(0), &BGSRenderWindowReferenceEditModule::MoveSelectObjectsExtremlyNG); + } *(uintptr_t*)&TESObjectREFR::SetPosition = _RELDATA_ADDR(1); + *(uintptr_t*)&TESObjectREFR_Extremly_NG::SetPosition = _RELDATA_ADDR(1); *(uintptr_t*)&TESObjectREFR_Extremly::SetPosition = _RELDATA_ADDR(1); return true; diff --git a/Creation Kit Platform Extended Core/Patches/FO4/ReplaceBSPointerHandleAndManagerF4.cpp b/Creation Kit Platform Extended Core/Patches/FO4/ReplaceBSPointerHandleAndManagerF4.cpp index c43d84af..27ff2318 100644 --- a/Creation Kit Platform Extended Core/Patches/FO4/ReplaceBSPointerHandleAndManagerF4.cpp +++ b/Creation Kit Platform Extended Core/Patches/FO4/ReplaceBSPointerHandleAndManagerF4.cpp @@ -6,6 +6,8 @@ #include "Editor API/FO4/BSPointerHandleManager.h" #include "ReplaceBSPointerHandleAndManagerF4.h" +#define CKPE_FO4_ENABLED_REFLIMIT 1 + namespace CreationKitPlatformExtended { namespace Patches @@ -31,11 +33,27 @@ namespace CreationKitPlatformExtended NiPointer ObjectPtr; if (!BSPointerHandleManagerCurrent::PointerHandleManagerCurrentId) Exist = BSPointerHandleManagerInterface_Original::GetSmartPointer1(Handle, ObjectPtr); - else + else if (BSPointerHandleManagerCurrent::PointerHandleManagerCurrentId == 1) Exist = BSPointerHandleManagerInterface_Extended::GetSmartPointer1(Handle, ObjectPtr); + else + Exist = BSPointerHandleManagerInterface_Extended_NG::GetSmartPointer1(Handle, ObjectPtr); } }; + // There are strings in the Cascadia mod that lead to a crash. + // This will prevent a crash and return false in this case, hopefully the strings will be deleted when saving. + static bool sub_string_crash(void* unk) + { + __try + { + return fastCall(pointer_ReplaceBSPointerHandleAndManager_code1, unk); + } + __except (1) + { + return false; + } + } + ReplaceBSPointerHandleAndManagerPatch::ReplaceBSPointerHandleAndManagerPatch() : Module(GlobalEnginePtr) {} @@ -181,42 +199,36 @@ namespace CreationKitPlatformExtended lpRelocator->DetourCall(rva + 5, func); }; + *(uintptr_t*)&pointer_ReplaceBSPointerHandleAndManager_code1 = + voltek::detours_function_class_jump(_RELDATA_ADDR(6), (uintptr_t)&sub_string_crash); + pointer_ReplaceBSPointerHandleAndManager_data1 = (uint32_t*)_RELDATA_ADDR(4); pointer_ReplaceBSPointerHandleAndManager_data2 = (uint32_t*)_RELDATA_ADDR(5); if (Extremly) { - BSPointerHandleManagerCurrent::PointerHandleManagerCurrentId = 1; - - { - ScopeRelocator textSection; - - auto addr = (uintptr_t)_RELDATA_RAV(0); - // Preparation, removal of all embedded pieces of code - lpRelocator->PatchNop(addr + 12, 0x7A); - lpRelocator->PatchMovFromRax(addr + 5, _RELDATA_RAV(1)); - // Specify the size - memcpy((void*)((uintptr_t)_RELDATA_ADDR(0) + 0x93), &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); - - // Modify CreateHandle - addr = (uintptr_t)_RELDATA_ADDR(3); - memcpy((void*)(addr + 0x12F), &BSUntypedPointerHandle_Extended::MAX_HANDLE_COUNT, 4); - uint32_t mask = BSUntypedPointerHandle_Extended::MASK_ACTIVE_BIT | BSUntypedPointerHandle_Extended::MASK_INDEX_BIT; - memcpy((void*)(addr + 0x134), &mask, 4); - } + using namespace std::chrono; + auto timerStart = high_resolution_clock::now(); + BSPointerHandleManagerCurrent::PointerHandleManagerCurrentId = 2; lpRelocator->DetourCall(_RELDATA_RAV(0), - (uintptr_t)&BSPointerHandleManager_Extended::InitSDM); + (uintptr_t)&BSPointerHandleManager_Extended_NG::InitSDM); lpRelocator->DetourCall(_RELDATA_RAV(2), - (uintptr_t)&BSPointerHandleManager_Extended::KillSDM); - - // Unfortunately, the array cleanup is not going through, so let's reset it ourselves - //lpRelocator->DetourJump(_RELDATA_RAV(15), - // (uintptr_t)&BSPointerHandleManager_Extended::CleanSDM); + (uintptr_t)&BSPointerHandleManager_Extended_NG::KillSDM); ScopeRelocator textSection; auto textRange = GlobalEnginePtr->GetSection(SECTION_TEXT); + auto addr = (uintptr_t)_RELDATA_RAV(0); + // Preparation, removal of all embedded pieces of code + lpRelocator->PatchNop(addr + 12, 0x7A); + lpRelocator->PatchMovFromRax(addr + 5, _RELDATA_RAV(1)); + // Specify the size + memcpy((void*)((uintptr_t)_RELDATA_ADDR(0) + 0x93), &BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT, 4); + + // Debug (for check) + //static std::vector storage; + auto __InstallPatchByPatternMask = [&textRange]( const char* pattern_mask, // pattern "? ? 00 E0 03" size_t offset, // offset from find patterns array @@ -225,47 +237,59 @@ namespace CreationKitPlatformExtended const void* source, // buffer size_t ssize // buffer size ) -> size_t { - auto patterns = voltek::find_patterns(textRange.base, textRange.end - textRange.base, pattern_mask); - if (patterns.size() > offset) - { - size_t max = std::min(patterns.size(), count + offset); - for (size_t index = offset; index < max; index++) - memcpy((void*)(patterns[index] + offset_find), source, ssize); + auto patterns = voltek::find_patterns(textRange.base, textRange.end - textRange.base, pattern_mask); - // Debug - //_CONSOLE("__InstallPatchByPatternMask() function was executed successfully. PatternMask: \"%s\", Count: %llu", - // pattern_mask, max - offset); + // Debug (for check) + //storage.append_range(patterns); - return max - offset; - } - //else - //{ - // // Debug - // _CONSOLE("__InstallPatchByPatternMask() function return failed. PatternMask: \"%s\", Count: %llu", - // pattern_mask, 0); - //} + if (patterns.size() > offset) + { + size_t max = std::min(patterns.size(), count + offset); + for (size_t index = offset; index < max; index++) + memcpy((void*)(patterns[index] + offset_find), source, ssize); - return 0; - }; + // Debug + //_CONSOLE("__InstallPatchByPatternMask() function was executed successfully. PatternMask: \"%s\", Count: %llu", + // pattern_mask, max - offset); + + return max - offset; + } + //else + //{ + // // Debug + // _CONSOLE("__InstallPatchByPatternMask() function return failed. PatternMask: \"%s\", Count: %llu", + // pattern_mask, 0); + //} + + return 0; + }; auto __InstallPatchByPatternMaskCustom = [&textRange]( const char* pattern_mask, // pattern "? ? 00 E0 03" size_t offset, // offset from find patterns array size_t count, // count need change - void(callback)(uintptr_t addr) // callback function + bool(callback)(uintptr_t addr) // callback function ) -> size_t { auto patterns = voltek::find_patterns(textRange.base, textRange.end - textRange.base, pattern_mask); + + // Debug (for check) + //storage.append_range(patterns); + if (patterns.size() > offset) { size_t max = std::min(patterns.size(), count + offset); + size_t total = 0; for (size_t index = offset; index < max; index++) - callback(patterns[index]); + { + if (callback(patterns[index])) + total++; + } // Debug //_CONSOLE("__InstallPatchByPatternMask() function was executed successfully. PatternMask: \"%s\", Count: %llu", // pattern_mask, max - offset); - return max - offset; + return total; } //else //{ @@ -287,6 +311,10 @@ namespace CreationKitPlatformExtended std::initializer_list excludes // list exclude indexes ) -> size_t { auto patterns = voltek::find_patterns(textRange.base, textRange.end - textRange.base, pattern_mask); + + // Debug (for check) + //storage.append_range(patterns); + if (patterns.size() > offset) { size_t max = std::min(patterns.size(), count + offset); @@ -315,148 +343,567 @@ namespace CreationKitPlatformExtended }; size_t total = 0; + size_t total_patches = 0; + static uint8_t buffer_cmd[0x10]; - _MESSAGE("Change BSPointerHandle inline functions"); +#if CKPE_FO4_ENABLED_REFLIMIT + // == REF_COUNT_MASK + total += __InstallPatchByPatternMaskCustom("? FF 03 00 00 ? FF 03 00 00", 0, -1, [](uintptr_t addr) -> bool + { + memcpy((uint8_t*)(addr + 1), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + memcpy((uint8_t*)(addr + 6), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + return true; + }); - // Change AGE - total += __InstallPatchByPatternMask("A9 00 00 E0 03", 0, -1, 1, &BSUntypedPointerHandle_Extended::MASK_AGE_BIT, 4); - total += __InstallPatchByPatternMask("F7 ? 00 00 E0 03", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_AGE_BIT, 4); - total += __InstallPatchByPatternMask("25 00 00 E0 03", 0, -1, 1, &BSUntypedPointerHandle_Extended::MASK_AGE_BIT, 4); - total += __InstallPatchByPatternMask("81 ? 00 00 E0 03", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_AGE_BIT, 4); + total += __InstallPatchByPatternMaskCustom("F7 ? ? FF 03 00 00", 0, -1, [](uintptr_t addr) -> bool + { + if ((*(uint8_t*)(addr + 2) != 0x38) && (*(uint8_t*)(addr + 2) != 0x8)) return false; + memcpy((uint8_t*)(addr + 3), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + return true; + }); - _MESSAGE("AGE Total %llu", total); + total += __InstallPatchByPatternMaskCustom("81 ? ? FF 03 00 00", 0, -1, [](uintptr_t addr) -> bool + { + if ((*(uint8_t*)(addr + 2) != 0x38) && (*(uint8_t*)(addr + 2) != 0x8)) return false; + memcpy((uint8_t*)(addr + 3), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + return true; + }); + + total += __InstallPatchByPatternMask("FF C8 A9 FF 03 00 00", 0, -1, 3, + &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + total += __InstallPatchByPatternMask("FF ? F7 ? FF 03 00 00", 0, -1, 4, + &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + total += __InstallPatchByPatternMask("41 F7 ? 24 38 FF 03 00 00", 0, -1, 5, + &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + total += __InstallPatchByPatternMask("41 FF ? 41 F7 ? FF 03 00 00", 0, -1, 6, + &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + + total += __InstallPatchByPatternMaskCustom("81 ? FF 03 00 00 81 ? FF 03 00 00", 0, 20, [](uintptr_t addr) -> bool + { + memcpy((uint8_t*)(addr + 2), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + memcpy((uint8_t*)(addr + 8), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + return true; + }); + + total += __InstallPatchByPatternMaskCustom("? FF 03 00 00 ? ? ? ? ? ? ? ? ? FF 03 00 00", 0, 20, [](uintptr_t addr) -> bool + { + memcpy((uint8_t*)(addr + 1), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + memcpy((uint8_t*)(addr + 14), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + return true; + }); + memcpy((uint8_t*)(lpRelocator->GetBase() + 0x538ACF), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + memcpy((uint8_t*)(lpRelocator->GetBase() + 0x53B0A1), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + memcpy((uint8_t*)(lpRelocator->GetBase() + 0x5B64B6), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + memcpy((uint8_t*)(lpRelocator->GetBase() + 0x5B64C4), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + memcpy((uint8_t*)(lpRelocator->GetBase() + 0xD3A786), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + memcpy((uint8_t*)(lpRelocator->GetBase() + 0xD9B4E2), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + memcpy((uint8_t*)(lpRelocator->GetBase() + 0xD9B5D1), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + memcpy((uint8_t*)(lpRelocator->GetBase() + 0x5AF00D), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + memcpy((uint8_t*)(lpRelocator->GetBase() + 0x5AF018), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + memcpy((uint8_t*)(lpRelocator->GetBase() + 0x5AF2B0), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + memcpy((uint8_t*)(lpRelocator->GetBase() + 0x5AF2C6), &EditorAPI::BSHandleRefObject_Extremly::REF_COUNT_MASK, 4); + + total_patches += total + 7; total = 0; - // Change INDEX - total += __InstallPatchByPatternMask("41 81 ? FF FF 1F 00", 0, -1, 3, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); - total += __InstallPatchByPatternMask("81 E1 FF FF 1F 00", 3, 25, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); - total += __InstallPatchByPatternMaskEx("81 E5 FF FF 1F 00", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4, { 4, 8 }); - total += __InstallPatchByPatternMaskEx("81 E6 FF FF 1F 00", 3, 24, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4, { 7, 8 }); - total += __InstallPatchByPatternMask("81 E7 FF FF 1F 00", 2, 1, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); - total += __InstallPatchByPatternMask("8B C7 25 FF FF 1F 00 8B D8", 0, -1, 3, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); - total += __InstallPatchByPatternMask("81 ? FF FF 1F 00 ? ? 48 ? ? 04", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); - total += __InstallPatchByPatternMask("81 ? FF FF 1F 00 ? ? ? ? ? ? 48 ? ? 04", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); - total += __InstallPatchByPatternMask("81 ? FF FF 1F 00 ? ? ? ? ? ? 44 ? ? 41 ? 00 00 00 00 49 ? ? 04", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); - total += __InstallPatchByPatternMask("81 ? FF FF 1F 00 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 49 ? ? 04", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); - total += __InstallPatchByPatternMask("81 E2 FF FF 1F 00", 0, 2, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); - - memcpy((void*)(lpRelocator->GetBase() + 0x5279F9), &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); - total += 1; + // CreateHandle fix + *(uint8_t*)(lpRelocator->GetBase() + 0x526D5D) = (uint8_t)EditorAPI::BSHandleRefObject_Extremly::ACTIVE_BIT_INDEX; + *(uint8_t*)(lpRelocator->GetBase() + 0x526DC6) = (uint8_t)EditorAPI::BSHandleRefObject_Extremly::ACTIVE_BIT_INDEX; + *(uint8_t*)(lpRelocator->GetBase() + 0x526EAC) = (uint8_t)EditorAPI::BSHandleRefObject_Extremly::ACTIVE_BIT_INDEX; + *(uint8_t*)(lpRelocator->GetBase() + 0x526D64) = (uint8_t)EditorAPI::BSHandleRefObject_Extremly::HANDLE_BIT_INDEX; + *(uint8_t*)(lpRelocator->GetBase() + 0x526DCE) = (uint8_t)EditorAPI::BSHandleRefObject_Extremly::HANDLE_BIT_INDEX; + *(uint8_t*)(lpRelocator->GetBase() + 0x526EA8) = (uint8_t)EditorAPI::BSHandleRefObject_Extremly::HANDLE_BIT_INDEX; + + addr = (uintptr_t)_RELDATA_ADDR(3); + memcpy((void*)(addr + 0x12F), &BSUntypedPointerHandle_Extended_NG::MAX_HANDLE_COUNT, 4); + uint32_t mask = BSUntypedPointerHandle_Extended_NG::MASK_ACTIVE_BIT | BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT; + memcpy((void*)(addr + 0x134), &mask, 4); + + // Change HANDLE_BIT_INDEX + uint8_t bit_byte = (uint8_t)EditorAPI::BSHandleRefObject_Extremly::HANDLE_BIT_INDEX; + total += __InstallPatchByPatternMask("C1 ? 0B 3B", 0, -1, 2, &bit_byte, 1); + total += __InstallPatchByPatternMask("C1 ? 0B 41 3B", 0, -1, 2, &bit_byte, 1); + + total_patches += total; + total = 0; - _MESSAGE("INDEX Total %llu", total); + // Change AGE + total += __InstallPatchByPatternMask("A9 00 00 E0 03", 0, -1, 1, + &BSUntypedPointerHandle_Extended_NG::MASK_AGE_BIT, 4); + total += __InstallPatchByPatternMask("F7 ? 00 00 E0 03", 0, -1, 2, + &BSUntypedPointerHandle_Extended_NG::MASK_AGE_BIT, 4); + total += __InstallPatchByPatternMask("25 00 00 E0 03", 0, -1, 1, + &BSUntypedPointerHandle_Extended_NG::MASK_AGE_BIT, 4); + total += __InstallPatchByPatternMask("81 ? 00 00 E0 03", 0, -1, 2, + &BSUntypedPointerHandle_Extended_NG::MASK_AGE_BIT, 4); + + total_patches += total; + total = 0; + // Change INDEX + total += __InstallPatchByPatternMask("41 81 ? FF FF 1F 00", 0, -1, 3, + &BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT, 4); + total += __InstallPatchByPatternMask("81 E1 FF FF 1F 00", 3, 25, 2, + &BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT, 4); + total += __InstallPatchByPatternMaskEx("81 E5 FF FF 1F 00", 0, -1, 2, + &BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT, 4, { 4, 8 }); + total += __InstallPatchByPatternMaskEx("81 E6 FF FF 1F 00", 3, 24, 2, + &BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT, 4, { 7, 8 }); + total += __InstallPatchByPatternMask("81 E7 FF FF 1F 00", 2, 1, 2, + &BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT, 4); + total += __InstallPatchByPatternMask("8B C7 25 FF FF 1F 00 8B D8", 0, -1, 3, + &BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT, 4); + total += __InstallPatchByPatternMask("81 ? FF FF 1F 00 ? ? 48 ? ? 04", 0, -1, 2, + &BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT, 4); + total += __InstallPatchByPatternMask("81 ? FF FF 1F 00 ? ? ? ? ? ? 48 ? ? 04", 0, -1, 2, + &BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT, 4); + total += __InstallPatchByPatternMask("81 ? FF FF 1F 00 ? ? ? ? ? ? 44 ? ? 41 ? 00 00 00 00 49 ? ? 04", 0, -1, 2, + &BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT, 4); + total += __InstallPatchByPatternMask("81 ? FF FF 1F 00 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 49 ? ? 04", 0, -1, 2, + &BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT, 4); + total += __InstallPatchByPatternMask("81 E2 FF FF 1F 00", 0, 2, 2, + &BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT, 4); + + memcpy((void*)(lpRelocator->GetBase() + 0x5279F9), + &BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT, 4); + + total += 1; + total_patches += total; total = 0; - uint32_t not_mask = ~BSUntypedPointerHandle_Extended::MASK_INDEX_BIT; + + uint32_t not_mask = ~BSUntypedPointerHandle_Extended_NG::MASK_INDEX_BIT; // Change NOT MASK_INDEX_BIT total += __InstallPatchByPatternMask("81 ? 00 00 E0 FF", 0, 56, 2, ¬_mask, 4); - _MESSAGE("NOT MASK_INDEX_BIT Total %llu", total); - + total_patches += total; + //_MESSAGE("NOT MASK_INDEX_BIT Total %llu", total); + total = 0; - not_mask = ~BSUntypedPointerHandle_Extended::MASK_ACTIVE_BIT; + not_mask = ~BSUntypedPointerHandle_Extended_NG::MASK_ACTIVE_BIT; // Change NOT MASK_ACTIVE_BIT total += __InstallPatchByPatternMask("81 ? FF FF FF FB", 0, -1, 2, ¬_mask, 4); - _MESSAGE("NOT MASK_INDEX_BIT Total %llu", total); + total_patches += total; + //_MESSAGE("NOT MASK_INDEX_BIT Total %llu", total); total = 0; // Change UNUSED_BIT_START - total += __InstallPatchByPatternMask("0F BA E0 1A", 0, 317, 3, &BSUntypedPointerHandle_Extended::UNUSED_BIT_START, 1); - total += __InstallPatchByPatternMaskEx("0F BA ?? 1A", 0, 72, 3, &BSUntypedPointerHandle_Extended::UNUSED_BIT_START, 1, + total += __InstallPatchByPatternMask("0F BA E0 1A", 0, 317, 3, + &BSUntypedPointerHandle_Extended_NG::UNUSED_BIT_START, 1); + total += __InstallPatchByPatternMaskEx("0F BA ?? 1A", 0, 72, 3, + &BSUntypedPointerHandle_Extended_NG::UNUSED_BIT_START, 1, { 18, 19, 23, 24, 30, 38, 39, 47, 48, 63, 64, 65, 66, 67, 68 }); - _MESSAGE("UNUSED_BIT_START Total %llu", total); - + total_patches += total; total = 0; - // Change REFR test handle index - total += __InstallPatchByPatternMaskCustom("8B ? 38 C1 ? 0B 41 3B ?", 0, -1, [](uintptr_t addr) - { - *(uint8_t*)(addr + 2) = (uint8_t)0x39; - *(uint8_t*)(addr + 5) = (uint8_t)0x3; - }); - total += __InstallPatchByPatternMaskCustom("8B ? 38 C1 ? 0B 3B ?", 0, -1, [](uintptr_t addr) - { - *(uint8_t*)(addr + 2) = (uint8_t)0x39; - *(uint8_t*)(addr + 5) = (uint8_t)0x3; - }); - - _MESSAGE("REFR_TEST Total %llu", total); - - total = 0; - // Change MAX_HANDLE_COUNT - total += __InstallPatchByPatternMask("81 ? 00 00 20 00", 0, 1, 2, &BSUntypedPointerHandle_Extended::MAX_HANDLE_COUNT, 4); - total += __InstallPatchByPatternMask("BD 00 00 20 00", 0, -1, 1, &BSUntypedPointerHandle_Extended::MAX_HANDLE_COUNT, 4); - - _MESSAGE("MAX_HANDLE_COUNT Total %llu", total); + total += __InstallPatchByPatternMask("81 ? 00 00 20 00", 0, 1, 2, &BSUntypedPointerHandle_Extended_NG::MAX_HANDLE_COUNT, 4); + total += __InstallPatchByPatternMask("BD 00 00 20 00", 0, -1, 1, &BSUntypedPointerHandle_Extended_NG::MAX_HANDLE_COUNT, 4); + + total_patches += total; + //_MESSAGE("MAX_HANDLE_COUNT Total %llu", total); total = 0; // Change MASK_ACTIVE_BIT - total += __InstallPatchByPatternMask("F7 ? 00 00 00 04", 0, 3, 2, &BSUntypedPointerHandle_Extended::MASK_ACTIVE_BIT, 4); + total += __InstallPatchByPatternMask("F7 ? 00 00 00 04", 0, 3, 2, &BSUntypedPointerHandle_Extended_NG::MASK_ACTIVE_BIT, 4); +#else + AssertMsg("Refrs extension is disabled by perchik71, it may be in implementation or abandoned."); +#endif /* CKPE_FO4_ENABLED_REFLIMIT */ - _MESSAGE("MASK_ACTIVE_BIT Total %llu", total); - } - else - { - BSPointerHandleManagerCurrent::PointerHandleManagerCurrentId = 0; + //////////////////////////////////////////////////////////////////////////////////////////////////// + // + // REFUSAL FOR NG, MAINTAINING 64 MILLION LINKS (2^26) IS TOO DIFFICULT AND UNSTABLE, TY FUCKESDA. + // THE PROBLEM: MULTIPLE INSERTS OF THE FUNCTION AS INLINE, THE INABILITY TO STABLY EDIT THE DECREF + // CODE, SINCE -1 MAY BE FAR FROM THE CODE SNIPPET. + // + //////////////////////////////////////////////////////////////////////////////////////////////////// + + // BSPointerHandleManagerCurrent::PointerHandleManagerCurrentId = 1; //{ // ScopeRelocator textSection; + // auto addr = (uintptr_t)_RELDATA_RAV(0); // // Preparation, removal of all embedded pieces of code - // lpRelocator->PatchNop((uintptr_t)lpRelocationDatabaseItem->At(0) + 12, 0x7A); - // lpRelocator->PatchMovFromRax((uintptr_t)lpRelocationDatabaseItem->At(0) + 5, lpRelocationDatabaseItem->At(1)); - - // // Stub out the rest of the functions which shouldn't ever be called now - // lpRelocator->Patch(lpRelocationDatabaseItem->At(4), { 0xCC }); // BSUntypedPointerHandle::Set + // lpRelocator->PatchNop(addr + 12, 0x7A); + // lpRelocator->PatchMovFromRax(addr + 5, _RELDATA_RAV(1)); + // // Specify the size + // memcpy((void*)((uintptr_t)_RELDATA_ADDR(0) + 0x93), &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); + + // // Modify CreateHandle + // addr = (uintptr_t)_RELDATA_ADDR(3); + // memcpy((void*)(addr + 0x12F), &BSUntypedPointerHandle_Extended::MAX_HANDLE_COUNT, 4); + // uint32_t mask = BSUntypedPointerHandle_Extended::MASK_ACTIVE_BIT | BSUntypedPointerHandle_Extended::MASK_INDEX_BIT; + // memcpy((void*)(addr + 0x134), &mask, 4); + // /* + // *(uint8_t*)(addr + 0x34) = 3; + // *(uint8_t*)(addr + 0x2D) = 2; + // *(uint8_t*)(addr + 0x21) = 0x39; + + // *(uint8_t*)(addr + 0x9E) = 3; + // *(uint8_t*)(addr + 0x96) = 2; + // *(uint8_t*)(addr + 0x8E) = 0x39; + + // *(uint8_t*)(addr + 0x178) = 3; + // *(uint8_t*)(addr + 0x17C) = 2; + // *(uint8_t*)(addr + 0x17F) = 0x39;*/ //} - //lpRelocator->DetourCall(lpRelocationDatabaseItem->At(0), - // (uintptr_t)&BSPointerHandleManager_Original::InitSDM); - //lpRelocator->DetourCall(lpRelocationDatabaseItem->At(2), - // (uintptr_t)&BSPointerHandleManager_Original::KillSDM); - //// Unfortunately, the array cleanup is not going through, so let's reset it ourselves - //lpRelocator->DetourJump(lpRelocationDatabaseItem->At(15), - // (uintptr_t)&BSPointerHandleManager_Original::CleanSDM); - //lpRelocator->DetourJump(lpRelocationDatabaseItem->At(3), - // (uintptr_t)&BSPointerHandleManagerInterface_Original::CreateHandle); - //lpRelocator->DetourJump(lpRelocationDatabaseItem->At(5), - // (uintptr_t)&BSPointerHandleManagerInterface_Original::Destroy1); - //lpRelocator->DetourJump(lpRelocationDatabaseItem->At(6), - // (uintptr_t)&BSPointerHandleManagerInterface_Original::Destroy2); - - //lpRelocator->DetourCall(lpRelocationDatabaseItem->At(16), (uintptr_t)&Check); + // + + // Change DecRef + // total += __InstallPatchByPatternMaskCustom("B8 FF FF FF FF F0 0F C1 ? 08 FF C8 A9 FF 03", 0, -1, [](uintptr_t addr) -> bool + // { + // memcpy(buffer_cmd, (uint8_t*)(addr + 6), 3); + // memcpy((uint8_t*)addr, "\x48\x83\xC8\xFF\xF0\x48\x90\x90\x90\x08", 10); + // memcpy((uint8_t*)(addr + 6), buffer_cmd, 3); + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("B8 FF FF FF FF F0 0F C1 ? 38 FF C8", 0, -1, [](uintptr_t addr) -> bool + // { + // memcpy(buffer_cmd, (uint8_t*)(addr + 6), 3); + // memcpy((uint8_t*)addr, "\x48\x83\xC8\xFF\xF0\x48\x90\x90\x90\x38", 10); + // memcpy((uint8_t*)(addr + 6), buffer_cmd, 3); + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("BA FF FF FF FF F0 0F C1 ? 08 FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // memcpy(buffer_cmd, (uint8_t*)(addr + 6), 3); + // memcpy((uint8_t*)addr, "\x48\x83\xCA\xFF\xF0\x48\x90\x90\x90\x08", 10); + // memcpy((uint8_t*)(addr + 6), buffer_cmd, 3); + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("BA FF FF FF FF F0 0F C1 ? 38 FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // memcpy(buffer_cmd, (uint8_t*)(addr + 6), 3); + // memcpy((uint8_t*)addr, "\x48\x83\xCA\xFF\xF0\x48\x90\x90\x90\x38", 10); + // memcpy((uint8_t*)(addr + 6), buffer_cmd, 3); + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("BE FF FF FF FF F0 0F C1 ? 38 FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // memcpy(buffer_cmd, (uint8_t*)(addr + 6), 3); + // memcpy((uint8_t*)addr, "\x48\x83\xCE\xFF\xF0\x48\x90\x90\x90\x38", 10); + // memcpy((uint8_t*)(addr + 6), buffer_cmd, 3); + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("BD FF FF FF FF F0 0F C1 ? 38 FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // memcpy(buffer_cmd, (uint8_t*)(addr + 6), 3); + // memcpy((uint8_t*)addr, "\x48\x83\xCD\xFF\xF0\x48\x90\x90\x90\x38", 10); + // memcpy((uint8_t*)(addr + 6), buffer_cmd, 3); + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("BB FF FF FF FF F0 0F C1 ? 08 FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // memcpy(buffer_cmd, (uint8_t*)(addr + 6), 3); + // memcpy((uint8_t*)addr, "\x48\x83\xCB\xFF\xF0\x48\x90\x90\x90\x08", 10); + // memcpy((uint8_t*)(addr + 6), buffer_cmd, 3); + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("48 ? ? FF FF FF FF F0 0F C1 ? 38 FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // memcpy(buffer_cmd, (uint8_t*)(addr + 8), 3); + // if (*(uint8_t*)(addr + 2) == 0xC0) + // memcpy((uint8_t*)addr, "\x48\x83\xC8\xFF\xF0\x48\x90\x90\x90\x38\x90\x90", 12); + // else if (*(uint8_t*)(addr + 2) == 0xC7) + // memcpy((uint8_t*)addr, "\x48\x83\xCF\xFF\xF0\x48\x90\x90\x90\x38\x90\x90", 12); + // else if (*(uint8_t*)(addr + 2) == 0xC6) + // memcpy((uint8_t*)addr, "\x48\x83\xCE\xFF\xF0\x48\x90\x90\x90\x38\x90\x90", 12); + // else return false; + // memcpy((uint8_t*)(addr + 6), buffer_cmd, 3); + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("48 ? ? FF FF FF FF F0 0F C1 ? 08 FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // memcpy(buffer_cmd, (uint8_t*)(addr + 8), 3); + // if (*(uint8_t*)(addr + 2) == 0xC0) + // memcpy((uint8_t*)addr, "\x48\x83\xC8\xFF\xF0\x48\x90\x90\x90\x08\x90\x90", 12); + // else if (*(uint8_t*)(addr + 2) == 0xC3) + // memcpy((uint8_t*)addr, "\x48\x83\xCB\xFF\xF0\x48\x90\x90\x90\x08\x90\x90", 12); + // else if (*(uint8_t*)(addr + 2) == 0xC6) + // memcpy((uint8_t*)addr, "\x48\x83\xCE\xFF\xF0\x48\x90\x90\x90\x08\x90\x90", 12); + // else return false; + // memcpy((uint8_t*)(addr + 6), buffer_cmd, 3); + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("? FF FF FF FF F0 ? 0F C1 ? ? ? FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // if ((*(uint8_t*)addr == 0xC7) || (*(uint8_t*)addr == 0xC6)) + // *(uint8_t*)(addr + 6) += 0x8; + // else if ((*(uint8_t*)addr == 0xBF) || (*(uint8_t*)addr == 0xBE)) + // { + // memcpy(buffer_cmd, (uint8_t*)(addr + 7), 4); + // if (*(uint8_t*)addr == 0xBF) + // memcpy((uint8_t*)addr, "\x49\x83\xCF\xFF\xF0\x4C\x90\x90\x90\x90\x90", 11); + // else + // memcpy((uint8_t*)addr, "\x49\x83\xCE\xFF\xF0\x4C\x90\x90\x90\x90\x90", 11); + // memcpy((uint8_t*)(addr + 6), buffer_cmd, 4); + // } + // else if (*(uint8_t*)addr == 0xB8) + // { + // memcpy(buffer_cmd, (uint8_t*)(addr + 7), 5); + // memcpy((uint8_t*)addr, "\x48\x83\xC8\xFF\xF0\x49\x90\x90\x90\x90\x90\x90", 12); + // memcpy((uint8_t*)(addr + 6), buffer_cmd, 5); + // } + // else return false; + + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("8B ? F0 ? 0F C1 ? ? FF ?", 0, 36, [](uintptr_t addr) -> bool + // { + // // mov r??, r?? + // // lock xadd dword ptr ds:[r?? + 0x??], r?? + // // FF r?? + // if (*(uint8_t*)(addr - 1) == 0x41) // prefix + // *(uint8_t*)(addr - 1) = 0x49; + // *(uint8_t*)(addr + 3) += 8; + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("8B ? F0 0F C1 ? ? FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // // mov r??, r?? + // // lock xadd dword ptr ds:[r?? + 0x??], r?? + // // FF r?? + // *(uint8_t*)(addr + 2) = 0x48; // remove lock prefix (idk stable or no) + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("F0 0F C1 ? 38 FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // *(uint8_t*)addr = 0x48; // remove lock prefix (idk stable or no) + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("F0 0F C1 ? 08 FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // + // + // *(uint8_t*)addr = 0x48; // remove lock prefix (idk stable or no) + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("F0 44 0F C1 ? 38 ? FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // *(uint8_t*)(addr + 1) = 0x4C; + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("F0 41 0F C1 ? 38 FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // if ((*(uint8_t*)(addr - 5) == 0xB8) && (*(uint8_t*)(addr - 1) == 0xFF)) + // memcpy((uint8_t*)(addr - 5), "\x48\x83\xC8\xFF\x90\x90", 5); + // *(uint8_t*)(addr + 1) = 0x49; + // return true; + // }); + // + // total += __InstallPatchByPatternMaskCustom("F0 41 0F C1 ? 08 FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // if ((*(uint8_t*)(addr - 5) == 0xB8) && (*(uint8_t*)(addr - 1) == 0xFF)) + // memcpy((uint8_t*)(addr - 5), "\x48\x83\xC8\xFF\x90\x90", 5); + // *(uint8_t*)(addr + 1) = 0x49; + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("F0 44 0F C1 ? 08 ? FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // *(uint8_t*)(addr + 1) = 0x4C; + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("B8 FF FF FF FF F0 0F C1 ? 38 ? ? ? ? ? FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // memcpy(buffer_cmd, (uint8_t*)(addr + 6), 3); + // memcpy((uint8_t*)addr, "\x48\x83\xC8\xFF\xF0\x48\x90\x90\x90\x38", 10); + // memcpy((uint8_t*)(addr + 6), buffer_cmd, 3); + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("F0 45 0F C1 ? 38 ? FF ?", 0, -1, [](uintptr_t addr) -> bool + // { + // *(uint8_t*)(addr + 1) = 0x4D; + // return true; + // }); + + // lpRelocator->Patch(0x83BC03, { 0x4D }); + // total++; + + // total_patches += total; + // //_MESSAGE("DecRef Total %llu", total); + + // total = 0; + + // // Change AGE + // total += __InstallPatchByPatternMask("A9 00 00 E0 03", 0, -1, 1, &BSUntypedPointerHandle_Extended::MASK_AGE_BIT, 4); + // total += __InstallPatchByPatternMask("F7 ? 00 00 E0 03", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_AGE_BIT, 4); + // total += __InstallPatchByPatternMask("25 00 00 E0 03", 0, -1, 1, &BSUntypedPointerHandle_Extended::MASK_AGE_BIT, 4); + // total += __InstallPatchByPatternMask("81 ? 00 00 E0 03", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_AGE_BIT, 4); + + // total_patches += total; + // //_MESSAGE("AGE Total %llu", total); + + // total = 0; + + // // Change INDEX + // total += __InstallPatchByPatternMask("41 81 ? FF FF 1F 00", 0, -1, 3, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); + // total += __InstallPatchByPatternMask("81 E1 FF FF 1F 00", 3, 25, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); + // total += __InstallPatchByPatternMaskEx("81 E5 FF FF 1F 00", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4, { 4, 8 }); + // total += __InstallPatchByPatternMaskEx("81 E6 FF FF 1F 00", 3, 24, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4, { 7, 8 }); + // total += __InstallPatchByPatternMask("81 E7 FF FF 1F 00", 2, 1, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); + // total += __InstallPatchByPatternMask("8B C7 25 FF FF 1F 00 8B D8", 0, -1, 3, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); + // total += __InstallPatchByPatternMask("81 ? FF FF 1F 00 ? ? 48 ? ? 04", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); + // total += __InstallPatchByPatternMask("81 ? FF FF 1F 00 ? ? ? ? ? ? 48 ? ? 04", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); + // total += __InstallPatchByPatternMask("81 ? FF FF 1F 00 ? ? ? ? ? ? 44 ? ? 41 ? 00 00 00 00 49 ? ? 04", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); + // total += __InstallPatchByPatternMask("81 ? FF FF 1F 00 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 49 ? ? 04", 0, -1, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); + // total += __InstallPatchByPatternMask("81 E2 FF FF 1F 00", 0, 2, 2, &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); + // + // memcpy((void*)(lpRelocator->GetBase() + 0x5279F9), &BSUntypedPointerHandle_Extended::MASK_INDEX_BIT, 4); + // total += 1; + + // total_patches += total; + // //_MESSAGE("INDEX Total %llu", total); + + // total = 0; + // uint32_t not_mask = ~BSUntypedPointerHandle_Extended::MASK_INDEX_BIT; + + // // Change NOT MASK_INDEX_BIT + // total += __InstallPatchByPatternMask("81 ? 00 00 E0 FF", 0, 56, 2, ¬_mask, 4); + + // total_patches += total; + // //_MESSAGE("NOT MASK_INDEX_BIT Total %llu", total); + + // total = 0; + // not_mask = ~BSUntypedPointerHandle_Extended::MASK_ACTIVE_BIT; + + // // Change NOT MASK_ACTIVE_BIT + // total += __InstallPatchByPatternMask("81 ? FF FF FF FB", 0, -1, 2, ¬_mask, 4); + + // total_patches += total; + // //_MESSAGE("NOT MASK_INDEX_BIT Total %llu", total); + + // total = 0; + + // // Change UNUSED_BIT_START + // total += __InstallPatchByPatternMask("0F BA E0 1A", 0, 317, 3, &BSUntypedPointerHandle_Extended::UNUSED_BIT_START, 1); + // total += __InstallPatchByPatternMaskEx("0F BA ?? 1A", 0, 72, 3, &BSUntypedPointerHandle_Extended::UNUSED_BIT_START, 1, + // { 18, 19, 23, 24, 30, 38, 39, 47, 48, 63, 64, 65, 66, 67, 68 }); + + // total_patches += total; + // //_MESSAGE("UNUSED_BIT_START Total %llu", total); + + // total = 0; + // // Need to fix it, in order to apply it to the entire register, will have to capture what is not needed... + + // /*total += __InstallPatchByPatternMaskCustom("41 ? FF FF FF FF", 0, -1, [](uintptr_t addr) -> bool + // { + // if (*(uint8_t*)(addr - 1) == 0xC7) return false; + // auto reg = *(uint8_t*)(addr + 1); + // memcpy((uint8_t*)addr, "\x49\x83\x90\xFF\x90\x90", 6); + // *(uint8_t*)(addr + 2) = reg + 0x10; + // return true; + // });*/ + + // lpRelocator->Patch(0xD46793, { 0x48, 0x83, 0xCF, 0xFF }); + // + // total_patches += total + 1; + // //_MESSAGE("FIXED_FFFFFFFF Total %llu", total); + // + // total = 0; + + // // Change REFR test handle index + ///* total += __InstallPatchByPatternMaskCustom("8B ? 38 C1 ? 0B 41 3B ?", 0, -1, [](uintptr_t addr) -> bool + // { + // *(uint8_t*)(addr + 2) = (uint8_t)0x39; + // *(uint8_t*)(addr + 5) = (uint8_t)0x3; + // return true; + // }); + // total += __InstallPatchByPatternMaskCustom("8B ? 38 C1 ? 0B 3B ?", 0, -1, [](uintptr_t addr) -> bool + // { + // *(uint8_t*)(addr + 2) = (uint8_t)0x39; + // *(uint8_t*)(addr + 5) = (uint8_t)0x3; + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("? ? 08 C1 ? 0B 3B", 0, -1, [](uintptr_t addr) -> bool + // { + // *(uint8_t*)(addr + 2) = (uint8_t)0x9; + // *(uint8_t*)(addr + 5) = (uint8_t)0x3; + // return true; + // }); + + // total += __InstallPatchByPatternMaskCustom("? ? 08 C1 ? 0B 41 3B", 0, -1, [](uintptr_t addr) -> bool + // { + // *(uint8_t*)(addr + 2) = (uint8_t)0x9; + // *(uint8_t*)(addr + 5) = (uint8_t)0x3; + // return true; + // }); + // + // total += __InstallPatchByPatternMaskCustom("8B ? 38 8B ? C1 ? 0B", 0, -1, [](uintptr_t addr) -> bool + // { + // *(uint8_t*)(addr + 2) = (uint8_t)0x9; + // *(uint8_t*)(addr + 7) = (uint8_t)0x3; + // return true; + // }); + // + // total += __InstallPatchByPatternMaskCustom("? ? 38 C1 ? 0B 41 3B", 0, -1, [](uintptr_t addr) -> bool + // { + // *(uint8_t*)(addr + 2) = (uint8_t)0x9; + // *(uint8_t*)(addr + 5) = (uint8_t)0x3; + // return true; + // });*/ + + // total_patches += total; + // //_MESSAGE("REFR_TEST Total %llu", total); + + // total = 0; + + // // Change MAX_HANDLE_COUNT + // total += __InstallPatchByPatternMask("81 ? 00 00 20 00", 0, 1, 2, &BSUntypedPointerHandle_Extended::MAX_HANDLE_COUNT, 4); + // total += __InstallPatchByPatternMask("BD 00 00 20 00", 0, -1, 1, &BSUntypedPointerHandle_Extended::MAX_HANDLE_COUNT, 4); + // + // total_patches += total; + // //_MESSAGE("MAX_HANDLE_COUNT Total %llu", total); + + // total = 0; - //{ - // ScopeRelocator textSection; + // // Change MASK_ACTIVE_BIT + // total += __InstallPatchByPatternMask("F7 ? 00 00 00 04", 0, 3, 2, &BSUntypedPointerHandle_Extended::MASK_ACTIVE_BIT, 4); - // // - // // Deleting the code, restoring the function - // // - // restoring_destroy1(lpRelocationDatabaseItem->At(7), 0xF2, - // (uintptr_t)&BSPointerHandleManagerInterface_Original::Destroy1); - // restoring_destroy1(lpRelocationDatabaseItem->At(8), 0xFE, - // (uintptr_t)&BSPointerHandleManagerInterface_Original::Destroy1); - // restoring_destroy1(lpRelocationDatabaseItem->At(9), 0xFE, - // (uintptr_t)&BSPointerHandleManagerInterface_Original::Destroy1); - // restoring_destroy1(lpRelocationDatabaseItem->At(10), 0xFE, - // (uintptr_t)&BSPointerHandleManagerInterface_Original::Destroy1); - // restoring_destroy1(lpRelocationDatabaseItem->At(11), 0xEF, - // (uintptr_t)&BSPointerHandleManagerInterface_Original::Destroy1); - // restoring_destroy1(lpRelocationDatabaseItem->At(12), 0xFE, - // (uintptr_t)&BSPointerHandleManagerInterface_Original::Destroy1); - // restoring_destroy1(lpRelocationDatabaseItem->At(13), 0xEF, - // (uintptr_t)&BSPointerHandleManagerInterface_Original::Destroy1); - // restoring_destroy2(lpRelocationDatabaseItem->At(14), 0x30, 0x10B, - // (uintptr_t)&BSPointerHandleManagerInterface_Original::Destroy2); - //} + // total_patches += total; + // //_MESSAGE("MASK_ACTIVE_BIT Total %llu", total); + + // /*std::vector pp; + // for (auto pattern : storage_check) + // for (auto find_pattern : storage) + // if (((pattern - 40) < find_pattern) && ((pattern + 40) > find_pattern)) + // pp.push_back(pattern); + + // for (auto pattern : storage_check) + // if (std::find(pp.begin(), pp.end(), pattern) == std::end(pp)) + // _CONSOLE("%llx", pattern);*/ + + auto duration = duration_cast(high_resolution_clock::now() - timerStart).count(); + _CONSOLE("CreationKitPlatformExtended::Experimental::BSPointerHandle: %llu patches applied in %llums", total_patches, duration); } + else + BSPointerHandleManagerCurrent::PointerHandleManagerCurrentId = 0; return true; } @@ -1100,404 +1547,6 @@ namespace CreationKitPlatformExtended _MESSAGE("BSHandleRefObject::DecRef (Patched: %d)", patched); } - - void ReplaceBSPointerHandleAndManagerPatch::IncRefPatch_980() - { - size_t total = 0; - - { - auto Sec = GlobalEnginePtr->GetSection(SECTION_TEXT); - auto Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 8D ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? F0 ? ? 38"); - Assert(Signatures.size() == 57); - total += Signatures.size(); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA ? ? ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? F0 ? ? 38"); - Assert(Signatures.size() == 179); - total += Signatures.size(); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "8D ? ? 48 8D 0D ? ? ? ? 4C 8D 05 ? ? ? ? E8 ? ? ? ? F0 ? ? 38"); - Assert(Signatures.size() == 31); - total += Signatures.size(); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? ? 8D ? ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? F0 ? ? 38"); - Assert(Signatures.size() == 13); - total += Signatures.size(); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA ? ? ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? F0 ? FF ? 38"); - Assert(Signatures.size() == 10); - total += Signatures.size(); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 8D ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? F0 41 ? ? 38"); - Assert(Signatures.size() == 6); - total += Signatures.size(); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA ? ? ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? F0 FF ? 08"); - Assert(Signatures.size() == 12); - // need only 1 - Signatures.resize(1); - total += Signatures.size(); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 41 8D ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? F0 FF ? 38"); - Assert(Signatures.size() == 12); - total += Signatures.size(); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "8D ? ? 48 8D 0D ? ? ? ? 4C 8D 05 ? ? ? ? E8 ? ? ? ? F0 41 FF ? 38"); - Assert(Signatures.size() == 3); - total += Signatures.size(); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 41 8D ? 3C 48 8D 0D ? ? ? ? E8 ? ? ? ? F0 41 FF ? 38"); - Assert(Signatures.size() == 1); - total += Signatures.size(); - - // TODO - - } - - _CONSOLE("BSHandleRefObject::IncRef (Patched: %llu)", total); - } - - void ReplaceBSPointerHandleAndManagerPatch::DecRefPatch_980() - { - size_t total_find = 0, total = 0; - - { - auto Sec = GlobalEnginePtr->GetSection(SECTION_TEXT); - auto Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? ? FF FF FF FF F0 0F"); - Assert(Signatures.size() == 716); - total += Signatures.size(); - - auto fff = Signatures; - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? ? FF FF FF FF F0 ? 0F"); - Assert(Signatures.size() == 41); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? F0 0F"); - Assert(Signatures.size() == 128); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? F0 ? 0F"); - Assert(Signatures.size() == 15); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? F0 0F"); - Assert(Signatures.size() == 171); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? F0 ? 0F"); - Assert(Signatures.size() == 76); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? ? F0 0F"); - Assert(Signatures.size() == 140); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? ? FF FF FF FF ? ? F0 0F"); - Assert(Signatures.size() == 9); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? 41 ? FF FF FF FF 41 ? ? F0 ? 0F"); - Assert(Signatures.size() == 3); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 8D ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? ? FF FF FF FF F0"); - Assert(Signatures.size() == 20); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - // there jump - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? ? FF FF FF"); - Assert(Signatures.size() == 35); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 41 8D ? 55 48 8D 0D ? ? ? ? E8 ? ? ? ?"); - Assert(Signatures.size() == 24); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 41 8D ? 56 48 8D 0D ? ? ? ? E8 ? ? ? ?"); - Assert(Signatures.size() == 6); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 8D ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? ? F0 0F"); - Assert(Signatures.size() == 1); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? EB ?"); - Assert(Signatures.size() == 5); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 41 8D ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? 41 ? ? F0 0F"); - Assert(Signatures.size() == 8); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? ? FF FF FF FF F0 0F"); - Assert(Signatures.size() == 17); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? ? FF FF FF FF F0 ? 0F"); - Assert(Signatures.size() == 6); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? ? F0 ? 0F"); - Assert(Signatures.size() == 13); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 8D ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? F0 0F"); - Assert(Signatures.size() == 49); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? E9 ? ? ? ?"); - Assert(Signatures.size() == 2); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 8D ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? F0 ? 0F"); - Assert(Signatures.size() == 2); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? ? 8D ? ? 56 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? ? ? ? ? F0 0F"); - Assert(Signatures.size() == 1); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? ? ? ? ? ? ? FF FF FF FF F0 0F"); - Assert(Signatures.size() == 1); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 41 8D ? ? 55 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? F0 ? 0F"); - Assert(Signatures.size() == 1); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? F0 ? 0F"); - Assert(Signatures.size() == 15); - total += Signatures.size(); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 41 8D ? ? 56 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? ? F0 0F"); - //Assert(Signatures.size() == 1); - total += Signatures.size(); - _CONSOLE("ddv4 %llu", Signatures.size()); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 41 8D ? ? 55 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? ? FF FF"); - //Assert(Signatures.size() == 15); - total += Signatures.size(); - _CONSOLE("ddv5 %llu", Signatures.size()); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "8D ? 54 48 8D 0D ? ? ? ? 4C 8D 05 ? ? ? ? E8 ? ? ? ? ? FF FF FF FF F0 0F"); - //Assert(Signatures.size() == 1); - total += Signatures.size(); - _CONSOLE("ddv4 %llu", Signatures.size()); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 41 8D ? ? 55 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? F0 0F"); - //Assert(Signatures.size() == 15); - total += Signatures.size(); - _CONSOLE("ddv5 %llu", Signatures.size()); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? 41 8D ? ? 55 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? ? F0 0F"); - //Assert(Signatures.size() == 1); - total += Signatures.size(); - _CONSOLE("ddv4 %llu", Signatures.size()); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? 45 33 C9 49 8B C9 41 8B C7 F0 0F"); - //Assert(Signatures.size() == 15); - total += Signatures.size(); - _CONSOLE("ddv5 %llu", Signatures.size()); - - fff.append_range(Signatures); - - // TODO - - Signatures = voltek::find_patterns(Sec.base, Sec.end - Sec.base, - "4C 8D 05 ? ? ? ? BA 55 00 00 00 48 8D 0D ? ? ? ? E8 ? ? ? ? ? ? ? ? FF FF FF FF F0 0F"); - //Assert(Signatures.size() == 15); - total += Signatures.size(); - _CONSOLE("ddv55 %llu", Signatures.size()); - - fff.append_range(Signatures); - - // TODO - } - - _CONSOLE("BSHandleRefObject::DecRef (Patched: %llu/%llu)", total, total_find); - } } } } \ No newline at end of file diff --git a/Creation Kit Platform Extended Core/Patches/Windows/FO4/MainWindowF4.cpp b/Creation Kit Platform Extended Core/Patches/Windows/FO4/MainWindowF4.cpp index 93e77974..6f7f6688 100644 --- a/Creation Kit Platform Extended Core/Patches/Windows/FO4/MainWindowF4.cpp +++ b/Creation Kit Platform Extended Core/Patches/Windows/FO4/MainWindowF4.cpp @@ -501,9 +501,9 @@ namespace CreationKitPlatformExtended { ConsolePatch::Log("Dump SDM Info:\n\tHead: 0x%08X\n\tMax: 0x%08X\n\tCapacity: %.2f%%", *pointer_ReplaceBSPointerHandleAndManager_data1, - EditorAPI::Fallout4::BSUntypedPointerHandle_Extended::MAX_HANDLE_COUNT, + EditorAPI::Fallout4::BSUntypedPointerHandle_Extended_NG::MAX_HANDLE_COUNT, ((((long double)(*pointer_ReplaceBSPointerHandleAndManager_data1)) * 100.0f) / - (long double)EditorAPI::Fallout4::BSUntypedPointerHandle_Extended::MAX_HANDLE_COUNT)); + (long double)EditorAPI::Fallout4::BSUntypedPointerHandle_Extended_NG::MAX_HANDLE_COUNT)); } else { diff --git a/Creation Kit Platform Extended Core/Version/build_version.txt b/Creation Kit Platform Extended Core/Version/build_version.txt index 2431ed5ba6fc2fd617dad03a10bb804dc6e2afd4..f6d7efa3da5ec38c9bce16a983dc822a9ab0c093 100644 GIT binary patch literal 12 RcmezW&z!*w2zeQ}7yukh0=NJG literal 12 TcmezW&z!-8!GM96fr|kE92f$y diff --git a/Creation Kit Platform Extended Core/Version/resource_version2.h b/Creation Kit Platform Extended Core/Version/resource_version2.h index c3cee2d62532ca2d3d1a9e90b72fd876524780a7..0ace2e20cd46dcb1fd8de08d0e90fef60703bbdc 100644 GIT binary patch delta 28 kcmcb@e}#X;17>zJ22%!J2Cm7B%+ix1Sfw`0uz(21^EB2Cm7B%+ix1Sfw`0uE&u=k diff --git a/Database/FO4/1_10_982_3/CreationKitPlatformExtended_FO4_1_10_982_3.database b/Database/FO4/1_10_982_3/CreationKitPlatformExtended_FO4_1_10_982_3.database index c1483e677d6a0a872a732f9c8ba0d9035c7b66c4..b27566a2af07d0e2ed78b554ff33897f3b83a547 100644 GIT binary patch delta 117 zcmZ2`jB)2N#tqtDjLMUByev3hF*AUH=;U0l0KVJd{0s~$@1-%YF*w`~pM2UYK_tF^H7#xg}CZ7fh>4Sti zwjE_=V@S|Vnr!O*kXb=DX|tq{A|rExVbWw<-|zei1|UTWonAnF2Y`~!e&0j@5?vi` diff --git a/Database/FO4/1_10_982_3/ReplaceBSPointerHandleAndManager.relb b/Database/FO4/1_10_982_3/ReplaceBSPointerHandleAndManager.relb index e83dc2cd..dc6de405 100644 --- a/Database/FO4/1_10_982_3/ReplaceBSPointerHandleAndManager.relb +++ b/Database/FO4/1_10_982_3/ReplaceBSPointerHandleAndManager.relb @@ -7,6 +7,7 @@ extended 526D30 64 4889742410574883EC20C70100000000488BF2488BF94885D20F84????????8B 3C5B684 0 3C5B688 0 +D3DE60 0 4AA700 70 40534883EC20833900488BD90F84????????488D0D????????4889742430E8???????? 532510 64 41564883EC208339004C8BF10F84????????48895C2430488D0D????????4889 5279E0 64 48895C24084889742410574883EC20418BF88BDA488BF181FAFFFF1F0076??4C diff --git a/Stuffs/FO4/CreationKitPlatformExtended.ini b/Stuffs/FO4/CreationKitPlatformExtended.ini index e4f84bce..b5028fd8 100644 --- a/Stuffs/FO4/CreationKitPlatformExtended.ini +++ b/Stuffs/FO4/CreationKitPlatformExtended.ini @@ -12,7 +12,7 @@ [CreationKit] bUIHotkeys=false ; [Experimental] Allow rebinding certain window hotkeys. See [Hotkeys] section. bVersionControlMergeWorkaround=false ; [Experimental] Workaround for version control not allowing merges with more than 2 masters present. Do NOT use this for anything else. -bBSPointerHandleExtremly=false ; [Experimental] Increase the maximum number of refs to 67.108.864. Use it at your own risk. +bBSPointerHandleExtremly=false ; [Experimental] Increase the maximum number of refs to 67.108.864 (for NG2 8.388.608). Use it at your own risk. bINICache=true ; Abandoning outdated "profile" functions, using the cache, for fast reading and saving options. bD3D11Patch=false ; Makes it possible to initialize both 11.0 and 11.2 version DirectX. So and fixed Nvidia NSight checks. Need Win8.1 and newer. diff --git a/rc2json/version/build_version.txt b/rc2json/version/build_version.txt index ca72bb642bd9d5a481d2fe9319ef3074a8516772..355f6f25a46baa91102398fd3684a01efe48e0d5 100644 GIT binary patch literal 10 RcmezW&z!-6ftP`c0RR?00)zkn literal 10 RcmezW&z!-WftP`c0RR>_0)qem diff --git a/rc2json/version/resource_version2.h b/rc2json/version/resource_version2.h index fca843e859fa1887e2cf5b0bf0adba6b01e45e70..0f5047e0c2f77ef3b28b62d793635f4046d00c55 100644 GIT binary patch delta 14 Wcmcb_e~Ev?17=3^%@3JBG6MiF