nasm astrcat_s函数 x86
xxx.asm
%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16
section .text
global dllmain
export astrcat_s
dllmain:
mov eax,1
ret 12
astrcat_s:
push ebp
mov ebp,esp
push ebx
mov ecx,[p1] ; dst char ptr
mov eax,[p2] ; src char ptr
mov edx,[p3] ; dwDstSize
; if dwDstSize==0 return FALSE
test edx,edx
jz .error
; get dst char end
.dstFor:
cmp byte [ecx],0
je .copyFor
inc ecx
dec edx
test edx,edx
jz .error
jmp .dstFor
.copyFor:
cmp byte [eax],0
je .success
dec edx
test edx,edx
jz .error
mov bl,byte [eax]
mov byte [ecx],bl
inc eax
inc ecx
jmp .copyFor
.error:
xor eax,eax
jmp .return
.success:
mov eax,1
jmp .return
.return:
pop ebx
mov esp,ebp
pop ebp
ret 12
c++:
#include <iostream>
#include <Windows.h>
typedef BOOL(CALLBACK* astrcat_s_t)(char* dst, const char* src, size_t dwDstSize);
astrcat_s_t astrcat_s;
int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
astrcat_s = (astrcat_s_t)GetProcAddress(myDLL, "astrcat_s");
const char* a = "hello";
const char* b = " world";
char dst[12] = { 0 };
if (!astrcat_s(dst, a, sizeof(dst)))
{
printf("astrcat_s 1 error.\n");
return 0;
}
if (!astrcat_s(dst, b, sizeof(dst)))
{
printf("astrcat_s 2 error.\n");
return 0;
}
printf("%p\n", dst);
printf("%s\n", dst); // hello world
return 0;
}
nasm astrcat_s函数 x86的更多相关文章
- nasm astrspn函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrcspn函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrchr函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...
- nasm astrlen函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm aat函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain dllmain: ...
- nasm astrstr函数 x86
xxx.asm: %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export as ...
- nasm astrset_s函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrrev函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
- nasm astrrchr函数 x86
xxx.asm %define p1 ebp+8 %define p2 ebp+12 %define p3 ebp+16 section .text global dllmain export ast ...
随机推荐
- luogu p3369
题目描述您需要写一种数据结构(可参考题目标题),来维护一些数,其中需要提供以下操作: 插入x数删除x数(若有多个相同的数,因只删除一个)查询x数的排名(排名定义为比当前数小的数的个数+1.若有多个相同 ...
- c++指针 c指针 改变值
1. #include <iostream>using namespace std;void move(int *p) ====>void move(*&p){ ...
- 基于Java+Spring Boot开源项目JeeSite的Jenkins持续交互介绍
一.实战项目介绍- JeeSite 基于Spring Boot 2.0 数据存储MySQL 语言:Java 规模大小:适中,适合初学者 源码地址:https://gitee.com/thinkgem/ ...
- ApiTesting全链路自动化测试框架 - 初版发布(一)
简介 此框架是基于Python+Pytest+Requests+Allure+Yaml+Json实现全链路接口自动化测试. 主要流程:解析接口数据包 ->生成接口基础配置(yml) ->生 ...
- 洛谷 P1525 关押罪犯 (贪心,扩展域并查集)
题意:有\(n\)个罪犯,\(m\)对罪犯之间有仇,现在将这些罪犯分到两个监狱里去,问两个监狱里有仇罪犯之间的最大权值最小为多少. 题解:先按边权从大到小排序,然后贪心,边权大的两个罪犯,我们一定要先 ...
- Milk Patterns POJ - 3261 后缀数组
Farmer John has noticed that the quality of milk given by his cows varies from day to day. On furthe ...
- requests -- Python
使用requests方法后,会返回一个response对象,其存储了服务器响应的内容:如下r表示get请求后的响应对象r = requests.get('http://hz.58.com/sale.s ...
- Nginx 版本回滚
目录 参考信息 源码安装 nginx-1.14.2 版本升级 nginx-1.16.1 版本回滚 ①.对于软件的版本升级.添加官方模块.添加第三方模块,都需要用源码安装包重新生成(configure) ...
- 缓冲区溢出实验 2 sizeof/strlen
实验环境.代码.及准备 https://www.cnblogs.com/lqerio/p/12870834.html vul2 下面只给出有漏洞部分的代码.Vul2问题为sizeof函数在计算时会考虑 ...
- Verilog hdl 实现单周期cpu
参考计组实验测试指令 - 简书,添加了一些细节. 1.添加 bne指令 修改 ctrl.v 之后修改mipstestloopjal_sim.asm,mars dump 为 bnetest. ...