xxx.asm

%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16 section .text
global dllmain
export astrcpy_s dllmain:
mov eax,1
ret 12 astrcpy_s:
push ebp
mov ebp,esp
push ebx mov eax,[p1] ; dst char ptr
mov ecx,[p2] ; dwDstSize
mov edx,[p3] ; src char ptr .for:
;-------------------------------------;
; get src first char
;-------------------------------------;
mov bl,[edx] ;-------------------------------------;
; 检查src是否结束
;-------------------------------------;
test bl,bl
jz .return ;-------------------------------------;
; copy
;-------------------------------------;
mov [eax],bl ;-------------------------------------;
; 避免dst溢出
;-------------------------------------;
dec ecx
test ecx,ecx
jz .return ;-------------------------------------;
; next
;-------------------------------------;
inc eax
inc edx
jmp .for .return:
pop ebx
mov esp,ebp
pop ebp
ret 12

c++:

#include <iostream>
#include <Windows.h> typedef void (CALLBACK* astrcpy_s_t)(char* dest, size_t dest_size, const char* src); astrcpy_s_t astrcpy_s; int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
astrcpy_s = (astrcpy_s_t)GetProcAddress(myDLL, "astrcpy_s"); char r[100]; strcpy_s(r, sizeof(r), "123");
printf("%s\n", r); // 123 astrcpy_s(r, sizeof(r), "456");
printf("%s\n", r); // 456 //===============================// strcpy_s(r, 2, "1");
printf("%s\n", r); // 1 astrcpy_s(r, 2, "2");
printf("%s\n", r); // 2
return 0;
}

nasm astrcpy_s函数 x86的更多相关文章

  1. nasm astrspn函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

  2. nasm astrcspn函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

  3. nasm astrchr函数 x86

    xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...

  4. nasm astrlen函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

  5. nasm aat函数 x86

    xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain dllmain: ...

  6. nasm astrstr函数 x86

    xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...

  7. nasm astrset_s函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

  8. nasm astrrev函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

  9. nasm astrrchr函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

随机推荐

  1. python 招聘数据分析

    导入包 import pandas as pd import numpy as np import matplotlib.pyplot as plt 读文件 df=pd.read_csv(r'C:\U ...

  2. (30)Linux文本处理

    1.cat命令:连接文件并打印输出到标准输出设备 cat 命令可以用来显示文本文件的内容(类似于 DOS 下的 type 命令),也可以把几个文件内容附加到另一个文件中,即连接合并文件. cat 命令 ...

  3. Hive配置Tez引擎踩坑

    框架版本 Hadoop 2.7.7 Hive 2.3.7 Tez 0.9.2 保证hadoop集群启动,hive元数据服务启动 上传tez到HDFS tar -zxvf apache-tez-0.9. ...

  4. Failed to initialize policy for cpu: 0

    今天在使用vmware安装ubuntu16.04的时候出现下列错误: Failed to initialize policy for cpu: 0 (-19),刚开始还以为是镜像文件出现了问题,结果发 ...

  5. PAT(乙级)2020年春季考试

    比赛链接:https://pintia.cn/market/item/1287964475579875328 7-1 对称日 题解 模拟,注意年月日不足位在前面补零. 代码 #include < ...

  6. Codeforces Global Round 8 B. Codeforces Subsequences(构造)

    题目链接:https://codeforces.com/contest/1368/problem/B 题意 构造最短的至少含有 $k$ 个 $codeforces$ 子序列的字符串. 题解 如下表: ...

  7. GPTL L3-003 社交集群(并查集)

    数据有些弱,Union函数不判不等也可以过. 题意: 依次给出 n 个人的兴趣,不同人兴趣相交.不同兴趣所属人员相交均属于同一集群,求形成的不相交集群个数及每个集群的人数. 思路: 枚举每个兴趣的人员 ...

  8. Codeforces Round #646 (Div. 2) C. Game On Leaves(树上博弈)

    题目链接:https://codeforces.com/contest/1363/problem/C 题意 有一棵 $n$ 个结点的树,每次只能取叶子结点,判断谁能最先取到结点 $x$ . 题解 除非 ...

  9. poj 1410 (没做出来,记得闲着没事看看这道题)

    听说这道题是个大大的坑题 结果wa了十多发,,,,还是没找到原因 #include<cstdio> #include<cmath> #include<algorithm& ...

  10. P1268 树的重量(板子)

    题目: 题目描述 树可以用来表示物种之间的进化关系.一棵"进化树"是一个带边权的树,其叶节点表示一个物种,两个叶节点之间的距离表示两个物种的差异.现在,一个重要的问题是,根据物种之 ...