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. HBase与Zookeeper的关系

    HBase与Zookeeper的关系 一.HBase与Zookeeper的关系 Zookeeper Client Master RegionServer 一.HBase与Zookeeper的关系 Cl ...

  2. vagrant虚拟化之多网卡网络配置

    vagrant虚拟化之多网卡网络配置 一.network改为public 二.查看本地主机网络的ip地址范围(最佳解决方案) 三.vagrant优秀博文 vagrant虚拟化之多网卡网络配置,通过am ...

  3. php文件下载的实现(header)

    php文件下载的实现(header) $file_xls=$path;    //   文件的保存路径 $example_name=basename($file_xls);  //获取文件名   he ...

  4. Inceptor常用SQL

    1.创建数据库 建一个数据库exchange_platform. DROP DATABASE IF EXISTS exchange_platform CASCADE; CREATE DATABASE ...

  5. Codeforces Round #177 (Div. 2) B. Polo the Penguin and Matrix (贪心,数学)

    题意:给你一个\(n\)x\(m\)的矩阵,可以对矩阵的所有元素进行\(\pm d\),问能否使得所有元素相等. 题解:我们可以直接记录一个\(n*m\)的数组存入所有数,所以\((a_1+xd)=( ...

  6. Splits CodeForces - 964A

    题意: 我们定义一个不上升的且和为 n 的正整数序列,叫做 n 的分解. 比如, 下面是8的分解: [4, 4], [3, 3, 2], [2, 2, 1, 1, 1, 1], [5, 2, 1]. ...

  7. PowerShell DSC学习资料

    官网 https://docs.microsoft.com/zh-cn/powershell/dsc/overview/overview CSDN中文博客(专题,32篇) https://blog.c ...

  8. Redis性能指标监控

    监控指标 •性能指标:Performance•内存指标: Memory•基本活动指标:Basic activity•持久性指标: Persistence•错误指标:Error 性能指标:Perform ...

  9. leetcode347 python

    通过维护最小堆排序,使用heapq模块 一般使用规则:创建列表 heap = [] 函 数                                                        ...

  10. 微服务架构Day02-SpringBoot日志slf4j

    日志框架 日志门面(接口,日志抽象层 ) 日志实现 JCL(Jakarta Commons Logging).slf4j(Simple Logging Facade for Java).jboss-l ...