nasm and golink create a DLL x86
and create dll x86
2023-09-14 08:58:44 时间
制作DLL
xxx.asm:
%macro fb 0
push ebp
mov ebp,esp
%endmacro
%macro fa 1
mov esp,ebp
pop ebp
ret %1
%endmacro
section .text
global dllmain
dllmain:
mov eax,1
ret 12
f1:
fb
mov eax,[ebp+8]
add eax,[ebp+12]
fa 8
xxx_link.fil:
; > golink @xxx_link.fil
/entry dllmain
/dll
/exports f1
xxx.obj
>nasm -f win32 xxx.asm
>golink @xxx_link.fil
制作dll后可以看下pe结构,免得的出问题
在x86汇编中调用
将xxx.dll拷贝到asm项目文件中
hello.asm:
extern MessageBoxA
extern ExitProcess
extern f1
section .data
title db "caption.",0
message db "hello world....",0
section .text
global main
main:
push 1
push 2
call f1
push 0
push title
push message
push 0
call MessageBoxA
_exit:
push 0
call ExitProcess
> nasm -f win32 hello.asm
> golink /entry main hello.obj kernel32.dll user32.dll xxx.dll
c++ 显示连接
将xxx.dll拷贝到c++项目文件中
#include <iostream>
#include <Windows.h>
typedef int (CALLBACK* f1_t)(int, int);
f1_t f1;
int main()
{
HMODULE myDLL = LoadLibraryA("xxx.dll");
f1 = (f1_t)GetProcAddress(myDLL, "f1");
if (f1)
printf("%d\n", f1(1, 2)); // 3
else
printf("dll not export f1");
return 0;
}
See also:
相关文章
- ORA-39339: Table string was skipped due to transportable import and TSTZ issues resulting from time zone version mismatch. ORACLE 报错 故障修复 远程处理
- ORA-54517: outer ring is on the same plane and overlaps another outer ring ORACLE 报错 故障修复 远程处理
- ORA-54605: CREATE_PC: scratch-tables/views (string) exist and need to be dropped ORACLE 报错 故障修复 远程处理
- ORA-55336: insufficient privileges for using one or more of the models and rules indexes ORACLE 报错 故障修复 远程处理
- ORA-00832: no streams pool created and cannot automatically create one ORACLE 报错 故障修复 远程处理
- MySQL Error number: MY-010438; Symbol: ER_ENGINE_COST_INVALID_CONST_CONSTANT_FOR_SE_AND_DEVICE; SQLSTATE: HY000 报错 故障修复 远程处理
- ORA-02166: ARCHIVELOG and NOARCHIVELOG specified ORACLE 报错 故障修复 远程处理
- ORA-09872: TASDEF_CREATE: create failure in creating ?/dbs/tasdef@.dbf. ORACLE 报错 故障修复 远程处理
- 深入浅出:MySQL中AND和OR运算符使用方法(mysql中and和or)
- Utilizing Redis Intersections for Advanced Data Analysis and Optimization(redis交集)
- Exploring the Features and Benefits of MySQL 5.5(mysql5.5)
- Exploring the Possibilities: Using Linux to Connect and Control HDMI Inputs(linuxhdmi输入)
- Exploring the Power of Linux Fingerprint Authentication: Secure and Efficient Access Control(linuxfp)
- Exploring the Benefits and Features of Linux Users(linux用户)
- Oracle数据库中的AND查询(oracle and查询)
- Mysql中强大的AND运算符的使用方法探究(mysql中and的使用)
- MySQL中如何正确使用AND运算符(mysql中and怎么用)
- Oracle中使用AND运算符的示例分析(oracle中and用法)