mach_kernel-r0drv-darwin.cpp revision 2c4363d85aea1af6eb54340ba34fe0013895214b
c79e39ad568d9af854765f64049534044ef6c034nd * IPRT - mach_kernel symbol resolving hack, R0 Driver, Darwin.
c79e39ad568d9af854765f64049534044ef6c034nd * Copyright (C) 2011 Oracle Corporation
c79e39ad568d9af854765f64049534044ef6c034nd * This file is part of VirtualBox Open Source Edition (OSE), as
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * available from http://www.virtualbox.org. This file is free software;
c79e39ad568d9af854765f64049534044ef6c034nd * you can redistribute it and/or modify it under the terms of the GNU
c79e39ad568d9af854765f64049534044ef6c034nd * General Public License (GPL) as published by the Free Software
#ifdef IN_RING0
# include "the-darwin-kernel.h"
#include "../../include/internal/ldrMach-O.h"
#ifdef RT_ARCH_X86
#ifdef DEBUG
# define RETURN_VERR_BAD_EXE_FORMAT \
# define RETURN_VERR_LDR_UNEXPECTED \
# define RETURN_VERR_LDR_ARCH_MISMATCH \
typedef struct RTR0DARWINKERNEL
char *pachStrTab;
#ifdef DEBUG
static bool g_fBreakpointOnError = true;
const char *pszName;
} const s_aStandardCandles[] =
#ifdef IN_RING0
if (uAddr == 0)
AssertLogRelMsgFailed(("%s (%p != %p)\n", s_aStandardCandles[i].pszName, uAddr, s_aStandardCandles[i].uAddr));
return VERR_INTERNAL_ERROR_2;
return VINF_SUCCESS;
return VERR_NO_MEMORY;
return rc;
return VERR_NO_MEMORY;
return rc;
#ifdef IN_RING3
RTAssertMsg2("%05i: %02x:%08x %02x %04x %s\n", iSym, pSym->n_sect, pSym->n_value, pSym->n_type, pSym->n_desc, pszSym);
case MACHO_N_SECT:
case MACHO_N_ABS:
case MACHO_N_UNDF:
case MACHO_N_INDR:
case MACHO_N_PBUD:
return VINF_SUCCESS;
return VERR_NO_MEMORY;
return rc;
case LC_SYMTAB:
case LC_SEGMENT_32:
case LC_SEGMENT_64:
case S_REGULAR:
case S_CSTRING_LITERALS:
case S_MOD_INIT_FUNC_POINTERS:
case S_MOD_TERM_FUNC_POINTERS:
case S_COALESCED:
case S_ZEROFILL:
case S_SYMBOL_STUBS:
case S_INTERPOSING:
case S_4BYTE_LITERALS:
case S_8BYTE_LITERALS:
case S_16BYTE_LITERALS:
case S_DTRACE_DOF:
case S_LAZY_SYMBOL_POINTERS:
case S_GB_ZEROFILL:
case LC_UUID:
case LC_DYSYMTAB:
case LC_UNIXTHREAD:
case LC_SYMSEG:
case LC_SEGMENT_64:
case LC_SEGMENT_32:
case LC_ROUTINES_64:
case LC_ROUTINES:
case LC_THREAD:
case LC_LOADFVMLIB:
case LC_IDFVMLIB:
case LC_IDENT:
case LC_FVMFILE:
case LC_PREPAGE:
case LC_TWOLEVEL_HINTS:
case LC_PREBIND_CKSUM:
case LC_LOAD_DYLIB:
case LC_ID_DYLIB:
case LC_LOAD_DYLINKER:
case LC_ID_DYLINKER:
case LC_PREBOUND_DYLIB:
case LC_SUB_FRAMEWORK:
case LC_SUB_UMBRELLA:
case LC_SUB_CLIENT:
case LC_SUB_LIBRARY:
return VINF_SUCCESS;
uint32_t i;
int rc = RTFileReadAt(pKernel->hFile, 0, pKernel->abBuf, sizeof(fat_header_t) + sizeof(fat_arch_t) * 16, NULL);
return rc;
return rc;
return VINF_SUCCESS;
if (!pKernel)
return VERR_NO_MEMORY;
int rc = RTFileOpen(&pKernel->hFile, pszMachKernel, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
return rc;