c++ - C++ 这段代码是否修改了指向 this 的任何数据指针,还是只返回它?
问题描述
似乎每次我调用这个函数。就像这样,它实际上是正确的。但我想避免调用函数,因为如果参数错误,这有时会崩溃,所以我想仅仅依靠修改内存地址/值来避免这个问题。
这是工作挂钩 CALL。
DWORD thisPointer = 0xABCDEF;
typedef int(__thiscall* dwordHookFunction )(DWORD a1, DWORD a2);
dwordHookFunction testCall;
testCall = (dwordHookFunction)0x5E0280; //Address matches ForceSlectionFunction offset.
testCall(thisPointer, 1);
这是反编译的函数。
int __thiscall ForceSelectionFunction(int this, int a2)
{
int result; // eax
if ( a2 > 0 && a2 < *(_DWORD *)(this + 4) )
result = *(_DWORD *)this + 0x1E9B8 * a2;
else
result = 0;
return result;
}
这个函数如何修改this
指针的内存它甚至修改它?它甚至修改任何东西还是只返回数据?..它必须修改一些东西,否则我认为它不会工作..
我将如何调用更改?
*(unsigned int*)(0xABCDEF + 0x1E9B8 * 1) = ???
或者是
*(unsigned int*)(0xABCDEF) = 0x1E9B8 * 1 //???
PS> 任何人都想看看这里的 ASM 代码。
seg000:005E0280 ; =============== S U B R O U T I N E =======================================
seg000:005E0280
seg000:005E0280 ; Attributes: bp-based frame
seg000:005E0280
seg000:005E0280 ; int __thiscall ForceSelectionFunction(_DWORD this, int a2)
seg000:005E0280 ForceSelectionFunction proc near ; CODE XREF: sub_412260+618↑p
seg000:005E0280 ; sub_415240+F6↑p ...
seg000:005E0280
seg000:005E0280 var_4 = dword ptr -4
seg000:005E0280 a2 = dword ptr 8
seg000:005E0280
seg000:005E0280 push ebp
seg000:005E0281 mov ebp, esp
seg000:005E0283 push ecx
seg000:005E0284 mov [ebp+var_4], ecx
seg000:005E0287 cmp [ebp+a2], 0
seg000:005E028B jle short loc_5E0298
seg000:005E028D mov eax, [ebp+var_4]
seg000:005E0290 mov ecx, [ebp+a2]
seg000:005E0293 cmp ecx, [eax+4]
seg000:005E0296 jl short loc_5E029C
seg000:005E0298
seg000:005E0298 loc_5E0298: ; CODE XREF: ForceSelectionFunction+B↑j
seg000:005E0298 xor eax, eax
seg000:005E029A jmp short loc_5E02AA
seg000:005E029C ; ---------------------------------------------------------------------------
seg000:005E029C
seg000:005E029C loc_5E029C: ; CODE XREF: ForceSelectionFunction+16↑j
seg000:005E029C mov eax, [ebp+a2]
seg000:005E029F imul eax, 1E9B8h
seg000:005E02A5 mov edx, [ebp+var_4]
seg000:005E02A8 add eax, [edx]
seg000:005E02AA
seg000:005E02AA loc_5E02AA: ; CODE XREF: ForceSelectionFunction+1A↑j
seg000:005E02AA mov esp, ebp
seg000:005E02AC pop ebp
seg000:005E02AD retn 4
seg000:005E02AD ForceSelectionFunction endp
在这个游戏的旧版本中,它会像这样反编译......这几乎是相同的事情,只是完成了一些结构工作。
int __thiscall ForceSelectionFunction(_DWORD *this, int a2)
{
int result; // eax
if ( a2 <= 0 || a2 >= this[1] )
result = 0;
else
result = *this + 0x1FB50 * a2;
return result;
}
解决方案
推荐阅读
- r - 按每行中的括号标题拆分和重新排列列
- swift - 在 RealityKit 场景上应用着色器
- c# - 哈希集
. 不包含与变量匹配,但与硬编码字符串匹配 - python - 证书检查因 Python 请求而失败
- json - 直接反序列化嵌入在 JSON 中的 JSON 字符串
- javascript - 如何在 JavaScript 中为对象数组创建构造函数?
- php - PHP:使用 header() 重定向相对路径时出现问题
- python - Keras 调谐器:使用的层数与报告的层数不匹配
- machine-learning - 是否需要在 K 折交叉验证之前或训练模型之后先训练模型?
- less - 如何在 Atom 中更改 Markdown 的块代码样式?