Index: trunk/src/VBox/Runtime/Makefile.kmk
===================================================================
--- trunk/src/VBox/Runtime/Makefile.kmk	(revision 5422)
+++ trunk/src/VBox/Runtime/Makefile.kmk	(revision 5423)
@@ -77,31 +77,31 @@
 #
 RuntimeWin64ASM_SOURCES = \
-	win64/ASMAtomicBitClear.asm \
-	win64/ASMAtomicBitTestAndToggle.asm \
-	win64/ASMAtomicBitToggle.asm \
-	win64/ASMAtomicReadU64.asm \
-	win64/ASMAtomicXchgU16.asm \
-	win64/ASMAtomicXchgU8.asm \
-	win64/ASMBitFirstClear.asm \
-	win64/ASMBitFirstSet.asm \
-	win64/ASMGetCS.asm \
-	win64/ASMGetDS.asm \
-	win64/ASMGetES.asm \
-	win64/ASMGetFlags.asm \
-	win64/ASMGetFS.asm \
-	win64/ASMGetGS.asm \
-	win64/ASMGetIDTR.asm \
-	win64/ASMGetGDTR.asm \
-	win64/ASMGetTR.asm \
-	win64/ASMGetSS.asm \
-	win64/ASMProbeReadByte.asm \
-	win64/ASMSetFlags.asm \
-	win64/ASMGetDR0.asm \
-	win64/ASMGetDR1.asm \
-	win64/ASMGetDR2.asm \
-	win64/ASMGetDR3.asm \
-	win64/ASMGetDR6.asm \
-	win64/ASMGetDR7.asm \
-	win64/ASMMultU64ByU32DivByU32.asm \
+	win/amd64/ASMAtomicBitClear.asm \
+	win/amd64/ASMAtomicBitTestAndToggle.asm \
+	win/amd64/ASMAtomicBitToggle.asm \
+	win/amd64/ASMAtomicReadU64.asm \
+	win/amd64/ASMAtomicXchgU16.asm \
+	win/amd64/ASMAtomicXchgU8.asm \
+	win/amd64/ASMBitFirstClear.asm \
+	win/amd64/ASMBitFirstSet.asm \
+	win/amd64/ASMGetCS.asm \
+	win/amd64/ASMGetDS.asm \
+	win/amd64/ASMGetES.asm \
+	win/amd64/ASMGetFlags.asm \
+	win/amd64/ASMGetFS.asm \
+	win/amd64/ASMGetGS.asm \
+	win/amd64/ASMGetIDTR.asm \
+	win/amd64/ASMGetGDTR.asm \
+	win/amd64/ASMGetTR.asm \
+	win/amd64/ASMGetSS.asm \
+	win/amd64/ASMProbeReadByte.asm \
+	win/amd64/ASMSetFlags.asm \
+	win/amd64/ASMGetDR0.asm \
+	win/amd64/ASMGetDR1.asm \
+	win/amd64/ASMGetDR2.asm \
+	win/amd64/ASMGetDR3.asm \
+	win/amd64/ASMGetDR6.asm \
+	win/amd64/ASMGetDR7.asm \
+	win/amd64/ASMMultU64ByU32DivByU32.asm \
 
 #
@@ -241,5 +241,5 @@
 	generic/rand-stubs-generic.cpp \
 	nt/RTErrConvertFromNtStatus.cpp \
-	win32/errmsgwin.cpp \
+	win/errmsgwin.cpp \
 	r3/posix/env-posix.cpp \
 	r3/win32/alloc-win32.cpp \
@@ -261,5 +261,5 @@
 	r3/win32/uuid-win32.cpp \
 	common/time/timesup.cpp \
-	win32/RTErrConvertFromWin32.cpp
+	win/RTErrConvertFromWin32.cpp
 
 RuntimeR3_SOURCES.win.amd64 = \
@@ -1052,6 +1052,6 @@
 common/err/errmsg.cpp_INCS = $(PATH_TARGET)
 
-win32/errmsgwin.cpp_DEPS = $(PATH_TARGET)/errmsgcomdata.h
-win32/errmsgwin.cpp_INCS = $(PATH_TARGET)
+win/errmsgwin.cpp_DEPS = $(PATH_TARGET)/errmsgcomdata.h
+win/errmsgwin.cpp_INCS = $(PATH_TARGET)
 
 
Index: trunk/src/VBox/Runtime/win/RTErrConvertFromWin32.cpp
===================================================================
--- trunk/src/VBox/Runtime/win/RTErrConvertFromWin32.cpp	(revision 5423)
+++ trunk/src/VBox/Runtime/win/RTErrConvertFromWin32.cpp	(revision 5423)
@@ -0,0 +1,395 @@
+/* $Id$ */
+/** @file
+ * innotek Portable Runtime - Convert win32 error codes to iprt status codes.
+ */
+
+/*
+ * Copyright (C) 2006-2007 innotek GmbH
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation,
+ * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+ * distribution. VirtualBox OSE is distributed in the hope that it will
+ * be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <Windows.h>
+
+#include <iprt/err.h>
+#include <iprt/assert.h>
+#include <iprt/err.h>
+
+
+RTR3DECL(int)  RTErrConvertFromWin32(unsigned uNativeCode)
+{
+    /* very fast check for no error. */
+    if (uNativeCode == ERROR_SUCCESS)
+        return(VINF_SUCCESS);
+
+    /* process error codes. */
+    switch (uNativeCode)
+    {
+        case ERROR_INVALID_FUNCTION:        return VERR_INVALID_FUNCTION;
+        case ERROR_FILE_NOT_FOUND:          return VERR_FILE_NOT_FOUND;
+        case ERROR_PATH_NOT_FOUND:          return VERR_PATH_NOT_FOUND;
+        case ERROR_TOO_MANY_OPEN_FILES:     return VERR_TOO_MANY_OPEN_FILES;
+        case ERROR_ACCESS_DENIED:           return VERR_ACCESS_DENIED;
+
+        case ERROR_INVALID_HANDLE:
+        case ERROR_DIRECT_ACCESS_HANDLE:    return VERR_INVALID_HANDLE;
+
+        case ERROR_NO_SYSTEM_RESOURCES: /** @todo better translation */
+        case ERROR_NOT_ENOUGH_MEMORY:
+        case ERROR_OUTOFMEMORY:             return VERR_NO_MEMORY;
+
+        case ERROR_INVALID_DRIVE:           return VERR_INVALID_DRIVE;
+        case ERROR_CURRENT_DIRECTORY:       return VERR_CANT_DELETE_DIRECTORY;
+        case ERROR_NOT_SAME_DEVICE:         return VERR_NOT_SAME_DEVICE;
+        case ERROR_NO_MORE_FILES:           return VERR_NO_MORE_FILES;
+        case ERROR_WRITE_PROTECT:           return VERR_WRITE_PROTECT;
+        case ERROR_BAD_UNIT:                return VERR_IO_BAD_UNIT;
+        case ERROR_NOT_READY:               return VERR_IO_NOT_READY;
+        case ERROR_BAD_COMMAND:             return VERR_IO_BAD_COMMAND;
+        case ERROR_CRC:                     return VERR_IO_CRC;
+        case ERROR_BAD_LENGTH:              return VERR_IO_BAD_LENGTH;
+        case ERROR_SEEK:                    return VERR_SEEK;
+        case ERROR_NOT_DOS_DISK:            return VERR_DISK_INVALID_FORMAT;
+        case ERROR_SECTOR_NOT_FOUND:        return VERR_IO_SECTOR_NOT_FOUND;
+        case ERROR_WRITE_FAULT:             return VERR_WRITE_ERROR;
+        case ERROR_READ_FAULT:              return VERR_READ_ERROR;
+        case ERROR_GEN_FAILURE:             return VERR_IO_GEN_FAILURE;
+        case ERROR_SHARING_VIOLATION:       return VERR_SHARING_VIOLATION;
+        case ERROR_LOCK_VIOLATION:          return VERR_FILE_LOCK_VIOLATION;
+        case ERROR_HANDLE_EOF:              return VERR_EOF;
+        case ERROR_NOT_LOCKED:              return VERR_FILE_NOT_LOCKED;
+        case ERROR_DIR_NOT_EMPTY:           return VERR_DIR_NOT_EMPTY;
+
+        case ERROR_HANDLE_DISK_FULL:
+        case ERROR_DISK_FULL:               return VERR_DISK_FULL;
+
+        case ERROR_NOT_SUPPORTED:           return VERR_NOT_SUPPORTED;
+
+        case ERROR_INVALID_PARAMETER:
+        case ERROR_BAD_ARGUMENTS:
+        case ERROR_INVALID_FLAGS:           return VERR_INVALID_PARAMETER;
+
+        case ERROR_REM_NOT_LIST:            return VERR_NET_IO_ERROR;
+
+        case ERROR_BAD_NETPATH:
+        case ERROR_NETNAME_DELETED:         return VERR_NET_HOST_NOT_FOUND;
+
+        case ERROR_BAD_NET_NAME:
+        case ERROR_DEV_NOT_EXIST:           return VERR_NET_PATH_NOT_FOUND;
+
+        case ERROR_NETWORK_BUSY:
+        case ERROR_TOO_MANY_CMDS:
+        case ERROR_TOO_MANY_NAMES:
+        case ERROR_TOO_MANY_SESS:
+        case ERROR_OUT_OF_STRUCTURES:       return VERR_NET_OUT_OF_RESOURCES;
+
+        case ERROR_PRINTQ_FULL:
+        case ERROR_NO_SPOOL_SPACE:
+        case ERROR_PRINT_CANCELLED:         return VERR_NET_PRINT_ERROR;
+
+        case ERROR_DUP_NAME:
+        case ERROR_ADAP_HDW_ERR:
+        case ERROR_BAD_NET_RESP:
+        case ERROR_UNEXP_NET_ERR:
+        case ERROR_BAD_REM_ADAP:
+        case ERROR_NETWORK_ACCESS_DENIED:
+        case ERROR_BAD_DEV_TYPE:
+        case ERROR_SHARING_PAUSED:
+        case ERROR_REQ_NOT_ACCEP:
+        case ERROR_REDIR_PAUSED:
+        case ERROR_ALREADY_ASSIGNED:
+        case ERROR_INVALID_PASSWORD:
+        case ERROR_NET_WRITE_FAULT:         return VERR_NET_IO_ERROR;
+
+        case ERROR_FILE_EXISTS:
+        case ERROR_ALREADY_EXISTS:          return VERR_ALREADY_EXISTS;
+
+        case ERROR_CANNOT_MAKE:             return VERR_CANT_CREATE;
+        case ERROR_NO_PROC_SLOTS:           return VERR_MAX_PROCS_REACHED;
+        case ERROR_TOO_MANY_SEMAPHORES:     return VERR_TOO_MANY_SEMAPHORES;
+        case ERROR_EXCL_SEM_ALREADY_OWNED:  return VERR_EXCL_SEM_ALREADY_OWNED;
+        case ERROR_SEM_IS_SET:              return VERR_SEM_IS_SET;
+        case ERROR_TOO_MANY_SEM_REQUESTS:   return VERR_TOO_MANY_SEM_REQUESTS;
+        case ERROR_SEM_OWNER_DIED:          return VERR_SEM_OWNER_DIED;
+        case ERROR_DRIVE_LOCKED:            return VERR_DRIVE_LOCKED;
+        case ERROR_BROKEN_PIPE:             return VERR_BROKEN_PIPE;
+        case ERROR_OPEN_FAILED:             return VERR_OPEN_FAILED;
+
+        case ERROR_BUFFER_OVERFLOW:
+        case ERROR_INSUFFICIENT_BUFFER:     return VERR_BUFFER_OVERFLOW;
+
+        case ERROR_NO_MORE_SEARCH_HANDLES:  return VERR_NO_MORE_SEARCH_HANDLES;
+
+        case ERROR_SEM_TIMEOUT:
+        case WAIT_TIMEOUT:
+        case ERROR_SERVICE_REQUEST_TIMEOUT:
+        case ERROR_COUNTER_TIMEOUT:
+        case ERROR_TIMEOUT:                 return VERR_TIMEOUT;
+
+        case ERROR_INVALID_NAME:
+        case ERROR_BAD_PATHNAME:            return VERR_INVALID_NAME;
+
+        case ERROR_NEGATIVE_SEEK:           return VERR_NEGATIVE_SEEK;
+        case ERROR_SEEK_ON_DEVICE:          return VERR_SEEK_ON_DEVICE;
+
+        case ERROR_SIGNAL_REFUSED:
+        case ERROR_NO_SIGNAL_SENT:          return VERR_SIGNAL_REFUSED;
+
+        case ERROR_SIGNAL_PENDING:          return VERR_SIGNAL_PENDING;
+        case ERROR_MAX_THRDS_REACHED:       return VERR_MAX_THRDS_REACHED;
+        case ERROR_LOCK_FAILED:             return VERR_FILE_LOCK_FAILED;
+        case ERROR_SEM_NOT_FOUND:           return VERR_SEM_NOT_FOUND;
+        case ERROR_FILENAME_EXCED_RANGE:    return VERR_FILENAME_TOO_LONG;
+        case ERROR_INVALID_SIGNAL_NUMBER:   return VERR_SIGNAL_INVALID;
+
+        case ERROR_BAD_PIPE:                return VERR_BAD_PIPE;
+        case ERROR_PIPE_BUSY:               return VERR_PIPE_BUSY;
+        case ERROR_NO_DATA:                 return VERR_NO_DATA;
+        case ERROR_PIPE_NOT_CONNECTED:      return VERR_PIPE_NOT_CONNECTED;
+        case ERROR_MORE_DATA:               return VERR_MORE_DATA;
+        case ERROR_NOT_OWNER:               return VERR_NOT_OWNER;
+        case ERROR_TOO_MANY_POSTS:          return VERR_TOO_MANY_POSTS;
+
+        case ERROR_PIPE_CONNECTED:
+        case ERROR_PIPE_LISTENING:          return VERR_PIPE_IO_ERROR;
+
+        case ERROR_OPERATION_ABORTED:       return VERR_INTERRUPTED;
+        case ERROR_NO_UNICODE_TRANSLATION:  return VERR_NO_TRANSLATION;
+
+        case RPC_S_INVALID_STRING_UUID:     return VERR_INVALID_UUID_FORMAT;
+
+        case ERROR_PROC_NOT_FOUND:          return VERR_SYMBOL_NOT_FOUND;
+        case ERROR_MOD_NOT_FOUND:           return VERR_MODULE_NOT_FOUND;
+
+        case ERROR_INVALID_EXE_SIGNATURE:   return VERR_INVALID_EXE_SIGNATURE;
+        case ERROR_BAD_EXE_FORMAT:          return VERR_BAD_EXE_FORMAT;
+        case ERROR_RESOURCE_DATA_NOT_FOUND: return VERR_NO_DATA; ///@todo fix ERROR_RESOURCE_DATA_NOT_FOUND translation
+        case ERROR_INVALID_ADDRESS:         return VERR_INVALID_POINTER; ///@todo fix ERROR_INVALID_ADDRESS translation - dbghelp returns it on some line number queries.
+
+        case ERROR_CANCELLED:               return VERR_CANCELLED;
+
+        /*
+         * Winsocket errors are mostly BSD errno.h wrappers.
+         * This is copied from RTErrConvertFromErrno() and checked against winsock.h.
+         * Please, keep things in sync!
+         */
+#ifdef WSAEPERM
+        case WSAEPERM:             return VERR_ACCESS_DENIED;                      /*   1 */
+#endif
+#ifdef WSAENOENT
+        case WSAENOENT:            return VERR_FILE_NOT_FOUND;
+#endif
+#ifdef WSAESRCH
+        case WSAESRCH:             return VERR_PROCESS_NOT_FOUND;
+#endif
+        case WSAEINTR:             return VERR_INTERRUPTED;
+#ifdef WSAEIO
+        case WSAEIO:               return VERR_DEV_IO_ERROR;
+#endif
+#ifdef WSAE2BIG
+        case WSAE2BIG:             return VERR_TOO_MUCH_DATA;
+#endif
+#ifdef WSAENOEXEC
+        case WSAENOEXEC:           return VERR_BAD_EXE_FORMAT;
+#endif
+        case WSAEBADF:             return VERR_INVALID_HANDLE;
+#ifdef WSAECHILD
+        case WSAECHILD:            return VERR_PROCESS_NOT_FOUND; //...            /*  10 */
+#endif
+        case WSAEWOULDBLOCK:       return VERR_TRY_AGAIN; /* EAGAIN */
+#ifdef WSAENOMEM
+        case WSAENOMEM:            return VERR_NO_MEMORY;
+#endif
+        case WSAEACCES:            return VERR_ACCESS_DENIED;
+        case WSAEFAULT:            return VERR_INVALID_POINTER;
+        //case WSAENOTBLK:           return VERR_;
+#ifdef WSAEBUSY
+        case WSAEBUSY:             return VERR_DEV_IO_ERROR;
+#endif
+#ifdef WSAEEXIST
+        case WSAEEXIST:            return VERR_ALREADY_EXISTS;
+#endif
+        //case WSAEXDEV:
+#ifdef WSAENODEV
+        case WSAENODEV:            return VERR_NOT_SUPPORTED;
+#endif
+#ifdef WSAENOTDIR
+        case WSAENOTDIR:           return VERR_PATH_NOT_FOUND;                     /*  20 */
+#endif
+#ifdef WSAEISDIR
+        case WSAEISDIR:            return VERR_FILE_NOT_FOUND;
+#endif
+        case WSAEINVAL:            return VERR_INVALID_PARAMETER;
+#ifdef WSAENFILE
+        case WSAENFILE:            return VERR_TOO_MANY_OPEN_FILES;
+#endif
+        case WSAEMFILE:            return VERR_TOO_MANY_OPEN_FILES;
+#ifdef WSAENOTTY
+        case WSAENOTTY:            return VERR_INVALID_FUNCTION;
+#endif
+#ifdef WSAETXTBSY
+        case WSAETXTBSY:           return VERR_SHARING_VIOLATION;
+#endif
+        //case WSAEFBIG:
+#ifdef WSAENOSPC
+        case WSAENOSPC:            return VERR_DISK_FULL;
+#endif
+#ifdef WSAESPIPE
+        case WSAESPIPE:            return VERR_SEEK_ON_DEVICE;
+#endif
+#ifdef WSAEROFS
+        case WSAEROFS:             return VERR_WRITE_PROTECT;                      /*  30 */
+#endif
+        //case WSAEMLINK:
+#ifdef WSAEPIPE
+        case WSAEPIPE:             return VERR_BROKEN_PIPE;
+#endif
+#ifdef WSAEDOM
+        case WSAEDOM:              return VERR_INVALID_PARAMETER;
+#endif
+#ifdef WSAERANGE
+        case WSAERANGE:            return VERR_INVALID_PARAMETER;
+#endif
+#ifdef WSAEDEADLK
+        case WSAEDEADLK:           return VERR_DEADLOCK;
+#endif
+        case WSAENAMETOOLONG:      return VERR_FILENAME_TOO_LONG;
+#ifdef WSAENOLCK
+        case WSAENOLCK:            return VERR_FILE_LOCK_FAILED;
+#endif
+#ifdef WSAENOSYS
+        case WSAENOSYS:            return VERR_NOT_SUPPORTED;
+#endif
+        case WSAENOTEMPTY:         return VERR_CANT_DELETE_DIRECTORY;
+        case WSAELOOP:             return VERR_TOO_MANY_SYMLINKS;                  /*  40 */
+        //case WSAENOMSG		42	/* No message of desired type */
+        //case WSAEIDRM		43	/* Identifier removed */
+        //case WSAECHRNG		44	/* Channel number out of range */
+        //case WSAEL2NSYNC	45	/* Level 2 not synchronized */
+        //case WSAEL3HLT		46	/* Level 3 halted */
+        //case WSAEL3RST		47	/* Level 3 reset */
+        //case WSAELNRNG		48	/* Link number out of range */
+        //case WSAEUNATCH		49	/* Protocol driver not attached */
+        //case WSAENOCSI		50	/* No CSI structure available */
+        //case WSAEL2HLT		51	/* Level 2 halted */
+        //case WSAEBADE		52	/* Invalid exchange */
+        //case WSAEBADR		53	/* Invalid request descriptor */
+        //case WSAEXFULL		54	/* Exchange full */
+        //case WSAENOANO		55	/* No anode */
+        //case WSAEBADRQC		56	/* Invalid request code */
+        //case WSAEBADSLT		57	/* Invalid slot */
+        //case 58:
+        //case WSAEBFONT		59	/* Bad font file format */
+        //case WSAENOSTR		60	/* Device not a stream */
+#ifdef WSAENODATA
+        case WSAENODATA:           return  VERR_NO_DATA;
+#endif
+        //case WSAETIME		62	/* Timer expired */
+        //case WSAENOSR		63	/* Out of streams resources */
+#ifdef WSAENONET
+        case WSAENONET:            return VERR_NET_NO_NETWORK;
+#endif
+        //case WSAENOPKG		65	/* Package not installed */
+         //case WSAEREMOTE		66	/* Object is remote */
+        //case WSAENOLINK		67	/* Link has been severed */
+        //case WSAEADV		68	/* Advertise error */
+        //case WSAESRMNT		69	/* Srmount error */
+        //case WSAECOMM		70	/* Communication error on send */
+        //case WSAEPROTO		71	/* Protocol error */
+        //case WSAEMULTIHOP	72	/* Multihop attempted */
+        //case WSAEDOTDOT		73	/* RFS specific error */
+        //case WSAEBADMSG		74	/* Not a data message */
+#ifdef WSAEOVERFLOW
+        case WSAEOVERFLOW:         return VERR_TOO_MUCH_DATA;
+#endif
+#ifdef WSAENOTUNIQ
+        case WSAENOTUNIQ:          return VERR_NET_NOT_UNIQUE_NAME;
+#endif
+#ifdef WSAEBADFD
+        case WSAEBADFD:            return VERR_INVALID_HANDLE;
+#endif
+        //case WSAEREMCHG		78	/* Remote address changed */
+        //case WSAELIBACC		79	/* Can not access a needed shared library */
+        //case WSAELIBBAD		80	/* Accessing a corrupted shared library */
+        //case WSAELIBSCN		81	/* .lib section in a.out corrupted */
+        //case WSAELIBMAX		82	/* Attempting to link in too many shared libraries */
+        //case WSAELIBEXEC	83	/* Cannot exec a shared library directly */
+#ifdef WSAEILSEQ
+        case WSAEILSEQ:            return VERR_NO_TRANSLATION;
+#endif
+#ifdef WSAERESTART
+        case WSAERESTART:          return VERR_INTERRUPTED;
+#endif
+        //case WSAESTRPIPE	86	/* Streams pipe error */
+        //case WSAEUSERS		87	/* Too many users */
+        case WSAENOTSOCK:          return VERR_NET_NOT_SOCKET;
+        case WSAEDESTADDRREQ:      return VERR_NET_DEST_ADDRESS_REQUIRED;
+        case WSAEMSGSIZE:          return VERR_NET_MSG_SIZE;
+        case WSAEPROTOTYPE:        return VERR_NET_PROTOCOL_TYPE;
+        case WSAENOPROTOOPT:       return VERR_NET_PROTOCOL_NOT_AVAILABLE;
+        case WSAEPROTONOSUPPORT:   return VERR_NET_PROTOCOL_NOT_SUPPORTED;
+        case WSAESOCKTNOSUPPORT:   return VERR_NET_SOCKET_TYPE_NOT_SUPPORTED;
+        case WSAEOPNOTSUPP:        return VERR_NET_OPERATION_NOT_SUPPORTED;
+        case WSAEPFNOSUPPORT:      return VERR_NET_PROTOCOL_FAMILY_NOT_SUPPORTED;
+        case WSAEAFNOSUPPORT:      return VERR_NET_ADDRESS_FAMILY_NOT_SUPPORTED;
+        case WSAEADDRINUSE:        return VERR_NET_ADDRESS_IN_USE;
+        case WSAEADDRNOTAVAIL:     return VERR_NET_ADDRESS_NOT_AVAILABLE;
+        case WSAENETDOWN:          return VERR_NET_DOWN;
+        case WSAENETUNREACH:       return VERR_NET_UNREACHABLE;
+        case WSAENETRESET:         return VERR_NET_CONNECTION_RESET;
+        case WSAECONNABORTED:      return VERR_NET_CONNECTION_ABORTED;
+        case WSAECONNRESET:        return VERR_NET_CONNECTION_RESET_BY_PEER;
+        case WSAENOBUFS:           return VERR_NET_NO_BUFFER_SPACE;
+        case WSAEISCONN:           return VERR_NET_ALREADY_CONNECTED;
+        case WSAENOTCONN:          return VERR_NET_NOT_CONNECTED;
+        case WSAESHUTDOWN:         return VERR_NET_SHUTDOWN;
+        case WSAETOOMANYREFS:      return VERR_NET_TOO_MANY_REFERENCES;
+        case WSAETIMEDOUT:         return VERR_TIMEOUT;
+        case WSAECONNREFUSED:      return VERR_NET_CONNECTION_REFUSED;
+        case WSAEHOSTDOWN:         return VERR_NET_HOST_DOWN;
+        case WSAEHOSTUNREACH:      return VERR_NET_HOST_UNREACHABLE;
+        case WSAEALREADY:          return VERR_NET_ALREADY_IN_PROGRESS;
+        case WSAEINPROGRESS:       return VERR_NET_IN_PROGRESS;
+        //case WSAESTALE		116	/* Stale NFS file handle */
+        //case WSAEUCLEAN		117	/* Structure needs cleaning */
+        //case WSAENOTNAM		118	/* Not a XENIX named type file */
+        //case WSAENAVAIL		119	/* No XENIX semaphores available */
+        //case WSAEISNAM		120	/* Is a named type file */
+        //case WSAEREMOTEIO	121	/* Remote I/O error */
+        case WSAEDQUOT:            return VERR_DISK_FULL;
+#ifdef WSAENOMEDIUM
+        case WSAENOMEDIUM:         return VERR_MEDIA_NOT_PRESENT;
+#endif
+#ifdef WSAEMEDIUMTYPE
+        case WSAEMEDIUMTYPE:       return VERR_MEDIA_NOT_RECOGNIZED;
+#endif
+        case WSAEPROCLIM:          return VERR_MAX_PROCS_REACHED;
+
+        //case WSAEDISCON:      (WSABASEERR+101)
+        //case WSASYSNOTREADY          (WSABASEERR+91)
+        //case WSAVERNOTSUPPORTED      (WSABASEERR+92)
+        //case WSANOTINITIALISED       (WSABASEERR+93)
+
+        //case WSAHOST_NOT_FOUND       (WSABASEERR+1001)
+        //case WSATRY_AGAIN            (WSABASEERR+1002)
+        //case WSANO_RECOVERY          (WSABASEERR+1003)
+        //case WSANO_DATA              (WSABASEERR+1004)
+    }
+
+    /* unknown error. */
+#ifndef DEBUG_dmik
+    AssertMsgFailed(("Unhandled error %u\n", uNativeCode));
+#endif
+    return VERR_UNRESOLVED_ERROR;
+}
+
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMAtomicBitClear.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMAtomicBitClear.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMAtomicBitClear.asm	(revision 5423)
@@ -0,0 +1,34 @@
+;; @file
+; innotek Portable Runtime - ASMAtomicBitClear().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Atomically clears a bit in a bitmap.
+;
+; @param   rcx  pvBitmap    Pointer to the bitmap.
+; @param   edx  iBit        The bit to toggle set.
+; @remark  No memory barrier, take care on smp.
+;
+BEGINPROC_EXPORTED ASMAtomicBitClear
+        lock btr [rcx], edx
+        ret
+ENDPROC ASMAtomicBitClear
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMAtomicBitTestAndToggle.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMAtomicBitTestAndToggle.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMAtomicBitTestAndToggle.asm	(revision 5423)
@@ -0,0 +1,36 @@
+;; @file
+; innotek Portable Runtime - ASMAtomicBitTestAndToggle().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Atomically tests and toggles a bit in a bitmap.
+;
+; @returns al(rax)      true if the bit was set.
+; @returns al(rax)      false if the bit was clear.
+; @param   rcx          pvBitmap    Pointer to the bitmap.
+; @param   edx          iBit        The bit to test and toggle.
+BEGINPROC_EXPORTED ASMAtomicBitTestAndToggle
+        lock btc [rcx], edx
+        sbb     eax, eax
+        ret
+ENDPROC ASMAtomicBitTestAndToggle
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMAtomicBitToggle.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMAtomicBitToggle.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMAtomicBitToggle.asm	(revision 5423)
@@ -0,0 +1,33 @@
+;; @file
+; innotek Portable Runtime - ASMAtomicBitToggle().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Atomically toggles a bit in a bitmap.
+;
+; @param   rcx  pvBitmap    Pointer to the bitmap.
+; @param   edx  iBit        The bit to test and set.
+BEGINPROC_EXPORTED ASMAtomicBitToggle
+        lock btc [rcx], edx
+        ret
+ENDPROC ASMAtomicBitToggle
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMAtomicReadU64.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMAtomicReadU64.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMAtomicReadU64.asm	(revision 5423)
@@ -0,0 +1,35 @@
+;; @file
+; innotek Portable Runtime - ASMAtomicReadU64().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Atomically Reads a unsigned 64-bit value.
+;
+; @returns rax  Current *pu64 value
+; @param   rcx  pu64    Pointer to the 64-bit variable to read.
+;                  The memory pointed to must be writable.
+;
+BEGINPROC_EXPORTED ASMAtomicReadU64
+        mov     rax, [rcx]
+        ret
+ENDPROC ASMAtomicReadU64
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMAtomicXchgU16.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMAtomicXchgU16.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMAtomicXchgU16.asm	(revision 5423)
@@ -0,0 +1,33 @@
+;; @file
+; innotek Portable Runtime - ASMAtomicXchgU16().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; @returns rax  Current *pu16 value
+; @param   rcx  pu16    Pointer to the 16-bit variable to update.
+; @param   rdx  u16     The 16-bit value to assign to *pu16.
+BEGINPROC_EXPORTED ASMAtomicXchgU16
+        xchg    [rcx], dx
+        movzx   eax, dx
+        ret
+ENDPROC ASMAtomicXchgU16
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMAtomicXchgU8.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMAtomicXchgU8.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMAtomicXchgU8.asm	(revision 5423)
@@ -0,0 +1,32 @@
+;; @file
+; innotek Portable Runtime - ASMAtomicXchgU8().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; @returns al Current *pu8 value
+; @param   rcx  pu8    Pointer to the 8-bit variable to update.
+; @param   dl   u8     The 8-bit value to assign to *pu8.
+BEGINPROC_EXPORTED ASMAtomicXchgU8
+        xchg    [rcx], dl
+        movzx   eax, dl
+        ret
+ENDPROC ASMAtomicXchgU8
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMBitFirstClear.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMBitFirstClear.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMBitFirstClear.asm	(revision 5423)
@@ -0,0 +1,75 @@
+;; @file
+; innotek Portable Runtime - ASMBitFirstClear().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Finds the first clear bit in a bitmap.
+;
+; @returns eax  Index of the first zero bit.
+; @returns eax  -1 if no clear bit was found.
+; @param   rcx  pvBitmap    Pointer to the bitmap.
+; @param   edx  cBits       The number of bits in the bitmap. Multiple of 32.
+;
+BEGINPROC_EXPORTED ASMBitFirstClear
+
+        ;if (cBits)
+        or      edx, edx
+        jz      short @failed
+        ;{
+        push    rdi
+
+        ;    asm {...}
+        mov     rdi, rcx                ; rdi = start of scasd
+        mov     ecx, edx
+        add     ecx, 31                 ; 32 bit aligned
+        shr     ecx, 5                  ; number of dwords to scan.
+        mov     rdx, rdi                ; rdx = saved pvBitmap
+        mov     eax, 0ffffffffh
+        repe    scasd                   ; Scan for the first dword with any clear bit.
+        je      @failed_restore
+
+        ; find the bit in question
+        lea     rdi, [rdi - 4]          ; one step back.
+        xor     eax, [rdi]              ; eax = NOT [rdi]
+        sub     rdi, rdx
+        shl     edi, 3                  ; calc bit offset.
+
+        mov     ecx, 0ffffffffh
+        bsf     ecx, eax
+        add     ecx, edi
+        mov     eax, ecx
+
+        ; return success
+        pop     rdi
+        ret
+
+        ; failure
+        ;}
+        ;return -1;
+@failed_restore:
+        pop     rdi
+        ret
+@failed:
+        mov     eax, 0ffffffffh
+        ret
+ENDPROC ASMBitFirstClear
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMBitFirstSet.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMBitFirstSet.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMBitFirstSet.asm	(revision 5423)
@@ -0,0 +1,76 @@
+;; @file
+; innotek Portable Runtime - ASMBitFirstSet().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Finds the first set bit in a bitmap.
+;
+; @returns eax  Index of the first set bit.
+; @returns eax  -1 if no clear bit was found.
+; @param   rcx  pvBitmap    Pointer to the bitmap.
+; @param   edx  cBits       The number of bits in the bitmap. Multiple of 32.
+;
+BEGINPROC_EXPORTED ASMBitFirstSet
+
+        ;if (cBits)
+        or      edx, edx
+        jz      short @failed
+        ;{
+        push    rdi
+
+        ;    asm {...}
+        mov     rdi, rcx                ; rdi = start of scasd
+        mov     ecx, edx
+        add     ecx, 31                 ; 32 bit aligned
+        shr     ecx, 5                  ; number of dwords to scan.
+        mov     rdx, rdi                ; rdx = saved pvBitmap
+        xor     eax, eax
+        repe    scasd                   ; Scan for the first dword with any set bit.
+        je      @failed_restore
+
+        ; find the bit in question
+        lea     rdi, [rdi - 4]          ; one step back.
+        mov     eax, [rdi]
+        sub     rdi, rdx
+        shl     edi, 3                  ; calc bit offset.
+
+        mov     ecx, 0ffffffffh
+        bsf     ecx, eax
+        add     ecx, edi
+        mov     eax, ecx
+
+        ; return success
+        pop     rdi
+        ret
+
+        ; failure
+        ;}
+        ;return -1;
+@failed_restore:
+        pop     rdi
+@failed:
+        mov     eax, 0ffffffffh
+        ret
+ENDPROC ASMBitFirstSet
+
+
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetCS.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetCS.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetCS.asm	(revision 5423)
@@ -0,0 +1,32 @@
+;; @file
+; innotek Portable Runtime - ASMGetCS().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Get the cs register.
+; @returns cs.
+;
+BEGINPROC_EXPORTED ASMGetCS
+        mov     eax, cs
+        ret
+ENDPROC ASMGetCS
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetDR0.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetDR0.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetDR0.asm	(revision 5423)
@@ -0,0 +1,33 @@
+;; @file
+; innotek Portable Runtime - ASMGetDR0().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Get the dr0 register value.
+; @returns dr0.
+;
+BEGINPROC_EXPORTED ASMGetDR0
+        mov     rax, dr0
+        ret
+ENDPROC ASMGetDR0
+
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetDR1.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetDR1.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetDR1.asm	(revision 5423)
@@ -0,0 +1,32 @@
+;; @file
+; innotek Portable Runtime - ASMGetDR1().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Get the dr1 register value.
+; @returns dr1.
+;
+BEGINPROC_EXPORTED ASMGetDR1
+        mov     rax, dr1
+        ret
+ENDPROC ASMGetDR1
+
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetDR2.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetDR2.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetDR2.asm	(revision 5423)
@@ -0,0 +1,33 @@
+;; @file
+; innotek Portable Runtime - ASMGetDR2().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Get the dr2 register value.
+; @returns dr2.
+;
+BEGINPROC_EXPORTED ASMGetDR2
+        mov     rax, dr2
+        ret
+ENDPROC ASMGetDR2
+
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetDR3.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetDR3.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetDR3.asm	(revision 5423)
@@ -0,0 +1,33 @@
+;; @file
+; innotek Portable Runtime - ASMGetDR3().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Get the dr3 register value.
+; @returns dr3.
+;
+BEGINPROC_EXPORTED ASMGetDR3
+        mov     rax, dr3
+        ret
+ENDPROC ASMGetDR3
+
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetDR6.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetDR6.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetDR6.asm	(revision 5423)
@@ -0,0 +1,32 @@
+;; @file
+; innotek Portable Runtime - ASMGetDR6().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Get the dr6 register value.
+; @returns dr6.
+;
+BEGINPROC_EXPORTED ASMGetDR6
+        mov     rax, dr6
+        ret
+ENDPROC ASMGetDR6
+
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetDR7.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetDR7.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetDR7.asm	(revision 5423)
@@ -0,0 +1,31 @@
+;; @file
+; innotek Portable Runtime - ASMGetDR7().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Get the dr7 register value.
+; @returns dr7.
+;
+BEGINPROC_EXPORTED ASMGetDR7
+        mov     rax, dr7
+        ret
+ENDPROC ASMGetDR7
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetDS.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetDS.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetDS.asm	(revision 5423)
@@ -0,0 +1,31 @@
+;; @file
+; innotek Portable Runtime - ASMGetDS().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Get the ds register.
+; @returns ds.
+;
+BEGINPROC_EXPORTED ASMGetDS
+        mov     eax, DS
+        ret
+ENDPROC ASMGetDS
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetES.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetES.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetES.asm	(revision 5423)
@@ -0,0 +1,31 @@
+;; @file
+; innotek Portable Runtime - ASMGetES().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Get the es register.
+; @returns es.
+;
+BEGINPROC_EXPORTED ASMGetES
+        mov     eax, es
+        ret
+ENDPROC ASMGetES
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetFS.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetFS.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetFS.asm	(revision 5423)
@@ -0,0 +1,31 @@
+;; @file
+; innotek Portable Runtime - ASMGetFS().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Get the fs register.
+; @returns fs.
+;
+BEGINPROC_EXPORTED ASMGetFS
+        mov     eax, fs
+        ret
+ENDPROC ASMGetFS
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetFlags.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetFlags.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetFlags.asm	(revision 5423)
@@ -0,0 +1,28 @@
+;; @file
+; innotek Portable Runtime - ASMGetFlags().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+BEGINPROC_EXPORTED ASMGetFlags
+        pushf
+        pop     rax
+        ret
+ENDPROC ASMGetFlags
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetGDTR.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetGDTR.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetGDTR.asm	(revision 5423)
@@ -0,0 +1,31 @@
+;; @file
+; innotek Portable Runtime - ASMGetGDTR().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Gets the content of the GDTR CPU register.
+; @param   rcx  pGdtr   Where to store the GDTR contents.
+;
+BEGINPROC_EXPORTED ASMGetGDTR
+        sgdt    [rcx]
+        ret
+ENDPROC ASMGetGDTR
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetGS.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetGS.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetGS.asm	(revision 5423)
@@ -0,0 +1,31 @@
+;; @file
+; innotek Portable Runtime - ASMGetGS().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Get the gs register.
+; @returns gs.
+;
+BEGINPROC_EXPORTED ASMGetGS
+        mov     eax, gs
+        ret
+ENDPROC ASMGetGS
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetIDTR.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetIDTR.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetIDTR.asm	(revision 5423)
@@ -0,0 +1,32 @@
+;; @file
+; innotek Portable Runtime - ASMGetIDTR().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Gets the content of the IDTR CPU register.
+; @param   rcx  pIdtr   Where to store the IDTR contents.
+;
+BEGINPROC_EXPORTED ASMGetIDTR
+        sidt    [rcx]
+        ret
+ENDPROC ASMGetIDTR
+
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetSS.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetSS.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetSS.asm	(revision 5423)
@@ -0,0 +1,31 @@
+;; @file
+; innotek Portable Runtime - ASMGetSS().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Get the ss register.
+; @returns ss.
+;
+BEGINPROC_EXPORTED ASMGetSS
+        mov     eax, ss
+        ret
+ENDPROC ASMGetSS
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMGetTR.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMGetTR.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMGetTR.asm	(revision 5423)
@@ -0,0 +1,32 @@
+;; @file
+; innotek Portable Runtime - ASMGetTR().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Get the TR register.
+; @returns TR.
+; 
+BEGINPROC_EXPORTED ASMGetTR
+        str     ax
+        movzx   eax, ax
+        ret
+ENDPROC ASMGetTR
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMMultU64ByU32DivByU32.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMMultU64ByU32DivByU32.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMMultU64ByU32DivByU32.asm	(revision 5423)
@@ -0,0 +1,41 @@
+;; @file
+; innotek Portable Runtime - ASMMultU64ByU32DivByU32().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Multiple a 64-bit by a 32-bit integer and divide the result by a 32-bit integer
+; using a 96 bit intermediate result.
+; 
+; @returns (u64A * u32B) / u32C. (rax)
+; @param   u64A    rcx      The 64-bit value.
+; @param   u32B    edx      The 32-bit value to multiple by A.
+; @param   u32C    r8d      The 32-bit value to divide A*B by.
+; 
+BEGINPROC_EXPORTED ASMMultU64ByU32DivByU32
+        mov     r9d, edx                        ; r9  = B
+        mov     rax, rcx                        ; rax = A
+        xor     edx, edx                        ; rdx = 0
+        mul     r9                              ; rax:rdx = A*B
+        mov     ecx, r8d                        ; rcx = C (overly careful)
+        div     rcx                             ; rax = A*B/C (rdx=reminder)
+        ret
+ENDPROC ASMMultU64ByU32DivByU32
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMProbeReadByte.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMProbeReadByte.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMProbeReadByte.asm	(revision 5423)
@@ -0,0 +1,38 @@
+;; @file
+; innotek Portable Runtime - ASMProbeReadByte().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; Probes a byte pointer for read access.
+;
+; While the function will not fault if the byte is not read accessible,
+; the idea is to do this in a safe place like before acquiring locks
+; and such like.
+;
+; Also, this functions guarantees that an eager compiler is not going
+; to optimize the probing away.
+;
+; @param   rcx  pvByte      Pointer to the byte.
+BEGINPROC_EXPORTED ASMProbeReadByte
+        mov     al, [rcx]
+        ret
+ENDPROC ASMProbeReadByte
+
Index: trunk/src/VBox/Runtime/win/amd64/ASMSetFlags.asm
===================================================================
--- trunk/src/VBox/Runtime/win/amd64/ASMSetFlags.asm	(revision 5423)
+++ trunk/src/VBox/Runtime/win/amd64/ASMSetFlags.asm	(revision 5423)
@@ -0,0 +1,31 @@
+;; @file
+; innotek Portable Runtime - ASMSetFlags().
+;
+
+;
+;  Copyright (C) 2006-2007 innotek GmbH
+; 
+;  This file is part of VirtualBox Open Source Edition (OSE), as
+;  available from http://www.virtualbox.org. This file is free software;
+;  you can redistribute it and/or modify it under the terms of the GNU
+;  General Public License as published by the Free Software Foundation,
+;  in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+;  distribution. VirtualBox OSE is distributed in the hope that it will
+;  be useful, but WITHOUT ANY WARRANTY of any kind.
+
+
+;*******************************************************************************
+;* Header Files                                                                *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+BEGINCODE
+
+;;
+; @param rcx  eflags
+BEGINPROC_EXPORTED ASMSetFlags
+        push    rcx
+        popfq
+        ret
+ENDPROC ASMSetFlags
+
Index: trunk/src/VBox/Runtime/win/errmsgwin.cpp
===================================================================
--- trunk/src/VBox/Runtime/win/errmsgwin.cpp	(revision 5423)
+++ trunk/src/VBox/Runtime/win/errmsgwin.cpp	(revision 5423)
@@ -0,0 +1,82 @@
+/* $Id$ */
+/** @file
+ * innotek Portable Runtime - Status code messages.
+ */
+
+/*
+ * Copyright (C) 2006-2007 innotek GmbH
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation,
+ * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+ * distribution. VirtualBox OSE is distributed in the hope that it will
+ * be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <windows.h>
+
+#include <iprt/err.h>
+#include <iprt/asm.h>
+#include <iprt/string.h>
+#include <iprt/err.h>
+#include <VBox/err.h>
+
+
+/*******************************************************************************
+*   Global Variables                                                           *
+*******************************************************************************/
+/** Array of messages.
+ * The data is generated by a sed script.
+ */
+static const RTWINERRMSG  g_aStatusMsgs[] =
+{
+#include "errmsgcomdata.h"
+    { NULL, NULL, 0 }
+};
+
+
+/** Temporary buffers to format unknown messages in.
+ * @{
+ */
+static char                 g_aszUnknownStr[4][64];
+static RTWINERRMSG          g_aUnknownMsgs[4] =
+{
+    { &g_aszUnknownStr[0][0], &g_aszUnknownStr[0][0], 0 },
+    { &g_aszUnknownStr[1][0], &g_aszUnknownStr[1][0], 0 },
+    { &g_aszUnknownStr[2][0], &g_aszUnknownStr[2][0], 0 },
+    { &g_aszUnknownStr[3][0], &g_aszUnknownStr[3][0], 0 }
+};
+/** Last used index in g_aUnknownMsgs. */
+static volatile uint32_t    g_iUnknownMsgs;
+/** @} */
+
+
+/**
+ * Get the message corresponding to a given status code.
+ *
+ * @returns Pointer to read-only message description.
+ * @param   rc      The status code.
+ */
+RTDECL(PCRTWINERRMSG) RTErrWinGet(long rc)
+{
+    unsigned i;
+    for (i = 0; i < ELEMENTS(g_aStatusMsgs); i++)
+    {
+        if (g_aStatusMsgs[i].iCode == rc)
+        {
+            return &g_aStatusMsgs[i];
+        }
+    }
+
+    /*
+     * Need to use the temporary stuff.
+     */
+    int iMsg = ASMAtomicXchgU32(&g_iUnknownMsgs, (g_iUnknownMsgs + 1) % ELEMENTS(g_aUnknownMsgs));
+    RTStrPrintf(&g_aszUnknownStr[iMsg][0], sizeof(g_aszUnknownStr[iMsg]), "Unknown Status 0x%X\n", rc);
+    return &g_aUnknownMsgs[iMsg];
+}
