OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
CxxSymbols.c File Reference
#include <Uefi.h>
#include <IndustryStandard/AppleMachoImage.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BaseOverflowLib.h>
#include <Library/DebugLib.h>
#include <Library/OcMachoLib.h>
#include <Library/OcStringLib.h>

Go to the source code of this file.

Macros

#define CXX_PREFIX   "__Z"
 
#define VTABLE_PREFIX   CXX_PREFIX "TV"
 
#define OSOBJ_PREFIX   CXX_PREFIX "N"
 
#define RESERVED_TOKEN   "_RESERVED"
 
#define METACLASS_TOKEN   "10gMetaClassE"
 
#define SMCP_TOKEN   "10superClassE"
 
#define METACLASS_VTABLE_PREFIX   VTABLE_PREFIX "N"
 
#define METACLASS_VTABLE_SUFFIX   "9MetaClassE"
 
#define CXX_PURE_VIRTUAL   "___cxa_pure_virtual"
 
#define FINAL_CLASS_TOKEN   "14__OSFinalClassEv"
 
#define VTABLE_ENTRY_SIZE_64   8U
 
#define VTABLE_HEADER_LEN_64   2U
 
#define VTABLE_HEADER_SIZE_64   (VTABLE_HEADER_LEN_64 * VTABLE_ENTRY_SIZE_64)
 

Functions

BOOLEAN MachoSymbolNameIsPureVirtual (IN CONST CHAR8 *Name)
 
BOOLEAN MachoSymbolNameIsPadslot (IN CONST CHAR8 *Name)
 
BOOLEAN MachoSymbolNameIsSmcp (IN OUT OC_MACHO_CONTEXT *Context, IN CONST CHAR8 *SymbolName)
 
BOOLEAN MachoSymbolNameIsMetaclassPointer (IN OUT OC_MACHO_CONTEXT *Context, IN CONST CHAR8 *SymbolName)
 
BOOLEAN MachoGetClassNameFromSuperMetaClassPointer (IN OUT OC_MACHO_CONTEXT *Context, IN CONST CHAR8 *SmcpName, IN UINTN ClassNameSize, OUT CHAR8 *ClassName)
 
CONST CHAR8 * MachoGetClassNameFromVtableName (IN CONST CHAR8 *VtableName)
 
BOOLEAN MachoGetFunctionPrefixFromClassName (IN CONST CHAR8 *ClassName, IN UINTN FunctionPrefixSize, OUT CHAR8 *FunctionPrefix)
 
BOOLEAN MachoGetClassNameFromMetaClassPointer (IN OUT OC_MACHO_CONTEXT *Context, IN CONST CHAR8 *MetaClassName, IN UINTN ClassNameSize, OUT CHAR8 *ClassName)
 
BOOLEAN MachoGetVtableNameFromClassName (IN CONST CHAR8 *ClassName, IN UINTN VtableNameSize, OUT CHAR8 *VtableName)
 
BOOLEAN MachoGetMetaVtableNameFromClassName (IN CONST CHAR8 *ClassName, IN UINTN VtableNameSize, OUT CHAR8 *VtableName)
 
BOOLEAN MachoGetFinalSymbolNameFromClassName (IN CONST CHAR8 *ClassName, IN UINTN FinalSymbolNameSize, OUT CHAR8 *FinalSymbolName)
 
BOOLEAN MachoSymbolNameIsVtable (IN CONST CHAR8 *SymbolName)
 
BOOLEAN MachoSymbolNameIsCxx (IN CONST CHAR8 *Name)
 
MACH_NLIST_ANYMachoGetMetaclassSymbolFromSmcpSymbol (IN OUT OC_MACHO_CONTEXT *Context, IN CONST MACH_NLIST_ANY *Smcp)
 
BOOLEAN MachoGetVtableSymbolsFromSmcp (IN OUT OC_MACHO_CONTEXT *Context, IN CONST CHAR8 *SmcpName, OUT CONST MACH_NLIST_ANY **Vtable, OUT CONST MACH_NLIST_ANY **MetaVtable)
 

Detailed Description

Provides services for C++ symbols.

Copyright (c) 2018, Download-Fritz. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php.

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file CxxSymbols.c.

Macro Definition Documentation

◆ CXX_PREFIX

#define CXX_PREFIX   "__Z"

Definition at line 26 of file CxxSymbols.c.

◆ CXX_PURE_VIRTUAL

#define CXX_PURE_VIRTUAL   "___cxa_pure_virtual"

Definition at line 34 of file CxxSymbols.c.

◆ FINAL_CLASS_TOKEN

#define FINAL_CLASS_TOKEN   "14__OSFinalClassEv"

Definition at line 35 of file CxxSymbols.c.

◆ METACLASS_TOKEN

#define METACLASS_TOKEN   "10gMetaClassE"

Definition at line 30 of file CxxSymbols.c.

◆ METACLASS_VTABLE_PREFIX

#define METACLASS_VTABLE_PREFIX   VTABLE_PREFIX "N"

Definition at line 32 of file CxxSymbols.c.

◆ METACLASS_VTABLE_SUFFIX

#define METACLASS_VTABLE_SUFFIX   "9MetaClassE"

Definition at line 33 of file CxxSymbols.c.

◆ OSOBJ_PREFIX

#define OSOBJ_PREFIX   CXX_PREFIX "N"

Definition at line 28 of file CxxSymbols.c.

◆ RESERVED_TOKEN

#define RESERVED_TOKEN   "_RESERVED"

Definition at line 29 of file CxxSymbols.c.

◆ SMCP_TOKEN

#define SMCP_TOKEN   "10superClassE"

Definition at line 31 of file CxxSymbols.c.

◆ VTABLE_ENTRY_SIZE_64

#define VTABLE_ENTRY_SIZE_64   8U

Definition at line 37 of file CxxSymbols.c.

◆ VTABLE_HEADER_LEN_64

#define VTABLE_HEADER_LEN_64   2U

Definition at line 38 of file CxxSymbols.c.

◆ VTABLE_HEADER_SIZE_64

#define VTABLE_HEADER_SIZE_64   (VTABLE_HEADER_LEN_64 * VTABLE_ENTRY_SIZE_64)

Definition at line 39 of file CxxSymbols.c.

◆ VTABLE_PREFIX

#define VTABLE_PREFIX   CXX_PREFIX "TV"

Definition at line 27 of file CxxSymbols.c.

Function Documentation

◆ MachoGetClassNameFromMetaClassPointer()

BOOLEAN MachoGetClassNameFromMetaClassPointer ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST CHAR8 * MetaClassName,
IN UINTN ClassNameSize,
OUT CHAR8 * ClassName )

Retrieves the class name of a Meta Class Pointer.

Parameters
[in,out]ContextContext of the Mach-O.
[in]MetaClassNameMCP Symbol name to get the class name of.
[in]ClassNameSizeThe size of ClassName.
[out]ClassNameThe output buffer for the class name.
Returns
Whether the name has been retrieved successfully.

Definition at line 204 of file CxxSymbols.c.

◆ MachoGetClassNameFromSuperMetaClassPointer()

BOOLEAN MachoGetClassNameFromSuperMetaClassPointer ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST CHAR8 * SmcpName,
IN UINTN ClassNameSize,
OUT CHAR8 * ClassName )

Retrieves the class name of a Super Meta Class Pointer.

Parameters
[in,out]ContextContext of the Mach-O.
[in]SmcpNameSMCP Symbol name to get the class name of.
[in]ClassNameSizeThe size of ClassName.
[out]ClassNameThe output buffer for the class name.
Returns
Whether the name has been retrieved successfully.

Definition at line 116 of file CxxSymbols.c.

◆ MachoGetClassNameFromVtableName()

CONST CHAR8 * MachoGetClassNameFromVtableName ( IN CONST CHAR8 * VtableName)

Retrieves the class name of a VTable.

Parameters
[out]VtableNameThe VTable's name.

Definition at line 152 of file CxxSymbols.c.

◆ MachoGetFinalSymbolNameFromClassName()

BOOLEAN MachoGetFinalSymbolNameFromClassName ( IN CONST CHAR8 * ClassName,
IN UINTN FinalSymbolNameSize,
OUT CHAR8 * FinalSymbolName )

Retrieves the final symbol name of a class name.

Parameters
[in]ClassNameClass name to get the final symbol name of.
[in]FinalSymbolNameSizeThe size of FinalSymbolName.
[out]FinalSymbolNameThe output buffer for the final symbol name.
Returns
Whether the name has been retrieved successfully.

Definition at line 327 of file CxxSymbols.c.

◆ MachoGetFunctionPrefixFromClassName()

BOOLEAN MachoGetFunctionPrefixFromClassName ( IN CONST CHAR8 * ClassName,
IN UINTN FunctionPrefixSize,
OUT CHAR8 * FunctionPrefix )

Retrieves the function prefix of a class name.

Parameters
[in]ClassNameThe class name to evaluate.
[in]FunctionPrefixSizeThe size of FunctionPrefix.
[out]FunctionPrefixThe output buffer for the function prefix.
Returns
Whether the name has been retrieved successfully.

Definition at line 165 of file CxxSymbols.c.

◆ MachoGetMetaclassSymbolFromSmcpSymbol()

MACH_NLIST_ANY * MachoGetMetaclassSymbolFromSmcpSymbol ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST MACH_NLIST_ANY * Smcp )

Retrieves Metaclass symbol of a SMCP.

Parameters
[in,out]ContextContext of the Mach-O.
[in]SmcpThe SMCP to evaluate.
Return values
NULLNULL is returned on failure.

Definition at line 400 of file CxxSymbols.c.

◆ MachoGetMetaVtableNameFromClassName()

BOOLEAN MachoGetMetaVtableNameFromClassName ( IN CONST CHAR8 * ClassName,
IN UINTN VtableNameSize,
OUT CHAR8 * VtableName )

Retrieves the Meta VTable name of a class name.

Parameters
[in]ClassNameClass name to get the Meta VTable name of.
[in]VtableNameSizeThe size of VtableName.
[out]VtableNameThe output buffer for the VTable name.
Returns
Whether the name has been retrieved successfully.

Definition at line 279 of file CxxSymbols.c.

◆ MachoGetVtableNameFromClassName()

BOOLEAN MachoGetVtableNameFromClassName ( IN CONST CHAR8 * ClassName,
IN UINTN VtableNameSize,
OUT CHAR8 * VtableName )

Retrieves the VTable name of a class name.

Parameters
[in]ClassNameClass name to get the VTable name of.
[in]VtableNameSizeThe size of VtableName.
[out]VtableNameThe output buffer for the VTable name.
Returns
Whether the name has been retrieved successfully.

Definition at line 239 of file CxxSymbols.c.

◆ MachoGetVtableSymbolsFromSmcp()

BOOLEAN MachoGetVtableSymbolsFromSmcp ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST CHAR8 * SmcpName,
OUT CONST MACH_NLIST_ANY ** Vtable,
OUT CONST MACH_NLIST_ANY ** MetaVtable )

Retrieves VTable and Meta VTable of a SMCP. Logically matches XNU's get_vtable_syms_from_smcp.

Parameters
[in,out]ContextContext of the Mach-O.
[in]SmcpNameSMCP Symbol mame to retrieve the VTables from.
[out]VtableOutput buffer for the VTable symbol pointer.
[out]MetaVtableOutput buffer for the Meta VTable symbol pointer.

Definition at line 413 of file CxxSymbols.c.

◆ MachoSymbolNameIsCxx()

BOOLEAN MachoSymbolNameIsCxx ( IN CONST CHAR8 * Name)

Returns whether the symbol name describes a C++ symbol.

Parameters
[in]NameThe name to evaluate.

Definition at line 391 of file CxxSymbols.c.

◆ MachoSymbolNameIsMetaclassPointer()

BOOLEAN MachoSymbolNameIsMetaclassPointer ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST CHAR8 * SymbolName )

Returns whether SymbolName defines a Super Metaclass Pointer.

Parameters
[in,out]ContextContext of the Mach-O.
[in]SymbolNameThe symbol name to check.

Definition at line 88 of file CxxSymbols.c.

◆ MachoSymbolNameIsPadslot()

BOOLEAN MachoSymbolNameIsPadslot ( IN CONST CHAR8 * Name)

Returns whether Name is a Padslot.

Parameters
[in]NameThe name to evaluate.

Definition at line 51 of file CxxSymbols.c.

◆ MachoSymbolNameIsPureVirtual()

BOOLEAN MachoSymbolNameIsPureVirtual ( IN CONST CHAR8 * Name)

Returns whether Name is pure virtual.

Parameters
[in]NameThe name to evaluate.

Definition at line 42 of file CxxSymbols.c.

◆ MachoSymbolNameIsSmcp()

BOOLEAN MachoSymbolNameIsSmcp ( IN OUT OC_MACHO_CONTEXT * Context,
IN CONST CHAR8 * SymbolName )

Returns whether SymbolName defines a Super Metaclass Pointer.

Parameters
[in,out]ContextContext of the Mach-O.
[in]SymbolNameThe symbol name to check.

Definition at line 60 of file CxxSymbols.c.

◆ MachoSymbolNameIsVtable()

BOOLEAN MachoSymbolNameIsVtable ( IN CONST CHAR8 * SymbolName)

Returns whether SymbolName defines a VTable.

Parameters
[in]SymbolNameThe symbol name to check.

Definition at line 379 of file CxxSymbols.c.