c++ - INC 操作码编译到错误的地址
问题描述
我正在编译以下代码,但它没有按预期工作。
有人可以解释为什么以下代码不起作用以及如何纠正它吗?
DWORD data_location = 0x0100579C;
DWORD ret = 0x1002FFA;
void __declspec(naked) inc()
{
// The following is what I'm trying to accomplish which works
*(DWORD*)data_location = *(DWORD*)data_location + 1;
__asm
{
inc [data_location] //Should compile as FF 05 9C570001, instead compiles to the address containing the pointer to data_location
// inc data_location also compiles to the same thing above
jmp [ret]
}
}
解决方案
如果我对你的理解正确,你想要一些类似的东西
DWORD data_location = 0x0100579C;
DWORD ret = 0x1002FFA;
void __declspec(naked) inc()
{
__asm
{
mov eax, [data_location]
inc dword ptr [eax]
jmp [ret]
}
}
推荐阅读
- php - webpack-encore-bundle 未知的“encore_entry_script_tags”函数
- java - 使用 JUnit 测试 Spring 安全性时如何删除“ROLE_”前缀?
- compilation - 如何与 .gpr 项目文件和 gprbuild 交叉编译?
- python - PySMB 连接但无法存储文件
- jquery - Jquery AJAX响应JSON解析
- verilog - 在 Verilog 中声明一个端口,其中一些位是输入,一些是输出
- kubernetes - 列出整个集群中所有正在运行的容器?
- javascript - 使用 reactjs 下载的 .zip 文件内容已损坏
- multithreading - Kotlin `?.let` 是线程安全的吗?
- react-native - 当我运行排毒测试时,我得到一个错误信息