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基础(列表中变量与内存关系)

    在Python中,copy的是内存地址,引用的是列表的引用地址,列表里存的是各个元素的地址 例如: name = [1,2,3,4,['xfxing','summer',6]] n2 = name.c ...

  2. LOJ2723

    LOJ2723 Get Luffy Out 题目大意:给你n对钥匙,每对钥匙只可以用其中的任意一个,钥匙有编号,且不重复.有m个大门,每个门上有两个锁,每个锁对应一个编号的钥匙,只要打开两个锁中的一个 ...

  3. XCTF-基础Android

    前期工作 查壳,无.打开看是普通的输入注册码然后验证. 逆向分析 这题太简单了,就不贴图了.看Manifest得知MainActivity是启动类,也就是点进去输入注册码那个类.密码不重要,验证成功后 ...

  4. ShowDoc,APIDoc,可道云API,语雀-适合IT企业的文档工具

    ShowDoc,APIDoc,可道云API,语雀-适合IT企业的文档工具 一.ShowDoc官方文档及说明 1.1 它可以用来做什么 1.2 它都有些什么功能 1.3 使用在线的ShowDoc 1.4 ...

  5. centos安装Qt

    转:http://blog.csdn.net/wavelee/article/details/7855727 在编译Qt4.8.6版本的库时,在配置时 ./configure 出现了如下的错误: Ba ...

  6. 12.su 命令与sudo 服务

     1.su 命令:解决切换用户身份的需求,使得当前用户在不退出登录的情况下,顺畅地切换到其他用户. 比如从root 管理员切换至普通用户: [root@Centos test]# id uid=0(r ...

  7. 【有趣的全彩LED | 编程】用STM32 HAL库让WS2812B为你所动

    一.效果展示 观看演示效果:https://www.bilibili.com/video/BV1dv411Y7x3 使用STM32 HAL库编程 PWM+DMA控制输出,CubeMX生成初始工程 实现 ...

  8. 【繁星Code】如何在EF将实体注释写入数据库中

    最近在项目中需要把各个字段的释义写到数据库中,该项目已经上线很长时间了,数据库中的字段没有上千也有上百个,要是一个项目一个项目打开然后再去找对应字段查看什么意思,估计要到明年过年了.由于项目中使用En ...

  9. Codeforces Round #673 (Div. 2) D. Make Them Equal(数论/构造)

    题目链接:https://codeforces.com/contest/1417/problem/D 题意 给出一个大小为 $n$ 的正整数数组 $a$ ,每次操作如下: 选择 $i,j$ 和 $x$ ...

  10. Educational Codeforces Round 17

    Educational Codeforces Round 17 A. k-th divisor 水题,把所有因子找出来排序然后找第\(k\)大 view code //#pragma GCC opti ...