C - 指针算法使用机器代码测试器框架

C - Pointer Arithmetic used machine code tester skeleton

我在网上发现了一种用 C 语言编写的类似形式的机器码测试器。

测试人员使用指向 运行 机器代码缓冲区的指针算法。

#include <stdio.h>
#include <string.h>

unsigned char code[] = \
"machine code to be executed";

void main() {
    int (*ret)() = (int(*)())code;
    ret();
}

谁能解释一下两者的指针运算背后的逻辑 上面显示的行?

Can anyone explain the logic behind the pointer arithmetic of the two lines presented above?

没有指针算法。代码只是声明了一个变量(ret),其类型是指向不带参数的函数的指针,returns一个int。它将该变量设置为指向 code,它可能包含机器代码的实际字节,然后使用它进行函数调用。