xxx.asm:

%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16
%define p4 ebp+20 section .text
global dllmain
export astrncat_s dllmain:
mov eax,1
ret 12 ;------------------------------------------------;
; 将字符追加到字符串
;------------------------------------------------;
astrncat_s:
push ebp
mov ebp,esp
sub esp,8
mov [ebp-4],ebx mov ecx,[p1] ; char *strDest
mov eax,[p2] ; size_t numberOfElements
mov edx,[p3] ; const char *strSource
mov ebx,[p4] ; size_t count ; get strDest end
.for1:
test eax,eax
jz .return
cmp byte [ecx],0
je .eachCopy
inc ecx
dec eax
jmp .for1 .eachCopy:
test ebx,ebx
jz .return
test eax,eax
jz .return
mov [ebp-8],ebx ; copy
mov bl,byte [edx]
test bl,bl
je .return
mov byte [ecx],bl ; next
mov ebx,[ebp-8]
inc ecx
inc edx
dec eax
dec ebx
jmp .eachCopy .return:
xor eax,eax
mov ebx,[ebp+4]
add esp,8
mov esp,ebp
pop ebp
ret 16

c++:

#include <iostream>
#include <Windows.h> typedef int (CALLBACK* astrncat_s_t)(char* strDest, size_t numberOfElements, const char* strSource, size_t count); astrncat_s_t astrncat_s; int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
astrncat_s = (astrncat_s_t)GetProcAddress(myDLL, "astrncat_s"); char s1[10] = "ab";
const char* s2 = "cde";
strncat_s(s1, sizeof(s1), s2, 2);
printf("%s\n", s1); // abcd //---------------------------------------------------------------------- char s3[10] = "ab";
const char* s4 = "cde";
astrncat_s(s3, sizeof(s3), s4, 2);
printf("%s\n", s3); // abcd
return 0;
}

nasm astrncat_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. RabbitMQ入门看这一篇就够了

    一文搞懂 RabbitMQ 的重要概念以及安装 一 RabbitMQ 介绍 这部分参考了 <RabbitMQ实战指南>这本书的第 1 章和第 2 章. 1.1 RabbitMQ 简介 Ra ...

  2. 在VMware15安装Ubuntu 16.04

    安装环境: VMware15 VMware15官网地址:https://my.vmware.com/cn/web/vmware/info/slug/desktop_end_user_computing ...

  3. POJ2961_kmp

    Period Time Limit: 3000MS   Memory Limit: 30000KB   64bit IO Format: %I64d & %I64u Submit Status ...

  4. Docker (error getsockopt: connection refused ,使用http无法使用 docker login 登录的问题)

    因部署Harbor 镜像仓库,部署完了之后根据提示上传 images,需要使用docker  login   ip:port  进行登录, 登录的时候发现因为docker 默认是https,因为测试环 ...

  5. 武装你的WEBAPI-OData常见问题

    本文属于OData系列 目录 武装你的WEBAPI-OData入门 武装你的WEBAPI-OData便捷查询 武装你的WEBAPI-OData分页查询 武装你的WEBAPI-OData资源更新Delt ...

  6. 怎样将Sublime Text 设置成中文版(完整教程)

    1.打开Sublime Text,使用快捷键Shift+Ctrl+P,弹出查找栏,如图: 2.在搜索框中输入关键字 install ,出现下拉选项,点击选择其中的:Package Control: I ...

  7. 浅谈Winform控件开发(一):使用GDI+美化基础窗口

    写在前面: 本系列随笔将作为我对于winform控件开发的心得总结,方便对一些读者在GDI+.winform等技术方面进行一个入门级的讲解,抛砖引玉. 别问为什么不用WPF,为什么不用QT.问就是懒, ...

  8. ApiTesting全链路自动化测试框架 - 初版发布(一)

    简介 此框架是基于Python+Pytest+Requests+Allure+Yaml+Json实现全链路接口自动化测试. 主要流程:解析接口数据包 ->生成接口基础配置(yml) ->生 ...

  9. 带撤销并查集 & 可持久化并查集

    带撤销并查集支持从某个元素从原来的集合中撤出来,然后加入到一个另外一个集合中,或者删除该元素 用一个映射来表示元素和并查集中序号的关系,代码中用\(to[x]\) 表示x号元素在并查集中的 id 删除 ...

  10. 1155 Heap Paths

    题干前半略. Sample Input 1: 8 98 72 86 60 65 12 23 50   Sample Output 1: 98 86 23 98 86 12 98 72 65 98 72 ...