 |
Migrating VC6 driver project to VC8 with DDK 2003
Task
We have VC6 driver project configured as described in
Creating Driver project for Visual Studio 6.0 article. Our task is
to build it with minimal efforts under Visual Studio 8 using DDK 2003. Also we want to keep compatibility with
previous versions of Visual Studio and DDK. At least .MAK file generated from VC6 .DSP project shall work with
nmake utility under all environments.
Note: Sometimes DDK 2003 comes under name DDK XP, but DDK 2003 has very specific
inc and lib directory structure:
| XP DDK | | DDK 2003 |
\inc
\lib
\i386
|
|
\inc
\atl21, \atl30, \crt, \ddk, \ifs,
\inc16, \mfc42, \w2k, \wnet, \wxp
\lib
\lib16
\w2k
\i386
\wnet
\amd64, \i386, \ia64
\wxp
\i386, \ia64
|
Problems
- different directory layout (see above), and as result disability to find headers .H and libraries .LIB
- new compiler (cl.exe) and linker (link.exe) options
cl : Command line warning D9035 : option 'GX' has been deprecated and will be removed
in a future release
cl : Command line warning D9036 : use 'EHsc' instead of 'GX'
- string functions deprecation warning
c:\projects\src\driver\mycpp.cpp(22) :
warning C4996: 'strcpy' was declared deprecated
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\string.h(73) :
see declaration of 'strcpy'
Message: 'This function or variable may be unsafe. Consider using
strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE.
See online help for details.'
- "unresolved external" errors
mycpp.obj : error LNK2001: unresolved external symbol ___security_cookie
mycpp.obj : error LNK2001: unresolved external symbol @__security_check_cookie@4
mycpp.obj : error LNK2001: unresolved external symbol __except_handler4
LINK : error LNK2001: unresolved external symbol __load_config_used
Solution N1 (by Alter)
Note:
All these steps must be performed for each build configuration (Debug/Release).
Solution N2 (by DeathSoft)
In order to get ___security_cookie, you
have to add BufferOverflowK.lib to your project.
You can get it from newer DDK.
Set /entry:"GsDriverEntry@8" option, this information can also be found in MSDN.
To have no problems with /safeseh:yes (it is the default in new Visual Studio)
add the following file to project:
safeseh.c:
extern ULONG_PTR __security_cookie; /* /GS security cookie */
/*
* The following two names are automatically created by the linker for any
* image that has the safe exception table present.
* /
extern PVOID __safe_se_handler_table[]; /* base of safe handler entry table * /
extern UCHAR __safe_se_handler_count; /* absolute symbol whose address is
the count of table entries * /
typedef struct {
ULONG Size;
ULONG TimeDateStamp;
USHORT MajorVersion;
USHORT MinorVersion;
ULONG GlobalFlagsClear;
ULONG GlobalFlagsSet;
ULONG CriticalSectionDefaultTimeout;
ULONG DeCommitFreeBlockThreshold;
ULONG DeCommitTotalFreeThreshold;
ULONG LockPrefixTable; // VA
ULONG MaximumAllocationSize;
ULONG VirtualMemoryThreshold;
ULONG ProcessHeapFlags;
ULONG ProcessAffinityMask;
USHORT CSDVersion;
USHORT Reserved1;
ULONG EditList; // VA
ULONG_PTR *SecurityCookie;
PVOID *SEHandlerTable;
ULONG SEHandlerCount;
} IMAGE_LOAD_CONFIG_DIRECTORY32_2;
extern
const IMAGE_LOAD_CONFIG_DIRECTORY32_2 _load_config_used = {
sizeof(IMAGE_LOAD_CONFIG_DIRECTORY32_2),
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
&__security_cookie,
__safe_se_handler_table,
(ULONG)(ULONG_PTR) &__safe_se_handler_count
};
Solution N3
Take pre-configured empty driver project for VS 2005 and add there your sources.
You can find it together with VC6 project for kernel mode driver.
Look in archive in pch_cpp subfolder. Also you can create VS8 project yourself
with help of this manual:
VC8 project for kernel mode driver.
Practically, you will completley convert your project from VS6 to VS8.
2006.11.23,
updated
2006.12.02
See also:
|
 |