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 ...
随机推荐
- 扒一扒ELF文件
ELF文件(Executable Linkable Format)是一种文件存储格式.Linux下的目标文件和可执行文件都按照该格式进行存储,有必要做个总结. 目录 1. 链接举例 2. ELF文件类 ...
- 题解 UVA11694 【Gokigen Naname谜题 Gokigen Naname】
题目 题解 考场上连暴力都不会打的码农题,深搜是真的难 /kk 前置问题 怎么输出"\" cout<<"\\"; 2.怎么处理不在一个环里,可以考虑 ...
- jackson学习之五:JsonInclude注解
欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...
- orm(Manager isn't accessible via %s instances" % cls.__name)报错
报错信息 Manager isn't accessible via %s instances" % cls.__name 解决方法 https://www.jianshu.com/p/5e0 ...
- shell循环字符串数组
#!/bin/bash arr=("0" "1" "2" "3" "4" "5" ...
- 将将List json 转成List<?>实体
package TestJson; import java.util.ArrayList; import java.util.List; import java.util.Map; import ne ...
- 简述vue-cli 2.x和vue-cli 3+在项目构建、运行、编译执行时的区别
码文不易啊,转载请带上本文链接呀,感谢感谢 https://www.cnblogs.com/echoyya/p/14363272.html 关于VUE的项目,有个问题一直不是特别清楚 ,不同公司的项目 ...
- jdk 安装过程配置环境变量 error 的解决过程
jdk 安装过程配置环境变量 error 的解决过程 问题背景: 我在安装 jdk 过程中在JAVA_HOME和path中添加路径后, cmd 中输入java 和javac均出现错误,因为之前在 D ...
- HOJ1867 经理的烦恼
My Tags (Edit) Source : HCPC 2005 Spring Time limit : 2 sec Memory limit : 32 M Submitted : ...
- Checkout Assistant CodeForces - 19B
题意: 给你n个物品,每个物品有一个价格ci和一个支付时间ti,在这个ti时间内,你可以免费拿ti个物品.问你想要带走这n个物品最小需要多少钱 题解: 原本还想着贪心去写,但是好像贪心写不了,,,不属 ...