Changeset 102754 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jan 3, 2024 5:49:16 PM (13 months ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp
r102753 r102754 63 63 * Structures and Typedefs * 64 64 *********************************************************************************************************************************/ 65 /* advapi32.dll: */ 66 typedef BOOL (WINAPI *PFNCONVERTSIDTOSTRINGSIDW)(PSID, LPWSTR *); 67 68 /* advapi32.dll: */ 69 static PFNCONVERTSIDTOSTRINGSIDW g_pfnConvertSidToStringSidW = NULL; 70 65 71 /** Structure for storing the looked up user information. */ 66 72 typedef struct VBOXSERVICEVMINFOUSER … … 221 227 } 222 228 RTLdrClose(hLdrMod); 229 230 /* advapi32: */ 231 rc = RTLdrLoadSystem("advapi32.dll", true /*fNoUnload*/, &hLdrMod); 232 if (RT_SUCCESS(rc)) 233 RTLdrGetSymbol(hLdrMod, "ConvertSidToStringSidW", (void **)&g_pfnConvertSidToStringSidW); 223 234 224 235 return VINF_SUCCESS; … … 1026 1037 * @param pszUser Name of guest user to update. 1027 1038 * @param pszDomain Domain of guest user to update. Optional. 1039 * @param pwszSid The user's SID as a string. Might be NULL if not supported (NT4). 1028 1040 * @param pszKey Key name of guest property to update. 1029 1041 * @param pszValueFormat Guest property value to set. Pass NULL for deleting … … 1035 1047 { 1036 1048 int rc = VGSvcUserUpdateF(pCache, pszUser, NULL /* pszDomain */, "Domain", pszDomain); 1037 if ( RT_SUCCESS(rc))1049 if (pwszSid && RT_SUCCESS(rc)) 1038 1050 rc = VGSvcUserUpdateF(pCache, pszUser, NULL /* pszDomain */, "SID", "%ls", pwszSid); 1039 1051 … … 1082 1094 if (RT_SUCCESS(rc)) 1083 1095 { 1084 WCHAR *pwszSid; 1085 if (ConvertSidToStringSidW(pSid, &pwszSid)) /** @todo Ditto. */ 1096 WCHAR *pwszSid = NULL; 1097 if (g_pfnConvertSidToStringSidW) 1098 g_pfnConvertSidToStringSidW(pSid, &pwszSid); /** @todo Ditto. */ 1099 1100 rc = vgsvcVMInfoWinUserUpdateFallbackV(pCache, pszUser, pszDomain, pwszSid, pszKey, pszValueFormat, va); 1101 if (RT_FAILURE(rc)) 1086 1102 { 1087 rc = vgsvcVMInfoWinUserUpdateFallbackV(pCache, pszUser, pszDomain, pwszSid, pszKey, pszValueFormat, va); 1088 if (RT_FAILURE(rc)) 1103 /** 1104 * If using the sole user name as a property name still is too long or something else failed, 1105 * at least try to look up the user's RID (relative identifier). Note that the RID always is bound to the 1106 * to the authority that issued the SID. 1107 */ 1108 int const cSubAuth = *GetSidSubAuthorityCount(pSid); 1109 if (cSubAuth > 1) 1089 1110 { 1090 /** 1091 * If using the sole user name as a property name still is too long or something else failed, 1092 * at least try to look up the user's RID (relative identifier). Note that the RID always is bound to the 1093 * to the authority that issued the SID. 1094 */ 1095 int const cSubAuth = *GetSidSubAuthorityCount(pSid); 1096 if (cSubAuth > 1) 1097 { 1098 DWORD const dwUserRid = *GetSidSubAuthority(pSid, cSubAuth - 1); 1099 char szUserRid[16 + 1]; 1100 if (RTStrPrintf2(szUserRid, sizeof(szUserRid), "%ld", dwUserRid) > 0) 1101 rc = vgsvcVMInfoWinUserUpdateFallbackV(pCache, szUserRid, pszDomain, pwszSid, pszKey, 1102 pszValueFormat, va); 1103 else 1104 rc = VERR_BUFFER_OVERFLOW; 1105 } 1106 /* else not much else we can do then. */ 1111 DWORD const dwUserRid = *GetSidSubAuthority(pSid, cSubAuth - 1); 1112 char szUserRid[16 + 1]; 1113 if (RTStrPrintf2(szUserRid, sizeof(szUserRid), "%ld", dwUserRid) > 0) 1114 rc = vgsvcVMInfoWinUserUpdateFallbackV(pCache, szUserRid, pszDomain, pwszSid, pszKey, 1115 pszValueFormat, va); 1116 else 1117 rc = VERR_BUFFER_OVERFLOW; 1107 1118 } 1108 1119 /* else not much else we can do then. */ 1120 } 1121 1122 if (pwszSid) 1123 { 1109 1124 LocalFree(pwszSid); 1110 1125 pwszSid = NULL; 1111 1126 } 1112 else1113 rc = RTErrConvertFromWin32(GetLastError());1114 1127 1115 1128 vgsvcVMInfoWinUserSidDestroy(pSid); -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.h
r102753 r102754 38 38 const char *pszKey, const char *pszFormat, va_list va); 39 39 40 extern int vgsvcVMInfoWinUserUpdateF(PVBOXSERVICEVEPROPCACHE pCache, const char *pszUser, const char *pszDomain,41 const char *pszKey, const char *pszValueFormat, ...);42 43 40 extern uint32_t g_uVMInfoUserIdleThresholdMS; 44 41
Note:
See TracChangeset
for help on using the changeset viewer.