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 ...
随机推荐
- Java并发练习
1.按顺序打印ABC 三个线程,每个线程分别打印A,B,C各十次,现在要求按顺序输出A,B,C package concurrency; import java.util.concurrent.Exe ...
- PowerBI官方文档
Excel 帮助和学习 - Microsoft 支持https://support.microsoft.com/zh-cn/excel Power Query M 公式语言引用 - PowerQuer ...
- JavaWeb——Ajax与MVC学习总结
Ajax: 什么是Ajax? 为什么使用Ajax? 使用jquery Ajax实现登录 Ajax实例练习: 设计模式 设计模式的定义: 设计模式的作用: MVC设计模式 MVC设计模式的模块组成: M ...
- Spark程序使用Scala进行单元测试
Spark程序使用Scala进行单元测试 1.Rdd测试 2.无返回值方法测试 3.测试私有方法 原文作者:大葱拌豆腐 原文地址:Spark程序进行单元测试-使用scala 1.Rdd测试 spark ...
- Spark练习之创建RDD(集合、本地文件),RDD持久化及RDD持久化策略
Spark练习之创建RDD(集合.本地文件) 一.创建RDD 二.并行化集合创建RDD 2.1 Java并行创建RDD--计算1-10的累加和 2.2 Scala并行创建RDD--计算1-10的累加和 ...
- 通过spring statemmachine 自定义构建属于自己的状态机(两种方式)
spring 的stateMachine 相对于当前的版本,还是比较新颖的,但是对于合适的业务场景,使用起来还是十分的方便的.但是对于官网提供的文档,讲解的是十分的精简,要想更深入的了解其内部架构,只 ...
- pytest内核测试平台落地初体验
测试平台,有人说它鸡肋,有人说它有用,有人说它轮子,众说纷纭,不如从自身出发,考虑是否要做测试平台: 第1阶段,用Python+requests写接口自动化. 第2阶段,选择unitttest或pyt ...
- three.js cannon.js物理引擎制作一个保龄球游戏
关于cannon.js我们已经学习了一些知识,今天郭先生就使用已学的cannon.js物理引擎的知识配合three基础知识来做一个保龄球小游戏,效果如下图,在线案例请点击博客原文. 我们需要掌握的技能 ...
- 2. Linear Regression with One Variable
Speaker:Andrew Ng 这一次主要讲解的是单变量的线性回归问题. 1.Model Representation 先来一个现实生活中的例子,这里的例子是房子尺寸和房价的模型关系表达. 通过学 ...
- Educational Codeforces Round 89 (Rated for Div. 2) A. Shovels and Swords(贪心/数学)
题目链接:https://codeforces.com/contest/1366/problem/A 题意 有两个数 $a$ 和 $b$,每次可以选择从一个数中取 $2$,另一个数中取 $1$,问最多 ...