xxx.asm:

  1. %define p1 ebp+8
  2. %define p2 ebp+12
  3. %define p3 ebp+16
  4. %define p4 ebp+20
  5. section .text
  6. global dllmain
  7. export astrncat_s
  8. dllmain:
  9. mov eax,1
  10. ret 12
  11. ;------------------------------------------------;
  12. ; 将字符追加到字符串
  13. ;------------------------------------------------;
  14. astrncat_s:
  15. push ebp
  16. mov ebp,esp
  17. sub esp,8
  18. mov [ebp-4],ebx
  19. mov ecx,[p1] ; char *strDest
  20. mov eax,[p2] ; size_t numberOfElements
  21. mov edx,[p3] ; const char *strSource
  22. mov ebx,[p4] ; size_t count
  23. ; get strDest end
  24. .for1:
  25. test eax,eax
  26. jz .return
  27. cmp byte [ecx],0
  28. je .eachCopy
  29. inc ecx
  30. dec eax
  31. jmp .for1
  32. .eachCopy:
  33. test ebx,ebx
  34. jz .return
  35. test eax,eax
  36. jz .return
  37. mov [ebp-8],ebx
  38. ; copy
  39. mov bl,byte [edx]
  40. test bl,bl
  41. je .return
  42. mov byte [ecx],bl
  43. ; next
  44. mov ebx,[ebp-8]
  45. inc ecx
  46. inc edx
  47. dec eax
  48. dec ebx
  49. jmp .eachCopy
  50. .return:
  51. xor eax,eax
  52. mov ebx,[ebp+4]
  53. add esp,8
  54. mov esp,ebp
  55. pop ebp
  56. ret 16

c++:

  1. #include <iostream>
  2. #include <Windows.h>
  3. typedef int (CALLBACK* astrncat_s_t)(char* strDest, size_t numberOfElements, const char* strSource, size_t count);
  4. astrncat_s_t astrncat_s;
  5. int main()
  6. {
  7. HMODULE myDLL = LoadLibraryA("xxx.dll");
  8. astrncat_s = (astrncat_s_t)GetProcAddress(myDLL, "astrncat_s");
  9. char s1[10] = "ab";
  10. const char* s2 = "cde";
  11. strncat_s(s1, sizeof(s1), s2, 2);
  12. printf("%s\n", s1); // abcd
  13. //----------------------------------------------------------------------
  14. char s3[10] = "ab";
  15. const char* s4 = "cde";
  16. astrncat_s(s3, sizeof(s3), s4, 2);
  17. printf("%s\n", s3); // abcd
  18. return 0;
  19. }

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. Codeforces #698 (Div. 2) E. Nezzar and Binary String 题解

    中文题意: 给你两个长度为 \(n\) 的01串 \(s,f,\)有 \(q\) 次询问. 每次询问有区间 \([\ l,r\ ]\) ,如果 \([\ l,r\ ]\) 同时包含\(0\)和\(1\ ...

  2. libuv事件循环中的三种句柄

    1.说明 本文会简单介绍 libuv 的事件循环,旨在入门级别的使用,而不做深入探究,简单来说就是,会大概用就行,先用熟练了,再去探究原理和源码 下图为官网的 libuv 的不同部分及其涉及的子系统的 ...

  3. Python 学习笔记(1)

    Mac下载安装Python mac 系统自带有python .但就最新的mac系统而言,它自带的python版本为2.*版本. 虽然不影响对于老python项目的运行,但3.*版本中很多语法都发生了改 ...

  4. Spring听课笔记(专题二)

    第3章 Spring Bean的装配(上) 3-1:配置项及作用域 1.Bean的配置项: -- Id -- Class (这个必须,其他的都可以不配置) -- Scope (作用域) -- Cons ...

  5. 上海某小公司面试题:Java线程池来聊聊

    <对线面试官>系列目前已经连载11篇啦!进度是一周更新两篇,欢迎持续关注 [对线面试官]Java注解 [对线面试官]Java泛型 [对线面试官] Java NIO [对线面试官]Java反 ...

  6. docker(8)Dockerfile指令介绍

    前言 Dockerfile 是一个用来构建镜像的文本文件,文本内容包含了一条条构建镜像所需的指令和说明. Dockerfile简介 Dockerfile是用来构建Docker镜像的构建文件,是由一系列 ...

  7. dp practice 1

    https://codeforces.com/problemset/problem/553/A dp+组合数学 dp[i] 放前i种颜色的方法数 #include<bits/stdc++.h&g ...

  8. P3128 [USACO15DEC]最大流Max Flow (树上差分)

    题目描述 Farmer John has installed a new system of N-1N−1 pipes to transport milk between the NN stalls ...

  9. Codeforces Round #658 (Div. 2)【ABC2】

    做完前四题还有一个半小时... 比赛链接:https://codeforces.com/contest/1382 A. Common Subsequence 题意 给出两个数组,找出二者最短的公共子序 ...

  10. Codeforces Global Round 7 D1. Prefix-Suffix Palindrome (Easy version)(字符串)

    题意: 取一字符串不相交的前缀和后缀(可为空)构成最长回文串. 思路: 先从两边取对称的前后缀,之后再取余下字符串较长的回文前缀或后缀. #include <bits/stdc++.h> ...