xxx.asm

%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16 section .text
global dllmain
export astrcat dllmain:
mov eax,1
ret 12 astrcat:
push ebp
mov ebp,esp mov ecx,[p1] ; dst char ptr
mov eax,[p2] ; src char ptr ; get dst char end
.dstFor:
cmp byte [ecx],0
je .copyFor
inc ecx
jmp .dstFor .copyFor:
cmp byte [eax],0
je .return
mov dl,byte [eax]
mov byte [ecx],dl
inc eax
inc ecx
jmp .copyFor .return:
mov eax,1
mov esp,ebp
pop ebp
ret 8

c++:

#include <iostream>
#include <Windows.h> typedef int (CALLBACK* astrcat_t)(char* dst, const char* src); astrcat_t astrcat; int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
astrcat = (astrcat_t)GetProcAddress(myDLL, "astrcat"); const char* a = "hello";
const char* b = " world";
char dst[10] = { 0 }; astrcat(dst, a);
astrcat(dst, b); printf("%p\n", dst); // 很明显长度超过了申请的大小10
// 为什么不会出问题,因为char*最后不仅有个NULL(0),还有自然对齐(align)填充的0
// 如果超过了align,就会出问题
printf("%s\n", dst); // hello world
printf("%s%s\n", a, b); // hello world getchar();
return 0;
}

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

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

  9. nasm astrrchr函数 x86

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

随机推荐

  1. [JSOI2019]节日庆典 做题心得

    [JSOI2019]节日庆典 做题心得 一个性质有趣的字符串题 这要是在考场上我肯定做不出来吧 一开始还以为要 SAM 什么的暴力搞,没想到只用到了 \(Z\) 函数 -- 也是我生疏了罢 (学了啥忘 ...

  2. python 字典的用法,访问、增删合并等

    python字典可以存储任意类型的对象,字典的每个键:值 冒号(:)分割,每个对直接逗号(,)分割,整个字典包含在{}中,例如:d = {key1 : value1, key2 : value2, k ...

  3. JVM类加载与双亲委派机制被打破

    前言 前文已经讲了虚拟机将java文件编译成class文件后的格式:JVM虚拟机Class类文件研究分析 java文件经过编译,形成class文件,那么虚拟机如何将这些Class文件读取到内存中呢? ...

  4. Docker安装mysql5.7并且配置主从复制

    Docker安装mysql5.7并且配置主从复制 一.拉取mysql镜像 二.创建文件docker.cnf 2.1 mysql主机(192.168.21.55:3307) 2.1.1 创建文件夹 2. ...

  5. MySql命令,吐血整理的Mysql,实话,真的吐血

    MySql命令,吐血整理的Mysql,实话,真的吐血 1.基本操作 2.数据库操作 3.表的操作 4.数据操作 5.字符集编码 6.数据类型(列类型) 7.列属性(列约束) 8.建表规范 9.SELE ...

  6. WPF 之 Binding 对数据的校验与转换(三)

    一.前言 ​ Binding 的作用就是架在 Source 和 Target 之间的桥梁,数据可以在这座桥梁的帮助下来流通.就像现实中的桥梁会设置一些关卡进行安检一样,Binding 这座桥上也可以设 ...

  7. c++中几种swap

    在c与c++中,有多种办法可以通过函数交换传入的两数的值,但有容易有一些问题产生,因而本文将几种交换方式及容易出错的点进行了分类. 1.传引用这是c++中最常见方式如下: int swap1 (int ...

  8. 「LYOI2018 Summer」Hzy's Rabbit Candy----拓扑排序问题

    「LYOI2018 Summer」Hzy's Rabbit Candy 题目描述 Hzy 和她的 m 只兔兔在一个 n 个点 m 条边的有向无环图上玩. 为了让兔兔们开心,Hzy 带了一些糖.Hzy ...

  9. AtCoder Beginner Contest 183 E - Queen on Grid (DP)

    题意:有一个\(n\)x\(m\)的棋盘,你需要从\((1,1)\)走到\((n,m)\),每次可以向右,右下,下走任意个单位,\(.\)表示可以走,#表示一堵墙,不能通过,问从\((1,1)\)走\ ...

  10. Codeforces Round #672 (Div. 2 B. Rock and Lever (位运算)

    题意:给你一组数,求有多少对\((i,j)\),使得\(a_{i}\)&\(a_{j}\ge a_{i}\ xor\ a_{j}\). 题解:对于任意两个数的二进制来说,他们的最高位要么相同要 ...