Changeset 26331 in vbox
- Timestamp:
- Feb 8, 2010 4:17:35 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57415
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl2.cpp
r26313 r26331 156 156 157 157 return S_OK; 158 } 159 160 static int getSmcDeviceKey(IMachine* pMachine, BSTR * aKey) 161 { 162 int rc; 163 164 # if defined(RT_OS_DARWIN) 165 char aKeyBuf[65]; 166 167 rc = DarwinSmcKey(aKeyBuf, sizeof aKeyBuf); 168 if (SUCCEEDED(rc)) 169 { 170 Bstr(aKeyBuf).detachTo(aKey); 171 return rc; 172 } 173 #endif 174 175 return pMachine->GetExtraData(Bstr("VBoxInternal2/SmcDeviceKey"), aKey); 158 176 } 159 177 … … 540 558 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ RC_CHECK(); 541 559 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); RC_CHECK(); 542 rc = pMachine->GetExtraData(Bstr("VBoxInternal2/SmcDeviceKey"), tmpStr2.asOutParam());RC_CHECK();560 rc = getSmcDeviceKey(pMachine, tmpStr2.asOutParam()); RC_CHECK(); 543 561 rc = CFGMR3InsertString(pCfg, "DeviceKey", Utf8Str(tmpStr2).raw());RC_CHECK(); 544 562 } -
trunk/src/VBox/Main/Makefile.kmk
r25946 r26331 588 588 VBoxC_LDFLAGS.darwin = \ 589 589 -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/components/VBoxC.dylib \ 590 -exported_symbols_list $(PATH_VBoxC)/VBoxC.def 590 -exported_symbols_list $(PATH_VBoxC)/VBoxC.def \ 591 -framework IOKit 591 592 ifdef VBOX_USE_VCC80 592 593 VBoxC_LDFLAGS.win = /MANIFEST -
trunk/src/VBox/Main/darwin/iokit.cpp
r25991 r26331 1679 1679 } 1680 1680 1681 int DarwinSmcKey(char* aKey, uint32_t iKeySize) 1682 { 1683 int rc; 1684 /* Based on Amith Singh SMC reading code sample in OS X Book */ 1685 typedef struct { 1686 uint32_t key; 1687 uint8_t __d0[22]; 1688 uint32_t datasize; 1689 uint8_t __d1[10]; 1690 uint8_t cmd; 1691 uint32_t __d2; 1692 uint8_t data[32]; 1693 } AppleSMCBuffer_t; 1694 1695 1696 if (iKeySize < 65) 1697 return VERR_INTERNAL_ERROR; 1698 1699 io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, 1700 IOServiceMatching("AppleSMC")); 1701 if (!service) 1702 return VERR_INTERNAL_ERROR; 1703 1704 io_connect_t port = (io_connect_t)0; 1705 kern_return_t kr = IOServiceOpen(service, mach_task_self(), 0, &port); 1706 IOObjectRelease(service); 1707 if (kr != kIOReturnSuccess) 1708 return VERR_INTERNAL_ERROR; 1709 1710 1711 AppleSMCBuffer_t inputStruct = { 0, {0}, 32, {0}, 5, }, outputStruct; 1712 size_t outputStructCnt = sizeof(outputStruct); 1713 char osk[65]; 1714 1715 for (int i = 0; i < 2; i++) 1716 { 1717 inputStruct.key = (uint32_t)((i == 0) ? 'OSK0' : 'OSK1'); 1718 kr = IOConnectCallStructMethod((mach_port_t)port, 1719 (uint32_t)2, 1720 (const void*)&inputStruct, 1721 sizeof(inputStruct), 1722 (void*)&outputStruct, 1723 &outputStructCnt); 1724 if (kr != kIOReturnSuccess) 1725 return VERR_INTERNAL_ERROR; 1726 1727 for (int j=0; j<32; j++) 1728 aKey[j + i*32] = outputStruct.data[j]; 1729 } 1730 1731 aKey[64] = 0; 1732 1733 return rc; 1734 } 1735 1681 1736 #ifdef STANDALONE_TESTCASE 1682 1737 /** … … 1796 1851 } 1797 1852 #endif 1798 1799 -
trunk/src/VBox/Main/darwin/iokit.h
r23134 r26331 87 87 PDARWINDVD DarwinGetDVDDrives(void); 88 88 PDARWINETHERNIC DarwinGetEthernetControllers(void); 89 int DarwinSmcKey(char* aKey, uint32_t iKeySize); 89 90 RT_C_DECLS_END 90 91 91 92 #endif 92
Note:
See TracChangeset
for help on using the changeset viewer.