Index: /trunk/include/iprt/err.h
===================================================================
--- /trunk/include/iprt/err.h	(revision 74637)
+++ /trunk/include/iprt/err.h	(revision 74638)
@@ -2482,4 +2482,80 @@
 /** Support for forwarders has not been implemented. */
 #define VERR_LDR_FORWARDERS_NOT_SUPPORTED           (-22954)
+/** Only native endian Mach-O files are supported. */
+#define VERR_LDRMACHO_OTHER_ENDIAN_NOT_SUPPORTED    (-22955)
+/** The Mach-O header is bad or contains new and unsupported features. */
+#define VERR_LDRMACHO_BAD_HEADER                    (-22956)
+/** The file type isn't supported. */
+#define VERR_LDRMACHO_UNSUPPORTED_FILE_TYPE         (-22957)
+/** The machine (cputype / cpusubtype combination) isn't supported. */
+#define VERR_LDRMACHO_UNSUPPORTED_MACHINE           (-22958)
+/** Bad load command(s). */
+#define VERR_LDRMACHO_BAD_LOAD_COMMAND              (-22959)
+/** Encountered an unknown load command.*/
+#define VERR_LDRMACHO_UNKNOWN_LOAD_COMMAND          (-22960)
+/** Encountered a load command that's not implemented.*/
+#define VERR_LDRMACHO_UNSUPPORTED_LOAD_COMMAND      (-22961)
+/** Bad section. */
+#define VERR_LDRMACHO_BAD_SECTION                   (-22962)
+/** Encountered a section type that's not implemented.*/
+#define VERR_LDRMACHO_UNSUPPORTED_SECTION           (-22963)
+/** Encountered a init function section.   */
+#define VERR_LDRMACHO_UNSUPPORTED_INIT_SECTION      (-22964)
+/** Encountered a term function section.   */
+#define VERR_LDRMACHO_UNSUPPORTED_TERM_SECTION      (-22965)
+/** Encountered a section type that's not known to the loader. (probably invalid) */
+#define VERR_LDRMACHO_UNKNOWN_SECTION               (-22966)
+/** The sections aren't ordered by segment as expected by the loader. */
+#define VERR_LDRMACHO_BAD_SECTION_ORDER             (-22967)
+/** The image is 32-bit and contains 64-bit load commands or vise versa. */
+#define VERR_LDRMACHO_BIT_MIX                       (-22968)
+/** Bad MH_OBJECT file. */
+#define VERR_LDRMACHO_BAD_OBJECT_FILE               (-22969)
+/** Bad symbol table entry. */
+#define VERR_LDRMACHO_BAD_SYMBOL                    (-22970)
+/** Unsupported fixup type. */
+#define VERR_LDRMACHO_UNSUPPORTED_FIXUP_TYPE        (-22971)
+/** Both debug and non-debug sections in segment. */
+#define VERR_LDRMACHO_MIXED_DEBUG_SECTION_FLAGS     (-22972)
+/** The segment bits are non-contiguous in the file. */
+#define VERR_LDRMACHO_NON_CONT_SEG_BITS             (-22973)
+/** Hit a todo in the mach-o loader. */
+#define VERR_LDRMACHO_TODO                          (-22974)
+/** Bad symbol table size in Mach-O image. */
+#define VERR_LDRMACHO_BAD_SYMTAB_SIZE               (-22975)
+/** Duplicate segment name. */
+#define VERR_LDR_DUPLICATE_SEGMENT_NAME             (-22976)
+/** No image UUID. */
+#define VERR_LDR_NO_IMAGE_UUID                      (-22977)
+/** Bad image relocation. */
+#define VERR_LDR_BAD_FIXUP                          (-22978)
+/** Address overflow. */
+#define VERR_LDR_ADDRESS_OVERFLOW                   (-22979)
+/** validation of LX header failed. */
+#define VERR_LDRLX_BAD_HEADER                       (-22980)
+/** validation of the loader section (in the LX header) failed. */
+#define VERR_LDRLX_BAD_LOADER_SECTION               (-22981)
+/** validation of the fixup section (in the LX header) failed. */
+#define VERR_LDRLX_BAD_FIXUP_SECTION                (-22982)
+/** validation of the LX object table failed. */
+#define VERR_LDRLX_BAD_OBJECT_TABLE                 (-22983)
+/** A bad page map entry was encountered. */
+#define VERR_LDRLX_BAD_PAGE_MAP                     (-22984)
+/** Bad iterdata (EXEPACK) data. */
+#define VERR_LDRLX_BAD_ITERDATA                     (-22985)
+/** Bad iterdata2 (EXEPACK2) data. */
+#define VERR_LDRLX_BAD_ITERDATA2                    (-22986)
+/** Bad bundle data. */
+#define VERR_LDRLX_BAD_BUNDLE                       (-22987)
+/** No soname. */
+#define VERR_LDRLX_NO_SONAME                        (-22988)
+/** Bad soname. */
+#define VERR_LDRLX_BAD_SONAME                       (-22989)
+/** Bad forwarder entry. */
+#define VERR_LDRLX_BAD_FORWARDER                    (-22990)
+/** internal fixup chain isn't implemented yet. */
+#define VERR_LDRLX_NRICHAIN_NOT_SUPPORTED           (-22991)
+/** Import module ordinal is out of bounds. */
+#define VERR_LDRLX_IMPORT_ORDINAL_OUT_OF_BOUNDS     (-22992)
 /** @} */
 
Index: /trunk/include/iprt/formats/lx.h
===================================================================
--- /trunk/include/iprt/formats/lx.h	(revision 74637)
+++ /trunk/include/iprt/formats/lx.h	(revision 74638)
@@ -1,3 +1,3 @@
-/* $Id $ */
+/* $Id$ */
 /** @file
  * LX structures, types and defines.
@@ -29,9 +29,9 @@
  */
 
-#ifndef ___k_kLdrFmts_lx_h___
-#define ___k_kLdrFmts_lx_h___
-
-#include <k/kDefs.h>
-#include <k/kTypes.h>
+#ifndef ___iprt_formats_lx_h___
+#define ___iprt_formats_lx_h___
+
+#include <iprt/types.h>
+#include <iprt/assertcompile.h>
 
 
@@ -41,5 +41,5 @@
 #endif
 
-#pragma pack(1)
+#pragma pack(1) /** @todo mostly unnecessary. */
 
 /**
@@ -49,81 +49,82 @@
 struct e32_exe
 {
-    KU8                 e32_magic[2];
-    KU8                 e32_border;
-    KU8                 e32_worder;
-    KU32                e32_level;
-    KU16                e32_cpu;
-    KU16                e32_os;
-    KU32                e32_ver;
-    KU32                e32_mflags;
-    KU32                e32_mpages;
-    KU32                e32_startobj;
-    KU32                e32_eip;
-    KU32                e32_stackobj;
-    KU32                e32_esp;
-    KU32                e32_pagesize;
-    KU32                e32_pageshift;
+    uint8_t             e32_magic[2];
+    uint8_t             e32_border;
+    uint8_t             e32_worder;
+    uint32_t            e32_level;
+    uint16_t            e32_cpu;
+    uint16_t            e32_os;
+    uint32_t            e32_ver;
+    uint32_t            e32_mflags;
+    uint32_t            e32_mpages;
+    uint32_t            e32_startobj;
+    uint32_t            e32_eip;
+    uint32_t            e32_stackobj;
+    uint32_t            e32_esp;
+    uint32_t            e32_pagesize;
+    uint32_t            e32_pageshift;
     /** The size of the fixup section.
      * The fixup section consists of the fixup page table, the fixup record table,
      * the import module table, and the import procedure name table.
      */
-    KU32                e32_fixupsize;
-    KU32                e32_fixupsum;
+    uint32_t            e32_fixupsize;
+    uint32_t            e32_fixupsum;
     /** The size of the resident loader section.
      * This includes the object table, the object page map table, the resource table, the resident name table,
      * the entry table, the module format directives table, and the page checksum table (?). */
-    KU32                e32_ldrsize;
+    uint32_t            e32_ldrsize;
     /** The checksum of the loader section. 0 if not calculated. */
-    KU32                e32_ldrsum;
+    uint32_t            e32_ldrsum;
     /** The offset of the object table relative to this structure. */
-    KU32                e32_objtab;
+    uint32_t            e32_objtab;
     /** Count of objects. */
-    KU32                e32_objcnt;
+    uint32_t            e32_objcnt;
     /** The offset of the object page map table relative to this structure. */
-    KU32                e32_objmap;
+    uint32_t            e32_objmap;
     /** The offset of the object iterated pages (whatever this is used for) relative to the start of the file. */
-    KU32                e32_itermap;
+    uint32_t            e32_itermap;
     /** The offset of the resource table relative to this structure. */
-    KU32                e32_rsrctab;
+    uint32_t            e32_rsrctab;
     /** The number of entries in the resource table. */
-    KU32                e32_rsrccnt;
+    uint32_t            e32_rsrccnt;
     /** The offset of the resident name table relative to this structure. */
-    KU32                e32_restab;
+    uint32_t            e32_restab;
     /** The offset of the entry (export) table relative to this structure. */
-    KU32                e32_enttab;
+    uint32_t            e32_enttab;
     /** The offset of the module format directives table relative to this structure. */
-    KU32                e32_dirtab;
+    uint32_t            e32_dirtab;
     /** The number of entries in the module format directives table. */
-    KU32                e32_dircnt;
+    uint32_t            e32_dircnt;
     /** The offset of the fixup page table relative to this structure. */
-    KU32                e32_fpagetab;
+    uint32_t            e32_fpagetab;
     /** The offset of the fixup record table relative to this structure. */
-    KU32                e32_frectab;
+    uint32_t            e32_frectab;
     /** The offset of the import module name table relative to this structure. */
-    KU32                e32_impmod;
+    uint32_t            e32_impmod;
     /** The number of entries in the import module name table. */
-    KU32                e32_impmodcnt;
+    uint32_t            e32_impmodcnt;
     /** The offset of the import procedure name table relative to this structure. */
-    KU32                e32_impproc;
+    uint32_t            e32_impproc;
     /** The offset of the page checksum table relative to this structure. */
-    KU32                e32_pagesum;
+    uint32_t            e32_pagesum;
     /** The offset of the data pages relative to the start of the file. */
-    KU32                e32_datapage;
+    uint32_t            e32_datapage;
     /** The number of preload pages (ignored). */
-    KU32                e32_preload;
+    uint32_t            e32_preload;
     /** The offset of the non-resident name table relative to the start of the file. */
-    KU32                e32_nrestab;
+    uint32_t            e32_nrestab;
     /** The size of the non-resident name table. */
-    KU32                e32_cbnrestab;
-    KU32                e32_nressum;
-    KU32                e32_autodata;
-    KU32                e32_debuginfo;
-    KU32                e32_debuglen;
-    KU32                e32_instpreload;
-    KU32                e32_instdemand;
-    KU32                e32_heapsize;
-    KU32                e32_stacksize;
-    KU8                 e32_res3[20];
-};
+    uint32_t            e32_cbnrestab;
+    uint32_t            e32_nressum;
+    uint32_t            e32_autodata;
+    uint32_t            e32_debuginfo;
+    uint32_t            e32_debuglen;
+    uint32_t            e32_instpreload;
+    uint32_t            e32_instdemand;
+    uint32_t            e32_heapsize;
+    uint32_t            e32_stacksize;
+    uint8_t             e32_res3[20];
+};
+AssertCompileSize(struct e32_exe, 196);
 
 /** e32_magic[0] */
@@ -142,5 +143,5 @@
 #define E32BEWO         1
 /** e32_level */
-#define E32LEVEL        KU32_C(0)
+#define E32LEVEL        UINT32_C(0)
 /** e32_cpu - 80286 */
 #define E32CPU286       1
@@ -150,5 +151,5 @@
 #define E32CPU486       3
 /** e32_pagesize */
-#define OBJPAGELEN      KU32_C(0x1000)
+#define OBJPAGELEN      UINT32_C(0x1000)
 
 
@@ -156,21 +157,21 @@
  * @{ */
 /** App Type: Fullscreen only. */
-#define E32NOPMW         KU32_C(0x00000100)
+#define E32NOPMW         UINT32_C(0x00000100)
 /** App Type: PM API. */
-#define E32PMAPI         KU32_C(0x00000300)
+#define E32PMAPI         UINT32_C(0x00000300)
 /** App Type: PM VIO compatible. */
-#define E32PMW           KU32_C(0x00000200)
+#define E32PMW           UINT32_C(0x00000200)
 /** Application type mask. */
-#define E32APPMASK       KU32_C(0x00000300)
+#define E32APPMASK       UINT32_C(0x00000300)
 /** Executable module. */
-#define E32MODEXE        KU32_C(0x00000000)
+#define E32MODEXE        UINT32_C(0x00000000)
 /** Dynamic link library (DLL / library) module. */
-#define E32MODDLL        KU32_C(0x00008000)
+#define E32MODDLL        UINT32_C(0x00008000)
 /** Protected memory DLL. */
-#define E32PROTDLL       KU32_C(0x00010000)
+#define E32PROTDLL       UINT32_C(0x00010000)
 /** Physical Device Driver. */
-#define E32MODPDEV       KU32_C(0x00020000)
+#define E32MODPDEV       UINT32_C(0x00020000)
 /** Virtual Device Driver. */
-#define E32MODVDEV       KU32_C(0x00028000)
+#define E32MODVDEV       UINT32_C(0x00028000)
 /** Device driver */
 #define E32DEVICE        E32MODPDEV
@@ -180,19 +181,19 @@
 #define E32MODPROTDLL    (E32MODDLL | E32PROTDLL)
 /** Module Type mask. */
-#define E32MODMASK       KU32_C(0x00038000)
+#define E32MODMASK       UINT32_C(0x00038000)
 /** Not loadable (linker error). */
-#define E32NOLOAD        KU32_C(0x00002000)
+#define E32NOLOAD        UINT32_C(0x00002000)
 /** No internal fixups. */
-#define E32NOINTFIX      KU32_C(0x00000010)
+#define E32NOINTFIX      UINT32_C(0x00000010)
 /** No external fixups (i.e. imports). */
-#define E32NOEXTFIX      KU32_C(0x00000020)
+#define E32NOEXTFIX      UINT32_C(0x00000020)
 /** System DLL, no internal fixups. */
-#define E32SYSDLL        KU32_C(0x00000008)
+#define E32SYSDLL        UINT32_C(0x00000008)
 /** Global (set) or per instance (cleared) library initialization. */
-#define E32LIBINIT       KU32_C(0x00000004)
+#define E32LIBINIT       UINT32_C(0x00000004)
 /** Global (set) or per instance (cleared) library termination. */
-#define E32LIBTERM       KU32_C(0x40000000)
+#define E32LIBTERM       UINT32_C(0x40000000)
 /** Indicates when set in an executable that the process isn't SMP safe. */
-#define E32NOTMPSAFE     KU32_C(0x00080000)
+#define E32NOTMPSAFE     UINT32_C(0x00080000)
 /** @} */
 
@@ -201,6 +202,6 @@
 typedef union _offset
 {
-    KU16                offset16;
-    KU32                offset32;
+    uint16_t            offset16;
+    uint32_t            offset32;
 } offset;
 
@@ -210,8 +211,8 @@
 struct r32_rlc
 {
-    KU8                 nr_stype;
-    KU8                 nr_flags;
-    KI16                r32_soff;
-    KU16                r32_objmod;
+    uint8_t             nr_stype;
+    uint8_t             nr_flags;
+    int16_t             r32_soff;
+    uint16_t            r32_objmod;
 
     union targetid
@@ -221,14 +222,14 @@
         {
             offset      proc;
-            KU32        ord;
+            uint32_t    ord;
         } extref;
         struct addfixup
         {
-            KU16        entry;
+            uint16_t    entry;
             offset      addval;
         } addfix;
     } r32_target;
-    KU16                r32_srccount;
-    KU16                r32_chain;
+    uint16_t            r32_srccount;
+    uint16_t            r32_chain;
 };
 
@@ -285,15 +286,15 @@
 {
     /** The size of the object. */
-    KU32                o32_size;
+    uint32_t            o32_size;
     /** The base address of the object. */
-    KU32                o32_base;
+    uint32_t            o32_base;
     /** Object flags. */
-    KU32                o32_flags;
+    uint32_t            o32_flags;
     /** Page map index. */
-    KU32                o32_pagemap;
+    uint32_t            o32_pagemap;
     /** Page map size. (doesn't need to be o32_size >> page shift). */
-    KU32                o32_mapsize;
+    uint32_t            o32_mapsize;
     /** Reserved */
-    KU32                o32_reserved;
+    uint32_t            o32_reserved;
 };
 
@@ -301,42 +302,42 @@
  * @{ */
 /** Read access. */
-#define OBJREAD         KU32_C(0x00000001)
+#define OBJREAD         UINT32_C(0x00000001)
 /** Write access. */
-#define OBJWRITE        KU32_C(0x00000002)
+#define OBJWRITE        UINT32_C(0x00000002)
 /** Execute access. */
-#define OBJEXEC         KU32_C(0x00000004)
+#define OBJEXEC         UINT32_C(0x00000004)
 /** Resource object. */
-#define OBJRSRC         KU32_C(0x00000008)
+#define OBJRSRC         UINT32_C(0x00000008)
 /** The object is discarable (i.e. don't swap, just load in pages from the executable).
  * This overlaps a bit with object type. */
-#define OBJDISCARD      KU32_C(0x00000010)
+#define OBJDISCARD      UINT32_C(0x00000010)
 /** The object is shared. */
-#define OBJSHARED       KU32_C(0x00000020)
+#define OBJSHARED       UINT32_C(0x00000020)
 /** The object has preload pages. */
-#define OBJPRELOAD      KU32_C(0x00000040)
+#define OBJPRELOAD      UINT32_C(0x00000040)
 /** The object has invalid pages. */
-#define OBJINVALID      KU32_C(0x00000080)
+#define OBJINVALID      UINT32_C(0x00000080)
 /** Non-permanent, link386 bug. */
-#define LNKNONPERM      KU32_C(0x00000600)
+#define LNKNONPERM      UINT32_C(0x00000600)
 /** Non-permanent, correct 'value'. */
-#define OBJNONPERM      KU32_C(0x00000000)
+#define OBJNONPERM      UINT32_C(0x00000000)
 /** Obj Type: The object is permanent and swappable. */
-#define OBJPERM         KU32_C(0x00000100)
+#define OBJPERM         UINT32_C(0x00000100)
 /** Obj Type: The object is permanent and resident (i.e. not swappable). */
-#define OBJRESIDENT     KU32_C(0x00000200)
+#define OBJRESIDENT     UINT32_C(0x00000200)
 /** Obj Type: The object is resident and contigious. */
-#define OBJCONTIG       KU32_C(0x00000300)
+#define OBJCONTIG       UINT32_C(0x00000300)
 /** Obj Type: The object is permanent and long locable. */
-#define OBJDYNAMIC      KU32_C(0x00000400)
+#define OBJDYNAMIC      UINT32_C(0x00000400)
 /** Object type mask. */
-#define OBJTYPEMASK     KU32_C(0x00000700)
+#define OBJTYPEMASK     UINT32_C(0x00000700)
 /** x86: The object require an 16:16 alias. */
-#define OBJALIAS16      KU32_C(0x00001000)
+#define OBJALIAS16      UINT32_C(0x00001000)
 /** x86: Big/Default selector setting, i.e. toggle 32-bit or 16-bit. */
-#define OBJBIGDEF       KU32_C(0x00002000)
+#define OBJBIGDEF       UINT32_C(0x00002000)
 /** x86: conforming selector setting (weird stuff). */
-#define OBJCONFORM      KU32_C(0x00004000)
+#define OBJCONFORM      UINT32_C(0x00004000)
 /** x86: IOPL. */
-#define OBJIOPL         KU32_C(0x00008000)
+#define OBJIOPL         UINT32_C(0x00008000)
 /** @} */
 
@@ -345,9 +346,9 @@
 {
     /** The file offset of the page. */
-    KU32                o32_pagedataoffset;
+    uint32_t            o32_pagedataoffset;
     /** The number of bytes of raw page data. */
-    KU16                o32_pagesize;
+    uint16_t            o32_pagesize;
     /** Per page flags describing how the page is encoded in the file. */
-    KU16                o32_pageflags;
+    uint16_t            o32_pageflags;
 };
 
@@ -356,15 +357,15 @@
  */
 /** Raw page (uncompressed) in the file. */
-#define VALID           KU16_C(0x0000)
+#define VALID           UINT16_C(0x0000)
 /** RLE encoded page in file. */
-#define ITERDATA        KU16_C(0x0001)
+#define ITERDATA        UINT16_C(0x0001)
 /** Invalid page, nothing in the file. */
-#define INVALID         KU16_C(0x0002)
+#define INVALID         UINT16_C(0x0002)
 /** Zero page, nothing in file. */
-#define ZEROED          KU16_C(0x0003)
+#define ZEROED          UINT16_C(0x0003)
 /** range of pages (what is this?) */
-#define RANGE           KU16_C(0x0004)
+#define RANGE           UINT16_C(0x0004)
 /** Compressed page in file. */
-#define ITERDATA2       KU16_C(0x0005)
+#define ITERDATA2       UINT16_C(0x0005)
 /** @} */
 
@@ -374,9 +375,9 @@
 {
     /** Number of iterations. */
-    KU16                LX_nIter;
+    uint16_t            LX_nIter;
     /** The number of bytes that's being iterated. */
-    KU16                LX_nBytes;
+    uint16_t            LX_nBytes;
     /** The bytes. */
-    KU8                 LX_Iterdata;
+    uint8_t             LX_Iterdata;
 };
 
@@ -388,13 +389,13 @@
 {
     /** Resource Type. */
-    KU16                type;
+    uint16_t            type;
     /** Resource ID. */
-    KU16                name;
+    uint16_t            name;
     /** Resource size in bytes. */
-    KU32                cb;
+    uint32_t            cb;
     /** The index of the object containing the resource. */
-    KU16                obj;
+    uint16_t            obj;
     /** Offset of the resource that within the object. */
-    KU32                offset;
+    uint32_t            offset;
 };
 
@@ -408,9 +409,9 @@
 {
     /** The number of entries. */
-    KU8                 b32_cnt;
+    uint8_t             b32_cnt;
     /** The type of bundle. */
-    KU8                 b32_type;
+    uint8_t             b32_type;
     /** The index of the object containing these entry points. */
-    KU16                b32_obj;
+    uint16_t            b32_obj;
 };
 
@@ -436,5 +437,5 @@
 {
     /** Entry point flags */
-    KU8                 e32_flags;      /* Entry point flags */
+    uint8_t             e32_flags;      /* Entry point flags */
     union entrykind
     {
@@ -442,10 +443,10 @@
         offset          e32_offset;
         /** GATE16 */
-        struct callgate
+        struct scallgate
         {
             /** Offset into segment. */
-            KU16        offset;
+            uint16_t    offset;
             /** The callgate selector */
-            KU16        callgate;
+            uint16_t    callgate;
         } e32_callgate;
         /** ENTRYFWD */
@@ -453,7 +454,7 @@
         {
             /** Module ordinal number (i.e. into the import module table). */
-            KU16        modord;
+            uint16_t    modord;
             /** Procedure name or ordinal number. */
-            KU32        value;
+            uint32_t    value;
         } e32_fwd;
     } e32_variant;
@@ -484,2 +485,3 @@
 #endif
 
+
Index: /trunk/include/iprt/formats/mach-o.h
===================================================================
--- /trunk/include/iprt/formats/mach-o.h	(revision 74637)
+++ /trunk/include/iprt/formats/mach-o.h	(revision 74638)
@@ -480,4 +480,20 @@
 } uuid_command_t;
 
+typedef struct linkedit_data_command
+{
+    uint32_t            cmd;        /**< LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS */
+    uint32_t            cmdsize;    /**< Size of this structure. */
+    uint32_t            dataoff;    /**< Offset into the file of the data. */
+    uint32_t            datasize;   /**< The size of the data. */
+} linkedit_data_command_t;
+
+typedef struct version_min_command
+{
+    uint32_t            cmd;        /**< LC_VERSION_MIN_MACOSX, LC_VERSION_MIN_IPHONEOS */
+    uint32_t            cmdsize;    /**< Size of this structure. */
+    uint32_t            version;    /**< 31..16=major, 15..8=minor, 7..0=patch. */
+    uint32_t            reserved;   /**< MBZ. */
+} version_min_command_t;
+
 typedef struct macho_nlist_32
 {
Index: /trunk/include/iprt/types.h
===================================================================
--- /trunk/include/iprt/types.h	(revision 74637)
+++ /trunk/include/iprt/types.h	(revision 74638)
@@ -3012,4 +3012,12 @@
     /** Pointer to a 64-bit unsigned value. */
     uint64_t        RT_FAR *pu64;
+    /** Pointer to a 8-bit signed value. */
+    int8_t          RT_FAR *pi8;
+    /** Pointer to a 16-bit signed value. */
+    int16_t         RT_FAR *pi16;
+    /** Pointer to a 32-bit signed value. */
+    int32_t         RT_FAR *pi32;
+    /** Pointer to a 64-bit signed value. */
+    int64_t         RT_FAR *pi64;
     /** Pointer to a UTF-16 character. */
     PRTUTF16                pwc;
@@ -3051,4 +3059,12 @@
     /** Pointer to a 64-bit unsigned value. */
     uint64_t const  RT_FAR *pu64;
+    /** Pointer to a 8-bit signed value. */
+    int8_t const    RT_FAR *pi8;
+    /** Pointer to a 16-bit signed value. */
+    int16_t const   RT_FAR *pi16;
+    /** Pointer to a 32-bit signed value. */
+    int32_t const   RT_FAR *pi32;
+    /** Pointer to a 64-bit signed value. */
+    int64_t const   RT_FAR *pi64;
     /** Pointer to a UTF-16 character. */
     PCRTUTF16               pwc;
@@ -3083,5 +3099,5 @@
     unsigned long volatile RT_FAR *pul;
     /** Pointer to a 8-bit unsigned value. */
-    uint8_t volatile RT_FAR *pu8;
+    uint8_t volatile RT_FAR  *pu8;
     /** Pointer to a 16-bit unsigned value. */
     uint16_t volatile RT_FAR *pu16;
@@ -3090,4 +3106,12 @@
     /** Pointer to a 64-bit unsigned value. */
     uint64_t volatile RT_FAR *pu64;
+    /** Pointer to a 8-bit signed value. */
+    int8_t volatile RT_FAR   *pi8;
+    /** Pointer to a 16-bit signed value. */
+    int16_t volatile RT_FAR  *pi16;
+    /** Pointer to a 32-bit signed value. */
+    int32_t volatile RT_FAR  *pi32;
+    /** Pointer to a 64-bit signed value. */
+    int64_t volatile RT_FAR  *pi64;
     /** Pointer to a UTF-16 character. */
     RTUTF16 volatile RT_FAR *pwc;
@@ -3129,4 +3153,12 @@
     /** Pointer to a 64-bit unsigned value. */
     uint64_t const volatile         RT_FAR *pu64;
+    /** Pointer to a 8-bit signed value. */
+    int8_t const volatile           RT_FAR *pi8;
+    /** Pointer to a 16-bit signed value. */
+    int16_t const volatile          RT_FAR *pi16;
+    /** Pointer to a 32-bit signed value. */
+    int32_t const volatile          RT_FAR *pi32;
+    /** Pointer to a 64-bit signed value. */
+    int64_t const volatile          RT_FAR *pi64;
     /** Pointer to a UTF-16 character. */
     RTUTF16 const volatile          RT_FAR *pwc;
Index: /trunk/src/VBox/Runtime/.scm-settings
===================================================================
--- /trunk/src/VBox/Runtime/.scm-settings	(revision 74637)
+++ /trunk/src/VBox/Runtime/.scm-settings	(revision 74638)
@@ -97,4 +97,7 @@
 /r3/win/VBoxRT-msvcr100-win32.def              : --external-copyright
 
+/common/ldr/ldrLX.cpp                          : --external-copyright
+/common/ldr/ldrMachO.cpp                       : --external-copyright
+
 /common/math/x86/fenv-x86.c                    : --external-copyright --no-convert-tabs
 
Index: /trunk/src/VBox/Runtime/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Runtime/Makefile.kmk	(revision 74637)
+++ /trunk/src/VBox/Runtime/Makefile.kmk	(revision 74638)
@@ -265,4 +265,5 @@
 	LDR_WITH_NATIVE \
 	LDR_WITH_ELF32 \
+	LDR_WITH_LX \
 	LDR_WITH_PE \
 	RT_WITH_VBOX \
@@ -271,4 +272,5 @@
 	IPRT_WITH_OPENSSL \
 	NOFILEID
+#	+= LDR_WITH_MACHO
 if1of ($(KBUILD_TARGET_ARCH), amd64 x86)
  RuntimeR3_DEFS         += \
@@ -456,4 +458,6 @@
 	common/ldr/ldrFile.cpp \
 	common/ldr/ldrVfsFile.cpp \
+	common/ldr/ldrLX.cpp \
+	common/ldr/ldrMachO.cpp \
 	common/ldr/ldrMemory.cpp \
 	common/ldr/ldrNative.cpp \
@@ -1625,4 +1629,6 @@
 	common/ldr/ldrFile.cpp \
 	common/ldr/ldrkStuff.cpp \
+	common/ldr/ldrLX.cpp \
+	common/ldr/ldrMachO.cpp \
 	common/ldr/ldrNative.cpp \
 	common/ldr/ldrPE.cpp \
Index: /trunk/src/VBox/Runtime/common/ldr/ldrELF.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/ldr/ldrELF.cpp	(revision 74637)
+++ /trunk/src/VBox/Runtime/common/ldr/ldrELF.cpp	(revision 74638)
@@ -121,5 +121,5 @@
  * @param   pErrInfo    Where to return extended error information. Optional.
  */
-int rtldrELFOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo)
+DECLHIDDEN(int) rtldrELFOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo)
 {
     const char *pszLogName = pReader->pfnLogName(pReader); NOREF(pszLogName);
Index: /trunk/src/VBox/Runtime/common/ldr/ldrEx.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/ldr/ldrEx.cpp	(revision 74637)
+++ /trunk/src/VBox/Runtime/common/ldr/ldrEx.cpp	(revision 74638)
@@ -42,4 +42,5 @@
 #include <iprt/string.h>
 #include <iprt/formats/mz.h>
+#include <iprt/formats/mach-o.h>
 #include "internal/ldr.h"
 
@@ -81,5 +82,11 @@
         &&  uSign.u32     != IMAGE_NT_SIGNATURE
         &&  uSign.u32     != IMAGE_ELF_SIGNATURE
-        &&  uSign.au16[0] != IMAGE_LX_SIGNATURE)
+        &&  uSign.au16[0] != IMAGE_LX_SIGNATURE
+        &&  uSign.u32     != IMAGE_MACHO64_SIGNATURE
+        &&  uSign.u32     != IMAGE_MACHO64_SIGNATURE_OE
+        &&  uSign.u32     != IMAGE_MACHO32_SIGNATURE
+        &&  uSign.u32     != IMAGE_MACHO32_SIGNATURE_OE
+        &&  uSign.u32     != IMAGE_FAT_SIGNATURE
+        &&  uSign.u32     != IMAGE_FAT_SIGNATURE_OE )
     {
         Log(("rtldrOpenWithReader: %s: unknown magic %#x / '%.4s\n", pReader->pfnLogName(pReader), uSign.u32, &uSign.ach[0]));
@@ -127,4 +134,20 @@
         rc = VERR_ELF_EXE_NOT_SUPPORTED;
 #endif
+    else if (   uSign.u32 == IMAGE_MACHO64_SIGNATURE
+             || uSign.u32 == IMAGE_MACHO64_SIGNATURE_OE
+             || uSign.u32 == IMAGE_MACHO32_SIGNATURE
+             || uSign.u32 == IMAGE_MACHO32_SIGNATURE_OE)
+#if defined(LDR_WITH_MACHO)
+        rc = rtldrMachOOpen(pReader, fFlags, enmArch, offHdr, phMod, pErrInfo);
+#else
+        rc = VERR_INVALID_EXE_SIGNATURE;
+#endif
+    else if (   uSign.u32 == IMAGE_FAT_SIGNATURE
+             || uSign.u32 == IMAGE_FAT_SIGNATURE_OE)
+#if defined(LDR_WITH_MACHO)
+        rc = rtldrFatOpen(pReader, fFlags, enmArch, phMod, pErrInfo);
+#else
+        rc = VERR_INVALID_EXE_SIGNATURE;
+#endif
     else if (uSign.au16[0] == IMAGE_LX_SIGNATURE)
 #ifdef LDR_WITH_LX
Index: /trunk/src/VBox/Runtime/common/ldr/ldrLX.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/ldr/ldrLX.cpp	(revision 74637)
+++ /trunk/src/VBox/Runtime/common/ldr/ldrLX.cpp	(revision 74638)
@@ -29,15 +29,26 @@
  */
 
-/*******************************************************************************
-*   Header Files                                                               *
-*******************************************************************************/
-#include <k/kLdr.h>
-#include "kLdrInternal.h"
-#include <k/kLdrFmts/lx.h>
-
-
-/*******************************************************************************
-*   Defined Constants And Macros                                               *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#define LOG_GROUP RTLOGGROUP_LDR
+#include <iprt/ldr.h>
+#include "internal/iprt.h"
+
+#include <iprt/asm.h>
+#include <iprt/assert.h>
+#include <iprt/err.h>
+#include <iprt/log.h>
+#include <iprt/mem.h>
+#include <iprt/string.h>
+
+#include <iprt/formats/lx.h>
+#include "internal/ldr.h"
+
+
+/*********************************************************************************************************************************
+*   Defined Constants And Macros                                                                                                 *
+*********************************************************************************************************************************/
 /** @def KLDRMODLX_STRICT
  * Define KLDRMODLX_STRICT to enabled strict checks in KLDRMODLX. */
@@ -48,5 +59,5 @@
  */
 #ifdef KLDRMODLX_STRICT
-# define KLDRMODLX_ASSERT(expr)  kHlpAssert(expr)
+# define KLDRMODLX_ASSERT(expr)  Assert(expr)
 #else
 # define KLDRMODLX_ASSERT(expr)  do {} while (0)
@@ -54,7 +65,7 @@
 
 
-/*******************************************************************************
-*   Structures and Typedefs                                                    *
-*******************************************************************************/
+/*********************************************************************************************************************************
+*   Structures and Typedefs                                                                                                      *
+*********************************************************************************************************************************/
 /**
  * Instance data for the LX module interpreter.
@@ -62,15 +73,16 @@
 typedef struct KLDRMODLX
 {
-    /** Pointer to the module. (Follows the section table.) */
-    PKLDRMOD                pMod;
+    /** Core module structure. */
+    RTLDRMODINTERNAL        Core;
+
     /** Pointer to the user mapping. */
     const void             *pvMapping;
     /** The size of the mapped LX image. */
-    KSIZE                   cbMapped;
+    size_t                  cbMapped;
     /** Reserved flags. */
-    KU32                    f32Reserved;
+    uint32_t                f32Reserved;
 
     /** The offset of the LX header. */
-    KLDRFOFF                offHdr;
+    RTFOFF                  offHdr;
     /** Copy of the LX header. */
     struct e32_exe          Hdr;
@@ -78,7 +90,7 @@
     /** Pointer to the loader section.
      * Allocated together with this strcture. */
-    const KU8              *pbLoaderSection;
+    const uint8_t          *pbLoaderSection;
     /** Pointer to the last byte in the loader section. */
-    const KU8              *pbLoaderSectionLast;
+    const uint8_t          *pbLoaderSectionLast;
     /** Pointer to the object table in the loader section. */
     const struct o32_obj   *paObjs;
@@ -88,96 +100,64 @@
     const struct rsrc32    *paRsrcs;
     /** Pointer to the resident name table in the loader section. */
-    const KU8              *pbResNameTab;
+    const uint8_t          *pbResNameTab;
     /** Pointer to the entry table in the loader section. */
-    const KU8              *pbEntryTab;
+    const uint8_t          *pbEntryTab;
 
     /** Pointer to the non-resident name table. */
-    KU8                    *pbNonResNameTab;
+    uint8_t                *pbNonResNameTab;
     /** Pointer to the last byte in the non-resident name table. */
-    const KU8              *pbNonResNameTabLast;
+    const uint8_t          *pbNonResNameTabLast;
 
     /** Pointer to the fixup section. */
-    KU8                    *pbFixupSection;
+    uint8_t                *pbFixupSection;
     /** Pointer to the last byte in the fixup section. */
-    const KU8              *pbFixupSectionLast;
+    const uint8_t          *pbFixupSectionLast;
     /** Pointer to the fixup page table within pvFixupSection. */
-    const KU32             *paoffPageFixups;
+    const uint32_t         *paoffPageFixups;
     /** Pointer to the fixup record table within pvFixupSection. */
-    const KU8              *pbFixupRecs;
+    const uint8_t          *pbFixupRecs;
     /** Pointer to the import module name table within pvFixupSection. */
-    const KU8              *pbImportMods;
+    const uint8_t          *pbImportMods;
     /** Pointer to the import module name table within pvFixupSection. */
-    const KU8              *pbImportProcs;
+    const uint8_t          *pbImportProcs;
+
+    /** Pointer to the module name (in the resident name table). */
+    const char             *pszName;
+    /** The name length. */
+    size_t                  cchName;
+
+    /** The target CPU. */
+    RTLDRCPU                enmCpu;
+    /** Number of segments in aSegments. */
+    uint32_t                cSegments;
+    /** Segment info. */
+    RTLDRSEG                aSegments[RT_FLEXIBLE_ARRAY];
 } KLDRMODLX, *PKLDRMODLX;
 
 
-/*******************************************************************************
-*   Internal Functions                                                         *
-*******************************************************************************/
-static int kldrModLXHasDbgInfo(PKLDRMOD pMod, const void *pvBits);
-static int kldrModLXRelocateBits(PKLDRMOD pMod, void *pvBits, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress,
-                                 PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
-static int kldrModLXDoCreate(PKRDR pRdr, KLDRFOFF offNewHdr, PKLDRMODLX *ppModLX);
-static const KU8 *kldrModLXDoNameTableLookupByOrdinal(const KU8 *pbNameTable, KSSIZE cbNameTable, KU32 iOrdinal);
-static int kldrModLXDoNameLookup(PKLDRMODLX pModLX, const char *pchSymbol, KSIZE cchSymbol, KU32 *piSymbol);
-static const KU8 *kldrModLXDoNameTableLookupByName(const KU8 *pbNameTable, KSSIZE cbNameTable,
-                                                       const char *pchSymbol, KSIZE cchSymbol);
+/*********************************************************************************************************************************
+*   Internal Functions                                                                                                           *
+*********************************************************************************************************************************/
+static int kldrModLXHasDbgInfo(PRTLDRMODINTERNAL pMod, const void *pvBits);
+static DECLCALLBACK(int) rtldrLX_RelocateBits(PRTLDRMODINTERNAL pMod, void *pvBits, RTUINTPTR NewBaseAddress,
+                                              RTUINTPTR OldBaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser);
+static const uint8_t *kldrModLXDoNameTableLookupByOrdinal(const uint8_t *pbNameTable, ssize_t cbNameTable, uint32_t iOrdinal);
+static int kldrModLXDoNameLookup(PKLDRMODLX pModLX, const char *pchSymbol, size_t cchSymbol, uint32_t *piSymbol);
+static const uint8_t *kldrModLXDoNameTableLookupByName(const uint8_t *pbNameTable, ssize_t cbNameTable,
+                                                       const char *pchSymbol, size_t cchSymbol);
+static int kldrModLXGetImport(PKLDRMODLX pThis, const void *pvBits, uint32_t iImport,
+                              char *pszName, size_t cchName, size_t *pcbNeeded);
 static int kldrModLXDoLoadBits(PKLDRMODLX pModLX, void *pvBits);
-static int kldrModLXDoIterDataUnpacking(KU8 *pbDst, const KU8 *pbSrc, int cbSrc);
-static int kldrModLXDoIterData2Unpacking(KU8 *pbDst, const KU8 *pbSrc, int cbSrc);
-static void kLdrModLXMemCopyW(KU8 *pbDst, const KU8 *pbSrc, int cb);
+static int kldrModLXDoIterDataUnpacking(uint8_t *pbDst, const uint8_t *pbSrc, int cbSrc);
+static int kldrModLXDoIterData2Unpacking(uint8_t *pbDst, const uint8_t *pbSrc, int cbSrc);
+static void kLdrModLXMemCopyW(uint8_t *pbDst, const uint8_t *pbSrc, int cb);
 static int kldrModLXDoProtect(PKLDRMODLX pModLX, void *pvBits, unsigned fUnprotectOrProtect);
-static int kldrModLXDoCallDLL(PKLDRMODLX pModLX, void *pvMapping, unsigned uOp, KUPTR uHandle);
+static int kldrModLXDoCallDLL(PKLDRMODLX pModLX, void *pvMapping, unsigned uOp, uintptr_t uHandle);
 static int kldrModLXDoForwarderQuery(PKLDRMODLX pModLX, const struct e32_entry *pEntry,
-                                     PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind);
+                                     PFNRTLDRIMPORT pfnGetForwarder, void *pvUser, PRTLDRADDR puValue, uint32_t *pfKind);
 static int kldrModLXDoLoadFixupSection(PKLDRMODLX pModLX);
-static KI32 kldrModLXDoCall(KUPTR uEntrypoint, KUPTR uHandle, KU32 uOp, void *pvReserved);
-static int kldrModLXDoReloc(KU8 *pbPage, int off, KLDRADDR PageAddress, const struct r32_rlc *prlc,
-                            int iSelector, KLDRADDR uValue, KU32 fKind);
-
-
-/**
- * Create a loader module instance interpreting the executable image found
- * in the specified file provider instance.
- *
- * @returns 0 on success and *ppMod pointing to a module instance.
- *          On failure, a non-zero OS specific error code is returned.
- * @param   pOps            Pointer to the registered method table.
- * @param   pRdr            The file provider instance to use.
- * @param   fFlags          Flags, MBZ.
- * @param   enmCpuArch      The desired CPU architecture. KCPUARCH_UNKNOWN means
- *                          anything goes, but with a preference for the current
- *                          host architecture.
- * @param   offNewHdr       The offset of the new header in MZ files. -1 if not found.
- * @param   ppMod           Where to store the module instance pointer.
- */
-static int kldrModLXCreate(PCKLDRMODOPS pOps, PKRDR pRdr, KU32 fFlags, KCPUARCH enmCpuArch, KLDRFOFF offNewHdr, PPKLDRMOD ppMod)
-{
-    PKLDRMODLX pModLX;
-    int rc;
-    K_NOREF(fFlags);
-
-    /*
-     * Create the instance data and do a minimal header validation.
-     */
-    rc = kldrModLXDoCreate(pRdr, offNewHdr, &pModLX);
-    if (!rc)
-    {
-        /*
-         * Match up against the requested CPU architecture.
-         */
-        if (    enmCpuArch == KCPUARCH_UNKNOWN
-            ||  pModLX->pMod->enmArch == enmCpuArch)
-        {
-            pModLX->pMod->pOps = pOps;
-            pModLX->pMod->u32Magic = KLDRMOD_MAGIC;
-            *ppMod = pModLX->pMod;
-            return 0;
-        }
-        rc = KLDR_ERR_CPU_ARCH_MISMATCH;
-    }
-    kHlpFree(pModLX);
-    return rc;
-}
+static int32_t kldrModLXDoCall(uintptr_t uEntrypoint, uintptr_t uHandle, uint32_t uOp, void *pvReserved);
+static int kldrModLXDoReloc(uint8_t *pbPage, int off, RTLDRADDR PageAddress, const struct r32_rlc *prlc,
+                            int iSelector, RTLDRADDR uValue, uint32_t fKind);
 
 
@@ -186,17 +166,14 @@
  * simplify cleanup on failure.
  */
-static int kldrModLXDoCreate(PKRDR pRdr, KLDRFOFF offNewHdr, PKLDRMODLX *ppModLX)
+static int kldrModLXDoCreate(PRTLDRREADER pRdr, RTFOFF offNewHdr, uint32_t fFlags, PKLDRMODLX *ppModLX, PRTERRINFO pErrInfo)
 {
     struct e32_exe Hdr;
     PKLDRMODLX pModLX;
-    PKLDRMOD pMod;
-    KSIZE cb;
-    KSIZE cchFilename;
-    KSIZE offLdrStuff;
-    KU32 off, offEnd;
-    KU32 i;
-    int rc;
+    uint32_t off, offEnd;
+    uint32_t i;
     int fCanOptimizeMapping;
-    KU32 NextRVA;
+    uint32_t NextRVA;
+
+    RT_NOREF(fFlags);
     *ppModLX = NULL;
 
@@ -204,10 +181,10 @@
      * Read the signature and file header.
      */
-    rc = kRdrRead(pRdr, &Hdr, sizeof(Hdr), offNewHdr > 0 ? offNewHdr : 0);
-    if (rc)
-        return rc;
+    int rc = pRdr->pfnRead(pRdr, &Hdr, sizeof(Hdr), offNewHdr > 0 ? offNewHdr : 0);
+    if (RT_FAILURE(rc))
+        return RTErrInfoSetF(pErrInfo, rc, "Error reading LX header at %RTfoff: %Rrc", offNewHdr, rc);
     if (    Hdr.e32_magic[0] != E32MAGIC1
         ||  Hdr.e32_magic[1] != E32MAGIC2)
-        return KLDR_ERR_UNKNOWN_FORMAT;
+        return RTErrInfoSetF(pErrInfo, VERR_INVALID_EXE_SIGNATURE, "Not LX magic: %02x %02x", Hdr.e32_magic[0], Hdr.e32_magic[1]);
 
     /* We're not interested in anything but x86 images. */
@@ -219,8 +196,8 @@
         ||  Hdr.e32_pagesize != OBJPAGELEN
         )
-        return KLDR_ERR_LX_BAD_HEADER;
+        return VERR_LDRLX_BAD_HEADER;
 
     /* Some rough sanity checks. */
-    offEnd = kRdrSize(pRdr) >= (KLDRFOFF)~(KU32)16 ? ~(KU32)16 : (KU32)kRdrSize(pRdr);
+    offEnd = pRdr->pfnSize(pRdr) >= (RTFOFF)~(uint32_t)16 ? ~(uint32_t)16 : (uint32_t)pRdr->pfnSize(pRdr);
     if (    Hdr.e32_itermap > offEnd
         ||  Hdr.e32_datapage > offEnd
@@ -230,30 +207,30 @@
         ||  Hdr.e32_fixupsize > offEnd - offNewHdr - sizeof(Hdr)
         ||  Hdr.e32_fixupsize + Hdr.e32_ldrsize > offEnd - offNewHdr - sizeof(Hdr))
-        return KLDR_ERR_LX_BAD_HEADER;
+        return VERR_LDRLX_BAD_HEADER;
 
     /* Verify the loader section. */
     offEnd = Hdr.e32_objtab + Hdr.e32_ldrsize;
     if (Hdr.e32_objtab < sizeof(Hdr))
-        return KLDR_ERR_LX_BAD_LOADER_SECTION;
+        return VERR_LDRLX_BAD_LOADER_SECTION;
     off = Hdr.e32_objtab + sizeof(struct o32_obj) * Hdr.e32_objcnt;
     if (off > offEnd)
-        return KLDR_ERR_LX_BAD_LOADER_SECTION;
+        return VERR_LDRLX_BAD_LOADER_SECTION;
     if (    Hdr.e32_objmap
         &&  (Hdr.e32_objmap < off || Hdr.e32_objmap > offEnd))
-        return KLDR_ERR_LX_BAD_LOADER_SECTION;
+        return VERR_LDRLX_BAD_LOADER_SECTION;
     if (    Hdr.e32_rsrccnt
         && (   Hdr.e32_rsrctab < off
             || Hdr.e32_rsrctab > offEnd
             || Hdr.e32_rsrctab + sizeof(struct rsrc32) * Hdr.e32_rsrccnt > offEnd))
-        return KLDR_ERR_LX_BAD_LOADER_SECTION;
+        return VERR_LDRLX_BAD_LOADER_SECTION;
     if (    Hdr.e32_restab
         &&  (Hdr.e32_restab < off || Hdr.e32_restab > offEnd - 2))
-        return KLDR_ERR_LX_BAD_LOADER_SECTION;
+        return VERR_LDRLX_BAD_LOADER_SECTION;
     if (    Hdr.e32_enttab
         &&  (Hdr.e32_enttab < off || Hdr.e32_enttab >= offEnd))
-        return KLDR_ERR_LX_BAD_LOADER_SECTION;
+        return VERR_LDRLX_BAD_LOADER_SECTION;
     if (    Hdr.e32_dircnt
         && (Hdr.e32_dirtab < off || Hdr.e32_dirtab > offEnd - 2))
-        return KLDR_ERR_LX_BAD_LOADER_SECTION;
+        return VERR_LDRLX_BAD_LOADER_SECTION;
 
     /* Verify the fixup section. */
@@ -272,61 +249,49 @@
     if (    Hdr.e32_frectab
         &&  (Hdr.e32_frectab < off || Hdr.e32_frectab > offEnd))
-        return KLDR_ERR_LX_BAD_FIXUP_SECTION;
+        return VERR_LDRLX_BAD_FIXUP_SECTION;
     if (    Hdr.e32_impmod
         &&  (Hdr.e32_impmod < off || Hdr.e32_impmod > offEnd || Hdr.e32_impmod + Hdr.e32_impmodcnt > offEnd))
-        return KLDR_ERR_LX_BAD_FIXUP_SECTION;
+        return VERR_LDRLX_BAD_FIXUP_SECTION;
     if (    Hdr.e32_impproc
         &&  (Hdr.e32_impproc < off || Hdr.e32_impproc > offEnd))
-        return KLDR_ERR_LX_BAD_FIXUP_SECTION;
+        return VERR_LDRLX_BAD_FIXUP_SECTION;
 
     /*
      * Calc the instance size, allocate and initialize it.
      */
-    cchFilename = kHlpStrLen(kRdrName(pRdr));
-    cb = K_ALIGN_Z(sizeof(KLDRMODLX), 8)
-       + K_ALIGN_Z(K_OFFSETOF(KLDRMOD, aSegments[Hdr.e32_objcnt + 1]), 8)
-       + K_ALIGN_Z(cchFilename + 1, 8);
-    offLdrStuff = cb;
-    cb += Hdr.e32_ldrsize + 2; /* +2 for two extra zeros. */
-    pModLX = (PKLDRMODLX)kHlpAlloc(cb);
+    size_t cbModLXAndSegments = RT_ALIGN_Z(RT_UOFFSETOF_DYN(KLDRMODLX, aSegments[Hdr.e32_objcnt + 1]), 8);
+    pModLX = (PKLDRMODLX)RTMemAlloc(cbModLXAndSegments + Hdr.e32_ldrsize + 2 /*for two extra zeros*/);
     if (!pModLX)
-        return KERR_NO_MEMORY;
+        return VERR_NO_MEMORY;
     *ppModLX = pModLX;
 
-    /* KLDRMOD */
-    pMod = (PKLDRMOD)((KU8 *)pModLX + K_ALIGN_Z(sizeof(KLDRMODLX), 8));
-    pMod->pvData = pModLX;
-    pMod->pRdr = pRdr;
-    pMod->pOps = NULL;      /* set upon success. */
-    pMod->cSegments = Hdr.e32_objcnt;
-    pMod->cchFilename = (KU32)cchFilename;
-    pMod->pszFilename = (char *)K_ALIGN_P(&pMod->aSegments[pMod->cSegments], 8);
-    kHlpMemCopy((char *)pMod->pszFilename, kRdrName(pRdr), cchFilename + 1);
-    pMod->pszName = NULL; /* finalized further down */
-    pMod->cchName = 0;
-    pMod->fFlags = 0;
+    /* Core & CPU. */
+    pModLX->Core.u32Magic   = 0;      /* set by caller. */
+    pModLX->Core.eState     = LDR_STATE_OPENED;
+    pModLX->Core.pOps       = NULL;   /* set by caller. */
+    pModLX->Core.pReader    = pRdr;
     switch (Hdr.e32_cpu)
     {
         case E32CPU286:
-            pMod->enmCpu = KCPU_I80286;
-            pMod->enmArch = KCPUARCH_X86_16;
+            pModLX->enmCpu = RTLDRCPU_I80286;
+            pModLX->Core.enmArch = RTLDRARCH_X86_16;
             break;
         case E32CPU386:
-            pMod->enmCpu = KCPU_I386;
-            pMod->enmArch = KCPUARCH_X86_32;
+            pModLX->enmCpu = RTLDRCPU_I386;
+            pModLX->Core.enmArch = RTLDRARCH_X86_32;
             break;
         case E32CPU486:
-            pMod->enmCpu = KCPU_I486;
-            pMod->enmArch = KCPUARCH_X86_32;
+            pModLX->enmCpu = RTLDRCPU_I486;
+            pModLX->Core.enmArch = RTLDRARCH_X86_32;
             break;
     }
-    pMod->enmEndian = KLDRENDIAN_LITTLE;
-    pMod->enmFmt = KLDRFMT_LX;
+    pModLX->Core.enmEndian = RTLDRENDIAN_LITTLE;
+    pModLX->Core.enmFormat = RTLDRFMT_LX;
     switch (Hdr.e32_mflags & E32MODMASK)
     {
         case E32MODEXE:
-            pMod->enmType = !(Hdr.e32_mflags & E32NOINTFIX)
-                ? KLDRTYPE_EXECUTABLE_RELOCATABLE
-                : KLDRTYPE_EXECUTABLE_FIXED;
+            pModLX->Core.enmType = !(Hdr.e32_mflags & E32NOINTFIX)
+                                 ? RTLDRTYPE_EXECUTABLE_RELOCATABLE
+                                 : RTLDRTYPE_EXECUTABLE_FIXED;
             break;
 
@@ -334,18 +299,19 @@
         case E32PROTDLL:
         case E32MODPROTDLL:
-            pMod->enmType = !(Hdr.e32_mflags & E32SYSDLL)
-                ? KLDRTYPE_SHARED_LIBRARY_RELOCATABLE
-                : KLDRTYPE_SHARED_LIBRARY_FIXED;
+            pModLX->Core.enmType = !(Hdr.e32_mflags & E32SYSDLL)
+                                 ? RTLDRTYPE_SHARED_LIBRARY_RELOCATABLE
+                                 : RTLDRTYPE_SHARED_LIBRARY_FIXED;
             break;
 
         case E32MODPDEV:
         case E32MODVDEV:
-            pMod->enmType = KLDRTYPE_SHARED_LIBRARY_RELOCATABLE;
+            pModLX->Core.enmType = RTLDRTYPE_SHARED_LIBRARY_RELOCATABLE;
             break;
     }
-    pMod->u32Magic = 0;     /* set upon success. */
 
     /* KLDRMODLX */
-    pModLX->pMod = pMod;
+    pModLX->cSegments = Hdr.e32_objcnt;
+    pModLX->pszName = NULL; /* finalized further down */
+    pModLX->cchName = 0;
     pModLX->pvMapping = 0;
     pModLX->cbMapped = 0;
@@ -353,7 +319,7 @@
 
     pModLX->offHdr = offNewHdr >= 0 ? offNewHdr : 0;
-    kHlpMemCopy(&pModLX->Hdr, &Hdr, sizeof(Hdr));
-
-    pModLX->pbLoaderSection = (uint8_t *)pModLX + offLdrStuff;
+    memcpy(&pModLX->Hdr, &Hdr, sizeof(Hdr));
+
+    pModLX->pbLoaderSection = (uint8_t *)pModLX + cbModLXAndSegments;
     pModLX->pbLoaderSectionLast = pModLX->pbLoaderSection + pModLX->Hdr.e32_ldrsize - 1;
     pModLX->paObjs = NULL;
@@ -376,9 +342,9 @@
      * Read the loader data.
      */
-    rc = kRdrRead(pRdr, (void *)pModLX->pbLoaderSection, pModLX->Hdr.e32_ldrsize, pModLX->Hdr.e32_objtab + pModLX->offHdr);
+    rc = pRdr->pfnRead(pRdr, (void *)pModLX->pbLoaderSection, pModLX->Hdr.e32_ldrsize, pModLX->Hdr.e32_objtab + pModLX->offHdr);
     if (rc)
         return rc;
-    ((KU8 *)pModLX->pbLoaderSectionLast)[1] = 0;
-    ((KU8 *)pModLX->pbLoaderSectionLast)[2] = 0;
+    ((uint8_t *)pModLX->pbLoaderSectionLast)[1] = 0;
+    ((uint8_t *)pModLX->pbLoaderSectionLast)[2] = 0;
     if (pModLX->Hdr.e32_objcnt)
         pModLX->paObjs = (const struct o32_obj *)pModLX->pbLoaderSection;
@@ -399,36 +365,36 @@
      */
     if (pModLX->pbResNameTab)
-        pMod->pszName = (const char *)kldrModLXDoNameTableLookupByOrdinal(pModLX->pbResNameTab,
-                                                                          pModLX->pbLoaderSectionLast - pModLX->pbResNameTab + 1,
-                                                                          0);
-    if (!pMod->pszName)
-        return KLDR_ERR_LX_NO_SONAME;
-    pMod->cchName = *(const KU8 *)pMod->pszName++;
-    if (pMod->cchName != kHlpStrLen(pMod->pszName))
-        return KLDR_ERR_LX_BAD_SONAME;
+        pModLX->pszName = (const char *)kldrModLXDoNameTableLookupByOrdinal(pModLX->pbResNameTab,
+                                                                            pModLX->pbLoaderSectionLast - pModLX->pbResNameTab + 1,
+                                                                            0);
+    if (!pModLX->pszName)
+        return VERR_LDRLX_NO_SONAME;
+    pModLX->cchName = *(const uint8_t *)pModLX->pszName++;
+    if (   pModLX->pszName[pModLX->cchName] != '\0'
+        || pModLX->cchName != strlen(pModLX->pszName))
+        return VERR_LDRLX_BAD_SONAME;
 
     /*
      * Quick validation of the object table.
      */
-    cb = 0;
-    for (i = 0; i < pMod->cSegments; i++)
+    for (i = 0; i < pModLX->cSegments; i++)
     {
         if (pModLX->paObjs[i].o32_base & (OBJPAGELEN - 1))
-            return KLDR_ERR_LX_BAD_OBJECT_TABLE;
+            return VERR_LDRLX_BAD_OBJECT_TABLE;
         if (pModLX->paObjs[i].o32_base + pModLX->paObjs[i].o32_size <= pModLX->paObjs[i].o32_base)
-            return KLDR_ERR_LX_BAD_OBJECT_TABLE;
+            return VERR_LDRLX_BAD_OBJECT_TABLE;
         if (pModLX->paObjs[i].o32_mapsize > (pModLX->paObjs[i].o32_size + (OBJPAGELEN - 1)))
-            return KLDR_ERR_LX_BAD_OBJECT_TABLE;
+            return VERR_LDRLX_BAD_OBJECT_TABLE;
         if (    pModLX->paObjs[i].o32_mapsize
-            &&  (   (KU8 *)&pModLX->paPageMappings[pModLX->paObjs[i].o32_pagemap] > pModLX->pbLoaderSectionLast
-                 || (KU8 *)&pModLX->paPageMappings[pModLX->paObjs[i].o32_pagemap + pModLX->paObjs[i].o32_mapsize]
+            &&  (   (uint8_t *)&pModLX->paPageMappings[pModLX->paObjs[i].o32_pagemap] > pModLX->pbLoaderSectionLast
+                 || (uint8_t *)&pModLX->paPageMappings[pModLX->paObjs[i].o32_pagemap + pModLX->paObjs[i].o32_mapsize]
                      > pModLX->pbLoaderSectionLast))
-            return KLDR_ERR_LX_BAD_OBJECT_TABLE;
+            return VERR_LDRLX_BAD_OBJECT_TABLE;
         if (i > 0 && !(pModLX->paObjs[i].o32_flags & OBJRSRC))
         {
             if (pModLX->paObjs[i].o32_base <= pModLX->paObjs[i - 1].o32_base)
-                return KLDR_ERR_LX_BAD_OBJECT_TABLE;
+                return VERR_LDRLX_BAD_OBJECT_TABLE;
             if (pModLX->paObjs[i].o32_base < pModLX->paObjs[i - 1].o32_base + pModLX->paObjs[i - 1].o32_mapsize)
-                return KLDR_ERR_LX_BAD_OBJECT_TABLE;
+                return VERR_LDRLX_BAD_OBJECT_TABLE;
         }
     }
@@ -445,40 +411,37 @@
      * Setup the KLDRMOD segment array.
      */
-    for (i = 0; i < pMod->cSegments; i++)
+    for (i = 0; i < pModLX->cSegments; i++)
     {
         /* unused */
-        pMod->aSegments[i].pvUser = NULL;
-        pMod->aSegments[i].MapAddress = 0;
-        pMod->aSegments[i].pchName = NULL;
-        pMod->aSegments[i].cchName = 0;
-        pMod->aSegments[i].offFile = -1;
-        pMod->aSegments[i].cbFile = -1;
-        pMod->aSegments[i].SelFlat = 0;
-        pMod->aSegments[i].Sel16bit = 0;
+        pModLX->aSegments[i].pszName    = NULL;
+        pModLX->aSegments[i].offFile    = -1;
+        pModLX->aSegments[i].cbFile     = -1;
+        pModLX->aSegments[i].SelFlat    = 0;
+        pModLX->aSegments[i].Sel16bit   = 0;
 
         /* flags */
-        pMod->aSegments[i].fFlags = 0;
+        pModLX->aSegments[i].fFlags = 0;
         if (pModLX->paObjs[i].o32_flags & OBJBIGDEF)
-            pMod->aSegments[i].fFlags = KLDRSEG_FLAG_16BIT;
+            pModLX->aSegments[i].fFlags = RTLDRSEG_FLAG_16BIT;
         if (pModLX->paObjs[i].o32_flags & OBJALIAS16)
-            pMod->aSegments[i].fFlags = KLDRSEG_FLAG_OS2_ALIAS16;
+            pModLX->aSegments[i].fFlags = RTLDRSEG_FLAG_OS2_ALIAS16;
         if (pModLX->paObjs[i].o32_flags & OBJCONFORM)
-            pMod->aSegments[i].fFlags = KLDRSEG_FLAG_OS2_CONFORM;
+            pModLX->aSegments[i].fFlags = RTLDRSEG_FLAG_OS2_CONFORM;
         if (pModLX->paObjs[i].o32_flags & OBJIOPL)
-            pMod->aSegments[i].fFlags = KLDRSEG_FLAG_OS2_IOPL;
+            pModLX->aSegments[i].fFlags = RTLDRSEG_FLAG_OS2_IOPL;
 
         /* size and addresses */
-        pMod->aSegments[i].Alignment   = OBJPAGELEN;
-        pMod->aSegments[i].cb          = pModLX->paObjs[i].o32_size;
-        pMod->aSegments[i].LinkAddress = pModLX->paObjs[i].o32_base;
-        pMod->aSegments[i].RVA         = NextRVA;
+        pModLX->aSegments[i].Alignment   = OBJPAGELEN;
+        pModLX->aSegments[i].cb          = pModLX->paObjs[i].o32_size;
+        pModLX->aSegments[i].LinkAddress = pModLX->paObjs[i].o32_base;
+        pModLX->aSegments[i].RVA         = NextRVA;
         if (    fCanOptimizeMapping
-            ||  i + 1 >= pMod->cSegments
+            ||  i + 1 >= pModLX->cSegments
             ||  (pModLX->paObjs[i].o32_flags & OBJRSRC)
             ||  (pModLX->paObjs[i + 1].o32_flags & OBJRSRC))
-            pMod->aSegments[i].cbMapped = K_ALIGN_Z(pModLX->paObjs[i].o32_size, OBJPAGELEN);
+            pModLX->aSegments[i].cbMapped = RT_ALIGN_Z(pModLX->paObjs[i].o32_size, OBJPAGELEN);
         else
-            pMod->aSegments[i].cbMapped = pModLX->paObjs[i + 1].o32_base - pModLX->paObjs[i].o32_base;
-        NextRVA += (KU32)pMod->aSegments[i].cbMapped;
+            pModLX->aSegments[i].cbMapped = pModLX->paObjs[i + 1].o32_base - pModLX->paObjs[i].o32_base;
+        NextRVA += (uint32_t)pModLX->aSegments[i].cbMapped;
 
         /* protection */
@@ -488,40 +451,40 @@
             case 0:
             case OBJSHARED:
-                pMod->aSegments[i].enmProt = KPROT_NOACCESS;
+                pModLX->aSegments[i].fProt = 0;
                 break;
             case OBJREAD:
             case OBJREAD | OBJSHARED:
-                pMod->aSegments[i].enmProt = KPROT_READONLY;
+                pModLX->aSegments[i].fProt = RTMEM_PROT_READ;
                 break;
             case OBJWRITE:
             case OBJWRITE | OBJREAD:
-                pMod->aSegments[i].enmProt = KPROT_WRITECOPY;
+                pModLX->aSegments[i].fProt = RTMEM_PROT_READ | RTMEM_PROT_WRITECOPY;
                 break;
             case OBJWRITE | OBJSHARED:
             case OBJWRITE | OBJSHARED | OBJREAD:
-                pMod->aSegments[i].enmProt = KPROT_READWRITE;
+                pModLX->aSegments[i].fProt = RTMEM_PROT_READ | RTMEM_PROT_WRITE;
                 break;
             case OBJEXEC:
             case OBJEXEC | OBJSHARED:
-                pMod->aSegments[i].enmProt = KPROT_EXECUTE;
+                pModLX->aSegments[i].fProt = RTMEM_PROT_EXEC;
                 break;
             case OBJEXEC | OBJREAD:
             case OBJEXEC | OBJREAD | OBJSHARED:
-                pMod->aSegments[i].enmProt = KPROT_EXECUTE_READ;
+                pModLX->aSegments[i].fProt = RTMEM_PROT_EXEC | RTMEM_PROT_READ;
                 break;
             case OBJEXEC | OBJWRITE:
             case OBJEXEC | OBJWRITE | OBJREAD:
-                pMod->aSegments[i].enmProt = KPROT_EXECUTE_WRITECOPY;
+                pModLX->aSegments[i].fProt = RTMEM_PROT_EXEC | RTMEM_PROT_READ | RTMEM_PROT_WRITECOPY;
                 break;
             case OBJEXEC | OBJWRITE | OBJSHARED:
             case OBJEXEC | OBJWRITE | OBJSHARED | OBJREAD:
-                pMod->aSegments[i].enmProt = KPROT_EXECUTE_READWRITE;
+                pModLX->aSegments[i].fProt = RTMEM_PROT_EXEC | RTMEM_PROT_READ | RTMEM_PROT_WRITE;
                 break;
         }
         if ((pModLX->paObjs[i].o32_flags & (OBJREAD | OBJWRITE | OBJEXEC | OBJRSRC)) == OBJRSRC)
-            pMod->aSegments[i].enmProt = KPROT_READONLY;
-        /*pMod->aSegments[i].f16bit = !(pModLX->paObjs[i].o32_flags & OBJBIGDEF)
-        pMod->aSegments[i].fIOPL = !(pModLX->paObjs[i].o32_flags & OBJIOPL)
-        pMod->aSegments[i].fConforming = !(pModLX->paObjs[i].o32_flags & OBJCONFORM) */
+            pModLX->aSegments[i].fProt = RTMEM_PROT_READ;
+        /*pModLX->aSegments[i].f16bit = !(pModLX->paObjs[i].o32_flags & OBJBIGDEF)
+        pModLX->aSegments[i].fIOPL = !(pModLX->paObjs[i].o32_flags & OBJIOPL)
+        pModLX->aSegments[i].fConforming = !(pModLX->paObjs[i].o32_flags & OBJCONFORM) */
     }
 
@@ -533,33 +496,35 @@
      */
     *ppModLX = pModLX;
-    return 0;
-}
-
-
-/** @copydoc KLDRMODOPS::pfnDestroy */
-static int kldrModLXDestroy(PKLDRMOD pMod)
-{
-    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
-    int rc = 0;
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnClose}
+ */
+static DECLCALLBACK(int) rtldrLX_Close(PRTLDRMODINTERNAL pMod)
+{
+    PKLDRMODLX pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
     KLDRMODLX_ASSERT(!pModLX->pvMapping);
 
-    if (pMod->pRdr)
-    {
-        rc = kRdrClose(pMod->pRdr);
-        pMod->pRdr = NULL;
+    int rc = VINF_SUCCESS;
+    if (pModLX->Core.pReader)
+    {
+        rc = pModLX->Core.pReader->pfnDestroy(pModLX->Core.pReader);
+        pModLX->Core.pReader = NULL;
     }
     if (pModLX->pbNonResNameTab)
     {
-        kHlpFree(pModLX->pbNonResNameTab);
+        RTMemFree(pModLX->pbNonResNameTab);
         pModLX->pbNonResNameTab = NULL;
     }
     if (pModLX->pbFixupSection)
     {
-        kHlpFree(pModLX->pbFixupSection);
+        RTMemFree(pModLX->pbFixupSection);
         pModLX->pbFixupSection = NULL;
     }
-    pMod->u32Magic = 0;
-    pMod->pOps = NULL;
-    kHlpFree(pModLX);
+    pModLX->Core.u32Magic = 0;
+    pModLX->Core.pOps = NULL;
+    RTMemFree(pModLX);
     return rc;
 }
@@ -572,24 +537,22 @@
  * @param   pBaseAddress    The base address, IN & OUT.
  */
-static void kldrModLXResolveBaseAddress(PKLDRMODLX pModLX, PKLDRADDR pBaseAddress)
-{
-    if (*pBaseAddress == KLDRMOD_BASEADDRESS_MAP)
-        *pBaseAddress = pModLX->pMod->aSegments[0].MapAddress;
-    else if (*pBaseAddress == KLDRMOD_BASEADDRESS_LINK)
-        *pBaseAddress = pModLX->pMod->aSegments[0].LinkAddress;
+static void kldrModLXResolveBaseAddress(PKLDRMODLX pModLX, PRTLDRADDR pBaseAddress)
+{
+    if (*pBaseAddress == RTLDR_BASEADDRESS_LINK)
+        *pBaseAddress = pModLX->aSegments[0].LinkAddress;
 }
 
 
 /** @copydoc kLdrModQuerySymbol */
-static int kldrModLXQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 iSymbol,
-                                const char *pchSymbol, KSIZE cchSymbol, const char *pszVersion,
-                                PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind)
-{
-    PKLDRMODLX                  pModLX = (PKLDRMODLX)pMod->pvData;
-    KU32                        iOrdinal;
+static int kldrModLXQuerySymbol(PRTLDRMODINTERNAL pMod, const void *pvBits, RTLDRADDR BaseAddress, uint32_t iSymbol,
+                                const char *pchSymbol, size_t cchSymbol, const char *pszVersion,
+                                PFNRTLDRIMPORT pfnGetForwarder, void *pvUser, PRTLDRADDR puValue, uint32_t *pfKind)
+{
+    PKLDRMODLX                  pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    uint32_t                    iOrdinal;
     int                         rc;
-    const struct b32_bundle     *pBundle;
-    K_NOREF(pvBits);
-    K_NOREF(pszVersion);
+    const struct b32_bundle    *pBundle;
+    RT_NOREF(pvBits);
+    RT_NOREF(pszVersion);
 
     /*
@@ -597,5 +560,5 @@
      */
     if (!pModLX->Hdr.e32_enttab)
-        return KLDR_ERR_SYMBOL_NOT_FOUND;
+        return VERR_SYMBOL_NOT_FOUND;
 
     /*
@@ -617,5 +580,5 @@
     while (pBundle->b32_cnt && iOrdinal <= iSymbol)
     {
-        static const KSIZE s_cbEntry[] = { 0, 3, 5, 5, 7 };
+        static const size_t s_cbEntry[] = { 0, 3, 5, 5, 7 };
 
         /*
@@ -625,6 +588,6 @@
         if (iSymbol < iOrdinal)
         {
-            KU32 offObject;
-            const struct e32_entry *pEntry = (const struct e32_entry *)((KUPTR)(pBundle + 1)
+            uint32_t offObject;
+            const struct e32_entry *pEntry = (const struct e32_entry *)((uintptr_t)(pBundle + 1)
                                                                         +   (iSymbol - (iOrdinal - pBundle->b32_cnt))
                                                                           * s_cbEntry[pBundle->b32_type]);
@@ -638,5 +601,5 @@
                 /* empty bundles are place holders unused ordinal ranges. */
                 case EMPTY:
-                    return KLDR_ERR_SYMBOL_NOT_FOUND;
+                    return VERR_SYMBOL_NOT_FOUND;
 
                 /* e32_flags + a 16-bit offset. */
@@ -644,5 +607,5 @@
                     offObject = pEntry->e32_variant.e32_offset.offset16;
                     if (pfKind)
-                        *pfKind = KLDRSYMKIND_16BIT | KLDRSYMKIND_NO_TYPE;
+                        *pfKind = RTLDRSYMKIND_16BIT | RTLDRSYMKIND_NO_TYPE;
                     break;
 
@@ -651,5 +614,5 @@
                     offObject = pEntry->e32_variant.e32_callgate.offset;
                     if (pfKind)
-                        *pfKind = KLDRSYMKIND_16BIT | KLDRSYMKIND_CODE;
+                        *pfKind = RTLDRSYMKIND_16BIT | RTLDRSYMKIND_CODE;
                     break;
 
@@ -658,5 +621,5 @@
                     offObject = pEntry->e32_variant.e32_offset.offset32;
                     if (pfKind)
-                        *pfKind = KLDRSYMKIND_32BIT;
+                        *pfKind = RTLDRSYMKIND_32BIT;
                     break;
 
@@ -668,5 +631,5 @@
                     /* anyone actually using TYPEINFO will end up here. */
                     KLDRMODLX_ASSERT(!"Bad bundle type");
-                    return KLDR_ERR_LX_BAD_BUNDLE;
+                    return VERR_LDRLX_BAD_BUNDLE;
             }
 
@@ -675,10 +638,10 @@
              */
             if (    pBundle->b32_obj <= 0
-                ||  pBundle->b32_obj > pMod->cSegments)
-                return KLDR_ERR_LX_BAD_BUNDLE;
+                ||  pBundle->b32_obj > pModLX->cSegments)
+                return VERR_LDRLX_BAD_BUNDLE;
             if (puValue)
                 *puValue = BaseAddress
                          + offObject
-                         + pMod->aSegments[pBundle->b32_obj - 1].RVA;
+                         + pModLX->aSegments[pBundle->b32_obj - 1].RVA;
             return 0;
         }
@@ -690,13 +653,25 @@
         {
             KLDRMODLX_ASSERT(!"Bad type"); /** @todo figure out TYPEINFO. */
-            return KLDR_ERR_LX_BAD_BUNDLE;
+            return VERR_LDRLX_BAD_BUNDLE;
         }
         if (pBundle->b32_type == 0)
-            pBundle = (const struct b32_bundle *)((const KU8 *)pBundle + 2);
+            pBundle = (const struct b32_bundle *)((const uint8_t *)pBundle + 2);
         else
-            pBundle = (const struct b32_bundle *)((const KU8 *)(pBundle + 1) + s_cbEntry[pBundle->b32_type] * pBundle->b32_cnt);
-    }
-
-    return KLDR_ERR_SYMBOL_NOT_FOUND;
+            pBundle = (const struct b32_bundle *)((const uint8_t *)(pBundle + 1) + s_cbEntry[pBundle->b32_type] * pBundle->b32_cnt);
+    }
+
+    return VERR_SYMBOL_NOT_FOUND;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnGetSymbolEx}
+ */
+static DECLCALLBACK(int) rtldrLX_GetSymbolEx(PRTLDRMODINTERNAL pMod, const void *pvBits, RTUINTPTR BaseAddress,
+                                             uint32_t iOrdinal, const char *pszSymbol, RTUINTPTR *pValue)
+{
+    uint32_t fKind = RTLDRSYMKIND_REQ_FLAT;
+    return kldrModLXQuerySymbol(pMod, pvBits, BaseAddress, iOrdinal, pszSymbol, pszSymbol ? strlen(pszSymbol) : 0,
+                                NULL, NULL, NULL, pValue, &fKind);
 }
 
@@ -711,5 +686,5 @@
  * @param   piSymbol    Where to store the symbol ordinal.
  */
-static int kldrModLXDoNameLookup(PKLDRMODLX pModLX, const char *pchSymbol, KSIZE cchSymbol, KU32 *piSymbol)
+static int kldrModLXDoNameLookup(PKLDRMODLX pModLX, const char *pchSymbol, size_t cchSymbol, uint32_t *piSymbol)
 {
 
@@ -722,5 +697,5 @@
      * Search the name tables.
      */
-    const KU8 *pbName = kldrModLXDoNameTableLookupByName(pModLX->pbResNameTab,
+    const uint8_t *pbName = kldrModLXDoNameTableLookupByName(pModLX->pbResNameTab,
                                                          pModLX->pbLoaderSectionLast - pModLX->pbResNameTab + 1,
                                                          pchSymbol, cchSymbol);
@@ -738,40 +713,9 @@
     }
     if (!pbName)
-        return KLDR_ERR_SYMBOL_NOT_FOUND;
-
-    *piSymbol = *(const KU16 *)(pbName + 1 + *pbName);
+        return VERR_SYMBOL_NOT_FOUND;
+
+    *piSymbol = *(const uint16_t *)(pbName + 1 + *pbName);
     return 0;
 }
-
-
-#if 0
-/**
- * Hash a symbol using the algorithm from sdbm.
- *
- * The following was is the documenation of the orignal sdbm functions:
- *
- * This algorithm was created for sdbm (a public-domain reimplementation of
- * ndbm) database library. it was found to do well in scrambling bits,
- * causing better distribution of the keys and fewer splits. it also happens
- * to be a good general hashing function with good distribution. the actual
- * function is hash(i) = hash(i - 1) * 65599 + str[i]; what is included below
- * is the faster version used in gawk. [there is even a faster, duff-device
- * version] the magic constant 65599 was picked out of thin air while
- * experimenting with different constants, and turns out to be a prime.
- * this is one of the algorithms used in berkeley db (see sleepycat) and
- * elsewhere.
- */
-static KU32 kldrModLXDoHash(const char *pchSymbol, KU8 cchSymbol)
-{
-    KU32 hash = 0;
-    int ch;
-
-    while (     cchSymbol-- > 0
-           &&   (ch = *(unsigned const char *)pchSymbol++))
-        hash = ch + (hash << 6) + (hash << 16) - hash;
-
-    return hash;
-}
-#endif
 
 
@@ -786,11 +730,11 @@
  * @param   cchSymbol       The length of the symbol name.
  */
-static const KU8 *kldrModLXDoNameTableLookupByName(const KU8 *pbNameTable, KSSIZE cbNameTable,
-                                                   const char *pchSymbol, KSIZE cchSymbol)
+static const uint8_t *kldrModLXDoNameTableLookupByName(const uint8_t *pbNameTable, ssize_t cbNameTable,
+                                                       const char *pchSymbol, size_t cchSymbol)
 {
     /*
      * Determin the namelength up front so we can skip anything which doesn't matches the length.
      */
-    KU8 cbSymbol8Bit = (KU8)cchSymbol;
+    uint8_t cbSymbol8Bit = (uint8_t)cchSymbol;
     if (cbSymbol8Bit != cchSymbol)
         return NULL; /* too long. */
@@ -801,5 +745,5 @@
     while (*pbNameTable != 0 && cbNameTable > 0)
     {
-        const KU8 cbName = *pbNameTable;
+        const uint8_t cbName = *pbNameTable;
 
         cbNameTable -= cbName + 1 + 2;
@@ -808,5 +752,5 @@
 
         if (    cbName == cbSymbol8Bit
-            &&  !kHlpMemComp(pbNameTable + 1, pchSymbol, cbName))
+            &&  !memcmp(pbNameTable + 1, pchSymbol, cbName))
             return pbNameTable;
 
@@ -831,13 +775,8 @@
  */
 static int kldrModLXDoForwarderQuery(PKLDRMODLX pModLX, const struct e32_entry *pEntry,
-                                     PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind)
-{
-    int rc;
-    KU32 iSymbol;
-    const char *pchSymbol;
-    KU8 cchSymbol;
-
+                                     PFNRTLDRIMPORT pfnGetForwarder, void *pvUser, PRTLDRADDR puValue, uint32_t *pfKind)
+{
     if (!pfnGetForwarder)
-        return KLDR_ERR_FORWARDER_SYMBOL;
+        return VERR_LDR_FORWARDER;
 
     /*
@@ -846,18 +785,25 @@
     if (    !pEntry->e32_variant.e32_fwd.modord
         ||  pEntry->e32_variant.e32_fwd.modord > pModLX->Hdr.e32_impmodcnt)
-        return KLDR_ERR_LX_BAD_FORWARDER;
+        return VERR_LDRLX_BAD_FORWARDER;
+
+    char szImpModule[256];
+    int rc = kldrModLXGetImport(pModLX, NULL, pEntry->e32_variant.e32_fwd.modord - 1, szImpModule, sizeof(szImpModule), NULL);
+    if (RT_FAILURE(rc))
+        return rc;
 
     /*
      * Figure out the parameters.
      */
+    uint32_t    iSymbol;
+    const char *pszSymbol;
+    char        szSymbol[256];
     if (pEntry->e32_flags & FWD_ORDINAL)
     {
         iSymbol = pEntry->e32_variant.e32_fwd.value;
-        pchSymbol = NULL;                   /* no symbol name. */
-        cchSymbol = 0;
+        pszSymbol = NULL;                   /* no symbol name. */
     }
     else
     {
-        const KU8 *pbName;
+        const uint8_t *pbName;
 
         /* load the fixup section if necessary. */
@@ -874,5 +820,5 @@
             ||  pbName < pModLX->pbFixupSection
             || !*pbName)
-            return KLDR_ERR_LX_BAD_FORWARDER;
+            return VERR_LDRLX_BAD_FORWARDER;
 
 
@@ -880,6 +826,6 @@
         if (pbName[1] == '#')
         {
-            KU8         cbLeft = *pbName;
-            const KU8  *pb = pbName + 1;
+            uint8_t         cbLeft = *pbName;
+            const uint8_t  *pb = pbName + 1;
             unsigned    uBase;
 
@@ -910,7 +856,7 @@
                     break;
                 else
-                    return KLDR_ERR_LX_BAD_FORWARDER;
+                    return VERR_LDRLX_BAD_FORWARDER;
                 if (uDigit >= uBase)
-                    return KLDR_ERR_LX_BAD_FORWARDER;
+                    return VERR_LDRLX_BAD_FORWARDER;
 
                 /* insert the digit */
@@ -919,14 +865,14 @@
             }
             if (!iSymbol)
-                return KLDR_ERR_LX_BAD_FORWARDER;
-
-            pchSymbol = NULL;               /* no symbol name. */
-            cchSymbol = 0;
+                return VERR_LDRLX_BAD_FORWARDER;
+
+            pszSymbol = NULL;               /* no symbol name. */
         }
         else
         {
-            pchSymbol = (char *)pbName + 1;
-            cchSymbol = *pbName;
-            iSymbol = NIL_KLDRMOD_SYM_ORDINAL;
+            memcpy(szSymbol, pbName + 1, *pbName);
+            szSymbol[*pbName] = '\0';
+            pszSymbol = szSymbol;
+            iSymbol = UINT32_MAX;
         }
     }
@@ -935,7 +881,7 @@
      * Resolve the forwarder.
      */
-    rc = pfnGetForwarder(pModLX->pMod, pEntry->e32_variant.e32_fwd.modord - 1, iSymbol, pchSymbol, cchSymbol, NULL, puValue, pfKind, pvUser);
-    if (!rc && pfKind)
-        *pfKind |= KLDRSYMKIND_FORWARDER;
+    rc = pfnGetForwarder(&pModLX->Core, szImpModule, pszSymbol, iSymbol, puValue, /*pfKind, */pvUser);
+    if (RT_SUCCESS(rc) && pfKind)
+        *pfKind |= RTLDRSYMKIND_FORWARDER;
     return rc;
 }
@@ -952,22 +898,18 @@
 static int kldrModLXDoLoadFixupSection(PKLDRMODLX pModLX)
 {
-    int rc;
-    KU32 off;
-    void *pv;
-
-    pv = kHlpAlloc(pModLX->Hdr.e32_fixupsize);
+    void *pv = RTMemAlloc(pModLX->Hdr.e32_fixupsize);
     if (!pv)
-        return KERR_NO_MEMORY;
-
-    off = pModLX->Hdr.e32_objtab + pModLX->Hdr.e32_ldrsize;
-    rc = kRdrRead(pModLX->pMod->pRdr, pv, pModLX->Hdr.e32_fixupsize,
-                     off + pModLX->offHdr);
-    if (!rc)
-    {
-        pModLX->pbFixupSection = pv;
+        return VERR_NO_MEMORY;
+
+    uint32_t off = pModLX->Hdr.e32_objtab + pModLX->Hdr.e32_ldrsize;
+    int rc = pModLX->Core.pReader->pfnRead(pModLX->Core.pReader, pv, pModLX->Hdr.e32_fixupsize,
+                                           off + pModLX->offHdr);
+    if (RT_SUCCESS(rc))
+    {
+        pModLX->pbFixupSection = (uint8_t *)pv;
         pModLX->pbFixupSectionLast = pModLX->pbFixupSection + pModLX->Hdr.e32_fixupsize;
         KLDRMODLX_ASSERT(!pModLX->paoffPageFixups);
         if (pModLX->Hdr.e32_fpagetab)
-            pModLX->paoffPageFixups = (const KU32 *)(pModLX->pbFixupSection + pModLX->Hdr.e32_fpagetab - off);
+            pModLX->paoffPageFixups = (const uint32_t *)(pModLX->pbFixupSection + pModLX->Hdr.e32_fpagetab - off);
         KLDRMODLX_ASSERT(!pModLX->pbFixupRecs);
         if (pModLX->Hdr.e32_frectab)
@@ -981,19 +923,18 @@
     }
     else
-        kHlpFree(pv);
+        RTMemFree(pv);
     return rc;
 }
 
 
-/** @copydoc kLdrModEnumSymbols */
-static int kldrModLXEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress,
-                                KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser)
-{
-    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
-    const struct b32_bundle *pBundle;
-    KU32 iOrdinal;
-    int rc = 0;
-    K_NOREF(pvBits);
-    K_NOREF(fFlags);
+/**
+ * @interface_method_impl{RTLDROPS,pfnEnumSymbols}
+ */
+static DECLCALLBACK(int) rtldrLX_EnumSymbols(PRTLDRMODINTERNAL pMod, unsigned fFlags, const void *pvBits,
+                                             RTUINTPTR BaseAddress, PFNRTLDRENUMSYMS pfnCallback, void *pvUser)
+{
+    PKLDRMODLX pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    RT_NOREF(pvBits);
+    RT_NOREF(fFlags);
 
     kldrModLXResolveBaseAddress(pModLX, &BaseAddress);
@@ -1003,9 +944,10 @@
      * (The entry table is made up of bundles of similar exports.)
      */
-    iOrdinal = 1;
-    pBundle = (const struct b32_bundle *)pModLX->pbEntryTab;
+    int                      rc       = VINF_SUCCESS;
+    uint32_t                 iOrdinal = 1;
+    const struct b32_bundle *pBundle  = (const struct b32_bundle *)pModLX->pbEntryTab;
     while (pBundle->b32_cnt && iOrdinal)
     {
-        static const KSIZE s_cbEntry[] = { 0, 3, 5, 5, 7 };
+        static const size_t s_cbEntry[] = { 0, 3, 5, 5, 7 };
 
         /*
@@ -1015,6 +957,6 @@
         {
             const struct e32_entry *pEntry;
-            KSIZE cbEntry;
-            KLDRADDR BundleRVA;
+            size_t cbEntry;
+            RTLDRADDR BundleRVA;
             unsigned cLeft;
 
@@ -1027,7 +969,7 @@
                 case ENTRY32:
                     if (    pBundle->b32_obj <= 0
-                        ||  pBundle->b32_obj > pMod->cSegments)
-                        return KLDR_ERR_LX_BAD_BUNDLE;
-                    BundleRVA = pMod->aSegments[pBundle->b32_obj - 1].RVA;
+                        ||  pBundle->b32_obj > pModLX->cSegments)
+                        return VERR_LDRLX_BAD_BUNDLE;
+                    BundleRVA = pModLX->aSegments[pBundle->b32_obj - 1].RVA;
                     break;
 
@@ -1039,5 +981,5 @@
                     /* anyone actually using TYPEINFO will end up here. */
                     KLDRMODLX_ASSERT(!"Bad bundle type");
-                    return KLDR_ERR_LX_BAD_BUNDLE;
+                    return VERR_LDRLX_BAD_BUNDLE;
             }
 
@@ -1048,8 +990,8 @@
             while (cLeft-- > 0)
             {
-                KLDRADDR uValue;
-                KU32 fKind;
+                RTLDRADDR uValue;
+                uint32_t fKind;
                 int fFoundName;
-                const KU8 *pbName;
+                const uint8_t *pbName;
 
                 /*
@@ -1061,5 +1003,5 @@
                     case ENTRY16:
                         uValue = BaseAddress + BundleRVA + pEntry->e32_variant.e32_offset.offset16;
-                        fKind = KLDRSYMKIND_16BIT | KLDRSYMKIND_NO_TYPE;
+                        fKind = RTLDRSYMKIND_16BIT | RTLDRSYMKIND_NO_TYPE;
                         break;
 
@@ -1067,5 +1009,5 @@
                     case GATE16:
                         uValue = BaseAddress + BundleRVA + pEntry->e32_variant.e32_callgate.offset;
-                        fKind = KLDRSYMKIND_16BIT | KLDRSYMKIND_CODE;
+                        fKind = RTLDRSYMKIND_16BIT | RTLDRSYMKIND_CODE;
                         break;
 
@@ -1073,5 +1015,5 @@
                     case ENTRY32:
                         uValue = BaseAddress + BundleRVA + pEntry->e32_variant.e32_offset.offset32;
-                        fKind = KLDRSYMKIND_32BIT;
+                        fKind = RTLDRSYMKIND_32BIT;
                         break;
 
@@ -1079,10 +1021,10 @@
                     case ENTRYFWD:
                         uValue = 0; /** @todo implement enumeration of forwarders properly. */
-                        fKind = KLDRSYMKIND_FORWARDER;
+                        fKind = RTLDRSYMKIND_FORWARDER;
                         break;
 
                     default: /* shut up gcc. */
                         uValue = 0;
-                        fKind = KLDRSYMKIND_NO_BIT | KLDRSYMKIND_NO_TYPE;
+                        fKind = RTLDRSYMKIND_NO_BIT | RTLDRSYMKIND_NO_TYPE;
                         break;
                 }
@@ -1092,4 +1034,5 @@
                  */
                 fFoundName = 0;
+                char szName[256];
 
                 /* resident name table. */
@@ -1103,5 +1046,7 @@
                             break;
                         fFoundName = 1;
-                        rc = pfnCallback(pMod, iOrdinal, (const char *)pbName + 1, *pbName, NULL, uValue, fKind, pvUser);
+                        memcpy(szName, (const char *)pbName + 1, *pbName);
+                        szName[*pbName] = '\0';
+                        rc = pfnCallback(pMod, szName, iOrdinal, uValue, /*fKind,*/ pvUser);
                         if (rc)
                             return rc;
@@ -1123,5 +1068,7 @@
                             break;
                         fFoundName = 1;
-                        rc = pfnCallback(pMod, iOrdinal, (const char *)pbName + 1, *pbName, NULL, uValue, fKind, pvUser);
+                        memcpy(szName, (const char *)pbName + 1, *pbName);
+                        szName[*pbName] = '\0';
+                        rc = pfnCallback(pMod, szName, iOrdinal, uValue, /*fKind,*/ pvUser);
                         if (rc)
                             return rc;
@@ -1137,5 +1084,6 @@
                 if (!fFoundName)
                 {
-                    rc = pfnCallback(pMod, iOrdinal, NULL, 0, NULL, uValue, fKind, pvUser);
+                    RT_NOREF(fKind);
+                    rc = pfnCallback(pMod, NULL /*pszName*/, iOrdinal, uValue, /*fKind,*/ pvUser);
                     if (rc)
                         return rc;
@@ -1144,5 +1092,5 @@
                 /* next */
                 iOrdinal++;
-                pEntry = (const struct e32_entry *)((KUPTR)pEntry + cbEntry);
+                pEntry = (const struct e32_entry *)((uintptr_t)pEntry + cbEntry);
             }
         }
@@ -1154,10 +1102,10 @@
         {
             KLDRMODLX_ASSERT(!"Bad type"); /** @todo figure out TYPEINFO. */
-            return KLDR_ERR_LX_BAD_BUNDLE;
+            return VERR_LDRLX_BAD_BUNDLE;
         }
         if (pBundle->b32_type == 0)
-            pBundle = (const struct b32_bundle *)((const KU8 *)pBundle + 2);
+            pBundle = (const struct b32_bundle *)((const uint8_t *)pBundle + 2);
         else
-            pBundle = (const struct b32_bundle *)((const KU8 *)(pBundle + 1) + s_cbEntry[pBundle->b32_type] * pBundle->b32_cnt);
+            pBundle = (const struct b32_bundle *)((const uint8_t *)(pBundle + 1) + s_cbEntry[pBundle->b32_type] * pBundle->b32_cnt);
     }
 
@@ -1175,10 +1123,10 @@
  * @param   iOrdinal    The ordinal to search for.
  */
-static const KU8 *kldrModLXDoNameTableLookupByOrdinal(const KU8 *pbNameTable, KSSIZE cbNameTable, KU32 iOrdinal)
+static const uint8_t *kldrModLXDoNameTableLookupByOrdinal(const uint8_t *pbNameTable, ssize_t cbNameTable, uint32_t iOrdinal)
 {
     while (*pbNameTable != 0 && cbNameTable > 0)
     {
-        const KU8   cbName = *pbNameTable;
-        KU32        iName;
+        const uint8_t   cbName = *pbNameTable;
+        uint32_t        iName;
 
         cbNameTable -= cbName + 1 + 2;
@@ -1200,10 +1148,10 @@
 
 /** @copydoc kLdrModGetImport */
-static int kldrModLXGetImport(PKLDRMOD pMod, const void *pvBits, KU32 iImport, char *pszName, KSIZE cchName)
-{
-    PKLDRMODLX  pModLX = (PKLDRMODLX)pMod->pvData;
-    const KU8  *pb;
-    int         rc;
-    K_NOREF(pvBits);
+static int kldrModLXGetImport(PKLDRMODLX pModLX, const void *pvBits, uint32_t iImport, char *pszName, size_t cchName,
+                              size_t *pcbNeeded)
+{
+    const uint8_t *pb;
+    int            rc;
+    RT_NOREF(pvBits);
 
     /*
@@ -1211,5 +1159,5 @@
      */
     if (iImport >= pModLX->Hdr.e32_impmodcnt)
-        return KLDR_ERR_IMPORT_ORDINAL_OUT_OF_BOUNDS;
+        return VERR_LDRLX_IMPORT_ORDINAL_OUT_OF_BOUNDS;
 
     /*
@@ -1233,7 +1181,9 @@
      * Copy out the result.
      */
+    if (pcbNeeded)
+        *pcbNeeded = *pb + 1;
     if (*pb < cchName)
     {
-        kHlpMemCopy(pszName, pb + 1, *pb);
+        memcpy(pszName, pb + 1, *pb);
         pszName[*pb] = '\0';
         rc = 0;
@@ -1241,8 +1191,8 @@
     else
     {
-        kHlpMemCopy(pszName, pb + 1, cchName);
+        memcpy(pszName, pb + 1, cchName);
         if (cchName)
             pszName[cchName - 1] = '\0';
-        rc = KERR_BUFFER_OVERFLOW;
+        rc = VERR_BUFFER_OVERFLOW;
     }
 
@@ -1250,10 +1200,11 @@
 }
 
+#if 0
 
 /** @copydoc kLdrModNumberOfImports */
-static KI32 kldrModLXNumberOfImports(PKLDRMOD pMod, const void *pvBits)
-{
-    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
-    K_NOREF(pvBits);
+static int32_t kldrModLXNumberOfImports(PRTLDRMODINTERNAL pMod, const void *pvBits)
+{
+    PKLDRMODLX pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    RT_NOREF(pvBits);
     return pModLX->Hdr.e32_impmodcnt;
 }
@@ -1261,15 +1212,15 @@
 
 /** @copydoc kLdrModGetStackInfo */
-static int kldrModLXGetStackInfo(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo)
-{
-    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
-    const KU32 i = pModLX->Hdr.e32_stackobj;
-    K_NOREF(pvBits);
+static int kldrModLXGetStackInfo(PRTLDRMODINTERNAL pMod, const void *pvBits, RTLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo)
+{
+    PKLDRMODLX pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    const uint32_t i = pModLX->Hdr.e32_stackobj;
+    RT_NOREF(pvBits);
 
     if (    i
-        &&  i <= pMod->cSegments
-        &&  pModLX->Hdr.e32_esp <= pMod->aSegments[i - 1].LinkAddress + pMod->aSegments[i - 1].cb
+        &&  i <= pModLX->cSegments
+        &&  pModLX->Hdr.e32_esp <= pModLX->aSegments[i - 1].LinkAddress + pModLX->aSegments[i - 1].cb
         &&  pModLX->Hdr.e32_stacksize
-        &&  pModLX->Hdr.e32_esp - pModLX->Hdr.e32_stacksize >= pMod->aSegments[i - 1].LinkAddress)
+        &&  pModLX->Hdr.e32_esp - pModLX->Hdr.e32_stacksize >= pModLX->aSegments[i - 1].LinkAddress)
     {
 
@@ -1277,11 +1228,11 @@
         pStackInfo->LinkAddress = pModLX->Hdr.e32_esp - pModLX->Hdr.e32_stacksize;
         pStackInfo->Address = BaseAddress
-                            + pMod->aSegments[i - 1].RVA
-                            + pModLX->Hdr.e32_esp - pModLX->Hdr.e32_stacksize - pMod->aSegments[i - 1].LinkAddress;
+                            + pModLX->aSegments[i - 1].RVA
+                            + pModLX->Hdr.e32_esp - pModLX->Hdr.e32_stacksize - pModLX->aSegments[i - 1].LinkAddress;
     }
     else
     {
-        pStackInfo->Address = NIL_KLDRADDR;
-        pStackInfo->LinkAddress = NIL_KLDRADDR;
+        pStackInfo->Address = NIL_RTLDRADDR;
+        pStackInfo->LinkAddress = NIL_RTLDRADDR;
     }
     pStackInfo->cbStack = pModLX->Hdr.e32_stacksize;
@@ -1293,8 +1244,8 @@
 
 /** @copydoc kLdrModQueryMainEntrypoint */
-static int kldrModLXQueryMainEntrypoint(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress)
-{
-    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
-    K_NOREF(pvBits);
+static int kldrModLXQueryMainEntrypoint(PRTLDRMODINTERNAL pMod, const void *pvBits, RTLDRADDR BaseAddress, PRTLDRADDR pMainEPAddress)
+{
+    PKLDRMODLX pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    RT_NOREF(pvBits);
 
     /*
@@ -1303,18 +1254,23 @@
     kldrModLXResolveBaseAddress(pModLX, &BaseAddress);
     *pMainEPAddress = pModLX->Hdr.e32_startobj
-                   && pModLX->Hdr.e32_startobj <= pMod->cSegments
-                   && pModLX->Hdr.e32_eip < pMod->aSegments[pModLX->Hdr.e32_startobj - 1].cb
-        ? BaseAddress + pMod->aSegments[pModLX->Hdr.e32_startobj - 1].RVA + pModLX->Hdr.e32_eip
-        : NIL_KLDRADDR;
+                   && pModLX->Hdr.e32_startobj <= pModLX->cSegments
+                   && pModLX->Hdr.e32_eip < pModLX->aSegments[pModLX->Hdr.e32_startobj - 1].cb
+        ? BaseAddress + pModLX->aSegments[pModLX->Hdr.e32_startobj - 1].RVA + pModLX->Hdr.e32_eip
+        : NIL_RTLDRADDR;
     return 0;
 }
 
-
-/** @copydoc kLdrModEnumDbgInfo */
-static int kldrModLXEnumDbgInfo(PKLDRMOD pMod, const void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser)
-{
-    /*PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;*/
-    K_NOREF(pfnCallback);
-    K_NOREF(pvUser);
+#endif
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnEnumDbgInfo}
+ */
+static DECLCALLBACK(int) rtldrLX_EnumDbgInfo(PRTLDRMODINTERNAL pMod, const void *pvBits,
+                                             PFNRTLDRENUMDBG pfnCallback, void *pvUser)
+{
+    /*PKLDRMODLX pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);*/
+    RT_NOREF(pfnCallback);
+    RT_NOREF(pvUser);
 
     /*
@@ -1335,8 +1291,8 @@
 
 /** @copydoc kLdrModHasDbgInfo */
-static int kldrModLXHasDbgInfo(PKLDRMOD pMod, const void *pvBits)
-{
-    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
-    K_NOREF(pvBits);
+static int kldrModLXHasDbgInfo(PRTLDRMODINTERNAL pMod, const void *pvBits)
+{
+    PKLDRMODLX pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    RT_NOREF(pvBits);
 
     /*
@@ -1345,13 +1301,14 @@
     if (    !pModLX->Hdr.e32_debuginfo
         ||  !pModLX->Hdr.e32_debuglen)
-        return KLDR_ERR_NO_DEBUG_INFO;
+        return VERR_NOT_FOUND;
     return 0;
 }
 
+#if 0
 
 /** @copydoc kLdrModMap */
-static int kldrModLXMap(PKLDRMOD pMod)
-{
-    PKLDRMODLX  pModLX = (PKLDRMODLX)pMod->pvData;
+static int kldrModLXMap(PRTLDRMODINTERNAL pMod)
+{
+    PKLDRMODLX  pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
     unsigned    fFixed;
     void       *pvBase;
@@ -1368,12 +1325,12 @@
      */
     /* fixed image? */
-    fFixed = pMod->enmType == KLDRTYPE_EXECUTABLE_FIXED
-          || pMod->enmType == KLDRTYPE_SHARED_LIBRARY_FIXED;
+    fFixed = pModLX->Core.enmType == RTLDRTYPE_EXECUTABLE_FIXED
+          || pModLX->Core.enmType == RTLDRTYPE_SHARED_LIBRARY_FIXED;
     if (!fFixed)
         pvBase = NULL;
     else
     {
-        pvBase = (void *)(KUPTR)pMod->aSegments[0].LinkAddress;
-        if ((KUPTR)pvBase != pMod->aSegments[0].LinkAddress)
+        pvBase = (void *)(uintptr_t)pModLX->aSegments[0].LinkAddress;
+        if ((uintptr_t)pvBase != pModLX->aSegments[0].LinkAddress)
             return KLDR_ERR_ADDRESS_OVERFLOW;
     }
@@ -1390,9 +1347,9 @@
     if (!rc)
     {
-        KU32 i;
-        for (i = 0; i < pMod->cSegments; i++)
+        uint32_t i;
+        for (i = 0; i < pModLX->cSegments; i++)
         {
-            if (pMod->aSegments[i].RVA != NIL_KLDRADDR)
-                pMod->aSegments[i].MapAddress = (KUPTR)pvBase + (KUPTR)pMod->aSegments[i].RVA;
+            if (pModLX->aSegments[i].RVA != NIL_RTLDRADDR)
+                pModLX->aSegments[i].MapAddress = (uintptr_t)pvBase + (uintptr_t)pModLX->aSegments[i].RVA;
         }
         pModLX->pvMapping = pvBase;
@@ -1403,4 +1360,5 @@
 }
 
+#endif
 
 /**
@@ -1415,8 +1373,8 @@
 static int kldrModLXDoLoadBits(PKLDRMODLX pModLX, void *pvBits)
 {
-    const PKRDR pRdr = pModLX->pMod->pRdr;
-    KU8 *pbTmpPage = NULL;
+    const PRTLDRREADER pRdr = pModLX->Core.pReader;
+    uint8_t *pbTmpPage = NULL;
     int rc = 0;
-    KU32 i;
+    uint32_t i;
 
     /*
@@ -1426,7 +1384,7 @@
     {
         const struct o32_obj * const pObj = &pModLX->paObjs[i];
-        const KU32      cPages = (KU32)(pModLX->pMod->aSegments[i].cbMapped / OBJPAGELEN);
-        KU32            iPage;
-        KU8            *pbPage = (KU8 *)pvBits + (KUPTR)pModLX->pMod->aSegments[i].RVA;
+        const uint32_t      cPages = (uint32_t)(pModLX->aSegments[i].cbMapped / OBJPAGELEN);
+        uint32_t            iPage;
+        uint8_t            *pbPage = (uint8_t *)pvBits + (uintptr_t)pModLX->aSegments[i].RVA;
 
         /*
@@ -1440,14 +1398,14 @@
                 case VALID:
                     if (pMap->o32_pagesize == OBJPAGELEN)
-                        rc = kRdrRead(pRdr, pbPage, OBJPAGELEN,
-                                         pModLX->Hdr.e32_datapage + (pMap->o32_pagedataoffset << pModLX->Hdr.e32_pageshift));
+                        rc = pRdr->pfnRead(pRdr, pbPage, OBJPAGELEN,
+                                           pModLX->Hdr.e32_datapage + (pMap->o32_pagedataoffset << pModLX->Hdr.e32_pageshift));
                     else if (pMap->o32_pagesize < OBJPAGELEN)
                     {
-                        rc = kRdrRead(pRdr, pbPage, pMap->o32_pagesize,
-                                         pModLX->Hdr.e32_datapage + (pMap->o32_pagedataoffset << pModLX->Hdr.e32_pageshift));
-                        kHlpMemSet(pbPage + pMap->o32_pagesize, 0, OBJPAGELEN - pMap->o32_pagesize);
+                        rc = pRdr->pfnRead(pRdr, pbPage, pMap->o32_pagesize,
+                                           pModLX->Hdr.e32_datapage + (pMap->o32_pagedataoffset << pModLX->Hdr.e32_pageshift));
+                        memset(pbPage + pMap->o32_pagesize, 0, OBJPAGELEN - pMap->o32_pagesize);
                     }
                     else
-                        rc = KLDR_ERR_LX_BAD_PAGE_MAP;
+                        rc = VERR_LDRLX_BAD_PAGE_MAP;
                     break;
 
@@ -1457,5 +1415,5 @@
                     if (!pbTmpPage)
                     {
-                        pbTmpPage = kHlpAlloc(OBJPAGELEN + 256);
+                        pbTmpPage = (uint8_t *)RTMemAlloc(OBJPAGELEN + 256);
                         if (!pbTmpPage)
                             break;
@@ -1464,14 +1422,14 @@
                     if (pMap->o32_pagesize > OBJPAGELEN + 252)
                     {
-                        rc = KLDR_ERR_LX_BAD_PAGE_MAP;
+                        rc = VERR_LDRLX_BAD_PAGE_MAP;
                         break;
                     }
 
                     /* read it and ensure 4 extra zero bytes. */
-                    rc = kRdrRead(pRdr, pbTmpPage, pMap->o32_pagesize,
-                                     pModLX->Hdr.e32_datapage + (pMap->o32_pagedataoffset << pModLX->Hdr.e32_pageshift));
+                    rc = pRdr->pfnRead(pRdr, pbTmpPage, pMap->o32_pagesize,
+                                       pModLX->Hdr.e32_datapage + (pMap->o32_pagedataoffset << pModLX->Hdr.e32_pageshift));
                     if (rc)
                         break;
-                    kHlpMemSet(pbTmpPage + pMap->o32_pagesize, 0, 4);
+                    memset(pbTmpPage + pMap->o32_pagesize, 0, 4);
 
                     /* unpack it into the image page. */
@@ -1484,5 +1442,5 @@
                 case INVALID: /* we're probably not dealing correctly with INVALID pages... */
                 case ZEROED:
-                    kHlpMemSet(pbPage, 0, OBJPAGELEN);
+                    memset(pbPage, 0, OBJPAGELEN);
                     break;
 
@@ -1491,5 +1449,5 @@
                     /* Falls through. */
                 default:
-                    rc = KLDR_ERR_LX_BAD_PAGE_MAP;
+                    rc = VERR_LDRLX_BAD_PAGE_MAP;
                     break;
             }
@@ -1502,9 +1460,9 @@
          */
         if (iPage < cPages)
-            kHlpMemSet(pbPage, 0, (cPages - iPage) * OBJPAGELEN);
+            memset(pbPage, 0, (cPages - iPage) * OBJPAGELEN);
     }
 
     if (pbTmpPage)
-        kHlpFree(pbTmpPage);
+        RTMemFree(pbTmpPage);
     return rc;
 }
@@ -1520,5 +1478,5 @@
  *                      contains 4 additional zero bytes.
  */
-static int kldrModLXDoIterDataUnpacking(KU8 *pbDst, const KU8 *pbSrc, int cbSrc)
+static int kldrModLXDoIterDataUnpacking(uint8_t *pbDst, const uint8_t *pbSrc, int cbSrc)
 {
     const struct LX_Iter   *pIter = (const struct LX_Iter *)pbSrc;
@@ -1527,5 +1485,5 @@
     /* Validate size of data. */
     if (cbSrc >= (int)OBJPAGELEN - 2)
-        return KLDR_ERR_LX_BAD_ITERDATA;
+        return VERR_LDRLX_BAD_ITERDATA;
 
     /*
@@ -1541,11 +1499,11 @@
             cbDst -= pIter->LX_nIter;
             if (cbDst < 0)
-                return KLDR_ERR_LX_BAD_ITERDATA;
+                return VERR_LDRLX_BAD_ITERDATA;
 
             cbSrc -= 4 + 1;
             if (cbSrc < -4)
-                return KLDR_ERR_LX_BAD_ITERDATA;
-
-            kHlpMemSet(pbDst, pIter->LX_Iterdata, pIter->LX_nIter);
+                return VERR_LDRLX_BAD_ITERDATA;
+
+            memset(pbDst, pIter->LX_Iterdata, pIter->LX_nIter);
             pbDst += pIter->LX_nIter;
             pIter++;
@@ -1560,12 +1518,12 @@
             cbDst -= pIter->LX_nIter * pIter->LX_nBytes;
             if (cbDst < 0)
-                return KLDR_ERR_LX_BAD_ITERDATA;
+                return VERR_LDRLX_BAD_ITERDATA;
 
             cbSrc -= 4 + pIter->LX_nBytes;
             if (cbSrc < -4)
-                return KLDR_ERR_LX_BAD_ITERDATA;
+                return VERR_LDRLX_BAD_ITERDATA;
 
             for (i = pIter->LX_nIter; i > 0; i--, pbDst += pIter->LX_nBytes)
-                kHlpMemCopy(pbDst, &pIter->LX_Iterdata, pIter->LX_nBytes);
+                memcpy(pbDst, &pIter->LX_Iterdata, pIter->LX_nBytes);
             pIter   = (struct LX_Iter *)((char*)pIter + 4 + pIter->LX_nBytes);
         }
@@ -1576,5 +1534,5 @@
      */
     if (cbDst > 0)
-        kHlpMemSet(pbDst, 0, cbDst);
+        memset(pbDst, 0, cbDst);
 
     return 0;
@@ -1591,5 +1549,5 @@
  *                      contains 4 additional zero bytes.
  */
-static int kldrModLXDoIterData2Unpacking(KU8 *pbDst, const KU8 *pbSrc, int cbSrc)
+static int kldrModLXDoIterData2Unpacking(uint8_t *pbDst, const uint8_t *pbSrc, int cbSrc)
 {
     int cbDst = OBJPAGELEN;
@@ -1629,14 +1587,14 @@
                     cbDst -= cb;
                     if (cbDst < 0)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
+                        return VERR_LDRLX_BAD_ITERDATA2;
                     cbSrc -= cb + 1;
                     if (cbSrc < 0)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
-                    kHlpMemCopy(pbDst, ++pbSrc, cb);
+                        return VERR_LDRLX_BAD_ITERDATA2;
+                    memcpy(pbDst, ++pbSrc, cb);
                     pbDst += cb;
                     pbSrc += cb;
                 }
                 else if (cbSrc < 2)
-                    return KLDR_ERR_LX_BAD_ITERDATA2;
+                    return VERR_LDRLX_BAD_ITERDATA2;
                 else
                 {
@@ -1646,9 +1604,9 @@
                     cbDst -= cb;
                     if (cbDst < 0)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
+                        return VERR_LDRLX_BAD_ITERDATA2;
                     cbSrc -= 3;
                     if (cbSrc < 0)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
-                    kHlpMemSet(pbDst, pbSrc[2], cb);
+                        return VERR_LDRLX_BAD_ITERDATA2;
+                    memset(pbDst, pbSrc[2], cb);
                     pbDst += cb;
                     pbSrc += 3;
@@ -1672,5 +1630,5 @@
                 cbSrc -= 2;
                 if (cbSrc < 0)
-                    return KLDR_ERR_LX_BAD_ITERDATA2;
+                    return VERR_LDRLX_BAD_ITERDATA2;
                 else
                 {
@@ -1682,18 +1640,18 @@
                     cbSrc -= cb1;
                     if (cbSrc < 0)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
+                        return VERR_LDRLX_BAD_ITERDATA2;
                     cbDst -= cb1;
                     if (cbDst < 0)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
-                    kHlpMemCopy(pbDst, pbSrc, cb1);
+                        return VERR_LDRLX_BAD_ITERDATA2;
+                    memcpy(pbDst, pbSrc, cb1);
                     pbDst += cb1;
                     pbSrc += cb1;
 
                     if (off > OBJPAGELEN - (unsigned)cbDst)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
+                        return VERR_LDRLX_BAD_ITERDATA2;
                     cbDst -= cb2;
                     if (cbDst < 0)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
-                    kHlpMemMove(pbDst, pbDst - off, cb2);
+                        return VERR_LDRLX_BAD_ITERDATA2;
+                    memmove(pbDst, pbDst - off, cb2);
                     pbDst += cb2;
                 }
@@ -1718,5 +1676,5 @@
                 cbSrc -= 2;
                 if (cbSrc < 0)
-                    return KLDR_ERR_LX_BAD_ITERDATA2;
+                    return VERR_LDRLX_BAD_ITERDATA2;
                 else
                 {
@@ -1726,8 +1684,8 @@
                     pbSrc += 2;
                     if (off > OBJPAGELEN - (unsigned)cbDst)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
+                        return VERR_LDRLX_BAD_ITERDATA2;
                     cbDst -= cb;
                     if (cbDst < 0)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
+                        return VERR_LDRLX_BAD_ITERDATA2;
                     kLdrModLXMemCopyW(pbDst, pbDst - off, cb);
                     pbDst += cb;
@@ -1753,5 +1711,5 @@
                 cbSrc -= 3;
                 if (cbSrc < 0)
-                    return KLDR_ERR_LX_BAD_ITERDATA2;
+                    return VERR_LDRLX_BAD_ITERDATA2;
                 else
                 {
@@ -1763,17 +1721,17 @@
                     cbSrc -= cb1;
                     if (cbSrc < 0)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
+                        return VERR_LDRLX_BAD_ITERDATA2;
                     cbDst -= cb1;
                     if (cbDst < 0)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
-                    kHlpMemCopy(pbDst, pbSrc, cb1);
+                        return VERR_LDRLX_BAD_ITERDATA2;
+                    memcpy(pbDst, pbSrc, cb1);
                     pbDst += cb1;
                     pbSrc += cb1;
 
                     if (off > OBJPAGELEN - (unsigned)cbDst)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
+                        return VERR_LDRLX_BAD_ITERDATA2;
                     cbDst -= cb2;
                     if (cbDst < 0)
-                        return KLDR_ERR_LX_BAD_ITERDATA2;
+                        return VERR_LDRLX_BAD_ITERDATA2;
                     kLdrModLXMemCopyW(pbDst, pbDst - off, cb2);
                     pbDst += cb2;
@@ -1791,5 +1749,5 @@
      */
     if (cbDst > 0)
-        kHlpMemSet(pbDst, 0, cbDst);
+        memset(pbDst, 0, cbDst);
 
     return 0;
@@ -1808,5 +1766,5 @@
  * @remark  This assumes that unaligned word and dword access is fine.
  */
-static void kLdrModLXMemCopyW(KU8 *pbDst, const KU8 *pbSrc, int cb)
+static void kLdrModLXMemCopyW(uint8_t *pbDst, const uint8_t *pbSrc, int cb)
 {
     switch (pbDst - pbSrc)
@@ -1820,5 +1778,5 @@
                 *pbDst++ = *pbSrc++;
             for (cb >>= 1; cb > 0; cb--, pbDst += 2, pbSrc += 2)
-                *(KU16 *)pbDst = *(const KU16 *)pbSrc;
+                *(uint16_t *)pbDst = *(const uint16_t *)pbSrc;
             break;
 
@@ -1829,14 +1787,15 @@
             if (cb & 2)
             {
-                *(KU16 *)pbDst = *(const KU16 *)pbSrc;
+                *(uint16_t *)pbDst = *(const uint16_t *)pbSrc;
                 pbDst += 2;
                 pbSrc += 2;
             }
             for (cb >>= 2; cb > 0; cb--, pbDst += 4, pbSrc += 4)
-                *(KU32 *)pbDst = *(const KU32 *)pbSrc;
+                *(uint32_t *)pbDst = *(const uint32_t *)pbSrc;
             break;
     }
 }
 
+#if 0
 
 /**
@@ -1853,11 +1812,10 @@
 static int kldrModLXDoProtect(PKLDRMODLX pModLX, void *pvBits, unsigned fUnprotectOrProtect)
 {
-    KU32 i;
-    PKLDRMOD pMod = pModLX->pMod;
+    uint32_t i;
 
     /*
      * Change object protection.
      */
-    for (i = 0; i < pMod->cSegments; i++)
+    for (i = 0; i < pModLX->cSegments; i++)
     {
         int rc;
@@ -1866,5 +1824,5 @@
 
         /* calc new protection. */
-        enmProt = pMod->aSegments[i].enmProt;
+        enmProt = pModLX->aSegments[i].enmProt;
         if (fUnprotectOrProtect)
         {
@@ -1899,7 +1857,7 @@
 
         /* calc the address and set page protection. */
-        pv = (KU8 *)pvBits + pMod->aSegments[i].RVA;
-
-        rc = kHlpPageProtect(pv, pMod->aSegments[i].cbMapped, enmProt);
+        pv = (uint8_t *)pvBits + pModLX->aSegments[i].RVA;
+
+        rc = kHlpPageProtect(pv, pModLX->aSegments[i].cbMapped, enmProt);
         if (rc)
             break;
@@ -1913,8 +1871,8 @@
 
 /** @copydoc kLdrModUnmap */
-static int kldrModLXUnmap(PKLDRMOD pMod)
-{
-    PKLDRMODLX  pModLX = (PKLDRMODLX)pMod->pvData;
-    KU32        i;
+static int kldrModLXUnmap(PRTLDRMODINTERNAL pMod)
+{
+    PKLDRMODLX  pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    uint32_t    i;
     int         rc;
 
@@ -1932,6 +1890,6 @@
     pModLX->pvMapping = NULL;
 
-    for (i = 0; i < pMod->cSegments; i++)
-        pMod->aSegments[i].MapAddress = 0;
+    for (i = 0; i < pModLX->cSegments; i++)
+        pModLX->aSegments[i].MapAddress = 0;
 
     return rc;
@@ -1940,7 +1898,7 @@
 
 /** @copydoc kLdrModAllocTLS */
-static int kldrModLXAllocTLS(PKLDRMOD pMod, void *pvMapping)
-{
-    PKLDRMODLX  pModLX = (PKLDRMODLX)pMod->pvData;
+static int kldrModLXAllocTLS(PRTLDRMODINTERNAL pMod, void *pvMapping)
+{
+    PKLDRMODLX  pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
 
     /* no tls, just do the error checking. */
@@ -1953,9 +1911,9 @@
 
 /** @copydoc kLdrModFreeTLS */
-static void kldrModLXFreeTLS(PKLDRMOD pMod, void *pvMapping)
+static void kldrModLXFreeTLS(PRTLDRMODINTERNAL pMod, void *pvMapping)
 {
     /* no tls. */
-    K_NOREF(pMod);
-    K_NOREF(pvMapping);
+    RT_NOREF(pMod);
+    RT_NOREF(pvMapping);
 
 }
@@ -1963,7 +1921,7 @@
 
 /** @copydoc kLdrModReload */
-static int kldrModLXReload(PKLDRMOD pMod)
-{
-    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
+static int kldrModLXReload(PRTLDRMODINTERNAL pMod)
+{
+    PKLDRMODLX pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
     int rc, rc2;
 
@@ -1997,7 +1955,7 @@
 
 /** @copydoc kLdrModFixupMapping */
-static int kldrModLXFixupMapping(PKLDRMOD pMod, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser)
-{
-    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
+static int kldrModLXFixupMapping(PRTLDRMODINTERNAL pMod, PFNRTLDRIMPORT pfnGetImport, void *pvUser)
+{
+    PKLDRMODLX pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
     int rc, rc2;
 
@@ -2018,6 +1976,6 @@
      * Apply fixups and resolve imports.
      */
-    rc = kldrModLXRelocateBits(pMod, (void *)pModLX->pvMapping, (KUPTR)pModLX->pvMapping,
-                               pMod->aSegments[0].LinkAddress, pfnGetImport, pvUser);
+    rc = rtldrLX_RelocateBits(pMod, (void *)pModLX->pvMapping, (uintptr_t)pModLX->pvMapping,
+                              pModLX->aSegments[0].LinkAddress, pfnGetImport, pvUser);
 
     /*
@@ -2032,7 +1990,7 @@
 
 /** @copydoc kLdrModCallInit */
-static int kldrModLXCallInit(PKLDRMOD pMod, void *pvMapping, KUPTR uHandle)
-{
-    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
+static int kldrModLXCallInit(PRTLDRMODINTERNAL pMod, void *pvMapping, uintptr_t uHandle)
+{
+    PKLDRMODLX pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
     int rc;
 
@@ -2068,5 +2026,5 @@
  * @param   uHandle         The module handle to present.
  */
-static int kldrModLXDoCallDLL(PKLDRMODLX pModLX, void *pvMapping, unsigned uOp, KUPTR uHandle)
+static int kldrModLXDoCallDLL(PKLDRMODLX pModLX, void *pvMapping, unsigned uOp, uintptr_t uHandle)
 {
     int rc;
@@ -2082,6 +2040,6 @@
      * Invoke the entrypoint and convert the boolean result to a kLdr status code.
      */
-    rc = kldrModLXDoCall((KUPTR)pvMapping
-                         + (KUPTR)pModLX->pMod->aSegments[pModLX->Hdr.e32_startobj - 1].RVA
+    rc = kldrModLXDoCall((uintptr_t)pvMapping
+                         + (uintptr_t)pModLX->aSegments[pModLX->Hdr.e32_startobj - 1].RVA
                          + pModLX->Hdr.e32_eip,
                          uHandle, uOp, NULL);
@@ -2105,8 +2063,8 @@
  * @param   pvReserved      The third argument, reserved argument. (figure this one out)
  */
-static KI32 kldrModLXDoCall(KUPTR uEntrypoint, KUPTR uHandle, KU32 uOp, void *pvReserved)
+static int32_t kldrModLXDoCall(uintptr_t uEntrypoint, uintptr_t uHandle, uint32_t uOp, void *pvReserved)
 {
 #if defined(__X86__) || defined(__i386__) || defined(_M_IX86)
-    KI32 rc;
+    int32_t rc;
 /** @todo try/except */
 
@@ -2146,12 +2104,12 @@
 #  error "port me!"
 # endif
-    K_NOREF(pvReserved);
+    RT_NOREF(pvReserved);
     return rc;
 
 #else
-    K_NOREF(uEntrypoint);
-    K_NOREF(uHandle);
-    K_NOREF(uOp);
-    K_NOREF(pvReserved);
+    RT_NOREF(uEntrypoint);
+    RT_NOREF(uHandle);
+    RT_NOREF(uOp);
+    RT_NOREF(pvReserved);
     return KCPU_ERR_ARCH_CPU_NOT_COMPATIBLE;
 #endif
@@ -2160,7 +2118,7 @@
 
 /** @copydoc kLdrModCallTerm */
-static int kldrModLXCallTerm(PKLDRMOD pMod, void *pvMapping, KUPTR uHandle)
-{
-    PKLDRMODLX  pModLX = (PKLDRMODLX)pMod->pvData;
+static int kldrModLXCallTerm(PRTLDRMODINTERNAL pMod, void *pvMapping, uintptr_t uHandle)
+{
+    PKLDRMODLX  pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
 
     /*
@@ -2185,50 +2143,57 @@
 
 /** @copydoc kLdrModCallThread */
-static int kldrModLXCallThread(PKLDRMOD pMod, void *pvMapping, KUPTR uHandle, unsigned fAttachingOrDetaching)
+static int kldrModLXCallThread(PRTLDRMODINTERNAL pMod, void *pvMapping, uintptr_t uHandle, unsigned fAttachingOrDetaching)
 {
     /* no thread attach/detach callout. */
-    K_NOREF(pMod);
-    K_NOREF(pvMapping);
-    K_NOREF(uHandle);
-    K_NOREF(fAttachingOrDetaching);
+    RT_NOREF(pMod);
+    RT_NOREF(pvMapping);
+    RT_NOREF(uHandle);
+    RT_NOREF(fAttachingOrDetaching);
     return 0;
 }
 
-
-/** @copydoc kLdrModSize */
-static KLDRADDR kldrModLXSize(PKLDRMOD pMod)
-{
-    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
+#endif
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnGetImageSize}
+ */
+static DECLCALLBACK(size_t) rtldrLX_GetImageSize(PRTLDRMODINTERNAL pMod)
+{
+    PKLDRMODLX pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
     return pModLX->cbMapped;
 }
 
 
-/** @copydoc kLdrModGetBits */
-static int kldrModLXGetBits(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser)
-{
-    PKLDRMODLX  pModLX = (PKLDRMODLX)pMod->pvData;
-    int         rc;
+/**
+ * @interface_method_impl{RTLDROPS,pfnGetBits}
+ */
+static DECLCALLBACK(int) rtldrLX_GetBits(PRTLDRMODINTERNAL pMod, void *pvBits, RTUINTPTR BaseAddress,
+                                         PFNRTLDRIMPORT pfnGetImport, void *pvUser)
+{
+    PKLDRMODLX pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
 
     /*
      * Load the image bits.
      */
-    rc = kldrModLXDoLoadBits(pModLX, pvBits);
-    if (rc)
-        return rc;
-
-    /*
-     * Perform relocations.
-     */
-    return kldrModLXRelocateBits(pMod, pvBits, BaseAddress, pMod->aSegments[0].LinkAddress, pfnGetImport, pvUser);
-
-}
-
-
-/** @copydoc kLdrModRelocateBits */
-static int kldrModLXRelocateBits(PKLDRMOD pMod, void *pvBits, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress,
-                                 PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser)
-{
-    PKLDRMODLX pModLX = (PKLDRMODLX)pMod->pvData;
-    KU32 iSeg;
+    int rc = kldrModLXDoLoadBits(pModLX, pvBits);
+    if (RT_SUCCESS(rc))
+    {
+        /*
+         * Perform relocations.
+         */
+        rc = rtldrLX_RelocateBits(pMod, pvBits, BaseAddress, pModLX->aSegments[0].LinkAddress, pfnGetImport, pvUser);
+    }
+    return rc;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnRelocate}
+ */
+static DECLCALLBACK(int) rtldrLX_RelocateBits(PRTLDRMODINTERNAL pMod, void *pvBits, RTUINTPTR NewBaseAddress,
+                                              RTUINTPTR OldBaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser)
+{
+    PKLDRMODLX pModLX = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    uint32_t iSeg;
     int rc;
 
@@ -2257,7 +2222,7 @@
     {
         const struct o32_obj * const pObj = &pModLX->paObjs[iSeg];
-        KLDRADDR        PageAddress = NewBaseAddress + pModLX->pMod->aSegments[iSeg].RVA;
-        KU32            iPage;
-        KU8            *pbPage = (KU8 *)pvBits + (KUPTR)pModLX->pMod->aSegments[iSeg].RVA;
+        RTLDRADDR           PageAddress = NewBaseAddress + pModLX->aSegments[iSeg].RVA;
+        uint32_t            iPage;
+        uint8_t            *pbPage = (uint8_t *)pvBits + (uintptr_t)pModLX->aSegments[iSeg].RVA;
 
         /*
@@ -2266,17 +2231,17 @@
         for (iPage = 0, rc = 0; !rc && iPage < pObj->o32_mapsize; iPage++, pbPage += OBJPAGELEN, PageAddress += OBJPAGELEN)
         {
-            const KU8 * const   pbFixupRecEnd = pModLX->pbFixupRecs + pModLX->paoffPageFixups[iPage + pObj->o32_pagemap];
-            const KU8          *pb            = pModLX->pbFixupRecs + pModLX->paoffPageFixups[iPage + pObj->o32_pagemap - 1];
-            KLDRADDR            uValue        = NIL_KLDRADDR;
-            KU32                fKind         = 0;
-            int                 iSelector;
+            const uint8_t * const   pbFixupRecEnd = pModLX->pbFixupRecs + pModLX->paoffPageFixups[iPage + pObj->o32_pagemap];
+            const uint8_t          *pb            = pModLX->pbFixupRecs + pModLX->paoffPageFixups[iPage + pObj->o32_pagemap - 1];
+            RTLDRADDR               uValue        = NIL_RTLDRADDR;
+            uint32_t                fKind         = 0;
+            int                     iSelector;
 
             /* sanity */
             if (pbFixupRecEnd < pb)
-                return KLDR_ERR_BAD_FIXUP;
+                return VERR_LDR_BAD_FIXUP;
             if (pbFixupRecEnd - 1 > pModLX->pbFixupSectionLast)
-                return KLDR_ERR_BAD_FIXUP;
+                return VERR_LDR_BAD_FIXUP;
             if (pb < pModLX->pbFixupSection)
-                return KLDR_ERR_BAD_FIXUP;
+                return VERR_LDR_BAD_FIXUP;
 
             /*
@@ -2287,8 +2252,8 @@
                 union _rel
                 {
-                    const KU8 *             pb;
+                    const uint8_t *             pb;
                     const struct r32_rlc   *prlc;
                 } u;
-
+                char szImpModule[256];
                 u.pb = pb;
                 pb += 3 + (u.prlc->nr_stype & NRCHAIN ? 0 : 1); /* place pch at the 4th member. */
@@ -2304,11 +2269,11 @@
                     case NRRINT:
                     {
-                        KU16 iTrgObject;
-                        KU32 offTrgObject;
+                        uint16_t iTrgObject;
+                        uint32_t offTrgObject;
 
                         /* the object */
                         if (u.prlc->nr_flags & NR16OBJMOD)
                         {
-                            iTrgObject = *(const KU16 *)pb;
+                            iTrgObject = *(const uint16_t *)pb;
                             pb += 2;
                         }
@@ -2317,5 +2282,5 @@
                         iTrgObject--;
                         if (iTrgObject >= pModLX->Hdr.e32_objcnt)
-                            return KLDR_ERR_BAD_FIXUP;
+                            return VERR_LDR_BAD_FIXUP;
 
                         /* the target */
@@ -2324,23 +2289,23 @@
                             if (u.prlc->nr_flags & NR32BITOFF)
                             {
-                                offTrgObject = *(const KU32 *)pb;
+                                offTrgObject = *(const uint32_t *)pb;
                                 pb += 4;
                             }
                             else
                             {
-                                offTrgObject = *(const KU16 *)pb;
+                                offTrgObject = *(const uint16_t *)pb;
                                 pb += 2;
                             }
 
                             /* calculate the symbol info. */
-                            uValue = offTrgObject + NewBaseAddress + pMod->aSegments[iTrgObject].RVA;
+                            uValue = offTrgObject + NewBaseAddress + pModLX->aSegments[iTrgObject].RVA;
                         }
                         else
-                            uValue = NewBaseAddress + pMod->aSegments[iTrgObject].RVA;
+                            uValue = NewBaseAddress + pModLX->aSegments[iTrgObject].RVA;
                         if (    (u.prlc->nr_stype & NRALIAS)
-                            ||  (pMod->aSegments[iTrgObject].fFlags & KLDRSEG_FLAG_16BIT))
-                            iSelector = pMod->aSegments[iTrgObject].Sel16bit;
+                            ||  (pModLX->aSegments[iTrgObject].fFlags & RTLDRSEG_FLAG_16BIT))
+                            iSelector = pModLX->aSegments[iTrgObject].Sel16bit;
                         else
-                            iSelector = pMod->aSegments[iTrgObject].SelFlat;
+                            iSelector = pModLX->aSegments[iTrgObject].SelFlat;
                         fKind = 0;
                         break;
@@ -2352,11 +2317,11 @@
                     case NRRORD:
                     {
-                        KU16 iModule;
-                        KU32 iSymbol;
+                        uint16_t iModule;
+                        uint32_t iSymbol;
 
                         /* the module ordinal */
                         if (u.prlc->nr_flags & NR16OBJMOD)
                         {
-                            iModule = *(const KU16 *)pb;
+                            iModule = *(const uint16_t *)pb;
                             pb += 2;
                         }
@@ -2365,8 +2330,12 @@
                         iModule--;
                         if (iModule >= pModLX->Hdr.e32_impmodcnt)
-                            return KLDR_ERR_BAD_FIXUP;
+                            return VERR_LDR_BAD_FIXUP;
+                        rc = kldrModLXGetImport(pModLX, NULL, iModule, szImpModule, sizeof(szImpModule), NULL);
+                        if (RT_FAILURE(rc))
+                            return rc;
+
 #if 1
                         if (u.prlc->nr_flags & NRICHAIN)
-                            return KLDR_ERR_BAD_FIXUP;
+                            return VERR_LDR_BAD_FIXUP;
 #endif
 
@@ -2374,10 +2343,10 @@
                         if (u.prlc->nr_flags & NR32BITOFF)
                         {
-                            iSymbol = *(const KU32 *)pb;
+                            iSymbol = *(const uint32_t *)pb;
                             pb += 4;
                         }
                         else if (!(u.prlc->nr_flags & NR8BITORD))
                         {
-                            iSymbol = *(const KU16 *)pb;
+                            iSymbol = *(const uint16_t *)pb;
                             pb += 2;
                         }
@@ -2386,5 +2355,5 @@
 
                         /* resolve it. */
-                        rc = pfnGetImport(pMod, iModule, iSymbol, NULL, 0, NULL, &uValue, &fKind, pvUser);
+                        rc = pfnGetImport(pMod, szImpModule, NULL, iSymbol, &uValue, /*&fKind,*/ pvUser);
                         if (rc)
                             return rc;
@@ -2398,12 +2367,12 @@
                     case NRRNAM:
                     {
-                        KU32 iModule;
-                        KU16 offSymbol;
-                        const KU8 *pbSymbol;
+                        uint32_t iModule;
+                        uint16_t offSymbol;
+                        const uint8_t *pbSymbol;
 
                         /* the module ordinal */
                         if (u.prlc->nr_flags & NR16OBJMOD)
                         {
-                            iModule = *(const KU16 *)pb;
+                            iModule = *(const uint16_t *)pb;
                             pb += 2;
                         }
@@ -2412,8 +2381,11 @@
                         iModule--;
                         if (iModule >= pModLX->Hdr.e32_impmodcnt)
-                            return KLDR_ERR_BAD_FIXUP;
+                            return VERR_LDR_BAD_FIXUP;
+                        rc = kldrModLXGetImport(pModLX, NULL, iModule, szImpModule, sizeof(szImpModule), NULL);
+                        if (RT_FAILURE(rc))
+                            return rc;
 #if 1
                         if (u.prlc->nr_flags & NRICHAIN)
-                            return KLDR_ERR_BAD_FIXUP;
+                            return VERR_LDR_BAD_FIXUP;
 #endif
 
@@ -2421,10 +2393,10 @@
                         if (u.prlc->nr_flags & NR32BITOFF)
                         {
-                            offSymbol = *(const KU32 *)pb;
+                            offSymbol = *(const uint32_t *)pb;
                             pb += 4;
                         }
                         else if (!(u.prlc->nr_flags & NR8BITORD))
                         {
-                            offSymbol = *(const KU16 *)pb;
+                            offSymbol = *(const uint16_t *)pb;
                             pb += 2;
                         }
@@ -2434,9 +2406,11 @@
                         if (    pbSymbol < pModLX->pbImportProcs
                             ||  pbSymbol > pModLX->pbFixupSectionLast)
-                            return KLDR_ERR_BAD_FIXUP;
+                            return VERR_LDR_BAD_FIXUP;
+                        char szSymbol[256];
+                        memcpy(szSymbol, pbSymbol + 1, *pbSymbol);
+                        szSymbol[*pbSymbol] = '\0';
 
                         /* resolve it. */
-                        rc = pfnGetImport(pMod, iModule, NIL_KLDRMOD_SYM_ORDINAL, (const char *)pbSymbol + 1, *pbSymbol, NULL,
-                                          &uValue, &fKind, pvUser);
+                        rc = pfnGetImport(pMod, szImpModule, szSymbol, UINT32_MAX, &uValue, /*&fKind,*/ pvUser);
                         if (rc)
                             return rc;
@@ -2458,10 +2432,10 @@
                     if (u.prlc->nr_flags & NR32BITADD)
                     {
-                        uValue += *(const KU32 *)pb;
+                        uValue += *(const uint32_t *)pb;
                         pb += 4;
                     }
                     else
                     {
-                        uValue += *(const KU16 *)pb;
+                        uValue += *(const uint16_t *)pb;
                         pb += 2;
                     }
@@ -2480,9 +2454,9 @@
                         &&  off >= 0
                         &&  off <= (int)OBJPAGELEN - 4)
-                        *(KU32 *)&pbPage[off] = (KU32)uValue;
+                        *(uint32_t *)&pbPage[off] = (uint32_t)uValue;
                     else if (    (u.prlc->nr_stype & NRSRCMASK) == NRSOFF32
                             &&  off >= 0
                             &&  off <= (int)OBJPAGELEN - 4)
-                        *(KU32 *)&pbPage[off] = (KU32)(uValue - (PageAddress + off + 4));
+                        *(uint32_t *)&pbPage[off] = (uint32_t)(uValue - (PageAddress + off + 4));
                     else
                     {
@@ -2495,6 +2469,6 @@
                 else if (!(u.prlc->nr_flags & NRICHAIN))
                 {
-                    const KI16 *poffSrc = (const KI16 *)pb;
-                    KU8 c = u.pb[2];
+                    const int16_t *poffSrc = (const int16_t *)pb;
+                    uint8_t c = u.pb[2];
 
                     /* common / simple */
@@ -2505,5 +2479,5 @@
                             int off = *poffSrc++;
                             if (off >= 0 && off <= (int)OBJPAGELEN - 4)
-                                *(KU32 *)&pbPage[off] = (KU32)uValue;
+                                *(uint32_t *)&pbPage[off] = (uint32_t)uValue;
                             else
                             {
@@ -2520,5 +2494,5 @@
                             int off = *poffSrc++;
                             if (off >= 0 && off <= (int)OBJPAGELEN - 4)
-                                *(KU32 *)&pbPage[off] = (KU32)(uValue - (PageAddress + off + 4));
+                                *(uint32_t *)&pbPage[off] = (uint32_t)(uValue - (PageAddress + off + 4));
                             else
                             {
@@ -2538,5 +2512,5 @@
                         }
                     }
-                    pb = (const KU8 *)poffSrc;
+                    pb = (const uint8_t *)poffSrc;
                 }
                 else
@@ -2544,5 +2518,5 @@
                     /* This is a pain because it will require virgin pages on a relocation. */
                     KLDRMODLX_ASSERT(!"NRICHAIN");
-                    return KLDR_ERR_LX_NRICHAIN_NOT_SUPPORTED;
+                    return VERR_LDRLX_NRICHAIN_NOT_SUPPORTED;
                 }
             }
@@ -2566,31 +2540,31 @@
  * @param   fKind       The target kind.
  */
-static int kldrModLXDoReloc(KU8 *pbPage, int off, KLDRADDR PageAddress, const struct r32_rlc *prlc,
-                            int iSelector, KLDRADDR uValue, KU32 fKind)
+static int kldrModLXDoReloc(uint8_t *pbPage, int off, RTLDRADDR PageAddress, const struct r32_rlc *prlc,
+                            int iSelector, RTLDRADDR uValue, uint32_t fKind)
 {
 #pragma pack(1) /* just to be sure */
     union
     {
-        KU8         ab[6];
-        KU32        off32;
-        KU16        off16;
-        KU8         off8;
+        uint8_t         ab[6];
+        uint32_t        off32;
+        uint16_t        off16;
+        uint8_t         off8;
         struct
         {
-            KU16    off;
-            KU16    Sel;
+            uint16_t    off;
+            uint16_t    Sel;
         }           Far16;
         struct
         {
-            KU32    off;
-            KU16    Sel;
+            uint32_t    off;
+            uint16_t    Sel;
         }           Far32;
     }               uData;
 #pragma pack()
-    const KU8      *pbSrc;
-    KU8            *pbDst;
-    KU8             cb;
-
-    K_NOREF(fKind);
+    const uint8_t      *pbSrc;
+    uint8_t            *pbDst;
+    uint8_t             cb;
+
+    RT_NOREF(fKind);
 
     /*
@@ -2600,5 +2574,5 @@
     {
         case NRSBYT:
-            uData.off8 = (KU8)uValue;
+            uData.off8 = (uint8_t)uValue;
             cb = 1;
             break;
@@ -2616,10 +2590,10 @@
                 /* fixme */
             }
-            uData.Far16.off = (KU16)uValue;
+            uData.Far16.off = (uint16_t)uValue;
             uData.Far16.Sel = iSelector;
             cb = 4;
             break;
         case NRSOFF:
-            uData.off16 = (KU16)uValue;
+            uData.off16 = (uint16_t)uValue;
             cb = 2;
             break;
@@ -2629,18 +2603,18 @@
                 /* fixme */
             }
-            uData.Far32.off = (KU32)uValue;
+            uData.Far32.off = (uint32_t)uValue;
             uData.Far32.Sel = iSelector;
             cb = 6;
             break;
         case NROFF32:
-            uData.off32 = (KU32)uValue;
+            uData.off32 = (uint32_t)uValue;
             cb = 4;
             break;
         case NRSOFF32:
-            uData.off32 = (KU32)(uValue - (PageAddress + off + 4));
+            uData.off32 = (uint32_t)(uValue - (PageAddress + off + 4));
             cb = 4;
             break;
         default:
-            return KLDR_ERR_LX_BAD_FIXUP_SECTION; /** @todo fix error, add more checks! */
+            return VERR_LDRLX_BAD_FIXUP_SECTION; /** @todo fix error, add more checks! */
     }
 
@@ -2665,38 +2639,226 @@
 
 /**
- * The LX module interpreter method table.
- */
-KLDRMODOPS g_kLdrModLXOps =
+ * @interface_method_impl{RTLDROPS,pfnEnumSegments}
+ */
+static DECLCALLBACK(int) rtldrLX_EnumSegments(PRTLDRMODINTERNAL pMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser)
+{
+    PKLDRMODLX      pThis     = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    uint32_t const  cSegments = pThis->cSegments;
+    for (uint32_t iSeg = 0; iSeg < cSegments; iSeg++)
+    {
+        RTLDRSEG Seg = pThis->aSegments[iSeg];
+        int rc = pfnCallback(pMod, &Seg, pvUser);
+        if (rc != VINF_SUCCESS)
+            return rc;
+    }
+
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnLinkAddressToSegOffset}
+ */
+static DECLCALLBACK(int) rtldrLX_LinkAddressToSegOffset(PRTLDRMODINTERNAL pMod, RTLDRADDR LinkAddress,
+                                                           uint32_t *piSeg, PRTLDRADDR poffSeg)
+{
+    PKLDRMODLX     pThis     = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    uint32_t const cSegments = pThis->cSegments;
+    for (uint32_t iSeg = 0; iSeg < cSegments; iSeg++)
+    {
+        RTLDRADDR offSeg = LinkAddress - pThis->aSegments[iSeg].LinkAddress;
+        if (   offSeg < pThis->aSegments[iSeg].cbMapped
+            || offSeg < pThis->aSegments[iSeg].cb)
+        {
+            *piSeg = iSeg;
+            *poffSeg = offSeg;
+            return VINF_SUCCESS;
+        }
+    }
+
+    return VERR_LDR_INVALID_LINK_ADDRESS;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnLinkAddressToRva}.
+ */
+static DECLCALLBACK(int) rtldrLX_LinkAddressToRva(PRTLDRMODINTERNAL pMod, RTLDRADDR LinkAddress, PRTLDRADDR pRva)
+{
+    PKLDRMODLX     pThis     = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    uint32_t const cSegments = pThis->cSegments;
+    for (uint32_t iSeg = 0; iSeg < cSegments; iSeg++)
+    {
+        RTLDRADDR offSeg = LinkAddress - pThis->aSegments[iSeg].LinkAddress;
+        if (   offSeg < pThis->aSegments[iSeg].cbMapped
+            || offSeg < pThis->aSegments[iSeg].cb)
+        {
+            *pRva = pThis->aSegments[iSeg].RVA + offSeg;
+            return VINF_SUCCESS;
+        }
+    }
+
+    return VERR_LDR_INVALID_RVA;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnSegOffsetToRva}
+ */
+static DECLCALLBACK(int) rtldrLX_SegOffsetToRva(PRTLDRMODINTERNAL pMod, uint32_t iSeg, RTLDRADDR offSeg, PRTLDRADDR pRva)
+{
+    PKLDRMODLX  pThis = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+
+    if (iSeg >= pThis->cSegments)
+        return VERR_LDR_INVALID_SEG_OFFSET;
+    PCRTLDRSEG pSegment = &pThis->aSegments[iSeg];
+
+    if (   offSeg > pSegment->cbMapped
+        && offSeg > pSegment->cb
+        && (    pSegment->cbFile < 0
+            ||  offSeg > (uint64_t)pSegment->cbFile))
+        return VERR_LDR_INVALID_SEG_OFFSET;
+
+    *pRva = pSegment->RVA + offSeg;
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnRvaToSegOffset}
+ */
+static DECLCALLBACK(int) rtldrLX_RvaToSegOffset(PRTLDRMODINTERNAL pMod, RTLDRADDR Rva, uint32_t *piSeg, PRTLDRADDR poffSeg)
+{
+    PKLDRMODLX     pThis     = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    uint32_t const cSegments = pThis->cSegments;
+    for (uint32_t iSeg = 0; iSeg < cSegments; iSeg++)
+    {
+        RTLDRADDR offSeg = Rva - pThis->aSegments[iSeg].RVA;
+        if (   offSeg < pThis->aSegments[iSeg].cbMapped
+            || offSeg < pThis->aSegments[iSeg].cb)
+        {
+            *piSeg = iSeg;
+            *poffSeg = offSeg;
+            return VINF_SUCCESS;
+        }
+    }
+
+    return VERR_LDR_INVALID_RVA;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnReadDbgInfo}
+ */
+static DECLCALLBACK(int) rtldrLX_ReadDbgInfo(PRTLDRMODINTERNAL pMod, uint32_t iDbgInfo, RTFOFF off, size_t cb, void *pvBuf)
+{
+    //PKLDRMODLX pThis = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    RT_NOREF(pMod, iDbgInfo, off, cb, pvBuf);
+    return VERR_OUT_OF_RANGE;
+}
+
+
+/** @interface_method_impl{RTLDROPS,pfnQueryProp} */
+static DECLCALLBACK(int) rtldrLX_QueryProp(PRTLDRMODINTERNAL pMod, RTLDRPROP enmProp, void const *pvBits,
+                                          void *pvBuf, size_t cbBuf, size_t *pcbRet)
+{
+    PKLDRMODLX pThis = RT_FROM_MEMBER(pMod, KLDRMODLX, Core);
+    int           rc;
+    switch (enmProp)
+    {
+        case RTLDRPROP_IMPORT_COUNT:
+            Assert(cbBuf == sizeof(uint32_t));
+            Assert(*pcbRet == cbBuf);
+            *(uint32_t *)pvBuf = pThis->Hdr.e32_impmodcnt;
+            rc = VINF_SUCCESS;
+            break;
+
+        case RTLDRPROP_IMPORT_MODULE:
+            rc = kldrModLXGetImport(pThis, pvBits, *(uint32_t const *)pvBuf, (char *)pvBuf, cbBuf, pcbRet);
+            break;
+
+        case RTLDRPROP_INTERNAL_NAME:
+            *pcbRet = pThis->cchName + 1;
+            if (cbBuf >= pThis->cchName + 1)
+            {
+                memcpy(pvBuf, pThis->pszName, pThis->cchName + 1);
+                rc = VINF_SUCCESS;
+            }
+            else
+                rc = VERR_BUFFER_OVERFLOW;
+            break;
+
+
+        default:
+            rc = VERR_NOT_FOUND;
+            break;
+    }
+    RT_NOREF_PV(pvBits);
+    return rc;
+}
+
+
+/**
+ * Operations for a Mach-O module interpreter.
+ */
+static const RTLDROPS s_rtldrLXOps=
 {
     "LX",
+    rtldrLX_Close,
     NULL,
-    kldrModLXCreate,
-    kldrModLXDestroy,
-    kldrModLXQuerySymbol,
-    kldrModLXEnumSymbols,
-    kldrModLXGetImport,
-    kldrModLXNumberOfImports,
-    NULL /* can execute one is optional */,
-    kldrModLXGetStackInfo,
-    kldrModLXQueryMainEntrypoint,
-    NULL /* pfnQueryImageUuid */,
-    NULL /* fixme */,
-    NULL /* fixme */,
-    kldrModLXEnumDbgInfo,
-    kldrModLXHasDbgInfo,
-    kldrModLXMap,
-    kldrModLXUnmap,
-    kldrModLXAllocTLS,
-    kldrModLXFreeTLS,
-    kldrModLXReload,
-    kldrModLXFixupMapping,
-    kldrModLXCallInit,
-    kldrModLXCallTerm,
-    kldrModLXCallThread,
-    kldrModLXSize,
-    kldrModLXGetBits,
-    kldrModLXRelocateBits,
-    NULL /* fixme: pfnMostlyDone */,
-    42 /* the end */
+    NULL /*pfnDone*/,
+    rtldrLX_EnumSymbols,
+    /* ext */
+    rtldrLX_GetImageSize,
+    rtldrLX_GetBits,
+    rtldrLX_RelocateBits,
+    rtldrLX_GetSymbolEx,
+    NULL /*pfnQueryForwarderInfo*/,
+    rtldrLX_EnumDbgInfo,
+    rtldrLX_EnumSegments,
+    rtldrLX_LinkAddressToSegOffset,
+    rtldrLX_LinkAddressToRva,
+    rtldrLX_SegOffsetToRva,
+    rtldrLX_RvaToSegOffset,
+    NULL,
+    rtldrLX_QueryProp,
+    NULL /*pfnVerifySignature*/,
+    NULL /*pfnHashImage*/,
+    NULL /*pfnUnwindFrame*/,
+    42
 };
 
+
+/**
+ * Handles opening LX images.
+ */
+DECLHIDDEN(int) rtldrLXOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offLxHdr,
+                            PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo)
+{
+
+    /*
+     * Create the instance data and do a minimal header validation.
+     */
+    PKLDRMODLX pThis = NULL;
+    int rc = kldrModLXDoCreate(pReader, offLxHdr, fFlags, &pThis, pErrInfo);
+    if (RT_SUCCESS(rc))
+    {
+        /*
+         * Match up against the requested CPU architecture.
+         */
+        if (   enmArch == RTLDRARCH_WHATEVER
+            || pThis->Core.enmArch == enmArch)
+        {
+            pThis->Core.pOps     = &s_rtldrLXOps;
+            pThis->Core.u32Magic = RTLDRMOD_MAGIC;
+            *phLdrMod = &pThis->Core;
+            return 0;
+        }
+        rc = VERR_LDR_ARCH_MISMATCH;
+    }
+    if (pThis)
+        RTMemFree(pThis);
+    return rc;
+
+}
+
Index: /trunk/src/VBox/Runtime/common/ldr/ldrMachO.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/ldr/ldrMachO.cpp	(revision 74637)
+++ /trunk/src/VBox/Runtime/common/ldr/ldrMachO.cpp	(revision 74638)
@@ -29,15 +29,26 @@
  */
 
-/*******************************************************************************
-*   Header Files                                                               *
-*******************************************************************************/
-#include <k/kLdr.h>
-#include "kLdrInternal.h"
-#include <k/kLdrFmts/mach-o.h>
-
-
-/*******************************************************************************
-*   Defined Constants And Macros                                               *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#define LOG_GROUP RTLOGGROUP_LDR
+#include <iprt/ldr.h>
+#include "internal/iprt.h"
+
+#include <iprt/asm.h>
+#include <iprt/assert.h>
+#include <iprt/err.h>
+#include <iprt/log.h>
+#include <iprt/mem.h>
+#include <iprt/string.h>
+
+#include <iprt/formats/mach-o.h>
+#include "internal/ldr.h"
+
+
+/*********************************************************************************************************************************
+*   Defined Constants And Macros                                                                                                 *
+*********************************************************************************************************************************/
 /** @def KLDRMODMACHO_STRICT
  * Define KLDRMODMACHO_STRICT to enabled strict checks in KLDRMODMACHO. */
@@ -48,5 +59,5 @@
  */
 #ifdef KLDRMODMACHO_STRICT
-# define KLDRMODMACHO_ASSERT(expr)  kHlpAssert(expr)
+# define KLDRMODMACHO_ASSERT(expr)  Assert(expr)
 #else
 # define KLDRMODMACHO_ASSERT(expr)  do {} while (0)
@@ -58,5 +69,5 @@
  */
 #ifdef KLDRMODMACHO_STRICT2
-# define KLDRMODMACHO_CHECK_RETURN(expr, rc)  kHlpAssertReturn(expr, rc)
+# define KLDRMODMACHO_CHECK_RETURN(expr, rc)  AssertReturn(expr, rc)
 #else
 # define KLDRMODMACHO_CHECK_RETURN(expr, rc)  do { if (!(expr)) { return (rc); } } while (0)
@@ -68,5 +79,5 @@
  */
 #ifdef KLDRMODMACHO_STRICT2
-# define KLDRMODMACHO_FAILED_RETURN(rc)  kHlpAssertFailedReturn(rc)
+# define KLDRMODMACHO_FAILED_RETURN(rc)  AssertFailedReturn(rc)
 #else
 # define KLDRMODMACHO_FAILED_RETURN(rc)  return (rc)
@@ -74,7 +85,7 @@
 
 
-/*******************************************************************************
-*   Structures and Typedefs                                                    *
-*******************************************************************************/
+/*********************************************************************************************************************************
+*   Structures and Typedefs                                                                                                      *
+*********************************************************************************************************************************/
 /**
  * Mach-O section details.
@@ -83,23 +94,23 @@
 {
     /** The size of the section (in bytes). */
-    KLDRSIZE                cb;
+    RTLDRADDR               cb;
     /** The link address of this section. */
-    KLDRADDR                LinkAddress;
+    RTLDRADDR               LinkAddress;
     /** The RVA of this section. */
-    KLDRADDR                RVA;
+    RTLDRADDR               RVA;
     /** The file offset of this section.
      * This is -1 if the section doesn't have a file backing. */
-    KLDRFOFF                offFile;
+    RTFOFF                  offFile;
     /** The number of fixups. */
-    KU32                    cFixups;
+    uint32_t                cFixups;
     /** The array of fixups. (lazy loaded) */
     macho_relocation_info_t *paFixups;
     /** The file offset of the fixups for this section.
      * This is -1 if the section doesn't have any fixups. */
-    KLDRFOFF                offFixups;
+    RTFOFF                  offFixups;
     /** Mach-O section flags. */
-    KU32                    fFlags;
+    uint32_t                fFlags;
     /** kLdr segment index. */
-    KU32                    iSegment;
+    uint32_t                iSegment;
     /** Pointer to the Mach-O section structure. */
     void                   *pvMachoSection;
@@ -113,8 +124,11 @@
 typedef struct KLDRMODMACHOSEG
 {
+    /** Common segment info. */
+    RTLDRSEG                SegInfo;
+
     /** The orignal segment number (in case we had to resort it). */
-    KU32                    iOrgSegNo;
+    uint32_t                iOrgSegNo;
     /** The number of sections in the segment. */
-    KU32                    cSections;
+    uint32_t                cSections;
     /** Pointer to the sections belonging to this segment.
      * The array resides in the big memory chunk allocated for
@@ -130,6 +144,13 @@
 typedef struct KLDRMODMACHO
 {
-    /** Pointer to the module. (Follows the section table.) */
-    PKLDRMOD                pMod;
+    /** Core module structure. */
+    RTLDRMODINTERNAL        Core;
+
+    /** The minium cpu this module was built for.
+     * This might not be accurate, so use kLdrModCanExecuteOn() to check. */
+    RTLDRCPU                enmCpu;
+    /** The number of segments in the module. */
+    uint32_t                cSegments;
+
     /** Pointer to the RDR file mapping of the raw file bits. NULL if not mapped. */
     const void             *pvBits;
@@ -137,27 +158,27 @@
     void                   *pvMapping;
     /** The module open flags. */
-    KU32                    fOpenFlags;
+    uint32_t                fOpenFlags;
 
     /** The offset of the image. (FAT fun.) */
-    KLDRFOFF                offImage;
+    RTFOFF                  offImage;
     /** The link address. */
-    KLDRADDR                LinkAddress;
+    RTLDRADDR               LinkAddress;
     /** The size of the mapped image. */
-    KLDRADDR                cbImage;
+    RTLDRADDR               cbImage;
     /** Whether we're capable of loading the image. */
-    KBOOL                   fCanLoad;
+    bool                    fCanLoad;
     /** Whether we're creating a global offset table segment.
      * This dependes on the cputype and image type. */
-    KBOOL                   fMakeGot;
+    bool                    fMakeGot;
     /** The size of a indirect GOT jump stub entry.
      * This is 0 if not needed. */
-    KU8                     cbJmpStub;
+    uint32_t                cbJmpStub;
     /** Effective file type.  If the original was a MH_OBJECT file, the
      * corresponding MH_DSYM needs the segment translation of a MH_OBJECT too.
      * The MH_DSYM normally has a separate __DWARF segment, but this is
      * automatically skipped during the transation. */
-    KU8                     uEffFileType;
+    uint32_t                uEffFileType;
     /** Pointer to the load commands. (endian converted) */
-    KU8                    *pbLoadCommands;
+    uint8_t                *pbLoadCommands;
     /** The Mach-O header. (endian converted)
      * @remark The reserved field is only valid for real 64-bit headers. */
@@ -165,26 +186,26 @@
 
     /** The offset of the symbol table. */
-    KLDRFOFF                offSymbols;
+    RTFOFF                  offSymbols;
     /** The number of symbols. */
-    KU32                    cSymbols;
+    uint32_t                cSymbols;
     /** The pointer to the loaded symbol table. */
     void                   *pvaSymbols;
     /** The offset of the string table. */
-    KLDRFOFF                offStrings;
+    RTFOFF                  offStrings;
     /** The size of the of the string table. */
-    KU32                    cchStrings;
+    uint32_t                cchStrings;
     /** Pointer to the loaded string table. */
     char                   *pchStrings;
 
     /** The image UUID, all zeros if not found. */
-    KU8                     abImageUuid[16];
+    uint32_t                abImageUuid[16];
 
     /** The RVA of the Global Offset Table. */
-    KLDRADDR                GotRVA;
+    RTLDRADDR               GotRVA;
     /** The RVA of the indirect GOT jump stubs.  */
-    KLDRADDR                JmpStubsRVA;
+    RTLDRADDR               JmpStubsRVA;
 
     /** The number of sections. */
-    KU32                    cSections;
+    uint32_t                cSections;
     /** Pointer to the section array running in parallel to the Mach-O one. */
     PKLDRMODMACHOSECT       paSections;
@@ -196,97 +217,48 @@
 
 
-/*******************************************************************************
-*   Internal Functions                                                         *
-*******************************************************************************/
+
+/*********************************************************************************************************************************
+*   Internal Functions                                                                                                           *
+*********************************************************************************************************************************/
 #if 0
-static KI32 kldrModMachONumberOfImports(PKLDRMOD pMod, const void *pvBits);
+static int32_t kldrModMachONumberOfImports(PRTLDRMODINTERNAL pMod, const void *pvBits);
 #endif
-static int kldrModMachORelocateBits(PKLDRMOD pMod, void *pvBits, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress,
-                                    PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
-
-static int  kldrModMachODoCreate(PKRDR pRdr, KLDRFOFF offImage, KU32 fOpenFlags, PKLDRMODMACHO *ppMod);
-static int  kldrModMachOPreParseLoadCommands(KU8 *pbLoadCommands, const mach_header_32_t *pHdr, PKRDR pRdr, KLDRFOFF offImage,
-                                             KU32 fOpenFlags, KU32 *pcSegments, KU32 *pcSections, KU32 *pcbStringPool,
-                                             PKBOOL pfCanLoad, PKLDRADDR pLinkAddress, KU8 *puEffFileType);
-static int  kldrModMachOParseLoadCommands(PKLDRMODMACHO pModMachO, char *pbStringPool, KU32 cbStringPool);
-static int  kldrModMachOAdjustBaseAddress(PKLDRMODMACHO pModMachO, PKLDRADDR pBaseAddress);
-
-/*static int  kldrModMachOLoadLoadCommands(PKLDRMODMACHO pModMachO);*/
-static int  kldrModMachOLoadObjSymTab(PKLDRMODMACHO pModMachO);
-static int  kldrModMachOLoadFixups(PKLDRMODMACHO pModMachO, KLDRFOFF offFixups, KU32 cFixups, macho_relocation_info_t **ppaFixups);
-static int  kldrModMachOMapVirginBits(PKLDRMODMACHO pModMachO);
-
-static int  kldrModMachODoQuerySymbol32Bit(PKLDRMODMACHO pModMachO, const macho_nlist_32_t *paSyms, KU32 cSyms, const char *pchStrings,
-                                           KU32 cchStrings, KLDRADDR BaseAddress, KU32 iSymbol, const char *pchSymbol,
-                                           KU32 cchSymbol, PKLDRADDR puValue, KU32 *pfKind);
-static int  kldrModMachODoQuerySymbol64Bit(PKLDRMODMACHO pModMachO, const macho_nlist_64_t *paSyms, KU32 cSyms, const char *pchStrings,
-                                           KU32 cchStrings, KLDRADDR BaseAddress, KU32 iSymbol, const char *pchSymbol,
-                                           KU32 cchSymbol, PKLDRADDR puValue, KU32 *pfKind);
-static int  kldrModMachODoEnumSymbols32Bit(PKLDRMODMACHO pModMachO, const macho_nlist_32_t *paSyms, KU32 cSyms,
-                                           const char *pchStrings, KU32 cchStrings, KLDRADDR BaseAddress,
-                                           KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser);
-static int  kldrModMachODoEnumSymbols64Bit(PKLDRMODMACHO pModMachO, const macho_nlist_64_t *paSyms, KU32 cSyms,
-                                           const char *pchStrings, KU32 cchStrings, KLDRADDR BaseAddress,
-                                           KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser);
-static int  kldrModMachOObjDoImports(PKLDRMODMACHO pModMachO, KLDRADDR BaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);
-static int  kldrModMachOObjDoFixups(PKLDRMODMACHO pModMachO, void *pvMapping, KLDRADDR NewBaseAddress);
-static int  kldrModMachOFixupSectionGeneric32Bit(PKLDRMODMACHO pModMachO, KU8 *pbSectBits, PKLDRMODMACHOSECT pFixupSect,
-                                                 macho_nlist_32_t *paSyms, KU32 cSyms, KLDRADDR NewBaseAddress);
-static int  kldrModMachOFixupSectionAMD64(PKLDRMODMACHO pModMachO, KU8 *pbSectBits, PKLDRMODMACHOSECT pFixupSect,
-                                          macho_nlist_64_t *paSyms, KU32 cSyms, KLDRADDR NewBaseAddress);
-
-static int  kldrModMachOMakeGOT(PKLDRMODMACHO pModMachO, void *pvBits, KLDRADDR NewBaseAddress);
-
-/*static int  kldrModMachODoFixups(PKLDRMODMACHO pModMachO, void *pvMapping, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress);
-static int  kldrModMachODoImports(PKLDRMODMACHO pModMachO, void *pvMapping, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser);*/
-
-
-/**
- * Create a loader module instance interpreting the executable image found
- * in the specified file provider instance.
- *
- * @returns 0 on success and *ppMod pointing to a module instance.
- *          On failure, a non-zero OS specific error code is returned.
- * @param   pOps            Pointer to the registered method table.
- * @param   pRdr            The file provider instance to use.
- * @param   fFlags          Flags, MBZ.
- * @param   enmCpuArch      The desired CPU architecture. KCPUARCH_UNKNOWN means
- *                          anything goes, but with a preference for the current
- *                          host architecture.
- * @param   offNewHdr       The offset of the new header in MZ files. -1 if not found.
- * @param   ppMod           Where to store the module instance pointer.
- */
-static int kldrModMachOCreate(PCKLDRMODOPS pOps, PKRDR pRdr, KU32 fFlags, KCPUARCH enmCpuArch, KLDRFOFF offNewHdr, PPKLDRMOD ppMod)
-{
-    PKLDRMODMACHO pModMachO;
-    int rc;
-
-    /*
-     * Create the instance data and do a minimal header validation.
-     */
-    rc = kldrModMachODoCreate(pRdr, offNewHdr == -1 ? 0 : offNewHdr, fFlags, &pModMachO);
-    if (!rc)
-    {
-
-        /*
-         * Match up against the requested CPU architecture.
-         */
-        if (    enmCpuArch == KCPUARCH_UNKNOWN
-            ||  pModMachO->pMod->enmArch == enmCpuArch)
-        {
-            pModMachO->pMod->pOps = pOps;
-            pModMachO->pMod->u32Magic = KLDRMOD_MAGIC;
-            *ppMod = pModMachO->pMod;
-            return 0;
-        }
-        rc = KLDR_ERR_CPU_ARCH_MISMATCH;
-    }
-    if (pModMachO)
-    {
-        kHlpFree(pModMachO->pbLoadCommands);
-        kHlpFree(pModMachO);
-    }
-    return rc;
-}
+static DECLCALLBACK(int) rtldrMachO_RelocateBits(PRTLDRMODINTERNAL pMod, void *pvBits, RTUINTPTR NewBaseAddress,
+                                                 RTUINTPTR OldBaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser);
+
+
+static int  kldrModMachOPreParseLoadCommands(uint8_t *pbLoadCommands, const mach_header_32_t *pHdr, PRTLDRREADER pRdr, RTFOFF   offImage,
+                                             uint32_t fOpenFlags, uint32_t *pcSegments, uint32_t *pcSections, uint32_t *pcbStringPool,
+                                             bool *pfCanLoad, PRTLDRADDR pLinkAddress, uint8_t *puEffFileType);
+static int  kldrModMachOParseLoadCommands(PKLDRMODMACHO pThis, char *pbStringPool, uint32_t cbStringPool);
+
+static int  kldrModMachOLoadObjSymTab(PKLDRMODMACHO pThis);
+static int  kldrModMachOLoadFixups(PKLDRMODMACHO pThis, RTFOFF offFixups, uint32_t cFixups, macho_relocation_info_t **ppaFixups);
+static int  kldrModMachOMapVirginBits(PKLDRMODMACHO pThis);
+
+static int  kldrModMachODoQuerySymbol32Bit(PKLDRMODMACHO pThis, const macho_nlist_32_t *paSyms, uint32_t cSyms, const char *pchStrings,
+                                           uint32_t cchStrings, RTLDRADDR BaseAddress, uint32_t iSymbol, const char *pchSymbol,
+                                           uint32_t cchSymbol, PRTLDRADDR puValue, uint32_t *pfKind);
+static int  kldrModMachODoQuerySymbol64Bit(PKLDRMODMACHO pThis, const macho_nlist_64_t *paSyms, uint32_t cSyms, const char *pchStrings,
+                                           uint32_t cchStrings, RTLDRADDR BaseAddress, uint32_t iSymbol, const char *pchSymbol,
+                                           uint32_t cchSymbol, PRTLDRADDR puValue, uint32_t *pfKind);
+static int  kldrModMachODoEnumSymbols32Bit(PKLDRMODMACHO pThis, const macho_nlist_32_t *paSyms, uint32_t cSyms,
+                                           const char *pchStrings, uint32_t cchStrings, RTLDRADDR BaseAddress,
+                                           uint32_t fFlags, PFNRTLDRENUMSYMS pfnCallback, void *pvUser);
+static int  kldrModMachODoEnumSymbols64Bit(PKLDRMODMACHO pThis, const macho_nlist_64_t *paSyms, uint32_t cSyms,
+                                           const char *pchStrings, uint32_t cchStrings, RTLDRADDR BaseAddress,
+                                           uint32_t fFlags, PFNRTLDRENUMSYMS pfnCallback, void *pvUser);
+static int  kldrModMachOObjDoImports(PKLDRMODMACHO pThis, RTLDRADDR BaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser);
+static int  kldrModMachOObjDoFixups(PKLDRMODMACHO pThis, void *pvMapping, RTLDRADDR NewBaseAddress);
+static int  kldrModMachOFixupSectionGeneric32Bit(PKLDRMODMACHO pThis, uint8_t *pbSectBits, PKLDRMODMACHOSECT pFixupSect,
+                                                 macho_nlist_32_t *paSyms, uint32_t cSyms, RTLDRADDR NewBaseAddress);
+static int  kldrModMachOFixupSectionAMD64(PKLDRMODMACHO pThis, uint8_t *pbSectBits, PKLDRMODMACHOSECT pFixupSect,
+                                          macho_nlist_64_t *paSyms, uint32_t cSyms, RTLDRADDR NewBaseAddress);
+
+static int  kldrModMachOMakeGOT(PKLDRMODMACHO pThis, void *pvBits, RTLDRADDR NewBaseAddress);
+
+/*static int  kldrModMachODoFixups(PKLDRMODMACHO pThis, void *pvMapping, RTLDRADDR NewBaseAddress, RTLDRADDR OldBaseAddress);
+static int  kldrModMachODoImports(PKLDRMODMACHO pThis, void *pvMapping, PFNRTLDRIMPORT pfnGetImport, void *pvUser);*/
+
 
 
@@ -295,6 +267,12 @@
  * simplify cleanup on failure.
  */
-static int kldrModMachODoCreate(PKRDR pRdr, KLDRFOFF offImage, KU32 fOpenFlags, PKLDRMODMACHO *ppModMachO)
-{
+static int kldrModMachODoCreate(PRTLDRREADER pRdr, RTFOFF offImage, uint32_t fOpenFlags,
+                                PKLDRMODMACHO *ppModMachO, PRTERRINFO pErrInfo)
+{
+    *ppModMachO = NULL;
+
+    /*
+     * Read the Mach-O header.
+     */
     union
     {
@@ -302,48 +280,30 @@
         mach_header_64_t    Hdr64;
     } s;
-    PKLDRMODMACHO pModMachO;
-    PKLDRMOD pMod;
-    KU8 *pbLoadCommands;
-    KU32 cSegments = 0; /* (MSC maybe used uninitialized) */
-    KU32 cSections = 0; /* (MSC maybe used uninitialized) */
-    KU32 cbStringPool = 0; /* (MSC maybe used uninitialized) */
-    KSIZE cchFilename;
-    KSIZE cb;
-    KBOOL fMakeGot;
-    KBOOL fCanLoad = K_TRUE;
-    KLDRADDR LinkAddress = NIL_KLDRADDR; /* (MSC maybe used uninitialized) */
-    KU8 cbJmpStub;
-    KU8 uEffFileType = 0; /* (MSC maybe used uninitialized) */
-    int rc;
-    *ppModMachO = NULL;
-
-    kHlpAssert(&s.Hdr32.magic == &s.Hdr64.magic);
-    kHlpAssert(&s.Hdr32.flags == &s.Hdr64.flags);
-
-    /*
-     * Read the Mach-O header.
-     */
-    rc = kRdrRead(pRdr, &s, sizeof(s), offImage);
+    Assert(&s.Hdr32.magic == &s.Hdr64.magic);
+    Assert(&s.Hdr32.flags == &s.Hdr64.flags);
+    int rc = pRdr->pfnRead(pRdr, &s, sizeof(s), offImage);
     if (rc)
-        return rc;
+        return RTErrInfoSetF(pErrInfo, rc, "Error reading Mach-O header at %RTfoff: %Rrc", offImage, rc);
     if (    s.Hdr32.magic != IMAGE_MACHO32_SIGNATURE
-        &&  s.Hdr32.magic != IMAGE_MACHO64_SIGNATURE
-        )
+        &&  s.Hdr32.magic != IMAGE_MACHO64_SIGNATURE)
     {
         if (    s.Hdr32.magic == IMAGE_MACHO32_SIGNATURE_OE
             ||  s.Hdr32.magic == IMAGE_MACHO64_SIGNATURE_OE)
-            return KLDR_ERR_MACHO_OTHER_ENDIAN_NOT_SUPPORTED;
-        return KLDR_ERR_UNKNOWN_FORMAT;
+            return VERR_LDRMACHO_OTHER_ENDIAN_NOT_SUPPORTED;
+        return VERR_INVALID_EXE_SIGNATURE;
     }
 
     /* sanity checks. */
-    if (    s.Hdr32.sizeofcmds > kRdrSize(pRdr) - sizeof(mach_header_32_t)
+    if (    s.Hdr32.sizeofcmds > pRdr->pfnSize(pRdr) - sizeof(mach_header_32_t)
         ||  s.Hdr32.sizeofcmds < sizeof(load_command_t) * s.Hdr32.ncmds
         ||  (s.Hdr32.flags & ~MH_VALID_FLAGS))
-        return KLDR_ERR_MACHO_BAD_HEADER;
+        return VERR_LDRMACHO_BAD_HEADER;
+
+    bool fMakeGot;
+    uint8_t cbJmpStub;
     switch (s.Hdr32.cputype)
     {
         case CPU_TYPE_X86:
-            fMakeGot = K_FALSE;
+            fMakeGot = false;
             cbJmpStub = 0;
             break;
@@ -353,6 +313,7 @@
             break;
         default:
-            return KLDR_ERR_MACHO_UNSUPPORTED_MACHINE;
-    }
+            return VERR_LDRMACHO_UNSUPPORTED_MACHINE;
+    }
+
     if (   s.Hdr32.filetype != MH_OBJECT
         && s.Hdr32.filetype != MH_EXECUTE
@@ -361,17 +322,24 @@
         && s.Hdr32.filetype != MH_DSYM
         && s.Hdr32.filetype != MH_KEXT_BUNDLE)
-        return KLDR_ERR_MACHO_UNSUPPORTED_FILE_TYPE;
+        return VERR_LDRMACHO_UNSUPPORTED_FILE_TYPE;
 
     /*
      * Read and pre-parse the load commands to figure out how many segments we'll be needing.
      */
-    pbLoadCommands = kHlpAlloc(s.Hdr32.sizeofcmds);
+    uint8_t *pbLoadCommands = (uint8_t *)RTMemAlloc(s.Hdr32.sizeofcmds);
     if (!pbLoadCommands)
-        return KERR_NO_MEMORY;
-    rc = kRdrRead(pRdr, pbLoadCommands, s.Hdr32.sizeofcmds,
-                     s.Hdr32.magic == IMAGE_MACHO32_SIGNATURE
-                  || s.Hdr32.magic == IMAGE_MACHO32_SIGNATURE_OE
-                  ? sizeof(mach_header_32_t) + offImage
-                  : sizeof(mach_header_64_t) + offImage);
+        return VERR_NO_MEMORY;
+    rc = pRdr->pfnRead(pRdr, pbLoadCommands, s.Hdr32.sizeofcmds,
+                          s.Hdr32.magic == IMAGE_MACHO32_SIGNATURE
+                       || s.Hdr32.magic == IMAGE_MACHO32_SIGNATURE_OE
+                       ? sizeof(mach_header_32_t) + offImage
+                       : sizeof(mach_header_64_t) + offImage);
+
+    uint32_t    cSegments    = 0;
+    uint32_t    cSections    = 0;
+    uint32_t    cbStringPool = 0;
+    bool        fCanLoad     = true;
+    RTLDRADDR   LinkAddress  = NIL_RTLDRADDR;
+    uint8_t     uEffFileType = 0;
     if (!rc)
         rc = kldrModMachOPreParseLoadCommands(pbLoadCommands, &s.Hdr32, pRdr, offImage, fOpenFlags,
@@ -379,5 +347,5 @@
     if (rc)
     {
-        kHlpFree(pbLoadCommands);
+        RTMemFree(pbLoadCommands);
         return rc;
     }
@@ -388,48 +356,36 @@
      * Calc the instance size, allocate and initialize it.
      */
-    cchFilename = kHlpStrLen(kRdrName(pRdr));
-    cb = K_ALIGN_Z(  K_OFFSETOF(KLDRMODMACHO, aSegments[cSegments])
-                      + sizeof(KLDRMODMACHOSECT) * cSections, 16)
-       + K_OFFSETOF(KLDRMOD, aSegments[cSegments])
-       + cchFilename + 1
-       + cbStringPool;
-    pModMachO = (PKLDRMODMACHO)kHlpAlloc(cb);
-    if (!pModMachO)
-        return KERR_NO_MEMORY;
-    *ppModMachO = pModMachO;
-    pModMachO->pbLoadCommands = pbLoadCommands;
-    pModMachO->offImage = offImage;
-
-    /* KLDRMOD */
-    pMod = (PKLDRMOD)((KU8 *)pModMachO + K_ALIGN_Z(  K_OFFSETOF(KLDRMODMACHO, aSegments[cSegments])
-                                                      + sizeof(KLDRMODMACHOSECT) * cSections, 16));
-    pMod->pvData = pModMachO;
-    pMod->pRdr = pRdr;
-    pMod->pOps = NULL;      /* set upon success. */
-    pMod->cSegments = cSegments;
-    pMod->cchFilename = (KU32)cchFilename;
-    pMod->pszFilename = (char *)&pMod->aSegments[pMod->cSegments];
-    kHlpMemCopy((char *)pMod->pszFilename, kRdrName(pRdr), cchFilename + 1);
-    pMod->pszName = kHlpGetFilename(pMod->pszFilename);
-    pMod->cchName = (KU32)(cchFilename - (pMod->pszName - pMod->pszFilename));
-    pMod->fFlags = 0;
+    size_t const cbModAndSegs = RT_ALIGN_Z(RT_UOFFSETOF_DYN(KLDRMODMACHO, aSegments[cSegments])
+                                           + sizeof(KLDRMODMACHOSECT) * cSections, 16);
+    PKLDRMODMACHO pThis = (PKLDRMODMACHO)RTMemAlloc(cbModAndSegs + cbStringPool);
+    if (!pThis)
+        return VERR_NO_MEMORY;
+    *ppModMachO = pThis;
+    pThis->pbLoadCommands = pbLoadCommands;
+    pThis->offImage = offImage;
+
+    /* Core & CPU.*/
+    pThis->Core.u32Magic  = 0;          /* set by caller */
+    pThis->Core.eState    = LDR_STATE_OPENED;
+    pThis->Core.pOps      = NULL;       /* set by caller. */
+    pThis->Core.pReader   = pRdr;
     switch (s.Hdr32.cputype)
     {
         case CPU_TYPE_X86:
-            pMod->enmArch = KCPUARCH_X86_32;
-            pMod->enmEndian = KLDRENDIAN_LITTLE;
+            pThis->Core.enmArch   = RTLDRARCH_X86_32;
+            pThis->Core.enmEndian = RTLDRENDIAN_LITTLE;
             switch (s.Hdr32.cpusubtype)
             {
                 case CPU_SUBTYPE_I386_ALL: /* == CPU_SUBTYPE_386 */
-                    pMod->enmCpu = KCPU_X86_32_BLEND;
+                    pThis->enmCpu = RTLDRCPU_X86_32_BLEND;
                     break;
                 case CPU_SUBTYPE_486:
-                    pMod->enmCpu = KCPU_I486;
+                    pThis->enmCpu = RTLDRCPU_I486;
                     break;
                 case CPU_SUBTYPE_486SX:
-                    pMod->enmCpu = KCPU_I486SX;
+                    pThis->enmCpu = RTLDRCPU_I486SX;
                     break;
                 case CPU_SUBTYPE_PENT: /* == CPU_SUBTYPE_586 */
-                    pMod->enmCpu = KCPU_I586;
+                    pThis->enmCpu = RTLDRCPU_I586;
                     break;
                 case CPU_SUBTYPE_PENTPRO:
@@ -441,5 +397,5 @@
                 case CPU_SUBTYPE_PENTIUM_3_M:
                 case CPU_SUBTYPE_PENTIUM_3_XEON:
-                    pMod->enmCpu = KCPU_I686;
+                    pThis->enmCpu = RTLDRCPU_I686;
                     break;
                 case CPU_SUBTYPE_PENTIUM_M:
@@ -448,5 +404,5 @@
                 case CPU_SUBTYPE_XEON:
                 case CPU_SUBTYPE_XEON_MP:
-                    pMod->enmCpu = KCPU_P4;
+                    pThis->enmCpu = RTLDRCPU_P4;
                     break;
 
@@ -456,68 +412,67 @@
                         && s.Hdr32.filetype   == MH_OBJECT)
                         break;
-                    return KLDR_ERR_MACHO_UNSUPPORTED_MACHINE;
+                    return VERR_LDRMACHO_UNSUPPORTED_MACHINE;
             }
             break;
 
         case CPU_TYPE_X86_64:
-            pMod->enmArch = KCPUARCH_AMD64;
-            pMod->enmEndian = KLDRENDIAN_LITTLE;
+            pThis->Core.enmArch   = RTLDRARCH_AMD64;
+            pThis->Core.enmEndian = RTLDRENDIAN_LITTLE;
             switch (s.Hdr32.cpusubtype & ~CPU_SUBTYPE_MASK)
             {
-                case CPU_SUBTYPE_X86_64_ALL:        pMod->enmCpu = KCPU_AMD64_BLEND; break;
+                case CPU_SUBTYPE_X86_64_ALL: pThis->enmCpu = RTLDRCPU_AMD64_BLEND; break;
                 default:
-                    return KLDR_ERR_MACHO_UNSUPPORTED_MACHINE;
+                    return VERR_LDRMACHO_UNSUPPORTED_MACHINE;
             }
             break;
 
         default:
-            return KLDR_ERR_MACHO_UNSUPPORTED_MACHINE;
-    }
-
-    pMod->enmFmt = KLDRFMT_MACHO;
+            return VERR_LDRMACHO_UNSUPPORTED_MACHINE;
+    }
+
+    pThis->Core.enmFormat = RTLDRFMT_MACHO;
     switch (s.Hdr32.filetype)
     {
-        case MH_OBJECT:     pMod->enmType = KLDRTYPE_OBJECT; break;
-        case MH_EXECUTE:    pMod->enmType = KLDRTYPE_EXECUTABLE_FIXED; break;
-        case MH_DYLIB:      pMod->enmType = KLDRTYPE_SHARED_LIBRARY_RELOCATABLE; break;
-        case MH_BUNDLE:     pMod->enmType = KLDRTYPE_SHARED_LIBRARY_RELOCATABLE; break;
-        case MH_KEXT_BUNDLE:pMod->enmType = KLDRTYPE_SHARED_LIBRARY_RELOCATABLE; break;
-        case MH_DSYM:       pMod->enmType = KLDRTYPE_DEBUG_INFO; break;
+        case MH_OBJECT:     pThis->Core.enmType = RTLDRTYPE_OBJECT; break;
+        case MH_EXECUTE:    pThis->Core.enmType = RTLDRTYPE_EXECUTABLE_FIXED; break;
+        case MH_DYLIB:      pThis->Core.enmType = RTLDRTYPE_SHARED_LIBRARY_RELOCATABLE; break;
+        case MH_BUNDLE:     pThis->Core.enmType = RTLDRTYPE_SHARED_LIBRARY_RELOCATABLE; break;
+        case MH_KEXT_BUNDLE:pThis->Core.enmType = RTLDRTYPE_SHARED_LIBRARY_RELOCATABLE; break;
+        case MH_DSYM:       pThis->Core.enmType = RTLDRTYPE_DEBUG_INFO; break;
         default:
-            return KLDR_ERR_MACHO_UNSUPPORTED_FILE_TYPE;
-    }
-    pMod->u32Magic = 0;     /* set upon success. */
+            return VERR_LDRMACHO_UNSUPPORTED_FILE_TYPE;
+    }
 
     /* KLDRMODMACHO */
-    pModMachO->pMod = pMod;
-    pModMachO->pvBits = NULL;
-    pModMachO->pvMapping = NULL;
-    pModMachO->fOpenFlags = fOpenFlags;
-    pModMachO->Hdr = s.Hdr64;
+    pThis->cSegments = cSegments;
+    pThis->pvBits = NULL;
+    pThis->pvMapping = NULL;
+    pThis->fOpenFlags = fOpenFlags;
+    pThis->Hdr = s.Hdr64;
     if (    s.Hdr32.magic == IMAGE_MACHO32_SIGNATURE
         ||  s.Hdr32.magic == IMAGE_MACHO32_SIGNATURE_OE)
-        pModMachO->Hdr.reserved = 0;
-    pModMachO->LinkAddress = LinkAddress;
-    pModMachO->cbImage = 0;
-    pModMachO->fCanLoad = fCanLoad;
-    pModMachO->fMakeGot = fMakeGot;
-    pModMachO->cbJmpStub = cbJmpStub;
-    pModMachO->uEffFileType = uEffFileType;
-    pModMachO->offSymbols = 0;
-    pModMachO->cSymbols = 0;
-    pModMachO->pvaSymbols = NULL;
-    pModMachO->offStrings = 0;
-    pModMachO->cchStrings = 0;
-    pModMachO->pchStrings = NULL;
-    kHlpMemSet(pModMachO->abImageUuid, 0, sizeof(pModMachO->abImageUuid));
-    pModMachO->GotRVA = NIL_KLDRADDR;
-    pModMachO->JmpStubsRVA = NIL_KLDRADDR;
-    pModMachO->cSections = cSections;
-    pModMachO->paSections = (PKLDRMODMACHOSECT)&pModMachO->aSegments[pModMachO->pMod->cSegments];
+        pThis->Hdr.reserved = 0;
+    pThis->LinkAddress = LinkAddress;
+    pThis->cbImage = 0;
+    pThis->fCanLoad = fCanLoad;
+    pThis->fMakeGot = fMakeGot;
+    pThis->cbJmpStub = cbJmpStub;
+    pThis->uEffFileType = uEffFileType;
+    pThis->offSymbols = 0;
+    pThis->cSymbols = 0;
+    pThis->pvaSymbols = NULL;
+    pThis->offStrings = 0;
+    pThis->cchStrings = 0;
+    pThis->pchStrings = NULL;
+    memset(pThis->abImageUuid, 0, sizeof(pThis->abImageUuid));
+    pThis->GotRVA = NIL_RTLDRADDR;
+    pThis->JmpStubsRVA = NIL_RTLDRADDR;
+    pThis->cSections = cSections;
+    pThis->paSections = (PKLDRMODMACHOSECT)&pThis->aSegments[pThis->cSegments];
 
     /*
      * Setup the KLDRMOD segment array.
      */
-    rc = kldrModMachOParseLoadCommands(pModMachO, (char *)pMod->pszFilename + pMod->cchFilename + 1, cbStringPool);
+    rc = kldrModMachOParseLoadCommands(pThis, (char *)pThis + cbModAndSegs, cbStringPool);
     if (rc)
         return rc;
@@ -551,5 +506,5 @@
  *
  * @returns 0 on success.
- * @returns KLDR_ERR_MACHO_* on failure.
+ * @returns VERR_LDRMACHO_* on failure.
  * @param   pbLoadCommands  The load commands to parse.
  * @param   pHdr            The header.
@@ -563,11 +518,11 @@
  *                          lowest segment address).
  */
-static int  kldrModMachOPreParseLoadCommands(KU8 *pbLoadCommands, const mach_header_32_t *pHdr, PKRDR pRdr, KLDRFOFF offImage,
-                                             KU32 fOpenFlags, KU32 *pcSegments, KU32 *pcSections, KU32 *pcbStringPool,
-                                             PKBOOL pfCanLoad, PKLDRADDR pLinkAddress, KU8 *puEffFileType)
+static int  kldrModMachOPreParseLoadCommands(uint8_t *pbLoadCommands, const mach_header_32_t *pHdr, PRTLDRREADER pRdr, RTFOFF   offImage,
+                                             uint32_t fOpenFlags, uint32_t *pcSegments, uint32_t *pcSections, uint32_t *pcbStringPool,
+                                             bool *pfCanLoad, PRTLDRADDR pLinkAddress, uint8_t *puEffFileType)
 {
     union
     {
-        KU8                  *pb;
+        uint8_t              *pb;
         load_command_t       *pLoadCmd;
         segment_command_32_t *pSeg32;
@@ -577,22 +532,22 @@
         uuid_command_t       *pUuid;
     } u;
-    const KU64 cbFile = kRdrSize(pRdr) - offImage;
-    KU32 cSegments = 0;
-    KU32 cSections = 0;
-    KSIZE cbStringPool = 0;
-    KU32 cLeft = pHdr->ncmds;
-    KU32 cbLeft = pHdr->sizeofcmds;
-    KU8 *pb = pbLoadCommands;
+    const uint64_t cbFile = pRdr->pfnSize(pRdr) - offImage;
+    uint32_t cSegments = 0;
+    uint32_t cSections = 0;
+    size_t cbStringPool = 0;
+    uint32_t cLeft = pHdr->ncmds;
+    uint32_t cbLeft = pHdr->sizeofcmds;
+    uint8_t *pb = pbLoadCommands;
     int cSegmentCommands = 0;
     int cSymbolTabs = 0;
     int fConvertEndian = pHdr->magic == IMAGE_MACHO32_SIGNATURE_OE
                       || pHdr->magic == IMAGE_MACHO64_SIGNATURE_OE;
-    KU8 uEffFileType = *puEffFileType = pHdr->filetype;
+    uint8_t uEffFileType = *puEffFileType = pHdr->filetype;
 
     *pcSegments = 0;
     *pcSections = 0;
     *pcbStringPool = 0;
-    *pfCanLoad = K_TRUE;
-    *pLinkAddress = ~(KLDRADDR)0;
+    *pfCanLoad = true;
+    *pLinkAddress = ~(RTLDRADDR)0;
 
     while (cLeft-- > 0)
@@ -603,11 +558,11 @@
          * Convert and validate command header.
          */
-        KLDRMODMACHO_CHECK_RETURN(cbLeft >= sizeof(load_command_t), KLDR_ERR_MACHO_BAD_LOAD_COMMAND);
+        KLDRMODMACHO_CHECK_RETURN(cbLeft >= sizeof(load_command_t), VERR_LDRMACHO_BAD_LOAD_COMMAND);
         if (fConvertEndian)
         {
-            u.pLoadCmd->cmd = K_E2E_U32(u.pLoadCmd->cmd);
-            u.pLoadCmd->cmdsize = K_E2E_U32(u.pLoadCmd->cmdsize);
-        }
-        KLDRMODMACHO_CHECK_RETURN(u.pLoadCmd->cmdsize <= cbLeft, KLDR_ERR_MACHO_BAD_LOAD_COMMAND);
+            u.pLoadCmd->cmd = RT_BSWAP_U32(u.pLoadCmd->cmd);
+            u.pLoadCmd->cmdsize = RT_BSWAP_U32(u.pLoadCmd->cmdsize);
+        }
+        KLDRMODMACHO_CHECK_RETURN(u.pLoadCmd->cmdsize <= cbLeft, VERR_LDRMACHO_BAD_LOAD_COMMAND);
         cbLeft -= u.pLoadCmd->cmdsize;
         pb += u.pLoadCmd->cmdsize;
@@ -623,21 +578,21 @@
                 section_32_t   *pFirstSect    = (section_32_t *)(pSrcSeg + 1);
                 section_32_t   *pSect         = pFirstSect;
-                KU32            cSectionsLeft = pSrcSeg->nsects;
-                KU64            offSect       = 0;
+                uint32_t        cSectionsLeft = pSrcSeg->nsects;
+                uint64_t            offSect       = 0;
 
                 /* Convert and verify the segment. */
-                KLDRMODMACHO_CHECK_RETURN(u.pLoadCmd->cmdsize >= sizeof(segment_command_32_t), KLDR_ERR_MACHO_BAD_LOAD_COMMAND);
+                KLDRMODMACHO_CHECK_RETURN(u.pLoadCmd->cmdsize >= sizeof(segment_command_32_t), VERR_LDRMACHO_BAD_LOAD_COMMAND);
                 KLDRMODMACHO_CHECK_RETURN(   pHdr->magic == IMAGE_MACHO32_SIGNATURE_OE
-                                          || pHdr->magic == IMAGE_MACHO32_SIGNATURE, KLDR_ERR_MACHO_BIT_MIX);
+                                          || pHdr->magic == IMAGE_MACHO32_SIGNATURE, VERR_LDRMACHO_BIT_MIX);
                 if (fConvertEndian)
                 {
-                    pSrcSeg->vmaddr   = K_E2E_U32(pSrcSeg->vmaddr);
-                    pSrcSeg->vmsize   = K_E2E_U32(pSrcSeg->vmsize);
-                    pSrcSeg->fileoff  = K_E2E_U32(pSrcSeg->fileoff);
-                    pSrcSeg->filesize = K_E2E_U32(pSrcSeg->filesize);
-                    pSrcSeg->maxprot  = K_E2E_U32(pSrcSeg->maxprot);
-                    pSrcSeg->initprot = K_E2E_U32(pSrcSeg->initprot);
-                    pSrcSeg->nsects   = K_E2E_U32(pSrcSeg->nsects);
-                    pSrcSeg->flags    = K_E2E_U32(pSrcSeg->flags);
+                    pSrcSeg->vmaddr   = RT_BSWAP_U32(pSrcSeg->vmaddr);
+                    pSrcSeg->vmsize   = RT_BSWAP_U32(pSrcSeg->vmsize);
+                    pSrcSeg->fileoff  = RT_BSWAP_U32(pSrcSeg->fileoff);
+                    pSrcSeg->filesize = RT_BSWAP_U32(pSrcSeg->filesize);
+                    pSrcSeg->maxprot  = RT_BSWAP_U32(pSrcSeg->maxprot);
+                    pSrcSeg->initprot = RT_BSWAP_U32(pSrcSeg->initprot);
+                    pSrcSeg->nsects   = RT_BSWAP_U32(pSrcSeg->nsects);
+                    pSrcSeg->flags    = RT_BSWAP_U32(pSrcSeg->flags);
                 }
 
@@ -645,6 +600,6 @@
                 #define VALIDATE_AND_ADD_SEGMENT(a_cBits) \
                 do { \
-                    KBOOL fSkipSeg = !kHlpStrComp(pSrcSeg->segname, "__DWARF")   /* Note: Not for non-object files. */ \
-                                  || (   !kHlpStrComp(pSrcSeg->segname, "__CTF") /* Their CTF tool did/does weird things, */ \
+                    bool fSkipSeg = !strcmp(pSrcSeg->segname, "__DWARF")   /* Note: Not for non-object files. */ \
+                                  || (   !strcmp(pSrcSeg->segname, "__CTF") /* Their CTF tool did/does weird things, */ \
                                       && pSrcSeg->vmsize == 0)                   /* overlapping vmaddr and zero vmsize. */ \
                                   || (cSectionsLeft > 0 && (pFirstSect->flags & S_ATTR_DEBUG)); \
@@ -658,16 +613,16 @@
                     KLDRMODMACHO_CHECK_RETURN(   pSrcSeg->filesize == 0 \
                                               || (   pSrcSeg->fileoff <= cbFile \
-                                                  && (KU64)pSrcSeg->fileoff + pSrcSeg->filesize <= cbFile), \
-                                              KLDR_ERR_MACHO_BAD_LOAD_COMMAND); \
+                                                  && (uint64_t)pSrcSeg->fileoff + pSrcSeg->filesize <= cbFile), \
+                                              VERR_LDRMACHO_BAD_LOAD_COMMAND); \
                     KLDRMODMACHO_CHECK_RETURN(   pSrcSeg->filesize <= pSrcSeg->vmsize \
-                                              || (fSkipSeg && !kHlpStrComp(pSrcSeg->segname, "__CTF") /* see above */), \
-                                              KLDR_ERR_MACHO_BAD_LOAD_COMMAND); \
+                                              || (fSkipSeg && !strcmp(pSrcSeg->segname, "__CTF") /* see above */), \
+                                              VERR_LDRMACHO_BAD_LOAD_COMMAND); \
                     KLDRMODMACHO_CHECK_RETURN(!(~pSrcSeg->maxprot & pSrcSeg->initprot), \
-                                              KLDR_ERR_MACHO_BAD_LOAD_COMMAND); \
+                                              VERR_LDRMACHO_BAD_LOAD_COMMAND); \
                     KLDRMODMACHO_CHECK_RETURN(!(pSrcSeg->flags & ~(SG_HIGHVM | SG_FVMLIB | SG_NORELOC | SG_PROTECTED_VERSION_1)), \
-                                              KLDR_ERR_MACHO_BAD_LOAD_COMMAND); \
+                                              VERR_LDRMACHO_BAD_LOAD_COMMAND); \
                     KLDRMODMACHO_CHECK_RETURN(   pSrcSeg->nsects * sizeof(section_##a_cBits##_t) \
                                               <= u.pLoadCmd->cmdsize - sizeof(segment_command_##a_cBits##_t), \
-                                              KLDR_ERR_MACHO_BAD_LOAD_COMMAND); \
+                                              VERR_LDRMACHO_BAD_LOAD_COMMAND); \
                     KLDRMODMACHO_CHECK_RETURN(   uEffFileType != MH_OBJECT \
                                               || cSegmentCommands == 0 \
@@ -676,5 +631,5 @@
                                                   && pHdr->filetype == MH_DSYM \
                                                   && fSkipSeg), \
-                                              KLDR_ERR_MACHO_BAD_OBJECT_FILE); \
+                                              VERR_LDRMACHO_BAD_OBJECT_FILE); \
                     cSegmentCommands++; \
                     \
@@ -682,5 +637,5 @@
                     if (!fSkipSeg && uEffFileType != MH_OBJECT) \
                     { \
-                        cbStringPool += kHlpStrNLen(&pSrcSeg->segname[0], sizeof(pSrcSeg->segname)) + 1; \
+                        cbStringPool += RTStrNLen(&pSrcSeg->segname[0], sizeof(pSrcSeg->segname)) + 1; \
                         cSegments++; \
                         if (cSegments == 1) /* The link address is set by the first segment. */  \
@@ -700,13 +655,13 @@
                     if (fConvertEndian)
                     {
-                        pSect->addr      = K_E2E_U32(pSect->addr);
-                        pSect->size      = K_E2E_U32(pSect->size);
-                        pSect->offset    = K_E2E_U32(pSect->offset);
-                        pSect->align     = K_E2E_U32(pSect->align);
-                        pSect->reloff    = K_E2E_U32(pSect->reloff);
-                        pSect->nreloc    = K_E2E_U32(pSect->nreloc);
-                        pSect->flags     = K_E2E_U32(pSect->flags);
-                        pSect->reserved1 = K_E2E_U32(pSect->reserved1);
-                        pSect->reserved2 = K_E2E_U32(pSect->reserved2);
+                        pSect->addr      = RT_BSWAP_U32(pSect->addr);
+                        pSect->size      = RT_BSWAP_U32(pSect->size);
+                        pSect->offset    = RT_BSWAP_U32(pSect->offset);
+                        pSect->align     = RT_BSWAP_U32(pSect->align);
+                        pSect->reloff    = RT_BSWAP_U32(pSect->reloff);
+                        pSect->nreloc    = RT_BSWAP_U32(pSect->nreloc);
+                        pSect->flags     = RT_BSWAP_U32(pSect->flags);
+                        pSect->reserved1 = RT_BSWAP_U32(pSect->reserved1);
+                        pSect->reserved2 = RT_BSWAP_U32(pSect->reserved2);
                     }
 
@@ -718,12 +673,12 @@
                         /* validate */ \
                         if (uEffFileType != MH_OBJECT) \
-                            KLDRMODMACHO_CHECK_RETURN(!kHlpStrComp(pSect->segname, pSrcSeg->segname),\
-                                                      KLDR_ERR_MACHO_BAD_SECTION); \
+                            KLDRMODMACHO_CHECK_RETURN(!strcmp(pSect->segname, pSrcSeg->segname),\
+                                                      VERR_LDRMACHO_BAD_SECTION); \
                         \
                         switch (pSect->flags & SECTION_TYPE) \
                         { \
                             case S_ZEROFILL: \
-                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved1, KLDR_ERR_MACHO_BAD_SECTION); \
-                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved2, KLDR_ERR_MACHO_BAD_SECTION); \
+                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved1, VERR_LDRMACHO_BAD_SECTION); \
+                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved2, VERR_LDRMACHO_BAD_SECTION); \
                                 fFileBits = 0; \
                                 break; \
@@ -734,13 +689,13 @@
                             case S_8BYTE_LITERALS: \
                             case S_16BYTE_LITERALS: \
-                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved1, KLDR_ERR_MACHO_BAD_SECTION); \
-                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved2, KLDR_ERR_MACHO_BAD_SECTION); \
+                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved1, VERR_LDRMACHO_BAD_SECTION); \
+                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved2, VERR_LDRMACHO_BAD_SECTION); \
                                 fFileBits = 1; \
                                 break; \
                             \
                             case S_SYMBOL_STUBS: \
-                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved1, KLDR_ERR_MACHO_BAD_SECTION); \
+                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved1, VERR_LDRMACHO_BAD_SECTION); \
                                 /* reserved2 == stub size. 0 has been seen (corecrypto.kext) */ \
-                                KLDRMODMACHO_CHECK_RETURN(pSect->reserved2 < 64, KLDR_ERR_MACHO_BAD_SECTION); \
+                                KLDRMODMACHO_CHECK_RETURN(pSect->reserved2 < 64, VERR_LDRMACHO_BAD_SECTION); \
                                 fFileBits = 1; \
                                 break; \
@@ -750,6 +705,6 @@
                             case S_LAZY_DYLIB_SYMBOL_POINTERS: \
                                 /* (reserved 1 = is indirect symbol table index) */ \
-                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved2, KLDR_ERR_MACHO_BAD_SECTION); \
-                                *pfCanLoad = K_FALSE; \
+                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved2, VERR_LDRMACHO_BAD_SECTION); \
+                                *pfCanLoad = false; \
                                 fFileBits = -1; /* __DATA.__got in the 64-bit mach_kernel has bits, any things without bits? */ \
                                 break; \
@@ -757,13 +712,13 @@
                             case S_MOD_INIT_FUNC_POINTERS: \
                                 /** @todo this requires a query API or flag... (e.g. C++ constructors) */ \
-                                KLDRMODMACHO_CHECK_RETURN(fOpenFlags & KLDRMOD_OPEN_FLAGS_FOR_INFO, \
-                                                          KLDR_ERR_MACHO_UNSUPPORTED_INIT_SECTION); \
+                                KLDRMODMACHO_CHECK_RETURN(fOpenFlags & RTLDR_O_FOR_DEBUG, \
+                                                          VERR_LDRMACHO_UNSUPPORTED_INIT_SECTION); \
                                 /* Falls through. */ \
                             case S_MOD_TERM_FUNC_POINTERS: \
                                 /** @todo this requires a query API or flag... (e.g. C++ destructors) */ \
-                                KLDRMODMACHO_CHECK_RETURN(fOpenFlags & KLDRMOD_OPEN_FLAGS_FOR_INFO, \
-                                                          KLDR_ERR_MACHO_UNSUPPORTED_TERM_SECTION); \
-                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved1, KLDR_ERR_MACHO_BAD_SECTION); \
-                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved2, KLDR_ERR_MACHO_BAD_SECTION); \
+                                KLDRMODMACHO_CHECK_RETURN(fOpenFlags & RTLDR_O_FOR_DEBUG, \
+                                                          VERR_LDRMACHO_UNSUPPORTED_TERM_SECTION); \
+                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved1, VERR_LDRMACHO_BAD_SECTION); \
+                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved2, VERR_LDRMACHO_BAD_SECTION); \
                                 fFileBits = 1; \
                                 break; /* ignored */ \
@@ -771,6 +726,6 @@
                             case S_LITERAL_POINTERS: \
                             case S_DTRACE_DOF: \
-                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved1, KLDR_ERR_MACHO_BAD_SECTION); \
-                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved2, KLDR_ERR_MACHO_BAD_SECTION); \
+                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved1, VERR_LDRMACHO_BAD_SECTION); \
+                                KLDRMODMACHO_CHECK_RETURN(!pSect->reserved2, VERR_LDRMACHO_BAD_SECTION); \
                                 fFileBits = 1; \
                                 break; \
@@ -778,8 +733,8 @@
                             case S_INTERPOSING: \
                             case S_GB_ZEROFILL: \
-                                KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_UNSUPPORTED_SECTION); \
+                                KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_UNSUPPORTED_SECTION); \
                             \
                             default: \
-                                KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_UNKNOWN_SECTION); \
+                                KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_UNKNOWN_SECTION); \
                         } \
                         KLDRMODMACHO_CHECK_RETURN(!(pSect->flags & ~(  S_ATTR_PURE_INSTRUCTIONS | S_ATTR_NO_TOC | S_ATTR_STRIP_STATIC_SYMS \
@@ -787,31 +742,31 @@
                                                                      | S_ATTR_DEBUG | S_ATTR_SOME_INSTRUCTIONS | S_ATTR_EXT_RELOC \
                                                                      | S_ATTR_LOC_RELOC | SECTION_TYPE)), \
-                                                  KLDR_ERR_MACHO_BAD_SECTION); \
+                                                  VERR_LDRMACHO_BAD_SECTION); \
                         KLDRMODMACHO_CHECK_RETURN((pSect->flags & S_ATTR_DEBUG) == (pFirstSect->flags & S_ATTR_DEBUG), \
-                                                  KLDR_ERR_MACHO_MIXED_DEBUG_SECTION_FLAGS); \
+                                                  VERR_LDRMACHO_MIXED_DEBUG_SECTION_FLAGS); \
                         \
                         KLDRMODMACHO_CHECK_RETURN(pSect->addr - pSrcSeg->vmaddr <= pSrcSeg->vmsize, \
-                                                  KLDR_ERR_MACHO_BAD_SECTION); \
+                                                  VERR_LDRMACHO_BAD_SECTION); \
                         KLDRMODMACHO_CHECK_RETURN(   pSect->addr - pSrcSeg->vmaddr + pSect->size <= pSrcSeg->vmsize \
-                                                  || !kHlpStrComp(pSrcSeg->segname, "__CTF") /* see above */, \
-                                                  KLDR_ERR_MACHO_BAD_SECTION); \
+                                                  || !strcmp(pSrcSeg->segname, "__CTF") /* see above */, \
+                                                  VERR_LDRMACHO_BAD_SECTION); \
                         KLDRMODMACHO_CHECK_RETURN(pSect->align < 31, \
-                                                  KLDR_ERR_MACHO_BAD_SECTION); \
+                                                  VERR_LDRMACHO_BAD_SECTION); \
                         /* Workaround for buggy ld64 (or as, llvm, ++) that produces a misaligned __TEXT.__unwind_info. */ \
                         /* Seen: pSect->align = 4, pSect->addr = 0x5ebe14.  Just adjust the alignment down. */ \
-                        if (   ((K_BIT32(pSect->align) - KU32_C(1)) & pSect->addr) \
+                        if (   ((RT_BIT_32(pSect->align) - UINT32_C(1)) & pSect->addr) \
                             && pSect->align == 4 \
-                            && kHlpStrComp(pSect->sectname, "__unwind_info") == 0) \
+                            && strcmp(pSect->sectname, "__unwind_info") == 0) \
                             pSect->align = 2; \
-                        KLDRMODMACHO_CHECK_RETURN(!((K_BIT32(pSect->align) - KU32_C(1)) & pSect->addr), \
-                                                  KLDR_ERR_MACHO_BAD_SECTION); \
-                        KLDRMODMACHO_CHECK_RETURN(!((K_BIT32(pSect->align) - KU32_C(1)) & pSrcSeg->vmaddr), \
-                                                  KLDR_ERR_MACHO_BAD_SECTION); \
+                        KLDRMODMACHO_CHECK_RETURN(!((RT_BIT_32(pSect->align) - UINT32_C(1)) & pSect->addr), \
+                                                  VERR_LDRMACHO_BAD_SECTION); \
+                        KLDRMODMACHO_CHECK_RETURN(!((RT_BIT_32(pSect->align) - UINT32_C(1)) & pSrcSeg->vmaddr), \
+                                                  VERR_LDRMACHO_BAD_SECTION); \
                         \
                         /* Adjust the section offset before we check file offset. */ \
-                        offSect = (offSect + K_BIT64(pSect->align) - KU64_C(1)) & ~(K_BIT64(pSect->align) - KU64_C(1)); \
+                        offSect = (offSect + RT_BIT_64(pSect->align) - UINT64_C(1)) & ~(RT_BIT_64(pSect->align) - UINT64_C(1)); \
                         if (pSect->addr) \
                         { \
-                            KLDRMODMACHO_CHECK_RETURN(offSect <= pSect->addr - pSrcSeg->vmaddr, KLDR_ERR_MACHO_BAD_SECTION); \
+                            KLDRMODMACHO_CHECK_RETURN(offSect <= pSect->addr - pSrcSeg->vmaddr, VERR_LDRMACHO_BAD_SECTION); \
                             if (offSect < pSect->addr - pSrcSeg->vmaddr) \
                                 offSect = pSect->addr - pSrcSeg->vmaddr; \
@@ -825,27 +780,27 @@
                             { \
                                 KLDRMODMACHO_CHECK_RETURN(pSect->offset == pSrcSeg->fileoff + offSect, \
-                                                          KLDR_ERR_MACHO_NON_CONT_SEG_BITS); \
+                                                          VERR_LDRMACHO_NON_CONT_SEG_BITS); \
                                 KLDRMODMACHO_CHECK_RETURN(pSect->offset - pSrcSeg->fileoff <= pSrcSeg->filesize, \
-                                                          KLDR_ERR_MACHO_BAD_SECTION); \
+                                                          VERR_LDRMACHO_BAD_SECTION); \
                             } \
                             KLDRMODMACHO_CHECK_RETURN(pSect->offset <= cbFile, \
-                                                      KLDR_ERR_MACHO_BAD_SECTION); \
-                            KLDRMODMACHO_CHECK_RETURN((KU64)pSect->offset + pSect->size <= cbFile, \
-                                                      KLDR_ERR_MACHO_BAD_SECTION); \
+                                                      VERR_LDRMACHO_BAD_SECTION); \
+                            KLDRMODMACHO_CHECK_RETURN((uint64_t)pSect->offset + pSect->size <= cbFile, \
+                                                      VERR_LDRMACHO_BAD_SECTION); \
                         } \
                         else \
-                            KLDRMODMACHO_CHECK_RETURN(pSect->offset == 0, KLDR_ERR_MACHO_BAD_SECTION); \
+                            KLDRMODMACHO_CHECK_RETURN(pSect->offset == 0, VERR_LDRMACHO_BAD_SECTION); \
                         \
                         if (!pSect->nreloc) \
                             KLDRMODMACHO_CHECK_RETURN(!pSect->reloff, \
-                                                      KLDR_ERR_MACHO_BAD_SECTION); \
+                                                      VERR_LDRMACHO_BAD_SECTION); \
                         else \
                         { \
                             KLDRMODMACHO_CHECK_RETURN(pSect->reloff <= cbFile, \
-                                                      KLDR_ERR_MACHO_BAD_SECTION); \
-                            KLDRMODMACHO_CHECK_RETURN(     (KU64)pSect->reloff \
-                                                         + (KLDRFOFF)pSect->nreloc * sizeof(macho_relocation_info_t) \
+                                                      VERR_LDRMACHO_BAD_SECTION); \
+                            KLDRMODMACHO_CHECK_RETURN(     (uint64_t)pSect->reloff \
+                                                         + (RTFOFF)pSect->nreloc * sizeof(macho_relocation_info_t) \
                                                       <= cbFile, \
-                                                      KLDR_ERR_MACHO_BAD_SECTION); \
+                                                      VERR_LDRMACHO_BAD_SECTION); \
                         } \
                         \
@@ -855,8 +810,8 @@
                             case MH_OBJECT: \
                                 if (   !(pSect->flags & S_ATTR_DEBUG) \
-                                    && kHlpStrComp(pSect->segname, "__DWARF")) \
+                                    && strcmp(pSect->segname, "__DWARF")) \
                                 { \
-                                    cbStringPool += kHlpStrNLen(&pSect->segname[0], sizeof(pSect->segname)) + 1; \
-                                    cbStringPool += kHlpStrNLen(&pSect->sectname[0], sizeof(pSect->sectname)) + 1; \
+                                    cbStringPool += RTStrNLen(&pSect->segname[0], sizeof(pSect->segname)) + 1; \
+                                    cbStringPool += RTStrNLen(&pSect->sectname[0], sizeof(pSect->sectname)) + 1; \
                                     cSegments++; \
                                     if (cSegments == 1) /* The link address is set by the first segment. */  \
@@ -872,5 +827,5 @@
                                 break; \
                             default: \
-                                KLDRMODMACHO_FAILED_RETURN(KERR_INVALID_PARAMETER); \
+                                KLDRMODMACHO_FAILED_RETURN(VERR_INVALID_PARAMETER); \
                         } \
                         \
@@ -892,21 +847,21 @@
                 section_64_t   *pFirstSect    = (section_64_t *)(pSrcSeg + 1);
                 section_64_t   *pSect         = pFirstSect;
-                KU32            cSectionsLeft = pSrcSeg->nsects;
-                KU64            offSect       = 0;
+                uint32_t        cSectionsLeft = pSrcSeg->nsects;
+                uint64_t            offSect       = 0;
 
                 /* Convert and verify the segment. */
-                KLDRMODMACHO_CHECK_RETURN(u.pLoadCmd->cmdsize >= sizeof(segment_command_64_t), KLDR_ERR_MACHO_BAD_LOAD_COMMAND);
+                KLDRMODMACHO_CHECK_RETURN(u.pLoadCmd->cmdsize >= sizeof(segment_command_64_t), VERR_LDRMACHO_BAD_LOAD_COMMAND);
                 KLDRMODMACHO_CHECK_RETURN(   pHdr->magic == IMAGE_MACHO64_SIGNATURE_OE
-                                          || pHdr->magic == IMAGE_MACHO64_SIGNATURE, KLDR_ERR_MACHO_BIT_MIX);
+                                          || pHdr->magic == IMAGE_MACHO64_SIGNATURE, VERR_LDRMACHO_BIT_MIX);
                 if (fConvertEndian)
                 {
-                    pSrcSeg->vmaddr   = K_E2E_U64(pSrcSeg->vmaddr);
-                    pSrcSeg->vmsize   = K_E2E_U64(pSrcSeg->vmsize);
-                    pSrcSeg->fileoff  = K_E2E_U64(pSrcSeg->fileoff);
-                    pSrcSeg->filesize = K_E2E_U64(pSrcSeg->filesize);
-                    pSrcSeg->maxprot  = K_E2E_U32(pSrcSeg->maxprot);
-                    pSrcSeg->initprot = K_E2E_U32(pSrcSeg->initprot);
-                    pSrcSeg->nsects   = K_E2E_U32(pSrcSeg->nsects);
-                    pSrcSeg->flags    = K_E2E_U32(pSrcSeg->flags);
+                    pSrcSeg->vmaddr   = RT_BSWAP_U64(pSrcSeg->vmaddr);
+                    pSrcSeg->vmsize   = RT_BSWAP_U64(pSrcSeg->vmsize);
+                    pSrcSeg->fileoff  = RT_BSWAP_U64(pSrcSeg->fileoff);
+                    pSrcSeg->filesize = RT_BSWAP_U64(pSrcSeg->filesize);
+                    pSrcSeg->maxprot  = RT_BSWAP_U32(pSrcSeg->maxprot);
+                    pSrcSeg->initprot = RT_BSWAP_U32(pSrcSeg->initprot);
+                    pSrcSeg->nsects   = RT_BSWAP_U32(pSrcSeg->nsects);
+                    pSrcSeg->flags    = RT_BSWAP_U32(pSrcSeg->flags);
                 }
 
@@ -920,13 +875,13 @@
                     if (fConvertEndian)
                     {
-                        pSect->addr      = K_E2E_U64(pSect->addr);
-                        pSect->size      = K_E2E_U64(pSect->size);
-                        pSect->offset    = K_E2E_U32(pSect->offset);
-                        pSect->align     = K_E2E_U32(pSect->align);
-                        pSect->reloff    = K_E2E_U32(pSect->reloff);
-                        pSect->nreloc    = K_E2E_U32(pSect->nreloc);
-                        pSect->flags     = K_E2E_U32(pSect->flags);
-                        pSect->reserved1 = K_E2E_U32(pSect->reserved1);
-                        pSect->reserved2 = K_E2E_U32(pSect->reserved2);
+                        pSect->addr      = RT_BSWAP_U64(pSect->addr);
+                        pSect->size      = RT_BSWAP_U64(pSect->size);
+                        pSect->offset    = RT_BSWAP_U32(pSect->offset);
+                        pSect->align     = RT_BSWAP_U32(pSect->align);
+                        pSect->reloff    = RT_BSWAP_U32(pSect->reloff);
+                        pSect->nreloc    = RT_BSWAP_U32(pSect->nreloc);
+                        pSect->flags     = RT_BSWAP_U32(pSect->flags);
+                        pSect->reserved1 = RT_BSWAP_U32(pSect->reserved1);
+                        pSect->reserved2 = RT_BSWAP_U32(pSect->reserved2);
                     }
 
@@ -942,11 +897,11 @@
             case LC_SYMTAB:
             {
-                KSIZE cbSym;
+                size_t cbSym;
                 if (fConvertEndian)
                 {
-                    u.pSymTab->symoff  = K_E2E_U32(u.pSymTab->symoff);
-                    u.pSymTab->nsyms   = K_E2E_U32(u.pSymTab->nsyms);
-                    u.pSymTab->stroff  = K_E2E_U32(u.pSymTab->stroff);
-                    u.pSymTab->strsize = K_E2E_U32(u.pSymTab->strsize);
+                    u.pSymTab->symoff  = RT_BSWAP_U32(u.pSymTab->symoff);
+                    u.pSymTab->nsyms   = RT_BSWAP_U32(u.pSymTab->nsyms);
+                    u.pSymTab->stroff  = RT_BSWAP_U32(u.pSymTab->stroff);
+                    u.pSymTab->strsize = RT_BSWAP_U32(u.pSymTab->strsize);
                 }
 
@@ -957,9 +912,9 @@
                       : sizeof(macho_nlist_64_t);
                 if (    u.pSymTab->symoff >= cbFile
-                    ||  (KU64)u.pSymTab->symoff + u.pSymTab->nsyms * cbSym > cbFile)
-                    KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_LOAD_COMMAND);
+                    ||  (uint64_t)u.pSymTab->symoff + u.pSymTab->nsyms * cbSym > cbFile)
+                    KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_LOAD_COMMAND);
                 if (    u.pSymTab->stroff >= cbFile
-                    ||  (KU64)u.pSymTab->stroff + u.pSymTab->strsize > cbFile)
-                    KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_LOAD_COMMAND);
+                    ||  (uint64_t)u.pSymTab->stroff + u.pSymTab->strsize > cbFile)
+                    KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_LOAD_COMMAND);
 
                 /* only one string in objects, please. */
@@ -967,5 +922,5 @@
                 if (    uEffFileType == MH_OBJECT
                     &&  cSymbolTabs != 1)
-                    KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_OBJECT_FILE);
+                    KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_OBJECT_FILE);
                 break;
             }
@@ -978,18 +933,18 @@
             case LC_UNIXTHREAD:
             {
-                KU32 *pu32 = (KU32 *)(u.pb + sizeof(load_command_t));
-                KU32 cItemsLeft = (u.pThread->cmdsize - sizeof(load_command_t)) / sizeof(KU32);
+                uint32_t *pu32 = (uint32_t *)(u.pb + sizeof(load_command_t));
+                uint32_t cItemsLeft = (u.pThread->cmdsize - sizeof(load_command_t)) / sizeof(uint32_t);
                 while (cItemsLeft)
                 {
-                    /* convert & verify header items ([0] == flavor, [1] == KU32 count). */
+                    /* convert & verify header items ([0] == flavor, [1] == uint32_t count). */
                     if (cItemsLeft < 2)
-                        KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_LOAD_COMMAND);
+                        KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_LOAD_COMMAND);
                     if (fConvertEndian)
                     {
-                        pu32[0] = K_E2E_U32(pu32[0]);
-                        pu32[1] = K_E2E_U32(pu32[1]);
+                        pu32[0] = RT_BSWAP_U32(pu32[0]);
+                        pu32[1] = RT_BSWAP_U32(pu32[1]);
                     }
                     if (pu32[1] + 2 > cItemsLeft)
-                        KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_LOAD_COMMAND);
+                        KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_LOAD_COMMAND);
 
                     /* convert & verify according to flavor. */
@@ -1010,5 +965,5 @@
             case LC_UUID:
                 if (u.pUuid->cmdsize != sizeof(uuid_command_t))
-                    KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_LOAD_COMMAND);
+                    KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_LOAD_COMMAND);
                 /** @todo Check anything here need converting? */
                 break;
@@ -1016,5 +971,5 @@
             case LC_CODE_SIGNATURE:
                 if (u.pUuid->cmdsize != sizeof(linkedit_data_command_t))
-                    KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_LOAD_COMMAND);
+                    KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_LOAD_COMMAND);
                 break;
 
@@ -1022,5 +977,5 @@
             case LC_VERSION_MIN_IPHONEOS:
                 if (u.pUuid->cmdsize != sizeof(version_min_command_t))
-                    KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_LOAD_COMMAND);
+                    KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_LOAD_COMMAND);
                 break;
 
@@ -1049,7 +1004,7 @@
             case LC_MAIN: /** @todo parse this and find and entry point or smth. */
                 /** @todo valid command size. */
-                if (!(fOpenFlags & KLDRMOD_OPEN_FLAGS_FOR_INFO))
-                    KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_UNSUPPORTED_LOAD_COMMAND);
-                *pfCanLoad = K_FALSE;
+                if (!(fOpenFlags & RTLDR_O_FOR_DEBUG))
+                    KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_UNSUPPORTED_LOAD_COMMAND);
+                *pfCanLoad = false;
                 break;
 
@@ -1068,8 +1023,8 @@
             case LC_PREBIND_CKSUM:
             case LC_SYMSEG:
-                KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_UNSUPPORTED_LOAD_COMMAND);
+                KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_UNSUPPORTED_LOAD_COMMAND);
 
             default:
-                KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_UNKNOWN_LOAD_COMMAND);
+                KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_UNKNOWN_LOAD_COMMAND);
         }
     }
@@ -1077,5 +1032,5 @@
     /* be strict. */
     if (cbLeft)
-        KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_LOAD_COMMAND);
+        KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_LOAD_COMMAND);
 
     switch (uEffFileType)
@@ -1088,5 +1043,5 @@
         case MH_KEXT_BUNDLE:
             if (!cSegments)
-                KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_OBJECT_FILE);
+                KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_OBJECT_FILE);
             break;
     }
@@ -1094,5 +1049,5 @@
     *pcSegments = cSegments;
     *pcSections = cSections;
-    *pcbStringPool = (KU32)cbStringPool;
+    *pcbStringPool = (uint32_t)cbStringPool;
 
     return 0;
@@ -1106,14 +1061,14 @@
  *
  * @returns 0 on success.
- * @returns KLDR_ERR_MACHO_* on failure.
- * @param   pModMachO       The module.
+ * @returns VERR_LDRMACHO_* on failure.
+ * @param   pThis       The module.
  * @param   pbStringPool    The string pool
  * @param   cbStringPool    The size of the string pool.
  */
-static int  kldrModMachOParseLoadCommands(PKLDRMODMACHO pModMachO, char *pbStringPool, KU32 cbStringPool)
+static int  kldrModMachOParseLoadCommands(PKLDRMODMACHO pThis, char *pbStringPool, uint32_t cbStringPool)
 {
     union
     {
-        const KU8                  *pb;
+        const uint8_t              *pb;
         const load_command_t       *pLoadCmd;
         const segment_command_32_t *pSeg32;
@@ -1122,13 +1077,12 @@
         const uuid_command_t       *pUuid;
     } u;
-    KU32 cLeft = pModMachO->Hdr.ncmds;
-    KU32 cbLeft = pModMachO->Hdr.sizeofcmds;
-    const KU8 *pb = pModMachO->pbLoadCommands;
-    PKLDRSEG pDstSeg = &pModMachO->pMod->aSegments[0];
-    PKLDRMODMACHOSEG pSegExtra = &pModMachO->aSegments[0];
-    PKLDRMODMACHOSECT pSectExtra = pModMachO->paSections;
-    const KU32 cSegments = pModMachO->pMod->cSegments;
-    PKLDRSEG pSegItr;
-    K_NOREF(cbStringPool);
+    uint32_t cLeft = pThis->Hdr.ncmds;
+    uint32_t cbLeft = pThis->Hdr.sizeofcmds;
+    const uint8_t *pb = pThis->pbLoadCommands;
+    PKLDRMODMACHOSEG pDstSeg = &pThis->aSegments[0];
+    PKLDRMODMACHOSECT pSectExtra = pThis->paSections;
+    const uint32_t cSegments = pThis->cSegments;
+    PKLDRMODMACHOSEG pSegItr;
+    RT_NOREF(cbStringPool);
 
     while (cLeft-- > 0)
@@ -1148,47 +1102,45 @@
                 section_32_t   *pFirstSect    = (section_32_t *)(pSrcSeg + 1);
                 section_32_t   *pSect         = pFirstSect;
-                KU32            cSectionsLeft = pSrcSeg->nsects;
+                uint32_t        cSectionsLeft = pSrcSeg->nsects;
 
                 /* Adds a segment, used by the macro below and thus shared with the 64-bit segment variant. */
                 #define NEW_SEGMENT(a_cBits, a_achName1, a_fObjFile, a_achName2, a_SegAddr, a_cbSeg, a_fFileBits, a_offFile, a_cbFile) \
                 do { \
-                    pDstSeg->pvUser = NULL; \
-                    pDstSeg->pchName = pbStringPool; \
-                    pDstSeg->cchName = (KU32)kHlpStrNLen(a_achName1, sizeof(a_achName1)); \
-                    kHlpMemCopy(pbStringPool, a_achName1, pDstSeg->cchName); \
-                    pbStringPool += pDstSeg->cchName; \
+                    pDstSeg->SegInfo.pszName = pbStringPool; \
+                    pDstSeg->SegInfo.cchName = (uint32_t)RTStrNLen(a_achName1, sizeof(a_achName1)); \
+                    memcpy(pbStringPool, a_achName1, pDstSeg->SegInfo.cchName); \
+                    pbStringPool += pDstSeg->SegInfo.cchName; \
                     if (a_fObjFile) \
                     {   /* MH_OBJECT: Add '.sectname' - sections aren't sorted by segments. */ \
-                        KSIZE cchName2 = kHlpStrNLen(a_achName2, sizeof(a_achName2)); \
+                        size_t cchName2 = RTStrNLen(a_achName2, sizeof(a_achName2)); \
                         *pbStringPool++ = '.'; \
-                        kHlpMemCopy(pbStringPool, a_achName2, cchName2); \
+                        memcpy(pbStringPool, a_achName2, cchName2); \
                         pbStringPool += cchName2; \
-                        pDstSeg->cchName += (KU32)cchName2; \
+                        pDstSeg->SegInfo.cchName += (uint32_t)cchName2; \
                     } \
                     *pbStringPool++ = '\0'; \
-                    pDstSeg->SelFlat = 0; \
-                    pDstSeg->Sel16bit = 0; \
-                    pDstSeg->fFlags = 0; \
-                    pDstSeg->enmProt = KPROT_EXECUTE_WRITECOPY; /** @todo fixme! */ \
-                    pDstSeg->cb = (a_cbSeg); \
-                    pDstSeg->Alignment = 1; /* updated while parsing sections. */ \
-                    pDstSeg->LinkAddress = (a_SegAddr); \
+                    pDstSeg->SegInfo.SelFlat = 0; \
+                    pDstSeg->SegInfo.Sel16bit = 0; \
+                    pDstSeg->SegInfo.fFlags = 0; \
+                    pDstSeg->SegInfo.fProt = RTMEM_PROT_READ | RTMEM_PROT_WRITE | RTMEM_PROT_EXEC; /** @todo fixme! */ \
+                    pDstSeg->SegInfo.cb = (a_cbSeg); \
+                    pDstSeg->SegInfo.Alignment = 1; /* updated while parsing sections. */ \
+                    pDstSeg->SegInfo.LinkAddress = (a_SegAddr); \
                     if (a_fFileBits) \
                     { \
-                        pDstSeg->offFile = (KLDRFOFF)((a_offFile) + pModMachO->offImage); \
-                        pDstSeg->cbFile  = (KLDRFOFF)(a_cbFile); \
+                        pDstSeg->SegInfo.offFile = (RTFOFF)((a_offFile) + pThis->offImage); \
+                        pDstSeg->SegInfo.cbFile  = (RTFOFF)(a_cbFile); \
                     } \
                     else \
                     { \
-                        pDstSeg->offFile = -1; \
-                        pDstSeg->cbFile  = -1; \
+                        pDstSeg->SegInfo.offFile = -1; \
+                        pDstSeg->SegInfo.cbFile  = -1; \
                     } \
-                    pDstSeg->RVA = (a_SegAddr) - pModMachO->LinkAddress; \
-                    pDstSeg->cbMapped = 0; \
-                    pDstSeg->MapAddress = 0; \
+                    pDstSeg->SegInfo.RVA = (a_SegAddr) - pThis->LinkAddress; \
+                    pDstSeg->SegInfo.cbMapped = 0; \
                     \
-                    pSegExtra->iOrgSegNo = (KU32)(pSegExtra - &pModMachO->aSegments[0]); \
-                    pSegExtra->cSections = 0; \
-                    pSegExtra->paSections = pSectExtra; \
+                    pDstSeg->iOrgSegNo = (uint32_t)(pDstSeg - &pThis->aSegments[0]); \
+                    pDstSeg->cSections = 0; \
+                    pDstSeg->paSections = pSectExtra; \
                 } while (0)
 
@@ -1196,6 +1148,5 @@
                 #define CLOSE_SEGMENT() \
                 do { \
-                    pSegExtra->cSections = (KU32)(pSectExtra - pSegExtra->paSections); \
-                    pSegExtra++; \
+                    pDstSeg->cSections = (uint32_t)(pSectExtra - pDstSeg->paSections); \
                     pDstSeg++; \
                 } while (0)
@@ -1205,5 +1156,5 @@
                 #define ADD_SEGMENT_AND_ITS_SECTIONS(a_cBits) \
                 do { \
-                    KBOOL fAddSegOuter = K_FALSE; \
+                    bool fAddSegOuter = false; \
                     \
                     /* \
@@ -1211,21 +1162,21 @@
                      * in the preparsing stage. \
                      */ \
-                    if (pModMachO->uEffFileType != MH_OBJECT) \
-                        for (pSegItr = &pModMachO->pMod->aSegments[0]; pSegItr != pDstSeg; pSegItr++) \
-                            if (!kHlpStrNComp(pSegItr->pchName, pSrcSeg->segname, sizeof(pSrcSeg->segname))) \
-                                KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_DUPLICATE_SEGMENT_NAME); \
+                    if (pThis->uEffFileType != MH_OBJECT) \
+                        for (pSegItr = &pThis->aSegments[0]; pSegItr != pDstSeg; pSegItr++) \
+                            if (!strncmp(pSegItr->SegInfo.pszName, pSrcSeg->segname, sizeof(pSrcSeg->segname))) \
+                                KLDRMODMACHO_FAILED_RETURN(VERR_LDR_DUPLICATE_SEGMENT_NAME); \
                     \
                     /* \
                      * Create a new segment, unless we're supposed to skip this one. \
                      */ \
-                    if (   pModMachO->uEffFileType != MH_OBJECT \
+                    if (   pThis->uEffFileType != MH_OBJECT \
                         && (cSectionsLeft == 0 || !(pFirstSect->flags & S_ATTR_DEBUG)) \
-                        && kHlpStrComp(pSrcSeg->segname, "__DWARF") \
-                        && kHlpStrComp(pSrcSeg->segname, "__CTF") ) \
+                        && strcmp(pSrcSeg->segname, "__DWARF") \
+                        && strcmp(pSrcSeg->segname, "__CTF") ) \
                     { \
-                        NEW_SEGMENT(a_cBits, pSrcSeg->segname, K_FALSE /*a_fObjFile*/, 0 /*a_achName2*/, \
+                        NEW_SEGMENT(a_cBits, pSrcSeg->segname, false /*a_fObjFile*/, 0 /*a_achName2*/, \
                                     pSrcSeg->vmaddr, pSrcSeg->vmsize, \
                                     pSrcSeg->filesize != 0, pSrcSeg->fileoff, pSrcSeg->filesize); \
-                        fAddSegOuter = K_TRUE; \
+                        fAddSegOuter = true; \
                     } \
                     \
@@ -1236,23 +1187,23 @@
                     { \
                         /* New segment if object file. */ \
-                        KBOOL fAddSegInner = K_FALSE; \
-                        if (   pModMachO->uEffFileType == MH_OBJECT \
+                        bool fAddSegInner = false; \
+                        if (   pThis->uEffFileType == MH_OBJECT \
                             && !(pSect->flags & S_ATTR_DEBUG) \
-                            && kHlpStrComp(pSrcSeg->segname, "__DWARF") \
-                            && kHlpStrComp(pSrcSeg->segname, "__CTF") ) \
+                            && strcmp(pSrcSeg->segname, "__DWARF") \
+                            && strcmp(pSrcSeg->segname, "__CTF") ) \
                         { \
-                            kHlpAssert(!fAddSegOuter); \
-                            NEW_SEGMENT(a_cBits, pSect->segname, K_TRUE /*a_fObjFile*/, pSect->sectname, \
+                            Assert(!fAddSegOuter); \
+                            NEW_SEGMENT(a_cBits, pSect->segname, true /*a_fObjFile*/, pSect->sectname, \
                                         pSect->addr, pSect->size, \
                                         pSect->offset != 0, pSect->offset, pSect->size); \
-                            fAddSegInner = K_TRUE; \
+                            fAddSegInner = true; \
                         } \
                         \
                         /* Section data extract. */ \
                         pSectExtra->cb = pSect->size; \
-                        pSectExtra->RVA = pSect->addr - pDstSeg->LinkAddress; \
+                        pSectExtra->RVA = pSect->addr - pDstSeg->SegInfo.LinkAddress; \
                         pSectExtra->LinkAddress = pSect->addr; \
                         if (pSect->offset) \
-                            pSectExtra->offFile = pSect->offset + pModMachO->offImage; \
+                            pSectExtra->offFile = pSect->offset + pThis->offImage; \
                         else \
                             pSectExtra->offFile = -1; \
@@ -1260,15 +1211,15 @@
                         pSectExtra->paFixups = NULL; \
                         if (pSect->nreloc) \
-                            pSectExtra->offFixups = pSect->reloff + pModMachO->offImage; \
+                            pSectExtra->offFixups = pSect->reloff + pThis->offImage; \
                         else \
                             pSectExtra->offFixups = -1; \
                         pSectExtra->fFlags = pSect->flags; \
-                        pSectExtra->iSegment = (KU32)(pSegExtra - &pModMachO->aSegments[0]); \
+                        pSectExtra->iSegment = (uint32_t)(pDstSeg - &pThis->aSegments[0]); \
                         pSectExtra->pvMachoSection = pSect; \
                         \
                         /* Update the segment alignment, if we're not skipping it. */ \
                         if (   (fAddSegOuter || fAddSegInner) \
-                            && pDstSeg->Alignment < ((KLDRADDR)1 << pSect->align)) \
-                            pDstSeg->Alignment = (KLDRADDR)1 << pSect->align; \
+                            && pDstSeg->SegInfo.Alignment < ((RTLDRADDR)1 << pSect->align)) \
+                            pDstSeg->SegInfo.Alignment = (RTLDRADDR)1 << pSect->align; \
                         \
                         /* Next section, and if object file next segment. */ \
@@ -1293,5 +1244,5 @@
                 section_64_t   *pFirstSect    = (section_64_t *)(pSrcSeg + 1);
                 section_64_t   *pSect         = pFirstSect;
-                KU32            cSectionsLeft = pSrcSeg->nsects;
+                uint32_t        cSectionsLeft = pSrcSeg->nsects;
 
                 ADD_SEGMENT_AND_ITS_SECTIONS(64);
@@ -1300,5 +1251,5 @@
 
             case LC_SYMTAB:
-                switch (pModMachO->uEffFileType)
+                switch (pThis->uEffFileType)
                 {
                     case MH_OBJECT:
@@ -1308,8 +1259,8 @@
                     case MH_DSYM:
                     case MH_KEXT_BUNDLE:
-                        pModMachO->offSymbols = u.pSymTab->symoff + pModMachO->offImage;
-                        pModMachO->cSymbols = u.pSymTab->nsyms;
-                        pModMachO->offStrings = u.pSymTab->stroff + pModMachO->offImage;
-                        pModMachO->cchStrings = u.pSymTab->strsize;
+                        pThis->offSymbols = u.pSymTab->symoff + pThis->offImage;
+                        pThis->cSymbols = u.pSymTab->nsyms;
+                        pThis->offStrings = u.pSymTab->stroff + pThis->offImage;
+                        pThis->cchStrings = u.pSymTab->strsize;
                         break;
                 }
@@ -1317,5 +1268,5 @@
 
             case LC_UUID:
-                kHlpMemCopy(pModMachO->abImageUuid, u.pUuid->uuid, sizeof(pModMachO->abImageUuid));
+                memcpy(pThis->abImageUuid, u.pUuid->uuid, sizeof(pThis->abImageUuid));
                 break;
 
@@ -1325,5 +1276,5 @@
     } /* while more commands */
 
-    kHlpAssert(pDstSeg == &pModMachO->pMod->aSegments[cSegments - pModMachO->fMakeGot]);
+    Assert(pDstSeg == &pThis->aSegments[cSegments - pThis->fMakeGot]);
 
     /*
@@ -1331,10 +1282,10 @@
      */
     {
-        KBOOL               fLoadLinkEdit = K_FALSE;
+        bool                fLoadLinkEdit = false;
         PKLDRMODMACHOSECT   pSectExtraItr;
-        KLDRADDR            uNextRVA = 0;
-        KLDRADDR            cb;
-        KU32                cSegmentsToAdjust = cSegments - pModMachO->fMakeGot;
-        KU32                c;
+        RTLDRADDR           uNextRVA = 0;
+        RTLDRADDR           cb;
+        uint32_t            cSegmentsToAdjust = cSegments - pThis->fMakeGot;
+        uint32_t            c;
 
         for (;;)
@@ -1343,9 +1294,9 @@
                out of the RVA negotiations and image loading. */
             if (   cSegmentsToAdjust > 0
-                && !kHlpStrComp(pModMachO->pMod->aSegments[cSegmentsToAdjust - 1].pchName, "__DWARF"))
+                && !strcmp(pThis->aSegments[cSegmentsToAdjust - 1].SegInfo.pszName, "__DWARF"))
             {
                 cSegmentsToAdjust--;
-                pModMachO->pMod->aSegments[cSegmentsToAdjust].RVA = NIL_KLDRADDR;
-                pModMachO->pMod->aSegments[cSegmentsToAdjust].cbMapped = 0;
+                pThis->aSegments[cSegmentsToAdjust].SegInfo.RVA = NIL_RTLDRADDR;
+                pThis->aSegments[cSegmentsToAdjust].SegInfo.cbMapped = 0;
                 continue;
             }
@@ -1356,9 +1307,9 @@
             if (   !fLoadLinkEdit
                 && cSegmentsToAdjust > 0
-                && !kHlpStrComp(pModMachO->pMod->aSegments[cSegmentsToAdjust - 1].pchName, "__LINKEDIT"))
+                && !strcmp(pThis->aSegments[cSegmentsToAdjust - 1].SegInfo.pszName, "__LINKEDIT"))
             {
                 cSegmentsToAdjust--;
-                pModMachO->pMod->aSegments[cSegmentsToAdjust].RVA = NIL_KLDRADDR;
-                pModMachO->pMod->aSegments[cSegmentsToAdjust].cbMapped = 0;
+                pThis->aSegments[cSegmentsToAdjust].SegInfo.RVA = NIL_RTLDRADDR;
+                pThis->aSegments[cSegmentsToAdjust].SegInfo.cbMapped = 0;
                 continue;
             }
@@ -1368,42 +1319,42 @@
         /* Adjust RVAs. */
         c = cSegmentsToAdjust;
-        for (pDstSeg = &pModMachO->pMod->aSegments[0]; c-- > 0; pDstSeg++)
-        {
-            cb = pDstSeg->RVA - uNextRVA;
+        for (pDstSeg = &pThis->aSegments[0]; c-- > 0; pDstSeg++)
+        {
+            cb = pDstSeg->SegInfo.RVA - uNextRVA;
             if (cb >= 0x00100000) /* 1MB */
             {
-                pDstSeg->RVA = uNextRVA;
-                pModMachO->pMod->fFlags |= KLDRMOD_FLAGS_NON_CONTIGUOUS_LINK_ADDRS;
+                pDstSeg->SegInfo.RVA = uNextRVA;
+                //pThis->pMod->fFlags |= KLDRMOD_FLAGS_NON_CONTIGUOUS_LINK_ADDRS;
             }
-            uNextRVA = pDstSeg->RVA + KLDR_ALIGN_ADDR(pDstSeg->cb, pDstSeg->Alignment);
+            uNextRVA = pDstSeg->SegInfo.RVA + RTLDR_ALIGN_ADDR(pDstSeg->SegInfo.cb, pDstSeg->SegInfo.Alignment);
         }
 
         /* Calculate the cbMapping members. */
         c = cSegmentsToAdjust;
-        for (pDstSeg = &pModMachO->pMod->aSegments[0]; c-- > 1; pDstSeg++)
-        {
-
-            cb = pDstSeg[1].RVA - pDstSeg->RVA;
-            pDstSeg->cbMapped = (KSIZE)cb == cb ? (KSIZE)cb : KSIZE_MAX;
-        }
-
-        cb = KLDR_ALIGN_ADDR(pDstSeg->cb, pDstSeg->Alignment);
-        pDstSeg->cbMapped = (KSIZE)cb == cb ? (KSIZE)cb : KSIZE_MAX;
+        for (pDstSeg = &pThis->aSegments[0]; c-- > 1; pDstSeg++)
+        {
+
+            cb = pDstSeg[1].SegInfo.RVA - pDstSeg->SegInfo.RVA;
+            pDstSeg->SegInfo.cbMapped = (size_t)cb == cb ? (size_t)cb : ~(size_t)0;
+        }
+
+        cb = RTLDR_ALIGN_ADDR(pDstSeg->SegInfo.cb, pDstSeg->SegInfo.Alignment);
+        pDstSeg->SegInfo.cbMapped = (size_t)cb == cb ? (size_t)cb : ~(size_t)0;
 
         /* Set the image size. */
-        pModMachO->cbImage = pDstSeg->RVA + cb;
+        pThis->cbImage = pDstSeg->SegInfo.RVA + cb;
 
         /* Fixup the section RVAs (internal). */
         c        = cSegmentsToAdjust;
-        uNextRVA = pModMachO->cbImage;
-        pDstSeg  = &pModMachO->pMod->aSegments[0];
-        for (pSectExtraItr = pModMachO->paSections; pSectExtraItr != pSectExtra; pSectExtraItr++)
+        uNextRVA = pThis->cbImage;
+        pDstSeg  = &pThis->aSegments[0];
+        for (pSectExtraItr = pThis->paSections; pSectExtraItr != pSectExtra; pSectExtraItr++)
         {
             if (pSectExtraItr->iSegment < c)
-                pSectExtraItr->RVA += pDstSeg[pSectExtraItr->iSegment].RVA;
+                pSectExtraItr->RVA += pDstSeg[pSectExtraItr->iSegment].SegInfo.RVA;
             else
             {
                 pSectExtraItr->RVA = uNextRVA;
-                uNextRVA += KLDR_ALIGN_ADDR(pSectExtraItr->cb, 64);
+                uNextRVA += RTLDR_ALIGN_ADDR(pSectExtraItr->cb, 64);
             }
         }
@@ -1413,49 +1364,47 @@
      * Make the GOT segment if necessary.
      */
-    if (pModMachO->fMakeGot)
-    {
-        KU32 cbPtr = (   pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE
-                      || pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
-                   ? sizeof(KU32)
-                   : sizeof(KU64);
-        KU32 cbGot = pModMachO->cSymbols * cbPtr;
-        KU32 cbJmpStubs;
-
-        pModMachO->GotRVA = pModMachO->cbImage;
-
-        if (pModMachO->cbJmpStub)
-        {
-            cbGot = K_ALIGN_Z(cbGot, 64);
-            pModMachO->JmpStubsRVA = pModMachO->GotRVA + cbGot;
-            cbJmpStubs = pModMachO->cbJmpStub * pModMachO->cSymbols;
+    if (pThis->fMakeGot)
+    {
+        uint32_t cbPtr = (   pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE
+                      || pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
+                   ? sizeof(uint32_t)
+                   : sizeof(uint64_t);
+        uint32_t cbGot = pThis->cSymbols * cbPtr;
+        uint32_t cbJmpStubs;
+
+        pThis->GotRVA = pThis->cbImage;
+
+        if (pThis->cbJmpStub)
+        {
+            cbGot = RT_ALIGN_Z(cbGot, 64);
+            pThis->JmpStubsRVA = pThis->GotRVA + cbGot;
+            cbJmpStubs = pThis->cbJmpStub * pThis->cSymbols;
         }
         else
         {
-            pModMachO->JmpStubsRVA = NIL_KLDRADDR;
+            pThis->JmpStubsRVA = NIL_RTLDRADDR;
             cbJmpStubs = 0;
         }
 
-        pDstSeg = &pModMachO->pMod->aSegments[cSegments - 1];
-        pDstSeg->pvUser = NULL;
-        pDstSeg->pchName = "GOT";
-        pDstSeg->cchName = 3;
-        pDstSeg->SelFlat = 0;
-        pDstSeg->Sel16bit = 0;
-        pDstSeg->fFlags = 0;
-        pDstSeg->enmProt = KPROT_READONLY;
-        pDstSeg->cb = cbGot + cbJmpStubs;
-        pDstSeg->Alignment = 64;
-        pDstSeg->LinkAddress = pModMachO->LinkAddress + pModMachO->GotRVA;
-        pDstSeg->offFile = -1;
-        pDstSeg->cbFile  = -1;
-        pDstSeg->RVA = pModMachO->GotRVA;
-        pDstSeg->cbMapped = (KSIZE)KLDR_ALIGN_ADDR(cbGot + cbJmpStubs, pDstSeg->Alignment);
-        pDstSeg->MapAddress = 0;
-
-        pSegExtra->iOrgSegNo = KU32_MAX;
-        pSegExtra->cSections = 0;
-        pSegExtra->paSections = NULL;
-
-        pModMachO->cbImage += pDstSeg->cbMapped;
+        pDstSeg = &pThis->aSegments[cSegments - 1];
+        pDstSeg->SegInfo.pszName = "GOT";
+        pDstSeg->SegInfo.cchName = 3;
+        pDstSeg->SegInfo.SelFlat = 0;
+        pDstSeg->SegInfo.Sel16bit = 0;
+        pDstSeg->SegInfo.fFlags = 0;
+        pDstSeg->SegInfo.fProt = RTMEM_PROT_READ;
+        pDstSeg->SegInfo.cb = cbGot + cbJmpStubs;
+        pDstSeg->SegInfo.Alignment = 64;
+        pDstSeg->SegInfo.LinkAddress = pThis->LinkAddress + pThis->GotRVA;
+        pDstSeg->SegInfo.offFile = -1;
+        pDstSeg->SegInfo.cbFile  = -1;
+        pDstSeg->SegInfo.RVA = pThis->GotRVA;
+        pDstSeg->SegInfo.cbMapped = (size_t)RTLDR_ALIGN_ADDR(cbGot + cbJmpStubs, pDstSeg->SegInfo.Alignment);
+
+        pDstSeg->iOrgSegNo = UINT32_MAX;
+        pDstSeg->cSections = 0;
+        pDstSeg->paSections = NULL;
+
+        pThis->cbImage += pDstSeg->SegInfo.cbMapped;
     }
 
@@ -1464,37 +1413,38 @@
 
 
-/** @copydoc KLDRMODOPS::pfnDestroy */
-static int kldrModMachODestroy(PKLDRMOD pMod)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
+/**
+ * @interface_method_impl{RTLDROPS,pfnClose}
+ */
+static DECLCALLBACK(int) rtldrMachO_Close(PRTLDRMODINTERNAL pMod)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
     int rc = 0;
-    KU32 i, j;
-    KLDRMODMACHO_ASSERT(!pModMachO->pvMapping);
-
-    i = pMod->cSegments;
+    KLDRMODMACHO_ASSERT(!pThis->pvMapping);
+
+    uint32_t i = pThis->cSegments;
     while (i-- > 0)
     {
-        j = pModMachO->aSegments[i].cSections;
+        uint32_t j = pThis->aSegments[i].cSections;
         while (j-- > 0)
         {
-            kHlpFree(pModMachO->aSegments[i].paSections[j].paFixups);
-            pModMachO->aSegments[i].paSections[j].paFixups = NULL;
-        }
-    }
-
-    if (pMod->pRdr)
-    {
-        rc = kRdrClose(pMod->pRdr);
-        pMod->pRdr = NULL;
-    }
-    pMod->u32Magic = 0;
-    pMod->pOps = NULL;
-    kHlpFree(pModMachO->pbLoadCommands);
-    pModMachO->pbLoadCommands = NULL;
-    kHlpFree(pModMachO->pchStrings);
-    pModMachO->pchStrings = NULL;
-    kHlpFree(pModMachO->pvaSymbols);
-    pModMachO->pvaSymbols = NULL;
-    kHlpFree(pModMachO);
+            RTMemFree(pThis->aSegments[i].paSections[j].paFixups);
+            pThis->aSegments[i].paSections[j].paFixups = NULL;
+        }
+    }
+
+    if (pThis->Core.pReader)
+    {
+        rc = pThis->Core.pReader->pfnDestroy(pThis->Core.pReader);
+        pThis->Core.pReader = NULL;
+    }
+    pThis->Core.u32Magic = 0;
+    pThis->Core.pOps = NULL;
+    RTMemFree(pThis->pbLoadCommands);
+    pThis->pbLoadCommands = NULL;
+    RTMemFree(pThis->pchStrings);
+    pThis->pchStrings = NULL;
+    RTMemFree(pThis->pvaSymbols);
+    pThis->pvaSymbols = NULL;
+    RTMemFree(pThis);
     return rc;
 }
@@ -1506,17 +1456,14 @@
  * @returns 0 on success.
  * @returns A non-zero status code if the BaseAddress isn't right.
- * @param   pModMachO       The interpreter module instance
+ * @param   pThis       The interpreter module instance
  * @param   pBaseAddress    The base address, IN & OUT. Optional.
  */
-static int kldrModMachOAdjustBaseAddress(PKLDRMODMACHO pModMachO, PKLDRADDR pBaseAddress)
+static int kldrModMachOAdjustBaseAddress(PKLDRMODMACHO pThis, PRTLDRADDR pBaseAddress)
 {
     /*
      * Adjust the base address.
      */
-    if (*pBaseAddress == KLDRMOD_BASEADDRESS_MAP)
-        *pBaseAddress = pModMachO->pMod->aSegments[0].MapAddress;
-    else if (*pBaseAddress == KLDRMOD_BASEADDRESS_LINK)
-        *pBaseAddress = pModMachO->LinkAddress;
-
+    if (*pBaseAddress == RTLDR_BASEADDRESS_LINK)
+        *pBaseAddress = pThis->LinkAddress;
     return 0;
 }
@@ -1529,7 +1476,6 @@
  * and segments.  This function checks for these and returns the right value.
  *
- * @returns 0 or KLDR_ERR_SYMBOL_NOT_FOUND.
- * @param   pModMachO           The interpreter module instance.
- * @param   pMod                The generic module instance.
+ * @returns 0 or VERR_SYMBOL_NOT_FOUND.
+ * @param   pThis           The interpreter module instance.
  * @param   pchSymbol           The symbol.
  * @param   cchSymbol           The length of the symbol.
@@ -1538,6 +1484,6 @@
  * @param   puValue             Where to return the symbol value.
  */
-static int kldrModMachOQueryLinkerSymbol(PKLDRMODMACHO pModMachO, PKLDRMOD pMod, const char *pchSymbol, KSIZE cchSymbol,
-                                         KLDRADDR BaseAddress, PKLDRADDR puValue)
+static int kldrModMachOQueryLinkerSymbol(PKLDRMODMACHO pThis, const char *pchSymbol, size_t cchSymbol,
+                                         RTLDRADDR BaseAddress, PRTLDRADDR puValue)
 {
     /*
@@ -1547,27 +1493,27 @@
     {
         const char *pszPrefix;
-        KU8         cchPrefix;
-        KBOOL       fSection;
-        KBOOL       fStart;
+        uint32_t    cchPrefix;
+        bool        fSection;
+        bool        fStart;
     }   s_aPrefixes[] =
     {
-        { "section$start$",  (KU8)sizeof("section$start$") - 1,   K_TRUE,  K_TRUE },
-        { "section$end$",    (KU8)sizeof("section$end$") - 1,     K_TRUE,  K_FALSE},
-        { "segment$start$",  (KU8)sizeof("segment$start$") - 1,   K_FALSE, K_TRUE },
-        { "segment$end$",    (KU8)sizeof("segment$end$") - 1,     K_FALSE, K_FALSE},
+        { "section$start$",  (uint8_t)sizeof("section$start$") - 1,   true,  true },
+        { "section$end$",    (uint8_t)sizeof("section$end$") - 1,     true,  false},
+        { "segment$start$",  (uint8_t)sizeof("segment$start$") - 1,   false, true },
+        { "segment$end$",    (uint8_t)sizeof("segment$end$") - 1,     false, false},
     };
-    KSIZE       cchSectName = 0;
+    size_t      cchSectName = 0;
     const char *pchSectName = "";
-    KSIZE       cchSegName  = 0;
+    size_t      cchSegName  = 0;
     const char *pchSegName  = NULL;
-    KU32        iPrefix     = K_ELEMENTS(s_aPrefixes) - 1;
-    KU32        iSeg;
-    KLDRADDR    uValue;
+    uint32_t    iPrefix     = RT_ELEMENTS(s_aPrefixes) - 1;
+    uint32_t    iSeg;
+    RTLDRADDR   uValue;
 
     for (;;)
     {
-        KU8 const cchPrefix = s_aPrefixes[iPrefix].cchPrefix;
+        uint8_t const cchPrefix = s_aPrefixes[iPrefix].cchPrefix;
         if (   cchSymbol > cchPrefix
-            && kHlpStrNComp(pchSymbol, s_aPrefixes[iPrefix].pszPrefix, cchPrefix) == 0)
+            && strncmp(pchSymbol, s_aPrefixes[iPrefix].pszPrefix, cchPrefix) == 0)
         {
             pchSegName = pchSymbol + cchPrefix;
@@ -1578,5 +1524,5 @@
         /* next */
         if (!iPrefix)
-            return KLDR_ERR_SYMBOL_NOT_FOUND;
+            return VERR_SYMBOL_NOT_FOUND;
         iPrefix--;
     }
@@ -1587,7 +1533,7 @@
     if (s_aPrefixes[iPrefix].fSection)
     {
-        pchSectName = kHlpMemChr(pchSegName, '$', cchSegName);
+        pchSectName = (const char *)memchr(pchSegName, '$', cchSegName);
         if (!pchSectName)
-            return KLDR_ERR_SYMBOL_NOT_FOUND;
+            return VERR_SYMBOL_NOT_FOUND;
         cchSegName  = pchSectName - pchSegName;
         pchSectName++;
@@ -1598,27 +1544,27 @@
      * Locate the segment.
      */
-    if (!pMod->cSegments)
-        return KLDR_ERR_SYMBOL_NOT_FOUND;
-    for (iSeg = 0; iSeg < pMod->cSegments; iSeg++)
-    {
-        if (   pMod->aSegments[iSeg].cchName >= cchSegName
-            && kHlpMemComp(pMod->aSegments[iSeg].pchName, pchSegName, cchSegName) == 0)
+    if (!pThis->cSegments)
+        return VERR_SYMBOL_NOT_FOUND;
+    for (iSeg = 0; iSeg < pThis->cSegments; iSeg++)
+    {
+        if (   pThis->aSegments[iSeg].SegInfo.cchName >= cchSegName
+            && memcmp(pThis->aSegments[iSeg].SegInfo.pszName, pchSegName, cchSegName) == 0)
         {
             section_32_t const *pSect;
-            if (   pMod->aSegments[iSeg].cchName == cchSegName
-                && pModMachO->Hdr.filetype != MH_OBJECT /* Good enough for __DWARF segs in MH_DHSYM, I hope. */)
+            if (   pThis->aSegments[iSeg].SegInfo.cchName == cchSegName
+                && pThis->Hdr.filetype != MH_OBJECT /* Good enough for __DWARF segs in MH_DHSYM, I hope. */)
                 break;
 
-            pSect = (section_32_t *)pModMachO->aSegments[iSeg].paSections[0].pvMachoSection;
-            if (   pModMachO->uEffFileType == MH_OBJECT
-                && pMod->aSegments[iSeg].cchName > cchSegName + 1
-                && pMod->aSegments[iSeg].pchName[cchSegName] == '.'
-                && kHlpStrNComp(&pMod->aSegments[iSeg].pchName[cchSegName + 1], pSect->sectname, sizeof(pSect->sectname)) == 0
-                && pMod->aSegments[iSeg].cchName - cchSegName - 1 <= sizeof(pSect->sectname) )
+            pSect = (section_32_t *)pThis->aSegments[iSeg].paSections[0].pvMachoSection;
+            if (   pThis->uEffFileType == MH_OBJECT
+                && pThis->aSegments[iSeg].SegInfo.cchName > cchSegName + 1
+                && pThis->aSegments[iSeg].SegInfo.pszName[cchSegName] == '.'
+                && strncmp(&pThis->aSegments[iSeg].SegInfo.pszName[cchSegName + 1], pSect->sectname, sizeof(pSect->sectname)) == 0
+                && pThis->aSegments[iSeg].SegInfo.cchName - cchSegName - 1 <= sizeof(pSect->sectname) )
                 break;
         }
     }
-    if (iSeg >= pMod->cSegments)
-        return KLDR_ERR_SYMBOL_NOT_FOUND;
+    if (iSeg >= pThis->cSegments)
+        return VERR_SYMBOL_NOT_FOUND;
 
     if (!s_aPrefixes[iPrefix].fSection)
@@ -1627,7 +1573,7 @@
          * Calculate the segment start/end address.
          */
-        uValue = pMod->aSegments[iSeg].RVA;
+        uValue = pThis->aSegments[iSeg].SegInfo.RVA;
         if (!s_aPrefixes[iPrefix].fStart)
-            uValue += pMod->aSegments[iSeg].cb;
+            uValue += pThis->aSegments[iSeg].SegInfo.cb;
     }
     else
@@ -1636,12 +1582,12 @@
          * Locate the section.
          */
-        KU32 iSect = pModMachO->aSegments[iSeg].cSections;
+        uint32_t iSect = pThis->aSegments[iSeg].cSections;
         if (!iSect)
-            return KLDR_ERR_SYMBOL_NOT_FOUND;
+            return VERR_SYMBOL_NOT_FOUND;
         for (;;)
         {
-            section_32_t *pSect = (section_32_t *)pModMachO->aSegments[iSeg].paSections[iSect].pvMachoSection;
+            section_32_t *pSect = (section_32_t *)pThis->aSegments[iSeg].paSections[iSect].pvMachoSection;
             if (   cchSectName <= sizeof(pSect->sectname)
-                && kHlpMemComp(pSect->sectname, pchSectName, cchSectName) == 0
+                && memcmp(pSect->sectname, pchSectName, cchSectName) == 0
                 && (   cchSectName == sizeof(pSect->sectname)
                     || pSect->sectname[cchSectName] == '\0') )
@@ -1649,11 +1595,11 @@
             /* next */
             if (!iSect)
-                return KLDR_ERR_SYMBOL_NOT_FOUND;
+                return VERR_SYMBOL_NOT_FOUND;
             iSect--;
         }
 
-        uValue = pModMachO->aSegments[iSeg].paSections[iSect].RVA;
+        uValue = pThis->aSegments[iSeg].paSections[iSect].RVA;
         if (!s_aPrefixes[iPrefix].fStart)
-            uValue += pModMachO->aSegments[iSeg].paSections[iSect].cb;
+            uValue += pThis->aSegments[iSeg].paSections[iSect].cb;
     }
 
@@ -1669,20 +1615,23 @@
 
 
-/** @copydoc kLdrModQuerySymbol */
-static int kldrModMachOQuerySymbol(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, KU32 iSymbol,
-                                   const char *pchSymbol, KSIZE cchSymbol, const char *pszVersion,
-                                   PFNKLDRMODGETIMPORT pfnGetForwarder, void *pvUser, PKLDRADDR puValue, KU32 *pfKind)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
-    int rc;
-    K_NOREF(pvBits);
-    K_NOREF(pszVersion);
-    K_NOREF(pfnGetForwarder);
-    K_NOREF(pvUser);
+/**
+ * @interface_method_impl{RTLDROPS,pfnGetSymbolEx}
+ */
+static DECLCALLBACK(int) rtldrMachO_GetSymbolEx(PRTLDRMODINTERNAL pMod, const void *pvBits, RTUINTPTR BaseAddress,
+                                                uint32_t iOrdinal, const char *pszSymbol, RTUINTPTR *pValue)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+    RT_NOREF(pvBits);
+    //RT_NOREF(pszVersion);
+    //RT_NOREF(pfnGetForwarder);
+    //RT_NOREF(pvUser);
+    uint32_t fKind = RTLDRSYMKIND_REQ_FLAT;
+    uint32_t *pfKind = &fKind;
+    size_t cchSymbol = pszSymbol ? strlen(pszSymbol) : 0;
 
     /*
      * Resolve defaults.
      */
-    rc  = kldrModMachOAdjustBaseAddress(pModMachO, &BaseAddress);
+    int rc = kldrModMachOAdjustBaseAddress(pThis, &BaseAddress);
     if (rc)
         return rc;
@@ -1692,29 +1641,29 @@
      */
     KLDRMODMACHO_CHECK_RETURN(   !pfKind
-                              || (*pfKind & KLDRSYMKIND_REQ_TYPE_MASK) == KLDRSYMKIND_REQ_FLAT,
-                              KLDR_ERR_TODO);
+                              || (*pfKind & RTLDRSYMKIND_REQ_TYPE_MASK) == RTLDRSYMKIND_REQ_FLAT,
+                              VERR_LDRMACHO_TODO);
 
     /*
      * Take action according to file type.
      */
-    if (   pModMachO->Hdr.filetype == MH_OBJECT
-        || pModMachO->Hdr.filetype == MH_EXECUTE /** @todo dylib, execute, dsym: symbols */
-        || pModMachO->Hdr.filetype == MH_DYLIB
-        || pModMachO->Hdr.filetype == MH_BUNDLE
-        || pModMachO->Hdr.filetype == MH_DSYM
-        || pModMachO->Hdr.filetype == MH_KEXT_BUNDLE)
-    {
-        rc = kldrModMachOLoadObjSymTab(pModMachO);
+    if (   pThis->Hdr.filetype == MH_OBJECT
+        || pThis->Hdr.filetype == MH_EXECUTE /** @todo dylib, execute, dsym: symbols */
+        || pThis->Hdr.filetype == MH_DYLIB
+        || pThis->Hdr.filetype == MH_BUNDLE
+        || pThis->Hdr.filetype == MH_DSYM
+        || pThis->Hdr.filetype == MH_KEXT_BUNDLE)
+    {
+        rc = kldrModMachOLoadObjSymTab(pThis);
         if (!rc)
         {
-            if (    pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE
-                ||  pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
-                rc = kldrModMachODoQuerySymbol32Bit(pModMachO, (macho_nlist_32_t *)pModMachO->pvaSymbols, pModMachO->cSymbols,
-                                                    pModMachO->pchStrings, pModMachO->cchStrings, BaseAddress, iSymbol, pchSymbol,
-                                                    (KU32)cchSymbol, puValue, pfKind);
+            if (    pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE
+                ||  pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
+                rc = kldrModMachODoQuerySymbol32Bit(pThis, (macho_nlist_32_t *)pThis->pvaSymbols, pThis->cSymbols,
+                                                    pThis->pchStrings, pThis->cchStrings, BaseAddress, iOrdinal, pszSymbol,
+                                                    (uint32_t)cchSymbol, pValue, pfKind);
             else
-                rc = kldrModMachODoQuerySymbol64Bit(pModMachO, (macho_nlist_64_t *)pModMachO->pvaSymbols, pModMachO->cSymbols,
-                                                    pModMachO->pchStrings, pModMachO->cchStrings, BaseAddress, iSymbol, pchSymbol,
-                                                    (KU32)cchSymbol, puValue, pfKind);
+                rc = kldrModMachODoQuerySymbol64Bit(pThis, (macho_nlist_64_t *)pThis->pvaSymbols, pThis->cSymbols,
+                                                    pThis->pchStrings, pThis->cchStrings, BaseAddress, iOrdinal, pszSymbol,
+                                                    (uint32_t)cchSymbol, pValue, pfKind);
         }
 
@@ -1725,18 +1674,18 @@
          * before querying symbols, we will ignore the prefix.
          */
-        if (  rc == KLDR_ERR_SYMBOL_NOT_FOUND
+        if (  rc == VERR_SYMBOL_NOT_FOUND
             && cchSymbol > sizeof("section$end$") - 1
-            && (    pchSymbol[0] == 's'
-                || (pchSymbol[1] == 's' && pchSymbol[0] == '_') )
-            && kHlpMemChr(pchSymbol, '$', cchSymbol) )
-        {
-            if (pchSymbol[0] == '_')
-                rc = kldrModMachOQueryLinkerSymbol(pModMachO, pMod, pchSymbol + 1, cchSymbol - 1, BaseAddress, puValue);
+            && (    pszSymbol[0] == 's'
+                || (pszSymbol[1] == 's' && pszSymbol[0] == '_') )
+            && memchr(pszSymbol, '$', cchSymbol) )
+        {
+            if (pszSymbol[0] == '_')
+                rc = kldrModMachOQueryLinkerSymbol(pThis, pszSymbol + 1, cchSymbol - 1, BaseAddress, pValue);
             else
-                rc = kldrModMachOQueryLinkerSymbol(pModMachO, pMod, pchSymbol, cchSymbol, BaseAddress, puValue);
+                rc = kldrModMachOQueryLinkerSymbol(pThis, pszSymbol, cchSymbol, BaseAddress, pValue);
         }
     }
     else
-        rc = KLDR_ERR_TODO;
+        rc = VERR_LDRMACHO_TODO;
 
     return rc;
@@ -1748,5 +1697,5 @@
  *
  * @returns See kLdrModQuerySymbol.
- * @param   pModMachO
+ * @param   pThis
  * @param   paSyms      Pointer to the symbol table.
  * @param   cSyms       Number of symbols in the table.
@@ -1760,20 +1709,20 @@
  * @param   pfKind      See kLdrModQuerySymbol.
  */
-static int kldrModMachODoQuerySymbol32Bit(PKLDRMODMACHO pModMachO, const macho_nlist_32_t *paSyms, KU32 cSyms,
-                                          const char *pchStrings, KU32 cchStrings, KLDRADDR BaseAddress, KU32 iSymbol,
-                                          const char *pchSymbol, KU32 cchSymbol, PKLDRADDR puValue, KU32 *pfKind)
+static int kldrModMachODoQuerySymbol32Bit(PKLDRMODMACHO pThis, const macho_nlist_32_t *paSyms, uint32_t cSyms,
+                                          const char *pchStrings, uint32_t cchStrings, RTLDRADDR BaseAddress, uint32_t iSymbol,
+                                          const char *pchSymbol, uint32_t cchSymbol, PRTLDRADDR puValue, uint32_t *pfKind)
 {
     /*
      * Find a valid symbol matching the search criteria.
      */
-    if (iSymbol == NIL_KLDRMOD_SYM_ORDINAL)
+    if (iSymbol == UINT32_MAX)
     {
         /* simplify validation. */
         if (cchStrings <= cchSymbol)
-            return KLDR_ERR_SYMBOL_NOT_FOUND;
+            return VERR_SYMBOL_NOT_FOUND;
         cchStrings -= cchSymbol;
 
         /* external symbols are usually at the end, so search the other way. */
-        for (iSymbol = cSyms - 1; iSymbol != KU32_MAX; iSymbol--)
+        for (iSymbol = cSyms - 1; iSymbol != UINT32_MAX; iSymbol--)
         {
             const char *psz;
@@ -1792,10 +1741,10 @@
             if (!paSyms[iSymbol].n_un.n_strx)
                 continue;
-            if ((KU32)paSyms[iSymbol].n_un.n_strx >= cchStrings)
+            if ((uint32_t)paSyms[iSymbol].n_un.n_strx >= cchStrings)
                 continue;
             psz = &pchStrings[paSyms[iSymbol].n_un.n_strx];
             if (psz[cchSymbol])
                 continue;
-            if (kHlpMemComp(psz, pchSymbol, cchSymbol))
+            if (memcmp(psz, pchSymbol, cchSymbol))
                 continue;
 
@@ -1803,15 +1752,15 @@
             break;
         }
-        if (iSymbol == KU32_MAX)
-            return KLDR_ERR_SYMBOL_NOT_FOUND;
+        if (iSymbol == UINT32_MAX)
+            return VERR_SYMBOL_NOT_FOUND;
     }
     else
     {
         if (iSymbol >= cSyms)
-            return KLDR_ERR_SYMBOL_NOT_FOUND;
+            return VERR_SYMBOL_NOT_FOUND;
         if (paSyms[iSymbol].n_type & MACHO_N_STAB)
-            return KLDR_ERR_SYMBOL_NOT_FOUND;
+            return VERR_SYMBOL_NOT_FOUND;
         if ((paSyms[iSymbol].n_type & MACHO_N_TYPE) == MACHO_N_UNDF)
-            return KLDR_ERR_SYMBOL_NOT_FOUND;
+            return VERR_SYMBOL_NOT_FOUND;
     }
 
@@ -1821,11 +1770,11 @@
     if (pfKind)
     {
-        if (    pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE
-            ||  pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
-            *pfKind = KLDRSYMKIND_32BIT | KLDRSYMKIND_NO_TYPE;
+        if (    pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE
+            ||  pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
+            *pfKind = RTLDRSYMKIND_32BIT | RTLDRSYMKIND_NO_TYPE;
         else
-            *pfKind = KLDRSYMKIND_64BIT | KLDRSYMKIND_NO_TYPE;
+            *pfKind = RTLDRSYMKIND_64BIT | RTLDRSYMKIND_NO_TYPE;
         if (paSyms[iSymbol].n_desc & N_WEAK_DEF)
-            *pfKind |= KLDRSYMKIND_WEAK;
+            *pfKind |= RTLDRSYMKIND_WEAK;
     }
 
@@ -1835,7 +1784,7 @@
         {
             PKLDRMODMACHOSECT pSect;
-            KLDRADDR offSect;
-            KLDRMODMACHO_CHECK_RETURN((KU32)(paSyms[iSymbol].n_sect - 1) < pModMachO->cSections, KLDR_ERR_MACHO_BAD_SYMBOL);
-            pSect = &pModMachO->paSections[paSyms[iSymbol].n_sect - 1];
+            RTLDRADDR offSect;
+            KLDRMODMACHO_CHECK_RETURN((uint32_t)(paSyms[iSymbol].n_sect - 1) < pThis->cSections, VERR_LDRMACHO_BAD_SYMBOL);
+            pSect = &pThis->paSections[paSyms[iSymbol].n_sect - 1];
 
             offSect = paSyms[iSymbol].n_value - pSect->LinkAddress;
@@ -1843,6 +1792,6 @@
                                       || (   paSyms[iSymbol].n_sect == 1 /* special hack for __mh_execute_header */
                                           && offSect == 0U - pSect->RVA
-                                          && pModMachO->uEffFileType != MH_OBJECT),
-                                      KLDR_ERR_MACHO_BAD_SYMBOL);
+                                          && pThis->uEffFileType != MH_OBJECT),
+                                      VERR_LDRMACHO_BAD_SYMBOL);
             if (puValue)
                 *puValue = BaseAddress + pSect->RVA + offSect;
@@ -1850,5 +1799,5 @@
             if (    pfKind
                 &&  (pSect->fFlags & (S_ATTR_PURE_INSTRUCTIONS | S_ATTR_SELF_MODIFYING_CODE)))
-                *pfKind = (*pfKind & ~KLDRSYMKIND_TYPE_MASK) | KLDRSYMKIND_CODE;
+                *pfKind = (*pfKind & ~RTLDRSYMKIND_TYPE_MASK) | RTLDRSYMKIND_CODE;
             break;
         }
@@ -1858,5 +1807,5 @@
                 *puValue = paSyms[iSymbol].n_value;
             /*if (pfKind)
-                pfKind |= KLDRSYMKIND_ABS;*/
+                pfKind |= RTLDRSYMKIND_ABS;*/
             break;
 
@@ -1865,5 +1814,5 @@
             /** @todo implement indirect and prebound symbols. */
         default:
-            KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_TODO);
+            KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_TODO);
     }
 
@@ -1876,5 +1825,5 @@
  *
  * @returns See kLdrModQuerySymbol.
- * @param   pModMachO
+ * @param   pThis
  * @param   paSyms      Pointer to the symbol table.
  * @param   cSyms       Number of symbols in the table.
@@ -1888,20 +1837,20 @@
  * @param   pfKind      See kLdrModQuerySymbol.
  */
-static int kldrModMachODoQuerySymbol64Bit(PKLDRMODMACHO pModMachO, const macho_nlist_64_t *paSyms, KU32 cSyms,
-                                          const char *pchStrings, KU32 cchStrings, KLDRADDR BaseAddress, KU32 iSymbol,
-                                          const char *pchSymbol, KU32 cchSymbol, PKLDRADDR puValue, KU32 *pfKind)
+static int kldrModMachODoQuerySymbol64Bit(PKLDRMODMACHO pThis, const macho_nlist_64_t *paSyms, uint32_t cSyms,
+                                          const char *pchStrings, uint32_t cchStrings, RTLDRADDR BaseAddress, uint32_t iSymbol,
+                                          const char *pchSymbol, uint32_t cchSymbol, PRTLDRADDR puValue, uint32_t *pfKind)
 {
     /*
      * Find a valid symbol matching the search criteria.
      */
-    if (iSymbol == NIL_KLDRMOD_SYM_ORDINAL)
+    if (iSymbol == UINT32_MAX)
     {
         /* simplify validation. */
         if (cchStrings <= cchSymbol)
-            return KLDR_ERR_SYMBOL_NOT_FOUND;
+            return VERR_SYMBOL_NOT_FOUND;
         cchStrings -= cchSymbol;
 
         /* external symbols are usually at the end, so search the other way. */
-        for (iSymbol = cSyms - 1; iSymbol != KU32_MAX; iSymbol--)
+        for (iSymbol = cSyms - 1; iSymbol != UINT32_MAX; iSymbol--)
         {
             const char *psz;
@@ -1920,10 +1869,10 @@
             if (!paSyms[iSymbol].n_un.n_strx)
                 continue;
-            if ((KU32)paSyms[iSymbol].n_un.n_strx >= cchStrings)
+            if ((uint32_t)paSyms[iSymbol].n_un.n_strx >= cchStrings)
                 continue;
             psz = &pchStrings[paSyms[iSymbol].n_un.n_strx];
             if (psz[cchSymbol])
                 continue;
-            if (kHlpMemComp(psz, pchSymbol, cchSymbol))
+            if (memcmp(psz, pchSymbol, cchSymbol))
                 continue;
 
@@ -1931,15 +1880,15 @@
             break;
         }
-        if (iSymbol == KU32_MAX)
-            return KLDR_ERR_SYMBOL_NOT_FOUND;
+        if (iSymbol == UINT32_MAX)
+            return VERR_SYMBOL_NOT_FOUND;
     }
     else
     {
         if (iSymbol >= cSyms)
-            return KLDR_ERR_SYMBOL_NOT_FOUND;
+            return VERR_SYMBOL_NOT_FOUND;
         if (paSyms[iSymbol].n_type & MACHO_N_STAB)
-            return KLDR_ERR_SYMBOL_NOT_FOUND;
+            return VERR_SYMBOL_NOT_FOUND;
         if ((paSyms[iSymbol].n_type & MACHO_N_TYPE) == MACHO_N_UNDF)
-            return KLDR_ERR_SYMBOL_NOT_FOUND;
+            return VERR_SYMBOL_NOT_FOUND;
     }
 
@@ -1949,11 +1898,11 @@
     if (pfKind)
     {
-        if (    pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE
-            ||  pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
-            *pfKind = KLDRSYMKIND_32BIT | KLDRSYMKIND_NO_TYPE;
+        if (    pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE
+            ||  pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
+            *pfKind = RTLDRSYMKIND_32BIT | RTLDRSYMKIND_NO_TYPE;
         else
-            *pfKind = KLDRSYMKIND_64BIT | KLDRSYMKIND_NO_TYPE;
+            *pfKind = RTLDRSYMKIND_64BIT | RTLDRSYMKIND_NO_TYPE;
         if (paSyms[iSymbol].n_desc & N_WEAK_DEF)
-            *pfKind |= KLDRSYMKIND_WEAK;
+            *pfKind |= RTLDRSYMKIND_WEAK;
     }
 
@@ -1963,7 +1912,7 @@
         {
             PKLDRMODMACHOSECT pSect;
-            KLDRADDR offSect;
-            KLDRMODMACHO_CHECK_RETURN((KU32)(paSyms[iSymbol].n_sect - 1) < pModMachO->cSections, KLDR_ERR_MACHO_BAD_SYMBOL);
-            pSect = &pModMachO->paSections[paSyms[iSymbol].n_sect - 1];
+            RTLDRADDR offSect;
+            KLDRMODMACHO_CHECK_RETURN((uint32_t)(paSyms[iSymbol].n_sect - 1) < pThis->cSections, VERR_LDRMACHO_BAD_SYMBOL);
+            pSect = &pThis->paSections[paSyms[iSymbol].n_sect - 1];
 
             offSect = paSyms[iSymbol].n_value - pSect->LinkAddress;
@@ -1971,6 +1920,6 @@
                                       || (   paSyms[iSymbol].n_sect == 1 /* special hack for __mh_execute_header */
                                           && offSect == 0U - pSect->RVA
-                                          && pModMachO->uEffFileType != MH_OBJECT),
-                                      KLDR_ERR_MACHO_BAD_SYMBOL);
+                                          && pThis->uEffFileType != MH_OBJECT),
+                                      VERR_LDRMACHO_BAD_SYMBOL);
             if (puValue)
                 *puValue = BaseAddress + pSect->RVA + offSect;
@@ -1978,5 +1927,5 @@
             if (    pfKind
                 &&  (pSect->fFlags & (S_ATTR_PURE_INSTRUCTIONS | S_ATTR_SELF_MODIFYING_CODE)))
-                *pfKind = (*pfKind & ~KLDRSYMKIND_TYPE_MASK) | KLDRSYMKIND_CODE;
+                *pfKind = (*pfKind & ~RTLDRSYMKIND_TYPE_MASK) | RTLDRSYMKIND_CODE;
             break;
         }
@@ -1986,5 +1935,5 @@
                 *puValue = paSyms[iSymbol].n_value;
             /*if (pfKind)
-                pfKind |= KLDRSYMKIND_ABS;*/
+                pfKind |= RTLDRSYMKIND_ABS;*/
             break;
 
@@ -1993,5 +1942,5 @@
             /** @todo implement indirect and prebound symbols. */
         default:
-            KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_TODO);
+            KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_TODO);
     }
 
@@ -2000,16 +1949,18 @@
 
 
-/** @copydoc kLdrModEnumSymbols */
-static int kldrModMachOEnumSymbols(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress,
-                                   KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
+/**
+ * @interface_method_impl{RTLDROPS,pfnEnumSymbols}
+ */
+static DECLCALLBACK(int) rtldrMachO_EnumSymbols(PRTLDRMODINTERNAL pMod, unsigned fFlags, const void *pvBits,
+                                                RTUINTPTR BaseAddress, PFNRTLDRENUMSYMS pfnCallback, void *pvUser)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
     int rc;
-    K_NOREF(pvBits);
+    RT_NOREF(pvBits);
 
     /*
      * Resolve defaults.
      */
-    rc  = kldrModMachOAdjustBaseAddress(pModMachO, &BaseAddress);
+    rc  = kldrModMachOAdjustBaseAddress(pThis, &BaseAddress);
     if (rc)
         return rc;
@@ -2018,27 +1969,27 @@
      * Take action according to file type.
      */
-    if (   pModMachO->Hdr.filetype == MH_OBJECT
-        || pModMachO->Hdr.filetype == MH_EXECUTE /** @todo dylib, execute, dsym: symbols */
-        || pModMachO->Hdr.filetype == MH_DYLIB
-        || pModMachO->Hdr.filetype == MH_BUNDLE
-        || pModMachO->Hdr.filetype == MH_DSYM
-        || pModMachO->Hdr.filetype == MH_KEXT_BUNDLE)
-    {
-        rc = kldrModMachOLoadObjSymTab(pModMachO);
+    if (   pThis->Hdr.filetype == MH_OBJECT
+        || pThis->Hdr.filetype == MH_EXECUTE /** @todo dylib, execute, dsym: symbols */
+        || pThis->Hdr.filetype == MH_DYLIB
+        || pThis->Hdr.filetype == MH_BUNDLE
+        || pThis->Hdr.filetype == MH_DSYM
+        || pThis->Hdr.filetype == MH_KEXT_BUNDLE)
+    {
+        rc = kldrModMachOLoadObjSymTab(pThis);
         if (!rc)
         {
-            if (    pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE
-                ||  pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
-                rc = kldrModMachODoEnumSymbols32Bit(pModMachO, (macho_nlist_32_t *)pModMachO->pvaSymbols, pModMachO->cSymbols,
-                                                    pModMachO->pchStrings, pModMachO->cchStrings, BaseAddress,
+            if (    pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE
+                ||  pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
+                rc = kldrModMachODoEnumSymbols32Bit(pThis, (macho_nlist_32_t *)pThis->pvaSymbols, pThis->cSymbols,
+                                                    pThis->pchStrings, pThis->cchStrings, BaseAddress,
                                                     fFlags, pfnCallback, pvUser);
             else
-                rc = kldrModMachODoEnumSymbols64Bit(pModMachO, (macho_nlist_64_t *)pModMachO->pvaSymbols, pModMachO->cSymbols,
-                                                    pModMachO->pchStrings, pModMachO->cchStrings, BaseAddress,
+                rc = kldrModMachODoEnumSymbols64Bit(pThis, (macho_nlist_64_t *)pThis->pvaSymbols, pThis->cSymbols,
+                                                    pThis->pchStrings, pThis->cchStrings, BaseAddress,
                                                     fFlags, pfnCallback, pvUser);
         }
     }
     else
-        KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_TODO);
+        KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_TODO);
 
     return rc;
@@ -2050,5 +2001,5 @@
  *
  * @returns See kLdrModQuerySymbol.
- * @param   pModMachO
+ * @param   pThis
  * @param   paSyms      Pointer to the symbol table.
  * @param   cSyms       Number of symbols in the table.
@@ -2060,12 +2011,12 @@
  * @param   pvUser      See kLdrModEnumSymbols.
  */
-static int kldrModMachODoEnumSymbols32Bit(PKLDRMODMACHO pModMachO, const macho_nlist_32_t *paSyms, KU32 cSyms,
-                                          const char *pchStrings, KU32 cchStrings, KLDRADDR BaseAddress,
-                                          KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser)
-{
-    const KU32 fKindBase =    pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE
-                           || pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE
-                         ? KLDRSYMKIND_32BIT : KLDRSYMKIND_64BIT;
-    KU32 iSym;
+static int kldrModMachODoEnumSymbols32Bit(PKLDRMODMACHO pThis, const macho_nlist_32_t *paSyms, uint32_t cSyms,
+                                          const char *pchStrings, uint32_t cchStrings, RTLDRADDR BaseAddress,
+                                          uint32_t fFlags, PFNRTLDRENUMSYMS pfnCallback, void *pvUser)
+{
+    const uint32_t fKindBase =    pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE
+                           || pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE
+                         ? RTLDRSYMKIND_32BIT : RTLDRSYMKIND_64BIT;
+    uint32_t iSym;
     int rc;
 
@@ -2075,8 +2026,8 @@
     for (iSym = 0; iSym < cSyms; iSym++)
     {
-        KU32 fKind;
-        KLDRADDR uValue;
+        uint32_t fKind;
+        RTLDRADDR uValue;
         const char *psz;
-        KSIZE cch;
+        size_t cch;
 
         /* Skip debug symbols and undefined symbols. */
@@ -2087,5 +2038,5 @@
 
         /* Skip non-public symbols unless they are requested explicitly. */
-        if (!(fFlags & KLDRMOD_ENUM_SYMS_FLAGS_ALL))
+        if (!(fFlags & RTLDR_ENUM_SYMBOL_FLAGS_ALL))
         {
             if (!(paSyms[iSym].n_type & MACHO_N_EXT)) /*??*/
@@ -2102,7 +2053,7 @@
 
         /* name */
-        KLDRMODMACHO_CHECK_RETURN((KU32)paSyms[iSym].n_un.n_strx < cchStrings, KLDR_ERR_MACHO_BAD_SYMBOL);
+        KLDRMODMACHO_CHECK_RETURN((uint32_t)paSyms[iSym].n_un.n_strx < cchStrings, VERR_LDRMACHO_BAD_SYMBOL);
         psz = &pchStrings[paSyms[iSym].n_un.n_strx];
-        cch = kHlpStrLen(psz);
+        cch = strlen(psz);
         if (!cch)
             psz = NULL;
@@ -2111,5 +2062,5 @@
         fKind = fKindBase;
         if (paSyms[iSym].n_desc & N_WEAK_DEF)
-            fKind |= KLDRSYMKIND_WEAK;
+            fKind |= RTLDRSYMKIND_WEAK;
         switch (paSyms[iSym].n_type & MACHO_N_TYPE)
         {
@@ -2117,6 +2068,6 @@
             {
                 PKLDRMODMACHOSECT pSect;
-                KLDRMODMACHO_CHECK_RETURN((KU32)(paSyms[iSym].n_sect - 1) < pModMachO->cSections, KLDR_ERR_MACHO_BAD_SYMBOL);
-                pSect = &pModMachO->paSections[paSyms[iSym].n_sect - 1];
+                KLDRMODMACHO_CHECK_RETURN((uint32_t)(paSyms[iSym].n_sect - 1) < pThis->cSections, VERR_LDRMACHO_BAD_SYMBOL);
+                pSect = &pThis->paSections[paSyms[iSym].n_sect - 1];
 
                 uValue = paSyms[iSym].n_value - pSect->LinkAddress;
@@ -2124,12 +2075,12 @@
                                           || (   paSyms[iSym].n_sect == 1 /* special hack for __mh_execute_header */
                                               && uValue == 0U - pSect->RVA
-                                              && pModMachO->uEffFileType != MH_OBJECT),
-                                          KLDR_ERR_MACHO_BAD_SYMBOL);
+                                              && pThis->uEffFileType != MH_OBJECT),
+                                          VERR_LDRMACHO_BAD_SYMBOL);
                 uValue += BaseAddress + pSect->RVA;
 
                 if (pSect->fFlags & (S_ATTR_PURE_INSTRUCTIONS | S_ATTR_SELF_MODIFYING_CODE))
-                    fKind |= KLDRSYMKIND_CODE;
+                    fKind |= RTLDRSYMKIND_CODE;
                 else
-                    fKind |= KLDRSYMKIND_NO_TYPE;
+                    fKind |= RTLDRSYMKIND_NO_TYPE;
                 break;
             }
@@ -2137,5 +2088,5 @@
             case MACHO_N_ABS:
                 uValue = paSyms[iSym].n_value;
-                fKind |= KLDRSYMKIND_NO_TYPE /*KLDRSYMKIND_ABS*/;
+                fKind |= RTLDRSYMKIND_NO_TYPE /*RTLDRSYMKIND_ABS*/;
                 break;
 
@@ -2144,5 +2095,5 @@
                 /** @todo implement indirect and prebound symbols. */
             default:
-                KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_TODO);
+                KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_TODO);
         }
 
@@ -2150,5 +2101,5 @@
          * Do callback.
          */
-        rc = pfnCallback(pModMachO->pMod, iSym, psz, cch, NULL, uValue, fKind, pvUser);
+        rc = pfnCallback(&pThis->Core, psz, iSym, uValue/*, fKind*/, pvUser);
         if (rc)
             return rc;
@@ -2162,5 +2113,5 @@
  *
  * @returns See kLdrModQuerySymbol.
- * @param   pModMachO
+ * @param   pThis
  * @param   paSyms      Pointer to the symbol table.
  * @param   cSyms       Number of symbols in the table.
@@ -2172,12 +2123,12 @@
  * @param   pvUser      See kLdrModEnumSymbols.
  */
-static int kldrModMachODoEnumSymbols64Bit(PKLDRMODMACHO pModMachO, const macho_nlist_64_t *paSyms, KU32 cSyms,
-                                          const char *pchStrings, KU32 cchStrings, KLDRADDR BaseAddress,
-                                          KU32 fFlags, PFNKLDRMODENUMSYMS pfnCallback, void *pvUser)
-{
-    const KU32 fKindBase =    pModMachO->Hdr.magic == IMAGE_MACHO64_SIGNATURE
-                           || pModMachO->Hdr.magic == IMAGE_MACHO64_SIGNATURE_OE
-                         ? KLDRSYMKIND_64BIT : KLDRSYMKIND_32BIT;
-    KU32 iSym;
+static int kldrModMachODoEnumSymbols64Bit(PKLDRMODMACHO pThis, const macho_nlist_64_t *paSyms, uint32_t cSyms,
+                                          const char *pchStrings, uint32_t cchStrings, RTLDRADDR BaseAddress,
+                                          uint32_t fFlags, PFNRTLDRENUMSYMS pfnCallback, void *pvUser)
+{
+    const uint32_t fKindBase =    pThis->Hdr.magic == IMAGE_MACHO64_SIGNATURE
+                           || pThis->Hdr.magic == IMAGE_MACHO64_SIGNATURE_OE
+                         ? RTLDRSYMKIND_64BIT : RTLDRSYMKIND_32BIT;
+    uint32_t iSym;
     int rc;
 
@@ -2187,8 +2138,8 @@
     for (iSym = 0; iSym < cSyms; iSym++)
     {
-        KU32 fKind;
-        KLDRADDR uValue;
+        uint32_t fKind;
+        RTLDRADDR uValue;
         const char *psz;
-        KSIZE cch;
+        size_t cch;
 
         /* Skip debug symbols and undefined symbols. */
@@ -2199,5 +2150,5 @@
 
         /* Skip non-public symbols unless they are requested explicitly. */
-        if (!(fFlags & KLDRMOD_ENUM_SYMS_FLAGS_ALL))
+        if (!(fFlags & RTLDR_ENUM_SYMBOL_FLAGS_ALL))
         {
             if (!(paSyms[iSym].n_type & MACHO_N_EXT)) /*??*/
@@ -2214,7 +2165,7 @@
 
         /* name */
-        KLDRMODMACHO_CHECK_RETURN((KU32)paSyms[iSym].n_un.n_strx < cchStrings, KLDR_ERR_MACHO_BAD_SYMBOL);
+        KLDRMODMACHO_CHECK_RETURN((uint32_t)paSyms[iSym].n_un.n_strx < cchStrings, VERR_LDRMACHO_BAD_SYMBOL);
         psz = &pchStrings[paSyms[iSym].n_un.n_strx];
-        cch = kHlpStrLen(psz);
+        cch = strlen(psz);
         if (!cch)
             psz = NULL;
@@ -2223,5 +2174,5 @@
         fKind = fKindBase;
         if (paSyms[iSym].n_desc & N_WEAK_DEF)
-            fKind |= KLDRSYMKIND_WEAK;
+            fKind |= RTLDRSYMKIND_WEAK;
         switch (paSyms[iSym].n_type & MACHO_N_TYPE)
         {
@@ -2229,6 +2180,6 @@
             {
                 PKLDRMODMACHOSECT pSect;
-                KLDRMODMACHO_CHECK_RETURN((KU32)(paSyms[iSym].n_sect - 1) < pModMachO->cSections, KLDR_ERR_MACHO_BAD_SYMBOL);
-                pSect = &pModMachO->paSections[paSyms[iSym].n_sect - 1];
+                KLDRMODMACHO_CHECK_RETURN((uint32_t)(paSyms[iSym].n_sect - 1) < pThis->cSections, VERR_LDRMACHO_BAD_SYMBOL);
+                pSect = &pThis->paSections[paSyms[iSym].n_sect - 1];
 
                 uValue = paSyms[iSym].n_value - pSect->LinkAddress;
@@ -2236,12 +2187,12 @@
                                           || (   paSyms[iSym].n_sect == 1 /* special hack for __mh_execute_header */
                                               && uValue == 0U - pSect->RVA
-                                              && pModMachO->uEffFileType != MH_OBJECT),
-                                          KLDR_ERR_MACHO_BAD_SYMBOL);
+                                              && pThis->uEffFileType != MH_OBJECT),
+                                          VERR_LDRMACHO_BAD_SYMBOL);
                 uValue += BaseAddress + pSect->RVA;
 
                 if (pSect->fFlags & (S_ATTR_PURE_INSTRUCTIONS | S_ATTR_SELF_MODIFYING_CODE))
-                    fKind |= KLDRSYMKIND_CODE;
+                    fKind |= RTLDRSYMKIND_CODE;
                 else
-                    fKind |= KLDRSYMKIND_NO_TYPE;
+                    fKind |= RTLDRSYMKIND_NO_TYPE;
                 break;
             }
@@ -2249,5 +2200,5 @@
             case MACHO_N_ABS:
                 uValue = paSyms[iSym].n_value;
-                fKind |= KLDRSYMKIND_NO_TYPE /*KLDRSYMKIND_ABS*/;
+                fKind |= RTLDRSYMKIND_NO_TYPE /*RTLDRSYMKIND_ABS*/;
                 break;
 
@@ -2256,5 +2207,5 @@
                 /** @todo implement indirect and prebound symbols. */
             default:
-                KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_TODO);
+                KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_TODO);
         }
 
@@ -2262,5 +2213,5 @@
          * Do callback.
          */
-        rc = pfnCallback(pModMachO->pMod, iSym, psz, cch, NULL, uValue, fKind, pvUser);
+        rc = pfnCallback(&pThis->Core, psz, iSym, uValue/*, fKind*/, pvUser);
         if (rc)
             return rc;
@@ -2269,15 +2220,16 @@
 }
 
+#if 0
 
 /** @copydoc kLdrModGetImport */
-static int kldrModMachOGetImport(PKLDRMOD pMod, const void *pvBits, KU32 iImport, char *pszName, KSIZE cchName)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
-    K_NOREF(pvBits);
-    K_NOREF(iImport);
-    K_NOREF(pszName);
-    K_NOREF(cchName);
-
-    if (pModMachO->Hdr.filetype == MH_OBJECT)
+static int kldrModMachOGetImport(PRTLDRMODINTERNAL pMod, const void *pvBits, uint32_t iImport, char *pszName, size_t cchName)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+    RT_NOREF(pvBits);
+    RT_NOREF(iImport);
+    RT_NOREF(pszName);
+    RT_NOREF(cchName);
+
+    if (pThis->Hdr.filetype == MH_OBJECT)
         return KLDR_ERR_IMPORT_ORDINAL_OUT_OF_BOUNDS;
 
@@ -2287,11 +2239,12 @@
 
 
+
 /** @copydoc kLdrModNumberOfImports */
-static KI32 kldrModMachONumberOfImports(PKLDRMOD pMod, const void *pvBits)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
-    K_NOREF(pvBits);
-
-    if (pModMachO->Hdr.filetype == MH_OBJECT)
+static int32_t kldrModMachONumberOfImports(PRTLDRMODINTERNAL pMod, const void *pvBits)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+    RT_NOREF(pvBits);
+
+    if (pThis->Hdr.filetype == MH_OBJECT)
         return 0;
 
@@ -2302,13 +2255,13 @@
 
 /** @copydoc kLdrModGetStackInfo */
-static int kldrModMachOGetStackInfo(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo)
-{
-    /*PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;*/
-    K_NOREF(pMod);
-    K_NOREF(pvBits);
-    K_NOREF(BaseAddress);
-
-    pStackInfo->Address = NIL_KLDRADDR;
-    pStackInfo->LinkAddress = NIL_KLDRADDR;
+static int kldrModMachOGetStackInfo(PRTLDRMODINTERNAL pMod, const void *pvBits, RTLDRADDR BaseAddress, PKLDRSTACKINFO pStackInfo)
+{
+    /*PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);*/
+    RT_NOREF(pMod);
+    RT_NOREF(pvBits);
+    RT_NOREF(BaseAddress);
+
+    pStackInfo->Address = NIL_RTLDRADDR;
+    pStackInfo->LinkAddress = NIL_RTLDRADDR;
     pStackInfo->cbStack = pStackInfo->cbStackThread = 0;
     /* later */
@@ -2317,10 +2270,12 @@
 }
 
+#endif
+
 
 /** @copydoc kLdrModQueryMainEntrypoint */
-static int kldrModMachOQueryMainEntrypoint(PKLDRMOD pMod, const void *pvBits, KLDRADDR BaseAddress, PKLDRADDR pMainEPAddress)
+static int kldrModMachOQueryMainEntrypoint(PRTLDRMODINTERNAL pMod, const void *pvBits, RTLDRADDR BaseAddress, PRTLDRADDR pMainEPAddress)
 {
 #if 0
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
     int rc;
 
@@ -2328,5 +2283,5 @@
      * Resolve base address alias if any.
      */
-    rc = kldrModMachOBitsAndBaseAddress(pModMachO, NULL, &BaseAddress);
+    rc = kldrModMachOBitsAndBaseAddress(pThis, NULL, &BaseAddress);
     if (rc)
         return rc;
@@ -2335,12 +2290,12 @@
      * Convert the address from the header.
      */
-    *pMainEPAddress = pModMachO->Hdrs.OptionalHeader.AddressOfEntryPoint
-        ? BaseAddress + pModMachO->Hdrs.OptionalHeader.AddressOfEntryPoint
-        : NIL_KLDRADDR;
+    *pMainEPAddress = pThis->Hdrs.OptionalHeader.AddressOfEntryPoint
+        ? BaseAddress + pThis->Hdrs.OptionalHeader.AddressOfEntryPoint
+        : NIL_RTLDRADDR;
 #else
-    *pMainEPAddress = NIL_KLDRADDR;
-    K_NOREF(pvBits);
-    K_NOREF(BaseAddress);
-    K_NOREF(pMod);
+    *pMainEPAddress = NIL_RTLDRADDR;
+    RT_NOREF(pvBits);
+    RT_NOREF(BaseAddress);
+    RT_NOREF(pMod);
 #endif
     return 0;
@@ -2349,43 +2304,48 @@
 
 /** @copydoc kLdrModQueryImageUuid */
-static int kldrModMachOQueryImageUuid(PKLDRMOD pMod, const void *pvBits, void *pvUuid, KSIZE cbUuid)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
-    K_NOREF(pvBits);
-
-    kHlpMemSet(pvUuid, 0, cbUuid);
-    if (kHlpMemComp(pvUuid, pModMachO->abImageUuid, sizeof(pModMachO->abImageUuid)) == 0)
-        return KLDR_ERR_NO_IMAGE_UUID;
-
-    kHlpMemCopy(pvUuid, pModMachO->abImageUuid, sizeof(pModMachO->abImageUuid));
-    return 0;
-}
-
-
-/** @copydoc kLdrModEnumDbgInfo */
-static int kldrModMachOEnumDbgInfo(PKLDRMOD pMod, const void *pvBits, PFNKLDRENUMDBG pfnCallback, void *pvUser)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
-    int rc = 0;
-    KU32 iSect;
-    K_NOREF(pvBits);
-
-    for (iSect = 0; iSect < pModMachO->cSections; iSect++)
-    {
-        section_32_t *pMachOSect = pModMachO->paSections[iSect].pvMachoSection; /* (32-bit & 64-bit starts the same way) */
+static int kldrModMachOQueryImageUuid(PKLDRMODMACHO pThis, const void *pvBits, void *pvUuid, size_t cbUuid)
+{
+    RT_NOREF(pvBits);
+
+    memset(pvUuid, 0, cbUuid);
+    if (memcmp(pvUuid, pThis->abImageUuid, sizeof(pThis->abImageUuid)) == 0)
+        return VERR_NOT_FOUND;
+
+    memcpy(pvUuid, pThis->abImageUuid, sizeof(pThis->abImageUuid));
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnEnumDbgInfo}
+ */
+static DECLCALLBACK(int) rtldrMachO_EnumDbgInfo(PRTLDRMODINTERNAL pMod, const void *pvBits, PFNRTLDRENUMDBG pfnCallback, void *pvUser)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+    int rc = VINF_SUCCESS;
+    uint32_t iSect;
+    RT_NOREF(pvBits);
+
+    for (iSect = 0; iSect < pThis->cSections; iSect++)
+    {
+        /* (32-bit & 64-bit starts the same way) */
+        section_32_t *pMachOSect = (section_32_t *)pThis->paSections[iSect].pvMachoSection;
         char          szTmp[sizeof(pMachOSect->sectname) + 1];
 
-        if (kHlpStrComp(pMachOSect->segname, "__DWARF"))
+        if (strcmp(pMachOSect->segname, "__DWARF"))
             continue;
 
-        kHlpMemCopy(szTmp, pMachOSect->sectname, sizeof(pMachOSect->sectname));
+        memcpy(szTmp, pMachOSect->sectname, sizeof(pMachOSect->sectname));
         szTmp[sizeof(pMachOSect->sectname)] = '\0';
 
-        rc = pfnCallback(pMod, iSect, KLDRDBGINFOTYPE_DWARF, 0, 0, szTmp,
-                         pModMachO->paSections[iSect].offFile,
-                         pModMachO->paSections[iSect].LinkAddress,
-                         pModMachO->paSections[iSect].cb,
-                         NULL, pvUser);
-        if (rc != 0)
+        RTLDRDBGINFO DbgInfo;
+        DbgInfo.enmType            = RTLDRDBGINFOTYPE_DWARF;
+        DbgInfo.iDbgInfo           = iSect;
+        DbgInfo.LinkAddress        = pThis->paSections[iSect].LinkAddress;
+        DbgInfo.cb                 = pThis->paSections[iSect].cb;
+        DbgInfo.pszExtFile         = NULL;
+        DbgInfo.u.Dwarf.pszSection = szTmp;
+        rc = pfnCallback(&pThis->Core, &DbgInfo, pvUser);
+        if (rc != VINF_SUCCESS)
             break;
     }
@@ -2394,9 +2354,10 @@
 }
 
+#if 0
 
 /** @copydoc kLdrModHasDbgInfo */
-static int kldrModMachOHasDbgInfo(PKLDRMOD pMod, const void *pvBits)
-{
-    /*PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;*/
+static int kldrModMachOHasDbgInfo(PRTLDRMODINTERNAL pMod, const void *pvBits)
+{
+    /*PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);*/
 
 #if 0
@@ -2404,13 +2365,13 @@
      * Base this entirely on the presence of a debug directory.
      */
-    if (    pModMachO->Hdrs.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].Size
+    if (    pThis->Hdrs.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].Size
             < sizeof(IMAGE_DEBUG_DIRECTORY) /* screw borland linkers */
-        ||  !pModMachO->Hdrs.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress)
+        ||  !pThis->Hdrs.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress)
         return KLDR_ERR_NO_DEBUG_INFO;
     return 0;
 #else
-    K_NOREF(pMod);
-    K_NOREF(pvBits);
-    return KLDR_ERR_NO_DEBUG_INFO;
+    RT_NOREF(pMod);
+    RT_NOREF(pvBits);
+    return VERR_LDR_NO_DEBUG_INFO;
 #endif
 }
@@ -2418,19 +2379,19 @@
 
 /** @copydoc kLdrModMap */
-static int kldrModMachOMap(PKLDRMOD pMod)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
+static int kldrModMachOMap(PRTLDRMODINTERNAL pMod)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
     unsigned fFixed;
-    KU32 i;
+    uint32_t i;
     void *pvBase;
     int rc;
 
-    if (!pModMachO->fCanLoad)
-        return KLDR_ERR_TODO;
+    if (!pThis->fCanLoad)
+        return VERR_LDRMACHO_TODO;
 
     /*
      * Already mapped?
      */
-    if (pModMachO->pvMapping)
+    if (pThis->pvMapping)
         return KLDR_ERR_ALREADY_MAPPED;
 
@@ -2445,7 +2406,7 @@
     else
     {
-        pvBase = (void *)(KUPTR)pMod->aSegments[0].LinkAddress;
-        if ((KUPTR)pvBase != pMod->aSegments[0].LinkAddress)
-            return KLDR_ERR_ADDRESS_OVERFLOW;
+        pvBase = (void *)(uintptr_t)pMod->aSegments[0].LinkAddress;
+        if ((uintptr_t)pvBase != pMod->aSegments[0].LinkAddress)
+            return VERR_LDR_ADDRESS_OVERFLOW;
     }
 
@@ -2460,8 +2421,8 @@
     for (i = 0; i < pMod->cSegments; i++)
     {
-        if (pMod->aSegments[i].RVA != NIL_KLDRADDR)
-            pMod->aSegments[i].MapAddress = (KUPTR)pvBase + (KUPTR)pMod->aSegments[i].RVA;
-    }
-    pModMachO->pvMapping = pvBase;
+        if (pMod->aSegments[i].RVA != NIL_RTLDRADDR)
+            pMod->aSegments[i].MapAddress = (uintptr_t)pvBase + (uintptr_t)pMod->aSegments[i].RVA;
+    }
+    pThis->pvMapping = pvBase;
 
     return 0;
@@ -2470,8 +2431,8 @@
 
 /** @copydoc kLdrModUnmap */
-static int kldrModMachOUnmap(PKLDRMOD pMod)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
-    KU32 i;
+static int kldrModMachOUnmap(PRTLDRMODINTERNAL pMod)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+    uint32_t i;
     int rc;
 
@@ -2479,5 +2440,5 @@
      * Mapped?
      */
-    if (!pModMachO->pvMapping)
+    if (!pThis->pvMapping)
         return KLDR_ERR_NOT_MAPPED;
 
@@ -2485,5 +2446,5 @@
      * Try unmap the image.
      */
-    rc = kRdrUnmap(pMod->pRdr, pModMachO->pvMapping, pMod->cSegments, pMod->aSegments);
+    rc = kRdrUnmap(pMod->pRdr, pThis->pvMapping, pMod->cSegments, pMod->aSegments);
     if (rc)
         return rc;
@@ -2492,5 +2453,5 @@
      * Update the segments to reflect that they aren't mapped any longer.
      */
-    pModMachO->pvMapping = NULL;
+    pThis->pvMapping = NULL;
     for (i = 0; i < pMod->cSegments; i++)
         pMod->aSegments[i].MapAddress = 0;
@@ -2501,7 +2462,7 @@
 
 /** @copydoc kLdrModAllocTLS */
-static int kldrModMachOAllocTLS(PKLDRMOD pMod, void *pvMapping)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
+static int kldrModMachOAllocTLS(PRTLDRMODINTERNAL pMod, void *pvMapping)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
 
     /*
@@ -2509,5 +2470,5 @@
      */
     if (   pvMapping == KLDRMOD_INT_MAP
-        && !pModMachO->pvMapping )
+        && !pThis->pvMapping )
         return KLDR_ERR_NOT_MAPPED;
     return 0;
@@ -2516,31 +2477,32 @@
 
 /** @copydoc kLdrModFreeTLS */
-static void kldrModMachOFreeTLS(PKLDRMOD pMod, void *pvMapping)
-{
-    K_NOREF(pMod);
-    K_NOREF(pvMapping);
-}
+static void kldrModMachOFreeTLS(PRTLDRMODINTERNAL pMod, void *pvMapping)
+{
+    RT_NOREF(pMod);
+    RT_NOREF(pvMapping);
+}
+
 
 
 /** @copydoc kLdrModReload */
-static int kldrModMachOReload(PKLDRMOD pMod)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
+static int kldrModMachOReload(PRTLDRMODINTERNAL pMod)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
 
     /*
      * Mapped?
      */
-    if (!pModMachO->pvMapping)
+    if (!pThis->pvMapping)
         return KLDR_ERR_NOT_MAPPED;
 
     /* the file provider does it all */
-    return kRdrRefresh(pMod->pRdr, pModMachO->pvMapping, pMod->cSegments, pMod->aSegments);
+    return kRdrRefresh(pMod->pRdr, pThis->pvMapping, pMod->cSegments, pMod->aSegments);
 }
 
 
 /** @copydoc kLdrModFixupMapping */
-static int kldrModMachOFixupMapping(PKLDRMOD pMod, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
+static int kldrModMachOFixupMapping(PRTLDRMODINTERNAL pMod, PFNRTLDRIMPORT pfnGetImport, void *pvUser)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
     int rc, rc2;
 
@@ -2548,5 +2510,5 @@
      * Mapped?
      */
-    if (!pModMachO->pvMapping)
+    if (!pThis->pvMapping)
         return KLDR_ERR_NOT_MAPPED;
 
@@ -2554,5 +2516,5 @@
      * Before doing anything we'll have to make all pages writable.
      */
-    rc = kRdrProtect(pMod->pRdr, pModMachO->pvMapping, pMod->cSegments, pMod->aSegments, 1 /* unprotect */);
+    rc = kRdrProtect(pMod->pRdr, pThis->pvMapping, pMod->cSegments, pMod->aSegments, 1 /* unprotect */);
     if (rc)
         return rc;
@@ -2561,11 +2523,11 @@
      * Resolve imports and apply base relocations.
      */
-    rc = kldrModMachORelocateBits(pMod, pModMachO->pvMapping, (KUPTR)pModMachO->pvMapping, pModMachO->LinkAddress,
-                                  pfnGetImport, pvUser);
+    rc = rtldrMachO_RelocateBits(pMod, pThis->pvMapping, (uintptr_t)pThis->pvMapping, pThis->LinkAddress,
+                                      pfnGetImport, pvUser);
 
     /*
      * Restore protection.
      */
-    rc2 = kRdrProtect(pMod->pRdr, pModMachO->pvMapping, pMod->cSegments, pMod->aSegments, 0 /* protect */);
+    rc2 = kRdrProtect(pMod->pRdr, pThis->pvMapping, pMod->cSegments, pMod->aSegments, 0 /* protect */);
     if (!rc && rc2)
         rc = rc2;
@@ -2573,4 +2535,5 @@
 }
 
+#endif
 
 /**
@@ -2578,12 +2541,12 @@
  *
  * @returns 0 on success, non-zero kLdr status code on failure.
- * @param   pModMachO       The Mach-O module interpreter instance.
+ * @param   pThis       The Mach-O module interpreter instance.
  * @param   pfnGetImport    The callback for resolving an imported symbol.
  * @param   pvUser          User argument to the callback.
  */
-static int  kldrModMachOObjDoImports(PKLDRMODMACHO pModMachO, KLDRADDR BaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser)
-{
-    const KU32 cSyms = pModMachO->cSymbols;
-    KU32 iSym;
+static int  kldrModMachOObjDoImports(PKLDRMODMACHO pThis, RTLDRADDR BaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser)
+{
+    const uint32_t cSyms = pThis->cSymbols;
+    uint32_t iSym;
     int rc;
 
@@ -2591,5 +2554,5 @@
      * Ensure that we've got the symbol table and section fixups handy.
      */
-    rc = kldrModMachOLoadObjSymTab(pModMachO);
+    rc = kldrModMachOLoadObjSymTab(pThis);
     if (rc)
         return rc;
@@ -2599,8 +2562,8 @@
      * We currently ignore REFERENCE_TYPE.
      */
-    if (    pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE
-        ||  pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
-    {
-        macho_nlist_32_t *paSyms = (macho_nlist_32_t *)pModMachO->pvaSymbols;
+    if (    pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE
+        ||  pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
+    {
+        macho_nlist_32_t *paSyms = (macho_nlist_32_t *)pThis->pvaSymbols;
         for (iSym = 0; iSym < cSyms; iSym++)
         {
@@ -2612,28 +2575,27 @@
             {
                 const char *pszSymbol;
-                KSIZE cchSymbol;
-                KU32 fKind = KLDRSYMKIND_REQ_FLAT;
-                KLDRADDR Value = NIL_KLDRADDR;
+                size_t cchSymbol;
+                //uint32_t fKind = RTLDRSYMKIND_REQ_FLAT;
+                RTLDRADDR Value = NIL_RTLDRADDR;
 
                 /** @todo Implement N_REF_TO_WEAK. */
-                KLDRMODMACHO_CHECK_RETURN(!(paSyms[iSym].n_desc & N_REF_TO_WEAK), KLDR_ERR_TODO);
+                KLDRMODMACHO_CHECK_RETURN(!(paSyms[iSym].n_desc & N_REF_TO_WEAK), VERR_LDRMACHO_TODO);
 
                 /* Get the symbol name. */
-                KLDRMODMACHO_CHECK_RETURN((KU32)paSyms[iSym].n_un.n_strx < pModMachO->cchStrings, KLDR_ERR_MACHO_BAD_SYMBOL);
-                pszSymbol = &pModMachO->pchStrings[paSyms[iSym].n_un.n_strx];
-                cchSymbol = kHlpStrLen(pszSymbol);
+                KLDRMODMACHO_CHECK_RETURN((uint32_t)paSyms[iSym].n_un.n_strx < pThis->cchStrings, VERR_LDRMACHO_BAD_SYMBOL);
+                pszSymbol = &pThis->pchStrings[paSyms[iSym].n_un.n_strx];
+                cchSymbol = strlen(pszSymbol);
 
                 /* Check for linker defined symbols relating to sections and segments. */
                 if (   cchSymbol > sizeof("section$end$") - 1
                     && *pszSymbol == 's'
-                    && kHlpMemChr(pszSymbol, '$', cchSymbol))
-                    rc = kldrModMachOQueryLinkerSymbol(pModMachO, pModMachO->pMod, pszSymbol, cchSymbol, BaseAddress, &Value);
+                    && memchr(pszSymbol, '$', cchSymbol))
+                    rc = kldrModMachOQueryLinkerSymbol(pThis, pszSymbol, cchSymbol, BaseAddress, &Value);
                 else
-                    rc = KLDR_ERR_SYMBOL_NOT_FOUND;
+                    rc = VERR_SYMBOL_NOT_FOUND;
 
                 /* Ask the user for an address to the symbol. */
                 if (rc)
-                    rc = pfnGetImport(pModMachO->pMod, NIL_KLDRMOD_IMPORT, iSym, pszSymbol, cchSymbol, NULL,
-                                      &Value, &fKind, pvUser);
+                    rc = pfnGetImport(&pThis->Core, NULL /*pszModule*/, pszSymbol, iSym, &Value/*, &fKind*/, pvUser);
                 if (rc)
                 {
@@ -2645,8 +2607,8 @@
 
                 /* Update the symbol. */
-                paSyms[iSym].n_value = (KU32)Value;
+                paSyms[iSym].n_value = (uint32_t)Value;
                 if (paSyms[iSym].n_value != Value)
                 {
-                    rc = KLDR_ERR_ADDRESS_OVERFLOW;
+                    rc = VERR_LDR_ADDRESS_OVERFLOW;
                     break;
                 }
@@ -2655,5 +2617,5 @@
             {
                 /** @todo implement weak symbols. */
-                /*return KLDR_ERR_TODO; - ignored for now. */
+                /*return VERR_LDRMACHO_TODO; - ignored for now. */
             }
         }
@@ -2662,5 +2624,5 @@
     {
         /* (Identical to the 32-bit code, just different paSym type. (and n_strx is unsigned)) */
-        macho_nlist_64_t *paSyms = (macho_nlist_64_t *)pModMachO->pvaSymbols;
+        macho_nlist_64_t *paSyms = (macho_nlist_64_t *)pThis->pvaSymbols;
         for (iSym = 0; iSym < cSyms; iSym++)
         {
@@ -2672,28 +2634,27 @@
             {
                 const char *pszSymbol;
-                KSIZE cchSymbol;
-                KU32 fKind = KLDRSYMKIND_REQ_FLAT;
-                KLDRADDR Value = NIL_KLDRADDR;
+                size_t cchSymbol;
+                //uint32_t fKind = RTLDRSYMKIND_REQ_FLAT;
+                RTLDRADDR Value = NIL_RTLDRADDR;
 
                 /** @todo Implement N_REF_TO_WEAK. */
-                KLDRMODMACHO_CHECK_RETURN(!(paSyms[iSym].n_desc & N_REF_TO_WEAK), KLDR_ERR_TODO);
+                KLDRMODMACHO_CHECK_RETURN(!(paSyms[iSym].n_desc & N_REF_TO_WEAK), VERR_LDRMACHO_TODO);
 
                  /* Get the symbol name. */
-                KLDRMODMACHO_CHECK_RETURN(paSyms[iSym].n_un.n_strx < pModMachO->cchStrings, KLDR_ERR_MACHO_BAD_SYMBOL);
-                pszSymbol = &pModMachO->pchStrings[paSyms[iSym].n_un.n_strx];
-                cchSymbol = kHlpStrLen(pszSymbol);
+                KLDRMODMACHO_CHECK_RETURN(paSyms[iSym].n_un.n_strx < pThis->cchStrings, VERR_LDRMACHO_BAD_SYMBOL);
+                pszSymbol = &pThis->pchStrings[paSyms[iSym].n_un.n_strx];
+                cchSymbol = strlen(pszSymbol);
 
                 /* Check for linker defined symbols relating to sections and segments. */
                 if (   cchSymbol > sizeof("section$end$") - 1
                     && *pszSymbol == 's'
-                    && kHlpMemChr(pszSymbol, '$', cchSymbol))
-                    rc = kldrModMachOQueryLinkerSymbol(pModMachO, pModMachO->pMod, pszSymbol, cchSymbol, BaseAddress, &Value);
+                    && memchr(pszSymbol, '$', cchSymbol))
+                    rc = kldrModMachOQueryLinkerSymbol(pThis, pszSymbol, cchSymbol, BaseAddress, &Value);
                 else
-                    rc = KLDR_ERR_SYMBOL_NOT_FOUND;
+                    rc = VERR_SYMBOL_NOT_FOUND;
 
                 /* Ask the user for an address to the symbol. */
                 if (rc)
-                    rc = pfnGetImport(pModMachO->pMod, NIL_KLDRMOD_IMPORT, iSym, pszSymbol, cchSymbol, NULL,
-                                      &Value, &fKind, pvUser);
+                    rc = pfnGetImport(&pThis->Core, NULL, pszSymbol, iSym, &Value, /*&fKind,*/ pvUser);
                 if (rc)
                 {
@@ -2708,5 +2669,5 @@
                 if (paSyms[iSym].n_value != Value)
                 {
-                    rc = KLDR_ERR_ADDRESS_OVERFLOW;
+                    rc = VERR_LDR_ADDRESS_OVERFLOW;
                     break;
                 }
@@ -2715,5 +2676,5 @@
             {
                 /** @todo implement weak symbols. */
-                /*return KLDR_ERR_TODO; - ignored for now. */
+                /*return VERR_LDRMACHO_TODO; - ignored for now. */
             }
         }
@@ -2728,12 +2689,12 @@
  *
  * @returns 0 on success, non-zero kLdr status code on failure.
- * @param   pModMachO       The Mach-O module interpreter instance.
+ * @param   pThis       The Mach-O module interpreter instance.
  * @param   pvMapping       The mapping to fixup.
  * @param   NewBaseAddress  The address to fixup the mapping to.
  * @param   OldBaseAddress  The address the mapping is currently fixed up to.
  */
-static int  kldrModMachOObjDoFixups(PKLDRMODMACHO pModMachO, void *pvMapping, KLDRADDR NewBaseAddress)
-{
-    KU32 iSeg;
+static int  kldrModMachOObjDoFixups(PKLDRMODMACHO pThis, void *pvMapping, RTLDRADDR NewBaseAddress)
+{
+    uint32_t iSeg;
     int rc;
 
@@ -2742,5 +2703,5 @@
      * Ensure that we've got the symbol table and section fixups handy.
      */
-    rc = kldrModMachOLoadObjSymTab(pModMachO);
+    rc = kldrModMachOLoadObjSymTab(pThis);
     if (rc)
         return rc;
@@ -2749,13 +2710,13 @@
      * Iterate over the segments and their sections and apply fixups.
      */
-    for (iSeg = rc = 0; !rc && iSeg < pModMachO->pMod->cSegments; iSeg++)
-    {
-        PKLDRMODMACHOSEG pSeg = &pModMachO->aSegments[iSeg];
-        KU32 iSect;
+    for (iSeg = rc = 0; !rc && iSeg < pThis->cSegments; iSeg++)
+    {
+        PKLDRMODMACHOSEG pSeg = &pThis->aSegments[iSeg];
+        uint32_t iSect;
 
         for (iSect = 0; iSect < pSeg->cSections; iSect++)
         {
             PKLDRMODMACHOSECT pSect = &pSeg->paSections[iSect];
-            KU8 *pbSectBits;
+            uint8_t *pbSectBits;
 
             /* skip sections without fixups. */
@@ -2766,5 +2727,5 @@
             if (!pSect->paFixups)
             {
-                rc = kldrModMachOLoadFixups(pModMachO, pSect->offFixups, pSect->cFixups, &pSect->paFixups);
+                rc = kldrModMachOLoadFixups(pThis, pSect->offFixups, pSect->cFixups, &pSect->paFixups);
                 if (rc)
                     break;
@@ -2774,16 +2735,16 @@
              * Apply the fixups.
              */
-            pbSectBits = (KU8 *)pvMapping + (KUPTR)pSect->RVA;
-            if (pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE) /** @todo this aint right. */
-                rc = kldrModMachOFixupSectionGeneric32Bit(pModMachO, pbSectBits, pSect,
-                                                          (macho_nlist_32_t *)pModMachO->pvaSymbols,
-                                                          pModMachO->cSymbols, NewBaseAddress);
-            else if (   pModMachO->Hdr.magic == IMAGE_MACHO64_SIGNATURE
-                     && pModMachO->Hdr.cputype == CPU_TYPE_X86_64)
-                rc = kldrModMachOFixupSectionAMD64(pModMachO, pbSectBits, pSect,
-                                                   (macho_nlist_64_t *)pModMachO->pvaSymbols,
-                                                   pModMachO->cSymbols, NewBaseAddress);
+            pbSectBits = (uint8_t *)pvMapping + (uintptr_t)pSect->RVA;
+            if (pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE) /** @todo this aint right. */
+                rc = kldrModMachOFixupSectionGeneric32Bit(pThis, pbSectBits, pSect,
+                                                          (macho_nlist_32_t *)pThis->pvaSymbols,
+                                                          pThis->cSymbols, NewBaseAddress);
+            else if (   pThis->Hdr.magic == IMAGE_MACHO64_SIGNATURE
+                     && pThis->Hdr.cputype == CPU_TYPE_X86_64)
+                rc = kldrModMachOFixupSectionAMD64(pThis, pbSectBits, pSect,
+                                                   (macho_nlist_64_t *)pThis->pvaSymbols,
+                                                   pThis->cSymbols, NewBaseAddress);
             else
-                KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_TODO);
+                KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_TODO);
             if (rc)
                 break;
@@ -2800,20 +2761,18 @@
  *
  * @returns 0 on success, non-zero kLdr status code on failure.
- * @param   pModMachO       The Mach-O module interpreter instance.
+ * @param   pThis       The Mach-O module interpreter instance.
  * @param   pbSectBits      Pointer to the section bits.
  * @param   pFixupSect      The section being fixed up.
  * @param   NewBaseAddress  The new base image address.
  */
-static int  kldrModMachOFixupSectionGeneric32Bit(PKLDRMODMACHO pModMachO, KU8 *pbSectBits, PKLDRMODMACHOSECT pFixupSect,
-                                                 macho_nlist_32_t *paSyms, KU32 cSyms, KLDRADDR NewBaseAddress)
+static int  kldrModMachOFixupSectionGeneric32Bit(PKLDRMODMACHO pThis, uint8_t *pbSectBits, PKLDRMODMACHOSECT pFixupSect,
+                                                 macho_nlist_32_t *paSyms, uint32_t cSyms, RTLDRADDR NewBaseAddress)
 {
     const macho_relocation_info_t *paFixups = pFixupSect->paFixups;
-    const KU32 cFixups = pFixupSect->cFixups;
-    KSIZE cbSectBits = (KSIZE)pFixupSect->cb;
-    const KU8 *pbSectVirginBits;
-    KU32 iFixup;
-    KLDRPU uFixVirgin;
-    KLDRPU uFix;
-    KLDRADDR SymAddr = ~(KLDRADDR)0;
+    const uint32_t cFixups = pFixupSect->cFixups;
+    size_t cbSectBits = (size_t)pFixupSect->cb;
+    const uint8_t *pbSectVirginBits;
+    uint32_t iFixup;
+    RTLDRADDR SymAddr = ~(RTLDRADDR)0;
     int rc;
 
@@ -2823,8 +2782,8 @@
     if (pFixupSect->offFile != -1)
     {
-        rc = kldrModMachOMapVirginBits(pModMachO);
+        rc = kldrModMachOMapVirginBits(pThis);
         if (rc)
             return rc;
-        pbSectVirginBits = (const KU8 *)pModMachO->pvBits + pFixupSect->offFile;
+        pbSectVirginBits = (const uint8_t *)pThis->pvBits + pFixupSect->offFile;
     }
     else
@@ -2836,4 +2795,6 @@
     for (iFixup = 0; iFixup < cFixups; iFixup++)
     {
+        RTPTRUNION uFix;
+        RTPTRUNION uFixVirgin;
         union
         {
@@ -2846,10 +2807,10 @@
         {
             /* sanity */
-            if ((KU32)Fixup.r.r_address >= cbSectBits)
-                return KLDR_ERR_BAD_FIXUP;
+            if ((uint32_t)Fixup.r.r_address >= cbSectBits)
+                return VERR_LDR_BAD_FIXUP;
 
             /* calc fixup addresses. */
             uFix.pv = pbSectBits + Fixup.r.r_address;
-            uFixVirgin.pv = pbSectVirginBits ? (KU8 *)pbSectVirginBits + Fixup.r.r_address : 0;
+            uFixVirgin.pv = pbSectVirginBits ? (uint8_t *)pbSectVirginBits + Fixup.r.r_address : 0;
 
             /*
@@ -2873,9 +2834,9 @@
                 const macho_nlist_32_t *pSym;
                 if (Fixup.r.r_symbolnum >= cSyms)
-                    return KLDR_ERR_BAD_FIXUP;
+                    return VERR_LDR_BAD_FIXUP;
                 pSym = &paSyms[Fixup.r.r_symbolnum];
 
                 if (pSym->n_type & MACHO_N_STAB)
-                    return KLDR_ERR_BAD_FIXUP;
+                    return VERR_LDR_BAD_FIXUP;
 
                 switch (pSym->n_type & MACHO_N_TYPE)
@@ -2884,6 +2845,6 @@
                     {
                         PKLDRMODMACHOSECT pSymSect;
-                        KLDRMODMACHO_CHECK_RETURN((KU32)pSym->n_sect - 1 <= pModMachO->cSections, KLDR_ERR_MACHO_BAD_SYMBOL);
-                        pSymSect = &pModMachO->paSections[pSym->n_sect - 1];
+                        KLDRMODMACHO_CHECK_RETURN((uint32_t)pSym->n_sect - 1 <= pThis->cSections, VERR_LDRMACHO_BAD_SYMBOL);
+                        pSymSect = &pThis->paSections[pSym->n_sect - 1];
 
                         SymAddr += pSym->n_value - pSymSect->LinkAddress + pSymSect->RVA + NewBaseAddress;
@@ -2898,7 +2859,7 @@
                     case MACHO_N_INDR:
                     case MACHO_N_PBUD:
-                        KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_TODO);
+                        KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_TODO);
                     default:
-                        KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_SYMBOL);
+                        KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_SYMBOL);
                 }
             }
@@ -2906,7 +2867,7 @@
             {
                 PKLDRMODMACHOSECT pSymSect;
-                if (Fixup.r.r_symbolnum > pModMachO->cSections)
-                    return KLDR_ERR_BAD_FIXUP;
-                pSymSect = &pModMachO->paSections[Fixup.r.r_symbolnum - 1];
+                if (Fixup.r.r_symbolnum > pThis->cSections)
+                    return VERR_LDR_BAD_FIXUP;
+                pSymSect = &pThis->paSections[Fixup.r.r_symbolnum - 1];
 
                 SymAddr -= pSymSect->LinkAddress;
@@ -2921,15 +2882,15 @@
         {
             PKLDRMODMACHOSECT pSymSect;
-            KU32 iSymSect;
-            KLDRADDR Value;
+            uint32_t iSymSect;
+            RTLDRADDR Value;
 
             /* sanity */
             KLDRMODMACHO_ASSERT(Fixup.s.r_scattered);
-            if ((KU32)Fixup.s.r_address >= cbSectBits)
-                return KLDR_ERR_BAD_FIXUP;
+            if ((uint32_t)Fixup.s.r_address >= cbSectBits)
+                return VERR_LDR_BAD_FIXUP;
 
             /* calc fixup addresses. */
             uFix.pv = pbSectBits + Fixup.s.r_address;
-            uFixVirgin.pv = pbSectVirginBits ? (KU8 *)pbSectVirginBits + Fixup.s.r_address : 0;
+            uFixVirgin.pv = pbSectVirginBits ? (uint8_t *)pbSectVirginBits + Fixup.s.r_address : 0;
 
             /*
@@ -2951,17 +2912,17 @@
             /* Find the section number from the r_value. */
             pSymSect = NULL;
-            for (iSymSect = 0; iSymSect < pModMachO->cSections; iSymSect++)
+            for (iSymSect = 0; iSymSect < pThis->cSections; iSymSect++)
             {
-                KLDRADDR off = Value - pModMachO->paSections[iSymSect].LinkAddress;
-                if (off < pModMachO->paSections[iSymSect].cb)
+                RTLDRADDR off = Value - pThis->paSections[iSymSect].LinkAddress;
+                if (off < pThis->paSections[iSymSect].cb)
                 {
-                    pSymSect = &pModMachO->paSections[iSymSect];
+                    pSymSect = &pThis->paSections[iSymSect];
                     break;
                 }
-                else if (off == pModMachO->paSections[iSymSect].cb) /* edge case */
-                    pSymSect = &pModMachO->paSections[iSymSect];
+                else if (off == pThis->paSections[iSymSect].cb) /* edge case */
+                    pSymSect = &pThis->paSections[iSymSect];
             }
             if (!pSymSect)
-                return KLDR_ERR_BAD_FIXUP;
+                return VERR_LDR_BAD_FIXUP;
 
             /* Calc the symbol address. */
@@ -2981,14 +2942,14 @@
             switch (Fixup.r.r_length)
             {
-                case 0: *uFix.pu8  = (KU8)SymAddr; break;
-                case 1: *uFix.pu16 = (KU16)SymAddr; break;
-                case 2: *uFix.pu32 = (KU32)SymAddr; break;
-                case 3: *uFix.pu64 = (KU64)SymAddr; break;
+                case 0: *uFix.pu8  = (uint8_t)SymAddr; break;
+                case 1: *uFix.pu16 = (uint16_t)SymAddr; break;
+                case 2: *uFix.pu32 = (uint32_t)SymAddr; break;
+                case 3: *uFix.pu64 = (uint64_t)SymAddr; break;
             }
         }
         else if (Fixup.r.r_type <= GENERIC_RELOC_LOCAL_SECTDIFF)
-            return KLDR_ERR_MACHO_UNSUPPORTED_FIXUP_TYPE;
+            return VERR_LDRMACHO_UNSUPPORTED_FIXUP_TYPE;
         else
-            return KLDR_ERR_BAD_FIXUP;
+            return VERR_LDR_BAD_FIXUP;
     }
 
@@ -3001,20 +2962,18 @@
  *
  * @returns 0 on success, non-zero kLdr status code on failure.
- * @param   pModMachO       The Mach-O module interpreter instance.
+ * @param   pThis       The Mach-O module interpreter instance.
  * @param   pbSectBits      Pointer to the section bits.
  * @param   pFixupSect      The section being fixed up.
  * @param   NewBaseAddress  The new base image address.
  */
-static int  kldrModMachOFixupSectionAMD64(PKLDRMODMACHO pModMachO, KU8 *pbSectBits, PKLDRMODMACHOSECT pFixupSect,
-                                          macho_nlist_64_t *paSyms, KU32 cSyms, KLDRADDR NewBaseAddress)
+static int  kldrModMachOFixupSectionAMD64(PKLDRMODMACHO pThis, uint8_t *pbSectBits, PKLDRMODMACHOSECT pFixupSect,
+                                          macho_nlist_64_t *paSyms, uint32_t cSyms, RTLDRADDR NewBaseAddress)
 {
     const macho_relocation_info_t *paFixups = pFixupSect->paFixups;
-    const KU32 cFixups = pFixupSect->cFixups;
-    KSIZE cbSectBits = (KSIZE)pFixupSect->cb;
-    const KU8 *pbSectVirginBits;
-    KU32 iFixup;
-    KLDRPU uFixVirgin;
-    KLDRPU uFix;
-    KLDRADDR SymAddr;
+    const uint32_t cFixups = pFixupSect->cFixups;
+    size_t cbSectBits = (size_t)pFixupSect->cb;
+    const uint8_t *pbSectVirginBits;
+    uint32_t iFixup;
+    RTLDRADDR SymAddr;
     int rc;
 
@@ -3024,8 +2983,8 @@
     if (pFixupSect->offFile != -1)
     {
-        rc = kldrModMachOMapVirginBits(pModMachO);
+        rc = kldrModMachOMapVirginBits(pThis);
         if (rc)
             return rc;
-        pbSectVirginBits = (const KU8 *)pModMachO->pvBits + pFixupSect->offFile;
+        pbSectVirginBits = (const uint8_t *)pThis->pvBits + pFixupSect->offFile;
     }
     else
@@ -3045,12 +3004,14 @@
 
         /* AMD64 doesn't use scattered fixups. */
-        KLDRMODMACHO_CHECK_RETURN(!(Fixup.r.r_address & R_SCATTERED), KLDR_ERR_BAD_FIXUP);
+        KLDRMODMACHO_CHECK_RETURN(!(Fixup.r.r_address & R_SCATTERED), VERR_LDR_BAD_FIXUP);
 
         /* sanity */
-        KLDRMODMACHO_CHECK_RETURN((KU32)Fixup.r.r_address < cbSectBits, KLDR_ERR_BAD_FIXUP);
+        KLDRMODMACHO_CHECK_RETURN((uint32_t)Fixup.r.r_address < cbSectBits, VERR_LDR_BAD_FIXUP);
 
         /* calc fixup addresses. */
+        RTPTRUNION uFix;
         uFix.pv = pbSectBits + Fixup.r.r_address;
-        uFixVirgin.pv = pbSectVirginBits ? (KU8 *)pbSectVirginBits + Fixup.r.r_address : 0;
+        RTPTRUNION uFixVirgin;
+        uFixVirgin.pv = pbSectVirginBits ? (uint8_t *)pbSectVirginBits + Fixup.r.r_address : 0;
 
         /*
@@ -3064,5 +3025,5 @@
             case 3: SymAddr = *uFixVirgin.pi64; break;
             default:
-                KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_BAD_FIXUP);
+                KLDRMODMACHO_FAILED_RETURN(VERR_LDR_BAD_FIXUP);
         }
 
@@ -3072,7 +3033,7 @@
             const macho_nlist_64_t *pSym;
 
-            KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_symbolnum < cSyms, KLDR_ERR_BAD_FIXUP);
+            KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_symbolnum < cSyms, VERR_LDR_BAD_FIXUP);
             pSym = &paSyms[Fixup.r.r_symbolnum];
-            KLDRMODMACHO_CHECK_RETURN(!(pSym->n_type & MACHO_N_STAB), KLDR_ERR_BAD_FIXUP);
+            KLDRMODMACHO_CHECK_RETURN(!(pSym->n_type & MACHO_N_STAB), VERR_LDR_BAD_FIXUP);
 
             switch (Fixup.r.r_type)
@@ -3090,10 +3051,10 @@
                         case MACHO_N_INDR:
                         case MACHO_N_PBUD:
-                            KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_TODO);
+                            KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_TODO);
                         default:
-                            KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_SYMBOL);
+                            KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_SYMBOL);
                     }
-                    SymAddr = sizeof(KU64) * Fixup.r.r_symbolnum + pModMachO->GotRVA + NewBaseAddress;
-                    KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_length == 2, KLDR_ERR_BAD_FIXUP);
+                    SymAddr = sizeof(uint64_t) * Fixup.r.r_symbolnum + pThis->GotRVA + NewBaseAddress;
+                    KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_length == 2, VERR_LDR_BAD_FIXUP);
                     SymAddr -= 4;
                     break;
@@ -3105,5 +3066,5 @@
                 case X86_64_RELOC_SIGNED_2:
                 case X86_64_RELOC_SIGNED_4:
-                    KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_pcrel, KLDR_ERR_BAD_FIXUP);
+                    KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_pcrel, VERR_LDR_BAD_FIXUP);
                     /* Falls through. */
                 default:
@@ -3113,8 +3074,8 @@
                     {
                         case X86_64_RELOC_UNSIGNED:
-                            KLDRMODMACHO_CHECK_RETURN(!Fixup.r.r_pcrel, KLDR_ERR_BAD_FIXUP);
+                            KLDRMODMACHO_CHECK_RETURN(!Fixup.r.r_pcrel, VERR_LDR_BAD_FIXUP);
                             break;
                         case X86_64_RELOC_BRANCH:
-                            KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_length == 2, KLDR_ERR_BAD_FIXUP);
+                            KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_length == 2, VERR_LDR_BAD_FIXUP);
                             SymAddr -= 4;
                             break;
@@ -3126,5 +3087,5 @@
                             break;
                         default:
-                            KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_BAD_FIXUP);
+                            KLDRMODMACHO_FAILED_RETURN(VERR_LDR_BAD_FIXUP);
                     }
 
@@ -3134,6 +3095,6 @@
                         {
                             PKLDRMODMACHOSECT pSymSect;
-                            KLDRMODMACHO_CHECK_RETURN((KU32)pSym->n_sect - 1 <= pModMachO->cSections, KLDR_ERR_MACHO_BAD_SYMBOL);
-                            pSymSect = &pModMachO->paSections[pSym->n_sect - 1];
+                            KLDRMODMACHO_CHECK_RETURN((uint32_t)pSym->n_sect - 1 <= pThis->cSections, VERR_LDRMACHO_BAD_SYMBOL);
+                            pSymSect = &pThis->paSections[pSym->n_sect - 1];
                             SymAddr += pSym->n_value - pSymSect->LinkAddress + pSymSect->RVA + NewBaseAddress;
                             break;
@@ -3145,7 +3106,7 @@
                                 &&       SymAddr + Fixup.r.r_address + pFixupSect->RVA + NewBaseAddress
                                        - pSym->n_value
-                                       + KU64_C(0x80000000)
-                                    >= KU64_C(0xffffff20))
-                                SymAddr += pModMachO->cbJmpStub * Fixup.r.r_symbolnum + pModMachO->JmpStubsRVA + NewBaseAddress;
+                                       + UINT64_C(0x80000000)
+                                    >= UINT64_C(0xffffff20))
+                                SymAddr += pThis->cbJmpStub * Fixup.r.r_symbolnum + pThis->JmpStubsRVA + NewBaseAddress;
                             else
                                 SymAddr += pSym->n_value;
@@ -3158,7 +3119,7 @@
                         case MACHO_N_INDR:
                         case MACHO_N_PBUD:
-                            KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_TODO);
+                            KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_TODO);
                         default:
-                            KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_SYMBOL);
+                            KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_SYMBOL);
                     }
                     break;
@@ -3178,6 +3139,6 @@
                         {
                             PKLDRMODMACHOSECT pSymSect;
-                            KLDRMODMACHO_CHECK_RETURN((KU32)pSym->n_sect - 1 <= pModMachO->cSections, KLDR_ERR_MACHO_BAD_SYMBOL);
-                            pSymSect = &pModMachO->paSections[pSym->n_sect - 1];
+                            KLDRMODMACHO_CHECK_RETURN((uint32_t)pSym->n_sect - 1 <= pThis->cSections, VERR_LDRMACHO_BAD_SYMBOL);
+                            pSymSect = &pThis->paSections[pSym->n_sect - 1];
                             SymAddr -= pSym->n_value - pSymSect->LinkAddress + pSymSect->RVA + NewBaseAddress;
                             break;
@@ -3191,12 +3152,12 @@
                         case MACHO_N_INDR:
                         case MACHO_N_PBUD:
-                            KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_TODO);
+                            KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_TODO);
                         default:
-                            KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_SYMBOL);
+                            KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_SYMBOL);
                     }
 
                     /* Load the 2nd fixup, check sanity. */
                     iFixup++;
-                    KLDRMODMACHO_CHECK_RETURN(!Fixup.r.r_pcrel && iFixup < cFixups, KLDR_ERR_BAD_FIXUP);
+                    KLDRMODMACHO_CHECK_RETURN(!Fixup.r.r_pcrel && iFixup < cFixups, VERR_LDR_BAD_FIXUP);
                     Fixup2 = paFixups[iFixup];
                     KLDRMODMACHO_CHECK_RETURN(   Fixup2.r_address == Fixup.r.r_address
@@ -3205,11 +3166,11 @@
                                               && !Fixup2.r_pcrel
                                               && Fixup2.r_symbolnum < cSyms,
-                                              KLDR_ERR_BAD_FIXUP);
+                                              VERR_LDR_BAD_FIXUP);
 
                     if (Fixup2.r_extern)
                     {
-                        KLDRMODMACHO_CHECK_RETURN(Fixup2.r_symbolnum < cSyms, KLDR_ERR_BAD_FIXUP);
+                        KLDRMODMACHO_CHECK_RETURN(Fixup2.r_symbolnum < cSyms, VERR_LDR_BAD_FIXUP);
                         pSym = &paSyms[Fixup2.r_symbolnum];
-                        KLDRMODMACHO_CHECK_RETURN(!(pSym->n_type & MACHO_N_STAB), KLDR_ERR_BAD_FIXUP);
+                        KLDRMODMACHO_CHECK_RETURN(!(pSym->n_type & MACHO_N_STAB), VERR_LDR_BAD_FIXUP);
 
                         /* Add it's value to SymAddr. */
@@ -3219,6 +3180,6 @@
                             {
                                 PKLDRMODMACHOSECT pSymSect;
-                                KLDRMODMACHO_CHECK_RETURN((KU32)pSym->n_sect - 1 <= pModMachO->cSections, KLDR_ERR_MACHO_BAD_SYMBOL);
-                                pSymSect = &pModMachO->paSections[pSym->n_sect - 1];
+                                KLDRMODMACHO_CHECK_RETURN((uint32_t)pSym->n_sect - 1 <= pThis->cSections, VERR_LDRMACHO_BAD_SYMBOL);
+                                pSymSect = &pThis->paSections[pSym->n_sect - 1];
                                 SymAddr += pSym->n_value - pSymSect->LinkAddress + pSymSect->RVA + NewBaseAddress;
                                 break;
@@ -3232,7 +3193,7 @@
                             case MACHO_N_INDR:
                             case MACHO_N_PBUD:
-                                KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_TODO);
+                                KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_TODO);
                             default:
-                                KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_MACHO_BAD_SYMBOL);
+                                KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_BAD_SYMBOL);
                         }
                     }
@@ -3240,10 +3201,10 @@
                     {
                         PKLDRMODMACHOSECT pSymSect;
-                        KLDRMODMACHO_CHECK_RETURN(Fixup2.r_symbolnum <= pModMachO->cSections, KLDR_ERR_BAD_FIXUP);
-                        pSymSect = &pModMachO->paSections[Fixup2.r_symbolnum - 1];
+                        KLDRMODMACHO_CHECK_RETURN(Fixup2.r_symbolnum <= pThis->cSections, VERR_LDR_BAD_FIXUP);
+                        pSymSect = &pThis->paSections[Fixup2.r_symbolnum - 1];
                         SymAddr += pSymSect->RVA + NewBaseAddress;
                     }
                     else
-                        KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_BAD_FIXUP);
+                        KLDRMODMACHO_FAILED_RETURN(VERR_LDR_BAD_FIXUP);
                 }
                 break;
@@ -3256,8 +3217,8 @@
             {
                 case X86_64_RELOC_UNSIGNED:
-                    KLDRMODMACHO_CHECK_RETURN(!Fixup.r.r_pcrel, KLDR_ERR_BAD_FIXUP);
+                    KLDRMODMACHO_CHECK_RETURN(!Fixup.r.r_pcrel, VERR_LDR_BAD_FIXUP);
                     break;
                 case X86_64_RELOC_BRANCH:
-                    KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_pcrel, KLDR_ERR_BAD_FIXUP);
+                    KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_pcrel, VERR_LDR_BAD_FIXUP);
                     SymAddr += 4; /* dunno what the assmbler/linker really is doing here... */
                     break;
@@ -3266,5 +3227,5 @@
                 case X86_64_RELOC_SIGNED_2:
                 case X86_64_RELOC_SIGNED_4:
-                    KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_pcrel, KLDR_ERR_BAD_FIXUP);
+                    KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_pcrel, VERR_LDR_BAD_FIXUP);
                     break;
                 /*case X86_64_RELOC_GOT_LOAD:*/
@@ -3272,11 +3233,11 @@
                 /*case X86_64_RELOC_SUBTRACTOR: - must be r_extern=1 says as. */
                 default:
-                    KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_BAD_FIXUP);
+                    KLDRMODMACHO_FAILED_RETURN(VERR_LDR_BAD_FIXUP);
             }
             if (Fixup.r.r_symbolnum != R_ABS)
             {
                 PKLDRMODMACHOSECT pSymSect;
-                KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_symbolnum <= pModMachO->cSections, KLDR_ERR_BAD_FIXUP);
-                pSymSect = &pModMachO->paSections[Fixup.r.r_symbolnum - 1];
+                KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_symbolnum <= pThis->cSections, VERR_LDR_BAD_FIXUP);
+                pSymSect = &pThis->paSections[Fixup.r.r_symbolnum - 1];
 
                 SymAddr -= pSymSect->LinkAddress;
@@ -3297,13 +3258,13 @@
         {
             case 3:
-                *uFix.pu64 = (KU64)SymAddr;
+                *uFix.pu64 = (uint64_t)SymAddr;
                 break;
             case 2:
-                KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_pcrel || Fixup.r.r_type == X86_64_RELOC_SUBTRACTOR, KLDR_ERR_BAD_FIXUP);
-                KLDRMODMACHO_CHECK_RETURN((KI32)SymAddr == (KI64)SymAddr, KLDR_ERR_ADDRESS_OVERFLOW);
-                *uFix.pu32 = (KU32)SymAddr;
+                KLDRMODMACHO_CHECK_RETURN(Fixup.r.r_pcrel || Fixup.r.r_type == X86_64_RELOC_SUBTRACTOR, VERR_LDR_BAD_FIXUP);
+                KLDRMODMACHO_CHECK_RETURN((int32_t)SymAddr == (int64_t)SymAddr, VERR_LDR_ADDRESS_OVERFLOW);
+                *uFix.pu32 = (uint32_t)SymAddr;
                 break;
             default:
-                KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_BAD_FIXUP);
+                KLDRMODMACHO_FAILED_RETURN(VERR_LDR_BAD_FIXUP);
         }
     }
@@ -3319,71 +3280,72 @@
  *
  * @returns 0 on success, non-zero kLdr status code on failure.
- * @param   pModMachO       The Mach-O module interpreter instance.
- */
-static int  kldrModMachOLoadObjSymTab(PKLDRMODMACHO pModMachO)
+ * @param   pThis       The Mach-O module interpreter instance.
+ */
+static int  kldrModMachOLoadObjSymTab(PKLDRMODMACHO pThis)
 {
     int rc = 0;
 
-    if (    !pModMachO->pvaSymbols
-        &&  pModMachO->cSymbols)
-    {
-        KSIZE cbSyms;
-        KSIZE cbSym;
+    if (    !pThis->pvaSymbols
+        &&  pThis->cSymbols)
+    {
+        size_t cbSyms;
+        size_t cbSym;
         void *pvSyms;
         void *pvStrings;
 
         /* sanity */
-        KLDRMODMACHO_CHECK_RETURN(   pModMachO->offSymbols
-                                  && (!pModMachO->cchStrings || pModMachO->offStrings),
-                                  KLDR_ERR_MACHO_BAD_OBJECT_FILE);
+        KLDRMODMACHO_CHECK_RETURN(   pThis->offSymbols
+                                  && (!pThis->cchStrings || pThis->offStrings),
+                                  VERR_LDRMACHO_BAD_OBJECT_FILE);
 
         /* allocate */
-        cbSym = pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE
-             || pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE
+        cbSym = pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE
+             || pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE
              ? sizeof(macho_nlist_32_t)
              : sizeof(macho_nlist_64_t);
-        cbSyms = pModMachO->cSymbols * cbSym;
-        KLDRMODMACHO_CHECK_RETURN(cbSyms / cbSym == pModMachO->cSymbols, KLDR_ERR_SIZE_OVERFLOW);
-        rc = KERR_NO_MEMORY;
-        pvSyms = kHlpAlloc(cbSyms);
+        cbSyms = pThis->cSymbols * cbSym;
+        KLDRMODMACHO_CHECK_RETURN(cbSyms / cbSym == pThis->cSymbols, VERR_LDRMACHO_BAD_SYMTAB_SIZE);
+        rc = VERR_NO_MEMORY;
+        pvSyms = RTMemAlloc(cbSyms);
         if (pvSyms)
         {
-            if (pModMachO->cchStrings)
-                pvStrings = kHlpAlloc(pModMachO->cchStrings);
+            if (pThis->cchStrings)
+                pvStrings = RTMemAlloc(pThis->cchStrings);
             else
-                pvStrings = kHlpAllocZ(4);
+                pvStrings = RTMemAllocZ(4);
             if (pvStrings)
             {
                 /* read */
-                rc = kRdrRead(pModMachO->pMod->pRdr, pvSyms, cbSyms, pModMachO->offSymbols);
-                if (!rc && pModMachO->cchStrings)
-                    rc = kRdrRead(pModMachO->pMod->pRdr, pvStrings, pModMachO->cchStrings, pModMachO->offStrings);
+                rc = pThis->Core.pReader->pfnRead(pThis->Core.pReader, pvSyms, cbSyms, pThis->offSymbols);
+                if (!rc && pThis->cchStrings)
+                    rc = pThis->Core.pReader->pfnRead(pThis->Core.pReader, pvStrings,
+                                                          pThis->cchStrings, pThis->offStrings);
                 if (!rc)
                 {
-                    pModMachO->pvaSymbols = pvSyms;
-                    pModMachO->pchStrings = (char *)pvStrings;
+                    pThis->pvaSymbols = pvSyms;
+                    pThis->pchStrings = (char *)pvStrings;
 
                     /* perform endian conversion? */
-                    if (pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
+                    if (pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
                     {
-                        KU32 cLeft = pModMachO->cSymbols;
+                        uint32_t cLeft = pThis->cSymbols;
                         macho_nlist_32_t *pSym = (macho_nlist_32_t *)pvSyms;
                         while (cLeft-- > 0)
                         {
-                            pSym->n_un.n_strx = K_E2E_U32(pSym->n_un.n_strx);
-                            pSym->n_desc = (KI16)K_E2E_U16(pSym->n_desc);
-                            pSym->n_value = K_E2E_U32(pSym->n_value);
+                            pSym->n_un.n_strx = RT_BSWAP_U32(pSym->n_un.n_strx);
+                            pSym->n_desc = (int16_t)RT_BSWAP_U16(pSym->n_desc);
+                            pSym->n_value = RT_BSWAP_U32(pSym->n_value);
                             pSym++;
                         }
                     }
-                    else if (pModMachO->Hdr.magic == IMAGE_MACHO64_SIGNATURE_OE)
+                    else if (pThis->Hdr.magic == IMAGE_MACHO64_SIGNATURE_OE)
                     {
-                        KU32 cLeft = pModMachO->cSymbols;
+                        uint32_t cLeft = pThis->cSymbols;
                         macho_nlist_64_t *pSym = (macho_nlist_64_t *)pvSyms;
                         while (cLeft-- > 0)
                         {
-                            pSym->n_un.n_strx = K_E2E_U32(pSym->n_un.n_strx);
-                            pSym->n_desc = (KI16)K_E2E_U16(pSym->n_desc);
-                            pSym->n_value = K_E2E_U64(pSym->n_value);
+                            pSym->n_un.n_strx = RT_BSWAP_U32(pSym->n_un.n_strx);
+                            pSym->n_desc = (int16_t)RT_BSWAP_U16(pSym->n_desc);
+                            pSym->n_value = RT_BSWAP_U64(pSym->n_value);
                             pSym++;
                         }
@@ -3392,11 +3354,11 @@
                     return 0;
                 }
-                kHlpFree(pvStrings);
+                RTMemFree(pvStrings);
             }
-            kHlpFree(pvSyms);
+            RTMemFree(pvSyms);
         }
     }
     else
-        KLDRMODMACHO_ASSERT(pModMachO->pchStrings || pModMachO->Hdr.filetype == MH_DSYM);
+        KLDRMODMACHO_ASSERT(pThis->pchStrings || pThis->Hdr.filetype == MH_DSYM);
 
     return rc;
@@ -3409,24 +3371,24 @@
  *
  * @returns 0 on success, non-zero kLdr status code on failure.
- * @param   pModMachO       The Mach-O module interpreter instance.
+ * @param   pThis       The Mach-O module interpreter instance.
  * @param   offFixups       The file offset of the fixups.
  * @param   cFixups         The number of fixups to load.
  * @param   ppaFixups       Where to put the pointer to the allocated fixup array.
  */
-static int  kldrModMachOLoadFixups(PKLDRMODMACHO pModMachO, KLDRFOFF offFixups, KU32 cFixups, macho_relocation_info_t **ppaFixups)
+static int  kldrModMachOLoadFixups(PKLDRMODMACHO pThis, RTFOFF offFixups, uint32_t cFixups, macho_relocation_info_t **ppaFixups)
 {
     macho_relocation_info_t *paFixups;
-    KSIZE cbFixups;
+    size_t cbFixups;
     int rc;
 
     /* allocate the memory. */
     cbFixups = cFixups * sizeof(*paFixups);
-    KLDRMODMACHO_CHECK_RETURN(cbFixups / sizeof(*paFixups) == cFixups, KLDR_ERR_SIZE_OVERFLOW);
-    paFixups = (macho_relocation_info_t *)kHlpAlloc(cbFixups);
+    KLDRMODMACHO_CHECK_RETURN(cbFixups / sizeof(*paFixups) == cFixups, VERR_LDRMACHO_BAD_SYMTAB_SIZE);
+    paFixups = (macho_relocation_info_t *)RTMemAlloc(cbFixups);
     if (!paFixups)
-        return KERR_NO_MEMORY;
+        return VERR_NO_MEMORY;
 
     /* read the fixups. */
-    rc = kRdrRead(pModMachO->pMod->pRdr, paFixups, cbFixups, offFixups);
+    rc = pThis->Core.pReader->pfnRead(pThis->Core.pReader, paFixups, cbFixups, offFixups);
     if (!rc)
     {
@@ -3434,18 +3396,18 @@
 
         /* do endian conversion if necessary. */
-        if (    pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE
-            ||  pModMachO->Hdr.magic == IMAGE_MACHO64_SIGNATURE_OE)
-        {
-            KU32 iFixup;
+        if (    pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE
+            ||  pThis->Hdr.magic == IMAGE_MACHO64_SIGNATURE_OE)
+        {
+            uint32_t iFixup;
             for (iFixup = 0; iFixup < cFixups; iFixup++)
             {
-                KU32 *pu32 = (KU32 *)&paFixups[iFixup];
-                pu32[0] = K_E2E_U32(pu32[0]);
-                pu32[1] = K_E2E_U32(pu32[1]);
+                uint32_t *pu32 = (uint32_t *)&paFixups[iFixup];
+                pu32[0] = RT_BSWAP_U32(pu32[0]);
+                pu32[1] = RT_BSWAP_U32(pu32[1]);
             }
         }
     }
     else
-        kHlpFree(paFixups);
+        RTMemFree(paFixups);
     return rc;
 }
@@ -3456,22 +3418,23 @@
  *
  * @returns 0 on success, non-zero kLdr status code on failure.
- * @param   pModMachO       The Mach-O module interpreter instance.
- */
-static int kldrModMachOMapVirginBits(PKLDRMODMACHO pModMachO)
+ * @param   pThis       The Mach-O module interpreter instance.
+ */
+static int kldrModMachOMapVirginBits(PKLDRMODMACHO pThis)
 {
     int rc = 0;
-    if (!pModMachO->pvBits)
-        rc = kRdrAllMap(pModMachO->pMod->pRdr, &pModMachO->pvBits);
+    if (!pThis->pvBits)
+        rc = pThis->Core.pReader->pfnMap(pThis->Core.pReader, &pThis->pvBits);
     return rc;
 }
 
+#if 0
 
 /** @copydoc kLdrModCallInit */
-static int kldrModMachOCallInit(PKLDRMOD pMod, void *pvMapping, KUPTR uHandle)
+static int kldrModMachOCallInit(PRTLDRMODINTERNAL pMod, void *pvMapping, uintptr_t uHandle)
 {
     /* later */
-    K_NOREF(pMod);
-    K_NOREF(pvMapping);
-    K_NOREF(uHandle);
+    RT_NOREF(pMod);
+    RT_NOREF(pvMapping);
+    RT_NOREF(uHandle);
     return 0;
 }
@@ -3479,10 +3442,10 @@
 
 /** @copydoc kLdrModCallTerm */
-static int kldrModMachOCallTerm(PKLDRMOD pMod, void *pvMapping, KUPTR uHandle)
+static int kldrModMachOCallTerm(PRTLDRMODINTERNAL pMod, void *pvMapping, uintptr_t uHandle)
 {
     /* later */
-    K_NOREF(pMod);
-    K_NOREF(pvMapping);
-    K_NOREF(uHandle);
+    RT_NOREF(pMod);
+    RT_NOREF(pvMapping);
+    RT_NOREF(uHandle);
     return 0;
 }
@@ -3490,53 +3453,58 @@
 
 /** @copydoc kLdrModCallThread */
-static int kldrModMachOCallThread(PKLDRMOD pMod, void *pvMapping, KUPTR uHandle, unsigned fAttachingOrDetaching)
+static int kldrModMachOCallThread(PRTLDRMODINTERNAL pMod, void *pvMapping, uintptr_t uHandle, unsigned fAttachingOrDetaching)
 {
     /* Relevant for Mach-O? */
-    K_NOREF(pMod);
-    K_NOREF(pvMapping);
-    K_NOREF(uHandle);
-    K_NOREF(fAttachingOrDetaching);
+    RT_NOREF(pMod);
+    RT_NOREF(pvMapping);
+    RT_NOREF(uHandle);
+    RT_NOREF(fAttachingOrDetaching);
     return 0;
 }
 
-
-/** @copydoc kLdrModSize */
-static KLDRADDR kldrModMachOSize(PKLDRMOD pMod)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
-    return pModMachO->cbImage;
-}
-
-
-/** @copydoc kLdrModGetBits */
-static int kldrModMachOGetBits(PKLDRMOD pMod, void *pvBits, KLDRADDR BaseAddress, PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser)
-{
-    PKLDRMODMACHO  pModMachO = (PKLDRMODMACHO)pMod->pvData;
-    KU32        i;
-    int         rc;
-
-    if (!pModMachO->fCanLoad)
-        return KLDR_ERR_TODO;
+#endif
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnGetImageSize}
+ */
+static size_t rtldrMachO_GetImageSize(PRTLDRMODINTERNAL pMod)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+    return pThis->cbImage;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnGetBits}
+ */
+static DECLCALLBACK(int) rtldrMachO_GetBits(PRTLDRMODINTERNAL pMod, void *pvBits, RTUINTPTR BaseAddress,
+                                            PFNRTLDRIMPORT pfnGetImport, void *pvUser)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+
+    if (!pThis->fCanLoad)
+        return VERR_LDRMACHO_TODO;
 
     /*
      * Zero the entire buffer first to simplify things.
      */
-    kHlpMemSet(pvBits, 0, (KSIZE)pModMachO->cbImage);
+    memset(pvBits, 0, (size_t)pThis->cbImage);
 
     /*
      * When possible use the segment table to load the data.
      */
-    for (i = 0; i < pMod->cSegments; i++)
+    for (uint32_t i = 0; i < pThis->cSegments; i++)
     {
         /* skip it? */
-        if (    pMod->aSegments[i].cbFile == -1
-            ||  pMod->aSegments[i].offFile == -1
-            ||  pMod->aSegments[i].LinkAddress == NIL_KLDRADDR
-            ||  !pMod->aSegments[i].Alignment)
+        if (   pThis->aSegments[i].SegInfo.cbFile == -1
+            || pThis->aSegments[i].SegInfo.offFile == -1
+            || pThis->aSegments[i].SegInfo.LinkAddress == NIL_RTLDRADDR
+            || !pThis->aSegments[i].SegInfo.Alignment)
             continue;
-        rc = kRdrRead(pMod->pRdr,
-                      (KU8 *)pvBits + pMod->aSegments[i].RVA,
-                      pMod->aSegments[i].cbFile,
-                      pMod->aSegments[i].offFile);
+        int rc = pThis->Core.pReader->pfnRead(pThis->Core.pReader,
+                                                  (uint8_t *)pvBits + pThis->aSegments[i].SegInfo.RVA,
+                                                  pThis->aSegments[i].SegInfo.cbFile,
+                                                  pThis->aSegments[i].SegInfo.offFile);
         if (rc)
             return rc;
@@ -3546,32 +3514,34 @@
      * Perform relocations.
      */
-    return kldrModMachORelocateBits(pMod, pvBits, BaseAddress, pModMachO->LinkAddress, pfnGetImport, pvUser);
-}
-
-
-/** @copydoc kLdrModRelocateBits */
-static int kldrModMachORelocateBits(PKLDRMOD pMod, void *pvBits, KLDRADDR NewBaseAddress, KLDRADDR OldBaseAddress,
-                                    PFNKLDRMODGETIMPORT pfnGetImport, void *pvUser)
-{
-    PKLDRMODMACHO pModMachO = (PKLDRMODMACHO)pMod->pvData;
+    return rtldrMachO_RelocateBits(pMod, pvBits, BaseAddress, pThis->LinkAddress, pfnGetImport, pvUser);
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnRelocate}
+ */
+static DECLCALLBACK(int) rtldrMachO_RelocateBits(PRTLDRMODINTERNAL pMod, void *pvBits, RTUINTPTR NewBaseAddress,
+                                                 RTUINTPTR OldBaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
     int rc;
-    K_NOREF(OldBaseAddress);
+    RT_NOREF(OldBaseAddress);
 
     /*
      * Call workers to do the jobs.
      */
-    if (pModMachO->Hdr.filetype == MH_OBJECT)
-    {
-        rc = kldrModMachOObjDoImports(pModMachO, NewBaseAddress, pfnGetImport, pvUser);
+    if (pThis->Hdr.filetype == MH_OBJECT)
+    {
+        rc = kldrModMachOObjDoImports(pThis, NewBaseAddress, pfnGetImport, pvUser);
         if (!rc)
-            rc = kldrModMachOObjDoFixups(pModMachO, pvBits, NewBaseAddress);
+            rc = kldrModMachOObjDoFixups(pThis, pvBits, NewBaseAddress);
 
     }
     else
-        rc = KLDR_ERR_TODO;
+        rc = VERR_LDRMACHO_TODO;
     /*{
-        rc = kldrModMachODoFixups(pModMachO, pvBits, NewBaseAddress, OldBaseAddress, pfnGetImport, pvUser);
+        rc = kldrModMachODoFixups(pThis, pvBits, NewBaseAddress, OldBaseAddress, pfnGetImport, pvUser);
         if (!rc)
-            rc = kldrModMachODoImports(pModMachO, pvBits, pfnGetImport, pvUser);
+            rc = kldrModMachODoImports(pThis, pvBits, pfnGetImport, pvUser);
     }*/
 
@@ -3580,6 +3550,6 @@
      * segment when present.
      */
-    if (!rc && pModMachO->fMakeGot)
-        rc = kldrModMachOMakeGOT(pModMachO, pvBits, NewBaseAddress);
+    if (!rc && pThis->fMakeGot)
+        rc = kldrModMachOMakeGOT(pThis, pvBits, NewBaseAddress);
 
     return rc;
@@ -3593,12 +3563,12 @@
  * the bits has been cleared up front.
  */
-static int kldrModMachOMakeGOT(PKLDRMODMACHO pModMachO, void *pvBits, KLDRADDR NewBaseAddress)
-{
-    KU32  iSym = pModMachO->cSymbols;
-    if (    pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE
-        ||  pModMachO->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
-    {
-        macho_nlist_32_t const *paSyms = (macho_nlist_32_t const *)pModMachO->pvaSymbols;
-        KU32 *paGOT = (KU32 *)((KU8 *)pvBits + pModMachO->GotRVA);
+static int kldrModMachOMakeGOT(PKLDRMODMACHO pThis, void *pvBits, RTLDRADDR NewBaseAddress)
+{
+    uint32_t  iSym = pThis->cSymbols;
+    if (    pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE
+        ||  pThis->Hdr.magic == IMAGE_MACHO32_SIGNATURE_OE)
+    {
+        macho_nlist_32_t const *paSyms = (macho_nlist_32_t const *)pThis->pvaSymbols;
+        uint32_t *paGOT = (uint32_t *)((uint8_t *)pvBits + pThis->GotRVA);
         while (iSym-- > 0)
             switch (paSyms[iSym].n_type & MACHO_N_TYPE)
@@ -3607,7 +3577,7 @@
                 {
                     PKLDRMODMACHOSECT pSymSect;
-                    KLDRMODMACHO_CHECK_RETURN((KU32)paSyms[iSym].n_sect - 1 <= pModMachO->cSections, KLDR_ERR_MACHO_BAD_SYMBOL);
-                    pSymSect = &pModMachO->paSections[paSyms[iSym].n_sect - 1];
-                    paGOT[iSym] = (KU32)(paSyms[iSym].n_value - pSymSect->LinkAddress + pSymSect->RVA + NewBaseAddress);
+                    KLDRMODMACHO_CHECK_RETURN((uint32_t)paSyms[iSym].n_sect - 1 <= pThis->cSections, VERR_LDRMACHO_BAD_SYMBOL);
+                    pSymSect = &pThis->paSections[paSyms[iSym].n_sect - 1];
+                    paGOT[iSym] = (uint32_t)(paSyms[iSym].n_value - pSymSect->LinkAddress + pSymSect->RVA + NewBaseAddress);
                     break;
                 }
@@ -3621,6 +3591,6 @@
     else
     {
-        macho_nlist_64_t const *paSyms = (macho_nlist_64_t const *)pModMachO->pvaSymbols;
-        KU64 *paGOT = (KU64 *)((KU8 *)pvBits + pModMachO->GotRVA);
+        macho_nlist_64_t const *paSyms = (macho_nlist_64_t const *)pThis->pvaSymbols;
+        uint64_t *paGOT = (uint64_t *)((uint8_t *)pvBits + pThis->GotRVA);
         while (iSym-- > 0)
         {
@@ -3630,6 +3600,6 @@
                 {
                     PKLDRMODMACHOSECT pSymSect;
-                    KLDRMODMACHO_CHECK_RETURN((KU32)paSyms[iSym].n_sect - 1 <= pModMachO->cSections, KLDR_ERR_MACHO_BAD_SYMBOL);
-                    pSymSect = &pModMachO->paSections[paSyms[iSym].n_sect - 1];
+                    KLDRMODMACHO_CHECK_RETURN((uint32_t)paSyms[iSym].n_sect - 1 <= pThis->cSections, VERR_LDRMACHO_BAD_SYMBOL);
+                    pSymSect = &pThis->paSections[paSyms[iSym].n_sect - 1];
                     paGOT[iSym] = paSyms[iSym].n_value - pSymSect->LinkAddress + pSymSect->RVA + NewBaseAddress;
                     break;
@@ -3643,8 +3613,8 @@
         }
 
-        if (pModMachO->JmpStubsRVA != NIL_KLDRADDR)
-        {
-            iSym = pModMachO->cSymbols;
-            switch (pModMachO->Hdr.cputype)
+        if (pThis->JmpStubsRVA != NIL_RTLDRADDR)
+        {
+            iSym = pThis->cSymbols;
+            switch (pThis->Hdr.cputype)
             {
                 /*
@@ -3655,15 +3625,15 @@
                 case CPU_TYPE_X86_64:
                 {
-                    KU64   *paJmps = (KU64 *)((KU8 *)pvBits + pModMachO->JmpStubsRVA);
-                    KI32    off;
-                    KU64    u64Tmpl;
+                    uint64_t   *paJmps = (uint64_t *)((uint8_t *)pvBits + pThis->JmpStubsRVA);
+                    int32_t     off;
+                    uint64_t    u64Tmpl;
                     union
                     {
-                        KU8     ab[8];
-                        KU64    u64;
+                        uint8_t     ab[8];
+                        uint64_t    u64;
                     }       Tmpl;
 
                     /* create the template. */
-                    off = (KI32)(pModMachO->GotRVA - (pModMachO->JmpStubsRVA + 6));
+                    off = (int32_t)(pThis->GotRVA - (pThis->JmpStubsRVA + 6));
                     Tmpl.ab[0] = 0xff; /* jmp [GOT-entry wrt RIP] */
                     Tmpl.ab[1] = 0x25;
@@ -3683,5 +3653,5 @@
 
                 default:
-                    KLDRMODMACHO_FAILED_RETURN(KLDR_ERR_TODO);
+                    KLDRMODMACHO_FAILED_RETURN(VERR_LDRMACHO_TODO);
             }
         }
@@ -3692,38 +3662,299 @@
 
 /**
- * The Mach-O module interpreter method table.
- */
-KLDRMODOPS g_kLdrModMachOOps =
-{
-    "Mach-O",
+ * @interface_method_impl{RTLDROPS,pfnEnumSegments}
+ */
+static DECLCALLBACK(int) rtldrMachO_EnumSegments(PRTLDRMODINTERNAL pMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser)
+{
+    PKLDRMODMACHO  pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+    uint32_t const cSegments  = pThis->cSegments;
+    for (uint32_t iSeg = 0; iSeg < cSegments; iSeg++)
+    {
+        RTLDRSEG Seg = pThis->aSegments[iSeg].SegInfo;
+        int rc = pfnCallback(pMod, &Seg, pvUser);
+        if (rc != VINF_SUCCESS)
+            return rc;
+    }
+
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnLinkAddressToSegOffset}
+ */
+static DECLCALLBACK(int) rtldrMachO_LinkAddressToSegOffset(PRTLDRMODINTERNAL pMod, RTLDRADDR LinkAddress,
+                                                           uint32_t *piSeg, PRTLDRADDR poffSeg)
+{
+    PKLDRMODMACHO  pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+    uint32_t const cSegments  = pThis->cSegments;
+    for (uint32_t iSeg = 0; iSeg < cSegments; iSeg++)
+    {
+        RTLDRADDR offSeg = LinkAddress - pThis->aSegments[iSeg].SegInfo.LinkAddress;
+        if (   offSeg < pThis->aSegments[iSeg].SegInfo.cbMapped
+            || offSeg < pThis->aSegments[iSeg].SegInfo.cb)
+        {
+            *piSeg = iSeg;
+            *poffSeg = offSeg;
+            return VINF_SUCCESS;
+        }
+    }
+
+    return VERR_LDR_INVALID_LINK_ADDRESS;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnLinkAddressToRva}.
+ */
+static DECLCALLBACK(int) rtldrMachO_LinkAddressToRva(PRTLDRMODINTERNAL pMod, RTLDRADDR LinkAddress, PRTLDRADDR pRva)
+{
+    PKLDRMODMACHO  pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+    uint32_t const cSegments  = pThis->cSegments;
+    for (uint32_t iSeg = 0; iSeg < cSegments; iSeg++)
+    {
+        RTLDRADDR offSeg = LinkAddress - pThis->aSegments[iSeg].SegInfo.LinkAddress;
+        if (   offSeg < pThis->aSegments[iSeg].SegInfo.cbMapped
+            || offSeg < pThis->aSegments[iSeg].SegInfo.cb)
+        {
+            *pRva = pThis->aSegments[iSeg].SegInfo.RVA + offSeg;
+            return VINF_SUCCESS;
+        }
+    }
+
+    return VERR_LDR_INVALID_RVA;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnSegOffsetToRva}
+ */
+static DECLCALLBACK(int) rtldrMachO_SegOffsetToRva(PRTLDRMODINTERNAL pMod, uint32_t iSeg, RTLDRADDR offSeg, PRTLDRADDR pRva)
+{
+    PKLDRMODMACHO  pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+
+    if (iSeg >= pThis->cSegments)
+        return VERR_LDR_INVALID_SEG_OFFSET;
+    KLDRMODMACHOSEG const *pSegment = &pThis->aSegments[iSeg];
+
+    if (   offSeg > pSegment->SegInfo.cbMapped
+        && offSeg > pSegment->SegInfo.cb
+        && (    pSegment->SegInfo.cbFile < 0
+            ||  offSeg > (uint64_t)pSegment->SegInfo.cbFile))
+        return VERR_LDR_INVALID_SEG_OFFSET;
+
+    *pRva = pSegment->SegInfo.RVA + offSeg;
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnRvaToSegOffset}
+ */
+static DECLCALLBACK(int) rtldrMachO_RvaToSegOffset(PRTLDRMODINTERNAL pMod, RTLDRADDR Rva, uint32_t *piSeg, PRTLDRADDR poffSeg)
+{
+    PKLDRMODMACHO  pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+    uint32_t const cSegments  = pThis->cSegments;
+    for (uint32_t iSeg = 0; iSeg < cSegments; iSeg++)
+    {
+        RTLDRADDR offSeg = Rva - pThis->aSegments[iSeg].SegInfo.RVA;
+        if (   offSeg < pThis->aSegments[iSeg].SegInfo.cbMapped
+            || offSeg < pThis->aSegments[iSeg].SegInfo.cb)
+        {
+            *piSeg = iSeg;
+            *poffSeg = offSeg;
+            return VINF_SUCCESS;
+        }
+    }
+
+    return VERR_LDR_INVALID_RVA;
+}
+
+
+/**
+ * @interface_method_impl{RTLDROPS,pfnReadDbgInfo}
+ */
+static DECLCALLBACK(int) rtldrMachO_ReadDbgInfo(PRTLDRMODINTERNAL pMod, uint32_t iDbgInfo, RTFOFF off, size_t cb, void *pvBuf)
+{
+    PKLDRMODMACHO  pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+
+    /** @todo May have to apply fixups here. */
+    if (iDbgInfo == iDbgInfo)
+        return pThis->Core.pReader->pfnRead(pThis->Core.pReader, pvBuf, cb, off);
+    if (iDbgInfo < pThis->cSections)
+    {
+        return pThis->Core.pReader->pfnRead(pThis->Core.pReader, pvBuf, cb, off);
+    }
+    return VERR_OUT_OF_RANGE;
+}
+
+
+/** @interface_method_impl{RTLDROPS,pfnQueryProp} */
+static DECLCALLBACK(int) rtldrMachO_QueryProp(PRTLDRMODINTERNAL pMod, RTLDRPROP enmProp, void const *pvBits,
+                                          void *pvBuf, size_t cbBuf, size_t *pcbRet)
+{
+    PKLDRMODMACHO pThis = RT_FROM_MEMBER(pMod, KLDRMODMACHO, Core);
+    int           rc;
+    switch (enmProp)
+    {
+        case RTLDRPROP_UUID:
+            rc = kldrModMachOQueryImageUuid(pThis, pvBits, (uint8_t *)pvBuf, cbBuf);
+            if (RT_FAILURE(rc))
+                return rc;
+            cbBuf = RT_MIN(cbBuf, sizeof(RTUUID));
+            break;
+
+#if 0 /** @todo return LC_ID_DYLIB */
+        case RTLDRPROP_INTERNAL_NAME:
+#endif
+
+        default:
+            return VERR_NOT_FOUND;
+    }
+    if (pcbRet)
+        *pcbRet = cbBuf;
+    RT_NOREF_PV(pvBits);
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * Operations for a Mach-O module interpreter.
+ */
+static const RTLDROPS s_rtldrMachOOps=
+{
+    "mach-o",
+    rtldrMachO_Close,
     NULL,
-    kldrModMachOCreate,
-    kldrModMachODestroy,
-    kldrModMachOQuerySymbol,
-    kldrModMachOEnumSymbols,
-    kldrModMachOGetImport,
-    kldrModMachONumberOfImports,
-    NULL /* can execute one is optional */,
-    kldrModMachOGetStackInfo,
-    kldrModMachOQueryMainEntrypoint,
-    kldrModMachOQueryImageUuid,
+    NULL /*pfnDone*/,
+    rtldrMachO_EnumSymbols,
+    /* ext */
+    rtldrMachO_GetImageSize,
+    rtldrMachO_GetBits,
+    rtldrMachO_RelocateBits,
+    rtldrMachO_GetSymbolEx,
+    NULL /*pfnQueryForwarderInfo*/,
+    rtldrMachO_EnumDbgInfo,
+    rtldrMachO_EnumSegments,
+    rtldrMachO_LinkAddressToSegOffset,
+    rtldrMachO_LinkAddressToRva,
+    rtldrMachO_SegOffsetToRva,
+    rtldrMachO_RvaToSegOffset,
     NULL,
-    NULL,
-    kldrModMachOEnumDbgInfo,
-    kldrModMachOHasDbgInfo,
-    kldrModMachOMap,
-    kldrModMachOUnmap,
-    kldrModMachOAllocTLS,
-    kldrModMachOFreeTLS,
-    kldrModMachOReload,
-    kldrModMachOFixupMapping,
-    kldrModMachOCallInit,
-    kldrModMachOCallTerm,
-    kldrModMachOCallThread,
-    kldrModMachOSize,
-    kldrModMachOGetBits,
-    kldrModMachORelocateBits,
-    NULL, /** @todo mostly done */
-    42 /* the end */
+    rtldrMachO_QueryProp,
+    NULL /*pfnVerifySignature*/,
+    NULL /*pfnHashImage*/,
+    NULL /*pfnUnwindFrame*/,
+    42
 };
 
+
+/**
+ * Handles opening Mach-O images (non-fat).
+ */
+DECLHIDDEN(int) rtldrMachOOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offImage,
+                               PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo)
+{
+
+    /*
+     * Create the instance data and do a minimal header validation.
+     */
+    PKLDRMODMACHO pThis = NULL;
+    int rc = kldrModMachODoCreate(pReader, offImage, fFlags, &pThis, pErrInfo);
+    if (RT_SUCCESS(rc))
+    {
+        /*
+         * Match up against the requested CPU architecture.
+         */
+        if (   enmArch == RTLDRARCH_WHATEVER
+            || pThis->Core.enmArch == enmArch)
+        {
+            pThis->Core.pOps     = &s_rtldrMachOOps;
+            pThis->Core.u32Magic = RTLDRMOD_MAGIC;
+            *phLdrMod = &pThis->Core;
+            return 0;
+        }
+        rc = VERR_LDR_ARCH_MISMATCH;
+    }
+    if (pThis)
+    {
+        RTMemFree(pThis->pbLoadCommands);
+        RTMemFree(pThis);
+    }
+    return rc;
+
+}
+
+
+/**
+ * Handles opening FAT Mach-O image.
+ */
+DECLHIDDEN(int) rtldrFatOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo)
+{
+    fat_header_t FatHdr;
+    int rc = pReader->pfnRead(pReader, &FatHdr, sizeof(FatHdr), 0);
+    if (RT_FAILURE(rc))
+        return RTErrInfoSetF(pErrInfo, rc, "Read error at offset 0: %Rrc", rc);
+
+    if (FatHdr.magic == IMAGE_FAT_SIGNATURE)
+    { /* likely */ }
+    else if (FatHdr.magic == IMAGE_FAT_SIGNATURE_OE)
+        FatHdr.nfat_arch = RT_BSWAP_U32(FatHdr.nfat_arch);
+    else
+        return RTErrInfoSetF(pErrInfo, VERR_INVALID_EXE_SIGNATURE, "magic=%#x", FatHdr.magic);
+    if (FatHdr.nfat_arch < 64)
+        return RTErrInfoSetF(pErrInfo, VERR_INVALID_EXE_SIGNATURE, "Bad nfat_arch value: %#x", FatHdr.nfat_arch);
+
+    uint32_t offEntry = sizeof(FatHdr);
+    for (uint32_t i = 0; i < FatHdr.nfat_arch; i++, offEntry += sizeof(fat_arch_t))
+    {
+        fat_arch_t FatEntry;
+        int rc = pReader->pfnRead(pReader, &FatEntry, sizeof(FatEntry), offEntry);
+        if (RT_FAILURE(rc))
+            return RTErrInfoSetF(pErrInfo, rc, "Read error at offset 0: %Rrc", rc);
+        if (FatHdr.magic == IMAGE_FAT_SIGNATURE_OE)
+        {
+            FatEntry.cputype    = (int32_t)RT_BSWAP_U32((uint32_t)FatEntry.cputype);
+            //FatEntry.cpusubtype = (int32_t)RT_BSWAP_U32((uint32_t)FatEntry.cpusubtype);
+            FatEntry.offset     = RT_BSWAP_U32(FatEntry.offset);
+            //FatEntry.size       = RT_BSWAP_U32(FatEntry.size);
+            //FatEntry.align      = RT_BSWAP_U32(FatEntry.align);
+        }
+
+        /*
+         * Match enmArch.
+         */
+        bool fMatch = false;
+        switch (enmArch)
+        {
+            case RTLDRARCH_WHATEVER:
+                fMatch = true;
+                break;
+
+            case RTLDRARCH_X86_32:
+                fMatch = FatEntry.cputype == CPU_TYPE_X86;
+                break;
+
+            case RTLDRARCH_AMD64:
+                fMatch = FatEntry.cputype == CPU_TYPE_X86_64;
+                break;
+
+            case RTLDRARCH_ARM32:
+            case RTLDRARCH_ARM64:
+            case RTLDRARCH_X86_16:
+                fMatch = false;
+                break;
+
+            case RTLDRARCH_INVALID:
+            case RTLDRARCH_HOST:
+            case RTLDRARCH_END:
+            case RTLDRARCH_32BIT_HACK:
+                AssertFailedReturn(VERR_INVALID_PARAMETER);
+        }
+        if (fMatch)
+            return rtldrMachOOpen(pReader, fFlags, enmArch, FatEntry.offset, phLdrMod, pErrInfo);
+    }
+
+    return VERR_LDR_ARCH_MISMATCH;
+
+}
+
Index: /trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp	(revision 74637)
+++ /trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp	(revision 74638)
@@ -4479,6 +4479,6 @@
  * @param   pErrInfo    Where to return extended error information. Optional.
  */
-int rtldrPEOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offNtHdrs,
-                PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo)
+DECLHIDDEN(int) rtldrPEOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offNtHdrs,
+                            PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo)
 {
     /*
Index: /trunk/src/VBox/Runtime/common/ldr/ldrkStuff.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/ldr/ldrkStuff.cpp	(revision 74637)
+++ /trunk/src/VBox/Runtime/common/ldr/ldrkStuff.cpp	(revision 74638)
@@ -921,5 +921,5 @@
  * @param   pErrInfo    Where to return extended error information. Optional.
  */
-int rtldrkLdrOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo)
+DECLHIDDEN(int) rtldrkLdrOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo)
 {
     RT_NOREF_PV(pErrInfo);
Index: /trunk/src/VBox/Runtime/include/internal/ldr.h
===================================================================
--- /trunk/src/VBox/Runtime/include/internal/ldr.h	(revision 74637)
+++ /trunk/src/VBox/Runtime/include/internal/ldr.h	(revision 74638)
@@ -73,4 +73,5 @@
 #undef IMAGE_DOS_SIGNATURE
 #undef IMAGE_NT_SIGNATURE
+#undef IMAGE_LX_SIGNATURE
 
 
@@ -87,4 +88,51 @@
 /** Little endian uint16_t MZ signature ("MZ"). */
 #define IMAGE_DOS_SIGNATURE ('M' | ('Z' << 8))
+
+
+/** Kind of missing flag. */
+#define RTMEM_PROT_WRITECOPY        RTMEM_PROT_WRITE
+
+
+/** @name Load symbol kind flags (from kStuff, expose later).
+ * @{ */
+/** The bitness doesn't matter. */
+#define RTLDRSYMKIND_NO_BIT                 UINT32_C(0x00000000)
+/** 16-bit symbol. */
+#define RTLDRSYMKIND_16BIT                  UINT32_C(0x00000001)
+/** 32-bit symbol. */
+#define RTLDRSYMKIND_32BIT                  UINT32_C(0x00000002)
+/** 64-bit symbol. */
+#define RTLDRSYMKIND_64BIT                  UINT32_C(0x00000003)
+/** Mask out the bit.*/
+#define RTLDRSYMKIND_BIT_MASK               UINT32_C(0x00000003)
+/** We don't know the type of symbol. */
+#define RTLDRSYMKIND_NO_TYPE                UINT32_C(0x00000000)
+/** The symbol is a code object (method/function/procedure/whateveryouwannacallit). */
+#define RTLDRSYMKIND_CODE                   UINT32_C(0x00000010)
+/** The symbol is a data object. */
+#define RTLDRSYMKIND_DATA                   UINT32_C(0x00000020)
+/** Mask out the symbol type. */
+#define RTLDRSYMKIND_TYPE_MASK              UINT32_C(0x00000030)
+/** Valid symbol kind mask. */
+#define RTLDRSYMKIND_MASK                   UINT32_C(0x00000033)
+/** Weak symbol. */
+#define RTLDRSYMKIND_WEAK                   UINT32_C(0x00000100)
+/** Forwarder symbol. */
+#define RTLDRSYMKIND_FORWARDER              UINT32_C(0x00000200)
+/** Request a flat symbol address. */
+#define RTLDRSYMKIND_REQ_FLAT               UINT32_C(0x00000000)
+/** Request a segmented symbol address. */
+#define RTLDRSYMKIND_REQ_SEGMENTED          UINT32_C(0x40000000)
+/** Request type mask. */
+#define RTLDRSYMKIND_REQ_TYPE_MASK          UINT32_C(0x40000000)
+/** @} */
+
+/** Align a RTLDRADDR value. */
+#define RTLDR_ALIGN_ADDR(val, align) ( ((val) + ((align) - 1)) & ~(RTLDRADDR)((align) - 1) )
+
+/** Special base address value alias for the link address.
+ * Consider propagating...  */
+#define RTLDR_BASEADDRESS_LINK              (~(RTLDRADDR)1)
+
 
 
@@ -108,4 +156,66 @@
     LDR_STATE_32BIT_HACK = 0x7fffffff
 } RTLDRSTATE;
+
+
+/**
+ * CPU models (from kStuff, expose later some time).
+ */
+typedef enum RTLDRCPU
+{
+    /** The usual invalid cpu. */
+    RTLDRCPU_INVALID = 0,
+
+    /** @name K_ARCH_X86_16
+     * @{ */
+    RTLDRCPU_I8086,
+    RTLDRCPU_I8088,
+    RTLDRCPU_I80186,
+    RTLDRCPU_I80286,
+    RTLDRCPU_I386_16,
+    RTLDRCPU_I486_16,
+    RTLDRCPU_I486SX_16,
+    RTLDRCPU_I586_16,
+    RTLDRCPU_I686_16,
+    RTLDRCPU_P4_16,
+    RTLDRCPU_CORE2_16,
+    RTLDRCPU_K6_16,
+    RTLDRCPU_K7_16,
+    RTLDRCPU_K8_16,
+    RTLDRCPU_FIRST_X86_16 = RTLDRCPU_I8086,
+    RTLDRCPU_LAST_X86_16 = RTLDRCPU_K8_16,
+    /** @} */
+
+    /** @name K_ARCH_X86_32
+     * @{ */
+    RTLDRCPU_X86_32_BLEND,
+    RTLDRCPU_I386,
+    RTLDRCPU_I486,
+    RTLDRCPU_I486SX,
+    RTLDRCPU_I586,
+    RTLDRCPU_I686,
+    RTLDRCPU_P4,
+    RTLDRCPU_CORE2_32,
+    RTLDRCPU_K6,
+    RTLDRCPU_K7,
+    RTLDRCPU_K8_32,
+    RTLDRCPU_FIRST_X86_32 = RTLDRCPU_I386,
+    RTLDRCPU_LAST_X86_32 = RTLDRCPU_K8_32,
+    /** @} */
+
+    /** @name K_ARCH_AMD64
+     * @{ */
+    RTLDRCPU_AMD64_BLEND,
+    RTLDRCPU_K8,
+    RTLDRCPU_P4_64,
+    RTLDRCPU_CORE2,
+    RTLDRCPU_FIRST_AMD64 = RTLDRCPU_K8,
+    RTLDRCPU_LAST_AMD64 = RTLDRCPU_CORE2,
+    /** @} */
+
+    /** The end of the valid cpu values (exclusive). */
+    RTLDRCPU_END,
+    /** Hack to blow the type up to 32-bit. */
+    RTLDRCPU_32BIT_HACK = 0x7fffffff
+} RTLDRCPU;
 
 
@@ -498,5 +608,5 @@
  * @param   pErrInfo        Where to return extended error information. Optional.
  */
-int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo);
+DECLHIDDEN(int) rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo);
 
 /**
@@ -509,11 +619,12 @@
  * @param   phLdrMod        Where to return the module handle on success.
  */
-int rtldrNativeLoadSystem(const char *pszFilename, const char *pszExt, uint32_t fFlags, PRTLDRMOD phLdrMod);
-
-int rtldrPEOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offNtHdrs, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
-int rtldrELFOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
-int rtldrkLdrOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
-/*int rtldrLXOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offLX, PRTLDRMOD phLdrMod);
-int rtldrMachoOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offSomething, PRTLDRMOD phLdrMod);*/
+DECLHIDDEN(int) rtldrNativeLoadSystem(const char *pszFilename, const char *pszExt, uint32_t fFlags, PRTLDRMOD phLdrMod);
+
+DECLHIDDEN(int) rtldrPEOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offNtHdrs, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
+DECLHIDDEN(int) rtldrELFOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
+DECLHIDDEN(int) rtldrLXOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offLxHdr, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
+DECLHIDDEN(int) rtldrMachOOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offImage, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
+DECLHIDDEN(int) rtldrFatOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
+DECLHIDDEN(int) rtldrkLdrOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
 
 
Index: /trunk/src/VBox/Runtime/r0drv/darwin/mp-r0drv-darwin.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r0drv/darwin/mp-r0drv-darwin.cpp	(revision 74637)
+++ /trunk/src/VBox/Runtime/r0drv/darwin/mp-r0drv-darwin.cpp	(revision 74638)
@@ -301,4 +301,5 @@
         return VERR_NOT_SUPPORTED;
     IPRT_DARWIN_SAVE_EFL_AC(); /* paranoia */
+    /// @todo use mp_cpus_kick() when available (since 10.10)?  It's probably slower (locks, mask iteration, checks), though...
     g_pfnR0DarwinCpuInterrupt(idCpu);
     IPRT_DARWIN_RESTORE_EFL_AC();
Index: /trunk/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp	(revision 74637)
+++ /trunk/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp	(revision 74638)
@@ -42,5 +42,5 @@
 
 
-int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo)
+DECLHIDDEN(int) rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo)
 {
     /*
@@ -126,5 +126,5 @@
 
 
-int rtldrNativeLoadSystem(const char *pszFilename, const char *pszExt, uint32_t fFlags, PRTLDRMOD phLdrMod)
+DECLHIDDEN(int) rtldrNativeLoadSystem(const char *pszFilename, const char *pszExt, uint32_t fFlags, PRTLDRMOD phLdrMod)
 {
     RT_NOREF_PV(pszFilename); RT_NOREF_PV(pszExt); RT_NOREF_PV(fFlags); RT_NOREF_PV(phLdrMod);
Index: /trunk/src/VBox/Runtime/r3/win/ldrNative-win.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/ldrNative-win.cpp	(revision 74637)
+++ /trunk/src/VBox/Runtime/r3/win/ldrNative-win.cpp	(revision 74638)
@@ -56,5 +56,5 @@
 
 
-int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo)
+DECLHIDDEN(int) rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo)
 {
     Assert(sizeof(*phHandle) >= sizeof(HMODULE));
@@ -176,5 +176,5 @@
 
 
-int rtldrNativeLoadSystem(const char *pszFilename, const char *pszExt, uint32_t fFlags, PRTLDRMOD phLdrMod)
+DECLHIDDEN(int) rtldrNativeLoadSystem(const char *pszFilename, const char *pszExt, uint32_t fFlags, PRTLDRMOD phLdrMod)
 {
     AssertReleaseMsg(g_hModKernel32,
