gpt4 book ai didi

带有参数和快速调用的 C++ typedef

转载 作者:行者123 更新时间:2023-11-28 07:31:49 25 4
gpt4 key购买 nike

所以我正在查看一些源代码,这件事让我很困惑。我是 C++ 的新手,所以我很难理解这是为了什么。我真的不知道下面的 typedef 是做什么用的,也不知道它在下面的代码中是如何使用的。

typedef void (__fastcall *TSecType_long___SetData_t)(DWORD dwAddress, DWORD dwEDX, DWORD dwValue);

这些是用于使用此 typedef 的方法的一些值。

const TSecType_long___SetData_t TSecType_long___SetData = reinterpret_cast<TSecType_long___SetData_t>(0x00518430); // 56 8B ? 8B ? ? ? ? ? 41 [3rd Result]

const DWORD *const pdwUserLocal = reinterpret_cast<const DWORD *const>(0x016A1234); // 8B ? ? ? ? ? 85 C9 74 ? 83 B8 ? ? ? ? 00 74 ? 8B ? ? ? ? ? 85 C0 7E ? 8B
const DWORD dwTeleportToggleOffset = 0x00008A94; // 8D ? ? ? ? ? 8B ? 8B ? E8 ? ? ? ? 85 ? 0F 85 ? ? ? ? 39 ? ? ? ? ?
const DWORD dwTeleportYOffset = 0x00008AAC; // 8D ? ? ? ? ? ? 8B ? E8 ? ? ? ? 6A ? 8B ? E8 ? ? ? ? 6A 00 68 ? ? ? ?
const DWORD dwTeleportXOffset = dwTeleportYOffset + 0x0C;

对于方法本身:

bool Teleport(_In_ int nX, _In_ int nY)
{
__try
{
{

DWORD dwUserLocal = *pdwUserLocal;
TSecType_long___SetData(dwUserLocal + dwTeleportToggleOffset, NULL, 0);
TSecType_long___SetData(dwUserLocal + dwTeleportXOffset, NULL, nX);
TSecType_long___SetData(dwUserLocal + dwTeleportYOffset, NULL, nY);
TSecType_long___SetData(dwUserLocal + dwTeleportToggleOffset, NULL, 1);
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
return false;
}
return true;
}

最佳答案

假设您知道typedef 是什么(它采用数据类型并赋予它另一个名称),所有这一切都是一个函数 typedef。换句话说,TSecType_long___SetData_t 是一个接受 3 个 DWORD 参数并返回一个 void 的函数。

在您的情况下,有人事先知道地址 0x00518430 包含一个可以在给定 TSecType_long___SetData_t API 的情况下调用的函数。为了使该地址可调用,该地址被重新解释为函数数据类型并分配给变量 TSecType_long___SetData

关于带有参数和快速调用的 C++ typedef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17518747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com