Changeset 70067 in vbox
- Timestamp:
- Dec 11, 2017 5:25:15 PM (7 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxGuest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r70066 r70067 1132 1132 1133 1133 /** 1134 * Implements RTL_QUERY_REGISTRY_ROUTINE for enumerating our registry key. 1135 */ 1136 static NTSTATUS NTAPI vbdrvNtRegistryEnumCallback(PWSTR pwszValueName, ULONG uValueType, 1137 PVOID pvValue, ULONG cbValue, PVOID pvUser, PVOID pvEntryCtx) 1138 { 1139 /* 1140 * Filter out general service config values. 1141 */ 1142 if ( RTUtf16ICmpAscii(pwszValueName, "Type") == 0 1143 || RTUtf16ICmpAscii(pwszValueName, "Start") == 0 1144 || RTUtf16ICmpAscii(pwszValueName, "ErrorControl") == 0 1145 || RTUtf16ICmpAscii(pwszValueName, "Tag") == 0 1146 || RTUtf16ICmpAscii(pwszValueName, "ImagePath") == 0 1147 || RTUtf16ICmpAscii(pwszValueName, "DisplayName") == 0 1148 || RTUtf16ICmpAscii(pwszValueName, "Group") == 0 1149 ) 1150 { 1151 return STATUS_SUCCESS; 1152 } 1153 1154 /* 1155 * Convert the value name. 1156 */ 1157 size_t cch = RTUtf16CalcUtf8Len(pwszValueName); 1158 if (cch < 64 && cch > 0) 1159 { 1160 char szValueName[72]; 1161 char *pszTmp = szValueName; 1162 int rc = RTUtf16ToUtf8Ex(pwszValueName, RTSTR_MAX, &pszTmp, sizeof(szValueName), NULL); 1163 if (RT_SUCCESS(rc)) 1164 { 1165 /* 1166 * Convert the value. 1167 */ 1168 char szValue[72]; 1169 char *pszFree = NULL; 1170 char *pszValue = NULL; 1171 szValue[0] = '\0'; 1172 switch (uValueType) 1173 { 1174 case REG_SZ: 1175 case REG_EXPAND_SZ: 1176 rc = RTUtf16CalcUtf8LenEx((PCRTUTF16)pvValue, cbValue / sizeof(RTUTF16), &cch); 1177 if (RT_SUCCESS(rc) && cch < _1K) 1178 { 1179 if (cch < sizeof(szValue)) 1180 { 1181 pszValue = szValue; 1182 rc = RTUtf16ToUtf8Ex((PCRTUTF16)pvValue, cbValue / sizeof(RTUTF16), &pszValue, sizeof(szValue), NULL); 1183 } 1184 else 1185 { 1186 rc = RTUtf16ToUtf8Ex((PCRTUTF16)pvValue, cbValue / sizeof(RTUTF16), &pszValue, sizeof(szValue), NULL); 1187 if (RT_SUCCESS(rc)) 1188 pszFree = pszValue; 1189 } 1190 if (RT_FAILURE(rc)) 1191 { 1192 LogRel(("VBoxGuest: Failed to convert registry value '%ls' string data to UTF-8: %Rrc\n", 1193 pwszValueName, rc)); 1194 pszValue = NULL; 1195 } 1196 } 1197 else if (RT_SUCCESS(rc)) 1198 LogRel(("VBoxGuest: Registry value '%ls' has a too long value: %#x (uvalueType=%#x)\n", 1199 pwszValueName, cbValue, uValueType)); 1200 else 1201 LogRel(("VBoxGuest: Registry value '%ls' has an invalid string value (cbValue=%#x, uvalueType=%#x)\n", 1202 pwszValueName, cbValue, uValueType)); 1203 break; 1204 1205 case REG_DWORD: 1206 if (cbValue == sizeof(uint32_t)) 1207 { 1208 RTStrFormatU32(szValue, sizeof(szValue), *(uint32_t const *)pvValue, 10, 0, 0, 0); 1209 pszValue = szValue; 1210 } 1211 else 1212 LogRel(("VBoxGuest: Registry value '%ls' has wrong length for REG_DWORD: %#x\n", pwszValueName, cbValue)); 1213 break; 1214 1215 case REG_QWORD: 1216 if (cbValue == sizeof(uint64_t)) 1217 { 1218 RTStrFormatU32(szValue, sizeof(szValue), *(uint32_t const *)pvValue, 10, 0, 0, 0); 1219 pszValue = szValue; 1220 } 1221 else 1222 LogRel(("VBoxGuest: Registry value '%ls' has wrong length for REG_DWORD: %#x\n", pwszValueName, cbValue)); 1223 break; 1224 1225 default: 1226 LogRel(("VBoxGuest: Ignoring registry value '%ls': Unsupported type %#x\n", pwszValueName, uValueType)); 1227 break; 1228 } 1229 if (pszValue) 1230 { 1231 /* 1232 * Process it. 1233 */ 1234 PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pvUser; 1235 VGDrvCommonProcessOption(pDevExt, szValueName, pszValue); 1236 if (pszFree) 1237 RTStrFree(pszFree); 1238 } 1239 } 1240 } 1241 else if (cch > 0) 1242 LogRel(("VBoxGuest: Ignoring registery value '%ls': name too long\n", pwszValueName)); 1243 else 1244 LogRel(("VBoxGuest: Ignoring registery value with bad name\n", pwszValueName)); 1245 NOREF(pvEntryCtx); 1246 return STATUS_SUCCESS; 1247 } 1248 1249 1250 /** 1134 1251 * Reads configuration from the registry and guest properties. 1135 1252 * … … 1145 1262 * First the registry. 1146 1263 */ 1147 ULONG uValue = 0; 1148 NTSTATUS rcNt = vgdrvNtRegistryReadDWORD(RTL_REGISTRY_SERVICES, L"VBoxGuest", L"LoggingEnabled", &uValue); 1149 if (NT_SUCCESS(rcNt)) 1150 { 1151 pDevExt->Core.fLoggingEnabled = uValue >= 0xFF; 1152 if (pDevExt->Core.fLoggingEnabled) 1153 LogRelFunc(("Logging to host log enabled (%#x)", uValue)); 1154 } 1264 RTL_QUERY_REGISTRY_TABLE aQuery[2]; 1265 RT_ZERO(aQuery); 1266 aQuery[0].QueryRoutine = vbdrvNtRegistryEnumCallback; 1267 aQuery[0].Flags = 0; 1268 aQuery[0].Name = NULL; 1269 aQuery[0].EntryContext = NULL; 1270 aQuery[0].DefaultType = REG_NONE; 1271 NTSTATUS rcNt = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES, L"VBoxGuest", &aQuery[0], pDevExt, NULL /* Environment */); 1272 if (!NT_SUCCESS(rcNt)) 1273 LogRel(("VBoxGuest: RtlQueryRegistryValues failed: %#x\n", rcNt)); 1155 1274 1156 1275 /* -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r70066 r70067 1182 1182 void VGDrvCommonProcessOption(PVBOXGUESTDEVEXT pDevExt, const char *pszName, const char *pszValue) 1183 1183 { 1184 if (strcmp(pszName, "r3_log_to_host") == 0) 1184 Log(("VGDrvCommonProcessOption: pszName='%s' pszValue='%s'\n", pszName, pszValue)); 1185 1186 if ( strcmp(pszName, "r3_log_to_host") == 0 1187 || strcmp(pszName, "LoggingEnabled") == 0 /*legacy*/ ) 1185 1188 pDevExt->fLoggingEnabled = VBDrvCommonIsOptionValueTrue(pszValue); 1186 1189 else if (VGDrvNativeProcessOption(pDevExt, pszName, pszValue))
Note:
See TracChangeset
for help on using the changeset viewer.