flat assembler
Message board for the users of flat assembler.

Index > Windows > Problem with MS COFF in C++ DLL file

Author
Thread Post new topic Reply to topic
kiselevd2002



Joined: 06 May 2021
Posts: 4
kiselevd2002
Hi,

I've got an error while compiling this simple project. Please help me.

Code:
format MS COFF
include 'C:/fasm/include/win32ax.inc'

public getdatainfo as '_GetDataInfo@4'

; external function as an example
proc getdatainfo,data:dword
    mov [data], 0
    ret
endp

.data
; data segment goes here

section '.rdata' data readable
; rdata section goes here

.code

proc mail
    ret
endp

section '.edata' export data readable
; export section goes here
export 'CR2.DLL',\
    mail,'_mail_'

    


When I compile this code I get this error:
>fasm main32.asm flat assembler version 1.73.27 (1048576 kilobytes memory) main32.asm [24]: section '.edata' export data readable processed: section '.edata' export data readable error: extra characters on line.

Also, when I read the manual it says concerning eporting dll functions that
Quote:

The export macroinstruction constructs the export data for the PE file (it should be either placed in the section marked as export, or within the data export block.


But what data export block is nowhere is told. Maybe someone could tell me (better with some code example) how to implement it?

Thank you in advance
Post 18 Jul 2021, 11:53
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3391
Location: vpcmipstrm
bitRAKE
Are you trying to produce a DLL or a MS COFF object file? Presently, you are mixing the two together. There are examples in the distribution to produce a DLL, so I will ignore that and assume you are trying to create an object file that exports a function.

Creating an object file, PUBLIC/EXTERN refers to functions that are accessible to other object files. PUBLIC makes the function visible by other object files, EXTERN indicates symbols that are in other object files.

Working with object files, it is the linker that creates the DLL. Which functions are exported by the DLL are typically specified in an external (.DEF or .EXP) file.

So, you see, there are two concepts getting mixed together.

_________________
¯\(°_o)/¯ unlicense.org
Post 18 Jul 2021, 15:34
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3391
Location: vpcmipstrm
bitRAKE
kiselevd2002 wrote:
But what data export block is nowhere is told.
The data export block is an optional way to defined the export section (instead of using the section directive).

Code would look like:
Code:
data export

; ( put code here to generate export data )

end data    
... my previous response was deficient in explaining this and the DLL examples in the distribution do not use this feature. If one wanted more fine-grained control of the section directories, fasm allows manually creating the entries with the data directive. From the manual ...
Quote:
data directive begins the definition of special PE data, it should be followed by one of the data identifiers (export, import, resource or fixups) or by the number of data entry in PE header. The data should be defined in next lines, ended with end data directive.
Also, I was surprised to not find any examples in searches of the board. Probably a deficiency is my search methodology.

_________________
¯\(°_o)/¯ unlicense.org
Post 19 Jul 2021, 21:54
View user's profile Send private message Visit poster's website Reply with quote
donn



Joined: 05 Mar 2010
Posts: 227
donn
ms coff example is here:

https://flatassembler.net/examples.php
Mixing assembly with MS Visual C

It's what I used to get started with MS COFF, and MS COFF is my primary format now. You can use it as a lib, or execute with it after linking, i.e.:

Code:
link /LARGEADDRESSAWARE /MACHINE:X64 /SUBSYSTEM:WINDOWS  /ENTRY:start asmObjFile.obj "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64\User32.Lib" "C:\VulkanSDK\1.1.130.0\Lib\vulkan-1.lib"   /LIBPATH:"C:\VulkanSDK\1.1.130.0\Lib"    

(incomplete included libraries, but shows the gist of a Win Vulkan app)
Post 26 Jul 2021, 00:31
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.