Windows SDK method declarations conflict

ww898 16 Reputation points
2020-10-20T10:37:12.147+00:00

Hi Support,

I found the conflict between declarations in netfw.h and networkisolation.h. The bug was detected in following Windows SDK's:

  • v10.0.17134.0
  • v10.0.18362.0
  • v10.0.19041.0

The netfw.h declare WinAPI calls without WINAPI calling convention. This typo is cause of compiler or linker errors.

netfw.h:

DWORD
NetworkIsolationEnumAppContainers(
    _In_  DWORD Flags,
    _Out_ DWORD *pdwNumPublicAppCs,
    _Outptr_result_buffer_(*pdwNumPublicAppCs) PINET_FIREWALL_APP_CONTAINER *ppPublicAppCs 
    );

networkisolation.h:

DWORD
WINAPI
NetworkIsolationEnumAppContainers(
    DWORD Flags,
    _Out_ DWORD* pdwNumPublicAppCs,
    _Outptr_result_buffer_(*pdwNumPublicAppCs) PINET_FIREWALL_APP_CONTAINER* ppPublicAppCs
    );

Compiler errors:

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\networkisolation.h(102,1): error C2373: 'NetworkIsolationSetupAppContainerBinaries': redefinition; different type modifiers
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\netfw.h(395): message : see declaration of 'NetworkIsolationSetupAppContainerBinaries'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\networkisolation.h(115,1): error C2373: 'NetworkIsolationRegisterForAppContainerChanges': redefinition; different type modifiers
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\netfw.h(480): message : see declaration of 'NetworkIsolationRegisterForAppContainerChanges'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\networkisolation.h(125,1): error C2373: 'NetworkIsolationUnregisterForAppContainerChanges': redefinition; different type modifiers
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\netfw.h(487): message : see declaration of 'NetworkIsolationUnregisterForAppContainerChanges'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\networkisolation.h(140,1): error C2373: 'NetworkIsolationFreeAppContainers': redefinition; different type modifiers
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\netfw.h(496): message : see declaration of 'NetworkIsolationFreeAppContainers'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\networkisolation.h(147,1): error C2373: 'NetworkIsolationEnumAppContainers': redefinition; different type modifiers
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\netfw.h(501): message : see declaration of 'NetworkIsolationEnumAppContainers'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\networkisolation.h(156,1): error C2373: 'NetworkIsolationGetAppContainerConfig': redefinition; different type modifiers
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\netfw.h(507): message : see declaration of 'NetworkIsolationGetAppContainerConfig'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\networkisolation.h(164,1): error C2373: 'NetworkIsolationSetAppContainerConfig': redefinition; different type modifiers
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\netfw.h(512): message : see declaration of 'NetworkIsolationSetAppContainerConfig'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\networkisolation.h(190,1): error C2373: 'NetworkIsolationDiagnoseConnectFailureAndGetInfo': redefinition; different type modifiers
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\netfw.h(528): message : see declaration of 'NetworkIsolationDiagnoseConnectFailureAndGetInfo'

Linker errors:

1>XXX.obj : error LNK2019: unresolved external symbol _NetworkIsolationFreeAppContainers referenced in function _main
1>XXX.obj : error LNK2019: unresolved external symbol _NetworkIsolationEnumAppContainers referenced in function _main
1>XXX.obj : error LNK2019: unresolved external symbol _NetworkIsolationGetAppContainerConfig referenced in function _main
1>XXX.obj : error LNK2019: unresolved external symbol _NetworkIsolationDiagnoseConnectFailureAndGetInfo referenced in function "void __cdecl CheckNetworkIsolationDiagnoseConnectFailure(wchar_t const *)" (?CheckNetworkIsolationDiagnoseConnectFailure@@YAXPB_W@Z)
1>C:\Users\XXX\source\repos\XXX\Debug\XXX.exe : fatal error LNK1120: 4 unresolved externals

Could you please fix ASAP?

Sincerely yours,
ww898

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,615 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rita Han - MSFT 2,161 Reputation points
    2020-10-27T09:25:38.79+00:00

    Hello @ww898 ,

    Based on the document, include Netfw.h, no need for including networkisolation.h. The following is an example you can refer to.

    #include <Netfw.h>  
      
    typedef DWORD  
    (WINAPI * PFNNETWORKISOLATIONENUMAPPCONTAINERS)(  
    	_In_  DWORD Flags,  
    	_Out_ DWORD* pdwNumPublicAppCs,  
    	_Outptr_result_buffer_(*pdwNumPublicAppCs) PINET_FIREWALL_APP_CONTAINER* ppPublicAppCs  
    );      
    
    	HMODULE hFirewallapiDll = LoadLibrary(L"Firewallapi.dll");  
    	PFNNETWORKISOLATIONENUMAPPCONTAINERS pfnNetworkIsolationEnumAppContainers = (PFNNETWORKISOLATIONENUMAPPCONTAINERS)GetProcAddress(hFirewallapiDll, "NetworkIsolationEnumAppContainers");  
    	DWORD dwNumPublicAppCs;  
    	PINET_FIREWALL_APP_CONTAINER pPublicAppCs;  
    	pfnNetworkIsolationEnumAppContainers(NETISO_FLAG_FORCE_COMPUTE_BINARIES, &dwNumPublicAppCs, &pPublicAppCs);  
    

    Thank you!


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.