>KMDF_VERSION_MAJOR=1
You cannot create a KMDF based export driver, drop this line
TARGETLIBS=$(TARGETLIBS) \
$(DDK_LIB_PATH)\ntstrsafe.lib \
…..\lib$(BUILD_ALT_DIR)*\api.lib \
Instead I would have $(OBJ_PATH)....\LIB$(O)\API.LIB. are you sure…..\lib$(BUILD_ALT_DIR)*\api.lib resolves to what you want and actually contains the export?
__declspec(dllexport)
You don’t need this since you have a .def file
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com.cn
Sent: Wednesday, May 12, 2010 12:45 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Driver Export Function Problem
The error is if another driver call the export function will failed,the informations as blow:
f:\code\dre_ex_raw_asyn_cmp_km.obj : error LNK2019: unresolved external symbol xxxxx@0 referenced in function _DRE_rawAsynCmp@0
The export function in ‘api.c’:
/****************************************************************/
__declspec(dllexport)
int function_test(void)
{
…
}
/****************************************************************/
The source for api.c:
/****************************************************************/
TARGETNAME=api
TARGETTYPE=DRIVER_LIBRARY
TARGETPATH=…....\lib$(BUILD_ALT_DIR)
KMDF_VERSION_MAJOR=1
NTTARGETFILES=
TARGETLIBS=$(TARGETLIBS) \
$(DDK_LIB_PATH)\ntstrsafe.lib
INCLUDES=$(INCLUDES);…....\h;
C_DEFINES = $(C_DEFINES)
SOURCES=api.c
Generate WPP tracing code
$(SOURCES) – run software preprocessor on files listed in SOURCES
-km – use kernel mode
-func – define function we’ll use for tracing
This would map all TraceEvents calls to
DoTraceMessage.
RUN_WPP= $(SOURCES) \
-km \
-func:TraceEvents(LEVEL,FLAGS,MSG,…) \
-gen:{km-WdfDefault.tpl}*.tmh
TARGET_DESTINATION=wdf
Temporarily excuse usage of serviceability impairing macros in code…
ALLOW_DATE_TIME=1
/****************************************************************/
The source for driver.c:
/****************************************************************/
TARGETNAME=dre_panther_ctrl
TARGETTYPE=EXPORT_DRIVER
TARGETPATH=…..\drivers_bin$(BUILD_ALT_DIR)
KMDF_VERSION_MAJOR=1
INF_NAME=dre_panther_ctrl
NTTARGETFILE0=$(OBJ_PATH)$(O)$(INF_NAME).inf
PASS0_BINPLACE=$(NTTARGETFILE0)
TARGETLIBS=$(TARGETLIBS) \
$(DDK_LIB_PATH)\ntstrsafe.lib \
…..\lib$(BUILD_ALT_DIR)*\api.lib \
INCLUDES=$(INCLUDES);
C_DEFINES = $(C_DEFINES)
SOURCES=driver.c
DLLDEF=driver.def
Generate WPP tracing code
$(SOURCES) – run software preprocessor on files listed in SOURCES
-km – use kernel mode
-func – define function we’ll use for tracing
This would map all TraceEvents calls to
DoTraceMessage.
RUN_WPP= $(SOURCES) \
-km \
-func:TraceEvents(LEVEL,FLAGS,MSG,…) \
-gen:{km-WdfDefault.tpl}*.tmh
TARGET_DESTINATION=wdf
Temporarily excuse usage of serviceability impairing macros in code…
ALLOW_DATE_TIME=1
/****************************************************************/
The driver.def:
/****************************************************************/
NAME driver.sys
EXPORTS
DllInitialize PRIVATE
DllUnload PRIVATE
function_test
/****************************************************************/
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