why Error in Windows Libraries when i build ?

i my filter file ::

filter.h

#ifndef FILTER_H
#define FILTER_H

#include “mux/win/ndis62/global.h”

#include <windows.h>
#include <winsock2.h>
#include <iphlpapi.h>

#pragma comment(lib, “ws2_32.lib”)
#pragma comment(lib, “iphlpapi.lib”)

class CFilter {

public:

typedef PIP_ADAPTER_ADDRESSES AddressesType;
}

----

#endif // FILTER_H
in filter.cpp i am writing code with including Filter.h file also .

But i am using Visual studio 2013 . After Building i got errors like

Filter.cpp

C:\Program Files (x86)\Windows Kits\8.1\Include\um\minwinbase.h(198): error C2146: syntax error : missing ‘;’ before identifier ‘CRITICAL_SECTION’ [C:\Users\driver\mux\win\ndis62\tun.vcxproj]
C:\Program Files (x86)\Windows Kits\8.1\Include\um\minwinbase.h(199): error C2146: syntax error : missing ‘;’ before identifier ‘PCRITICAL_SECTION’ [C:\Users\driver\mux\win\ndis62\tun.vcxproj]
C:\Program Files (x86)\Windows Kits\8.1\Include\um\minwinbase.h(202): error C2146: syntax error : missing ‘;’ before identifier ‘CRITICAL_SECTION_DEBUG’ [C:\Users\driver\mux\win\ndis62\tun.vcxproj]
C:\Program Files (x86)\Windows Kits\8.1\Include\um\minwinbase.h(203): error C2146: syntax error : missing ‘;’ before identifier ‘PCRITICAL_SECTION_DEBUG’ [C:\Users\driver\mux\win\ndis62\tun.vcxproj]
C:\Program Files (x86)\Windows Kits\8.1\Include\um\errhandlingapi.h(181): error C2061: syntax error : identifier ‘PVECTORED_EXCEPTION_HANDLER’ [C:\Users\driver\mux\win\ndis62\tun.vcxproj]

I tried to include windows.h in filter.h file . But same error . I am also include C:\Program Files (x86)\Windows Kits\8.1\Include\um in properties -> C/C++ -> General -> Additional include directories like

$(IntDir);%(AdditionalIncludeDirectories);C:\Program Files (x86)\Windows Kits\8.1\Include\um

i tried ::

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#include <iphlpapi.h>

and also tried

#include <winsock2.h>
#include <windows.h>
#include <iphlpapi.h>

Why this error getting ??

i also tried like this ::

*********
Filter .h


ifndef FILTER_H
#define FILTER_H

#include <winsock2.h>
#include <iphlpapi.h>
#include “multiplexer/windows/ndis62/global.h”
#pragma comment(lib, “ws2_32.lib”)
#pragma comment(lib, “iphlpapi.lib”)

and in

*
Filter.cpp ::


#include <ntddk.h>

*******************************

the amount of error decreasing but got errors like ::

C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ntdef.h(163): error C2220: warning treated as error - no ‘object’ file generated
C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ntdef.h(163): warning C4005: ‘PROBE_ALIGNMENT’ : macro redefinition
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(140) : see previous definition of ‘PROBE_ALIGNMENT’
C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ntdef.h(173): warning C4005: ‘PROBE_ALIGNMENT32’ : macro redefinition
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(150) : see previous definition of ‘PROBE_ALIGNMENT32’
C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ntdef.h(687): error C2011: ‘_PROCESSOR_NUMBER’ : ‘struct’ type redefinition
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(547) : see declaration of ‘_PROCESSOR_NUMBER’
C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ntdef.h(698): error C2011: ‘_GROUP_AFFINITY’ : ‘struct’ type redefinition
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(558) : see declaration of ‘_GROUP_AFFINITY’
C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ntdef.h(992): error C2011: ‘_FLOAT128’ : ‘struct’ type redefinition
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(708) : see declaration of ‘_FLOAT128’
C:\Program Files (x86)\Windows Kits\8.1\Include\shared\ntdef.h(1043): error C2011: ‘_LARGE_INTEGER’ : ‘union’ type redefinition
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(755) : see declaration of ‘_LARGE_INTEGER’

etc …

why ? any suggestions ?</ntddk.h></iphlpapi.h></winsock2.h></iphlpapi.h></windows.h></winsock2.h></iphlpapi.h></winsock2.h></windows.h></iphlpapi.h></winsock2.h></windows.h>

You’re building a KM filter driver, right? (Filter.cpp includes ntddk.h) If so, you can’t use UM headers and libs in there.

So how can I include these library ? Because I need to implement ip helper function in filter.cpp … any idea ?
Or should I call a function inside filter.cpp and implement that function in another file ?

Please look this document . I am implementing this in filter .cpp

https://msdn.microsoft.com/en-us/library/windows/hardware/ff552604(v=vs.85).aspx

That page points you to what you need: “To use the IP Helper functions in kernel mode, miniport drivers must include the Netioapi.h header file, and link against Netio.lib.”

IP Helper:
https://msdn.microsoft.com/en-us/library/windows/hardware/ff557015(v=vs.85).aspx

Including Header Files for IP Helper:
https://msdn.microsoft.com/en-us/library/windows/hardware/ff554804(v=vs.85).aspx

Why dont you want to simply give it up??? Look - if, after having been asking questions here for at least half a year, you are still incapable of understanding WHY one cannot link KM code against UM libraries…well, just check my posts and look for Mr. Burn’s statement that I am so fond of quoting - it seems to perfectly apply here(I cannot quote it myself - otherwise I will be, again, accused of trolling). I dont want to say that I follow your “progress” that closely, but I am under the impression that even Mr.Roberts have been eventually turned away by such levels of obtuseness - after all, he does not seem to be helping you that much these days,does he…

Anton Bassov

You can NOT. You are trying to include User Mode (UM) code into a driver. You will have to break the code up by building a separate UM application that communicates to your driver. Your driver will need to signal and communicate with the UM application what it wants done.

Hope this helps

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, March 15, 2016 2:13 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] why Error in Windows Libraries when i build ?

So how can I include these library ? Because I need to implement ip helper function in filter.cpp … any idea ?
Or should I call a function inside filter.cpp and implement that function in another file ?


NTDEV is sponsored by OSR

Visit the list online at: http:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at http:</http:></http:></http:>

my build Succeed with implemetn the IP helper in another function . But when i installing my filter driver , it is not installing .

in Filter.cpp :

*****************
//calling a function

add interface ()
{
status = Interface::mb_adapter_address();
}

and in another file interface i am implementing this function

Interface.cpp :

***************************
#include <windows.h>
#include <winsock.h>
#include <iphlpapi.h>
#include <stdlib.h>

// i added iphlpapi.lib in visual stdio lib files

u32_t Interface::mb_adapter_address()
{

PIP_ADAPTER_INFO pAdapterInfo;

ULONG ulOutBufLen = sizeof (IP_ADAPTER_INFO);

pAdapterInfo = NULL;

if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_SUCCESS) {

print(?Error Success\n?);
}
}

i am checking whether is installing or not . Build got success . But when i put " GetAdaptersInfo " i can’t install filter driver . If i remove " GetAdaptersInfo " and i checked whether the filter is calling the function with out " GetAdaptersInfo " . this is working . only when i put " GetAdaptersInfo " code , this filter is not installing . Any suggestions ??

when i put

GetAdaptersInfo(NULL, &ulOutBufLen)

again same problem . not installing</stdlib.h></iphlpapi.h></winsock.h></windows.h>