This will take care of orphaned applications that are assigned to 'Base Profile', and will add the invariant AppX package family name to the profile in order to have a valid driver profile for Microsoft Store games. The orphaned application profile issue is currently only auto-resolved for Microsoft Store games.
| 1780 | // The orphaned application profile issue is currently only auto-resolved |
| 1781 | // for Microsoft Store games. |
| 1782 | void |
| 1783 | SK_NvAPI_AddMicrosoftStoreAppToProfile (NvDRSProfileHandle hProfile, NvDRSSessionHandle hSession) |
| 1784 | { |
| 1785 | NVDRS_APPLICATION app = { }; |
| 1786 | app.version = NVDRS_APPLICATION_VER; |
| 1787 | |
| 1788 | auto appx_package_family = |
| 1789 | SK_AppX_GetCurrentPackageFamilyName (); |
| 1790 | |
| 1791 | if (! appx_package_family.has_value ()) |
| 1792 | return; |
| 1793 | |
| 1794 | const wchar_t* name = appx_package_family.value (); |
| 1795 | |
| 1796 | NvDRSProfileHandle hProfileTest; |
| 1797 | |
| 1798 | auto ret = |
| 1799 | NvAPI_DRS_FindApplicationByName ( hSession, |
| 1800 | (NvU16 *)name, |
| 1801 | &hProfileTest, |
| 1802 | &app ); |
| 1803 | |
| 1804 | NVDRS_PROFILE profile_info = {}; |
| 1805 | profile_info.version = NVDRS_PROFILE_VER; |
| 1806 | |
| 1807 | NvAPI_DRS_GetProfileInfo (hSession, hProfileTest, &profile_info); |
| 1808 | |
| 1809 | // Remove the app from "Base Profile" if necessary, because it's not possible to configure that. |
| 1810 | if (ret == NVAPI_OK && _wcsicmp ((const wchar_t *)profile_info.profileName, L"Base Profile") == 0) |
| 1811 | { |
| 1812 | ret = NVAPI_EXECUTABLE_NOT_FOUND; |
| 1813 | |
| 1814 | NvAPI_DRS_DeleteApplication (hSession, hProfileTest, (NvU16 *)name); |
| 1815 | |
| 1816 | NVDRS_PROFILE custom_profile = {}; |
| 1817 | |
| 1818 | if (friendly_name.empty ()) // Avoid NVAPI failure: NVAPI_PROFILE_NAME_EMPTY |
| 1819 | friendly_name = app_name; |
| 1820 | |
| 1821 | custom_profile.isPredefined = FALSE; |
| 1822 | |
| 1823 | lstrcpyW ((wchar_t *)custom_profile.profileName, friendly_name.c_str ()); |
| 1824 | |
| 1825 | custom_profile.version = NVDRS_PROFILE_VER; |
| 1826 | |
| 1827 | NvAPI_DRS_CreateProfile (hSession, &custom_profile, &hProfile); |
| 1828 | NvAPI_DRS_GetProfileInfo (hSession, hProfile, &profile_info); |
| 1829 | |
| 1830 | SK_LOGi0 ( |
| 1831 | L"Application removed from 'Base Profile' and added to %ws", friendly_name.c_str () |
| 1832 | ); |
| 1833 | } |
| 1834 | |
| 1835 | SK_LOGi1 (L"FindApplicationByName [%ws, in %ws]: %d", name, profile_info.profileName, ret); |
| 1836 | |
| 1837 | if (ret == NVAPI_EXECUTABLE_NOT_FOUND) |
| 1838 | { |
| 1839 | SK_LOGi1 (L" ? Adding Microsoft Store App to NVAPI Profile: %ws", name); |
no test coverage detected