I have a minifilter driver and want to connect it with FilterConnectCommunicationPort. It works well in wpf, but it returns E_ACCESSDENIED in UWP even after I add SECURITY_ATTRIBUTES.
SECURITY_ATTRIBUTES sa;
PSECURITY_DESCRIPTOR SecurityDescriptor;
bool ret = ConvertStringSecurityDescriptorToSecurityDescriptorW(
L"D:P(A;;GA;;;WD)(A;;GA;;;AC)(A;;GA;;;S-1-15-2-2)S:(ML;;;;;LW)",
SDDL_REVISION, &SecurityDescriptor, 0);
// Initialize a security attributes structure.
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = SecurityDescriptor;
sa.bInheritHandle = FALSE;
HRESULT hResult = S_OK;
hResult = FilterConnectCommunicationPort(NPMINI_PORT_NAME, 0, NULL, 0, &sa, &g_hPort);
if (IS_ERROR(hResult))
{
LogError("FilterConnectCommunicationPort fail! 0x%x",hResult);
return hResult;
}
I modify app package manifest to declare some restricted capabilities. Still not work.
<rescap:Capability Name="interopServices"/>
<iot:Capability Name="lowLevelDevices"/>
I am not sure whether FilterConnectCommunicationPort is allowed in UWP.If the api is ok, how to work with it? Thanks.
You don't need those capabilities.
interopServicesis a hold-out from the Windows Phone days, andlowLevelDevicesonly works on actual IOT (embedded-mode) OSes.Adding the right ACE can be done with a function like this - just pass in the handle to your object, the PFN of the target app, and the desired access rights. (This hard-codes
SE_KERNEL_OBJECTfor simplicity; you might need to use a different object type depending on your needs).