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;
}

最新文章

  1. 协同js库,代码编辑器
  2. VSCode+Ionic+Apache Ripple开发环境搭建
  3. 根据网站所做的SEO优化整理的一份文档
  4. 安装 Apache 出现 &lt;OS 10013&gt; 以一种访问权限不允许的方式做了一个访问套接字的尝试
  5. 【jqGrid for ASP.NET MVC Documentation】.学习笔记.2.jqGrid Model-View-Controller 分离
  6. 论文笔记之:RATM: RECURRENT ATTENTIVE TRACKING MODEL
  7. IMAP收邮件
  8. OC9_代理正向传值
  9. HTML5와 CSS3 적용기
  10. (转)浅谈dedecms模板引擎工作原理及自定义标签
  11. 解决spring mvc 上传报错,Field [] isn&#39;t an enum value,Failed to convert value of type &#39;java.lang.String[]&#39; to required type &#39;
  12. Hibernate乐观锁和悲观锁
  13. 用 parseInt()解决的 小 bug
  14. 第一篇--认识Jmeter
  15. 【Linux部署 &#183; GIT】在linux系统安装git和配置实现SSH
  16. CI/CD持续集成/持续部署 敏捷开发
  17. 【转】SSH穿越跳板机:一条命令跨越跳板机直接登陆远程计算机
  18. 目标检测算法之YOLOv3
  19. C++中如何对输出几位小数进行控制(setprecision)
  20. C++ auto 关键字的使用

热门文章

  1. Linux 中的文件属性
  2. Java 字符串简介
  3. mysql数据恢复:.frm和.ibd,恢复表结构和数据
  4. Spring5源码,Spring Web中的处理程序执行链
  5. 面向对象编程(UDP协议)
  6. linux c驴杂记
  7. vmware安装linux系统,自动建立没选项
  8. 6.DHCP配置故障转移(Windows2012)
  9. 如何为Kafka集群确定合适的分区数以及分区数过多带来的弊端
  10. git的几种实用操作(合并代码与暂存复原代码)