xxx.asm

%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16 section .text
global dllmain
export astrrev dllmain:
mov eax,1
ret 12 ;------------------------------------------------;
; 反转字符串的字符。
;------------------------------------------------;
astrrev:
push ebp
mov ebp,esp mov ecx,[p1] ; char *str
mov edx,[p1] ;------------------------------------------------;
; get last
;------------------------------------------------;
.getLast:
mov ah,[ecx]
test ah,ah
jz .getLastBreak
inc ecx
jmp .getLast .getLastBreak:
dec ecx .rev:
cmp ecx,edx
jc .return ; 偶数ecx会小于edx
je .return ; 奇数会相等 ;------------------------------------------------;
; 交换字节
;------------------------------------------------;
mov ah,[ecx]
mov al,[edx]
mov [edx],ah
mov [ecx],al ; next
dec ecx
inc edx
jmp .rev .return:
mov eax,[p1] ; 返回原始指针
mov esp,ebp
pop ebp
ret 4

c++:

#include <iostream>
#include <Windows.h>
#include <tchar.h>
#include <string> typedef char* (CALLBACK* astrrev_t)(char* str); astrrev_t astrrev; int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
astrrev = (astrrev_t)GetProcAddress(myDLL, "astrrev"); char s[12] = "hello world";
printf("%s, %s\n", _strrev(s), s); // dlrow olleh, dlrow olleh
printf("%s, %s\n", astrrev(s), s); // hello world, hello world
return 0;
}

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

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

  7. nasm astrset_s函数 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. 进程的创建-multiprocessing

    multiprocessing模块就是跨平台版本的多进程模块,提供了一个Process类来代表一个进程对象,这个对象可以理解为是一个独立的进程,可以执行另外的事情 1. 2个while循环一起执行 # ...

  2. mysql8.0.19忘记密码

    1.管理员打开cmd窗口 2.输入net stop mysql,停止mysql服务 3.开启跳过验证密码的mysql服务 用记事本打开 输入skip-grant-tables ,保存 4.管理员打开新 ...

  3. .htaccess 和 .user.ini

    .htaccess 仅能用于apache下,并且内容严格,不能有错误行,如:GIF89a .user.ini php 5.3.0开始引入,可设置除了:PHP_INI_SYSTEM 外的其他,包括(PH ...

  4. JavaScript 类型、原型与继承学习笔记

    目录 一.概览 二.数据类型 1. JavaScript中的数据类型 2. 什么是基本类型(Primitive Data Type) 2.1 概念 2.2 七个基本类型 2.3 基本类型封装对象 3. ...

  5. Java中运行javascript代码

    Java中运行javascript代码 1.Java 代码 2.JS代码 2.1demoWithParams.js 2.2demoWithListParams.js 原文作者:russle 原文地址: ...

  6. c++复习笔记(3)

    这篇是各种琐碎的东西. 类的函数如果在类内部直接实现,则成为内联函数候选.类外部实现的方法,可以用inline声明,使其称为内联函数候选.但是函数是否可以成为内联函数,需要看编译器的行为.. 构造函数 ...

  7. python--函数、参数、名称空间与作用域、匿名函数、内置函数、闭包

    python函数 函数定义 def welcome(): print('hello world!!') welcome() #函数调用 ...运行结果 hello world!! 函数定义和编写原则: ...

  8. jvm系列三垃圾回收

    三.垃圾回收 1.如何判断对象可以回收 引用计数法 弊端:循环引用时,两个对象的计数都为1,导致两个对象都无法被释放 可达性分析算法 JVM中的垃圾回收器通过可达性分析来探索所有存活的对象 扫描堆中的 ...

  9. Java JDBC 模糊查询 避免输入_,%返回全部数据

    Java JDBC 模糊查询 避免输入_,%返回全部数据 "SELECT * FROM employees WHERE INSTR(first_name,?)>0 " 仅供参 ...

  10. C - C(换钱问题)

    换钱问题: 给出n种钱,m个站点,现在有第 s种钱,身上有v 这么多: 下面 m行 站点有a,b两种钱,rab a->b的汇率,cab a-->b的手续费, 相反rba cba :  问在 ...