Index: trunk/src/VBox/ExtPacks/VBoxDTrace/Config.kmk
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/Config.kmk	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/Config.kmk	(revision 53657)
@@ -37,3 +37,5 @@
 VBOXDT_PATH_CMD  = $(VBOXDT_PATH_ONNV)/cmd
 VBOXDT_PATH_LIBCTF    = $(VBOXDT_PATH_ONNV)/lib/libctf
+VBOXDT_PATH_CMN_CTF   = $(VBOXDT_PATH_ONNV)/common/ctf
 VBOXDT_PATH_LIBDTRACE = $(VBOXDT_PATH_ONNV)/lib/libdtrace
+VBOXDT_PATH_CMN_DTRACE= $(VBOXDT_PATH_ONNV)/common/dtrace
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/VBoxDTrace/Makefile.kmk
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/VBoxDTrace/Makefile.kmk	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/VBoxDTrace/Makefile.kmk	(revision 53657)
@@ -34,9 +34,11 @@
 PROGRAMS += VBoxDTrace
 VBoxDTrace_TEMPLATE = VBOXR3NPEXE
+VBoxDTrace_SDKS = VBOX_ZLIB
 VBoxDTrace_INCS = \
 	../include \
 	$(VBOXDT_PATH_UTS)/common \
 	$(VBOXDT_PATH_LIBCTF)/common \
-	$(VBOXDT_PATH_LIBDTRACE)/common
+	$(VBOXDT_PATH_LIBDTRACE)/common \
+	$(VBOXDT_PATH_CMN_CTF)
 VBoxDTrace_SOURCES = \
 	$(VBOXDT_PATH_CMD)/dtrace/dtrace.c \
@@ -73,4 +75,19 @@
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_work.c \
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_xlator.c \
+	\
+	$(VBOXDT_PATH_CMN_CTF)/ctf_create.c \
+	$(VBOXDT_PATH_CMN_CTF)/ctf_error.c \
+	$(VBOXDT_PATH_CMN_CTF)/ctf_decl.c \
+	$(VBOXDT_PATH_CMN_CTF)/ctf_hash.c \
+	$(VBOXDT_PATH_CMN_CTF)/ctf_labels.c \
+	$(VBOXDT_PATH_CMN_CTF)/ctf_lookup.c \
+	$(VBOXDT_PATH_CMN_CTF)/ctf_open.c \
+	$(VBOXDT_PATH_CMN_CTF)/ctf_types.c \
+	$(VBOXDT_PATH_CMN_CTF)/ctf_util.c \
+	\
+	$(VBOXDT_PATH_LIBCTF)/common/ctf_subr.c \
+	$(VBOXDT_PATH_LIBCTF)/common/ctf_lib.c
+
+VBoxDTrace_VBOX_TODO = \
 
 VBoxDTrace_VBOX_TODO = \
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceTypes.h
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceTypes.h	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceTypes.h	(revision 53657)
@@ -151,4 +151,5 @@
 # define EALREADY               (114)
 # define EOVERFLOW              (79)
+# define ENOTSUP                (48)
 #endif
 
@@ -424,5 +425,14 @@
 	} while (0)
 
-#endif
+/*
+ * gelf
+ */
+# include "../../../Runtime/include/internal/ldrELF64.h"
+typedef Elf64_Half GElf_Half;
+typedef Elf64_Shdr GElf_Shdr;
+typedef Elf64_Ehdr GElf_Ehdr;
+typedef Elf64_Sym  GElf_Sym;
+
+#endif /* IN_RING3 */
 
 RT_C_DECLS_END
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_create.c
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_create.c	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_create.c	(revision 53657)
@@ -26,4 +26,5 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
@@ -31,4 +32,6 @@
 #include <sys/param.h>
 #include <sys/mman.h>
+#else  /* VBOX */
+#endif /* VBOX */
 #include <ctf_impl.h>
 
@@ -94,5 +97,5 @@
 		if (dmd->dmd_name) {
 			ctm.ctm_name = soff;
-			soff += strlen(dmd->dmd_name) + 1;
+			soff += VBDTCAST(uint_t)strlen(dmd->dmd_name) + 1;
 		} else
 			ctm.ctm_name = 0;
@@ -117,5 +120,5 @@
 		if (dmd->dmd_name) {
 			ctlm.ctlm_name = soff;
-			soff += strlen(dmd->dmd_name) + 1;
+			soff += VBDTCAST(uint_t)strlen(dmd->dmd_name) + 1;
 		} else
 			ctlm.ctlm_name = 0;
@@ -142,5 +145,5 @@
 		cte.cte_name = soff;
 		cte.cte_value = dmd->dmd_value;
-		soff += strlen(dmd->dmd_name) + 1;
+		soff += VBDTCAST(uint_t)strlen(dmd->dmd_name) + 1;
 		bcopy(&cte, t, sizeof (cte));
 		t += sizeof (cte);
@@ -258,6 +261,6 @@
 	 * bcopy the finished header to the start of the buffer.
 	 */
-	hdr.cth_stroff = hdr.cth_typeoff + size;
-	hdr.cth_strlen = fp->ctf_dtstrlen;
+	hdr.cth_stroff = hdr.cth_typeoff + VBDTCAST(uint_t)size;
+	hdr.cth_strlen = VBDTCAST(uint_t)fp->ctf_dtstrlen;
 	size = sizeof (ctf_header_t) + hdr.cth_stroff + hdr.cth_strlen;
 
@@ -597,5 +600,5 @@
 
 	dtd->dtd_data.ctt_info = CTF_TYPE_INFO(kind, flag, 0);
-	dtd->dtd_data.ctt_size = clp2(P2ROUNDUP(ep->cte_bits, NBBY) / NBBY);
+	dtd->dtd_data.ctt_size = VBDTCAST(ushort_t)clp2(P2ROUNDUP(ep->cte_bits, NBBY) / NBBY);
 	dtd->dtd_u.dtu_enc = *ep;
 
@@ -777,5 +780,5 @@
 
 	dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_ENUM, flag, 0);
-	dtd->dtd_data.ctt_size = fp->ctf_dmodel->ctd_int;
+	dtd->dtd_data.ctt_size = VBDTCAST(ushort_t)fp->ctf_dmodel->ctd_int;
 
 	return (type);
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_decl.c
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_decl.c	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_decl.c	(revision 53657)
@@ -25,5 +25,7 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
+#endif
 
 /*
@@ -177,5 +179,9 @@
 
 	va_start(ap, format);
+#ifndef VBOX
 	n = vsnprintf(cd->cd_ptr, len, format, ap);
+#else
+	n = RTStrPrintfV(cd->cd_ptr, len, format, ap);
+#endif
 	va_end(ap);
 
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_error.c
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_error.c	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_error.c	(revision 53657)
@@ -25,5 +25,7 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
+#endif
 
 #include <ctf_impl.h>
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_hash.c
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_hash.c	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_hash.c	(revision 53657)
@@ -26,5 +26,7 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
+#endif
 
 #include <ctf_impl.h>
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_impl.h
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_impl.h	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_impl.h	(revision 53657)
@@ -29,4 +29,5 @@
 #define	_CTF_IMPL_H
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
@@ -34,11 +35,18 @@
 #include <sys/errno.h>
 #include <sys/sysmacros.h>
+#else  /* VBOX */
+# include "../../../../../Runtime/include/internal/ldrELF32.h"
+# include "../../../../../Runtime/include/internal/ldrELF64.h"
+# include <errno.h>
+#endif /* VBOX */
 #include <sys/ctf_api.h>
 
 #ifdef _KERNEL
 
+#ifndef VBOX
 #include <sys/systm.h>
 #include <sys/cmn_err.h>
 #include <sys/varargs.h>
+#endif
 
 #define	isspace(c) \
@@ -50,4 +58,5 @@
 #else	/* _KERNEL */
 
+#ifndef VBOX
 #include <strings.h>
 #include <stdlib.h>
@@ -56,4 +65,5 @@
 #include <limits.h>
 #include <ctype.h>
+#endif
 
 #endif	/* _KERNEL */
@@ -330,4 +340,10 @@
 extern int _libctf_debug;		/* debugging messages enabled */
 
+#ifdef VBOX
+# ifndef MAP_FAILED /* returned by ctf_data_alloc on failure. */
+#  define MAP_FAILED ((void *)~(uintptr_t)0)
+# endif
+#endif
+
 #ifdef	__cplusplus
 }
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_labels.c
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_labels.c	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_labels.c	(revision 53657)
@@ -25,5 +25,7 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
+#endif
 
 #include <ctf_impl.h>
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_lookup.c
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_lookup.c	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_lookup.c	(revision 53657)
@@ -26,7 +26,11 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
 #include <sys/sysmacros.h>
+#else  /* VBOX */
+# include <ctype.h>
+#endif /* VBOX */
 #include <ctf_impl.h>
 
@@ -198,5 +202,5 @@
 	}
 
-	if (fp->ctf_sxlate[symidx] == -1u)
+	if (fp->ctf_sxlate[symidx] == ~0u /*VBOX: -1u*/)
 		return (ctf_set_errno(fp, ECTF_NOTYPEDAT));
 
@@ -261,5 +265,5 @@
 	}
 
-	if (fp->ctf_sxlate[symidx] == -1u)
+	if (fp->ctf_sxlate[symidx] == ~0u /*VBOX: -1u*/)
 		return (ctf_set_errno(fp, ECTF_NOFUNCDAT));
 
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_open.c
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_open.c	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_open.c	(revision 53657)
@@ -26,9 +26,20 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
-
+#endif
+
+#ifndef VBOX
 #include <ctf_impl.h>
 #include <sys/mman.h>
 #include <sys/zmod.h>
+#else  /* VBOX */
+# define CTF_OLD_VERSIONS
+# include <ctf_impl.h>
+# include <zlib.h>
+# define z_compress     compress
+# define z_uncompress   uncompress
+# define z_strerror     zError
+#endif /* VBOX */
 
 static const ctf_dmodel_t _libctf_models[] = {
@@ -143,5 +154,5 @@
 		    strcmp(name, "_START_") == 0 ||
 		    strcmp(name, "_END_") == 0) {
-			*xp = -1u;
+			*xp = ~0u /*VBOX: -1u*/;
 			continue;
 		}
@@ -151,5 +162,5 @@
 			if (objtoff >= hp->cth_funcoff ||
 			    (gsp->st_shndx == SHN_ABS && gsp->st_value == 0)) {
-				*xp = -1u;
+				*xp = ~0u /*VBOX: -1u*/;
 				break;
 			}
@@ -161,5 +172,5 @@
 		case STT_FUNC:
 			if (funcoff >= hp->cth_typeoff) {
-				*xp = -1u;
+				*xp = ~0u /*VBOX: -1u*/;
 				break;
 			}
@@ -183,5 +194,5 @@
 
 		default:
-			*xp = -1u;
+			*xp = ~0u /*VBOX: -1u*/;
 			break;
 		}
@@ -632,10 +643,17 @@
 	 */
 	if (hp.cth_flags & CTF_F_COMPRESS) {
+#ifndef VBOX
 		size_t srclen, dstlen;
+#else
+		uLong srclen;
+		uLong dstlen;
+#endif
 		const void *src;
 		int rc = Z_OK;
 
+#ifndef VBOX
 		if (ctf_zopen(errp) == NULL)
 			return (NULL); /* errp is set for us */
+#endif
 
 		if ((base = ctf_data_alloc(size + hdrsz)) == MAP_FAILED)
@@ -647,6 +665,6 @@
 
 		src = (uchar_t *)ctfsect->cts_data + hdrsz;
-		srclen = ctfsect->cts_size - hdrsz;
-		dstlen = size;
+		srclen = VBDTCAST(uLong)(ctfsect->cts_size - hdrsz);
+		dstlen = VBDTCAST(uLong)size;
 
 		if ((rc = z_uncompress(buf, &dstlen, src, srclen)) != Z_OK) {
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_types.c
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_types.c	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_types.c	(revision 53657)
@@ -26,5 +26,7 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
+#endif
 
 #include <ctf_impl.h>
@@ -310,5 +312,5 @@
 {
 	ssize_t rv = ctf_type_lname(fp, type, buf, len);
-	return (rv >= 0 && rv < len ? buf : NULL);
+	return (rv >= 0 && VBDTCAST(size_t)rv < len ? buf : NULL);
 }
 
@@ -406,5 +408,5 @@
 			for (; n != 0; n--, mp++) {
 				ssize_t am = ctf_type_align(fp, mp->ctm_type);
-				align = MAX(align, am);
+				align = MAX(VBDTCAST(ssize_t)align, am);
 			}
 		} else {
@@ -412,5 +414,5 @@
 			for (; n != 0; n--, lmp++) {
 				ssize_t am = ctf_type_align(fp, lmp->ctlm_type);
-				align = MAX(align, am);
+				align = MAX(VBDTCAST(ssize_t)align, am);
 			}
 		}
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_util.c
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_util.c	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/common/ctf/ctf_util.c	(revision 53657)
@@ -25,5 +25,7 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
+#endif
 
 #include <ctf_impl.h>
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_lib.c
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_lib.c	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_lib.c	(revision 53657)
@@ -25,4 +25,5 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
@@ -36,5 +37,23 @@
 #include <dlfcn.h>
 #include <gelf.h>
-
+#else
+# include <libctf.h>
+# include <ctf_impl.h>
+# include <iprt/param.h>
+# include <sys/stat.h>
+# include <stdio.h>
+# include <fcntl.h>
+# ifdef _MSC_VER
+#  include <io.h>
+# else
+#  include <unistd.h>
+# endif
+# define stat64  stat
+# define fstat64 fstat
+# define open64  open
+# define off64_t int64_t
+#endif
+
+#ifndef VBOX /* staticly linked in */
 #ifdef _LP64
 static const char *_libctf_zlib = "/usr/lib/64/libz.so";
@@ -48,22 +67,117 @@
 	void *z_dlp;
 } zlib;
+#endif /* !VBOX */
 
 static size_t _PAGESIZE;
 static size_t _PAGEMASK;
 
+#ifndef VBOX
 #pragma init(_libctf_init)
 void
 _libctf_init(void)
-{
+#else
+void libctf_init(void)
+#endif
+{
+#ifndef VBOX
 	const char *p = getenv("LIBCTF_DECOMPRESSOR");
 
 	if (p != NULL)
 		_libctf_zlib = p; /* use alternate decompression library */
+#endif
 
 	_libctf_debug = getenv("LIBCTF_DEBUG") != NULL;
 
+#ifndef VBOX
 	_PAGESIZE = getpagesize();
+#else
+	_PAGESIZE = PAGE_SIZE;
+#endif
 	_PAGEMASK = ~(_PAGESIZE - 1);
 }
+
+#ifdef VBOX
+/*
+ * Fake MMAP for read only access.
+ */
+# define munmap(a_pvMem, a_cbMem) \
+	RTMemPageFree(a_pvMem, a_cbMem)
+
+# define mmap64(a_pvAddr, a_cb, a_fProt, a_fFlags, a_fd, a_offFile) \
+	VBoxCtfMap64Fake(a_pvAddr, a_cb, a_fProt, a_fFlags, a_fd, a_offFile)
+
+# undef PROT_READ
+# define PROT_READ 		0xfeed
+# undef MAP_PRIVATE
+# define MAP_PRIVATE	0xbeef
+
+static void *VBoxCtfMap64Fake(void *pvAddr, size_t cb, int fProt, int fFlags, int fd, int64_t offFile)
+{
+	off_t const offSaved = lseek(fd, 0, SEEK_CUR);
+	void *pvRet;
+	int err;
+
+	Assert(pvAddr == NULL); NOREF(pvAddr);
+	Assert(fProt == PROT_READ);
+	Assert(fFlags == MAP_PRIVATE);
+	if ((off_t)offFile != offFile) {
+		errno = EIO;
+		return MAP_FAILED;
+	}
+
+	if (lseek(offFile, offFile, SEEK_SET) >= 0) {
+
+		pvRet = RTMemPageAllocZ(cb);
+		if (!pvRet) {
+#ifdef _MSC_VER
+			ssize_t cbRead = read(fd, pvRet, (unsigned int)cb);
+#else
+			ssize_t cbRead = read(fd, pvRet, cb);
+#endif
+			if (cbRead < 0) {
+				RTMemPageFree(pvRet, cb);
+				pvRet = MAP_FAILED;
+			}
+		} else {
+			errno = ENOMEM;
+			pvRet = MAP_FAILED;
+		}
+
+		/* restore original position */
+		err = errno;
+		lseek(offSaved, 0, SEEK_SET);
+		errno = err;
+	}
+
+	return pvRet;
+}
+
+/*
+ * pread64
+ */
+#define pread64(a_fd, a_pvBuf, a_cbToRead, a_offFile) \
+	VBoxCtfPRead64(a_fd, a_pvBuf, a_cbToRead, a_offFile)
+
+static ssize_t VBoxCtfPRead64(int fd, void *pvBuf, size_t cbToRead, int64_t offFile)
+{
+	if ((off_t)offFile != offFile) {
+		errno = EIO;
+		return -1;
+	}
+
+	if (lseek(fd, offFile, SEEK_SET) < 0)
+		return -1;
+#ifndef _MSC_VER
+	return read(fd, pvBuf, cbToRead);
+#else
+	return read(fd, pvBuf, (unsigned int)cbToRead);
+#endif
+}
+
+
+
+#endif /* VBOX */
+
+#ifndef VBOX
 
 /*
@@ -113,4 +227,6 @@
 	return (zlib.z_error(err));
 }
+
+#endif /* VBOX */
 
 /*
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_subr.c
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_subr.c	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/ctf_subr.c	(revision 53657)
@@ -25,16 +25,28 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
+#endif
 
 #include <ctf_impl.h>
 #include <libctf.h>
+#ifndef VBOX
 #include <sys/mman.h>
 #include <stdarg.h>
+#else
+# include <iprt/asm.h>
+# include <iprt/log.h>
+#endif
 
 void *
 ctf_data_alloc(size_t size)
 {
+#ifndef VBOX
 	return (mmap(NULL, size, PROT_READ | PROT_WRITE,
 	    MAP_PRIVATE | MAP_ANON, -1, 0));
+#else
+    void *pv = RTMemPageAlloc(size);
+    return pv == NULL ? MAP_FAILED : pv;
+#endif
 }
 
@@ -42,5 +54,9 @@
 ctf_data_free(void *buf, size_t size)
 {
+#ifndef VBOX
 	(void) munmap(buf, size);
+#else
+    RTMemPageFree(buf, size);
+#endif
 }
 
@@ -48,5 +64,10 @@
 ctf_data_protect(void *buf, size_t size)
 {
+#ifndef VBOX
 	(void) mprotect(buf, size, PROT_READ);
+#else
+    int rc = RTMemProtect(buf, size, RTMEM_PROT_READ);
+    AssertRC(rc);
+#endif
 }
 
@@ -54,5 +75,9 @@
 ctf_alloc(size_t size)
 {
+#ifndef VBOX
 	return (malloc(size));
+#else
+    return RTMemAlloc(size);
+#endif
 }
 
@@ -61,5 +86,9 @@
 ctf_free(void *buf, size_t size)
 {
+#ifndef VBOX
 	free(buf);
+#else
+    RTMemFree(buf);
+#endif
 }
 
@@ -78,6 +107,10 @@
 
 		va_start(alist, format);
+#ifndef VBOX
 		(void) fputs("libctf DEBUG: ", stderr);
 		(void) vfprintf(stderr, format, alist);
+#else
+        RTLogPrintf("libctf DEBUG: %N", format, alist);
+#endif
 		va_end(alist);
 	}
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/libctf.h
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/libctf.h	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libctf/common/libctf.h	(revision 53657)
@@ -56,4 +56,8 @@
 extern int _libctf_debug;
 
+#ifdef VBOX
+extern void libctf_init(void);
+#endif
+
 #ifdef	__cplusplus
 }
Index: trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_open.c
===================================================================
--- trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_open.c	(revision 53656)
+++ trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_open.c	(revision 53657)
@@ -686,4 +686,5 @@
 #ifdef VBOX
 # include <iprt/critsect.h>
+# include <libctf.h>
 extern RTCRITSECT dt_qsort_lock; /* dt_aggregate.c */
 
@@ -703,4 +704,6 @@
 	}
 #else
+
+	libctf_init();
 	RTCritSectInit(&dt_qsort_lock);
 #endif
