xxx.asm:

%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16 section .text
global dllmain
export astrstr dllmain:
mov eax,1
ret 12 ;-------------------------------------------------------------;
; 返回一个指针,该指针指向字符串中第一次出现的搜索字符串
;-------------------------------------------------------------;
astrstr:
push ebp
mov ebp,esp
sub esp,4 mov ecx,[p1] ; const char *str
mov edx,[p2] ; const char *strSearch mov [ebp-4],ecx .for:
mov ah,[edx]
mov al,[ecx] ;--------------------------------------------------;
; strSearch 全部查找完
;--------------------------------------------------;
test ah,ah
jz .find ;--------------------------------------------------;
; str 全部查找完
;--------------------------------------------------;
test al,al
jz .notFind ;--------------------------------------------------;
; 如果相等进行下一个strSearch字符的判断
;--------------------------------------------------;
cmp ah,al
je .foarchNext ;--------------------------------------------------;
; 不相等进行下一个str字符的判断
; 如果strSearch指针变动,则恢复strSearch指针
;--------------------------------------------------;
cmp edx,[p2]
jne .reSearch
inc ecx
mov [ebp-4],ecx
jmp .for .reSearch:
mov edx,[p2]
mov [ebp-4],ecx
jmp .for .foarchNext:
inc ecx
inc edx
jmp .for .notFind:
xor eax,eax
jmp .return .find:
mov eax,[ebp-4]
jmp .return .return:
add esp,4
mov esp,ebp
pop ebp
ret 8

c++:

#include <iostream>
#include <Windows.h> typedef int (CALLBACK* astrstr_t)(const char* str, const char* strCharSet);
astrstr_t astrstr; int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
astrstr = (astrstr_t)GetProcAddress(myDLL, "astrstr"); const char* s1 = "hello world";
const char* s2 = "ll";
printf("%s\n", strstr( s1, s2)); // llo world
printf("%s\n", astrstr(s1, s2)); // llo world
return 0;
}

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. Python学习【第7篇】:字符串拼接

    1.格式化字符有%s,%d,%f浮点数 %s代表格式化字符串,s是string意思 msg = 'my name is %s'%"xiaoxing"print(msg)运行结果:m ...

  2. windows.open、 window.location.href

    windows.open("URL","窗口名称","窗口外观设定");打开新窗口,window对象的方法 不一定打开新窗口,只要有窗口的名 ...

  3. vue项目中如何引用tinymce

    最近公司在做一个CMS系统的项目,其中富文本编辑框用的很多,目前流行的也很多,包括wangEditor.TinyMCE.百度ueditor.kindeditor.CKEditor等.经过自己的一番翻箱 ...

  4. MySql数据表设计,索引优化,SQL优化,其他数据库

    MySql数据表设计,索引优化,SQL优化,其他数据库 1.数据表设计 1.1数据类型 1.2避免空值 1.3text类型优化 2.索引优化 2.1索引分类 2.2索引优化 3.SQL优化 3.1分批 ...

  5. Prometheus 初探和配置(安装测试)

    本文大纲: • Prometheus 官⽹下载• Prometheus 开始安装• Prometheus 启动运⾏• Prometheus 基本配置⽂件讲解• 安装第⼀个exporter => ...

  6. Hadoop优势,组成的相关架构,大数据生态体系下的模式

    Hadoop优势,组成的相关架构,大数据生态体系下的模式 一.Hadoop的优势 二.Hadoop的组成 2.1 HDFS架构 2.2 Yarn架构 2.3 MapReduce架构 三.大数据生态体系 ...

  7. java 去掉重复的数字

    public static void main(String[] args) { String s="1,2,2,2,2,2,3,3,3"; String[] array = s. ...

  8. 4. Linux工作目录切换和文本文件编辑命令

    1.pwd:显示用户当前所处的工作目录 举例:[root@Centos ~]# pwd /root 2.cd:切换工作路径   "cd -"命令返回到上一次所处的目录 " ...

  9. Pythonchallenge1过关攻略

    第一关上来是一个电视,上面写着2^38,这就非常关键了,这时候我们已经有了大致思路,再看一眼电视机下面的话确认一下,"Hint: try to change the URL address. ...

  10. c++nullptr(空指针常量)、constexpr(常量表达式)

    总述     又来更新了,今天带来的是nullptr空指针常量.constexpr(常量表达式)C++的两个用法.Result result_fun = nullptr;constexpr stati ...