写了一个玩具程序,学习学习x86指令的机器码,^_^
2004-12-07 16:04
435 查看
//arrayExec.cpp
//complie with: g++ arrayExec.cpp -o arrayExec.exe
//or cl arrayExec.cpp
#include <stdio.h>
#define SIZE 1024
//等效的代码
//void call(int* n)
//{
// n=990;
//}
typedef void (*F)(int*);
int main()
{
char inst[SIZE];
int op=0;
inst[op++]=0x55;//push %ebp
inst[op++]=0x8b;//mov %esp %ebp
inst[op++]=0xec;
inst[op++]=0x8b;//mov 8(%ebp),%eax
inst[op++]=0x45;
inst[op++]=0x08;
inst[op++]=0xc7;//move $16,(%eax)
inst[op++]=0x00;
inst[op++]=0x10;
inst[op++]=0x00;
inst[op++]=0x00;
inst[op++]=0x00;
inst[op++]=0x5d;//pop %ebp
inst[op++]=0xc3;//ret
int n=9;
//vc7.1的编译器,好像对F function = (F)array;不认帐
F funcion = (F)(void*)inst;
funcion(&n); //结果等价于call(&n)
printf("%i/n",n);
}
//complie with: g++ arrayExec.cpp -o arrayExec.exe
//or cl arrayExec.cpp
#include <stdio.h>
#define SIZE 1024
//等效的代码
//void call(int* n)
//{
// n=990;
//}
typedef void (*F)(int*);
int main()
{
char inst[SIZE];
int op=0;
inst[op++]=0x55;//push %ebp
inst[op++]=0x8b;//mov %esp %ebp
inst[op++]=0xec;
inst[op++]=0x8b;//mov 8(%ebp),%eax
inst[op++]=0x45;
inst[op++]=0x08;
inst[op++]=0xc7;//move $16,(%eax)
inst[op++]=0x00;
inst[op++]=0x10;
inst[op++]=0x00;
inst[op++]=0x00;
inst[op++]=0x00;
inst[op++]=0x5d;//pop %ebp
inst[op++]=0xc3;//ret
int n=9;
//vc7.1的编译器,好像对F function = (F)array;不认帐
F funcion = (F)(void*)inst;
funcion(&n); //结果等价于call(&n)
printf("%i/n",n);
}
相关文章推荐
- VC与Delphi之间动态链接库互相调用
- javascript表单之间的数据传递!
- PHP 的 MySQL 操作类,跟手册上的函数一样用,但是更方便了。多说无益,看了就知道了。
- delphi中的时间操作技术(1)
- delphi中的时间操作技术(2)
- VB五子棋问题,请高手赐教
- IP地址的隐藏(delphi实现 )
- 解析IP地址为主机域名
- 将某一主机域名解析为IP地址
- 有关TrueDBGrid的问题向各位大虾请教
- 开发工具浅谈
- 用VB和MTS开发多层数据库应用系统
- 看到一篇好文章与大家分享!!!!!
- 纯编码实现数据库的建立或压缩
- 从数据库中动态选取下拉列表的方法
- 编译器(解释器)编写指南-编写编译器(解释器)的工具-LEX
- thinking in c++卷2
- 如何在VB例程中接收自定义消息
- [转贴]Phrack 最新公开的Win32用户态rootkit技术
- creating a Self Deleting Executable