nasm astrstr函数 x86
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的更多相关文章
- nasm astrspn函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrcspn函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrchr函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...
- nasm astrlen函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm aat函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain dllmain: ...
- nasm astrset_s函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrrev函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrrchr函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrncmp函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...
随机推荐
- CF1428C
Description 有一个只包含'A'与'B'的字符串,每次可以消掉一个 "AB" 或一个 "BB",并把剩下的拼在一起,求字符串最短的长度. 题意已经够简 ...
- 获取本机IP和主机名
如果是在windows环境: 使用InetAddress.getLocalHost()方法即可 package com.datongsoft.wg.common.util; import java.n ...
- ubuntu中如何安装selenium+chrome(headless)无界面浏览器?
selenium是一个Web的自动化测试工具,它可以根据我们的指令,让浏览器自动加载页面,获取需要的数据,甚至页面截屏,或者判断网站上某些动作是否发生.但是它自身不带浏览器,不支持浏览器的功能,因此它 ...
- 使用 shell 脚本自动对比两个安装目录并生成差异补丁包
问题的提出 公司各个业务线的安装包小则几十兆.大则几百兆,使用自建的升级系统向全国百万级用户下发新版本时,流量耗费相当惊人.有时新版本仅仅改了几个 dll ,总变更量不过几十 K 而已,也要发布一个完 ...
- 关于ckfinder上传文件时不能根据结果返回自定义操作问题?
最近项目中为了便于文件的管理,所以CMS项目中使用到了ckfinder插件,但是在使用的过程中,发现其自带的上传事件,如果上传重名的文件,该工具会自动提示错误,显示上传失败.但是如果想要自己去处理重名 ...
- Dos命令思维导图
通过思维导图的方式,总结常用Dos命令. 各种思维导图下载地址
- REST架构及其介绍
概述 REST是英文Representational State Transfer的缩写,中文翻译:表述性状态转移. 他是由Roy Thomas Fielding博士在他的论文 < ...
- HDU - 4300 Clairewd’s message (拓展kmp)
HDU - 4300 题意:这个题目好难读懂,,先给你一个字母的转换表,然后给你一个字符串密文+明文,密文一定是全的,但明文不一定是全的,求最短的密文和解密后的明文: 题解:由于密文一定是全的,所以他 ...
- Codeforces Round #652 (Div. 2)D. TediousLee 推导
题意: Rooted Dead Bush (RDB) of level 1是只有一个点,如下图 当(RDB) of level i变成(RDB) of level i+1的时候,每一个顶点要进行下面的 ...
- 分块 && 例题 I Hate It HDU - 1754
分块算法: 分块就是对暴力方法的一种优化: _ 假设我们总共的序列长度为n,然后我们把它切成√n 块,然后把每一块里的东西当成一个整体来看,完整块:被 ...