nasm astrset_s函数 x86
函数 x86
2023-09-14 08:58:44 时间
xxx.asm
%define p1 ebp+8
%define p2 ebp+12
%define p3 ebp+16
section .text
global dllmain
export astrset_s
dllmain:
mov eax,1
ret 12
;------------------------------------------------;
; 将字符串的字符设置为字符
;------------------------------------------------;
astrset_s:
push ebp
mov ebp,esp
mov ecx,[p1] ; char* str
mov eax,[p2] ; size_t numberOfElements
mov edx,[p3] ; int c
.for:
test eax,eax
jz .return
cmp byte [ecx],0
je .return
mov [ecx],dl
inc ecx
dec eax
jmp .for
.return:
xor eax,eax
mov esp,ebp
pop ebp
ret 12
c++:
#include <iostream>
#include <Windows.h>
typedef int (CALLBACK* astrset_s_t)(char* str, size_t numberOfElements, int c);
astrset_s_t astrset_s;
int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
astrset_s = (astrset_s_t)GetProcAddress(myDLL, "astrset_s");
char s[12] = "abc";
_strset_s(s, sizeof(s), "x"[0]);
printf("%s\n", s); // xxx
astrset_s(s, sizeof(s), "y"[0]);
printf("%s\n", s); // yyy
return 0;
}
相关文章
- 共轭函数_复共轭函数
- 函数c()_函数的调用
- react子父组件相互通信传值系列之——父组件传值与函数给子组
- 微信小程序上拉触底事件函数onReachBottom不触发的解决方案
- 三种方法实现strlen函数
- MongoDB时间聚合函数使用
- MySQL时间函数:获取当前时间的简单方式(mysql当前时间函数)
- 使用Oracle函数格式化日期和时间(oracle格式化函数)
- Linux中强大的指针函数(linux指针函数)
- MySQL两字段求和函数,轻松完成数据统计(mysql两字段求和函数)
- 掌握Oracle ROWNM函数的精髓(oracle rownm)
- Python函数学习笔记
- 学习并汇集javascript匿名函数
- PHP取整数函数常用的四种方法小结
- 在c和c++中实现函数回调
- php中debug_backtrace、debug_print_backtrace和匿名函数用法实例
- 使用ob系列函数实现PHP网站页面静态化