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. loj10003加工生产调度

    题目描述 某工厂收到了 n个产品的订单,这  个产品分别在 A.B 两个车间加工,并且必须先在 A 车间加工后才可以到 B 车间加工. 某个产品 i 在 A,B 两车间加工的时间分别为 A_i,B_i ...

  2. Win10安装CUDA 10.2

    目录 一.安装VS2015 二.安装CUDA 10.2 2.1 安装前工作 2.2 CUDA 10.2下载安装过程 2.2.1 下载CUDA 10.2 2.2.1.1 官网下载地址 2.2.1.2 网 ...

  3. Jenkins安装部署项目

    Jenkins安装部署项目 配置JDK git maven 部署到服务器 一.新建任务 二.配置jenkins 三.添加构建信息 四.应用.保存 五.踩坑填坑记录 5.1没有jar包的情况 5.2无法 ...

  4. MySQL数据库---配置文件及数据文件

    1.主配置文件 #/usr/local/mysql/bin/mysqld --verbose --help |grep -A 1 'Default options' #cat /etc/my.cnf ...

  5. OpenStack (cinder存储服务)

    cinder简介 提供 OpenStack 存储块(Volume)服务,该管理模块原来也为 Nova 的一部分,即 Nova-volume,后来从 Folsom 版本开始使用 Cinder 来分离出块 ...

  6. php之PDO连接mysql数据库,增删改查等等操作实例

    我们使用传统的 mysql_connect .mysql_query方法来连接查询数据库时,如果过滤不严就有SQL注入风险,导致网站被攻击. 虽然可以用mysql_real_escape_string ...

  7. 力扣643.子数组最大平均数I-C语言实现

    题目 给定 n 个整数,找出平均数最大且长度为 k 的连续子数组,并输出该最大平均数. 示例: 输入:[1,12,-5,-6,50,3], k = 4 输出:12.75 解释:最大平均数 (12-5- ...

  8. spark sql优化

    1.内存优化 1.1.RDD RDD默认cache仅使用内存 可以看到使用默认cache时,四个分区只在内存中缓存了3个分区,4.4G的数据 使用kryo序列化+MEMORY_ONLY_SER 可以看 ...

  9. Educational Codeforces Round 84 (Div. 2)

    Educational Codeforces Round 84 (Div. 2) 读题读题读题+脑筋急转弯 = =. A. Sum of Odd Integers 奇奇为奇,奇偶为偶,所以n,k奇偶性 ...

  10. STL中去重函数unique

    一:unique(a.begin(),a.end());去重函数只是去掉连续的重复值,对于不连续的值没有影响,SO,在使用前一般需要进行排序处理: 二:  vector<int>::ite ...