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. Spring 动态代理时是如何解决循环依赖的?为什么要使用三级缓存?

    前言 在研究 『 Spring 是如何解决循环依赖的 』 的时候,了解到 Spring 是借助三级缓存来解决循环依赖的. 同样在上一节留下了疑问: 循环依赖为什么要使用三级缓存?而不是使用二级缓存? ...

  2. MySQL常见优化

    MySQL常见优化 1.操作符优化 1.1<> 操作符(不等于) 1.2LIKE优化 1.3in,not in,exists与not exists 1.3.1in和exists 2.whe ...

  3. Python3 注释、运算符、数字、字符串

    文章目录 注释 单引号(''') 双引号(""") 运算符 数字(Number) Python 数字类型转换 数学函数 随机数函数 三角函数 数学常量 数字与字符,列表之 ...

  4. java导出xls

    package com.spring.mvc.xls; import java.io.File;import java.io.FileInputStream;import java.text.Deci ...

  5. sql 工具类function

    --判断是否为整数 create or replace function is_number(param VARCHAR2) return NUMBER is v_num NUMBER; begin ...

  6. sql如何查询数据库最后10条记录并正序输出

    select * from (select * from 表名 order by 字段 desc limit 10) 临时表 order by 字段

  7. JavaScript中是如何定义私有变量的

    前言 JavaScript并不像别的语言,能使用关键字来声明私有变量. 我了解的JavaScript能用来声明私有变量的方式有两种,一种是使用闭包,一种是使用WeakMap. 闭包 闭包的描述有很多种 ...

  8. BZOJ3998 弦论 【SAM】k小子串

    BZOJ3998 弦论 给一个字符串,问其第\(K\)小字串是什么 两种形式 1.不同起始位置的相同串只算一次 2.不同起始位置的相同串各算一次 首先建\(SAM\) 所有串的数量就是\(SAM\)中 ...

  9. HDOJ1232 畅通工程 DFS

    很早之前就做过的题以前用并查集做的 现在用DFS重做算是熟悉DFS吧 #include<stdio.h>#include<string.h>const int size=100 ...

  10. 【noi 2.2_8758】2的幂次方表示(递归)

    题意:将正整数N用2的幂次方表示(彻底分解至2(0),2). 解法:将层次间和每层的操作理清楚,母问题分成子问题就简单了.但说得容易,操作没那么容易,我就打得挺纠结的......下面附上2个代码,都借 ...