xxx.asm:

  1. %define p1 ebp+8
  2. %define p2 ebp+12
  3. %define p3 ebp+16
  4. section .text
  5. global dllmain
  6. export astrstr
  7. dllmain:
  8. mov eax,1
  9. ret 12
  10. ;-------------------------------------------------------------;
  11. ; 返回一个指针,该指针指向字符串中第一次出现的搜索字符串
  12. ;-------------------------------------------------------------;
  13. astrstr:
  14. push ebp
  15. mov ebp,esp
  16. sub esp,4
  17. mov ecx,[p1] ; const char *str
  18. mov edx,[p2] ; const char *strSearch
  19. mov [ebp-4],ecx
  20. .for:
  21. mov ah,[edx]
  22. mov al,[ecx]
  23. ;--------------------------------------------------;
  24. ; strSearch 全部查找完
  25. ;--------------------------------------------------;
  26. test ah,ah
  27. jz .find
  28. ;--------------------------------------------------;
  29. ; str 全部查找完
  30. ;--------------------------------------------------;
  31. test al,al
  32. jz .notFind
  33. ;--------------------------------------------------;
  34. ; 如果相等进行下一个strSearch字符的判断
  35. ;--------------------------------------------------;
  36. cmp ah,al
  37. je .foarchNext
  38. ;--------------------------------------------------;
  39. ; 不相等进行下一个str字符的判断
  40. ; 如果strSearch指针变动,则恢复strSearch指针
  41. ;--------------------------------------------------;
  42. cmp edx,[p2]
  43. jne .reSearch
  44. inc ecx
  45. mov [ebp-4],ecx
  46. jmp .for
  47. .reSearch:
  48. mov edx,[p2]
  49. mov [ebp-4],ecx
  50. jmp .for
  51. .foarchNext:
  52. inc ecx
  53. inc edx
  54. jmp .for
  55. .notFind:
  56. xor eax,eax
  57. jmp .return
  58. .find:
  59. mov eax,[ebp-4]
  60. jmp .return
  61. .return:
  62. add esp,4
  63. mov esp,ebp
  64. pop ebp
  65. ret 8

c++:

  1. #include <iostream>
  2. #include <Windows.h>
  3. typedef int (CALLBACK* astrstr_t)(const char* str, const char* strCharSet);
  4. astrstr_t astrstr;
  5. int main()
  6. {
  7. HMODULE myDLL = LoadLibraryA("xxx.dll");
  8. astrstr = (astrstr_t)GetProcAddress(myDLL, "astrstr");
  9. const char* s1 = "hello world";
  10. const char* s2 = "ll";
  11. printf("%s\n", strstr( s1, s2)); // llo world
  12. printf("%s\n", astrstr(s1, s2)); // llo world
  13. return 0;
  14. }

nasm astrstr函数 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 astrset_s函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

  7. nasm astrrev函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

  8. nasm astrrchr函数 x86

    xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...

  9. nasm astrncmp函数 x86

    xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...

随机推荐

  1. P6584 重拳出击

    写在前面 来给 zrm 大佬的题写一篇题解. 这题代码实现难度不高,但是比较锻炼思维,而且应该有不少种解法.着实是一道质量很高的题目. 算法思路 首先呢,显然当小 Z 向当前节点的一棵子树走去时,这棵 ...

  2. CF 板刷总结

    CF 板刷总结 这件事的开始要从万圣节那一天说起.当然,万圣节只用于描述时间,我显然是不参加任何万圣节活动的对吧. 以下是一些我觉得有必要拿出来讲的,有技术含量的题.会持续更新,断更了记得来催更. C ...

  3. HMS Core华为分析丨受众细分,多场景促进精益运营

    用户的偏好不同,对产品的需求也不一样,要想更好地培养用户粘性,就需要因人施策,精细化运营,而受众细分是精细化运营的重要方法之一.受众细分是根据用户属性和行为数据,将具有相同或类似特征的用户归为一个群组 ...

  4. JQuery——相关练习

    ####JQuery的基本语法 <!--导入JQuery文件--> <script src="js/jquery-3.1.1.min.js"> /*带min ...

  5. Centos6.5添加163软件yum源

    将yum源设置为163yum,可以提升软件包安装和更新的速度,同时避免一些常见软件版本无法找到.具体设置方法如下: 1,进入yum源配置目录cd /etc/yum.repos.d 2,备份系统自带的y ...

  6. cassandra权威指南读书笔记--cassandra概述

    cassandra是一个开源的.分布式.去中心化.弹性可扩展.高可用.容错.可调一致性.面向行数据库,分布式设计基于Amazon Dynamo,数据模型基于Google BigTable.cassan ...

  7. 图的连通性——Tarjan算法&割边&割点

    tarjan算法 原理: 我们考虑 DFS 搜索树与强连通分量之间的关系. 如果结点 是某个强连通分量在搜索树中遇到的第⼀个结点,那么这个强连通分量的其余结点肯定 是在搜索树中以 为根的⼦树中. 被称 ...

  8. Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final) D. Extreme Subtraction (贪心)

    题意:有一个长度为\(n\)的序列,可以任意取\(k(1\le k\le n)\),对序列前\(k\)项或者后\(k\)减\(1\),可以进行任意次操作,问是否可以使所有元素都变成\(0\). 题解: ...

  9. c#小灶——9.算术运算符

    算数运算符用来在程序中进行运算. 首先,了解最简单的加(+)减(-)乘(*)除(/)运算符: 举例 int a = 1; int b = 2; int c = a + b; Console.Write ...

  10. Linux 搭建网站

    wget http://dl.wdlinux.cn/lanmp_laster.tar.gz tar zxvf lanmp_laster.tar.gz sh lanmp.sh https://www.w ...