VirtualBox

Changeset 26332 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Feb 8, 2010 4:58:53 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57417
Message:

burn fix

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r26331 r26332  
    107107#include <VBox/param.h>
    108108#include <VBox/pdmapi.h> /* For PDMR3DriverAttach/PDMR3DriverDetach */
     109
     110#if defined(RT_OS_DARWIN)
     111
     112# include "IOKit/IOKitLib.h"
     113
     114int DarwinSmcKey(char* aKey, uint32_t iKeySize)
     115{
     116    int rc;
     117    /* Based on Amith Singh SMC reading code sample in OS X Book */
     118    typedef struct {
     119        uint32_t   key;
     120        uint8_t    __d0[22];
     121        uint32_t   datasize;
     122        uint8_t    __d1[10];
     123        uint8_t    cmd;
     124        uint32_t   __d2;
     125        uint8_t    data[32];
     126    } AppleSMCBuffer_t;
     127
     128
     129    if (iKeySize < 65)
     130        return VERR_INTERNAL_ERROR;
     131
     132    io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault,
     133                                                       IOServiceMatching("AppleSMC"));
     134    if (!service)
     135        return VERR_INTERNAL_ERROR;
     136
     137    io_connect_t port = (io_connect_t)0;
     138    kern_return_t kr = IOServiceOpen(service, mach_task_self(), 0, &port);
     139    IOObjectRelease(service);
     140    if (kr != kIOReturnSuccess)
     141        return VERR_INTERNAL_ERROR;
     142
     143
     144    AppleSMCBuffer_t inputStruct = { 0, {0}, 32, {0}, 5, }, outputStruct;
     145    size_t outputStructCnt = sizeof(outputStruct);
     146
     147    for (int i = 0; i < 2; i++)
     148    {
     149        inputStruct.key = (uint32_t)((i == 0) ? 'OSK0' : 'OSK1');
     150        kr = IOConnectCallStructMethod((mach_port_t)port,
     151                                       (uint32_t)2,
     152                                       (const void*)&inputStruct,
     153                                       sizeof(inputStruct),
     154                                       (void*)&outputStruct,
     155                                       &outputStructCnt);
     156        if (kr != kIOReturnSuccess)
     157            return VERR_INTERNAL_ERROR;
     158
     159        for (int j=0; j<32; j++)
     160            aKey[j + i*32] = outputStruct.data[j];
     161    }
     162
     163    aKey[64] = 0;
     164   
     165    //fprintf(stderr, "osk=%s\n", aKey)
     166
     167    return rc;
     168}
     169
     170#endif
    109171
    110172#undef PVM
  • trunk/src/VBox/Main/darwin/iokit.cpp

    r26331 r26332  
    16791679}
    16801680
    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 
    17361681#ifdef STANDALONE_TESTCASE
    17371682/**
  • trunk/src/VBox/Main/darwin/iokit.h

    r26331 r26332  
    8787PDARWINDVD      DarwinGetDVDDrives(void);
    8888PDARWINETHERNIC DarwinGetEthernetControllers(void);
    89 int             DarwinSmcKey(char* aKey, uint32_t iKeySize);
    9089RT_C_DECLS_END
    9190
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette