Skip to content

Commit

Permalink
Update vcpkg hash. Add bools to debug whether we were able to read th…
Browse files Browse the repository at this point in the history
…e pointer chain.
  • Loading branch information
Squirrelies committed Feb 21, 2025
1 parent fa5b562 commit 04d7f8c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Common/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace RE2RR::Common::Memory
logger.LogMessage("[TrySetPointer: %s] Begin %s: %p\n", pointerName, NAMEOF(pointer), pointer);
try
{
*object = (void *)pointer;
*object = const_cast<void *>(pointer);
for (size_t i = 0; i < offsets.size(); ++i)
{
if ((void *)((uintptr_t)*object + offsets[i]) == nullptr)
Expand Down
18 changes: 10 additions & 8 deletions src/Hook/DllHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,17 @@ __stdcall uintptr_t HookItemPickup(uintptr_t param1, uintptr_t param2, uintptr_t
(randomizer = ui != nullptr ? ui->GetRandomizer() : nullptr) == nullptr) // If we're not randomizing, this will be null.
return itemPickupFunc(param1, param2, param3, param4);

RE2RR::Types::RE2RItem *itemToReplace = (RE2RR::Types::RE2RItem *)param3;
const GUID *itemPositionGuid = (GUID *)param4;
if (!RE2RR::Common::Memory::TryReadPointer((const void *)param3, {0x50, 0x10, 0x10}, (void **)&itemToReplace, NAMEOF(itemToReplace), *logger.get()) ||
!RE2RR::Common::Memory::TryReadPointer((const void *)param4, {0x30}, (void **)&itemPositionGuid, NAMEOF(itemPositionGuid), *logger.get()))
return itemPickupFunc(param1, param2, param3, param4);
RE2RR::Types::RE2RItem *itemToReplace = (RE2RR::Types::RE2RItem *)param3; // Sometimes uninitialized data, only write here.
const RE2RR::Types::RE2RItem *currentItem = (RE2RR::Types::RE2RItem *)param4; // This is where we want to read to get what the item is.
const GUID *itemPositionGuid = (GUID *)param4; // The item's position GUID.

bool itemToReplaceSuccess = RE2RR::Common::Memory::TryReadPointer((const void *)param3, {0x50, 0x10, 0x10}, (void **)&itemToReplace, NAMEOF(itemToReplace), *logger.get());
bool UNUSED(currentItemSuccess) = RE2RR::Common::Memory::TryReadPointer((const void *)param4, {0x14}, (void **)&currentItem, NAMEOF(currentItem), *logger.get());
bool itemPositionGuidSuccess = RE2RR::Common::Memory::TryReadPointer((const void *)param4, {0x30}, (void **)&itemPositionGuid, NAMEOF(itemPositionGuid), *logger.get());

// RE2RR::Types::RE2RItem *itemToReplace = (RE2RR::Types::RE2RItem *)(param3 + 0x50 + 0x10 + 0x10); // Sometimes uninitialized data, only write here.
// const RE2RR::Types::RE2RItem *currentItem = (RE2RR::Types::RE2RItem *)(param4 + 0x14); // This is where we want to read to get what the item is.
// const GUID *itemPositionGuid = (GUID *)(param4 + 0x30); // The item's position GUID.
if (!itemToReplaceSuccess ||
!itemPositionGuidSuccess)
return itemPickupFunc(param1, param2, param3, param4);

if (itemToReplace != nullptr && itemPositionGuid != nullptr)
randomizer->ItemPickup(*itemToReplace, *itemPositionGuid);
Expand Down
2 changes: 1 addition & 1 deletion vcpkg-configuration.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"default-registry": {
"kind": "git",
"baseline": "f0376cb987beefabcbef170a0764dc363f789b78",
"baseline": "37d46edf0f2024c3d04997a2d432d59278ca1dff",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
Expand Down

0 comments on commit 04d7f8c

Please sign in to comment.