创建有导出函数的内核驱动程序
testsys.def
;testsys.def : Declares the module parameters for the DLL.
; LIBRARY "testsys"
EXPORTS
; Explicit exports can go here
SDK_ExportFunction1 @1
SDK_ExportFunction2 @2
testsys.h
#ifndef _TESTSYS_H #define _TESTSYS_H 1 extern void NTAPI SDK_ExportFunction1(ULONG nIndex) ; extern void NTAPI SDK_ExportFunction2(); #endif
testsys.c
#include <ntddk.h>
#include "testsys.h"
void NTAPI SDK_ExportFunction1(ULONG nIndex)
{
return ;
}
void NTAPI SDK_ExportFunction2()
{
return ;
}
#pragma code_seg("INIT")
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
{
return STATUS_SUCCESS ;
}
#pragma code_seg()
source
TARGETNAME=testsys
TARGETPATH=.\obj
TARGETTYPE=EXPORT_DRIVER
INCLUDES=$(IFSKIT_INC_PATH)SOURCES=testsys.c
DLLDEF=.\testsys.def
TARGETLIBS=$(DDK_LIB_PATH)\wdmsec.lib
makefile
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the driver components of the Windows NT DDK
#!INCLUDE $(NTMAKEENV)\makefile.def
testsys.dsp
# Microsoft Developer Studio Project File – Name=”testsys” – Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **# TARGTYPE “Win32 (x86) Application” 0×0101
CFG=testsys – Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f “testsys.mak”.
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f “testsys.mak” CFG=”testsys – Win32 Debug”
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE “testsys – Win32 Release” (based on “Win32 (x86) Application”)
!MESSAGE “testsys – Win32 Debug” (based on “Win32 (x86) Application”)
!MESSAGE# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName “”
# PROP Scc_LocalPath “”
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe!IF “$(CFG)” == “testsys – Win32 Release”
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir “Release”
# PROP BASE Intermediate_Dir “Release”
# PROP BASE Target_Dir “”
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir “Release”
# PROP Intermediate_Dir “Release”
# PROP Ignore_Export_Lib 0
# PROP Target_Dir “”
# ADD BASE CPP /nologo /Gz /W3 /WX /Oy /Gy /D “WIN32″ /Oxs /c
# ADD CPP /nologo /Gz /W3 /WX /O2 /I “$(BASEDIR)\inc\ddk\w2k” /I “$(BASEDIR)\inc\ddk\wdm\w2k” /I “$(BASEDIR)\inc\w2k” /D WINNT=1 /D _WIN32_WINNT=0×0400 /D DBG=0 /D _X86_=1 /FAcs /FR /YX /Oxs /Zel -cbstring /QIfdiv- /QIf /GF /c
# ADD BASE MTL /nologo /D “NDEBUG” /mktyplib203 /o “NUL” /win32
# ADD MTL /nologo /D “NDEBUG” /mktyplib203 /o “NUL” /win32
# ADD BASE RSC /l 0×409 /d “NDEBUG”
# ADD RSC /l 0×409 /i “$(BASEDIR)\inc” /d “NDEBUG”
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /machine:IX86
# ADD LINK32 ntoskrnl.lib hal.lib /nologo /base:”0×10000″ /version:5.1 /entry:”DriverEntry” /map /machine:IX86 /nodefaultlib /out:”Release\testsys.sys” /libpath:”$(BASEDIR)\lib\w2k\i386″ /driver /IGNORE:4078 /MERGE:_PAGE=PAGE /MERGE:_TEXT=.text /SECTION:INIT,d /OPT:REF /align:0×20 /osversion:5.1 /subsystem:native,5.1
# SUBTRACT LINK32 /pdb:none!ELSEIF “$(CFG)” == “testsys – Win32 Debug”
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir “Debug”
# PROP BASE Intermediate_Dir “Debug”
# PROP BASE Target_Dir “”
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir “Debug”
# PROP Intermediate_Dir “Debug”
# PROP Ignore_Export_Lib 0
# PROP Target_Dir “”
# ADD BASE CPP /nologo /Gz /W3 /Zi /Od /D “WIN32″ /YX /FD /c
# ADD CPP /Gz /W3 /Z7 /Od /Gy /I “$(BASEDIR)\inc\ddk\w2k” /I “$(BASEDIR)\inc\ddk\wdm\w2k” /I “$(BASEDIR)\inc\w2k” /D WINNT=1 /D _WIN32_WINNT=0×0400 /D DBG=1 /D _X86_=1 /FAcs /FR /YX /FD /Zel -cbstring /QIfdiv- /QIf /GF /c
# SUBTRACT CPP /nologo
# ADD BASE MTL /nologo /mktyplib203 /o “NUL” /win32
# ADD MTL /nologo /mktyplib203 /o “NUL” /win32
# ADD BASE RSC /l 0×409
# ADD RSC /l 0×409 /i “$(BASEDIR)\inc”
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /machine:IX86
# ADD LINK32 ntoskrnl.lib hal.lib /base:”0×10000″ /version:5.1 /entry:”DriverEntry” /incremental:no /map /debug /machine:IX86 /nodefaultlib /out:”Debug\testsys.sys” /libpath:”$(BASEDIR)\lib\w2k\i386″ /driver /ignore:4078 /MERGE:_PAGE=PAGE /MERGE:_TEXT=.text /SECTION:INIT,d /OPT:REF /align:0×20 /osversion:5.1 /subsystem:native,5.1
# SUBTRACT LINK32 /pdb:none!ENDIF
# Begin Target
# Name “testsys – Win32 Release”
# Name “testsys – Win32 Debug”
# Begin Group “Source Files”# PROP Default_Filter “cpp;c;cxx;rc;def;r;odl;idl;hpj;bat”
# Begin Source FileSOURCE=.\testsys.c
!IF “$(CFG)” == “testsys – Win32 Release”
!ELSEIF “$(CFG)” == “testsys – Win32 Debug”
!ENDIF
# End Source File
# Begin Source FileSOURCE=.\testsys.def
# End Source File
# End Group
# Begin Group “Header Files”# PROP Default_Filter “h;hpp;hxx;hm;inl”
# Begin Source FileSOURCE=.\testsys.h
# End Source File
# End Group
# Begin Group “Resource Files”# PROP Default_Filter “ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe”
# End Group
# Begin Source FileSOURCE=.\Readme.txt
# End Source File
# End Target
# End Project
打包下载 testsys
延伸阅读:
DLLs in Kernel Mode
内核模式的 DLL

近期评论