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 ...
随机推荐
- udp聊天器
import socket def send_msg(udp_socket): """获取键盘数据,并将其发送给对方""" # 1. 从键盘 ...
- P1663 山
写在前面 简单的二分答案,稍微加点数学计算,很有意思. 算法思路 二分答案可行的原因:答案具有单调性. 这道题目中证明一下:首先无限高显然是能看到任何一个点的,且山的每一条边都是对答案的一个限制,因此 ...
- BootstrapValidator验证规则、BootStrap表格:列参数
BootstrapValidator验证规则 需引用组件 <script src="~/Scripts/jquery-1.10.2.js"></script> ...
- hibernate+spring+tomcat启动报错Not supported by BasicDataSource
最近使用hibernate+spring+jsp的小项目制作过程中出现一些错误,例如: java.lang.UnsupportedOperationException: Not supported b ...
- codeforces 1461D,离线查询是什么神仙方法,为什么快这么多?
大家好,欢迎来到codeforces专题. 今天我们选择的题目是1461场次的D题,这题全场通过了3702人,从难度上来说比较适中.既没有很难,也很适合同学们练手.另外它用到了一种全新的思想是在我们之 ...
- NodeMCU使用ArduinoJson判断指定键值对存在与否
NodeMCU使用ArduinoJson判断指定键值对存在与否 从ArduinoJson库中可以得知,判断键值对是否存在可以使用containskey()函数,但是查看ArduinoJson-cont ...
- c#的dllimport使用方法详解(Port API)
DllImport是System.Runtime.InteropServices命名空间下的一个属性类,其功能是提供从非托管DLL(托管/非托管是微软的.net framework中特有的概念,其中, ...
- The Department of Redundancy Department
Write a program that will remove all duplicates from a sequence of integers and print the list of un ...
- G - 跑跑卡丁车
跑跑卡丁车是时下一款流行的网络休闲游戏,你可以在这虚拟的世界里体验驾驶的乐趣.这款游戏的特别之处是你可以通过漂移来获得一种加速卡,用这种加速卡可以在有限的时间里提高你的速度.为了使问题简单化,我们假设 ...
- Codeforces Round #633 (Div. 2)
Codeforces Round #633(Div.2) \(A.Filling\ Diamonds\) 答案就是构成的六边形数量+1 //#pragma GCC optimize("O3& ...