nasm astrcat_s函数 x86
xxx.asm
%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16
section .text
global dllmain
export astrcat_s
dllmain:
mov eax,1
ret 12
astrcat_s:
push ebp
mov ebp,esp
push ebx
mov ecx,[p1] ; dst char ptr
mov eax,[p2] ; src char ptr
mov edx,[p3] ; dwDstSize
; if dwDstSize==0 return FALSE
test edx,edx
jz .error
; get dst char end
.dstFor:
cmp byte [ecx],0
je .copyFor
inc ecx
dec edx
test edx,edx
jz .error
jmp .dstFor
.copyFor:
cmp byte [eax],0
je .success
dec edx
test edx,edx
jz .error
mov bl,byte [eax]
mov byte [ecx],bl
inc eax
inc ecx
jmp .copyFor
.error:
xor eax,eax
jmp .return
.success:
mov eax,1
jmp .return
.return:
pop ebx
mov esp,ebp
pop ebp
ret 12
c++:
#include <iostream>
#include <Windows.h>
typedef BOOL(CALLBACK* astrcat_s_t)(char* dst, const char* src, size_t dwDstSize);
astrcat_s_t astrcat_s;
int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
astrcat_s = (astrcat_s_t)GetProcAddress(myDLL, "astrcat_s");
const char* a = "hello";
const char* b = " world";
char dst[12] = { 0 };
if (!astrcat_s(dst, a, sizeof(dst)))
{
printf("astrcat_s 1 error.\n");
return 0;
}
if (!astrcat_s(dst, b, sizeof(dst)))
{
printf("astrcat_s 2 error.\n");
return 0;
}
printf("%p\n", dst);
printf("%s\n", dst); // hello world
return 0;
}
nasm astrcat_s函数 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 ...
随机推荐
- loj10014数列分段二
10014. 「一本通 1.2 练习 1」数列分段 II 题目描述 对于给定的一个长度为 n 的正整数数列 A ,现要将其分成 m 段,并要求每段连续,且每段和的最大值最小. 例如,将数列 4,2,4 ...
- loj10006数列分段
题目描述 对于给定的一个长度为 N 的正整数数列 A,现要将其分成连续的若干段,并且每段和不超过 M(可以等于 M),问最少能将其分成多少段使得满足要求. 输入格式 第一行包含两个正整数 N,M表示了 ...
- Azure Functions(一)什么是 ServerLess
一,引言 自去年4月份分享过3篇关于 Azure Functions 的文章之后,就一直没有再将 Azure Functions 相关的内容了.今天再次开始将 Azure Functions 相关的课 ...
- hdu 6268 Master of Subgraph(点分治+bitset)
You are given a tree with n nodes. The weight of the i-th node is wi. Given a positive integer m, no ...
- 静态链表 Static Link List
Static Link List 静态链表 其中上图来自http://www.cnblogs.com/rookiefly/p/3447982.html 参考: http://www.cnblogs. ...
- Codeforces Round #665 (Div. 2) D - Maximum Distributed Tree dfs贡献记录
题意: t组输入,每组数据中n个节点构成一棵树,然后给你n-1条边.给你一个m,然后给你m个k的素数因子,你需要给这n-1条边都赋一个权值,这n-1条边的权值之积应该等于k.如果k的素数因子数量小于n ...
- hdu 6832 A Very Easy Graph Problem 构造树+dfs
题意: 给你一个n个点m条边的图,对于第i条边,它的长度是2i,对于每一个顶点,它不是0类型,就是1类型.你需要找出来对于所有的"两个不同类型的点之间最短距离"的和 题解(参考:h ...
- Go - 实现项目内链路追踪(二)
上篇文章 Go - 实现项目内链路追踪 分享了,通过 链路 ID 可以将 请求信息.响应信息.调用第三方接口的信息.调试信息.执行的 SQL 信息.执行的 Redis 信息 串起来,记录的具体参数在文 ...
- Java解决Hash(散列)冲突的四种方法--开放地址法(线性探测,二次探测,伪随机探测)、链地址法、再哈希、建立公共溢出区
最近时间有点紧,暂时先放参考链接了,待有时间在总结一下: 查了好多,这几篇博客写的真心好,互有优缺点,大家一个一个看就会明白了: 参考 1. 先看这个明白拉链法(链地址法),这个带源码,很好看懂,只不 ...
- mybatis(八)手写简易版mybatis
一.画出流程图 二.设计核心类 二.V1.0 的实现 创建一个全新的 maven 工程,命名为 mebatis,引入 mysql 的依赖. <dependency> <groupId ...