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. 在VMware15安装Ubuntu 16.04

    安装环境: VMware15 VMware15官网地址:https://my.vmware.com/cn/web/vmware/info/slug/desktop_end_user_computing ...

  2. 洛谷P4127

    Description 给出两个数 \(a\),\(b\) ,求出 \([a,b]\) 中各位数字之和能整除原数的数的个数 Solution 设 \(f[i][j][k][q]\) 表示 枚举到第 i ...

  3. 最简单直接地理解Java软件设计原则之依赖倒置原则

    理论性知识 定义 依赖倒置原则,Dependence Inversion Principle (DIP) 高层模块不应该依赖低层模块.二者都应该依赖其抽象. 抽象不应该依赖细节,细节应该依赖抽象. 针 ...

  4. 玩遍博客网站,我整理了 Hexo 及其流行的风格主题

    搭建博客网站是个人进入互联网世界的最常见方式之一.伴随着网站技术的发展,如何搭建博客网站已经变得非常容易了.当然,你可以选择诸如 新浪博客.CSDN.博客园 之类的大型网站,快速创建依赖于大平台的个人 ...

  5. python --装饰器通俗讲解

    装饰器 什么是装饰器?:在不修改源代码和调用方式的基础上给其增加新的功能,多个装饰器可以装饰在同一个函数上 Python中的装饰器是你进入Python大门的一道坎; 装饰器特点: 不改变原函数原代码: ...

  6. 5.DHCP新建作用域及添加地址保留(Windows2012)

    1.新建作用域 右键IPv4 点击新建作用域 点击下一步 命名,下一步 填写子网,下一步 在上一步已经预留了,直接点下一步即可. 设置租用期限,建议为3天,下一步. 下一步,配置DHCP选项 配置默认 ...

  7. MacOS Big Sur开HiDPI

    我自己的环境: 开启hidpi的目的是为了让显示更加细腻,代价是缩小了显示范围. 自己在网上看了很多帖子,也尝试了几种,有些方法已经不再适合Big Sur系统了,所以本文提供一种可用的,在Big Su ...

  8. java swing JDialog 和 java.util.concurrent的使用

    参考链接: Java-Swing的JFrame的一些插件使用详解 java swing JDialog 使用 ScheduledExecutorService定时周期执行指定的任务 swing JDi ...

  9. zjnu1725 COCI (类似二维树状数组模拟)

    Description The 3rd round of COCI is already here! In order to bet on predict the scores, we have as ...

  10. Codeforces Round #665 (Div. 2) D. Maximum Distributed Tree (dfs计数,树)

    题意:给你含有\(n\)个节点,\(n-1\)条边的树,以及\(m\)个质数和\(1\),你需要在这\(m\)个质数和一个\(1\)选择数(质数只能选一次,\(1\)可以多选)给\(n-1\)条边赋值 ...