Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

Compilation errors with including <windows.h> in a windows driver application.

I need to include the file <windows.h> in a windows driver application built using DDK winddk\6001.18001. But this includes file <winbase.h> and during compilation I get hundreds of errors, which I must resolve:

c:\winddk\6001.18001\inc\api\winbase.h(316) : error C2061: syntax error : identi
fier 'CRITICAL_SECTION'
c:\winddk\6001.18001\inc\api\winbase.h(316) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(317) : error C2061: syntax error : identi
fier 'PCRITICAL_SECTION'
c:\winddk\6001.18001\inc\api\winbase.h(317) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(318) : error C2061: syntax error : identi
fier 'LPCRITICAL_SECTION'
c:\winddk\6001.18001\inc\api\winbase.h(318) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(320) : error C2061: syntax error : identi
fier 'CRITICAL_SECTION_DEBUG'
c:\winddk\6001.18001\inc\api\winbase.h(320) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(321) : error C2061: syntax error : identi
fier 'PCRITICAL_SECTION_DEBUG'
c:\winddk\6001.18001\inc\api\winbase.h(321) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(322) : error C2061: syntax error : identi
fier 'LPCRITICAL_SECTION_DEBUG'
c:\winddk\6001.18001\inc\api\winbase.h(322) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(401) : error C2061: syntax error : identi
fier 'SRWLOCK'
c:\winddk\6001.18001\inc\api\winbase.h(401) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(401) : error C2059: syntax error : ','
c:\winddk\6001.18001\inc\api\winbase.h(409) : error C2146: syntax error : missin
g ')' before identifier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(409) : error C2061: syntax error : identi
fier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(409) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(410) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(416) : error C2146: syntax error : missin
g ')' before identifier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(416) : error C2061: syntax error : identi
fier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(416) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(417) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(423) : error C2146: syntax error : missin
g ')' before identifier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(423) : error C2061: syntax error : identi
fier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(423) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(424) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(430) : error C2146: syntax error : missin
g ')' before identifier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(430) : error C2061: syntax error : identi
fier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(430) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(431) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(437) : error C2146: syntax error : missin
g ')' before identifier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(437) : error C2061: syntax error : identi
fier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(437) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(438) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(444) : error C2061: syntax error : identi
fier 'CONDITION_VARIABLE'
c:\winddk\6001.18001\inc\api\winbase.h(444) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(444) : error C2059: syntax error : ','
c:\winddk\6001.18001\inc\api\winbase.h(450) : error C2146: syntax error : missin
g ')' before identifier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(450) : error C2061: syntax error : identi
fier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(450) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(451) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(457) : error C2146: syntax error : missin
g ')' before identifier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(457) : error C2061: syntax error : identi
fier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(457) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(458) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(464) : error C2146: syntax error : missin
g ')' before identifier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(464) : error C2061: syntax error : identi
fier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(464) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(465) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(471) : error C2146: syntax error : missin
g ')' before identifier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(471) : error C2061: syntax error : identi
fier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(471) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(471) : error C2059: syntax error : ','
c:\winddk\6001.18001\inc\api\winbase.h(474) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(480) : error C2146: syntax error : missin
g ')' before identifier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(480) : error C2061: syntax error : identi
fier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(480) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(480) : error C2059: syntax error : ','
c:\winddk\6001.18001\inc\api\winbase.h(484) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(531) : error C2061: syntax error : identi
fier 'LPLDT_ENTRY'
c:\winddk\6001.18001\inc\api\winbase.h(531) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(2279) : warning C4005: 'InterlockedExchan
gePointer' : macro redefinition
        c:\winddk\6001.18001\inc\ddk\wdm.h(11164) : see previous definition of '
InterlockedExchangePointer'
c:\winddk\6001.18001\inc\api\winbase.h(2292) : error C2059: syntax error : '('
c:\winddk\6001.18001\inc\api\winbase.h(2321) : error C2084: function 'LONGLONG _
InterlockedAnd64(volatile LONGLONG *,LONGLONG)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4449) : see previous definition of
'_InterlockedAnd64'
c:\winddk\6001.18001\inc\api\winbase.h(2339) : error C2084: function 'LONGLONG _
InterlockedOr64(volatile LONGLONG *,LONGLONG)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4469) : see previous definition of
'_InterlockedOr64'
c:\winddk\6001.18001\inc\api\winbase.h(2357) : error C2084: function 'LONGLONG _
InterlockedXor64(volatile LONGLONG *,LONGLONG)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4489) : see previous definition of
'_InterlockedXor64'
c:\winddk\6001.18001\inc\api\winbase.h(2374) : error C2084: function 'LONGLONG _
InterlockedIncrement64(volatile LONGLONG *)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4509) : see previous definition of
'_InterlockedIncrement64'
c:\winddk\6001.18001\inc\api\winbase.h(2391) : error C2084: function 'LONGLONG _
InterlockedDecrement64(volatile LONGLONG *)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4528) : see previous definition of
'_InterlockedDecrement64'
c:\winddk\6001.18001\inc\api\winbase.h(2409) : error C2084: function 'LONGLONG _
InterlockedExchange64(volatile LONGLONG *,LONGLONG)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4547) : see previous definition of
'_InterlockedExchange64'
c:\winddk\6001.18001\inc\api\winbase.h(2427) : error C2084: function 'LONGLONG _
InterlockedExchangeAdd64(volatile LONGLONG *,LONGLONG)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4567) : see previous definition of
'_InterlockedExchangeAdd64'
c:\winddk\6001.18001\inc\api\winbase.h(2469) : warning C4005: 'InterlockedCompar
eExchangePointer' : macro redefinition
        c:\winddk\6001.18001\inc\ddk\wdm.h(11120) : see previous definition of '
InterlockedCompareExchangePointer'
c:\winddk\6001.18001\inc\api\winbase.h(2495) : error C2375: 'InitializeSListHead
' : redefinition; different linkage
        c:\winddk\6001.18001\inc\ddk\wdm.h(14639) : see declaration of 'Initiali
zeSListHead'
c:\winddk\6001.18001\inc\api\winbase.h(2502) : error C2373: 'InterlockedPopEntry
SList' : redefinition; different type modifiers
        c:\winddk\6001.18001\inc\ddk\wdm.h(14858) : see declaration of 'Interloc
kedPopEntrySList'
c:\winddk\6001.18001\inc\api\winbase.h(2510) : error C2373: 'InterlockedPushEntr
ySList' : redefinition; different type modifiers
        c:\winddk\6001.18001\inc\ddk\wdm.h(14865) : see declaration of 'Interloc
kedPushEntrySList'
c:\winddk\6001.18001\inc\api\winbase.h(2517) : error C2373: 'ExInterlockedFlushS
List' : redefinition; different type modifiers
        c:\winddk\6001.18001\inc\ddk\wdm.h(14849) : see declaration of 'ExInterl
ockedFlushSList'
c:\winddk\6001.18001\inc\api\winbase.h(2524) : error C2059: syntax error : '('
c:\winddk\6001.18001\inc\api\winbase.h(2903) : error C2146: syntax error : missi
ng ')' before identifier 'lpBuffer'
c:\winddk\6001.18001\inc\api\winbase.h(2903) : error C2081: 'PMEMORY_BASIC_INFOR
MATION' : name in formal parameter list illegal
c:\winddk\6001.18001\inc\api\winbase.h(2903) : error C2061: syntax error : ident
ifier 'lpBuffer'
c:\winddk\6001.18001\inc\api\winbase.h(2903) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(2903) : error C2059: syntax error : ','
c:\winddk\6001.18001\inc\api\winbase.h(2905) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(3016) : error C2146: syntax error : missi
ng ')' before identifier 'lpBuffer'
c:\winddk\6001.18001\inc\api\winbase.h(3016) : error C2081: 'PMEMORY_BASIC_INFOR
MATION' : name in formal parameter list illegal
c:\winddk\6001.18001\inc\api\winbase.h(3016) : error C2061: syntax error : ident
ifier 'lpBuffer'
c:\winddk\6001.18001\inc\api\winbase.h(3016) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(3016) : error C2059: syntax error : ','
c:\winddk\6001.18001\inc\api\winbase.h(3018) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(3161) : error C2146: syntax error : missi
ng ')' before identifier 'HeapInformationClass'
c:\winddk\6001.18001\inc\api\winbase.h(3161) : error C2081: 'HEAP_INFORMATION_CL
ifier 'HeapInformationClass'
c:\winddk\6001.18001\inc\api\winbase.h(3171) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(3171) : fatal error C1003: error count exceeded
0
supriyaksen
Asked:
supriyaksen
1 Solution
 
DavidCommented:
There are a dozen things this could be, from not using the proper compiler environment variables to wrong compiler, to wrong  target (32bit vs 64bit vs WOW), ...  to settings in files included BEFORE the <windows.h>

Best way to get this resolved is to use the DDK and compile one of the simple sample applications and get that to work.  Then you'll know  your runtime./compile environment is correct.

You could publish source code of the entire operation, and people running different system configurations will get different results.
0
 
Seth SimmonsSr. Systems AdministratorCommented:
that DDK version is for windows 2008 sp1
what version of windows are you running this on?
0
 
supriyaksenAuthor Commented:
Yes, I am running this on a windows  8 system. What typical compiler environment variables are used to resolve these issues, and what particular header files need to be included before the windows.h header during compilation? A sample posting of these would be really helpful.

 I am currently using the following complier flags:

cygdrive/c/winddk/6001.18001/bin/x86/x86/cl -nologo -Gz -Zp8 -Ob1 -EHsc -Oi -Zl -Zi -Ox -W4

and the following compiler defines:
-D_X86_ -D_WDM_INCLUDED_ -D_i386_ -D_WIN32 -DWINNT=1 -D_WIN32_WINNT=0x0502 -DWINVER=0x0502 -D_WIN32_IE=0x0603 -D_NTDRIVER_ -D__BUILDMACHINE__=WinDDK  -DCPU=X86 -DQCPU=QX86

Not sure which header file to include before the windows.h file.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
DavidCommented:
https:#a40021810 is correct answer.  The DDK is specifically designed to work for Win2008, not "Windows 8".
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now