FASM 中的外部程序
我一直在尝试将程序从外部文件导出到主汇编程序,但它不起作用。
这是来自外部文件的测试代码:
; Export procedure Summa
format PE GUI 4.0
include 'win32a.inc'
section '.code' code readable executable
proc Summa
Public Summa
ret 2
endp
在主文件中,我尝试附加摘要:
format PE GUI 4.0
include 'win32a.inc'
section '.data' data readable writeable
extrn Summa as Summa : proc
在编译主文件时,我在带有 extrn 关键字的行中收到非法指令错误。
尝试在网络上搜索,但我没有幸运地找到如何在 FASM 中附加外部程序...
谢谢!
I have been trying to export procedure from external file to the main assembly program, but it didn't work.
Here is test code from external file:
; Export procedure Summa
format PE GUI 4.0
include 'win32a.inc'
section '.code' code readable executable
proc Summa
Public Summa
ret 2
endp
And in the main file I try to attach Summa:
format PE GUI 4.0
include 'win32a.inc'
section '.data' data readable writeable
extrn Summa as Summa : proc
While compiling main file I get Illegal Instruction error in the line with extrn keyword.
Tried to search the web, but I wasn't lucky to find how I should attach external procedure in FASM...
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我看到你有两个 GUI 可执行文件,那么“从外部文件导出过程到主汇编程序”是什么意思?
您想创建两个目标文件 (.obj) 然后将它们链接在一起吗?
然后在两个文件中使用
format MS COFF
,添加适当的extrn
和public
指令,并使用一些链接器(例如link.exe)来构建.exe 文件。另请阅读 fasm.pdf,第 2.4.3 节“通用对象文件格式”。
I see that you have two GUI executables, so what means "export procedure from external file to the main assembly program"?
Do you want to make two object files (.obj) and then link them together?
Then use
format MS COFF
in both files, add properextrn
andpublic
directives, and use some linker (for example link.exe) to build .exe file.Also, read fasm.pdf, section 2.4.3 "Common Object File Format".
使用PE,我相信您可以像这样从DLL导入:
如果您使用MS COFF,链接样式将根据您的位数32或64而不同:
32位:
64 位:
一个展示 32 位链接的好例子:
https://flatassembler.net/examples/msvc.zip
您还可以将 extrn 与 ELF64 一起使用,Linux 示例:
https://2ton.com.au/rants_and_musings/gcc_integration.html
PE DLL函数导入示例:
https://flatassembler.net/examples/quetannon.zip
With PE, I believe you can import from a DLL like so:
If you use MS COFF, the linking style will be different depending on your bitness 32 or 64:
32-bit:
64-bit:
A great example showing linking in 32-bit:
https://flatassembler.net/examples/msvc.zip
You can also use extrn with ELF64, Linux example:
https://2ton.com.au/rants_and_musings/gcc_integration.html
PE DLL function import example:
https://flatassembler.net/examples/quetannon.zip