-
Автор темы
- #1
При вызове оригинальной функции PaintTraverseOriginal(interfaces::panel, vguiPanel, forceRepaint, allowForce); выдает еррор "Вызвано исключение по адресу 0x00000002 в csgo.exe: 0xC0000005: нарушение прав доступа при исполнении по адресу 0x00000002." Ну и послес соответственно крашит кс. Как фиксануть
C++:
void __stdcall hooks::PaintTraverse(std::uintptr_t vguiPanel, bool forceRepaint, bool allowForce) noexcept
{
if (vguiPanel == interfaces::engineVGui->GetPanel(PANEL_TOOLS))
{
if (globals::localPlayer && interfaces::engine->IsInGame())
{
for (int i = 1; i < interfaces::globals->maxClients; ++i)
{
CEntity* player = interfaces::entityList->GetEntityFromIndex(i);
if (!player)
continue;
if (player->IsDormant() || !player->IsAlive())
continue;
if (player->GetTeam() == globals::localPlayer->GetTeam())
continue;
if (!globals::localPlayer->IsAlive())
if (globals::localPlayer->GetObserverTarget() == player)
continue;
CMatrix3x4 bones[128];
if (!player->SetupBones(bones, 128, 0x7FF00, interfaces::globals->currentTime))
continue;
CVector top;
if (interfaces::debugOverlay->ScreenPosition(bones[8].Origin() + CVector{ 0.f, 0.f, 11.f }, top))
continue;
CVector bottom;
if (interfaces::debugOverlay->ScreenPosition(player->GetAbsOrigin() - CVector{ 0.f, 0.f, 9.f }, bottom))
continue;
const float h = bottom.y - top.y;
const float w = h * 0.3f;
const auto left = static_cast<int>(top.x - w);
const auto right = static_cast<int>(top.x + w);
interfaces::surface->DrawSetColor(255, 255, 255, 255);
interfaces::surface->DrawOutlinedRect(left, top.y, right, bottom.y);
}
}
}
PaintTraverseOriginal(interfaces::panel, vguiPanel, forceRepaint, allowForce);
}
hook.h:
using PaintTraverseFn = void(__stdcall*)(IVPanel*, std::uintptr_t, bool, bool) noexcept;
inline PaintTraverseFn PaintTraverseOriginal = nullptr;
void __stdcall PaintTraverse(std::uintptr_t vguiPanel, bool forceReraint, bool allowForce) noexcept;
hooks.cpp:
MH_CreateHook(
memory::Get(interfaces::panel, 41),
&PaintTraverse,
reinterpret_cast<void**>(&PaintTraverseOriginal)
Последнее редактирование: