Changeset 26331 in vbox for trunk/src/VBox/Main/darwin/iokit.cpp
- Timestamp:
- Feb 8, 2010 4:17:35 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.