使用 memcpy 将 jnz 更改为 jmp

发布于 2024-08-25 13:05:22 字数 247 浏览 3 评论 0原文

没有太多使用 memcpy,但这是我的代码,不起作用。

memcpy((PVOID)(enginebase+0x74C9D),(void *)0xEB,2);

(enginebase+0x74C9D) 是指向我要修补的字节地址的指针位置。

(void *)0xEB 是我想要的 jmp 类型的操作码。

唯一的问题是,线路尝试运行时就崩溃了,我不知道我做错了什么,有任何煽动吗?

Not used memcpy much but here's my code that doesn't work.

memcpy((PVOID)(enginebase+0x74C9D),(void *)0xEB,2);

(enginebase+0x74C9D) is a pointer location to the address of the bytes that I want to patch.

(void *)0xEB is the op code for the kind of jmp that I want.

Only problem is that this crashes the instant that the line tries to run, I don't know what I'm doing wrong, any incite?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

送你一个梦 2024-09-01 13:05:22

参数 (void*)0xEB 表示从地址 0xEB 复制内存;想必您想要更多类似的东西,

unsigned char x = 0xEB;
memcpy((void*)(enginebase+0x74c9d), (void*)&x, 2);

以便将 0xEB正确复制到目标。顺便说一句,2 是将单个字节复制到程序存储器的正确值吗?看起来应该是 1,因为您正在复制 1 个字节。我还假设你

((char*)enginebase)[0x74c9d] = 0xEB; 

出于某种原因不能这样做? (我没有任何故意覆盖程序内存的经验)

The argument (void*)0xEB is saying to copy memory from address 0xEB; presumably you want something more like

unsigned char x = 0xEB;
memcpy((void*)(enginebase+0x74c9d), (void*)&x, 2);

in order to properly copy the value 0xEB to the destination. BTW, is 2 the right value to copy a single byte to program memory? Looks like it should be 1, since you're copying 1 byte. I'm also under the assumption that you can't just do

((char*)enginebase)[0x74c9d] = 0xEB; 

for some reason? (I don't have any experience overwriting program memory intentionally)

梦行七里 2024-09-01 13:05:22

memcpy() 期望有两个指向源缓冲区和目标缓冲区的指针。您的第二个参数不是指针,而是数据本身(正如您所描述的,它是 jnz 的操作码)。如果我正确理解您要执行的操作,您应该设置一个以操作码作为其内容的数组,并为 memcpy() 提供指向该数组的指针。

由于您尝试引用指定空间之外的内存位置(地址 0xEB),程序崩溃。

memcpy() expect two pointers for the source and destination buffers. Your second argument is not a pointer but rather the data itself (it is the opcode of jnz, as you described it). If I understand correctly what you are trying to do, you should set an array with the opcode as its contetns, and provide memcpy() with the pointer to that array.

The program crashes b/c you try to reference a memory location out of your assigned space (address 0xEB).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文