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. Python爬虫学习笔记(三)

    Cookies: 以抓取https://www.yaozh.com/为例 Test1(不使用cookies): 代码: import urllib.request # 1.添加URL url = &q ...

  2. 2021年,python的入门基础-----基础一

    先记录下pycharm编译器相关的信息 1.某些常用快捷键: Ctrl+/ 注释: Tab缩进,shift+Tab; Ctrl+Z 撤销 2.设置界面编辑风格: File>Settings> ...

  3. EIGRP和OSPF__EIGRP

    EIGRP解释 1.Enhanced Interior Gateway Routing Protocol 即增强内部网关路由协议.EIGRP同内部网关路由选择协议(IGRP)一样,是Cisco公司的私 ...

  4. 闲聊CAP、BASE与XA

    CAP理论与BASE理论 首先要和大家说的就是大名鼎鼎的CAP理论与BASE理论了,这两个理论与解决分布式事务问题是密切相关的. 其实网上有很多关于CAP与BASE相关的文章,一写就写了一大堆,篇幅很 ...

  5. SpringBoot - 实现文件上传2(多文件上传、常用上传参数配置)

    在前文中我介绍了 Spring Boot 项目如何实现单文件上传,而多文件上传逻辑和单文件上传基本一致,下面通过样例进行演示. 多文件上传 1,代码编写 1)首先在 static 目录中创建一个 up ...

  6. Effective Java读书笔记--类和接口

    1.使类和成员的可访问性最小化不指定访问级别,就是包私有.protected = 包私有 + 子类一般private不会被访问到,如果实现了Serializable,可能会泄露.反射.final集合或 ...

  7. elasticsearch7.8权限控制和规划

    由于在版本7开始,x-pack可以免费使用了,但是权限控制免费的不够细,但是控制到索引级别都基本够用了.付费的可以体验更细致的权限控制.本文的基础是已经有了es集群的基础上进行的. 官网:https: ...

  8. codeblocks输出中文乱码解决办法

    在使用codeblocks进行编程的时候我发现控制台输出会出现中文乱码,就像这样: 所以很快我就问了老师,解决步骤如下: 一:如果源码是用codeblock编写的,打开Setting->Edit ...

  9. AtCoder Beginner Contest 171

    比赛链接:https://atcoder.jp/contests/abc171/tasks A - αlphabet 题意 给出一个字母,如果为大写输出 'A',如果为小写输出 'a' . 代码 #i ...

  10. Codeforces Round #628 (Div. 2) D. Ehab the Xorcist(异或,思维题)

    题意: 寻找异或后值为 u,相加后和为 v 的最短数组. 思路: 异或得 u ,则 v 至少应大于等于 u ,且多出来的部分可以等分为两份相消. 即初始数组为 u , (v-u)/2 , (v-u)/ ...