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. 从零搭建TypeScript与React开发环境

    前言 平时进行开发大多数是基于vue-cli或者create-react-app等官方或者公司内部搭建的脚手架.   我们业务仔做的最多就是npm i和npm run dev或者npm start,然 ...

  2. Python学习【第3篇】:列表魔法

    ##########################深灰魔法-list类中提供的方法###################list 类,列表list = [1,12,9,"age" ...

  3. 单体架构、SOA架构、微服务架构

  4. redis学习教程四《管理、备份、客户端连接》

    redis学习教程四<管理.备份.客户端连接>  一:Redis服务器命令 Redis服务器命令 下表列出了与Redis服务器相关的一些基本命令. 序号 命令 说明 1 BGREWRITE ...

  5. form(form基础、标签渲染、错误显示 重置信息、form属性、局部钩子、全局钩子)

    form基础 Django中的Form使用时一般有两种功能: 1.生成html标签 2.验证输入内容 要想使用django提供的form,要在views里导入form模块 from django im ...

  6. H3C交换机DHCP配置

    1.dhcp配置 dhcp enable:开启dhcp功能 dhcp server forbidden-ip 10.1.130.2 10.1.130.10----排除dhcp的一些地址 dhcp se ...

  7. Java复习整理 day01

    练习代码: 1 //这条语句说明这个Java文件在demo的包下 2 package demo1; 3 /** 4 * 5 * @author 王兴平 6 * 这个是第一个hello world 案例 ...

  8. P2805 [NOI2009]植物大战僵尸 (拓扑排序 + 最小割)

    题意:N*M的矩阵 每个点上都有一颗植物 僵尸只能从每一行的最右边向左进攻 每个植物有攻击范围 可以保护在攻击范围内的植物 同时每一颗植物也保护他左边的植物 摧毁每个植物能获得价值 如果这个植物被保护 ...

  9. Codeforces 1345 D - Monopole Magnets

    传送门:D. Monopole Magnets 这一场也是很神奇了,先是推迟三天,后是评测鸡崩了,unrated... 题意:每一行,每一列必须都要至少有一个s,n要可以到所有的黑格,n的上下左右如果 ...

  10. 【bzoj 2163】复杂的大门(算法效率--拆点+贪心)

    题目:你去找某bm玩,到了门口才发现要打开他家的大门不是一件容易的事-- 他家的大门外有n个站台,用1到n的正整数编号.你需要对每个站台访问一定次数以后大门才能开启.站台之间有m个单向的传送门,通过传 ...