uwpinject.c
/* dlls need certain permissions to be visible to uwp processes */
dlls need certain permissions to be visible to uwp processes
dlls need certain permissions to be visible to uwp processes
int uwp_fileperm(wchar_t* file) {
  PACL old_acl = 0;
  PACL new_acl = 0;
  PSECURITY_DESCRIPTOR sd = 0;
  EXPLICIT_ACCESS_W access;
  SECURITY_INFORMATION si = DACL_SECURITY_INFORMATION;
  DWORD res = ERROR_SUCCESS;
  PSID sid;
  res = GetNamedSecurityInfoW(file, SE_FILE_OBJECT,
    DACL_SECURITY_INFORMATION, 0, 0, &old_acl, 0, &sd);
  if (res != ERROR_SUCCESS) {
    win32_perror(res, L"GetNamedSecurityInfoW failed");
    goto cleanup;
  }
  ConvertStringSidToSidW(L"S-1-15-2-1", &sid);
  if (!sid) {
    win32_perror(GetLastError(), L"ConvertStringSidToSid failed");
    goto cleanup;
  }
  ZeroMemory(&access, sizeof(access));
  access.grfAccessPermissions = GENERIC_READ | GENERIC_EXECUTE;
  access.grfAccessMode = SET_ACCESS;
  access.grfInheritance = SUB_CONTAINERS_AND_OBJECTS_INHERIT;
  access.Trustee.TrusteeForm = TRUSTEE_IS_SID;
  access.Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
  access.Trustee.ptstrName = (LPWSTR)sid;
  res = SetEntriesInAclW(1, &access, old_acl, &new_acl);
  if (res != ERROR_SUCCESS) {
    win32_perror(res, L"SetEntriesInAcl failed");
    goto cleanup;
  }
  res = SetNamedSecurityInfoW(file, SE_FILE_OBJECT, si, 0, 0, new_acl, 0);
  if (res != ERROR_SUCCESS) {
    win32_perror(res, L"SetNamedSecurityInfo failed");
    goto cleanup;
  }
cleanup:
  if (sd) {
    LocalFree((HLOCAL)sd);
  }
  if (new_acl) {
    LocalFree((HLOCAL)new_acl);
  }
  return res == ERROR_SUCCESS;
}
int uwp_fileperm ( wchar_t * file ) { PACL old_acl = 0 ; PACL new_acl = 0 ; PSECURITY_DESCRIPTOR sd = 0 ; EXPLICIT_ACCESS_W access ; SECURITY_INFORMATION si = DACL_SECURITY_INFORMATION ; DWORD res = ERROR_SUCCESS ; PSID sid ; res = GetNamedSecurityInfoW ( file , SE_FILE_OBJECT , DACL_SECURITY_INFORMATION , 0 , 0 , & old_acl , 0 , & sd ) ; if ( res != ERROR_SUCCESS ) { win32_perror ( res , L" " ) ; goto cleanup ; } ConvertStringSidToSidW ( L" " , & sid ) ; if ( ! sid ) { win32_perror ( GetLastError ( ) , L" " ) ; goto cleanup ; } ZeroMemory ( & access , sizeof ( access ) ) ; access . grfAccessPermissions = GENERIC_READ | GENERIC_EXECUTE ; access . grfAccessMode = SET_ACCESS ; access . grfInheritance = SUB_CONTAINERS_AND_OBJECTS_INHERIT ; access . Trustee . TrusteeForm = TRUSTEE_IS_SID ; access . Trustee . TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP ; access . Trustee . ptstrName = ( LPWSTR ) sid ; res = SetEntriesInAclW ( 1 , & access , old_acl , & new_acl ) ; if ( res != ERROR_SUCCESS ) { win32_perror ( res , L" " ) ; goto cleanup ; } res = SetNamedSecurityInfoW ( file , SE_FILE_OBJECT , si , 0 , 0 , new_acl , 0 ) ; if ( res != ERROR_SUCCESS ) { win32_perror ( res , L" " ) ; goto cleanup ; } cleanup : if ( sd ) { LocalFree ( ( HLOCAL ) sd ) ; } if ( new_acl ) { LocalFree ( ( HLOCAL ) new_acl ) ; } return res == ERROR_SUCCESS ; }
dlls need certain permissions to be visible to uwp processes
dlls need certain permissions to be visible to uwp processes
/* get current acl */ /* sid for all application packages */ /* merge new ace into old acl */ /* attach new acl */