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. PowerBI官方文档

    Excel 帮助和学习 - Microsoft 支持https://support.microsoft.com/zh-cn/excel Power Query M 公式语言引用 - PowerQuer ...

  2. (四)Springboot以jar包方式启动、关闭、重启脚本

    Springboot以jar包方式启动.关闭.重启脚本 1.启动 2.关闭 3.重启 4.脚本授权 SpringBoot: nohup java -jar zlkj-data-server-1.0-S ...

  3. K8s 二、(1、kubeadm部署Kubernetes集群)

    准备工作 满足安装 Docker 项目所需的要求,比如 64 位的 Linux 操作系统.3.10 及以上的内核版本: x86 或者 ARM 架构均可: 机器之间网络互通,这是将来容器之间网络互通的前 ...

  4. 802.1X

    1.简介 IEEE802 LAN/WAN委员会为解决无线局域网网络安全问题,提出了802.1X协议.后来,802.1X协议作为局域网端口的一个普通接入控制机制在以太网中被广泛应用,主要解决以太网内认证 ...

  5. Spring集成swagger步骤(包含Header)

    1.添加依赖,2.4.0: <dependency> <groupId>io.springfox</groupId> <artifactId>sprin ...

  6. linux学习之---在linux服务器上跑一段Java代码

    经常在windows上进行开发,有时候,需要在Linux环境上跑一些程序测下代码,要怎么办才好嘞? 假设你对Java常用命令和linux常用命令已经基本熟悉,就可以直接按照以下步骤来啦,默认linux ...

  7. Python Line Messaging Api

    Line Messaging line 是国外一个很火的实时通信软件,类似与WX,由于公司业务需求,需要基于line开发一个聊天平台,下面主要介绍关于line messaging api 的使用. 官 ...

  8. HDU5732 Subway【树重心 树哈希】

    HDU5732 Subway 题意: 给出两棵大小为\(N\)的同构树,要求输出对应的节点 \(N\le 10^5\) 题解: 由于重心最多只有两个,找到重心之后以重心为根进行树哈希,找到相同哈希值的 ...

  9. c语言实现--带头结点单链表操作

    可能是顺序表研究的细致了一点,单链表操作一下子就实现了.这里先实现带头结点的单链表操作. 大概有以下知识点. 1;结点:结点就是单链表中研究的数据元素,结点中存储数据的部分称为数据域,存储直接后继地址 ...

  10. 【uva 11134】Fabled Rooks(算法效率--问题分解+贪心)

    题意:要求在一个N*N的棋盘上放N个车,使得它们所在的行和列均不同,而且分别处于第 i 个矩形中. 解法:问题分解+贪心. 由于行.列不相关,所以可以先把行和列均不同的问题分解为2个"在区间 ...