#include #include #include #include #include #include "Shared.h" void printMsgBuffer(io_service_t service) { kern_return_t ret; io_connect_t connect = 0; vm_address_t address; vm_size_t size; ret = IOServiceOpen(service, mach_task_self(), 0, &connect); if (ret != KERN_SUCCESS) { printf("error: IOServiceOpen returned 0x%08x\n", ret); goto failure; } ret = IOConnectMapMemory(connect, kVoodooHDAMemoryMessageBuffer, mach_task_self(), &address, &size, kIOMapAnywhere | kIOMapDefaultCache); if (ret != kIOReturnSuccess) { printf("error: IOConnectMapMemory returned 0x%08x\n", ret); goto failure; } printf("%s\n", (char *) address); failure: if (connect) { ret = IOServiceClose(connect); if (ret != KERN_SUCCESS) printf("warning: IOServiceClose returned 0x%08x\n", ret); } } int main() { mach_port_t masterPort; io_iterator_t iter; io_service_t service = 0; kern_return_t ret; io_string_t path; ret = IOMasterPort(MACH_PORT_NULL, &masterPort); if (ret != KERN_SUCCESS) { printf("error: IOMasterPort returned 0x%08x\n", ret); goto failure; } ret = IOServiceGetMatchingServices(masterPort, IOServiceMatching(kVoodooHDAClassName), &iter); if (ret != KERN_SUCCESS) { printf("error: IOServiceGetMatchingServices returned 0x%08x\n", ret); goto failure; } service = IOIteratorNext(iter); IOObjectRelease(iter); ret = IORegistryEntryGetPath(service, kIOServicePlane, path); if (ret != KERN_SUCCESS) { printf("error: IORegistryEntryGetPath returned 0x%08x\n", ret); goto failure; } printf("Found a device of class "kVoodooHDAClassName": %s\n\n", path); printMsgBuffer(service); failure: if (service) IOObjectRelease(service); return 0; }