xxx.asm

%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16 section .text
global dllmain
export astrcat_s dllmain:
mov eax,1
ret 12 astrcat_s:
push ebp
mov ebp,esp
push ebx mov ecx,[p1] ; dst char ptr
mov eax,[p2] ; src char ptr
mov edx,[p3] ; dwDstSize ; if dwDstSize==0 return FALSE
test edx,edx
jz .error ; get dst char end
.dstFor:
cmp byte [ecx],0
je .copyFor
inc ecx
dec edx
test edx,edx
jz .error
jmp .dstFor .copyFor:
cmp byte [eax],0
je .success
dec edx
test edx,edx
jz .error
mov bl,byte [eax]
mov byte [ecx],bl
inc eax
inc ecx
jmp .copyFor .error:
xor eax,eax
jmp .return .success:
mov eax,1
jmp .return .return:
pop ebx
mov esp,ebp
pop ebp
ret 12

c++:

#include <iostream>
#include <Windows.h> typedef BOOL(CALLBACK* astrcat_s_t)(char* dst, const char* src, size_t dwDstSize); astrcat_s_t astrcat_s; int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
astrcat_s = (astrcat_s_t)GetProcAddress(myDLL, "astrcat_s"); const char* a = "hello";
const char* b = " world";
char dst[12] = { 0 };
if (!astrcat_s(dst, a, sizeof(dst)))
{
printf("astrcat_s 1 error.\n");
return 0;
} if (!astrcat_s(dst, b, sizeof(dst)))
{
printf("astrcat_s 2 error.\n");
return 0;
} printf("%p\n", dst);
printf("%s\n", dst); // hello world
return 0;
}

nasm astrcat_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. (万字好文)Dubbo服务熔断与降级的深入讲解&代码实战

    原文链接:(万字好文)Dubbo服务熔断与降级的深入讲解&代码实战 一.Dubbo服务降级实战 1 mock 机制 谈到服务降级,Dubbo 本身就提供了服务降级的机制:而 Dubbo 的服务 ...

  2. LOJ10159旅游规划

    题目描述 W 市的交通规划出现了重大问题,市政府下定决心在全市各大交通路口安排疏导员来疏导密集的车流.但由于人员不足,W 市市长决定只在最需要安排人员的路口安排人员. 具体来说,W 市的交通网络十分简 ...

  3. Flutter环境搭建遇坑小结(二)

    在上一节中,已经对Flutter运行中始终卡在Running Gradle task 'assembleDebug'...,做出了解决方案,继续往下运行,但是新的问题又出现了: Failed to i ...

  4. Java面试,面试题

    Java面试,面试题 HashMap,HashTable,ConcurrentHash的共同点和区别 HashMap HashTable ConcurrentHashMap ArrayList和Lin ...

  5. 常见JVM面试题及答案整理

    常见JVM面试题及答案整理 1.什么情况下会发生栈内存溢出 2.JVM内存模型 3.JVM内存为什么要分成新生代,老年代,持久代.新生代中为什么要分为Eden和Survivor. 3.1共享内存区划分 ...

  6. 最新Ceph L版与openstack Pike对接

    安装Ceph luminous   实验环境 三台服务器,每台服务器都有4块硬盘,每台服务器都将自己的第一块硬盘作为系统盘,剩下的做ceph   一.在所有服务器上操作 #使用阿里源 yum inst ...

  7. Java之jdk环境变量配置

    1.jdk下载(按平时下载,注意一下路径就行)2.配置环境变量 :JAVA_HOME.Path.ClassPath3.检查是否成功:(查一下版本,可省略).运行环境(java.javac) 2:电脑- ...

  8. getline()的使用注意

    在使用getline读入一整行时,若是前面是使用getchar().cin这类读入了一个字母,但是不会读入后续换行\n符号或者空格的输入时,再接getline()就容易出现问题. 这是因为输入数字之后 ...

  9. hdu 2072 单词数(字符串)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2072 题意 每行输入由小写字母和空格组成,统计每行中不同的单词数. 题解 题解一 比较简洁的解法,读入 ...

  10. gym101002K. Inversions (FFT)

    题意:给定一个仅含有AB的字母串 如果i有一个B j有一个A 且j>i 会对F(j-i)产生贡献 求出所有发Fi 题解:好像是很裸的FFT B的分布可以看作一个多项式 同理A也可以 然后把B的位 ...