nasm aat函数 x86
xxx.asm:
%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16
section .text
	global dllmain
dllmain:
	mov eax,1
	ret 12
aat:
	push ebp
	mov ebp,esp
	; 函数必须保留所有寄存器,但eax,ecx和edx除外
	; esp则必须根据调用约定进行更新
	mov ecx,[p1]  	 ; array ptr
	mov edx,[p2]     ; index
	mov eax,[p3] 	 ; size
	mul edx			 ; eax=eax*edx
	lea eax,[ecx+eax]
	mov esp,ebp
	pop ebp
	ret 12
c++:
#include <iostream>
#include <Windows.h>
typedef PVOID (CALLBACK* aat_t)(PVOID pArray, size_t index, size_t size);
aat_t aat;
struct Player
{
  size_t id;
  DWORD hp;
  DWORD mp;
};
int main()
{
  HMODULE myDLL = LoadLibraryA("xxx.dll");
  aat = (aat_t)GetProcAddress(myDLL, "aat");
  int a[] = { 1,2,3 };
  printf("%d\n", *(int*)aat(a, 2, sizeof(int))); // 3
  Player b[] = {
    Player{1, 10, 20},
    Player{2, 50, 60},
    Player{3, 90, 20},
  };
  Player* it = (Player*)aat(b, 0, sizeof(Player));
  printf("[%d]: %d %d\n", it->id, it->hp, it->mp); // [1]: 10 20
  it = (Player*)aat(b, 1, sizeof(Player));
  printf("[%d]: %d %d\n", it->id, it->hp, it->mp); // [2]: 50 60
  it = (Player*)aat(b, 2, sizeof(Player));
  printf("[%d]: %d %d\n", it->id, it->hp, it->mp); // [3]: 90 20
  return 0;
}
nasm aat函数 x86的更多相关文章
- nasm astrspn函数 x86
		xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ... 
- nasm astrcspn函数 x86
		xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ... 
- nasm astrchr函数 x86
		xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ... 
- nasm astrlen函数 x86
		xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ... 
- nasm astrstr函数 x86
		xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ... 
- nasm astrset_s函数 x86
		xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ... 
- nasm astrrev函数 x86
		xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ... 
- nasm astrrchr函数 x86
		xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ... 
- nasm astrncmp函数 x86
		xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ... 
随机推荐
- Mysql 不能使用逗号的情况
			不存在逗号的情况: 联合查询: 1.UNION SELECT * FROM ((SELECT 1)a JOIN (SELECT 2)b JOIN (SELECT 3)c JOIN (SELECT 4) ... 
- 解决java.lang.NoClassDefFoundError: ch/qos/logback/core/joran/spi/Pattern
			明明引入了这个,却提示没有 看下面文章: http://www.maocaoying.com/article/109 
- 【疑】接入交换机lacp port-channel连接核心突然中断
			现状: 职场网络架构为接入交换机2个端口通过lacp协议的active模式组成port-channel上联到核心. 具体配置如下 接入: 核心: 故障现象: zabbix监控到核心交换机对应该接入交换 ... 
- Failed to initialize policy for cpu: 0
			今天在使用vmware安装ubuntu16.04的时候出现下列错误: Failed to initialize policy for cpu: 0 (-19),刚开始还以为是镜像文件出现了问题,结果发 ... 
- jQuery插件Validate
			一.导入js库 <script type="text/javascript" src="<%=path %>/validate/jquery-1.6.2 ... 
- Codeforces Round #658 (Div. 2)【ABC2】
			做完前四题还有一个半小时... 比赛链接:https://codeforces.com/contest/1382 A. Common Subsequence 题意 给出两个数组,找出二者最短的公共子序 ... 
- Educational Codeforces Round 17
			Educational Codeforces Round 17 A. k-th divisor 水题,把所有因子找出来排序然后找第\(k\)大 view code //#pragma GCC opti ... 
- 2013-2014 ACM-ICPC, NEERC, Eastern Subregional Contest PART (8/10)
			$$2013-2014\ ACM-ICPC,\ NEERC,\ Eastern\ Subregional\ Contest$$ \(A.Podracing\) 首先枚举各个折现上的点,找出最小宽度,然 ... 
- hdu1890 Robotic Sort (splay+区间翻转单点更新)
			Problem Description Somewhere deep in the Czech Technical University buildings, there are laboratori ... 
- poj2926Requirements (曼哈顿距离)
			Description An undergraduate student, realizing that he needs to do research to improve his chances ... 
