nasm and golink create a DLL x86
制作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:
nasm and golink create a DLL x86的更多相关文章
- create dll project based on the existing project
Today, I have to create a dll project(called my.sln), the dllmain.cpp/.h/ is already in another proj ...
- [转]Replace all UUIDs in an ATL COM DLL.
1. Introduction. 1.1 Recently, a friend asked me for advise on a very unusual requirement. 1.2 He ne ...
- Dll学习一_Dll 创建并动态引用窗体且释放窗体Demo
1.新建Dll工程 2.Dll工程全部代码 library SubMain; { Important note about DLL memory management: ShareMem must b ...
- Delphi中编写无输出函数名的DLL文件(有点意思)(400多篇博客)
用 Delphi 用长了,总是发现,有些和 MS 不同的地方.例如,MS 的公开库中,常常隐藏了许多重要函数,这些函数在系统中常常有起着非常巨大的作用.一旦知道如何调用,可以给自己的应用程序提供很强的 ...
- Cannot generate C# proxy dll with JNI4NET tool, running batch file as trusted assembly?
From: https://stackoverflow.com/questions/41042368/cannot-generate-c-sharp-proxy-dll-with-jni4net-to ...
- Delphi调用DLL中的接口
问题描述: 具体问题就是在隐式使用接口变量后,在FreeLibrary执行后,就会出现一个非法访址的错误. 这个错误的原因就是在FreeLibrary后,DLL以的代码均为不可用状态,而在代码执行完整 ...
- Delphi DLL制作和加载 Static, Dynamic, Delayed 以及 Shared-Memory Manager
一 Dll的制作一般分为以下几步:1 在一个DLL工程里写一个过程或函数2 写一个Exports关键字,在其下写过程的名称.不用写参数和调用后缀.二 参数传递1 参数类型最好与window C++的参 ...
- DYNAMIC LINK LIBRARY - DLL
https://www.tenouk.com/ModuleBB.html MODULE BB DYNAMIC LINK LIBRARY - DLL Part 1: STORY What do we h ...
- Walkthrough: Create and use your own Dynamic Link Library (C++)
参考网站:https://docs.microsoft.com/en-us/cpp/build/walkthrough-creating-and-using-a-dynamic-link-librar ...
随机推荐
- mysql8.0.19忘记密码
1.管理员打开cmd窗口 2.输入net stop mysql,停止mysql服务 3.开启跳过验证密码的mysql服务 用记事本打开 输入skip-grant-tables ,保存 4.管理员打开新 ...
- SpringCloud-常用组件介绍
SpringCloud-常用组件介绍 分布式系统开发用于分布式环境(多个服务器不在同一个机房,同一个业务服务在多台服务器运行) Spring Cloud 是基于Springboot的分布式云服务架构, ...
- flutter--Dart基础语法(一)
一.前言 Flutter 是 Google 开源的 UI 工具包,帮助开发者通过一套代码库高效构建多平台精美应用,Flutter 开源.免费,拥有宽松的开源协议,支持移动.Web.桌面和嵌入式平台. ...
- MySql(二)索引的设计与使用
MySql(二)索引的设计与使用 一.索引概述 二.设计索引的原则 三.BTREE索引与HASH索引 一.索引概述 所有Mysql列类型都可以被索引,对相关列使用索引时提高select操作性能的最佳途 ...
- jenkins 简介和简单操作
持续集成:Continuous Intergration (CI) 持续交付:Continuous Delivery(CD) 持续部署:Continuous Deployment(CD) jenkin ...
- 深度解读.NET5 授权中间件执行策略
前文提要 2021.1月份我写了一个<这难道不是.NET5 的bug? 在线求锤?>, 讲述了我在实现[全局授权访问+特例匿名访问] 遇到的技术困惑: [特例匿名访问,还是走了认证流程]. ...
- jdk 安装过程配置环境变量 error 的解决过程
jdk 安装过程配置环境变量 error 的解决过程 问题背景: 我在安装 jdk 过程中在JAVA_HOME和path中添加路径后, cmd 中输入java 和javac均出现错误,因为之前在 D ...
- 如何获得svn的版本号信息?
方法一 popen(可获取命令行执行后的输出结果) 转载自: C++执行命令行指令并获取命令行执行后的输出结果 1 /* 2 Execute command line commands and ge ...
- BZOJ-1086 [SCOI2005]王室联邦 (树分块)
递归处理子树,把当前结点当作栈底,然后递归,回溯回来之后如果栈中结点数量到达某一个标准时,弹出栈中所有的元素分到一个块中,最后递归结束了如果栈中还有元素,那么剩下的这些元素放在新的块中 题目:BZOJ ...
- POJ 2195 & HDU 1533 Going Home(最小费用最大流)
这就是一道最小费用最大流问题 最大流就体现到每一个'm'都能找到一个'H',但是要在这个基础上面加一个费用,按照题意费用就是(横坐标之差的绝对值加上纵坐标之差的绝对值) 然后最小费用最大流模板就是再用 ...