Skip to content

Commit 92b10b4

Browse files
committed
Push int64 Address under dhook callbacks
1 parent a086f60 commit 92b10b4

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

extensions/dhooks/src/capsule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ std::uint32_t Capsule::AddCallback(SourcePawn::IPluginFunction* callback, Source
9191
cb.associated_capsule = this;
9292
cb.callback = callback;
9393
cb.remove_callback = remove_callback;
94+
cb.using_int64_address = (callback->GetParentRuntime()->FindPubvarByName("__Int64_Address__", nullptr) == SP_ERROR_NONE);
9495

9596
auto plugin_it = locals::plugin_hook_ids.find(callback->GetParentRuntime()->GetDefaultContext());
9697
if (plugin_it == locals::plugin_hook_ids.end()) {

extensions/dhooks/src/capsule.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,12 @@ void Capsule::PrePostHookLoop(std::uint8_t* saved_register, bool post) const {
147147
}
148148
hook.callback->PushCell(entity_index.value_or(-1));
149149
} else if (hook.this_pointer_type == sp::ThisPointer_Address) {
150-
hook.callback->PushCell(globals::sourcemod->ToPseudoAddress(this_ptr));
150+
if (hook.using_int64_address) {
151+
std::int64_t sm_address = reinterpret_cast<std::int64_t>(this_ptr);
152+
hook.callback->PushArray((cell_t*)&sm_address, 2);
153+
} else {
154+
hook.callback->PushCell(reinterpret_cast<std::intptr_t>(this_ptr));
155+
}
151156
}
152157
}
153158

extensions/dhooks/src/hook.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct HookCallback {
1515
Capsule* associated_capsule;
1616
SourcePawn::IPluginFunction* callback;
1717
SourcePawn::IPluginFunction* remove_callback;
18+
bool using_int64_address;
1819
};
1920

2021
}

0 commit comments

Comments
 (0)