News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

symbol redefinition error __imp_readfile and others

Started by markallyn, September 12, 2021, 07:11:50 AM

Previous topic - Next topic

markallyn

Hello everyone,

If I prefix the setfilepointer, readfile, and writefile in the snippet below with __imp_ the linker throws symbol redefinition errors.  If I remove them, as shown in the quote, and postfix these declarations with "A", the linker is happy.  On the other hand, if I remove the "__imp_" prefix from CreateFileEx then the linker kicks out a symbol redefiniton error.  Furthermore, if I remove the "Ex" postfix the linker throws out a symbol redefinition error. 

I don't get it. 

To make matters even more confusing, "printf" is happy with neither a prefix or a postfix.  I know that printf comes from msvcrt ultimately and the other three originate in kernel32.  So, that may be part of the answer.

The original definitions for readfile, writefile, and setfilepointer are in "fileapi.h".  Where can I find the equivalent file in masm32?

Lots of questions.  I hope they are clear!  I'm happy to send more stuff on this if it would be helpful.

Quote
include ..\masm32\include64\masm64rt.inc

__imp_CreateFileEx PROTO :LPCTSTR, :DWORD, :DWORD, :LPSECURITY_ATTRIBUTES, :DWORD, :DWORD, :HANDLE
printf   PROTO :VARARG
SetFilePointerA PROTO :QWORD, :QWORD, :QWORD, :DWORD
ReadFileA   PROTO   :HANDLE, :QWORD, :DWORD, :QWORD, :LPOVERLAPPED
WriteFileA   PROTO :HANDLE, :QWORD, :DWORD, :QWORD, :LPOVERLAPPED

Thanks,
Mark Allyn

hutch--

Mark,

You are using the main include file for 64 bit MASM which will not work with 32 bit MASM code. I don't know where you got the prototypes from but they are not the ones provided with the MASM32 SDK.

You cannot mix and match between different systems, you must use components that are designed to be compatible with each other.

Note that the MASM32 SDK does NOT copy the format of the C/C++ header files, it uses a master include file and for each system DLL it uses a separate include file. If you are using other include files, you need to use them with matching libraries.

markallyn

Good morning, Hutch,

Looks like I have to download the masm32 SDK.  I made the wrong assumption that the prototypes as defined by msdn were duplicated in masm32.  So, unintentionally I wound up accidentally trying to mix and match.

MSDN is where I got the prototypes, btw.  They are also the same as described in Johnson Hart's 3rd edition of "Windows System Programming".

Thanks for the tip.

Mark Allyn