title: Show UAC prompt before access is denied by IoCreateDeviceSecure function
body: <p>I am adding the access control for a driver (WinPcap's NDIS 6 filter driver) running on Windows 7 and 8. We want to let only administrators (users in Administrators group) to use the driver. So I used the new <strong>IoCreateDeviceSecure</strong> function instead of original <strong>IoCreateDevice</strong> call.</p>
  
  <p>My code is as belows:</p>
  
  <pre><code>UNICODE_STRING sddl = RTL_CONSTANT_STRING(L"D:P(A;;GA;;;SY)(A;;GA;;;BA)");
  const GUID guidClassNPF = { 0x26e0d1e0L, 0x8189, 0x12e0, { 0x99, 0x14, 0x08, 0x00, 0x22, 0x30, 0x19, 0x04 } };
  status = IoCreateDeviceSecure(adriverObjectP, sizeof(DEVICE_EXTENSION), &amp;deviceName, FILE_DEVICE_TRANSPORT,
  FILE_DEVICE_SECURE_OPEN, FALSE, &amp;sddl, (LPCGUID) &amp;guidClassNPF, &amp;devObjP);
  </code></pre>
  
  <p>My SDDL string is <strong>"D:P(A;;GA;;;SY)(A;;GA;;;BA)"</strong> which means <strong>"allows the kernel, system, and administrator complete control over the device. No other users may access the device."</strong> in <a href="https://msdn.microsoft.com/en-us/library/windows/hardware/ff563667(v=vs.85).aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/windows/hardware/ff563667(v=vs.85).aspx</a>. </p>
  
  <p>It seems that only <strong>build-in Administrator account</strong> can directly access my device now. The <strong>other members of Administrators group</strong> will be denied because they don't have an escalated access token based on Windows's <a href="https://technet.microsoft.com/en-us/library/cc772207%28v=ws.10%29.aspx" rel="nofollow">User Account Control</a>. I know that when a user tries to make critical changes for the system, a <strong>UAC prompt</strong> will show up to the user to ask for permissions.</p>
  
  <p>My question is, is there a way that <strong>Windows shows such a prompt when executing my driver's IoCreateDeviceSecure call</strong>, so <strong>if the user agrees with the UAC prompt, the call can succeed</strong>. The currently silent denial is not very friendly for a member in Administrators group to use rights. thanks!</p>
  
  <hr>
  
  <p>More details:</p>
  
  <p>My software is a combination of <strong>some DLLs (wpcap.dll and packet.dll) and a driver (npcap.sys)</strong>. <strong>Other people develop the applications</strong> (like Wireshark and Nmap) to use my DLLs and driver. The invoking path is: EXE -> wpcap.dll -> packet.dll -> npcap.sys. But getting app elevated also has issue. Because other people develop the apps. I'd like to <strong>do the elevating thing in the DLL level</strong>.</p>
  
  <p>I have learnt that an application (EXE) can specify /MANIFESTUAC: highestAvailable in its manifest to enforce an Administrator elevation. I have tried to add  /MANIFESTUAC: highestAvailable option to a DLL too (in VS 2008, by modifying Properties -> Linker -> Manifest File -> UAC Execution Level to highestAvailable), but nothing happened. I doubt if it is meaningful to add such an option to a DLL. <strong>Is there a way for DLL to enforce an Administrator elevation for the process that loads it?</strong> So when an EXE (without /MANIFESTUAC: highestAvailable) loading my DLL (with /MANIFESTUAC: highestAvailable) tries to start, it will be required to be elevated by a UAC prompt?</p>