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 ...
随机推荐
- Solon rpc 1.3.1 发布,推出Cloud接口与配置规范
Solon 是一个微型的Java RPC开发框架.项目从2018年启动以来,参考过大量前人作品:历时两年,3500多次的commit:内核保持0.1m的身材,超高的跑分,良好的使用体验.支持:Rpc. ...
- Vue3.0短视频+直播|vue3+vite2+vant3仿抖音界面|vue3.x小视频实例
基于vue3.0构建移动端仿抖音/快手短视频+直播实战项目Vue3-DouYin. 5G时代已来,短视频也越来越成为新一代年轻人的娱乐方式,在这个特殊之年,又将再一次成为新年俗! 基于vue3.x+v ...
- vue3系列:vue3.0自定义虚拟滚动条V3Scroll|vue3模拟滚动条组件
基于Vue3.0构建PC桌面端自定义美化滚动条组件V3Scroll. 前段时间有分享一个Vue3 PC网页端弹窗组件,今天带来最新开发的Vue3.0版虚拟滚动条组件. V3Scroll 使用vue3. ...
- 一:Spring Boot 的配置文件 application.properties
Spring Boot 的配置文件 application.properties 1.位置问题 2.普通的属性注入 3.类型安全的属性注入 1.位置问题 当我们创建一个 Spring Boot 工程时 ...
- Java 集合框架()
一概述 二Collection接口 List Set Queue 三Map接口 HashMap LinkedHashMap TreeMap 四其它集合类 Vector Stack HashTable ...
- Django(命名空间)
命名空间 命名空间(英语:Namespace)是表示标识符的可见范围.一个标识符可在多个命名空间中定义,它在不同命名空间中的含义是互不相干的.这样,在一个新的命名空间中可定义任何标识符,它们不会与任何 ...
- Pytest(18)pytest接口自动化完整框架思维导图
pytest接口自动化完整框架思维导图
- 【函数分享】每日PHP函数分享(2021-2-6)
array_combine - 创建一个数组,用一个数组的值作为其键名,另一个数组的值作为其值 说明: array_combine ( array $keys , array $values ) : ...
- workflow定时任务部分失败
workflow遇到一个问题,每天定时任务导致部分失败,截图如下 目前这个问题现场出现过是重启wf解决的 ,但是也给研发排查了,根本原因不清楚,不确保现场还会再遇到.
- poj2926Requirements (曼哈顿距离)
Description An undergraduate student, realizing that he needs to do research to improve his chances ...