nasm astrncat_s函数 x86
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的更多相关文章
- nasm astrspn函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrcspn函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrchr函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...
- nasm astrlen函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm aat函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain dllmain: ...
- nasm astrstr函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...
- nasm astrset_s函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrrev函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrrchr函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
随机推荐
- 【Python爬虫】:使用高性能异步多进程爬虫获取豆瓣电影Top250
在本篇博文当中,将会教会大家如何使用高性能爬虫,快速爬取并解析页面当中的信息.一般情况下,如果我们请求网页的次数太多,每次都要发出一次请求,进行串行执行的话,那么请求将会占用我们大量的时间,这样得不偿 ...
- react报错 TypeError: Cannot read property 'setState' of undefined
代码如下: class test extends Component { constructor(props) { super(props); this.state = { liked: false ...
- vue3.0初尝试
- Spark踩坑填坑-聚合函数-序列化异常
Spark踩坑填坑-聚合函数-序列化异常 一.Spark聚合函数特殊场景 二.spark sql group by 三.Spark Caused by: java.io.NotSerializable ...
- 小白搭建WNMP详细教程---PHP安装与设置
php的安装请参考WAMP中PHP的安装教程https://www.cnblogs.com/missbye/p/12049925.html 需要注意的是,我们下载的PHP版本要下载Non Thread ...
- Pytest(8)parametrize参数化
前言 当某个接口中的一个字段,里面规定的范围为1-5,你5个数字都要单独写一条测试用例,就太麻烦了,这个时候可以使用pytest.mark.parametrize装饰器可以实现测试用例参数化. 官方示 ...
- BZOJ3998 弦论 【SAM】k小子串
BZOJ3998 弦论 给一个字符串,问其第\(K\)小字串是什么 两种形式 1.不同起始位置的相同串只算一次 2.不同起始位置的相同串各算一次 首先建\(SAM\) 所有串的数量就是\(SAM\)中 ...
- Codeforces Round #494 (Div. 3) D. Coins and Queries (贪心,数学)
题意:给你一组全是\(2^d\ (d\ge0)\)的数,询问q次,每次询问一个数,问这个数是否能够由原数组中的数相加得到,如果能,输出最少用多少个数,否则输出\(-1\). 题解:首先贪心得出结论:如 ...
- Codeforces Round #653 (Div. 3) A. Required Remainder (数学)
题意:有三个正整数\(x,y,n\),再\(1\)~\(n\)中找一个最大的数\(k\),使得\(k\ mod\ x=y\). 题解:先记\(tmp=n/x\),再判断\(tmp*x+y\)的值是否大 ...
- C# 异常重试策略
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...