Changeset 55362 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Apr 21, 2015 5:28:50 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r55314 r55362 132 132 133 133 134 135 #if defined(RT_OS_DARWIN)136 137 static int DarwinSmcKey(char *pabKey, uint32_t cbKey)138 {139 /*140 * Method as described in Amit Singh's article:141 * http://osxbook.com/book/bonus/chapter7/tpmdrmmyth/142 */143 typedef struct144 {145 uint32_t key;146 uint8_t pad0[22];147 uint32_t datasize;148 uint8_t pad1[10];149 uint8_t cmd;150 uint32_t pad2;151 uint8_t data[32];152 } AppleSMCBuffer;153 154 AssertReturn(cbKey >= 65, VERR_INTERNAL_ERROR);155 156 io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault,157 IOServiceMatching("AppleSMC"));158 if (!service)159 return VERR_NOT_FOUND;160 161 io_connect_t port = (io_connect_t)0;162 kern_return_t kr = IOServiceOpen(service, mach_task_self(), 0, &port);163 IOObjectRelease(service);164 165 if (kr != kIOReturnSuccess)166 return RTErrConvertFromDarwin(kr);167 168 AppleSMCBuffer inputStruct = { 0, {0}, 32, {0}, 5, };169 AppleSMCBuffer outputStruct;170 size_t cbOutputStruct = sizeof(outputStruct);171 172 for (int i = 0; i < 2; i++)173 {174 inputStruct.key = (uint32_t)(i == 0 ? 'OSK0' : 'OSK1');175 kr = IOConnectCallStructMethod((mach_port_t)port,176 (uint32_t)2,177 (const void *)&inputStruct,178 sizeof(inputStruct),179 (void *)&outputStruct,180 &cbOutputStruct);181 if (kr != kIOReturnSuccess)182 {183 IOServiceClose(port);184 return RTErrConvertFromDarwin(kr);185 }186 187 for (int j = 0; j < 32; j++)188 pabKey[j + i*32] = outputStruct.data[j];189 }190 191 IOServiceClose(port);192 193 pabKey[64] = 0;194 195 return VINF_SUCCESS;196 }197 198 #endif /* RT_OS_DARWIN */199 200 134 /* Darwin compile kludge */ 201 135 #undef PVM … … 273 207 274 208 #ifdef RT_OS_DARWIN 209 275 210 /* 276 * Query it here and now.211 * Work done in EFI/DevSmc 277 212 */ 278 char abKeyBuf[65]; 279 int rc = DarwinSmcKey(abKeyBuf, sizeof(abKeyBuf)); 280 if (SUCCEEDED(rc)) 281 { 282 *pStrKey = abKeyBuf; 283 *pfGetKeyFromRealSMC = true; 284 return rc; 285 } 286 LogRel(("Warning: DarwinSmcKey failed with rc=%Rrc!\n", rc)); 213 *pfGetKeyFromRealSMC = true; 214 int rc = VINF_SUCCESS; 287 215 288 216 #else … … 1596 1524 AssertRCReturn(rc, rc); 1597 1525 1598 InsertConfigString(pCfg, "DeviceKey", strKey); 1526 if (!fGetKeyFromRealSMC) 1527 InsertConfigString(pCfg, "DeviceKey", strKey); 1599 1528 InsertConfigInteger(pCfg, "GetKeyFromRealSMC", fGetKeyFromRealSMC); 1600 1529 }
Note:
See TracChangeset
for help on using the changeset viewer.