如何使用c++执行附加在可执行文件末尾的机器代码
How to execute machine code appended to the end of an executable file using c++?
我有一个程序,它将机器代码附加到可执行文件的末尾,我想在可执行文件开头写一个c++程序来运行附加的机器代码。附加的代码将运行原始程序。
我的程序将在mac上运行。
这里还有一个类似的问题:执行附加在可执行文件末尾的机器代码然而,这个问题没有得到回答,而是提出了其他解决办法。我不能使用链表,因为这个程序的目的是修改机器上的可执行文件的功能,这些机器可能不一定安装编译器。
这里有一个例子:
// C++ program at the beginning of file, runs appended machine code.
// Original program, must be skipped over and run after appended machine code is run.
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
FILE *input,*output;
char buffer[512];
=fopen("a.out","rb");
output=fopen("filename","ab");
for(;fread(buffer,512,1,input)==1;)
fwrite(buffer,512,1,output);
fclose(output);
cout << "Testing, testing, testing" << endl;
//Run original program
}
您可以制作一个程序,从附加的代码中创建一个可执行文件,然后执行它。或者,如果您想要的是可执行文件执行附加的代码,那么您必须将附加的代码作为函数调用,或者跳转到内联程序集中的代码("call"或"jmp")。
相关文章:
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 使用不同的链接器会产生不同的机器代码吗
- objdump 不显示机器代码,但显示 ASM
- 从.o目标文件中提取函数的原始机器代码?
- 我在区分源代码、目标代码、汇编代码和机器代码时感到困惑
- 如果C++编译为机器代码,为什么我们需要安装"运行时"?
- 是否可以执行存储在变量中的机器代码
- "Double or Nothing"赌博机器代码无法超过15组合
- 如何在 c++ 中将机器代码作为函数运行
- 可以从文件执行机器代码吗?
- 如何将x64机器代码写入虚拟内存并在C++中为Windows执行
- 如何将高级/低级编程代码直接转换为机器代码
- (如何)我可以使用LLVM机器代码分析器预测代码片段的运行时间
- 如何使用llvm生成机器代码
- 使用LLVM生成纯机器代码
- 注释会被翻译成机器代码吗?C++
- 如何使用c++执行附加在可执行文件末尾的机器代码
- 如何从机器代码中恢复C++尝试/抛出/捕获块长度和地址
- 是否有编译器可以编译为机器代码的 C C++ C# 编译器
- C++ - 极其奇怪的机器代码行为