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