extern “C” means you are compiling in C++.
You did not specify the calling convention.
extern “C” void __cdecl GetPtrGetKtProcAddress();
the name is therefore
_GetPtrGetKtProcAddress
and if in a DLL might be
__imp__GetPtrGetKtProcAddress
when in doubt, use some useful utility to examine the file you are linking
to, like the dumpbin utility
joe
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Soren Dreijer
Sent: Monday, February 21, 2011 1:41 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Calling a C function from ASM in user-mode driver
I have a user-mode driver (DLL) that I’m compiling with the WDK. The driver
uses an ASM file that’s included in the build process like so:
I386_SOURCES= \
i386\stub.asm
The ASM file is calls a C-function, but for some reason the linker ends up
with an unresolved symbol error.
The C-function I’m trying to call is defined as follows:
extern “C” void GetPtrGetKtProcAddress()
{
}
The ASM file looks as follows:
.586
.MODEL FLAT, C
EXTRN GetPtrGetKtProcAddress:proc
.DATA
.CODE
; Function prototypes
public GetKtProcAddress
GetKtProcAddress proc
pushad
call GetPtrGetKtProcAddress
ret
GetKtProcAddress endp
_text ends
end
The code compiles and links fine in VS2010, so I’m thinking I’m missing
something specific to the WDK somewhere.
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
–
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.