nasm astrcat函数 x86
xxx.asm
%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16
section .text
global dllmain
export astrcat
dllmain:
mov eax,1
ret 12
astrcat:
push ebp
mov ebp,esp
mov ecx,[p1] ; dst char ptr
mov eax,[p2] ; src char ptr
; get dst char end
.dstFor:
cmp byte [ecx],0
je .copyFor
inc ecx
jmp .dstFor
.copyFor:
cmp byte [eax],0
je .return
mov dl,byte [eax]
mov byte [ecx],dl
inc eax
inc ecx
jmp .copyFor
.return:
mov eax,1
mov esp,ebp
pop ebp
ret 8
c++:
#include <iostream>
#include <Windows.h>
typedef int (CALLBACK* astrcat_t)(char* dst, const char* src);
astrcat_t astrcat;
int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
astrcat = (astrcat_t)GetProcAddress(myDLL, "astrcat");
const char* a = "hello";
const char* b = " world";
char dst[10] = { 0 };
astrcat(dst, a);
astrcat(dst, b);
printf("%p\n", dst);
// 很明显长度超过了申请的大小10
// 为什么不会出问题,因为char*最后不仅有个NULL(0),还有自然对齐(align)填充的0
// 如果超过了align,就会出问题
printf("%s\n", dst); // hello world
printf("%s%s\n", a, b); // hello world
getchar();
return 0;
}
nasm astrcat函数 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 aat函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain dllmain: ...
- 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 ...
随机推荐
- LIS的优化
二分优化 在求一个最长不上升自序列中,显然其结尾元素越小,越有利于接其他元素,对答案的贡献也就可能会更高 那么我们可以用low[i]去存长度为i的LIS结尾元素的最小值 因此我们只要维护low数组 对 ...
- CF1428C
Description 有一个只包含'A'与'B'的字符串,每次可以消掉一个 "AB" 或一个 "BB",并把剩下的拼在一起,求字符串最短的长度. 题意已经够简 ...
- MySQL数据库迁移与MySQL数据库批量恢复
目录 一.MySQL数据库迁移或备份 1. 了解使用InnoDB引擎创建数据库所产生的文件 2. 迁移数据库步骤 1. 从A服务器迁移至B服务器 2. MySQL重装并导入之前数据库 二.MySQL数 ...
- Codeforces Round #656 (Div. 3) C. Make It Good
题目链接:https://codeforces.com/contest/1385/problem/C 题意 去除一个数组的最短前缀使得余下的数组每次从首或尾部取元素可以排为非减序. 题解一 当两个大数 ...
- java大数函数(附官方文档链接)
java文档 字段摘要 static BigInteger ONE BigInteger 的常量 1. static BigInteger TEN BigInt ...
- 关于贪心算法的经典问题(算法效率 or 动态规划)
如题,贪心算法隶属于提高算法效率的方法,也常与动态规划的思路相挂钩或一同出现.下面介绍几个经典贪心问题.(参考自刘汝佳著<算法竞赛入门经典>).P.S.下文皆是我一个字一个字敲出来的,绝对 ...
- Educational Codeforces Round 88 (Rated for Div. 2) D、Yet Another Yet Another Task
题意: 给你一个含n个数a1,a2...an的数组,你要找到一个区间[l,r],使得al+a(l+1)+...+a(r-1)+ar减去max(al,a(l+1),...,a(r-1),ar)的值尽可能 ...
- 在异步或子线程中show窗体的时候要用MethodInvoker委托,要不然show不出来
this.Invoke((MethodInvoker)delegate () { Thread.Sleep(500); this.Hide(); FloatWnd floatWnd = new Flo ...
- Windows Terminal 更换主题
1. 打开设置,是个json文件 2. 在此处获取主题配置:https://atomcorp.github.io/themes/ 3.将主题配置粘贴到schemes节点(可以增加N个) 4.配置每个命 ...
- 【转】分布式事务之——tcc-transaction分布式TCC型事务框架搭建与实战案例
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/73731363 一.背景 有一定分布式开发经验的朋友都知道,产品/项目/系统最初为了 ...