[PATCH 10/13] D: The D runtime library and license.

This patch adds the D runtime library and license (Boost) files.  D runtime is a low level that implements the building blocks of the runtime environment, as well as C and C++ platform bindings.  Many high level operations are lowered to generate calls to various functions defined in this library.

---

diff --git a/libphobos/libdruntime/LICENSE b/libphobos/libdruntime/LICENSE
new file mode 100644
index 00000000000..c83ac898df4
--- /dev/null
+++ b/libphobos/libdruntime/LICENSE
@@ -0,0 +1,26 @@
+DRuntime: Runtime Library for the D Programming Language
+========================================================
+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/libphobos/libdruntime/core/atomic.d b/libphobos/libdruntime/core/atomic.d
new file mode 100644
index 00000000000..b395341e5ec
--- /dev/null
+++ b/libphobos/libdruntime/core/atomic.d
@@ -0,0 +1,1772 @@
+/**
+ * The atomic module provides basic support for lock-free
+ * concurrent programming.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2010.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Source:    $(DRUNTIMESRC core/_atomic.d)
+ */
+
+/*          Copyright Sean Kelly 2005 - 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module core.atomic;
+
+version( D_InlineAsm_X86 )
+{
+    version = AsmX86;
+    version = AsmX86_32;
+    enum has64BitCAS = true;
+    enum has128BitCAS = false;
+}
+else version( D_InlineAsm_X86_64 )
+{
+    version = AsmX86;
+    version = AsmX86_64;
+    enum has64BitCAS = true;
+    enum has128BitCAS = true;
+}
+else version (GNU)
+{
+    import gcc.config;
+    enum has64BitCAS = true;
+    enum has128BitCAS = HAVE_LIBATOMIC;
+}
+else
+{
+    enum has64BitCAS = false;
+    enum has128BitCAS = false;
+}
+
+private
+{
+    template HeadUnshared(T)
+    {
+        static if( is( T U : shared(U*) ) )
+            alias shared(U)* HeadUnshared;
+        else
+            alias T HeadUnshared;
+    }
+}
+
+
+version( AsmX86 )
+{
+    // NOTE: Strictly speaking, the x86 supports atomic operations on
+    //       unaligned values.  However, this is far slower than the
+    //       common case, so such behavior should be prohibited.
+    private bool atomicValueIsProperlyAligned(T)( size_t addr ) pure nothrow
+    {
+        return addr % T.sizeof == 0;
+    }
+}
+
+
+version( CoreDdoc )
+{
+    /**
+     * Performs the binary operation 'op' on val using 'mod' as the modifier.
+     *
+     * Params:
+     *  val = The target variable.
+     *  mod = The modifier to apply.
+     *
+     * Returns:
+     *  The result of the operation.
+     */
+    HeadUnshared!(T) atomicOp(string op, T, V1)( ref shared T val, V1 mod ) pure nothrow @nogc
+        if( __traits( compiles, mixin( "*cast(T*)&val" ~ op ~ "mod" ) ) )
+    {
+        return HeadUnshared!(T).init;
+    }
+
+
+    /**
+     * Stores 'writeThis' to the memory referenced by 'here' if the value
+     * referenced by 'here' is equal to 'ifThis'.  This operation is both
+     * lock-free and atomic.
+     *
+     * Params:
+     *  here      = The address of the destination variable.
+     *  writeThis = The value to store.
+     *  ifThis    = The comparison value.
+     *
+     * Returns:
+     *  true if the store occurred, false if not.
+     */
+    bool cas(T,V1,V2)( shared(T)* here, const V1 ifThis, V2 writeThis ) pure nothrow @nogc
+        if( !is(T == class) && !is(T U : U*) && __traits( compiles, { *here = writeThis; } ) );
+
+    /// Ditto
+    bool cas(T,V1,V2)( shared(T)* here, const shared(V1) ifThis, shared(V2) writeThis ) pure nothrow @nogc
+        if( is(T == class) && __traits( compiles, { *here = writeThis; } ) );
+
+    /// Ditto
+    bool cas(T,V1,V2)( shared(T)* here, const shared(V1)* ifThis, shared(V2)* writeThis ) pure nothrow @nogc
+        if( is(T U : U*) && __traits( compiles, { *here = writeThis; } ) );
+
+    /**
+     * Loads 'val' from memory and returns it.  The memory barrier specified
+     * by 'ms' is applied to the operation, which is fully sequenced by
+     * default.  Valid memory orders are MemoryOrder.raw, MemoryOrder.acq,
+     * and MemoryOrder.seq.
+     *
+     * Params:
+     *  val = The target variable.
+     *
+     * Returns:
+     *  The value of 'val'.
+     */
+    HeadUnshared!(T) atomicLoad(MemoryOrder ms = MemoryOrder.seq,T)( ref const shared T val ) pure nothrow @nogc
+    {
+        return HeadUnshared!(T).init;
+    }
+
+
+    /**
+     * Writes 'newval' into 'val'.  The memory barrier specified by 'ms' is
+     * applied to the operation, which is fully sequenced by default.
+     * Valid memory orders are MemoryOrder.raw, MemoryOrder.rel, and
+     * MemoryOrder.seq.
+     *
+     * Params:
+     *  val    = The target variable.
+     *  newval = The value to store.
+     */
+    void atomicStore(MemoryOrder ms = MemoryOrder.seq,T,V1)( ref shared T val, V1 newval ) pure nothrow @nogc
+        if( __traits( compiles, { val = newval; } ) )
+    {
+
+    }
+
+
+    /**
+     * Specifies the memory ordering semantics of an atomic operation.
+     */
+    enum MemoryOrder
+    {
+        raw,    /// Not sequenced.
+        acq,    /// Hoist-load + hoist-store barrier.
+        rel,    /// Sink-load + sink-store barrier.
+        seq,    /// Fully sequenced (acquire + release).
+    }
+
+    deprecated("Please use MemoryOrder instead.")
+    alias MemoryOrder msync;
+
+    /**
+     * Inserts a full load/store memory fence (on platforms that need it). This ensures
+     * that all loads and stores before a call to this function are executed before any
+     * loads and stores after the call.
+     */
+    void atomicFence() nothrow @nogc;
+}
+else version( AsmX86_32 )
+{
+    // Uses specialized asm for fast fetch and add operations
+    private HeadUnshared!(T) atomicFetchAdd(T, V1)( ref shared T val, V1 mod ) pure nothrow @nogc
+        if( T.sizeof <= 4 && V1.sizeof <= 4)
+    {
+        size_t tmp = mod; // convert all operands to size_t
+        asm pure nothrow @nogc
+        {
+            mov EAX, tmp;
+            mov EDX, val;
+        }
+        static if (T.sizeof == 1) asm pure nothrow @nogc { lock; xadd[EDX], AL; }
+        else static if (T.sizeof == 2) asm pure nothrow @nogc { lock; xadd[EDX], AX; }
+        else static if (T.sizeof == 4) asm pure nothrow @nogc { lock; xadd[EDX], EAX; }
+
+        asm pure nothrow @nogc
+        {
+            mov tmp, EAX;
+        }
+
+        return cast(T)tmp;
+    }
+
+    private HeadUnshared!(T) atomicFetchSub(T, V1)( ref shared T val, V1 mod ) pure nothrow @nogc
+        if( T.sizeof <= 4 && V1.sizeof <= 4)
+    {
+        return atomicFetchAdd(val, -mod);
+    }
+
+    HeadUnshared!(T) atomicOp(string op, T, V1)( ref shared T val, V1 mod ) pure nothrow @nogc
+        if( __traits( compiles, mixin( "*cast(T*)&val" ~ op ~ "mod" ) ) )
+    in
+    {
+        // NOTE: 32 bit x86 systems support 8 byte CAS, which only requires
+        //       4 byte alignment, so use size_t as the align type here.
+        static if( T.sizeof > size_t.sizeof )
+            assert( atomicValueIsProperlyAligned!(size_t)( cast(size_t) &val ) );
+        else
+            assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) );
+    }
+    body
+    {
+        // binary operators
+        //
+        // +    -   *   /   %   ^^  &
+        // |    ^   <<  >>  >>> ~   in
+        // ==   !=  <   <=  >   >=
+        static if( op == "+"  || op == "-"  || op == "*"  || op == "/"   ||
+                   op == "%"  || op == "^^" || op == "&"  || op == "|"   ||
+                   op == "^"  || op == "<<" || op == ">>" || op == ">>>" ||
+                   op == "~"  || // skip "in"
+                   op == "==" || op == "!=" || op == "<"  || op == "<="  ||
+                   op == ">"  || op == ">=" )
+        {
+            HeadUnshared!(T) get = atomicLoad!(MemoryOrder.raw)( val );
+            mixin( "return get " ~ op ~ " mod;" );
+        }
+        else
+        // assignment operators
+        //
+        // +=   -=  *=  /=  %=  ^^= &=
+        // |=   ^=  <<= >>= >>>=    ~=
+        static if( op == "+=" && __traits(isIntegral, T) && T.sizeof <= 4 && V1.sizeof <= 4)
+        {
+            return cast(T)(atomicFetchAdd!(T)(val, mod) + mod);
+        }
+        else static if( op == "-=" && __traits(isIntegral, T) && T.sizeof <= 4 && V1.sizeof <= 4)
+        {
+            return cast(T)(atomicFetchSub!(T)(val, mod) - mod);
+        }
+        else static if( op == "+=" || op == "-="  || op == "*="  || op == "/=" ||
+                   op == "%=" || op == "^^=" || op == "&="  || op == "|=" ||
+                   op == "^=" || op == "<<=" || op == ">>=" || op == ">>>=" ) // skip "~="
+        {
+            HeadUnshared!(T) get, set;
+
+            do
+            {
+                get = set = atomicLoad!(MemoryOrder.raw)( val );
+                mixin( "set " ~ op ~ " mod;" );
+            } while( !cas( &val, get, set ) );
+            return set;
+        }
+        else
+        {
+            static assert( false, "Operation not supported." );
+        }
+    }
+
+    bool cas(T,V1,V2)( shared(T)* here, const V1 ifThis, V2 writeThis ) pure nothrow @nogc
+        if( !is(T == class) && !is(T U : U*) && __traits( compiles, { *here = writeThis; } ) )
+    {
+        return casImpl(here, ifThis, writeThis);
+    }
+
+    bool cas(T,V1,V2)( shared(T)* here, const shared(V1) ifThis, shared(V2) writeThis ) pure nothrow @nogc
+        if( is(T == class) && __traits( compiles, { *here = writeThis; } ) )
+    {
+        return casImpl(here, ifThis, writeThis);
+    }
+
+    bool cas(T,V1,V2)( shared(T)* here, const shared(V1)* ifThis, shared(V2)* writeThis ) pure nothrow @nogc
+        if( is(T U : U*) && __traits( compiles, { *here = writeThis; } ) )
+    {
+        return casImpl(here, ifThis, writeThis);
+    }
+
+    private bool casImpl(T,V1,V2)( shared(T)* here, V1 ifThis, V2 writeThis ) pure nothrow @nogc
+    in
+    {
+        // NOTE: 32 bit x86 systems support 8 byte CAS, which only requires
+        //       4 byte alignment, so use size_t as the align type here.
+        static if( T.sizeof > size_t.sizeof )
+            assert( atomicValueIsProperlyAligned!(size_t)( cast(size_t) here ) );
+        else
+            assert( atomicValueIsProperlyAligned!(T)( cast(size_t) here ) );
+    }
+    body
+    {
+        static if( T.sizeof == byte.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 1 Byte CAS
+            //////////////////////////////////////////////////////////////////
+
+            asm pure nothrow @nogc
+            {
+                mov DL, writeThis;
+                mov AL, ifThis;
+                mov ECX, here;
+                lock; // lock always needed to make this op atomic
+                cmpxchg [ECX], DL;
+                setz AL;
+            }
+        }
+        else static if( T.sizeof == short.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 2 Byte CAS
+            //////////////////////////////////////////////////////////////////
+
+            asm pure nothrow @nogc
+            {
+                mov DX, writeThis;
+                mov AX, ifThis;
+                mov ECX, here;
+                lock; // lock always needed to make this op atomic
+                cmpxchg [ECX], DX;
+                setz AL;
+            }
+        }
+        else static if( T.sizeof == int.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 4 Byte CAS
+            //////////////////////////////////////////////////////////////////
+
+            asm pure nothrow @nogc
+            {
+                mov EDX, writeThis;
+                mov EAX, ifThis;
+                mov ECX, here;
+                lock; // lock always needed to make this op atomic
+                cmpxchg [ECX], EDX;
+                setz AL;
+            }
+        }
+        else static if( T.sizeof == long.sizeof && has64BitCAS )
+        {
+
+            //////////////////////////////////////////////////////////////////
+            // 8 Byte CAS on a 32-Bit Processor
+            //////////////////////////////////////////////////////////////////
+
+            asm pure nothrow @nogc
+            {
+                push EDI;
+                push EBX;
+                lea EDI, writeThis;
+                mov EBX, [EDI];
+                mov ECX, 4[EDI];
+                lea EDI, ifThis;
+                mov EAX, [EDI];
+                mov EDX, 4[EDI];
+                mov EDI, here;
+                lock; // lock always needed to make this op atomic
+                cmpxchg8b [EDI];
+                setz AL;
+                pop EBX;
+                pop EDI;
+
+            }
+
+        }
+        else
+        {
+            static assert( false, "Invalid template type specified." );
+        }
+    }
+
+
+    enum MemoryOrder
+    {
+        raw,
+        acq,
+        rel,
+        seq,
+    }
+
+    deprecated("Please use MemoryOrder instead.")
+    alias MemoryOrder msync;
+
+
+    private
+    {
+        // NOTE: x86 loads implicitly have acquire semantics so a memory
+        //       barrier is only necessary on releases.
+        template needsLoadBarrier( MemoryOrder ms )
+        {
+            enum bool needsLoadBarrier = ms == MemoryOrder.seq;
+        }
+
+
+        // NOTE: x86 stores implicitly have release semantics so a memory
+        //       barrier is only necessary on acquires.
+        template needsStoreBarrier( MemoryOrder ms )
+        {
+            enum bool needsStoreBarrier = ms == MemoryOrder.seq;
+        }
+    }
+
+
+    HeadUnshared!(T) atomicLoad(MemoryOrder ms = MemoryOrder.seq, T)( ref const shared T val ) pure nothrow @nogc
+    if(!__traits(isFloating, T))
+    {
+        static assert( ms != MemoryOrder.rel, "invalid MemoryOrder for atomicLoad()" );
+        static assert( __traits(isPOD, T), "argument to atomicLoad() must be POD" );
+
+        static if( T.sizeof == byte.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 1 Byte Load
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsLoadBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov DL, 0;
+                    mov AL, 0;
+                    mov ECX, val;
+                    lock; // lock always needed to make this op atomic
+                    cmpxchg [ECX], DL;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov EAX, val;
+                    mov AL, [EAX];
+                }
+            }
+        }
+        else static if( T.sizeof == short.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 2 Byte Load
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsLoadBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov DX, 0;
+                    mov AX, 0;
+                    mov ECX, val;
+                    lock; // lock always needed to make this op atomic
+                    cmpxchg [ECX], DX;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov EAX, val;
+                    mov AX, [EAX];
+                }
+            }
+        }
+        else static if( T.sizeof == int.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 4 Byte Load
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsLoadBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov EDX, 0;
+                    mov EAX, 0;
+                    mov ECX, val;
+                    lock; // lock always needed to make this op atomic
+                    cmpxchg [ECX], EDX;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov EAX, val;
+                    mov EAX, [EAX];
+                }
+            }
+        }
+        else static if( T.sizeof == long.sizeof && has64BitCAS )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 8 Byte Load on a 32-Bit Processor
+            //////////////////////////////////////////////////////////////////
+
+            asm pure nothrow @nogc
+            {
+                push EDI;
+                push EBX;
+                mov EBX, 0;
+                mov ECX, 0;
+                mov EAX, 0;
+                mov EDX, 0;
+                mov EDI, val;
+                lock; // lock always needed to make this op atomic
+                cmpxchg8b [EDI];
+                pop EBX;
+                pop EDI;
+            }
+        }
+        else
+        {
+            static assert( false, "Invalid template type specified." );
+        }
+    }
+
+    void atomicStore(MemoryOrder ms = MemoryOrder.seq, T, V1)( ref shared T val, V1 newval ) pure nothrow @nogc
+        if( __traits( compiles, { val = newval; } ) )
+    {
+        static assert( ms != MemoryOrder.acq, "invalid MemoryOrder for atomicStore()" );
+        static assert( __traits(isPOD, T), "argument to atomicStore() must be POD" );
+
+        static if( T.sizeof == byte.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 1 Byte Store
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsStoreBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov EAX, val;
+                    mov DL, newval;
+                    lock;
+                    xchg [EAX], DL;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov EAX, val;
+                    mov DL, newval;
+                    mov [EAX], DL;
+                }
+            }
+        }
+        else static if( T.sizeof == short.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 2 Byte Store
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsStoreBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov EAX, val;
+                    mov DX, newval;
+                    lock;
+                    xchg [EAX], DX;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov EAX, val;
+                    mov DX, newval;
+                    mov [EAX], DX;
+                }
+            }
+        }
+        else static if( T.sizeof == int.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 4 Byte Store
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsStoreBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov EAX, val;
+                    mov EDX, newval;
+                    lock;
+                    xchg [EAX], EDX;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov EAX, val;
+                    mov EDX, newval;
+                    mov [EAX], EDX;
+                }
+            }
+        }
+        else static if( T.sizeof == long.sizeof && has64BitCAS )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 8 Byte Store on a 32-Bit Processor
+            //////////////////////////////////////////////////////////////////
+
+            asm pure nothrow @nogc
+            {
+                push EDI;
+                push EBX;
+                lea EDI, newval;
+                mov EBX, [EDI];
+                mov ECX, 4[EDI];
+                mov EDI, val;
+                mov EAX, [EDI];
+                mov EDX, 4[EDI];
+            L1: lock; // lock always needed to make this op atomic
+                cmpxchg8b [EDI];
+                jne L1;
+                pop EBX;
+                pop EDI;
+            }
+        }
+        else
+        {
+            static assert( false, "Invalid template type specified." );
+        }
+    }
+
+
+    void atomicFence() nothrow
+    {
+        import core.cpuid;
+
+        asm pure nothrow @nogc
+        {
+            naked;
+
+            call sse2;
+            test AL, AL;
+            jne Lcpuid;
+
+            // Fast path: We have SSE2, so just use mfence.
+            mfence;
+            jmp Lend;
+
+        Lcpuid:
+
+            // Slow path: We use cpuid to serialize. This is
+            // significantly slower than mfence, but is the
+            // only serialization facility we have available
+            // on older non-SSE2 chips.
+            push EBX;
+
+            mov EAX, 0;
+            cpuid;
+
+            pop EBX;
+
+        Lend:
+
+            ret;
+        }
+    }
+}
+else version( AsmX86_64 )
+{
+    // Uses specialized asm for fast fetch and add operations
+    private HeadUnshared!(T) atomicFetchAdd(T, V1)( ref shared T val, V1 mod ) pure nothrow @nogc
+        if( __traits(isIntegral, T) && __traits(isIntegral, V1) )
+    in
+    {
+        // NOTE: 32 bit x86 systems support 8 byte CAS, which only requires
+        //       4 byte alignment, so use size_t as the align type here.
+        static if( T.sizeof > size_t.sizeof )
+            assert( atomicValueIsProperlyAligned!(size_t)( cast(size_t) &val ) );
+        else
+            assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) );
+    }
+    body
+    {
+        size_t tmp = mod; // convert all operands to size_t
+        asm pure nothrow @nogc
+        {
+            mov RAX, tmp;
+            mov RDX, val;
+        }
+        static if (T.sizeof == 1) asm pure nothrow @nogc { lock; xadd[RDX], AL; }
+        else static if (T.sizeof == 2) asm pure nothrow @nogc { lock; xadd[RDX], AX; }
+        else static if (T.sizeof == 4) asm pure nothrow @nogc { lock; xadd[RDX], EAX; }
+        else static if (T.sizeof == 8) asm pure nothrow @nogc { lock; xadd[RDX], RAX; }
+
+        asm pure nothrow @nogc
+        {
+            mov tmp, RAX;
+        }
+
+        return cast(T)tmp;
+    }
+
+    private HeadUnshared!(T) atomicFetchSub(T, V1)( ref shared T val, V1 mod ) pure nothrow @nogc
+        if( __traits(isIntegral, T) && __traits(isIntegral, V1) )
+    {
+        return atomicFetchAdd(val, -mod);
+    }
+
+    HeadUnshared!(T) atomicOp(string op, T, V1)( ref shared T val, V1 mod ) pure nothrow @nogc
+        if( __traits( compiles, mixin( "*cast(T*)&val" ~ op ~ "mod" ) ) )
+    in
+    {
+        // NOTE: 32 bit x86 systems support 8 byte CAS, which only requires
+        //       4 byte alignment, so use size_t as the align type here.
+        static if( T.sizeof > size_t.sizeof )
+            assert( atomicValueIsProperlyAligned!(size_t)( cast(size_t) &val ) );
+        else
+            assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) );
+    }
+    body
+    {
+        // binary operators
+        //
+        // +    -   *   /   %   ^^  &
+        // |    ^   <<  >>  >>> ~   in
+        // ==   !=  <   <=  >   >=
+        static if( op == "+"  || op == "-"  || op == "*"  || op == "/"   ||
+                   op == "%"  || op == "^^" || op == "&"  || op == "|"   ||
+                   op == "^"  || op == "<<" || op == ">>" || op == ">>>" ||
+                   op == "~"  || // skip "in"
+                   op == "==" || op == "!=" || op == "<"  || op == "<="  ||
+                   op == ">"  || op == ">=" )
+        {
+            HeadUnshared!(T) get = atomicLoad!(MemoryOrder.raw)( val );
+            mixin( "return get " ~ op ~ " mod;" );
+        }
+        else
+        // assignment operators
+        //
+        // +=   -=  *=  /=  %=  ^^= &=
+        // |=   ^=  <<= >>= >>>=    ~=
+        static if( op == "+=" && __traits(isIntegral, T) && __traits(isIntegral, V1))
+        {
+            return cast(T)(atomicFetchAdd!(T)(val, mod) + mod);
+        }
+        else static if( op == "-=" && __traits(isIntegral, T) && __traits(isIntegral, V1))
+        {
+            return cast(T)(atomicFetchSub!(T)(val, mod) - mod);
+        }
+        else static if( op == "+=" || op == "-="  || op == "*="  || op == "/=" ||
+                   op == "%=" || op == "^^=" || op == "&="  || op == "|=" ||
+                   op == "^=" || op == "<<=" || op == ">>=" || op == ">>>=" ) // skip "~="
+        {
+            HeadUnshared!(T) get, set;
+
+            do
+            {
+                get = set = atomicLoad!(MemoryOrder.raw)( val );
+                mixin( "set " ~ op ~ " mod;" );
+            } while( !cas( &val, get, set ) );
+            return set;
+        }
+        else
+        {
+            static assert( false, "Operation not supported." );
+        }
+    }
+
+
+    bool cas(T,V1,V2)( shared(T)* here, const V1 ifThis, V2 writeThis ) pure nothrow @nogc
+        if( !is(T == class) && !is(T U : U*) &&  __traits( compiles, { *here = writeThis; } ) )
+    {
+        return casImpl(here, ifThis, writeThis);
+    }
+
+    bool cas(T,V1,V2)( shared(T)* here, const shared(V1) ifThis, shared(V2) writeThis ) pure nothrow @nogc
+        if( is(T == class) && __traits( compiles, { *here = writeThis; } ) )
+    {
+        return casImpl(here, ifThis, writeThis);
+    }
+
+    bool cas(T,V1,V2)( shared(T)* here, const shared(V1)* ifThis, shared(V2)* writeThis ) pure nothrow @nogc
+        if( is(T U : U*) && __traits( compiles, { *here = writeThis; } ) )
+    {
+        return casImpl(here, ifThis, writeThis);
+    }
+
+    private bool casImpl(T,V1,V2)( shared(T)* here, V1 ifThis, V2 writeThis ) pure nothrow @nogc
+    in
+    {
+        // NOTE: 32 bit x86 systems support 8 byte CAS, which only requires
+        //       4 byte alignment, so use size_t as the align type here.
+        static if( T.sizeof > size_t.sizeof )
+            assert( atomicValueIsProperlyAligned!(size_t)( cast(size_t) here ) );
+        else
+            assert( atomicValueIsProperlyAligned!(T)( cast(size_t) here ) );
+    }
+    body
+    {
+        static if( T.sizeof == byte.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 1 Byte CAS
+            //////////////////////////////////////////////////////////////////
+
+            asm pure nothrow @nogc
+            {
+                mov DL, writeThis;
+                mov AL, ifThis;
+                mov RCX, here;
+                lock; // lock always needed to make this op atomic
+                cmpxchg [RCX], DL;
+                setz AL;
+            }
+        }
+        else static if( T.sizeof == short.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 2 Byte CAS
+            //////////////////////////////////////////////////////////////////
+
+            asm pure nothrow @nogc
+            {
+                mov DX, writeThis;
+                mov AX, ifThis;
+                mov RCX, here;
+                lock; // lock always needed to make this op atomic
+                cmpxchg [RCX], DX;
+                setz AL;
+            }
+        }
+        else static if( T.sizeof == int.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 4 Byte CAS
+            //////////////////////////////////////////////////////////////////
+
+            asm pure nothrow @nogc
+            {
+                mov EDX, writeThis;
+                mov EAX, ifThis;
+                mov RCX, here;
+                lock; // lock always needed to make this op atomic
+                cmpxchg [RCX], EDX;
+                setz AL;
+            }
+        }
+        else static if( T.sizeof == long.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 8 Byte CAS on a 64-Bit Processor
+            //////////////////////////////////////////////////////////////////
+
+            asm pure nothrow @nogc
+            {
+                mov RDX, writeThis;
+                mov RAX, ifThis;
+                mov RCX, here;
+                lock; // lock always needed to make this op atomic
+                cmpxchg [RCX], RDX;
+                setz AL;
+            }
+        }
+        else static if( T.sizeof == long.sizeof*2 && has128BitCAS)
+        {
+            //////////////////////////////////////////////////////////////////
+            // 16 Byte CAS on a 64-Bit Processor
+            //////////////////////////////////////////////////////////////////
+            version(Win64){
+                //Windows 64 calling convention uses different registers.
+                //DMD appears to reverse the register order.
+                asm pure nothrow @nogc
+                {
+                    push RDI;
+                    push RBX;
+                    mov R9, writeThis;
+                    mov R10, ifThis;
+                    mov R11, here;
+
+                    mov RDI, R9;
+                    mov RBX, [RDI];
+                    mov RCX, 8[RDI];
+
+                    mov RDI, R10;
+                    mov RAX, [RDI];
+                    mov RDX, 8[RDI];
+
+                    mov RDI, R11;
+                    lock;
+                    cmpxchg16b [RDI];
+                    setz AL;
+                    pop RBX;
+                    pop RDI;
+                }
+
+            }else{
+
+                asm pure nothrow @nogc
+                {
+                    push RDI;
+                    push RBX;
+                    lea RDI, writeThis;
+                    mov RBX, [RDI];
+                    mov RCX, 8[RDI];
+                    lea RDI, ifThis;
+                    mov RAX, [RDI];
+                    mov RDX, 8[RDI];
+                    mov RDI, here;
+                    lock; // lock always needed to make this op atomic
+                    cmpxchg16b [RDI];
+                    setz AL;
+                    pop RBX;
+                    pop RDI;
+                }
+            }
+        }
+        else
+        {
+            static assert( false, "Invalid template type specified." );
+        }
+    }
+
+
+    enum MemoryOrder
+    {
+        raw,
+        acq,
+        rel,
+        seq,
+    }
+
+    deprecated("Please use MemoryOrder instead.")
+    alias MemoryOrder msync;
+
+
+    private
+    {
+        // NOTE: x86 loads implicitly have acquire semantics so a memory
+        //       barrier is only necessary on releases.
+        template needsLoadBarrier( MemoryOrder ms )
+        {
+            enum bool needsLoadBarrier = ms == MemoryOrder.seq;
+        }
+
+
+        // NOTE: x86 stores implicitly have release semantics so a memory
+        //       barrier is only necessary on acquires.
+        template needsStoreBarrier( MemoryOrder ms )
+        {
+            enum bool needsStoreBarrier = ms == MemoryOrder.seq;
+        }
+    }
+
+
+    HeadUnshared!(T) atomicLoad(MemoryOrder ms = MemoryOrder.seq, T)( ref const shared T val ) pure nothrow @nogc
+    if(!__traits(isFloating, T))
+    {
+        static assert( ms != MemoryOrder.rel, "invalid MemoryOrder for atomicLoad()" );
+        static assert( __traits(isPOD, T), "argument to atomicLoad() must be POD" );
+
+        static if( T.sizeof == byte.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 1 Byte Load
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsLoadBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov DL, 0;
+                    mov AL, 0;
+                    mov RCX, val;
+                    lock; // lock always needed to make this op atomic
+                    cmpxchg [RCX], DL;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov RAX, val;
+                    mov AL, [RAX];
+                }
+            }
+        }
+        else static if( T.sizeof == short.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 2 Byte Load
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsLoadBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov DX, 0;
+                    mov AX, 0;
+                    mov RCX, val;
+                    lock; // lock always needed to make this op atomic
+                    cmpxchg [RCX], DX;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov RAX, val;
+                    mov AX, [RAX];
+                }
+            }
+        }
+        else static if( T.sizeof == int.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 4 Byte Load
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsLoadBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov EDX, 0;
+                    mov EAX, 0;
+                    mov RCX, val;
+                    lock; // lock always needed to make this op atomic
+                    cmpxchg [RCX], EDX;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov RAX, val;
+                    mov EAX, [RAX];
+                }
+            }
+        }
+        else static if( T.sizeof == long.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 8 Byte Load
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsLoadBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov RDX, 0;
+                    mov RAX, 0;
+                    mov RCX, val;
+                    lock; // lock always needed to make this op atomic
+                    cmpxchg [RCX], RDX;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov RAX, val;
+                    mov RAX, [RAX];
+                }
+            }
+        }
+        else static if( T.sizeof == long.sizeof*2 && has128BitCAS )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 16 Byte Load on a 64-Bit Processor
+            //////////////////////////////////////////////////////////////////
+            version(Win64){
+                size_t[2] retVal;
+                asm pure nothrow @nogc
+                {
+                    push RDI;
+                    push RBX;
+                    mov RDI, val;
+                    mov RBX, 0;
+                    mov RCX, 0;
+                    mov RAX, 0;
+                    mov RDX, 0;
+                    lock; // lock always needed to make this op atomic
+                    cmpxchg16b [RDI];
+                    lea RDI, retVal;
+                    mov [RDI], RAX;
+                    mov 8[RDI], RDX;
+                    pop RBX;
+                    pop RDI;
+                }
+                return cast(typeof(return)) retVal;
+            }else{
+                asm pure nothrow @nogc
+                {
+                    push RDI;
+                    push RBX;
+                    mov RBX, 0;
+                    mov RCX, 0;
+                    mov RAX, 0;
+                    mov RDX, 0;
+                    mov RDI, val;
+                    lock; // lock always needed to make this op atomic
+                    cmpxchg16b [RDI];
+                    pop RBX;
+                    pop RDI;
+                }
+            }
+        }
+        else
+        {
+            static assert( false, "Invalid template type specified." );
+        }
+    }
+
+
+    void atomicStore(MemoryOrder ms = MemoryOrder.seq, T, V1)( ref shared T val, V1 newval ) pure nothrow @nogc
+        if( __traits( compiles, { val = newval; } ) )
+    {
+        static assert( ms != MemoryOrder.acq, "invalid MemoryOrder for atomicStore()" );
+        static assert( __traits(isPOD, T), "argument to atomicStore() must be POD" );
+
+        static if( T.sizeof == byte.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 1 Byte Store
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsStoreBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov RAX, val;
+                    mov DL, newval;
+                    lock;
+                    xchg [RAX], DL;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov RAX, val;
+                    mov DL, newval;
+                    mov [RAX], DL;
+                }
+            }
+        }
+        else static if( T.sizeof == short.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 2 Byte Store
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsStoreBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov RAX, val;
+                    mov DX, newval;
+                    lock;
+                    xchg [RAX], DX;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov RAX, val;
+                    mov DX, newval;
+                    mov [RAX], DX;
+                }
+            }
+        }
+        else static if( T.sizeof == int.sizeof )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 4 Byte Store
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsStoreBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov RAX, val;
+                    mov EDX, newval;
+                    lock;
+                    xchg [RAX], EDX;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov RAX, val;
+                    mov EDX, newval;
+                    mov [RAX], EDX;
+                }
+            }
+        }
+        else static if( T.sizeof == long.sizeof && has64BitCAS )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 8 Byte Store on a 64-Bit Processor
+            //////////////////////////////////////////////////////////////////
+
+            static if( needsStoreBarrier!(ms) )
+            {
+                asm pure nothrow @nogc
+                {
+                    mov RAX, val;
+                    mov RDX, newval;
+                    lock;
+                    xchg [RAX], RDX;
+                }
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    mov RAX, val;
+                    mov RDX, newval;
+                    mov [RAX], RDX;
+                }
+            }
+        }
+        else static if( T.sizeof == long.sizeof*2 && has128BitCAS )
+        {
+            //////////////////////////////////////////////////////////////////
+            // 16 Byte Store on a 64-Bit Processor
+            //////////////////////////////////////////////////////////////////
+            version(Win64){
+                asm pure nothrow @nogc
+                {
+                    push RDI;
+                    push RBX;
+                    mov R9, val;
+                    mov R10, newval;
+
+                    mov RDI, R10;
+                    mov RBX, [RDI];
+                    mov RCX, 8[RDI];
+
+                    mov RDI, R9;
+                    mov RAX, [RDI];
+                    mov RDX, 8[RDI];
+
+                    L1: lock; // lock always needed to make this op atomic
+                    cmpxchg16b [RDI];
+                    jne L1;
+                    pop RBX;
+                    pop RDI;
+                }
+            }else{
+                asm pure nothrow @nogc
+                {
+                    push RDI;
+                    push RBX;
+                    lea RDI, newval;
+                    mov RBX, [RDI];
+                    mov RCX, 8[RDI];
+                    mov RDI, val;
+                    mov RAX, [RDI];
+                    mov RDX, 8[RDI];
+                    L1: lock; // lock always needed to make this op atomic
+                    cmpxchg16b [RDI];
+                    jne L1;
+                    pop RBX;
+                    pop RDI;
+                }
+            }
+        }
+        else
+        {
+            static assert( false, "Invalid template type specified." );
+        }
+    }
+
+
+    void atomicFence() nothrow @nogc
+    {
+        // SSE2 is always present in 64-bit x86 chips.
+        asm nothrow @nogc
+        {
+            naked;
+
+            mfence;
+            ret;
+        }
+    }
+}
+else version( GNU )
+{
+    import gcc.builtins;
+
+    HeadUnshared!(T) atomicOp(string op, T, V1)( ref shared T val, V1 mod ) nothrow
+        if( __traits( compiles, mixin( "*cast(T*)&val" ~ op ~ "mod" ) ) )
+    {
+        // binary operators
+        //
+        // +    -   *   /   %   ^^  &
+        // |    ^   <<  >>  >>> ~   in
+        // ==   !=  <   <=  >   >=
+        static if( op == "+"  || op == "-"  || op == "*"  || op == "/"   ||
+                   op == "%"  || op == "^^" || op == "&"  || op == "|"   ||
+                   op == "^"  || op == "<<" || op == ">>" || op == ">>>" ||
+                   op == "~"  || // skip "in"
+                   op == "==" || op == "!=" || op == "<"  || op == "<="  ||
+                   op == ">"  || op == ">=" )
+        {
+            HeadUnshared!(T) get = atomicLoad!(MemoryOrder.raw)( val );
+            mixin( "return get " ~ op ~ " mod;" );
+        }
+        else
+        // assignment operators
+        //
+        // +=   -=  *=  /=  %=  ^^= &=
+        // |=   ^=  <<= >>= >>>=    ~=
+        static if( op == "+=" || op == "-="  || op == "*="  || op == "/=" ||
+                   op == "%=" || op == "^^=" || op == "&="  || op == "|=" ||
+                   op == "^=" || op == "<<=" || op == ">>=" || op == ">>>=" ) // skip "~="
+        {
+            HeadUnshared!(T) get, set;
+
+            do
+            {
+                get = set = atomicLoad!(MemoryOrder.raw)( val );
+                mixin( "set " ~ op ~ " mod;" );
+            } while( !cas( &val, get, set ) );
+            return set;
+        }
+        else
+        {
+            static assert( false, "Operation not supported." );
+        }
+    }
+
+
+    bool cas(T,V1,V2)( shared(T)* here, const V1 ifThis, V2 writeThis ) pure nothrow @nogc
+        if( !is(T == class) && !is(T U : U*) && __traits( compiles, { *here = writeThis; } ) )
+    {
+        return casImpl(here, ifThis, writeThis);
+    }
+
+    bool cas(T,V1,V2)( shared(T)* here, const shared(V1) ifThis, shared(V2) writeThis ) pure nothrow @nogc
+        if( is(T == class) && __traits( compiles, { *here = writeThis; } ) )
+    {
+        return casImpl(here, ifThis, writeThis);
+    }
+
+    bool cas(T,V1,V2)( shared(T)* here, const shared(V1)* ifThis, shared(V2)* writeThis ) pure nothrow @nogc
+        if( is(T U : U*) && __traits( compiles, { *here = writeThis; } ) )
+    {
+        return casImpl(here, ifThis, writeThis);
+    }
+
+    private bool casImpl(T,V1,V2)( shared(T)* here, V1 ifThis, V2 writeThis ) pure nothrow @nogc
+    {
+        bool res = void;
+
+        static if (__traits(isFloating, T))
+        {
+            static if (T.sizeof == int.sizeof)
+            {
+                static assert(is(T : float));
+
+                res = __atomic_compare_exchange_4(here, cast(void*) &ifThis, *cast(int*) &writeThis,
+                                                  false, MemoryOrder.seq, MemoryOrder.seq);
+            }
+            else static if(T.sizeof == long.sizeof)
+            {
+                static assert(is(T : double));
+
+                res = __atomic_compare_exchange_8(here, cast(void*) &ifThis, *cast(long*) &writeThis,
+                                                  false, MemoryOrder.seq, MemoryOrder.seq);
+            }
+            else
+            {
+                static assert(false, "Cannot atomically store 80-bit reals.");
+            }
+        }
+        else static if (is(T P == U*, U) || is(T == class) || is(T == interface))
+        {
+            version (D_LP64)
+                res = __atomic_compare_exchange_8(here, cast(void*) &ifThis, *cast(ulong*) &writeThis,
+                                                  false, MemoryOrder.seq, MemoryOrder.seq);
+            else
+                res = __atomic_compare_exchange_4(here, cast(void*) &ifThis, *cast(uint*) &writeThis,
+                                                  false, MemoryOrder.seq, MemoryOrder.seq);
+        }
+        else static if (T.sizeof == byte.sizeof)
+        {
+            res = __atomic_compare_exchange_1(here, cast(void*) &ifThis, writeThis,
+                                              false, MemoryOrder.seq, MemoryOrder.seq);
+        }
+        else static if (T.sizeof == short.sizeof)
+        {
+            res = __atomic_compare_exchange_2(here, cast(void*) &ifThis, writeThis,
+                                              false, MemoryOrder.seq, MemoryOrder.seq);
+        }
+        else static if (T.sizeof == int.sizeof)
+        {
+            res = __atomic_compare_exchange_4(here, cast(void*) &ifThis, writeThis,
+                                              false, MemoryOrder.seq, MemoryOrder.seq);
+        }
+        else static if (T.sizeof == long.sizeof)
+        {
+            res = __atomic_compare_exchange_8(here, cast(void*) &ifThis, writeThis,
+                                              false, MemoryOrder.seq, MemoryOrder.seq);
+        }
+        else static if( T.sizeof == long.sizeof * 2 && HAVE_LIBATOMIC)
+        {
+            res = __atomic_compare_exchange(T.sizeof, here, cast(void*)&ifThis, cast(void*)&writeThis,
+                                            MemoryOrder.seq, MemoryOrder.seq);
+        }
+        else
+            static assert(0, "Invalid template type specified.");
+
+        return res;
+    }
+
+
+    // Memory model types for the __atomic* builtins.
+    enum MemoryOrder
+    {
+        raw = 0,
+        acq = 2,
+        rel = 3,
+        seq = 5,
+    }
+
+    deprecated("Please use MemoryOrder instead.")
+    alias MemoryOrder msync;
+
+
+    HeadUnshared!(T) atomicLoad(MemoryOrder ms = MemoryOrder.seq, T)( ref const shared T val )
+    if(!__traits(isFloating, T))
+    {
+        static assert (ms != MemoryOrder.rel, "Invalid MemoryOrder for atomicLoad");
+        static assert(__traits(isPOD, T), "argument to atomicLoad() must be POD");
+
+        static if (T.sizeof == ubyte.sizeof)
+        {
+            ubyte value = __atomic_load_1(&val, ms);
+            return *cast(HeadUnshared!T*) &value;
+        }
+        else static if (T.sizeof == ushort.sizeof)
+        {
+            ushort value = __atomic_load_2(&val, ms);
+            return *cast(HeadUnshared!T*) &value;
+        }
+        else static if (T.sizeof == uint.sizeof)
+        {
+            uint value = __atomic_load_4(&val, ms);
+            return *cast(HeadUnshared!T*) &value;
+        }
+        else static if (T.sizeof == ulong.sizeof)
+        {
+            ulong value = __atomic_load_8(&val, ms);
+            return *cast(HeadUnshared!T*) &value;
+        }
+        else static if (T.sizeof == ulong.sizeof * 2 && HAVE_LIBATOMIC)
+        {
+            T value;
+            __atomic_load(T.sizeof, &val, cast(void*)&value, ms);
+            return *cast(HeadUnshared!T*) &value;
+        }
+        else
+            static assert(0, "Invalid template type specified.");
+    }
+
+
+    void atomicStore(MemoryOrder ms = MemoryOrder.seq, T, V1)( ref shared T val, V1 newval )
+        if( __traits( compiles, { val = newval; } ) )
+    {
+        static assert(ms != MemoryOrder.acq, "Invalid MemoryOrder for atomicStore");
+        static assert(__traits(isPOD, T), "argument to atomicLoad() must be POD");
+
+        static if (T.sizeof == ubyte.sizeof)
+        {
+            __atomic_store_1(&val, *cast(ubyte*) &newval, ms);
+        }
+        else static if (T.sizeof == ushort.sizeof)
+        {
+            __atomic_store_2(&val, *cast(ushort*) &newval, ms);
+        }
+        else static if (T.sizeof == uint.sizeof)
+        {
+            __atomic_store_4(&val, *cast(uint*) &newval, ms);
+        }
+        else static if (T.sizeof == ulong.sizeof)
+        {
+            __atomic_store_8(&val, *cast(ulong*) &newval, ms);
+        }
+        else static if (T.sizeof == ulong.sizeof * 2 && HAVE_LIBATOMIC)
+        {
+            __atomic_store(T.sizeof, &val, cast(void*)&newval, ms);
+        }
+        else
+            static assert(0, "Invalid template type specified.");
+    }
+
+
+    void atomicFence() nothrow @nogc
+    {
+        __atomic_thread_fence(MemoryOrder.seq);
+    }
+}
+
+// This is an ABI adapter that works on all architectures.  It type puns
+// floats and doubles to ints and longs, atomically loads them, then puns
+// them back.  This is necessary so that they get returned in floating
+// point instead of integer registers.
+HeadUnshared!(T) atomicLoad(MemoryOrder ms = MemoryOrder.seq, T)( ref const shared T val ) pure nothrow @nogc
+if(__traits(isFloating, T))
+{
+    static if(T.sizeof == int.sizeof)
+    {
+        static assert(is(T : float));
+        auto ptr = cast(const shared int*) &val;
+        auto asInt = atomicLoad!(ms)(*ptr);
+        return *(cast(typeof(return)*) &asInt);
+    }
+    else static if(T.sizeof == long.sizeof)
+    {
+        static assert(is(T : double));
+        auto ptr = cast(const shared long*) &val;
+        auto asLong = atomicLoad!(ms)(*ptr);
+        return *(cast(typeof(return)*) &asLong);
+    }
+    else
+    {
+        static assert(0, "Cannot atomically load 80-bit reals.");
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Unit Tests
+////////////////////////////////////////////////////////////////////////////////
+
+
+version( unittest )
+{
+    void testCAS(T)( T val ) pure nothrow
+    in
+    {
+        assert(val !is T.init);
+    }
+    body
+    {
+        T         base;
+        shared(T) atom;
+
+        assert( base !is val, T.stringof );
+        assert( atom is base, T.stringof );
+
+        assert( cas( &atom, base, val ), T.stringof );
+        assert( atom is val, T.stringof );
+        assert( !cas( &atom, base, base ), T.stringof );
+        assert( atom is val, T.stringof );
+    }
+
+    void testLoadStore(MemoryOrder ms = MemoryOrder.seq, T)( T val = T.init + 1 ) pure nothrow
+    {
+        T         base = cast(T) 0;
+        shared(T) atom = cast(T) 0;
+
+        assert( base !is val );
+        assert( atom is base );
+        atomicStore!(ms)( atom, val );
+        base = atomicLoad!(ms)( atom );
+
+        assert( base is val, T.stringof );
+        assert( atom is val );
+    }
+
+
+    void testType(T)( T val = T.init + 1 ) pure nothrow
+    {
+        testCAS!(T)( val );
+        testLoadStore!(MemoryOrder.seq, T)( val );
+        testLoadStore!(MemoryOrder.raw, T)( val );
+    }
+
+
+    //@@@BUG@@@ http://d.puremagic.com/issues/show_bug.cgi?id=8081
+    /+pure nothrow+/ unittest
+    {
+        testType!(bool)();
+
+        testType!(byte)();
+        testType!(ubyte)();
+
+        testType!(short)();
+        testType!(ushort)();
+
+        testType!(int)();
+        testType!(uint)();
+
+        testType!(shared int*)();
+
+        static class Klass {}
+        testCAS!(shared Klass)( new shared(Klass) );
+
+        testType!(float)(1.0f);
+        testType!(double)(1.0);
+
+        static if( has64BitCAS )
+        {
+            testType!(long)();
+            testType!(ulong)();
+        }
+
+        static if (has128BitCAS)
+        {
+            struct DoubleValue
+            {
+                long value1;
+                long value2;
+            }
+
+            align(16) shared DoubleValue a;
+            atomicStore(a, DoubleValue(1,2));
+            assert(a.value1 == 1 && a.value2 ==2);
+
+            while(!cas(&a, DoubleValue(1,2), DoubleValue(3,4))){}
+            assert(a.value1 == 3 && a.value2 ==4);
+
+            align(16) DoubleValue b = atomicLoad(a);
+            assert(b.value1 == 3 && b.value2 ==4);
+        }
+
+        version (D_LP64)
+        {
+            enum hasDWCAS = has128BitCAS;
+        }
+        else
+        {
+            enum hasDWCAS = has64BitCAS;
+        }
+
+        static if (hasDWCAS)
+        {
+            static struct List { size_t gen; List* next; }
+            shared(List) head;
+            assert(cas(&head, shared(List)(0, null), shared(List)(1, cast(List*)1)));
+            assert(head.gen == 1);
+            assert(cast(size_t)head.next == 1);
+        }
+
+        shared(size_t) i;
+
+        atomicOp!"+="( i, cast(size_t) 1 );
+        assert( i == 1 );
+
+        atomicOp!"-="( i, cast(size_t) 1 );
+        assert( i == 0 );
+
+        shared float f = 0;
+        atomicOp!"+="( f, 1 );
+        assert( f == 1 );
+
+        shared double d = 0;
+        atomicOp!"+="( d, 1 );
+        assert( d == 1 );
+    }
+
+    //@@@BUG@@@ http://d.puremagic.com/issues/show_bug.cgi?id=8081
+    /+pure nothrow+/ unittest
+    {
+        static struct S { int val; }
+        auto s = shared(S)(1);
+
+        shared(S*) ptr;
+
+        // head unshared
+        shared(S)* ifThis = null;
+        shared(S)* writeThis = &s;
+        assert(ptr is null);
+        assert(cas(&ptr, ifThis, writeThis));
+        assert(ptr is writeThis);
+
+        // head shared
+        shared(S*) ifThis2 = writeThis;
+        shared(S*) writeThis2 = null;
+        assert(cas(&ptr, ifThis2, writeThis2));
+        assert(ptr is null);
+
+        // head unshared target doesn't want atomic CAS
+        shared(S)* ptr2;
+        static assert(!__traits(compiles, cas(&ptr2, ifThis, writeThis)));
+        static assert(!__traits(compiles, cas(&ptr2, ifThis2, writeThis2)));
+    }
+
+    unittest
+    {
+        import core.thread;
+
+        // Use heap memory to ensure an optimizing
+        // compiler doesn't put things in registers.
+        uint* x = new uint();
+        bool* f = new bool();
+        uint* r = new uint();
+
+        auto thr = new Thread(()
+        {
+            while (!*f)
+            {
+            }
+
+            atomicFence();
+
+            *r = *x;
+        });
+
+        thr.start();
+
+        *x = 42;
+
+        atomicFence();
+
+        *f = true;
+
+        atomicFence();
+
+        thr.join();
+
+        assert(*r == 42);
+    }
+
+    // === atomicFetchAdd and atomicFetchSub operations ====
+    unittest
+    {
+        shared ubyte u8 = 1;
+        shared ushort u16 = 2;
+        shared uint u32 = 3;
+        shared byte i8 = 5;
+        shared short i16 = 6;
+        shared int i32 = 7;
+
+        assert(atomicOp!"+="(u8, 8) == 9);
+        assert(atomicOp!"+="(u16, 8) == 10);
+        assert(atomicOp!"+="(u32, 8) == 11);
+        assert(atomicOp!"+="(i8, 8) == 13);
+        assert(atomicOp!"+="(i16, 8) == 14);
+        assert(atomicOp!"+="(i32, 8) == 15);
+        version( AsmX86_64 )
+        {
+            shared ulong u64 = 4;
+            shared long i64 = 8;
+            assert(atomicOp!"+="(u64, 8) == 12);
+            assert(atomicOp!"+="(i64, 8) == 16);
+        }
+    }
+
+    unittest
+    {
+        shared ubyte u8 = 1;
+        shared ushort u16 = 2;
+        shared uint u32 = 3;
+        shared byte i8 = 5;
+        shared short i16 = 6;
+        shared int i32 = 7;
+
+        assert(atomicOp!"-="(u8, 1) == 0);
+        assert(atomicOp!"-="(u16, 1) == 1);
+        assert(atomicOp!"-="(u32, 1) == 2);
+        assert(atomicOp!"-="(i8, 1) == 4);
+        assert(atomicOp!"-="(i16, 1) == 5);
+        assert(atomicOp!"-="(i32, 1) == 6);
+        version( AsmX86_64 )
+        {
+            shared ulong u64 = 4;
+            shared long i64 = 8;
+            assert(atomicOp!"-="(u64, 1) == 3);
+            assert(atomicOp!"-="(i64, 1) == 7);
+        }
+    }
+}
diff --git a/libphobos/libdruntime/core/attribute.d b/libphobos/libdruntime/core/attribute.d
new file mode 100644
index 00000000000..9d350d8e100
--- /dev/null
+++ b/libphobos/libdruntime/core/attribute.d
@@ -0,0 +1,57 @@
+/**
+ * This module contains UDA's (User Defined Attributes) either used in
+ * the runtime or special UDA's recognized by compiler.
+ *
+ * Copyright: Copyright Jacob Carlborg 2015.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Jacob Carlborg
+ * Source:    $(DRUNTIMESRC core/_attribute.d)
+ */
+
+/*          Copyright Jacob Carlborg 2015.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.attribute;
+
+/**
+ * Use this attribute to attach an Objective-C selector to a method.
+ *
+ * This is a special compiler recognized attribute, it has several
+ * requirements, which all will be enforced by the compiler:
+ *
+ * $(UL
+ *  $(LI
+ *      The attribute can only be attached to methods or constructors which
+ *      have Objective-C linkage. That is, a method or a constructor in a
+ *      class or interface declared as $(D_CODE extern(Objective-C)).
+ *  ),
+ *
+ *  $(LI It cannot be attached to a method or constructor that is a template),
+ *
+ *  $(LI
+ *      The number of colons in the string need to match the number of
+ *      arguments the method accept.
+ *  ),
+ *
+ *  $(LI It can only be used once in a method declaration)
+ * )
+ *
+ * Examples:
+ * ---
+ * extern (Objective-C)
+ * class NSObject
+ * {
+ *  this() @selector("init");
+ *  static NSObject alloc() @selector("alloc");
+ *  NSObject initWithUTF8String(in char* str) @selector("initWithUTF8String:");
+ *  ObjcObject copyScriptingValue(ObjcObject value, NSString key, NSDictionary properties)
+ *      @selector("copyScriptingValue:forKey:withProperties:");
+ * }
+ * ---
+ */
+version (D_ObjectiveC) struct selector
+{
+    string selector;
+}
diff --git a/libphobos/libdruntime/core/bitop.d b/libphobos/libdruntime/core/bitop.d
new file mode 100644
index 00000000000..1d138dc24d6
--- /dev/null
+++ b/libphobos/libdruntime/core/bitop.d
@@ -0,0 +1,1018 @@
+/**
+ * This module contains a collection of bit-level operations.
+ *
+ * Copyright: Copyright Don Clugston 2005 - 2013.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Don Clugston, Sean Kelly, Walter Bright, Alex Rønne Petersen, Thomas Stuart Bockman
+ * Source:    $(DRUNTIMESRC core/_bitop.d)
+ */
+
+module core.bitop;
+
+nothrow:
+@safe:
+@nogc:
+
+version( D_InlineAsm_X86_64 )
+    version = AsmX86;
+else version( D_InlineAsm_X86 )
+    version = AsmX86;
+
+version (X86_64)
+    version = AnyX86;
+else version (X86)
+    version = AnyX86;
+
+// Use to implement 64-bit bitops on 32-bit arch.
+private union Split64
+{
+    ulong u64;
+    struct
+    {
+        version(LittleEndian)
+        {
+            uint lo;
+            uint hi;
+        }
+        else
+        {
+            uint hi;
+            uint lo;
+        }
+    }
+
+    pragma(inline, true)
+    this(ulong u64) @safe pure nothrow @nogc
+    {
+        if (__ctfe)
+        {
+            lo = cast(uint) u64;
+            hi = cast(uint) (u64 >>> 32);
+        }
+        else
+            this.u64 = u64;
+    }
+}
+
+unittest
+{
+    const rt = Split64(1);
+    assert((rt.lo == 1) && (rt.hi == 0));
+
+    enum ct = Split64(1);
+    assert((ct.lo == rt.lo) && (ct.hi == rt.hi));
+}
+
+/**
+ * Scans the bits in v starting with bit 0, looking
+ * for the first set bit.
+ * Returns:
+ *      The bit number of the first bit set.
+ *      The return value is undefined if v is zero.
+ */
+int bsf(uint v) pure
+{
+    pragma(inline, false);  // so intrinsic detection will work
+    return softBsf!uint(v);
+}
+
+/// ditto
+int bsf(ulong v) pure
+{
+    static if (size_t.sizeof == ulong.sizeof)  // 64 bit code gen
+    {
+        pragma(inline, false);   // so intrinsic detection will work
+        return softBsf!ulong(v);
+    }
+    else
+    {
+        /* intrinsic not available for 32 bit code,
+         * make do with 32 bit bsf
+         */
+        const sv = Split64(v);
+        return (sv.lo == 0)?
+            bsf(sv.hi) + 32 :
+            bsf(sv.lo);
+    }
+}
+
+///
+unittest
+{
+    assert(bsf(0x21) == 0);
+    assert(bsf(ulong.max << 39) == 39);
+}
+
+unittest
+{
+    // Make sure bsf() is available at CTFE
+    enum test_ctfe = bsf(ulong.max);
+    assert(test_ctfe == 0);
+}
+
+/**
+ * Scans the bits in v from the most significant bit
+ * to the least significant bit, looking
+ * for the first set bit.
+ * Returns:
+ *      The bit number of the first bit set.
+ *      The return value is undefined if v is zero.
+ */
+int bsr(uint v) pure
+{
+    pragma(inline, false);  // so intrinsic detection will work
+    return softBsr!uint(v);
+}
+
+/// ditto
+int bsr(ulong v) pure
+{
+    static if (size_t.sizeof == ulong.sizeof)  // 64 bit code gen
+    {
+        pragma(inline, false);   // so intrinsic detection will work
+        return softBsr!ulong(v);
+    }
+    else
+    {
+        /* intrinsic not available for 32 bit code,
+         * make do with 32 bit bsr
+         */
+        const sv = Split64(v);
+        return (sv.hi == 0)?
+            bsr(sv.lo) :
+            bsr(sv.hi) + 32;
+    }
+}
+
+///
+unittest
+{
+    assert(bsr(0x21) == 5);
+    assert(bsr((ulong.max >> 15) - 1) == 48);
+}
+
+unittest
+{
+    // Make sure bsr() is available at CTFE
+    enum test_ctfe = bsr(ulong.max);
+    assert(test_ctfe == 63);
+}
+
+private alias softBsf(N) = softScan!(N, true);
+private alias softBsr(N) = softScan!(N, false);
+
+/* Shared software fallback implementation for bit scan foward and reverse.
+
+If forward is true, bsf is computed (the index of the first set bit).
+If forward is false, bsr is computed (the index of the last set bit).
+
+-1 is returned if no bits are set (v == 0).
+*/
+private int softScan(N, bool forward)(N v) pure
+    if(is(N == uint) || is(N == ulong))
+{
+    // bsf() and bsr() are officially undefined for v == 0.
+    if (!v)
+        return -1;
+
+    // This is essentially an unrolled binary search:
+    enum mask(ulong lo) = forward ? cast(N) lo : cast(N)~lo;
+    enum inc(int up) = forward ? up : -up;
+
+    N x;
+    int ret;
+    static if (is(N == ulong))
+    {
+        x = v & mask!0x0000_0000_FFFF_FFFFL;
+        if (x)
+        {
+            v = x;
+            ret = forward ? 0 : 63;
+        }
+        else
+            ret = forward ? 32 : 31;
+
+        x = v & mask!0x0000_FFFF_0000_FFFFL;
+        if (x)
+            v = x;
+        else
+            ret += inc!16;
+    }
+    else static if (is(N == uint))
+    {
+        x = v & mask!0x0000_FFFF;
+        if (x)
+        {
+            v = x;
+            ret = forward ? 0 : 31;
+        }
+        else
+            ret = forward ? 16 : 15;
+    }
+    else
+        static assert(false);
+
+    x = v & mask!0x00FF_00FF_00FF_00FFL;
+    if (x)
+        v = x;
+    else
+        ret += inc!8;
+
+    x = v & mask!0x0F0F_0F0F_0F0F_0F0FL;
+    if (x)
+        v = x;
+    else
+        ret += inc!4;
+
+    x = v & mask!0x3333_3333_3333_3333L;
+    if (x)
+        v = x;
+    else
+        ret += inc!2;
+
+    x = v & mask!0x5555_5555_5555_5555L;
+    if (!x)
+        ret += inc!1;
+
+    return ret;
+}
+
+unittest
+{
+    assert(softBsf!uint(0u) == -1);
+    assert(softBsr!uint(0u) == -1);
+    assert(softBsf!ulong(0uL) == -1);
+    assert(softBsr!ulong(0uL) == -1);
+
+    assert(softBsf!uint(0x0031_A000) == 13);
+    assert(softBsr!uint(0x0031_A000) == 21);
+    assert(softBsf!ulong(0x0000_0001_8000_0000L) == 31);
+    assert(softBsr!ulong(0x0000_0001_8000_0000L) == 32);
+
+    foreach (b; 0 .. 64)
+    {
+        if(b < 32)
+        {
+            assert(softBsf!uint(1u << b) == b);
+            assert(softBsr!uint(1u << b) == b);
+        }
+
+        assert(softBsf!ulong(1uL << b) == b);
+        assert(softBsr!ulong(1uL << b) == b);
+    }
+}
+
+/**
+ * Tests the bit.
+ * (No longer an intrisic - the compiler recognizes the patterns
+ * in the body.)
+ */
+int bt(in size_t* p, size_t bitnum) pure @system
+{
+    static if (size_t.sizeof == 8)
+        return ((p[bitnum >> 6] & (1L << (bitnum & 63)))) != 0;
+    else static if (size_t.sizeof == 4)
+        return ((p[bitnum >> 5] & (1  << (bitnum & 31)))) != 0;
+    else
+        static assert(0);
+}
+///
+@system pure unittest
+{
+    size_t[2] array;
+
+    array[0] = 2;
+    array[1] = 0x100;
+
+    assert(bt(array.ptr, 1));
+    assert(array[0] == 2);
+    assert(array[1] == 0x100);
+}
+
+/**
+ * Tests and complements the bit.
+ */
+int btc(size_t* p, size_t bitnum) pure @system;
+
+
+/**
+ * Tests and resets (sets to 0) the bit.
+ */
+int btr(size_t* p, size_t bitnum) pure @system;
+
+
+/**
+ * Tests and sets the bit.
+ * Params:
+ * p = a non-NULL pointer to an array of size_ts.
+ * bitnum = a bit number, starting with bit 0 of p[0],
+ * and progressing. It addresses bits like the expression:
+---
+p[index / (size_t.sizeof*8)] & (1 << (index & ((size_t.sizeof*8) - 1)))
+---
+ * Returns:
+ *      A non-zero value if the bit was set, and a zero
+ *      if it was clear.
+ */
+int bts(size_t* p, size_t bitnum) pure @system;
+
+///
+@system pure unittest
+{
+    size_t[2] array;
+
+    array[0] = 2;
+    array[1] = 0x100;
+
+    assert(btc(array.ptr, 35) == 0);
+    if (size_t.sizeof == 8)
+    {
+        assert(array[0] == 0x8_0000_0002);
+        assert(array[1] == 0x100);
+    }
+    else
+    {
+        assert(array[0] == 2);
+        assert(array[1] == 0x108);
+    }
+
+    assert(btc(array.ptr, 35));
+    assert(array[0] == 2);
+    assert(array[1] == 0x100);
+
+    assert(bts(array.ptr, 35) == 0);
+    if (size_t.sizeof == 8)
+    {
+        assert(array[0] == 0x8_0000_0002);
+        assert(array[1] == 0x100);
+    }
+    else
+    {
+        assert(array[0] == 2);
+        assert(array[1] == 0x108);
+    }
+
+    assert(btr(array.ptr, 35));
+    assert(array[0] == 2);
+    assert(array[1] == 0x100);
+}
+
+/**
+ * Range over bit set. Each element is the bit number that is set.
+ *
+ * This is more efficient than testing each bit in a sparsely populated bit
+ * set. Note that the first bit in the bit set would be bit 0.
+ */
+struct BitRange
+{
+    /// Number of bits in each size_t
+    enum bitsPerWord = size_t.sizeof * 8;
+
+    private
+    {
+        const(size_t)*bits; // points at next word of bits to check
+        size_t cur; // needed to allow searching bits using bsf
+        size_t idx; // index of current set bit
+        size_t len; // number of bits in the bit set.
+    }
+    @nogc nothrow pure:
+
+    /**
+     * Construct a BitRange.
+     *
+     * Params:
+     *   bitarr - The array of bits to iterate over
+     *   numBits - The total number of valid bits in the given bit array
+     */
+    this(const(size_t)* bitarr, size_t numBits) @system
+    {
+        bits = bitarr;
+        len = numBits;
+        if (len)
+        {
+            // prime the first bit
+            cur = *bits++ ^ 1;
+            popFront();
+        }
+    }
+
+    /// Range functions
+    size_t front()
+    {
+        assert(!empty);
+        return idx;
+    }
+
+    /// ditto
+    bool empty() const
+    {
+        return idx >= len;
+    }
+
+    /// ditto
+    void popFront() @system
+    {
+        // clear the current bit
+        auto curbit = idx % bitsPerWord;
+        cur ^= size_t(1) << curbit;
+        if(!cur)
+        {
+            // find next size_t with set bit
+            idx -= curbit;
+            while (!cur)
+            {
+                if ((idx += bitsPerWord) >= len)
+                    // now empty
+                    return;
+                cur = *bits++;
+            }
+            idx += bsf(cur);
+        }
+        else
+        {
+            idx += bsf(cur) - curbit;
+        }
+    }
+}
+
+///
+@system unittest
+{
+    import core.stdc.stdlib : malloc, free;
+    import core.stdc.string : memset;
+
+    // initialize a bit array
+    enum nBytes = (100 + BitRange.bitsPerWord - 1) / 8;
+    size_t *bitArr = cast(size_t *)malloc(nBytes);
+    scope(exit) free(bitArr);
+    memset(bitArr, 0, nBytes);
+
+    // set some bits
+    bts(bitArr, 48);
+    bts(bitArr, 24);
+    bts(bitArr, 95);
+    bts(bitArr, 78);
+
+    enum sum = 48 + 24 + 95 + 78;
+
+    // iterate
+    size_t testSum;
+    size_t nBits;
+    foreach(b; BitRange(bitArr, 100))
+    {
+        testSum += b;
+        ++nBits;
+    }
+
+    assert(testSum == sum);
+    assert(nBits == 4);
+}
+
+@system unittest
+{
+    void testIt(size_t numBits, size_t[] bitsToTest...) nothrow @nogc
+    {
+        import core.stdc.stdlib : malloc, free;
+        import core.stdc.string : memset;
+        immutable numBytes = (numBits + size_t.sizeof * 8 - 1) / 8;
+        size_t* bitArr = cast(size_t *)malloc(numBytes);
+        scope(exit) free(bitArr);
+        memset(bitArr, 0, numBytes);
+        foreach(b; bitsToTest)
+            bts(bitArr, b);
+        auto br = BitRange(bitArr, numBits);
+        foreach(b; bitsToTest)
+        {
+            assert(!br.empty);
+            assert(b == br.front);
+            br.popFront();
+        }
+        assert(br.empty);
+    }
+
+    testIt(100, 0, 1, 31, 63, 85);
+    testIt(100, 6, 45, 89, 92, 99);
+}
+
+/**
+ * Swaps bytes in a 4 byte uint end-to-end, i.e. byte 0 becomes
+ * byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3
+ * becomes byte 0.
+ */
+uint bswap(uint v) pure;
+
+/**
+ * Swaps bytes in an 8 byte ulong end-to-end, i.e. byte 0 becomes
+ * byte 7, byte 1 becomes byte 6, etc.
+ */
+ulong bswap(ulong v) pure
+{
+    auto sv = Split64(v);
+
+    const temp = sv.lo;
+    sv.lo = bswap(sv.hi);
+    sv.hi = bswap(temp);
+
+    return (cast(ulong) sv.hi << 32) | sv.lo;
+}
+
+version (DigitalMars) version (AnyX86) @system // not pure
+{
+    /**
+     * Reads I/O port at port_address.
+     */
+    ubyte inp(uint port_address);
+
+
+    /**
+     * ditto
+     */
+    ushort inpw(uint port_address);
+
+
+    /**
+     * ditto
+     */
+    uint inpl(uint port_address);
+
+
+    /**
+     * Writes and returns value to I/O port at port_address.
+     */
+    ubyte outp(uint port_address, ubyte value);
+
+
+    /**
+     * ditto
+     */
+    ushort outpw(uint port_address, ushort value);
+
+
+    /**
+     * ditto
+     */
+    uint outpl(uint port_address, uint value);
+}
+
+
+/**
+ *  Calculates the number of set bits in an integer.
+ */
+int popcnt(uint x) pure
+{
+    // Select the fastest method depending on the compiler and CPU architecture
+    version(LDC)
+    {
+        return _popcnt(x);
+    }
+    else
+    {
+        version(DigitalMars)
+        {
+            static if (is(typeof(_popcnt(uint.max))))
+            {
+                import core.cpuid;
+                if (!__ctfe && hasPopcnt)
+                    return _popcnt(x);
+            }
+        }
+
+        return softPopcnt!uint(x);
+    }
+}
+
+unittest
+{
+    assert( popcnt( 0 ) == 0 );
+    assert( popcnt( 7 ) == 3 );
+    assert( popcnt( 0xAA )== 4 );
+    assert( popcnt( 0x8421_1248 ) == 8 );
+    assert( popcnt( 0xFFFF_FFFF ) == 32 );
+    assert( popcnt( 0xCCCC_CCCC ) == 16 );
+    assert( popcnt( 0x7777_7777 ) == 24 );
+
+    // Make sure popcnt() is available at CTFE
+    enum test_ctfe = popcnt(uint.max);
+    assert(test_ctfe == 32);
+}
+
+/// ditto
+int popcnt(ulong x) pure
+{
+    // Select the fastest method depending on the compiler and CPU architecture
+    version(LDC)
+    {
+        return _popcnt(x);
+    }
+    else
+    {
+        import core.cpuid;
+
+        static if (size_t.sizeof == uint.sizeof)
+        {
+            const sx = Split64(x);
+            version(DigitalMars)
+            {
+                static if (is(typeof(_popcnt(uint.max))))
+                {
+                    if (!__ctfe && hasPopcnt)
+                        return _popcnt(sx.lo) + _popcnt(sx.hi);
+                }
+            }
+
+            return softPopcnt!uint(sx.lo) + softPopcnt!uint(sx.hi);
+        }
+        else static if (size_t.sizeof == ulong.sizeof)
+        {
+            version(DigitalMars)
+            {
+                static if (is(typeof(_popcnt(ulong.max))))
+                {
+                    if (!__ctfe && hasPopcnt)
+                        return _popcnt(x);
+                }
+            }
+
+            return softPopcnt!ulong(x);
+        }
+        else
+            static assert(false);
+    }
+}
+
+unittest
+{
+    assert(popcnt(0uL) == 0);
+    assert(popcnt(1uL) == 1);
+    assert(popcnt((1uL << 32) - 1) == 32);
+    assert(popcnt(0x48_65_6C_6C_6F_3F_21_00uL) == 28);
+    assert(popcnt(ulong.max) == 64);
+
+    // Make sure popcnt() is available at CTFE
+    enum test_ctfe = popcnt(ulong.max);
+    assert(test_ctfe == 64);
+}
+
+private int softPopcnt(N)(N x) pure
+    if (is(N == uint) || is(N == ulong))
+{
+    // Avoid branches, and the potential for cache misses which
+    // could be incurred with a table lookup.
+
+    // We need to mask alternate bits to prevent the
+    // sum from overflowing.
+    // add neighbouring bits. Each bit is 0 or 1.
+    enum mask1 = cast(N) 0x5555_5555_5555_5555L;
+    x = x - ((x>>1) & mask1);
+    // now each two bits of x is a number 00,01 or 10.
+    // now add neighbouring pairs
+    enum mask2a = cast(N) 0xCCCC_CCCC_CCCC_CCCCL;
+    enum mask2b = cast(N) 0x3333_3333_3333_3333L;
+    x = ((x & mask2a)>>2) + (x & mask2b);
+    // now each nibble holds 0000-0100. Adding them won't
+    // overflow any more, so we don't need to mask any more
+
+    enum mask4 = cast(N) 0x0F0F_0F0F_0F0F_0F0FL;
+    x = (x + (x >> 4)) & mask4;
+
+    enum shiftbits = is(N == uint)? 24 : 56;
+    enum maskMul = cast(N) 0x0101_0101_0101_0101L;
+    x = (x * maskMul) >> shiftbits;
+
+    return cast(int) x;
+}
+
+version (DigitalMars) version (AnyX86)
+{
+    /**
+     * Calculates the number of set bits in an integer
+     * using the X86 SSE4 POPCNT instruction.
+     * POPCNT is not available on all X86 CPUs.
+     */
+    ushort _popcnt( ushort x ) pure;
+    /// ditto
+    int _popcnt( uint x ) pure;
+    version (X86_64)
+    {
+        /// ditto
+        int _popcnt( ulong x ) pure;
+    }
+
+    unittest
+    {
+        // Not everyone has SSE4 instructions
+        import core.cpuid;
+        if (!hasPopcnt)
+            return;
+
+        static int popcnt_x(ulong u) nothrow @nogc
+        {
+            int c;
+            while (u)
+            {
+                c += u & 1;
+                u >>= 1;
+            }
+            return c;
+        }
+
+        for (uint u = 0; u < 0x1_0000; ++u)
+        {
+            //writefln("%x %x %x", u,   _popcnt(cast(ushort)u), popcnt_x(cast(ushort)u));
+            assert(_popcnt(cast(ushort)u) == popcnt_x(cast(ushort)u));
+
+            assert(_popcnt(cast(uint)u) == popcnt_x(cast(uint)u));
+            uint ui = u * 0x3_0001;
+            assert(_popcnt(ui) == popcnt_x(ui));
+
+            version (X86_64)
+            {
+                assert(_popcnt(cast(ulong)u) == popcnt_x(cast(ulong)u));
+                ulong ul = u * 0x3_0003_0001;
+                assert(_popcnt(ul) == popcnt_x(ul));
+            }
+        }
+    }
+}
+
+
+/*************************************
+ * Read/write value from/to the memory location indicated by ptr.
+ *
+ * These functions are recognized by the compiler, and calls to them are guaranteed
+ * to not be removed (as dead assignment elimination or presumed to have no effect)
+ * or reordered in the same thread.
+ *
+ * These reordering guarantees are only made with regards to other
+ * operations done through these functions; the compiler is free to reorder regular
+ * loads/stores with regards to loads/stores done through these functions.
+ *
+ * This is useful when dealing with memory-mapped I/O (MMIO) where a store can
+ * have an effect other than just writing a value, or where sequential loads
+ * with no intervening stores can retrieve
+ * different values from the same location due to external stores to the location.
+ *
+ * These functions will, when possible, do the load/store as a single operation. In
+ * general, this is possible when the size of the operation is less than or equal to
+ * $(D (void*).sizeof), although some targets may support larger operations. If the
+ * load/store cannot be done as a single operation, multiple smaller operations will be used.
+ *
+ * These are not to be conflated with atomic operations. They do not guarantee any
+ * atomicity. This may be provided by coincidence as a result of the instructions
+ * used on the target, but this should not be relied on for portable programs.
+ * Further, no memory fences are implied by these functions.
+ * They should not be used for communication between threads.
+ * They may be used to guarantee a write or read cycle occurs at a specified address.
+ */
+
+ubyte  volatileLoad(ubyte * ptr);
+ushort volatileLoad(ushort* ptr);  /// ditto
+uint   volatileLoad(uint  * ptr);  /// ditto
+ulong  volatileLoad(ulong * ptr);  /// ditto
+
+void volatileStore(ubyte * ptr, ubyte  value);   /// ditto
+void volatileStore(ushort* ptr, ushort value);   /// ditto
+void volatileStore(uint  * ptr, uint   value);   /// ditto
+void volatileStore(ulong * ptr, ulong  value);   /// ditto
+
+@system unittest
+{
+    alias TT(T...) = T;
+
+    foreach (T; TT!(ubyte, ushort, uint, ulong))
+    {
+        T u;
+        T* p = &u;
+        volatileStore(p, 1);
+        T r = volatileLoad(p);
+        assert(r == u);
+    }
+}
+
+
+/**
+ * Reverses the order of bits in a 32-bit integer.
+ */
+pragma(inline, true)
+uint bitswap( uint x ) pure
+{
+    if (!__ctfe)
+    {
+        static if (is(typeof(asmBitswap32(x))))
+            return asmBitswap32(x);
+    }
+
+    return softBitswap!uint(x);
+}
+
+unittest
+{
+    static void test(alias impl)()
+    {
+        assert (impl( 0x8000_0100 ) == 0x0080_0001);
+        foreach(i; 0 .. 32)
+            assert (impl(1 << i) == 1 << 32 - i - 1);
+    }
+
+    test!(bitswap)();
+    test!(softBitswap!uint)();
+    static if (is(typeof(asmBitswap32(0u))))
+        test!(asmBitswap32)();
+
+    // Make sure bitswap() is available at CTFE
+    enum test_ctfe = bitswap(1U);
+    assert(test_ctfe == (1U << 31));
+}
+
+/**
+ * Reverses the order of bits in a 64-bit integer.
+ */
+pragma(inline, true)
+ulong bitswap ( ulong x ) pure
+{
+    if (!__ctfe)
+    {
+        static if (is(typeof(asmBitswap64(x))))
+            return asmBitswap64(x);
+    }
+
+    return softBitswap!ulong(x);
+}
+
+unittest
+{
+    static void test(alias impl)()
+    {
+        assert (impl( 0b1000000000000000000000010000000000000000100000000000000000000001)
+            == 0b1000000000000000000000010000000000000000100000000000000000000001);
+        assert (impl( 0b1110000000000000000000010000000000000000100000000000000000000001)
+            == 0b1000000000000000000000010000000000000000100000000000000000000111);
+        foreach (i; 0 .. 64)
+            assert (impl(1UL << i) == 1UL << 64 - i - 1);
+    }
+
+    test!(bitswap)();
+    test!(softBitswap!ulong)();
+    static if (is(typeof(asmBitswap64(0uL))))
+        test!(asmBitswap64)();
+
+    // Make sure bitswap() is available at CTFE
+    enum test_ctfe = bitswap(1UL);
+    assert(test_ctfe == (1UL << 63));
+}
+
+private N softBitswap(N)(N x) pure
+    if (is(N == uint) || is(N == ulong))
+{
+    // swap 1-bit pairs:
+    enum mask1 = cast(N) 0x5555_5555_5555_5555L;
+    x = ((x >> 1) & mask1) | ((x & mask1) << 1);
+    // swap 2-bit pairs:
+    enum mask2 = cast(N) 0x3333_3333_3333_3333L;
+    x = ((x >> 2) & mask2) | ((x & mask2) << 2);
+    // swap 4-bit pairs:
+    enum mask4 = cast(N) 0x0F0F_0F0F_0F0F_0F0FL;
+    x = ((x >> 4) & mask4) | ((x & mask4) << 4);
+
+    // reverse the order of all bytes:
+    x = bswap(x);
+
+    return x;
+}
+
+version (AsmX86)
+{
+    private uint asmBitswap32(uint x) @trusted pure
+    {
+        asm pure nothrow @nogc { naked; }
+
+        version (D_InlineAsm_X86_64)
+        {
+            version (Win64)
+                asm pure nothrow @nogc { mov EAX, ECX; }
+            else
+                asm pure nothrow @nogc { mov EAX, EDI; }
+        }
+
+        asm pure nothrow @nogc
+        {
+            // Author: Tiago Gasiba.
+            mov EDX, EAX;
+            shr EAX, 1;
+            and EDX, 0x5555_5555;
+            and EAX, 0x5555_5555;
+            shl EDX, 1;
+            or  EAX, EDX;
+            mov EDX, EAX;
+            shr EAX, 2;
+            and EDX, 0x3333_3333;
+            and EAX, 0x3333_3333;
+            shl EDX, 2;
+            or  EAX, EDX;
+            mov EDX, EAX;
+            shr EAX, 4;
+            and EDX, 0x0f0f_0f0f;
+            and EAX, 0x0f0f_0f0f;
+            shl EDX, 4;
+            or  EAX, EDX;
+            bswap EAX;
+            ret;
+        }
+    }
+}
+
+version (D_InlineAsm_X86_64)
+{
+    private ulong asmBitswap64(ulong x) @trusted pure
+    {
+        asm pure nothrow @nogc { naked; }
+
+        version (Win64)
+            asm pure nothrow @nogc { mov RAX, RCX; }
+        else
+            asm pure nothrow @nogc { mov RAX, RDI; }
+
+        asm pure nothrow @nogc
+        {
+            // Author: Tiago Gasiba.
+            mov RDX, RAX;
+            shr RAX, 1;
+            mov RCX, 0x5555_5555_5555_5555L;
+            and RDX, RCX;
+            and RAX, RCX;
+            shl RDX, 1;
+            or  RAX, RDX;
+
+            mov RDX, RAX;
+            shr RAX, 2;
+            mov RCX, 0x3333_3333_3333_3333L;
+            and RDX, RCX;
+            and RAX, RCX;
+            shl RDX, 2;
+            or  RAX, RDX;
+
+            mov RDX, RAX;
+            shr RAX, 4;
+            mov RCX, 0x0f0f_0f0f_0f0f_0f0fL;
+            and RDX, RCX;
+            and RAX, RCX;
+            shl RDX, 4;
+            or  RAX, RDX;
+            bswap RAX;
+            ret;
+        }
+    }
+}
+
+/**
+ *  Bitwise rotate `value` left (`rol`) or right (`ror`) by
+ *  `count` bit positions.
+ */
+pure T rol(T)(in T value, in uint count)
+    if (__traits(isIntegral, T) && __traits(isUnsigned, T))
+{
+    assert(count < 8 * T.sizeof);
+    return cast(T) ((value << count) | (value >> (-count & (T.sizeof * 8 - 1))));
+}
+/// ditto
+pure T ror(T)(in T value, in uint count)
+    if (__traits(isIntegral, T) && __traits(isUnsigned, T))
+{
+    assert(count < 8 * T.sizeof);
+    return cast(T) ((value >> count) | (value << (-count & (T.sizeof * 8 - 1))));
+}
+/// ditto
+pure T rol(uint count, T)(in T value)
+    if (__traits(isIntegral, T) && __traits(isUnsigned, T))
+{
+    static assert(count < 8 * T.sizeof);
+    return cast(T) ((value << count) | (value >> (-count & (T.sizeof * 8 - 1))));
+}
+/// ditto
+pure T ror(uint count, T)(in T value)
+    if (__traits(isIntegral, T) && __traits(isUnsigned, T))
+{
+    static assert(count < 8 * T.sizeof);
+    return cast(T) ((value >> count) | (value << (-count & (T.sizeof * 8 - 1))));
+}
+
+///
+unittest
+{
+    ubyte a = 0b10101010U;
+    ulong b = ulong.max;
+
+    assert(rol(a, 1) == 0b01010101);
+    assert(ror(a, 1) == 0b01010101);
+    assert(rol(a, 3) == 0b01010101);
+    assert(ror(a, 3) == 0b01010101);
+
+    assert(rol(a, 0) == a);
+    assert(ror(a, 0) == a);
+
+    assert(rol(b, 63) == ulong.max);
+    assert(ror(b, 63) == ulong.max);
+
+    assert(rol!3(a) == 0b01010101);
+    assert(ror!3(a) == 0b01010101);
+}
diff --git a/libphobos/libdruntime/core/checkedint.d b/libphobos/libdruntime/core/checkedint.d
new file mode 100644
index 00000000000..422d59bde91
--- /dev/null
+++ b/libphobos/libdruntime/core/checkedint.d
@@ -0,0 +1,519 @@
+
+/**********************************************
+ * This module implements integral arithmetic primitives that check
+ * for out-of-range results.
+ *
+ * Integral arithmetic operators operate on fixed width types.
+ * Results that are not representable in those fixed widths are silently
+ * truncated to fit.
+ * This module offers integral arithmetic primitives that produce the
+ * same results, but set an 'overflow' flag when such truncation occurs.
+ * The setting is sticky, meaning that numerous operations can be cascaded
+ * and then the flag need only be checked at the end.
+ * Whether the operation is signed or unsigned is indicated by an 's' or 'u'
+ * suffix, respectively. While this could be achieved without such suffixes by
+ * using overloading on the signedness of the types, the suffix makes it clear
+ * which is happening without needing to examine the types.
+ *
+ * While the generic versions of these functions are computationally expensive
+ * relative to the cost of the operation itself, compiler implementations are free
+ * to recognize them and generate equivalent and faster code.
+ *
+ * References: $(LINK2 http://blog.regehr.org/archives/1139, Fast Integer Overflow Checks)
+ * Copyright: Copyright (c) Walter Bright 2014.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Walter Bright
+ * Source:    $(DRUNTIMESRC core/_checkedint.d)
+ */
+
+module core.checkedint;
+
+nothrow:
+@safe:
+@nogc:
+pure:
+
+/*******************************
+ * Add two signed integers, checking for overflow.
+ *
+ * The overflow is sticky, meaning a sequence of operations can
+ * be done and overflow need only be checked at the end.
+ * Params:
+ *      x = left operand
+ *      y = right operand
+ *      overflow = set if an overflow occurs, is not affected otherwise
+ * Returns:
+ *      the sum
+ */
+
+pragma(inline, true)
+int adds(int x, int y, ref bool overflow)
+{
+    long r = cast(long)x + cast(long)y;
+    if (r < int.min || r > int.max)
+        overflow = true;
+    return cast(int)r;
+}
+
+unittest
+{
+    bool overflow;
+    assert(adds(2, 3, overflow) == 5);
+    assert(!overflow);
+    assert(adds(1, int.max - 1, overflow) == int.max);
+    assert(!overflow);
+    assert(adds(int.min + 1, -1, overflow) == int.min);
+    assert(!overflow);
+    assert(adds(int.max, 1, overflow) == int.min);
+    assert(overflow);
+    overflow = false;
+    assert(adds(int.min, -1, overflow) == int.max);
+    assert(overflow);
+    assert(adds(0, 0, overflow) == 0);
+    assert(overflow);                   // sticky
+}
+
+/// ditto
+pragma(inline, true)
+long adds(long x, long y, ref bool overflow)
+{
+    long r = cast(ulong)x + cast(ulong)y;
+    if (x <  0 && y <  0 && r >= 0 ||
+        x >= 0 && y >= 0 && r <  0)
+        overflow = true;
+    return r;
+}
+
+unittest
+{
+    bool overflow;
+    assert(adds(2L, 3L, overflow) == 5);
+    assert(!overflow);
+    assert(adds(1L, long.max - 1, overflow) == long.max);
+    assert(!overflow);
+    assert(adds(long.min + 1, -1, overflow) == long.min);
+    assert(!overflow);
+    assert(adds(long.max, 1, overflow) == long.min);
+    assert(overflow);
+    overflow = false;
+    assert(adds(long.min, -1, overflow) == long.max);
+    assert(overflow);
+    assert(adds(0L, 0L, overflow) == 0);
+    assert(overflow);                   // sticky
+}
+
+
+/*******************************
+ * Add two unsigned integers, checking for overflow (aka carry).
+ *
+ * The overflow is sticky, meaning a sequence of operations can
+ * be done and overflow need only be checked at the end.
+ * Params:
+ *      x = left operand
+ *      y = right operand
+ *      overflow = set if an overflow occurs, is not affected otherwise
+ * Returns:
+ *      the sum
+ */
+
+pragma(inline, true)
+uint addu(uint x, uint y, ref bool overflow)
+{
+    uint r = x + y;
+    if (r < x || r < y)
+        overflow = true;
+    return r;
+}
+
+unittest
+{
+    bool overflow;
+    assert(addu(2, 3, overflow) == 5);
+    assert(!overflow);
+    assert(addu(1, uint.max - 1, overflow) == uint.max);
+    assert(!overflow);
+    assert(addu(uint.min, -1, overflow) == uint.max);
+    assert(!overflow);
+    assert(addu(uint.max, 1, overflow) == uint.min);
+    assert(overflow);
+    overflow = false;
+    assert(addu(uint.min + 1, -1, overflow) == uint.min);
+    assert(overflow);
+    assert(addu(0, 0, overflow) == 0);
+    assert(overflow);                   // sticky
+}
+
+/// ditto
+pragma(inline, true)
+ulong addu(ulong x, ulong y, ref bool overflow)
+{
+    ulong r = x + y;
+    if (r < x || r < y)
+        overflow = true;
+    return r;
+}
+
+unittest
+{
+    bool overflow;
+    assert(addu(2L, 3L, overflow) == 5);
+    assert(!overflow);
+    assert(addu(1, ulong.max - 1, overflow) == ulong.max);
+    assert(!overflow);
+    assert(addu(ulong.min, -1L, overflow) == ulong.max);
+    assert(!overflow);
+    assert(addu(ulong.max, 1, overflow) == ulong.min);
+    assert(overflow);
+    overflow = false;
+    assert(addu(ulong.min + 1, -1L, overflow) == ulong.min);
+    assert(overflow);
+    assert(addu(0L, 0L, overflow) == 0);
+    assert(overflow);                   // sticky
+}
+
+
+/*******************************
+ * Subtract two signed integers, checking for overflow.
+ *
+ * The overflow is sticky, meaning a sequence of operations can
+ * be done and overflow need only be checked at the end.
+ * Params:
+ *      x = left operand
+ *      y = right operand
+ *      overflow = set if an overflow occurs, is not affected otherwise
+ * Returns:
+ *      the difference
+ */
+
+pragma(inline, true)
+int subs(int x, int y, ref bool overflow)
+{
+    long r = cast(long)x - cast(long)y;
+    if (r < int.min || r > int.max)
+        overflow = true;
+    return cast(int)r;
+}
+
+unittest
+{
+    bool overflow;
+    assert(subs(2, -3, overflow) == 5);
+    assert(!overflow);
+    assert(subs(1, -int.max + 1, overflow) == int.max);
+    assert(!overflow);
+    assert(subs(int.min + 1, 1, overflow) == int.min);
+    assert(!overflow);
+    assert(subs(int.max, -1, overflow) == int.min);
+    assert(overflow);
+    overflow = false;
+    assert(subs(int.min, 1, overflow) == int.max);
+    assert(overflow);
+    assert(subs(0, 0, overflow) == 0);
+    assert(overflow);                   // sticky
+}
+
+/// ditto
+pragma(inline, true)
+long subs(long x, long y, ref bool overflow)
+{
+    long r = cast(ulong)x - cast(ulong)y;
+    if (x <  0 && y >= 0 && r >= 0 ||
+        x >= 0 && y <  0 && (r <  0 || y == long.min))
+        overflow = true;
+    return r;
+}
+
+unittest
+{
+    bool overflow;
+    assert(subs(2L, -3L, overflow) == 5);
+    assert(!overflow);
+    assert(subs(1L, -long.max + 1, overflow) == long.max);
+    assert(!overflow);
+    assert(subs(long.min + 1, 1, overflow) == long.min);
+    assert(!overflow);
+    assert(subs(-1L, long.min, overflow) == long.max);
+    assert(!overflow);
+    assert(subs(long.max, -1, overflow) == long.min);
+    assert(overflow);
+    overflow = false;
+    assert(subs(long.min, 1, overflow) == long.max);
+    assert(overflow);
+    assert(subs(0L, 0L, overflow) == 0);
+    assert(overflow);                   // sticky
+}
+
+/*******************************
+ * Subtract two unsigned integers, checking for overflow (aka borrow).
+ *
+ * The overflow is sticky, meaning a sequence of operations can
+ * be done and overflow need only be checked at the end.
+ * Params:
+ *      x = left operand
+ *      y = right operand
+ *      overflow = set if an overflow occurs, is not affected otherwise
+ * Returns:
+ *      the difference
+ */
+
+pragma(inline, true)
+uint subu(uint x, uint y, ref bool overflow)
+{
+    if (x < y)
+        overflow = true;
+    return x - y;
+}
+
+unittest
+{
+    bool overflow;
+    assert(subu(3, 2, overflow) == 1);
+    assert(!overflow);
+    assert(subu(uint.max, 1, overflow) == uint.max - 1);
+    assert(!overflow);
+    assert(subu(1, 1, overflow) == uint.min);
+    assert(!overflow);
+    assert(subu(0, 1, overflow) == uint.max);
+    assert(overflow);
+    overflow = false;
+    assert(subu(uint.max - 1, uint.max, overflow) == uint.max);
+    assert(overflow);
+    assert(subu(0, 0, overflow) == 0);
+    assert(overflow);                   // sticky
+}
+
+
+/// ditto
+pragma(inline, true)
+ulong subu(ulong x, ulong y, ref bool overflow)
+{
+    if (x < y)
+        overflow = true;
+    return x - y;
+}
+
+unittest
+{
+    bool overflow;
+    assert(subu(3UL, 2UL, overflow) == 1);
+    assert(!overflow);
+    assert(subu(ulong.max, 1, overflow) == ulong.max - 1);
+    assert(!overflow);
+    assert(subu(1UL, 1UL, overflow) == ulong.min);
+    assert(!overflow);
+    assert(subu(0UL, 1UL, overflow) == ulong.max);
+    assert(overflow);
+    overflow = false;
+    assert(subu(ulong.max - 1, ulong.max, overflow) == ulong.max);
+    assert(overflow);
+    assert(subu(0UL, 0UL, overflow) == 0);
+    assert(overflow);                   // sticky
+}
+
+
+/***********************************************
+ * Negate an integer.
+ *
+ * Params:
+ *      x = operand
+ *      overflow = set if x cannot be negated, is not affected otherwise
+ * Returns:
+ *      the negation of x
+ */
+
+pragma(inline, true)
+int negs(int x, ref bool overflow)
+{
+    if (x == int.min)
+        overflow = true;
+    return -x;
+}
+
+unittest
+{
+    bool overflow;
+    assert(negs(0, overflow) == -0);
+    assert(!overflow);
+    assert(negs(1234, overflow) == -1234);
+    assert(!overflow);
+    assert(negs(-5678, overflow) == 5678);
+    assert(!overflow);
+    assert(negs(int.min, overflow) == -int.min);
+    assert(overflow);
+    assert(negs(0, overflow) == -0);
+    assert(overflow);                   // sticky
+}
+
+/// ditto
+pragma(inline, true)
+long negs(long x, ref bool overflow)
+{
+    if (x == long.min)
+        overflow = true;
+    return -x;
+}
+
+unittest
+{
+    bool overflow;
+    assert(negs(0L, overflow) == -0);
+    assert(!overflow);
+    assert(negs(1234L, overflow) == -1234);
+    assert(!overflow);
+    assert(negs(-5678L, overflow) == 5678);
+    assert(!overflow);
+    assert(negs(long.min, overflow) == -long.min);
+    assert(overflow);
+    assert(negs(0L, overflow) == -0);
+    assert(overflow);                   // sticky
+}
+
+
+/*******************************
+ * Multiply two signed integers, checking for overflow.
+ *
+ * The overflow is sticky, meaning a sequence of operations can
+ * be done and overflow need only be checked at the end.
+ * Params:
+ *      x = left operand
+ *      y = right operand
+ *      overflow = set if an overflow occurs, is not affected otherwise
+ * Returns:
+ *      the product
+ */
+
+pragma(inline, true)
+int muls(int x, int y, ref bool overflow)
+{
+    long r = cast(long)x * cast(long)y;
+    if (r < int.min || r > int.max)
+        overflow = true;
+    return cast(int)r;
+}
+
+unittest
+{
+    bool overflow;
+    assert(muls(2, 3, overflow) == 6);
+    assert(!overflow);
+    assert(muls(-200, 300, overflow) == -60_000);
+    assert(!overflow);
+    assert(muls(1, int.max, overflow) == int.max);
+    assert(!overflow);
+    assert(muls(int.min, 1, overflow) == int.min);
+    assert(!overflow);
+    assert(muls(int.max, 2, overflow) == (int.max * 2));
+    assert(overflow);
+    overflow = false;
+    assert(muls(int.min, -1, overflow) == int.min);
+    assert(overflow);
+    assert(muls(0, 0, overflow) == 0);
+    assert(overflow);                   // sticky
+}
+
+/// ditto
+pragma(inline, true)
+long muls(long x, long y, ref bool overflow)
+{
+    long r = cast(ulong)x * cast(ulong)y;
+    enum not0or1 = ~1L;
+    if((x & not0or1) && ((r == y)? r : (r / x) != y))
+        overflow = true;
+    return r;
+}
+
+unittest
+{
+    bool overflow;
+    assert(muls(2L, 3L, overflow) == 6);
+    assert(!overflow);
+    assert(muls(-200L, 300L, overflow) == -60_000);
+    assert(!overflow);
+    assert(muls(1, long.max, overflow) == long.max);
+    assert(!overflow);
+    assert(muls(long.min, 1L, overflow) == long.min);
+    assert(!overflow);
+    assert(muls(long.max, 2L, overflow) == (long.max * 2));
+    assert(overflow);
+    overflow = false;
+    assert(muls(-1L, long.min, overflow) == long.min);
+    assert(overflow);
+    overflow = false;
+    assert(muls(long.min, -1L, overflow) == long.min);
+    assert(overflow);
+    assert(muls(0L, 0L, overflow) == 0);
+    assert(overflow);                   // sticky
+}
+
+
+/*******************************
+ * Multiply two unsigned integers, checking for overflow (aka carry).
+ *
+ * The overflow is sticky, meaning a sequence of operations can
+ * be done and overflow need only be checked at the end.
+ * Params:
+ *      x = left operand
+ *      y = right operand
+ *      overflow = set if an overflow occurs, is not affected otherwise
+ * Returns:
+ *      the product
+ */
+
+pragma(inline, true)
+uint mulu(uint x, uint y, ref bool overflow)
+{
+    ulong r = ulong(x) * ulong(y);
+    if (r > uint.max)
+        overflow = true;
+    return cast(uint)r;
+}
+
+unittest
+{
+    void test(uint x, uint y, uint r, bool overflow) @nogc nothrow
+    {
+        bool o;
+        assert(mulu(x, y, o) == r);
+        assert(o == overflow);
+    }
+    test(2, 3, 6, false);
+    test(1, uint.max, uint.max, false);
+    test(0, 1, 0, false);
+    test(0, uint.max, 0, false);
+    test(uint.max, 2, 2 * uint.max, true);
+    test(1 << 16, 1U << 16, 0, true);
+
+    bool overflow = true;
+    assert(mulu(0, 0, overflow) == 0);
+    assert(overflow);                   // sticky
+}
+
+/// ditto
+pragma(inline, true)
+ulong mulu(ulong x, ulong y, ref bool overflow)
+{
+    ulong r = x * y;
+    if (x && (r / x) != y)
+        overflow = true;
+    return r;
+}
+
+unittest
+{
+    void test(ulong x, ulong y, ulong r, bool overflow) @nogc nothrow
+    {
+        bool o;
+        assert(mulu(x, y, o) == r);
+        assert(o == overflow);
+    }
+    test(2, 3, 6, false);
+    test(1, ulong.max, ulong.max, false);
+    test(0, 1, 0, false);
+    test(0, ulong.max, 0, false);
+    test(ulong.max, 2, 2 * ulong.max, true);
+    test(1UL << 32, 1UL << 32, 0, true);
+
+    bool overflow = true;
+    assert(mulu(0UL, 0UL, overflow) == 0);
+    assert(overflow);                   // sticky
+}
diff --git a/libphobos/libdruntime/core/cpuid.d b/libphobos/libdruntime/core/cpuid.d
new file mode 100644
index 00000000000..232c8ce3f8f
--- /dev/null
+++ b/libphobos/libdruntime/core/cpuid.d
@@ -0,0 +1,1132 @@
+/**
+ * Identify the characteristics of the host CPU, providing information
+ * about cache sizes and assembly optimisation hints. This module is
+ * provided primarily for assembly language programmers.
+ *
+ * References:
+ * Some of this information was extremely difficult to track down. Some of the
+ * documents below were found only in cached versions stored by search engines!
+ * This code relies on information found in:
+ *
+ * $(UL
+ * $(LI "Intel(R) 64 and IA-32 Architectures Software Developers Manual,
+ *    Volume 2A: Instruction Set Reference, A-M" (2007).
+ * )
+ * $(LI "AMD CPUID Specification", Advanced Micro Devices, Rev 2.28 (2008).
+ * )
+ * $(LI "AMD Processor Recognition Application Note For Processors Prior to AMD
+ *    Family 0Fh Processors", Advanced Micro Devices, Rev 3.13 (2005).
+ * )
+ * $(LI "AMD Geode(TM) GX Processors Data Book",
+ *    Advanced Micro Devices, Publication ID 31505E, (2005).
+ * )
+ * $(LI "AMD K6 Processor Code Optimisation", Advanced Micro Devices, Rev D (2000).
+ * )
+ * $(LI "Application note 106: Software Customization for the 6x86 Family",
+ *    Cyrix Corporation, Rev 1.5 (1998)
+ * )
+ * $(LI $(LINK http://www.datasheetcatalog.org/datasheet/nationalsemiconductor/GX1.pdf))
+ * $(LI "Geode(TM) GX1 Processor Series Low Power Integrated X86 Solution",
+ *   National Semiconductor, (2002)
+ * )
+ * $(LI "The VIA Isaiah Architecture", G. Glenn Henry, Centaur Technology, Inc (2008).
+ * )
+ * $(LI $(LINK http://www.sandpile.org/ia32/cpuid.htm))
+ * $(LI $(LINK http://www.akkadia.org/drepper/cpumemory.pdf))
+ * $(LI "What every programmer should know about memory",
+ *    Ulrich Depper, Red Hat, Inc., (2007).
+ * )
+ * $(LI "CPU Identification by the Windows Kernel", G. Chappell (2009).
+ *   $(LINK http://www.geoffchappell.com/viewer.htm?doc=studies/windows/km/cpu/cx8.htm)
+ * )
+ * $(LI "Intel(R) Processor Identification and the CPUID Instruction, Application
+ *    Note 485" (2009).
+ * )
+ * )
+ *
+ * Bugs: Currently only works on x86 and Itanium CPUs.
+ *      Many processors have bugs in their microcode for the CPUID instruction,
+ *      so sometimes the cache information may be incorrect.
+ *
+ * Copyright: Copyright Don Clugston 2007 - 2009.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Don Clugston, Tomas Lindquist Olsen &lt;tomas@famolsen.dk&gt;
+ * Source:    $(DRUNTIMESRC core/_cpuid.d)
+ */
+
+module core.cpuid;
+
+@trusted:
+nothrow:
+@nogc:
+
+// If optimizing for a particular processor, it is generally better
+// to identify based on features rather than model. NOTE: Normally
+// it's only worthwhile to optimise for the latest Intel and AMD CPU,
+// with a backup for other CPUs.
+// Pentium    -- preferPentium1()
+// PMMX       --   + mmx()
+// PPro       -- default
+// PII        --   + mmx()
+// PIII       --   + mmx() + sse()
+// PentiumM   --   + mmx() + sse() + sse2()
+// Pentium4   -- preferPentium4()
+// PentiumD   --   + isX86_64()
+// Core2      -- default + isX86_64()
+// AMD K5     -- preferPentium1()
+// AMD K6     --   + mmx()
+// AMD K6-II  --   + mmx() + 3dnow()
+// AMD K7     -- preferAthlon()
+// AMD K8     --   + sse2()
+// AMD K10    --   + isX86_64()
+// Cyrix 6x86 -- preferPentium1()
+//    6x86MX  --   + mmx()
+
+// GDC support uses extended inline assembly:
+//   https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html        (general information and hints)
+//   https://gcc.gnu.org/onlinedocs/gcc/Simple-Constraints.html  (binding variables to registers)
+//   https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html (x86 specific register short names)
+
+public:
+
+/// Cache size and behaviour
+struct CacheInfo
+{
+    /// Size of the cache, in kilobytes, per CPU.
+    /// For L1 unified (data + code) caches, this size is half the physical size.
+    /// (we don't halve it for larger sizes, since normally
+    /// data size is much greater than code size for critical loops).
+    size_t size;
+    /// Number of ways of associativity, eg:
+    /// $(UL
+    /// $(LI 1 = direct mapped)
+    /// $(LI 2 = 2-way set associative)
+    /// $(LI 3 = 3-way set associative)
+    /// $(LI ubyte.max = fully associative)
+    /// )
+    ubyte associativity;
+    /// Number of bytes read into the cache when a cache miss occurs.
+    uint lineSize;
+}
+
+public:
+    /// $(RED Scheduled for deprecation. Please use $(D dataCaches) instead.)
+    // Note: When we deprecate it, we simply make it private.
+    __gshared CacheInfo[5] datacache;
+
+@property pure
+{
+    /// The data caches. If there are fewer than 5 physical caches levels,
+    /// the remaining levels are set to size_t.max (== entire memory space)
+    const(CacheInfo)[5] dataCaches() { return _dataCaches; }
+
+    /// Returns vendor string, for display purposes only.
+    /// Do NOT use this to determine features!
+    /// Note that some CPUs have programmable vendorIDs.
+    string vendor()     {return _vendor;}
+    /// Returns processor string, for display purposes only
+    string processor()  {return _processor;}
+
+    /// Does it have an x87 FPU on-chip?
+    bool x87onChip()    {return _x87onChip;}
+    /// Is MMX supported?
+    bool mmx()          {return _mmx;}
+    /// Is SSE supported?
+    bool sse()          {return _sse;}
+    /// Is SSE2 supported?
+    bool sse2()         {return _sse2;}
+    /// Is SSE3 supported?
+    bool sse3()         {return _sse3;}
+    /// Is SSSE3 supported?
+    bool ssse3()         {return _ssse3;}
+    /// Is SSE4.1 supported?
+    bool sse41()        {return _sse41;}
+    /// Is SSE4.2 supported?
+    bool sse42()        {return _sse42;}
+    /// Is SSE4a supported?
+    bool sse4a()        {return _sse4a;}
+    /// Is AES supported
+    bool aes()          {return _aes;}
+    /// Is pclmulqdq supported
+    bool hasPclmulqdq() {return _hasPclmulqdq;}
+    /// Is rdrand supported
+    bool hasRdrand()    {return _hasRdrand;}
+    /// Is AVX supported
+    bool avx()          {return _avx;}
+    /// Is VEX-Encoded AES supported
+    bool vaes()         {return _vaes;}
+    /// Is vpclmulqdq supported
+    bool hasVpclmulqdq(){return _hasVpclmulqdq; }
+    /// Is FMA supported
+    bool fma()          {return _fma;}
+    /// Is FP16C supported
+    bool fp16c()        {return _fp16c;}
+    /// Is AVX2 supported
+    bool avx2()         {return _avx2;}
+    /// Is HLE (hardware lock elision) supported
+    bool hle()          {return _hle;}
+    /// Is RTM (restricted transactional memory) supported
+    bool rtm()          {return _rtm;}
+    /// Is rdseed supported
+    bool hasRdseed()    {return _hasRdseed;}
+    /// Is SHA supported
+    bool hasSha()       {return _hasSha;}
+    /// Is AMD 3DNOW supported?
+    bool amd3dnow()     {return _amd3dnow;}
+    /// Is AMD 3DNOW Ext supported?
+    bool amd3dnowExt()  {return _amd3dnowExt;}
+    /// Are AMD extensions to MMX supported?
+    bool amdMmx()       {return _amdMmx;}
+    /// Is fxsave/fxrstor supported?
+    bool hasFxsr()          {return _hasFxsr;}
+    /// Is cmov supported?
+    bool hasCmov()          {return _hasCmov;}
+    /// Is rdtsc supported?
+    bool hasRdtsc()         {return _hasRdtsc;}
+    /// Is cmpxchg8b supported?
+    bool hasCmpxchg8b()     {return _hasCmpxchg8b;}
+    /// Is cmpxchg8b supported?
+    bool hasCmpxchg16b()    {return _hasCmpxchg16b;}
+    /// Is SYSENTER/SYSEXIT supported?
+    bool hasSysEnterSysExit() {return _hasSysEnterSysExit;}
+    /// Is 3DNow prefetch supported?
+    bool has3dnowPrefetch()   {return _has3dnowPrefetch;}
+    /// Are LAHF and SAHF supported in 64-bit mode?
+    bool hasLahfSahf()        {return _hasLahfSahf;}
+    /// Is POPCNT supported?
+    bool hasPopcnt()        {return _hasPopcnt;}
+    /// Is LZCNT supported?
+    bool hasLzcnt()         {return _hasLzcnt;}
+    /// Is this an Intel64 or AMD 64?
+    bool isX86_64()         {return _isX86_64;}
+
+    /// Is this an IA64 (Itanium) processor?
+    bool isItanium()        { return _isItanium; }
+
+    /// Is hyperthreading supported?
+    bool hyperThreading()   { return _hyperThreading; }
+    /// Returns number of threads per CPU
+    uint threadsPerCPU()    {return _threadsPerCPU;}
+    /// Returns number of cores in CPU
+    uint coresPerCPU()      {return _coresPerCPU;}
+
+    /// Optimisation hints for assembly code.
+    ///
+    /// For forward compatibility, the CPU is compared against different
+    /// microarchitectures. For 32-bit x86, comparisons are made against
+    /// the Intel PPro/PII/PIII/PM family.
+    ///
+    /// The major 32-bit x86 microarchitecture 'dynasties' have been:
+    ///
+    /// $(UL
+    /// $(LI Intel P6 (PentiumPro, PII, PIII, PM, Core, Core2). )
+    /// $(LI AMD Athlon (K7, K8, K10). )
+    /// $(LI Intel NetBurst (Pentium 4, Pentium D). )
+    /// $(LI In-order Pentium (Pentium1, PMMX, Atom) )
+    /// )
+    ///
+    /// Other early CPUs (Nx586, AMD K5, K6, Centaur C3, Transmeta,
+    /// Cyrix, Rise) were mostly in-order.
+    ///
+    /// Some new processors do not fit into the existing categories:
+    ///
+    /// $(UL
+    /// $(LI Intel Atom 230/330 (family 6, model 0x1C) is an in-order core. )
+    /// $(LI Centaur Isiah = VIA Nano (family 6, model F) is an out-of-order core. )
+    /// )
+    ///
+    /// Within each dynasty, the optimisation techniques are largely
+    /// identical (eg, use instruction pairing for group 4). Major
+    /// instruction set improvements occur within each dynasty.
+
+    /// Does this CPU perform better on AMD K7 code than PentiumPro..Core2 code?
+    bool preferAthlon() { return _preferAthlon; }
+    /// Does this CPU perform better on Pentium4 code than PentiumPro..Core2 code?
+    bool preferPentium4() { return _preferPentium4; }
+    /// Does this CPU perform better on Pentium I code than Pentium Pro code?
+    bool preferPentium1() { return _preferPentium1; }
+}
+
+private immutable
+{
+    /* These exist as immutables so that the query property functions can
+     * be backwards compatible with code that called them with ().
+     * Also, immutables can only be set by the static this().
+     */
+    const(CacheInfo)[5] _dataCaches;
+    string _vendor;
+    string _processor;
+    bool _x87onChip;
+    bool _mmx;
+    bool _sse;
+    bool _sse2;
+    bool _sse3;
+    bool _ssse3;
+    bool _sse41;
+    bool _sse42;
+    bool _sse4a;
+    bool _aes;
+    bool _hasPclmulqdq;
+    bool _hasRdrand;
+    bool _avx;
+    bool _vaes;
+    bool _hasVpclmulqdq;
+    bool _fma;
+    bool _fp16c;
+    bool _avx2;
+    bool _hle;
+    bool _rtm;
+    bool _hasRdseed;
+    bool _hasSha;
+    bool _amd3dnow;
+    bool _amd3dnowExt;
+    bool _amdMmx;
+    bool _hasFxsr;
+    bool _hasCmov;
+    bool _hasRdtsc;
+    bool _hasCmpxchg8b;
+    bool _hasCmpxchg16b;
+    bool _hasSysEnterSysExit;
+    bool _has3dnowPrefetch;
+    bool _hasLahfSahf;
+    bool _hasPopcnt;
+    bool _hasLzcnt;
+    bool _isX86_64;
+    bool _isItanium;
+    bool _hyperThreading;
+    uint _threadsPerCPU;
+    uint _coresPerCPU;
+    bool _preferAthlon;
+    bool _preferPentium4;
+    bool _preferPentium1;
+}
+
+__gshared:
+    // All these values are set only once, and never subsequently modified.
+public:
+    /// $(RED Warning: This field will be turned into a property in a future release.)
+    ///
+    /// Processor type (vendor-dependent).
+    /// This should be visible ONLY for display purposes.
+    uint stepping, model, family;
+    /// $(RED This field has been deprecated. Please use $(D cacheLevels) instead.)
+    uint numCacheLevels = 1;
+    /// The number of cache levels in the CPU.
+    @property uint cacheLevels() { return numCacheLevels; }
+private:
+
+struct CpuFeatures
+{
+    bool probablyIntel; // true = _probably_ an Intel processor, might be faking
+    bool probablyAMD; // true = _probably_ an AMD processor
+    string processorName;
+    char [12] vendorID;
+    char [48] processorNameBuffer;
+    uint features = 0;     // mmx, sse, sse2, hyperthreading, etc
+    uint miscfeatures = 0; // sse3, etc.
+    uint extfeatures = 0;  // HLE, AVX2, RTM, etc.
+    uint amdfeatures = 0;  // 3DNow!, mmxext, etc
+    uint amdmiscfeatures = 0; // sse4a, sse5, svm, etc
+    ulong xfeatures = 0;   // XFEATURES_ENABLED_MASK
+    uint maxCores = 1;
+    uint maxThreads = 1;
+}
+
+CpuFeatures cpuFeatures;
+
+/* Hide from the optimizer where cf (a register) is coming from, so that
+ * cf doesn't get "optimized away". The idea is to  reference
+ * the global data through cf so not so many fixups are inserted
+ * into the executable image.
+ */
+CpuFeatures* getCpuFeatures() @nogc nothrow
+{
+    pragma(inline, false);
+    return &cpuFeatures;
+}
+
+    // Note that this may indicate multi-core rather than hyperthreading.
+    @property bool hyperThreadingBit()    { return (cpuFeatures.features&HTT_BIT)!=0;}
+
+    // feature flags CPUID1_EDX
+    enum : uint
+    {
+        FPU_BIT = 1,
+        TIMESTAMP_BIT = 1<<4, // rdtsc
+        MDSR_BIT = 1<<5,      // RDMSR/WRMSR
+        CMPXCHG8B_BIT = 1<<8,
+        SYSENTERSYSEXIT_BIT = 1<<11,
+        CMOV_BIT = 1<<15,
+        MMX_BIT = 1<<23,
+        FXSR_BIT = 1<<24,
+        SSE_BIT = 1<<25,
+        SSE2_BIT = 1<<26,
+        HTT_BIT = 1<<28,
+        IA64_BIT = 1<<30
+    }
+    // feature flags misc CPUID1_ECX
+    enum : uint
+    {
+        SSE3_BIT = 1,
+        PCLMULQDQ_BIT = 1<<1, // from AVX
+        MWAIT_BIT = 1<<3,
+        SSSE3_BIT = 1<<9,
+        FMA_BIT = 1<<12,     // from AVX
+        CMPXCHG16B_BIT = 1<<13,
+        SSE41_BIT = 1<<19,
+        SSE42_BIT = 1<<20,
+        POPCNT_BIT = 1<<23,
+        AES_BIT = 1<<25, // AES instructions from AVX
+        OSXSAVE_BIT = 1<<27, // Used for AVX
+        AVX_BIT = 1<<28,
+        FP16C_BIT = 1<<29,
+        RDRAND_BIT = 1<<30,
+    }
+    // Feature flags for cpuid.{EAX = 7, ECX = 0}.EBX.
+    enum : uint
+    {
+        FSGSBASE_BIT = 1 << 0,
+        BMI1_BIT = 1 << 3,
+        HLE_BIT = 1 << 4,
+        AVX2_BIT = 1 << 5,
+        SMEP_BIT = 1 << 7,
+        BMI2_BIT = 1 << 8,
+        ERMS_BIT = 1 << 9,
+        INVPCID_BIT = 1 << 10,
+        RTM_BIT = 1 << 11,
+        RDSEED_BIT = 1 << 18,
+        SHA_BIT = 1 << 29,
+    }
+    // feature flags XFEATURES_ENABLED_MASK
+    enum : ulong
+    {
+        XF_FP_BIT  = 0x1,
+        XF_SSE_BIT = 0x2,
+        XF_YMM_BIT = 0x4,
+    }
+    // AMD feature flags CPUID80000001_EDX
+    enum : uint
+    {
+        AMD_MMX_BIT = 1<<22,
+//      FXR_OR_CYRIXMMX_BIT = 1<<24, // Cyrix/NS: 6x86MMX instructions.
+        FFXSR_BIT = 1<<25,
+        PAGE1GB_BIT = 1<<26, // support for 1GB pages
+        RDTSCP_BIT = 1<<27,
+        AMD64_BIT = 1<<29,
+        AMD_3DNOW_EXT_BIT = 1<<30,
+        AMD_3DNOW_BIT = 1<<31
+    }
+    // AMD misc feature flags CPUID80000001_ECX
+    enum : uint
+    {
+        LAHFSAHF_BIT = 1,
+        LZCNT_BIT = 1<<5,
+        SSE4A_BIT = 1<<6,
+        AMD_3DNOW_PREFETCH_BIT = 1<<8,
+    }
+
+
+version(GNU) {
+    version(X86)
+        enum supportedX86 = true;
+    else version(X86_64)
+        enum supportedX86 = true;
+    else
+        enum supportedX86 = false;
+} else version(D_InlineAsm_X86) {
+    enum supportedX86 = true;
+} else version(D_InlineAsm_X86_64) {
+    enum supportedX86 = true;
+} else {
+    enum supportedX86 = false;
+}
+
+static if (supportedX86) {
+// Note that this code will also work for Itanium in x86 mode.
+
+__gshared uint max_cpuid, max_extended_cpuid;
+
+// CPUID2: "cache and tlb information"
+void getcacheinfoCPUID2()
+{
+    // We are only interested in the data caches
+    void decipherCpuid2(ubyte x) @nogc nothrow {
+        if (x==0) return;
+        // Values from http://www.sandpile.org/ia32/cpuid.htm.
+        // Includes Itanium and non-Intel CPUs.
+        //
+        static immutable ubyte [63] ids = [
+            0x0A, 0x0C, 0x0D, 0x2C, 0x60, 0x0E, 0x66, 0x67, 0x68,
+            // level 2 cache
+            0x41, 0x42, 0x43, 0x44, 0x45, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7F,
+            0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x49, 0x4E,
+            0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x48, 0x80, 0x81,
+            // level 3 cache
+            0x22, 0x23, 0x25, 0x29, 0x46, 0x47, 0x4A, 0x4B, 0x4C, 0x4D,
+
+            0xD0, 0xD1, 0xD2, 0xD6, 0xD7, 0xD8, 0xDC, 0xDD, 0xDE,
+            0xE2, 0xE3, 0xE4, 0xEA, 0xEB, 0xEC
+        ];
+        static immutable uint [63] sizes = [
+            8, 16, 16, 64, 16, 24, 8, 16, 32,
+            128, 256, 512, 1024, 2048, 1024, 128, 256, 512, 1024, 2048, 512,
+            256, 512, 1024, 2048, 512, 1024, 4096, 6*1024,
+            128, 192, 128, 256, 384, 512, 3072, 512, 128,
+            512, 1024, 2048, 4096, 4096, 8192, 6*1024, 8192, 12*1024, 16*1024,
+
+            512, 1024, 2048, 1024, 2048, 4096, 1024+512, 3*1024, 6*1024,
+            2*1024, 4*1024, 8*1024, 12*1024, 28*1024, 24*1024
+        ];
+    // CPUBUG: Pentium M reports 0x2C but tests show it is only 4-way associative
+        static immutable ubyte [63] ways = [
+            2, 4, 4, 8, 8, 6, 4, 4, 4,
+            4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 2,
+            8, 8, 8, 8, 4, 8, 16, 24,
+            4, 6, 2, 4, 6, 4, 12, 8, 8,
+            4, 8, 8, 8, 4, 8, 12, 16, 12, 16,
+            4, 4, 4, 8, 8, 8, 12, 12, 12,
+            16, 16, 16, 24, 24, 24
+        ];
+        enum { FIRSTDATA2 = 8, FIRSTDATA3 = 28+9 }
+        for (size_t i=0; i< ids.length; ++i) {
+            if (x==ids[i]) {
+                int level = i< FIRSTDATA2 ? 0: i<FIRSTDATA3 ? 1 : 2;
+                if (x==0x49 && family==0xF && model==0x6) level=2;
+                datacache[level].size=sizes[i];
+                datacache[level].associativity=ways[i];
+                if (level == 3 || x==0x2C || x==0x0D || (x>=0x48 && x<=0x80)
+                                   || x==0x86 || x==0x87
+                                   || (x>=0x66 && x<=0x68) || (x>=0x39 && x<=0x3E)){
+                    datacache[level].lineSize = 64;
+                } else datacache[level].lineSize = 32;
+            }
+        }
+    }
+
+    uint[4] a;
+    bool firstTime = true;
+    // On a multi-core system, this could theoretically fail, but it's only used
+    // for old single-core CPUs.
+    uint numinfos = 1;
+    do {
+        version(GNU) asm pure nothrow @nogc {
+            "cpuid" : "=a" a[0], "=b" a[1], "=c" a[2], "=d" a[3] : "a" 2;
+        } else asm pure nothrow @nogc {
+            mov EAX, 2;
+            cpuid;
+            mov a, EAX;
+            mov a+4, EBX;
+            mov a+8, ECX;
+            mov a+12, EDX;
+        }
+        if (firstTime) {
+            if (a[0]==0x0000_7001 && a[3]==0x80 && a[1]==0 && a[2]==0) {
+        // Cyrix MediaGX MMXEnhanced returns: EAX= 00007001, EDX=00000080.
+        // These are NOT standard Intel values
+        // (TLB = 32 entry, 4 way associative, 4K pages)
+        // (L1 cache = 16K, 4way, linesize16)
+                datacache[0].size=8;
+                datacache[0].associativity=4;
+                datacache[0].lineSize=16;
+                return;
+            }
+            // lsb of a is how many times to loop.
+            numinfos = a[0] & 0xFF;
+            // and otherwise it should be ignored
+            a[0] &= 0xFFFF_FF00;
+            firstTime = false;
+        }
+        for (int c=0; c<4;++c) {
+            // high bit set == no info.
+            if (a[c] & 0x8000_0000) continue;
+            decipherCpuid2(cast(ubyte)(a[c] & 0xFF));
+            decipherCpuid2(cast(ubyte)((a[c]>>8) & 0xFF));
+            decipherCpuid2(cast(ubyte)((a[c]>>16) & 0xFF));
+            decipherCpuid2(cast(ubyte)((a[c]>>24) & 0xFF));
+        }
+    } while (--numinfos);
+}
+
+// CPUID4: "Deterministic cache parameters" leaf
+void getcacheinfoCPUID4()
+{
+    int cachenum = 0;
+    for(;;) {
+        uint a, b, number_of_sets;
+        version(GNU) asm pure nothrow @nogc {
+            "cpuid" : "=a" a, "=b" b, "=c" number_of_sets : "a" 4, "c" cachenum : "edx";
+        } else asm pure nothrow @nogc {
+            mov EAX, 4;
+            mov ECX, cachenum;
+            cpuid;
+            mov a, EAX;
+            mov b, EBX;
+            mov number_of_sets, ECX;
+        }
+        ++cachenum;
+        if ((a&0x1F)==0) break; // no more caches
+        uint numthreads = ((a>>14) & 0xFFF)  + 1;
+        uint numcores = ((a>>26) & 0x3F) + 1;
+        if (numcores > cpuFeatures.maxCores) cpuFeatures.maxCores = numcores;
+        if ((a&0x1F)!=1 && ((a&0x1F)!=3)) continue; // we only want data & unified caches
+
+        ++number_of_sets;
+        ubyte level = cast(ubyte)(((a>>5)&7)-1);
+        if (level > datacache.length) continue; // ignore deep caches
+        datacache[level].associativity = a & 0x200 ? ubyte.max :cast(ubyte)((b>>22)+1);
+        datacache[level].lineSize = (b & 0xFFF)+ 1; // system coherency line size
+        uint line_partitions = ((b >> 12)& 0x3FF) + 1;
+        // Size = number of sets * associativity * cachelinesize * linepartitions
+        // and must convert to Kb, also dividing by the number of hyperthreads using this cache.
+        ulong sz = (datacache[level].associativity< ubyte.max)? number_of_sets *
+            datacache[level].associativity : number_of_sets;
+        datacache[level].size = cast(uint)(
+                (sz * datacache[level].lineSize * line_partitions ) / (numthreads *1024));
+        if (level == 0 && (a&0xF)==3) {
+            // Halve the size for unified L1 caches
+            datacache[level].size/=2;
+        }
+    }
+}
+
+// CPUID8000_0005 & 6
+void getAMDcacheinfo()
+{
+    uint dummy, c5, c6, d6;
+    version(GNU) asm pure nothrow @nogc {
+        "cpuid" : "=a" dummy, "=c" c5 : "a" 0x8000_0005 : "ebx", "edx";
+    } else asm pure nothrow @nogc {
+        mov EAX, 0x8000_0005; // L1 cache
+        cpuid;
+        // EAX has L1_TLB_4M.
+        // EBX has L1_TLB_4K
+        // EDX has L1 instruction cache
+        mov c5, ECX;
+    }
+
+    datacache[0].size = ( (c5>>24) & 0xFF);
+    datacache[0].associativity = cast(ubyte)( (c5 >> 16) & 0xFF);
+    datacache[0].lineSize = c5 & 0xFF;
+
+    if (max_extended_cpuid >= 0x8000_0006) {
+        // AMD K6-III or K6-2+ or later.
+        ubyte numcores = 1;
+        if (max_extended_cpuid >=0x8000_0008) {
+            version(GNU) asm pure nothrow @nogc {
+                "cpuid" : "=a" dummy, "=c" numcores : "a" 0x8000_0008 : "ebx", "edx";
+            } else asm pure nothrow @nogc {
+                mov EAX, 0x8000_0008;
+                cpuid;
+                mov numcores, CL;
+            }
+            ++numcores;
+            if (numcores>cpuFeatures.maxCores) cpuFeatures.maxCores = numcores;
+        }
+
+        version(GNU) asm pure nothrow @nogc {
+            "cpuid" : "=a" dummy, "=c" c6, "=d" d6 : "a" 0x8000_0006 : "ebx";
+        } else asm pure nothrow @nogc {
+            mov EAX, 0x8000_0006; // L2/L3 cache
+            cpuid;
+            mov c6, ECX; // L2 cache info
+            mov d6, EDX; // L3 cache info
+        }
+
+        static immutable ubyte [] assocmap = [ 0, 1, 2, 0, 4, 0, 8, 0, 16, 0, 32, 48, 64, 96, 128, 0xFF ];
+        datacache[1].size = (c6>>16) & 0xFFFF;
+        datacache[1].associativity = assocmap[(c6>>12)&0xF];
+        datacache[1].lineSize = c6 & 0xFF;
+
+        // The L3 cache value is TOTAL, not per core.
+        datacache[2].size = ((d6>>18)*512)/numcores; // could be up to 2 * this, -1.
+        datacache[2].associativity = assocmap[(d6>>12)&0xF];
+        datacache[2].lineSize = d6 & 0xFF;
+    }
+}
+
+// For Intel CoreI7 and later, use function 0x0B
+// to determine number of processors.
+void getCpuInfo0B()
+{
+    int level=0;
+    int threadsPerCore;
+    uint a, b, c, d;
+    do {
+        version(GNU) asm pure nothrow @nogc {
+            "cpuid" : "=a" a, "=b" b, "=c" c, "=d" d : "a" 0x0B, "c" level;
+        } else asm pure nothrow @nogc {
+            mov EAX, 0x0B;
+            mov ECX, level;
+            cpuid;
+            mov a, EAX;
+            mov b, EBX;
+            mov c, ECX;
+            mov d, EDX;
+        }
+        if (b!=0) {
+           // I'm not sure about this. The docs state that there
+           // are 2 hyperthreads per core if HT is factory enabled.
+            if (level==0)
+                threadsPerCore = b & 0xFFFF;
+            else if (level==1) {
+                cpuFeatures.maxThreads = b & 0xFFFF;
+                cpuFeatures.maxCores = cpuFeatures.maxThreads / threadsPerCore;
+            }
+
+        }
+        ++level;
+    } while (a!=0 || b!=0);
+
+}
+
+void cpuidX86()
+{
+    auto cf = getCpuFeatures();
+
+    char * venptr = cf.vendorID.ptr;
+    uint a, b, c, d, a2;
+    version(GNU)
+    {
+        asm pure nothrow @nogc { "cpuid" : "=a" a, "=b" venptr[0], "=d" venptr[1], "=c" venptr[2] : "a" 0; }
+        asm pure nothrow @nogc { "cpuid" : "=a" a2 : "a" 0x8000_0000 : "ebx", "ecx", "edx"; }
+    }
+    else version(D_InlineAsm_X86)
+    {
+        asm pure nothrow @nogc {
+            mov EAX, 0;
+            cpuid;
+            mov a, EAX;
+            mov EAX, venptr;
+            mov [EAX], EBX;
+            mov [EAX + 4], EDX;
+            mov [EAX + 8], ECX;
+        }
+    }
+    else version(D_InlineAsm_X86_64)
+    {
+        asm pure nothrow @nogc {
+            mov EAX, 0;
+            cpuid;
+            mov a, EAX;
+            mov RAX, venptr;
+            mov [RAX], EBX;
+            mov [RAX + 4], EDX;
+            mov [RAX + 8], ECX;
+        }
+        asm pure nothrow @nogc {
+            mov EAX, 0x8000_0000;
+            cpuid;
+            mov a2, EAX;
+        }
+    }
+    max_cpuid = a;
+    max_extended_cpuid = a2;
+
+
+    cf.probablyIntel = cf.vendorID == "GenuineIntel";
+    cf.probablyAMD = cf.vendorID == "AuthenticAMD";
+    uint apic = 0; // brand index, apic id
+    version(GNU) asm pure nothrow @nogc {
+        "cpuid" : "=a" a, "=b" apic, "=c" c, "=d" d : "a" 1;
+    } else {
+        asm pure nothrow @nogc {
+            mov EAX, 1; // model, stepping
+            cpuid;
+            mov a, EAX;
+            mov apic, EBX;
+            mov c, ECX;
+            mov d, EDX;
+        }
+    }
+    cf.features = d;
+    cf.miscfeatures = c;
+
+    if (max_cpuid >= 7)
+    {
+        uint ext;
+
+        version(GNU) asm pure nothrow @nogc {
+            "cpuid" : "=a" a, "=b" ext, "=c" c : "a" 7, "c" 0 : "edx";
+        } else {
+            asm pure nothrow @nogc
+            {
+                mov EAX, 7; // Structured extended feature leaf.
+                mov ECX, 0; // Main leaf.
+                cpuid;
+                mov ext, EBX; // HLE, AVX2, RTM, etc.
+            }
+        }
+
+        cf.extfeatures = ext;
+    }
+
+    if (cf.miscfeatures & OSXSAVE_BIT)
+    {
+        version(GNU) asm pure nothrow @nogc {
+            "xgetbv" : "=a" a, "=d" d : "c" 0;
+        } else asm pure nothrow @nogc {
+            mov ECX, 0;
+            xgetbv;
+            mov d, EDX;
+            mov a, EAX;
+        }
+        cf.xfeatures = cast(ulong)d << 32 | a;
+    }
+    cf.amdfeatures = 0;
+    cf.amdmiscfeatures = 0;
+    if (max_extended_cpuid >= 0x8000_0001) {
+        version(GNU) asm pure nothrow @nogc {
+            "cpuid" : "=a" a, "=c" c, "=d" d : "a" 0x8000_0001 : "ebx";
+        } else {
+            asm pure nothrow @nogc {
+                mov EAX, 0x8000_0001;
+                cpuid;
+                mov c, ECX;
+                mov d, EDX;
+            }
+        }
+        cf.amdmiscfeatures = c;
+        cf.amdfeatures = d;
+    }
+    // Try to detect fraudulent vendorIDs
+    if (amd3dnow) cf.probablyIntel = false;
+
+    stepping = a & 0xF;
+    uint fbase = (a >> 8) & 0xF;
+    uint mbase = (a >> 4) & 0xF;
+    family = ((fbase == 0xF) || (fbase == 0)) ? fbase + (a >> 20) & 0xFF : fbase;
+    model = ((fbase == 0xF) || (fbase == 6 && cf.probablyIntel) ) ?
+         mbase + ((a >> 12) & 0xF0) : mbase;
+
+    if (!cf.probablyIntel && max_extended_cpuid >= 0x8000_0008) {
+        // determine max number of cores for AMD
+        version(GNU) asm pure nothrow @nogc {
+            "cpuid" : "=a" a, "=c" c : "a" 0x8000_0008 : "ebx", "edx";
+        } else asm pure nothrow @nogc {
+            mov EAX, 0x8000_0008;
+            cpuid;
+            mov c, ECX;
+        }
+        //http://support.amd.com/TechDocs/25481.pdf pg.36
+        cf.maxCores = 1;
+        if (hyperThreadingBit) {
+            cf.maxCores += c & 0xFF;
+        }
+    }
+
+    if (max_extended_cpuid >= 0x8000_0004) {
+        char *procptr = cf.processorNameBuffer.ptr;
+        version(GNU)
+        {
+            asm pure nothrow @nogc { "cpuid" : "=a" procptr[0], "=b" procptr[1], "=c" procptr[ 2], "=d" procptr[ 3] : "a" 0x8000_0002; }
+            asm pure nothrow @nogc { "cpuid" : "=a" procptr[4], "=b" procptr[5], "=c" procptr[ 6], "=d" procptr[ 7] : "a" 0x8000_0003; }
+            asm pure nothrow @nogc { "cpuid" : "=a" procptr[8], "=b" procptr[9], "=c" procptr[10], "=d" procptr[11] : "a" 0x8000_0004; }
+        }
+        else version(D_InlineAsm_X86)
+        {
+            asm pure nothrow @nogc {
+                push ESI;
+                mov ESI, procptr;
+                mov EAX, 0x8000_0002;
+                cpuid;
+                mov [ESI], EAX;
+                mov [ESI+4], EBX;
+                mov [ESI+8], ECX;
+                mov [ESI+12], EDX;
+                mov EAX, 0x8000_0003;
+                cpuid;
+                mov [ESI+16], EAX;
+                mov [ESI+20], EBX;
+                mov [ESI+24], ECX;
+                mov [ESI+28], EDX;
+                mov EAX, 0x8000_0004;
+                cpuid;
+                mov [ESI+32], EAX;
+                mov [ESI+36], EBX;
+                mov [ESI+40], ECX;
+                mov [ESI+44], EDX;
+                pop ESI;
+            }
+        }
+        else version(D_InlineAsm_X86_64)
+        {
+            asm pure nothrow @nogc {
+                push RSI;
+                mov RSI, procptr;
+                mov EAX, 0x8000_0002;
+                cpuid;
+                mov [RSI], EAX;
+                mov [RSI+4], EBX;
+                mov [RSI+8], ECX;
+                mov [RSI+12], EDX;
+                mov EAX, 0x8000_0003;
+                cpuid;
+                mov [RSI+16], EAX;
+                mov [RSI+20], EBX;
+                mov [RSI+24], ECX;
+                mov [RSI+28], EDX;
+                mov EAX, 0x8000_0004;
+                cpuid;
+                mov [RSI+32], EAX;
+                mov [RSI+36], EBX;
+                mov [RSI+40], ECX;
+                mov [RSI+44], EDX;
+                pop RSI;
+            }
+        }
+        // Intel P4 and PM pad at front with spaces.
+        // Other CPUs pad at end with nulls.
+        int start = 0, end = 0;
+        while (cf.processorNameBuffer[start] == ' ') { ++start; }
+        while (cf.processorNameBuffer[cf.processorNameBuffer.length-end-1] == 0) { ++end; }
+        cf.processorName = cast(string)(cf.processorNameBuffer[start..$-end]);
+    } else {
+        cf.processorName = "Unknown CPU";
+    }
+    // Determine cache sizes
+
+    // Intel docs specify that they return 0 for 0x8000_0005.
+    // AMD docs do not specify the behaviour for 0004 and 0002.
+    // Centaur/VIA and most other manufacturers use the AMD method,
+    // except Cyrix MediaGX MMX Enhanced uses their OWN form of CPUID2!
+    // NS Geode GX1 provides CyrixCPUID2 _and_ does the same wrong behaviour
+    // for CPUID80000005. But Geode GX uses the AMD method
+
+    // Deal with Geode GX1 - make it same as MediaGX MMX.
+    if (max_extended_cpuid==0x8000_0005 && max_cpuid==2) {
+        max_extended_cpuid = 0x8000_0004;
+    }
+    // Therefore, we try the AMD method unless it's an Intel chip.
+    // If we still have no info, try the Intel methods.
+    datacache[0].size = 0;
+    if (max_cpuid<2 || !cf.probablyIntel) {
+        if (max_extended_cpuid >= 0x8000_0005) {
+            getAMDcacheinfo();
+        } else if (cf.probablyAMD) {
+            // According to AMDProcRecognitionAppNote, this means CPU
+            // K5 model 0, or Am5x86 (model 4), or Am4x86DX4 (model 4)
+            // Am5x86 has 16Kb 4-way unified data & code cache.
+            datacache[0].size = 8;
+            datacache[0].associativity = 4;
+            datacache[0].lineSize = 32;
+        } else {
+            // Some obscure CPU.
+            // Values for Cyrix 6x86MX (family 6, model 0)
+            datacache[0].size = 64;
+            datacache[0].associativity = 4;
+            datacache[0].lineSize = 32;
+        }
+    }
+    if ((datacache[0].size == 0) && max_cpuid>=4) {
+        getcacheinfoCPUID4();
+    }
+    if ((datacache[0].size == 0) && max_cpuid>=2) {
+        getcacheinfoCPUID2();
+    }
+    if (datacache[0].size == 0) {
+        // Pentium, PMMX, late model 486, or an obscure CPU
+        if (mmx) { // Pentium MMX. Also has 8kB code cache.
+            datacache[0].size = 16;
+            datacache[0].associativity = 4;
+            datacache[0].lineSize = 32;
+        } else { // Pentium 1 (which also has 8kB code cache)
+                 // or 486.
+            // Cyrix 6x86: 16, 4way, 32 linesize
+            datacache[0].size = 8;
+            datacache[0].associativity = 2;
+            datacache[0].lineSize = 32;
+        }
+    }
+    if (max_cpuid >=0x0B) {
+        // For Intel i7 and later, use function 0x0B to determine
+        // cores and hyperthreads.
+        getCpuInfo0B();
+    } else {
+        if (hyperThreadingBit) cf.maxThreads = (apic>>>16) & 0xFF;
+        else cf.maxThreads = cf.maxCores;
+    }
+}
+
+// Return true if the cpuid instruction is supported.
+// BUG(WONTFIX): Returns false for Cyrix 6x86 and 6x86L. They will be treated as 486 machines.
+bool hasCPUID()
+{
+    version(X86_64)
+        return true;
+    else
+    {
+        uint flags;
+        version(GNU)
+        {
+            // http://wiki.osdev.org/CPUID#Checking_CPUID_availability
+            // ASM template supports both AT&T and Intel syntax.
+            asm nothrow @nogc { "
+                pushf{l|d}                 # Save EFLAGS
+                pushf{l|d}                 # Store EFLAGS
+                xor{l $0x00200000, (%%esp)| dword ptr [esp], 0x00200000}
+                                           # Invert the ID bit in stored EFLAGS
+                popf{l|d}                  # Load stored EFLAGS (with ID bit inverted)
+                pushf{l|d}                 # Store EFLAGS again (ID bit may or may not be inverted)
+                pop {%%}eax                # eax = modified EFLAGS (ID bit may or may not be inverted)
+                xor {(%%esp), %%eax|eax, [esp]}
+                                           # eax = whichever bits were changed
+                popf{l|d}                  # Restore original EFLAGS
+                " : "=a" flags;
+            }
+        }
+        else version(D_InlineAsm_X86)
+        {
+            asm nothrow @nogc {
+                pushfd;
+                pop EAX;
+                mov flags, EAX;
+                xor EAX, 0x0020_0000;
+                push EAX;
+                popfd;
+                pushfd;
+                pop EAX;
+                xor flags, EAX;
+            }
+        }
+        return (flags & 0x0020_0000) !=0;
+    }
+}
+
+} else { // supported X86
+
+    bool hasCPUID() { return false; }
+
+    void cpuidX86()
+    {
+            datacache[0].size = 8;
+            datacache[0].associativity = 2;
+            datacache[0].lineSize = 32;
+    }
+}
+
+/*
+// TODO: Implement this function with OS support
+void cpuidPPC()
+{
+    enum :int  { PPC601, PPC603, PPC603E, PPC604,
+                 PPC604E, PPC620, PPCG3, PPCG4, PPCG5 }
+
+    // TODO:
+    // asm { mfpvr; } returns the CPU version but unfortunately it can
+    // only be used in kernel mode. So OS support is required.
+    int cputype = PPC603;
+
+    // 601 has a 8KB combined data & code L1 cache.
+    uint sizes[] = [4, 8, 16, 16, 32, 32, 32, 32, 64];
+    ubyte ways[] = [8, 2,  4,  4,  4,  8,  8,  8,  8];
+    uint L2size[]= [0, 0,  0,  0,  0,  0,  0,  256,  512];
+    uint L3size[]= [0, 0,  0,  0,  0,  0,  0,  2048,  0];
+
+    datacache[0].size = sizes[cputype];
+    datacache[0].associativity = ways[cputype];
+    datacache[0].lineSize = (cputype==PPCG5)? 128 :
+        (cputype == PPC620 || cputype == PPCG3)? 64 : 32;
+    datacache[1].size = L2size[cputype];
+    datacache[2].size = L3size[cputype];
+    datacache[1].lineSize = datacache[0].lineSize;
+    datacache[2].lineSize = datacache[0].lineSize;
+}
+
+// TODO: Implement this function with OS support
+void cpuidSparc()
+{
+    // UltaSparcIIi  : L1 = 16,  2way. L2 = 512, 4 way.
+    // UltraSparcIII : L1 = 64,  4way. L2= 4096 or 8192.
+    // UltraSparcIIIi: L1 = 64,  4way. L2= 1024, 4 way
+    // UltraSparcIV  : L1 = 64,  4way. L2 = 16*1024.
+    // UltraSparcIV+ : L1 = 64,  4way. L2 = 2048, L3=32*1024.
+    // Sparc64V      : L1 = 128, 2way. L2 = 4096 4way.
+}
+*/
+
+shared static this()
+{
+    auto cf = getCpuFeatures();
+
+    if (hasCPUID()) {
+        cpuidX86();
+    } else {
+        // it's a 386 or 486, or a Cyrix 6x86.
+        //Probably still has an external cache.
+    }
+    if (datacache[0].size==0) {
+            // Guess same as Pentium 1.
+            datacache[0].size = 8;
+            datacache[0].associativity = 2;
+            datacache[0].lineSize = 32;
+    }
+    numCacheLevels = 1;
+    // And now fill up all the unused levels with full memory space.
+    for (size_t i=1; i< datacache.length; ++i) {
+        if (datacache[i].size==0) {
+            // Set all remaining levels of cache equal to full address space.
+            datacache[i].size = size_t.max/1024;
+            datacache[i].associativity = 1;
+            datacache[i].lineSize = datacache[i-1].lineSize;
+        }
+        else
+            ++numCacheLevels;
+    }
+
+    // Set the immortals
+
+    _dataCaches =     datacache;
+    _vendor =         cast(string)cf.vendorID;
+    _processor =      cf.processorName;
+    _x87onChip =      (cf.features&FPU_BIT)!=0;
+    _mmx =            (cf.features&MMX_BIT)!=0;
+    _sse =            (cf.features&SSE_BIT)!=0;
+    _sse2 =           (cf.features&SSE2_BIT)!=0;
+    _sse3 =           (cf.miscfeatures&SSE3_BIT)!=0;
+    _ssse3 =          (cf.miscfeatures&SSSE3_BIT)!=0;
+    _sse41 =          (cf.miscfeatures&SSE41_BIT)!=0;
+    _sse42 =          (cf.miscfeatures&SSE42_BIT)!=0;
+    _sse4a =          (cf.amdmiscfeatures&SSE4A_BIT)!=0;
+    _aes =            (cf.miscfeatures&AES_BIT)!=0;
+    _hasPclmulqdq =   (cf.miscfeatures&PCLMULQDQ_BIT)!=0;
+    _hasRdrand =      (cf.miscfeatures&RDRAND_BIT)!=0;
+
+    enum avx_mask = XF_SSE_BIT|XF_YMM_BIT;
+    _avx =            (cf.xfeatures & avx_mask) == avx_mask && (cf.miscfeatures&AVX_BIT)!=0;
+
+    _vaes =           avx && aes;
+    _hasVpclmulqdq =  avx && hasPclmulqdq;
+    _fma =            avx && (cf.miscfeatures&FMA_BIT)!=0;
+    _fp16c =          avx && (cf.miscfeatures&FP16C_BIT)!=0;
+    _avx2 =           avx && (cf.extfeatures & AVX2_BIT) != 0;
+    _hle =            (cf.extfeatures & HLE_BIT) != 0;
+    _rtm =            (cf.extfeatures & RTM_BIT) != 0;
+    _hasRdseed =      (cf.extfeatures&RDSEED_BIT)!=0;
+    _hasSha =         (cf.extfeatures&SHA_BIT)!=0;
+    _amd3dnow =       (cf.amdfeatures&AMD_3DNOW_BIT)!=0;
+    _amd3dnowExt =    (cf.amdfeatures&AMD_3DNOW_EXT_BIT)!=0;
+    _amdMmx =         (cf.amdfeatures&AMD_MMX_BIT)!=0;
+    _hasFxsr =        (cf.features&FXSR_BIT)!=0;
+    _hasCmov =        (cf.features&CMOV_BIT)!=0;
+    _hasRdtsc =       (cf.features&TIMESTAMP_BIT)!=0;
+    _hasCmpxchg8b =   (cf.features&CMPXCHG8B_BIT)!=0;
+    _hasCmpxchg16b =  (cf.miscfeatures&CMPXCHG16B_BIT)!=0;
+    _hasSysEnterSysExit =
+        // The SYSENTER/SYSEXIT features were buggy on Pentium Pro and early PentiumII.
+        // (REF: www.geoffchappell.com).
+        (cf.probablyIntel && (family < 6 || (family==6 && (model< 3 || (model==3 && stepping<3)))))
+            ? false
+            : (cf.features & SYSENTERSYSEXIT_BIT)!=0;
+    _has3dnowPrefetch = (cf.amdmiscfeatures&AMD_3DNOW_PREFETCH_BIT)!=0;
+    _hasLahfSahf =    (cf.amdmiscfeatures&LAHFSAHF_BIT)!=0;
+    _hasPopcnt =      (cf.miscfeatures&POPCNT_BIT)!=0;
+    _hasLzcnt =       (cf.amdmiscfeatures&LZCNT_BIT)!=0;
+    _isX86_64 =       (cf.amdfeatures&AMD64_BIT)!=0;
+    _isItanium =      (cf.features&IA64_BIT)!=0;
+    _hyperThreading = cf.maxThreads>cf.maxCores;
+    _threadsPerCPU =  cf.maxThreads;
+    _coresPerCPU =    cf.maxCores;
+    _preferAthlon =   cf.probablyAMD && family >=6;
+    _preferPentium4 = cf.probablyIntel && family == 0xF;
+    _preferPentium1 = family < 6 || (family==6 && model < 0xF && !cf.probablyIntel);
+}
diff --git a/libphobos/libdruntime/core/demangle.d b/libphobos/libdruntime/core/demangle.d
new file mode 100644
index 00000000000..1d497cfd217
--- /dev/null
+++ b/libphobos/libdruntime/core/demangle.d
@@ -0,0 +1,2030 @@
+/**
+ * The demangle module converts mangled D symbols to a representation similar
+ * to what would have existed in code.
+ *
+ * Copyright: Copyright Sean Kelly 2010 - 2014.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/_demangle.d)
+ */
+
+module core.demangle;
+
+
+debug(trace) import core.stdc.stdio : printf;
+debug(info) import core.stdc.stdio : printf;
+
+private struct Demangle
+{
+    // NOTE: This implementation currently only works with mangled function
+    //       names as they exist in an object file.  Type names mangled via
+    //       the .mangleof property are effectively incomplete as far as the
+    //       ABI is concerned and so are not considered to be mangled symbol
+    //       names.
+
+    // NOTE: This implementation builds the demangled buffer in place by
+    //       writing data as it is decoded and then rearranging it later as
+    //       needed.  In practice this results in very little data movement,
+    //       and the performance cost is more than offset by the gain from
+    //       not allocating dynamic memory to assemble the name piecemeal.
+    //
+    //       If the destination buffer is too small, parsing will restart
+    //       with a larger buffer.  Since this generally means only one
+    //       allocation during the course of a parsing run, this is still
+    //       faster than assembling the result piecemeal.
+
+
+    enum AddType { no, yes }
+
+
+    this( const(char)[] buf_, char[] dst_ = null )
+    {
+        this( buf_, AddType.yes, dst_ );
+    }
+
+
+    this( const(char)[] buf_, AddType addType_, char[] dst_ = null )
+    {
+        buf     = buf_;
+        addType = addType_;
+        dst     = dst_;
+    }
+
+
+    enum size_t minBufSize = 4000;
+
+
+    const(char)[]   buf     = null;
+    char[]          dst     = null;
+    size_t          pos     = 0;
+    size_t          len     = 0;
+    AddType         addType = AddType.yes;
+
+
+    static class ParseException : Exception
+    {
+        @safe pure nothrow this( string msg )
+        {
+            super( msg );
+        }
+    }
+
+
+    static class OverflowException : Exception
+    {
+        @safe pure nothrow this( string msg )
+        {
+            super( msg );
+        }
+    }
+
+
+    static void error( string msg = "Invalid symbol" )
+    {
+        //throw new ParseException( msg );
+        debug(info) printf( "error: %.*s\n", cast(int) msg.length, msg.ptr );
+        throw __ctfe ? new ParseException(msg)
+                     : cast(ParseException) cast(void*) typeid(ParseException).initializer;
+
+    }
+
+
+    static void overflow( string msg = "Buffer overflow" )
+    {
+        //throw new OverflowException( msg );
+        debug(info) printf( "overflow: %.*s\n", cast(int) msg.length, msg.ptr );
+        throw cast(OverflowException) cast(void*) typeid(OverflowException).initializer;
+    }
+
+
+    //////////////////////////////////////////////////////////////////////////
+    // Type Testing and Conversion
+    //////////////////////////////////////////////////////////////////////////
+
+
+    static bool isAlpha( char val )
+    {
+        return ('a' <= val && 'z' >= val) ||
+               ('A' <= val && 'Z' >= val) ||
+               (0x80 & val); // treat all unicode as alphabetic
+    }
+
+
+    static bool isDigit( char val )
+    {
+        return '0' <= val && '9' >= val;
+    }
+
+
+    static bool isHexDigit( char val )
+    {
+        return ('0' <= val && '9' >= val) ||
+               ('a' <= val && 'f' >= val) ||
+               ('A' <= val && 'F' >= val);
+    }
+
+
+    static ubyte ascii2hex( char val )
+    {
+        if (val >= 'a' && val <= 'f')
+            return cast(ubyte)(val - 'a' + 10);
+        if (val >= 'A' && val <= 'F')
+            return cast(ubyte)(val - 'A' + 10);
+        if (val >= '0' && val <= '9')
+            return cast(ubyte)(val - '0');
+        error();
+        return 0;
+    }
+
+
+    //////////////////////////////////////////////////////////////////////////
+    // Data Output
+    //////////////////////////////////////////////////////////////////////////
+
+
+    static bool contains( const(char)[] a, const(char)[] b )
+    {
+        if (a.length && b.length)
+        {
+            auto bend = b.ptr + b.length;
+            auto aend = a.ptr + a.length;
+            return a.ptr <= b.ptr && bend <= aend;
+        }
+        return false;
+    }
+
+
+    char[] shift( const(char)[] val )
+    {
+        void exch( size_t a, size_t b )
+        {
+            char t = dst[a];
+            dst[a] = dst[b];
+            dst[b] = t;
+        }
+
+        if( val.length )
+        {
+            assert( contains( dst[0 .. len], val ) );
+            debug(info) printf( "shifting (%.*s)\n", cast(int) val.length, val.ptr );
+
+            for( size_t n = 0; n < val.length; n++ )
+            {
+                for( size_t v = val.ptr - dst.ptr; v + 1 < len; v++ )
+                {
+                    exch( v, v + 1 );
+                }
+            }
+            return dst[len - val.length .. len];
+        }
+        return null;
+    }
+
+
+    char[] append( const(char)[] val )
+    {
+        if( val.length )
+        {
+            if( !dst.length )
+                dst.length = minBufSize;
+            assert( !contains( dst[0 .. len], val ) );
+            debug(info) printf( "appending (%.*s)\n", cast(int) val.length, val.ptr );
+
+            if( dst.ptr + len == val.ptr &&
+                dst.length - len >= val.length )
+            {
+                // data is already in place
+                auto t = dst[len .. len + val.length];
+                len += val.length;
+                return t;
+            }
+            if( dst.length - len >= val.length )
+            {
+                dst[len .. len + val.length] = val[];
+                auto t = dst[len .. len + val.length];
+                len += val.length;
+                return t;
+            }
+            overflow();
+        }
+        return null;
+    }
+
+    void putComma(size_t n)
+    {
+        pragma(inline, false);
+        if (n)
+            put(", ");
+    }
+
+    char[] put(char c)
+    {
+        char[1] val = c;
+        return put(val[]);
+    }
+
+    char[] put( const(char)[] val )
+    {
+        if( val.length )
+        {
+            if( !contains( dst[0 .. len], val ) )
+                return append( val );
+            return shift( val );
+        }
+        return null;
+    }
+
+
+    void putAsHex( size_t val, int width = 0 )
+    {
+        import core.internal.string;
+
+        UnsignedStringBuf buf;
+
+        auto s = unsignedToTempString(val, buf, 16);
+        int slen = cast(int)s.length;
+        if (slen < width)
+        {
+            foreach(i; slen .. width)
+                put('0');
+        }
+        put(s);
+    }
+
+
+    void pad( const(char)[] val )
+    {
+        if( val.length )
+        {
+            append( " " );
+            put( val );
+        }
+    }
+
+
+    void silent( lazy void dg )
+    {
+        debug(trace) printf( "silent+\n" );
+        debug(trace) scope(success) printf( "silent-\n" );
+        auto n = len; dg(); len = n;
+    }
+
+
+    //////////////////////////////////////////////////////////////////////////
+    // Parsing Utility
+    //////////////////////////////////////////////////////////////////////////
+
+    @property bool empty()
+    {
+        return pos >= buf.length;
+    }
+
+    @property char front()
+    {
+        if( pos < buf.length )
+            return buf[pos];
+        return char.init;
+    }
+
+
+    void test( char val )
+    {
+        if( val != front )
+            error();
+    }
+
+
+    void popFront()
+    {
+        if( pos++ >= buf.length )
+            error();
+    }
+
+
+    void match( char val )
+    {
+        test( val );
+        popFront();
+    }
+
+
+    void match( const(char)[] val )
+    {
+        foreach(char e; val )
+        {
+            test( e );
+            popFront();
+        }
+    }
+
+
+    void eat( char val )
+    {
+        if( val == front )
+            popFront();
+    }
+
+
+    //////////////////////////////////////////////////////////////////////////
+    // Parsing Implementation
+    //////////////////////////////////////////////////////////////////////////
+
+
+    /*
+    Number:
+        Digit
+        Digit Number
+    */
+    const(char)[] sliceNumber()
+    {
+        debug(trace) printf( "sliceNumber+\n" );
+        debug(trace) scope(success) printf( "sliceNumber-\n" );
+
+        auto beg = pos;
+
+        while( true )
+        {
+            auto t = front;
+            if (t >= '0' && t <= '9')
+                popFront();
+            else
+                return buf[beg .. pos];
+        }
+    }
+
+
+    size_t decodeNumber()
+    {
+        debug(trace) printf( "decodeNumber+\n" );
+        debug(trace) scope(success) printf( "decodeNumber-\n" );
+
+        return decodeNumber( sliceNumber() );
+    }
+
+
+    size_t decodeNumber( const(char)[] num )
+    {
+        debug(trace) printf( "decodeNumber+\n" );
+        debug(trace) scope(success) printf( "decodeNumber-\n" );
+
+        size_t val = 0;
+
+        foreach( c; num )
+        {
+            import core.checkedint : mulu, addu;
+
+            bool overflow = false;
+            val = mulu(val, 10, overflow);
+            val = addu(val, c - '0',  overflow);
+            if (overflow)
+                error();
+        }
+        return val;
+    }
+
+
+    void parseReal()
+    {
+        debug(trace) printf( "parseReal+\n" );
+        debug(trace) scope(success) printf( "parseReal-\n" );
+
+        char[64] tbuf = void;
+        size_t   tlen = 0;
+        real     val  = void;
+
+        if( 'I' == front )
+        {
+            match( "INF" );
+            put( "real.infinity" );
+            return;
+        }
+        if( 'N' == front )
+        {
+            popFront();
+            if( 'I' == front )
+            {
+                match( "INF" );
+                put( "-real.infinity" );
+                return;
+            }
+            if( 'A' == front )
+            {
+                match( "AN" );
+                put( "real.nan" );
+                return;
+            }
+            tbuf[tlen++] = '-';
+        }
+
+        tbuf[tlen++] = '0';
+        tbuf[tlen++] = 'X';
+        if( !isHexDigit( front ) )
+            error( "Expected hex digit" );
+        tbuf[tlen++] = front;
+        tbuf[tlen++] = '.';
+        popFront();
+
+        while( isHexDigit( front ) )
+        {
+            tbuf[tlen++] = front;
+            popFront();
+        }
+        match( 'P' );
+        tbuf[tlen++] = 'p';
+        if( 'N' == front )
+        {
+            tbuf[tlen++] = '-';
+            popFront();
+        }
+        else
+        {
+            tbuf[tlen++] = '+';
+        }
+        while( isDigit( front ) )
+        {
+            tbuf[tlen++] = front;
+            popFront();
+        }
+
+        tbuf[tlen] = 0;
+        debug(info) printf( "got (%s)\n", tbuf.ptr );
+        import core.stdc.stdlib : strtold;
+        val = strtold( tbuf.ptr, null );
+        import core.stdc.stdio : snprintf;
+        tlen = snprintf( tbuf.ptr, tbuf.length, "%#Lg", val );
+        debug(info) printf( "converted (%.*s)\n", cast(int) tlen, tbuf.ptr );
+        put( tbuf[0 .. tlen] );
+    }
+
+
+    /*
+    LName:
+        Number Name
+
+    Name:
+        Namestart
+        Namestart Namechars
+
+    Namestart:
+        _
+        Alpha
+
+    Namechar:
+        Namestart
+        Digit
+
+    Namechars:
+        Namechar
+        Namechar Namechars
+    */
+    void parseLName()
+    {
+        debug(trace) printf( "parseLName+\n" );
+        debug(trace) scope(success) printf( "parseLName-\n" );
+
+        auto n = decodeNumber();
+
+        if( !n || n > buf.length || n > buf.length - pos )
+            error( "LName must be at least 1 character" );
+        if( '_' != front && !isAlpha( front ) )
+            error( "Invalid character in LName" );
+        foreach(char e; buf[pos + 1 .. pos + n] )
+        {
+            if( '_' != e && !isAlpha( e ) && !isDigit( e ) )
+                error( "Invalid character in LName" );
+        }
+
+        put( buf[pos .. pos + n] );
+        pos += n;
+    }
+
+
+    /*
+    Type:
+        Shared
+        Const
+        Immutable
+        Wild
+        TypeArray
+        TypeVector
+        TypeStaticArray
+        TypeAssocArray
+        TypePointer
+        TypeFunction
+        TypeIdent
+        TypeClass
+        TypeStruct
+        TypeEnum
+        TypeTypedef
+        TypeDelegate
+        TypeNone
+        TypeVoid
+        TypeByte
+        TypeUbyte
+        TypeShort
+        TypeUshort
+        TypeInt
+        TypeUint
+        TypeLong
+        TypeUlong
+        TypeCent
+        TypeUcent
+        TypeFloat
+        TypeDouble
+        TypeReal
+        TypeIfloat
+        TypeIdouble
+        TypeIreal
+        TypeCfloat
+        TypeCdouble
+        TypeCreal
+        TypeBool
+        TypeChar
+        TypeWchar
+        TypeDchar
+        TypeTuple
+
+    Shared:
+        O Type
+
+    Const:
+        x Type
+
+    Immutable:
+        y Type
+
+    Wild:
+        Ng Type
+
+    TypeArray:
+        A Type
+
+    TypeVector:
+        Nh Type
+
+    TypeStaticArray:
+        G Number Type
+
+    TypeAssocArray:
+        H Type Type
+
+    TypePointer:
+        P Type
+
+    TypeFunction:
+        CallConvention FuncAttrs Arguments ArgClose Type
+
+    TypeIdent:
+        I LName
+
+    TypeClass:
+        C LName
+
+    TypeStruct:
+        S LName
+
+    TypeEnum:
+        E LName
+
+    TypeTypedef:
+        T LName
+
+    TypeDelegate:
+        D TypeFunction
+
+    TypeNone:
+        n
+
+    TypeVoid:
+        v
+
+    TypeByte:
+        g
+
+    TypeUbyte:
+        h
+
+    TypeShort:
+        s
+
+    TypeUshort:
+        t
+
+    TypeInt:
+        i
+
+    TypeUint:
+        k
+
+    TypeLong:
+        l
+
+    TypeUlong:
+        m
+
+    TypeCent
+        zi
+
+    TypeUcent
+        zk
+
+    TypeFloat:
+        f
+
+    TypeDouble:
+        d
+
+    TypeReal:
+        e
+
+    TypeIfloat:
+        o
+
+    TypeIdouble:
+        p
+
+    TypeIreal:
+        j
+
+    TypeCfloat:
+        q
+
+    TypeCdouble:
+        r
+
+    TypeCreal:
+        c
+
+    TypeBool:
+        b
+
+    TypeChar:
+        a
+
+    TypeWchar:
+        u
+
+    TypeDchar:
+        w
+
+    TypeTuple:
+        B Number Arguments
+    */
+    char[] parseType( char[] name = null )
+    {
+        static immutable string[23] primitives = [
+            "char", // a
+            "bool", // b
+            "creal", // c
+            "double", // d
+            "real", // e
+            "float", // f
+            "byte", // g
+            "ubyte", // h
+            "int", // i
+            "ireal", // j
+            "uint", // k
+            "long", // l
+            "ulong", // m
+            null, // n
+            "ifloat", // o
+            "idouble", // p
+            "cfloat", // q
+            "cdouble", // r
+            "short", // s
+            "ushort", // t
+            "wchar", // u
+            "void", // v
+            "dchar", // w
+        ];
+
+        debug(trace) printf( "parseType+\n" );
+        debug(trace) scope(success) printf( "parseType-\n" );
+        auto beg = len;
+        auto t = front;
+
+        switch( t )
+        {
+        case 'O': // Shared (O Type)
+            popFront();
+            put( "shared(" );
+            parseType();
+            put( ')' );
+            pad( name );
+            return dst[beg .. len];
+        case 'x': // Const (x Type)
+            popFront();
+            put( "const(" );
+            parseType();
+            put( ')' );
+            pad( name );
+            return dst[beg .. len];
+        case 'y': // Immutable (y Type)
+            popFront();
+            put( "immutable(" );
+            parseType();
+            put( ')' );
+            pad( name );
+            return dst[beg .. len];
+        case 'N':
+            popFront();
+            switch( front )
+            {
+            case 'g': // Wild (Ng Type)
+                popFront();
+                // TODO: Anything needed here?
+                put( "inout(" );
+                parseType();
+                put( ')' );
+                return dst[beg .. len];
+            case 'h': // TypeVector (Nh Type)
+                popFront();
+                put( "__vector(" );
+                parseType();
+                put( ')' );
+                return dst[beg .. len];
+            default:
+                error();
+                assert( 0 );
+            }
+        case 'A': // TypeArray (A Type)
+            popFront();
+            parseType();
+            put( "[]" );
+            pad( name );
+            return dst[beg .. len];
+        case 'G': // TypeStaticArray (G Number Type)
+            popFront();
+            auto num = sliceNumber();
+            parseType();
+            put( '[' );
+            put( num );
+            put( ']' );
+            pad( name );
+            return dst[beg .. len];
+        case 'H': // TypeAssocArray (H Type Type)
+            popFront();
+            // skip t1
+            auto tx = parseType();
+            parseType();
+            put( '[' );
+            put( tx );
+            put( ']' );
+            pad( name );
+            return dst[beg .. len];
+        case 'P': // TypePointer (P Type)
+            popFront();
+            parseType();
+            put( '*' );
+            pad( name );
+            return dst[beg .. len];
+        case 'F': case 'U': case 'W': case 'V': case 'R': // TypeFunction
+            return parseTypeFunction( name );
+        case 'I': // TypeIdent (I LName)
+        case 'C': // TypeClass (C LName)
+        case 'S': // TypeStruct (S LName)
+        case 'E': // TypeEnum (E LName)
+        case 'T': // TypeTypedef (T LName)
+            popFront();
+            parseQualifiedName();
+            pad( name );
+            return dst[beg .. len];
+        case 'D': // TypeDelegate (D TypeFunction)
+            popFront();
+            parseTypeFunction( name, IsDelegate.yes );
+            return dst[beg .. len];
+        case 'n': // TypeNone (n)
+            popFront();
+            // TODO: Anything needed here?
+            return dst[beg .. len];
+        case 'B': // TypeTuple (B Number Arguments)
+            popFront();
+            // TODO: Handle this.
+            return dst[beg .. len];
+        case 'Z': // Internal symbol
+            // This 'type' is used for untyped internal symbols, i.e.:
+            // __array
+            // __init
+            // __vtbl
+            // __Class
+            // __Interface
+            // __ModuleInfo
+            popFront();
+            return dst[beg .. len];
+        default:
+            if (t >= 'a' && t <= 'w')
+            {
+                popFront();
+                put( primitives[cast(size_t)(t - 'a')] );
+                pad( name );
+                return dst[beg .. len];
+            }
+            else if (t == 'z')
+            {
+                popFront();
+                switch( front )
+                {
+                case 'i':
+                    popFront();
+                    put( "cent" );
+                    pad( name );
+                    return dst[beg .. len];
+                case 'k':
+                    popFront();
+                    put( "ucent" );
+                    pad( name );
+                    return dst[beg .. len];
+                default:
+                    error();
+                    assert( 0 );
+                }
+            }
+            error();
+            return null;
+        }
+    }
+
+
+    /*
+    TypeFunction:
+        CallConvention FuncAttrs Arguments ArgClose Type
+
+    CallConvention:
+        F       // D
+        U       // C
+        W       // Windows
+        V       // Pascal
+        R       // C++
+
+    FuncAttrs:
+        FuncAttr
+        FuncAttr FuncAttrs
+
+    FuncAttr:
+        empty
+        FuncAttrPure
+        FuncAttrNothrow
+        FuncAttrProperty
+        FuncAttrRef
+        FuncAttrTrusted
+        FuncAttrSafe
+
+    FuncAttrPure:
+        Na
+
+    FuncAttrNothrow:
+        Nb
+
+    FuncAttrRef:
+        Nc
+
+    FuncAttrProperty:
+        Nd
+
+    FuncAttrTrusted:
+        Ne
+
+    FuncAttrSafe:
+        Nf
+
+    FuncAttrNogc:
+        Ni
+
+    FuncAttrReturn:
+        Nj
+
+    Arguments:
+        Argument
+        Argument Arguments
+
+    Argument:
+        Argument2
+        M Argument2     // scope
+
+    Argument2:
+        Type
+        J Type     // out
+        K Type     // ref
+        L Type     // lazy
+
+    ArgClose
+        X     // variadic T t,...) style
+        Y     // variadic T t...) style
+        Z     // not variadic
+    */
+    void parseCallConvention()
+    {
+        // CallConvention
+        switch( front )
+        {
+        case 'F': // D
+            popFront();
+            break;
+        case 'U': // C
+            popFront();
+            put( "extern (C) " );
+            break;
+        case 'W': // Windows
+            popFront();
+            put( "extern (Windows) " );
+            break;
+        case 'V': // Pascal
+            popFront();
+            put( "extern (Pascal) " );
+            break;
+        case 'R': // C++
+            popFront();
+            put( "extern (C++) " );
+            break;
+        default:
+            error();
+        }
+    }
+
+    void parseFuncAttr()
+    {
+        // FuncAttrs
+        breakFuncAttrs:
+        while( 'N' == front )
+        {
+            popFront();
+            switch( front )
+            {
+            case 'a': // FuncAttrPure
+                popFront();
+                put( "pure " );
+                continue;
+            case 'b': // FuncAttrNoThrow
+                popFront();
+                put( "nothrow " );
+                continue;
+            case 'c': // FuncAttrRef
+                popFront();
+                put( "ref " );
+                continue;
+            case 'd': // FuncAttrProperty
+                popFront();
+                put( "@property " );
+                continue;
+            case 'e': // FuncAttrTrusted
+                popFront();
+                put( "@trusted " );
+                continue;
+            case 'f': // FuncAttrSafe
+                popFront();
+                put( "@safe " );
+                continue;
+            case 'g':
+            case 'h':
+            case 'k':
+                // NOTE: The inout parameter type is represented as "Ng".
+                //       The vector parameter type is represented as "Nh".
+                //       The return parameter type is represented as "Nk".
+                //       These make it look like a FuncAttr, but infact
+                //       if we see these, then we know we're really in
+                //       the parameter list.  Rewind and break.
+                pos--;
+                break breakFuncAttrs;
+            case 'i': // FuncAttrNogc
+                popFront();
+                put( "@nogc " );
+                continue;
+            case 'j': // FuncAttrReturn
+                popFront();
+                put( "return " );
+                continue;
+            default:
+                error();
+            }
+        }
+    }
+
+    void parseFuncArguments()
+    {
+        // Arguments
+        for( size_t n = 0; true; n++ )
+        {
+            debug(info) printf( "tok (%c)\n", front );
+            switch( front )
+            {
+            case 'X': // ArgClose (variadic T t...) style)
+                popFront();
+                put( "..." );
+                return;
+            case 'Y': // ArgClose (variadic T t,...) style)
+                popFront();
+                put( ", ..." );
+                return;
+            case 'Z': // ArgClose (not variadic)
+                popFront();
+                return;
+            default:
+                break;
+            }
+            putComma(n);
+            if( 'M' == front )
+            {
+                popFront();
+                put( "scope " );
+            }
+            if( 'N' == front )
+            {
+                popFront();
+                if( 'k' == front ) // Return (Nk Parameter2)
+                {
+                    popFront();
+                    put( "return " );
+                }
+                else
+                    pos--;
+            }
+            switch( front )
+            {
+            case 'J': // out (J Type)
+                popFront();
+                put( "out " );
+                parseType();
+                continue;
+            case 'K': // ref (K Type)
+                popFront();
+                put( "ref " );
+                parseType();
+                continue;
+            case 'L': // lazy (L Type)
+                popFront();
+                put( "lazy " );
+                parseType();
+                continue;
+            default:
+                parseType();
+            }
+        }
+    }
+
+    enum IsDelegate { no, yes }
+    // returns the argument list with the left parenthesis, but not the right
+    char[] parseTypeFunction( char[] name = null, IsDelegate isdg = IsDelegate.no )
+    {
+        debug(trace) printf( "parseTypeFunction+\n" );
+        debug(trace) scope(success) printf( "parseTypeFunction-\n" );
+        auto beg = len;
+
+        parseCallConvention();
+        parseFuncAttr();
+
+        beg = len;
+        put( '(' );
+        scope(success)
+        {
+            put( ')' );
+            auto t = len;
+            parseType();
+            put( ' ' );
+            if( name.length )
+            {
+                if( !contains( dst[0 .. len], name ) )
+                    put( name );
+                else if( shift( name ).ptr != name.ptr )
+                {
+                    beg -= name.length;
+                    t -= name.length;
+                }
+            }
+            else if( IsDelegate.yes == isdg )
+                put( "delegate" );
+            else
+                put( "function" );
+            shift( dst[beg .. t] );
+        }
+        parseFuncArguments();
+        return dst[beg..len];
+    }
+
+    static bool isCallConvention( char ch )
+    {
+        switch( ch )
+        {
+            case 'F', 'U', 'V', 'W', 'R':
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    /*
+    Value:
+        n
+        Number
+        i Number
+        N Number
+        e HexFloat
+        c HexFloat c HexFloat
+        A Number Value...
+
+    HexFloat:
+        NAN
+        INF
+        NINF
+        N HexDigits P Exponent
+        HexDigits P Exponent
+
+    Exponent:
+        N Number
+        Number
+
+    HexDigits:
+        HexDigit
+        HexDigit HexDigits
+
+    HexDigit:
+        Digit
+        A
+        B
+        C
+        D
+        E
+        F
+    */
+    void parseValue( char[] name = null, char type = '\0' )
+    {
+        debug(trace) printf( "parseValue+\n" );
+        debug(trace) scope(success) printf( "parseValue-\n" );
+
+//        printf( "*** %c\n", front );
+        switch( front )
+        {
+        case 'n':
+            popFront();
+            put( "null" );
+            return;
+        case 'i':
+            popFront();
+            if( '0' > front || '9' < front )
+                error( "Number expected" );
+            goto case;
+        case '0': .. case '9':
+            parseIntegerValue( name, type );
+            return;
+        case 'N':
+            popFront();
+            put( '-' );
+            parseIntegerValue( name, type );
+            return;
+        case 'e':
+            popFront();
+            parseReal();
+            return;
+        case 'c':
+            popFront();
+            parseReal();
+            put( '+' );
+            match( 'c' );
+            parseReal();
+            put( 'i' );
+            return;
+        case 'a': case 'w': case 'd':
+            char t = front;
+            popFront();
+            auto n = decodeNumber();
+            match( '_' );
+            put( '"' );
+            foreach (i; 0..n)
+            {
+                auto a = ascii2hex( front ); popFront();
+                auto b = ascii2hex( front ); popFront();
+                auto v = cast(char)((a << 4) | b);
+                if (' ' <= v && v <= '~')   // ASCII printable
+                {
+                    put(v);
+                }
+                else
+                {
+                    put("\\x");
+                    putAsHex(v, 2);
+                }
+            }
+            put( '"' );
+            if( 'a' != t )
+                put(t);
+            return;
+        case 'A':
+            // NOTE: This is kind of a hack.  An associative array literal
+            //       [1:2, 3:4] is represented as HiiA2i1i2i3i4, so the type
+            //       is "Hii" and the value is "A2i1i2i3i4".  Thus the only
+            //       way to determine that this is an AA value rather than an
+            //       array value is for the caller to supply the type char.
+            //       Hopefully, this will change so that the value is
+            //       "H2i1i2i3i4", rendering this unnecesary.
+            if( 'H' == type )
+                goto LassocArray;
+            // A Number Value...
+            // An array literal. Value is repeated Number times.
+            popFront();
+            put( '[' );
+            auto n = decodeNumber();
+            foreach( i; 0 .. n )
+            {
+                putComma(i);
+                parseValue();
+            }
+            put( ']' );
+            return;
+        case 'H':
+        LassocArray:
+            // H Number Value...
+            // An associative array literal. Value is repeated 2*Number times.
+            popFront();
+            put( '[' );
+            auto n = decodeNumber();
+            foreach( i; 0 .. n )
+            {
+                putComma(i);
+                parseValue();
+                put(':');
+                parseValue();
+            }
+            put( ']' );
+            return;
+        case 'S':
+            // S Number Value...
+            // A struct literal. Value is repeated Number times.
+            popFront();
+            if( name.length )
+                put( name );
+            put( '(' );
+            auto n = decodeNumber();
+            foreach( i; 0 .. n )
+            {
+                putComma(i);
+                parseValue();
+            }
+            put( ')' );
+            return;
+        default:
+            error();
+        }
+    }
+
+
+    void parseIntegerValue( char[] name = null, char type = '\0' )
+    {
+        debug(trace) printf( "parseIntegerValue+\n" );
+        debug(trace) scope(success) printf( "parseIntegerValue-\n" );
+
+        switch( type )
+        {
+        case 'a': // char
+        case 'u': // wchar
+        case 'w': // dchar
+        {
+            auto val = sliceNumber();
+            auto num = decodeNumber( val );
+
+            switch( num )
+            {
+            case '\'':
+                put( "'\\''" );
+                return;
+            // \", \?
+            case '\\':
+                put( "'\\\\'" );
+                return;
+            case '\a':
+                put( "'\\a'" );
+                return;
+            case '\b':
+                put( "'\\b'" );
+                return;
+            case '\f':
+                put( "'\\f'" );
+                return;
+            case '\n':
+                put( "'\\n'" );
+                return;
+            case '\r':
+                put( "'\\r'" );
+                return;
+            case '\t':
+                put( "'\\t'" );
+                return;
+            case '\v':
+                put( "'\\v'" );
+                return;
+            default:
+                switch( type )
+                {
+                case 'a':
+                    if( num >= 0x20 && num < 0x7F )
+                    {
+                        put( '\'' );
+                        put( cast(char)num );
+                        put( '\'' );
+                        return;
+                    }
+                    put( "\\x" );
+                    putAsHex( num, 2 );
+                    return;
+                case 'u':
+                    put( "'\\u" );
+                    putAsHex( num, 4 );
+                    put( '\'' );
+                    return;
+                case 'w':
+                    put( "'\\U" );
+                    putAsHex( num, 8 );
+                    put( '\'' );
+                    return;
+                default:
+                    assert( 0 );
+                }
+            }
+        }
+        case 'b': // bool
+            put( decodeNumber() ? "true" : "false" );
+            return;
+        case 'h', 't', 'k': // ubyte, ushort, uint
+            put( sliceNumber() );
+            put( 'u' );
+            return;
+        case 'l': // long
+            put( sliceNumber() );
+            put( 'L' );
+            return;
+        case 'm': // ulong
+            put( sliceNumber() );
+            put( "uL" );
+            return;
+        default:
+            put( sliceNumber() );
+            return;
+        }
+    }
+
+
+    /*
+    TemplateArgs:
+        TemplateArg
+        TemplateArg TemplateArgs
+
+    TemplateArg:
+        TemplateArgX
+        H TemplateArgX
+
+    TemplateArgX:
+        T Type
+        V Type Value
+        S LName
+    */
+    void parseTemplateArgs()
+    {
+        debug(trace) printf( "parseTemplateArgs+\n" );
+        debug(trace) scope(success) printf( "parseTemplateArgs-\n" );
+
+        for( size_t n = 0; true; n++ )
+        {
+            if( front == 'H' )
+                popFront();
+
+            switch( front )
+            {
+            case 'T':
+                popFront();
+                putComma(n);
+                parseType();
+                continue;
+            case 'V':
+                popFront();
+                putComma(n);
+                // NOTE: In the few instances where the type is actually
+                //       desired in the output it should precede the value
+                //       generated by parseValue, so it is safe to simply
+                //       decrement len and let put/append do its thing.
+                char t = front; // peek at type for parseValue
+                char[] name; silent( name = parseType() );
+                parseValue( name, t );
+                continue;
+            case 'S':
+                popFront();
+                putComma(n);
+
+                if ( mayBeMangledNameArg() )
+                {
+                    auto l = len;
+                    auto p = pos;
+
+                    try
+                    {
+                        debug(trace) printf( "may be mangled name arg\n" );
+                        parseMangledNameArg();
+                        continue;
+                    }
+                    catch( ParseException e )
+                    {
+                        len = l;
+                        pos = p;
+                        debug(trace) printf( "not a mangled name arg\n" );
+                    }
+                }
+
+                parseQualifiedName();
+                continue;
+            default:
+                return;
+            }
+        }
+    }
+
+
+    bool mayBeMangledNameArg()
+    {
+        debug(trace) printf( "mayBeMangledNameArg+\n" );
+        debug(trace) scope(success) printf( "mayBeMangledNameArg-\n" );
+
+        auto p = pos;
+        scope(exit) pos = p;
+        auto n = decodeNumber();
+        return n >= 4 &&
+           pos < buf.length && '_' == buf[pos++] &&
+           pos < buf.length && 'D' == buf[pos++] &&
+           isDigit(buf[pos]);
+    }
+
+
+    void parseMangledNameArg()
+    {
+        debug(trace) printf( "parseMangledNameArg+\n" );
+        debug(trace) scope(success) printf( "parseMangledNameArg-\n" );
+
+        auto n = decodeNumber();
+        parseMangledName( n );
+    }
+
+
+    /*
+    TemplateInstanceName:
+        Number __T LName TemplateArgs Z
+    */
+    void parseTemplateInstanceName()
+    {
+        debug(trace) printf( "parseTemplateInstanceName+\n" );
+        debug(trace) scope(success) printf( "parseTemplateInstanceName-\n" );
+
+        auto sav = pos;
+        scope(failure) pos = sav;
+        auto n = decodeNumber();
+        auto beg = pos;
+        match( "__T" );
+        parseLName();
+        put( "!(" );
+        parseTemplateArgs();
+        match( 'Z' );
+        if( pos - beg != n )
+            error( "Template name length mismatch" );
+        put( ')' );
+    }
+
+
+    bool mayBeTemplateInstanceName()
+    {
+        debug(trace) printf( "mayBeTemplateInstanceName+\n" );
+        debug(trace) scope(success) printf( "mayBeTemplateInstanceName-\n" );
+
+        auto p = pos;
+        scope(exit) pos = p;
+        auto n = decodeNumber();
+        return n >= 5 &&
+               pos < buf.length && '_' == buf[pos++] &&
+               pos < buf.length && '_' == buf[pos++] &&
+               pos < buf.length && 'T' == buf[pos++];
+    }
+
+
+    /*
+    SymbolName:
+        LName
+        TemplateInstanceName
+    */
+    void parseSymbolName()
+    {
+        debug(trace) printf( "parseSymbolName+\n" );
+        debug(trace) scope(success) printf( "parseSymbolName-\n" );
+
+        // LName -> Number
+        // TemplateInstanceName -> Number "__T"
+        switch( front )
+        {
+        case '0': .. case '9':
+            if( mayBeTemplateInstanceName() )
+            {
+                auto t = len;
+
+                try
+                {
+                    debug(trace) printf( "may be template instance name\n" );
+                    parseTemplateInstanceName();
+                    return;
+                }
+                catch( ParseException e )
+                {
+                    debug(trace) printf( "not a template instance name\n" );
+                    len = t;
+                }
+            }
+            parseLName();
+            return;
+        default:
+            error();
+        }
+    }
+
+
+    /*
+    QualifiedName:
+        SymbolName
+        SymbolName QualifiedName
+    */
+    char[] parseQualifiedName()
+    {
+        debug(trace) printf( "parseQualifiedName+\n" );
+        debug(trace) scope(success) printf( "parseQualifiedName-\n" );
+        size_t  beg = len;
+        size_t  n   = 0;
+
+        do
+        {
+            if( n++ )
+                put( '.' );
+            parseSymbolName();
+
+            if( isCallConvention( front ) )
+            {
+                // try to demangle a function, in case we are pointing to some function local
+                auto prevpos = pos;
+                auto prevlen = len;
+
+                // we don't want calling convention and attributes in the qualified name
+                parseCallConvention();
+                parseFuncAttr();
+                len = prevlen;
+
+                put( '(' );
+                parseFuncArguments();
+                put( ')' );
+                if( !isDigit( front ) ) // voldemort types don't have a return type on the function
+                {
+                    auto funclen = len;
+                    parseType();
+
+                    if( !isDigit( front ) )
+                    {
+                        // not part of a qualified name, so back up
+                        pos = prevpos;
+                        len = prevlen;
+                    }
+                    else
+                        len = funclen; // remove return type from qualified name
+                }
+            }
+        } while( isDigit( front ) );
+        return dst[beg .. len];
+    }
+
+
+    /*
+    MangledName:
+        _D QualifiedName Type
+        _D QualifiedName M Type
+    */
+    void parseMangledName(size_t n = 0)
+    {
+        debug(trace) printf( "parseMangledName+\n" );
+        debug(trace) scope(success) printf( "parseMangledName-\n" );
+        char[] name = null;
+
+        auto end = pos + n;
+
+        eat( '_' );
+        match( 'D' );
+        do
+        {
+            name = parseQualifiedName();
+            debug(info) printf( "name (%.*s)\n", cast(int) name.length, name.ptr );
+            if( 'M' == front )
+                popFront(); // has 'this' pointer
+            if( AddType.yes == addType )
+                parseType( name );
+            if( pos >= buf.length || (n != 0 && pos >= end) )
+                return;
+            put( '.' );
+        } while( true );
+    }
+
+
+    char[] doDemangle(alias FUNC)()
+    {
+        while( true )
+        {
+            try
+            {
+                debug(info) printf( "demangle(%.*s)\n", cast(int) buf.length, buf.ptr );
+                FUNC();
+                return dst[0 .. len];
+            }
+            catch( OverflowException e )
+            {
+                debug(trace) printf( "overflow... restarting\n" );
+                auto a = minBufSize;
+                auto b = 2 * dst.length;
+                auto newsz = a < b ? b : a;
+                debug(info) printf( "growing dst to %lu bytes\n", newsz );
+                dst.length = newsz;
+                pos = len = 0;
+                continue;
+            }
+            catch( ParseException e )
+            {
+                debug(info)
+                {
+                    auto msg = e.toString();
+                    printf( "error: %.*s\n", cast(int) msg.length, msg.ptr );
+                }
+                if( dst.length < buf.length )
+                    dst.length = buf.length;
+                dst[0 .. buf.length] = buf[];
+                return dst[0 .. buf.length];
+            }
+        }
+    }
+
+    char[] demangleName()
+    {
+        return doDemangle!parseMangledName();
+    }
+
+    char[] demangleType()
+    {
+        return doDemangle!parseType();
+    }
+}
+
+
+/**
+ * Demangles D mangled names.  If it is not a D mangled name, it returns its
+ * argument name.
+ *
+ * Params:
+ *  buf = The string to demangle.
+ *  dst = An optional destination buffer.
+ *
+ * Returns:
+ *  The demangled name or the original string if the name is not a mangled D
+ *  name.
+ */
+char[] demangle( const(char)[] buf, char[] dst = null )
+{
+    //return Demangle(buf, dst)();
+    auto d = Demangle(buf, dst);
+    return d.demangleName();
+}
+
+
+/**
+ * Demangles a D mangled type.
+ *
+ * Params:
+ *  buf = The string to demangle.
+ *  dst = An optional destination buffer.
+ *
+ * Returns:
+ *  The demangled type name or the original string if the name is not a
+ *  mangled D type.
+*/
+char[] demangleType( const(char)[] buf, char[] dst = null )
+{
+    auto d = Demangle(buf, dst);
+    return d.demangleType();
+}
+
+
+/**
+ * Mangles a D symbol.
+ *
+ * Params:
+ *  T = The type of the symbol.
+ *  fqn = The fully qualified name of the symbol.
+ *  dst = An optional destination buffer.
+ *
+ * Returns:
+ *  The mangled name for a symbols of type T and the given fully
+ *  qualified name.
+ */
+char[] mangle(T)(const(char)[] fqn, char[] dst = null) @safe pure nothrow
+{
+    import core.internal.string : numDigits, unsignedToTempString;
+
+    static struct DotSplitter
+    {
+    @safe pure nothrow:
+        const(char)[] s;
+
+        @property bool empty() const { return !s.length; }
+
+        @property const(char)[] front() const
+        {
+            immutable i = indexOfDot();
+            return i == -1 ? s[0 .. $] : s[0 .. i];
+        }
+
+        void popFront()
+        {
+            immutable i = indexOfDot();
+            s = i == -1 ? s[$ .. $] : s[i+1 .. $];
+        }
+
+        private ptrdiff_t indexOfDot() const
+        {
+            foreach (i, c; s) if (c == '.') return i;
+            return -1;
+        }
+    }
+
+    size_t len = "_D".length;
+    foreach (comp; DotSplitter(fqn))
+        len += numDigits(comp.length) + comp.length;
+    len += T.mangleof.length;
+    if (dst.length < len) dst.length = len;
+
+    size_t i = "_D".length;
+    dst[0 .. i] = "_D";
+    foreach (comp; DotSplitter(fqn))
+    {
+        const ndigits = numDigits(comp.length);
+        unsignedToTempString(comp.length, dst[i .. i + ndigits]);
+        i += ndigits;
+        dst[i .. i + comp.length] = comp[];
+        i += comp.length;
+    }
+    dst[i .. i + T.mangleof.length] = T.mangleof[];
+    i += T.mangleof.length;
+    return dst[0 .. i];
+}
+
+
+///
+unittest
+{
+    assert(mangle!int("a.b") == "_D1a1bi");
+    assert(mangle!(char[])("test.foo") == "_D4test3fooAa");
+    assert(mangle!(int function(int))("a.b") == "_D1a1bPFiZi");
+}
+
+unittest
+{
+    static assert(mangle!int("a.b") == "_D1a1bi");
+
+    auto buf = new char[](10);
+    buf = mangle!int("a.b", buf);
+    assert(buf == "_D1a1bi");
+    buf = mangle!(char[])("test.foo", buf);
+    assert(buf == "_D4test3fooAa");
+    buf = mangle!(real delegate(int))("modµ.dg");
+    assert(buf == "_D5modµ2dgDFiZe", buf);
+}
+
+
+/**
+ * Mangles a D function.
+ *
+ * Params:
+ *  T = function pointer type.
+ *  fqn = The fully qualified name of the symbol.
+ *  dst = An optional destination buffer.
+ *
+ * Returns:
+ *  The mangled name for a function with function pointer type T and
+ *  the given fully qualified name.
+ */
+char[] mangleFunc(T:FT*, FT)(const(char)[] fqn, char[] dst = null) @safe pure nothrow if (is(FT == function))
+{
+    static if (isExternD!FT)
+    {
+        return mangle!FT(fqn, dst);
+    }
+    else static if (hasPlainMangling!FT)
+    {
+        dst.length = fqn.length;
+        dst[] = fqn[];
+        return dst;
+    }
+    else static if (isExternCPP!FT)
+    {
+        static assert(0, "Can't mangle extern(C++) functions.");
+    }
+    else
+    {
+        static assert(0, "Can't mangle function with unknown linkage ("~FT.stringof~").");
+    }
+}
+
+
+///
+unittest
+{
+    assert(mangleFunc!(int function(int))("a.b") == "_D1a1bFiZi");
+    assert(mangleFunc!(int function(Object))("object.Object.opEquals") == "_D6object6Object8opEqualsFC6ObjectZi");
+}
+
+unittest
+{
+    int function(lazy int[], ...) fp;
+    assert(mangle!(typeof(fp))("demangle.test") == "_D8demangle4testPFLAiYi");
+    assert(mangle!(typeof(*fp))("demangle.test") == "_D8demangle4testFLAiYi");
+}
+
+private template isExternD(FT) if (is(FT == function))
+{
+    enum isExternD = FT.mangleof[0] == 'F';
+}
+
+private template isExternCPP(FT) if (is(FT == function))
+{
+    enum isExternCPP = FT.mangleof[0] == 'R';
+}
+
+private template hasPlainMangling(FT) if (is(FT == function))
+{
+    enum c = FT.mangleof[0];
+    // C || Pascal || Windows
+    enum hasPlainMangling = c == 'U' || c == 'V' || c == 'W';
+}
+
+unittest
+{
+    static extern(D) void fooD();
+    static extern(C) void fooC();
+    static extern(Pascal) void fooP();
+    static extern(Windows) void fooW();
+    static extern(C++) void fooCPP();
+
+    bool check(FT)(bool isD, bool isCPP, bool isPlain)
+    {
+        return isExternD!FT == isD && isExternCPP!FT == isCPP &&
+            hasPlainMangling!FT == isPlain;
+    }
+    static assert(check!(typeof(fooD))(true, false, false));
+    static assert(check!(typeof(fooC))(false, false, true));
+    static assert(check!(typeof(fooP))(false, false, true));
+    static assert(check!(typeof(fooW))(false, false, true));
+    static assert(check!(typeof(fooCPP))(false, true, false));
+
+    static assert(__traits(compiles, mangleFunc!(typeof(&fooD))("")));
+    static assert(__traits(compiles, mangleFunc!(typeof(&fooC))("")));
+    static assert(__traits(compiles, mangleFunc!(typeof(&fooP))("")));
+    static assert(__traits(compiles, mangleFunc!(typeof(&fooW))("")));
+    static assert(!__traits(compiles, mangleFunc!(typeof(&fooCPP))("")));
+}
+
+/***
+ * C name mangling is done by adding a prefix on some platforms.
+ */
+version(Win32)
+    enum string cPrefix = "_";
+else version(OSX)
+    enum string cPrefix = "_";
+else
+    enum string cPrefix = "";
+
+version(unittest)
+{
+    immutable string[2][] table =
+    [
+        ["printf", "printf"],
+        ["_foo", "_foo"],
+        ["_D88", "_D88"],
+        ["_D4test3fooAa", "char[] test.foo"],
+        ["_D8demangle8demangleFAaZAa", "char[] demangle.demangle(char[])"],
+        ["_D6object6Object8opEqualsFC6ObjectZi", "int object.Object.opEquals(Object)"],
+        ["_D4test2dgDFiYd", "double test.dg(int, ...)"],
+        //["_D4test58__T9factorialVde67666666666666860140VG5aa5_68656c6c6fVPvnZ9factorialf", ""],
+        //["_D4test101__T9factorialVde67666666666666860140Vrc9a999999999999d9014000000000000000c00040VG5aa5_68656c6c6fVPvnZ9factorialf", ""],
+        ["_D4test34__T3barVG3uw3_616263VG3wd3_646566Z1xi", "int test.bar!(\"abc\"w, \"def\"d).x"],
+        ["_D8demangle4testFLC6ObjectLDFLiZiZi", "int demangle.test(lazy Object, lazy int delegate(lazy int))"],
+        ["_D8demangle4testFAiXi", "int demangle.test(int[]...)"],
+        ["_D8demangle4testFAiYi", "int demangle.test(int[], ...)"],
+        ["_D8demangle4testFLAiXi", "int demangle.test(lazy int[]...)"],
+        ["_D8demangle4testFLAiYi", "int demangle.test(lazy int[], ...)"],
+        ["_D6plugin8generateFiiZAya", "immutable(char)[] plugin.generate(int, int)"],
+        ["_D6plugin8generateFiiZAxa", "const(char)[] plugin.generate(int, int)"],
+        ["_D6plugin8generateFiiZAOa", "shared(char)[] plugin.generate(int, int)"],
+        ["_D8demangle3fnAFZ3fnBMFZv", "void demangle.fnA().fnB()"],
+        ["_D8demangle4mainFZ1S3fnCMFZv", "void demangle.main().S.fnC()"],
+        ["_D8demangle4mainFZ1S3fnDMFZv", "void demangle.main().S.fnD()"],
+        ["_D8demangle20__T2fnVAiA4i1i2i3i4Z2fnFZv", "void demangle.fn!([1, 2, 3, 4]).fn()"],
+        ["_D8demangle10__T2fnVi1Z2fnFZv", "void demangle.fn!(1).fn()"],
+        ["_D8demangle26__T2fnVS8demangle1SS2i1i2Z2fnFZv", "void demangle.fn!(demangle.S(1, 2)).fn()"],
+        ["_D8demangle13__T2fnVeeNANZ2fnFZv", "void demangle.fn!(real.nan).fn()"],
+        ["_D8demangle14__T2fnVeeNINFZ2fnFZv", "void demangle.fn!(-real.infinity).fn()"],
+        ["_D8demangle13__T2fnVeeINFZ2fnFZv", "void demangle.fn!(real.infinity).fn()"],
+        ["_D8demangle21__T2fnVHiiA2i1i2i3i4Z2fnFZv", "void demangle.fn!([1:2, 3:4]).fn()"],
+        ["_D8demangle2fnFNgiZNgi", "inout(int) demangle.fn(inout(int))"],
+        ["_D8demangle29__T2fnVa97Va9Va0Vu257Vw65537Z2fnFZv", "void demangle.fn!('a', '\\t', \\x00, '\\u0101', '\\U00010001').fn()"],
+        ["_D2gc11gctemplates56__T8mkBitmapTS3std5range13__T4iotaTiTiZ4iotaFiiZ6ResultZ8mkBitmapFNbNiNfPmmZv",
+         "nothrow @nogc @safe void gc.gctemplates.mkBitmap!(std.range.iota!(int, int).iota(int, int).Result).mkBitmap(ulong*, ulong)"],
+        ["_D8serenity9persister6Sqlite69__T15SqlitePersisterTS8serenity9persister6Sqlite11__unittest6FZ4TestZ15SqlitePersister12__T7opIndexZ7opIndexMFmZS8serenity9persister6Sqlite11__unittest6FZ4Test",
+         "serenity.persister.Sqlite.__unittest6().Test serenity.persister.Sqlite.SqlitePersister!(serenity.persister.Sqlite.__unittest6().Test).SqlitePersister.opIndex!().opIndex(ulong)"],
+        ["_D8bug100274mainFZ5localMFZi","int bug10027.main().local()"],
+        ["_D8demangle4testFNhG16gZv", "void demangle.test(__vector(byte[16]))"],
+        ["_D8demangle4testFNhG8sZv", "void demangle.test(__vector(short[8]))"],
+        ["_D8demangle4testFNhG4iZv", "void demangle.test(__vector(int[4]))"],
+        ["_D8demangle4testFNhG2lZv", "void demangle.test(__vector(long[2]))"],
+        ["_D8demangle4testFNhG4fZv", "void demangle.test(__vector(float[4]))"],
+        ["_D8demangle4testFNhG2dZv", "void demangle.test(__vector(double[2]))"],
+        ["_D8demangle4testFNhG4fNhG4fZv", "void demangle.test(__vector(float[4]), __vector(float[4]))"],
+        ["_D8bug1119234__T3fooS23_D8bug111924mainFZ3bariZ3fooMFZv","void bug11192.foo!(int bug11192.main().bar).foo()"],
+        ["_D13libd_demangle12__ModuleInfoZ", "libd_demangle.__ModuleInfo"],
+        ["_D15TypeInfo_Struct6__vtblZ", "TypeInfo_Struct.__vtbl"],
+        ["_D3std5stdio12__ModuleInfoZ", "std.stdio.__ModuleInfo"],
+        ["_D3std6traits15__T8DemangleTkZ8Demangle6__initZ", "std.traits.Demangle!(uint).Demangle.__init"],
+        ["_D3foo3Bar7__ClassZ", "foo.Bar.__Class"],
+        ["_D3foo3Bar6__vtblZ", "foo.Bar.__vtbl"],
+        ["_D3foo3Bar11__interfaceZ", "foo.Bar.__interface"],
+        ["_D3foo7__arrayZ", "foo.__array"],
+        ["_D8link657428__T3fooVE8link65746Methodi0Z3fooFZi", "int link6574.foo!(0).foo()"],
+        ["_D8link657429__T3fooHVE8link65746Methodi0Z3fooFZi", "int link6574.foo!(0).foo()"],
+        ["_D4test22__T4funcVAyaa3_610a62Z4funcFNaNbNiNfZAya", `pure nothrow @nogc @safe immutable(char)[] test.func!("a\x0ab").func()`],
+        ["_D3foo3barFzkZzi", "cent foo.bar(ucent)"],
+    ];
+
+    template staticIota(int x)
+    {
+        template Seq(T...){ alias T Seq; }
+
+        static if (x == 0)
+            alias Seq!() staticIota;
+        else
+            alias Seq!(staticIota!(x - 1), x - 1) staticIota;
+    }
+}
+unittest
+{
+    foreach( i, name; table )
+    {
+        auto r = demangle( name[0] );
+        assert( r == name[1],
+                "demangled \"" ~ name[0] ~ "\" as \"" ~ r ~ "\" but expected \"" ~ name[1] ~ "\"");
+    }
+    foreach( i; staticIota!(table.length) )
+    {
+        enum r = demangle( table[i][0] );
+        static assert( r == table[i][1],
+                "demangled \"" ~ table[i][0] ~ "\" as \"" ~ r ~ "\" but expected \"" ~ table[i][1] ~ "\"");
+    }
+}
+
+
+/*
+ *
+ */
+string decodeDmdString( const(char)[] ln, ref size_t p )
+{
+    string s;
+    uint zlen, zpos;
+
+    // decompress symbol
+    while( p < ln.length )
+    {
+        int ch = cast(ubyte) ln[p++];
+        if( (ch & 0xc0) == 0xc0 )
+        {
+            zlen = (ch & 0x7) + 1;
+            zpos = ((ch >> 3) & 7) + 1; // + zlen;
+            if( zpos > s.length )
+                break;
+            s ~= s[$ - zpos .. $ - zpos + zlen];
+        }
+        else if( ch >= 0x80 )
+        {
+            if( p >= ln.length )
+                break;
+            int ch2 = cast(ubyte) ln[p++];
+            zlen = (ch2 & 0x7f) | ((ch & 0x38) << 4);
+            if( p >= ln.length )
+                break;
+            int ch3 = cast(ubyte) ln[p++];
+            zpos = (ch3 & 0x7f) | ((ch & 7) << 7);
+            if( zpos > s.length )
+                break;
+            s ~= s[$ - zpos .. $ - zpos + zlen];
+        }
+        else if( Demangle.isAlpha(cast(char)ch) || Demangle.isDigit(cast(char)ch) || ch == '_' )
+            s ~= cast(char) ch;
+        else
+        {
+            p--;
+            break;
+        }
+    }
+    return s;
+}
diff --git a/libphobos/libdruntime/core/exception.d b/libphobos/libdruntime/core/exception.d
new file mode 100644
index 00000000000..16baa771f90
--- /dev/null
+++ b/libphobos/libdruntime/core/exception.d
@@ -0,0 +1,718 @@
+/**
+ * The exception module defines all system-level exceptions and provides a
+ * mechanism to alter system-level error handling.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2013.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly and Jonathan M Davis
+ * Source:    $(DRUNTIMESRC core/_exception.d)
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module core.exception;
+
+/**
+ * Thrown on a range error.
+ */
+class RangeError : Error
+{
+    @safe pure nothrow this( string file = __FILE__, size_t line = __LINE__, Throwable next = null )
+    {
+        super( "Range violation", file, line, next );
+    }
+}
+
+unittest
+{
+    {
+        auto re = new RangeError();
+        assert(re.file == __FILE__);
+        assert(re.line == __LINE__ - 2);
+        assert(re.next is null);
+        assert(re.msg == "Range violation");
+    }
+
+    {
+        auto re = new RangeError("hello", 42, new Exception("It's an Exception!"));
+        assert(re.file == "hello");
+        assert(re.line == 42);
+        assert(re.next !is null);
+        assert(re.msg == "Range violation");
+    }
+}
+
+
+/**
+ * Thrown on an assert error.
+ */
+class AssertError : Error
+{
+    @safe pure nothrow this( string file, size_t line )
+    {
+        this(cast(Throwable)null, file, line);
+    }
+
+    @safe pure nothrow this( Throwable next, string file = __FILE__, size_t line = __LINE__ )
+    {
+        this( "Assertion failure", file, line, next);
+    }
+
+    @safe pure nothrow this( string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null )
+    {
+        super( msg, file, line, next );
+    }
+}
+
+unittest
+{
+    {
+        auto ae = new AssertError("hello", 42);
+        assert(ae.file == "hello");
+        assert(ae.line == 42);
+        assert(ae.next is null);
+        assert(ae.msg == "Assertion failure");
+    }
+
+    {
+        auto ae = new AssertError(new Exception("It's an Exception!"));
+        assert(ae.file == __FILE__);
+        assert(ae.line == __LINE__ - 2);
+        assert(ae.next !is null);
+        assert(ae.msg == "Assertion failure");
+    }
+
+    {
+        auto ae = new AssertError(new Exception("It's an Exception!"), "hello", 42);
+        assert(ae.file == "hello");
+        assert(ae.line == 42);
+        assert(ae.next !is null);
+        assert(ae.msg == "Assertion failure");
+    }
+
+    {
+        auto ae = new AssertError("msg");
+        assert(ae.file == __FILE__);
+        assert(ae.line == __LINE__ - 2);
+        assert(ae.next is null);
+        assert(ae.msg == "msg");
+    }
+
+    {
+        auto ae = new AssertError("msg", "hello", 42);
+        assert(ae.file == "hello");
+        assert(ae.line == 42);
+        assert(ae.next is null);
+        assert(ae.msg == "msg");
+    }
+
+    {
+        auto ae = new AssertError("msg", "hello", 42, new Exception("It's an Exception!"));
+        assert(ae.file == "hello");
+        assert(ae.line == 42);
+        assert(ae.next !is null);
+        assert(ae.msg == "msg");
+    }
+}
+
+
+/**
+ * Thrown on finalize error.
+ */
+class FinalizeError : Error
+{
+    TypeInfo   info;
+
+    this( TypeInfo ci, Throwable next, string file = __FILE__, size_t line = __LINE__ ) @safe pure nothrow @nogc
+    {
+        this(ci, file, line, next);
+    }
+
+    this( TypeInfo ci, string file = __FILE__, size_t line = __LINE__, Throwable next = null ) @safe pure nothrow @nogc
+    {
+        super( "Finalization error", file, line, next );
+        super.info = SuppressTraceInfo.instance;
+        info = ci;
+    }
+
+    override string toString() const @safe
+    {
+        return "An exception was thrown while finalizing an instance of " ~ info.toString();
+    }
+}
+
+unittest
+{
+    ClassInfo info = new ClassInfo;
+    info.name = "testInfo";
+
+    {
+        auto fe = new FinalizeError(info);
+        assert(fe.file == __FILE__);
+        assert(fe.line == __LINE__ - 2);
+        assert(fe.next is null);
+        assert(fe.msg == "Finalization error");
+        assert(fe.info == info);
+    }
+
+    {
+        auto fe = new FinalizeError(info, new Exception("It's an Exception!"));
+        assert(fe.file == __FILE__);
+        assert(fe.line == __LINE__ - 2);
+        assert(fe.next !is null);
+        assert(fe.msg == "Finalization error");
+        assert(fe.info == info);
+    }
+
+    {
+        auto fe = new FinalizeError(info, "hello", 42);
+        assert(fe.file == "hello");
+        assert(fe.line == 42);
+        assert(fe.next is null);
+        assert(fe.msg == "Finalization error");
+        assert(fe.info == info);
+    }
+
+    {
+        auto fe = new FinalizeError(info, "hello", 42, new Exception("It's an Exception!"));
+        assert(fe.file == "hello");
+        assert(fe.line == 42);
+        assert(fe.next !is null);
+        assert(fe.msg == "Finalization error");
+        assert(fe.info == info);
+    }
+}
+
+/**
+ * Thrown on hidden function error.
+ * $(RED Deprecated.
+ *   This feature is not longer part of the language.)
+ */
+deprecated class HiddenFuncError : Error
+{
+    @safe pure nothrow this( ClassInfo ci )
+    {
+        super( "Hidden method called for " ~ ci.name );
+    }
+}
+
+deprecated unittest
+{
+    ClassInfo info = new ClassInfo;
+    info.name = "testInfo";
+
+    {
+        auto hfe = new HiddenFuncError(info);
+        assert(hfe.next is null);
+        assert(hfe.msg == "Hidden method called for testInfo");
+    }
+}
+
+
+/**
+ * Thrown on an out of memory error.
+ */
+class OutOfMemoryError : Error
+{
+    this(string file = __FILE__, size_t line = __LINE__, Throwable next = null ) @safe pure nothrow @nogc
+    {
+        this(true, file, line, next);
+    }
+
+    this(bool trace, string file = __FILE__, size_t line = __LINE__, Throwable next = null ) @safe pure nothrow @nogc
+    {
+        super("Memory allocation failed", file, line, next);
+        if (!trace)
+            this.info = SuppressTraceInfo.instance;
+    }
+
+    override string toString() const @trusted
+    {
+        return msg.length ? (cast()this).superToString() : "Memory allocation failed";
+    }
+
+    // kludge to call non-const super.toString
+    private string superToString() @trusted
+    {
+        return super.toString();
+    }
+}
+
+unittest
+{
+    {
+        auto oome = new OutOfMemoryError();
+        assert(oome.file == __FILE__);
+        assert(oome.line == __LINE__ - 2);
+        assert(oome.next is null);
+        assert(oome.msg == "Memory allocation failed");
+        assert(oome.toString.length);
+    }
+
+    {
+        auto oome = new OutOfMemoryError("hello", 42, new Exception("It's an Exception!"));
+        assert(oome.file == "hello");
+        assert(oome.line == 42);
+        assert(oome.next !is null);
+        assert(oome.msg == "Memory allocation failed");
+    }
+}
+
+
+/**
+ * Thrown on an invalid memory operation.
+ *
+ * An invalid memory operation error occurs in circumstances when the garbage
+ * collector has detected an operation it cannot reliably handle. The default
+ * D GC is not re-entrant, so this can happen due to allocations done from
+ * within finalizers called during a garbage collection cycle.
+ */
+class InvalidMemoryOperationError : Error
+{
+    this(string file = __FILE__, size_t line = __LINE__, Throwable next = null ) @safe pure nothrow @nogc
+    {
+        super( "Invalid memory operation", file, line, next );
+        this.info = SuppressTraceInfo.instance;
+    }
+
+    override string toString() const @trusted
+    {
+        return msg.length ? (cast()this).superToString() : "Invalid memory operation";
+    }
+
+    // kludge to call non-const super.toString
+    private string superToString() @trusted
+    {
+        return super.toString();
+    }
+}
+
+unittest
+{
+    {
+        auto oome = new InvalidMemoryOperationError();
+        assert(oome.file == __FILE__);
+        assert(oome.line == __LINE__ - 2);
+        assert(oome.next is null);
+        assert(oome.msg == "Invalid memory operation");
+        assert(oome.toString.length);
+    }
+
+    {
+        auto oome = new InvalidMemoryOperationError("hello", 42, new Exception("It's an Exception!"));
+        assert(oome.file == "hello");
+        assert(oome.line == 42);
+        assert(oome.next !is null);
+        assert(oome.msg == "Invalid memory operation");
+    }
+}
+
+
+/**
+ * Thrown on a switch error.
+ */
+class SwitchError : Error
+{
+    @safe pure nothrow this( string file = __FILE__, size_t line = __LINE__, Throwable next = null )
+    {
+        super( "No appropriate switch clause found", file, line, next );
+    }
+}
+
+unittest
+{
+    {
+        auto se = new SwitchError();
+        assert(se.file == __FILE__);
+        assert(se.line == __LINE__ - 2);
+        assert(se.next is null);
+        assert(se.msg == "No appropriate switch clause found");
+    }
+
+    {
+        auto se = new SwitchError("hello", 42, new Exception("It's an Exception!"));
+        assert(se.file == "hello");
+        assert(se.line == 42);
+        assert(se.next !is null);
+        assert(se.msg == "No appropriate switch clause found");
+    }
+}
+
+
+/**
+ * Thrown on a unicode conversion error.
+ */
+class UnicodeException : Exception
+{
+    size_t idx;
+
+    this( string msg, size_t idx, string file = __FILE__, size_t line = __LINE__, Throwable next = null ) @safe pure nothrow
+    {
+        super( msg, file, line, next );
+        this.idx = idx;
+    }
+}
+
+unittest
+{
+    {
+        auto ue = new UnicodeException("msg", 2);
+        assert(ue.file == __FILE__);
+        assert(ue.line == __LINE__ - 2);
+        assert(ue.next is null);
+        assert(ue.msg == "msg");
+        assert(ue.idx == 2);
+    }
+
+    {
+        auto ue = new UnicodeException("msg", 2, "hello", 42, new Exception("It's an Exception!"));
+        assert(ue.file == "hello");
+        assert(ue.line == 42);
+        assert(ue.next !is null);
+        assert(ue.msg == "msg");
+        assert(ue.idx == 2);
+    }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Overrides
+///////////////////////////////////////////////////////////////////////////////
+
+
+// NOTE: One assert handler is used for all threads.  Thread-local
+//       behavior should occur within the handler itself.  This delegate
+//       is __gshared for now based on the assumption that it will only
+//       set by the main thread during program initialization.
+private __gshared AssertHandler _assertHandler = null;
+
+
+/**
+Gets/sets assert hander. null means the default handler is used.
+*/
+alias AssertHandler = void function(string file, size_t line, string msg) nothrow;
+
+/// ditto
+@property AssertHandler assertHandler() @trusted nothrow @nogc
+{
+    return _assertHandler;
+}
+
+/// ditto
+@property void assertHandler(AssertHandler handler) @trusted nothrow @nogc
+{
+    _assertHandler = handler;
+}
+
+/**
+ * Overrides the default assert hander with a user-supplied version.
+ * $(RED Deprecated.
+ *   Please use $(LREF assertHandler) instead.)
+ *
+ * Params:
+ *  h = The new assert handler.  Set to null to use the default handler.
+ */
+deprecated void setAssertHandler( AssertHandler h ) @trusted nothrow @nogc
+{
+    assertHandler = h;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Overridable Callbacks
+///////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * A callback for assert errors in D.  The user-supplied assert handler will
+ * be called if one has been supplied, otherwise an $(LREF AssertError) will be
+ * thrown.
+ *
+ * Params:
+ *  file = The name of the file that signaled this error.
+ *  line = The line number on which this error occurred.
+ */
+extern (C) void onAssertError( string file = __FILE__, size_t line = __LINE__ ) nothrow
+{
+    if( _assertHandler is null )
+        throw new AssertError( file, line );
+    _assertHandler( file, line, null);
+}
+
+
+/**
+ * A callback for assert errors in D.  The user-supplied assert handler will
+ * be called if one has been supplied, otherwise an $(LREF AssertError) will be
+ * thrown.
+ *
+ * Params:
+ *  file = The name of the file that signaled this error.
+ *  line = The line number on which this error occurred.
+ *  msg  = An error message supplied by the user.
+ */
+extern (C) void onAssertErrorMsg( string file, size_t line, string msg ) nothrow
+{
+    if( _assertHandler is null )
+        throw new AssertError( msg, file, line );
+    _assertHandler( file, line, msg );
+}
+
+
+/**
+ * A callback for unittest errors in D.  The user-supplied unittest handler
+ * will be called if one has been supplied, otherwise the error will be
+ * written to stderr.
+ *
+ * Params:
+ *  file = The name of the file that signaled this error.
+ *  line = The line number on which this error occurred.
+ *  msg  = An error message supplied by the user.
+ */
+extern (C) void onUnittestErrorMsg( string file, size_t line, string msg ) nothrow
+{
+    onAssertErrorMsg( file, line, msg );
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Internal Error Callbacks
+///////////////////////////////////////////////////////////////////////////////
+
+/**
+ * A callback for array bounds errors in D.  A $(LREF RangeError) will be thrown.
+ *
+ * Params:
+ *  file = The name of the file that signaled this error.
+ *  line = The line number on which this error occurred.
+ *
+ * Throws:
+ *  $(LREF RangeError).
+ */
+extern (C) void onRangeError( string file = __FILE__, size_t line = __LINE__ ) @safe pure nothrow
+{
+    throw new RangeError( file, line, null );
+}
+
+
+/**
+ * A callback for finalize errors in D.  A $(LREF FinalizeError) will be thrown.
+ *
+ * Params:
+ *  info = The TypeInfo instance for the object that failed finalization.
+ *  e = The exception thrown during finalization.
+ *  file = The name of the file that signaled this error.
+ *  line = The line number on which this error occurred.
+ *
+ * Throws:
+ *  $(LREF FinalizeError).
+ */
+extern (C) void onFinalizeError( TypeInfo info, Throwable e, string file = __FILE__, size_t line = __LINE__ ) @trusted nothrow
+{
+    // This error is thrown during a garbage collection, so no allocation must occur while
+    //  generating this object. So we use a preallocated instance
+    throw staticError!FinalizeError(info, e, file, line);
+}
+
+
+/**
+ * A callback for hidden function errors in D.  A $(LREF HiddenFuncError) will be
+ * thrown.
+ * $(RED Deprecated.
+ *   This feature is not longer part of the language.)
+ *
+ * Throws:
+ *  $(LREF HiddenFuncError).
+ */
+deprecated extern (C) void onHiddenFuncError( Object o ) @safe pure nothrow
+{
+    throw new HiddenFuncError( typeid(o) );
+}
+
+
+/**
+ * A callback for out of memory errors in D.  An $(LREF OutOfMemoryError) will be
+ * thrown.
+ *
+ * Throws:
+ *  $(LREF OutOfMemoryError).
+ */
+extern (C) void onOutOfMemoryError(void* pretend_sideffect = null) @trusted pure nothrow @nogc /* dmd @@@BUG11461@@@ */
+{
+    // NOTE: Since an out of memory condition exists, no allocation must occur
+    //       while generating this object.
+    throw staticError!OutOfMemoryError();
+}
+
+extern (C) void onOutOfMemoryErrorNoGC() @trusted nothrow @nogc
+{
+    // suppress stacktrace until they are @nogc
+    throw staticError!OutOfMemoryError(false);
+}
+
+
+/**
+ * A callback for invalid memory operations in D.  An
+ * $(LREF InvalidMemoryOperationError) will be thrown.
+ *
+ * Throws:
+ *  $(LREF InvalidMemoryOperationError).
+ */
+extern (C) void onInvalidMemoryOperationError(void* pretend_sideffect = null) @trusted pure nothrow @nogc /* dmd @@@BUG11461@@@ */
+{
+    // The same restriction applies as for onOutOfMemoryError. The GC is in an
+    // undefined state, thus no allocation must occur while generating this object.
+    throw staticError!InvalidMemoryOperationError();
+}
+
+
+/**
+ * A callback for switch errors in D.  A $(LREF SwitchError) will be thrown.
+ *
+ * Params:
+ *  file = The name of the file that signaled this error.
+ *  line = The line number on which this error occurred.
+ *
+ * Throws:
+ *  $(LREF SwitchError).
+ */
+extern (C) void onSwitchError( string file = __FILE__, size_t line = __LINE__ ) @safe pure nothrow
+{
+    throw new SwitchError( file, line, null );
+}
+
+
+/**
+ * A callback for unicode errors in D.  A $(LREF UnicodeException) will be thrown.
+ *
+ * Params:
+ *  msg = Information about the error.
+ *  idx = String index where this error was detected.
+ *  file = The name of the file that signaled this error.
+ *  line = The line number on which this error occurred.
+ *
+ * Throws:
+ *  $(LREF UnicodeException).
+ */
+extern (C) void onUnicodeError( string msg, size_t idx, string file = __FILE__, size_t line = __LINE__ ) @safe pure
+{
+    throw new UnicodeException( msg, idx, file, line );
+}
+
+/***********************************
+ * These functions must be defined for any D program linked
+ * against this library.
+ */
+/+
+extern (C) void onAssertError(string file, size_t line);
+extern (C) void onAssertErrorMsg(string file, size_t line, string msg);
+extern (C) void onUnittestErrorMsg(string file, size_t line, string msg);
+extern (C) void onRangeError(string file, size_t line);
+extern (C) void onHiddenFuncError(Object o);
+extern (C) void onSwitchError(string file, size_t line);
++/
+
+/***********************************
+ * Function calls to these are generated by the compiler and inserted into
+ * the object code.
+ */
+
+extern (C)
+{
+    // Use ModuleInfo to get file name for "m" versions
+
+    /* One of these three is called upon an assert() fail.
+     */
+    void _d_assertm(immutable(ModuleInfo)* m, uint line)
+    {
+        onAssertError(m.name, line);
+    }
+
+    void _d_assert_msg(string msg, string file, uint line)
+    {
+        onAssertErrorMsg(file, line, msg);
+    }
+
+    void _d_assert(string file, uint line)
+    {
+        onAssertError(file, line);
+    }
+
+    /* One of these three is called upon an assert() fail inside of a unittest block
+     */
+    void _d_unittestm(immutable(ModuleInfo)* m, uint line)
+    {
+        _d_unittest(m.name, line);
+    }
+
+    void _d_unittest_msg(string msg, string file, uint line)
+    {
+        onUnittestErrorMsg(file, line, msg);
+    }
+
+    void _d_unittest(string file, uint line)
+    {
+        _d_unittest_msg("unittest failure", file, line);
+    }
+
+    /* Called when an array index is out of bounds
+     */
+    void _d_array_bounds(immutable(ModuleInfo)* m, uint line)
+    {
+        onRangeError(m.name, line);
+    }
+
+    void _d_arraybounds(string file, uint line)
+    {
+        onRangeError(file, line);
+    }
+
+    /* Called when a switch statement has no DefaultStatement, yet none of the cases match
+     */
+    void _d_switch_errorm(immutable(ModuleInfo)* m, uint line)
+    {
+        onSwitchError(m.name, line);
+    }
+
+    void _d_switch_error(string file, uint line)
+    {
+        onSwitchError(file, line);
+    }
+}
+
+// TLS storage shared for all errors, chaining might create circular reference
+private void[128] _store;
+
+// only Errors for now as those are rarely chained
+private T staticError(T, Args...)(auto ref Args args)
+    if (is(T : Error))
+{
+    // pure hack, what we actually need is @noreturn and allow to call that in pure functions
+    static T get()
+    {
+        static assert(__traits(classInstanceSize, T) <= _store.length,
+                      T.stringof ~ " is too large for staticError()");
+
+        _store[0 .. __traits(classInstanceSize, T)] = typeid(T).initializer[];
+        return cast(T) _store.ptr;
+    }
+    auto res = (cast(T function() @trusted pure nothrow @nogc) &get)();
+    res.__ctor(args);
+    return res;
+}
+
+// Suppress traceinfo generation when the GC cannot be used.  Workaround for
+// Bugzilla 14993. We should make stack traces @nogc instead.
+package class SuppressTraceInfo : Throwable.TraceInfo
+{
+    override int opApply(scope int delegate(ref const(char[]))) const { return 0; }
+    override int opApply(scope int delegate(ref size_t, ref const(char[]))) const { return 0; }
+    override string toString() const { return null; }
+    static SuppressTraceInfo instance() @trusted @nogc pure nothrow
+    {
+        static immutable SuppressTraceInfo it = new SuppressTraceInfo;
+        return cast(SuppressTraceInfo)it;
+    }
+}
diff --git a/libphobos/libdruntime/core/internal/abort.d b/libphobos/libdruntime/core/internal/abort.d
new file mode 100644
index 00000000000..d2d0eb87240
--- /dev/null
+++ b/libphobos/libdruntime/core/internal/abort.d
@@ -0,0 +1,45 @@
+module core.internal.abort;
+
+/*
+ * Use instead of assert(0, msg), since this does not print a message for -release compiled
+ * code, and druntime is -release compiled.
+ */
+void abort(string msg, string filename = __FILE__, size_t line = __LINE__) @nogc nothrow @safe
+{
+    import core.stdc.stdlib: c_abort = abort;
+    // use available OS system calls to print the message to stderr
+    version(Posix)
+    {
+        import core.sys.posix.unistd: write;
+        static void writeStr(const(char)[][] m...) @nogc nothrow @trusted
+        {
+            foreach(s; m)
+                write(2, s.ptr, s.length);
+        }
+    }
+    else version(Windows)
+    {
+        import core.sys.windows.windows: GetStdHandle, STD_ERROR_HANDLE, WriteFile, INVALID_HANDLE_VALUE;
+        auto h = (() @trusted => GetStdHandle(STD_ERROR_HANDLE))();
+        if(h == INVALID_HANDLE_VALUE)
+            // attempt best we can to print the message
+            assert(0, msg);
+        void writeStr(const(char)[][] m...) @nogc nothrow @trusted
+        {
+            foreach(s; m)
+            {
+                assert(s.length <= uint.max);
+                WriteFile(h, s.ptr, cast(uint)s.length, null, null);
+            }
+        }
+    }
+    else
+        static assert(0, "Unsupported OS");
+
+    import core.internal.string;
+    UnsignedStringBuf strbuff;
+
+    // write an appropriate message, then abort the program
+    writeStr("Aborting from ", filename, "(", line.unsignedToTempString(strbuff, 10), ") ", msg);
+    c_abort();
+}
diff --git a/libphobos/libdruntime/core/internal/convert.d b/libphobos/libdruntime/core/internal/convert.d
new file mode 100644
index 00000000000..140c14bb245
--- /dev/null
+++ b/libphobos/libdruntime/core/internal/convert.d
@@ -0,0 +1,638 @@
+/**
+ * Written in the D programming language.
+ * This module provides functions to converting different values to const(ubyte)[]
+ *
+ * Copyright: Copyright Igor Stepanov 2013-2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Igor Stepanov
+ * Source: $(DRUNTIMESRC core/internal/_convert.d)
+ */
+module core.internal.convert;
+import core.internal.traits : Unqual;
+
+@trusted pure nothrow
+const(ubyte)[] toUbyte(T)(ref T val) if(is(Unqual!T == float) || is(Unqual!T == double) || is(Unqual!T == real) ||
+                                        is(Unqual!T == ifloat) || is(Unqual!T == idouble) || is(Unqual!T == ireal))
+{
+    static const(ubyte)[] reverse_(const(ubyte)[] arr)
+    {
+        ubyte[] buff = new ubyte[arr.length];
+        foreach(k, v; arr)
+        {
+            buff[$-k-1] = v;
+        }
+        return buff;
+    }
+    if(__ctfe)
+    {
+        auto parsed = parse(val);
+
+        ulong mantissa = parsed.mantissa;
+        uint exp = parsed.exponent;
+        uint sign = parsed.sign;
+
+        ubyte[T.sizeof] buff;
+        size_t off_bytes = 0;
+        size_t off_bits  = 0;
+
+        for(; off_bytes < FloatTraits!T.MANTISSA/8; ++off_bytes)
+        {
+            buff[off_bytes] = cast(ubyte)mantissa;
+            mantissa >>= 8;
+        }
+        off_bits = FloatTraits!T.MANTISSA%8;
+        buff[off_bytes] = cast(ubyte)mantissa;
+
+        for(size_t i=0; i<FloatTraits!T.EXPONENT/8; ++i)
+        {
+            ubyte cur_exp = cast(ubyte)exp;
+            exp >>= 8;
+            buff[off_bytes] |= (cur_exp << off_bits);
+            ++off_bytes;
+            buff[off_bytes] |= cur_exp >> 8 - off_bits;
+        }
+
+
+        exp <<= 8 - FloatTraits!T.EXPONENT%8 - 1;
+        buff[off_bytes] |= exp;
+        sign <<= 7;
+        buff[off_bytes] |= sign;
+
+        version(LittleEndian)
+        {
+            return buff.dup;
+        }
+        else
+        {
+            return reverse_(buff);
+        }
+    }
+    else
+    {
+        return (cast(const(ubyte)*)&val)[0 .. T.sizeof];
+    }
+}
+
+@safe pure nothrow
+private Float parse(bool is_denormalized = false, T)(T x) if(is(Unqual!T == ifloat) || is(Unqual!T == idouble) || is(Unqual!T == ireal))
+{
+    return parse(x.im);
+}
+
+@safe pure nothrow
+private Float parse(bool is_denormalized = false, T:real)(T x_) if(floatFormat!T != FloatFormat.Real80)
+{
+    Unqual!T x = x_;
+    assert(floatFormat!T != FloatFormat.DoubleDouble && floatFormat!T != FloatFormat.Quadruple,
+           "doubledouble and quadruple float formats are not supported in CTFE");
+    if(x is cast(T)0.0) return FloatTraits!T.ZERO;
+    if(x is cast(T)-0.0) return FloatTraits!T.NZERO;
+    if(x is T.nan) return FloatTraits!T.NAN;
+    if(x is -T.nan) return FloatTraits!T.NNAN;
+    if(x is T.infinity || x > T.max) return FloatTraits!T.INF;
+    if(x is -T.infinity || x < -T.max) return FloatTraits!T.NINF;
+
+    uint sign = x < 0;
+    x = sign ? -x : x;
+    int e = binLog2(x);
+    real x2 = x;
+    uint exp = cast(uint)(e + (2^^(FloatTraits!T.EXPONENT-1) - 1));
+
+    if(!exp)
+    {
+        if(is_denormalized)
+            return Float(0, 0, sign);
+        else
+            return Float(denormalizedMantissa(x), 0, sign);
+    }
+
+    x2 /= binPow2(e);
+
+    static if(!is_denormalized)
+        x2 -= 1.0;
+
+    x2 *=  2UL<<(FloatTraits!T.MANTISSA);
+    ulong mant = shiftrRound(cast(ulong)x2);
+    return Float(mant, exp, sign);
+}
+
+@safe pure nothrow
+private Float parse(bool _ = false, T:real)(T x_) if(floatFormat!T == FloatFormat.Real80)
+{
+    Unqual!T x = x_;
+    //HACK @@@3632@@@
+
+    if(x == 0.0L)
+    {
+        real y = 1.0L/x;
+        if(y == real.infinity) // -0.0
+            return FloatTraits!T.ZERO;
+        else
+            return FloatTraits!T.NZERO; //0.0
+    }
+
+    if(x != x) //HACK: should be if(x is real.nan) and if(x is -real.nan)
+    {
+        auto y = cast(double)x;
+        if(y is double.nan)
+            return FloatTraits!T.NAN;
+        else
+            return FloatTraits!T.NNAN;
+    }
+
+    if(x == real.infinity) return FloatTraits!T.INF;
+    if(x == -real.infinity) return FloatTraits!T.NINF;
+
+    enum EXPONENT_MED = (2^^(FloatTraits!T.EXPONENT-1) - 1);
+    uint sign = x < 0;
+    x = sign ? -x : x;
+
+    int e = binLog2(x);
+    uint exp = cast(uint)(e + EXPONENT_MED);
+    if(!exp)
+    {
+        return Float(denormalizedMantissa(x), 0, sign);
+    }
+    int pow = (FloatTraits!T.MANTISSA-1-e);
+    x *=  binPow2((pow / EXPONENT_MED)*EXPONENT_MED); //To avoid overflow in 2.0L ^^ pow
+    x *=  binPow2(pow % EXPONENT_MED);
+    ulong mant = cast(ulong)x;
+    return Float(mant, exp, sign);
+}
+
+private struct Float
+{
+    ulong mantissa;
+    uint exponent;
+    uint sign;
+}
+
+private template FloatTraits(T) if(floatFormat!T == FloatFormat.Float)
+{
+    enum EXPONENT = 8;
+    enum MANTISSA = 23;
+    enum ZERO     = Float(0, 0, 0);
+    enum NZERO    = Float(0, 0, 1);
+    enum NAN      = Float(0x400000UL, 0xff, 0);
+    enum NNAN     = Float(0x400000UL, 0xff, 1);
+    enum INF      = Float(0, 255, 0);
+    enum NINF     = Float(0, 255, 1);
+}
+
+private template FloatTraits(T) if(floatFormat!T == FloatFormat.Double)
+{
+    enum EXPONENT = 11;
+    enum MANTISSA = 52;
+    enum ZERO     = Float(0, 0, 0);
+    enum NZERO    = Float(0, 0, 1);
+    enum NAN      = Float(0x8000000000000UL, 0x7ff, 0);
+    enum NNAN     = Float(0x8000000000000UL, 0x7ff, 1);
+    enum INF      = Float(0, 0x7ff, 0);
+    enum NINF     = Float(0, 0x7ff, 1);
+}
+
+private template FloatTraits(T) if(floatFormat!T == FloatFormat.Real80)
+{
+    enum EXPONENT = 15;
+    enum MANTISSA = 64;
+    enum ZERO     = Float(0, 0, 0);
+    enum NZERO    = Float(0, 0, 1);
+    enum NAN      = Float(0xC000000000000000UL, 0x7fff, 0);
+    enum NNAN     = Float(0xC000000000000000UL, 0x7fff, 1);
+    enum INF      = Float(0x8000000000000000UL, 0x7fff, 0);
+    enum NINF     = Float(0x8000000000000000UL, 0x7fff, 1);
+}
+
+private template FloatTraits(T) if(floatFormat!T == FloatFormat.DoubleDouble) //Unsupported in CTFE
+{
+    enum EXPONENT = 11;
+    enum MANTISSA = 106;
+    enum ZERO     = Float(0, 0, 0);
+    enum NZERO    = Float(0, 0, 1);
+    enum NAN      = Float(0x8000000000000UL, 0x7ff, 0);
+    enum NNAN     = Float(0x8000000000000UL, 0x7ff, 1);
+    enum INF      = Float(0, 0x7ff, 0);
+    enum NINF     = Float(0, 0x7ff, 1);
+}
+
+private template FloatTraits(T) if(floatFormat!T == FloatFormat.Quadruple) //Unsupported in CTFE
+{
+    enum EXPONENT = 15;
+    enum MANTISSA = 112;
+    enum ZERO     = Float(0, 0, 0);
+    enum NZERO    = Float(0, 0, 1);
+    enum NAN      = Float(-1, 0x7fff, 0);
+    enum NNAN     = Float(-1, 0x7fff, 1);
+    enum INF      = Float(0, 0x7fff, 0);
+    enum NINF     = Float(0, 0x7fff, 1);
+}
+
+
+@safe pure nothrow
+private real binPow2(int pow)
+{
+    static real binPosPow2(int pow) @safe pure nothrow
+    {
+        assert(pow > 0);
+
+        if(pow == 1) return 2.0L;
+
+        int subpow = pow/2;
+        real p = binPosPow2(subpow);
+        real ret = p*p;
+
+        if(pow%2)
+        {
+            ret *= 2.0L;
+        }
+
+        return ret;
+    }
+
+    if(!pow) return 1.0L;
+    if(pow > 0) return binPosPow2(pow);
+    return 1.0L/binPosPow2(-pow);
+}
+
+
+//Need in CTFE, because CTFE float and double expressions computed more precisely that run-time expressions.
+@safe pure nothrow
+private ulong shiftrRound(ulong x)
+{
+    return (x >> 1) + (x & 1);
+}
+
+@safe pure nothrow
+private uint binLog2(T)(T x)
+{
+    assert(x > 0);
+    int max = 2 ^^ (FloatTraits!T.EXPONENT-1)-1;
+    int min = -max+1;
+    int med = (min + max) / 2;
+
+    if(x < T.min_normal) return -max;
+
+    while((max - min) > 1)
+    {
+        if(binPow2(med) > x)
+        {
+            max = med;
+        }
+        else
+        {
+            min = med;
+        }
+        med = (min + max) / 2;
+    }
+
+    if(x < binPow2(max))
+        return min;
+    return max;
+}
+
+@safe pure nothrow
+private ulong denormalizedMantissa(T)(T x) if(floatFormat!T == FloatFormat.Real80)
+{
+    x *= 2.0L^^FloatTraits!T.MANTISSA;
+    auto fl = parse(x);
+    uint pow = FloatTraits!T.MANTISSA - fl.exponent + 1;
+    return fl.mantissa >> pow;
+}
+
+@safe pure nothrow
+private ulong denormalizedMantissa(T)(T x) if(floatFormat!T != FloatFormat.Real80)
+{
+    x *= 2.0L^^FloatTraits!T.MANTISSA;
+    auto fl = parse!true(x);
+    ulong mant = fl.mantissa >> (FloatTraits!T.MANTISSA - fl.exponent);
+    return shiftrRound(mant);
+}
+
+version(unittest)
+{
+    private const(ubyte)[] toUbyte2(T)(T val)
+    {
+        return toUbyte(val).dup;
+    }
+
+    private void testNumberConvert(string v)()
+    {
+        enum ctval = mixin(v);
+
+        alias TYPE = typeof(ctval);
+        auto rtval = ctval;
+        auto rtbytes = *cast(ubyte[TYPE.sizeof]*)&rtval;
+
+        enum ctbytes = toUbyte2(ctval);
+
+        // don't test pad bytes because can be anything
+        enum testsize =
+            (FloatTraits!TYPE.EXPONENT + FloatTraits!TYPE.MANTISSA + 1)/8;
+        assert(rtbytes[0..testsize] == ctbytes[0..testsize]);
+    }
+
+    private void testConvert()
+    {
+        /**Test special values*/
+        testNumberConvert!("-float.infinity");
+        testNumberConvert!("float.infinity");
+        testNumberConvert!("-0.0F");
+        testNumberConvert!("0.0F");
+        //testNumberConvert!("-float.nan"); //BUG @@@3632@@@
+        testNumberConvert!("float.nan");
+
+        testNumberConvert!("-double.infinity");
+        testNumberConvert!("double.infinity");
+        testNumberConvert!("-0.0");
+        testNumberConvert!("0.0");
+        //testNumberConvert!("-double.nan"); //BUG @@@3632@@@
+        testNumberConvert!("double.nan");
+
+        testNumberConvert!("-real.infinity");
+        testNumberConvert!("real.infinity");
+        testNumberConvert!("-0.0L");
+        testNumberConvert!("0.0L");
+        //testNumberConvert!("-real.nan"); //BUG @@@3632@@@
+        testNumberConvert!("real.nan");
+
+        /**
+            Test min and max values values: min value has an '1' mantissa and minimal exponent,
+            Max value has an all '1' bits mantissa and max exponent.
+        */
+        testNumberConvert!("float.min_normal");
+        testNumberConvert!("float.max");
+
+        /**Test common values*/
+        testNumberConvert!("-0.17F");
+        testNumberConvert!("3.14F");
+
+        /**Test immutable and const*/
+        testNumberConvert!("cast(const)3.14F");
+        testNumberConvert!("cast(immutable)3.14F");
+
+        /**The same tests for double and real*/
+        testNumberConvert!("double.min_normal");
+        testNumberConvert!("double.max");
+        testNumberConvert!("-0.17");
+        testNumberConvert!("3.14");
+        testNumberConvert!("cast(const)3.14");
+        testNumberConvert!("cast(immutable)3.14");
+
+        testNumberConvert!("real.min_normal");
+        testNumberConvert!("real.max");
+        testNumberConvert!("-0.17L");
+        testNumberConvert!("3.14L");
+        testNumberConvert!("cast(const)3.14L");
+        testNumberConvert!("cast(immutable)3.14L");
+
+        /**Test denormalized values*/
+
+        /**Max denormalized value, first bit is 1*/
+        testNumberConvert!("float.min_normal/2");
+        /**Min denormalized value, last bit is 1*/
+        testNumberConvert!("float.min_normal/2UL^^23");
+
+        /**Denormalized values with round*/
+        testNumberConvert!("float.min_normal/19");
+        testNumberConvert!("float.min_normal/17");
+
+        testNumberConvert!("double.min_normal/2");
+        testNumberConvert!("double.min_normal/2UL^^52");
+        testNumberConvert!("double.min_normal/19");
+        testNumberConvert!("double.min_normal/17");
+
+        testNumberConvert!("real.min_normal/2");
+        testNumberConvert!("real.min_normal/2UL^^63");
+        //testNumberConvert!("real.min_normal/19"); // XGDC: ct[0] == 0, rt[0] == 27
+        //testNumberConvert!("real.min_normal/17"); // XGDC: ct[0= == 128, rt[0] == 136
+
+        /**Test imaginary values: convert algorithm is same with real values*/
+        testNumberConvert!("0.0Fi");
+        testNumberConvert!("0.0i");
+        testNumberConvert!("0.0Li");
+
+        /**True random values*/
+        //testNumberConvert!("-0x9.0f7ee55df77618fp-13829L"); //XGDC: ct[0,1] == [0,96], rt[0,1] == [143,97]
+        //testNumberConvert!("0x7.36e6e2640120d28p+8797L"); // XGDC: ct[0,1] == [0,24], rt[0,1] == [80,26]
+        testNumberConvert!("-0x1.05df6ce4702ccf8p+15835L");
+        testNumberConvert!("0x9.54bb0d88806f714p-7088L");
+
+        testNumberConvert!("-0x9.0f7ee55df7ffp-338");
+        testNumberConvert!("0x7.36e6e264012dp+879");
+        testNumberConvert!("-0x1.05df6ce4708ep+658");
+        testNumberConvert!("0x9.54bb0d888061p-708");
+
+        testNumberConvert!("-0x9.0f7eefp-101F");
+        testNumberConvert!("0x7.36e6ep+87F");
+        testNumberConvert!("-0x1.05df6p+112F");
+        testNumberConvert!("0x9.54bb0p-70F");
+
+        /**Big overflow or underflow*/
+        testNumberConvert!("cast(double)-0x9.0f7ee55df77618fp-13829L");
+        testNumberConvert!("cast(double)0x7.36e6e2640120d28p+8797L");
+        testNumberConvert!("cast(double)-0x1.05df6ce4702ccf8p+15835L");
+        testNumberConvert!("cast(double)0x9.54bb0d88806f714p-7088L");
+
+        testNumberConvert!("cast(float)-0x9.0f7ee55df77618fp-13829L");
+        testNumberConvert!("cast(float)0x7.36e6e2640120d28p+8797L");
+        testNumberConvert!("cast(float)-0x1.05df6ce4702ccf8p+15835L");
+        testNumberConvert!("cast(float)0x9.54bb0d88806f714p-7088L");
+    }
+
+
+    unittest
+    {
+        testConvert();
+    }
+}
+
+
+
+private enum FloatFormat
+{
+    Float,
+    Double,
+    Real80,
+    DoubleDouble,
+    Quadruple
+}
+
+template floatFormat(T) if(is(T:real) || is(T:ireal))
+{
+    static if(T.mant_dig == 24)
+        enum floatFormat = FloatFormat.Float;
+    else static if(T.mant_dig == 53)
+        enum floatFormat = FloatFormat.Double;
+    else static if(T.mant_dig == 64)
+        enum floatFormat = FloatFormat.Real80;
+    else static if(T.mant_dig == 106)
+        enum floatFormat = FloatFormat.DoubleDouble;
+    else static if(T.mant_dig == 113)
+        enum floatFormat = FloatFormat.Quadruple;
+    else
+        static assert(0);
+
+}
+
+//  all toUbyte functions must be evaluable at compile time
+@trusted pure nothrow
+const(ubyte)[] toUbyte(T)(T[] arr) if (T.sizeof == 1)
+{
+    return cast(const(ubyte)[])arr;
+}
+
+@trusted pure nothrow
+const(ubyte)[] toUbyte(T)(T[] arr) if ((is(typeof(toUbyte(arr[0])) == const(ubyte)[])) && (T.sizeof > 1))
+{
+    if (__ctfe)
+    {
+        const(ubyte)[] ret;
+        foreach (cur; arr)
+        {
+            ret ~= toUbyte(cur);
+        }
+        return ret;
+    }
+    else
+    {
+        return (cast(const(ubyte)*)(arr.ptr))[0 .. T.sizeof*arr.length];
+    }
+}
+
+@trusted pure nothrow
+const(ubyte)[] toUbyte(T)(ref T val) if (__traits(isIntegral, T) && !is(T == enum))
+{
+    static if (T.sizeof == 1)
+    {
+        if (__ctfe)
+        {
+            return cast(const(ubyte)[])[val];
+        }
+        else
+        {
+            return (cast(const(ubyte)*)(&val))[0 .. T.sizeof];
+        }
+    }
+    else if (__ctfe)
+    {
+        ubyte[T.sizeof] tmp;
+        Unqual!T val_ = val;
+        for (size_t i = 0; i < T.sizeof; ++i)
+        {
+            size_t idx;
+            version(LittleEndian) idx = i;
+            else idx = T.sizeof-i-1;
+            tmp[idx] = cast(ubyte)(val_&0xff);
+            val_ >>= 8;
+        }
+        return tmp[].dup;
+    }
+    else
+    {
+        return (cast(const(ubyte)*)(&val))[0 .. T.sizeof];
+    }
+}
+
+@trusted pure nothrow
+const(ubyte)[] toUbyte(T)(ref T val) if (is(Unqual!T == cfloat) || is(Unqual!T == cdouble) ||is(Unqual!T == creal))
+{
+    if (__ctfe)
+    {
+        auto re = val.re;
+        auto im = val.im;
+        return (re.toUbyte() ~ im.toUbyte());
+    }
+    else
+    {
+        return (cast(const(ubyte)*)&val)[0 .. T.sizeof];
+    }
+}
+
+@trusted pure nothrow
+const(ubyte)[] toUbyte(T)(ref T val) if (is(T == enum) && is(typeof(toUbyte(cast(V)val)) == const(ubyte)[]))
+{
+    if (__ctfe)
+    {
+        static if (is(T V == enum)){}
+        V e_val = val;
+        return toUbyte(e_val);
+    }
+    else
+    {
+        return (cast(const(ubyte)*)&val)[0 .. T.sizeof];
+    }
+}
+
+private bool isNonReference(T)()
+{
+    static if (is(T == struct) || is(T == union))
+    {
+        return isNonReferenceStruct!T();
+    }
+    else static if (__traits(isStaticArray, T))
+    {
+      return isNonReference!(typeof(T.init[0]))();
+    }
+    else static if (is(T E == enum))
+    {
+      return isNonReference!(E)();
+    }
+    else static if (!__traits(isScalar, T))
+    {
+        return false;
+    }
+    else static if (is(T V : V*))
+    {
+        return false;
+    }
+    else static if (is(T == function))
+    {
+        return false;
+    }
+    else
+    {
+        return true;
+    }
+}
+
+private bool isNonReferenceStruct(T)() if (is(T == struct) || is(T == union))
+{
+    foreach (cur; T.init.tupleof)
+    {
+        static if (!isNonReference!(typeof(cur))()) return false;
+    }
+
+    return true;
+}
+
+@trusted pure nothrow
+const(ubyte)[] toUbyte(T)(ref T val) if (is(T == struct) || is(T == union))
+{
+    if (__ctfe)
+    {
+        ubyte[T.sizeof] bytes;
+        foreach (key, cur; val.tupleof)
+        {
+            alias CUR_TYPE = typeof(cur);
+            static if(isNonReference!(CUR_TYPE)())
+            {
+                bytes[val.tupleof[key].offsetof .. val.tupleof[key].offsetof + cur.sizeof] = toUbyte(cur)[];
+            }
+            else static if(is(typeof(val.tupleof[key] is null)))
+            {
+                assert(val.tupleof[key] is null, "Unable to compute byte representation of non-null reference field at compile time");
+                //skip, because val bytes are zeros
+            }
+            else
+            {
+                //pragma(msg, "is null: ", typeof(CUR_TYPE).stringof);
+                assert(0, "Unable to compute byte representation of "~typeof(CUR_TYPE).stringof~" field at compile time");
+            }
+        }
+        return bytes[].dup;
+    }
+    else
+    {
+        return (cast(const(ubyte)*)&val)[0 .. T.sizeof];
+    }
+}
diff --git a/libphobos/libdruntime/core/internal/hash.d b/libphobos/libdruntime/core/internal/hash.d
new file mode 100644
index 00000000000..f27f021354d
--- /dev/null
+++ b/libphobos/libdruntime/core/internal/hash.d
@@ -0,0 +1,508 @@
+/**
+ * Written in the D programming language.
+ * This module provides functions to uniform calculating hash values for different types
+ *
+ * Copyright: Copyright Igor Stepanov 2013-2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Igor Stepanov
+ * Source: $(DRUNTIMESRC core/internal/_hash.d)
+ */
+module core.internal.hash;
+
+import core.internal.convert;
+
+//enum hash. CTFE depends on base type
+size_t hashOf(T)(auto ref T val, size_t seed = 0) if (is(T == enum))
+{
+    static if (is(T EType == enum)) //for EType
+    {
+        EType e_val = cast(EType)val;
+        return hashOf(e_val, seed);
+    }
+    else
+    {
+        static assert(0);
+    }
+}
+
+//CTFE ready (depends on base type). Can be merged with dynamic array hash
+size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && __traits(isStaticArray, T))
+{
+    size_t cur_hash = seed;
+    foreach (ref cur; val)
+    {
+        cur_hash = hashOf(cur, cur_hash);
+    }
+    return cur_hash;
+}
+
+//dynamic array hash
+size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && !is(T : typeof(null)) && is(T S: S[]) && !__traits(isStaticArray, T))
+{
+    alias ElementType = typeof(val[0]);
+    static if (is(ElementType == interface) || is(ElementType == class) ||
+                   ((is(ElementType == struct) || is(ElementType == union))
+                       && is(typeof(val[0].toHash()) == size_t)))
+    //class or interface array or struct array with toHash(); CTFE depend on toHash() method
+    {
+        size_t hash = seed;
+        foreach (o; val)
+        {
+            hash = hashOf(o, hash);
+        }
+        return hash;
+    }
+    else static if (is(typeof(toUbyte(val)) == const(ubyte)[]))
+    //ubyteble array (arithmetic types and structs without toHash) CTFE ready for arithmetic types and structs without reference fields
+    {
+        auto bytes = toUbyte(val);
+        return bytesHash(bytes.ptr, bytes.length, seed);
+    }
+    else //Other types. CTFE unsupported
+    {
+        assert(!__ctfe, "unable to compute hash of "~T.stringof);
+        return bytesHash(val.ptr, ElementType.sizeof*val.length, seed);
+    }
+}
+
+//arithmetic type hash
+@trusted nothrow pure
+size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && __traits(isArithmetic, T))
+{
+    static if(__traits(isFloating, val))
+    {
+        T data = (val != val) ? T.nan : val;
+        auto bytes = toUbyte(data);
+        return bytesHash(bytes.ptr, bytes.length, seed);
+    }
+    else
+    {
+        auto bytes = toUbyte(val);
+        return bytesHash(bytes.ptr, bytes.length, seed);
+    }
+}
+
+//typeof(null) hash. CTFE supported
+@trusted nothrow pure
+size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && is(T : typeof(null)))
+{
+    return hashOf(cast(void*)null);
+}
+
+//Pointers hash. CTFE unsupported if not null
+@trusted nothrow pure
+size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && is(T V : V*) && !is(T : typeof(null)))
+{
+    if(__ctfe)
+    {
+        if(val is null)
+        {
+            return hashOf(cast(size_t)0);
+        }
+        else
+        {
+            assert(0, "Unable to calculate hash of non-null pointer at compile time");
+        }
+
+    }
+    return hashOf(cast(size_t)val);
+}
+
+//struct or union hash
+size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && (is(T == struct) || is(T == union)))
+{
+    static if (is(typeof(val.toHash()) == size_t)) //CTFE depends on toHash()
+    {
+        return hashOf(val.toHash(), seed);
+    }
+    else
+    {
+        static if(__traits(hasMember, T, "toHash") && is(typeof(T.toHash) == function))
+        {
+            pragma(msg, "Warning: struct "~__traits(identifier, T)~" has method toHash, however it cannot be called with "~T.stringof~" this.");
+        }
+
+        static if (is(typeof(toUbyte(val)) == const(ubyte)[]))//CTFE ready for structs without reference fields
+        {
+            auto bytes = toUbyte(val);
+            return bytesHash(bytes.ptr, bytes.length, seed);
+        }
+        else // CTFE unsupproreted for structs with reference fields
+        {
+            assert(!__ctfe, "unable to compute hash of "~T.stringof);
+            const(ubyte)[] bytes = (cast(const(ubyte)*)&val)[0 .. T.sizeof];
+            return bytesHash(bytes.ptr, bytes.length, seed);
+        }
+    }
+}
+
+//delegate hash. CTFE unsupported
+@trusted nothrow pure
+size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && is(T == delegate))
+{
+    assert(!__ctfe, "unable to compute hash of "~T.stringof);
+    const(ubyte)[] bytes = (cast(const(ubyte)*)&val)[0 .. T.sizeof];
+    return bytesHash(bytes.ptr, bytes.length, seed);
+}
+
+//class or interface hash. CTFE depends on toHash
+size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && is(T == interface) || is(T == class))
+{
+    return hashOf(val ? (cast(Object)val).toHash() : 0, seed);
+}
+
+//associative array hash. CTFE depends on base types
+size_t hashOf(T)(auto ref T aa, size_t seed = 0) if (!is(T == enum) && __traits(isAssociativeArray, T))
+{
+    if (!aa.length) return hashOf(0, seed);
+    size_t h = 0;
+
+    // The computed hash is independent of the foreach traversal order.
+    foreach (key, ref val; aa)
+    {
+        size_t[2] hpair;
+        hpair[0] = key.hashOf();
+        hpair[1] = val.hashOf();
+        h ^= hpair.hashOf();
+    }
+    return h.hashOf(seed);
+}
+
+unittest
+{
+    static struct Foo
+    {
+        int a = 99;
+        float b = 4.0;
+        size_t toHash() const pure @safe nothrow
+        {
+            return a;
+        }
+    }
+
+    static struct Bar
+    {
+        char c = 'x';
+        int a = 99;
+        float b = 4.0;
+        void* d = null;
+    }
+
+    static struct Boom
+    {
+        char c = 'M';
+        int* a = null;
+    }
+
+    interface IBoo
+    {
+        void boo();
+    }
+
+    static class Boo: IBoo
+    {
+        override void boo()
+        {
+        }
+
+        override size_t toHash()
+        {
+            return 1;
+        }
+    }
+
+    static struct Goo
+    {
+        size_t toHash() pure @safe nothrow
+        {
+            return 1;
+        }
+    }
+
+    enum Gun: long
+    {
+        A = 99,
+        B = 17
+    }
+
+    enum double dexpr = 3.14;
+    enum float fexpr = 2.71;
+    enum wstring wsexpr = "abcdef"w;
+    enum string csexpr = "abcdef";
+    enum int iexpr = 7;
+    enum long lexpr = 42;
+    enum int[2][3] saexpr = [[1, 2], [3, 4], [5, 6]];
+    enum int[] daexpr = [7,8,9];
+    enum Foo thsexpr = Foo();
+    enum Bar vsexpr = Bar();
+    enum int[int] aaexpr = [99:2, 12:6, 45:4];
+    enum Gun eexpr = Gun.A;
+    enum cdouble cexpr = 7+4i;
+    enum Foo[] staexpr = [Foo(), Foo(), Foo()];
+    enum Bar[] vsaexpr = [Bar(), Bar(), Bar()];
+    enum realexpr = 7.88;
+    enum raexpr = [8.99L+86i, 3.12L+99i, 5.66L+12i];
+    enum nullexpr = null;
+
+    //No CTFE:
+    Boom rstructexpr = Boom();
+    Boom[] rstrarrexpr = [Boom(), Boom(), Boom()];
+    int delegate() dgexpr  = (){return 78;};
+    void* ptrexpr = &dgexpr;
+
+
+    //CTFE hashes
+    enum h1 = dexpr.hashOf();
+    enum h2 = fexpr.hashOf();
+    enum h3 = wsexpr.hashOf();
+    enum h4 = csexpr.hashOf();
+    enum h5 = iexpr.hashOf();
+    enum h6 = lexpr.hashOf();
+    enum h7 = saexpr.hashOf();
+    enum h8 = daexpr.hashOf();
+    enum h9 = thsexpr.hashOf();
+    enum h10 = vsexpr.hashOf();
+    enum h11 = aaexpr.hashOf();
+    enum h12 = eexpr.hashOf();
+    enum h13 = cexpr.hashOf();
+    enum h14 = hashOf(new Boo);
+    enum h15 = staexpr.hashOf();
+    enum h16 = hashOf([new Boo, new Boo, new Boo]);
+    enum h17 = hashOf([cast(IBoo)new Boo, cast(IBoo)new Boo, cast(IBoo)new Boo]);
+    enum h18 = hashOf(cast(IBoo)new Boo);
+    enum h19 = vsaexpr.hashOf();
+    enum h20 = hashOf(cast(Foo[3])staexpr);
+
+    //BUG: cannot cast [Boo(), Boo(), Boo()][0] to object.Object at compile time
+    auto h21 = hashOf(cast(Boo[3])[new Boo, new Boo, new Boo]);
+    auto h22 = hashOf(cast(IBoo[3])[cast(IBoo)new Boo, cast(IBoo)new Boo, cast(IBoo)new Boo]);
+    enum h23 = hashOf(cast(Bar[3])vsaexpr);
+
+    //NO CTFE (Compute, but don't check correctness):
+    auto h24 = rstructexpr.hashOf();
+    auto h25 = rstrarrexpr.hashOf();
+    auto h26 = dgexpr.hashOf();
+    auto h27 = ptrexpr.hashOf();
+
+    enum h28 = realexpr.hashOf();
+    enum h29 = raexpr.hashOf();
+    enum h30 = nullexpr.hashOf();
+
+    auto v1 = dexpr;
+    auto v2 = fexpr;
+    auto v3 = wsexpr;
+    auto v4 = csexpr;
+    auto v5 = iexpr;
+    auto v6 = lexpr;
+    auto v7 = saexpr;
+    auto v8 = daexpr;
+    auto v9 = thsexpr;
+    auto v10 = vsexpr;
+    auto v11 = aaexpr;
+    auto v12 = eexpr;
+    auto v13 = cexpr;
+    auto v14 = new Boo;
+    auto v15 = staexpr;
+    auto v16 = [new Boo, new Boo, new Boo];
+    auto v17 = [cast(IBoo)new Boo, cast(IBoo)new Boo, cast(IBoo)new Boo];
+    auto v18 = cast(IBoo)new Boo;
+    auto v19 = vsaexpr;
+    auto v20 = cast(Foo[3])staexpr;
+    auto v21 = cast(Boo[3])[new Boo, new Boo, new Boo];
+    auto v22 = cast(IBoo[3])[cast(IBoo)new Boo, cast(IBoo)new Boo, cast(IBoo)new Boo];
+    auto v23 = cast(Bar[3])vsaexpr;
+    auto v30 = null;
+
+    //NO CTFE:
+    /*auto v24 = rstructexpr;
+    auto v25 = rstrarrexpr;
+    auto v26 = dgexpr;
+    auto v27 = ptrexpr;
+    auto v28 = realexpr;
+    auto v29 = raexpr;*/
+
+    //runtime hashes
+    auto rth1 = hashOf(v1);
+    auto rth2 = hashOf(v2);
+    auto rth3 = hashOf(v3);
+    auto rth4 = hashOf(v4);
+    auto rth5 = hashOf(v5);
+    auto rth6 = hashOf(v6);
+    auto rth7 = hashOf(v7);
+    auto rth8 = hashOf(v8);
+    auto rth9 = hashOf(v9);
+    auto rth10 = hashOf(v10);
+    auto rth11 = hashOf(v11);
+    auto rth12 = hashOf(v12);
+    auto rth13 = hashOf(v13);
+    auto rth14 = hashOf(v14);
+    auto rth15 = hashOf(v15);
+    auto rth16 = hashOf(v16);
+    auto rth17 = hashOf(v17);
+    auto rth18 = hashOf(v18);
+    auto rth19 = hashOf(v19);
+    auto rth20 = hashOf(v20);
+    auto rth21 = hashOf(v21);
+    auto rth22 = hashOf(v22);
+    auto rth23 = hashOf(v23);
+    auto rth30 = hashOf(v30);
+    /*//NO CTFE:
+    auto rth24 = hashOf(v24);
+    auto rth25 = hashOf(v25);
+    auto rth26 = hashOf(v26);
+    auto rth27 = hashOf(v27);
+    auto rth28 = hashOf(v28);
+    auto rth29 = hashOf(v29);*/
+
+    assert(h1 == rth1);
+    assert(h2 == rth2);
+    assert(h3 == rth3);
+    assert(h4 == rth4);
+    assert(h5 == rth5);
+    assert(h6 == rth6);
+    assert(h7 == rth7);
+    assert(h8 == rth8);
+    assert(h9 == rth9);
+    assert(h10 == rth10);
+    assert(h11 == rth11);
+    assert(h12 == rth12);
+    assert(h13 == rth13);
+    assert(h14 == rth14);
+    assert(h15 == rth15);
+    assert(h16 == rth16);
+    assert(h17 == rth17);
+    assert(h18 == rth18);
+    assert(h19 == rth19);
+    assert(h20 == rth20);
+    assert(h21 == rth21);
+    assert(h22 == rth22);
+    assert(h23 == rth23);
+    /*assert(h24 == rth24);
+    assert(h25 == rth25);
+    assert(h26 == rth26);
+    assert(h27 == rth27);
+    assert(h28 == rth28);
+    assert(h29 == rth29);*/
+    assert(h30 == rth30);
+}
+
+
+
+// MurmurHash3 was written by Austin Appleby, and is placed in the public
+// domain. The author hereby disclaims copyright to this source code.
+
+version(X86)
+    version = AnyX86;
+version(X86_64)
+    version = AnyX86;
+
+version(AnyX86)
+{
+    version(DigitalMars)
+    {
+    }
+    else
+    {
+        version = HasUnalignedOps;
+    }
+}
+
+@trusted pure nothrow
+size_t bytesHash(const(void)* buf, size_t len, size_t seed = 0)
+{
+    static uint rotl32(uint n)(in uint x) pure nothrow @safe
+    {
+        return (x << n) | (x >> (32 - n));
+    }
+
+    //-----------------------------------------------------------------------------
+    // Block read - if your platform needs to do endian-swapping or can only
+    // handle aligned reads, do the conversion here
+    static uint get32bits(const (ubyte)* x) pure nothrow
+    {
+        //Compiler can optimize this code to simple *cast(uint*)x if it possible.
+        version(HasUnalignedOps)
+        {
+            if (!__ctfe)
+                return *cast(uint*)x; //BUG: Can't be inlined by DMD
+        }
+        version(BigEndian)
+        {
+            return ((cast(uint) x[0]) << 24) | ((cast(uint) x[1]) << 16) | ((cast(uint) x[2]) << 8) | (cast(uint) x[3]);
+        }
+        else
+        {
+            return ((cast(uint) x[3]) << 24) | ((cast(uint) x[2]) << 16) | ((cast(uint) x[1]) << 8) | (cast(uint) x[0]);
+        }
+    }
+
+    //-----------------------------------------------------------------------------
+    // Finalization mix - force all bits of a hash block to avalanche
+    static uint fmix32(uint h) pure nothrow @safe
+    {
+        h ^= h >> 16;
+        h *= 0x85ebca6b;
+        h ^= h >> 13;
+        h *= 0xc2b2ae35;
+        h ^= h >> 16;
+
+        return h;
+    }
+
+    auto data = cast(const(ubyte)*)buf;
+    auto nblocks = len / 4;
+
+    uint h1 = cast(uint)seed;
+
+    enum uint c1 = 0xcc9e2d51;
+    enum uint c2 = 0x1b873593;
+    enum uint c3 = 0xe6546b64;
+
+    //----------
+    // body
+    auto end_data = data+nblocks*uint.sizeof;
+    for(; data!=end_data; data += uint.sizeof)
+    {
+        uint k1 = get32bits(data);
+        k1 *= c1;
+        k1 = rotl32!15(k1);
+        k1 *= c2;
+
+        h1 ^= k1;
+        h1 = rotl32!13(h1);
+        h1 = h1*5+c3;
+    }
+
+    //----------
+    // tail
+    uint k1 = 0;
+
+    switch(len & 3)
+    {
+        case 3: k1 ^= data[2] << 16; goto case;
+        case 2: k1 ^= data[1] << 8;  goto case;
+        case 1: k1 ^= data[0];
+                k1 *= c1; k1 = rotl32!15(k1); k1 *= c2; h1 ^= k1;
+                goto default;
+        default:
+    }
+
+    //----------
+    // finalization
+    h1 ^= len;
+    h1 = fmix32(h1);
+    return h1;
+}
+
+//  Check that bytesHash works with CTFE
+unittest
+{
+    size_t ctfeHash(string x)
+    {
+        return bytesHash(x.ptr, x.length);
+    }
+
+    enum test_str = "Sample string";
+    enum size_t hashVal = ctfeHash(test_str);
+    assert(hashVal == bytesHash(test_str.ptr, test_str.length));
+}
diff --git a/libphobos/libdruntime/core/internal/spinlock.d b/libphobos/libdruntime/core/internal/spinlock.d
new file mode 100644
index 00000000000..fb689dc561f
--- /dev/null
+++ b/libphobos/libdruntime/core/internal/spinlock.d
@@ -0,0 +1,103 @@
+/**
+ * SpinLock for runtime internal usage.
+ *
+ * Copyright: Copyright Digital Mars 2015 -.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ * Source: $(DRUNTIMESRC core/internal/_spinlock.d)
+ */
+module core.internal.spinlock;
+
+import core.atomic, core.thread;
+
+shared struct SpinLock
+{
+    /// for how long is the lock usually contended
+    enum Contention : ubyte
+    {
+        brief,
+        medium,
+        lengthy,
+    }
+
+@trusted @nogc nothrow:
+    this(Contention contention)
+    {
+        this.contention = contention;
+    }
+
+    void lock()
+    {
+        if (cas(&val, size_t(0), size_t(1)))
+            return;
+        // Try to reduce the chance of another cas failure
+        // TTAS lock (https://en.wikipedia.org/wiki/Test_and_test-and-set)
+        immutable step = 1 << contention;
+        while (true)
+        {
+            for (size_t n; atomicLoad!(MemoryOrder.raw)(val); n += step)
+                yield(n);
+            if (cas(&val, size_t(0), size_t(1)))
+                return;
+        }
+    }
+
+    void unlock()
+    {
+        atomicStore!(MemoryOrder.rel)(val, size_t(0));
+    }
+
+    /// yield with backoff
+    void yield(size_t k)
+    {
+        if (k < pauseThresh)
+            return pause();
+        else if (k < 32)
+            return Thread.yield();
+        Thread.sleep(1.msecs);
+    }
+
+private:
+    version (D_InlineAsm_X86)
+        enum X86 = true;
+    else version (D_InlineAsm_X86_64)
+        enum X86 = true;
+    else
+        enum X86 = false;
+
+    static if (X86)
+    {
+        enum pauseThresh = 16;
+        void pause()
+        {
+            asm @trusted @nogc nothrow
+            {
+                // pause instruction
+                rep;
+                nop;
+            }
+        }
+    }
+    else
+    {
+        enum pauseThresh = 4;
+        void pause()
+        {
+        }
+    }
+
+    size_t val;
+    Contention contention;
+}
+
+// aligned to cacheline to avoid false sharing
+shared align(64) struct AlignedSpinLock
+{
+    this(SpinLock.Contention contention)
+    {
+        impl = shared(SpinLock)(contention);
+    }
+
+    SpinLock impl;
+    alias impl this;
+}
diff --git a/libphobos/libdruntime/core/internal/string.d b/libphobos/libdruntime/core/internal/string.d
new file mode 100644
index 00000000000..cecec37fe37
--- /dev/null
+++ b/libphobos/libdruntime/core/internal/string.d
@@ -0,0 +1,207 @@
+/**
+ * String manipulation and comparison utilities.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Walter Bright
+ * Source: $(DRUNTIMESRC src/rt/util/_string.d)
+ */
+
+module core.internal.string;
+
+pure:
+nothrow:
+@nogc:
+
+alias UnsignedStringBuf = char[20];
+
+char[] unsignedToTempString(ulong value, char[] buf, uint radix = 10) @safe
+{
+    size_t i = buf.length;
+    do
+    {
+        ubyte x = cast(ubyte)(value % radix);
+        value = value / radix;
+        buf[--i] = cast(char)((x < 10) ? x + '0' : x - 10 + 'a');
+    } while (value);
+    return buf[i .. $];
+}
+
+private struct TempStringNoAlloc
+{
+    // need to handle 65 bytes for radix of 2 with negative sign.
+    private char[65] _buf;
+    private ubyte _len;
+    auto get() return
+    {
+        return _buf[$-_len..$];
+    }
+    alias get this;
+}
+
+auto unsignedToTempString(ulong value, uint radix) @safe
+{
+    TempStringNoAlloc result = void;
+    result._len = unsignedToTempString(value, result._buf, radix).length & 0xff;
+    return result;
+}
+
+unittest
+{
+    UnsignedStringBuf buf;
+    assert(0.unsignedToTempString(buf, 10) == "0");
+    assert(1.unsignedToTempString(buf, 10) == "1");
+    assert(12.unsignedToTempString(buf, 10) == "12");
+    assert(0x12ABCF .unsignedToTempString(buf, 16) == "12abcf");
+    assert(long.sizeof.unsignedToTempString(buf, 10) == "8");
+    assert(uint.max.unsignedToTempString(buf, 10) == "4294967295");
+    assert(ulong.max.unsignedToTempString(buf, 10) == "18446744073709551615");
+
+    // use stack allocated struct version
+    assert(0.unsignedToTempString(10) == "0");
+    assert(1.unsignedToTempString(10) == "1");
+    assert(12.unsignedToTempString(10) == "12");
+    assert(0x12ABCF .unsignedToTempString(16) == "12abcf");
+    assert(long.sizeof.unsignedToTempString(10) == "8");
+    assert(uint.max.unsignedToTempString(10) == "4294967295");
+    assert(ulong.max.unsignedToTempString(10) == "18446744073709551615");
+}
+
+alias SignedStringBuf = char[20];
+
+auto signedToTempString(long value, char[] buf, uint radix) @safe
+{
+    bool neg = value < 0;
+    if(neg)
+        value = cast(ulong)-value;
+    auto r = unsignedToTempString(value, buf, radix);
+    if(neg)
+    {
+        // about to do a slice without a bounds check
+        assert(r.ptr > buf.ptr);
+        r = (() @trusted => (r.ptr-1)[0..r.length+1])();
+        r[0] = '-';
+    }
+    return r;
+}
+
+auto signedToTempString(long value, uint radix) @safe
+{
+    bool neg = value < 0;
+    if(neg)
+        value = cast(ulong)-value;
+    auto r = unsignedToTempString(value, radix);
+    if(neg)
+    {
+        r._len++;
+        r.get()[0] = '-';
+    }
+    return r;
+}
+
+unittest
+{
+    SignedStringBuf buf;
+    assert(0.signedToTempString(buf, 10) == "0");
+    assert(1.signedToTempString(buf, 10) == "1");
+    assert((-1).signedToTempString(buf, 10) == "-1");
+    assert(12.signedToTempString(buf, 10) == "12");
+    assert((-12).signedToTempString(buf, 10) == "-12");
+    assert(0x12ABCF .signedToTempString(buf, 16) == "12abcf");
+    assert((-0x12ABCF) .signedToTempString(buf, 16) == "-12abcf");
+    assert(long.sizeof.signedToTempString(buf, 10) == "8");
+    assert(int.max.signedToTempString(buf, 10) == "2147483647");
+    assert(int.min.signedToTempString(buf, 10) == "-2147483648");
+    assert(long.max.signedToTempString(buf, 10) == "9223372036854775807");
+    assert(long.min.signedToTempString(buf, 10) == "-9223372036854775808");
+
+    // use stack allocated struct version
+    assert(0.signedToTempString(10) == "0");
+    assert(1.signedToTempString(10) == "1");
+    assert((-1).signedToTempString(10) == "-1");
+    assert(12.signedToTempString(10) == "12");
+    assert((-12).signedToTempString(10) == "-12");
+    assert(0x12ABCF .signedToTempString(16) == "12abcf");
+    assert((-0x12ABCF) .signedToTempString(16) == "-12abcf");
+    assert(long.sizeof.signedToTempString(10) == "8");
+    assert(int.max.signedToTempString(10) == "2147483647");
+    assert(int.min.signedToTempString(10) == "-2147483648");
+    assert(long.max.signedToTempString(10) == "9223372036854775807");
+    assert(long.min.signedToTempString(10) == "-9223372036854775808");
+    assert(long.max.signedToTempString(2) == "111111111111111111111111111111111111111111111111111111111111111");
+    assert(long.min.signedToTempString(2) == "-1000000000000000000000000000000000000000000000000000000000000000");
+}
+
+
+/********************************
+ * Determine number of digits that will result from a
+ * conversion of value to a string.
+ * Params:
+ *      value = number to convert
+ *      radix = radix
+ * Returns:
+ *      number of digits
+ */
+int numDigits(uint radix = 10)(ulong value) @safe
+{
+     int n = 1;
+     while (1)
+     {
+        if (value <= uint.max)
+        {
+            uint v = cast(uint)value;
+            while (1)
+            {
+                if (v < radix)
+                    return n;
+                if (v < radix * radix)
+                    return n + 1;
+                if (v < radix * radix * radix)
+                    return n + 2;
+                if (v < radix * radix * radix * radix)
+                    return n + 3;
+                n += 4;
+                v /= radix * radix * radix * radix;
+            }
+        }
+        n += 4;
+        value /= radix * radix * radix * radix;
+     }
+}
+
+unittest
+{
+    assert(0.numDigits == 1);
+    assert(9.numDigits == 1);
+    assert(10.numDigits == 2);
+    assert(99.numDigits == 2);
+    assert(100.numDigits == 3);
+    assert(999.numDigits == 3);
+    assert(1000.numDigits == 4);
+    assert(9999.numDigits == 4);
+    assert(10000.numDigits == 5);
+    assert(99999.numDigits == 5);
+    assert(uint.max.numDigits == 10);
+    assert(ulong.max.numDigits == 20);
+
+    assert(0.numDigits!2 == 1);
+    assert(1.numDigits!2 == 1);
+    assert(2.numDigits!2 == 2);
+    assert(3.numDigits!2 == 2);
+}
+
+int dstrcmp( in char[] s1, in char[] s2 ) @trusted
+{
+    import core.stdc.string : memcmp;
+
+    int  ret = 0;
+    auto len = s1.length;
+    if( s2.length < len )
+        len = s2.length;
+    if( 0 != (ret = memcmp( s1.ptr, s2.ptr, len )) )
+        return ret;
+    return s1.length >  s2.length ? 1 :
+           s1.length == s2.length ? 0 : -1;
+}
+
+
diff --git a/libphobos/libdruntime/core/internal/traits.d b/libphobos/libdruntime/core/internal/traits.d
new file mode 100644
index 00000000000..8142f90c512
--- /dev/null
+++ b/libphobos/libdruntime/core/internal/traits.d
@@ -0,0 +1,189 @@
+/**
+ * Contains traits for runtime internal usage.
+ *
+ * Copyright: Copyright Digital Mars 2014 -.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ * Source: $(DRUNTIMESRC core/internal/_traits.d)
+ */
+module core.internal.traits;
+
+/// taken from std.typetuple.TypeTuple
+template TypeTuple(TList...)
+{
+    alias TypeTuple = TList;
+}
+
+T trustedCast(T, U)(auto ref U u) @trusted pure nothrow
+{
+    return cast(T)u;
+}
+
+template Unconst(T)
+{
+         static if (is(T U ==   immutable U)) alias Unconst = U;
+    else static if (is(T U == inout const U)) alias Unconst = U;
+    else static if (is(T U == inout       U)) alias Unconst = U;
+    else static if (is(T U ==       const U)) alias Unconst = U;
+    else                                      alias Unconst = T;
+}
+
+/// taken from std.traits.Unqual
+template Unqual(T)
+{
+    version (none) // Error: recursive alias declaration @@@BUG1308@@@
+    {
+             static if (is(T U ==     const U)) alias Unqual = Unqual!U;
+        else static if (is(T U == immutable U)) alias Unqual = Unqual!U;
+        else static if (is(T U ==     inout U)) alias Unqual = Unqual!U;
+        else static if (is(T U ==    shared U)) alias Unqual = Unqual!U;
+        else                                    alias Unqual =        T;
+    }
+    else // workaround
+    {
+             static if (is(T U ==          immutable U)) alias Unqual = U;
+        else static if (is(T U == shared inout const U)) alias Unqual = U;
+        else static if (is(T U == shared inout       U)) alias Unqual = U;
+        else static if (is(T U == shared       const U)) alias Unqual = U;
+        else static if (is(T U == shared             U)) alias Unqual = U;
+        else static if (is(T U ==        inout const U)) alias Unqual = U;
+        else static if (is(T U ==        inout       U)) alias Unqual = U;
+        else static if (is(T U ==              const U)) alias Unqual = U;
+        else                                             alias Unqual = T;
+    }
+}
+
+// Substitute all `inout` qualifiers that appears in T to `const`
+template substInout(T)
+{
+    static if (is(T == immutable))
+    {
+        alias substInout = T;
+    }
+    else static if (is(T : shared const U, U) || is(T : const U, U))
+    {
+        // U is top-unqualified
+        mixin("alias substInout = "
+            ~ (is(T == shared) ? "shared " : "")
+            ~ (is(T == const) || is(T == inout) ? "const " : "")    // substitute inout to const
+            ~ "substInoutForm!U;");
+    }
+    else
+        static assert(0);
+}
+
+private template substInoutForm(T)
+{
+    static if (is(T == struct) || is(T == class) || is(T == union) || is(T == interface))
+    {
+        alias substInoutForm = T;   // prevent matching to the form of alias-this-ed type
+    }
+    else static if (is(T : V[K], K, V))        alias substInoutForm = substInout!V[substInout!K];
+    else static if (is(T : U[n], U, size_t n)) alias substInoutForm = substInout!U[n];
+    else static if (is(T : U[], U))            alias substInoutForm = substInout!U[];
+    else static if (is(T : U*, U))             alias substInoutForm = substInout!U*;
+    else                                       alias substInoutForm = T;
+}
+
+/// used to declare an extern(D) function that is defined in a different module
+template externDFunc(string fqn, T:FT*, FT) if(is(FT == function))
+{
+    static if (is(FT RT == return) && is(FT Args == function))
+    {
+        import core.demangle : mangleFunc;
+        enum decl = {
+            string s = "extern(D) RT externDFunc(Args)";
+            foreach (attr; __traits(getFunctionAttributes, FT))
+                s ~= " " ~ attr;
+            return s ~ ";";
+        }();
+        pragma(mangle, mangleFunc!T(fqn)) mixin(decl);
+    }
+    else
+        static assert(0);
+}
+
+template staticIota(int beg, int end)
+{
+    static if (beg + 1 >= end)
+    {
+        static if (beg >= end)
+        {
+            alias staticIota = TypeTuple!();
+        }
+        else
+        {
+            alias staticIota = TypeTuple!(+beg);
+        }
+    }
+    else
+    {
+        enum mid = beg + (end - beg) / 2;
+        alias staticIota = TypeTuple!(staticIota!(beg, mid), staticIota!(mid, end));
+    }
+}
+
+template dtorIsNothrow(T)
+{
+    enum dtorIsNothrow = is(typeof(function{T t=void;}) : void function() nothrow);
+}
+
+template anySatisfy(alias F, T...)
+{
+    static if (T.length == 0)
+    {
+        enum anySatisfy = false;
+    }
+    else static if (T.length == 1)
+    {
+        enum anySatisfy = F!(T[0]);
+    }
+    else
+    {
+        enum anySatisfy =
+            anySatisfy!(F, T[ 0  .. $/2]) ||
+            anySatisfy!(F, T[$/2 ..  $ ]);
+    }
+}
+
+// Somehow fails for non-static nested structs without support for aliases
+template hasElaborateDestructor(T...)
+{
+    static if (is(T[0]))
+        alias S = T[0];
+    else
+        alias S = typeof(T[0]);
+
+    static if (is(S : E[n], E, size_t n) && S.length)
+    {
+        enum bool hasElaborateDestructor = hasElaborateDestructor!E;
+    }
+    else static if (is(S == struct))
+    {
+        enum hasElaborateDestructor = __traits(hasMember, S, "__dtor")
+            || anySatisfy!(.hasElaborateDestructor, S.tupleof);
+    }
+    else
+        enum bool hasElaborateDestructor = false;
+}
+
+// Somehow fails for non-static nested structs without support for aliases
+template hasElaborateCopyConstructor(T...)
+{
+    static if (is(T[0]))
+        alias S = T[0];
+    else
+        alias S = typeof(T[0]);
+
+    static if (is(S : E[n], E, size_t n) && S.length)
+    {
+        enum bool hasElaborateCopyConstructor = hasElaborateCopyConstructor!E;
+    }
+    else static if (is(S == struct))
+    {
+        enum hasElaborateCopyConstructor = __traits(hasMember, S, "__postblit")
+            || anySatisfy!(.hasElaborateCopyConstructor, S.tupleof);
+    }
+    else
+        enum bool hasElaborateCopyConstructor = false;
+}
diff --git a/libphobos/libdruntime/core/math.d b/libphobos/libdruntime/core/math.d
new file mode 100644
index 00000000000..75f06cd9951
--- /dev/null
+++ b/libphobos/libdruntime/core/math.d
@@ -0,0 +1,160 @@
+﻿// Written in the D programming language.
+
+/**
+ * Builtin mathematical intrinsics
+ *
+ * Source: $(DRUNTIMESRC core/_math.d)
+ * Macros:
+ *      TABLE_SV = <table border="1" cellpadding="4" cellspacing="0">
+ *              <caption>Special Values</caption>
+ *              $0</table>
+ *
+ *      NAN = $(RED NAN)
+ *      SUP = <span style="vertical-align:super;font-size:smaller">$0</span>
+ *      POWER = $1<sup>$2</sup>
+ *      PLUSMN = &plusmn;
+ *      INFIN = &infin;
+ *      PLUSMNINF = &plusmn;&infin;
+ *      LT = &lt;
+ *      GT = &gt;
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2011.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   $(WEB digitalmars.com, Walter Bright),
+ *                        Don Clugston
+ */
+module core.math;
+
+public:
+@nogc:
+
+/***********************************
+ * Returns cosine of x. x is in radians.
+ *
+ *      $(TABLE_SV
+ *      $(TR $(TH x)                 $(TH cos(x)) $(TH invalid?))
+ *      $(TR $(TD $(NAN))            $(TD $(NAN)) $(TD yes)     )
+ *      $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(NAN)) $(TD yes)     )
+ *      )
+ * Bugs:
+ *      Results are undefined if |x| >= $(POWER 2,64).
+ */
+
+real cos(real x) @safe pure nothrow;       /* intrinsic */
+
+/***********************************
+ * Returns sine of x. x is in radians.
+ *
+ *      $(TABLE_SV
+ *      $(TR $(TH x)               $(TH sin(x))      $(TH invalid?))
+ *      $(TR $(TD $(NAN))          $(TD $(NAN))      $(TD yes))
+ *      $(TR $(TD $(PLUSMN)0.0)    $(TD $(PLUSMN)0.0) $(TD no))
+ *      $(TR $(TD $(PLUSMNINF))    $(TD $(NAN))      $(TD yes))
+ *      )
+ * Bugs:
+ *      Results are undefined if |x| >= $(POWER 2,64).
+ */
+
+real sin(real x) @safe pure nothrow;       /* intrinsic */
+
+/*****************************************
+ * Returns x rounded to a long value using the current rounding mode.
+ * If the integer value of x is
+ * greater than long.max, the result is
+ * indeterminate.
+ */
+long rndtol(real x) @safe pure nothrow;    /* intrinsic */
+
+
+/*****************************************
+ * Returns x rounded to a long value using the FE_TONEAREST rounding mode.
+ * If the integer value of x is
+ * greater than long.max, the result is
+ * indeterminate.
+ */
+extern (C) real rndtonl(real x);
+
+/***************************************
+ * Compute square root of x.
+ *
+ *      $(TABLE_SV
+ *      $(TR $(TH x)         $(TH sqrt(x))   $(TH invalid?))
+ *      $(TR $(TD -0.0)      $(TD -0.0)      $(TD no))
+ *      $(TR $(TD $(LT)0.0)  $(TD $(NAN))    $(TD yes))
+ *      $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD no))
+ *      )
+ */
+
+@safe pure nothrow
+{
+    float sqrt(float x);    /* intrinsic */
+    double sqrt(double x);  /* intrinsic */ /// ditto
+    real sqrt(real x);      /* intrinsic */ /// ditto
+}
+
+/*******************************************
+ * Compute n * 2$(SUPERSCRIPT exp)
+ * References: frexp
+ */
+
+real ldexp(real n, int exp) @safe pure nothrow;    /* intrinsic */
+
+unittest {
+    static if (real.mant_dig == 113)
+    {
+        assert(ldexp(1, -16384) == 0x1p-16384L);
+        assert(ldexp(1, -16382) == 0x1p-16382L);
+    }
+    else static if (real.mant_dig == 64)
+    {
+        assert(ldexp(1, -16384) == 0x1p-16384L);
+        assert(ldexp(1, -16382) == 0x1p-16382L);
+    }
+    else static if (real.mant_dig == 53)
+    {
+        assert(ldexp(1,  1023) == 0x1p1023L);
+        assert(ldexp(1, -1022) == 0x1p-1022L);
+        assert(ldexp(1, -1021) == 0x1p-1021L);
+    }
+    else
+        assert(false, "Only 128bit, 80bit and 64bit reals expected here");
+}
+
+/*******************************
+ * Returns |x|
+ *
+ *      $(TABLE_SV
+ *      $(TR $(TH x)                 $(TH fabs(x)))
+ *      $(TR $(TD $(PLUSMN)0.0)      $(TD +0.0) )
+ *      $(TR $(TD $(PLUSMN)$(INFIN)) $(TD +$(INFIN)) )
+ *      )
+ */
+real fabs(real x) @safe pure nothrow;      /* intrinsic */
+
+/**********************************
+ * Rounds x to the nearest integer value, using the current rounding
+ * mode.
+ * If the return value is not equal to x, the FE_INEXACT
+ * exception is raised.
+ * $(B nearbyint) performs
+ * the same operation, but does not set the FE_INEXACT exception.
+ */
+real rint(real x) @safe pure nothrow;      /* intrinsic */
+
+/***********************************
+ * Building block functions, they
+ * translate to a single x87 instruction.
+ */
+
+real yl2x(real x, real y)   @safe pure nothrow;       // y * log2(x)
+real yl2xp1(real x, real y) @safe pure nothrow;       // y * log2(x + 1)
+
+unittest
+{
+    version (INLINE_YL2X)
+    {
+        assert(yl2x(1024, 1) == 10);
+        assert(yl2xp1(1023, 1) == 10);
+    }
+}
+
diff --git a/libphobos/libdruntime/core/memory.d b/libphobos/libdruntime/core/memory.d
new file mode 100644
index 00000000000..22e2fe9b43e
--- /dev/null
+++ b/libphobos/libdruntime/core/memory.d
@@ -0,0 +1,791 @@
+/**
+ * This module provides an interface to the garbage collector used by
+ * applications written in the D programming language. It allows the
+ * garbage collector in the runtime to be swapped without affecting
+ * binary compatibility of applications.
+ *
+ * Using this module is not necessary in typical D code. It is mostly
+ * useful when doing low-level _memory management.
+ *
+ * Notes_to_users:
+ *
+   $(OL
+   $(LI The GC is a conservative mark-and-sweep collector. It only runs a
+        collection cycle when an allocation is requested of it, never
+        otherwise. Hence, if the program is not doing allocations,
+        there will be no GC collection pauses. The pauses occur because
+        all threads the GC knows about are halted so the threads' stacks
+        and registers can be scanned for references to GC allocated data.
+   )
+
+   $(LI The GC does not know about threads that were created by directly calling
+        the OS/C runtime thread creation APIs and D threads that were detached
+        from the D runtime after creation.
+        Such threads will not be paused for a GC collection, and the GC might not detect
+        references to GC allocated data held by them. This can cause memory corruption.
+        There are several ways to resolve this issue:
+        $(OL
+        $(LI Do not hold references to GC allocated data in such threads.)
+        $(LI Register/unregister such data with calls to $(LREF addRoot)/$(LREF removeRoot) and
+        $(LREF addRange)/$(LREF removeRange).)
+        $(LI Maintain another reference to that same data in another thread that the
+        GC does know about.)
+        $(LI Disable GC collection cycles while that thread is active with $(LREF disable)/$(LREF enable).)
+        $(LI Register the thread with the GC using $(CXREF thread, thread_attachThis)/$(CXREF thread, thread_detachThis).)
+        )
+   )
+   )
+ *
+ * Notes_to_implementors:
+ * $(UL
+ * $(LI On POSIX systems, the signals SIGUSR1 and SIGUSR2 are reserved
+ *   by this module for use in the garbage collector implementation.
+ *   Typically, they will be used to stop and resume other threads
+ *   when performing a collection, but an implementation may choose
+ *   not to use this mechanism (or not stop the world at all, in the
+ *   case of concurrent garbage collectors).)
+ *
+ * $(LI Registers, the stack, and any other _memory locations added through
+ *   the $(D GC.$(LREF addRange)) function are always scanned conservatively.
+ *   This means that even if a variable is e.g. of type $(D float),
+ *   it will still be scanned for possible GC pointers. And, if the
+ *   word-interpreted representation of the variable matches a GC-managed
+ *   _memory block's address, that _memory block is considered live.)
+ *
+ * $(LI Implementations are free to scan the non-root heap in a precise
+ *   manner, so that fields of types like $(D float) will not be considered
+ *   relevant when scanning the heap. Thus, casting a GC pointer to an
+ *   integral type (e.g. $(D size_t)) and storing it in a field of that
+ *   type inside the GC heap may mean that it will not be recognized
+ *   if the _memory block was allocated with precise type info or with
+ *   the $(D GC.BlkAttr.$(LREF NO_SCAN)) attribute.)
+ *
+ * $(LI Destructors will always be executed while other threads are
+ *   active; that is, an implementation that stops the world must not
+ *   execute destructors until the world has been resumed.)
+ *
+ * $(LI A destructor of an object must not access object references
+ *   within the object. This means that an implementation is free to
+ *   optimize based on this rule.)
+ *
+ * $(LI An implementation is free to perform heap compaction and copying
+ *   so long as no valid GC pointers are invalidated in the process.
+ *   However, _memory allocated with $(D GC.BlkAttr.$(LREF NO_MOVE)) must
+ *   not be moved/copied.)
+ *
+ * $(LI Implementations must support interior pointers. That is, if the
+ *   only reference to a GC-managed _memory block points into the
+ *   middle of the block rather than the beginning (for example), the
+ *   GC must consider the _memory block live. The exception to this
+ *   rule is when a _memory block is allocated with the
+ *   $(D GC.BlkAttr.$(LREF NO_INTERIOR)) attribute; it is the user's
+ *   responsibility to make sure such _memory blocks have a proper pointer
+ *   to them when they should be considered live.)
+ *
+ * $(LI It is acceptable for an implementation to store bit flags into
+ *   pointer values and GC-managed _memory blocks, so long as such a
+ *   trick is not visible to the application. In practice, this means
+ *   that only a stop-the-world collector can do this.)
+ *
+ * $(LI Implementations are free to assume that GC pointers are only
+ *   stored on word boundaries. Unaligned pointers may be ignored
+ *   entirely.)
+ *
+ * $(LI Implementations are free to run collections at any point. It is,
+ *   however, recommendable to only do so when an allocation attempt
+ *   happens and there is insufficient _memory available.)
+ * )
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2015.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Source:    $(DRUNTIMESRC core/_memory.d)
+ */
+
+module core.memory;
+
+
+private
+{
+    extern (C) void gc_init();
+    extern (C) void gc_term();
+
+    extern (C) void gc_enable() nothrow;
+    extern (C) void gc_disable() nothrow;
+    extern (C) void gc_collect() nothrow;
+    extern (C) void gc_minimize() nothrow;
+
+    extern (C) uint gc_getAttr( void* p ) pure nothrow;
+    extern (C) uint gc_setAttr( void* p, uint a ) pure nothrow;
+    extern (C) uint gc_clrAttr( void* p, uint a ) pure nothrow;
+
+    extern (C) void*    gc_malloc( size_t sz, uint ba = 0, const TypeInfo = null ) pure nothrow;
+    extern (C) void*    gc_calloc( size_t sz, uint ba = 0, const TypeInfo = null ) pure nothrow;
+    extern (C) BlkInfo_ gc_qalloc( size_t sz, uint ba = 0, const TypeInfo = null ) pure nothrow;
+    extern (C) void*    gc_realloc( void* p, size_t sz, uint ba = 0, const TypeInfo = null ) pure nothrow;
+    extern (C) size_t   gc_extend( void* p, size_t mx, size_t sz, const TypeInfo = null ) pure nothrow;
+    extern (C) size_t   gc_reserve( size_t sz ) nothrow;
+    extern (C) void     gc_free( void* p ) pure nothrow;
+
+    extern (C) void*   gc_addrOf( void* p ) pure nothrow;
+    extern (C) size_t  gc_sizeOf( void* p ) pure nothrow;
+
+    struct BlkInfo_
+    {
+        void*  base;
+        size_t size;
+        uint   attr;
+    }
+
+    extern (C) BlkInfo_ gc_query( void* p ) pure nothrow;
+
+    extern (C) void gc_addRoot( in void* p ) nothrow;
+    extern (C) void gc_addRange( in void* p, size_t sz, const TypeInfo ti = null ) nothrow @nogc;
+
+    extern (C) void gc_removeRoot( in void* p ) nothrow;
+    extern (C) void gc_removeRange( in void* p ) nothrow @nogc;
+    extern (C) void gc_runFinalizers( in void[] segment );
+
+    package extern (C) bool gc_inFinalizer();
+}
+
+
+/**
+ * This struct encapsulates all garbage collection functionality for the D
+ * programming language.
+ */
+struct GC
+{
+    @disable this();
+
+    /**
+     * Enables automatic garbage collection behavior if collections have
+     * previously been suspended by a call to disable.  This function is
+     * reentrant, and must be called once for every call to disable before
+     * automatic collections are enabled.
+     */
+    static void enable() nothrow /* FIXME pure */
+    {
+        gc_enable();
+    }
+
+
+    /**
+     * Disables automatic garbage collections performed to minimize the
+     * process footprint.  Collections may continue to occur in instances
+     * where the implementation deems necessary for correct program behavior,
+     * such as during an out of memory condition.  This function is reentrant,
+     * but enable must be called once for each call to disable.
+     */
+    static void disable() nothrow /* FIXME pure */
+    {
+        gc_disable();
+    }
+
+
+    /**
+     * Begins a full collection.  While the meaning of this may change based
+     * on the garbage collector implementation, typical behavior is to scan
+     * all stack segments for roots, mark accessible memory blocks as alive,
+     * and then to reclaim free space.  This action may need to suspend all
+     * running threads for at least part of the collection process.
+     */
+    static void collect() nothrow /* FIXME pure */
+    {
+        gc_collect();
+    }
+
+    /**
+     * Indicates that the managed memory space be minimized by returning free
+     * physical memory to the operating system.  The amount of free memory
+     * returned depends on the allocator design and on program behavior.
+     */
+    static void minimize() nothrow /* FIXME pure */
+    {
+        gc_minimize();
+    }
+
+
+    /**
+     * Elements for a bit field representing memory block attributes.  These
+     * are manipulated via the getAttr, setAttr, clrAttr functions.
+     */
+    enum BlkAttr : uint
+    {
+        NONE        = 0b0000_0000, /// No attributes set.
+        FINALIZE    = 0b0000_0001, /// Finalize the data in this block on collect.
+        NO_SCAN     = 0b0000_0010, /// Do not scan through this block on collect.
+        NO_MOVE     = 0b0000_0100, /// Do not move this memory block on collect.
+        /**
+        This block contains the info to allow appending.
+
+        This can be used to manually allocate arrays. Initial slice size is 0.
+
+        Note: The slice's useable size will not match the block size. Use
+        $(LREF capacity) to retrieve actual useable capacity.
+
+        Example:
+        ----
+        // Allocate the underlying array.
+        int*  pToArray = cast(int*)GC.malloc(10 * int.sizeof, GC.BlkAttr.NO_SCAN | GC.BlkAttr.APPENDABLE);
+        // Bind a slice. Check the slice has capacity information.
+        int[] slice = pToArray[0 .. 0];
+        assert(capacity(slice) > 0);
+        // Appending to the slice will not relocate it.
+        slice.length = 5;
+        slice ~= 1;
+        assert(slice.ptr == p);
+        ----
+        */
+        APPENDABLE  = 0b0000_1000,
+
+        /**
+        This block is guaranteed to have a pointer to its base while it is
+        alive.  Interior pointers can be safely ignored.  This attribute is
+        useful for eliminating false pointers in very large data structures
+        and is only implemented for data structures at least a page in size.
+        */
+        NO_INTERIOR = 0b0001_0000,
+
+        STRUCTFINAL = 0b0010_0000, // the block has a finalizer for (an array of) structs
+    }
+
+
+    /**
+     * Contains aggregate information about a block of managed memory.  The
+     * purpose of this struct is to support a more efficient query style in
+     * instances where detailed information is needed.
+     *
+     * base = A pointer to the base of the block in question.
+     * size = The size of the block, calculated from base.
+     * attr = Attribute bits set on the memory block.
+     */
+    alias BlkInfo_ BlkInfo;
+
+
+    /**
+     * Returns a bit field representing all block attributes set for the memory
+     * referenced by p.  If p references memory not originally allocated by
+     * this garbage collector, points to the interior of a memory block, or if
+     * p is null, zero will be returned.
+     *
+     * Params:
+     *  p = A pointer to the root of a valid memory block or to null.
+     *
+     * Returns:
+     *  A bit field containing any bits set for the memory block referenced by
+     *  p or zero on error.
+     */
+    static uint getAttr( in void* p ) nothrow
+    {
+        return getAttr(cast()p);
+    }
+
+
+    /// ditto
+    static uint getAttr(void* p) pure nothrow
+    {
+        return gc_getAttr( p );
+    }
+
+
+    /**
+     * Sets the specified bits for the memory references by p.  If p references
+     * memory not originally allocated by this garbage collector, points to the
+     * interior of a memory block, or if p is null, no action will be
+     * performed.
+     *
+     * Params:
+     *  p = A pointer to the root of a valid memory block or to null.
+     *  a = A bit field containing any bits to set for this memory block.
+     *
+     * Returns:
+     *  The result of a call to getAttr after the specified bits have been
+     *  set.
+     */
+    static uint setAttr( in void* p, uint a ) nothrow
+    {
+        return setAttr(cast()p, a);
+    }
+
+
+    /// ditto
+    static uint setAttr(void* p, uint a) pure nothrow
+    {
+        return gc_setAttr( p, a );
+    }
+
+
+    /**
+     * Clears the specified bits for the memory references by p.  If p
+     * references memory not originally allocated by this garbage collector,
+     * points to the interior of a memory block, or if p is null, no action
+     * will be performed.
+     *
+     * Params:
+     *  p = A pointer to the root of a valid memory block or to null.
+     *  a = A bit field containing any bits to clear for this memory block.
+     *
+     * Returns:
+     *  The result of a call to getAttr after the specified bits have been
+     *  cleared.
+     */
+    static uint clrAttr( in void* p, uint a ) nothrow
+    {
+        return clrAttr(cast()p, a);
+    }
+
+
+    /// ditto
+    static uint clrAttr(void* p, uint a) pure nothrow
+    {
+        return gc_clrAttr( p, a );
+    }
+
+
+    /**
+     * Requests an aligned block of managed memory from the garbage collector.
+     * This memory may be deleted at will with a call to free, or it may be
+     * discarded and cleaned up automatically during a collection run.  If
+     * allocation fails, this function will call onOutOfMemory which is
+     * expected to throw an OutOfMemoryError.
+     *
+     * Params:
+     *  sz = The desired allocation size in bytes.
+     *  ba = A bitmask of the attributes to set on this block.
+     *  ti = TypeInfo to describe the memory. The GC might use this information
+     *       to improve scanning for pointers or to call finalizers.
+     *
+     * Returns:
+     *  A reference to the allocated memory or null if insufficient memory
+     *  is available.
+     *
+     * Throws:
+     *  OutOfMemoryError on allocation failure.
+     */
+    static void* malloc( size_t sz, uint ba = 0, const TypeInfo ti = null ) pure nothrow
+    {
+        return gc_malloc( sz, ba, ti );
+    }
+
+
+    /**
+     * Requests an aligned block of managed memory from the garbage collector.
+     * This memory may be deleted at will with a call to free, or it may be
+     * discarded and cleaned up automatically during a collection run.  If
+     * allocation fails, this function will call onOutOfMemory which is
+     * expected to throw an OutOfMemoryError.
+     *
+     * Params:
+     *  sz = The desired allocation size in bytes.
+     *  ba = A bitmask of the attributes to set on this block.
+     *  ti = TypeInfo to describe the memory. The GC might use this information
+     *       to improve scanning for pointers or to call finalizers.
+     *
+     * Returns:
+     *  Information regarding the allocated memory block or BlkInfo.init on
+     *  error.
+     *
+     * Throws:
+     *  OutOfMemoryError on allocation failure.
+     */
+    static BlkInfo qalloc( size_t sz, uint ba = 0, const TypeInfo ti = null ) pure nothrow
+    {
+        return gc_qalloc( sz, ba, ti );
+    }
+
+
+    /**
+     * Requests an aligned block of managed memory from the garbage collector,
+     * which is initialized with all bits set to zero.  This memory may be
+     * deleted at will with a call to free, or it may be discarded and cleaned
+     * up automatically during a collection run.  If allocation fails, this
+     * function will call onOutOfMemory which is expected to throw an
+     * OutOfMemoryError.
+     *
+     * Params:
+     *  sz = The desired allocation size in bytes.
+     *  ba = A bitmask of the attributes to set on this block.
+     *  ti = TypeInfo to describe the memory. The GC might use this information
+     *       to improve scanning for pointers or to call finalizers.
+     *
+     * Returns:
+     *  A reference to the allocated memory or null if insufficient memory
+     *  is available.
+     *
+     * Throws:
+     *  OutOfMemoryError on allocation failure.
+     */
+    static void* calloc( size_t sz, uint ba = 0, const TypeInfo ti = null ) pure nothrow
+    {
+        return gc_calloc( sz, ba, ti );
+    }
+
+
+    /**
+     * If sz is zero, the memory referenced by p will be deallocated as if
+     * by a call to free.  A new memory block of size sz will then be
+     * allocated as if by a call to malloc, or the implementation may instead
+     * resize the memory block in place.  The contents of the new memory block
+     * will be the same as the contents of the old memory block, up to the
+     * lesser of the new and old sizes.  Note that existing memory will only
+     * be freed by realloc if sz is equal to zero.  The garbage collector is
+     * otherwise expected to later reclaim the memory block if it is unused.
+     * If allocation fails, this function will call onOutOfMemory which is
+     * expected to throw an OutOfMemoryError.  If p references memory not
+     * originally allocated by this garbage collector, or if it points to the
+     * interior of a memory block, no action will be taken.  If ba is zero
+     * (the default) and p references the head of a valid, known memory block
+     * then any bits set on the current block will be set on the new block if a
+     * reallocation is required.  If ba is not zero and p references the head
+     * of a valid, known memory block then the bits in ba will replace those on
+     * the current memory block and will also be set on the new block if a
+     * reallocation is required.
+     *
+     * Params:
+     *  p  = A pointer to the root of a valid memory block or to null.
+     *  sz = The desired allocation size in bytes.
+     *  ba = A bitmask of the attributes to set on this block.
+     *  ti = TypeInfo to describe the memory. The GC might use this information
+     *       to improve scanning for pointers or to call finalizers.
+     *
+     * Returns:
+     *  A reference to the allocated memory on success or null if sz is
+     *  zero.  On failure, the original value of p is returned.
+     *
+     * Throws:
+     *  OutOfMemoryError on allocation failure.
+     */
+    static void* realloc( void* p, size_t sz, uint ba = 0, const TypeInfo ti = null ) pure nothrow
+    {
+        return gc_realloc( p, sz, ba, ti );
+    }
+
+    /// Issue 13111
+    unittest
+    {
+        enum size1 = 1 << 11 + 1; // page in large object pool
+        enum size2 = 1 << 22 + 1; // larger than large object pool size
+
+        auto data1 = cast(ubyte*)GC.calloc(size1);
+        auto data2 = cast(ubyte*)GC.realloc(data1, size2);
+
+        BlkInfo info = query(data2);
+        assert(info.size >= size2);
+    }
+
+
+    /**
+     * Requests that the managed memory block referenced by p be extended in
+     * place by at least mx bytes, with a desired extension of sz bytes.  If an
+     * extension of the required size is not possible or if p references memory
+     * not originally allocated by this garbage collector, no action will be
+     * taken.
+     *
+     * Params:
+     *  p  = A pointer to the root of a valid memory block or to null.
+     *  mx = The minimum extension size in bytes.
+     *  sz = The desired extension size in bytes.
+     *  ti = TypeInfo to describe the full memory block. The GC might use
+     *       this information to improve scanning for pointers or to
+     *       call finalizers.
+     *
+     * Returns:
+     *  The size in bytes of the extended memory block referenced by p or zero
+     *  if no extension occurred.
+     *
+     * Note:
+     *  Extend may also be used to extend slices (or memory blocks with
+     *  $(LREF APPENDABLE) info). However, use the return value only
+     *  as an indicator of success. $(LREF capacity) should be used to
+     *  retrieve actual useable slice capacity.
+     */
+    static size_t extend( void* p, size_t mx, size_t sz, const TypeInfo ti = null ) pure nothrow
+    {
+        return gc_extend( p, mx, sz, ti );
+    }
+    /// Standard extending
+    unittest
+    {
+        size_t size = 1000;
+        int* p = cast(int*)GC.malloc(size * int.sizeof, GC.BlkAttr.NO_SCAN);
+
+        //Try to extend the allocated data by 1000 elements, preferred 2000.
+        size_t u = GC.extend(p, 1000 * int.sizeof, 2000 * int.sizeof);
+        if (u != 0)
+            size = u / int.sizeof;
+    }
+    /// slice extending
+    unittest
+    {
+        int[] slice = new int[](1000);
+        int*  p     = slice.ptr;
+
+        //Check we have access to capacity before attempting the extend
+        if (slice.capacity)
+        {
+            //Try to extend slice by 1000 elements, preferred 2000.
+            size_t u = GC.extend(p, 1000 * int.sizeof, 2000 * int.sizeof);
+            if (u != 0)
+            {
+                slice.length = slice.capacity;
+                assert(slice.length >= 2000);
+            }
+        }
+    }
+
+
+    /**
+     * Requests that at least sz bytes of memory be obtained from the operating
+     * system and marked as free.
+     *
+     * Params:
+     *  sz = The desired size in bytes.
+     *
+     * Returns:
+     *  The actual number of bytes reserved or zero on error.
+     */
+    static size_t reserve( size_t sz ) nothrow /* FIXME pure */
+    {
+        return gc_reserve( sz );
+    }
+
+
+    /**
+     * Deallocates the memory referenced by p.  If p is null, no action occurs.
+     * If p references memory not originally allocated by this garbage
+     * collector, if p points to the interior of a memory block, or if this
+     * method is called from a finalizer, no action will be taken.  The block
+     * will not be finalized regardless of whether the FINALIZE attribute is
+     * set.  If finalization is desired, use delete instead.
+     *
+     * Params:
+     *  p = A pointer to the root of a valid memory block or to null.
+     */
+    static void free( void* p ) pure nothrow
+    {
+        gc_free( p );
+    }
+
+
+    /**
+     * Returns the base address of the memory block containing p.  This value
+     * is useful to determine whether p is an interior pointer, and the result
+     * may be passed to routines such as sizeOf which may otherwise fail.  If p
+     * references memory not originally allocated by this garbage collector, if
+     * p is null, or if the garbage collector does not support this operation,
+     * null will be returned.
+     *
+     * Params:
+     *  p = A pointer to the root or the interior of a valid memory block or to
+     *      null.
+     *
+     * Returns:
+     *  The base address of the memory block referenced by p or null on error.
+     */
+    static inout(void)* addrOf( inout(void)* p ) nothrow /* FIXME pure */
+    {
+        return cast(inout(void)*)gc_addrOf(cast(void*)p);
+    }
+
+
+    /// ditto
+    static void* addrOf(void* p) pure nothrow
+    {
+        return gc_addrOf(p);
+    }
+
+
+    /**
+     * Returns the true size of the memory block referenced by p.  This value
+     * represents the maximum number of bytes for which a call to realloc may
+     * resize the existing block in place.  If p references memory not
+     * originally allocated by this garbage collector, points to the interior
+     * of a memory block, or if p is null, zero will be returned.
+     *
+     * Params:
+     *  p = A pointer to the root of a valid memory block or to null.
+     *
+     * Returns:
+     *  The size in bytes of the memory block referenced by p or zero on error.
+     */
+    static size_t sizeOf( in void* p ) nothrow
+    {
+        return gc_sizeOf(cast(void*)p);
+    }
+
+
+    /// ditto
+    static size_t sizeOf(void* p) pure nothrow
+    {
+        return gc_sizeOf( p );
+    }
+
+    // verify that the reallocation doesn't leave the size cache in a wrong state
+    unittest
+    {
+        auto data = cast(int*)realloc(null, 4096);
+        size_t size = GC.sizeOf(data);
+        assert(size >= 4096);
+        data = cast(int*)GC.realloc(data, 4100);
+        size = GC.sizeOf(data);
+        assert(size >= 4100);
+    }
+
+    /**
+     * Returns aggregate information about the memory block containing p.  If p
+     * references memory not originally allocated by this garbage collector, if
+     * p is null, or if the garbage collector does not support this operation,
+     * BlkInfo.init will be returned.  Typically, support for this operation
+     * is dependent on support for addrOf.
+     *
+     * Params:
+     *  p = A pointer to the root or the interior of a valid memory block or to
+     *      null.
+     *
+     * Returns:
+     *  Information regarding the memory block referenced by p or BlkInfo.init
+     *  on error.
+     */
+    static BlkInfo query( in void* p ) nothrow
+    {
+        return gc_query(cast(void*)p);
+    }
+
+
+    /// ditto
+    static BlkInfo query(void* p) pure nothrow
+    {
+        return gc_query( p );
+    }
+
+
+    /**
+     * Adds an internal root pointing to the GC memory block referenced by p.
+     * As a result, the block referenced by p itself and any blocks accessible
+     * via it will be considered live until the root is removed again.
+     *
+     * If p is null, no operation is performed.
+     *
+     * Params:
+     *  p = A pointer into a GC-managed memory block or null.
+     *
+     * Example:
+     * ---
+     * // Typical C-style callback mechanism; the passed function
+     * // is invoked with the user-supplied context pointer at a
+     * // later point.
+     * extern(C) void addCallback(void function(void*), void*);
+     *
+     * // Allocate an object on the GC heap (this would usually be
+     * // some application-specific context data).
+     * auto context = new Object;
+     *
+     * // Make sure that it is not collected even if it is no
+     * // longer referenced from D code (stack, GC heap, …).
+     * GC.addRoot(cast(void*)context);
+     *
+     * // Also ensure that a moving collector does not relocate
+     * // the object.
+     * GC.setAttr(cast(void*)context, GC.BlkAttr.NO_MOVE);
+     *
+     * // Now context can be safely passed to the C library.
+     * addCallback(&myHandler, cast(void*)context);
+     *
+     * extern(C) void myHandler(void* ctx)
+     * {
+     *     // Assuming that the callback is invoked only once, the
+     *     // added root can be removed again now to allow the GC
+     *     // to collect it later.
+     *     GC.removeRoot(ctx);
+     *     GC.clrAttr(ctx, GC.BlkAttr.NO_MOVE);
+     *
+     *     auto context = cast(Object)ctx;
+     *     // Use context here…
+     * }
+     * ---
+     */
+    static void addRoot( in void* p ) nothrow /* FIXME pure */
+    {
+        gc_addRoot( p );
+    }
+
+
+    /**
+     * Removes the memory block referenced by p from an internal list of roots
+     * to be scanned during a collection.  If p is null or is not a value
+     * previously passed to addRoot() then no operation is performed.
+     *
+     * Params:
+     *  p = A pointer into a GC-managed memory block or null.
+     */
+    static void removeRoot( in void* p ) nothrow /* FIXME pure */
+    {
+        gc_removeRoot( p );
+    }
+
+
+    /**
+     * Adds $(D p[0 .. sz]) to the list of memory ranges to be scanned for
+     * pointers during a collection. If p is null, no operation is performed.
+     *
+     * Note that $(D p[0 .. sz]) is treated as an opaque range of memory assumed
+     * to be suitably managed by the caller. In particular, if p points into a
+     * GC-managed memory block, addRange does $(I not) mark this block as live.
+     *
+     * Params:
+     *  p  = A pointer to a valid memory address or to null.
+     *  sz = The size in bytes of the block to add. If sz is zero then the
+     *       no operation will occur. If p is null then sz must be zero.
+     *  ti = TypeInfo to describe the memory. The GC might use this information
+     *       to improve scanning for pointers or to call finalizers
+     *
+     * Example:
+     * ---
+     * // Allocate a piece of memory on the C heap.
+     * enum size = 1_000;
+     * auto rawMemory = core.stdc.stdlib.malloc(size);
+     *
+     * // Add it as a GC range.
+     * GC.addRange(rawMemory, size);
+     *
+     * // Now, pointers to GC-managed memory stored in
+     * // rawMemory will be recognized on collection.
+     * ---
+     */
+    static void addRange( in void* p, size_t sz, const TypeInfo ti = null ) @nogc nothrow /* FIXME pure */
+    {
+        gc_addRange( p, sz, ti );
+    }
+
+
+    /**
+     * Removes the memory range starting at p from an internal list of ranges
+     * to be scanned during a collection. If p is null or does not represent
+     * a value previously passed to addRange() then no operation is
+     * performed.
+     *
+     * Params:
+     *  p  = A pointer to a valid memory address or to null.
+     */
+    static void removeRange( in void* p ) nothrow @nogc /* FIXME pure */
+    {
+        gc_removeRange( p );
+    }
+
+
+    /**
+     * Runs any finalizer that is located in address range of the
+     * given code segment.  This is used before unloading shared
+     * libraries.  All matching objects which have a finalizer in this
+     * code segment are assumed to be dead, using them while or after
+     * calling this method has undefined behavior.
+     *
+     * Params:
+     *  segment = address range of a code segment.
+     */
+    static void runFinalizers( in void[] segment )
+    {
+        gc_runFinalizers( segment );
+    }
+}
diff --git a/libphobos/libdruntime/core/runtime.d b/libphobos/libdruntime/core/runtime.d
new file mode 100644
index 00000000000..bd2b70c9319
--- /dev/null
+++ b/libphobos/libdruntime/core/runtime.d
@@ -0,0 +1,843 @@
+/**
+ * The runtime module exposes information specific to the D runtime code.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/_runtime.d)
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module core.runtime;
+
+version (Windows) import core.stdc.wchar_ : wchar_t;
+
+
+/// C interface for Runtime.loadLibrary
+extern (C) void* rt_loadLibrary(const char* name);
+/// ditto
+version (Windows) extern (C) void* rt_loadLibraryW(const wchar_t* name);
+/// C interface for Runtime.unloadLibrary, returns 1/0 instead of bool
+extern (C) int rt_unloadLibrary(void* ptr);
+
+/// C interface for Runtime.initialize, returns 1/0 instead of bool
+extern(C) int rt_init();
+/// C interface for Runtime.terminate, returns 1/0 instead of bool
+extern(C) int rt_term();
+
+private
+{
+    alias bool function() ModuleUnitTester;
+    alias bool function(Object) CollectHandler;
+    alias Throwable.TraceInfo function( void* ptr ) TraceHandler;
+
+    extern (C) void rt_setCollectHandler( CollectHandler h );
+    extern (C) CollectHandler rt_getCollectHandler();
+
+    extern (C) void rt_setTraceHandler( TraceHandler h );
+    extern (C) TraceHandler rt_getTraceHandler();
+
+    alias void delegate( Throwable ) ExceptionHandler;
+    extern (C) void _d_print_throwable(Throwable t);
+
+    extern (C) void* thread_stackBottom();
+
+    extern (C) string[] rt_args();
+    extern (C) CArgs rt_cArgs() @nogc;
+}
+
+
+static this()
+{
+    // NOTE: Some module ctors will run before this handler is set, so it's
+    //       still possible the app could exit without a stack trace.  If
+    //       this becomes an issue, the handler could be set in C main
+    //       before the module ctors are run.
+    Runtime.traceHandler = &defaultTraceHandler;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Runtime
+///////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Stores the unprocessed arguments supplied when the
+ * process was started.
+ */
+struct CArgs
+{
+    int argc; /// The argument count.
+    char** argv; /// The arguments as a C array of strings.
+}
+
+/**
+ * This struct encapsulates all functionality related to the underlying runtime
+ * module for the calling context.
+ */
+struct Runtime
+{
+    /**
+     * Initializes the runtime.  This call is to be used in instances where the
+     * standard program initialization process is not executed.  This is most
+     * often in shared libraries or in libraries linked to a C program.
+     * If the runtime was already successfully initialized this returns true.
+     * Each call to initialize must be paired by a call to $(LREF terminate).
+     *
+     * Returns:
+     *  true if initialization succeeded or false if initialization failed.
+     */
+    static bool initialize()
+    {
+        return !!rt_init();
+    }
+
+    deprecated("Please use the overload of Runtime.initialize that takes no argument.")
+    static bool initialize(ExceptionHandler dg = null)
+    {
+        return !!rt_init();
+    }
+
+
+    /**
+     * Terminates the runtime.  This call is to be used in instances where the
+     * standard program termination process will not be not executed.  This is
+     * most often in shared libraries or in libraries linked to a C program.
+     * If the runtime was not successfully initialized the function returns false.
+     *
+     * Returns:
+     *  true if termination succeeded or false if termination failed.
+     */
+    static bool terminate()
+    {
+        return !!rt_term();
+    }
+
+    deprecated("Please use the overload of Runtime.terminate that takes no argument.")
+    static bool terminate(ExceptionHandler dg = null)
+    {
+        return !!rt_term();
+    }
+
+
+    /**
+     * Returns the arguments supplied when the process was started.
+     *
+     * Returns:
+     *  The arguments supplied when this process was started.
+     */
+    static @property string[] args()
+    {
+        return rt_args();
+    }
+
+    /**
+     * Returns the unprocessed C arguments supplied when the process was started.
+     * Use this when you need to supply argc and argv to C libraries.
+     *
+     * Returns:
+     *  A $(LREF CArgs) struct with the arguments supplied when this process was started.
+     *
+     * Example:
+     * ---
+     * import core.runtime;
+     *
+     * // A C library function requiring char** arguments
+     * extern(C) void initLibFoo(int argc, char** argv);
+     *
+     * void main()
+     * {
+     *     auto args = Runtime.cArgs;
+     *     initLibFoo(args.argc, args.argv);
+     * }
+     * ---
+     */
+    static @property CArgs cArgs() @nogc
+    {
+        return rt_cArgs();
+    }
+
+    /**
+     * Locates a dynamic library with the supplied library name and dynamically
+     * loads it into the caller's address space.  If the library contains a D
+     * runtime it will be integrated with the current runtime.
+     *
+     * Params:
+     *  name = The name of the dynamic library to load.
+     *
+     * Returns:
+     *  A reference to the library or null on error.
+     */
+    static void* loadLibrary()(in char[] name)
+    {
+        import core.stdc.stdlib : free, malloc;
+        version (Windows)
+        {
+            import core.sys.windows.windows;
+
+            if (name.length == 0) return null;
+            // Load a DLL at runtime
+            auto len = MultiByteToWideChar(
+                CP_UTF8, 0, name.ptr, cast(int)name.length, null, 0);
+            if (len == 0)
+                return null;
+
+            auto buf = cast(wchar_t*)malloc((len+1) * wchar_t.sizeof);
+            if (buf is null) return null;
+            scope (exit) free(buf);
+
+            len = MultiByteToWideChar(
+                CP_UTF8, 0, name.ptr, cast(int)name.length, buf, len);
+            if (len == 0)
+                return null;
+
+            buf[len] = '\0';
+
+            return rt_loadLibraryW(buf);
+        }
+        else version (Posix)
+        {
+            /* Need a 0-terminated C string for the dll name
+             */
+            immutable len = name.length;
+            auto buf = cast(char*)malloc(len + 1);
+            if (!buf) return null;
+            scope (exit) free(buf);
+
+            buf[0 .. len] = name[];
+            buf[len] = 0;
+
+            return rt_loadLibrary(buf);
+        }
+    }
+
+
+    /**
+     * Unloads the dynamic library referenced by p.  If this library contains a
+     * D runtime then any necessary finalization or cleanup of that runtime
+     * will be performed.
+     *
+     * Params:
+     *  p = A reference to the library to unload.
+     */
+    static bool unloadLibrary()(void* p)
+    {
+        return !!rt_unloadLibrary(p);
+    }
+
+
+    /**
+     * Overrides the default trace mechanism with a user-supplied version.  A
+     * trace represents the context from which an exception was thrown, and the
+     * trace handler will be called when this occurs.  The pointer supplied to
+     * this routine indicates the base address from which tracing should occur.
+     * If the supplied pointer is null then the trace routine should determine
+     * an appropriate calling context from which to begin the trace.
+     *
+     * Params:
+     *  h = The new trace handler.  Set to null to use the default handler.
+     */
+    static @property void traceHandler( TraceHandler h )
+    {
+        rt_setTraceHandler( h );
+    }
+
+    /**
+     * Gets the current trace handler.
+     *
+     * Returns:
+     *  The current trace handler or null if none has been set.
+     */
+    static @property TraceHandler traceHandler()
+    {
+        return rt_getTraceHandler();
+    }
+
+    /**
+     * Overrides the default collect hander with a user-supplied version.  This
+     * routine will be called for each resource object that is finalized in a
+     * non-deterministic manner--typically during a garbage collection cycle.
+     * If the supplied routine returns true then the object's dtor will called
+     * as normal, but if the routine returns false than the dtor will not be
+     * called.  The default behavior is for all object dtors to be called.
+     *
+     * Params:
+     *  h = The new collect handler.  Set to null to use the default handler.
+     */
+    static @property void collectHandler( CollectHandler h )
+    {
+        rt_setCollectHandler( h );
+    }
+
+
+    /**
+     * Gets the current collect handler.
+     *
+     * Returns:
+     *  The current collect handler or null if none has been set.
+     */
+    static @property CollectHandler collectHandler()
+    {
+        return rt_getCollectHandler();
+    }
+
+
+    /**
+     * Overrides the default module unit tester with a user-supplied version.
+     * This routine will be called once on program initialization.  The return
+     * value of this routine indicates to the runtime whether the tests ran
+     * without error.
+     *
+     * Params:
+     *  h = The new unit tester.  Set to null to use the default unit tester.
+     */
+    static @property void moduleUnitTester( ModuleUnitTester h )
+    {
+        sm_moduleUnitTester = h;
+    }
+
+
+    /**
+     * Gets the current module unit tester.
+     *
+     * Returns:
+     *  The current module unit tester handler or null if none has been set.
+     */
+    static @property ModuleUnitTester moduleUnitTester()
+    {
+        return sm_moduleUnitTester;
+    }
+
+
+private:
+
+    // NOTE: This field will only ever be set in a static ctor and should
+    //       never occur within any but the main thread, so it is safe to
+    //       make it __gshared.
+    __gshared ModuleUnitTester sm_moduleUnitTester = null;
+}
+
+/**
+ * Set source file path for coverage reports.
+ *
+ * Params:
+ *  path = The new path name.
+ * Note:
+ *  This is a dmd specific setting.
+ */
+extern (C) void dmd_coverSourcePath(string path);
+
+/**
+ * Set output path for coverage reports.
+ *
+ * Params:
+ *  path = The new path name.
+ * Note:
+ *  This is a dmd specific setting.
+ */
+extern (C) void dmd_coverDestPath(string path);
+
+/**
+ * Enable merging of coverage reports with existing data.
+ *
+ * Params:
+ *  flag = enable/disable coverage merge mode
+ * Note:
+ *  This is a dmd specific setting.
+ */
+extern (C) void dmd_coverSetMerge(bool flag);
+
+/**
+ * Set the output file name for profile reports (-profile switch).
+ * An empty name will set the output to stdout.
+ *
+ * Params:
+ *  name = file name
+ * Note:
+ *  This is a dmd specific setting.
+ */
+extern (C) void trace_setlogfilename(string name);
+
+/**
+ * Set the output file name for the optimized profile linker DEF file (-profile switch).
+ * An empty name will set the output to stdout.
+ *
+ * Params:
+ *  name = file name
+ * Note:
+ *  This is a dmd specific setting.
+ */
+extern (C) void trace_setdeffilename(string name);
+
+/**
+ * Set the output file name for memory profile reports (-profile=gc switch).
+ * An empty name will set the output to stdout.
+ *
+ * Params:
+ *  name = file name
+ * Note:
+ *  This is a dmd specific setting.
+ */
+extern (C) void profilegc_setlogfilename(string name);
+
+///////////////////////////////////////////////////////////////////////////////
+// Overridable Callbacks
+///////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * This routine is called by the runtime to run module unit tests on startup.
+ * The user-supplied unit tester will be called if one has been supplied,
+ * otherwise all unit tests will be run in sequence.
+ *
+ * Returns:
+ *  true if execution should continue after testing is complete and false if
+ *  not.  Default behavior is to return true.
+ */
+extern (C) bool runModuleUnitTests()
+{
+    // backtrace
+    version(GNU)
+        import gcc.backtrace;
+    version( CRuntime_Glibc )
+        import core.sys.linux.execinfo;
+    else version( OSX )
+        import core.sys.osx.execinfo;
+    else version( FreeBSD )
+        import core.sys.freebsd.execinfo;
+    else version( Windows )
+        import core.sys.windows.stacktrace;
+    else version( Solaris )
+        import core.sys.solaris.execinfo;
+
+    static if( __traits( compiles, new LibBacktrace(0) ) )
+    {
+        import core.sys.posix.signal; // segv handler
+
+        static extern (C) void unittestSegvHandler( int signum, siginfo_t* info, void* ptr )
+        {
+            import core.stdc.stdio;
+            fprintf(stderr, "Segmentation fault while running unittests:\n");
+            fprintf(stderr, "----------------\n");
+
+            enum alignment = LibBacktrace.MaxAlignment;
+            enum classSize = __traits(classInstanceSize, LibBacktrace);
+
+            void[classSize + alignment] bt_store = void;
+            void* alignedAddress = cast(byte*)((cast(size_t)(bt_store.ptr + alignment - 1))
+                & ~(alignment - 1));
+
+            (alignedAddress[0 .. classSize]) = typeid(LibBacktrace).init[];
+            auto bt = cast(LibBacktrace)(alignedAddress);
+            // First frame is LibBacktrace ctor. Second is signal handler, but include that for now
+            bt.__ctor(1);
+
+            foreach(size_t i, const(char[]) msg; bt)
+                fprintf(stderr, "%s\n", msg.ptr ? msg.ptr : "???");
+        }
+
+        sigaction_t action = void;
+        sigaction_t oldseg = void;
+        sigaction_t oldbus = void;
+
+        (cast(byte*) &action)[0 .. action.sizeof] = 0;
+        sigfillset( &action.sa_mask ); // block other signals
+        action.sa_flags = SA_SIGINFO | SA_RESETHAND;
+        action.sa_sigaction = &unittestSegvHandler;
+        sigaction( SIGSEGV, &action, &oldseg );
+        sigaction( SIGBUS, &action, &oldbus );
+        scope( exit )
+        {
+            sigaction( SIGSEGV, &oldseg, null );
+            sigaction( SIGBUS, &oldbus, null );
+        }
+    }
+    else static if( __traits( compiles, backtrace ) )
+    {
+        import core.sys.posix.signal; // segv handler
+
+        static extern (C) void unittestSegvHandler( int signum, siginfo_t* info, void* ptr ) nothrow
+        {
+            static enum MAXFRAMES = 128;
+            void*[MAXFRAMES]  callstack;
+            int               numframes;
+
+            numframes = backtrace( callstack.ptr, MAXFRAMES );
+            backtrace_symbols_fd( callstack.ptr, numframes, 2 );
+        }
+
+        sigaction_t action = void;
+        sigaction_t oldseg = void;
+        sigaction_t oldbus = void;
+
+        (cast(byte*) &action)[0 .. action.sizeof] = 0;
+        sigfillset( &action.sa_mask ); // block other signals
+        action.sa_flags = SA_SIGINFO | SA_RESETHAND;
+        action.sa_sigaction = &unittestSegvHandler;
+        sigaction( SIGSEGV, &action, &oldseg );
+        sigaction( SIGBUS, &action, &oldbus );
+        scope( exit )
+        {
+            sigaction( SIGSEGV, &oldseg, null );
+            sigaction( SIGBUS, &oldbus, null );
+        }
+    }
+
+    if( Runtime.sm_moduleUnitTester is null )
+    {
+        size_t failed = 0;
+        foreach( m; ModuleInfo )
+        {
+            if( m )
+            {
+                auto fp = m.unitTest;
+
+                if( fp )
+                {
+                    try
+                    {
+                        fp();
+                    }
+                    catch( Throwable e )
+                    {
+                        _d_print_throwable(e);
+                        failed++;
+                    }
+                }
+            }
+        }
+        return failed == 0;
+    }
+    return Runtime.sm_moduleUnitTester();
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Default Implementations
+///////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ *
+ */
+Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
+{
+    // backtrace
+    version(GNU)
+        import gcc.backtrace;
+    version( CRuntime_Glibc )
+        import core.sys.linux.execinfo;
+    else version( OSX )
+        import core.sys.osx.execinfo;
+    else version( FreeBSD )
+        import core.sys.freebsd.execinfo;
+    else version( Windows )
+        import core.sys.windows.stacktrace;
+    else version( Solaris )
+        import core.sys.solaris.execinfo;
+
+    // avoid recursive GC calls in finalizer, trace handlers should be made @nogc instead
+    import core.memory : gc_inFinalizer;
+    if (gc_inFinalizer)
+        return null;
+
+    //printf("runtime.defaultTraceHandler()\n");
+    static if( __traits( compiles, new LibBacktrace(0) ) )
+    {
+        version(Posix)
+        {
+            static enum FIRSTFRAME = 4;
+        }
+        else version (Win64)
+        {
+            static enum FIRSTFRAME = 4;
+        }
+        else
+        {
+            static enum FIRSTFRAME = 0;
+        }
+        return new LibBacktrace(FIRSTFRAME);
+    }
+    else static if( __traits( compiles, backtrace ) )
+    {
+        import core.demangle;
+        import core.stdc.stdlib : free;
+        import core.stdc.string : strlen, memchr, memmove;
+
+        class DefaultTraceInfo : Throwable.TraceInfo
+        {
+            this()
+            {
+                numframes = 0; //backtrace( callstack, MAXFRAMES );
+                if (numframes < 2) // backtrace() failed, do it ourselves
+                {
+                    static void** getBasePtr()
+                    {
+                        version( D_InlineAsm_X86 )
+                            asm { naked; mov EAX, EBP; ret; }
+                        else
+                        version( D_InlineAsm_X86_64 )
+                            asm { naked; mov RAX, RBP; ret; }
+                        else
+                            return null;
+                    }
+
+                    auto  stackTop    = getBasePtr();
+                    auto  stackBottom = cast(void**) thread_stackBottom();
+                    void* dummy;
+
+                    if( stackTop && &dummy < stackTop && stackTop < stackBottom )
+                    {
+                        auto stackPtr = stackTop;
+
+                        for( numframes = 0; stackTop <= stackPtr &&
+                                            stackPtr < stackBottom &&
+                                            numframes < MAXFRAMES; )
+                        {
+                            enum CALL_INSTRUCTION_SIZE = 1; // it may not be 1 but it is good enough to get
+                                                            // in CALL instruction address range for backtrace
+                            callstack[numframes++] = *(stackPtr + 1) - CALL_INSTRUCTION_SIZE;
+                            stackPtr = cast(void**) *stackPtr;
+                        }
+                    }
+                }
+            }
+
+            override int opApply( scope int delegate(ref const(char[])) dg ) const
+            {
+                return opApply( (ref size_t, ref const(char[]) buf)
+                                {
+                                    return dg( buf );
+                                } );
+            }
+
+            override int opApply( scope int delegate(ref size_t, ref const(char[])) dg ) const
+            {
+                version(Posix)
+                {
+                    // NOTE: The first 4 frames with the current implementation are
+                    //       inside core.runtime and the object code, so eliminate
+                    //       these for readability.  The alternative would be to
+                    //       exclude the first N frames that are in a list of
+                    //       mangled function names.
+                    enum FIRSTFRAME = 4;
+                }
+                else version(Windows)
+                {
+                    // NOTE: On Windows, the number of frames to exclude is based on
+                    //       whether the exception is user or system-generated, so
+                    //       it may be necessary to exclude a list of function names
+                    //       instead.
+                    enum FIRSTFRAME = 0;
+                }
+
+                version(linux) enum enableDwarf = true;
+                else version(FreeBSD) enum enableDwarf = true;
+                else enum enableDwarf = false;
+
+                static if (enableDwarf)
+                {
+                    import core.internal.traits : externDFunc;
+
+                    alias traceHandlerOpApplyImpl = externDFunc!(
+                        "rt.backtrace.dwarf.traceHandlerOpApplyImpl",
+                        int function(const void*[], scope int delegate(ref size_t, ref const(char[])))
+                    );
+
+                    if (numframes >= FIRSTFRAME)
+                    {
+                        return traceHandlerOpApplyImpl(
+                            callstack[FIRSTFRAME .. numframes],
+                            dg
+                        );
+                    }
+                    else
+                    {
+                        return 0;
+                    }
+                }
+                else
+                {
+                    const framelist = backtrace_symbols( callstack.ptr, numframes );
+                    scope(exit) free(cast(void*) framelist);
+
+                    int ret = 0;
+                    for( int i = FIRSTFRAME; i < numframes; ++i )
+                    {
+                        char[4096] fixbuf;
+                        auto buf = framelist[i][0 .. strlen(framelist[i])];
+                        auto pos = cast(size_t)(i - FIRSTFRAME);
+                        buf = fixline( buf, fixbuf );
+                        ret = dg( pos, buf );
+                        if( ret )
+                            break;
+                    }
+                    return ret;
+                }
+
+            }
+
+            override string toString() const
+            {
+                string buf;
+                foreach( i, line; this )
+                    buf ~= i ? "\n" ~ line : line;
+                return buf;
+            }
+
+        private:
+            int     numframes;
+            static enum MAXFRAMES = 128;
+            void*[MAXFRAMES]  callstack = void;
+
+        private:
+            const(char)[] fixline( const(char)[] buf, return ref char[4096] fixbuf ) const
+            {
+                size_t symBeg, symEnd;
+                version( OSX )
+                {
+                    // format is:
+                    //  1  module    0x00000000 D6module4funcAFZv + 0
+                    for( size_t i = 0, n = 0; i < buf.length; i++ )
+                    {
+                        if( ' ' == buf[i] )
+                        {
+                            n++;
+                            while( i < buf.length && ' ' == buf[i] )
+                                i++;
+                            if( 3 > n )
+                                continue;
+                            symBeg = i;
+                            while( i < buf.length && ' ' != buf[i] )
+                                i++;
+                            symEnd = i;
+                            break;
+                        }
+                    }
+                }
+                else version( CRuntime_Glibc )
+                {
+                    // format is:  module(_D6module4funcAFZv) [0x00000000]
+                    // or:         module(_D6module4funcAFZv+0x78) [0x00000000]
+                    auto bptr = cast(char*) memchr( buf.ptr, '(', buf.length );
+                    auto eptr = cast(char*) memchr( buf.ptr, ')', buf.length );
+                    auto pptr = cast(char*) memchr( buf.ptr, '+', buf.length );
+
+                    if (pptr && pptr < eptr)
+                        eptr = pptr;
+
+                    if( bptr++ && eptr )
+                    {
+                        symBeg = bptr - buf.ptr;
+                        symEnd = eptr - buf.ptr;
+                    }
+                }
+                else version( FreeBSD )
+                {
+                    // format is: 0x00000000 <_D6module4funcAFZv+0x78> at module
+                    auto bptr = cast(char*) memchr( buf.ptr, '<', buf.length );
+                    auto eptr = cast(char*) memchr( buf.ptr, '+', buf.length );
+
+                    if( bptr++ && eptr )
+                    {
+                        symBeg = bptr - buf.ptr;
+                        symEnd = eptr - buf.ptr;
+                    }
+                }
+                else version( Solaris )
+                {
+                    // format is object'symbol+offset [pc]
+                    auto bptr = cast(char*) memchr( buf.ptr, '\'', buf.length );
+                    auto eptr = cast(char*) memchr( buf.ptr, '+', buf.length );
+
+                    if( bptr++ && eptr )
+                    {
+                        symBeg = bptr - buf.ptr;
+                        symEnd = eptr - buf.ptr;
+                    }
+                }
+                else
+                {
+                    // fallthrough
+                }
+
+                assert(symBeg < buf.length && symEnd < buf.length);
+                assert(symBeg <= symEnd);
+
+                enum min = (size_t a, size_t b) => a <= b ? a : b;
+                if (symBeg == symEnd || symBeg >= fixbuf.length)
+                {
+                    immutable len = min(buf.length, fixbuf.length);
+                    fixbuf[0 .. len] = buf[0 .. len];
+                    return fixbuf[0 .. len];
+                }
+                else
+                {
+                    fixbuf[0 .. symBeg] = buf[0 .. symBeg];
+
+                    auto sym = demangle(buf[symBeg .. symEnd], fixbuf[symBeg .. $]);
+
+                    if (sym.ptr !is fixbuf.ptr + symBeg)
+                    {
+                        // demangle reallocated the buffer, copy the symbol to fixbuf
+                        immutable len = min(fixbuf.length - symBeg, sym.length);
+                        memmove(fixbuf.ptr + symBeg, sym.ptr, len);
+                        if (symBeg + len == fixbuf.length)
+                            return fixbuf[];
+                    }
+
+                    immutable pos = symBeg + sym.length;
+                    assert(pos < fixbuf.length);
+                    immutable tail = buf.length - symEnd;
+                    immutable len = min(fixbuf.length - pos, tail);
+                    fixbuf[pos .. pos + len] = buf[symEnd .. symEnd + len];
+                    return fixbuf[0 .. pos + len];
+                }
+            }
+        }
+
+        return new DefaultTraceInfo;
+    }
+    else static if( __traits( compiles, new StackTrace(0, null) ) )
+    {
+        version (Win64)
+        {
+            static enum FIRSTFRAME = 4;
+        }
+        else version (Win32)
+        {
+            static enum FIRSTFRAME = 0;
+        }
+        import core.sys.windows.windows : CONTEXT;
+        auto s = new StackTrace(FIRSTFRAME, cast(CONTEXT*)ptr);
+        return s;
+    }
+    else static if( __traits( compiles, new UnwindBacktrace(0) ) )
+    {
+        version(Posix)
+        {
+            static enum FIRSTFRAME = 5;
+        }
+        else version (Win64)
+        {
+            static enum FIRSTFRAME = 4;
+        }
+        else
+        {
+            static enum FIRSTFRAME = 0;
+        }
+        return new UnwindBacktrace(FIRSTFRAME);
+    }
+    else
+    {
+        return null;
+    }
+}
diff --git a/libphobos/libdruntime/core/simd.d b/libphobos/libdruntime/core/simd.d
new file mode 100644
index 00000000000..f2e5f239f3f
--- /dev/null
+++ b/libphobos/libdruntime/core/simd.d
@@ -0,0 +1,462 @@
+// Written in the D programming language.
+
+/**
+ * Builtin SIMD intrinsics
+ *
+ * Source: $(DRUNTIMESRC core/_simd.d)
+ *
+ * Copyright: Copyright Digital Mars 2012.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   $(WEB digitalmars.com, Walter Bright),
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module core.simd;
+
+pure:
+nothrow:
+@safe:
+@nogc:
+
+/*******************************
+ * Create a vector type.
+ *
+ * Parameters:
+ *      T = one of double[2], float[4], void[16], byte[16], ubyte[16],
+ *      short[8], ushort[8], int[4], uint[4], long[2], ulong[2].
+ *      For 256 bit vectors,
+ *      one of double[4], float[8], void[32], byte[32], ubyte[32],
+ *      short[16], ushort[16], int[8], uint[8], long[4], ulong[4]
+ */
+
+template Vector(T)
+{
+    /* __vector is compiler magic, hide it behind a template.
+     * The compiler will reject T's that don't work.
+     */
+    alias __vector(T) Vector;
+}
+
+/* Handy aliases
+ */
+static if (is(Vector!(void[8])))    alias Vector!(void[8])  void8;          ///
+static if (is(Vector!(float[2])))   alias Vector!(float[2])  float2;        ///
+static if (is(Vector!(byte[8])))    alias Vector!(byte[8])  byte8;          ///
+static if (is(Vector!(ubyte[8])))   alias Vector!(ubyte[8]) ubyte8;         ///
+static if (is(Vector!(short[4])))   alias Vector!(short[4])  short4;        ///
+static if (is(Vector!(ushort[4])))  alias Vector!(ushort[4]) ushort4;       ///
+static if (is(Vector!(int[2])))     alias Vector!(int[2])    int2;          ///
+static if (is(Vector!(uint[2])))    alias Vector!(uint[2])   uint2;         ///
+
+static if (is(Vector!(void[16])))   alias Vector!(void[16])  void16;        ///
+static if (is(Vector!(double[2])))  alias Vector!(double[2]) double2;       ///
+static if (is(Vector!(float[4])))   alias Vector!(float[4])  float4;        ///
+static if (is(Vector!(byte[16])))   alias Vector!(byte[16])  byte16;        ///
+static if (is(Vector!(ubyte[16])))  alias Vector!(ubyte[16]) ubyte16;       ///
+static if (is(Vector!(short[8])))   alias Vector!(short[8])  short8;        ///
+static if (is(Vector!(ushort[8])))  alias Vector!(ushort[8]) ushort8;       ///
+static if (is(Vector!(int[4])))     alias Vector!(int[4])    int4;          ///
+static if (is(Vector!(uint[4])))    alias Vector!(uint[4])   uint4;         ///
+static if (is(Vector!(long[2])))    alias Vector!(long[2])   long2;         ///
+static if (is(Vector!(ulong[2])))   alias Vector!(ulong[2])  ulong2;        ///
+
+static if (is(Vector!(void[32])))   alias Vector!(void[32])   void32;        ///
+static if (is(Vector!(double[4])))  alias Vector!(double[4])  double4;       ///
+static if (is(Vector!(float[8])))   alias Vector!(float[8])   float8;        ///
+static if (is(Vector!(byte[32])))   alias Vector!(byte[32])   byte32;        ///
+static if (is(Vector!(ubyte[32])))  alias Vector!(ubyte[32])  ubyte32;       ///
+static if (is(Vector!(short[16])))  alias Vector!(short[16])  short16;       ///
+static if (is(Vector!(ushort[16]))) alias Vector!(ushort[16]) ushort16;      ///
+static if (is(Vector!(int[8])))     alias Vector!(int[8])     int8;          ///
+static if (is(Vector!(uint[8])))    alias Vector!(uint[8])    uint8;         ///
+static if (is(Vector!(long[4])))    alias Vector!(long[4])    long4;         ///
+static if (is(Vector!(ulong[4])))   alias Vector!(ulong[4])   ulong4;        ///
+
+version ( D_SIMD )
+{
+  /** XMM opcodes that conform to the following:
+   *
+   *  opcode xmm1,xmm2/mem
+   *
+   * and do not have side effects (i.e. do not write to memory).
+   */
+  enum XMM
+  {
+    ADDSS = 0xF30F58,
+    ADDSD = 0xF20F58,
+    ADDPS = 0x000F58,
+    ADDPD = 0x660F58,
+    PADDB = 0x660FFC,
+    PADDW = 0x660FFD,
+    PADDD = 0x660FFE,
+    PADDQ = 0x660FD4,
+
+    SUBSS = 0xF30F5C,
+    SUBSD = 0xF20F5C,
+    SUBPS = 0x000F5C,
+    SUBPD = 0x660F5C,
+    PSUBB = 0x660FF8,
+    PSUBW = 0x660FF9,
+    PSUBD = 0x660FFA,
+    PSUBQ = 0x660FFB,
+
+    MULSS = 0xF30F59,
+    MULSD = 0xF20F59,
+    MULPS = 0x000F59,
+    MULPD = 0x660F59,
+    PMULLW = 0x660FD5,
+
+    DIVSS = 0xF30F5E,
+    DIVSD = 0xF20F5E,
+    DIVPS = 0x000F5E,
+    DIVPD = 0x660F5E,
+
+    PAND  = 0x660FDB,
+    POR   = 0x660FEB,
+
+    UCOMISS = 0x000F2E,
+    UCOMISD = 0x660F2E,
+
+    XORPS = 0x000F57,
+    XORPD = 0x660F57,
+
+    // Use STO and LOD instead of MOV to distinguish the direction
+    STOSS  = 0xF30F11,
+    STOSD  = 0xF20F11,
+    STOAPS = 0x000F29,
+    STOAPD = 0x660F29,
+    STODQA = 0x660F7F,
+    STOD   = 0x660F7E,        // MOVD reg/mem64, xmm   66 0F 7E /r
+    STOQ   = 0x660FD6,
+
+    LODSS  = 0xF30F10,
+    LODSD  = 0xF20F10,
+    LODAPS = 0x000F28,
+    LODAPD = 0x660F28,
+    LODDQA = 0x660F6F,
+    LODD   = 0x660F6E,        // MOVD xmm, reg/mem64   66 0F 6E /r
+    LODQ   = 0xF30F7E,
+
+    LODDQU   = 0xF30F6F,      // MOVDQU xmm1, xmm2/mem128  F3 0F 6F /r
+    STODQU   = 0xF30F7F,      // MOVDQU xmm1/mem128, xmm2  F3 0F 7F /r
+    MOVDQ2Q  = 0xF20FD6,      // MOVDQ2Q mmx, xmm          F2 0F D6 /r
+    MOVHLPS  = 0x0F12,        // MOVHLPS xmm1, xmm2        0F 12 /r
+    LODHPD   = 0x660F16,
+    STOHPD   = 0x660F17,      // MOVHPD mem64, xmm         66 0F 17 /r
+    LODHPS   = 0x0F16,
+    STOHPS   = 0x0F17,
+    MOVLHPS  = 0x0F16,
+    LODLPD   = 0x660F12,
+    STOLPD   = 0x660F13,
+    LODLPS   = 0x0F12,
+    STOLPS   = 0x0F13,
+    MOVMSKPD = 0x660F50,
+    MOVMSKPS = 0x0F50,
+    MOVNTDQ  = 0x660FE7,
+    MOVNTI   = 0x0FC3,
+    MOVNTPD  = 0x660F2B,
+    MOVNTPS  = 0x0F2B,
+    MOVNTQ   = 0x0FE7,
+    MOVQ2DQ  = 0xF30FD6,
+    LODUPD   = 0x660F10,
+    STOUPD   = 0x660F11,
+    LODUPS   = 0x0F10,
+    STOUPS   = 0x0F11,
+
+    PACKSSDW = 0x660F6B,
+    PACKSSWB = 0x660F63,
+    PACKUSWB = 0x660F67,
+    PADDSB = 0x660FEC,
+    PADDSW = 0x660FED,
+    PADDUSB = 0x660FDC,
+    PADDUSW = 0x660FDD,
+    PANDN = 0x660FDF,
+    PCMPEQB = 0x660F74,
+    PCMPEQD = 0x660F76,
+    PCMPEQW = 0x660F75,
+    PCMPGTB = 0x660F64,
+    PCMPGTD = 0x660F66,
+    PCMPGTW = 0x660F65,
+    PMADDWD = 0x660FF5,
+    PSLLW = 0x660FF1,
+    PSLLD = 0x660FF2,
+    PSLLQ = 0x660FF3,
+    PSRAW = 0x660FE1,
+    PSRAD = 0x660FE2,
+    PSRLW = 0x660FD1,
+    PSRLD = 0x660FD2,
+    PSRLQ = 0x660FD3,
+    PSUBSB = 0x660FE8,
+    PSUBSW = 0x660FE9,
+    PSUBUSB = 0x660FD8,
+    PSUBUSW = 0x660FD9,
+    PUNPCKHBW = 0x660F68,
+    PUNPCKHDQ = 0x660F6A,
+    PUNPCKHWD = 0x660F69,
+    PUNPCKLBW = 0x660F60,
+    PUNPCKLDQ = 0x660F62,
+    PUNPCKLWD = 0x660F61,
+    PXOR = 0x660FEF,
+    ANDPD = 0x660F54,
+    ANDPS = 0x0F54,
+    ANDNPD = 0x660F55,
+    ANDNPS = 0x0F55,
+    CMPPS = 0x0FC2,
+    CMPPD = 0x660FC2,
+    CMPSD = 0xF20FC2,
+    CMPSS = 0xF30FC2,
+    COMISD = 0x660F2F,
+    COMISS = 0x0F2F,
+    CVTDQ2PD = 0xF30FE6,
+    CVTDQ2PS = 0x0F5B,
+    CVTPD2DQ = 0xF20FE6,
+    CVTPD2PI = 0x660F2D,
+    CVTPD2PS = 0x660F5A,
+    CVTPI2PD = 0x660F2A,
+    CVTPI2PS = 0x0F2A,
+    CVTPS2DQ = 0x660F5B,
+    CVTPS2PD = 0x0F5A,
+    CVTPS2PI = 0x0F2D,
+    CVTSD2SI = 0xF20F2D,
+    CVTSD2SS = 0xF20F5A,
+    CVTSI2SD = 0xF20F2A,
+    CVTSI2SS = 0xF30F2A,
+    CVTSS2SD = 0xF30F5A,
+    CVTSS2SI = 0xF30F2D,
+    CVTTPD2PI = 0x660F2C,
+    CVTTPD2DQ = 0x660FE6,
+    CVTTPS2DQ = 0xF30F5B,
+    CVTTPS2PI = 0x0F2C,
+    CVTTSD2SI = 0xF20F2C,
+    CVTTSS2SI = 0xF30F2C,
+    MASKMOVDQU = 0x660FF7,
+    MASKMOVQ = 0x0FF7,
+    MAXPD = 0x660F5F,
+    MAXPS = 0x0F5F,
+    MAXSD = 0xF20F5F,
+    MAXSS = 0xF30F5F,
+    MINPD = 0x660F5D,
+    MINPS = 0x0F5D,
+    MINSD = 0xF20F5D,
+    MINSS = 0xF30F5D,
+    ORPD = 0x660F56,
+    ORPS = 0x0F56,
+    PAVGB = 0x660FE0,
+    PAVGW = 0x660FE3,
+    PMAXSW = 0x660FEE,
+    //PINSRW = 0x660FC4,
+    PMAXUB = 0x660FDE,
+    PMINSW = 0x660FEA,
+    PMINUB = 0x660FDA,
+    //PMOVMSKB = 0x660FD7,
+    PMULHUW = 0x660FE4,
+    PMULHW = 0x660FE5,
+    PMULUDQ = 0x660FF4,
+    PSADBW = 0x660FF6,
+    PUNPCKHQDQ = 0x660F6D,
+    PUNPCKLQDQ = 0x660F6C,
+    RCPPS = 0x0F53,
+    RCPSS = 0xF30F53,
+    RSQRTPS = 0x0F52,
+    RSQRTSS = 0xF30F52,
+    SQRTPD = 0x660F51,
+    SHUFPD = 0x660FC6,
+    SHUFPS = 0x0FC6,
+    SQRTPS = 0x0F51,
+    SQRTSD = 0xF20F51,
+    SQRTSS = 0xF30F51,
+    UNPCKHPD = 0x660F15,
+    UNPCKHPS = 0x0F15,
+    UNPCKLPD = 0x660F14,
+    UNPCKLPS = 0x0F14,
+
+    PSHUFD = 0x660F70,
+    PSHUFHW = 0xF30F70,
+    PSHUFLW = 0xF20F70,
+    PSHUFW = 0x0F70,
+    PSLLDQ = 0x07660F73,
+    PSRLDQ = 0x03660F73,
+
+    //PREFETCH = 0x0F18,
+
+// SSE3 Pentium 4 (Prescott)
+
+    ADDSUBPD = 0x660FD0,
+    ADDSUBPS = 0xF20FD0,
+    HADDPD   = 0x660F7C,
+    HADDPS   = 0xF20F7C,
+    HSUBPD   = 0x660F7D,
+    HSUBPS   = 0xF20F7D,
+    MOVDDUP  = 0xF20F12,
+    MOVSHDUP = 0xF30F16,
+    MOVSLDUP = 0xF30F12,
+    LDDQU    = 0xF20FF0,
+    MONITOR  = 0x0F01C8,
+    MWAIT    = 0x0F01C9,
+
+// SSSE3
+    PALIGNR = 0x660F3A0F,
+    PHADDD = 0x660F3802,
+    PHADDW = 0x660F3801,
+    PHADDSW = 0x660F3803,
+    PABSB = 0x660F381C,
+    PABSD = 0x660F381E,
+    PABSW = 0x660F381D,
+    PSIGNB = 0x660F3808,
+    PSIGND = 0x660F380A,
+    PSIGNW = 0x660F3809,
+    PSHUFB = 0x660F3800,
+    PMADDUBSW = 0x660F3804,
+    PMULHRSW = 0x660F380B,
+    PHSUBD = 0x660F3806,
+    PHSUBW = 0x660F3805,
+    PHSUBSW = 0x660F3807,
+
+// SSE4.1
+
+    BLENDPD   = 0x660F3A0D,
+    BLENDPS   = 0x660F3A0C,
+    BLENDVPD  = 0x660F3815,
+    BLENDVPS  = 0x660F3814,
+    DPPD      = 0x660F3A41,
+    DPPS      = 0x660F3A40,
+    EXTRACTPS = 0x660F3A17,
+    INSERTPS  = 0x660F3A21,
+    MPSADBW   = 0x660F3A42,
+    PBLENDVB  = 0x660F3810,
+    PBLENDW   = 0x660F3A0E,
+    PEXTRD    = 0x660F3A16,
+    PEXTRQ    = 0x660F3A16,
+    PINSRB    = 0x660F3A20,
+    PINSRD    = 0x660F3A22,
+    PINSRQ    = 0x660F3A22,
+
+    MOVNTDQA = 0x660F382A,
+    PACKUSDW = 0x660F382B,
+    PCMPEQQ = 0x660F3829,
+    PEXTRB = 0x660F3A14,
+    PHMINPOSUW = 0x660F3841,
+    PMAXSB = 0x660F383C,
+    PMAXSD = 0x660F383D,
+    PMAXUD = 0x660F383F,
+    PMAXUW = 0x660F383E,
+    PMINSB = 0x660F3838,
+    PMINSD = 0x660F3839,
+    PMINUD = 0x660F383B,
+    PMINUW = 0x660F383A,
+    PMOVSXBW = 0x660F3820,
+    PMOVSXBD = 0x660F3821,
+    PMOVSXBQ = 0x660F3822,
+    PMOVSXWD = 0x660F3823,
+    PMOVSXWQ = 0x660F3824,
+    PMOVSXDQ = 0x660F3825,
+    PMOVZXBW = 0x660F3830,
+    PMOVZXBD = 0x660F3831,
+    PMOVZXBQ = 0x660F3832,
+    PMOVZXWD = 0x660F3833,
+    PMOVZXWQ = 0x660F3834,
+    PMOVZXDQ = 0x660F3835,
+    PMULDQ   = 0x660F3828,
+    PMULLD   = 0x660F3840,
+    PTEST    = 0x660F3817,
+
+    ROUNDPD = 0x660F3A09,
+    ROUNDPS = 0x660F3A08,
+    ROUNDSD = 0x660F3A0B,
+    ROUNDSS = 0x660F3A0A,
+
+// SSE4.2
+    PCMPESTRI  = 0x660F3A61,
+    PCMPESTRM  = 0x660F3A60,
+    PCMPISTRI  = 0x660F3A63,
+    PCMPISTRM  = 0x660F3A62,
+    PCMPGTQ    = 0x660F3837,
+    //CRC32
+
+// SSE4a (AMD only)
+    // EXTRQ,INSERTQ,MOVNTSD,MOVNTSS
+
+// POPCNT and LZCNT (have their own CPUID bits)
+    POPCNT     = 0xF30FB8,
+    // LZCNT
+  }
+
+  /**
+   * Generate two operand instruction with XMM 128 bit operands.
+   *
+   * This is a compiler magic function - it doesn't behave like
+   * regular D functions.
+   *
+   * Parameters:
+   *      opcode  any of the XMM opcodes; it must be a compile time constant
+   *      op1     first operand
+   *      op2     second operand
+   * Returns:
+   *      result of opcode
+   */
+  pure @safe void16 __simd(XMM opcode, void16 op1, void16 op2);
+
+  /**
+   * Unary SIMD instructions.
+   */
+  pure @safe void16 __simd(XMM opcode, void16 op1);
+  pure @safe void16 __simd(XMM opcode, double d);       ///
+  pure @safe void16 __simd(XMM opcode, float f);        ///
+
+  /****
+   * For instructions:
+   * CMPPD, CMPSS, CMPSD, CMPPS,
+   * PSHUFD, PSHUFHW, PSHUFLW,
+   * BLENDPD, BLENDPS, DPPD, DPPS,
+   * MPSADBW, PBLENDW,
+   * ROUNDPD, ROUNDPS, ROUNDSD, ROUNDSS
+   * Parameters:
+   *      opcode  any of the above XMM opcodes; it must be a compile time constant
+   *      op1     first operand
+   *      op2     second operand
+   *      imm8    third operand; must be a compile time constant
+   * Returns:
+   *      result of opcode
+   */
+  pure @safe void16 __simd(XMM opcode, void16 op1, void16 op2, ubyte imm8);
+
+  /***
+   * For instructions with the imm8 version:
+   * PSLLD, PSLLQ, PSLLW, PSRAD, PSRAW, PSRLD, PSRLQ, PSRLW,
+   * PSRLDQ, PSLLDQ
+   * Parameters:
+   *      opcode  any of the XMM opcodes; it must be a compile time constant
+   *      op1     first operand
+   *      imm8    second operand; must be a compile time constant
+   * Returns:
+   *      result of opcode
+   */
+  pure @safe void16 __simd_ib(XMM opcode, void16 op1, ubyte imm8);
+
+  /*****
+   * For "store" operations of the form:
+   *    op1 op= op2
+   * Returns:
+   *    op2
+   * These cannot be marked as pure, as semantic() doesn't check them.
+   */
+  @safe void16 __simd_sto(XMM opcode, void16 op1, void16 op2);
+  @safe void16 __simd_sto(XMM opcode, double op1, void16 op2); ///
+  @safe void16 __simd_sto(XMM opcode, float op1, void16 op2);  ///
+
+  /* The following use overloading to ensure correct typing.
+   * Compile with inlining on for best performance.
+   */
+
+  pure @safe short8 pcmpeq()(short8 v1, short8 v2)
+  {
+      return __simd(XMM.PCMPEQW, v1, v2);
+  }
+
+  pure @safe ushort8 pcmpeq()(ushort8 v1, ushort8 v2)
+  {
+      return __simd(XMM.PCMPEQW, v1, v2);
+  }
+}
diff --git a/libphobos/libdruntime/core/stdc/complex.d b/libphobos/libdruntime/core/stdc/complex.d
new file mode 100644
index 00000000000..dae35f2725c
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/complex.d
@@ -0,0 +1,177 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_complex.h.html, _complex.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_complex.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.complex;
+
+extern (C):
+@trusted: // All of these operate on floating point values only.
+nothrow:
+@nogc:
+
+///
+alias creal complex;
+///
+alias ireal imaginary;
+///
+cdouble cacos(cdouble z);
+///
+cfloat  cacosf(cfloat z);
+///
+creal   cacosl(creal z);
+
+///
+cdouble casin(cdouble z);
+///
+cfloat  casinf(cfloat z);
+///
+creal   casinl(creal z);
+
+///
+cdouble catan(cdouble z);
+///
+cfloat  catanf(cfloat z);
+///
+creal   catanl(creal z);
+
+///
+cdouble ccos(cdouble z);
+///
+cfloat  ccosf(cfloat z);
+///
+creal   ccosl(creal z);
+
+///
+cdouble csin(cdouble z);
+///
+cfloat  csinf(cfloat z);
+///
+creal   csinl(creal z);
+
+///
+cdouble ctan(cdouble z);
+///
+cfloat  ctanf(cfloat z);
+///
+creal   ctanl(creal z);
+
+///
+cdouble cacosh(cdouble z);
+///
+cfloat  cacoshf(cfloat z);
+///
+creal   cacoshl(creal z);
+
+///
+cdouble casinh(cdouble z);
+///
+cfloat  casinhf(cfloat z);
+///
+creal   casinhl(creal z);
+
+///
+cdouble catanh(cdouble z);
+///
+cfloat  catanhf(cfloat z);
+///
+creal   catanhl(creal z);
+
+///
+cdouble ccosh(cdouble z);
+///
+cfloat  ccoshf(cfloat z);
+///
+creal   ccoshl(creal z);
+
+///
+cdouble csinh(cdouble z);
+///
+cfloat  csinhf(cfloat z);
+///
+creal   csinhl(creal z);
+
+///
+cdouble ctanh(cdouble z);
+///
+cfloat  ctanhf(cfloat z);
+///
+creal   ctanhl(creal z);
+
+///
+cdouble cexp(cdouble z);
+///
+cfloat  cexpf(cfloat z);
+///
+creal   cexpl(creal z);
+
+///
+cdouble clog(cdouble z);
+///
+cfloat  clogf(cfloat z);
+///
+creal   clogl(creal z);
+
+///
+ double cabs(cdouble z);
+ ///
+ float  cabsf(cfloat z);
+ ///
+ real   cabsl(creal z);
+
+ ///
+cdouble cpow(cdouble x, cdouble y);
+///
+cfloat  cpowf(cfloat x, cfloat y);
+///
+creal   cpowl(creal x, creal y);
+
+///
+cdouble csqrt(cdouble z);
+///
+cfloat  csqrtf(cfloat z);
+///
+creal   csqrtl(creal z);
+
+///
+ double carg(cdouble z);
+ ///
+ float  cargf(cfloat z);
+ ///
+ real   cargl(creal z);
+
+ ///
+ double cimag(cdouble z);
+ ///
+ float  cimagf(cfloat z);
+ ///
+ real   cimagl(creal z);
+
+ ///
+cdouble conj(cdouble z);
+///
+cfloat  conjf(cfloat z);
+///
+creal   conjl(creal z);
+
+///
+cdouble cproj(cdouble z);
+///
+cfloat  cprojf(cfloat z);
+///
+creal   cprojl(creal z);
+
+// double creal(cdouble z);
+///
+ float  crealf(cfloat z);
+ ///
+ real   creall(creal z);
diff --git a/libphobos/libdruntime/core/stdc/config.d b/libphobos/libdruntime/core/stdc/config.d
new file mode 100644
index 00000000000..119ebe4401d
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/config.d
@@ -0,0 +1,151 @@
+/**
+ * D header file for C99.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_config.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module core.stdc.config;
+
+extern (C):
+@trusted: // Types only.
+nothrow:
+@nogc:
+
+version( GNU )
+{
+    import gcc.builtins;
+    alias __builtin_clong c_long;
+    alias __builtin_culong c_ulong;
+}
+else version( Windows )
+{
+    struct __c_long
+    {
+      pure nothrow @nogc @safe:
+        this(int x) { lng = x; }
+        int lng;
+        alias lng this;
+    }
+
+    struct __c_ulong
+    {
+      pure nothrow @nogc @safe:
+        this(uint x) { lng = x; }
+        uint lng;
+        alias lng this;
+    }
+
+    /*
+     * This is cpp_long instead of c_long because:
+     * 1. Implicit casting of an int to __c_long doesn't happen, because D doesn't
+     *    allow constructor calls in implicit conversions.
+     * 2. long lng;
+     *    cast(__c_long)lng;
+     *    does not work because lng has to be implicitly cast to an int in the constructor,
+     *    and since that truncates it is not done.
+     * Both of these break existing code, so until we find a resolution the types are named
+     * cpp_xxxx.
+     */
+
+    alias __c_long   cpp_long;
+    alias __c_ulong  cpp_ulong;
+
+    alias int   c_long;
+    alias uint  c_ulong;
+}
+else version( Posix )
+{
+  static if( (void*).sizeof > int.sizeof )
+  {
+    alias long  c_long;
+    alias ulong c_ulong;
+  }
+  else
+  {
+    struct __c_long
+    {
+      pure nothrow @nogc @safe:
+        this(int x) { lng = x; }
+        int lng;
+        alias lng this;
+    }
+
+    struct __c_ulong
+    {
+      pure nothrow @nogc @safe:
+        this(uint x) { lng = x; }
+        uint lng;
+        alias lng this;
+    }
+
+    alias __c_long   cpp_long;
+    alias __c_ulong  cpp_ulong;
+
+    alias int   c_long;
+    alias uint  c_ulong;
+  }
+}
+
+version( CRuntime_Microsoft )
+{
+    /* long double is 64 bits, not 80 bits, but is mangled differently
+     * than double. To distinguish double from long double, create a wrapper to represent
+     * long double, then recognize that wrapper specially in the compiler
+     * to generate the correct name mangling and correct function call/return
+     * ABI conformance.
+     */
+    struct __c_long_double
+    {
+      pure nothrow @nogc @safe:
+        this(double d) { ld = d; }
+        double ld;
+        alias ld this;
+    }
+
+    alias __c_long_double c_long_double;
+}
+else version( DigitalMars )
+{
+    version( X86 )
+    {
+        alias real c_long_double;
+    }
+    else version( X86_64 )
+    {
+        version( linux )
+            alias real c_long_double;
+        else version( FreeBSD )
+            alias real c_long_double;
+        else version( Solaris )
+            alias real c_long_double;
+        else version( OSX )
+            alias real c_long_double;
+    }
+}
+else version( GNU )
+    alias real c_long_double;
+else version( LDC )
+{
+    version( X86 )
+        alias real c_long_double;
+    else version( X86_64 )
+        alias real c_long_double;
+}
+else version( SDC )
+{
+    version( X86 )
+        alias real c_long_double;
+    else version( X86_64 )
+        alias real c_long_double;
+}
+
+static assert(is(c_long_double), "c_long_double needs to be declared for this platform/architecture.");
diff --git a/libphobos/libdruntime/core/stdc/ctype.d b/libphobos/libdruntime/core/stdc/ctype.d
new file mode 100644
index 00000000000..061ea354f1b
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/ctype.d
@@ -0,0 +1,49 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_ctype.h.html, _ctype.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_ctype.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.ctype;
+
+extern (C):
+@trusted: // All of these operate on integers only.
+nothrow:
+@nogc:
+
+    ///
+pure int isalnum(int c);
+///
+pure int isalpha(int c);
+///
+pure int isblank(int c);
+///
+pure int iscntrl(int c);
+///
+pure int isdigit(int c);
+///
+pure int isgraph(int c);
+///
+pure int islower(int c);
+///
+pure int isprint(int c);
+///
+pure int ispunct(int c);
+///
+pure int isspace(int c);
+///
+pure int isupper(int c);
+///
+pure int isxdigit(int c);
+///
+pure int tolower(int c);
+///
+pure int toupper(int c);
diff --git a/libphobos/libdruntime/core/stdc/errno.d b/libphobos/libdruntime/core/stdc/errno.d
new file mode 100644
index 00000000000..0715e74a95c
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/errno.d
@@ -0,0 +1,1232 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_errno.h.html, _errno.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Source:    $(DRUNTIMESRC core/stdc/_errno.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.errno;
+
+@trusted: // Only manipulates errno.
+nothrow:
+@nogc:
+
+///
+@property int errno() { return getErrno(); }
+///
+@property int errno(int n) { return setErrno(n); }
+
+extern (C):
+
+private extern (C) int getErrno();      // for internal use
+private extern (C) int setErrno(int);   // for internal use
+
+version( Windows )
+{
+    enum EPERM              = 1;        /// Operation not permitted
+    enum ENOENT             = 2;        /// No such file or directory
+    enum ESRCH              = 3;        /// No such process
+    enum EINTR              = 4;        /// Interrupted system call
+    enum EIO                = 5;        /// I/O error
+    enum ENXIO              = 6;        /// No such device or address
+    enum E2BIG              = 7;        /// Argument list too long
+    enum ENOEXEC            = 8;        /// Exec format error
+    enum EBADF              = 9;        /// Bad file number
+    enum ECHILD             = 10;       /// No child processes
+    enum EAGAIN             = 11;       /// Try again
+    enum ENOMEM             = 12;       /// Out of memory
+    enum EACCES             = 13;       /// Permission denied
+    enum EFAULT             = 14;       /// Bad address
+    enum EBUSY              = 16;       /// Device or resource busy
+    enum EEXIST             = 17;       /// File exists
+    enum EXDEV              = 18;       /// Cross-device link
+    enum ENODEV             = 19;       /// No such device
+    enum ENOTDIR            = 20;       /// Not a directory
+    enum EISDIR             = 21;       /// Is a directory
+    enum EINVAL             = 22;       /// Invalid argument
+    enum ENFILE             = 23;       /// File table overflow
+    enum EMFILE             = 24;       /// Too many open files
+    enum ENOTTY             = 25;       /// Not a typewriter
+    enum EFBIG              = 27;       /// File too large
+    enum ENOSPC             = 28;       /// No space left on device
+    enum ESPIPE             = 29;       /// Illegal seek
+    enum EROFS              = 30;       /// Read-only file system
+    enum EMLINK             = 31;       /// Too many links
+    enum EPIPE              = 32;       /// Broken pipe
+    enum EDOM               = 33;       /// Math argument out of domain of func
+    enum ERANGE             = 34;       /// Math result not representable
+    enum EDEADLK            = 36;       /// Resource deadlock would occur
+    enum ENAMETOOLONG       = 38;       /// File name too long
+    enum ENOLCK             = 39;       /// No record locks available
+    enum ENOSYS             = 40;       /// Function not implemented
+    enum ENOTEMPTY          = 41;       /// Directory not empty
+    enum EILSEQ             = 42;       /// Illegal byte sequence
+    enum EDEADLOCK          = EDEADLK;  /// Resource deadlock would occur
+}
+else version( linux )
+{
+    enum EPERM              = 1;  ///
+    enum ENOENT             = 2;  ///
+    enum ESRCH              = 3;  ///
+    enum EINTR              = 4;  ///
+    enum EIO                = 5;  ///
+    enum ENXIO              = 6;  ///
+    enum E2BIG              = 7;  ///
+    enum ENOEXEC            = 8;  ///
+    enum EBADF              = 9;  ///
+    enum ECHILD             = 10; ///
+    enum EAGAIN             = 11; ///
+    enum ENOMEM             = 12; ///
+    enum EACCES             = 13; ///
+    enum EFAULT             = 14; ///
+    enum ENOTBLK            = 15; ///
+    enum EBUSY              = 16; ///
+    enum EEXIST             = 17; ///
+    enum EXDEV              = 18; ///
+    enum ENODEV             = 19; ///
+    enum ENOTDIR            = 20; ///
+    enum EISDIR             = 21; ///
+    enum EINVAL             = 22; ///
+    enum ENFILE             = 23; ///
+    enum EMFILE             = 24; ///
+    enum ENOTTY             = 25; ///
+    enum ETXTBSY            = 26; ///
+    enum EFBIG              = 27; ///
+    enum ENOSPC             = 28; ///
+    enum ESPIPE             = 29; ///
+    enum EROFS              = 30; ///
+    enum EMLINK             = 31; ///
+    enum EPIPE              = 32; ///
+    enum EDOM               = 33; ///
+    enum ERANGE             = 34; ///
+
+    version(X86)
+    {
+        enum EDEADLK            = 35;         ///
+        enum ENAMETOOLONG       = 36;         ///
+        enum ENOLCK             = 37;         ///
+        enum ENOSYS             = 38;         ///
+        enum ENOTEMPTY          = 39;         ///
+        enum ELOOP              = 40;         ///
+        enum EWOULDBLOCK        = EAGAIN;     ///
+        enum ENOMSG             = 42;         ///
+        enum EIDRM              = 43;         ///
+        enum ECHRNG             = 44;         ///
+        enum EL2NSYNC           = 45;         ///
+        enum EL3HLT             = 46;         ///
+        enum EL3RST             = 47;         ///
+        enum ELNRNG             = 48;         ///
+        enum EUNATCH            = 49;         ///
+        enum ENOCSI             = 50;         ///
+        enum EL2HLT             = 51;         ///
+        enum EBADE              = 52;         ///
+        enum EBADR              = 53;         ///
+        enum EXFULL             = 54;         ///
+        enum ENOANO             = 55;         ///
+        enum EBADRQC            = 56;         ///
+        enum EBADSLT            = 57;         ///
+        enum EDEADLOCK          = EDEADLK;    ///
+        enum EBFONT             = 59;         ///
+        enum ENOSTR             = 60;         ///
+        enum ENODATA            = 61;         ///
+        enum ETIME              = 62;         ///
+        enum ENOSR              = 63;         ///
+        enum ENONET             = 64;         ///
+        enum ENOPKG             = 65;         ///
+        enum EREMOTE            = 66;         ///
+        enum ENOLINK            = 67;         ///
+        enum EADV               = 68;         ///
+        enum ESRMNT             = 69;         ///
+        enum ECOMM              = 70;         ///
+        enum EPROTO             = 71;         ///
+        enum EMULTIHOP          = 72;         ///
+        enum EDOTDOT            = 73;         ///
+        enum EBADMSG            = 74;         ///
+        enum EOVERFLOW          = 75;         ///
+        enum ENOTUNIQ           = 76;         ///
+        enum EBADFD             = 77;         ///
+        enum EREMCHG            = 78;         ///
+        enum ELIBACC            = 79;         ///
+        enum ELIBBAD            = 80;         ///
+        enum ELIBSCN            = 81;         ///
+        enum ELIBMAX            = 82;         ///
+        enum ELIBEXEC           = 83;         ///
+        enum EILSEQ             = 84;         ///
+        enum ERESTART           = 85;         ///
+        enum ESTRPIPE           = 86;         ///
+        enum EUSERS             = 87;         ///
+        enum ENOTSOCK           = 88;         ///
+        enum EDESTADDRREQ       = 89;         ///
+        enum EMSGSIZE           = 90;         ///
+        enum EPROTOTYPE         = 91;         ///
+        enum ENOPROTOOPT        = 92;         ///
+        enum EPROTONOSUPPORT    = 93;         ///
+        enum ESOCKTNOSUPPORT    = 94;         ///
+        enum EOPNOTSUPP         = 95;         ///
+        enum ENOTSUP            = EOPNOTSUPP; ///
+        enum EPFNOSUPPORT       = 96;         ///
+        enum EAFNOSUPPORT       = 97;         ///
+        enum EADDRINUSE         = 98;         ///
+        enum EADDRNOTAVAIL      = 99;         ///
+        enum ENETDOWN           = 100;        ///
+        enum ENETUNREACH        = 101;        ///
+        enum ENETRESET          = 102;        ///
+        enum ECONNABORTED       = 103;        ///
+        enum ECONNRESET         = 104;        ///
+        enum ENOBUFS            = 105;        ///
+        enum EISCONN            = 106;        ///
+        enum ENOTCONN           = 107;        ///
+        enum ESHUTDOWN          = 108;        ///
+        enum ETOOMANYREFS       = 109;        ///
+        enum ETIMEDOUT          = 110;        ///
+        enum ECONNREFUSED       = 111;        ///
+        enum EHOSTDOWN          = 112;        ///
+        enum EHOSTUNREACH       = 113;        ///
+        enum EALREADY           = 114;        ///
+        enum EINPROGRESS        = 115;        ///
+        enum ESTALE             = 116;        ///
+        enum EUCLEAN            = 117;        ///
+        enum ENOTNAM            = 118;        ///
+        enum ENAVAIL            = 119;        ///
+        enum EISNAM             = 120;        ///
+        enum EREMOTEIO          = 121;        ///
+        enum EDQUOT             = 122;        ///
+        enum ENOMEDIUM          = 123;        ///
+        enum EMEDIUMTYPE        = 124;        ///
+        enum ECANCELED          = 125;        ///
+        enum ENOKEY             = 126;        ///
+        enum EKEYEXPIRED        = 127;        ///
+        enum EKEYREVOKED        = 128;        ///
+        enum EKEYREJECTED       = 129;        ///
+        enum EOWNERDEAD         = 130;        ///
+        enum ENOTRECOVERABLE    = 131;        ///
+    }
+    else version(X86_64)
+    {
+        enum EDEADLK            = 35;         ///
+        enum ENAMETOOLONG       = 36;         ///
+        enum ENOLCK             = 37;         ///
+        enum ENOSYS             = 38;         ///
+        enum ENOTEMPTY          = 39;         ///
+        enum ELOOP              = 40;         ///
+        enum EWOULDBLOCK        = EAGAIN;     ///
+        enum ENOMSG             = 42;         ///
+        enum EIDRM              = 43;         ///
+        enum ECHRNG             = 44;         ///
+        enum EL2NSYNC           = 45;         ///
+        enum EL3HLT             = 46;         ///
+        enum EL3RST             = 47;         ///
+        enum ELNRNG             = 48;         ///
+        enum EUNATCH            = 49;         ///
+        enum ENOCSI             = 50;         ///
+        enum EL2HLT             = 51;         ///
+        enum EBADE              = 52;         ///
+        enum EBADR              = 53;         ///
+        enum EXFULL             = 54;         ///
+        enum ENOANO             = 55;         ///
+        enum EBADRQC            = 56;         ///
+        enum EBADSLT            = 57;         ///
+        enum EDEADLOCK          = EDEADLK;    ///
+        enum EBFONT             = 59;         ///
+        enum ENOSTR             = 60;         ///
+        enum ENODATA            = 61;         ///
+        enum ETIME              = 62;         ///
+        enum ENOSR              = 63;         ///
+        enum ENONET             = 64;         ///
+        enum ENOPKG             = 65;         ///
+        enum EREMOTE            = 66;         ///
+        enum ENOLINK            = 67;         ///
+        enum EADV               = 68;         ///
+        enum ESRMNT             = 69;         ///
+        enum ECOMM              = 70;         ///
+        enum EPROTO             = 71;         ///
+        enum EMULTIHOP          = 72;         ///
+        enum EDOTDOT            = 73;         ///
+        enum EBADMSG            = 74;         ///
+        enum EOVERFLOW          = 75;         ///
+        enum ENOTUNIQ           = 76;         ///
+        enum EBADFD             = 77;         ///
+        enum EREMCHG            = 78;         ///
+        enum ELIBACC            = 79;         ///
+        enum ELIBBAD            = 80;         ///
+        enum ELIBSCN            = 81;         ///
+        enum ELIBMAX            = 82;         ///
+        enum ELIBEXEC           = 83;         ///
+        enum EILSEQ             = 84;         ///
+        enum ERESTART           = 85;         ///
+        enum ESTRPIPE           = 86;         ///
+        enum EUSERS             = 87;         ///
+        enum ENOTSOCK           = 88;         ///
+        enum EDESTADDRREQ       = 89;         ///
+        enum EMSGSIZE           = 90;         ///
+        enum EPROTOTYPE         = 91;         ///
+        enum ENOPROTOOPT        = 92;         ///
+        enum EPROTONOSUPPORT    = 93;         ///
+        enum ESOCKTNOSUPPORT    = 94;         ///
+        enum EOPNOTSUPP         = 95;         ///
+        enum ENOTSUP            = EOPNOTSUPP; ///
+        enum EPFNOSUPPORT       = 96;         ///
+        enum EAFNOSUPPORT       = 97;         ///
+        enum EADDRINUSE         = 98;         ///
+        enum EADDRNOTAVAIL      = 99;         ///
+        enum ENETDOWN           = 100;        ///
+        enum ENETUNREACH        = 101;        ///
+        enum ENETRESET          = 102;        ///
+        enum ECONNABORTED       = 103;        ///
+        enum ECONNRESET         = 104;        ///
+        enum ENOBUFS            = 105;        ///
+        enum EISCONN            = 106;        ///
+        enum ENOTCONN           = 107;        ///
+        enum ESHUTDOWN          = 108;        ///
+        enum ETOOMANYREFS       = 109;        ///
+        enum ETIMEDOUT          = 110;        ///
+        enum ECONNREFUSED       = 111;        ///
+        enum EHOSTDOWN          = 112;        ///
+        enum EHOSTUNREACH       = 113;        ///
+        enum EALREADY           = 114;        ///
+        enum EINPROGRESS        = 115;        ///
+        enum ESTALE             = 116;        ///
+        enum EUCLEAN            = 117;        ///
+        enum ENOTNAM            = 118;        ///
+        enum ENAVAIL            = 119;        ///
+        enum EISNAM             = 120;        ///
+        enum EREMOTEIO          = 121;        ///
+        enum EDQUOT             = 122;        ///
+        enum ENOMEDIUM          = 123;        ///
+        enum EMEDIUMTYPE        = 124;        ///
+        enum ECANCELED          = 125;        ///
+        enum ENOKEY             = 126;        ///
+        enum EKEYEXPIRED        = 127;        ///
+        enum EKEYREVOKED        = 128;        ///
+        enum EKEYREJECTED       = 129;        ///
+        enum EOWNERDEAD         = 130;        ///
+        enum ENOTRECOVERABLE    = 131;        ///
+    }
+    else version(ARM)
+    {
+        enum EDEADLK            = 35;         ///
+        enum ENAMETOOLONG       = 36;         ///
+        enum ENOLCK             = 37;         ///
+        enum ENOSYS             = 38;         ///
+        enum ENOTEMPTY          = 39;         ///
+        enum ELOOP              = 40;         ///
+        enum EWOULDBLOCK        = EAGAIN;     ///
+        enum ENOMSG             = 42;         ///
+        enum EIDRM              = 43;         ///
+        enum ECHRNG             = 44;         ///
+        enum EL2NSYNC           = 45;         ///
+        enum EL3HLT             = 46;         ///
+        enum EL3RST             = 47;         ///
+        enum ELNRNG             = 48;         ///
+        enum EUNATCH            = 49;         ///
+        enum ENOCSI             = 50;         ///
+        enum EL2HLT             = 51;         ///
+        enum EBADE              = 52;         ///
+        enum EBADR              = 53;         ///
+        enum EXFULL             = 54;         ///
+        enum ENOANO             = 55;         ///
+        enum EBADRQC            = 56;         ///
+        enum EBADSLT            = 57;         ///
+        enum EDEADLOCK          = EDEADLK;    ///
+        enum EBFONT             = 59;         ///
+        enum ENOSTR             = 60;         ///
+        enum ENODATA            = 61;         ///
+        enum ETIME              = 62;         ///
+        enum ENOSR              = 63;         ///
+        enum ENONET             = 64;         ///
+        enum ENOPKG             = 65;         ///
+        enum EREMOTE            = 66;         ///
+        enum ENOLINK            = 67;         ///
+        enum EADV               = 68;         ///
+        enum ESRMNT             = 69;         ///
+        enum ECOMM              = 70;         ///
+        enum EPROTO             = 71;         ///
+        enum EMULTIHOP          = 72;         ///
+        enum EDOTDOT            = 73;         ///
+        enum EBADMSG            = 74;         ///
+        enum EOVERFLOW          = 75;         ///
+        enum ENOTUNIQ           = 76;         ///
+        enum EBADFD             = 77;         ///
+        enum EREMCHG            = 78;         ///
+        enum ELIBACC            = 79;         ///
+        enum ELIBBAD            = 80;         ///
+        enum ELIBSCN            = 81;         ///
+        enum ELIBMAX            = 82;         ///
+        enum ELIBEXEC           = 83;         ///
+        enum EILSEQ             = 84;         ///
+        enum ERESTART           = 85;         ///
+        enum ESTRPIPE           = 86;         ///
+        enum EUSERS             = 87;         ///
+        enum ENOTSOCK           = 88;         ///
+        enum EDESTADDRREQ       = 89;         ///
+        enum EMSGSIZE           = 90;         ///
+        enum EPROTOTYPE         = 91;         ///
+        enum ENOPROTOOPT        = 92;         ///
+        enum EPROTONOSUPPORT    = 93;         ///
+        enum ESOCKTNOSUPPORT    = 94;         ///
+        enum EOPNOTSUPP         = 95;         ///
+        enum ENOTSUP            = EOPNOTSUPP; ///
+        enum EPFNOSUPPORT       = 96;         ///
+        enum EAFNOSUPPORT       = 97;         ///
+        enum EADDRINUSE         = 98;         ///
+        enum EADDRNOTAVAIL      = 99;         ///
+        enum ENETDOWN           = 100;        ///
+        enum ENETUNREACH        = 101;        ///
+        enum ENETRESET          = 102;        ///
+        enum ECONNABORTED       = 103;        ///
+        enum ECONNRESET         = 104;        ///
+        enum ENOBUFS            = 105;        ///
+        enum EISCONN            = 106;        ///
+        enum ENOTCONN           = 107;        ///
+        enum ESHUTDOWN          = 108;        ///
+        enum ETOOMANYREFS       = 109;        ///
+        enum ETIMEDOUT          = 110;        ///
+        enum ECONNREFUSED       = 111;        ///
+        enum EHOSTDOWN          = 112;        ///
+        enum EHOSTUNREACH       = 113;        ///
+        enum EALREADY           = 114;        ///
+        enum EINPROGRESS        = 115;        ///
+        enum ESTALE             = 116;        ///
+        enum EUCLEAN            = 117;        ///
+        enum ENOTNAM            = 118;        ///
+        enum ENAVAIL            = 119;        ///
+        enum EISNAM             = 120;        ///
+        enum EREMOTEIO          = 121;        ///
+        enum EDQUOT             = 122;        ///
+        enum ENOMEDIUM          = 123;        ///
+        enum EMEDIUMTYPE        = 124;        ///
+        enum ECANCELED          = 125;        ///
+        enum ENOKEY             = 126;        ///
+        enum EKEYEXPIRED        = 127;        ///
+        enum EKEYREVOKED        = 128;        ///
+        enum EKEYREJECTED       = 129;        ///
+        enum EOWNERDEAD         = 130;        ///
+        enum ENOTRECOVERABLE    = 131;        ///
+    }
+    else version(AArch64)
+    {
+        enum EDEADLK            = 35;         ///
+        enum ENAMETOOLONG       = 36;         ///
+        enum ENOLCK             = 37;         ///
+        enum ENOSYS             = 38;         ///
+        enum ENOTEMPTY          = 39;         ///
+        enum ELOOP              = 40;         ///
+        enum EWOULDBLOCK        = EAGAIN;     ///
+        enum ENOMSG             = 42;         ///
+        enum EIDRM              = 43;         ///
+        enum ECHRNG             = 44;         ///
+        enum EL2NSYNC           = 45;         ///
+        enum EL3HLT             = 46;         ///
+        enum EL3RST             = 47;         ///
+        enum ELNRNG             = 48;         ///
+        enum EUNATCH            = 49;         ///
+        enum ENOCSI             = 50;         ///
+        enum EL2HLT             = 51;         ///
+        enum EBADE              = 52;         ///
+        enum EBADR              = 53;         ///
+        enum EXFULL             = 54;         ///
+        enum ENOANO             = 55;         ///
+        enum EBADRQC            = 56;         ///
+        enum EBADSLT            = 57;         ///
+        enum EDEADLOCK          = EDEADLK;    ///
+        enum EBFONT             = 59;         ///
+        enum ENOSTR             = 60;         ///
+        enum ENODATA            = 61;         ///
+        enum ETIME              = 62;         ///
+        enum ENOSR              = 63;         ///
+        enum ENONET             = 64;         ///
+        enum ENOPKG             = 65;         ///
+        enum EREMOTE            = 66;         ///
+        enum ENOLINK            = 67;         ///
+        enum EADV               = 68;         ///
+        enum ESRMNT             = 69;         ///
+        enum ECOMM              = 70;         ///
+        enum EPROTO             = 71;         ///
+        enum EMULTIHOP          = 72;         ///
+        enum EDOTDOT            = 73;         ///
+        enum EBADMSG            = 74;         ///
+        enum EOVERFLOW          = 75;         ///
+        enum ENOTUNIQ           = 76;         ///
+        enum EBADFD             = 77;         ///
+        enum EREMCHG            = 78;         ///
+        enum ELIBACC            = 79;         ///
+        enum ELIBBAD            = 80;         ///
+        enum ELIBSCN            = 81;         ///
+        enum ELIBMAX            = 82;         ///
+        enum ELIBEXEC           = 83;         ///
+        enum EILSEQ             = 84;         ///
+        enum ERESTART           = 85;         ///
+        enum ESTRPIPE           = 86;         ///
+        enum EUSERS             = 87;         ///
+        enum ENOTSOCK           = 88;         ///
+        enum EDESTADDRREQ       = 89;         ///
+        enum EMSGSIZE           = 90;         ///
+        enum EPROTOTYPE         = 91;         ///
+        enum ENOPROTOOPT        = 92;         ///
+        enum EPROTONOSUPPORT    = 93;         ///
+        enum ESOCKTNOSUPPORT    = 94;         ///
+        enum EOPNOTSUPP         = 95;         ///
+        enum EPFNOSUPPORT       = 96;         ///
+        enum EAFNOSUPPORT       = 97;         ///
+        enum EADDRINUSE         = 98;         ///
+        enum EADDRNOTAVAIL      = 99;         ///
+        enum ENETDOWN           = 100;        ///
+        enum ENETUNREACH        = 101;        ///
+        enum ENETRESET          = 102;        ///
+        enum ECONNABORTED       = 103;        ///
+        enum ECONNRESET         = 104;        ///
+        enum ENOBUFS            = 105;        ///
+        enum EISCONN            = 106;        ///
+        enum ENOTCONN           = 107;        ///
+        enum ESHUTDOWN          = 108;        ///
+        enum ETOOMANYREFS       = 109;        ///
+        enum ETIMEDOUT          = 110;        ///
+        enum ECONNREFUSED       = 111;        ///
+        enum EHOSTDOWN          = 112;        ///
+        enum EHOSTUNREACH       = 113;        ///
+        enum EALREADY           = 114;        ///
+        enum EINPROGRESS        = 115;        ///
+        enum ESTALE             = 116;        ///
+        enum EUCLEAN            = 117;        ///
+        enum ENOTNAM            = 118;        ///
+        enum ENAVAIL            = 119;        ///
+        enum EISNAM             = 120;        ///
+        enum EREMOTEIO          = 121;        ///
+        enum EDQUOT             = 122;        ///
+        enum ENOMEDIUM          = 123;        ///
+        enum EMEDIUMTYPE        = 124;        ///
+        enum ECANCELED          = 125;        ///
+        enum ENOKEY             = 126;        ///
+        enum EKEYEXPIRED        = 127;        ///
+        enum EKEYREVOKED        = 128;        ///
+        enum EKEYREJECTED       = 129;        ///
+        enum EOWNERDEAD         = 130;        ///
+        enum ERFKILL            = 132;        ///
+        enum EHWPOISON          = 133;        ///
+    }
+    else version(MIPS64)
+    {
+        enum ENOMSG             = 35;         ///
+        enum EIDRM              = 36;         ///
+        enum ECHRNG             = 37;         ///
+        enum EL2NSYNC           = 38;         ///
+        enum EL3HLT             = 39;         ///
+        enum EL3RST             = 40;         ///
+        enum ELNRNG             = 41;         ///
+        enum EUNATCH            = 42;         ///
+        enum ENOCSI             = 43;         ///
+        enum EL2HLT             = 44;         ///
+        enum EDEADLK            = 45;         ///
+        enum ENOLCK             = 46;         ///
+        enum EBADE              = 50;         ///
+        enum EBADR              = 51;         ///
+        enum EXFULL             = 52;         ///
+        enum ENOANO             = 53;         ///
+        enum EBADRQC            = 54;         ///
+        enum EBADSLT            = 55;         ///
+        enum EDEADLOCK          = 56;         ///
+        enum EBFONT             = 59;         ///
+        enum ENOSTR             = 60;         ///
+        enum ENODATA            = 61;         ///
+        enum ETIME              = 62;         ///
+        enum ENOSR              = 63;         ///
+        enum ENONET             = 64;         ///
+        enum ENOPKG             = 65;         ///
+        enum EREMOTE            = 66;         ///
+        enum ENOLINK            = 67;         ///
+        enum EADV               = 68;         ///
+        enum ESRMNT             = 69;         ///
+        enum ECOMM              = 70;         ///
+        enum EPROTO             = 71;         ///
+        enum EDOTDOT            = 73;         ///
+        enum EMULTIHOP          = 74;         ///
+        enum EBADMSG            = 77;         ///
+        enum ENAMETOOLONG       = 78;         ///
+        enum EOVERFLOW          = 79;         ///
+        enum ENOTUNIQ           = 80;         ///
+        enum EBADFD             = 81;         ///
+        enum EREMCHG            = 82;         ///
+        enum ELIBACC            = 83;         ///
+        enum ELIBBAD            = 84;         ///
+        enum ELIBSCN            = 85;         ///
+        enum ELIBMAX            = 86;         ///
+        enum ELIBEXEC           = 87;         ///
+        enum EILSEQ             = 88;         ///
+        enum ENOSYS             = 89;         ///
+        enum ELOOP              = 90;         ///
+        enum ERESTART           = 91;         ///
+        enum ESTRPIPE           = 92;         ///
+        enum ENOTEMPTY          = 93;         ///
+        enum EUSERS             = 94;         ///
+        enum ENOTSOCK           = 95;         ///
+        enum EDESTADDRREQ       = 96;         ///
+        enum EMSGSIZE           = 97;         ///
+        enum EPROTOTYPE         = 98;         ///
+        enum ENOPROTOOPT        = 99;         ///
+        enum EPROTONOSUPPORT    = 120;        ///
+        enum ESOCKTNOSUPPORT    = 121;        ///
+        enum EOPNOTSUPP         = 122;        ///
+        enum EPFNOSUPPORT       = 123;        ///
+        enum EAFNOSUPPORT       = 124;        ///
+        enum EADDRINUSE         = 125;        ///
+        enum EADDRNOTAVAIL      = 126;        ///
+        enum ENETDOWN           = 127;        ///
+        enum ENETUNREACH        = 128;        ///
+        enum ENETRESET          = 129;        ///
+        enum ECONNABORTED       = 130;        ///
+        enum ECONNRESET         = 131;        ///
+        enum ENOBUFS            = 132;        ///
+        enum EISCONN            = 133;        ///
+        enum ENOTCONN           = 134;        ///
+        enum EUCLEAN            = 135;        ///
+        enum ENOTNAM            = 137;        ///
+        enum ENAVAIL            = 138;        ///
+        enum EISNAM             = 139;        ///
+        enum EREMOTEIO          = 140;        ///
+        enum EINIT              = 141;        ///
+        enum EREMDEV            = 142;        ///
+        enum ESHUTDOWN          = 143;        ///
+        enum ETOOMANYREFS       = 144;        ///
+        enum ETIMEDOUT          = 145;        ///
+        enum ECONNREFUSED       = 146;        ///
+        enum EHOSTDOWN          = 147;        ///
+        enum EHOSTUNREACH       = 148;        ///
+        enum EWOULDBLOCK        = EAGAIN;     ///
+        enum EALREADY           = 149;        ///
+        enum EINPROGRESS        = 150;        ///
+        enum ESTALE             = 151;        ///
+        enum ECANCELED          = 158;        ///
+        enum ENOMEDIUM          = 159;        ///
+        enum EMEDIUMTYPE        = 160;        ///
+        enum ENOKEY             = 161;        ///
+        enum EKEYEXPIRED        = 162;        ///
+        enum EKEYREVOKED        = 163;        ///
+        enum EKEYREJECTED       = 164;        ///
+        enum EOWNERDEAD         = 165;        ///
+        enum ENOTRECOVERABLE    = 166;        ///
+        enum ERFKILL            = 167;        ///
+        enum EHWPOISON          = 168;        ///
+        enum EDQUOT             = 1133;       ///
+    }
+    else version(PPC)
+    {
+        enum EDEADLK            = 35;         ///
+        enum ENAMETOOLONG       = 36;         ///
+        enum ENOLCK             = 37;         ///
+        enum ENOSYS             = 38;         ///
+        enum ENOTEMPTY          = 39;         ///
+        enum ELOOP              = 40;         ///
+        enum EWOULDBLOCK        = EAGAIN;     ///
+        enum ENOMSG             = 42;         ///
+        enum EIDRM              = 43;         ///
+        enum ECHRNG             = 44;         ///
+        enum EL2NSYNC           = 45;         ///
+        enum EL3HLT             = 46;         ///
+        enum EL3RST             = 47;         ///
+        enum ELNRNG             = 48;         ///
+        enum EUNATCH            = 49;         ///
+        enum ENOCSI             = 50;         ///
+        enum EL2HLT             = 51;         ///
+        enum EBADE              = 52;         ///
+        enum EBADR              = 53;         ///
+        enum EXFULL             = 54;         ///
+        enum ENOANO             = 55;         ///
+        enum EBADRQC            = 56;         ///
+        enum EBADSLT            = 57;         ///
+        enum EDEADLOCK          = EDEADLK;    ///
+        enum EBFONT             = 59;         ///
+        enum ENOSTR             = 60;         ///
+        enum ENODATA            = 61;         ///
+        enum ETIME              = 62;         ///
+        enum ENOSR              = 63;         ///
+        enum ENONET             = 64;         ///
+        enum ENOPKG             = 65;         ///
+        enum EREMOTE            = 66;         ///
+        enum ENOLINK            = 67;         ///
+        enum EADV               = 68;         ///
+        enum ESRMNT             = 69;         ///
+        enum ECOMM              = 70;         ///
+        enum EPROTO             = 71;         ///
+        enum EMULTIHOP          = 72;         ///
+        enum EDOTDOT            = 73;         ///
+        enum EBADMSG            = 74;         ///
+        enum EOVERFLOW          = 75;         ///
+        enum ENOTUNIQ           = 76;         ///
+        enum EBADFD             = 77;         ///
+        enum EREMCHG            = 78;         ///
+        enum ELIBACC            = 79;         ///
+        enum ELIBBAD            = 80;         ///
+        enum ELIBSCN            = 81;         ///
+        enum ELIBMAX            = 82;         ///
+        enum ELIBEXEC           = 83;         ///
+        enum EILSEQ             = 84;         ///
+        enum ERESTART           = 85;         ///
+        enum ESTRPIPE           = 86;         ///
+        enum EUSERS             = 87;         ///
+        enum ENOTSOCK           = 88;         ///
+        enum EDESTADDRREQ       = 89;         ///
+        enum EMSGSIZE           = 90;         ///
+        enum EPROTOTYPE         = 91;         ///
+        enum ENOPROTOOPT        = 92;         ///
+        enum EPROTONOSUPPORT    = 93;         ///
+        enum ESOCKTNOSUPPORT    = 94;         ///
+        enum EOPNOTSUPP         = 95;         ///
+        enum EPFNOSUPPORT       = 96;         ///
+        enum EAFNOSUPPORT       = 97;         ///
+        enum EADDRINUSE         = 98;         ///
+        enum EADDRNOTAVAIL      = 99;         ///
+        enum ENETDOWN           = 100;        ///
+        enum ENETUNREACH        = 101;        ///
+        enum ENETRESET          = 102;        ///
+        enum ECONNABORTED       = 103;        ///
+        enum ECONNRESET         = 104;        ///
+        enum ENOBUFS            = 105;        ///
+        enum EISCONN            = 106;        ///
+        enum ENOTCONN           = 107;        ///
+        enum ESHUTDOWN          = 108;        ///
+        enum ETOOMANYREFS       = 109;        ///
+        enum ETIMEDOUT          = 110;        ///
+        enum ECONNREFUSED       = 111;        ///
+        enum EHOSTDOWN          = 112;        ///
+        enum EHOSTUNREACH       = 113;        ///
+        enum EALREADY           = 114;        ///
+        enum EINPROGRESS        = 115;        ///
+        enum ESTALE             = 116;        ///
+        enum EUCLEAN            = 117;        ///
+        enum ENOTNAM            = 118;        ///
+        enum ENAVAIL            = 119;        ///
+        enum EISNAM             = 120;        ///
+        enum EREMOTEIO          = 121;        ///
+        enum EDQUOT             = 122;        ///
+        enum ENOMEDIUM          = 123;        ///
+        enum EMEDIUMTYPE        = 124;        ///
+        enum ECANCELED          = 125;        ///
+        enum ENOKEY             = 126;        ///
+        enum EKEYEXPIRED        = 127;        ///
+        enum EKEYREVOKED        = 128;        ///
+        enum EKEYREJECTED       = 129;        ///
+        enum EOWNERDEAD         = 130;        ///
+        enum ERFKILL            = 132;        ///
+        enum EHWPOISON          = 133;        ///
+    }
+    else version(PPC64)
+    {
+        enum EDEADLK            = 35;         ///
+        enum ENAMETOOLONG       = 36;         ///
+        enum ENOLCK             = 37;         ///
+        enum ENOSYS             = 38;         ///
+        enum ENOTEMPTY          = 39;         ///
+        enum ELOOP              = 40;         ///
+        enum EWOULDBLOCK        = EAGAIN;     ///
+        enum ENOMSG             = 42;         ///
+        enum EIDRM              = 43;         ///
+        enum ECHRNG             = 44;         ///
+        enum EL2NSYNC           = 45;         ///
+        enum EL3HLT             = 46;         ///
+        enum EL3RST             = 47;         ///
+        enum ELNRNG             = 48;         ///
+        enum EUNATCH            = 49;         ///
+        enum ENOCSI             = 50;         ///
+        enum EL2HLT             = 51;         ///
+        enum EBADE              = 52;         ///
+        enum EBADR              = 53;         ///
+        enum EXFULL             = 54;         ///
+        enum ENOANO             = 55;         ///
+        enum EBADRQC            = 56;         ///
+        enum EBADSLT            = 57;         ///
+        enum EDEADLOCK          = EDEADLK;    ///
+        enum EBFONT             = 59;         ///
+        enum ENOSTR             = 60;         ///
+        enum ENODATA            = 61;         ///
+        enum ETIME              = 62;         ///
+        enum ENOSR              = 63;         ///
+        enum ENONET             = 64;         ///
+        enum ENOPKG             = 65;         ///
+        enum EREMOTE            = 66;         ///
+        enum ENOLINK            = 67;         ///
+        enum EADV               = 68;         ///
+        enum ESRMNT             = 69;         ///
+        enum ECOMM              = 70;         ///
+        enum EPROTO             = 71;         ///
+        enum EMULTIHOP          = 72;         ///
+        enum EDOTDOT            = 73;         ///
+        enum EBADMSG            = 74;         ///
+        enum EOVERFLOW          = 75;         ///
+        enum ENOTUNIQ           = 76;         ///
+        enum EBADFD             = 77;         ///
+        enum EREMCHG            = 78;         ///
+        enum ELIBACC            = 79;         ///
+        enum ELIBBAD            = 80;         ///
+        enum ELIBSCN            = 81;         ///
+        enum ELIBMAX            = 82;         ///
+        enum ELIBEXEC           = 83;         ///
+        enum EILSEQ             = 84;         ///
+        enum ERESTART           = 85;         ///
+        enum ESTRPIPE           = 86;         ///
+        enum EUSERS             = 87;         ///
+        enum ENOTSOCK           = 88;         ///
+        enum EDESTADDRREQ       = 89;         ///
+        enum EMSGSIZE           = 90;         ///
+        enum EPROTOTYPE         = 91;         ///
+        enum ENOPROTOOPT        = 92;         ///
+        enum EPROTONOSUPPORT    = 93;         ///
+        enum ESOCKTNOSUPPORT    = 94;         ///
+        enum EOPNOTSUPP         = 95;         ///
+        enum EPFNOSUPPORT       = 96;         ///
+        enum EAFNOSUPPORT       = 97;         ///
+        enum EADDRINUSE         = 98;         ///
+        enum EADDRNOTAVAIL      = 99;         ///
+        enum ENETDOWN           = 100;        ///
+        enum ENETUNREACH        = 101;        ///
+        enum ENETRESET          = 102;        ///
+        enum ECONNABORTED       = 103;        ///
+        enum ECONNRESET         = 104;        ///
+        enum ENOBUFS            = 105;        ///
+        enum EISCONN            = 106;        ///
+        enum ENOTCONN           = 107;        ///
+        enum ESHUTDOWN          = 108;        ///
+        enum ETOOMANYREFS       = 109;        ///
+        enum ETIMEDOUT          = 110;        ///
+        enum ECONNREFUSED       = 111;        ///
+        enum EHOSTDOWN          = 112;        ///
+        enum EHOSTUNREACH       = 113;        ///
+        enum EALREADY           = 114;        ///
+        enum EINPROGRESS        = 115;        ///
+        enum ESTALE             = 116;        ///
+        enum EUCLEAN            = 117;        ///
+        enum ENOTNAM            = 118;        ///
+        enum ENAVAIL            = 119;        ///
+        enum EISNAM             = 120;        ///
+        enum EREMOTEIO          = 121;        ///
+        enum EDQUOT             = 122;        ///
+        enum ENOMEDIUM          = 123;        ///
+        enum EMEDIUMTYPE        = 124;        ///
+        enum ECANCELED          = 125;        ///
+        enum ENOKEY             = 126;        ///
+        enum EKEYEXPIRED        = 127;        ///
+        enum EKEYREVOKED        = 128;        ///
+        enum EKEYREJECTED       = 129;        ///
+        enum EOWNERDEAD         = 130;        ///
+        enum ERFKILL            = 132;        ///
+        enum EHWPOISON          = 133;        ///
+    }
+    else version(SystemZ)
+    {
+        enum EDEADLK            = 35;         ///
+        enum ENAMETOOLONG       = 36;         ///
+        enum ENOLCK             = 37;         ///
+        enum ENOSYS             = 38;         ///
+        enum ENOTEMPTY          = 39;         ///
+        enum ELOOP              = 40;         ///
+        enum EWOULDBLOCK        = EAGAIN;     ///
+        enum ENOMSG             = 42;         ///
+        enum EIDRM              = 43;         ///
+        enum ECHRNG             = 44;         ///
+        enum EL2NSYNC           = 45;         ///
+        enum EL3HLT             = 46;         ///
+        enum EL3RST             = 47;         ///
+        enum ELNRNG             = 48;         ///
+        enum EUNATCH            = 49;         ///
+        enum ENOCSI             = 50;         ///
+        enum EL2HLT             = 51;         ///
+        enum EBADE              = 52;         ///
+        enum EBADR              = 53;         ///
+        enum EXFULL             = 54;         ///
+        enum ENOANO             = 55;         ///
+        enum EBADRQC            = 56;         ///
+        enum EBADSLT            = 57;         ///
+        enum EDEADLOCK          = EDEADLK;    ///
+        enum EBFONT             = 59;         ///
+        enum ENOSTR             = 60;         ///
+        enum ENODATA            = 61;         ///
+        enum ETIME              = 62;         ///
+        enum ENOSR              = 63;         ///
+        enum ENONET             = 64;         ///
+        enum ENOPKG             = 65;         ///
+        enum EREMOTE            = 66;         ///
+        enum ENOLINK            = 67;         ///
+        enum EADV               = 68;         ///
+        enum ESRMNT             = 69;         ///
+        enum ECOMM              = 70;         ///
+        enum EPROTO             = 71;         ///
+        enum EMULTIHOP          = 72;         ///
+        enum EDOTDOT            = 73;         ///
+        enum EBADMSG            = 74;         ///
+        enum EOVERFLOW          = 75;         ///
+        enum ENOTUNIQ           = 76;         ///
+        enum EBADFD             = 77;         ///
+        enum EREMCHG            = 78;         ///
+        enum ELIBACC            = 79;         ///
+        enum ELIBBAD            = 80;         ///
+        enum ELIBSCN            = 81;         ///
+        enum ELIBMAX            = 82;         ///
+        enum ELIBEXEC           = 83;         ///
+        enum EILSEQ             = 84;         ///
+        enum ERESTART           = 85;         ///
+        enum ESTRPIPE           = 86;         ///
+        enum EUSERS             = 87;         ///
+        enum ENOTSOCK           = 88;         ///
+        enum EDESTADDRREQ       = 89;         ///
+        enum EMSGSIZE           = 90;         ///
+        enum EPROTOTYPE         = 91;         ///
+        enum ENOPROTOOPT        = 92;         ///
+        enum EPROTONOSUPPORT    = 93;         ///
+        enum ESOCKTNOSUPPORT    = 94;         ///
+        enum EOPNOTSUPP         = 95;         ///
+        enum EPFNOSUPPORT       = 96;         ///
+        enum EAFNOSUPPORT       = 97;         ///
+        enum EADDRINUSE         = 98;         ///
+        enum EADDRNOTAVAIL      = 99;         ///
+        enum ENETDOWN           = 100;        ///
+        enum ENETUNREACH        = 101;        ///
+        enum ENETRESET          = 102;        ///
+        enum ECONNABORTED       = 103;        ///
+        enum ECONNRESET         = 104;        ///
+        enum ENOBUFS            = 105;        ///
+        enum EISCONN            = 106;        ///
+        enum ENOTCONN           = 107;        ///
+        enum ESHUTDOWN          = 108;        ///
+        enum ETOOMANYREFS       = 109;        ///
+        enum ETIMEDOUT          = 110;        ///
+        enum ECONNREFUSED       = 111;        ///
+        enum EHOSTDOWN          = 112;        ///
+        enum EHOSTUNREACH       = 113;        ///
+        enum EALREADY           = 114;        ///
+        enum EINPROGRESS        = 115;        ///
+        enum ESTALE             = 116;        ///
+        enum EUCLEAN            = 117;        ///
+        enum ENOTNAM            = 118;        ///
+        enum ENAVAIL            = 119;        ///
+        enum EISNAM             = 120;        ///
+        enum EREMOTEIO          = 121;        ///
+        enum EDQUOT             = 122;        ///
+        enum ENOMEDIUM          = 123;        ///
+        enum EMEDIUMTYPE        = 124;        ///
+        enum ECANCELED          = 125;        ///
+        enum ENOKEY             = 126;        ///
+        enum EKEYEXPIRED        = 127;        ///
+        enum EKEYREVOKED        = 128;        ///
+        enum EKEYREJECTED       = 129;        ///
+        enum EOWNERDEAD         = 130;        ///
+        enum ERFKILL            = 132;        ///
+        enum EHWPOISON          = 133;        ///
+    }
+    else
+    {
+        static assert(false, "Architecture not supported.");
+    }
+}
+else version( OSX )
+{
+    enum EPERM              = 1;        /// Operation not permitted
+    enum ENOENT             = 2;        /// No such file or directory
+    enum ESRCH              = 3;        /// No such process
+    enum EINTR              = 4;        /// Interrupted system call
+    enum EIO                = 5;        /// Input/output error
+    enum ENXIO              = 6;        /// Device not configured
+    enum E2BIG              = 7;        /// Argument list too long
+    enum ENOEXEC            = 8;        /// Exec format error
+    enum EBADF              = 9;        /// Bad file descriptor
+    enum ECHILD             = 10;       /// No child processes
+    enum EDEADLK            = 11;       /// Resource deadlock avoided
+    enum ENOMEM             = 12;       /// Cannot allocate memory
+    enum EACCES             = 13;       /// Permission denied
+    enum EFAULT             = 14;       /// Bad address
+    enum EBUSY              = 16;       /// Device busy
+    enum EEXIST             = 17;       /// File exists
+    enum EXDEV              = 18;       /// Cross-device link
+    enum ENODEV             = 19;       /// Operation not supported by device
+    enum ENOTDIR            = 20;       /// Not a directory
+    enum EISDIR             = 21;       /// Is a directory
+    enum EINVAL             = 22;       /// Invalid argument
+    enum ENFILE             = 23;       /// Too many open files in system
+    enum EMFILE             = 24;       /// Too many open files
+    enum ENOTTY             = 25;       /// Inappropriate ioctl for device
+    enum ETXTBSY            = 26;       /// Text file busy
+    enum EFBIG              = 27;       /// File too large
+    enum ENOSPC             = 28;       /// No space left on device
+    enum ESPIPE             = 29;       /// Illegal seek
+    enum EROFS              = 30;       /// Read-only file system
+    enum EMLINK             = 31;       /// Too many links
+    enum EPIPE              = 32;       /// Broken pipe
+    enum EDOM               = 33;       /// Numerical argument out of domain
+    enum ERANGE             = 34;       /// Result too large
+    enum EAGAIN             = 35;       /// Resource temporarily unavailable
+    enum EWOULDBLOCK        = EAGAIN;   /// Operation would block
+    enum EINPROGRESS        = 36;       /// Operation now in progress
+    enum EALREADY           = 37;       /// Operation already in progress
+    enum ENOTSOCK           = 38;       /// Socket operation on non-socket
+    enum EDESTADDRREQ       = 39;       /// Destination address required
+    enum EMSGSIZE           = 40;       /// Message too long
+    enum EPROTOTYPE         = 41;       /// Protocol wrong type for socket
+    enum ENOPROTOOPT        = 42;       /// Protocol not available
+    enum EPROTONOSUPPORT    = 43;       /// Protocol not supported
+    enum ENOTSUP            = 45;       /// Operation not supported
+    enum EOPNOTSUPP         = ENOTSUP;  /// Operation not supported on socket
+    enum EAFNOSUPPORT       = 47;       /// Address family not supported by protocol family
+    enum EADDRINUSE         = 48;       /// Address already in use
+    enum EADDRNOTAVAIL      = 49;       /// Can't assign requested address
+    enum ENETDOWN           = 50;       /// Network is down
+    enum ENETUNREACH        = 51;       /// Network is unreachable
+    enum ENETRESET          = 52;       /// Network dropped connection on reset
+    enum ECONNABORTED       = 53;       /// Software caused connection abort
+    enum ECONNRESET         = 54;       /// Connection reset by peer
+    enum ENOBUFS            = 55;       /// No buffer space available
+    enum EISCONN            = 56;       /// Socket is already connected
+    enum ENOTCONN           = 57;       /// Socket is not connected
+    enum ETIMEDOUT          = 60;       /// Operation timed out
+    enum ECONNREFUSED       = 61;       /// Connection refused
+    enum ELOOP              = 62;       /// Too many levels of symbolic links
+    enum ENAMETOOLONG       = 63;       /// File name too long
+    enum EHOSTUNREACH       = 65;       /// No route to host
+    enum ENOTEMPTY          = 66;       /// Directory not empty
+    enum EDQUOT             = 69;       /// Disc quota exceeded
+    enum ESTALE             = 70;       /// Stale NFS file handle
+    enum ENOLCK             = 77;       /// No locks available
+    enum ENOSYS             = 78;       /// Function not implemented
+    enum EOVERFLOW          = 84;       /// Value too large to be stored in data type
+    enum ECANCELED          = 89;       /// Operation canceled
+    enum EIDRM              = 90;       /// Identifier removed
+    enum ENOMSG             = 91;       /// No message of desired type
+    enum EILSEQ             = 92;       /// Illegal byte sequence
+    enum EBADMSG            = 94;       /// Bad message
+    enum EMULTIHOP          = 95;       /// Reserved
+    enum ENODATA            = 96;       /// No message available on STREAM
+    enum ENOLINK            = 97;       /// Reserved
+    enum ENOSR              = 98;       /// No STREAM resources
+    enum ENOSTR             = 99;       /// Not a STREAM
+    enum EPROTO             = 100;      /// Protocol error
+    enum ETIME              = 101;      /// STREAM ioctl timeout
+    enum ELAST              = 101;      /// Must be equal largest errno
+}
+else version( FreeBSD )
+{
+    enum EPERM              = 1;        /// Operation not permitted
+    enum ENOENT             = 2;        /// No such file or directory
+    enum ESRCH              = 3;        /// No such process
+    enum EINTR              = 4;        /// Interrupted system call
+    enum EIO                = 5;        /// Input/output error
+    enum ENXIO              = 6;        /// Device not configured
+    enum E2BIG              = 7;        /// Argument list too long
+    enum ENOEXEC            = 8;        /// Exec format error
+    enum EBADF              = 9;        /// Bad file descriptor
+    enum ECHILD             = 10;       /// No child processes
+    enum EDEADLK            = 11;       /// Resource deadlock avoided
+    enum ENOMEM             = 12;       /// Cannot allocate memory
+    enum EACCES             = 13;       /// Permission denied
+    enum EFAULT             = 14;       /// Bad address
+    enum ENOTBLK            = 15;       /// Block device required
+    enum EBUSY              = 16;       /// Device busy
+    enum EEXIST             = 17;       /// File exists
+    enum EXDEV              = 18;       /// Cross-device link
+    enum ENODEV             = 19;       /// Operation not supported by device
+    enum ENOTDIR            = 20;       /// Not a directory
+    enum EISDIR             = 21;       /// Is a directory
+    enum EINVAL             = 22;       /// Invalid argument
+    enum ENFILE             = 23;       /// Too many open files in system
+    enum EMFILE             = 24;       /// Too many open files
+    enum ENOTTY             = 25;       /// Inappropriate ioctl for device
+    enum ETXTBSY            = 26;       /// Text file busy
+    enum EFBIG              = 27;       /// File too large
+    enum ENOSPC             = 28;       /// No space left on device
+    enum ESPIPE             = 29;       /// Illegal seek
+    enum EROFS              = 30;       /// Read-only file system
+    enum EMLINK             = 31;       /// Too many links
+    enum EPIPE              = 32;       /// Broken pipe
+    enum EDOM               = 33;       /// Numerical argument out of domain
+    enum ERANGE             = 34;       /// Result too large
+    enum EAGAIN             = 35;       /// Resource temporarily unavailable
+    enum EWOULDBLOCK        = EAGAIN;   /// Operation would block
+    enum EINPROGRESS        = 36;       /// Operation now in progress
+    enum EALREADY           = 37;       /// Operation already in progress
+    enum ENOTSOCK           = 38;       /// Socket operation on non-socket
+    enum EDESTADDRREQ       = 39;       /// Destination address required
+    enum EMSGSIZE           = 40;       /// Message too long
+    enum EPROTOTYPE         = 41;       /// Protocol wrong type for socket
+    enum ENOPROTOOPT        = 42;       /// Protocol not available
+    enum EPROTONOSUPPORT    = 43;       /// Protocol not supported
+    enum ENOTSUP            = 45;       /// Operation not supported
+    enum EOPNOTSUPP         = ENOTSUP;  /// Operation not supported on socket
+    enum EAFNOSUPPORT       = 47;       /// Address family not supported by protocol family
+    enum EADDRINUSE         = 48;       /// Address already in use
+    enum EADDRNOTAVAIL      = 49;       /// Can't assign requested address
+    enum ENETDOWN           = 50;       /// Network is down
+    enum ENETUNREACH        = 51;       /// Network is unreachable
+    enum ENETRESET          = 52;       /// Network dropped connection on reset
+    enum ECONNABORTED       = 53;       /// Software caused connection abort
+    enum ECONNRESET         = 54;       /// Connection reset by peer
+    enum ENOBUFS            = 55;       /// No buffer space available
+    enum EISCONN            = 56;       /// Socket is already connected
+    enum ENOTCONN           = 57;       /// Socket is not connected
+    enum ESHUTDOWN          = 58;       /// Can't send after socket shutdown
+    enum ETOOMANYREFS       = 59;       /// Too many refrences; can't splice
+    enum ETIMEDOUT          = 60;       /// Operation timed out
+    enum ECONNREFUSED       = 61;       /// Connection refused
+    enum ELOOP              = 62;       /// Too many levels of symbolic links
+    enum ENAMETOOLONG       = 63;       /// File name too long
+    enum EHOSTUNREACH       = 65;       /// No route to host
+    enum ENOTEMPTY          = 66;       /// Directory not empty
+    enum EPROCLIM           = 67;       /// Too many processes
+    enum EUSERS             = 68;       /// Too many users
+    enum EDQUOT             = 69;       /// Disc quota exceeded
+    enum ESTALE             = 70;       /// Stale NFS file handle
+    enum EREMOTE            = 71;       /// Too many levels of remote in path
+    enum EBADRPC            = 72;       /// RPC struct is bad
+    enum ERPCMISMATCH       = 73;       /// RPC version wrong
+    enum EPROGUNAVAIL       = 74;       /// RPC prog. not avail
+    enum EPROGMISMATCH      = 75;       /// Program version wrong
+    enum EPROCUNAVAIL       = 76;       /// Bad procedure for program
+    enum ENOLCK             = 77;       /// No locks available
+    enum ENOSYS             = 78;       /// Function not implemented
+    enum EFTYPE             = 79;       /// Inappropriate file type or format
+    enum EAUTH              = 80;       /// Authentication error
+    enum ENEEDAUTH          = 81;       /// Need authenticator
+    enum EIDRM              = 82;       /// Itendifier removed
+    enum ENOMSG             = 83;       /// No message of desired type
+    enum EOVERFLOW          = 84;       /// Value too large to be stored in data type
+    enum ECANCELED          = 85;       /// Operation canceled
+    enum EILSEQ             = 86;       /// Illegal byte sequence
+    enum ENOATTR            = 87;       /// Attribute not found
+    enum EDOOFUS            = 88;       /// Programming error
+    enum EBADMSG            = 89;       /// Bad message
+    enum EMULTIHOP          = 90;       /// Multihop attempted
+    enum ENOLINK            = 91;       /// Link has been severed
+    enum EPROTO             = 92;       /// Protocol error
+    enum ELAST              = 92;       /// Must be equal largest errno
+}
+else version (Solaris)
+{
+    enum EPERM =  1       /** Not super-user                       */;
+    enum ENOENT = 2       /** No such file or directory            */;
+    enum ESRCH =  3       /** No such process                      */;
+    enum EINTR =  4       /** interrupted system call              */;
+    enum EIO =    5       /** I/O error                            */;
+    enum ENXIO =  6       /** No such device or address            */;
+    enum E2BIG =  7       /** Arg list too long                    */;
+    enum ENOEXEC = 8       /** Exec format error                    */;
+    enum EBADF =  9       /** Bad file number                      */;
+    enum ECHILD = 10      /** No children                          */;
+    enum EAGAIN = 11      /** Resource temporarily unavailable     */;
+    enum ENOMEM = 12      /** Not enough core                      */;
+    enum EACCES = 13      /** Permission denied                    */;
+    enum EFAULT = 14      /** Bad address                          */;
+    enum ENOTBLK = 15      /** Block device required                */;
+    enum EBUSY =  16      /** Mount device busy                    */;
+    enum EEXIST = 17      /** File exists                          */;
+    enum EXDEV =  18      /** Cross-device link                    */;
+    enum ENODEV = 19      /** No such device                       */;
+    enum ENOTDIR = 20      /** Not a directory                      */;
+    enum EISDIR = 21      /** Is a directory                       */;
+    enum EINVAL = 22      /** Invalid argument                     */;
+    enum ENFILE = 23      /** File table overflow                  */;
+    enum EMFILE = 24      /** Too many open files                  */;
+    enum ENOTTY = 25      /** Inappropriate ioctl for device       */;
+    enum ETXTBSY = 26      /** Text file busy                       */;
+    enum EFBIG =  27      /** File too large                       */;
+    enum ENOSPC = 28      /** No space left on device              */;
+    enum ESPIPE = 29      /** Illegal seek                         */;
+    enum EROFS =  30      /** Read only file system                */;
+    enum EMLINK = 31      /** Too many links                       */;
+    enum EPIPE =  32      /** Broken pipe                          */;
+    enum EDOM =   33      /** Math arg out of domain of func       */;
+    enum ERANGE = 34      /** Math result not representable        */;
+    enum ENOMSG = 35      /** No message of desired type           */;
+    enum EIDRM =  36      /** Identifier removed                   */;
+    enum ECHRNG = 37      /** Channel number out of range          */;
+    enum EL2NSYNC = 38     /** Level 2 not synchronized             */;
+    enum EL3HLT = 39      /** Level 3 halted                       */;
+    enum EL3RST = 40      /** Level 3 reset                        */;
+    enum ELNRNG = 41      /** Link number out of range             */;
+    enum EUNATCH = 42      /** Protocol driver not attached         */;
+    enum ENOCSI = 43      /** No CSI structure available           */;
+    enum EL2HLT = 44      /** Level 2 halted                       */;
+    enum EDEADLK = 45      /** Deadlock condition.                  */;
+    enum ENOLCK = 46      /** No record locks available.           */;
+    enum ECANCELED = 47    /** Operation canceled                   */;
+    enum ENOTSUP = 48      /** Operation not supported              */;
+    enum EDQUOT = 49      /** Disc quota exceeded                  */;
+    enum EBADE =  50      /** invalid exchange                     */;
+    enum EBADR =  51      /** invalid request descriptor           */;
+    enum EXFULL = 52      /** exchange full                        */;
+    enum ENOANO = 53      /** no anode                             */;
+    enum EBADRQC = 54      /** invalid request code                 */;
+    enum EBADSLT = 55      /** invalid slot                         */;
+    enum EDEADLOCK = 56    /** file locking deadlock error          */;
+    enum EBFONT = 57      /** bad font file fmt                    */;
+    enum EOWNERDEAD =     58      /** process died with the lock */;
+    enum ENOTRECOVERABLE = 59      /** lock is not recoverable */;
+    enum ENOSTR = 60      /** Device not a stream                  */;
+    enum ENODATA = 61      /** no data (for no delay io)            */;
+    enum ETIME =  62      /** timer expired                        */;
+    enum ENOSR =  63      /** out of streams resources             */;
+    enum ENONET = 64      /** Machine is not on the network        */;
+    enum ENOPKG = 65      /** Package not installed                */;
+    enum EREMOTE = 66      /** The object is remote                 */;
+    enum ENOLINK = 67      /** the link has been severed            */;
+    enum EADV =   68      /** advertise error                      */;
+    enum ESRMNT = 69      /** srmount error                        */;
+    enum ECOMM =  70      /** Communication error on send          */;
+    enum EPROTO = 71      /** Protocol error                       */;
+    enum ELOCKUNMAPPED =  72      /** locked lock was unmapped */;
+    enum ENOTACTIVE = 73   /** Facility is not active               */;
+    enum EMULTIHOP = 74    /** multihop attempted                   */;
+    enum EBADMSG = 77      /** trying to read unreadable message    */;
+    enum ENAMETOOLONG = 78 /** path name is too long                */;
+    enum EOVERFLOW = 79    /** value too large to be stored in data type */;
+    enum ENOTUNIQ = 80     /** given log. name not unique           */;
+    enum EBADFD =  81      /** f.d. invalid for this operation      */;
+    enum EREMCHG = 82      /** Remote address changed               */;
+    enum ELIBACC = 83      /** Can't access a needed shared lib.    */;
+    enum ELIBBAD = 84      /** Accessing a corrupted shared lib.    */;
+    enum ELIBSCN = 85      /** .lib section in a.out corrupted.     */;
+    enum ELIBMAX = 86      /** Attempting to link in too many libs. */;
+    enum ELIBEXEC = 87     /** Attempting to exec a shared library. */;
+    enum EILSEQ = 88      /** Illegal byte sequence.               */;
+    enum ENOSYS = 89      /** Unsupported file system operation    */;
+    enum ELOOP =  90      /** Symbolic link loop                   */;
+    enum ERESTART = 91     /** Restartable system call              */;
+    enum ESTRPIPE = 92     /** if pipe/FIFO, don't sleep in stream head */;
+    enum ENOTEMPTY = 93    /** directory not empty                  */;
+    enum EUSERS = 94      /** Too many users (for UFS)             */;
+    enum ENOTSOCK =       95      /** Socket operation on non-socket */;
+    enum EDESTADDRREQ =   96      /** Destination address required */;
+    enum EMSGSIZE =       97      /** Message too long */;
+    enum EPROTOTYPE =     98      /** Protocol wrong type for socket */;
+    enum ENOPROTOOPT =    99      /** Protocol not available */;
+    enum EPROTONOSUPPORT = 120     /** Protocol not supported */;
+    enum ESOCKTNOSUPPORT = 121     /** Socket type not supported */;
+    enum EOPNOTSUPP =     122     /** Operation not supported on socket */;
+    enum EPFNOSUPPORT =   123     /** Protocol family not supported */;
+    enum EAFNOSUPPORT =   124     /** Address family not supported by the protocol family */;
+    enum EADDRINUSE =     125     /** Address already in use */;
+    enum EADDRNOTAVAIL =   126     /** Can't assign requested address */;
+    enum ENETDOWN =       127     /** Network is down */;
+    enum ENETUNREACH =    128     /** Network is unreachable */;
+    enum ENETRESET =      129     /** Network dropped connection because of reset */;
+    enum ECONNABORTED =   130     /** Software caused connection abort */;
+    enum ECONNRESET =     131     /** Connection reset by peer */;
+    enum ENOBUFS =        132     /** No buffer space available */;
+    enum EISCONN =        133     /** Socket is already connected */;
+    enum ENOTCONN =       134     /** Socket is not connected */;
+    enum ESHUTDOWN =      143     /** Can't send after socket shutdown */;
+    enum ETOOMANYREFS =   144     /** Too many references: can't splice */;
+    enum ETIMEDOUT =      145     /** Connection timed out */;
+    enum ECONNREFUSED =   146     /** Connection refused */;
+    enum EHOSTDOWN =      147     /** Host is down */;
+    enum EHOSTUNREACH =   148     /** No route to host */;
+    enum EWOULDBLOCK =    EAGAIN;      /** Resource temporarily unavailable     */;
+    enum EALREADY =       149     /** operation already in progress */;
+    enum EINPROGRESS =    150     /** operation now in progress */;
+    enum ESTALE =         151     /** Stale NFS file handle */;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/stdc/errno_.c b/libphobos/libdruntime/core/stdc/errno_.c
new file mode 100644
index 00000000000..49e9ed43633
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/errno_.c
@@ -0,0 +1,25 @@
+/**
+ * This file contains wrapper functions for macro-defined C routines.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/errno.c)
+ */
+
+#include <errno.h>
+
+
+int getErrno()
+{
+    return errno;
+}
+
+
+int setErrno( int val )
+{
+    errno = val;
+    return val;
+}
diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d
new file mode 100644
index 00000000000..a2780293c39
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/fenv.d
@@ -0,0 +1,392 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_fenv.h.html, _fenv.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_fenv.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.fenv;
+
+extern (C):
+@system:
+nothrow:
+@nogc:
+
+version( MinGW )
+    version = GNUFP;
+version( CRuntime_Glibc )
+    version = GNUFP;
+
+version( GNUFP )
+{
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu/bits/fenv.h
+    version (X86)
+    {
+        struct fenv_t
+        {
+            ushort __control_word;
+            ushort __unused1;
+            ushort __status_word;
+            ushort __unused2;
+            ushort __tags;
+            ushort __unused3;
+            uint   __eip;
+            ushort __cs_selector;
+            ushort __opcode;
+            uint   __data_offset;
+            ushort __data_selector;
+            ushort __unused5;
+        }
+
+        alias fexcept_t = ushort;
+    }
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu/bits/fenv.h
+    else version (X86_64)
+    {
+        struct fenv_t
+        {
+            ushort __control_word;
+            ushort __unused1;
+            ushort __status_word;
+            ushort __unused2;
+            ushort __tags;
+            ushort __unused3;
+            uint   __eip;
+            ushort __cs_selector;
+            ushort __opcode;
+            uint   __data_offset;
+            ushort __data_selector;
+            ushort __unused5;
+            uint   __mxcsr;
+        }
+
+        alias fexcept_t = ushort;
+    }
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/mips/bits/fenv.h
+    else version (MIPS32)
+    {
+        struct fenv_t
+        {
+            uint   __fp_control_register;
+        }
+
+        alias fexcept_t = ushort;
+    }
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/mips/bits/fenv.h
+    else version (MIPS64)
+    {
+        struct fenv_t
+        {
+            uint   __fp_control_register;
+        }
+
+        alias fexcept_t = ushort;
+    }
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/aarch64/bits/fenv.h
+    else version (AArch64)
+    {
+        struct fenv_t
+        {
+            uint __fpcr;
+            uint __fpsr;
+        }
+
+        alias fexcept_t = uint;
+    }
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/arm/bits/fenv.h
+    else version (ARM)
+    {
+        struct fenv_t
+        {
+            uint __cw;
+        }
+
+        alias fexcept_t = uint;
+    }
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/bits/fenv.h
+    else version (PPC64)
+    {
+        alias fenv_t = double;
+        alias fexcept_t = uint;
+    }
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/s390/fpu/bits/fenv.h
+    else version (SystemZ)
+    {
+        struct fenv_t
+        {
+            fexcept_t __fpc;
+            void*     __unused;
+        }
+
+        alias fexcept_t = uint;
+    }
+    else
+    {
+        static assert(0, "Unimplemented architecture");
+    }
+}
+else version( CRuntime_DigitalMars )
+{
+    struct fenv_t
+    {
+        ushort    status;
+        ushort    control;
+        ushort    round;
+        ushort[2] reserved;
+    }
+    alias fexcept_t = int;
+}
+else version( CRuntime_Microsoft )
+{
+    struct fenv_t
+    {
+        uint ctl;
+        uint stat;
+    }
+
+    alias fexcept_t = uint;
+}
+else version ( OSX )
+{
+    version ( BigEndian )
+    {
+        alias uint fenv_t;
+        alias uint fexcept_t;
+    }
+    version ( LittleEndian )
+    {
+        struct fenv_t
+        {
+            ushort  __control;
+            ushort  __status;
+            uint    __mxcsr;
+            byte[8] __reserved;
+        }
+
+        alias ushort fexcept_t;
+    }
+}
+else version ( FreeBSD )
+{
+    struct fenv_t
+    {
+        ushort __control;
+        ushort __mxcsr_hi;
+        ushort __status;
+        ushort __mxcsr_lo;
+        uint __tag;
+        byte[16] __other;
+    }
+
+    alias ushort fexcept_t;
+}
+else version( CRuntime_Bionic )
+{
+    version(X86)
+    {
+        struct fenv_t
+        {
+            ushort   __control;
+            ushort   __mxcsr_hi;
+            ushort   __status;
+            ushort   __mxcsr_lo;
+            uint     __tag;
+            byte[16] __other;
+        }
+
+        alias ushort fexcept_t;
+    }
+    else version(ARM)
+    {
+        alias uint fenv_t;
+        alias uint fexcept_t;
+    }
+    else
+    {
+        static assert(false, "Architecture not supported.");
+    }
+}
+else version( Solaris )
+{
+    import core.stdc.config : c_ulong;
+
+    enum FEX_NUM_EXC = 12;
+
+    struct fex_handler_t
+    {
+        int             __mode;
+        void function() __handler;
+    }
+
+    struct fenv_t
+    {
+        fex_handler_t[FEX_NUM_EXC]  __handler;
+        c_ulong                     __fsr;
+    }
+
+    alias int fexcept_t;
+}
+else
+{
+    static assert( false, "Unsupported platform" );
+}
+
+version( CRuntime_Microsoft )
+{
+    enum
+    {
+        FE_INEXACT      = 1, ///
+        FE_UNDERFLOW    = 2, ///
+        FE_OVERFLOW     = 4, ///
+        FE_DIVBYZERO    = 8, ///
+        FE_INVALID      = 0x10, ///
+        FE_ALL_EXCEPT   = 0x1F, ///
+        FE_TONEAREST    = 0, ///
+        FE_UPWARD       = 0x100, ///
+        FE_DOWNWARD     = 0x200, ///
+        FE_TOWARDZERO   = 0x300, ///
+    }
+}
+else
+{
+    enum
+    {
+        FE_INVALID      = 1, ///
+        FE_DENORMAL     = 2, /// non-standard
+        FE_DIVBYZERO    = 4, ///
+        FE_OVERFLOW     = 8, ///
+        FE_UNDERFLOW    = 0x10, ///
+        FE_INEXACT      = 0x20, ///
+        FE_ALL_EXCEPT   = 0x3F, ///
+        FE_TONEAREST    = 0, ///
+        FE_UPWARD       = 0x800, ///
+        FE_DOWNWARD     = 0x400, ///
+        FE_TOWARDZERO   = 0xC00, ///
+    }
+}
+
+version( GNUFP )
+{
+    ///
+    enum FE_DFL_ENV = cast(fenv_t*)(-1);
+}
+else version( CRuntime_DigitalMars )
+{
+    private extern __gshared fenv_t _FE_DFL_ENV;
+    ///
+    enum fenv_t* FE_DFL_ENV = &_FE_DFL_ENV;
+}
+else version( CRuntime_Microsoft )
+{
+    private extern __gshared fenv_t _Fenv0;
+    ///
+    enum FE_DFL_ENV = &_Fenv0;
+}
+else version( OSX )
+{
+    private extern __gshared fenv_t _FE_DFL_ENV;
+    ///
+    enum FE_DFL_ENV = &_FE_DFL_ENV;
+}
+else version( FreeBSD )
+{
+    private extern const fenv_t __fe_dfl_env;
+    ///
+    enum FE_DFL_ENV = &__fe_dfl_env;
+}
+else version( CRuntime_Bionic )
+{
+    private extern const fenv_t __fe_dfl_env;
+    ///
+    enum FE_DFL_ENV = &__fe_dfl_env;
+}
+else version( Solaris )
+{
+    private extern const fenv_t __fenv_def_env;
+    ///
+    enum FE_DFL_ENV = &__fenv_def_env;
+}
+else
+{
+    static assert( false, "Unsupported platform" );
+}
+
+///
+int feclearexcept(int excepts);
+
+///
+int fetestexcept(int excepts);
+///
+int feholdexcept(fenv_t* envp);
+
+///
+int fegetexceptflag(fexcept_t* flagp, int excepts);
+///
+int fesetexceptflag(in fexcept_t* flagp, int excepts);
+
+///
+int fegetround();
+///
+int fesetround(int round);
+
+///
+int fegetenv(fenv_t* envp);
+///
+int fesetenv(in fenv_t* envp);
+
+// MS define feraiseexcept() and feupdateenv() inline.
+version( CRuntime_Microsoft ) // supported since MSVCRT 12 (VS 2013) only
+{
+    ///
+    int feraiseexcept()(int excepts)
+    {
+        struct Entry
+        {
+            int    exceptVal;
+            double num;
+            double denom;
+        }
+        static __gshared immutable(Entry[5]) table =
+        [ // Raise exception by evaluating num / denom:
+            { FE_INVALID,   0.0,    0.0    },
+            { FE_DIVBYZERO, 1.0,    0.0    },
+            { FE_OVERFLOW,  1e+300, 1e-300 },
+            { FE_UNDERFLOW, 1e-300, 1e+300 },
+            { FE_INEXACT,   2.0,    3.0    }
+        ];
+
+        if ((excepts &= FE_ALL_EXCEPT) == 0)
+            return 0;
+
+        // Raise the exceptions not masked:
+        double ans = void;
+        foreach (i; 0 .. table.length)
+        {
+            if ((excepts & table[i].exceptVal) != 0)
+                ans = table[i].num / table[i].denom;
+        }
+
+        return 0;
+    }
+
+    ///
+    int feupdateenv()(in fenv_t* envp)
+    {
+        int excepts = fetestexcept(FE_ALL_EXCEPT);
+        return (fesetenv(envp) != 0 || feraiseexcept(excepts) != 0 ? 1 : 0);
+    }
+}
+else
+{
+    ///
+    int feraiseexcept(int excepts);
+    ///
+    int feupdateenv(in fenv_t* envp);
+}
diff --git a/libphobos/libdruntime/core/stdc/float_.d b/libphobos/libdruntime/core/stdc/float_.d
new file mode 100644
index 00000000000..3ae43569d3a
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/float_.d
@@ -0,0 +1,92 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_float.h.html, _float.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_float_.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.float_;
+
+extern (C):
+@trusted: // Constants only.
+nothrow:
+@nogc:
+
+///
+enum FLT_ROUNDS                 = 1;
+///
+enum FLT_EVAL_METHOD    = 2;
+///
+enum FLT_RADIX                  = 2;
+
+///
+enum DECIMAL_DIG                = real.dig;
+///
+enum FLT_DIG                    = float.dig;
+///
+enum DBL_DIG                    = double.dig;
+///
+enum LDBL_DIG                   = real.dig;
+
+///
+enum FLT_MANT_DIG               = float.mant_dig;
+///
+enum DBL_MANT_DIG               = double.mant_dig;
+///
+enum LDBL_MANT_DIG              = real.mant_dig;
+
+///
+enum FLT_MIN                    = float.min_normal;
+///
+enum DBL_MIN                    = double.min_normal;
+///
+enum LDBL_MIN                   = real.min_normal;
+
+///
+enum FLT_MAX                    = float.max;
+///
+enum DBL_MAX                    = double.max;
+///
+enum LDBL_MAX                   = real.max;
+
+///
+enum FLT_EPSILON                = float.epsilon;
+///
+enum DBL_EPSILON                = double.epsilon;
+///
+enum LDBL_EPSILON               = real.epsilon;
+
+///
+enum FLT_MIN_EXP                = float.min_exp;
+///
+enum DBL_MIN_EXP                = double.min_exp;
+///
+enum LDBL_MIN_EXP               = real.min_exp;
+
+///
+enum FLT_MAX_EXP                = float.max_exp;
+///
+enum DBL_MAX_EXP                = double.max_exp;
+///
+enum LDBL_MAX_EXP               = real.max_exp;
+
+///
+enum FLT_MIN_10_EXP             = float.min_10_exp;
+///
+enum DBL_MIN_10_EXP             = double.min_10_exp;
+///
+enum LDBL_MIN_10_EXP    = real.min_10_exp;
+
+///
+enum FLT_MAX_10_EXP             = float.max_10_exp;
+///
+enum DBL_MAX_10_EXP             = double.max_10_exp;
+///
+enum LDBL_MAX_10_EXP    = real.max_10_exp;
diff --git a/libphobos/libdruntime/core/stdc/inttypes.d b/libphobos/libdruntime/core/stdc/inttypes.d
new file mode 100644
index 00000000000..6df2ff28ac7
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/inttypes.d
@@ -0,0 +1,443 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_inttypes.h.html, _inttypes.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_inttypes.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.inttypes;
+
+public import core.stdc.stddef; // for wchar_t
+public import core.stdc.stdint; // required by spec
+
+extern (C):
+@trusted: // Types and constants only.
+nothrow:
+@nogc:
+
+///
+struct imaxdiv_t
+{
+    intmax_t    quot,
+                rem;
+}
+
+private alias immutable(char)* _cstr;
+
+///
+enum _cstr PRId8            = "hhd";
+///
+enum _cstr PRId16           = "hd";
+///
+enum _cstr PRId32           = "ld";
+///
+enum _cstr PRId64           = "lld";
+
+///
+enum _cstr PRIdLEAST8       = "hhd";
+///
+enum _cstr PRIdLEAST16      = "hd";
+///
+enum _cstr PRIdLEAST32      = "ld";
+///
+enum _cstr PRIdLEAST64      = "lld";
+
+///
+enum _cstr PRIdFAST8        = "hhd";
+///
+enum _cstr PRIdFAST16       = "d";
+///
+enum _cstr PRIdFAST32       = "ld";
+///
+enum _cstr PRIdFAST64       = "lld";
+
+///
+enum _cstr PRIi8            = "hhi";
+///
+enum _cstr PRIi16           = "hi";
+///
+enum _cstr PRIi32           = "li";
+///
+enum _cstr PRIi64           = "lli";
+
+///
+enum _cstr PRIiLEAST8       = "hhi";
+///
+enum _cstr PRIiLEAST16      = "hi";
+///
+enum _cstr PRIiLEAST32      = "li";
+///
+enum _cstr PRIiLEAST64      = "lli";
+
+///
+enum _cstr PRIiFAST8        = "hhi";
+///
+enum _cstr PRIiFAST16       = "i";
+///
+enum _cstr PRIiFAST32       = "li";
+///
+enum _cstr PRIiFAST64       = "lli";
+
+///
+enum _cstr PRIo8            = "hho";
+///
+enum _cstr PRIo16           = "ho";
+///
+enum _cstr PRIo32           = "lo";
+///
+enum _cstr PRIo64           = "llo";
+
+///
+enum _cstr PRIoLEAST8       = "hho";
+///
+enum _cstr PRIoLEAST16      = "ho";
+///
+enum _cstr PRIoLEAST32      = "lo";
+///
+enum _cstr PRIoLEAST64      = "llo";
+
+///
+enum _cstr PRIoFAST8        = "hho";
+///
+enum _cstr PRIoFAST16       = "o";
+///
+enum _cstr PRIoFAST32       = "lo";
+///
+enum _cstr PRIoFAST64       = "llo";
+
+///
+enum _cstr PRIu8            = "hhu";
+///
+enum _cstr PRIu16           = "hu";
+///
+enum _cstr PRIu32           = "lu";
+///
+enum _cstr PRIu64           = "llu";
+
+///
+enum _cstr PRIuLEAST8       = "hhu";
+///
+enum _cstr PRIuLEAST16      = "hu";
+///
+enum _cstr PRIuLEAST32      = "lu";
+///
+enum _cstr PRIuLEAST64      = "llu";
+
+///
+enum _cstr PRIuFAST8        = "hhu";
+///
+enum _cstr PRIuFAST16       = "u";
+///
+enum _cstr PRIuFAST32       = "lu";
+///
+enum _cstr PRIuFAST64       = "llu";
+
+///
+enum _cstr PRIx8            = "hhx";
+///
+enum _cstr PRIx16           = "hx";
+///
+enum _cstr PRIx32           = "lx";
+///
+enum _cstr PRIx64           = "llx";
+
+///
+enum _cstr PRIxLEAST8       = "hhx";
+///
+enum _cstr PRIxLEAST16      = "hx";
+///
+enum _cstr PRIxLEAST32      = "lx";
+///
+enum _cstr PRIxLEAST64      = "llx";
+
+///
+enum _cstr PRIxFAST8        = "hhx";
+///
+enum _cstr PRIxFAST16       = "x";
+///
+enum _cstr PRIxFAST32       = "lx";
+///
+enum _cstr PRIxFAST64       = "llx";
+
+///
+enum _cstr PRIX8            = "hhX";
+///
+enum _cstr PRIX16           = "hX";
+///
+enum _cstr PRIX32           = "lX";
+///
+enum _cstr PRIX64           = "llX";
+
+///
+enum _cstr PRIXLEAST8       = "hhX";
+///
+enum _cstr PRIXLEAST16      = "hX";
+///
+enum _cstr PRIXLEAST32      = "lX";
+///
+enum _cstr PRIXLEAST64      = "llX";
+
+///
+enum _cstr PRIXFAST8        = "hhX";
+///
+enum _cstr PRIXFAST16       = "X";
+///
+enum _cstr PRIXFAST32       = "lX";
+///
+enum _cstr PRIXFAST64       = "llX";
+
+///
+enum _cstr SCNd8            = "hhd";
+///
+enum _cstr SCNd16           = "hd";
+///
+enum _cstr SCNd32           = "ld";
+///
+enum _cstr SCNd64           = "lld";
+
+///
+enum _cstr SCNdLEAST8       = "hhd";
+///
+enum _cstr SCNdLEAST16      = "hd";
+///
+enum _cstr SCNdLEAST32      = "ld";
+///
+enum _cstr SCNdLEAST64      = "lld";
+
+///
+enum _cstr SCNdFAST8        = "hhd";
+///
+enum _cstr SCNdFAST16       = "d";
+///
+enum _cstr SCNdFAST32       = "ld";
+///
+enum _cstr SCNdFAST64       = "lld";
+
+///
+enum _cstr SCNi8            = "hhd";
+///
+enum _cstr SCNi16           = "hi";
+///
+enum _cstr SCNi32           = "li";
+///
+enum _cstr SCNi64           = "lli";
+
+///
+enum _cstr SCNiLEAST8       = "hhd";
+///
+enum _cstr SCNiLEAST16      = "hi";
+///
+enum _cstr SCNiLEAST32      = "li";
+///
+enum _cstr SCNiLEAST64      = "lli";
+
+///
+enum _cstr SCNiFAST8        = "hhd";
+///
+enum _cstr SCNiFAST16       = "i";
+///
+enum _cstr SCNiFAST32       = "li";
+///
+enum _cstr SCNiFAST64       = "lli";
+
+///
+enum _cstr SCNo8            = "hhd";
+///
+enum _cstr SCNo16           = "ho";
+///
+enum _cstr SCNo32           = "lo";
+///
+enum _cstr SCNo64           = "llo";
+
+///
+enum _cstr SCNoLEAST8       = "hhd";
+///
+enum _cstr SCNoLEAST16      = "ho";
+///
+enum _cstr SCNoLEAST32      = "lo";
+///
+enum _cstr SCNoLEAST64      = "llo";
+
+///
+enum _cstr SCNoFAST8        = "hhd";
+///
+enum _cstr SCNoFAST16       = "o";
+///
+enum _cstr SCNoFAST32       = "lo";
+///
+enum _cstr SCNoFAST64       = "llo";
+
+///
+enum _cstr SCNu8            = "hhd";
+///
+enum _cstr SCNu16           = "hu";
+///
+enum _cstr SCNu32           = "lu";
+///
+enum _cstr SCNu64           = "llu";
+
+///
+enum _cstr SCNuLEAST8       = "hhd";
+///
+enum _cstr SCNuLEAST16      = "hu";
+///
+enum _cstr SCNuLEAST32      = "lu";
+///
+enum _cstr SCNuLEAST64      = "llu";
+
+///
+enum _cstr SCNuFAST8        = "hhd";
+///
+enum _cstr SCNuFAST16       = "u";
+///
+enum _cstr SCNuFAST32       = "lu";
+///
+enum _cstr SCNuFAST64       = "llu";
+
+///
+enum _cstr SCNx8            = "hhd";
+///
+enum _cstr SCNx16           = "hx";
+///
+enum _cstr SCNx32           = "lx";
+///
+enum _cstr SCNx64           = "llx";
+
+///
+enum _cstr SCNxLEAST8       = "hhd";
+///
+enum _cstr SCNxLEAST16      = "hx";
+///
+enum _cstr SCNxLEAST32      = "lx";
+///
+enum _cstr SCNxLEAST64      = "llx";
+
+///
+enum _cstr SCNxFAST8        = "hhd";
+///
+enum _cstr SCNxFAST16       = "x";
+///
+enum _cstr SCNxFAST32       = "lx";
+///
+enum _cstr SCNxFAST64       = "llx";
+
+version( D_LP64 )
+{
+    ///
+    enum _cstr PRIdMAX      = PRId64;
+    ///
+    enum _cstr PRIiMAX      = PRIi64;
+    ///
+    enum _cstr PRIoMAX      = PRIo64;
+    ///
+    enum _cstr PRIuMAX      = PRIu64;
+    ///
+    enum _cstr PRIxMAX      = PRIx64;
+    ///
+    enum _cstr PRIXMAX      = PRIX64;
+
+    ///
+    enum _cstr SCNdMAX      = SCNd64;
+    ///
+    enum _cstr SCNiMAX      = SCNi64;
+    ///
+    enum _cstr SCNoMAX      = SCNo64;
+    ///
+    enum _cstr SCNuMAX      = SCNu64;
+    ///
+    enum _cstr SCNxMAX      = SCNx64;
+
+    ///
+    enum _cstr PRIdPTR      = PRId64;
+    ///
+    enum _cstr PRIiPTR      = PRIi64;
+    ///
+    enum _cstr PRIoPTR      = PRIo64;
+    ///
+    enum _cstr PRIuPTR      = PRIu64;
+    ///
+    enum _cstr PRIxPTR      = PRIx64;
+    ///
+    enum _cstr PRIXPTR      = PRIX64;
+
+    ///
+    enum _cstr SCNdPTR      = SCNd64;
+    ///
+    enum _cstr SCNiPTR      = SCNi64;
+    ///
+    enum _cstr SCNoPTR      = SCNo64;
+    ///
+    enum _cstr SCNuPTR      = SCNu64;
+    ///
+    enum _cstr SCNxPTR      = SCNx64;
+}
+else
+{
+    ///
+    enum _cstr PRIdMAX      = PRId32;
+    ///
+    enum _cstr PRIiMAX      = PRIi32;
+    ///
+    enum _cstr PRIoMAX      = PRIo32;
+    ///
+    enum _cstr PRIuMAX      = PRIu32;
+    ///
+    enum _cstr PRIxMAX      = PRIx32;
+    ///
+    enum _cstr PRIXMAX      = PRIX32;
+
+    ///
+    enum _cstr SCNdMAX      = SCNd32;
+    ///
+    enum _cstr SCNiMAX      = SCNi32;
+    ///
+    enum _cstr SCNoMAX      = SCNo32;
+    ///
+    enum _cstr SCNuMAX      = SCNu32;
+    ///
+    enum _cstr SCNxMAX      = SCNx32;
+
+    ///
+    enum _cstr PRIdPTR      = PRId32;
+    ///
+    enum _cstr PRIiPTR      = PRIi32;
+    ///
+    enum _cstr PRIoPTR      = PRIo32;
+    ///
+    enum _cstr PRIuPTR      = PRIu32;
+    ///
+    enum _cstr PRIxPTR      = PRIx32;
+    ///
+    enum _cstr PRIXPTR      = PRIX32;
+
+    ///
+    enum _cstr SCNdPTR      = SCNd32;
+    ///
+    enum _cstr SCNiPTR      = SCNi32;
+    ///
+    enum _cstr SCNoPTR      = SCNo32;
+    ///
+    enum _cstr SCNuPTR      = SCNu32;
+    ///
+    enum _cstr SCNxPTR      = SCNx32;
+}
+
+///
+intmax_t  imaxabs(intmax_t j);
+///
+imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
+///
+intmax_t  strtoimax(in char* nptr, char** endptr, int base);
+///
+uintmax_t strtoumax(in char* nptr, char** endptr, int base);
+///
+intmax_t  wcstoimax(in wchar_t* nptr, wchar_t** endptr, int base);
+///
+uintmax_t wcstoumax(in wchar_t* nptr, wchar_t** endptr, int base);
diff --git a/libphobos/libdruntime/core/stdc/limits.d b/libphobos/libdruntime/core/stdc/limits.d
new file mode 100644
index 00000000000..3ed167216ce
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/limits.d
@@ -0,0 +1,61 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_limits.h.html, _limits.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_limits.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.limits;
+
+private import core.stdc.config;
+
+extern (C):
+@trusted: // Constants only.
+nothrow:
+@nogc:
+
+///
+enum CHAR_BIT       = 8;
+///
+enum SCHAR_MIN      = byte.min;
+///
+enum SCHAR_MAX      = byte.max;
+///
+enum UCHAR_MAX      = ubyte.max;
+///
+enum CHAR_MIN       = char.min;
+///
+enum CHAR_MAX       = char.max;
+///
+enum MB_LEN_MAX     = 2;
+///
+enum SHRT_MIN       = short.min;
+///
+enum SHRT_MAX       = short.max;
+///
+enum USHRT_MAX      = ushort.max;
+///
+enum INT_MIN        = int.min;
+///
+enum INT_MAX        = int.max;
+///
+enum UINT_MAX       = uint.max;
+///
+enum LONG_MIN       = c_long.min;
+///
+enum LONG_MAX       = c_long.max;
+///
+enum ULONG_MAX      = c_ulong.max;
+///
+enum LLONG_MIN      = long.min;
+///
+enum LLONG_MAX      = long.max;
+///
+enum ULLONG_MAX     = ulong.max;
diff --git a/libphobos/libdruntime/core/stdc/locale.d b/libphobos/libdruntime/core/stdc/locale.d
new file mode 100644
index 00000000000..c9631a3b545
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/locale.d
@@ -0,0 +1,186 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_locale.h.html, _locale.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_locale.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.locale;
+
+extern (C):
+@trusted: // Only setlocale operates on C strings.
+nothrow:
+@nogc:
+
+///
+struct lconv
+{
+    char* decimal_point;
+    char* thousands_sep;
+    char* grouping;
+    char* int_curr_symbol;
+    char* currency_symbol;
+    char* mon_decimal_point;
+    char* mon_thousands_sep;
+    char* mon_grouping;
+    char* positive_sign;
+    char* negative_sign;
+    byte  int_frac_digits;
+    byte  frac_digits;
+    byte  p_cs_precedes;
+    byte  p_sep_by_space;
+    byte  n_cs_precedes;
+    byte  n_sep_by_space;
+    byte  p_sign_posn;
+    byte  n_sign_posn;
+    byte  int_p_cs_precedes;
+    byte  int_p_sep_by_space;
+    byte  int_n_cs_precedes;
+    byte  int_n_sep_by_space;
+    byte  int_p_sign_posn;
+    byte  int_n_sign_posn;
+}
+
+version(CRuntime_Glibc)
+{
+    ///
+    enum LC_CTYPE          = 0;
+    ///
+    enum LC_NUMERIC        = 1;
+    ///
+    enum LC_TIME           = 2;
+    ///
+    enum LC_COLLATE        = 3;
+    ///
+    enum LC_MONETARY       = 4;
+    ///
+    enum LC_MESSAGES       = 5;
+    ///
+    enum LC_ALL            = 6;
+    ///
+    enum LC_PAPER          = 7;  // non-standard
+    ///
+    enum LC_NAME           = 8;  // non-standard
+    ///
+    enum LC_ADDRESS        = 9;  // non-standard
+    ///
+    enum LC_TELEPHONE      = 10; // non-standard
+    ///
+    enum LC_MEASUREMENT    = 11; // non-standard
+    ///
+    enum LC_IDENTIFICATION = 12; // non-standard
+}
+else version(Windows)
+{
+    ///
+    enum LC_ALL            = 0;
+    ///
+    enum LC_COLLATE        = 1;
+    ///
+    enum LC_CTYPE          = 2;
+    ///
+    enum LC_MONETARY       = 3;
+    ///
+    enum LC_NUMERIC        = 4;
+    ///
+    enum LC_TIME           = 5;
+}
+else version(OSX)
+{
+    ///
+    enum LC_ALL            = 0;
+    ///
+    enum LC_COLLATE        = 1;
+    ///
+    enum LC_CTYPE          = 2;
+    ///
+    enum LC_MONETARY       = 3;
+    ///
+    enum LC_NUMERIC        = 4;
+    ///
+    enum LC_TIME           = 5;
+    ///
+    enum LC_MESSAGES       = 6;
+}
+else version(FreeBSD)
+{
+    ///
+    enum LC_ALL            = 0;
+    ///
+    enum LC_COLLATE        = 1;
+    ///
+    enum LC_CTYPE          = 2;
+    ///
+    enum LC_MONETARY       = 3;
+    ///
+    enum LC_NUMERIC        = 4;
+    ///
+    enum LC_TIME           = 5;
+    ///
+    enum LC_MESSAGES       = 6;
+}
+else version(CRuntime_Bionic)
+{
+    enum
+    {
+        ///
+        LC_CTYPE          = 0,
+        ///
+        LC_NUMERIC        = 1,
+        ///
+        LC_TIME           = 2,
+        ///
+        LC_COLLATE        = 3,
+        ///
+        LC_MONETARY       = 4,
+        ///
+        LC_MESSAGES       = 5,
+        ///
+        LC_ALL            = 6,
+        ///
+        LC_PAPER          = 7,
+        ///
+        LC_NAME           = 8,
+        ///
+        LC_ADDRESS        = 9,
+        ///
+        LC_TELEPHONE      = 10,
+        ///
+        LC_MEASUREMENT    = 11,
+        ///
+        LC_IDENTIFICATION = 12,
+    }
+}
+else version(Solaris)
+{
+    ///
+    enum LC_CTYPE       = 0;
+    ///
+    enum LC_NUMERIC     = 1;
+    ///
+    enum LC_TIME        = 2;
+    ///
+    enum LC_COLLATE     = 3;
+    ///
+    enum LC_MONETARY    = 4;
+    ///
+    enum LC_MESSAGES    = 5;
+    ///
+    enum LC_ALL         = 6;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+///
+@system char*  setlocale(int category, in char* locale);
+///
+lconv* localeconv();
diff --git a/libphobos/libdruntime/core/stdc/math.d b/libphobos/libdruntime/core/stdc/math.d
new file mode 100644
index 00000000000..0afed079937
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/math.d
@@ -0,0 +1,2667 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_math.h.html, _math.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2012.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_math.d)
+ */
+
+module core.stdc.math;
+
+private import core.stdc.config;
+
+extern (C):
+@trusted: // All functions here operate on floating point and integer values only.
+nothrow:
+@nogc:
+
+///
+alias float  float_t;
+///
+alias double double_t;
+
+///
+enum double HUGE_VAL      = double.infinity;
+///
+enum double HUGE_VALF     = float.infinity;
+///
+enum double HUGE_VALL     = real.infinity;
+
+///
+enum float INFINITY       = float.infinity;
+///
+enum float NAN            = float.nan;
+
+version (FreeBSD)
+{
+    ///
+    enum int FP_ILOGB0        = -int.max;
+    ///
+    enum int FP_ILOGBNAN      = int.max;
+}
+else version (CRuntime_Bionic)
+{
+    ///
+    enum int FP_ILOGB0        = -int.max;
+    ///
+    enum int FP_ILOGBNAN      = int.max;
+}
+else version (CRuntime_Glibc)
+{
+    version (X86)
+    {
+        ///
+        enum int FP_ILOGB0        = int.min;
+        ///
+        enum int FP_ILOGBNAN      = int.min;
+    }
+    else version (X86_64)
+    {
+        ///
+        enum int FP_ILOGB0        = int.min;
+        ///
+        enum int FP_ILOGBNAN      = int.min;
+    }
+    else version (ARM)
+    {
+        ///
+        enum int FP_ILOGB0        = -2147483647;
+        ///
+        enum int FP_ILOGBNAN      = 2147483647;
+    }
+    else version (AArch64)
+    {
+        ///
+        enum int FP_ILOGB0        = -2147483647;
+        ///
+        enum int FP_ILOGBNAN      = 2147483647;
+    }
+    else version (MIPS64)
+    {
+        ///
+        enum int FP_ILOGB0        = -2147483647;
+        ///
+        enum int FP_ILOGBNAN      = 2147483647;
+    }
+    else version (PPC)
+    {
+        ///
+        enum int FP_ILOGB0        = -2147483647;
+        ///
+        enum int FP_ILOGBNAN      = 2147483647;
+    }
+    else version (PPC64)
+    {
+        ///
+        enum int FP_ILOGB0        = -2147483647;
+        ///
+        enum int FP_ILOGBNAN      = 2147483647;
+    }
+    else
+    {
+        static assert(false, "Architecture not supported.");
+    }
+}
+else
+{
+    ///
+    enum int FP_ILOGB0        = int.min;
+    ///
+    enum int FP_ILOGBNAN      = int.min;
+}
+
+///
+enum int MATH_ERRNO       = 1;
+///
+enum int MATH_ERREXCEPT   = 2;
+///
+enum int math_errhandling = MATH_ERRNO | MATH_ERREXCEPT;
+
+version( none )
+{
+    //
+    // these functions are all macros in C
+    //
+
+    //int fpclassify(real-floating x);
+    int fpclassify(float x);
+    int fpclassify(double x);
+    int fpclassify(real x);
+
+    //int isfinite(real-floating x);
+    int isfinite(float x);
+    int isfinite(double x);
+    int isfinite(real x);
+
+    //int isinf(real-floating x);
+    int isinf(float x);
+    int isinf(double x);
+    int isinf(real x);
+
+    //int isnan(real-floating x);
+    int isnan(float x);
+    int isnan(double x);
+    int isnan(real x);
+
+    //int isnormal(real-floating x);
+    int isnormal(float x);
+    int isnormal(double x);
+    int isnormal(real x);
+
+    //int signbit(real-floating x);
+    int signbit(float x);
+    int signbit(double x);
+    int signbit(real x);
+
+    //int isgreater(real-floating x, real-floating y);
+    int isgreater(float x, float y);
+    int isgreater(double x, double y);
+    int isgreater(real x, real y);
+
+    //int isgreaterequal(real-floating x, real-floating y);
+    int isgreaterequal(float x, float y);
+    int isgreaterequal(double x, double y);
+    int isgreaterequal(real x, real y);
+
+    //int isless(real-floating x, real-floating y);
+    int isless(float x, float y);
+    int isless(double x, double y);
+    int isless(real x, real y);
+
+    //int islessequal(real-floating x, real-floating y);
+    int islessequal(float x, float y);
+    int islessequal(double x, double y);
+    int islessequal(real x, real y);
+
+    //int islessgreater(real-floating x, real-floating y);
+    int islessgreater(float x, float y);
+    int islessgreater(double x, double y);
+    int islessgreater(real x, real y);
+
+    //int isunordered(real-floating x, real-floating y);
+    int isunordered(float x, float y);
+    int isunordered(double x, double y);
+    int isunordered(real x, real y);
+}
+
+version( CRuntime_DigitalMars )
+{
+    enum
+    {
+        ///
+        FP_NANS        = 0,
+        ///
+        FP_NANQ        = 1,
+        ///
+        FP_INFINITE    = 2,
+        ///
+        FP_NORMAL      = 3,
+        ///
+        FP_SUBNORMAL   = 4,
+        ///
+        FP_ZERO        = 5,
+        ///
+        FP_NAN         = FP_NANQ,
+        ///
+        FP_EMPTY       = 6,
+        ///
+        FP_UNSUPPORTED = 7,
+    }
+
+    enum
+    {
+        ///
+        FP_FAST_FMA  = 0,
+        ///
+        FP_FAST_FMAF = 0,
+        ///
+        FP_FAST_FMAL = 0,
+    }
+
+    uint __fpclassify_f(float x);
+    uint __fpclassify_d(double x);
+    uint __fpclassify_ld(real x);
+
+  extern (D)
+  {
+    //int fpclassify(real-floating x);
+    ///
+    int fpclassify(float x)     { return __fpclassify_f(x); }
+    ///
+    int fpclassify(double x)    { return __fpclassify_d(x); }
+    ///
+    int fpclassify(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __fpclassify_d(x)
+            : __fpclassify_ld(x);
+    }
+
+    //int isfinite(real-floating x);
+    ///
+    int isfinite(float x)       { return fpclassify(x) >= FP_NORMAL; }
+    ///
+    int isfinite(double x)      { return fpclassify(x) >= FP_NORMAL; }
+    ///
+    int isfinite(real x)        { return fpclassify(x) >= FP_NORMAL; }
+
+    //int isinf(real-floating x);
+    ///
+    int isinf(float x)          { return fpclassify(x) == FP_INFINITE; }
+    ///
+    int isinf(double x)         { return fpclassify(x) == FP_INFINITE; }
+    ///
+    int isinf(real x)           { return fpclassify(x) == FP_INFINITE; }
+
+    //int isnan(real-floating x);
+    ///
+    int isnan(float x)          { return fpclassify(x) <= FP_NANQ;   }
+    ///
+    int isnan(double x)         { return fpclassify(x) <= FP_NANQ;   }
+    ///
+    int isnan(real x)           { return fpclassify(x) <= FP_NANQ;   }
+
+    //int isnormal(real-floating x);
+    ///
+    int isnormal(float x)       { return fpclassify(x) == FP_NORMAL; }
+    ///
+    int isnormal(double x)      { return fpclassify(x) == FP_NORMAL; }
+    ///
+    int isnormal(real x)        { return fpclassify(x) == FP_NORMAL; }
+
+    //int signbit(real-floating x);
+    ///
+    int signbit(float x)     { return (cast(short*)&(x))[1] & 0x8000; }
+    ///
+    int signbit(double x)    { return (cast(short*)&(x))[3] & 0x8000; }
+    ///
+    int signbit(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? (cast(short*)&(x))[3] & 0x8000
+            : (cast(short*)&(x))[4] & 0x8000;
+    }
+  }
+}
+else version( CRuntime_Microsoft ) // fully supported since MSVCRT 12 (VS 2013) only
+{
+  version( all ) // legacy stuff to be removed in the future
+  {
+    enum
+    {
+        _FPCLASS_SNAN = 1,
+        _FPCLASS_QNAN = 2,
+        _FPCLASS_NINF = 4,
+        _FPCLASS_NN   = 8,
+        _FPCLASS_ND   = 0x10,
+        _FPCLASS_NZ   = 0x20,
+        _FPCLASS_PZ   = 0x40,
+        _FPCLASS_PD   = 0x80,
+        _FPCLASS_PN   = 0x100,
+        _FPCLASS_PINF = 0x200,
+    }
+
+    //deprecated("Please use the standard C99 function copysignf() instead.")
+    float _copysignf(float x, float s);
+
+    //deprecated("_chgsignf(x) is a non-standard MS extension. Please consider using -x instead.")
+    float _chgsignf(float x);
+
+    version( Win64 ) // not available in 32-bit runtimes
+    {
+        //deprecated("Please use the standard C99 function isfinite() instead.")
+        int _finitef(float x);
+
+        //deprecated("Please use the standard C99 function isnan() instead.")
+        int _isnanf(float x);
+
+        //deprecated("Please use the standard C99 function fpclassify() instead.")
+        int _fpclassf(float x);
+    }
+
+    //deprecated("Please use the standard C99 function copysign() instead.")
+    double _copysign(double x, double s);
+
+    //deprecated("_chgsign(x) is a non-standard MS extension. Please consider using -x instead.")
+    double _chgsign(double x);
+
+    //deprecated("Please use the standard C99 function isfinite() instead.")
+    int _finite(double x);
+
+    //deprecated("Please use the standard C99 function isnan() instead.")
+    int _isnan(double x);
+
+    //deprecated("Please use the standard C99 function fpclassify() instead.")
+    int _fpclass(double x);
+  }
+
+    enum
+    {
+        ///
+        FP_SUBNORMAL = -2,
+        ///
+        FP_NORMAL    = -1,
+        ///
+        FP_ZERO      =  0,
+        ///
+        FP_INFINITE  =  1,
+        ///
+        FP_NAN       =  2,
+    }
+
+    private short _fdclass(float x);
+    private short _dclass(double x);
+
+    private int _fdsign(float x);
+    private int _dsign(double x);
+
+  extern(D)
+  {
+    //int fpclassify(real-floating x);
+    ///
+    int fpclassify()(float x)   { return _fdclass(x); }
+    ///
+    int fpclassify()(double x)  { return _dclass(x);  }
+    ///
+    int fpclassify()(real x)
+    {
+        static if (real.sizeof == double.sizeof)
+            return _dclass(cast(double) x);
+        else
+            static assert(false, "fpclassify(real) not supported by MS C runtime");
+    }
+
+    //int isfinite(real-floating x);
+    ///
+    int isfinite()(float x)     { return fpclassify(x) <= 0; }
+    ///
+    int isfinite()(double x)    { return fpclassify(x) <= 0; }
+    ///
+    int isfinite()(real x)      { return fpclassify(x) <= 0; }
+
+    //int isinf(real-floating x);
+    ///
+    int isinf()(float x)        { return fpclassify(x) == FP_INFINITE; }
+    ///
+    int isinf()(double x)       { return fpclassify(x) == FP_INFINITE; }
+    ///
+    int isinf()(real x)         { return fpclassify(x) == FP_INFINITE; }
+
+    //int isnan(real-floating x);
+    version( none ) // requires MSVCRT 12+ (VS 2013)
+    {
+        ///
+        int isnan(float x)      { return fpclassify(x) == FP_NAN; }
+        ///
+        int isnan(double x)     { return fpclassify(x) == FP_NAN; }
+        ///
+        int isnan(real x)       { return fpclassify(x) == FP_NAN; }
+    }
+    else // for backward compatibility with older runtimes
+    {
+        ///
+        int isnan(float x)      { version(Win64) return _isnanf(x); else return _isnan(cast(double) x); }
+        ///
+        int isnan(double x)     { return _isnan(x); }
+        ///
+        int isnan(real x)       { return _isnan(cast(double) x); }
+    }
+
+    //int isnormal(real-floating x);
+    ///
+    int isnormal()(float x)     { return fpclassify(x) == FP_NORMAL; }
+    ///
+    int isnormal()(double x)    { return fpclassify(x) == FP_NORMAL; }
+    ///
+    int isnormal()(real x)      { return fpclassify(x) == FP_NORMAL; }
+
+    //int signbit(real-floating x);
+    ///
+    int signbit()(float x)   { return _fdsign(x); }
+    ///
+    int signbit()(double x)  { return _dsign(x);  }
+    ///
+    int signbit()(real x)
+    {
+        static if (real.sizeof == double.sizeof)
+            return _dsign(cast(double) x);
+        else
+            return (cast(short*)&(x))[4] & 0x8000;
+    }
+  }
+}
+else version( CRuntime_Glibc )
+{
+    enum
+    {
+        ///
+        FP_NAN,
+        ///
+        FP_INFINITE,
+        ///
+        FP_ZERO,
+        ///
+        FP_SUBNORMAL,
+        ///
+        FP_NORMAL,
+    }
+
+    enum
+    {
+        ///
+        FP_FAST_FMA  = 0,
+        ///
+        FP_FAST_FMAF = 0,
+        ///
+        FP_FAST_FMAL = 0,
+    }
+
+    int __fpclassifyf(float x);
+    int __fpclassify(double x);
+    int __fpclassifyl(real x);
+
+    int __finitef(float x);
+    int __finite(double x);
+    int __finitel(real x);
+
+    int __isinff(float x);
+    int __isinf(double x);
+    int __isinfl(real x);
+
+    int __isnanf(float x);
+    int __isnan(double x);
+    int __isnanl(real x);
+
+    int __signbitf(float x);
+    int __signbit(double x);
+    int __signbitl(real x);
+
+  extern (D)
+  {
+    //int fpclassify(real-floating x);
+      ///
+    int fpclassify(float x)     { return __fpclassifyf(x); }
+    ///
+    int fpclassify(double x)    { return __fpclassify(x);  }
+    ///
+    int fpclassify(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __fpclassify(x)
+            : __fpclassifyl(x);
+    }
+
+    //int isfinite(real-floating x);
+    ///
+    int isfinite(float x)       { return __finitef(x); }
+    ///
+    int isfinite(double x)      { return __finite(x);  }
+    ///
+    int isfinite(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __finite(x)
+            : __finitel(x);
+    }
+
+    //int isinf(real-floating x);
+    ///
+    int isinf(float x)          { return __isinff(x);  }
+    ///
+    int isinf(double x)         { return __isinf(x);   }
+    ///
+    int isinf(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __isinf(x)
+            : __isinfl(x);
+    }
+
+    //int isnan(real-floating x);
+    ///
+    int isnan(float x)          { return __isnanf(x);  }
+    ///
+    int isnan(double x)         { return __isnan(x);   }
+    ///
+    int isnan(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __isnan(x)
+            : __isnanl(x);
+    }
+
+    //int isnormal(real-floating x);
+    ///
+    int isnormal(float x)       { return fpclassify(x) == FP_NORMAL; }
+    ///
+    int isnormal(double x)      { return fpclassify(x) == FP_NORMAL; }
+    ///
+    int isnormal(real x)        { return fpclassify(x) == FP_NORMAL; }
+
+    //int signbit(real-floating x);
+    ///
+    int signbit(float x)     { return __signbitf(x); }
+    ///
+    int signbit(double x)    { return __signbit(x);  }
+    ///
+    int signbit(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __signbit(x)
+            : __signbitl(x);
+    }
+  }
+}
+else version( MinGW )
+{
+    enum
+    {
+        ///
+        FP_NAN = 0x0100,
+        ///
+        FP_NORMAL = 0x0400,
+        ///
+        FP_INFINITE = FP_NAN | FP_NORMAL,
+        ///
+        FP_ZERO = 0x0400,
+        ///
+        FP_SUBNORMAL = FP_NORMAL | FP_ZERO
+    }
+
+    int __fpclassifyf(float x);
+    int __fpclassify(double x);
+    int __fpclassifyl(real x);
+
+    int __isnanf(float x);
+    int __isnan(double x);
+    int __isnanl(real x);
+
+    int __signbitf(float x);
+    int __signbit(double x);
+    int __signbitl(real x);
+
+  extern (D)
+  {
+    //int fpclassify(real-floating x);
+      ///
+    int fpclassify(float x)     { return __fpclassifyf(x); }
+    ///
+    int fpclassify(double x)    { return __fpclassify(x);  }
+    ///
+    int fpclassify(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __fpclassify(x)
+            : __fpclassifyl(x);
+    }
+
+    //int isfinite(real-floating x);
+    ///
+    int isfinite(float x)       { return (fpclassify(x) & FP_NORMAL) == 0; }
+    ///
+    int isfinite(double x)      { return (fpclassify(x) & FP_NORMAL) == 0; }
+    ///
+    int isfinite(real x)        { return (fpclassify(x) & FP_NORMAL) == 0; }
+
+    //int isinf(real-floating x);
+    ///
+    int isinf(float x)          { return fpclassify(x) == FP_INFINITE; }
+    ///
+    int isinf(double x)         { return fpclassify(x) == FP_INFINITE; }
+    ///
+    int isinf(real x)           { return fpclassify(x) == FP_INFINITE; }
+
+    //int isnan(real-floating x);
+    ///
+    int isnan(float x)          { return __isnanf(x);  }
+    ///
+    int isnan(double x)         { return __isnan(x);   }
+    ///
+    int isnan(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __isnan(x)
+            : __isnanl(x);
+    }
+
+    //int isnormal(real-floating x);
+    ///
+    int isnormal(float x)       { return fpclassify(x) == FP_NORMAL; }
+    ///
+    int isnormal(double x)      { return fpclassify(x) == FP_NORMAL; }
+    ///
+    int isnormal(real x)        { return fpclassify(x) == FP_NORMAL; }
+
+    //int signbit(real-floating x);
+    ///
+    int signbit(float x)     { return __signbitf(x); }
+    ///
+    int signbit(double x)    { return __signbit(x);  }
+    ///
+    int signbit(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __signbit(x)
+            : __signbitl(x);
+    }
+  }
+}
+else version( OSX )
+{
+    enum
+    {
+        ///
+        FP_NAN         = 1,
+        ///
+        FP_INFINITE    = 2,
+        ///
+        FP_ZERO        = 3,
+        ///
+        FP_NORMAL      = 4,
+        ///
+        FP_SUBNORMAL   = 5,
+        ///
+        FP_SUPERNORMAL = 6,
+    }
+
+    enum
+    {
+        ///
+        FP_FAST_FMA  = 0,
+        ///
+        FP_FAST_FMAF = 0,
+        ///
+        FP_FAST_FMAL = 0,
+    }
+
+    int __fpclassifyf(float x);
+    int __fpclassifyd(double x);
+    int __fpclassify(real x);
+
+    int __isfinitef(float x);
+    int __isfinited(double x);
+    int __isfinite(real x);
+
+    int __isinff(float x);
+    int __isinfd(double x);
+    int __isinf(real x);
+
+    int __isnanf(float x);
+    int __isnand(double x);
+    int __isnan(real x);
+
+    int __signbitf(float x);
+    int __signbitd(double x);
+    int __signbitl(real x);
+
+  extern (D)
+  {
+    //int fpclassify(real-floating x);
+      ///
+    int fpclassify(float x)     { return __fpclassifyf(x); }
+    ///
+    int fpclassify(double x)    { return __fpclassifyd(x); }
+    ///
+    int fpclassify(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __fpclassifyd(x)
+            : __fpclassify(x);
+    }
+
+    //int isfinite(real-floating x);
+    ///
+    int isfinite(float x)       { return __isfinitef(x); }
+    ///
+    int isfinite(double x)      { return __isfinited(x); }
+    ///
+    int isfinite(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __isfinited(x)
+            : __isfinite(x);
+    }
+
+    //int isinf(real-floating x);
+    ///
+    int isinf(float x)          { return __isinff(x); }
+    ///
+    int isinf(double x)         { return __isinfd(x); }
+    ///
+    int isinf(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __isinfd(x)
+            : __isinf(x);
+    }
+
+    //int isnan(real-floating x);
+    ///
+    int isnan(float x)          { return __isnanf(x); }
+    ///
+    int isnan(double x)         { return __isnand(x); }
+    ///
+    int isnan(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __isnand(x)
+            : __isnan(x);
+    }
+
+    //int isnormal(real-floating x);
+    ///
+    int isnormal(float x)       { return fpclassify(x) == FP_NORMAL; }
+    ///
+    int isnormal(double x)      { return fpclassify(x) == FP_NORMAL; }
+    ///
+    int isnormal(real x)        { return fpclassify(x) == FP_NORMAL; }
+
+    //int signbit(real-floating x);
+    ///
+    int signbit(float x)     { return __signbitf(x); }
+    ///
+    int signbit(double x)    { return __signbitd(x); }
+    ///
+    int signbit(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __signbitd(x)
+            : __signbitl(x);
+    }
+  }
+}
+else version( FreeBSD )
+{
+    enum
+    {
+        ///
+        FP_INFINITE  = 0x01,
+        ///
+        FP_NAN       = 0x02,
+        ///
+        FP_NORMAL    = 0x04,
+        ///
+        FP_SUBNORMAL = 0x08,
+        ///
+        FP_ZERO      = 0x10,
+    }
+
+    enum
+    {
+        ///
+        FP_FAST_FMA  = 0,
+        ///
+        FP_FAST_FMAF = 0,
+        ///
+        FP_FAST_FMAL = 0,
+    }
+
+    int __fpclassifyd(double);
+    int __fpclassifyf(float);
+    int __fpclassifyl(real);
+    int __isfinitef(float);
+    int __isfinite(double);
+    int __isfinitel(real);
+    int __isinff(float);
+    int __isinfl(real);
+    int __isnanl(real);
+    int __isnormalf(float);
+    int __isnormal(double);
+    int __isnormall(real);
+    int __signbit(double);
+    int __signbitf(float);
+    int __signbitl(real);
+
+  extern (D)
+  {
+    //int fpclassify(real-floating x);
+      ///
+    int fpclassify(float x)     { return __fpclassifyf(x); }
+    ///
+    int fpclassify(double x)    { return __fpclassifyd(x); }
+    ///
+    int fpclassify(real x)      { return __fpclassifyl(x); }
+
+    //int isfinite(real-floating x);
+    ///
+    int isfinite(float x)       { return __isfinitef(x); }
+    ///
+    int isfinite(double x)      { return __isfinite(x); }
+    ///
+    int isfinite(real x)        { return __isfinitel(x); }
+
+    //int isinf(real-floating x);
+    ///
+    int isinf(float x)          { return __isinff(x); }
+    ///
+    int isinf(double x)         { return __isinfl(x); }
+    ///
+    int isinf(real x)           { return __isinfl(x); }
+
+    //int isnan(real-floating x);
+    ///
+    int isnan(float x)          { return __isnanl(x); }
+    ///
+    int isnan(double x)         { return __isnanl(x); }
+    ///
+    int isnan(real x)           { return __isnanl(x); }
+
+    //int isnormal(real-floating x);
+    ///
+    int isnormal(float x)       { return __isnormalf(x); }
+    ///
+    int isnormal(double x)      { return __isnormal(x); }
+    ///
+    int isnormal(real x)        { return __isnormall(x); }
+
+    //int signbit(real-floating x);
+    ///
+    int signbit(float x)        { return __signbitf(x); }
+    ///
+    int signbit(double x)       { return __signbit(x); }
+    ///
+    int signbit(real x)         { return __signbit(x); }
+  }
+}
+else version( Solaris )
+{
+    int __isnanf(float x);
+    int __isnan(double x);
+    int __isnanl(real x);
+
+  extern (D)
+  {
+    //int isnan(real-floating x);
+      ///
+    int isnan(float x)          { return __isnanf(x);  }
+    ///
+    int isnan(double x)         { return __isnan(x);   }
+    ///
+    int isnan(real x)
+    {
+        return (real.sizeof == double.sizeof)
+            ? __isnan(x)
+            : __isnanl(x);
+    }
+  }
+}
+else version( CRuntime_Bionic )
+{
+    enum
+    {
+        ///
+        FP_INFINITE  = 0x01,
+        ///
+        FP_NAN       = 0x02,
+        ///
+        FP_NORMAL    = 0x04,
+        ///
+        FP_SUBNORMAL = 0x08,
+        ///
+        FP_ZERO      = 0x10,
+    }
+
+    ///
+    enum FP_FAST_FMAF;
+
+    int __fpclassifyd(double);
+    int __fpclassifyf(float);
+    int __fpclassifyl(real);
+
+    int __isfinitef(float);
+    int __isfinite(double);
+    int __isfinitel(real);
+
+    int __isinff(float);
+    int __isinf(double);
+    int __isinfl(real);
+
+    int isnanf(float);
+    int isnan(double);
+    int __isnanl(real);
+
+    int __isnormalf(float);
+    int __isnormal(double);
+    int __isnormall(real);
+
+    int __signbit(double);
+    int __signbitf(float);
+    int __signbitl(real);
+
+  extern (D)
+  {
+    //int fpclassify(real-floating x);
+      ///
+    int fpclassify(float x)     { return __fpclassifyf(x); }
+    ///
+    int fpclassify(double x)    { return __fpclassifyd(x); }
+    ///
+    int fpclassify(real x)      { return __fpclassifyl(x); }
+
+    //int isfinite(real-floating x);
+    ///
+    int isfinite(float x)       { return __isfinitef(x); }
+    ///
+    int isfinite(double x)      { return __isfinite(x); }
+    ///
+    int isfinite(real x)        { return __isfinitel(x); }
+
+    //int isinf(real-floating x);
+    ///
+    int isinf(float x)          { return __isinff(x); }
+    ///
+    int isinf(double x)         { return __isinf(x); }
+    ///
+    int isinf(real x)           { return __isinfl(x); }
+
+    //int isnan(real-floating x);
+    ///
+    int isnan(float x)          { return isnanf(x); }
+    ///
+    int isnan(real x)           { return __isnanl(x); }
+
+    //int isnormal(real-floating x);
+    ///
+    int isnormal(float x)       { return __isnormalf(x); }
+    ///
+    int isnormal(double x)      { return __isnormal(x); }
+    ///
+    int isnormal(real x)        { return __isnormall(x); }
+
+    //int signbit(real-floating x);
+    ///
+    int signbit(float x)        { return __signbitf(x); }
+    ///
+    int signbit(double x)       { return __signbit(x); }
+    ///
+    int signbit(real x)         { return __signbitl(x); }
+  }
+}
+
+extern (D)
+{
+    //int isgreater(real-floating x, real-floating y);
+    ///
+    int isgreater(float x, float y)        { return x > y && !isunordered(x, y); }
+    ///
+    int isgreater(double x, double y)      { return x > y && !isunordered(x, y); }
+    ///
+    int isgreater(real x, real y)          { return x > y && !isunordered(x, y); }
+
+    //int isgreaterequal(real-floating x, real-floating y);
+    ///
+    int isgreaterequal(float x, float y)   { return x >= y && !isunordered(x, y); }
+    ///
+    int isgreaterequal(double x, double y) { return x >= y && !isunordered(x, y); }
+    ///
+    int isgreaterequal(real x, real y)     { return x >= y && !isunordered(x, y); }
+
+    //int isless(real-floating x, real-floating y);
+    ///
+    int isless(float x, float y)           { return x < y && !isunordered(x, y); }
+    ///
+    int isless(double x, double y)         { return x < y && !isunordered(x, y); }
+    ///
+    int isless(real x, real y)             { return x < y && !isunordered(x, y); }
+
+    //int islessequal(real-floating x, real-floating y);
+    ///
+    int islessequal(float x, float y)      { return x <= y && !isunordered(x, y); }
+    ///
+    int islessequal(double x, double y)    { return x <= y && !isunordered(x, y); }
+    ///
+    int islessequal(real x, real y)        { return x <= y && !isunordered(x, y); }
+
+    //int islessgreater(real-floating x, real-floating y);
+    ///
+    int islessgreater(float x, float y)    { return x != y && !isunordered(x, y); }
+    ///
+    int islessgreater(double x, double y)  { return x != y && !isunordered(x, y); }
+    ///
+    int islessgreater(real x, real y)      { return x != y && !isunordered(x, y); }
+
+    //int isunordered(real-floating x, real-floating y);
+    ///
+    int isunordered(float x, float y)      { return isnan(x) || isnan(y); }
+    ///
+    int isunordered(double x, double y)    { return isnan(x) || isnan(y); }
+    ///
+    int isunordered(real x, real y)        { return isnan(x) || isnan(y); }
+}
+
+/* MS define some functions inline.
+ * Additionally, their *l functions work with a 64-bit long double and are thus
+ * useless for 80-bit D reals. So we use our own wrapper implementations working
+ * internally with reduced 64-bit precision.
+ * This also enables relaxing real to 64-bit double.
+ */
+version( CRuntime_Microsoft ) // fully supported since MSVCRT 12 (VS 2013) only
+{
+    ///
+    double  acos(double x);
+    ///
+    float   acosf(float x);
+    ///
+    extern(D) real acosl()(real x)   { return acos(cast(double) x); }
+
+    ///
+    double  asin(double x);
+    ///
+    float   asinf(float x);
+    ///
+    extern(D) real asinl()(real x)   { return asin(cast(double) x); }
+
+    ///
+    double  atan(double x);
+    ///
+    float   atanf(float x);
+    ///
+    extern(D) real atanl()(real x)   { return atan(cast(double) x); }
+
+    ///
+    double  atan2(double y, double x);
+    ///
+    float   atan2f(float y, float x);
+    ///
+    extern(D) real atan2l()(real y, real x) { return atan2(cast(double) y, cast(double) x); }
+
+    ///
+    double  cos(double x);
+    ///
+    float   cosf(float x);
+    ///
+    extern(D) real cosl()(real x)    { return cos(cast(double) x); }
+
+    ///
+    double  sin(double x);
+    ///
+    float   sinf(float x);
+    ///
+    extern(D) real sinl()(real x)    { return sin(cast(double) x); }
+
+    ///
+    double  tan(double x);
+    ///
+    float   tanf(float x);
+    ///
+    extern(D) real tanl()(real x)    { return tan(cast(double) x); }
+
+    ///
+    double  acosh(double x);
+    ///
+    float   acoshf(float x);
+    ///
+    extern(D) real acoshl()(real x)  { return acosh(cast(double) x); }
+
+    ///
+    double  asinh(double x);
+    ///
+    float   asinhf(float x);
+    ///
+    extern(D) real asinhl()(real x)  { return asinh(cast(double) x); }
+
+    ///
+    double  atanh(double x);
+    ///
+    float   atanhf(float x);
+    ///
+    extern(D) real atanhl()(real x)  { return atanh(cast(double) x); }
+
+    ///
+    double  cosh(double x);
+    ///
+    float   coshf(float x);
+    ///
+    extern(D) real coshl()(real x)   { return cosh(cast(double) x); }
+
+    ///
+    double  sinh(double x);
+    ///
+    float   sinhf(float x);
+    ///
+    extern(D) real sinhl()(real x)   { return sinh(cast(double) x); }
+
+    ///
+    double  tanh(double x);
+    ///
+    float   tanhf(float x);
+    ///
+    extern(D) real tanhl()(real x)   { return tanh(cast(double) x); }
+
+    ///
+    double  exp(double x);
+    ///
+    float   expf(float x);
+    ///
+    extern(D) real expl()(real x)    { return exp(cast(double) x); }
+
+    ///
+    double  exp2(double x);
+    ///
+    float   exp2f(float x);
+    ///
+    extern(D) real exp2l()(real x)   { return exp2(cast(double) x); }
+
+    ///
+    double  expm1(double x);
+    ///
+    float   expm1f(float x);
+    ///
+    extern(D) real expm1l()(real x)  { return expm1(cast(double) x); }
+
+    ///
+    double  frexp(double value, int* exp);
+    ///
+    extern(D) float frexpf()(float value, int* exp) { return cast(float) frexp(value, exp); }
+    ///
+    extern(D) real  frexpl()(real value, int* exp)  { return frexp(cast(double) value, exp); }
+
+    ///
+    int     ilogb(double x);
+    ///
+    int     ilogbf(float x);
+    ///
+    extern(D) int ilogbl()(real x)   { return ilogb(cast(double) x); }
+
+    ///
+    double  ldexp(double x, int exp);
+    ///
+    extern(D) float ldexpf()(float x, int exp) { return cast(float) ldexp(x, exp); }
+    ///
+    extern(D) real  ldexpl()(real x, int exp)  { return ldexp(cast(double) x, exp); }
+
+    ///
+    double  log(double x);
+    ///
+    float   logf(float x);
+    ///
+    extern(D) real logl()(real x)    { return log(cast(double) x); }
+
+    ///
+    double  log10(double x);
+    ///
+    float   log10f(float x);
+    ///
+    extern(D) real log10l()(real x)  { return log10(cast(double) x); }
+
+    ///
+    double  log1p(double x);
+    ///
+    float   log1pf(float x);
+    ///
+    extern(D) real log1pl()(real x)  { return log1p(cast(double) x); }
+
+    ///
+    double  log2(double x);
+    ///
+    float   log2f(float x);
+    ///
+    extern(D) real log2l()(real x)   { return log2(cast(double) x); }
+
+    ///
+    double  logb(double x);
+    ///
+    float   logbf(float x);
+    ///
+    extern(D) real logbl()(real x)   { return logb(cast(double) x); }
+
+    ///
+    double  modf(double value, double* iptr);
+    ///
+    float   modff(float value, float* iptr);
+    ///
+    extern(D) real modfl()(real value, real* iptr)
+    {
+        double i;
+        double r = modf(cast(double) value, &i);
+        *iptr = i;
+        return r;
+    }
+
+    ///
+    double  scalbn(double x, int n);
+    ///
+    float   scalbnf(float x, int n);
+    ///
+    extern(D) real scalbnl()(real x, int n) { return scalbn(cast(double) x, n); }
+
+    ///
+    double  scalbln(double x, c_long n);
+    ///
+    float   scalblnf(float x, c_long n);
+    ///
+    extern(D) real scalblnl()(real x, c_long n) { return scalbln(cast(double) x, n); }
+
+    ///
+    double  cbrt(double x);
+    ///
+    float   cbrtf(float x);
+    ///
+    extern(D) real cbrtl()(real x)   { return cbrt(cast(double) x); }
+
+    ///
+    double  fabs(double x);
+    ///
+    extern(D) float fabsf()(float x) { return cast(float) fabs(x); }
+    ///
+    extern(D) real  fabsl()(real x)  { return fabs(cast(double) x); }
+
+    private double _hypot(double x, double y);
+    private float  _hypotf(float x, float y);
+    ///
+    extern(D) double hypot(double x, double y) { return _hypot(x, y); }
+    ///
+    extern(D) float  hypotf(float x, float y)  { return _hypotf(x, y); }
+    ///
+    extern(D) real   hypotl(real x, real y)    { return _hypot(cast(double) x, cast(double) y); }
+
+    ///
+    double  pow(double x, double y);
+    ///
+    float   powf(float x, float y);
+    ///
+    extern(D) real powl()(real x, real y) { return pow(cast(double) x, cast(double) y); }
+
+    ///
+    double  sqrt(double x);
+    ///
+    float   sqrtf(float x);
+    ///
+    extern(D) real sqrtl()(real x)   { return sqrt(cast(double) x); }
+
+    ///
+    double  erf(double x);
+    ///
+    float   erff(float x);
+    ///
+    extern(D) real erfl()(real x)    { return erf(cast(double) x); }
+
+    ///
+    double  erfc(double x);
+    ///
+    float   erfcf(float x);
+    ///
+    extern(D) real erfcl()(real x)   { return erfc(cast(double) x); }
+
+    ///
+    double  lgamma(double x);
+    ///
+    float   lgammaf(float x);
+    ///
+    extern(D) real lgammal()(real x) { return lgamma(cast(double) x); }
+
+    ///
+    double  tgamma(double x);
+    ///
+    float   tgammaf(float x);
+    ///
+    extern(D) real tgammal()(real x) { return tgamma(cast(double) x); }
+
+    ///
+    double  ceil(double x);
+    ///
+    float   ceilf(float x);
+    ///
+    extern(D) real ceill()(real x)   { return ceil(cast(double) x); }
+
+    ///
+    double  floor(double x);
+    ///
+    float   floorf(float x);
+    ///
+    extern(D) real floorl()(real x)  { return floor(cast(double) x); }
+
+    ///
+    double  nearbyint(double x);
+    ///
+    float   nearbyintf(float x);
+    ///
+    extern(D) real nearbyintl()(real x) { return nearbyint(cast(double) x); }
+
+    ///
+    double  rint(double x);
+    ///
+    float   rintf(float x);
+    ///
+    extern(D) real rintl()(real x)   { return rint(cast(double) x); }
+
+    ///
+    c_long  lrint(double x);
+    ///
+    c_long  lrintf(float x);
+    ///
+    extern(D) c_long lrintl()(real x) { return lrint(cast(double) x); }
+
+    ///
+    long    llrint(double x);
+    ///
+    long    llrintf(float x);
+    ///
+    extern(D) long llrintl()(real x) { return llrint(cast(double) x); }
+
+    ///
+    double  round(double x);
+    ///
+    float   roundf(float x);
+    ///
+    extern(D) real roundl()(real x)  { return round(cast(double) x); }
+
+    ///
+    c_long  lround(double x);
+    ///
+    c_long  lroundf(float x);
+    ///
+    extern(D) c_long lroundl()(real x) { return lround(cast(double) x); }
+
+    ///
+    long    llround(double x);
+    ///
+    long    llroundf(float x);
+    ///
+    extern(D) long llroundl()(real x) { return llround(cast(double) x); }
+
+    ///
+    double  trunc(double x);
+    ///
+    float   truncf(float x);
+    ///
+    extern(D) real truncl()(real x)  { return trunc(cast(double) x); }
+
+    ///
+    double  fmod(double x, double y);
+    ///
+    float   fmodf(float x, float y);
+    ///
+    extern(D) real fmodl()(real x, real y) { return fmod(cast(double) x, cast(double) y); }
+
+    ///
+    double  remainder(double x, double y);
+    ///
+    float   remainderf(float x, float y);
+    ///
+    extern(D) real remainderl()(real x, real y) { return remainder(cast(double) x, cast(double) y); }
+
+    ///
+    double  remquo(double x, double y, int* quo);
+    ///
+    float   remquof(float x, float y, int* quo);
+    ///
+    extern(D) real remquol()(real x, real y, int* quo) { return remquo(cast(double) x, cast(double) y, quo); }
+
+    ///
+    double  copysign(double x, double y);
+    ///
+    float   copysignf(float x, float y);
+    ///
+    extern(D) real copysignl()(real x, real y) { return copysign(cast(double) x, cast(double) y); }
+
+    ///
+    double  nan(char* tagp);
+    ///
+    float   nanf(char* tagp);
+    ///
+    extern(D) real nanl()(char* tagp) { return nan(tagp); }
+
+    ///
+    double  nextafter(double x, double y);
+    ///
+    float   nextafterf(float x, float y);
+    ///
+    extern(D) real nextafterl()(real x, real y) { return nextafter(cast(double) x, cast(double) y); }
+
+    ///
+    double  nexttoward(double x, real y);
+    ///
+    float   nexttowardf(float x, real y);
+    ///
+    extern(D) real nexttowardl()(real x, real y) { return nexttoward(cast(double) x, cast(double) y); }
+
+    ///
+    double  fdim(double x, double y);
+    ///
+    float   fdimf(float x, float y);
+    ///
+    extern(D) real fdiml()(real x, real y) { return fdim(cast(double) x, cast(double) y); }
+
+    ///
+    double  fmax(double x, double y);
+    ///
+    float   fmaxf(float x, float y);
+    ///
+    extern(D) real fmaxl()(real x, real y) { return fmax(cast(double) x, cast(double) y); }
+
+    ///
+    double  fmin(double x, double y);
+    ///
+    float   fminf(float x, float y);
+    ///
+    extern(D) real fminl()(real x, real y) { return fmin(cast(double) x, cast(double) y); }
+
+    ///
+    double  fma(double x, double y, double z);
+    ///
+    float   fmaf(float x, float y, float z);
+    ///
+    extern(D) real fmal()(real x, real y, real z) { return fma(cast(double) x, cast(double) y, cast(double) z); }
+}
+/* NOTE: freebsd < 8-CURRENT doesn't appear to support *l, but we can
+ *       approximate.
+ * A lot of them were added in 8.0-RELEASE, and so a lot of these workarounds
+ * should then be removed.
+ */
+// NOTE: FreeBSD 8.0-RELEASE doesn't support log2* nor these *l functions:
+//         acoshl, asinhl, atanhl, coshl, sinhl, tanhl, cbrtl, powl, expl,
+//         expm1l, logl, log1pl, log10l, erfcl, erfl, lgammal, tgammal;
+//       but we can approximate.
+else version( FreeBSD )
+{
+  version (none) // < 8-CURRENT
+  {
+    real    acosl(real x) { return acos(x); }
+    real    asinl(real x) { return asin(x); }
+    real    atanl(real x) { return atan(x); }
+    real    atan2l(real y, real x) { return atan2(y, x); }
+    real    cosl(real x) { return cos(x); }
+    real    sinl(real x) { return sin(x); }
+    real    tanl(real x) { return tan(x); }
+    real    exp2l(real x) { return exp2(x); }
+    real    frexpl(real value, int* exp) { return frexp(value, exp); }
+    int     ilogbl(real x) { return ilogb(x); }
+    real    ldexpl(real x, int exp) { return ldexp(x, exp); }
+    real    logbl(real x) { return logb(x); }
+    //real    modfl(real value, real *iptr); // nontrivial conversion
+    real    scalbnl(real x, int n) { return scalbn(x, n); }
+    real    scalblnl(real x, c_long n) { return scalbln(x, n); }
+    real    fabsl(real x) { return fabs(x); }
+    real    hypotl(real x, real y) { return hypot(x, y); }
+    real    sqrtl(real x) { return sqrt(x); }
+    real    ceill(real x) { return ceil(x); }
+    real    floorl(real x) { return floor(x); }
+    real    nearbyintl(real x) { return nearbyint(x); }
+    real    rintl(real x) { return rint(x); }
+    c_long  lrintl(real x) { return lrint(x); }
+    real    roundl(real x) { return round(x); }
+    c_long  lroundl(real x) { return lround(x); }
+    long    llroundl(real x) { return llround(x); }
+    real    truncl(real x) { return trunc(x); }
+    real    fmodl(real x, real y) { return fmod(x, y); }
+    real    remainderl(real x, real y) { return remainder(x, y); }
+    real    remquol(real x, real y, int* quo) { return remquo(x, y, quo); }
+    real    copysignl(real x, real y) { return copysign(x, y); }
+//  double  nan(char* tagp);
+//  float   nanf(char* tagp);
+//  real    nanl(char* tagp);
+    real    nextafterl(real x, real y) { return nextafter(x, y); }
+    real    nexttowardl(real x, real y) { return nexttoward(x, y); }
+    real    fdiml(real x, real y) { return fdim(x, y); }
+    real    fmaxl(real x, real y) { return fmax(x, y); }
+    real    fminl(real x, real y) { return fmin(x, y); }
+    real    fmal(real x, real y, real z) { return fma(x, y, z); }
+  }
+  else
+  {
+      ///
+    real    acosl(real x);
+    ///
+    real    asinl(real x);
+    ///
+    real    atanl(real x);
+    ///
+    real    atan2l(real y, real x);
+    ///
+    real    cosl(real x);
+    ///
+    real    sinl(real x);
+    ///
+    real    tanl(real x);
+    ///
+    real    exp2l(real x);
+    ///
+    real    frexpl(real value, int* exp);
+    ///
+    int     ilogbl(real x);
+    ///
+    real    ldexpl(real x, int exp);
+    ///
+    real    logbl(real x);
+    ///
+    real    modfl(real value, real *iptr);
+    ///
+    real    scalbnl(real x, int n);
+    ///
+    real    scalblnl(real x, c_long n);
+    ///
+    real    fabsl(real x);
+    ///
+    real    hypotl(real x, real y);
+    ///
+    real    sqrtl(real x);
+    ///
+    real    ceill(real x);
+    ///
+    real    floorl(real x);
+    ///
+    real    nearbyintl(real x);
+    ///
+    real    rintl(real x);
+    ///
+    c_long  lrintl(real x);
+    ///
+    real    roundl(real x);
+    ///
+    c_long  lroundl(real x);
+    ///
+    long    llroundl(real x);
+    ///
+    real    truncl(real x);
+    ///
+    real    fmodl(real x, real y);
+    ///
+    real    remainderl(real x, real y);
+    ///
+    real    remquol(real x, real y, int* quo);
+    ///
+    real    copysignl(real x, real y);
+    ///
+    double  nan(char* tagp);
+    ///
+    float   nanf(char* tagp);
+    ///
+    real    nanl(char* tagp);
+    ///
+    real    nextafterl(real x, real y);
+    ///
+    real    nexttowardl(real x, real y);
+    ///
+    real    fdiml(real x, real y);
+    ///
+    real    fmaxl(real x, real y);
+    ///
+    real    fminl(real x, real y);
+    ///
+    real    fmal(real x, real y, real z);
+  }
+  ///
+    double  acos(double x);
+    ///
+    float   acosf(float x);
+
+    ///
+    double  asin(double x);
+    ///
+    float   asinf(float x);
+
+    ///
+    double  atan(double x);
+    ///
+    float   atanf(float x);
+
+    ///
+    double  atan2(double y, double x);
+    ///
+    float   atan2f(float y, float x);
+
+    ///
+    double  cos(double x);
+    ///
+    float   cosf(float x);
+
+    ///
+    double  sin(double x);
+    ///
+    float   sinf(float x);
+
+    ///
+    double  tan(double x);
+    ///
+    float   tanf(float x);
+
+    ///
+    double  acosh(double x);
+    ///
+    float   acoshf(float x);
+    ///
+    real    acoshl(real x) { return acosh(x); }
+
+    ///
+    double  asinh(double x);
+    ///
+    float   asinhf(float x);
+    ///
+    real    asinhl(real x) { return asinh(x); }
+
+    ///
+    double  atanh(double x);
+    ///
+    float   atanhf(float x);
+    ///
+    real    atanhl(real x) { return atanh(x); }
+
+    ///
+    double  cosh(double x);
+    ///
+    float   coshf(float x);
+    ///
+    real    coshl(real x) { return cosh(x); }
+
+    ///
+    double  sinh(double x);
+    ///
+    float   sinhf(float x);
+    ///
+    real    sinhl(real x) { return sinh(x); }
+
+    ///
+    double  tanh(double x);
+    ///
+    float   tanhf(float x);
+    ///
+    real    tanhl(real x) { return tanh(x); }
+
+    ///
+    double  exp(double x);
+    ///
+    float   expf(float x);
+    ///
+    real    expl(real x) { return exp(x); }
+
+    ///
+    double  exp2(double x);
+    ///
+    float   exp2f(float x);
+
+    ///
+    double  expm1(double x);
+    ///
+    float   expm1f(float x);
+    ///
+    real    expm1l(real x) { return expm1(x); }
+
+    ///
+    double  frexp(double value, int* exp);
+    ///
+    float   frexpf(float value, int* exp);
+
+    ///
+    int     ilogb(double x);
+    ///
+    int     ilogbf(float x);
+
+    ///
+    double  ldexp(double x, int exp);
+    ///
+    float   ldexpf(float x, int exp);
+
+    ///
+    double  log(double x);
+    ///
+    float   logf(float x);
+    ///
+    real    logl(real x) { return log(x); }
+
+    ///
+    double  log10(double x);
+    ///
+    float   log10f(float x);
+    ///
+    real    log10l(real x) { return log10(x); }
+
+    ///
+    double  log1p(double x);
+    ///
+    float   log1pf(float x);
+    ///
+    real    log1pl(real x) { return log1p(x); }
+
+    private enum real ONE_LN2 = 1 / 0x1.62e42fefa39ef358p-1L;
+    ///
+    double  log2(double x) { return log(x) * ONE_LN2; }
+    ///
+    float   log2f(float x) { return logf(x) * ONE_LN2; }
+    ///
+    real    log2l(real x)  { return logl(x) * ONE_LN2; }
+
+    ///
+    double  logb(double x);
+    ///
+    float   logbf(float x);
+
+    ///
+    double  modf(double value, double* iptr);
+    ///
+    float   modff(float value, float* iptr);
+
+    ///
+    double  scalbn(double x, int n);
+    ///
+    float   scalbnf(float x, int n);
+
+    ///
+    double  scalbln(double x, c_long n);
+    ///
+    float   scalblnf(float x, c_long n);
+
+    ///
+    double  cbrt(double x);
+    ///
+    float   cbrtf(float x);
+    ///
+    real    cbrtl(real x) { return cbrt(x); }
+
+    ///
+    double  fabs(double x);
+    ///
+    float   fabsf(float x);
+
+    ///
+    double  hypot(double x, double y);
+    ///
+    float   hypotf(float x, float y);
+
+    ///
+    double  pow(double x, double y);
+    ///
+    float   powf(float x, float y);
+    ///
+    real    powl(real x, real y) { return pow(x, y); }
+
+    ///
+    double  sqrt(double x);
+    ///
+    float   sqrtf(float x);
+
+    ///
+    double  erf(double x);
+    ///
+    float   erff(float x);
+    ///
+    real    erfl(real x) { return erf(x); }
+
+    ///
+    double  erfc(double x);
+    ///
+    float   erfcf(float x);
+    ///
+    real    erfcl(real x) { return erfc(x); }
+
+    ///
+    double  lgamma(double x);
+    ///
+    float   lgammaf(float x);
+    ///
+    real    lgammal(real x) { return lgamma(x); }
+
+    ///
+    double  tgamma(double x);
+    ///
+    float   tgammaf(float x);
+    ///
+    real    tgammal(real x) { return tgamma(x); }
+
+    ///
+    double  ceil(double x);
+    ///
+    float   ceilf(float x);
+
+    ///
+    double  floor(double x);
+    ///
+    float   floorf(float x);
+
+    ///
+    double  nearbyint(double x);
+    ///
+    float   nearbyintf(float x);
+
+    ///
+    double  rint(double x);
+    ///
+    float   rintf(float x);
+
+    ///
+    c_long  lrint(double x);
+    ///
+    c_long  lrintf(float x);
+
+    ///
+    long    llrint(double x);
+    ///
+    long    llrintf(float x);
+    ///
+    long    llrintl(real x) { return llrint(x); }
+
+    ///
+    double  round(double x);
+    ///
+    float   roundf(float x);
+
+    ///
+    c_long  lround(double x);
+    ///
+    c_long  lroundf(float x);
+
+    ///
+    long    llround(double x);
+    ///
+    long    llroundf(float x);
+
+    ///
+    double  trunc(double x);
+    ///
+    float   truncf(float x);
+
+    ///
+    double  fmod(double x, double y);
+    ///
+    float   fmodf(float x, float y);
+
+    ///
+    double  remainder(double x, double y);
+    ///
+    float   remainderf(float x, float y);
+
+    ///
+    double  remquo(double x, double y, int* quo);
+    ///
+    float   remquof(float x, float y, int* quo);
+
+    ///
+    double  copysign(double x, double y);
+    ///
+    float   copysignf(float x, float y);
+
+    ///
+    double  nextafter(double x, double y);
+    ///
+    float   nextafterf(float x, float y);
+
+    ///
+    double  nexttoward(double x, real y);
+    ///
+    float   nexttowardf(float x, real y);
+
+    ///
+    double  fdim(double x, double y);
+    ///
+    float   fdimf(float x, float y);
+
+    ///
+    double  fmax(double x, double y);
+    ///
+    float   fmaxf(float x, float y);
+
+    ///
+    double  fmin(double x, double y);
+    ///
+    float   fminf(float x, float y);
+
+    ///
+    double  fma(double x, double y, double z);
+    ///
+    float   fmaf(float x, float y, float z);
+}
+else version(CRuntime_Bionic)
+{
+    // Bionic defines long double as 64 bits, same as double, so several long
+    // double functions are missing.  nexttoward was modified to reflect this.
+    ///
+    double  acos(double x);
+    ///
+    float   acosf(float x);
+    //real    acosl(real x);
+
+    ///
+    double  asin(double x);
+    ///
+    float   asinf(float x);
+    //real    asinl(real x);
+
+    ///
+    double  atan(double x);
+    ///
+    float   atanf(float x);
+    //real    atanl(real x);
+
+    ///
+    double  atan2(double y, double x);
+    ///
+    float   atan2f(float y, float x);
+    //real    atan2l(real y, real x);
+
+    ///
+    double  cos(double x);
+    ///
+    float   cosf(float x);
+    //real    cosl(real x);
+
+    ///
+    double  sin(double x);
+    ///
+    float   sinf(float x);
+    //real    sinl(real x);
+
+    ///
+    double  tan(double x);
+    ///
+    float   tanf(float x);
+    //real    tanl(real x);
+
+    ///
+    double  acosh(double x);
+    ///
+    float   acoshf(float x);
+    //real    acoshl(real x);
+
+    ///
+    double  asinh(double x);
+    ///
+    float   asinhf(float x);
+    //real    asinhl(real x);
+
+    ///
+    double  atanh(double x);
+    ///
+    float   atanhf(float x);
+    //real    atanhl(real x);
+
+    ///
+    double  cosh(double x);
+    ///
+    float   coshf(float x);
+    //real    coshl(real x);
+
+    ///
+    double  sinh(double x);
+    ///
+    float   sinhf(float x);
+    //real    sinhl(real x);
+
+    ///
+    double  tanh(double x);
+    ///
+    float   tanhf(float x);
+    //real    tanhl(real x);
+
+    ///
+    double  exp(double x);
+    ///
+    float   expf(float x);
+    //real    expl(real x);
+
+    ///
+    double  exp2(double x);
+    ///
+    float   exp2f(float x);
+    ///
+    real    exp2l(real x) { return exp2(x); }
+
+    ///
+    double  expm1(double x);
+    ///
+    float   expm1f(float x);
+    //real    expm1l(real x);
+
+    ///
+    double  frexp(double value, int* exp);
+    ///
+    float   frexpf(float value, int* exp);
+    // alias for double: real    frexpl(real value, int* exp);
+
+    ///
+    int     ilogb(double x);
+    ///
+    int     ilogbf(float x);
+    ///
+    int     ilogbl(real x) { return ilogb(x); }
+
+    ///
+    double  ldexp(double x, int exp);
+    ///
+    float   ldexpf(float x, int exp);
+    // alias for double: real    ldexpl(real x, int exp);
+
+    ///
+    double  log(double x);
+    ///
+    float   logf(float x);
+    //real    logl(real x);
+
+    ///
+    double  log10(double x);
+    ///
+    float   log10f(float x);
+    //real    log10l(real x);
+
+    ///
+    double  log1p(double x);
+    ///
+    float   log1pf(float x);
+    //real    log1pl(real x);
+
+    //double  log2(double x);
+    //float   log2f(float x);
+    //real    log2l(real x);
+
+    ///
+    double  logb(double x);
+    ///
+    float   logbf(float x);
+    ///
+    real    logbl(real x) { return logb(x); }
+
+    ///
+    double  modf(double value, double* iptr);
+    ///
+    float   modff(float value, float* iptr);
+    ///
+    real    modfl(real value, real *iptr) { return modf(value, cast(double*)iptr); }
+
+    ///
+    double  scalbn(double x, int n);
+    ///
+    float   scalbnf(float x, int n);
+    // alias for double: real    scalbnl(real x, int n);
+
+    ///
+    double  scalbln(double x, c_long n);
+    ///
+    float   scalblnf(float x, c_long n);
+    // alias for double: real    scalblnl(real x, c_long n);
+
+    ///
+    double  cbrt(double x);
+    ///
+    float   cbrtf(float x);
+    ///
+    real    cbrtl(real x) { return cbrt(x); }
+
+    ///
+    double  fabs(double x);
+    ///
+    float   fabsf(float x);
+    // alias for double: real    fabsl(real x);
+
+    ///
+    double  hypot(double x, double y);
+    ///
+    float   hypotf(float x, float y);
+    //real    hypotl(real x, real y);
+
+    ///
+    double  pow(double x, double y);
+    ///
+    float   powf(float x, float y);
+    //real    powl(real x, real y);
+
+    ///
+    double  sqrt(double x);
+    ///
+    float   sqrtf(float x);
+    //real    sqrtl(real x);
+
+    ///
+    double  erf(double x);
+    ///
+    float   erff(float x);
+    //real    erfl(real x);
+
+    ///
+    double  erfc(double x);
+    ///
+    float   erfcf(float x);
+    //real    erfcl(real x);
+
+    ///
+    double  lgamma(double x);
+    ///
+    float   lgammaf(float x);
+    //real    lgammal(real x);
+
+    ///
+    double  tgamma(double x);
+    //float   tgammaf(float x);
+    //real    tgammal(real x);
+
+    ///
+    double  ceil(double x);
+    ///
+    float   ceilf(float x);
+    // alias for double: real    ceill(real x);
+
+    ///
+    double  floor(double x);
+    ///
+    float   floorf(float x);
+    // alias for double: real    floorl(real x);
+
+    ///
+    double  nearbyint(double x);
+    ///
+    float   nearbyintf(float x);
+    ///
+    real    nearbyintl(real x) { return nearbyint(x); }
+
+    ///
+    double  rint(double x);
+    ///
+    float   rintf(float x);
+    //real    rintl(real x);
+
+    ///
+    c_long  lrint(double x);
+    ///
+    c_long  lrintf(float x);
+    //c_long  lrintl(real x);
+
+    ///
+    long    llrint(double x);
+    ///
+    long    llrintf(float x);
+    //long    llrintl(real x);
+
+    ///
+    double  round(double x);
+    ///
+    float   roundf(float x);
+    ///
+    real    roundl(real x) { return round(x); }
+
+    ///
+    c_long  lround(double x);
+    ///
+    c_long  lroundf(float x);
+    // alias for double: c_long  lroundl(real x);
+
+    ///
+    long    llround(double x);
+    ///
+    long    llroundf(float x);
+    ///
+    long    llroundl(real x) { return llround(x); }
+
+    ///
+    double  trunc(double x);
+    ///
+    float   truncf(float x);
+    ///
+    real    truncl(real x) { return trunc(x); }
+
+    ///
+    double  fmod(double x, double y);
+    ///
+    float   fmodf(float x, float y);
+    ///
+    real    fmodl(real x, real y) { return fmod(x,y); }
+
+    ///
+    double  remainder(double x, double y);
+    ///
+    float   remainderf(float x, float y);
+    ///
+    real    remainderl(real x, real y) { return remainder(x,y); }
+
+    ///
+    double  remquo(double x, double y, int* quo);
+    ///
+    float   remquof(float x, float y, int* quo);
+    ///
+    real    remquol(real x, real y, int* quo) { return remquo(x,y,quo); }
+
+    ///
+    double  copysign(double x, double y);
+    ///
+    float   copysignf(float x, float y);
+    // alias for double: real    copysignl(real x, real y);
+
+    //double  nan(char* tagp);
+    //float   nanf(char* tagp);
+    //real    nanl(char* tagp);
+
+    ///
+    double  nextafter(double x, double y);
+    ///
+    float   nextafterf(float x, float y);
+    // alias for double: real    nextafterl(real x, real y);
+
+    ///
+    double  nexttoward(double x, double y);
+    ///
+    float   nexttowardf(float x, double y);
+    // alias for double: real    nexttowardl(real x, real y);
+
+    ///
+    double  fdim(double x, double y);
+    ///
+    float   fdimf(float x, float y);
+    // alias for double: real    fdiml(real x, real y);
+
+    ///
+    double  fmax(double x, double y);
+    ///
+    float   fmaxf(float x, float y);
+    // alias for double: real    fmaxl(real x, real y);
+
+    ///
+    double  fmin(double x, double y);
+    ///
+    float   fminf(float x, float y);
+    // alias for double: real    fminl(real x, real y);
+
+    ///
+    double  fma(double x, double y, double z);
+    ///
+    float   fmaf(float x, float y, float z);
+    // alias for double: real    fmal(real x, real y, real z);
+}
+else
+{
+    ///
+    double  acos(double x);
+    ///
+    float   acosf(float x);
+    ///
+    real    acosl(real x);
+
+    ///
+    double  asin(double x);
+    ///
+    float   asinf(float x);
+    ///
+    real    asinl(real x);
+
+    ///
+    double  atan(double x);
+    ///
+    float   atanf(float x);
+    ///
+    real    atanl(real x);
+
+    ///
+    double  atan2(double y, double x);
+    ///
+    float   atan2f(float y, float x);
+    ///
+    real    atan2l(real y, real x);
+
+    ///
+    double  cos(double x);
+    ///
+    float   cosf(float x);
+    ///
+    real    cosl(real x);
+
+    ///
+    double  sin(double x);
+    ///
+    float   sinf(float x);
+    ///
+    real    sinl(real x);
+
+    ///
+    double  tan(double x);
+    ///
+    float   tanf(float x);
+    ///
+    real    tanl(real x);
+
+    ///
+    double  acosh(double x);
+    ///
+    float   acoshf(float x);
+    ///
+    real    acoshl(real x);
+
+    ///
+    double  asinh(double x);
+    ///
+    float   asinhf(float x);
+    ///
+    real    asinhl(real x);
+
+    ///
+    double  atanh(double x);
+    ///
+    float   atanhf(float x);
+    ///
+    real    atanhl(real x);
+
+    ///
+    double  cosh(double x);
+    ///
+    float   coshf(float x);
+    ///
+    real    coshl(real x);
+
+    ///
+    double  sinh(double x);
+    ///
+    float   sinhf(float x);
+    ///
+    real    sinhl(real x);
+
+    ///
+    double  tanh(double x);
+    ///
+    float   tanhf(float x);
+    ///
+    real    tanhl(real x);
+
+    ///
+    double  exp(double x);
+    ///
+    float   expf(float x);
+    ///
+    real    expl(real x);
+
+    ///
+    double  exp2(double x);
+    ///
+    float   exp2f(float x);
+    ///
+    real    exp2l(real x);
+
+    ///
+    double  expm1(double x);
+    ///
+    float   expm1f(float x);
+    ///
+    real    expm1l(real x);
+
+    ///
+    double  frexp(double value, int* exp);
+    ///
+    float   frexpf(float value, int* exp);
+    ///
+    real    frexpl(real value, int* exp);
+
+    ///
+    int     ilogb(double x);
+    ///
+    int     ilogbf(float x);
+    ///
+    int     ilogbl(real x);
+
+    ///
+    double  ldexp(double x, int exp);
+    ///
+    float   ldexpf(float x, int exp);
+    ///
+    real    ldexpl(real x, int exp);
+
+    ///
+    double  log(double x);
+    ///
+    float   logf(float x);
+    ///
+    real    logl(real x);
+
+    ///
+    double  log10(double x);
+    ///
+    float   log10f(float x);
+    ///
+    real    log10l(real x);
+
+    ///
+    double  log1p(double x);
+    ///
+    float   log1pf(float x);
+    ///
+    real    log1pl(real x);
+
+    ///
+    double  log2(double x);
+    ///
+    float   log2f(float x);
+    ///
+    real    log2l(real x);
+
+    ///
+    double  logb(double x);
+    ///
+    float   logbf(float x);
+    ///
+    real    logbl(real x);
+
+    ///
+    double  modf(double value, double* iptr);
+    ///
+    float   modff(float value, float* iptr);
+    ///
+    real    modfl(real value, real *iptr);
+
+    ///
+    double  scalbn(double x, int n);
+    ///
+    float   scalbnf(float x, int n);
+    ///
+    real    scalbnl(real x, int n);
+
+    ///
+    double  scalbln(double x, c_long n);
+    ///
+    float   scalblnf(float x, c_long n);
+    ///
+    real    scalblnl(real x, c_long n);
+
+    ///
+    double  cbrt(double x);
+    ///
+    float   cbrtf(float x);
+    ///
+    real    cbrtl(real x);
+
+    ///
+    double  fabs(double x);
+    version( CRuntime_Microsoft )
+    {
+    }
+    else
+    {
+        ///
+        float   fabsf(float x);
+        ///
+        real    fabsl(real x);
+    }
+
+    ///
+    double  hypot(double x, double y);
+    ///
+    float   hypotf(float x, float y);
+    ///
+    real    hypotl(real x, real y);
+
+    ///
+    double  pow(double x, double y);
+    ///
+    float   powf(float x, float y);
+    ///
+    real    powl(real x, real y);
+
+    ///
+    double  sqrt(double x);
+    ///
+    float   sqrtf(float x);
+    ///
+    real    sqrtl(real x);
+
+    ///
+    double  erf(double x);
+    ///
+    float   erff(float x);
+    ///
+    real    erfl(real x);
+
+    ///
+    double  erfc(double x);
+    ///
+    float   erfcf(float x);
+    ///
+    real    erfcl(real x);
+
+    ///
+    double  lgamma(double x);
+    ///
+    float   lgammaf(float x);
+    ///
+    real    lgammal(real x);
+
+    ///
+    double  tgamma(double x);
+    ///
+    float   tgammaf(float x);
+    ///
+    real    tgammal(real x);
+
+    ///
+    double  ceil(double x);
+    ///
+    float   ceilf(float x);
+    ///
+    real    ceill(real x);
+
+    ///
+    double  floor(double x);
+    ///
+    float   floorf(float x);
+    ///
+    real    floorl(real x);
+
+    ///
+    double  nearbyint(double x);
+    ///
+    float   nearbyintf(float x);
+    ///
+    real    nearbyintl(real x);
+
+    ///
+    double  rint(double x);
+    ///
+    float   rintf(float x);
+    ///
+    real    rintl(real x);
+
+    ///
+    c_long  lrint(double x);
+    ///
+    c_long  lrintf(float x);
+    ///
+    c_long  lrintl(real x);
+
+    ///
+    long    llrint(double x);
+    ///
+    long    llrintf(float x);
+    ///
+    long    llrintl(real x);
+
+    ///
+    double  round(double x);
+    ///
+    float   roundf(float x);
+    ///
+    real    roundl(real x);
+
+    ///
+    c_long  lround(double x);
+    ///
+    c_long  lroundf(float x);
+    ///
+    c_long  lroundl(real x);
+
+    ///
+    long    llround(double x);
+    ///
+    long    llroundf(float x);
+    ///
+    long    llroundl(real x);
+
+    ///
+    double  trunc(double x);
+    ///
+    float   truncf(float x);
+    ///
+    real    truncl(real x);
+
+    ///
+    double  fmod(double x, double y);
+    ///
+    float   fmodf(float x, float y);
+    ///
+    real    fmodl(real x, real y);
+
+    ///
+    double  remainder(double x, double y);
+    ///
+    float   remainderf(float x, float y);
+    ///
+    real    remainderl(real x, real y);
+
+    ///
+    double  remquo(double x, double y, int* quo);
+    ///
+    float   remquof(float x, float y, int* quo);
+    ///
+    real    remquol(real x, real y, int* quo);
+
+    ///
+    double  copysign(double x, double y);
+    ///
+    float   copysignf(float x, float y);
+    ///
+    real    copysignl(real x, real y);
+
+    ///
+    double  nan(char* tagp);
+    ///
+    float   nanf(char* tagp);
+    ///
+    real    nanl(char* tagp);
+
+    ///
+    double  nextafter(double x, double y);
+    ///
+    float   nextafterf(float x, float y);
+    ///
+    real    nextafterl(real x, real y);
+
+    ///
+    double  nexttoward(double x, real y);
+    ///
+    float   nexttowardf(float x, real y);
+    ///
+    real    nexttowardl(real x, real y);
+
+    ///
+    double  fdim(double x, double y);
+    ///
+    float   fdimf(float x, float y);
+    ///
+    real    fdiml(real x, real y);
+
+    ///
+    double  fmax(double x, double y);
+    ///
+    float   fmaxf(float x, float y);
+    ///
+    real    fmaxl(real x, real y);
+
+    ///
+    double  fmin(double x, double y);
+    ///
+    float   fminf(float x, float y);
+    ///
+    real    fminl(real x, real y);
+
+    ///
+    double  fma(double x, double y, double z);
+    ///
+    float   fmaf(float x, float y, float z);
+    ///
+    real    fmal(real x, real y, real z);
+}
diff --git a/libphobos/libdruntime/core/stdc/signal.d b/libphobos/libdruntime/core/stdc/signal.d
new file mode 100644
index 00000000000..6a66d3e88d3
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/signal.d
@@ -0,0 +1,78 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_signal.h.html, _signal.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_signal.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.signal;
+
+extern (C):
+@system:
+nothrow:
+@nogc:
+
+// this should be volatile
+///
+alias int sig_atomic_t;
+
+private alias void function(int) sigfn_t;
+
+version( Posix )
+{
+    ///
+    enum SIG_ERR    = cast(sigfn_t) -1;
+    ///
+    enum SIG_DFL    = cast(sigfn_t) 0;
+    ///
+    enum SIG_IGN    = cast(sigfn_t) 1;
+
+    // standard C signals
+    ///
+    enum SIGABRT    = 6;  // Abnormal termination
+    ///
+    enum SIGFPE     = 8;  // Floating-point error
+    ///
+    enum SIGILL     = 4;  // Illegal hardware instruction
+    ///
+    enum SIGINT     = 2;  // Terminal interrupt character
+    ///
+    enum SIGSEGV    = 11; // Invalid memory reference
+    ///
+    enum SIGTERM    = 15; // Termination
+}
+else version( Windows )
+{
+    ///
+    enum SIG_ERR    = cast(sigfn_t) -1;
+    ///
+    enum SIG_DFL    = cast(sigfn_t) 0;
+    ///
+    enum SIG_IGN    = cast(sigfn_t) 1;
+
+    // standard C signals
+    ///
+    enum SIGABRT    = 22; // Abnormal termination
+    ///
+    enum SIGFPE     = 8;  // Floating-point error
+    ///
+    enum SIGILL     = 4;  // Illegal hardware instruction
+    ///
+    enum SIGINT     = 2;  // Terminal interrupt character
+    ///
+    enum SIGSEGV    = 11; // Invalid memory reference
+    ///
+    enum SIGTERM    = 15; // Termination
+}
+
+///
+sigfn_t signal(int sig, sigfn_t func);
+///
+int     raise(int sig);
diff --git a/libphobos/libdruntime/core/stdc/stdarg.d b/libphobos/libdruntime/core/stdc/stdarg.d
new file mode 100644
index 00000000000..667e7be25f2
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/stdarg.d
@@ -0,0 +1,687 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_stdarg.h.html, _stdarg.h)
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Hauke Duden
+ * Standards: ISO/IEC 9899:1999 (E)
+ * Source: $(DRUNTIMESRC core/stdc/_stdarg.d)
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module core.stdc.stdarg;
+
+@system:
+//@nogc:    // Not yet, need to make TypeInfo's member functions @nogc first
+nothrow:
+
+version( GNU )
+{
+    import gcc.builtins;
+    alias __builtin_va_list __gnuc_va_list;
+
+
+    /*********************
+     * The argument pointer type.
+     */
+    alias __gnuc_va_list va_list;
+
+
+    /**********
+     * Initialize ap.
+     * parmn should be the last named parameter.
+     */
+    void va_start(T)(out va_list ap, ref T parmn);
+
+
+    /************
+     * Retrieve and return the next value that is type T.
+     */
+    T va_arg(T)(ref va_list ap);
+
+
+    /*************
+     * Retrieve and store through parmn the next value that is of type T.
+     */
+    void va_arg(T)(ref va_list ap, ref T parmn);
+
+
+    /*************
+     * Retrieve and store through parmn the next value that is of TypeInfo ti.
+     * Used when the static type is not known.
+     */
+    version( X86 )
+    {
+        ///
+        void va_arg()(ref va_list ap, TypeInfo ti, void* parmn)
+        {
+            auto p = ap;
+            auto tsize = ti.tsize;
+            ap = cast(va_list)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
+            parmn[0..tsize] = p[0..tsize];
+        }
+    }
+    else version( X86_64 )
+    {
+        /// Layout of this struct must match __builtin_va_list for C ABI compatibility
+        struct __va_list
+        {
+            uint offset_regs = 6 * 8;            // no regs
+            uint offset_fpregs = 6 * 8 + 8 * 16; // no fp regs
+            void* stack_args;
+            void* reg_args;
+        }
+
+        ///
+        void va_arg()(ref va_list apx, TypeInfo ti, void* parmn)
+        {
+            __va_list* ap = cast(__va_list*)apx;
+            TypeInfo arg1, arg2;
+            if (!ti.argTypes(arg1, arg2))
+            {
+                bool inXMMregister(TypeInfo arg) pure nothrow @safe
+                {
+                    return (arg.flags & 2) != 0;
+                }
+
+                TypeInfo_Vector v1 = arg1 ? cast(TypeInfo_Vector)arg1 : null;
+                if (arg1 && (arg1.tsize() <= 8 || v1))
+                {   // Arg is passed in one register
+                    auto tsize = arg1.tsize();
+                    void* p;
+                    bool stack = false;
+                    auto offset_fpregs_save = ap.offset_fpregs;
+                    auto offset_regs_save = ap.offset_regs;
+                L1:
+                    if (inXMMregister(arg1) || v1)
+                    {   // Passed in XMM register
+                        if (ap.offset_fpregs < (6 * 8 + 16 * 8) && !stack)
+                        {
+                            p = ap.reg_args + ap.offset_fpregs;
+                            ap.offset_fpregs += 16;
+                        }
+                        else
+                        {
+                            p = ap.stack_args;
+                            ap.stack_args += (tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                            stack = true;
+                        }
+                    }
+                    else
+                    {   // Passed in regular register
+                        if (ap.offset_regs < 6 * 8 && !stack)
+                        {
+                            p = ap.reg_args + ap.offset_regs;
+                            ap.offset_regs += 8;
+                        }
+                        else
+                        {
+                            p = ap.stack_args;
+                            ap.stack_args += 8;
+                            stack = true;
+                        }
+                    }
+                    parmn[0..tsize] = p[0..tsize];
+
+                    if (arg2)
+                    {
+                        if (inXMMregister(arg2))
+                        {   // Passed in XMM register
+                            if (ap.offset_fpregs < (6 * 8 + 16 * 8) && !stack)
+                            {
+                                p = ap.reg_args + ap.offset_fpregs;
+                                ap.offset_fpregs += 16;
+                            }
+                            else
+                            {
+                                if (!stack)
+                                {   // arg1 is really on the stack, so rewind and redo
+                                    ap.offset_fpregs = offset_fpregs_save;
+                                    ap.offset_regs = offset_regs_save;
+                                    stack = true;
+                                    goto L1;
+                                }
+                                p = ap.stack_args;
+                                ap.stack_args += (arg2.tsize() + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                            }
+                        }
+                        else
+                        {   // Passed in regular register
+                            if (ap.offset_regs < 6 * 8 && !stack)
+                            {
+                                p = ap.reg_args + ap.offset_regs;
+                                ap.offset_regs += 8;
+                            }
+                            else
+                            {
+                                if (!stack)
+                                {   // arg1 is really on the stack, so rewind and redo
+                                    ap.offset_fpregs = offset_fpregs_save;
+                                    ap.offset_regs = offset_regs_save;
+                                    stack = true;
+                                    goto L1;
+                                }
+                                p = ap.stack_args;
+                                ap.stack_args += 8;
+                            }
+                        }
+                        auto sz = ti.tsize() - 8;
+                        (parmn + 8)[0..sz] = p[0..sz];
+                    }
+                }
+                else
+                {   // Always passed in memory
+                    // The arg may have more strict alignment than the stack
+                    auto talign = ti.talign();
+                    auto tsize = ti.tsize();
+                    auto p = cast(void*)((cast(size_t)ap.stack_args + talign - 1) & ~(talign - 1));
+                    ap.stack_args = cast(void*)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
+                    parmn[0..tsize] = p[0..tsize];
+                }
+            }
+            else
+            {
+                assert(false, "not a valid argument type for va_arg");
+            }
+        }
+    }
+    else version( ARM )
+    {
+        ///
+        void va_arg()(ref va_list ap, TypeInfo ti, void* parmn)
+        {
+            auto p = *cast(void**) &ap;
+            auto tsize = ti.tsize();
+            *cast(void**) &ap += ( tsize + size_t.sizeof - 1 ) & ~( size_t.sizeof - 1 );
+            parmn[0..tsize] = p[0..tsize];
+        }
+    }
+    else
+    {
+        ///
+        void va_arg()(ref va_list ap, TypeInfo ti, void* parmn)
+        {
+            static assert(false, "Unsupported platform");
+        }
+    }
+
+
+    /***********************
+     * End use of ap.
+     */
+    alias __builtin_va_end va_end;
+
+
+    /***********************
+     * Make a copy of ap.
+     */
+    alias __builtin_va_copy va_copy;
+
+}
+else version( X86 )
+{
+    /*********************
+     * The argument pointer type.
+     */
+    alias char* va_list;
+
+    /**********
+     * Initialize ap.
+     * For 32 bit code, parmn should be the last named parameter.
+     * For 64 bit code, parmn should be __va_argsave.
+     */
+    void va_start(T)(out va_list ap, ref T parmn)
+    {
+        ap = cast(va_list)( cast(void*) &parmn + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) );
+    }
+
+    /************
+     * Retrieve and return the next value that is type T.
+     * Should use the other va_arg instead, as this won't work for 64 bit code.
+     */
+    T va_arg(T)(ref va_list ap)
+    {
+        T arg = *cast(T*) ap;
+        ap = cast(va_list)( cast(void*) ap + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) );
+        return arg;
+    }
+
+    /************
+     * Retrieve and return the next value that is type T.
+     * This is the preferred version.
+     */
+    void va_arg(T)(ref va_list ap, ref T parmn)
+    {
+        parmn = *cast(T*)ap;
+        ap = cast(va_list)(cast(void*)ap + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1)));
+    }
+
+    /*************
+     * Retrieve and store through parmn the next value that is of TypeInfo ti.
+     * Used when the static type is not known.
+     */
+    void va_arg()(ref va_list ap, TypeInfo ti, void* parmn)
+    {
+        // Wait until everyone updates to get TypeInfo.talign
+        //auto talign = ti.talign;
+        //auto p = cast(void*)(cast(size_t)ap + talign - 1) & ~(talign - 1);
+        auto p = ap;
+        auto tsize = ti.tsize;
+        ap = cast(va_list)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
+        parmn[0..tsize] = p[0..tsize];
+    }
+
+    /***********************
+     * End use of ap.
+     */
+    void va_end(va_list ap)
+    {
+    }
+
+    ///
+    void va_copy(out va_list dest, va_list src)
+    {
+        dest = src;
+    }
+}
+else version (Windows) // Win64
+{   /* Win64 is characterized by all arguments fitting into a register size.
+     * Smaller ones are padded out to register size, and larger ones are passed by
+     * reference.
+     */
+
+    /*********************
+     * The argument pointer type.
+     */
+    alias char* va_list;
+
+    /**********
+     * Initialize ap.
+     * parmn should be the last named parameter.
+     */
+    void va_start(T)(out va_list ap, ref T parmn); // Compiler intrinsic
+
+    /************
+     * Retrieve and return the next value that is type T.
+     */
+    T va_arg(T)(ref va_list ap)
+    {
+        static if (T.sizeof > size_t.sizeof)
+            T arg = **cast(T**)ap;
+        else
+            T arg = *cast(T*)ap;
+        ap = cast(va_list)(cast(void*)ap + ((size_t.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
+        return arg;
+    }
+
+    /************
+     * Retrieve and return the next value that is type T.
+     * This is the preferred version.
+     */
+    void va_arg(T)(ref va_list ap, ref T parmn)
+    {
+        static if (T.sizeof > size_t.sizeof)
+            parmn = **cast(T**)ap;
+        else
+            parmn = *cast(T*)ap;
+        ap = cast(va_list)(cast(void*)ap + ((size_t.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
+    }
+
+    /*************
+     * Retrieve and store through parmn the next value that is of TypeInfo ti.
+     * Used when the static type is not known.
+     */
+    void va_arg()(ref va_list ap, TypeInfo ti, void* parmn)
+    {
+        // Wait until everyone updates to get TypeInfo.talign
+        //auto talign = ti.talign;
+        //auto p = cast(void*)(cast(size_t)ap + talign - 1) & ~(talign - 1);
+        auto p = ap;
+        auto tsize = ti.tsize;
+        ap = cast(va_list)(cast(size_t)p + ((size_t.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
+        void* q = (tsize > size_t.sizeof) ? *cast(void**)p : p;
+        parmn[0..tsize] = q[0..tsize];
+    }
+
+    /***********************
+     * End use of ap.
+     */
+    void va_end(va_list ap)
+    {
+    }
+
+    ///
+    void va_copy(out va_list dest, va_list src)
+    {
+        dest = src;
+    }
+}
+else version (X86_64)
+{
+    // Determine if type is a vector type
+    template isVectorType(T)
+    {
+        enum isVectorType = false;
+    }
+
+    template isVectorType(T : __vector(T[N]), size_t N)
+    {
+        enum isVectorType = true;
+    }
+
+    // Layout of this struct must match __gnuc_va_list for C ABI compatibility
+    struct __va_list_tag
+    {
+        uint offset_regs = 6 * 8;            // no regs
+        uint offset_fpregs = 6 * 8 + 8 * 16; // no fp regs
+        void* stack_args;
+        void* reg_args;
+    }
+    alias __va_list = __va_list_tag;
+
+    align(16) struct __va_argsave_t
+    {
+        size_t[6] regs;   // RDI,RSI,RDX,RCX,R8,R9
+        real[8] fpregs;   // XMM0..XMM7
+        __va_list va;
+    }
+
+    /*
+     * Making it an array of 1 causes va_list to be passed as a pointer in
+     * function argument lists
+     */
+    alias va_list = __va_list*;
+
+    ///
+    void va_start(T)(out va_list ap, ref T parmn); // Compiler intrinsic
+
+    ///
+    T va_arg(T)(va_list ap)
+    {   T a;
+        va_arg(ap, a);
+        return a;
+    }
+
+    ///
+    void va_arg(T)(va_list apx, ref T parmn)
+    {
+        __va_list* ap = cast(__va_list*)apx;
+        static if (is(T U == __argTypes))
+        {
+            static if (U.length == 0 || T.sizeof > 16 || (U[0].sizeof > 8 && !isVectorType!(U[0])))
+            {   // Always passed in memory
+                // The arg may have more strict alignment than the stack
+                auto p = (cast(size_t)ap.stack_args + T.alignof - 1) & ~(T.alignof - 1);
+                ap.stack_args = cast(void*)(p + ((T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
+                parmn = *cast(T*)p;
+            }
+            else static if (U.length == 1)
+            {   // Arg is passed in one register
+                alias U[0] T1;
+                static if (is(T1 == double) || is(T1 == float) || isVectorType!(T1))
+                {   // Passed in XMM register
+                    if (ap.offset_fpregs < (6 * 8 + 16 * 8))
+                    {
+                        parmn = *cast(T*)(ap.reg_args + ap.offset_fpregs);
+                        ap.offset_fpregs += 16;
+                    }
+                    else
+                    {
+                        parmn = *cast(T*)ap.stack_args;
+                        ap.stack_args += (T1.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                    }
+                }
+                else
+                {   // Passed in regular register
+                    if (ap.offset_regs < 6 * 8 && T.sizeof <= 8)
+                    {
+                        parmn = *cast(T*)(ap.reg_args + ap.offset_regs);
+                        ap.offset_regs += 8;
+                    }
+                    else
+                    {
+                        auto p = (cast(size_t)ap.stack_args + T.alignof - 1) & ~(T.alignof - 1);
+                        ap.stack_args = cast(void*)(p + ((T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
+                        parmn = *cast(T*)p;
+                    }
+                }
+            }
+            else static if (U.length == 2)
+            {   // Arg is passed in two registers
+                alias U[0] T1;
+                alias U[1] T2;
+                auto p = cast(void*)&parmn + 8;
+
+                // Both must be in registers, or both on stack, hence 4 cases
+
+                static if ((is(T1 == double) || is(T1 == float)) &&
+                           (is(T2 == double) || is(T2 == float)))
+                {
+                    if (ap.offset_fpregs < (6 * 8 + 16 * 8) - 16)
+                    {
+                        *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_fpregs);
+                        *cast(T2*)p = *cast(T2*)(ap.reg_args + ap.offset_fpregs + 16);
+                        ap.offset_fpregs += 32;
+                    }
+                    else
+                    {
+                        *cast(T1*)&parmn = *cast(T1*)ap.stack_args;
+                        ap.stack_args += (T1.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                        *cast(T2*)p = *cast(T2*)ap.stack_args;
+                        ap.stack_args += (T2.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                    }
+                }
+                else static if (is(T1 == double) || is(T1 == float))
+                {
+                    void* a = void;
+                    if (ap.offset_fpregs < (6 * 8 + 16 * 8) &&
+                        ap.offset_regs < 6 * 8 && T2.sizeof <= 8)
+                    {
+                        *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_fpregs);
+                        ap.offset_fpregs += 16;
+                        a = ap.reg_args + ap.offset_regs;
+                        ap.offset_regs += 8;
+                    }
+                    else
+                    {
+                        *cast(T1*)&parmn = *cast(T1*)ap.stack_args;
+                        ap.stack_args += (T1.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                        a = ap.stack_args;
+                        ap.stack_args += 8;
+                    }
+                    // Be careful not to go past the size of the actual argument
+                    const sz2 = T.sizeof - 8;
+                    p[0..sz2] = a[0..sz2];
+                }
+                else static if (is(T2 == double) || is(T2 == float))
+                {
+                    if (ap.offset_regs < 6 * 8 && T1.sizeof <= 8 &&
+                        ap.offset_fpregs < (6 * 8 + 16 * 8))
+                    {
+                        *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_regs);
+                        ap.offset_regs += 8;
+                        *cast(T2*)p = *cast(T2*)(ap.reg_args + ap.offset_fpregs);
+                        ap.offset_fpregs += 16;
+                    }
+                    else
+                    {
+                        *cast(T1*)&parmn = *cast(T1*)ap.stack_args;
+                        ap.stack_args += 8;
+                        *cast(T2*)p = *cast(T2*)ap.stack_args;
+                        ap.stack_args += (T2.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                    }
+                }
+                else // both in regular registers
+                {
+                    void* a = void;
+                    if (ap.offset_regs < 5 * 8 && T1.sizeof <= 8 && T2.sizeof <= 8)
+                    {
+                        *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_regs);
+                        ap.offset_regs += 8;
+                        a = ap.reg_args + ap.offset_regs;
+                        ap.offset_regs += 8;
+                    }
+                    else
+                    {
+                        *cast(T1*)&parmn = *cast(T1*)ap.stack_args;
+                        ap.stack_args += 8;
+                        a = ap.stack_args;
+                        ap.stack_args += 8;
+                    }
+                    // Be careful not to go past the size of the actual argument
+                    const sz2 = T.sizeof - 8;
+                    p[0..sz2] = a[0..sz2];
+                }
+            }
+            else
+            {
+                static assert(false);
+            }
+        }
+        else
+        {
+            static assert(false, "not a valid argument type for va_arg");
+        }
+    }
+
+    ///
+    void va_arg()(va_list apx, TypeInfo ti, void* parmn)
+    {
+        __va_list* ap = cast(__va_list*)apx;
+        TypeInfo arg1, arg2;
+        if (!ti.argTypes(arg1, arg2))
+        {
+            bool inXMMregister(TypeInfo arg) pure nothrow @safe
+            {
+                return (arg.flags & 2) != 0;
+            }
+
+            TypeInfo_Vector v1 = arg1 ? cast(TypeInfo_Vector)arg1 : null;
+            if (arg1 && (arg1.tsize <= 8 || v1))
+            {   // Arg is passed in one register
+                auto tsize = arg1.tsize;
+                void* p;
+                bool stack = false;
+                auto offset_fpregs_save = ap.offset_fpregs;
+                auto offset_regs_save = ap.offset_regs;
+            L1:
+                if (inXMMregister(arg1) || v1)
+                {   // Passed in XMM register
+                    if (ap.offset_fpregs < (6 * 8 + 16 * 8) && !stack)
+                    {
+                        p = ap.reg_args + ap.offset_fpregs;
+                        ap.offset_fpregs += 16;
+                    }
+                    else
+                    {
+                        p = ap.stack_args;
+                        ap.stack_args += (tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                        stack = true;
+                    }
+                }
+                else
+                {   // Passed in regular register
+                    if (ap.offset_regs < 6 * 8 && !stack)
+                    {
+                        p = ap.reg_args + ap.offset_regs;
+                        ap.offset_regs += 8;
+                    }
+                    else
+                    {
+                        p = ap.stack_args;
+                        ap.stack_args += 8;
+                        stack = true;
+                    }
+                }
+                parmn[0..tsize] = p[0..tsize];
+
+                if (arg2)
+                {
+                    if (inXMMregister(arg2))
+                    {   // Passed in XMM register
+                        if (ap.offset_fpregs < (6 * 8 + 16 * 8) && !stack)
+                        {
+                            p = ap.reg_args + ap.offset_fpregs;
+                            ap.offset_fpregs += 16;
+                        }
+                        else
+                        {
+                            if (!stack)
+                            {   // arg1 is really on the stack, so rewind and redo
+                                ap.offset_fpregs = offset_fpregs_save;
+                                ap.offset_regs = offset_regs_save;
+                                stack = true;
+                                goto L1;
+                            }
+                            p = ap.stack_args;
+                            ap.stack_args += (arg2.tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+                        }
+                    }
+                    else
+                    {   // Passed in regular register
+                        if (ap.offset_regs < 6 * 8 && !stack)
+                        {
+                            p = ap.reg_args + ap.offset_regs;
+                            ap.offset_regs += 8;
+                        }
+                        else
+                        {
+                            if (!stack)
+                            {   // arg1 is really on the stack, so rewind and redo
+                                ap.offset_fpregs = offset_fpregs_save;
+                                ap.offset_regs = offset_regs_save;
+                                stack = true;
+                                goto L1;
+                            }
+                            p = ap.stack_args;
+                            ap.stack_args += 8;
+                        }
+                    }
+                    auto sz = ti.tsize - 8;
+                    (parmn + 8)[0..sz] = p[0..sz];
+                }
+            }
+            else
+            {   // Always passed in memory
+                // The arg may have more strict alignment than the stack
+                auto talign = ti.talign;
+                auto tsize = ti.tsize;
+                auto p = cast(void*)((cast(size_t)ap.stack_args + talign - 1) & ~(talign - 1));
+                ap.stack_args = cast(void*)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
+                parmn[0..tsize] = p[0..tsize];
+            }
+        }
+        else
+        {
+            assert(false, "not a valid argument type for va_arg");
+        }
+    }
+
+    ///
+    void va_end(va_list ap)
+    {
+    }
+
+    import core.stdc.stdlib : alloca;
+
+    ///
+    void va_copy(out va_list dest, va_list src, void* storage = alloca(__va_list_tag.sizeof))
+    {
+        // Instead of copying the pointers, and aliasing the source va_list,
+        // the default argument alloca will allocate storage in the caller's
+        // stack frame.  This is still not correct (it should be allocated in
+        // the place where the va_list variable is declared) but most of the
+        // time the caller's stack frame _is_ the place where the va_list is
+        // allocated, so in most cases this will now work.
+        dest = cast(va_list)storage;
+        *dest = *src;
+    }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/stdc/stddef.d b/libphobos/libdruntime/core/stdc/stddef.d
new file mode 100644
index 00000000000..5dcaa8985b1
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/stddef.d
@@ -0,0 +1,33 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_stddef.h.html, _stddef.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_stddef.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.stddef;
+
+extern (C):
+@trusted: // Types only.
+nothrow:
+@nogc:
+
+// size_t and ptrdiff_t are defined in the object module.
+
+version( Windows )
+{
+    ///
+    alias wchar wchar_t;
+}
+else version( Posix )
+{
+    ///
+    alias dchar wchar_t;
+}
diff --git a/libphobos/libdruntime/core/stdc/stdint.d b/libphobos/libdruntime/core/stdc/stdint.d
new file mode 100644
index 00000000000..eebc5f9edfd
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/stdint.d
@@ -0,0 +1,258 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_stdint.h.html, _stdint.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_stdint.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module core.stdc.stdint;
+
+version(GNU) import gcc.builtins;
+
+private import core.stdc.stddef; // for wchar_t
+private import core.stdc.signal; // for sig_atomic_t
+private import core.stdc.wchar_; // for wint_t
+
+
+// Can't be `private` because of @@@BUG11173@@@.
+T _typify(T)(T val) @safe pure nothrow { return val; }
+
+extern (C):
+@trusted: // Types and constants only.
+nothrow:
+@nogc:
+
+///
+alias int8_t  = byte ;
+///
+alias int16_t = short;
+///
+alias int32_t = int  ;
+///
+alias int64_t = long ;
+//alias int128_t = cent;
+
+///
+alias uint8_t  = ubyte ;
+///
+alias uint16_t = ushort;
+///
+alias uint32_t = uint  ;
+///
+alias uint64_t = ulong ;
+//alias uint128_t = ucent;
+
+///
+alias int_least8_t  = byte ;
+///
+alias int_least16_t = short;
+///
+alias int_least32_t = int  ;
+///
+alias int_least64_t = long ;
+
+///
+alias uint_least8_t  = ubyte ;
+///
+alias uint_least16_t = ushort;
+///
+alias uint_least32_t = uint  ;
+///
+alias uint_least64_t = ulong ;
+
+///
+alias int_fast8_t  = byte;
+///
+alias int_fast16_t = int ;
+///
+alias int_fast32_t = int ;
+///
+alias int_fast64_t = long;
+
+///
+alias uint_fast8_t  = ubyte;
+///
+alias uint_fast16_t = uint ;
+///
+alias uint_fast32_t = uint ;
+///
+alias uint_fast64_t = ulong;
+
+version( GNU )
+{
+    ///
+    alias intptr_t = __builtin_pointer_int;
+    ///
+    alias uintptr_t = __builtin_pointer_uint;
+}
+else version( D_LP64 )
+{
+    ///
+    alias intptr_t  = long ;
+    ///
+    alias uintptr_t = ulong;
+}
+else
+{
+    ///
+    alias intptr_t  = int ;
+    ///
+    alias uintptr_t = uint;
+}
+
+///
+alias intmax_t  = long ;
+///
+alias uintmax_t = ulong;
+
+///
+enum int8_t   INT8_MIN  = int8_t.min;
+///
+enum int8_t   INT8_MAX  = int8_t.max;
+///
+enum int16_t  INT16_MIN = int16_t.min;
+///
+enum int16_t  INT16_MAX = int16_t.max;
+///
+enum int32_t  INT32_MIN = int32_t.min;
+///
+enum int32_t  INT32_MAX = int32_t.max;
+///
+enum int64_t  INT64_MIN = int64_t.min;
+///
+enum int64_t  INT64_MAX = int64_t.max;
+
+///
+enum uint8_t  UINT8_MAX  = uint8_t.max;
+///
+enum uint16_t UINT16_MAX = uint16_t.max;
+///
+enum uint32_t UINT32_MAX = uint32_t.max;
+///
+enum uint64_t UINT64_MAX = uint64_t.max;
+
+///
+enum int_least8_t    INT_LEAST8_MIN   = int_least8_t.min;
+///
+enum int_least8_t    INT_LEAST8_MAX   = int_least8_t.max;
+///
+enum int_least16_t   INT_LEAST16_MIN  = int_least16_t.min;
+///
+enum int_least16_t   INT_LEAST16_MAX  = int_least16_t.max;
+///
+enum int_least32_t   INT_LEAST32_MIN  = int_least32_t.min;
+///
+enum int_least32_t   INT_LEAST32_MAX  = int_least32_t.max;
+///
+enum int_least64_t   INT_LEAST64_MIN  = int_least64_t.min;
+///
+enum int_least64_t   INT_LEAST64_MAX  = int_least64_t.max;
+
+///
+enum uint_least8_t   UINT_LEAST8_MAX  = uint_least8_t.max;
+///
+enum uint_least16_t  UINT_LEAST16_MAX = uint_least16_t.max;
+///
+enum uint_least32_t  UINT_LEAST32_MAX = uint_least32_t.max;
+///
+enum uint_least64_t  UINT_LEAST64_MAX = uint_least64_t.max;
+
+///
+enum int_fast8_t   INT_FAST8_MIN   = int_fast8_t.min;
+///
+enum int_fast8_t   INT_FAST8_MAX   = int_fast8_t.max;
+///
+enum int_fast16_t  INT_FAST16_MIN  = int_fast16_t.min;
+///
+enum int_fast16_t  INT_FAST16_MAX  = int_fast16_t.max;
+///
+enum int_fast32_t  INT_FAST32_MIN  = int_fast32_t.min;
+///
+enum int_fast32_t  INT_FAST32_MAX  = int_fast32_t.max;
+///
+enum int_fast64_t  INT_FAST64_MIN  = int_fast64_t.min;
+///
+enum int_fast64_t  INT_FAST64_MAX  = int_fast64_t.max;
+
+///
+enum uint_fast8_t  UINT_FAST8_MAX  = uint_fast8_t.max;
+///
+enum uint_fast16_t UINT_FAST16_MAX = uint_fast16_t.max;
+///
+enum uint_fast32_t UINT_FAST32_MAX = uint_fast32_t.max;
+///
+enum uint_fast64_t UINT_FAST64_MAX = uint_fast64_t.max;
+
+///
+enum intptr_t  INTPTR_MIN  = intptr_t.min;
+///
+enum intptr_t  INTPTR_MAX  = intptr_t.max;
+
+///
+enum uintptr_t UINTPTR_MIN = uintptr_t.min;
+///
+enum uintptr_t UINTPTR_MAX = uintptr_t.max;
+
+///
+enum intmax_t  INTMAX_MIN  = intmax_t.min;
+///
+enum intmax_t  INTMAX_MAX  = intmax_t.max;
+
+///
+enum uintmax_t UINTMAX_MAX = uintmax_t.max;
+
+///
+enum ptrdiff_t PTRDIFF_MIN = ptrdiff_t.min;
+///
+enum ptrdiff_t PTRDIFF_MAX = ptrdiff_t.max;
+
+///
+enum sig_atomic_t SIG_ATOMIC_MIN = sig_atomic_t.min;
+///
+enum sig_atomic_t SIG_ATOMIC_MAX = sig_atomic_t.max;
+
+///
+enum size_t  SIZE_MAX  = size_t.max;
+
+///
+enum wchar_t WCHAR_MIN = wchar_t.min;
+///
+enum wchar_t WCHAR_MAX = wchar_t.max;
+
+///
+enum wint_t  WINT_MIN  = wint_t.min;
+///
+enum wint_t  WINT_MAX  = wint_t.max;
+
+///
+alias INT8_C  = _typify!int8_t ;
+///
+alias INT16_C = _typify!int16_t;
+///
+alias INT32_C = _typify!int32_t;
+///
+alias INT64_C = _typify!int64_t;
+
+///
+alias UINT8_C  = _typify!uint8_t ;
+///
+alias UINT16_C = _typify!uint16_t;
+///
+alias UINT32_C = _typify!uint32_t;
+///
+alias UINT64_C = _typify!uint64_t;
+
+///
+alias INTMAX_C  = _typify!intmax_t ;
+///
+alias UINTMAX_C = _typify!uintmax_t;
diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d
new file mode 100644
index 00000000000..a7301ae594b
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/stdio.d
@@ -0,0 +1,1261 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_stdio.h.html, _stdio.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly,
+ *            Alex Rønne Petersen
+ * Source:    $(DRUNTIMESRC core/stdc/_stdio.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.stdio;
+
+private
+{
+    import core.stdc.config;
+    import core.stdc.stdarg; // for va_list
+    import core.stdc.stdint : intptr_t;
+
+  version (FreeBSD)
+  {
+    import core.sys.posix.sys.types;
+  }
+}
+
+extern (C):
+@system:
+nothrow:
+@nogc:
+
+version( CRuntime_DigitalMars )
+{
+    enum
+    {
+        ///
+        BUFSIZ       = 0x4000,
+        ///
+        EOF          = -1,
+        ///
+        FOPEN_MAX    = 20,
+        ///
+        FILENAME_MAX = 256, // 255 plus NULL
+        ///
+        TMP_MAX      = 32767,
+        ///
+        SYS_OPEN     = 20,      // non-standard
+    }
+
+    ///
+    enum int     _NFILE     = 60;       // non-standard
+    ///
+    enum string  _P_tmpdir  = "\\"; // non-standard
+    ///
+    enum wstring _wP_tmpdir = "\\"; // non-standard
+    ///
+    enum int     L_tmpnam   = _P_tmpdir.length + 12;
+}
+else version( CRuntime_Microsoft )
+{
+    enum
+    {
+        ///
+        BUFSIZ       = 512,
+        ///
+        EOF          = -1,
+        ///
+        FOPEN_MAX    = 20,
+        ///
+        FILENAME_MAX = 260,
+        /// Actually int.max since Visual Studio 2015.
+        TMP_MAX      = 32767,
+        ///
+        _SYS_OPEN    = 20,      // non-standard
+    }
+
+    ///
+    enum int     _NFILE     = 512;       // non-standard
+    /// Removed since Visual Studio 2015.
+    enum string  _P_tmpdir  = "\\"; // non-standard
+    /// Removed since Visual Studio 2015.
+    enum wstring _wP_tmpdir = "\\"; // non-standard
+    /// Actually 260 since Visual Studio 2015.
+    enum int     L_tmpnam   = _P_tmpdir.length + 12;
+}
+else version( CRuntime_Glibc )
+{
+    enum
+    {
+        ///
+        BUFSIZ       = 8192,
+        ///
+        EOF          = -1,
+        ///
+        FOPEN_MAX    = 16,
+        ///
+        FILENAME_MAX = 4095,
+        ///
+        TMP_MAX      = 238328,
+        ///
+        L_tmpnam     = 20
+    }
+}
+else version( OSX )
+{
+    enum
+    {
+        ///
+        BUFSIZ       = 1024,
+        ///
+        EOF          = -1,
+        ///
+        FOPEN_MAX    = 20,
+        ///
+        FILENAME_MAX = 1024,
+        ///
+        TMP_MAX      = 308915776,
+        ///
+        L_tmpnam     = 1024,
+    }
+
+    private
+    {
+        struct __sbuf
+        {
+            ubyte*  _base;
+            int     _size;
+        }
+
+        struct __sFILEX
+        {
+
+        }
+    }
+}
+else version ( FreeBSD )
+{
+    enum
+    {
+        ///
+        BUFSIZ       = 1024,
+        ///
+        EOF          = -1,
+        ///
+        FOPEN_MAX    = 20,
+        ///
+        FILENAME_MAX = 1024,
+        ///
+        TMP_MAX      = 308915776,
+        ///
+        L_tmpnam     = 1024
+    }
+
+    struct __sbuf
+    {
+        ubyte *_base;
+        int _size;
+    }
+
+    union __mbstate_t // <sys/_types.h>
+    {
+        char[128]   _mbstate8;
+        long        _mbstateL;
+    }
+}
+else version (Solaris)
+{
+    enum
+    {
+        ///
+        BUFSIZ = 1024,
+        ///
+        EOF = -1,
+        ///
+        FOPEN_MAX = _NFILE,
+        ///
+        FILENAME_MAX = 1024,
+        ///
+        TMP_MAX = 17576,
+        ///
+        L_tmpnam = 25,
+    }
+
+    version (X86)
+        ///
+        enum int _NFILE = 60;
+    else
+        ///
+        enum int _NFILE = 20;
+}
+else version( CRuntime_Bionic )
+{
+    enum
+    {
+        ///
+        BUFSIZ       = 1024,
+        ///
+        EOF          = -1,
+        ///
+        FOPEN_MAX    = 20,
+        ///
+        FILENAME_MAX = 1024,
+        ///
+        TMP_MAX      = 308915776,
+        ///
+        L_tmpnam     = 1024
+    }
+
+    struct __sbuf
+    {
+        ubyte* _base;
+        int _size;
+    }
+}
+else
+{
+    static assert( false, "Unsupported platform" );
+}
+
+enum
+{
+    /// Offset is relative to the beginning
+    SEEK_SET,
+    /// Offset is relative to the current position
+    SEEK_CUR,
+    /// Offset is relative to the end
+    SEEK_END
+}
+
+version( CRuntime_DigitalMars )
+{
+    ///
+    alias c_long fpos_t;
+
+    ///
+    struct _iobuf
+    {
+        char* _ptr;
+        int   _cnt;
+        char* _base;
+        int   _flag;
+        int   _file;
+        int   _charbuf;
+        int   _bufsiz;
+        char* __tmpnum;
+    }
+
+    ///
+    alias shared(_iobuf) FILE;
+}
+else version( CRuntime_Microsoft )
+{
+    ///
+    alias long fpos_t;
+
+    ///
+    struct _iobuf
+    {
+        void* undefined;
+    }
+
+    ///
+    alias shared(_iobuf) FILE;
+}
+else version( CRuntime_Glibc )
+{
+    import core.stdc.wchar_ : mbstate_t;
+    ///
+    struct fpos_t
+    {
+        long __pos; // couldn't use off_t because of static if issue
+        mbstate_t __state;
+    }
+
+    ///
+    struct _IO_FILE
+    {
+        int     _flags;
+        char*   _read_ptr;
+        char*   _read_end;
+        char*   _read_base;
+        char*   _write_base;
+        char*   _write_ptr;
+        char*   _write_end;
+        char*   _buf_base;
+        char*   _buf_end;
+        char*   _save_base;
+        char*   _backup_base;
+        char*   _save_end;
+        void*   _markers;
+        _IO_FILE* _chain;
+        int     _fileno;
+        int     _blksize;
+        int     _old_offset;
+        ushort  _cur_column;
+        byte    _vtable_offset;
+        char[1] _shortbuf;
+        void*   _lock;
+    }
+
+    ///
+    alias _IO_FILE _iobuf;
+    ///
+    alias shared(_IO_FILE) FILE;
+}
+else version( OSX )
+{
+    ///
+    alias long fpos_t;
+
+    ///
+    struct __sFILE
+    {
+        ubyte*    _p;
+        int       _r;
+        int       _w;
+        short     _flags;
+        short     _file;
+        __sbuf    _bf;
+        int       _lbfsize;
+
+        void*     _cookie;
+        int     function(void*)                    _close;
+        int     function(void*, char*, int)        _read;
+        fpos_t  function(void*, fpos_t, int)       _seek;
+        int     function(void*, char *, int)       _write;
+
+        __sbuf    _ub;
+        __sFILEX* _extra;
+        int       _ur;
+
+        ubyte[3]  _ubuf;
+        ubyte[1]  _nbuf;
+
+        __sbuf    _lb;
+
+        int       _blksize;
+        fpos_t    _offset;
+    }
+
+    ///
+    alias __sFILE _iobuf;
+    ///
+    alias shared(__sFILE) FILE;
+}
+else version( FreeBSD )
+{
+    ///
+    alias off_t fpos_t;
+
+    ///
+    struct __sFILE
+    {
+        ubyte*          _p;
+        int             _r;
+        int             _w;
+        short           _flags;
+        short           _file;
+        __sbuf          _bf;
+        int             _lbfsize;
+
+        void*           _cookie;
+        int     function(void*)                 _close;
+        int     function(void*, char*, int)     _read;
+        fpos_t  function(void*, fpos_t, int)    _seek;
+        int     function(void*, in char*, int)  _write;
+
+        __sbuf          _ub;
+        ubyte*          _up;
+        int             _ur;
+
+        ubyte[3]        _ubuf;
+        ubyte[1]        _nbuf;
+
+        __sbuf          _lb;
+
+        int             _blksize;
+        fpos_t          _offset;
+
+        pthread_mutex_t _fl_mutex;
+        pthread_t       _fl_owner;
+        int             _fl_count;
+        int             _orientation;
+        __mbstate_t     _mbstate;
+    }
+
+    ///
+    alias __sFILE _iobuf;
+    ///
+    alias shared(__sFILE) FILE;
+}
+else version (Solaris)
+{
+    ///
+    alias c_long fpos_t;
+
+    ///
+    struct _iobuf
+    {
+        char* _ptr;
+        int _cnt;
+        char* _base;
+        char _flag;
+        char _magic;
+        ushort __flags; // __orientation:2
+                        // __ionolock:1
+                        // __seekable:1
+                        // __extendedfd:1
+                        // __xf_nocheck:1
+                        // __filler:10
+    }
+
+    ///
+    alias shared(_iobuf) FILE;
+}
+else version( CRuntime_Bionic )
+{
+    import core.sys.posix.sys.types : off_t;
+    ///
+    alias off_t fpos_t;
+
+    ///
+    struct __sFILE
+    {
+        ubyte*    _p;
+        int       _r;
+        int       _w;
+        short     _flags;
+        short     _file;
+        __sbuf    _bf;
+        int       _lbfsize;
+
+        void*     _cookie;
+        int      function(void*)                    _close;
+        int      function(void*, char*, int)        _read;
+        fpos_t   function(void*, fpos_t, int)       _seek;
+        int      function(void*, in char*, int)     _write;
+
+        __sbuf    _ext;
+        ubyte*    _up;
+        int       _ur;
+
+        ubyte[3]  _ubuf;
+        ubyte[1]  _nbuf;
+
+        __sbuf    _lb;
+
+        int       _blksize;
+        fpos_t    _offset;
+    }
+
+    ///
+    alias __sFILE _iobuf;
+    ///
+    alias shared(__sFILE) FILE;
+}
+else
+{
+    static assert( false, "Unsupported platform" );
+}
+
+enum
+{
+    ///
+    _F_RDWR = 0x0003, // non-standard
+    ///
+    _F_READ = 0x0001, // non-standard
+    ///
+    _F_WRIT = 0x0002, // non-standard
+    ///
+    _F_BUF  = 0x0004, // non-standard
+    ///
+    _F_LBUF = 0x0008, // non-standard
+    ///
+    _F_ERR  = 0x0010, // non-standard
+    ///
+    _F_EOF  = 0x0020, // non-standard
+    ///
+    _F_BIN  = 0x0040, // non-standard
+    ///
+    _F_IN   = 0x0080, // non-standard
+    ///
+    _F_OUT  = 0x0100, // non-standard
+    ///
+    _F_TERM = 0x0200, // non-standard
+}
+
+version( CRuntime_DigitalMars )
+{
+    enum
+    {
+        ///
+        _IOFBF   = 0,
+        ///
+        _IOLBF   = 0x40,
+        ///
+        _IONBF   = 4,
+        ///
+        _IOREAD  = 1,     // non-standard
+        ///
+        _IOWRT   = 2,     // non-standard
+        ///
+        _IOMYBUF = 8,     // non-standard
+        ///
+        _IOEOF   = 0x10,  // non-standard
+        ///
+        _IOERR   = 0x20,  // non-standard
+        ///
+        _IOSTRG  = 0x40,  // non-standard
+        ///
+        _IORW    = 0x80,  // non-standard
+        ///
+        _IOTRAN  = 0x100, // non-standard
+        ///
+        _IOAPP   = 0x200, // non-standard
+    }
+
+    extern shared void function() _fcloseallp;
+
+    private extern shared FILE[_NFILE] _iob;
+
+    ///
+    shared stdin  = &_iob[0];
+    ///
+    shared stdout = &_iob[1];
+    ///
+    shared stderr = &_iob[2];
+    ///
+    shared stdaux = &_iob[3];
+    ///
+    shared stdprn = &_iob[4];
+}
+else version( CRuntime_Microsoft )
+{
+    enum
+    {
+        ///
+        _IOFBF   = 0,
+        ///
+        _IOLBF   = 0x40,
+        ///
+        _IONBF   = 4,
+        /// Removed since Visual Studio 2015.
+        _IOREAD  = 1,     // non-standard
+        /// Removed since Visual Studio 2015.
+        _IOWRT   = 2,     // non-standard
+        /// Removed since Visual Studio 2015.
+        _IOMYBUF = 8,     // non-standard
+        /// Removed since Visual Studio 2015.
+        _IOEOF   = 0x10,  // non-standard
+        /// Removed since Visual Studio 2015.
+        _IOERR   = 0x20,  // non-standard
+        /// Removed since Visual Studio 2015.
+        _IOSTRG  = 0x40,  // non-standard
+        /// Removed since Visual Studio 2015.
+        _IORW    = 0x80,  // non-standard
+        /// Removed since Visual Studio 2015.
+        _IOAPP   = 0x200, // non-standard
+        /// Removed since Visual Studio 2015.
+        _IOAPPEND = 0x200, // non-standard
+    }
+
+    extern shared void function() _fcloseallp;
+
+    ///
+    shared FILE* stdin;  // = &__iob_func()[0];
+    ///
+    shared FILE* stdout; // = &__iob_func()[1];
+    ///
+    shared FILE* stderr; // = &__iob_func()[2];
+}
+else version( CRuntime_Glibc )
+{
+    enum
+    {
+        ///
+        _IOFBF = 0,
+        ///
+        _IOLBF = 1,
+        ///
+        _IONBF = 2,
+    }
+
+    ///
+    extern shared FILE* stdin;
+    ///
+    extern shared FILE* stdout;
+    ///
+    extern shared FILE* stderr;
+}
+else version( OSX )
+{
+    enum
+    {
+        ///
+        _IOFBF = 0,
+        ///
+        _IOLBF = 1,
+        ///
+        _IONBF = 2,
+    }
+
+    private extern shared FILE* __stdinp;
+    private extern shared FILE* __stdoutp;
+    private extern shared FILE* __stderrp;
+
+    ///
+    alias __stdinp  stdin;
+    ///
+    alias __stdoutp stdout;
+    ///
+    alias __stderrp stderr;
+}
+else version( FreeBSD )
+{
+    enum
+    {
+        ///
+        _IOFBF = 0,
+        ///
+        _IOLBF = 1,
+        ///
+        _IONBF = 2,
+    }
+
+    private extern shared FILE* __stdinp;
+    private extern shared FILE* __stdoutp;
+    private extern shared FILE* __stderrp;
+
+    ///
+    alias __stdinp  stdin;
+    ///
+    alias __stdoutp stdout;
+    ///
+    alias __stderrp stderr;
+}
+else version (Solaris)
+{
+    enum
+    {
+        ///
+        _IOFBF = 0x00,
+        ///
+        _IOLBF = 0x40,
+        ///
+        _IONBF = 0x04,
+        ///
+        _IOEOF = 0x20,
+        ///
+        _IOERR = 0x40,
+        ///
+        _IOREAD = 0x01,
+        ///
+        _IOWRT = 0x02,
+        ///
+        _IORW = 0x80,
+        ///
+        _IOMYBUF = 0x08,
+    }
+
+    private extern shared FILE[_NFILE] __iob;
+
+    ///
+    shared stdin = &__iob[0];
+    ///
+    shared stdout = &__iob[1];
+    ///
+    shared stderr = &__iob[2];
+}
+else version( CRuntime_Bionic )
+{
+    enum
+    {
+        ///
+        _IOFBF = 0,
+        ///
+        _IOLBF = 1,
+        ///
+        _IONBF = 2,
+    }
+
+    private extern shared FILE[3] __sF;
+
+    ///
+    shared stdin  = &__sF[0];
+    ///
+    shared stdout = &__sF[1];
+    ///
+    shared stderr = &__sF[2];
+}
+else
+{
+    static assert( false, "Unsupported platform" );
+}
+
+///
+int remove(in char* filename);
+///
+int rename(in char* from, in char* to);
+
+///
+@trusted FILE* tmpfile(); // No unsafe pointer manipulation.
+///
+char* tmpnam(char* s);
+
+///
+int   fclose(FILE* stream);
+
+// No unsafe pointer manipulation.
+@trusted
+{
+    ///
+    int   fflush(FILE* stream);
+}
+
+///
+FILE* fopen(in char* filename, in char* mode);
+///
+FILE* freopen(in char* filename, in char* mode, FILE* stream);
+
+///
+void setbuf(FILE* stream, char* buf);
+///
+int  setvbuf(FILE* stream, char* buf, int mode, size_t size);
+
+version (MinGW)
+{
+    // Prefer the MinGW versions over the MSVC ones, as the latter don't handle
+    // reals at all.
+    ///
+    int __mingw_fprintf(FILE* stream, in char* format, ...);
+    ///
+    alias __mingw_fprintf fprintf;
+
+    ///
+    int __mingw_fscanf(FILE* stream, in char* format, ...);
+    ///
+    alias __mingw_fscanf fscanf;
+
+    ///
+    int __mingw_sprintf(char* s, in char* format, ...);
+    ///
+    alias __mingw_sprintf sprintf;
+
+    ///
+    int __mingw_sscanf(in char* s, in char* format, ...);
+    ///
+    alias __mingw_sscanf sscanf;
+
+    ///
+    int __mingw_vfprintf(FILE* stream, in char* format, va_list arg);
+    ///
+    alias __mingw_vfprintf vfprintf;
+
+    ///
+    int __mingw_vfscanf(FILE* stream, in char* format, va_list arg);
+    ///
+    alias __mingw_vfscanf vfscanf;
+
+    ///
+    int __mingw_vsprintf(char* s, in char* format, va_list arg);
+    ///
+    alias __mingw_vsprintf vsprintf;
+
+    ///
+    int __mingw_vsscanf(in char* s, in char* format, va_list arg);
+    ///
+    alias __mingw_vsscanf vsscanf;
+
+    ///
+    int __mingw_vprintf(in char* format, va_list arg);
+    ///
+    alias __mingw_vprintf vprintf;
+
+    ///
+    int __mingw_vscanf(in char* format, va_list arg);
+    ///
+    alias __mingw_vscanf vscanf;
+
+    ///
+    int __mingw_printf(in char* format, ...);
+    ///
+    alias __mingw_printf printf;
+
+    ///
+    int __mingw_scanf(in char* format, ...);
+    ///
+    alias __mingw_scanf scanf;
+}
+else
+{
+    ///
+    int fprintf(FILE* stream, in char* format, ...);
+    ///
+    int fscanf(FILE* stream, in char* format, ...);
+    ///
+    int sprintf(char* s, in char* format, ...);
+    ///
+    int sscanf(in char* s, in char* format, ...);
+    ///
+    int vfprintf(FILE* stream, in char* format, va_list arg);
+    ///
+    int vfscanf(FILE* stream, in char* format, va_list arg);
+    ///
+    int vsprintf(char* s, in char* format, va_list arg);
+    ///
+    int vsscanf(in char* s, in char* format, va_list arg);
+    ///
+    int vprintf(in char* format, va_list arg);
+    ///
+    int vscanf(in char* format, va_list arg);
+    ///
+    int printf(in char* format, ...);
+    ///
+    int scanf(in char* format, ...);
+}
+
+// No unsafe pointer manipulation.
+@trusted
+{
+    ///
+    int fgetc(FILE* stream);
+    ///
+    int fputc(int c, FILE* stream);
+}
+
+///
+char* fgets(char* s, int n, FILE* stream);
+///
+int   fputs(in char* s, FILE* stream);
+///
+char* gets(char* s);
+///
+int   puts(in char* s);
+
+// No unsafe pointer manipulation.
+extern (D) @trusted
+{
+    ///
+    int getchar()                 { return getc(stdin);     }
+    ///
+    int putchar(int c)            { return putc(c,stdout);  }
+    ///
+    int getc(FILE* stream)        { return fgetc(stream);   }
+    ///
+    int putc(int c, FILE* stream) { return fputc(c,stream); }
+}
+
+///
+@trusted int ungetc(int c, FILE* stream); // No unsafe pointer manipulation.
+
+///
+size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream);
+///
+size_t fwrite(in void* ptr, size_t size, size_t nmemb, FILE* stream);
+
+// No unsafe pointer manipulation.
+@trusted
+{
+    ///
+    int fgetpos(FILE* stream, fpos_t * pos);
+    ///
+    int fsetpos(FILE* stream, in fpos_t* pos);
+
+    ///
+    int    fseek(FILE* stream, c_long offset, int whence);
+    ///
+    c_long ftell(FILE* stream);
+}
+
+version( MinGW )
+{
+  // No unsafe pointer manipulation.
+  extern (D) @trusted
+  {
+      ///
+    void rewind(FILE* stream)   { fseek(stream,0L,SEEK_SET); stream._flag = stream._flag & ~_IOERR; }
+    ///
+    pure void clearerr(FILE* stream) { stream._flag = stream._flag & ~(_IOERR|_IOEOF);                 }
+    ///
+    pure int  feof(FILE* stream)     { return stream._flag&_IOEOF;                       }
+    ///
+    pure int  ferror(FILE* stream)   { return stream._flag&_IOERR;                       }
+  }
+  ///
+    int   __mingw_snprintf(char* s, size_t n, in char* fmt, ...);
+    ///
+    alias __mingw_snprintf _snprintf;
+    ///
+    alias __mingw_snprintf snprintf;
+
+    ///
+    int   __mingw_vsnprintf(char* s, size_t n, in char* format, va_list arg);
+    ///
+    alias __mingw_vsnprintf _vsnprintf;
+    ///
+    alias __mingw_vsnprintf vsnprintf;
+}
+else version( CRuntime_DigitalMars )
+{
+  // No unsafe pointer manipulation.
+  extern (D) @trusted
+  {
+      ///
+    void rewind(FILE* stream)   { fseek(stream,0L,SEEK_SET); stream._flag= stream._flag & ~_IOERR; }
+    ///
+    pure void clearerr(FILE* stream) { stream._flag = stream._flag & ~(_IOERR|_IOEOF);                 }
+    ///
+    pure int  feof(FILE* stream)     { return stream._flag&_IOEOF;                       }
+    ///
+    pure int  ferror(FILE* stream)   { return stream._flag&_IOERR;                       }
+    ///
+    pure int  fileno(FILE* stream)   { return stream._file;                              }
+  }
+  ///
+    int   _snprintf(char* s, size_t n, in char* fmt, ...);
+    ///
+    alias _snprintf snprintf;
+
+    ///
+    int   _vsnprintf(char* s, size_t n, in char* format, va_list arg);
+    ///
+    alias _vsnprintf vsnprintf;
+}
+else version( CRuntime_Microsoft )
+{
+  // No unsafe pointer manipulation.
+  @trusted
+  {
+      ///
+    void rewind(FILE* stream);
+    ///
+    pure void clearerr(FILE* stream);
+    ///
+    pure int  feof(FILE* stream);
+    ///
+    pure int  ferror(FILE* stream);
+    ///
+    pure int  fileno(FILE* stream);
+  }
+
+  ///
+    int _snprintf(char* s, size_t n, in char* format, ...);
+    ///
+    int  snprintf(char* s, size_t n, in char* format, ...);
+
+    ///
+    int _vsnprintf(char* s, size_t n, in char* format, va_list arg);
+    ///
+    int  vsnprintf(char* s, size_t n, in char* format, va_list arg);
+
+    ///
+    int _fputc_nolock(int c, FILE *fp);
+    ///
+    int _fgetc_nolock(FILE *fp);
+
+    ///
+    int _lock_file(FILE *fp);
+    ///
+    int _unlock_file(FILE *fp);
+
+    ///
+    intptr_t _get_osfhandle(int fd);
+    ///
+    int _open_osfhandle(intptr_t osfhandle, int flags);
+}
+else version( CRuntime_Glibc )
+{
+  // No unsafe pointer manipulation.
+  @trusted
+  {
+      ///
+    void rewind(FILE* stream);
+    ///
+    pure void clearerr(FILE* stream);
+    ///
+    pure int  feof(FILE* stream);
+    ///
+    pure int  ferror(FILE* stream);
+    ///
+    int  fileno(FILE *);
+  }
+
+  ///
+    int  snprintf(char* s, size_t n, in char* format, ...);
+    ///
+    int  vsnprintf(char* s, size_t n, in char* format, va_list arg);
+}
+else version( OSX )
+{
+  // No unsafe pointer manipulation.
+  @trusted
+  {
+      ///
+    void rewind(FILE*);
+    ///
+    pure void clearerr(FILE*);
+    ///
+    pure int  feof(FILE*);
+    ///
+    pure int  ferror(FILE*);
+    ///
+    int  fileno(FILE*);
+  }
+
+  ///
+    int  snprintf(char* s, size_t n, in char* format, ...);
+    ///
+    int  vsnprintf(char* s, size_t n, in char* format, va_list arg);
+}
+else version( FreeBSD )
+{
+  // No unsafe pointer manipulation.
+  @trusted
+  {
+      ///
+    void rewind(FILE*);
+    ///
+    pure void clearerr(FILE*);
+    ///
+    pure int  feof(FILE*);
+    ///
+    pure int  ferror(FILE*);
+    ///
+    int  fileno(FILE*);
+  }
+
+  ///
+    int  snprintf(char* s, size_t n, in char* format, ...);
+    ///
+    int  vsnprintf(char* s, size_t n, in char* format, va_list arg);
+}
+else version (Solaris)
+{
+  // No unsafe pointer manipulation.
+  @trusted
+  {
+      ///
+    void rewind(FILE*);
+    ///
+    pure void clearerr(FILE*);
+    ///
+    pure int  feof(FILE*);
+    ///
+    pure int  ferror(FILE*);
+    ///
+    int  fileno(FILE*);
+  }
+
+  ///
+    int  snprintf(char* s, size_t n, in char* format, ...);
+    ///
+    int  vsnprintf(char* s, size_t n, in char* format, va_list arg);
+}
+else version( CRuntime_Bionic )
+{
+  // No unsafe pointer manipulation.
+  @trusted
+  {
+      ///
+    void rewind(FILE*);
+    ///
+    pure void clearerr(FILE*);
+    ///
+    pure int  feof(FILE*);
+    ///
+    pure int  ferror(FILE*);
+    ///
+    int  fileno(FILE*);
+  }
+
+  ///
+    int  snprintf(char* s, size_t n, in char* format, ...);
+    ///
+    int  vsnprintf(char* s, size_t n, in char* format, va_list arg);
+}
+else
+{
+    static assert( false, "Unsupported platform" );
+}
+
+///
+void perror(in char* s);
+
+version(CRuntime_DigitalMars)
+{
+    import core.sys.windows.windows;
+
+    enum
+    {
+        ///
+        FHND_APPEND     = 0x04,
+        ///
+        FHND_DEVICE     = 0x08,
+        ///
+        FHND_TEXT       = 0x10,
+        ///
+        FHND_BYTE       = 0x20,
+        ///
+        FHND_WCHAR      = 0x40,
+    }
+
+    private enum _MAX_SEMAPHORES = 10 + _NFILE;
+    private enum _semIO = 3;
+
+    private extern __gshared short[_MAX_SEMAPHORES] _iSemLockCtrs;
+    private extern __gshared int[_MAX_SEMAPHORES] _iSemThreadIds;
+    private extern __gshared int[_MAX_SEMAPHORES] _iSemNestCount;
+    private extern __gshared HANDLE[_NFILE] _osfhnd;
+    extern shared ubyte[_NFILE] __fhnd_info;
+
+    private void _WaitSemaphore(int iSemaphore);
+    private void _ReleaseSemaphore(int iSemaphore);
+
+    // this is copied from semlock.h in DMC's runtime.
+    private void LockSemaphore(uint num)
+    {
+        asm nothrow @nogc
+        {
+            mov EDX, num;
+            lock;
+            inc _iSemLockCtrs[EDX * 2];
+            jz lsDone;
+            push EDX;
+            call _WaitSemaphore;
+            add ESP, 4;
+        }
+
+    lsDone: {}
+    }
+
+    // this is copied from semlock.h in DMC's runtime.
+    private void UnlockSemaphore(uint num)
+    {
+        asm nothrow @nogc
+        {
+            mov EDX, num;
+            lock;
+            dec _iSemLockCtrs[EDX * 2];
+            js usDone;
+            push EDX;
+            call _ReleaseSemaphore;
+            add ESP, 4;
+        }
+
+    usDone: {}
+    }
+
+    // This converts a HANDLE to a file descriptor in DMC's runtime
+    ///
+    int _handleToFD(HANDLE h, int flags)
+    {
+        LockSemaphore(_semIO);
+        scope(exit) UnlockSemaphore(_semIO);
+
+        foreach (fd; 0 .. _NFILE)
+        {
+            if (!_osfhnd[fd])
+            {
+                _osfhnd[fd] = h;
+                __fhnd_info[fd] = cast(ubyte)flags;
+                return fd;
+            }
+        }
+
+        return -1;
+    }
+
+    ///
+    HANDLE _fdToHandle(int fd)
+    {
+        // no semaphore is required, once inserted, a file descriptor
+        // doesn't change.
+        if (fd < 0 || fd >= _NFILE)
+            return null;
+
+        return _osfhnd[fd];
+    }
+
+    enum
+    {
+        ///
+        STDIN_FILENO  = 0,
+        ///
+        STDOUT_FILENO = 1,
+        ///
+        STDERR_FILENO = 2,
+    }
+
+    int open(const(char)* filename, int flags, ...); ///
+    alias _open = open; ///
+    int _wopen(const wchar* filename, int oflag, ...); ///
+    int sopen(const char* filename, int oflag, int shflag, ...); ///
+    alias _sopen = sopen; ///
+    int _wsopen(const wchar* filename, int oflag, int shflag, ...); ///
+    int close(int fd); ///
+    alias _close = close; ///
+    FILE *fdopen(int fd, const(char)* flags); ///
+    alias _fdopen = fdopen; ///
+    FILE *_wfdopen(int fd, const(wchar)* flags); ///
+
+}
+else version (CRuntime_Microsoft)
+{
+    int _open(const char* filename, int oflag, ...); ///
+    int _wopen(const wchar* filename, int oflag, ...); ///
+    int _sopen(const char* filename, int oflag, int shflag, ...); ///
+    int _wsopen(const wchar* filename, int oflag, int shflag, ...); ///
+    int _close(int fd); ///
+    FILE *_fdopen(int fd, const(char)* flags); ///
+    FILE *_wfdopen(int fd, const(wchar)* flags); ///
+}
+
+version (Windows)
+{
+    // file open flags
+    enum
+    {
+        _O_RDONLY = 0x0000, ///
+        O_RDONLY = _O_RDONLY, ///
+        _O_WRONLY = 0x0001, ///
+        O_WRONLY = _O_WRONLY, ///
+        _O_RDWR   = 0x0002, ///
+        O_RDWR = _O_RDWR, ///
+        _O_APPEND = 0x0008, ///
+        O_APPEND = _O_APPEND, ///
+        _O_CREAT  = 0x0100, ///
+        O_CREAT = _O_CREAT, ///
+        _O_TRUNC  = 0x0200, ///
+        O_TRUNC = _O_TRUNC, ///
+        _O_EXCL   = 0x0400, ///
+        O_EXCL = _O_EXCL, ///
+        _O_TEXT   = 0x4000, ///
+        O_TEXT = _O_TEXT, ///
+        _O_BINARY = 0x8000, ///
+        O_BINARY = _O_BINARY, ///
+    }
+
+    enum
+    {
+        _S_IREAD  = 0x0100, /// read permission, owner
+        S_IREAD = _S_IREAD, /// read permission, owner
+        _S_IWRITE = 0x0080, /// write permission, owner
+        S_IWRITE = _S_IWRITE, /// write permission, owner
+    }
+
+    enum
+    {
+        _SH_DENYRW = 0x10, /// deny read/write mode
+        SH_DENYRW = _SH_DENYRW, /// deny read/write mode
+        _SH_DENYWR = 0x20, /// deny write mode
+        SH_DENYWR = _SH_DENYWR, /// deny write mode
+        _SH_DENYRD = 0x30, /// deny read mode
+        SH_DENYRD = _SH_DENYRD, /// deny read mode
+        _SH_DENYNO = 0x40, /// deny none mode
+        SH_DENYNO = _SH_DENYNO, /// deny none mode
+    }
+}
diff --git a/libphobos/libdruntime/core/stdc/stdlib.d b/libphobos/libdruntime/core/stdc/stdlib.d
new file mode 100644
index 00000000000..d644d0bfe12
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/stdlib.d
@@ -0,0 +1,224 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_stdlib.h.html, _stdlib.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2014.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Standards: ISO/IEC 9899:1999 (E)
+ * Source: $(DRUNTIMESRC src/core/stdc/_stdlib.d)
+ */
+
+module core.stdc.stdlib;
+
+private import core.stdc.config;
+public import core.stdc.stddef; // for wchar_t
+
+extern (C):
+@system:
+
+/* Placed outside @nogc in order to not constrain what the callback does.
+ */
+///
+alias int function(in void*, in void*) _compare_fp_t;
+///
+void*   bsearch(in void* key, in void* base, size_t nmemb, size_t size, _compare_fp_t compar);
+///
+void    qsort(void* base, size_t nmemb, size_t size, _compare_fp_t compar);
+
+
+nothrow:
+@nogc:
+
+///
+struct div_t
+{
+    int quot,
+        rem;
+}
+
+///
+struct ldiv_t
+{
+    int quot,
+        rem;
+}
+
+///
+struct lldiv_t
+{
+    long quot,
+         rem;
+}
+
+///
+enum EXIT_SUCCESS = 0;
+///
+enum EXIT_FAILURE = 1;
+///
+enum MB_CUR_MAX   = 1;
+
+///
+version(Windows)      enum RAND_MAX = 0x7fff;
+else version(CRuntime_Glibc)  enum RAND_MAX = 0x7fffffff;
+else version(OSX)     enum RAND_MAX = 0x7fffffff;
+else version(FreeBSD) enum RAND_MAX = 0x7fffffff;
+else version(Solaris) enum RAND_MAX = 0x7fff;
+else version(CRuntime_Bionic) enum RAND_MAX = 0x7fffffff;
+else static assert( false, "Unsupported platform" );
+
+///
+double  atof(in char* nptr);
+///
+int     atoi(in char* nptr);
+///
+c_long  atol(in char* nptr);
+///
+long    atoll(in char* nptr);
+
+///
+double  strtod(in char* nptr, char** endptr);
+///
+float   strtof(in char* nptr, char** endptr);
+///
+c_long  strtol(in char* nptr, char** endptr, int base);
+///
+long    strtoll(in char* nptr, char** endptr, int base);
+///
+c_ulong strtoul(in char* nptr, char** endptr, int base);
+///
+ulong   strtoull(in char* nptr, char** endptr, int base);
+
+version (CRuntime_Microsoft)
+{
+    // strtold exists starting from VS2013, so we make this a template to avoid link errors
+    ///
+    real strtold()(in char* nptr, char** endptr)
+    {   // Fake it 'till we make it
+        return strtod(nptr, endptr);
+    }
+}
+else version (MinGW)
+{
+    ///
+    real __mingw_strtold(in char* nptr, char** endptr);
+    ///
+    alias __mingw_strtold strtold;
+}
+else version (CRuntime_Bionic)
+{
+    ///
+    real strtold(in char* nptr, char** endptr)
+    {   // Fake it again till we make it
+        return strtod(nptr, endptr);
+    }
+}
+else
+{
+    ///
+    real strtold(in char* nptr, char** endptr);
+}
+
+// No unsafe pointer manipulation.
+@trusted
+{
+    version(CRuntime_Bionic)
+    {
+       import core.sys.posix.stdlib: lrand48, srand48;
+       ///
+       alias core.sys.posix.stdlib.lrand48 rand;
+       ///
+       alias core.sys.posix.stdlib.srand48 srand;
+    }
+    else
+    {
+        ///
+       int     rand();
+       ///
+       void    srand(uint seed);
+    }
+}
+
+// We don't mark these @trusted. Given that they return a void*, one has
+// to do a pointer cast to do anything sensible with the result. Thus,
+// functions using these already have to be @trusted, allowing them to
+// call @system stuff anyway.
+///
+void*   malloc(size_t size);
+///
+void*   calloc(size_t nmemb, size_t size);
+///
+void*   realloc(void* ptr, size_t size);
+///
+void    free(void* ptr);
+
+///
+void    abort() @safe;
+///
+void    exit(int status);
+///
+int     atexit(void function() func);
+///
+void    _Exit(int status);
+
+///
+char*   getenv(in char* name);
+///
+int     system(in char* string);
+
+// These only operate on integer values.
+@trusted
+{
+    ///
+    pure int     abs(int j);
+    ///
+    pure c_long  labs(c_long j);
+    ///
+    pure long    llabs(long j);
+
+    ///
+    div_t   div(int numer, int denom);
+    ///
+    ldiv_t  ldiv(c_long numer, c_long denom);
+    ///
+    lldiv_t lldiv(long numer, long denom);
+}
+
+///
+int     mblen(in char* s, size_t n);
+///
+int     mbtowc(wchar_t* pwc, in char* s, size_t n);
+///
+int     wctomb(char*s, wchar_t wc);
+///
+size_t  mbstowcs(wchar_t* pwcs, in char* s, size_t n);
+///
+size_t  wcstombs(char* s, in wchar_t* pwcs, size_t n);
+
+///
+version( DigitalMars )
+{
+    // See malloc comment about @trusted.
+    void* alloca(size_t size); // non-standard
+}
+else version( GNU )
+{
+    void* alloca(size_t size); // compiler intrinsic
+}
+
+version( CRuntime_Microsoft )
+{
+    ///
+    ulong  _strtoui64(in char *,char **,int);
+    ///
+    ulong  _wcstoui64(in wchar *,wchar **,int);
+
+    ///
+    long  _strtoi64(in char *,char **,int);
+    ///
+    long  _wcstoi64(in wchar *,wchar **,int);
+}
+
diff --git a/libphobos/libdruntime/core/stdc/string.d b/libphobos/libdruntime/core/stdc/string.d
new file mode 100644
index 00000000000..1ed6e3a237e
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/string.d
@@ -0,0 +1,95 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_string.h.html, _string.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_string.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.string;
+
+extern (C):
+@system:
+nothrow:
+@nogc:
+
+///
+pure void* memchr(in void* s, int c, size_t n);
+///
+pure int   memcmp(in void* s1, in void* s2, size_t n);
+///
+pure void* memcpy(void* s1, in void* s2, size_t n);
+version (Windows)
+{
+    ///
+    int memicmp(in char* s1, in char* s2, size_t n);
+}
+///
+pure void* memmove(void* s1, in void* s2, size_t n);
+///
+pure void* memset(void* s, int c, size_t n);
+
+///
+pure char*  strcpy(char* s1, in char* s2);
+///
+pure char*  strncpy(char* s1, in char* s2, size_t n);
+///
+pure char*  strcat(char* s1, in char* s2);
+///
+pure char*  strncat(char* s1, in char* s2, size_t n);
+///
+pure int    strcmp(in char* s1, in char* s2);
+///
+int    strcoll(in char* s1, in char* s2);
+///
+pure int    strncmp(in char* s1, in char* s2, size_t n);
+///
+size_t strxfrm(char* s1, in char* s2, size_t n);
+///
+pure char*  strchr(in char* s, int c);
+///
+pure size_t strcspn(in char* s1, in char* s2);
+///
+pure char*  strpbrk(in char* s1, in char* s2);
+///
+pure char*  strrchr(in char* s, int c);
+///
+pure size_t strspn(in char* s1, in char* s2);
+///
+pure char*  strstr(in char* s1, in char* s2);
+///
+char*  strtok(char* s1, in char* s2);
+///
+char*  strerror(int errnum);
+version (CRuntime_Glibc)
+{
+    ///
+    const(char)* strerror_r(int errnum, char* buf, size_t buflen);
+}
+else version (OSX)
+{
+    int strerror_r(int errnum, char* buf, size_t buflen);
+}
+else version (FreeBSD)
+{
+    int strerror_r(int errnum, char* buf, size_t buflen);
+}
+else version (Solaris)
+{
+    int strerror_r(int errnum, char* buf, size_t buflen);
+}
+else version (CRuntime_Bionic)
+{
+    ///
+    int strerror_r(int errnum, char* buf, size_t buflen);
+}
+///
+pure size_t strlen(in char* s);
+///
+char*  strdup(in char *s);
diff --git a/libphobos/libdruntime/core/stdc/tgmath.d b/libphobos/libdruntime/core/stdc/tgmath.d
new file mode 100644
index 00000000000..802f27e6b79
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/tgmath.d
@@ -0,0 +1,1131 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_tgmath.h.html, _tgmath.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_tgmath.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.tgmath;
+
+private import core.stdc.config;
+private static import core.stdc.math;
+private static import core.stdc.complex;
+
+extern (C):
+@trusted: // Everything here operates on floating point and integer values.
+nothrow:
+@nogc:
+
+version( FreeBSD )
+{
+    ///
+    alias core.stdc.math.acos          acos;
+    ///
+    alias core.stdc.math.acosf         acos;
+    ///
+    alias core.stdc.math.acosl         acos;
+
+    ///
+    alias core.stdc.complex.cacos      acos;
+    ///
+    alias core.stdc.complex.cacosf     acos;
+    ///
+    alias core.stdc.complex.cacosl     acos;
+
+    ///
+    alias core.stdc.math.asin          asin;
+    ///
+    alias core.stdc.math.asinf         asin;
+    ///
+    alias core.stdc.math.asinl         asin;
+
+    ///
+    alias core.stdc.complex.casin      asin;
+    ///
+    alias core.stdc.complex.casinf     asin;
+    ///
+    alias core.stdc.complex.casinl     asin;
+
+    ///
+    alias core.stdc.math.atan          atan;
+    ///
+    alias core.stdc.math.atanf         atan;
+    ///
+    alias core.stdc.math.atanl         atan;
+
+    ///
+    alias core.stdc.complex.catan      atan;
+    ///
+    alias core.stdc.complex.catanf     atan;
+    ///
+    alias core.stdc.complex.catanl     atan;
+
+    ///
+    alias core.stdc.math.atan2         atan2;
+    ///
+    alias core.stdc.math.atan2f        atan2;
+    ///
+    alias core.stdc.math.atan2l        atan2;
+
+    ///
+    alias core.stdc.math.cos           cos;
+    ///
+    alias core.stdc.math.cosf          cos;
+    ///
+    alias core.stdc.math.cosl          cos;
+
+    ///
+    alias core.stdc.complex.ccos       cos;
+    ///
+    alias core.stdc.complex.ccosf      cos;
+    ///
+    alias core.stdc.complex.ccosl      cos;
+
+    ///
+    alias core.stdc.math.sin           sin;
+    ///
+    alias core.stdc.math.sinf          sin;
+    ///
+    alias core.stdc.math.sinl          sin;
+
+    ///
+    alias core.stdc.complex.csin       csin;
+    ///
+    alias core.stdc.complex.csinf      csin;
+    ///
+    alias core.stdc.complex.csinl      csin;
+
+    ///
+    alias core.stdc.math.tan           tan;
+    ///
+    alias core.stdc.math.tanf          tan;
+    ///
+    alias core.stdc.math.tanl          tan;
+
+    ///
+    alias core.stdc.complex.ctan       tan;
+    ///
+    alias core.stdc.complex.ctanf      tan;
+    ///
+    alias core.stdc.complex.ctanl      tan;
+
+    ///
+    alias core.stdc.math.acosh         acosh;
+    ///
+    alias core.stdc.math.acoshf        acosh;
+    ///
+    alias core.stdc.math.acoshl        acosh;
+
+    ///
+    alias core.stdc.complex.cacosh     acosh;
+    ///
+    alias core.stdc.complex.cacoshf    acosh;
+    ///
+    alias core.stdc.complex.cacoshl    acosh;
+
+    ///
+    alias core.stdc.math.asinh         asinh;
+    ///
+    alias core.stdc.math.asinhf        asinh;
+    ///
+    alias core.stdc.math.asinhl        asinh;
+
+    ///
+    alias core.stdc.complex.casinh     asinh;
+    ///
+    alias core.stdc.complex.casinhf    asinh;
+    ///
+    alias core.stdc.complex.casinhl    asinh;
+
+    ///
+    alias core.stdc.math.atanh         atanh;
+    ///
+    alias core.stdc.math.atanhf        atanh;
+    ///
+    alias core.stdc.math.atanhl        atanh;
+
+    ///
+    alias core.stdc.complex.catanh     atanh;
+    ///
+    alias core.stdc.complex.catanhf    atanh;
+    ///
+    alias core.stdc.complex.catanhl    atanh;
+
+    ///
+    alias core.stdc.math.cosh          cosh;
+    ///
+    alias core.stdc.math.coshf         cosh;
+    ///
+    alias core.stdc.math.coshl         cosh;
+
+    ///
+    alias core.stdc.complex.ccosh      cosh;
+    ///
+    alias core.stdc.complex.ccoshf     cosh;
+    ///
+    alias core.stdc.complex.ccoshl     cosh;
+
+    ///
+    alias core.stdc.math.sinh          sinh;
+    ///
+    alias core.stdc.math.sinhf         sinh;
+    ///
+    alias core.stdc.math.sinhl         sinh;
+
+    ///
+    alias core.stdc.complex.csinh      sinh;
+    ///
+    alias core.stdc.complex.csinhf     sinh;
+    ///
+    alias core.stdc.complex.csinhl     sinh;
+
+    ///
+    alias core.stdc.math.tanh          tanh;
+    ///
+    alias core.stdc.math.tanhf         tanh;
+    ///
+    alias core.stdc.math.tanhl         tanh;
+
+    ///
+    alias core.stdc.complex.ctanh      tanh;
+    ///
+    alias core.stdc.complex.ctanhf     tanh;
+    ///
+    alias core.stdc.complex.ctanhl     tanh;
+
+    ///
+    alias core.stdc.math.exp           exp;
+    ///
+    alias core.stdc.math.expf          exp;
+    ///
+    alias core.stdc.math.expl          exp;
+
+    ///
+    alias core.stdc.complex.cexp       exp;
+    ///
+    alias core.stdc.complex.cexpf      exp;
+    ///
+    alias core.stdc.complex.cexpl      exp;
+
+    ///
+    alias core.stdc.math.exp2          exp2;
+    ///
+    alias core.stdc.math.exp2f         exp2;
+    ///
+    alias core.stdc.math.exp2l         exp2;
+
+    ///
+    alias core.stdc.math.expm1         expm1;
+    ///
+    alias core.stdc.math.expm1f        expm1;
+    ///
+    alias core.stdc.math.expm1l        expm1;
+
+    ///
+    alias core.stdc.math.frexp         frexp;
+    ///
+    alias core.stdc.math.frexpf        frexp;
+    ///
+    alias core.stdc.math.frexpl        frexp;
+
+    ///
+    alias core.stdc.math.ilogb         ilogb;
+    ///
+    alias core.stdc.math.ilogbf        ilogb;
+    ///
+    alias core.stdc.math.ilogbl        ilogb;
+
+    ///
+    alias core.stdc.math.ldexp         ldexp;
+    ///
+    alias core.stdc.math.ldexpf        ldexp;
+    ///
+    alias core.stdc.math.ldexpl        ldexp;
+
+    ///
+    alias core.stdc.math.log           log;
+    ///
+    alias core.stdc.math.logf          log;
+    ///
+    alias core.stdc.math.logl          log;
+
+    ///
+    alias core.stdc.complex.clog       log;
+    ///
+    alias core.stdc.complex.clogf      log;
+    ///
+    alias core.stdc.complex.clogl      log;
+
+    ///
+    alias core.stdc.math.log10         log10;
+    ///
+    alias core.stdc.math.log10f        log10;
+    ///
+    alias core.stdc.math.log10l        log10;
+
+    ///
+    alias core.stdc.math.log1p         log1p;
+    ///
+    alias core.stdc.math.log1pf        log1p;
+    ///
+    alias core.stdc.math.log1pl        log1p;
+
+    ///
+    alias core.stdc.math.log2          log2;
+    ///
+    alias core.stdc.math.log2f         log2;
+    ///
+    alias core.stdc.math.log2l         log2;
+
+    ///
+    alias core.stdc.math.logb          logb;
+    ///
+    alias core.stdc.math.logbf         logb;
+    ///
+    alias core.stdc.math.logbl         logb;
+
+    ///
+    alias core.stdc.math.modf          modf;
+    ///
+    alias core.stdc.math.modff         modf;
+//  alias core.stdc.math.modfl         modf;
+
+    ///
+    alias core.stdc.math.scalbn        scalbn;
+    ///
+    alias core.stdc.math.scalbnf       scalbn;
+    ///
+    alias core.stdc.math.scalbnl       scalbn;
+
+    ///
+    alias core.stdc.math.scalbln       scalbln;
+    ///
+    alias core.stdc.math.scalblnf      scalbln;
+    ///
+    alias core.stdc.math.scalblnl      scalbln;
+
+    ///
+    alias core.stdc.math.cbrt          cbrt;
+    ///
+    alias core.stdc.math.cbrtf         cbrt;
+    ///
+    alias core.stdc.math.cbrtl         cbrt;
+
+    ///
+    alias core.stdc.math.fabs          fabs;
+    ///
+    alias core.stdc.math.fabsf         fabs;
+    ///
+    alias core.stdc.math.fabsl         fabs;
+
+    ///
+    alias core.stdc.complex.cabs       fabs;
+    ///
+    alias core.stdc.complex.cabsf      fabs;
+    ///
+    alias core.stdc.complex.cabsl      fabs;
+
+    ///
+    alias core.stdc.math.hypot         hypot;
+    ///
+    alias core.stdc.math.hypotf        hypot;
+    ///
+    alias core.stdc.math.hypotl        hypot;
+
+    ///
+    alias core.stdc.math.pow           pow;
+    ///
+    alias core.stdc.math.powf          pow;
+    ///
+    alias core.stdc.math.powl          pow;
+
+    ///
+    alias core.stdc.complex.cpow       pow;
+    ///
+    alias core.stdc.complex.cpowf      pow;
+    ///
+    alias core.stdc.complex.cpowl      pow;
+
+    ///
+    alias core.stdc.math.sqrt          sqrt;
+    ///
+    alias core.stdc.math.sqrtf         sqrt;
+    ///
+    alias core.stdc.math.sqrtl         sqrt;
+
+    ///
+    alias core.stdc.complex.csqrt      sqrt;
+    ///
+    alias core.stdc.complex.csqrtf     sqrt;
+    ///
+    alias core.stdc.complex.csqrtl     sqrt;
+
+    ///
+    alias core.stdc.math.erf           erf;
+    ///
+    alias core.stdc.math.erff          erf;
+    ///
+    alias core.stdc.math.erfl          erf;
+
+    ///
+    alias core.stdc.math.erfc          erfc;
+    ///
+    alias core.stdc.math.erfcf         erfc;
+    ///
+    alias core.stdc.math.erfcl         erfc;
+
+    ///
+    alias core.stdc.math.lgamma        lgamma;
+    ///
+    alias core.stdc.math.lgammaf       lgamma;
+    ///
+    alias core.stdc.math.lgammal       lgamma;
+
+    ///
+    alias core.stdc.math.tgamma        tgamma;
+    ///
+    alias core.stdc.math.tgammaf       tgamma;
+    ///
+    alias core.stdc.math.tgammal       tgamma;
+
+    ///
+    alias core.stdc.math.ceil          ceil;
+    ///
+    alias core.stdc.math.ceilf         ceil;
+    ///
+    alias core.stdc.math.ceill         ceil;
+
+    ///
+    alias core.stdc.math.floor         floor;
+    ///
+    alias core.stdc.math.floorf        floor;
+    ///
+    alias core.stdc.math.floorl        floor;
+
+    ///
+    alias core.stdc.math.nearbyint     nearbyint;
+    ///
+    alias core.stdc.math.nearbyintf    nearbyint;
+    ///
+    alias core.stdc.math.nearbyintl    nearbyint;
+
+    ///
+    alias core.stdc.math.rint          rint;
+    ///
+    alias core.stdc.math.rintf         rint;
+    ///
+    alias core.stdc.math.rintl         rint;
+
+    ///
+    alias core.stdc.math.lrint         lrint;
+    ///
+    alias core.stdc.math.lrintf        lrint;
+    ///
+    alias core.stdc.math.lrintl        lrint;
+
+    ///
+    alias core.stdc.math.llrint        llrint;
+    ///
+    alias core.stdc.math.llrintf       llrint;
+    ///
+    alias core.stdc.math.llrintl       llrint;
+
+    ///
+    alias core.stdc.math.round         round;
+    ///
+    alias core.stdc.math.roundf        round;
+    ///
+    alias core.stdc.math.roundl        round;
+
+    ///
+    alias core.stdc.math.lround        lround;
+    ///
+    alias core.stdc.math.lroundf       lround;
+    ///
+    alias core.stdc.math.lroundl       lround;
+
+    ///
+    alias core.stdc.math.llround       llround;
+    ///
+    alias core.stdc.math.llroundf      llround;
+    ///
+    alias core.stdc.math.llroundl      llround;
+
+    ///
+    alias core.stdc.math.trunc         trunc;
+    ///
+    alias core.stdc.math.truncf        trunc;
+    ///
+    alias core.stdc.math.truncl        trunc;
+
+    ///
+    alias core.stdc.math.fmod          fmod;
+    ///
+    alias core.stdc.math.fmodf         fmod;
+    ///
+    alias core.stdc.math.fmodl         fmod;
+
+    ///
+    alias core.stdc.math.remainder     remainder;
+    ///
+    alias core.stdc.math.remainderf    remainder;
+    ///
+    alias core.stdc.math.remainderl    remainder;
+
+    ///
+    alias core.stdc.math.remquo        remquo;
+    ///
+    alias core.stdc.math.remquof       remquo;
+    ///
+    alias core.stdc.math.remquol       remquo;
+
+    ///
+    alias core.stdc.math.copysign      copysign;
+    ///
+    alias core.stdc.math.copysignf     copysign;
+    ///
+    alias core.stdc.math.copysignl     copysign;
+
+//  alias core.stdc.math.nan           nan;
+//  alias core.stdc.math.nanf          nan;
+//  alias core.stdc.math.nanl          nan;
+
+    ///
+    alias core.stdc.math.nextafter     nextafter;
+    ///
+    alias core.stdc.math.nextafterf    nextafter;
+    ///
+    alias core.stdc.math.nextafterl    nextafter;
+
+    ///
+    alias core.stdc.math.nexttoward    nexttoward;
+    ///
+    alias core.stdc.math.nexttowardf   nexttoward;
+    ///
+    alias core.stdc.math.nexttowardl   nexttoward;
+
+    ///
+    alias core.stdc.math.fdim          fdim;
+    ///
+    alias core.stdc.math.fdimf         fdim;
+    ///
+    alias core.stdc.math.fdiml         fdim;
+
+    ///
+    alias core.stdc.math.fmax          fmax;
+    ///
+    alias core.stdc.math.fmaxf         fmax;
+    ///
+    alias core.stdc.math.fmaxl         fmax;
+
+    ///
+    alias core.stdc.math.fmin          fmin;
+    ///
+    alias core.stdc.math.fmin          fmin;
+    ///
+    alias core.stdc.math.fminl         fmin;
+
+    ///
+    alias core.stdc.math.fma           fma;
+    ///
+    alias core.stdc.math.fmaf          fma;
+    ///
+    alias core.stdc.math.fmal          fma;
+
+    ///
+    alias core.stdc.complex.carg       carg;
+    ///
+    alias core.stdc.complex.cargf      carg;
+    ///
+    alias core.stdc.complex.cargl      carg;
+
+    ///
+    alias core.stdc.complex.cimag      cimag;
+    ///
+    alias core.stdc.complex.cimagf     cimag;
+    ///
+    alias core.stdc.complex.cimagl     cimag;
+
+    ///
+    alias core.stdc.complex.conj       conj;
+    ///
+    alias core.stdc.complex.conjf      conj;
+    ///
+    alias core.stdc.complex.conjl      conj;
+
+    ///
+    alias core.stdc.complex.cproj      cproj;
+    ///
+    alias core.stdc.complex.cprojf     cproj;
+    ///
+    alias core.stdc.complex.cprojl     cproj;
+
+//  alias core.stdc.complex.creal      creal;
+//  alias core.stdc.complex.crealf     creal;
+//  alias core.stdc.complex.creall     creal;
+}
+else
+{
+    ///
+    alias core.stdc.math.acos          acos;
+    ///
+    alias core.stdc.math.acosf         acos;
+    ///
+    alias core.stdc.math.acosl         acos;
+
+    ///
+    alias core.stdc.complex.cacos      acos;
+    ///
+    alias core.stdc.complex.cacosf     acos;
+    ///
+    alias core.stdc.complex.cacosl     acos;
+
+    ///
+    alias core.stdc.math.asin          asin;
+    ///
+    alias core.stdc.math.asinf         asin;
+    ///
+    alias core.stdc.math.asinl         asin;
+
+    ///
+    alias core.stdc.complex.casin      asin;
+    ///
+    alias core.stdc.complex.casinf     asin;
+    ///
+    alias core.stdc.complex.casinl     asin;
+
+    ///
+    alias core.stdc.math.atan          atan;
+    ///
+    alias core.stdc.math.atanf         atan;
+    ///
+    alias core.stdc.math.atanl         atan;
+
+    ///
+    alias core.stdc.complex.catan      atan;
+    ///
+    alias core.stdc.complex.catanf     atan;
+    ///
+    alias core.stdc.complex.catanl     atan;
+
+    ///
+    alias core.stdc.math.atan2         atan2;
+    ///
+    alias core.stdc.math.atan2f        atan2;
+    ///
+    alias core.stdc.math.atan2l        atan2;
+
+    ///
+    alias core.stdc.math.cos           cos;
+    ///
+    alias core.stdc.math.cosf          cos;
+    ///
+    alias core.stdc.math.cosl          cos;
+
+    ///
+    alias core.stdc.complex.ccos       cos;
+    ///
+    alias core.stdc.complex.ccosf      cos;
+    ///
+    alias core.stdc.complex.ccosl      cos;
+
+    ///
+    alias core.stdc.math.sin           sin;
+    ///
+    alias core.stdc.math.sinf          sin;
+    ///
+    alias core.stdc.math.sinl          sin;
+
+    ///
+    alias core.stdc.complex.csin       csin;
+    ///
+    alias core.stdc.complex.csinf      csin;
+    ///
+    alias core.stdc.complex.csinl      csin;
+
+    ///
+    alias core.stdc.math.tan           tan;
+    ///
+    alias core.stdc.math.tanf          tan;
+    ///
+    alias core.stdc.math.tanl          tan;
+
+    ///
+    alias core.stdc.complex.ctan       tan;
+    ///
+    alias core.stdc.complex.ctanf      tan;
+    ///
+    alias core.stdc.complex.ctanl      tan;
+
+    ///
+    alias core.stdc.math.acosh         acosh;
+    ///
+    alias core.stdc.math.acoshf        acosh;
+    ///
+    alias core.stdc.math.acoshl        acosh;
+
+    ///
+    alias core.stdc.complex.cacosh     acosh;
+    ///
+    alias core.stdc.complex.cacoshf    acosh;
+    ///
+    alias core.stdc.complex.cacoshl    acosh;
+
+    ///
+    alias core.stdc.math.asinh         asinh;
+    ///
+    alias core.stdc.math.asinhf        asinh;
+    ///
+    alias core.stdc.math.asinhl        asinh;
+
+    ///
+    alias core.stdc.complex.casinh     asinh;
+    ///
+    alias core.stdc.complex.casinhf    asinh;
+    ///
+    alias core.stdc.complex.casinhl    asinh;
+
+    ///
+    alias core.stdc.math.atanh         atanh;
+    ///
+    alias core.stdc.math.atanhf        atanh;
+    ///
+    alias core.stdc.math.atanhl        atanh;
+
+    ///
+    alias core.stdc.complex.catanh     atanh;
+    ///
+    alias core.stdc.complex.catanhf    atanh;
+    ///
+    alias core.stdc.complex.catanhl    atanh;
+
+    ///
+    alias core.stdc.math.cosh          cosh;
+    ///
+    alias core.stdc.math.coshf         cosh;
+    ///
+    alias core.stdc.math.coshl         cosh;
+
+    ///
+    alias core.stdc.complex.ccosh      cosh;
+    ///
+    alias core.stdc.complex.ccoshf     cosh;
+    ///
+    alias core.stdc.complex.ccoshl     cosh;
+
+    ///
+    alias core.stdc.math.sinh          sinh;
+    ///
+    alias core.stdc.math.sinhf         sinh;
+    ///
+    alias core.stdc.math.sinhl         sinh;
+
+    ///
+    alias core.stdc.complex.csinh      sinh;
+    ///
+    alias core.stdc.complex.csinhf     sinh;
+    ///
+    alias core.stdc.complex.csinhl     sinh;
+
+    ///
+    alias core.stdc.math.tanh          tanh;
+    ///
+    alias core.stdc.math.tanhf         tanh;
+    ///
+    alias core.stdc.math.tanhl         tanh;
+
+    ///
+    alias core.stdc.complex.ctanh      tanh;
+    ///
+    alias core.stdc.complex.ctanhf     tanh;
+    ///
+    alias core.stdc.complex.ctanhl     tanh;
+
+    ///
+    alias core.stdc.math.exp           exp;
+    ///
+    alias core.stdc.math.expf          exp;
+    ///
+    alias core.stdc.math.expl          exp;
+
+    ///
+    alias core.stdc.complex.cexp       exp;
+    ///
+    alias core.stdc.complex.cexpf      exp;
+    ///
+    alias core.stdc.complex.cexpl      exp;
+
+    ///
+    alias core.stdc.math.exp2          exp2;
+    ///
+    alias core.stdc.math.exp2f         exp2;
+    ///
+    alias core.stdc.math.exp2l         exp2;
+
+    ///
+    alias core.stdc.math.expm1         expm1;
+    ///
+    alias core.stdc.math.expm1f        expm1;
+    ///
+    alias core.stdc.math.expm1l        expm1;
+
+    ///
+    alias core.stdc.math.frexp         frexp;
+    ///
+    alias core.stdc.math.frexpf        frexp;
+    ///
+    alias core.stdc.math.frexpl        frexp;
+
+    ///
+    alias core.stdc.math.ilogb         ilogb;
+    ///
+    alias core.stdc.math.ilogbf        ilogb;
+    ///
+    alias core.stdc.math.ilogbl        ilogb;
+
+    ///
+    alias core.stdc.math.ldexp         ldexp;
+    ///
+    alias core.stdc.math.ldexpf        ldexp;
+    ///
+    alias core.stdc.math.ldexpl        ldexp;
+
+    ///
+    alias core.stdc.math.log           log;
+    ///
+    alias core.stdc.math.logf          log;
+    ///
+    alias core.stdc.math.logl          log;
+
+    ///
+    alias core.stdc.complex.clog       log;
+    ///
+    alias core.stdc.complex.clogf      log;
+    ///
+    alias core.stdc.complex.clogl      log;
+
+    ///
+    alias core.stdc.math.log10         log10;
+    ///
+    alias core.stdc.math.log10f        log10;
+    ///
+    alias core.stdc.math.log10l        log10;
+
+    ///
+    alias core.stdc.math.log1p         log1p;
+    ///
+    alias core.stdc.math.log1pf        log1p;
+    ///
+    alias core.stdc.math.log1pl        log1p;
+
+    ///
+    alias core.stdc.math.log2          log2;
+    ///
+    alias core.stdc.math.log2f         log2;
+    ///
+    alias core.stdc.math.log2l         log2;
+
+    ///
+    alias core.stdc.math.logb          logb;
+    ///
+    alias core.stdc.math.logbf         logb;
+    ///
+    alias core.stdc.math.logbl         logb;
+
+    ///
+    alias core.stdc.math.modf          modf;
+    ///
+    alias core.stdc.math.modff         modf;
+    ///
+    alias core.stdc.math.modfl         modf;
+
+    ///
+    alias core.stdc.math.scalbn        scalbn;
+    ///
+    alias core.stdc.math.scalbnf       scalbn;
+    ///
+    alias core.stdc.math.scalbnl       scalbn;
+
+    ///
+    alias core.stdc.math.scalbln       scalbln;
+    ///
+    alias core.stdc.math.scalblnf      scalbln;
+    ///
+    alias core.stdc.math.scalblnl      scalbln;
+
+    ///
+    alias core.stdc.math.cbrt          cbrt;
+    ///
+    alias core.stdc.math.cbrtf         cbrt;
+    ///
+    alias core.stdc.math.cbrtl         cbrt;
+
+    ///
+    alias core.stdc.math.fabs          fabs;
+    version( CRuntime_Microsoft )
+    {
+    }
+    else
+    {
+        ///
+        alias core.stdc.math.fabsf         fabs;
+        ///
+        alias core.stdc.math.fabsl         fabs;
+    }
+
+    ///
+    alias core.stdc.complex.cabs       fabs;
+    ///
+    alias core.stdc.complex.cabsf      fabs;
+    ///
+    alias core.stdc.complex.cabsl      fabs;
+
+    ///
+    alias core.stdc.math.hypot         hypot;
+    ///
+    alias core.stdc.math.hypotf        hypot;
+    ///
+    alias core.stdc.math.hypotl        hypot;
+
+    ///
+    alias core.stdc.math.pow           pow;
+    ///
+    alias core.stdc.math.powf          pow;
+    ///
+    alias core.stdc.math.powl          pow;
+
+    ///
+    alias core.stdc.complex.cpow       pow;
+    ///
+    alias core.stdc.complex.cpowf      pow;
+    ///
+    alias core.stdc.complex.cpowl      pow;
+
+    ///
+    alias core.stdc.math.sqrt          sqrt;
+    ///
+    alias core.stdc.math.sqrtf         sqrt;
+    ///
+    alias core.stdc.math.sqrtl         sqrt;
+
+    ///
+    alias core.stdc.complex.csqrt      sqrt;
+    ///
+    alias core.stdc.complex.csqrtf     sqrt;
+    ///
+    alias core.stdc.complex.csqrtl     sqrt;
+
+    ///
+    alias core.stdc.math.erf           erf;
+    ///
+    alias core.stdc.math.erff          erf;
+    ///
+    alias core.stdc.math.erfl          erf;
+
+    ///
+    alias core.stdc.math.erfc          erfc;
+    ///
+    alias core.stdc.math.erfcf         erfc;
+    ///
+    alias core.stdc.math.erfcl         erfc;
+
+    ///
+    alias core.stdc.math.lgamma        lgamma;
+    ///
+    alias core.stdc.math.lgammaf       lgamma;
+    ///
+    alias core.stdc.math.lgammal       lgamma;
+
+    ///
+    alias core.stdc.math.tgamma        tgamma;
+    ///
+    alias core.stdc.math.tgammaf       tgamma;
+    ///
+    alias core.stdc.math.tgammal       tgamma;
+
+    ///
+    alias core.stdc.math.ceil          ceil;
+    ///
+    alias core.stdc.math.ceilf         ceil;
+    ///
+    alias core.stdc.math.ceill         ceil;
+
+    ///
+    alias core.stdc.math.floor         floor;
+    ///
+    alias core.stdc.math.floorf        floor;
+    ///
+    alias core.stdc.math.floorl        floor;
+
+    ///
+    alias core.stdc.math.nearbyint     nearbyint;
+    ///
+    alias core.stdc.math.nearbyintf    nearbyint;
+    ///
+    alias core.stdc.math.nearbyintl    nearbyint;
+
+    ///
+    alias core.stdc.math.rint          rint;
+    ///
+    alias core.stdc.math.rintf         rint;
+    ///
+    alias core.stdc.math.rintl         rint;
+
+    ///
+    alias core.stdc.math.lrint         lrint;
+    ///
+    alias core.stdc.math.lrintf        lrint;
+    ///
+    alias core.stdc.math.lrintl        lrint;
+
+    ///
+    alias core.stdc.math.llrint        llrint;
+    ///
+    alias core.stdc.math.llrintf       llrint;
+    ///
+    alias core.stdc.math.llrintl       llrint;
+
+    ///
+    alias core.stdc.math.round         round;
+    ///
+    alias core.stdc.math.roundf        round;
+    ///
+    alias core.stdc.math.roundl        round;
+
+    ///
+    alias core.stdc.math.lround        lround;
+    ///
+    alias core.stdc.math.lroundf       lround;
+    ///
+    alias core.stdc.math.lroundl       lround;
+
+    ///
+    alias core.stdc.math.llround       llround;
+    ///
+    alias core.stdc.math.llroundf      llround;
+    ///
+    alias core.stdc.math.llroundl      llround;
+
+    ///
+    alias core.stdc.math.trunc         trunc;
+    ///
+    alias core.stdc.math.truncf        trunc;
+    ///
+    alias core.stdc.math.truncl        trunc;
+
+    ///
+    alias core.stdc.math.fmod          fmod;
+    ///
+    alias core.stdc.math.fmodf         fmod;
+    ///
+    alias core.stdc.math.fmodl         fmod;
+
+    ///
+    alias core.stdc.math.remainder     remainder;
+    ///
+    alias core.stdc.math.remainderf    remainder;
+    ///
+    alias core.stdc.math.remainderl    remainder;
+
+    ///
+    alias core.stdc.math.remquo        remquo;
+    ///
+    alias core.stdc.math.remquof       remquo;
+    ///
+    alias core.stdc.math.remquol       remquo;
+
+    ///
+    alias core.stdc.math.copysign      copysign;
+    ///
+    alias core.stdc.math.copysignf     copysign;
+    ///
+    alias core.stdc.math.copysignl     copysign;
+
+    ///
+    alias core.stdc.math.nan           nan;
+    ///
+    alias core.stdc.math.nanf          nan;
+    ///
+    alias core.stdc.math.nanl          nan;
+
+    ///
+    alias core.stdc.math.nextafter     nextafter;
+    ///
+    alias core.stdc.math.nextafterf    nextafter;
+    ///
+    alias core.stdc.math.nextafterl    nextafter;
+
+    ///
+    alias core.stdc.math.nexttoward    nexttoward;
+    ///
+    alias core.stdc.math.nexttowardf   nexttoward;
+    ///
+    alias core.stdc.math.nexttowardl   nexttoward;
+
+    ///
+    alias core.stdc.math.fdim          fdim;
+    ///
+    alias core.stdc.math.fdimf         fdim;
+    ///
+    alias core.stdc.math.fdiml         fdim;
+
+    ///
+    alias core.stdc.math.fmax          fmax;
+    ///
+    alias core.stdc.math.fmaxf         fmax;
+    ///
+    alias core.stdc.math.fmaxl         fmax;
+
+    ///
+    alias core.stdc.math.fmin          fmin;
+    ///
+    alias core.stdc.math.fmin          fmin;
+    ///
+    alias core.stdc.math.fminl         fmin;
+
+    ///
+    alias core.stdc.math.fma           fma;
+    ///
+    alias core.stdc.math.fmaf          fma;
+    ///
+    alias core.stdc.math.fmal          fma;
+
+    ///
+    alias core.stdc.complex.carg       carg;
+    ///
+    alias core.stdc.complex.cargf      carg;
+    ///
+    alias core.stdc.complex.cargl      carg;
+
+    ///
+    alias core.stdc.complex.cimag      cimag;
+    ///
+    alias core.stdc.complex.cimagf     cimag;
+    ///
+    alias core.stdc.complex.cimagl     cimag;
+
+    ///
+    alias core.stdc.complex.conj       conj;
+    ///
+    alias core.stdc.complex.conjf      conj;
+    ///
+    alias core.stdc.complex.conjl      conj;
+
+    ///
+    alias core.stdc.complex.cproj      cproj;
+    ///
+    alias core.stdc.complex.cprojf     cproj;
+    ///
+    alias core.stdc.complex.cprojl     cproj;
+
+//  alias core.stdc.complex.creal      creal;
+//  alias core.stdc.complex.crealf     creal;
+//  alias core.stdc.complex.creall     creal;
+}
diff --git a/libphobos/libdruntime/core/stdc/time.d b/libphobos/libdruntime/core/stdc/time.d
new file mode 100644
index 00000000000..9bb3afc7fbb
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/time.d
@@ -0,0 +1,165 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_time.h.html, _time.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly,
+ *            Alex Rønne Petersen
+ * Source:    $(DRUNTIMESRC core/stdc/_time.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.time;
+
+private import core.stdc.config;
+
+extern (C):
+@trusted: // There are only a few functions here that use unsafe C strings.
+nothrow:
+@nogc:
+
+version( Windows )
+{
+    ///
+    struct tm
+    {
+        int     tm_sec;     /// seconds after the minute - [0, 60]
+        int     tm_min;     /// minutes after the hour - [0, 59]
+        int     tm_hour;    /// hours since midnight - [0, 23]
+        int     tm_mday;    /// day of the month - [1, 31]
+        int     tm_mon;     /// months since January - [0, 11]
+        int     tm_year;    /// years since 1900
+        int     tm_wday;    /// days since Sunday - [0, 6]
+        int     tm_yday;    /// days since January 1 - [0, 365]
+        int     tm_isdst;   /// Daylight Saving Time flag
+    }
+}
+else version( Posix )
+{
+    ///
+    struct tm
+    {
+        int     tm_sec;     /// seconds after the minute [0-60]
+        int     tm_min;     /// minutes after the hour [0-59]
+        int     tm_hour;    /// hours since midnight [0-23]
+        int     tm_mday;    /// day of the month [1-31]
+        int     tm_mon;     /// months since January [0-11]
+        int     tm_year;    /// years since 1900
+        int     tm_wday;    /// days since Sunday [0-6]
+        int     tm_yday;    /// days since January 1 [0-365]
+        int     tm_isdst;   /// Daylight Savings Time flag
+        c_long  tm_gmtoff;  /// offset from CUT in seconds
+        char*   tm_zone;    /// timezone abbreviation
+    }
+}
+
+version ( Posix )
+{
+    public import core.sys.posix.sys.types : time_t, clock_t;
+}
+else version ( Windows )
+{
+    ///
+    alias c_long time_t;
+    ///
+    alias c_long clock_t;
+}
+
+///
+version( Windows )
+{
+    enum clock_t CLOCKS_PER_SEC = 1000;
+}
+else version( OSX )
+{
+    enum clock_t CLOCKS_PER_SEC = 100;
+}
+else version( FreeBSD )
+{
+    enum clock_t CLOCKS_PER_SEC = 128;
+}
+else version (CRuntime_Glibc)
+{
+    enum clock_t CLOCKS_PER_SEC = 1_000_000;
+}
+else version (CRuntime_Bionic)
+{
+    enum clock_t CLOCKS_PER_SEC = 1_000_000;
+}
+
+///
+clock_t clock();
+///
+double  difftime(time_t time1, time_t time0);
+///
+time_t  mktime(tm* timeptr);
+///
+time_t  time(time_t* timer);
+///
+char*   asctime(in tm* timeptr);
+///
+char*   ctime(in time_t* timer);
+///
+tm*     gmtime(in time_t* timer);
+///
+tm*     localtime(in time_t* timer);
+///
+@system size_t  strftime(char* s, size_t maxsize, in char* format, in tm* timeptr);
+
+version( Windows )
+{
+    ///
+    void  tzset();                           // non-standard
+    ///
+    void  _tzset();                          // non-standard
+    ///
+    @system char* _strdate(char* s);                 // non-standard
+    ///
+    @system char* _strtime(char* s);                 // non-standard
+
+    ///
+    extern __gshared const(char)*[2] tzname; // non-standard
+}
+else version( OSX )
+{
+    ///
+    void tzset();                            // non-standard
+    ///
+    extern __gshared const(char)*[2] tzname; // non-standard
+}
+else version( CRuntime_Glibc )
+{
+    ///
+    void tzset();                            // non-standard
+    ///
+    extern __gshared const(char)*[2] tzname; // non-standard
+}
+else version( FreeBSD )
+{
+    ///
+    void tzset();                            // non-standard
+    ///
+    extern __gshared const(char)*[2] tzname; // non-standard
+}
+else version (Solaris)
+{
+    ///
+    void tzset();
+    ///
+    extern __gshared const(char)*[2] tzname;
+}
+else version( CRuntime_Bionic )
+{
+    ///
+    void tzset();
+    ///
+    extern __gshared const(char)*[2] tzname;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/stdc/wchar_.d b/libphobos/libdruntime/core/stdc/wchar_.d
new file mode 100644
index 00000000000..efdd1390ee1
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/wchar_.d
@@ -0,0 +1,236 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_wchar.h.html, _wchar.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_wchar_.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module core.stdc.wchar_;
+
+private import core.stdc.config;
+private import core.stdc.stdarg; // for va_list
+private import core.stdc.stdio;  // for FILE, not exposed per spec
+public import core.stdc.stddef;  // for wchar_t
+public import core.stdc.time;    // for tm
+public import core.stdc.stdint;  // for WCHAR_MIN, WCHAR_MAX
+
+extern (C):
+@system:
+nothrow:
+@nogc:
+
+version( CRuntime_Glibc )
+{
+    ///
+    struct mbstate_t
+    {
+        int __count;
+        union ___value
+        {
+            wint_t __wch;
+            char[4] __wchb;
+        }
+        ___value __value;
+    }
+}
+else
+{
+    ///
+    alias int mbstate_t;
+}
+
+///
+alias wchar_t wint_t;
+
+///
+enum wchar_t WEOF = 0xFFFF;
+
+///
+int fwprintf(FILE* stream, in wchar_t* format, ...);
+///
+int fwscanf(FILE* stream, in wchar_t* format, ...);
+int swscanf(in wchar_t* s, in wchar_t* format, ...);
+///
+int vfwprintf(FILE* stream, in wchar_t* format, va_list arg);
+///
+int vfwscanf(FILE* stream, in wchar_t* format, va_list arg);
+int vswscanf(in wchar_t* s, in wchar_t* format, va_list arg);
+///
+int vwprintf(in wchar_t* format, va_list arg);
+///
+int vwscanf(in wchar_t* format, va_list arg);
+///
+int wprintf(in wchar_t* format, ...);
+///
+int wscanf(in wchar_t* format, ...);
+
+/*
+ * Windows has 2 versions of swprintf and vswprintf.  MinGW defaults to the
+ * Microsoft signature.  Alias to match DMD/ANSI signature.
+ */
+version( MinGW )
+{
+    ///
+    int _snwprintf(wchar_t* s, size_t n, in wchar_t* format, ...);
+    alias _snwprintf swprintf;
+    ///
+    int _vsnwprintf(wchar_t* s, size_t n, in wchar_t* format, va_list arg);
+    alias _vsnwprintf vswprintf;	
+}
+else
+{
+    ///
+    int swprintf(wchar_t* s, size_t n, in wchar_t* format, ...);
+    ///
+    int vswprintf(wchar_t* s, size_t n, in wchar_t* format, va_list arg);
+}
+
+// No unsafe pointer manipulation.
+@trusted
+{
+    ///
+    wint_t fgetwc(FILE* stream);
+    ///
+    wint_t fputwc(wchar_t c, FILE* stream);
+}
+
+///
+wchar_t* fgetws(wchar_t* s, int n, FILE* stream);
+///
+int      fputws(in wchar_t* s, FILE* stream);
+
+// No unsafe pointer manipulation.
+extern (D) @trusted
+{
+    ///
+    wint_t getwchar()                     { return fgetwc(stdin);     }
+    ///
+    wint_t putwchar(wchar_t c)            { return fputwc(c,stdout);  }
+    ///
+    wint_t getwc(FILE* stream)            { return fgetwc(stream);    }
+    ///
+    wint_t putwc(wchar_t c, FILE* stream) { return fputwc(c, stream); }
+}
+
+// No unsafe pointer manipulation.
+@trusted
+{
+    ///
+    wint_t ungetwc(wint_t c, FILE* stream);
+    ///
+    version( CRuntime_Microsoft )
+    {
+        // MSVC defines this as an inline function.
+        int fwide(FILE* stream, int mode) { return mode; }
+    }
+    else
+    {
+        int    fwide(FILE* stream, int mode);
+    }
+}
+
+///
+double  wcstod(in wchar_t* nptr, wchar_t** endptr);
+///
+float   wcstof(in wchar_t* nptr, wchar_t** endptr);
+///
+real    wcstold(in wchar_t* nptr, wchar_t** endptr);
+///
+c_long  wcstol(in wchar_t* nptr, wchar_t** endptr, int base);
+///
+long    wcstoll(in wchar_t* nptr, wchar_t** endptr, int base);
+///
+c_ulong wcstoul(in wchar_t* nptr, wchar_t** endptr, int base);
+///
+ulong   wcstoull(in wchar_t* nptr, wchar_t** endptr, int base);
+
+///
+wchar_t* wcscpy(wchar_t* s1, in wchar_t* s2);
+///
+wchar_t* wcsncpy(wchar_t* s1, in wchar_t* s2, size_t n);
+///
+wchar_t* wcscat(wchar_t* s1, in wchar_t* s2);
+///
+wchar_t* wcsncat(wchar_t* s1, in wchar_t* s2, size_t n);
+///
+int      wcscmp(in wchar_t* s1, in wchar_t* s2);
+///
+int      wcscoll(in wchar_t* s1, in wchar_t* s2);
+///
+int      wcsncmp(in wchar_t* s1, in wchar_t* s2, size_t n);
+///
+size_t   wcsxfrm(wchar_t* s1, in wchar_t* s2, size_t n);
+///
+wchar_t* wcschr(in wchar_t* s, wchar_t c);
+///
+size_t   wcscspn(in wchar_t* s1, in wchar_t* s2);
+///
+wchar_t* wcspbrk(in wchar_t* s1, in wchar_t* s2);
+///
+wchar_t* wcsrchr(in wchar_t* s, wchar_t c);
+///
+size_t   wcsspn(in wchar_t* s1, in wchar_t* s2);
+///
+wchar_t* wcsstr(in wchar_t* s1, in wchar_t* s2);
+///
+wchar_t* wcstok(wchar_t* s1, in wchar_t* s2, wchar_t** ptr);
+///
+size_t   wcslen(in wchar_t* s);
+
+///
+wchar_t* wmemchr(in wchar_t* s, wchar_t c, size_t n);
+///
+int      wmemcmp(in wchar_t* s1, in wchar_t* s2, size_t n);
+///
+wchar_t* wmemcpy(wchar_t* s1, in wchar_t* s2, size_t n);
+///
+wchar_t* wmemmove(wchar_t*s1, in wchar_t* s2, size_t n);
+///
+wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);
+
+///
+size_t wcsftime(wchar_t* s, size_t maxsize, in wchar_t* format, in tm* timeptr);
+
+version( Windows )
+{
+    ///
+    wchar_t* _wasctime(tm*);      // non-standard
+    ///
+    wchar_t* _wctime(time_t*);    // non-standard
+    ///
+    wchar_t* _wstrdate(wchar_t*); // non-standard
+    ///
+    wchar_t* _wstrtime(wchar_t*); // non-standard
+}
+
+// No unsafe pointer manipulation.
+@trusted
+{
+    ///
+    wint_t btowc(int c);
+    ///
+    int    wctob(wint_t c);
+}
+
+///
+int    mbsinit(in mbstate_t* ps);
+///
+size_t mbrlen(in char* s, size_t n, mbstate_t* ps);
+///
+size_t mbrtowc(wchar_t* pwc, in char* s, size_t n, mbstate_t* ps);
+///
+size_t wcrtomb(char* s, wchar_t wc, mbstate_t* ps);
+///
+size_t mbsrtowcs(wchar_t* dst, in char** src, size_t len, mbstate_t* ps);
+///
+size_t wcsrtombs(char* dst, in wchar_t** src, size_t len, mbstate_t* ps);
diff --git a/libphobos/libdruntime/core/stdc/wctype.d b/libphobos/libdruntime/core/stdc/wctype.d
new file mode 100644
index 00000000000..b0c81079a7a
--- /dev/null
+++ b/libphobos/libdruntime/core/stdc/wctype.d
@@ -0,0 +1,65 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_wctype.h.html, _wctype.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/stdc/_wctype.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.stdc.wctype;
+
+public  import core.stdc.wchar_; // for wint_t, WEOF
+
+extern (C):
+@trusted: // Only a couple of functions below operate on unsafe C strings.
+nothrow:
+@nogc:
+
+///
+alias wchar_t wctrans_t;
+///
+alias wchar_t wctype_t;
+
+///
+pure int iswalnum(wint_t wc);
+///
+pure int iswalpha(wint_t wc);
+///
+pure int iswblank(wint_t wc);
+///
+pure int iswcntrl(wint_t wc);
+///
+pure int iswdigit(wint_t wc);
+///
+pure int iswgraph(wint_t wc);
+///
+pure int iswlower(wint_t wc);
+///
+pure int iswprint(wint_t wc);
+///
+pure int iswpunct(wint_t wc);
+///
+pure int iswspace(wint_t wc);
+///
+pure int iswupper(wint_t wc);
+///
+pure int iswxdigit(wint_t wc);
+
+///
+int       iswctype(wint_t wc, wctype_t desc);
+///
+@system wctype_t  wctype(in char* property);
+///
+pure wint_t    towlower(wint_t wc);
+///
+pure wint_t    towupper(wint_t wc);
+///
+wint_t    towctrans(wint_t wc, wctrans_t desc);
+///
+@system wctrans_t wctrans(in char* property);
diff --git a/libphobos/libdruntime/core/stdcpp/exception.d b/libphobos/libdruntime/core/stdcpp/exception.d
new file mode 100644
index 00000000000..2064fbc567f
--- /dev/null
+++ b/libphobos/libdruntime/core/stdcpp/exception.d
@@ -0,0 +1,106 @@
+// Written in the D programming language.
+
+/**
+ * Interface to C++ <exception>
+ *
+ * Copyright: Copyright (c) 2016 D Language Foundation
+ * License:   $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   $(WEB digitalmars.com, Walter Bright)
+ * Source:    $(DRUNTIMESRC core/stdcpp/_exception.d)
+ */
+
+module core.stdcpp.exception;
+
+version (CRuntime_DigitalMars)
+{
+    import core.stdcpp.typeinfo;
+
+    extern (C++, std)
+    {
+        alias void function() unexpected_handler;
+        unexpected_handler set_unexpected(unexpected_handler f) nothrow;
+        void unexpected();
+
+        alias void function() terminate_handler;
+        terminate_handler set_terminate(terminate_handler f) nothrow;
+        void terminate();
+
+        bool uncaught_exception();
+
+        class exception
+        {
+            this() nothrow { }
+            this(const exception) nothrow { }
+            //exception operator=(const exception) nothrow { return this; }
+            //virtual ~this() nothrow;
+            void dtor() { }
+            const(char)* what() const nothrow;
+        }
+
+        class bad_exception : exception
+        {
+            this() nothrow { }
+            this(const bad_exception) nothrow { }
+            //bad_exception operator=(const bad_exception) nothrow { return this; }
+            //virtual ~this() nothrow;
+            override const(char)* what() const nothrow;
+        }
+    }
+}
+else version (CRuntime_Glibc)
+{
+    extern (C++, std)
+    {
+        alias void function() unexpected_handler;
+        unexpected_handler set_unexpected(unexpected_handler f) nothrow;
+        void unexpected();
+
+        alias void function() terminate_handler;
+        terminate_handler set_terminate(terminate_handler f) nothrow;
+        void terminate();
+
+        void unexpected();
+        pure bool uncaught_exception();
+
+        class exception
+        {
+            this();
+            //virtual ~this();
+            void dtor1();
+            void dtor2();
+            const(char)* what() const;
+        }
+
+        class bad_exception : exception
+        {
+            this();
+            //virtual ~this();
+            const(char)* what() const;
+        }
+    }
+}
+else version (CRuntime_Microsoft)
+{
+    extern (C++, std)
+    {
+        class exception
+        {
+            this();
+            this(const exception);
+            //exception operator=(const exception) { return this; }
+            //virtual ~this();
+            void dtor() { }
+            const(char)* what() const;
+
+          private:
+            const(char)* mywhat;
+            bool dofree;
+        }
+
+        class bad_exception : exception
+        {
+            this(const(char)* msg = "bad exception");
+            //virtual ~this();
+        }
+    }
+}
diff --git a/libphobos/libdruntime/core/stdcpp/typeinfo.d b/libphobos/libdruntime/core/stdcpp/typeinfo.d
new file mode 100644
index 00000000000..de29e05cb57
--- /dev/null
+++ b/libphobos/libdruntime/core/stdcpp/typeinfo.d
@@ -0,0 +1,146 @@
+// Written in the D programming language.
+
+/**
+ * Interface to C++ <typeinfo>
+ *
+ * Copyright: Copyright (c) 2016 D Language Foundation
+ * License:   $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   $(WEB digitalmars.com, Walter Bright)
+ * Source:    $(DRUNTIMESRC core/stdcpp/_typeinfo.d)
+ */
+
+module core.stdcpp.typeinfo;
+
+version (CRuntime_DigitalMars)
+{
+    import core.stdcpp.exception;
+
+    extern (C++, std)
+    {
+        class type_info
+        {
+            void* pdata;
+
+          public:
+            //virtual ~this();
+            void dtor() { }     // reserve slot in vtbl[]
+
+            //bool operator==(const type_info rhs) const;
+            //bool operator!=(const type_info rhs) const;
+            final bool before(const type_info rhs) const;
+            final const(char)* name() const;
+          protected:
+            //type_info();
+          private:
+            //this(const type_info rhs);
+            //type_info operator=(const type_info rhs);
+        }
+
+        class bad_cast : core.stdcpp.exception.std.exception
+        {
+            this() nothrow { }
+            this(const bad_cast) nothrow { }
+            //bad_cast operator=(const bad_cast) nothrow { return this; }
+            //virtual ~this() nothrow;
+            override const(char)* what() const nothrow;
+        }
+
+        class bad_typeid : core.stdcpp.exception.std.exception
+        {
+            this() nothrow { }
+            this(const bad_typeid) nothrow { }
+            //bad_typeid operator=(const bad_typeid) nothrow { return this; }
+            //virtual ~this() nothrow;
+            override const (char)* what() const nothrow;
+        }
+    }
+}
+else version (CRuntime_Microsoft)
+{
+    import core.stdcpp.exception;
+
+    struct __type_info_node
+    {
+        void* _MemPtr;
+        __type_info_node* _Next;
+    }
+
+    extern __gshared __type_info_node __type_info_root_node;
+
+    extern (C++, std)
+    {
+        class type_info
+        {
+
+          public:
+            //virtual ~this();
+            void dtor() { }     // reserve slot in vtbl[]
+            //bool operator==(const type_info rhs) const;
+            //bool operator!=(const type_info rhs) const;
+            final bool before(const type_info rhs) const;
+            final const(char)* name(__type_info_node* p = &__type_info_root_node) const;
+
+          private:
+            void* pdata;
+            char[1] _name;
+            //this(const type_info rhs);
+            //type_info operator=(const type_info rhs);
+        }
+
+        class bad_cast : core.stdcpp.exception.std.exception
+        {
+            this(const(char)* msg = "bad cast") { }
+            this(const bad_cast) { }
+            //virtual ~this();
+        }
+
+        class bad_typeid : core.stdcpp.exception.std.exception
+        {
+            this(const(char)* msg = "bad typeid") { }
+            this(const bad_typeid) { }
+            //virtual ~this();
+        }
+    }
+}
+else version (CRuntime_Glibc)
+{
+    import core.stdcpp.exception;
+
+    extern (C++, __cxxabiv1)
+    {
+        class __class_type_info;
+    }
+
+    extern (C++, std)
+    {
+        class type_info
+        {
+            void dtor1();                           // consume destructor slot in vtbl[]
+            void dtor2();                           // consume destructor slot in vtbl[]
+            final const(char)* name();
+            final bool before(const type_info) const;
+            //bool operator==(const type_info) const;
+            bool __is_pointer_p() const;
+            bool __is_function_p() const;
+            bool __do_catch(const type_info, void**, uint) const;
+            bool __do_upcast(const __cxxabiv1.__class_type_info, void**) const;
+
+            const(char)* _name;
+            this(const(char)*);
+        }
+
+        class bad_cast : core.stdcpp.exception.std.exception
+        {
+            this();
+            //~this();
+            const(char)* what() const;
+        }
+
+        class bad_typeid : core.stdcpp.exception.std.exception
+        {
+            this();
+            //~this();
+            const(char)* what() const;
+        }
+    }
+}
diff --git a/libphobos/libdruntime/core/sync/barrier.d b/libphobos/libdruntime/core/sync/barrier.d
new file mode 100644
index 00000000000..5ef1975955e
--- /dev/null
+++ b/libphobos/libdruntime/core/sync/barrier.d
@@ -0,0 +1,151 @@
+/**
+ * The barrier module provides a primitive for synchronizing the progress of
+ * a group of threads.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/sync/_barrier.d)
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sync.barrier;
+
+
+public import core.sync.exception;
+private import core.sync.condition;
+private import core.sync.mutex;
+
+version( Posix )
+{
+    private import core.stdc.errno;
+    private import core.sys.posix.pthread;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Barrier
+//
+// void wait();
+////////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * This class represents a barrier across which threads may only travel in
+ * groups of a specific size.
+ */
+class Barrier
+{
+    ////////////////////////////////////////////////////////////////////////////
+    // Initialization
+    ////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Initializes a barrier object which releases threads in groups of limit
+     * in size.
+     *
+     * Params:
+     *  limit = The number of waiting threads to release in unison.
+     *
+     * Throws:
+     *  SyncError on error.
+     */
+    this( uint limit )
+    in
+    {
+        assert( limit > 0 );
+    }
+    body
+    {
+        m_lock  = new Mutex;
+        m_cond  = new Condition( m_lock );
+        m_group = 0;
+        m_limit = limit;
+        m_count = limit;
+    }
+
+
+    ////////////////////////////////////////////////////////////////////////////
+    // General Actions
+    ////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Wait for the pre-determined number of threads and then proceed.
+     *
+     * Throws:
+     *  SyncError on error.
+     */
+    void wait()
+    {
+        synchronized( m_lock )
+        {
+            uint group = m_group;
+
+            if( --m_count == 0 )
+            {
+                m_group++;
+                m_count = m_limit;
+                m_cond.notifyAll();
+            }
+            while( group == m_group )
+                m_cond.wait();
+        }
+    }
+
+
+private:
+    Mutex       m_lock;
+    Condition   m_cond;
+    uint        m_group;
+    uint        m_limit;
+    uint        m_count;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Unit Tests
+////////////////////////////////////////////////////////////////////////////////
+
+
+version( unittest )
+{
+    private import core.thread;
+
+
+    unittest
+    {
+        int  numThreads = 10;
+        auto barrier    = new Barrier( numThreads );
+        auto synInfo    = new Object;
+        int  numReady   = 0;
+        int  numPassed  = 0;
+
+        void threadFn()
+        {
+            synchronized( synInfo )
+            {
+                ++numReady;
+            }
+            barrier.wait();
+            synchronized( synInfo )
+            {
+                ++numPassed;
+            }
+        }
+
+        auto group = new ThreadGroup;
+
+        for( int i = 0; i < numThreads; ++i )
+        {
+            group.create( &threadFn );
+        }
+        group.joinAll();
+        assert( numReady == numThreads && numPassed == numThreads );
+    }
+}
diff --git a/libphobos/libdruntime/core/sync/condition.d b/libphobos/libdruntime/core/sync/condition.d
new file mode 100644
index 00000000000..aa0caa6f4ac
--- /dev/null
+++ b/libphobos/libdruntime/core/sync/condition.d
@@ -0,0 +1,606 @@
+/**
+ * The condition module provides a primitive for synchronized condition
+ * checking.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/sync/_condition.d)
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sync.condition;
+
+
+public import core.sync.exception;
+public import core.sync.mutex;
+public import core.time;
+
+version( Windows )
+{
+    private import core.sync.semaphore;
+    private import core.sys.windows.windows;
+}
+else version( Posix )
+{
+    private import core.sync.config;
+    private import core.stdc.errno;
+    private import core.sys.posix.pthread;
+    private import core.sys.posix.time;
+}
+else
+{
+    static assert(false, "Platform not supported");
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Condition
+//
+// void wait();
+// void notify();
+// void notifyAll();
+////////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * This class represents a condition variable as conceived by C.A.R. Hoare.  As
+ * per Mesa type monitors however, "signal" has been replaced with "notify" to
+ * indicate that control is not transferred to the waiter when a notification
+ * is sent.
+ */
+class Condition
+{
+    ////////////////////////////////////////////////////////////////////////////
+    // Initialization
+    ////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Initializes a condition object which is associated with the supplied
+     * mutex object.
+     *
+     * Params:
+     *  m = The mutex with which this condition will be associated.
+     *
+     * Throws:
+     *  SyncError on error.
+     */
+    this( Mutex m ) nothrow @safe
+    {
+        version( Windows )
+        {
+            m_blockLock = CreateSemaphoreA( null, 1, 1, null );
+            if( m_blockLock == m_blockLock.init )
+                throw new SyncError( "Unable to initialize condition" );
+            scope(failure) CloseHandle( m_blockLock );
+
+            m_blockQueue = CreateSemaphoreA( null, 0, int.max, null );
+            if( m_blockQueue == m_blockQueue.init )
+                throw new SyncError( "Unable to initialize condition" );
+            scope(failure) CloseHandle( m_blockQueue );
+
+            InitializeCriticalSection( &m_unblockLock );
+            m_assocMutex = m;
+        }
+        else version( Posix )
+        {
+            m_assocMutex = m;
+            int rc = pthread_cond_init( &m_hndl, null );
+            if( rc )
+                throw new SyncError( "Unable to initialize condition" );
+        }
+    }
+
+
+    ~this()
+    {
+        version( Windows )
+        {
+            BOOL rc = CloseHandle( m_blockLock );
+            assert( rc, "Unable to destroy condition" );
+            rc = CloseHandle( m_blockQueue );
+            assert( rc, "Unable to destroy condition" );
+            DeleteCriticalSection( &m_unblockLock );
+        }
+        else version( Posix )
+        {
+            int rc = pthread_cond_destroy( &m_hndl );
+            assert( !rc, "Unable to destroy condition" );
+        }
+    }
+
+
+    ////////////////////////////////////////////////////////////////////////////
+    // General Properties
+    ////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Gets the mutex associated with this condition.
+     *
+     * Returns:
+     *  The mutex associated with this condition.
+     */
+    @property Mutex mutex()
+    {
+        return m_assocMutex;
+    }
+
+    // undocumented function for internal use
+    final @property Mutex mutex_nothrow() pure nothrow @safe @nogc
+    {
+        return m_assocMutex;
+    }
+
+
+    ////////////////////////////////////////////////////////////////////////////
+    // General Actions
+    ////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Wait until notified.
+     *
+     * Throws:
+     *  SyncError on error.
+     */
+    void wait()
+    {
+        version( Windows )
+        {
+            timedWait( INFINITE );
+        }
+        else version( Posix )
+        {
+            int rc = pthread_cond_wait( &m_hndl, m_assocMutex.handleAddr() );
+            if( rc )
+                throw new SyncError( "Unable to wait for condition" );
+        }
+    }
+
+
+    /**
+     * Suspends the calling thread until a notification occurs or until the
+     * supplied time period has elapsed.
+     *
+     * Params:
+     *  val = The time to wait.
+     *
+     * In:
+     *  val must be non-negative.
+     *
+     * Throws:
+     *  SyncError on error.
+     *
+     * Returns:
+     *  true if notified before the timeout and false if not.
+     */
+    bool wait( Duration val )
+    in
+    {
+        assert( !val.isNegative );
+    }
+    body
+    {
+        version( Windows )
+        {
+            auto maxWaitMillis = dur!("msecs")( uint.max - 1 );
+
+            while( val > maxWaitMillis )
+            {
+                if( timedWait( cast(uint)
+                               maxWaitMillis.total!"msecs" ) )
+                    return true;
+                val -= maxWaitMillis;
+            }
+            return timedWait( cast(uint) val.total!"msecs" );
+        }
+        else version( Posix )
+        {
+            timespec t = void;
+            mktspec( t, val );
+
+            int rc = pthread_cond_timedwait( &m_hndl,
+                                             m_assocMutex.handleAddr(),
+                                             &t );
+            if( !rc )
+                return true;
+            if( rc == ETIMEDOUT )
+                return false;
+            throw new SyncError( "Unable to wait for condition" );
+        }
+    }
+
+
+    /**
+     * Notifies one waiter.
+     *
+     * Throws:
+     *  SyncError on error.
+     */
+    void notify()
+    {
+        version( Windows )
+        {
+            notify( false );
+        }
+        else version( Posix )
+        {
+            int rc = pthread_cond_signal( &m_hndl );
+            if( rc )
+                throw new SyncError( "Unable to notify condition" );
+        }
+    }
+
+
+    /**
+     * Notifies all waiters.
+     *
+     * Throws:
+     *  SyncError on error.
+     */
+    void notifyAll()
+    {
+        version( Windows )
+        {
+            notify( true );
+        }
+        else version( Posix )
+        {
+            int rc = pthread_cond_broadcast( &m_hndl );
+            if( rc )
+                throw new SyncError( "Unable to notify condition" );
+        }
+    }
+
+
+private:
+    version( Windows )
+    {
+        bool timedWait( DWORD timeout )
+        {
+            int   numSignalsLeft;
+            int   numWaitersGone;
+            DWORD rc;
+
+            rc = WaitForSingleObject( m_blockLock, INFINITE );
+            assert( rc == WAIT_OBJECT_0 );
+
+            m_numWaitersBlocked++;
+
+            rc = ReleaseSemaphore( m_blockLock, 1, null );
+            assert( rc );
+
+            m_assocMutex.unlock();
+            scope(failure) m_assocMutex.lock();
+
+            rc = WaitForSingleObject( m_blockQueue, timeout );
+            assert( rc == WAIT_OBJECT_0 || rc == WAIT_TIMEOUT );
+            bool timedOut = (rc == WAIT_TIMEOUT);
+
+            EnterCriticalSection( &m_unblockLock );
+            scope(failure) LeaveCriticalSection( &m_unblockLock );
+
+            if( (numSignalsLeft = m_numWaitersToUnblock) != 0 )
+            {
+                if ( timedOut )
+                {
+                    // timeout (or canceled)
+                    if( m_numWaitersBlocked != 0 )
+                    {
+                        m_numWaitersBlocked--;
+                        // do not unblock next waiter below (already unblocked)
+                        numSignalsLeft = 0;
+                    }
+                    else
+                    {
+                        // spurious wakeup pending!!
+                        m_numWaitersGone = 1;
+                    }
+                }
+                if( --m_numWaitersToUnblock == 0 )
+                {
+                    if( m_numWaitersBlocked != 0 )
+                    {
+                        // open the gate
+                        rc = ReleaseSemaphore( m_blockLock, 1, null );
+                        assert( rc );
+                        // do not open the gate below again
+                        numSignalsLeft = 0;
+                    }
+                    else if( (numWaitersGone = m_numWaitersGone) != 0 )
+                    {
+                        m_numWaitersGone = 0;
+                    }
+                }
+            }
+            else if( ++m_numWaitersGone == int.max / 2 )
+            {
+                // timeout/canceled or spurious event :-)
+                rc = WaitForSingleObject( m_blockLock, INFINITE );
+                assert( rc == WAIT_OBJECT_0 );
+                // something is going on here - test of timeouts?
+                m_numWaitersBlocked -= m_numWaitersGone;
+                rc = ReleaseSemaphore( m_blockLock, 1, null );
+                assert( rc == WAIT_OBJECT_0 );
+                m_numWaitersGone = 0;
+            }
+
+            LeaveCriticalSection( &m_unblockLock );
+
+            if( numSignalsLeft == 1 )
+            {
+                // better now than spurious later (same as ResetEvent)
+                for( ; numWaitersGone > 0; --numWaitersGone )
+                {
+                    rc = WaitForSingleObject( m_blockQueue, INFINITE );
+                    assert( rc == WAIT_OBJECT_0 );
+                }
+                // open the gate
+                rc = ReleaseSemaphore( m_blockLock, 1, null );
+                assert( rc );
+            }
+            else if( numSignalsLeft != 0 )
+            {
+                // unblock next waiter
+                rc = ReleaseSemaphore( m_blockQueue, 1, null );
+                assert( rc );
+            }
+            m_assocMutex.lock();
+            return !timedOut;
+        }
+
+
+        void notify( bool all )
+        {
+            DWORD rc;
+
+            EnterCriticalSection( &m_unblockLock );
+            scope(failure) LeaveCriticalSection( &m_unblockLock );
+
+            if( m_numWaitersToUnblock != 0 )
+            {
+                if( m_numWaitersBlocked == 0 )
+                {
+                    LeaveCriticalSection( &m_unblockLock );
+                    return;
+                }
+                if( all )
+                {
+                    m_numWaitersToUnblock += m_numWaitersBlocked;
+                    m_numWaitersBlocked = 0;
+                }
+                else
+                {
+                    m_numWaitersToUnblock++;
+                    m_numWaitersBlocked--;
+                }
+                LeaveCriticalSection( &m_unblockLock );
+            }
+            else if( m_numWaitersBlocked > m_numWaitersGone )
+            {
+                rc = WaitForSingleObject( m_blockLock, INFINITE );
+                assert( rc == WAIT_OBJECT_0 );
+                if( 0 != m_numWaitersGone )
+                {
+                    m_numWaitersBlocked -= m_numWaitersGone;
+                    m_numWaitersGone = 0;
+                }
+                if( all )
+                {
+                    m_numWaitersToUnblock = m_numWaitersBlocked;
+                    m_numWaitersBlocked = 0;
+                }
+                else
+                {
+                    m_numWaitersToUnblock = 1;
+                    m_numWaitersBlocked--;
+                }
+                LeaveCriticalSection( &m_unblockLock );
+                rc = ReleaseSemaphore( m_blockQueue, 1, null );
+                assert( rc );
+            }
+            else
+            {
+                LeaveCriticalSection( &m_unblockLock );
+            }
+        }
+
+
+        // NOTE: This implementation uses Algorithm 8c as described here:
+        //       http://groups.google.com/group/comp.programming.threads/
+        //              browse_frm/thread/1692bdec8040ba40/e7a5f9d40e86503a
+        HANDLE              m_blockLock;    // auto-reset event (now semaphore)
+        HANDLE              m_blockQueue;   // auto-reset event (now semaphore)
+        Mutex               m_assocMutex;   // external mutex/CS
+        CRITICAL_SECTION    m_unblockLock;  // internal mutex/CS
+        int                 m_numWaitersGone        = 0;
+        int                 m_numWaitersBlocked     = 0;
+        int                 m_numWaitersToUnblock   = 0;
+    }
+    else version( Posix )
+    {
+        Mutex               m_assocMutex;
+        pthread_cond_t      m_hndl;
+    }
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Unit Tests
+////////////////////////////////////////////////////////////////////////////////
+
+
+version( unittest )
+{
+    private import core.thread;
+    private import core.sync.mutex;
+    private import core.sync.semaphore;
+
+
+    void testNotify()
+    {
+        auto mutex      = new Mutex;
+        auto condReady  = new Condition( mutex );
+        auto semDone    = new Semaphore;
+        auto synLoop    = new Object;
+        int  numWaiters = 10;
+        int  numTries   = 10;
+        int  numReady   = 0;
+        int  numTotal   = 0;
+        int  numDone    = 0;
+        int  numPost    = 0;
+
+        void waiter()
+        {
+            for( int i = 0; i < numTries; ++i )
+            {
+                synchronized( mutex )
+                {
+                    while( numReady < 1 )
+                    {
+                        condReady.wait();
+                    }
+                    --numReady;
+                    ++numTotal;
+                }
+
+                synchronized( synLoop )
+                {
+                    ++numDone;
+                }
+                semDone.wait();
+            }
+        }
+
+        auto group = new ThreadGroup;
+
+        for( int i = 0; i < numWaiters; ++i )
+            group.create( &waiter );
+
+        for( int i = 0; i < numTries; ++i )
+        {
+            for( int j = 0; j < numWaiters; ++j )
+            {
+                synchronized( mutex )
+                {
+                    ++numReady;
+                    condReady.notify();
+                }
+            }
+            while( true )
+            {
+                synchronized( synLoop )
+                {
+                    if( numDone >= numWaiters )
+                        break;
+                }
+                Thread.yield();
+            }
+            for( int j = 0; j < numWaiters; ++j )
+            {
+                semDone.notify();
+            }
+        }
+
+        group.joinAll();
+        assert( numTotal == numWaiters * numTries );
+    }
+
+
+    void testNotifyAll()
+    {
+        auto mutex      = new Mutex;
+        auto condReady  = new Condition( mutex );
+        int  numWaiters = 10;
+        int  numReady   = 0;
+        int  numDone    = 0;
+        bool alert      = false;
+
+        void waiter()
+        {
+            synchronized( mutex )
+            {
+                ++numReady;
+                while( !alert )
+                    condReady.wait();
+                ++numDone;
+            }
+        }
+
+        auto group = new ThreadGroup;
+
+        for( int i = 0; i < numWaiters; ++i )
+            group.create( &waiter );
+
+        while( true )
+        {
+            synchronized( mutex )
+            {
+                if( numReady >= numWaiters )
+                {
+                    alert = true;
+                    condReady.notifyAll();
+                    break;
+                }
+            }
+            Thread.yield();
+        }
+        group.joinAll();
+        assert( numReady == numWaiters && numDone == numWaiters );
+    }
+
+
+    void testWaitTimeout()
+    {
+        auto mutex      = new Mutex;
+        auto condReady  = new Condition( mutex );
+        bool waiting    = false;
+        bool alertedOne = true;
+        bool alertedTwo = true;
+
+        void waiter()
+        {
+            synchronized( mutex )
+            {
+                waiting    = true;
+                // we never want to miss the notification (30s)
+                alertedOne = condReady.wait( dur!"seconds"(30) );
+                // but we don't want to wait long for the timeout (10ms)
+                alertedTwo = condReady.wait( dur!"msecs"(10) );
+            }
+        }
+
+        auto thread = new Thread( &waiter );
+        thread.start();
+
+        while( true )
+        {
+            synchronized( mutex )
+            {
+                if( waiting )
+                {
+                    condReady.notify();
+                    break;
+                }
+            }
+            Thread.yield();
+        }
+        thread.join();
+        assert( waiting );
+        assert( alertedOne );
+        assert( !alertedTwo );
+    }
+
+
+    unittest
+    {
+        testNotify();
+        testNotifyAll();
+        testWaitTimeout();
+    }
+}
diff --git a/libphobos/libdruntime/core/sync/config.d b/libphobos/libdruntime/core/sync/config.d
new file mode 100644
index 00000000000..19ba3d8d18c
--- /dev/null
+++ b/libphobos/libdruntime/core/sync/config.d
@@ -0,0 +1,68 @@
+/**
+ * The config module contains utility routines and configuration information
+ * specific to this package.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/sync/_config.d)
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sync.config;
+
+
+version( Posix )
+{
+    private import core.sys.posix.time;
+    private import core.sys.posix.sys.time;
+    private import core.time;
+
+
+    void mktspec( ref timespec t ) nothrow
+    {
+        static if( false && is( typeof( clock_gettime ) ) )
+        {
+            clock_gettime( CLOCK_REALTIME, &t );
+        }
+        else
+        {
+            timeval tv;
+
+            gettimeofday( &tv, null );
+            (cast(byte*) &t)[0 .. t.sizeof] = 0;
+            t.tv_sec  = cast(typeof(t.tv_sec))  tv.tv_sec;
+            t.tv_nsec = cast(typeof(t.tv_nsec)) tv.tv_usec * 1_000;
+        }
+    }
+
+
+    void mktspec( ref timespec t, Duration delta ) nothrow
+    {
+        mktspec( t );
+        mvtspec( t, delta );
+    }
+
+
+    void mvtspec( ref timespec t, Duration delta ) nothrow
+    {
+        auto val  = delta;
+             val += dur!"seconds"( t.tv_sec );
+             val += dur!"nsecs"( t.tv_nsec );
+
+        //auto val = delta + dur!"seconds"( t.tv_sec ) +
+        //                 + dur!"nsecs"( t.tv_nsec );
+
+        if( val.total!"seconds" > t.tv_sec.max )
+        {
+            t.tv_sec  = t.tv_sec.max;
+            t.tv_nsec = cast(typeof(t.tv_nsec)) val.split!("seconds", "nsecs")().nsecs;
+        }
+        else
+            val.split!("seconds", "nsecs")(t.tv_sec, t.tv_nsec);
+    }
+}
diff --git a/libphobos/libdruntime/core/sync/exception.d b/libphobos/libdruntime/core/sync/exception.d
new file mode 100644
index 00000000000..e6f4b17729d
--- /dev/null
+++ b/libphobos/libdruntime/core/sync/exception.d
@@ -0,0 +1,32 @@
+/**
+ * Define base class for synchronization exceptions.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/sync/_exception.d)
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sync.exception;
+
+
+/**
+ * Base class for synchronization errors.
+ */
+class SyncError : Error
+{
+    @safe pure nothrow this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null)
+    {
+        super(msg, file, line, next);
+    }
+
+    @safe pure nothrow this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__)
+    {
+        super(msg, file, line, next);
+    }
+}
diff --git a/libphobos/libdruntime/core/sync/mutex.d b/libphobos/libdruntime/core/sync/mutex.d
new file mode 100644
index 00000000000..bdedb099862
--- /dev/null
+++ b/libphobos/libdruntime/core/sync/mutex.d
@@ -0,0 +1,275 @@
+/**
+ * The mutex module provides a primitive for maintaining mutually exclusive
+ * access.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/sync/_mutex.d)
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sync.mutex;
+
+
+public import core.sync.exception;
+
+version( Windows )
+{
+    private import core.sys.windows.windows;
+}
+else version( Posix )
+{
+    private import core.sys.posix.pthread;
+}
+else
+{
+    static assert(false, "Platform not supported");
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Mutex
+//
+// void lock();
+// void unlock();
+// bool tryLock();
+////////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * This class represents a general purpose, recursive mutex.
+ */
+class Mutex :
+    Object.Monitor
+{
+    ////////////////////////////////////////////////////////////////////////////
+    // Initialization
+    ////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Initializes a mutex object.
+     *
+     * Throws:
+     *  SyncError on error.
+     */
+    this() nothrow @trusted
+    {
+        version( Windows )
+        {
+            InitializeCriticalSection( &m_hndl );
+        }
+        else version( Posix )
+        {
+            pthread_mutexattr_t attr = void;
+
+            if( pthread_mutexattr_init( &attr ) )
+                throw new SyncError( "Unable to initialize mutex" );
+            scope(exit) pthread_mutexattr_destroy( &attr );
+
+            if( pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE ) )
+                throw new SyncError( "Unable to initialize mutex" );
+
+            if( pthread_mutex_init( &m_hndl, &attr ) )
+                throw new SyncError( "Unable to initialize mutex" );
+        }
+        m_proxy.link = this;
+        this.__monitor = &m_proxy;
+    }
+
+
+    /**
+     * Initializes a mutex object and sets it as the monitor for o.
+     *
+     * In:
+     *  o must not already have a monitor.
+     */
+    this( Object o ) nothrow @trusted
+    in
+    {
+        assert( o.__monitor is null );
+    }
+    body
+    {
+        this();
+        o.__monitor = &m_proxy;
+    }
+
+
+    ~this()
+    {
+        version( Windows )
+        {
+            DeleteCriticalSection( &m_hndl );
+        }
+        else version( Posix )
+        {
+            int rc = pthread_mutex_destroy( &m_hndl );
+            assert( !rc, "Unable to destroy mutex" );
+        }
+        this.__monitor = null;
+    }
+
+
+    ////////////////////////////////////////////////////////////////////////////
+    // General Actions
+    ////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * If this lock is not already held by the caller, the lock is acquired,
+     * then the internal counter is incremented by one.
+     *
+     * Throws:
+     *  SyncError on error.
+     */
+    @trusted void lock()
+    {
+        lock_nothrow();
+    }
+
+    // undocumented function for internal use
+    final void lock_nothrow() nothrow @trusted @nogc
+    {
+        version( Windows )
+        {
+            EnterCriticalSection( &m_hndl );
+        }
+        else version( Posix )
+        {
+            int rc = pthread_mutex_lock( &m_hndl );
+            if( rc )
+            {
+                SyncError syncErr = cast(SyncError) cast(void*) typeid(SyncError).initializer;
+                syncErr.msg = "Unable to lock mutex.";
+                throw syncErr;
+            }
+        }
+    }
+
+    /**
+     * Decrements the internal lock count by one.  If this brings the count to
+     * zero, the lock is released.
+     *
+     * Throws:
+     *  SyncError on error.
+     */
+    @trusted void unlock()
+    {
+        unlock_nothrow();
+    }
+
+    // undocumented function for internal use
+    final void unlock_nothrow() nothrow @trusted @nogc
+    {
+        version( Windows )
+        {
+            LeaveCriticalSection( &m_hndl );
+        }
+        else version( Posix )
+        {
+            int rc = pthread_mutex_unlock( &m_hndl );
+            if( rc )
+            {
+                SyncError syncErr = cast(SyncError) cast(void*) typeid(SyncError).initializer;
+                syncErr.msg = "Unable to unlock mutex.";
+                throw syncErr;
+            }
+        }
+    }
+
+    /**
+     * If the lock is held by another caller, the method returns.  Otherwise,
+     * the lock is acquired if it is not already held, and then the internal
+     * counter is incremented by one.
+     *
+     * Throws:
+     *  SyncError on error.
+     *
+     * Returns:
+     *  true if the lock was acquired and false if not.
+     */
+    bool tryLock()
+    {
+        version( Windows )
+        {
+            return TryEnterCriticalSection( &m_hndl ) != 0;
+        }
+        else version( Posix )
+        {
+            return pthread_mutex_trylock( &m_hndl ) == 0;
+        }
+    }
+
+
+private:
+    version( Windows )
+    {
+        CRITICAL_SECTION    m_hndl;
+    }
+    else version( Posix )
+    {
+        pthread_mutex_t     m_hndl;
+    }
+
+    struct MonitorProxy
+    {
+        Object.Monitor link;
+    }
+
+    MonitorProxy            m_proxy;
+
+
+package:
+    version( Posix )
+    {
+        pthread_mutex_t* handleAddr()
+        {
+            return &m_hndl;
+        }
+    }
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Unit Tests
+////////////////////////////////////////////////////////////////////////////////
+
+
+version( unittest )
+{
+    private import core.thread;
+
+
+    unittest
+    {
+        auto mutex      = new Mutex;
+        int  numThreads = 10;
+        int  numTries   = 1000;
+        int  lockCount  = 0;
+
+        void testFn()
+        {
+            for( int i = 0; i < numTries; ++i )
+            {
+                synchronized( mutex )
+                {
+                    ++lockCount;
+                }
+            }
+        }
+
+        auto group = new ThreadGroup;
+
+        for( int i = 0; i < numThreads; ++i )
+            group.create( &testFn );
+
+        group.joinAll();
+        assert( lockCount == numThreads * numTries );
+    }
+}
diff --git a/libphobos/libdruntime/core/sync/rwmutex.d b/libphobos/libdruntime/core/sync/rwmutex.d
new file mode 100644
index 00000000000..3de5e404539
--- /dev/null
+++ b/libphobos/libdruntime/core/sync/rwmutex.d
@@ -0,0 +1,528 @@
+/**
+ * The read/write mutex module provides a primitive for maintaining shared read
+ * access and mutually exclusive write access.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/sync/_rwmutex.d)
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sync.rwmutex;
+
+
+public import core.sync.exception;
+private import core.sync.condition;
+private import core.sync.mutex;
+private import core.memory;
+
+version( Posix )
+{
+    private import core.sys.posix.pthread;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// ReadWriteMutex
+//
+// Reader reader();
+// Writer writer();
+////////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * This class represents a mutex that allows any number of readers to enter,
+ * but when a writer enters, all other readers and writers are blocked.
+ *
+ * Please note that this mutex is not recursive and is intended to guard access
+ * to data only.  Also, no deadlock checking is in place because doing so would
+ * require dynamic memory allocation, which would reduce performance by an
+ * unacceptable amount.  As a result, any attempt to recursively acquire this
+ * mutex may well deadlock the caller, particularly if a write lock is acquired
+ * while holding a read lock, or vice-versa.  In practice, this should not be
+ * an issue however, because it is uncommon to call deeply into unknown code
+ * while holding a lock that simply protects data.
+ */
+class ReadWriteMutex
+{
+    /**
+     * Defines the policy used by this mutex.  Currently, two policies are
+     * defined.
+     *
+     * The first will queue writers until no readers hold the mutex, then
+     * pass the writers through one at a time.  If a reader acquires the mutex
+     * while there are still writers queued, the reader will take precedence.
+     *
+     * The second will queue readers if there are any writers queued.  Writers
+     * are passed through one at a time, and once there are no writers present,
+     * all queued readers will be alerted.
+     *
+     * Future policies may offer a more even balance between reader and writer
+     * precedence.
+     */
+    enum Policy
+    {
+        PREFER_READERS, /// Readers get preference.  This may starve writers.
+        PREFER_WRITERS  /// Writers get preference.  This may starve readers.
+    }
+
+
+    ////////////////////////////////////////////////////////////////////////////
+    // Initialization
+    ////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Initializes a read/write mutex object with the supplied policy.
+     *
+     * Params:
+     *  policy = The policy to use.
+     *
+     * Throws:
+     *  SyncError on error.
+     */
+    this( Policy policy = Policy.PREFER_WRITERS )
+    {
+        m_commonMutex = new Mutex;
+        if( !m_commonMutex )
+            throw new SyncError( "Unable to initialize mutex" );
+
+        m_readerQueue = new Condition( m_commonMutex );
+        if( !m_readerQueue )
+            throw new SyncError( "Unable to initialize mutex" );
+
+        m_writerQueue = new Condition( m_commonMutex );
+        if( !m_writerQueue )
+            throw new SyncError( "Unable to initialize mutex" );
+
+        m_policy = policy;
+        m_reader = new Reader;
+        m_writer = new Writer;
+    }
+
+    ////////////////////////////////////////////////////////////////////////////
+    // General Properties
+    ////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Gets the policy used by this mutex.
+     *
+     * Returns:
+     *  The policy used by this mutex.
+     */
+    @property Policy policy()
+    {
+        return m_policy;
+    }
+
+
+    ////////////////////////////////////////////////////////////////////////////
+    // Reader/Writer Handles
+    ////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Gets an object representing the reader lock for the associated mutex.
+     *
+     * Returns:
+     *  A reader sub-mutex.
+     */
+    @property Reader reader()
+    {
+        return m_reader;
+    }
+
+
+    /**
+     * Gets an object representing the writer lock for the associated mutex.
+     *
+     * Returns:
+     *  A writer sub-mutex.
+     */
+    @property Writer writer()
+    {
+        return m_writer;
+    }
+
+
+    ////////////////////////////////////////////////////////////////////////////
+    // Reader
+    ////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * This class can be considered a mutex in its own right, and is used to
+     * negotiate a read lock for the enclosing mutex.
+     */
+    class Reader :
+        Object.Monitor
+    {
+        /**
+         * Initializes a read/write mutex reader proxy object.
+         */
+        this()
+        {
+            m_proxy.link = this;
+            this.__monitor = &m_proxy;
+        }
+
+
+        /**
+         * Acquires a read lock on the enclosing mutex.
+         */
+        @trusted void lock()
+        {
+            synchronized( m_commonMutex )
+            {
+                ++m_numQueuedReaders;
+                scope(exit) --m_numQueuedReaders;
+
+                while( shouldQueueReader )
+                    m_readerQueue.wait();
+                ++m_numActiveReaders;
+            }
+        }
+
+
+        /**
+         * Releases a read lock on the enclosing mutex.
+         */
+        @trusted void unlock()
+        {
+            synchronized( m_commonMutex )
+            {
+                if( --m_numActiveReaders < 1 )
+                {
+                    if( m_numQueuedWriters > 0 )
+                        m_writerQueue.notify();
+                }
+            }
+        }
+
+
+        /**
+         * Attempts to acquire a read lock on the enclosing mutex.  If one can
+         * be obtained without blocking, the lock is acquired and true is
+         * returned.  If not, the lock is not acquired and false is returned.
+         *
+         * Returns:
+         *  true if the lock was acquired and false if not.
+         */
+        bool tryLock()
+        {
+            synchronized( m_commonMutex )
+            {
+                if( shouldQueueReader )
+                    return false;
+                ++m_numActiveReaders;
+                return true;
+            }
+        }
+
+
+    private:
+        @property bool shouldQueueReader()
+        {
+            if( m_numActiveWriters > 0 )
+                return true;
+
+            switch( m_policy )
+            {
+            case Policy.PREFER_WRITERS:
+                 return m_numQueuedWriters > 0;
+
+            case Policy.PREFER_READERS:
+            default:
+                 break;
+            }
+
+        return false;
+        }
+
+        struct MonitorProxy
+        {
+            Object.Monitor link;
+        }
+
+        MonitorProxy    m_proxy;
+    }
+
+
+    ////////////////////////////////////////////////////////////////////////////
+    // Writer
+    ////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * This class can be considered a mutex in its own right, and is used to
+     * negotiate a write lock for the enclosing mutex.
+     */
+    class Writer :
+        Object.Monitor
+    {
+        /**
+         * Initializes a read/write mutex writer proxy object.
+         */
+        this()
+        {
+            m_proxy.link = this;
+            this.__monitor = &m_proxy;
+        }
+
+
+        /**
+         * Acquires a write lock on the enclosing mutex.
+         */
+        @trusted void lock()
+        {
+            synchronized( m_commonMutex )
+            {
+                ++m_numQueuedWriters;
+                scope(exit) --m_numQueuedWriters;
+
+                while( shouldQueueWriter )
+                    m_writerQueue.wait();
+                ++m_numActiveWriters;
+            }
+        }
+
+
+        /**
+         * Releases a write lock on the enclosing mutex.
+         */
+        @trusted void unlock()
+        {
+            synchronized( m_commonMutex )
+            {
+                if( --m_numActiveWriters < 1 )
+                {
+                    switch( m_policy )
+                    {
+                    default:
+                    case Policy.PREFER_READERS:
+                        if( m_numQueuedReaders > 0 )
+                            m_readerQueue.notifyAll();
+                        else if( m_numQueuedWriters > 0 )
+                            m_writerQueue.notify();
+                        break;
+                    case Policy.PREFER_WRITERS:
+                        if( m_numQueuedWriters > 0 )
+                            m_writerQueue.notify();
+                        else if( m_numQueuedReaders > 0 )
+                            m_readerQueue.notifyAll();
+                    }
+                }
+            }
+        }
+
+
+        /**
+         * Attempts to acquire a write lock on the enclosing mutex.  If one can
+         * be obtained without blocking, the lock is acquired and true is
+         * returned.  If not, the lock is not acquired and false is returned.
+         *
+         * Returns:
+         *  true if the lock was acquired and false if not.
+         */
+        bool tryLock()
+        {
+            synchronized( m_commonMutex )
+            {
+                if( shouldQueueWriter )
+                    return false;
+                ++m_numActiveWriters;
+                return true;
+            }
+        }
+
+
+    private:
+        @property bool shouldQueueWriter()
+        {
+            if( m_numActiveWriters > 0 ||
+                m_numActiveReaders > 0 )
+                return true;
+            switch( m_policy )
+            {
+            case Policy.PREFER_READERS:
+                return m_numQueuedReaders > 0;
+
+            case Policy.PREFER_WRITERS:
+            default:
+                 break;
+            }
+
+        return false;
+        }
+
+        struct MonitorProxy
+        {
+            Object.Monitor link;
+        }
+
+        MonitorProxy    m_proxy;
+    }
+
+
+private:
+    Policy      m_policy;
+    Reader      m_reader;
+    Writer      m_writer;
+
+    Mutex       m_commonMutex;
+    Condition   m_readerQueue;
+    Condition   m_writerQueue;
+
+    int         m_numQueuedReaders;
+    int         m_numActiveReaders;
+    int         m_numQueuedWriters;
+    int         m_numActiveWriters;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Unit Tests
+////////////////////////////////////////////////////////////////////////////////
+
+
+unittest
+{
+    import core.atomic, core.thread, core.sync.semaphore;
+
+    static void runTest(ReadWriteMutex.Policy policy)
+    {
+        scope mutex = new ReadWriteMutex(policy);
+        scope rdSemA = new Semaphore, rdSemB = new Semaphore,
+              wrSemA = new Semaphore, wrSemB = new Semaphore;
+        shared size_t numReaders, numWriters;
+
+        void readerFn()
+        {
+            synchronized (mutex.reader)
+            {
+                atomicOp!"+="(numReaders, 1);
+                rdSemA.notify();
+                rdSemB.wait();
+                atomicOp!"-="(numReaders, 1);
+            }
+        }
+
+        void writerFn()
+        {
+            synchronized (mutex.writer)
+            {
+                atomicOp!"+="(numWriters, 1);
+                wrSemA.notify();
+                wrSemB.wait();
+                atomicOp!"-="(numWriters, 1);
+            }
+        }
+
+        void waitQueued(size_t queuedReaders, size_t queuedWriters)
+        {
+            for (;;)
+            {
+                synchronized (mutex.m_commonMutex)
+                {
+                    if (mutex.m_numQueuedReaders == queuedReaders &&
+                        mutex.m_numQueuedWriters == queuedWriters)
+                        break;
+                }
+                Thread.yield();
+            }
+        }
+
+        scope group = new ThreadGroup;
+
+        // 2 simultaneous readers
+        group.create(&readerFn); group.create(&readerFn);
+        rdSemA.wait(); rdSemA.wait();
+        assert(numReaders == 2);
+        rdSemB.notify(); rdSemB.notify();
+        group.joinAll();
+        assert(numReaders == 0);
+        foreach (t; group) group.remove(t);
+
+        // 1 writer at a time
+        group.create(&writerFn); group.create(&writerFn);
+        wrSemA.wait();
+        assert(!wrSemA.tryWait());
+        assert(numWriters == 1);
+        wrSemB.notify();
+        wrSemA.wait();
+        assert(numWriters == 1);
+        wrSemB.notify();
+        group.joinAll();
+        assert(numWriters == 0);
+        foreach (t; group) group.remove(t);
+
+        // reader and writer are mutually exclusive
+        group.create(&readerFn);
+        rdSemA.wait();
+        group.create(&writerFn);
+        waitQueued(0, 1);
+        assert(!wrSemA.tryWait());
+        assert(numReaders == 1 && numWriters == 0);
+        rdSemB.notify();
+        wrSemA.wait();
+        assert(numReaders == 0 && numWriters == 1);
+        wrSemB.notify();
+        group.joinAll();
+        assert(numReaders == 0 && numWriters == 0);
+        foreach (t; group) group.remove(t);
+
+        // writer and reader are mutually exclusive
+        group.create(&writerFn);
+        wrSemA.wait();
+        group.create(&readerFn);
+        waitQueued(1, 0);
+        assert(!rdSemA.tryWait());
+        assert(numReaders == 0 && numWriters == 1);
+        wrSemB.notify();
+        rdSemA.wait();
+        assert(numReaders == 1 && numWriters == 0);
+        rdSemB.notify();
+        group.joinAll();
+        assert(numReaders == 0 && numWriters == 0);
+        foreach (t; group) group.remove(t);
+
+        // policy determines whether queued reader or writers progress first
+        group.create(&writerFn);
+        wrSemA.wait();
+        group.create(&readerFn);
+        group.create(&writerFn);
+        waitQueued(1, 1);
+        assert(numReaders == 0 && numWriters == 1);
+        wrSemB.notify();
+
+        if (policy == ReadWriteMutex.Policy.PREFER_READERS)
+        {
+            rdSemA.wait();
+            assert(numReaders == 1 && numWriters == 0);
+            rdSemB.notify();
+            wrSemA.wait();
+            assert(numReaders == 0 && numWriters == 1);
+            wrSemB.notify();
+        }
+        else if (policy == ReadWriteMutex.Policy.PREFER_WRITERS)
+        {
+            wrSemA.wait();
+            assert(numReaders == 0 && numWriters == 1);
+            wrSemB.notify();
+            rdSemA.wait();
+            assert(numReaders == 1 && numWriters == 0);
+            rdSemB.notify();
+        }
+        group.joinAll();
+        assert(numReaders == 0 && numWriters == 0);
+        foreach (t; group) group.remove(t);
+    }
+    runTest(ReadWriteMutex.Policy.PREFER_READERS);
+    runTest(ReadWriteMutex.Policy.PREFER_WRITERS);
+}
diff --git a/libphobos/libdruntime/core/sync/semaphore.d b/libphobos/libdruntime/core/sync/semaphore.d
new file mode 100644
index 00000000000..a73f46a3fab
--- /dev/null
+++ b/libphobos/libdruntime/core/sync/semaphore.d
@@ -0,0 +1,445 @@
+/**
+ * The semaphore module provides a general use semaphore for synchronization.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Sean Kelly
+ * Source:    $(DRUNTIMESRC core/sync/_semaphore.d)
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sync.semaphore;
+
+
+public import core.sync.exception;
+public import core.time;
+
+version( Windows )
+{
+    private import core.sys.windows.windows;
+}
+else version( OSX )
+{
+    private import core.sync.config;
+    private import core.stdc.errno;
+    private import core.sys.posix.time;
+    private import core.sys.osx.mach.semaphore;
+}
+else version( Posix )
+{
+    private import core.sync.config;
+    private import core.stdc.errno;
+    private import core.sys.posix.pthread;
+    private import core.sys.posix.semaphore;
+}
+else
+{
+    static assert(false, "Platform not supported");
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Semaphore
+//
+// void wait();
+// void notify();
+// bool tryWait();
+////////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * This class represents a general counting semaphore as concieved by Edsger
+ * Dijkstra.  As per Mesa type monitors however, "signal" has been replaced
+ * with "notify" to indicate that control is not transferred to the waiter when
+ * a notification is sent.
+ */
+class Semaphore
+{
+    ////////////////////////////////////////////////////////////////////////////
+    // Initialization
+    ////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Initializes a semaphore object with the specified initial count.
+     *
+     * Params:
+     *  count = The initial count for the semaphore.
+     *
+     * Throws:
+     *  SyncError on error.
+     */
+    this( uint count = 0 )
+    {
+        version( Windows )
+        {
+            m_hndl = CreateSemaphoreA( null, count, int.max, null );
+            if( m_hndl == m_hndl.init )
+                throw new SyncError( "Unable to create semaphore" );
+        }
+        else version( OSX )
+        {
+            auto rc = semaphore_create( mach_task_self(), &m_hndl, SYNC_POLICY_FIFO, count );
+            if( rc )
+                throw new SyncError( "Unable to create semaphore" );
+        }
+        else version( Posix )
+        {
+            int rc = sem_init( &m_hndl, 0, count );
+            if( rc )
+                throw new SyncError( "Unable to create semaphore" );
+        }
+    }
+
+
+    ~this()
+    {
+        version( Windows )
+        {
+            BOOL rc = CloseHandle( m_hndl );
+            assert( rc, "Unable to destroy semaphore" );
+        }
+        else version( OSX )
+        {
+            auto rc = semaphore_destroy( mach_task_self(), m_hndl );
+            assert( !rc, "Unable to destroy semaphore" );
+        }
+        else version( Posix )
+        {
+            int rc = sem_destroy( &m_hndl );
+            assert( !rc, "Unable to destroy semaphore" );
+        }
+    }
+
+
+    ////////////////////////////////////////////////////////////////////////////
+    // General Actions
+    ////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Wait until the current count is above zero, then atomically decrement
+     * the count by one and return.
+     *
+     * Throws:
+     *  SyncError on error.
+     */
+    void wait()
+    {
+        version( Windows )
+        {
+            DWORD rc = WaitForSingleObject( m_hndl, INFINITE );
+            if( rc != WAIT_OBJECT_0 )
+                throw new SyncError( "Unable to wait for semaphore" );
+        }
+        else version( OSX )
+        {
+            while( true )
+            {
+                auto rc = semaphore_wait( m_hndl );
+                if( !rc )
+                    return;
+                if( rc == KERN_ABORTED && errno == EINTR )
+                    continue;
+                throw new SyncError( "Unable to wait for semaphore" );
+            }
+        }
+        else version( Posix )
+        {
+            while( true )
+            {
+                if( !sem_wait( &m_hndl ) )
+                    return;
+                if( errno != EINTR )
+                    throw new SyncError( "Unable to wait for semaphore" );
+            }
+        }
+    }
+
+
+    /**
+     * Suspends the calling thread until the current count moves above zero or
+     * until the supplied time period has elapsed.  If the count moves above
+     * zero in this interval, then atomically decrement the count by one and
+     * return true.  Otherwise, return false.
+     *
+     * Params:
+     *  period = The time to wait.
+     *
+     * In:
+     *  period must be non-negative.
+     *
+     * Throws:
+     *  SyncError on error.
+     *
+     * Returns:
+     *  true if notified before the timeout and false if not.
+     */
+    bool wait( Duration period )
+    in
+    {
+        assert( !period.isNegative );
+    }
+    body
+    {
+        version( Windows )
+        {
+            auto maxWaitMillis = dur!("msecs")( uint.max - 1 );
+
+            while( period > maxWaitMillis )
+            {
+                auto rc = WaitForSingleObject( m_hndl, cast(uint)
+                                                       maxWaitMillis.total!"msecs" );
+                switch( rc )
+                {
+                case WAIT_OBJECT_0:
+                    return true;
+                case WAIT_TIMEOUT:
+                    period -= maxWaitMillis;
+                    continue;
+                default:
+                    throw new SyncError( "Unable to wait for semaphore" );
+                }
+            }
+            switch( WaitForSingleObject( m_hndl, cast(uint) period.total!"msecs" ) )
+            {
+            case WAIT_OBJECT_0:
+                return true;
+            case WAIT_TIMEOUT:
+                return false;
+            default:
+                throw new SyncError( "Unable to wait for semaphore" );
+            }
+        }
+        else version( OSX )
+        {
+            mach_timespec_t t = void;
+            (cast(byte*) &t)[0 .. t.sizeof] = 0;
+
+            if( period.total!"seconds" > t.tv_sec.max )
+            {
+                t.tv_sec  = t.tv_sec.max;
+                t.tv_nsec = cast(typeof(t.tv_nsec)) period.split!("seconds", "nsecs")().nsecs;
+            }
+            else
+                period.split!("seconds", "nsecs")(t.tv_sec, t.tv_nsec);
+            while( true )
+            {
+                auto rc = semaphore_timedwait( m_hndl, t );
+                if( !rc )
+                    return true;
+                if( rc == KERN_OPERATION_TIMED_OUT )
+                    return false;
+                if( rc != KERN_ABORTED || errno != EINTR )
+                    throw new SyncError( "Unable to wait for semaphore" );
+            }
+        }
+        else version( Posix )
+        {
+            timespec t = void;
+            mktspec( t, period );
+
+            while( true )
+            {
+                if( !sem_timedwait( &m_hndl, &t ) )
+                    return true;
+                if( errno == ETIMEDOUT )
+                    return false;
+                if( errno != EINTR )
+                    throw new SyncError( "Unable to wait for semaphore" );
+            }
+        }
+    }
+
+
+    /**
+     * Atomically increment the current count by one.  This will notify one
+     * waiter, if there are any in the queue.
+     *
+     * Throws:
+     *  SyncError on error.
+     */
+    void notify()
+    {
+        version( Windows )
+        {
+            if( !ReleaseSemaphore( m_hndl, 1, null ) )
+                throw new SyncError( "Unable to notify semaphore" );
+        }
+        else version( OSX )
+        {
+            auto rc = semaphore_signal( m_hndl );
+            if( rc )
+                throw new SyncError( "Unable to notify semaphore" );
+        }
+        else version( Posix )
+        {
+            int rc = sem_post( &m_hndl );
+            if( rc )
+                throw new SyncError( "Unable to notify semaphore" );
+        }
+    }
+
+
+    /**
+     * If the current count is equal to zero, return.  Otherwise, atomically
+     * decrement the count by one and return true.
+     *
+     * Throws:
+     *  SyncError on error.
+     *
+     * Returns:
+     *  true if the count was above zero and false if not.
+     */
+    bool tryWait()
+    {
+        version( Windows )
+        {
+            switch( WaitForSingleObject( m_hndl, 0 ) )
+            {
+            case WAIT_OBJECT_0:
+                return true;
+            case WAIT_TIMEOUT:
+                return false;
+            default:
+                throw new SyncError( "Unable to wait for semaphore" );
+            }
+        }
+        else version( OSX )
+        {
+            return wait( dur!"hnsecs"(0) );
+        }
+        else version( Posix )
+        {
+            while( true )
+            {
+                if( !sem_trywait( &m_hndl ) )
+                    return true;
+                if( errno == EAGAIN )
+                    return false;
+                if( errno != EINTR )
+                    throw new SyncError( "Unable to wait for semaphore" );
+            }
+        }
+    }
+
+
+private:
+    version( Windows )
+    {
+        HANDLE  m_hndl;
+    }
+    else version( OSX )
+    {
+        semaphore_t m_hndl;
+    }
+    else version( Posix )
+    {
+        sem_t   m_hndl;
+    }
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Unit Tests
+////////////////////////////////////////////////////////////////////////////////
+
+
+version( unittest )
+{
+    import core.thread, core.atomic;
+
+    void testWait()
+    {
+        auto semaphore = new Semaphore;
+        shared bool stopConsumption = false;
+        immutable numToProduce = 20;
+        immutable numConsumers = 10;
+        shared size_t numConsumed;
+        shared size_t numComplete;
+
+        void consumer()
+        {
+            while (true)
+            {
+                semaphore.wait();
+
+                if (atomicLoad(stopConsumption))
+                    break;
+                atomicOp!"+="(numConsumed, 1);
+            }
+            atomicOp!"+="(numComplete, 1);
+        }
+
+        void producer()
+        {
+            assert(!semaphore.tryWait());
+
+            foreach (_; 0 .. numToProduce)
+                semaphore.notify();
+
+            // wait until all items are consumed
+            while (atomicLoad(numConsumed) != numToProduce)
+                Thread.yield();
+
+            // mark consumption as finished
+            atomicStore(stopConsumption, true);
+
+            // wake all consumers
+            foreach (_; 0 .. numConsumers)
+                semaphore.notify();
+
+            // wait until all consumers completed
+            while (atomicLoad(numComplete) != numConsumers)
+                Thread.yield();
+
+            assert(!semaphore.tryWait());
+            semaphore.notify();
+            assert(semaphore.tryWait());
+            assert(!semaphore.tryWait());
+        }
+
+        auto group = new ThreadGroup;
+
+        for( int i = 0; i < numConsumers; ++i )
+            group.create(&consumer);
+        group.create(&producer);
+        group.joinAll();
+    }
+
+
+    void testWaitTimeout()
+    {
+        auto sem = new Semaphore;
+        shared bool semReady;
+        bool alertedOne, alertedTwo;
+
+        void waiter()
+        {
+            while (!atomicLoad(semReady))
+                Thread.yield();
+            alertedOne = sem.wait(dur!"msecs"(1));
+            alertedTwo = sem.wait(dur!"msecs"(1));
+            assert(alertedOne && !alertedTwo);
+        }
+
+        auto thread = new Thread(&waiter);
+        thread.start();
+
+        sem.notify();
+        atomicStore(semReady, true);
+        thread.join();
+        assert(alertedOne && !alertedTwo);
+    }
+
+
+    unittest
+    {
+        testWait();
+        testWaitTimeout();
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/bionic/fcntl.d b/libphobos/libdruntime/core/sys/bionic/fcntl.d
new file mode 100644
index 00000000000..1ed58ebd57e
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/bionic/fcntl.d
@@ -0,0 +1,5 @@
+module core.sys.bionic.fcntl;
+
+version(CRuntime_Bionic) extern(C) nothrow @nogc:
+
+enum LOCK_EX = 2;
diff --git a/libphobos/libdruntime/core/sys/bionic/unistd.d b/libphobos/libdruntime/core/sys/bionic/unistd.d
new file mode 100644
index 00000000000..dd5314c04fe
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/bionic/unistd.d
@@ -0,0 +1,5 @@
+module core.sys.bionic.unistd;
+
+version(CRuntime_Bionic) extern(C) nothrow @nogc:
+
+int flock(int, int) @trusted;
diff --git a/libphobos/libdruntime/core/sys/freebsd/dlfcn.d b/libphobos/libdruntime/core/sys/freebsd/dlfcn.d
new file mode 100644
index 00000000000..bcb41a44f71
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/freebsd/dlfcn.d
@@ -0,0 +1,113 @@
+/**
+ * D header file for FreeBSD.
+ *
+ * Copyright: Copyright Martin Nowak 2012.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ */
+module core.sys.freebsd.dlfcn;
+
+public import core.sys.posix.dlfcn;
+
+version (FreeBSD):
+extern (C):
+nothrow:
+
+enum __BSD_VISIBLE = true;
+
+/*
+ * Modes and flags for dlopen().
+ */
+static assert(RTLD_LAZY   == 1);
+static assert(RTLD_NOW    == 2);
+enum RTLD_MODEMASK        =  0x3;
+static assert(RTLD_GLOBAL == 0x100);
+static assert(RTLD_LOCAL  == 0);
+enum RTLD_TRACE           =  0x200;
+enum RTLD_NODELETE        =  0x01000;
+enum RTLD_NOLOAD          =  0x02000;
+
+/*
+ * Request arguments for dlinfo().
+ */
+enum RTLD_DI_LINKMAP     = 2;    /* Obtain link map. */
+enum RTLD_DI_SERINFO     = 4;    /* Obtain search path info. */
+enum RTLD_DI_SERINFOSIZE = 5;    /*  ... query for required space. */
+enum RTLD_DI_ORIGIN      = 6;    /* Obtain object origin */
+enum RTLD_DI_MAX         = RTLD_DI_ORIGIN;
+
+/*
+ * Special handle arguments for dlsym()/dlinfo().
+ */
+enum RTLD_NEXT    = cast(void *)-1;    /* Search subsequent objects. */
+enum RTLD_DEFAULT = cast(void *)-2;    /* Use default search algorithm. */
+enum RTLD_SELF    = cast(void *)-3;    /* Search the caller itself. */
+
+static if (__BSD_VISIBLE)
+{
+    /*
+     * Structure filled in by dladdr().
+     */
+    struct Dl_info {
+        const(char)     *dli_fname;     /* Pathname of shared object. */
+        void            *dli_fbase;     /* Base address of shared object. */
+        const(char)     *dli_sname;     /* Name of nearest symbol. */
+        void            *dli_saddr;     /* Address of nearest symbol. */
+    };
+
+    /*-
+     * The actual type declared by this typedef is immaterial, provided that
+     * it is a function pointer.  Its purpose is to provide a return type for
+     * dlfunc() which can be cast to a function pointer type without depending
+     * on behavior undefined by the C standard, which might trigger a compiler
+     * diagnostic.  We intentionally declare a unique type signature to force
+     * a diagnostic should the application not cast the return value of dlfunc()
+     * appropriately.
+     */
+    struct __dlfunc_arg {
+        int     __dlfunc_dummy;
+    };
+
+    alias void function(__dlfunc_arg) dlfunc_t;
+
+    /*
+     * Structures, returned by the RTLD_DI_SERINFO dlinfo() request.
+     */
+    struct Dl_serpath {
+        char *          dls_name;       /* single search path entry */
+        uint            dls_flags;      /* path information */
+    };
+
+    struct Dl_serinfo {
+        size_t          dls_size;       /* total buffer size */
+        uint            dls_cnt;        /* number of path entries */
+        Dl_serpath[1]   dls_serpath;    /* there may be more than one */
+    };
+}
+
+private template __externC(RT, P...)
+{
+    alias extern(C) RT function(P) nothrow @nogc __externC;
+}
+
+/* XSI functions first. */
+static assert(is(typeof(&dlclose) == __externC!(int, void*)));
+static assert(is(typeof(&dlerror) == __externC!(char*)));
+static assert(is(typeof(&dlopen)  == __externC!(void*, const char*, int)));
+static assert(is(typeof(&dlsym)   == __externC!(void*, void*, const char*)));
+
+static if (__BSD_VISIBLE)
+{
+    void*    fdlopen(int, int);
+    int      dladdr(const(void)*, Dl_info*);
+    dlfunc_t dlfunc(void*, const(char)*);
+    int      dlinfo(void*, int, void*);
+    void     dllockinit(void* _context,
+        void* function(void* _context) _lock_create,
+        void  function(void* _lock)    _rlock_acquire,
+        void  function(void* _lock)    _wlock_acquire,
+        void  function(void* _lock)    _lock_release,
+        void  function(void* _lock)    _lock_destroy,
+        void  function(void* _context) _context_destroy);
+    void*    dlvsym(void*, const(char)*, const(char)*);
+}
diff --git a/libphobos/libdruntime/core/sys/freebsd/execinfo.d b/libphobos/libdruntime/core/sys/freebsd/execinfo.d
new file mode 100644
index 00000000000..7b4ad6c03c4
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/freebsd/execinfo.d
@@ -0,0 +1,133 @@
+/**
+ * FreeBSD implementation of glibc's $(LINK2 http://www.gnu.org/software/libc/manual/html_node/Backtraces.html backtrace) facility.
+ *
+ * Copyright: Copyright Martin Nowak 2012.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Martin Nowak
+ * Source:    $(DRUNTIMESRC core/sys/freebsd/_execinfo.d)
+ */
+module core.sys.freebsd.execinfo;
+
+version (FreeBSD):
+extern (C):
+nothrow:
+
+import core.sys.freebsd.dlfcn;
+
+// Use extern (D) so that these functions don't collide with libexecinfo.
+
+extern (D) int backtrace(void** buffer, int size)
+{
+    import core.thread : thread_stackBottom;
+
+    void** p, pend=cast(void**)thread_stackBottom();
+    version (D_InlineAsm_X86)
+        asm nothrow @trusted { mov p[EBP], EBP; }
+    else version (D_InlineAsm_X86_64)
+        asm nothrow @trusted { mov p[RBP], RBP; }
+    else
+        static assert(false, "Architecture not supported.");
+
+    int i;
+    for (; i < size && p < pend; ++i)
+    {
+        buffer[i] = *(p + 1);
+        auto pnext = cast(void**)*p;
+        if (pnext <= p) break;
+        p = pnext;
+    }
+    return i;
+}
+
+
+extern (D) char** backtrace_symbols(const(void*)* buffer, int size)
+{
+    static void* realloc(void* p, size_t len) nothrow
+    {
+        static import cstdlib=core.stdc.stdlib;
+        auto res = cstdlib.realloc(p, len);
+        if (res is null) cstdlib.free(p);
+        return res;
+    }
+
+    if (size <= 0) return null;
+
+    size_t pos = size * (char*).sizeof;
+    char** p = cast(char**)realloc(null, pos);
+    if (p is null) return null;
+
+    Dl_info info;
+    foreach (i, addr; buffer[0 .. size])
+    {
+        if (dladdr(addr, &info) == 0)
+            (cast(ubyte*)&info)[0 .. info.sizeof] = 0;
+        fixupDLInfo(addr, info);
+
+        immutable len = formatStackFrame(null, 0, addr, info);
+        assert(len > 0);
+
+        p = cast(char**)realloc(p, pos + len);
+        if (p is null) return null;
+
+        formatStackFrame(cast(char*)p + pos, len, addr, info) == len || assert(0);
+
+        p[i] = cast(char*)pos;
+        pos += len;
+    }
+    foreach (i; 0 .. size)
+    {
+        pos = cast(size_t)p[i];
+        p[i] = cast(char*)p + pos;
+    }
+    return p;
+}
+
+
+extern (D) void backtrace_symbols_fd(const(void*)* buffer, int size, int fd)
+{
+    import core.sys.posix.unistd : write;
+    import core.stdc.stdlib : alloca;
+
+    if (size <= 0) return;
+
+    Dl_info info;
+    foreach (i, addr; buffer[0 .. size])
+    {
+        if (dladdr(addr, &info) == 0)
+            (cast(ubyte*)&info)[0 .. info.sizeof] = 0;
+        fixupDLInfo(addr, info);
+
+        enum maxAlloca = 1024;
+        enum min = (size_t a, size_t b) => a <= b ? a : b;
+        immutable len = min(formatStackFrame(null, 0, addr, info), maxAlloca);
+        assert(len > 0);
+
+        auto p = cast(char*)alloca(len);
+        if (p is null) return;
+
+        formatStackFrame(p, len, addr, info) >= len || assert(0);
+        p[len - 1] = '\n';
+        write(fd, p, len);
+    }
+}
+
+
+private void fixupDLInfo(const(void)* addr, ref Dl_info info)
+{
+    if (info.dli_fname is null) info.dli_fname = "???";
+    if (info.dli_fbase is null) info.dli_fbase = null;
+    if (info.dli_sname is null) info.dli_sname = "???";
+    if (info.dli_saddr is null) info.dli_saddr = cast(void*)addr;
+}
+
+
+private size_t formatStackFrame(char* p, size_t plen, const(void)* addr, const ref Dl_info info)
+{
+    import core.stdc.stdio : snprintf;
+
+    immutable off = addr - info.dli_saddr;
+    immutable len = snprintf(p, plen, "%p <%s+%zd> at %s",
+                             addr, info.dli_sname, off, info.dli_fname);
+    assert(len > 0);
+    return cast(size_t)len + 1; // + '\0'
+}
diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/cdefs.d b/libphobos/libdruntime/core/sys/freebsd/sys/cdefs.d
new file mode 100644
index 00000000000..09deb5bee83
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/freebsd/sys/cdefs.d
@@ -0,0 +1,16 @@
+/**
+ * D header file for FreeBSD
+ *
+ * Authors: Martin Nowak
+ */
+module core.sys.freebsd.sys.cdefs;
+
+version (FreeBSD):
+
+public import core.sys.posix.config;
+
+// https://svnweb.freebsd.org/base/head/sys/sys/cdefs.h?revision=271155&view=markup
+enum __POSIX_VISIBLE = 200112;
+enum __XSI_VISIBLE = 700;
+enum __BSD_VISIBLE = true;
+enum __ISO_C_VISIBLE = 1999;
diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/elf.d b/libphobos/libdruntime/core/sys/freebsd/sys/elf.d
new file mode 100644
index 00000000000..3dcb41f05f8
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/freebsd/sys/elf.d
@@ -0,0 +1,11 @@
+/**
+ * D header file for FreeBSD.
+ *
+ * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/elf.h?view=markup, sys/elf.h)
+ */
+module core.sys.freebsd.sys.elf;
+
+version (FreeBSD):
+
+public import core.sys.freebsd.sys.elf32;
+public import core.sys.freebsd.sys.elf64;
diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/elf32.d b/libphobos/libdruntime/core/sys/freebsd/sys/elf32.d
new file mode 100644
index 00000000000..4a55a0c001c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/freebsd/sys/elf32.d
@@ -0,0 +1,187 @@
+/**
+ * D header file for FreeBSD.
+ *
+ * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/elf32.h?view=markup, sys/elf32.h)
+ */
+module core.sys.freebsd.sys.elf32;
+
+version (FreeBSD):
+extern (C):
+pure:
+nothrow:
+
+import core.stdc.stdint;
+public import core.sys.freebsd.sys.elf_common;
+
+alias uint16_t Elf32_Half;
+alias uint32_t Elf32_Word;
+alias int32_t  Elf32_Sword;
+alias uint64_t Elf32_Lword;
+alias uint32_t Elf32_Addr;
+alias uint32_t Elf32_Off;
+alias Elf32_Word Elf32_Hashelt;
+alias Elf32_Word Elf32_Size;
+alias Elf32_Sword Elf32_Ssize;
+
+struct Elf32_Ehdr
+{
+    char[EI_NIDENT] e_ident;
+    Elf32_Half    e_type;
+    Elf32_Half    e_machine;
+    Elf32_Word    e_version;
+    Elf32_Addr    e_entry;
+    Elf32_Off     e_phoff;
+    Elf32_Off     e_shoff;
+    Elf32_Word    e_flags;
+    Elf32_Half    e_ehsize;
+    Elf32_Half    e_phentsize;
+    Elf32_Half    e_phnum;
+    Elf32_Half    e_shentsize;
+    Elf32_Half    e_shnum;
+    Elf32_Half    e_shstrndx;
+}
+
+struct Elf32_Shdr
+{
+    Elf32_Word    sh_name;
+    Elf32_Word    sh_type;
+    Elf32_Word    sh_flags;
+    Elf32_Addr    sh_addr;
+    Elf32_Off     sh_offset;
+    Elf32_Word    sh_size;
+    Elf32_Word    sh_link;
+    Elf32_Word    sh_info;
+    Elf32_Word    sh_addralign;
+    Elf32_Word    sh_entsize;
+}
+
+struct Elf32_Phdr
+{
+    Elf32_Word    p_type;
+    Elf32_Off     p_offset;
+    Elf32_Addr    p_vaddr;
+    Elf32_Addr    p_paddr;
+    Elf32_Word    p_filesz;
+    Elf32_Word    p_memsz;
+    Elf32_Word    p_flags;
+    Elf32_Word    p_align;
+}
+
+struct Elf32_Dyn
+{
+  Elf32_Sword   d_tag;
+  union _d_un
+  {
+      Elf32_Word d_val;
+      Elf32_Addr d_ptr;
+  } _d_un d_un;
+}
+
+struct Elf32_Rel
+{
+    Elf32_Addr    r_offset;
+    Elf32_Word    r_info;
+}
+
+struct Elf32_Rela
+{
+    Elf32_Addr    r_offset;
+    Elf32_Word    r_info;
+    Elf32_Sword   r_addend;
+}
+
+extern (D)
+{
+    auto ELF32_R_SYM(V)(V val) { return val >> 8; }
+    auto ELF32_R_TYPE(V)(V val) { return val & 0xff; }
+    auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); }
+}
+
+alias Elf_Note Elf32_Nhdr;
+
+struct Elf32_Move
+{
+    Elf32_Lword   m_value;
+    Elf32_Word    m_info;
+    Elf32_Word    m_poffset;
+    Elf32_Half    m_repeat;
+    Elf32_Half    m_stride;
+}
+
+extern (D)
+{
+    auto ELF32_M_SYM(I)(I info) { return info >> 8; }
+    auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; }
+    auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubye)size; }
+}
+
+struct Elf32_Cap
+{
+    Elf32_Word    c_tag;
+    union _c_un
+    {
+        Elf32_Word      c_val;
+        Elf32_Addr      c_ptr;
+    } _c_un c_un;
+}
+
+struct Elf32_Sym
+{
+    Elf32_Word    st_name;
+    Elf32_Addr    st_value;
+    Elf32_Word    st_size;
+    ubyte st_info;
+    ubyte st_other;
+    Elf32_Half st_shndx;
+}
+
+extern (D)
+{
+    auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
+    auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; }
+    auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); }
+    auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; }
+}
+
+struct Elf32_Verdef
+{
+    Elf32_Half    vd_version;
+    Elf32_Half    vd_flags;
+    Elf32_Half    vd_ndx;
+    Elf32_Half    vd_cnt;
+    Elf32_Word    vd_hash;
+    Elf32_Word    vd_aux;
+    Elf32_Word    vd_next;
+}
+
+struct Elf32_Verdaux
+{
+    Elf32_Word    vda_name;
+    Elf32_Word    vda_next;
+}
+
+struct Elf32_Verneed
+{
+    Elf32_Half    vn_version;
+    Elf32_Half    vn_cnt;
+    Elf32_Word    vn_file;
+    Elf32_Word    vn_aux;
+    Elf32_Word    vn_next;
+}
+
+struct Elf32_Vernaux
+{
+    Elf32_Word    vna_hash;
+    Elf32_Half    vna_flags;
+    Elf32_Half    vna_other;
+    Elf32_Word    vna_name;
+    Elf32_Word    vna_next;
+}
+
+alias Elf32_Half Elf32_Versym;
+
+struct Elf32_Syminfo
+{
+    Elf32_Half si_boundto;
+    Elf32_Half si_flags;
+}
diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/elf64.d b/libphobos/libdruntime/core/sys/freebsd/sys/elf64.d
new file mode 100644
index 00000000000..d3c189ebd60
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/freebsd/sys/elf64.d
@@ -0,0 +1,193 @@
+/**
+ * D header file for FreeBSD.
+ *
+ * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/elf64.h?view=markup, sys/elf64.h)
+ */
+module core.sys.freebsd.sys.elf64;
+
+version (FreeBSD):
+extern (C):
+pure:
+nothrow:
+
+import core.stdc.stdint;
+public import core.sys.freebsd.sys.elf_common;
+
+alias uint16_t Elf64_Half;
+alias uint32_t Elf64_Word;
+alias int32_t  Elf64_Sword;
+alias uint64_t Elf64_Lword;
+alias uint64_t Elf64_Xword;
+alias int64_t  Elf64_Sxword;
+alias uint64_t Elf64_Addr;
+alias uint64_t Elf64_Off;
+alias Elf64_Word Elf64_Hashelt;
+alias Elf64_Xword Elf64_Size;
+alias Elf64_Sxword Elf64_Ssize;
+
+struct Elf64_Ehdr
+{
+    char[EI_NIDENT] e_ident;
+    Elf64_Half    e_type;
+    Elf64_Half    e_machine;
+    Elf64_Word    e_version;
+    Elf64_Addr    e_entry;
+    Elf64_Off     e_phoff;
+    Elf64_Off     e_shoff;
+    Elf64_Word    e_flags;
+    Elf64_Half    e_ehsize;
+    Elf64_Half    e_phentsize;
+    Elf64_Half    e_phnum;
+    Elf64_Half    e_shentsize;
+    Elf64_Half    e_shnum;
+    Elf64_Half    e_shstrndx;
+}
+
+struct Elf64_Shdr
+{
+    Elf64_Word    sh_name;
+    Elf64_Word    sh_type;
+    Elf64_Xword   sh_flags;
+    Elf64_Addr    sh_addr;
+    Elf64_Off     sh_offset;
+    Elf64_Xword   sh_size;
+    Elf64_Word    sh_link;
+    Elf64_Word    sh_info;
+    Elf64_Xword   sh_addralign;
+    Elf64_Xword   sh_entsize;
+}
+
+struct Elf64_Phdr
+{
+    Elf64_Word    p_type;
+    Elf64_Word    p_flags;
+    Elf64_Off     p_offset;
+    Elf64_Addr    p_vaddr;
+    Elf64_Addr    p_paddr;
+    Elf64_Xword   p_filesz;
+    Elf64_Xword   p_memsz;
+    Elf64_Xword   p_align;
+}
+
+struct Elf64_Dyn
+{
+  Elf64_Sxword  d_tag;
+  union _d_un
+  {
+      Elf64_Xword d_val;
+      Elf64_Addr d_ptr;
+  } _d_un d_un;
+}
+
+struct Elf64_Rel
+{
+    Elf64_Addr    r_offset;
+    Elf64_Xword   r_info;
+}
+
+struct Elf64_Rela
+{
+    Elf64_Addr    r_offset;
+    Elf64_Xword   r_info;
+    Elf64_Sxword  r_addend;
+}
+
+extern (D)
+{
+    auto ELF64_R_SYM(I)(I i) { return i >> 32; }
+    auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; }
+    auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type & 0xffffffff); }
+
+    auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; }
+    auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; }
+    auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; }
+}
+
+alias Elf_Note Elf64_Nhdr;
+
+struct Elf64_Move
+{
+    Elf64_Lword   m_value;
+    Elf64_Xword   m_info;
+    Elf64_Xword   m_poffset;
+    Elf64_Half    m_repeat;
+    Elf64_Half    m_stride;
+}
+
+extern (D)
+{
+    auto ELF64_M_SYM(I)(I info) { return info >> 8; }
+    auto ELF64_M_SIZE(I)(I info) { return cast(ubyte)info; }
+    auto ELF64_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubye)size; }
+}
+
+struct Elf64_Cap
+{
+    Elf64_Xword   c_tag;
+    union _c_un
+    {
+        Elf64_Xword     c_val;
+        Elf64_Addr      c_ptr;
+    } _c_un c_un;
+}
+
+struct Elf64_Sym
+{
+    Elf64_Word    st_name;
+    ubyte st_info;
+    ubyte st_other;
+    Elf64_Half st_shndx;
+    Elf64_Addr    st_value;
+    Elf64_Xword   st_size;
+}
+
+extern (D)
+{
+    auto ELF64_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
+    auto ELF64_ST_TYPE(T)(T val) { return val & 0xf; }
+    auto ELF64_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); }
+    auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; }
+}
+
+struct Elf64_Verdef
+{
+    Elf64_Half    vd_version;
+    Elf64_Half    vd_flags;
+    Elf64_Half    vd_ndx;
+    Elf64_Half    vd_cnt;
+    Elf64_Word    vd_hash;
+    Elf64_Word    vd_aux;
+    Elf64_Word    vd_next;
+}
+
+struct Elf64_Verdaux
+{
+    Elf64_Word    vda_name;
+    Elf64_Word    vda_next;
+}
+
+struct Elf64_Verneed
+{
+    Elf64_Half    vn_version;
+    Elf64_Half    vn_cnt;
+    Elf64_Word    vn_file;
+    Elf64_Word    vn_aux;
+    Elf64_Word    vn_next;
+}
+
+struct Elf64_Vernaux
+{
+    Elf64_Word    vna_hash;
+    Elf64_Half    vna_flags;
+    Elf64_Half    vna_other;
+    Elf64_Word    vna_name;
+    Elf64_Word    vna_next;
+}
+
+alias Elf64_Half Elf64_Versym;
+
+struct Elf64_Syminfo
+{
+    Elf64_Half si_boundto;
+    Elf64_Half si_flags;
+}
diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/elf_common.d b/libphobos/libdruntime/core/sys/freebsd/sys/elf_common.d
new file mode 100644
index 00000000000..fb8fcba1a42
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/freebsd/sys/elf_common.d
@@ -0,0 +1,853 @@
+/**
+ * D header file for FreeBSD.
+ *
+ * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/elf_common.h?view=markup, sys/elf_common.h)
+ */
+module core.sys.freebsd.sys.elf_common;
+
+version (FreeBSD):
+extern (C):
+pure:
+nothrow:
+
+import core.stdc.stdint;
+
+struct Elf_Note
+{
+    uint32_t      n_namesz;
+    uint32_t      n_descsz;
+    uint32_t      n_type;
+}
+
+struct Elf_GNU_Hash_Header
+{
+    uint32_t      gh_nbuckets;
+    uint32_t      gh_symndx;
+    uint32_t      gh_maskwords;
+    uint32_t      gh_shift2;
+}
+
+enum EI_MAG0 =         0;
+enum EI_MAG1 =         1;
+enum EI_MAG2 =         2;
+enum EI_MAG3 =         3;
+enum EI_CLASS =        4;
+enum EI_DATA =         5;
+enum EI_VERSION =      6;
+enum EI_OSABI =        7;
+enum EI_ABIVERSION =   8;
+enum OLD_EI_BRAND =    8;
+enum EI_PAD =          9;
+enum EI_NIDENT =       16;
+
+enum ELFMAG0 =         0x7f;
+enum ELFMAG1 =         'E';
+enum ELFMAG2 =         'L';
+enum ELFMAG3 =         'F';
+enum ELFMAG =          "\177ELF";
+enum SELFMAG =         4;
+
+enum EV_NONE =         0;
+enum EV_CURRENT =      1;
+
+enum ELFCLASSNONE =    0;
+enum ELFCLASS32 =      1;
+enum ELFCLASS64 =      2;
+
+enum ELFDATANONE =     0;
+enum ELFDATA2LSB =     1;
+enum ELFDATA2MSB =     2;
+
+enum ELFOSABI_NONE =           0;
+enum ELFOSABI_SYSV =           0;
+enum ELFOSABI_HPUX =           1;
+enum ELFOSABI_NETBSD =         2;
+enum ELFOSABI_LINUX =          3;
+enum ELFOSABI_HURD  =          4;
+enum ELFOSABI_86OPEN =         5;
+enum ELFOSABI_SOLARIS =        6;
+enum ELFOSABI_AIX =            7;
+enum ELFOSABI_MONTEREY =       7;
+enum ELFOSABI_IRIX =           8;
+enum ELFOSABI_FREEBSD =        9;
+enum ELFOSABI_TRU64 =          10;
+enum ELFOSABI_MODESTO =        11;
+enum ELFOSABI_OPENBSD =        12;
+enum ELFOSABI_OPENVMS =        13;
+enum ELFOSABI_NSK =            14;
+enum ELFOSABI_AROS =           15;
+enum ELFOSABI_ARM =            97;
+enum ELFOSABI_STANDALONE =     255;
+
+extern (D)
+{
+    auto IS_ELF(T)(T ehdr) { return ehdr.e_ident[EI_MAG0] == ELFMAG0 &&
+                                    ehdr.e_ident[EI_MAG1] == ELFMAG1 &&
+                                    ehdr.e_ident[EI_MAG2] == ELFMAG2 &&
+                                    ehdr.e_ident[EI_MAG3] == ELFMAG3; }
+}
+
+enum ET_NONE =         0;
+enum ET_REL =          1;
+enum ET_EXEC =         2;
+enum ET_DYN =          3;
+enum ET_CORE =         4;
+enum ET_LOOS =         0xfe00;
+enum ET_HIOS =         0xfeff;
+enum ET_LOPROC =       0xff00;
+enum ET_HIPROC =       0xffff;
+
+enum EM_NONE =          0;
+enum EM_M32 =           1;
+enum EM_SPARC =         2;
+enum EM_386 =           3;
+enum EM_68K =           4;
+enum EM_88K =           5;
+enum EM_860 =           7;
+enum EM_MIPS =          8;
+enum EM_S370 =          9;
+enum EM_MIPS_RS3_LE =  10;
+enum EM_PARISC =       15;
+enum EM_VPP500 =       17;
+enum EM_SPARC32PLUS =  18;
+enum EM_960 =          19;
+enum EM_PPC =          20;
+enum EM_PPC64 =        21;
+enum EM_S390 =         22;
+enum EM_V800 =         36;
+enum EM_FR20 =         37;
+enum EM_RH32 =         38;
+enum EM_RCE =          39;
+enum EM_ARM =          40;
+enum EM_SH =           42;
+enum EM_SPARCV9 =      43;
+enum EM_TRICORE =      44;
+enum EM_ARC =          45;
+enum EM_H8_300 =       46;
+enum EM_H8_300H =      47;
+enum EM_H8S =          48;
+enum EM_H8_500 =       49;
+enum EM_IA_64 =        50;
+enum EM_MIPS_X =       51;
+enum EM_COLDFIRE =     52;
+enum EM_68HC12 =       53;
+enum EM_MMA =          54;
+enum EM_PCP =          55;
+enum EM_NCPU =         56;
+enum EM_NDR1 =         57;
+enum EM_STARCORE =     58;
+enum EM_ME16 =         59;
+enum EM_ST100 =        60;
+enum EM_TINYJ =        61;
+enum EM_X86_64 =       62;
+enum EM_AMD64 =        62;
+enum EM_PDSP =         63;
+enum EM_FX66 =         66;
+enum EM_ST9PLUS =      67;
+enum EM_ST7 =          68;
+enum EM_68HC16 =       69;
+enum EM_68HC11 =       70;
+enum EM_68HC08 =       71;
+enum EM_68HC05 =       72;
+enum EM_SVX =          73;
+enum EM_ST19 =         74;
+enum EM_VAX =          75;
+enum EM_CRIS =         76;
+enum EM_JAVELIN =      77;
+enum EM_FIREPATH =     78;
+enum EM_ZSP =          79;
+enum EM_MMIX =         80;
+enum EM_HUANY =        81;
+enum EM_PRISM =        82;
+enum EM_AVR =          83;
+enum EM_FR30 =         84;
+enum EM_D10V =         85;
+enum EM_D30V =         86;
+enum EM_V850 =         87;
+enum EM_M32R =         88;
+enum EM_MN10300 =      89;
+enum EM_MN10200 =      90;
+enum EM_PJ =           91;
+enum EM_OPENRISC =     92;
+enum EM_ARC_A5 =       93;
+enum EM_XTENSA =       94;
+enum EM_VIDEOCORE =    95;
+enum EM_TMM_GPP =      96;
+enum EM_NS32K =        97;
+enum EM_TPC =          98;
+enum EM_SNP1K =        99;
+enum EM_ST200 =       100;
+enum EM_IP2K =        101;
+enum EM_MAX =         102;
+enum EM_CR =          103;
+enum EM_F2MC16 =      104;
+enum EM_MSP430 =      105;
+enum EM_BLACKFIN =    106;
+enum EM_SE_C33 =      107;
+enum EM_SEP =         108;
+enum EM_ARCA =        109;
+enum EM_UNICORE =     110;
+
+enum EM_486 =           6;
+enum EM_MIPS_RS4_BE =  10;
+enum EM_ALPHA_STD =    41;
+enum EM_ALPHA =    0x9026;
+
+enum SHN_UNDEF =       0;
+enum SHN_LORESERVE =   0xff00;
+enum SHN_LOPROC =      0xff00;
+enum SHN_HIPROC =      0xff1f;
+enum SHN_LOOS =        0xff20;
+enum SHN_HIOS =        0xff3f;
+enum SHN_ABS =         0xfff1;
+enum SHN_COMMON =      0xfff2;
+enum SHN_XINDEX =      0xffff;
+enum SHN_HIRESERVE =   0xffff;
+
+enum SHT_NULL =          0;
+enum SHT_PROGBITS =      1;
+enum SHT_SYMTAB =        2;
+enum SHT_STRTAB =        3;
+enum SHT_RELA =          4;
+enum SHT_HASH =          5;
+enum SHT_DYNAMIC =       6;
+enum SHT_NOTE =          7;
+enum SHT_NOBITS =        8;
+enum SHT_REL =           9;
+enum SHT_SHLIB =         10;
+enum SHT_DYNSYM =        11;
+enum SHT_INIT_ARRAY =    14;
+enum SHT_FINI_ARRAY =    15;
+enum SHT_PREINIT_ARRAY = 16;
+enum SHT_GROUP =         17;
+enum SHT_SYMTAB_SHNDX =  18;
+enum SHT_LOOS =          0x60000000;
+enum SHT_LOSUNW =        0x6ffffff4;
+enum SHT_SUNW_dof =      0x6ffffff4;
+enum SHT_SUNW_cap =      0x6ffffff5;
+enum SHT_SUNW_SIGNATURE = 0x6ffffff6;
+enum SHT_GNU_HASH =      0x6ffffff6;
+enum SHT_SUNW_ANNOTATE = 0x6ffffff7;
+enum SHT_SUNW_DEBUGSTR = 0x6ffffff8;
+enum SHT_SUNW_DEBUG =    0x6ffffff9;
+enum SHT_SUNW_move =     0x6ffffffa;
+enum SHT_SUNW_COMDAT =   0x6ffffffb;
+enum SHT_SUNW_syminfo =  0x6ffffffc;
+enum SHT_SUNW_verdef =   0x6ffffffd;
+enum SHT_GNU_verdef =    0x6ffffffd;
+enum SHT_SUNW_verneed =  0x6ffffffe;
+enum SHT_GNU_verneed =   0x6ffffffe;
+enum SHT_SUNW_versym =   0x6fffffff;
+enum SHT_GNU_versym =    0x6fffffff;
+enum SHT_HISUNW =        0x6fffffff;
+enum SHT_HIOS =          0x6fffffff;
+enum SHT_LOPROC =        0x70000000;
+enum SHT_AMD64_UNWIND =  0x70000001;
+enum SHT_ARM_EXIDX =     0x70000001;
+enum SHT_ARM_PREEMPTMAP = 0x70000002;
+enum SHT_ARM_ATTRIBUTES = 0x70000003;
+enum SHT_ARM_DEBUGOVERLAY = 0x70000004;
+enum SHT_ARM_OVERLAYSECTION = 0x70000005;
+enum SHT_MIPS_REGINFO =  0x70000006;
+enum SHT_MIPS_OPTIONS =  0x7000000d;
+enum SHT_MIPS_DWARF =    0x7000001e;
+enum SHT_HIPROC =        0x7fffffff;
+enum SHT_LOUSER =        0x80000000;
+enum SHT_HIUSER =        0x8fffffff;
+
+enum SHF_WRITE =            (1 << 0);
+enum SHF_ALLOC =            (1 << 1);
+enum SHF_EXECINSTR =        (1 << 2);
+enum SHF_MERGE =            (1 << 4);
+enum SHF_STRINGS =          (1 << 5);
+enum SHF_INFO_LINK =        (1 << 6);
+enum SHF_LINK_ORDER =       (1 << 7);
+enum SHF_OS_NONCONFORMING = (1 << 8);
+enum SHF_GROUP =            (1 << 9);
+enum SHF_TLS =              (1 << 10);
+enum SHF_MASKOS =           0x0ff00000;
+enum SHF_MASKPROC =         0xf0000000;
+
+enum PT_NULL =         0;
+enum PT_LOAD =         1;
+enum PT_DYNAMIC =      2;
+enum PT_INTERP =       3;
+enum PT_NOTE =         4;
+enum PT_SHLIB =        5;
+enum PT_PHDR =         6;
+enum PT_TLS =          7;
+enum PT_LOOS =         0x60000000;
+enum PT_SUNW_UNWIND =  0x6464e550;
+enum PT_GNU_EH_FRAME = 0x6474e550;
+enum PT_GNU_STACK =    0x6474e551;
+enum PT_GNU_RELRO =    0x6474e552;
+enum PT_LOSUNW =       0x6ffffffa;
+enum PT_SUNWBSS =      0x6ffffffa;
+enum PT_SUNWSTACK =    0x6ffffffb;
+enum PT_SUNWDTRACE =   0x6ffffffc;
+enum PT_SUNWCAP =      0x6ffffffd;
+enum PT_HISUNW =       0x6fffffff;
+enum PT_HIOS =         0x6fffffff;
+enum PT_LOPROC =       0x70000000;
+enum PT_HIPROC =       0x7fffffff;
+
+enum PF_X =            (1 << 0);
+enum PF_W =            (1 << 1);
+enum PF_R =            (1 << 2);
+enum PF_MASKOS =       0x0ff00000;
+enum PF_MASKPROC =     0xf0000000;
+
+enum PN_XNUM =         0xffff;
+
+enum DT_NULL =         0;
+enum DT_NEEDED =       1;
+enum DT_PLTRELSZ =     2;
+enum DT_PLTGOT =       3;
+enum DT_HASH =         4;
+enum DT_STRTAB =       5;
+enum DT_SYMTAB =       6;
+enum DT_RELA =         7;
+enum DT_RELASZ =       8;
+enum DT_RELAENT =      9;
+enum DT_STRSZ =        10;
+enum DT_SYMENT =       11;
+enum DT_INIT =         12;
+enum DT_FINI =         13;
+enum DT_SONAME =       14;
+enum DT_RPATH =        15;
+enum DT_SYMBOLIC =     16;
+enum DT_REL =          17;
+enum DT_RELSZ =        18;
+enum DT_RELENT =       19;
+enum DT_PLTREL =       20;
+enum DT_DEBUG =        21;
+enum DT_TEXTREL =      22;
+enum DT_JMPREL =       23;
+enum DT_BIND_NOW =     24;
+enum DT_INIT_ARRAY =   25;
+enum DT_FINI_ARRAY =   26;
+enum DT_INIT_ARRAYSZ = 27;
+enum DT_FINI_ARRAYSZ = 28;
+enum DT_RUNPATH =      29;
+enum DT_FLAGS =        30;
+enum DT_ENCODING =     32;
+enum DT_PREINIT_ARRAY = 32;
+enum DT_PREINIT_ARRAYSZ = 33;
+enum DT_MAXPOSTAGS =   34;
+enum DT_LOOS =         0x6000000d;
+enum DT_SUNW_AUXILIARY = 0x6000000d;
+enum DT_SUNW_RTLDINF = 0x6000000e;
+enum DT_SUNW_FILTER =  0x6000000f;
+enum DT_SUNW_CAP =     0x60000010;
+enum DT_HIOS =         0x6ffff000;
+enum DT_VALRNGLO =     0x6ffffd00;
+enum DT_CHECKSUM =     0x6ffffdf8;
+enum DT_PLTPADSZ =     0x6ffffdf9;
+enum DT_MOVEENT =      0x6ffffdfa;
+enum DT_MOVESZ =       0x6ffffdfb;
+enum DT_FEATURE_1 =    0x6ffffdfc;
+enum DT_POSFLAG_1 =    0x6ffffdfd;
+enum DT_SYMINSZ =      0x6ffffdfe;
+enum DT_SYMINENT =     0x6ffffdff;
+enum DT_VALRNGHI =     0x6ffffdff;
+enum DT_ADDRRNGLO =    0x6ffffe00;
+enum DT_GNU_HASH =     0x6ffffef5;
+enum DT_CONFIG =       0x6ffffefa;
+enum DT_DEPAUDIT =     0x6ffffefb;
+enum DT_AUDIT =        0x6ffffefc;
+enum DT_PLTPAD =       0x6ffffefd;
+enum DT_MOVETAB =      0x6ffffefe;
+enum DT_SYMINFO =      0x6ffffeff;
+enum DT_ADDRRNGHI =    0x6ffffeff;
+enum DT_VERSYM =       0x6ffffff0;
+enum DT_RELACOUNT =    0x6ffffff9;
+enum DT_RELCOUNT =     0x6ffffffa;
+enum DT_FLAGS_1 =      0x6ffffffb;
+enum DT_VERDEF =       0x6ffffffc;
+enum DT_VERDEFNUM =    0x6ffffffd;
+enum DT_VERNEED =      0x6ffffffe;
+enum DT_VERNEEDNUM =   0x6fffffff;
+enum DT_LOPROC =       0x70000000;
+enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001;
+enum DT_AUXILIARY =    0x7ffffffd;
+enum DT_USED =         0x7ffffffe;
+enum DT_FILTER =       0x7fffffff;
+enum DT_HIPROC =       0x7fffffff;
+
+enum DF_ORIGIN =       0x00000001;
+enum DF_SYMBOLIC =     0x00000002;
+enum DF_TEXTREL =      0x00000004;
+enum DF_BIND_NOW =     0x00000008;
+enum DF_STATIC_TLS =   0x00000010;
+
+enum DF_1_BIND_NOW =   0x00000001;
+enum DF_1_GLOBAL =     0x00000002;
+enum DF_1_NODELETE =   0x00000008;
+enum DF_1_LOADFLTR =   0x00000010;
+enum DF_1_NOOPEN =     0x00000040;
+enum DF_1_NODEFLIB =   0x00000800;
+
+enum NT_PRSTATUS =     1;
+enum NT_FPREGSET =     2;
+enum NT_PRPSINFO =     3;
+enum NT_THRMISC =      7;
+enum NT_PROCSTAT_PROC = 8;
+enum NT_PROCSTAT_FILES = 9;
+enum NT_PROCSTAT_VMMAP = 10;
+enum NT_PROCSTAT_GROUPS = 11;
+enum NT_PROCSTAT_UMASK = 12;
+enum NT_PROCSTAT_RLIMIT = 13;
+enum NT_PROCSTAT_OSREL = 14;
+enum NT_PROCSTAT_PSSTRINGS = 15;
+enum NT_PROCSTAT_AUXV = 16;
+
+enum STB_LOCAL =       0;
+enum STB_GLOBAL =      1;
+enum STB_WEAK =        2;
+enum STB_NUM =         3;
+enum STB_LOOS =        10;
+enum STB_HIOS =        12;
+enum STB_LOPROC =      13;
+enum STB_HIPROC =      15;
+
+enum STT_NOTYPE =      0;
+enum STT_OBJECT =      1;
+enum STT_FUNC =        2;
+enum STT_SECTION =     3;
+enum STT_FILE =        4;
+enum STT_COMMON =      5;
+enum STT_TLS =         6;
+enum STT_NUM =         7;
+enum STT_LOOS =        10;
+enum STT_GNU_IFUNC =   10;
+enum STT_HIOS =        12;
+enum STT_LOPROC =      13;
+enum STT_HIPROC =      15;
+
+enum STV_DEFAULT =     0;
+enum STV_INTERNAL =    1;
+enum STV_HIDDEN =      2;
+enum STV_PROTECTED =   3;
+enum STV_EXPORTED =    4;
+enum STV_SINGLETON =   5;
+enum STV_ELIMINATE =   6;
+
+enum STN_UNDEF =       0;
+
+enum VER_DEF_CURRENT = 1;
+alias VER_NDX VER_DEF_IDX;
+
+enum VER_FLG_BASE =    0x1;
+enum VER_FLG_WEAK =    0x2;
+
+enum VER_NEED_CURRENT = 1;
+enum VER_NEED_WEAK =    32768;
+enum VER_NEED_HIDDEN = VER_NDX_HIDDEN;
+alias VER_NDX VER_NEED_IDX;
+
+enum VER_NDX_LOCAL =           0;
+enum VER_NDX_GLOBAL =          1;
+enum VER_NDX_GIVEN =           2;
+
+enum VER_NDX_HIDDEN =      32768;
+extern (D)
+{
+    auto VER_NDX(V)(V v) { return v & ~(1u << 15); }
+}
+
+enum CA_SUNW_NULL =    0;
+enum CA_SUNW_HW_1 =    1;
+enum CA_SUNW_SF_1 =    2;
+
+enum SYMINFO_FLG_DIRECT =      0x0001;
+enum SYMINFO_FLG_PASSTHRU =    0x0002;
+enum SYMINFO_FLG_COPY =        0x0004;
+enum SYMINFO_FLG_LAZYLOAD =    0x0008;
+enum SYMINFO_FLG_DIRECTBIND =  0x0010;
+enum SYMINFO_FLG_NOEXTDIRECT = 0x0020;
+enum SYMINFO_FLG_FILTER =      0x0002;
+enum SYMINFO_FLG_AUXILIARY =   0x0040;
+
+enum SYMINFO_BT_SELF =         0xffff;
+enum SYMINFO_BT_PARENT =       0xfffe;
+enum SYMINFO_BT_NONE =         0xfffd;
+enum SYMINFO_BT_EXTERN =       0xfffc;
+enum SYMINFO_BT_LOWRESERVE =   0xff00;
+
+enum SYMINFO_NONE =            0;
+enum SYMINFO_CURRENT =         1;
+enum SYMINFO_NUM =             2;
+
+enum R_386_NONE =               0;
+enum R_386_32 =                 1;
+enum R_386_PC32 =               2;
+enum R_386_GOT32 =              3;
+enum R_386_PLT32 =              4;
+enum R_386_COPY =               5;
+enum R_386_GLOB_DAT =           6;
+enum R_386_JMP_SLOT =           7;
+enum R_386_RELATIVE =           8;
+enum R_386_GOTOFF =             9;
+enum R_386_GOTPC =              10;
+enum R_386_TLS_TPOFF =          14;
+enum R_386_TLS_IE =             15;
+enum R_386_TLS_GOTIE =          16;
+enum R_386_TLS_LE =             17;
+enum R_386_TLS_GD =             18;
+enum R_386_TLS_LDM =            19;
+enum R_386_TLS_GD_32 =          24;
+enum R_386_TLS_GD_PUSH =        25;
+enum R_386_TLS_GD_CALL =        26;
+enum R_386_TLS_GD_POP =         27;
+enum R_386_TLS_LDM_32 =         28;
+enum R_386_TLS_LDM_PUSH =       29;
+enum R_386_TLS_LDM_CALL =       30;
+enum R_386_TLS_LDM_POP =        31;
+enum R_386_TLS_LDO_32 =         32;
+enum R_386_TLS_IE_32 =          33;
+enum R_386_TLS_LE_32 =          34;
+enum R_386_TLS_DTPMOD32 =       35;
+enum R_386_TLS_DTPOFF32 =       36;
+enum R_386_TLS_TPOFF32 =        37;
+enum R_386_IRELATIVE =          42;
+
+enum R_ARM_NONE =               0;
+enum R_ARM_PC24 =               1;
+enum R_ARM_ABS32 =              2;
+enum R_ARM_REL32 =              3;
+enum R_ARM_PC13 =               4;
+enum R_ARM_ABS16 =              5;
+enum R_ARM_ABS12 =              6;
+enum R_ARM_THM_ABS5 =           7;
+enum R_ARM_ABS8 =               8;
+enum R_ARM_SBREL32 =            9;
+enum R_ARM_THM_PC22 =           10;
+enum R_ARM_THM_PC8 =            11;
+enum R_ARM_AMP_VCALL9 =         12;
+enum R_ARM_SWI24 =              13;
+enum R_ARM_THM_SWI8 =           14;
+enum R_ARM_XPC25 =              15;
+enum R_ARM_THM_XPC22 =          16;
+enum R_ARM_TLS_DTPMOD32 =       17;
+enum R_ARM_TLS_DTPOFF32 =       18;
+enum R_ARM_TLS_TPOFF32 =        19;
+enum R_ARM_COPY =               20;
+enum R_ARM_GLOB_DAT =           21;
+enum R_ARM_JUMP_SLOT =          22;
+enum R_ARM_RELATIVE =           23;
+enum R_ARM_GOTOFF =             24;
+enum R_ARM_GOTPC =              25;
+enum R_ARM_GOT32 =              26;
+enum R_ARM_PLT32 =              27;
+enum R_ARM_GNU_VTENTRY =        100;
+enum R_ARM_GNU_VTINHERIT =      101;
+enum R_ARM_RSBREL32 =           250;
+enum R_ARM_THM_RPC22 =          251;
+enum R_ARM_RREL32 =             252;
+enum R_ARM_RABS32 =             253;
+enum R_ARM_RPC24 =              254;
+enum R_ARM_RBASE =              255;
+
+enum R_IA_64_NONE =             0;
+enum R_IA_64_IMM14 =            0x21;
+enum R_IA_64_IMM22 =            0x22;
+enum R_IA_64_IMM64 =            0x23;
+enum R_IA_64_DIR32MSB =         0x24;
+enum R_IA_64_DIR32LSB =         0x25;
+enum R_IA_64_DIR64MSB =         0x26;
+enum R_IA_64_DIR64LSB =         0x27;
+enum R_IA_64_GPREL22 =          0x2a;
+enum R_IA_64_GPREL64I =         0x2b;
+enum R_IA_64_GPREL32MSB =       0x2c;
+enum R_IA_64_GPREL32LSB =       0x2d;
+enum R_IA_64_GPREL64MSB =       0x2e;
+enum R_IA_64_GPREL64LSB =       0x2f;
+enum R_IA_64_LTOFF22 =          0x32;
+enum R_IA_64_LTOFF64I =         0x33;
+enum R_IA_64_PLTOFF22 =         0x3a;
+enum R_IA_64_PLTOFF64I =        0x3b;
+enum R_IA_64_PLTOFF64MSB =      0x3e;
+enum R_IA_64_PLTOFF64LSB =      0x3f;
+enum R_IA_64_FPTR64I =          0x43;
+enum R_IA_64_FPTR32MSB =        0x44;
+enum R_IA_64_FPTR32LSB =        0x45;
+enum R_IA_64_FPTR64MSB =        0x46;
+enum R_IA_64_FPTR64LSB =        0x47;
+enum R_IA_64_PCREL60B =         0x48;
+enum R_IA_64_PCREL21B =         0x49;
+enum R_IA_64_PCREL21M =         0x4a;
+enum R_IA_64_PCREL21F =         0x4b;
+enum R_IA_64_PCREL32MSB =       0x4c;
+enum R_IA_64_PCREL32LSB =       0x4d;
+enum R_IA_64_PCREL64MSB =       0x4e;
+enum R_IA_64_PCREL64LSB =       0x4f;
+enum R_IA_64_LTOFF_FPTR22 =     0x52;
+enum R_IA_64_LTOFF_FPTR64I =    0x53;
+enum R_IA_64_LTOFF_FPTR32MSB =  0x54;
+enum R_IA_64_LTOFF_FPTR32LSB =  0x55;
+enum R_IA_64_LTOFF_FPTR64MSB =  0x56;
+enum R_IA_64_LTOFF_FPTR64LSB =  0x57;
+enum R_IA_64_SEGREL32MSB =      0x5c;
+enum R_IA_64_SEGREL32LSB =      0x5d;
+enum R_IA_64_SEGREL64MSB =      0x5e;
+enum R_IA_64_SEGREL64LSB =      0x5f;
+enum R_IA_64_SECREL32MSB =      0x64;
+enum R_IA_64_SECREL32LSB =      0x65;
+enum R_IA_64_SECREL64MSB =      0x66;
+enum R_IA_64_SECREL64LSB =      0x67;
+enum R_IA_64_REL32MSB =         0x6c;
+enum R_IA_64_REL32LSB =         0x6d;
+enum R_IA_64_REL64MSB =         0x6e;
+enum R_IA_64_REL64LSB =         0x6f;
+enum R_IA_64_LTV32MSB =         0x74;
+enum R_IA_64_LTV32LSB =         0x75;
+enum R_IA_64_LTV64MSB =         0x76;
+enum R_IA_64_LTV64LSB =         0x77;
+enum R_IA_64_PCREL21BI =        0x79;
+enum R_IA_64_PCREL22 =          0x7a;
+enum R_IA_64_PCREL64I =         0x7b;
+enum R_IA_64_IPLTMSB =          0x80;
+enum R_IA_64_IPLTLSB =          0x81;
+enum R_IA_64_SUB =              0x85;
+enum R_IA_64_LTOFF22X =         0x86;
+enum R_IA_64_LDXMOV =           0x87;
+enum R_IA_64_TPREL14 =          0x91;
+enum R_IA_64_TPREL22 =          0x92;
+enum R_IA_64_TPREL64I =         0x93;
+enum R_IA_64_TPREL64MSB =       0x96;
+enum R_IA_64_TPREL64LSB =       0x97;
+enum R_IA_64_LTOFF_TPREL22 =    0x9a;
+enum R_IA_64_DTPMOD64MSB =      0xa6;
+enum R_IA_64_DTPMOD64LSB =      0xa7;
+enum R_IA_64_LTOFF_DTPMOD22 =   0xaa;
+enum R_IA_64_DTPREL14 =         0xb1;
+enum R_IA_64_DTPREL22 =         0xb2;
+enum R_IA_64_DTPREL64I =        0xb3;
+enum R_IA_64_DTPREL32MSB =      0xb4;
+enum R_IA_64_DTPREL32LSB =      0xb5;
+enum R_IA_64_DTPREL64MSB =      0xb6;
+enum R_IA_64_DTPREL64LSB =      0xb7;
+enum R_IA_64_LTOFF_DTPREL22 =   0xba;
+
+enum R_MIPS_NONE =              0;
+enum R_MIPS_16 =                1;
+enum R_MIPS_32 =                2;
+enum R_MIPS_REL32 =             3;
+enum R_MIPS_26 =                4;
+enum R_MIPS_HI16 =              5;
+enum R_MIPS_LO16 =              6;
+enum R_MIPS_GPREL16 =           7;
+enum R_MIPS_LITERAL =           8;
+enum R_MIPS_GOT16 =             9;
+enum R_MIPS_PC16 =              10;
+enum R_MIPS_CALL16 =            11;
+enum R_MIPS_GPREL32 =           12;
+enum R_MIPS_GOTHI16 =           21;
+enum R_MIPS_GOTLO16 =           22;
+enum R_MIPS_CALLHI16 =          30;
+enum R_MIPS_CALLLO16 =          31;
+
+enum R_PPC_NONE =               0;
+enum R_PPC_ADDR32 =             1;
+enum R_PPC_ADDR24 =             2;
+enum R_PPC_ADDR16 =             3;
+enum R_PPC_ADDR16_LO =          4;
+enum R_PPC_ADDR16_HI =          5;
+enum R_PPC_ADDR16_HA =          6;
+enum R_PPC_ADDR14 =             7;
+enum R_PPC_ADDR14_BRTAKEN =     8;
+enum R_PPC_ADDR14_BRNTAKEN =    9;
+enum R_PPC_REL24 =              10;
+enum R_PPC_REL14 =              11;
+enum R_PPC_REL14_BRTAKEN =      12;
+enum R_PPC_REL14_BRNTAKEN =     13;
+enum R_PPC_GOT16 =              14;
+enum R_PPC_GOT16_LO =           15;
+enum R_PPC_GOT16_HI =           16;
+enum R_PPC_GOT16_HA =           17;
+enum R_PPC_PLTREL24 =           18;
+enum R_PPC_COPY =               19;
+enum R_PPC_GLOB_DAT =           20;
+enum R_PPC_JMP_SLOT =           21;
+enum R_PPC_RELATIVE =           22;
+enum R_PPC_LOCAL24PC =          23;
+enum R_PPC_UADDR32 =            24;
+enum R_PPC_UADDR16 =            25;
+enum R_PPC_REL32 =              26;
+enum R_PPC_PLT32 =              27;
+enum R_PPC_PLTREL32 =           28;
+enum R_PPC_PLT16_LO =           29;
+enum R_PPC_PLT16_HI =           30;
+enum R_PPC_PLT16_HA =           31;
+enum R_PPC_SDAREL16 =           32;
+enum R_PPC_SECTOFF =            33;
+enum R_PPC_SECTOFF_LO =         34;
+enum R_PPC_SECTOFF_HI =         35;
+enum R_PPC_SECTOFF_HA =         36;
+
+enum R_PPC64_ADDR64 =           38;
+enum R_PPC64_ADDR16_HIGHER =    39;
+enum R_PPC64_ADDR16_HIGHERA =   40;
+enum R_PPC64_ADDR16_HIGHEST =   41;
+enum R_PPC64_ADDR16_HIGHESTA =  42;
+enum R_PPC64_UADDR64 =          43;
+enum R_PPC64_REL64 =            44;
+enum R_PPC64_PLT64 =            45;
+enum R_PPC64_PLTREL64 =         46;
+enum R_PPC64_TOC16 =            47;
+enum R_PPC64_TOC16_LO =         48;
+enum R_PPC64_TOC16_HI =         49;
+enum R_PPC64_TOC16_HA =         50;
+enum R_PPC64_TOC =              51;
+enum R_PPC64_DTPMOD64 =         68;
+enum R_PPC64_TPREL64 =          73;
+enum R_PPC64_DTPREL64 =         78;
+
+enum R_PPC_TLS =                67;
+enum R_PPC_DTPMOD32 =           68;
+enum R_PPC_TPREL16 =            69;
+enum R_PPC_TPREL16_LO =         70;
+enum R_PPC_TPREL16_HI =         71;
+enum R_PPC_TPREL16_HA =         72;
+enum R_PPC_TPREL32 =            73;
+enum R_PPC_DTPREL16 =           74;
+enum R_PPC_DTPREL16_LO =        75;
+enum R_PPC_DTPREL16_HI =        76;
+enum R_PPC_DTPREL16_HA =        77;
+enum R_PPC_DTPREL32 =           78;
+enum R_PPC_GOT_TLSGD16 =        79;
+enum R_PPC_GOT_TLSGD16_LO =     80;
+enum R_PPC_GOT_TLSGD16_HI =     81;
+enum R_PPC_GOT_TLSGD16_HA =     82;
+enum R_PPC_GOT_TLSLD16 =        83;
+enum R_PPC_GOT_TLSLD16_LO =     84;
+enum R_PPC_GOT_TLSLD16_HI =     85;
+enum R_PPC_GOT_TLSLD16_HA =     86;
+enum R_PPC_GOT_TPREL16 =        87;
+enum R_PPC_GOT_TPREL16_LO =     88;
+enum R_PPC_GOT_TPREL16_HI =     89;
+enum R_PPC_GOT_TPREL16_HA =     90;
+
+enum R_PPC_EMB_NADDR32 =        101;
+enum R_PPC_EMB_NADDR16 =        102;
+enum R_PPC_EMB_NADDR16_LO =     103;
+enum R_PPC_EMB_NADDR16_HI =     104;
+enum R_PPC_EMB_NADDR16_HA =     105;
+enum R_PPC_EMB_SDAI16 =         106;
+enum R_PPC_EMB_SDA2I16 =        107;
+enum R_PPC_EMB_SDA2REL =        108;
+enum R_PPC_EMB_SDA21 =          109;
+enum R_PPC_EMB_MRKREF =         110;
+enum R_PPC_EMB_RELSEC16 =       111;
+enum R_PPC_EMB_RELST_LO =       112;
+enum R_PPC_EMB_RELST_HI =       113;
+enum R_PPC_EMB_RELST_HA =       114;
+enum R_PPC_EMB_BIT_FLD =        115;
+enum R_PPC_EMB_RELSDA =         116;
+
+enum R_SPARC_NONE =             0;
+enum R_SPARC_8 =                1;
+enum R_SPARC_16 =               2;
+enum R_SPARC_32 =               3;
+enum R_SPARC_DISP8 =            4;
+enum R_SPARC_DISP16 =           5;
+enum R_SPARC_DISP32 =           6;
+enum R_SPARC_WDISP30 =          7;
+enum R_SPARC_WDISP22 =          8;
+enum R_SPARC_HI22 =             9;
+enum R_SPARC_22 =               10;
+enum R_SPARC_13 =               11;
+enum R_SPARC_LO10 =             12;
+enum R_SPARC_GOT10 =            13;
+enum R_SPARC_GOT13 =            14;
+enum R_SPARC_GOT22 =            15;
+enum R_SPARC_PC10 =             16;
+enum R_SPARC_PC22 =             17;
+enum R_SPARC_WPLT30 =           18;
+enum R_SPARC_COPY =             19;
+enum R_SPARC_GLOB_DAT =         20;
+enum R_SPARC_JMP_SLOT =         21;
+enum R_SPARC_RELATIVE =         22;
+enum R_SPARC_UA32 =             23;
+enum R_SPARC_PLT32 =            24;
+enum R_SPARC_HIPLT22 =          25;
+enum R_SPARC_LOPLT10 =          26;
+enum R_SPARC_PCPLT32 =          27;
+enum R_SPARC_PCPLT22 =          28;
+enum R_SPARC_PCPLT10 =          29;
+enum R_SPARC_10 =               30;
+enum R_SPARC_11 =               31;
+enum R_SPARC_64 =               32;
+enum R_SPARC_OLO10 =            33;
+enum R_SPARC_HH22 =             34;
+enum R_SPARC_HM10 =             35;
+enum R_SPARC_LM22 =             36;
+enum R_SPARC_PC_HH22 =          37;
+enum R_SPARC_PC_HM10 =          38;
+enum R_SPARC_PC_LM22 =          39;
+enum R_SPARC_WDISP16 =          40;
+enum R_SPARC_WDISP19 =          41;
+enum R_SPARC_GLOB_JMP =         42;
+enum R_SPARC_7 =                43;
+enum R_SPARC_5 =                44;
+enum R_SPARC_6 =                45;
+enum R_SPARC_DISP64 =           46;
+enum R_SPARC_PLT64 =            47;
+enum R_SPARC_HIX22 =            48;
+enum R_SPARC_LOX10 =            49;
+enum R_SPARC_H44 =              50;
+enum R_SPARC_M44 =              51;
+enum R_SPARC_L44 =              52;
+enum R_SPARC_REGISTER =         53;
+enum R_SPARC_UA64 =             54;
+enum R_SPARC_UA16 =             55;
+enum R_SPARC_TLS_GD_HI22 =      56;
+enum R_SPARC_TLS_GD_LO10 =      57;
+enum R_SPARC_TLS_GD_ADD =       58;
+enum R_SPARC_TLS_GD_CALL =      59;
+enum R_SPARC_TLS_LDM_HI22 =     60;
+enum R_SPARC_TLS_LDM_LO10 =     61;
+enum R_SPARC_TLS_LDM_ADD =      62;
+enum R_SPARC_TLS_LDM_CALL =     63;
+enum R_SPARC_TLS_LDO_HIX22 =    64;
+enum R_SPARC_TLS_LDO_LOX10 =    65;
+enum R_SPARC_TLS_LDO_ADD =      66;
+enum R_SPARC_TLS_IE_HI22 =      67;
+enum R_SPARC_TLS_IE_LO10 =      68;
+enum R_SPARC_TLS_IE_LD =        69;
+enum R_SPARC_TLS_IE_LDX =       70;
+enum R_SPARC_TLS_IE_ADD =       71;
+enum R_SPARC_TLS_LE_HIX22 =     72;
+enum R_SPARC_TLS_LE_LOX10 =     73;
+enum R_SPARC_TLS_DTPMOD32 =     74;
+enum R_SPARC_TLS_DTPMOD64 =     75;
+enum R_SPARC_TLS_DTPOFF32 =     76;
+enum R_SPARC_TLS_DTPOFF64 =     77;
+enum R_SPARC_TLS_TPOFF32 =      78;
+enum R_SPARC_TLS_TPOFF64 =      79;
+
+enum R_X86_64_NONE =            0;
+enum R_X86_64_64 =              1;
+enum R_X86_64_PC32 =            2;
+enum R_X86_64_GOT32 =           3;
+enum R_X86_64_PLT32 =           4;
+enum R_X86_64_COPY =            5;
+enum R_X86_64_GLOB_DAT =        6;
+enum R_X86_64_JMP_SLOT =        7;
+enum R_X86_64_RELATIVE =        8;
+enum R_X86_64_GOTPCREL =        9;
+enum R_X86_64_32 =              10;
+enum R_X86_64_32S =             11;
+enum R_X86_64_16 =              12;
+enum R_X86_64_PC16 =            13;
+enum R_X86_64_8 =               14;
+enum R_X86_64_PC8 =             15;
+enum R_X86_64_DTPMOD64 =        16;
+enum R_X86_64_DTPOFF64 =        17;
+enum R_X86_64_TPOFF64 =         18;
+enum R_X86_64_TLSGD =           19;
+enum R_X86_64_TLSLD =           20;
+enum R_X86_64_DTPOFF32 =        21;
+enum R_X86_64_GOTTPOFF =        22;
+enum R_X86_64_TPOFF32 =         23;
+enum R_X86_64_IRELATIVE =       37;
diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/event.d b/libphobos/libdruntime/core/sys/freebsd/sys/event.d
new file mode 100644
index 00000000000..70f9822158c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/freebsd/sys/event.d
@@ -0,0 +1,130 @@
+/**
+ * D header file for FreeBSD.
+ *
+ * Copyright: Copyright Martin Nowak 2012.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ */
+
+/*          Copyright Martin Nowak 2012.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.freebsd.sys.event;
+
+version (FreeBSD):
+extern (C):
+
+import core.stdc.stdint;    // intptr_t, uintptr_t
+import core.sys.posix.time; // timespec
+
+enum
+{
+    EVFILT_READ     =  -1,
+    EVFILT_WRITE    =  -2,
+    EVFILT_AIO      =  -3, /* attached to aio requests */
+    EVFILT_VNODE    =  -4, /* attached to vnodes */
+    EVFILT_PROC     =  -5, /* attached to struct proc */
+    EVFILT_SIGNAL   =  -6, /* attached to struct proc */
+    EVFILT_TIMER    =  -7, /* timers */
+    // EVFILT_NETDEV   =  -8, /* no longer supported */
+    EVFILT_FS       =  -9, /* filesystem events */
+    EVFILT_LIO      = -10, /* attached to lio requests */
+    EVFILT_USER     = -11, /* User events */
+    EVFILT_SYSCOUNT =  11,
+}
+
+extern(D) void EV_SET(kevent_t* kevp, typeof(kevent_t.tupleof) args)
+{
+    *kevp = kevent_t(args);
+}
+
+struct kevent_t
+{
+    uintptr_t    ident; /* identifier for this event */
+    short       filter; /* filter for event */
+    ushort       flags;
+    uint        fflags;
+    intptr_t      data;
+    void        *udata; /* opaque user data identifier */
+}
+
+enum
+{
+    /* actions */
+    EV_ADD      = 0x0001, /* add event to kq (implies enable) */
+    EV_DELETE   = 0x0002, /* delete event from kq */
+    EV_ENABLE   = 0x0004, /* enable event */
+    EV_DISABLE  = 0x0008, /* disable event (not reported) */
+
+    /* flags */
+    EV_ONESHOT  = 0x0010, /* only report one occurrence */
+    EV_CLEAR    = 0x0020, /* clear event state after reporting */
+    EV_RECEIPT  = 0x0040, /* force EV_ERROR on success, data=0 */
+    EV_DISPATCH = 0x0080, /* disable event after reporting */
+
+    EV_SYSFLAGS = 0xF000, /* reserved by system */
+    EV_FLAG1    = 0x2000, /* filter-specific flag */
+
+    /* returned values */
+    EV_EOF      = 0x8000, /* EOF detected */
+    EV_ERROR    = 0x4000, /* error, data contains errno */
+}
+
+enum
+{
+    /*
+     * data/hint flags/masks for EVFILT_USER, shared with userspace
+     *
+     * On input, the top two bits of fflags specifies how the lower twenty four
+     * bits should be applied to the stored value of fflags.
+     *
+     * On output, the top two bits will always be set to NOTE_FFNOP and the
+     * remaining twenty four bits will contain the stored fflags value.
+     */
+    NOTE_FFNOP      = 0x00000000, /* ignore input fflags */
+    NOTE_FFAND      = 0x40000000, /* AND fflags */
+    NOTE_FFOR       = 0x80000000, /* OR fflags */
+    NOTE_FFCOPY     = 0xc0000000, /* copy fflags */
+    NOTE_FFCTRLMASK = 0xc0000000, /* masks for operations */
+    NOTE_FFLAGSMASK = 0x00ffffff,
+
+    NOTE_TRIGGER    = 0x01000000, /* Cause the event to be
+                                  triggered for output. */
+
+    /*
+     * data/hint flags for EVFILT_{READ|WRITE}, shared with userspace
+     */
+    NOTE_LOWAT      = 0x0001, /* low water mark */
+
+    /*
+     * data/hint flags for EVFILT_VNODE, shared with userspace
+     */
+    NOTE_DELETE     = 0x0001, /* vnode was removed */
+    NOTE_WRITE      = 0x0002, /* data contents changed */
+    NOTE_EXTEND     = 0x0004, /* size increased */
+    NOTE_ATTRIB     = 0x0008, /* attributes changed */
+    NOTE_LINK       = 0x0010, /* link count changed */
+    NOTE_RENAME     = 0x0020, /* vnode was renamed */
+    NOTE_REVOKE     = 0x0040, /* vnode access was revoked */
+
+    /*
+     * data/hint flags for EVFILT_PROC, shared with userspace
+     */
+    NOTE_EXIT       = 0x80000000, /* process exited */
+    NOTE_FORK       = 0x40000000, /* process forked */
+    NOTE_EXEC       = 0x20000000, /* process exec'd */
+    NOTE_PCTRLMASK  = 0xf0000000, /* mask for hint bits */
+    NOTE_PDATAMASK  = 0x000fffff, /* mask for pid */
+
+    /* additional flags for EVFILT_PROC */
+    NOTE_TRACK      = 0x00000001, /* follow across forks */
+    NOTE_TRACKERR   = 0x00000002, /* could not track child */
+    NOTE_CHILD      = 0x00000004, /* am a child process */
+}
+
+int kqueue();
+int kevent(int kq, const kevent_t *changelist, int nchanges,
+           kevent_t *eventlist, int nevents,
+           const timespec *timeout);
diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/link_elf.d b/libphobos/libdruntime/core/sys/freebsd/sys/link_elf.d
new file mode 100644
index 00000000000..13f9639501a
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/freebsd/sys/link_elf.d
@@ -0,0 +1,79 @@
+/**
+ * D header file for FreeBSD.
+ *
+ * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/link_elf.h?view=markup, sys/link_elf.h)
+ */
+module core.sys.freebsd.sys.link_elf;
+
+version (FreeBSD):
+extern (C):
+nothrow:
+
+import core.stdc.stdint : uint64_t;
+import core.sys.freebsd.sys.elf;
+
+version(D_LP64)
+    enum __ELF_NATIVE_CLASS = 64;
+else
+    enum __ELF_NATIVE_CLASS = 32;
+
+template ElfW(string type)
+{
+    mixin("alias Elf"~__ELF_NATIVE_CLASS.stringof~"_"~type~" ElfW;");
+}
+
+enum LA_SER_ORIG =      0x01;
+enum LA_SER_LIBPATH =   0x02;
+enum LA_SER_RUNPATH =   0x04;
+enum LA_SER_CONFIG =    0x08;
+enum LA_SER_DEFAULT =   0x40;
+enum LA_SER_SECURE =    0x80;
+
+struct link_map
+{
+    char*           l_addr;
+
+    version (MIPS32)
+        char*       l_offs;
+    version (MIPS64)
+        char*       l_offs;
+
+    char*           l_name;
+    void*           l_ld;
+    link_map*       l_next, l_prev;
+}
+alias link_map Link_map;
+
+enum
+{
+    RT_CONSISTENT,
+    RT_ADD,
+    RT_DELETE,
+}
+
+struct r_debug
+{
+    int             r_version;
+    link_map*       r_map;
+    void function(r_debug*, link_map*) r_brk;
+};
+
+struct dl_phdr_info
+{
+    ElfW!"Addr"     dlpi_addr;
+    char*           dlpi_name;
+    ElfW!"Phdr"*    dlpi_phdr;
+    ElfW!"Half"     dlpi_phnum;
+    uint64_t        dlpi_adds;
+    uint64_t        dlpi_subs;
+    size_t          dlpi_tls_modid;
+    void*           dlpi_tls_data;
+};
+
+
+private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb;
+private alias extern(C) int function(dl_phdr_info*, size_t, void *) @nogc dl_iterate_phdr_cb_ngc;
+extern int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data);
+extern int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc;
+extern int _rtld_addr_phdr(const void*, dl_phdr_info*) @nogc;
+extern int _rtld_get_stack_prot() @nogc;
diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/mman.d b/libphobos/libdruntime/core/sys/freebsd/sys/mman.d
new file mode 100644
index 00000000000..fb5100d8f73
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/freebsd/sys/mman.d
@@ -0,0 +1,143 @@
+/**
+ * D header file for FreeBSD
+ *
+ * Authors: Martin Nowak
+ */
+module core.sys.freebsd.sys.mman;
+
+version (FreeBSD):
+extern (C):
+nothrow:
+
+public import core.sys.posix.sys.mman;
+import core.sys.freebsd.sys.cdefs;
+import core.sys.posix.sys.types;
+// https://svnweb.freebsd.org/base/head/sys/sys/mman.h?revision=270825&view=markup
+
+static if (__BSD_VISIBLE)
+{
+    enum INHERIT_SHARE = 0;
+    enum INHERIT_COPY = 1;
+    enum INHERIT_NONE = 2;
+}
+
+// already in core.sys.posix.sys.mman
+// enum PROT_NONE = 0x00;
+// enum PROT_READ = 0x01;
+// enum PROT_WRITE = 0x02;
+// enum PROT_EXEC = 0x04;
+// enum MAP_SHARED = 0x0001;
+// enum MAP_PRIVATE = 0x0002;
+static if (__BSD_VISIBLE)
+    alias MAP_COPY = MAP_PRIVATE;
+// enum MAP_FIXED = 0x0010;
+
+static if (__BSD_VISIBLE)
+{
+    enum MAP_RENAME = 0x0020;
+    enum MAP_NORESERVE = 0x0040;
+    enum MAP_RESERVED0080 = 0x0080;
+    enum MAP_RESERVED0100 = 0x0100;
+    enum MAP_HASSEMAPHORE = 0x0200;
+    enum MAP_STACK = 0x0400;
+    enum MAP_NOSYNC = 0x0800;
+
+    enum MAP_FILE = 0x0000;
+
+    // already in core.sys.posix.sys.mman
+    // enum MAP_ANON = 0x1000;
+    //#ifndef _KERNEL
+    alias MAP_ANONYMOUS = MAP_ANON;
+    //#endif /* !_KERNEL */
+
+    enum MAP_EXCL = 0x00004000;
+    enum MAP_NOCORE = 0x00020000;
+    enum MAP_PREFAULT_READ = 0x00040000;
+    version (LP64)
+        enum MAP_32BIT = 0x00080000;
+
+
+    extern(D) int MAP_ALIGNED(int n) { return n << MAP_ALIGNMENT_SHIFT; }
+    enum MAP_ALIGNMENT_SHIFT = 24;
+    enum MAP_ALIGNMENT_MASK = MAP_ALIGNED(0xff);
+    enum MAP_ALIGNED_SUPER = MAP_ALIGNED(1);
+}
+
+static if (__POSIX_VISIBLE >= 199309)
+{
+    // already in core.sys.posix.sys.mman
+    // enum MCL_CURRENT = 0x0001;
+    // enum MCL_FUTURE = 0x0002;
+}
+
+// already in core.sys.posix.sys.mman
+enum MAP_FAILED = cast(void*)-1;
+
+// already in core.sys.posix.sys.mman
+// enum MS_SYNC = 0x0000;
+// enum MS_ASYNC = 0x0001;
+// enum MS_INVALIDATE = 0x0002;
+
+enum _MADV_NORMAL = 0;
+enum _MADV_RANDOM = 1;
+enum _MADV_SEQUENTIAL = 2;
+enum _MADV_WILLNEED = 3;
+enum _MADV_DONTNEED = 4;
+
+static if (__BSD_VISIBLE)
+{
+    alias MADV_NORMAL = _MADV_NORMAL;
+    alias MADV_RANDOM = _MADV_RANDOM;
+    alias MADV_SEQUENTIAL = _MADV_SEQUENTIAL;
+    alias MADV_WILLNEED = _MADV_WILLNEED;
+    alias MADV_DONTNEED = _MADV_DONTNEED;
+    enum MADV_FREE = 5;
+    enum MADV_NOSYNC = 6;
+    enum MADV_AUTOSYNC = 7;
+    enum MADV_NOCORE = 8;
+    enum MADV_CORE = 9;
+    enum MADV_PROTECT = 10;
+
+    enum MINCORE_INCORE = 0x1;
+    enum MINCORE_REFERENCED = 0x2;
+    enum MINCORE_MODIFIED = 0x4;
+    enum MINCORE_REFERENCED_OTHER = 0x8;
+    enum MINCORE_MODIFIED_OTHER = 0x10;
+    enum MINCORE_SUPER = 0x20;
+
+    enum SHM_ANON = cast(const(char) *)1;
+}
+
+static if (__POSIX_VISIBLE >= 200112)
+{
+    // already in core.sys.posix.sys.mman
+    // alias POSIX_MADV_NORMAL = _MADV_NORMAL;
+    // alias POSIX_MADV_RANDOM = _MADV_RANDOM;
+    // alias POSIX_MADV_SEQUENTIAL = _MADV_SEQUENTIAL;
+    // alias POSIX_MADV_WILLNEED = _MADV_WILLNEED;
+    // alias POSIX_MADV_DONTNEED = _MADV_DONTNEED;
+}
+
+static if (__BSD_VISIBLE)
+{
+    int getpagesizes(size_t *, int);
+    int madvise(void *, size_t, int);
+    int mincore(const(void) *, size_t, char *);
+    int minherit(void *, size_t, int);
+}
+// already in core.sys.posix.sys.mman
+// int mlock(const void *, size_t);
+// void *  mmap(void *, size_t, int, int, int, off_t);
+// int mprotect(const void *, size_t, int);
+// int msync(void *, size_t, int);
+// int munlock(const void *, size_t);
+// int munmap(void *, size_t);
+static if (__POSIX_VISIBLE >= 200112)
+    // int posix_madvise(void *, size_t, int);
+static if (__POSIX_VISIBLE >= 199309)
+{
+    // int mlockall(int);
+    // int munlockall();
+    // int shm_open(const(char) *, int, mode_t);
+    // int shm_unlink(const(char) *);
+}
diff --git a/libphobos/libdruntime/core/sys/freebsd/time.d b/libphobos/libdruntime/core/sys/freebsd/time.d
new file mode 100644
index 00000000000..8878ec95137
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/freebsd/time.d
@@ -0,0 +1,25 @@
+//Written in the D programming language
+
+/++
+    D header file for FreeBSD's extensions to POSIX's time.h.
+
+    Copyright: Copyright 2014
+    License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+    Authors:   Jonathan M Davis
+ +/
+module core.sys.freebsd.time;
+
+public import core.sys.posix.time;
+
+version(FreeBSD):
+
+enum CLOCK_VIRTUAL           = 1;
+enum CLOCK_PROF              = 2;
+enum CLOCK_UPTIME            = 5;
+enum CLOCK_UPTIME_PRECISE    = 7;
+enum CLOCK_UPTIME_FAST       = 8;
+enum CLOCK_REALTIME_PRECISE  = 9;
+enum CLOCK_REALTIME_FAST     = 10;
+enum CLOCK_MONOTONIC_PRECISE = 11;
+enum CLOCK_MONOTONIC_FAST    = 12;
+enum CLOCK_SECOND            = 13;
diff --git a/libphobos/libdruntime/core/sys/linux/config.d b/libphobos/libdruntime/core/sys/linux/config.d
new file mode 100644
index 00000000000..e867ecaf3bf
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/config.d
@@ -0,0 +1,28 @@
+/**
+ * D header file for GNU/Linux
+ *
+ * Authors: Martin Nowak
+ */
+module core.sys.linux.config;
+
+version (linux):
+
+public import core.sys.posix.config;
+
+// man 7 feature_test_macros
+// http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
+enum _GNU_SOURCE = true;
+// deduced <features.h>
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=include/features.h
+enum _BSD_SOURCE = true;
+enum _SVID_SOURCE = true;
+enum _ATFILE_SOURCE = true;
+
+enum __USE_MISC = _BSD_SOURCE || _SVID_SOURCE;
+enum __USE_BSD = _BSD_SOURCE;
+enum __USE_SVID = _SVID_SOURCE;
+enum __USE_ATFILE = _ATFILE_SOURCE;
+enum __USE_GNU = _GNU_SOURCE;
+
+// Available in bionic from API 21
+version(CRuntime_Bionic) enum __WORDSIZE = 32;
diff --git a/libphobos/libdruntime/core/sys/linux/dlfcn.d b/libphobos/libdruntime/core/sys/linux/dlfcn.d
new file mode 100644
index 00000000000..a3293c39562
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/dlfcn.d
@@ -0,0 +1,306 @@
+/**
+ * D header file for GNU/Linux
+ *
+ * $(LINK2 http://sourceware.org/git/?p=glibc.git;a=blob;f=dlfcn/dlfcn.h, glibc dlfcn/dlfcn.h)
+ */
+module core.sys.linux.dlfcn;
+
+version (linux):
+extern (C):
+nothrow:
+
+public import core.sys.posix.dlfcn;
+import core.sys.linux.config;
+
+// <bits/dlfcn.h>
+version (X86)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
+    // enum RTLD_LAZY = 0x00001; // POSIX
+    // enum RTLD_NOW = 0x00002; // POSIX
+    enum RTLD_BINDING_MASK = 0x3;
+    enum RTLD_NOLOAD = 0x00004;
+    enum RTLD_DEEPBIND = 0x00008;
+
+    // enum RTLD_GLOBAL = 0x00100; // POSIX
+    // enum RTLD_LOCAL = 0; // POSIX
+    enum RTLD_NODELETE = 0x01000;
+
+    static if (__USE_GNU)
+    {
+        RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
+        {
+            _dl_mcount_wrapper_check(cast(void*)fctp);
+            return fctp(args);
+        }
+
+        void _dl_mcount_wrapper_check(void* __selfpc);
+    }
+}
+else version (X86_64)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
+    // enum RTLD_LAZY = 0x00001; // POSIX
+    // enum RTLD_NOW = 0x00002; // POSIX
+    enum RTLD_BINDING_MASK = 0x3;
+    enum RTLD_NOLOAD = 0x00004;
+    enum RTLD_DEEPBIND = 0x00008;
+
+    // enum RTLD_GLOBAL = 0x00100; // POSIX
+    // enum RTLD_LOCAL = 0; // POSIX
+    enum RTLD_NODELETE = 0x01000;
+
+    static if (__USE_GNU)
+    {
+        RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
+        {
+            _dl_mcount_wrapper_check(cast(void*)fctp);
+            return fctp(args);
+        }
+
+        void _dl_mcount_wrapper_check(void* __selfpc);
+    }
+}
+else version (MIPS32)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/mips/bits/dlfcn.h
+    // enum RTLD_LAZY = 0x0001; // POSIX
+    // enum RTLD_NOW = 0x0002; // POSIX
+    enum RTLD_BINDING_MASK = 0x3;
+    enum RTLD_NOLOAD = 0x00008;
+    enum RTLD_DEEPBIND = 0x00010;
+
+    // enum RTLD_GLOBAL = 0x0004; // POSIX
+    // enum RTLD_LOCAL = 0; // POSIX
+    enum RTLD_NODELETE = 0x01000;
+
+    static if (__USE_GNU)
+    {
+        RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
+        {
+            _dl_mcount_wrapper_check(cast(void*)fctp);
+            return fctp(args);
+        }
+
+        void _dl_mcount_wrapper_check(void* __selfpc);
+    }
+}
+else version (MIPS64)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/mips/bits/dlfcn.h
+    // enum RTLD_LAZY = 0x0001; // POSIX
+    // enum RTLD_NOW = 0x0002; // POSIX
+    enum RTLD_BINDING_MASK = 0x3;
+    enum RTLD_NOLOAD = 0x00008;
+    enum RTLD_DEEPBIND = 0x00010;
+
+    // enum RTLD_GLOBAL = 0x0004; // POSIX
+    // enum RTLD_LOCAL = 0; // POSIX
+    enum RTLD_NODELETE = 0x01000;
+
+    static if (__USE_GNU)
+    {
+        RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
+        {
+            _dl_mcount_wrapper_check(cast(void*)fctp);
+            return fctp(args);
+        }
+
+        void _dl_mcount_wrapper_check(void* __selfpc);
+    }
+}
+else version (PPC)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
+    // enum RTLD_LAZY = 0x0001; // POSIX
+    // enum RTLD_NOW = 0x0002; // POSIX
+    enum RTLD_BINDING_MASK = 0x3;
+    enum RTLD_NOLOAD = 0x00004;
+    enum RTLD_DEEPBIND = 0x00008;
+
+    // enum RTLD_GLOBAL = 0x00100; // POSIX
+    // enum RTLD_LOCAL = 0; // POSIX
+    enum RTLD_NODELETE = 0x01000;
+
+    static if (__USE_GNU)
+    {
+        RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
+        {
+            _dl_mcount_wrapper_check(cast(void*)fctp);
+            return fctp(args);
+        }
+
+        void _dl_mcount_wrapper_check(void* __selfpc);
+    }
+}
+else version (PPC64)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
+    // enum RTLD_LAZY = 0x0001; // POSIX
+    // enum RTLD_NOW = 0x0002; // POSIX
+    enum RTLD_BINDING_MASK = 0x3;
+    enum RTLD_NOLOAD = 0x00004;
+    enum RTLD_DEEPBIND = 0x00008;
+
+    // enum RTLD_GLOBAL = 0x00100; // POSIX
+    // enum RTLD_LOCAL = 0; // POSIX
+    enum RTLD_NODELETE = 0x01000;
+
+    static if (__USE_GNU)
+    {
+        RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
+        {
+            _dl_mcount_wrapper_check(cast(void*)fctp);
+            return fctp(args);
+        }
+
+        void _dl_mcount_wrapper_check(void* __selfpc);
+    }
+}
+else version (ARM)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
+    // enum RTLD_LAZY = 0x0001; // POSIX
+    // enum RTLD_NOW = 0x0002; // POSIX
+    enum RTLD_BINDING_MASK = 0x3;
+    enum RTLD_NOLOAD = 0x00004;
+    enum RTLD_DEEPBIND = 0x00008;
+
+    // enum RTLD_GLOBAL = 0x00100; // POSIX
+    // enum RTLD_LOCAL = 0; // POSIX
+    enum RTLD_NODELETE = 0x01000;
+
+    static if (__USE_GNU)
+    {
+        RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
+        {
+            _dl_mcount_wrapper_check(cast(void*)fctp);
+            return fctp(args);
+        }
+
+        void _dl_mcount_wrapper_check(void* __selfpc);
+    }
+}
+else version (AArch64)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
+    // enum RTLD_LAZY = 0x0001; // POSIX
+    // enum RTLD_NOW = 0x0002; // POSIX
+    enum RTLD_BINDING_MASK = 0x3;
+    enum RTLD_NOLOAD = 0x00004;
+    enum RTLD_DEEPBIND = 0x00008;
+
+    // enum RTLD_GLOBAL = 0x00100; // POSIX
+    // enum RTLD_LOCAL = 0; // POSIX
+    enum RTLD_NODELETE = 0x01000;
+
+    static if (__USE_GNU)
+    {
+        RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
+        {
+            _dl_mcount_wrapper_check(cast(void*)fctp);
+            return fctp(args);
+        }
+
+        void _dl_mcount_wrapper_check(void* __selfpc);
+    }
+}
+else version (SystemZ)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h
+    // enum RTLD_LAZY = 0x0001; // POSIX
+    // enum RTLD_NOW = 0x0002; // POSIX
+    enum RTLD_BINDING_MASK = 0x3;
+    enum RTLD_NOLOAD = 0x00004;
+    enum RTLD_DEEPBIND = 0x00008;
+
+    // enum RTLD_GLOBAL = 0x00100; // POSIX
+    // enum RTLD_LOCAL = 0; // POSIX
+    enum RTLD_NODELETE = 0x01000;
+
+    static if (__USE_GNU)
+    {
+        RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args)
+        {
+            _dl_mcount_wrapper_check(cast(void*)fctp);
+            return fctp(args);
+        }
+
+        void _dl_mcount_wrapper_check(void* __selfpc);
+    }
+}
+else
+    static assert(0, "unimplemented");
+
+// <bits/dlfcn.h>
+
+static if (__USE_GNU)
+{
+    enum RTLD_NEXT = cast(void *)-1L;
+    enum RTLD_DEFAULT = cast(void *)0;
+    alias c_long Lmid_t;
+    enum LM_ID_BASE = 0;
+    enum LM_ID_NEWLM = -1;
+}
+
+// void* dlopen(in char* __file, int __mode); // POSIX
+// int dlclose(void* __handle); // POSIX
+// void* dlsym(void* __handle, in char* __name); // POSIX
+
+static if (__USE_GNU)
+{
+    void* dlmopen(Lmid_t __nsid, in char* __file, int __mode);
+    void* dlvsym(void* __handle, in char* __name, in char* __version);
+}
+
+// char* dlerror(); // POSIX
+
+static if (__USE_GNU)
+{
+    struct Dl_info
+    {
+        const(char)* dli_fname;
+        void* dli_fbase;
+        const(char)* dli_sname;
+        void* dli_saddr;
+    }
+
+    int dladdr(void* __address, Dl_info* __info);
+    int dladdr1(void* __address, Dl_info* __info, void** __extra_info, int __flags);
+
+    enum
+    {
+        RTLD_DL_SYMENT = 1,
+        RTLD_DL_LINKMAP = 2,
+    }
+
+    int dlinfo(void* __handle, int __request, void* __arg);
+
+    enum
+    {
+        RTLD_DI_LMID = 1,
+        RTLD_DI_LINKMAP = 2,
+        RTLD_DI_CONFIGADDR = 3,
+        RTLD_DI_SERINFO = 4,
+        RTLD_DI_SERINFOSIZE = 5,
+        RTLD_DI_ORIGIN = 6,
+        RTLD_DI_PROFILENAME = 7,
+        RTLD_DI_PROFILEOUT = 8,
+        RTLD_DI_TLS_MODID = 9,
+        RTLD_DI_TLS_DATA = 10,
+        RTLD_DI_MAX = 10,
+    }
+
+    struct Dl_serpath
+    {
+        char* dls_name;
+        uint dls_flags;
+    }
+
+    struct Dl_serinfo
+    {
+        size_t dls_size;
+        uint dls_cnt;
+        Dl_serpath[1] dls_serpath;
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/linux/elf.d b/libphobos/libdruntime/core/sys/linux/elf.d
new file mode 100644
index 00000000000..235806a38a1
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/elf.d
@@ -0,0 +1,2529 @@
+/**
+ * D header file for GNU/Linux
+ *
+ * $(LINK2 http://sourceware.org/git/?p=glibc.git;a=blob;f=elf/elf.h, glibc elf/elf.h)
+ */
+module core.sys.linux.elf;
+
+version (linux):
+extern (C):
+pure:
+nothrow:
+
+import core.stdc.stdint;
+
+alias uint16_t Elf32_Half;
+alias uint16_t Elf64_Half;
+
+alias uint32_t Elf32_Word;
+alias int32_t  Elf32_Sword;
+alias uint32_t Elf64_Word;
+alias int32_t  Elf64_Sword;
+
+alias uint64_t Elf32_Xword;
+alias int64_t  Elf32_Sxword;
+alias uint64_t Elf64_Xword;
+alias int64_t  Elf64_Sxword;
+
+alias uint32_t Elf32_Addr;
+alias uint64_t Elf64_Addr;
+
+alias uint32_t Elf32_Off;
+alias uint64_t Elf64_Off;
+
+alias uint16_t Elf32_Section;
+alias uint16_t Elf64_Section;
+
+alias Elf32_Half Elf32_Versym;
+alias Elf64_Half Elf64_Versym;
+
+
+enum EI_NIDENT = 16;
+
+struct Elf32_Ehdr
+{
+    char[EI_NIDENT] e_ident;
+    Elf32_Half    e_type;
+    Elf32_Half    e_machine;
+    Elf32_Word    e_version;
+    Elf32_Addr    e_entry;
+    Elf32_Off     e_phoff;
+    Elf32_Off     e_shoff;
+    Elf32_Word    e_flags;
+    Elf32_Half    e_ehsize;
+    Elf32_Half    e_phentsize;
+    Elf32_Half    e_phnum;
+    Elf32_Half    e_shentsize;
+    Elf32_Half    e_shnum;
+    Elf32_Half    e_shstrndx;
+}
+
+struct Elf64_Ehdr
+{
+    char[EI_NIDENT] e_ident;
+    Elf64_Half    e_type;
+    Elf64_Half    e_machine;
+    Elf64_Word    e_version;
+    Elf64_Addr    e_entry;
+    Elf64_Off     e_phoff;
+    Elf64_Off     e_shoff;
+    Elf64_Word    e_flags;
+    Elf64_Half    e_ehsize;
+    Elf64_Half    e_phentsize;
+    Elf64_Half    e_phnum;
+    Elf64_Half    e_shentsize;
+    Elf64_Half    e_shnum;
+    Elf64_Half    e_shstrndx;
+}
+
+enum EI_MAG0 =         0;
+enum ELFMAG0 =         0x7f;
+
+enum EI_MAG1 =         1;
+enum ELFMAG1 =         'E';
+
+enum EI_MAG2 =         2;
+enum ELFMAG2 =         'L';
+
+enum EI_MAG3 =         3;
+enum ELFMAG3 =         'F';
+enum ELFMAG =          "\177ELF";
+enum SELFMAG =         4;
+
+enum EI_CLASS =        4;
+enum ELFCLASSNONE =    0;
+enum ELFCLASS32 =      1;
+enum ELFCLASS64 =      2;
+enum ELFCLASSNUM =     3;
+
+enum EI_DATA =         5;
+enum ELFDATANONE =     0;
+enum ELFDATA2LSB =     1;
+enum ELFDATA2MSB =     2;
+enum ELFDATANUM =      3;
+
+enum EI_VERSION =      6;
+
+enum EI_OSABI =        7;
+enum ELFOSABI_NONE =           0;
+enum ELFOSABI_SYSV =           0;
+enum ELFOSABI_HPUX =           1;
+enum ELFOSABI_NETBSD =         2;
+enum ELFOSABI_GNU =            3;
+enum ELFOSABI_LINUX =          ELFOSABI_GNU;
+enum ELFOSABI_SOLARIS =        6;
+enum ELFOSABI_AIX =            7;
+enum ELFOSABI_IRIX =           8;
+enum ELFOSABI_FREEBSD =        9;
+enum ELFOSABI_TRU64 =          10;
+enum ELFOSABI_MODESTO =        11;
+enum ELFOSABI_OPENBSD =        12;
+enum ELFOSABI_ARM_AEABI =      64;
+enum ELFOSABI_ARM =            97;
+enum ELFOSABI_STANDALONE =     255;
+
+enum EI_ABIVERSION =   8;
+
+enum EI_PAD =          9;
+
+enum ET_NONE =         0;
+enum ET_REL =          1;
+enum ET_EXEC =         2;
+enum ET_DYN =          3;
+enum ET_CORE =         4;
+enum ET_NUM =          5;
+enum ET_LOOS =         0xfe00;
+enum ET_HIOS =         0xfeff;
+enum ET_LOPROC =       0xff00;
+enum ET_HIPROC =       0xffff;
+
+enum EM_NONE =          0;
+enum EM_M32 =           1;
+enum EM_SPARC =         2;
+enum EM_386 =           3;
+enum EM_68K =           4;
+enum EM_88K =           5;
+enum EM_860 =           7;
+enum EM_MIPS =          8;
+enum EM_S370 =          9;
+enum EM_MIPS_RS3_LE =  10;
+
+enum EM_PARISC =       15;
+enum EM_VPP500 =       17;
+enum EM_SPARC32PLUS =  18;
+enum EM_960 =          19;
+enum EM_PPC =          20;
+enum EM_PPC64 =        21;
+enum EM_S390 =         22;
+
+enum EM_V800 =         36;
+enum EM_FR20 =         37;
+enum EM_RH32 =         38;
+enum EM_RCE =          39;
+enum EM_ARM =          40;
+enum EM_FAKE_ALPHA =   41;
+enum EM_SH =           42;
+enum EM_SPARCV9 =      43;
+enum EM_TRICORE =      44;
+enum EM_ARC =          45;
+enum EM_H8_300 =       46;
+enum EM_H8_300H =      47;
+enum EM_H8S =          48;
+enum EM_H8_500 =       49;
+enum EM_IA_64 =        50;
+enum EM_MIPS_X =       51;
+enum EM_COLDFIRE =     52;
+enum EM_68HC12 =       53;
+enum EM_MMA =          54;
+enum EM_PCP =          55;
+enum EM_NCPU =         56;
+enum EM_NDR1 =         57;
+enum EM_STARCORE =     58;
+enum EM_ME16 =         59;
+enum EM_ST100 =        60;
+enum EM_TINYJ =        61;
+enum EM_X86_64 =       62;
+enum EM_PDSP =         63;
+
+enum EM_FX66 =         66;
+enum EM_ST9PLUS =      67;
+enum EM_ST7 =          68;
+enum EM_68HC16 =       69;
+enum EM_68HC11 =       70;
+enum EM_68HC08 =       71;
+enum EM_68HC05 =       72;
+enum EM_SVX =          73;
+enum EM_ST19 =         74;
+enum EM_VAX =          75;
+enum EM_CRIS =         76;
+enum EM_JAVELIN =      77;
+enum EM_FIREPATH =     78;
+enum EM_ZSP =          79;
+enum EM_MMIX =         80;
+enum EM_HUANY =        81;
+enum EM_PRISM =        82;
+enum EM_AVR =          83;
+enum EM_FR30 =         84;
+enum EM_D10V =         85;
+enum EM_D30V =         86;
+enum EM_V850 =         87;
+enum EM_M32R =         88;
+enum EM_MN10300 =      89;
+enum EM_MN10200 =      90;
+enum EM_PJ =           91;
+enum EM_OPENRISC =     92;
+enum EM_ARC_A5 =       93;
+enum EM_XTENSA =       94;
+enum EM_AARCH64 =      183;
+enum EM_TILEPRO =      188;
+enum EM_TILEGX =       191;
+enum EM_NUM =          192;
+
+enum EM_ALPHA =        0x9026;
+
+enum EV_NONE =         0;
+enum EV_CURRENT =      1;
+enum EV_NUM =          2;
+
+struct Elf32_Shdr
+{
+  Elf32_Word    sh_name;
+  Elf32_Word    sh_type;
+  Elf32_Word    sh_flags;
+  Elf32_Addr    sh_addr;
+  Elf32_Off     sh_offset;
+  Elf32_Word    sh_size;
+  Elf32_Word    sh_link;
+  Elf32_Word    sh_info;
+  Elf32_Word    sh_addralign;
+  Elf32_Word    sh_entsize;
+}
+
+struct Elf64_Shdr
+{
+  Elf64_Word    sh_name;
+  Elf64_Word    sh_type;
+  Elf64_Xword   sh_flags;
+  Elf64_Addr    sh_addr;
+  Elf64_Off     sh_offset;
+  Elf64_Xword   sh_size;
+  Elf64_Word    sh_link;
+  Elf64_Word    sh_info;
+  Elf64_Xword   sh_addralign;
+  Elf64_Xword   sh_entsize;
+}
+
+enum SHN_UNDEF =       0;
+enum SHN_LORESERVE =   0xff00;
+enum SHN_LOPROC =      0xff00;
+enum SHN_BEFORE =      0xff00;
+enum SHN_AFTER =       0xff01;
+enum SHN_HIPROC =      0xff1f;
+enum SHN_LOOS =        0xff20;
+enum SHN_HIOS =        0xff3f;
+enum SHN_ABS =         0xfff1;
+enum SHN_COMMON =      0xfff2;
+enum SHN_XINDEX =      0xffff;
+enum SHN_HIRESERVE =   0xffff;
+
+enum SHT_NULL =          0;
+enum SHT_PROGBITS =      1;
+enum SHT_SYMTAB =        2;
+enum SHT_STRTAB =        3;
+enum SHT_RELA =          4;
+enum SHT_HASH =          5;
+enum SHT_DYNAMIC =       6;
+enum SHT_NOTE =          7;
+enum SHT_NOBITS =        8;
+enum SHT_REL =           9;
+enum SHT_SHLIB =         10;
+enum SHT_DYNSYM =        11;
+enum SHT_INIT_ARRAY =    14;
+enum SHT_FINI_ARRAY =    15;
+enum SHT_PREINIT_ARRAY = 16;
+enum SHT_GROUP =         17;
+enum SHT_SYMTAB_SHNDX =  18;
+enum SHT_NUM =           19;
+enum SHT_LOOS =          0x60000000;
+enum SHT_GNU_ATTRIBUTES = 0x6ffffff5;
+enum SHT_GNU_HASH =      0x6ffffff6;
+enum SHT_GNU_LIBLIST =   0x6ffffff7;
+enum SHT_CHECKSUM =      0x6ffffff8;
+enum SHT_LOSUNW =        0x6ffffffa;
+enum SHT_SUNW_move =     0x6ffffffa;
+enum SHT_SUNW_COMDAT =   0x6ffffffb;
+enum SHT_SUNW_syminfo =  0x6ffffffc;
+enum SHT_GNU_verdef =    0x6ffffffd;
+enum SHT_GNU_verneed =   0x6ffffffe;
+enum SHT_GNU_versym =    0x6fffffff;
+enum SHT_HISUNW =        0x6fffffff;
+enum SHT_HIOS =          0x6fffffff;
+enum SHT_LOPROC =        0x70000000;
+enum SHT_HIPROC =        0x7fffffff;
+enum SHT_LOUSER =        0x80000000;
+enum SHT_HIUSER =        0x8fffffff;
+
+enum SHF_WRITE =            (1 << 0);
+enum SHF_ALLOC =            (1 << 1);
+enum SHF_EXECINSTR =        (1 << 2);
+enum SHF_MERGE =            (1 << 4);
+enum SHF_STRINGS =          (1 << 5);
+enum SHF_INFO_LINK =        (1 << 6);
+enum SHF_LINK_ORDER =       (1 << 7);
+enum SHF_OS_NONCONFORMING = (1 << 8);
+enum SHF_GROUP =            (1 << 9);
+enum SHF_TLS =              (1 << 10);
+enum SHF_MASKOS =           0x0ff00000;
+enum SHF_MASKPROC =         0xf0000000;
+enum SHF_ORDERED =          (1 << 30);
+enum SHF_EXCLUDE =          (1 << 31);
+enum GRP_COMDAT =      0x1;
+
+struct Elf32_Sym
+{
+  Elf32_Word    st_name;
+  Elf32_Addr    st_value;
+  Elf32_Word    st_size;
+  ubyte st_info;
+  ubyte st_other;
+  Elf32_Section st_shndx;
+}
+
+struct Elf64_Sym
+{
+  Elf64_Word    st_name;
+  ubyte st_info;
+  ubyte st_other;
+  Elf64_Section st_shndx;
+  Elf64_Addr    st_value;
+  Elf64_Xword   st_size;
+}
+
+struct Elf32_Syminfo
+{
+  Elf32_Half si_boundto;
+  Elf32_Half si_flags;
+}
+
+struct Elf64_Syminfo
+{
+  Elf64_Half si_boundto;
+  Elf64_Half si_flags;
+}
+enum SYMINFO_BT_SELF =         0xffff;
+enum SYMINFO_BT_PARENT =       0xfffe;
+enum SYMINFO_BT_LOWRESERVE =   0xff00;
+enum SYMINFO_FLG_DIRECT =      0x0001;
+enum SYMINFO_FLG_PASSTHRU =    0x0002;
+enum SYMINFO_FLG_COPY =        0x0004;
+enum SYMINFO_FLG_LAZYLOAD =    0x0008;
+enum SYMINFO_NONE =            0;
+enum SYMINFO_CURRENT =         1;
+enum SYMINFO_NUM =             2;
+
+extern (D)
+{
+    auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
+    auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; }
+    auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); }
+    alias ELF32_ST_BIND ELF64_ST_BIND;
+    alias ELF32_ST_TYPE ELF64_ST_TYPE;
+    alias ELF32_ST_INFO ELF64_ST_INFO;
+}
+
+enum STB_LOCAL =       0;
+enum STB_GLOBAL =      1;
+enum STB_WEAK =        2;
+enum STB_NUM =         3;
+enum STB_LOOS =        10;
+enum STB_GNU_UNIQUE =  10;
+enum STB_HIOS =        12;
+enum STB_LOPROC =      13;
+enum STB_HIPROC =      15;
+
+enum STT_NOTYPE =      0;
+enum STT_OBJECT =      1;
+enum STT_FUNC =        2;
+enum STT_SECTION =     3;
+enum STT_FILE =        4;
+enum STT_COMMON =      5;
+enum STT_TLS =         6;
+enum STT_NUM =         7;
+enum STT_LOOS =        10;
+enum STT_GNU_IFUNC =   10;
+enum STT_HIOS =        12;
+enum STT_LOPROC =      13;
+enum STT_HIPROC =      15;
+
+enum STN_UNDEF =       0;
+
+extern (D)
+{
+    auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; }
+    alias ELF32_ST_VISIBILITY ELF64_ST_VISIBILITY;
+}
+enum STV_DEFAULT =     0;
+enum STV_INTERNAL =    1;
+enum STV_HIDDEN =      2;
+enum STV_PROTECTED =   3;
+
+struct Elf32_Rel
+{
+  Elf32_Addr    r_offset;
+  Elf32_Word    r_info;
+}
+
+struct Elf64_Rel
+{
+  Elf64_Addr    r_offset;
+  Elf64_Xword   r_info;
+}
+
+struct Elf32_Rela
+{
+  Elf32_Addr    r_offset;
+  Elf32_Word    r_info;
+  Elf32_Sword   r_addend;
+}
+
+struct Elf64_Rela
+{
+  Elf64_Addr    r_offset;
+  Elf64_Xword   r_info;
+  Elf64_Sxword  r_addend;
+}
+
+extern (D)
+{
+    auto ELF32_R_SYM(V)(V val) { return val >> 8; }
+    auto ELF32_R_TYPE(V)(V val) { return val & 0xff; }
+    auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); }
+
+    auto ELF64_R_SYM(I)(I i) { return i >> 32; }
+    auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; }
+    auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type); }
+}
+
+struct Elf32_Phdr
+{
+  Elf32_Word    p_type;
+  Elf32_Off     p_offset;
+  Elf32_Addr    p_vaddr;
+  Elf32_Addr    p_paddr;
+  Elf32_Word    p_filesz;
+  Elf32_Word    p_memsz;
+  Elf32_Word    p_flags;
+  Elf32_Word    p_align;
+}
+
+struct Elf64_Phdr
+{
+  Elf64_Word    p_type;
+  Elf64_Word    p_flags;
+  Elf64_Off     p_offset;
+  Elf64_Addr    p_vaddr;
+  Elf64_Addr    p_paddr;
+  Elf64_Xword   p_filesz;
+  Elf64_Xword   p_memsz;
+  Elf64_Xword   p_align;
+}
+
+enum PN_XNUM =         0xffff;
+
+enum PT_NULL =         0;
+enum PT_LOAD =         1;
+enum PT_DYNAMIC =      2;
+enum PT_INTERP =       3;
+enum PT_NOTE =         4;
+enum PT_SHLIB =        5;
+enum PT_PHDR =         6;
+enum PT_TLS =          7;
+enum PT_NUM =          8;
+enum PT_LOOS =         0x60000000;
+enum PT_GNU_EH_FRAME = 0x6474e550;
+enum PT_GNU_STACK =    0x6474e551;
+enum PT_GNU_RELRO =    0x6474e552;
+enum PT_LOSUNW =       0x6ffffffa;
+enum PT_SUNWBSS =      0x6ffffffa;
+enum PT_SUNWSTACK =    0x6ffffffb;
+enum PT_HISUNW =       0x6fffffff;
+enum PT_HIOS =         0x6fffffff;
+enum PT_LOPROC =       0x70000000;
+enum PT_HIPROC =       0x7fffffff;
+
+enum PF_X =            (1 << 0);
+enum PF_W =            (1 << 1);
+enum PF_R =            (1 << 2);
+enum PF_MASKOS =       0x0ff00000;
+enum PF_MASKPROC =     0xf0000000;
+
+enum NT_PRSTATUS =     1;
+enum NT_FPREGSET =     2;
+enum NT_PRPSINFO =     3;
+enum NT_PRXREG =       4;
+enum NT_TASKSTRUCT =   4;
+enum NT_PLATFORM =     5;
+enum NT_AUXV =         6;
+enum NT_GWINDOWS =     7;
+enum NT_ASRS =         8;
+enum NT_PSTATUS =      10;
+enum NT_PSINFO =       13;
+enum NT_PRCRED =       14;
+enum NT_UTSNAME =      15;
+enum NT_LWPSTATUS =    16;
+enum NT_LWPSINFO =     17;
+enum NT_PRFPXREG =     20;
+enum NT_SIGINFO =      0x53494749;
+enum NT_FILE =         0x46494c45;
+enum NT_PRXFPREG =     0x46e62b7f;
+enum NT_PPC_VMX =      0x100;
+enum NT_PPC_SPE =      0x101;
+enum NT_PPC_VSX =      0x102;
+enum NT_386_TLS =      0x200;
+enum NT_386_IOPERM =   0x201;
+enum NT_X86_XSTATE =   0x202;
+enum NT_S390_HIGH_GPRS =       0x300;
+enum NT_S390_TIMER =   0x301;
+enum NT_S390_TODCMP =  0x302;
+enum NT_S390_TODPREG = 0x303;
+enum NT_S390_CTRS =    0x304;
+enum NT_S390_PREFIX =  0x305;
+enum NT_S390_LAST_BREAK =      0x306;
+enum NT_S390_SYSTEM_CALL =     0x307;
+enum NT_S390_TDB =     0x308;
+enum NT_ARM_VFP =      0x400;
+enum NT_ARM_TLS =      0x401;
+enum NT_ARM_HW_BREAK = 0x402;
+enum NT_ARM_HW_WATCH = 0x403;
+
+enum NT_VERSION =      1;
+
+struct Elf32_Dyn
+{
+  Elf32_Sword   d_tag;
+  union _d_un
+  {
+      Elf32_Word d_val;
+      Elf32_Addr d_ptr;
+  } _d_un d_un;
+}
+
+struct Elf64_Dyn
+{
+  Elf64_Sxword  d_tag;
+  union _d_un
+  {
+      Elf64_Xword d_val;
+      Elf64_Addr d_ptr;
+  } _d_un d_un;
+}
+
+enum DT_NULL =         0;
+enum DT_NEEDED =       1;
+enum DT_PLTRELSZ =     2;
+enum DT_PLTGOT =       3;
+enum DT_HASH =         4;
+enum DT_STRTAB =       5;
+enum DT_SYMTAB =       6;
+enum DT_RELA =         7;
+enum DT_RELASZ =       8;
+enum DT_RELAENT =      9;
+enum DT_STRSZ =        10;
+enum DT_SYMENT =       11;
+enum DT_INIT =         12;
+enum DT_FINI =         13;
+enum DT_SONAME =       14;
+enum DT_RPATH =        15;
+enum DT_SYMBOLIC =     16;
+enum DT_REL =          17;
+enum DT_RELSZ =        18;
+enum DT_RELENT =       19;
+enum DT_PLTREL =       20;
+enum DT_DEBUG =        21;
+enum DT_TEXTREL =      22;
+enum DT_JMPREL =       23;
+enum DT_BIND_NOW =     24;
+enum DT_INIT_ARRAY =   25;
+enum DT_FINI_ARRAY =   26;
+enum DT_INIT_ARRAYSZ = 27;
+enum DT_FINI_ARRAYSZ = 28;
+enum DT_RUNPATH =      29;
+enum DT_FLAGS =        30;
+enum DT_ENCODING =     32;
+enum DT_PREINIT_ARRAY = 32;
+enum DT_PREINIT_ARRAYSZ = 33;
+enum DT_NUM =          34;
+enum DT_LOOS =         0x6000000d;
+enum DT_HIOS =         0x6ffff000;
+enum DT_LOPROC =       0x70000000;
+enum DT_HIPROC =       0x7fffffff;
+enum DT_PROCNUM =      DT_MIPS_NUM;
+enum DT_VALRNGLO =     0x6ffffd00;
+enum DT_GNU_PRELINKED = 0x6ffffdf5;
+enum DT_GNU_CONFLICTSZ = 0x6ffffdf6;
+enum DT_GNU_LIBLISTSZ = 0x6ffffdf7;
+enum DT_CHECKSUM =     0x6ffffdf8;
+enum DT_PLTPADSZ =     0x6ffffdf9;
+enum DT_MOVEENT =      0x6ffffdfa;
+enum DT_MOVESZ =       0x6ffffdfb;
+enum DT_FEATURE_1 =    0x6ffffdfc;
+enum DT_POSFLAG_1 =    0x6ffffdfd;
+enum DT_SYMINSZ =      0x6ffffdfe;
+enum DT_SYMINENT =     0x6ffffdff;
+enum DT_VALRNGHI =     0x6ffffdff;
+extern (D) auto DT_VALTAGIDX(T)(T tag)
+{
+    return DT_VALRNGHI - tag;
+}
+enum DT_VALNUM = 12;
+enum DT_ADDRRNGLO =    0x6ffffe00;
+enum DT_GNU_HASH =     0x6ffffef5;
+enum DT_TLSDESC_PLT =  0x6ffffef6;
+enum DT_TLSDESC_GOT =  0x6ffffef7;
+enum DT_GNU_CONFLICT = 0x6ffffef8;
+enum DT_GNU_LIBLIST =  0x6ffffef9;
+enum DT_CONFIG =       0x6ffffefa;
+enum DT_DEPAUDIT =     0x6ffffefb;
+enum DT_AUDIT =        0x6ffffefc;
+enum DT_PLTPAD =       0x6ffffefd;
+enum DT_MOVETAB =      0x6ffffefe;
+enum DT_SYMINFO =      0x6ffffeff;
+enum DT_ADDRRNGHI =    0x6ffffeff;
+extern (D) auto DT_ADDRTAGIDX(T)(T tag)
+{
+    return DT_ADDRRNGHI - tag;
+}
+enum DT_ADDRNUM = 11;
+enum DT_VERSYM =       0x6ffffff0;
+
+enum DT_RELACOUNT =    0x6ffffff9;
+enum DT_RELCOUNT =     0x6ffffffa;
+enum DT_FLAGS_1 =      0x6ffffffb;
+enum DT_VERDEF =       0x6ffffffc;
+enum DT_VERDEFNUM =    0x6ffffffd;
+enum DT_VERNEED =      0x6ffffffe;
+enum DT_VERNEEDNUM =   0x6fffffff;
+extern (D) auto DT_VERSIONTAGIDX(T)(T tag)
+{
+    return DT_VERNEEDNUM - tag;
+}
+enum DT_VERSIONTAGNUM = 16;
+enum DT_AUXILIARY =    0x7ffffffd;
+enum DT_FILTER =       0x7fffffff;
+extern (D) auto DT_EXTRATAGIDX(T)(T tag)
+{
+    return cast(Elf32_Word)(-(cast(Elf32_Sword)(tag) <<1>>1)-1);
+}
+enum DT_EXTRANUM =     3;
+enum DF_ORIGIN =       0x00000001;
+enum DF_SYMBOLIC =     0x00000002;
+enum DF_TEXTREL =      0x00000004;
+enum DF_BIND_NOW =     0x00000008;
+enum DF_STATIC_TLS =   0x00000010;
+enum DF_1_NOW =        0x00000001;
+enum DF_1_GLOBAL =     0x00000002;
+enum DF_1_GROUP =      0x00000004;
+enum DF_1_NODELETE =   0x00000008;
+enum DF_1_LOADFLTR =   0x00000010;
+enum DF_1_INITFIRST =  0x00000020;
+enum DF_1_NOOPEN =     0x00000040;
+enum DF_1_ORIGIN =     0x00000080;
+enum DF_1_DIRECT =     0x00000100;
+enum DF_1_TRANS =      0x00000200;
+enum DF_1_INTERPOSE =  0x00000400;
+enum DF_1_NODEFLIB =   0x00000800;
+enum DF_1_NODUMP =     0x00001000;
+enum DF_1_CONFALT =    0x00002000;
+enum DF_1_ENDFILTEE =  0x00004000;
+enum DF_1_DISPRELDNE = 0x00008000;
+enum DF_1_DISPRELPND = 0x00010000;
+enum DF_1_NODIRECT =   0x00020000;
+enum DF_1_IGNMULDEF =  0x00040000;
+enum DF_1_NOKSYMS =    0x00080000;
+enum DF_1_NOHDR =      0x00100000;
+enum DF_1_EDITED =     0x00200000;
+enum DF_1_NORELOC =    0x00400000;
+enum DF_1_SYMINTPOSE = 0x00800000;
+enum DF_1_GLOBAUDIT =  0x01000000;
+enum DF_1_SINGLETON =  0x02000000;
+enum DTF_1_PARINIT =   0x00000001;
+enum DTF_1_CONFEXP =   0x00000002;
+enum DF_P1_LAZYLOAD =  0x00000001;
+enum DF_P1_GROUPPERM = 0x00000002;
+
+struct Elf32_Verdef
+{
+    Elf32_Half    vd_version;
+    Elf32_Half    vd_flags;
+    Elf32_Half    vd_ndx;
+    Elf32_Half    vd_cnt;
+    Elf32_Word    vd_hash;
+    Elf32_Word    vd_aux;
+    Elf32_Word    vd_next;
+}
+
+struct Elf64_Verdef
+{
+    Elf64_Half    vd_version;
+    Elf64_Half    vd_flags;
+    Elf64_Half    vd_ndx;
+    Elf64_Half    vd_cnt;
+    Elf64_Word    vd_hash;
+    Elf64_Word    vd_aux;
+    Elf64_Word    vd_next;
+}
+enum VER_DEF_NONE =    0;
+enum VER_DEF_CURRENT = 1;
+enum VER_DEF_NUM =     2;
+enum VER_FLG_BASE =    0x1;
+enum VER_FLG_WEAK =    0x2;
+enum VER_NDX_LOCAL =           0;
+enum VER_NDX_GLOBAL =          1;
+enum VER_NDX_LORESERVE =       0xff00;
+enum VER_NDX_ELIMINATE =       0xff01;
+
+struct Elf32_Verdaux
+{
+    Elf32_Word    vda_name;
+    Elf32_Word    vda_next;
+}
+
+struct Elf64_Verdaux
+{
+    Elf64_Word    vda_name;
+    Elf64_Word    vda_next;
+}
+
+struct Elf32_Verneed
+{
+    Elf32_Half    vn_version;
+    Elf32_Half    vn_cnt;
+    Elf32_Word    vn_file;
+    Elf32_Word    vn_aux;
+    Elf32_Word    vn_next;
+}
+
+struct Elf64_Verneed
+{
+    Elf64_Half    vn_version;
+    Elf64_Half    vn_cnt;
+    Elf64_Word    vn_file;
+    Elf64_Word    vn_aux;
+    Elf64_Word    vn_next;
+}
+enum VER_NEED_NONE =    0;
+enum VER_NEED_CURRENT = 1;
+enum VER_NEED_NUM =     2;
+
+struct Elf32_Vernaux
+{
+    Elf32_Word    vna_hash;
+    Elf32_Half    vna_flags;
+    Elf32_Half    vna_other;
+    Elf32_Word    vna_name;
+    Elf32_Word    vna_next;
+}
+
+struct Elf64_Vernaux
+{
+    Elf64_Word    vna_hash;
+    Elf64_Half    vna_flags;
+    Elf64_Half    vna_other;
+    Elf64_Word    vna_name;
+    Elf64_Word    vna_next;
+}
+// duplicate
+// enum VER_FLG_WEAK =    0x2;
+
+struct Elf32_auxv_t
+{
+    uint32_t a_type;
+    union _a_un
+    {
+        uint32_t a_val;
+    } _a_un a_un;
+}
+
+struct Elf64_auxv_t
+{
+    uint64_t a_type;
+    union _a_un
+    {
+        uint64_t a_val;
+    } _a_un a_un;
+}
+
+enum AT_NULL =         0;
+enum AT_IGNORE =       1;
+enum AT_EXECFD =       2;
+enum AT_PHDR =         3;
+enum AT_PHENT =        4;
+enum AT_PHNUM =        5;
+enum AT_PAGESZ =       6;
+enum AT_BASE =         7;
+enum AT_FLAGS =        8;
+enum AT_ENTRY =        9;
+enum AT_NOTELF =       10;
+enum AT_UID =          11;
+enum AT_EUID =         12;
+enum AT_GID =          13;
+enum AT_EGID =         14;
+enum AT_CLKTCK =       17;
+enum AT_PLATFORM =     15;
+enum AT_HWCAP =        16;
+enum AT_FPUCW =        18;
+enum AT_DCACHEBSIZE =  19;
+enum AT_ICACHEBSIZE =  20;
+enum AT_UCACHEBSIZE =  21;
+enum AT_IGNOREPPC =    22;
+
+enum AT_SECURE =       23;
+
+enum AT_BASE_PLATFORM = 24;
+
+enum AT_RANDOM =       25;
+
+enum AT_EXECFN =       31;
+enum AT_SYSINFO =      32;
+enum AT_SYSINFO_EHDR = 33;
+
+;
+enum AT_L1I_CACHESHAPE =       34;
+enum AT_L1D_CACHESHAPE =       35;
+enum AT_L2_CACHESHAPE =        36;
+enum AT_L3_CACHESHAPE =        37;
+
+struct Elf32_Nhdr
+{
+  Elf32_Word n_namesz;
+  Elf32_Word n_descsz;
+  Elf32_Word n_type;
+}
+
+struct Elf64_Nhdr
+{
+  Elf64_Word n_namesz;
+  Elf64_Word n_descsz;
+  Elf64_Word n_type;
+}
+enum ELF_NOTE_SOLARIS =        "SUNW Solaris";
+enum ELF_NOTE_GNU =            "GNU";
+enum ELF_NOTE_PAGESIZE_HINT =  1;
+enum NT_GNU_ABI_TAG =  1;
+enum ELF_NOTE_ABI =    NT_GNU_ABI_TAG;
+enum ELF_NOTE_OS_LINUX =       0;
+enum ELF_NOTE_OS_GNU =         1;
+enum ELF_NOTE_OS_SOLARIS2 =    2;
+enum ELF_NOTE_OS_FREEBSD =     3;
+enum NT_GNU_HWCAP =    2;
+enum NT_GNU_BUILD_ID = 3;
+enum NT_GNU_GOLD_VERSION =     4;
+struct Elf32_Move
+{
+  Elf32_Xword m_value;
+  Elf32_Word m_info;
+  Elf32_Word m_poffset;
+  Elf32_Half m_repeat;
+  Elf32_Half m_stride;
+}
+
+struct Elf64_Move
+{
+  Elf64_Xword m_value;
+  Elf64_Xword m_info;
+  Elf64_Xword m_poffset;
+  Elf64_Half m_repeat;
+  Elf64_Half m_stride;
+}
+extern (D)
+{
+    auto ELF32_M_SYM(I)(I info) { return info >> 8; }
+    auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; }
+    auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; }
+}
+
+alias ELF32_M_SYM ELF64_M_SYM;
+alias ELF32_M_SIZE ELF64_M_SIZE;
+alias ELF32_M_INFO ELF64_M_INFO;
+enum EF_CPU32 =        0x00810000;
+
+enum R_68K_NONE =      0;
+enum R_68K_32 =        1;
+enum R_68K_16 =        2;
+enum R_68K_8 =         3;
+enum R_68K_PC32 =      4;
+enum R_68K_PC16 =      5;
+enum R_68K_PC8 =       6;
+enum R_68K_GOT32 =     7;
+enum R_68K_GOT16 =     8;
+enum R_68K_GOT8 =      9;
+enum R_68K_GOT32O =    10;
+enum R_68K_GOT16O =    11;
+enum R_68K_GOT8O =     12;
+enum R_68K_PLT32 =     13;
+enum R_68K_PLT16 =     14;
+enum R_68K_PLT8 =      15;
+enum R_68K_PLT32O =    16;
+enum R_68K_PLT16O =    17;
+enum R_68K_PLT8O =     18;
+enum R_68K_COPY =      19;
+enum R_68K_GLOB_DAT =  20;
+enum R_68K_JMP_SLOT =  21;
+enum R_68K_RELATIVE =  22;
+enum R_68K_TLS_GD32 =      25;
+enum R_68K_TLS_GD16 =      26;
+enum R_68K_TLS_GD8 =       27;
+enum R_68K_TLS_LDM32 =     28;
+enum R_68K_TLS_LDM16 =     29;
+enum R_68K_TLS_LDM8 =      30;
+enum R_68K_TLS_LDO32 =     31;
+enum R_68K_TLS_LDO16 =     32;
+enum R_68K_TLS_LDO8 =      33;
+enum R_68K_TLS_IE32 =      34;
+enum R_68K_TLS_IE16 =      35;
+enum R_68K_TLS_IE8 =       36;
+enum R_68K_TLS_LE32 =      37;
+enum R_68K_TLS_LE16 =      38;
+enum R_68K_TLS_LE8 =       39;
+enum R_68K_TLS_DTPMOD32 =  40;
+enum R_68K_TLS_DTPREL32 =  41;
+enum R_68K_TLS_TPREL32 =   42;
+enum R_68K_NUM =       43;
+
+enum R_386_NONE =         0;
+enum R_386_32 =           1;
+enum R_386_PC32 =         2;
+enum R_386_GOT32 =        3;
+enum R_386_PLT32 =        4;
+enum R_386_COPY =         5;
+enum R_386_GLOB_DAT =     6;
+enum R_386_JMP_SLOT =     7;
+enum R_386_RELATIVE =     8;
+enum R_386_GOTOFF =       9;
+enum R_386_GOTPC =        10;
+enum R_386_32PLT =        11;
+enum R_386_TLS_TPOFF =    14;
+enum R_386_TLS_IE =       15;
+enum R_386_TLS_GOTIE =    16;
+enum R_386_TLS_LE =       17;
+enum R_386_TLS_GD =       18;
+enum R_386_TLS_LDM =      19;
+enum R_386_16 =           20;
+enum R_386_PC16 =         21;
+enum R_386_8 =            22;
+enum R_386_PC8 =          23;
+enum R_386_TLS_GD_32 =    24;
+enum R_386_TLS_GD_PUSH =  25;
+enum R_386_TLS_GD_CALL =  26;
+enum R_386_TLS_GD_POP =   27;
+enum R_386_TLS_LDM_32 =   28;
+enum R_386_TLS_LDM_PUSH = 29;
+enum R_386_TLS_LDM_CALL = 30;
+enum R_386_TLS_LDM_POP =  31;
+enum R_386_TLS_LDO_32 =   32;
+enum R_386_TLS_IE_32 =    33;
+enum R_386_TLS_LE_32 =    34;
+enum R_386_TLS_DTPMOD32 = 35;
+enum R_386_TLS_DTPOFF32 = 36;
+enum R_386_TLS_TPOFF32 =  37;
+enum R_386_SIZE32 =       38;
+enum R_386_TLS_GOTDESC =  39;
+enum R_386_TLS_DESC_CALL = 40;
+enum R_386_TLS_DESC =     41;
+enum R_386_IRELATIVE =    42;
+enum R_386_NUM =          43;
+
+enum STT_SPARC_REGISTER =      13;
+
+enum EF_SPARCV9_MM =           3;
+enum EF_SPARCV9_TSO =          0;
+enum EF_SPARCV9_PSO =          1;
+enum EF_SPARCV9_RMO =          2;
+enum EF_SPARC_LEDATA =         0x800000;
+enum EF_SPARC_EXT_MASK =       0xFFFF00;
+enum EF_SPARC_32PLUS =         0x000100;
+enum EF_SPARC_SUN_US1 =        0x000200;
+enum EF_SPARC_HAL_R1 =         0x000400;
+enum EF_SPARC_SUN_US3 =        0x000800;
+
+enum R_SPARC_NONE =            0;
+enum R_SPARC_8 =               1;
+enum R_SPARC_16 =              2;
+enum R_SPARC_32 =              3;
+enum R_SPARC_DISP8 =           4;
+enum R_SPARC_DISP16 =          5;
+enum R_SPARC_DISP32 =          6;
+enum R_SPARC_WDISP30 =         7;
+enum R_SPARC_WDISP22 =         8;
+enum R_SPARC_HI22 =            9;
+enum R_SPARC_22 =              10;
+enum R_SPARC_13 =              11;
+enum R_SPARC_LO10 =            12;
+enum R_SPARC_GOT10 =           13;
+enum R_SPARC_GOT13 =           14;
+enum R_SPARC_GOT22 =           15;
+enum R_SPARC_PC10 =            16;
+enum R_SPARC_PC22 =            17;
+enum R_SPARC_WPLT30 =          18;
+enum R_SPARC_COPY =            19;
+enum R_SPARC_GLOB_DAT =        20;
+enum R_SPARC_JMP_SLOT =        21;
+enum R_SPARC_RELATIVE =        22;
+enum R_SPARC_UA32 =            23;
+
+enum R_SPARC_PLT32 =           24;
+enum R_SPARC_HIPLT22 =         25;
+enum R_SPARC_LOPLT10 =         26;
+enum R_SPARC_PCPLT32 =         27;
+enum R_SPARC_PCPLT22 =         28;
+enum R_SPARC_PCPLT10 =         29;
+enum R_SPARC_10 =              30;
+enum R_SPARC_11 =              31;
+enum R_SPARC_64 =              32;
+enum R_SPARC_OLO10 =           33;
+enum R_SPARC_HH22 =            34;
+enum R_SPARC_HM10 =            35;
+enum R_SPARC_LM22 =            36;
+enum R_SPARC_PC_HH22 =         37;
+enum R_SPARC_PC_HM10 =         38;
+enum R_SPARC_PC_LM22 =         39;
+enum R_SPARC_WDISP16 =         40;
+enum R_SPARC_WDISP19 =         41;
+enum R_SPARC_GLOB_JMP =        42;
+enum R_SPARC_7 =               43;
+enum R_SPARC_5 =               44;
+enum R_SPARC_6 =               45;
+enum R_SPARC_DISP64 =          46;
+enum R_SPARC_PLT64 =           47;
+enum R_SPARC_HIX22 =           48;
+enum R_SPARC_LOX10 =           49;
+enum R_SPARC_H44 =             50;
+enum R_SPARC_M44 =             51;
+enum R_SPARC_L44 =             52;
+enum R_SPARC_REGISTER =        53;
+enum R_SPARC_UA64 =            54;
+enum R_SPARC_UA16 =            55;
+enum R_SPARC_TLS_GD_HI22 =     56;
+enum R_SPARC_TLS_GD_LO10 =     57;
+enum R_SPARC_TLS_GD_ADD =      58;
+enum R_SPARC_TLS_GD_CALL =     59;
+enum R_SPARC_TLS_LDM_HI22 =    60;
+enum R_SPARC_TLS_LDM_LO10 =    61;
+enum R_SPARC_TLS_LDM_ADD =     62;
+enum R_SPARC_TLS_LDM_CALL =    63;
+enum R_SPARC_TLS_LDO_HIX22 =   64;
+enum R_SPARC_TLS_LDO_LOX10 =   65;
+enum R_SPARC_TLS_LDO_ADD =     66;
+enum R_SPARC_TLS_IE_HI22 =     67;
+enum R_SPARC_TLS_IE_LO10 =     68;
+enum R_SPARC_TLS_IE_LD =       69;
+enum R_SPARC_TLS_IE_LDX =      70;
+enum R_SPARC_TLS_IE_ADD =      71;
+enum R_SPARC_TLS_LE_HIX22 =    72;
+enum R_SPARC_TLS_LE_LOX10 =    73;
+enum R_SPARC_TLS_DTPMOD32 =    74;
+enum R_SPARC_TLS_DTPMOD64 =    75;
+enum R_SPARC_TLS_DTPOFF32 =    76;
+enum R_SPARC_TLS_DTPOFF64 =    77;
+enum R_SPARC_TLS_TPOFF32 =     78;
+enum R_SPARC_TLS_TPOFF64 =     79;
+enum R_SPARC_GOTDATA_HIX22 =   80;
+enum R_SPARC_GOTDATA_LOX10 =   81;
+enum R_SPARC_GOTDATA_OP_HIX22 =        82;
+enum R_SPARC_GOTDATA_OP_LOX10 =        83;
+enum R_SPARC_GOTDATA_OP =      84;
+enum R_SPARC_H34 =             85;
+enum R_SPARC_SIZE32 =          86;
+enum R_SPARC_SIZE64 =          87;
+enum R_SPARC_WDISP10 =         88;
+enum R_SPARC_JMP_IREL =        248;
+enum R_SPARC_IRELATIVE =       249;
+enum R_SPARC_GNU_VTINHERIT =   250;
+enum R_SPARC_GNU_VTENTRY =     251;
+enum R_SPARC_REV32 =           252;
+enum R_SPARC_NUM =             253;
+
+enum DT_SPARC_REGISTER =       0x70000001;
+enum DT_SPARC_NUM =            2;
+
+enum EF_MIPS_NOREORDER =       1;
+enum EF_MIPS_PIC =             2;
+enum EF_MIPS_CPIC =            4;
+enum EF_MIPS_XGOT =            8;
+enum EF_MIPS_64BIT_WHIRL =     16;
+enum EF_MIPS_ABI2 =            32;
+enum EF_MIPS_ABI_ON32 =        64;
+enum EF_MIPS_ARCH =            0xf0000000;
+
+enum EF_MIPS_ARCH_1 =          0x00000000;
+enum EF_MIPS_ARCH_2 =          0x10000000;
+enum EF_MIPS_ARCH_3 =          0x20000000;
+enum EF_MIPS_ARCH_4 =          0x30000000;
+enum EF_MIPS_ARCH_5 =          0x40000000;
+enum EF_MIPS_ARCH_32 =         0x50000000;
+enum EF_MIPS_ARCH_64 =         0x60000000;
+enum EF_MIPS_ARCH_32R2 =       0x70000000;
+enum EF_MIPS_ARCH_64R2 =       0x80000000;
+
+enum E_MIPS_ARCH_1 =           EF_MIPS_ARCH_1;
+enum E_MIPS_ARCH_2 =           EF_MIPS_ARCH_2;
+enum E_MIPS_ARCH_3 =           EF_MIPS_ARCH_3;
+enum E_MIPS_ARCH_4 =           EF_MIPS_ARCH_4;
+enum E_MIPS_ARCH_5 =           EF_MIPS_ARCH_5;
+enum E_MIPS_ARCH_32 =          EF_MIPS_ARCH_32;
+enum E_MIPS_ARCH_64 =          EF_MIPS_ARCH_64;
+
+enum SHN_MIPS_ACOMMON =        0xff00;
+enum SHN_MIPS_TEXT =           0xff01;
+enum SHN_MIPS_DATA =           0xff02;
+enum SHN_MIPS_SCOMMON =        0xff03;
+enum SHN_MIPS_SUNDEFINED =     0xff04;
+
+enum SHT_MIPS_LIBLIST =        0x70000000;
+enum SHT_MIPS_MSYM =           0x70000001;
+enum SHT_MIPS_CONFLICT =       0x70000002;
+enum SHT_MIPS_GPTAB =          0x70000003;
+enum SHT_MIPS_UCODE =          0x70000004;
+enum SHT_MIPS_DEBUG =          0x70000005;
+enum SHT_MIPS_REGINFO =        0x70000006;
+enum SHT_MIPS_PACKAGE =        0x70000007;
+enum SHT_MIPS_PACKSYM =        0x70000008;
+enum SHT_MIPS_RELD =           0x70000009;
+enum SHT_MIPS_IFACE =          0x7000000b;
+enum SHT_MIPS_CONTENT =        0x7000000c;
+enum SHT_MIPS_OPTIONS =        0x7000000d;
+enum SHT_MIPS_SHDR =           0x70000010;
+enum SHT_MIPS_FDESC =          0x70000011;
+enum SHT_MIPS_EXTSYM =         0x70000012;
+enum SHT_MIPS_DENSE =          0x70000013;
+enum SHT_MIPS_PDESC =          0x70000014;
+enum SHT_MIPS_LOCSYM =         0x70000015;
+enum SHT_MIPS_AUXSYM =         0x70000016;
+enum SHT_MIPS_OPTSYM =         0x70000017;
+enum SHT_MIPS_LOCSTR =         0x70000018;
+enum SHT_MIPS_LINE =           0x70000019;
+enum SHT_MIPS_RFDESC =         0x7000001a;
+enum SHT_MIPS_DELTASYM =       0x7000001b;
+enum SHT_MIPS_DELTAINST =      0x7000001c;
+enum SHT_MIPS_DELTACLASS =     0x7000001d;
+enum SHT_MIPS_DWARF =          0x7000001e;
+enum SHT_MIPS_DELTADECL =      0x7000001f;
+enum SHT_MIPS_SYMBOL_LIB =     0x70000020;
+enum SHT_MIPS_EVENTS =         0x70000021;
+enum SHT_MIPS_TRANSLATE =      0x70000022;
+enum SHT_MIPS_PIXIE =          0x70000023;
+enum SHT_MIPS_XLATE =          0x70000024;
+enum SHT_MIPS_XLATE_DEBUG =    0x70000025;
+enum SHT_MIPS_WHIRL =          0x70000026;
+enum SHT_MIPS_EH_REGION =      0x70000027;
+enum SHT_MIPS_XLATE_OLD =      0x70000028;
+enum SHT_MIPS_PDR_EXCEPTION =  0x70000029;
+
+enum SHF_MIPS_GPREL =          0x10000000;
+enum SHF_MIPS_MERGE =          0x20000000;
+enum SHF_MIPS_ADDR =           0x40000000;
+enum SHF_MIPS_STRINGS =        0x80000000;
+enum SHF_MIPS_NOSTRIP =        0x08000000;
+enum SHF_MIPS_LOCAL =          0x04000000;
+enum SHF_MIPS_NAMES =          0x02000000;
+enum SHF_MIPS_NODUPE =         0x01000000;
+enum STO_MIPS_DEFAULT =                0x0;
+enum STO_MIPS_INTERNAL =               0x1;
+enum STO_MIPS_HIDDEN =                 0x2;
+enum STO_MIPS_PROTECTED =              0x3;
+enum STO_MIPS_PLT =                    0x8;
+enum STO_MIPS_SC_ALIGN_UNUSED =        0xff;
+enum STB_MIPS_SPLIT_COMMON =           13;
+
+union Elf32_gptab
+{
+    struct _gt_header
+    {
+        Elf32_Word gt_current_g_value;
+        Elf32_Word gt_unused;
+    } _gt_header gt_header;
+    struct _gt_entry
+    {
+        Elf32_Word gt_g_value;
+        Elf32_Word gt_bytes;
+    } _gt_entry gt_entry;
+}
+
+struct Elf32_RegInfo
+{
+    Elf32_Word ri_gprmask;
+    Elf32_Word[4] ri_cprmask;
+    Elf32_Sword ri_gp_value;
+}
+
+struct Elf_Options
+{
+    ubyte kind;
+    ubyte size;
+    Elf32_Section section;
+    Elf32_Word info;
+}
+
+enum ODK_NULL =        0;
+enum ODK_REGINFO =     1;
+enum ODK_EXCEPTIONS =  2;
+enum ODK_PAD =         3;
+enum ODK_HWPATCH =     4;
+enum ODK_FILL =        5;
+enum ODK_TAGS =        6;
+enum ODK_HWAND =       7;
+enum ODK_HWOR =        8;
+
+enum OEX_FPU_MIN =     0x1f;
+enum OEX_FPU_MAX =     0x1f00;
+enum OEX_PAGE0 =       0x10000;
+enum OEX_SMM =         0x20000;
+enum OEX_FPDBUG =      0x40000;
+enum OEX_PRECISEFP =   OEX_FPDBUG;
+enum OEX_DISMISS =     0x80000;
+
+enum OEX_FPU_INVAL =   0x10;
+enum OEX_FPU_DIV0 =    0x08;
+enum OEX_FPU_OFLO =    0x04;
+enum OEX_FPU_UFLO =    0x02;
+enum OEX_FPU_INEX =    0x01;
+
+enum OHW_R4KEOP =      0x1;
+enum OHW_R8KPFETCH =   0x2;
+enum OHW_R5KEOP =      0x4;
+enum OHW_R5KCVTL =     0x8;
+
+enum OPAD_PREFIX =     0x1;
+enum OPAD_POSTFIX =    0x2;
+enum OPAD_SYMBOL =     0x4;
+
+struct Elf_Options_Hw
+{
+    Elf32_Word hwp_flags1;
+    Elf32_Word hwp_flags2;
+}
+
+enum OHWA0_R4KEOP_CHECKED =    0x00000001;
+enum OHWA1_R4KEOP_CLEAN =      0x00000002;
+
+enum R_MIPS_NONE =             0;
+enum R_MIPS_16 =               1;
+enum R_MIPS_32 =               2;
+enum R_MIPS_REL32 =            3;
+enum R_MIPS_26 =               4;
+enum R_MIPS_HI16 =             5;
+enum R_MIPS_LO16 =             6;
+enum R_MIPS_GPREL16 =          7;
+enum R_MIPS_LITERAL =          8;
+enum R_MIPS_GOT16 =            9;
+enum R_MIPS_PC16 =             10;
+enum R_MIPS_CALL16 =           11;
+enum R_MIPS_GPREL32 =          12;
+
+enum R_MIPS_SHIFT5 =           16;
+enum R_MIPS_SHIFT6 =           17;
+enum R_MIPS_64 =               18;
+enum R_MIPS_GOT_DISP =         19;
+enum R_MIPS_GOT_PAGE =         20;
+enum R_MIPS_GOT_OFST =         21;
+enum R_MIPS_GOT_HI16 =         22;
+enum R_MIPS_GOT_LO16 =         23;
+enum R_MIPS_SUB =              24;
+enum R_MIPS_INSERT_A =         25;
+enum R_MIPS_INSERT_B =         26;
+enum R_MIPS_DELETE =           27;
+enum R_MIPS_HIGHER =           28;
+enum R_MIPS_HIGHEST =          29;
+enum R_MIPS_CALL_HI16 =        30;
+enum R_MIPS_CALL_LO16 =        31;
+enum R_MIPS_SCN_DISP =         32;
+enum R_MIPS_REL16 =            33;
+enum R_MIPS_ADD_IMMEDIATE =    34;
+enum R_MIPS_PJUMP =            35;
+enum R_MIPS_RELGOT =           36;
+enum R_MIPS_JALR =             37;
+enum R_MIPS_TLS_DTPMOD32 =     38;
+enum R_MIPS_TLS_DTPREL32 =     39;
+enum R_MIPS_TLS_DTPMOD64 =     40;
+enum R_MIPS_TLS_DTPREL64 =     41;
+enum R_MIPS_TLS_GD =           42;
+enum R_MIPS_TLS_LDM =          43;
+enum R_MIPS_TLS_DTPREL_HI16 =  44;
+enum R_MIPS_TLS_DTPREL_LO16 =  45;
+enum R_MIPS_TLS_GOTTPREL =     46;
+enum R_MIPS_TLS_TPREL32 =      47;
+enum R_MIPS_TLS_TPREL64 =      48;
+enum R_MIPS_TLS_TPREL_HI16 =   49;
+enum R_MIPS_TLS_TPREL_LO16 =   50;
+enum R_MIPS_GLOB_DAT =         51;
+enum R_MIPS_COPY =             126;
+enum R_MIPS_JUMP_SLOT =        127;
+enum R_MIPS_NUM =              128;
+
+enum PT_MIPS_REGINFO = 0x70000000;
+enum PT_MIPS_RTPROC =  0x70000001;
+enum PT_MIPS_OPTIONS = 0x70000002;
+
+enum PF_MIPS_LOCAL =   0x10000000;
+
+enum DT_MIPS_RLD_VERSION =  0x70000001;
+enum DT_MIPS_TIME_STAMP =   0x70000002;
+enum DT_MIPS_ICHECKSUM =    0x70000003;
+enum DT_MIPS_IVERSION =     0x70000004;
+enum DT_MIPS_FLAGS =        0x70000005;
+enum DT_MIPS_BASE_ADDRESS = 0x70000006;
+enum DT_MIPS_MSYM =         0x70000007;
+enum DT_MIPS_CONFLICT =     0x70000008;
+enum DT_MIPS_LIBLIST =      0x70000009;
+enum DT_MIPS_LOCAL_GOTNO =  0x7000000a;
+enum DT_MIPS_CONFLICTNO =   0x7000000b;
+enum DT_MIPS_LIBLISTNO =    0x70000010;
+enum DT_MIPS_SYMTABNO =     0x70000011;
+enum DT_MIPS_UNREFEXTNO =   0x70000012;
+enum DT_MIPS_GOTSYM =       0x70000013;
+enum DT_MIPS_HIPAGENO =     0x70000014;
+enum DT_MIPS_RLD_MAP =      0x70000016;
+enum DT_MIPS_DELTA_CLASS =  0x70000017;
+enum DT_MIPS_DELTA_CLASS_NO =    0x70000018;
+enum DT_MIPS_DELTA_INSTANCE =    0x70000019;
+enum DT_MIPS_DELTA_INSTANCE_NO = 0x7000001a;
+enum DT_MIPS_DELTA_RELOC =  0x7000001b;
+enum DT_MIPS_DELTA_RELOC_NO = 0x7000001c;
+enum DT_MIPS_DELTA_SYM =    0x7000001d;
+enum DT_MIPS_DELTA_SYM_NO = 0x7000001e;
+enum DT_MIPS_DELTA_CLASSSYM = 0x70000020;
+enum DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021;
+enum DT_MIPS_CXX_FLAGS =    0x70000022;
+enum DT_MIPS_PIXIE_INIT =   0x70000023;
+enum DT_MIPS_SYMBOL_LIB =   0x70000024;
+enum DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025;
+enum DT_MIPS_LOCAL_GOTIDX = 0x70000026;
+enum DT_MIPS_HIDDEN_GOTIDX = 0x70000027;
+enum DT_MIPS_PROTECTED_GOTIDX = 0x70000028;
+enum DT_MIPS_OPTIONS =      0x70000029;
+enum DT_MIPS_INTERFACE =    0x7000002a;
+enum DT_MIPS_DYNSTR_ALIGN = 0x7000002b;
+enum DT_MIPS_INTERFACE_SIZE = 0x7000002c;
+enum DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002d;
+enum DT_MIPS_PERF_SUFFIX =  0x7000002e;
+enum DT_MIPS_COMPACT_SIZE = 0x7000002f;
+enum DT_MIPS_GP_VALUE =     0x70000030;
+enum DT_MIPS_AUX_DYNAMIC =  0x70000031;
+enum DT_MIPS_PLTGOT =       0x70000032;
+enum DT_MIPS_RWPLT =        0x70000034;
+enum DT_MIPS_NUM =          0x35;
+
+enum RHF_NONE =                   0;
+enum RHF_QUICKSTART =             (1 << 0);
+enum RHF_NOTPOT =                 (1 << 1);
+enum RHF_NO_LIBRARY_REPLACEMENT = (1 << 2);
+enum RHF_NO_MOVE =                (1 << 3);
+enum RHF_SGI_ONLY =               (1 << 4);
+enum RHF_GUARANTEE_INIT =         (1 << 5);
+enum RHF_DELTA_C_PLUS_PLUS =      (1 << 6);
+enum RHF_GUARANTEE_START_INIT =   (1 << 7);
+enum RHF_PIXIE =                  (1 << 8);
+enum RHF_DEFAULT_DELAY_LOAD =     (1 << 9);
+enum RHF_REQUICKSTART =           (1 << 10);
+enum RHF_REQUICKSTARTED =         (1 << 11);
+enum RHF_CORD =                   (1 << 12);
+enum RHF_NO_UNRES_UNDEF =         (1 << 13);
+enum RHF_RLD_ORDER_SAFE =         (1 << 14);
+
+struct Elf32_Lib
+{
+    Elf32_Word l_name;
+    Elf32_Word l_time_stamp;
+    Elf32_Word l_checksum;
+    Elf32_Word l_version;
+    Elf32_Word l_flags;
+}
+
+struct Elf64_Lib
+{
+    Elf64_Word l_name;
+    Elf64_Word l_time_stamp;
+    Elf64_Word l_checksum;
+    Elf64_Word l_version;
+    Elf64_Word l_flags;
+}
+
+enum LL_NONE =           0;
+enum LL_EXACT_MATCH =    (1 << 0);
+enum LL_IGNORE_INT_VER = (1 << 1);
+enum LL_REQUIRE_MINOR =  (1 << 2);
+enum LL_EXPORTS =        (1 << 3);
+enum LL_DELAY_LOAD =     (1 << 4);
+enum LL_DELTA =          (1 << 5);
+
+alias Elf32_Addr Elf32_Conflict;
+
+enum EF_PARISC_TRAPNIL =       0x00010000;
+enum EF_PARISC_EXT =           0x00020000;
+enum EF_PARISC_LSB =           0x00040000;
+enum EF_PARISC_WIDE =          0x00080000;
+enum EF_PARISC_NO_KABP =       0x00100000;
+enum EF_PARISC_LAZYSWAP =      0x00400000;
+enum EF_PARISC_ARCH =          0x0000ffff;
+
+enum EFA_PARISC_1_0 =              0x020b;
+enum EFA_PARISC_1_1 =              0x0210;
+enum EFA_PARISC_2_0 =              0x0214;
+
+enum SHN_PARISC_ANSI_COMMON =  0xff00;
+enum SHN_PARISC_HUGE_COMMON =  0xff01;
+
+enum SHT_PARISC_EXT =          0x70000000;
+enum SHT_PARISC_UNWIND =       0x70000001;
+enum SHT_PARISC_DOC =          0x70000002;
+
+enum SHF_PARISC_SHORT =        0x20000000;
+enum SHF_PARISC_HUGE =         0x40000000;
+enum SHF_PARISC_SBP =          0x80000000;
+
+enum STT_PARISC_MILLICODE =    13;
+
+enum STT_HP_OPAQUE =           (STT_LOOS + 0x1);
+enum STT_HP_STUB =             (STT_LOOS + 0x2);
+
+enum R_PARISC_NONE =           0;
+enum R_PARISC_DIR32 =          1;
+enum R_PARISC_DIR21L =         2;
+enum R_PARISC_DIR17R =         3;
+enum R_PARISC_DIR17F =         4;
+enum R_PARISC_DIR14R =         6;
+enum R_PARISC_PCREL32 =        9;
+enum R_PARISC_PCREL21L =       10;
+enum R_PARISC_PCREL17R =       11;
+enum R_PARISC_PCREL17F =       12;
+enum R_PARISC_PCREL14R =       14;
+enum R_PARISC_DPREL21L =       18;
+enum R_PARISC_DPREL14R =       22;
+enum R_PARISC_GPREL21L =       26;
+enum R_PARISC_GPREL14R =       30;
+enum R_PARISC_LTOFF21L =       34;
+enum R_PARISC_LTOFF14R =       38;
+enum R_PARISC_SECREL32 =       41;
+enum R_PARISC_SEGBASE =        48;
+enum R_PARISC_SEGREL32 =       49;
+enum R_PARISC_PLTOFF21L =      50;
+enum R_PARISC_PLTOFF14R =      54;
+enum R_PARISC_LTOFF_FPTR32 =   57;
+enum R_PARISC_LTOFF_FPTR21L =  58;
+enum R_PARISC_LTOFF_FPTR14R =  62;
+enum R_PARISC_FPTR64 =         64;
+enum R_PARISC_PLABEL32 =       65;
+enum R_PARISC_PLABEL21L =      66;
+enum R_PARISC_PLABEL14R =      70;
+enum R_PARISC_PCREL64 =        72;
+enum R_PARISC_PCREL22F =       74;
+enum R_PARISC_PCREL14WR =      75;
+enum R_PARISC_PCREL14DR =      76;
+enum R_PARISC_PCREL16F =       77;
+enum R_PARISC_PCREL16WF =      78;
+enum R_PARISC_PCREL16DF =      79;
+enum R_PARISC_DIR64 =          80;
+enum R_PARISC_DIR14WR =        83;
+enum R_PARISC_DIR14DR =        84;
+enum R_PARISC_DIR16F =         85;
+enum R_PARISC_DIR16WF =        86;
+enum R_PARISC_DIR16DF =        87;
+enum R_PARISC_GPREL64 =        88;
+enum R_PARISC_GPREL14WR =      91;
+enum R_PARISC_GPREL14DR =      92;
+enum R_PARISC_GPREL16F =       93;
+enum R_PARISC_GPREL16WF =      94;
+enum R_PARISC_GPREL16DF =      95;
+enum R_PARISC_LTOFF64 =        96;
+enum R_PARISC_LTOFF14WR =      99;
+enum R_PARISC_LTOFF14DR =      100;
+enum R_PARISC_LTOFF16F =       101;
+enum R_PARISC_LTOFF16WF =      102;
+enum R_PARISC_LTOFF16DF =      103;
+enum R_PARISC_SECREL64 =       104;
+enum R_PARISC_SEGREL64 =       112;
+enum R_PARISC_PLTOFF14WR =     115;
+enum R_PARISC_PLTOFF14DR =     116;
+enum R_PARISC_PLTOFF16F =      117;
+enum R_PARISC_PLTOFF16WF =     118;
+enum R_PARISC_PLTOFF16DF =     119;
+enum R_PARISC_LTOFF_FPTR64 =   120;
+enum R_PARISC_LTOFF_FPTR14WR = 123;
+enum R_PARISC_LTOFF_FPTR14DR = 124;
+enum R_PARISC_LTOFF_FPTR16F =  125;
+enum R_PARISC_LTOFF_FPTR16WF = 126;
+enum R_PARISC_LTOFF_FPTR16DF = 127;
+enum R_PARISC_LORESERVE =      128;
+enum R_PARISC_COPY =           128;
+enum R_PARISC_IPLT =           129;
+enum R_PARISC_EPLT =           130;
+enum R_PARISC_TPREL32 =        153;
+enum R_PARISC_TPREL21L =       154;
+enum R_PARISC_TPREL14R =       158;
+enum R_PARISC_LTOFF_TP21L =    162;
+enum R_PARISC_LTOFF_TP14R =    166;
+enum R_PARISC_LTOFF_TP14F =    167;
+enum R_PARISC_TPREL64 =        216;
+enum R_PARISC_TPREL14WR =      219;
+enum R_PARISC_TPREL14DR =      220;
+enum R_PARISC_TPREL16F =       221;
+enum R_PARISC_TPREL16WF =      222;
+enum R_PARISC_TPREL16DF =      223;
+enum R_PARISC_LTOFF_TP64 =     224;
+enum R_PARISC_LTOFF_TP14WR =   227;
+enum R_PARISC_LTOFF_TP14DR =   228;
+enum R_PARISC_LTOFF_TP16F =    229;
+enum R_PARISC_LTOFF_TP16WF =   230;
+enum R_PARISC_LTOFF_TP16DF =   231;
+enum R_PARISC_GNU_VTENTRY =    232;
+enum R_PARISC_GNU_VTINHERIT =  233;
+enum R_PARISC_TLS_GD21L =      234;
+enum R_PARISC_TLS_GD14R =      235;
+enum R_PARISC_TLS_GDCALL =     236;
+enum R_PARISC_TLS_LDM21L =     237;
+enum R_PARISC_TLS_LDM14R =     238;
+enum R_PARISC_TLS_LDMCALL =    239;
+enum R_PARISC_TLS_LDO21L =     240;
+enum R_PARISC_TLS_LDO14R =     241;
+enum R_PARISC_TLS_DTPMOD32 =   242;
+enum R_PARISC_TLS_DTPMOD64 =   243;
+enum R_PARISC_TLS_DTPOFF32 =   244;
+enum R_PARISC_TLS_DTPOFF64 =   245;
+enum R_PARISC_TLS_LE21L =      R_PARISC_TPREL21L;
+enum R_PARISC_TLS_LE14R =      R_PARISC_TPREL14R;
+enum R_PARISC_TLS_IE21L =      R_PARISC_LTOFF_TP21L;
+enum R_PARISC_TLS_IE14R =      R_PARISC_LTOFF_TP14R;
+enum R_PARISC_TLS_TPREL32 =    R_PARISC_TPREL32;
+enum R_PARISC_TLS_TPREL64 =    R_PARISC_TPREL64;
+enum R_PARISC_HIRESERVE =      255;
+
+enum PT_HP_TLS =               (PT_LOOS + 0x0);
+enum PT_HP_CORE_NONE =         (PT_LOOS + 0x1);
+enum PT_HP_CORE_VERSION =      (PT_LOOS + 0x2);
+enum PT_HP_CORE_KERNEL =       (PT_LOOS + 0x3);
+enum PT_HP_CORE_COMM =         (PT_LOOS + 0x4);
+enum PT_HP_CORE_PROC =         (PT_LOOS + 0x5);
+enum PT_HP_CORE_LOADABLE =     (PT_LOOS + 0x6);
+enum PT_HP_CORE_STACK =        (PT_LOOS + 0x7);
+enum PT_HP_CORE_SHM =          (PT_LOOS + 0x8);
+enum PT_HP_CORE_MMF =          (PT_LOOS + 0x9);
+enum PT_HP_PARALLEL =          (PT_LOOS + 0x10);
+enum PT_HP_FASTBIND =          (PT_LOOS + 0x11);
+enum PT_HP_OPT_ANNOT =         (PT_LOOS + 0x12);
+enum PT_HP_HSL_ANNOT =         (PT_LOOS + 0x13);
+enum PT_HP_STACK =             (PT_LOOS + 0x14);
+
+enum PT_PARISC_ARCHEXT =       0x70000000;
+enum PT_PARISC_UNWIND =        0x70000001;
+
+enum PF_PARISC_SBP =           0x08000000;
+
+enum PF_HP_PAGE_SIZE =         0x00100000;
+enum PF_HP_FAR_SHARED =        0x00200000;
+enum PF_HP_NEAR_SHARED =       0x00400000;
+enum PF_HP_CODE =              0x01000000;
+enum PF_HP_MODIFY =            0x02000000;
+enum PF_HP_LAZYSWAP =          0x04000000;
+enum PF_HP_SBP =               0x08000000;
+
+enum EF_ALPHA_32BIT =          1;
+enum EF_ALPHA_CANRELAX =       2;
+enum SHT_ALPHA_DEBUG =         0x70000001;
+enum SHT_ALPHA_REGINFO =       0x70000002;
+
+enum SHF_ALPHA_GPREL =         0x10000000;
+enum STO_ALPHA_NOPV =          0x80;
+enum STO_ALPHA_STD_GPLOAD =    0x88;
+
+enum R_ALPHA_NONE =            0;
+enum R_ALPHA_REFLONG =         1;
+enum R_ALPHA_REFQUAD =         2;
+enum R_ALPHA_GPREL32 =         3;
+enum R_ALPHA_LITERAL =         4;
+enum R_ALPHA_LITUSE =          5;
+enum R_ALPHA_GPDISP =          6;
+enum R_ALPHA_BRADDR =          7;
+enum R_ALPHA_HINT =            8;
+enum R_ALPHA_SREL16 =          9;
+enum R_ALPHA_SREL32 =          10;
+enum R_ALPHA_SREL64 =          11;
+enum R_ALPHA_GPRELHIGH =       17;
+enum R_ALPHA_GPRELLOW =        18;
+enum R_ALPHA_GPREL16 =         19;
+enum R_ALPHA_COPY =            24;
+enum R_ALPHA_GLOB_DAT =        25;
+enum R_ALPHA_JMP_SLOT =        26;
+enum R_ALPHA_RELATIVE =        27;
+enum R_ALPHA_TLS_GD_HI =       28;
+enum R_ALPHA_TLSGD =           29;
+enum R_ALPHA_TLS_LDM =         30;
+enum R_ALPHA_DTPMOD64 =        31;
+enum R_ALPHA_GOTDTPREL =       32;
+enum R_ALPHA_DTPREL64 =        33;
+enum R_ALPHA_DTPRELHI =        34;
+enum R_ALPHA_DTPRELLO =        35;
+enum R_ALPHA_DTPREL16 =        36;
+enum R_ALPHA_GOTTPREL =        37;
+enum R_ALPHA_TPREL64 =         38;
+enum R_ALPHA_TPRELHI =         39;
+enum R_ALPHA_TPRELLO =         40;
+enum R_ALPHA_TPREL16 =         41;
+enum R_ALPHA_NUM =             46;
+enum LITUSE_ALPHA_ADDR =       0;
+enum LITUSE_ALPHA_BASE =       1;
+enum LITUSE_ALPHA_BYTOFF =     2;
+enum LITUSE_ALPHA_JSR =        3;
+enum LITUSE_ALPHA_TLS_GD =     4;
+enum LITUSE_ALPHA_TLS_LDM =    5;
+enum DT_ALPHA_PLTRO =          (DT_LOPROC + 0);
+enum DT_ALPHA_NUM =            1;
+enum EF_PPC_EMB =              0x80000000;
+enum EF_PPC_RELOCATABLE =      0x00010000;
+enum EF_PPC_RELOCATABLE_LIB =  0x00008000;
+enum R_PPC_NONE =              0;
+enum R_PPC_ADDR32 =            1;
+enum R_PPC_ADDR24 =            2;
+enum R_PPC_ADDR16 =            3;
+enum R_PPC_ADDR16_LO =         4;
+enum R_PPC_ADDR16_HI =         5;
+enum R_PPC_ADDR16_HA =         6;
+enum R_PPC_ADDR14 =            7;
+enum R_PPC_ADDR14_BRTAKEN =    8;
+enum R_PPC_ADDR14_BRNTAKEN =   9;
+enum R_PPC_REL24 =             10;
+enum R_PPC_REL14 =             11;
+enum R_PPC_REL14_BRTAKEN =     12;
+enum R_PPC_REL14_BRNTAKEN =    13;
+enum R_PPC_GOT16 =             14;
+enum R_PPC_GOT16_LO =          15;
+enum R_PPC_GOT16_HI =          16;
+enum R_PPC_GOT16_HA =          17;
+enum R_PPC_PLTREL24 =          18;
+enum R_PPC_COPY =              19;
+enum R_PPC_GLOB_DAT =          20;
+enum R_PPC_JMP_SLOT =          21;
+enum R_PPC_RELATIVE =          22;
+enum R_PPC_LOCAL24PC =         23;
+enum R_PPC_UADDR32 =           24;
+enum R_PPC_UADDR16 =           25;
+enum R_PPC_REL32 =             26;
+enum R_PPC_PLT32 =             27;
+enum R_PPC_PLTREL32 =          28;
+enum R_PPC_PLT16_LO =          29;
+enum R_PPC_PLT16_HI =          30;
+enum R_PPC_PLT16_HA =          31;
+enum R_PPC_SDAREL16 =          32;
+enum R_PPC_SECTOFF =           33;
+enum R_PPC_SECTOFF_LO =        34;
+enum R_PPC_SECTOFF_HI =        35;
+enum R_PPC_SECTOFF_HA =        36;
+enum R_PPC_TLS =               67;
+enum R_PPC_DTPMOD32 =          68;
+enum R_PPC_TPREL16 =           69;
+enum R_PPC_TPREL16_LO =        70;
+enum R_PPC_TPREL16_HI =        71;
+enum R_PPC_TPREL16_HA =        72;
+enum R_PPC_TPREL32 =           73;
+enum R_PPC_DTPREL16 =          74;
+enum R_PPC_DTPREL16_LO =       75;
+enum R_PPC_DTPREL16_HI =       76;
+enum R_PPC_DTPREL16_HA =       77;
+enum R_PPC_DTPREL32 =          78;
+enum R_PPC_GOT_TLSGD16 =       79;
+enum R_PPC_GOT_TLSGD16_LO =    80;
+enum R_PPC_GOT_TLSGD16_HI =    81;
+enum R_PPC_GOT_TLSGD16_HA =    82;
+enum R_PPC_GOT_TLSLD16 =       83;
+enum R_PPC_GOT_TLSLD16_LO =    84;
+enum R_PPC_GOT_TLSLD16_HI =    85;
+enum R_PPC_GOT_TLSLD16_HA =    86;
+enum R_PPC_GOT_TPREL16 =       87;
+enum R_PPC_GOT_TPREL16_LO =    88;
+enum R_PPC_GOT_TPREL16_HI =    89;
+enum R_PPC_GOT_TPREL16_HA =    90;
+enum R_PPC_GOT_DTPREL16 =      91;
+enum R_PPC_GOT_DTPREL16_LO =   92;
+enum R_PPC_GOT_DTPREL16_HI =   93;
+enum R_PPC_GOT_DTPREL16_HA =   94;
+enum R_PPC_EMB_NADDR32 =       101;
+enum R_PPC_EMB_NADDR16 =       102;
+enum R_PPC_EMB_NADDR16_LO =    103;
+enum R_PPC_EMB_NADDR16_HI =    104;
+enum R_PPC_EMB_NADDR16_HA =    105;
+enum R_PPC_EMB_SDAI16 =        106;
+enum R_PPC_EMB_SDA2I16 =       107;
+enum R_PPC_EMB_SDA2REL =       108;
+enum R_PPC_EMB_SDA21 =         109;
+enum R_PPC_EMB_MRKREF =        110;
+enum R_PPC_EMB_RELSEC16 =      111;
+enum R_PPC_EMB_RELST_LO =      112;
+enum R_PPC_EMB_RELST_HI =      113;
+enum R_PPC_EMB_RELST_HA =      114;
+enum R_PPC_EMB_BIT_FLD =       115;
+enum R_PPC_EMB_RELSDA =        116;
+enum R_PPC_DIAB_SDA21_LO =     180;
+enum R_PPC_DIAB_SDA21_HI =     181;
+enum R_PPC_DIAB_SDA21_HA =     182;
+enum R_PPC_DIAB_RELSDA_LO =    183;
+enum R_PPC_DIAB_RELSDA_HI =    184;
+enum R_PPC_DIAB_RELSDA_HA =    185;
+enum R_PPC_IRELATIVE =         248;
+enum R_PPC_REL16 =             249;
+enum R_PPC_REL16_LO =          250;
+enum R_PPC_REL16_HI =          251;
+enum R_PPC_REL16_HA =          252;
+enum R_PPC_TOC16 =             255;
+enum DT_PPC_GOT =              (DT_LOPROC + 0);
+enum DT_PPC_NUM =              1;
+enum R_PPC64_NONE =            R_PPC_NONE;
+enum R_PPC64_ADDR32 =          R_PPC_ADDR32;
+enum R_PPC64_ADDR24 =          R_PPC_ADDR24;
+enum R_PPC64_ADDR16 =          R_PPC_ADDR16;
+enum R_PPC64_ADDR16_LO =       R_PPC_ADDR16_LO;
+enum R_PPC64_ADDR16_HI =       R_PPC_ADDR16_HI;
+enum R_PPC64_ADDR16_HA =       R_PPC_ADDR16_HA;
+enum R_PPC64_ADDR14 =          R_PPC_ADDR14;
+enum R_PPC64_ADDR14_BRTAKEN =  R_PPC_ADDR14_BRTAKEN;
+enum R_PPC64_ADDR14_BRNTAKEN = R_PPC_ADDR14_BRNTAKEN;
+enum R_PPC64_REL24 =           R_PPC_REL24;
+enum R_PPC64_REL14 =           R_PPC_REL14;
+enum R_PPC64_REL14_BRTAKEN =   R_PPC_REL14_BRTAKEN;
+enum R_PPC64_REL14_BRNTAKEN =  R_PPC_REL14_BRNTAKEN;
+enum R_PPC64_GOT16 =           R_PPC_GOT16;
+enum R_PPC64_GOT16_LO =        R_PPC_GOT16_LO;
+enum R_PPC64_GOT16_HI =        R_PPC_GOT16_HI;
+enum R_PPC64_GOT16_HA =        R_PPC_GOT16_HA;
+
+enum R_PPC64_COPY =            R_PPC_COPY;
+enum R_PPC64_GLOB_DAT =        R_PPC_GLOB_DAT;
+enum R_PPC64_JMP_SLOT =        R_PPC_JMP_SLOT;
+enum R_PPC64_RELATIVE =        R_PPC_RELATIVE;
+
+enum R_PPC64_UADDR32 =         R_PPC_UADDR32;
+enum R_PPC64_UADDR16 =         R_PPC_UADDR16;
+enum R_PPC64_REL32 =           R_PPC_REL32;
+enum R_PPC64_PLT32 =           R_PPC_PLT32;
+enum R_PPC64_PLTREL32 =        R_PPC_PLTREL32;
+enum R_PPC64_PLT16_LO =        R_PPC_PLT16_LO;
+enum R_PPC64_PLT16_HI =        R_PPC_PLT16_HI;
+enum R_PPC64_PLT16_HA =        R_PPC_PLT16_HA;
+
+enum R_PPC64_SECTOFF =         R_PPC_SECTOFF;
+enum R_PPC64_SECTOFF_LO =      R_PPC_SECTOFF_LO;
+enum R_PPC64_SECTOFF_HI =      R_PPC_SECTOFF_HI;
+enum R_PPC64_SECTOFF_HA =      R_PPC_SECTOFF_HA;
+enum R_PPC64_ADDR30 =          37;
+enum R_PPC64_ADDR64 =          38;
+enum R_PPC64_ADDR16_HIGHER =   39;
+enum R_PPC64_ADDR16_HIGHERA =  40;
+enum R_PPC64_ADDR16_HIGHEST =  41;
+enum R_PPC64_ADDR16_HIGHESTA = 42;
+enum R_PPC64_UADDR64 =         43;
+enum R_PPC64_REL64 =           44;
+enum R_PPC64_PLT64 =           45;
+enum R_PPC64_PLTREL64 =        46;
+enum R_PPC64_TOC16 =           47;
+enum R_PPC64_TOC16_LO =        48;
+enum R_PPC64_TOC16_HI =        49;
+enum R_PPC64_TOC16_HA =        50;
+enum R_PPC64_TOC =             51;
+enum R_PPC64_PLTGOT16 =        52;
+enum R_PPC64_PLTGOT16_LO =     53;
+enum R_PPC64_PLTGOT16_HI =     54;
+enum R_PPC64_PLTGOT16_HA =     55;
+
+enum R_PPC64_ADDR16_DS =       56;
+enum R_PPC64_ADDR16_LO_DS =    57;
+enum R_PPC64_GOT16_DS =        58;
+enum R_PPC64_GOT16_LO_DS =     59;
+enum R_PPC64_PLT16_LO_DS =     60;
+enum R_PPC64_SECTOFF_DS =      61;
+enum R_PPC64_SECTOFF_LO_DS =   62;
+enum R_PPC64_TOC16_DS =        63;
+enum R_PPC64_TOC16_LO_DS =     64;
+enum R_PPC64_PLTGOT16_DS =     65;
+enum R_PPC64_PLTGOT16_LO_DS =  66;
+enum R_PPC64_TLS =             67;
+enum R_PPC64_DTPMOD64 =        68;
+enum R_PPC64_TPREL16 =         69;
+enum R_PPC64_TPREL16_LO =      70;
+enum R_PPC64_TPREL16_HI =      71;
+enum R_PPC64_TPREL16_HA =      72;
+enum R_PPC64_TPREL64 =         73;
+enum R_PPC64_DTPREL16 =        74;
+enum R_PPC64_DTPREL16_LO =     75;
+enum R_PPC64_DTPREL16_HI =     76;
+enum R_PPC64_DTPREL16_HA =     77;
+enum R_PPC64_DTPREL64 =        78;
+enum R_PPC64_GOT_TLSGD16 =     79;
+enum R_PPC64_GOT_TLSGD16_LO =  80;
+enum R_PPC64_GOT_TLSGD16_HI =  81;
+enum R_PPC64_GOT_TLSGD16_HA =  82;
+enum R_PPC64_GOT_TLSLD16 =     83;
+enum R_PPC64_GOT_TLSLD16_LO =  84;
+enum R_PPC64_GOT_TLSLD16_HI =  85;
+enum R_PPC64_GOT_TLSLD16_HA =  86;
+enum R_PPC64_GOT_TPREL16_DS =  87;
+enum R_PPC64_GOT_TPREL16_LO_DS = 88;
+enum R_PPC64_GOT_TPREL16_HI =  89;
+enum R_PPC64_GOT_TPREL16_HA =  90;
+enum R_PPC64_GOT_DTPREL16_DS = 91;
+enum R_PPC64_GOT_DTPREL16_LO_DS = 92;
+enum R_PPC64_GOT_DTPREL16_HI = 93;
+enum R_PPC64_GOT_DTPREL16_HA = 94;
+enum R_PPC64_TPREL16_DS =      95;
+enum R_PPC64_TPREL16_LO_DS =   96;
+enum R_PPC64_TPREL16_HIGHER =  97;
+enum R_PPC64_TPREL16_HIGHERA = 98;
+enum R_PPC64_TPREL16_HIGHEST = 99;
+enum R_PPC64_TPREL16_HIGHESTA = 100;
+enum R_PPC64_DTPREL16_DS =     101;
+enum R_PPC64_DTPREL16_LO_DS =  102;
+enum R_PPC64_DTPREL16_HIGHER = 103;
+enum R_PPC64_DTPREL16_HIGHERA = 104;
+enum R_PPC64_DTPREL16_HIGHEST = 105;
+enum R_PPC64_DTPREL16_HIGHESTA = 106;
+enum R_PPC64_JMP_IREL =        247;
+enum R_PPC64_IRELATIVE =       248;
+enum R_PPC64_REL16 =           249;
+enum R_PPC64_REL16_LO =        250;
+enum R_PPC64_REL16_HI =        251;
+enum R_PPC64_REL16_HA =        252;
+enum DT_PPC64_GLINK =  (DT_LOPROC + 0);
+enum DT_PPC64_OPD =    (DT_LOPROC + 1);
+enum DT_PPC64_OPDSZ =  (DT_LOPROC + 2);
+enum DT_PPC64_NUM =    3;
+enum EF_ARM_RELEXEC =          0x01;
+enum EF_ARM_HASENTRY =         0x02;
+enum EF_ARM_INTERWORK =        0x04;
+enum EF_ARM_APCS_26 =          0x08;
+enum EF_ARM_APCS_FLOAT =       0x10;
+enum EF_ARM_PIC =              0x20;
+enum EF_ARM_ALIGN8 =           0x40;
+enum EF_ARM_NEW_ABI =          0x80;
+enum EF_ARM_OLD_ABI =          0x100;
+enum EF_ARM_SOFT_FLOAT =       0x200;
+enum EF_ARM_VFP_FLOAT =        0x400;
+enum EF_ARM_MAVERICK_FLOAT =   0x800;
+
+enum EF_ARM_ABI_FLOAT_SOFT =   0x200;
+enum EF_ARM_ABI_FLOAT_HARD =   0x400;
+enum EF_ARM_SYMSARESORTED =    0x04;
+enum EF_ARM_DYNSYMSUSESEGIDX = 0x08;
+enum EF_ARM_MAPSYMSFIRST =     0x10;
+enum EF_ARM_EABIMASK =         0XFF000000;
+enum EF_ARM_BE8 =          0x00800000;
+enum EF_ARM_LE8 =          0x00400000;
+
+extern (D) auto EF_ARM_EABI_VERSION(F)(F flags) { return flags & EF_ARM_EABIMASK; }
+enum EF_ARM_EABI_UNKNOWN =     0x00000000;
+enum EF_ARM_EABI_VER1 =        0x01000000;
+enum EF_ARM_EABI_VER2 =        0x02000000;
+enum EF_ARM_EABI_VER3 =        0x03000000;
+enum EF_ARM_EABI_VER4 =        0x04000000;
+enum EF_ARM_EABI_VER5 =        0x05000000;
+enum STT_ARM_TFUNC =           STT_LOPROC;
+enum STT_ARM_16BIT =           STT_HIPROC;
+enum SHF_ARM_ENTRYSECT =       0x10000000;
+enum SHF_ARM_COMDEF =          0x80000000;
+enum PF_ARM_SB =               0x10000000;
+enum PF_ARM_PI =               0x20000000;
+enum PF_ARM_ABS =              0x40000000;
+enum PT_ARM_EXIDX =            (PT_LOPROC + 1);
+enum SHT_ARM_EXIDX =           (SHT_LOPROC + 1);
+enum SHT_ARM_PREEMPTMAP =      (SHT_LOPROC + 2);
+enum SHT_ARM_ATTRIBUTES =      (SHT_LOPROC + 3);
+
+enum R_AARCH64_NONE =            0;
+enum R_AARCH64_ABS64 =         257;
+enum R_AARCH64_ABS32 =         258;
+enum R_AARCH64_COPY =         1024;
+enum R_AARCH64_GLOB_DAT =     1025;
+enum R_AARCH64_JUMP_SLOT =    1026;
+enum R_AARCH64_RELATIVE =     1027;
+enum R_AARCH64_TLS_DTPMOD64 = 1028;
+enum R_AARCH64_TLS_DTPREL64 = 1029;
+enum R_AARCH64_TLS_TPREL64 =  1030;
+enum R_AARCH64_TLSDESC =      1031;
+
+enum R_ARM_NONE =              0;
+enum R_ARM_PC24 =              1;
+enum R_ARM_ABS32 =             2;
+enum R_ARM_REL32 =             3;
+enum R_ARM_PC13 =              4;
+enum R_ARM_ABS16 =             5;
+enum R_ARM_ABS12 =             6;
+enum R_ARM_THM_ABS5 =          7;
+enum R_ARM_ABS8 =              8;
+enum R_ARM_SBREL32 =           9;
+enum R_ARM_THM_PC22 =          10;
+enum R_ARM_THM_PC8 =           11;
+enum R_ARM_AMP_VCALL9 =        12;
+enum R_ARM_SWI24 =             13;
+enum R_ARM_TLS_DESC =          13;
+enum R_ARM_THM_SWI8 =          14;
+enum R_ARM_XPC25 =             15;
+enum R_ARM_THM_XPC22 =         16;
+enum R_ARM_TLS_DTPMOD32 =      17;
+enum R_ARM_TLS_DTPOFF32 =      18;
+enum R_ARM_TLS_TPOFF32 =       19;
+enum R_ARM_COPY =              20;
+enum R_ARM_GLOB_DAT =          21;
+enum R_ARM_JUMP_SLOT =         22;
+enum R_ARM_RELATIVE =          23;
+enum R_ARM_GOTOFF =            24;
+enum R_ARM_GOTPC =             25;
+enum R_ARM_GOT32 =             26;
+enum R_ARM_PLT32 =             27;
+enum R_ARM_ALU_PCREL_7_0 =     32;
+enum R_ARM_ALU_PCREL_15_8 =    33;
+enum R_ARM_ALU_PCREL_23_15 =   34;
+enum R_ARM_LDR_SBREL_11_0 =    35;
+enum R_ARM_ALU_SBREL_19_12 =   36;
+enum R_ARM_ALU_SBREL_27_20 =   37;
+enum R_ARM_TLS_GOTDESC =       90;
+enum R_ARM_TLS_CALL =          91;
+enum R_ARM_TLS_DESCSEQ =       92;
+enum R_ARM_THM_TLS_CALL =      93;
+enum R_ARM_GNU_VTENTRY =       100;
+enum R_ARM_GNU_VTINHERIT =     101;
+enum R_ARM_THM_PC11 =          102;
+enum R_ARM_THM_PC9 =           103;
+enum R_ARM_TLS_GD32 =          104;
+enum R_ARM_TLS_LDM32 =         105;
+enum R_ARM_TLS_LDO32 =         106;
+enum R_ARM_TLS_IE32 =          107;
+enum R_ARM_TLS_LE32 =          108;
+enum R_ARM_THM_TLS_DESCSEQ =   129;
+enum R_ARM_IRELATIVE =         160;
+enum R_ARM_RXPC25 =            249;
+enum R_ARM_RSBREL32 =          250;
+enum R_ARM_THM_RPC22 =         251;
+enum R_ARM_RREL32 =            252;
+enum R_ARM_RABS22 =            253;
+enum R_ARM_RPC24 =             254;
+enum R_ARM_RBASE =             255;
+enum R_ARM_NUM =               256;
+enum EF_IA_64_MASKOS =         0x0000000f;
+enum EF_IA_64_ABI64 =          0x00000010;
+enum EF_IA_64_ARCH =           0xff000000;
+enum PT_IA_64_ARCHEXT =        (PT_LOPROC + 0);
+enum PT_IA_64_UNWIND =         (PT_LOPROC + 1);
+enum PT_IA_64_HP_OPT_ANOT =    (PT_LOOS + 0x12);
+enum PT_IA_64_HP_HSL_ANOT =    (PT_LOOS + 0x13);
+enum PT_IA_64_HP_STACK =       (PT_LOOS + 0x14);
+enum PF_IA_64_NORECOV =        0x80000000;
+enum SHT_IA_64_EXT =           (SHT_LOPROC + 0);
+enum SHT_IA_64_UNWIND =        (SHT_LOPROC + 1);
+enum SHF_IA_64_SHORT =         0x10000000;
+enum SHF_IA_64_NORECOV =       0x20000000;
+enum DT_IA_64_PLT_RESERVE =    (DT_LOPROC + 0);
+enum DT_IA_64_NUM =            1;
+enum R_IA64_NONE =             0x00;
+enum R_IA64_IMM14 =            0x21;
+enum R_IA64_IMM22 =            0x22;
+enum R_IA64_IMM64 =            0x23;
+enum R_IA64_DIR32MSB =         0x24;
+enum R_IA64_DIR32LSB =         0x25;
+enum R_IA64_DIR64MSB =         0x26;
+enum R_IA64_DIR64LSB =         0x27;
+enum R_IA64_GPREL22 =          0x2a;
+enum R_IA64_GPREL64I =         0x2b;
+enum R_IA64_GPREL32MSB =       0x2c;
+enum R_IA64_GPREL32LSB =       0x2d;
+enum R_IA64_GPREL64MSB =       0x2e;
+enum R_IA64_GPREL64LSB =       0x2f;
+enum R_IA64_LTOFF22 =          0x32;
+enum R_IA64_LTOFF64I =         0x33;
+enum R_IA64_PLTOFF22 =         0x3a;
+enum R_IA64_PLTOFF64I =        0x3b;
+enum R_IA64_PLTOFF64MSB =      0x3e;
+enum R_IA64_PLTOFF64LSB =      0x3f;
+enum R_IA64_FPTR64I =          0x43;
+enum R_IA64_FPTR32MSB =        0x44;
+enum R_IA64_FPTR32LSB =        0x45;
+enum R_IA64_FPTR64MSB =        0x46;
+enum R_IA64_FPTR64LSB =        0x47;
+enum R_IA64_PCREL60B =         0x48;
+enum R_IA64_PCREL21B =         0x49;
+enum R_IA64_PCREL21M =         0x4a;
+enum R_IA64_PCREL21F =         0x4b;
+enum R_IA64_PCREL32MSB =       0x4c;
+enum R_IA64_PCREL32LSB =       0x4d;
+enum R_IA64_PCREL64MSB =       0x4e;
+enum R_IA64_PCREL64LSB =       0x4f;
+enum R_IA64_LTOFF_FPTR22 =     0x52;
+enum R_IA64_LTOFF_FPTR64I =    0x53;
+enum R_IA64_LTOFF_FPTR32MSB =  0x54;
+enum R_IA64_LTOFF_FPTR32LSB =  0x55;
+enum R_IA64_LTOFF_FPTR64MSB =  0x56;
+enum R_IA64_LTOFF_FPTR64LSB =  0x57;
+enum R_IA64_SEGREL32MSB =      0x5c;
+enum R_IA64_SEGREL32LSB =      0x5d;
+enum R_IA64_SEGREL64MSB =      0x5e;
+enum R_IA64_SEGREL64LSB =      0x5f;
+enum R_IA64_SECREL32MSB =      0x64;
+enum R_IA64_SECREL32LSB =      0x65;
+enum R_IA64_SECREL64MSB =      0x66;
+enum R_IA64_SECREL64LSB =      0x67;
+enum R_IA64_REL32MSB =         0x6c;
+enum R_IA64_REL32LSB =         0x6d;
+enum R_IA64_REL64MSB =         0x6e;
+enum R_IA64_REL64LSB =         0x6f;
+enum R_IA64_LTV32MSB =         0x74;
+enum R_IA64_LTV32LSB =         0x75;
+enum R_IA64_LTV64MSB =         0x76;
+enum R_IA64_LTV64LSB =         0x77;
+enum R_IA64_PCREL21BI =        0x79;
+enum R_IA64_PCREL22 =          0x7a;
+enum R_IA64_PCREL64I =         0x7b;
+enum R_IA64_IPLTMSB =          0x80;
+enum R_IA64_IPLTLSB =          0x81;
+enum R_IA64_COPY =             0x84;
+enum R_IA64_SUB =              0x85;
+enum R_IA64_LTOFF22X =         0x86;
+enum R_IA64_LDXMOV =           0x87;
+enum R_IA64_TPREL14 =          0x91;
+enum R_IA64_TPREL22 =          0x92;
+enum R_IA64_TPREL64I =         0x93;
+enum R_IA64_TPREL64MSB =       0x96;
+enum R_IA64_TPREL64LSB =       0x97;
+enum R_IA64_LTOFF_TPREL22 =    0x9a;
+enum R_IA64_DTPMOD64MSB =      0xa6;
+enum R_IA64_DTPMOD64LSB =      0xa7;
+enum R_IA64_LTOFF_DTPMOD22 =   0xaa;
+enum R_IA64_DTPREL14 =         0xb1;
+enum R_IA64_DTPREL22 =         0xb2;
+enum R_IA64_DTPREL64I =        0xb3;
+enum R_IA64_DTPREL32MSB =      0xb4;
+enum R_IA64_DTPREL32LSB =      0xb5;
+enum R_IA64_DTPREL64MSB =      0xb6;
+enum R_IA64_DTPREL64LSB =      0xb7;
+enum R_IA64_LTOFF_DTPREL22 =   0xba;
+enum EF_SH_MACH_MASK =         0x1f;
+enum EF_SH_UNKNOWN =           0x0;
+enum EF_SH1 =                  0x1;
+enum EF_SH2 =                  0x2;
+enum EF_SH3 =                  0x3;
+enum EF_SH_DSP =               0x4;
+enum EF_SH3_DSP =              0x5;
+enum EF_SH4AL_DSP =            0x6;
+enum EF_SH3E =                 0x8;
+enum EF_SH4 =                  0x9;
+enum EF_SH2E =                 0xb;
+enum EF_SH4A =                 0xc;
+enum EF_SH2A =                 0xd;
+enum EF_SH4_NOFPU =            0x10;
+enum EF_SH4A_NOFPU =           0x11;
+enum EF_SH4_NOMMU_NOFPU =      0x12;
+enum EF_SH2A_NOFPU =           0x13;
+enum EF_SH3_NOMMU =            0x14;
+enum EF_SH2A_SH4_NOFPU =       0x15;
+enum EF_SH2A_SH3_NOFPU =       0x16;
+enum EF_SH2A_SH4 =             0x17;
+enum EF_SH2A_SH3E =            0x18;
+enum R_SH_NONE =               0;
+enum R_SH_DIR32 =              1;
+enum R_SH_REL32 =              2;
+enum R_SH_DIR8WPN =            3;
+enum R_SH_IND12W =             4;
+enum R_SH_DIR8WPL =            5;
+enum R_SH_DIR8WPZ =            6;
+enum R_SH_DIR8BP =             7;
+enum R_SH_DIR8W =              8;
+enum R_SH_DIR8L =              9;
+enum R_SH_SWITCH16 =           25;
+enum R_SH_SWITCH32 =           26;
+enum R_SH_USES =               27;
+enum R_SH_COUNT =              28;
+enum R_SH_ALIGN =              29;
+enum R_SH_CODE =               30;
+enum R_SH_DATA =               31;
+enum R_SH_LABEL =              32;
+enum R_SH_SWITCH8 =            33;
+enum R_SH_GNU_VTINHERIT =      34;
+enum R_SH_GNU_VTENTRY =        35;
+enum R_SH_TLS_GD_32 =          144;
+enum R_SH_TLS_LD_32 =          145;
+enum R_SH_TLS_LDO_32 =         146;
+enum R_SH_TLS_IE_32 =          147;
+enum R_SH_TLS_LE_32 =          148;
+enum R_SH_TLS_DTPMOD32 =       149;
+enum R_SH_TLS_DTPOFF32 =       150;
+enum R_SH_TLS_TPOFF32 =        151;
+enum R_SH_GOT32 =              160;
+enum R_SH_PLT32 =              161;
+enum R_SH_COPY =               162;
+enum R_SH_GLOB_DAT =           163;
+enum R_SH_JMP_SLOT =           164;
+enum R_SH_RELATIVE =           165;
+enum R_SH_GOTOFF =             166;
+enum R_SH_GOTPC =              167;
+enum R_SH_NUM =                256;
+
+enum EF_S390_HIGH_GPRS =    0x00000001;
+
+enum R_390_NONE =              0;
+enum R_390_8 =                 1;
+enum R_390_12 =                2;
+enum R_390_16 =                3;
+enum R_390_32 =                4;
+enum R_390_PC32 =              5;
+enum R_390_GOT12 =             6;
+enum R_390_GOT32 =             7;
+enum R_390_PLT32 =             8;
+enum R_390_COPY =              9;
+enum R_390_GLOB_DAT =          10;
+enum R_390_JMP_SLOT =          11;
+enum R_390_RELATIVE =          12;
+enum R_390_GOTOFF32 =          13;
+enum R_390_GOTPC =             14;
+enum R_390_GOT16 =             15;
+enum R_390_PC16 =              16;
+enum R_390_PC16DBL =           17;
+enum R_390_PLT16DBL =          18;
+enum R_390_PC32DBL =           19;
+enum R_390_PLT32DBL =          20;
+enum R_390_GOTPCDBL =          21;
+enum R_390_64 =                22;
+enum R_390_PC64 =              23;
+enum R_390_GOT64 =             24;
+enum R_390_PLT64 =             25;
+enum R_390_GOTENT =            26;
+enum R_390_GOTOFF16 =          27;
+enum R_390_GOTOFF64 =          28;
+enum R_390_GOTPLT12 =          29;
+enum R_390_GOTPLT16 =          30;
+enum R_390_GOTPLT32 =          31;
+enum R_390_GOTPLT64 =          32;
+enum R_390_GOTPLTENT =         33;
+enum R_390_PLTOFF16 =          34;
+enum R_390_PLTOFF32 =          35;
+enum R_390_PLTOFF64 =          36;
+enum R_390_TLS_LOAD =          37;
+enum R_390_TLS_GDCALL =        38;
+enum R_390_TLS_LDCALL =        39;
+enum R_390_TLS_GD32 =          40;
+enum R_390_TLS_GD64 =          41;
+enum R_390_TLS_GOTIE12 =       42;
+enum R_390_TLS_GOTIE32 =       43;
+enum R_390_TLS_GOTIE64 =       44;
+enum R_390_TLS_LDM32 =         45;
+enum R_390_TLS_LDM64 =         46;
+enum R_390_TLS_IE32 =          47;
+enum R_390_TLS_IE64 =          48;
+enum R_390_TLS_IEENT =         49;
+enum R_390_TLS_LE32 =          50;
+enum R_390_TLS_LE64 =          51;
+enum R_390_TLS_LDO32 =         52;
+enum R_390_TLS_LDO64 =         53;
+enum R_390_TLS_DTPMOD =        54;
+enum R_390_TLS_DTPOFF =        55;
+enum R_390_TLS_TPOFF =         56;
+enum R_390_20 =                57;
+enum R_390_GOT20 =             58;
+enum R_390_GOTPLT20 =          59;
+enum R_390_TLS_GOTIE20 =       60;
+enum R_390_IRELATIVE =         61;
+enum R_390_NUM =               62;
+enum R_CRIS_NONE =             0;
+enum R_CRIS_8 =                1;
+enum R_CRIS_16 =               2;
+enum R_CRIS_32 =               3;
+enum R_CRIS_8_PCREL =          4;
+enum R_CRIS_16_PCREL =         5;
+enum R_CRIS_32_PCREL =         6;
+enum R_CRIS_GNU_VTINHERIT =    7;
+enum R_CRIS_GNU_VTENTRY =      8;
+enum R_CRIS_COPY =             9;
+enum R_CRIS_GLOB_DAT =         10;
+enum R_CRIS_JUMP_SLOT =        11;
+enum R_CRIS_RELATIVE =         12;
+enum R_CRIS_16_GOT =           13;
+enum R_CRIS_32_GOT =           14;
+enum R_CRIS_16_GOTPLT =        15;
+enum R_CRIS_32_GOTPLT =        16;
+enum R_CRIS_32_GOTREL =        17;
+enum R_CRIS_32_PLT_GOTREL =    18;
+enum R_CRIS_32_PLT_PCREL =     19;
+
+enum R_CRIS_NUM =              20;
+enum R_X86_64_NONE =           0;
+enum R_X86_64_64 =             1;
+enum R_X86_64_PC32 =           2;
+enum R_X86_64_GOT32 =          3;
+enum R_X86_64_PLT32 =          4;
+enum R_X86_64_COPY =           5;
+enum R_X86_64_GLOB_DAT =       6;
+enum R_X86_64_JUMP_SLOT =      7;
+enum R_X86_64_RELATIVE =       8;
+enum R_X86_64_GOTPCREL =       9;
+enum R_X86_64_32 =             10;
+enum R_X86_64_32S =            11;
+enum R_X86_64_16 =             12;
+enum R_X86_64_PC16 =           13;
+enum R_X86_64_8 =              14;
+enum R_X86_64_PC8 =            15;
+enum R_X86_64_DTPMOD64 =       16;
+enum R_X86_64_DTPOFF64 =       17;
+enum R_X86_64_TPOFF64 =        18;
+enum R_X86_64_TLSGD =          19;
+enum R_X86_64_TLSLD =          20;
+enum R_X86_64_DTPOFF32 =       21;
+enum R_X86_64_GOTTPOFF =       22;
+enum R_X86_64_TPOFF32 =        23;
+enum R_X86_64_PC64 =           24;
+enum R_X86_64_GOTOFF64 =       25;
+enum R_X86_64_GOTPC32 =        26;
+enum R_X86_64_GOT64 =          27;
+enum R_X86_64_GOTPCREL64 =     28;
+enum R_X86_64_GOTPC64 =        29;
+enum R_X86_64_GOTPLT64 =       30;
+enum R_X86_64_PLTOFF64 =       31;
+enum R_X86_64_SIZE32 =         32;
+enum R_X86_64_SIZE64 =         33;
+enum R_X86_64_GOTPC32_TLSDESC = 34;
+enum R_X86_64_TLSDESC_CALL =   35;
+enum R_X86_64_TLSDESC =        36;
+enum R_X86_64_IRELATIVE =      37;
+enum R_X86_64_RELATIVE64 =     38;
+
+enum R_X86_64_NUM =            39;
+enum R_MN10300_NONE =          0;
+enum R_MN10300_32 =            1;
+enum R_MN10300_16 =            2;
+enum R_MN10300_8 =             3;
+enum R_MN10300_PCREL32 =       4;
+enum R_MN10300_PCREL16 =       5;
+enum R_MN10300_PCREL8 =        6;
+enum R_MN10300_GNU_VTINHERIT = 7;
+enum R_MN10300_GNU_VTENTRY =   8;
+enum R_MN10300_24 =            9;
+enum R_MN10300_GOTPC32 =       10;
+enum R_MN10300_GOTPC16 =       11;
+enum R_MN10300_GOTOFF32 =      12;
+enum R_MN10300_GOTOFF24 =      13;
+enum R_MN10300_GOTOFF16 =      14;
+enum R_MN10300_PLT32 =         15;
+enum R_MN10300_PLT16 =         16;
+enum R_MN10300_GOT32 =         17;
+enum R_MN10300_GOT24 =         18;
+enum R_MN10300_GOT16 =         19;
+enum R_MN10300_COPY =          20;
+enum R_MN10300_GLOB_DAT =      21;
+enum R_MN10300_JMP_SLOT =      22;
+enum R_MN10300_RELATIVE =      23;
+enum R_MN10300_TLS_GD =        24;
+enum R_MN10300_TLS_LD =        25;
+enum R_MN10300_TLS_LDO =       26;
+enum R_MN10300_TLS_GOTIE =     27;
+enum R_MN10300_TLS_IE =        28;
+enum R_MN10300_TLS_LE =        29;
+enum R_MN10300_TLS_DTPMOD =    30;
+enum R_MN10300_TLS_DTPOFF =    31;
+enum R_MN10300_TLS_TPOFF =     32;
+enum R_MN10300_SYM_DIFF =      33;
+enum R_MN10300_ALIGN =         34;
+enum R_MN10300_NUM =           35;
+enum R_M32R_NONE =             0;
+enum R_M32R_16 =               1;
+enum R_M32R_32 =               2;
+enum R_M32R_24 =               3;
+enum R_M32R_10_PCREL =         4;
+enum R_M32R_18_PCREL =         5;
+enum R_M32R_26_PCREL =         6;
+enum R_M32R_HI16_ULO =         7;
+enum R_M32R_HI16_SLO =         8;
+enum R_M32R_LO16 =             9;
+enum R_M32R_SDA16 =            10;
+enum R_M32R_GNU_VTINHERIT =    11;
+enum R_M32R_GNU_VTENTRY =      12;
+enum R_M32R_16_RELA =          33;
+enum R_M32R_32_RELA =          34;
+enum R_M32R_24_RELA =          35;
+enum R_M32R_10_PCREL_RELA =    36;
+enum R_M32R_18_PCREL_RELA =    37;
+enum R_M32R_26_PCREL_RELA =    38;
+enum R_M32R_HI16_ULO_RELA =    39;
+enum R_M32R_HI16_SLO_RELA =    40;
+enum R_M32R_LO16_RELA =        41;
+enum R_M32R_SDA16_RELA =       42;
+enum R_M32R_RELA_GNU_VTINHERIT =       43;
+enum R_M32R_RELA_GNU_VTENTRY = 44;
+enum R_M32R_REL32 =            45;
+
+enum R_M32R_GOT24 =            48;
+enum R_M32R_26_PLTREL =        49;
+enum R_M32R_COPY =             50;
+enum R_M32R_GLOB_DAT =         51;
+enum R_M32R_JMP_SLOT =         52;
+enum R_M32R_RELATIVE =         53;
+enum R_M32R_GOTOFF =           54;
+enum R_M32R_GOTPC24 =          55;
+enum R_M32R_GOT16_HI_ULO =     56;
+enum R_M32R_GOT16_HI_SLO =     57;
+enum R_M32R_GOT16_LO =         58;
+enum R_M32R_GOTPC_HI_ULO =     59;
+enum R_M32R_GOTPC_HI_SLO =     60;
+enum R_M32R_GOTPC_LO =         61;
+enum R_M32R_GOTOFF_HI_ULO =    62;
+enum R_M32R_GOTOFF_HI_SLO =    63;
+enum R_M32R_GOTOFF_LO =        64;
+enum R_M32R_NUM =              256;
+enum R_TILEPRO_NONE =          0;
+enum R_TILEPRO_32 =            1;
+enum R_TILEPRO_16 =            2;
+enum R_TILEPRO_8 =             3;
+enum R_TILEPRO_32_PCREL =      4;
+enum R_TILEPRO_16_PCREL =      5;
+enum R_TILEPRO_8_PCREL =       6;
+enum R_TILEPRO_LO16 =          7;
+enum R_TILEPRO_HI16 =          8;
+enum R_TILEPRO_HA16 =          9;
+enum R_TILEPRO_COPY =          10;
+enum R_TILEPRO_GLOB_DAT =      11;
+enum R_TILEPRO_JMP_SLOT =      12;
+enum R_TILEPRO_RELATIVE =      13;
+enum R_TILEPRO_BROFF_X1 =      14;
+enum R_TILEPRO_JOFFLONG_X1 =   15;
+enum R_TILEPRO_JOFFLONG_X1_PLT = 16;
+enum R_TILEPRO_IMM8_X0 =       17;
+enum R_TILEPRO_IMM8_Y0 =       18;
+enum R_TILEPRO_IMM8_X1 =       19;
+enum R_TILEPRO_IMM8_Y1 =       20;
+enum R_TILEPRO_MT_IMM15_X1 =   21;
+enum R_TILEPRO_MF_IMM15_X1 =   22;
+enum R_TILEPRO_IMM16_X0 =      23;
+enum R_TILEPRO_IMM16_X1 =      24;
+enum R_TILEPRO_IMM16_X0_LO =   25;
+enum R_TILEPRO_IMM16_X1_LO =   26;
+enum R_TILEPRO_IMM16_X0_HI =   27;
+enum R_TILEPRO_IMM16_X1_HI =   28;
+enum R_TILEPRO_IMM16_X0_HA =   29;
+enum R_TILEPRO_IMM16_X1_HA =   30;
+enum R_TILEPRO_IMM16_X0_PCREL = 31;
+enum R_TILEPRO_IMM16_X1_PCREL = 32;
+enum R_TILEPRO_IMM16_X0_LO_PCREL = 33;
+enum R_TILEPRO_IMM16_X1_LO_PCREL = 34;
+enum R_TILEPRO_IMM16_X0_HI_PCREL = 35;
+enum R_TILEPRO_IMM16_X1_HI_PCREL = 36;
+enum R_TILEPRO_IMM16_X0_HA_PCREL = 37;
+enum R_TILEPRO_IMM16_X1_HA_PCREL = 38;
+enum R_TILEPRO_IMM16_X0_GOT =  39;
+enum R_TILEPRO_IMM16_X1_GOT =  40;
+enum R_TILEPRO_IMM16_X0_GOT_LO = 41;
+enum R_TILEPRO_IMM16_X1_GOT_LO = 42;
+enum R_TILEPRO_IMM16_X0_GOT_HI = 43;
+enum R_TILEPRO_IMM16_X1_GOT_HI = 44;
+enum R_TILEPRO_IMM16_X0_GOT_HA = 45;
+enum R_TILEPRO_IMM16_X1_GOT_HA = 46;
+enum R_TILEPRO_MMSTART_X0 =    47;
+enum R_TILEPRO_MMEND_X0 =      48;
+enum R_TILEPRO_MMSTART_X1 =    49;
+enum R_TILEPRO_MMEND_X1 =      50;
+enum R_TILEPRO_SHAMT_X0 =      51;
+enum R_TILEPRO_SHAMT_X1 =      52;
+enum R_TILEPRO_SHAMT_Y0 =      53;
+enum R_TILEPRO_SHAMT_Y1 =      54;
+enum R_TILEPRO_DEST_IMM8_X1 =  55;
+enum R_TILEPRO_TLS_GD_CALL =   60;
+enum R_TILEPRO_IMM8_X0_TLS_GD_ADD = 61;
+enum R_TILEPRO_IMM8_X1_TLS_GD_ADD = 62;
+enum R_TILEPRO_IMM8_Y0_TLS_GD_ADD = 63;
+enum R_TILEPRO_IMM8_Y1_TLS_GD_ADD = 64;
+enum R_TILEPRO_TLS_IE_LOAD =   65;
+enum R_TILEPRO_IMM16_X0_TLS_GD = 66;
+enum R_TILEPRO_IMM16_X1_TLS_GD = 67;
+enum R_TILEPRO_IMM16_X0_TLS_GD_LO = 68;
+enum R_TILEPRO_IMM16_X1_TLS_GD_LO = 69;
+enum R_TILEPRO_IMM16_X0_TLS_GD_HI = 70;
+enum R_TILEPRO_IMM16_X1_TLS_GD_HI = 71;
+enum R_TILEPRO_IMM16_X0_TLS_GD_HA = 72;
+enum R_TILEPRO_IMM16_X1_TLS_GD_HA = 73;
+enum R_TILEPRO_IMM16_X0_TLS_IE = 74;
+enum R_TILEPRO_IMM16_X1_TLS_IE = 75;
+enum R_TILEPRO_IMM16_X0_TLS_IE_LO = 76;
+enum R_TILEPRO_IMM16_X1_TLS_IE_LO = 77;
+enum R_TILEPRO_IMM16_X0_TLS_IE_HI = 78;
+enum R_TILEPRO_IMM16_X1_TLS_IE_HI = 79;
+enum R_TILEPRO_IMM16_X0_TLS_IE_HA = 80;
+enum R_TILEPRO_IMM16_X1_TLS_IE_HA = 81;
+enum R_TILEPRO_TLS_DTPMOD32 =  82;
+enum R_TILEPRO_TLS_DTPOFF32 =  83;
+enum R_TILEPRO_TLS_TPOFF32 =   84;
+enum R_TILEPRO_IMM16_X0_TLS_LE = 85;
+enum R_TILEPRO_IMM16_X1_TLS_LE = 86;
+enum R_TILEPRO_IMM16_X0_TLS_LE_LO = 87;
+enum R_TILEPRO_IMM16_X1_TLS_LE_LO = 88;
+enum R_TILEPRO_IMM16_X0_TLS_LE_HI = 89;
+enum R_TILEPRO_IMM16_X1_TLS_LE_HI = 90;
+enum R_TILEPRO_IMM16_X0_TLS_LE_HA = 91;
+enum R_TILEPRO_IMM16_X1_TLS_LE_HA = 92;
+
+enum R_TILEPRO_GNU_VTINHERIT = 128;
+enum R_TILEPRO_GNU_VTENTRY =   129;
+
+enum R_TILEPRO_NUM =           130;
+enum R_TILEGX_NONE =           0;
+enum R_TILEGX_64 =             1;
+enum R_TILEGX_32 =             2;
+enum R_TILEGX_16 =             3;
+enum R_TILEGX_8 =              4;
+enum R_TILEGX_64_PCREL =       5;
+enum R_TILEGX_32_PCREL =       6;
+enum R_TILEGX_16_PCREL =       7;
+enum R_TILEGX_8_PCREL =        8;
+enum R_TILEGX_HW0 =            9;
+enum R_TILEGX_HW1 =            10;
+enum R_TILEGX_HW2 =            11;
+enum R_TILEGX_HW3 =            12;
+enum R_TILEGX_HW0_LAST =       13;
+enum R_TILEGX_HW1_LAST =       14;
+enum R_TILEGX_HW2_LAST =       15;
+enum R_TILEGX_COPY =           16;
+enum R_TILEGX_GLOB_DAT =       17;
+enum R_TILEGX_JMP_SLOT =       18;
+enum R_TILEGX_RELATIVE =       19;
+enum R_TILEGX_BROFF_X1 =       20;
+enum R_TILEGX_JUMPOFF_X1 =     21;
+enum R_TILEGX_JUMPOFF_X1_PLT = 22;
+enum R_TILEGX_IMM8_X0 =        23;
+enum R_TILEGX_IMM8_Y0 =        24;
+enum R_TILEGX_IMM8_X1 =        25;
+enum R_TILEGX_IMM8_Y1 =        26;
+enum R_TILEGX_DEST_IMM8_X1 =   27;
+enum R_TILEGX_MT_IMM14_X1 =    28;
+enum R_TILEGX_MF_IMM14_X1 =    29;
+enum R_TILEGX_MMSTART_X0 =     30;
+enum R_TILEGX_MMEND_X0 =       31;
+enum R_TILEGX_SHAMT_X0 =       32;
+enum R_TILEGX_SHAMT_X1 =       33;
+enum R_TILEGX_SHAMT_Y0 =       34;
+enum R_TILEGX_SHAMT_Y1 =       35;
+enum R_TILEGX_IMM16_X0_HW0 =   36;
+enum R_TILEGX_IMM16_X1_HW0 =   37;
+enum R_TILEGX_IMM16_X0_HW1 =   38;
+enum R_TILEGX_IMM16_X1_HW1 =   39;
+enum R_TILEGX_IMM16_X0_HW2 =   40;
+enum R_TILEGX_IMM16_X1_HW2 =   41;
+enum R_TILEGX_IMM16_X0_HW3 =   42;
+enum R_TILEGX_IMM16_X1_HW3 =   43;
+enum R_TILEGX_IMM16_X0_HW0_LAST = 44;
+enum R_TILEGX_IMM16_X1_HW0_LAST = 45;
+enum R_TILEGX_IMM16_X0_HW1_LAST = 46;
+enum R_TILEGX_IMM16_X1_HW1_LAST = 47;
+enum R_TILEGX_IMM16_X0_HW2_LAST = 48;
+enum R_TILEGX_IMM16_X1_HW2_LAST = 49;
+enum R_TILEGX_IMM16_X0_HW0_PCREL = 50;
+enum R_TILEGX_IMM16_X1_HW0_PCREL = 51;
+enum R_TILEGX_IMM16_X0_HW1_PCREL = 52;
+enum R_TILEGX_IMM16_X1_HW1_PCREL = 53;
+enum R_TILEGX_IMM16_X0_HW2_PCREL = 54;
+enum R_TILEGX_IMM16_X1_HW2_PCREL = 55;
+enum R_TILEGX_IMM16_X0_HW3_PCREL = 56;
+enum R_TILEGX_IMM16_X1_HW3_PCREL = 57;
+enum R_TILEGX_IMM16_X0_HW0_LAST_PCREL = 58;
+enum R_TILEGX_IMM16_X1_HW0_LAST_PCREL = 59;
+enum R_TILEGX_IMM16_X0_HW1_LAST_PCREL = 60;
+enum R_TILEGX_IMM16_X1_HW1_LAST_PCREL = 61;
+enum R_TILEGX_IMM16_X0_HW2_LAST_PCREL = 62;
+enum R_TILEGX_IMM16_X1_HW2_LAST_PCREL = 63;
+enum R_TILEGX_IMM16_X0_HW0_GOT = 64;
+enum R_TILEGX_IMM16_X1_HW0_GOT = 65;
+enum R_TILEGX_IMM16_X0_HW0_PLT_PCREL = 66;
+enum R_TILEGX_IMM16_X1_HW0_PLT_PCREL = 67;
+enum R_TILEGX_IMM16_X0_HW1_PLT_PCREL = 68;
+enum R_TILEGX_IMM16_X1_HW1_PLT_PCREL = 69;
+enum R_TILEGX_IMM16_X0_HW2_PLT_PCREL = 70;
+enum R_TILEGX_IMM16_X1_HW2_PLT_PCREL = 71;
+enum R_TILEGX_IMM16_X0_HW0_LAST_GOT = 72;
+enum R_TILEGX_IMM16_X1_HW0_LAST_GOT = 73;
+enum R_TILEGX_IMM16_X0_HW1_LAST_GOT = 74;
+enum R_TILEGX_IMM16_X1_HW1_LAST_GOT = 75;
+enum R_TILEGX_IMM16_X0_HW3_PLT_PCREL = 76;
+enum R_TILEGX_IMM16_X1_HW3_PLT_PCREL = 77;
+enum R_TILEGX_IMM16_X0_HW0_TLS_GD = 78;
+enum R_TILEGX_IMM16_X1_HW0_TLS_GD = 79;
+enum R_TILEGX_IMM16_X0_HW0_TLS_LE = 80;
+enum R_TILEGX_IMM16_X1_HW0_TLS_LE = 81;
+enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE = 82;
+enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE = 83;
+enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE = 84;
+enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE = 85;
+enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD = 86;
+enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD = 87;
+enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD = 88;
+enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD = 89;
+enum R_TILEGX_IMM16_X0_HW0_TLS_IE = 92;
+enum R_TILEGX_IMM16_X1_HW0_TLS_IE = 93;
+enum R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL = 94;
+enum R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL = 95;
+enum R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL = 96;
+enum R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL = 97;
+enum R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL = 98;
+enum R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL = 99;
+enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE = 100;
+enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE = 101;
+enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE = 102;
+enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE = 103;
+enum R_TILEGX_TLS_DTPMOD64 =   106;
+enum R_TILEGX_TLS_DTPOFF64 =   107;
+enum R_TILEGX_TLS_TPOFF64 =    108;
+enum R_TILEGX_TLS_DTPMOD32 =   109;
+enum R_TILEGX_TLS_DTPOFF32 =   110;
+enum R_TILEGX_TLS_TPOFF32 =    111;
+enum R_TILEGX_TLS_GD_CALL =    112;
+enum R_TILEGX_IMM8_X0_TLS_GD_ADD = 113;
+enum R_TILEGX_IMM8_X1_TLS_GD_ADD = 114;
+enum R_TILEGX_IMM8_Y0_TLS_GD_ADD = 115;
+enum R_TILEGX_IMM8_Y1_TLS_GD_ADD = 116;
+enum R_TILEGX_TLS_IE_LOAD =    117;
+enum R_TILEGX_IMM8_X0_TLS_ADD = 118;
+enum R_TILEGX_IMM8_X1_TLS_ADD = 119;
+enum R_TILEGX_IMM8_Y0_TLS_ADD = 120;
+enum R_TILEGX_IMM8_Y1_TLS_ADD = 121;
+
+enum R_TILEGX_GNU_VTINHERIT =  128;
+enum R_TILEGX_GNU_VTENTRY =    129;
+
+enum R_TILEGX_NUM =            130;
diff --git a/libphobos/libdruntime/core/sys/linux/epoll.d b/libphobos/libdruntime/core/sys/linux/epoll.d
new file mode 100644
index 00000000000..c22f39184b5
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/epoll.d
@@ -0,0 +1,130 @@
+/**
+ * D header file to interface with the Linux epoll API (http://man7.org/linux/man-pages/man7/epoll.7.html).
+ * Available since Linux 2.6
+ *
+ * Copyright: Copyright Adil Baig 2012.
+ * License : $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors  : Adil Baig (github.com/adilbaig)
+ */
+module core.sys.linux.epoll;
+
+version (linux):
+
+extern (C):
+@system:
+nothrow:
+
+enum
+{
+    EPOLL_CLOEXEC  = 0x80000,
+    EPOLL_NONBLOCK = 0x800
+}
+
+enum
+{
+    EPOLLIN     = 0x001,
+    EPOLLPRI    = 0x002,
+    EPOLLOUT    = 0x004,
+    EPOLLRDNORM = 0x040,
+    EPOLLRDBAND = 0x080,
+    EPOLLWRNORM = 0x100,
+    EPOLLWRBAND = 0x200,
+    EPOLLMSG    = 0x400,
+    EPOLLERR    = 0x008,
+    EPOLLHUP    = 0x010,
+    EPOLLRDHUP  = 0x2000, // since Linux 2.6.17
+    EPOLLONESHOT = 1u << 30,
+    EPOLLET     = 1u << 31
+}
+
+/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl().  */
+enum
+{
+    EPOLL_CTL_ADD = 1, // Add a file descriptor to the interface.
+    EPOLL_CTL_DEL = 2, // Remove a file descriptor from the interface.
+    EPOLL_CTL_MOD = 3, // Change file descriptor epoll_event structure.
+}
+
+version (X86)
+{
+    align(1) struct epoll_event
+    {
+    align(1):
+        uint events;
+        epoll_data_t data;
+    }
+}
+else version (X86_64)
+{
+    align(1) struct epoll_event
+    {
+    align(1):
+        uint events;
+        epoll_data_t data;
+    }
+}
+else version (ARM)
+{
+    struct epoll_event
+    {
+        uint events;
+        epoll_data_t data;
+    }
+}
+else version (AArch64)
+{
+    struct epoll_event
+    {
+        uint events;
+        epoll_data_t data;
+    }
+}
+else version (PPC)
+{
+    struct epoll_event
+    {
+        uint events;
+        epoll_data_t data;
+    }
+}
+else version (PPC64)
+{
+    struct epoll_event
+    {
+        uint events;
+        epoll_data_t data;
+    }
+}
+else version (MIPS64)
+{
+    struct epoll_event
+    {
+        uint events;
+        epoll_data_t data;
+    }
+}
+else version (SystemZ)
+{
+    struct epoll_event
+    {
+        uint events;
+        epoll_data_t data;
+    }
+}
+else
+{
+    static assert(false, "Platform not supported");
+}
+
+union epoll_data_t
+{
+    void *ptr;
+    int fd;
+    uint u32;
+    ulong u64;
+}
+
+int epoll_create (int size);
+int epoll_create1 (int flags);
+int epoll_ctl (int epfd, int op, int fd, epoll_event *event);
+int epoll_wait (int epfd, epoll_event *events, int maxevents, int timeout);
diff --git a/libphobos/libdruntime/core/sys/linux/errno.d b/libphobos/libdruntime/core/sys/linux/errno.d
new file mode 100644
index 00000000000..bc93675c735
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/errno.d
@@ -0,0 +1,19 @@
+/**
+ * D header file for GNU/Linux
+ *
+ * $(LINK2 http://sourceware.org/git/?p=glibc.git;a=blob;f=stdlib/errno.h, glibc stdlib/errno.h)
+ */
+module core.sys.linux.errno;
+
+version (linux):
+extern (C):
+nothrow:
+
+public import core.stdc.errno;
+import core.sys.linux.config;
+
+static if (__USE_GNU)
+{
+    extern __gshared char* program_invocation_name, program_invocation_short_name;
+    alias error_t = int;
+}
diff --git a/libphobos/libdruntime/core/sys/linux/execinfo.d b/libphobos/libdruntime/core/sys/linux/execinfo.d
new file mode 100644
index 00000000000..3259443fe53
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/execinfo.d
@@ -0,0 +1,16 @@
+/**
+ * D header file for GNU/Linux.
+ *
+ * Copyright: Copyright Martin Nowak 2012.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Martin Nowak
+ */
+module core.sys.linux.execinfo;
+
+version (linux):
+extern (C):
+nothrow:
+
+int backtrace(void** buffer, int size);
+char** backtrace_symbols(const(void*)* buffer, int size);
+void backtrace_symbols_fd(const(void*)* buffer, int size, int fd);
diff --git a/libphobos/libdruntime/core/sys/linux/fcntl.d b/libphobos/libdruntime/core/sys/linux/fcntl.d
new file mode 100644
index 00000000000..2d15aa118ca
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/fcntl.d
@@ -0,0 +1,18 @@
+module core.sys.linux.fcntl;
+
+public import core.sys.posix.fcntl;
+
+version (linux):
+extern(C):
+nothrow:
+
+// From linux/falloc.h
+enum {
+    FALLOC_FL_KEEP_SIZE = 0x01,
+    FALLOC_FL_PUNCH_HOLE = 0x02,
+    FALLOC_FL_NO_HIDE_STALE = 0x04
+}
+
+// Linux-specific fallocate
+// (http://man7.org/linux/man-pages/man2/fallocate.2.html)
+int fallocate(int fd, int mode, off_t offset, off_t len);
diff --git a/libphobos/libdruntime/core/sys/linux/link.d b/libphobos/libdruntime/core/sys/linux/link.d
new file mode 100644
index 00000000000..34be70f6f15
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/link.d
@@ -0,0 +1,177 @@
+/**
+ * D header file for GNU/Linux
+ *
+ * $(LINK2 http://sourceware.org/git/?p=glibc.git;a=blob;f=elf/link.h, glibc elf/link.h)
+ */
+module core.sys.linux.link;
+
+version (linux):
+extern (C):
+nothrow:
+
+import core.stdc.stdint : uintptr_t, uint32_t, uint64_t;
+import core.sys.linux.config : __WORDSIZE;
+import core.sys.linux.dlfcn : Lmid_t;
+import core.sys.linux.elf;
+
+// <bits/elfclass.h>
+version (X86)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h
+    alias __WORDSIZE __ELF_NATIVE_CLASS;
+    alias uint32_t Elf_Symndx;
+}
+else version (X86_64)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h
+    alias __WORDSIZE __ELF_NATIVE_CLASS;
+    alias uint32_t Elf_Symndx;
+}
+else version (MIPS32)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h
+    alias __WORDSIZE __ELF_NATIVE_CLASS;
+    alias uint32_t Elf_Symndx;
+}
+else version (MIPS64)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h
+    alias __WORDSIZE __ELF_NATIVE_CLASS;
+    alias uint32_t Elf_Symndx;
+}
+else version (PPC)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h
+    alias __WORDSIZE __ELF_NATIVE_CLASS;
+    alias uint32_t Elf_Symndx;
+}
+else version (PPC64)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h
+    alias __WORDSIZE __ELF_NATIVE_CLASS;
+    alias uint32_t Elf_Symndx;
+}
+else version (ARM)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h
+    alias __WORDSIZE __ELF_NATIVE_CLASS;
+    alias uint32_t Elf_Symndx;
+}
+else version (AArch64)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h
+    alias __WORDSIZE __ELF_NATIVE_CLASS;
+    alias uint32_t Elf_Symndx;
+}
+else version (SystemZ)
+{
+    // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h
+    alias __WORDSIZE __ELF_NATIVE_CLASS;
+    alias uint64_t Elf_Symndx;
+}
+else
+    static assert(0, "unimplemented");
+// <bits/elfclass.h>
+
+template ElfW(string type)
+{
+    mixin("alias Elf"~__ELF_NATIVE_CLASS.stringof~"_"~type~" ElfW;");
+}
+
+enum
+{
+    RT_CONSISTENT,
+    RT_ADD,
+    RT_DELETE,
+}
+
+struct r_debug
+{
+    int r_version;
+    link_map* r_map;
+    ElfW!"Addr" r_brk;
+    typeof(RT_CONSISTENT) r_state;
+    ElfW!"Addr" r_ldbase;
+}
+
+extern r_debug _r_debug;
+extern ElfW!"Dyn"* _DYNAMIC;
+
+struct link_map
+{
+    ElfW!"Addr" l_addr;
+    char* l_name;
+    ElfW!"Dyn"* l_ld;
+    link_map* l_next, l_prev;
+}
+
+enum
+{
+    LA_ACT_CONSISTENT,
+    LA_ACT_ADD,
+    LA_ACT_DELETE,
+}
+
+enum
+{
+    LA_SER_ORIG = 0x01,
+    LA_SER_LIBPATH = 0x02,
+    LA_SER_RUNPATH = 0x04,
+    LA_SER_CONFIG = 0x08,
+    LA_SER_DEFAULT = 0x40,
+    LA_SER_SECURE = 0x80,
+}
+
+
+enum
+{
+    LA_FLG_BINDTO = 0x01,
+    LA_FLG_BINDFROM = 0x02,
+}
+
+
+enum
+{
+    LA_SYMB_NOPLTENTER = 0x01,
+    LA_SYMB_NOPLTEXIT = 0x02,
+    LA_SYMB_STRUCTCALL = 0x04,
+    LA_SYMB_DLSYM = 0x08,
+    LA_SYMB_ALTVALUE = 0x10,
+}
+
+struct dl_phdr_info
+{
+    ElfW!"Addr" dlpi_addr;
+    const(char)* dlpi_name;
+    const(ElfW!"Phdr")* dlpi_phdr;
+    ElfW!"Half" dlpi_phnum;
+
+    // check the SIZE argument of the dl_iterate_phdr callback whether
+    // the following members are available
+    ulong dlpi_adds;
+    ulong dlpi_subs;
+
+    size_t dlpi_tls_modid;
+    void *dlpi_tls_data;
+}
+
+private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb;
+private alias extern(C) int function(dl_phdr_info*, size_t, void *) @nogc dl_iterate_phdr_cb_ngc;
+extern int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data);
+extern int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc;
+
+// ld.so auditing interfaces prototypes have to be defined by the auditing DSO.
+extern uint la_version(uint __version);
+extern void la_activity(uintptr_t *__cookie, uint __flag);
+extern char* la_objsearch(const(char)* __name, uintptr_t* __cookie,
+                          uint __flag);
+extern uint la_objopen(link_map* __map, Lmid_t __lmid,
+                       uintptr_t* __cookie);
+extern void la_preinit(uintptr_t* __cookie);
+extern uintptr_t la_symbind32(Elf32_Sym* __sym, uint __ndx,
+                              uintptr_t* __refcook, uintptr_t* __defcook,
+                              uint *__flags, const(char)* __symname);
+extern uintptr_t la_symbind64(Elf64_Sym* __sym, uint __ndx,
+                              uintptr_t* __refcook, uintptr_t* __defcook,
+                              uint* __flags, const(char)* __symname);
+extern uint la_objclose(uintptr_t *__cookie);
diff --git a/libphobos/libdruntime/core/sys/linux/stdio.d b/libphobos/libdruntime/core/sys/linux/stdio.d
new file mode 100644
index 00000000000..ba6cdc0586a
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/stdio.d
@@ -0,0 +1,105 @@
+/**
+  * D header file for GNU stdio.
+  *
+  * Copyright: Danny Milosavljevic 2014
+  * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
+  * Authors: Danny Milosavljevic
+  */
+module core.sys.linux.stdio;
+version (CRuntime_Glibc):
+public import core.sys.posix.stdio;
+import core.sys.posix.sys.types : ssize_t, off64_t = off_t;
+import core.sys.linux.config : __USE_FILE_OFFSET64;
+import core.stdc.stdio : FILE;
+import core.stdc.stddef : wchar_t;
+
+extern(C) nothrow
+{
+    alias ssize_t function(void *cookie, char *buf, size_t size) cookie_read_function_t;
+    alias ssize_t function(void *cookie, const(char) *buf, size_t size) cookie_write_function_t;
+    alias int function(void *cookie, off64_t *offset, int whence) cookie_seek_function_t;
+    alias int function(void *cookie) cookie_close_function_t;
+
+    struct cookie_io_functions_t
+    {
+        cookie_read_function_t read;
+        cookie_write_function_t write;
+        cookie_seek_function_t seek;
+        cookie_close_function_t close;
+    }
+    FILE* fopencookie(in void* cookie, in char* mode, cookie_io_functions_t io_funcs);
+    void setbuffer(FILE *stream, char *buf, size_t size); // note: _BSD_SOURCE
+}
+
+unittest
+{
+    static int flag = 0;
+    static int written = 0;
+    static int closed = 0;
+    // Note: this test needs to run on both a 32 and a 64 bit machine, both have to pass.
+    import core.stdc.errno : errno, EBADF;
+    //import core.sys.posix.sys.stat : off64_t;
+    import core.stdc.stdio : FILE, fflush, fileno, fprintf, fgetc, EOF, fclose;
+    import core.stdc.string : memcpy, memset;
+    extern (C) ssize_t specialRead(void *cookie, char *buf, size_t size) nothrow
+    {
+        memset(buf, 'a', size);
+        return size;
+    }
+    extern (C) int specialClose(void* cookie) nothrow
+    {
+        ++closed;
+        return 0;
+    }
+    extern (C) ssize_t specialWrite(void *cookie, const(char) *buf, size_t size) nothrow
+    {
+        int* c = cast(int*) cookie;
+        flag = *c;
+        written += size;
+        return size;
+    }
+    int dummy = 42;
+    cookie_io_functions_t fns =
+    {
+        read: &specialRead,
+        write: &specialWrite,
+        close: &specialClose,
+    };
+    FILE* f = fopencookie(&dummy, "r+", fns);
+    assert(f !is null);
+    //File.open();
+    //auto g = File(f);
+    assert(fileno(f) == -1 && errno == EBADF);
+    assert(fprintf(f, "hello") == "hello".length);
+    //assert(errno == EBADF);
+    assert(fflush(f) == 0);
+    assert(written == "hello".length);
+    // Note: do not swap reading and writing here.
+    int c = 0;
+    while((c = fgetc(f)) != EOF)
+    {
+        assert(c == 'a');
+        break; // endless otherwise
+    }
+    assert(c == 'a');
+    assert(fclose(f) == 0);
+    assert(closed == 1);
+    assert(flag == dummy);
+    //stdin.getFP();
+    //assert(stdin.fileno() == 0);
+}
+
+unittest
+{ /* setbuffer */
+    char buf;
+    int c;
+    byte[10] dummy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+    FILE* f = fmemopen(dummy.ptr, 10, "r");
+    assert(f !is null);
+    setbuffer(f, &buf, 1);
+    assert(fgetc(f) == 1);
+    assert(fgetc(f) == 2);
+    assert(fgetc(f) == 3);
+    assert(fgetc(f) == 4);
+    assert(fclose(f) == 0);
+}
diff --git a/libphobos/libdruntime/core/sys/linux/sys/inotify.d b/libphobos/libdruntime/core/sys/linux/sys/inotify.d
new file mode 100644
index 00000000000..41ad65c2e31
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/sys/inotify.d
@@ -0,0 +1,102 @@
+/**
+ * D header file for GNU/Linux.
+ *
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Gary Willoughby
+ */
+module core.sys.linux.sys.inotify;
+
+version (linux):
+extern (C):
+@system:
+nothrow:
+
+struct inotify_event
+{
+    int wd;
+    uint mask;
+    uint cookie;
+    uint len;
+    char[0] name;
+}
+
+enum: uint
+{
+    IN_ACCESS        = 0x00000000,
+    IN_MODIFY        = 0x00000002,
+    IN_ATTRIB        = 0x00000004,
+    IN_CLOSE_WRITE   = 0x00000008,
+    IN_CLOSE_NOWRITE = 0x00000010,
+    IN_OPEN          = 0x00000020,
+    IN_MOVED_FROM    = 0x00000040,
+    IN_MOVED_TO      = 0x00000080,
+    IN_CREATE        = 0x00000100,
+    IN_DELETE        = 0x00000200,
+    IN_DELETE_SELF   = 0x00000400,
+    IN_MOVE_SELF     = 0x00000800,
+    IN_UMOUNT        = 0x00002000,
+    IN_Q_OVERFLOW    = 0x00004000,
+    IN_IGNORED       = 0x00008000,
+    IN_CLOSE         = 0x00000018,
+    IN_MOVE          = 0x000000C0,
+    IN_ONLYDIR       = 0x01000000,
+    IN_DONT_FOLLOW   = 0x02000000,
+    IN_EXCL_UNLINK   = 0x04000000,
+    IN_MASK_ADD      = 0x20000000,
+    IN_ISDIR         = 0x40000000,
+    IN_ONESHOT       = 0x80000000,
+    IN_ALL_EVENTS    = 0x80000FFF,
+}
+
+version (X86)
+{
+    enum IN_CLOEXEC = 0x80000; // octal!2000000
+    enum IN_NONBLOCK = 0x800; // octal!4000
+}
+else version (X86_64)
+{
+    enum IN_CLOEXEC = 0x80000; // octal!2000000
+    enum IN_NONBLOCK = 0x800; // octal!4000
+}
+else version (MIPS32)
+{
+    enum IN_CLOEXEC = 0x80000; // octal!2000000
+    enum IN_NONBLOCK = 0x80; // octal!200
+}
+else version (MIPS64)
+{
+    enum IN_CLOEXEC = 0x80000; // octal!2000000
+    enum IN_NONBLOCK = 0x80; // octal!200
+}
+else version (PPC)
+{
+    enum IN_CLOEXEC = 0x80000; // octal!2000000
+    enum IN_NONBLOCK = 0x800; // octal!4000
+}
+else version (PPC64)
+{
+    enum IN_CLOEXEC = 0x80000; // octal!2000000
+    enum IN_NONBLOCK = 0x800; // octal!4000
+}
+else version (ARM)
+{
+    enum IN_CLOEXEC = 0x80000; // octal!2000000
+    enum IN_NONBLOCK = 0x800; // octal!4000
+}
+else version (AArch64)
+{
+    enum IN_CLOEXEC = 0x80000; // octal!2000000
+    enum IN_NONBLOCK = 0x800; // octal!4000
+}
+else version (SystemZ)
+{
+    enum IN_CLOEXEC = 0x80000; // octal!2000000
+    enum IN_NONBLOCK = 0x800; // octal!4000
+}
+else
+    static assert(0, "unimplemented");
+
+int inotify_init();
+int inotify_init1(int flags);
+int inotify_add_watch(int fd, const(char)* name, uint mask);
+int inotify_rm_watch(int fd, uint wd);
diff --git a/libphobos/libdruntime/core/sys/linux/sys/mman.d b/libphobos/libdruntime/core/sys/linux/sys/mman.d
new file mode 100644
index 00000000000..109c085efe4
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/sys/mman.d
@@ -0,0 +1,724 @@
+/**
+ * D header file for GNU/Linux
+ *
+ * Authors: Martin Nowak
+ */
+module core.sys.linux.sys.mman;
+
+version (linux):
+extern (C):
+nothrow:
+
+public import core.sys.posix.sys.mman;
+import core.sys.linux.config;
+
+// <bits/mman.h>
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/powerpc/bits/mman.h
+version (PPC)
+{
+    enum PROT_SAO = 0x10;
+
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x00100,
+        MAP_DENYWRITE = 0x00800,
+        MAP_EXECUTABLE = 0x01000,
+        MAP_LOCKED = 0x00080,
+        MAP_NORESERVE = 0x00040,
+        MAP_POPULATE = 0x08000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+
+    // in core.sys.posix.sys.mman
+    // enum
+    // {
+    //     MCL_CURRENT = 0x2000,
+    //     MCL_FUTURE = 0x4000,
+    // }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/powerpc/bits/mman.h
+else version (PPC64)
+{
+    enum PROT_SAO = 0x10;
+
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x00100,
+        MAP_DENYWRITE = 0x00800,
+        MAP_EXECUTABLE = 0x01000,
+        MAP_LOCKED = 0x00080,
+        MAP_NORESERVE = 0x00040,
+        MAP_POPULATE = 0x08000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+
+    // in core.sys.posix.sys.mman
+    // enum
+    // {
+    //     MCL_CURRENT = 0x2000,
+    //     MCL_FUTURE = 0x4000,
+    // }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/s390/bits/mman.h
+else version (S390)
+{
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x00100,
+        MAP_DENYWRITE = 0x00800,
+        MAP_EXECUTABLE = 0x01000,
+        MAP_LOCKED = 0x02000,
+        MAP_NORESERVE = 0x04000,
+        MAP_POPULATE = 0x08000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/s390/bits/mman.h
+else version (SystemZ)
+{
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x00100,
+        MAP_DENYWRITE = 0x00800,
+        MAP_EXECUTABLE = 0x01000,
+        MAP_LOCKED = 0x02000,
+        MAP_NORESERVE = 0x04000,
+        MAP_POPULATE = 0x08000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sh/bits/mman.h
+else version (SH)
+{
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x0100,
+        MAP_DENYWRITE = 0x0800,
+        MAP_EXECUTABLE = 0x1000,
+        MAP_LOCKED = 0x2000,
+        MAP_NORESERVE = 0x4000,
+        MAP_POPULATE = 0x8000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sh/bits/mman.h
+else version (SH64)
+{
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x0100,
+        MAP_DENYWRITE = 0x0800,
+        MAP_EXECUTABLE = 0x1000,
+        MAP_LOCKED = 0x2000,
+        MAP_NORESERVE = 0x4000,
+        MAP_POPULATE = 0x8000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sparc/bits/mman.h
+else version (SPARC)
+{
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x0200,
+        MAP_DENYWRITE = 0x0800,
+        MAP_EXECUTABLE = 0x1000,
+        MAP_LOCKED = 0x0100,
+        MAP_NORESERVE = 0x0040,
+        _MAP_NEW = 0x80000000,
+        MAP_POPULATE = 0x8000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+
+    // in core.sys.posix.sys.mman
+    // enum
+    // {
+    //     MCL_CURRENT = 0x2000,
+    //     MCL_FUTURE = 0x4000,
+    // }
+
+    static if (__USE_MISC) enum MAP_RENAME MAP_ANONYMOUS;
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sparc/bits/mman.h
+else version (SPARC64)
+{
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x0200,
+        MAP_DENYWRITE = 0x0800,
+        MAP_EXECUTABLE = 0x1000,
+        MAP_LOCKED = 0x0100,
+        MAP_NORESERVE = 0x0040,
+        _MAP_NEW = 0x80000000,
+        MAP_POPULATE = 0x8000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+
+    // in core.sys.posix.sys.mman
+    // enum
+    // {
+    //     MCL_CURRENT = 0x2000,
+    //     MCL_FUTURE = 0x4000,
+    // }
+
+    static if (__USE_MISC) enum MAP_RENAME MAP_ANONYMOUS;
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/x86/bits/mman.h
+else version (X86)
+{
+    static if (__USE_MISC) enum MAP_32BIT = 0x40;
+
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x00100,
+        MAP_DENYWRITE = 0x00800,
+        MAP_EXECUTABLE = 0x01000,
+        MAP_LOCKED = 0x02000,
+        MAP_NORESERVE = 0x04000,
+        MAP_POPULATE = 0x08000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/x86/bits/mman.h
+else version (X86_64)
+{
+    static if (__USE_MISC) enum MAP_32BIT = 0x40;
+
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x00100,
+        MAP_DENYWRITE = 0x00800,
+        MAP_EXECUTABLE = 0x01000,
+        MAP_LOCKED = 0x02000,
+        MAP_NORESERVE = 0x04000,
+        MAP_POPULATE = 0x08000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/unix/sysv/linux/aarch64/bits/mman.h
+else version (AArch64)
+{
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x00100,
+        MAP_DENYWRITE = 0x00800,
+        MAP_EXECUTABLE = 0x01000,
+        MAP_LOCKED = 0x02000,
+        MAP_NORESERVE = 0x04000,
+        MAP_POPULATE = 0x08000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/unix/sysv/linux/alpha/bits/mman.h
+else version (Alpha)
+{
+    enum
+    {
+        PROT_READ = 0x1,
+        PROT_WRITE = 0x2,
+        PROT_EXEC = 0x4,
+        PROT_NONE = 0x0,
+        PROT_GROWSDOWN = 0x01000000,
+        PROT_GROWSUP = 0x02000000,
+    }
+
+    enum MAP_SHARED = 0x01;
+    enum MAP_PRIVATE = 0x02;
+    static if (__USE_MISC)
+        enum MAP_TYPE = 0x0f;
+
+    enum MAP_FIXED = 0x10;
+    static if (__USE_MISC) enum
+    {
+        MAP_FILE = 0,
+        MAP_ANONYMOUS = MAP_ANON,
+        // in core.sys.posix.sys.mman
+        // MAP_ANON = MAP_ANONYMOUS,
+        MAP_HUGE_SHIFT = 26,
+        MAP_HUGE_MASK = 0x3f,
+    }
+
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x01000,
+        MAP_DENYWRITE = 0x02000,
+        MAP_EXECUTABLE = 0x04000,
+        MAP_LOCKED = 0x08000,
+        MAP_NORESERVE = 0x10000,
+        MAP_POPULATE = 0x20000,
+        MAP_NONBLOCK = 0x40000,
+        MAP_STACK = 0x80000,
+        MAP_HUGETLB = 0x100000,
+    }
+
+    // in core.sys.posix.sys.mman
+    // enum
+    // {
+    //     MS_ASYNC = 1,
+    //     MS_SYNC = 2,
+    //     MS_INVALIDATE = 4,
+    // }
+
+    // in core.sys.posix.sys.mman
+    // enum
+    // {
+    //     MCL_CURRENT = 8192,
+    //     MCL_FUTURE = 16384,
+    // }
+
+    static if (__USE_GNU) enum
+    {
+        MREMAP_MAYMOVE = 1,
+        MREMAP_FIXED = 2,
+    }
+
+    static if (__USE_BSD) enum
+    {
+        MADV_NORMAL = 0,
+        MADV_RANDOM = 1,
+        MADV_SEQUENTIAL = 2,
+        MADV_WILLNEED = 3,
+        MADV_DONTNEED = 6,
+        MADV_REMOVE = 9,
+        MADV_DONTFORK = 10,
+        MADV_DOFORK = 11,
+        MADV_MERGEABLE = 12,
+        MADV_UNMERGEABLE = 13,
+        MADV_HUGEPAGE = 14,
+        MADV_NOHUGEPAGE = 15,
+        MADV_DONTDUMP = 16,
+        MADV_DODUMP = 17,
+        MADV_HWPOISON = 100,
+    }
+
+    // in core.sys.posix.sys.mman
+    // static if (__USE_XOPEN2K) enum
+    // {
+    //         POSIX_MADV_NORMAL = 0,
+    //         POSIX_MADV_RANDOM = 1,
+    //         POSIX_MADV_SEQUENTIAL = 2,
+    //         POSIX_MADV_WILLNEED = 3,
+    //         POSIX_MADV_DONTNEED = 6,
+    // }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/unix/sysv/linux/arm/bits/mman.h
+else version (ARM)
+{
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x00100,
+        MAP_DENYWRITE = 0x00800,
+        MAP_EXECUTABLE = 0x01000,
+        MAP_LOCKED = 0x02000,
+        MAP_NORESERVE = 0x04000,
+        MAP_POPULATE = 0x08000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/unix/sysv/linux/hppa/bits/mman.h
+else version (HPPA)
+{
+    enum
+    {
+        PROT_READ = 0x1,
+        PROT_WRITE = 0x2,
+        PROT_EXEC = 0x4,
+        PROT_NONE = 0x0,
+        PROT_GROWSDOWN = 0x01000000,
+        PROT_GROWSUP = 0x02000000,
+    }
+
+    enum MAP_SHARED = 0x01;
+    enum MAP_PRIVATE = 0x02;
+    static if (__USE_MISC)
+        enum MAP_TYPE = 0x0f;
+
+    enum MAP_FIXED = 0x04;
+    static if (__USE_MISC) enum
+    {
+        MAP_FILE = 0,
+        MAP_ANONYMOUS = MAP_ANON,
+        // in core.sys.posix.sys.mman
+        // MAP_ANON = MAP_ANONYMOUS,
+        MAP_VARIABLE = 0,
+        MAP_HUGE_SHIFT = 26,
+        MAP_HUGE_MASK = 0x3f,
+    }
+
+    static if (__USE_MISC) enum
+    {
+        MAP_DENYWRITE = 0x0800,
+        MAP_EXECUTABLE = 0x1000,
+        MAP_LOCKED = 0x2000,
+        MAP_NORESERVE = 0x4000,
+        MAP_GROWSDOWN = 0x8000,
+        MAP_POPULATE = 0x10000,
+        MAP_NONBLOCK = 0x20000,
+    }
+
+    // in core.sys.posix.sys.mman
+    // enum
+    // {
+    //     MS_ASYNC = 1,
+    //     MS_SYNC = 2,
+    //     MS_INVALIDATE = 4,
+    // }
+
+    // in core.sys.posix.sys.mman
+    // enum
+    // {
+    //     MCL_CURRENT = 1,
+    //     MCL_FUTURE = 2,
+    // }
+
+    static if (__USE_GNU) enum
+    {
+        MREMAP_MAYMOVE = 1,
+        MREMAP_FIXED = 2,
+    }
+
+    static if (__USE_BSD) enum
+    {
+        MADV_NORMAL = 0,
+        MADV_RANDOM = 1,
+        MADV_SEQUENTIAL = 2,
+        MADV_WILLNEED = 3,
+        MADV_DONTNEED = 4,
+        MADV_SPACEAVAIL = 5,
+        MADV_VPS_PURGE = 6,
+        MADV_VPS_INHERIT = 7,
+        MADV_REMOVE = 9,
+        MADV_DONTFORK = 10,
+        MADV_DOFORK = 11,
+        MADV_MERGEABLE = 65,
+        MADV_UNMERGEABLE = 66,
+    }
+
+    enum
+    {
+        MADV_4K_PAGES = 12,
+        MADV_16K_PAGES = 14,
+        MADV_64K_PAGES = 16,
+        MADV_256K_PAGES = 18,
+        MADV_1M_PAGES = 20,
+        MADV_4M_PAGES = 22,
+        MADV_16M_PAGES = 24,
+        MADV_64M_PAGES = 26,
+    }
+
+    // in core.sys.posix.sys.mman
+    // static if (__USE_XOPEN2K) enum
+    // {
+    //     POSIX_MADV_NORMAL = 0,
+    //     POSIX_MADV_RANDOM = 1,
+    //     POSIX_MADV_SEQUENTIAL = 2,
+    //     POSIX_MADV_WILLNEED = 3,
+    //     POSIX_MADV_DONTNEED = 4,
+    // }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/unix/sysv/linux/hppa/bits/mman.h
+else version (HPPA64)
+{
+    enum
+    {
+        PROT_READ = 0x1,
+        PROT_WRITE = 0x2,
+        PROT_EXEC = 0x4,
+        PROT_NONE = 0x0,
+        PROT_GROWSDOWN = 0x01000000,
+        PROT_GROWSUP = 0x02000000,
+    }
+
+    enum MAP_SHARED = 0x01;
+    enum MAP_PRIVATE = 0x02;
+    static if (__USE_MISC)
+        enum MAP_TYPE = 0x0f;
+
+    enum MAP_FIXED = 0x04;
+    static if (__USE_MISC) enum
+    {
+        MAP_FILE = 0,
+        MAP_ANONYMOUS = MAP_ANON,
+        // in core.sys.posix.sys.mman
+        // MAP_ANON = MAP_ANONYMOUS,
+        MAP_VARIABLE = 0,
+        MAP_HUGE_SHIFT = 26,
+        MAP_HUGE_MASK = 0x3f,
+    }
+
+    static if (__USE_MISC) enum
+    {
+        MAP_DENYWRITE = 0x0800,
+        MAP_EXECUTABLE = 0x1000,
+        MAP_LOCKED = 0x2000,
+        MAP_NORESERVE = 0x4000,
+        MAP_GROWSDOWN = 0x8000,
+        MAP_POPULATE = 0x10000,
+        MAP_NONBLOCK = 0x20000,
+    }
+
+    // in core.sys.posix.sys.mman
+    // enum
+    // {
+    //     MS_ASYNC = 1,
+    //     MS_SYNC = 2,
+    //     MS_INVALIDATE = 4,
+    // }
+
+    // in core.sys.posix.sys.mman
+    // enum
+    // {
+    //     MCL_CURRENT = 1,
+    //     MCL_FUTURE = 2,
+    // }
+
+    static if (__USE_GNU) enum
+    {
+        MREMAP_MAYMOVE = 1,
+        MREMAP_FIXED = 2,
+    }
+
+    static if (__USE_BSD) enum
+    {
+        MADV_NORMAL = 0,
+        MADV_RANDOM = 1,
+        MADV_SEQUENTIAL = 2,
+        MADV_WILLNEED = 3,
+        MADV_DONTNEED = 4,
+        MADV_SPACEAVAIL = 5,
+        MADV_VPS_PURGE = 6,
+        MADV_VPS_INHERIT = 7,
+        MADV_REMOVE = 9,
+        MADV_DONTFORK = 10,
+        MADV_DOFORK = 11,
+        MADV_MERGEABLE = 65,
+        MADV_UNMERGEABLE = 66,
+    }
+
+    enum
+    {
+        MADV_4K_PAGES = 12,
+        MADV_16K_PAGES = 14,
+        MADV_64K_PAGES = 16,
+        MADV_256K_PAGES = 18,
+        MADV_1M_PAGES = 20,
+        MADV_4M_PAGES = 22,
+        MADV_16M_PAGES = 24,
+        MADV_64M_PAGES = 26,
+    }
+
+    // in core.sys.posix.sys.mman
+    // static if (__USE_XOPEN2K) enum
+    // {
+    //     POSIX_MADV_NORMAL = 0,
+    //     POSIX_MADV_RANDOM = 1,
+    //     POSIX_MADV_SEQUENTIAL = 2,
+    //     POSIX_MADV_WILLNEED = 3,
+    //     POSIX_MADV_DONTNEED = 4,
+    // }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/unix/sysv/linux/ia64/bits/mman.h
+else version (IA64)
+{
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x00100,
+        MAP_GROWSUP = 0x00200,
+        MAP_DENYWRITE = 0x00800,
+        MAP_EXECUTABLE = 0x01000,
+        MAP_LOCKED = 0x02000,
+        MAP_NORESERVE = 0x04000,
+        MAP_POPULATE = 0x08000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/unix/sysv/linux/m68k/bits/mman.h
+else version (M68K)
+{
+    static if (__USE_MISC) enum
+    {
+        MAP_GROWSDOWN = 0x00100,
+        MAP_DENYWRITE = 0x00800,
+        MAP_EXECUTABLE = 0x01000,
+        MAP_LOCKED = 0x02000,
+        MAP_NORESERVE = 0x04000,
+        MAP_POPULATE = 0x08000,
+        MAP_NONBLOCK = 0x10000,
+        MAP_STACK = 0x20000,
+        MAP_HUGETLB = 0x40000,
+    }
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/unix/sysv/linux/mips/bits/mman.h
+else version (MIPS32)
+{
+    static if (__USE_MISC) enum
+    {
+        MAP_NORESERVE = 0x0400,
+        MAP_GROWSDOWN = 0x1000,
+        MAP_DENYWRITE = 0x2000,
+        MAP_EXECUTABLE = 0x4000,
+        MAP_LOCKED = 0x8000,
+        MAP_POPULATE = 0x10000,
+        MAP_NONBLOCK = 0x20000,
+        MAP_STACK = 0x40000,
+        MAP_HUGETLB = 0x80000,
+    }
+
+    static if (__USE_MISC) enum MAP_RENAME = MAP_ANONYMOUS;
+}
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/unix/sysv/linux/mips/bits/mman.h
+else version (MIPS64)
+{
+    static if (__USE_MISC) enum
+    {
+        MAP_NORESERVE = 0x0400,
+        MAP_GROWSDOWN = 0x1000,
+        MAP_DENYWRITE = 0x2000,
+        MAP_EXECUTABLE = 0x4000,
+        MAP_LOCKED = 0x8000,
+        MAP_POPULATE = 0x10000,
+        MAP_NONBLOCK = 0x20000,
+        MAP_STACK = 0x40000,
+        MAP_HUGETLB = 0x80000,
+    }
+
+    static if (__USE_MISC) enum MAP_RENAME = MAP_ANONYMOUS;
+}
+else
+{
+    static assert(0, "unimplemented");
+}
+
+
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/bits/mman-linux.h
+version (Alpha)
+{
+}
+else version (HPPA)
+{
+}
+else version (HPPA64)
+{
+}
+else
+{
+    // in core.sys.posix.sys.mman
+    // enum PROT_READ = 0x1;
+    // enum PROT_WRITE = 0x2;
+    // enum PROT_EXEC = 0x4;
+    // enum PROT_NONE = 0x0;
+
+    enum PROT_GROWSDOWN = 0x01000000;
+    enum PROT_GROWSUP = 0x02000000;
+
+    enum MAP_SHARED = 0x01;
+    enum MAP_PRIVATE = 0x02;
+    static if (__USE_MISC)
+        enum MAP_TYPE = 0x0f;
+
+    enum MAP_FIXED = 0x10;
+    static if (__USE_MISC) enum
+    {
+        MAP_FILE = 0,
+        MAP_ANONYMOUS = MAP_ANON,
+        // in core.sys.posix.sys.mman
+        // MAP_ANON = 0xXX,
+        MAP_HUGE_SHIFT = 26,
+        MAP_HUGE_MASK = 0x3f,
+    }
+
+    // in core.sys.posix.sys.mman
+    // enum
+    // {
+    //     MS_ASYNC = 1,
+    //     MS_SYNC = 4,
+    //     MS_INVALIDATE = 2,
+    // }
+
+    static if (__USE_GNU) enum
+    {
+        MREMAP_MAYMOVE = 1,
+        MREMAP_FIXED = 2,
+    }
+
+    static if (__USE_BSD) enum
+    {
+        MADV_NORMAL = 0,
+        MADV_RANDOM = 1,
+        MADV_SEQUENTIAL = 2,
+        MADV_WILLNEED = 3,
+        MADV_DONTNEED = 4,
+        MADV_REMOVE = 9,
+        MADV_DONTFORK = 10,
+        MADV_DOFORK = 11,
+        MADV_MERGEABLE = 12,
+        MADV_UNMERGEABLE = 13,
+        MADV_HWPOISON = 100,
+    }
+
+    // in core.sys.posix.sys.mman
+    // static if (__USE_XOPEN2K) enum
+    // {
+    //     POSIX_MADV_NORMAL = 0,
+    //     POSIX_MADV_RANDOM = 1,
+    //     POSIX_MADV_SEQUENTIAL = 2,
+    //     POSIX_MADV_WILLNEED = 3,
+    //     POSIX_MADV_DONTNEED = 4,
+    // }
+
+    // in core.sys.posix.sys.mman
+    // enum
+    // {
+    //
+    //     MCL_CURRENT = 1,
+    //     MCL_FUTURE = 2,
+    // }
+}
+
+// http://sourceware.org/git/?p=glibc.git;a=blob;f=misc/sys/mman.h
+// in core.sys.posix.sys.mman
+// static if (__USE_LARGEFILE64) void* mmap64(void*, size_t, int, int, int, off_t);
+// static if (__USE_FILE_OFFSET64)
+//     alias mmap64 mmap;
+// else
+//     void* mmap(void*, size_t, int, int, int, off_t);
+// int munmap(void*, size_t);
+// int mprotect(void *__addr, size_t __len, int __prot);
+// int msync(void *__addr, size_t __len, int __flags);
+static if (__USE_BSD) int madvise(void *__addr, size_t __len, int __advice);
+// static if (__USE_XOPEN2K) int posix_madvise(void *__addr, size_t __len, int __advice);
+// int mlock(const(void) *__addr, size_t __len);
+// int munlock(const(void) *__addr, size_t __len);
+// int mlockall(int __flags);
+// int munlockall();
+static if (__USE_MISC) int mincore(void *__start, size_t __len, ubyte *__vec);
+static if (__USE_GNU) void *mremap(void *__addr, size_t __old_len, size_t __new_len, int __flags, ...);
+static if (__USE_GNU) int remap_file_pages(void *__start, size_t __size, int __prot, size_t __pgoff, int __flags);
+// int shm_open(in char *__name, int __oflag, mode_t __mode);
+// int shm_unlink(in char *__name);
diff --git a/libphobos/libdruntime/core/sys/linux/sys/signalfd.d b/libphobos/libdruntime/core/sys/linux/sys/signalfd.d
new file mode 100644
index 00000000000..5d4cb674955
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/sys/signalfd.d
@@ -0,0 +1,42 @@
+/**
+ * D header file for Linux.
+ *
+ * Copyright: Copyright Alex Rønne Petersen 2012.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Alex Rønne Petersen
+ */
+module core.sys.linux.sys.signalfd;
+
+import core.sys.posix.signal;
+
+version (linux):
+
+extern (C):
+@system:
+nothrow:
+
+struct signalfd_siginfo
+{
+    uint ssi_signo;
+    int ssi_errno;
+    int ssi_code;
+    uint ssi_pid;
+    uint ssi_uid;
+    int ssi_fd;
+    uint ssi_tid;
+    uint ssi_band;
+    uint ssi_overrun;
+    uint ssi_trapno;
+    int ssi_status;
+    int ssi_int;
+    ulong ssi_ptr;
+    ulong ssi_utime;
+    ulong ssi_stime;
+    ulong ssi_addr;
+    ubyte[48] __pad;
+}
+
+enum SFD_CLOEXEC = 0x80000; // 02000000
+enum SFD_NONBLOCK = 0x800; // 04000
+
+int signalfd (int __fd, const(sigset_t)* __mask, int __flags);
diff --git a/libphobos/libdruntime/core/sys/linux/sys/socket.d b/libphobos/libdruntime/core/sys/linux/sys/socket.d
new file mode 100644
index 00000000000..4ae1b8f5830
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/sys/socket.d
@@ -0,0 +1,19 @@
+/**
+ * D header file for GNU/Linux.
+ *
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Paul O'Neil
+ */
+module core.sys.linux.sys.socket;
+
+public import core.sys.posix.sys.socket;
+
+version(linux):
+extern(C):
+@nogc:
+nothrow:
+
+enum {
+    AF_RXRPC    = 33,
+    PF_RXRPC    = AF_RXRPC,
+}
diff --git a/libphobos/libdruntime/core/sys/linux/sys/sysinfo.d b/libphobos/libdruntime/core/sys/linux/sys/sysinfo.d
new file mode 100644
index 00000000000..92f36ccf98e
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/sys/sysinfo.d
@@ -0,0 +1,39 @@
+/**
+ * D header file for GNU/Linux.
+ *
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Martin Nowak
+ */
+module core.sys.linux.sys.sysinfo;
+
+version(linux) extern(C) @nogc nothrow:
+
+import core.sys.linux.config;
+
+// linux/sysinfo.h
+enum SI_LOAD_SHIFT = 16;
+
+struct sysinfo_
+{
+    c_long uptime;     /* Seconds since boot */
+    c_ulong[3] loads;  /* 1, 5, and 15 minute load averages */
+    c_ulong totalram;  /* Total usable main memory size */
+    c_ulong freeram;   /* Available memory size */
+    c_ulong sharedram; /* Amount of shared memory */
+    c_ulong bufferram; /* Memory used by buffers */
+    c_ulong totalswap; /* Total swap space size */
+    c_ulong freeswap;  /* swap space still available */
+    ushort procs;      /* Number of current processes */
+    ushort pad;        /* Explicit padding for m68k */
+    c_ulong totalhigh; /* Total high memory size */
+    c_ulong freehigh;  /* Available high memory size */
+    uint mem_unit;     /* Memory unit size in bytes */
+    ubyte[20-2 * c_ulong.sizeof - uint.sizeof] _f; /* Padding: libc5 uses this.. */
+}
+
+
+int sysinfo(sysinfo_ *info);
+int get_nprocs_conf();
+int get_nprocs();
+c_long get_phys_pages();
+c_long get_avphys_pages();
diff --git a/libphobos/libdruntime/core/sys/linux/sys/xattr.d b/libphobos/libdruntime/core/sys/linux/sys/xattr.d
new file mode 100644
index 00000000000..a14c6c6174b
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/sys/xattr.d
@@ -0,0 +1,68 @@
+/**
+ * D header file for GNU/Linux.
+ *
+ * Copyright: Copyright Robert Klotzner 2012.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Robert Klotzner
+ */
+module core.sys.linux.sys.xattr;
+
+import core.sys.posix.sys.types;
+
+version (linux):
+extern (C):
+@system:
+nothrow:
+
+enum {
+    XATTR_CREATE = 1, /* set value, fail if attr already exists.  */
+    XATTR_REPLACE = 2 /* set value, fail if attr does not exist.  */
+}
+
+enum XATTR_OS2_PREFIX = "os2.";
+enum XATTR_OS2_PREFIX_LEN = XATTR_OS2_PREFIX.length;
+enum XATTR_SECURITY_PREFIX = "security.";
+enum XATTR_SECURITY_PREFIX_LEN = XATTR_SECURITY_PREFIX.length;
+enum XATTR_SYSTEM_PREFIX = "system.";
+enum XATTR_SYSTEM_PREFIX_LEN = XATTR_SYSTEM_PREFIX.length;
+enum XATTR_TRUSTED_PREFIX = "trusted.";
+enum XATTR_TRUSTED_PREFIX_LEN = XATTR_TRUSTED_PREFIX.length;
+enum XATTR_USER_PREFIX = "user.";
+enum XATTR_USER_PREFIX_LEN = XATTR_USER_PREFIX.length;
+
+/* Security namespace */
+enum XATTR_SELINUX_SUFFIX = "selinux.";
+enum XATTR_NAME_SELINUX = XATTR_SECURITY_PREFIX ~ XATTR_SELINUX_SUFFIX;
+
+enum XATTR_SMACK_SUFFIX = "SMACK64";
+enum XATTR_SMACK_IPIN = "SMACK64IPIN";
+enum XATTR_SMACK_IPOUT = "SMACK64IPOUT";
+enum XATTR_SMACK_EXEC = "SMACK64EXEC";
+enum XATTR_SMACK_TRANSMUTE = "SMACK64TRANSMUTE";
+enum XATTR_SMACK_MMAP = "SMACK64MMAP";
+
+enum XATTR_NAME_SMACK = XATTR_SECURITY_PREFIX ~ XATTR_SMACK_SUFFIX;
+enum XATTR_NAME_SMACKIPIN = XATTR_SECURITY_PREFIX ~ XATTR_SMACK_IPIN;
+enum XATTR_NAME_SMACKIPOUT = XATTR_SECURITY_PREFIX ~ XATTR_SMACK_IPOUT;
+enum XATTR_NAME_SMACKEXEC = XATTR_SECURITY_PREFIX ~ XATTR_SMACK_EXEC;
+enum XATTR_NAME_SMACKTRANSMUTE = XATTR_SECURITY_PREFIX ~ XATTR_SMACK_TRANSMUTE;
+enum XATTR_NAME_SMACKMMAP = XATTR_SECURITY_PREFIX ~ XATTR_SMACK_MMAP;
+
+enum XATTR_CAPS_SUFFIX = "capability";
+enum XATTR_NAME_CAPS = XATTR_SECURITY_PREFIX ~ XATTR_CAPS_SUFFIX;
+
+
+int setxattr(in char* path, in char* name, in void* value, size_t size, int flags);
+
+int lsetxattr(in char* path, in char* name, in void* value, size_t size, int flags);
+int fsetxattr(int fd, in char* name, in void* value, size_t size, int flags);
+ssize_t getxattr(in char* path, in char* name, void* value, size_t size);
+ssize_t lgetxattr(in char* path, in char* name, void* value, size_t size);
+ssize_t fgetxattr(int fd, in char* name, void* value, size_t size);
+ssize_t listxattr(in char* path, char* list, size_t size);
+ssize_t llistxattr(in char* path, char* list, size_t size);
+ssize_t flistxattr (int __fd, char *list, size_t size);
+int removexattr (in char *path, in char *name);
+int lremovexattr (in char *path, in char *name);
+int fremovexattr (int fd, in char *name);
+
diff --git a/libphobos/libdruntime/core/sys/linux/termios.d b/libphobos/libdruntime/core/sys/linux/termios.d
new file mode 100644
index 00000000000..cface698d64
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/termios.d
@@ -0,0 +1,30 @@
+/**
+ * D header file for GNU/Linux
+ */
+/* Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+module core.sys.linux.termios;
+
+version(linux):
+    public import core.sys.posix.termios;
+
+    enum B57600 = 0x1001; // 0010001
+    enum B115200 = 0x1002; // 0010002
+    enum B230400 = 0x1003; // 0010003
+    enum B460800 = 0x1004; // 0010004
+    enum B500000 = 0x1005; // 0010005
+    enum B576000 = 0x1006; // 0010006
+    enum B921600 = 0x1007; // 0010007
+    enum B1000000 = 0x1008; // 0010010
+    enum B1152000 = 0x1009; // 0010011
+    enum B1500000 = 0x100A; // 0010012
+    enum B2000000 = 0x100B; // 0010013
+    enum B2500000 = 0x100C; // 0010014
+    enum B3000000 = 0x100D; // 0010015
+    enum B3500000 = 0x100E; // 0010016
+    enum B4000000 = 0x100F; // 0010017
+
+    enum CRTSCTS = 0x80000000; // 020000000000
diff --git a/libphobos/libdruntime/core/sys/linux/time.d b/libphobos/libdruntime/core/sys/linux/time.d
new file mode 100644
index 00000000000..7fb8e35ec0f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/time.d
@@ -0,0 +1,23 @@
+//Written in the D programming language
+
+/++
+    D header file for Linux extensions to POSIX's time.h.
+
+    Copyright: Copyright 2014
+    License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+    Authors:   Jonathan M Davis
+ +/
+module core.sys.linux.time;
+
+public import core.sys.posix.time;
+
+version(linux):
+
+enum CLOCK_MONOTONIC_RAW      = 4;
+enum CLOCK_REALTIME_COARSE    = 5;
+enum CLOCK_MONOTONIC_COARSE   = 6;
+enum CLOCK_BOOTTIME           = 7;
+enum CLOCK_REALTIME_ALARM     = 8;
+enum CLOCK_BOOTTIME_ALARM     = 9;
+enum CLOCK_SGI_CYCLE          = 10;
+enum CLOCK_TAI                = 11;
diff --git a/libphobos/libdruntime/core/sys/linux/timerfd.d b/libphobos/libdruntime/core/sys/linux/timerfd.d
new file mode 100644
index 00000000000..047f257d98d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/timerfd.d
@@ -0,0 +1,24 @@
+/**
+ * D header file to interface with the Linux timefd API <http://man7.org/linux/man-pages/man2/timerfd_create.2.html>
+ * Available since Linux 2.6
+ *
+ * License : $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ */
+module core.sys.linux.timerfd;
+
+version (linux):
+
+public import core.sys.posix.time;
+
+extern (C):
+@system:
+@nogc:
+nothrow:
+
+int timerfd_create(int clockid, int flags);
+int timerfd_settime(int fd, int flags, const itimerspec* new_value, itimerspec* old_value);
+int timerfd_gettime(int fd, itimerspec* curr_value);
+
+enum TFD_TIMER_ABSTIME = 1 << 0;
+enum TFD_CLOEXEC       = 0x80000;
+enum TFD_NONBLOCK      = 0x800;
diff --git a/libphobos/libdruntime/core/sys/linux/tipc.d b/libphobos/libdruntime/core/sys/linux/tipc.d
new file mode 100644
index 00000000000..161a313d079
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/tipc.d
@@ -0,0 +1,210 @@
+/**
+ * Interface for Linux TIPC sockets, /usr/include/linux/tipc.h
+ *
+ * Copyright: Public Domain
+ * License:   Public Domain
+ * Authors:   Leandro Lucarella
+ */
+
+module core.sys.linux.tipc;
+
+version (linux):
+extern (C) nothrow @nogc:
+
+struct tipc_portid
+{
+        uint ref_;
+        uint node;
+}
+
+struct tipc_name
+{
+        uint type;
+        uint instance;
+}
+
+struct tipc_name_seq
+{
+        uint type;
+        uint lower;
+        uint upper;
+}
+
+struct tipc_subscr
+{
+        tipc_name_seq seq;
+        uint timeout;
+        uint filter;
+        ubyte[8] usr_handle;
+}
+
+struct tipc_event
+{
+        uint event;
+        uint found_lower;
+        uint found_upper;
+        tipc_portid port;
+        tipc_subscr s;
+}
+
+struct sockaddr_tipc
+{
+        ushort family;
+        ubyte addrtype;
+        byte scope_;
+        union Addr
+        {
+                tipc_portid id;
+                tipc_name_seq nameseq;
+                static struct Name
+                {
+                        tipc_name name;
+                        uint domain;
+                }
+                Name name;
+        }
+        Addr addr;
+}
+
+uint tipc_addr(uint zone, uint cluster, uint node)
+{
+        return (zone << 24) | (cluster << 12) | node;
+}
+
+unittest
+{
+        assert (tipc_addr(0, 0, 0) == 0);
+        assert (tipc_addr(1, 1, 1) == 16781313);
+        assert (tipc_addr(2, 1, 27) == 33558555);
+        assert (tipc_addr(3, 1, 63) == 50335807);
+}
+
+uint tipc_zone(uint addr)
+{
+        return addr >> 24;
+}
+
+unittest
+{
+        assert (tipc_zone(0u) == 0);
+        assert (tipc_zone(16781313u) == 1);
+        assert (tipc_zone(33558555u) == 2);
+        assert (tipc_zone(50335807u) == 3);
+}
+
+uint tipc_cluster(uint addr)
+{
+        return (addr >> 12) & 0xfff;
+}
+
+unittest
+{
+        assert (tipc_cluster(0u) == 0);
+        assert (tipc_cluster(16781313u) == 1);
+        assert (tipc_cluster(33558555u) == 1);
+        assert (tipc_cluster(50335807u) == 1);
+}
+
+uint tipc_node(uint addr)
+{
+        return addr & 0xfff;
+}
+
+unittest
+{
+        assert (tipc_node(0u) == 0);
+        assert (tipc_node(16781313u) == 1);
+        assert (tipc_node(33558555u) == 27);
+        assert (tipc_node(50335807u) == 63);
+}
+
+enum: int
+{
+        TIPC_CFG_SRV    = 0,
+        TIPC_TOP_SRV    = 1,
+        TIPC_RESERVED_TYPES = 64,
+}
+
+enum: int
+{
+        TIPC_ZONE_SCOPE    = 1,
+        TIPC_CLUSTER_SCOPE = 2,
+        TIPC_NODE_SCOPE    = 3,
+}
+
+enum: int
+{
+        TIPC_MAX_USER_MSG_SIZE = 66000,
+}
+
+enum: int
+{
+        TIPC_LOW_IMPORTANCE      = 0,
+        TIPC_MEDIUM_IMPORTANCE   = 1,
+        TIPC_HIGH_IMPORTANCE     = 2,
+        TIPC_CRITICAL_IMPORTANCE = 3,
+}
+
+enum: int
+{
+        TIPC_OK     = 0,
+        TIPC_ERR_NO_NAME   = 1,
+        TIPC_ERR_NO_PORT   = 2,
+        TIPC_ERR_NO_NODE   = 3,
+        TIPC_ERR_OVERLOAD  = 4,
+        TIPC_CONN_SHUTDOWN = 5,
+}
+
+enum: int
+{
+        TIPC_SUB_PORTS    = 0x01,
+        TIPC_SUB_SERVICE  = 0x02,
+        TIPC_SUB_CANCEL   = 0x04,
+}
+
+version (none) enum: int
+{
+        TIPC_SUB_NO_BIND_EVTS   = 0x04,
+        TIPC_SUB_NO_UNBIND_EVTS = 0x08,
+        TIPC_SUB_SINGLE_EVT     = 0x10,
+}
+
+enum: int
+{
+        TIPC_WAIT_FOREVER = ~0,
+}
+
+enum: int
+{
+
+        TIPC_PUBLISHED      = 1,
+        TIPC_WITHDRAWN      = 2,
+        TIPC_SUBSCR_TIMEOUT = 3,
+}
+
+enum: int
+{
+        AF_TIPC    = 30,
+        PF_TIPC    = 30,
+        SOL_TIPC          = 271,
+        TIPC_ADDR_NAMESEQ = 1,
+        TIPC_ADDR_MCAST   = 1,
+        TIPC_ADDR_NAME    = 2,
+        TIPC_ADDR_ID      = 3,
+}
+
+enum: int
+{
+        TIPC_ERRINFO  = 1,
+        TIPC_RETDATA  = 2,
+        TIPC_DESTNAME = 3,
+}
+
+enum: int
+{
+        TIPC_IMPORTANCE     = 127,
+        TIPC_SRC_DROPPABLE  = 128,
+        TIPC_DEST_DROPPABLE = 129,
+        TIPC_CONN_TIMEOUT   = 130,
+}
+
diff --git a/libphobos/libdruntime/core/sys/linux/unistd.d b/libphobos/libdruntime/core/sys/linux/unistd.d
new file mode 100644
index 00000000000..66cd2fbd6e3
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/unistd.d
@@ -0,0 +1,20 @@
+module core.sys.linux.unistd;
+
+public import core.sys.posix.unistd;
+
+version(linux):
+extern(C):
+nothrow:
+
+// Additional seek constants for sparse file handling
+// from Linux's unistd.h, stdio.h, and linux/fs.h
+// (see http://man7.org/linux/man-pages/man2/lseek.2.html)
+enum {
+    /// Offset is relative to the next location containing data
+    SEEK_DATA = 3,
+    /// Offset is relative to the next hole (or EOF if file is not sparse)
+    SEEK_HOLE = 4
+}
+
+/// Prompt for a password without echoing it.
+char* getpass(const(char)* prompt);
diff --git a/libphobos/libdruntime/core/sys/osx/execinfo.d b/libphobos/libdruntime/core/sys/osx/execinfo.d
new file mode 100644
index 00000000000..9cb45ff7377
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/osx/execinfo.d
@@ -0,0 +1,16 @@
+/**
+ * D header file for OSX.
+ *
+ * Copyright: Copyright Martin Nowak 2012.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Martin Nowak
+ */
+module core.sys.osx.execinfo;
+
+version (OSX):
+extern (C):
+nothrow:
+
+int backtrace(void** buffer, int size);
+char** backtrace_symbols(const(void*)* buffer, int size);
+void backtrace_symbols_fd(const(void*)* buffer, int size, int fd);
diff --git a/libphobos/libdruntime/core/sys/osx/mach/dyld.d b/libphobos/libdruntime/core/sys/osx/mach/dyld.d
new file mode 100644
index 00000000000..ada9db5ca98
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/osx/mach/dyld.d
@@ -0,0 +1,27 @@
+/**
+ * Copyright: Copyright Digital Mars 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Jacob Carlborg
+ * Version: Initial created: Feb 20, 2010
+ */
+
+/*          Copyright Digital Mars 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.osx.mach.dyld;
+
+version (OSX):
+extern (C):
+
+public import core.stdc.stdint; // for intptr_t
+public import core.sys.osx.mach.loader;
+
+uint         _dyld_image_count();
+const(char)* _dyld_get_image_name(uint image_index);
+mach_header* _dyld_get_image_header(uint image_index);
+void         _dyld_register_func_for_add_image(void function(in mach_header* mh, intptr_t vmaddr_slide));
+void         _dyld_register_func_for_remove_image(void function(in mach_header* mh, intptr_t vmaddr_slide));
+
+
diff --git a/libphobos/libdruntime/core/sys/osx/mach/getsect.d b/libphobos/libdruntime/core/sys/osx/mach/getsect.d
new file mode 100644
index 00000000000..1c6eec58e43
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/osx/mach/getsect.d
@@ -0,0 +1,22 @@
+/**
+ * Copyright: Copyright Digital Mars 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Jacob Carlborg
+ * Version: Initial created: Mar 16, 2010
+ */
+
+/*          Copyright Digital Mars 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.osx.mach.getsect;
+
+version (OSX):
+extern (C):
+
+public import core.sys.osx.mach.loader;
+
+const(section)*    getsectbynamefromheader(in mach_header* mhp, in char* segname, in char* sectname);
+const(section_64)* getsectbynamefromheader_64(in mach_header_64* mhp, in char* segname, in char* sectname);
+
diff --git a/libphobos/libdruntime/core/sys/osx/mach/kern_return.d b/libphobos/libdruntime/core/sys/osx/mach/kern_return.d
new file mode 100644
index 00000000000..54fe4d7dfe6
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/osx/mach/kern_return.d
@@ -0,0 +1,73 @@
+/**
+ * D header file for OSX.
+ *
+ * Copyright: Copyright Sean Kelly 2008 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ */
+
+/*          Copyright Sean Kelly 2008 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.osx.mach.kern_return;
+
+version (OSX):
+extern (C):
+
+alias int kern_return_t;
+
+enum : kern_return_t
+{
+    KERN_SUCCESS                = 0,
+    KERN_INVALID_ADDRESS        = 1,
+    KERN_PROTECTION_FAILURE     = 2,
+    KERN_NO_SPACE               = 3,
+    KERN_INVALID_ARGUMENT       = 4,
+    KERN_FAILURE                = 5,
+    KERN_RESOURCE_SHORTAGE      = 6,
+    KERN_NOT_RECEIVER           = 7,
+    KERN_NO_ACCESS              = 8,
+    KERN_MEMORY_FAILURE         = 9,
+    KERN_MEMORY_ERROR           = 10,
+    KERN_ALREADY_IN_SET         = 11,
+    KERN_NOT_IN_SET             = 12,
+    KERN_NAME_EXISTS            = 13,
+    KERN_ABORTED                = 14,
+    KERN_INVALID_NAME           = 15,
+    KERN_INVALID_TASK           = 16,
+    KERN_INVALID_RIGHT          = 17,
+    KERN_INVALID_VALUE          = 18,
+    KERN_UREFS_OVERFLOW         = 19,
+    KERN_INVALID_CAPABILITY     = 20,
+    KERN_RIGHT_EXISTS           = 21,
+    KERN_INVALID_HOST           = 22,
+    KERN_MEMORY_PRESENT         = 23,
+    KERN_MEMORY_DATA_MOVED      = 24,
+    KERN_MEMORY_RESTART_COPY    = 25,
+    KERN_INVALID_PROCESSOR_SET  = 26,
+    KERN_POLICY_LIMIT           = 27,
+    KERN_INVALID_POLICY         = 28,
+    KERN_INVALID_OBJECT         = 29,
+    KERN_ALREADY_WAITING        = 30,
+    KERN_DEFAULT_SET            = 31,
+    KERN_EXCEPTION_PROTECTED    = 32,
+    KERN_INVALID_LEDGER         = 33,
+    KERN_INVALID_MEMORY_CONTROL = 34,
+    KERN_INVALID_SECURITY       = 35,
+    KERN_NOT_DEPRESSED          = 36,
+    KERN_TERMINATED             = 37,
+    KERN_LOCK_SET_DESTROYED     = 38,
+    KERN_LOCK_UNSTABLE          = 39,
+    KERN_LOCK_OWNED             = 40,
+    KERN_LOCK_OWNED_SELF        = 41,
+    KERN_SEMAPHORE_DESTROYED    = 42,
+    KERN_RPC_SERVER_TERMINATED  = 43,
+    KERN_RPC_TERMINATE_ORPHAN   = 44,
+    KERN_RPC_CONTINUE_ORPHAN    = 45,
+    KERN_NOT_SUPPORTED          = 46,
+    KERN_NODE_DOWN              = 47,
+    KERN_OPERATION_TIMED_OUT    = 49,
+    KERN_RETURN_MAX             = 0x100,
+}
diff --git a/libphobos/libdruntime/core/sys/osx/mach/loader.d b/libphobos/libdruntime/core/sys/osx/mach/loader.d
new file mode 100644
index 00000000000..d3ceb6d0263
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/osx/mach/loader.d
@@ -0,0 +1,97 @@
+/**
+ * Copyright: Copyright Digital Mars 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Jacob Carlborg
+ * Version: Initial created: Feb 20, 2010
+ */
+
+/*          Copyright Digital Mars 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.osx.mach.loader;
+
+version (OSX):
+extern (C):
+
+struct mach_header
+{
+    uint magic;
+    int  cputype;
+    int  cpusubtype;
+    uint filetype;
+    uint ncmds;
+    uint sizeofcmds;
+    uint flags;
+}
+
+struct mach_header_64
+{
+    uint magic;
+    int  cputype;
+    int  cpusubtype;
+    uint filetype;
+    uint ncmds;
+    uint sizeofcmds;
+    uint flags;
+    uint reserved;
+}
+
+enum uint MH_MAGIC      = 0xfeedface;
+enum uint MH_CIGAM      = 0xcefaedfe;
+enum uint MH_MAGIC_64   = 0xfeedfacf;
+enum uint MH_CIGAM_64   = 0xcffaedfe;
+
+enum SEG_PAGEZERO       = "__PAGEZERO";
+enum SEG_TEXT           = "__TEXT";
+enum SECT_TEXT          = "__text";
+enum SECT_FVMLIB_INIT0  = "__fvmlib_init0";
+enum SECT_FVMLIB_INIT1  = "__fvmlib_init1";
+enum SEG_DATA           = "__DATA";
+enum SECT_DATA          = "__data";
+enum SECT_BSS           = "__bss";
+enum SECT_COMMON        = "__common";
+enum SEG_OBJC           = "__OBJC";
+enum SECT_OBJC_SYMBOLS  = "__symbol_table";
+enum SECT_OBJC_MODULES  = "__module_info";
+enum SECT_OBJC_STRINGS  = "__selector_strs";
+enum SECT_OBJC_REFS     = "__selector_refs";
+enum SEG_ICON           = "__ICON";
+enum SECT_ICON_HEADER   = "__header";
+enum SECT_ICON_TIFF     = "__tiff";
+enum SEG_LINKEDIT       = "__LINKEDIT";
+enum SEG_UNIXSTACK      = "__UNIXSTACK";
+enum SEG_IMPORT         = "__IMPORT";
+
+struct section
+{
+    char[16] sectname;
+    char[16] segname;
+    uint     addr;
+    uint     size;
+    uint     offset;
+    uint     align_;
+    uint     reloff;
+    uint     nreloc;
+    uint     flags;
+    uint     reserved1;
+    uint     reserved2;
+}
+
+struct section_64
+{
+    char[16] sectname;
+    char[16] segname;
+    ulong    addr;
+    ulong    size;
+    uint     offset;
+    uint     align_;
+    uint     reloff;
+    uint     nreloc;
+    uint     flags;
+    uint     reserved1;
+    uint     reserved2;
+    uint     reserved3;
+}
+
diff --git a/libphobos/libdruntime/core/sys/osx/mach/port.d b/libphobos/libdruntime/core/sys/osx/mach/port.d
new file mode 100644
index 00000000000..40538e6d36d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/osx/mach/port.d
@@ -0,0 +1,27 @@
+/**
+ * D header file for OSX.
+ *
+ * Copyright: Copyright Sean Kelly 2008 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ */
+
+/*          Copyright Sean Kelly 2008 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.osx.mach.port;
+
+version (OSX):
+extern (C):
+
+version( X86 )
+    version = i386;
+version( X86_64 )
+    version = i386;
+version( i386 )
+{
+    alias uint        natural_t;
+    alias natural_t   mach_port_t;
+}
diff --git a/libphobos/libdruntime/core/sys/osx/mach/semaphore.d b/libphobos/libdruntime/core/sys/osx/mach/semaphore.d
new file mode 100644
index 00000000000..6eefd24bd1c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/osx/mach/semaphore.d
@@ -0,0 +1,57 @@
+/**
+ * D header file for OSX.
+ *
+ * Copyright: Copyright Sean Kelly 2008 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ */
+
+/*          Copyright Sean Kelly 2008 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.osx.mach.semaphore;
+
+version (OSX):
+extern (C):
+nothrow:
+
+public import core.sys.osx.mach.kern_return;
+public import core.sys.osx.mach.port;
+
+alias mach_port_t   task_t;
+alias mach_port_t   thread_t;
+alias mach_port_t   semaphore_t;
+alias int           sync_policy_t;
+
+alias int clock_res_t;
+struct mach_timespec_t
+{
+        uint        tv_sec;
+        clock_res_t     tv_nsec;
+}
+
+enum
+{
+    SYNC_POLICY_FIFO            = 0x0,
+    SYNC_POLICY_FIXED_PRIORITY  = 0x1,
+    SYNC_POLICY_REVERSED        = 0x2,
+    SYNC_POLICY_ORDER_MASK      = 0x3,
+    SYNC_POLICY_LIFO            = (SYNC_POLICY_FIFO | SYNC_POLICY_REVERSED),
+    SYNC_POLICY_MAX                         = 0x7,
+}
+
+task_t        mach_task_self();
+kern_return_t semaphore_create(task_t, semaphore_t*, int, int);
+kern_return_t semaphore_destroy(task_t, semaphore_t);
+
+kern_return_t semaphore_signal(semaphore_t);
+kern_return_t semaphore_signal_all(semaphore_t);
+kern_return_t semaphore_signal_thread(semaphore_t, thread_t);
+
+kern_return_t semaphore_wait(semaphore_t);
+kern_return_t semaphore_wait_signal(semaphore_t, semaphore_t);
+
+kern_return_t semaphore_timedwait(semaphore_t, mach_timespec_t);
+kern_return_t semaphore_timedwait_signal(semaphore_t, semaphore_t, mach_timespec_t);
diff --git a/libphobos/libdruntime/core/sys/osx/mach/thread_act.d b/libphobos/libdruntime/core/sys/osx/mach/thread_act.d
new file mode 100644
index 00000000000..51d04cf07d2
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/osx/mach/thread_act.d
@@ -0,0 +1,127 @@
+/**
+ * D header file for OSX.
+ *
+ * Copyright: Copyright Sean Kelly 2008 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ */
+
+/*          Copyright Sean Kelly 2008 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.osx.mach.thread_act;
+
+version (OSX):
+extern (C):
+nothrow:
+
+public import core.sys.osx.mach.kern_return;
+public import core.sys.osx.mach.port;
+
+version( X86 )
+    version = i386;
+version( X86_64 )
+    version = i386;
+version( i386 )
+{
+    alias mach_port_t thread_act_t;
+    alias void        thread_state_t;
+    alias int         thread_state_flavor_t;
+    alias natural_t   mach_msg_type_number_t;
+
+    enum
+    {
+        x86_THREAD_STATE32      = 1,
+        x86_FLOAT_STATE32       = 2,
+        x86_EXCEPTION_STATE32   = 3,
+        x86_THREAD_STATE64      = 4,
+        x86_FLOAT_STATE64       = 5,
+        x86_EXCEPTION_STATE64   = 6,
+        x86_THREAD_STATE        = 7,
+        x86_FLOAT_STATE         = 8,
+        x86_EXCEPTION_STATE     = 9,
+        x86_DEBUG_STATE32       = 10,
+        x86_DEBUG_STATE64       = 11,
+        x86_DEBUG_STATE         = 12,
+        THREAD_STATE_NONE       = 13,
+    }
+
+    struct x86_thread_state32_t
+    {
+        uint    eax;
+        uint    ebx;
+        uint    ecx;
+        uint    edx;
+        uint    edi;
+        uint    esi;
+        uint    ebp;
+        uint    esp;
+        uint    ss;
+        uint    eflags;
+        uint    eip;
+        uint    cs;
+        uint    ds;
+        uint    es;
+        uint    fs;
+        uint    gs;
+    }
+
+    struct x86_thread_state64_t
+    {
+        ulong   rax;
+        ulong   rbx;
+        ulong   rcx;
+        ulong   rdx;
+        ulong   rdi;
+        ulong   rsi;
+        ulong   rbp;
+        ulong   rsp;
+        ulong   r8;
+        ulong   r9;
+        ulong   r10;
+        ulong   r11;
+        ulong   r12;
+        ulong   r13;
+        ulong   r14;
+        ulong   r15;
+        ulong   rip;
+        ulong   rflags;
+        ulong   cs;
+        ulong   fs;
+        ulong   gs;
+    }
+
+    struct x86_state_hdr_t
+    {
+        int     flavor;
+        int     count;
+    }
+
+    struct x86_thread_state_t
+    {
+        x86_state_hdr_t             tsh;
+        union _uts
+        {
+            x86_thread_state32_t    ts32;
+            x86_thread_state64_t    ts64;
+        }
+        _uts                        uts;
+    }
+
+    enum : mach_msg_type_number_t
+    {
+        x86_THREAD_STATE32_COUNT = cast(mach_msg_type_number_t)( x86_thread_state32_t.sizeof / int.sizeof ),
+        x86_THREAD_STATE64_COUNT = cast(mach_msg_type_number_t)( x86_thread_state64_t.sizeof / int.sizeof ),
+        x86_THREAD_STATE_COUNT   = cast(mach_msg_type_number_t)( x86_thread_state_t.sizeof / int.sizeof ),
+    }
+
+    alias x86_THREAD_STATE          MACHINE_THREAD_STATE;
+    alias x86_THREAD_STATE_COUNT    MACHINE_THREAD_STATE_COUNT;
+
+    mach_port_t   mach_thread_self();
+    kern_return_t thread_suspend(thread_act_t);
+    kern_return_t thread_resume(thread_act_t);
+    kern_return_t thread_get_state(thread_act_t, thread_state_flavor_t, thread_state_t*, mach_msg_type_number_t*);
+}
diff --git a/libphobos/libdruntime/core/sys/osx/pthread.d b/libphobos/libdruntime/core/sys/osx/pthread.d
new file mode 100644
index 00000000000..953a7873671
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/osx/pthread.d
@@ -0,0 +1,50 @@
+/**
+ * D header file for OSX.
+ *
+ * Copyright: Copyright Sean Kelly 2008 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ */
+
+/*          Copyright Sean Kelly 2008 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.osx.pthread;
+
+version (OSX):
+extern (C):
+nothrow:
+
+public import core.sys.posix.pthread;
+public import core.sys.osx.mach.port;
+
+int pthread_is_threaded_np();
+int pthread_threadid_np(pthread_t, ulong*);
+// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
+int pthread_rwlock_longrdlock_np(pthread_rwlock_t*);
+int pthread_rwlock_yieldwrlock_np(pthread_rwlock_t*);
+// ^ __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
+int pthread_rwlock_downgrade_np(pthread_rwlock_t*);
+int pthread_rwlock_upgrade_np(pthread_rwlock_t*);
+int pthread_rwlock_tryupgrade_np(pthread_rwlock_t*);
+int pthread_rwlock_held_np(pthread_rwlock_t*);
+int pthread_rwlock_rdheld_np(pthread_rwlock_t*);
+int pthread_rwlock_wrheld_np(pthread_rwlock_t*);
+int pthread_getname_np(pthread_t, char*, size_t);
+int pthread_setname_np(in char*);
+// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
+int pthread_main_np();
+mach_port_t pthread_mach_thread_np(pthread_t);
+size_t pthread_get_stacksize_np(pthread_t);
+void* pthread_get_stackaddr_np(pthread_t);
+int pthread_cond_signal_thread_np(pthread_cond_t*, pthread_t);
+int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, in timespec*);
+int pthread_create_suspended_np(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
+int pthread_kill(pthread_t, int);
+pthread_t pthread_from_mach_thread_np(mach_port_t);
+// ^ __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
+int pthread_sigmask(int, in sigset_t*, sigset_t*);
+// ^ __DARWIN_ALIAS(pthread_sigmask)
+void pthread_yield_np();
diff --git a/libphobos/libdruntime/core/sys/osx/sys/cdefs.d b/libphobos/libdruntime/core/sys/osx/sys/cdefs.d
new file mode 100644
index 00000000000..6c12d2bd904
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/osx/sys/cdefs.d
@@ -0,0 +1,16 @@
+/**
+ * D header file for OSX
+ *
+ * Authors: Martin Nowak
+ */
+module core.sys.osx.sys.cdefs;
+
+version (OSX):
+
+public import core.sys.posix.config;
+
+// http://www.opensource.apple.com/source/xnu/xnu-2422.115.4/bsd/sys/cdefs.h
+enum _DARWIN_C_SOURCE = true;
+
+enum __DARWIN_C_FULL = 900000L;
+enum __DARWIN_C_LEVEL = __DARWIN_C_FULL;
diff --git a/libphobos/libdruntime/core/sys/osx/sys/event.d b/libphobos/libdruntime/core/sys/osx/sys/event.d
new file mode 100644
index 00000000000..cb20c4c35e5
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/osx/sys/event.d
@@ -0,0 +1,130 @@
+/**
+ * D header file for OSX.
+ *
+ * Copyright: Copyright Martin Nowak 2012. Etienne Cimon 2015.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ */
+
+/*          Copyright Martin Nowak 2012. Etienne Cimon 2015.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.osx.sys.event;
+
+version (OSX):
+extern (C):
+
+import core.stdc.stdint;    // intptr_t, uintptr_t
+import core.sys.posix.time; // timespec
+
+enum : short
+{
+    EVFILT_READ     =  -1,
+    EVFILT_WRITE    =  -2,
+    EVFILT_AIO      =  -3, /* attached to aio requests */
+    EVFILT_VNODE    =  -4, /* attached to vnodes */
+    EVFILT_PROC     =  -5, /* attached to struct proc */
+    EVFILT_SIGNAL   =  -6, /* attached to struct proc */
+    EVFILT_TIMER    =  -7, /* timers */
+    EVFILT_MACHPORT =  -8, /* Mach portsets */
+    EVFILT_FS       =  -9, /* filesystem events */
+    EVFILT_USER     = -10, /* User events */
+    EVFILT_VM       = -12, /* virtual memory events */
+    EVFILT_SYSCOUNT =  11
+}
+
+extern(D) void EV_SET(kevent_t* kevp, typeof(kevent_t.tupleof) args)
+{
+    *kevp = kevent_t(args);
+}
+
+struct kevent_t
+{
+    uintptr_t    ident; /* identifier for this event */
+    short       filter; /* filter for event */
+    ushort       flags;
+    uint        fflags;
+    intptr_t      data;
+    void        *udata; /* opaque user data identifier */
+}
+
+enum
+{
+    /* actions */
+    EV_ADD      = 0x0001, /* add event to kq (implies enable) */
+    EV_DELETE   = 0x0002, /* delete event from kq */
+    EV_ENABLE   = 0x0004, /* enable event */
+    EV_DISABLE  = 0x0008, /* disable event (not reported) */
+
+    /* flags */
+    EV_ONESHOT  = 0x0010, /* only report one occurrence */
+    EV_CLEAR    = 0x0020, /* clear event state after reporting */
+    EV_RECEIPT  = 0x0040, /* force EV_ERROR on success, data=0 */
+    EV_DISPATCH = 0x0080, /* disable event after reporting */
+
+    EV_SYSFLAGS = 0xF000, /* reserved by system */
+    EV_FLAG1    = 0x2000, /* filter-specific flag */
+
+    /* returned values */
+    EV_EOF      = 0x8000, /* EOF detected */
+    EV_ERROR    = 0x4000, /* error, data contains errno */
+}
+
+enum
+{
+    /*
+     * data/hint flags/masks for EVFILT_USER, shared with userspace
+     *
+     * On input, the top two bits of fflags specifies how the lower twenty four
+     * bits should be applied to the stored value of fflags.
+     *
+     * On output, the top two bits will always be set to NOTE_FFNOP and the
+     * remaining twenty four bits will contain the stored fflags value.
+     */
+    NOTE_FFNOP      = 0x00000000, /* ignore input fflags */
+    NOTE_FFAND      = 0x40000000, /* AND fflags */
+    NOTE_FFOR       = 0x80000000, /* OR fflags */
+    NOTE_FFCOPY     = 0xc0000000, /* copy fflags */
+    NOTE_FFCTRLMASK = 0xc0000000, /* masks for operations */
+    NOTE_FFLAGSMASK = 0x00ffffff,
+
+    NOTE_TRIGGER    = 0x01000000, /* Cause the event to be
+                                  triggered for output. */
+
+    /*
+     * data/hint flags for EVFILT_{READ|WRITE}, shared with userspace
+     */
+    NOTE_LOWAT      = 0x0001, /* low water mark */
+
+    /*
+     * data/hint flags for EVFILT_VNODE, shared with userspace
+     */
+    NOTE_DELETE     = 0x0001, /* vnode was removed */
+    NOTE_WRITE      = 0x0002, /* data contents changed */
+    NOTE_EXTEND     = 0x0004, /* size increased */
+    NOTE_ATTRIB     = 0x0008, /* attributes changed */
+    NOTE_LINK       = 0x0010, /* link count changed */
+    NOTE_RENAME     = 0x0020, /* vnode was renamed */
+    NOTE_REVOKE     = 0x0040, /* vnode access was revoked */
+
+    /*
+     * data/hint flags for EVFILT_PROC, shared with userspace
+     */
+    NOTE_EXIT       = 0x80000000, /* process exited */
+    NOTE_FORK       = 0x40000000, /* process forked */
+    NOTE_EXEC       = 0x20000000, /* process exec'd */
+    NOTE_PCTRLMASK  = 0xf0000000, /* mask for hint bits */
+    NOTE_PDATAMASK  = 0x000fffff, /* mask for pid */
+
+    /* additional flags for EVFILT_PROC */
+    NOTE_TRACK      = 0x00000001, /* follow across forks */
+    NOTE_TRACKERR   = 0x00000002, /* could not track child */
+    NOTE_CHILD      = 0x00000004, /* am a child process */
+}
+
+int kqueue();
+int kevent(int kq, const kevent_t *changelist, int nchanges,
+           kevent_t *eventlist, int nevents,
+           const timespec *timeout);
diff --git a/libphobos/libdruntime/core/sys/osx/sys/mman.d b/libphobos/libdruntime/core/sys/osx/sys/mman.d
new file mode 100644
index 00000000000..1a29903aa7c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/osx/sys/mman.d
@@ -0,0 +1,102 @@
+/**
+ * D header file for FreeBSD
+ *
+ * Authors: Martin Nowak
+ */
+module core.sys.osx.sys.mman;
+
+version (OSX):
+extern (C):
+nothrow:
+
+public import core.sys.posix.sys.mman;
+import core.sys.osx.sys.cdefs;
+import core.sys.posix.sys.types;
+
+// already in core.sys.posix.sys.mman
+// enum PROT_NONE = 0x00;
+// enum PROT_READ = 0x01;
+// enum PROT_WRITE = 0x02;
+// enum PROT_EXEC = 0x04;
+
+// already in core.sys.posix.sys.mman
+// enum MAP_SHARED = 0x0001;
+// enum MAP_PRIVATE = 0x0002;
+static if (_DARWIN_C_SOURCE)
+    alias MAP_COPY = MAP_PRIVATE;
+// enum MAP_FIXED = 0x0010;
+
+static if (_DARWIN_C_SOURCE)
+{
+     enum MAP_RENAME = 0x0020;
+     enum MAP_NORESERVE = 0x0040;
+     enum MAP_RESERVED0080 = 0x0080;
+     enum MAP_NOEXTEND = 0x0100;
+     enum MAP_HASSEMAPHORE = 0x0200;
+     enum MAP_NOCACHE = 0x0400;
+     enum MAP_JIT = 0x0800;
+}
+
+// already in core.sys.posix.sys.mman
+// enum MCL_CURRENT = 0x0001;
+// enum MCL_FUTURE = 0x0002;
+
+// enum MAP_FAILED = cast(void*)-1;
+
+// enum MS_ASYNC = 0x0001;
+// enum MS_INVALIDATE = 0x0002;
+// enum MS_SYNC = 0x0010;
+
+static if (_DARWIN_C_SOURCE)
+{
+    enum MS_KILLPAGES = 0x0004;
+    enum MS_DEACTIVATE = 0x0008;
+
+    enum MAP_FILE = 0x0000;
+
+// already in core.sys.posix.sys.mman
+// enum MAP_ANON = 0x1000;
+
+// enum POSIX_MADV_NORMAL = 0;
+// enum POSIX_MADV_RANDOM = 1;
+// enum POSIX_MADV_SEQUENTIAL = 2;
+// enum POSIX_MADV_WILLNEED = 3;
+// enum POSIX_MADV_DONTNEED = 4;
+
+    alias MADV_NORMAL = POSIX_MADV_NORMAL;
+    alias MADV_RANDOM = POSIX_MADV_RANDOM;
+    alias MADV_SEQUENTIAL = POSIX_MADV_SEQUENTIAL;
+    alias MADV_WILLNEED = POSIX_MADV_WILLNEED;
+    alias MADV_DONTNEED = POSIX_MADV_DONTNEED;
+    enum MADV_FREE = 5;
+    enum MADV_ZERO_WIRED_PAGES = 6;
+    enum MADV_FREE_REUSABLE = 7;
+    enum MADV_FREE_REUSE = 8;
+    enum MADV_CAN_REUSE = 9;
+
+    enum MINCORE_INCORE = 0x1;
+    enum MINCORE_REFERENCED = 0x2;
+    enum MINCORE_MODIFIED = 0x4;
+    enum MINCORE_REFERENCED_OTHER = 0x8;
+    enum MINCORE_MODIFIED_OTHER = 0x10;
+}
+
+// already in core.sys.posix.sys.mman
+// int mlockall(int);
+// int munlockall(void);
+// int mlock(const void *, size_t);
+// void *  mmap(void *, size_t, int, int, int, off_t);
+// int mprotect(void *, size_t, int);
+// int msync(void *, size_t, int);
+// int munlock(const void *, size_t);
+// int munmap(void *, size_t);
+// int shm_open(const char *, int, ...);
+// int shm_unlink(const char *);
+// int posix_madvise(void *, size_t, int);
+
+static if (_DARWIN_C_SOURCE)
+{
+    int madvise(void *, size_t, int);
+    int mincore(const(void)*, size_t, char *);
+    int minherit(void *, size_t, int);
+}
diff --git a/libphobos/libdruntime/core/sys/posix/arpa/inet.d b/libphobos/libdruntime/core/sys/posix/arpa/inet.d
new file mode 100644
index 00000000000..6763df249bd
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/arpa/inet.d
@@ -0,0 +1,221 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.arpa.inet;
+
+private import core.sys.posix.config;
+public import core.stdc.inttypes; // for uint32_t, uint16_t
+public import core.sys.posix.sys.socket; // for socklen_t
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// Required
+//
+/*
+NOTE: The following must must be defined in core.sys.posix.arpa.inet to break
+      a circular import: in_port_t, in_addr_t, struct in_addr, INET_ADDRSTRLEN.
+
+in_port_t // from core.sys.posix.netinet.in_
+in_addr_t // from core.sys.posix.netinet.in_
+
+struct in_addr  // from core.sys.posix.netinet.in_
+INET_ADDRSTRLEN // from core.sys.posix.netinet.in_
+
+uint32_t // from core.stdc.inttypes
+uint16_t // from core.stdc.inttypes
+
+uint32_t htonl(uint32_t);
+uint16_t htons(uint16_t);
+uint32_t ntohl(uint32_t);
+uint16_t ntohs(uint16_t);
+
+in_addr_t inet_addr(in char*);
+char*     inet_ntoa(in_addr);
+// per spec: const char* inet_ntop(int, const void*, char*, socklen_t);
+char*     inet_ntop(int, in void*, char*, socklen_t);
+int       inet_pton(int, in char*, void*);
+*/
+
+version( CRuntime_Glibc )
+{
+    alias uint16_t in_port_t;
+    alias uint32_t in_addr_t;
+
+    struct in_addr
+    {
+        in_addr_t s_addr;
+    }
+
+    enum INET_ADDRSTRLEN = 16;
+
+    @trusted pure
+    {
+    uint32_t htonl(uint32_t);
+    uint16_t htons(uint16_t);
+    uint32_t ntohl(uint32_t);
+    uint16_t ntohs(uint16_t);
+    }
+
+    in_addr_t       inet_addr(in char*);
+    char*           inet_ntoa(in_addr);
+    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
+    int             inet_pton(int, in char*, void*);
+}
+else version( OSX )
+{
+    alias uint16_t in_port_t;
+    alias uint32_t in_addr_t;
+
+    struct in_addr
+    {
+        in_addr_t s_addr;
+    }
+
+    enum INET_ADDRSTRLEN = 16;
+
+    @trusted pure
+    {
+    uint32_t htonl(uint32_t);
+    uint16_t htons(uint16_t);
+    uint32_t ntohl(uint32_t);
+    uint16_t ntohs(uint16_t);
+    }
+
+    in_addr_t       inet_addr(in char*);
+    char*           inet_ntoa(in_addr);
+    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
+    int             inet_pton(int, in char*, void*);
+}
+else version( FreeBSD )
+{
+    alias uint16_t in_port_t;
+    alias uint32_t in_addr_t;
+
+    struct in_addr
+    {
+        in_addr_t s_addr;
+    }
+
+    enum INET_ADDRSTRLEN = 16;
+
+    @trusted pure
+    {
+    uint32_t htonl(uint32_t);
+    uint16_t htons(uint16_t);
+    uint32_t ntohl(uint32_t);
+    uint16_t ntohs(uint16_t);
+    }
+
+    in_addr_t       inet_addr(in char*);
+    char*           inet_ntoa(in_addr);
+    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
+    int             inet_pton(int, in char*, void*);
+}
+else version( Solaris )
+{
+    alias uint16_t in_port_t;
+    alias uint32_t in_addr_t;
+
+    struct in_addr
+    {
+        in_addr_t s_addr;
+    }
+    enum INET_ADDRSTRLEN = 16;
+
+    @trusted pure
+    {
+    uint32_t htonl(uint32_t);
+    uint16_t htons(uint16_t);
+    uint32_t ntohl(uint32_t);
+    uint16_t ntohs(uint16_t);
+    }
+
+    in_addr_t       inet_addr(in char*);
+    char*           inet_ntoa(in_addr);
+    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
+    int             inet_pton(int, in char*, void*);
+}
+else version( CRuntime_Bionic )
+{
+    alias uint32_t in_addr_t;
+
+    struct in_addr
+    {
+        in_addr_t s_addr;
+    }
+
+    enum INET_ADDRSTRLEN = 16;
+
+    @safe pure extern (D)
+    {
+        private
+        {
+            uint32_t __swap32( uint32_t x )
+            {
+                uint32_t byte32_swap = (x & 0xff) << 24 | (x &0xff00) << 8 |
+                                     (x & 0xff0000) >> 8 | (x & 0xff000000) >> 24;
+                return byte32_swap;
+            }
+
+            uint16_t __swap16( uint16_t x )
+            {
+                uint16_t byte16_swap = (x & 0xff) << 8 | (x & 0xff00) >> 8;
+                return byte16_swap;
+            }
+        }
+
+        uint32_t htonl(uint32_t x) { return __swap32(x); }
+        uint16_t htons(uint16_t x) { return __swap16(x); }
+        uint32_t ntohl(uint32_t x) { return __swap32(x); }
+        uint16_t ntohs(uint16_t x) { return __swap16(x); }
+    }
+
+    in_addr_t       inet_addr(in char*);
+    char*           inet_ntoa(in_addr);
+    const(char)*    inet_ntop(int, in void*, char*, size_t);
+    int             inet_pton(int, in char*, void*);
+}
+
+//
+// IPV6 (IP6)
+//
+/*
+NOTE: The following must must be defined in core.sys.posix.arpa.inet to break
+      a circular import: INET6_ADDRSTRLEN.
+
+INET6_ADDRSTRLEN // from core.sys.posix.netinet.in_
+*/
+
+version( CRuntime_Glibc )
+{
+    enum INET6_ADDRSTRLEN = 46;
+}
+else version( OSX )
+{
+    enum INET6_ADDRSTRLEN = 46;
+}
+else version( FreeBSD )
+{
+    enum INET6_ADDRSTRLEN = 46;
+}
+else version( Solaris )
+{
+    enum INET6_ADDRSTRLEN = 46;
+}
+else version( CRuntime_Bionic )
+{
+    enum INET6_ADDRSTRLEN = 46;
+}
diff --git a/libphobos/libdruntime/core/sys/posix/config.d b/libphobos/libdruntime/core/sys/posix/config.d
new file mode 100644
index 00000000000..a6c43523210
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/config.d
@@ -0,0 +1,82 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly,
+              Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.config;
+
+public import core.stdc.config;
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+enum _XOPEN_SOURCE     = 600;
+enum _POSIX_SOURCE     = true;
+enum _POSIX_C_SOURCE   = 200112L;
+
+version (CRuntime_Glibc)
+{
+    // man 7 feature_test_macros
+    // http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
+    enum _GNU_SOURCE         = false;
+    enum _BSD_SOURCE         = false;
+    enum _SVID_SOURCE        = false;
+    enum _ATFILE_SOURCE      = false;
+
+    enum _FILE_OFFSET_BITS   = 64;
+    // <sys/cdefs.h>
+    enum __REDIRECT          = false;
+
+    enum _REENTRANT          = true; // set by compiler when linking -pthread
+
+    // deduced <features.h>
+    enum __USE_FILE_OFFSET64 = _FILE_OFFSET_BITS == 64;
+    enum __USE_LARGEFILE     = __USE_FILE_OFFSET64 && !__REDIRECT;
+    enum __USE_LARGEFILE64   = __USE_FILE_OFFSET64 && !__REDIRECT;
+
+    enum __USE_XOPEN2K       = _XOPEN_SOURCE >= 600;
+    enum __USE_XOPEN2KXSI    = _XOPEN_SOURCE >= 600;
+    enum __USE_XOPEN2K8      = _XOPEN_SOURCE >= 700;
+    enum __USE_XOPEN2K8XSI   = _XOPEN_SOURCE >= 700;
+
+    enum __USE_MISC          = _BSD_SOURCE || _SVID_SOURCE;
+    enum __USE_BSD           = _BSD_SOURCE;
+    enum __USE_SVID          = _SVID_SOURCE;
+    enum __USE_ATFILE        = _ATFILE_SOURCE;
+    enum __USE_GNU           = _GNU_SOURCE;
+    enum __USE_REENTRANT     = _REENTRANT;
+
+    version(D_LP64)
+        enum __WORDSIZE=64;
+    else
+        enum __WORDSIZE=32;
+}
+else version (Solaris)
+{
+    enum _FILE_OFFSET_BITS = 64;
+    enum __REDIRECT = false;
+
+    enum __USE_FILE_OFFSET64 = _FILE_OFFSET_BITS == 64;
+    enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT;
+    enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT;
+
+    enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600;
+    enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600;
+    enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700;
+    enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700;
+
+    version (D_LP64)
+        enum __WORDSIZE = 64;
+    else
+        enum __WORDSIZE = 32;
+}
diff --git a/libphobos/libdruntime/core/sys/posix/dirent.d b/libphobos/libdruntime/core/sys/posix/dirent.d
new file mode 100644
index 00000000000..d0db5952370
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/dirent.d
@@ -0,0 +1,331 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly,
+              Alex Rønne Petersn
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.dirent;
+
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types; // for ino_t
+
+version (Posix):
+extern (C):
+nothrow:
+@nogc:
+
+//
+// Required
+//
+/*
+DIR
+
+struct dirent
+{
+    char[] d_name;
+}
+
+int     closedir(DIR*);
+DIR*    opendir(in char*);
+dirent* readdir(DIR*);
+void    rewinddir(DIR*);
+*/
+
+version( CRuntime_Glibc )
+{
+    // NOTE: The following constants are non-standard Linux definitions
+    //       for dirent.d_type.
+    enum
+    {
+        DT_UNKNOWN  = 0,
+        DT_FIFO     = 1,
+        DT_CHR      = 2,
+        DT_DIR      = 4,
+        DT_BLK      = 6,
+        DT_REG      = 8,
+        DT_LNK      = 10,
+        DT_SOCK     = 12,
+        DT_WHT      = 14
+    }
+
+    struct dirent
+    {
+        ino_t       d_ino;
+        off_t       d_off;
+        ushort      d_reclen;
+        ubyte       d_type;
+        char[256]   d_name;
+    }
+
+    struct DIR
+    {
+        // Managed by OS
+    }
+
+    static if( __USE_FILE_OFFSET64 )
+    {
+        dirent* readdir64(DIR*);
+        alias   readdir64 readdir;
+    }
+    else
+    {
+        dirent* readdir(DIR*);
+    }
+}
+else version( OSX )
+{
+    enum
+    {
+        DT_UNKNOWN  = 0,
+        DT_FIFO     = 1,
+        DT_CHR      = 2,
+        DT_DIR      = 4,
+        DT_BLK      = 6,
+        DT_REG      = 8,
+        DT_LNK      = 10,
+        DT_SOCK     = 12,
+        DT_WHT      = 14
+    }
+
+    // _DARWIN_FEATURE_64_BIT_INODE dirent is default for Mac OSX >10.5 and is
+    // only meaningful type for other OS X/Darwin variants (e.g. iOS).
+    // man dir(5) has some info, man stat(2) gives details.
+    struct dirent
+    {
+        ino_t       d_ino;
+        alias       d_fileno = d_ino;
+        ulong       d_seekoff;
+        ushort      d_reclen;
+        ushort      d_namlen;
+        ubyte       d_type;
+        char[1024]  d_name;
+    }
+
+    struct DIR
+    {
+        // Managed by OS
+    }
+
+    // OS X maintains backwards compatibility with older binaries using 32-bit
+    // inode functions by appending $INODE64 to newer 64-bit inode functions.
+    pragma(mangle, "readdir$INODE64") dirent* readdir(DIR*);
+}
+else version( FreeBSD )
+{
+    enum
+    {
+        DT_UNKNOWN  = 0,
+        DT_FIFO     = 1,
+        DT_CHR      = 2,
+        DT_DIR      = 4,
+        DT_BLK      = 6,
+        DT_REG      = 8,
+        DT_LNK      = 10,
+        DT_SOCK     = 12,
+        DT_WHT      = 14
+    }
+
+    align(4)
+    struct dirent
+    {
+        uint      d_fileno;
+        ushort    d_reclen;
+        ubyte     d_type;
+        ubyte     d_namlen;
+        char[256] d_name;
+    }
+
+    alias void* DIR;
+
+    dirent* readdir(DIR*);
+}
+else version (Solaris)
+{
+    struct dirent
+    {
+        ino_t d_ino;
+        off_t d_off;
+        ushort d_reclen;
+        char[1] d_name;
+    }
+
+    struct DIR
+    {
+        int dd_fd;
+        int dd_loc;
+        int dd_size;
+        char* dd_buf;
+    }
+
+    static if (__USE_LARGEFILE64)
+    {
+        dirent* readdir64(DIR*);
+        alias readdir64 readdir;
+    }
+    else
+    {
+        dirent* readdir(DIR*);
+    }
+}
+else version( CRuntime_Bionic )
+{
+    enum
+    {
+        DT_UNKNOWN  = 0,
+        DT_FIFO     = 1,
+        DT_CHR      = 2,
+        DT_DIR      = 4,
+        DT_BLK      = 6,
+        DT_REG      = 8,
+        DT_LNK      = 10,
+        DT_SOCK     = 12,
+        DT_WHT      = 14
+    }
+
+    struct dirent
+    {
+        ulong       d_ino;
+        long        d_off;
+        ushort      d_reclen;
+        ubyte       d_type;
+        char[256]   d_name;
+    }
+
+    struct DIR
+    {
+    }
+
+    dirent* readdir(DIR*);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+version( OSX )
+{
+    version( D_LP64 )
+    {
+        int closedir(DIR*);
+        pragma(mangle, "opendir$INODE64")   DIR* opendir(in char*);
+        pragma(mangle, "rewinddir$INODE64") void rewinddir(DIR*);
+    }
+    else
+    {
+        // 32-bit mangles __DARWIN_UNIX03 specific functions with $UNIX2003 to
+        // maintain backward compatibility with binaries build pre 10.5
+        pragma(mangle, "closedir$UNIX2003")          int closedir(DIR*);
+        pragma(mangle, "opendir$INODE64$UNIX2003")   DIR* opendir(in char*);
+        pragma(mangle, "rewinddir$INODE64$UNIX2003") void rewinddir(DIR*);
+    }
+}
+else
+{
+    int     closedir(DIR*);
+    DIR*    opendir(in char*);
+    //dirent* readdir(DIR*);
+    void    rewinddir(DIR*);
+}
+
+//
+// Thread-Safe Functions (TSF)
+//
+/*
+int readdir_r(DIR*, dirent*, dirent**);
+*/
+
+version( CRuntime_Glibc )
+{
+  static if( __USE_LARGEFILE64 )
+  {
+    int   readdir64_r(DIR*, dirent*, dirent**);
+    alias readdir64_r readdir_r;
+  }
+  else
+  {
+    int readdir_r(DIR*, dirent*, dirent**);
+  }
+}
+else version( OSX )
+{
+    pragma(mangle, "readdir_r$INODE64") int readdir_r(DIR*, dirent*, dirent**);
+}
+else version( FreeBSD )
+{
+    int readdir_r(DIR*, dirent*, dirent**);
+}
+else version (Solaris)
+{
+    static if (__USE_LARGEFILE64)
+    {
+        int readdir64_r(DIR*, dirent*, dirent**);
+        alias readdir64_r readdir_r;
+    }
+    else
+    {
+        int readdir_r(DIR*, dirent*, dirent**);
+    }
+}
+else version( CRuntime_Bionic )
+{
+    int readdir_r(DIR*, dirent*, dirent**);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// XOpen (XSI)
+//
+/*
+void   seekdir(DIR*, c_long);
+c_long telldir(DIR*);
+*/
+
+version( CRuntime_Glibc )
+{
+    void   seekdir(DIR*, c_long);
+    c_long telldir(DIR*);
+}
+else version( FreeBSD )
+{
+    void   seekdir(DIR*, c_long);
+    c_long telldir(DIR*);
+}
+else version ( OSX )
+{
+    version ( D_LP64 )
+    {
+        pragma(mangle, "seekdir$INODE64") void seekdir(DIR*, c_long);
+        pragma(mangle, "telldir$INODE64") c_long telldir(DIR*);
+    }
+    else
+    {
+        // 32-bit mangles __DARWIN_UNIX03 specific functions with $UNIX2003 to
+        // maintain backward compatibility with binaries build pre 10.5
+        pragma(mangle, "seekdir$INODE64$UNIX2003") void seekdir(DIR*, c_long);
+        pragma(mangle, "telldir$INODE64$UNIX2003") c_long telldir(DIR*);
+    }
+}
+else version (Solaris)
+{
+    c_long telldir(DIR*);
+    void seekdir(DIR*, c_long);
+}
+else version (CRuntime_Bionic)
+{
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/dlfcn.d b/libphobos/libdruntime/core/sys/posix/dlfcn.d
new file mode 100644
index 00000000000..bd5b8eab70c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/dlfcn.d
@@ -0,0 +1,212 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.dlfcn;
+
+private import core.sys.posix.config;
+
+version (Posix):
+extern (C):
+nothrow:
+@nogc:
+
+//
+// XOpen (XSI)
+//
+/*
+RTLD_LAZY
+RTLD_NOW
+RTLD_GLOBAL
+RTLD_LOCAL
+
+int   dlclose(void*);
+char* dlerror();
+void* dlopen(in char*, int);
+void* dlsym(void*, in char*);
+*/
+
+version( CRuntime_Glibc )
+{
+    version (X86)
+    {
+        enum RTLD_LAZY      = 0x00001;
+        enum RTLD_NOW       = 0x00002;
+        enum RTLD_GLOBAL    = 0x00100;
+        enum RTLD_LOCAL     = 0x00000;
+    }
+    else version (X86_64)
+    {
+        enum RTLD_LAZY      = 0x00001;
+        enum RTLD_NOW       = 0x00002;
+        enum RTLD_GLOBAL    = 0x00100;
+        enum RTLD_LOCAL     = 0x00000;
+    }
+    else version (MIPS32)
+    {
+        enum RTLD_LAZY      = 0x0001;
+        enum RTLD_NOW       = 0x0002;
+        enum RTLD_GLOBAL    = 0x0004;
+        enum RTLD_LOCAL     = 0;
+    }
+    else version (MIPS64)
+    {
+        enum RTLD_LAZY      = 0x0001;
+        enum RTLD_NOW       = 0x0002;
+        enum RTLD_GLOBAL    = 0x0004;
+        enum RTLD_LOCAL     = 0;
+    }
+    else version (PPC)
+    {
+        enum RTLD_LAZY      = 0x00001;
+        enum RTLD_NOW       = 0x00002;
+        enum RTLD_GLOBAL    = 0x00100;
+        enum RTLD_LOCAL     = 0;
+    }
+    else version (PPC64)
+    {
+        enum RTLD_LAZY      = 0x00001;
+        enum RTLD_NOW       = 0x00002;
+        enum RTLD_GLOBAL    = 0x00100;
+        enum RTLD_LOCAL     = 0;
+    }
+    else version (ARM)
+    {
+        enum RTLD_LAZY      = 0x00001;
+        enum RTLD_NOW       = 0x00002;
+        enum RTLD_GLOBAL    = 0x00100;
+        enum RTLD_LOCAL     = 0;
+    }
+    else version (AArch64)
+    {
+        enum RTLD_LAZY      = 0x00001;
+        enum RTLD_NOW       = 0x00002;
+        enum RTLD_GLOBAL    = 0x00100;
+        enum RTLD_LOCAL     = 0;
+    }
+    else version (SystemZ)
+    {
+        enum RTLD_LAZY      = 0x00001;
+        enum RTLD_NOW       = 0x00002;
+        enum RTLD_GLOBAL    = 0x00100;
+        enum RTLD_LOCAL     = 0;
+    }
+    else
+        static assert(0, "unimplemented");
+
+    int   dlclose(void*);
+    char* dlerror();
+    void* dlopen(in char*, int);
+    void* dlsym(void*, in char*);
+
+    deprecated("Please use core.sys.linux.dlfcn for non-POSIX extensions")
+    {
+        int   dladdr(void* addr, Dl_info* info);
+        void* dlvsym(void* handle, in char* symbol, in char* version_);
+
+        struct Dl_info
+        {
+            const(char)* dli_fname;
+            void*        dli_fbase;
+            const(char)* dli_sname;
+            void*        dli_saddr;
+        }
+    }
+}
+else version( OSX )
+{
+    enum RTLD_LAZY      = 0x00001;
+    enum RTLD_NOW       = 0x00002;
+    enum RTLD_GLOBAL    = 0x00100;
+    enum RTLD_LOCAL     = 0x00000;
+
+    int   dlclose(void*);
+    char* dlerror();
+    void* dlopen(in char*, int);
+    void* dlsym(void*, in char*);
+    int   dladdr(void* addr, Dl_info* info);
+
+    struct Dl_info
+    {
+        const(char)* dli_fname;
+        void*        dli_fbase;
+        const(char)* dli_sname;
+        void*        dli_saddr;
+    }
+}
+else version( FreeBSD )
+{
+    enum RTLD_LAZY      = 1;
+    enum RTLD_NOW       = 2;
+    enum RTLD_GLOBAL    = 0x100;
+    enum RTLD_LOCAL     = 0;
+
+    int   dlclose(void*);
+    char* dlerror();
+    void* dlopen(in char*, int);
+    void* dlsym(void*, in char*);
+    int   dladdr(const(void)* addr, Dl_info* info);
+
+    struct Dl_info
+    {
+        const(char)* dli_fname;
+        void*        dli_fbase;
+        const(char)* dli_sname;
+        void*        dli_saddr;
+    }
+}
+else version( Solaris )
+{
+    enum RTLD_LAZY      = 1;
+    enum RTLD_NOW       = 2;
+    enum RTLD_GLOBAL    = 0x100;
+    enum RTLD_LOCAL     = 0;
+
+    int   dlclose(void*);
+    char* dlerror();
+    void* dlopen(in char*, int);
+    void* dlsym(void*, in char*);
+    int   dladdr(const(void)* addr, Dl_info* info);
+
+    struct Dl_info
+    {
+        const(char)* dli_fname;
+        void*        dli_fbase;
+        const(char)* dli_sname;
+        void*        dli_saddr;
+    }
+}
+else version( CRuntime_Bionic )
+{
+    enum
+    {
+        RTLD_NOW    = 0,
+        RTLD_LAZY   = 1,
+        RTLD_LOCAL  = 0,
+        RTLD_GLOBAL = 2
+    }
+
+    int          dladdr(in void*, Dl_info*);
+    int          dlclose(void*);
+    const(char)* dlerror();
+    void*        dlopen(in char*, int);
+    void*        dlsym(void*, in char*);
+
+    struct Dl_info
+    {
+        const(char)* dli_fname;
+        void*        dli_fbase;
+        const(char)* dli_sname;
+        void*        dli_saddr;
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/posix/fcntl.d b/libphobos/libdruntime/core/sys/posix/fcntl.d
new file mode 100644
index 00000000000..2e13912ddd1
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/fcntl.d
@@ -0,0 +1,570 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.fcntl;
+
+private import core.sys.posix.config;
+private import core.stdc.stdint;
+public import core.sys.posix.sys.types; // for off_t, mode_t
+public import core.sys.posix.sys.stat;  // for S_IFMT, etc.
+
+version (Posix):
+extern (C):
+
+nothrow:
+@nogc:
+
+//
+// Required
+//
+/*
+F_DUPFD
+F_GETFD
+F_SETFD
+F_GETFL
+F_SETFL
+F_GETLK
+F_SETLK
+F_SETLKW
+F_GETOWN
+F_SETOWN
+
+FD_CLOEXEC
+
+F_RDLCK
+F_UNLCK
+F_WRLCK
+
+O_CREAT
+O_EXCL
+O_NOCTTY
+O_TRUNC
+
+O_APPEND
+O_DSYNC
+O_NONBLOCK
+O_RSYNC
+O_SYNC
+
+O_ACCMODE
+O_RDONLY
+O_RDWR
+O_WRONLY
+
+struct flock
+{
+    short   l_type;
+    short   l_whence;
+    off_t   l_start;
+    off_t   l_len;
+    pid_t   l_pid;
+}
+
+int creat(in char*, mode_t);
+int fcntl(int, int, ...);
+int open(in char*, int, ...);
+*/
+version( CRuntime_Glibc )
+{
+    enum F_DUPFD        = 0;
+    enum F_GETFD        = 1;
+    enum F_SETFD        = 2;
+    enum F_GETFL        = 3;
+    enum F_SETFL        = 4;
+  version(X86_64)
+  {
+    static assert(off_t.sizeof == 8);
+    enum F_GETLK        = 5;
+    enum F_SETLK        = 6;
+    enum F_SETLKW       = 7;
+  }
+  else
+  static if( __USE_FILE_OFFSET64 )
+  {
+    enum F_GETLK        = 12;
+    enum F_SETLK        = 13;
+    enum F_SETLKW       = 14;
+  }
+  else
+  {
+    enum F_GETLK        = 5;
+    enum F_SETLK        = 6;
+    enum F_SETLKW       = 7;
+  }
+    enum F_GETOWN       = 9;
+    enum F_SETOWN       = 8;
+
+    enum FD_CLOEXEC     = 1;
+
+    enum F_RDLCK        = 0;
+    enum F_UNLCK        = 2;
+    enum F_WRLCK        = 1;
+
+    version (X86)
+    {
+        enum O_CREAT        = 0x40;     // octal     0100
+        enum O_EXCL         = 0x80;     // octal     0200
+        enum O_NOCTTY       = 0x100;    // octal     0400
+        enum O_TRUNC        = 0x200;    // octal    01000
+
+        enum O_APPEND       = 0x400;    // octal    02000
+        enum O_NONBLOCK     = 0x800;    // octal    04000
+        enum O_SYNC         = 0x101000; // octal 04010000
+        enum O_DSYNC        = 0x1000;   // octal   010000
+        enum O_RSYNC        = O_SYNC;
+    }
+    else version (X86_64)
+    {
+        enum O_CREAT        = 0x40;     // octal     0100
+        enum O_EXCL         = 0x80;     // octal     0200
+        enum O_NOCTTY       = 0x100;    // octal     0400
+        enum O_TRUNC        = 0x200;    // octal    01000
+
+        enum O_APPEND       = 0x400;    // octal    02000
+        enum O_NONBLOCK     = 0x800;    // octal    04000
+        enum O_SYNC         = 0x101000; // octal 04010000
+        enum O_DSYNC        = 0x1000;   // octal   010000
+        enum O_RSYNC        = O_SYNC;
+    }
+    else version (MIPS32)
+    {
+        enum O_CREAT        = 0x0100;
+        enum O_EXCL         = 0x0400;
+        enum O_NOCTTY       = 0x0800;
+        enum O_TRUNC        = 0x0200;
+
+        enum O_APPEND       = 0x0008;
+        enum O_DSYNC        = O_SYNC;
+        enum O_NONBLOCK     = 0x0080;
+        enum O_RSYNC        = O_SYNC;
+        enum O_SYNC         = 0x0010;
+    }
+    else version (MIPS64)
+    {
+        enum O_CREAT        = 0x0100;
+        enum O_EXCL         = 0x0400;
+        enum O_NOCTTY       = 0x0800;
+        enum O_TRUNC        = 0x0200;
+
+        enum O_APPEND       = 0x0008;
+        enum O_DSYNC        = 0x0010;
+        enum O_NONBLOCK     = 0x0080;
+        enum O_RSYNC        = O_SYNC;
+        enum O_SYNC         = 0x4010;
+    }
+    else version (PPC)
+    {
+        enum O_CREAT        = 0x40;     // octal     0100
+        enum O_EXCL         = 0x80;     // octal     0200
+        enum O_NOCTTY       = 0x100;    // octal     0400
+        enum O_TRUNC        = 0x200;    // octal    01000
+
+        enum O_APPEND       = 0x400;    // octal    02000
+        enum O_NONBLOCK     = 0x800;    // octal    04000
+        enum O_SYNC         = 0x101000; // octal 04010000
+        enum O_DSYNC        = 0x1000;   // octal   010000
+        enum O_RSYNC        = O_SYNC;
+    }
+    else version (PPC64)
+    {
+        enum O_CREAT        = 0x40;     // octal     0100
+        enum O_EXCL         = 0x80;     // octal     0200
+        enum O_NOCTTY       = 0x100;    // octal     0400
+        enum O_TRUNC        = 0x200;    // octal    01000
+
+        enum O_APPEND       = 0x400;    // octal    02000
+        enum O_NONBLOCK     = 0x800;    // octal    04000
+        enum O_SYNC         = 0x101000; // octal 04010000
+        enum O_DSYNC        = 0x1000;   // octal   010000
+        enum O_RSYNC        = O_SYNC;
+    }
+    else version (ARM)
+    {
+        enum O_CREAT        = 0x40;     // octal     0100
+        enum O_EXCL         = 0x80;     // octal     0200
+        enum O_NOCTTY       = 0x100;    // octal     0400
+        enum O_TRUNC        = 0x200;    // octal    01000
+
+        enum O_APPEND       = 0x400;    // octal    02000
+        enum O_NONBLOCK     = 0x800;    // octal    04000
+        enum O_SYNC         = 0x101000; // octal 04010000
+        enum O_DSYNC        = 0x1000;   // octal   010000
+        enum O_RSYNC        = O_SYNC;
+    }
+    else version (AArch64)
+    {
+        enum O_CREAT        = 0x40;     // octal     0100
+        enum O_EXCL         = 0x80;     // octal     0200
+        enum O_NOCTTY       = 0x100;    // octal     0400
+        enum O_TRUNC        = 0x200;    // octal    01000
+
+        enum O_APPEND       = 0x400;    // octal    02000
+        enum O_NONBLOCK     = 0x800;    // octal    04000
+        enum O_SYNC         = 0x101000; // octal 04010000
+        enum O_DSYNC        = 0x1000;   // octal   010000
+        enum O_RSYNC        = O_SYNC;
+    }
+    else version (SystemZ)
+    {
+        enum O_CREAT        = 0x40;     // octal     0100
+        enum O_EXCL         = 0x80;     // octal     0200
+        enum O_NOCTTY       = 0x100;    // octal     0400
+        enum O_TRUNC        = 0x200;    // octal    01000
+
+        enum O_APPEND       = 0x400;    // octal    02000
+        enum O_NONBLOCK     = 0x800;    // octal    04000
+        enum O_SYNC         = 0x101000; // octal 04010000
+        enum O_DSYNC        = 0x1000;   // octal   010000
+        enum O_RSYNC        = O_SYNC;
+    }
+    else
+        static assert(0, "unimplemented");
+
+    enum O_ACCMODE      = 0x3;
+    enum O_RDONLY       = 0x0;
+    enum O_WRONLY       = 0x1;
+    enum O_RDWR         = 0x2;
+
+    struct flock
+    {
+        short   l_type;
+        short   l_whence;
+        off_t   l_start;
+        off_t   l_len;
+        pid_t   l_pid;
+    }
+
+    static if( __USE_FILE_OFFSET64 )
+    {
+        int   creat64(in char*, mode_t);
+        alias creat64 creat;
+
+        int   open64(in char*, int, ...);
+        alias open64 open;
+    }
+    else
+    {
+        int   creat(in char*, mode_t);
+        int   open(in char*, int, ...);
+    }
+}
+else version( OSX )
+{
+    enum F_DUPFD        = 0;
+    enum F_GETFD        = 1;
+    enum F_SETFD        = 2;
+    enum F_GETFL        = 3;
+    enum F_SETFL        = 4;
+    enum F_GETOWN       = 5;
+    enum F_SETOWN       = 6;
+    enum F_GETLK        = 7;
+    enum F_SETLK        = 8;
+    enum F_SETLKW       = 9;
+
+    enum FD_CLOEXEC     = 1;
+
+    enum F_RDLCK        = 1;
+    enum F_UNLCK        = 2;
+    enum F_WRLCK        = 3;
+
+    enum O_CREAT        = 0x0200;
+    enum O_EXCL         = 0x0800;
+    enum O_NOCTTY       = 0;
+    enum O_TRUNC        = 0x0400;
+
+    enum O_RDONLY       = 0x0000;
+    enum O_WRONLY       = 0x0001;
+    enum O_RDWR         = 0x0002;
+    enum O_ACCMODE      = 0x0003;
+
+    enum O_NONBLOCK     = 0x0004;
+    enum O_APPEND       = 0x0008;
+    enum O_SYNC         = 0x0080;
+    //enum O_DSYNC
+    //enum O_RSYNC
+
+    struct flock
+    {
+        off_t   l_start;
+        off_t   l_len;
+        pid_t   l_pid;
+        short   l_type;
+        short   l_whence;
+    }
+
+    int creat(in char*, mode_t);
+    int open(in char*, int, ...);
+}
+else version( FreeBSD )
+{
+    enum F_DUPFD        = 0;
+    enum F_GETFD        = 1;
+    enum F_SETFD        = 2;
+    enum F_GETFL        = 3;
+    enum F_SETFL        = 4;
+    enum F_GETOWN       = 5;
+    enum F_SETOWN       = 6;
+    enum F_GETLK        = 11;
+    enum F_SETLK        = 12;
+    enum F_SETLKW       = 13;
+    enum F_OGETLK       = 7;
+    enum F_OSETLK       = 8;
+    enum F_OSETLKW      = 9;
+    enum F_DUP2FD       = 10;
+
+    enum FD_CLOEXEC     = 1;
+
+    enum F_RDLCK        = 1;
+    enum F_UNLCK        = 2;
+    enum F_WRLCK        = 3;
+
+    enum O_CREAT        = 0x0200;
+    enum O_EXCL         = 0x0800;
+    enum O_NOCTTY       = 0x8000;
+    enum O_TRUNC        = 0x0400;
+
+    enum O_RDONLY       = 0x0000;
+    enum O_WRONLY       = 0x0001;
+    enum O_RDWR         = 0x0002;
+    enum O_ACCMODE      = 0x0003;
+
+    enum O_NONBLOCK     = 0x0004;
+    enum O_APPEND       = 0x0008;
+    enum O_SYNC         = 0x0080;
+    //enum O_DSYNC
+    //enum O_RSYNC
+
+    struct flock
+    {
+        off_t   l_start;
+        off_t   l_len;
+        pid_t   l_pid;
+        short   l_type;
+        short   l_whence;
+        int     l_sysid;
+    }
+
+    struct oflock
+    {
+        off_t   l_start;
+        off_t   l_len;
+        pid_t   l_pid;
+        short   l_type;
+        short   l_whence;
+    }
+
+    int creat(in char*, mode_t);
+    int open(in char*, int, ...);
+}
+else version (Solaris)
+{
+    enum F_DUPFD = 0;
+    enum F_GETFD = 1;
+    enum F_SETFD = 2;
+    enum F_GETFL = 3;
+    enum F_SETFL = 4;
+
+    version (D_LP64)
+    {
+        enum F_GETLK = 14;
+        enum F_SETLK = 6;
+        enum F_SETLKW = 7;
+    }
+    else
+    {
+        static if (__USE_FILE_OFFSET64)
+        {
+            enum F_GETLK = 14;
+            enum F_SETLK = 6;
+            enum F_SETLKW = 7;
+        }
+        else
+        {
+            enum F_GETLK = 33;
+            enum F_SETLK = 34;
+            enum F_SETLKW = 35;
+        }
+    }
+
+    enum F_GETOWN = 23;
+    enum F_SETOWN = 24;
+
+    enum FD_CLOEXEC = 1;
+
+    enum F_RDLCK = 1;
+    enum F_UNLCK = 3;
+    enum F_WRLCK = 2;
+    enum F_UNCKSYS = 4;
+
+    enum O_CREAT = 0x0100;
+    enum O_EXCL = 0x0400;
+    enum O_NOCTTY = 0x0800;
+    enum O_TRUNC = 0x0200;
+
+    enum O_APPEND = 0x0008;
+    enum O_NONBLOCK = 0x0080;
+    enum O_SYNC = 0x0010;
+    enum O_DSYNC = 0x0040;
+    enum O_RSYNC = 0x8000;
+
+    enum O_ACCMODE = (O_SEARCH | O_EXEC | 0x3);
+    enum O_RDONLY = 0;
+    enum O_WRONLY = 1;
+    enum O_RDWR = 2;
+    enum O_SEARCH = 0x200000;
+    enum O_EXEC = 0x400000;
+
+    struct flock
+    {
+        short l_type;
+        short l_whence;
+        off_t l_start;
+        off_t l_len;
+        int l_sysid;
+        pid_t l_pid;
+        c_long[4] l_pad;
+    }
+
+    static if (__USE_LARGEFILE64)
+    {
+        struct flock64
+        {
+            short       l_type;
+            short       l_whence;
+            off64_t     l_start;
+            off64_t     l_len;
+            int         l_sysid;
+            pid_t       l_pid;
+            c_long[4]   l_pad;
+        }
+    }
+
+    version (D_LP64)
+    {
+        int creat(in char*, mode_t);
+        int open(in char*, int, ...);
+
+        static if (__USE_LARGEFILE64)
+        {
+            alias creat creat64;
+            alias open open64;
+        }
+    }
+    else
+    {
+        static if (__USE_LARGEFILE64)
+        {
+            int creat64(in char*, mode_t);
+            alias creat64 creat;
+
+            int open64(in char*, int, ...);
+            alias open64 open;
+        }
+        else
+        {
+            int creat(in char*, mode_t);
+            int open(in char*, int, ...);
+        }
+    }
+}
+else version( CRuntime_Bionic )
+{
+    // All these except for the two functions open and creat really come from
+    // the linux kernel and can probably be merged.
+    enum F_DUPFD        = 0;
+    enum F_GETFD        = 1;
+    enum F_SETFD        = 2;
+    enum F_GETFL        = 3;
+    enum F_SETFL        = 4;
+    enum F_GETLK        = 5;
+    enum F_SETLK        = 6;
+    enum F_SETLKW       = 7;
+    enum F_SETOWN       = 8;
+    enum F_GETOWN       = 9;
+
+    enum FD_CLOEXEC     = 1;
+
+    enum F_RDLCK        = 0;
+    enum F_WRLCK        = 1;
+    enum F_UNLCK        = 2;
+
+    version (X86)
+    {
+        enum O_CREAT        = 0x40;     // octal     0100
+        enum O_EXCL         = 0x80;     // octal     0200
+        enum O_NOCTTY       = 0x100;    // octal     0400
+        enum O_TRUNC        = 0x200;    // octal    01000
+
+        enum O_APPEND       = 0x400;    // octal    02000
+        enum O_NONBLOCK     = 0x800;    // octal    04000
+        enum O_SYNC         = 0x1000;   // octal   010000
+    }
+    else version (ARM)
+    {
+        enum O_CREAT        = 0x40;     // octal     0100
+        enum O_EXCL         = 0x80;     // octal     0200
+        enum O_NOCTTY       = 0x100;    // octal     0400
+        enum O_TRUNC        = 0x200;    // octal    01000
+
+        enum O_APPEND       = 0x400;    // octal    02000
+        enum O_NONBLOCK     = 0x800;    // octal    04000
+        enum O_SYNC         = 0x1000;   // octal   010000
+    }
+    else
+    {
+        static assert(false, "Architecture not supported.");
+    }
+
+    enum O_ACCMODE      = 0x3;
+    enum O_RDONLY       = 0x0;
+    enum O_WRONLY       = 0x1;
+    enum O_RDWR         = 0x2;
+
+    struct flock
+    {
+        short   l_type;
+        short   l_whence;
+        off_t   l_start;
+        off_t   l_len;
+        pid_t   l_pid;
+    }
+
+    int   creat(in char*, mode_t);
+    int   open(in char*, int, ...);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//int creat(in char*, mode_t);
+int fcntl(int, int, ...);
+//int open(in char*, int, ...);
+
+// Generic Posix fallocate
+int posix_fallocate(int, off_t, off_t);
+
+//
+// Advisory Information (ADV)
+//
+/*
+POSIX_FADV_NORMAL
+POSIX_FADV_SEQUENTIAL
+POSIX_FADV_RANDOM
+POSIX_FADV_WILLNEED
+POSIX_FADV_DONTNEED
+POSIX_FADV_NOREUSE
+
+int posix_fadvise(int, off_t, off_t, int);
+*/
diff --git a/libphobos/libdruntime/core/sys/posix/grp.d b/libphobos/libdruntime/core/sys/posix/grp.d
new file mode 100644
index 00000000000..d930242775f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/grp.d
@@ -0,0 +1,174 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009, Sönke Ludwig 2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen, Sönke Ludwig
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.grp;
+
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types; // for gid_t, uid_t
+
+version (Posix):
+extern (C):
+nothrow:
+@nogc:
+
+//
+// Required
+//
+/*
+struct group
+{
+    char*   gr_name;
+    char*   gr_passwd;
+    gid_t   gr_gid;
+    char**  gr_mem;
+}
+
+group* getgrnam(in char*);
+group* getgrgid(gid_t);
+*/
+
+version( CRuntime_Glibc )
+{
+    struct group
+    {
+        char*   gr_name;
+        char*   gr_passwd;
+        gid_t   gr_gid;
+        char**  gr_mem;
+    }
+}
+else version( OSX )
+{
+    struct group
+    {
+        char*   gr_name;
+        char*   gr_passwd;
+        gid_t   gr_gid;
+        char**  gr_mem;
+    }
+}
+else version( FreeBSD )
+{
+    struct group
+    {
+        char*   gr_name;
+        char*   gr_passwd;
+        gid_t   gr_gid;
+        char**  gr_mem;
+    }
+}
+else version( Solaris )
+{
+    struct group
+    {
+        char*   gr_name;
+        char*   gr_passwd;
+        gid_t   gr_gid;
+        char**  gr_mem;
+    }
+}
+else version( CRuntime_Bionic )
+{
+    struct group
+    {
+        char*   gr_name;
+        char*   gr_passwd;
+        gid_t   gr_gid;
+        char**  gr_mem;
+    }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+group* getgrnam(in char*);
+group* getgrgid(gid_t);
+
+//
+// Thread-Safe Functions (TSF)
+//
+/*
+int getgrnam_r(in char*, group*, char*, size_t, group**);
+int getgrgid_r(gid_t, group*, char*, size_t, group**);
+*/
+
+version( CRuntime_Glibc )
+{
+    int getgrnam_r(in char*, group*, char*, size_t, group**);
+    int getgrgid_r(gid_t, group*, char*, size_t, group**);
+}
+else version( OSX )
+{
+    int getgrnam_r(in char*, group*, char*, size_t, group**);
+    int getgrgid_r(gid_t, group*, char*, size_t, group**);
+}
+else version( FreeBSD )
+{
+    int getgrnam_r(in char*, group*, char*, size_t, group**);
+    int getgrgid_r(gid_t, group*, char*, size_t, group**);
+}
+else version( Solaris )
+{
+    int getgrnam_r(in char*, group*, char*, int, group**);
+    int getgrgid_r(gid_t, group*, char*, int, group**);
+}
+else version( CRuntime_Bionic )
+{
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// XOpen (XSI)
+//
+/*
+struct group  *getgrent(void);
+void           endgrent(void);
+void           setgrent(void);
+*/
+
+version( CRuntime_Glibc )
+{
+    group* getgrent();
+    @trusted void endgrent();
+    @trusted void setgrent();
+}
+else version( OSX )
+{
+    group* getgrent();
+    @trusted void endgrent();
+    @trusted void setgrent();
+}
+else version( FreeBSD )
+{
+    group* getgrent();
+    @trusted void endgrent();
+    @trusted void setgrent();
+}
+else version( Solaris )
+{
+    group* getgrent();
+    @trusted void endgrent();
+    @trusted void setgrent();
+}
+else version( CRuntime_Bionic )
+{
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/inttypes.d b/libphobos/libdruntime/core/sys/posix/inttypes.d
new file mode 100644
index 00000000000..7bca85bb638
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/inttypes.d
@@ -0,0 +1,40 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.inttypes;
+
+private import core.sys.posix.config;
+public import core.stdc.inttypes;
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// Required
+//
+/*
+intmax_t  imaxabs(intmax_t);
+imaxdiv_t imaxdiv(intmax_t, intmax_t);
+intmax_t  strtoimax(in char*, char**, int);
+uintmax_t strtoumax(in char *, char**, int);
+intmax_t  wcstoimax(in wchar_t*, wchar_t**, int);
+uintmax_t wcstoumax(in wchar_t*, wchar_t**, int);
+*/
+
+intmax_t  imaxabs(intmax_t);
+imaxdiv_t imaxdiv(intmax_t, intmax_t);
+intmax_t  strtoimax(in char*, char**, int);
+uintmax_t strtoumax(in char *, char**, int);
+intmax_t  wcstoimax(in wchar_t*, wchar_t**, int);
+uintmax_t wcstoumax(in wchar_t*, wchar_t**, int);
diff --git a/libphobos/libdruntime/core/sys/posix/mqueue.d b/libphobos/libdruntime/core/sys/posix/mqueue.d
new file mode 100644
index 00000000000..67ea678c819
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/mqueue.d
@@ -0,0 +1,218 @@
+/**
+ * D header file for Posix Message Queues
+ *
+ * Defines external functions required to manage Posix Message Queues
+ *
+ * mq_open(3)          open a message queue
+ * mq_close(3)         close a message queue
+ * mq_unlink(3)        remove a message queue
+ * mq_send(3)          send a message
+ * mq_receive(3)       receive a message
+ * mq_timedsend(3)     send a message with a timeout (linux specific)
+ * mq_timedreceive(3)  receive a message with a timeout (linux specific)
+ * mq_getattr(3)       get message queue attributes
+ * mq_setattr(3)       set message queue attributes
+ * mq_notify(3)        register asynchronous notify
+ *
+ * Copyright: Copyright (c) 2016 sociomantic labs. All rights reserved
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Andreas Bok Andersen, Mathias Lang
+ * Standards: POSIX.1-2001.
+ * See_Also:  $(WEB pubs.opengroup.org/onlinepubs/9699919799/basedefs/mqueue.h.html, Standard)
+ */
+module core.sys.posix.mqueue;
+
+import core.sys.posix.config;
+import core.sys.posix.signal;
+import core.sys.posix.time;
+
+version (Posix):
+version (CRuntime_Glibc):
+extern (C):
+@nogc nothrow:
+
+
+/// Message queue descriptor.
+alias int mqd_t;
+
+/**
+ * Used in getting and setting the attributes of a message queue.
+ */
+struct mq_attr
+{
+    /// Message queue flags.
+    c_long mq_flags;
+    /// Maximum number of messages.
+    c_long mq_maxmsg;
+    /// Maximum message size.
+    c_long mq_msgsize;
+    /// Number of messages currently queued.
+    c_long mq_curmsgs;
+}
+
+
+/**
+ * Establish connection between a process and a message queue `name`.
+ *
+ * Note:
+ * Linux prototypes are:
+ * mqd_t mq_open (const(char)* name, int oflag);
+ * mqd_t mq_open(const(char)* name, int oflag, mode_t mode, mq_attr* attr);
+ *
+ * Params:
+ *   name   = Name of the message queue to open.
+ *   oflags = determines the type of access used.
+ *            If `O_CREAT` is on `oflag`, the third argument is taken as a
+ *            `mode_t`, the mode of the created message queue.
+ *            If `O_CREAT` is on `oflag`, the fourth argument is taken as
+ *            a pointer to a `mq_attr' (message queue attributes).
+ *            If the fourth argument is `null`, default attributes are used.
+ *
+ * Returns:
+ *  Message queue descriptor or (mqd_t) -1 on error.
+ */
+mqd_t mq_open(const(char)* name, int oflag, ...);
+
+
+/**
+ * Closes the message queue descriptor mqdes.
+ *
+ * Params:
+ *   mqdes = Message queue descriptor to close.
+ *
+ * Returns:
+ *   On success mq_close() returns 0; on error, -1 is returned, with errno
+ *   set to indicate the error.
+ */
+int mq_close (mqd_t mqdes);
+
+
+/**
+ * Query status and attributes of message queue `mqdes`.
+ *
+ * Params:
+ *   mqdes  = Message queue descriptor.
+ *   mqstat = Buffer to fill with the message queue's attributes.
+ *
+ * Returns:
+ *   On success mq_getattr() return 0; on error, -1 is returned, with errno
+ *   set to indicate the error.
+ */
+int mq_getattr (mqd_t mqdes, mq_attr* mqstat);
+
+
+/*
+ * Set attributes associated with message queue `mqdes`
+ *
+ * Params:
+ *   mqdes   = Message queue descriptor.
+ *   newstat = non-null pointer to fill with attributes for `mqdes`.
+ *   oldstat = if not `null` it is filled with the old attributes.
+ *
+ * Returns:
+ *   On success mq_setattr() return 0; on error, -1 is returned, with errno
+ *   set to indicate the error.
+ */
+int mq_setattr (mqd_t mqdes, const(mq_attr)* newstat, mq_attr* oldstat);
+
+
+/**
+ * Remove the specified message queue `name`.
+ *
+ * Params:
+ *   name = Name of the queue to remove.
+ *
+ * Returns:
+ *   On success mq_unlink() returns 0; on error, -1 is returned, with errno
+ *   set to indicate the error.
+ */
+int mq_unlink (const(char)* name);
+
+
+/**
+ * Register for notification when a message is available
+ *
+ * Params:
+ *   mqdes        = Message queue descriptor.
+ *   notification = See `man 3 mq_notify` for details.
+ *
+ * Returns:
+ *   On success mq_notify() returns 0; on error, -1 is returned, with errno
+ *   set to indicate the error.
+ */
+int mq_notify (mqd_t mqdes, const(sigevent)* notification);
+
+
+/**
+ * Receive the oldest message with the highest priority the the message queue
+ *
+ * Params:
+ *   mqdes      = Message queue descriptor.
+ *   msg_ptr    = Buffer to write the message to
+ *   msg_len    = Size of the buffer provided as `msg_ptr`. Must be greater
+ *                than the mq_msgsize attribute of the queue.
+ *   msg_prio   = If not `null`, set to the priority of this message.
+ *
+ * Returns:
+ *   On success, mq_receive() returns the number of bytes in the received
+ *   message; on error, -1 is returned, with errno set to indicate the error
+ */
+ssize_t mq_receive (mqd_t mqdes, char* msg_ptr, size_t msg_len, uint* msg_prio);
+
+
+/**
+ * Receive the oldest message with the highest priority the the message queue,
+ * wait up to a certain timeout.
+ *
+ * Params:
+ *   mqdes       = Message queue descriptor.
+ *   msg_ptr     = Buffer to write the message to
+ *   msg_len     = Size of the buffer provided as `msg_ptr`. Must be greater
+ *                 than the mq_msgsize attribute of the queue.
+ *   msg_prio    = If not `null`, set to the priority of this message.
+ *   abs_timeout = Specify a ceiling on the time to block if the queue is empty.
+ *
+ * Returns:
+ *   On success, mq_receive() returns the number of bytes in the received
+ *   message; on error, -1 is returned, with errno set to indicate the error
+ */
+ssize_t mq_timedreceive (mqd_t mqdes, char* msg_ptr, size_t msg_len,
+                         uint* msg_prio, const(timespec)* abs_timeout);
+
+
+/**
+ * Add a message to a message queue.
+ *
+ * Params:
+ *   mqdes      = Message queue descriptor.
+ *   msg_ptr    = Buffer to read the message from
+ *   msg_len    = Size of the message provided via `msg_ptr`. Must be lower
+ *                or equal to the mq_msgsize attribute of the queue.
+ *   msg_prio   = Priority of this message.
+ *
+ * Returns:
+ *   On success, mq_send() return zero; on error, -1 is returned, with errno
+ *   set to indicate the error.
+ */
+int mq_send (mqd_t mqdes, const(char)* msg_ptr, size_t msg_len, uint msg_prio);
+
+
+/**
+ * Add a message to a message queue, block up to a certain time if the queue
+ * is full.
+ *
+ * Params:
+ *   mqdes      = Message queue descriptor.
+ *   msg_ptr    = Buffer to read the message from
+ *   msg_len    = Size of the message provided via `msg_ptr`. Must be lower
+ *                or equal to the mq_msgsize attribute of the queue.
+ *   msg_prio   = Priority of this message.
+ *   abs_timeout = Specify a ceiling on the time to block if the queue is empty.
+ *
+ * Returns:
+ *   On success, mq_timedsend() return zero; on error, -1 is returned,
+ *   with errno set to indicate the error.
+ *
+ */
+int mq_timedsend (mqd_t mqdes, const(char)* msg_ptr, size_t msg_len,
+                   uint msg_prio, const(timespec)* abs_timeout);
diff --git a/libphobos/libdruntime/core/sys/posix/net/if_.d b/libphobos/libdruntime/core/sys/posix/net/if_.d
new file mode 100644
index 00000000000..4cdd8300ce1
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/net/if_.d
@@ -0,0 +1,91 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.net.if_;
+
+private import core.sys.posix.config;
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// Required
+//
+/*
+struct if_nameindex // renamed to if_nameindex_t
+{
+    uint    if_index;
+    char*   if_name;
+}
+
+IF_NAMESIZE
+
+uint            if_nametoindex(in char*);
+char*           if_indextoname(uint, char*);
+if_nameindex_t* if_nameindex();
+void            if_freenameindex(if_nameindex_t*);
+*/
+
+version( CRuntime_Glibc )
+{
+    struct if_nameindex_t
+    {
+        uint    if_index;
+        char*   if_name;
+    }
+
+    enum IF_NAMESIZE = 16;
+
+    uint            if_nametoindex(in char*);
+    char*           if_indextoname(uint, char*);
+    if_nameindex_t* if_nameindex();
+    void            if_freenameindex(if_nameindex_t*);
+}
+else version( OSX )
+{
+    struct if_nameindex_t
+    {
+        uint    if_index;
+        char*   if_name;
+    }
+
+    enum IF_NAMESIZE = 16;
+
+    uint            if_nametoindex(in char*);
+    char*           if_indextoname(uint, char*);
+    if_nameindex_t* if_nameindex();
+    void            if_freenameindex(if_nameindex_t*);
+}
+else version( FreeBSD )
+{
+    struct if_nameindex_t
+    {
+        uint    if_index;
+        char*   if_name;
+    }
+
+    enum IF_NAMESIZE = 16;
+
+    uint            if_nametoindex(in char*);
+    char*           if_indextoname(uint, char*);
+    if_nameindex_t* if_nameindex();
+    void            if_freenameindex(if_nameindex_t*);
+}
+else version( CRuntime_Bionic )
+{
+    enum IF_NAMESIZE = 16;
+
+    uint            if_nametoindex(in char*);
+    char*           if_indextoname(uint, char*);
+}
diff --git a/libphobos/libdruntime/core/sys/posix/netdb.d b/libphobos/libdruntime/core/sys/posix/netdb.d
new file mode 100644
index 00000000000..26a6d20f6aa
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/netdb.d
@@ -0,0 +1,589 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright David Nadlinger 2011.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   David Nadlinger, Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright David Nadlinger 2011.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.netdb;
+
+private import core.sys.posix.config;
+public import core.stdc.inttypes;         // for uint32_t
+public import core.sys.posix.netinet.in_; // for in_port_t, in_addr_t
+public import core.sys.posix.sys.types;   // for ino_t
+public import core.sys.posix.sys.socket;  // for socklen_t
+
+version (Posix):
+extern (C):
+nothrow:
+@nogc:
+
+//
+// Required
+//
+/*
+struct hostent
+{
+    char*   h_name;
+    char**  h_aliases;
+    int     h_addrtype;
+    int     h_length;
+    char**  h_addr_list;
+}
+
+struct netent
+{
+    char*   n_name;
+    char**  n_aliase;
+    int     n_addrtype;
+    uint32_t n_net;
+}
+
+struct protoent
+{
+    char*   p_name;
+    char**  p_aliases;
+    int     p_proto;
+}
+
+struct servent
+{
+    char*   s_name;
+    char**  s_aliases;
+    int     s_port;
+    char*   s_proto;
+}
+
+IPPORT_RESERVED
+
+h_errno
+
+HOST_NOT_FOUND
+NO_DATA
+NO_RECOVERY
+TRY_AGAIN
+
+struct addrinfo
+{
+    int         ai_flags;
+    int         ai_family;
+    int         ai_socktype;
+    int         ai_protocol;
+    socklen_t   ai_addrlen;
+    sockaddr*   ai_addr;
+    char*       ai_canonname;
+    addrinfo*   ai_next;
+}
+
+AI_PASSIVE
+AI_CANONNAME
+AI_NUMERICHOST
+AI_NUMERICSERV
+AI_V4MAPPED
+AI_ALL
+AI_ADDRCONFIG
+
+NI_NOFQDN
+NI_NUMERICHOST
+NI_NAMEREQD
+NI_NUMERICSERV
+NI_NUMERICSCOPE
+NI_DGRAM
+
+EAI_AGAIN
+EAI_BADFLAGS
+EAI_FAIL
+EAI_FAMILY
+EAI_MEMORY
+EAI_NONAME
+
+EAI_SERVICE
+EAI_SOCKTYPE
+EAI_SYSTEM
+EAI_OVERFLOW
+
+void         endhostent();
+void         endnetent();
+void         endprotoent();
+void         endservent();
+void         freeaddrinfo(addrinfo*);
+const(char)* gai_strerror(int);
+int          getaddrinfo(const(char)*, const(char)*, const(addrinfo)*, addrinfo**);
+hostent*     gethostbyaddr(const(void)*, socklen_t, int);
+hostent*     gethostbyname(const(char)*);
+hostent*     gethostent();
+int          getnameinfo(const(sockaddr)*, socklen_t, char*, socklen_t, char*, socklen_t, int);
+netent*      getnetbyaddr(uint32_t, int);
+netent*      getnetbyname(const(char)*);
+netent*      getnetent();
+protoent*    getprotobyname(const(char)*);
+protoent*    getprotobynumber(int);
+protoent*    getprotoent();
+servent*     getservbyname(const(char)*, const(char)*);
+servent*     getservbyport(int, const(char)*);
+servent*     getservent();
+void         sethostent(int);
+void         setnetent(int);
+void         setprotoent(int);
+void         setservent(int);
+*/
+
+version( CRuntime_Glibc )
+{
+    struct hostent
+    {
+        char*   h_name;
+        char**  h_aliases;
+        int     h_addrtype;
+        int     h_length;
+        char**  h_addr_list;
+        char*   h_addr() @property { return h_addr_list[0]; } // non-standard
+    }
+
+    struct netent
+    {
+        char*   n_name;
+        char**  n_aliases;
+        int     n_addrtype;
+        uint32_t n_net;
+    }
+
+    struct protoent
+    {
+        char*   p_name;
+        char**  p_aliases;
+        int     p_proto;
+    }
+
+    struct servent
+    {
+        char*   s_name;
+        char**  s_aliases;
+        int     s_port;
+        char*   s_proto;
+    }
+
+    enum IPPORT_RESERVED = 1024;
+
+    //h_errno
+
+    enum HOST_NOT_FOUND = 1;
+    enum NO_DATA        = 4;
+    enum NO_RECOVERY    = 3;
+    enum TRY_AGAIN      = 2;
+
+    struct addrinfo
+    {
+        int         ai_flags;
+        int         ai_family;
+        int         ai_socktype;
+        int         ai_protocol;
+        socklen_t   ai_addrlen;
+        sockaddr*   ai_addr;
+        char*       ai_canonname;
+        addrinfo*   ai_next;
+    }
+
+    enum AI_PASSIVE         = 0x1;
+    enum AI_CANONNAME       = 0x2;
+    enum AI_NUMERICHOST     = 0x4;
+    enum AI_NUMERICSERV     = 0x400;
+    enum AI_V4MAPPED        = 0x8;
+    enum AI_ALL             = 0x10;
+    enum AI_ADDRCONFIG      = 0x20;
+
+    enum NI_NOFQDN          = 4;
+    enum NI_NUMERICHOST     = 1;
+    enum NI_NAMEREQD        = 8;
+    enum NI_NUMERICSERV     = 2;
+    //enum NI_NUMERICSCOPE    = ?;
+    enum NI_DGRAM           = 16;
+    enum NI_MAXHOST         = 1025; // non-standard
+    enum NI_MAXSERV         = 32;   // non-standard
+
+    enum EAI_AGAIN          = -3;
+    enum EAI_BADFLAGS       = -1;
+    enum EAI_FAIL           = -4;
+    enum EAI_FAMILY         = -6;
+    enum EAI_MEMORY         = -10;
+    enum EAI_NONAME         = -2;
+    enum EAI_SERVICE        = -8;
+    enum EAI_SOCKTYPE       = -7;
+    enum EAI_SYSTEM         = -11;
+    enum EAI_OVERFLOW       = -12;
+}
+else version( OSX )
+{
+    struct hostent
+    {
+        char*   h_name;
+        char**  h_aliases;
+        int     h_addrtype;
+        int     h_length;
+        char**  h_addr_list;
+        char*   h_addr() @property { return h_addr_list[0]; } // non-standard
+    }
+
+    struct netent
+    {
+        char*   n_name;
+        char**  n_aliases;
+        int     n_addrtype;
+        uint32_t n_net;
+    }
+
+    struct protoent
+    {
+        char*   p_name;
+        char**  p_aliases;
+        int     p_proto;
+    }
+
+    struct servent
+    {
+        char*   s_name;
+        char**  s_aliases;
+        int     s_port;
+        char*   s_proto;
+    }
+
+    enum IPPORT_RESERVED = 1024;
+
+    //h_errno
+
+    enum HOST_NOT_FOUND = 1;
+    enum NO_DATA        = 4;
+    enum NO_RECOVERY    = 3;
+    enum TRY_AGAIN      = 2;
+
+    struct addrinfo
+    {
+        int         ai_flags;
+        int         ai_family;
+        int         ai_socktype;
+        int         ai_protocol;
+        socklen_t   ai_addrlen;
+        char*       ai_canonname;
+        sockaddr*   ai_addr;
+        addrinfo*   ai_next;
+    }
+
+    enum AI_PASSIVE         = 0x1;
+    enum AI_CANONNAME       = 0x2;
+    enum AI_NUMERICHOST     = 0x4;
+    enum AI_NUMERICSERV     = 0x1000;
+    enum AI_V4MAPPED        = 0x800;
+    enum AI_ALL             = 0x100;
+    enum AI_ADDRCONFIG      = 0x400;
+
+    enum NI_NOFQDN          = 0x1;
+    enum NI_NUMERICHOST     = 0x2;
+    enum NI_NAMEREQD        = 0x4;
+    enum NI_NUMERICSERV     = 0x8;
+    //enum NI_NUMERICSCOPE    = ?;
+    enum NI_DGRAM           = 0x10;
+    enum NI_MAXHOST         = 1025; // non-standard
+    enum NI_MAXSERV         = 32;   // non-standard
+
+    enum EAI_AGAIN          = 2;
+    enum EAI_BADFLAGS       = 3;
+    enum EAI_FAIL           = 4;
+    enum EAI_FAMILY         = 5;
+    enum EAI_MEMORY         = 6;
+    enum EAI_NONAME         = 8;
+    enum EAI_SERVICE        = 9;
+    enum EAI_SOCKTYPE       = 10;
+    enum EAI_SYSTEM         = 11;
+    enum EAI_OVERFLOW       = 14;
+}
+else version( FreeBSD )
+{
+    struct hostent
+    {
+        char*   h_name;
+        char**  h_aliases;
+        int     h_addrtype;
+        int     h_length;
+        char**  h_addr_list;
+        extern (D) char* h_addr() @property { return h_addr_list[0]; } // non-standard
+    }
+
+    struct netent
+    {
+        char*   n_name;
+        char**  n_aliases;
+        int     n_addrtype;
+        uint32_t n_net;
+    }
+
+    struct protoent
+    {
+        char*   p_name;
+        char**  p_aliases;
+        int     p_proto;
+    }
+
+    struct servent
+    {
+        char*   s_name;
+        char**  s_aliases;
+        int     s_port;
+        char*   s_proto;
+    }
+
+    enum IPPORT_RESERVED = 1024;
+
+    //h_errno
+
+    enum HOST_NOT_FOUND = 1;
+    enum NO_DATA        = 4;
+    enum NO_RECOVERY    = 3;
+    enum TRY_AGAIN      = 2;
+
+    struct addrinfo
+    {
+        int         ai_flags;
+        int         ai_family;
+        int         ai_socktype;
+        int         ai_protocol;
+        socklen_t   ai_addrlen;
+        char*       ai_canonname;
+        sockaddr*   ai_addr;
+        addrinfo*   ai_next;
+    }
+
+    enum AI_PASSIVE         = 0x1;
+    enum AI_CANONNAME       = 0x2;
+    enum AI_NUMERICHOST     = 0x4;
+    enum AI_NUMERICSERV     = 0x8;
+    enum AI_V4MAPPED        = 0x800;
+    enum AI_ALL             = 0x100;
+    enum AI_ADDRCONFIG      = 0x400;
+
+    enum NI_NOFQDN          = 0x1;
+    enum NI_NUMERICHOST     = 0x2;
+    enum NI_NAMEREQD        = 0x4;
+    enum NI_NUMERICSERV     = 0x8;
+    //enum NI_NUMERICSCOPE    = ?;
+    enum NI_DGRAM           = 0x10;
+    enum NI_MAXHOST         = 1025; // non-standard
+    enum NI_MAXSERV         = 32;   // non-standard
+
+    enum EAI_AGAIN          = 2;
+    enum EAI_BADFLAGS       = 3;
+    enum EAI_FAIL           = 4;
+    enum EAI_FAMILY         = 5;
+    enum EAI_MEMORY         = 6;
+    enum EAI_NONAME         = 8;
+    enum EAI_SERVICE        = 9;
+    enum EAI_SOCKTYPE       = 10;
+    enum EAI_SYSTEM         = 11;
+    enum EAI_OVERFLOW       = 14;
+}
+else version (Solaris)
+{
+    struct hostent
+    {
+        char* h_name;
+        char** h_aliases;
+        int h_addrtype;
+        int h_length;
+        char** h_addr_list;
+
+        extern (D) char* h_addr() @property { return h_addr_list[0]; } // non-standard
+    }
+
+    struct netent
+    {
+        char* n_name;
+        char** n_aliases;
+        int n_addrtype;
+        uint32_t n_net;
+    }
+
+    struct protoent
+    {
+        char* p_name;
+        char** p_aliases;
+        int p_proto;
+    }
+
+    struct servent
+    {
+        char* s_name;
+        char** s_aliases;
+        int s_port;
+        char* s_proto;
+    }
+
+    enum HOST_NOT_FOUND = 1;
+    enum TRY_AGAIN = 2;
+    enum NO_RECOVERY = 3;
+    enum NO_DATA = 4;
+
+    struct addrinfo
+    {
+        int ai_flags;
+        int ai_family;
+        int ai_socktype;
+        int ai_protocol;
+
+        version (SPARC)
+            int _ai_pad;
+        else version (SPARC64)
+            int _ai_pad;
+
+        socklen_t ai_addrlen;
+        char* ai_canonname;
+        sockaddr* ai_addr;
+        addrinfo* ai_next;
+    }
+
+    enum AI_PASSIVE = 0x0008;
+    enum AI_CANONNAME = 0x0010;
+    enum AI_NUMERICHOST = 0x0020;
+    enum AI_NUMERICSERV = 0x0040;
+    enum AI_V4MAPPED = 0x0001;
+    enum AI_ALL = 0x0002;
+    enum AI_ADDRCONFIG = 0x0004;
+
+    enum NI_NOFQDN = 0x0001;
+    enum NI_NUMERICHOST = 0x0002;
+    enum NI_NAMEREQD = 0x0004;
+    enum NI_NUMERICSERV = 0x0008;
+    enum NI_DGRAM = 0x0010;
+    enum NI_WITHSCOPEID = 0x0020;
+    enum NI_NUMERICSCOPE = 0x0040;
+    enum NI_MAXHOST = 1025;
+    enum NI_MAXSERV = 32;
+
+    enum EAI_AGAIN = 2;
+    enum EAI_BADFLAGS = 3;
+    enum EAI_FAIL = 4;
+    enum EAI_FAMILY = 5;
+    enum EAI_MEMORY = 6;
+    enum EAI_NONAME = 8;
+    enum EAI_SERVICE = 9;
+    enum EAI_SOCKTYPE = 10;
+    enum EAI_SYSTEM = 11;
+    enum EAI_OVERFLOW = 14;
+    enum EAI_PROTOCOL = 13;
+    enum EAI_MAX = 14;
+}
+else version( CRuntime_Bionic )
+{
+    struct hostent
+    {
+        char*   h_name;
+        char**  h_aliases;
+        int     h_addrtype;
+        int     h_length;
+        char**  h_addr_list;
+        extern (D) char* h_addr() @property { return h_addr_list[0]; } // non-standard
+    }
+
+    struct netent
+    {
+        char*   n_name;
+        char**  n_aliases;
+        int     n_addrtype;
+        uint32_t n_net;
+    }
+
+    struct protoent
+    {
+        char*   p_name;
+        char**  p_aliases;
+        int     p_proto;
+    }
+
+    struct servent
+    {
+        char*   s_name;
+        char**  s_aliases;
+        int     s_port;
+        char*   s_proto;
+    }
+
+    enum IPPORT_RESERVED = 1024;
+
+    enum HOST_NOT_FOUND = 1;
+    enum NO_DATA        = 4;
+    enum NO_RECOVERY    = 3;
+    enum TRY_AGAIN      = 2;
+
+    struct addrinfo
+    {
+        int         ai_flags;
+        int         ai_family;
+        int         ai_socktype;
+        int         ai_protocol;
+        socklen_t   ai_addrlen;
+        char*       ai_canonname;
+        sockaddr*   ai_addr;
+        addrinfo*   ai_next;
+    }
+
+    enum AI_PASSIVE         = 0x1;
+    enum AI_CANONNAME       = 0x2;
+    enum AI_NUMERICHOST     = 0x4;
+    enum AI_NUMERICSERV     = 0x8;
+    enum AI_V4MAPPED        = 0x800;
+    enum AI_ALL             = 0x100;
+    enum AI_ADDRCONFIG      = 0x400;
+
+    enum NI_NOFQDN          = 0x1;
+    enum NI_NUMERICHOST     = 0x2;
+    enum NI_NAMEREQD        = 0x4;
+    enum NI_NUMERICSERV     = 0x8;
+    enum NI_DGRAM           = 0x10;
+    enum NI_MAXHOST         = 1025; // non-standard
+    enum NI_MAXSERV         = 32;   // non-standard
+
+    enum EAI_AGAIN          = 2;
+    enum EAI_BADFLAGS       = 3;
+    enum EAI_FAIL           = 4;
+    enum EAI_FAMILY         = 5;
+    enum EAI_MEMORY         = 6;
+    enum EAI_NONAME         = 8;
+    enum EAI_SERVICE        = 9;
+    enum EAI_SOCKTYPE       = 10;
+    enum EAI_SYSTEM         = 11;
+    enum EAI_OVERFLOW       = 14;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+void         endhostent();
+void         endnetent();
+void         endprotoent();
+void         endservent();
+void         freeaddrinfo(addrinfo*);
+const(char)* gai_strerror(int);
+int          getaddrinfo(const(char)*, const(char)*, const(addrinfo)*, addrinfo**);
+hostent*     gethostbyaddr(const(void)*, socklen_t, int);
+hostent*     gethostbyname(const(char)*);
+hostent*     gethostent();
+int          getnameinfo(const(sockaddr)*, socklen_t, char*, socklen_t, char*, socklen_t, int);
+netent*      getnetbyaddr(uint32_t, int);
+netent*      getnetbyname(const(char)*);
+netent*      getnetent();
+protoent*    getprotobyname(const(char)*);
+protoent*    getprotobynumber(int);
+protoent*    getprotoent();
+servent*     getservbyname(const(char)*, const(char)*);
+servent*     getservbyport(int, const(char)*);
+servent*     getservent();
+void         sethostent(int);
+void         setnetent(int);
+void         setprotoent(int);
+void         setservent(int);
diff --git a/libphobos/libdruntime/core/sys/posix/netinet/in_.d b/libphobos/libdruntime/core/sys/posix/netinet/in_.d
new file mode 100644
index 00000000000..e145eb8a4c6
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/netinet/in_.d
@@ -0,0 +1,999 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.netinet.in_;
+
+private import core.sys.posix.config;
+public import core.stdc.inttypes; // for uint32_t, uint16_t, uint8_t
+public import core.sys.posix.arpa.inet;
+public import core.sys.posix.sys.socket; // for sa_family_t
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// Required
+//
+/*
+NOTE: The following must must be defined in core.sys.posix.arpa.inet to break
+      a circular import: in_port_t, in_addr_t, struct in_addr, INET_ADDRSTRLEN.
+
+in_port_t
+in_addr_t
+
+sa_family_t // from core.sys.posix.sys.socket
+uint8_t     // from core.stdc.inttypes
+uint32_t    // from core.stdc.inttypes
+
+struct in_addr
+{
+    in_addr_t   s_addr;
+}
+
+struct sockaddr_in
+{
+    sa_family_t sin_family;
+    in_port_t   sin_port;
+    in_addr     sin_addr;
+}
+
+IPPROTO_IP
+IPPROTO_ICMP
+IPPROTO_TCP
+IPPROTO_UDP
+
+INADDR_ANY
+INADDR_BROADCAST
+
+INET_ADDRSTRLEN
+
+htonl() // from core.sys.posix.arpa.inet
+htons() // from core.sys.posix.arpa.inet
+ntohl() // from core.sys.posix.arpa.inet
+ntohs() // from core.sys.posix.arpa.inet
+*/
+
+version( CRuntime_Glibc )
+{
+    // Some networking constants are subtly different for glibc, linux kernel
+    // constants are also provided below.
+
+    //alias uint16_t in_port_t;
+    //alias uint32_t in_addr_t;
+
+    //struct in_addr
+    //{
+    //    in_addr_t s_addr;
+    //}
+
+    private enum __SOCK_SIZE__ = 16;
+
+    struct sockaddr_in
+    {
+        sa_family_t sin_family;
+        in_port_t   sin_port;
+        in_addr     sin_addr;
+
+        /* Pad to size of `struct sockaddr'. */
+        ubyte[__SOCK_SIZE__ - sa_family_t.sizeof -
+              in_port_t.sizeof - in_addr.sizeof] __pad;
+    }
+
+    enum
+    {
+        IPPROTO_IP   = 0,
+        IPPROTO_ICMP = 1,
+        IPPROTO_IGMP = 2,
+        IPPROTO_GGP  = 3,
+        IPPROTO_TCP  = 6,
+        IPPROTO_PUP  = 12,
+        IPPROTO_UDP  = 17,
+        IPPROTO_IDP  = 22,
+        IPPROTO_ND   = 77,
+        IPPROTO_MAX  = 256
+    }
+
+    enum : uint
+    {
+        INADDR_ANY       = 0x00000000,
+        INADDR_BROADCAST = 0xffffffff,
+        INADDR_LOOPBACK  = 0x7F000001,
+        INADDR_NONE      = 0xFFFFFFFF
+    }
+
+    //enum INET_ADDRSTRLEN       = 16;
+}
+else version( OSX )
+{
+    //alias uint16_t in_port_t;
+    //alias uint32_t in_addr_t;
+
+    //struct in_addr
+    //{
+    //    in_addr_t s_addr;
+    //}
+
+    private enum __SOCK_SIZE__ = 16;
+
+    struct sockaddr_in
+    {
+        ubyte       sin_len;
+        sa_family_t sin_family;
+        in_port_t   sin_port;
+        in_addr     sin_addr;
+        ubyte[8]    sin_zero;
+    }
+
+    enum
+    {
+        IPPROTO_IP   = 0,
+        IPPROTO_ICMP = 1,
+        IPPROTO_IGMP = 2,
+        IPPROTO_GGP  = 3,
+        IPPROTO_TCP  = 6,
+        IPPROTO_PUP  = 12,
+        IPPROTO_UDP  = 17,
+        IPPROTO_IDP  = 22,
+        IPPROTO_ND   = 77,
+        IPPROTO_MAX  = 256
+    }
+
+    enum : uint
+    {
+        INADDR_ANY       = 0x00000000,
+        INADDR_BROADCAST = 0xffffffff,
+        INADDR_LOOPBACK  = 0x7F000001,
+        INADDR_NONE      = 0xFFFFFFFF
+    }
+
+    //enum INET_ADDRSTRLEN       = 16;
+}
+else version( FreeBSD )
+{
+    //alias uint16_t in_port_t;
+    //alias uint32_t in_addr_t;
+
+    //struct in_addr
+    //{
+    //    in_addr_t s_addr;
+    //}
+
+    struct sockaddr_in
+    {
+        ubyte       sin_len;
+        sa_family_t sin_family;
+        in_port_t   sin_port;
+        in_addr     sin_addr;
+        ubyte[8]    sin_zero;
+    }
+
+    enum
+    {
+        IPPROTO_IP   = 0,
+        IPPROTO_ICMP = 1,
+        IPPROTO_IGMP = 2,
+        IPPROTO_GGP  = 3,
+        IPPROTO_TCP  = 6,
+        IPPROTO_PUP  = 12,
+        IPPROTO_UDP  = 17,
+        IPPROTO_IDP  = 22,
+        IPPROTO_ND   = 77,
+        IPPROTO_MAX  = 256
+    }
+
+    enum : uint
+    {
+        INADDR_ANY       = 0x00000000,
+        INADDR_BROADCAST = 0xffffffff,
+        INADDR_LOOPBACK  = 0x7f000001,
+        INADDR_NONE      = 0xffffffff
+    }
+
+    //enum INET_ADDRSTRLEN       = 16;
+}
+else version( Solaris )
+{
+    struct sockaddr_in
+    {
+        sa_family_t sin_family;
+        in_port_t   sin_port;
+        in_addr     sin_addr;
+        ubyte[8]    sin_zero;
+    }
+
+    enum
+    {
+        IPPROTO_IP   = 0,
+        IPPROTO_ICMP = 1,
+        IPPROTO_IGMP = 2,
+        IPPROTO_GGP  = 3,
+        IPPROTO_TCP  = 6,
+        IPPROTO_PUP  = 12,
+        IPPROTO_UDP  = 17,
+        IPPROTO_IDP  = 22,
+        IPPROTO_ND   = 77,
+        IPPROTO_MAX  = 256
+    }
+
+    enum : uint
+    {
+        INADDR_ANY       = 0x00000000,
+        INADDR_BROADCAST = 0xffffffff,
+        INADDR_LOOPBACK  = 0x7f000001,
+        INADDR_NONE      = 0xffffffff
+    }
+}
+else version( linux )
+{
+    private enum __SOCK_SIZE__ = 16;
+
+    struct sockaddr_in
+    {
+        sa_family_t sin_family;
+        ushort      sin_port;
+        in_addr     sin_addr;
+
+        /* Pad to size of `struct sockaddr'. */
+        ubyte[__SOCK_SIZE__ - sa_family_t.sizeof -
+              ushort.sizeof - in_addr.sizeof] __pad;
+    }
+
+    enum
+    {
+        IPPROTO_IP   = 0,
+        IPPROTO_ICMP = 1,
+        IPPROTO_IGMP = 2,
+        IPPROTO_GGP  = 3,
+        IPPROTO_TCP  = 6,
+        IPPROTO_PUP  = 12,
+        IPPROTO_UDP  = 17,
+        IPPROTO_IDP  = 22
+    }
+
+    enum : c_ulong
+    {
+        INADDR_ANY       = 0x00000000,
+        INADDR_BROADCAST = 0xffffffff,
+        INADDR_LOOPBACK  = 0x7f000001,
+        INADDR_NONE      = 0xFFFFFFFF
+    }
+}
+
+
+//
+// IPV6 (IP6)
+//
+/*
+NOTE: The following must must be defined in core.sys.posix.arpa.inet to break
+      a circular import: INET6_ADDRSTRLEN.
+
+struct in6_addr
+{
+    uint8_t[16] s6_addr;
+}
+
+struct sockaddr_in6
+{
+    sa_family_t sin6_family;
+    in_port_t   sin6_port;
+    uint32_t    sin6_flowinfo;
+    in6_addr    sin6_addr;
+    uint32_t    sin6_scope_id;
+}
+
+extern in6_addr in6addr_any;
+extern in6_addr in6addr_loopback;
+
+struct ipv6_mreq
+{
+    in6_addr    ipv6mr_multiaddr;
+    uint        ipv6mr_interface;
+}
+
+IPPROTO_IPV6
+
+INET6_ADDRSTRLEN
+
+IPV6_JOIN_GROUP
+IPV6_LEAVE_GROUP
+IPV6_MULTICAST_HOPS
+IPV6_MULTICAST_IF
+IPV6_MULTICAST_LOOP
+IPV6_UNICAST_HOPS
+IPV6_V6ONLY
+
+// macros
+int IN6_IS_ADDR_UNSPECIFIED(in6_addr*)
+int IN6_IS_ADDR_LOOPBACK(in6_addr*)
+int IN6_IS_ADDR_MULTICAST(in6_addr*)
+int IN6_IS_ADDR_LINKLOCAL(in6_addr*)
+int IN6_IS_ADDR_SITELOCAL(in6_addr*)
+int IN6_IS_ADDR_V4MAPPED(in6_addr*)
+int IN6_IS_ADDR_V4COMPAT(in6_addr*)
+int IN6_IS_ADDR_MC_NODELOCAL(in6_addr*)
+int IN6_IS_ADDR_MC_LINKLOCAL(in6_addr*)
+int IN6_IS_ADDR_MC_SITELOCAL(in6_addr*)
+int IN6_IS_ADDR_MC_ORGLOCAL(in6_addr*)
+int IN6_IS_ADDR_MC_GLOBAL(in6_addr*)
+*/
+
+version ( CRuntime_Glibc )
+{
+    struct in6_addr
+    {
+        union
+        {
+            uint8_t[16] s6_addr;
+            uint16_t[8] s6_addr16;
+            uint32_t[4] s6_addr32;
+        }
+    }
+
+    struct sockaddr_in6
+    {
+        sa_family_t sin6_family;
+        in_port_t   sin6_port;
+        uint32_t    sin6_flowinfo;
+        in6_addr    sin6_addr;
+        uint32_t    sin6_scope_id;
+    }
+
+    extern __gshared immutable in6_addr in6addr_any;
+    extern __gshared immutable in6_addr in6addr_loopback;
+
+    struct ipv6_mreq
+    {
+        in6_addr    ipv6mr_multiaddr;
+        uint        ipv6mr_interface;
+    }
+
+    enum : uint
+    {
+        IPPROTO_IPV6        = 41,
+
+        //INET6_ADDRSTRLEN    = 46,
+
+        IPV6_JOIN_GROUP     = 20,
+        IPV6_LEAVE_GROUP    = 21,
+        IPV6_MULTICAST_HOPS = 18,
+        IPV6_MULTICAST_IF   = 17,
+        IPV6_MULTICAST_LOOP = 19,
+        IPV6_UNICAST_HOPS   = 16,
+        IPV6_V6ONLY         = 26
+    }
+
+    // macros
+    extern (D) int IN6_IS_ADDR_UNSPECIFIED( in6_addr* addr ) pure
+    {
+        return (cast(uint32_t*) addr)[0] == 0 &&
+               (cast(uint32_t*) addr)[1] == 0 &&
+               (cast(uint32_t*) addr)[2] == 0 &&
+               (cast(uint32_t*) addr)[3] == 0;
+    }
+
+    extern (D) int IN6_IS_ADDR_LOOPBACK( in6_addr* addr ) pure
+    {
+        return (cast(uint32_t*) addr)[0] == 0  &&
+               (cast(uint32_t*) addr)[1] == 0  &&
+               (cast(uint32_t*) addr)[2] == 0  &&
+               (cast(uint32_t*) addr)[3] == htonl( 1 );
+    }
+
+    extern (D) int IN6_IS_ADDR_MULTICAST( in6_addr* addr ) pure
+    {
+        return (cast(uint8_t*) addr)[0] == 0xff;
+    }
+
+    extern (D) int IN6_IS_ADDR_LINKLOCAL( in6_addr* addr ) pure
+    {
+        return ((cast(uint32_t*) addr)[0] & htonl( 0xffc00000 )) == htonl( 0xfe800000 );
+    }
+
+    extern (D) int IN6_IS_ADDR_SITELOCAL( in6_addr* addr ) pure
+    {
+        return ((cast(uint32_t*) addr)[0] & htonl( 0xffc00000 )) == htonl( 0xfec00000 );
+    }
+
+    extern (D) int IN6_IS_ADDR_V4MAPPED( in6_addr* addr ) pure
+    {
+        return (cast(uint32_t*) addr)[0] == 0 &&
+               (cast(uint32_t*) addr)[1] == 0 &&
+               (cast(uint32_t*) addr)[2] == htonl( 0xffff );
+    }
+
+    extern (D) int IN6_IS_ADDR_V4COMPAT( in6_addr* addr ) pure
+    {
+        return (cast(uint32_t*) addr)[0] == 0 &&
+               (cast(uint32_t*) addr)[1] == 0 &&
+               (cast(uint32_t*) addr)[2] == 0 &&
+               ntohl( (cast(uint32_t*) addr)[3] ) > 1;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in6_addr* addr ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST( addr ) &&
+               ((cast(uint8_t*) addr)[1] & 0xf) == 0x1;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in6_addr* addr ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST( addr ) &&
+               ((cast(uint8_t*) addr)[1] & 0xf) == 0x2;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in6_addr* addr ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST(addr) &&
+               ((cast(uint8_t*) addr)[1] & 0xf) == 0x5;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in6_addr* addr ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST( addr) &&
+               ((cast(uint8_t*) addr)[1] & 0xf) == 0x8;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_GLOBAL( in6_addr* addr ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST( addr ) &&
+               ((cast(uint8_t*) addr)[1] & 0xf) == 0xe;
+    }
+}
+else version( OSX )
+{
+    struct in6_addr
+    {
+        union
+        {
+            uint8_t[16] s6_addr;
+            uint16_t[8] s6_addr16;
+            uint32_t[4] s6_addr32;
+        }
+    }
+
+    struct sockaddr_in6
+    {
+        uint8_t     sin6_len;
+        sa_family_t sin6_family;
+        in_port_t   sin6_port;
+        uint32_t    sin6_flowinfo;
+        in6_addr    sin6_addr;
+        uint32_t    sin6_scope_id;
+    }
+
+    extern __gshared immutable in6_addr in6addr_any;
+    extern __gshared immutable in6_addr in6addr_loopback;
+
+    struct ipv6_mreq
+    {
+        in6_addr    ipv6mr_multiaddr;
+        uint        ipv6mr_interface;
+    }
+
+    enum : uint
+    {
+        IPPROTO_IPV6        = 41,
+
+        //INET6_ADDRSTRLEN    = 46,
+
+        IPV6_JOIN_GROUP     = 12,
+        IPV6_LEAVE_GROUP    = 13,
+        IPV6_MULTICAST_HOPS = 10,
+        IPV6_MULTICAST_IF   = 9,
+        IPV6_MULTICAST_LOOP = 11,
+        IPV6_UNICAST_HOPS   = 4,
+        IPV6_V6ONLY         = 27
+    }
+
+    // macros
+    extern (D) int IN6_IS_ADDR_UNSPECIFIED( in6_addr* addr ) pure
+    {
+        return (cast(uint32_t*) addr)[0] == 0 &&
+               (cast(uint32_t*) addr)[1] == 0 &&
+               (cast(uint32_t*) addr)[2] == 0 &&
+               (cast(uint32_t*) addr)[3] == 0;
+    }
+
+    extern (D) int IN6_IS_ADDR_LOOPBACK( in6_addr* addr ) pure
+    {
+        return (cast(uint32_t*) addr)[0] == 0  &&
+               (cast(uint32_t*) addr)[1] == 0  &&
+               (cast(uint32_t*) addr)[2] == 0  &&
+               (cast(uint32_t*) addr)[3] == ntohl( 1 );
+    }
+
+    extern (D) int IN6_IS_ADDR_MULTICAST( in6_addr* addr ) pure
+    {
+        return addr.s6_addr[0] == 0xff;
+    }
+
+    extern (D) int IN6_IS_ADDR_LINKLOCAL( in6_addr* addr ) pure
+    {
+        return addr.s6_addr[0] == 0xfe && (addr.s6_addr[1] & 0xc0) == 0x80;
+    }
+
+    extern (D) int IN6_IS_ADDR_SITELOCAL( in6_addr* addr ) pure
+    {
+        return addr.s6_addr[0] == 0xfe && (addr.s6_addr[1] & 0xc0) == 0xc0;
+    }
+
+    extern (D) int IN6_IS_ADDR_V4MAPPED( in6_addr* addr ) pure
+    {
+        return (cast(uint32_t*) addr)[0] == 0 &&
+               (cast(uint32_t*) addr)[1] == 0 &&
+               (cast(uint32_t*) addr)[2] == ntohl( 0x0000ffff );
+    }
+
+    extern (D) int IN6_IS_ADDR_V4COMPAT( in6_addr* addr ) pure
+    {
+        return (cast(uint32_t*) addr)[0] == 0 &&
+               (cast(uint32_t*) addr)[1] == 0 &&
+               (cast(uint32_t*) addr)[2] == 0 &&
+               (cast(uint32_t*) addr)[3] != 0 &&
+               (cast(uint32_t*) addr)[3] != ntohl( 1 );
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in6_addr* addr ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST( addr ) &&
+               ((cast(uint8_t*) addr)[1] & 0xf) == 0x1;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in6_addr* addr ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST( addr ) &&
+               ((cast(uint8_t*) addr)[1] & 0xf) == 0x2;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in6_addr* addr ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST(addr) &&
+               ((cast(uint8_t*) addr)[1] & 0xf) == 0x5;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in6_addr* addr ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST( addr) &&
+               ((cast(uint8_t*) addr)[1] & 0xf) == 0x8;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_GLOBAL( in6_addr* addr ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST( addr ) &&
+               ((cast(uint8_t*) addr)[1] & 0xf) == 0xe;
+    }
+}
+else version( FreeBSD )
+{
+    struct in6_addr
+    {
+        union
+        {
+            uint8_t[16] s6_addr;
+            uint16_t[8] s6_addr16;
+            uint32_t[4] s6_addr32;
+        }
+    }
+
+    struct sockaddr_in6
+    {
+        uint8_t     sin6_len;
+        sa_family_t sin6_family;
+        in_port_t   sin6_port;
+        uint32_t    sin6_flowinfo;
+        in6_addr    sin6_addr;
+        uint32_t    sin6_scope_id;
+    }
+
+    extern __gshared immutable in6_addr in6addr_any;
+    extern __gshared immutable in6_addr in6addr_loopback;
+
+    struct ipv6_mreq
+    {
+        in6_addr    ipv6mr_multiaddr;
+        uint        ipv6mr_interface;
+    }
+
+    enum : uint
+    {
+        IPPROTO_IPV6        = 41,
+
+        //INET6_ADDRSTRLEN    = 46,
+
+        IPV6_JOIN_GROUP     = 12,
+        IPV6_LEAVE_GROUP    = 13,
+        IPV6_MULTICAST_HOPS = 10,
+        IPV6_MULTICAST_IF   = 9,
+        IPV6_MULTICAST_LOOP = 11,
+        IPV6_UNICAST_HOPS   = 4,
+        IPV6_V6ONLY         = 27,
+    }
+
+    private enum
+    {
+        __IPV6_ADDR_SCOPE_NODELOCAL     = 0x01,
+        __IPV6_ADDR_SCOPE_INTFACELOCAL  = 0x01,
+        __IPV6_ADDR_SCOPE_LINKLOCAL     = 0x02,
+        __IPV6_ADDR_SCOPE_SITELOCAL     = 0x05,
+        __IPV6_ADDR_SCOPE_ORGLOCAL      = 0x08,
+        __IPV6_ADDR_SCOPE_GLOBAL        = 0x0e,
+    }
+
+    // macros
+    extern (D) int IN6_IS_ADDR_UNSPECIFIED( in in6_addr* a ) pure
+    {
+        return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
+               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
+               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) &&
+               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == 0);
+    }
+
+    extern (D) int IN6_IS_ADDR_LOOPBACK( in in6_addr* a ) pure
+    {
+        return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
+               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
+               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) &&
+               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == ntohl(1));
+    }
+
+    extern (D) int IN6_IS_ADDR_V4COMPAT( in in6_addr* a ) pure
+    {
+        return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
+               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
+               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) &&
+               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != 0) &&
+               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != ntohl(1));
+    }
+
+    extern (D) int IN6_IS_ADDR_V4MAPPED( in in6_addr* a ) pure
+    {
+        return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
+               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
+               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == ntohl(0x0000ffff));
+    }
+
+    extern (D) int IN6_IS_ADDR_LINKLOCAL( in in6_addr* a ) pure
+    {
+        return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0x80;
+    }
+
+    extern (D) int IN6_IS_ADDR_SITELOCAL( in in6_addr* a ) pure
+    {
+        return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0xc0;
+    }
+
+    extern (D) int IN6_IS_ADDR_MULTICAST( in in6_addr* a ) pure
+    {
+        return a.s6_addr[0] == 0xff;
+    }
+
+    extern (D) uint8_t __IPV6_ADDR_MC_SCOPE( in in6_addr* a ) pure
+    {
+        return a.s6_addr[1] & 0x0f;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in in6_addr* a ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST(a) &&
+               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in in6_addr* a ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST(a) &&
+               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in in6_addr* a ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST(a) &&
+               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in in6_addr* a ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST(a) &&
+               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_GLOBAL( in in6_addr* a ) pure
+    {
+        return IN6_IS_ADDR_MULTICAST(a) &&
+               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL;
+    }
+}
+else version( Solaris )
+{
+    struct in6_addr
+    {
+        union
+        {
+            uint8_t[16] s6_addr;
+            uint8_t[16] s6_addr8;
+            uint32_t[4] s6_addr32;
+        }
+    }
+
+    struct sockaddr_in6
+    {
+        sa_family_t sin6_family;
+        in_port_t   sin6_port;
+        uint32_t    sin6_flowinfo;
+        in6_addr    sin6_addr;
+        uint32_t    sin6_scope_id;
+        uint32_t    __sin6_src_id;
+    }
+
+    extern __gshared immutable in6_addr in6addr_any;
+    extern __gshared immutable in6_addr in6addr_loopback;
+
+    struct ipv6_mreq
+    {
+        in6_addr    ipv6mr_multiaddr;
+        uint        ipv6mr_interface;
+    }
+
+    enum : uint
+    {
+        IPPROTO_IPV6        = 41,
+
+        //INET6_ADDRSTRLEN    = 46,
+
+        IPV6_JOIN_GROUP     = 9,
+        IPV6_LEAVE_GROUP    = 10,
+        IPV6_MULTICAST_HOPS = 7,
+        IPV6_MULTICAST_IF   = 6,
+        IPV6_MULTICAST_LOOP = 8,
+        IPV6_UNICAST_HOPS   = 5,
+        IPV6_V6ONLY         = 39,
+    }
+
+    // macros
+    extern (D) int IN6_IS_ADDR_UNSPECIFIED( in in6_addr* a ) pure
+    {
+        return (a.s6_addr32[0] == 0) && (a.s6_addr32[1] == 0) &&
+               (a.s6_addr32[2] == 0) && (a.s6_addr32[3] == 0);
+    }
+
+    extern (D) int IN6_IS_ADDR_LOOPBACK( in in6_addr* a ) pure
+    {
+        return (a.s6_addr32[0] == 0) && (a.s6_addr32[1] == 0) &&
+               (a.s6_addr32[2] == 0) && (a.s6_addr32[3] == ntohl(1));
+    }
+
+    extern (D) int IN6_IS_ADDR_V4COMPAT( in in6_addr* a ) pure
+    {
+        return (a.s6_addr32[0] == 0) && (a.s6_addr32[1] == 0) &&
+               (a.s6_addr32[2] == 0) && (a.s6_addr32[3] != 0) &&
+               (a.s6_addr32[3] != ntohl(1));
+    }
+
+    extern (D) int IN6_IS_ADDR_V4MAPPED( in in6_addr* a ) pure
+    {
+        return (a.s6_addr32[0] == 0) && (a.s6_addr32[1] == 0) &&
+               (a.s6_addr32[2] == ntohl(0x0000ffff));
+    }
+
+    extern (D) int IN6_IS_ADDR_LINKLOCAL( in in6_addr* a ) pure
+    {
+        return a.s6_addr8[0] == 0xfe && (a.s6_addr8[1] & 0xc0) == 0x80;
+    }
+
+    extern (D) int IN6_IS_ADDR_SITELOCAL( in in6_addr* a ) pure
+    {
+        return a.s6_addr8[0] == 0xfe && (a.s6_addr8[1] & 0xc0) == 0xc0;
+    }
+
+    extern (D) int IN6_IS_ADDR_MULTICAST( in in6_addr* a ) pure
+    {
+        return a.s6_addr8[0] == 0xff;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in in6_addr* a ) pure
+    {
+        return a.s6_addr8[0] == 0xff && (a.s6_addr8[1] & 0x0f) == 0x01;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in in6_addr* a ) pure
+    {
+        return a.s6_addr8[0] == 0xff && (a.s6_addr8[1] & 0x0f) == 0x02;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in in6_addr* a ) pure
+    {
+        return a.s6_addr8[0] == 0xff && (a.s6_addr8[1] & 0x0f) == 0x05;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in in6_addr* a ) pure
+    {
+        return a.s6_addr8[0] == 0xff && (a.s6_addr8[1] & 0x0f) == 0x08;
+    }
+
+    extern (D) int IN6_IS_ADDR_MC_GLOBAL( in in6_addr* a ) pure
+    {
+        return a.s6_addr8[0] == 0xff && (a.s6_addr8[1] & 0x0f) == 0x0e;
+    }
+}
+else version( CRuntime_Bionic )
+{
+    struct in6_addr
+    {
+        union
+        {
+            uint8_t[16] s6_addr;
+            uint16_t[8] s6_addr16;
+            uint32_t[4] s6_addr32;
+        }
+    }
+
+    struct sockaddr_in6
+    {
+        ushort      sin6_family;
+        uint16_t    sin6_port;
+        uint32_t    sin6_flowinfo;
+        in6_addr    sin6_addr;
+        uint32_t    sin6_scope_id;
+    }
+
+    __gshared immutable in6_addr in6addr_any = {[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]};
+    __gshared immutable in6_addr in6addr_loopback = {[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]};
+
+    struct ipv6_mreq
+    {
+        in6_addr ipv6mr_multiaddr;
+        int      ipv6mr_ifindex;
+    }
+
+    enum : uint
+    {
+        IPPROTO_IPV6        = 41,
+
+        IPV6_JOIN_GROUP     = 20,
+        IPV6_LEAVE_GROUP    = 21,
+        IPV6_MULTICAST_HOPS = 18,
+        IPV6_MULTICAST_IF   = 17,
+        IPV6_MULTICAST_LOOP = 19,
+        IPV6_UNICAST_HOPS   = 16,
+        IPV6_V6ONLY         = 26
+    }
+
+    private enum
+    {
+        IPV6_ADDR_SCOPE_NODELOCAL     = 0x01,
+        IPV6_ADDR_SCOPE_INTFACELOCAL  = 0x01,
+        IPV6_ADDR_SCOPE_LINKLOCAL     = 0x02,
+        IPV6_ADDR_SCOPE_SITELOCAL     = 0x05,
+        IPV6_ADDR_SCOPE_ORGLOCAL      = 0x08,
+        IPV6_ADDR_SCOPE_GLOBAL        = 0x0e,
+    }
+
+    extern (D) pure
+    {
+        bool IN6_IS_ADDR_UNSPECIFIED( in in6_addr* a )
+        {
+            return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
+                   (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
+                   (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) &&
+                   (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == 0);
+        }
+
+        bool IN6_IS_ADDR_LOOPBACK( in in6_addr* a )
+        {
+            return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
+                   (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
+                   (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) &&
+                   (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == ntohl(1));
+        }
+
+        bool IN6_IS_ADDR_V4COMPAT( in in6_addr* a )
+        {
+            return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
+                   (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
+                   (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) &&
+                   (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != 0) &&
+                   (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != ntohl(1));
+        }
+
+        bool IN6_IS_ADDR_V4MAPPED( in in6_addr* a )
+        {
+            return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
+                   (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
+                   (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == ntohl(0x0000ffff));
+        }
+
+        bool IN6_IS_ADDR_LINKLOCAL( in in6_addr* a )
+        {
+            return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0x80;
+        }
+
+        bool IN6_IS_ADDR_SITELOCAL( in in6_addr* a )
+        {
+            return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0xc0;
+        }
+
+        bool IN6_IS_ADDR_ULA( in in6_addr* a )
+        {
+            return (a.s6_addr[0] & 0xfe) == 0xfc;
+        }
+
+        bool IN6_IS_ADDR_MULTICAST( in in6_addr* a )
+        {
+            return a.s6_addr[0] == 0xff;
+        }
+
+        uint8_t IPV6_ADDR_MC_SCOPE( in in6_addr* a )
+        {
+            return a.s6_addr[1] & 0x0f;
+        }
+
+        bool IN6_IS_ADDR_MC_NODELOCAL( in in6_addr* a )
+        {
+            return IN6_IS_ADDR_MULTICAST(a) &&
+                   IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL;
+        }
+
+        bool IN6_IS_ADDR_MC_LINKLOCAL( in in6_addr* a )
+        {
+            return IN6_IS_ADDR_MULTICAST(a) &&
+                   IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL;
+        }
+
+        bool IN6_IS_ADDR_MC_SITELOCAL( in in6_addr* a )
+        {
+            return IN6_IS_ADDR_MULTICAST(a) &&
+                   IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL;
+        }
+
+        bool IN6_IS_ADDR_MC_ORGLOCAL( in in6_addr* a )
+        {
+            return IN6_IS_ADDR_MULTICAST(a) &&
+                   IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL;
+        }
+
+        bool IN6_IS_ADDR_MC_GLOBAL( in in6_addr* a )
+        {
+            return IN6_IS_ADDR_MULTICAST(a) &&
+                   IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL;
+        }
+    }
+}
+
+
+//
+// Raw Sockets (RS)
+//
+/*
+IPPROTO_RAW
+*/
+
+version( CRuntime_Glibc )
+{
+    enum uint IPPROTO_RAW = 255;
+}
+else version( OSX )
+{
+    enum uint IPPROTO_RAW = 255;
+}
+else version( FreeBSD )
+{
+    enum uint IPPROTO_RAW = 255;
+}
+else version( Solaris )
+{
+    enum uint IPPROTO_RAW = 255;
+}
+else version( linux )
+{
+    enum uint IPPROTO_RAW = 255;
+}
diff --git a/libphobos/libdruntime/core/sys/posix/netinet/tcp.d b/libphobos/libdruntime/core/sys/posix/netinet/tcp.d
new file mode 100644
index 00000000000..5c40915f45f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/netinet/tcp.d
@@ -0,0 +1,48 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.netinet.tcp;
+
+private import core.sys.posix.config;
+
+version (Posix):
+extern (C):
+
+//
+// Required
+//
+/*
+TCP_NODELAY
+*/
+
+version( CRuntime_Glibc )
+{
+    enum TCP_NODELAY = 1;
+}
+else version( OSX )
+{
+    enum TCP_NODELAY = 1;
+}
+else version( FreeBSD )
+{
+    enum TCP_NODELAY = 1;
+}
+else version( Solaris )
+{
+    enum TCP_NODELAY = 1;
+}
+else version( linux )
+{
+    enum TCP_NODELAY = 1;
+}
diff --git a/libphobos/libdruntime/core/sys/posix/poll.d b/libphobos/libdruntime/core/sys/posix/poll.d
new file mode 100644
index 00000000000..c98bcfcb7ac
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/poll.d
@@ -0,0 +1,199 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.poll;
+
+private import core.sys.posix.config;
+
+version (Posix):
+extern (C):
+nothrow:
+@nogc:
+
+//
+// XOpen (XSI)
+//
+/*
+struct pollfd
+{
+    int     fd;
+    short   events;
+    short   revents;
+}
+
+nfds_t
+
+POLLIN
+POLLRDNORM
+POLLRDBAND
+POLLPRI
+POLLOUT
+POLLWRNORM
+POLLWRBAND
+POLLERR
+POLLHUP
+POLLNVAL
+
+int poll(pollfd[], nfds_t, int);
+*/
+
+version( CRuntime_Glibc )
+{
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    }
+
+    alias c_ulong nfds_t;
+
+    enum
+    {
+        POLLIN      = 0x001,
+        POLLRDNORM  = 0x040,
+        POLLRDBAND  = 0x080,
+        POLLPRI     = 0x002,
+        POLLOUT     = 0x004,
+        POLLWRNORM  = 0x100,
+        POLLWRBAND  = 0x200,
+        POLLERR     = 0x008,
+        POLLHUP     = 0x010,
+        POLLNVAL    = 0x020,
+    }
+
+    int poll(pollfd*, nfds_t, int);
+}
+else version( OSX )
+{
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    };
+
+    alias uint nfds_t;
+
+    enum
+    {
+        POLLIN      = 0x0001,
+        POLLPRI     = 0x0002,
+        POLLOUT     = 0x0004,
+        POLLRDNORM  = 0x0040,
+        POLLWRNORM  = POLLOUT,
+        POLLRDBAND  = 0x0080,
+        POLLWRBAND  = 0x0100,
+        POLLEXTEND  = 0x0200,
+        POLLATTRIB  = 0x0400,
+        POLLNLINK   = 0x0800,
+        POLLWRITE   = 0x1000,
+        POLLERR     = 0x0008,
+        POLLHUP     = 0x0010,
+        POLLNVAL    = 0x0020,
+
+        POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
+                        POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
+    }
+
+    int poll(pollfd*, nfds_t, int);
+}
+else version( FreeBSD )
+{
+    alias uint nfds_t;
+
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    };
+
+    enum
+    {
+        POLLIN      = 0x0001,
+        POLLPRI     = 0x0002,
+        POLLOUT     = 0x0004,
+        POLLRDNORM  = 0x0040,
+        POLLWRNORM  = POLLOUT,
+        POLLRDBAND  = 0x0080,
+        POLLWRBAND  = 0x0100,
+        //POLLEXTEND  = 0x0200,
+        //POLLATTRIB  = 0x0400,
+        //POLLNLINK   = 0x0800,
+        //POLLWRITE   = 0x1000,
+        POLLERR     = 0x0008,
+        POLLHUP     = 0x0010,
+        POLLNVAL    = 0x0020,
+
+        POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
+        POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
+    }
+
+    int poll(pollfd*, nfds_t, int);
+}
+else version( Solaris )
+{
+    alias c_ulong nfds_t;
+
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    }
+
+    enum
+    {
+        POLLIN      = 0x0001,
+        POLLPRI     = 0x0002,
+        POLLOUT     = 0x0004,
+        POLLRDNORM  = 0x0040,
+        POLLWRNORM  = POLLOUT,
+        POLLRDBAND  = 0x0080,
+        POLLWRBAND  = 0x0100,
+        POLLERR     = 0x0008,
+        POLLHUP     = 0x0010,
+        POLLNVAL    = 0x0020,
+    }
+
+    int poll(pollfd*, nfds_t, int);
+}
+else version( CRuntime_Bionic )
+{
+    struct pollfd
+    {
+        int     fd;
+        short   events;
+        short   revents;
+    }
+
+    alias uint nfds_t;
+
+    enum
+    {
+        POLLIN      = 0x001,
+        POLLRDNORM  = 0x040,
+        POLLRDBAND  = 0x080,
+        POLLPRI     = 0x002,
+        POLLOUT     = 0x004,
+        POLLWRNORM  = 0x100,
+        POLLWRBAND  = 0x200,
+        POLLERR     = 0x008,
+        POLLHUP     = 0x010,
+        POLLNVAL    = 0x020,
+    }
+
+    int poll(pollfd*, nfds_t, c_long);
+}
diff --git a/libphobos/libdruntime/core/sys/posix/pthread.d b/libphobos/libdruntime/core/sys/posix/pthread.d
new file mode 100644
index 00000000000..074bd5cca9f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/pthread.d
@@ -0,0 +1,1039 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.pthread;
+
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types;
+public import core.sys.posix.sched;
+public import core.sys.posix.time;
+
+import core.stdc.stdint;
+
+version (Posix):
+extern (C)
+nothrow:
+
+//
+// Required
+//
+/*
+PTHREAD_CANCEL_ASYNCHRONOUS
+PTHREAD_CANCEL_ENABLE
+PTHREAD_CANCEL_DEFERRED
+PTHREAD_CANCEL_DISABLE
+PTHREAD_CANCELED
+PTHREAD_COND_INITIALIZER
+PTHREAD_CREATE_DETACHED
+PTHREAD_CREATE_JOINABLE
+PTHREAD_EXPLICIT_SCHED
+PTHREAD_INHERIT_SCHED
+PTHREAD_MUTEX_INITIALIZER
+PTHREAD_ONCE_INIT
+PTHREAD_PROCESS_SHARED
+PTHREAD_PROCESS_PRIVATE
+
+int pthread_atfork(void function(), void function(), void function());
+int pthread_attr_destroy(pthread_attr_t*);
+int pthread_attr_getdetachstate(in pthread_attr_t*, int*);
+int pthread_attr_getschedparam(in pthread_attr_t*, sched_param*);
+int pthread_attr_init(pthread_attr_t*);
+int pthread_attr_setdetachstate(pthread_attr_t*, int);
+int pthread_attr_setschedparam(in pthread_attr_t*, sched_param*);
+int pthread_cancel(pthread_t);
+void pthread_cleanup_push(void function(void*), void*);
+void pthread_cleanup_pop(int);
+int pthread_cond_broadcast(pthread_cond_t*);
+int pthread_cond_destroy(pthread_cond_t*);
+int pthread_cond_init(in pthread_cond_t*, pthread_condattr_t*);
+int pthread_cond_signal(pthread_cond_t*);
+int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, in timespec*);
+int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
+int pthread_condattr_destroy(pthread_condattr_t*);
+int pthread_condattr_init(pthread_condattr_t*);
+int pthread_create(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
+int pthread_detach(pthread_t);
+int pthread_equal(pthread_t, pthread_t);
+void pthread_exit(void*);
+void* pthread_getspecific(pthread_key_t);
+int pthread_join(pthread_t, void**);
+int pthread_key_create(pthread_key_t*, void function(void*));
+int pthread_key_delete(pthread_key_t);
+int pthread_mutex_destroy(pthread_mutex_t*);
+int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t*);
+int pthread_mutex_lock(pthread_mutex_t*);
+int pthread_mutex_trylock(pthread_mutex_t*);
+int pthread_mutex_unlock(pthread_mutex_t*);
+int pthread_mutexattr_destroy(pthread_mutexattr_t*);
+int pthread_mutexattr_init(pthread_mutexattr_t*);
+int pthread_once(pthread_once_t*, void function());
+int pthread_rwlock_destroy(pthread_rwlock_t*);
+int pthread_rwlock_init(pthread_rwlock_t*, in pthread_rwlockattr_t*);
+int pthread_rwlock_rdlock(pthread_rwlock_t*);
+int pthread_rwlock_tryrdlock(pthread_rwlock_t*);
+int pthread_rwlock_trywrlock(pthread_rwlock_t*);
+int pthread_rwlock_unlock(pthread_rwlock_t*);
+int pthread_rwlock_wrlock(pthread_rwlock_t*);
+int pthread_rwlockattr_destroy(pthread_rwlockattr_t*);
+int pthread_rwlockattr_init(pthread_rwlockattr_t*);
+pthread_t pthread_self();
+int pthread_setcancelstate(int, int*);
+int pthread_setcanceltype(int, int*);
+int pthread_setspecific(pthread_key_t, in void*);
+void pthread_testcancel();
+*/
+version( CRuntime_Glibc )
+{
+    enum
+    {
+        PTHREAD_CANCEL_ENABLE,
+        PTHREAD_CANCEL_DISABLE
+    }
+
+    enum
+    {
+        PTHREAD_CANCEL_DEFERRED,
+        PTHREAD_CANCEL_ASYNCHRONOUS
+    }
+
+    enum PTHREAD_CANCELED = cast(void*) -1;
+
+    //enum pthread_mutex_t PTHREAD_COND_INITIALIZER = { __LOCK_ALT_INITIALIZER, 0, "", 0 };
+
+    enum
+    {
+        PTHREAD_CREATE_JOINABLE,
+        PTHREAD_CREATE_DETACHED
+    }
+
+    enum
+    {
+        PTHREAD_INHERIT_SCHED,
+        PTHREAD_EXPLICIT_SCHED
+    }
+
+    enum PTHREAD_MUTEX_INITIALIZER  = pthread_mutex_t.init;
+    enum PTHREAD_ONCE_INIT          = pthread_once_t.init;
+
+    enum
+    {
+        PTHREAD_PROCESS_PRIVATE,
+        PTHREAD_PROCESS_SHARED
+    }
+}
+else version( OSX )
+{
+    enum
+    {
+        PTHREAD_CANCEL_ENABLE   = 1,
+        PTHREAD_CANCEL_DISABLE  = 0
+    }
+
+    enum
+    {
+        PTHREAD_CANCEL_DEFERRED     = 2,
+        PTHREAD_CANCEL_ASYNCHRONOUS = 0
+    }
+
+    enum PTHREAD_CANCELED = cast(void*) -1;
+
+    //enum pthread_mutex_t PTHREAD_COND_INITIALIZER = { __LOCK_ALT_INITIALIZER, 0, "", 0 };
+
+    enum
+    {
+        PTHREAD_CREATE_JOINABLE = 1,
+        PTHREAD_CREATE_DETACHED = 2
+    }
+
+    enum
+    {
+        PTHREAD_INHERIT_SCHED   = 1,
+        PTHREAD_EXPLICIT_SCHED  = 2
+    }
+
+    enum PTHREAD_MUTEX_INITIALIZER  = pthread_mutex_t(0x32AAABA7);
+    enum PTHREAD_ONCE_INIT          = pthread_once_t(0x30b1bcba);
+
+    enum
+    {
+        PTHREAD_PROCESS_PRIVATE = 2,
+        PTHREAD_PROCESS_SHARED  = 1
+    }
+}
+else version( FreeBSD )
+{
+    enum
+    {
+        PTHREAD_DETACHED            = 0x1,
+        PTHREAD_INHERIT_SCHED       = 0x4,
+        PTHREAD_NOFLOAT             = 0x8,
+
+        PTHREAD_CREATE_DETACHED     = PTHREAD_DETACHED,
+        PTHREAD_CREATE_JOINABLE     = 0,
+        PTHREAD_EXPLICIT_SCHED      = 0,
+    }
+
+    enum
+    {
+        PTHREAD_PROCESS_PRIVATE     = 0,
+        PTHREAD_PROCESS_SHARED      = 1,
+    }
+
+    enum
+    {
+        PTHREAD_CANCEL_ENABLE       = 0,
+        PTHREAD_CANCEL_DISABLE      = 1,
+        PTHREAD_CANCEL_DEFERRED     = 0,
+        PTHREAD_CANCEL_ASYNCHRONOUS = 2,
+    }
+
+    enum PTHREAD_CANCELED = cast(void*) -1;
+
+    enum PTHREAD_NEEDS_INIT = 0;
+    enum PTHREAD_DONE_INIT  = 1;
+
+    enum PTHREAD_MUTEX_INITIALIZER              = null;
+    enum PTHREAD_ONCE_INIT                      = null;
+    enum PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP  = null;
+    enum PTHREAD_COND_INITIALIZER               = null;
+    enum PTHREAD_RWLOCK_INITIALIZER             = null;
+}
+else version (Solaris)
+{
+    enum
+    {
+        PTHREAD_INHERIT_SCHED = 0x01,
+        PTHREAD_NOFLOAT = 0x08,
+        PTHREAD_CREATE_DETACHED = 0x40,
+        PTHREAD_CREATE_JOINABLE = 0x00,
+        PTHREAD_EXPLICIT_SCHED = 0x00,
+    }
+
+    enum
+    {
+        PTHREAD_PROCESS_PRIVATE = 0,
+        PTHREAD_PROCESS_SHARED = 1,
+    }
+
+    enum
+    {
+        PTHREAD_CANCEL_ENABLE = 0,
+        PTHREAD_CANCEL_DISABLE = 1,
+        PTHREAD_CANCEL_DEFERRED = 0,
+        PTHREAD_CANCEL_ASYNCHRONOUS = 2,
+    }
+
+    enum PTHREAD_CANCELED = cast(void*)-19;
+
+    enum PTHREAD_MUTEX_INITIALIZER  = pthread_mutex_t.init;
+    enum PTHREAD_ONCE_INIT          = pthread_once_t.init;
+}
+else version( CRuntime_Bionic )
+{
+    enum
+    {
+        PTHREAD_CREATE_JOINABLE,
+        PTHREAD_CREATE_DETACHED
+    }
+
+    enum PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t.init;
+    enum PTHREAD_ONCE_INIT         = pthread_once_t.init;
+
+    enum
+    {
+        PTHREAD_PROCESS_PRIVATE,
+        PTHREAD_PROCESS_SHARED
+    }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+int pthread_atfork(void function(), void function(), void function());
+int pthread_attr_destroy(pthread_attr_t*);
+int pthread_attr_getdetachstate(in pthread_attr_t*, int*);
+int pthread_attr_getschedparam(in pthread_attr_t*, sched_param*);
+int pthread_attr_init(pthread_attr_t*);
+int pthread_attr_setdetachstate(pthread_attr_t*, int);
+int pthread_attr_setschedparam(in pthread_attr_t*, sched_param*);
+int pthread_cancel(pthread_t);
+
+version( CRuntime_Glibc )
+{
+    alias void function(void*) _pthread_cleanup_routine;
+
+    struct _pthread_cleanup_buffer
+    {
+        _pthread_cleanup_routine    __routine;
+        void*                       __arg;
+        int                         __canceltype;
+        _pthread_cleanup_buffer*    __prev;
+    }
+
+    void _pthread_cleanup_push(_pthread_cleanup_buffer*, _pthread_cleanup_routine, void*);
+    void _pthread_cleanup_pop(_pthread_cleanup_buffer*, int);
+
+    struct pthread_cleanup
+    {
+        _pthread_cleanup_buffer buffer = void;
+
+        extern (D) void push()( _pthread_cleanup_routine routine, void* arg )
+        {
+            _pthread_cleanup_push( &buffer, routine, arg );
+        }
+
+        extern (D) void pop()( int execute )
+        {
+            _pthread_cleanup_pop( &buffer, execute );
+        }
+    }
+}
+else version( OSX )
+{
+    alias void function(void*) _pthread_cleanup_routine;
+
+    struct _pthread_cleanup_buffer
+    {
+        _pthread_cleanup_routine    __routine;
+        void*                       __arg;
+        _pthread_cleanup_buffer*    __next;
+    }
+
+    struct pthread_cleanup
+    {
+        _pthread_cleanup_buffer buffer = void;
+
+        extern (D) void push()( _pthread_cleanup_routine routine, void* arg )
+        {
+            pthread_t self       = pthread_self();
+            buffer.__routine     = routine;
+            buffer.__arg         = arg;
+            buffer.__next        = cast(_pthread_cleanup_buffer*) self.__cleanup_stack;
+            self.__cleanup_stack = cast(pthread_handler_rec*) &buffer;
+        }
+
+        extern (D) void pop()( int execute )
+        {
+            pthread_t self       = pthread_self();
+            self.__cleanup_stack = cast(pthread_handler_rec*) buffer.__next;
+            if( execute )
+            {
+                buffer.__routine( buffer.__arg );
+            }
+        }
+    }
+}
+else version( FreeBSD )
+{
+    alias void function(void*) _pthread_cleanup_routine;
+
+    struct _pthread_cleanup_info
+    {
+        uintptr_t[8]    pthread_cleanup_pad;
+    }
+
+    struct pthread_cleanup
+    {
+        _pthread_cleanup_info __cleanup_info__ = void;
+
+        extern (D) void push()( _pthread_cleanup_routine cleanup_routine, void* cleanup_arg )
+        {
+            __pthread_cleanup_push_imp( cleanup_routine, cleanup_arg, &__cleanup_info__ );
+        }
+
+        extern (D) void pop()( int execute )
+        {
+            __pthread_cleanup_pop_imp( execute );
+        }
+    }
+
+    void __pthread_cleanup_push_imp(_pthread_cleanup_routine, void*, _pthread_cleanup_info*);
+    void __pthread_cleanup_pop_imp(int);
+}
+else version (Solaris)
+{
+    alias void function(void*) _pthread_cleanup_routine;
+
+    caddr_t _getfp();
+
+    struct _pthread_cleanup_info
+    {
+        uintptr_t[4] pthread_cleanup_pad;
+    }
+
+    struct pthread_cleanup
+    {
+        _pthread_cleanup_info __cleanup_info__ = void;
+
+        extern (D) void push()(_pthread_cleanup_routine cleanup_routine, void* cleanup_arg)
+        {
+            __pthread_cleanup_push(cleanup_routine, cleanup_arg, _getfp(), &__cleanup_info__);
+        }
+
+        extern (D) void pop()(int execute)
+        {
+            __pthread_cleanup_pop(execute, &__cleanup_info__);
+        }
+    }
+
+    void __pthread_cleanup_push(_pthread_cleanup_routine, void*, caddr_t, _pthread_cleanup_info*);
+    void __pthread_cleanup_pop(int, _pthread_cleanup_info*);
+}
+else version( CRuntime_Bionic )
+{
+    alias void function(void*) __pthread_cleanup_func_t;
+
+    struct __pthread_cleanup_t
+    {
+        __pthread_cleanup_t*     __cleanup_prev;
+        __pthread_cleanup_func_t __cleanup_routine;
+        void*                    __cleanup_arg;
+    }
+
+    void __pthread_cleanup_push(__pthread_cleanup_t*, __pthread_cleanup_func_t,
+                                void*);
+    void __pthread_cleanup_pop(__pthread_cleanup_t*, int);
+
+    struct pthread_cleanup
+    {
+        __pthread_cleanup_t __cleanup = void;
+
+        extern (D) void push()( __pthread_cleanup_func_t routine, void* arg )
+        {
+            __pthread_cleanup_push( &__cleanup, routine, arg );
+        }
+
+        extern (D) void pop()( int execute )
+        {
+            __pthread_cleanup_pop( &__cleanup, execute );
+        }
+    }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+@nogc
+{
+    int pthread_cond_broadcast(pthread_cond_t*);
+    int pthread_cond_destroy(pthread_cond_t*);
+    int pthread_cond_init(in pthread_cond_t*, pthread_condattr_t*) @trusted;
+    int pthread_cond_signal(pthread_cond_t*);
+    int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, in timespec*);
+    int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
+    int pthread_condattr_destroy(pthread_condattr_t*);
+    int pthread_condattr_init(pthread_condattr_t*);
+    int pthread_create(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
+    int pthread_detach(pthread_t);
+    int pthread_equal(pthread_t, pthread_t);
+    void pthread_exit(void*);
+    void* pthread_getspecific(pthread_key_t);
+    int pthread_join(pthread_t, void**);
+    int pthread_key_create(pthread_key_t*, void function(void*));
+    int pthread_key_delete(pthread_key_t);
+    int pthread_mutex_destroy(pthread_mutex_t*);
+    int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t*) @trusted;
+    int pthread_mutex_lock(pthread_mutex_t*);
+    int pthread_mutex_trylock(pthread_mutex_t*);
+    int pthread_mutex_unlock(pthread_mutex_t*);
+    int pthread_mutexattr_destroy(pthread_mutexattr_t*);
+    int pthread_mutexattr_init(pthread_mutexattr_t*) @trusted;
+    int pthread_once(pthread_once_t*, void function());
+    int pthread_rwlock_destroy(pthread_rwlock_t*);
+    int pthread_rwlock_init(pthread_rwlock_t*, in pthread_rwlockattr_t*);
+    int pthread_rwlock_rdlock(pthread_rwlock_t*);
+    int pthread_rwlock_tryrdlock(pthread_rwlock_t*);
+    int pthread_rwlock_trywrlock(pthread_rwlock_t*);
+    int pthread_rwlock_unlock(pthread_rwlock_t*);
+    int pthread_rwlock_wrlock(pthread_rwlock_t*);
+    int pthread_rwlockattr_destroy(pthread_rwlockattr_t*);
+    int pthread_rwlockattr_init(pthread_rwlockattr_t*);
+    pthread_t pthread_self();
+    int pthread_setcancelstate(int, int*);
+    int pthread_setcanceltype(int, int*);
+    int pthread_setspecific(pthread_key_t, in void*);
+    void pthread_testcancel();
+}
+
+//
+// Barrier (BAR)
+//
+/*
+PTHREAD_BARRIER_SERIAL_THREAD
+
+int pthread_barrier_destroy(pthread_barrier_t*);
+int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+int pthread_barrier_wait(pthread_barrier_t*);
+int pthread_barrierattr_destroy(pthread_barrierattr_t*);
+int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*); (BAR|TSH)
+int pthread_barrierattr_init(pthread_barrierattr_t*);
+int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int); (BAR|TSH)
+*/
+
+version( CRuntime_Glibc )
+{
+    enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
+
+    int pthread_barrier_destroy(pthread_barrier_t*);
+    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+    int pthread_barrier_wait(pthread_barrier_t*);
+    int pthread_barrierattr_destroy(pthread_barrierattr_t*);
+    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
+    int pthread_barrierattr_init(pthread_barrierattr_t*);
+    int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
+}
+else version( FreeBSD )
+{
+    enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
+
+    int pthread_barrier_destroy(pthread_barrier_t*);
+    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+    int pthread_barrier_wait(pthread_barrier_t*);
+    int pthread_barrierattr_destroy(pthread_barrierattr_t*);
+    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
+    int pthread_barrierattr_init(pthread_barrierattr_t*);
+    int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
+}
+else version (OSX)
+{
+}
+else version (Solaris)
+{
+    enum PTHREAD_BARRIER_SERIAL_THREAD = -2;
+
+    int pthread_barrier_destroy(pthread_barrier_t*);
+    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+    int pthread_barrier_wait(pthread_barrier_t*);
+    int pthread_barrierattr_destroy(pthread_barrierattr_t*);
+    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
+    int pthread_barrierattr_init(pthread_barrierattr_t*);
+    int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
+}
+else version (CRuntime_Bionic)
+{
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Clock (CS)
+//
+/*
+int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
+*/
+
+//
+// Spinlock (SPI)
+//
+/*
+int pthread_spin_destroy(pthread_spinlock_t*);
+int pthread_spin_init(pthread_spinlock_t*, int);
+int pthread_spin_lock(pthread_spinlock_t*);
+int pthread_spin_trylock(pthread_spinlock_t*);
+int pthread_spin_unlock(pthread_spinlock_t*);
+*/
+
+version( CRuntime_Glibc )
+{
+    int pthread_spin_destroy(pthread_spinlock_t*);
+    int pthread_spin_init(pthread_spinlock_t*, int);
+    int pthread_spin_lock(pthread_spinlock_t*);
+    int pthread_spin_trylock(pthread_spinlock_t*);
+    int pthread_spin_unlock(pthread_spinlock_t*);
+}
+else version( FreeBSD )
+{
+    int pthread_spin_init(pthread_spinlock_t*, int);
+    int pthread_spin_destroy(pthread_spinlock_t*);
+    int pthread_spin_lock(pthread_spinlock_t*);
+    int pthread_spin_trylock(pthread_spinlock_t*);
+    int pthread_spin_unlock(pthread_spinlock_t*);
+}
+else version (OSX)
+{
+}
+else version (Solaris)
+{
+    int pthread_spin_init(pthread_spinlock_t*, int);
+    int pthread_spin_destroy(pthread_spinlock_t*);
+    int pthread_spin_lock(pthread_spinlock_t*);
+    int pthread_spin_trylock(pthread_spinlock_t*);
+    int pthread_spin_unlock(pthread_spinlock_t*);
+}
+else version (CRuntime_Bionic)
+{
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// XOpen (XSI)
+//
+/*
+PTHREAD_MUTEX_DEFAULT
+PTHREAD_MUTEX_ERRORCHECK
+PTHREAD_MUTEX_NORMAL
+PTHREAD_MUTEX_RECURSIVE
+
+int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+int pthread_attr_setguardsize(pthread_attr_t*, size_t);
+int pthread_getconcurrency();
+int pthread_mutexattr_gettype(in pthread_mutexattr_t*, int*);
+int pthread_mutexattr_settype(pthread_mutexattr_t*, int);
+int pthread_setconcurrency(int);
+*/
+
+version( CRuntime_Glibc )
+{
+    enum PTHREAD_MUTEX_NORMAL       = 0;
+    enum PTHREAD_MUTEX_RECURSIVE    = 1;
+    enum PTHREAD_MUTEX_ERRORCHECK   = 2;
+    enum PTHREAD_MUTEX_DEFAULT      = PTHREAD_MUTEX_NORMAL;
+
+    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_setguardsize(pthread_attr_t*, size_t);
+    int pthread_getconcurrency();
+    int pthread_mutexattr_gettype(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
+    int pthread_setconcurrency(int);
+}
+else version( OSX )
+{
+    enum PTHREAD_MUTEX_NORMAL       = 0;
+    enum PTHREAD_MUTEX_ERRORCHECK   = 1;
+    enum PTHREAD_MUTEX_RECURSIVE    = 2;
+    enum PTHREAD_MUTEX_DEFAULT      = PTHREAD_MUTEX_NORMAL;
+
+    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_setguardsize(pthread_attr_t*, size_t);
+    int pthread_getconcurrency();
+    int pthread_mutexattr_gettype(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
+    int pthread_setconcurrency(int);
+}
+else version( FreeBSD )
+{
+    enum
+    {
+        PTHREAD_MUTEX_ERRORCHECK    = 1,
+        PTHREAD_MUTEX_RECURSIVE     = 2,
+        PTHREAD_MUTEX_NORMAL        = 3,
+        PTHREAD_MUTEX_ADAPTIVE_NP   = 4,
+        PTHREAD_MUTEX_TYPE_MAX
+    }
+    enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK;
+
+    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_setguardsize(pthread_attr_t*, size_t);
+    int pthread_getconcurrency();
+    int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
+    int pthread_setconcurrency(int);
+}
+else version (Solaris)
+{
+    enum
+    {
+        PTHREAD_MUTEX_ERRORCHECK    = 2,
+        PTHREAD_MUTEX_RECURSIVE     = 4,
+        PTHREAD_MUTEX_NORMAL        = 0,
+    }
+
+    enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL;
+
+    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_setguardsize(pthread_attr_t*, size_t);
+    int pthread_getconcurrency();
+    int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
+    int pthread_setconcurrency(int);
+}
+else version (CRuntime_Bionic)
+{
+    enum PTHREAD_MUTEX_NORMAL     = 0;
+    enum PTHREAD_MUTEX_RECURSIVE  = 1;
+    enum PTHREAD_MUTEX_ERRORCHECK = 2;
+    enum PTHREAD_MUTEX_DEFAULT    = PTHREAD_MUTEX_NORMAL;
+
+    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_setguardsize(pthread_attr_t*, size_t);
+    int pthread_mutexattr_gettype(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// CPU Time (TCT)
+//
+/*
+int pthread_getcpuclockid(pthread_t, clockid_t*);
+*/
+
+version( CRuntime_Glibc )
+{
+    int pthread_getcpuclockid(pthread_t, clockid_t*);
+}
+else version( FreeBSD )
+{
+    int pthread_getcpuclockid(pthread_t, clockid_t*);
+}
+else version (OSX)
+{
+}
+else version (Solaris)
+{
+}
+else version( CRuntime_Bionic )
+{
+    int pthread_getcpuclockid(pthread_t, clockid_t*);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Timeouts (TMO)
+//
+/*
+int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
+int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
+int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+*/
+
+version( CRuntime_Glibc )
+{
+    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+}
+else version( OSX )
+{
+    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+}
+else version( FreeBSD )
+{
+    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+}
+else version (Solaris)
+{
+    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+}
+else version( CRuntime_Bionic )
+{
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Priority (TPI|TPP)
+//
+/*
+PTHREAD_PRIO_INHERIT (TPI)
+PTHREAD_PRIO_NONE (TPP|TPI)
+PTHREAD_PRIO_PROTECT (TPI)
+
+int pthread_mutex_getprioceiling(in pthread_mutex_t*, int*); (TPP)
+int pthread_mutex_setprioceiling(pthread_mutex_t*, int, int*); (TPP)
+int pthread_mutexattr_getprioceiling(pthread_mutexattr_t*, int*); (TPP)
+int pthread_mutexattr_getprotocol(in pthread_mutexattr_t*, int*); (TPI|TPP)
+int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int); (TPP)
+int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int); (TPI|TPP)
+*/
+version( OSX )
+{
+    enum
+    {
+        PTHREAD_PRIO_NONE,
+        PTHREAD_PRIO_INHERIT,
+        PTHREAD_PRIO_PROTECT
+    }
+
+    int pthread_mutex_getprioceiling(in pthread_mutex_t*, int*);
+    int pthread_mutex_setprioceiling(pthread_mutex_t*, int, int*);
+    int pthread_mutexattr_getprioceiling(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getprotocol(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int);
+    int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int);
+}
+else version( Solaris )
+{
+    enum
+    {
+        PTHREAD_PRIO_NONE    = 0x00,
+        PTHREAD_PRIO_INHERIT = 0x10,
+        PTHREAD_PRIO_PROTECT = 0x20,
+    }
+
+    int pthread_mutex_getprioceiling(in pthread_mutex_t*, int*);
+    int pthread_mutex_setprioceiling(pthread_mutex_t*, int, int*);
+    int pthread_mutexattr_getprioceiling(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getprotocol(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int);
+    int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int);
+}
+
+//
+// Scheduling (TPS)
+//
+/*
+PTHREAD_SCOPE_PROCESS
+PTHREAD_SCOPE_SYSTEM
+
+int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
+int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
+int pthread_attr_getscope(in pthread_attr_t*, int*);
+int pthread_attr_setinheritsched(pthread_attr_t*, int);
+int pthread_attr_setschedpolicy(pthread_attr_t*, int);
+int pthread_attr_setscope(pthread_attr_t*, int);
+int pthread_getschedparam(pthread_t, int*, sched_param*);
+int pthread_setschedparam(pthread_t, int, in sched_param*);
+int pthread_setschedprio(pthread_t, int);
+*/
+
+version( CRuntime_Glibc )
+{
+    enum
+    {
+        PTHREAD_SCOPE_SYSTEM,
+        PTHREAD_SCOPE_PROCESS
+    }
+
+    int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
+    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
+    int pthread_attr_getscope(in pthread_attr_t*, int*);
+    int pthread_attr_setinheritsched(pthread_attr_t*, int);
+    int pthread_attr_setschedpolicy(pthread_attr_t*, int);
+    int pthread_attr_setscope(pthread_attr_t*, int);
+    int pthread_getschedparam(pthread_t, int*, sched_param*);
+    int pthread_setschedparam(pthread_t, int, in sched_param*);
+    int pthread_setschedprio(pthread_t, int);
+}
+else version( OSX )
+{
+    enum
+    {
+        PTHREAD_SCOPE_SYSTEM    = 1,
+        PTHREAD_SCOPE_PROCESS   = 2
+    }
+
+    int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
+    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
+    int pthread_attr_getscope(in pthread_attr_t*, int*);
+    int pthread_attr_setinheritsched(pthread_attr_t*, int);
+    int pthread_attr_setschedpolicy(pthread_attr_t*, int);
+    int pthread_attr_setscope(pthread_attr_t*, int);
+    int pthread_getschedparam(pthread_t, int*, sched_param*);
+    int pthread_setschedparam(pthread_t, int, in sched_param*);
+    // int pthread_setschedprio(pthread_t, int); // not implemented
+}
+else version( FreeBSD )
+{
+    enum
+    {
+        PTHREAD_SCOPE_PROCESS   = 0,
+        PTHREAD_SCOPE_SYSTEM    = 0x2
+    }
+
+    int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
+    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
+    int pthread_attr_getscope(in pthread_attr_t*, int*);
+    int pthread_attr_setinheritsched(pthread_attr_t*, int);
+    int pthread_attr_setschedpolicy(pthread_attr_t*, int);
+    int pthread_attr_setscope(in pthread_attr_t*, int);
+    int pthread_getschedparam(pthread_t, int*, sched_param*);
+    int pthread_setschedparam(pthread_t, int, sched_param*);
+    // int pthread_setschedprio(pthread_t, int); // not implemented
+}
+else version (Solaris)
+{
+    enum
+    {
+        PTHREAD_SCOPE_PROCESS = 0,
+        PTHREAD_SCOPE_SYSTEM = 1,
+    }
+
+    int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
+    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
+    int pthread_attr_getscope(in pthread_attr_t*, int*);
+    int pthread_attr_setinheritsched(pthread_attr_t*, int);
+    int pthread_attr_setschedpolicy(pthread_attr_t*, int);
+    int pthread_attr_setscope(in pthread_attr_t*, int);
+    int pthread_getschedparam(pthread_t, int*, sched_param*);
+    int pthread_setschedparam(pthread_t, int, sched_param*);
+    int pthread_setschedprio(pthread_t, int);
+}
+else version (CRuntime_Bionic)
+{
+    enum
+    {
+        PTHREAD_SCOPE_SYSTEM,
+        PTHREAD_SCOPE_PROCESS
+    }
+
+    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
+    int pthread_attr_getscope(in pthread_attr_t*);
+    int pthread_attr_setschedpolicy(pthread_attr_t*, int);
+    int pthread_attr_setscope(pthread_attr_t*, int);
+    int pthread_getschedparam(pthread_t, int*, sched_param*);
+    int pthread_setschedparam(pthread_t, int, in sched_param*);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Stack (TSA|TSS)
+//
+/*
+int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*); (TSA|TSS)
+int pthread_attr_getstackaddr(in pthread_attr_t*, void**); (TSA)
+int pthread_attr_getstacksize(in pthread_attr_t*, size_t*); (TSS)
+int pthread_attr_setstack(pthread_attr_t*, void*, size_t); (TSA|TSS)
+int pthread_attr_setstackaddr(pthread_attr_t*, void*); (TSA)
+int pthread_attr_setstacksize(pthread_attr_t*, size_t); (TSS)
+*/
+
+version( CRuntime_Glibc )
+{
+    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
+    int pthread_attr_setstackaddr(pthread_attr_t*, void*);
+    int pthread_attr_setstacksize(pthread_attr_t*, size_t);
+}
+else version( OSX )
+{
+    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
+    int pthread_attr_setstackaddr(pthread_attr_t*, void*);
+    int pthread_attr_setstacksize(pthread_attr_t*, size_t);
+}
+else version( FreeBSD )
+{
+    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
+    int pthread_attr_setstackaddr(pthread_attr_t*, void*);
+    int pthread_attr_setstacksize(pthread_attr_t*, size_t);
+}
+else version (Solaris)
+{
+    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
+    int pthread_attr_setstackaddr(pthread_attr_t*, void*);
+    int pthread_attr_setstacksize(pthread_attr_t*, size_t);
+}
+else version (CRuntime_Bionic)
+{
+    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
+    int pthread_attr_setstackaddr(pthread_attr_t*, void*);
+    int pthread_attr_setstacksize(pthread_attr_t*, size_t);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Shared Synchronization (TSH)
+//
+/*
+int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+int pthread_condattr_setpshared(pthread_condattr_t*, int);
+int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
+int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
+*/
+
+version (CRuntime_Glibc)
+{
+    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+    int pthread_condattr_setpshared(pthread_condattr_t*, int);
+    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
+    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
+}
+else version( FreeBSD )
+{
+    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+    int pthread_condattr_setpshared(pthread_condattr_t*, int);
+    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
+    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
+}
+else version( OSX )
+{
+    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+    int pthread_condattr_setpshared(pthread_condattr_t*, int);
+    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
+    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
+}
+else version (Solaris)
+{
+    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+    int pthread_condattr_setpshared(pthread_condattr_t*, int);
+    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
+    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
+}
+else version (CRuntime_Bionic)
+{
+    int pthread_condattr_getpshared(pthread_condattr_t*, int*);
+    int pthread_condattr_setpshared(pthread_condattr_t*, int);
+    int pthread_mutexattr_getpshared(pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
+    int pthread_rwlockattr_getpshared(pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/pwd.d b/libphobos/libdruntime/core/sys/posix/pwd.d
new file mode 100644
index 00000000000..69dcd3021f8
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/pwd.d
@@ -0,0 +1,199 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.pwd;
+
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types; // for gid_t, uid_t
+
+version (Posix):
+extern (C):
+nothrow:
+@nogc:
+
+//
+// Required
+//
+/*
+struct passwd
+{
+    char*   pw_name;
+    uid_t   pw_uid;
+    gid_t   pw_gid;
+    char*   pw_dir;
+    char*   pw_shell;
+}
+
+passwd* getpwnam(in char*);
+passwd* getpwuid(uid_t);
+*/
+
+version( CRuntime_Glibc )
+{
+    struct passwd
+    {
+        char*   pw_name;
+        char*   pw_passwd;
+        uid_t   pw_uid;
+        gid_t   pw_gid;
+        char*   pw_gecos;
+        char*   pw_dir;
+        char*   pw_shell;
+    }
+}
+else version( OSX )
+{
+    struct passwd
+    {
+        char*   pw_name;
+        char*   pw_passwd;
+        uid_t   pw_uid;
+        gid_t   pw_gid;
+        time_t  pw_change;
+        char*   pw_class;
+        char*   pw_gecos;
+        char*   pw_dir;
+        char*   pw_shell;
+        time_t  pw_expire;
+    }
+}
+else version( FreeBSD )
+{
+    struct passwd
+    {
+        char*   pw_name;        /* user name */
+        char*   pw_passwd;      /* encrypted password */
+        uid_t   pw_uid;         /* user uid */
+        gid_t   pw_gid;         /* user gid */
+        time_t  pw_change;      /* password change time */
+        char*   pw_class;       /* user access class */
+        char*   pw_gecos;       /* Honeywell login info */
+        char*   pw_dir;     /* home directory */
+        char*   pw_shell;       /* default shell */
+        time_t  pw_expire;      /* account expiration */
+        int pw_fields;      /* internal: fields filled in */
+    }
+}
+else version (Solaris)
+{
+    struct passwd
+    {
+        char* pw_name;
+        char* pw_passwd;
+        uid_t pw_uid;
+        gid_t pw_gid;
+        char* pw_age;
+        char* pw_comment;
+        char* pw_gecos;
+        char* pw_dir;
+        char* pw_shell;
+    }
+}
+else version( CRuntime_Bionic )
+{
+    struct passwd
+    {
+        char*   pw_name;
+        char*   pw_passwd;
+        uid_t   pw_uid;
+        gid_t   pw_gid;
+        char*   pw_dir;
+        char*   pw_shell;
+    }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+passwd* getpwnam(in char*);
+passwd* getpwuid(uid_t);
+
+//
+// Thread-Safe Functions (TSF)
+//
+/*
+int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
+*/
+
+version( CRuntime_Glibc )
+{
+    int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+    int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
+}
+else version( OSX )
+{
+    int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+    int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
+}
+else version( FreeBSD )
+{
+    int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+    int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
+}
+else version (Solaris)
+{
+    int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+    int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
+}
+else version( CRuntime_Bionic )
+{
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// XOpen (XSI)
+//
+/*
+void    endpwent();
+passwd* getpwent();
+void    setpwent();
+*/
+
+version( CRuntime_Glibc )
+{
+    void    endpwent();
+    passwd* getpwent();
+    void    setpwent();
+}
+else version ( OSX )
+{
+    void    endpwent();
+    passwd* getpwent();
+    void    setpwent();
+}
+else version ( FreeBSD )
+{
+    void    endpwent();
+    passwd* getpwent();
+    void    setpwent();
+}
+else version (Solaris)
+{
+    void endpwent();
+    passwd* getpwent();
+    void setpwent();
+}
+else version ( CRuntime_Bionic )
+{
+    void    endpwent();
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sched.d b/libphobos/libdruntime/core/sys/posix/sched.d
new file mode 100644
index 00000000000..4d7639d4da9
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sched.d
@@ -0,0 +1,202 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly,
+              Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.sched;
+
+private import core.sys.posix.config;
+public import core.sys.posix.time;
+public import core.sys.posix.sys.types;
+
+version (Posix):
+extern (C):
+nothrow:
+@nogc:
+
+//
+// Required
+//
+/*
+struct sched_param
+{
+    int sched_priority (THR)
+    int sched_ss_low_priority (SS|TSP)
+    struct timespec sched_ss_repl_period (SS|TSP)
+    struct timespec sched_ss_init_budget (SS|TSP)
+    int sched_ss_max_repl (SS|TSP)
+}
+
+SCHED_FIFO
+SCHED_RR
+SCHED_SPORADIC (SS|TSP)
+SCHED_OTHER
+
+int sched_getparam(pid_t, sched_param*);
+int sched_getscheduler(pid_t);
+int sched_setparam(pid_t, in sched_param*);
+int sched_setscheduler(pid_t, int, in sched_param*);
+*/
+
+version( CRuntime_Glibc )
+{
+    struct sched_param
+    {
+        int sched_priority;
+    }
+
+    enum SCHED_OTHER    = 0;
+    enum SCHED_FIFO     = 1;
+    enum SCHED_RR       = 2;
+    //SCHED_SPORADIC (SS|TSP)
+}
+else version( OSX )
+{
+    enum SCHED_OTHER    = 1;
+    enum SCHED_FIFO     = 4;
+    enum SCHED_RR       = 2;
+    //SCHED_SPORADIC (SS|TSP)
+
+    private enum __SCHED_PARAM_SIZE__ = 4;
+
+    struct sched_param
+    {
+        int                             sched_priority;
+        byte[__PTHREAD_MUTEX_SIZE__]    __opaque;
+    }
+}
+else version( FreeBSD )
+{
+    struct sched_param
+    {
+        int sched_priority;
+    }
+
+    enum SCHED_FIFO     = 1;
+    enum SCHED_OTHER    = 2;
+    enum SCHED_RR       = 3;
+}
+else version (Solaris)
+{
+    struct sched_param
+    {
+        int sched_priority;
+        int[8] sched_pad;
+    }
+
+    enum SCHED_OTHER = 0;
+    enum SCHED_FIFO = 1;
+    enum SCHED_RR = 2;
+    enum SCHED_SYS = 3;
+    enum SCHED_IA = 4;
+    enum SCHED_FSS = 5;
+    enum SCHED_FX = 6;
+    enum _SCHED_NEXT = 7;
+}
+else version( CRuntime_Bionic )
+{
+    struct sched_param
+    {
+        int sched_priority;
+    }
+
+    enum SCHED_NORMAL   = 0;
+    enum SCHED_OTHER    = 0;
+    enum SCHED_FIFO     = 1;
+    enum SCHED_RR       = 2;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+int sched_getparam(pid_t, sched_param*);
+int sched_getscheduler(pid_t);
+int sched_setparam(pid_t, in sched_param*);
+int sched_setscheduler(pid_t, int, in sched_param*);
+
+//
+// Thread (THR)
+//
+/*
+int sched_yield();
+*/
+
+version( CRuntime_Glibc )
+{
+    int sched_yield();
+}
+else version( OSX )
+{
+    int sched_yield();
+}
+else version( FreeBSD )
+{
+    int sched_yield();
+}
+else version (Solaris)
+{
+    int sched_yield();
+}
+else version (CRuntime_Bionic)
+{
+    int sched_yield();
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Scheduling (TPS)
+//
+/*
+int sched_get_priority_max(int);
+int sched_get_priority_min(int);
+int sched_rr_get_interval(pid_t, timespec*);
+*/
+
+version( CRuntime_Glibc )
+{
+    int sched_get_priority_max(int);
+    int sched_get_priority_min(int);
+    int sched_rr_get_interval(pid_t, timespec*);
+}
+else version( OSX )
+{
+    int sched_get_priority_min(int);
+    int sched_get_priority_max(int);
+    //int sched_rr_get_interval(pid_t, timespec*); // FIXME: unavailable?
+}
+else version( FreeBSD )
+{
+    int sched_get_priority_min(int);
+    int sched_get_priority_max(int);
+    int sched_rr_get_interval(pid_t, timespec*);
+}
+else version (Solaris)
+{
+    int sched_get_priority_max(int);
+    int sched_get_priority_min(int);
+    int sched_rr_get_interval(pid_t, timespec*);
+}
+else version (CRuntime_Bionic)
+{
+    int sched_get_priority_max(int);
+    int sched_get_priority_min(int);
+    int sched_rr_get_interval(pid_t, timespec*);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/semaphore.d b/libphobos/libdruntime/core/sys/posix/semaphore.d
new file mode 100644
index 00000000000..2ce8f30f2c3
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/semaphore.d
@@ -0,0 +1,151 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.semaphore;
+
+private import core.sys.posix.config;
+private import core.sys.posix.time;
+
+version (Posix):
+extern (C):
+nothrow:
+@nogc:
+
+//
+// Required
+//
+/*
+sem_t
+SEM_FAILED
+
+int sem_close(sem_t*);
+int sem_destroy(sem_t*);
+int sem_getvalue(sem_t*, int*);
+int sem_init(sem_t*, int, uint);
+sem_t* sem_open(in char*, int, ...);
+int sem_post(sem_t*);
+int sem_trywait(sem_t*);
+int sem_unlink(in char*);
+int sem_wait(sem_t*);
+*/
+
+version( CRuntime_Glibc )
+{
+    private alias int __atomic_lock_t;
+
+    private struct _pthread_fastlock
+    {
+      c_long            __status;
+      __atomic_lock_t   __spinlock;
+    }
+
+    struct sem_t
+    {
+      _pthread_fastlock __sem_lock;
+      int               __sem_value;
+      void*             __sem_waiting;
+    }
+
+    enum SEM_FAILED = cast(sem_t*) null;
+}
+else version( OSX )
+{
+    alias int sem_t;
+
+    enum SEM_FAILED = cast(sem_t*) null;
+}
+else version( FreeBSD )
+{
+    // FBSD-9.0 definition
+    struct sem_t
+    {
+        uint _magic;
+        struct _usem
+        {
+            shared uint _has_waiters;
+            shared uint _count;
+            uint _flags;
+        } _usem _kern;
+    }
+
+    enum SEM_FAILED = cast(sem_t*) null;
+}
+else version (Solaris)
+{
+    struct sem_t
+    {
+        uint sem_count;
+        ushort sem_type;
+        ushort sem_magic;
+        ulong[3] sem_pad1;
+        ulong[2] sem_pad2;
+    }
+
+    enum SEM_FAILED = cast(sem_t*)-1;
+}
+else version( CRuntime_Bionic )
+{
+    struct sem_t
+    {
+        uint count; //volatile
+    }
+
+    enum SEM_FAILED = null;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+int sem_close(sem_t*);
+int sem_destroy(sem_t*);
+int sem_getvalue(sem_t*, int*);
+int sem_init(sem_t*, int, uint);
+sem_t* sem_open(in char*, int, ...);
+int sem_post(sem_t*);
+int sem_trywait(sem_t*);
+int sem_unlink(in char*);
+int sem_wait(sem_t*);
+
+//
+// Timeouts (TMO)
+//
+/*
+int sem_timedwait(sem_t*, in timespec*);
+*/
+
+version( CRuntime_Glibc )
+{
+    int sem_timedwait(sem_t*, in timespec*);
+}
+else version( OSX )
+{
+    int sem_timedwait(sem_t*, in timespec*);
+}
+else version( FreeBSD )
+{
+    int sem_timedwait(sem_t*, in timespec*);
+}
+else version (Solaris)
+{
+    int sem_timedwait(sem_t*, in timespec*);
+}
+else version( CRuntime_Bionic )
+{
+    int sem_timedwait(sem_t*, in timespec*);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/setjmp.d b/libphobos/libdruntime/core/sys/posix/setjmp.d
new file mode 100644
index 00000000000..e5758c524b3
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/setjmp.d
@@ -0,0 +1,271 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.setjmp;
+
+private import core.sys.posix.config;
+private import core.sys.posix.signal; // for sigset_t
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// Required
+//
+/*
+jmp_buf
+
+int  setjmp(ref jmp_buf);
+void longjmp(ref jmp_buf, int);
+*/
+
+version( CRuntime_Glibc )
+{
+    version( X86_64 )
+    {
+        //enum JB_BX      = 0;
+        //enum JB_BP      = 1;
+        //enum JB_12      = 2;
+        //enum JB_13      = 3;
+        //enum JB_14      = 4;
+        //enum JB_15      = 5;
+        //enum JB_SP      = 6;
+        //enum JB_PC      = 7;
+        //enum JB_SIZE    = 64;
+
+        alias long[8] __jmp_buf;
+    }
+    else version( X86 )
+    {
+        //enum JB_BX      = 0;
+        //enum JB_SI      = 1;
+        //enum JB_DI      = 2;
+        //enum JB_BP      = 3;
+        //enum JB_SP      = 4;
+        //enum JB_PC      = 5;
+        //enum JB_SIZE    = 24;
+
+        alias int[6] __jmp_buf;
+    }
+    else version ( SPARC )
+    {
+        alias int[3] __jmp_buf;
+    }
+    else version (AArch64)
+    {
+        alias long[22] __jmp_buf;
+    }
+    else version (ARM)
+    {
+        alias int[64] __jmp_buf;
+    }
+    else version (PPC)
+    {
+        alias int[64 + (12*4)] __jmp_buf;
+    }
+    else version (PPC64)
+    {
+        alias long[64] __jmp_buf;
+    }
+    else version (MIPS)
+    {
+        struct __jmp_buf
+        {
+            version (MIPS_O32)
+            {
+                void * __pc;
+                void * __sp;
+                int[8] __regs;
+                void * __fp;
+                void * __gp;
+            }
+            else
+            {
+                long __pc;
+                long __sp;
+                long[8] __regs;
+                long __fp;
+                long __gp;
+            }
+            int __fpc_csr;
+            version (MIPS_N64)
+                double[8] __fpregs;
+            else
+                double[6] __fpregs;
+        }
+    }
+    else version (MIPS64)
+    {
+        struct __jmp_buf
+        {
+            long __pc;
+            long __sp;
+            long[8] __regs;
+            long __fp;
+            long __gp;
+            int __fpc_csr;
+            version (MIPS_N64)
+                double[8] __fpregs;
+            else
+                double[6] __fpregs;
+        }
+    }
+    else version (SystemZ)
+    {
+        struct __s390_jmp_buf
+        {
+            c_long[10] __gregs;
+            c_long[8] __fpregs;
+        }
+        alias __jmp_buf = __s390_jmp_buf[1];
+    }
+    else
+        static assert(0, "unimplemented");
+
+    struct __jmp_buf_tag
+    {
+        __jmp_buf   __jmpbuf;
+        int         __mask_was_saved;
+        sigset_t    __saved_mask;
+    }
+
+    alias __jmp_buf_tag[1] jmp_buf;
+
+    alias _setjmp setjmp; // see XOpen block
+    void longjmp(ref jmp_buf, int);
+}
+else version( FreeBSD )
+{
+    // <machine/setjmp.h>
+    version( X86 )
+    {
+        enum _JBLEN = 11;
+        struct _jmp_buf { int[_JBLEN + 1] _jb; }
+    }
+    else version( X86_64)
+    {
+        enum _JBLEN = 12;
+        struct _jmp_buf { c_long[_JBLEN] _jb; }
+    }
+    else version( SPARC )
+    {
+        enum _JBLEN = 5;
+        struct _jmp_buf { c_long[_JBLEN + 1] _jb; }
+    }
+    else
+        static assert(0);
+    alias _jmp_buf[1] jmp_buf;
+
+    int  setjmp(ref jmp_buf);
+    void longjmp(ref jmp_buf, int);
+}
+else version( CRuntime_Bionic )
+{
+    // <machine/setjmp.h>
+    version( X86 )
+    {
+        enum _JBLEN = 10;
+    }
+    else version( ARM )
+    {
+        enum _JBLEN = 64;
+    }
+    else
+    {
+        static assert(false, "Architecture not supported.");
+    }
+
+    alias c_long[_JBLEN] jmp_buf;
+
+    int  setjmp(ref jmp_buf);
+    void longjmp(ref jmp_buf, int);
+}
+
+//
+// C Extension (CX)
+//
+/*
+sigjmp_buf
+
+int  sigsetjmp(sigjmp_buf, int);
+void siglongjmp(sigjmp_buf, int);
+*/
+
+version( CRuntime_Glibc )
+{
+    alias jmp_buf sigjmp_buf;
+
+    int __sigsetjmp(sigjmp_buf, int);
+    alias __sigsetjmp sigsetjmp;
+    void siglongjmp(sigjmp_buf, int);
+}
+else version( FreeBSD )
+{
+    // <machine/setjmp.h>
+    version( X86 )
+    {
+        struct _sigjmp_buf { int[_JBLEN + 1] _ssjb; }
+    }
+    else version( X86_64)
+    {
+        struct _sigjmp_buf { c_long[_JBLEN] _sjb; }
+    }
+    else version( SPARC )
+    {
+        enum _JBLEN         = 5;
+        enum _JB_FP         = 0;
+        enum _JB_PC         = 1;
+        enum _JB_SP         = 2;
+        enum _JB_SIGMASK    = 3;
+        enum _JB_SIGFLAG    = 5;
+        struct _sigjmp_buf { c_long[_JBLEN + 1] _sjb; }
+    }
+    else
+        static assert(0);
+    alias _sigjmp_buf[1] sigjmp_buf;
+
+    int  sigsetjmp(ref sigjmp_buf);
+    void siglongjmp(ref sigjmp_buf, int);
+}
+else version( CRuntime_Bionic )
+{
+    alias c_long[_JBLEN + 1] sigjmp_buf;
+
+    int  sigsetjmp(ref sigjmp_buf, int);
+    void siglongjmp(ref sigjmp_buf, int);
+}
+
+//
+// XOpen (XSI)
+//
+/*
+int  _setjmp(jmp_buf);
+void _longjmp(jmp_buf, int);
+*/
+
+version( CRuntime_Glibc )
+{
+    int  _setjmp(ref jmp_buf);
+    void _longjmp(ref jmp_buf, int);
+}
+else version( FreeBSD )
+{
+    int  _setjmp(ref jmp_buf);
+    void _longjmp(ref jmp_buf, int);
+}
+else version( CRuntime_Bionic )
+{
+    int  _setjmp(ref jmp_buf);
+    void _longjmp(ref jmp_buf, int);
+}
diff --git a/libphobos/libdruntime/core/sys/posix/signal.d b/libphobos/libdruntime/core/sys/posix/signal.d
new file mode 100644
index 00000000000..4495c77d534
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/signal.d
@@ -0,0 +1,2143 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Sean Kelly,
+              Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ * Source:    $(DRUNTIMESRC core/sys/posix/_signal.d)
+ */
+
+module core.sys.posix.signal;
+
+private import core.sys.posix.config;
+public import core.stdc.signal;
+public import core.sys.posix.sys.types; // for pid_t
+//public import core.sys.posix.time;      // for timespec, now defined here
+
+version (Posix):
+extern (C):
+//nothrow:  // this causes Issue 12738
+
+//
+// Required
+//
+/*
+SIG_DFL (defined in core.stdc.signal)
+SIG_ERR (defined in core.stdc.signal)
+SIG_IGN (defined in core.stdc.signal)
+
+sig_atomic_t (defined in core.stdc.signal)
+
+SIGEV_NONE
+SIGEV_SIGNAL
+SIGEV_THREAD
+
+union sigval
+{
+    int   sival_int;
+    void* sival_ptr;
+}
+
+SIGRTMIN
+SIGRTMAX
+
+SIGABRT (defined in core.stdc.signal)
+SIGALRM
+SIGBUS
+SIGCHLD
+SIGCONT
+SIGFPE (defined in core.stdc.signal)
+SIGHUP
+SIGILL (defined in core.stdc.signal)
+SIGINT (defined in core.stdc.signal)
+SIGKILL
+SIGPIPE
+SIGQUIT
+SIGSEGV (defined in core.stdc.signal)
+SIGSTOP
+SIGTERM (defined in core.stdc.signal)
+SIGTSTP
+SIGTTIN
+SIGTTOU
+SIGUSR1
+SIGUSR2
+SIGURG
+
+struct sigaction_t
+{
+    sigfn_t     sa_handler;
+    sigset_t    sa_mask;
+    sigactfn_t  sa_sigaction;
+}
+
+sigfn_t signal(int sig, sigfn_t func); (defined in core.stdc.signal)
+int raise(int sig);                    (defined in core.stdc.signal)
+*/
+
+//SIG_DFL (defined in core.stdc.signal)
+//SIG_ERR (defined in core.stdc.signal)
+//SIG_IGN (defined in core.stdc.signal)
+
+//sig_atomic_t (defined in core.stdc.signal)
+
+private alias void function(int) sigfn_t;
+private alias void function(int, siginfo_t*, void*) sigactfn_t;
+
+// nothrow versions
+nothrow @nogc
+{
+    private alias void function(int) sigfn_t2;
+    private alias void function(int, siginfo_t*, void*) sigactfn_t2;
+}
+
+enum
+{
+  SIGEV_SIGNAL,
+  SIGEV_NONE,
+  SIGEV_THREAD
+}
+
+union sigval
+{
+    int     sival_int;
+    void*   sival_ptr;
+}
+
+version( Solaris )
+{
+    import core.sys.posix.unistd;
+
+    @property int SIGRTMIN() nothrow @nogc {
+        __gshared static int sig = -1;
+        if (sig == -1) {
+            sig = cast(int)sysconf(_SC_SIGRT_MIN);
+        }
+        return sig;
+    }
+
+    @property int SIGRTMAX() nothrow @nogc {
+        __gshared static int sig = -1;
+        if (sig == -1) {
+            sig = cast(int)sysconf(_SC_SIGRT_MAX);
+        }
+        return sig;
+    }
+}
+else version( CRuntime_Glibc )
+{
+    private extern (C) nothrow @nogc
+    {
+        int __libc_current_sigrtmin();
+        int __libc_current_sigrtmax();
+    }
+
+    @property int SIGRTMIN() nothrow @nogc {
+        __gshared static int sig = -1;
+        if (sig == -1) {
+            sig = __libc_current_sigrtmin();
+        }
+        return sig;
+    }
+
+    @property int SIGRTMAX() nothrow @nogc {
+        __gshared static int sig = -1;
+        if (sig == -1) {
+            sig = __libc_current_sigrtmax();
+        }
+        return sig;
+    }
+}
+else version (FreeBSD) {
+    // https://github.com/freebsd/freebsd/blob/e79c62ff68fc74d88cb6f479859f6fae9baa5101/sys/sys/signal.h#L117
+    enum SIGRTMIN = 65;
+    enum SIGRTMAX = 126;
+}
+// Note: it appears that FreeBSD (prior to 7) and OSX do not support realtime signals
+
+version( linux )
+{
+    version (X86)
+    {
+        //SIGABRT (defined in core.stdc.signal)
+        enum SIGALRM    = 14;
+        enum SIGBUS     = 7;
+        enum SIGCHLD    = 17;
+        enum SIGCONT    = 18;
+        //SIGFPE (defined in core.stdc.signal)
+        enum SIGHUP     = 1;
+        //SIGILL (defined in core.stdc.signal)
+        //SIGINT (defined in core.stdc.signal)
+        enum SIGKILL    = 9;
+        enum SIGPIPE    = 13;
+        enum SIGQUIT    = 3;
+        //SIGSEGV (defined in core.stdc.signal)
+        enum SIGSTOP    = 19;
+        //SIGTERM (defined in core.stdc.signal)
+        enum SIGTSTP    = 20;
+        enum SIGTTIN    = 21;
+        enum SIGTTOU    = 22;
+        enum SIGUSR1    = 10;
+        enum SIGUSR2    = 12;
+        enum SIGURG     = 23;
+    }
+    else version (X86_64)
+    {
+        //SIGABRT (defined in core.stdc.signal)
+        enum SIGALRM    = 14;
+        enum SIGBUS     = 7;
+        enum SIGCHLD    = 17;
+        enum SIGCONT    = 18;
+        //SIGFPE (defined in core.stdc.signal)
+        enum SIGHUP     = 1;
+        //SIGILL (defined in core.stdc.signal)
+        //SIGINT (defined in core.stdc.signal)
+        enum SIGKILL    = 9;
+        enum SIGPIPE    = 13;
+        enum SIGQUIT    = 3;
+        //SIGSEGV (defined in core.stdc.signal)
+        enum SIGSTOP    = 19;
+        //SIGTERM (defined in core.stdc.signal)
+        enum SIGTSTP    = 20;
+        enum SIGTTIN    = 21;
+        enum SIGTTOU    = 22;
+        enum SIGUSR1    = 10;
+        enum SIGUSR2    = 12;
+        enum SIGURG     = 23;
+    }
+    else version (MIPS32)
+    {
+        //SIGABRT (defined in core.stdc.signal)
+        enum SIGALRM    = 14;
+        enum SIGBUS     = 10;
+        enum SIGCHLD    = 18;
+        enum SIGCONT    = 25;
+        //SIGFPE (defined in core.stdc.signal)
+        enum SIGHUP     = 1;
+        //SIGILL (defined in core.stdc.signal)
+        //SIGINT (defined in core.stdc.signal)
+        enum SIGKILL    = 9;
+        enum SIGPIPE    = 13;
+        enum SIGQUIT    = 3;
+        //SIGSEGV (defined in core.stdc.signal)
+        enum SIGSTOP    = 23;
+        //SIGTERM (defined in core.stdc.signal)
+        enum SIGTSTP    = 24;
+        enum SIGTTIN    = 26;
+        enum SIGTTOU    = 27;
+        enum SIGUSR1    = 16;
+        enum SIGUSR2    = 17;
+        enum SIGURG     = 21;
+    }
+    else version (MIPS64)
+    {
+        //SIGABRT (defined in core.stdc.signal)
+        enum SIGALRM    = 14;
+        enum SIGBUS     = 10;
+        enum SIGCHLD    = 18;
+        enum SIGCONT    = 25;
+        //SIGFPE (defined in core.stdc.signal)
+        enum SIGHUP     = 1;
+        //SIGILL (defined in core.stdc.signal)
+        //SIGINT (defined in core.stdc.signal)
+        enum SIGKILL    = 9;
+        enum SIGPIPE    = 13;
+        enum SIGQUIT    = 3;
+        //SIGSEGV (defined in core.stdc.signal)
+        enum SIGSTOP    = 23;
+        //SIGTERM (defined in core.stdc.signal)
+        enum SIGTSTP    = 24;
+        enum SIGTTIN    = 26;
+        enum SIGTTOU    = 27;
+        enum SIGUSR1    = 16;
+        enum SIGUSR2    = 17;
+        enum SIGURG     = 21;
+    }
+    else version (PPC)
+    {
+        //SIGABRT (defined in core.stdc.signal)
+        enum SIGALRM    = 14;
+        enum SIGBUS     = 7;
+        enum SIGCHLD    = 17;
+        enum SIGCONT    = 18;
+        //SIGFPE (defined in core.stdc.signal)
+        enum SIGHUP     = 1;
+        //SIGILL (defined in core.stdc.signal)
+        //SIGINT (defined in core.stdc.signal)
+        enum SIGKILL    = 9;
+        enum SIGPIPE    = 13;
+        enum SIGQUIT    = 3;
+        //SIGSEGV (defined in core.stdc.signal)
+        enum SIGSTOP    = 19;
+        //SIGTERM (defined in core.stdc.signal)
+        enum SIGTSTP    = 20;
+        enum SIGTTIN    = 21;
+        enum SIGTTOU    = 22;
+        enum SIGUSR1    = 10;
+        enum SIGUSR2    = 12;
+        enum SIGURG     = 23;
+    }
+    else version (PPC64)
+    {
+        //SIGABRT (defined in core.stdc.signal)
+        enum SIGALRM    = 14;
+        enum SIGBUS     = 7;
+        enum SIGCHLD    = 17;
+        enum SIGCONT    = 18;
+        //SIGFPE (defined in core.stdc.signal)
+        enum SIGHUP     = 1;
+        //SIGILL (defined in core.stdc.signal)
+        //SIGINT (defined in core.stdc.signal)
+        enum SIGKILL    = 9;
+        enum SIGPIPE    = 13;
+        enum SIGQUIT    = 3;
+        //SIGSEGV (defined in core.stdc.signal)
+        enum SIGSTOP    = 19;
+        //SIGTERM (defined in core.stdc.signal)
+        enum SIGTSTP    = 20;
+        enum SIGTTIN    = 21;
+        enum SIGTTOU    = 22;
+        enum SIGUSR1    = 10;
+        enum SIGUSR2    = 12;
+        enum SIGURG     = 23;
+    }
+    else version (ARM)
+    {
+        //SIGABRT (defined in core.stdc.signal)
+        enum SIGALRM    = 14;
+        enum SIGBUS     = 7;
+        enum SIGCHLD    = 17;
+        enum SIGCONT    = 18;
+        //SIGFPE (defined in core.stdc.signal)
+        enum SIGHUP     = 1;
+        //SIGILL (defined in core.stdc.signal)
+        //SIGINT (defined in core.stdc.signal)
+        enum SIGKILL    = 9;
+        enum SIGPIPE    = 13;
+        enum SIGQUIT    = 3;
+        //SIGSEGV (defined in core.stdc.signal)
+        enum SIGSTOP    = 19;
+        //SIGTERM (defined in core.stdc.signal)
+        enum SIGTSTP    = 20;
+        enum SIGTTIN    = 21;
+        enum SIGTTOU    = 22;
+        enum SIGUSR1    = 10;
+        enum SIGUSR2    = 12;
+        enum SIGURG     = 23;
+    }
+    else version (AArch64)
+    {
+        //SIGABRT (defined in core.stdc.signal)
+        enum SIGALRM    = 14;
+        enum SIGBUS     = 7;
+        enum SIGCHLD    = 17;
+        enum SIGCONT    = 18;
+        //SIGFPE (defined in core.stdc.signal)
+        enum SIGHUP     = 1;
+        //SIGILL (defined in core.stdc.signal)
+        //SIGINT (defined in core.stdc.signal)
+        enum SIGKILL    = 9;
+        enum SIGPIPE    = 13;
+        enum SIGQUIT    = 3;
+        //SIGSEGV (defined in core.stdc.signal)
+        enum SIGSTOP    = 19;
+        //SIGTERM (defined in core.stdc.signal)
+        enum SIGTSTP    = 20;
+        enum SIGTTIN    = 21;
+        enum SIGTTOU    = 22;
+        enum SIGUSR1    = 10;
+        enum SIGUSR2    = 12;
+        enum SIGURG     = 23;
+    }
+    else version (SystemZ)
+    {
+        //SIGABRT (defined in core.stdc.signal)
+        enum SIGALRM    = 14;
+        enum SIGBUS     = 7;
+        enum SIGCHLD    = 17;
+        enum SIGCONT    = 18;
+        //SIGFPE (defined in core.stdc.signal)
+        enum SIGHUP     = 1;
+        //SIGILL (defined in core.stdc.signal)
+        //SIGINT (defined in core.stdc.signal)
+        enum SIGKILL    = 9;
+        enum SIGPIPE    = 13;
+        enum SIGQUIT    = 3;
+        //SIGSEGV (defined in core.stdc.signal)
+        enum SIGSTOP    = 19;
+        //SIGTERM (defined in core.stdc.signal)
+        enum SIGTSTP    = 20;
+        enum SIGTTIN    = 21;
+        enum SIGTTOU    = 22;
+        enum SIGUSR1    = 10;
+        enum SIGUSR2    = 12;
+        enum SIGURG     = 23;
+    }
+    else
+        static assert(0, "unimplemented");
+}
+else version( OSX )
+{
+    //SIGABRT (defined in core.stdc.signal)
+    enum SIGALRM    = 14;
+    enum SIGBUS     = 10;
+    enum SIGCHLD    = 20;
+    enum SIGCONT    = 19;
+    //SIGFPE (defined in core.stdc.signal)
+    enum SIGHUP     = 1;
+    //SIGILL (defined in core.stdc.signal)
+    //SIGINT (defined in core.stdc.signal)
+    enum SIGKILL    = 9;
+    enum SIGPIPE    = 13;
+    enum SIGQUIT    = 3;
+    //SIGSEGV (defined in core.stdc.signal)
+    enum SIGSTOP    = 17;
+    //SIGTERM (defined in core.stdc.signal)
+    enum SIGTSTP    = 18;
+    enum SIGTTIN    = 21;
+    enum SIGTTOU    = 22;
+    enum SIGUSR1    = 30;
+    enum SIGUSR2    = 31;
+    enum SIGURG     = 16;
+}
+else version( FreeBSD )
+{
+    //SIGABRT (defined in core.stdc.signal)
+    enum SIGALRM    = 14;
+    enum SIGBUS     = 10;
+    enum SIGCHLD    = 20;
+    enum SIGCONT    = 19;
+    //SIGFPE (defined in core.stdc.signal)
+    enum SIGHUP     = 1;
+    //SIGILL (defined in core.stdc.signal)
+    //SIGINT (defined in core.stdc.signal)
+    enum SIGKILL    = 9;
+    enum SIGPIPE    = 13;
+    enum SIGQUIT    = 3;
+    //SIGSEGV (defined in core.stdc.signal)
+    enum SIGSTOP    = 17;
+    //SIGTERM (defined in core.stdc.signal)
+    enum SIGTSTP    = 18;
+    enum SIGTTIN    = 21;
+    enum SIGTTOU    = 22;
+    enum SIGUSR1    = 30;
+    enum SIGUSR2    = 31;
+    enum SIGURG     = 16;
+}
+else version (Solaris)
+{
+    enum SIGALRM = 14;
+    enum SIGBUS = 10;
+    enum SIGCHLD = 18;
+    enum SIGCONT = 25;
+    enum SIGHUP = 1;
+    enum SIGKILL = 9;
+    enum SIGPIPE = 13;
+    enum SIGQUIT = 3;
+    enum SIGSTOP = 23;
+    enum SIGTSTP = 24;
+    enum SIGTTIN = 26;
+    enum SIGTTOU = 27;
+    enum SIGUSR1 = 16;
+    enum SIGUSR2 = 17;
+    enum SIGURG = 21;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+version( CRuntime_Glibc )
+{
+    struct sigaction_t
+    {
+        static if( true /* __USE_POSIX199309 */ )
+        {
+            union
+            {
+                sigfn_t     sa_handler;
+                sigactfn_t  sa_sigaction;
+            }
+        }
+        else
+        {
+            sigfn_t     sa_handler;
+        }
+        sigset_t        sa_mask;
+        int             sa_flags;
+
+        void function() sa_restorer;
+    }
+}
+else version( FreeBSD )
+{
+    struct sigaction_t
+    {
+        union
+        {
+            sigfn_t     sa_handler;
+            sigactfn_t  sa_sigaction;
+        }
+        int      sa_flags;
+        sigset_t sa_mask;
+    }
+}
+else version (Solaris)
+{
+    struct sigaction_t
+    {
+        int sa_flags;
+
+        union
+        {
+            sigfn_t sa_handler;
+            sigactfn_t sa_sigaction;
+        }
+
+        sigset_t sa_mask;
+        version (D_LP64) {}
+        else
+            int[2] sa_resv;
+    }
+}
+else version (linux)
+{
+    version (X86)
+    {
+        struct sigaction_t
+        {
+            union
+            {
+                sigfn_t    sa_handler;
+                sigactfn_t sa_sigaction;
+            }
+
+            sigset_t        sa_mask;
+            c_ulong         sa_flags;
+            void function() sa_restorer;
+        }
+    }
+    else version (ARM)
+    {
+        struct sigaction_t
+        {
+            union
+            {
+                sigfn_t    sa_handler;
+                sigactfn_t sa_sigaction;
+            }
+
+            sigset_t        sa_mask;
+            c_ulong         sa_flags;
+            void function() sa_restorer;
+        }
+    }
+    else
+    {
+        static assert(false, "Architecture not supported.");
+    }
+}
+else version( OSX )
+{
+    struct sigaction_t
+    {
+        static if( true /* __USE_POSIX199309 */ )
+        {
+            union
+            {
+                sigfn_t     sa_handler;
+                sigactfn_t  sa_sigaction;
+            }
+        }
+        else
+        {
+            sigfn_t     sa_handler;
+        }
+        sigset_t        sa_mask;
+        int             sa_flags;
+    }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// C Extension (CX)
+//
+/*
+SIG_HOLD
+
+sigset_t
+pid_t   (defined in core.sys.types)
+
+SIGABRT (defined in core.stdc.signal)
+SIGFPE  (defined in core.stdc.signal)
+SIGILL  (defined in core.stdc.signal)
+SIGINT  (defined in core.stdc.signal)
+SIGSEGV (defined in core.stdc.signal)
+SIGTERM (defined in core.stdc.signal)
+
+SA_NOCLDSTOP (CX|XSI)
+SIG_BLOCK
+SIG_UNBLOCK
+SIG_SETMASK
+
+struct siginfo_t
+{
+    int     si_signo;
+    int     si_code;
+
+    version( XSI )
+    {
+        int     si_errno;
+        pid_t   si_pid;
+        uid_t   si_uid;
+        void*   si_addr;
+        int     si_status;
+        c_long  si_band;
+    }
+    version( RTS )
+    {
+        sigval  si_value;
+    }
+}
+
+SI_USER
+SI_QUEUE
+SI_TIMER
+SI_ASYNCIO
+SI_MESGQ
+
+int kill(pid_t, int);
+int sigaction(int, in sigaction_t*, sigaction_t*);
+int sigaddset(sigset_t*, int);
+int sigdelset(sigset_t*, int);
+int sigemptyset(sigset_t*);
+int sigfillset(sigset_t*);
+int sigismember(in sigset_t*, int);
+int sigpending(sigset_t*);
+int sigprocmask(int, in sigset_t*, sigset_t*);
+int sigsuspend(in sigset_t*);
+int sigwait(in sigset_t*, int*);
+*/
+
+nothrow @nogc
+{
+
+version( CRuntime_Glibc )
+{
+    enum SIG_HOLD = cast(sigfn_t2) 1;
+
+    private enum _SIGSET_NWORDS = 1024 / (8 * c_ulong.sizeof);
+
+    struct sigset_t
+    {
+        c_ulong[_SIGSET_NWORDS] __val;
+    }
+
+    // pid_t  (defined in core.sys.types)
+
+    //SIGABRT (defined in core.stdc.signal)
+    //SIGFPE  (defined in core.stdc.signal)
+    //SIGILL  (defined in core.stdc.signal)
+    //SIGINT  (defined in core.stdc.signal)
+    //SIGSEGV (defined in core.stdc.signal)
+    //SIGTERM (defined in core.stdc.signal)
+
+    enum SA_NOCLDSTOP   = 1; // (CX|XSI)
+
+    enum SIG_BLOCK      = 0;
+    enum SIG_UNBLOCK    = 1;
+    enum SIG_SETMASK    = 2;
+
+    private enum __SI_MAX_SIZE = 128;
+
+    static if( false /* __WORDSIZE == 64 */ )
+    {
+        private enum __SI_PAD_SIZE = ((__SI_MAX_SIZE / int.sizeof) - 4);
+    }
+    else
+    {
+        private enum __SI_PAD_SIZE = ((__SI_MAX_SIZE / int.sizeof) - 3);
+    }
+
+    struct siginfo_t
+    {
+        int si_signo;       // Signal number
+        int si_errno;       // If non-zero, an errno value associated with
+                            // this signal, as defined in <errno.h>
+        int si_code;        // Signal code
+
+        union _sifields_t
+        {
+            int[__SI_PAD_SIZE] _pad;
+
+            // kill()
+            struct _kill_t
+            {
+                pid_t si_pid; // Sending process ID
+                uid_t si_uid; // Real user ID of sending process
+            } _kill_t _kill;
+
+            // POSIX.1b timers.
+            struct _timer_t
+            {
+                int    si_tid;     // Timer ID
+                int    si_overrun; // Overrun count
+                sigval si_sigval;  // Signal value
+            } _timer_t _timer;
+
+            // POSIX.1b signals
+            struct _rt_t
+            {
+                pid_t  si_pid;    // Sending process ID
+                uid_t  si_uid;    // Real user ID of sending process
+                sigval si_sigval; // Signal value
+            } _rt_t _rt;
+
+            // SIGCHLD
+            struct _sigchild_t
+            {
+                pid_t   si_pid;    // Which child
+                uid_t   si_uid;    // Real user ID of sending process
+                int     si_status; // Exit value or signal
+                clock_t si_utime;
+                clock_t si_stime;
+            } _sigchild_t _sigchld;
+
+            // SIGILL, SIGFPE, SIGSEGV, SIGBUS
+            struct _sigfault_t
+            {
+                void*     si_addr;  // Faulting insn/memory ref
+            } _sigfault_t _sigfault;
+
+            // SIGPOLL
+            struct _sigpoll_t
+            {
+                c_long   si_band;   // Band event for SIGPOLL
+                int      si_fd;
+            } _sigpoll_t _sigpoll;
+        } _sifields_t _sifields;
+
+    nothrow @nogc:
+        @property ref pid_t si_pid() return { return _sifields._kill.si_pid; }
+        @property ref uid_t si_uid() return { return _sifields._kill.si_uid; }
+        @property ref void* si_addr() return { return _sifields._sigfault.si_addr; }
+        @property ref int si_status() return { return _sifields._sigchld.si_status; }
+        @property ref c_long si_band() return { return _sifields._sigpoll.si_band; }
+        @property ref sigval si_value() return { return _sifields._rt.si_sigval; }
+    }
+
+    enum
+    {
+        SI_ASYNCNL = -60,
+        SI_TKILL   = -6,
+        SI_SIGIO,
+        SI_ASYNCIO,
+        SI_MESGQ,
+        SI_TIMER,
+        SI_QUEUE,
+        SI_USER,
+        SI_KERNEL  = 0x80
+    }
+
+    int kill(pid_t, int);
+    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaddset(sigset_t*, int);
+    int sigdelset(sigset_t*, int);
+    int sigemptyset(sigset_t*);
+    int sigfillset(sigset_t*);
+    int sigismember(in sigset_t*, int);
+    int sigpending(sigset_t*);
+    int sigprocmask(int, in sigset_t*, sigset_t*);
+    int sigsuspend(in sigset_t*);
+    int sigwait(in sigset_t*, int*);
+}
+else version( OSX )
+{
+    enum SIG_HOLD = cast(sigfn_t2) 5;
+
+    alias uint sigset_t;
+    // pid_t  (defined in core.sys.types)
+
+    //SIGABRT (defined in core.stdc.signal)
+    //SIGFPE  (defined in core.stdc.signal)
+    //SIGILL  (defined in core.stdc.signal)
+    //SIGINT  (defined in core.stdc.signal)
+    //SIGSEGV (defined in core.stdc.signal)
+    //SIGTERM (defined in core.stdc.signal)
+
+    enum SA_NOCLDSTOP = 8; // (CX|XSI)
+
+    enum SIG_BLOCK   = 1;
+    enum SIG_UNBLOCK = 2;
+    enum SIG_SETMASK = 3;
+
+    struct siginfo_t
+    {
+        int     si_signo;
+        int     si_errno;
+        int     si_code;
+        pid_t   si_pid;
+        uid_t   si_uid;
+        int     si_status;
+        void*   si_addr;
+        sigval  si_value;
+        int     si_band;
+        uint[7] pad;
+    }
+
+    enum SI_USER    = 0x10001;
+    enum SI_QUEUE   = 0x10002;
+    enum SI_TIMER   = 0x10003;
+    enum SI_ASYNCIO = 0x10004;
+    enum SI_MESGQ   = 0x10005;
+
+    int kill(pid_t, int);
+    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaddset(sigset_t*, int);
+    int sigdelset(sigset_t*, int);
+    int sigemptyset(sigset_t*);
+    int sigfillset(sigset_t*);
+    int sigismember(in sigset_t*, int);
+    int sigpending(sigset_t*);
+    int sigprocmask(int, in sigset_t*, sigset_t*);
+    int sigsuspend(in sigset_t*);
+    int sigwait(in sigset_t*, int*);
+}
+else version( FreeBSD )
+{
+    enum SIG_HOLD = cast(sigfn_t2) 3;
+
+    struct sigset_t
+    {
+        uint[4] __bits;
+    }
+
+    enum SA_NOCLDSTOP = 8;
+
+    enum SIG_BLOCK = 1;
+    enum SIG_UNBLOCK = 2;
+    enum SIG_SETMASK = 3;
+
+    struct siginfo_t
+    {
+        int si_signo;
+        int si_errno;
+        int si_code;
+        pid_t si_pid;
+        uid_t si_uid;
+        int si_status;
+        void* si_addr;
+        sigval si_value;
+        union __reason
+        {
+            struct __fault
+            {
+                int _trapno;
+            }
+            __fault _fault;
+            struct __timer
+            {
+                int _timerid;
+                int _overrun;
+            }
+            __timer _timer;
+            struct __mesgq
+            {
+                int _mqd;
+            }
+            __mesgq _mesgq;
+            struct __poll
+            {
+                c_long _band;
+            }
+            __poll _poll;
+            struct ___spare___
+            {
+                c_long __spare1__;
+                int[7] __spare2__;
+            }
+            ___spare___ __spare__;
+        }
+        __reason _reason;
+
+        @property ref c_long si_band() return { return _reason._poll._band; }
+    }
+
+    enum SI_USER    = 0x10001;
+    enum SI_QUEUE   = 0x10002;
+    enum SI_TIMER   = 0x10003;
+    enum SI_ASYNCIO = 0x10004;
+    enum SI_MESGQ   = 0x10005;
+
+    int kill(pid_t, int);
+    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaddset(sigset_t*, int);
+    int sigdelset(sigset_t*, int);
+    int sigemptyset(sigset_t *);
+    int sigfillset(sigset_t *);
+    int sigismember(in sigset_t *, int);
+    int sigpending(sigset_t *);
+    int sigprocmask(int, in sigset_t*, sigset_t*);
+    int sigsuspend(in sigset_t *);
+    int sigwait(in sigset_t*, int*);
+}
+else version (Solaris)
+{
+    enum SIG_HOLD = cast(sigfn_t2)2;
+
+    struct sigset_t
+    {
+        uint[4] __bits;
+    }
+
+    struct siginfo_t
+    {
+        int si_signo;
+        int si_code;
+        int si_errno;
+
+        version (D_LP64)
+            int si_pad;
+
+        union ___data
+        {
+            version (D_LP64)
+                int[(256 / int.sizeof) - 4] si_pad;
+            else
+                int[(128 / int.sizeof) - 3] si_pad;
+
+            struct ___proc
+            {
+                pid_t __pid;
+
+                union ___pdata
+                {
+                    struct ___kill
+                    {
+                        uid_t __uid;
+                        sigval __value;
+                    }
+
+                    ___kill __kill;
+
+                    struct ___cld
+                    {
+                        clock_t __utime;
+                        int __status;
+                        clock_t __stime;
+                    }
+
+                    ___cld __cld;
+                }
+
+                ___pdata __pdata;
+                ctid_t __ctid;
+                zoneid_t __zoneid;
+            }
+
+            ___proc __proc;
+
+            struct ___fault
+            {
+                void* __addr;
+                int __trapno;
+                caddr_t __pc;
+            }
+
+            ___fault __fault;
+
+            struct ___file
+            {
+                int __fd;
+                c_long __band;
+            }
+
+            ___file __file;
+
+            struct ___prof
+            {
+                caddr_t __faddr;
+                timestruc_t __tstamp;
+                short __syscall;
+                char __nsysarg;
+                char __fault;
+                c_long[8] __sysarg;
+                int[10] __mstate;
+            }
+
+            ___prof __prof;
+
+            struct ___rctl
+            {
+                int __entity;
+            }
+
+            ___rctl __rctl;
+        }
+
+        ___data __data;
+    }
+
+    int kill(pid_t, int);
+    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaddset(sigset_t*, int);
+    int sigdelset(sigset_t*, int);
+    int sigemptyset(sigset_t*);
+    int sigfillset(sigset_t*);
+    int sigismember(in sigset_t*, int);
+    int sigpending(sigset_t*);
+    int sigprocmask(int, in sigset_t*, sigset_t*);
+    int sigsuspend(in sigset_t*);
+    int sigwait(in sigset_t*, int*);
+}
+else version( CRuntime_Bionic )
+{
+    public import core.sys.posix.time: timer_t;
+    private import core.stdc.string : memset;
+
+    version (X86)
+    {
+        alias c_ulong sigset_t;
+        enum int LONG_BIT = 32;
+    }
+    else version (ARM)
+    {
+        alias c_ulong sigset_t;
+        enum int LONG_BIT = 32;
+    }
+    else
+    {
+        static assert(false, "Architecture not supported.");
+    }
+
+    enum SIG_BLOCK   = 0;
+    enum SIG_UNBLOCK = 1;
+    enum SIG_SETMASK = 2;
+
+    private enum SI_MAX_SIZE = 128;
+    private enum SI_PAD_SIZE = ((SI_MAX_SIZE / int.sizeof) - 3);
+
+    struct siginfo_t
+    {
+        int si_signo;
+        int si_errno;
+        int si_code;
+
+        union _sifields_t
+        {
+            int[SI_PAD_SIZE] _pad;
+
+            struct _kill_t
+            {
+                pid_t _pid;
+                uid_t _uid;
+            } _kill_t _kill;
+
+            struct _timer_t
+            {
+                timer_t _tid;
+                int     _overrun;
+                sigval  _sigval;
+                int     _sys_private;
+            } _timer_t _timer;
+
+            struct _rt_t
+            {
+                pid_t  _pid;
+                uid_t  _uid;
+                sigval _sigval;
+            } _rt_t _rt;
+
+            struct _sigchild_t
+            {
+                pid_t   _pid;
+                uid_t   _uid;
+                int     _status;
+                clock_t _utime;
+                clock_t _stime;
+            } _sigchild_t _sigchld;
+
+            struct _sigfault_t
+            {
+                void*   _addr;
+            } _sigfault_t _sigfault;
+
+            struct _sigpoll_t
+            {
+                c_long _band;
+                int    _fd;
+            } _sigpoll_t _sigpoll;
+        } _sifields_t _sifields;
+    }
+
+    enum
+    {
+        SI_TKILL   = -6,
+        SI_SIGIO,
+        SI_ASYNCIO,
+        SI_MESGQ,
+        SI_TIMER,
+        SI_QUEUE,
+        SI_USER,
+        SI_KERNEL  = 0x80
+    }
+
+    int kill(pid_t, int);
+    int sigaction(int, in sigaction_t*, sigaction_t*);
+
+    // These functions are defined inline in bionic.
+    int sigaddset(sigset_t* set, int signum)
+    {
+        c_ulong* local_set = cast(c_ulong*) set;
+        signum--;
+        local_set[signum/LONG_BIT] |= 1UL << (signum%LONG_BIT);
+        return 0;
+    }
+
+    int sigdelset(sigset_t* set, int signum)
+    {
+        c_ulong* local_set = cast(c_ulong*) set;
+        signum--;
+        local_set[signum/LONG_BIT] &= ~(1UL << (signum%LONG_BIT));
+        return 0;
+    }
+
+    int sigemptyset(sigset_t* set) { memset(set, 0, (*set).sizeof); return 0; }
+
+    int sigfillset(sigset_t* set) { memset(set, ~0, (*set).sizeof); return 0; }
+
+    int sigismember(sigset_t* set, int signum)
+    {
+        c_ulong* local_set = cast(c_ulong*) set;
+        signum--;
+        return cast(int) ((local_set[signum/LONG_BIT] >> (signum%LONG_BIT)) & 1);
+    }
+
+    int sigpending(sigset_t*);
+    int sigprocmask(int, in sigset_t*, sigset_t*);
+    int sigsuspend(in sigset_t*);
+    int sigwait(in sigset_t*, int*);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+}
+
+//
+// XOpen (XSI)
+//
+/*
+SIGPOLL
+SIGPROF
+SIGSYS
+SIGTRAP
+SIGVTALRM
+SIGXCPU
+SIGXFSZ
+
+SA_ONSTACK
+SA_RESETHAND
+SA_RESTART
+SA_SIGINFO
+SA_NOCLDWAIT
+SA_NODEFER
+SS_ONSTACK
+SS_DISABLE
+MINSIGSTKSZ
+SIGSTKSZ
+
+ucontext_t // from ucontext
+mcontext_t // from ucontext
+
+struct stack_t
+{
+    void*   ss_sp;
+    size_t  ss_size;
+    int     ss_flags;
+}
+
+struct sigstack
+{
+    int   ss_onstack;
+    void* ss_sp;
+}
+
+ILL_ILLOPC
+ILL_ILLOPN
+ILL_ILLADR
+ILL_ILLTRP
+ILL_PRVOPC
+ILL_PRVREG
+ILL_COPROC
+ILL_BADSTK
+
+FPE_INTDIV
+FPE_INTOVF
+FPE_FLTDIV
+FPE_FLTOVF
+FPE_FLTUND
+FPE_FLTRES
+FPE_FLTINV
+FPE_FLTSUB
+
+SEGV_MAPERR
+SEGV_ACCERR
+
+BUS_ADRALN
+BUS_ADRERR
+BUS_OBJERR
+
+TRAP_BRKPT
+TRAP_TRACE
+
+CLD_EXITED
+CLD_KILLED
+CLD_DUMPED
+CLD_TRAPPED
+CLD_STOPPED
+CLD_CONTINUED
+
+POLL_IN
+POLL_OUT
+POLL_MSG
+POLL_ERR
+POLL_PRI
+POLL_HUP
+
+sigfn_t bsd_signal(int sig, sigfn_t func);
+sigfn_t sigset(int sig, sigfn_t func);
+
+int killpg(pid_t, int);
+int sigaltstack(in stack_t*, stack_t*);
+int sighold(int);
+int sigignore(int);
+int siginterrupt(int, int);
+int sigpause(int);
+int sigrelse(int);
+*/
+
+version( CRuntime_Glibc )
+{
+    version (X86)
+    {
+        enum SIGPOLL        = 29;
+        enum SIGPROF        = 27;
+        enum SIGSYS         = 31;
+        enum SIGTRAP        = 5;
+        enum SIGVTALRM      = 26;
+        enum SIGXCPU        = 24;
+        enum SIGXFSZ        = 25;
+    }
+    else version (X86_64)
+    {
+        enum SIGPOLL        = 29;
+        enum SIGPROF        = 27;
+        enum SIGSYS         = 31;
+        enum SIGTRAP        = 5;
+        enum SIGVTALRM      = 26;
+        enum SIGXCPU        = 24;
+        enum SIGXFSZ        = 25;
+    }
+    else version (MIPS32)
+    {
+        enum SIGPOLL    = 22;
+        enum SIGPROF    = 29;
+        enum SIGSYS     = 12;
+        enum SIGTRAP    = 5;
+        enum SIGVTALRM  = 28;
+        enum SIGXCPU    = 30;
+        enum SIGXFSZ    = 31;
+    }
+    else version (MIPS64)
+    {
+        enum SIGPOLL    = 22;
+        enum SIGPROF    = 29;
+        enum SIGSYS     = 12;
+        enum SIGTRAP    = 5;
+        enum SIGVTALRM  = 28;
+        enum SIGXCPU    = 30;
+        enum SIGXFSZ    = 31;
+    }
+    else version (PPC)
+    {
+        enum SIGPOLL    = 29;
+        enum SIGPROF    = 27;
+        enum SIGSYS     = 31;
+        enum SIGTRAP    = 5;
+        enum SIGVTALRM  = 26;
+        enum SIGXCPU    = 24;
+        enum SIGXFSZ    = 25;
+    }
+    else version (PPC64)
+    {
+        enum SIGPOLL    = 29;
+        enum SIGPROF    = 27;
+        enum SIGSYS     = 31;
+        enum SIGTRAP    = 5;
+        enum SIGVTALRM  = 26;
+        enum SIGXCPU    = 24;
+        enum SIGXFSZ    = 25;
+    }
+    else version (ARM)
+    {
+        enum SIGPOLL    = 29;
+        enum SIGPROF    = 27;
+        enum SIGSYS     = 31;
+        enum SIGTRAP    = 5;
+        enum SIGVTALRM  = 26;
+        enum SIGXCPU    = 24;
+        enum SIGXFSZ    = 25;
+    }
+    else version (AArch64)
+    {
+        enum SIGPOLL    = 29;
+        enum SIGPROF    = 27;
+        enum SIGSYS     = 31;
+        enum SIGTRAP    = 5;
+        enum SIGVTALRM  = 26;
+        enum SIGXCPU    = 24;
+        enum SIGXFSZ    = 25;
+    }
+    else version (SystemZ)
+    {
+        enum SIGPOLL    = 29;
+        enum SIGPROF    = 27;
+        enum SIGSYS     = 31;
+        enum SIGTRAP    = 5;
+        enum SIGVTALRM  = 26;
+        enum SIGXCPU    = 24;
+        enum SIGXFSZ    = 25;
+    }
+    else
+        static assert(0, "unimplemented");
+
+    enum SA_ONSTACK     = 0x08000000;
+    enum SA_RESETHAND   = 0x80000000;
+    enum SA_RESTART     = 0x10000000;
+    enum SA_SIGINFO     = 4;
+    enum SA_NOCLDWAIT   = 2;
+    enum SA_NODEFER     = 0x40000000;
+    enum SS_ONSTACK     = 1;
+    enum SS_DISABLE     = 2;
+    enum MINSIGSTKSZ    = 2048;
+    enum SIGSTKSZ       = 8192;
+
+    //ucontext_t (defined in core.sys.posix.ucontext)
+    //mcontext_t (defined in core.sys.posix.ucontext)
+
+    struct stack_t
+    {
+        void*   ss_sp;
+        int     ss_flags;
+        size_t  ss_size;
+    }
+
+    struct sigstack
+    {
+        void*   ss_sp;
+        int     ss_onstack;
+    }
+
+    enum
+    {
+        ILL_ILLOPC = 1,
+        ILL_ILLOPN,
+        ILL_ILLADR,
+        ILL_ILLTRP,
+        ILL_PRVOPC,
+        ILL_PRVREG,
+        ILL_COPROC,
+        ILL_BADSTK
+    }
+
+    enum
+    {
+        FPE_INTDIV = 1,
+        FPE_INTOVF,
+        FPE_FLTDIV,
+        FPE_FLTOVF,
+        FPE_FLTUND,
+        FPE_FLTRES,
+        FPE_FLTINV,
+        FPE_FLTSUB
+    }
+
+    enum
+    {
+        SEGV_MAPERR = 1,
+        SEGV_ACCERR
+    }
+
+    enum
+    {
+        BUS_ADRALN = 1,
+        BUS_ADRERR,
+        BUS_OBJERR
+    }
+
+    enum
+    {
+        TRAP_BRKPT = 1,
+        TRAP_TRACE
+    }
+
+    enum
+    {
+        CLD_EXITED = 1,
+        CLD_KILLED,
+        CLD_DUMPED,
+        CLD_TRAPPED,
+        CLD_STOPPED,
+        CLD_CONTINUED
+    }
+
+    enum
+    {
+        POLL_IN = 1,
+        POLL_OUT,
+        POLL_MSG,
+        POLL_ERR,
+        POLL_PRI,
+        POLL_HUP
+    }
+
+    sigfn_t bsd_signal(int sig, sigfn_t func);
+    sigfn_t sigset(int sig, sigfn_t func);
+
+  nothrow:
+  @nogc:
+    sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
+    sigfn_t2 sigset(int sig, sigfn_t2 func);
+
+    int killpg(pid_t, int);
+    int sigaltstack(in stack_t*, stack_t*);
+    int sighold(int);
+    int sigignore(int);
+    int siginterrupt(int, int);
+    int sigpause(int);
+    int sigrelse(int);
+}
+else version( OSX )
+{
+    enum SIGPOLL        = 7;
+    enum SIGPROF        = 27;
+    enum SIGSYS         = 12;
+    enum SIGTRAP        = 5;
+    enum SIGVTALRM      = 26;
+    enum SIGXCPU        = 24;
+    enum SIGXFSZ        = 25;
+
+    enum SA_ONSTACK     = 0x0001;
+    enum SA_RESETHAND   = 0x0004;
+    enum SA_RESTART     = 0x0002;
+    enum SA_SIGINFO     = 0x0040;
+    enum SA_NOCLDWAIT   = 0x0020;
+    enum SA_NODEFER     = 0x0010;
+    enum SS_ONSTACK     = 0x0001;
+    enum SS_DISABLE     = 0x0004;
+    enum MINSIGSTKSZ    = 32768;
+    enum SIGSTKSZ       = 131072;
+
+    //ucontext_t (defined in core.sys.posix.ucontext)
+    //mcontext_t (defined in core.sys.posix.ucontext)
+
+    struct stack_t
+    {
+        void*   ss_sp;
+        size_t  ss_size;
+        int     ss_flags;
+    }
+
+    struct sigstack
+    {
+        void*   ss_sp;
+        int     ss_onstack;
+    }
+
+    enum ILL_ILLOPC = 1;
+    enum ILL_ILLOPN = 4;
+    enum ILL_ILLADR = 5;
+    enum ILL_ILLTRP = 2;
+    enum ILL_PRVOPC = 3;
+    enum ILL_PRVREG = 6;
+    enum ILL_COPROC = 7;
+    enum ILL_BADSTK = 8;
+
+    enum FPE_INTDIV = 7;
+    enum FPE_INTOVF = 8;
+    enum FPE_FLTDIV = 1;
+    enum FPE_FLTOVF = 2;
+    enum FPE_FLTUND = 3;
+    enum FPE_FLTRES = 4;
+    enum FPE_FLTINV = 5;
+    enum FPE_FLTSUB = 6;
+
+    enum
+    {
+        SEGV_MAPERR = 1,
+        SEGV_ACCERR
+    }
+
+    enum
+    {
+        BUS_ADRALN = 1,
+        BUS_ADRERR,
+        BUS_OBJERR
+    }
+
+    enum
+    {
+        TRAP_BRKPT = 1,
+        TRAP_TRACE
+    }
+
+    enum
+    {
+        CLD_EXITED = 1,
+        CLD_KILLED,
+        CLD_DUMPED,
+        CLD_TRAPPED,
+        CLD_STOPPED,
+        CLD_CONTINUED
+    }
+
+    enum
+    {
+        POLL_IN = 1,
+        POLL_OUT,
+        POLL_MSG,
+        POLL_ERR,
+        POLL_PRI,
+        POLL_HUP
+    }
+
+    sigfn_t bsd_signal(int sig, sigfn_t func);
+    sigfn_t sigset(int sig, sigfn_t func);
+
+  nothrow:
+  @nogc:
+    sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
+    sigfn_t2 sigset(int sig, sigfn_t2 func);
+
+    int killpg(pid_t, int);
+    int sigaltstack(in stack_t*, stack_t*);
+    int sighold(int);
+    int sigignore(int);
+    int siginterrupt(int, int);
+    int sigpause(int);
+    int sigrelse(int);
+}
+else version( FreeBSD )
+{
+    // No SIGPOLL on *BSD
+    enum SIGPROF        = 27;
+    enum SIGSYS         = 12;
+    enum SIGTRAP        = 5;
+    enum SIGVTALRM      = 26;
+    enum SIGXCPU        = 24;
+    enum SIGXFSZ        = 25;
+
+    enum
+    {
+        SA_ONSTACK      = 0x0001,
+        SA_RESTART      = 0x0002,
+        SA_RESETHAND    = 0x0004,
+        SA_NODEFER      = 0x0010,
+        SA_NOCLDWAIT    = 0x0020,
+        SA_SIGINFO      = 0x0040,
+    }
+
+    enum
+    {
+        SS_ONSTACK = 0x0001,
+        SS_DISABLE = 0x0004,
+    }
+
+    enum MINSIGSTKSZ = 512 * 4;
+    enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
+;
+    //ucontext_t (defined in core.sys.posix.ucontext)
+    //mcontext_t (defined in core.sys.posix.ucontext)
+
+    struct stack_t
+    {
+        void*   ss_sp;
+        size_t  ss_size;
+        int     ss_flags;
+    }
+
+    struct sigstack
+    {
+        void*   ss_sp;
+        int     ss_onstack;
+    }
+
+    enum
+    {
+        ILL_ILLOPC = 1,
+        ILL_ILLOPN,
+        ILL_ILLADR,
+        ILL_ILLTRP,
+        ILL_PRVOPC,
+        ILL_PRVREG,
+        ILL_COPROC,
+        ILL_BADSTK,
+    }
+
+    enum
+    {
+        BUS_ADRALN = 1,
+        BUS_ADRERR,
+        BUS_OBJERR,
+    }
+
+    enum
+    {
+        SEGV_MAPERR = 1,
+        SEGV_ACCERR,
+    }
+
+    enum
+    {
+        FPE_INTOVF = 1,
+        FPE_INTDIV,
+        FPE_FLTDIV,
+        FPE_FLTOVF,
+        FPE_FLTUND,
+        FPE_FLTRES,
+        FPE_FLTINV,
+        FPE_FLTSUB,
+    }
+
+    enum
+    {
+        TRAP_BRKPT = 1,
+        TRAP_TRACE,
+    }
+
+    enum
+    {
+        CLD_EXITED = 1,
+        CLD_KILLED,
+        CLD_DUMPED,
+        CLD_TRAPPED,
+        CLD_STOPPED,
+        CLD_CONTINUED,
+    }
+
+    enum
+    {
+        POLL_IN = 1,
+        POLL_OUT,
+        POLL_MSG,
+        POLL_ERR,
+        POLL_PRI,
+        POLL_HUP,
+    }
+
+    //sigfn_t bsd_signal(int sig, sigfn_t func);
+    sigfn_t sigset(int sig, sigfn_t func);
+
+  nothrow:
+  @nogc:
+    //sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
+    sigfn_t2 sigset(int sig, sigfn_t2 func);
+
+    int killpg(pid_t, int);
+    int sigaltstack(in stack_t*, stack_t*);
+    int sighold(int);
+    int sigignore(int);
+    int siginterrupt(int, int);
+    int sigpause(int);
+    int sigrelse(int);
+}
+else version (Solaris)
+{
+    enum SIGPOLL = 22;
+    enum SIGPROF = 29;
+    enum SIGSYS = 12;
+    enum SIGTRAP = 5;
+    enum SIGVTALRM = 31;
+    enum SIGXCPU = 30;
+    enum SIGXFSZ = 25;
+
+    enum
+    {
+        SA_ONSTACK = 0x00001,
+        SA_RESTART = 0x00004,
+        SA_RESETHAND = 0x00002,
+        SA_NODEFER = 0x00010,
+        SA_NOCLDWAIT = 0x10000,
+        SA_SIGINFO = 0x00008,
+    }
+
+    enum
+    {
+        SS_ONSTACK = 0x0001,
+        SS_DISABLE = 0x0002,
+    }
+
+    enum MINSIGSTKSZ = 2048;
+    enum SIGSTKSZ = 8192;
+
+    struct stack_t
+    {
+        void* ss_sp;
+        size_t ss_size;
+        int ss_flags;
+    }
+
+    struct sigstack
+    {
+        void* ss_sp;
+        int ss_onstack;
+    }
+
+    enum
+    {
+        ILL_ILLOPC = 1,
+        ILL_ILLOPN,
+        ILL_ILLADR,
+        ILL_ILLTRP,
+        ILL_PRVOPC,
+        ILL_PRVREG,
+        ILL_COPROC,
+        ILL_BADSTK,
+    }
+
+    enum
+    {
+        BUS_ADRALN = 1,
+        BUS_ADRERR,
+        BUS_OBJERR,
+    }
+
+    enum
+    {
+        SEGV_MAPERR = 1,
+        SEGV_ACCERR,
+    }
+
+    enum
+    {
+        FPE_INTDIV = 1,
+        FPE_INTOVF,
+        FPE_FLTDIV,
+        FPE_FLTOVF,
+        FPE_FLTUND,
+        FPE_FLTRES,
+        FPE_FLTINV,
+        FPE_FLTSUB,
+        FPE_FLTDEN,
+    }
+
+    enum
+    {
+        TRAP_BRKPT = 1,
+        TRAP_TRACE,
+        TRAP_RWATCH,
+        TRAP_WWATCH,
+        TRAP_XWATCH,
+        TRAP_DTRACE,
+    }
+
+    enum
+    {
+        CLD_EXITED = 1,
+        CLD_KILLED,
+        CLD_DUMPED,
+        CLD_TRAPPED,
+        CLD_STOPPED,
+        CLD_CONTINUED,
+    }
+
+    enum
+    {
+        POLL_IN = 1,
+        POLL_OUT,
+        POLL_MSG,
+        POLL_ERR,
+        POLL_PRI,
+        POLL_HUP,
+    }
+
+    sigfn_t sigset(int sig, sigfn_t func);
+
+  nothrow:
+  @nogc:
+    sigfn_t2 sigset(int sig, sigfn_t2 func);
+
+    int killpg(pid_t, int);
+    int sigaltstack(in stack_t*, stack_t*);
+    int sighold(int);
+    int sigignore(int);
+    int siginterrupt(int, int);
+    int sigpause(int);
+    int sigrelse(int);
+}
+else version (CRuntime_Bionic)
+{
+    version (X86)
+    {
+        enum SIGPOLL   = 29;
+        enum SIGPROF   = 27;
+        enum SIGSYS    = 31;
+        enum SIGTRAP   = 5;
+        enum SIGVTALRM = 26;
+        enum SIGXCPU   = 24;
+        enum SIGXFSZ   = 25;
+
+        enum SA_ONSTACK     = 0x08000000;
+        enum SA_RESETHAND   = 0x80000000;
+        enum SA_RESTART     = 0x10000000;
+        enum SA_SIGINFO     = 4;
+        enum SA_NOCLDWAIT   = 2;
+        enum SA_NODEFER     = 0x40000000;
+        enum SS_ONSTACK     = 1;
+        enum SS_DISABLE     = 2;
+        enum MINSIGSTKSZ    = 2048;
+        enum SIGSTKSZ       = 8192;
+
+        struct stack_t
+        {
+            void*   ss_sp;
+            int     ss_flags;
+            size_t  ss_size;
+        }
+    }
+    else version (ARM)
+    {
+        enum SIGPOLL   = 29;
+        enum SIGPROF   = 27;
+        enum SIGSYS    = 31;
+        enum SIGTRAP   = 5;
+        enum SIGVTALRM = 26;
+        enum SIGXCPU   = 24;
+        enum SIGXFSZ   = 25;
+
+        enum SA_ONSTACK     = 0x08000000;
+        enum SA_RESETHAND   = 0x80000000;
+        enum SA_RESTART     = 0x10000000;
+        enum SA_SIGINFO     = 4;
+        enum SA_NOCLDWAIT   = 2;
+        enum SA_NODEFER     = 0x40000000;
+        enum SS_ONSTACK     = 1;
+        enum SS_DISABLE     = 2;
+        enum MINSIGSTKSZ    = 2048;
+        enum SIGSTKSZ       = 8192;
+
+        struct stack_t
+        {
+            void*   ss_sp;
+            int     ss_flags;
+            size_t  ss_size;
+        }
+    }
+    else
+    {
+        static assert(false, "Architecture not supported.");
+    }
+
+    enum
+    {
+        ILL_ILLOPC = 1,
+        ILL_ILLOPN,
+        ILL_ILLADR,
+        ILL_ILLTRP,
+        ILL_PRVOPC,
+        ILL_PRVREG,
+        ILL_COPROC,
+        ILL_BADSTK
+    }
+
+    enum
+    {
+        FPE_INTDIV = 1,
+        FPE_INTOVF,
+        FPE_FLTDIV,
+        FPE_FLTOVF,
+        FPE_FLTUND,
+        FPE_FLTRES,
+        FPE_FLTINV,
+        FPE_FLTSUB
+    }
+
+    enum
+    {
+        SEGV_MAPERR = 1,
+        SEGV_ACCERR
+    }
+
+    enum
+    {
+        BUS_ADRALN = 1,
+        BUS_ADRERR,
+        BUS_OBJERR
+    }
+
+    enum
+    {
+        TRAP_BRKPT = 1,
+        TRAP_TRACE
+    }
+
+    enum
+    {
+        CLD_EXITED = 1,
+        CLD_KILLED,
+        CLD_DUMPED,
+        CLD_TRAPPED,
+        CLD_STOPPED,
+        CLD_CONTINUED
+    }
+
+    enum
+    {
+        POLL_IN = 1,
+        POLL_OUT,
+        POLL_MSG,
+        POLL_ERR,
+        POLL_PRI,
+        POLL_HUP
+    }
+
+    sigfn_t bsd_signal(int, sigfn_t);
+
+  nothrow:
+  @nogc:
+    sigfn_t2 bsd_signal(int, sigfn_t2);
+
+    int killpg(int, int);
+    int sigaltstack(in stack_t*, stack_t*);
+    int siginterrupt(int, int);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Timer (TMR)
+//
+/*
+NOTE: This should actually be defined in core.sys.posix.time.
+      It is defined here instead to break a circular import.
+
+struct timespec
+{
+    time_t  tv_sec;
+    int     tv_nsec;
+}
+*/
+
+version( linux )
+{
+    struct timespec
+    {
+        time_t  tv_sec;
+        c_long  tv_nsec;
+    }
+}
+else version( OSX )
+{
+    struct timespec
+    {
+        time_t  tv_sec;
+        c_long  tv_nsec;
+    }
+}
+else version( FreeBSD )
+{
+    struct timespec
+    {
+        time_t  tv_sec;
+        c_long  tv_nsec;
+    }
+}
+else version (Solaris)
+{
+    struct timespec
+    {
+        time_t tv_sec;
+        c_long tv_nsec;
+    }
+
+    alias timespec timestruc_t;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Realtime Signals (RTS)
+//
+/*
+struct sigevent
+{
+    int             sigev_notify;
+    int             sigev_signo;
+    sigval          sigev_value;
+    void(*)(sigval) sigev_notify_function;
+    pthread_attr_t* sigev_notify_attributes;
+}
+
+int sigqueue(pid_t, int, in sigval);
+int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
+int sigwaitinfo(in sigset_t*, siginfo_t*);
+*/
+
+nothrow:
+@nogc:
+
+version( CRuntime_Glibc )
+{
+    private enum __SIGEV_MAX_SIZE = 64;
+
+    static if( false /* __WORDSIZE == 64 */ )
+    {
+        private enum __SIGEV_PAD_SIZE = ((__SIGEV_MAX_SIZE / int.sizeof) - 4);
+    }
+    else
+    {
+        private enum __SIGEV_PAD_SIZE = ((__SIGEV_MAX_SIZE / int.sizeof) - 3);
+    }
+
+    struct sigevent
+    {
+        sigval      sigev_value;
+        int         sigev_signo;
+        int         sigev_notify;
+
+        union _sigev_un_t
+        {
+            int[__SIGEV_PAD_SIZE] _pad;
+            pid_t                 _tid;
+
+            struct _sigev_thread_t
+            {
+                void function(sigval)   _function;
+                void*                   _attribute;
+            } _sigev_thread_t _sigev_thread;
+        } _sigev_un_t _sigev_un;
+    }
+
+    int sigqueue(pid_t, int, in sigval);
+    int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
+    int sigwaitinfo(in sigset_t*, siginfo_t*);
+}
+else version( FreeBSD )
+{
+    struct sigevent
+    {
+        int             sigev_notify;
+        int             sigev_signo;
+        sigval          sigev_value;
+        union  _sigev_un
+        {
+            lwpid_t _threadid;
+            struct _sigev_thread
+            {
+                void function(sigval) _function;
+                void* _attribute;
+            }
+            c_long[8] __spare__;
+        }
+    }
+
+    int sigqueue(pid_t, int, in sigval);
+    int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
+    int sigwaitinfo(in sigset_t*, siginfo_t*);
+}
+else version (OSX)
+{
+}
+else version (Solaris)
+{
+    struct sigevent
+    {
+        int sigev_notify;
+        int sigev_signo;
+        sigval sigev_value;
+        void function(sigval) sigev_notify_function;
+        pthread_attr_t* sigev_notify_attributes;
+        int __sigev_pad2;
+    }
+
+    int sigqueue(pid_t, int, in sigval);
+    int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
+    int sigwaitinfo(in sigset_t*, siginfo_t*);
+}
+else version( CRuntime_Bionic )
+{
+    private enum __ARCH_SIGEV_PREAMBLE_SIZE = (int.sizeof * 2) + sigval.sizeof;
+    private enum SIGEV_MAX_SIZE = 64;
+    private enum SIGEV_PAD_SIZE = (SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE)
+                                  / int.sizeof;
+
+    struct sigevent
+    {
+        sigval      sigev_value;
+        int         sigev_signo;
+        int         sigev_notify;
+
+        union _sigev_un_t
+        {
+            int[SIGEV_PAD_SIZE] _pad;
+            int                 _tid;
+
+            struct _sigev_thread_t
+            {
+                void function(sigval) _function;
+                void*                 _attribute;
+            } _sigev_thread_t _sigev_thread;
+        } _sigev_un_t _sigev_un;
+    }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Threads (THR)
+//
+/*
+int pthread_kill(pthread_t, int);
+int pthread_sigmask(int, in sigset_t*, sigset_t*);
+*/
+
+version( CRuntime_Glibc )
+{
+    int pthread_kill(pthread_t, int);
+    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+}
+else version( OSX )
+{
+    int pthread_kill(pthread_t, int);
+    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+}
+else version( FreeBSD )
+{
+    int pthread_kill(pthread_t, int);
+    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+}
+else version (Solaris)
+{
+    int pthread_kill(pthread_t, int);
+    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+}
+else version( CRuntime_Bionic )
+{
+    int pthread_kill(pthread_t, int);
+    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
new file mode 100644
index 00000000000..122cba07ef5
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -0,0 +1,323 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.stdio;
+
+private import core.sys.posix.config;
+public import core.stdc.stdio;
+public import core.sys.posix.sys.types; // for off_t
+
+version (Posix):
+extern (C):
+
+nothrow:
+@nogc:
+
+//
+// Required (defined in core.stdc.stdio)
+//
+/*
+BUFSIZ
+_IOFBF
+_IOLBF
+_IONBF
+L_tmpnam
+SEEK_CUR
+SEEK_END
+SEEK_SET
+FILENAME_MAX
+FOPEN_MAX
+TMP_MAX
+EOF
+NULL
+stderr
+stdin
+stdout
+FILE
+fpos_t
+size_t
+
+void   clearerr(FILE*);
+int    fclose(FILE*);
+int    feof(FILE*);
+int    ferror(FILE*);
+int    fflush(FILE*);
+int    fgetc(FILE*);
+int    fgetpos(FILE*, fpos_t *);
+char*  fgets(char*, int, FILE*);
+FILE*  fopen(in char*, in char*);
+int    fprintf(FILE*, in char*, ...);
+int    fputc(int, FILE*);
+int    fputs(in char*, FILE*);
+size_t fread(void *, size_t, size_t, FILE*);
+FILE*  freopen(in char*, in char*, FILE*);
+int    fscanf(FILE*, in char*, ...);
+int    fseek(FILE*, c_long, int);
+int    fsetpos(FILE*, in fpos_t*);
+c_long ftell(FILE*);
+size_t fwrite(in void *, size_t, size_t, FILE*);
+int    getc(FILE*);
+int    getchar();
+char*  gets(char*);
+void   perror(in char*);
+int    printf(in char*, ...);
+int    putc(int, FILE*);
+int    putchar(int);
+int    puts(in char*);
+int    remove(in char*);
+int    rename(in char*, in char*);
+void   rewind(FILE*);
+int    scanf(in char*, ...);
+void   setbuf(FILE*, char*);
+int    setvbuf(FILE*, char*, int, size_t);
+int    snprintf(char*, size_t, in char*, ...);
+int    sprintf(char*, in char*, ...);
+int    sscanf(in char*, in char*, int ...);
+FILE*  tmpfile();
+char*  tmpnam(char*);
+int    ungetc(int, FILE*);
+int    vfprintf(FILE*, in char*, va_list);
+int    vfscanf(FILE*, in char*, va_list);
+int    vprintf(in char*, va_list);
+int    vscanf(in char*, va_list);
+int    vsnprintf(char*, size_t, in char*, va_list);
+int    vsprintf(char*, in char*, va_list);
+int    vsscanf(in char*, in char*, va_list arg);
+*/
+
+version( CRuntime_Glibc )
+{
+    /*
+     * actually, if __USE_FILE_OFFSET64 && !_LARGEFILE64_SOURCE
+     * the *64 functions shouldn't be visible, but the aliases should
+     * still be supported
+     */
+    static if( __USE_FILE_OFFSET64 )
+    {
+        int   fgetpos64(FILE*, fpos_t *);
+        alias fgetpos64 fgetpos;
+
+        FILE* fopen64(in char*, in char*);
+        alias fopen64 fopen;
+
+        FILE* freopen64(in char*, in char*, FILE*);
+        alias freopen64 freopen;
+
+        int   fseek(FILE*, c_long, int);
+
+        int   fsetpos64(FILE*, in fpos_t*);
+        alias fsetpos64 fsetpos;
+
+        FILE* tmpfile64();
+        alias tmpfile64 tmpfile;
+    }
+    else
+    {
+        int   fgetpos(FILE*, fpos_t *);
+        FILE* fopen(in char*, in char*);
+        FILE* freopen(in char*, in char*, FILE*);
+        int   fseek(FILE*, c_long, int);
+        int   fsetpos(FILE*, in fpos_t*);
+        FILE* tmpfile();
+    }
+}
+else version( CRuntime_Bionic )
+{
+    int   fgetpos(FILE*, fpos_t *);
+    FILE* fopen(in char*, in char*);
+    FILE* freopen(in char*, in char*, FILE*);
+    int   fseek(FILE*, c_long, int);
+    int   fsetpos(FILE*, in fpos_t*);
+}
+
+//
+// C Extension (CX)
+//
+/*
+L_ctermid
+
+char*  ctermid(char*);
+FILE*  fdopen(int, in char*);
+int    fileno(FILE*);
+int    fseeko(FILE*, off_t, int);
+off_t  ftello(FILE*);
+char*  gets(char*);
+int    pclose(FILE*);
+FILE*  popen(in char*, in char*);
+*/
+
+version( CRuntime_Glibc )
+{
+    enum L_ctermid = 9;
+
+  static if( __USE_FILE_OFFSET64 )
+  {
+    int   fseeko64(FILE*, off_t, int);
+    alias fseeko64 fseeko;
+  }
+  else
+  {
+    int   fseeko(FILE*, off_t, int);
+  }
+
+  static if( __USE_FILE_OFFSET64 )
+  {
+    off_t ftello64(FILE*);
+    alias ftello64 ftello;
+  }
+  else
+  {
+    off_t ftello(FILE*);
+  }
+}
+else version( Posix )
+{
+    int   fseeko(FILE*, off_t, int);
+    off_t ftello(FILE*);
+}
+
+char*  ctermid(char*);
+FILE*  fdopen(int, in char*);
+int    fileno(FILE*);
+//int    fseeko(FILE*, off_t, int);
+//off_t  ftello(FILE*);
+char*  gets(char*);
+int    pclose(FILE*);
+FILE*  popen(in char*, in char*);
+
+
+// memstream functions are conforming to POSIX.1-2008.  These functions are
+// not specified in POSIX.1-2001 and are not widely available on other
+// systems.
+version( CRuntime_Glibc )                     // as of glibc 1.0x
+    version = HaveMemstream;
+else version( FreeBSD )                      // as of FreeBSD 9.2
+    version = HaveMemstream;
+else version( OpenBSD )                      // as of OpenBSD 5.4
+    version = HaveMemstream;
+
+version( HaveMemstream )
+{
+    FILE*  fmemopen(in void* buf, in size_t size, in char* mode);
+    FILE*  open_memstream(char** ptr, size_t* sizeloc);
+    FILE*  open_wmemstream(wchar_t** ptr, size_t* sizeloc);
+}
+
+//
+// Thread-Safe Functions (TSF)
+//
+/*
+void   flockfile(FILE*);
+int    ftrylockfile(FILE*);
+void   funlockfile(FILE*);
+int    getc_unlocked(FILE*);
+int    getchar_unlocked();
+int    putc_unlocked(int, FILE*);
+int    putchar_unlocked(int);
+*/
+
+version( CRuntime_Glibc )
+{
+    void   flockfile(FILE*);
+    int    ftrylockfile(FILE*);
+    void   funlockfile(FILE*);
+    int    getc_unlocked(FILE*);
+    int    getchar_unlocked();
+    int    putc_unlocked(int, FILE*);
+    int    putchar_unlocked(int);
+}
+else version( Solaris )
+{
+    void   flockfile(FILE*);
+    int    ftrylockfile(FILE*);
+    void   funlockfile(FILE*);
+    int    getc_unlocked(FILE*);
+    int    getchar_unlocked();
+    int    putc_unlocked(int, FILE*);
+    int    putchar_unlocked(int);
+}
+
+//
+// XOpen (XSI)
+//
+/*
+P_tmpdir
+va_list (defined in core.stdc.stdarg)
+
+char*  tempnam(in char*, in char*);
+*/
+
+char*  tempnam(in char*, in char*);
+
+version( CRuntime_Glibc )
+{
+    enum P_tmpdir  = "/tmp";
+}
+version( OSX )
+{
+    enum P_tmpdir  = "/var/tmp";
+}
+version( FreeBSD )
+{
+    enum P_tmpdir  = "/var/tmp/";
+}
+version( Solaris )
+{
+    enum P_tmpdir  = "/var/tmp/";
+}
+
+version( HaveMemstream )
+unittest
+{ /* fmemopen */
+    import core.stdc.string : memcmp;
+    byte[10] buf;
+    auto f = fmemopen(buf.ptr, 10, "w");
+    assert(f !is null);
+    assert(fprintf(f, "hello") == "hello".length);
+    assert(fflush(f) == 0);
+    assert(memcmp(buf.ptr, "hello".ptr, "hello".length) == 0);
+    //assert(buf
+    assert(fclose(f) == 0);
+}
+
+version( HaveMemstream )
+unittest
+{ /* Note: open_memstream is only useful for writing */
+    import core.stdc.string : memcmp;
+    char* ptr = null;
+    char[6] testdata = ['h', 'e', 'l', 'l', 'o', 0];
+    size_t sz = 0;
+    auto f = open_memstream(&ptr, &sz);
+    assert(f !is null);
+    assert(fprintf(f, "%s", testdata.ptr) == 5);
+    assert(fflush(f) == 0);
+    assert(memcmp(ptr, testdata.ptr, testdata.length) == 0);
+    assert(fclose(f) == 0);
+}
+
+version( HaveMemstream )
+unittest
+{ /* Note: open_wmemstream is only useful for writing */
+    import core.stdc.string : memcmp;
+    import core.stdc.wchar_ : fwprintf;
+    wchar_t* ptr = null;
+    wchar_t[6] testdata = ['h', 'e', 'l', 'l', 'o', 0];
+    size_t sz = 0;
+    auto f = open_wmemstream(&ptr, &sz);
+    assert(f !is null);
+    assert(fwprintf(f, testdata.ptr) == 5);
+    assert(fflush(f) == 0);
+    assert(memcmp(ptr, testdata.ptr, testdata.length*wchar_t.sizeof) == 0);
+    assert(fclose(f) == 0);
+}
diff --git a/libphobos/libdruntime/core/sys/posix/stdlib.d b/libphobos/libdruntime/core/sys/posix/stdlib.d
new file mode 100644
index 00000000000..189cef6dd1c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/stdlib.d
@@ -0,0 +1,423 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.stdlib;
+
+private import core.sys.posix.config;
+public import core.stdc.stdlib;
+public import core.sys.posix.sys.wait;
+
+version (Posix):
+extern (C):
+nothrow:
+@nogc:
+
+//
+// Required (defined in core.stdc.stdlib)
+//
+/*
+EXIT_FAILURE
+EXIT_SUCCESS
+NULL
+RAND_MAX
+MB_CUR_MAX
+div_t
+ldiv_t
+lldiv_t
+size_t
+wchar_t
+
+void    _Exit(int);
+void    abort();
+int     abs(int);
+int     atexit(void function());
+double  atof(in char*);
+int     atoi(in char*);
+c_long  atol(in char*);
+long    atoll(in char*);
+void*   bsearch(in void*, in void*, size_t, size_t, int function(in void*, in void*));
+void*   calloc(size_t, size_t);
+div_t   div(int, int);
+void    exit(int);
+void    free(void*);
+char*   getenv(in char*);
+c_long  labs(c_long);
+ldiv_t  ldiv(c_long, c_long);
+long    llabs(long);
+lldiv_t lldiv(long, long);
+void*   malloc(size_t);
+int     mblen(in char*, size_t);
+size_t  mbstowcs(wchar_t*, in char*, size_t);
+int     mbtowc(wchar_t*, in char*, size_t);
+void    qsort(void*, size_t, size_t, int function(in void*, in void*));
+int     rand();
+void*   realloc(void*, size_t);
+void    srand(uint);
+double  strtod(in char*, char**);
+float   strtof(in char*, char**);
+c_long  strtol(in char*, char**, int);
+real    strtold(in char*, char**);
+long    strtoll(in char*, char**, int);
+c_ulong strtoul(in char*, char**, int);
+ulong   strtoull(in char*, char**, int);
+int     system(in char*);
+size_t  wcstombs(char*, in wchar_t*, size_t);
+int     wctomb(char*, wchar_t);
+*/
+
+//
+// Advisory Information (ADV)
+//
+/*
+int posix_memalign(void**, size_t, size_t);
+*/
+
+version( CRuntime_Glibc )
+{
+    int posix_memalign(void**, size_t, size_t);
+}
+else version( FreeBSD )
+{
+    int posix_memalign(void**, size_t, size_t);
+}
+else version( Solaris )
+{
+    int posix_memalign(void**, size_t, size_t);
+}
+
+//
+// C Extension (CX)
+//
+/*
+int setenv(in char*, in char*, int);
+int unsetenv(in char*);
+*/
+
+version( CRuntime_Glibc )
+{
+    int setenv(in char*, in char*, int);
+    int unsetenv(in char*);
+
+    void* valloc(size_t); // LEGACY non-standard
+}
+else version( OSX )
+{
+    int setenv(in char*, in char*, int);
+    int unsetenv(in char*);
+
+    void* valloc(size_t); // LEGACY non-standard
+}
+else version( FreeBSD )
+{
+    int setenv(in char*, in char*, int);
+    int unsetenv(in char*);
+
+    void* valloc(size_t); // LEGACY non-standard
+}
+else version( CRuntime_Bionic )
+{
+    int setenv(in char*, in char*, int);
+    int unsetenv(in char*);
+
+    void* valloc(size_t);
+}
+else version( Solaris )
+{
+    int setenv(in char*, in char*, int);
+    int unsetenv(in char*);
+
+    void* valloc(size_t); // LEGACY non-standard
+}
+
+//
+// Thread-Safe Functions (TSF)
+//
+/*
+int rand_r(uint*);
+*/
+
+version( CRuntime_Glibc )
+{
+    int rand_r(uint*);
+}
+else version( OSX )
+{
+    int rand_r(uint*);
+}
+else version( FreeBSD )
+{
+    int rand_r(uint*);
+}
+else version( Solaris )
+{
+    int rand_r(uint*);
+}
+
+//
+// XOpen (XSI)
+//
+/*
+WNOHANG     (defined in core.sys.posix.sys.wait)
+WUNTRACED   (defined in core.sys.posix.sys.wait)
+WEXITSTATUS (defined in core.sys.posix.sys.wait)
+WIFEXITED   (defined in core.sys.posix.sys.wait)
+WIFSIGNALED (defined in core.sys.posix.sys.wait)
+WIFSTOPPED  (defined in core.sys.posix.sys.wait)
+WSTOPSIG    (defined in core.sys.posix.sys.wait)
+WTERMSIG    (defined in core.sys.posix.sys.wait)
+
+c_long a64l(in char*);
+double drand48();
+char*  ecvt(double, int, int *, int *); // LEGACY
+double erand48(ref ushort[3]);
+char*  fcvt(double, int, int *, int *); // LEGACY
+char*  gcvt(double, int, char*); // LEGACY
+// per spec: int getsubopt(char** char* const*, char**);
+int    getsubopt(char**, in char**, char**);
+int    grantpt(int);
+char*  initstate(uint, char*, size_t);
+c_long jrand48(ref ushort[3]);
+char*  l64a(c_long);
+void   lcong48(ref ushort[7]);
+c_long lrand48();
+char*  mktemp(char*); // LEGACY
+int    mkstemp(char*);
+int    mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
+c_long mrand48();
+c_long nrand48(ref ushort[3]);
+int    posix_openpt(int);
+char*  ptsname(int);
+int    putenv(char*);
+c_long random();
+char*  realpath(in char*, char*);
+ushort *seed48(ref ushort[3]);
+void   setkey(in char*);
+char*  setstate(in char*);
+void   srand48(c_long);
+void   srandom(uint);
+int    unlockpt(int);
+*/
+
+version( CRuntime_Glibc )
+{
+    //WNOHANG     (defined in core.sys.posix.sys.wait)
+    //WUNTRACED   (defined in core.sys.posix.sys.wait)
+    //WEXITSTATUS (defined in core.sys.posix.sys.wait)
+    //WIFEXITED   (defined in core.sys.posix.sys.wait)
+    //WIFSIGNALED (defined in core.sys.posix.sys.wait)
+    //WIFSTOPPED  (defined in core.sys.posix.sys.wait)
+    //WSTOPSIG    (defined in core.sys.posix.sys.wait)
+    //WTERMSIG    (defined in core.sys.posix.sys.wait)
+
+    c_long a64l(in char*);
+    double drand48();
+    char*  ecvt(double, int, int *, int *); // LEGACY
+    double erand48(ref ushort[3]);
+    char*  fcvt(double, int, int *, int *); // LEGACY
+    char*  gcvt(double, int, char*); // LEGACY
+    int    getsubopt(char**, in char**, char**);
+    int    grantpt(int);
+    char*  initstate(uint, char*, size_t);
+    c_long jrand48(ref ushort[3]);
+    char*  l64a(c_long);
+    void   lcong48(ref ushort[7]);
+    c_long lrand48();
+    char*  mktemp(char*); // LEGACY
+    //int    mkstemp(char*);
+    char*  mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
+    c_long mrand48();
+    c_long nrand48(ref ushort[3]);
+    int    posix_openpt(int);
+    char*  ptsname(int);
+    int    putenv(char*);
+    c_long random();
+    char*  realpath(in char*, char*);
+    ushort *seed48(ref ushort[3]);
+    void   setkey(in char*);
+    char*  setstate(in char*);
+    void   srand48(c_long);
+    void   srandom(uint);
+    int    unlockpt(int);
+
+  static if( __USE_LARGEFILE64 )
+  {
+    int    mkstemp64(char*);
+    alias  mkstemp64 mkstemp;
+  }
+  else
+  {
+    int    mkstemp(char*);
+  }
+}
+else version( OSX )
+{
+    //WNOHANG     (defined in core.sys.posix.sys.wait)
+    //WUNTRACED   (defined in core.sys.posix.sys.wait)
+    //WEXITSTATUS (defined in core.sys.posix.sys.wait)
+    //WIFEXITED   (defined in core.sys.posix.sys.wait)
+    //WIFSIGNALED (defined in core.sys.posix.sys.wait)
+    //WIFSTOPPED  (defined in core.sys.posix.sys.wait)
+    //WSTOPSIG    (defined in core.sys.posix.sys.wait)
+    //WTERMSIG    (defined in core.sys.posix.sys.wait)
+
+    c_long a64l(in char*);
+    double drand48();
+    char*  ecvt(double, int, int *, int *); // LEGACY
+    double erand48(ref ushort[3]);
+    char*  fcvt(double, int, int *, int *); // LEGACY
+    char*  gcvt(double, int, char*); // LEGACY
+    int    getsubopt(char**, in char**, char**);
+    int    grantpt(int);
+    char*  initstate(uint, char*, size_t);
+    c_long jrand48(ref ushort[3]);
+    char*  l64a(c_long);
+    void   lcong48(ref ushort[7]);
+    c_long lrand48();
+    char*  mktemp(char*); // LEGACY
+    int    mkstemp(char*);
+    char*  mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
+    c_long mrand48();
+    c_long nrand48(ref ushort[3]);
+    int    posix_openpt(int);
+    char*  ptsname(int);
+    int    putenv(char*);
+    c_long random();
+    char*  realpath(in char*, char*);
+    ushort *seed48(ref ushort[3]);
+    void   setkey(in char*);
+    char*  setstate(in char*);
+    void   srand48(c_long);
+    void   srandom(uint);
+    int    unlockpt(int);
+}
+else version( FreeBSD )
+{
+    //WNOHANG     (defined in core.sys.posix.sys.wait)
+    //WUNTRACED   (defined in core.sys.posix.sys.wait)
+    //WEXITSTATUS (defined in core.sys.posix.sys.wait)
+    //WIFEXITED   (defined in core.sys.posix.sys.wait)
+    //WIFSIGNALED (defined in core.sys.posix.sys.wait)
+    //WIFSTOPPED  (defined in core.sys.posix.sys.wait)
+    //WSTOPSIG    (defined in core.sys.posix.sys.wait)
+    //WTERMSIG    (defined in core.sys.posix.sys.wait)
+
+    c_long a64l(in char*);
+    double drand48();
+    //char*  ecvt(double, int, int *, int *); // LEGACY
+    double erand48(ref ushort[3]);
+    //char*  fcvt(double, int, int *, int *); // LEGACY
+    //char*  gcvt(double, int, char*); // LEGACY
+    int    getsubopt(char**, in char**, char**);
+    int    grantpt(int);
+    char*  initstate(uint, char*, size_t);
+    c_long jrand48(ref ushort[3]);
+    char*  l64a(c_long);
+    void   lcong48(ref ushort[7]);
+    c_long lrand48();
+    char*  mktemp(char*); // LEGACY
+    int    mkstemp(char*);
+    char*  mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
+    c_long mrand48();
+    c_long nrand48(ref ushort[3]);
+    int    posix_openpt(int);
+    char*  ptsname(int);
+    int    putenv(char*);
+    c_long random();
+    char*  realpath(in char*, char*);
+    ushort *seed48(ref ushort[3]);
+    void   setkey(in char*);
+    char*  setstate(in char*);
+    void   srand48(c_long);
+    void   srandom(uint);
+    int    unlockpt(int);
+}
+else version( CRuntime_Bionic )
+{
+    double  drand48();
+    double  erand48(ref ushort[3]);
+    //int   grantpt(int); defined inline, but seems to do nothing in bionic
+    c_long  jrand48(ref ushort[3]);
+    c_long  lrand48();
+    char*   mktemp(char*); // LEGACY
+    int     mkstemp(char*);
+    char*   mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
+    c_long  mrand48();
+    c_long  nrand48(ref ushort[3]);
+    char*   ptsname(int);
+    int     putenv(in char*);
+    c_long  random() { return lrand48(); }
+    char*   realpath(in char*, char*);
+    ushort* seed48(ref ushort[3]);
+    void    srand48(c_long);
+    void    srandom(uint s) { srand48(s); }
+    int     unlockpt(int);
+}
+else version( Solaris )
+{
+    //WNOHANG     (defined in core.sys.posix.sys.wait)
+    //WUNTRACED   (defined in core.sys.posix.sys.wait)
+    //WEXITSTATUS (defined in core.sys.posix.sys.wait)
+    //WIFEXITED   (defined in core.sys.posix.sys.wait)
+    //WIFSIGNALED (defined in core.sys.posix.sys.wait)
+    //WIFSTOPPED  (defined in core.sys.posix.sys.wait)
+    //WSTOPSIG    (defined in core.sys.posix.sys.wait)
+    //WTERMSIG    (defined in core.sys.posix.sys.wait)
+
+    c_long a64l(in char*);
+    double drand48();
+    char*  ecvt(double, int, int *, int *); // LEGACY
+    double erand48(ref ushort[3]);
+    char*  fcvt(double, int, int *, int *); // LEGACY
+    char*  gcvt(double, int, char*); // LEGACY
+    int    getsubopt(char**, in char**, char**);
+    int    grantpt(int);
+    char*  initstate(uint, char*, size_t);
+    c_long jrand48(ref ushort[3]);
+    char*  l64a(c_long);
+    void   lcong48(ref ushort[7]);
+    c_long lrand48();
+    char*  mktemp(char*); // LEGACY
+    //int    mkstemp(char*);
+    char*  mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
+    c_long mrand48();
+    c_long nrand48(ref ushort[3]);
+    int    posix_openpt(int);
+    char*  ptsname(int);
+    int    putenv(char*);
+    c_long random();
+    char*  realpath(in char*, char*);
+    ushort *seed48(ref ushort[3]);
+    void   setkey(in char*);
+    char*  setstate(in char*);
+    void   srand48(c_long);
+    void   srandom(uint);
+    int    unlockpt(int);
+
+    version (D_LP64)
+    {
+        int mkstemp(char*);
+
+        static if ( __USE_LARGEFILE64 )
+            alias mkstemp mkstemp64;
+    }
+    else
+    {
+        int mkstemp64(char*);
+
+        static if ( __USE_LARGEFILE64 )
+            alias mkstemp64 mkstemp;
+        else
+            int mkstemp(char*);
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/ioctl.d b/libphobos/libdruntime/core/sys/posix/sys/ioctl.d
new file mode 100644
index 00000000000..13168f719cc
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/ioctl.d
@@ -0,0 +1,373 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Alex Rønne Petersen 2011 - 2012.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Alex Rønne Petersen 2011 - 2012.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.sys.ioctl;
+
+import core.stdc.config;
+
+version (Posix):
+
+extern (C) nothrow @nogc:
+
+version (CRuntime_Glibc)
+{
+    import core.sys.posix.termios; // tcflag_t, speed_t, cc_t
+
+    enum _IOC_NRBITS = 8;
+    enum _IOC_TYPEBITS = 8;
+    enum _IOC_SIZEBITS = 14;
+    enum _IOC_DIRBITS = 2;
+
+    enum _IOC_NRMASK = (1 << _IOC_NRBITS) - 1;
+    enum _IOC_TYPEMASK = (1 << _IOC_TYPEBITS) - 1;
+    enum _IOC_SIZEMASK = (1 << _IOC_SIZEBITS) - 1;
+    enum _IOC_DIRMASK = (1 << _IOC_DIRBITS) - 1;
+
+    enum _IOC_NRSHIFT = 0;
+    enum _IOC_TYPESHIFT = _IOC_NRSHIFT + _IOC_NRBITS;
+    enum _IOC_SIZESHIFT = _IOC_TYPESHIFT + _IOC_TYPEBITS;
+    enum _IOC_DIRSHIFT = _IOC_SIZESHIFT + _IOC_SIZEBITS;
+
+    enum _IOC_NONE = 0;
+    enum _IOC_WRITE = 1;
+    enum _IOC_READ = 2;
+
+    extern (D) int _IOC(T = typeof(null))(int dir, int type, int nr)
+    {
+        return (dir << _IOC_DIRSHIFT) |
+               (type << _IOC_TYPESHIFT) |
+               (nr << _IOC_NRSHIFT) |
+               (is(T == typeof(null)) ? 0 : T.sizeof << _IOC_SIZESHIFT);
+    }
+
+    extern (D) int _IO(int type, int nr)
+    {
+        return _IOC(_IOC_NONE, type, nr);
+    }
+
+    extern (D) int _IOR(T)(int type, int nr)
+    {
+        return _IOC!T(_IOC_READ, type, nr);
+    }
+
+    extern (D) int _IOW(T)(int type, int nr)
+    {
+        return _IOC!T(_IOC_WRITE, type, nr);
+    }
+
+    extern (D) int _IOWR(T)(int type, int nr)
+    {
+        return _IOC!T(_IOC_READ | _IOC_WRITE, type, nr);
+    }
+
+    extern (D) int _IOC_DIR(int nr)
+    {
+        return (nr >> _IOC_DIRSHIFT) & _IOC_DIRMASK;
+    }
+
+    extern (D) int _IOC_TYPE(int nr)
+    {
+        return (nr >> _IOC_TYPESHIFT) & _IOC_TYPEMASK;
+    }
+
+    extern (D) int _IOC_NR(int nr)
+    {
+        return (nr >> _IOC_NRSHIFT) & _IOC_NRMASK;
+    }
+
+    extern (D) int _IOC_SIZE(int nr)
+    {
+        return (nr >> _IOC_SIZESHIFT) & _IOC_SIZEMASK;
+    }
+
+    enum IOC_IN = _IOC_WRITE << _IOC_DIRSHIFT;
+    enum IOC_OUT = _IOC_READ << _IOC_DIRSHIFT;
+    enum IOC_INOUT = (_IOC_READ | _IOC_WRITE) << _IOC_DIRSHIFT;
+    enum IOCSIZE_MASK = _IOC_SIZEMASK << _IOC_DIRSHIFT;
+    enum IOCSIZE_SHIFT = _IOC_SIZESHIFT;
+
+    enum NCCS = 19;
+
+    struct termios2
+    {
+        tcflag_t c_iflag;
+        tcflag_t c_oflag;
+        tcflag_t c_cflag;
+        tcflag_t c_lflag;
+        cc_t c_line;
+        cc_t[NCCS] c_cc;
+        speed_t c_ispeed;
+        speed_t c_ospeed;
+    }
+
+    struct winsize
+    {
+        ushort ws_row;
+        ushort ws_col;
+        ushort ws_xpixel;
+        ushort ws_ypixel;
+    }
+
+    enum NCC = 8;
+
+    struct termio
+    {
+        ushort c_iflag;
+        ushort c_oflag;
+        ushort c_cflag;
+        ushort c_lflag;
+        ubyte c_line;
+        ubyte[NCC] c_cc;
+    }
+
+    enum TIOCM_LE = 0x001;
+    enum TIOCM_DTR = 0x002;
+    enum TIOCM_RTS = 0x004;
+    enum TIOCM_ST = 0x008;
+    enum TIOCM_SR = 0x010;
+    enum TIOCM_CTS = 0x020;
+    enum TIOCM_CAR = 0x040;
+    enum TIOCM_RNG = 0x080;
+    enum TIOCM_DSR = 0x100;
+    enum TIOCM_CD = TIOCM_CAR;
+    enum TIOCM_RI = TIOCM_RNG;
+
+    enum N_TTY = 0;
+    enum N_SLIP = 1;
+    enum N_MOUSE = 2;
+    enum N_PPP = 3;
+    enum N_STRIP = 4;
+    enum N_AX25 = 5;
+    enum N_X25 = 6;
+    enum N_6PACK = 7;
+    enum N_MASC = 8;
+    enum N_R3964 = 9;
+    enum N_PROFIBUS_FDL = 10;
+    enum N_IRDA = 11;
+    enum N_SMSBLOCK = 12;
+    enum N_HDLC = 13;
+    enum N_SYNC_PPP = 14;
+    enum N_HCI = 15;
+
+    enum TCGETS = 0x5401;
+    enum TCSETS = 0x5402;
+    enum TCSETSW = 0x5403;
+    enum TCSETSF = 0x5404;
+    enum TCGETA = 0x5405;
+    enum TCSETA = 0x5406;
+    enum TCSETAW = 0x5407;
+    enum TCSETAF = 0x5408;
+    enum TCSBRK = 0x5409;
+    enum TCXONC = 0x540A;
+    enum TCFLSH = 0x540B;
+    enum TIOCEXCL = 0x540C;
+    enum TIOCNXCL = 0x540D;
+    enum TIOCSCTTY = 0x540E;
+    enum TIOCGPGRP = 0x540F;
+    enum TIOCSPGRP = 0x5410;
+    enum TIOCOUTQ = 0x5411;
+    enum TIOCSTI = 0x5412;
+    enum TIOCGWINSZ = 0x5413;
+    enum TIOCSWINSZ = 0x5414;
+    enum TIOCMGET = 0x5415;
+    enum TIOCMBIS = 0x5416;
+    enum TIOCMBIC = 0x5417;
+    enum TIOCMSET = 0x5418;
+    enum TIOCGSOFTCAR = 0x5419;
+    enum TIOCSSOFTCAR = 0x541A;
+    enum FIONREAD = 0x541B;
+    enum TIOCINQ = FIONREAD;
+    enum TIOCLINUX = 0x541C;
+    enum TIOCCONS = 0x541D;
+    enum TIOCGSERIAL = 0x541E;
+    enum TIOCSSERIAL = 0x541F;
+    enum TIOCPKT = 0x5420;
+    enum FIONBIO = 0x5421;
+    enum TIOCNOTTY = 0x5422;
+    enum TIOCSETD = 0x5423;
+    enum TIOCGETD = 0x5424;
+    enum TCSBRKP = 0x5425;
+    enum TIOCSBRK = 0x5427;
+    enum TIOCCBRK = 0x5428;
+    enum TIOCGSID = 0x5429;
+
+    enum TCGETS2 = _IOR!termios2('T', 0x2A);
+    enum TCSETS2 = _IOR!termios2('T', 0x2B);
+    enum TCSETSW2 = _IOW!termios2('T', 0x2C);
+    enum TCSETSF2 = _IOW!termios2('T', 0x2D);
+
+    enum TIOCGRS485 = 0x542E;
+    enum TIOCSRS485 = 0x542F;
+
+    enum TIOCGPTN   = _IOR!uint('T', 0x30);
+    enum TIOCSPTLCK = _IOW!int('T', 0x31);
+    enum TIOCGDEV   = _IOR!uint('T', 0x32);
+
+    enum TCGETX = 0x5432;
+    enum TCSETX = 0x5433;
+    enum TCSETXF = 0x5434;
+    enum TCSETXW = 0x5435;
+
+    enum TIOCSIG = _IOW!int('T', 0x36);
+
+    enum TIOCVHANGUP = 0x5437;
+
+    enum FIONCLEX = 0x5450;
+    enum FIOCLEX = 0x5451;
+    enum FIOASYNC = 0x5452;
+    enum TIOCSERCONFIG = 0x5453;
+    enum TIOCSERGWILD = 0x5454;
+    enum TIOCSERSWILD = 0x5455;
+    enum TIOCGLCKTRMIOS = 0x5456;
+    enum TIOCSLCKTRMIOS = 0x5457;
+    enum TIOCSERGSTRUCT = 0x5458;
+    enum TIOCSERGETLSR = 0x5459;
+    enum TIOCSERGETMULTI = 0x545A;
+    enum TIOCSERSETMULTI = 0x545B;
+
+    enum TIOCMIWAIT = 0x545C;
+    enum TIOCGICOUNT = 0x545D;
+
+    enum FIOQSIZE = 0x5460;
+
+    enum TIOCPKT_DATA = 0;
+    enum TIOCPKT_FLUSHREAD = 1;
+    enum TIOCPKT_FLUSHWRITE = 2;
+    enum TIOCPKT_STOP = 4;
+    enum TIOCPKT_START = 8;
+    enum TIOCPKT_NOSTOP = 16;
+    enum TIOCPKT_DOSTOP = 32;
+    enum TIOCPKT_IOCTL = 64;
+
+    enum TIOCSER_TEMT = 0x01;
+
+    enum SIOCADDRT = 0x890B;
+    enum SIOCDELRT = 0x890C;
+    enum SIOCRTMSG = 0x890D;
+
+    enum SIOCGIFNAME = 0x8910;
+    enum SIOCSIFLINK = 0x8911;
+    enum SIOCGIFCONF = 0x8912;
+    enum SIOCGIFFLAGS = 0x8913;
+    enum SIOCSIFFLAGS = 0x8914;
+    enum SIOCGIFADDR = 0x8915;
+    enum SIOCSIFADDR = 0x8916;
+    enum SIOCGIFDSTADDR = 0x8917;
+    enum SIOCSIFDSTADDR = 0x8918;
+    enum SIOCGIFBRDADDR = 0x8919;
+    enum SIOCSIFBRDADDR = 0x891a;
+    enum SIOCGIFNETMASK = 0x891b;
+    enum SIOCSIFNETMASK = 0x891c;
+    enum SIOCGIFMETRIC = 0x891d;
+    enum SIOCSIFMETRIC = 0x891e;
+    enum SIOCGIFMEM = 0x891f;
+    enum SIOCSIFMEM = 0x8920;
+    enum SIOCGIFMTU = 0x8921;
+    enum SIOCSIFMTU = 0x8922;
+    enum SIOCSIFNAME = 0x8923;
+    enum SIOCSIFHWADDR = 0x8924;
+    enum SIOCGIFENCAP = 0x8925;
+    enum SIOCSIFENCAP = 0x8926;
+    enum SIOCGIFHWADDR = 0x8927;
+    enum SIOCGIFSLAVE = 0x8929;
+    enum SIOCSIFSLAVE = 0x8930;
+    enum SIOCADDMULTI = 0x8931;
+    enum SIOCDELMULTI = 0x8932;
+    enum SIOCGIFINDEX = 0x8933;
+    enum SIOGIFINDEX = SIOCGIFINDEX;
+    enum SIOCSIFPFLAGS = 0x8934;
+    enum SIOCGIFPFLAGS = 0x8935;
+    enum SIOCDIFADDR = 0x8936;
+    enum SIOCSIFHWBROADCAST = 0x8937;
+    enum SIOCGIFCOUNT = 0x8938;
+
+    enum SIOCGIFBR = 0x8940;
+    enum SIOCSIFBR = 0x8941;
+
+    enum SIOCGIFTXQLEN = 0x8942;
+    enum SIOCSIFTXQLEN = 0x8943;
+
+    enum SIOCDARP = 0x8953;
+    enum SIOCGARP = 0x8954;
+    enum SIOCSARP = 0x8955;
+
+    enum SIOCDRARP = 0x8960;
+    enum SIOCGRARP = 0x8961;
+    enum SIOCSRARP = 0x8962;
+
+    enum SIOCGIFMAP = 0x8970;
+    enum SIOCSIFMAP = 0x8971;
+
+    enum SIOCADDDLCI = 0x8980;
+    enum SIOCDELDLCI = 0x8981;
+
+    enum SIOCDEVPRIVATE = 0x89F0;
+
+    enum SIOCPROTOPRIVATE = 0x89E0;
+
+    int ioctl(int __fd, c_ulong __request, ...);
+}
+else version (OSX)
+{
+    import core.sys.posix.termios; // termios
+    import core.sys.posix.sys.time; // timeval
+
+    struct winsize
+    {
+        ushort ws_row;
+        ushort ws_col;
+        ushort ws_xpixel;
+        ushort ws_ypixel;
+    }
+
+    struct ttysize
+    {
+        ushort ts_lines;
+        ushort ts_cols;
+        ushort ts_xxx;
+        ushort ts_yyy;
+    }
+
+    int ioctl(int fildes, c_ulong request, ...);
+}
+else version (FreeBSD)
+{
+    struct fiodgname_arg
+    {
+        int len;
+        void* buf;
+    }
+
+    struct winsize
+    {
+        ushort ws_row;
+        ushort ws_col;
+        ushort ws_xpixel;
+        ushort ws_ypixel;
+    }
+
+    int ioctl(int, c_ulong, ...);
+}
+else version (Solaris)
+{
+    int ioctl(int fildes, int request, ...);
+}
+else version (CRuntime_Bionic)
+{
+    int ioctl(int, int, ...);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/ipc.d b/libphobos/libdruntime/core/sys/posix/sys/ipc.d
new file mode 100644
index 00000000000..07892a060da
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/ipc.d
@@ -0,0 +1,163 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.sys.ipc;
+
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types; // for uid_t, gid_t, mode_t, key_t
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// XOpen (XSI)
+//
+/*
+struct ipc_perm
+{
+    uid_t    uid;
+    gid_t    gid;
+    uid_t    cuid;
+    gid_t    cgid;
+    mode_t   mode;
+}
+
+IPC_CREAT
+IPC_EXCL
+IPC_NOWAIT
+
+IPC_PRIVATE
+
+IPC_RMID
+IPC_SET
+IPC_STAT
+
+key_t ftok(in char*, int);
+*/
+
+version( CRuntime_Glibc )
+{
+    struct ipc_perm
+    {
+        key_t   __key;
+        uid_t   uid;
+        gid_t   gid;
+        uid_t   cuid;
+        gid_t   cgid;
+        ushort  mode;
+        ushort  __pad1;
+        ushort  __seq;
+        ushort  __pad2;
+        c_ulong __unused1;
+        c_ulong __unused2;
+    }
+
+    enum IPC_CREAT      = 0x0200; // 01000
+    enum IPC_EXCL       = 0x0400; // 02000
+    enum IPC_NOWAIT     = 0x0800; // 04000
+
+    enum key_t IPC_PRIVATE = 0;
+
+    enum IPC_RMID       = 0;
+    enum IPC_SET        = 1;
+    enum IPC_STAT       = 2;
+
+    key_t ftok(in char*, int);
+}
+else version( OSX )
+{
+
+}
+else version( FreeBSD )
+{
+    struct ipc_perm_old // <= FreeBSD7
+    {
+        ushort cuid;
+        ushort cguid;
+        ushort uid;
+        ushort gid;
+        ushort mode;
+        ushort seq;
+        key_t key;
+    }
+
+    struct ipc_perm
+    {
+        uid_t   cuid;
+        gid_t   cgid;
+        uid_t   uid;
+        gid_t   gid;
+        mode_t  mode;
+        ushort  seq;
+        key_t   key;
+    }
+
+    enum IPC_CREAT      = 0x0200; // 01000
+    enum IPC_EXCL       = 0x0400; // 02000
+    enum IPC_NOWAIT     = 0x0800; // 04000
+
+    enum key_t IPC_PRIVATE = 0;
+
+    enum IPC_RMID       = 0;
+    enum IPC_SET        = 1;
+    enum IPC_STAT       = 2;
+
+    key_t ftok(in char*, int);
+}
+else version( CRuntime_Bionic )
+{
+    // All except ftok are from the linux kernel headers.
+    version (X86)
+    {
+        struct ipc_perm
+        {
+            key_t   key;
+            ushort  uid;
+            ushort  gid;
+            ushort  cuid;
+            ushort  cgid;
+            mode_t  mode;
+            ushort  seq;
+        }
+    }
+    else version (ARM)
+    {
+        struct ipc_perm
+        {
+            key_t   key;
+            ushort  uid;
+            ushort  gid;
+            ushort  cuid;
+            ushort  cgid;
+            mode_t  mode;
+            ushort  seq;
+        }
+    }
+    else
+    {
+        static assert(false, "Architecture not supported.");
+    }
+
+    enum IPC_CREAT      = 0x0200; // 01000
+    enum IPC_EXCL       = 0x0400; // 02000
+    enum IPC_NOWAIT     = 0x0800; // 04000
+
+    enum key_t IPC_PRIVATE = 0;
+
+    enum IPC_RMID       = 0;
+    enum IPC_SET        = 1;
+    enum IPC_STAT       = 2;
+
+    key_t ftok(in char*, int);
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/mman.d b/libphobos/libdruntime/core/sys/posix/sys/mman.d
new file mode 100644
index 00000000000..94a84eebcc5
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/mman.d
@@ -0,0 +1,575 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.sys.mman;
+
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types; // for off_t, mode_t
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// Advisory Information (ADV)
+//
+/*
+int posix_madvise(void*, size_t, int);
+*/
+
+//
+// Advisory Information and either Memory Mapped Files or Shared Memory Objects (MC1)
+//
+/*
+POSIX_MADV_NORMAL
+POSIX_MADV_SEQUENTIAL
+POSIX_MADV_RANDOM
+POSIX_MADV_WILLNEED
+POSIX_MADV_DONTNEED
+*/
+
+version( CRuntime_Glibc )
+{
+    version (Alpha)
+        private enum __POSIX_MADV_DONTNEED = 6;
+    else
+        private enum __POSIX_MADV_DONTNEED = 4;
+
+    static if (__USE_XOPEN2K)
+    {
+        enum
+        {
+            POSIX_MADV_NORMAL = 0,
+            POSIX_MADV_RANDOM = 1,
+            POSIX_MADV_SEQUENTIAL = 2,
+            POSIX_MADV_WILLNEED = 3,
+            POSIX_MADV_DONTNEED = __POSIX_MADV_DONTNEED,
+        }
+        int posix_madvise(void *__addr, size_t __len, int __advice);
+    }
+}
+else version( OSX )
+{
+    enum POSIX_MADV_NORMAL      = 0;
+    enum POSIX_MADV_RANDOM      = 1;
+    enum POSIX_MADV_SEQUENTIAL  = 2;
+    enum POSIX_MADV_WILLNEED    = 3;
+    enum POSIX_MADV_DONTNEED    = 4;
+    int posix_madvise(void *addr, size_t len, int advice);
+}
+else version( FreeBSD )
+{
+    enum POSIX_MADV_NORMAL      = 0;
+    enum POSIX_MADV_RANDOM      = 1;
+    enum POSIX_MADV_SEQUENTIAL  = 2;
+    enum POSIX_MADV_WILLNEED    = 3;
+    enum POSIX_MADV_DONTNEED    = 4;
+    int posix_madvise(void *addr, size_t len, int advice);
+}
+else version (Solaris)
+{
+}
+else version (CRuntime_Bionic)
+{
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Memory Mapped Files, Shared Memory Objects, or Memory Protection (MC2)
+//
+/*
+PROT_READ
+PROT_WRITE
+PROT_EXEC
+PROT_NONE
+*/
+
+version( CRuntime_Glibc )
+{
+    enum PROT_NONE      = 0x0;
+    enum PROT_READ      = 0x1;
+    enum PROT_WRITE     = 0x2;
+    enum PROT_EXEC      = 0x4;
+}
+else version( OSX )
+{
+    enum PROT_NONE      = 0x00;
+    enum PROT_READ      = 0x01;
+    enum PROT_WRITE     = 0x02;
+    enum PROT_EXEC      = 0x04;
+}
+else version( FreeBSD )
+{
+    enum PROT_NONE      = 0x00;
+    enum PROT_READ      = 0x01;
+    enum PROT_WRITE     = 0x02;
+    enum PROT_EXEC      = 0x04;
+}
+else version (Solaris)
+{
+    enum PROT_NONE = 0x00;
+    enum PROT_READ = 0x01;
+    enum PROT_WRITE = 0x02;
+    enum PROT_EXEC = 0x04;
+}
+else version (CRuntime_Bionic)
+{
+    enum PROT_NONE = 0x00;
+    enum PROT_READ = 0x01;
+    enum PROT_WRITE = 0x02;
+    enum PROT_EXEC = 0x04;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Memory Mapped Files, Shared Memory Objects, or Typed Memory Objects (MC3)
+//
+/*
+void* mmap(void*, size_t, int, int, int, off_t);
+int munmap(void*, size_t);
+*/
+
+version( CRuntime_Glibc )
+{
+    static if (__USE_LARGEFILE64) void* mmap64(void*, size_t, int, int, int, off_t);
+    static if (__USE_FILE_OFFSET64)
+        alias mmap = mmap64;
+    else
+        void* mmap(void*, size_t, int, int, int, off_t);
+    int munmap(void*, size_t);
+}
+else version( OSX )
+{
+    void* mmap(void*, size_t, int, int, int, off_t);
+    int   munmap(void*, size_t);
+}
+else version( FreeBSD )
+{
+    void* mmap(void*, size_t, int, int, int, off_t);
+    int   munmap(void*, size_t);
+}
+else version (Solaris)
+{
+    void* mmap(void*, size_t, int, int, int, off_t);
+    int   munmap(void*, size_t);
+}
+else version (CRuntime_Bionic)
+{
+    void* mmap(void*, size_t, int, int, int, off_t);
+    int   munmap(void*, size_t);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Memory Mapped Files (MF)
+//
+/*
+MAP_SHARED (MF|SHM)
+MAP_PRIVATE (MF|SHM)
+MAP_FIXED  (MF|SHM)
+MAP_FAILED (MF|SHM)
+
+MS_ASYNC (MF|SIO)
+MS_SYNC (MF|SIO)
+MS_INVALIDATE (MF|SIO)
+
+int msync(void*, size_t, int); (MF|SIO)
+*/
+
+version( CRuntime_Glibc )
+{
+    enum MAP_SHARED     = 0x01;
+    enum MAP_PRIVATE    = 0x02;
+    enum MAP_FIXED      = 0x10;
+
+    enum MAP_FAILED     = cast(void*) -1;
+
+    version (MICROBLAZE)
+        private enum DEFAULTS = true;
+    else version (Alpha)
+    {
+        private enum DEFAULTS = false;
+        enum MAP_ANON = 0x10;
+        enum MS_ASYNC = 1;
+        enum MS_SYNC = 2;
+        enum MS_INVALIDATE = 4;
+    }
+    else version (SH)
+        private enum DEFAULTS = true;
+    else version (SH64)
+        private enum DEFAULTS = true;
+    else version (AArch64)
+        private enum DEFAULTS = true;
+    else version (ARM)
+        private enum DEFAULTS = true;
+    else version (S390)
+        private enum DEFAULTS = true;
+    else version (SystemZ)
+        private enum DEFAULTS = true;
+    else version (IA64)
+        private enum DEFAULTS = true;
+    else version (HPPA)
+    {
+        private enum DEFAULTS = false;
+        enum MAP_ANON = 0x10;
+        enum MS_SYNC = 1;
+        enum MS_ASYNC = 2;
+        enum MS_INVALIDATE = 4;
+    }
+    else version (HPPA64)
+    {
+        private enum DEFAULTS = false;
+        enum MAP_ANON = 0x10;
+        enum MS_SYNC = 1;
+        enum MS_ASYNC = 2;
+        enum MS_INVALIDATE = 4;
+    }
+    else version (M68K)
+        private enum DEFAULTS = true;
+    else version (TILE)
+        private enum DEFAULTS = true;
+    else version (X86)
+        private enum DEFAULTS = true;
+    else version (X86_64)
+        private enum DEFAULTS = true;
+    else version (MIPS32)
+    {
+        private enum DEFAULTS = false;
+        enum MAP_ANON = 0x0800;
+        enum MS_ASYNC = 1;
+        enum MS_INVALIDATE = 2;
+        enum MS_SYNC = 4;
+    }
+    else version (MIPS64)
+    {
+        private enum DEFAULTS = false;
+        enum MAP_ANON = 0x0800;
+        enum MS_ASYNC = 1;
+        enum MS_INVALIDATE = 2;
+        enum MS_SYNC = 4;
+    }
+    else version (SPARC)
+        private enum DEFAULTS = true;
+    else version (SPARC64)
+        private enum DEFAULTS = true;
+    else version (PPC)
+        private enum DEFAULTS = true;
+    else version (PPC64)
+        private enum DEFAULTS = true;
+    else
+        static assert(0, "unimplemented");
+
+    static if (DEFAULTS)
+    {
+        enum MAP_ANON = 0x20;
+        enum MS_ASYNC = 1;
+        enum MS_INVALIDATE = 2;
+        enum MS_SYNC = 4;
+    }
+
+    int msync(void*, size_t, int);
+}
+else version( OSX )
+{
+    enum MAP_SHARED     = 0x0001;
+    enum MAP_PRIVATE    = 0x0002;
+    enum MAP_FIXED      = 0x0010;
+    enum MAP_ANON       = 0x1000;
+
+    enum MAP_FAILED     = cast(void*)-1;
+
+    enum MS_ASYNC       = 0x0001;
+    enum MS_INVALIDATE  = 0x0002;
+    enum MS_SYNC        = 0x0010;
+
+    int msync(void*, size_t, int);
+}
+else version( FreeBSD )
+{
+    enum MAP_SHARED     = 0x0001;
+    enum MAP_PRIVATE    = 0x0002;
+    enum MAP_FIXED      = 0x0010;
+    enum MAP_ANON       = 0x1000;
+
+    enum MAP_FAILED     = cast(void*)-1;
+
+    enum MS_SYNC        = 0x0000;
+    enum MS_ASYNC       = 0x0001;
+    enum MS_INVALIDATE  = 0x0002;
+
+    int msync(void*, size_t, int);
+}
+else version (Solaris)
+{
+    enum MAP_SHARED = 0x0001;
+    enum MAP_PRIVATE = 0x0002;
+    enum MAP_FIXED = 0x0010;
+    enum MAP_ANON = 0x0100;
+
+    enum MAP_FAILED = cast(void*)-1;
+
+    enum MS_SYNC = 0x0004;
+    enum MS_ASYNC = 0x0001;
+    enum MS_INVALIDATE  = 0x0002;
+
+    int msync(void*, size_t, int);
+}
+else version (CRuntime_Bionic)
+{
+    enum MAP_SHARED     = 0x0001;
+    enum MAP_PRIVATE    = 0x0002;
+    enum MAP_FIXED      = 0x0010;
+
+    version (X86)
+    {
+        enum MAP_ANON       = 0x0020;
+    }
+    else version (ARM)
+    {
+        enum MAP_ANON       = 0x0020;
+    }
+    else
+    {
+        static assert(false, "Architecture not supported.");
+    }
+
+    enum MAP_FAILED     = cast(void*)-1;
+
+    enum MS_SYNC        = 4;
+    enum MS_ASYNC       = 1;
+    enum MS_INVALIDATE  = 2;
+
+    int msync(in void*, size_t, int);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Process Memory Locking (ML)
+//
+/*
+MCL_CURRENT
+MCL_FUTURE
+
+int mlockall(int);
+int munlockall();
+*/
+
+version( CRuntime_Glibc )
+{
+    version (SPARC) enum
+    {
+        MCL_CURRENT = 0x2000,
+        MCL_FUTURE = 0x4000,
+    }
+    else version (SPARC64) enum
+    {
+        MCL_CURRENT = 0x2000,
+        MCL_FUTURE = 0x4000,
+    }
+    else version (PPC) enum
+    {
+        MCL_CURRENT = 0x2000,
+        MCL_FUTURE = 0x4000,
+    }
+    else version (PPC64) enum
+    {
+        MCL_CURRENT = 0x2000,
+        MCL_FUTURE = 0x4000,
+    }
+    else version (Alpha) enum
+    {
+        MCL_CURRENT = 8192,
+        MCL_FUTURE = 16384,
+    }
+    else enum
+    {
+        MCL_CURRENT = 1,
+        MCL_FUTURE = 2,
+    }
+
+    int mlockall(int);
+    int munlockall();
+
+}
+else version( OSX )
+{
+    enum MCL_CURRENT    = 0x0001;
+    enum MCL_FUTURE     = 0x0002;
+
+    int mlockall(int);
+    int munlockall();
+}
+else version( FreeBSD )
+{
+    enum MCL_CURRENT    = 0x0001;
+    enum MCL_FUTURE     = 0x0002;
+
+    int mlockall(int);
+    int munlockall();
+}
+else version (Solaris)
+{
+    enum MCL_CURRENT = 0x0001;
+    enum MCL_FUTURE = 0x0002;
+
+    int mlockall(int);
+    int munlockall();
+}
+else version (CRuntime_Bionic)
+{
+    enum MCL_CURRENT = 1;
+    enum MCL_FUTURE  = 2;
+
+    int mlockall(int);
+    int munlockall();
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Range Memory Locking (MLR)
+//
+/*
+int mlock(in void*, size_t);
+int munlock(in void*, size_t);
+*/
+
+version( CRuntime_Glibc )
+{
+    int mlock(in void*, size_t);
+    int munlock(in void*, size_t);
+}
+else version( OSX )
+{
+    int mlock(in void*, size_t);
+    int munlock(in void*, size_t);
+}
+else version( FreeBSD )
+{
+    int mlock(in void*, size_t);
+    int munlock(in void*, size_t);
+}
+else version (Solaris)
+{
+    int mlock(in void*, size_t);
+    int munlock(in void*, size_t);
+}
+else version (CRuntime_Bionic)
+{
+    int mlock(in void*, size_t);
+    int munlock(in void*, size_t);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Memory Protection (MPR)
+//
+/*
+int mprotect(void*, size_t, int);
+*/
+
+version (CRuntime_Glibc)
+{
+    int mprotect(void*, size_t, int);
+}
+else version( OSX )
+{
+    int mprotect(void*, size_t, int);
+}
+else version( FreeBSD )
+{
+    int mprotect(void*, size_t, int);
+}
+else version (Solaris)
+{
+    int mprotect(void*, size_t, int);
+}
+else version (CRuntime_Bionic)
+{
+    int mprotect(in void*, size_t, int);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Shared Memory Objects (SHM)
+//
+/*
+int shm_open(in char*, int, mode_t);
+int shm_unlink(in char*);
+*/
+
+version( CRuntime_Glibc )
+{
+    int shm_open(in char*, int, mode_t);
+    int shm_unlink(in char*);
+}
+else version( OSX )
+{
+    int shm_open(in char*, int, mode_t);
+    int shm_unlink(in char*);
+}
+else version( FreeBSD )
+{
+    int shm_open(in char*, int, mode_t);
+    int shm_unlink(in char*);
+}
+else version (Solaris)
+{
+    int shm_open(in char*, int, mode_t);
+    int shm_unlink(in char*);
+}
+else version (CRuntime_Bionic)
+{
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Typed Memory Objects (TYM)
+//
+/*
+POSIX_TYPED_MEM_ALLOCATE
+POSIX_TYPED_MEM_ALLOCATE_CONTIG
+POSIX_TYPED_MEM_MAP_ALLOCATABLE
+
+struct posix_typed_mem_info
+{
+    size_t posix_tmi_length;
+}
+
+int posix_mem_offset(in void*, size_t, off_t *, size_t *, int *);
+int posix_typed_mem_get_info(int, struct posix_typed_mem_info *);
+int posix_typed_mem_open(in char*, int, int);
+*/
diff --git a/libphobos/libdruntime/core/sys/posix/sys/msg.d b/libphobos/libdruntime/core/sys/posix/sys/msg.d
new file mode 100644
index 00000000000..7f4b9a336cb
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/msg.d
@@ -0,0 +1,345 @@
+/**
+* D header file for POSIX.
+*
+* Authors: Neven Miculinić
+*/
+
+module core.sys.posix.sys.msg;
+
+import core.sys.posix.sys.ipc;
+public import core.sys.posix.sys.types;
+public import core.stdc.config;
+
+version (CRuntime_Glibc):
+// Some of these may be from linux kernel headers.
+extern (C):
+
+public enum MSG_STAT = 11;
+public enum MSG_INFO = 12;
+
+public enum MSG_NOERROR = 1 << 12; // octal!10000
+public enum  MSG_EXCEPT = 2 << 12; // octal!20000
+public enum    MSG_COPY = 4 << 12; // octal!40000
+
+struct msgbuf {
+    c_long mtype;
+    char[1] mtext;
+};
+
+struct msginfo {
+    int msgpool;
+    int msgmap;
+    int msgmax;
+    int msgmnb;
+    int msgmni;
+    int msgssz;
+    int msgtql;
+    ushort msgseg;
+};
+
+version(Alpha)
+{
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/alpha/bits/msq.h
+    alias c_ulong msgqnum_t;
+    alias c_ulong msglen_t;
+
+    struct msqid_ds
+    {
+        ipc_perm msg_perm;
+        time_t msg_stime;
+        time_t msg_rtime;
+        time_t msg_ctime;
+        c_ulong __msg_cbytes;
+        msgqnum_t msg_qnum;
+        msglen_t msg_qbytes;
+        pid_t msg_lspid;
+        pid_t msg_lrpid;
+        c_ulong __glibc_reserved1;
+        c_ulong __glibc_reserved2;
+    };
+}
+else version(HPPA)
+{
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/hppa/bits/msq.h
+    alias c_ulong msgqnum_t;
+    alias c_ulong msglen_t;
+
+    // Assuming word size is 32
+    struct msqid_ds {
+        ipc_perm msg_perm;
+        c_ulong __pad1;
+        time_t          msg_stime;
+        c_ulong __pad2;
+        time_t          msg_rtime;
+        c_ulong __pad3;
+        time_t          msg_ctime;
+        c_ulong         __msg_cbytes;
+        msgqnum_t       msg_qnum;
+        msglen_t        msg_qbytes;
+        pid_t           msg_lspid;
+        pid_t           msg_lrpid;
+        c_ulong __glibc_reserved1;
+        c_ulong __glibc_reserved2;
+    };
+
+}
+else version(MIPS)
+{
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/mips/bits/msq.h
+    alias c_ulong msgqnum_t;
+    alias c_ulong msglen_t;
+
+    struct msqid_ds
+    {
+        ipc_perm  msg_perm;
+        version(BigEndian) c_ulong __glibc_reserved1;
+        time_t    msg_stime;
+        version(LittleEndian) c_ulong __glibc_reserved1;
+        version(BigEndian) c_ulong __glibc_reserved2;
+        time_t    msg_rtime;
+        version(LittleEndian) c_ulong __glibc_reserved2;
+        version(BigEndian) c_ulong __glibc_reserved3;
+        time_t    msg_ctime;
+        version(LittleEndian) c_ulong __glibc_reserved3;
+        c_ulong   __msg_cbytes;
+        msgqnum_t msg_qnum;
+        msglen_t  msg_qbytes;
+        pid_t     msg_lspid;
+        pid_t     msg_lrpid;
+        c_ulong   __glibc_reserved4;
+        c_ulong   __glibc_reserved5;
+    };
+}
+else version(MIPS64)
+{
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/mips/bits/msq.h
+    alias c_ulong msgqnum_t;
+    alias c_ulong msglen_t;
+
+    struct msqid_ds
+    {
+        ipc_perm  msg_perm;
+        time_t    msg_stime;
+        time_t    msg_rtime;
+        time_t    msg_ctime;
+        c_ulong   __msg_cbytes;
+        msgqnum_t msg_qnum;
+        msglen_t  msg_qbytes;
+        pid_t     msg_lspid;
+        pid_t     msg_lrpid;
+        c_ulong   __glibc_reserved4;
+        c_ulong   __glibc_reserved5;
+    };
+}
+else version (PPC)
+{
+
+    //  https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/powerpc/bits/msq.h
+    alias c_ulong msgqnum_t;
+    alias c_ulong msglen_t;
+
+    struct msqid_ds {
+        ipc_perm msg_perm;
+        c_ulong __glibc_reserved1;
+        time_t          msg_stime;
+        c_ulong __glibc_reserved2;
+        time_t          msg_rtime;
+        c_ulong __glibc_reserved3;
+        time_t          msg_ctime;
+        c_ulong         __msg_cbytes;
+        msgqnum_t       msg_qnum;
+        msglen_t        msg_qbytes;
+        pid_t           msg_lspid;
+        pid_t           msg_lrpid;
+        c_ulong __glibc_reserved4;
+        c_ulong __glibc_reserved5;
+    };
+}
+else version (PPC64)
+{
+    //  https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/powerpc/bits/msq.h
+    alias c_ulong msgqnum_t;
+    alias c_ulong msglen_t;
+
+    struct msqid_ds {
+        ipc_perm  msg_perm;
+        time_t    msg_stime;
+        time_t    msg_rtime;
+        time_t    msg_ctime;
+        c_ulong   __msg_cbytes;
+        msgqnum_t msg_qnum;
+        msglen_t  msg_qbytes;
+        pid_t     msg_lspid;
+        pid_t     msg_lrpid;
+        c_ulong   __glibc_reserved4;
+        c_ulong   __glibc_reserved5;
+    };
+}
+else version (S390)
+{
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/s390/bits/msq.h
+    alias c_ulong msgqnum_t;
+    alias c_ulong msglen_t;
+
+    // Assuming wordsize != 64
+    struct msqid_ds {
+        ipc_perm msg_perm;
+        c_ulong __glibc_reserved1;
+        time_t          msg_stime;
+        c_ulong __glibc_reserved2;
+        time_t          msg_rtime;
+        c_ulong __glibc_reserved3;
+        time_t          msg_ctime;
+        c_ulong         __msg_cbytes;
+        msgqnum_t       msg_qnum;
+        msglen_t        msg_qbytes;
+        pid_t           msg_lspid;
+        pid_t           msg_lrpid;
+        c_ulong __glibc_reserved4;
+        c_ulong __glibc_reserved5;
+    };
+}
+else version (SystemZ)
+{
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/s390/bits/msq.h
+    alias c_ulong msgqnum_t;
+    alias c_ulong msglen_t;
+
+    // Assuming wordsize == 64
+    struct msqid_ds {
+        ipc_perm msg_perm;
+        time_t          msg_stime;
+        time_t          msg_rtime;
+        time_t          msg_ctime;
+        c_ulong         __msg_cbytes;
+        msgqnum_t       msg_qnum;
+        msglen_t        msg_qbytes;
+        pid_t           msg_lspid;
+        pid_t           msg_lrpid;
+        c_ulong __glibc_reserved4;
+        c_ulong __glibc_reserved5;
+    };
+}
+else version (SPARC)
+{
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sparc/bits/msq.h
+    alias c_ulong msgqnum_t;
+    alias c_ulong msglen_t;
+
+    // Assuming word size is 32
+    struct msqid_ds {
+        ipc_perm msg_perm;
+        c_ulong __pad1;
+        time_t          msg_stime;
+        c_ulong __pad2;
+        time_t          msg_rtime;
+        c_ulong __pad3;
+        time_t          msg_ctime;
+        c_ulong         __msg_cbytes;
+        msgqnum_t       msg_qnum;
+        msglen_t        msg_qbytes;
+        pid_t           msg_lspid;
+        pid_t           msg_lrpid;
+        c_ulong __glibc_reserved1;
+        c_ulong __glibc_reserved2;
+    };
+}
+else version (X86)
+{
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/x86/bits/msq.h
+    alias c_ulong msgqnum_t;
+    alias c_ulong msglen_t;
+
+    struct msqid_ds {
+        ipc_perm msg_perm;
+        time_t          msg_stime;
+        time_t          msg_rtime;
+        time_t          msg_ctime;
+        c_ulong         __msg_cbytes;
+        msgqnum_t       msg_qnum;
+        msglen_t        msg_qbytes;
+        pid_t           msg_lspid;
+        pid_t           msg_lrpid;
+        c_ulong __glibc_reserved4;
+        c_ulong __glibc_reserved5;
+    };
+}
+else version (X86_64)
+{
+    // Can't find adequate bits.h in https://sourceware.org/git/?p=glibc.git;a=tree;f=sysdeps/unix/sysv/linux/x86_64/bits;h=cd03a84463c9393dd751d78fba19e59aad3e0bb3;hb=HEAD
+    // Using the same as in X86 version
+    alias c_ulong msgqnum_t;
+    alias c_ulong msglen_t;
+
+    struct msqid_ds {
+        ipc_perm msg_perm;
+        c_ulong __glibc_reserved1;
+        time_t          msg_stime;
+        c_ulong __glibc_reserved2;
+        time_t          msg_rtime;
+        c_ulong __glibc_reserved3;
+        time_t          msg_ctime;
+        c_ulong         __msg_cbytes;
+        msgqnum_t       msg_qnum;
+        msglen_t        msg_qbytes;
+        pid_t           msg_lspid;
+        pid_t           msg_lrpid;
+        c_ulong __glibc_reserved4;
+        c_ulong __glibc_reserved5;
+    };
+}
+else version (AArch64)
+{
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/generic/bits/msq.h
+    alias c_ulong msgqnum_t;
+    alias c_ulong msglen_t;
+
+    struct msqid_ds {
+        ipc_perm msg_perm;
+        time_t          msg_stime;
+        time_t          msg_rtime;
+        time_t          msg_ctime;
+        c_ulong         __msg_cbytes;
+        msgqnum_t       msg_qnum;
+        msglen_t        msg_qbytes;
+        pid_t           msg_lspid;
+        pid_t           msg_lrpid;
+        c_ulong __glibc_reserved4;
+        c_ulong __glibc_reserved5;
+    };
+}
+else version (ARM)
+{
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/generic/bits/msq.h
+    alias c_ulong msgqnum_t;
+    alias c_ulong msglen_t;
+
+    struct msqid_ds {
+        ipc_perm msg_perm;
+        c_ulong __glibc_reserved1;
+        time_t          msg_stime;
+        c_ulong __glibc_reserved2;
+        time_t          msg_rtime;
+        c_ulong __glibc_reserved3;
+        time_t          msg_ctime;
+        c_ulong         __msg_cbytes;
+        msgqnum_t       msg_qnum;
+        msglen_t        msg_qbytes;
+        pid_t           msg_lspid;
+        pid_t           msg_lrpid;
+        c_ulong __glibc_reserved4;
+        c_ulong __glibc_reserved5;
+    };
+} else
+    static assert(0, "unimplemented");
+
+
+public enum MSG_MEM_SCALE =  32;
+public enum MSGMNI =     16;
+public enum MSGMAX =   8192;
+public enum MSGMNB =  16384;
+
+int msgctl (int msqid, int cmd, msqid_ds *__buf);
+int msgget ( key_t key, int msgflg );
+ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, c_long msgtyp, int msgflg);
+int msgsnd ( int msqid, msgbuf *msgp, int msgsz, int msgflg );
diff --git a/libphobos/libdruntime/core/sys/posix/sys/resource.d b/libphobos/libdruntime/core/sys/posix/sys/resource.d
new file mode 100644
index 00000000000..f7b58e0ab30
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/resource.d
@@ -0,0 +1,414 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright (c) 2013 Lars Tandle Kyllingstad.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Lars Tandle Kyllingstad
+ * Standards: The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008
+ */
+module core.sys.posix.sys.resource;
+version (Posix):
+
+public import core.sys.posix.sys.time;
+public import core.sys.posix.sys.types: id_t;
+import core.sys.posix.config;
+
+nothrow extern(C):
+
+//
+// XOpen (XSI)
+//
+// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_resource.h.html
+/*
+enum
+{
+    PRIO_PROCESS,
+    PRIO_PGRP,
+    PRIO_USER,
+}
+
+alias ulong rlim_t;
+
+enum
+{
+    RLIM_INFINITY,
+    RLIM_SAVED_MAX,
+    RLIM_SAVED_CUR,
+}
+
+enum
+{
+    RUSAGE_SELF,
+    RUSAGE_CHILDREN,
+}
+
+struct rlimit
+{
+    rlim_t rlim_cur;
+    rlim_t rlim_max;
+}
+
+struct rusage
+{
+    timeval ru_utime;
+    timeval ru_stime;
+}
+
+enum
+{
+    RLIMIT_CORE,
+    RLIMIT_CPU,
+    RLIMIT_DATA,
+    RLIMIT_FSIZE,
+    RLIMIT_NOFILE,
+    RLIMIT_STACK,
+    RLIMIT_AS,
+}
+
+int getpriority(int, id_t);
+int getrlimit(int, rlimit*);
+int getrusage(int, rusage*);
+int setpriority(int, id_t, int);
+int setrlimit(int, const rlimit*);
+*/
+
+
+version (CRuntime_Glibc)
+{
+    // rusage and some other constants in the Bionic section below really
+    // come from the linux kernel headers, but they're all mixed right now.
+    enum
+    {
+        PRIO_PROCESS = 0,
+        PRIO_PGRP    = 1,
+        PRIO_USER    = 2,
+    }
+
+    static if (__USE_FILE_OFFSET64)
+         alias ulong rlim_t;
+    else
+         alias c_ulong rlim_t;
+
+    static if (__USE_FILE_OFFSET64)
+        enum RLIM_INFINITY = 0xffffffffffffffffUL;
+    else
+        enum RLIM_INFINITY = cast(c_ulong)(~0UL);
+
+    enum RLIM_SAVED_MAX = RLIM_INFINITY;
+    enum RLIM_SAVED_CUR = RLIM_INFINITY;
+
+    enum
+    {
+        RUSAGE_SELF     =  0,
+        RUSAGE_CHILDREN = -1,
+    }
+
+    struct rusage
+    {
+        timeval ru_utime;
+        timeval ru_stime;
+        c_long ru_maxrss;
+        c_long ru_ixrss;
+        c_long ru_idrss;
+        c_long ru_isrss;
+        c_long ru_minflt;
+        c_long ru_majflt;
+        c_long ru_nswap;
+        c_long ru_inblock;
+        c_long ru_oublock;
+        c_long ru_msgsnd;
+        c_long ru_msgrcv;
+        c_long ru_nsignals;
+        c_long ru_nvcsw;
+        c_long ru_nivcsw;
+    }
+
+    enum
+    {
+        RLIMIT_CORE   = 4,
+        RLIMIT_CPU    = 0,
+        RLIMIT_DATA   = 2,
+        RLIMIT_FSIZE  = 1,
+        RLIMIT_NOFILE = 7,
+        RLIMIT_STACK  = 3,
+        RLIMIT_AS     = 9,
+    }
+}
+else version (OSX)
+{
+    enum
+    {
+        PRIO_PROCESS = 0,
+        PRIO_PGRP    = 1,
+        PRIO_USER    = 2,
+    }
+
+    alias ulong rlim_t;
+
+    enum
+    {
+        RLIM_INFINITY  = ((cast(ulong) 1 << 63) - 1),
+        RLIM_SAVED_MAX = RLIM_INFINITY,
+        RLIM_SAVED_CUR = RLIM_INFINITY,
+    }
+
+    enum
+    {
+        RUSAGE_SELF     =  0,
+        RUSAGE_CHILDREN = -1,
+    }
+
+    struct rusage
+    {
+        timeval ru_utime;
+        timeval ru_stime;
+        c_long[14] ru_opaque;
+    }
+
+    enum
+    {
+        RLIMIT_CORE   = 4,
+        RLIMIT_CPU    = 0,
+        RLIMIT_DATA   = 2,
+        RLIMIT_FSIZE  = 1,
+        RLIMIT_NOFILE = 8,
+        RLIMIT_STACK  = 3,
+        RLIMIT_AS     = 5,
+    }
+}
+else version (FreeBSD)
+{
+    enum
+    {
+        PRIO_PROCESS = 0,
+        PRIO_PGRP    = 1,
+        PRIO_USER    = 2,
+    }
+
+    alias long rlim_t;
+
+    enum
+    {
+        RLIM_INFINITY   = (cast(rlim_t)((cast(ulong) 1 << 63) - 1)),
+        // FreeBSD explicitly does not define the following:
+        //RLIM_SAVED_MAX,
+        //RLIM_SAVED_CUR,
+    }
+
+    enum
+    {
+        RUSAGE_SELF     =  0,
+        RUSAGE_CHILDREN = -1,
+    }
+
+    struct rusage
+    {
+        timeval ru_utime;
+        timeval ru_stime;
+        c_long ru_maxrss;
+        alias ru_ixrss ru_first;
+        c_long ru_ixrss;
+        c_long ru_idrss;
+        c_long ru_isrss;
+        c_long ru_minflt;
+        c_long ru_majflt;
+        c_long ru_nswap;
+        c_long ru_inblock;
+        c_long ru_oublock;
+        c_long ru_msgsnd;
+        c_long ru_msgrcv;
+        c_long ru_nsignals;
+        c_long ru_nvcsw;
+        c_long ru_nivcsw;
+        alias ru_nivcsw ru_last;
+    }
+
+    enum
+    {
+        RLIMIT_CORE   =  4,
+        RLIMIT_CPU    =  0,
+        RLIMIT_DATA   =  2,
+        RLIMIT_FSIZE  =  1,
+        RLIMIT_NOFILE =  8,
+        RLIMIT_STACK  =  3,
+        RLIMIT_AS     = 10,
+    }
+}
+else version (Solaris)
+{
+    enum
+    {
+        PRIO_PROCESS = 0,
+        PRIO_PGRP    = 1,
+        PRIO_USER    = 2,
+    }
+
+    alias c_ulong rlim_t;
+
+    enum : c_long
+    {
+        RLIM_INFINITY   = -3,
+        RLIM_SAVED_MAX  = -2,
+        RLIM_SAVED_CUR  = -1,
+    }
+
+    enum
+    {
+        RUSAGE_SELF     =  0,
+        RUSAGE_CHILDREN = -1,
+    }
+
+    struct rusage
+    {
+        timeval ru_utime;
+        timeval ru_stime;
+        c_long ru_maxrss;
+        c_long ru_ixrss;
+        c_long ru_idrss;
+        c_long ru_isrss;
+        c_long ru_minflt;
+        c_long ru_majflt;
+        c_long ru_nswap;
+        c_long ru_inblock;
+        c_long ru_oublock;
+        c_long ru_msgsnd;
+        c_long ru_msgrcv;
+        c_long ru_nsignals;
+        c_long ru_nvcsw;
+        c_long ru_nivcsw;
+    }
+
+    enum
+    {
+        RLIMIT_CORE   = 4,
+        RLIMIT_CPU    = 0,
+        RLIMIT_DATA   = 2,
+        RLIMIT_FSIZE  = 1,
+        RLIMIT_NOFILE = 5,
+        RLIMIT_STACK  = 3,
+        RLIMIT_AS     = 6,
+    }
+}
+else version (CRuntime_Bionic)
+{
+    enum
+    {
+        PRIO_PROCESS = 0,
+        PRIO_PGRP    = 1,
+        PRIO_USER    = 2,
+    }
+
+    alias c_ulong rlim_t;
+    enum RLIM_INFINITY = cast(c_ulong)(~0UL);
+
+    enum
+    {
+        RUSAGE_SELF     =  0,
+        RUSAGE_CHILDREN = -1,
+    }
+
+    struct rusage
+    {
+        timeval ru_utime;
+        timeval ru_stime;
+        c_long ru_maxrss;
+        c_long ru_ixrss;
+        c_long ru_idrss;
+        c_long ru_isrss;
+        c_long ru_minflt;
+        c_long ru_majflt;
+        c_long ru_nswap;
+        c_long ru_inblock;
+        c_long ru_oublock;
+        c_long ru_msgsnd;
+        c_long ru_msgrcv;
+        c_long ru_nsignals;
+        c_long ru_nvcsw;
+        c_long ru_nivcsw;
+    }
+
+    enum
+    {
+        RLIMIT_CORE   = 4,
+        RLIMIT_CPU    = 0,
+        RLIMIT_DATA   = 2,
+        RLIMIT_FSIZE  = 1,
+        RLIMIT_NOFILE = 7,
+        RLIMIT_STACK  = 3,
+        RLIMIT_AS     = 9,
+    }
+}
+else static assert (false, "Unsupported platform");
+
+struct rlimit
+{
+    rlim_t rlim_cur;
+    rlim_t rlim_max;
+}
+
+version (CRuntime_Glibc)
+{
+    int getpriority(int, id_t);
+    int setpriority(int, id_t, int);
+}
+else version (FreeBSD)
+{
+    int getpriority(int, int);
+    int setpriority(int, int, int);
+}
+else version (CRuntime_Bionic)
+{
+    int getpriority(int, int);
+    int setpriority(int, int, int);
+}
+else version (Solaris)
+{
+    int getpriority(int, id_t);
+    int setpriority(int, id_t, int);
+}
+else version (OSX)
+{
+    int getpriority(int, id_t);
+    int setpriority(int, id_t, int);
+}
+
+version (CRuntime_Glibc)
+{
+    static if (__USE_FILE_OFFSET64)
+    {
+        int getrlimit64(int, rlimit*);
+        int setrlimit64(int, in rlimit*);
+        alias getrlimit = getrlimit64;
+        alias setrlimit = setrlimit64;
+    }
+    else
+    {
+        int getrlimit(int, rlimit*);
+        int setrlimit(int, in rlimit*);
+    }
+    int getrusage(int, rusage*);
+}
+else version (CRuntime_Bionic)
+{
+    int getrlimit(int, rlimit*);
+    int getrusage(int, rusage*);
+    int setrlimit(int, in rlimit*);
+}
+else version (OSX)
+{
+    int getrlimit(int, rlimit*);
+    int getrusage(int, rusage*);
+    int setrlimit(int, in rlimit*);
+}
+else version (FreeBSD)
+{
+    int getrlimit(int, rlimit*);
+    int getrusage(int, rusage*);
+    int setrlimit(int, in rlimit*);
+}
+else version (Solaris)
+{
+    int getrlimit(int, rlimit*);
+    int getrusage(int, rusage*);
+    int setrlimit(int, in rlimit*);
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/select.d b/libphobos/libdruntime/core/sys/posix/sys/select.d
new file mode 100644
index 00000000000..cb0c9821630
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/select.d
@@ -0,0 +1,366 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.sys.select;
+
+private import core.sys.posix.config;
+public import core.stdc.time;           // for timespec
+public import core.sys.posix.sys.time;  // for timeval
+public import core.sys.posix.sys.types; // for time_t
+public import core.sys.posix.signal;    // for sigset_t
+
+//debug=select;  // uncomment to turn on debugging printf's
+version(unittest) import core.stdc.stdio: printf;
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// Required
+//
+/*
+NOTE: This module requires timeval from core.sys.posix.sys.time, but timeval
+      is supposedly an XOpen extension.  As a result, this header will not
+      compile on platforms that are not XSI-compliant.  This must be resolved
+      on a per-platform basis.
+
+fd_set
+
+void FD_CLR(int fd, fd_set* fdset);
+int FD_ISSET(int fd, const(fd_set)* fdset);
+void FD_SET(int fd, fd_set* fdset);
+void FD_ZERO(fd_set* fdset);
+
+FD_SETSIZE
+
+int  pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+int  select(int, fd_set*, fd_set*, fd_set*, timeval*);
+*/
+
+version( CRuntime_Glibc )
+{
+    private
+    {
+        alias c_long __fd_mask;
+        enum uint __NFDBITS = 8 * __fd_mask.sizeof;
+
+        extern (D) auto __FDELT( int d )
+        {
+            return d / __NFDBITS;
+        }
+
+        extern (D) auto __FDMASK( int d )
+        {
+            return cast(__fd_mask) 1 << ( d % __NFDBITS );
+        }
+    }
+
+    enum FD_SETSIZE = 1024;
+
+    struct fd_set
+    {
+        __fd_mask[FD_SETSIZE / __NFDBITS] fds_bits;
+    }
+
+    extern (D) void FD_CLR( int fd, fd_set* fdset )
+    {
+        fdset.fds_bits[__FDELT( fd )] &= ~__FDMASK( fd );
+    }
+
+    extern (D) bool FD_ISSET( int fd, const(fd_set)* fdset )
+    {
+        return (fdset.fds_bits[__FDELT( fd )] & __FDMASK( fd )) != 0;
+    }
+
+    extern (D) void FD_SET( int fd, fd_set* fdset )
+    {
+        fdset.fds_bits[__FDELT( fd )] |= __FDMASK( fd );
+    }
+
+    extern (D) void FD_ZERO( fd_set* fdset )
+    {
+        fdset.fds_bits[0 .. $] = 0;
+    }
+
+    /+
+     + GNU ASM Implementation
+     +
+    # define __FD_ZERO(fdsp)                                \
+      do {                                                  \
+        int __d0, __d1;                                     \
+        __asm__ __volatile__ ("cld; rep; stosl"             \
+                  : "=c" (__d0), "=D" (__d1)                \
+                  : "a" (0), "0" (sizeof (fd_set)           \
+                          / sizeof (__fd_mask)),            \
+                    "1" (&__FDS_BITS (fdsp)[0])             \
+                  : "memory");                              \
+      } while (0)
+
+    # define __FD_SET(fd, fdsp)                             \
+      __asm__ __volatile__ ("btsl %1,%0"                    \
+                : "=m" (__FDS_BITS (fdsp)[__FDELT (fd)])    \
+                : "r" (((int) (fd)) % __NFDBITS)            \
+                : "cc","memory")
+    # define __FD_CLR(fd, fdsp)                             \
+      __asm__ __volatile__ ("btrl %1,%0"                    \
+                : "=m" (__FDS_BITS (fdsp)[__FDELT (fd)])    \
+                : "r" (((int) (fd)) % __NFDBITS)            \
+                : "cc","memory")
+    # define __FD_ISSET(fd, fdsp)                           \
+      (__extension__                                        \
+       ({register char __result;                            \
+         __asm__ __volatile__ ("btl %1,%2 ; setcb %b0"      \
+                   : "=q" (__result)                        \
+                   : "r" (((int) (fd)) % __NFDBITS),        \
+                     "m" (__FDS_BITS (fdsp)[__FDELT (fd)])  \
+                   : "cc");                                 \
+         __result; }))
+     +/
+
+    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int select(int, fd_set*, fd_set*, fd_set*, timeval*);
+}
+else version( OSX )
+{
+    private
+    {
+        enum uint __DARWIN_NBBY    = 8;                            /* bits in a byte */
+        enum uint __DARWIN_NFDBITS = (int.sizeof * __DARWIN_NBBY); /* bits per mask */
+    }
+
+    enum FD_SETSIZE = 1024;
+
+    struct fd_set
+    {
+        int[(FD_SETSIZE + (__DARWIN_NFDBITS - 1)) / __DARWIN_NFDBITS] fds_bits;
+    }
+
+    extern (D) void FD_CLR( int fd, fd_set* fdset )
+    {
+        fdset.fds_bits[fd / __DARWIN_NFDBITS] &= ~(1 << (fd % __DARWIN_NFDBITS));
+    }
+
+    extern (D) bool FD_ISSET( int fd, const(fd_set)* fdset )
+    {
+        return (fdset.fds_bits[fd / __DARWIN_NFDBITS] & (1 << (fd % __DARWIN_NFDBITS))) != 0;
+    }
+
+    extern (D) void FD_SET( int fd, fd_set* fdset )
+    {
+        fdset.fds_bits[fd / __DARWIN_NFDBITS] |= 1 << (fd % __DARWIN_NFDBITS);
+    }
+
+    extern (D) void FD_ZERO( fd_set* fdset )
+    {
+        fdset.fds_bits[0 .. $] = 0;
+    }
+
+    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int select(int, fd_set*, fd_set*, fd_set*, timeval*);
+}
+else version( FreeBSD )
+{
+    private
+    {
+        alias c_ulong __fd_mask;
+        enum _NFDBITS = __fd_mask.sizeof * 8;
+    }
+
+    enum uint FD_SETSIZE = 1024;
+
+    struct fd_set
+    {
+        __fd_mask[(FD_SETSIZE + (_NFDBITS - 1)) / _NFDBITS] __fds_bits;
+    }
+
+    extern (D) __fd_mask __fdset_mask(uint n)
+    {
+        return cast(__fd_mask) 1 << (n % _NFDBITS);
+    }
+
+    extern (D) void FD_CLR( int n, fd_set* p )
+    {
+        p.__fds_bits[n / _NFDBITS] &= ~__fdset_mask(n);
+    }
+
+    extern (D) bool FD_ISSET( int n, const(fd_set)* p )
+    {
+        return (p.__fds_bits[n / _NFDBITS] & __fdset_mask(n)) != 0;
+    }
+
+    extern (D) void FD_SET( int n, fd_set* p )
+    {
+        p.__fds_bits[n / _NFDBITS] |= __fdset_mask(n);
+    }
+
+    extern (D) void FD_ZERO( fd_set* p )
+    {
+        fd_set *_p;
+        size_t _n;
+
+        _p = p;
+        _n = (FD_SETSIZE + (_NFDBITS - 1)) / _NFDBITS;
+        while (_n > 0)
+            _p.__fds_bits[--_n] = 0;
+    }
+
+    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int select(int, fd_set*, fd_set*, fd_set*, timeval*);
+}
+else version (Solaris)
+{
+    private
+    {
+        alias c_long fds_mask;
+
+        enum _NBBY = 8;
+        enum FD_NFDBITS = fds_mask.sizeof * _NBBY;
+    }
+
+    version (D_LP64)
+        enum uint FD_SETSIZE = 65536;
+    else
+        enum uint FD_SETSIZE = 1024;
+
+    struct fd_set
+    {
+        c_long[(FD_SETSIZE + (FD_NFDBITS - 1)) / FD_NFDBITS] fds_bits;
+    }
+
+    extern (D) void FD_SET(int __n, fd_set* __p)
+    {
+        __p.fds_bits[__n / FD_NFDBITS] |= 1UL << (__n % FD_NFDBITS);
+    }
+
+    extern (D) void FD_CLR(int __n, fd_set* __p)
+    {
+        __p.fds_bits[__n / FD_NFDBITS] &= ~(1UL << (__n % FD_NFDBITS));
+    }
+
+    extern (D) bool FD_ISSET(int __n, const(fd_set)* __p)
+    {
+        return (__p.fds_bits[__n / FD_NFDBITS] & (1UL << (__n % FD_NFDBITS))) != 0;
+    }
+
+    extern (D) void FD_ZERO(fd_set* __p)
+    {
+        __p.fds_bits[0 .. $] = 0;
+    }
+
+    int select(int, fd_set*, fd_set*, fd_set*, timeval*);
+    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+}
+else version( CRuntime_Bionic )
+{
+    private
+    {
+        alias c_ulong __fd_mask;
+        enum uint __NFDBITS = 8 * __fd_mask.sizeof;
+
+        extern (D) auto __FDELT( int d )
+        {
+            return d / __NFDBITS;
+        }
+
+        extern (D) auto __FDMASK( int d )
+        {
+            return cast(__fd_mask) 1 << ( d % __NFDBITS );
+        }
+    }
+
+    enum FD_SETSIZE = 1024;
+
+    struct fd_set
+    {
+        __fd_mask[FD_SETSIZE / __NFDBITS] fds_bits;
+    }
+
+    // These functions are generated in assembly in bionic.
+    extern (D) void FD_CLR( int fd, fd_set* fdset )
+    {
+        fdset.fds_bits[__FDELT( fd )] &= ~__FDMASK( fd );
+    }
+
+    extern (D) bool FD_ISSET( int fd, const(fd_set)* fdset )
+    {
+        return (fdset.fds_bits[__FDELT( fd )] & __FDMASK( fd )) != 0;
+    }
+
+    extern (D) void FD_SET( int fd, fd_set* fdset )
+    {
+        fdset.fds_bits[__FDELT( fd )] |= __FDMASK( fd );
+    }
+
+    extern (D) void FD_ZERO( fd_set* fdset )
+    {
+        fdset.fds_bits[0 .. $] = 0;
+    }
+
+    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int select(int, fd_set*, fd_set*, fd_set*, timeval*);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+unittest
+{
+    debug(select) printf("core.sys.posix.sys.select unittest\n");
+
+    fd_set fd;
+
+    for (auto i = 0; i < FD_SETSIZE; i++)
+    {
+        assert(!FD_ISSET(i, &fd));
+    }
+
+    for (auto i = 0; i < FD_SETSIZE; i++)
+    {
+        if ((i & -i) == i)
+            FD_SET(i, &fd);
+    }
+
+    for (auto i = 0; i < FD_SETSIZE; i++)
+    {
+        if ((i & -i) == i)
+            assert(FD_ISSET(i, &fd));
+        else
+            assert(!FD_ISSET(i, &fd));
+    }
+
+    for (auto i = 0; i < FD_SETSIZE; i++)
+    {
+        if ((i & -i) == i)
+            FD_CLR(i, &fd);
+        else
+            FD_SET(i, &fd);
+    }
+
+    for (auto i = 0; i < FD_SETSIZE; i++)
+    {
+        if ((i & -i) == i)
+            assert(!FD_ISSET(i, &fd));
+        else
+            assert(FD_ISSET(i, &fd));
+    }
+
+    FD_ZERO(&fd);
+
+    for (auto i = 0; i < FD_SETSIZE; i++)
+    {
+        assert(!FD_ISSET(i, &fd));
+    }
+}
+
diff --git a/libphobos/libdruntime/core/sys/posix/sys/shm.d b/libphobos/libdruntime/core/sys/posix/sys/shm.d
new file mode 100644
index 00000000000..de16d236dd2
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/shm.d
@@ -0,0 +1,127 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.sys.shm;
+
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types; // for pid_t, time_t, key_t
+public import core.sys.posix.sys.ipc;
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// XOpen (XSI)
+//
+/*
+SHM_RDONLY
+SHM_RND
+
+SHMLBA
+
+shmatt_t
+
+struct shmid_ds
+{
+    ipc_perm    shm_perm;
+    size_t      shm_segsz;
+    pid_t       shm_lpid;
+    pid_t       shm_cpid;
+    shmatt_t    shm_nattch;
+    time_t      shm_atime;
+    time_t      shm_dtime;
+    time_t      shm_ctime;
+}
+
+void* shmat(int, in void*, int);
+int   shmctl(int, int, shmid_ds*);
+int   shmdt(in void*);
+int   shmget(key_t, size_t, int);
+*/
+
+version( CRuntime_Glibc )
+{
+    enum SHM_RDONLY     = 0x01000; // 010000
+    enum SHM_RND        = 0x02000; // 020000
+
+    int   __getpagesize();
+    alias __getpagesize SHMLBA;
+
+    alias c_ulong   shmatt_t;
+
+    /* For any changes, please check /usr/include/bits/shm.h */
+    struct shmid_ds
+    {
+        ipc_perm    shm_perm;
+        size_t      shm_segsz;
+        time_t      shm_atime;
+        version( X86_64 ) {} else c_ulong     __unused1;
+        time_t      shm_dtime;
+        version( X86_64 ) {} else c_ulong     __unused2;
+        time_t      shm_ctime;
+        version( X86_64 ) {} else c_ulong     __unused3;
+        pid_t       shm_cpid;
+        pid_t       shm_lpid;
+        shmatt_t    shm_nattch;
+        c_ulong     __unused4;
+        c_ulong     __unused5;
+    }
+
+    void* shmat(int, in void*, int);
+    int   shmctl(int, int, shmid_ds*);
+    int   shmdt(in void*);
+    int   shmget(key_t, size_t, int);
+}
+else version( FreeBSD )
+{
+    enum SHM_RDONLY     = 0x01000; // 010000
+    enum SHM_RND        = 0x02000; // 020000
+    enum SHMLBA         = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
+
+    alias c_ulong   shmatt_t;
+
+    struct shmid_ds_old // <= FreeBSD7
+    {
+        ipc_perm_old    shm_perm;
+        int             shm_segsz;
+        pid_t           shm_lpid;
+        pid_t           shm_cpid;
+        short           shm_nattch;
+        time_t          shm_atime;
+        time_t          shm_dtime;
+        time_t          shm_ctime;
+        void*           shm_internal;
+    }
+
+    struct shmid_ds
+    {
+         ipc_perm    shm_perm;
+         int         shm_segsz;
+         pid_t       shm_lpid;
+         pid_t       shm_cpid;
+         short       shm_nattch;
+         time_t      shm_atime;
+         time_t      shm_dtime;
+         time_t      shm_ctime;
+    }
+
+    void* shmat(int, in void*, int);
+    int   shmctl(int, int, shmid_ds*);
+    int   shmdt(in void*);
+    int   shmget(key_t, size_t, int);
+}
+else version( OSX )
+{
+
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/socket.d b/libphobos/libdruntime/core/sys/posix/sys/socket.d
new file mode 100644
index 00000000000..a9d978d6d1e
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/socket.d
@@ -0,0 +1,1378 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.sys.socket;
+
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types; // for ssize_t
+public import core.sys.posix.sys.uio;   // for iovec
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// Required
+//
+/*
+socklen_t
+sa_family_t
+
+struct sockaddr
+{
+    sa_family_t sa_family;
+    char        sa_data[];
+}
+
+struct sockaddr_storage
+{
+    sa_family_t ss_family;
+}
+
+struct msghdr
+{
+    void*         msg_name;
+    socklen_t     msg_namelen;
+    struct iovec* msg_iov;
+    int           msg_iovlen;
+    void*         msg_control;
+    socklen_t     msg_controllen;
+    int           msg_flags;
+}
+
+struct iovec {} // from core.sys.posix.sys.uio
+
+struct cmsghdr
+{
+    socklen_t cmsg_len;
+    int       cmsg_level;
+    int       cmsg_type;
+}
+
+SCM_RIGHTS
+
+CMSG_DATA(cmsg)
+CMSG_NXTHDR(mhdr,cmsg)
+CMSG_FIRSTHDR(mhdr)
+
+struct linger
+{
+    int l_onoff;
+    int l_linger;
+}
+
+SOCK_DGRAM
+SOCK_SEQPACKET
+SOCK_STREAM
+
+SOL_SOCKET
+
+SO_ACCEPTCONN
+SO_BROADCAST
+SO_DEBUG
+SO_DONTROUTE
+SO_ERROR
+SO_KEEPALIVE
+SO_LINGER
+SO_OOBINLINE
+SO_RCVBUF
+SO_RCVLOWAT
+SO_RCVTIMEO
+SO_REUSEADDR
+SO_SNDBUF
+SO_SNDLOWAT
+SO_SNDTIMEO
+SO_TYPE
+
+SOMAXCONN
+
+MSG_CTRUNC
+MSG_DONTROUTE
+MSG_EOR
+MSG_OOB
+MSG_PEEK
+MSG_TRUNC
+MSG_WAITALL
+
+AF_INET
+AF_UNIX
+AF_UNSPEC
+
+SHUT_RD
+SHUT_RDWR
+SHUT_WR
+
+int     accept(int, sockaddr*, socklen_t*);
+int     bind(int, in sockaddr*, socklen_t);
+int     connect(int, in sockaddr*, socklen_t);
+int     getpeername(int, sockaddr*, socklen_t*);
+int     getsockname(int, sockaddr*, socklen_t*);
+int     getsockopt(int, int, int, void*, socklen_t*);
+int     listen(int, int);
+ssize_t recv(int, void*, size_t, int);
+ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
+ssize_t recvmsg(int, msghdr*, int);
+ssize_t send(int, in void*, size_t, int);
+ssize_t sendmsg(int, in msghdr*, int);
+ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
+int     setsockopt(int, int, int, in void*, socklen_t);
+int     shutdown(int, int);
+int     socket(int, int, int);
+int     sockatmark(int);
+int     socketpair(int, int, int, ref int[2]);
+*/
+
+version( CRuntime_Glibc )
+{
+    // Some of the constants below and from the Bionic section are really from
+    // the linux kernel headers.
+    alias uint   socklen_t;
+    alias ushort sa_family_t;
+
+    struct sockaddr
+    {
+        sa_family_t sa_family;
+        byte[14]    sa_data;
+    }
+
+    private enum : size_t
+    {
+        _SS_SIZE    = 128,
+        _SS_PADSIZE = _SS_SIZE - (c_ulong.sizeof * 2)
+    }
+
+    struct sockaddr_storage
+    {
+        sa_family_t ss_family;
+        c_ulong     __ss_align;
+        byte[_SS_PADSIZE] __ss_padding;
+    }
+
+    struct msghdr
+    {
+        void*     msg_name;
+        socklen_t msg_namelen;
+        iovec*    msg_iov;
+        size_t    msg_iovlen;
+        void*     msg_control;
+        size_t    msg_controllen;
+        int       msg_flags;
+    }
+
+    struct cmsghdr
+    {
+        size_t cmsg_len;
+        int    cmsg_level;
+        int    cmsg_type;
+        static if( false /* (!is( __STRICT_ANSI__ ) && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L */ )
+        {
+            ubyte[1] __cmsg_data;
+        }
+    }
+
+    enum : uint
+    {
+        SCM_RIGHTS = 0x01
+    }
+
+    static if( false /* (!is( __STRICT_ANSI__ ) && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L */ )
+    {
+        extern (D) ubyte[1] CMSG_DATA( cmsghdr* cmsg ) pure nothrow @nogc { return cmsg.__cmsg_data; }
+    }
+    else
+    {
+        extern (D) inout(ubyte)*   CMSG_DATA( inout(cmsghdr)* cmsg ) pure nothrow @nogc { return cast(ubyte*)( cmsg + 1 ); }
+    }
+
+    private inout(cmsghdr)* __cmsg_nxthdr(inout(msghdr)*, inout(cmsghdr)*) pure nothrow @nogc;
+    extern (D)  inout(cmsghdr)* CMSG_NXTHDR(inout(msghdr)* msg, inout(cmsghdr)* cmsg) pure nothrow @nogc
+    {
+        return __cmsg_nxthdr(msg, cmsg);
+    }
+
+    extern (D) inout(cmsghdr)* CMSG_FIRSTHDR( inout(msghdr)* mhdr ) pure nothrow @nogc
+    {
+        return ( cast(size_t)mhdr.msg_controllen >= cmsghdr.sizeof
+                             ? cast(inout(cmsghdr)*) mhdr.msg_control
+                             : cast(inout(cmsghdr)*) null );
+    }
+
+    extern (D)
+    {
+        size_t CMSG_ALIGN( size_t len ) pure nothrow @nogc
+        {
+            return (len + size_t.sizeof - 1) & cast(size_t) (~(size_t.sizeof - 1));
+        }
+
+        size_t CMSG_LEN( size_t len ) pure nothrow @nogc
+        {
+            return CMSG_ALIGN(cmsghdr.sizeof) + len;
+        }
+    }
+
+    extern (D) size_t CMSG_SPACE(size_t len) pure nothrow @nogc
+    {
+        return CMSG_ALIGN(len) + CMSG_ALIGN(cmsghdr.sizeof);
+    }
+
+    struct linger
+    {
+        int l_onoff;
+        int l_linger;
+    }
+
+    version (X86)
+    {
+        enum
+        {
+            SOCK_DGRAM      = 2,
+            SOCK_SEQPACKET  = 5,
+            SOCK_STREAM     = 1
+        }
+
+        enum
+        {
+            SOL_SOCKET      = 1
+        }
+
+        enum
+        {
+            SO_ACCEPTCONN   = 30,
+            SO_BROADCAST    = 6,
+            SO_DEBUG        = 1,
+            SO_DONTROUTE    = 5,
+            SO_ERROR        = 4,
+            SO_KEEPALIVE    = 9,
+            SO_LINGER       = 13,
+            SO_OOBINLINE    = 10,
+            SO_RCVBUF       = 8,
+            SO_RCVLOWAT     = 18,
+            SO_RCVTIMEO     = 20,
+            SO_REUSEADDR    = 2,
+            SO_SNDBUF       = 7,
+            SO_SNDLOWAT     = 19,
+            SO_SNDTIMEO     = 21,
+            SO_TYPE         = 3
+        }
+    }
+    else version (X86_64)
+    {
+        enum
+        {
+            SOCK_DGRAM      = 2,
+            SOCK_SEQPACKET  = 5,
+            SOCK_STREAM     = 1
+        }
+
+        enum
+        {
+            SOL_SOCKET      = 1
+        }
+
+        enum
+        {
+            SO_ACCEPTCONN   = 30,
+            SO_BROADCAST    = 6,
+            SO_DEBUG        = 1,
+            SO_DONTROUTE    = 5,
+            SO_ERROR        = 4,
+            SO_KEEPALIVE    = 9,
+            SO_LINGER       = 13,
+            SO_OOBINLINE    = 10,
+            SO_RCVBUF       = 8,
+            SO_RCVLOWAT     = 18,
+            SO_RCVTIMEO     = 20,
+            SO_REUSEADDR    = 2,
+            SO_SNDBUF       = 7,
+            SO_SNDLOWAT     = 19,
+            SO_SNDTIMEO     = 21,
+            SO_TYPE         = 3
+        }
+    }
+    else version (MIPS32)
+    {
+        enum
+        {
+            SOCK_DGRAM      = 1,
+            SOCK_SEQPACKET  = 5,
+            SOCK_STREAM     = 2,
+        }
+
+        enum
+        {
+            SOL_SOCKET      = 0xffff
+        }
+
+        enum
+        {
+            SO_ACCEPTCONN   = 0x1009,
+            SO_BROADCAST    = 0x0020,
+            SO_DEBUG        = 0x0001,
+            SO_DONTROUTE    = 0x0010,
+            SO_ERROR        = 0x1007,
+            SO_KEEPALIVE    = 0x0008,
+            SO_LINGER       = 0x0080,
+            SO_OOBINLINE    = 0x0100,
+            SO_RCVBUF       = 0x1002,
+            SO_RCVLOWAT     = 0x1004,
+            SO_RCVTIMEO     = 0x1006,
+            SO_REUSEADDR    = 0x0004,
+            SO_SNDBUF       = 0x1001,
+            SO_SNDLOWAT     = 0x1003,
+            SO_SNDTIMEO     = 0x1005,
+            SO_TYPE         = 0x1008,
+        }
+    }
+    else version (MIPS64)
+    {
+        enum
+        {
+            SOCK_DGRAM      = 1,
+            SOCK_SEQPACKET  = 5,
+            SOCK_STREAM     = 2,
+        }
+
+        enum
+        {
+            SOL_SOCKET      = 0xffff
+        }
+
+        enum
+        {
+            SO_ACCEPTCONN   = 0x1009,
+            SO_BROADCAST    = 0x0020,
+            SO_DEBUG        = 0x0001,
+            SO_DONTROUTE    = 0x0010,
+            SO_ERROR        = 0x1007,
+            SO_KEEPALIVE    = 0x0008,
+            SO_LINGER       = 0x0080,
+            SO_OOBINLINE    = 0x0100,
+            SO_RCVBUF       = 0x1002,
+            SO_RCVLOWAT     = 0x1004,
+            SO_RCVTIMEO     = 0x1006,
+            SO_REUSEADDR    = 0x0004,
+            SO_SNDBUF       = 0x1001,
+            SO_SNDLOWAT     = 0x1003,
+            SO_SNDTIMEO     = 0x1005,
+            SO_TYPE         = 0x1008,
+        }
+    }
+    else version (PPC)
+    {
+        enum
+        {
+            SOCK_DGRAM      = 2,
+            SOCK_SEQPACKET  = 5,
+            SOCK_STREAM     = 1
+        }
+
+        enum
+        {
+            SOL_SOCKET      = 1
+        }
+
+        enum
+        {
+            SO_ACCEPTCONN   = 30,
+            SO_BROADCAST    = 6,
+            SO_DEBUG        = 1,
+            SO_DONTROUTE    = 5,
+            SO_ERROR        = 4,
+            SO_KEEPALIVE    = 9,
+            SO_LINGER       = 13,
+            SO_OOBINLINE    = 10,
+            SO_RCVBUF       = 8,
+            SO_RCVLOWAT     = 16,
+            SO_RCVTIMEO     = 18,
+            SO_REUSEADDR    = 2,
+            SO_SNDBUF       = 7,
+            SO_SNDLOWAT     = 17,
+            SO_SNDTIMEO     = 19,
+            SO_TYPE         = 3
+        }
+    }
+    else version (PPC64)
+    {
+        enum
+        {
+            SOCK_DGRAM      = 2,
+            SOCK_SEQPACKET  = 5,
+            SOCK_STREAM     = 1
+        }
+
+        enum
+        {
+            SOL_SOCKET      = 1
+        }
+
+        enum
+        {
+            SO_ACCEPTCONN   = 30,
+            SO_BROADCAST    = 6,
+            SO_DEBUG        = 1,
+            SO_DONTROUTE    = 5,
+            SO_ERROR        = 4,
+            SO_KEEPALIVE    = 9,
+            SO_LINGER       = 13,
+            SO_OOBINLINE    = 10,
+            SO_RCVBUF       = 8,
+            SO_RCVLOWAT     = 16,
+            SO_RCVTIMEO     = 18,
+            SO_REUSEADDR    = 2,
+            SO_SNDBUF       = 7,
+            SO_SNDLOWAT     = 17,
+            SO_SNDTIMEO     = 19,
+            SO_TYPE         = 3
+        }
+    }
+    else version (AArch64)
+    {
+        enum
+        {
+            SOCK_DGRAM      = 2,
+            SOCK_SEQPACKET  = 5,
+            SOCK_STREAM     = 1
+        }
+
+        enum
+        {
+            SOL_SOCKET      = 1
+        }
+
+        enum
+        {
+            SO_ACCEPTCONN   = 30,
+            SO_BROADCAST    = 6,
+            SO_DEBUG        = 1,
+            SO_DONTROUTE    = 5,
+            SO_ERROR        = 4,
+            SO_KEEPALIVE    = 9,
+            SO_LINGER       = 13,
+            SO_OOBINLINE    = 10,
+            SO_RCVBUF       = 8,
+            SO_RCVLOWAT     = 18,
+            SO_RCVTIMEO     = 20,
+            SO_REUSEADDR    = 2,
+            SO_SNDBUF       = 7,
+            SO_SNDLOWAT     = 19,
+            SO_SNDTIMEO     = 21,
+            SO_TYPE         = 3
+        }
+    }
+    else version (ARM)
+    {
+        enum
+        {
+            SOCK_DGRAM      = 2,
+            SOCK_SEQPACKET  = 5,
+            SOCK_STREAM     = 1
+        }
+
+        enum
+        {
+            SOL_SOCKET      = 1
+        }
+
+        enum
+        {
+            SO_ACCEPTCONN   = 30,
+            SO_BROADCAST    = 6,
+            SO_DEBUG        = 1,
+            SO_DONTROUTE    = 5,
+            SO_ERROR        = 4,
+            SO_KEEPALIVE    = 9,
+            SO_LINGER       = 13,
+            SO_OOBINLINE    = 10,
+            SO_RCVBUF       = 8,
+            SO_RCVLOWAT     = 18,
+            SO_RCVTIMEO     = 20,
+            SO_REUSEADDR    = 2,
+            SO_SNDBUF       = 7,
+            SO_SNDLOWAT     = 19,
+            SO_SNDTIMEO     = 21,
+            SO_TYPE         = 3
+        }
+    }
+    else version (SystemZ)
+    {
+        enum
+        {
+            SOCK_DGRAM      = 2,
+            SOCK_SEQPACKET  = 5,
+            SOCK_STREAM     = 1
+        }
+
+        enum
+        {
+            SOL_SOCKET      = 1
+        }
+
+        enum
+        {
+            SO_ACCEPTCONN   = 30,
+            SO_BROADCAST    = 6,
+            SO_DEBUG        = 1,
+            SO_DONTROUTE    = 5,
+            SO_ERROR        = 4,
+            SO_KEEPALIVE    = 9,
+            SO_LINGER       = 13,
+            SO_OOBINLINE    = 10,
+            SO_RCVBUF       = 8,
+            SO_RCVLOWAT     = 18,
+            SO_RCVTIMEO     = 20,
+            SO_REUSEADDR    = 2,
+            SO_SNDBUF       = 7,
+            SO_SNDLOWAT     = 19,
+            SO_SNDTIMEO     = 21,
+            SO_TYPE         = 3
+        }
+    }
+    else
+        static assert(0, "unimplemented");
+
+    enum
+    {
+        SOMAXCONN       = 128
+    }
+
+    enum : uint
+    {
+        MSG_CTRUNC      = 0x08,
+        MSG_DONTROUTE   = 0x04,
+        MSG_EOR         = 0x80,
+        MSG_OOB         = 0x01,
+        MSG_PEEK        = 0x02,
+        MSG_TRUNC       = 0x20,
+        MSG_WAITALL     = 0x100,
+        MSG_NOSIGNAL    = 0x4000
+    }
+
+    enum
+    {
+        AF_APPLETALK    = 5,
+        AF_INET         = 2,
+        AF_IPX          = 4,
+        AF_UNIX         = 1,
+        AF_UNSPEC       = 0,
+        PF_APPLETALK    = AF_APPLETALK,
+        PF_IPX          = AF_IPX
+    }
+
+    enum int SOCK_RDM   = 4;
+
+    enum
+    {
+        SHUT_RD,
+        SHUT_WR,
+        SHUT_RDWR
+    }
+
+    int     accept(int, sockaddr*, socklen_t*);
+    int     bind(int, in sockaddr*, socklen_t);
+    int     connect(int, in sockaddr*, socklen_t);
+    int     getpeername(int, sockaddr*, socklen_t*);
+    int     getsockname(int, sockaddr*, socklen_t*);
+    int     getsockopt(int, int, int, void*, socklen_t*);
+    int     listen(int, int);
+    ssize_t recv(int, void*, size_t, int);
+    ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
+    ssize_t recvmsg(int, msghdr*, int);
+    ssize_t send(int, in void*, size_t, int);
+    ssize_t sendmsg(int, in msghdr*, int);
+    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
+    int     setsockopt(int, int, int, in void*, socklen_t);
+    int     shutdown(int, int);
+    int     socket(int, int, int);
+    int     sockatmark(int);
+    int     socketpair(int, int, int, ref int[2]);
+}
+else version( OSX )
+{
+    alias uint   socklen_t;
+    alias ubyte  sa_family_t;
+
+    struct sockaddr
+    {
+        ubyte       sa_len;
+        sa_family_t sa_family;
+        byte[14]    sa_data;
+    }
+
+    private enum : size_t
+    {
+        _SS_PAD1    = long.sizeof - ubyte.sizeof - sa_family_t.sizeof,
+        _SS_PAD2    = 128 - ubyte.sizeof - sa_family_t.sizeof - _SS_PAD1 - long.sizeof
+    }
+
+    struct sockaddr_storage
+    {
+         ubyte          ss_len;
+         sa_family_t    ss_family;
+         byte[_SS_PAD1] __ss_pad1;
+         long           __ss_align;
+         byte[_SS_PAD2] __ss_pad2;
+    }
+
+    struct msghdr
+    {
+        void*     msg_name;
+        socklen_t msg_namelen;
+        iovec*    msg_iov;
+        int       msg_iovlen;
+        void*     msg_control;
+        socklen_t msg_controllen;
+        int       msg_flags;
+    }
+
+    struct cmsghdr
+    {
+         socklen_t cmsg_len;
+         int       cmsg_level;
+         int       cmsg_type;
+    }
+
+    enum : uint
+    {
+        SCM_RIGHTS = 0x01
+    }
+
+    /+
+    CMSG_DATA(cmsg)     ((unsigned char *)(cmsg) + \
+                         ALIGN(sizeof(struct cmsghdr)))
+    CMSG_NXTHDR(mhdr, cmsg) \
+                        (((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len) + \
+                         ALIGN(sizeof(struct cmsghdr)) > \
+                         (unsigned char *)(mhdr)->msg_control +(mhdr)->msg_controllen) ? \
+                         (struct cmsghdr *)0 /* NULL */ : \
+                         (struct cmsghdr *)((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len)))
+    CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
+    +/
+
+    struct linger
+    {
+        int l_onoff;
+        int l_linger;
+    }
+
+    enum
+    {
+        SOCK_DGRAM      = 2,
+        SOCK_RDM        = 4,
+        SOCK_SEQPACKET  = 5,
+        SOCK_STREAM     = 1
+    }
+
+    enum : uint
+    {
+        SOL_SOCKET      = 0xffff
+    }
+
+    enum : uint
+    {
+        SO_ACCEPTCONN   = 0x0002,
+        SO_BROADCAST    = 0x0020,
+        SO_DEBUG        = 0x0001,
+        SO_DONTROUTE    = 0x0010,
+        SO_ERROR        = 0x1007,
+        SO_KEEPALIVE    = 0x0008,
+        SO_LINGER       = 0x1080,
+        SO_NOSIGPIPE    = 0x1022, // non-standard
+        SO_OOBINLINE    = 0x0100,
+        SO_RCVBUF       = 0x1002,
+        SO_RCVLOWAT     = 0x1004,
+        SO_RCVTIMEO     = 0x1006,
+        SO_REUSEADDR    = 0x0004,
+        SO_SNDBUF       = 0x1001,
+        SO_SNDLOWAT     = 0x1003,
+        SO_SNDTIMEO     = 0x1005,
+        SO_TYPE         = 0x1008
+    }
+
+    enum
+    {
+        SOMAXCONN       = 128
+    }
+
+    enum : uint
+    {
+        MSG_CTRUNC      = 0x20,
+        MSG_DONTROUTE   = 0x4,
+        MSG_EOR         = 0x8,
+        MSG_OOB         = 0x1,
+        MSG_PEEK        = 0x2,
+        MSG_TRUNC       = 0x10,
+        MSG_WAITALL     = 0x40
+    }
+
+    enum
+    {
+        AF_APPLETALK    = 16,
+        AF_INET         = 2,
+        AF_IPX          = 23,
+        AF_UNIX         = 1,
+        AF_UNSPEC       = 0,
+        PF_APPLETALK    = AF_APPLETALK,
+        PF_IPX          = AF_IPX
+    }
+
+    enum
+    {
+        SHUT_RD,
+        SHUT_WR,
+        SHUT_RDWR
+    }
+
+    int     accept(int, sockaddr*, socklen_t*);
+    int     bind(int, in sockaddr*, socklen_t);
+    int     connect(int, in sockaddr*, socklen_t);
+    int     getpeername(int, sockaddr*, socklen_t*);
+    int     getsockname(int, sockaddr*, socklen_t*);
+    int     getsockopt(int, int, int, void*, socklen_t*);
+    int     listen(int, int);
+    ssize_t recv(int, void*, size_t, int);
+    ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
+    ssize_t recvmsg(int, msghdr*, int);
+    ssize_t send(int, in void*, size_t, int);
+    ssize_t sendmsg(int, in msghdr*, int);
+    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
+    int     setsockopt(int, int, int, in void*, socklen_t);
+    int     shutdown(int, int);
+    int     socket(int, int, int);
+    int     sockatmark(int);
+    int     socketpair(int, int, int, ref int[2]);
+}
+else version( FreeBSD )
+{
+    alias uint   socklen_t;
+    alias ubyte  sa_family_t;
+
+    struct sockaddr
+    {
+        ubyte       sa_len;
+        sa_family_t sa_family;
+        byte[14]    sa_data;
+    }
+
+    private
+    {
+        enum _SS_ALIGNSIZE  = long.sizeof;
+        enum _SS_MAXSIZE    = 128;
+        enum _SS_PAD1SIZE   = _SS_ALIGNSIZE - ubyte.sizeof - sa_family_t.sizeof;
+        enum _SS_PAD2SIZE   = _SS_MAXSIZE - ubyte.sizeof - sa_family_t.sizeof - _SS_PAD1SIZE - _SS_ALIGNSIZE;
+    }
+
+    struct sockaddr_storage
+    {
+         ubyte              ss_len;
+         sa_family_t        ss_family;
+         byte[_SS_PAD1SIZE] __ss_pad1;
+         long               __ss_align;
+         byte[_SS_PAD2SIZE] __ss_pad2;
+    }
+
+    struct msghdr
+    {
+        void*     msg_name;
+        socklen_t msg_namelen;
+        iovec*    msg_iov;
+        int       msg_iovlen;
+        void*     msg_control;
+        socklen_t msg_controllen;
+        int       msg_flags;
+    }
+
+    struct cmsghdr
+    {
+         socklen_t cmsg_len;
+         int       cmsg_level;
+         int       cmsg_type;
+    }
+
+    enum : uint
+    {
+        SCM_RIGHTS = 0x01
+    }
+
+    private // <machine/param.h>
+    {
+        enum _ALIGNBYTES = /+c_int+/ int.sizeof - 1;
+        extern (D) size_t _ALIGN( size_t p ) { return (p + _ALIGNBYTES) & ~_ALIGNBYTES; }
+    }
+
+    extern (D) ubyte* CMSG_DATA( cmsghdr* cmsg )
+    {
+        return cast(ubyte*) cmsg + _ALIGN( cmsghdr.sizeof );
+    }
+
+    extern (D) cmsghdr* CMSG_NXTHDR( msghdr* mhdr, cmsghdr* cmsg )
+    {
+        if( cmsg == null )
+        {
+           return CMSG_FIRSTHDR( mhdr );
+        }
+        else
+        {
+            if( cast(ubyte*) cmsg + _ALIGN( cmsg.cmsg_len ) + _ALIGN( cmsghdr.sizeof ) >
+                    cast(ubyte*) mhdr.msg_control + mhdr.msg_controllen )
+                return null;
+            else
+                return cast(cmsghdr*) (cast(ubyte*) cmsg + _ALIGN( cmsg.cmsg_len ));
+        }
+    }
+
+    extern (D) cmsghdr* CMSG_FIRSTHDR( msghdr* mhdr )
+    {
+        return mhdr.msg_controllen >= cmsghdr.sizeof ? cast(cmsghdr*) mhdr.msg_control : null;
+    }
+
+    struct linger
+    {
+        int l_onoff;
+        int l_linger;
+    }
+
+    enum
+    {
+        SOCK_DGRAM      = 2,
+        SOCK_RDM        = 4,
+        SOCK_SEQPACKET  = 5,
+        SOCK_STREAM     = 1
+    }
+
+    enum : uint
+    {
+        SOL_SOCKET      = 0xffff
+    }
+
+    enum : uint
+    {
+        SO_ACCEPTCONN   = 0x0002,
+        SO_BROADCAST    = 0x0020,
+        SO_DEBUG        = 0x0001,
+        SO_DONTROUTE    = 0x0010,
+        SO_ERROR        = 0x1007,
+        SO_KEEPALIVE    = 0x0008,
+        SO_LINGER       = 0x0080,
+        SO_NOSIGPIPE    = 0x0800, // non-standard
+        SO_OOBINLINE    = 0x0100,
+        SO_RCVBUF       = 0x1002,
+        SO_RCVLOWAT     = 0x1004,
+        SO_RCVTIMEO     = 0x1006,
+        SO_REUSEADDR    = 0x0004,
+        SO_SNDBUF       = 0x1001,
+        SO_SNDLOWAT     = 0x1003,
+        SO_SNDTIMEO     = 0x1005,
+        SO_TYPE         = 0x1008
+    }
+
+    enum
+    {
+        SOMAXCONN       = 128
+    }
+
+    enum : uint
+    {
+        MSG_CTRUNC      = 0x20,
+        MSG_DONTROUTE   = 0x4,
+        MSG_EOR         = 0x8,
+        MSG_OOB         = 0x1,
+        MSG_PEEK        = 0x2,
+        MSG_TRUNC       = 0x10,
+        MSG_WAITALL     = 0x40,
+        MSG_NOSIGNAL    = 0x20000
+    }
+
+    enum
+    {
+        AF_APPLETALK    = 16,
+        AF_INET         = 2,
+        AF_IPX          = 23,
+        AF_UNIX         = 1,
+        AF_UNSPEC       = 0
+    }
+
+    enum
+    {
+        SHUT_RD = 0,
+        SHUT_WR = 1,
+        SHUT_RDWR = 2
+    }
+
+    int     accept(int, sockaddr*, socklen_t*);
+    int     bind(int, in sockaddr*, socklen_t);
+    int     connect(int, in sockaddr*, socklen_t);
+    int     getpeername(int, sockaddr*, socklen_t*);
+    int     getsockname(int, sockaddr*, socklen_t*);
+    int     getsockopt(int, int, int, void*, socklen_t*);
+    int     listen(int, int);
+    ssize_t recv(int, void*, size_t, int);
+    ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
+    ssize_t recvmsg(int, msghdr*, int);
+    ssize_t send(int, in void*, size_t, int);
+    ssize_t sendmsg(int, in msghdr*, int);
+    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
+    int     setsockopt(int, int, int, in void*, socklen_t);
+    int     shutdown(int, int);
+    int     socket(int, int, int);
+    int     sockatmark(int);
+    int     socketpair(int, int, int, ref int[2]);
+}
+else version (Solaris)
+{
+    alias uint socklen_t;
+    alias ushort sa_family_t;
+
+    struct sockaddr
+    {
+        sa_family_t sa_family;
+        char[14] sa_data;
+    }
+
+    alias double sockaddr_maxalign_t;
+
+    private
+    {
+        enum _SS_ALIGNSIZE  = sockaddr_maxalign_t.sizeof;
+        enum _SS_MAXSIZE    = 256;
+        enum _SS_PAD1SIZE   = _SS_ALIGNSIZE - sa_family_t.sizeof;
+        enum _SS_PAD2SIZE   = _SS_MAXSIZE - sa_family_t.sizeof + _SS_PAD1SIZE + _SS_ALIGNSIZE;
+    }
+
+    struct sockaddr_storage
+    {
+         sa_family_t ss_family;
+         char[_SS_PAD1SIZE] _ss_pad1;
+         sockaddr_maxalign_t _ss_align;
+         char[_SS_PAD2SIZE] _ss_pad2;
+    }
+
+    struct msghdr
+    {
+        void* msg_name;
+        socklen_t msg_namelen;
+        iovec* msg_iov;
+        int msg_iovlen;
+        void* msg_control;
+        socklen_t msg_controllen;
+        int msg_flags;
+    }
+
+    struct cmsghdr
+    {
+         socklen_t cmsg_len;
+         int cmsg_level;
+         int cmsg_type;
+    }
+
+    enum : uint
+    {
+        SCM_RIGHTS = 0x1010
+    }
+
+    // FIXME: CMSG_DATA, CMSG_NXTHDR, CMSG_FIRSTHDR missing
+
+    struct linger
+    {
+        int l_onoff;
+        int l_linger;
+    }
+
+    enum
+    {
+        SOCK_STREAM = 2,
+        SOCK_DGRAM = 1,
+        SOCK_RDM = 5,
+        SOCK_SEQPACKET = 6,
+    }
+
+    enum : uint
+    {
+        SOL_SOCKET      = 0xffff
+    }
+
+    enum : uint
+    {
+        SO_ACCEPTCONN   = 0x0002,
+        SO_BROADCAST    = 0x0020,
+        SO_DEBUG        = 0x0001,
+        SO_DONTROUTE    = 0x0010,
+        SO_ERROR        = 0x1007,
+        SO_KEEPALIVE    = 0x0008,
+        SO_LINGER       = 0x0080,
+        SO_OOBINLINE    = 0x0100,
+        SO_RCVBUF       = 0x1002,
+        SO_RCVLOWAT     = 0x1004,
+        SO_RCVTIMEO     = 0x1006,
+        SO_REUSEADDR    = 0x0004,
+        SO_SNDBUF       = 0x1001,
+        SO_SNDLOWAT     = 0x1003,
+        SO_SNDTIMEO     = 0x1005,
+        SO_TYPE         = 0x1008,
+
+        SO_USELOOPBACK  = 0x0040, // non-standard
+        SO_DGRAM_ERRIND = 0x0200, // non-standard
+        SO_RECVUCRED    = 0x0400, // non-standard
+    }
+
+    enum
+    {
+        SOMAXCONN = 128
+    }
+
+    enum : uint
+    {
+        MSG_CTRUNC      = 0x10,
+        MSG_DONTROUTE   = 0x4,
+        MSG_EOR         = 0x8,
+        MSG_OOB         = 0x1,
+        MSG_PEEK        = 0x2,
+        MSG_TRUNC       = 0x20,
+        MSG_WAITALL     = 0x40
+    }
+
+    enum
+    {
+        AF_IPX          = 23,
+        AF_APPLETALK    = 16,
+        AF_INET         = 2,
+        AF_UNIX         = 1,
+        AF_UNSPEC       = 0
+    }
+
+    enum
+    {
+        SHUT_RD,
+        SHUT_WR,
+        SHUT_RDWR
+    }
+
+    int accept(int, sockaddr*, socklen_t*);
+    int bind(int, in sockaddr*, socklen_t);
+    int connect(int, in sockaddr*, socklen_t);
+    int getpeername(int, sockaddr*, socklen_t*);
+    int getsockname(int, sockaddr*, socklen_t*);
+    int getsockopt(int, int, int, void*, socklen_t*);
+    int listen(int, int);
+    ssize_t recv(int, void*, size_t, int);
+    ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
+    ssize_t recvmsg(int, msghdr*, int);
+    ssize_t send(int, in void*, size_t, int);
+    ssize_t sendmsg(int, in msghdr*, int);
+    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
+    int setsockopt(int, int, int, in void*, socklen_t);
+    int shutdown(int, int);
+    int socket(int, int, int);
+    int sockatmark(int);
+    int socketpair(int, int, int, ref int[2]);
+}
+else version( CRuntime_Bionic )
+{
+    alias int    socklen_t;
+    alias ushort sa_family_t;
+
+    struct sockaddr
+    {
+        sa_family_t sa_family;
+        byte[14]    sa_data;
+    }
+
+    private enum size_t _K_SS_MAXSIZE  = 128;
+
+    struct sockaddr_storage
+    {
+        ushort ss_family;
+        byte[_K_SS_MAXSIZE - ushort.sizeof] __data;
+    }
+
+    enum : uint
+    {
+        SCM_RIGHTS = 0x01
+    }
+
+    private enum _ALIGNBYTES = c_long.sizeof - 1;
+
+    extern (D)
+    {
+        size_t CMSG_ALIGN( size_t len )
+        {
+            return (len + _ALIGNBYTES) & ~_ALIGNBYTES;
+        }
+
+        void* CMSG_DATA( cmsghdr* cmsg )
+        {
+            return cast(void*) (cast(char*) cmsg + CMSG_ALIGN( cmsghdr.sizeof ));
+        }
+
+        cmsghdr* CMSG_NXTHDR( msghdr* mhdr, cmsghdr* cmsg )
+        {
+            cmsghdr* __ptr = cast(cmsghdr*) ((cast(ubyte*) cmsg) + CMSG_ALIGN(cmsg.cmsg_len));
+            return cast(c_ulong)( cast(char*)(__ptr+1) - cast(char*) mhdr.msg_control) > mhdr.msg_controllen ? null : __ptr;
+        }
+
+        cmsghdr* CMSG_FIRSTHDR( msghdr* mhdr )
+        {
+            return mhdr.msg_controllen >= cmsghdr.sizeof ? cast(cmsghdr*) mhdr.msg_control : null;
+        }
+    }
+
+    struct linger
+    {
+        int l_onoff;
+        int l_linger;
+    }
+
+    struct msghdr
+    {
+        void*           msg_name;
+        int             msg_namelen;
+        iovec*          msg_iov;
+        __kernel_size_t msg_iovlen;
+        void*           msg_control;
+        __kernel_size_t msg_controllen;
+        uint            msg_flags;
+    }
+
+    struct cmsghdr
+    {
+        __kernel_size_t cmsg_len;
+        int             cmsg_level;
+        int             cmsg_type;
+    }
+
+    version (X86)
+    {
+        alias uint __kernel_size_t;
+
+        enum
+        {
+            SOCK_DGRAM      = 2,
+            SOCK_SEQPACKET  = 5,
+            SOCK_STREAM     = 1
+        }
+
+        enum
+        {
+            SOL_SOCKET      = 1
+        }
+
+        enum
+        {
+            SO_ACCEPTCONN   = 30,
+            SO_BROADCAST    = 6,
+            SO_DEBUG        = 1,
+            SO_DONTROUTE    = 5,
+            SO_ERROR        = 4,
+            SO_KEEPALIVE    = 9,
+            SO_LINGER       = 13,
+            SO_OOBINLINE    = 10,
+            SO_RCVBUF       = 8,
+            SO_RCVLOWAT     = 18,
+            SO_RCVTIMEO     = 20,
+            SO_REUSEADDR    = 2,
+            SO_SNDBUF       = 7,
+            SO_SNDLOWAT     = 19,
+            SO_SNDTIMEO     = 21,
+            SO_TYPE         = 3
+        }
+    }
+    else version (ARM)
+    {
+        alias uint __kernel_size_t;
+
+        enum
+        {
+            SOCK_DGRAM      = 2,
+            SOCK_SEQPACKET  = 5,
+            SOCK_STREAM     = 1
+        }
+
+        enum
+        {
+            SOL_SOCKET      = 1
+        }
+
+        enum
+        {
+            SO_ACCEPTCONN   = 30,
+            SO_BROADCAST    = 6,
+            SO_DEBUG        = 1,
+            SO_DONTROUTE    = 5,
+            SO_ERROR        = 4,
+            SO_KEEPALIVE    = 9,
+            SO_LINGER       = 13,
+            SO_OOBINLINE    = 10,
+            SO_RCVBUF       = 8,
+            SO_RCVLOWAT     = 18,
+            SO_RCVTIMEO     = 20,
+            SO_REUSEADDR    = 2,
+            SO_SNDBUF       = 7,
+            SO_SNDLOWAT     = 19,
+            SO_SNDTIMEO     = 21,
+            SO_TYPE         = 3
+        }
+    }
+    else
+    {
+        static assert(false, "Architecture not supported.");
+    }
+
+    enum
+    {
+        SOMAXCONN       = 128
+    }
+
+    enum : uint
+    {
+        MSG_CTRUNC      = 0x08,
+        MSG_DONTROUTE   = 0x04,
+        MSG_EOR         = 0x80,
+        MSG_OOB         = 0x01,
+        MSG_PEEK        = 0x02,
+        MSG_TRUNC       = 0x20,
+        MSG_WAITALL     = 0x100
+    }
+
+    enum
+    {
+        AF_APPLETALK    = 5,
+        AF_INET         = 2,
+        AF_IPX          = 4,
+        AF_UNIX         = 1,
+        AF_UNSPEC       = 0
+    }
+
+    enum
+    {
+        SHUT_RD,
+        SHUT_WR,
+        SHUT_RDWR
+    }
+
+    enum SOCK_RDM = 4;
+
+    int     accept(int, sockaddr*, socklen_t*);
+    int     bind(int, in sockaddr*, int);
+    int     connect(int, in sockaddr*, socklen_t);
+    int     getpeername(int, sockaddr*, socklen_t*);
+    int     getsockname(int, sockaddr*, socklen_t*);
+    int     getsockopt(int, int, int, void*, socklen_t*);
+    int     listen(int, int);
+    ssize_t recv(int, void*, size_t, uint);
+    ssize_t recvfrom(int, void*, size_t, uint, in sockaddr*, socklen_t*);
+    int     recvmsg(int, msghdr*, uint);
+    ssize_t send(int, in void*, size_t, uint);
+    int     sendmsg(int, in msghdr*, uint);
+    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
+    int     setsockopt(int, int, int, in void*, socklen_t);
+    int     shutdown(int, int);
+    int     socket(int, int, int);
+    int     socketpair(int, int, int, ref int[2]);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// IPV6 (IP6)
+//
+/*
+AF_INET6
+*/
+
+version( CRuntime_Glibc )
+{
+    enum
+    {
+        AF_INET6    = 10
+    }
+}
+else version( OSX )
+{
+    enum
+    {
+        AF_INET6    = 30
+    }
+}
+else version( FreeBSD )
+{
+    enum
+    {
+        AF_INET6    = 28
+    }
+}
+else version (Solaris)
+{
+    enum
+    {
+        AF_INET6 = 26,
+    }
+}
+else version( CRuntime_Bionic )
+{
+    enum
+    {
+        AF_INET6    = 10
+    }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Raw Sockets (RS)
+//
+/*
+SOCK_RAW
+*/
+
+version( CRuntime_Glibc )
+{
+    enum
+    {
+        SOCK_RAW    = 3
+    }
+}
+else version( OSX )
+{
+    enum
+    {
+        SOCK_RAW    = 3
+    }
+}
+else version( FreeBSD )
+{
+    enum
+    {
+        SOCK_RAW    = 3
+    }
+}
+else version (Solaris)
+{
+    enum
+    {
+        SOCK_RAW = 4,
+    }
+}
+else version( CRuntime_Bionic )
+{
+    enum
+    {
+        SOCK_RAW    = 3
+    }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/stat.d b/libphobos/libdruntime/core/sys/posix/sys/stat.d
new file mode 100644
index 00000000000..a9631860e70
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/stat.d
@@ -0,0 +1,1209 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.sys.stat;
+
+private import core.sys.posix.config;
+private import core.stdc.stdint;
+private import core.sys.posix.time;     // for timespec
+public import core.sys.posix.sys.types; // for off_t, mode_t
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// Required
+//
+/*
+struct stat
+{
+    dev_t   st_dev;
+    ino_t   st_ino;
+    mode_t  st_mode;
+    nlink_t st_nlink;
+    uid_t   st_uid;
+    gid_t   st_gid;
+    off_t   st_size;
+    time_t  st_atime;
+    time_t  st_mtime;
+    time_t  st_ctime;
+}
+
+S_IRWXU
+    S_IRUSR
+    S_IWUSR
+    S_IXUSR
+S_IRWXG
+    S_IRGRP
+    S_IWGRP
+    S_IXGRP
+S_IRWXO
+    S_IROTH
+    S_IWOTH
+    S_IXOTH
+S_ISUID
+S_ISGID
+S_ISVTX
+
+S_ISBLK(m)
+S_ISCHR(m)
+S_ISDIR(m)
+S_ISFIFO(m)
+S_ISREG(m)
+S_ISLNK(m)
+S_ISSOCK(m)
+
+S_TYPEISMQ(buf)
+S_TYPEISSEM(buf)
+S_TYPEISSHM(buf)
+
+int    chmod(in char*, mode_t);
+int    fchmod(int, mode_t);
+int    fstat(int, stat*);
+int    lstat(in char*, stat*);
+int    mkdir(in char*, mode_t);
+int    mkfifo(in char*, mode_t);
+int    stat(in char*, stat*);
+mode_t umask(mode_t);
+ */
+
+version( CRuntime_Glibc )
+{
+    version (X86)
+    {
+        struct stat_t
+        {
+            dev_t       st_dev;
+            ushort      __pad1;
+            static if (!__USE_FILE_OFFSET64)
+            {
+                ino_t       st_ino;
+            }
+            else
+            {
+                uint        __st_ino;
+            }
+            mode_t      st_mode;
+            nlink_t     st_nlink;
+            uid_t       st_uid;
+            gid_t       st_gid;
+            dev_t       st_rdev;
+            ushort      __pad2;
+            off_t       st_size;
+            blksize_t   st_blksize;
+            blkcnt_t    st_blocks;
+            static if (__USE_MISC || __USE_XOPEN2K8)
+            {
+                timespec    st_atim;
+                timespec    st_mtim;
+                timespec    st_ctim;
+                extern(D)
+                {
+                    @property ref time_t st_atime() { return st_atim.tv_sec; }
+                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
+                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                }
+            }
+            else
+            {
+                time_t      st_atime;
+                ulong_t     st_atimensec;
+                time_t      st_mtime;
+                ulong_t     st_mtimensec;
+                time_t      st_ctime;
+                ulong_t     st_ctimensec;
+            }
+            static if (__USE_FILE_OFFSET64)
+            {
+                ino_t       st_ino;
+            }
+            else
+            {
+                c_ulong     __unused4;
+                c_ulong     __unused5;
+            }
+        }
+    }
+    else version (X86_64)
+    {
+        struct stat_t
+        {
+            dev_t       st_dev;
+            ino_t       st_ino;
+            nlink_t     st_nlink;
+            mode_t      st_mode;
+            uid_t       st_uid;
+            gid_t       st_gid;
+            uint        __pad0;
+            dev_t       st_rdev;
+            off_t       st_size;
+            blksize_t   st_blksize;
+            blkcnt_t    st_blocks;
+            static if (__USE_MISC || __USE_XOPEN2K8)
+            {
+                timespec    st_atim;
+                timespec    st_mtim;
+                timespec    st_ctim;
+                extern(D)
+                {
+                    @property ref time_t st_atime() { return st_atim.tv_sec; }
+                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
+                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                }
+            }
+            else
+            {
+                time_t      st_atime;
+                ulong_t     st_atimensec;
+                time_t      st_mtime;
+                ulong_t     st_mtimensec;
+                time_t      st_ctime;
+                ulong_t     st_ctimensec;
+            }
+            slong_t[3]     __unused;
+        }
+    }
+    else version (MIPS_O32)
+    {
+        struct stat_t
+        {
+            c_ulong     st_dev;
+            c_long[3]   st_pad1;
+            ino_t       st_ino;
+            mode_t      st_mode;
+            nlink_t     st_nlink;
+            uid_t       st_uid;
+            gid_t       st_gid;
+            c_ulong     st_rdev;
+            static if (!__USE_FILE_OFFSET64)
+            {
+                c_long[2]   st_pad2;
+                off_t       st_size;
+                c_long      st_pad3;
+            }
+            else
+            {
+                c_long[3]   st_pad2;
+                off_t       st_size;
+            }
+            static if (__USE_MISC || __USE_XOPEN2K8)
+            {
+                timespec    st_atim;
+                timespec    st_mtim;
+                timespec    st_ctim;
+                extern(D)
+                {
+                    @property ref time_t st_atime() { return st_atim.tv_sec; }
+                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
+                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                }
+            }
+            else
+            {
+                time_t      st_atime;
+                c_ulong     st_atimensec;
+                time_t      st_mtime;
+                c_ulong     st_mtimensec;
+                time_t      st_ctime;
+                c_ulong     st_ctimensec;
+            }
+            blksize_t   st_blksize;
+            static if (!__USE_FILE_OFFSET64)
+            {
+                blkcnt_t    st_blocks;
+            }
+            else
+            {
+                c_long      st_pad4;
+                blkcnt_t    st_blocks;
+            }
+            c_long[14]  st_pad5;
+        }
+    }
+    else version (MIPS64)
+    {
+        struct stat_t
+        {
+            c_ulong     st_dev;
+            int[3]      st_pad1;
+            static if (!__USE_FILE_OFFSET64)
+            {
+                ino_t       st_ino;
+            }
+            else
+            {
+                c_ulong     st_ino;
+            }
+            mode_t      st_mode;
+            nlink_t     st_nlink;
+            uid_t       st_uid;
+            gid_t       st_gid;
+            c_ulong     st_rdev;
+            static if (!__USE_FILE_OFFSET64)
+            {
+                uint[2]     st_pad2;
+                off_t       st_size;
+                int         st_pad3;
+            }
+            else
+            {
+                c_long[3]   st_pad2;
+                c_long      st_size;
+            }
+            static if (__USE_MISC || __USE_XOPEN2K8)
+            {
+                timespec    st_atim;
+                timespec    st_mtim;
+                timespec    st_ctim;
+                extern(D)
+                {
+                    @property ref time_t st_atime() { return st_atim.tv_sec; }
+                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
+                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                }
+            }
+            else
+            {
+                time_t      st_atime;
+                c_ulong     st_atimensec;
+                time_t      st_mtime;
+                c_ulong     st_mtimensec;
+                time_t      st_ctime;
+                c_ulong     st_ctimensec;
+            }
+            blksize_t   st_blksize;
+            uint        st_pad4;
+            static if (!__USE_FILE_OFFSET64)
+            {
+                blkcnt_t    st_blocks;
+            }
+            else
+            {
+                c_long  st_blocks;
+            }
+            c_long[14]  st_pad5;
+        }
+    }
+    else version (PPC)
+    {
+        struct stat_t
+        {
+            c_ulong     st_dev;
+            ino_t       st_ino;
+            mode_t      st_mode;
+            nlink_t     st_nlink;
+            uid_t       st_uid;
+            gid_t       st_gid;
+            c_ulong     st_rdev;
+            off_t       st_size;
+            c_ulong     st_blksize;
+            c_ulong     st_blocks;
+            c_ulong     st_atime;
+            c_ulong     st_atime_nsec;
+            c_ulong     st_mtime;
+            c_ulong     st_mtime_nsec;
+            c_ulong     st_ctime;
+            c_ulong     st_ctime_nsec;
+            c_ulong     __unused4;
+            c_ulong     __unused5;
+        }
+    }
+    else version (PPC64)
+    {
+        struct stat_t
+        {
+            c_ulong     st_dev;
+            ino_t       st_ino;
+            nlink_t     st_nlink;
+            mode_t      st_mode;
+            uid_t       st_uid;
+            gid_t       st_gid;
+            c_ulong     st_rdev;
+            off_t       st_size;
+            c_ulong     st_blksize;
+            c_ulong     st_blocks;
+            c_ulong     st_atime;
+            c_ulong     st_atime_nsec;
+            c_ulong     st_mtime;
+            c_ulong     st_mtime_nsec;
+            c_ulong     st_ctime;
+            c_ulong     st_ctime_nsec;
+            c_ulong     __unused4;
+            c_ulong     __unused5;
+            c_ulong     __unused6;
+        }
+    }
+    else version (ARM)
+    {
+        private
+        {
+            alias __dev_t = ulong;
+            alias __ino_t = c_ulong;
+            alias __ino64_t = ulong;
+            alias __mode_t = uint;
+            alias __nlink_t = size_t;
+            alias __uid_t = uint;
+            alias __gid_t = uint;
+            alias __off_t = c_long;
+            alias __off64_t = long;
+            alias __blksize_t = c_long;
+            alias __blkcnt_t = c_long;
+            alias __blkcnt64_t = long;
+            alias __timespec = timespec;
+            alias __time_t = time_t;
+        }
+        struct stat_t
+        {
+            __dev_t st_dev;
+            ushort __pad1;
+
+            static if(!__USE_FILE_OFFSET64)
+            {
+                __ino_t st_ino;
+            }
+            else
+            {
+                __ino_t __st_ino;
+            }
+            __mode_t st_mode;
+            __nlink_t st_nlink;
+            __uid_t st_uid;
+            __gid_t st_gid;
+            __dev_t st_rdev;
+            ushort __pad2;
+
+            static if(!__USE_FILE_OFFSET64)
+            {
+                __off_t st_size;
+            }
+            else
+            {
+                __off64_t st_size;
+            }
+            __blksize_t st_blksize;
+
+            static if(!__USE_FILE_OFFSET64)
+            {
+                __blkcnt_t st_blocks;
+            }
+            else
+            {
+                __blkcnt64_t st_blocks;
+            }
+
+            static if( __USE_MISC || __USE_XOPEN2K8)
+            {
+                __timespec st_atim;
+                __timespec st_mtim;
+                __timespec st_ctim;
+                extern(D)
+                {
+                    @property ref time_t st_atime() { return st_atim.tv_sec; }
+                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
+                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                }
+            }
+            else
+            {
+                __time_t st_atime;
+                c_ulong st_atimensec;
+                __time_t st_mtime;
+                c_ulong st_mtimensec;
+                __time_t st_ctime;
+                c_ulong st_ctimensec;
+            }
+
+            static if(!__USE_FILE_OFFSET64)
+            {
+                c_ulong __unused4;
+                c_ulong __unused5;
+            }
+            else
+            {
+                __ino64_t st_ino;
+            }
+        }
+        static if(__USE_FILE_OFFSET64)
+            static assert(stat_t.sizeof == 104);
+        else
+            static assert(stat_t.sizeof == 88);
+    }
+    else version (AArch64)
+    {
+        private
+        {
+            alias __dev_t = ulong;
+            alias __ino_t = c_ulong;
+            alias __ino64_t = ulong;
+            alias __mode_t = uint;
+            alias __nlink_t = uint;
+            alias __uid_t = uint;
+            alias __gid_t = uint;
+            alias __off_t = c_long;
+            alias __off64_t = long;
+            alias __blksize_t = int;
+            alias __blkcnt_t = c_long;
+            alias __blkcnt64_t = long;
+            alias __timespec = timespec;
+            alias __time_t = time_t;
+        }
+        struct stat_t
+        {
+            __dev_t st_dev;
+
+            static if(!__USE_FILE_OFFSET64)
+            {
+                __ino_t st_ino;
+            }
+            else
+            {
+                __ino64_t st_ino;
+            }
+            __mode_t st_mode;
+            __nlink_t st_nlink;
+            __uid_t st_uid;
+            __gid_t st_gid;
+            __dev_t st_rdev;
+            __dev_t __pad1;
+
+            static if(!__USE_FILE_OFFSET64)
+            {
+                __off_t st_size;
+            }
+            else
+            {
+                __off64_t st_size;
+            }
+            __blksize_t st_blksize;
+            int __pad2;
+
+            static if(!__USE_FILE_OFFSET64)
+            {
+                __blkcnt_t st_blocks;
+            }
+            else
+            {
+                __blkcnt64_t st_blocks;
+            }
+
+            static if(__USE_MISC)
+            {
+                __timespec st_atim;
+                __timespec st_mtim;
+                __timespec st_ctim;
+                extern(D)
+                {
+                    @property ref time_t st_atime() { return st_atim.tv_sec; }
+                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
+                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                }
+            }
+            else
+            {
+                __time_t st_atime;
+                c_ulong st_atimensec;
+                __time_t st_mtime;
+                c_ulong st_mtimensec;
+                __time_t st_ctime;
+                c_ulong st_ctimensec;
+            }
+            int[2] __unused;
+        }
+        static if(__USE_FILE_OFFSET64)
+            static assert(stat_t.sizeof == 128);
+        else
+            static assert(stat_t.sizeof == 128);
+    }
+    else version (SystemZ)
+    {
+        private
+        {
+            alias __dev_t = ulong;
+            alias __ino_t = c_ulong;
+            alias __ino64_t = ulong;
+            alias __mode_t = uint;
+            alias __nlink_t = uint;
+            alias __uid_t = uint;
+            alias __gid_t = uint;
+            alias __off_t = c_long;
+            alias __off64_t = long;
+            alias __blksize_t = int;
+            alias __blkcnt_t = c_long;
+            alias __blkcnt64_t = long;
+            alias __timespec = timespec;
+            alias __time_t = time_t;
+        }
+        struct stat_t
+        {
+            __dev_t st_dev;
+            __ino_t st_ino;
+            __nlink_t st_nlink;
+            __mode_t st_mode;
+            __uid_t st_uid;
+            __gid_t st_gid;
+            int __glibc_reserved0;
+            __dev_t st_rdev;
+            __off_t st_size;
+            static if (__USE_XOPEN2K8)
+            {
+                __timespec st_atim;
+                __timespec st_mtim;
+                __timespec st_ctim;
+                extern(D)
+                {
+                    @property ref time_t st_atime() { return st_atim.tv_sec; }
+                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
+                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                }
+            }
+            else
+            {
+                __time_t st_atime;
+                c_ulong st_atimensec;
+                __time_t st_mtime;
+                c_ulong st_mtimensec;
+                __time_t st_ctime;
+                c_ulong st_ctimensec;
+            }
+            __blksize_t st_blksize;
+            __blkcnt_t st_blocks;
+            c_long[3] __glibc_reserved;
+        }
+        static if(__USE_XOPEN2K8)
+            static assert(stat_t.sizeof == 144);
+        else
+            static assert(stat_t.sizeof == 144);
+    }
+    else
+        static assert(0, "unimplemented");
+
+    enum S_IRUSR    = 0x100; // octal 0400
+    enum S_IWUSR    = 0x080; // octal 0200
+    enum S_IXUSR    = 0x040; // octal 0100
+    enum S_IRWXU    = S_IRUSR | S_IWUSR | S_IXUSR;
+
+    enum S_IRGRP    = S_IRUSR >> 3;
+    enum S_IWGRP    = S_IWUSR >> 3;
+    enum S_IXGRP    = S_IXUSR >> 3;
+    enum S_IRWXG    = S_IRWXU >> 3;
+
+    enum S_IROTH    = S_IRGRP >> 3;
+    enum S_IWOTH    = S_IWGRP >> 3;
+    enum S_IXOTH    = S_IXGRP >> 3;
+    enum S_IRWXO    = S_IRWXG >> 3;
+
+    enum S_ISUID    = 0x800; // octal 04000
+    enum S_ISGID    = 0x400; // octal 02000
+    enum S_ISVTX    = 0x200; // octal 01000
+
+    private
+    {
+        extern (D) bool S_ISTYPE( mode_t mode, uint mask )
+        {
+            return ( mode & S_IFMT ) == mask;
+        }
+    }
+
+    extern (D) bool S_ISBLK( mode_t mode )  { return S_ISTYPE( mode, S_IFBLK );  }
+    extern (D) bool S_ISCHR( mode_t mode )  { return S_ISTYPE( mode, S_IFCHR );  }
+    extern (D) bool S_ISDIR( mode_t mode )  { return S_ISTYPE( mode, S_IFDIR );  }
+    extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO );  }
+    extern (D) bool S_ISREG( mode_t mode )  { return S_ISTYPE( mode, S_IFREG );  }
+    extern (D) bool S_ISLNK( mode_t mode )  { return S_ISTYPE( mode, S_IFLNK );  }
+    extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
+
+    static if( true /*__USE_POSIX199309*/ )
+    {
+        extern bool S_TYPEISMQ( stat_t* buf )  { return false; }
+        extern bool S_TYPEISSEM( stat_t* buf ) { return false; }
+        extern bool S_TYPEISSHM( stat_t* buf ) { return false; }
+    }
+}
+else version( OSX )
+{
+    // _DARWIN_FEATURE_64_BIT_INODE stat is default for Mac OSX >10.5 and is
+    // only meaningful type for other OS X/Darwin variants (e.g. iOS).
+    // man stat(2) gives details.
+    struct stat_t
+    {
+        dev_t       st_dev;
+        mode_t      st_mode;
+        nlink_t     st_nlink;
+        ino_t       st_ino;
+        uid_t       st_uid;
+        gid_t       st_gid;
+        dev_t       st_rdev;
+        union
+        {
+            struct
+            {
+                timespec  st_atimespec;
+                timespec  st_mtimespec;
+                timespec  st_ctimespec;
+                timespec  st_birthtimespec;
+            }
+            struct
+            {
+                time_t      st_atime;
+                c_long      st_atimensec;
+                time_t      st_mtime;
+                c_long      st_mtimensec;
+                time_t      st_ctime;
+                c_long      st_ctimensec;
+                time_t      st_birthtime;
+                c_long      st_birthtimensec;
+            }
+        }
+        off_t       st_size;
+        blkcnt_t    st_blocks;
+        blksize_t   st_blksize;
+        uint        st_flags;
+        uint        st_gen;
+        int         st_lspare;
+        long[2]     st_qspare;
+    }
+
+    enum S_IRUSR    = 0x100;  // octal 0400
+    enum S_IWUSR    = 0x080;  // octal 0200
+    enum S_IXUSR    = 0x040;  // octal 0100
+    enum S_IRWXU    = S_IRUSR | S_IWUSR | S_IXUSR;
+
+    enum S_IRGRP    = S_IRUSR >> 3;
+    enum S_IWGRP    = S_IWUSR >> 3;
+    enum S_IXGRP    = S_IXUSR >> 3;
+    enum S_IRWXG    = S_IRWXU >> 3;
+
+    enum S_IROTH    = S_IRGRP >> 3;
+    enum S_IWOTH    = S_IWGRP >> 3;
+    enum S_IXOTH    = S_IXGRP >> 3;
+    enum S_IRWXO    = S_IRWXG >> 3;
+
+    enum S_ISUID    = 0x800; // octal 04000
+    enum S_ISGID    = 0x400; // octal 02000
+    enum S_ISVTX    = 0x200; // octal 01000
+
+    private
+    {
+        extern (D) bool S_ISTYPE( mode_t mode, uint mask )
+        {
+            return ( mode & S_IFMT ) == mask;
+        }
+    }
+
+    extern (D) bool S_ISBLK( mode_t mode )  { return S_ISTYPE( mode, S_IFBLK );  }
+    extern (D) bool S_ISCHR( mode_t mode )  { return S_ISTYPE( mode, S_IFCHR );  }
+    extern (D) bool S_ISDIR( mode_t mode )  { return S_ISTYPE( mode, S_IFDIR );  }
+    extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO );  }
+    extern (D) bool S_ISREG( mode_t mode )  { return S_ISTYPE( mode, S_IFREG );  }
+    extern (D) bool S_ISLNK( mode_t mode )  { return S_ISTYPE( mode, S_IFLNK );  }
+    extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
+}
+else version( FreeBSD )
+{
+    struct stat_t
+    {
+        dev_t       st_dev;
+        ino_t       st_ino;
+        mode_t      st_mode;
+        nlink_t     st_nlink;
+        uid_t       st_uid;
+        gid_t       st_gid;
+        dev_t       st_rdev;
+
+        time_t      st_atime;
+        c_long      __st_atimensec;
+        time_t      st_mtime;
+        c_long      __st_mtimensec;
+        time_t      st_ctime;
+        c_long      __st_ctimensec;
+
+        off_t       st_size;
+        blkcnt_t    st_blocks;
+        blksize_t   st_blksize;
+        fflags_t    st_flags;
+        uint        st_gen;
+        int         st_lspare;
+
+        time_t      st_birthtime;
+        c_long      st_birthtimensec;
+
+        ubyte[16 - timespec.sizeof] padding;
+    }
+
+    enum S_IRUSR    = 0x100; // octal 0000400
+    enum S_IWUSR    = 0x080; // octal 0000200
+    enum S_IXUSR    = 0x040; // octal 0000100
+    enum S_IRWXU    = 0x1C0; // octal 0000700
+
+    enum S_IRGRP    = 0x020;  // octal 0000040
+    enum S_IWGRP    = 0x010;  // octal 0000020
+    enum S_IXGRP    = 0x008;  // octal 0000010
+    enum S_IRWXG    = 0x038;  // octal 0000070
+
+    enum S_IROTH    = 0x4; // 0000004
+    enum S_IWOTH    = 0x2; // 0000002
+    enum S_IXOTH    = 0x1; // 0000001
+    enum S_IRWXO    = 0x7; // 0000007
+
+    enum S_ISUID    = 0x800; // octal 0004000
+    enum S_ISGID    = 0x400; // octal 0002000
+    enum S_ISVTX    = 0x200; // octal 0001000
+
+    private
+    {
+        extern (D) bool S_ISTYPE( mode_t mode, uint mask )
+        {
+            return ( mode & S_IFMT ) == mask;
+        }
+    }
+
+    extern (D) bool S_ISBLK( mode_t mode )  { return S_ISTYPE( mode, S_IFBLK );  }
+    extern (D) bool S_ISCHR( mode_t mode )  { return S_ISTYPE( mode, S_IFCHR );  }
+    extern (D) bool S_ISDIR( mode_t mode )  { return S_ISTYPE( mode, S_IFDIR );  }
+    extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO );  }
+    extern (D) bool S_ISREG( mode_t mode )  { return S_ISTYPE( mode, S_IFREG );  }
+    extern (D) bool S_ISLNK( mode_t mode )  { return S_ISTYPE( mode, S_IFLNK );  }
+    extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
+}
+else version (Solaris)
+{
+    private enum _ST_FSTYPSZ = 16;
+
+    version (D_LP64)
+    {
+        struct stat_t
+        {
+            dev_t st_dev;
+            ino_t st_ino;
+            mode_t st_mode;
+            nlink_t st_nlink;
+            uid_t st_uid;
+            gid_t st_gid;
+            dev_t st_rdev;
+            off_t st_size;
+            union
+            {
+                timestruc_t st_atim;
+                time_t      st_atime;
+            }
+            union
+            {
+                timestruc_t st_mtim;
+                time_t      st_mtime;
+            }
+            union
+            {
+                timestruc_t st_ctim;
+                time_t      st_ctime;
+            }
+            blksize_t st_blksize;
+            blkcnt_t st_blocks;
+            char[_ST_FSTYPSZ] st_fstype;
+        }
+
+        static if (__USE_LARGEFILE64) alias stat_t stat64_t;
+    }
+    else
+    {
+        struct stat32_t
+        {
+            dev_t st_dev;
+            c_long[3] st_pad1;
+            ino_t st_ino;
+            mode_t st_mode;
+            nlink_t st_nlink;
+            uid_t st_uid;
+            gid_t st_gid;
+            dev_t st_rdev;
+            c_long[2] st_pad2;
+            off_t st_size;
+            c_long st_pad3;
+            union
+            {
+                timestruc_t st_atim;
+                time_t      st_atime;
+            }
+            union
+            {
+                timestruc_t st_mtim;
+                time_t      st_mtime;
+            }
+            union
+            {
+                timestruc_t st_ctim;
+                time_t      st_ctime;
+            }
+            blksize_t st_blksize;
+            blkcnt_t st_blocks;
+            char[_ST_FSTYPSZ] st_fstype;
+            c_long[8] st_pad4;
+        }
+
+        struct stat64_t
+        {
+            dev_t st_dev;
+            c_long[3] st_pad1;
+            ino64_t st_ino;
+            mode_t st_mode;
+            nlink_t st_nlink;
+            uid_t st_uid;
+            gid_t st_gid;
+            dev_t st_rdev;
+            c_long[2] st_pad2;
+            off64_t st_size;
+            c_long st_pad3;
+            union
+            {
+                timestruc_t st_atim;
+                time_t      st_atime;
+            }
+            union
+            {
+                timestruc_t st_mtim;
+                time_t      st_mtime;
+            }
+            union
+            {
+                timestruc_t st_ctim;
+                time_t      st_ctime;
+            }
+            blksize_t st_blksize;
+            blkcnt64_t st_blocks;
+            char[_ST_FSTYPSZ] st_fstype;
+            c_long[8] st_pad4;
+        }
+
+        static if (__USE_FILE_OFFSET64)
+            alias stat64_t stat_t;
+        else
+            alias stat32_t stat_t;
+
+    }
+
+    enum S_IRUSR = 0x100;
+    enum S_IWUSR = 0x080;
+    enum S_IXUSR = 0x040;
+    enum S_IRWXU = 0x1C0;
+
+    enum S_IRGRP = 0x020;
+    enum S_IWGRP = 0x010;
+    enum S_IXGRP = 0x008;
+    enum S_IRWXG = 0x038;
+
+    enum S_IROTH = 0x4; // 0000004
+    enum S_IWOTH = 0x2; // 0000002
+    enum S_IXOTH = 0x1; // 0000001
+    enum S_IRWXO = 0x7; // 0000007
+
+    enum S_ISUID = 0x800;
+    enum S_ISGID = 0x400;
+    enum S_ISVTX = 0x200;
+
+    private
+    {
+        extern (D) bool S_ISTYPE(mode_t mode, uint mask)
+        {
+            return (mode & S_IFMT) == mask;
+        }
+    }
+
+    extern (D) bool S_ISBLK(mode_t mode) { return S_ISTYPE(mode, S_IFBLK); }
+    extern (D) bool S_ISCHR(mode_t mode) { return S_ISTYPE(mode, S_IFCHR); }
+    extern (D) bool S_ISDIR(mode_t mode) { return S_ISTYPE(mode, S_IFDIR); }
+    extern (D) bool S_ISFIFO(mode_t mode) { return S_ISTYPE(mode, S_IFIFO); }
+    extern (D) bool S_ISREG(mode_t mode) { return S_ISTYPE(mode, S_IFREG); }
+    extern (D) bool S_ISLNK(mode_t mode) { return S_ISTYPE(mode, S_IFLNK); }
+    extern (D) bool S_ISSOCK(mode_t mode) { return S_ISTYPE(mode, S_IFSOCK); }
+    extern (D) bool S_ISDOOR(mode_t mode) { return S_ISTYPE(mode, S_IFDOOR); }
+    extern (D) bool S_ISPORT(mode_t mode) { return S_ISTYPE(mode, S_IFPORT); }
+}
+else version( CRuntime_Bionic )
+{
+    version (X86)
+    {
+        struct stat_t
+        {
+            ulong       st_dev;
+            ubyte[4]    __pad0;
+            c_ulong     __st_ino;
+            uint        st_mode;
+            uint        st_nlink;
+            c_ulong     st_uid;
+            c_ulong     st_gid;
+            ulong       st_rdev;
+            ubyte[4]    __pad3;
+
+            long        st_size;
+            c_ulong     st_blksize;
+            ulong       st_blocks;
+            c_ulong     st_atime;
+            c_ulong     st_atime_nsec;
+            c_ulong     st_mtime;
+            c_ulong     st_mtime_nsec;
+            c_ulong     st_ctime;
+            c_ulong     st_ctime_nsec;
+            ulong       st_ino;
+        }
+    }
+    else version (ARM)
+    {
+        struct stat_t
+        {
+            ulong       st_dev;
+            ubyte[4]    __pad0;
+            c_ulong     __st_ino;
+            uint        st_mode;
+            uint        st_nlink;
+            c_ulong     st_uid;
+            c_ulong     st_gid;
+            ulong       st_rdev;
+            ubyte[4]    __pad3;
+
+            long        st_size;
+            c_ulong     st_blksize;
+            ulong       st_blocks;
+            c_ulong     st_atime;
+            c_ulong     st_atime_nsec;
+            c_ulong     st_mtime;
+            c_ulong     st_mtime_nsec;
+            c_ulong     st_ctime;
+            c_ulong     st_ctime_nsec;
+            ulong       st_ino;
+        }
+    }
+    else
+    {
+        static assert(false, "Architecture not supported.");
+    }
+
+    enum S_IRUSR    = 0x100; // octal 0000400
+    enum S_IWUSR    = 0x080; // octal 0000200
+    enum S_IXUSR    = 0x040; // octal 0000100
+    enum S_IRWXU    = 0x1C0; // octal 0000700
+
+    enum S_IRGRP    = 0x020;  // octal 0000040
+    enum S_IWGRP    = 0x010;  // octal 0000020
+    enum S_IXGRP    = 0x008;  // octal 0000010
+    enum S_IRWXG    = 0x038;  // octal 0000070
+
+    enum S_IROTH    = 0x4; // 0000004
+    enum S_IWOTH    = 0x2; // 0000002
+    enum S_IXOTH    = 0x1; // 0000001
+    enum S_IRWXO    = 0x7; // 0000007
+
+    enum S_ISUID    = 0x800; // octal 0004000
+    enum S_ISGID    = 0x400; // octal 0002000
+    enum S_ISVTX    = 0x200; // octal 0001000
+
+    private
+    {
+        extern (D) bool S_ISTYPE( uint mode, uint mask )
+        {
+            return ( mode & S_IFMT ) == mask;
+        }
+    }
+
+    extern (D) bool S_ISBLK( uint mode )  { return S_ISTYPE( mode, S_IFBLK );  }
+    extern (D) bool S_ISCHR( uint mode )  { return S_ISTYPE( mode, S_IFCHR );  }
+    extern (D) bool S_ISDIR( uint mode )  { return S_ISTYPE( mode, S_IFDIR );  }
+    extern (D) bool S_ISFIFO( uint mode ) { return S_ISTYPE( mode, S_IFIFO );  }
+    extern (D) bool S_ISREG( uint mode )  { return S_ISTYPE( mode, S_IFREG );  }
+    extern (D) bool S_ISLNK( uint mode )  { return S_ISTYPE( mode, S_IFLNK );  }
+    extern (D) bool S_ISSOCK( uint mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+int    chmod(in char*, mode_t);
+int    fchmod(int, mode_t);
+//int    fstat(int, stat_t*);
+//int    lstat(in char*, stat_t*);
+int    mkdir(in char*, mode_t);
+int    mkfifo(in char*, mode_t);
+//int    stat(in char*, stat_t*);
+mode_t umask(mode_t);
+
+version( CRuntime_Glibc )
+{
+  static if( __USE_LARGEFILE64 )
+  {
+    int   fstat64(int, stat_t*) @trusted;
+    alias fstat64 fstat;
+
+    int   lstat64(in char*, stat_t*);
+    alias lstat64 lstat;
+
+    int   stat64(in char*, stat_t*);
+    alias stat64 stat;
+  }
+  else
+  {
+    int   fstat(int, stat_t*) @trusted;
+    int   lstat(in char*, stat_t*);
+    int   stat(in char*, stat_t*);
+  }
+}
+else version (Solaris)
+{
+    version (D_LP64)
+    {
+        int fstat(int, stat_t*) @trusted;
+        int lstat(in char*, stat_t*);
+        int stat(in char*, stat_t*);
+
+        static if (__USE_LARGEFILE64)
+        {
+            alias fstat fstat64;
+            alias lstat lstat64;
+            alias stat stat64;
+        }
+    }
+    else
+    {
+        static if (__USE_LARGEFILE64)
+        {
+            int   fstat64(int, stat_t*) @trusted;
+            alias fstat64 fstat;
+
+            int   lstat64(in char*, stat_t*);
+            alias lstat64 lstat;
+
+            int   stat64(in char*, stat_t*);
+            alias stat64 stat;
+        }
+        else
+        {
+            int fstat(int, stat_t*) @trusted;
+            int lstat(in char*, stat_t*);
+            int stat(in char*, stat_t*);
+        }
+    }
+}
+else version( OSX )
+{
+    // OS X maintains backwards compatibility with older binaries using 32-bit
+    // inode functions by appending $INODE64 to newer 64-bit inode functions.
+    pragma(mangle, "fstat$INODE64") int fstat(int, stat_t*);
+    pragma(mangle, "lstat$INODE64") int lstat(in char*, stat_t*);
+    pragma(mangle, "stat$INODE64")  int stat(in char*, stat_t*);
+}
+else version( FreeBSD )
+{
+    int   fstat(int, stat_t*);
+    int   lstat(in char*, stat_t*);
+    int   stat(in char*, stat_t*);
+}
+else version( CRuntime_Bionic )
+{
+    int   fstat(int, stat_t*) @trusted;
+    int   lstat(in char*, stat_t*);
+    int   stat(in char*, stat_t*);
+}
+
+//
+// Typed Memory Objects (TYM)
+//
+/*
+S_TYPEISTMO(buf)
+*/
+
+//
+// XOpen (XSI)
+//
+/*
+S_IFMT
+S_IFBLK
+S_IFCHR
+S_IFIFO
+S_IFREG
+S_IFDIR
+S_IFLNK
+S_IFSOCK
+
+int mknod(in 3char*, mode_t, dev_t);
+*/
+
+version( CRuntime_Glibc )
+{
+    enum S_IFMT     = 0xF000; // octal 0170000
+    enum S_IFBLK    = 0x6000; // octal 0060000
+    enum S_IFCHR    = 0x2000; // octal 0020000
+    enum S_IFIFO    = 0x1000; // octal 0010000
+    enum S_IFREG    = 0x8000; // octal 0100000
+    enum S_IFDIR    = 0x4000; // octal 0040000
+    enum S_IFLNK    = 0xA000; // octal 0120000
+    enum S_IFSOCK   = 0xC000; // octal 0140000
+
+    int mknod(in char*, mode_t, dev_t);
+}
+else version( OSX )
+{
+    enum S_IFMT     = 0xF000; // octal 0170000
+    enum S_IFBLK    = 0x6000; // octal 0060000
+    enum S_IFCHR    = 0x2000; // octal 0020000
+    enum S_IFIFO    = 0x1000; // octal 0010000
+    enum S_IFREG    = 0x8000; // octal 0100000
+    enum S_IFDIR    = 0x4000; // octal 0040000
+    enum S_IFLNK    = 0xA000; // octal 0120000
+    enum S_IFSOCK   = 0xC000; // octal 0140000
+
+    int mknod(in char*, mode_t, dev_t);
+}
+else version( FreeBSD )
+{
+    enum S_IFMT     = 0xF000; // octal 0170000
+    enum S_IFBLK    = 0x6000; // octal 0060000
+    enum S_IFCHR    = 0x2000; // octal 0020000
+    enum S_IFIFO    = 0x1000; // octal 0010000
+    enum S_IFREG    = 0x8000; // octal 0100000
+    enum S_IFDIR    = 0x4000; // octal 0040000
+    enum S_IFLNK    = 0xA000; // octal 0120000
+    enum S_IFSOCK   = 0xC000; // octal 0140000
+
+    int mknod(in char*, mode_t, dev_t);
+}
+else version (Solaris)
+{
+    enum S_IFMT = 0xF000;
+    enum S_IFBLK = 0x6000;
+    enum S_IFCHR = 0x2000;
+    enum S_IFIFO = 0x1000;
+    enum S_IFREG = 0x8000;
+    enum S_IFDIR = 0x4000;
+    enum S_IFLNK = 0xA000;
+    enum S_IFSOCK = 0xC000;
+    enum S_IFDOOR = 0xD000;
+    enum S_IFPORT = 0xE000;
+
+    int mknod(in char*, mode_t, dev_t);
+}
+else version( CRuntime_Bionic )
+{
+    enum S_IFMT     = 0xF000; // octal 0170000
+    enum S_IFBLK    = 0x6000; // octal 0060000
+    enum S_IFCHR    = 0x2000; // octal 0020000
+    enum S_IFIFO    = 0x1000; // octal 0010000
+    enum S_IFREG    = 0x8000; // octal 0100000
+    enum S_IFDIR    = 0x4000; // octal 0040000
+    enum S_IFLNK    = 0xA000; // octal 0120000
+    enum S_IFSOCK   = 0xC000; // octal 0140000
+
+    int mknod(in char*, mode_t, dev_t);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/statvfs.d b/libphobos/libdruntime/core/sys/posix/sys/statvfs.d
new file mode 100644
index 00000000000..eb7435903cc
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/statvfs.d
@@ -0,0 +1,112 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Robert Klotzner 2012
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Robert Klotzner
+ * Standards: The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004 Edition
+ */
+
+module core.sys.posix.sys.statvfs;
+private import core.stdc.config;
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types;
+
+version (Posix):
+extern (C) :
+
+version(CRuntime_Glibc) {
+    static if(__WORDSIZE == 32)
+    {
+        version=_STATVFSBUF_F_UNUSED;
+    }
+    struct statvfs_t
+    {
+        c_ulong f_bsize;
+        c_ulong f_frsize;
+        fsblkcnt_t f_blocks;
+        fsblkcnt_t f_bfree;
+        fsblkcnt_t f_bavail;
+        fsfilcnt_t f_files;
+        fsfilcnt_t f_ffree;
+        fsfilcnt_t f_favail;
+        c_ulong f_fsid;
+        version(_STATVFSBUF_F_UNUSED)
+        {
+            int __f_unused;
+        }
+        c_ulong f_flag;
+        c_ulong f_namemax;
+        int[6] __f_spare;
+    }
+    /* Definitions for the flag in `f_flag'.  These definitions should be
+      kept in sync with the definitions in <sys/mount.h>.  */
+    static if(__USE_GNU)
+    {
+        enum FFlag
+        {
+            ST_RDONLY = 1,        /* Mount read-only.  */
+            ST_NOSUID = 2,
+            ST_NODEV = 4,         /* Disallow access to device special files.  */
+            ST_NOEXEC = 8,        /* Disallow program execution.  */
+            ST_SYNCHRONOUS = 16,      /* Writes are synced at once.  */
+            ST_MANDLOCK = 64,     /* Allow mandatory locks on an FS.  */
+            ST_WRITE = 128,       /* Write on file/directory/symlink.  */
+            ST_APPEND = 256,      /* Append-only file.  */
+            ST_IMMUTABLE = 512,       /* Immutable file.  */
+            ST_NOATIME = 1024,        /* Do not update access times.  */
+            ST_NODIRATIME = 2048,     /* Do not update directory access times.  */
+            ST_RELATIME = 4096        /* Update atime relative to mtime/ctime.  */
+
+        }
+    }  /* Use GNU.  */
+    else
+    { // Posix defined:
+        enum FFlag
+        {
+            ST_RDONLY = 1,        /* Mount read-only.  */
+            ST_NOSUID = 2
+        }
+    }
+
+    static if( __USE_FILE_OFFSET64 )
+    {
+        int statvfs64 (const char * file, statvfs_t* buf);
+        alias statvfs64 statvfs;
+
+        int fstatvfs64 (int fildes, statvfs_t *buf) @trusted;
+        alias fstatvfs64 fstatvfs;
+    }
+    else
+    {
+        int statvfs (const char * file, statvfs_t* buf);
+        int fstatvfs (int fildes, statvfs_t *buf);
+    }
+
+}
+else
+{
+    struct statvfs_t
+    {
+        c_ulong f_bsize;
+        c_ulong f_frsize;
+        fsblkcnt_t f_blocks;
+        fsblkcnt_t f_bfree;
+        fsblkcnt_t f_bavail;
+        fsfilcnt_t f_files;
+        fsfilcnt_t f_ffree;
+        fsfilcnt_t f_favail;
+        c_ulong f_fsid;
+        c_ulong f_flag;
+        c_ulong f_namemax;
+    }
+
+    enum FFlag
+    {
+        ST_RDONLY = 1,        /* Mount read-only.  */
+        ST_NOSUID = 2
+    }
+
+    int statvfs (const char * file, statvfs_t* buf);
+    int fstatvfs (int fildes, statvfs_t *buf) @trusted;
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/time.d b/libphobos/libdruntime/core/sys/posix/sys/time.d
new file mode 100644
index 00000000000..dbeb58a9f48
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/time.d
@@ -0,0 +1,177 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.sys.time;
+
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types;  // for time_t, suseconds_t
+public import core.sys.posix.sys.select; // for fd_set, FD_CLR() FD_ISSET() FD_SET() FD_ZERO() FD_SETSIZE, select()
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// XOpen (XSI)
+//
+/*
+struct timeval
+{
+    time_t      tv_sec;
+    suseconds_t tv_usec;
+}
+
+struct itimerval
+{
+    timeval it_interval;
+    timeval it_value;
+}
+
+ITIMER_REAL
+ITIMER_VIRTUAL
+ITIMER_PROF
+
+int getitimer(int, itimerval*);
+int gettimeofday(timeval*, void*);
+int select(int, fd_set*, fd_set*, fd_set*, timeval*); (defined in core.sys.posix.sys.signal)
+int setitimer(int, in itimerval*, itimerval*);
+int utimes(in char*, ref const(timeval)[2]); // LEGACY
+*/
+
+version( CRuntime_Glibc )
+{
+    struct timeval
+    {
+        time_t      tv_sec;
+        suseconds_t tv_usec;
+    }
+
+    struct itimerval
+    {
+        timeval it_interval;
+        timeval it_value;
+    }
+
+    enum ITIMER_REAL    = 0;
+    enum ITIMER_VIRTUAL = 1;
+    enum ITIMER_PROF    = 2;
+
+    int getitimer(int, itimerval*);
+    int gettimeofday(timeval*, void*);
+    int setitimer(int, in itimerval*, itimerval*);
+    int utimes(in char*, ref const(timeval)[2]); // LEGACY
+}
+else version( OSX )
+{
+    struct timeval
+    {
+        time_t      tv_sec;
+        suseconds_t tv_usec;
+    }
+
+    struct itimerval
+    {
+        timeval it_interval;
+        timeval it_value;
+    }
+
+    // non-standard
+    struct timezone_t
+    {
+        int tz_minuteswest;
+        int tz_dsttime;
+    }
+
+    int getitimer(int, itimerval*);
+    int gettimeofday(timeval*, timezone_t*); // timezone_t* is normally void*
+    int setitimer(int, in itimerval*, itimerval*);
+    int utimes(in char*, ref const(timeval)[2]);
+}
+else version( FreeBSD )
+{
+    struct timeval
+    {
+        time_t      tv_sec;
+        suseconds_t tv_usec;
+    }
+
+    struct itimerval
+    {
+        timeval it_interval;
+        timeval it_value;
+    }
+
+    // non-standard
+    struct timezone_t
+    {
+        int tz_minuteswest;
+        int tz_dsttime;
+    }
+
+    int getitimer(int, itimerval*);
+    int gettimeofday(timeval*, timezone_t*); // timezone_t* is normally void*
+    int setitimer(int, in itimerval*, itimerval*);
+    int utimes(in char*, ref const(timeval)[2]);
+}
+else version (Solaris)
+{
+    struct timeval
+    {
+        time_t tv_sec;
+        suseconds_t tv_usec;
+    }
+
+    struct itimerval
+    {
+        timeval it_interval;
+        timeval it_value;
+    }
+
+    int getitimer(int, itimerval*);
+    int gettimeofday(timeval*, void*);
+    int setitimer(int, in itimerval*, itimerval*);
+    int utimes(in char*, ref const(timeval)[2]);
+}
+else version( CRuntime_Bionic )
+{
+    struct timeval
+    {
+        time_t      tv_sec;
+        suseconds_t tv_usec;
+    }
+
+    struct itimerval
+    {
+        timeval it_interval;
+        timeval it_value;
+    }
+
+    struct timezone_t
+    {
+        int tz_minuteswest;
+        int tz_dsttime;
+    }
+
+    enum ITIMER_REAL    = 0;
+    enum ITIMER_VIRTUAL = 1;
+    enum ITIMER_PROF    = 2;
+
+    int getitimer(int, itimerval*);
+    int gettimeofday(timeval*, timezone_t*);
+    int setitimer(int, in itimerval*, itimerval*);
+    int utimes(in char*, ref const(timeval)[2]);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/types.d b/libphobos/libdruntime/core/sys/posix/sys/types.d
new file mode 100644
index 00000000000..103b064482d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/types.d
@@ -0,0 +1,872 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly,
+              Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.sys.types;
+
+private import core.sys.posix.config;
+private import core.stdc.stdint;
+public import core.stdc.stddef;
+
+version (Posix):
+extern (C):
+
+//
+// bits/typesizes.h -- underlying types for *_t.
+//
+/*
+__syscall_slong_t
+__syscall_ulong_t
+*/
+version (CRuntime_Glibc)
+{
+    version (X86_64)
+    {
+        version (D_X32)
+        {
+            // X32 kernel interface is 64-bit.
+            alias long slong_t;
+            alias ulong ulong_t;
+        }
+        else
+        {
+            alias c_long slong_t;
+            alias c_ulong ulong_t;
+        }
+    }
+    else
+    {
+        alias c_long slong_t;
+        alias c_ulong ulong_t;
+    }
+}
+else
+{
+    alias c_long slong_t;
+    alias c_ulong ulong_t;
+}
+
+//
+// Required
+//
+/*
+blkcnt_t
+blksize_t
+dev_t
+gid_t
+ino_t
+mode_t
+nlink_t
+off_t
+pid_t
+size_t
+ssize_t
+time_t
+uid_t
+*/
+
+version( CRuntime_Glibc )
+{
+  static if( __USE_FILE_OFFSET64 )
+  {
+    alias long      blkcnt_t;
+    alias ulong     ino_t;
+    alias long      off_t;
+  }
+  else
+  {
+    alias slong_t   blkcnt_t;
+    alias ulong_t   ino_t;
+    alias slong_t   off_t;
+  }
+    alias slong_t   blksize_t;
+    alias ulong     dev_t;
+    alias uint      gid_t;
+    alias uint      mode_t;
+    alias ulong_t   nlink_t;
+    alias int       pid_t;
+    //size_t (defined in core.stdc.stddef)
+    alias c_long    ssize_t;
+    alias slong_t   time_t;
+    alias uint      uid_t;
+}
+else version( OSX )
+{
+    alias long      blkcnt_t;
+    alias int       blksize_t;
+    alias int       dev_t;
+    alias uint      gid_t;
+    alias ulong     ino_t;
+    alias ushort    mode_t;
+    alias ushort    nlink_t;
+    alias long      off_t;
+    alias int       pid_t;
+    //size_t (defined in core.stdc.stddef)
+    alias c_long    ssize_t;
+    alias c_long    time_t;
+    alias uint      uid_t;
+}
+else version( FreeBSD )
+{
+    alias long      blkcnt_t;
+    alias uint      blksize_t;
+    alias uint      dev_t;
+    alias uint      gid_t;
+    alias uint      ino_t;
+    alias ushort    mode_t;
+    alias ushort    nlink_t;
+    alias long      off_t;
+    alias int       pid_t;
+    //size_t (defined in core.stdc.stddef)
+    alias c_long    ssize_t;
+    alias c_long    time_t;
+    alias uint      uid_t;
+    alias uint      fflags_t;
+}
+else version (Solaris)
+{
+    alias char* caddr_t;
+    alias c_long daddr_t;
+    alias short cnt_t;
+
+    static if (__USE_FILE_OFFSET64)
+    {
+        alias long blkcnt_t;
+        alias ulong ino_t;
+        alias long off_t;
+    }
+    else
+    {
+        alias c_long blkcnt_t;
+        alias c_ulong ino_t;
+        alias c_long off_t;
+    }
+
+    version (D_LP64)
+    {
+        alias blkcnt_t blkcnt64_t;
+        alias ino_t ino64_t;
+        alias off_t off64_t;
+    }
+    else
+    {
+        alias long blkcnt64_t;
+        alias ulong ino64_t;
+        alias long off64_t;
+    }
+
+    alias uint blksize_t;
+    alias c_ulong dev_t;
+    alias uid_t gid_t;
+    alias uint mode_t;
+    alias uint nlink_t;
+    alias int pid_t;
+    alias c_long ssize_t;
+    alias c_long time_t;
+    alias uint uid_t;
+}
+else version( CRuntime_Bionic )
+{
+    alias c_ulong   blkcnt_t;
+    alias c_ulong   blksize_t;
+    alias uint      dev_t;
+    alias uint      gid_t;
+    alias c_ulong   ino_t;
+    alias c_long    off_t;
+    alias int       pid_t;
+    alias int       ssize_t;
+    alias c_long    time_t;
+    alias uint      uid_t;
+
+    version(X86)
+    {
+        alias ushort    mode_t;
+        alias ushort    nlink_t;
+    }
+    else version(ARM)
+    {
+        alias ushort    mode_t;
+        alias ushort    nlink_t;
+    }
+    else version(MIPS32)
+    {
+        alias uint      mode_t;
+        alias uint      nlink_t;
+    }
+    else
+    {
+        static assert(false, "Architecture not supported.");
+    }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// XOpen (XSI)
+//
+/*
+clock_t
+fsblkcnt_t
+fsfilcnt_t
+id_t
+key_t
+suseconds_t
+useconds_t
+*/
+
+version( CRuntime_Glibc )
+{
+  static if( __USE_FILE_OFFSET64 )
+  {
+    alias ulong     fsblkcnt_t;
+    alias ulong     fsfilcnt_t;
+  }
+  else
+  {
+    alias ulong_t   fsblkcnt_t;
+    alias ulong_t   fsfilcnt_t;
+  }
+    alias slong_t   clock_t;
+    alias uint      id_t;
+    alias int       key_t;
+    alias slong_t   suseconds_t;
+    alias uint      useconds_t;
+}
+else version( OSX )
+{
+    alias uint   fsblkcnt_t;
+    alias uint   fsfilcnt_t;
+    alias c_long clock_t;
+    alias uint   id_t;
+    // key_t
+    alias int    suseconds_t;
+    alias uint   useconds_t;
+}
+else version( FreeBSD )
+{
+    alias ulong     fsblkcnt_t;
+    alias ulong     fsfilcnt_t;
+    alias c_long    clock_t;
+    alias long      id_t;
+    alias c_long    key_t;
+    alias c_long    suseconds_t;
+    alias uint      useconds_t;
+}
+else version (Solaris)
+{
+    static if (__USE_FILE_OFFSET64)
+    {
+        alias ulong fsblkcnt_t;
+        alias ulong fsfilcnt_t;
+    }
+    else
+    {
+        alias c_ulong fsblkcnt_t;
+        alias c_ulong fsfilcnt_t;
+    }
+
+    alias c_long clock_t;
+    alias int id_t;
+    alias int key_t;
+    alias c_long suseconds_t;
+    alias uint useconds_t;
+
+    alias id_t taskid_t;
+    alias id_t projid_t;
+    alias id_t poolid_t;
+    alias id_t zoneid_t;
+    alias id_t ctid_t;
+}
+else version( CRuntime_Bionic )
+{
+    alias c_ulong  fsblkcnt_t;
+    alias c_ulong  fsfilcnt_t;
+    alias c_long   clock_t;
+    alias uint     id_t;
+    alias int      key_t;
+    alias c_long   suseconds_t;
+    alias c_long   useconds_t;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Thread (THR)
+//
+/*
+pthread_attr_t
+pthread_cond_t
+pthread_condattr_t
+pthread_key_t
+pthread_mutex_t
+pthread_mutexattr_t
+pthread_once_t
+pthread_rwlock_t
+pthread_rwlockattr_t
+pthread_t
+*/
+
+version (CRuntime_Glibc)
+{
+    version (X86)
+    {
+        enum __SIZEOF_PTHREAD_ATTR_T = 36;
+        enum __SIZEOF_PTHREAD_MUTEX_T = 24;
+        enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
+        enum __SIZEOF_PTHREAD_COND_T = 48;
+        enum __SIZEOF_PTHREAD_CONDATTR_T = 4;
+        enum __SIZEOF_PTHREAD_RWLOCK_T = 32;
+        enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+        enum __SIZEOF_PTHREAD_BARRIER_T = 20;
+        enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
+    }
+    else version (X86_64)
+    {
+        static if (__WORDSIZE == 64)
+        {
+            enum __SIZEOF_PTHREAD_ATTR_T = 56;
+            enum __SIZEOF_PTHREAD_MUTEX_T = 40;
+            enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
+            enum __SIZEOF_PTHREAD_COND_T = 48;
+            enum __SIZEOF_PTHREAD_CONDATTR_T = 4;
+            enum __SIZEOF_PTHREAD_RWLOCK_T = 56;
+            enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+            enum __SIZEOF_PTHREAD_BARRIER_T = 32;
+            enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
+        }
+        else
+        {
+            enum __SIZEOF_PTHREAD_ATTR_T = 32;
+            enum __SIZEOF_PTHREAD_MUTEX_T = 32;
+            enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
+            enum __SIZEOF_PTHREAD_COND_T = 48;
+            enum __SIZEOF_PTHREAD_CONDATTR_T = 4;
+            enum __SIZEOF_PTHREAD_RWLOCK_T = 44;
+            enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+            enum __SIZEOF_PTHREAD_BARRIER_T = 20;
+            enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
+        }
+    }
+    else version (AArch64)
+    {
+        enum __SIZEOF_PTHREAD_ATTR_T = 64;
+        enum __SIZEOF_PTHREAD_MUTEX_T = 48;
+        enum __SIZEOF_PTHREAD_MUTEXATTR_T = 8;
+        enum __SIZEOF_PTHREAD_COND_T = 48;
+        enum __SIZEOF_PTHREAD_CONDATTR_T = 8;
+        enum __SIZEOF_PTHREAD_RWLOCK_T = 56;
+        enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+        enum __SIZEOF_PTHREAD_BARRIER_T = 32;
+        enum __SIZEOF_PTHREAD_BARRIERATTR_T = 8;
+    }
+    else version (ARM)
+    {
+        enum __SIZEOF_PTHREAD_ATTR_T = 36;
+        enum __SIZEOF_PTHREAD_MUTEX_T = 24;
+        enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
+        enum __SIZEOF_PTHREAD_COND_T = 48;
+        enum __SIZEOF_PTHREAD_CONDATTR_T = 4;
+        enum __SIZEOF_PTHREAD_RWLOCK_T = 32;
+        enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+        enum __SIZEOF_PTHREAD_BARRIER_T = 20;
+        enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
+    }
+    else version (IA64)
+    {
+        enum __SIZEOF_PTHREAD_ATTR_T = 56;
+        enum __SIZEOF_PTHREAD_MUTEX_T = 40;
+        enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
+        enum __SIZEOF_PTHREAD_COND_T = 48;
+        enum __SIZEOF_PTHREAD_CONDATTR_T = 4;
+        enum __SIZEOF_PTHREAD_RWLOCK_T = 56;
+        enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+        enum __SIZEOF_PTHREAD_BARRIER_T = 32;
+        enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
+    }
+    else version (MIPS32)
+    {
+        enum __SIZEOF_PTHREAD_ATTR_T = 36;
+        enum __SIZEOF_PTHREAD_MUTEX_T = 24;
+        enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
+        enum __SIZEOF_PTHREAD_COND_T = 48;
+        enum __SIZEOF_PTHREAD_CONDATTR_T = 4;
+        enum __SIZEOF_PTHREAD_RWLOCK_T = 32;
+        enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+        enum __SIZEOF_PTHREAD_BARRIER_T = 20;
+        enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
+    }
+    else version (MIPS64)
+    {
+        enum __SIZEOF_PTHREAD_ATTR_T = 56;
+        enum __SIZEOF_PTHREAD_MUTEX_T = 40;
+        enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
+        enum __SIZEOF_PTHREAD_COND_T = 48;
+        enum __SIZEOF_PTHREAD_CONDATTR_T = 4;
+        enum __SIZEOF_PTHREAD_RWLOCK_T = 56;
+        enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+        enum __SIZEOF_PTHREAD_BARRIER_T = 32;
+        enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
+    }
+    else version (PPC)
+    {
+        enum __SIZEOF_PTHREAD_ATTR_T = 36;
+        enum __SIZEOF_PTHREAD_MUTEX_T = 24;
+        enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
+        enum __SIZEOF_PTHREAD_COND_T = 48;
+        enum __SIZEOF_PTHREAD_CONDATTR_T = 4;
+        enum __SIZEOF_PTHREAD_RWLOCK_T = 32;
+        enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+        enum __SIZEOF_PTHREAD_BARRIER_T = 20;
+        enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
+    }
+    else version (PPC64)
+    {
+        enum __SIZEOF_PTHREAD_ATTR_T = 56;
+        enum __SIZEOF_PTHREAD_MUTEX_T = 40;
+        enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
+        enum __SIZEOF_PTHREAD_COND_T = 48;
+        enum __SIZEOF_PTHREAD_CONDATTR_T = 4;
+        enum __SIZEOF_PTHREAD_RWLOCK_T = 56;
+        enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+        enum __SIZEOF_PTHREAD_BARRIER_T = 32;
+        enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
+    }
+    else version (S390)
+    {
+        enum __SIZEOF_PTHREAD_ATTR_T = 36;
+        enum __SIZEOF_PTHREAD_MUTEX_T = 24;
+        enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
+        enum __SIZEOF_PTHREAD_COND_T = 48;
+        enum __SIZEOF_PTHREAD_CONDATTR_T = 4;
+        enum __SIZEOF_PTHREAD_RWLOCK_T = 32;
+        enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+        enum __SIZEOF_PTHREAD_BARRIER_T = 20;
+        enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
+    }
+    else version (SystemZ)
+    {
+        enum __SIZEOF_PTHREAD_ATTR_T = 56;
+        enum __SIZEOF_PTHREAD_MUTEX_T = 40;
+        enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
+        enum __SIZEOF_PTHREAD_COND_T = 48;
+        enum __SIZEOF_PTHREAD_CONDATTR_T = 4;
+        enum __SIZEOF_PTHREAD_RWLOCK_T = 56;
+        enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+        enum __SIZEOF_PTHREAD_BARRIER_T = 32;
+        enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
+    }
+    else
+    {
+        static assert (false, "Unsupported platform");
+    }
+
+    union pthread_attr_t
+    {
+        byte[__SIZEOF_PTHREAD_ATTR_T] __size;
+        c_long __align;
+    }
+
+    private alias int __atomic_lock_t;
+
+    private struct _pthread_fastlock
+    {
+        c_long          __status;
+        __atomic_lock_t __spinlock;
+    }
+
+    private alias void* _pthread_descr;
+
+    union pthread_cond_t
+    {
+        byte[__SIZEOF_PTHREAD_COND_T] __size;
+        long  __align;
+    }
+
+    union pthread_condattr_t
+    {
+        byte[__SIZEOF_PTHREAD_CONDATTR_T] __size;
+        int __align;
+    }
+
+    alias uint pthread_key_t;
+
+    union pthread_mutex_t
+    {
+        byte[__SIZEOF_PTHREAD_MUTEX_T] __size;
+        c_long __align;
+    }
+
+    union pthread_mutexattr_t
+    {
+        byte[__SIZEOF_PTHREAD_MUTEXATTR_T] __size;
+        int __align;
+    }
+
+    alias int pthread_once_t;
+
+    struct pthread_rwlock_t
+    {
+        byte[__SIZEOF_PTHREAD_RWLOCK_T] __size;
+        c_long __align;
+    }
+
+    struct pthread_rwlockattr_t
+    {
+        byte[__SIZEOF_PTHREAD_RWLOCKATTR_T] __size;
+        c_long __align;
+    }
+
+    alias c_ulong pthread_t;
+}
+else version( OSX )
+{
+    version( D_LP64 )
+    {
+        enum __PTHREAD_SIZE__               = 1168;
+        enum __PTHREAD_ATTR_SIZE__          = 56;
+        enum __PTHREAD_MUTEXATTR_SIZE__     = 8;
+        enum __PTHREAD_MUTEX_SIZE__         = 56;
+        enum __PTHREAD_CONDATTR_SIZE__      = 8;
+        enum __PTHREAD_COND_SIZE__          = 40;
+        enum __PTHREAD_ONCE_SIZE__          = 8;
+        enum __PTHREAD_RWLOCK_SIZE__        = 192;
+        enum __PTHREAD_RWLOCKATTR_SIZE__    = 16;
+    }
+    else
+    {
+        enum __PTHREAD_SIZE__               = 596;
+        enum __PTHREAD_ATTR_SIZE__          = 36;
+        enum __PTHREAD_MUTEXATTR_SIZE__     = 8;
+        enum __PTHREAD_MUTEX_SIZE__         = 40;
+        enum __PTHREAD_CONDATTR_SIZE__      = 4;
+        enum __PTHREAD_COND_SIZE__          = 24;
+        enum __PTHREAD_ONCE_SIZE__          = 4;
+        enum __PTHREAD_RWLOCK_SIZE__        = 124;
+        enum __PTHREAD_RWLOCKATTR_SIZE__    = 12;
+    }
+
+    struct pthread_handler_rec
+    {
+      void function(void*)  __routine;
+      void*                 __arg;
+      pthread_handler_rec*  __next;
+    }
+
+    struct pthread_attr_t
+    {
+        c_long                              __sig;
+        byte[__PTHREAD_ATTR_SIZE__]         __opaque;
+    }
+
+    struct pthread_cond_t
+    {
+        c_long                              __sig;
+        byte[__PTHREAD_COND_SIZE__]         __opaque;
+    }
+
+    struct pthread_condattr_t
+    {
+        c_long                              __sig;
+        byte[__PTHREAD_CONDATTR_SIZE__]     __opaque;
+    }
+
+    alias c_ulong pthread_key_t;
+
+    struct pthread_mutex_t
+    {
+        c_long                              __sig;
+        byte[__PTHREAD_MUTEX_SIZE__]        __opaque;
+    }
+
+    struct pthread_mutexattr_t
+    {
+        c_long                              __sig;
+        byte[__PTHREAD_MUTEXATTR_SIZE__]    __opaque;
+    }
+
+    struct pthread_once_t
+    {
+        c_long                              __sig;
+        byte[__PTHREAD_ONCE_SIZE__]         __opaque;
+    }
+
+    struct pthread_rwlock_t
+    {
+        c_long                              __sig;
+        byte[__PTHREAD_RWLOCK_SIZE__]       __opaque;
+    }
+
+    struct pthread_rwlockattr_t
+    {
+        c_long                              __sig;
+        byte[__PTHREAD_RWLOCKATTR_SIZE__]   __opaque;
+    }
+
+    private struct _opaque_pthread_t
+    {
+        c_long                  __sig;
+        pthread_handler_rec*    __cleanup_stack;
+        byte[__PTHREAD_SIZE__]  __opaque;
+    }
+
+    alias _opaque_pthread_t* pthread_t;
+}
+else version( FreeBSD )
+{
+    alias int lwpid_t;
+
+    alias void* pthread_attr_t;
+    alias void* pthread_cond_t;
+    alias void* pthread_condattr_t;
+    alias void* pthread_key_t;
+    alias void* pthread_mutex_t;
+    alias void* pthread_mutexattr_t;
+    alias void* pthread_once_t;
+    alias void* pthread_rwlock_t;
+    alias void* pthread_rwlockattr_t;
+    alias void* pthread_t;
+}
+else version (Solaris)
+{
+    alias uint pthread_t;
+
+    struct pthread_attr_t
+    {
+        void* __pthread_attrp;
+    }
+
+    struct pthread_cond_t
+    {
+        struct ___pthread_cond_flags
+        {
+            ubyte[4] __pthread_cond_flags;
+            ushort __pthread_cond_type;
+            ushort __pthread_cond_magic;
+        }
+
+        ___pthread_cond_flags __pthread_cond_flags;
+        ulong __pthread_cond_data;
+    }
+
+    struct pthread_condattr_t
+    {
+        void* __pthread_condattrp;
+    }
+
+    struct pthread_rwlock_t
+    {
+        int __pthread_rwlock_readers;
+        ushort __pthread_rwlock_type;
+        ushort __pthread_rwlock_magic;
+        pthread_mutex_t __pthread_rwlock_mutex;
+        pthread_cond_t __pthread_rwlock_readercv;
+        pthread_cond_t __pthread_rwlock_writercv;
+    }
+
+    struct pthread_rwlockattr_t
+    {
+        void* __pthread_rwlockattrp;
+    }
+
+    struct pthread_mutex_t
+    {
+        struct ___pthread_mutex_flags
+        {
+            ushort __pthread_mutex_flag1;
+            ubyte __pthread_mutex_flag2;
+            ubyte __pthread_mutex_ceiling;
+            ushort __pthread_mutex_type;
+            ushort __pthread_mutex_magic;
+        }
+
+        ___pthread_mutex_flags __pthread_mutex_flags;
+
+        union ___pthread_mutex_lock
+        {
+            struct ___pthread_mutex_lock64
+            {
+                ubyte[8] __pthread_mutex_pad;
+            }
+
+            ___pthread_mutex_lock64 __pthread_mutex_lock64;
+
+            struct ___pthread_mutex_lock32
+            {
+                uint __pthread_ownerpid;
+                uint __pthread_lockword;
+            }
+
+            ___pthread_mutex_lock32 __pthread_mutex_lock32;
+            ulong __pthread_mutex_owner64;
+        }
+
+        ___pthread_mutex_lock __pthread_mutex_lock;
+        ulong __pthread_mutex_data;
+    }
+
+    struct pthread_mutexattr_t
+    {
+        void* __pthread_mutexattrp;
+    }
+
+    struct pthread_once_t
+    {
+        ulong[4] __pthread_once_pad;
+    }
+
+    alias uint pthread_key_t;
+}
+else version( CRuntime_Bionic )
+{
+    struct pthread_attr_t
+    {
+        uint    flags;
+        void*   stack_base;
+        size_t  stack_size;
+        size_t  guard_size;
+        int     sched_policy;
+        int     sched_priority;
+    }
+
+    struct pthread_cond_t
+    {
+        int value; //volatile
+    }
+
+    alias c_long pthread_condattr_t;
+    alias int    pthread_key_t;
+
+    struct pthread_mutex_t
+    {
+        int value; //volatile
+    }
+
+    alias c_long pthread_mutexattr_t;
+    alias int    pthread_once_t; //volatile
+
+    struct pthread_rwlock_t
+    {
+        pthread_mutex_t  lock;
+        pthread_cond_t   cond;
+        int              numLocks;
+        int              writerThreadId;
+        int              pendingReaders;
+        int              pendingWriters;
+        void*[4]         reserved;
+    }
+
+    alias int    pthread_rwlockattr_t;
+    alias c_long pthread_t;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Barrier (BAR)
+//
+/*
+pthread_barrier_t
+pthread_barrierattr_t
+*/
+
+version( CRuntime_Glibc )
+{
+    struct pthread_barrier_t
+    {
+        byte[__SIZEOF_PTHREAD_BARRIER_T] __size;
+        c_long __align;
+    }
+
+    struct pthread_barrierattr_t
+    {
+        byte[__SIZEOF_PTHREAD_BARRIERATTR_T] __size;
+        int __align;
+    }
+}
+else version( FreeBSD )
+{
+    alias void* pthread_barrier_t;
+    alias void* pthread_barrierattr_t;
+}
+else version( OSX )
+{
+}
+else version (Solaris)
+{
+    struct pthread_barrier_t
+    {
+        uint __pthread_barrier_count;
+        uint __pthread_barrier_current;
+        ulong __pthread_barrier_cycle;
+        ulong __pthread_barrier_reserved;
+        pthread_mutex_t __pthread_barrier_lock;
+        pthread_cond_t __pthread_barrier_cond;
+    }
+
+    struct pthread_barrierattr_t
+    {
+        void* __pthread_barrierattrp;
+    }
+}
+else version( CRuntime_Bionic )
+{
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Spin (SPN)
+//
+/*
+pthread_spinlock_t
+*/
+
+version( CRuntime_Glibc )
+{
+    alias int pthread_spinlock_t; // volatile
+}
+else version( FreeBSD )
+{
+    alias void* pthread_spinlock_t;
+}
+else version (Solaris)
+{
+    alias pthread_mutex_t pthread_spinlock_t;
+}
+
+//
+// Timer (TMR)
+//
+/*
+clockid_t
+timer_t
+*/
+
+//
+// Trace (TRC)
+//
+/*
+trace_attr_t
+trace_event_id_t
+trace_event_set_t
+trace_id_t
+*/
diff --git a/libphobos/libdruntime/core/sys/posix/sys/uio.d b/libphobos/libdruntime/core/sys/posix/sys/uio.d
new file mode 100644
index 00000000000..e0c50f4f5f8
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/uio.d
@@ -0,0 +1,98 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.sys.uio;
+
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types; // for ssize_t
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// Required
+//
+/*
+struct iovec
+{
+    void*  iov_base;
+    size_t iov_len;
+}
+
+ssize_t // from core.sys.posix.sys.types
+size_t  // from core.sys.posix.sys.types
+
+ssize_t readv(int, in iovec*, int);
+ssize_t writev(int, in iovec*, int);
+*/
+
+version( CRuntime_Glibc )
+{
+    struct iovec
+    {
+        void*  iov_base;
+        size_t iov_len;
+    }
+
+    ssize_t readv(int, in iovec*, int);
+    ssize_t writev(int, in iovec*, int);
+}
+else version( OSX )
+{
+    struct iovec
+    {
+        void*  iov_base;
+        size_t iov_len;
+    }
+
+    ssize_t readv(int, in iovec*, int);
+    ssize_t writev(int, in iovec*, int);
+}
+else version( FreeBSD )
+{
+    struct iovec
+    {
+        void*  iov_base;
+        size_t iov_len;
+    }
+
+    ssize_t readv(int, in iovec*, int);
+    ssize_t writev(int, in iovec*, int);
+}
+else version (Solaris)
+{
+    struct iovec
+    {
+        void* iov_base;
+        size_t iov_len;
+    }
+
+    ssize_t readv(int, in iovec*, int);
+    ssize_t writev(int, in iovec*, int);
+}
+else version( CRuntime_Bionic )
+{
+    struct iovec
+    {
+        void* iov_base;
+        uint  iov_len;
+    }
+
+    int readv(int, in iovec*, int);
+    int writev(int, in iovec*, int);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/un.d b/libphobos/libdruntime/core/sys/posix/sys/un.d
new file mode 100644
index 00000000000..9b46fc1ff76
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/un.d
@@ -0,0 +1,70 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.sys.un;
+
+version (Posix):
+extern(C):
+
+public import core.sys.posix.sys.socket: sa_family_t;
+
+//
+// Required
+//
+/*
+struct sockaddr_un
+{
+    sa_family_t sun_family;
+    char        sa_data[];
+}
+
+sa_family_t    // From core.sys.posix.sys.socket
+*/
+
+version( linux )
+{
+    enum UNIX_PATH_MAX = 108;
+
+    struct sockaddr_un
+    {
+        sa_family_t         sun_family;
+        byte[UNIX_PATH_MAX] sun_path;
+    }
+}
+else version( OSX )
+{
+    struct sockaddr_un
+    {
+        ubyte       sun_len;
+        sa_family_t sun_family;
+        byte[104]   sun_path;
+    }
+}
+else version( FreeBSD )
+{
+    struct sockaddr_un
+    {
+        ubyte       sun_len;
+        sa_family_t sun_family;
+        byte[104]   sun_path;
+    }
+}
+else version( Solaris )
+{
+    struct sockaddr_un
+    {
+        sa_family_t  sun_family;
+        byte[108]    sun_path;
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/utsname.d b/libphobos/libdruntime/core/sys/posix/sys/utsname.d
new file mode 100644
index 00000000000..cb01193b3bc
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/utsname.d
@@ -0,0 +1,72 @@
+module core.sys.posix.sys.utsname;
+
+version (Posix):
+extern(C):
+
+version(CRuntime_Glibc)
+{
+    private enum utsNameLength = 65;
+
+    struct utsname
+    {
+        char[utsNameLength] sysname;
+        char[utsNameLength] nodename;
+        char[utsNameLength] release;
+        // The field name is version but version is a keyword in D.
+        char[utsNameLength] update;
+        char[utsNameLength] machine;
+
+        char[utsNameLength] __domainname;
+    }
+
+    int uname(utsname* __name);
+}
+else version(OSX)
+{
+    private enum utsNameLength = 256;
+
+    struct utsname
+    {
+        char[utsNameLength] sysname;
+        char[utsNameLength] nodename;
+        char[utsNameLength] release;
+        // The field name is version but version is a keyword in D.
+        char[utsNameLength] update;
+        char[utsNameLength] machine;
+    }
+
+    int uname(utsname* __name);
+}
+else version(FreeBSD)
+{
+    private enum utsNameLength = 32;
+
+    struct utsname
+    {
+        char[utsNameLength] sysname;
+        char[utsNameLength] nodename;
+        char[utsNameLength] release;
+        // The field name is version but version is a keyword in D.
+        char[utsNameLength] update;
+        char[utsNameLength] machine;
+    }
+
+    int uname(utsname* __name);
+}
+else version(CRuntime_Bionic)
+{
+    private enum SYS_NMLN = 65;
+
+    struct utsname
+    {
+        char[SYS_NMLN] sysname;
+        char[SYS_NMLN] nodename;
+        char[SYS_NMLN] release;
+        // The field name is version but version is a keyword in D.
+        char[SYS_NMLN] _version;
+        char[SYS_NMLN] machine;
+        char[SYS_NMLN] domainname;
+    }
+
+    int uname(utsname*);
+}
diff --git a/libphobos/libdruntime/core/sys/posix/sys/wait.d b/libphobos/libdruntime/core/sys/posix/sys/wait.d
new file mode 100644
index 00000000000..ed42ba85972
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/sys/wait.d
@@ -0,0 +1,253 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.sys.wait;
+
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types; // for id_t, pid_t
+public import core.sys.posix.signal;    // for siginfo_t (XSI)
+//public import core.sys.posix.resource; // for rusage (XSI)
+
+version (Posix):
+extern (C) nothrow @nogc:
+
+//
+// Required
+//
+/*
+WNOHANG
+WUNTRACED
+
+WEXITSTATUS
+WIFCONTINUED
+WIFEXITED
+WIFSIGNALED
+WIFSTOPPED
+WSTOPSIG
+WTERMSIG
+
+pid_t wait(int*);
+pid_t waitpid(pid_t, int*, int);
+*/
+
+version( CRuntime_Glibc )
+{
+    enum WNOHANG        = 1;
+    enum WUNTRACED      = 2;
+
+    private
+    {
+        enum __W_CONTINUED = 0xFFFF;
+
+        extern (D) int __WTERMSIG( int status ) { return status & 0x7F; }
+    }
+
+    //
+    // NOTE: These macros assume __USE_BSD is not defined in the relevant
+    //       C headers as the parameter definition there is different and
+    //       much more complicated.
+    //
+    extern (D) int  WEXITSTATUS( int status )  { return ( status & 0xFF00 ) >> 8;   }
+    extern (D) int  WIFCONTINUED( int status ) { return status == __W_CONTINUED;    }
+    extern (D) bool WIFEXITED( int status )    { return __WTERMSIG( status ) == 0;  }
+    extern (D) bool WIFSIGNALED( int status )
+    {
+        return ( cast(byte) ( ( status & 0x7F ) + 1 ) >> 1 ) > 0;
+    }
+    extern (D) bool WIFSTOPPED( int status )   { return ( status & 0xFF ) == 0x7F;  }
+    extern (D) int  WSTOPSIG( int status )     { return WEXITSTATUS( status );      }
+    extern (D) int  WTERMSIG( int status )     { return status & 0x7F;              }
+}
+else version( OSX )
+{
+    enum WNOHANG        = 1;
+    enum WUNTRACED      = 2;
+
+    private
+    {
+        enum _WSTOPPED = 0x7F; // octal 0177
+    }
+
+    extern (D) int _WSTATUS(int status)         { return (status & 0x7F);           }
+    extern (D) int  WEXITSTATUS( int status )   { return (status >> 8);             }
+    extern (D) int  WIFCONTINUED( int status )  { return status == 0x13;            }
+    extern (D) bool WIFEXITED( int status )     { return _WSTATUS(status) == 0;     }
+    extern (D) bool WIFSIGNALED( int status )
+    {
+        return _WSTATUS( status ) != _WSTOPPED && _WSTATUS( status ) != 0;
+    }
+    extern (D) bool WIFSTOPPED( int status )   { return _WSTATUS( status ) == _WSTOPPED; }
+    extern (D) int  WSTOPSIG( int status )     { return status >> 8;                     }
+    extern (D) int  WTERMSIG( int status )     { return _WSTATUS( status );              }
+}
+else version( FreeBSD )
+{
+    enum WNOHANG        = 1;
+    enum WUNTRACED      = 2;
+
+    private
+    {
+        enum _WSTOPPED = 0x7F; // octal 0177
+    }
+
+    extern (D) int _WSTATUS(int status)         { return (status & 0x7F);           }
+    extern (D) int  WEXITSTATUS( int status )   { return (status >> 8);             }
+    extern (D) int  WIFCONTINUED( int status )  { return status == 0x13;            }
+    extern (D) bool WIFEXITED( int status )     { return _WSTATUS(status) == 0;     }
+    extern (D) bool WIFSIGNALED( int status )
+    {
+        return _WSTATUS( status ) != _WSTOPPED && _WSTATUS( status ) != 0;
+    }
+    extern (D) bool WIFSTOPPED( int status )   { return _WSTATUS( status ) == _WSTOPPED; }
+    extern (D) int  WSTOPSIG( int status )     { return status >> 8;                     }
+    extern (D) int  WTERMSIG( int status )     { return _WSTATUS( status );              }
+}
+else version (Solaris)
+{
+    enum WNOHANG        = 64;
+    enum WUNTRACED      = 4;
+
+    extern (D) int WEXITSTATUS(int status) { return (status >> 8) & 0xff; }
+    extern (D) int WIFCONTINUED(int status) { return (status & 0xffff) == 0xffff; }
+    extern (D) bool WIFEXITED(int status) { return (status & 0xff) == 0;     }
+    extern (D) bool WIFSIGNALED(int status) { return (status & 0xff) > 0 && (status & 0xff00) == 0; }
+    extern (D) bool WIFSTOPPED(int status) { return (status & 0xff) == 0x7f && (status & 0xff00) != 0; }
+    extern (D) int WSTOPSIG(int status) { return (status >> 8) & 0x7f; }
+    extern (D) int WTERMSIG(int status) { return (status & 0x7f); }
+}
+else version( CRuntime_Bionic )
+{
+    enum WNOHANG   = 1;
+    enum WUNTRACED = 2;
+
+    extern (D) int  WEXITSTATUS( int status ) { return ( status & 0xFF00 ) >> 8; }
+    extern (D) bool WIFEXITED( int status ) { return WTERMSIG(status) == 0; }
+    extern (D) bool WIFSIGNALED( int status ) { return WTERMSIG(status + 1) >= 2; }
+    extern (D) bool WIFSTOPPED( int status ) { return WTERMSIG(status) == 0x7F; }
+    extern (D) int  WSTOPSIG( int status ) { return WEXITSTATUS(status); }
+    extern (D) int  WTERMSIG( int status ) { return status & 0x7F; }
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+pid_t wait(int*);
+pid_t waitpid(pid_t, int*, int);
+
+//
+// XOpen (XSI)
+//
+/*
+WEXITED
+WSTOPPED
+WCONTINUED
+WNOWAIT
+
+enum idtype_t
+{
+    P_ALL,
+    P_PID,
+    P_PGID
+}
+
+int waitid(idtype_t, id_t, siginfo_t*, int);
+*/
+
+version( CRuntime_Glibc )
+{
+    enum WEXITED    = 4;
+    enum WSTOPPED   = 2;
+    enum WCONTINUED = 8;
+    enum WNOWAIT    = 0x01000000;
+
+    enum idtype_t
+    {
+        P_ALL,
+        P_PID,
+        P_PGID
+    }
+
+    int waitid(idtype_t, id_t, siginfo_t*, int);
+}
+else version( OSX )
+{
+    enum WEXITED    = 0x00000004;
+    enum WSTOPPED   = 0x00000008;
+    enum WCONTINUED = 0x00000010;
+    enum WNOWAIT    = 0x00000020;
+
+    enum idtype_t
+    {
+        P_ALL,
+        P_PID,
+        P_PGID
+    }
+
+    int waitid(idtype_t, id_t, siginfo_t*, int);
+}
+else version (FreeBSD)
+{
+    enum WSTOPPED       = WUNTRACED;
+    enum WCONTINUED     = 4;
+    enum WNOWAIT        = 8;
+
+    // http://www.freebsd.org/projects/c99/
+}
+else version (Solaris)
+{
+    enum WEXITED = 1;
+    enum WTRAPPED = 2;
+    enum WSTOPPED = WUNTRACED;
+    enum WCONTINUED = 8;
+    enum WNOWAIT = 128;
+
+    enum idtype_t
+    {
+        P_PID,          /* A process identifier.                */
+        P_PPID,         /* A parent process identifier.         */
+        P_PGID,         /* A process group (job control group)  */
+                        /* identifier.                          */
+        P_SID,          /* A session identifier.                */
+        P_CID,          /* A scheduling class identifier.       */
+        P_UID,          /* A user identifier.                   */
+        P_GID,          /* A group identifier.                  */
+        P_ALL,          /* All processes.                       */
+        P_LWPID,        /* An LWP identifier.                   */
+        P_TASKID,       /* A task identifier.                   */
+        P_PROJID,       /* A project identifier.                */
+        P_POOLID,       /* A pool identifier.                   */
+        P_ZONEID,       /* A zone identifier.                   */
+        P_CTID,         /* A (process) contract identifier.     */
+        P_CPUID,        /* CPU identifier.                      */
+        P_PSETID,       /* Processor set identifier             */
+    }
+
+    int waitid(idtype_t, id_t, siginfo_t*, int);
+}
+else version( CRuntime_Bionic )
+{
+    enum WEXITED    = 4;
+    enum WSTOPPED   = 2;
+    enum WCONTINUED = 8;
+    enum WNOWAIT    = 0x01000000;
+
+    alias int idtype_t;
+
+    int waitid(idtype_t, id_t, siginfo_t*, int);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/syslog.d b/libphobos/libdruntime/core/sys/posix/syslog.d
new file mode 100644
index 00000000000..2d117b04e54
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/syslog.d
@@ -0,0 +1,264 @@
+/**
+ * D header file for POSIX system logger API.
+ * (http://pubs.opengroup.org/onlinepubs/007904875/basedefs/syslog.h.html)
+ *
+ * Copyright: Copyright Adil Baig 2013.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Adil Baig
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Adil Baig 2013.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.syslog;
+
+version (Posix):
+
+extern (C) nothrow @nogc:
+
+version(CRuntime_Glibc)
+{
+    //PRIORITY
+    enum {
+        LOG_EMERG = 0,     /* system is unusable */
+        LOG_ALERT = 1,     /* action must be taken immediately */
+        LOG_CRIT  = 2,     /* critical conditions */
+        LOG_ERR   = 3,     /* error conditions */
+        LOG_WARNING = 4,   /* warning conditions */
+        LOG_NOTICE  = 5,   /* normal but significant condition */
+        LOG_INFO    = 6,   /* informational */
+        LOG_DEBUG   = 7,   /* debug-level messages */
+    };
+
+    //OPTIONS
+    enum {
+        LOG_PID    = 0x01,  /* log the pid with each message */
+        LOG_CONS   = 0x02,  /* log on the console if errors in sending */
+        LOG_ODELAY = 0x04,  /* delay open until first syslog() (default) */
+        LOG_NDELAY = 0x08,  /* don't delay open */
+        LOG_NOWAIT = 0x10,  /* don't wait for console forks: DEPRECATED */
+        LOG_PERROR = 0x20,  /* log to stderr as well */
+    };
+
+    //FACILITY
+    enum {
+        LOG_KERN   = (0<<3),  /* kernel messages */
+        LOG_USER   = (1<<3),  /* random user-level messages */
+        LOG_MAIL   = (2<<3),  /* mail system */
+        LOG_DAEMON = (3<<3),  /* system daemons */
+        LOG_AUTH   = (4<<3),  /* security/authorization messages */
+        LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
+        LOG_LPR    = (6<<3),  /* line printer subsystem */
+        LOG_NEWS   = (7<<3),  /* network news subsystem */
+        LOG_UUCP   = (8<<3),  /* UUCP subsystem */
+        LOG_CRON   = (9<<3),  /* clock daemon */
+        LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */
+        LOG_FTP    =  (11<<3), /* ftp daemon */
+
+        /* other codes through 15 reserved for system use */
+        LOG_LOCAL0 = (16<<3), /* reserved for local use */
+        LOG_LOCAL1 = (17<<3), /* reserved for local use */
+        LOG_LOCAL2 = (18<<3), /* reserved for local use */
+        LOG_LOCAL3 = (19<<3), /* reserved for local use */
+        LOG_LOCAL4 = (20<<3), /* reserved for local use */
+        LOG_LOCAL5 = (21<<3), /* reserved for local use */
+        LOG_LOCAL6 = (22<<3), /* reserved for local use */
+        LOG_LOCAL7 = (23<<3), /* reserved for local use */
+
+        LOG_NFACILITIES = 24,  /* current number of facilities */
+    };
+
+    int LOG_MASK(int pri) { return 1 << pri; }        /* mask for one priority */
+    int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
+
+    void openlog (const char *, int __option, int __facility);
+    int  setlogmask (int __mask);
+    void syslog (int __pri, const char *__fmt, ...);
+    void closelog();
+}
+else version( OSX )
+{
+    //http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/osfmk/sys/syslog.h
+
+    //PRIORITY
+    enum {
+        LOG_EMERG = 0,     /* system is unusable */
+        LOG_ALERT = 1,     /* action must be taken immediately */
+        LOG_CRIT  = 2,     /* critical conditions */
+        LOG_ERR   = 3,     /* error conditions */
+        LOG_WARNING = 4,   /* warning conditions */
+        LOG_NOTICE  = 5,   /* normal but significant condition */
+        LOG_INFO    = 6,   /* informational */
+        LOG_DEBUG   = 7,   /* debug-level messages */
+    };
+
+    //OPTIONS
+    enum {
+        LOG_PID    = 0x01,     /* log the pid with each message */
+        LOG_CONS   = 0x02,  /* log on the console if errors in sending */
+        LOG_ODELAY = 0x04,  /* delay open until first syslog() (default) */
+        LOG_NDELAY = 0x08,  /* don't delay open */
+        LOG_NOWAIT = 0x10,  /* don't wait for console forks: DEPRECATED */
+    };
+
+    //FACILITY
+    enum {
+        LOG_KERN   = (0<<3),  /* kernel messages */
+        LOG_USER   = (1<<3),  /* random user-level messages */
+        LOG_MAIL   = (2<<3),  /* mail system */
+        LOG_DAEMON = (3<<3),  /* system daemons */
+        LOG_AUTH   = (4<<3),  /* security/authorization messages */
+        LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
+        LOG_LPR    = (6<<3),  /* line printer subsystem */
+        LOG_NEWS   = (7<<3),  /* network news subsystem */
+        LOG_UUCP   = (8<<3),  /* UUCP subsystem */
+
+        /* other codes through 15 reserved for system use */
+        LOG_LOCAL0 = (16<<3), /* reserved for local use */
+        LOG_LOCAL1 = (17<<3), /* reserved for local use */
+        LOG_LOCAL2 = (18<<3), /* reserved for local use */
+        LOG_LOCAL3 = (19<<3), /* reserved for local use */
+        LOG_LOCAL4 = (20<<3), /* reserved for local use */
+        LOG_LOCAL5 = (21<<3), /* reserved for local use */
+        LOG_LOCAL6 = (22<<3), /* reserved for local use */
+        LOG_LOCAL7 = (23<<3), /* reserved for local use */
+
+        LOG_NFACILITIES = 24,  /* current number of facilities */
+    };
+
+    int LOG_MASK(int pri) { return 1 << pri; }        /* mask for one priority */
+    int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
+
+    void openlog (const char *, int __option, int __facility);
+    int  setlogmask (int __mask);
+    void syslog (int __pri, const char *__fmt, ...);
+    void closelog();
+}
+else version( FreeBSD )
+{
+    //http://fxr.watson.org/fxr/source/sys/syslog.h
+
+    //PRIORITY
+    enum {
+        LOG_EMERG = 0,     /* system is unusable */
+        LOG_ALERT = 1,     /* action must be taken immediately */
+        LOG_CRIT  = 2,     /* critical conditions */
+        LOG_ERR   = 3,     /* error conditions */
+        LOG_WARNING = 4,   /* warning conditions */
+        LOG_NOTICE  = 5,   /* normal but significant condition */
+        LOG_INFO    = 6,   /* informational */
+        LOG_DEBUG   = 7,   /* debug-level messages */
+    };
+
+    //OPTIONS
+    enum {
+        LOG_PID    = 0x01,    /* log the pid with each message */
+        LOG_CONS   = 0x02,    /* log on the console if errors in sending */
+        LOG_ODELAY = 0x04,    /* delay open until first syslog() (default) */
+        LOG_NDELAY = 0x08,    /* don't delay open */
+        LOG_NOWAIT = 0x10,    /* don't wait for console forks: DEPRECATED */
+        LOG_PERROR = 0x20,    /* log to stderr as well */
+    };
+
+    //FACILITY
+    enum {
+        LOG_KERN   = (0<<3),  /* kernel messages */
+        LOG_USER   = (1<<3),  /* random user-level messages */
+        LOG_MAIL   = (2<<3),  /* mail system */
+        LOG_DAEMON = (3<<3),  /* system daemons */
+        LOG_AUTH   = (4<<3),  /* security/authorization messages */
+        LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
+        LOG_LPR    = (6<<3),  /* line printer subsystem */
+        LOG_NEWS   = (7<<3),  /* network news subsystem */
+        LOG_UUCP   = (8<<3),  /* UUCP subsystem */
+        LOG_CRON   = (9<<3),  /* clock daemon */
+        LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */
+        LOG_FTP    =  (11<<3), /* ftp daemon */
+        LOG_NTP    = (12<<3), /* NTP subsystem */
+        LOG_SECURITY = (13<<3), /* security subsystems (firewalling, etc.) */
+        LOG_CONSOLE  = (14<<3), /* /dev/console output */
+
+        /* other codes through 15 reserved for system use */
+        LOG_LOCAL0 = (16<<3), /* reserved for local use */
+        LOG_LOCAL1 = (17<<3), /* reserved for local use */
+        LOG_LOCAL2 = (18<<3), /* reserved for local use */
+        LOG_LOCAL3 = (19<<3), /* reserved for local use */
+        LOG_LOCAL4 = (20<<3), /* reserved for local use */
+        LOG_LOCAL5 = (21<<3), /* reserved for local use */
+        LOG_LOCAL6 = (22<<3), /* reserved for local use */
+        LOG_LOCAL7 = (23<<3), /* reserved for local use */
+
+        LOG_NFACILITIES = 24,  /* current number of facilities */
+    };
+
+    int LOG_MASK(int pri) { return 1 << pri; }        /* mask for one priority */
+    int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
+
+    void openlog (const char *, int __option, int __facility);
+    int  setlogmask (int __mask);
+    void syslog (int __pri, const char *__fmt, ...);
+    void closelog();
+}
+else version( Solaris )
+{
+    //http://pubs.opengroup.org/onlinepubs/007904875/basedefs/syslog.h.html
+
+    //PRIORITY
+    enum {
+        LOG_EMERG = 0,     /* system is unusable */
+        LOG_ALERT = 1,     /* action must be taken immediately */
+        LOG_CRIT  = 2,     /* critical conditions */
+        LOG_ERR   = 3,     /* error conditions */
+        LOG_WARNING = 4,   /* warning conditions */
+        LOG_NOTICE  = 5,   /* normal but significant condition */
+        LOG_INFO    = 6,   /* informational */
+        LOG_DEBUG   = 7,   /* debug-level messages */
+    };
+
+    //OPTIONS
+    enum {
+        LOG_PID = 0x01,     /* log the pid with each message */
+        LOG_CONS   = 0x02,  /* log on the console if errors in sending */
+        LOG_NDELAY = 0x08,  /* don't delay open */
+        LOG_NOWAIT = 0x10,  /* don't wait for console forks: DEPRECATED */
+    };
+
+    //FACILITY
+    enum {
+        LOG_KERN   = (0<<3),  /* kernel messages */
+        LOG_USER   = (1<<3),  /* random user-level messages */
+        LOG_MAIL   = (2<<3),  /* mail system */
+        LOG_DAEMON = (3<<3),  /* system daemons */
+        LOG_AUTH   = (4<<3),  /* security/authorization messages */
+        LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
+        LOG_LPR    = (6<<3),  /* line printer subsystem */
+        LOG_NEWS   = (7<<3),  /* network news subsystem */
+        LOG_UUCP   = (8<<3),  /* UUCP subsystem */
+        LOG_CRON   = (9<<3),  /* clock daemon */
+        LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */
+        LOG_FTP    =  (11<<3), /* ftp daemon */
+
+        /* other codes through 15 reserved for system use */
+        LOG_LOCAL0 = (16<<3), /* reserved for local use */
+        LOG_LOCAL1 = (17<<3), /* reserved for local use */
+        LOG_LOCAL2 = (18<<3), /* reserved for local use */
+        LOG_LOCAL3 = (19<<3), /* reserved for local use */
+        LOG_LOCAL4 = (20<<3), /* reserved for local use */
+        LOG_LOCAL5 = (21<<3), /* reserved for local use */
+        LOG_LOCAL6 = (22<<3), /* reserved for local use */
+        LOG_LOCAL7 = (23<<3), /* reserved for local use */
+
+        LOG_NFACILITIES = 24,  /* current number of facilities */
+    };
+
+    int LOG_MASK(int pri) { return 1 << pri; }        /* mask for one priority */
+    int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
+
+    void openlog (const char *, int __option, int __facility);
+    int  setlogmask (int __mask);
+    void syslog (int __pri, const char *__fmt, ...);
+    void closelog();
+}
diff --git a/libphobos/libdruntime/core/sys/posix/termios.d b/libphobos/libdruntime/core/sys/posix/termios.d
new file mode 100644
index 00000000000..85061d1db4e
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/termios.d
@@ -0,0 +1,604 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly, Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.termios;
+
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types; // for pid_t
+
+version (Posix):
+extern (C):
+
+nothrow:
+@nogc:
+
+//
+// Required
+//
+/*
+cc_t
+speed_t
+tcflag_t
+
+NCCS
+
+struct termios
+{
+    tcflag_t   c_iflag;
+    tcflag_t   c_oflag;
+    tcflag_t   c_cflag;
+    tcflag_t   c_lflag;
+    cc_t[NCCS] c_cc;
+}
+
+VEOF
+VEOL
+VERASE
+VINTR
+VKILL
+VMIN
+VQUIT
+VSTART
+VSTOP
+VSUSP
+VTIME
+
+BRKINT
+ICRNL
+IGNBRK
+IGNCR
+IGNPAR
+INLCR
+INPCK
+ISTRIP
+IXOFF
+IXON
+PARMRK
+
+OPOST
+
+B0
+B50
+B75
+B110
+B134
+B150
+B200
+B300
+B600
+B1200
+B1800
+B2400
+B4800
+B9600
+B19200
+B38400
+
+CSIZE
+    CS5
+    CS6
+    CS7
+    CS8
+CSTOPB
+CREAD
+PARENB
+PARODD
+HUPCL
+CLOCAL
+
+ECHO
+ECHOE
+ECHOK
+ECHONL
+ICANON
+IEXTEN
+ISIG
+NOFLSH
+TOSTOP
+
+TCSANOW
+TCSADRAIN
+TCSAFLUSH
+
+TCIFLUSH
+TCIOFLUSH
+TCOFLUSH
+
+TCIOFF
+TCION
+TCOOFF
+TCOON
+
+speed_t cfgetispeed(in termios*);
+speed_t cfgetospeed(in termios*);
+int     cfsetispeed(termios*, speed_t);
+int     cfsetospeed(termios*, speed_t);
+int     tcdrain(int);
+int     tcflow(int, int);
+int     tcflush(int, int);
+int     tcgetattr(int, termios*);
+int     tcsendbreak(int, int);
+int     tcsetattr(int, int, in termios*);
+*/
+
+version( CRuntime_Glibc )
+{
+    alias ubyte cc_t;
+    alias uint  speed_t;
+    alias uint  tcflag_t;
+
+    enum NCCS   = 32;
+
+    struct termios
+    {
+        tcflag_t   c_iflag;
+        tcflag_t   c_oflag;
+        tcflag_t   c_cflag;
+        tcflag_t   c_lflag;
+        cc_t       c_line;
+        cc_t[NCCS] c_cc;
+        speed_t    c_ispeed;
+        speed_t    c_ospeed;
+    }
+
+    enum VEOF       = 4;
+    enum VEOL       = 11;
+    enum VERASE     = 2;
+    enum VINTR      = 0;
+    enum VKILL      = 3;
+    enum VMIN       = 6;
+    enum VQUIT      = 1;
+    enum VSTART     = 8;
+    enum VSTOP      = 9;
+    enum VSUSP      = 10;
+    enum VTIME      = 5;
+
+    enum BRKINT     = 0x0000002; // 0000002
+    enum ICRNL      = 0x0000100; // 0000400
+    enum IGNBRK     = 0x0000001; // 0000001
+    enum IGNCR      = 0x0000080; // 0000200
+    enum IGNPAR     = 0x0000004; // 0000004
+    enum INLCR      = 0x0000040; // 0000100
+    enum INPCK      = 0x0000010; // 0000020
+    enum ISTRIP     = 0x0000020; // 0000040
+    enum IXOFF      = 0x0001000; // 0010000
+    enum IXON       = 0x0000400; // 0002000
+    enum PARMRK     = 0x0000008; // 0000010
+
+    enum OPOST      = 0x0000001; // 0000001
+
+    enum B0         = 0x0000000; // 0000000
+    enum B50        = 0x0000001; // 0000001
+    enum B75        = 0x0000002; // 0000002
+    enum B110       = 0x0000003; // 0000003
+    enum B134       = 0x0000004; // 0000004
+    enum B150       = 0x0000005; // 0000005
+    enum B200       = 0x0000006; // 0000006
+    enum B300       = 0x0000007; // 0000007
+    enum B600       = 0x0000008; // 0000010
+    enum B1200      = 0x0000009; // 0000011
+    enum B1800      = 0x000000A; // 0000012
+    enum B2400      = 0x000000B; // 0000013
+    enum B4800      = 0x000000C; // 0000014
+    enum B9600      = 0x000000D; // 0000015
+    enum B19200     = 0x000000E; // 0000016
+    enum B38400     = 0x000000F; // 0000017
+
+    enum CSIZE      = 0x0000030; // 0000060
+    enum   CS5      = 0x0000000; // 0000000
+    enum   CS6      = 0x0000010; // 0000020
+    enum   CS7      = 0x0000020; // 0000040
+    enum   CS8      = 0x0000030; // 0000060
+    enum CSTOPB     = 0x0000040; // 0000100
+    enum CREAD      = 0x0000080; // 0000200
+    enum PARENB     = 0x0000100; // 0000400
+    enum PARODD     = 0x0000200; // 0001000
+    enum HUPCL      = 0x0000400; // 0002000
+    enum CLOCAL     = 0x0000800; // 0004000
+
+    enum ECHO       = 0x0000008; // 0000010
+    enum ECHOE      = 0x0000010; // 0000020
+    enum ECHOK      = 0x0000020; // 0000040
+    enum ECHONL     = 0x0000040; // 0000100
+    enum ICANON     = 0x0000002; // 0000002
+    enum IEXTEN     = 0x0008000; // 0100000
+    enum ISIG       = 0x0000001; // 0000001
+    enum NOFLSH     = 0x0000080; // 0000200
+    enum TOSTOP     = 0x0000100; // 0000400
+
+    enum TCSANOW    = 0;
+    enum TCSADRAIN  = 1;
+    enum TCSAFLUSH  = 2;
+
+    enum TCIFLUSH   = 0;
+    enum TCOFLUSH   = 1;
+    enum TCIOFLUSH  = 2;
+
+    enum TCIOFF     = 2;
+    enum TCION      = 3;
+    enum TCOOFF     = 0;
+    enum TCOON      = 1;
+
+    speed_t cfgetispeed(in termios*);
+    speed_t cfgetospeed(in termios*);
+    int     cfsetispeed(termios*, speed_t);
+    int     cfsetospeed(termios*, speed_t);
+    int     tcdrain(int);
+    int     tcflow(int, int);
+    int     tcflush(int, int);
+    int     tcgetattr(int, termios*);
+    int     tcsendbreak(int, int);
+    int     tcsetattr(int, int, in termios*);
+}
+else version( OSX )
+{
+    alias ubyte cc_t;
+    alias c_ulong  speed_t;
+    alias c_ulong  tcflag_t;
+
+    enum NCCS   = 20;
+
+    struct termios
+    {
+        tcflag_t   c_iflag;
+        tcflag_t   c_oflag;
+        tcflag_t   c_cflag;
+        tcflag_t   c_lflag;
+        cc_t[NCCS] c_cc;
+        speed_t    c_ispeed;
+        speed_t    c_ospeed;
+    }
+
+    enum VEOF       = 0;
+    enum VEOL       = 1;
+    enum VERASE     = 3;
+    enum VINTR      = 8;
+    enum VKILL      = 5;
+    enum VMIN       = 16;
+    enum VQUIT      = 9;
+    enum VSTART     = 12;
+    enum VSTOP      = 13;
+    enum VSUSP      = 10;
+    enum VTIME      = 17;
+
+    enum BRKINT     = 0x0000002;
+    enum ICRNL      = 0x0000100;
+    enum IGNBRK     = 0x0000001;
+    enum IGNCR      = 0x0000080;
+    enum IGNPAR     = 0x0000004;
+    enum INLCR      = 0x0000040;
+    enum INPCK      = 0x0000010;
+    enum ISTRIP     = 0x0000020;
+    enum IXOFF      = 0x0000400;
+    enum IXON       = 0x0000200;
+    enum PARMRK     = 0x0000008;
+
+    enum OPOST      = 0x0000001;
+
+    enum B0         = 0;
+    enum B50        = 50;
+    enum B75        = 75;
+    enum B110       = 110;
+    enum B134       = 134;
+    enum B150       = 150;
+    enum B200       = 200;
+    enum B300       = 300;
+    enum B600       = 600;
+    enum B1200      = 1200;
+    enum B1800      = 1800;
+    enum B2400      = 2400;
+    enum B4800      = 4800;
+    enum B9600      = 9600;
+    enum B19200     = 19200;
+    enum B38400     = 38400;
+
+    enum CSIZE      = 0x0000300;
+    enum   CS5      = 0x0000000;
+    enum   CS6      = 0x0000100;
+    enum   CS7      = 0x0000200;
+    enum   CS8      = 0x0000300;
+    enum CSTOPB     = 0x0000400;
+    enum CREAD      = 0x0000800;
+    enum PARENB     = 0x0001000;
+    enum PARODD     = 0x0002000;
+    enum HUPCL      = 0x0004000;
+    enum CLOCAL     = 0x0008000;
+
+    enum ECHO       = 0x00000008;
+    enum ECHOE      = 0x00000002;
+    enum ECHOK      = 0x00000004;
+    enum ECHONL     = 0x00000010;
+    enum ICANON     = 0x00000100;
+    enum IEXTEN     = 0x00000400;
+    enum ISIG       = 0x00000080;
+    enum NOFLSH     = 0x80000000;
+    enum TOSTOP     = 0x00400000;
+
+    enum TCSANOW    = 0;
+    enum TCSADRAIN  = 1;
+    enum TCSAFLUSH  = 2;
+
+    enum TCIFLUSH   = 1;
+    enum TCOFLUSH   = 2;
+    enum TCIOFLUSH  = 3;
+
+    enum TCIOFF     = 3;
+    enum TCION      = 4;
+    enum TCOOFF     = 1;
+    enum TCOON      = 2;
+
+    speed_t cfgetispeed(in termios*);
+    speed_t cfgetospeed(in termios*);
+    int     cfsetispeed(termios*, speed_t);
+    int     cfsetospeed(termios*, speed_t);
+    int     tcdrain(int);
+    int     tcflow(int, int);
+    int     tcflush(int, int);
+    int     tcgetattr(int, termios*);
+    int     tcsendbreak(int, int);
+    int     tcsetattr(int, int, in termios*);
+
+}
+else version ( FreeBSD )
+{
+    alias ubyte cc_t;
+    alias uint  speed_t;
+    alias uint  tcflag_t;
+
+    enum NCCS   = 20;
+
+    struct termios
+    {
+        tcflag_t   c_iflag;
+        tcflag_t   c_oflag;
+        tcflag_t   c_cflag;
+        tcflag_t   c_lflag;
+        cc_t[NCCS] c_cc;
+        speed_t    c_ispeed;
+        speed_t    c_ospeed;
+    }
+
+    enum VEOF       = 0;
+    enum VEOL       = 1;
+    enum VERASE     = 3;
+    enum VINTR      = 8;
+    enum VKILL      = 5;
+    enum VMIN       = 16;
+    enum VQUIT      = 9;
+    enum VSTART     = 12;
+    enum VSTOP      = 13;
+    enum VSUSP      = 10;
+    enum VTIME      = 17;
+
+    enum BRKINT     = 0x0000002;
+    enum ICRNL      = 0x0000100;
+    enum IGNBRK     = 0x0000001;
+    enum IGNCR      = 0x0000080;
+    enum IGNPAR     = 0x0000004;
+    enum INLCR      = 0x0000040;
+    enum INPCK      = 0x0000010;
+    enum ISTRIP     = 0x0000020;
+    enum IXOFF      = 0x0000400;
+    enum IXON       = 0x0000200;
+    enum PARMRK     = 0x0000008;
+
+    enum OPOST      = 0x0000001;
+
+    enum B0         = 0;
+    enum B50        = 50;
+    enum B75        = 75;
+    enum B110       = 110;
+    enum B134       = 134;
+    enum B150       = 150;
+    enum B200       = 200;
+    enum B300       = 300;
+    enum B600       = 600;
+    enum B1200      = 1200;
+    enum B1800      = 1800;
+    enum B2400      = 2400;
+    enum B4800      = 4800;
+    enum B9600      = 9600;
+    enum B19200     = 19200;
+    enum B38400     = 38400;
+
+    enum CSIZE      = 0x0000300;
+    enum   CS5      = 0x0000000;
+    enum   CS6      = 0x0000100;
+    enum   CS7      = 0x0000200;
+    enum   CS8      = 0x0000300;
+    enum CSTOPB     = 0x0000400;
+    enum CREAD      = 0x0000800;
+    enum PARENB     = 0x0001000;
+    enum PARODD     = 0x0002000;
+    enum HUPCL      = 0x0004000;
+    enum CLOCAL     = 0x0008000;
+
+    enum ECHO       = 0x00000008;
+    enum ECHOE      = 0x00000002;
+    enum ECHOK      = 0x00000004;
+    enum ECHONL     = 0x00000010;
+    enum ICANON     = 0x00000100;
+    enum IEXTEN     = 0x00000400;
+    enum ISIG       = 0x00000080;
+    enum NOFLSH     = 0x80000000;
+    enum TOSTOP     = 0x00400000;
+
+    enum TCSANOW    = 0;
+    enum TCSADRAIN  = 1;
+    enum TCSAFLUSH  = 2;
+
+    enum TCIFLUSH   = 1;
+    enum TCOFLUSH   = 2;
+    enum TCIOFLUSH  = 3;
+
+    enum TCIOFF     = 3;
+    enum TCION      = 4;
+    enum TCOOFF     = 1;
+    enum TCOON      = 2;
+
+    speed_t cfgetispeed(in termios*);
+    speed_t cfgetospeed(in termios*);
+    int     cfsetispeed(termios*, speed_t);
+    int     cfsetospeed(termios*, speed_t);
+    int     tcdrain(int);
+    int     tcflow(int, int);
+    int     tcflush(int, int);
+    int     tcgetattr(int, termios*);
+    int     tcsendbreak(int, int);
+    int     tcsetattr(int, int, in termios*);
+
+}
+
+//
+// XOpen (XSI)
+//
+/*
+IXANY
+
+ONLCR
+OCRNL
+ONOCR
+ONLRET
+OFILL
+NLDLY
+    NL0
+    NL1
+CRDLY
+    CR0
+    CR1
+    CR2
+    CR3
+TABDLY
+    TAB0
+    TAB1
+    TAB2
+    TAB3
+BSDLY
+    BS0
+    BS1
+VTDLY
+    VT0
+    VT1
+FFDLY
+    FF0
+    FF1
+
+pid_t   tcgetsid(int);
+*/
+
+version( CRuntime_Glibc )
+{
+    enum IXANY      = 0x0000800; // 0004000
+
+    enum ONLCR      = 0x0000004; // 0000004
+    enum OCRNL      = 0x0000008; // 0000010
+    enum ONOCR      = 0x0000010; // 0000020
+    enum ONLRET     = 0x0000020; // 0000040
+    enum OFILL      = 0x0000040; // 0000100
+    enum NLDLY      = 0x0000100; // 0000400
+    enum   NL0      = 0x0000000; // 0000000
+    enum   NL1      = 0x0000100; // 0000400
+    enum CRDLY      = 0x0000600; // 0003000
+    enum   CR0      = 0x0000000; // 0000000
+    enum   CR1      = 0x0000200; // 0001000
+    enum   CR2      = 0x0000400; // 0002000
+    enum   CR3      = 0x0000600; // 0003000
+    enum TABDLY     = 0x0001800; // 0014000
+    enum   TAB0     = 0x0000000; // 0000000
+    enum   TAB1     = 0x0000800; // 0004000
+    enum   TAB2     = 0x0001000; // 0010000
+    enum   TAB3     = 0x0001800; // 0014000
+    enum BSDLY      = 0x0002000; // 0020000
+    enum   BS0      = 0x0000000; // 0000000
+    enum   BS1      = 0x0002000; // 0020000
+    enum VTDLY      = 0x0004000; // 0040000
+    enum   VT0      = 0x0000000; // 0000000
+    enum   VT1      = 0x0004000; // 0040000
+    enum FFDLY      = 0x0008000; // 0100000
+    enum   FF0      = 0x0000000; // 0000000
+    enum   FF1      = 0x0008000; // 0100000
+
+    pid_t   tcgetsid(int);
+}
+
+else version (OSX)
+{
+    enum IXANY      = 0x00000800;
+
+    enum ONLCR      = 0x00000002;
+    enum OCRNL      = 0x00000010;
+    enum ONOCR      = 0x00000020;
+    enum ONLRET     = 0x00000040;
+    enum OFILL      = 0x00000080;
+    enum NLDLY      = 0x00000300;
+    enum   NL0      = 0x00000000;
+    enum   NL1      = 0x00000100;
+    enum CRDLY      = 0x00003000;
+    enum   CR0      = 0x00000000;
+    enum   CR1      = 0x00001000;
+    enum   CR2      = 0x00002000;
+    enum   CR3      = 0x00003000;
+    enum TABDLY     = 0x00000c04;
+    enum   TAB0     = 0x00000000;
+    enum   TAB1     = 0x00000400;
+    enum   TAB2     = 0x00000800;
+    enum   TAB3     = 0x00000004;
+    enum BSDLY      = 0x00008000;
+    enum   BS0      = 0x00000000;
+    enum   BS1      = 0x00008000;
+    enum VTDLY      = 0x00010000;
+    enum   VT0      = 0x00000000;
+    enum   VT1      = 0x00010000;
+    enum FFDLY      = 0x00004000;
+    enum   FF0      = 0x00000000;
+    enum   FF1      = 0x00004000;
+
+    pid_t tcgetsid (int);
+}
+
+else version( FreeBSD )
+{
+    enum IXANY      = 0x00000800;
+
+    enum ONLCR      = 0x00000002;
+    enum OCRNL      = 0x00000010;
+    enum ONOCR      = 0x00000020;
+    enum ONLRET     = 0x00000040;
+    //enum OFILL
+    //enum NLDLY
+    //enum     NL0
+    //enum     NL1
+    //enum CRDLY
+    //enum     CR0
+    //enum     CR1
+    //enum     CR2
+    //enum     CR3
+    enum TABDLY     = 0x00000004;
+    enum     TAB0   = 0x00000000;
+    //enum     TAB1
+    //enum     TAB2
+    enum     TAB3   = 0x00000004;
+    //enum BSDLY
+    //enum     BS0
+    //enum     BS1
+    //enum VTDLY
+    //enum     VT0
+    //enum     VT1
+    //enum FFDLY
+    //enum     FF0
+    //enum     FF1
+
+    pid_t   tcgetsid(int);
+}
+
diff --git a/libphobos/libdruntime/core/sys/posix/time.d b/libphobos/libdruntime/core/sys/posix/time.d
new file mode 100644
index 00000000000..bd54f610fe4
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/time.d
@@ -0,0 +1,413 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly,
+              Alex Rønne Petersen
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.time;
+
+private import core.sys.posix.config;
+public import core.stdc.time;
+public import core.sys.posix.sys.types;
+public import core.sys.posix.signal; // for sigevent
+
+version (Posix):
+extern (C):
+nothrow:
+@nogc:
+
+//
+// Required (defined in core.stdc.time)
+//
+/*
+char* asctime(in tm*);
+clock_t clock();
+char* ctime(in time_t*);
+double difftime(time_t, time_t);
+tm* gmtime(in time_t*);
+tm* localtime(in time_t*);
+time_t mktime(tm*);
+size_t strftime(char*, size_t, in char*, in tm*);
+time_t time(time_t*);
+*/
+
+version( CRuntime_Glibc )
+{
+    time_t timegm(tm*); // non-standard
+}
+else version( OSX )
+{
+    time_t timegm(tm*); // non-standard
+}
+else version( FreeBSD )
+{
+    time_t timegm(tm*); // non-standard
+}
+else version (Solaris)
+{
+    time_t timegm(tm*); // non-standard
+}
+else version (CRuntime_Bionic)
+{
+    // Not supported.
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// C Extension (CX)
+// (defined in core.stdc.time)
+//
+/*
+char* tzname[];
+void tzset();
+*/
+
+//
+// Process CPU-Time Clocks (CPT)
+//
+/*
+int clock_getcpuclockid(pid_t, clockid_t*);
+*/
+
+//
+// Clock Selection (CS)
+//
+/*
+int clock_nanosleep(clockid_t, int, in timespec*, timespec*);
+*/
+
+//
+// Monotonic Clock (MON)
+//
+/*
+CLOCK_MONOTONIC
+*/
+
+version( linux )
+{
+    enum CLOCK_MONOTONIC          = 1;
+    // To be removed in December 2015.
+    static import core.sys.linux.time;
+    deprecated("Please import it from core.sys.linux.time instead.")
+        alias CLOCK_MONOTONIC_RAW = core.sys.linux.time.CLOCK_MONOTONIC_RAW; // non-standard
+    deprecated("Please import it from core.sys.linux.time instead.")
+        alias CLOCK_MONOTONIC_COARSE = core.sys.linux.time.CLOCK_MONOTONIC_COARSE; // non-standard
+}
+else version (FreeBSD)
+{   // time.h
+    enum CLOCK_MONOTONIC         = 4;
+    // To be removed in December 2015.
+    static import core.sys.freebsd.time;
+    deprecated("Please import it from core.sys.freebsd.time instead.")
+        alias CLOCK_MONOTONIC_PRECISE = core.sys.freebsd.time.CLOCK_MONOTONIC_PRECISE;
+    deprecated("Please import it from core.sys.freebsd.time instead.")
+        alias CLOCK_MONOTONIC_FAST = core.sys.freebsd.time.CLOCK_MONOTONIC_FAST;
+}
+else version (OSX)
+{
+    // No CLOCK_MONOTONIC defined
+}
+else version (Solaris)
+{
+    enum CLOCK_MONOTONIC = 4;
+}
+else
+{
+    static assert(0);
+}
+
+//
+// Timer (TMR)
+//
+/*
+CLOCK_PROCESS_CPUTIME_ID (TMR|CPT)
+CLOCK_THREAD_CPUTIME_ID (TMR|TCT)
+
+NOTE: timespec must be defined in core.sys.posix.signal to break
+      a circular import.
+
+struct timespec
+{
+    time_t  tv_sec;
+    int     tv_nsec;
+}
+
+struct itimerspec
+{
+    timespec it_interval;
+    timespec it_value;
+}
+
+CLOCK_REALTIME
+TIMER_ABSTIME
+
+clockid_t
+timer_t
+
+int clock_getres(clockid_t, timespec*);
+int clock_gettime(clockid_t, timespec*);
+int clock_settime(clockid_t, in timespec*);
+int nanosleep(in timespec*, timespec*);
+int timer_create(clockid_t, sigevent*, timer_t*);
+int timer_delete(timer_t);
+int timer_gettime(timer_t, itimerspec*);
+int timer_getoverrun(timer_t);
+int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
+*/
+
+version( CRuntime_Glibc )
+{
+    enum CLOCK_PROCESS_CPUTIME_ID = 2;
+    enum CLOCK_THREAD_CPUTIME_ID  = 3;
+
+    // NOTE: See above for why this is commented out.
+    //
+    //struct timespec
+    //{
+    //    time_t  tv_sec;
+    //    c_long  tv_nsec;
+    //}
+
+    struct itimerspec
+    {
+        timespec it_interval;
+        timespec it_value;
+    }
+
+    enum CLOCK_REALTIME         = 0;
+    // To be removed in December 2015.
+    static import core.sys.linux.time;
+    deprecated("Please import it from core.sys.linux.time instead.")
+        alias CLOCK_REALTIME_COARSE = core.sys.linux.time.CLOCK_REALTIME_COARSE; // non-standard
+    enum TIMER_ABSTIME          = 0x01;
+
+    alias int clockid_t;
+    alias int timer_t;
+
+    int clock_getres(clockid_t, timespec*);
+    int clock_gettime(clockid_t, timespec*);
+    int clock_settime(clockid_t, in timespec*);
+    int nanosleep(in timespec*, timespec*);
+    int timer_create(clockid_t, sigevent*, timer_t*);
+    int timer_delete(timer_t);
+    int timer_gettime(timer_t, itimerspec*);
+    int timer_getoverrun(timer_t);
+    int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
+}
+else version( OSX )
+{
+    int nanosleep(in timespec*, timespec*);
+}
+else version( FreeBSD )
+{
+    //enum CLOCK_PROCESS_CPUTIME_ID = ??;
+    enum CLOCK_THREAD_CPUTIME_ID  = 15;
+
+    // NOTE: See above for why this is commented out.
+    //
+    //struct timespec
+    //{
+    //    time_t  tv_sec;
+    //    c_long  tv_nsec;
+    //}
+
+    struct itimerspec
+    {
+        timespec it_interval;
+        timespec it_value;
+    }
+
+    enum CLOCK_REALTIME      = 0;
+    enum TIMER_ABSTIME       = 0x01;
+
+    alias int clockid_t; // <sys/_types.h>
+    alias int timer_t;
+
+    int clock_getres(clockid_t, timespec*);
+    int clock_gettime(clockid_t, timespec*);
+    int clock_settime(clockid_t, in timespec*);
+    int nanosleep(in timespec*, timespec*);
+    int timer_create(clockid_t, sigevent*, timer_t*);
+    int timer_delete(timer_t);
+    int timer_gettime(timer_t, itimerspec*);
+    int timer_getoverrun(timer_t);
+    int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
+}
+else version (Solaris)
+{
+    enum CLOCK_PROCESS_CPUTIME_ID = 5; // <sys/time_impl.h>
+    enum CLOCK_THREAD_CPUTIME_ID  = 2; // <sys/time_impl.h>
+
+    struct itimerspec
+    {
+        timespec it_interval;
+        timespec it_value;
+    }
+
+    enum CLOCK_REALTIME = 3; // <sys/time_impl.h>
+    enum TIMER_ABSOLUTE = 0x1;
+
+    alias int clockid_t;
+    alias int timer_t;
+
+    int clock_getres(clockid_t, timespec*);
+    int clock_gettime(clockid_t, timespec*);
+    int clock_settime(clockid_t, in timespec*);
+    int clock_nanosleep(clockid_t, int, in timespec*, timespec*);
+
+    int nanosleep(in timespec*, timespec*);
+
+    int timer_create(clockid_t, sigevent*, timer_t*);
+    int timer_delete(timer_t);
+    int timer_getoverrun(timer_t);
+    int timer_gettime(timer_t, itimerspec*);
+    int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
+}
+else version( CRuntime_Bionic )
+{
+    enum CLOCK_PROCESS_CPUTIME_ID = 2;
+    enum CLOCK_THREAD_CPUTIME_ID  = 3;
+
+    struct itimerspec
+    {
+        timespec it_interval;
+        timespec it_value;
+    }
+
+    enum CLOCK_REALTIME    = 0;
+    enum CLOCK_REALTIME_HR = 4;
+    enum TIMER_ABSTIME     = 0x01;
+
+    alias int clockid_t;
+    alias int timer_t;
+
+    int clock_getres(int, timespec*);
+    int clock_gettime(int, timespec*);
+    int nanosleep(in timespec*, timespec*);
+    int timer_create(int, sigevent*, timer_t*);
+    int timer_delete(timer_t);
+    int timer_gettime(timer_t, itimerspec*);
+    int timer_getoverrun(timer_t);
+    int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// Thread-Safe Functions (TSF)
+//
+/*
+char* asctime_r(in tm*, char*);
+char* ctime_r(in time_t*, char*);
+tm*   gmtime_r(in time_t*, tm*);
+tm*   localtime_r(in time_t*, tm*);
+*/
+
+version( CRuntime_Glibc )
+{
+    char* asctime_r(in tm*, char*);
+    char* ctime_r(in time_t*, char*);
+    tm*   gmtime_r(in time_t*, tm*);
+    tm*   localtime_r(in time_t*, tm*);
+}
+else version( OSX )
+{
+    char* asctime_r(in tm*, char*);
+    char* ctime_r(in time_t*, char*);
+    tm*   gmtime_r(in time_t*, tm*);
+    tm*   localtime_r(in time_t*, tm*);
+}
+else version( FreeBSD )
+{
+    char* asctime_r(in tm*, char*);
+    char* ctime_r(in time_t*, char*);
+    tm*   gmtime_r(in time_t*, tm*);
+    tm*   localtime_r(in time_t*, tm*);
+}
+else version (Solaris)
+{
+    char* asctime_r(in tm*, char*);
+    char* ctime_r(in time_t*, char*);
+    tm* gmtime_r(in time_t*, tm*);
+    tm* localtime_r(in time_t*, tm*);
+}
+else version (CRuntime_Bionic)
+{
+    char* asctime_r(in tm*, char*);
+    char* ctime_r(in time_t*, char*);
+    tm* gmtime_r(in time_t*, tm*);
+    tm* localtime_r(in time_t*, tm*);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
+
+//
+// XOpen (XSI)
+//
+/*
+getdate_err
+
+int daylight;
+int timezone;
+
+tm* getdate(in char*);
+char* strptime(in char*, in char*, tm*);
+*/
+
+version( CRuntime_Glibc )
+{
+    extern __gshared int    daylight;
+    extern __gshared c_long timezone;
+
+    tm*   getdate(in char*);
+    char* strptime(in char*, in char*, tm*);
+}
+else version( OSX )
+{
+    extern __gshared c_long timezone;
+    extern __gshared int    daylight;
+
+    tm*   getdate(in char*);
+    char* strptime(in char*, in char*, tm*);
+}
+else version( FreeBSD )
+{
+    //tm*   getdate(in char*);
+    char* strptime(in char*, in char*, tm*);
+}
+else version (Solaris)
+{
+    extern __gshared c_long timezone, altzone;
+    extern __gshared int daylight;
+
+    tm* getdate(in char*);
+    char* __strptime_dontzero(in char*, in char*, tm*);
+    alias __strptime_dontzero strptime;
+}
+else version( CRuntime_Bionic )
+{
+    extern __gshared int    daylight;
+    extern __gshared c_long timezone;
+
+    char* strptime(in char*, in char*, tm*);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/ucontext.d b/libphobos/libdruntime/core/sys/posix/ucontext.d
new file mode 100644
index 00000000000..54e6cc095b8
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/ucontext.d
@@ -0,0 +1,823 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.ucontext;
+
+private import core.sys.posix.config;
+public import core.sys.posix.signal; // for sigset_t, stack_t
+private import core.stdc.stdint : uintptr_t;
+
+version (Posix):
+extern (C):
+nothrow:
+@nogc:
+
+//
+// XOpen (XSI)
+//
+/*
+mcontext_t
+
+struct ucontext_t
+{
+    ucontext_t* uc_link;
+    sigset_t    uc_sigmask;
+    stack_t     uc_stack;
+    mcontext_t  uc_mcontext;
+}
+*/
+
+version( CRuntime_Glibc )
+{
+
+    version( X86_64 )
+    {
+        enum
+        {
+            REG_R8 = 0,
+            REG_R9,
+            REG_R10,
+            REG_R11,
+            REG_R12,
+            REG_R13,
+            REG_R14,
+            REG_R15,
+            REG_RDI,
+            REG_RSI,
+            REG_RBP,
+            REG_RBX,
+            REG_RDX,
+            REG_RAX,
+            REG_RCX,
+            REG_RSP,
+            REG_RIP,
+            REG_EFL,
+            REG_CSGSFS,     /* Actually short cs, gs, fs, __pad0.  */
+            REG_ERR,
+            REG_TRAPNO,
+            REG_OLDMASK,
+            REG_CR2
+        }
+
+        private
+        {
+            struct _libc_fpxreg
+            {
+                ushort[4] significand;
+                ushort    exponent;
+                ushort[3] padding;
+            }
+
+            struct _libc_xmmreg
+            {
+                uint[4] element;
+            }
+
+            struct _libc_fpstate
+            {
+                ushort           cwd;
+                ushort           swd;
+                ushort           ftw;
+                ushort           fop;
+                ulong            rip;
+                ulong            rdp;
+                uint             mxcsr;
+                uint             mxcr_mask;
+                _libc_fpxreg[8]  _st;
+                _libc_xmmreg[16] _xmm;
+                uint[24]         padding;
+            }
+
+            enum NGREG = 23;
+
+            alias c_long            greg_t;
+            alias greg_t[NGREG]     gregset_t;
+            alias _libc_fpstate*    fpregset_t;
+        }
+
+        struct mcontext_t
+        {
+            gregset_t   gregs;
+            fpregset_t  fpregs;
+            c_ulong[8]  __reserved1;
+        }
+
+        struct ucontext_t
+        {
+            c_ulong         uc_flags;
+            ucontext_t*     uc_link;
+            stack_t         uc_stack;
+            mcontext_t      uc_mcontext;
+            sigset_t        uc_sigmask;
+            _libc_fpstate   __fpregs_mem;
+        }
+    }
+    else version( X86 )
+    {
+        enum
+        {
+            REG_GS = 0,
+            REG_FS,
+            REG_ES,
+            REG_DS,
+            REG_EDI,
+            REG_ESI,
+            REG_EBP,
+            REG_ESP,
+            REG_EBX,
+            REG_EDX,
+            REG_ECX,
+            REG_EAX,
+            REG_TRAPNO,
+            REG_ERR,
+            REG_EIP,
+            REG_CS,
+            REG_EFL,
+            REG_UESP,
+            REG_SS
+        }
+
+        private
+        {
+            struct _libc_fpreg
+            {
+              ushort[4] significand;
+              ushort    exponent;
+            }
+
+            struct _libc_fpstate
+            {
+              c_ulong           cw;
+              c_ulong           sw;
+              c_ulong           tag;
+              c_ulong           ipoff;
+              c_ulong           cssel;
+              c_ulong           dataoff;
+              c_ulong           datasel;
+              _libc_fpreg[8]    _st;
+              c_ulong           status;
+            }
+
+            enum NGREG = 19;
+
+            alias int               greg_t;
+            alias greg_t[NGREG]     gregset_t;
+            alias _libc_fpstate*    fpregset_t;
+        }
+
+        struct mcontext_t
+        {
+            gregset_t   gregs;
+            fpregset_t  fpregs;
+            c_ulong     oldmask;
+            c_ulong     cr2;
+        }
+
+        struct ucontext_t
+        {
+            c_ulong         uc_flags;
+            ucontext_t*     uc_link;
+            stack_t         uc_stack;
+            mcontext_t      uc_mcontext;
+            sigset_t        uc_sigmask;
+            _libc_fpstate   __fpregs_mem;
+        }
+    }
+    else version (MIPS32)
+    {
+        private
+        {
+            enum NGREG  = 32;
+            enum NFPREG = 32;
+
+            alias ulong         greg_t;
+            alias greg_t[NGREG] gregset_t;
+
+            struct fpregset_t
+            {
+                union fp_r_t
+                {
+                    double[NFPREG]  fp_dregs;
+                    static struct fp_fregs_t
+                    {
+                        float   _fp_fregs;
+                        uint    _fp_pad;
+                    } fp_fregs_t[NFPREG] fp_fregs;
+                } fp_r_t fp_r;
+            }
+        }
+
+        version (MIPS_O32)
+        {
+            struct mcontext_t
+            {
+                uint regmask;
+                uint status;
+                greg_t pc;
+                gregset_t gregs;
+                fpregset_t fpregs;
+                uint fp_owned;
+                uint fpc_csr;
+                uint fpc_eir;
+                uint used_math;
+                uint dsp;
+                greg_t mdhi;
+                greg_t mdlo;
+                c_ulong hi1;
+                c_ulong lo1;
+                c_ulong hi2;
+                c_ulong lo2;
+                c_ulong hi3;
+                c_ulong lo3;
+            }
+        }
+        else
+        {
+            struct mcontext_t
+            {
+                gregset_t gregs;
+                fpregset_t fpregs;
+                greg_t mdhi;
+                greg_t hi1;
+                greg_t hi2;
+                greg_t hi3;
+                greg_t mdlo;
+                greg_t lo1;
+                greg_t lo2;
+                greg_t lo3;
+                greg_t pc;
+                uint fpc_csr;
+                uint used_math;
+                uint dsp;
+                uint reserved;
+            }
+        }
+
+        struct ucontext_t
+        {
+            c_ulong     uc_flags;
+            ucontext_t* uc_link;
+            stack_t     uc_stack;
+            mcontext_t  uc_mcontext;
+            sigset_t    uc_sigmask;
+        }
+    }
+    else version (MIPS64)
+    {
+        private
+        {
+            enum NGREG  = 32;
+            enum NFPREG = 32;
+
+            alias ulong         greg_t;
+            alias greg_t[NGREG] gregset_t;
+
+            struct fpregset_t
+            {
+                union fp_r_t
+                {
+                    double[NFPREG]  fp_dregs;
+                    static struct fp_fregs_t
+                    {
+                        float   _fp_fregs;
+                        uint    _fp_pad;
+                    } fp_fregs_t[NFPREG] fp_fregs;
+                } fp_r_t fp_r;
+            }
+        }
+
+        struct mcontext_t
+        {
+            gregset_t gregs;
+            fpregset_t fpregs;
+            greg_t mdhi;
+            greg_t hi1;
+            greg_t hi2;
+            greg_t hi3;
+            greg_t mdlo;
+            greg_t lo1;
+            greg_t lo2;
+            greg_t lo3;
+            greg_t pc;
+            uint fpc_csr;
+            uint used_math;
+            uint dsp;
+            uint reserved;
+        }
+
+        struct ucontext_t
+        {
+            c_ulong     uc_flags;
+            ucontext_t* uc_link;
+            stack_t     uc_stack;
+            mcontext_t  uc_mcontext;
+            sigset_t    uc_sigmask;
+        }
+    }
+    else version (PPC)
+    {
+        private
+        {
+            enum NGREG  = 48;
+
+            alias c_ulong        greg_t;
+            alias greg_t[NGREG]  gregset_t;
+
+            struct fpregset_t
+            {
+                double[32] fpregs;
+                double fpscr;
+                uint[2] _pad;
+            }
+
+            struct vrregset_t
+            {
+                uint[32][4] vrregs;
+                uint        vrsave;
+                uint[2]     __pad;
+                uint vscr;
+            }
+
+            struct pt_regs
+            {
+                c_ulong[32] gpr;
+                c_ulong     nip;
+                c_ulong     msr;
+                c_ulong     orig_gpr3;
+                c_ulong     ctr;
+                c_ulong     link;
+                c_ulong     xer;
+                c_ulong     ccr;
+                c_ulong     mq;
+                c_ulong     trap;
+                c_ulong     dar;
+                c_ulong     dsisr;
+                c_ulong     result;
+            }
+        }
+
+        struct mcontext_t
+        {
+            gregset_t gregs;
+            fpregset_t fpregs;
+            align(16) vrregset_t vrregs;
+        }
+
+        struct ucontext_t
+        {
+            c_ulong     uc_flags;
+            ucontext_t* uc_link;
+            stack_t     uc_stack;
+            int[7]      uc_pad;
+            union uc_mcontext
+            {
+                pt_regs*     regs;
+                mcontext_t*  uc_regs;
+            }
+            sigset_t    uc_sigmask;
+            char[mcontext_t.sizeof + 12] uc_reg_space;
+        }
+    }
+    else version (PPC64)
+    {
+        private
+        {
+            enum NGREG  = 48;
+            enum NFPREG = 33;
+            enum NVRREG = 34;
+
+            alias c_ulong        greg_t;
+            alias greg_t[NGREG]  gregset_t;
+            alias double[NFPREG] fpregset_t;
+
+            struct vscr_t
+            {
+                uint[3] __pad;
+                uint    vscr_word;
+            }
+
+            struct vrregset_t
+            {
+                uint[32][4] vrregs;
+                vscr_t      vscr;
+                uint        vrsave;
+                uint[3]     __pad;
+            }
+
+            struct pt_regs
+            {
+                c_ulong[32] gpr;
+                c_ulong     nip;
+                c_ulong     msr;
+                c_ulong     orig_gpr3;
+                c_ulong     ctr;
+                c_ulong     link;
+                c_ulong     xer;
+                c_ulong     ccr;
+                c_ulong     softe;
+                c_ulong     trap;
+                c_ulong     dar;
+                c_ulong     dsisr;
+                c_ulong     result;
+            }
+        }
+
+        struct mcontext_t
+        {
+            c_ulong[4] __unused;
+            int signal;
+            int __pad0;
+            c_ulong handler;
+            c_ulong oldmask;
+            pt_regs* regs;
+            gregset_t gp_regs;
+            fpregset_t fp_regs;
+            vrregset_t *v_regs;
+            c_long[NVRREG+NVRREG+1] vmx_reserve;
+        }
+
+        struct ucontext_t
+        {
+            c_ulong     uc_flags;
+            ucontext_t* uc_link;
+            stack_t     uc_stack;
+            sigset_t    uc_sigmask;
+            mcontext_t  uc_mcontext;
+        }
+    }
+    else version(ARM)
+    {
+        enum
+        {
+            R0 = 0,
+            R1 = 1,
+            R2 = 2,
+            R3 = 3,
+            R4 = 4,
+            R5 = 5,
+            R6 = 6,
+            R7 = 7,
+            R8 = 8,
+            R9 = 9,
+            R10 = 10,
+            R11 = 11,
+            R12 = 12,
+            R13 = 13,
+            R14 = 14,
+            R15 = 15
+        }
+
+        struct sigcontext
+        {
+            c_ulong trap_no;
+            c_ulong error_code;
+            c_ulong oldmask;
+            c_ulong arm_r0;
+            c_ulong arm_r1;
+            c_ulong arm_r2;
+            c_ulong arm_r3;
+            c_ulong arm_r4;
+            c_ulong arm_r5;
+            c_ulong arm_r6;
+            c_ulong arm_r7;
+            c_ulong arm_r8;
+            c_ulong arm_r9;
+            c_ulong arm_r10;
+            c_ulong arm_fp;
+            c_ulong arm_ip;
+            c_ulong arm_sp;
+            c_ulong arm_lr;
+            c_ulong arm_pc;
+            c_ulong arm_cpsr;
+            c_ulong fault_address;
+        }
+
+        //alias elf_fpregset_t fpregset_t;
+        alias sigcontext mcontext_t;
+
+        struct ucontext_t
+        {
+            c_ulong uc_flags;
+            ucontext_t* uc_link;
+            stack_t uc_stack;
+            mcontext_t uc_mcontext;
+            sigset_t uc_sigmask;
+            align(8) c_ulong[128] uc_regspace;
+        }
+    }
+    else version (AArch64)
+    {
+        alias int greg_t;
+
+        struct sigcontext {
+            ulong           fault_address;
+            /* AArch64 registers */
+            ulong[31]       regs;
+            ulong           sp;
+            ulong           pc;
+            ulong           pstate;
+            /* 4K reserved for FP/SIMD state and future expansion */
+            align(16) ubyte[4096] __reserved;
+        }
+
+        alias sigcontext mcontext_t;
+
+        struct ucontext_t
+        {
+            c_ulong     uc_flags;
+            ucontext_t* uc_link;
+            stack_t     uc_stack;
+            sigset_t    uc_sigmask;
+            mcontext_t  uc_mcontext;
+        }
+    }
+    else version (SystemZ)
+    {
+        public import core.sys.posix.signal : sigset_t;
+
+        enum NGREG = 27;
+
+        alias greg_t = c_ulong;
+        alias gregset_t = align(8) greg_t[NGREG];
+
+        align(8) struct __psw_t
+        {
+            c_ulong mask;
+            c_ulong addr;
+        }
+
+        union fpreg_t
+        {
+            double d;
+            float  f;
+        }
+
+        struct fpregset_t
+        {
+            uint        fpc;
+            fpreg_t[16] fprs;
+        }
+
+        struct  mcontext_t
+        {
+            __psw_t     psw;
+            c_ulong[16] gregs;
+            uint[16]    aregs;
+            fpregset_t  fpregs;
+        }
+
+        struct ucontext
+        {
+            c_ulong    uc_flags;
+            ucontext*  uc_link;
+            stack_t    uc_stack;
+            mcontext_t uc_mcontext;
+            sigset_t   uc_sigmask;
+        }
+
+        alias ucontext_t = ucontext;
+    }
+    else
+        static assert(0, "unimplemented");
+}
+else version( FreeBSD )
+{
+    // <machine/ucontext.h>
+    version( X86_64 )
+    {
+      alias long __register_t;
+      alias uint __uint32_t;
+      alias ushort __uint16_t;
+
+      struct mcontext_t {
+       __register_t    mc_onstack;
+       __register_t    mc_rdi;
+       __register_t    mc_rsi;
+       __register_t    mc_rdx;
+       __register_t    mc_rcx;
+       __register_t    mc_r8;
+       __register_t    mc_r9;
+       __register_t    mc_rax;
+       __register_t    mc_rbx;
+       __register_t    mc_rbp;
+       __register_t    mc_r10;
+       __register_t    mc_r11;
+       __register_t    mc_r12;
+       __register_t    mc_r13;
+       __register_t    mc_r14;
+       __register_t    mc_r15;
+       __uint32_t      mc_trapno;
+       __uint16_t      mc_fs;
+       __uint16_t      mc_gs;
+       __register_t    mc_addr;
+       __uint32_t      mc_flags;
+       __uint16_t      mc_es;
+       __uint16_t      mc_ds;
+       __register_t    mc_err;
+       __register_t    mc_rip;
+       __register_t    mc_cs;
+       __register_t    mc_rflags;
+       __register_t    mc_rsp;
+       __register_t    mc_ss;
+
+       long    mc_len;                 /* sizeof(mcontext_t) */
+
+       long    mc_fpformat;
+       long    mc_ownedfp;
+
+       align(16)
+       long[64]    mc_fpstate;
+
+       __register_t    mc_fsbase;
+       __register_t    mc_gsbase;
+
+       long[6]    mc_spare;
+      }
+    }
+    else version( X86 )
+    {
+        alias int __register_t;
+
+        struct mcontext_t
+        {
+            __register_t    mc_onstack;
+            __register_t    mc_gs;
+            __register_t    mc_fs;
+            __register_t    mc_es;
+            __register_t    mc_ds;
+            __register_t    mc_edi;
+            __register_t    mc_esi;
+            __register_t    mc_ebp;
+            __register_t    mc_isp;
+            __register_t    mc_ebx;
+            __register_t    mc_edx;
+            __register_t    mc_ecx;
+            __register_t    mc_eax;
+            __register_t    mc_trapno;
+            __register_t    mc_err;
+            __register_t    mc_eip;
+            __register_t    mc_cs;
+            __register_t    mc_eflags;
+            __register_t    mc_esp;
+            __register_t    mc_ss;
+
+            int             mc_len;
+            int             mc_fpformat;
+            int             mc_ownedfp;
+            int[1]          mc_spare1;
+
+            align(16)
+            int[128]        mc_fpstate;
+
+            __register_t    mc_fsbase;
+            __register_t    mc_gsbase;
+
+            int[6]          mc_spare2;
+        }
+    }
+
+    // <ucontext.h>
+    enum UCF_SWAPPED = 0x00000001;
+
+    struct ucontext_t
+    {
+        sigset_t        uc_sigmask;
+        mcontext_t      uc_mcontext;
+
+        ucontext_t*     uc_link;
+        stack_t         uc_stack;
+        int             uc_flags;
+        int[4]          __spare__;
+    }
+}
+else version ( Solaris )
+{
+    alias uint[4] upad128_t;
+
+    version ( X86_64 )
+    {
+        enum _NGREG = 28;
+        alias long greg_t;
+    }
+    else version ( X86 )
+    {
+        enum _NGREG = 19;
+        alias int greg_t;
+    }
+
+    alias greg_t[_NGREG] gregset_t;
+
+    version ( X86_64 )
+    {
+        union _u_st
+        {
+            ushort[5]   fpr_16;
+            upad128_t   __fpr_pad;
+        }
+
+        struct fpregset_t
+        {
+            union fp_reg_set
+            {
+                struct fpchip_state
+                {
+                    ushort          cw;
+                    ushort          sw;
+                    ubyte           fctw;
+                    ubyte           __fx_rsvd;
+                    ushort          fop;
+                    ulong           rip;
+                    ulong           rdp;
+                    uint            mxcsr;
+                    uint            mxcsr_mask;
+                    _u_st[8]        st;
+                    upad128_t[16]   xmm;
+                    upad128_t[6]    __fx_ign2;
+                    uint            status;
+                    uint            xstatus;
+                }
+                uint[130]   f_fpregs;
+            }
+        }
+    }
+    else version ( X86 )
+    {
+        struct fpregset_t
+        {
+            union u_fp_reg_set
+            {
+                struct s_fpchip_state
+                {
+                    uint[27]        state;
+                    uint            status;
+                    uint            mxcsr;
+                    uint            xstatus;
+                    uint[2]         __pad;
+                    upad128_t[8]    xmm;
+                }
+                s_fpchip_state    fpchip_state;
+
+                struct s_fp_emul_space
+                {
+                    ubyte[246]  fp_emul;
+                    ubyte[2]    fp_epad;
+                }
+                s_fp_emul_space   fp_emul_space;
+                uint[95]        f_fpregs;
+            }
+        u_fp_reg_set fp_reg_set;
+        }
+    }
+    struct mcontext_t
+    {
+        gregset_t   gregs;
+        fpregset_t  fpregs;
+    }
+
+    struct ucontext_t
+    {
+        c_ulong      uc_flags;
+        ucontext_t  *uc_link;
+        sigset_t    uc_sigmask;
+        stack_t     uc_stack;
+        mcontext_t  uc_mcontext;
+        c_long[5]   uc_filler;
+    }
+}
+
+//
+// Obsolescent (OB)
+//
+/*
+int  getcontext(ucontext_t*);
+void makecontext(ucontext_t*, void function(), int, ...);
+int  setcontext(in ucontext_t*);
+int  swapcontext(ucontext_t*, in ucontext_t*);
+*/
+
+static if( is( ucontext_t ) )
+{
+    int  getcontext(ucontext_t*);
+    void makecontext(ucontext_t*, void function(), int, ...);
+    int  setcontext(in ucontext_t*);
+    int  swapcontext(ucontext_t*, in ucontext_t*);
+}
+
+version (Solaris)
+{
+    int walkcontext(in ucontext_t*, int function(uintptr_t, int, void*), void*);
+    int addrtosymstr(uintptr_t, char*, int);
+    int printstack(int);
+}
+
diff --git a/libphobos/libdruntime/core/sys/posix/unistd.d b/libphobos/libdruntime/core/sys/posix/unistd.d
new file mode 100644
index 00000000000..ab445db318d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/unistd.d
@@ -0,0 +1,1338 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.unistd;
+
+private import core.sys.posix.config;
+private import core.stdc.stddef;
+public import core.sys.posix.inttypes;  // for intptr_t
+public import core.sys.posix.sys.types; // for ssize_t, uid_t, gid_t, off_t, pid_t, useconds_t
+
+version (Posix):
+extern (C):
+nothrow:
+@nogc:
+
+enum STDIN_FILENO  = 0;
+enum STDOUT_FILENO = 1;
+enum STDERR_FILENO = 2;
+
+extern __gshared char*   optarg;
+extern __gshared int     optind;
+extern __gshared int     opterr;
+extern __gshared int     optopt;
+
+int     access(in char*, int);
+uint    alarm(uint) @trusted;
+int     chdir(in char*);
+int     chown(in char*, uid_t, gid_t);
+int     close(int) @trusted;
+size_t  confstr(int, char*, size_t);
+int     dup(int) @trusted;
+int     dup2(int, int) @trusted;
+int     execl(in char*, in char*, ...);
+int     execle(in char*, in char*, ...);
+int     execlp(in char*, in char*, ...);
+int     execv(in char*, in char**);
+int     execve(in char*, in char**, in char**);
+int     execvp(in char*, in char**);
+void    _exit(int) @trusted;
+int     fchown(int, uid_t, gid_t) @trusted;
+pid_t   fork() @trusted;
+c_long  fpathconf(int, int) @trusted;
+//int     ftruncate(int, off_t);
+char*   getcwd(char*, size_t);
+gid_t   getegid() @trusted;
+uid_t   geteuid() @trusted;
+gid_t   getgid() @trusted;
+int     getgroups(int, gid_t *);
+int     gethostname(char*, size_t);
+char*   getlogin() @trusted;
+int     getlogin_r(char*, size_t);
+int     getopt(int, in char**, in char*);
+pid_t   getpgrp() @trusted;
+pid_t   getpid() @trusted;
+pid_t   getppid() @trusted;
+uid_t   getuid() @trusted;
+int     isatty(int) @trusted;
+int     link(in char*, in char*);
+//off_t   lseek(int, off_t, int);
+c_long  pathconf(in char*, int);
+int     pause() @trusted;
+int     pipe(ref int[2]) @trusted;
+ssize_t read(int, void*, size_t);
+ssize_t readlink(in char*, char*, size_t);
+int     rmdir(in char*);
+int     setegid(gid_t) @trusted;
+int     seteuid(uid_t) @trusted;
+int     setgid(gid_t) @trusted;
+int     setpgid(pid_t, pid_t) @trusted;
+pid_t   setsid() @trusted;
+int     setuid(uid_t) @trusted;
+uint    sleep(uint) @trusted;
+int     symlink(in char*, in char*);
+c_long  sysconf(int) @trusted;
+pid_t   tcgetpgrp(int) @trusted;
+int     tcsetpgrp(int, pid_t) @trusted;
+char*   ttyname(int) @trusted;
+int     ttyname_r(int, char*, size_t);
+int     unlink(in char*);
+ssize_t write(int, in void*, size_t);
+
+version( CRuntime_Glibc )
+{
+  static if( __USE_FILE_OFFSET64 )
+  {
+    off_t lseek64(int, off_t, int) @trusted;
+    alias lseek64 lseek;
+  }
+  else
+  {
+    off_t lseek(int, off_t, int) @trusted;
+  }
+  static if( __USE_LARGEFILE64 )
+  {
+    int   ftruncate64(int, off_t) @trusted;
+    alias ftruncate64 ftruncate;
+  }
+  else
+  {
+    int   ftruncate(int, off_t) @trusted;
+  }
+}
+else version( FreeBSD )
+{
+    off_t lseek(int, off_t, int) @trusted;
+    int   ftruncate(int, off_t) @trusted;
+}
+else version( Solaris )
+{
+    version ( D_LP64 )
+    {
+        off_t   lseek(int, off_t, int) @trusted;
+        alias   lseek lseek64;
+
+        int     ftruncate(int, off_t) @trusted;
+        alias   ftruncate ftruncate64;
+    }
+    else
+    {
+        static if( __USE_LARGEFILE64 )
+        {
+            off64_t lseek64(int, off64_t, int) @trusted;
+            alias   lseek64 lseek;
+
+            int     ftruncate64(int, off64_t) @trusted;
+            alias   ftruncate64 ftruncate;
+        }
+        else
+        {
+            off_t   lseek(int, off_t, int) @trusted;
+            int     ftruncate(int, off_t) @trusted;
+        }
+    }
+}
+else version( OSX )
+{
+    off_t lseek(int, off_t, int) @trusted;
+    int   ftruncate(int, off_t) @trusted;
+}
+else version( CRuntime_Bionic )
+{
+    off_t lseek(int, off_t, int) @trusted;
+    int   ftruncate(int, off_t) @trusted;
+}
+
+version( CRuntime_Glibc )
+{
+    enum F_OK       = 0;
+    enum R_OK       = 4;
+    enum W_OK       = 2;
+    enum X_OK       = 1;
+
+    enum F_ULOCK    = 0;
+    enum F_LOCK     = 1;
+    enum F_TLOCK    = 2;
+    enum F_TEST     = 3;
+
+    enum
+    {
+        _CS_PATH,
+
+        _CS_V6_WIDTH_RESTRICTED_ENVS,
+
+        _CS_GNU_LIBC_VERSION,
+        _CS_GNU_LIBPTHREAD_VERSION,
+
+        _CS_LFS_CFLAGS = 1000,
+        _CS_LFS_LDFLAGS,
+        _CS_LFS_LIBS,
+        _CS_LFS_LINTFLAGS,
+        _CS_LFS64_CFLAGS,
+        _CS_LFS64_LDFLAGS,
+        _CS_LFS64_LIBS,
+        _CS_LFS64_LINTFLAGS,
+
+        _CS_XBS5_ILP32_OFF32_CFLAGS = 1100,
+        _CS_XBS5_ILP32_OFF32_LDFLAGS,
+        _CS_XBS5_ILP32_OFF32_LIBS,
+        _CS_XBS5_ILP32_OFF32_LINTFLAGS,
+        _CS_XBS5_ILP32_OFFBIG_CFLAGS,
+        _CS_XBS5_ILP32_OFFBIG_LDFLAGS,
+        _CS_XBS5_ILP32_OFFBIG_LIBS,
+        _CS_XBS5_ILP32_OFFBIG_LINTFLAGS,
+        _CS_XBS5_LP64_OFF64_CFLAGS,
+        _CS_XBS5_LP64_OFF64_LDFLAGS,
+        _CS_XBS5_LP64_OFF64_LIBS,
+        _CS_XBS5_LP64_OFF64_LINTFLAGS,
+        _CS_XBS5_LPBIG_OFFBIG_CFLAGS,
+        _CS_XBS5_LPBIG_OFFBIG_LDFLAGS,
+        _CS_XBS5_LPBIG_OFFBIG_LIBS,
+        _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,
+
+        _CS_POSIX_V6_ILP32_OFF32_CFLAGS,
+        _CS_POSIX_V6_ILP32_OFF32_LDFLAGS,
+        _CS_POSIX_V6_ILP32_OFF32_LIBS,
+        _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,
+        _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,
+        _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,
+        _CS_POSIX_V6_ILP32_OFFBIG_LIBS,
+        _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,
+        _CS_POSIX_V6_LP64_OFF64_CFLAGS,
+        _CS_POSIX_V6_LP64_OFF64_LDFLAGS,
+        _CS_POSIX_V6_LP64_OFF64_LIBS,
+        _CS_POSIX_V6_LP64_OFF64_LINTFLAGS,
+        _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,
+        _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,
+        _CS_POSIX_V6_LPBIG_OFFBIG_LIBS,
+        _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
+    }
+
+    enum
+    {
+        _PC_LINK_MAX,
+        _PC_MAX_CANON,
+        _PC_MAX_INPUT,
+        _PC_NAME_MAX,
+        _PC_PATH_MAX,
+        _PC_PIPE_BUF,
+        _PC_CHOWN_RESTRICTED,
+        _PC_NO_TRUNC,
+        _PC_VDISABLE,
+        _PC_SYNC_IO,
+        _PC_ASYNC_IO,
+        _PC_PRIO_IO,
+        _PC_SOCK_MAXBUF,
+        _PC_FILESIZEBITS,
+        _PC_REC_INCR_XFER_SIZE,
+        _PC_REC_MAX_XFER_SIZE,
+        _PC_REC_MIN_XFER_SIZE,
+        _PC_REC_XFER_ALIGN,
+        _PC_ALLOC_SIZE_MIN,
+        _PC_SYMLINK_MAX,
+        _PC_2_SYMLINKS
+    }
+
+    enum
+    {
+        _SC_ARG_MAX,
+        _SC_CHILD_MAX,
+        _SC_CLK_TCK,
+        _SC_NGROUPS_MAX,
+        _SC_OPEN_MAX,
+        _SC_STREAM_MAX,
+        _SC_TZNAME_MAX,
+        _SC_JOB_CONTROL,
+        _SC_SAVED_IDS,
+        _SC_REALTIME_SIGNALS,
+        _SC_PRIORITY_SCHEDULING,
+        _SC_TIMERS,
+        _SC_ASYNCHRONOUS_IO,
+        _SC_PRIORITIZED_IO,
+        _SC_SYNCHRONIZED_IO,
+        _SC_FSYNC,
+        _SC_MAPPED_FILES,
+        _SC_MEMLOCK,
+        _SC_MEMLOCK_RANGE,
+        _SC_MEMORY_PROTECTION,
+        _SC_MESSAGE_PASSING,
+        _SC_SEMAPHORES,
+        _SC_SHARED_MEMORY_OBJECTS,
+        _SC_AIO_LISTIO_MAX,
+        _SC_AIO_MAX,
+        _SC_AIO_PRIO_DELTA_MAX,
+        _SC_DELAYTIMER_MAX,
+        _SC_MQ_OPEN_MAX,
+        _SC_MQ_PRIO_MAX,
+        _SC_VERSION,
+        _SC_PAGESIZE,
+        _SC_PAGE_SIZE = _SC_PAGESIZE,
+        _SC_RTSIG_MAX,
+        _SC_SEM_NSEMS_MAX,
+        _SC_SEM_VALUE_MAX,
+        _SC_SIGQUEUE_MAX,
+        _SC_TIMER_MAX,
+
+        _SC_BC_BASE_MAX,
+        _SC_BC_DIM_MAX,
+        _SC_BC_SCALE_MAX,
+        _SC_BC_STRING_MAX,
+        _SC_COLL_WEIGHTS_MAX,
+        _SC_EQUIV_CLASS_MAX,
+        _SC_EXPR_NEST_MAX,
+        _SC_LINE_MAX,
+        _SC_RE_DUP_MAX,
+        _SC_CHARCLASS_NAME_MAX,
+
+        _SC_2_VERSION,
+        _SC_2_C_BIND,
+        _SC_2_C_DEV,
+        _SC_2_FORT_DEV,
+        _SC_2_FORT_RUN,
+        _SC_2_SW_DEV,
+        _SC_2_LOCALEDEF,
+
+        _SC_PII,
+        _SC_PII_XTI,
+        _SC_PII_SOCKET,
+        _SC_PII_INTERNET,
+        _SC_PII_OSI,
+        _SC_POLL,
+        _SC_SELECT,
+        _SC_UIO_MAXIOV,
+        _SC_IOV_MAX = _SC_UIO_MAXIOV,
+        _SC_PII_INTERNET_STREAM,
+        _SC_PII_INTERNET_DGRAM,
+        _SC_PII_OSI_COTS,
+        _SC_PII_OSI_CLTS,
+        _SC_PII_OSI_M,
+        _SC_T_IOV_MAX,
+
+        _SC_THREADS,
+        _SC_THREAD_SAFE_FUNCTIONS,
+        _SC_GETGR_R_SIZE_MAX,
+        _SC_GETPW_R_SIZE_MAX,
+        _SC_LOGIN_NAME_MAX,
+        _SC_TTY_NAME_MAX,
+        _SC_THREAD_DESTRUCTOR_ITERATIONS,
+        _SC_THREAD_KEYS_MAX,
+        _SC_THREAD_STACK_MIN,
+        _SC_THREAD_THREADS_MAX,
+        _SC_THREAD_ATTR_STACKADDR,
+        _SC_THREAD_ATTR_STACKSIZE,
+        _SC_THREAD_PRIORITY_SCHEDULING,
+        _SC_THREAD_PRIO_INHERIT,
+        _SC_THREAD_PRIO_PROTECT,
+        _SC_THREAD_PROCESS_SHARED,
+
+        _SC_NPROCESSORS_CONF,
+        _SC_NPROCESSORS_ONLN,
+        _SC_PHYS_PAGES,
+        _SC_AVPHYS_PAGES,
+        _SC_ATEXIT_MAX,
+        _SC_PASS_MAX,
+
+        _SC_XOPEN_VERSION,
+        _SC_XOPEN_XCU_VERSION,
+        _SC_XOPEN_UNIX,
+        _SC_XOPEN_CRYPT,
+        _SC_XOPEN_ENH_I18N,
+        _SC_XOPEN_SHM,
+
+        _SC_2_CHAR_TERM,
+        _SC_2_C_VERSION,
+        _SC_2_UPE,
+
+        _SC_XOPEN_XPG2,
+        _SC_XOPEN_XPG3,
+        _SC_XOPEN_XPG4,
+
+        _SC_CHAR_BIT,
+        _SC_CHAR_MAX,
+        _SC_CHAR_MIN,
+        _SC_INT_MAX,
+        _SC_INT_MIN,
+        _SC_LONG_BIT,
+        _SC_WORD_BIT,
+        _SC_MB_LEN_MAX,
+        _SC_NZERO,
+        _SC_SSIZE_MAX,
+        _SC_SCHAR_MAX,
+        _SC_SCHAR_MIN,
+        _SC_SHRT_MAX,
+        _SC_SHRT_MIN,
+        _SC_UCHAR_MAX,
+        _SC_UINT_MAX,
+        _SC_ULONG_MAX,
+        _SC_USHRT_MAX,
+
+        _SC_NL_ARGMAX,
+        _SC_NL_LANGMAX,
+        _SC_NL_MSGMAX,
+        _SC_NL_NMAX,
+        _SC_NL_SETMAX,
+        _SC_NL_TEXTMAX,
+
+        _SC_XBS5_ILP32_OFF32,
+        _SC_XBS5_ILP32_OFFBIG,
+        _SC_XBS5_LP64_OFF64,
+        _SC_XBS5_LPBIG_OFFBIG,
+
+        _SC_XOPEN_LEGACY,
+        _SC_XOPEN_REALTIME,
+        _SC_XOPEN_REALTIME_THREADS,
+
+        _SC_ADVISORY_INFO,
+        _SC_BARRIERS,
+        _SC_BASE,
+        _SC_C_LANG_SUPPORT,
+        _SC_C_LANG_SUPPORT_R,
+        _SC_CLOCK_SELECTION,
+        _SC_CPUTIME,
+        _SC_THREAD_CPUTIME,
+        _SC_DEVICE_IO,
+        _SC_DEVICE_SPECIFIC,
+        _SC_DEVICE_SPECIFIC_R,
+        _SC_FD_MGMT,
+        _SC_FIFO,
+        _SC_PIPE,
+        _SC_FILE_ATTRIBUTES,
+        _SC_FILE_LOCKING,
+        _SC_FILE_SYSTEM,
+        _SC_MONOTONIC_CLOCK,
+        _SC_MULTI_PROCESS,
+        _SC_SINGLE_PROCESS,
+        _SC_NETWORKING,
+        _SC_READER_WRITER_LOCKS,
+        _SC_SPIN_LOCKS,
+        _SC_REGEXP,
+        _SC_REGEX_VERSION,
+        _SC_SHELL,
+        _SC_SIGNALS,
+        _SC_SPAWN,
+        _SC_SPORADIC_SERVER,
+        _SC_THREAD_SPORADIC_SERVER,
+        _SC_SYSTEM_DATABASE,
+        _SC_SYSTEM_DATABASE_R,
+        _SC_TIMEOUTS,
+        _SC_TYPED_MEMORY_OBJECTS,
+        _SC_USER_GROUPS,
+        _SC_USER_GROUPS_R,
+        _SC_2_PBS,
+        _SC_2_PBS_ACCOUNTING,
+        _SC_2_PBS_LOCATE,
+        _SC_2_PBS_MESSAGE,
+        _SC_2_PBS_TRACK,
+        _SC_SYMLOOP_MAX,
+        _SC_STREAMS,
+        _SC_2_PBS_CHECKPOINT,
+
+        _SC_V6_ILP32_OFF32,
+        _SC_V6_ILP32_OFFBIG,
+        _SC_V6_LP64_OFF64,
+        _SC_V6_LPBIG_OFFBIG,
+
+        _SC_HOST_NAME_MAX,
+        _SC_TRACE,
+        _SC_TRACE_EVENT_FILTER,
+        _SC_TRACE_INHERIT,
+        _SC_TRACE_LOG,
+
+        _SC_LEVEL1_ICACHE_SIZE,
+        _SC_LEVEL1_ICACHE_ASSOC,
+        _SC_LEVEL1_ICACHE_LINESIZE,
+        _SC_LEVEL1_DCACHE_SIZE,
+        _SC_LEVEL1_DCACHE_ASSOC,
+        _SC_LEVEL1_DCACHE_LINESIZE,
+        _SC_LEVEL2_CACHE_SIZE,
+        _SC_LEVEL2_CACHE_ASSOC,
+        _SC_LEVEL2_CACHE_LINESIZE,
+        _SC_LEVEL3_CACHE_SIZE,
+        _SC_LEVEL3_CACHE_ASSOC,
+        _SC_LEVEL3_CACHE_LINESIZE,
+        _SC_LEVEL4_CACHE_SIZE,
+        _SC_LEVEL4_CACHE_ASSOC,
+        _SC_LEVEL4_CACHE_LINESIZE,
+
+        _SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,
+        _SC_RAW_SOCKETS
+    }
+}
+else version( OSX )
+{
+    enum F_OK       = 0;
+    enum R_OK       = 4;
+    enum W_OK       = 2;
+    enum X_OK       = 1;
+
+    enum F_ULOCK    = 0;
+    enum F_LOCK     = 1;
+    enum F_TLOCK    = 2;
+    enum F_TEST     = 3;
+
+    enum
+    {
+        _SC_ARG_MAX                      =   1,
+        _SC_CHILD_MAX                    =   2,
+        _SC_CLK_TCK                      =   3,
+        _SC_NGROUPS_MAX                  =   4,
+        _SC_OPEN_MAX                     =   5,
+        _SC_JOB_CONTROL                  =   6,
+        _SC_SAVED_IDS                    =   7,
+        _SC_VERSION                      =   8,
+        _SC_BC_BASE_MAX                  =   9,
+        _SC_BC_DIM_MAX                   =  10,
+        _SC_BC_SCALE_MAX                 =  11,
+        _SC_BC_STRING_MAX                =  12,
+        _SC_COLL_WEIGHTS_MAX             =  13,
+        _SC_EXPR_NEST_MAX                =  14,
+        _SC_LINE_MAX                     =  15,
+        _SC_RE_DUP_MAX                   =  16,
+        _SC_2_VERSION                    =  17,
+        _SC_2_C_BIND                     =  18,
+        _SC_2_C_DEV                      =  19,
+        _SC_2_CHAR_TERM                  =  20,
+        _SC_2_FORT_DEV                   =  21,
+        _SC_2_FORT_RUN                   =  22,
+        _SC_2_LOCALEDEF                  =  23,
+        _SC_2_SW_DEV                     =  24,
+        _SC_2_UPE                        =  25,
+        _SC_STREAM_MAX                   =  26,
+        _SC_TZNAME_MAX                   =  27,
+        _SC_ASYNCHRONOUS_IO              =  28,
+        _SC_PAGESIZE                     =  29,
+        _SC_MEMLOCK                      =  30,
+        _SC_MEMLOCK_RANGE                =  31,
+        _SC_MEMORY_PROTECTION            =  32,
+        _SC_MESSAGE_PASSING              =  33,
+        _SC_PRIORITIZED_IO               =  34,
+        _SC_PRIORITY_SCHEDULING          =  35,
+        _SC_REALTIME_SIGNALS             =  36,
+        _SC_SEMAPHORES                   =  37,
+        _SC_FSYNC                        =  38,
+        _SC_SHARED_MEMORY_OBJECTS        =  39,
+        _SC_SYNCHRONIZED_IO              =  40,
+        _SC_TIMERS                       =  41,
+        _SC_AIO_LISTIO_MAX               =  42,
+        _SC_AIO_MAX                      =  43,
+        _SC_AIO_PRIO_DELTA_MAX           =  44,
+        _SC_DELAYTIMER_MAX               =  45,
+        _SC_MQ_OPEN_MAX                  =  46,
+        _SC_MAPPED_FILES                 =  47,
+        _SC_RTSIG_MAX                    =  48,
+        _SC_SEM_NSEMS_MAX                =  49,
+        _SC_SEM_VALUE_MAX                =  50,
+        _SC_SIGQUEUE_MAX                 =  51,
+        _SC_TIMER_MAX                    =  52,
+        _SC_IOV_MAX                      =  56,
+        _SC_NPROCESSORS_CONF             =  57,
+        _SC_NPROCESSORS_ONLN             =  58,
+        _SC_2_PBS                        =  59,
+        _SC_2_PBS_ACCOUNTING             =  60,
+        _SC_2_PBS_CHECKPOINT             =  61,
+        _SC_2_PBS_LOCATE                 =  62,
+        _SC_2_PBS_MESSAGE                =  63,
+        _SC_2_PBS_TRACK                  =  64,
+        _SC_ADVISORY_INFO                =  65,
+        _SC_BARRIERS                     =  66,
+        _SC_CLOCK_SELECTION              =  67,
+        _SC_CPUTIME                      =  68,
+        _SC_FILE_LOCKING                 =  69,
+        _SC_GETGR_R_SIZE_MAX             =  70,
+        _SC_GETPW_R_SIZE_MAX             =  71,
+        _SC_HOST_NAME_MAX                =  72,
+        _SC_LOGIN_NAME_MAX               =  73,
+        _SC_MONOTONIC_CLOCK              =  74,
+        _SC_MQ_PRIO_MAX                  =  75,
+        _SC_READER_WRITER_LOCKS          =  76,
+        _SC_REGEXP                       =  77,
+        _SC_SHELL                        =  78,
+        _SC_SPAWN                        =  79,
+        _SC_SPIN_LOCKS                   =  80,
+        _SC_SPORADIC_SERVER              =  81,
+        _SC_THREAD_ATTR_STACKADDR        =  82,
+        _SC_THREAD_ATTR_STACKSIZE        =  83,
+        _SC_THREAD_CPUTIME               =  84,
+        _SC_THREAD_DESTRUCTOR_ITERATIONS =  85,
+        _SC_THREAD_KEYS_MAX              =  86,
+        _SC_THREAD_PRIO_INHERIT          =  87,
+        _SC_THREAD_PRIO_PROTECT          =  88,
+        _SC_THREAD_PRIORITY_SCHEDULING   =  89,
+        _SC_THREAD_PROCESS_SHARED        =  90,
+        _SC_THREAD_SAFE_FUNCTIONS        =  91,
+        _SC_THREAD_SPORADIC_SERVER       =  92,
+        _SC_THREAD_STACK_MIN             =  93,
+        _SC_THREAD_THREADS_MAX           =  94,
+        _SC_TIMEOUTS                     =  95,
+        _SC_THREADS                      =  96,
+        _SC_TRACE                        =  97,
+        _SC_TRACE_EVENT_FILTER           =  98,
+        _SC_TRACE_INHERIT                =  99,
+        _SC_TRACE_LOG                    = 100,
+        _SC_TTY_NAME_MAX                 = 101,
+        _SC_TYPED_MEMORY_OBJECTS         = 102,
+        _SC_V6_ILP32_OFF32               = 103,
+        _SC_V6_ILP32_OFFBIG              = 104,
+        _SC_V6_LP64_OFF64                = 105,
+        _SC_V6_LPBIG_OFFBIG              = 106,
+        _SC_ATEXIT_MAX                   = 107,
+        _SC_XOPEN_CRYPT                  = 108,
+        _SC_XOPEN_ENH_I18N               = 109,
+        _SC_XOPEN_LEGACY                 = 110,
+        _SC_XOPEN_REALTIME               = 111,
+        _SC_XOPEN_REALTIME_THREADS       = 112,
+        _SC_XOPEN_SHM                    = 113,
+        _SC_XOPEN_STREAMS                = 114,
+        _SC_XOPEN_UNIX                   = 115,
+        _SC_XOPEN_VERSION                = 116,
+        _SC_IPV6                         = 118,
+        _SC_RAW_SOCKETS                  = 119,
+        _SC_SYMLOOP_MAX                  = 120,
+        _SC_XOPEN_XCU_VERSION            = 121,
+        _SC_XBS5_ILP32_OFF32             = 122,
+        _SC_XBS5_ILP32_OFFBIG            = 123,
+        _SC_XBS5_LP64_OFF64              = 124,
+        _SC_XBS5_LPBIG_OFFBIG            = 125,
+        _SC_SS_REPL_MAX                  = 126,
+        _SC_TRACE_EVENT_NAME_MAX         = 127,
+        _SC_TRACE_NAME_MAX               = 128,
+        _SC_TRACE_SYS_MAX                = 129,
+        _SC_TRACE_USER_EVENT_MAX         = 130,
+        _SC_PASS_MAX                     = 131,
+    }
+
+    enum _SC_PAGE_SIZE = _SC_PAGESIZE;
+
+    enum
+    {
+        _CS_PATH                                =     1,
+        _CS_POSIX_V6_ILP32_OFF32_CFLAGS         =     2,
+        _CS_POSIX_V6_ILP32_OFF32_LDFLAGS        =     3,
+        _CS_POSIX_V6_ILP32_OFF32_LIBS           =     4,
+        _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS        =     5,
+        _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS       =     6,
+        _CS_POSIX_V6_ILP32_OFFBIG_LIBS          =     7,
+        _CS_POSIX_V6_LP64_OFF64_CFLAGS          =     8,
+        _CS_POSIX_V6_LP64_OFF64_LDFLAGS         =     9,
+        _CS_POSIX_V6_LP64_OFF64_LIBS            =    10,
+        _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS        =    11,
+        _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS       =    12,
+        _CS_POSIX_V6_LPBIG_OFFBIG_LIBS          =    13,
+        _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS      =    14,
+
+        _CS_XBS5_ILP32_OFF32_CFLAGS             =    20,
+        _CS_XBS5_ILP32_OFF32_LDFLAGS            =    21,
+        _CS_XBS5_ILP32_OFF32_LIBS               =    22,
+        _CS_XBS5_ILP32_OFF32_LINTFLAGS          =    23,
+        _CS_XBS5_ILP32_OFFBIG_CFLAGS            =    24,
+        _CS_XBS5_ILP32_OFFBIG_LDFLAGS           =    25,
+        _CS_XBS5_ILP32_OFFBIG_LIBS              =    26,
+        _CS_XBS5_ILP32_OFFBIG_LINTFLAGS         =    27,
+        _CS_XBS5_LP64_OFF64_CFLAGS              =    28,
+        _CS_XBS5_LP64_OFF64_LDFLAGS             =    29,
+        _CS_XBS5_LP64_OFF64_LIBS                =    30,
+        _CS_XBS5_LP64_OFF64_LINTFLAGS           =    31,
+        _CS_XBS5_LPBIG_OFFBIG_CFLAGS            =    32,
+        _CS_XBS5_LPBIG_OFFBIG_LDFLAGS           =    33,
+        _CS_XBS5_LPBIG_OFFBIG_LIBS              =    34,
+        _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS         =    35,
+
+        _CS_DARWIN_USER_DIR                     = 65536,
+        _CS_DARWIN_USER_TEMP_DIR                = 65537,
+        _CS_DARWIN_USER_CACHE_DIR               = 65538,
+    }
+}
+else version( FreeBSD )
+{
+    enum F_OK       = 0;
+    enum R_OK       = 0x04;
+    enum W_OK       = 0x02;
+    enum X_OK       = 0x01;
+
+    enum F_ULOCK    = 0;
+    enum F_LOCK     = 1;
+    enum F_TLOCK    = 2;
+    enum F_TEST     = 3;
+
+    enum
+    {
+        _SC_ARG_MAX                        =   1,
+        _SC_CHILD_MAX                      =   2,
+        _SC_CLK_TCK                        =   3,
+        _SC_NGROUPS_MAX                    =   4,
+        _SC_OPEN_MAX                       =   5,
+        _SC_JOB_CONTROL                    =   6,
+        _SC_SAVED_IDS                      =   7,
+        _SC_VERSION                        =   8,
+        _SC_BC_BASE_MAX                    =   9,
+        _SC_BC_DIM_MAX                     =  10,
+        _SC_BC_SCALE_MAX                   =  11,
+        _SC_BC_STRING_MAX                  =  12,
+        _SC_COLL_WEIGHTS_MAX               =  13,
+        _SC_EXPR_NEST_MAX                  =  14,
+        _SC_LINE_MAX                       =  15,
+        _SC_RE_DUP_MAX                     =  16,
+        _SC_2_VERSION                      =  17,
+        _SC_2_C_BIND                       =  18,
+        _SC_2_C_DEV                        =  19,
+        _SC_2_CHAR_TERM                    =  20,
+        _SC_2_FORT_DEV                     =  21,
+        _SC_2_FORT_RUN                     =  22,
+        _SC_2_LOCALEDEF                    =  23,
+        _SC_2_SW_DEV                       =  24,
+        _SC_2_UPE                          =  25,
+        _SC_STREAM_MAX                     =  26,
+        _SC_TZNAME_MAX                     =  27,
+        _SC_ASYNCHRONOUS_IO                =  28,
+        _SC_MAPPED_FILES                   =  29,
+        _SC_MEMLOCK                        =  30,
+        _SC_MEMLOCK_RANGE                  =  31,
+        _SC_MEMORY_PROTECTION              =  32,
+        _SC_MESSAGE_PASSING                =  33,
+        _SC_PRIORITIZED_IO                 =  34,
+        _SC_PRIORITY_SCHEDULING            =  35,
+        _SC_REALTIME_SIGNALS               =  36,
+        _SC_SEMAPHORES                     =  37,
+        _SC_FSYNC                          =  38,
+        _SC_SHARED_MEMORY_OBJECTS          =  39,
+        _SC_SYNCHRONIZED_IO                =  40,
+        _SC_TIMERS                         =  41,
+        _SC_AIO_LISTIO_MAX                 =  42,
+        _SC_AIO_MAX                        =  43,
+        _SC_AIO_PRIO_DELTA_MAX             =  44,
+        _SC_DELAYTIMER_MAX                 =  45,
+        _SC_MQ_OPEN_MAX                    =  46,
+        _SC_PAGESIZE                       =  47,
+        _SC_RTSIG_MAX                      =  48,
+        _SC_SEM_NSEMS_MAX                  =  49,
+        _SC_SEM_VALUE_MAX                  =  50,
+        _SC_SIGQUEUE_MAX                   =  51,
+        _SC_TIMER_MAX                      =  52,
+        _SC_IOV_MAX                        =  56,
+        _SC_NPROCESSORS_CONF               =  57,
+        _SC_NPROCESSORS_ONLN               =  58,
+        _SC_2_PBS                          =  59,
+        _SC_2_PBS_ACCOUNTING               =  60,
+        _SC_2_PBS_CHECKPOINT               =  61,
+        _SC_2_PBS_LOCATE                   =  62,
+        _SC_2_PBS_MESSAGE                  =  63,
+        _SC_2_PBS_TRACK                    =  64,
+        _SC_ADVISORY_INFO                  =  65,
+        _SC_BARRIERS                       =  66,
+        _SC_CLOCK_SELECTION                =  67,
+        _SC_CPUTIME                        =  68,
+        _SC_FILE_LOCKING                   =  69,
+        _SC_GETGR_R_SIZE_MAX               =  70,
+        _SC_GETPW_R_SIZE_MAX               =  71,
+        _SC_HOST_NAME_MAX                  =  72,
+        _SC_LOGIN_NAME_MAX                 =  73,
+        _SC_MONOTONIC_CLOCK                =  74,
+        _SC_MQ_PRIO_MAX                    =  75,
+        _SC_READER_WRITER_LOCKS            =  76,
+        _SC_REGEXP                         =  77,
+        _SC_SHELL                          =  78,
+        _SC_SPAWN                          =  79,
+        _SC_SPIN_LOCKS                     =  80,
+        _SC_SPORADIC_SERVER                =  81,
+        _SC_THREAD_ATTR_STACKADDR          =  82,
+        _SC_THREAD_ATTR_STACKSIZE          =  83,
+        _SC_THREAD_CPUTIME                 =  84,
+        _SC_THREAD_DESTRUCTOR_ITERATIONS   =  85,
+        _SC_THREAD_KEYS_MAX                =  86,
+        _SC_THREAD_PRIO_INHERIT            =  87,
+        _SC_THREAD_PRIO_PROTECT            =  88,
+        _SC_THREAD_PRIORITY_SCHEDULING     =  89,
+        _SC_THREAD_PROCESS_SHARED          =  90,
+        _SC_THREAD_SAFE_FUNCTIONS          =  91,
+        _SC_THREAD_SPORADIC_SERVER         =  92,
+        _SC_THREAD_STACK_MIN               =  93,
+        _SC_THREAD_THREADS_MAX             =  94,
+        _SC_TIMEOUTS                       =  95,
+        _SC_THREADS                        =  96,
+        _SC_TRACE                          =  97,
+        _SC_TRACE_EVENT_FILTER             =  98,
+        _SC_TRACE_INHERIT                  =  99,
+        _SC_TRACE_LOG                      = 100,
+        _SC_TTY_NAME_MAX                   = 101,
+        _SC_TYPED_MEMORY_OBJECTS           = 102,
+        _SC_V6_ILP32_OFF32                 = 103,
+        _SC_V6_ILP32_OFFBIG                = 104,
+        _SC_V6_LP64_OFF64                  = 105,
+        _SC_V6_LPBIG_OFFBIG                = 106,
+        _SC_IPV6                           = 118,
+        _SC_RAW_SOCKETS                    = 119,
+        _SC_SYMLOOP_MAX                    = 120,
+        _SC_ATEXIT_MAX                     = 107,
+        _SC_XOPEN_CRYPT                    = 108,
+        _SC_XOPEN_ENH_I18N                 = 109,
+        _SC_XOPEN_LEGACY                   = 110,
+        _SC_XOPEN_REALTIME                 = 111,
+        _SC_XOPEN_REALTIME_THREADS         = 112,
+        _SC_XOPEN_SHM                      = 113,
+        _SC_XOPEN_STREAMS                  = 114,
+        _SC_XOPEN_UNIX                     = 115,
+        _SC_XOPEN_VERSION                  = 116,
+        _SC_XOPEN_XCU_VERSION              = 117,
+        _SC_CPUSET_SIZE                    = 122,
+        _SC_PHYS_PAGES                     = 121,
+    }
+
+    enum _SC_PAGE_SIZE = _SC_PAGESIZE;
+
+    enum
+    {
+        _CS_PATH                           =   1,
+        _CS_POSIX_V6_ILP32_OFF32_CFLAGS    =   2,
+        _CS_POSIX_V6_ILP32_OFF32_LDFLAGS   =   3,
+        _CS_POSIX_V6_ILP32_OFF32_LIBS      =   4,
+        _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS   =   5,
+        _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS  =   6,
+        _CS_POSIX_V6_ILP32_OFFBIG_LIBS     =   7,
+        _CS_POSIX_V6_LP64_OFF64_CFLAGS     =   8,
+        _CS_POSIX_V6_LP64_OFF64_LDFLAGS    =   9,
+        _CS_POSIX_V6_LP64_OFF64_LIBS       =  10,
+        _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS   =  11,
+        _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS  =  12,
+        _CS_POSIX_V6_LPBIG_OFFBIG_LIBS     =  13,
+        _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS =  14,
+    }
+}
+else version( CRuntime_Bionic )
+{
+    enum F_OK       = 0;
+    enum R_OK       = 4;
+    enum W_OK       = 2;
+    enum X_OK       = 1;
+
+    enum _SC_PAGESIZE         = 0x0027;
+    enum _SC_NPROCESSORS_ONLN = 0x0061;
+    enum _SC_THREAD_STACK_MIN = 0x004c;
+}
+else version( Solaris )
+{
+    enum F_OK       = 0;
+    enum R_OK       = 4;
+    enum W_OK       = 2;
+    enum X_OK       = 1;
+
+    enum F_ULOCK    = 0;
+    enum F_LOCK     = 1;
+    enum F_TLOCK    = 2;
+    enum F_TEST     = 3;
+
+    enum
+    {
+        // large file compilation environment configuration
+        _CS_LFS_CFLAGS                  = 68,
+        _CS_LFS_LDFLAGS                 = 69,
+        _CS_LFS_LIBS                    = 70,
+        _CS_LFS_LINTFLAGS               = 71,
+        // transitional large file interface configuration
+        _CS_LFS64_CFLAGS                = 72,
+        _CS_LFS64_LDFLAGS               = 73,
+        _CS_LFS64_LIBS                  = 74,
+        _CS_LFS64_LINTFLAGS             = 75,
+
+        // UNIX 98
+        _CS_XBS5_ILP32_OFF32_CFLAGS     = 700,
+        _CS_XBS5_ILP32_OFF32_LDFLAGS    = 701,
+        _CS_XBS5_ILP32_OFF32_LIBS       = 702,
+        _CS_XBS5_ILP32_OFF32_LINTFLAGS  = 703,
+        _CS_XBS5_ILP32_OFFBIG_CFLAGS    = 705,
+        _CS_XBS5_ILP32_OFFBIG_LDFLAGS   = 706,
+        _CS_XBS5_ILP32_OFFBIG_LIBS      = 707,
+        _CS_XBS5_ILP32_OFFBIG_LINTFLAGS = 708,
+        _CS_XBS5_LP64_OFF64_CFLAGS      = 709,
+        _CS_XBS5_LP64_OFF64_LDFLAGS     = 710,
+        _CS_XBS5_LP64_OFF64_LIBS        = 711,
+        _CS_XBS5_LP64_OFF64_LINTFLAGS   = 712,
+        _CS_XBS5_LPBIG_OFFBIG_CFLAGS    = 713,
+        _CS_XBS5_LPBIG_OFFBIG_LDFLAGS   = 714,
+        _CS_XBS5_LPBIG_OFFBIG_LIBS      = 715,
+        _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS = 716,
+
+        // UNIX 03
+        _CS_POSIX_V6_ILP32_OFF32_CFLAGS         = 800,
+        _CS_POSIX_V6_ILP32_OFF32_LDFLAGS        = 801,
+        _CS_POSIX_V6_ILP32_OFF32_LIBS           = 802,
+        _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS      = 803,
+        _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS        = 804,
+        _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS       = 805,
+        _CS_POSIX_V6_ILP32_OFFBIG_LIBS          = 806,
+        _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS     = 807,
+        _CS_POSIX_V6_LP64_OFF64_CFLAGS          = 808,
+        _CS_POSIX_V6_LP64_OFF64_LDFLAGS         = 809,
+        _CS_POSIX_V6_LP64_OFF64_LIBS            = 810,
+        _CS_POSIX_V6_LP64_OFF64_LINTFLAGS       = 811,
+        _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS        = 812,
+        _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS       = 813,
+        _CS_POSIX_V6_LPBIG_OFFBIG_LIBS          = 814,
+        _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS     = 815,
+        _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS      = 816
+    }
+
+    enum {
+        _SC_ARG_MAX                     = 1,
+        _SC_CHILD_MAX                   = 2,
+        _SC_CLK_TCK                     = 3,
+        _SC_NGROUPS_MAX                 = 4,
+        _SC_OPEN_MAX                    = 5,
+        _SC_JOB_CONTROL                 = 6,
+        _SC_SAVED_IDS                   = 7,
+        _SC_VERSION                     = 8,
+
+        _SC_PASS_MAX                    = 9,
+        _SC_LOGNAME_MAX                 = 10,
+        _SC_PAGESIZE                    = 11,
+        _SC_XOPEN_VERSION               = 12,
+        // 13 reserved for SVr4-ES/MP _SC_NACLS_MAX
+        _SC_NPROCESSORS_CONF            = 14,
+        _SC_NPROCESSORS_ONLN            = 15,
+        _SC_STREAM_MAX                  = 16,
+        _SC_TZNAME_MAX                  = 17,
+
+        _SC_AIO_LISTIO_MAX              = 18,
+        _SC_AIO_MAX                     = 19,
+        _SC_AIO_PRIO_DELTA_MAX          = 20,
+        _SC_ASYNCHRONOUS_IO             = 21,
+        _SC_DELAYTIMER_MAX              = 22,
+        _SC_FSYNC                       = 23,
+        _SC_MAPPED_FILES                = 24,
+        _SC_MEMLOCK                     = 25,
+        _SC_MEMLOCK_RANGE               = 26,
+        _SC_MEMORY_PROTECTION           = 27,
+        _SC_MESSAGE_PASSING             = 28,
+        _SC_MQ_OPEN_MAX                 = 29,
+        _SC_MQ_PRIO_MAX                 = 30,
+        _SC_PRIORITIZED_IO              = 31,
+        _SC_PRIORITY_SCHEDULING         = 32,
+        _SC_REALTIME_SIGNALS            = 33,
+        _SC_RTSIG_MAX                   = 34,
+        _SC_SEMAPHORES                  = 35,
+        _SC_SEM_NSEMS_MAX               = 36,
+        _SC_SEM_VALUE_MAX               = 37,
+        _SC_SHARED_MEMORY_OBJECTS       = 38,
+        _SC_SIGQUEUE_MAX                = 39,
+        _SC_SIGRT_MIN                   = 40,
+        _SC_SIGRT_MAX                   = 41,
+        _SC_SYNCHRONIZED_IO             = 42,
+        _SC_TIMERS                      = 43,
+        _SC_TIMER_MAX                   = 44,
+
+        _SC_2_C_BIND                    = 45,
+        _SC_2_C_DEV                     = 46,
+        _SC_2_C_VERSION                 = 47,
+        _SC_2_FORT_DEV                  = 48,
+        _SC_2_FORT_RUN                  = 49,
+        _SC_2_LOCALEDEF                 = 50,
+        _SC_2_SW_DEV                    = 51,
+        _SC_2_UPE                       = 52,
+        _SC_2_VERSION                   = 53,
+        _SC_BC_BASE_MAX                 = 54,
+        _SC_BC_DIM_MAX                  = 55,
+        _SC_BC_SCALE_MAX                = 56,
+        _SC_BC_STRING_MAX               = 57,
+        _SC_COLL_WEIGHTS_MAX            = 58,
+        _SC_EXPR_NEST_MAX               = 59,
+        _SC_LINE_MAX                    = 60,
+        _SC_RE_DUP_MAX                  = 61,
+        _SC_XOPEN_CRYPT                 = 62,
+        _SC_XOPEN_ENH_I18N              = 63,
+        _SC_XOPEN_SHM                   = 64,
+        _SC_2_CHAR_TERM                 = 66,
+        _SC_XOPEN_XCU_VERSION           = 67,
+
+        _SC_ATEXIT_MAX                  = 76,
+        _SC_IOV_MAX                     = 77,
+        _SC_XOPEN_UNIX                  = 78,
+
+        _SC_T_IOV_MAX                   = 79,
+
+        _SC_PHYS_PAGES                  = 500,
+        _SC_AVPHYS_PAGES                = 501,
+
+        _SC_COHER_BLKSZ         = 503,
+        _SC_SPLIT_CACHE         = 504,
+        _SC_ICACHE_SZ           = 505,
+        _SC_DCACHE_SZ           = 506,
+        _SC_ICACHE_LINESZ       = 507,
+        _SC_DCACHE_LINESZ       = 508,
+        _SC_ICACHE_BLKSZ        = 509,
+        _SC_DCACHE_BLKSZ        = 510,
+        _SC_DCACHE_TBLKSZ       = 511,
+        _SC_ICACHE_ASSOC        = 512,
+        _SC_DCACHE_ASSOC        = 513,
+
+        _SC_MAXPID              = 514,
+        _SC_STACK_PROT          = 515,
+        _SC_NPROCESSORS_MAX     = 516,
+        _SC_CPUID_MAX           = 517,
+        _SC_EPHID_MAX           = 518,
+
+        _SC_THREAD_DESTRUCTOR_ITERATIONS = 568,
+        _SC_GETGR_R_SIZE_MAX            = 569,
+        _SC_GETPW_R_SIZE_MAX            = 570,
+        _SC_LOGIN_NAME_MAX              = 571,
+        _SC_THREAD_KEYS_MAX             = 572,
+        _SC_THREAD_STACK_MIN            = 573,
+        _SC_THREAD_THREADS_MAX          = 574,
+        _SC_TTY_NAME_MAX                = 575,
+        _SC_THREADS                     = 576,
+        _SC_THREAD_ATTR_STACKADDR       = 577,
+        _SC_THREAD_ATTR_STACKSIZE       = 578,
+        _SC_THREAD_PRIORITY_SCHEDULING  = 579,
+        _SC_THREAD_PRIO_INHERIT         = 580,
+        _SC_THREAD_PRIO_PROTECT         = 581,
+        _SC_THREAD_PROCESS_SHARED       = 582,
+        _SC_THREAD_SAFE_FUNCTIONS       = 583,
+
+        _SC_XOPEN_LEGACY                = 717,
+        _SC_XOPEN_REALTIME              = 718,
+        _SC_XOPEN_REALTIME_THREADS      = 719,
+        _SC_XBS5_ILP32_OFF32            = 720,
+        _SC_XBS5_ILP32_OFFBIG           = 721,
+        _SC_XBS5_LP64_OFF64             = 722,
+        _SC_XBS5_LPBIG_OFFBIG           = 723,
+
+        _SC_2_PBS                       = 724,
+        _SC_2_PBS_ACCOUNTING            = 725,
+        _SC_2_PBS_CHECKPOINT            = 726,
+        _SC_2_PBS_LOCATE                = 728,
+        _SC_2_PBS_MESSAGE               = 729,
+        _SC_2_PBS_TRACK                 = 730,
+        _SC_ADVISORY_INFO               = 731,
+        _SC_BARRIERS                    = 732,
+        _SC_CLOCK_SELECTION             = 733,
+        _SC_CPUTIME                     = 734,
+        _SC_HOST_NAME_MAX               = 735,
+        _SC_MONOTONIC_CLOCK             = 736,
+        _SC_READER_WRITER_LOCKS         = 737,
+        _SC_REGEXP                      = 738,
+        _SC_SHELL                       = 739,
+        _SC_SPAWN                       = 740,
+        _SC_SPIN_LOCKS                  = 741,
+        _SC_SPORADIC_SERVER             = 742,
+        _SC_SS_REPL_MAX                 = 743,
+        _SC_SYMLOOP_MAX                 = 744,
+        _SC_THREAD_CPUTIME              = 745,
+        _SC_THREAD_SPORADIC_SERVER      = 746,
+        _SC_TIMEOUTS                    = 747,
+        _SC_TRACE                       = 748,
+        _SC_TRACE_EVENT_FILTER          = 749,
+        _SC_TRACE_EVENT_NAME_MAX        = 750,
+        _SC_TRACE_INHERIT               = 751,
+        _SC_TRACE_LOG                   = 752,
+        _SC_TRACE_NAME_MAX              = 753,
+        _SC_TRACE_SYS_MAX               = 754,
+        _SC_TRACE_USER_EVENT_MAX        = 755,
+        _SC_TYPED_MEMORY_OBJECTS        = 756,
+        _SC_V6_ILP32_OFF32              = 757,
+        _SC_V6_ILP32_OFFBIG             = 758,
+        _SC_V6_LP64_OFF64               = 759,
+        _SC_V6_LPBIG_OFFBIG             = 760,
+        _SC_XOPEN_STREAMS               = 761,
+        _SC_IPV6                        = 762,
+        _SC_RAW_SOCKETS                 = 763,
+    }
+    enum _SC_PAGE_SIZE = _SC_PAGESIZE;
+
+    enum {
+        _PC_LINK_MAX            = 1,
+        _PC_MAX_CANON           = 2,
+        _PC_MAX_INPUT           = 3,
+        _PC_NAME_MAX            = 4,
+        _PC_PATH_MAX            = 5,
+        _PC_PIPE_BUF            = 6,
+        _PC_NO_TRUNC            = 7,
+        _PC_VDISABLE            = 8,
+        _PC_CHOWN_RESTRICTED    = 9,
+
+        _PC_ASYNC_IO            = 10,
+        _PC_PRIO_IO             = 11,
+        _PC_SYNC_IO             = 12,
+
+        _PC_ALLOC_SIZE_MIN      = 13,
+        _PC_REC_INCR_XFER_SIZE  = 14,
+        _PC_REC_MAX_XFER_SIZE   = 15,
+        _PC_REC_MIN_XFER_SIZE   = 16,
+        _PC_REC_XFER_ALIGN      = 17,
+        _PC_SYMLINK_MAX         = 18,
+        _PC_2_SYMLINKS          = 19,
+        _PC_ACL_ENABLED         = 20,
+        _PC_MIN_HOLE_SIZE       = 21,
+        _PC_CASE_BEHAVIOR       = 22,
+        _PC_SATTR_ENABLED       = 23,
+        _PC_SATTR_EXISTS        = 24,
+        _PC_ACCESS_FILTERING    = 25,
+
+        _PC_TIMESTAMP_RESOLUTION = 26,
+
+        _PC_FILESIZEBITS        = 67,
+
+        _PC_XATTR_ENABLED       = 100,
+        _PC_XATTR_EXISTS        = 101
+    }
+
+    enum _PC_LAST = 101;
+}
+
+//
+// File Synchronization (FSC)
+//
+/*
+int fsync(int);
+*/
+
+version( CRuntime_Glibc )
+{
+    int fsync(int) @trusted;
+}
+else version( OSX )
+{
+    int fsync(int) @trusted;
+}
+else version( FreeBSD )
+{
+    int fsync(int) @trusted;
+}
+else version( CRuntime_Bionic )
+{
+    int fsync(int) @trusted;
+}
+else version( Solaris )
+{
+    int fsync(int) @trusted;
+}
+
+//
+// Synchronized I/O (SIO)
+//
+/*
+int fdatasync(int);
+*/
+
+version( CRuntime_Glibc )
+{
+    int fdatasync(int) @trusted;
+}
+else version( Solaris )
+{
+    int fdatasync(int) @trusted;
+}
+else version( CRuntime_Bionic )
+{
+    int fdatasync(int) @trusted;
+}
+
+//
+// XOpen (XSI)
+//
+/*
+char*      crypt(in char*, in char*);
+char*      ctermid(char*);
+void       encrypt(ref char[64], int);
+int        fchdir(int);
+c_long     gethostid();
+pid_t      getpgid(pid_t);
+pid_t      getsid(pid_t);
+char*      getwd(char*); // LEGACY
+int        lchown(in char*, uid_t, gid_t);
+int        lockf(int, int, off_t);
+int        nice(int);
+ssize_t    pread(int, void*, size_t, off_t);
+ssize_t    pwrite(int, in void*, size_t, off_t);
+pid_t      setpgrp();
+int        setregid(gid_t, gid_t);
+int        setreuid(uid_t, uid_t);
+void       swab(in void*, void*, ssize_t);
+void       sync();
+int        truncate(in char*, off_t);
+useconds_t ualarm(useconds_t, useconds_t);
+int        usleep(useconds_t);
+pid_t      vfork();
+*/
+
+version( CRuntime_Glibc )
+{
+    char*      crypt(in char*, in char*);
+    char*      ctermid(char*);
+    void       encrypt(ref char[64], int) @trusted;
+    int        fchdir(int) @trusted;
+    c_long     gethostid() @trusted;
+    pid_t      getpgid(pid_t) @trusted;
+    pid_t      getsid(pid_t) @trusted;
+    char*      getwd(char*); // LEGACY
+    int        lchown(in char*, uid_t, gid_t);
+    //int        lockf(int, int, off_t);
+    int        nice(int) @trusted;
+    //ssize_t    pread(int, void*, size_t, off_t);
+    //ssize_t    pwrite(int, in void*, size_t, off_t);
+    pid_t      setpgrp() @trusted;
+    int        setregid(gid_t, gid_t) @trusted;
+    int        setreuid(uid_t, uid_t) @trusted;
+    void       swab(in void*, void*, ssize_t);
+    void       sync() @trusted;
+    //int        truncate(in char*, off_t);
+    useconds_t ualarm(useconds_t, useconds_t) @trusted;
+    int        usleep(useconds_t) @trusted;
+    pid_t      vfork();
+
+  static if( __USE_FILE_OFFSET64 )
+  {
+    int        lockf64(int, int, off_t) @trusted;
+    alias      lockf64 lockf;
+
+    ssize_t    pread64(int, void*, size_t, off_t);
+    alias      pread64 pread;
+
+    ssize_t    pwrite64(int, in void*, size_t, off_t);
+    alias      pwrite64 pwrite;
+
+    int        truncate64(in char*, off_t);
+    alias      truncate64 truncate;
+  }
+  else
+  {
+    int        lockf(int, int, off_t) @trusted;
+    ssize_t    pread(int, void*, size_t, off_t);
+    ssize_t    pwrite(int, in void*, size_t, off_t);
+    int        truncate(in char*, off_t);
+  }
+}
+else version( OSX )
+{
+    char*      crypt(in char*, in char*);
+    char*      ctermid(char*);
+    void       encrypt(ref char[64], int) @trusted;
+    int        fchdir(int) @trusted;
+    c_long     gethostid() @trusted;
+    pid_t      getpgid(pid_t) @trusted;
+    pid_t      getsid(pid_t) @trusted;
+    char*      getwd(char*); // LEGACY
+    int        lchown(in char*, uid_t, gid_t);
+    int        lockf(int, int, off_t) @trusted;
+    int        nice(int) @trusted;
+    ssize_t    pread(int, void*, size_t, off_t);
+    ssize_t    pwrite(int, in void*, size_t, off_t);
+    pid_t      setpgrp() @trusted;
+    int        setregid(gid_t, gid_t) @trusted;
+    int        setreuid(uid_t, uid_t) @trusted;
+    void       swab(in void*, void*, ssize_t);
+    void       sync() @trusted;
+    int        truncate(in char*, off_t);
+    useconds_t ualarm(useconds_t, useconds_t) @trusted;
+    int        usleep(useconds_t) @trusted;
+    pid_t      vfork();
+}
+else version( FreeBSD )
+{
+    char*      crypt(in char*, in char*);
+    //char*      ctermid(char*);
+    void       encrypt(ref char[64], int) @trusted;
+    int        fchdir(int) @trusted;
+    c_long     gethostid() @trusted;
+    int        getpgid(pid_t) @trusted;
+    int        getsid(pid_t) @trusted;
+    char*      getwd(char*); // LEGACY
+    int        lchown(in char*, uid_t, gid_t);
+    int        lockf(int, int, off_t) @trusted;
+    int        nice(int) @trusted;
+    ssize_t    pread(int, void*, size_t, off_t);
+    ssize_t    pwrite(int, in void*, size_t, off_t);
+    int        setpgrp(pid_t, pid_t) @trusted;
+    int        setregid(gid_t, gid_t) @trusted;
+    int        setreuid(uid_t, uid_t) @trusted;
+    void       swab(in void*, void*, ssize_t);
+    void       sync() @trusted;
+    int        truncate(in char*, off_t);
+    useconds_t ualarm(useconds_t, useconds_t) @trusted;
+    int        usleep(useconds_t) @trusted;
+    pid_t      vfork();
+}
+else version( CRuntime_Bionic )
+{
+    int        fchdir(int) @trusted;
+    pid_t      getpgid(pid_t) @trusted;
+    int        lchown(in char*, uid_t, gid_t);
+    int        nice(int) @trusted;
+    ssize_t    pread(int, void*, size_t, off_t);
+    ssize_t    pwrite(int, in void*, size_t, off_t);
+    int        setpgrp() @trusted;
+    int        setregid(gid_t, gid_t) @trusted;
+    int        setreuid(uid_t, uid_t) @trusted;
+    int        sync() @trusted;
+    int        truncate(in char*, off_t);
+    int        usleep(c_ulong) @trusted;
+    pid_t      vfork();
+}
+else version( Solaris )
+{
+    char*      crypt(in char*, in char*);
+    char*      ctermid(char*);
+    void       encrypt(ref char[64], int);
+    int        fchdir(int);
+    c_long     gethostid();
+    pid_t      getpgid(pid_t);
+    pid_t      getsid(pid_t);
+    char*      getwd(char*); // LEGACY
+    int        lchown(in char*, uid_t, gid_t);
+    int        nice(int);
+    pid_t      setpgrp();
+    int        setregid(gid_t, gid_t);
+    int        setreuid(uid_t, uid_t);
+    void       swab(in void*, void*, ssize_t);
+    void       sync();
+    useconds_t ualarm(useconds_t, useconds_t);
+    int        usleep(useconds_t);
+    pid_t      vfork();
+
+    version (D_LP64)
+    {
+        int         lockf(int, int, off_t);
+        alias       lockf lockf64;
+
+        ssize_t     pread(int, void*, size_t, off_t);
+        alias       pread pread64;
+
+        ssize_t     pwrite(int, in void*, size_t, off_t);
+        alias       pwrite pwrite64;
+
+        int         truncate(in char*, off_t);
+        alias       truncate truncate64;
+    }
+    else
+    {
+        static if( __USE_FILE_OFFSET64 )
+        {
+            int        lockf64(int, int, off64_t);
+            alias      lockf64 lockf;
+
+            ssize_t    pread64(int, void*, size_t, off64_t);
+            alias      pread64 pread;
+
+            ssize_t    pwrite64(int, in void*, size_t, off_t);
+            alias      pwrite64 pwrite;
+
+            int        truncate64(in char*, off_t);
+            alias      truncate64 truncate;
+        }
+        else
+        {
+            int        lockf(int, int, off_t);
+            ssize_t    pread(int, void*, size_t, off_t);
+            ssize_t    pwrite(int, in void*, size_t, off_t);
+            int        truncate(in char*, off_t);
+        }
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/posix/utime.d b/libphobos/libdruntime/core/sys/posix/utime.d
new file mode 100644
index 00000000000..7a05d415a58
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/utime.d
@@ -0,0 +1,87 @@
+/**
+ * D header file for POSIX.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.sys.posix.utime;
+
+private import core.sys.posix.config;
+public import core.sys.posix.sys.types; // for time_t
+
+version (Posix):
+extern (C):
+nothrow:
+@nogc:
+
+//
+// Required
+//
+/*
+struct utimbuf
+{
+    time_t  actime;
+    time_t  modtime;
+}
+
+int utime(in char*, in utimbuf*);
+*/
+
+version( CRuntime_Glibc )
+{
+    struct utimbuf
+    {
+        time_t  actime;
+        time_t  modtime;
+    }
+
+    int utime(in char*, in utimbuf*);
+}
+else version( OSX )
+{
+    struct utimbuf
+    {
+        time_t  actime;
+        time_t  modtime;
+    }
+
+    int utime(in char*, in utimbuf*);
+}
+else version( FreeBSD )
+{
+    struct utimbuf
+    {
+        time_t  actime;
+        time_t  modtime;
+    }
+
+    int utime(in char*, in utimbuf*);
+}
+else version( Solaris )
+{
+    struct utimbuf
+    {
+        time_t  actime;
+        time_t  modtime;
+    }
+
+    int utime(in char*, in utimbuf*);
+}
+else version( CRuntime_Bionic )
+{
+    struct utimbuf
+    {
+        time_t  actime;
+        time_t  modtime;
+    }
+
+    int utime(in char*, in utimbuf*);
+}
diff --git a/libphobos/libdruntime/core/sys/solaris/dlfcn.d b/libphobos/libdruntime/core/sys/solaris/dlfcn.d
new file mode 100644
index 00000000000..95afc89cec5
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/dlfcn.d
@@ -0,0 +1,112 @@
+/**
+ * D header file for Solaris
+ *
+ * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/head/dlfcn.h, illumos dlfcn.h)
+ */
+
+module core.sys.solaris.dlfcn;
+
+version (Solaris):
+extern (C):
+nothrow:
+
+public import core.sys.posix.dlfcn;
+import core.stdc.config;
+
+// enum RTLD_LAZY = 0x00001; // POSIX
+// enum RTLD_NOW = 0x00002; // POSIX
+enum RTLD_NOLOAD = 0x00004;
+enum RTLD_DEEPBIND = 0x00008;
+
+// enum RTLD_GLOBAL = 0x00100; // POSIX
+// enum RTLD_LOCAL = 0; // POSIX
+enum RTLD_PARENT   = 0x00200;
+enum RTLD_GROUP    = 0x00400;
+enum RTLD_WORLD    = 0x00800;
+enum RTLD_NODELETE = 0x01000;
+enum RTLD_FIRST    = 0x02000;
+enum RTLD_CONFGEN  = 0x10000;
+
+
+enum
+{
+    RTLD_NEXT    = cast(void *)-1,
+    RTLD_DEFAULT = cast(void *)-2,
+    RTLD_SELF    = cast(void *)-3,
+    RTLD_PROBE   = cast(void *)-4,
+}
+
+alias c_ulong Lmid_t;
+
+void* dlmopen(Lmid_t, in char*, int);
+
+enum
+{
+    RTLD_REL_RELATIVE = 0x00001,
+    RTLD_REL_EXEC     = 0x00002,
+    RTLD_REL_DEPENDS  = 0x00004,
+    RTLD_REL_PRELOAD  = 0x00008,
+    RTLD_REL_SELF     = 0x00010,
+    RTLD_REL_WEAK     = 0x00020,
+    RTLD_REL_ALL      = 0x00fff,
+    RTLD_MEMORY       = 0x01000,
+    RTLD_STRIP        = 0x02000,
+    RTLD_NOHEAP       = 0x04000,
+    RTLD_CONFSET      = 0x10000,
+}
+
+int dldump(in char*, in char*, int);
+
+struct Dl_info
+{
+    const(char)* dli_fname;
+    void*        dli_fbase;
+    const(char)* dli_sname;
+    void*        dli_saddr;
+}
+
+enum
+{
+    RTLD_DL_SYMENT = 1,
+    RTLD_DL_LINKMAP = 2,
+}
+
+int dladdr(const(void)*, Dl_info*);
+int dladdr1(void*, Dl_info*, void**, int);
+
+enum
+{
+    RTLD_DI_LMID         = 1,
+    RTLD_DI_LINKMAP      = 2,
+    RTLD_DI_CONFIGADDR   = 3,
+    RTLD_DI_SERINFO      = 4,
+    RTLD_DI_SERINFOSIZE  = 5,
+    RTLD_DI_ORIGIN       = 6,
+    RTLD_DI_PROFILENAME  = 7,
+    RTLD_DI_PROFILEOUT   = 8,
+    RTLD_DI_GETSIGNAL    = 9,
+    RTLD_DI_SETSIGNAL    = 10,
+    RTLD_DI_ARGSINFO     = 11,
+    RTLD_DI_MMAPS        = 12,
+    RTLD_DI_MMAPCNT      = 13,
+    RTLD_DI_DEFERRED     = 14,
+    RTLD_DI_DEFERRED_SYM = 15,
+    RTLD_DI_MAX          = 15,
+}
+
+int dlinfo(void*, int, void*);
+
+struct Dl_serpath
+{
+    char*  dls_name;
+    uint   dls_flags;
+}
+
+struct Dl_serinfo
+{
+    size_t         dls_size;
+    uint           dls_cnt;
+    Dl_serpath[1]  dls_serpath;
+}
+
+// FIXME: Dl_argsinfo, Dl_mapinfo, Dl_amd64_unwindinfo are missing
\ No newline at end of file
diff --git a/libphobos/libdruntime/core/sys/solaris/elf.d b/libphobos/libdruntime/core/sys/solaris/elf.d
new file mode 100644
index 00000000000..f91d69a9253
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/elf.d
@@ -0,0 +1,12 @@
+/**
+ * D header file for Solaris.
+ *
+ * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/head/elf.h, illumos elf.h)
+ */
+module core.sys.solaris.elf;
+
+version (Solaris):
+extern (C):
+nothrow:
+
+public import core.sys.solaris.sys.elf;
diff --git a/libphobos/libdruntime/core/sys/solaris/execinfo.d b/libphobos/libdruntime/core/sys/solaris/execinfo.d
new file mode 100644
index 00000000000..4c5f7f430c7
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/execinfo.d
@@ -0,0 +1,18 @@
+/**
+ * D header file for Solaris.
+ *
+ * Copyright: Copyright Martin Nowak 2012.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Martin Nowak
+ */
+module core.sys.solaris.execinfo;
+
+// The interface is exactly the same as linux, so copied from linux's execinfo.d
+
+version (Solaris):
+extern (C):
+nothrow:
+
+int backtrace(void** buffer, int size);
+char** backtrace_symbols(const(void*)* buffer, int size);
+void backtrace_symbols_fd(const(void*)* buffer, int size, int fd);
diff --git a/libphobos/libdruntime/core/sys/solaris/libelf.d b/libphobos/libdruntime/core/sys/solaris/libelf.d
new file mode 100644
index 00000000000..b89187811ec
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/libelf.d
@@ -0,0 +1,166 @@
+/**
+ * D header file for Solaris.
+ *
+ * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/head/libelf.h, illumos libelf.h)
+ */
+module core.sys.solaris.libelf;
+
+version (Solaris):
+extern (C):
+nothrow:
+
+import core.stdc.config;
+import core.sys.posix.sys.types;
+import core.sys.solaris.sys.elf;
+
+enum Elf_Cmd
+{
+    ELF_C_NULL = 0,
+    ELF_C_READ,
+    ELF_C_WRITE,
+    ELF_C_CLR,
+    ELF_C_SET,
+    ELF_C_FDDONE,
+    ELF_C_FDREAD,
+    ELF_C_RDWR,
+    ELF_C_WRIMAGE,
+    ELF_C_IMAGE,
+    ELF_C_NUM
+}
+
+enum ELF_F_DIRTY  = 0x1;
+enum ELF_F_LAYOUT = 0x4;
+
+enum Elf_Kind
+{
+    ELF_K_NONE = 0,
+    ELF_K_AR,
+    ELF_K_COFF,
+    ELF_K_ELF,
+    ELF_K_NUM
+}
+
+enum Elf_Type
+{
+    ELF_T_BYTE = 0,
+    ELF_T_ADDR,
+    ELF_T_DYN,
+    ELF_T_EHDR,
+    ELF_T_HALF,
+    ELF_T_OFF,
+    ELF_T_PHDR,
+    ELF_T_RELA,
+    ELF_T_REL,
+    ELF_T_SHDR,
+    ELF_T_SWORD,
+    ELF_T_SYM,
+    ELF_T_WORD,
+    ELF_T_VDEF,
+    ELF_T_VNEED,
+    ELF_T_SXWORD,
+    ELF_T_XWORD,
+    ELF_T_SYMINFO,
+    ELF_T_NOTE,
+    ELF_T_MOVE,
+    ELF_T_MOVEP,
+    ELF_T_CAP,
+    ELF_T_NUM
+}
+
+struct Elf
+{
+}
+
+struct Elf_Scn
+{
+}
+
+struct Elf_Arhdr
+{
+    char*   ar_name;
+    time_t  ar_date;
+    uid_t   ar_uid;
+    gid_t   ar_gid;
+    mode_t  ar_mode;
+    off_t   ar_size;
+    char*   ar_rawname;
+}
+
+struct Elf_Arsym
+{
+    char*    as_name;
+    size_t   as_off;
+    c_ulong  as_hash;
+}
+
+struct Elf_Data
+{
+  void*     d_buf;
+  Elf_Type  d_type;
+  size_t    d_size;
+  off_t     d_off;
+  size_t    d_align;
+  uint      d_version;
+}
+
+Elf* elf_begin(int, Elf_Cmd, Elf*);
+int elf_cntl(Elf*, Elf_Cmd);
+int elf_end(Elf*);
+const(char)* elf_errmsg(int);
+int elf_errno();
+void elf_fill(int);
+uint elf_flagdata(Elf_Data*, Elf_Cmd, uint);
+uint elf_flagehdr(Elf*, Elf_Cmd,  uint);
+uint elf_flagelf(Elf*, Elf_Cmd, uint);
+uint elf_flagphdr(Elf*, Elf_Cmd, uint);
+uint elf_flagscn(Elf_Scn*, Elf_Cmd, uint);
+uint elf_flagshdr(Elf_Scn*, Elf_Cmd, uint);
+size_t elf32_fsize(Elf_Type, size_t, uint);
+Elf_Arhdr* elf_getarhdr(Elf*);
+Elf_Arsym* elf_getarsym(Elf*, size_t*);
+off_t elf_getbase(Elf*);
+Elf_Data* elf_getdata(Elf_Scn*, Elf_Data*);
+Elf32_Ehdr* elf32_getehdr(Elf*);
+char* elf_getident(Elf*, size_t*);
+Elf32_Phdr* elf32_getphdr(Elf*);
+Elf_Scn* elf_getscn(Elf*, size_t);
+Elf32_Shdr* elf32_getshdr(Elf_Scn*);
+int elf_getphnum(Elf*, size_t*);
+int elf_getphdrnum(Elf*, size_t*);
+int elf_getshnum(Elf*, size_t*);
+int elf_getshdrnum(Elf*, size_t*);
+int elf_getshstrndx(Elf*, size_t*);
+int elf_getshdrstrndx(Elf*, size_t*);
+c_ulong elf_hash(in char*);
+uint elf_sys_encoding();
+long elf32_checksum(Elf*);
+Elf_Kind elf_kind(Elf*);
+Elf* elf_memory(char*, size_t);
+size_t elf_ndxscn(Elf_Scn*);
+Elf_Data* elf_newdata(Elf_Scn*);
+Elf32_Ehdr* elf32_newehdr(Elf*);
+Elf32_Phdr* elf32_newphdr(Elf*, size_t);
+Elf_Scn* elf_newscn(Elf*);
+Elf_Scn* elf_nextscn(Elf*, Elf_Scn*);
+Elf_Cmd elf_next(Elf*);
+size_t elf_rand(Elf*, size_t);
+Elf_Data* elf_rawdata(Elf_Scn*, Elf_Data*);
+char* elf_rawfile(Elf*, size_t*);
+char* elf_strptr(Elf*, size_t, size_t);
+off_t elf_update(Elf*, Elf_Cmd);
+uint elf_version(uint);
+Elf_Data* elf32_xlatetof(Elf_Data*, in Elf_Data*, uint);
+Elf_Data* elf32_xlatetom(Elf_Data*, in Elf_Data*, uint);
+
+version(D_LP64)
+{
+size_t elf64_fsize(Elf_Type, size_t, uint);
+Elf64_Ehdr* elf64_getehdr(Elf*);
+Elf64_Phdr* elf64_getphdr(Elf*);
+Elf64_Shdr* elf64_getshdr(Elf_Scn*);
+long elf64_checksum(Elf*);
+Elf64_Ehdr* elf64_newehdr(Elf*);
+Elf64_Phdr* elf64_newphdr(Elf*, size_t);
+Elf_Data* elf64_xlatetof(Elf_Data*, in Elf_Data*, uint);
+Elf_Data* elf64_xlatetom(Elf_Data*, in Elf_Data*, uint);
+}
\ No newline at end of file
diff --git a/libphobos/libdruntime/core/sys/solaris/link.d b/libphobos/libdruntime/core/sys/solaris/link.d
new file mode 100644
index 00000000000..a8fae3fd976
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/link.d
@@ -0,0 +1,173 @@
+﻿/**
+ * D header file for Solaris.
+ *
+ * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/head/link.h, illumos link.h)
+ */
+module core.sys.solaris.link;
+
+version (Solaris):
+extern (C):
+nothrow:
+
+import core.stdc.stdint;
+import core.sys.solaris.dlfcn;
+import core.sys.solaris.libelf;
+import core.sys.solaris.sys.elf;
+import core.sys.solaris.sys.link;
+
+uint ld_version(uint);
+void ld_input_done(uint*);
+
+void ld_start(in char*, in Elf32_Half, in char*);
+void ld_atexit(int);
+void ld_open(in char**, in char**, int*, int, Elf**, Elf*, size_t, in Elf_Kind);
+void ld_file(in char*, in Elf_Kind, int, Elf*);
+void ld_input_section(in char*, Elf32_Shdr**, Elf32_Word, Elf_Data*, Elf*, uint*);
+void ld_section(in char*, Elf32_Shdr*, Elf32_Word, Elf_Data*, Elf*);
+
+version(D_LP64)
+{
+void ld_start64(inchar*, in Elf64_Half, in char*);
+void ld_atexit64(int);
+void ld_open64(in char**, in char**, int*, int, Elf**, Elf*, size_t, in Elf_Kind);
+void ld_file64(in char*, in Elf_Kind, int, Elf*);
+void ld_input_section64(in char*, Elf64_Shdr**, Elf64_Word, Elf_Data*, Elf*, uint*);
+void ld_section64(in char*, Elf64_Shdr*, Elf64_Word, Elf_Data*, Elf*);
+}
+
+enum LD_SUP_VNONE    = 0;
+enum LD_SUP_VERSION1 = 1;
+enum LD_SUP_VERSION2 = 2;
+enum LD_SUP_VERSION3 = 3;
+enum LD_SUP_VCURRENT = LD_SUP_VERSION3;
+
+enum LD_SUP_DERIVED   = 0x1;
+enum LD_SUP_INHERITED = 0x2;
+enum LD_SUP_EXTRACTED = 0x4;
+
+enum LM_ID_BASE = 0x00;
+enum LM_ID_LDSO = 0x01;
+enum LM_ID_NUM  = 2;
+
+enum LM_ID_BRAND = 0xfd;
+enum LM_ID_NONE  = 0xfe;
+enum LM_ID_NEWLM = 0xff;
+
+enum LAV_NONE     = 0;
+enum LAV_VERSION1 = 1;
+enum LAV_VERSION2 = 2;
+enum LAV_VERSION3 = 3;
+enum LAV_VERSION4 = 4;
+enum LAV_VERSION5 = 5;
+enum LAV_CURRENT  = LAV_VERSION5;
+enum LAV_NUM      = 6;
+
+enum LA_FLG_BINDTO   = 0x0001;
+enum LA_FLG_BINDFROM = 0x0002;
+
+enum LA_SYMB_NOPLTENTER = 0x0001;
+enum LA_SYMB_NOPLTEXIT  = 0x0002;
+enum LA_SYMB_STRUCTCALL = 0x0004;
+enum LA_SYMB_DLSYM      = 0x0008;
+enum LA_SYMB_ALTVALUE   = 0x0010;
+
+enum LA_SER_ORIG    = 0x001;
+enum LA_SER_LIBPATH = 0x002;
+enum LA_SER_RUNPATH = 0x004;
+enum LA_SER_CONFIG  = 0x008;
+enum LA_SER_DEFAULT = 0x040;
+enum LA_SER_SECURE  = 0x080;
+
+enum LA_SER_MASK    = 0xfff;
+
+enum LA_ACT_CONSISTENT = 0x00;
+enum LA_ACT_ADD        = 0x01;
+enum LA_ACT_DELETE     = 0x02;
+enum LA_ACT_MAX        = 3;
+
+version(D_LP64)
+    alias long lagreg_t;
+else
+    alias int lagreg_t;
+
+struct _la_sparc_regs
+{
+    lagreg_t  lr_rego0;
+    lagreg_t  lr_rego1;
+    lagreg_t  lr_rego2;
+    lagreg_t  lr_rego3;
+    lagreg_t  lr_rego4;
+    lagreg_t  lr_rego5;
+    lagreg_t  lr_rego6;
+    lagreg_t  lr_rego7;
+}
+
+version(D_LP64)
+{
+    alias _la_sparc_regs La_sparcv9_regs;
+    struct La_amd64_regs
+    {
+        lagreg_t  lr_rsp;
+        lagreg_t  lr_rbp;
+        lagreg_t  lr_rdi;
+        lagreg_t  lr_rsi;
+        lagreg_t  lr_rdx;
+        lagreg_t  lr_rcx;
+        lagreg_t  lr_r8;
+        lagreg_t  lr_r9;
+    }
+}
+else
+{
+    alias _la_sparc_regs La_sparcv8_regs;
+    struct La_i86_regs
+    {
+        lagreg_t  lr_esp;
+        lagreg_t  lr_ebp;
+    }
+}
+
+uint la_version(uint);
+void la_activity(uintptr_t*, uint);
+void la_preinit(uintptr_t*);
+char* la_objsearch(in char*, uintptr_t*, uint);
+uint la_objopen(Link_map*, Lmid_t, uintptr_t*);
+uint la_objclose(uintptr_t*);
+int la_objfilter(uintptr_t*, in char*, uintptr_t*, uint);
+
+version(D_LP64)
+{
+uintptr_t la_amd64_pltenter(Elf64_Sym*, uint, uintptr_t*, uintptr_t*, La_amd64_regs*, uint*, in char*);
+uintptr_t la_symbind64(Elf64_Sym*, uint, uintptr_t*, uintptr_t*, uint*, in char*);
+uintptr_t la_sparcv9_pltenter(Elf64_Sym*, uint, uintptr_t*, uintptr_t*, La_sparcv9_regs*, uint*, in char*);
+uintptr_t la_pltexit64(Elf64_Sym*, uint, uintptr_t*, uintptr_t*, uintptr_t, in char*);
+}
+else
+{
+uintptr_t la_symbind32(Elf32_Sym*, uint, uintptr_t*, uintptr_t*, uint*);
+uintptr_t la_sparcv8_pltenter(Elf32_Sym*, uint, uintptr_t*, uintptr_t*, La_sparcv8_regs*, uint*);
+uintptr_t la_i86_pltenter(Elf32_Sym*, uint, uintptr_t*, uintptr_t*, La_i86_regs*, uint*);
+uintptr_t la_pltexit(Elf32_Sym*, uint, uintptr_t*, uintptr_t*, uintptr_t);
+}
+
+template ElfW(string type)
+{
+    version (D_LP64)
+        mixin("alias Elf64_"~type~" ElfW;");
+    else
+        mixin("alias Elf32_"~type~" ElfW;");
+}
+
+struct dl_phdr_info {
+    ElfW!"Addr"        dlpi_addr;
+    char*              dlpi_name;
+    ElfW!"Phdr"*       dlpi_phdr;
+    ElfW!"Half"        dlpi_phnum;
+    uint64_t           dlpi_adds;
+    uint64_t           dlpi_subs;
+};
+
+private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb;
+private alias extern(C) int function(dl_phdr_info*, size_t, void *) @nogc dl_iterate_phdr_cb_ngc;
+extern int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data);
+extern int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc;
diff --git a/libphobos/libdruntime/core/sys/solaris/sys/elf.d b/libphobos/libdruntime/core/sys/solaris/sys/elf.d
new file mode 100644
index 00000000000..5b59f22abd2
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/sys/elf.d
@@ -0,0 +1,657 @@
+/**
+ * D header file for Solaris.
+ *
+ * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/sys/elf_386.h, illumos sys/elf_386.h)
+ */
+module core.sys.solaris.sys.elf;
+
+version (Solaris):
+extern (C):
+nothrow:
+
+public import core.sys.solaris.sys.elftypes;
+
+enum ELF32_FSZ_ADDR  = 4;
+enum ELF32_FSZ_HALF  = 2;
+enum ELF32_FSZ_OFF   = 4;
+enum ELF32_FSZ_SWORD = 4;
+enum ELF32_FSZ_WORD  = 4;
+
+enum ELF64_FSZ_ADDR   = 8;
+enum ELF64_FSZ_HALF   = 2;
+enum ELF64_FSZ_OFF    = 8;
+enum ELF64_FSZ_SWORD  = 4;
+enum ELF64_FSZ_WORD   = 4;
+enum ELF64_FSZ_SXWORD = 8;
+enum ELF64_FSZ_XWORD  = 8;
+
+enum EI_NIDENT = 16;
+
+struct Elf32_Ehdr
+{
+    char[EI_NIDENT] e_ident;
+    Elf32_Half    e_type;
+    Elf32_Half    e_machine;
+    Elf32_Word    e_version;
+    Elf32_Addr    e_entry;
+    Elf32_Off     e_phoff;
+    Elf32_Off     e_shoff;
+    Elf32_Word    e_flags;
+    Elf32_Half    e_ehsize;
+    Elf32_Half    e_phentsize;
+    Elf32_Half    e_phnum;
+    Elf32_Half    e_shentsize;
+    Elf32_Half    e_shnum;
+    Elf32_Half    e_shstrndx;
+}
+
+struct Elf64_Ehdr
+{
+    char[EI_NIDENT] e_ident;
+    Elf64_Half    e_type;
+    Elf64_Half    e_machine;
+    Elf64_Word    e_version;
+    Elf64_Addr    e_entry;
+    Elf64_Off     e_phoff;
+    Elf64_Off     e_shoff;
+    Elf64_Word    e_flags;
+    Elf64_Half    e_ehsize;
+    Elf64_Half    e_phentsize;
+    Elf64_Half    e_phnum;
+    Elf64_Half    e_shentsize;
+    Elf64_Half    e_shnum;
+    Elf64_Half    e_shstrndx;
+}
+
+enum EI_MAG0       = 0;
+enum EI_MAG1       = 1;
+enum EI_MAG2       = 2;
+enum EI_MAG3       = 3;
+enum EI_CLASS      = 4;
+enum EI_DATA       = 5;
+enum EI_VERSION    = 6;
+enum EI_OSABI      = 7;
+enum EI_ABIVERSION = 8;
+enum EI_PAD        = 9;
+
+enum ELFMAG0 = 0x7f;
+enum ELFMAG1 = 'E';
+enum ELFMAG2 = 'L';
+enum ELFMAG3 = 'F';
+enum ELFMAG  = "\177ELF";
+enum SELFMAG = 4;
+
+enum ELFCLASSNONE = 0;
+enum ELFCLASS32   = 1;
+enum ELFCLASS64   = 2;
+enum ELFCLASSNUM  = 3;
+
+enum ELFDATANONE = 0;
+enum ELFDATA2LSB = 1;
+enum ELFDATA2MSB = 2;
+enum ELFDATANUM  = 3;
+
+enum ET_NONE       = 0;
+enum ET_REL        = 1;
+enum ET_EXEC       = 2;
+enum ET_DYN        = 3;
+enum ET_CORE       = 4;
+enum ET_NUM        = 5;
+enum ET_LOOS       = 0xfe00;
+enum ET_LOSUNW     = 0xfeff;
+enum ET_SUNWPSEUDO = 0xfeff;
+enum ET_HISUNW     = 0xfeff;
+enum ET_HIOS       = 0xfeff;
+enum ET_LOPROC     = 0xff00;
+enum ET_HIPROC     = 0xffff;
+
+enum EM_NONE        = 0;
+enum EM_M32         = 1;
+enum EM_SPARC       = 2;
+enum EM_386         = 3;
+enum EM_68K         = 4;
+enum EM_88K         = 5;
+enum EM_486         = 6;
+enum EM_860         = 7;
+enum EM_MIPS        = 8;
+enum EM_S370        = 9;
+enum EM_MIPS_RS3_LE = 10;
+enum EM_RS6000      = 11;
+enum EM_UNKNOWN12   = 12;
+enum EM_UNKNOWN13   = 13;
+enum EM_UNKNOWN14   = 14;
+enum EM_PA_RISC     = 15;
+enum EM_PARISC      = EM_PA_RISC;
+enum EM_nCUBE       = 16;
+enum EM_VPP500      = 17;
+enum EM_SPARC32PLUS = 18;
+enum EM_960         = 19;
+enum EM_PPC         = 20;
+enum EM_PPC64       = 21;
+enum EM_S390        = 22;
+enum EM_UNKNOWN22   = EM_S390;
+enum EM_UNKNOWN23   = 23;
+enum EM_UNKNOWN24   = 24;
+enum EM_UNKNOWN25   = 25;
+enum EM_UNKNOWN26   = 26;
+enum EM_UNKNOWN27   = 27;
+enum EM_UNKNOWN28   = 28;
+enum EM_UNKNOWN29   = 29;
+enum EM_UNKNOWN30   = 30;
+enum EM_UNKNOWN31   = 31;
+enum EM_UNKNOWN32   = 32;
+enum EM_UNKNOWN33   = 33;
+enum EM_UNKNOWN34   = 34;
+enum EM_UNKNOWN35   = 35;
+enum EM_V800        = 36;
+enum EM_FR20        = 37;
+enum EM_RH32        = 38;
+enum EM_RCE         = 39;
+enum EM_ARM         = 40;
+enum EM_ALPHA       = 41;
+enum EM_SH          = 42;
+enum EM_SPARCV9     = 43;
+enum EM_TRICORE     = 44;
+enum EM_ARC         = 45;
+enum EM_H8_300      = 46;
+enum EM_H8_300H     = 47;
+enum EM_H8S         = 48;
+enum EM_H8_500      = 49;
+enum EM_IA_64       = 50;
+enum EM_MIPS_X      = 51;
+enum EM_COLDFIRE    = 52;
+enum EM_68HC12      = 53;
+enum EM_MMA         = 54;
+enum EM_PCP         = 55;
+enum EM_NCPU        = 56;
+enum EM_NDR1        = 57;
+enum EM_STARCORE    = 58;
+enum EM_ME16        = 59;
+enum EM_ST100       = 60;
+enum EM_TINYJ       = 61;
+enum EM_AMD64       = 62;
+enum EM_X86_64      = EM_AMD64;
+enum EM_PDSP        = 63;
+enum EM_UNKNOWN64   = 64;
+enum EM_UNKNOWN65   = 65;
+enum EM_FX66        = 66;
+enum EM_ST9PLUS     = 67;
+enum EM_ST7         = 68;
+enum EM_68HC16      = 69;
+enum EM_68HC11      = 70;
+enum EM_68HC08      = 71;
+enum EM_68HC05      = 72;
+enum EM_SVX         = 73;
+enum EM_ST19        = 74;
+enum EM_VAX         = 75;
+enum EM_CRIS        = 76;
+enum EM_JAVELIN     = 77;
+enum EM_FIREPATH    = 78;
+enum EM_ZSP         = 79;
+enum EM_MMIX        = 80;
+enum EM_HUANY       = 81;
+enum EM_PRISM       = 82;
+enum EM_AVR         = 83;
+enum EM_FR30        = 84;
+enum EM_D10V        = 85;
+enum EM_D30V        = 86;
+enum EM_V850        = 87;
+enum EM_M32R        = 88;
+enum EM_MN10300     = 89;
+enum EM_MN10200     = 90;
+enum EM_PJ          = 91;
+enum EM_OPENRISC    = 92;
+enum EM_ARC_A5      = 93;
+enum EM_XTENSA      = 94;
+enum EM_NUM         = 95;
+
+enum EV_NONE    = 0;
+enum EV_CURRENT = 1;
+enum EV_NUM     = 2;
+
+
+enum ELFOSABI_NONE        = 0;
+enum ELFOSABI_SYSV        = ELFOSABI_NONE;
+enum ELFOSABI_HPUX        = 1;
+enum ELFOSABI_NETBSD      = 2;
+enum ELFOSABI_LINUX       = 3;
+enum ELFOSABI_UNKNOWN4    = 4;
+enum ELFOSABI_UNKNOWN5    = 5;
+enum ELFOSABI_SOLARIS     = 6;
+enum ELFOSABI_AIX         = 7;
+enum ELFOSABI_IRIX        = 8;
+enum ELFOSABI_FREEBSD     = 9;
+enum ELFOSABI_TRU64       = 10;
+enum ELFOSABI_MODESTO     = 11;
+enum ELFOSABI_OPENBSD     = 12;
+enum ELFOSABI_OPENVMS     = 13;
+enum ELFOSABI_NSK         = 14;
+enum ELFOSABI_AROS        = 15;
+enum ELFOSABI_ARM         = 97;
+enum ELFOSABI_STANDALONE  = 255;
+
+enum EAV_SUNW_NONE    = 0;
+enum EAV_SUNW_CURRENT = 1;
+enum EAV_SUNW_NUM     = 2;
+
+struct Elf32_Phdr
+{
+    Elf32_Word    p_type;
+    Elf32_Off     p_offset;
+    Elf32_Addr    p_vaddr;
+    Elf32_Addr    p_paddr;
+    Elf32_Word    p_filesz;
+    Elf32_Word    p_memsz;
+    Elf32_Word    p_flags;
+    Elf32_Word    p_align;
+}
+
+struct Elf64_Phdr
+{
+    Elf64_Word    p_type;
+    Elf64_Word    p_flags;
+    Elf64_Off     p_offset;
+    Elf64_Addr    p_vaddr;
+    Elf64_Addr    p_paddr;
+    Elf64_Xword   p_filesz;
+    Elf64_Xword   p_memsz;
+    Elf64_Xword   p_align;
+}
+
+enum PT_NULL    = 0;
+enum PT_LOAD    = 1;
+enum PT_DYNAMIC = 2;
+enum PT_INTERP  = 3;
+enum PT_NOTE    = 4;
+enum PT_SHLIB   = 5;
+enum PT_PHDR    = 6;
+enum PT_TLS     = 7;
+enum PT_NUM     = 8;
+
+enum PT_LOOS    = 0x60000000;
+
+enum PT_SUNW_UNWIND   = 0x6464e550;
+enum PT_SUNW_EH_FRAME = 0x6474e550;
+enum PT_GNU_EH_FRAME  = PT_SUNW_EH_FRAME;
+
+enum PT_GNU_STACK = 0x6474e551;
+enum PT_GNU_RELRO = 0x6474e552;
+
+enum PT_LOSUNW     = 0x6ffffffa;
+enum PT_SUNWBSS    = 0x6ffffffa;
+enum PT_SUNWSTACK  = 0x6ffffffb;
+enum PT_SUNWDTRACE = 0x6ffffffc;
+enum PT_SUNWCAP    = 0x6ffffffd;
+enum PT_HISUNW     = 0x6fffffff;
+enum PT_HIOS       = 0x6fffffff;
+enum PT_LOPROC     = 0x70000000;
+enum PT_HIPROC     = 0x7fffffff;
+
+enum PF_R = 0x4;
+enum PF_W = 0x2;
+enum PF_X = 0x1;
+
+enum PF_MASKOS   = 0x0ff00000;
+enum PF_MASKPROC = 0xf0000000;
+
+enum PF_SUNW_FAILURE = 0x00100000;
+enum PF_SUNW_KILLED  = 0x00200000;
+enum PF_SUNW_SIGINFO = 0x00400000;
+
+enum PN_XNUM = 0xffff;
+
+struct Elf32_Shdr
+{
+    Elf32_Word    sh_name;
+    Elf32_Word    sh_type;
+    Elf32_Word    sh_flags;
+    Elf32_Addr    sh_addr;
+    Elf32_Off     sh_offset;
+    Elf32_Word    sh_size;
+    Elf32_Word    sh_link;
+    Elf32_Word    sh_info;
+    Elf32_Word    sh_addralign;
+    Elf32_Word    sh_entsize;
+}
+
+struct Elf64_Shdr
+{
+    Elf64_Word    sh_name;
+    Elf64_Word    sh_type;
+    Elf64_Xword   sh_flags;
+    Elf64_Addr    sh_addr;
+    Elf64_Off     sh_offset;
+    Elf64_Xword   sh_size;
+    Elf64_Word    sh_link;
+    Elf64_Word    sh_info;
+    Elf64_Xword   sh_addralign;
+    Elf64_Xword   sh_entsize;
+}
+
+enum SHT_NULL          = 0;
+enum SHT_PROGBITS      = 1;
+enum SHT_SYMTAB        = 2;
+enum SHT_STRTAB        = 3;
+enum SHT_RELA          = 4;
+enum SHT_HASH          = 5;
+enum SHT_DYNAMIC       = 6;
+enum SHT_NOTE          = 7;
+enum SHT_NOBITS        = 8;
+enum SHT_REL           = 9;
+enum SHT_SHLIB         = 10;
+enum SHT_DYNSYM        = 11;
+enum SHT_UNKNOWN12     = 12;
+enum SHT_UNKNOWN13     = 13;
+enum SHT_INIT_ARRAY    = 14;
+enum SHT_FINI_ARRAY    = 15;
+enum SHT_PREINIT_ARRAY = 16;
+enum SHT_GROUP         = 17;
+enum SHT_SYMTAB_SHNDX  = 18;
+enum SHT_NUM           = 19;
+
+enum SHT_LOOS           = 0x60000000;
+enum SHT_LOSUNW         = 0x6fffffef;
+enum SHT_SUNW_capchain  = 0x6fffffef;
+enum SHT_SUNW_capinfo   = 0x6ffffff0;
+enum SHT_SUNW_symsort   = 0x6ffffff1;
+enum SHT_SUNW_tlssort   = 0x6ffffff2;
+enum SHT_SUNW_LDYNSYM   = 0x6ffffff3;
+enum SHT_SUNW_dof       = 0x6ffffff4;
+enum SHT_SUNW_cap       = 0x6ffffff5;
+enum SHT_SUNW_SIGNATURE = 0x6ffffff6;
+enum SHT_SUNW_ANNOTATE  = 0x6ffffff7;
+enum SHT_SUNW_DEBUGSTR  = 0x6ffffff8;
+enum SHT_SUNW_DEBUG     = 0x6ffffff9;
+enum SHT_SUNW_move      = 0x6ffffffa;
+enum SHT_SUNW_COMDAT    = 0x6ffffffb;
+enum SHT_SUNW_syminfo   = 0x6ffffffc;
+enum SHT_SUNW_verdef    = 0x6ffffffd;
+enum SHT_GNU_verdef     = SHT_SUNW_verdef;
+enum SHT_SUNW_verneed   = 0x6ffffffe;
+enum SHT_GNU_verneed    = SHT_SUNW_verneed;
+enum SHT_SUNW_versym    = 0x6fffffff;
+enum SHT_GNU_versym     = SHT_SUNW_versym;
+enum SHT_HISUNW         = 0x6fffffff;
+enum SHT_HIOS           = 0x6fffffff;
+enum SHT_GNU_ATTRIBUTES = 0x6ffffff5;
+enum SHT_GNU_HASH       = 0x6ffffff6;
+enum SHT_GNU_LIBLIST    = 0x6ffffff7;
+enum SHT_CHECKSUM       = 0x6ffffff8;
+enum SHT_LOPROC         = 0x70000000;
+enum SHT_HIPROC         = 0x7fffffff;
+enum SHT_LOUSER         = 0x80000000;
+enum SHT_HIUSER         = 0xffffffff;
+
+enum SHF_WRITE            = 0x01;
+enum SHF_ALLOC            = 0x02;
+enum SHF_EXECINSTR        = 0x04;
+enum SHF_MERGE            = 0x10;
+enum SHF_STRINGS          = 0x20;
+enum SHF_INFO_LINK        = 0x40;
+enum SHF_LINK_ORDER       = 0x80;
+enum SHF_OS_NONCONFORMING = 0x100;
+enum SHF_GROUP            = 0x200;
+enum SHF_TLS              = 0x400;
+
+enum SHF_MASKOS = 0x0ff00000;
+
+enum SHF_MASKPROC = 0xf0000000;
+
+enum SHN_UNDEF       = 0;
+enum SHN_LORESERVE   = 0xff00;
+enum SHN_LOPROC      = 0xff00;
+enum SHN_HIPROC      = 0xff1f;
+enum SHN_LOOS        = 0xff20;
+enum SHN_LOSUNW      = 0xff3f;
+enum SHN_SUNW_IGNORE = 0xff3f;
+enum SHN_HISUNW      = 0xff3f;
+enum SHN_HIOS        = 0xff3f;
+enum SHN_ABS         = 0xfff1;
+enum SHN_COMMON      = 0xfff2;
+enum SHN_XINDEX      = 0xffff;
+enum SHN_HIRESERVE   = 0xffff;
+
+struct Elf32_Sym
+{
+    Elf32_Word    st_name;
+    Elf32_Addr    st_value;
+    Elf32_Word    st_size;
+    ubyte         st_info;
+    ubyte         st_other;
+    Elf32_Half    st_shndx;
+}
+
+struct Elf64_Sym
+{
+    Elf64_Word    st_name;
+    ubyte         st_info;
+    ubyte         st_other;
+    Elf64_Half    st_shndx;
+    Elf64_Addr    st_value;
+    Elf64_Xword   st_size;
+}
+
+enum STN_UNDEF  = 0;
+
+extern (D)
+{
+    auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
+    auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; }
+    auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); }
+    alias ELF32_ST_BIND ELF64_ST_BIND;
+    alias ELF32_ST_TYPE ELF64_ST_TYPE;
+    alias ELF32_ST_INFO ELF64_ST_INFO;
+}
+
+enum STB_LOCAL  = 0;
+enum STB_GLOBAL = 1;
+enum STB_WEAK   = 2;
+enum STB_NUM    = 3;
+enum STB_LOPROC = 13;
+enum STB_HIPROC = 15;
+
+enum STT_NOTYPE  = 0;
+enum STT_OBJECT  = 1;
+enum STT_FUNC    = 2;
+enum STT_SECTION = 3;
+enum STT_FILE    = 4;
+enum STT_COMMON  = 5;
+enum STT_TLS     = 6;
+enum STT_NUM     = 7;
+enum STT_LOOS    = 10;
+enum STT_HIOS    = 12;
+enum STT_LOPROC  = 13;
+enum STT_HIPROC  = 15;
+
+extern (D)
+{
+    auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x07; }
+    alias ELF32_ST_VISIBILITY ELF64_ST_VISIBILITY;
+}
+
+enum STV_DEFAULT   = 0;
+enum STV_INTERNAL  = 1;
+enum STV_HIDDEN    = 2;
+enum STV_PROTECTED = 3;
+enum STV_EXPORTED  = 4;
+enum STV_SINGLETON = 5;
+enum STV_ELIMINATE = 6;
+enum STV_NUM       = 7;
+
+struct Elf32_Rel
+{
+    Elf32_Addr    r_offset;
+    Elf32_Word    r_info;
+}
+
+struct Elf32_Rela
+{
+    Elf32_Addr    r_offset;
+    Elf32_Word    r_info;
+    Elf32_Sword   r_addend;
+}
+
+struct Elf64_Rel
+{
+    Elf64_Addr    r_offset;
+    Elf64_Xword   r_info;
+}
+
+struct Elf64_Rela
+{
+    Elf64_Addr    r_offset;
+    Elf64_Xword   r_info;
+    Elf64_Sxword  r_addend;
+}
+
+extern (D)
+{
+    auto ELF32_R_SYM(V)(V val) { return val >> 8; }
+    auto ELF32_R_TYPE(V)(V val) { return val & 0xff; }
+    auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); }
+
+    auto ELF64_R_SYM(I)(I i) { return i >> 32; }
+    auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; }
+    auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type); }
+
+    auto ELF64_R_TYPE_DATA(I)(I i) { return (i << 32) >> 40; }
+    auto ELF64_R_TYPE_ID(I)(I i) { return (i << 56) >> 56; }
+    auto ELF64_R_TYPE_INFO(S, T)(S sym, T type) { return (sym <<8) + (type); }
+}
+
+enum GRP_COMDAT = 0x01;
+
+struct Elf32_Nhdr
+{
+    Elf32_Word n_namesz;
+    Elf32_Word n_descsz;
+    Elf32_Word n_type;
+}
+
+struct Elf64_Nhdr
+{
+    Elf64_Word n_namesz;
+    Elf64_Word n_descsz;
+    Elf64_Word n_type;
+}
+
+struct Elf32_Move
+{
+    Elf32_Lword m_value;
+    Elf32_Word  m_info;
+    Elf32_Word  m_poffset;
+    Elf32_Half  m_repeat;
+    Elf32_Half  m_stride;
+}
+
+extern (D)
+{
+    auto ELF32_M_SYM(I)(I info) { return info >> 8; }
+    auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; }
+    auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; }
+}
+
+struct Elf64_Move
+{
+    Elf64_Lword m_value;
+    Elf64_Xword m_info;
+    Elf64_Xword m_poffset;
+    Elf64_Half  m_repeat;
+    Elf64_Half  m_stride;
+}
+
+alias ELF32_M_SYM ELF64_M_SYM;
+alias ELF32_M_SIZE ELF64_M_SIZE;
+alias ELF32_M_INFO ELF64_M_INFO;
+
+struct Elf32_Cap
+{
+    Elf32_Word  c_tag;
+    union c_un
+    {
+        Elf32_Word  c_val;
+        Elf32_Addr  c_ptr;
+    }
+}
+
+alias Elf32_Word Elf32_Capinfo;
+alias Elf32_Word Elf32_Capchain;
+
+
+alias ELF32_M_SYM ELF32_C_SYM;
+alias ELF32_M_SIZE ELF32_C_GROUP;
+alias ELF32_M_INFO ELF32_C_INFO;
+
+struct Elf64_Cap
+{
+    Elf64_Xword c_tag;
+    union c_un
+    {
+        Elf64_Xword c_val;
+        Elf64_Addr  c_ptr;
+    }
+}
+
+alias Elf64_Xword Elf64_Capinfo;
+alias Elf64_Word  Elf64_Capchain;
+
+/*
+ *  Macros to compose and decompose values for capabilities info.
+ *
+ *  sym = ELF64_C_SYM(info)
+ *  grp = ELF64_C_GROUP(info)
+ *  info = ELF64_C_INFO(sym, grp)
+ */
+extern (D)
+{
+    auto ELF64_C_SYM(I)(I info) { return info >> 32; }
+    auto ELF64_C_GROUP(I)(I info) { return cast(Elf64_Word)info; }
+    auto ELF64_C_INFO(S, G)(S sym, G grp) { return (sym << 32) + grp; }
+}
+
+enum CAPINFO_NONE    = 0;
+enum CAPINFO_CURRENT = 1;
+enum CAPINFO_NUM     = 2;
+
+enum CAPCHAIN_NONE    = 0;
+enum CAPCHAIN_CURRENT = 1;
+enum CAPCHAIN_NUM     = 2;
+
+enum CAPINFO_SUNW_GLOB = 0xff;
+
+enum CA_SUNW_NULL = 0;
+enum CA_SUNW_HW_1 = 1;
+enum CA_SUNW_SF_1 = 2;
+enum CA_SUNW_HW_2 = 3;
+enum CA_SUNW_PLAT = 4;
+enum CA_SUNW_MACH = 5;
+enum CA_SUNW_ID   = 6;
+enum CA_SUNW_NUM  = 7;
+
+enum SF1_SUNW_FPKNWN = 0x001;
+enum SF1_SUNW_FPUSED = 0x002;
+enum SF1_SUNW_ADDR32 = 0x004;
+enum SF1_SUNW_MASK   = 0x007;
+
+enum NT_PRSTATUS   = 1;
+enum NT_PRFPREG    = 2;
+enum NT_PRPSINFO   = 3;
+enum NT_PRXREG     = 4;
+enum NT_PLATFORM   = 5;
+enum NT_AUXV       = 6;
+enum NT_GWINDOWS   = 7;
+enum NT_ASRS       = 8;
+enum NT_LDT        = 9;
+enum NT_PSTATUS    = 10;
+enum NT_PSINFO     = 13;
+enum NT_PRCRED     = 14;
+enum NT_UTSNAME    = 15;
+enum NT_LWPSTATUS  = 16;
+enum NT_LWPSINFO   = 17;
+enum NT_PRPRIV     = 18;
+enum NT_PRPRIVINFO = 19;
+enum NT_CONTENT    = 20;
+enum NT_ZONENAME   = 21;
+enum NT_FDINFO     = 22;
+enum NT_SPYMASTER  = 23;
+enum NT_NUM        = 23;
diff --git a/libphobos/libdruntime/core/sys/solaris/sys/elf_386.d b/libphobos/libdruntime/core/sys/solaris/sys/elf_386.d
new file mode 100644
index 00000000000..94a07411c52
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/sys/elf_386.d
@@ -0,0 +1,82 @@
+/**
+ * D header file for Solaris.
+ *
+ * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/sys/elf_386.h, illumos sys/elf_386.h)
+ */
+module core.sys.solaris.sys.elf_386;
+
+version (Solaris):
+extern (C):
+nothrow:
+
+enum R_386_NONE         = 0;
+enum R_386_32           = 1;
+enum R_386_PC32         = 2;
+enum R_386_GOT32        = 3;
+enum R_386_PLT32        = 4;
+enum R_386_COPY         = 5;
+enum R_386_GLOB_DAT     = 6;
+enum R_386_JMP_SLOT     = 7;
+enum R_386_RELATIVE     = 8;
+enum R_386_GOTOFF       = 9;
+enum R_386_GOTPC        = 10;
+enum R_386_32PLT        = 11;
+enum R_386_TLS_GD_PLT   = 12;
+enum R_386_TLS_LDM_PLT  = 13;
+enum R_386_TLS_TPOFF    = 14;
+enum R_386_TLS_IE       = 15;
+enum R_386_TLS_GOTIE    = 16;
+enum R_386_TLS_LE       = 17;
+enum R_386_TLS_GD       = 18;
+enum R_386_TLS_LDM      = 19;
+enum R_386_16           = 20;
+enum R_386_PC16         = 21;
+enum R_386_8            = 22;
+enum R_386_PC8          = 23;
+enum R_386_UNKNOWN24    = 24;
+enum R_386_UNKNOWN25    = 25;
+enum R_386_UNKNOWN26    = 26;
+enum R_386_UNKNOWN27    = 27;
+enum R_386_UNKNOWN28    = 28;
+enum R_386_UNKNOWN29    = 29;
+enum R_386_UNKNOWN30    = 30;
+enum R_386_UNKNOWN31    = 31;
+enum R_386_TLS_LDO_32   = 32;
+enum R_386_UNKNOWN33    = 33;
+enum R_386_UNKNOWN34    = 34;
+enum R_386_TLS_DTPMOD32 = 35;
+enum R_386_TLS_DTPOFF32 = 36;
+enum R_386_UNKNOWN37    = 37;
+enum R_386_SIZE32       = 38;
+enum R_386_NUM          = 39;
+
+enum ELF_386_MAXPGSZ = 0x10000;
+
+enum SHF_ORDERED = 0x40000000;
+enum SHF_EXCLUDE = 0x80000000;
+
+enum SHN_BEFORE = 0xff00;
+enum SHN_AFTER  = 0xff01;
+
+enum M_PLT_INSSIZE  = 6;
+enum M_PLT_XNumber  = 1;
+enum M_GOT_XDYNAMIC = 0;
+enum M_GOT_XLINKMAP = 1;
+enum M_GOT_XRTLD    = 2;
+enum M_GOT_XNumber  = 3;
+
+enum M32_WORD_ALIGN   = 4;
+enum M32_PLT_ENTSIZE  = 16;
+enum M32_PLT_ALIGN    = M32_WORD_ALIGN;
+enum M32_GOT_ENTSIZE  = 4;
+enum M32_PLT_RESERVSZ = (M_PLT_XNumber * M32_PLT_ENTSIZE);
+
+version(_ELF64) {}
+else
+{
+    enum M_WORD_ALIGN   = M32_WORD_ALIGN;
+    enum M_PLT_ENTSIZE  = M32_PLT_ENTSIZE;
+    enum M_PLT_ALIGN    = M32_PLT_ALIGN;
+    enum M_PLT_RESERVSZ = M32_PLT_RESERVSZ;
+    enum M_GOT_ENTSIZE  = M32_GOT_ENTSIZE;
+}
diff --git a/libphobos/libdruntime/core/sys/solaris/sys/elf_SPARC.d b/libphobos/libdruntime/core/sys/solaris/sys/elf_SPARC.d
new file mode 100644
index 00000000000..1360d05db84
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/sys/elf_SPARC.d
@@ -0,0 +1,181 @@
+/**
+ * D header file for Solaris.
+ *
+ * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/sys/elf_SPARC.h, illumos sys/elf_SPARC.h)
+ */
+module core.sys.solaris.sys.elf_SPARC;
+
+version (Solaris):
+extern (C):
+nothrow:
+
+enum EF_SPARC_32PLUS_MASK = 0xffff00;
+enum EF_SPARC_32PLUS      = 0x000100;
+enum EF_SPARC_EXT_MASK    = 0xffff00;
+enum EF_SPARC_SUN_US1     = 0x000200;
+enum EF_SPARC_HAL_R1      = 0x000400;
+enum EF_SPARC_SUN_US3     = 0x000800;
+
+enum EF_SPARCV9_MM  = 0x3;
+enum EF_SPARCV9_TSO = 0x0;
+enum EF_SPARCV9_PSO = 0x1;
+enum EF_SPARCV9_RMO = 0x2;
+
+enum R_SPARC_NONE             = 0;
+enum R_SPARC_8                = 1;
+enum R_SPARC_16               = 2;
+enum R_SPARC_32               = 3;
+enum R_SPARC_DISP8            = 4;
+enum R_SPARC_DISP16           = 5;
+enum R_SPARC_DISP32           = 6;
+enum R_SPARC_WDISP30          = 7;
+enum R_SPARC_WDISP22          = 8;
+enum R_SPARC_HI22             = 9;
+enum R_SPARC_22               = 10;
+enum R_SPARC_13               = 11;
+enum R_SPARC_LO10             = 12;
+enum R_SPARC_GOT10            = 13;
+enum R_SPARC_GOT13            = 14;
+enum R_SPARC_GOT22            = 15;
+enum R_SPARC_PC10             = 16;
+enum R_SPARC_PC22             = 17;
+enum R_SPARC_WPLT30           = 18;
+enum R_SPARC_COPY             = 19;
+enum R_SPARC_GLOB_DAT         = 20;
+enum R_SPARC_JMP_SLOT         = 21;
+enum R_SPARC_RELATIVE         = 22;
+enum R_SPARC_UA32             = 23;
+enum R_SPARC_PLT32            = 24;
+enum R_SPARC_HIPLT22          = 25;
+enum R_SPARC_LOPLT10          = 26;
+enum R_SPARC_PCPLT32          = 27;
+enum R_SPARC_PCPLT22          = 28;
+enum R_SPARC_PCPLT10          = 29;
+enum R_SPARC_10               = 30;
+enum R_SPARC_11               = 31;
+enum R_SPARC_64               = 32;
+enum R_SPARC_OLO10            = 33;
+enum R_SPARC_HH22             = 34;
+enum R_SPARC_HM10             = 35;
+enum R_SPARC_LM22             = 36;
+enum R_SPARC_PC_HH22          = 37;
+enum R_SPARC_PC_HM10          = 38;
+enum R_SPARC_PC_LM22          = 39;
+enum R_SPARC_WDISP16          = 40;
+enum R_SPARC_WDISP19          = 41;
+enum R_SPARC_GLOB_JMP         = 42;
+enum R_SPARC_7                = 43;
+enum R_SPARC_5                = 44;
+enum R_SPARC_6                = 45;
+enum R_SPARC_DISP64           = 46;
+enum R_SPARC_PLT64            = 47;
+enum R_SPARC_HIX22            = 48;
+enum R_SPARC_LOX10            = 49;
+enum R_SPARC_H44              = 50;
+enum R_SPARC_M44              = 51;
+enum R_SPARC_L44              = 52;
+enum R_SPARC_REGISTER         = 53;
+enum R_SPARC_UA64             = 54;
+enum R_SPARC_UA16             = 55;
+enum R_SPARC_TLS_GD_HI22      = 56;
+enum R_SPARC_TLS_GD_LO10      = 57;
+enum R_SPARC_TLS_GD_ADD       = 58;
+enum R_SPARC_TLS_GD_CALL      = 59;
+enum R_SPARC_TLS_LDM_HI22     = 60;
+enum R_SPARC_TLS_LDM_LO10     = 61;
+enum R_SPARC_TLS_LDM_ADD      = 62;
+enum R_SPARC_TLS_LDM_CALL     = 63;
+enum R_SPARC_TLS_LDO_HIX22    = 64;
+enum R_SPARC_TLS_LDO_LOX10    = 65;
+enum R_SPARC_TLS_LDO_ADD      = 66;
+enum R_SPARC_TLS_IE_HI22      = 67;
+enum R_SPARC_TLS_IE_LO10      = 68;
+enum R_SPARC_TLS_IE_LD        = 69;
+enum R_SPARC_TLS_IE_LDX       = 70;
+enum R_SPARC_TLS_IE_ADD       = 71;
+enum R_SPARC_TLS_LE_HIX22     = 72;
+enum R_SPARC_TLS_LE_LOX10     = 73;
+enum R_SPARC_TLS_DTPMOD32     = 74;
+enum R_SPARC_TLS_DTPMOD64     = 75;
+enum R_SPARC_TLS_DTPOFF32     = 76;
+enum R_SPARC_TLS_DTPOFF64     = 77;
+enum R_SPARC_TLS_TPOFF32      = 78;
+enum R_SPARC_TLS_TPOFF64      = 79;
+enum R_SPARC_GOTDATA_HIX22    = 80;
+enum R_SPARC_GOTDATA_LOX10    = 81;
+enum R_SPARC_GOTDATA_OP_HIX22 = 82;
+enum R_SPARC_GOTDATA_OP_LOX10 = 83;
+enum R_SPARC_GOTDATA_OP       = 84;
+enum R_SPARC_H34              = 85;
+enum R_SPARC_SIZE32           = 86;
+enum R_SPARC_SIZE64           = 87;
+enum R_SPARC_NUM              = 88;
+
+enum R_SPARC_L34 = R_SPARC_L44;
+
+enum ELF_SPARC_MAXPGSZ   = 0x10000;
+enum ELF_SPARCV9_MAXPGSZ = 0x100000;
+
+enum SHT_SPARC_GOTDATA = 0x70000000;
+
+enum SHF_ORDERED = 0x40000000;
+enum SHF_EXCLUDE = 0x80000000;
+
+enum SHN_BEFORE = 0xff00;
+enum SHN_AFTER  =  0xff01;
+
+enum STT_SPARC_REGISTER = 13;
+
+enum DT_SPARC_REGISTER = 0x70000001;
+
+enum STO_SPARC_REGISTER_G1 = 0x1;
+enum STO_SPARC_REGISTER_G2 = 0x2;
+enum STO_SPARC_REGISTER_G3 = 0x3;
+enum STO_SPARC_REGISTER_G4 = 0x4;
+enum STO_SPARC_REGISTER_G5 = 0x5;
+enum STO_SPARC_REGISTER_G6 = 0x6;
+enum STO_SPARC_REGISTER_G7 = 0x7;
+
+enum M_PLT_INSSIZE  = 4;
+enum M_PLT_XNumber  = 4;
+enum M_GOT_XDYNAMIC = 0;
+enum M_GOT_XNumber  = 1;
+
+enum M32_WORD_ALIGN   = 4;
+enum M32_PLT_ENTSIZE  = 12;
+enum M32_PLT_ALIGN    = M_WORD_ALIGN;
+enum M32_GOT_ENTSIZE  = 4;
+enum M32_GOT_MAXSMALL = 2048;
+enum M32_PLT_RESERVSZ = (M_PLT_XNumber * M32_PLT_ENTSIZE);
+
+enum M64_WORD_ALIGN   = 8;
+enum M64_PLT_ENTSIZE  = 32;
+enum M64_PLT_ALIGN    = 256;
+enum M64_GOT_ENTSIZE  = 8;
+enum M64_GOT_MAXSMALL = 1024;
+enum M64_PLT_RESERVSZ = (M_PLT_XNumber * M64_PLT_ENTSIZE);
+
+enum M64_PLT_NEARPLTS = 0x8000;
+enum M64_PLT_FENTSIZE = 24;
+enum M64_PLT_PSIZE    = 8;
+enum M64_PLT_FBLKCNTS = 160;
+enum M64_PLT_FBLOCKSZ = (M64_PLT_FBLKCNTS * M64_PLT_ENTSIZE);
+
+version(_ELF64)
+{
+    enum M_WORD_ALIGN   = M64_WORD_ALIGN;
+    enum M_PLT_ENTSIZE  = M64_PLT_ENTSIZE;
+    enum M_PLT_ALIGN    = M64_PLT_ALIGN;
+    enum M_PLT_RESERVSZ = M64_PLT_RESERVSZ;
+    enum M_GOT_ENTSIZE  = M64_GOT_ENTSIZE;
+    enum M_GOT_MAXSMALL = M64_GOT_MAXSMALL;
+}
+else
+{
+    enum M_WORD_ALIGN   = M32_WORD_ALIGN;
+    enum M_PLT_ENTSIZE  = M32_PLT_ENTSIZE;
+    enum M_PLT_ALIGN    = M32_PLT_ALIGN;
+    enum M_PLT_RESERVSZ = M32_PLT_RESERVSZ;
+    enum M_GOT_ENTSIZE  = M32_GOT_ENTSIZE;
+    enum M_GOT_MAXSMALL = M32_GOT_MAXSMALL;
+}
\ No newline at end of file
diff --git a/libphobos/libdruntime/core/sys/solaris/sys/elf_amd64.d b/libphobos/libdruntime/core/sys/solaris/sys/elf_amd64.d
new file mode 100644
index 00000000000..4a6b915b943
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/sys/elf_amd64.d
@@ -0,0 +1,111 @@
+/**
+ * D header file for Solaris.
+ *
+ * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/sys/elf_amd64.h, illumos sys/elf_amd64.h)
+ */
+module core.sys.solaris.sys.elf_amd64;
+
+version (Solaris):
+extern (C):
+nothrow:
+
+public import core.sys.solaris.sys.elf_386;
+
+enum R_AMD64_NONE       = 0;
+enum R_AMD64_64         = 1;
+enum R_AMD64_PC32       = 2;
+enum R_AMD64_GOT32      = 3;
+enum R_AMD64_PLT32      = 4;
+enum R_AMD64_COPY       = 5;
+enum R_AMD64_GLOB_DAT   = 6;
+enum R_AMD64_JUMP_SLOT  = 7;
+enum R_AMD64_RELATIVE   = 8;
+enum R_AMD64_GOTPCREL   = 9;
+enum R_AMD64_32         = 10;
+enum R_AMD64_32S        = 11;
+enum R_AMD64_16         = 12;
+enum R_AMD64_PC16       = 13;
+enum R_AMD64_8          = 14;
+enum R_AMD64_PC8        = 15;
+enum R_AMD64_DTPMOD64   = 16;
+enum R_AMD64_DTPOFF64   = 17;
+enum R_AMD64_TPOFF64    = 18;
+enum R_AMD64_TLSGD      = 19;
+enum R_AMD64_TLSLD      = 20;
+enum R_AMD64_DTPOFF32   = 21;
+enum R_AMD64_GOTTPOFF   = 22;
+enum R_AMD64_TPOFF32    = 23;
+enum R_AMD64_PC64       = 24;
+enum R_AMD64_GOTOFF64   = 25;
+enum R_AMD64_GOTPC32    = 26;
+enum R_AMD64_GOT64      = 27;
+enum R_AMD64_GOTPCREL64 = 28;
+enum R_AMD64_GOTPC64    = 29;
+enum R_AMD64_GOTPLT64   = 30;
+enum R_AMD64_PLTOFF64   = 31;
+enum R_AMD64_SIZE32     = 32;
+enum R_AMD64_SIZE64     = 33;
+enum R_AMD64_NUM        = 34;
+
+
+enum R_X86_64_NONE       = R_AMD64_NONE;
+enum R_X86_64_64         = R_AMD64_64;
+enum R_X86_64_PC32       = R_AMD64_PC32;
+enum R_X86_64_GOT32      = R_AMD64_GOT32;
+enum R_X86_64_PLT32      = R_AMD64_PLT32;
+enum R_X86_64_COPY       = R_AMD64_COPY;
+enum R_X86_64_GLOB_DAT   = R_AMD64_GLOB_DAT;
+enum R_X86_64_JUMP_SLOT  = R_AMD64_JUMP_SLOT;
+enum R_X86_64_RELATIVE   = R_AMD64_RELATIVE;
+enum R_X86_64_GOTPCREL   = R_AMD64_GOTPCREL;
+enum R_X86_64_32         = R_AMD64_32;
+enum R_X86_64_32S        = R_AMD64_32S;
+enum R_X86_64_16         = R_AMD64_16;
+enum R_X86_64_PC16       = R_AMD64_PC16;
+enum R_X86_64_8          = R_AMD64_8;
+enum R_X86_64_PC8        = R_AMD64_PC8;
+enum R_X86_64_DTPMOD64   = R_AMD64_DTPMOD64;
+enum R_X86_64_DTPOFF64   = R_AMD64_DTPOFF64;
+enum R_X86_64_TPOFF64    = R_AMD64_TPOFF64;
+enum R_X86_64_TLSGD      = R_AMD64_TLSGD;
+enum R_X86_64_TLSLD      = R_AMD64_TLSLD;
+enum R_X86_64_DTPOFF32   = R_AMD64_DTPOFF32;
+enum R_X86_64_GOTTPOFF   = R_AMD64_GOTTPOFF;
+enum R_X86_64_TPOFF32    = R_AMD64_TPOFF32;
+enum R_X86_64_PC64       = R_AMD64_PC64;
+enum R_X86_64_GOTPC32    = R_AMD64_GOTPC32;
+enum R_X86_64_GOTOFF64   = R_AMD64_GOTOFF64;
+enum R_X86_64_GOT64      = R_AMD64_GOT64;
+enum R_X86_64_GOTPCREL64 = R_AMD64_GOTPCREL64;
+enum R_X86_64_GOTPC64    = R_AMD64_GOTPC64;
+enum R_X86_64_GOTPLT64   = R_AMD64_GOTPLT64;
+enum R_X86_64_PLTOFF64   = R_AMD64_PLTOFF64;
+enum R_X86_64_SIZE32     = R_AMD64_SIZE32;
+enum R_X86_64_SIZE64     = R_AMD64_SIZE64;
+enum R_X86_64_NUM        = R_AMD64_NUM;
+
+enum ELF_AMD64_MAXPGSZ = 0x100000;
+
+enum SHT_AMD64_UNWIND   = 0x70000001;
+enum SHT_X86_64_UNWIND  = SHT_AMD64_UNWIND;
+
+enum SHF_AMD64_LARGE  = 0x10000000;
+enum SHF_X86_64_LARGE = SHF_AMD64_LARGE;
+
+enum SHN_AMD64_LCOMMON  = 0xff02;
+enum SHN_X86_64_LCOMMON = SHN_AMD64_LCOMMON;
+
+enum M64_WORD_ALIGN   = 8;
+enum M64_PLT_ENTSIZE  = M32_PLT_ENTSIZE;
+enum M64_PLT_ALIGN    = M64_WORD_ALIGN;
+enum M64_GOT_ENTSIZE  = 8;
+enum M64_PLT_RESERVSZ = M32_PLT_RESERVSZ;
+
+version(_ELF64)
+{
+    enum M_WORD_ALIGN   = M64_WORD_ALIGN;
+    enum M_PLT_ENTSIZE  = M64_PLT_ENTSIZE;
+    enum M_PLT_ALIGN    = M64_PLT_ALIGN;
+    enum M_PLT_RESERVSZ = M64_PLT_RESERVSZ;
+    enum M_GOT_ENTSIZE  = M64_GOT_ENTSIZE;
+}
diff --git a/libphobos/libdruntime/core/sys/solaris/sys/elf_notes.d b/libphobos/libdruntime/core/sys/solaris/sys/elf_notes.d
new file mode 100644
index 00000000000..a568962211d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/sys/elf_notes.d
@@ -0,0 +1,14 @@
+/**
+ * D header file for Solaris.
+ *
+ * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/sys/elf_notes.h, illumos sys/elf_notes.h)
+ */
+module core.sys.solaris.sys.elf_notes;
+
+version (Solaris):
+extern (C):
+nothrow:
+
+enum ELF_NOTE_SOLARIS = "SUNW Solaris";
+
+enum ELF_NOTE_PAGESIZE_HINT = 1;
diff --git a/libphobos/libdruntime/core/sys/solaris/sys/elftypes.d b/libphobos/libdruntime/core/sys/solaris/sys/elftypes.d
new file mode 100644
index 00000000000..a43cc5ad606
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/sys/elftypes.d
@@ -0,0 +1,28 @@
+/**
+ * D header file for Solaris.
+ *
+ * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/sys/elftypes.h, illumos sys/elftypes.h)
+ */
+module core.sys.solaris.sys.elftypes;
+
+version (Solaris):
+extern (C):
+nothrow:
+
+import core.stdc.stdint;
+
+alias uint32_t Elf32_Addr;
+alias uint16_t Elf32_Half;
+alias uint32_t Elf32_Off;
+alias int32_t  Elf32_Sword;
+alias uint32_t Elf32_Word;
+
+alias uint64_t Elf64_Addr;
+alias uint16_t Elf64_Half;
+alias uint64_t Elf64_Off;
+alias int32_t  Elf64_Sword;
+alias int64_t  Elf64_Sxword;
+alias uint32_t Elf64_Word;
+alias uint64_t Elf64_Xword;
+alias uint64_t Elf64_Lword;
+alias uint64_t Elf32_Lword;
diff --git a/libphobos/libdruntime/core/sys/solaris/sys/link.d b/libphobos/libdruntime/core/sys/solaris/sys/link.d
new file mode 100644
index 00000000000..1f147fa9e95
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/sys/link.d
@@ -0,0 +1,426 @@
+/**
+ * D header file for Solaris.
+ *
+ * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/sys/link.h, illumos sys/link.h)
+ */
+module core.sys.solaris.sys.link;
+
+version (Solaris):
+extern (C):
+nothrow:
+
+public import core.sys.solaris.sys.elftypes;
+import core.stdc.config;
+
+struct Elf32_Dyn
+{
+    Elf32_Sword d_tag;
+    union d_un
+    {
+        Elf32_Word d_val;
+        Elf32_Addr d_ptr;
+        Elf32_Off  d_off;
+    }
+}
+
+struct Elf64_Dyn
+{
+    Elf64_Xword d_tag;
+    union d_un
+    {
+        Elf64_Xword d_val;
+        Elf64_Addr  d_ptr;
+    }
+}
+
+enum DT_NULL         = 0;
+enum DT_NEEDED       = 1;
+enum DT_PLTRELSZ     = 2;
+enum DT_PLTGOT       = 3;
+enum DT_HASH         = 4;
+enum DT_STRTAB       = 5;
+enum DT_SYMTAB       = 6;
+enum DT_RELA         = 7;
+enum DT_RELASZ       = 8;
+enum DT_RELAENT      = 9;
+enum DT_STRSZ        = 10;
+enum DT_SYMENT       = 11;
+enum DT_INIT         = 12;
+enum DT_FINI         = 13;
+enum DT_SONAME       = 14;
+enum DT_RPATH        = 15;
+enum DT_SYMBOLIC     = 16;
+enum DT_REL          = 17;
+enum DT_RELSZ        = 18;
+enum DT_RELENT       = 19;
+enum DT_PLTREL       = 20;
+enum DT_DEBUG        = 21;
+enum DT_TEXTREL      = 22;
+enum DT_JMPREL       = 23;
+enum DT_BIND_NOW     = 24;
+enum DT_INIT_ARRAY   = 25;
+enum DT_FINI_ARRAY   = 26;
+enum DT_INIT_ARRAYSZ = 27;
+enum DT_FINI_ARRAYSZ = 28;
+enum DT_RUNPATH      = 29;
+enum DT_FLAGS        = 30;
+
+enum DT_ENCODING        = 32;
+enum DT_PREINIT_ARRAY   = 32;
+enum DT_PREINIT_ARRAYSZ = 33;
+
+enum DT_MAXPOSTAGS = 34;
+
+enum DT_LOOS           = 0x6000000d;
+enum DT_SUNW_AUXILIARY = 0x6000000d;
+enum DT_SUNW_RTLDINF   = 0x6000000e;
+enum DT_SUNW_FILTER    = 0x6000000f;
+enum DT_SUNW_CAP       = 0x60000010;
+enum DT_SUNW_SYMTAB    = 0x60000011;
+enum DT_SUNW_SYMSZ     = 0x60000012;
+
+enum DT_SUNW_ENCODING    = 0x60000013;
+enum DT_SUNW_SORTENT     = 0x60000013;
+enum DT_SUNW_SYMSORT     = 0x60000014;
+enum DT_SUNW_SYMSORTSZ   = 0x60000015;
+enum DT_SUNW_TLSSORT     = 0x60000016;
+enum DT_SUNW_TLSSORTSZ   = 0x60000017;
+enum DT_SUNW_CAPINFO     = 0x60000018;
+enum DT_SUNW_STRPAD      = 0x60000019;
+enum DT_SUNW_CAPCHAIN    = 0x6000001a;
+enum DT_SUNW_LDMACH      = 0x6000001b;
+enum DT_SUNW_CAPCHAINENT = 0x6000001d;
+enum DT_SUNW_CAPCHAINSZ  = 0x6000001f;
+
+enum DT_HIOS = 0x6ffff000;
+
+enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001;
+
+enum DT_VALRNGLO = 0x6ffffd00;
+
+enum DT_GNU_PRELINKED  = 0x6ffffdf5;
+enum DT_GNU_CONFLICTSZ = 0x6ffffdf6;
+enum DT_GNU_LIBLISTSZ  = 0x6ffffdf7;
+enum DT_CHECKSUM       = 0x6ffffdf8;
+enum DT_PLTPADSZ       = 0x6ffffdf9;
+enum DT_MOVEENT        = 0x6ffffdfa;
+enum DT_MOVESZ         = 0x6ffffdfb;
+enum DT_FEATURE_1      = 0x6ffffdfc;
+enum DT_POSFLAG_1      = 0x6ffffdfd;
+enum DT_SYMINSZ        = 0x6ffffdfe;
+enum DT_SYMINENT       = 0x6ffffdff;
+enum DT_VALRNGHI       = 0x6ffffdff;
+
+enum DT_ADDRRNGLO = 0x6ffffe00;
+
+enum DT_GNU_HASH     = 0x6ffffef5;
+enum DT_TLSDESC_PLT  = 0x6ffffef6;
+enum DT_TLSDESC_GOT  = 0x6ffffef7;
+enum DT_GNU_CONFLICT = 0x6ffffef8;
+enum DT_GNU_LIBLIST  = 0x6ffffef9;
+
+enum DT_CONFIG    = 0x6ffffefa;
+enum DT_DEPAUDIT  = 0x6ffffefb;
+enum DT_AUDIT     = 0x6ffffefc;
+enum DT_PLTPAD    = 0x6ffffefd;
+enum DT_MOVETAB   = 0x6ffffefe;
+enum DT_SYMINFO   = 0x6ffffeff;
+enum DT_ADDRRNGHI = 0x6ffffeff;
+
+enum DT_VERSYM = 0x6ffffff0;
+
+enum DT_RELACOUNT  = 0x6ffffff9;
+enum DT_RELCOUNT   = 0x6ffffffa;
+enum DT_FLAGS_1    = 0x6ffffffb;
+enum DT_VERDEF     = 0x6ffffffc;
+enum DT_VERDEFNUM  = 0x6ffffffd;
+enum DT_VERNEED    = 0x6ffffffe;
+enum DT_VERNEEDNUM = 0x6fffffff;
+
+enum DT_LOPROC    = 0x70000000;
+enum DT_AUXILIARY = 0x7ffffffd;
+enum DT_USED      = 0x7ffffffe;
+enum DT_FILTER    = 0x7fffffff;
+enum DT_HIPROC    = 0x7fffffff;
+
+enum DF_ORIGIN     = 0x00000001;
+enum DF_SYMBOLIC   = 0x00000002;
+enum DF_TEXTREL    = 0x00000004;
+enum DF_BIND_NOW   = 0x00000008;
+enum DF_STATIC_TLS = 0x00000010;
+
+enum DF_P1_LAZYLOAD  = 0x00000001;
+enum DF_P1_GROUPPERM = 0x00000002;
+enum DF_P1_DEFERRED  = 0x00000004;
+
+enum DF_1_NOW        = 0x00000001;
+enum DF_1_GLOBAL     = 0x00000002;
+enum DF_1_GROUP      = 0x00000004;
+enum DF_1_NODELETE   = 0x00000008;
+enum DF_1_LOADFLTR   = 0x00000010;
+enum DF_1_INITFIRST  = 0x00000020;
+enum DF_1_NOOPEN     = 0x00000040;
+enum DF_1_ORIGIN     = 0x00000080;
+enum DF_1_DIRECT     = 0x00000100;
+enum DF_1_TRANS      = 0x00000200;
+enum DF_1_INTERPOSE  = 0x00000400;
+enum DF_1_NODEFLIB   = 0x00000800;
+enum DF_1_NODUMP     = 0x00001000;
+enum DF_1_CONFALT    = 0x00002000;
+enum DF_1_ENDFILTEE  = 0x00004000;
+enum DF_1_DISPRELDNE = 0x00008000;
+enum DF_1_DISPRELPND = 0x00010000;
+enum DF_1_NODIRECT   = 0x00020000;
+enum DF_1_IGNMULDEF  = 0x00040000;
+enum DF_1_NOKSYMS    = 0x00080000;
+enum DF_1_NOHDR      = 0x00100000;
+enum DF_1_EDITED     = 0x00200000;
+enum DF_1_NORELOC    = 0x00400000;
+enum DF_1_SYMINTPOSE = 0x00800000;
+enum DF_1_GLOBAUDIT  = 0x01000000;
+enum DF_1_SINGLETON  = 0x02000000;
+
+enum DTF_1_PARINIT = 0x00000001;
+enum DTF_1_CONFEXP = 0x00000002;
+
+struct Elf32_Verdef
+{
+    Elf32_Half  vd_version;
+    Elf32_Half  vd_flags;
+    Elf32_Half  vd_ndx;
+    Elf32_Half  vd_cnt;
+    Elf32_Word  vd_hash;
+    Elf32_Word  vd_aux;
+    Elf32_Word  vd_next;
+}
+
+struct Elf32_Verdaux
+{
+    Elf32_Word  vda_name;
+    Elf32_Word  vda_next;
+}
+
+struct Elf32_Verneed
+{
+    Elf32_Half  vn_version;
+    Elf32_Half  vn_cnt;
+    Elf32_Word  vn_file;
+    Elf32_Word  vn_aux;
+    Elf32_Word  vn_next;
+}
+
+struct Elf32_Vernaux
+{
+    Elf32_Word  vna_hash;
+    Elf32_Half  vna_flags;
+    Elf32_Half  vna_other;
+    Elf32_Word  vna_name;
+    Elf32_Word  vna_next;
+}
+
+alias Elf32_Half  Elf32_Versym;
+
+struct Elf32_Syminfo
+{
+    Elf32_Half  si_boundto;
+    Elf32_Half  si_flags;
+}
+
+struct Elf64_Verdef
+{
+    Elf64_Half  vd_version;
+    Elf64_Half  vd_flags;
+    Elf64_Half  vd_ndx;
+    Elf64_Half  vd_cnt;
+    Elf64_Word  vd_hash;
+    Elf64_Word  vd_aux;
+    Elf64_Word  vd_next;
+}
+
+struct Elf64_Verdaux
+{
+    Elf64_Word  vda_name;
+    Elf64_Word  vda_next;
+}
+
+struct Elf64_Verneed
+{
+    Elf64_Half  vn_version;
+    Elf64_Half  vn_cnt;
+    Elf64_Word  vn_file;
+    Elf64_Word  vn_aux;
+    Elf64_Word  vn_next;
+}
+
+struct Elf64_Vernaux
+{
+    Elf64_Word  vna_hash;
+    Elf64_Half  vna_flags;
+    Elf64_Half  vna_other;
+    Elf64_Word  vna_name;
+    Elf64_Word  vna_next;
+}
+
+alias Elf64_Half  Elf64_Versym;
+
+struct Elf64_Syminfo
+{
+    Elf64_Half  si_boundto;
+    Elf64_Half  si_flags;
+}
+
+enum VER_NDX_LOCAL     = 0;
+enum VER_NDX_GLOBAL    = 1;
+enum VER_NDX_LORESERVE = 0xff00;
+enum VER_NDX_ELIMINATE = 0xff01;
+
+enum VER_FLG_BASE = 0x1;
+enum VER_FLG_WEAK = 0x2;
+enum VER_FLG_INFO = 0x4;
+
+enum VER_DEF_NONE    = 0;
+enum VER_DEF_CURRENT = 1;
+enum VER_DEF_NUM     = 2;
+
+enum VER_NEED_NONE    = 0;
+enum VER_NEED_CURRENT = 1;
+enum VER_NEED_NUM     = 2;
+
+enum SYMINFO_FLG_DIRECT      = 0x0001;
+enum SYMINFO_FLG_FILTER      = 0x0002;
+enum SYMINFO_FLG_PASSTHRU    = SYMINFO_FLG_FILTER;
+enum SYMINFO_FLG_COPY        = 0x0004;
+enum SYMINFO_FLG_LAZYLOAD    = 0x0008;
+enum SYMINFO_FLG_DIRECTBIND  = 0x0010;
+enum SYMINFO_FLG_NOEXTDIRECT = 0x0020;
+enum SYMINFO_FLG_AUXILIARY   = 0x0040;
+enum SYMINFO_FLG_INTERPOSE   = 0x0080;
+enum SYMINFO_FLG_CAP         = 0x0100;
+enum SYMINFO_FLG_DEFERRED    = 0x0200;
+
+enum SYMINFO_BT_SELF       = 0xffff;
+enum SYMINFO_BT_PARENT     = 0xfffe;
+enum SYMINFO_BT_NONE       = 0xfffd;
+enum SYMINFO_BT_EXTERN     = 0xfffc;
+enum SYMINFO_BT_LOWRESERVE = 0xff00;
+
+enum SYMINFO_NONE    = 0;
+enum SYMINFO_CURRENT = 1;
+enum SYMINFO_NUM     = 2;
+
+alias link_map Link_map;
+
+struct link_map
+{
+    c_ulong  l_addr;
+    char*    l_name;
+    version(D_LP64)
+        Elf64_Dyn*  l_ld;
+    else
+        Elf32_Dyn*  l_ld;
+    Link_map*  l_next;
+    Link_map*  l_prev;
+    char*      l_refname;
+}
+
+version(_SYSCALL32)
+{
+alias link_map32 Link_map32;
+
+struct link_map32
+{
+    Elf32_Word  l_addr;
+    Elf32_Addr  l_name;
+    Elf32_Addr  l_ld;
+    Elf32_Addr  l_next;
+    Elf32_Addr  l_prev;
+    Elf32_Addr  l_refname;
+}
+}
+
+enum r_state_e
+{
+    RT_CONSISTENT,
+    RT_ADD,
+    RT_DELETE
+}
+
+enum rd_flags_e
+{
+    RD_FL_NONE = 0,
+    RD_FL_ODBG = (1<<0),
+    RD_FL_DBG  = (1<<1)
+}
+
+enum rd_event_e
+{
+    RD_NONE = 0,
+    RD_PREINIT,
+    RD_POSTINIT,
+    RD_DLACTIVITY
+}
+
+struct r_debug
+{
+    int         r_version;
+    Link_map*   r_map;
+    c_ulong     r_brk;
+    r_state_e   r_state;
+    c_ulong     r_ldbase;
+    Link_map*   r_ldsomap;
+    rd_event_e  r_rdevent;
+    rd_flags_e  r_flags;
+}
+
+version(_SYSCALL32)
+{
+struct r_debug32
+{
+    Elf32_Word  r_version;
+    Elf32_Addr  r_map;
+    Elf32_Word  r_brk;
+    r_state_e   r_state;
+    Elf32_Word  r_ldbase;
+    Elf32_Addr  r_ldsomap;
+    rd_event_e  r_rdevent;
+    rd_flags_e  r_flags;
+}
+}
+
+enum R_DEBUG_VERSION = 2;
+
+struct Elf32_Boot
+{
+    Elf32_Sword eb_tag;
+    union eb_un
+    {
+        Elf32_Word eb_val;
+        Elf32_Addr eb_ptr;
+        Elf32_Off  eb_off;
+    }
+}
+
+struct Elf64_Boot
+{
+    Elf64_Xword eb_tag;
+    union eb_un
+    {
+        Elf64_Xword eb_val;
+        Elf64_Addr eb_ptr;
+        Elf64_Off eb_off;
+    }
+}
+
+enum EB_NULL       = 0;
+enum EB_DYNAMIC    = 1;
+enum EB_LDSO_BASE  = 2;
+enum EB_ARGV       = 3;
+enum EB_ENVP       = 4;
+enum EB_AUXV       = 5;
+enum EB_DEVZERO    = 6;
+enum EB_PAGESIZE   = 7;
+enum EB_MAX        = 8;
+enum EB_MAX_SIZE32 = 64;
+enum EB_MAX_SIZE64 = 128;
+
+void _ld_libc(void *);
diff --git a/libphobos/libdruntime/core/sys/solaris/sys/priocntl.d b/libphobos/libdruntime/core/sys/solaris/sys/priocntl.d
new file mode 100644
index 00000000000..9640f1e3976
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/sys/priocntl.d
@@ -0,0 +1,115 @@
+/**
+ * D header file for the Solaris priocntl(2) and priocntlset(2) functions.
+ *
+ * Copyright:   Copyright 2014 Jason King.
+ * License:     $(WEB www.boost.org/LICENSE_1.0.txt, Boost License 1.0).
+ * Authors:     Jason King
+ */
+
+/*
+ * Copyright 2014 Jason King.
+ * Distributed under the Boost Software License, Version 1.0.
+ * See accompanying file LICENSE or copy at
+ *  http://www.boost.org/LICENSE_1_0.txt
+ */
+module core.sys.solaris.sys.priocntl;
+
+version (Solaris):
+nothrow:
+@nogc:
+extern (C):
+
+import core.sys.posix.sys.types : caddr_t, id_t;
+import core.stdc.config : c_long;
+import core.sys.solaris.sys.procset;
+import core.sys.solaris.sys.types : pri_t;
+
+c_long priocntl(idtype_t, id_t, int, ...);
+c_long priocntlset(procset_t*, int, ...);
+
+
+enum PC_GETCID       = 0;       /* Get class ID */
+enum PC_GETCLINFO    = 1;       /* Get info about a configured class */
+enum PC_SETPARMS     = 2;       /* Set scheduling parameters */
+enum PC_GETPARMS     = 3;       /* Get scheduling parameters */
+enum PC_ADMIN        = 4;       /* Scheduler administration (used by */
+                                /* dispadmin(1M), not for general use) */
+enum PC_GETPRIRANGE  = 5;       /* Get priority range for a class */
+                                /* posix.4; scheduling, not for general use */
+enum PC_DONICE       = 6;       /* Set or get nice value */
+enum PC_SETXPARMS    = 7;       /* Set extended scheduling parameters */
+enum PC_GETXPARMS    = 8;       /* Get extended scheduling parameters */
+enum PC_SETDFLCL     = 9;       /* Set default class, not for general use */
+enum PC_GETDFLCL     = 10;      /* Get default class, not for general use */
+enum PC_DOPRIO       = 11;      /* Set or get priority, not for general use */
+
+enum PC_CLNULL       = -1;
+
+enum PC_CLNMSZ       = 16;
+enum PC_CLINFOSZ     = (32 / int.sizeof);
+enum PC_CLPARMSZ     = (32 / int.sizeof);
+
+enum PC_GETNICE = 0;
+enum PC_SETNICE = 1;
+
+enum PC_GETPRIO      = 0;
+enum PC_SETPRIO      = 1;
+
+struct pcinfo_t
+{
+    id_t                pc_cid;     // class id
+    char[PC_CLNMSZ]     pc_clname;  // class name
+    int[PC_CLINFOSZ]    pc_clinfo;  // class information
+}
+
+struct pcparms_t
+{
+    id_t                pc_cid;     // process class
+    int[PC_CLPARMSZ]    pc_clparms; //class specific parameters
+}
+
+struct pcnice_t
+{
+    int pc_val; // nice value
+    int pc_op;  // type of operation, set or get
+}
+
+struct pcprio_t
+{
+    int     pc_op;  // type of operation, set or get
+    id_t    pc_cid; // class id
+    int     pc_val; // priority value
+}
+
+// Used by the priocntl varargs interface
+// PC_SETXPARMS and PC_GETXPARMS
+enum PC_VAPARMCNT = 8;  // max # of kv pairs
+enum PC_KY_NULL   = 0;  // kv chain terminator
+enum PC_KY_CLNAME = 1;  // get the class name of a process or LWP
+
+struct pc_vaparm_t
+{
+    int     pc_key;
+    ulong   pc_parm;
+}
+
+struct pc_vaparms_t
+{
+    int                         pc_vaparmscnt; // # of kv pairs
+    pc_vaparm_t[PC_VAPARMCNT]   pc_parm;
+}
+
+// Not for general use
+struct pcpri_t
+{
+    id_t    pc_cid;
+    pri_t   pc_clpmax;
+    pri_t   pc_clpmin;
+}
+
+struct pcadmin_t
+{
+    id_t    pc_cid;
+    caddr_t pc_cladmin;
+}
+
diff --git a/libphobos/libdruntime/core/sys/solaris/sys/procset.d b/libphobos/libdruntime/core/sys/solaris/sys/procset.d
new file mode 100644
index 00000000000..856efffe330
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/sys/procset.d
@@ -0,0 +1,53 @@
+/**
+ * D header file defining a process set.
+ *
+ * Copyright:   Copyright 2014 Jason King.
+ * License:     $(WEB www.boost.org/LICENSE_1.0.txt, Boost License 1.0).
+ * Authors:     Jason King
+ */
+
+/*
+ * Copyright 2014 Jason King.
+ * Distributed under the Boost Software License, Version 1.0.
+ * See accompanying file LICENSE or copy at
+ *  http://www.boost.org/LICENSE_1_0.txt
+ */
+module core.sys.solaris.sys.procset;
+
+version (Solaris):
+nothrow:
+@nogc:
+
+import core.sys.posix.sys.types : id_t;
+import core.sys.posix.sys.wait : idtype_t;
+
+enum P_INITPID  = 1;
+enum P_INITUID  = 0;
+enum P_INITPGID = 0;
+
+enum idop_t
+{
+    POP_DIFF,
+    POP_AND,
+    POP_OR,
+    POP_XOR
+}
+
+struct procset_t
+{
+    idop_t      p_op;
+    idtype_t    p_lidtype;
+    id_t        p_lid;
+    idtype_t    p_ridtype;
+    id_t        p_rid;
+}
+
+void setprocset(ref procset_t psp, idop_t op, idtype_t ltype, id_t lid, idtype_t rtype, id_t rid)
+{
+    psp.p_op = op;
+    psp.p_lidtype = ltype;
+    psp.p_lid = lid;
+    psp.p_ridtype = rtype;
+    psp.p_rid = rid;
+}
+
diff --git a/libphobos/libdruntime/core/sys/solaris/sys/types.d b/libphobos/libdruntime/core/sys/solaris/sys/types.d
new file mode 100644
index 00000000000..0ec7f269558
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/sys/types.d
@@ -0,0 +1,24 @@
+/**
+ * D header file that defines Solaris-specific types.
+ *
+ * Copyright:   Copyright 2014 Jason King.
+ * License:     $(WEB www.boost.org/LICENSE_1.0.txt, Boost License 1.0).
+ * Authors:     Jason King
+ */
+
+/*
+ * Copyright 2014 Jason King.
+ * Distributed under the Boost Software License, Version 1.0.
+ * See accompanying file LICENSE or copy at
+ *  http://www.boost.org/LICENSE_1_0.txt
+ */
+
+module core.sys.solaris.sys.types;
+
+version (Solaris):
+nothrow:
+@nogc:
+
+alias short pri_t;
+
+enum P_MYID = -1;
diff --git a/libphobos/libdruntime/core/sys/solaris/time.d b/libphobos/libdruntime/core/sys/solaris/time.d
new file mode 100644
index 00000000000..c5407ee5e7a
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/solaris/time.d
@@ -0,0 +1,18 @@
+//Written in the D programming language
+
+/++
+    D header file for Solaris's extensions to POSIX's time.h.
+
+    Copyright: Copyright 2014
+    License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+    Authors:   Kai Nacke
+ +/
+module core.sys.solaris.time;
+
+public import core.sys.posix.time;
+
+version(Solaris):
+
+enum CLOCK_VIRTUAL           = 1;
+enum CLOCK_HIGHRES           = CLOCK_MONOTONIC;
+enum CLOCK_PROF              = CLOCK_THREAD_CPUTIME_ID;
diff --git a/libphobos/libdruntime/core/sys/windows/accctrl.d b/libphobos/libdruntime/core/sys/windows/accctrl.d
new file mode 100644
index 00000000000..e28f5df73aa
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/accctrl.d
@@ -0,0 +1,422 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_accctrl.d)
+ */
+module core.sys.windows.accctrl;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.basetyps, core.sys.windows.w32api, core.sys.windows.winbase, core.sys.windows.windef;
+
+// FIXME: check types and grouping of constants
+// FIXME: check Windows version support
+
+alias LocalFree AccFree;
+
+enum uint
+    ACTRL_RESERVED            = 0x00000000,
+    ACTRL_ACCESS_PROTECTED    = 0x00000001,
+    ACTRL_ACCESS_ALLOWED      = 0x00000001,
+    ACTRL_ACCESS_DENIED       = 0x00000002,
+    ACTRL_AUDIT_SUCCESS       = 0x00000004,
+    ACTRL_AUDIT_FAILURE       = 0x00000008,
+    ACTRL_SYSTEM_ACCESS       = 0x04000000,
+    ACTRL_DELETE              = 0x08000000,
+    ACTRL_READ_CONTROL        = 0x10000000,
+    ACTRL_CHANGE_ACCESS       = 0x20000000,
+    ACTRL_CHANGE_OWNER        = 0x40000000,
+    ACTRL_SYNCHRONIZE         = 0x80000000,
+    ACTRL_STD_RIGHTS_ALL      = 0xf8000000;
+
+enum uint
+    ACTRL_FILE_READ           = 0x00000001,
+    ACTRL_FILE_WRITE          = 0x00000002,
+    ACTRL_FILE_APPEND         = 0x00000004,
+    ACTRL_FILE_READ_PROP      = 0x00000008,
+    ACTRL_FILE_WRITE_PROP     = 0x00000010,
+    ACTRL_FILE_EXECUTE        = 0x00000020,
+    ACTRL_FILE_READ_ATTRIB    = 0x00000080,
+    ACTRL_FILE_WRITE_ATTRIB   = 0x00000100,
+    ACTRL_FILE_CREATE_PIPE    = 0x00000200;
+
+enum uint
+    ACTRL_DIR_LIST            = 0x00000001,
+    ACTRL_DIR_CREATE_OBJECT   = 0x00000002,
+    ACTRL_DIR_CREATE_CHILD    = 0x00000004,
+    ACTRL_DIR_DELETE_CHILD    = 0x00000040,
+    ACTRL_DIR_TRAVERSE        = 0x00000020;
+
+enum uint
+    ACTRL_KERNEL_TERMINATE    = 0x00000001,
+    ACTRL_KERNEL_THREAD       = 0x00000002,
+    ACTRL_KERNEL_VM           = 0x00000004,
+    ACTRL_KERNEL_VM_READ      = 0x00000008,
+    ACTRL_KERNEL_VM_WRITE     = 0x00000010,
+    ACTRL_KERNEL_DUP_HANDLE   = 0x00000020,
+    ACTRL_KERNEL_PROCESS      = 0x00000040,
+    ACTRL_KERNEL_SET_INFO     = 0x00000080,
+    ACTRL_KERNEL_GET_INFO     = 0x00000100,
+    ACTRL_KERNEL_CONTROL      = 0x00000200,
+    ACTRL_KERNEL_ALERT        = 0x00000400,
+    ACTRL_KERNEL_GET_CONTEXT  = 0x00000800,
+    ACTRL_KERNEL_SET_CONTEXT  = 0x00001000,
+    ACTRL_KERNEL_TOKEN        = 0x00002000,
+    ACTRL_KERNEL_IMPERSONATE  = 0x00004000,
+    ACTRL_KERNEL_DIMPERSONATE = 0x00008000;
+
+enum uint
+    ACTRL_PRINT_SADMIN        = 0x00000001,
+    ACTRL_PRINT_SLIST         = 0x00000002,
+    ACTRL_PRINT_PADMIN        = 0x00000004,
+    ACTRL_PRINT_PUSE          = 0x00000008,
+    ACTRL_PRINT_JADMIN        = 0x00000010;
+
+enum uint
+    ACTRL_SVC_GET_INFO        = 0x00000001,
+    ACTRL_SVC_SET_INFO        = 0x00000002,
+    ACTRL_SVC_STATUS          = 0x00000004,
+    ACTRL_SVC_LIST            = 0x00000008,
+    ACTRL_SVC_START           = 0x00000010,
+    ACTRL_SVC_STOP            = 0x00000020,
+    ACTRL_SVC_PAUSE           = 0x00000040,
+    ACTRL_SVC_INTERROGATE     = 0x00000080,
+    ACTRL_SVC_UCONTROL        = 0x00000100;
+
+enum uint
+    ACTRL_REG_QUERY           = 0x00000001,
+    ACTRL_REG_SET             = 0x00000002,
+    ACTRL_REG_CREATE_CHILD    = 0x00000004,
+    ACTRL_REG_LIST            = 0x00000008,
+    ACTRL_REG_NOTIFY          = 0x00000010,
+    ACTRL_REG_LINK            = 0x00000020;
+
+enum uint
+    ACTRL_WIN_CLIPBRD         = 0x00000001,
+    ACTRL_WIN_GLOBAL_ATOMS    = 0x00000002,
+    ACTRL_WIN_CREATE          = 0x00000004,
+    ACTRL_WIN_LIST_DESK       = 0x00000008,
+    ACTRL_WIN_LIST            = 0x00000010,
+    ACTRL_WIN_READ_ATTRIBS    = 0x00000020,
+    ACTRL_WIN_WRITE_ATTRIBS   = 0x00000040,
+    ACTRL_WIN_SCREEN          = 0x00000080,
+    ACTRL_WIN_EXIT            = 0x00000100;
+
+enum : uint {
+    ACTRL_ACCESS_NO_OPTIONS              = 0x00000000,
+    ACTRL_ACCESS_SUPPORTS_OBJECT_ENTRIES = 0x00000001
+}
+
+const TCHAR[] ACCCTRL_DEFAULT_PROVIDER = "Windows NT Access Provider";
+
+enum uint
+    TRUSTEE_ACCESS_ALLOWED    = 0x00000001,
+    TRUSTEE_ACCESS_READ       = 0x00000002,
+    TRUSTEE_ACCESS_WRITE      = 0x00000004,
+    TRUSTEE_ACCESS_EXPLICIT   = 0x00000001,
+    TRUSTEE_ACCESS_READ_WRITE = 0x00000006,
+    TRUSTEE_ACCESS_ALL        = 0xFFFFFFFF;
+
+enum uint
+    NO_INHERITANCE                     = 0x0,
+    SUB_OBJECTS_ONLY_INHERIT           = 0x1,
+    SUB_CONTAINERS_ONLY_INHERIT        = 0x2,
+    SUB_CONTAINERS_AND_OBJECTS_INHERIT = 0x3,
+    INHERIT_NO_PROPAGATE               = 0x4,
+    INHERIT_ONLY                       = 0x8,
+    INHERITED_ACCESS_ENTRY             = 0x10,
+    INHERITED_PARENT                   = 0x10000000,
+    INHERITED_GRANDPARENT              = 0x20000000;
+
+alias ULONG INHERIT_FLAGS, ACCESS_RIGHTS;
+alias ULONG* PINHERIT_FLAGS, PACCESS_RIGHTS;
+
+enum ACCESS_MODE {
+    NOT_USED_ACCESS,
+    GRANT_ACCESS,
+    SET_ACCESS,
+    DENY_ACCESS,
+    REVOKE_ACCESS,
+    SET_AUDIT_SUCCESS,
+    SET_AUDIT_FAILURE
+}
+
+enum SE_OBJECT_TYPE {
+    SE_UNKNOWN_OBJECT_TYPE,
+    SE_FILE_OBJECT,
+    SE_SERVICE,
+    SE_PRINTER,
+    SE_REGISTRY_KEY,
+    SE_LMSHARE,
+    SE_KERNEL_OBJECT,
+    SE_WINDOW_OBJECT,
+    SE_DS_OBJECT,
+    SE_DS_OBJECT_ALL,
+    SE_PROVIDER_DEFINED_OBJECT,
+    SE_WMIGUID_OBJECT,
+    SE_REGISTRY_WOW64_32KEY
+}
+
+enum TRUSTEE_TYPE {
+    TRUSTEE_IS_UNKNOWN,
+    TRUSTEE_IS_USER,
+    TRUSTEE_IS_GROUP,
+    TRUSTEE_IS_DOMAIN,
+    TRUSTEE_IS_ALIAS,
+    TRUSTEE_IS_WELL_KNOWN_GROUP,
+    TRUSTEE_IS_DELETED,
+    TRUSTEE_IS_INVALID,
+    TRUSTEE_IS_COMPUTER
+}
+
+enum TRUSTEE_FORM {
+    TRUSTEE_IS_SID,
+    TRUSTEE_IS_NAME,
+    TRUSTEE_BAD_FORM,
+    TRUSTEE_IS_OBJECTS_AND_SID,
+    TRUSTEE_IS_OBJECTS_AND_NAME
+}
+
+enum MULTIPLE_TRUSTEE_OPERATION {
+    NO_MULTIPLE_TRUSTEE,
+    TRUSTEE_IS_IMPERSONATE
+}
+
+struct TRUSTEE_A {
+    TRUSTEE_A*                 pMultipleTrustee;
+    MULTIPLE_TRUSTEE_OPERATION MultipleTrusteeOperation;
+    TRUSTEE_FORM               TrusteeForm;
+    TRUSTEE_TYPE               TrusteeType;
+    LPSTR                      ptstrName;
+}
+alias TRUSTEE_A TRUSTEEA;
+alias TRUSTEE_A* PTRUSTEE_A, PTRUSTEEA;
+
+struct TRUSTEE_W {
+    TRUSTEE_W*                 pMultipleTrustee;
+    MULTIPLE_TRUSTEE_OPERATION MultipleTrusteeOperation;
+    TRUSTEE_FORM               TrusteeForm;
+    TRUSTEE_TYPE               TrusteeType;
+    LPWSTR                     ptstrName;
+}
+alias TRUSTEE_W TRUSTEEW;
+alias TRUSTEEW* PTRUSTEE_W, PTRUSTEEW;
+
+struct ACTRL_ACCESS_ENTRYA {
+    TRUSTEE_A     Trustee;
+    ULONG         fAccessFlags;
+    ACCESS_RIGHTS Access;
+    ACCESS_RIGHTS ProvSpecificAccess;
+    INHERIT_FLAGS Inheritance;
+    LPCSTR        lpInheritProperty;
+}
+alias ACTRL_ACCESS_ENTRYA* PACTRL_ACCESS_ENTRYA;
+
+struct ACTRL_ACCESS_ENTRYW {
+    TRUSTEE_W     Trustee;
+    ULONG         fAccessFlags;
+    ACCESS_RIGHTS Access;
+    ACCESS_RIGHTS ProvSpecificAccess;
+    INHERIT_FLAGS Inheritance;
+    LPCWSTR       lpInheritProperty;
+}
+alias ACTRL_ACCESS_ENTRYW* PACTRL_ACCESS_ENTRYW;
+
+struct ACTRL_ACCESS_ENTRY_LISTA {
+    ULONG                cEntries;
+    ACTRL_ACCESS_ENTRYA* pAccessList;
+}
+alias ACTRL_ACCESS_ENTRY_LISTA* PACTRL_ACCESS_ENTRY_LISTA;
+
+struct ACTRL_ACCESS_ENTRY_LISTW {
+    ULONG                cEntries;
+    ACTRL_ACCESS_ENTRYW* pAccessList;
+}
+alias ACTRL_ACCESS_ENTRY_LISTW* PACTRL_ACCESS_ENTRY_LISTW;
+
+struct ACTRL_PROPERTY_ENTRYA {
+    LPCSTR                    lpProperty;
+    PACTRL_ACCESS_ENTRY_LISTA pAccessEntryList;
+    ULONG                     fListFlags;
+}
+alias ACTRL_PROPERTY_ENTRYA* PACTRL_PROPERTY_ENTRYA;
+
+struct ACTRL_PROPERTY_ENTRYW {
+    LPCWSTR                   lpProperty;
+    PACTRL_ACCESS_ENTRY_LISTW pAccessEntryList;
+    ULONG                     fListFlags;
+}
+alias ACTRL_PROPERTY_ENTRYW* PACTRL_PROPERTY_ENTRYW;
+
+struct ACTRL_ACCESSA {
+    ULONG                  cEntries;
+    PACTRL_PROPERTY_ENTRYA pPropertyAccessList;
+}
+alias ACTRL_ACCESSA ACTRL_AUDITA;
+alias ACTRL_ACCESSA* PACTRL_ACCESSA, PACTRL_AUDITA;
+
+struct ACTRL_ACCESSW {
+    ULONG                  cEntries;
+    PACTRL_PROPERTY_ENTRYW pPropertyAccessList;
+}
+alias ACTRL_ACCESSW ACTRL_AUDITW;
+alias ACTRL_ACCESSW* PACTRL_ACCESSW, PACTRL_AUDITW;
+
+struct TRUSTEE_ACCESSA {
+    LPSTR         lpProperty;
+    ACCESS_RIGHTS Access;
+    ULONG         fAccessFlags;
+    ULONG         fReturnedAccess;
+}
+alias TRUSTEE_ACCESSA* PTRUSTEE_ACCESSA;
+
+struct TRUSTEE_ACCESSW {
+    LPWSTR        lpProperty;
+    ACCESS_RIGHTS Access;
+    ULONG         fAccessFlags;
+    ULONG         fReturnedAccess;
+}
+alias TRUSTEE_ACCESSW* PTRUSTEE_ACCESSW;
+
+struct ACTRL_OVERLAPPED {
+    union {
+        PVOID Provider;
+        ULONG Reserved1;
+    }
+    ULONG     Reserved2;
+    HANDLE    hEvent;
+}
+alias ACTRL_OVERLAPPED* PACTRL_OVERLAPPED;
+
+struct ACTRL_ACCESS_INFOA {
+    ULONG fAccessPermission;
+    LPSTR lpAccessPermissionName;
+}
+alias ACTRL_ACCESS_INFOA* PACTRL_ACCESS_INFOA;
+
+struct ACTRL_ACCESS_INFOW {
+    ULONG  fAccessPermission;
+    LPWSTR lpAccessPermissionName;
+}
+alias ACTRL_ACCESS_INFOW* PACTRL_ACCESS_INFOW;
+
+struct ACTRL_CONTROL_INFOA {
+    LPSTR lpControlId;
+    LPSTR lpControlName;
+}
+alias ACTRL_CONTROL_INFOA* PACTRL_CONTROL_INFOA;
+
+struct ACTRL_CONTROL_INFOW {
+    LPWSTR lpControlId;
+    LPWSTR lpControlName;
+}
+alias ACTRL_CONTROL_INFOW* PACTRL_CONTROL_INFOW;
+
+struct EXPLICIT_ACCESS_A {
+    DWORD       grfAccessPermissions;
+    ACCESS_MODE grfAccessMode;
+    DWORD       grfInheritance;
+    TRUSTEE_A   Trustee;
+}
+alias EXPLICIT_ACCESS_A EXPLICIT_ACCESSA;
+alias EXPLICIT_ACCESS_A* PEXPLICIT_ACCESS_A, PEXPLICIT_ACCESSA;
+
+struct EXPLICIT_ACCESS_W {
+    DWORD       grfAccessPermissions;
+    ACCESS_MODE grfAccessMode;
+    DWORD       grfInheritance;
+    TRUSTEE_W   Trustee;
+}
+alias EXPLICIT_ACCESS_W EXPLICIT_ACCESSW;
+alias EXPLICIT_ACCESS_W* PEXPLICIT_ACCESS_W, PEXPLICIT_ACCESSW;
+
+struct OBJECTS_AND_SID {
+    DWORD ObjectsPresent;
+    GUID  ObjectTypeGuid;
+    GUID  InheritedObjectTypeGuid;
+    SID*  pSid;
+}
+alias OBJECTS_AND_SID* POBJECTS_AND_SID;
+
+struct OBJECTS_AND_NAME_A {
+    DWORD          ObjectsPresent;
+    SE_OBJECT_TYPE ObjectType;
+    LPSTR          ObjectTypeName;
+    LPSTR          InheritedObjectTypeName;
+    LPSTR          ptstrName;
+}
+alias OBJECTS_AND_NAME_A* POBJECTS_AND_NAME_A;
+
+struct OBJECTS_AND_NAME_W {
+    DWORD          ObjectsPresent;
+    SE_OBJECT_TYPE ObjectType;
+    LPWSTR         ObjectTypeName;
+    LPWSTR         InheritedObjectTypeName;
+    LPWSTR         ptstrName;
+}
+alias OBJECTS_AND_NAME_W* POBJECTS_AND_NAME_W;
+
+static if (_WIN32_WINNT >= 0x501) {
+    struct INHERITED_FROMA {
+        LONG  GenerationGap;
+        LPSTR AncestorName;
+    }
+    alias INHERITED_FROMA* PINHERITED_FROMA;
+
+    struct INHERITED_FROMW {
+        LONG   GenerationGap;
+        LPWSTR AncestorName;
+    }
+    alias INHERITED_FROMW* PINHERITED_FROMW;
+}
+
+version (Unicode) {
+    alias TRUSTEEW TRUSTEE;
+    alias ACTRL_ACCESSW ACTRL_ACCESS;
+    alias ACTRL_ACCESS_ENTRY_LISTW ACTRL_ACCESS_ENTRY_LIST;
+    alias ACTRL_ACCESS_INFOW ACTRL_ACCESS_INFO;
+    alias ACTRL_ACCESS_ENTRYW ACTRL_ACCESS_ENTRY;
+    alias ACTRL_AUDITW ACTRL_AUDIT;
+    alias ACTRL_CONTROL_INFOW ACTRL_CONTROL_INFO;
+    alias EXPLICIT_ACCESSW EXPLICIT_ACCESS;
+    alias TRUSTEE_ACCESSW TRUSTEE_ACCESS;
+    alias OBJECTS_AND_NAME_W OBJECTS_AND_NAME_;
+    static if (_WIN32_WINNT >= 0x501) {
+        alias INHERITED_FROMW INHERITED_FROM;
+    }
+} else {
+    alias TRUSTEEA TRUSTEE;
+    alias ACTRL_ACCESSA ACTRL_ACCESS;
+    alias ACTRL_ACCESS_ENTRY_LISTA ACTRL_ACCESS_ENTRY_LIST;
+    alias ACTRL_ACCESS_INFOA ACTRL_ACCESS_INFO;
+    alias ACTRL_ACCESS_ENTRYA ACTRL_ACCESS_ENTRY;
+    alias ACTRL_AUDITA ACTRL_AUDIT;
+    alias ACTRL_CONTROL_INFOA ACTRL_CONTROL_INFO;
+    alias EXPLICIT_ACCESSA EXPLICIT_ACCESS;
+    alias TRUSTEE_ACCESSA TRUSTEE_ACCESS;
+    alias OBJECTS_AND_NAME_A OBJECTS_AND_NAME_;
+    static if (_WIN32_WINNT >= 0x501) {
+        alias INHERITED_FROMA INHERITED_FROM;
+    }
+}
+
+alias TRUSTEE TRUSTEE_;
+alias TRUSTEE* PTRUSTEE, PTRUSTEE_;
+alias ACTRL_ACCESS* PACTRL_ACCESS;
+alias ACTRL_ACCESS_ENTRY_LIST* PACTRL_ACCESS_ENTRY_LIST;
+alias ACTRL_ACCESS_INFO* PACTRL_ACCESS_INFO;
+alias ACTRL_ACCESS_ENTRY* PACTRL_ACCESS_ENTRY;
+alias ACTRL_AUDIT* PACTRL_AUDIT;
+alias ACTRL_CONTROL_INFO* PACTRL_CONTROL_INFO;
+alias EXPLICIT_ACCESS EXPLICIT_ACCESS_;
+alias EXPLICIT_ACCESS* PEXPLICIT_ACCESS, PEXPLICIT_ACCESS_;
+alias TRUSTEE_ACCESS* PTRUSTEE_ACCESS;
+alias OBJECTS_AND_NAME_* POBJECTS_AND_NAME_;
+static if (_WIN32_WINNT >= 0x501) {
+    alias INHERITED_FROM* PINHERITED_FROM;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/aclapi.d b/libphobos/libdruntime/core/sys/windows/aclapi.d
new file mode 100644
index 00000000000..ed05161bb02
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/aclapi.d
@@ -0,0 +1,139 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_aclapi.d)
+ */
+module core.sys.windows.aclapi;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "advapi32");
+
+import core.sys.windows.windows, core.sys.windows.accctrl;
+
+extern (Windows) {
+    VOID BuildExplicitAccessWithNameA(PEXPLICIT_ACCESS_A, LPSTR, DWORD,
+      ACCESS_MODE, DWORD);
+    VOID BuildExplicitAccessWithNameW(PEXPLICIT_ACCESS_W, LPWSTR, DWORD,
+      ACCESS_MODE, DWORD);
+    DWORD BuildSecurityDescriptorA(PTRUSTEE_A, PTRUSTEE_A , ULONG,
+      PEXPLICIT_ACCESS_A, ULONG, PEXPLICIT_ACCESS_A, PSECURITY_DESCRIPTOR,
+      PULONG, PSECURITY_DESCRIPTOR*);
+    DWORD BuildSecurityDescriptorW(PTRUSTEE_W, PTRUSTEE_W , ULONG,
+      PEXPLICIT_ACCESS_W, ULONG, PEXPLICIT_ACCESS_W, PSECURITY_DESCRIPTOR,
+      PULONG, PSECURITY_DESCRIPTOR*);
+    VOID BuildTrusteeWithNameA(PTRUSTEE_A, LPSTR);
+    VOID BuildTrusteeWithNameW(PTRUSTEE_W, LPWSTR);
+    VOID BuildTrusteeWithObjectsAndNameA(PTRUSTEE_A, POBJECTS_AND_NAME_A,
+      SE_OBJECT_TYPE, LPSTR, LPSTR, LPSTR);
+    VOID BuildTrusteeWithObjectsAndNameW(PTRUSTEE_W, POBJECTS_AND_NAME_W,
+      SE_OBJECT_TYPE, LPWSTR, LPWSTR, LPWSTR);
+    VOID BuildTrusteeWithObjectsAndSidA(PTRUSTEE_A, POBJECTS_AND_SID,
+      GUID*, GUID*, PSID);
+    VOID BuildTrusteeWithObjectsAndSidW(PTRUSTEE_W, POBJECTS_AND_SID,
+      GUID*, GUID*, PSID);
+    VOID BuildTrusteeWithSidA(PTRUSTEE_A, PSID);
+    VOID BuildTrusteeWithSidW(PTRUSTEE_W, PSID);
+    DWORD GetAuditedPermissionsFromAclA(PACL, PTRUSTEE_A, PACCESS_MASK,
+      PACCESS_MASK);
+    DWORD GetAuditedPermissionsFromAclW(PACL, PTRUSTEE_W, PACCESS_MASK,
+      PACCESS_MASK);
+    DWORD GetEffectiveRightsFromAclA(PACL, PTRUSTEE_A, PACCESS_MASK);
+    DWORD GetEffectiveRightsFromAclW(PACL, PTRUSTEE_W, PACCESS_MASK);
+    DWORD GetExplicitEntriesFromAclA(PACL, PULONG, PEXPLICIT_ACCESS_A*);
+    DWORD GetExplicitEntriesFromAclW(PACL, PULONG, PEXPLICIT_ACCESS_W*);
+    static if (_WIN32_WINNT >= 0x501) {
+        DWORD GetInheritanceSourceA(LPSTR, SE_OBJECT_TYPE,
+          SECURITY_INFORMATION, BOOL, GUID**, DWORD, PACL, void*,
+          PGENERIC_MAPPING, PINHERITED_FROMA);
+        DWORD GetInheritanceSourceW(LPWSTR, SE_OBJECT_TYPE,
+          SECURITY_INFORMATION, BOOL, GUID**, DWORD, PACL, void*,
+          PGENERIC_MAPPING, PINHERITED_FROMW);
+    }
+    DWORD GetNamedSecurityInfoA(LPSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION,
+      PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*);
+    DWORD GetNamedSecurityInfoW(LPWSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION,
+      PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*);
+    DWORD GetSecurityInfo(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
+      PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*);
+    TRUSTEE_FORM GetTrusteeFormA(PTRUSTEE_A);
+    TRUSTEE_FORM GetTrusteeFormW(PTRUSTEE_W);
+    LPSTR GetTrusteeNameA(PTRUSTEE_A);
+    LPWSTR GetTrusteeNameW(PTRUSTEE_W);
+    TRUSTEE_TYPE GetTrusteeTypeA(PTRUSTEE_A);
+    TRUSTEE_TYPE GetTrusteeTypeW(PTRUSTEE_W);
+    DWORD LookupSecurityDescriptorPartsA(PTRUSTEE_A*, PTRUSTEE_A*, PULONG,
+      PEXPLICIT_ACCESS_A*, PULONG, PEXPLICIT_ACCESS_A*,
+      PSECURITY_DESCRIPTOR);
+    DWORD LookupSecurityDescriptorPartsW(PTRUSTEE_W*, PTRUSTEE_W*, PULONG,
+      PEXPLICIT_ACCESS_W*, PULONG, PEXPLICIT_ACCESS_W*,
+      PSECURITY_DESCRIPTOR);
+    DWORD SetEntriesInAclA(ULONG, PEXPLICIT_ACCESS_A, PACL, PACL*);
+    DWORD SetEntriesInAclW(ULONG, PEXPLICIT_ACCESS_W, PACL, PACL*);
+    DWORD SetNamedSecurityInfoA(LPSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION,
+      PSID, PSID, PACL, PACL);
+    DWORD SetNamedSecurityInfoW(LPWSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION,
+      PSID, PSID, PACL, PACL);
+    DWORD SetSecurityInfo(HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION, PSID,
+      PSID, PACL, PACL);
+    VOID BuildImpersonateExplicitAccessWithNameA(PEXPLICIT_ACCESS_A, LPSTR,
+      PTRUSTEE_A, DWORD, ACCESS_MODE, DWORD);
+    VOID BuildImpersonateExplicitAccessWithNameW(PEXPLICIT_ACCESS_W, LPWSTR,
+      PTRUSTEE_W, DWORD, ACCESS_MODE, DWORD);
+    VOID BuildImpersonateTrusteeA(PTRUSTEE_A, PTRUSTEE_A);
+    VOID BuildImpersonateTrusteeW(PTRUSTEE_W, PTRUSTEE_W);
+    PTRUSTEE_A GetMultipleTrusteeA(PTRUSTEE_A);
+    PTRUSTEE_W GetMultipleTrusteeW(PTRUSTEE_W);
+    MULTIPLE_TRUSTEE_OPERATION GetMultipleTrusteeOperationA(PTRUSTEE_A);
+    MULTIPLE_TRUSTEE_OPERATION GetMultipleTrusteeOperationW(PTRUSTEE_W);
+}
+
+version (Unicode) {
+    alias BuildExplicitAccessWithNameW BuildExplicitAccessWithName;
+    alias BuildSecurityDescriptorW BuildSecurityDescriptor;
+    alias BuildTrusteeWithNameW BuildTrusteeWithName;
+    alias BuildTrusteeWithObjectsAndNameW BuildTrusteeWithObjectsAndName;
+    alias BuildTrusteeWithObjectsAndSidW BuildTrusteeWithObjectsAndSid;
+    alias BuildTrusteeWithSidW BuildTrusteeWithSid;
+    alias GetAuditedPermissionsFromAclW GetAuditedPermissionsFromAcl;
+    alias GetEffectiveRightsFromAclW GetEffectiveRightsFromAcl;
+    alias GetExplicitEntriesFromAclW GetExplicitEntriesFromAcl;
+    alias GetNamedSecurityInfoW GetNamedSecurityInfo;
+    alias GetTrusteeFormW GetTrusteeForm;
+    alias GetTrusteeNameW GetTrusteeName;
+    alias GetTrusteeTypeW GetTrusteeType;
+    alias LookupSecurityDescriptorPartsW LookupSecurityDescriptorParts;
+    alias SetEntriesInAclW SetEntriesInAcl;
+    alias SetNamedSecurityInfoW SetNamedSecurityInfo;
+    alias BuildImpersonateExplicitAccessWithNameW
+      BuildImpersonateExplicitAccessWithName;
+    alias BuildImpersonateTrusteeW BuildImpersonateTrustee;
+    alias GetMultipleTrusteeW GetMultipleTrustee;
+    alias GetMultipleTrusteeOperationW GetMultipleTrusteeOperation;
+} else {
+    alias BuildExplicitAccessWithNameA BuildExplicitAccessWithName;
+    alias BuildSecurityDescriptorA BuildSecurityDescriptor;
+    alias BuildTrusteeWithNameA BuildTrusteeWithName;
+    alias BuildTrusteeWithObjectsAndNameA BuildTrusteeWithObjectsAndName;
+    alias BuildTrusteeWithObjectsAndSidA BuildTrusteeWithObjectsAndSid;
+    alias BuildTrusteeWithSidA BuildTrusteeWithSid;
+    alias GetAuditedPermissionsFromAclA GetAuditedPermissionsFromAcl;
+    alias GetEffectiveRightsFromAclA GetEffectiveRightsFromAcl;
+    alias GetExplicitEntriesFromAclA GetExplicitEntriesFromAcl;
+    alias GetNamedSecurityInfoA GetNamedSecurityInfo;
+    alias GetTrusteeFormA GetTrusteeForm;
+    alias GetTrusteeNameA GetTrusteeName;
+    alias GetTrusteeTypeA GetTrusteeType;
+    alias LookupSecurityDescriptorPartsA LookupSecurityDescriptorParts;
+    alias SetEntriesInAclA SetEntriesInAcl;
+    alias SetNamedSecurityInfoA SetNamedSecurityInfo;
+    alias BuildImpersonateExplicitAccessWithNameA
+      BuildImpersonateExplicitAccessWithName;
+    alias BuildImpersonateTrusteeA BuildImpersonateTrustee;
+    alias GetMultipleTrusteeA GetMultipleTrustee;
+    alias GetMultipleTrusteeOperationA GetMultipleTrusteeOperation;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/aclui.d b/libphobos/libdruntime/core/sys/windows/aclui.d
new file mode 100644
index 00000000000..6000375454c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/aclui.d
@@ -0,0 +1,120 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.10
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_aclui.d)
+ */
+module core.sys.windows.aclui;
+version (Windows):
+pragma(lib, "aclui");
+
+private import core.sys.windows.w32api;
+/*
+static assert (_WIN32_WINNT >= 0x500,
+    "core.sys.windows.aclui is available only if version Windows2000, WindowsXP, Windows2003 "
+    "or WindowsVista is set");
+*/
+import core.sys.windows.accctrl, core.sys.windows.commctrl, core.sys.windows.objbase;
+private import core.sys.windows.basetyps, core.sys.windows.prsht, core.sys.windows.unknwn, core.sys.windows.windef,
+  core.sys.windows.winuser;
+
+
+struct SI_OBJECT_INFO {
+    DWORD     dwFlags;
+    HINSTANCE hInstance;
+    LPWSTR    pszServerName;
+    LPWSTR    pszObjectName;
+    LPWSTR    pszPageTitle;
+    GUID      guidObjectType;
+}
+alias SI_OBJECT_INFO* PSI_OBJECT_INFO;
+
+// values for SI_OBJECT_INFO.dwFlags
+enum DWORD
+    SI_EDIT_PERMS               = 0x00000000,
+    SI_EDIT_OWNER               = 0x00000001,
+    SI_EDIT_AUDITS              = 0x00000002,
+    SI_CONTAINER                = 0x00000004,
+    SI_READONLY                 = 0x00000008,
+    SI_ADVANCED                 = 0x00000010,
+    SI_RESET                    = 0x00000020,
+    SI_OWNER_READONLY           = 0x00000040,
+    SI_EDIT_PROPERTIES          = 0x00000080,
+    SI_OWNER_RECURSE            = 0x00000100,
+    SI_NO_ACL_PROTECT           = 0x00000200,
+    SI_NO_TREE_APPLY            = 0x00000400,
+    SI_PAGE_TITLE               = 0x00000800,
+    SI_SERVER_IS_DC             = 0x00001000,
+    SI_RESET_DACL_TREE          = 0x00004000,
+    SI_RESET_SACL_TREE          = 0x00008000,
+    SI_OBJECT_GUID              = 0x00010000,
+    SI_EDIT_EFFECTIVE           = 0x00020000,
+    SI_RESET_DACL               = 0x00040000,
+    SI_RESET_SACL               = 0x00080000,
+    SI_RESET_OWNER              = 0x00100000,
+    SI_NO_ADDITIONAL_PERMISSION = 0x00200000,
+    SI_MAY_WRITE                = 0x10000000,
+    SI_EDIT_ALL                 = SI_EDIT_PERMS | SI_EDIT_OWNER
+                                  | SI_EDIT_AUDITS;
+
+struct SI_ACCESS {
+const(GUID)* pguid;
+    ACCESS_MASK  mask;
+    LPCWSTR      pszName;
+    DWORD        dwFlags;
+}
+alias SI_ACCESS* PSI_ACCESS;
+
+// values for SI_ACCESS.dwFlags
+enum DWORD
+    SI_ACCESS_SPECIFIC  = 0x00010000,
+    SI_ACCESS_GENERAL   = 0x00020000,
+    SI_ACCESS_CONTAINER = 0x00040000,
+    SI_ACCESS_PROPERTY  = 0x00080000;
+
+
+struct SI_INHERIT_TYPE {
+const(GUID)* pguid;
+    ULONG        dwFlags;
+    LPCWSTR      pszName;
+}
+alias SI_INHERIT_TYPE* PSI_INHERIT_TYPE;
+
+/* values for SI_INHERIT_TYPE.dwFlags
+   INHERIT_ONLY_ACE, CONTAINER_INHERIT_ACE, OBJECT_INHERIT_ACE
+   defined elsewhere */
+
+enum SI_PAGE_TYPE {
+    SI_PAGE_PERM,
+    SI_PAGE_ADVPERM,
+    SI_PAGE_AUDIT,
+    SI_PAGE_OWNER
+}
+
+enum uint PSPCB_SI_INITDIALOG = WM_USER + 1;
+
+interface ISecurityInformation : IUnknown {
+    HRESULT GetObjectInformation(PSI_OBJECT_INFO);
+    HRESULT GetSecurity(SECURITY_INFORMATION, PSECURITY_DESCRIPTOR*, BOOL);
+    HRESULT SetSecurity(SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
+    HRESULT GetAccessRights(const(GUID)*, DWORD, PSI_ACCESS*, ULONG*, ULONG*);
+    HRESULT MapGeneric(const(GUID)*, UCHAR*, ACCESS_MASK*);
+    HRESULT GetInheritTypes(PSI_INHERIT_TYPE*, ULONG*);
+    HRESULT PropertySheetPageCallback(HWND, UINT, SI_PAGE_TYPE);
+}
+alias ISecurityInformation LPSECURITYINFO;
+
+/* Comment from MinGW
+ * TODO: ISecurityInformation2, IEffectivePermission, ISecurityObjectTypeInfo
+ */
+
+// FIXME: linkage attribute?
+extern (C) /+DECLSPEC_IMPORT+/ extern const IID IID_ISecurityInformation;
+
+extern (Windows) {
+    HPROPSHEETPAGE CreateSecurityPage(LPSECURITYINFO psi);
+    BOOL EditSecurity(HWND hwndOwner, LPSECURITYINFO psi);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/basetsd.d b/libphobos/libdruntime/core/sys/windows/basetsd.d
new file mode 100644
index 00000000000..9ac18416efb
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/basetsd.d
@@ -0,0 +1,159 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.12
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_basetsd.d)
+ */
+module core.sys.windows.basetsd;
+version (Windows):
+
+/*  This template is used in these modules to declare constant pointer types,
+ *  in order to support both D 1.x and 2.x.
+ *  Since removed - now supporting only D2
+ */
+/*template CPtr(T) {
+    version (D_Version2) {
+        // must use mixin so that it doesn't cause a syntax error under D1
+        mixin("alias const(T)* CPtr;");
+    } else {
+        alias T* CPtr;
+    }
+}*/
+
+/*  [CyberShadow VP 2011.12.22] typedef is now deprecated in D2.
+ */
+template TypeDef(T) {
+    version (D_Version2) {
+        alias T TypeDef;
+    } else {
+        // must use mixin so that it doesn't cause a deprecation error under D2
+        mixin("typedef T TypeDef;");
+    }
+}
+
+// [SnakE 2009-02-23] Moved HANDLE definition here from winnt.d to avoid
+// 'forwatd template reference' to CPtr from winnt.d caused by a circular
+// import.
+
+alias TypeDef!(void*) HANDLE;
+/+struct HANDLE {
+const(void)* h;
+    alias h this;
+}+/
+
+package template DECLARE_HANDLE(string name, base = HANDLE) {
+    mixin ("alias " ~ base.stringof ~ " " ~ name ~ ";");
+}
+alias HANDLE* PHANDLE, LPHANDLE;
+
+version (Win64) {
+    alias long __int3264;
+enum ulong ADDRESS_TAG_BIT = 0x40000000000;
+
+    alias long INT_PTR, LONG_PTR;
+    alias long* PINT_PTR, PLONG_PTR;
+    alias ulong UINT_PTR, ULONG_PTR, HANDLE_PTR;
+    alias ulong* PUINT_PTR, PULONG_PTR;
+    alias int HALF_PTR;
+    alias int* PHALF_PTR;
+    alias uint UHALF_PTR;
+    alias uint* PUHALF_PTR;
+
+    uint HandleToULong(void* h) { return(cast(uint) cast(ULONG_PTR) h); }
+    int HandleToLong(void* h)   { return(cast(int) cast(LONG_PTR) h); }
+    void* ULongToHandle(uint h) { return(cast(void*) cast(UINT_PTR) h); }
+    void* LongToHandle(int h)   { return(cast(void*) cast(INT_PTR) h); }
+    uint PtrToUlong(void* p)    { return(cast(uint) cast(ULONG_PTR) p); }
+    uint PtrToUint(void* p)     { return(cast(uint) cast(UINT_PTR) p); }
+    ushort PtrToUshort(void* p) { return(cast(ushort) cast(uint) cast(ULONG_PTR) p); }
+    int PtrToLong(void* p)      { return(cast(int) cast(LONG_PTR) p); }
+    int PtrToInt(void* p)       { return(cast(int) cast(INT_PTR) p); }
+    short PtrToShort(void* p)   { return(cast(short) cast(int) cast(LONG_PTR) p); }
+    void* IntToPtr(int i)       { return(cast(void*) cast(INT_PTR) i); }
+    void* UIntToPtr(uint ui)    { return(cast(void*) cast(UINT_PTR) ui); }
+    void* LongToPtr(int l)      { return(cast(void*) cast(LONG_PTR) l); }
+    void* ULongToPtr(uint ul)   { return(cast(void*) cast(ULONG_PTR) ul); }
+
+} else {
+    alias int __int3264;
+enum uint ADDRESS_TAG_BIT = 0x80000000;
+
+    alias int INT_PTR, LONG_PTR;
+    alias int* PINT_PTR, PLONG_PTR;
+    alias uint UINT_PTR, ULONG_PTR, HANDLE_PTR;
+    alias uint* PUINT_PTR, PULONG_PTR;
+    alias short HALF_PTR;
+    alias short* PHALF_PTR;
+    alias ushort UHALF_PTR;
+    alias ushort* PUHALF_PTR;
+
+    uint HandleToUlong(HANDLE h)      { return cast(uint) h; }
+    int HandleToLong(HANDLE h)        { return cast(int) h; }
+    HANDLE LongToHandle(LONG_PTR h)   { return cast(HANDLE)h; }
+    uint PtrToUlong(const(void)* p)    { return cast(uint) p; }
+    uint PtrToUint(const(void)* p)     { return cast(uint) p; }
+    int PtrToInt(const(void)* p)       { return cast(int) p; }
+    ushort PtrToUshort(const(void)* p) { return cast(ushort) p; }
+    short PtrToShort(const(void)* p)   { return cast(short) p; }
+    void* IntToPtr(int i)             { return cast(void*) i; }
+    void* UIntToPtr(uint ui)          { return cast(void*) ui; }
+    alias IntToPtr LongToPtr;
+    alias UIntToPtr ULongToPtr;
+}
+
+alias UIntToPtr UintToPtr, UlongToPtr;
+
+enum : UINT_PTR {
+    MAXUINT_PTR = UINT_PTR.max
+}
+
+enum : INT_PTR {
+    MAXINT_PTR = INT_PTR.max,
+    MININT_PTR = INT_PTR.min
+}
+
+enum : ULONG_PTR {
+    MAXULONG_PTR = ULONG_PTR.max
+}
+
+enum : LONG_PTR {
+    MAXLONG_PTR = LONG_PTR.max,
+    MINLONG_PTR = LONG_PTR.min
+}
+
+enum : UHALF_PTR {
+    MAXUHALF_PTR = UHALF_PTR.max
+}
+
+enum : HALF_PTR {
+    MAXHALF_PTR = HALF_PTR.max,
+    MINHALF_PTR = HALF_PTR.min
+}
+
+alias byte INT8;
+alias byte* PINT8;
+alias ubyte UINT8;
+alias ubyte* PUINT8;
+
+alias short INT16;
+alias short* PINT16;
+alias ushort UINT16;
+alias ushort* PUINT16;
+
+alias int LONG32, INT32;
+alias int* PLONG32, PINT32;
+alias uint ULONG32, DWORD32, UINT32;
+alias uint* PULONG32, PDWORD32, PUINT32;
+
+alias ULONG_PTR SIZE_T, DWORD_PTR;
+alias ULONG_PTR* PSIZE_T, PDWORD_PTR;
+alias LONG_PTR SSIZE_T;
+alias LONG_PTR* PSSIZE_T;
+
+alias long LONG64, INT64;
+alias long* PLONG64, PINT64;
+alias ulong ULONG64, DWORD64, UINT64;
+alias ulong* PULONG64, PDWORD64, PUINT64;
diff --git a/libphobos/libdruntime/core/sys/windows/basetyps.d b/libphobos/libdruntime/core/sys/windows/basetyps.d
new file mode 100644
index 00000000000..bef43075e20
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/basetyps.d
@@ -0,0 +1,27 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.10
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_basetyps.d)
+ */
+module core.sys.windows.basetyps;
+version (Windows):
+
+private import core.sys.windows.windef, core.sys.windows.basetsd;
+
+align(1) struct GUID {  // size is 16
+    align(1):
+    DWORD   Data1;
+    WORD    Data2;
+    WORD    Data3;
+    BYTE[8] Data4;
+}
+alias GUID UUID, /*IID, CLSID, */FMTID, uuid_t;
+alias IID = const(GUID);
+alias CLSID = const(GUID);
+
+alias GUID* LPGUID, LPCLSID, LPIID;
+alias const(GUID)* LPCGUID, REFGUID, REFIID, REFCLSID, REFFMTID;
+alias uint error_status_t, PROPID;
diff --git a/libphobos/libdruntime/core/sys/windows/cderr.d b/libphobos/libdruntime/core/sys/windows/cderr.d
new file mode 100644
index 00000000000..278a11c5b95
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/cderr.d
@@ -0,0 +1,50 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_cderr.d)
+ */
+module core.sys.windows.cderr;
+version (Windows):
+
+enum {
+    CDERR_DIALOGFAILURE    = 0xFFFF,
+    CDERR_GENERALCODES     = 0x0000,
+    CDERR_STRUCTSIZE,
+    CDERR_INITIALIZATION,
+    CDERR_NOTEMPLATE,
+    CDERR_NOHINSTANCE,
+    CDERR_LOADSTRFAILURE,
+    CDERR_FINDRESFAILURE,
+    CDERR_LOADRESFAILURE,
+    CDERR_LOCKRESFAILURE,
+    CDERR_MEMALLOCFAILURE,
+    CDERR_MEMLOCKFAILURE,
+    CDERR_NOHOOK,
+    CDERR_REGISTERMSGFAIL,
+    PDERR_PRINTERCODES     = 0x1000,
+    PDERR_SETUPFAILURE,
+    PDERR_PARSEFAILURE,
+    PDERR_RETDEFFAILURE,
+    PDERR_LOADDRVFAILURE,
+    PDERR_GETDEVMODEFAIL,
+    PDERR_INITFAILURE,
+    PDERR_NODEVICES,
+    PDERR_NODEFAULTPRN,
+    PDERR_DNDMMISMATCH,
+    PDERR_CREATEICFAILURE,
+    PDERR_PRINTERNOTFOUND,
+    PDERR_DEFAULTDIFFERENT,
+    CFERR_CHOOSEFONTCODES  = 0x2000,
+    CFERR_NOFONTS,
+    CFERR_MAXLESSTHANMIN,
+    FNERR_FILENAMECODES    = 0x3000,
+    FNERR_SUBCLASSFAILURE,
+    FNERR_INVALIDFILENAME,
+    FNERR_BUFFERTOOSMALL,
+    FRERR_FINDREPLACECODES = 0x4000,
+    FRERR_BUFFERLENGTHZERO,
+    CCERR_CHOOSECOLORCODES = 0x5000
+}
diff --git a/libphobos/libdruntime/core/sys/windows/cguid.d b/libphobos/libdruntime/core/sys/windows/cguid.d
new file mode 100644
index 00000000000..b6db658be9e
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/cguid.d
@@ -0,0 +1,13 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_cguid.d)
+ */
+module core.sys.windows.cguid;
+version (Windows):
+
+private import core.sys.windows.basetyps;
+
diff --git a/libphobos/libdruntime/core/sys/windows/com.d b/libphobos/libdruntime/core/sys/windows/com.d
new file mode 100644
index 00000000000..caa6907d63c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/com.d
@@ -0,0 +1,105 @@
+module core.sys.windows.com;
+version (Windows):
+
+version (GNU) {}
+else pragma(lib,"uuid");
+
+import core.atomic;
+import core.sys.windows.windows;
+//import std.string;
+
+public import core.sys.windows.basetyps : GUID, IID, CLSID;
+
+public import core.sys.windows.objbase :
+    CLSCTX_INPROC, CLSCTX_ALL, CLSCTX_SERVER,
+    COINIT,
+    CoBuildVersion, StringFromGUID2,
+    CoInitialize, CoInitializeEx, CoUninitialize, CoGetCurrentProcess,
+    CoCreateInstance,
+    CoFreeLibrary, CoFreeAllLibraries, CoFreeUnusedLibraries;
+
+public import core.sys.windows.ole2ver : rmm, rup;
+
+public import core.sys.windows.unknwn : IUnknown, IClassFactory;
+
+public import core.sys.windows.winerror :
+    S_OK,
+    S_FALSE,
+    NOERROR,
+    E_NOTIMPL,
+    E_NOINTERFACE,
+    E_POINTER,
+    E_ABORT,
+    E_FAIL,
+    E_HANDLE,
+    CLASS_E_NOAGGREGATION,
+    E_OUTOFMEMORY,
+    E_INVALIDARG,
+    E_UNEXPECTED,
+    RPC_E_CHANGED_MODE;
+
+public import core.sys.windows.wtypes :
+    OLECHAR, LPOLESTR, LPCOLESTR;
+
+alias CLSCTX_INPROC_SERVER     = core.sys.windows.wtypes.CLSCTX.CLSCTX_INPROC_SERVER    ;
+alias CLSCTX_INPROC_HANDLER    = core.sys.windows.wtypes.CLSCTX.CLSCTX_INPROC_HANDLER   ;
+alias CLSCTX_LOCAL_SERVER      = core.sys.windows.wtypes.CLSCTX.CLSCTX_LOCAL_SERVER     ;
+alias CLSCTX_INPROC_SERVER16   = core.sys.windows.wtypes.CLSCTX.CLSCTX_INPROC_SERVER16  ;
+alias CLSCTX_REMOTE_SERVER     = core.sys.windows.wtypes.CLSCTX.CLSCTX_REMOTE_SERVER    ;
+alias CLSCTX_INPROC_HANDLER16  = core.sys.windows.wtypes.CLSCTX.CLSCTX_INPROC_HANDLER16 ;
+alias CLSCTX_INPROC_SERVERX86  = core.sys.windows.wtypes.CLSCTX.CLSCTX_INPROC_SERVERX86 ;
+alias CLSCTX_INPROC_HANDLERX86 = core.sys.windows.wtypes.CLSCTX.CLSCTX_INPROC_HANDLERX86;
+
+alias COINIT_APARTMENTTHREADED   = COINIT.COINIT_APARTMENTTHREADED;
+alias COINIT_MULTITHREADED       = COINIT.COINIT_MULTITHREADED    ;
+alias COINIT_DISABLE_OLE1DDE     = COINIT.COINIT_DISABLE_OLE1DDE  ;
+alias COINIT_SPEED_OVER_MEMORY   = COINIT.COINIT_SPEED_OVER_MEMORY;
+
+public import core.sys.windows.uuid;
+
+extern (System)
+{
+
+class ComObject : IUnknown
+{
+extern (System):
+    HRESULT QueryInterface(const(IID)* riid, void** ppv)
+    {
+        if (*riid == IID_IUnknown)
+        {
+            *ppv = cast(void*)cast(IUnknown)this;
+            AddRef();
+            return S_OK;
+        }
+        else
+        {   *ppv = null;
+            return E_NOINTERFACE;
+        }
+    }
+
+    ULONG AddRef()
+    {
+        return atomicOp!"+="(*cast(shared)&count, 1);
+    }
+
+    ULONG Release()
+    {
+        LONG lRef = atomicOp!"-="(*cast(shared)&count, 1);
+        if (lRef == 0)
+        {
+            // free object
+
+            // If we delete this object, then the postinvariant called upon
+            // return from Release() will fail.
+            // Just let the GC reap it.
+            //delete this;
+
+            return 0;
+        }
+        return cast(ULONG)lRef;
+    }
+
+    LONG count = 0;             // object reference count
+}
+
+}
diff --git a/libphobos/libdruntime/core/sys/windows/comcat.d b/libphobos/libdruntime/core/sys/windows/comcat.d
new file mode 100644
index 00000000000..36c6a9125cb
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/comcat.d
@@ -0,0 +1,73 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_comcat.d)
+ */
+module core.sys.windows.comcat;
+version (Windows):
+
+import core.sys.windows.windows, core.sys.windows.ole2;
+private import core.sys.windows.basetyps, core.sys.windows.cguid, core.sys.windows.objbase, core.sys.windows.unknwn,
+  core.sys.windows.windef, core.sys.windows.wtypes;
+
+alias IEnumGUID LPENUMGUID;
+
+interface IEnumGUID : IUnknown {
+    HRESULT Next(ULONG, GUID*, ULONG*);
+    HRESULT Skip(ULONG);
+    HRESULT Reset();
+    HRESULT Clone(LPENUMGUID*);
+}
+
+alias GUID CATID;
+alias REFGUID REFCATID;
+alias GUID_NULL CATID_NULL;
+alias IsEqualGUID IsEqualCATID;
+
+struct CATEGORYINFO {
+    CATID        catid;
+    LCID         lcid;
+    OLECHAR[128] szDescription;
+}
+alias CATEGORYINFO* LPCATEGORYINFO;
+
+alias IEnumGUID IEnumCATID;
+alias LPENUMGUID LPENUMCATID;
+alias IID_IEnumGUID IID_IEnumCATID;
+
+alias IEnumGUID IEnumCLSID;
+alias LPENUMGUID LPENUMCLSID;
+alias IID_IEnumGUID IID_IEnumCLSID;
+
+interface ICatInformation : IUnknown {
+    HRESULT EnumCategories(LCID, LPENUMCATEGORYINFO*);
+    HRESULT GetCategoryDesc(REFCATID, LCID, PWCHAR*);
+    HRESULT EnumClassesOfCategories(ULONG, CATID*, ULONG, CATID*,
+      LPENUMCLSID*);
+    HRESULT IsClassOfCategories(REFCLSID, ULONG, CATID*, ULONG, CATID*);
+    HRESULT EnumImplCategoriesOfClass(REFCLSID, LPENUMCATID*);
+    HRESULT EnumReqCategoriesOfClass(REFCLSID, LPENUMCATID*);
+}
+alias ICatInformation LPCATINFORMATION;
+
+interface ICatRegister : IUnknown {
+    HRESULT RegisterCategories(ULONG, CATEGORYINFO*);
+    HRESULT UnRegisterCategories(ULONG, CATID*);
+    HRESULT RegisterClassImplCategories(REFCLSID, ULONG, CATID*);
+    HRESULT UnRegisterClassImplCategories(REFCLSID, ULONG, CATID*);
+    HRESULT RegisterClassReqCategories(REFCLSID, ULONG, CATID*);
+    HRESULT UnRegisterClassReqCategories(REFCLSID, ULONG, CATID*);
+}
+alias ICatRegister LPCATREGISTER;
+
+interface IEnumCATEGORYINFO : IUnknown {
+    HRESULT Next(ULONG, CATEGORYINFO*, ULONG*);
+    HRESULT Skip(ULONG);
+    HRESULT Reset();
+    HRESULT Clone(LPENUMCATEGORYINFO*);
+}
+alias IEnumCATEGORYINFO LPENUMCATEGORYINFO;
diff --git a/libphobos/libdruntime/core/sys/windows/commctrl.d b/libphobos/libdruntime/core/sys/windows/commctrl.d
new file mode 100644
index 00000000000..ba390816288
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/commctrl.d
@@ -0,0 +1,6282 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.12
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_commctrl.d)
+ */
+module core.sys.windows.commctrl;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "comctl32");
+
+private import core.sys.windows.w32api, core.sys.windows.windef, core.sys.windows.winuser;
+private import core.sys.windows.winbase; // for SYSTEMTIME
+private import core.sys.windows.objfwd;  // for LPSTREAM
+
+import core.sys.windows.prsht;
+
+enum COMCTL32_VERSION = 6;
+
+const TCHAR[]
+    DRAGLISTMSGSTRING  = "commctrl_DragListMsg",
+    HOTKEY_CLASS       = "msctls_hotkey32",
+    PROGRESS_CLASS     = "msctls_progress32",
+    STATUSCLASSNAME    = "msctls_statusbar32",
+    TOOLBARCLASSNAME   = "ToolbarWindow32",
+    TOOLTIPS_CLASS     = "tooltips_class32",
+    TRACKBAR_CLASS     = "msctls_trackbar32",
+    UPDOWN_CLASS       = "msctls_updown32",
+    ANIMATE_CLASS      = "SysAnimate32",
+    DATETIMEPICK_CLASS = "SysDateTimePick32",
+    MONTHCAL_CLASS     = "SysMonthCal32",
+    REBARCLASSNAME     = "ReBarWindow32",
+    WC_COMBOBOXEX      = "ComboBoxEx32",
+    WC_IPADDRESS       = "SysIPAddress32",
+    WC_LISTVIEW        = "SysListView32",
+    WC_TABCONTROL      = "SysTabControl32",
+    WC_TREEVIEW        = "SysTreeView32",
+    WC_HEADER          = "SysHeader32",
+    WC_PAGESCROLLER    = "SysPager",
+    WC_NATIVEFONTCTL   = "NativeFontCtl",
+    WC_BUTTON          = "Button",
+    WC_STATIC          = "Static",
+    WC_EDIT            = "Edit",
+    WC_LISTBOX         = "ListBox",
+    WC_COMBOBOX        = "ComboBox",
+    WC_SCROLLBAR       = "ScrollBar",
+    WC_LINKA           = "SysLink";
+
+enum {
+    LVM_FIRST = 0x1000,
+    TV_FIRST  = 0x1100,
+    HDM_FIRST = 0x1200
+}
+
+enum {
+    ACM_OPENA = WM_USER + 100,
+    ACM_PLAY  = WM_USER + 101,
+    ACM_STOP  = WM_USER + 102,
+    ACM_OPENW = WM_USER + 103,
+    ACM_ISPLAYING = WM_USER + 104
+}
+
+enum {
+    ACN_START = 1,
+    ACN_STOP
+}
+
+enum {
+    CBEIF_TEXT          = 0x00000001,
+    CBEIF_IMAGE         = 0x00000002,
+    CBEIF_SELECTEDIMAGE = 0x00000004,
+    CBEIF_OVERLAY       = 0x00000008,
+    CBEIF_INDENT        = 0x00000010,
+    CBEIF_LPARAM        = 0x00000020,
+    CBEIF_DI_SETITEM    = 0x10000000
+}
+
+enum {
+    RBN_FIRST  = -831U,
+    RBN_LAST   = -859U,
+    MCN_FIRST  = -750U,
+    MCN_LAST   = -759U,
+    DTN_FIRST  = -760U,
+    DTN_LAST   = -799U,
+    CBEN_FIRST = -800U,
+    CBEN_LAST  = -830U
+}
+
+enum {
+    CBEN_INSERTITEM = CBEN_FIRST - 1,
+    CBEN_DELETEITEM = CBEN_FIRST - 2,
+    CBEN_BEGINEDIT  = CBEN_FIRST - 4,
+    CBEN_ENDEDITA   = CBEN_FIRST - 5,
+    CBEN_ENDEDITW   = CBEN_FIRST - 6
+}
+
+enum {
+    CBENF_KILLFOCUS = 1,
+    CBENF_RETURN,
+    CBENF_ESCAPE,
+    CBENF_DROPDOWN // = 4
+}
+
+enum CBEMAXSTRLEN = 260;
+
+enum {
+    DL_BEGINDRAG  = 1157,
+    DL_CANCELDRAG = 1160,
+    DL_DRAGGING   = 1158,
+    DL_DROPPED    = 1159,
+    DL_CURSORSET  = 0,
+    DL_STOPCURSOR = 1,
+    DL_COPYCURSOR = 2,
+    DL_MOVECURSOR = 3
+}
+
+enum {
+    CCS_TOP           = 1,
+    CCS_NOMOVEY       = 2,
+    CCS_BOTTOM        = 3,
+    CCS_NORESIZE      = 4,
+    CCS_NOPARENTALIGN = 8,
+    CCS_ADJUSTABLE    = 32,
+    CCS_NODIVIDER     = 64
+}
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        CCS_VERT    = 128,
+        CCS_LEFT    = 129,
+        CCS_NOMOVEX = 130,
+        CCS_RIGHT   = 131
+    }
+}
+
+enum {
+    ACS_CENTER      = 0x0001,
+    ACS_TRANSPARENT = 0x0002,
+    ACS_AUTOPLAY    = 0x0004,
+    ACS_TIMER       = 0x0008
+}
+
+enum {
+    PGS_VERT       = 0x00000000,
+    PGS_HORZ       = 0x00000001,
+    PGS_AUTOSCROLL = 0x00000002,
+    PGS_DRAGNDROP  = 0x00000004
+}
+
+enum CMB_MASKED = 2;
+
+enum MINSYSCOMMAND = SC_SIZE;
+
+enum {
+    SBT_OWNERDRAW  = 0x1000,
+    SBT_NOBORDERS  = 256,
+    SBT_POPOUT     = 512,
+    SBT_RTLREADING = 1024
+}
+
+enum {
+    SB_SETTEXTA       = WM_USER + 1,
+    SB_SETTEXTW       = WM_USER + 11,
+    SB_GETTEXTA       = WM_USER + 2,
+    SB_GETTEXTW       = WM_USER + 13,
+    SB_GETTEXTLENGTHA = WM_USER + 3,
+    SB_GETTEXTLENGTHW = WM_USER + 12,
+    SB_SETPARTS       = WM_USER + 4,
+    SB_GETPARTS       = WM_USER + 6,
+    SB_GETBORDERS     = WM_USER + 7,
+    SB_SETMINHEIGHT   = WM_USER + 8,
+    SB_SIMPLE         = WM_USER + 9,
+    SB_GETRECT        = WM_USER + 10
+}
+
+enum {
+    MSGF_COMMCTRL_BEGINDRAG   = 0x4200,
+    MSGF_COMMCTRL_SIZEHEADER  = 0x4201,
+    MSGF_COMMCTRL_DRAGSELECT  = 0x4202,
+    MSGF_COMMCTRL_TOOLBARCUST = 0x4203
+}
+
+enum {
+    ILC_COLOR    = 0,
+    ILC_COLOR4   = 4,
+    ILC_COLOR8   = 8,
+    ILC_COLOR16  = 16,
+    ILC_COLOR24  = 24,
+    ILC_COLOR32  = 32,
+    ILC_COLORDDB = 254,
+    ILC_MASK     = 1,
+    ILC_PALETTE  = 2048
+}
+
+enum {
+    ILCF_MOVE,
+    ILCF_SWAP
+}
+
+enum {
+    ILS_NORMAL        = 0,
+    ILS_GLOW          = 1,
+    ILS_SHADOW        = 2,
+    ILS_SATURATE      = 4,
+    ILS_ALPHA         = 8,
+    ILD_BLEND25       = 2,
+    ILD_BLEND50       = 4,
+    ILD_SELECTED      = 4,
+    ILD_BLEND         = 4,
+    ILD_FOCUS         = 2,
+    ILD_MASK          = 16,
+    ILD_NORMAL        = 0,
+    ILD_TRANSPARENT   = 1,
+    ILD_IMAGE         = 0x0020,
+    ILD_ROP           = 0x0040,
+    ILD_OVERLAYMASK   = 0x0F00,
+    ILD_PRESERVEALPHA = 0x1000,
+    ILD_SCALE         = 0x2000,
+    ILD_DPISCALE      = 0x4000
+}
+
+enum {
+    HDS_HORZ    = 0,
+    HDS_BUTTONS = 2,
+    HDS_HIDDEN  = 8
+}
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        HDS_HOTTRACK = 4,
+        HDS_DRAGDROP = 0x0040,
+        HDS_FULLDRAG = 0x0080
+    }
+}
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        HDS_FILTERBAR = 0x0100
+    }
+}
+
+enum {
+    NM_FIRST  = 0,
+    NM_LAST   = -99U,
+    LVN_FIRST = -100U,
+    LVN_LAST  = -199U,
+    HDN_FIRST = -300U,
+    HDN_LAST  = -399U,
+    TVN_FIRST = -400U,
+    TVN_LAST  = -499U,
+    TTN_FIRST = -520U,
+    TTN_LAST  = -549U,
+    TCN_FIRST = -550U,
+    TCN_LAST  = -580U,
+    CDN_FIRST = -601U, /* also in commdlg.h */
+    CDN_LAST  = -699U,
+    TBN_FIRST = -700U,
+    TBN_LAST  = -720U,
+    UDN_FIRST = -721U,
+    UDN_LAST  = -740U
+}
+/*static if (_WIN32_IE >= 0x300) {
+    enum {
+        RBN_FIRST  = -831U,
+        RBN_LAST   = -859U,
+        MCN_FIRST  = -750U,
+        MCN_LAST   = -759U,
+        DTN_FIRST  = -760U,
+        DTN_LAST   = -799U,
+        CBEN_FIRST = -800U,
+        CBEN_LAST  = -830U
+    }
+}*/
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        IPN_FIRST        = -860U,
+        IPN_LAST         = -879U,
+        IPN_FIELDCHANGED = IPN_FIRST,
+        SBN_FIRST        = -880U,
+        SBN_LAST         = -899U,
+        PGN_FIRST        = -900U,
+        PGN_LAST         = -950U,
+        PGN_SCROLL       = PGN_FIRST-1,
+        PGN_CALCSIZE     = PGN_FIRST-2
+    }
+}
+
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        WMN_FIRST = -1000U,
+        WMN_LAST = -1200U,
+    }
+}
+
+static if (_WIN32_WINNT >= 0x501)
+{
+    enum {
+        BCN_FIRST = -1250U,
+        BCN_LAST = -1350U,
+    }
+}
+
+static if (_WIN32_WINNT >= 0x600)
+{
+    enum {
+        TRBN_FIRST = -1501U,
+        TRBN_LAST = -1519U,
+    }
+}
+
+enum {
+    HDI_WIDTH  = 1,
+    HDI_HEIGHT = 1,
+    HDI_TEXT   = 2,
+    HDI_FORMAT = 4,
+    HDI_LPARAM = 8,
+    HDI_BITMAP = 16
+}
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        HDI_IMAGE      = 32,
+        HDI_DI_SETITEM = 64,
+        HDI_ORDER      = 128
+    }
+}
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        HDI_FILTER = 256
+    }
+}
+
+enum {
+    CBES_EX_NOEDITIMAGE       = 0x00000001,
+    CBES_EX_NOEDITIMAGEINDENT = 0x00000002,
+    CBES_EX_PATHWORDBREAKPROC = 0x00000004
+}
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        CBES_EX_NOSIZELIMIT   = 0x00000008,
+        CBES_EX_CASESENSITIVE = 0x00000010,
+        CBEN_GETDISPINFOA     = CBEN_FIRST - 0,
+        CBEN_GETDISPINFOW     = CBEN_FIRST - 7,
+        CBEN_DRAGBEGINA       = CBEN_FIRST - 8,
+        CBEN_DRAGBEGINW       = CBEN_FIRST - 9
+    }
+}
+
+enum {
+    HDF_LEFT,
+    HDF_RIGHT,
+    HDF_CENTER,
+    HDF_JUSTIFYMASK,
+    HDF_RTLREADING, // = 4
+    HDF_OWNERDRAW = 0x8000,
+    HDF_STRING    = 0x4000,
+    HDF_BITMAP    = 0x2000
+}
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        HDF_BITMAP_ON_RIGHT = 0x1000,
+        HDF_IMAGE           = 0x0800
+    }
+}
+
+enum {
+    CCM_FIRST            = 0x2000,
+    CCM_LAST             = CCM_FIRST + 0x200,
+    CCM_SETBKCOLOR       = 8193,
+    CCM_SETCOLORSCHEME   = 8194,
+    CCM_GETCOLORSCHEME   = 8195,
+    CCM_GETDROPTARGET    = 8196,
+    CCM_SETUNICODEFORMAT = 8197,
+    CCM_GETUNICODEFORMAT = 8198,
+    CCM_SETVERSION       = 0x2007,
+    CCM_GETVERSION       = 0x2008,
+    CCM_SETNOTIFYWINDOW  = 0x2009
+}
+
+enum {
+    HDM_GETITEMCOUNT = HDM_FIRST,
+    HDM_INSERTITEMA  = HDM_FIRST + 1,
+    HDM_INSERTITEMW  = HDM_FIRST + 10,
+    HDM_DELETEITEM   = HDM_FIRST + 2,
+    HDM_GETITEMA     = HDM_FIRST + 3,
+    HDM_GETITEMW     = HDM_FIRST + 11,
+    HDM_SETITEMA     = HDM_FIRST + 4,
+    HDM_SETITEMW     = HDM_FIRST + 12,
+    HDM_LAYOUT       = HDM_FIRST + 5
+}
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        HDM_GETITEMRECT     = HDM_FIRST + 7,
+        HDM_SETIMAGELIST    = HDM_FIRST + 8,
+        HDM_GETIMAGELIST    = HDM_FIRST + 9,
+        HDM_ORDERTOINDEX    = HDM_FIRST + 15,
+        HDM_CREATEDRAGIMAGE = HDM_FIRST + 16,
+        HDM_GETORDERARRAY   = HDM_FIRST + 17,
+        HDM_SETORDERARRAY   = HDM_FIRST + 18,
+        HDM_SETHOTDIVIDER   = HDM_FIRST + 19
+    }
+}
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        HDM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT,
+        HDM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT
+    }
+}
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        HDM_SETBITMAPMARGIN = HDM_FIRST + 20,
+        HDM_GETBITMAPMARGIN = HDM_FIRST + 21,
+        HDM_SETFILTERCHANGETIMEOUT = HDM_FIRST + 22,
+        HDM_EDITFILTER = HDM_FIRST + 23,
+        HDM_CLEARFILTER = HDM_FIRST + 24,
+    }
+}
+static if (_WIN32_IE >= 0x600) {
+    enum {
+        HDM_GETITEMDROPDOWNRECT = HDM_FIRST + 25,
+        HDM_GETOVERFLOWRECT = HDM_FIRST + 26,
+        HDM_GETFOCUSEDITEM = HDM_FIRST + 27,
+        HDM_SETFOCUSEDITEM = HDM_FIRST + 28,
+    }
+}
+
+enum {
+    HHT_NOWHERE   = 1,
+    HHT_ONHEADER  = 2,
+    HHT_ONDIVIDER = 4,
+    HHT_ONDIVOPEN = 8,
+    HHT_ABOVE     = 256,
+    HHT_BELOW     = 512,
+    HHT_TORIGHT   = 1024,
+    HHT_TOLEFT    = 2048
+}
+
+enum {
+    HDM_HITTEST = HDM_FIRST + 6
+}
+
+enum {
+    HDN_ITEMCHANGINGA    = HDN_FIRST -0,
+    HDN_ITEMCHANGINGW    = HDN_FIRST -20,
+    HDN_ITEMCHANGEDA     = HDN_FIRST -1,
+    HDN_ITEMCHANGEDW     = HDN_FIRST -21,
+    HDN_ITEMCLICKA       = HDN_FIRST -2,
+    HDN_ITEMCLICKW       = HDN_FIRST -22,
+    HDN_ITEMDBLCLICKA    = HDN_FIRST -3,
+    HDN_ITEMDBLCLICKW    = HDN_FIRST -23,
+    HDN_DIVIDERDBLCLICKA = HDN_FIRST -5,
+    HDN_DIVIDERDBLCLICKW = HDN_FIRST -25,
+    HDN_BEGINTRACKA      = HDN_FIRST -6,
+    HDN_BEGINTRACKW      = HDN_FIRST -26,
+    HDN_ENDTRACKA        = HDN_FIRST -7,
+    HDN_ENDTRACKW        = HDN_FIRST -27,
+    HDN_TRACKA           = HDN_FIRST -8,
+    HDN_TRACKW           = HDN_FIRST -28
+}
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        HDN_ENDDRAG      = (HDN_FIRST-11),
+        HDN_BEGINDRAG    = (HDN_FIRST-10),
+        HDN_GETDISPINFOA = (HDN_FIRST-9),
+        HDN_GETDISPINFOW = (HDN_FIRST-29)
+    }
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        HICF_OTHER          = 0x00,
+        HICF_MOUSE          = 0x01,
+        HICF_ARROWKEYS      = 0x02,
+        HICF_ACCELERATOR    = 0x04,
+        HICF_DUPACCEL       = 0x08,
+        HICF_ENTERING       = 0x10,
+        HICF_LEAVING        = 0x20,
+        HICF_RESELECT       = 0x40,
+        HICF_LMOUSE         = 0x80,
+        HICF_TOGGLEDROPDOWN = 0x100
+    }
+}
+
+enum {
+    IPM_CLEARADDRESS = WM_USER + 100,
+    IPM_SETADDRESS   = WM_USER + 101,
+    IPM_GETADDRESS   = WM_USER + 102,
+    IPM_SETRANGE     = WM_USER + 103,
+    IPM_SETFOCUS     = WM_USER + 104,
+    IPM_ISBLANK      = WM_USER + 105
+}
+
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        I_INDENTCALLBACK = -1,
+        I_IMAGENONE      = -2
+    }
+}
+
+enum {
+    TBSTATE_CHECKED       = 1,
+    TBSTATE_PRESSED       = 2,
+    TBSTATE_ENABLED       = 4,
+    TBSTATE_HIDDEN        = 8,
+    TBSTATE_INDETERMINATE = 16,
+    TBSTATE_WRAP          = 32
+}
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        TBSTATE_ELLIPSES = 0x40
+    }
+}
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TBSTATE_MARKED = 0x0080
+    }
+}
+
+enum {
+    TBSTYLE_BUTTON     = 0,
+    TBSTYLE_SEP        = 1,
+    TBSTYLE_CHECK      = 2,
+    TBSTYLE_GROUP      = 4,
+    TBSTYLE_CHECKGROUP = TBSTYLE_GROUP | TBSTYLE_CHECK
+}
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        TBSTYLE_DROPDOWN = 8
+    }
+}
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TBSTYLE_AUTOSIZE = 16,
+        TBSTYLE_NOPREFIX = 32
+    }
+}
+enum {
+    TBSTYLE_TOOLTIPS = 256,
+    TBSTYLE_WRAPABLE = 512,
+    TBSTYLE_ALTDRAG  = 1024
+}
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        TBSTYLE_FLAT        = 2048,
+        TBSTYLE_LIST        = 4096,
+        TBSTYLE_CUSTOMERASE = 8192
+    }
+}
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TBSTYLE_REGISTERDROP    = 0x4000,
+        TBSTYLE_TRANSPARENT     = 0x8000,
+        TBSTYLE_EX_DRAWDDARROWS = 0x00000001
+    }
+}
+static if (_WIN32_IE >= 0x501) {
+    enum {
+        TBSTYLE_EX_MIXEDBUTTONS       = 8,
+        TBSTYLE_EX_HIDECLIPPEDBUTTONS = 16
+    }
+}
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        TBSTYLE_EX_DOUBLEBUFFER = 0x80
+    }
+}
+
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        BTNS_BUTTON        = TBSTYLE_BUTTON,
+        BTNS_SEP           = TBSTYLE_SEP,
+        BTNS_CHECK         = TBSTYLE_CHECK,
+        BTNS_GROUP         = TBSTYLE_GROUP,
+        BTNS_CHECKGROUP    = TBSTYLE_CHECKGROUP,
+        BTNS_DROPDOWN      = TBSTYLE_DROPDOWN,
+        BTNS_AUTOSIZE      = TBSTYLE_AUTOSIZE,
+        BTNS_NOPREFIX      = TBSTYLE_NOPREFIX,
+        BTNS_WHOLEDROPDOWN = 0x0080
+    }
+}
+static if (_WIN32_IE >= 0x501) {
+    enum {
+        BTNS_SHOWTEXT = 0x0040
+    }
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TBCDRF_NOEDGES        = 0x10000,
+        TBCDRF_HILITEHOTTRACK = 0x20000,
+        TBCDRF_NOOFFSET       = 0x40000,
+        TBCDRF_NOMARK         = 0x80000,
+        TBCDRF_NOETCHEDEFFECT = 0x100000
+    }
+}
+
+enum HINST_COMMCTRL = cast(HINSTANCE) (-1);
+
+enum {
+    IDB_STD_SMALL_COLOR,
+    IDB_STD_LARGE_COLOR,
+    IDB_VIEW_SMALL_COLOR = 4,
+    IDB_VIEW_LARGE_COLOR = 5
+}
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        IDB_HIST_SMALL_COLOR = 8,
+        IDB_HIST_LARGE_COLOR = 9
+    }
+}
+
+enum {
+    STD_CUT,
+    STD_COPY,
+    STD_PASTE,
+    STD_UNDO,
+    STD_REDOW,
+    STD_DELETE,
+    STD_FILENEW,
+    STD_FILEOPEN,
+    STD_FILESAVE,
+    STD_PRINTPRE,
+    STD_PROPERTIES,
+    STD_HELP,
+    STD_FIND,
+    STD_REPLACE,
+    STD_PRINT // = 14
+}
+
+enum {
+    VIEW_LARGEICONS,
+    VIEW_SMALLICONS,
+    VIEW_LIST,
+    VIEW_DETAILS,
+    VIEW_SORTNAME,
+    VIEW_SORTSIZE,
+    VIEW_SORTDATE,
+    VIEW_SORTTYPE,
+    VIEW_PARENTFOLDER,
+    VIEW_NETCONNECT,
+    VIEW_NETDISCONNECT,
+    VIEW_NEWFOLDER // = 11
+}
+
+enum {
+    TB_ENABLEBUTTON          = WM_USER + 1,
+    TB_CHECKBUTTON,
+    TB_PRESSBUTTON,
+    TB_HIDEBUTTON,
+    TB_INDETERMINATE, //     = WM_USER + 5,
+    TB_ISBUTTONENABLED       = WM_USER + 9,
+    TB_ISBUTTONCHECKED,
+    TB_ISBUTTONPRESSED,
+    TB_ISBUTTONHIDDEN,
+    TB_ISBUTTONINDETERMINATE, // = WM_USER + 13,
+    TB_SETSTATE              = WM_USER + 17,
+    TB_GETSTATE              = WM_USER + 18,
+    TB_ADDBITMAP             = WM_USER + 19,
+    TB_DELETEBUTTON          = WM_USER + 22,
+    TB_GETBUTTON,
+    TB_BUTTONCOUNT,
+    TB_COMMANDTOINDEX,
+    TB_SAVERESTOREA,
+    TB_CUSTOMIZE,
+    TB_ADDSTRINGA,
+    TB_GETITEMRECT,
+    TB_BUTTONSTRUCTSIZE,
+    TB_SETBUTTONSIZE,
+    TB_SETBITMAPSIZE,
+    TB_AUTOSIZE, //          = WM_USER + 33,
+    TB_GETTOOLTIPS           = WM_USER + 35,
+    TB_SETTOOLTIPS           = WM_USER + 36,
+    TB_SETPARENT             = WM_USER + 37,
+    TB_SETROWS               = WM_USER + 39,
+    TB_GETROWS,
+    TB_GETBITMAPFLAGS,
+    TB_SETCMDID,
+    TB_CHANGEBITMAP,
+    TB_GETBITMAP,
+    TB_GETBUTTONTEXTA,
+    TB_REPLACEBITMAP, //     = WM_USER + 46,
+    TB_GETBUTTONSIZE         = WM_USER + 58,
+    TB_SETBUTTONWIDTH        = WM_USER + 59,
+    TB_GETBUTTONTEXTW        = WM_USER + 75,
+    TB_SAVERESTOREW          = WM_USER + 76,
+    TB_ADDSTRINGW            = WM_USER + 77,
+}
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TB_MARKBUTTON = WM_USER + 6
+    }
+}
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TB_ISBUTTONHIGHLIGHTED = WM_USER + 14
+    }
+}
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TB_ADDBUTTONSA   = WM_USER + 20,
+        TB_INSERTBUTTONA = WM_USER + 21
+    }
+} else {
+    enum {
+        TB_ADDBUTTONS   = WM_USER + 20,
+        TB_INSERTBUTTON = WM_USER + 21
+    }
+}
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        TB_SETINDENT = WM_USER + 47,
+        TB_SETIMAGELIST,
+        TB_GETIMAGELIST,
+        TB_LOADIMAGES,
+        TB_GETRECT,
+        TB_SETHOTIMAGELIST,
+        TB_GETHOTIMAGELIST,
+        TB_SETDISABLEDIMAGELIST,
+        TB_GETDISABLEDIMAGELIST,
+        TB_SETSTYLE,
+        TB_GETSTYLE,
+        //TB_GETBUTTONSIZE,
+        //TB_SETBUTTONWIDTH,
+        TB_SETMAXTEXTROWS,
+        TB_GETTEXTROWS // = WM_USER + 61
+    }
+}
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TB_GETOBJECT            = WM_USER + 62,
+        TB_GETBUTTONINFOW,
+        TB_SETBUTTONINFOW,
+        TB_GETBUTTONINFOA,
+        TB_SETBUTTONINFOA,
+        TB_INSERTBUTTONW,
+        TB_ADDBUTTONSW,
+        TB_HITTEST, //          = WM_USER + 69
+        TB_SETEXTENDEDSTYLE     = WM_USER + 84,
+        TB_GETEXTENDEDSTYLE     = WM_USER + 85,
+        TB_SETDRAWTEXTFLAGS     = WM_USER + 70,
+        TB_GETHOTITEM,
+        TB_SETHOTITEM,
+        TB_SETANCHORHIGHLIGHT,
+        TB_GETANCHORHIGHLIGHT, // = WM_USER + 74
+        TB_MAPACCELERATORA      = WM_USER + 78,
+        TB_GETINSERTMARK,
+        TB_SETINSERTMARK,
+        TB_INSERTMARKHITTEST,
+        TB_MOVEBUTTON,
+        TB_GETMAXSIZE,
+        //TB_SETEXTENDEDSTYLE,
+        //TB_GETEXTENDEDSTYLE,
+        TB_GETPADDING,
+        TB_SETPADDING,
+        TB_SETINSERTMARKCOLOR,
+        TB_GETINSERTMARKCOLOR,
+        TB_MAPACCELERATORW,
+        TB_GETSTRINGW,
+        TB_GETSTRINGA, //       = WM_USER + 92
+        TB_SETHOTITEM2          = WM_USER + 94,
+        TB_SETLISTGAP           = WM_USER + 96,
+        TB_GETIMAGELISTCOUNT    = WM_USER + 98,
+        TB_GETIDEALSIZE         = WM_USER + 99,
+        //TB_TRANSLATEACCELERATOR = CCM_TRANSLATEACCELERATOR,
+        TB_SETCOLORSCHEME       = CCM_SETCOLORSCHEME,
+        TB_GETCOLORSCHEME       = CCM_GETCOLORSCHEME,
+        TB_SETUNICODEFORMAT     = CCM_SETUNICODEFORMAT,
+        TB_GETUNICODEFORMAT     = CCM_GETUNICODEFORMAT
+    }
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        TB_GETMETRICS = WM_USER + 101,
+        TB_SETMETRICS = WM_USER + 102,
+    }
+}
+
+static if (_WIN32_WINNT >= 0x600) {
+    enum {
+        TB_GETITEMDROPDOWNRECT = WM_USER + 103,
+        TB_SETPRESSEDIMAGELIST = WM_USER + 104,
+        TB_GETPRESSEDIMAGELIST = WM_USER + 105,
+    }
+}
+
+enum TBBF_LARGE = 1;
+
+enum {
+    TBN_GETBUTTONINFOA = TBN_FIRST -0,
+    TBN_BEGINDRAG      = TBN_FIRST -1,
+    TBN_ENDDRAG        = TBN_FIRST -2,
+    TBN_BEGINADJUST    = TBN_FIRST -3,
+    TBN_ENDADJUST      = TBN_FIRST -4,
+    TBN_RESET          = TBN_FIRST -5,
+    TBN_QUERYINSERT    = TBN_FIRST -6,
+    TBN_QUERYDELETE    = TBN_FIRST -7,
+    TBN_TOOLBARCHANGE  = TBN_FIRST -8,
+    TBN_CUSTHELP       = TBN_FIRST -9
+}
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        TBN_DROPDOWN = TBN_FIRST - 10
+    }
+}
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TBN_HOTITEMCHANGE  = TBN_FIRST - 13,
+        TBN_DRAGOUT        = TBN_FIRST - 14,
+        TBN_DELETINGBUTTON = TBN_FIRST - 15,
+        TBN_GETDISPINFOA   = TBN_FIRST - 16,
+        TBN_GETDISPINFOW   = TBN_FIRST - 17,
+        TBN_GETINFOTIPA    = TBN_FIRST - 18,
+        TBN_GETINFOTIPW    = TBN_FIRST - 19,
+        TBN_GETBUTTONINFOW = TBN_FIRST - 20
+    }
+}
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        TBN_RESTORE       = TBN_FIRST - 21,
+        TBN_SAVE          = TBN_FIRST - 22,
+        TBN_INITCUSTOMIZE = TBN_FIRST - 23
+    }
+
+    enum {
+        TBNRF_HIDEHELP = 1,
+        TBNRF_ENDCUSTOMIZE
+    }
+
+    enum {
+        TBNF_IMAGE      = 1,
+        TBNF_TEXT       = 2,
+        TBNF_DI_SETITEM = 0x10000000
+    }
+}
+
+enum {
+    TTS_ALWAYSTIP = 1,
+    TTS_NOPREFIX
+}
+static if(_WIN32_IE >= 0x500) {
+    enum {
+        TTS_NOANIMATE = 0x10,
+        TTS_NOFADE    = 0x20,
+        TTS_BALLOON   = 0x40,
+        TTS_CLOSE     = 0x80
+    }
+}
+
+enum {
+    TTF_IDISHWND   = 1,
+    TTF_CENTERTIP  = 2,
+    TTF_RTLREADING = 4,
+    TTF_SUBCLASS   = 16
+}
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        TTF_TRACK       = 0x0020,
+        TTF_ABSOLUTE    = 0x0080,
+        TTF_TRANSPARENT = 0x0100,
+        TTF_DI_SETITEM  = 0x8000
+    }
+
+    static if (_WIN32_IE >= 0x501) {
+        enum {
+            TTF_PARSELINKS = 0x1000
+        }
+    }
+
+    enum {
+        TBCD_TICS = 1,
+        TBCD_THUMB,
+        TBCD_CHANNEL // = 3
+    }
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TBDDRET_DEFAULT,
+        TBDDRET_NODEFAULT,
+        TBDDRET_TREATPRESSED
+    }
+
+    enum {
+        TBIMHT_AFTER = 1,
+        TBIMHT_BACKGROUND
+    }
+}
+
+enum {
+    TTDT_AUTOMATIC,
+    TTDT_RESHOW,
+    TTDT_AUTOPOP,
+    TTDT_INITIAL
+}
+
+enum {
+    TTM_ACTIVATE        = WM_USER + 1,
+    TTM_SETDELAYTIME    = WM_USER + 3,
+    TTM_ADDTOOLA,
+    TTM_DELTOOLA,
+    TTM_NEWTOOLRECTA,
+    TTM_RELAYEVENT,
+    TTM_GETTOOLINFOA,
+    TTM_SETTOOLINFOA,
+    TTM_HITTESTA,
+    TTM_GETTEXTA,
+    TTM_UPDATETIPTEXTA,
+    TTM_GETTOOLCOUNT,
+    TTM_ENUMTOOLSA,
+    TTM_GETCURRENTTOOLA,
+    TTM_WINDOWFROMPOINT, // = WM_USER + 16
+    TTM_ADDTOOLW        = WM_USER + 50,
+    TTM_DELTOOLW,
+    TTM_NEWTOOLRECTW,
+    TTM_GETTOOLINFOW,
+    TTM_SETTOOLINFOW,
+    TTM_HITTESTW,
+    TTM_GETTEXTW,
+    TTM_UPDATETIPTEXTW,
+    TTM_ENUMTOOLSW,
+    TTM_GETCURRENTTOOLW // = WM_USER + 59
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        TTM_TRACKACTIVATE = WM_USER + 17,
+        TTM_TRACKPOSITION,
+        TTM_SETTIPBKCOLOR,
+        TTM_SETTIPTEXTCOLOR,
+        TTM_GETDELAYTIME,
+        TTM_GETTIPBKCOLOR,
+        TTM_GETTIPTEXTCOLOR,
+        TTM_SETMAXTIPWIDTH,
+        TTM_GETMAXTIPWIDTH,
+        TTM_SETMARGIN,
+        TTM_GETMARGIN,
+        TTM_POP // = WM_USER + 28
+    }
+}
+
+static if (_WIN32_IE >= 0x400) {  // IE4.0 ???
+    enum {
+        TTM_UPDATE = WM_USER + 29,
+        TTM_GETBUBBLESIZE,
+        TTM_ADJUSTRECT,
+        TTM_SETTITLEA,
+        TTM_SETTITLEW // = WM_USER + 33
+    }
+    static if (_WIN32_IE >= 0x500) {
+        alias TTM_SETTITLEW TTM_SETTITLE;
+    } else {
+        alias TTM_SETTITLEA TTM_SETTITLE;
+    }
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        TTM_POPUP = (WM_USER + 34),
+        TTM_GETTITLE = (WM_USER + 35),
+    }
+}
+
+enum {
+    TTN_GETDISPINFOA = TTN_FIRST - 0,
+    TTN_GETDISPINFOW = TTN_FIRST - 10,
+    TTN_NEEDTEXTA    = TTN_GETDISPINFOA,
+    TTN_NEEDTEXTW    = TTN_GETDISPINFOW,
+    TTN_SHOW         = TTN_FIRST-1,
+    TTN_POP          = TTN_FIRST-2
+}
+
+enum UD_MAXVAL = 0x7fff;
+enum UD_MINVAL = -UD_MAXVAL;
+
+enum {
+    UDN_DELTAPOS    = UDN_FIRST-1,
+    UDS_WRAP        = 1,
+    UDS_SETBUDDYINT = 2,
+    UDS_ALIGNRIGHT  = 4,
+    UDS_ALIGNLEFT   = 8,
+    UDS_AUTOBUDDY   = 16,
+    UDS_ARROWKEYS   = 32,
+    UDS_HORZ        = 64,
+    UDS_NOTHOUSANDS = 128
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        UDS_HOTTRACK = 0x0100
+    }
+}
+
+enum {
+    UDM_SETRANGE = WM_USER + 101,
+    UDM_GETRANGE,
+    UDM_SETPOS,
+    UDM_GETPOS,
+    UDM_SETBUDDY,
+    UDM_GETBUDDY,
+    UDM_SETACCEL,
+    UDM_GETACCEL,
+    UDM_SETBASE,
+    UDM_GETBASE // = WM_USER + 110
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        UDM_SETRANGE32 = WM_USER + 111,
+        UDM_GETRANGE32,
+        UDM_SETPOS32,
+        UDM_GETPOS32 // = WM_USER + 114
+    }
+}
+
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        UDM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT,
+        UDM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT
+    }
+}
+
+/*enum {
+    SB_SETTEXTA       = WM_USER + 1,
+    SB_GETTEXTA,
+    SB_GETTEXTLENGTHA,
+    SB_SETPARTS,   // = WM_USER + 4
+    SB_GETPARTS       = WM_USER + 6,
+    SB_GETBORDERS,
+    SB_SETMINHEIGHT,
+    SB_SIMPLE,
+    SB_GETRECT,
+    SB_SETTEXTW,
+    SB_GETTEXTLENGTHW,
+    SB_GETTEXTW    // = WM_USER + 13
+}*/
+
+/*enum {
+    SBT_OWNERDRAW  = 0x1000,
+    SBT_NOBORDERS  = 256,
+    SBT_POPOUT     = 512,
+    SBT_RTLREADING = 1024
+}*/
+
+static if(_WIN32_IE >= 0x400) {
+    enum {
+        SBT_TOOLTIPS         = 0x0800,
+        SBN_SIMPLEMODECHANGE = SBN_FIRST
+    }
+}
+
+enum {
+    TBS_AUTOTICKS      = 1,
+    TBS_VERT           = 2,
+    TBS_HORZ           = 0,
+    TBS_TOP            = 4,
+    TBS_BOTTOM         = 0,
+    TBS_LEFT           = 4,
+    TBS_RIGHT          = 0,
+    TBS_BOTH           = 8,
+    TBS_NOTICKS        = 16,
+    TBS_ENABLESELRANGE = 32,
+    TBS_FIXEDLENGTH    = 64,
+    TBS_NOTHUMB        = 128
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        TBS_TOOLTIPS = 0x0100,
+        TBTS_TOP     = 0,
+        TBTS_LEFT,
+        TBTS_BOTTOM,
+        TBTS_RIGHT // = 3
+    }
+}
+
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        TBS_REVERSED = 0x0200
+    }
+}
+
+static if (_WIN32_IE >= 0x501) {
+    enum {
+        TBS_DOWNISLEFT = 0x0400
+    }
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TBIF_BYINDEX = 0x80000000,
+        TBIF_COMMAND = 32,
+        TBIF_IMAGE   = 1,
+        TBIF_LPARAM  = 16,
+        TBIF_SIZE    = 64,
+        TBIF_STATE   = 4,
+        TBIF_STYLE   = 8,
+        TBIF_TEXT    = 2
+    }
+}
+
+enum {
+    TBM_GETPOS           = WM_USER,
+    TBM_GETRANGEMIN,
+    TBM_GETRANGEMAX,
+    TBM_GETTIC,
+    TBM_SETTIC,
+    TBM_SETPOS,
+    TBM_SETRANGE,
+    TBM_SETRANGEMIN,
+    TBM_SETRANGEMAX,
+    TBM_CLEARTICS,
+    TBM_SETSEL,
+    TBM_SETSELSTART,
+    TBM_SETSELEND,    // = WM_USER+12,
+    TBM_GETPTICS         = WM_USER+14,
+    TBM_GETTICPOS,
+    TBM_GETNUMTICS,
+    TBM_GETSELSTART,
+    TBM_GETSELEND,
+    TBM_CLEARSEL,
+    TBM_SETTICFREQ,
+    TBM_SETPAGESIZE,
+    TBM_GETPAGESIZE,
+    TBM_SETLINESIZE,
+    TBM_GETLINESIZE,
+    TBM_GETTHUMBRECT,
+    TBM_GETCHANNELRECT,
+    TBM_SETTHUMBLENGTH,
+    TBM_GETTHUMBLENGTH,
+    TBM_SETTOOLTIPS,
+    TBM_GETTOOLTIPS,
+    TBM_SETTIPSIDE,
+    TBM_SETBUDDY,
+    TBM_GETBUDDY, //     = WM_USER+33,
+    TBM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT,
+    TBM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT
+}
+
+enum {
+    TB_LINEUP,
+    TB_LINEDOWN,
+    TB_PAGEUP,
+    TB_PAGEDOWN,
+    TB_THUMBPOSITION,
+    TB_THUMBTRACK,
+    TB_TOP,
+    TB_BOTTOM,
+    TB_ENDTRACK // = 8
+}
+
+enum {
+    HOTKEYF_SHIFT   = 1,
+    HOTKEYF_CONTROL = 2,
+    HOTKEYF_ALT     = 4,
+    HOTKEYF_EXT     = 8
+}
+
+enum {
+    HKCOMB_NONE = 1,
+    HKCOMB_S    = 2,
+    HKCOMB_C    = 4,
+    HKCOMB_A    = 8,
+    HKCOMB_SC   = 16,
+    HKCOMB_SA   = 32,
+    HKCOMB_CA   = 64,
+    HKCOMB_SCA  = 128
+}
+
+enum {
+    HKM_SETHOTKEY = WM_USER + 1,
+    HKM_GETHOTKEY = WM_USER + 2,
+    HKM_SETRULES  = WM_USER + 3
+}
+
+enum {
+    PBM_SETRANGE     = WM_USER + 1,
+    PBM_SETPOS,
+    PBM_DELTAPOS,
+    PBM_SETSTEP,
+    PBM_STEPIT,   // = WM_USER + 5
+    PBM_SETRANGE32   = 1030,
+    PBM_GETRANGE,
+    PBM_GETPOS,
+    PBM_SETBARCOLOR, // = 1033
+    PBM_SETBKCOLOR   = CCM_SETBKCOLOR
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        PBM_SETMARQUEE = WM_USER + 10,
+    }
+}
+
+static if (_WIN32_WINNT >= 0x600) {
+    enum {
+        PBM_GETSTEP = WM_USER + 13,
+        PBM_GETBKCOLOR,
+        PBM_GETBARCOLOR,
+        PBM_SETSTATE,
+        PBM_GETSTATE,
+    }
+}
+
+enum {
+    PBS_SMOOTH   = 1,
+    PBS_VERTICAL = 4
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        PBS_MARQUEE = 8,
+    }
+}
+
+static if (_WIN32_WINNT >= 0x600) {
+    enum {
+        PBS_SMOOTHREVERSE = 16,
+    }
+}
+
+enum {
+    LVS_ICON,
+    LVS_REPORT,
+    LVS_SMALLICON,
+    LVS_LIST,        // = 3
+    LVS_TYPEMASK        = 3,
+    LVS_SINGLESEL       = 4,
+    LVS_SHOWSELALWAYS   = 8,
+    LVS_SORTASCENDING   = 16,
+    LVS_SORTDESCENDING  = 32,
+    LVS_SHAREIMAGELISTS = 64,
+    LVS_NOLABELWRAP     = 128,
+    LVS_AUTOARRANGE     = 256,
+    LVS_EDITLABELS      = 512,
+    LVS_NOSCROLL        = 0x2000,
+    LVS_TYPESTYLEMASK   = 0xFC00,
+    LVS_ALIGNTOP        = 0,
+    LVS_ALIGNLEFT       = 0x800,
+    LVS_ALIGNMASK       = 0xC00,
+    LVS_OWNERDRAWFIXED  = 0x400,
+    LVS_NOCOLUMNHEADER  = 0x4000,
+    LVS_NOSORTHEADER    = 0x8000
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        CDIS_CHECKED       = 8,
+        CDIS_DEFAULT       = 32,
+        CDIS_DISABLED      = 4,
+        CDIS_FOCUS         = 16,
+        CDIS_GRAYED        = 2,
+        CDIS_HOT           = 64,
+        CDIS_SELECTED      = 1,
+        CDIS_MARKED        = 128,
+        CDIS_INDETERMINATE = 256
+    }
+
+    static if (_WIN32_WINNT >= 0x501) {
+        enum {
+            CDIS_SHOWKEYBOARDCUES = 512
+        }
+    }
+
+    enum {
+        CDDS_POSTERASE     = 4,
+        CDDS_POSTPAINT     = 2,
+        CDDS_PREERASE      = 3,
+        CDDS_PREPAINT      = 1,
+        CDDS_ITEM          = 65536,
+        CDDS_ITEMPOSTERASE = 65540,
+        CDDS_ITEMPOSTPAINT = 65538,
+        CDDS_ITEMPREERASE  = 65539,
+        CDDS_ITEMPREPAINT  = 65537
+    }
+
+    static if (_WIN32_IE >= 0x400) {
+        enum {
+            CDDS_SUBITEM = 0x20000
+        }
+    }
+
+    enum {
+        CDRF_DODEFAULT         = 0x00,
+        CDRF_NOTIFYITEMDRAW    = 0x20,
+        CDRF_NOTIFYSUBITEMDRAW = 0x20,
+        CDRF_NOTIFYITEMERASE   = 0x80,
+        CDRF_NOTIFYPOSTERASE   = 0x40,
+        CDRF_NOTIFYPOSTPAINT   = 0x10,
+        CDRF_NEWFONT           = 0x02,
+        CDRF_SKIPDEFAULT       = 0x04
+    }
+
+    static if (_WIN32_IE >= 0x400) {
+        enum {
+            LVBKIF_SOURCE_NONE    = 0x00000000,
+            LVBKIF_SOURCE_HBITMAP = 0x00000001,
+            LVBKIF_SOURCE_URL     = 0x00000002,
+            LVBKIF_SOURCE_MASK    = 0x00000003,
+            LVBKIF_STYLE_NORMAL   = 0x00000000,
+            LVBKIF_STYLE_TILE     = 0x00000010,
+            LVBKIF_STYLE_MASK     = 0x00000010
+        }
+    }
+
+    static if (_WIN32_WINNT >= 0x501) {
+        enum {
+            LVBKIF_FLAG_TILEOFFSET = 0x00000100,
+            LVBKIF_TYPE_WATERMARK  = 0x10000000
+        }
+    }
+
+    enum {
+        LVS_OWNERDATA = 4096
+    }
+
+    enum {
+        LVS_EX_CHECKBOXES       = 4,
+        LVS_EX_FULLROWSELECT    = 32,
+        LVS_EX_GRIDLINES        = 1,
+        LVS_EX_HEADERDRAGDROP   = 16,
+        LVS_EX_ONECLICKACTIVATE = 64,
+        LVS_EX_SUBITEMIMAGES    = 2,
+        LVS_EX_TRACKSELECT      = 8,
+        LVS_EX_TWOCLICKACTIVATE = 128
+    }
+
+    enum {
+        LVSICF_NOINVALIDATEALL = 0x00000001,
+        LVSICF_NOSCROLL        = 0x00000002
+    }
+
+    static if(_WIN32_IE >= 0x400) {
+        enum {
+            LVS_EX_FLATSB         = 0x00000100,
+            LVS_EX_REGIONAL       = 0x00000200,
+            LVS_EX_INFOTIP        = 0x00000400,
+            LVS_EX_UNDERLINEHOT   = 0x00000800,
+            LVS_EX_UNDERLINECOLD  = 0x00001000,
+            LVS_EX_MULTIWORKAREAS = 0x00002000
+        }
+    }
+
+    static if(_WIN32_IE >= 0x500) {
+        enum {
+            LVS_EX_LABELTIP     = 0x00004000,
+            LVS_EX_BORDERSELECT = 0x00008000
+        }
+    }
+}
+
+enum {
+    LVSIL_NORMAL,
+    LVSIL_SMALL,
+    LVSIL_STATE
+}
+
+enum {
+    LVM_GETBKCOLOR             = LVM_FIRST,
+    LVM_SETBKCOLOR,
+    LVM_GETIMAGELIST,
+    LVM_SETIMAGELIST,
+    LVM_GETITEMCOUNT,       // = LVM_FIRST +   4
+    LVM_SORTITEMSEX            = LVM_FIRST +  81,
+    LVM_GETGROUPSTATE          = LVM_FIRST + 92,
+    LVM_GETFOCUSEDGROUP,
+    LVM_GETGROUPRECT           = LVM_FIRST + 98,
+    LVM_SETVIEW                = LVM_FIRST + 142,
+    LVM_GETVIEW,            // = LVM_FIRST + 143
+    LVM_INSERTGROUP            = LVM_FIRST + 145,
+    LVM_SETGROUPINFO           = LVM_FIRST + 147,
+    LVM_GETGROUPINFO           = LVM_FIRST + 149,
+    LVM_REMOVEGROUP,
+    LVM_MOVEGROUP,          // = LVM_FIRST + 151
+    LVM_GETGROUPCOUNT,
+    LVM_GETGROUPINFOBYINDEX,
+    LVM_MOVEITEMTOGROUP,
+    LVM_SETGROUPMETRICS        = LVM_FIRST + 155,
+    LVM_GETGROUPMETRICS,
+    LVM_ENABLEGROUPVIEW,
+    LVM_SORTGROUPS,
+    LVM_INSERTGROUPSORTED,
+    LVM_REMOVEALLGROUPS,
+    LVM_HASGROUP,
+    LVM_SETTILEVIEWINFO,
+    LVM_GETTILEVIEWINFO,
+    LVM_SETTILEINFO,
+    LVM_GETTILEINFO,
+    LVM_SETINSERTMARK,
+    LVM_GETINSERTMARK,
+    LVM_INSERTMARKHITTEST,
+    LVM_GETINSERTMARKRECT,
+    LVM_SETINSERTMARKCOLOR,
+    LVM_GETINSERTMARKCOLOR, // = LVM_FIRST + 171
+    LVM_SETINFOTIP             = LVM_FIRST + 173,
+    LVM_GETSELECTEDCOLUMN,
+    LVM_ISGROUPVIEWENABLED,
+    LVM_GETOUTLINECOLOR,
+    LVM_SETOUTLINECOLOR,    // = LVM_FIRST + 177
+    LVM_CANCELEDITLABEL        = LVM_FIRST + 179,
+    LVM_MAPINDEXTOID           = LVM_FIRST + 180,
+    LVM_MAPIDTOINDEX           = LVM_FIRST + 181,
+    LVM_ISITEMVISIBLE          = LVM_FIRST + 182,
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        LVM_SETSELECTEDCOLUMN  = LVM_FIRST + 140
+    }
+}
+
+static if (_WIN32_WINNT >= 0x600) {
+    enum {
+        LVM_GETEMPTYTEXT = LVM_FIRST + 204,
+        LVM_GETFOOTERRECT = LVM_FIRST + 205,
+        LVM_GETFOOTERINFO = LVM_FIRST + 206,
+        LVM_GETFOOTERITEMRECT = LVM_FIRST + 207,
+        LVM_GETFOOTERITEM = (LVM_FIRST + 208),
+        LVM_GETITEMINDEXRECT = (LVM_FIRST + 209),
+        LVM_SETITEMINDEXSTATE = (LVM_FIRST + 210),
+        LVM_GETNEXTITEMINDEX = (LVM_FIRST + 211),
+    }
+}
+
+enum {
+    LVIF_TEXT  = 1,
+    LVIF_IMAGE = 2,
+    LVIF_PARAM = 4,
+    LVIF_STATE = 8
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        LVIF_INDENT      = 16,
+        LVIF_NORECOMPUTE = 2048
+    }
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        LVIF_GROUPID = 128,
+        LVIF_COLUMNS = 256
+    }
+}
+
+enum {
+    LVIS_FOCUSED        = 1,
+    LVIS_SELECTED       = 2,
+    LVIS_CUT            = 4,
+    LVIS_DROPHILITED    = 8,
+    LVIS_OVERLAYMASK    = 0xF00,
+    LVIS_STATEIMAGEMASK = 0xF000
+}
+
+enum LPWSTR LPSTR_TEXTCALLBACKW = cast(LPWSTR) -1;
+enum LPSTR  LPSTR_TEXTCALLBACKA = cast(LPSTR) -1;
+
+enum I_IMAGECALLBACK = -1;
+
+static if(_WIN32_IE >= 0x400) {
+    enum {
+        LVM_SETBKIMAGEA          = LVM_FIRST + 68,
+        LVM_SETBKIMAGEW          = LVM_FIRST + 138,
+        LVM_GETBKIMAGEA          = LVM_FIRST + 69,
+        LVM_GETBKIMAGEW          = LVM_FIRST + 139,
+        LV_MAX_WORKAREAS         = 16,
+        LVM_SETWORKAREAS         = LVM_FIRST + 65,
+        LVM_GETWORKAREAS         = LVM_FIRST + 70,
+        LVM_GETNUMBEROFWORKAREAS = LVM_FIRST + 73,
+        LVM_GETSELECTIONMARK     = LVM_FIRST + 66,
+        LVM_SETSELECTIONMARK     = LVM_FIRST + 67,
+        LVM_SETHOVERTIME         = LVM_FIRST + 71,
+        LVM_GETHOVERTIME         = LVM_FIRST + 72,
+        LVM_SETTOOLTIPS          = LVM_FIRST + 74,
+        LVM_GETTOOLTIPS          = LVM_FIRST + 78,
+        LVM_SETUNICODEFORMAT     = CCM_SETUNICODEFORMAT,
+        LVM_GETUNICODEFORMAT     = CCM_GETUNICODEFORMAT
+    }
+}
+
+enum {
+    LVNI_ALL,
+    LVNI_FOCUSED     = 1,
+    LVNI_SELECTED    = 2,
+    LVNI_CUT         = 4,
+    LVNI_DROPHILITED = 8,
+    LVNI_ABOVE       = 256,
+    LVNI_BELOW       = 512,
+    LVNI_TOLEFT      = 1024,
+    LVNI_TORIGHT     = 2048
+}
+
+enum {
+    LVM_GETITEMA          = LVM_FIRST + 5,
+    LVM_SETITEMA,
+    LVM_INSERTITEMA,
+    LVM_DELETEITEM,
+    LVM_DELETEALLITEMS,
+    LVM_GETCALLBACKMASK,
+    LVM_SETCALLBACKMASK,
+    LVM_GETNEXTITEM,
+    LVM_FINDITEMA,
+    LVM_GETITEMRECT,
+    LVM_SETITEMPOSITION,
+    LVM_GETITEMPOSITION,
+    LVM_GETSTRINGWIDTHA,
+    LVM_HITTEST,
+    LVM_ENSUREVISIBLE,
+    LVM_SCROLL,
+    LVM_REDRAWITEMS,
+    LVM_ARRANGE,
+    LVM_EDITLABELA,
+    LVM_GETEDITCONTROL,
+    LVM_GETCOLUMNA,
+    LVM_SETCOLUMNA,
+    LVM_INSERTCOLUMNA,
+    LVM_DELETECOLUMN,
+    LVM_GETCOLUMNWIDTH,
+    LVM_SETCOLUMNWIDTH, // = LVM_FIRST + 30,
+    LVM_CREATEDRAGIMAGE   = LVM_FIRST + 33,
+    LVM_GETVIEWRECT,
+    LVM_GETTEXTCOLOR,
+    LVM_SETTEXTCOLOR,
+    LVM_GETTEXTBKCOLOR,
+    LVM_SETTEXTBKCOLOR,
+    LVM_GETTOPINDEX,
+    LVM_GETCOUNTPERPAGE,
+    LVM_GETORIGIN,
+    LVM_UPDATE,
+    LVM_SETITEMSTATE,
+    LVM_GETITEMSTATE,
+    LVM_GETITEMTEXTA,
+    LVM_SETITEMTEXTA,
+    LVM_SETITEMCOUNT,
+    LVM_SORTITEMS,
+    LVM_SETITEMPOSITION32,
+    LVM_GETSELECTEDCOUNT,
+    LVM_GETITEMSPACING,
+    LVM_GETISEARCHSTRINGA, // = LVM_FIRST + 52,
+    LVM_GETITEMW          = LVM_FIRST + 75,
+    LVM_SETITEMW          = LVM_FIRST + 76,
+    LVM_INSERTITEMW       = LVM_FIRST + 77,
+    LVM_FINDITEMW         = LVM_FIRST + 83,
+    LVM_GETSTRINGWIDTHW   = LVM_FIRST + 87,
+    LVM_GETCOLUMNW        = LVM_FIRST + 95,
+    LVM_SETCOLUMNW        = LVM_FIRST + 96,
+    LVM_INSERTCOLUMNW     = LVM_FIRST + 97,
+    LVM_GETITEMTEXTW      = LVM_FIRST + 115,
+    LVM_SETITEMTEXTW,
+    LVM_GETISEARCHSTRINGW,
+    LVM_EDITLABELW     // = LVM_FIRST + 118,
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        LVM_GETHEADER                = LVM_FIRST + 31,
+        LVM_SETICONSPACING           = LVM_FIRST + 53,
+        LVM_SETEXTENDEDLISTVIEWSTYLE,
+        LVM_GETEXTENDEDLISTVIEWSTYLE,
+        LVM_GETSUBITEMRECT,
+        LVM_SUBITEMHITTEST,
+        LVM_SETCOLUMNORDERARRAY,
+        LVM_GETCOLUMNORDERARRAY,
+        LVM_SETHOTITEM,
+        LVM_GETHOTITEM,
+        LVM_SETHOTCURSOR,
+        LVM_GETHOTCURSOR,
+        LVM_APPROXIMATEVIEWRECT   // = LVM_FIRST + 64,
+    }
+}
+
+enum {
+    LVFI_PARAM     = 1,
+    LVFI_STRING    = 2,
+    LVFI_PARTIAL   = 8,
+    LVFI_WRAP      = 32,
+    LVFI_NEARESTXY = 64
+}
+
+enum {
+    LVIF_DI_SETITEM = 0x1000
+}
+
+enum {
+    LVIR_BOUNDS,
+    LVIR_ICON,
+    LVIR_LABEL,
+    LVIR_SELECTBOUNDS // = 3
+}
+
+enum {
+    LVHT_NOWHERE         = 1,
+    LVHT_ONITEMICON      = 2,
+    LVHT_ONITEMLABEL     = 4,
+    LVHT_ONITEMSTATEICON = 8,
+    LVHT_ONITEM          = LVHT_ONITEMICON | LVHT_ONITEMLABEL
+                           | LVHT_ONITEMSTATEICON,
+    LVHT_ABOVE           = 8,
+    LVHT_BELOW           = 16,
+    LVHT_TORIGHT         = 32,
+    LVHT_TOLEFT          = 64
+}
+
+enum {
+    LVA_DEFAULT    = 0,
+    LVA_ALIGNLEFT  = 1,
+    LVA_ALIGNTOP   = 2,
+    LVA_SNAPTOGRID = 5
+}
+
+enum {
+    LVCF_FMT     = 1,
+    LVCF_WIDTH   = 2,
+    LVCF_TEXT    = 4,
+    LVCF_SUBITEM = 8
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        LVCF_IMAGE = 16,
+        LVCF_ORDER = 32
+    }
+}
+
+enum {
+    LVCFMT_LEFT,
+    LVCFMT_RIGHT,
+    LVCFMT_CENTER,
+    LVCFMT_JUSTIFYMASK // = 3
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        LVCFMT_IMAGE           = 2048,
+        LVCFMT_BITMAP_ON_RIGHT = 4096,
+        LVCFMT_COL_HAS_IMAGES  = 32768
+    }
+}
+
+enum {
+    LVSCW_AUTOSIZE           = -1,
+    LVSCW_AUTOSIZE_USEHEADER = -2
+}
+
+enum {
+    LVN_ITEMCHANGING    = LVN_FIRST,
+    LVN_ITEMCHANGED     = LVN_FIRST - 1,
+    LVN_INSERTITEM      = LVN_FIRST - 2,
+    LVN_DELETEITEM      = LVN_FIRST - 3,
+    LVN_DELETEALLITEMS  = LVN_FIRST - 4,
+    LVN_BEGINLABELEDITA = LVN_FIRST - 5,
+    LVN_ENDLABELEDITA   = LVN_FIRST - 6,
+    LVN_COLUMNCLICK     = LVN_FIRST - 8,
+    LVN_BEGINDRAG       = LVN_FIRST - 9,
+    LVN_BEGINRDRAG      = LVN_FIRST - 11,
+    LVN_GETDISPINFOA    = LVN_FIRST - 50,
+    LVN_SETDISPINFOA    = LVN_FIRST - 51,
+    LVN_KEYDOWN         = LVN_FIRST - 55,
+    LVN_BEGINLABELEDITW = LVN_FIRST - 75,
+    LVN_ENDLABELEDITW   = LVN_FIRST - 76,
+    LVN_GETDISPINFOW    = LVN_FIRST - 77,
+    LVN_SETDISPINFOW    = LVN_FIRST - 78
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        LVN_MARQUEEBEGIN = LVN_FIRST - 56,
+        LVN_GETINFOTIPA  = LVN_FIRST - 57,
+        LVN_GETINFOTIPW  = LVN_FIRST - 58,
+        LVKF_ALT         = 1,
+        LVKF_CONTROL     = 2,
+        LVKF_SHIFT       = 4,
+        LVGIT_UNFOLDED   = 1
+    }
+}
+
+enum {
+    TVS_HASBUTTONS      = 1,
+    TVS_HASLINES        = 2,
+    TVS_LINESATROOT     = 4,
+    TVS_EDITLABELS      = 8,
+    TVS_DISABLEDRAGDROP = 16,
+    TVS_SHOWSELALWAYS   = 32
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        TVS_RTLREADING  = 64,
+        TVS_NOTOOLTIPS  = 128,
+        TVS_CHECKBOXES  = 256,
+        TVS_TRACKSELECT = 512
+    }
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TVS_SINGLEEXPAND  = 1024,
+        TVS_INFOTIP       = 2048,
+        TVS_FULLROWSELECT = 4096,
+        TVS_NOSCROLL      = 8192,
+        TVS_NONEVENHEIGHT = 16384
+    }
+}
+
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        TVS_NOHSCROLL = 0x8000
+    }
+}
+
+enum {
+    TVIF_TEXT          = 1,
+    TVIF_IMAGE         = 2,
+    TVIF_PARAM         = 4,
+    TVIF_STATE         = 8,
+    TVIF_HANDLE        = 16,
+    TVIF_SELECTEDIMAGE = 32,
+    TVIF_CHILDREN      = 64
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TVIF_INTEGRAL = 0x0080
+    }
+}
+
+enum {
+    TVIS_FOCUSED        = 1,
+    TVIS_SELECTED       = 2,
+    TVIS_CUT            = 4,
+    TVIS_DROPHILITED    = 8,
+    TVIS_BOLD           = 16,
+    TVIS_EXPANDED       = 32,
+    TVIS_EXPANDEDONCE   = 64,
+    TVIS_OVERLAYMASK    = 0xF00,
+    TVIS_STATEIMAGEMASK = 0xF000,
+    TVIS_USERMASK       = 0xF000
+}
+
+enum {
+    I_CHILDRENCALLBACK = -1
+}
+
+mixin DECLARE_HANDLE!("HTREEITEM");
+mixin DECLARE_HANDLE!("HIMAGELIST");
+
+version(Win64)
+{
+enum HTREEITEM
+    TVI_ROOT  = cast(HTREEITEM) cast(ULONG_PTR)-0x10000,
+    TVI_FIRST = cast(HTREEITEM) cast(ULONG_PTR)-0xffff,
+    TVI_LAST  = cast(HTREEITEM) cast(ULONG_PTR)-0xfffe,
+    TVI_SORT  = cast(HTREEITEM) cast(ULONG_PTR)-0xfffd;
+} else {
+enum HTREEITEM
+    TVI_ROOT  = cast(HTREEITEM) 0xFFFF0000,
+    TVI_FIRST = cast(HTREEITEM) 0xFFFF0001,
+    TVI_LAST  = cast(HTREEITEM) 0xFFFF0002,
+    TVI_SORT  = cast(HTREEITEM) 0xFFFF0003;
+}
+
+enum {
+    TVSIL_NORMAL = 0,
+    TVSIL_STATE  = 2
+}
+
+enum {
+    TVM_INSERTITEMA       = TV_FIRST,
+    TVM_DELETEITEM        = TV_FIRST + 1,
+    TVM_EXPAND            = TV_FIRST + 2,
+    TVM_GETITEMRECT       = TV_FIRST + 4,
+    TVM_GETCOUNT,
+    TVM_GETINDENT,
+    TVM_SETINDENT,
+    TVM_GETIMAGELIST,
+    TVM_SETIMAGELIST,
+    TVM_GETNEXTITEM,
+    TVM_SELECTITEM,
+    TVM_GETITEMA,
+    TVM_SETITEMA,
+    TVM_EDITLABELA,
+    TVM_GETEDITCONTROL,
+    TVM_GETVISIBLECOUNT,
+    TVM_HITTEST,
+    TVM_CREATEDRAGIMAGE,
+    TVM_SORTCHILDREN,
+    TVM_ENSUREVISIBLE,
+    TVM_SORTCHILDRENCB,
+    TVM_ENDEDITLABELNOW,
+    TVM_GETISEARCHSTRINGA, // = TV_FIRST + 23
+    TVM_INSERTITEMW       = TV_FIRST + 50,
+    TVM_GETITEMW          = TV_FIRST + 62,
+    TVM_SETITEMW          = TV_FIRST + 63,
+    TVM_GETISEARCHSTRINGW = TV_FIRST + 64,
+    TVM_EDITLABELW        = TV_FIRST + 65
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        TVM_GETTOOLTIPS = TV_FIRST + 25,
+        TVM_SETTOOLTIPS = TV_FIRST + 24
+    }
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TVM_SETINSERTMARK      = TV_FIRST + 26,
+        TVM_SETITEMHEIGHT,
+        TVM_GETITEMHEIGHT,
+        TVM_SETBKCOLOR,
+        TVM_SETTEXTCOLOR,
+        TVM_GETBKCOLOR,
+        TVM_GETTEXTCOLOR,
+        TVM_SETSCROLLTIME,
+        TVM_GETSCROLLTIME,  // = TV_FIRST + 34
+        TVM_SETINSERTMARKCOLOR = TV_FIRST + 37,
+        TVM_GETINSERTMARKCOLOR = TV_FIRST + 38,
+        TVM_SETUNICODEFORMAT   = CCM_SETUNICODEFORMAT,
+        TVM_GETUNICODEFORMAT   = CCM_GETUNICODEFORMAT
+    }
+}
+
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        TVM_GETITEMSTATE = TV_FIRST + 39,
+        TVM_SETLINECOLOR = TV_FIRST + 40,
+        TVM_GETLINECOLOR = TV_FIRST + 41
+    }
+}
+
+static if (_WIN32_IE >= 0x501) {
+    enum {
+        TVM_MAPACCIDTOHTREEITEM = TV_FIRST + 42,
+        TVM_MAPHTREEITEMTOACCID = TV_FIRST + 43,
+        TVM_SETEXTENDEDSTYLE = TV_FIRST + 44,
+        TVM_GETEXTENDEDSTYLE = TV_FIRST + 45,
+        TVM_SETAUTOSCROLLINFO = TV_FIRST + 59
+    }
+}
+
+static if (_WIN32_IE >= 0x600) {
+    enum {
+        TVM_GETSELECTEDCOUNT = TV_FIRST + 70,
+        TVM_SHOWINFOTIP = TV_FIRST + 71,
+        TVM_GETITEMPARTRECT = TV_FIRST + 72,
+    }
+}
+
+enum {
+    TVE_COLLAPSE      = 1,
+    TVE_EXPAND        = 2,
+    TVE_TOGGLE        = 3,
+    TVE_COLLAPSERESET = 0x8000
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        TVE_EXPANDPARTIAL = 0x4000
+    }
+}
+
+enum {
+    TVC_UNKNOWN,
+    TVC_BYMOUSE,
+    TVC_BYKEYBOARD // = 2
+}
+
+enum {
+    TVGN_ROOT,
+    TVGN_NEXT,
+    TVGN_PREVIOUS,
+    TVGN_PARENT,
+    TVGN_CHILD,
+    TVGN_FIRSTVISIBLE,
+    TVGN_NEXTVISIBLE,
+    TVGN_PREVIOUSVISIBLE,
+    TVGN_DROPHILITE,
+    TVGN_CARET // = 9
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TVGN_LASTVISIBLE = 10
+    }
+}
+
+static if (_WIN32_IE >= 0x600) {
+    enum {
+        TVGN_NEXTSELECTED = 11
+    }
+}
+
+enum {
+    TVN_SELCHANGINGA    = TVN_FIRST - 1,
+    TVN_SELCHANGEDA     = TVN_FIRST - 2,
+    TVN_GETDISPINFOA    = TVN_FIRST - 3,
+    TVN_SETDISPINFOA    = TVN_FIRST - 4,
+    TVN_ITEMEXPANDINGA  = TVN_FIRST - 5,
+    TVN_ITEMEXPANDEDA   = TVN_FIRST - 6,
+    TVN_BEGINDRAGA      = TVN_FIRST - 7,
+    TVN_BEGINRDRAGA     = TVN_FIRST - 8,
+    TVN_DELETEITEMA     = TVN_FIRST - 9,
+    TVN_BEGINLABELEDITA = TVN_FIRST - 10,
+    TVN_ENDLABELEDITA   = TVN_FIRST - 11,
+    TVN_KEYDOWN         = TVN_FIRST - 12,
+    TVN_SELCHANGINGW    = TVN_FIRST - 50,
+    TVN_SELCHANGEDW     = TVN_FIRST - 51,
+    TVN_GETDISPINFOW    = TVN_FIRST - 52,
+    TVN_SETDISPINFOW    = TVN_FIRST - 53,
+    TVN_ITEMEXPANDINGW  = TVN_FIRST - 54,
+    TVN_ITEMEXPANDEDW   = TVN_FIRST - 55,
+    TVN_BEGINDRAGW      = TVN_FIRST - 56,
+    TVN_BEGINRDRAGW     = TVN_FIRST - 57,
+    TVN_DELETEITEMW     = TVN_FIRST - 58,
+    TVN_BEGINLABELEDITW = TVN_FIRST - 59,
+    TVN_ENDLABELEDITW   = TVN_FIRST - 60
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TVNRET_DEFAULT   = 0,
+        TVNRET_SKIPOLD   = 1,
+        TVNRET_SKIPNEW   = 2,
+        TVN_GETINFOTIPA  = TVN_FIRST - 13,
+        TVN_GETINFOTIPW  = TVN_FIRST - 14,
+        TVN_SINGLEEXPAND = TVN_FIRST - 15
+    }
+}
+
+enum {
+    TVIF_DI_SETITEM = 0x1000
+}
+
+enum {
+    TVHT_NOWHERE         = 1,
+    TVHT_ONITEMICON      = 2,
+    TVHT_ONITEMLABEL     = 4,
+    TVHT_ONITEMINDENT    = 8,
+    TVHT_ONITEMBUTTON    = 16,
+    TVHT_ONITEMRIGHT     = 32,
+    TVHT_ONITEMSTATEICON = 64,
+    TVHT_ABOVE           = 256,
+    TVHT_BELOW           = 512,
+    TVHT_TORIGHT         = 1024,
+    TVHT_TOLEFT          = 2048,
+    TCHT_NOWHERE         = 1,
+    TCHT_ONITEMICON      = 2,
+    TCHT_ONITEMLABEL     = 4,
+    TVHT_ONITEM          = TVHT_ONITEMICON | TVHT_ONITEMLABEL
+                           | TVHT_ONITEMSTATEICON,
+    TCHT_ONITEM          = TCHT_ONITEMICON | TCHT_ONITEMLABEL
+}
+
+enum {
+    TCS_TABS              = 0,
+    TCS_RIGHTJUSTIFY      = 0,
+    TCS_SINGLELINE        = 0,
+    TCS_FORCEICONLEFT     = 16,
+    TCS_FORCELABELLEFT    = 32,
+    TCS_BUTTONS           = 256,
+    TCS_MULTILINE         = 512,
+    TCS_FIXEDWIDTH        = 1024,
+    TCS_RAGGEDRIGHT       = 2048,
+    TCS_FOCUSONBUTTONDOWN = 0x1000,
+    TCS_OWNERDRAWFIXED    = 0x2000,
+    TCS_TOOLTIPS          = 0x4000,
+    TCS_FOCUSNEVER        = 0x8000
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        TCS_BOTTOM         = 2,
+        TCS_RIGHT          = 2,
+        TCS_VERTICAL       = 128,
+        TCS_SCROLLOPPOSITE = 0x0001,
+        TCS_HOTTRACK       = 0x0040,
+        TCS_MULTISELECT    = 0x0004
+    }
+}
+
+static if(_WIN32_IE >= 0x400) {
+    enum {
+        TCS_FLATBUTTONS       = 0x0008,
+        TCS_EX_FLATSEPARATORS = 0x00000001,
+        TCS_EX_REGISTERDROP   = 0x00000002
+    }
+}
+
+enum {
+    TCIF_TEXT       = 1,
+    TCIF_IMAGE      = 2,
+    TCIF_RTLREADING = 4,
+    TCIF_PARAM      = 8
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TCIF_STATE = 16
+    }
+}
+
+enum {
+    TCIS_BUTTONPRESSED = 1
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        TCIS_HIGHLIGHTED = 2
+    }
+}
+
+enum {
+    TCM_FIRST          = 0x1300,
+    TCM_GETIMAGELIST   = TCM_FIRST + 2,
+    TCM_SETIMAGELIST,
+    TCM_GETITEMCOUNT,
+    TCM_GETITEMA,
+    TCM_SETITEMA,
+    TCM_INSERTITEMA,
+    TCM_DELETEITEM,
+    TCM_DELETEALLITEMS,
+    TCM_GETITEMRECT,
+    TCM_GETCURSEL,
+    TCM_SETCURSEL,
+    TCM_HITTEST,
+    TCM_SETITEMEXTRA, // = TCM_FIRST + 14
+    TCM_ADJUSTRECT     = TCM_FIRST + 40,
+    TCM_SETITEMSIZE,
+    TCM_REMOVEIMAGE,
+    TCM_SETPADDING,
+    TCM_GETROWCOUNT,
+    TCM_GETTOOLTIPS,
+    TCM_SETTOOLTIPS,
+    TCM_GETCURFOCUS,
+    TCM_SETCURFOCUS,
+    TCM_SETMINTABWIDTH,
+    TCM_DESELECTALL, // = TCM_FIRST + 50
+    TCM_GETITEMW       = TCM_FIRST + 60,
+    TCM_SETITEMW       = TCM_FIRST + 61,
+    TCM_INSERTITEMW    = TCM_FIRST + 62
+}
+
+static if (_WIN32_IE >=0x0400) {
+    enum {
+        TCM_HIGHLIGHTITEM    = TCM_FIRST + 51,
+        TCM_SETEXTENDEDSTYLE = TCM_FIRST + 52,
+        TCM_GETEXTENDEDSTYLE = TCM_FIRST + 53,
+        TCM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT,
+        TCM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT
+    }
+}
+
+enum {
+    TCN_KEYDOWN     = TCN_FIRST,
+    TCN_SELCHANGE   = TCN_FIRST - 1,
+    TCN_SELCHANGING = TCN_FIRST - 2
+}
+
+enum {
+    NM_OUTOFMEMORY     = NM_FIRST - 1,
+    NM_CLICK           = NM_FIRST - 2,
+    NM_DBLCLK          = NM_FIRST - 3,
+    NM_RETURN          = NM_FIRST - 4,
+    NM_RCLICK          = NM_FIRST - 5,
+    NM_RDBLCLK         = NM_FIRST - 6,
+    NM_SETFOCUS        = NM_FIRST - 7,
+    NM_KILLFOCUS       = NM_FIRST - 8,
+    NM_CUSTOMDRAW      = NM_FIRST - 12,
+    NM_HOVER           = NM_FIRST - 13,
+    NM_NCHITTEST       = NM_FIRST - 14,
+    NM_KEYDOWN         = NM_FIRST - 15,
+    NM_RELEASEDCAPTURE = NM_FIRST - 16,
+    NM_SETCURSOR       = NM_FIRST - 17,
+    NM_CHAR            = NM_FIRST - 18,
+    NM_TOOLTIPSCREATED = NM_FIRST - 19
+}
+
+enum {
+    SBARS_SIZEGRIP = 256
+}
+
+/*enum {
+    CCM_FIRST            = 0x2000,
+    CCM_LAST             = CCM_FIRST + 0x200,
+    CCM_SETBKCOLOR       = 8193,
+    CCM_SETCOLORSCHEME   = 8194,
+    CCM_GETCOLORSCHEME   = 8195,
+    CCM_GETDROPTARGET    = 8196,
+    CCM_SETUNICODEFORMAT = 8197,
+    CCM_GETUNICODEFORMAT = 8198,
+    CCM_SETVERSION       = 0x2007,
+    CCM_GETVERSION       = 0x2008,
+    CCM_SETNOTIFYWINDOW  = 0x2009
+}*/
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        CCM_SETWINDOWTHEME = 0x200b,
+        CCM_DPISCALE       = 0x200c,
+
+        RB_GETBANDMARGINS = WM_USER + 40,
+        RB_SETWINDOWTHEME = CCM_SETWINDOWTHEME,
+        TB_SETWINDOWTHEME  = CCM_SETWINDOWTHEME,
+        TTM_SETWINDOWTHEME = CCM_SETWINDOWTHEME,
+    }
+}
+
+enum {
+    ICC_LISTVIEW_CLASSES = 1,
+    ICC_TREEVIEW_CLASSES = 2,
+    ICC_BAR_CLASSES      = 4,
+    ICC_TAB_CLASSES      = 8,
+    ICC_UPDOWN_CLASS     = 16,
+    ICC_PROGRESS_CLASS   = 32,
+    ICC_HOTKEY_CLASS     = 64,
+    ICC_ANIMATE_CLASS    = 128,
+    ICC_WIN95_CLASSES    = 255,
+    ICC_DATE_CLASSES     = 256,
+    ICC_USEREX_CLASSES   = 512,
+    ICC_COOL_CLASSES     = 1024
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        INFOTIPSIZE            = 1024,
+        ICC_INTERNET_CLASSES   = 2048,
+        ICC_PAGESCROLLER_CLASS = 4096,
+        ICC_NATIVEFNTCTL_CLASS = 8192
+    }
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        ICC_STANDARD_CLASSES = 0x00004000,
+        ICC_LINK_CLASS       = 0x00008000
+    }
+}
+
+enum {
+    GDTR_MIN = 1,
+    GDTR_MAX = 2
+}
+
+enum {
+    GMR_VISIBLE,
+    GMR_DAYSTATE
+}
+
+enum {
+    GDT_ERROR = -1,
+    GDT_VALID = 0,
+    GDT_NONE  = 1
+}
+
+enum {
+    DTS_SHORTDATEFORMAT = 0,
+    DTS_UPDOWN          = 1,
+    DTS_SHOWNONE        = 2,
+    DTS_LONGDATEFORMAT  = 4,
+    DTS_TIMEFORMAT      = 9,
+    DTS_APPCANPARSE     = 16,
+    DTS_RIGHTALIGN      = 32
+}
+
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        DTS_SHORTDATECENTURYFORMAT = 0x000C
+    }
+}
+
+enum {
+    MCS_DAYSTATE    = 1,
+    MCS_MULTISELECT = 2,
+    MCS_WEEKNUMBERS = 4
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        MCS_NOTODAYCIRCLE = 0x0008,
+        MCS_NOTODAY       = 0x0010
+    }
+} else {
+    enum {
+        MCS_NOTODAY = 0x0008
+    }
+}
+
+enum {
+    DTM_FIRST         = 0x10000,
+    DTM_GETSYSTEMTIME = 0x1001,
+    DTM_SETSYSTEMTIME = 0x1002,
+    DTM_GETRANGE      = 0x1003,
+    DTM_SETRANGE      = 0x1004,
+    DTM_SETFORMATA    = 0x1005,
+    DTM_SETMCCOLOR    = 0x1006,
+    DTM_GETMCCOLOR    = 0x1007,
+    DTM_GETMONTHCAL   = 0x1008,
+    DTM_SETMCFONT     = 0x1009,
+    DTM_GETMCFONT     = 0x100a,
+    DTM_SETFORMATW    = 0x1050
+}
+
+static if (_WIN32_WINNT >= 0x600) {
+    enum {
+        DTM_SETMCSTYLE = DTM_FIRST + 11,
+        DTM_GETMCSTYLE,
+        DTM_CLOSEMONTHCAL,
+        DTM_GETDATETIMEPICKERINFO,
+        DTM_GETIDEALSIZE,
+    }
+}
+
+enum {
+    DTN_USERSTRINGA    = -758U,
+    DTN_USERSTRINGW    = -745U,
+    DTN_WMKEYDOWNA     = -757U,
+    DTN_WMKEYDOWNW     = -744U,
+    DTN_FORMATA        = -756U,
+    DTN_FORMATW        = -743U,
+    DTN_FORMATQUERYA   = -755U,
+    DTN_FORMATQUERYW   = -742U,
+    DTN_DROPDOWN       = -754U,
+    DTN_CLOSEUP        = -753U,
+    DTN_DATETIMECHANGE = -759U,
+}
+
+enum {
+    MCM_FIRST             = 0x1000,
+    MCM_GETCURSEL         = 0x1001,
+    MCM_SETCURSEL         = 0x1002,
+    MCM_GETMAXSELCOUNT    = 0x1003,
+    MCM_SETMAXSELCOUNT    = 0x1004,
+    MCM_GETSELRANGE       = 0x1005,
+    MCM_SETSELRANGE       = 0x1006,
+    MCM_GETMONTHRANGE     = 0x1007,
+    MCM_SETDAYSTATE       = 0x1008,
+    MCM_GETMINREQRECT     = 0x1009,
+    MCM_SETCOLOR          = 0x100a,
+    MCM_GETCOLOR          = 0x100b,
+    MCM_SETTODAY          = 0x100c,
+    MCM_GETTODAY          = 0x100d,
+    MCM_HITTEST           = 0x100e,
+    MCM_SETFIRSTDAYOFWEEK = 0x100f,
+    MCM_GETFIRSTDAYOFWEEK = 0x1010,
+    MCM_GETRANGE          = 0x1011,
+    MCM_SETRANGE          = 0x1012,
+    MCM_GETMONTHDELTA     = 0x1013,
+    MCM_SETMONTHDELTA     = 0x1014,
+    MCM_GETMAXTODAYWIDTH  = 0x1015,
+    MCM_GETUNICODEFORMAT  = CCM_GETUNICODEFORMAT,
+    MCM_SETUNICODEFORMAT  = CCM_SETUNICODEFORMAT
+}
+
+static if (_WIN32_WINNT >= 0x600) {
+    enum {
+        MCM_GETCURRENTVIEW = MCM_FIRST + 22,
+        MCM_GETCALENDARCOUNT,
+        MCM_GETCALENDARGRIDINFO,
+        MCM_GETCALID = MCM_FIRST + 27,
+        MCM_SETCALID,
+        MCM_SIZERECTTOMIN,
+        MCM_SETCALENDARBORDER,
+        MCM_GETCALENDARBORDER,
+        MCM_SETCURRENTVIEW,
+    }
+}
+
+enum {
+    MCN_SELCHANGE   = -749U,
+    MCN_GETDAYSTATE = -747U,
+    MCN_SELECT      = -746U
+}
+
+enum {
+    ODT_HEADER = 100,
+    ODT_TAB,
+    ODT_LISTVIEW // = 102
+}
+
+enum {
+    SB_SETBKCOLOR = 0x2001
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        SB_ISSIMPLE = 1038
+    }
+
+    enum {
+        MCSC_BACKGROUND,
+        MCSC_TEXT,
+        MCSC_TITLEBK,
+        MCSC_TITLETEXT,
+        MCSC_MONTHBK,
+        MCSC_TRAILINGTEXT // = 5
+    }
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        MCHT_TITLE            = 0x10000,
+        MCHT_CALENDAR         = 0x20000,
+        MCHT_TODAYLINK        = 0x30000,
+        MCHT_NEXT             = 0x1000000,
+        MCHT_PREV             = 0x2000000,
+        MCHT_NOWHERE          = 0x00,
+        MCHT_TITLEBK          = MCHT_TITLE,
+        MCHT_TITLEMONTH       = MCHT_TITLE | 0x0001,
+        MCHT_TITLEYEAR        = MCHT_TITLE | 0x0002,
+        MCHT_TITLEBTNNEXT     = MCHT_TITLE | MCHT_NEXT | 0x0003,
+        MCHT_TITLEBTNPREV     = MCHT_TITLE | MCHT_PREV | 0x0003,
+        MCHT_CALENDARBK       = MCHT_CALENDAR,
+        MCHT_CALENDARDATE     = MCHT_CALENDAR | 0x0001,
+        MCHT_CALENDARDATENEXT = MCHT_CALENDARDATE | MCHT_NEXT,
+        MCHT_CALENDARDATEPREV = MCHT_CALENDARDATE | MCHT_PREV,
+        MCHT_CALENDARDAY      = MCHT_CALENDAR | 0x0002,
+        MCHT_CALENDARWEEKNUM  = MCHT_CALENDAR | 0x0003
+    }
+}
+
+enum {
+    RBS_TOOLTIPS    = 256,
+    RBS_VARHEIGHT   = 512,
+    RBS_BANDBORDERS = 1024,
+    RBS_FIXEDORDER  = 2048
+}
+
+enum {
+    RBIM_IMAGELIST = 1
+}
+
+enum {
+    RB_SETCOLORSCHEME = CCM_SETCOLORSCHEME,
+    RB_GETCOLORSCHEME = CCM_GETCOLORSCHEME
+}
+
+enum {
+    RBBS_BREAK          = 0x0001,
+    RBBS_FIXEDSIZE      = 0x0002,
+    RBBS_CHILDEDGE      = 0x0004,
+    RBBS_HIDDEN         = 0x0008,
+    RBBS_NOVERT         = 0x0010,
+    RBBS_FIXEDBMP       = 0x0020,
+    RBBS_VARIABLEHEIGHT = 0x0040,
+    RBBS_GRIPPERALWAYS  = 0x0080,
+    RBBS_NOGRIPPER      = 0x0100
+}
+
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        RBBS_USECHEVRON = 0x0200
+    }
+}
+
+static if (_WIN32_IE >= 0x501) {
+    enum {
+        RBBS_HIDETITLE = 0x0400,
+        RBBS_TOPALIGN  = 0x0800
+    }
+}
+
+enum {
+    RBBIM_STYLE      = 1,
+    RBBIM_COLORS     = 2,
+    RBBIM_TEXT       = 4,
+    RBBIM_IMAGE      = 8,
+    RBBIM_CHILD      = 16,
+    RBBIM_CHILDSIZE  = 32,
+    RBBIM_SIZE       = 64,
+    RBBIM_BACKGROUND = 128,
+    RBBIM_ID         = 256
+}
+
+enum {
+    RB_INSERTBANDA  = WM_USER + 1,
+    RB_DELETEBAND,
+    RB_GETBARINFO,
+    RB_SETBARINFO, // = WM_USER + 4
+    RB_SETBANDINFOA = WM_USER + 6,
+    RB_SETPARENT    = WM_USER + 7,
+    RB_INSERTBANDW  = WM_USER + 10,
+    RB_SETBANDINFOW,
+    RB_GETBANDCOUNT,
+    RB_GETROWCOUNT,
+    RB_GETROWHEIGHT // = WM_USER + 14,
+}
+
+enum {
+    RBN_HEIGHTCHANGE = RBN_FIRST
+}
+
+static if (_WIN32_IE >= 0x300) {
+    enum {
+        LVN_ODCACHEHINT    = LVN_FIRST - 13,
+        LVN_ODFINDITEMA    = LVN_FIRST - 52,
+        LVN_ODFINDITEMW    = LVN_FIRST - 79,
+        LVN_ITEMACTIVATE   = LVN_FIRST - 14,
+        LVN_ODSTATECHANGED = LVN_FIRST - 15
+    }
+
+    version (Unicode) {
+        enum {
+            LVN_ODFINDITEM = LVN_ODFINDITEMW
+        }
+    } else {
+        enum {
+            LVN_ODFINDITEM = LVN_ODFINDITEMA
+        }
+    }
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        SB_SETICON          = 1039,
+        SB_SETTIPTEXTA,
+        SB_SETTIPTEXTW,
+        SB_GETTIPTEXTA,
+        SB_GETTIPTEXTW,
+        SB_GETICON,      // = 1044
+        SB_SETUNICODEFORMAT = 0x2005,
+        SB_GETUNICODEFORMAT = 0x2006
+    }
+
+    enum {
+        PGF_INVISIBLE = 0,
+        PGF_NORMAL    = 1,
+        PGF_GRAYED    = 2,
+        PGF_DEPRESSED = 4,
+        PGF_HOT       = 8
+    }
+
+    enum {
+        PGB_TOPORLEFT,
+        PGB_BOTTOMORRIGHT
+    }
+
+    enum {
+        PGF_SCROLLUP    = 1,
+        PGF_SCROLLDOWN  = 2,
+        PGF_SCROLLLEFT  = 4,
+        PGF_SCROLLRIGHT = 8
+    }
+
+    enum {
+        PGK_SHIFT   = 1,
+        PGK_CONTROL = 2,
+        PGK_MENU    = 4
+    }
+
+    enum {
+        PGF_CALCWIDTH  = 1,
+        PGF_CALCHEIGHT = 2
+    }
+
+    enum {
+        PGM_FIRST    = 0x1400,
+        PGM_SETCHILD = PGM_FIRST + 1,
+        PGM_RECALCSIZE,
+        PGM_FORWARDMOUSE,
+        PGM_SETBKCOLOR,
+        PGM_GETBKCOLOR,
+        PGM_SETBORDER,
+        PGM_GETBORDER,
+        PGM_SETPOS,
+        PGM_GETPOS,
+        PGM_SETBUTTONSIZE,
+        PGM_GETBUTTONSIZE,
+        PGM_GETBUTTONSTATE, // = PGM_FIRST + 12
+        PGM_GETDROPTARGET = CCM_GETDROPTARGET
+    }
+
+    enum {
+        RBS_REGISTERDROP    = 4096,
+        RBS_AUTOSIZE        = 8192,
+        RBS_VERTICALGRIPPER = 16384,
+        RBS_DBLCLKTOGGLE    = 32768
+    }
+
+    enum {
+        RBBIM_IDEALSIZE  = 512,
+        RBBIM_LPARAM     = 1024,
+        RBBIM_HEADERSIZE = 2048
+    }
+
+    enum {
+        RB_HITTEST          = WM_USER + 8,
+        RB_GETRECT          = WM_USER + 9,
+        RB_IDTOINDEX        = WM_USER + 16,
+        RB_GETTOOLTIPS,
+        RB_SETTOOLTIPS,
+        RB_SETBKCOLOR,
+        RB_GETBKCOLOR,
+        RB_SETTEXTCOLOR,
+        RB_GETTEXTCOLOR,
+        RB_SIZETORECT,
+        RB_BEGINDRAG,
+        RB_ENDDRAG,
+        RB_DRAGMOVE,
+        RB_GETBARHEIGHT,
+        RB_GETBANDINFOW,
+        RB_GETBANDINFOA,
+        RB_MINIMIZEBAND,
+        RB_MAXIMIZEBAND, // = WM_USER + 31
+        RB_GETDROPTARGET    = CCM_GETDROPTARGET,
+        RB_GETBANDBORDERS   = WM_USER + 34,
+        RB_SHOWBAND         = WM_USER + 35,
+        RB_SETPALETTE       = WM_USER + 37,
+        RB_GETPALETTE       = WM_USER + 38,
+        RB_MOVEBAND         = WM_USER + 39,
+        RB_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT,
+        RB_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT
+    }
+
+    enum {
+        RBN_GETOBJECT     = RBN_FIRST - 1,
+        RBN_LAYOUTCHANGED = RBN_FIRST - 2,
+        RBN_AUTOSIZE      = RBN_FIRST - 3,
+        RBN_BEGINDRAG     = RBN_FIRST - 4,
+        RBN_ENDDRAG       = RBN_FIRST - 5,
+        RBN_DELETINGBAND  = RBN_FIRST - 6,
+        RBN_DELETEDBAND   = RBN_FIRST - 7,
+        RBN_CHILDSIZE     = RBN_FIRST - 8
+    }
+
+    enum {
+        RBNM_ID     = 1,
+        RBNM_STYLE  = 2,
+        RBNM_LPARAM = 4
+    }
+
+    enum {
+        RBHT_NOWHERE = 1,
+        RBHT_CAPTION,
+        RBHT_CLIENT,
+        RBHT_GRABBER
+    }
+
+    version (Unicode) {
+        alias SB_SETTIPTEXTW SB_SETTIPTEXT;
+        alias SB_GETTIPTEXTW SB_GETTIPTEXT;
+        alias RB_GETBANDINFOW RB_GETBANDINFO;
+    } else {
+        alias SB_SETTIPTEXTA SB_SETTIPTEXT;
+        alias SB_GETTIPTEXTA SB_GETTIPTEXT;
+        alias RB_GETBANDINFOA RB_GETBANDINFO;
+    }
+} else {
+    enum {
+        RB_GETBANDINFO = WM_USER + 5
+    }
+}
+
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        RB_PUSHCHEVRON = WM_USER + 43,
+    }
+}
+
+static if (_WIN32_IE >= 0x600) {
+    enum {
+        RB_SETEXTENDEDSTYLE = WM_USER + 41,
+        RB_GETEXTENDEDSTYLE = WM_USER + 42,
+    }
+}
+
+static if (_WIN32_WINNT >= 0x500) {
+    enum {
+        RB_SETBANDWIDTH = WM_USER + 44,
+    }
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        ECM_FIRST = 0x1500,
+        BCM_FIRST = 0x1600,
+
+        BCM_GETIDEALSIZE = BCM_FIRST + 0x0001,
+        BCM_SETIMAGELIST = BCM_FIRST + 0x0002,
+        BCM_GETIMAGELIST = BCM_FIRST + 0x0003,
+        BCM_SETTEXTMARGIN = BCM_FIRST + 0x0004,
+        BCM_GETTEXTMARGIN = BCM_FIRST + 0x0005,
+
+        BCN_HOTITEMCHANGE = BCN_FIRST + 0x0001,
+    }
+
+    struct NMBCHOTITEM {
+        NMHDR hdr;
+        DWORD dwFlags;
+    }
+    alias NMBCHOTITEM* LPNMBCHOTITEM;
+}
+
+static if(_WIN32_WINNT >= 0x600) {
+    enum {
+        BST_DROPDOWNPUSHED      = 0x0400,
+
+        BS_SPLITBUTTON          = 0x0000_000C,
+        BS_DEFSPLITBUTTON       = 0x0000_000D,
+        BS_COMMANDLINK          = 0x0000_000E,
+        BS_DEFCOMMANDLINK       = 0x0000_000F,
+
+        BCSIF_GLYPH             = 0x0001,
+        BCSIF_IMAGE             = 0x0002,
+        BCSIF_STYLE             = 0x0004,
+        BCSIF_SIZE              = 0x0008,
+
+        BCSS_NOSPLIT            = 0x0001,
+        BCSS_STRETCH            = 0x0002,
+        BCSS_ALIGNLEFT          = 0x0004,
+        BCSS_IMAGE              = 0x0008,
+
+        BCM_SETDROPDOWNSTATE = BCM_FIRST + 0x0006,
+        BCM_SETSPLITINFO = BCM_FIRST + 0x0007,
+        BCM_GETSPLITINFO = BCM_FIRST + 0x0008,
+        BCM_SETNOTE = BCM_FIRST + 0x0009,
+        BCM_GETNOTE = BCM_FIRST + 0x000A,
+        BCM_GETNOTELENGTH = BCM_FIRST + 0x000B,
+        BCM_SETSHIELD = BCM_FIRST + 0x000C,
+
+        BCN_DROPDOWN = BCN_FIRST + 0x0002,
+    }
+
+enum HIMAGELIST BCCL_NOGLYPH = cast(HIMAGELIST)-1;
+
+    struct BUTTON_SPLITINFO
+    {
+        UINT mask;
+        HIMAGELIST himlGlyph;
+        UINT uSplitStyle;
+        SIZE size;
+    }
+    alias BUTTON_SPLITINFO* PBUTTON_SPLITINFO;
+}
+
+enum {
+    CBEM_INSERTITEMA = WM_USER + 1,
+    CBEM_SETIMAGELIST,
+    CBEM_GETIMAGELIST,
+    CBEM_GETITEMA,
+    CBEM_SETITEMA,
+    CBEM_GETCOMBOCONTROL,
+    CBEM_GETEDITCONTROL,
+    CBEM_SETEXSTYLE,
+    CBEM_GETEXSTYLE, // = WM_USER + 9)
+    CBEM_DELETEITEM  = CB_DELETESTRING
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        CBEM_SETEXTENDEDSTYLE = WM_USER + 14,
+        CBEM_GETEXTENDEDSTYLE = WM_USER + 9,
+        CBEM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT,
+        CBEM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT
+    }
+}
+
+enum {
+    CBEM_HASEDITCHANGED = WM_USER + 10,
+    CBEM_INSERTITEMW    = WM_USER + 11,
+    CBEM_SETITEMW       = WM_USER + 12,
+    CBEM_GETITEMW       = WM_USER + 13
+}
+
+static if (_WIN32_WINNT >= 0x501)
+{
+    enum {
+        CBEM_SETWINDOWTHEME = CCM_SETWINDOWTHEME
+    }
+}
+
+enum {
+    DA_LAST = 0x7fffffff
+}
+
+enum {
+    DPA_APPEND = 0x7fffffff,
+    DPA_ERR    = -1
+}
+
+enum {
+    DSA_APPEND = 0x7fffffff,
+    DSA_ERR    = -1
+}
+
+enum {
+    DPAS_SORTED       = 1,
+    DPAS_INSERTBEFORE = 2,
+    DPAS_INSERTAFTER  = 4
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        WSB_PROP_CYVSCROLL = 1,
+        WSB_PROP_CXHSCROLL = 2,
+        WSB_PROP_CYHSCROLL = 4,
+        WSB_PROP_CXVSCROLL = 8,
+        WSB_PROP_CXHTHUMB  = 16,
+        WSB_PROP_CYVTHUMB  = 32,
+        WSB_PROP_VBKGCOLOR = 64,
+        WSB_PROP_HBKGCOLOR = 128,
+        WSB_PROP_VSTYLE    = 256,
+        WSB_PROP_HSTYLE    = 512,
+        WSB_PROP_WINSTYLE  = 1024,
+        WSB_PROP_PALETTE   = 2048,
+        WSB_PROP_MASK      = 0xfff,
+        FSB_FLAT_MODE      = 2,
+        FSB_ENCARTA_MODE   = 1,
+        FSB_REGULAR_MODE   = 0
+    }
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        LIF_ITEMINDEX = 1,
+        LIF_STATE     = 2,
+        LIF_ITEMID    = 4,
+        LIF_URL       = 8
+    }
+
+    enum {
+        LIS_FOCUSED = 1,
+        LIS_ENABLED = 2,
+        LIS_VISITED = 4
+    }
+
+    enum {
+        LM_HITTEST        = WM_USER + 768,
+        LM_GETIDEALHEIGHT,
+        LM_SETITEM,
+        LM_GETITEM,     // = WM_USER + 771
+        LM_GETIDEALSIZE = LM_GETIDEALHEIGHT,
+    }
+
+enum size_t MAX_LINKID_TEXT  =   48;
+enum size_t L_MAX_URL_LENGTH = 2084;
+}
+
+
+struct TBMETRICS {
+    UINT  cbSize = TBMETRICS.sizeof;
+    DWORD dwMask;
+    int   cxPad;
+    int   cyPad;
+    int   cxBarPad;
+    int   cyBarPad;
+    int   cxButtonSpacing;
+    int   cyButtonSpacing;
+}
+alias TBMETRICS* LPTBMETRICS;
+
+static if (_WIN32_WINNT >= 0x501) {
+    struct TTGETTITLE {
+        DWORD dwSize = TTGETTITLE.sizeof;
+        UINT  uTitleBitmap;
+        UINT  cch;
+        WCHAR* pszTitle;
+    }
+    alias TTGETTITLE* PTTGETTITLE;
+}
+
+static if (_WIN32_WINNT >= 0x600) {
+    struct MCGRIDINFO {
+        UINT cbSize;
+        DWORD dwPart;
+        DWORD dwFlags;
+        int iCalendar;
+        int iRow;
+        int iCol;
+        BOOL bSelected;
+        SYSTEMTIME stStart;
+        SYSTEMTIME stEnd;
+        RECT rc;
+        PWSTR pszName;
+        size_t cchName;
+    }
+    alias MCGRIDINFO* PMCGRIDINFO;
+
+    struct DATETIMEPICKERINFO
+    {
+        DWORD cbSize;
+        RECT rcCheck;
+        DWORD stateCheck;
+        RECT rcButton;
+        DWORD stateButton;
+        HWND hwndEdit;
+        HWND hwndUD;
+        HWND hwndDropDown;
+    }
+    alias DATETIMEPICKERINFO* LPDATETIMEPICKERINFO;
+}
+
+struct COMBOBOXEXITEMA {
+    UINT   mask;
+    INT_PTR iItem;
+    LPSTR  pszText;
+    int    cchTextMax;
+    int    iImage;
+    int    iSelectedImage;
+    int    iOverlay;
+    int    iIndent;
+    LPARAM lParam;
+}
+alias COMBOBOXEXITEMA*        PCOMBOBOXEXITEMA;
+alias const(COMBOBOXEXITEMA)* PCCOMBOEXITEMA;
+
+struct COMBOBOXEXITEMW {
+    UINT   mask;
+    INT_PTR iItem;
+    LPWSTR pszText;
+    int    cchTextMax;
+    int    iImage;
+    int    iSelectedImage;
+    int    iOverlay;
+    int    iIndent;
+    LPARAM lParam;
+}
+alias COMBOBOXEXITEMW*        PCOMBOBOXEXITEMW;
+alias const(COMBOBOXEXITEMW)* PCCOMBOEXITEMW;
+
+static if (_WIN32_IE >= 0x400) {
+    struct NMCOMBOBOXEXA {
+        NMHDR           hdr;
+        COMBOBOXEXITEMA ceItem;
+    }
+    alias NMCOMBOBOXEXA* PNMCOMBOBOXEXA;
+
+    struct NMCOMBOBOXEXW {
+        NMHDR           hdr;
+        COMBOBOXEXITEMW ceItem;
+    }
+    alias NMCOMBOBOXEXW* PNMCOMBOBOXEXW;
+
+    struct NMCBEDRAGBEGINW {
+        NMHDR hdr;
+        int   iItemid;
+        WCHAR[CBEMAXSTRLEN] szText;
+    }
+    alias NMCBEDRAGBEGINW* LPNMCBEDRAGBEGINW, PNMCBEDRAGBEGINW;
+
+    struct NMCBEDRAGBEGINA {
+        NMHDR hdr;
+        int   iItemid;
+        char[CBEMAXSTRLEN] szText;
+    }
+    alias NMCBEDRAGBEGINA* LPNMCBEDRAGBEGINA, PNMCBEDRAGBEGINA;
+
+    struct NMIPADDRESS {
+        NMHDR hdr;
+        int   iField;
+        int   iValue;
+    }
+    alias NMIPADDRESS* LPNMIPADDRESS;
+
+    struct NMLVKEYDOWN {
+        NMHDR hdr;
+        WORD  wVKey;
+        UINT  flags;
+    }
+    alias NMLVKEYDOWN* LPNMLVKEYDOWN;
+
+    struct NMPGCALCSIZE {
+        NMHDR hdr;
+        DWORD dwFlag;
+        int   iWidth;
+        int   iHeight;
+    }
+    alias NMPGCALCSIZE* LPNMPGCALCSIZE;
+
+    struct NMPGSCROLL {
+        NMHDR hdr;
+        BOOL  fwKeys;
+        RECT  rcParent;
+        int   iDir;
+        int   iXpos;
+        int   iYpos;
+        int   iScroll;
+    }
+    alias NMPGSCROLL* LPNMPGSCROLL;
+
+    struct NMSELCHANGE {
+        NMHDR      nmhdr;
+        SYSTEMTIME stSelStart;
+        SYSTEMTIME stSelEnd;
+    }
+    alias NMSELCHANGE* LPNMSELCHANGE;
+
+    struct NMTBHOTITEM {
+        NMHDR hdr;
+        int   idOld;
+        int   idNew;
+        DWORD dwFlags;
+    }
+    alias NMTBHOTITEM* LPNMTBHOTITEM;
+
+    struct NMTBDISPINFOA {
+        NMHDR     hdr;
+        DWORD     dwMask;
+        int       idCommand;
+        DWORD_PTR lParam;
+        int       iImage;
+        LPSTR     pszText;
+        int       cchText;
+    }
+    alias NMTBDISPINFOA* LPNMTBDISPINFOA;
+
+    struct NMTBDISPINFOW {
+        NMHDR     hdr;
+        DWORD     dwMask;
+        int       idCommand;
+        DWORD_PTR lParam;
+        int       iImage;
+        LPWSTR    pszText;
+        int       cchText;
+    }
+    alias NMTBDISPINFOW* LPNMTBDISPINFOW;
+
+    struct NMTBGETINFOTIPA {
+        NMHDR  hdr;
+        LPSTR  pszText;
+        int    cchTextMax;
+        int    iItem;
+        LPARAM lParam;
+    }
+    alias NMTBGETINFOTIPA* LPNMTBGETINFOTIPA;
+
+    struct NMTBGETINFOTIPW {
+        NMHDR  hdr;
+        LPWSTR pszText;
+        int    cchTextMax;
+        int    iItem;
+        LPARAM lParam;
+    }
+    alias NMTBGETINFOTIPW* LPNMTBGETINFOTIPW;
+
+    struct NMMOUSE {
+        NMHDR     hdr;
+        DWORD_PTR dwItemSpec;
+        DWORD_PTR dwItemData;
+        POINT     pt;
+        LPARAM    dwHitInfo;
+    }
+    alias NMMOUSE* LPNMMOUSE;
+}
+
+static if (_WIN32_IE >= 0x401) {
+    struct NMTOOLTIPSCREATED {
+        NMHDR hdr;
+        HWND  hwndToolTips;
+    }
+    alias NMTOOLTIPSCREATED* LPNMTOOLTIPSCREATED;
+}
+
+struct NMDATETIMECHANGE {
+    NMHDR      nmhdr;
+    DWORD      dwFlags;
+    SYSTEMTIME st;
+}
+alias NMDATETIMECHANGE* LPNMDATETIMECHANGE;
+
+struct NMCBEENDEDITW {
+    NMHDR hdr;
+    BOOL  fChanged;
+    int   iNewSelection;
+    WCHAR[CBEMAXSTRLEN] szText;
+    int   iWhy;
+}
+alias NMCBEENDEDITW* LPNMCBEENDEDITW, PNMCBEENDEDITW;
+
+struct NMCBEENDEDITA {
+    NMHDR hdr;
+    BOOL  fChanged;
+    int   iNewSelection;
+    char[CBEMAXSTRLEN] szText;
+    int   iWhy;
+}
+alias NMCBEENDEDITA* LPNMCBEENDEDITA, PNMCBEENDEDITA;
+
+struct COLORMAP {
+    COLORREF from;
+    COLORREF to;
+}
+alias COLORMAP* LPCOLORMAP;
+
+struct DRAGLISTINFO {
+    UINT  uNotification;
+    HWND  hWnd;
+    POINT ptCursor;
+}
+alias DRAGLISTINFO* LPDRAGLISTINFO;
+
+struct TBBUTTON {
+    int   iBitmap;
+    int   idCommand;
+    BYTE  fsState;
+    BYTE  fsStyle;
+    version(Win64){
+        BYTE[6] bReserved;
+    } else {
+        BYTE[2] bReserved;
+    }
+    DWORD_PTR dwData;
+    INT_PTR iString;
+}
+alias TBBUTTON*        PTBBUTTON, LPTBBUTTON;
+alias const(TBBUTTON)* LPCTBBUTTON;
+
+static if (_WIN32_IE >= 0x400) {
+    struct TBBUTTONINFOA {
+        UINT  cbSize = TBBUTTONINFOA.sizeof;
+        DWORD dwMask;
+        int   idCommand;
+        int   iImage;
+        BYTE  fsState;
+        BYTE  fsStyle;
+        WORD  cx;
+        DWORD_PTR lParam;
+        LPSTR pszText;
+        int   cchText;
+    }
+    alias TBBUTTONINFOA* LPTBBUTTONINFOA;
+
+    struct TBBUTTONINFOW {
+        UINT   cbSize = TBBUTTONINFOW.sizeof;
+        DWORD  dwMask;
+        int    idCommand;
+        int    iImage;
+        BYTE   fsState;
+        BYTE   fsStyle;
+        WORD   cx;
+        DWORD_PTR lParam;
+        LPWSTR pszText;
+        int    cchText;
+    }
+    alias TBBUTTONINFOW* LPTBBUTTONINFOW;
+
+    struct TBINSERTMARK {
+        int   iButton;
+        DWORD dwFlags;
+    }
+    alias TBINSERTMARK* LPTBINSERTMARK;
+
+    struct LVBKIMAGEA {
+        ULONG   ulFlags;
+        HBITMAP hbm;
+        LPSTR   pszImage;
+        UINT    cchImageMax;
+        int     xOffsetPercent;
+        int     yOffsetPercent;
+    }
+    alias LVBKIMAGEA* LPLVBKIMAGEA;
+
+    struct LVBKIMAGEW {
+        ULONG   ulFlags;
+        HBITMAP hbm;
+        LPWSTR  pszImage;
+        UINT    cchImageMax;
+        int     xOffsetPercent;
+        int     yOffsetPercent;
+    }
+    alias LVBKIMAGEW* LPLVBKIMAGEW;
+}
+
+/*struct TBNOTIFY {
+    NMHDR    hdr;
+    int      iItem;
+    TBBUTTON tbButton;
+    int      cchText;
+    LPTSTR   pszText;
+}
+alias TBNOTIFY* LPTBNOTIFY;
+*/
+
+/*struct TBSAVEPARAMS {
+    HKEY    hkr;
+    LPCTSTR pszSubKey;
+    LPCTSTR pszValueName;
+}*/
+
+struct IMAGEINFO {
+    HBITMAP hbmImage;
+    HBITMAP hbmMask;
+    int     Unused1;
+    int     Unused2;
+    RECT    rcImage;
+}
+alias IMAGEINFO* LPIMAGEINFO;
+
+static if (_WIN32_IE >= 0x500) {
+    struct HDITEMA {
+        UINT    mask;
+        int     cxy;
+        LPSTR   pszText;
+        HBITMAP hbm;
+        int     cchTextMax;
+        int     fmt;
+        LPARAM  lParam;
+        int     iImage;
+        int     iOrder;
+        UINT    type;
+        LPVOID  pvFilter;
+    }
+
+    struct HDITEMW {
+        UINT    mask;
+        int     cxy;
+        LPWSTR  pszText;
+        HBITMAP hbm;
+        int     cchTextMax;
+        int     fmt;
+        LPARAM  lParam;
+        int     iImage;
+        int     iOrder;
+        UINT    type;
+        LPVOID  pvFilter;
+    }
+} else static if (_WIN32_IE >= 0x300) {
+    struct HDITEMA {
+        UINT    mask;
+        int     cxy;
+        LPSTR   pszText;
+        HBITMAP hbm;
+        int     cchTextMax;
+        int     fmt;
+        LPARAM  lParam;
+        int     iImage;
+        int     iOrder;
+    }
+
+    struct HDITEMW {
+        UINT    mask;
+        int     cxy;
+        LPWSTR  pszText;
+        HBITMAP hbm;
+        int     cchTextMax;
+        int     fmt;
+        LPARAM  lParam;
+        int     iImage;
+        int     iOrder;
+    }
+} else {
+    struct HDITEMA {
+        UINT    mask;
+        int     cxy;
+        LPSTR   pszText;
+        HBITMAP hbm;
+        int     cchTextMax;
+        int     fmt;
+        LPARAM  lParam;
+    }
+
+    struct HDITEMW {
+        UINT    mask;
+        int     cxy;
+        LPWSTR  pszText;
+        HBITMAP hbm;
+        int     cchTextMax;
+        int     fmt;
+        LPARAM  lParam;
+    }
+}
+alias HDITEMA* LPHDITEMA;
+alias HDITEMW* LPHDITEMW;
+
+deprecated {
+    alias HDITEMA HD_ITEMA;
+    alias HDITEMW HD_ITEMW;
+    //alias HDITEM HD_ITEM; fixme
+}
+
+struct HD_LAYOUT {
+    RECT*      prc;
+    WINDOWPOS* pwpos;
+}
+alias HD_LAYOUT* LPHDLAYOUT;
+deprecated alias HD_LAYOUT HDLAYOUT;
+
+struct HD_HITTESTINFO {
+    POINT pt;
+    UINT  flags;
+    int   iItem;
+}
+alias HD_HITTESTINFO* LPHDHITTESTINFO;
+
+struct HD_NOTIFYA {
+    NMHDR    hdr;
+    int      iItem;
+    int      iButton;
+    HDITEMA* pitem;
+}
+
+struct HD_NOTIFYW {
+    NMHDR    hdr;
+    int      iItem;
+    int      iButton;
+    HDITEMW* pitem;
+}
+
+/* FIXME: NMHEADER structure (base for all events of the comctl controls)
+   is the same as HD_NOTIFY depending on the value of _WIN32_IE macro.
+   I'm defining both for now. */
+struct NMHEADERA {
+    NMHDR    hdr;
+    int      iItem;
+    int      iButton;
+    HDITEMA* pitem;
+}
+alias NMHEADERA* LPNMHEADERA;
+
+struct NMHEADERW {
+    NMHDR    hdr;
+    int      iItem;
+    int      iButton;
+    HDITEMW* pitem;
+}
+alias NMHEADERW* LPNMHEADERW;
+
+version (Unicode) {
+    alias NMHEADERW NMHEADER;
+    alias LPNMHEADERW LPNMHEADER;
+} else {
+    alias NMHEADERA NMHEADER;
+    alias LPNMHEADERA LPNMHEADER;
+}
+// End FIXME
+
+struct NMHDDISPINFOA {
+    NMHDR  hdr;
+    int    iItem;
+    UINT   mask;
+    LPSTR  pszText;
+    int    cchTextMax;
+    int    iImage;
+    LPARAM lParam;
+}
+alias NMHDDISPINFOA* LPNMHDDISPINFOA;
+
+struct NMHDDISPINFOW {
+    NMHDR  hdr;
+    int    iItem;
+    UINT   mask;
+    LPWSTR pszText;
+    int    cchTextMax;
+    int    iImage;
+    LPARAM lParam;
+}
+alias NMHDDISPINFOW* LPNMHDDISPINFOW;
+
+struct NMCUSTOMDRAW {
+    NMHDR  hdr;
+    DWORD  dwDrawStage;
+    HDC    hdc;
+    RECT   rc;
+    DWORD  dwItemSpec;
+    UINT   uItemState;
+    LPARAM lItemlParam;
+}
+alias NMCUSTOMDRAW* LPNMCUSTOMDRAW;
+
+static if (_WIN32_IE >= 0x400) {
+    struct NMLVCUSTOMDRAW {
+        NMCUSTOMDRAW nmcd;
+        COLORREF     clrText;
+        COLORREF     clrTextBk;
+        int          iSubItem;
+    }
+} else {
+    struct NMLVCUSTOMDRAW {
+        NMCUSTOMDRAW nmcd;
+        COLORREF     clrText;
+        COLORREF     clrTextBk;
+    }
+}
+alias NMLVCUSTOMDRAW* LPNMLVCUSTOMDRAW;
+
+static if (_WIN32_IE >= 0x400) {
+    struct NMLVGETINFOTIPA {
+        NMHDR  hdr;
+        DWORD  dwFlags;
+        LPSTR  pszText;
+        int    cchTextMax;
+        int    iItem;
+        int    iSubItem;
+        LPARAM lParam;
+    }
+    alias NMLVGETINFOTIPA* LPNMLVGETINFOTIPA;
+
+    struct NMLVGETINFOTIPW {
+        NMHDR  hdr;
+        DWORD  dwFlags;
+        LPWSTR pszText;
+        int    cchTextMax;
+        int    iItem;
+        int    iSubItem;
+        LPARAM lParam;
+    }
+    alias NMLVGETINFOTIPW* LPNMLVGETINFOTIPW;
+}
+
+static if (_WIN32_IE >= 0x400) {
+    struct NMTVCUSTOMDRAW {
+        NMCUSTOMDRAW nmcd;
+        COLORREF     clrText;
+        COLORREF     clrTextBk;
+        int          iLevel;
+    }
+} else {
+    struct NMTVCUSTOMDRAW {
+        NMCUSTOMDRAW nmcd;
+        COLORREF     clrText;
+        COLORREF     clrTextBk;
+    }
+}
+alias NMTVCUSTOMDRAW* LPNMTVCUSTOMDRAW;
+
+static if (_WIN32_IE >= 0x400) {
+    static if (_WIN32_WINNT >= 0x501) {
+        struct NMTBCUSTOMDRAW {
+            NMCUSTOMDRAW nmcd;
+            HBRUSH       hbrMonoDither;
+            HBRUSH       hbrLines;
+            HPEN         hpenLines;
+            COLORREF     clrText;
+            COLORREF     clrMark;
+            COLORREF     clrTextHighlight;
+            COLORREF     clrBtnFace;
+            COLORREF     clrBtnHighlight;
+            COLORREF     clrHighlightHotTrack;
+            RECT         rcText;
+            int          nStringBkMode;
+            int          nHLStringBkMode;
+            int          iListGap;
+        }
+    } else {
+        struct NMTBCUSTOMDRAW {
+            NMCUSTOMDRAW nmcd;
+            HBRUSH       hbrMonoDither;
+            HBRUSH       hbrLines;
+            HPEN         hpenLines;
+            COLORREF     clrText;
+            COLORREF     clrMark;
+            COLORREF     clrTextHighlight;
+            COLORREF     clrBtnFace;
+            COLORREF     clrBtnHighlight;
+            COLORREF     clrHighlightHotTrack;
+            RECT         rcText;
+            int          nStringBkMode;
+            int          nHLStringBkMode;
+        }
+    }
+    alias NMTBCUSTOMDRAW* LPNMTBCUSTOMDRAW;
+
+    struct NMITEMACTIVATE {
+        NMHDR  hdr;
+        int    iItem;
+        int    iSubItem;
+        UINT   uNewState;
+        UINT   uOldState;
+        UINT   uChanged;
+        POINT  ptAction;
+        LPARAM lParam;
+        UINT   uKeyFlags;
+    }
+    alias NMITEMACTIVATE* LPNMITEMACTIVATE;
+}
+
+struct TBADDBITMAP {
+    HINSTANCE hInst;
+    UINT_PTR  nID;
+}
+alias TBADDBITMAP* LPTBADDBITMAP;
+
+struct TBSAVEPARAMSA {
+    HKEY   hkr;
+    LPCSTR pszSubKey;
+    LPCSTR pszValueName;
+}
+
+struct TBSAVEPARAMSW {
+    HKEY    hkr;
+    LPCWSTR pszSubKey;
+    LPCWSTR pszValueName;
+}
+
+struct TBREPLACEBITMAP {
+    HINSTANCE hInstOld;
+    UINT_PTR  nIDOld;
+    HINSTANCE hInstNew;
+    UINT_PTR  nIDNew;
+    int       nButtons;
+}
+alias TBREPLACEBITMAP* LPTBREPLACEBITMAP;
+
+static if (_WIN32_IE >= 0x500) {
+    struct NMTOOLBARA {
+        NMHDR    hdr;
+        int      iItem;
+        TBBUTTON tbButton;
+        int      cchText;
+        LPSTR    pszText;
+        RECT     rcButton;
+    }
+
+    struct NMTOOLBARW {
+        NMHDR    hdr;
+        int      iItem;
+        TBBUTTON tbButton;
+        int      cchText;
+        LPWSTR   pszText;
+        RECT     rcButton;
+    }
+} else {
+    struct NMTOOLBARA {
+        NMHDR    hdr;
+        int      iItem;
+        TBBUTTON tbButton;
+        int      cchText;
+        LPSTR    pszText;
+    }
+
+    struct NMTOOLBARW {
+        NMHDR    hdr;
+        int      iItem;
+        TBBUTTON tbButton;
+        int      cchText;
+        LPWSTR   pszText;
+    }
+}
+alias NMTOOLBARA* LPNMTOOLBARA;
+alias NMTOOLBARW* LPNMTOOLBARW;
+
+alias NMTOOLBARA TBNOTIFYA;
+alias LPNMTOOLBARA LPTBNOTIFYA;
+
+alias NMTOOLBARW TBNOTIFYW;
+alias LPNMTOOLBARW LPTBNOTIFYW;
+
+static if (_WIN32_WINNT >= 0x501) {
+    struct TOOLINFOA {
+        UINT      cbSize = TOOLINFOA.sizeof;
+        UINT      uFlags;
+        HWND      hwnd;
+        UINT_PTR  uId;
+        RECT      rect;
+        HINSTANCE hinst;
+        LPSTR     lpszText;
+        LPARAM    lParam;
+        void*     lpReserved;
+    }
+
+    struct TOOLINFOW {
+        UINT      cbSize = TOOLINFOW.sizeof;
+        UINT      uFlags;
+        HWND      hwnd;
+        UINT_PTR  uId;
+        RECT      rect;
+        HINSTANCE hinst;
+        LPWSTR    lpszText;
+        LPARAM    lParam;
+        void*     lpReserved;
+    }
+
+enum size_t
+        TTTOOLINFOA_V1_SIZE = TOOLINFOA.lParam.offsetof,
+        TTTOOLINFOW_V1_SIZE = TOOLINFOW.lParam.offsetof,
+        TTTOOLINFOA_V2_SIZE = TOOLINFOA.lpReserved.offsetof,
+        TTTOOLINFOW_V2_SIZE = TOOLINFOW.lpReserved.offsetof,
+        TTTOOLINFOA_V3_SIZE = TOOLINFOA.sizeof,
+        TTTOOLINFOW_V3_SIZE = TOOLINFOW.sizeof;
+} else static if (_WIN32_IE >= 0x300) {
+    struct TOOLINFOA {
+        UINT      cbSize = TOOLINFOA.sizeof;
+        UINT      uFlags;
+        HWND      hwnd;
+        UINT      uId;
+        RECT      rect;
+        HINSTANCE hinst;
+        LPSTR     lpszText;
+        LPARAM    lParam;
+    }
+
+    struct TOOLINFOW {
+        UINT      cbSize = TOOLINFOW.sizeof;
+        UINT      uFlags;
+        HWND      hwnd;
+        UINT      uId;
+        RECT      rect;
+        HINSTANCE hinst;
+        LPWSTR    lpszText;
+        LPARAM    lParam;
+    }
+
+enum size_t
+        TTTOOLINFOA_V1_SIZE = TOOLINFOA.lParam.offsetof,
+        TTTOOLINFOW_V1_SIZE = TOOLINFOW.lParam.offsetof,
+        TTTOOLINFOA_V2_SIZE = TOOLINFOA.sizeof,
+        TTTOOLINFOW_V2_SIZE = TOOLINFOW.sizeof;
+} else {
+    struct TOOLINFOA {
+        UINT      cbSize = TOOLINFOA.sizeof;
+        UINT      uFlags;
+        HWND      hwnd;
+        UINT      uId;
+        RECT      rect;
+        HINSTANCE hinst;
+        LPSTR     lpszText;
+    }
+
+    struct TOOLINFOW {
+        UINT      cbSize = TOOLINFOW.sizeof;
+        UINT      uFlags;
+        HWND      hwnd;
+        UINT      uId;
+        RECT      rect;
+        HINSTANCE hinst;
+        LPWSTR    lpszText;
+    }
+
+enum size_t
+        TTTOOLINFOA_V1_SIZE = TOOLINFOA.sizeof,
+        TTTOOLINFOW_V1_SIZE = TOOLINFOW.sizeof;
+}
+alias TOOLINFOA TTTOOLINFOA;
+alias TOOLINFOW TTTOOLINFOW;
+alias TTTOOLINFOA* LPTTTOOLINFOA, PTOOLINFOA, LPTOOLINFOA;
+alias TTTOOLINFOW* LPTTTOOLINFOW, PTOOLINFOW, LPTOOLINFOW;
+
+struct TTHITTESTINFOA {
+    HWND      hwnd;
+    POINT     pt;
+    TOOLINFOA ti;
+}
+alias TTHITTESTINFOA* LPTTHITTESTINFOA, LPHITTESTINFOA;
+
+struct TTHITTESTINFOW {
+    HWND      hwnd;
+    POINT     pt;
+    TOOLINFOW ti;
+}
+alias TTHITTESTINFOW* LPTTHITTESTINFOW, LPHITTESTINFOW;
+
+static if (_WIN32_IE >= 0x300) {
+    struct NMTTDISPINFOA {
+        NMHDR     hdr;
+        LPSTR     lpszText;
+        char[80]  szText;
+        HINSTANCE hinst;
+        UINT      uFlags;
+        LPARAM    lParam;
+    }
+
+    struct NMTTDISPINFOW {
+        NMHDR     hdr;
+        LPWSTR    lpszText;
+        WCHAR[80] szText;
+        HINSTANCE hinst;
+        UINT      uFlags;
+        LPARAM    lParam;
+    }
+} else {
+    struct NMTTDISPINFOA {
+        NMHDR     hdr;
+        LPSTR     lpszText;
+        char[80]  szText;
+        HINSTANCE hinst;
+        UINT      uFlags;
+    }
+
+    struct NMTTDISPINFOW {
+        NMHDR     hdr;
+        LPWSTR    lpszText;
+        WCHAR[80] szText;
+        HINSTANCE hinst;
+        UINT      uFlags;
+    }
+}
+alias NMTTDISPINFOA* LPNMTTDISPINFOA;
+alias NMTTDISPINFOW* LPNMTTDISPINFOW;
+alias NMTTDISPINFOA TOOLTIPTEXTA;
+alias LPNMTTDISPINFOA LPTOOLTIPTEXTA;
+alias NMTTDISPINFOW TOOLTIPTEXTW;
+alias LPNMTTDISPINFOW LPTOOLTIPTEXTW;
+
+struct UDACCEL {
+    UINT nSec;
+    UINT nInc;
+}
+alias UDACCEL* LPUDACCEL;
+
+struct NMUPDOWN {
+    NMHDR hdr;
+    int   iPos;
+    int   iDelta;
+}
+alias NMUPDOWN* LPNMUPDOWN;
+
+deprecated {
+    alias NMUPDOWN NM_UPDOWN;
+    alias LPNMUPDOWN LPNM_UPDOWN;
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    struct LVITEMA {
+        UINT   mask;
+        int    iItem;
+        int    iSubItem;
+        UINT   state;
+        UINT   stateMask;
+        LPSTR  pszText;
+        int    cchTextMax;
+        int    iImage;
+        LPARAM lParam;
+        int    iIndent;
+        int    iGroupId;
+        UINT   cColumns;
+        PUINT  puColumns;
+    }
+
+    struct LVITEMW {
+        UINT   mask;
+        int    iItem;
+        int    iSubItem;
+        UINT   state;
+        UINT   stateMask;
+        LPWSTR pszText;
+        int    cchTextMax;
+        int    iImage;
+        LPARAM lParam;
+        int    iIndent;
+        int    iGroupId;
+        UINT   cColumns;
+        PUINT  puColumns;
+    }
+} else static if (_WIN32_IE >= 0x300) {
+    struct LVITEMA {
+        UINT   mask;
+        int    iItem;
+        int    iSubItem;
+        UINT   state;
+        UINT   stateMask;
+        LPSTR  pszText;
+        int    cchTextMax;
+        int    iImage;
+        LPARAM lParam;
+        int    iIndent;
+    }
+
+    struct LVITEMW {
+        UINT   mask;
+        int    iItem;
+        int    iSubItem;
+        UINT   state;
+        UINT   stateMask;
+        LPWSTR pszText;
+        int    cchTextMax;
+        int    iImage;
+        LPARAM lParam;
+        int    iIndent;
+    }
+} else {
+    struct LVITEMA {
+        UINT   mask;
+        int    iItem;
+        int    iSubItem;
+        UINT   state;
+        UINT   stateMask;
+        LPSTR  pszText;
+        int    cchTextMax;
+        int    iImage;
+        LPARAM lParam;
+    }
+
+    struct LVITEMW {
+        UINT   mask;
+        int    iItem;
+        int    iSubItem;
+        UINT   state;
+        UINT   stateMask;
+        LPWSTR pszText;
+        int    cchTextMax;
+        int    iImage;
+        LPARAM lParam;
+    }
+}
+alias LVITEMA* LPLVITEMA;
+alias LVITEMW* LPLVITEMW;
+alias LVITEMA LV_ITEMA;
+alias LVITEMW LV_ITEMW;
+
+struct LVFINDINFOA {
+    UINT   flags;
+    LPCSTR psz;
+    LPARAM lParam;
+    POINT  pt;
+    UINT   vkDirection;
+}
+
+struct LVFINDINFOW {
+    UINT    flags;
+    LPCWSTR psz;
+    LPARAM  lParam;
+    POINT   pt;
+    UINT    vkDirection;
+}
+
+alias LVFINDINFOA* LPFINDINFOA;
+alias LVFINDINFOA LV_FINDINFOA;
+alias LVFINDINFOW* LPFINDINFOW;
+alias LVFINDINFOW LV_FINDINFOW;
+
+struct NMLVFINDITEMA {
+    NMHDR       hdr;
+    int         iStart;
+    LVFINDINFOA lvfi;
+}
+
+struct NMLVFINDITEMW {
+    NMHDR       hdr;
+    int         iStart;
+    LVFINDINFOW lvfi;
+}
+
+alias NMLVFINDITEMA* PNMLVFINDITEMA, LPNMLVFINDITEMA;
+alias NMLVFINDITEMW* PNMLVFINDITEMW, LPNMLVFINDITEMW;
+
+static if (_WIN32_IE >= 0x300) {
+    struct LVHITTESTINFO {
+        POINT pt;
+        UINT  flags;
+        int   iItem;
+        int   iSubItem;
+    }
+} else {
+    struct LVHITTESTINFO {
+        POINT pt;
+        UINT  flags;
+        int   iItem;
+    }
+}
+alias LVHITTESTINFO* LPLVHITTESTINFO;
+alias LVHITTESTINFO LV_HITTESTINFO;
+
+static if (_WIN32_IE >= 0x300) {
+    struct LVCOLUMNA {
+        UINT  mask;
+        int   fmt;
+        int   cx;
+        LPSTR pszText;
+        int   cchTextMax;
+        int   iSubItem;
+        int   iImage;
+        int   iOrder;
+    }
+    struct LVCOLUMNW {
+        UINT   mask;
+        int    fmt;
+        int    cx;
+        LPWSTR pszText;
+        int    cchTextMax;
+        int    iSubItem;
+        int    iImage;
+        int    iOrder;
+    }
+} else {
+    struct LVCOLUMNA {
+        UINT  mask;
+        int   fmt;
+        int   cx;
+        LPSTR pszText;
+        int   cchTextMax;
+        int   iSubItem;
+    }
+    struct LVCOLUMNW {
+        UINT   mask;
+        int    fmt;
+        int    cx;
+        LPWSTR pszText;
+        int    cchTextMax;
+        int    iSubItem;
+    }
+}
+alias LVCOLUMNA* LPLVCOLUMNA;
+alias LVCOLUMNW* LPLVCOLUMNW;
+alias LVCOLUMNA LV_COLUMNA;
+alias LVCOLUMNW LV_COLUMNW;
+
+static if (_WIN32_WINNT >= 0x501) {
+    /*  SG: The definitions in this static if block are from the MSDN docs.
+     *  They are not in MinGW, but nonetheless required for macros that are.
+     */
+    struct LVGROUP {
+        UINT    cbSize = LVGROUP.sizeof;
+        UINT    mask;
+        LPWSTR  pszHeader;
+        int     cchHeader;
+        LPWSTR  pszFooter;
+        int     cchFooter;
+        int     iGroupId;
+        UINT    stateMask;
+        UINT    state;
+        UINT    uAlign;
+        static if (_WIN32_WINNT >= 0x600) {
+            LPWSTR  pszSubtitle;
+            UINT    cchSubtitle;
+            LPWSTR  pszTask;
+            UINT    cchTask;
+            LPWSTR  pszDescriptionTop;
+            UINT    cchDescriptionTop;
+            LPWSTR  pszDescriptionBottom;
+            UINT    cchDescriptionBottom;
+            int     iTitleImage;
+            int     iExtendedImage;
+            int     iFirstItem;         // Read only
+            UINT    cItems;             // Read only
+            LPWSTR  pszSubsetTitle;     // NULL if group is not subset
+            UINT    cchSubsetTitle;
+        }
+    }
+    alias LVGROUP* PLVGROUP;
+
+    struct LVGROUPMETRICS {
+        UINT     cbSize = LVGROUPMETRICS.sizeof;
+        UINT     mask;
+        UINT     Left;
+        UINT     Top;
+        UINT     Right;
+        UINT     Bottom;
+        COLORREF crLeft;
+        COLORREF crTop;
+        COLORREF crRight;
+        COLORREF crBottom;
+        COLORREF crHeader;
+        COLORREF crFooter;
+    }
+    alias LVGROUPMETRICS* PLVGROUPMETRICS;
+
+    struct LVINSERTMARK {
+        UINT  cbSize = LVINSERTMARK.sizeof;
+        DWORD dwFlags;
+        int   iItem;
+        DWORD dwReserved;
+    }
+    alias LVINSERTMARK* PLVINSERTMARK;
+    alias LVINSERTMARK* LPLVINSERTMARK;
+
+    struct LVTILEINFO {
+        UINT     cbSize = LVTILEINFO.sizeof;
+        int      iItem;
+        UINT     cColumns;
+        PUINT    puColumns;
+        static if (_WIN32_WINNT >= 0x600) {
+            int* piColFmt;
+        }
+    }
+    alias LVTILEINFO* PLVTILEINFO;
+
+    struct LVTILEVIEWINFO {
+        UINT  cbSize = LVTILEVIEWINFO.sizeof;
+        DWORD dwMask;
+        DWORD dwFlags;
+        SIZE  sizeTile;
+        int   cLines;
+        RECT  rcLabelMargin;
+    }
+    alias LVTILEVIEWINFO* PLVTILEVIEWINFO;
+
+    struct LVINSERTGROUPSORTED {
+        PFNLVGROUPCOMPARE pfnGroupCompare;
+        LPVOID* pvData;
+        LVGROUP lvGroup;
+    }
+    alias LVINSERTGROUPSORTED* PLVINSERTGROUPSORTED;
+
+    alias int function(INT, INT, VOID*) PFNLVGROUPCOMPARE;
+
+    struct LVSETINFOTIP {
+        UINT    cbSize = LVSETINFOTIP.sizeof;
+        DWORD   dwFlags;
+        LPWSTR  pszText;
+        int     iItem;
+        int     iSubItem;
+        HBITMAP hbmp;
+    }
+    alias LVSETINFOTIP* PLVSETINFOTIP;
+
+    struct BUTTON_IMAGELIST {
+        HIMAGELIST himl;
+        RECT margin;
+        UINT uAlign;
+    }
+    alias BUTTON_IMAGELIST* PBUTTON_IMAGELIST;
+}
+
+static if (_WIN32_WINNT >= 0x600) {
+    struct LVITEMINDEX
+    {
+        int iItem;
+        int iGroup;
+    };
+    alias LVITEMINDEX* PLVITEMINDEX;
+
+    struct LVFOOTERINFO
+    {
+        UINT mask;
+        LPWSTR pszText;
+        int cchTextMax;
+        UINT cItems;
+    }
+    alias LVFOOTERINFO* LPLVFOOTERINFO;
+
+    struct LVFOOTERITEM
+    {
+        UINT mask;
+        int iItem;
+        LPWSTR pszText;
+        int cchTextMax;
+        UINT state;
+        UINT stateMask;
+    }
+    alias LVFOOTERITEM *LPLVFOOTERITEM;
+
+    alias UINT TVITEMPART;
+    enum {
+        TVGIPR_BUTTON  = 0x0001,
+    }
+}
+
+alias int function(LPARAM, LPARAM, LPARAM) PFNLVCOMPARE;
+
+struct NMLISTVIEW {
+    NMHDR  hdr;
+    int    iItem;
+    int    iSubItem;
+    UINT   uNewState;
+    UINT   uOldState;
+    UINT   uChanged;
+    POINT  ptAction;
+    LPARAM lParam;
+}
+alias NMLISTVIEW* LPNMLISTVIEW;
+
+deprecated {
+    alias NMLISTVIEW NM_LISTVIEW;
+    alias LPNMLISTVIEW LPNM_LISTVIEW;
+}
+
+struct NMLVDISPINFOA {
+    NMHDR    hdr;
+    LV_ITEMA item;
+}
+alias NMLVDISPINFOA* LPNMLVDISPINFOA;
+alias NMLVDISPINFOA LV_DISPINFOA;
+
+struct NMLVDISPINFOW {
+    NMHDR    hdr;
+    LV_ITEMW item;
+}
+alias NMLVDISPINFOW* LPNMLVDISPINFOW;
+alias NMLVDISPINFOW LV_DISPINFOW;
+
+struct LV_KEYDOWN {
+    NMHDR hdr;
+    WORD  wVKey;
+    UINT  flags;
+}
+
+struct NMLVCACHEHINT {
+    NMHDR hdr;
+    int   iFrom;
+    int   iTo;
+}
+alias NMLVCACHEHINT* LPNMLVCACHEHINT, PNM_CACHEHINT, LPNM_CACHEHINT;
+alias NMLVCACHEHINT NM_CACHEHINT;
+
+struct TVITEMA {
+    UINT      mask;
+    HTREEITEM hItem;
+    UINT      state;
+    UINT      stateMask;
+    LPSTR     pszText;
+    int       cchTextMax;
+    int       iImage;
+    int       iSelectedImage;
+    int       cChildren;
+    LPARAM    lParam;
+}
+alias TVITEMA* LPTVITEMA, LPTV_ITEMA;
+alias TVITEMA TV_ITEMA;
+
+struct TVITEMW {
+    UINT      mask;
+    HTREEITEM hItem;
+    UINT      state;
+    UINT      stateMask;
+    LPWSTR    pszText;
+    int       cchTextMax;
+    int       iImage;
+    int       iSelectedImage;
+    int       cChildren;
+    LPARAM    lParam;
+}
+alias TVITEMW* LPTVITEMW, LPTV_ITEMW;
+alias TVITEMW TV_ITEMW;
+
+static if (_WIN32_IE >= 0x400) {
+    struct TVITEMEXA {
+        UINT      mask;
+        HTREEITEM hItem;
+        UINT      state;
+        UINT      stateMask;
+        LPSTR     pszText;
+        int       cchTextMax;
+        int       iImage;
+        int       iSelectedImage;
+        int       cChildren;
+        LPARAM    lParam;
+        int       iIntegral;
+    }
+    alias TVITEMEXA* LPTVITEMEXA;
+
+    struct TVITEMEXW {
+        UINT      mask;
+        HTREEITEM hItem;
+        UINT      state;
+        UINT      stateMask;
+        LPWSTR    pszText;
+        int       cchTextMax;
+        int       iImage;
+        int       iSelectedImage;
+        int       cChildren;
+        LPARAM    lParam;
+        int       iIntegral;
+    }
+    alias TVITEMEXW* LPTVITEMEXW;
+}
+
+static if (_WIN32_IE >= 0x400) {
+    struct TVINSERTSTRUCTA {
+        HTREEITEM hParent;
+        HTREEITEM hInsertAfter;
+        union {
+            TVITEMEXA itemex;
+            TV_ITEMA  item;
+        }
+    }
+
+    struct TVINSERTSTRUCTW {
+        HTREEITEM hParent;
+        HTREEITEM hInsertAfter;
+        union {
+            TVITEMEXW itemex;
+            TV_ITEMW  item;
+        }
+    }
+} else {
+    struct TVINSERTSTRUCTA {
+        HTREEITEM hParent;
+        HTREEITEM hInsertAfter;
+        TV_ITEMA  item;
+    }
+
+    struct TVINSERTSTRUCTW {
+        HTREEITEM hParent;
+        HTREEITEM hInsertAfter;
+        TV_ITEMW  item;
+    }
+}
+alias TVINSERTSTRUCTA* LPTVINSERTSTRUCTA, LPTV_INSERTSTRUCTA;
+alias TVINSERTSTRUCTA TV_INSERTSTRUCTA;
+alias TVINSERTSTRUCTW* LPTVINSERTSTRUCTW, LPTV_INSERTSTRUCTW;
+alias TVINSERTSTRUCTW TV_INSERTSTRUCTW;
+
+struct TVHITTESTINFO {
+    POINT     pt;
+    UINT      flags;
+    HTREEITEM hItem;
+}
+alias TVHITTESTINFO* LPTVHITTESTINFO, LPTV_HITTESTINFO;
+alias TVHITTESTINFO TV_HITTESTINFO;
+
+static if (_WIN32_WINNT >= 0x600) {
+    struct TVGETITEMPARTRECTINFO {
+        HTREEITEM hti;
+        RECT*     prc;
+        TVITEMPART partID;
+    }
+}
+
+alias int function(LPARAM, LPARAM, LPARAM) PFNTVCOMPARE;
+struct TVSORTCB {
+    HTREEITEM    hParent;
+    PFNTVCOMPARE lpfnCompare;
+    LPARAM       lParam;
+}
+alias TVSORTCB* LPTVSORTCB, LPTV_SORTCB;
+alias TVSORTCB TV_SORTCB;
+
+struct NMTREEVIEWA {
+    NMHDR    hdr;
+    UINT     action;
+    TV_ITEMA itemOld;
+    TV_ITEMA itemNew;
+    POINT    ptDrag;
+}
+alias NMTREEVIEWA* LPNMTREEVIEWA, LPNM_TREEVIEWA;
+alias NMTREEVIEWA NM_TREEVIEWA;
+
+struct NMTREEVIEWW {
+    NMHDR    hdr;
+    UINT     action;
+    TV_ITEMW itemOld;
+    TV_ITEMW itemNew;
+    POINT    ptDrag;
+}
+alias NMTREEVIEWW* LPNMTREEVIEWW, LPNM_TREEVIEWW;
+alias NMTREEVIEWW NM_TREEVIEWW;
+
+struct NMTVDISPINFOA {
+    NMHDR   hdr;
+    TVITEMA item;
+}
+alias NMTVDISPINFOA* LPNMTVDISPINFOA;
+alias NMTVDISPINFOA TV_DISPINFOA;
+
+struct NMTVDISPINFOW {
+    NMHDR   hdr;
+    TVITEMW item;
+}
+alias NMTVDISPINFOW* LPNMTVDISPINFOW;
+alias NMTVDISPINFOW TV_DISPINFOW;
+
+static if (_WIN32_IE >= 0x400) {
+    struct NMTVGETINFOTIPA {
+        NMHDR     hdr;
+        LPSTR     pszText;
+        int       cchTextMax;
+        HTREEITEM hItem;
+        LPARAM    lParam;
+    }
+    alias NMTVGETINFOTIPA* LPNMTVGETINFOTIPA;
+
+    struct NMTVGETINFOTIPW {
+        NMHDR     hdr;
+        LPWSTR    pszText;
+        int       cchTextMax;
+        HTREEITEM hItem;
+        LPARAM    lParam;
+    }
+    alias NMTVGETINFOTIPW* LPNMTVGETINFOTIPW;
+}
+
+struct TV_KEYDOWN {
+    NMHDR hdr;
+    WORD  wVKey;
+    UINT  flags;
+}
+
+struct TC_ITEMHEADERA {
+    UINT  mask;
+    UINT  lpReserved1;
+    UINT  lpReserved2;
+    LPSTR pszText;
+    int   cchTextMax;
+    int   iImage;
+}
+
+struct TC_ITEMHEADERW {
+    UINT   mask;
+    UINT   lpReserved1;
+    UINT   lpReserved2;
+    LPWSTR pszText;
+    int    cchTextMax;
+    int    iImage;
+}
+
+static if (_WIN32_IE >= 0x300) {
+    struct TCITEMA {
+        UINT   mask;
+        DWORD  dwState;
+        DWORD  dwStateMask;
+        LPSTR  pszText;
+        int    cchTextMax;
+        int    iImage;
+        LPARAM lParam;
+    }
+
+    struct TCITEMW {
+        UINT   mask;
+        DWORD  dwState;
+        DWORD  dwStateMask;
+        LPWSTR pszText;
+        int    cchTextMax;
+        int    iImage;
+        LPARAM lParam;
+    }
+} else {
+    struct TCITEMA {
+        UINT   mask;
+        UINT   lpReserved1;
+        UINT   lpReserved2;
+        LPSTR  pszText;
+        int    cchTextMax;
+        int    iImage;
+        LPARAM lParam;
+    }
+
+    struct TCITEMW {
+        UINT   mask;
+        UINT   lpReserved1;
+        UINT   lpReserved2;
+        LPWSTR pszText;
+        int    cchTextMax;
+        int    iImage;
+        LPARAM lParam;
+    }
+}
+alias TCITEMA* LPTCITEMA;
+alias TCITEMA TC_ITEMA;
+alias TCITEMW* LPTCITEMW;
+alias TCITEMW TC_ITEMW;
+
+struct TCHITTESTINFO {
+    POINT pt;
+    UINT  flags;
+}
+alias TCHITTESTINFO* LPTCHITTESTINFO, LPTC_HITTESTINFO;
+alias TCHITTESTINFO TC_HITTESTINFO;
+
+struct TC_KEYDOWN {
+    NMHDR hdr;
+    WORD wVKey;
+    UINT flags;
+}
+
+static if (_WIN32_IE >= 0x300) {
+    struct INITCOMMONCONTROLSEX {
+        DWORD dwSize = INITCOMMONCONTROLSEX.sizeof;
+        DWORD dwICC;
+    }
+    alias INITCOMMONCONTROLSEX* LPINITCOMMONCONTROLSEX;
+}
+
+struct PBRANGE {
+    int iLow;
+    int iHigh;
+}
+alias PBRANGE* PPBRANGE;
+
+struct COLORSCHEME {
+    DWORD    dwSize = COLORSCHEME.sizeof;
+    COLORREF clrBtnHighlight;
+    COLORREF clrBtnShadow;
+}
+alias COLORSCHEME* LPCOLORSCHEME;
+
+struct MCHITTESTINFO {
+    UINT       cbSize = MCHITTESTINFO.sizeof;
+    POINT      pt;
+    UINT       uHit;
+    SYSTEMTIME st;
+}
+alias MCHITTESTINFO* PMCHITTESTINFO;
+
+alias DWORD MONTHDAYSTATE;
+alias MONTHDAYSTATE* LPMONTHDAYSTATE;
+
+struct NMDAYSTATE {
+    NMHDR           nmhdr;
+    SYSTEMTIME      stStart;
+    int             cDayState;
+    LPMONTHDAYSTATE prgDayState;
+}
+alias NMDAYSTATE* LPNMDAYSTATE;
+
+struct REBARINFO {
+    UINT       cbSize = REBARINFO.sizeof;
+    UINT       fMask;
+    HIMAGELIST himl;
+}
+alias REBARINFO* LPREBARINFO;
+
+static if (_WIN32_IE >= 0x400) {
+    struct REBARBANDINFOA {
+        UINT     cbSize = REBARBANDINFOA.sizeof;
+        UINT     fMask;
+        UINT     fStyle;
+        COLORREF clrFore;
+        COLORREF clrBack;
+        LPSTR    lpText;
+        UINT     cch;
+        int      iImage;
+        HWND     hwndChild;
+        UINT     cxMinChild;
+        UINT     cyMinChild;
+        UINT     cx;
+        HBITMAP  hbmBack;
+        UINT     wID;
+        UINT     cyChild;
+        UINT     cyMaxChild;
+        UINT     cyIntegral;
+        UINT     cxIdeal;
+        LPARAM   lParam;
+        UINT     cxHeader;
+    }
+
+    struct REBARBANDINFOW {
+        UINT     cbSize = REBARBANDINFOW.sizeof;
+        UINT     fMask;
+        UINT     fStyle;
+        COLORREF clrFore;
+        COLORREF clrBack;
+        LPWSTR   lpText;
+        UINT     cch;
+        int      iImage;
+        HWND     hwndChild;
+        UINT     cxMinChild;
+        UINT     cyMinChild;
+        UINT     cx;
+        HBITMAP  hbmBack;
+        UINT     wID;
+        UINT     cyChild;
+        UINT     cyMaxChild;
+        UINT     cyIntegral;
+        UINT     cxIdeal;
+        LPARAM   lParam;
+        UINT     cxHeader;
+    }
+
+    enum : size_t {
+        REBARBANDINFOA_V3_SIZE = REBARBANDINFOA.cyChild.offsetof,
+        REBARBANDINFOW_V3_SIZE = REBARBANDINFOW.cyChild.offsetof
+    }
+} else {
+    struct REBARBANDINFOA {
+        UINT     cbSize = REBARBANDINFOA.sizeof;
+        UINT     fMask;
+        UINT     fStyle;
+        COLORREF clrFore;
+        COLORREF clrBack;
+        LPSTR    lpText;
+        UINT     cch;
+        int      iImage;
+        HWND     hwndChild;
+        UINT     cxMinChild;
+        UINT     cyMinChild;
+        UINT     cx;
+        HBITMAP  hbmBack;
+        UINT     wID;
+    }
+
+    struct REBARBANDINFOW {
+        UINT     cbSize = REBARBANDINFOW.sizeof;
+        UINT     fMask;
+        UINT     fStyle;
+        COLORREF clrFore;
+        COLORREF clrBack;
+        LPWSTR   lpText;
+        UINT     cch;
+        int      iImage;
+        HWND     hwndChild;
+        UINT     cxMinChild;
+        UINT     cyMinChild;
+        UINT     cx;
+        HBITMAP  hbmBack;
+        UINT     wID;
+    }
+
+    enum : size_t {
+        REBARBANDINFOA_V3_SIZE = REBARBANDINFOA.sizeof,
+        REBARBANDINFOW_V3_SIZE = REBARBANDINFOW.sizeof
+    }
+}
+alias REBARBANDINFOA*        LPREBARBANDINFOA;
+alias const(REBARBANDINFOA)* LPCREBARBANDINFOA;
+alias REBARBANDINFOW*        LPREBARBANDINFOW;
+alias const(REBARBANDINFOW)* LPCREBARBANDINFOW;
+
+static if (_WIN32_IE >= 0x300) {
+    struct NMLVODSTATECHANGE {
+        NMHDR hdr;
+        int iFrom;
+        int iTo;
+        UINT uNewState;
+        UINT uOldState;
+    }
+    alias NMLVODSTATECHANGE* LPNMLVODSTATECHANGE;
+
+    static if (_WIN32_WINNT >= 0x501) {
+        struct IMAGELISTDRAWPARAMS {
+            DWORD      cbSize = IMAGELISTDRAWPARAMS.sizeof;
+            HIMAGELIST himl;
+            int        i;
+            HDC        hdcDst;
+            int        x;
+            int        y;
+            int        cx;
+            int        cy;
+            int        xBitmap;
+            int        yBitmap;
+            COLORREF   rgbBk;
+            COLORREF   rgbFg;
+            UINT       fStyle;
+            DWORD      dwRop;
+            DWORD      fState;
+            DWORD      Frame;
+            COLORREF   crEffect;
+        }
+    } else {
+        struct IMAGELISTDRAWPARAMS {
+            DWORD      cbSize = IMAGELISTDRAWPARAMS.sizeof;
+            HIMAGELIST himl;
+            int        i;
+            HDC        hdcDst;
+            int        x;
+            int        y;
+            int        cx;
+            int        cy;
+            int        xBitmap;
+            int        yBitmap;
+            COLORREF   rgbBk;
+            COLORREF   rgbFg;
+            UINT       fStyle;
+            DWORD      dwRop;
+        }
+    }
+    alias IMAGELISTDRAWPARAMS* LPIMAGELISTDRAWPARAMS;
+}
+
+static if (_WIN32_IE >= 0x400) {
+    struct NMREBARCHILDSIZE {
+        NMHDR hdr;
+        UINT  uBand;
+        UINT  wID;
+        RECT  rcChild;
+        RECT  rcBand;
+    }
+    alias NMREBARCHILDSIZE* LPNMREBARCHILDSIZE;
+
+    struct NMREBAR {
+        NMHDR  hdr;
+        DWORD  dwMask;
+        UINT   uBand;
+        UINT   fStyle;
+        UINT   wID;
+        LPARAM lParam;
+    }
+    alias NMREBAR* LPNMREBAR;
+
+    struct NMRBAUTOSIZE {
+        NMHDR hdr;
+        BOOL  fChanged;
+        RECT  rcTarget;
+        RECT  rcActual;
+    }
+    alias NMRBAUTOSIZE* LPNMRBAUTOSIZE;
+
+    static if (_WIN32_IE >= 0x500) {
+        struct NMREBARCHEVRON {
+            NMHDR  hdr;
+            UINT   uBand;
+            UINT   wID;
+            LPARAM lParam;
+            RECT   rc;
+            LPARAM lParamNM;
+        }
+        alias NMREBARCHEVRON* LPNMREBARCHEVRON;
+    }
+
+    struct RBHITTESTINFO {
+        POINT pt;
+        UINT  flags;
+        int   iBand;
+    }
+    alias RBHITTESTINFO* LPRBHITTESTINFO;
+}
+
+mixin DECLARE_HANDLE!("HDSA");
+mixin DECLARE_HANDLE!("HDPA");
+
+version (Unicode) {
+    alias HDITEMW HDITEM;
+    alias LPHDITEMW LPHDITEM;
+    alias TOOLINFOW TOOLINFO;
+    alias TOOLINFOW* PTOOLINFO, LPTOOLINFO;
+    alias TTHITTESTINFOW TTHITTESTINFO;
+    alias TTHITTESTINFOW* LPHITTESTINFO, LPTTHITTESTINFO;
+    alias TOOLTIPTEXTW TOOLTIPTEXT;
+    alias TOOLTIPTEXTW* LPTOOLTIPTEXT;
+    alias NMTTDISPINFOW NMTTDISPINFO;
+    alias NMTTDISPINFOW* LPNMTTDISPINFO;
+    alias TV_ITEMW TV_ITEM;
+    alias TV_ITEMW* LPTV_ITEM;
+    alias TVITEMW TVITEM;
+    alias TVITEMW* LPTVITEM;
+
+    static if (_WIN32_IE >= 0x400) {
+        alias TVITEMEXW TVITEMEX;
+        alias TVITEMEXW* LPTVITEMEX;
+    }
+
+    alias TV_INSERTSTRUCTW TV_INSERTSTRUCT;
+    alias TV_INSERTSTRUCTW* LPTV_INSERTSTRUCT;
+    alias TVINSERTSTRUCTW TVINSERTSTRUCT;
+    alias TVINSERTSTRUCTW* LPTVINSERTSTRUCT;
+    alias NM_TREEVIEWW NM_TREEVIEW;
+    alias NM_TREEVIEWW* LPNM_TREEVIEW;
+    alias NMTREEVIEWW NMTREEVIEW;
+    alias NMTREEVIEWW* LPNMTREEVIEW;
+    alias NMHDDISPINFOW NMHDDISPINFO;
+    alias NMHDDISPINFOW* LPNMHDDISPINFO;
+
+    alias ACM_OPENW ACM_OPEN;
+    alias COMBOBOXEXITEMW COMBOBOXEXITEM;
+    alias PCOMBOBOXEXITEMW PCOMBOBOXEXITEM;
+    //alias PCCOMBOBOXEXITEMW PCCOMBOBOXEXITEM; fixme
+    alias CBEM_INSERTITEMW CBEM_INSERTITEM;
+    alias CBEM_SETITEMW CBEM_SETITEM;
+    alias CBEM_GETITEMW CBEM_GETITEM;
+    alias CBEN_ENDEDITW CBEN_ENDEDIT;
+    alias NMCBEENDEDITW NMCBEENDEDIT;
+    alias LPNMCBEENDEDITW LPNMCBEENDEDIT;
+    alias PNMCBEENDEDITW PNMCBEENDEDIT;
+
+    static if (_WIN32_IE >= 0x400) {
+        alias NMCOMBOBOXEXW NMCOMBOBOXEX;
+        alias PNMCOMBOBOXEXW PNMCOMBOBOXEX;
+        alias CBEN_GETDISPINFOW CBEN_GETDISPINFO;
+        alias CBEN_DRAGBEGINW CBEN_DRAGBEGIN;
+        alias NMCBEDRAGBEGINW NMCBEDRAGBEGIN;
+        alias LPNMCBEDRAGBEGINW LPNMCBEDRAGBEGIN;
+        alias PNMCBEDRAGBEGINW PNMCBEDRAGBEGIN;
+    }
+
+    alias SB_GETTEXTW SB_GETTEXT;
+    alias SB_SETTEXTW SB_SETTEXT;
+    alias SB_GETTEXTLENGTHW SB_GETTEXTLENGTH;
+    alias HDM_INSERTITEMW HDM_INSERTITEM;
+    alias HDM_GETITEMW HDM_GETITEM;
+    alias HDM_SETITEMW HDM_SETITEM;
+    alias HDN_ITEMCHANGINGW HDN_ITEMCHANGING;
+    alias HDN_ITEMCHANGEDW HDN_ITEMCHANGED;
+    alias HDN_ITEMCLICKW HDN_ITEMCLICK;
+    alias HDN_ITEMDBLCLICKW HDN_ITEMDBLCLICK;
+    alias HDN_DIVIDERDBLCLICKW HDN_DIVIDERDBLCLICK;
+    alias HDN_BEGINTRACKW HDN_BEGINTRACK;
+    alias HDN_ENDTRACKW HDN_ENDTRACK;
+    alias HDN_TRACKW HDN_TRACK;
+
+    static if (_WIN32_IE >= 0x300) {
+        alias HDN_GETDISPINFOW HDN_GETDISPINFO;
+    }
+
+    alias HD_NOTIFYW HD_NOTIFY;
+    alias TBSAVEPARAMSW TBSAVEPARAMS;
+    alias TB_GETBUTTONTEXTW TB_GETBUTTONTEXT;
+    alias TB_SAVERESTOREW TB_SAVERESTORE;
+    alias TB_ADDSTRINGW TB_ADDSTRING;
+
+    static if (_WIN32_IE >= 0x400) {
+        alias TBN_GETBUTTONINFOW TBN_GETBUTTONINFO;  // fixme
+        alias TB_GETBUTTONINFOW TB_GETBUTTONINFO;
+        alias TB_SETBUTTONINFOW TB_SETBUTTONINFO;
+        alias TB_INSERTBUTTONW TB_INSERTBUTTON;
+        alias TB_ADDBUTTONSW TB_ADDBUTTONS;
+        alias TB_MAPACCELERATORW TB_MAPACCELERATOR;
+        alias TB_GETSTRINGW TB_GETSTRING;
+        alias TBBUTTONINFOW TBBUTTONINFO;
+        alias LPTBBUTTONINFOW LPTBBUTTONINFO;
+        alias TBN_GETDISPINFOW TBN_GETDISPINFO;
+        alias NMTBDISPINFOW NMTBDISPINFO;
+        alias LPNMTBDISPINFOW LPNMTBDISPINFO;
+        alias NMTBGETINFOTIPW NMTBGETINFOTIP;
+        alias LPNMTBGETINFOTIPW LPNMTBGETINFOTIP;
+    }
+
+    alias TBNOTIFYW TBNOTIFY;
+    alias LPTBNOTIFYW LPTBNOTIFY;
+    alias NMTOOLBARW NMTOOLBAR;
+    alias LPNMTOOLBARW LPNMTOOLBAR;
+    alias TTM_ADDTOOLW TTM_ADDTOOL;
+    alias TTM_DELTOOLW TTM_DELTOOL;
+    alias TTM_NEWTOOLRECTW TTM_NEWTOOLRECT;
+    alias TTM_GETTOOLINFOW TTM_GETTOOLINFO;
+    alias TTM_SETTOOLINFOW TTM_SETTOOLINFO;
+    alias TTM_HITTESTW TTM_HITTEST;
+    alias TTM_GETTEXTW TTM_GETTEXT;
+    alias TTM_UPDATETIPTEXTW TTM_UPDATETIPTEXT;
+    alias TTM_ENUMTOOLSW TTM_ENUMTOOLS;
+    alias TTM_GETCURRENTTOOLW TTM_GETCURRENTTOOL;
+    alias TTN_NEEDTEXTW TTN_NEEDTEXT;
+    alias TTN_GETDISPINFOW TTN_GETDISPINFO;
+    //alias SB_GETTEXTW SB_GETTEXT;
+    //alias SB_SETTEXTW SB_SETTEXT;
+    //alias SB_GETTEXTLENGTHW SB_GETTEXTLENGTH;
+    alias LV_ITEMW LV_ITEM;
+    alias LVITEMW LVITEM;
+    alias LVITEM* LPLVITEM;
+    alias LPSTR_TEXTCALLBACKW LPSTR_TEXTCALLBACK;
+
+    static if (_WIN32_IE >= 0x400) {
+        alias LVBKIMAGEW LVBKIMAGE;
+        alias LPLVBKIMAGEW LPLVBKIMAGE;
+        alias LVM_SETBKIMAGEW LVM_SETBKIMAGE;
+        alias LVM_GETBKIMAGEW LVM_GETBKIMAGE;
+    }
+
+    alias LVM_GETITEMW LVM_GETITEM;
+    alias LVM_SETITEMW LVM_SETITEM;
+    alias LVM_INSERTITEMW LVM_INSERTITEM;
+    alias LV_FINDINFOW LV_FINDINFO;
+    alias LVFINDINFOW LVFINDINFO;
+    alias LPFINDINFOW LPFINDINFO;
+    alias NMLVFINDITEMW NMLVFINDITEM;
+    alias PNMLVFINDITEMW PNMLVFINDITEM;
+    alias LPNMLVFINDITEMW LPNMLVFINDITEM;
+    alias LVM_FINDITEMW LVM_FINDITEM;
+    alias LVM_GETSTRINGWIDTHW LVM_GETSTRINGWIDTH;
+    alias LVM_EDITLABELW LVM_EDITLABEL;
+    alias LV_COLUMNW LV_COLUMN;
+    alias LVCOLUMNW LVCOLUMN;
+    alias LVCOLUMNW* LPLVCOLUMN;
+    alias LVM_GETCOLUMNW LVM_GETCOLUMN;
+    alias LVM_SETCOLUMNW LVM_SETCOLUMN;
+    alias LVM_INSERTCOLUMNW LVM_INSERTCOLUMN;
+    alias LVM_GETITEMTEXTW LVM_GETITEMTEXT;
+    alias LVM_SETITEMTEXTW LVM_SETITEMTEXT;
+    alias LVM_GETISEARCHSTRINGW LVM_GETISEARCHSTRING;
+    alias LVN_BEGINLABELEDITW LVN_BEGINLABELEDIT;
+    alias LVN_ENDLABELEDITW LVN_ENDLABELEDIT;
+    alias LVN_GETDISPINFOW LVN_GETDISPINFO;
+    alias LVN_SETDISPINFOW LVN_SETDISPINFO;
+
+    static if (_WIN32_IE >= 0x400) {
+        alias LVN_GETINFOTIPW LVN_GETINFOTIP;
+        alias NMLVGETINFOTIPW NMLVGETINFOTIP;
+        alias LPNMLVGETINFOTIPW LPNMLVGETINFOTIP;
+    }
+
+    alias LV_DISPINFOW LV_DISPINFO;
+    alias NMLVDISPINFOW NMLVDISPINFO;
+    alias LPNMLVDISPINFOW LPNMLVDISPINFO;
+    alias TVM_INSERTITEMW TVM_INSERTITEM;
+    alias TVM_GETITEMW TVM_GETITEM;
+    alias TVM_SETITEMW TVM_SETITEM;
+    alias TVM_EDITLABELW TVM_EDITLABEL;
+    alias TVM_GETISEARCHSTRINGW TVM_GETISEARCHSTRING;
+    alias NMTVDISPINFOW TV_DISPINFO;
+    alias NMTVDISPINFOW NMTVDISPINFO;
+    alias LPNMTVDISPINFOW LPNMTVDISPINFO;
+
+    static if (_WIN32_IE >= 0x400) {
+        alias NMTVGETINFOTIPW NMTVGETINFOTIP;
+        alias LPNMTVGETINFOTIPW LPNMTVGETINFOTIP;
+        alias TVN_GETINFOTIPW TVN_GETINFOTIP;
+    }
+
+    alias TVN_SELCHANGINGW TVN_SELCHANGING;
+    alias TVN_SELCHANGEDW TVN_SELCHANGED;
+    alias TVN_GETDISPINFOW TVN_GETDISPINFO;
+    alias TVN_SETDISPINFOW TVN_SETDISPINFO;
+    alias TVN_ITEMEXPANDINGW TVN_ITEMEXPANDING;
+    alias TVN_ITEMEXPANDEDW TVN_ITEMEXPANDED;
+    alias TVN_BEGINDRAGW TVN_BEGINDRAG;
+    alias TVN_BEGINRDRAGW TVN_BEGINRDRAG;
+    alias TVN_DELETEITEMW TVN_DELETEITEM;
+    alias TVN_BEGINLABELEDITW TVN_BEGINLABELEDIT;
+    alias TVN_ENDLABELEDITW TVN_ENDLABELEDIT;
+    alias TC_ITEMHEADERW TC_ITEMHEADER;
+    alias TC_ITEMW TC_ITEM;
+    alias TCITEMW TCITEM;
+    alias LPTCITEMW LPTCITEM;
+    alias TCM_GETITEMW TCM_GETITEM;
+    alias TCM_SETITEMW TCM_SETITEM;
+    alias TCM_INSERTITEMW TCM_INSERTITEM;
+    alias CreateStatusWindowW CreateStatusWindow;
+    alias DrawStatusTextW DrawStatusText;
+    alias ImageList_LoadImageW ImageList_LoadImage;
+    alias DTM_SETFORMATW DTM_SETFORMAT;
+    alias DTN_USERSTRINGW DTN_USERSTRING;
+    alias DTN_WMKEYDOWNW DTN_WMKEYDOWN;
+    alias DTN_FORMATW DTN_FORMAT;
+    alias DTN_FORMATQUERYW DTN_FORMATQUERY;
+    alias REBARBANDINFOW REBARBANDINFO;
+    alias REBARBANDINFO* LPREBARBANDINFO;
+    alias LPCREBARBANDINFOW LPCREBARBANDINFO;
+    alias REBARBANDINFOW_V3_SIZE REBARBANDINFO_V3_SIZE;
+    alias RB_INSERTBANDW RB_INSERTBAND;
+    alias RB_SETBANDINFOW RB_SETBANDINFO;
+} else {
+    alias HDITEMA HDITEM;
+    alias LPHDITEMA LPHDITEM;
+    alias TOOLINFOA TOOLINFO;
+    alias TOOLINFOA* PTOOLINFO, LPTOOLINFO;
+    alias TTHITTESTINFOA TTHITTESTINFO;
+    alias TTHITTESTINFOA* LPHITTESTINFO, LPTTHITTESTINFO;
+    alias TOOLTIPTEXTA TOOLTIPTEXT;
+    alias TOOLTIPTEXTA* LPTOOLTIPTEXT;
+    alias NMTTDISPINFOA NMTTDISPINFO;
+    alias NMTTDISPINFOA* LPNMTTDISPINFO;
+    alias TV_ITEMA TV_ITEM;
+    alias TV_ITEMA* LPTV_ITEM;
+    alias TVITEMA TVITEM;
+    alias TVITEMA* LPTVITEM;
+
+    static if (_WIN32_IE >= 0x400) {
+        alias TVITEMEXA TVITEMEX;
+        alias TVITEMEXA* LPTVITEMEX;
+    }
+
+    alias TV_INSERTSTRUCTA TV_INSERTSTRUCT;
+    alias TV_INSERTSTRUCTA* LPTV_INSERTSTRUCT;
+    alias TVINSERTSTRUCTA TVINSERTSTRUCT;
+    alias TVINSERTSTRUCTA* LPTVINSERTSTRUCT;
+    alias NM_TREEVIEWA NM_TREEVIEW;
+    alias NM_TREEVIEWA* LPNM_TREEVIEW;
+    alias NMTREEVIEWA NMTREEVIEW;
+    alias NMTREEVIEWA* LPNMTREEVIEW;
+    alias NMHDDISPINFOW NMHDDISPINFO;
+    alias NMHDDISPINFOW* LPNMHDDISPINFO;
+
+    alias ACM_OPENA ACM_OPEN;
+    alias COMBOBOXEXITEMA COMBOBOXEXITEM;
+    alias PCOMBOBOXEXITEMA PCOMBOBOXEXITEM;
+    //alias PCCOMBOBOXEXITEMA PCCOMBOBOXEXITEM; fixme
+    alias CBEM_INSERTITEMA CBEM_INSERTITEM;
+    alias CBEM_SETITEMA CBEM_SETITEM;
+    alias CBEM_GETITEMA CBEM_GETITEM;
+    alias CBEN_ENDEDITA CBEN_ENDEDIT;
+    alias NMCBEENDEDITA NMCBEENDEDIT;
+    alias LPNMCBEENDEDITA LPNMCBEENDEDIT;
+    alias PNMCBEENDEDITA PNMCBEENDEDIT;
+
+    static if (_WIN32_IE >= 0x400) {
+        alias TB_GETBUTTONINFOA TB_GETBUTTONINFO;
+        alias TB_SETBUTTONINFOA TB_SETBUTTONINFO;
+        alias TB_INSERTBUTTONA TB_INSERTBUTTON;
+        alias TB_ADDBUTTONSA TB_ADDBUTTONS;
+        alias TB_MAPACCELERATORA TB_MAPACCELERATOR;
+        alias TB_GETSTRINGA TB_GETSTRING;
+        alias NMCOMBOBOXEXA NMCOMBOBOXEX;
+        alias PNMCOMBOBOXEXA PNMCOMBOBOXEX;
+        alias CBEN_DRAGBEGINA CBEN_DRAGBEGIN;
+        alias CBEN_GETDISPINFOA CBEN_GETDISPINFO;
+        alias NMCBEDRAGBEGINA NMCBEDRAGBEGIN;
+        alias LPNMCBEDRAGBEGINA LPNMCBEDRAGBEGIN;
+        alias PNMCBEDRAGBEGINA PNMCBEDRAGBEGIN;
+        alias TBN_GETDISPINFOA TBN_GETDISPINFO;
+        alias NMTBDISPINFOA NMTBDISPINFO;
+        alias LPNMTBDISPINFOA LPNMTBDISPINFO;
+        alias NMTBGETINFOTIPA NMTBGETINFOTIP;
+        alias LPNMTBGETINFOTIPA LPNMTBGETINFOTIP;
+    }
+
+    alias SB_GETTEXTA SB_GETTEXT;
+    alias SB_SETTEXTA SB_SETTEXT;
+    alias SB_GETTEXTLENGTHA SB_GETTEXTLENGTH;
+    alias HDM_INSERTITEMA HDM_INSERTITEM;
+    alias HDM_GETITEMA HDM_GETITEM;
+    alias HDM_SETITEMA HDM_SETITEM;
+    alias HDN_ITEMCHANGINGA HDN_ITEMCHANGING;
+    alias HDN_ITEMCHANGEDA HDN_ITEMCHANGED;
+    alias HDN_ITEMCLICKA HDN_ITEMCLICK;
+    alias HDN_ITEMDBLCLICKA HDN_ITEMDBLCLICK;
+    alias HDN_DIVIDERDBLCLICKA HDN_DIVIDERDBLCLICK;
+    alias HDN_BEGINTRACKA HDN_BEGINTRACK;
+    alias HDN_ENDTRACKA HDN_ENDTRACK;
+    alias HDN_TRACKA HDN_TRACK;
+
+    static if (_WIN32_IE >= 0x300) {
+        alias HDN_GETDISPINFOA HDN_GETDISPINFO;
+    }
+
+    alias HD_NOTIFYA HD_NOTIFY;
+    alias TBSAVEPARAMSA TBSAVEPARAMS;
+    alias TB_GETBUTTONTEXTA TB_GETBUTTONTEXT;
+    alias TB_SAVERESTOREA TB_SAVERESTORE;
+    alias TB_ADDSTRINGA TB_ADDSTRING;
+    alias TBN_GETBUTTONINFOA TBN_GETBUTTONINFO;
+
+    static if (_WIN32_IE >= 0x400) {
+        alias TBBUTTONINFOA TBBUTTONINFO;
+        alias LPTBBUTTONINFOA LPTBBUTTONINFO;
+    }
+
+    alias TBNOTIFYA TBNOTIFY;
+    alias LPTBNOTIFYA LPTBNOTIFY;
+    alias NMTOOLBARA NMTOOLBAR;
+    alias LPNMTOOLBARA LPNMTOOLBAR;
+    alias TTM_ADDTOOLA TTM_ADDTOOL;
+    alias TTM_DELTOOLA TTM_DELTOOL;
+    alias TTM_NEWTOOLRECTA TTM_NEWTOOLRECT;
+    alias TTM_GETTOOLINFOA TTM_GETTOOLINFO;
+    alias TTM_SETTOOLINFOA TTM_SETTOOLINFO;
+    alias TTM_HITTESTA TTM_HITTEST;
+    alias TTM_GETTEXTA TTM_GETTEXT;
+    alias TTM_UPDATETIPTEXTA TTM_UPDATETIPTEXT;
+    alias TTM_ENUMTOOLSA TTM_ENUMTOOLS;
+    alias TTM_GETCURRENTTOOLA TTM_GETCURRENTTOOL;
+    alias TTN_NEEDTEXTA TTN_NEEDTEXT;
+    alias TTN_GETDISPINFOA TTN_GETDISPINFO;
+    alias LV_ITEMA LV_ITEM;
+    alias LVITEMA LVITEM;
+    alias LVITEM* LPLVITEM;
+    alias LPSTR_TEXTCALLBACKA LPSTR_TEXTCALLBACK;
+
+    static if (_WIN32_IE >= 0x400) {
+        alias LVBKIMAGEA LVBKIMAGE;
+        alias LPLVBKIMAGEA LPLVBKIMAGE;
+        alias LVM_SETBKIMAGEA LVM_SETBKIMAGE;
+        alias LVM_GETBKIMAGEA LVM_GETBKIMAGE;
+    }
+
+    alias LVM_GETITEMA LVM_GETITEM;
+    alias LVM_SETITEMA LVM_SETITEM;
+    alias LVM_INSERTITEMA LVM_INSERTITEM;
+    alias LV_FINDINFOA LV_FINDINFO;
+    alias LVFINDINFOA LVFINDINFO;
+    alias LPFINDINFOA LPFINDINFO;
+    alias NMLVFINDITEMA NMLVFINDITEM;
+    alias PNMLVFINDITEMA PNMLVFINDITEM;
+    alias LPNMLVFINDITEMA LPNMLVFINDITEM;
+    alias LVM_FINDITEMA LVM_FINDITEM;
+    alias LVM_GETSTRINGWIDTHA LVM_GETSTRINGWIDTH;
+    alias LVM_EDITLABELA LVM_EDITLABEL;
+    alias LV_COLUMNA LV_COLUMN;
+    alias LVCOLUMNA LVCOLUMN;
+    alias LVCOLUMNA* LPLVCOLUMN;
+    alias LVM_GETCOLUMNA LVM_GETCOLUMN;
+    alias LVM_SETCOLUMNA LVM_SETCOLUMN;
+    alias LVM_INSERTCOLUMNA LVM_INSERTCOLUMN;
+    alias LVM_GETITEMTEXTA LVM_GETITEMTEXT;
+    alias LVM_SETITEMTEXTA LVM_SETITEMTEXT;
+    alias LVM_GETISEARCHSTRINGA LVM_GETISEARCHSTRING;
+    alias LVN_BEGINLABELEDITA LVN_BEGINLABELEDIT;
+    alias LVN_ENDLABELEDITA LVN_ENDLABELEDIT;
+    alias LVN_GETDISPINFOA LVN_GETDISPINFO;
+    alias LVN_SETDISPINFOA LVN_SETDISPINFO;
+
+    static if (_WIN32_IE >= 0x400) {
+        alias LVN_GETINFOTIPA LVN_GETINFOTIP;
+        alias NMLVGETINFOTIPA NMLVGETINFOTIP;
+        alias LPNMLVGETINFOTIPA LPNMLVGETINFOTIP;
+    }
+
+    alias LV_DISPINFOA LV_DISPINFO;
+    alias NMLVDISPINFOA NMLVDISPINFO;
+    alias LPNMLVDISPINFOA LPNMLVDISPINFO;
+    alias TVM_INSERTITEMA TVM_INSERTITEM;
+    alias TVM_GETITEMA TVM_GETITEM;
+    alias TVM_SETITEMA TVM_SETITEM;
+    alias TVM_EDITLABELA TVM_EDITLABEL;
+    alias TVM_GETISEARCHSTRINGA TVM_GETISEARCHSTRING;
+    alias NMTVDISPINFOA TV_DISPINFO;
+    alias NMTVDISPINFOA NMTVDISPINFO;
+    alias LPNMTVDISPINFOA LPNMTVDISPINFO;
+
+    static if (_WIN32_IE >= 0x400) {
+        alias NMTVGETINFOTIPA NMTVGETINFOTIP;
+        alias LPNMTVGETINFOTIPA LPNMTVGETINFOTIP;
+        alias TVN_GETINFOTIPA TVN_GETINFOTIP;
+    }
+
+    alias TVN_SELCHANGINGA TVN_SELCHANGING;
+    alias TVN_SELCHANGEDA TVN_SELCHANGED;
+    alias TVN_GETDISPINFOA TVN_GETDISPINFO;
+    alias TVN_SETDISPINFOA TVN_SETDISPINFO;
+    alias TVN_ITEMEXPANDINGA TVN_ITEMEXPANDING;
+    alias TVN_ITEMEXPANDEDA TVN_ITEMEXPANDED;
+    alias TVN_BEGINDRAGA TVN_BEGINDRAG;
+    alias TVN_BEGINRDRAGA TVN_BEGINRDRAG;
+    alias TVN_DELETEITEMA TVN_DELETEITEM;
+    alias TVN_BEGINLABELEDITA TVN_BEGINLABELEDIT;
+    alias TVN_ENDLABELEDITA TVN_ENDLABELEDIT;
+    alias TC_ITEMHEADERA TC_ITEMHEADER;
+    alias TC_ITEMA TC_ITEM;
+    alias TCITEMA TCITEM;
+    alias LPTCITEMA LPTCITEM;
+    alias TCM_GETITEMA TCM_GETITEM;
+    alias TCM_SETITEMA TCM_SETITEM;
+    alias TCM_INSERTITEMA TCM_INSERTITEM;
+    alias CreateStatusWindowA CreateStatusWindow;
+    alias DrawStatusTextA DrawStatusText;
+    alias ImageList_LoadImageA ImageList_LoadImage;
+    alias DTM_SETFORMATA DTM_SETFORMAT;
+    alias DTN_USERSTRINGA DTN_USERSTRING;
+    alias DTN_WMKEYDOWNA DTN_WMKEYDOWN;
+    alias DTN_FORMATA DTN_FORMAT;
+    alias DTN_FORMATQUERYA DTN_FORMATQUERY;
+    alias REBARBANDINFOA REBARBANDINFO;
+    alias REBARBANDINFOA* LPREBARBANDINFO;
+    alias LPCREBARBANDINFOA LPCREBARBANDINFO;
+    alias REBARBANDINFOA_V3_SIZE REBARBANDINFO_V3_SIZE;
+    alias RB_INSERTBANDA RB_INSERTBAND;
+    alias RB_SETBANDINFOA RB_SETBANDINFO;
+}
+
+
+alias INT function(PVOID, PVOID) PFNDPAENUMCALLBACK;
+alias INT function(PVOID, PVOID) PFNDSAENUMCALLBACK;
+alias INT function(PVOID, PVOID, LPARAM) PFNDPACOMPARE;
+
+static if (_WIN32_WINNT >= 0x501) {
+    extern (Windows)
+    alias LRESULT function(HWND, UINT, WPARAM, LPARAM, UINT_PTR, DWORD_PTR)
+      SUBCLASSPROC;
+
+    struct LITEM {
+        UINT mask;
+        int  iLink;
+        UINT state;
+        UINT stateMask;
+        WCHAR[MAX_LINKID_TEXT]  szID;
+        WCHAR[L_MAX_URL_LENGTH] szUrl;
+    }
+    alias LITEM* PLITEM;
+
+    struct LHITTESTINFO {
+        POINT pt;
+        LITEM item;
+    }
+    alias LHITTESTINFO* PLHITTESTINFO;
+
+    struct NMLINK {
+        NMHDR hdr;
+        LITEM item;
+    }
+    alias NMLINK* PNMLINK;
+}
+
+uint INDEXTOOVERLAYMASK(uint i) { return i << 8; }
+uint INDEXTOSTATEIMAGEMASK(uint i) { return i << 12; }
+
+template HANDLE_WM_NOTIFY(R) {
+    R HANDLE_WM_NOTIFY(HWND hwnd, WPARAM wParam, LPARAM lParam,
+          R function(HWND, int, NMHDR*) fn) {
+        return fn(hwnd, wParam, cast(NMHDR*) lParam);
+    }
+}
+int FORWARD_WM_NOTIFY(HWND hwnd, int idFrom, NMHDR* pnmhdr,
+      int function(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) fn) {
+    return fn(hwnd, WM_NOTIFY, idFrom, cast(LPARAM) pnmhdr);
+}
+
+//#define CCSIZEOF_STRUCT(s, m) (((int)((PBYTE)(&((s*)0)->m)-((PBYTE)((s*)0))))+sizeof(((s*)0)->m))
+
+LPARAM MAKEIPADDRESS(ubyte b1, ubyte b2, ubyte b3, ubyte b4) {
+    return (cast(DWORD) b1 << 24)
+         | (cast(DWORD) b2 << 16)
+         | (cast(DWORD) b3 << 8)
+         | (cast(DWORD) b4);
+}
+
+LPARAM MAKEIPRANGE(ubyte low, ubyte high) {
+    return (cast(int) high << 8) | low;
+}
+
+ubyte FIRST_IPADDRESS(LPARAM x) {
+    return cast(ubyte) (x >> 24);
+}
+
+ubyte SECOND_IPADDRESS(LPARAM x) {
+    return cast(ubyte) (x >> 16);
+}
+
+ubyte THIRD_IPADDRESS(LPARAM x) {
+    return cast(ubyte) (x >> 8);
+}
+
+ubyte FOURTH_IPADDRESS(LPARAM x) {
+    return cast(ubyte) x;
+}
+
+HWND Animate_Create(HWND hwndP, UINT id, DWORD dwStyle,
+      HINSTANCE hInstance) {
+    return CreateWindow(cast(TCHAR*)ANIMATE_CLASS.ptr, null, dwStyle, 0, 0, 0, 0, hwndP,
+      cast(HMENU) id, hInstance, null);
+}
+
+BOOL Animate_Open(HWND hwnd, LPTSTR szName) {
+    return cast(BOOL) SendMessage(hwnd, ACM_OPEN, 0, cast(LPARAM) szName);
+}
+
+BOOL Animate_OpenEx(HWND hwnd, HINSTANCE hInst, LPTSTR szName) {
+    return cast(BOOL) SendMessage(hwnd, ACM_OPEN, cast(WPARAM) hInst,
+      cast(LPARAM) szName);
+}
+
+BOOL Animate_Play(HWND hwnd, int from, int to, int rep) {
+    return cast(BOOL) SendMessage(hwnd, ACM_PLAY, rep,
+      MAKELONG(cast(ushort) from, cast(ushort) to));
+}
+
+BOOL Animate_Stop(HWND hwnd) {
+    return cast(BOOL) SendMessage(hwnd, ACM_STOP, 0, 0);
+}
+
+BOOL Animate_Close(HWND hwnd) {
+    return Animate_Open(hwnd, null);
+}
+
+BOOL Animate_Seek(HWND hwnd, int frame) {
+    return Animate_Play(hwnd, frame, frame, 1);
+}
+
+extern (Windows) {
+    HBITMAP CreateMappedBitmap(HINSTANCE, INT_PTR, UINT, LPCOLORMAP, int);
+    HWND CreateStatusWindowA(LONG, LPCSTR, HWND, UINT);
+    HWND CreateStatusWindowW(LONG, LPCWSTR, HWND, UINT);
+    HWND CreateToolbarEx(HWND, DWORD, UINT, int, HINSTANCE, UINT_PTR,
+      LPCTBBUTTON, int, int, int, int, int, UINT);
+    HWND CreateUpDownControl(DWORD, int, int, int, int, HWND, int, HINSTANCE,
+      HWND, int, int, int);
+}
+
+HWND DateTime_GetMonthCal(HWND hwnd) {
+    return cast(HWND) SendMessage(hwnd, DTM_GETMONTHCAL, 0, 0);
+}
+
+COLORREF DateTime_GetMonthCalColor(HWND hwnd, int iColor) {
+    return cast(COLORREF) SendMessage(hwnd, DTM_GETMCCOLOR, iColor, 0);
+}
+
+HFONT DateTime_GetMonthCalFont(HWND hwnd) {
+    return cast(HFONT) SendMessage(hwnd, DTM_GETMCFONT, 0, 0);
+}
+
+DWORD DateTime_GetRange(HWND hwnd, LPSYSTEMTIME lpSysTimeArray) {
+    return cast(DWORD) SendMessage(hwnd, DTM_GETRANGE, 0, cast(LPARAM) lpSysTimeArray);
+}
+
+DWORD DateTime_GetSystemtime(HWND hwnd, LPSYSTEMTIME lpSysTime) {
+    return cast(DWORD) SendMessage(hwnd, DTM_GETSYSTEMTIME, 0, cast(LPARAM) lpSysTime);
+}
+
+BOOL DateTime_SetFormat(HWND hwnd, LPCTSTR lpszFormat) {
+    return cast(BOOL) SendMessage(hwnd, DTM_SETFORMAT, 0,
+      cast(LPARAM) lpszFormat);
+}
+
+LRESULT DateTime_SetMonthCalColor(HWND hwnd, int iColor, COLORREF clr) {
+    return SendMessage(hwnd, DTM_SETMCCOLOR, cast(WPARAM) iColor,
+      cast(LPARAM) clr);
+}
+
+void DateTime_SetMonthCalFont(HWND hwnd, HFONT hfont, BOOL fRedraw) {
+    SendMessage(hwnd, DTM_SETMCFONT, cast(WPARAM) hfont, fRedraw);
+}
+
+BOOL DateTime_SetRange(HWND hwnd, WPARAM flags, LPSYSTEMTIME lpSysTimeArray) {
+    return cast(BOOL) SendMessage(hwnd, DTM_SETRANGE, flags,
+      cast(LPARAM) lpSysTimeArray);
+}
+
+BOOL DateTime_SetSystemtime(HWND hwnd, WPARAM flag, LPSYSTEMTIME lpSysTime) {
+    return cast(BOOL) SendMessage(hwnd, DTM_SETSYSTEMTIME, flag,
+      cast(LPARAM) lpSysTime);
+}
+
+extern (Windows) {
+    void DrawInsert(HWND, HWND, int);
+    void DrawStatusTextA(HDC, LPRECT, LPCSTR, UINT);
+    void DrawStatusTextW(HDC, LPRECT, LPCWSTR, UINT);
+    void GetEffectiveClientRect(HWND, LPRECT, LPINT);
+}
+
+int Header_GetItemCount(HWND w) {
+    return cast(int) SendMessage(w, HDM_GETITEMCOUNT, 0, 0);
+}
+
+int Header_InsertItem(HWND w, int i, const(HDITEM)* phdi) {
+    return cast(int) SendMessage(w, HDM_INSERTITEM, i, cast(LPARAM) phdi);
+}
+
+BOOL Header_DeleteItem(HWND w, int i) {
+    return cast(BOOL) SendMessage(w, HDM_DELETEITEM, i, 0);
+}
+
+BOOL Header_GetItem(HWND w, int i, LPHDITEM phdi) {
+    return cast(BOOL) SendMessage(w, HDM_GETITEM, i, cast(LPARAM) phdi);
+}
+
+BOOL Header_SetItem(HWND w, int i, const(HDITEM)* phdi) {
+    return cast(BOOL) SendMessage(w, HDM_SETITEM, i, cast(LPARAM) phdi);
+}
+
+BOOL Header_Layout(HWND w, LPHDLAYOUT playout) {
+    return cast(BOOL) SendMessage(w, HDM_LAYOUT, 0, cast(LPARAM) playout);
+}
+
+static if (_WIN32_IE >= 0x300) {
+    int Header_OrderToIndex(HWND w, int i) {
+        return cast(int) SendMessage(w, HDM_ORDERTOINDEX, i, 0);
+    }
+
+    BOOL Header_GetItemRect(HWND w, int i, RECT* r) {
+        return cast(BOOL) SendMessage(w, HDM_GETITEMRECT, i, cast(LPARAM) r);
+    }
+
+    BOOL Header_GetOrderArray(HWND w, int iSize, LPINT lpiArray) {
+        return cast(BOOL) SendMessage(w, HDM_GETORDERARRAY, iSize,
+          cast(LPARAM) lpiArray);
+    }
+
+    BOOL Header_SetOrderArray(HWND w, int iSize, LPINT lpiArray) {
+        return cast(BOOL) SendMessage(w, HDM_SETORDERARRAY, iSize,
+          cast(LPARAM) lpiArray);
+    }
+
+    HIMAGELIST Header_CreateDragImage(HWND w, int i) {
+        return cast(HIMAGELIST) SendMessage(w, HDM_CREATEDRAGIMAGE, i, 0);
+    }
+
+    HIMAGELIST Header_SetImageList(HWND w, HIMAGELIST himl) {
+        return cast(HIMAGELIST) SendMessage(w, HDM_SETIMAGELIST, 0,
+          cast(LPARAM) himl);
+    }
+
+    HIMAGELIST Header_GetImageList(HWND w) {
+        return cast(HIMAGELIST) SendMessage(w, HDM_GETIMAGELIST, 0, 0);
+    }
+}
+
+static if (_WIN32_IE >= 0x400) {
+    BOOL Header_GetUnicodeFormat(HWND w) {
+        return cast(BOOL) SendMessage(w, HDM_GETUNICODEFORMAT, 0, 0);
+    }
+
+    BOOL Header_SetUnicodeFormat(HWND w, BOOL fUnicode) {
+        return cast(BOOL) SendMessage(w, HDM_SETUNICODEFORMAT, fUnicode, 0);
+    }
+}
+
+extern (Windows) {
+    HDSA DSA_Create(INT, INT);
+    BOOL DSA_Destroy(HDSA);
+    VOID DSA_DestroyCallback(HDSA, PFNDSAENUMCALLBACK, PVOID);
+    PVOID DSA_GetItemPtr(HDSA, INT);
+    INT DSA_InsertItem(HDSA, INT, PVOID);
+    HDPA DPA_Create(INT);
+    BOOL DPA_Destroy(HDPA);
+    PVOID DPA_DeletePtr(HDPA, INT);
+    BOOL DPA_DeleteAllPtrs(HDPA);
+    VOID DPA_EnumCallback(HDPA, PFNDPAENUMCALLBACK, PVOID);
+    VOID DPA_DestroyCallback(HDPA, PFNDPAENUMCALLBACK, PVOID);
+    BOOL DPA_SetPtr(HDPA, INT, PVOID);
+    INT DPA_InsertPtr(HDPA, INT, PVOID);
+    PVOID DPA_GetPtr(HDPA, INT_PTR);
+    BOOL DPA_Sort(HDPA, PFNDPACOMPARE, LPARAM);
+    INT DPA_Search(HDPA, PVOID, INT, PFNDPACOMPARE, LPARAM, UINT);
+    BOOL Str_SetPtrW(LPWSTR*, LPCWSTR);
+
+    static if (_WIN32_IE >= 0x400) {
+        BOOL FlatSB_EnableScrollBar(HWND, INT, UINT);
+        BOOL FlatSB_ShowScrollBar(HWND, INT, BOOL);
+        BOOL FlatSB_GetScrollRange(HWND, INT, LPINT, LPINT);
+        BOOL FlatSB_GetScrollInfo(HWND, INT, LPSCROLLINFO);
+        INT FlatSB_GetScrollPos(HWND, INT);
+        BOOL FlatSB_GetScrollProp(HWND, INT, LPINT);
+        version (Win64) {
+            BOOL FlatSB_GetScrollPropPtr(HWND, INT, PINT_PTR);
+        } else {
+            alias FlatSB_GetScrollProp FlatSB_GetScrollPropPtr;
+        }
+        INT FlatSB_SetScrollPos(HWND, INT, INT, BOOL);
+        INT FlatSB_SetScrollInfo(HWND, INT, LPSCROLLINFO, BOOL);
+        INT FlatSB_SetScrollRange(HWND, INT, INT, INT, BOOL);
+        BOOL FlatSB_SetScrollProp(HWND, UINT, INT_PTR, BOOL);
+        alias FlatSB_SetScrollProp FlatSB_SetScrollPropPtr;
+        BOOL InitializeFlatSB(HWND);
+        HRESULT UninitializeFlatSB(HWND);
+    }
+
+    static if (_WIN32_WINNT >= 0x501) {
+        BOOL SetWindowSubclass(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR);
+        BOOL GetWindowSubclass(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR*);
+        BOOL RemoveWindowSubclass(HWND, SUBCLASSPROC, UINT_PTR);
+        LRESULT DefSubclassProc(HWND, UINT, WPARAM, LPARAM);
+        INT DrawShadowText(HDC, LPCWSTR, UINT, RECT*, DWORD, COLORREF,
+          COLORREF, INT, INT);
+    }
+
+    int ImageList_Add(HIMAGELIST, HBITMAP, HBITMAP);
+    int ImageList_AddMasked(HIMAGELIST, HBITMAP, COLORREF);
+    BOOL ImageList_BeginDrag(HIMAGELIST, int, int, int);
+    HIMAGELIST ImageList_Create(int, int, UINT, int, int);
+    BOOL ImageList_Destroy(HIMAGELIST);
+    BOOL ImageList_DragEnter(HWND, int, int);
+    BOOL ImageList_DragLeave(HWND);
+    BOOL ImageList_DragMove(int, int);
+    BOOL ImageList_DragShowNolock(BOOL);
+    BOOL ImageList_Draw(HIMAGELIST, int, HDC, int, int, UINT);
+    BOOL ImageList_DrawEx(HIMAGELIST, int, HDC, int, int, int, int, COLORREF,
+      COLORREF, UINT);
+    void ImageList_EndDrag();
+    COLORREF ImageList_GetBkColor(HIMAGELIST);
+    HIMAGELIST ImageList_GetDragImage(LPPOINT, LPPOINT);
+    HICON ImageList_GetIcon(HIMAGELIST, int, UINT);
+    BOOL ImageList_GetIconSize(HIMAGELIST, int*, int*);
+    int ImageList_GetImageCount(HIMAGELIST);
+    BOOL ImageList_GetImageInfo(HIMAGELIST, int, IMAGEINFO*);
+    HIMAGELIST ImageList_LoadImageA(HINSTANCE, LPCSTR, int, int, COLORREF,
+      UINT, UINT);
+    HIMAGELIST ImageList_LoadImageW(HINSTANCE, LPCWSTR, int, int, COLORREF,
+      UINT, UINT);
+    HIMAGELIST ImageList_Merge(HIMAGELIST, int, HIMAGELIST, int, int, int);
+    BOOL ImageList_Remove(HIMAGELIST, int);
+    BOOL ImageList_Replace(HIMAGELIST, int, HBITMAP, HBITMAP);
+    int ImageList_ReplaceIcon(HIMAGELIST, int, HICON);
+    COLORREF ImageList_SetBkColor(HIMAGELIST, COLORREF);
+    BOOL ImageList_SetDragCursorImage(HIMAGELIST, int, int, int);
+    BOOL ImageList_SetIconSize(HIMAGELIST, int, int);
+    BOOL ImageList_SetOverlayImage(HIMAGELIST, int, int);
+
+    //#ifdef _OBJIDL_H
+    HIMAGELIST ImageList_Read(LPSTREAM);
+    BOOL ImageList_Write(HIMAGELIST, LPSTREAM);
+    //#endif
+
+    static if (_WIN32_IE >= 0x400) {
+        HIMAGELIST ImageList_Duplicate(HIMAGELIST himl);
+    }
+
+    void InitCommonControls();
+
+    static if (_WIN32_IE >= 0x300) {
+        BOOL InitCommonControlsEx(LPINITCOMMONCONTROLSEX);
+    }
+
+    int LBItemFromPt(HWND, POINT, BOOL);
+}
+
+int ImageList_AddIcon(HIMAGELIST himl, HICON hicon) {
+    return ImageList_ReplaceIcon(himl, -1, hicon);
+}
+
+HICON ImageList_ExtractIcon(HINSTANCE hi, HIMAGELIST himl, int i) {
+    return ImageList_GetIcon(himl, i, 0);
+}
+
+HIMAGELIST ImageList_LoadBitmap(HINSTANCE hi, LPCTSTR lpbmp, int cx,
+      int cGrow, COLORREF crMask) {
+    return ImageList_LoadImage(hi, lpbmp, cx, cGrow, crMask, IMAGE_BITMAP, 0);
+}
+
+BOOL ImageList_RemoveAll(HIMAGELIST himl) {
+    return ImageList_Remove(himl, -1);
+}
+
+COLORREF ListView_GetBkColor(HWND w) {
+    return cast(COLORREF) SendMessage(w, LVM_GETBKCOLOR, 0, 0);
+}
+
+HIMAGELIST ListView_GetImageList(HWND w, int i) {
+    return cast(HIMAGELIST) SendMessage(w, LVM_GETIMAGELIST, i, 0);
+}
+
+int ListView_GetItemCount(HWND w) {
+    return cast(int) SendMessage(w, LVM_GETITEMCOUNT, 0, 0);
+}
+
+BOOL ListView_GetItem(HWND w, LPLVITEM pitem) {
+    return cast(BOOL) SendMessage(w, LVM_GETITEM, 0, cast(LPARAM) pitem);
+}
+
+BOOL ListView_SetBkColor(HWND w, COLORREF c) {
+    return cast(BOOL) SendMessage(w, LVM_SETBKCOLOR, 0, cast(LPARAM) c);
+}
+
+HIMAGELIST ListView_SetImageList(HWND w, HIMAGELIST h, int i) {
+    return cast(HIMAGELIST) SendMessage(w, LVM_SETIMAGELIST, i,
+      cast(LPARAM) h);
+}
+
+BOOL ListView_SetItem(HWND w, const(LV_ITEM)* i) {
+    return cast(BOOL) SendMessage(w, LVM_SETITEM, 0, cast(LPARAM) i);
+}
+
+int ListView_InsertItem(HWND w, const(LV_ITEM)* i) {
+    return cast(int) SendMessage(w, LVM_INSERTITEM, 0, cast(LPARAM) i);
+}
+
+BOOL ListView_DeleteItem(HWND w, int i) {
+    return cast(BOOL) SendMessage(w, LVM_DELETEITEM, i, 0);
+}
+
+BOOL ListView_DeleteAllItems(HWND w) {
+    return cast(BOOL) SendMessage(w, LVM_DELETEALLITEMS, 0, 0);
+}
+
+UINT ListView_GetCallbackMask(HWND w) {
+    return cast(UINT) SendMessage(w, LVM_GETCALLBACKMASK, 0, 0);
+}
+
+BOOL ListView_SetCallbackMask(HWND w, UINT m) {
+    return cast(BOOL) SendMessage(w, LVM_SETCALLBACKMASK, m, 0);
+}
+
+int ListView_GetNextItem(HWND w, int i, UINT f) {
+    return cast(int) SendMessage(w, LVM_GETNEXTITEM, i, MAKELPARAM(cast(ushort)f, 0));
+}
+
+int ListView_FindItem(HWND w, int i, const(LV_FINDINFO)* p) {
+    return cast(int) SendMessage(w, LVM_FINDITEM, i, cast(LPARAM) p);
+}
+
+BOOL ListView_GetItemRect(HWND w, int i, LPRECT p, int c) {
+    return cast(BOOL) SendMessage(w, LVM_GETITEMRECT, i, p ?
+      (p.left = c, cast(LPARAM) p) : 0);
+}
+
+BOOL ListView_SetItemPosition(HWND w, int i, int x, int y) {
+    return cast(BOOL) SendMessage(w, LVM_SETITEMPOSITION, i, MAKELPARAM(cast(ushort)x, cast(ushort)y));
+}
+
+BOOL ListView_GetItemPosition(HWND w, int i, POINT* p) {
+    return cast(BOOL) SendMessage(w, LVM_GETITEMPOSITION, i, cast(LPARAM) p);
+}
+
+DWORD ListView_GetItemSpacing(HWND w, BOOL f) {
+    return cast(DWORD) SendMessage(w, LVM_GETITEMSPACING, f, 0);
+}
+
+int ListView_GetStringWidth(HWND w, LPCSTR s) {
+    return cast(int) SendMessage(w, LVM_GETSTRINGWIDTH, 0, cast(LPARAM) s);
+}
+
+int ListView_HitTest(HWND w, LPLVHITTESTINFO p) {
+    return cast(int) SendMessage(w, LVM_HITTEST, 0, cast(LPARAM) p);
+}
+
+BOOL ListView_EnsureVisible(HWND w, int i, BOOL f) {
+    return cast(BOOL) SendMessage(w, LVM_ENSUREVISIBLE, i, MAKELPARAM(cast(ushort)f, 0));
+}
+
+BOOL ListView_Scroll(HWND w, int dx, int dy) {
+    return cast(BOOL) SendMessage(w, LVM_SCROLL, dx, dy);
+}
+
+BOOL ListView_RedrawItems(HWND w, int f, int l) {
+    return cast(BOOL) SendMessage(w, LVM_REDRAWITEMS, f, l);
+}
+
+BOOL ListView_Arrange(HWND w, UINT c) {
+    return cast(BOOL) SendMessage(w, LVM_ARRANGE, c, 0);
+}
+
+HWND ListView_EditLabel(HWND w, int i) {
+    return cast(HWND) SendMessage(w, LVM_EDITLABEL, i, 0);
+}
+
+HWND ListView_GetEditControl(HWND w) {
+    return cast(HWND) SendMessage(w, LVM_GETEDITCONTROL, 0, 0);
+}
+
+BOOL ListView_GetColumn(HWND w, int i, LPLVCOLUMN p) {
+    return cast(BOOL) SendMessage(w, LVM_GETCOLUMN, i, cast(LPARAM) p);
+}
+
+BOOL ListView_SetColumn(HWND w, int i, const(LV_COLUMN)* p) {
+    return cast(BOOL) SendMessage(w, LVM_SETCOLUMN, i, cast(LPARAM) p);
+}
+
+int ListView_InsertColumn(HWND w, int i, const(LV_COLUMN)* p) {
+    return cast(int) SendMessage(w, LVM_INSERTCOLUMN, i, cast(LPARAM) p);
+}
+
+BOOL ListView_DeleteColumn(HWND w, int i) {
+    return cast(BOOL) SendMessage(w, LVM_DELETECOLUMN, i, 0);
+}
+
+int ListView_GetColumnWidth(HWND w, int i) {
+    return cast(int) SendMessage(w, LVM_GETCOLUMNWIDTH, i, 0);
+}
+
+BOOL ListView_SetColumnWidth(HWND w, int i, int x) {
+    return cast(BOOL) SendMessage(w, LVM_SETCOLUMNWIDTH, i, MAKELPARAM(cast(ushort)x, 0));
+}
+
+HIMAGELIST ListView_CreateDragImage(HWND w, int i, LPPOINT p) {
+    return cast(HIMAGELIST) SendMessage(w, LVM_CREATEDRAGIMAGE, i,
+      cast(LPARAM) p);
+}
+
+BOOL ListView_GetViewRect(HWND w, RECT* p) {
+    return cast(BOOL) SendMessage(w, LVM_GETVIEWRECT, 0, cast(LPARAM) p);
+}
+
+COLORREF ListView_GetTextColor(HWND w) {
+    return cast(COLORREF) SendMessage(w, LVM_GETTEXTCOLOR, 0, 0);
+}
+
+BOOL ListView_SetTextColor(HWND w, COLORREF c) {
+    return cast(BOOL) SendMessage(w, LVM_SETTEXTCOLOR, 0, cast(LPARAM) c);
+}
+
+COLORREF ListView_GetTextBkColor(HWND w) {
+    return cast(COLORREF) SendMessage(w, LVM_GETTEXTBKCOLOR, 0, 0);
+}
+
+BOOL ListView_SetTextBkColor(HWND w, COLORREF c) {
+    return cast(BOOL) SendMessage(w, LVM_SETTEXTBKCOLOR, 0, cast(LPARAM) c);
+}
+
+int ListView_GetTopIndex(HWND w) {
+    return cast(int) SendMessage(w, LVM_GETTOPINDEX, 0, 0);
+}
+
+int ListView_GetCountPerPage(HWND w) {
+    return cast(int) SendMessage(w, LVM_GETCOUNTPERPAGE, 0, 0);
+}
+
+BOOL ListView_GetOrigin(HWND w, LPPOINT p) {
+    return cast(BOOL) SendMessage(w, LVM_GETORIGIN, 0, cast(LPARAM) p);
+}
+
+BOOL ListView_Update(HWND w, WPARAM i) {
+    return cast(BOOL) SendMessage(w, LVM_UPDATE, i, 0);
+}
+
+void ListView_SetItemState(HWND w, int i, UINT d, UINT m) {
+    LV_ITEM _lvi;
+    _lvi.stateMask = m;
+    _lvi.state = d;
+    SendMessage(w, LVM_SETITEMSTATE, i, cast(LPARAM) &_lvi);
+}
+
+UINT ListView_GetItemState(HWND w, int i, UINT m) {
+    return cast(UINT) SendMessage(w, LVM_GETITEMSTATE, i, m);
+}
+
+void ListView_GetItemText(HWND w, int i, int iS, LPTSTR s, int n) {
+    LV_ITEM _lvi;
+    _lvi.iSubItem = iS;
+    _lvi.cchTextMax = n;
+    _lvi.pszText = s;
+    SendMessage(w, LVM_GETITEMTEXT, i, cast(LPARAM) &_lvi);
+}
+
+void ListView_SetItemText(HWND w, int i, int iS, LPTSTR s) {
+    LV_ITEM _lvi;
+    _lvi.iSubItem = iS;
+    _lvi.pszText = s;
+    SendMessage(w, LVM_SETITEMTEXT, i, cast(LPARAM) &_lvi);
+}
+
+void ListView_SetItemCount(HWND w, int n) {
+    SendMessage(w, LVM_SETITEMCOUNT, n, 0);
+}
+
+BOOL ListView_SortItems(HWND w, PFNLVCOMPARE f, LPARAM l) {
+    return cast(BOOL) SendMessage(w, LVM_SORTITEMS, l, cast(LPARAM) f);
+}
+
+void ListView_SetItemPosition32(HWND w, int i, int x, int y) {
+    POINT p;
+    p.x = x;
+    p.y = y;
+    SendMessage(w, LVM_SETITEMPOSITION32, i, cast(LPARAM) &p);
+}
+
+UINT ListView_GetSelectedCount(HWND w) {
+    return cast(UINT) SendMessage(w, LVM_GETSELECTEDCOUNT, 0, 0);
+}
+
+UINT ListView_GetCheckState(HWND w, UINT i) {
+    return ((cast(UINT) SendMessage(w, LVM_GETITEMSTATE, i, LVIS_STATEIMAGEMASK)) >> 12) - 1;
+}
+
+void ListView_SetCheckState(HWND w, UINT i, BOOL f) {
+    ListView_SetItemState(w, i, INDEXTOSTATEIMAGEMASK(f ? 2 : 1),
+      LVIS_STATEIMAGEMASK);
+}
+
+BOOL ListView_GetISearchString(HWND w, LPSTR lpsz) {
+    return cast(BOOL) SendMessage(w, LVM_GETISEARCHSTRING, 0,
+      cast(LPARAM) lpsz);
+}
+
+void ListView_CancelEditLabel(HWND w) {
+    SendMessage(w, LVM_CANCELEDITLABEL, 0, 0);
+}
+
+int ListView_EnableGroupView(HWND w, BOOL i) {
+    return cast(int) SendMessage(w, LVM_ENABLEGROUPVIEW, i, 0);
+}
+
+//static if (_WIN32_WINNT >= 0x500 || _WIN32_IE >= 0x500) {
+    BOOL ListView_SortItemsEx(HWND w, PFNLVCOMPARE c, LPARAM p) {
+        return cast(BOOL) SendMessage(w, LVM_SORTITEMSEX, cast(WPARAM) p, cast(LPARAM)c);
+    }
+//}
+
+static if (_WIN32_WINNT >= 0x501) {
+    int ListView_GetGroupInfo(HWND w, int i, PLVGROUP p) {
+        return cast(int) SendMessage(w, LVM_GETGROUPINFO, i, cast(LPARAM) p);
+    }
+
+    void ListView_GetGroupMetrics(HWND w, PLVGROUPMETRICS p) {
+        SendMessage(w, LVM_GETGROUPMETRICS, 0, cast(LPARAM) p);
+    }
+
+    BOOL ListView_GetInsertMark(HWND w, PLVINSERTMARK p) {
+        return cast(BOOL) SendMessage(w, LVM_GETINSERTMARK, 0, cast(LPARAM) p);
+    }
+
+    COLORREF ListView_GetInsertMarkColor(HWND w) {
+        return cast(COLORREF) SendMessage(w, LVM_GETINSERTMARKCOLOR, 0, 0);
+    }
+
+    int ListView_GetInsertMarkRect(HWND w, LPRECT p) {
+        return cast(int) SendMessage(w, LVM_GETINSERTMARKRECT, 0, cast(LPARAM) p);
+    }
+
+    COLORREF ListView_GetOutlineColor(HWND w) {
+        return cast(COLORREF) SendMessage(w, LVM_GETOUTLINECOLOR, 0, 0);
+    }
+
+    UINT ListView_GetSelectedColumn(HWND w) {
+        return cast(UINT) SendMessage(w, LVM_GETSELECTEDCOLUMN, 0, 0);
+    }
+
+    void ListView_GetTileInfo(HWND w, PLVTILEINFO p) {
+        SendMessage(w, LVM_GETTILEINFO, 0, cast(LPARAM) p);
+    }
+
+    void ListView_GetTileViewInfo(HWND w, PLVTILEVIEWINFO p) {
+        SendMessage(w, LVM_GETTILEVIEWINFO, 0, cast(LPARAM) p);
+    }
+
+    DWORD ListView_GetView(HWND w) {
+        return cast(DWORD) SendMessage(w, LVM_GETVIEW, 0, 0);
+    }
+
+    BOOL ListView_HasGroup(HWND w, int i) {
+        return cast(BOOL) SendMessage(w, LVM_HASGROUP, i, 0);
+    }
+
+    int ListView_InsertGroup(HWND w, int i, PLVGROUP p) {
+        return cast(int) SendMessage(w, LVM_INSERTGROUP, i, cast(LPARAM) p);
+    }
+
+    void ListView_InsertGroupSorted(HWND w, PLVINSERTGROUPSORTED p) {
+        SendMessage(w, LVM_INSERTGROUPSORTED, cast(WPARAM) p, 0);
+    }
+
+    BOOL ListView_InsertMarkHitTest(HWND w, LPPOINT p, PLVINSERTMARK t) {
+        return cast(BOOL) SendMessage(w, LVM_INSERTMARKHITTEST, cast(WPARAM) p, cast(LPARAM) t);
+    }
+
+    BOOL ListView_IsGroupViewEnabled(HWND w) {
+        return cast(BOOL) SendMessage(w, LVM_ISGROUPVIEWENABLED, 0, 0);
+    }
+
+    UINT ListView_MapIDToIndex(HWND w, UINT i) {
+        return cast(UINT) SendMessage(w, LVM_MAPIDTOINDEX, i, 0);
+    }
+
+    /*  ??? MSDN documents this as "Not implemented", except in relation to
+     *  Windows CE/Mobile.
+     */
+    void ListView_MoveGroup(HWND w, int i, int t) {
+        SendMessage(w, LVM_MOVEGROUP, i, t);
+    }
+
+    void ListView_RemoveAllGroups(HWND w) {
+        SendMessage(w, LVM_REMOVEALLGROUPS, 0, 0);
+    }
+
+    int ListView_RemoveGroup(HWND w, int i) {
+        return cast(int) SendMessage(w, LVM_REMOVEGROUP, i, 0);
+    }
+
+    int ListView_SetGroupInfo(HWND w, int i, PLVGROUP p) {
+        return cast(int) SendMessage(w, LVM_SETGROUPINFO, i, cast(LPARAM) p);
+    }
+
+    void ListView_SetGroupMetrics(HWND w, PLVGROUPMETRICS p) {
+        SendMessage(w, LVM_SETGROUPMETRICS, 0, cast(LPARAM) p);
+    }
+
+    BOOL ListView_SetInfoTip(HWND w, PLVSETINFOTIP p) {
+        return cast(BOOL) SendMessage(w, LVM_SETINFOTIP, 0, cast(LPARAM) p);
+    }
+
+    BOOL ListView_SetInsertMark(HWND w, PLVINSERTMARK p) {
+        return cast(BOOL) SendMessage(w, LVM_SETINSERTMARK, 0, cast(LPARAM) p);
+    }
+
+    COLORREF ListView_SetInsertMarkColor(HWND w, COLORREF c) {
+        return cast(COLORREF) SendMessage(w, LVM_SETINSERTMARKCOLOR, 0, c);
+    }
+
+    COLORREF ListView_SetOutlineColor(HWND w, COLORREF c) {
+        return cast(COLORREF) SendMessage(w, LVM_SETOUTLINECOLOR, 0, c);
+    }
+
+    void ListView_SetSelectedColumn(HWND w, int i) {
+        SendMessage(w, LVM_SETSELECTEDCOLUMN, i, 0);
+    }
+
+    BOOL ListView_SetTileInfo(HWND w, PLVTILEINFO p) {
+        return cast(BOOL) SendMessage(w, LVM_SETTILEINFO, 0, cast(LPARAM) p);
+    }
+
+    BOOL ListView_SetTileViewInfo(HWND w, PLVTILEVIEWINFO p) {
+        return cast(BOOL) SendMessage(w, LVM_SETTILEVIEWINFO, 0, cast(LPARAM) p);
+    }
+
+    int ListView_SetView(HWND w, DWORD i) {
+        return cast(int) SendMessage(w, LVM_SETVIEW, i, 0);
+    }
+
+    int ListView_SortGroups(HWND w, PFNLVGROUPCOMPARE c, LPVOID p) {
+        return cast(int) SendMessage(w, LVM_SORTGROUPS, cast(WPARAM) c, cast(LPARAM) p);
+    }
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        CBM_FIRST        = 0x1700,
+        CB_SETMINVISIBLE = CBM_FIRST + 1,
+        CB_GETMINVISIBLE = CBM_FIRST + 2,
+        CB_SETCUEBANNER = CBM_FIRST + 3,
+        CB_GETCUEBANNER = CBM_FIRST + 4,
+    }
+
+    BOOL ComboBox_SetMinVisible(HWND w, INT i) {
+        return cast(BOOL) SendMessage(w, CB_SETMINVISIBLE, cast(WPARAM) i, 0);
+    }
+
+    int ComboBox_GetMinVisible(HWND w) {
+        return cast(int) SendMessage(w, CB_GETMINVISIBLE, 0, 0);
+    }
+}
+
+extern (Windows) BOOL MakeDragList(HWND);
+extern (Windows) void MenuHelp(UINT, WPARAM, LPARAM, HMENU, HINSTANCE, HWND,
+  PUINT);
+
+COLORREF MonthCal_GetColor(HWND hwnd, INT icolor) {
+    return cast(COLORREF) SendMessage(hwnd, MCM_GETCOLOR,
+      cast(WPARAM) icolor, 0);
+}
+
+BOOL MonthCal_GetCurSel(HWND hwnd, LPSYSTEMTIME lpsystime) {
+    return cast(BOOL) SendMessage(hwnd, MCM_GETCURSEL, 0,
+      cast(LPARAM) lpsystime);
+}
+
+DWORD MonthCal_GetFirstDayOfWeek(HWND hwnd) {
+    return cast(DWORD) SendMessage(hwnd, MCM_GETFIRSTDAYOFWEEK, 0, 0);
+}
+
+DWORD MonthCal_GetMaxSelCount(HWND hwnd) {
+    return cast(DWORD) SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
+}
+
+DWORD MonthCal_GetMaxTodayWidth(HWND hwnd) {
+    return cast(DWORD) SendMessage(hwnd, MCM_GETMAXTODAYWIDTH, 0, 0);
+}
+
+BOOL MonthCal_GetMinReqRect(HWND hwnd, LPRECT lpRectInfo) {
+    return cast(BOOL) SendMessage(hwnd, MCM_GETMINREQRECT, 0,
+      cast(LPARAM) lpRectInfo);
+}
+
+INT MonthCal_GetMonthDelta(HWND hwnd) {
+    return cast(INT) SendMessage(hwnd, MCM_GETMONTHDELTA, 0, 0);
+}
+
+INT MonthCal_GetMonthRange(HWND hwnd, DWORD flag, LPSYSTEMTIME systimearray) {
+    return cast(INT) SendMessage(hwnd, MCM_GETMONTHRANGE, cast(WPARAM) flag,
+      cast(LPARAM) systimearray);
+}
+
+DWORD MonthCal_GetRange(HWND hwnd, LPSYSTEMTIME systimearray) {
+    return cast(DWORD) SendMessage(hwnd, MCM_GETRANGE, 0,
+      cast(LPARAM) systimearray);
+}
+
+BOOL MonthCal_GetSelRange(HWND hwnd, LPSYSTEMTIME systimearray) {
+    return cast(BOOL) SendMessage(hwnd, MCM_GETSELRANGE, 0,
+      cast(LPARAM) systimearray);
+}
+
+BOOL MonthCal_GetToday(HWND hwnd, LPSYSTEMTIME systime) {
+    return cast(BOOL) SendMessage(hwnd, MCM_GETTODAY, 0,
+      cast(LPARAM) systime);
+}
+
+BOOL MonthCal_GetUnicodeFormat(HWND hwnd) {
+    return cast(BOOL) SendMessage(hwnd, MCM_GETUNICODEFORMAT, 0, 0);
+}
+
+DWORD MonthCal_HitTest(HWND hwnd, PMCHITTESTINFO pmchittest) {
+    return cast(DWORD) SendMessage(hwnd, MCM_HITTEST, 0,
+      cast(LPARAM) pmchittest);
+}
+
+COLORREF MonthCal_SetColor(HWND hwnd, INT icolor, COLORREF clr) {
+    return cast(COLORREF) SendMessage(hwnd, MCM_SETCOLOR, cast(WPARAM) icolor,
+      cast(LPARAM) clr);
+}
+
+BOOL MonthCal_SetCurSel(HWND hwnd, LPSYSTEMTIME lpsystime) {
+    return cast(BOOL) SendMessage(hwnd, MCM_SETCURSEL, 0,
+      cast(LPARAM) lpsystime);
+}
+
+BOOL MonthCal_SetDayState(HWND hwnd, INT imonths, LPMONTHDAYSTATE lpdatestatearray) {
+    return cast(BOOL) SendMessage(hwnd, MCM_SETDAYSTATE, cast(WPARAM) imonths,
+      cast(LPARAM) lpdatestatearray);
+}
+
+DWORD MonthCal_SetFirstDayOfWeek(HWND hwnd, INT iday) {
+    return cast(DWORD) SendMessage(hwnd, MCM_SETFIRSTDAYOFWEEK, 0,
+      cast(LPARAM) iday);
+}
+
+BOOL MonthCal_SetMaxSelCount(HWND hwnd, UINT imax) {
+    return cast(BOOL) SendMessage(hwnd, MCM_SETMAXSELCOUNT,
+      cast(WPARAM) imax, 0);
+}
+
+INT MonthCal_SetMonthDelta(HWND hwnd, INT idelta) {
+    return cast(INT) SendMessage(hwnd, MCM_SETMONTHDELTA, cast(WPARAM) idelta, 0);
+}
+
+BOOL MonthCal_SetSelRange(HWND hwnd, LPSYSTEMTIME systimearray) {
+    return cast(BOOL) SendMessage(hwnd, MCM_SETSELRANGE, 0,
+      cast(LPARAM) systimearray);
+}
+
+void MonthCal_SetToday(HWND hwnd, LPSYSTEMTIME systime) {
+    SendMessage(hwnd, MCM_SETTODAY, 0, cast(LPARAM) systime);
+}
+
+BOOL MonthCal_SetUnicodeFormat(HWND hwnd, BOOL unicode) {
+    return cast(BOOL) SendMessage(hwnd, MCM_SETUNICODEFORMAT,
+      cast(WPARAM) unicode, 0);
+}
+
+BOOL MonthCal_SetRange(HWND w, DWORD f, LPSYSTEMTIME st) {
+    return cast(BOOL) SendMessage(w, MCM_SETRANGE, cast(WPARAM) f,
+      cast(LPARAM) st);
+}
+
+extern (Windows) BOOL ShowHideMenuCtl(HWND, UINT_PTR, PINT);
+
+BOOL TabCtrl_GetItem(HWND w, int i, LPTCITEM p) {
+    return cast(BOOL) SendMessage(w, TCM_GETITEM, i, cast(LPARAM) p);
+}
+
+BOOL TabCtrl_SetItem(HWND w, int i, LPTCITEM p) {
+    return cast(BOOL) SendMessage(w, TCM_SETITEM, i, cast(LPARAM) p);
+}
+
+int TabCtrl_InsertItem(HWND w, int i, const(TC_ITEM)* p) {
+    return cast(int) SendMessage(w, TCM_INSERTITEM, i, cast(LPARAM) p);
+}
+
+BOOL TabCtrl_DeleteItem(HWND w, int i) {
+    return cast(BOOL) SendMessage(w, TCM_DELETEITEM, i, 0);
+}
+
+BOOL TabCtrl_DeleteAllItems(HWND w) {
+    return cast(BOOL) SendMessage(w, TCM_DELETEALLITEMS, 0, 0);
+}
+
+BOOL TabCtrl_GetItemRect(HWND w, int i, LPRECT p) {
+    return cast(BOOL) SendMessage(w, TCM_GETITEMRECT, i, cast(LPARAM) p);
+}
+
+int TabCtrl_GetCurSel(HWND w) {
+    return cast(int) SendMessage(w, TCM_GETCURSEL, 0, 0);
+}
+
+int TabCtrl_SetCurSel(HWND w, int i) {
+    return cast(int) SendMessage(w, TCM_SETCURSEL, i, 0);
+}
+
+int TabCtrl_HitTest(HWND w, LPTCHITTESTINFO p) {
+    return cast(int) SendMessage(w, TCM_HITTEST, 0, cast(LPARAM) p);
+}
+
+BOOL TabCtrl_SetItemExtra(HWND w, int c) {
+    return cast(BOOL) SendMessage(w, TCM_SETITEMEXTRA, c, 0);
+}
+
+int TabCtrl_AdjustRect(HWND w, BOOL b, LPRECT p) {
+    return cast(int) SendMessage(w, TCM_ADJUSTRECT, b, cast(LPARAM) p);
+}
+
+DWORD TabCtrl_SetItemSize(HWND w, int x, int y) {
+    return cast(DWORD) SendMessage(w, TCM_SETITEMSIZE, 0, MAKELPARAM(cast(ushort)x, cast(ushort)y));
+}
+
+void TabCtrl_RemoveImage(HWND w, int i) {
+    SendMessage(w, TCM_REMOVEIMAGE, i, 0);
+}
+
+void TabCtrl_SetPadding(HWND w, int x, int y) {
+    SendMessage(w, TCM_SETPADDING, 0, MAKELPARAM(cast(ushort)x, cast(ushort)y));
+}
+
+int TabCtrl_GetRowCount(HWND w) {
+    return cast(int) SendMessage(w, TCM_GETROWCOUNT, 0, 0);
+}
+
+HWND TabCtrl_GetToolTips(HWND w) {
+    return cast(HWND) SendMessage(w, TCM_GETTOOLTIPS, 0, 0);
+}
+
+void TabCtrl_SetToolTips(HWND w, HWND t) {
+    SendMessage(w, TCM_SETTOOLTIPS, cast(WPARAM) t, 0);
+}
+
+int TabCtrl_GetCurFocus(HWND w) {
+    return cast(int) SendMessage(w, TCM_GETCURFOCUS, 0, 0);
+}
+
+void TabCtrl_SetCurFocus(HWND w, int i) {
+    SendMessage(w, TCM_SETCURFOCUS, i, 0);
+}
+
+HIMAGELIST TabCtrl_GetImageList(HWND w) {
+    return cast(HIMAGELIST) SendMessage(w, TCM_GETIMAGELIST, 0, 0);
+}
+
+HIMAGELIST TabCtrl_SetImageList(HWND w, HIMAGELIST h) {
+    return cast(HIMAGELIST) SendMessage(w, TCM_SETIMAGELIST, 0,
+      cast(LPARAM) h);
+}
+
+int TabCtrl_GetItemCount(HWND w) {
+    return cast(int) SendMessage(w, TCM_GETITEMCOUNT, 0, 0);
+}
+
+extern (Windows) BOOL _TrackMouseEvent(LPTRACKMOUSEEVENT);
+
+HTREEITEM TreeView_InsertItem(HWND w, LPTVINSERTSTRUCT i) {
+    return cast(HTREEITEM) SendMessage(w, TVM_INSERTITEM, 0, cast(LPARAM) i);
+}
+
+BOOL TreeView_DeleteItem(HWND w, HTREEITEM i) {
+    return cast(BOOL) SendMessage(w, TVM_DELETEITEM, 0, cast(LPARAM) i);
+}
+
+BOOL TreeView_DeleteAllItems(HWND w) {
+    return cast(BOOL) SendMessage(w, TVM_DELETEITEM, 0, cast(LPARAM) TVI_ROOT);
+}
+
+BOOL TreeView_Expand(HWND w, HTREEITEM i, UINT c) {
+    return cast(BOOL) SendMessage(w, TVM_EXPAND, c, cast(LPARAM) i);
+}
+
+BOOL TreeView_GetItemRect(HWND w, HTREEITEM i, LPRECT p, BOOL c) {
+    *cast(HTREEITEM*) p = i;
+    return cast(BOOL) SendMessage(w, TVM_GETITEMRECT, c, cast(LPARAM) p);
+}
+
+UINT TreeView_GetCount(HWND w) {
+    return cast(UINT) SendMessage(w, TVM_GETCOUNT, 0, 0);
+}
+
+UINT TreeView_GetIndent(HWND w) {
+    return cast(UINT) SendMessage(w, TVM_GETINDENT, 0, 0);
+}
+
+BOOL TreeView_SetIndent(HWND w, INT i) {
+    return cast(BOOL) SendMessage(w, TVM_SETINDENT, i, 0);
+}
+
+HIMAGELIST TreeView_GetImageList(HWND w, INT i) {
+    return cast(HIMAGELIST) SendMessage(w, TVM_GETIMAGELIST, i, 0);
+}
+
+HIMAGELIST TreeView_SetImageList(HWND w, HIMAGELIST h, INT i) {
+    return cast(HIMAGELIST) SendMessage(w, TVM_SETIMAGELIST, i,
+      cast(LPARAM) h);
+}
+
+HTREEITEM TreeView_GetNextItem(HWND w, HTREEITEM i, UINT c) {
+    return cast(HTREEITEM) SendMessage(w, TVM_GETNEXTITEM, c, cast(LPARAM) i);
+}
+
+HTREEITEM TreeView_GetChild(HWND w, HTREEITEM i) {
+    return TreeView_GetNextItem(w, i, TVGN_CHILD);
+}
+
+HTREEITEM TreeView_GetNextSibling(HWND w, HTREEITEM i) {
+    return TreeView_GetNextItem(w, i, TVGN_NEXT);
+}
+
+HTREEITEM TreeView_GetPrevSibling(HWND w, HTREEITEM i) {
+    return TreeView_GetNextItem(w, i, TVGN_PREVIOUS);
+}
+
+HTREEITEM TreeView_GetParent(HWND w, HTREEITEM i) {
+    return TreeView_GetNextItem(w, i, TVGN_PARENT);
+}
+
+HTREEITEM TreeView_GetFirstVisible(HWND w) {
+    return TreeView_GetNextItem(w, null, TVGN_FIRSTVISIBLE);
+}
+
+HTREEITEM TreeView_GetNextVisible(HWND w, HTREEITEM i) {
+    return TreeView_GetNextItem(w, i, TVGN_NEXTVISIBLE);
+}
+
+HTREEITEM TreeView_GetPrevVisible(HWND w, HTREEITEM i) {
+    return TreeView_GetNextItem(w, i, TVGN_PREVIOUSVISIBLE);
+}
+
+HTREEITEM TreeView_GetSelection(HWND w) {
+    return TreeView_GetNextItem(w, null, TVGN_CARET);
+}
+
+HTREEITEM TreeView_GetDropHilight(HTREEITEM w) {
+    return TreeView_GetNextItem(w, null, TVGN_DROPHILITE);
+}
+
+HTREEITEM TreeView_GetRoot(HWND w) {
+    return TreeView_GetNextItem(w, null, TVGN_ROOT);
+}
+
+BOOL TreeView_Select(HWND w, HTREEITEM i, UINT c) {
+    return cast(BOOL) SendMessage(w, TVM_SELECTITEM, c, cast(LPARAM) i);
+}
+
+BOOL TreeView_SelectItem(HWND w, HTREEITEM i) {
+    return TreeView_Select(w, i, TVGN_CARET);
+}
+
+BOOL TreeView_SelectDropTarget(HWND w, HTREEITEM i) {
+    return TreeView_Select(w, i, TVGN_DROPHILITE);
+}
+
+BOOL TreeView_SelectSetFirstVisible(HWND w, HTREEITEM i) {
+    return TreeView_Select(w, i, TVGN_FIRSTVISIBLE);
+}
+
+BOOL TreeView_GetItem(HWND w, LPTVITEM i) {
+ return cast(BOOL) SendMessage(w, TVM_GETITEM, 0, cast(LPARAM) i);
+}
+
+BOOL TreeView_SetItem(HWND w, const(TV_ITEM)* i) {
+    return cast(BOOL) SendMessage(w, TVM_SETITEM, 0, cast(LPARAM) i);
+}
+
+HWND TreeView_EditLabel(HWND w, HTREEITEM i) {
+    return cast(HWND) SendMessage(w, TVM_EDITLABEL, 0, cast(LPARAM) i);
+}
+
+HWND TreeView_GetEditControl(HWND w) {
+    return cast(HWND) SendMessage(w, TVM_GETEDITCONTROL, 0, 0);
+}
+
+UINT TreeView_GetVisibleCount(HWND w) {
+    return cast(UINT) SendMessage(w, TVM_GETVISIBLECOUNT, 0, 0);
+}
+
+HTREEITEM TreeView_HitTest(HWND w, LPTVHITTESTINFO p) {
+    return cast(HTREEITEM) SendMessage(w, TVM_HITTEST, 0, cast(LPARAM) p);
+}
+
+HIMAGELIST TreeView_CreateDragImage(HWND w, HTREEITEM i) {
+    return cast(HIMAGELIST) SendMessage(w, TVM_CREATEDRAGIMAGE, 0,
+      cast(LPARAM) i);
+}
+
+BOOL TreeView_SortChildren(HWND w, HTREEITEM i, BOOL r) {
+    return cast(BOOL) SendMessage(w, TVM_SORTCHILDREN, r, cast(LPARAM) i);
+}
+
+BOOL TreeView_EnsureVisible(HWND w, HTREEITEM i) {
+    return cast(BOOL) SendMessage(w, TVM_ENSUREVISIBLE, 0, cast(LPARAM) i);
+}
+
+BOOL TreeView_SortChildrenCB(HWND w, LPTVSORTCB s, BOOL r) {
+    return cast(BOOL) SendMessage(w, TVM_SORTCHILDRENCB, r, cast(LPARAM) s);
+}
+
+BOOL TreeView_EndEditLabelNow(HWND w, BOOL f) {
+    return cast(BOOL) SendMessage(w, TVM_ENDEDITLABELNOW, f, 0);
+}
+
+BOOL TreeView_GetISearchString(HWND w, LPTSTR s) {
+    return cast(BOOL) SendMessage(w, TVM_GETISEARCHSTRING, 0, cast(LPARAM) s);
+}
+
+static if (_WIN32_IE >= 0x300) {
+    DWORD ListView_ApproximateViewRect(HWND w, int iw, int ih, int i) {
+        return cast(DWORD) SendMessage(w, LVM_APPROXIMATEVIEWRECT, i,
+          MAKELPARAM(cast(ushort)iw, cast(ushort)ih));
+    }
+
+    DWORD ListView_SetExtendedListViewStyle(HWND w, DWORD s) {
+        return cast(DWORD) SendMessage(w, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, s);
+    }
+
+    DWORD ListView_GetExtendedListViewStyle(HWND w) {
+        return cast(DWORD) SendMessage(w, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+    }
+
+    BOOL ListView_SetColumnOrderArray(HWND w, int i, int* a) {
+        return cast(BOOL) SendMessage(w, LVM_SETCOLUMNORDERARRAY,
+          cast(WPARAM) i, cast(LPARAM) a);
+    }
+
+    BOOL ListView_GetColumnOrderArray(HWND w, int i, int* a) {
+        return cast(BOOL) SendMessage(w, LVM_GETCOLUMNORDERARRAY,
+          cast(WPARAM) i, cast(LPARAM) a);
+    }
+
+    HWND ListView_GetHeader(HWND w) {
+        return cast(HWND) SendMessage(w, LVM_GETHEADER, 0, 0);
+    }
+
+    HCURSOR ListView_GetHotCursor(HWND w) {
+        return cast(HCURSOR) SendMessage(w, LVM_GETHOTCURSOR, 0, 0);
+    }
+
+    INT ListView_GetHotItem(HWND w) {
+        return cast(INT) SendMessage(w, LVM_GETHOTITEM, 0, 0);
+    }
+
+    BOOL ListView_GetSubItemRect(HWND w, int i, int isi, int c, LPRECT p) {
+        return cast(BOOL) SendMessage(w, LVM_GETSUBITEMRECT, i,
+          p ? (p.left = c, p.top = isi, cast(LPARAM) p) : 0);
+    }
+
+    HCURSOR ListView_SetHotCursor(HWND w, HCURSOR c) {
+        return cast(HCURSOR) SendMessage(w, LVM_SETHOTCURSOR, 0,
+          cast(LPARAM) c);
+    }
+
+    INT ListView_SetHotItem(HWND w, INT i) {
+        return cast(INT) SendMessage(w, LVM_SETHOTITEM, cast(WPARAM) i, 0);
+    }
+
+    DWORD ListView_SetIconSpacing(HWND w, int x, int y) {
+        return cast(DWORD) SendMessage(w, LVM_SETICONSPACING, 0,
+          MAKELONG(cast(ushort)x, cast(ushort)y));
+    }
+
+    INT ListView_SubItemHitTest(HWND w, LPLVHITTESTINFO p) {
+        return cast(INT) SendMessage(w, LVM_SUBITEMHITTEST, 0, cast(LPARAM) p);
+    }
+
+    BOOL ListView_SetItemCountEx(HWND w, int i, DWORD f) {
+        return cast(BOOL) SendMessage(w, LVM_SETITEMCOUNT, i, cast(LPARAM) f);
+    }
+
+    extern (Windows) {
+        WINBOOL ImageList_SetImageCount(HIMAGELIST, UINT);
+        WINBOOL ImageList_Copy(HIMAGELIST, int, HIMAGELIST, int, UINT);
+        WINBOOL ImageList_DrawIndirect(IMAGELISTDRAWPARAMS*);
+    }
+
+    int TabCtrl_SetMinTabWidth(HWND hwnd, int x) {
+        return cast(int) SendMessage(hwnd, TCM_SETMINTABWIDTH, 0, x);
+    }
+
+    VOID TabCtrl_DeselectAll(HWND hwnd, UINT fExcludeFocus) {
+        SendMessage(hwnd, TCM_DESELECTALL, fExcludeFocus, 0);
+    }
+
+    HWND TreeView_GetToolTips(HWND w) {
+        return cast(HWND) SendMessage(w, TVM_GETTOOLTIPS, 0, 0);
+    }
+
+    HWND TreeView_SetToolTips(HWND w, HWND wt) {
+        return cast(HWND) SendMessage(w, TVM_SETTOOLTIPS, cast(WPARAM) wt, 0);
+    }
+}
+
+static if (_WIN32_IE >= 0x400) {
+    BOOL ListView_GetBkImage(HWND h, LPLVBKIMAGE plvbki) {
+        return cast(BOOL) SendMessage(h, LVM_GETBKIMAGE, 0,
+          cast(LPARAM) plvbki);
+    }
+
+    BOOL ListView_SetBkImage(HWND h, LPLVBKIMAGE plvbki) {
+        return cast(BOOL) SendMessage(h, LVM_SETBKIMAGE, 0,
+          cast(LPARAM) plvbki);
+    }
+
+    DWORD ListView_SetExtendedListViewStyleEx(HWND w, DWORD m, DWORD s) {
+        return cast(DWORD) SendMessage(w, LVM_SETEXTENDEDLISTVIEWSTYLE, m, s);
+    }
+
+    VOID ListView_SetWorkAreas(HWND w, INT n, LPRECT r) {
+        SendMessage(w, LVM_SETWORKAREAS, cast(WPARAM) n, cast(LPARAM) r);
+    }
+
+    VOID ListView_GetWorkAreas(HWND w, INT n, LPRECT r) {
+        SendMessage(w, LVM_GETWORKAREAS, cast(WPARAM) n, cast(LPARAM) r);
+    }
+
+    BOOL ListView_GetNumberOfWorkAreas(HWND w, LPUINT n) {
+        return cast(BOOL) SendMessage(w, LVM_GETNUMBEROFWORKAREAS, 0,
+          cast(LPARAM) n);
+    }
+
+    DWORD ListView_SetHoverTime(HWND w, DWORD t) {
+        return cast(DWORD) SendMessage(w, LVM_SETHOVERTIME, 0,
+          cast(LPARAM) t);
+    }
+
+    DWORD ListView_GetHoverTime(HWND w) {
+        return cast(DWORD) SendMessage(w, LVM_GETHOVERTIME, 0, 0);
+    }
+
+    INT ListView_GetSelectionMark(HWND w) {
+        return cast(INT) SendMessage(w, LVM_GETSELECTIONMARK, 0, 0);
+    }
+
+    INT ListView_SetSelectionMark(HWND w, INT i) {
+        return cast(INT) SendMessage(w, LVM_SETSELECTIONMARK, 0, cast(LPARAM) i);
+    }
+
+    HWND ListView_SetToolTips(HWND w, HWND n) {
+        return cast(HWND) SendMessage(w, LVM_SETTOOLTIPS, cast(WPARAM) n, 0);
+    }
+
+    HWND ListView_GetToolTips(HWND w) {
+        return cast(HWND) SendMessage(w, LVM_GETTOOLTIPS, 0, 0);
+    }
+
+    BOOL ListView_SetUnicodeFormat(HWND w, BOOL f) {
+        return cast(BOOL) SendMessage(w, LVM_SETUNICODEFORMAT,
+          cast(WPARAM) f, 0);
+    }
+
+    BOOL ListView_GetUnicodeFormat(HWND w) {
+        return cast(BOOL) SendMessage(w, LVM_GETUNICODEFORMAT, 0, 0);
+    }
+
+    BOOL TabCtrl_HighlightItem(HWND hwnd, INT i, WORD fHighlight) {
+        return cast(BOOL) SendMessage(hwnd, TCM_HIGHLIGHTITEM,
+          cast(WPARAM) i, cast(LPARAM) MAKELONG(fHighlight, 0));
+    }
+
+    DWORD TabCtrl_SetExtendedStyle(HWND hwnd, DWORD dw) {
+        return cast(DWORD) SendMessage(hwnd, TCM_SETEXTENDEDSTYLE, 0, dw);
+    }
+
+    DWORD TabCtrl_GetExtendedStyle(HWND hwnd) {
+        return cast(DWORD) SendMessage(hwnd, TCM_GETEXTENDEDSTYLE, 0, 0);
+    }
+
+    BOOL TabCtrl_SetUnicodeFormat(HWND hwnd, HWND fUnicode) {
+        return cast(BOOL) SendMessage(hwnd, TCM_SETUNICODEFORMAT,
+          cast(WPARAM) fUnicode, 0);
+    }
+
+    BOOL TabCtrl_GetUnicodeFormat(HWND hwnd) {
+        return cast(BOOL) SendMessage(hwnd, TCM_GETUNICODEFORMAT, 0, 0);
+    }
+
+    COLORREF TreeView_GetBkColor(HWND w) {
+        return cast(COLORREF) SendMessage(w, TVM_GETBKCOLOR, 0, 0);
+    }
+
+    COLORREF TreeView_GetInsertMarkColor(HWND w) {
+        return cast(COLORREF) SendMessage(w, TVM_GETINSERTMARKCOLOR, 0, 0);
+    }
+
+    int TreeView_GetItemHeight(HWND w) {
+        return cast(int) SendMessage(w, TVM_GETITEMHEIGHT, 0, 0);
+    }
+
+    UINT TreeView_GetScrollTime(HWND w) {
+        return cast(UINT) SendMessage(w, TVM_GETSCROLLTIME, 0, 0);
+    }
+
+    COLORREF TreeView_GetTextColor(HWND w) {
+        return cast(COLORREF) SendMessage(w, TVM_GETTEXTCOLOR, 0, 0);
+    }
+
+    COLORREF TreeView_SetBkColor(HWND w, COLORREF c) {
+        return cast(COLORREF) SendMessage(w, TVM_SETBKCOLOR, 0,
+          cast(LPARAM) c);
+    }
+
+    COLORREF TreeView_SetInsertMarkColor(HWND w, COLORREF c) {
+        return cast(COLORREF) SendMessage(w, TVM_SETINSERTMARKCOLOR, 0,
+          cast(LPARAM) c);
+    }
+
+    int TreeView_SetItemHeight(HWND w, SHORT h) {
+        return cast(int) SendMessage(w, TVM_SETITEMHEIGHT, cast(WPARAM) h, 0);
+    }
+
+    UINT TreeView_SetScrollTime(HWND w, UINT t) {
+        return cast(UINT) SendMessage(w, TVM_SETSCROLLTIME, cast(WPARAM) t, 0);
+    }
+
+    COLORREF TreeView_SetTextColor(HWND w, COLORREF c) {
+        return cast(COLORREF) SendMessage(w, TVM_SETTEXTCOLOR, 0,
+          cast(LPARAM) c);
+    }
+
+    BOOL TreeView_SetInsertMark(HWND w, HTREEITEM i, BOOL a) {
+        return cast(BOOL) SendMessage(w, TVM_SETINSERTMARK, cast(WPARAM) a,
+          cast(LPARAM) i);
+    }
+
+    BOOL TreeView_SetUnicodeFormat(HWND w, BOOL u) {
+        return cast(BOOL) SendMessage(w, TVM_SETUNICODEFORMAT,
+          cast(WPARAM) u, 0);
+    }
+
+    BOOL TreeView_GetUnicodeFormat(HWND w) {
+        return cast(BOOL) SendMessage(w, TVM_GETUNICODEFORMAT, 0, 0);
+    }
+
+    HTREEITEM TreeView_GetLastVisible(HWND w) {
+        return TreeView_GetNextItem(w, null, TVGN_LASTVISIBLE);
+    }
+}
+
+static if (_WIN32_IE >= 0x500) {
+    UINT TreeView_GetItemState(HWND w, HTREEITEM i, UINT m) {
+        return cast(UINT) SendMessage(w, TVM_GETITEMSTATE, cast(WPARAM) i,
+          cast(LPARAM) m);
+    }
+
+    BOOL TreeView_SetItemState(HWND w, HTREEITEM i, UINT d, UINT m) {
+        TVITEM _tvi;
+        _tvi.mask = TVIF_STATE;
+        _tvi.hItem = i;
+        _tvi.stateMask = m;
+        _tvi.state = d;
+        return cast(BOOL) SendMessage(w, TVM_SETITEM, 0, cast(LPARAM) &_tvi);
+    }
+}
+
+
+//#ifdef _WIN32_WCE               // these are PPC only
+/+
+extern (Windows) {
+    HWND  CommandBar_Create(HINSTANCE, HWND, int);
+    BOOL  CommandBar_Show(HWND, BOOL);
+    int   CommandBar_AddBitmap(HWND, HINSTANCE, int, int, int, int);
+    HWND  CommandBar_InsertComboBox(HWND, HINSTANCE, int, UINT, WORD, WORD);
+    BOOL  CommandBar_InsertMenubar(HWND, HINSTANCE, WORD, WORD );
+    BOOL  CommandBar_InsertMenubarEx(HWND, HINSTANCE, LPTSTR, WORD);
+    BOOL  CommandBar_DrawMenuBar(HWND, WORD);
+    HMENU CommandBar_GetMenu(HWND, WORD);
+    BOOL  CommandBar_AddAdornments(HWND, DWORD, DWORD);
+    int   CommandBar_Height(HWND hwndCB);
+}
+
+// MinGW: These two are not in the DLL
+void CommandBar_InsertButton(HWND hwnd, int i, LPTBBUTTON lptbbutton) {
+    SendMessage(hwnd, TB_INSERTBUTTON, i, lptbbutton);
+}
+alias DestroyWindow CommandBar_Destroy;
++/
+//#endif // _WIN32_WCE
+
+
+static if (_WIN32_WINNT >= 0x501) {
+    struct EDITBALLOONTIP
+    {
+        DWORD cbStruct;
+        LPCWSTR pszTitle;
+        LPCWSTR pszText;
+        INT ttiIcon;
+    }
+    alias EDITBALLOONTIP* PEDITBALLOONTIP;
+
+enum EM_SETCUEBANNER = ECM_FIRST + 1;
+enum EM_GETCUEBANNER = ECM_FIRST + 2;
+enum EM_SHOWBALLOONTIP = ECM_FIRST + 3;
+enum EM_HIDEBALLOONTIP = ECM_FIRST + 4;
+}
+
+static if (_WIN32_WINNT >= 0x600) {
+enum EM_SETHILITE = ECM_FIRST + 5;
+enum EM_GETHILITE = ECM_FIRST + 6;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/commdlg.d b/libphobos/libdruntime/core/sys/windows/commdlg.d
new file mode 100644
index 00000000000..81fafbd2800
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/commdlg.d
@@ -0,0 +1,718 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.12
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_commdlg.d)
+ */
+module core.sys.windows.commdlg;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "comdlg32");
+
+private import core.sys.windows.w32api;
+import core.sys.windows.windef, core.sys.windows.winuser;
+import core.sys.windows.wingdi; // for LPLOGFONTA
+
+const TCHAR[]
+    LBSELCHSTRING = "commdlg_LBSelChangedNotify",
+    SHAREVISTRING = "commdlg_ShareViolation",
+    FILEOKSTRING  = "commdlg_FileNameOK",
+    COLOROKSTRING = "commdlg_ColorOK",
+    SETRGBSTRING  = "commdlg_SetRGBColor",
+    HELPMSGSTRING = "commdlg_help",
+    FINDMSGSTRING = "commdlg_FindReplace";
+
+enum : UINT {
+    CDN_FIRST          = -601, // also in commctrl.h
+    CDN_LAST           = -699,
+    CDN_INITDONE       = CDN_FIRST,
+    CDN_SELCHANGE      = CDN_FIRST - 1,
+    CDN_FOLDERCHANGE   = CDN_FIRST - 2,
+    CDN_SHAREVIOLATION = CDN_FIRST - 3,
+    CDN_HELP           = CDN_FIRST - 4,
+    CDN_FILEOK         = CDN_FIRST - 5,
+    CDN_TYPECHANGE     = CDN_FIRST - 6,
+}
+
+//static if(_WIN32_WINNT >= 0x500) {
+    enum : UINT {
+        CDN_INCLUDEITEM    = CDN_FIRST - 7,
+    }
+//}
+
+enum : UINT {
+    CDM_FIRST           = WM_USER + 100,
+    CDM_LAST            = WM_USER + 200,
+    CDM_GETSPEC         = CDM_FIRST,
+    CDM_GETFILEPATH,
+    CDM_GETFOLDERPATH,
+    CDM_GETFOLDERIDLIST,
+    CDM_SETCONTROLTEXT,
+    CDM_HIDECONTROL,
+    CDM_SETDEFEXT    // = CDM_FIRST + 6
+}
+
+// flags for ChooseColor
+enum : DWORD {
+    CC_RGBINIT              = 0x0001,
+    CC_FULLOPEN             = 0x0002,
+    CC_PREVENTFULLOPEN      = 0x0004,
+    CC_SHOWHELP             = 0x0008,
+    CC_ENABLEHOOK           = 0x0010,
+    CC_ENABLETEMPLATE       = 0x0020,
+    CC_ENABLETEMPLATEHANDLE = 0x0040,
+    CC_SOLIDCOLOR           = 0x0080,
+    CC_ANYCOLOR             = 0x0100
+}
+
+// flags for ChooseFont
+enum : DWORD {
+    CF_SCREENFONTS          = 0x00000001,
+    CF_PRINTERFONTS         = 0x00000002,
+    CF_BOTH                 = 0x00000003,
+    CF_SHOWHELP             = 0x00000004,
+    CF_ENABLEHOOK           = 0x00000008,
+    CF_ENABLETEMPLATE       = 0x00000010,
+    CF_ENABLETEMPLATEHANDLE = 0x00000020,
+    CF_INITTOLOGFONTSTRUCT  = 0x00000040,
+    CF_USESTYLE             = 0x00000080,
+    CF_EFFECTS              = 0x00000100,
+    CF_APPLY                = 0x00000200,
+    CF_ANSIONLY             = 0x00000400,
+    CF_SCRIPTSONLY          = CF_ANSIONLY,
+    CF_NOVECTORFONTS        = 0x00000800,
+    CF_NOOEMFONTS           = 0x00000800,
+    CF_NOSIMULATIONS        = 0x00001000,
+    CF_LIMITSIZE            = 0x00002000,
+    CF_FIXEDPITCHONLY       = 0x00004000,
+    CF_WYSIWYG              = 0x00008000,
+    CF_FORCEFONTEXIST       = 0x00010000,
+    CF_SCALABLEONLY         = 0x00020000,
+    CF_TTONLY               = 0x00040000,
+    CF_NOFACESEL            = 0x00080000,
+    CF_NOSTYLESEL           = 0x00100000,
+    CF_NOSIZESEL            = 0x00200000,
+    CF_SELECTSCRIPT         = 0x00400000,
+    CF_NOSCRIPTSEL          = 0x00800000,
+    CF_NOVERTFONTS          = 0x01000000
+}
+
+// Font type for ChooseFont
+enum : WORD {
+    BOLD_FONTTYPE      = 0x0100,
+    ITALIC_FONTTYPE    = 0x0200,
+    REGULAR_FONTTYPE   = 0x0400,
+    SCREEN_FONTTYPE    = 0x2000,
+    PRINTER_FONTTYPE   = 0x4000,
+    SIMULATED_FONTTYPE = 0x8000
+}
+
+enum : UINT {
+    WM_CHOOSEFONT_GETLOGFONT = WM_USER +   1,
+    WM_CHOOSEFONT_SETLOGFONT = WM_USER + 101,
+    WM_CHOOSEFONT_SETFLAGS   = WM_USER + 102
+}
+
+// flags for OpenFileName
+enum : DWORD {
+    OFN_SHAREWARN            = 0,
+    OFN_SHARENOWARN          = 0x000001,
+    OFN_READONLY             = 0x000001,
+    OFN_SHAREFALLTHROUGH     = 0x000002,
+    OFN_OVERWRITEPROMPT      = 0x000002,
+    OFN_HIDEREADONLY         = 0x000004,
+    OFN_NOCHANGEDIR          = 0x000008,
+    OFN_SHOWHELP             = 0x000010,
+    OFN_ENABLEHOOK           = 0x000020,
+    OFN_ENABLETEMPLATE       = 0x000040,
+    OFN_ENABLETEMPLATEHANDLE = 0x000080,
+    OFN_NOVALIDATE           = 0x000100,
+    OFN_ALLOWMULTISELECT     = 0x000200,
+    OFN_EXTENSIONDIFFERENT   = 0x000400,
+    OFN_PATHMUSTEXIST        = 0x000800,
+    OFN_FILEMUSTEXIST        = 0x001000,
+    OFN_CREATEPROMPT         = 0x002000,
+    OFN_SHAREAWARE           = 0x004000,
+    OFN_NOREADONLYRETURN     = 0x008000,
+    OFN_NOTESTFILECREATE     = 0x010000,
+    OFN_NONETWORKBUTTON      = 0x020000,
+    OFN_NOLONGNAMES          = 0x040000,
+    OFN_EXPLORER             = 0x080000,
+    OFN_NODEREFERENCELINKS   = 0x100000,
+    OFN_LONGNAMES            = 0x200000,
+    OFN_ENABLESIZING         = 0x800000
+}
+
+enum : DWORD {
+    FR_DOWN                 = 0x00000001,
+    FR_WHOLEWORD            = 0x00000002,
+    FR_MATCHCASE            = 0x00000004,
+    FR_FINDNEXT             = 0x00000008,
+    FR_REPLACE              = 0x00000010,
+    FR_REPLACEALL           = 0x00000020,
+    FR_DIALOGTERM           = 0x00000040,
+    FR_SHOWHELP             = 0x00000080,
+    FR_ENABLEHOOK           = 0x00000100,
+    FR_ENABLETEMPLATE       = 0x00000200,
+    FR_NOUPDOWN             = 0x00000400,
+    FR_NOMATCHCASE          = 0x00000800,
+    FR_NOWHOLEWORD          = 0x00001000,
+    FR_ENABLETEMPLATEHANDLE = 0x00002000,
+    FR_HIDEUPDOWN           = 0x00004000,
+    FR_HIDEMATCHCASE        = 0x00008000,
+    FR_HIDEWHOLEWORD        = 0x00010000,
+    FR_MATCHDIAC            = 0x20000000,
+    FR_MATCHKASHIDA         = 0x40000000,
+    FR_MATCHALEFHAMZA       = 0x80000000
+}
+
+enum : DWORD {
+    PD_ALLPAGES                   = 0,
+    PD_SELECTION                  = 0x000001,
+    PD_PAGENUMS                   = 0x000002,
+    PD_NOSELECTION                = 0x000004,
+    PD_NOPAGENUMS                 = 0x000008,
+    PD_COLLATE                    = 0x000010,
+    PD_PRINTTOFILE                = 0x000020,
+    PD_PRINTSETUP                 = 0x000040,
+    PD_NOWARNING                  = 0x000080,
+    PD_RETURNDC                   = 0x000100,
+    PD_RETURNIC                   = 0x000200,
+    PD_RETURNDEFAULT              = 0x000400,
+    PD_SHOWHELP                   = 0x000800,
+    PD_ENABLEPRINTHOOK            = 0x001000,
+    PD_ENABLESETUPHOOK            = 0x002000,
+    PD_ENABLEPRINTTEMPLATE        = 0x004000,
+    PD_ENABLESETUPTEMPLATE        = 0x008000,
+    PD_ENABLEPRINTTEMPLATEHANDLE  = 0x010000,
+    PD_ENABLESETUPTEMPLATEHANDLE  = 0x020000,
+    PD_USEDEVMODECOPIES           = 0x040000,
+    PD_USEDEVMODECOPIESANDCOLLATE = 0x040000,
+    PD_DISABLEPRINTTOFILE         = 0x080000,
+    PD_HIDEPRINTTOFILE            = 0x100000,
+    PD_NONETWORKBUTTON            = 0x200000
+}
+
+//static if (_WIN32_WINNT >= 0x500) {
+    enum : DWORD {
+        PD_CURRENTPAGE      = 0x00400000,
+        PD_NOCURRENTPAGE    = 0x00800000,
+        PD_EXCLUSIONFLAGS   = 0x01000000,
+        PD_USELARGETEMPLATE = 0x10000000,
+    }
+
+    enum : HRESULT {
+        PD_RESULT_CANCEL,
+        PD_RESULT_PRINT,
+        PD_RESULT_APPLY
+    }
+
+enum DWORD START_PAGE_GENERAL = 0xFFFFFFFF;
+//}
+
+enum {
+    PSD_DEFAULTMINMARGINS             = 0,
+    PSD_INWININIINTLMEASURE           = 0,
+    PSD_MINMARGINS                    = 0x000001,
+    PSD_MARGINS                       = 0x000002,
+    PSD_INTHOUSANDTHSOFINCHES         = 0x000004,
+    PSD_INHUNDREDTHSOFMILLIMETERS     = 0x000008,
+    PSD_DISABLEMARGINS                = 0x000010,
+    PSD_DISABLEPRINTER                = 0x000020,
+    PSD_NOWARNING                     = 0x000080,
+    PSD_DISABLEORIENTATION            = 0x000100,
+    PSD_DISABLEPAPER                  = 0x000200,
+    PSD_RETURNDEFAULT                 = 0x000400,
+    PSD_SHOWHELP                      = 0x000800,
+    PSD_ENABLEPAGESETUPHOOK           = 0x002000,
+    PSD_ENABLEPAGESETUPTEMPLATE       = 0x008000,
+    PSD_ENABLEPAGESETUPTEMPLATEHANDLE = 0x020000,
+    PSD_ENABLEPAGEPAINTHOOK           = 0x040000,
+    PSD_DISABLEPAGEPAINTING           = 0x080000
+}
+
+enum : UINT {
+    WM_PSD_PAGESETUPDLG = WM_USER,
+    WM_PSD_FULLPAGERECT,
+    WM_PSD_MINMARGINRECT,
+    WM_PSD_MARGINRECT,
+    WM_PSD_GREEKTEXTRECT,
+    WM_PSD_ENVSTAMPRECT,
+    WM_PSD_YAFULLPAGERECT // = WM_USER + 6
+}
+
+enum : int {
+    CD_LBSELNOITEMS = -1,
+    CD_LBSELCHANGE,
+    CD_LBSELSUB,
+    CD_LBSELADD
+}
+
+enum WORD DN_DEFAULTPRN = 1;
+
+/+
+// Both MinGW and the windows docs indicate that there are macros for the send messages
+// the controls. These seem to be totally unnecessary -- and at least one of MinGW or
+// Windows Docs is buggy!
+
+int CommDlg_OpenSave_GetSpec(HWND hWndControl, LPARAM lparam, WPARAM wParam) {
+    return SendMessage(hWndControl, CDM_GETSPEC, wParam, lParam);
+}
+
+int CommDlg_OpenSave_GetFilePath(HWND hWndControl, LPARAM lparam, WPARAM wParam) {
+    return SendMessage(hWndControl, CDM_GETFILEPATH, wParam, lParam);
+}
+
+int CommDlg_OpenSave_GetFolderPath(HWND hWndControl, LPARAM lparam, WPARAM wParam) {
+    return SendMessage(hWndControl, CDM_GETFOLDERPATH, wParam, lParam);
+}
+
+int CommDlg_OpenSave_GetFolderIDList(HWND hWndControl, LPARAM lparam, WPARAM wParam) {
+    return SendMessage(hWndControl, CDM_GETFOLDERIDLIST, wParam, lParam);
+}
+
+void CommDlg_OpenSave_SetControlText(HWND hWndControl, LPARAM lparam, WPARAM wParam) {
+    return SendMessage(hWndControl, CDM_SETCONTROLTEXT, wParam, lParam);
+}
+
+void CommDlg_OpenSave_HideControl(HWND hWndControl, WPARAM wParam) {
+    return SendMessage(hWndControl, CDM_HIDECONTROL, wParam, 0);
+}
+
+void CommDlg_OpenSave_SetDefExt(HWND hWndControl, TCHAR* lparam) {
+    return SendMessage(hWndControl, CDM_SETCONTROLTEXT, 0, cast(LPARAM)lParam);
+}
+
+// These aliases seem even more unnecessary
+alias CommDlg_OpenSave_GetSpec
+    CommDlg_OpenSave_GetSpecA, CommDlg_OpenSave_GetSpecW;
+alias CommDlg_OpenSave_GetFilePath
+    CommDlg_OpenSave_GetFilePathA, CommDlg_OpenSave_GetFilePathW;
+alias CommDlg_OpenSave_GetFolderPath
+    CommDlg_OpenSave_GetFolderPathA, CommDlg_OpenSave_GetFolderPathW;
++/
+
+// Callbacks.
+extern(Windows) {
+alias UINT_PTR function (HWND, UINT, WPARAM, LPARAM) nothrow
+    LPCCHOOKPROC, LPCFHOOKPROC, LPFRHOOKPROC, LPOFNHOOKPROC,
+    LPPAGEPAINTHOOK, LPPAGESETUPHOOK, LPSETUPHOOKPROC, LPPRINTHOOKPROC;
+}
+
+align (1):
+
+struct CHOOSECOLORA {
+    DWORD        lStructSize = CHOOSECOLORA.sizeof;
+    HWND         hwndOwner;
+    HWND         hInstance;
+    COLORREF     rgbResult;
+    COLORREF*    lpCustColors;
+    DWORD        Flags;
+    LPARAM       lCustData;
+    LPCCHOOKPROC lpfnHook;
+    LPCSTR       lpTemplateName;
+}
+alias CHOOSECOLORA* LPCHOOSECOLORA;
+
+struct CHOOSECOLORW {
+    DWORD        lStructSize = CHOOSECOLORW.sizeof;
+    HWND         hwndOwner;
+    HWND         hInstance;
+    COLORREF     rgbResult;
+    COLORREF*    lpCustColors;
+    DWORD        Flags;
+    LPARAM       lCustData;
+    LPCCHOOKPROC lpfnHook;
+    LPCWSTR      lpTemplateName;
+}
+alias CHOOSECOLORW* LPCHOOSECOLORW;
+
+align (4) struct CHOOSEFONTA {
+    DWORD        lStructSize = CHOOSEFONTA.sizeof;
+    HWND         hwndOwner;
+    HDC          hDC;
+    LPLOGFONTA   lpLogFont;
+    INT          iPointSize;
+    DWORD        Flags;
+    DWORD        rgbColors;
+    LPARAM       lCustData;
+    LPCFHOOKPROC lpfnHook;
+    LPCSTR       lpTemplateName;
+    HINSTANCE    hInstance;
+    LPSTR        lpszStyle;
+    WORD         nFontType;
+    //WORD         ___MISSING_ALIGNMENT__;
+    INT          nSizeMin;
+    INT          nSizeMax;
+}
+alias CHOOSEFONTA* LPCHOOSEFONTA;
+
+align (4) struct CHOOSEFONTW {
+    DWORD        lStructSize = CHOOSEFONTW.sizeof;
+    HWND         hwndOwner;
+    HDC          hDC;
+    LPLOGFONTW   lpLogFont;
+    INT          iPointSize;
+    DWORD        Flags;
+    DWORD        rgbColors;
+    LPARAM       lCustData;
+    LPCFHOOKPROC lpfnHook;
+    LPCWSTR      lpTemplateName;
+    HINSTANCE    hInstance;
+    LPWSTR       lpszStyle;
+    WORD         nFontType;
+    //WORD         ___MISSING_ALIGNMENT__;
+    INT          nSizeMin;
+    INT          nSizeMax;
+}
+alias CHOOSEFONTW* LPCHOOSEFONTW;
+
+struct DEVNAMES {
+    WORD wDriverOffset;
+    WORD wDeviceOffset;
+    WORD wOutputOffset;
+    WORD wDefault;
+}
+alias DEVNAMES* LPDEVNAMES;
+
+struct FINDREPLACEA {
+    DWORD        lStructSize = FINDREPLACEA.sizeof;
+    HWND         hwndOwner;
+    HINSTANCE    hInstance;
+    DWORD        Flags;
+    LPSTR        lpstrFindWhat;
+    LPSTR        lpstrReplaceWith;
+    WORD         wFindWhatLen;
+    WORD         wReplaceWithLen;
+    LPARAM       lCustData;
+    LPFRHOOKPROC lpfnHook;
+    LPCSTR       lpTemplateName;
+}
+alias FINDREPLACEA* LPFINDREPLACEA;
+
+struct FINDREPLACEW {
+    DWORD        lStructSize = FINDREPLACEW.sizeof;
+    HWND         hwndOwner;
+    HINSTANCE    hInstance;
+    DWORD        Flags;
+    LPWSTR       lpstrFindWhat;
+    LPWSTR       lpstrReplaceWith;
+    WORD         wFindWhatLen;
+    WORD         wReplaceWithLen;
+    LPARAM       lCustData;
+    LPFRHOOKPROC lpfnHook;
+    LPCWSTR      lpTemplateName;
+}
+alias FINDREPLACEW* LPFINDREPLACEW;
+
+struct OPENFILENAMEA {
+    DWORD         lStructSize = OPENFILENAMEA.sizeof;
+    HWND          hwndOwner;
+    HINSTANCE     hInstance;
+    LPCSTR        lpstrFilter;
+    LPSTR         lpstrCustomFilter;
+    DWORD         nMaxCustFilter;
+    DWORD         nFilterIndex;
+    LPSTR         lpstrFile;
+    DWORD         nMaxFile;
+    LPSTR         lpstrFileTitle;
+    DWORD         nMaxFileTitle;
+    LPCSTR        lpstrInitialDir;
+    LPCSTR        lpstrTitle;
+    DWORD         Flags;
+    WORD          nFileOffset;
+    WORD          nFileExtension;
+    LPCSTR        lpstrDefExt;
+    LPARAM        lCustData;
+    LPOFNHOOKPROC lpfnHook;
+    LPCSTR        lpTemplateName;
+
+    //static if (_WIN32_WINNT >= 0x500) {
+        void          *pvReserved;
+        DWORD         dwReserved;
+        DWORD         FlagsEx;
+    //}
+}
+alias OPENFILENAMEA* LPOPENFILENAMEA;
+
+struct OPENFILENAMEW {
+    DWORD         lStructSize = OPENFILENAMEW.sizeof;
+    HWND          hwndOwner;
+    HINSTANCE     hInstance;
+    LPCWSTR       lpstrFilter;
+    LPWSTR        lpstrCustomFilter;
+    DWORD         nMaxCustFilter;
+    DWORD         nFilterIndex;
+    LPWSTR        lpstrFile;
+    DWORD         nMaxFile;
+    LPWSTR        lpstrFileTitle;
+    DWORD         nMaxFileTitle;
+    LPCWSTR       lpstrInitialDir;
+    LPCWSTR       lpstrTitle;
+    DWORD         Flags;
+    WORD          nFileOffset;
+    WORD          nFileExtension;
+    LPCWSTR       lpstrDefExt;
+    LPARAM        lCustData;
+    LPOFNHOOKPROC lpfnHook;
+    LPCWSTR       lpTemplateName;
+
+    //static if (_WIN32_WINNT >= 0x500) {
+        void          *pvReserved;
+        DWORD         dwReserved;
+        DWORD         FlagsEx;
+    //}
+}
+alias OPENFILENAMEW* LPOPENFILENAMEW;
+
+enum size_t OPENFILENAME_SIZE_VERSION_400 = 76;
+
+struct OFNOTIFYA {
+    NMHDR           hdr;
+    LPOPENFILENAMEA lpOFN;
+    LPSTR           pszFile;
+}
+alias OFNOTIFYA* LPOFNOTIFYA;
+
+struct OFNOTIFYW {
+    NMHDR           hdr;
+    LPOPENFILENAMEW lpOFN;
+    LPWSTR          pszFile;
+}
+alias OFNOTIFYW* LPOFNOTIFYW;
+
+struct PAGESETUPDLGA {
+    DWORD           lStructSize = PAGESETUPDLGA.sizeof;
+    HWND            hwndOwner;
+    HGLOBAL         hDevMode;
+    HGLOBAL         hDevNames;
+    DWORD           Flags;
+    POINT           ptPaperSize;
+    RECT            rtMinMargin;
+    RECT            rtMargin;
+    HINSTANCE       hInstance;
+    LPARAM          lCustData;
+    LPPAGESETUPHOOK lpfnPageSetupHook;
+    LPPAGEPAINTHOOK lpfnPagePaintHook;
+    LPCSTR          lpPageSetupTemplateName;
+    HGLOBAL         hPageSetupTemplate;
+}
+alias PAGESETUPDLGA* LPPAGESETUPDLGA;
+
+struct PAGESETUPDLGW {
+    DWORD           lStructSize = PAGESETUPDLGW.sizeof;
+    HWND            hwndOwner;
+    HGLOBAL         hDevMode;
+    HGLOBAL         hDevNames;
+    DWORD           Flags;
+    POINT           ptPaperSize;
+    RECT            rtMinMargin;
+    RECT            rtMargin;
+    HINSTANCE       hInstance;
+    LPARAM          lCustData;
+    LPPAGESETUPHOOK lpfnPageSetupHook;
+    LPPAGEPAINTHOOK lpfnPagePaintHook;
+    LPCWSTR         lpPageSetupTemplateName;
+    HGLOBAL         hPageSetupTemplate;
+}
+alias PAGESETUPDLGW* LPPAGESETUPDLGW;
+
+struct PRINTDLGA {
+    DWORD           lStructSize = PRINTDLGA.sizeof;
+    HWND            hwndOwner;
+    HANDLE          hDevMode;
+    HANDLE          hDevNames;
+    HDC             hDC;
+    DWORD           Flags;
+    WORD            nFromPage;
+    WORD            nToPage;
+    WORD            nMinPage;
+    WORD            nMaxPage;
+    WORD            nCopies;
+    HINSTANCE       hInstance;
+    LPARAM          lCustData;
+    LPPRINTHOOKPROC lpfnPrintHook;
+    LPSETUPHOOKPROC lpfnSetupHook;
+    LPCSTR          lpPrintTemplateName;
+    LPCSTR          lpSetupTemplateName;
+    HANDLE          hPrintTemplate;
+    HANDLE          hSetupTemplate;
+}
+alias PRINTDLGA* LPPRINTDLGA;
+
+struct PRINTDLGW {
+    DWORD           lStructSize = PRINTDLGW.sizeof;
+    HWND            hwndOwner;
+    HANDLE          hDevMode;
+    HANDLE          hDevNames;
+    HDC             hDC;
+    DWORD           Flags;
+    WORD            nFromPage;
+    WORD            nToPage;
+    WORD            nMinPage;
+    WORD            nMaxPage;
+    WORD            nCopies;
+    HINSTANCE       hInstance;
+    LPARAM          lCustData;
+    LPPRINTHOOKPROC lpfnPrintHook;
+    LPSETUPHOOKPROC lpfnSetupHook;
+    LPCWSTR         lpPrintTemplateName;
+    LPCWSTR         lpSetupTemplateName;
+    HANDLE          hPrintTemplate;
+    HANDLE          hSetupTemplate;
+}
+alias PRINTDLGW* LPPRINTDLGW;
+
+//static if (_WIN32_WINNT >= 0x500) {
+    import core.sys.windows.unknwn; // for LPUNKNOWN
+    import core.sys.windows.prsht;  // for HPROPSHEETPAGE
+
+    struct PRINTPAGERANGE {
+        DWORD  nFromPage;
+        DWORD  nToPage;
+    }
+    alias PRINTPAGERANGE* LPPRINTPAGERANGE;
+
+    struct PRINTDLGEXA {
+        DWORD            lStructSize = PRINTDLGEXA.sizeof;
+        HWND             hwndOwner;
+        HGLOBAL          hDevMode;
+        HGLOBAL          hDevNames;
+        HDC              hDC;
+        DWORD            Flags;
+        DWORD            Flags2;
+        DWORD            ExclusionFlags;
+        DWORD            nPageRanges;
+        DWORD            nMaxPageRanges;
+        LPPRINTPAGERANGE lpPageRanges;
+        DWORD            nMinPage;
+        DWORD            nMaxPage;
+        DWORD            nCopies;
+        HINSTANCE        hInstance;
+        LPCSTR           lpPrintTemplateName;
+        LPUNKNOWN        lpCallback;
+        DWORD            nPropertyPages;
+        HPROPSHEETPAGE*  lphPropertyPages;
+        DWORD            nStartPage;
+        DWORD            dwResultAction;
+    }
+    alias PRINTDLGEXA* LPPRINTDLGEXA;
+
+    struct PRINTDLGEXW {
+        DWORD            lStructSize = PRINTDLGEXW.sizeof;
+        HWND             hwndOwner;
+        HGLOBAL          hDevMode;
+        HGLOBAL          hDevNames;
+        HDC              hDC;
+        DWORD            Flags;
+        DWORD            Flags2;
+        DWORD            ExclusionFlags;
+        DWORD            nPageRanges;
+        DWORD            nMaxPageRanges;
+        LPPRINTPAGERANGE lpPageRanges;
+        DWORD            nMinPage;
+        DWORD            nMaxPage;
+        DWORD            nCopies;
+        HINSTANCE        hInstance;
+        LPCWSTR          lpPrintTemplateName;
+        LPUNKNOWN        lpCallback;
+        DWORD            nPropertyPages;
+        HPROPSHEETPAGE*  lphPropertyPages;
+        DWORD            nStartPage;
+        DWORD            dwResultAction;
+    }
+    alias PRINTDLGEXW* LPPRINTDLGEXW;
+
+//} // _WIN32_WINNT >= 0x500
+
+extern (Windows) nothrow @nogc {
+    BOOL ChooseColorA(LPCHOOSECOLORA);
+    BOOL ChooseColorW(LPCHOOSECOLORW);
+    BOOL ChooseFontA(LPCHOOSEFONTA);
+    BOOL ChooseFontW(LPCHOOSEFONTW);
+    DWORD CommDlgExtendedError();
+    HWND FindTextA(LPFINDREPLACEA);
+    HWND FindTextW(LPFINDREPLACEW);
+    short GetFileTitleA(LPCSTR, LPSTR, WORD);
+    short GetFileTitleW(LPCWSTR, LPWSTR, WORD);
+    BOOL GetOpenFileNameA(LPOPENFILENAMEA);
+    BOOL GetOpenFileNameW(LPOPENFILENAMEW);
+    BOOL GetSaveFileNameA(LPOPENFILENAMEA);
+    BOOL GetSaveFileNameW(LPOPENFILENAMEW);
+    BOOL PageSetupDlgA(LPPAGESETUPDLGA);
+    BOOL PageSetupDlgW(LPPAGESETUPDLGW);
+    BOOL PrintDlgA(LPPRINTDLGA);
+    BOOL PrintDlgW(LPPRINTDLGW);
+    HWND ReplaceTextA(LPFINDREPLACEA);
+    HWND ReplaceTextW(LPFINDREPLACEW);
+
+    //static if (_WIN32_WINNT >= 0x500) {
+        HRESULT PrintDlgExA(LPPRINTDLGEXA);
+        HRESULT PrintDlgExW(LPPRINTDLGEXW);
+    //}
+}
+
+version (Unicode) {
+    alias CHOOSECOLORW CHOOSECOLOR;
+    alias CHOOSEFONTW CHOOSEFONT;
+    alias FINDREPLACEW FINDREPLACE;
+    alias OPENFILENAMEW OPENFILENAME;
+    alias OFNOTIFYW OFNOTIFY;
+    alias PAGESETUPDLGW PAGESETUPDLG;
+    alias PRINTDLGW PRINTDLG;
+
+    alias ChooseColorW ChooseColor;
+    alias ChooseFontW ChooseFont;
+    alias FindTextW FindText;
+    alias GetFileTitleW GetFileTitle;
+    alias GetOpenFileNameW GetOpenFileName;
+    alias GetSaveFileNameW GetSaveFileName;
+    alias PageSetupDlgW PageSetupDlg;
+    alias PrintDlgW PrintDlg;
+    alias ReplaceTextW ReplaceText;
+
+    //static if (_WIN32_WINNT >= 0x500) {
+        alias PRINTDLGEXW PRINTDLGEX;
+        alias PrintDlgExW PrintDlgEx;
+    //}
+
+} else { // UNICODE
+
+    alias CHOOSECOLORA CHOOSECOLOR;
+    alias CHOOSEFONTA CHOOSEFONT;
+    alias FINDREPLACEA FINDREPLACE;
+    alias OPENFILENAMEA OPENFILENAME;
+    alias OFNOTIFYA OFNOTIFY;
+    alias PAGESETUPDLGA PAGESETUPDLG;
+    alias PRINTDLGA PRINTDLG;
+
+    alias ChooseColorA ChooseColor;
+    alias ChooseFontA ChooseFont;
+    alias FindTextA FindText;
+    alias GetFileTitleA GetFileTitle;
+    alias GetOpenFileNameA GetOpenFileName;
+    alias GetSaveFileNameA GetSaveFileName;
+    alias PageSetupDlgA PageSetupDlg;
+    alias PrintDlgA PrintDlg;
+    alias ReplaceTextA ReplaceText;
+
+    //static if (_WIN32_WINNT >= 0x500) {
+        alias PRINTDLGEXA PRINTDLGEX;
+        alias PrintDlgExA PrintDlgEx;
+    //}
+
+} // UNICODE
+
+alias CHOOSECOLOR* LPCHOOSECOLOR;
+alias CHOOSEFONT* LPCHOOSEFONT;
+alias FINDREPLACE* LPFINDREPLACE;
+alias OPENFILENAME* LPOPENFILENAME;
+alias OFNOTIFY* LPOFNOTIFY;
+alias PAGESETUPDLG* LPPAGESETUPDLG;
+alias PRINTDLG* LPPRINTDLG;
+//static if (_WIN32_WINNT >= 0x500) {
+    alias PRINTDLGEX* LPPRINTDLGEX;
+//}
diff --git a/libphobos/libdruntime/core/sys/windows/core.d b/libphobos/libdruntime/core/sys/windows/core.d
new file mode 100644
index 00000000000..8b355b3e2a6
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/core.d
@@ -0,0 +1,30 @@
+/**
+ * Helper module for the Windows API
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_core.d)
+ */
+module core.sys.windows.core;
+version (Windows):
+
+/**
+ The core Windows API functions.
+
+ Importing this file is equivalent to the C code:
+ ---
+ #define WIN32_LEAN_AND_MEAN
+ #include "windows.h"
+ ---
+
+*/
+
+public import core.sys.windows.windef;
+public import core.sys.windows.winnt;
+public import core.sys.windows.wincon;
+public import core.sys.windows.winbase;
+public import core.sys.windows.wingdi;
+public import core.sys.windows.winuser;
+public import core.sys.windows.winnls;
+public import core.sys.windows.winver;
+public import core.sys.windows.winnetwk;
+public import core.sys.windows.winsvc;
diff --git a/libphobos/libdruntime/core/sys/windows/cpl.d b/libphobos/libdruntime/core/sys/windows/cpl.d
new file mode 100644
index 00000000000..a2fa35a6053
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/cpl.d
@@ -0,0 +1,79 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_cpl.d)
+ */
+module core.sys.windows.cpl;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.windef, core.sys.windows.winuser;
+
+enum : uint {
+    WM_CPL_LAUNCH = WM_USER + 1000,
+    WM_CPL_LAUNCHED
+}
+
+enum : uint {
+    CPL_DYNAMIC_RES,
+    CPL_INIT,
+    CPL_GETCOUNT,
+    CPL_INQUIRE,
+    CPL_SELECT,
+    CPL_DBLCLK,
+    CPL_STOP,
+    CPL_EXIT,
+    CPL_NEWINQUIRE,
+    CPL_STARTWPARMSA,
+    CPL_STARTWPARMSW, // = 10
+    CPL_SETUP = 200
+}
+
+extern (Windows) alias LONG function(HWND, UINT, LONG, LONG) APPLET_PROC;
+
+struct CPLINFO {
+    int  idIcon;
+    int  idName;
+    int  idInfo;
+    LONG lData;
+}
+alias CPLINFO* LPCPLINFO;
+
+struct NEWCPLINFOA {
+    DWORD     dwSize = NEWCPLINFOA.sizeof;
+    DWORD     dwFlags;
+    DWORD     dwHelpContext;
+    LONG      lData;
+    HICON     hIcon;
+    CHAR[32]  szName;
+    CHAR[64]  szInfo;
+    CHAR[128] szHelpFile;
+}
+alias NEWCPLINFOA* LPNEWCPLINFOA;
+
+struct NEWCPLINFOW {
+    DWORD      dwSize = NEWCPLINFOW.sizeof;
+    DWORD      dwFlags;
+    DWORD      dwHelpContext;
+    LONG       lData;
+    HICON      hIcon;
+    WCHAR[32]  szName;
+    WCHAR[64]  szInfo;
+    WCHAR[128] szHelpFile;
+}
+alias NEWCPLINFOW* LPNEWCPLINFOW;
+
+version (Unicode) {
+    alias CPL_STARTWPARMSW CPL_STARTWPARMS;
+    alias NEWCPLINFOW NEWCPLINFO;
+} else {
+    alias CPL_STARTWPARMSA CPL_STARTWPARMS;
+    alias NEWCPLINFOA NEWCPLINFO;
+}
+
+alias NEWCPLINFO* LPNEWCPLINFO;
diff --git a/libphobos/libdruntime/core/sys/windows/cplext.d b/libphobos/libdruntime/core/sys/windows/cplext.d
new file mode 100644
index 00000000000..89d892e2956
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/cplext.d
@@ -0,0 +1,19 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.10
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_cplext.d)
+ */
+module core.sys.windows.cplext;
+version (Windows):
+
+enum : uint {
+    CPLPAGE_MOUSE_BUTTONS      = 1,
+    CPLPAGE_MOUSE_PTRMOTION    = 2,
+    CPLPAGE_MOUSE_WHEEL        = 3,
+    CPLPAGE_KEYBOARD_SPEED     = 1,
+    CPLPAGE_DISPLAY_BACKGROUND = 1
+}
diff --git a/libphobos/libdruntime/core/sys/windows/custcntl.d b/libphobos/libdruntime/core/sys/windows/custcntl.d
new file mode 100644
index 00000000000..4044ec3153c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/custcntl.d
@@ -0,0 +1,124 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_custcntl.d)
+ */
+module core.sys.windows.custcntl;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.windef;
+
+// FIXME: check type
+enum CCF_NOTEXT = 1;
+
+enum size_t
+    CCHCCCLASS =  32,
+    CCHCCDESC  =  32,
+    CCHCCTEXT  = 256;
+
+struct CCSTYLEA {
+    DWORD           flStyle;
+    DWORD           flExtStyle;
+    CHAR[CCHCCTEXT] szText;
+    LANGID          lgid;
+    WORD            wReserved1;
+}
+alias CCSTYLEA* LPCCSTYLEA;
+
+struct CCSTYLEW {
+    DWORD            flStyle;
+    DWORD            flExtStyle;
+    WCHAR[CCHCCTEXT] szText;
+    LANGID           lgid;
+    WORD             wReserved1;
+}
+alias CCSTYLEW* LPCCSTYLEW;
+
+struct CCSTYLEFLAGA {
+    DWORD flStyle;
+    DWORD flStyleMask;
+    LPSTR pszStyle;
+}
+alias CCSTYLEFLAGA* LPCCSTYLEFLAGA;
+
+struct CCSTYLEFLAGW {
+    DWORD  flStyle;
+    DWORD  flStyleMask;
+    LPWSTR pszStyle;
+}
+alias CCSTYLEFLAGW* LPCCSTYLEFLAGW;
+
+struct CCINFOA {
+    CHAR[CCHCCCLASS]  szClass;
+    DWORD             flOptions;
+    CHAR[CCHCCDESC]   szDesc;
+    UINT              cxDefault;
+    UINT              cyDefault;
+    DWORD             flStyleDefault;
+    DWORD             flExtStyleDefault;
+    DWORD             flCtrlTypeMask;
+    CHAR[CCHCCTEXT]   szTextDefault;
+    INT               cStyleFlags;
+    LPCCSTYLEFLAGA    aStyleFlags;
+    LPFNCCSTYLEA      lpfnStyle;
+    LPFNCCSIZETOTEXTA lpfnSizeToText;
+    DWORD             dwReserved1;
+    DWORD             dwReserved2;
+}
+alias CCINFOA* LPCCINFOA;
+
+struct CCINFOW {
+    WCHAR[CCHCCCLASS] szClass;
+    DWORD             flOptions;
+    WCHAR[CCHCCDESC]  szDesc;
+    UINT              cxDefault;
+    UINT              cyDefault;
+    DWORD             flStyleDefault;
+    DWORD             flExtStyleDefault;
+    DWORD             flCtrlTypeMask;
+    WCHAR[CCHCCTEXT]  szTextDefault;
+    INT               cStyleFlags;
+    LPCCSTYLEFLAGW    aStyleFlags;
+    LPFNCCSTYLEW      lpfnStyle;
+    LPFNCCSIZETOTEXTW lpfnSizeToText;
+    DWORD             dwReserved1;
+    DWORD             dwReserved2;
+}
+alias CCINFOW* LPCCINFOW;
+
+extern (Windows) {
+    alias BOOL function(HWND, LPCCSTYLEA) LPFNCCSTYLEA;
+    alias BOOL function(HWND, LPCCSTYLEW) LPFNCCSTYLEW;
+    alias INT function(DWORD, DWORD, HFONT, LPSTR) LPFNCCSIZETOTEXTA;
+    alias INT function(DWORD, DWORD, HFONT, LPWSTR) LPFNCCSIZETOTEXTW;
+    alias UINT function(LPCCINFOA) LPFNCCINFOA;
+    alias UINT function(LPCCINFOW) LPFNCCINFOW;
+    UINT CustomControlInfoA(LPCCINFOA acci);
+    UINT CustomControlInfoW(LPCCINFOW acci);
+}
+
+version (Unicode) {
+    alias CCSTYLEW CCSTYLE;
+    alias CCSTYLEFLAGW CCSTYLEFLAG;
+    alias CCINFOW CCINFO;
+    alias LPFNCCSTYLEW LPFNCCSTYLE;
+    alias LPFNCCSIZETOTEXTW LPFNCCSIZETOTEXT;
+    alias LPFNCCINFOW LPFNCCINFO;
+} else {
+    alias CCSTYLEA CCSTYLE;
+    alias CCSTYLEFLAGA CCSTYLEFLAG;
+    alias CCINFOA CCINFO;
+    alias LPFNCCSTYLEA LPFNCCSTYLE;
+    alias LPFNCCSIZETOTEXTA LPFNCCSIZETOTEXT;
+    alias LPFNCCINFOA LPFNCCINFO;
+}
+
+alias CCSTYLE* LPCCSTYLE;
+alias CCSTYLEFLAG* LPCCSTYLEFLAG;
+alias CCINFO* LPCCINFO;
diff --git a/libphobos/libdruntime/core/sys/windows/dbghelp.d b/libphobos/libdruntime/core/sys/windows/dbghelp.d
new file mode 100644
index 00000000000..aa00b6921bf
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/dbghelp.d
@@ -0,0 +1,107 @@
+/**
+ * ...
+ *
+ * Copyright: Copyright Benjamin Thaut 2010 - 2011.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Benjamin Thaut, Sean Kelly
+ * Source:    $(DRUNTIMESRC core/sys/windows/_stacktrace.d)
+ */
+
+module core.sys.windows.dbghelp;
+version (Windows):
+
+import core.sys.windows.windows;
+
+public import core.sys.windows.dbghelp_types;
+
+extern(System)
+{
+    alias BOOL         function(HANDLE hProcess, DWORD64 lpBaseAddress, PVOID lpBuffer, DWORD nSize, LPDWORD lpNumberOfBytesRead) ReadProcessMemoryProc64;
+    alias PVOID        function(HANDLE hProcess, DWORD64 AddrBase) FunctionTableAccessProc64;
+    alias DWORD64      function(HANDLE hProcess, DWORD64 Address) GetModuleBaseProc64;
+    alias DWORD64      function(HANDLE hProcess, HANDLE hThread, ADDRESS64 *lpaddr) TranslateAddressProc64;
+
+    alias BOOL         function(HANDLE hProcess, PCSTR UserSearchPath, bool fInvadeProcess) SymInitializeFunc;
+    alias BOOL         function(HANDLE hProcess) SymCleanupFunc;
+    alias DWORD        function(DWORD SymOptions) SymSetOptionsFunc;
+    alias DWORD        function() SymGetOptionsFunc;
+    alias PVOID        function(HANDLE hProcess, DWORD64 AddrBase) SymFunctionTableAccess64Func;
+    alias BOOL         function(DWORD MachineType, HANDLE hProcess, HANDLE hThread, STACKFRAME64 *StackFrame, PVOID ContextRecord,
+                                ReadProcessMemoryProc64 ReadMemoryRoutine, FunctionTableAccessProc64 FunctoinTableAccess,
+                                GetModuleBaseProc64 GetModuleBaseRoutine, TranslateAddressProc64 TranslateAddress) StackWalk64Func;
+    alias BOOL         function(HANDLE hProcess, DWORD64 dwAddr, PDWORD pdwDisplacement, IMAGEHLP_LINEA64 *line) SymGetLineFromAddr64Func;
+    alias DWORD64      function(HANDLE hProcess, DWORD64 dwAddr) SymGetModuleBase64Func;
+    alias BOOL         function(HANDLE hProcess, DWORD64 dwAddr, IMAGEHLP_MODULEA64 *ModuleInfo) SymGetModuleInfo64Func;
+    alias BOOL         function(HANDLE hProcess, DWORD64 Address, DWORD64 *Displacement, IMAGEHLP_SYMBOLA64 *Symbol) SymGetSymFromAddr64Func;
+    alias DWORD        function(PCTSTR DecoratedName, PTSTR UnDecoratedName, DWORD UndecoratedLength, DWORD Flags) UnDecorateSymbolNameFunc;
+    alias DWORD64      function(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll) SymLoadModule64Func;
+    alias BOOL         function(HANDLE HProcess, PTSTR SearchPath, DWORD SearchPathLength) SymGetSearchPathFunc;
+    alias BOOL         function(HANDLE hProcess, DWORD64 Address) SymUnloadModule64Func;
+    alias BOOL         function(HANDLE hProcess, ULONG ActionCode, ulong CallbackContext, ulong UserContext) PSYMBOL_REGISTERED_CALLBACK64;
+    alias BOOL         function(HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ulong UserContext) SymRegisterCallback64Func;
+    alias API_VERSION* function() ImagehlpApiVersionFunc;
+}
+
+struct DbgHelp
+{
+    SymInitializeFunc        SymInitialize;
+    SymCleanupFunc           SymCleanup;
+    StackWalk64Func          StackWalk64;
+    SymGetOptionsFunc        SymGetOptions;
+    SymSetOptionsFunc        SymSetOptions;
+    SymFunctionTableAccess64Func SymFunctionTableAccess64;
+    SymGetLineFromAddr64Func SymGetLineFromAddr64;
+    SymGetModuleBase64Func   SymGetModuleBase64;
+    SymGetModuleInfo64Func   SymGetModuleInfo64;
+    SymGetSymFromAddr64Func  SymGetSymFromAddr64;
+    UnDecorateSymbolNameFunc UnDecorateSymbolName;
+    SymLoadModule64Func      SymLoadModule64;
+    SymGetSearchPathFunc     SymGetSearchPath;
+    SymUnloadModule64Func    SymUnloadModule64;
+    SymRegisterCallback64Func SymRegisterCallback64;
+    ImagehlpApiVersionFunc   ImagehlpApiVersion;
+
+    static DbgHelp* get()
+    {
+        if( sm_hndl != sm_hndl.init )
+            return &sm_inst;
+        if( (sm_hndl = LoadLibraryA( "dbghelp.dll" )) != sm_hndl.init )
+        {
+            sm_inst.SymInitialize            = cast(SymInitializeFunc) GetProcAddress(sm_hndl,"SymInitialize");
+            sm_inst.SymCleanup               = cast(SymCleanupFunc) GetProcAddress(sm_hndl,"SymCleanup");
+            sm_inst.StackWalk64              = cast(StackWalk64Func) GetProcAddress(sm_hndl,"StackWalk64");
+            sm_inst.SymGetOptions            = cast(SymGetOptionsFunc) GetProcAddress(sm_hndl,"SymGetOptions");
+            sm_inst.SymSetOptions            = cast(SymSetOptionsFunc) GetProcAddress(sm_hndl,"SymSetOptions");
+            sm_inst.SymFunctionTableAccess64 = cast(SymFunctionTableAccess64Func) GetProcAddress(sm_hndl,"SymFunctionTableAccess64");
+            sm_inst.SymGetLineFromAddr64     = cast(SymGetLineFromAddr64Func) GetProcAddress(sm_hndl,"SymGetLineFromAddr64");
+            sm_inst.SymGetModuleBase64       = cast(SymGetModuleBase64Func) GetProcAddress(sm_hndl,"SymGetModuleBase64");
+            sm_inst.SymGetModuleInfo64       = cast(SymGetModuleInfo64Func) GetProcAddress(sm_hndl,"SymGetModuleInfo64");
+            sm_inst.SymGetSymFromAddr64      = cast(SymGetSymFromAddr64Func) GetProcAddress(sm_hndl,"SymGetSymFromAddr64");
+            sm_inst.SymLoadModule64          = cast(SymLoadModule64Func) GetProcAddress(sm_hndl,"SymLoadModule64");
+            sm_inst.SymGetSearchPath         = cast(SymGetSearchPathFunc) GetProcAddress(sm_hndl,"SymGetSearchPath");
+            sm_inst.SymUnloadModule64        = cast(SymUnloadModule64Func) GetProcAddress(sm_hndl,"SymUnloadModule64");
+            sm_inst.SymRegisterCallback64    = cast(SymRegisterCallback64Func) GetProcAddress(sm_hndl, "SymRegisterCallback64");
+            sm_inst.ImagehlpApiVersion       = cast(ImagehlpApiVersionFunc) GetProcAddress(sm_hndl, "ImagehlpApiVersion");
+            assert( sm_inst.SymInitialize && sm_inst.SymCleanup && sm_inst.StackWalk64 && sm_inst.SymGetOptions &&
+                    sm_inst.SymSetOptions && sm_inst.SymFunctionTableAccess64 && sm_inst.SymGetLineFromAddr64 &&
+                    sm_inst.SymGetModuleBase64 && sm_inst.SymGetModuleInfo64 && sm_inst.SymGetSymFromAddr64 &&
+                    sm_inst.SymLoadModule64 && sm_inst.SymGetSearchPath && sm_inst.SymUnloadModule64 &&
+                    sm_inst.SymRegisterCallback64 && sm_inst.ImagehlpApiVersion);
+
+            return &sm_inst;
+        }
+        return null;
+    }
+
+    shared static ~this()
+    {
+        if( sm_hndl != sm_hndl.init )
+            FreeLibrary( sm_hndl );
+    }
+
+private:
+    __gshared DbgHelp sm_inst;
+    __gshared HANDLE  sm_hndl;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/dbghelp_types.d b/libphobos/libdruntime/core/sys/windows/dbghelp_types.d
new file mode 100644
index 00000000000..ff52c565e1d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/dbghelp_types.d
@@ -0,0 +1,233 @@
+/**
+ * ...
+ *
+ * Copyright: Copyright Benjamin Thaut 2010 - 2011.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Benjamin Thaut, Sean Kelly
+ * Source:    $(DRUNTIMESRC core/sys/windows/_dbghelp_types.d)
+ */
+
+module core.sys.windows.dbghelp_types;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+import core.sys.windows.windows;
+
+public import core.sys.windows.winnt : TCHAR;
+
+/*
+enum ADDRESS_MODE : DWORD
+{
+    AddrMode1616 = 0,
+    AddrMode1632 = 1,
+    AddrModeReal = 2,
+    AddrModeFlat = 3,
+}
+*/
+enum : DWORD
+{
+    SYMOPT_DEFERRED_LOAD        = 0x00000004,
+    SYMOPT_FAIL_CRITICAL_ERRORS = 0x00000200,
+    SYMOPT_LOAD_LINES           = 0x00000010,
+    SYMOPT_DEBUG                = 0x80000000,
+}
+
+enum : ULONG
+{
+    CBA_READ_MEMORY             = 0x00000006,
+    CBA_DEBUG_INFO              = 0x10000000,
+}
+
+public import core.sys.windows.basetyps : GUID;
+
+struct ADDRESS64
+{
+    DWORD64      Offset;
+    WORD         Segment;
+    ADDRESS_MODE Mode;
+}
+
+struct KDHELP64
+{
+    DWORD64 Thread;
+    DWORD   ThCallbackStack;
+    DWORD   ThCallbackBStore;
+    DWORD   NextCallback;
+    DWORD   FramePointer;
+    DWORD64 KiCallUserMode;
+    DWORD64 KeUserCallbackDispatcher;
+    DWORD64 SystemRangeStart;
+    DWORD64 KiUserExceptionDispatcher;
+    DWORD64 StackBase;
+    DWORD64 StackLimit;
+    DWORD64[5] Reserved;
+}
+
+struct STACKFRAME64
+{
+    ADDRESS64  AddrPC;
+    ADDRESS64  AddrReturn;
+    ADDRESS64  AddrFrame;
+    ADDRESS64  AddrStack;
+    ADDRESS64  AddrBStore;
+    PVOID      FuncTableEntry;
+    DWORD64[4] Params;
+    BOOL       Far;
+    BOOL       Virtual;
+    DWORD64[3] Reserved;
+    KDHELP64   KdHelp;
+}
+
+public import core.sys.windows.winnt : IMAGE_FILE_MACHINE_I386, IMAGE_FILE_MACHINE_IA64, IMAGE_FILE_MACHINE_AMD64;
+
+struct IMAGEHLP_LINEA64
+{
+    DWORD   SizeOfStruct;
+    PVOID   Key;
+    DWORD   LineNumber;
+    PCSTR   FileName;
+    DWORD64 Address;
+}
+struct IMAGEHLP_LINEW64
+{
+    DWORD   SizeOfStruct;
+    PVOID   Key;
+    DWORD   LineNumber;
+    PWSTR FileName;
+    DWORD64 Address;
+}
+
+enum SYM_TYPE : int
+{
+    SymNone = 0,
+    SymCoff,
+    SymCv,
+    SymPdb,
+    SymExport,
+    SymDeferred,
+    SymSym,
+    SymDia,
+    SymVirtual,
+    NumSymTypes,
+}
+
+struct IMAGEHLP_MODULEA64
+{
+    DWORD      SizeOfStruct;
+    DWORD64    BaseOfImage;
+    DWORD      ImageSize;
+    DWORD      TimeDateStamp;
+    DWORD      CheckSum;
+    DWORD      NumSyms;
+    SYM_TYPE   SymType;
+    CHAR[32]   ModuleName;
+    CHAR[256]  ImageName;
+    CHAR[256]  LoadedImageName;
+    // new elements: 07-Jun-2002
+    version (none)
+    {
+        CHAR[256]  LoadedPdbName;
+        DWORD      CVSig;
+        CHAR[MAX_PATH*3] CVData;
+        DWORD      PdbSig;
+        GUID       PdbSig70;
+        DWORD      PdbAge;
+        BOOL       PdbUnmatched;
+        BOOL       DbgUnmachted;
+        BOOL       LineNumbers;
+        BOOL       GlobalSymbols;
+        BOOL       TypeInfo;
+    }
+    // new elements: 17-Dec-2003
+    version (none)
+    {
+        BOOL       SourceIndexed;
+        BOOL       Publics;
+    }
+}
+struct IMAGEHLP_MODULEW64
+{
+    DWORD      SizeOfStruct;
+    DWORD64    BaseOfImage;
+    DWORD      ImageSize;
+    DWORD      TimeDateStamp;
+    DWORD      CheckSum;
+    DWORD      NumSyms;
+    SYM_TYPE   SymType;
+    WCHAR[32]  ModuleName;
+    WCHAR[256] ImageName;
+    WCHAR[256] LoadedImageName;
+    // new elements: 07-Jun-2002
+    version (none)
+    {
+        WCHAR[256] LoadedPdbName;
+        DWORD      CVSig;
+        WCHAR[MAX_PATH*3] CVData;
+        DWORD      PdbSig;
+        GUID       PdbSig70;
+        DWORD      PdbAge;
+        BOOL       PdbUnmatched;
+        BOOL       DbgUnmachted;
+        BOOL       LineNumbers;
+        BOOL       GlobalSymbols;
+        BOOL       TypeInfo;
+    }
+    // new elements: 17-Dec-2003
+    version (none)
+    {
+        BOOL       SourceIndexed;
+        BOOL       Publics;
+    }
+}
+
+struct IMAGEHLP_SYMBOLA64
+{
+    DWORD    SizeOfStruct;
+    DWORD64  Address;
+    DWORD    Size;
+    DWORD    Flags;
+    DWORD    MaxNameLength;
+    CHAR[1] Name;
+}
+struct IMAGEHLP_SYMBOLW64
+{
+    DWORD    SizeOfStruct;
+    DWORD64  Address;
+    DWORD    Size;
+    DWORD    Flags;
+    DWORD    MaxNameLength;
+    WCHAR[1] Name;
+}
+
+
+struct IMAGEHLP_CBA_READ_MEMORY
+{
+    DWORD64 addr;
+    PVOID   buf;
+    DWORD   bytes;
+    DWORD   *bytesread;
+}
+
+struct API_VERSION
+{
+    USHORT MajorVersion;
+    USHORT MinorVersion;
+    USHORT Revision;
+    USHORT Reserved;
+}
+
+version (Unicode)
+{
+    alias IMAGEHLP_LINEW64 IMAGEHLP_LINE64;
+    alias IMAGEHLP_MODULEW64 IMAGEHLP_MODULE64;
+    alias IMAGEHLP_SYMBOLW64 IMAGEHLP_SYMBOL64;
+}
+else
+{
+    alias IMAGEHLP_LINEA64 IMAGEHLP_LINE64;
+    alias IMAGEHLP_MODULEA64 IMAGEHLP_MODULE64;
+    alias IMAGEHLP_SYMBOLA64 IMAGEHLP_SYMBOL64;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/dbt.d b/libphobos/libdruntime/core/sys/windows/dbt.d
new file mode 100644
index 00000000000..c97944203ec
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/dbt.d
@@ -0,0 +1,191 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Vladimir Vlasov
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_dbt.d)
+ */
+module core.sys.windows.dbt;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+import core.sys.windows.w32api, core.sys.windows.windef;
+import core.sys.windows.basetyps; // for GUID
+
+// FIXME: clean up Windows version support
+
+enum : DWORD {
+    DBT_NO_DISK_SPACE           = 0x47,
+    DBT_CONFIGMGPRIVATE         = 0x7FFF,
+    DBT_DEVICEARRIVAL           = 0x8000,
+    DBT_DEVICEQUERYREMOVE       = 0x8001,
+    DBT_DEVICEQUERYREMOVEFAILED = 0x8002,
+    DBT_DEVICEREMOVEPENDING     = 0x8003,
+    DBT_DEVICEREMOVECOMPLETE    = 0x8004,
+    DBT_DEVICETYPESPECIFIC      = 0x8005,
+    DBT_DEVTYP_OEM              = 0,
+    DBT_DEVTYP_DEVNODE,
+    DBT_DEVTYP_VOLUME,
+    DBT_DEVTYP_PORT,
+    DBT_DEVTYP_NET,
+    DBT_DEVTYP_DEVICEINTERFACE,
+    DBT_DEVTYP_HANDLE        // = 6
+}
+
+enum : DWORD {
+    DBT_APPYBEGIN,
+    DBT_APPYEND,
+    DBT_DEVNODES_CHANGED     = 7,
+    DBT_QUERYCHANGECONFIG    = 0x17,
+    DBT_CONFIGCHANGED        = 0x18,
+    DBT_CONFIGCHANGECANCELED = 0x19,
+    DBT_MONITORCHANGE        = 0x1B,
+    DBT_SHELLLOGGEDON        = 32,
+    DBT_CONFIGMGAPI32        = 34,
+    DBT_VXDINITCOMPLETE      = 35,
+    DBT_VOLLOCKQUERYLOCK     = 0x8041,
+    DBT_VOLLOCKLOCKTAKEN     = 0x8042,
+    DBT_VOLLOCKLOCKFAILED    = 0x8043,
+    DBT_VOLLOCKQUERYUNLOCK   = 0x8044,
+    DBT_VOLLOCKLOCKRELEASED  = 0x8045,
+    DBT_VOLLOCKUNLOCKFAILED  = 0x8046,
+    DBT_USERDEFINED          = 0xFFFF
+}
+
+enum : WORD {
+    DBTF_MEDIA = 1,
+    DBTF_NET   = 2
+}
+
+enum : DWORD {
+    BSM_ALLCOMPONENTS      = 0,
+    BSM_APPLICATIONS       = 8,
+    BSM_ALLDESKTOPS        = 16,
+    BSM_INSTALLABLEDRIVERS = 4,
+    BSM_NETDRIVER          = 2,
+    BSM_VXDS               = 1,
+    BSF_FLUSHDISK          = 0x00000004,
+    BSF_FORCEIFHUNG        = 0x00000020,
+    BSF_IGNORECURRENTTASK  = 0x00000002,
+    BSF_NOHANG             = 0x00000008,
+    BSF_NOTIMEOUTIFNOTHUNG = 0x00000040,
+    BSF_POSTMESSAGE        = 0x00000010,
+    BSF_QUERY              = 0x00000001,
+    BSF_MSGSRV32ISOK_BIT   = 31,
+    BSF_MSGSRV32ISOK       = 0x80000000
+}
+
+//static if (_WIN32_WINNT >= 0x500) {
+    enum : DWORD {
+        BSF_ALLOWSFW          = 0x00000080,
+        BSF_SENDNOTIFYMESSAGE = 0x00000100
+    }
+//}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum : DWORD {
+        BSF_LUID        = 0x00000400,
+        BSF_RETURNHDESK = 0x00000200
+    }
+}
+
+struct DEV_BROADCAST_HDR {
+    DWORD dbch_size = DEV_BROADCAST_HDR.sizeof;
+    DWORD dbch_devicetype;
+    DWORD dbch_reserved;
+}
+alias DEV_BROADCAST_HDR* PDEV_BROADCAST_HDR;
+
+struct DEV_BROADCAST_OEM {
+    DWORD dbco_size = DEV_BROADCAST_OEM.sizeof;
+    DWORD dbco_devicetype;
+    DWORD dbco_reserved;
+    DWORD dbco_identifier;
+    DWORD dbco_suppfunc;
+}
+alias DEV_BROADCAST_OEM* PDEV_BROADCAST_OEM;
+
+struct DEV_BROADCAST_PORT_A {
+    DWORD dbcp_size = DEV_BROADCAST_PORT_A.sizeof;
+    DWORD dbcp_devicetype;
+    DWORD dbcp_reserved;
+    char  _dbcp_name;
+    char* dbcp_name() return { return &_dbcp_name; }
+}
+alias DEV_BROADCAST_PORT_A* PDEV_BROADCAST_PORT_A;
+
+struct DEV_BROADCAST_PORT_W {
+    DWORD  dbcp_size = DEV_BROADCAST_PORT_W.sizeof;
+    DWORD  dbcp_devicetype;
+    DWORD  dbcp_reserved;
+    WCHAR  _dbcp_name;
+    WCHAR* dbcp_name() return { return &_dbcp_name; }
+}
+alias DEV_BROADCAST_PORT_W* PDEV_BROADCAST_PORT_W;
+
+struct DEV_BROADCAST_USERDEFINED {
+    DEV_BROADCAST_HDR dbud_dbh;
+    char  _dbud_szName;
+    char* dbud_szName() return { return &_dbud_szName; }
+}
+
+struct DEV_BROADCAST_VOLUME {
+    DWORD dbcv_size = DEV_BROADCAST_VOLUME.sizeof;
+    DWORD dbcv_devicetype;
+    DWORD dbcv_reserved;
+    DWORD dbcv_unitmask;
+    WORD  dbcv_flags;
+}
+alias DEV_BROADCAST_VOLUME* PDEV_BROADCAST_VOLUME;
+
+version (Unicode) {
+    alias DEV_BROADCAST_PORT_W DEV_BROADCAST_PORT;
+} else {
+    alias DEV_BROADCAST_PORT_A DEV_BROADCAST_PORT;
+}
+alias DEV_BROADCAST_PORT* PDEV_BROADCAST_PORT;
+
+//static if (_WIN32_WINNT >= 0x500) {
+    struct DEV_BROADCAST_DEVICEINTERFACE_A {
+        DWORD dbcc_size = DEV_BROADCAST_DEVICEINTERFACE_A.sizeof;
+        DWORD dbcc_devicetype;
+        DWORD dbcc_reserved;
+        GUID  dbcc_classguid;
+        char  _dbcc_name;
+        char* dbcc_name() return { return &_dbcc_name; }
+    }
+    alias DEV_BROADCAST_DEVICEINTERFACE_A* PDEV_BROADCAST_DEVICEINTERFACE_A;
+
+    struct DEV_BROADCAST_DEVICEINTERFACE_W {
+        DWORD  dbcc_size = DEV_BROADCAST_DEVICEINTERFACE_W.sizeof;
+        DWORD  dbcc_devicetype;
+        DWORD  dbcc_reserved;
+        GUID   dbcc_classguid;
+        WCHAR  _dbcc_name;
+        WCHAR* dbcc_name() return { return &_dbcc_name; }
+    }
+    alias DEV_BROADCAST_DEVICEINTERFACE_W* PDEV_BROADCAST_DEVICEINTERFACE_W;
+
+    version (Unicode) {
+        alias DEV_BROADCAST_DEVICEINTERFACE_W DEV_BROADCAST_DEVICEINTERFACE;
+    } else {
+        alias DEV_BROADCAST_DEVICEINTERFACE_A DEV_BROADCAST_DEVICEINTERFACE;
+    }
+    alias DEV_BROADCAST_DEVICEINTERFACE* PDEV_BROADCAST_DEVICEINTERFACE;
+
+    struct DEV_BROADCAST_HANDLE {
+        DWORD  dbch_size = DEV_BROADCAST_HANDLE.sizeof;
+        DWORD  dbch_devicetype;
+        DWORD  dbch_reserved;
+        HANDLE dbch_handle;
+        DWORD  dbch_hdevnotify;
+        GUID   dbch_eventguid;
+        LONG   dbch_nameoffset;
+        BYTE   _dbch_data;
+        BYTE*  dbch_data() return { return &_dbch_data; }
+    }
+    alias DEV_BROADCAST_HANDLE* PDEV_BROADCAST_HANDLE;
+//}
diff --git a/libphobos/libdruntime/core/sys/windows/dde.d b/libphobos/libdruntime/core/sys/windows/dde.d
new file mode 100644
index 00000000000..168cbd185a1
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/dde.d
@@ -0,0 +1,215 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_dde.d)
+ */
+module core.sys.windows.dde;
+version (Windows):
+pragma(lib, "user32");
+
+private import core.sys.windows.windef;
+
+enum : uint {
+    WM_DDE_FIRST     = 0x03E0,
+    WM_DDE_INITIATE  = WM_DDE_FIRST,
+    WM_DDE_TERMINATE,
+    WM_DDE_ADVISE,
+    WM_DDE_UNADVISE,
+    WM_DDE_ACK,
+    WM_DDE_DATA,
+    WM_DDE_REQUEST,
+    WM_DDE_POKE,
+    WM_DDE_EXECUTE,
+    WM_DDE_LAST      = WM_DDE_EXECUTE
+}
+
+struct DDEACK {
+    ubyte bAppReturnCode;
+    ubyte _bf;
+
+    @property ubyte reserved() { return cast(ubyte) (_bf & 0x3F); }
+    @property bool  fBusy()    { return cast(bool)  (_bf & 0x40); }
+    @property bool  fAck()     { return cast(bool)  (_bf & 0x80); }
+
+    @property ubyte reserved(ubyte r) {
+        _bf = cast(ubyte) ((_bf & ~0x3F) | (r & 0x3F));
+        return cast(ubyte)(r & 0x3F);
+    }
+
+    @property bool fBusy(bool f) { _bf = cast(ubyte) ((_bf & ~0x40) | (f << 6)); return f; }
+    @property bool fAck(bool f)  { _bf = cast(ubyte) ((_bf & ~0x80) | (f << 7)); return f; }
+}
+
+struct DDEADVISE {
+    ushort _bf;
+    short  cfFormat;
+
+    @property ushort reserved()  { return cast(ushort) (_bf & 0x3FFF); }
+    @property bool   fDeferUpd() { return cast(bool)   (_bf & 0x4000); }
+    @property bool   fAckReq()   { return cast(bool)   (_bf & 0x8000); }
+
+    @property ushort reserved(ushort r) {
+        _bf = cast(ushort) ((_bf & ~0x3FFF) | (r & 0x3FFF));
+        return cast(ushort)(r & 0x3FFF);
+    }
+
+    @property bool   fDeferUpd(bool f) { _bf = cast(ushort) ((_bf & ~0x4000) | (f << 14)); return f; }
+    @property bool   fAckReq(bool f)   { _bf = cast(ushort) ((_bf & ~0x8000) | (f << 15)); return f; }
+}
+
+struct DDEDATA {
+    ushort _bf;
+    short  cfFormat;
+    byte   _Value;
+
+    @property ushort unused()    { return cast(ushort) (_bf & 0x0FFF); }
+    @property bool   fResponse() { return cast(bool)   (_bf & 0x1000); }
+    @property bool   fRelease()  { return cast(bool)   (_bf & 0x2000); }
+    @property bool   reserved()  { return cast(bool)   (_bf & 0x4000); }
+    @property bool   fAckReq()   { return cast(bool)   (_bf & 0x8000); }
+
+    @property byte*  Value() return { return &_Value; }
+
+    @property ushort unused(ushort r) {
+        _bf = cast(ushort) ((_bf & ~0x0FFF) | (r & 0x0FFF));
+        return cast(ushort)(r & 0x0FFF);
+    }
+
+    @property bool   fResponse(bool f) { _bf = cast(ushort) ((_bf & ~0x1000) | (f << 12)); return f; }
+    @property bool   fRelease(bool f)  { _bf = cast(ushort) ((_bf & ~0x2000) | (f << 13)); return f; }
+    @property bool   reserved(bool f)  { _bf = cast(ushort) ((_bf & ~0x4000) | (f << 14)); return f; }
+    @property bool   fAckReq(bool f)   { _bf = cast(ushort) ((_bf & ~0x8000) | (f << 15)); return f; }
+}
+
+struct DDEPOKE {
+    ushort _bf;
+    short  cfFormat;
+    byte   _Value;
+
+    @property ushort unused()    { return cast(ushort) (_bf & 0x1FFF); }
+    @property bool   fRelease()  { return cast(bool)   (_bf & 0x2000); }
+    @property ubyte  fReserved() { return cast(ubyte)  ((_bf & 0xC000) >>> 14); }
+
+    @property byte*  Value() return { return &_Value; }
+
+    @property ushort unused(ushort u) {
+        _bf = cast(ushort) ((_bf & ~0x1FFF) | (u & 0x1FFF));
+        return cast(ushort)(u & 0x1FFF);
+    }
+
+    @property bool   fRelease(bool f)   { _bf = cast(ushort) ((_bf & ~0x2000) | (f << 13)); return f; }
+    @property ubyte  fReserved(ubyte r) { _bf = cast(ushort) ((_bf & ~0xC000) | (r << 14)); return r; }
+}
+
+deprecated struct DDELN {
+    ushort _bf;
+    short  cfFormat;
+
+    @property ushort unused()    { return cast(ushort) (_bf & 0x1FFF); }
+    @property bool   fRelease()  { return cast(bool)   (_bf & 0x2000); }
+    @property bool   fDeferUpd() { return cast(bool)   (_bf & 0x4000); }
+    @property bool   fAckReq()   { return cast(bool)   (_bf & 0x8000); }
+
+    @property ushort unused(ushort u) {
+        _bf = cast(ushort)((_bf & ~0x1FFF) | (u & 0x1FFF));
+        return cast(ushort)(u & 0x1FFF);
+    }
+
+    @property bool   fRelease(bool f)  { _bf = cast(ushort) ((_bf & ~0x2000) | (f << 13)); return f; }
+    @property bool   fDeferUpd(bool f) { _bf = cast(ushort) ((_bf & ~0x4000) | (f << 14)); return f; }
+    @property bool   fAckReq(bool f)   { _bf = cast(ushort) ((_bf & ~0x8000) | (f << 15)); return f; }
+}
+
+deprecated struct DDEUP {
+    ushort _bf;
+    short  cfFormat;
+    byte   _rgb;
+
+    @property ushort unused()    { return cast(ushort) (_bf & 0x0FFF); }
+    @property bool   fAck()      { return cast(bool)   (_bf & 0x1000); }
+    @property bool   fRelease()  { return cast(bool)   (_bf & 0x2000); }
+    @property bool   fReserved() { return cast(bool)   (_bf & 0x4000); }
+    @property bool   fAckReq()   { return cast(bool)   (_bf & 0x8000); }
+
+    @property byte*  rgb() return { return &_rgb; }
+
+    @property ushort unused(ushort r) {
+        _bf = cast(ushort) ((_bf & ~0x0FFF) | (r & 0x0FFF));
+        return cast(ushort)(r & 0x0FFF);
+    }
+
+    @property bool   fAck(bool f)      { _bf = cast(ushort) ((_bf & ~0x1000) | (f << 12)); return f; }
+    @property bool   fRelease(bool f)  { _bf = cast(ushort) ((_bf & ~0x2000) | (f << 13)); return f; }
+    @property bool   fReserved(bool f) { _bf = cast(ushort) ((_bf & ~0x4000) | (f << 14)); return f; }
+    @property bool   fAckReq(bool f)   { _bf = cast(ushort) ((_bf & ~0x8000) | (f << 15)); return f; }
+}
+
+extern (Windows) {
+    BOOL DdeSetQualityOfService(HWND, const(SECURITY_QUALITY_OF_SERVICE)*,
+      PSECURITY_QUALITY_OF_SERVICE);
+    BOOL ImpersonateDdeClientWindow(HWND, HWND);
+    LPARAM PackDDElParam(UINT, UINT_PTR, UINT_PTR);
+    BOOL UnpackDDElParam(UINT, LPARAM, PUINT_PTR, PUINT_PTR);
+    BOOL FreeDDElParam(UINT, LPARAM);
+    LPARAM ReuseDDElParam(LPARAM, UINT, UINT, UINT_PTR, UINT_PTR);
+}
+
+debug (WindowsUnitTest) {
+    unittest {
+        DDEACK ddeack;
+
+        with (ddeack) {
+            reserved = 10;
+            assert (_bf == 0x0A);
+            fBusy = true;
+            assert (_bf == 0x4A);
+            fAck = true;
+            assert (_bf == 0xCA);
+
+            assert (reserved == 10);
+            assert (fBusy == true);
+            assert (fAck == true);
+
+            reserved = 43;
+            assert (_bf == 0xEB);
+            fBusy = false;
+            assert (_bf == 0xAB);
+            fAck = false;
+            assert (_bf == 0x2B);
+
+            assert (reserved == 43);
+            assert (fBusy == false);
+            assert (fAck == false);
+        }
+
+        DDEPOKE ddepoke;
+
+        with (ddepoke) {
+            unused = 3456;
+            assert (_bf == 0x0D80);
+            fRelease = true;
+            assert (_bf == 0x2D80);
+            fReserved = 2;
+            assert (_bf == 0xAD80);
+
+            assert (unused == 3456);
+            assert (fRelease == true);
+            assert (fReserved == 2);
+
+            unused = 2109;
+            assert (_bf == 0xa83d);
+            fRelease = false;
+            assert (_bf == 0x883d);
+            fReserved = 1;
+            assert (_bf == 0x483d);
+
+            assert (unused == 2109);
+            assert (fRelease == false);
+            assert (fReserved == 1);
+        }
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/windows/ddeml.d b/libphobos/libdruntime/core/sys/windows/ddeml.d
new file mode 100644
index 00000000000..9cda322b354
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/ddeml.d
@@ -0,0 +1,379 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_ddeml.d)
+ */
+module core.sys.windows.ddeml;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "user32");
+
+private import core.sys.windows.basetsd, core.sys.windows.windef, core.sys.windows.winnt;
+
+enum : int {
+    CP_WINANSI    = 1004,
+    CP_WINUNICODE = 1200
+}
+
+enum : UINT {
+    XTYPF_NOBLOCK = 2,
+    XTYPF_NODATA  = 4,
+    XTYPF_ACKREQ  = 8
+}
+
+enum : UINT {
+    XCLASS_MASK         = 0xFC00,
+    XCLASS_BOOL         = 0x1000,
+    XCLASS_DATA         = 0x2000,
+    XCLASS_FLAGS        = 0x4000,
+    XCLASS_NOTIFICATION = 0x8000
+}
+
+enum : UINT {
+    XST_NULL,
+    XST_INCOMPLETE,
+    XST_CONNECTED,
+    XST_INIT1,
+    XST_INIT2,
+    XST_REQSENT,
+    XST_DATARCVD,
+    XST_POKESENT,
+    XST_POKEACKRCVD,
+    XST_EXECSENT,
+    XST_EXECACKRCVD,
+    XST_ADVSENT,
+    XST_UNADVSENT,
+    XST_ADVACKRCVD,
+    XST_UNADVACKRCVD,
+    XST_ADVDATASENT,
+    XST_ADVDATAACKRCVD // = 16
+}
+
+enum : UINT {
+    XTYP_ERROR           = XCLASS_NOTIFICATION | XTYPF_NOBLOCK,
+    XTYP_ADVDATA         = 0x0010 | XCLASS_FLAGS,
+    XTYP_ADVREQ          = 0x0020 | XCLASS_DATA | XTYPF_NOBLOCK,
+    XTYP_ADVSTART        = 0x0030 | XCLASS_BOOL,
+    XTYP_ADVSTOP         = 0x0040 | XCLASS_NOTIFICATION,
+    XTYP_EXECUTE         = 0x0050 | XCLASS_FLAGS,
+    XTYP_CONNECT         = 0x0060 | XCLASS_BOOL | XTYPF_NOBLOCK,
+    XTYP_CONNECT_CONFIRM = 0x0070 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK,
+    XTYP_XACT_COMPLETE   = 0x0080 | XCLASS_NOTIFICATION,
+    XTYP_POKE            = 0x0090 | XCLASS_FLAGS,
+    XTYP_REGISTER        = 0x00A0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK,
+    XTYP_REQUEST         = 0x00B0 | XCLASS_DATA,
+    XTYP_DISCONNECT      = 0x00C0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK,
+    XTYP_UNREGISTER      = 0x00D0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK,
+    XTYP_WILDCONNECT     = 0x00E0 | XCLASS_DATA | XTYPF_NOBLOCK,
+    XTYP_MONITOR         = 0X00F0 | XCLASS_NOTIFICATION | XTYPF_NOBLOCK,
+    XTYP_MASK            = 0x00F0,
+    XTYP_SHIFT           = 4
+}
+
+/+
+#define TIMEOUT_ASYNC  0xFFFFFFFF
+#define QID_SYNC       0xFFFFFFFF
++/
+
+enum : UINT {
+    ST_CONNECTED  =   1,
+    ST_ADVISE     =   2,
+    ST_ISLOCAL    =   4,
+    ST_BLOCKED    =   8,
+    ST_CLIENT     =  16,
+    ST_TERMINATED =  32,
+    ST_INLIST     =  64,
+    ST_BLOCKNEXT  = 128,
+    ST_ISSELF     = 256
+}
+
+/+
+#define CADV_LATEACK 0xFFFF
++/
+
+enum : UINT {
+    DMLERR_NO_ERROR      = 0,
+    DMLERR_FIRST         = 0x4000,
+    DMLERR_ADVACKTIMEOUT = DMLERR_FIRST,
+    DMLERR_BUSY,
+    DMLERR_DATAACKTIMEOUT,
+    DMLERR_DLL_NOT_INITIALIZED,
+    DMLERR_DLL_USAGE,
+    DMLERR_EXECACKTIMEOUT,
+    DMLERR_INVALIDPARAMETER,
+    DMLERR_LOW_MEMORY,
+    DMLERR_MEMORY_ERROR,
+    DMLERR_NOTPROCESSED,
+    DMLERR_NO_CONV_ESTABLISHED,
+    DMLERR_POKEACKTIMEOUT,
+    DMLERR_POSTMSG_FAILED,
+    DMLERR_REENTRANCY,
+    DMLERR_SERVER_DIED,
+    DMLERR_SYS_ERROR,
+    DMLERR_UNADVACKTIMEOUT,
+    DMLERR_UNFOUND_QUEUE_ID, // = 0x4011
+    DMLERR_LAST          = DMLERR_UNFOUND_QUEUE_ID
+}
+
+/+
+#define DDE_FACK    0x8000
+#define DDE_FBUSY   0x4000
+#define DDE_FDEFERUPD   0x4000
+#define DDE_FACKREQ 0x8000
+#define DDE_FRELEASE    0x2000
+#define DDE_FREQUESTED  0x1000
+#define DDE_FAPPSTATUS  0x00ff
+#define DDE_FNOTPROCESSED   0
+#define DDE_FACKRESERVED    (~(DDE_FACK|DDE_FBUSY|DDE_FAPPSTATUS))
+#define DDE_FADVRESERVED    (~(DDE_FACKREQ|DDE_FDEFERUPD))
+#define DDE_FDATRESERVED    (~(DDE_FACKREQ|DDE_FRELEASE|DDE_FREQUESTED))
+#define DDE_FPOKRESERVED    (~DDE_FRELEASE)
+#define MSGF_DDEMGR 0x8001
+#define CBR_BLOCK   ((HDDEDATA)0xffffffff)
++/
+
+enum DWORD
+    APPCLASS_STANDARD         = 0,
+    APPCLASS_MONITOR          = 0x00000001,
+    APPCLASS_MASK             = 0x0000000F,
+    APPCMD_CLIENTONLY         = 0x00000010,
+    APPCMD_FILTERINITS        = 0x00000020,
+    APPCMD_MASK               = 0x00000FF0,
+    CBF_FAIL_SELFCONNECTIONS  = 0x00001000,
+    CBF_FAIL_CONNECTIONS      = 0x00002000,
+    CBF_FAIL_ADVISES          = 0x00004000,
+    CBF_FAIL_EXECUTES         = 0x00008000,
+    CBF_FAIL_POKES            = 0x00010000,
+    CBF_FAIL_REQUESTS         = 0x00020000,
+    CBF_FAIL_ALLSVRXACTIONS   = 0x0003f000,
+    CBF_SKIP_CONNECT_CONFIRMS = 0x00040000,
+    CBF_SKIP_REGISTRATIONS    = 0x00080000,
+    CBF_SKIP_UNREGISTRATIONS  = 0x00100000,
+    CBF_SKIP_DISCONNECTS      = 0x00200000,
+    CBF_SKIP_ALLNOTIFICATIONS = 0x003c0000,
+    MF_HSZ_INFO               = 0x01000000,
+    MF_SENDMSGS               = 0x02000000,
+    MF_POSTMSGS               = 0x04000000,
+    MF_CALLBACKS              = 0x08000000,
+    MF_ERRORS                 = 0x10000000,
+    MF_LINKS                  = 0x20000000,
+    MF_CONV                   = 0x40000000,
+    MF_MASK                   = 0xFF000000;
+
+enum : UINT {
+    EC_ENABLEALL    = 0,
+    EC_ENABLEONE    = ST_BLOCKNEXT,
+    EC_DISABLE      = ST_BLOCKED,
+    EC_QUERYWAITING = 2
+}
+
+enum : UINT {
+    DNS_REGISTER   = 1,
+    DNS_UNREGISTER = 2,
+    DNS_FILTERON   = 4,
+    DNS_FILTEROFF  = 8
+}
+
+/+
+#define HDATA_APPOWNED  1
+#define MAX_MONITORS    4
++/
+
+enum : int {
+    MH_CREATE  = 1,
+    MH_KEEP    = 2,
+    MH_DELETE  = 3,
+    MH_CLEANUP = 4
+}
+
+mixin DECLARE_HANDLE!("HCONVLIST");
+mixin DECLARE_HANDLE!("HCONV");
+mixin DECLARE_HANDLE!("HSZ");
+mixin DECLARE_HANDLE!("HDDEDATA");
+
+extern (Windows) alias HDDEDATA
+  function(UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD) PFNCALLBACK;
+
+struct HSZPAIR {
+    HSZ hszSvc;
+    HSZ hszTopic;
+}
+alias HSZPAIR* PHSZPAIR;
+
+struct CONVCONTEXT {
+    UINT                        cb = CONVCONTEXT.sizeof;
+    UINT                        wFlags;
+    UINT                        wCountryID;
+    int                         iCodePage;
+    DWORD                       dwLangID;
+    DWORD                       dwSecurity;
+    SECURITY_QUALITY_OF_SERVICE qos;
+}
+alias CONVCONTEXT* PCONVCONTEXT;
+
+struct CONVINFO {
+    DWORD       cb = CONVINFO.sizeof;
+    DWORD       hUser;
+    HCONV       hConvPartner;
+    HSZ         hszSvcPartner;
+    HSZ         hszServiceReq;
+    HSZ         hszTopic;
+    HSZ         hszItem;
+    UINT        wFmt;
+    UINT        wType;
+    UINT        wStatus;
+    UINT        wConvst;
+    UINT        wLastError;
+    HCONVLIST   hConvList;
+    CONVCONTEXT ConvCtxt;
+    HWND        hwnd;
+    HWND        hwndPartner;
+}
+alias CONVINFO* PCONVINFO;
+
+struct DDEML_MSG_HOOK_DATA {
+    UINT_PTR uiLo;
+    UINT_PTR uiHi;
+    DWORD    cbData;
+    DWORD[8] Data;
+}
+
+struct MONHSZSTRUCT {
+    UINT     cb = MONHSZSTRUCT.sizeof;
+    int      fsAction;
+    DWORD    dwTime;
+    HSZ      hsz;
+    HANDLE   hTask;
+    TCHAR[1] _str;
+
+    TCHAR* str() return { return _str.ptr; }
+}
+alias MONHSZSTRUCT* PMONHSZSTRUCT;
+
+struct MONLINKSTRUCT {
+    UINT   cb = MONLINKSTRUCT.sizeof;
+    DWORD  dwTime;
+    HANDLE hTask;
+    BOOL   fEstablished;
+    BOOL   fNoData;
+    HSZ    hszSvc;
+    HSZ    hszTopic;
+    HSZ    hszItem;
+    UINT   wFmt;
+    BOOL   fServer;
+    HCONV  hConvServer;
+    HCONV  hConvClient;
+}
+alias MONLINKSTRUCT* PMONLINKSTRUCT;
+
+struct MONCONVSTRUCT {
+    UINT   cb = MONCONVSTRUCT.sizeof;
+    BOOL   fConnect;
+    DWORD  dwTime;
+    HANDLE hTask;
+    HSZ    hszSvc;
+    HSZ    hszTopic;
+    HCONV  hConvClient;
+    HCONV  hConvServer;
+}
+alias MONCONVSTRUCT* PMONCONVSTRUCT;
+
+struct MONCBSTRUCT {
+    UINT        cb = MONCBSTRUCT.sizeof;
+    DWORD       dwTime;
+    HANDLE      hTask;
+    DWORD       dwRet;
+    UINT        wType;
+    UINT        wFmt;
+    HCONV       hConv;
+    HSZ         hsz1;
+    HSZ         hsz2;
+    HDDEDATA    hData;
+    ULONG_PTR   dwData1;
+    ULONG_PTR   dwData2;
+    CONVCONTEXT cc;
+    DWORD       cbData;
+    DWORD[8]    Data;
+}
+alias MONCBSTRUCT* PMONCBSTRUCT;
+
+struct MONERRSTRUCT {
+    UINT   cb = MONERRSTRUCT.sizeof;
+    UINT   wLastError;
+    DWORD  dwTime;
+    HANDLE hTask;
+}
+alias MONERRSTRUCT* PMONERRSTRUCT;
+
+struct MONMSGSTRUCT {
+    UINT   cb = MONMSGSTRUCT.sizeof;
+    HWND   hwndTo;
+    DWORD  dwTime;
+    HANDLE hTask;
+    UINT   wMsg;
+    WPARAM wParam;
+    LPARAM lParam;
+    DDEML_MSG_HOOK_DATA dmhd;
+}
+alias MONMSGSTRUCT* PMONMSGSTRUCT;
+
+extern (Windows) {
+    BOOL DdeAbandonTransaction(DWORD, HCONV, DWORD);
+    PBYTE DdeAccessData(HDDEDATA, PDWORD);
+    HDDEDATA DdeAddData(HDDEDATA, PBYTE, DWORD, DWORD);
+    HDDEDATA DdeClientTransaction(PBYTE, DWORD, HCONV, HSZ, UINT, UINT,
+      DWORD, PDWORD);
+    int DdeCmpStringHandles(HSZ, HSZ);
+    HCONV DdeConnect(DWORD, HSZ, HSZ, PCONVCONTEXT);
+    HCONVLIST DdeConnectList(DWORD, HSZ, HSZ, HCONVLIST, PCONVCONTEXT);
+    HDDEDATA DdeCreateDataHandle(DWORD, PBYTE, DWORD, DWORD, HSZ, UINT,
+      UINT);
+    HSZ DdeCreateStringHandleA(DWORD, LPSTR, int);
+    HSZ DdeCreateStringHandleW(DWORD, LPWSTR, int);
+    BOOL DdeDisconnect(HCONV);
+    BOOL DdeDisconnectList(HCONVLIST);
+    BOOL DdeEnableCallback(DWORD, HCONV, UINT);
+    BOOL DdeFreeDataHandle(HDDEDATA);
+    BOOL DdeFreeStringHandle(DWORD, HSZ);
+    DWORD DdeGetData(HDDEDATA, PBYTE, DWORD, DWORD);
+    UINT DdeGetLastError(DWORD);
+    BOOL DdeImpersonateClient(HCONV);
+    UINT DdeInitializeA(PDWORD, PFNCALLBACK, DWORD, DWORD);
+    UINT DdeInitializeW(PDWORD, PFNCALLBACK, DWORD, DWORD);
+    BOOL DdeKeepStringHandle(DWORD, HSZ);
+    HDDEDATA DdeNameService(DWORD, HSZ, HSZ, UINT);
+    BOOL DdePostAdvise(DWORD, HSZ, HSZ);
+    UINT DdeQueryConvInfo(HCONV, DWORD, PCONVINFO);
+    HCONV DdeQueryNextServer(HCONVLIST, HCONV);
+    DWORD DdeQueryStringA(DWORD, HSZ, LPSTR, DWORD, int);
+    DWORD DdeQueryStringW(DWORD, HSZ, LPWSTR, DWORD, int);
+    HCONV DdeReconnect(HCONV);
+    BOOL DdeSetUserHandle(HCONV, DWORD, DWORD);
+    BOOL DdeUnaccessData(HDDEDATA);
+    BOOL DdeUninitialize(DWORD);
+}
+
+const TCHAR[]
+    SZDDESYS_TOPIC         = "System",
+    SZDDESYS_ITEM_TOPICS   = "Topics",
+    SZDDESYS_ITEM_SYSITEMS = "SysItems",
+    SZDDESYS_ITEM_RTNMSG   = "ReturnMessage",
+    SZDDESYS_ITEM_STATUS   = "Status",
+    SZDDESYS_ITEM_FORMATS  = "Formats",
+    SZDDESYS_ITEM_HELP     = "Help",
+    SZDDE_ITEM_ITEMLIST    = "TopicItemList";
+
+version (Unicode) {
+    alias DdeCreateStringHandleW DdeCreateStringHandle;
+    alias DdeInitializeW DdeInitialize;
+    alias DdeQueryStringW DdeQueryString;
+} else {
+    alias DdeCreateStringHandleA DdeCreateStringHandle;
+    alias DdeInitializeA DdeInitialize;
+    alias DdeQueryStringA DdeQueryString;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/dhcpcsdk.d b/libphobos/libdruntime/core/sys/windows/dhcpcsdk.d
new file mode 100644
index 00000000000..4c0db442d6f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/dhcpcsdk.d
@@ -0,0 +1,58 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_dhcpcsdk.d)
+ */
+module core.sys.windows.dhcpcsdk;
+version (Windows):
+
+private import core.sys.windows.w32api, core.sys.windows.windef;
+
+/*static assert (_WIN32_WINNT >= 0x500,
+"core.sys.windows.dhcpcsdk is available only if version Windows2000, WindowsXP, Windows2003
+or WindowsVista is set");*/
+
+//#if (_WIN32_WINNT >= 0x500)
+
+// FIXME: check type
+enum DHCPCAPI_REGISTER_HANDLE_EVENT = 1;
+enum DHCPCAPI_REQUEST_PERSISTENT    = 1;
+enum DHCPCAPI_REQUEST_SYNCHRONOUS   = 2;
+
+struct DHCPCAPI_CLASSID {
+    ULONG  Flags;
+    LPBYTE Data;
+    ULONG  nBytesData;
+}
+alias DHCPCAPI_CLASSID* PDHCPCAPI_CLASSID, LPDHCPCAPI_CLASSID;
+
+struct DHCPAPI_PARAMS {
+    ULONG  Flags;
+    ULONG  OptionId;
+    BOOL   IsVendor;
+    LPBYTE Data;
+    DWORD  nBytesData;
+}
+alias DHCPAPI_PARAMS* PDHCPAPI_PARAMS, LPDHCPAPI_PARAMS;
+
+struct DHCPCAPI_PARAMS_ARRAY {
+    ULONG            nParams;
+    LPDHCPAPI_PARAMS Params;
+}
+alias DHCPCAPI_PARAMS_ARRAY* PDHCPCAPI_PARAMS_ARRAY, LPDHCPCAPI_PARAMS_ARRAY;
+
+extern (Windows) {
+    void DhcpCApiCleanup();
+    DWORD DhcpCApiInitialize(LPDWORD);
+    DWORD DhcpDeRegisterParamChange(DWORD, LPVOID, LPVOID);
+    DWORD DhcpRegisterParamChange(DWORD, LPVOID, PWSTR, LPDHCPCAPI_CLASSID,
+      DHCPCAPI_PARAMS_ARRAY, LPVOID);
+    DWORD DhcpRemoveDNSRegistrations();
+    DWORD DhcpUndoRequestParams(DWORD, LPVOID, LPWSTR, LPWSTR);
+}
+
+//#endif // (_WIN32_WINNT >= 0x500)
diff --git a/libphobos/libdruntime/core/sys/windows/dlgs.d b/libphobos/libdruntime/core/sys/windows/dlgs.d
new file mode 100644
index 00000000000..f9306d6e620
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/dlgs.d
@@ -0,0 +1,191 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_dlgs.d)
+ */
+module core.sys.windows.dlgs;
+version (Windows):
+
+private import core.sys.windows.windef;
+
+enum : ushort {
+    FILEOPENORD      = 1536,
+    MULTIFILEOPENORD = 1537,
+    PRINTDLGORD      = 1538,
+    PRNSETUPDLGORD   = 1539,
+    FINDDLGORD       = 1540,
+    REPLACEDLGORD    = 1541,
+    FONTDLGORD       = 1542,
+    FORMATDLGORD31   = 1543,
+    FORMATDLGORD30   = 1544,
+    PAGESETUPDLGORD  = 1546
+}
+
+enum : int {
+    ctlFirst = 0x400,
+    ctlLast  = 0x4ff,
+    chx1     = 0x410,
+    chx2     = 0x411,
+    chx3     = 0x412,
+    chx4     = 0x413,
+    chx5     = 0x414,
+    chx6     = 0x415,
+    chx7     = 0x416,
+    chx8     = 0x417,
+    chx9     = 0x418,
+    chx10    = 0x419,
+    chx11    = 0x41a,
+    chx12    = 0x41b,
+    chx13    = 0x41c,
+    chx14    = 0x41d,
+    chx15    = 0x41e,
+    chx16    = 0x41f,
+    cmb1     = 0x470,
+    cmb2     = 0x471,
+    cmb3     = 0x472,
+    cmb4     = 0x473,
+    cmb5     = 0x474,
+    cmb6     = 0x475,
+    cmb7     = 0x476,
+    cmb8     = 0x477,
+    cmb9     = 0x478,
+    cmb10    = 0x479,
+    cmb11    = 0x47a,
+    cmb12    = 0x47b,
+    cmb13    = 0x47c,
+    cmb14    = 0x47d,
+    cmb15    = 0x47e,
+    cmb16    = 0x47f,
+    edt1     = 0x480,
+    edt2     = 0x481,
+    edt3     = 0x482,
+    edt4     = 0x483,
+    edt5     = 0x484,
+    edt6     = 0x485,
+    edt7     = 0x486,
+    edt8     = 0x487,
+    edt9     = 0x488,
+    edt10    = 0x489,
+    edt11    = 0x48a,
+    edt12    = 0x48b,
+    edt13    = 0x48c,
+    edt14    = 0x48d,
+    edt15    = 0x48e,
+    edt16    = 0x48f,
+    frm1     = 0x434,
+    frm2     = 0x435,
+    frm3     = 0x436,
+    frm4     = 0x437,
+    grp1     = 0x430,
+    grp2     = 0x431,
+    grp3     = 0x432,
+    grp4     = 0x433,
+    ico1     = 0x43c,
+    ico2     = 0x43d,
+    ico3     = 0x43e,
+    ico4     = 0x43f,
+    lst1     = 0x460,
+    lst2     = 0x461,
+    lst3     = 0x462,
+    lst4     = 0x463,
+    lst5     = 0x464,
+    lst6     = 0x465,
+    lst7     = 0x466,
+    lst8     = 0x467,
+    lst9     = 0x468,
+    lst10    = 0x469,
+    lst11    = 0x46a,
+    lst12    = 0x46b,
+    lst13    = 0x46c,
+    lst14    = 0x46d,
+    lst15    = 0x46e,
+    lst16    = 0x46f,
+    psh1     = 0x400,
+    psh2     = 0x401,
+    psh3     = 0x402,
+    psh4     = 0x403,
+    psh5     = 0x404,
+    psh6     = 0x405,
+    psh7     = 0x406,
+    psh8     = 0x407,
+    psh9     = 0x408,
+    psh10    = 0x409,
+    psh11    = 0x40a,
+    psh12    = 0x40b,
+    psh13    = 0x40c,
+    psh14    = 0x40d,
+    psh15    = 0x40e,
+    pshHelp  = 0x40e,
+    psh16    = 0x40f,
+    rad1     = 0x420,
+    rad2     = 0x421,
+    rad3     = 0x422,
+    rad4     = 0x423,
+    rad5     = 0x424,
+    rad6     = 0x425,
+    rad7     = 0x426,
+    rad8     = 0x427,
+    rad9     = 0x428,
+    rad10    = 0x429,
+    rad11    = 0x42a,
+    rad12    = 0x42b,
+    rad13    = 0x42c,
+    rad14    = 0x42d,
+    rad15    = 0x42e,
+    rad16    = 0x42f,
+    rct1     = 0x438,
+    rct2     = 0x439,
+    rct3     = 0x43a,
+    rct4     = 0x43b,
+    scr1     = 0x490,
+    scr2     = 0x491,
+    scr3     = 0x492,
+    scr4     = 0x493,
+    scr5     = 0x494,
+    scr6     = 0x495,
+    scr7     = 0x496,
+    scr8     = 0x497,
+    stc1     = 0x440,
+    stc2     = 0x441,
+    stc3     = 0x442,
+    stc4     = 0x443,
+    stc5     = 0x444,
+    stc6     = 0x445,
+    stc7     = 0x446,
+    stc8     = 0x447,
+    stc9     = 0x448,
+    stc10    = 0x449,
+    stc11    = 0x44a,
+    stc12    = 0x44b,
+    stc13    = 0x44c,
+    stc14    = 0x44d,
+    stc15    = 0x44e,
+    stc16    = 0x44f,
+    stc17    = 0x450,
+    stc18    = 0x451,
+    stc19    = 0x452,
+    stc20    = 0x453,
+    stc21    = 0x454,
+    stc22    = 0x455,
+    stc23    = 0x456,
+    stc24    = 0x457,
+    stc25    = 0x458,
+    stc26    = 0x459,
+    stc27    = 0x45a,
+    stc28    = 0x45b,
+    stc29    = 0x45c,
+    stc30    = 0x45d,
+    stc31    = 0x45e,
+    stc32    = 0x45f
+}
+
+struct CRGB {
+    ubyte bRed;
+    ubyte bGreen;
+    ubyte bBlue;
+    ubyte bExtra;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/dll.d b/libphobos/libdruntime/core/sys/windows/dll.d
new file mode 100644
index 00000000000..14939b1607f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/dll.d
@@ -0,0 +1,514 @@
+/**
+ * This module provides OS specific helper function for DLL support
+ *
+ * Copyright: Copyright Digital Mars 2010 - 2012.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Rainer Schuetze
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_dll.d)
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module core.sys.windows.dll;
+version (Windows):
+
+import core.sys.windows.windows;
+import core.stdc.string;
+import core.runtime;
+
+public import core.sys.windows.threadaux;
+
+///////////////////////////////////////////////////////////////////
+// support fixing implicit TLS for dynamically loaded DLLs on Windows XP
+
+// in this special case, we have to treat _tlsstart and _tlsend as non-TLS variables
+//  as they are used to simulate TLS when it is not set up under XP. In this case we must
+//  not access tls_array[tls_index] as needed for thread local _tlsstart and _tlsend
+extern (C)
+{
+        version (MinGW)
+        {
+            extern __gshared void* _tls_start;
+            extern __gshared void* _tls_end;
+            extern __gshared void* __xl_a;
+
+            alias _tls_start _tlsstart;
+            alias _tls_end   _tlsend;
+            alias __xl_a     _tls_callbacks_a;
+        }
+        else version (Win32)
+    {
+        version(CRuntime_DigitalMars)
+        {
+            extern __gshared byte  _tlsstart;
+            extern __gshared byte  _tlsend;
+            extern __gshared void* _tls_callbacks_a;
+        }
+        else version(CRuntime_Microsoft)
+        {
+            extern __gshared byte  _tls_start;
+            extern __gshared byte  _tls_end;
+            extern __gshared void*  __xl_a;
+            alias _tls_start _tlsstart;
+            alias _tls_end   _tlsend;
+            alias __xl_a     _tls_callbacks_a;
+        }
+        extern __gshared int   _tls_index;
+    }
+}
+
+extern (C) // rt.minfo
+{
+    void rt_moduleTlsCtor();
+    void rt_moduleTlsDtor();
+}
+
+private:
+version (Win32)
+{
+struct dll_aux
+{
+    // don't let symbols leak into other modules
+    struct LdrpTlsListEntry
+    {
+        LdrpTlsListEntry* next;
+        LdrpTlsListEntry* prev;
+        void* tlsstart;
+        void* tlsend;
+        void* ptr_tlsindex;
+        void* callbacks;
+        void* zerofill;
+        int   tlsindex;
+    }
+
+    alias fnRtlAllocateHeap = extern(Windows)
+    void* function(void* HeapHandle, uint Flags, size_t Size) nothrow;
+
+    // find a code sequence and return the address after the sequence
+    static void* findCodeSequence( void* adr, int len, ref ubyte[] pattern ) nothrow
+    {
+        if( !adr )
+            return null;
+
+        ubyte* code = cast(ubyte*) adr;
+        for( int p = 0; p < len; p++ )
+        {
+            if( code[ p .. p + pattern.length ] == pattern[ 0 .. $ ] )
+            {
+                ubyte* padr = code + p + pattern.length;
+                return padr;
+            }
+        }
+        return null;
+    }
+
+    // find a code sequence and return the (relative) address that follows
+    static void* findCodeReference( void* adr, int len, ref ubyte[] pattern, bool relative ) nothrow
+    {
+        if( !adr )
+            return null;
+
+        ubyte* padr = cast(ubyte*) findCodeSequence( adr, len, pattern );
+        if( padr )
+        {
+            if( relative )
+                return padr + 4 + *cast(int*) padr;
+            return *cast(void**) padr;
+        }
+        return null;
+    }
+
+    // crawl through ntdll to find function _LdrpAllocateTls@0 and references
+    //  to _LdrpNumberOfTlsEntries, _NtdllBaseTag and _LdrpTlsList
+    // LdrInitializeThunk
+    // -> _LdrpInitialize@12
+    // -> _LdrpInitializeThread@4
+    // -> _LdrpAllocateTls@0
+    // -> je chunk
+    //     _LdrpNumberOfTlsEntries - number of entries in TlsList
+    //     _NtdllBaseTag           - tag used for RtlAllocateHeap
+    //     _LdrpTlsList            - root of the double linked list with TlsList entries
+
+    static __gshared int* pNtdllBaseTag; // remembered for reusage in addTlsData
+
+    static __gshared ubyte[] jmp_LdrpInitialize = [ 0x33, 0xED, 0xE9 ]; // xor ebp,ebp; jmp _LdrpInitialize
+    static __gshared ubyte[] jmp__LdrpInitialize = [ 0x5D, 0xE9 ]; // pop ebp; jmp __LdrpInitialize
+    static __gshared ubyte[] jmp__LdrpInitialize_xp64 = [ 0x5D, 0x90, 0x90, 0x90, 0x90, 0x90 ]; // pop ebp; nop; nop; nop; nop; nop;
+    static __gshared ubyte[] call_LdrpInitializeThread = [ 0xFF, 0x75, 0x08, 0xE8 ]; // push [ebp+8]; call _LdrpInitializeThread
+    static __gshared ubyte[] call_LdrpAllocateTls = [ 0x00, 0x00, 0xE8 ]; // jne 0xc3; call _LdrpAllocateTls
+    static __gshared ubyte[] call_LdrpAllocateTls_svr03 = [ 0x65, 0xfc, 0x00, 0xE8 ]; // and [ebp+fc], 0; call _LdrpAllocateTls
+    static __gshared ubyte[] jne_LdrpAllocateTls = [ 0x0f, 0x85 ]; // jne body_LdrpAllocateTls
+    static __gshared ubyte[] mov_LdrpNumberOfTlsEntries = [ 0x8B, 0x0D ]; // mov ecx, _LdrpNumberOfTlsEntries
+    static __gshared ubyte[] mov_NtdllBaseTag = [ 0x51, 0x8B, 0x0D ]; // push ecx; mov ecx, _NtdllBaseTag
+    static __gshared ubyte[] mov_NtdllBaseTag_srv03 = [ 0x50, 0xA1 ]; // push eax; mov eax, _NtdllBaseTag
+    static __gshared ubyte[] mov_LdrpTlsList = [ 0x8B, 0x3D ]; // mov edi, _LdrpTlsList
+
+    static LdrpTlsListEntry* addTlsListEntry( void** peb, void* tlsstart, void* tlsend, void* tls_callbacks_a, int* tlsindex ) nothrow
+    {
+        HANDLE hnd = GetModuleHandleA( "NTDLL" );
+        assert( hnd, "cannot get module handle for ntdll" );
+        ubyte* fn = cast(ubyte*) GetProcAddress( hnd, "LdrInitializeThunk" );
+        assert( fn, "cannot find LdrInitializeThunk in ntdll" );
+
+        void* pLdrpInitialize = findCodeReference( fn, 20, jmp_LdrpInitialize, true );
+        void* p_LdrpInitialize = findCodeReference( pLdrpInitialize, 40, jmp__LdrpInitialize, true );
+        if( !p_LdrpInitialize )
+            p_LdrpInitialize = findCodeSequence( pLdrpInitialize, 40, jmp__LdrpInitialize_xp64 );
+        void* pLdrpInitializeThread = findCodeReference( p_LdrpInitialize, 200, call_LdrpInitializeThread, true );
+        void* pLdrpAllocateTls = findCodeReference( pLdrpInitializeThread, 40, call_LdrpAllocateTls, true );
+        if(!pLdrpAllocateTls)
+            pLdrpAllocateTls = findCodeReference( pLdrpInitializeThread, 100, call_LdrpAllocateTls_svr03, true );
+        void* pBodyAllocateTls = findCodeReference( pLdrpAllocateTls, 40, jne_LdrpAllocateTls, true );
+
+        int* pLdrpNumberOfTlsEntries = cast(int*) findCodeReference( pBodyAllocateTls, 60, mov_LdrpNumberOfTlsEntries, false );
+        pNtdllBaseTag = cast(int*) findCodeReference( pBodyAllocateTls, 30, mov_NtdllBaseTag, false );
+        if(!pNtdllBaseTag)
+            pNtdllBaseTag = cast(int*) findCodeReference( pBodyAllocateTls, 30, mov_NtdllBaseTag_srv03, false );
+        LdrpTlsListEntry* pLdrpTlsList = cast(LdrpTlsListEntry*)findCodeReference( pBodyAllocateTls, 80, mov_LdrpTlsList, false );
+
+        if( !pLdrpNumberOfTlsEntries || !pNtdllBaseTag || !pLdrpTlsList )
+            return null;
+
+        fnRtlAllocateHeap fnAlloc = cast(fnRtlAllocateHeap) GetProcAddress( hnd, "RtlAllocateHeap" );
+        if( !fnAlloc )
+            return null;
+
+        // allocate new TlsList entry (adding 0xC0000 to the tag is obviously a flag also usesd by
+        //  the nt-loader, could be the result of HEAP_MAKE_TAG_FLAGS(0,HEAP_NO_SERIALIZE|HEAP_GROWABLE)
+        //  but this is not documented in the msdn entry for RtlAlloateHeap
+        void* heap = peb[6];
+        LdrpTlsListEntry* entry = cast(LdrpTlsListEntry*) (*fnAlloc)( heap, *pNtdllBaseTag | 0xc0000, LdrpTlsListEntry.sizeof );
+        if( !entry )
+            return null;
+
+        // fill entry
+        entry.tlsstart = tlsstart;
+        entry.tlsend = tlsend;
+        entry.ptr_tlsindex = tlsindex;
+        entry.callbacks = tls_callbacks_a;
+        entry.zerofill = null;
+        entry.tlsindex = *pLdrpNumberOfTlsEntries;
+
+        // and add it to the end of TlsList
+        *tlsindex = *pLdrpNumberOfTlsEntries;
+        entry.next = pLdrpTlsList;
+        entry.prev = pLdrpTlsList.prev;
+        pLdrpTlsList.prev.next = entry;
+        pLdrpTlsList.prev = entry;
+        (*pLdrpNumberOfTlsEntries)++;
+
+        return entry;
+    }
+
+    // reallocate TLS array and create a copy of the TLS data section
+    static bool addTlsData( void** teb, void* tlsstart, void* tlsend, int tlsindex ) nothrow
+    {
+        HANDLE hnd = GetModuleHandleA( "NTDLL" );
+        assert( hnd, "cannot get module handle for ntdll" );
+
+        fnRtlAllocateHeap fnAlloc = cast(fnRtlAllocateHeap) GetProcAddress( hnd, "RtlAllocateHeap" );
+        if( !fnAlloc || !pNtdllBaseTag )
+            return false;
+
+        void** peb = cast(void**) teb[12];
+        void* heap = peb[6];
+
+        auto sz = tlsend - tlsstart;
+        void* tlsdata = cast(void*) (*fnAlloc)( heap, *pNtdllBaseTag | 0xc0000, sz );
+        if( !tlsdata )
+            return false;
+
+        // no relocations! not even self-relocations. Windows does not do them.
+        core.stdc.string.memcpy( tlsdata, tlsstart, sz );
+
+        // create copy of tls pointer array
+        void** array = cast(void**) (*fnAlloc)( heap, *pNtdllBaseTag | 0xc0000, (tlsindex + 1) * (void*).sizeof );
+        if( !array )
+            return false;
+
+        if( tlsindex > 0 && teb[11] )
+            core.stdc.string.memcpy( array, teb[11], tlsindex * (void*).sizeof);
+        array[tlsindex] = tlsdata;
+        teb[11] = cast(void*) array;
+
+        // let the old array leak, in case a oncurrent thread is still relying on it
+        return true;
+    }
+
+    alias bool BOOLEAN;
+
+    struct UNICODE_STRING
+    {
+        short Length;
+        short MaximumLength;
+        wchar* Buffer;
+    }
+
+    struct LIST_ENTRY
+    {
+        LIST_ENTRY* next;
+        LIST_ENTRY* prev;
+    }
+
+    // the following structures can be found here: http://undocumented.ntinternals.net/
+    struct LDR_MODULE
+    {
+        LIST_ENTRY      InLoadOrderModuleList;
+        LIST_ENTRY      InMemoryOrderModuleList;
+        LIST_ENTRY      InInitializationOrderModuleList;
+        PVOID           BaseAddress;
+        PVOID           EntryPoint;
+        ULONG           SizeOfImage;
+        UNICODE_STRING  FullDllName;
+        UNICODE_STRING  BaseDllName;
+        ULONG           Flags;
+        SHORT           LoadCount;
+        SHORT           TlsIndex;
+        LIST_ENTRY      HashTableEntry;
+        ULONG           TimeDateStamp;
+    }
+
+    struct PEB_LDR_DATA
+    {
+        ULONG           Length;
+        BOOLEAN         Initialized;
+        PVOID           SsHandle;
+        LIST_ENTRY      InLoadOrderModuleList;
+        LIST_ENTRY      InMemoryOrderModuleList;
+        LIST_ENTRY      InInitializationOrderModuleList;
+    }
+
+    static LDR_MODULE* findLdrModule( HINSTANCE hInstance, void** peb ) nothrow
+    {
+        PEB_LDR_DATA* ldrData = cast(PEB_LDR_DATA*) peb[3];
+        LIST_ENTRY* root = &ldrData.InLoadOrderModuleList;
+        for(LIST_ENTRY* entry = root.next; entry != root; entry = entry.next)
+        {
+            LDR_MODULE *ldrMod = cast(LDR_MODULE*) entry;
+            if(ldrMod.BaseAddress == hInstance)
+                return ldrMod;
+        }
+        return null;
+    }
+
+    static bool setDllTlsUsage( HINSTANCE hInstance, void** peb ) nothrow
+    {
+        LDR_MODULE *thisMod = findLdrModule( hInstance, peb );
+        if( !thisMod )
+            return false;
+
+        thisMod.TlsIndex = -1;  // uses TLS (not the index itself)
+        thisMod.LoadCount = -1; // never unload
+        return true;
+    }
+}
+}
+
+public:
+/* *****************************************************
+ * Fix implicit thread local storage for the case when a DLL is loaded
+ * dynamically after process initialization.
+ * The link time variables are passed to allow placing this function into
+ * an RTL DLL itself.
+ * The problem is described in Bugzilla 3342 and
+ * http://www.nynaeve.net/?p=187, to quote from the latter:
+ *
+ * "When a DLL using implicit TLS is loaded, because the loader doesn't process the TLS
+ *  directory, the _tls_index value is not initialized by the loader, nor is there space
+ *  allocated for module's TLS data in the ThreadLocalStoragePointer arrays of running
+ *  threads. The DLL continues to load, however, and things will appear to work... until the
+ *  first access to a __declspec(thread) variable occurs, that is."
+ *
+ * _tls_index is initialized by the compiler to 0, so we can use this as a test.
+ */
+bool dll_fixTLS( HINSTANCE hInstance, void* tlsstart, void* tlsend, void* tls_callbacks_a, int* tlsindex ) nothrow
+{
+    version (Win64)
+        return true;                // fixed
+    else version (Win32)
+    {
+    /* If the OS has allocated a TLS slot for us, we don't have to do anything
+     * tls_index 0 means: the OS has not done anything, or it has allocated slot 0
+     * Vista and later Windows systems should do this correctly and not need
+     * this function.
+     */
+    if( *tlsindex != 0 )
+        return true;
+
+    void** peb;
+    asm pure nothrow @nogc
+    {
+        mov EAX,FS:[0x30];
+        mov peb, EAX;
+    }
+    dll_aux.LDR_MODULE *ldrMod = dll_aux.findLdrModule( hInstance, peb );
+    if( !ldrMod )
+        return false; // not in module list, bail out
+    if( ldrMod.TlsIndex != 0 )
+        return true;  // the OS has already setup TLS
+
+    dll_aux.LdrpTlsListEntry* entry = dll_aux.addTlsListEntry( peb, tlsstart, tlsend, tls_callbacks_a, tlsindex );
+    if( !entry )
+        return false;
+
+    scope (failure) assert(0); // enforce nothrow, Bugzilla 13561
+
+    if( !enumProcessThreads(
+        function (uint id, void* context) nothrow {
+            dll_aux.LdrpTlsListEntry* entry = cast(dll_aux.LdrpTlsListEntry*) context;
+            return dll_aux.addTlsData( getTEB( id ), entry.tlsstart, entry.tlsend, entry.tlsindex );
+        }, entry ) )
+        return false;
+
+    ldrMod.TlsIndex = -1;  // flag TLS usage (not the index itself)
+    ldrMod.LoadCount = -1; // prevent unloading of the DLL,
+                           // since XP does not keep track of used TLS entries
+    return true;
+    }
+}
+
+// fixup TLS storage, initialize runtime and attach to threads
+// to be called from DllMain with reason DLL_PROCESS_ATTACH
+bool dll_process_attach( HINSTANCE hInstance, bool attach_threads,
+                         void* tlsstart, void* tlsend, void* tls_callbacks_a, int* tlsindex )
+{
+    version (Win32)
+    {
+        if( !dll_fixTLS( hInstance, tlsstart, tlsend, tls_callbacks_a, tlsindex ) )
+            return false;
+    }
+
+    Runtime.initialize();
+
+    if( !attach_threads )
+        return true;
+
+    // attach to all other threads
+    return enumProcessThreads(
+        function (uint id, void* context) {
+            if( !thread_findByAddr( id ) )
+            {
+                // if the OS has not prepared TLS for us, don't attach to the thread
+                if( GetTlsDataAddress( id ) )
+                {
+                    thread_attachByAddr( id );
+                    thread_moduleTlsCtor( id );
+                }
+            }
+            return true;
+        }, null );
+}
+
+// same as above, but only usable if druntime is linked statically
+bool dll_process_attach( HINSTANCE hInstance, bool attach_threads = true )
+{
+    version (Win64)
+    {
+        return dll_process_attach( hInstance, attach_threads,
+                                   null, null, null, null );
+    }
+    else version (Win32)
+    {
+        return dll_process_attach( hInstance, attach_threads,
+                                   &_tlsstart, &_tlsend, &_tls_callbacks_a, &_tls_index );
+    }
+}
+
+// to be called from DllMain with reason DLL_PROCESS_DETACH
+void dll_process_detach( HINSTANCE hInstance, bool detach_threads = true )
+{
+    // detach from all other threads
+    if( detach_threads )
+        enumProcessThreads(
+            function (uint id, void* context) {
+                if( id != GetCurrentThreadId() && thread_findByAddr( id ) )
+                {
+                    thread_moduleTlsDtor( id );
+                    thread_detachByAddr( id );
+                }
+                return true;
+            }, null );
+
+    Runtime.terminate();
+}
+
+/* Make sure that tlsCtorRun is itself a tls variable
+ */
+static bool tlsCtorRun;
+static this() { tlsCtorRun = true; }
+static ~this() { tlsCtorRun = false; }
+
+// to be called from DllMain with reason DLL_THREAD_ATTACH
+bool dll_thread_attach( bool attach_thread = true, bool initTls = true )
+{
+    // if the OS has not prepared TLS for us, don't attach to the thread
+    //  (happened when running under x64 OS)
+    if( !GetTlsDataAddress( GetCurrentThreadId() ) )
+        return false;
+    if( !thread_findByAddr( GetCurrentThreadId() ) )
+    {
+        // only attach to thread and initalize it if it is not in the thread list (so it's not created by "new Thread")
+        if( attach_thread )
+            thread_attachThis();
+        if( initTls && !tlsCtorRun ) // avoid duplicate calls
+            rt_moduleTlsCtor();
+    }
+    return true;
+}
+
+// to be called from DllMain with reason DLL_THREAD_DETACH
+bool dll_thread_detach( bool detach_thread = true, bool exitTls = true )
+{
+    // if the OS has not prepared TLS for us, we did not attach to the thread
+    if( !GetTlsDataAddress( GetCurrentThreadId() ) )
+         return false;
+    if( thread_findByAddr( GetCurrentThreadId() ) )
+    {
+        if( exitTls && tlsCtorRun ) // avoid dtors to be run twice
+            rt_moduleTlsDtor();
+        if( detach_thread )
+            thread_detachThis();
+    }
+    return true;
+}
+
+/// A simple mixin to provide a $(D DllMain) which calls the necessary
+/// runtime initialization and termination functions automatically.
+///
+/// Instead of writing a custom $(D DllMain), simply write:
+///
+/// ---
+/// mixin SimpleDllMain;
+/// ---
+mixin template SimpleDllMain()
+{
+    import core.sys.windows.windows : HINSTANCE;
+
+    extern(Windows)
+    bool DllMain(HINSTANCE hInstance, uint ulReason, void* reserved)
+    {
+        import core.sys.windows.windows;
+        import core.sys.windows.dll :
+            dll_process_attach, dll_process_detach,
+            dll_thread_attach, dll_thread_detach;
+        switch(ulReason)
+        {
+            default: assert(0);
+            case DLL_PROCESS_ATTACH:
+                return dll_process_attach( hInstance, true );
+
+            case DLL_PROCESS_DETACH:
+                dll_process_detach( hInstance, true );
+                return true;
+
+            case DLL_THREAD_ATTACH:
+                return dll_thread_attach( true, true );
+
+            case DLL_THREAD_DETACH:
+                return dll_thread_detach( true, true );
+        }
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/windows/docobj.d b/libphobos/libdruntime/core/sys/windows/docobj.d
new file mode 100644
index 00000000000..1ea66db0672
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/docobj.d
@@ -0,0 +1,133 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_docobj.d)
+ */
+module core.sys.windows.docobj;
+version (Windows):
+
+private import core.sys.windows.basetyps, core.sys.windows.oaidl, core.sys.windows.objidl, core.sys.windows.oleidl,
+  core.sys.windows.unknwn, core.sys.windows.windef, core.sys.windows.wtypes;
+
+// FIXME: remove inherited methods from interface definitions
+
+enum {
+    OLECMDERR_E_UNKNOWNGROUP = -2147221244,
+    OLECMDERR_E_CANCELED     = -2147221245,
+    OLECMDERR_E_NOHELP       = -2147221246,
+    OLECMDERR_E_DISABLED     = -2147221247,
+    OLECMDERR_E_NOTSUPPORTED = -2147221248
+}
+
+enum OLECMDID {
+    OLECMDID_OPEN = 1,
+    OLECMDID_NEW = 2,
+    OLECMDID_SAVE = 3,
+    OLECMDID_SAVEAS = 4,
+    OLECMDID_SAVECOPYAS = 5,
+    OLECMDID_PRINT = 6,
+    OLECMDID_PRINTPREVIEW = 7,
+    OLECMDID_PAGESETUP = 8,
+    OLECMDID_SPELL = 9,
+    OLECMDID_PROPERTIES = 10,
+    OLECMDID_CUT = 11,
+    OLECMDID_COPY = 12,
+    OLECMDID_PASTE = 13,
+    OLECMDID_PASTESPECIAL = 14,
+    OLECMDID_UNDO = 15,
+    OLECMDID_REDO = 16,
+    OLECMDID_SELECTALL = 17,
+    OLECMDID_CLEARSELECTION = 18,
+    OLECMDID_ZOOM = 19,
+    OLECMDID_GETZOOMRANGE = 20,
+    OLECMDID_UPDATECOMMANDS = 21,
+    OLECMDID_REFRESH = 22,
+    OLECMDID_STOP = 23,
+    OLECMDID_HIDETOOLBARS = 24,
+    OLECMDID_SETPROGRESSMAX = 25,
+    OLECMDID_SETPROGRESSPOS = 26,
+    OLECMDID_SETPROGRESSTEXT = 27,
+    OLECMDID_SETTITLE = 28,
+    OLECMDID_SETDOWNLOADSTATE = 29,
+    OLECMDID_STOPDOWNLOAD = 30
+}
+
+enum OLECMDF {
+    OLECMDF_SUPPORTED = 1,
+    OLECMDF_ENABLED = 2,
+    OLECMDF_LATCHED = 4,
+    OLECMDF_NINCHED = 8
+}
+
+enum OLECMDEXECOPT {
+    OLECMDEXECOPT_DODEFAULT = 0,
+    OLECMDEXECOPT_PROMPTUSER = 1,
+    OLECMDEXECOPT_DONTPROMPTUSER = 2,
+    OLECMDEXECOPT_SHOWHELP = 3
+}
+
+struct OLECMDTEXT {
+    DWORD cmdtextf;
+    ULONG cwActual;
+    ULONG cwBuf;
+    wchar[1] rgwz;
+}
+
+struct OLECMD {
+    ULONG cmdID;
+    DWORD cmdf;
+}
+
+alias IOleInPlaceSite LPOLEINPLACESITE;
+alias IEnumOleDocumentViews LPENUMOLEDOCUMENTVIEWS;
+
+extern (C) extern const IID
+    IID_IContinueCallback,
+    IID_IEnumOleDocumentViews,
+    IID_IPrint,
+    IID_IOleDocumentView,
+    IID_IOleDocument,
+    IID_IOleCommandTarget,
+    IID_IOleDocumentSite;
+
+
+interface IOleDocumentView : IUnknown {
+    HRESULT SetInPlaceSite(LPOLEINPLACESITE);
+    HRESULT GetInPlaceSite(LPOLEINPLACESITE*);
+    HRESULT GetDocument(IUnknown*);
+    HRESULT SetRect(LPRECT);
+    HRESULT GetRect(LPRECT);
+    HRESULT SetRectComplex(LPRECT, LPRECT, LPRECT, LPRECT);
+    HRESULT Show(BOOL);
+    HRESULT UIActivate(BOOL);
+    HRESULT Open();
+    HRESULT Close(DWORD);
+    HRESULT SaveViewState(IStream);
+    HRESULT ApplyViewState(IStream);
+    HRESULT Clone(LPOLEINPLACESITE, IOleDocumentView*);
+}
+
+interface IEnumOleDocumentViews : IUnknown {
+      HRESULT Next(ULONG, IOleDocumentView, ULONG*);
+      HRESULT Skip(ULONG);
+      HRESULT Reset();
+      HRESULT Clone(IEnumOleDocumentViews*);
+}
+
+interface IOleDocument : IUnknown {
+    HRESULT CreateView(LPOLEINPLACESITE, IStream, DWORD, IOleDocumentView*);
+    HRESULT GetDocMiscStatus(DWORD*);
+    HRESULT EnumViews(LPENUMOLEDOCUMENTVIEWS*, IOleDocumentView*);
+}
+
+interface IOleCommandTarget : IUnknown {
+    HRESULT QueryStatus(const(GUID)*, ULONG, OLECMD*, OLECMDTEXT*);
+    HRESULT Exec(const(GUID)*, DWORD, DWORD, VARIANTARG*, VARIANTARG*);
+}
+
+interface IOleDocumentSite : IUnknown {
+    HRESULT ActivateMe(IOleDocumentView);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/errorrep.d b/libphobos/libdruntime/core/sys/windows/errorrep.d
new file mode 100644
index 00000000000..62782961b3d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/errorrep.d
@@ -0,0 +1,42 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_errorrep.d)
+ */
+module core.sys.windows.errorrep;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.w32api, core.sys.windows.windef;
+
+static assert (_WIN32_WINNT >= 0x501,
+    "core.sys.windows.errorrep is available only if version WindowsXP, Windows2003 "
+    "or WindowsVista is set");
+
+enum EFaultRepRetVal {
+    frrvOk,
+    frrvOkManifest,
+    frrvOkQueued,
+    frrvErr,
+    frrvErrNoDW,
+    frrvErrTimeout,
+    frrvLaunchDebugger,
+    frrvOkHeadless // = 7
+}
+
+extern (Windows) {
+    BOOL AddERExcludedApplicationA(LPCSTR);
+    BOOL AddERExcludedApplicationW(LPCWSTR);
+    EFaultRepRetVal ReportFault(LPEXCEPTION_POINTERS, DWORD);
+}
+
+version (Unicode) {
+    alias AddERExcludedApplicationW AddERExcludedApplication;
+} else {
+    alias AddERExcludedApplicationA AddERExcludedApplication;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/exdisp.d b/libphobos/libdruntime/core/sys/windows/exdisp.d
new file mode 100644
index 00000000000..6b953bf2d69
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/exdisp.d
@@ -0,0 +1,127 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_exdisp.d)
+ */
+module core.sys.windows.exdisp;
+version (Windows):
+
+import core.sys.windows.docobj, core.sys.windows.oaidl, core.sys.windows.ocidl;
+private import core.sys.windows.basetyps, core.sys.windows.windef, core.sys.windows.wtypes;
+
+
+enum BrowserNavConstants {
+    navOpenInNewWindow = 0x01,
+    navNoHistory       = 0x02,
+    navNoReadFromCache = 0x04,
+    navNoWriteTocache  = 0x08,
+    navAllowAutosearch = 0x10,
+    navBrowserBar      = 0x20,
+    navHyperLink       = 0x40
+}
+
+interface IWebBrowser : IDispatch {
+    HRESULT GoBack();
+    HRESULT GoForward();
+    HRESULT GoHome();
+    HRESULT GoSearch();
+    HRESULT Navigate(BSTR, VARIANT*, VARIANT*, VARIANT*, VARIANT*);
+    HRESULT Refresh();
+    HRESULT Refresh2(VARIANT*);
+    HRESULT Stop();
+    HRESULT get_Application(IDispatch* ppDisp);
+    HRESULT get_Parent(IDispatch* ppDisp);
+    HRESULT get_Container(IDispatch* ppDisp);
+    HRESULT get_Document(IDispatch* ppDisp);
+    HRESULT get_TopLevelContainer(VARIANT_BOOL*);
+    HRESULT get_Type(BSTR*);
+    HRESULT get_Left(LONG*);
+    HRESULT put_Left(LONG);
+    HRESULT get_Top(LONG*);
+    HRESULT put_Top(LONG);
+    HRESULT get_Width(LONG*);
+    HRESULT put_Width(LONG);
+    HRESULT get_Height(LONG*);
+    HRESULT put_Height(LONG);
+    HRESULT get_LocationName(BSTR*);
+    HRESULT get_LocationURL(BSTR*);
+    HRESULT get_Busy(VARIANT_BOOL*);
+}
+
+interface IWebBrowserApp : IWebBrowser {
+    HRESULT Quit();
+    HRESULT ClientToWindow(int*, int*);
+    HRESULT PutProperty(BSTR, VARIANT);
+    HRESULT GetProperty(BSTR, VARIANT*);
+    HRESULT get_Name(BSTR*);
+    HRESULT get_HWND(LONG*);
+    HRESULT get_FullName(BSTR*);
+    HRESULT get_Path(BSTR*);
+    HRESULT get_Visible(VARIANT_BOOL*);
+    HRESULT put_Visible(VARIANT_BOOL);
+    HRESULT get_StatusBar(VARIANT_BOOL*);
+    HRESULT put_StatusBar(VARIANT_BOOL);
+    HRESULT get_StatusText(BSTR*);
+    HRESULT put_StatusText(BSTR);
+    HRESULT get_ToolBar(int*);
+    HRESULT put_ToolBar(int);
+    HRESULT get_MenuBar(VARIANT_BOOL*);
+    HRESULT put_MenuBar(VARIANT_BOOL);
+    HRESULT get_FullScreen(VARIANT_BOOL*);
+    HRESULT put_FullScreen(VARIANT_BOOL);
+}
+
+interface IWebBrowser2 : IWebBrowserApp {
+    HRESULT Navigate2(VARIANT*, VARIANT*, VARIANT*, VARIANT*, VARIANT*);
+    HRESULT QueryStatusWB(OLECMDID, OLECMDF*);
+    HRESULT ExecWB(OLECMDID, OLECMDEXECOPT, VARIANT*, VARIANT*);
+    HRESULT ShowBrowserBar(VARIANT*, VARIANT*, VARIANT*);
+    HRESULT get_ReadyState(READYSTATE*);
+    HRESULT get_Offline(VARIANT_BOOL*);
+    HRESULT put_Offline(VARIANT_BOOL);
+    HRESULT get_Silent(VARIANT_BOOL*);
+    HRESULT put_Silent(VARIANT_BOOL);
+    HRESULT get_RegistaerAsBrowser(VARIANT_BOOL*);
+    HRESULT put_RegisterAsBrowser(VARIANT_BOOL);
+    HRESULT get_RegistaerAsDropTarget(VARIANT_BOOL*);
+    HRESULT put_RegisterAsDropTarget(VARIANT_BOOL);
+    HRESULT get_TheaterMode(VARIANT_BOOL*);
+    HRESULT put_TheaterMode(VARIANT_BOOL);
+    HRESULT get_AddressBar(VARIANT_BOOL*);
+    HRESULT put_AddressBar(VARIANT_BOOL);
+    HRESULT get_Resizable(VARIANT_BOOL*);
+    HRESULT put_Resizable(VARIANT_BOOL);
+}
+
+interface DWebBrowserEvents2 : IDispatch {
+    void StatusTextChange(BSTR);
+    void ProgressChange(LONG, LONG);
+    void CommandStateChange(LONG, VARIANT_BOOL);
+    void DownloadBegin();
+    void DownloadComplete();
+    void TitleChange(BSTR);
+    void PropertyChange(BSTR);
+    void BeforeNavigate2(IDispatch pDisp, VARIANT*, VARIANT*, VARIANT*, VARIANT*, VARIANT*, VARIANT_BOOL*);
+    void NewWindow2(IDispatch* ppDisp, VARIANT_BOOL*);
+    void NavigateComplete(IDispatch pDisp, VARIANT*);
+    void DocumentComplete(IDispatch pDisp, VARIANT*);
+    void OnQuit();
+    void OnVisible(VARIANT_BOOL);
+    void OnToolBar(VARIANT_BOOL);
+    void OnMenuBar(VARIANT_BOOL);
+    void OnStatusBar(VARIANT_BOOL);
+    void OnFullScreen(VARIANT_BOOL);
+    void OnTheaterMode(VARIANT_BOOL);
+    void WindowSetResizable(VARIANT_BOOL);
+    void WindowSetLeft(LONG);
+    void WindowSetTop(LONG);
+    void WindowSetWidth(LONG);
+    void WindowSetHeight(LONG);
+    void WindowClosing(VARIANT_BOOL, VARIANT_BOOL*);
+    void ClientToHostWindow(LONG*, LONG*);
+    void SetSecureLockIcon(LONG);
+    void FileDownload(VARIANT_BOOL*);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/exdispid.d b/libphobos/libdruntime/core/sys/windows/exdispid.d
new file mode 100644
index 00000000000..fcf04f9945e
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/exdispid.d
@@ -0,0 +1,20 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.10
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_exdispid.d)
+ */
+module core.sys.windows.exdispid;
+version (Windows):
+
+enum : int {
+    DISPID_STATUSTEXTCHANGE = 102,
+    DISPID_PROGRESSCHANGE   = 108,
+    DISPID_TITLECHANGE      = 113,
+    DISPID_BEFORENAVIGATE2  = 250,
+    DISPID_NEWWINDOW2       = 251,
+    DISPID_DOCUMENTCOMPLETE = 259
+}
diff --git a/libphobos/libdruntime/core/sys/windows/httpext.d b/libphobos/libdruntime/core/sys/windows/httpext.d
new file mode 100644
index 00000000000..0a3d79c88cf
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/httpext.d
@@ -0,0 +1,114 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_httpext.d)
+ */
+module core.sys.windows.httpext;
+version (Windows):
+
+/* Comment from MinGW
+       httpext.h - Header for ISAPI extensions.
+
+       This file is part of a free library for the Win32 API.
+
+       This library is distributed in the hope that it will be useful,
+       but WITHOUT ANY WARRANTY; without even the implied warranty of
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+*/
+
+private import core.sys.windows.windows;
+
+enum {
+    HSE_VERSION_MAJOR               = 2,
+    HSE_VERSION_MINOR               = 0,
+    HSE_LOG_BUFFER_LEN              = 80,
+    HSE_MAX_EXT_DLL_NAME_LEN        = 256,
+    HSE_STATUS_SUCCESS              = 1,
+    HSE_STATUS_SUCCESS_AND_KEEP_CONN,
+    HSE_STATUS_PENDING,
+    HSE_STATUS_ERROR,
+    HSE_REQ_BASE                    = 0,
+    HSE_REQ_SEND_URL_REDIRECT_RESP,
+    HSE_REQ_SEND_URL,
+    HSE_REQ_SEND_RESPONSE_HEADER,
+    HSE_REQ_DONE_WITH_SESSION,
+    HSE_REQ_SEND_RESPONSE_HEADER_EX = 1016,
+    HSE_REQ_END_RESERVED            = 1000,
+    HSE_TERM_ADVISORY_UNLOAD        = 0x00000001,
+    HSE_TERM_MUST_UNLOAD,
+    HSE_IO_SYNC                     = 0x00000001,
+    HSE_IO_ASYNC,
+    HSE_IO_DISCONNECT_AFTER_SEND    = 0x00000004,
+    HSE_IO_SEND_HEADERS             = 0x00000008
+}
+
+mixin DECLARE_HANDLE!("HCONN");
+
+struct HSE_VERSION_INFO {
+    DWORD dwExtensionVersion;
+    CHAR[HSE_MAX_EXT_DLL_NAME_LEN] lpszExtensionDesc;
+}
+alias HSE_VERSION_INFO* LPHSE_VERSION_INFO;
+
+struct EXTENSION_CONTROL_BLOCK {
+    DWORD  cbSize = EXTENSION_CONTROL_BLOCK.sizeof;
+    DWORD  dwVersion;
+    HCONN  ConnID;
+    DWORD  dwHttpStatusCode;
+    CHAR[HSE_LOG_BUFFER_LEN] lpszLogData;
+    LPSTR  lpszMethod;
+    LPSTR  lpszQueryString;
+    LPSTR  lpszPathInfo;
+    LPSTR  lpszPathTranslated;
+    DWORD  cbTotalBytes;
+    DWORD  cbAvailable;
+    LPBYTE lpbData;
+    LPSTR  lpszContentType;
+    extern(Pascal) BOOL function(HCONN, LPSTR, LPVOID, LPDWORD)
+      GetServerVariable;
+    extern(Pascal) BOOL function(HCONN, LPVOID, LPDWORD, DWORD) WriteClient;
+    extern(Pascal) BOOL function(HCONN, LPVOID, LPDWORD) ReadClient;
+    extern(Pascal) BOOL function(HCONN, DWORD, LPVOID, LPDWORD, LPDWORD)
+      ServerSupportFunction;
+}
+alias EXTENSION_CONTROL_BLOCK* LPEXTENSION_CONTROL_BLOCK;
+
+extern (Pascal) {
+    alias BOOL function(HSE_VERSION_INFO*) PFN_GETEXTENSIONVERSION;
+    alias DWORD function(EXTENSION_CONTROL_BLOCK*) PFN_HTTPEXTENSIONPROC;
+    alias BOOL function(DWORD) PFN_TERMINATEEXTENSION;
+    alias VOID function(EXTENSION_CONTROL_BLOCK*, PVOID, DWORD, DWORD) PFN_HSE_IO_COMPLETION;
+}
+
+struct HSE_TF_INFO {
+    PFN_HSE_IO_COMPLETION pfnHseIO;
+    PVOID  pContext;
+    HANDLE hFile;
+    LPCSTR pszStatusCode;
+    DWORD  BytesToWrite;
+    DWORD  Offset;
+    PVOID  pHead;
+    DWORD  HeadLength;
+    PVOID  pTail;
+    DWORD  TailLength;
+    DWORD  dwFlags;
+}
+alias HSE_TF_INFO* LPHSE_TF_INFO;
+
+struct HSE_SEND_HEADER_EX_INFO {
+    LPCSTR pszStatus;
+    LPCSTR pszHeader;
+    DWORD  cchStatus;
+    DWORD  cchHeader;
+    BOOL   fKeepConn;
+}
+alias HSE_SEND_HEADER_EX_INFO* LPHSE_SEND_HEADER_EX_INF;
+
+extern (Pascal) {
+    BOOL GetExtensionVersion(HSE_VERSION_INFO*);
+    DWORD HttpExtensionProc(EXTENSION_CONTROL_BLOCK*);
+    BOOL TerminateExtension(DWORD);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/idispids.d b/libphobos/libdruntime/core/sys/windows/idispids.d
new file mode 100644
index 00000000000..074c3fa8b8f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/idispids.d
@@ -0,0 +1,16 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.10
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_idispids.d)
+ */
+module core.sys.windows.idispids;
+version (Windows):
+
+enum : int {
+    DISPID_AMBIENT_OFFLINEIFNOTCONNECTED = -5501,
+    DISPID_AMBIENT_SILENT                = -5502
+}
diff --git a/libphobos/libdruntime/core/sys/windows/imagehlp.d b/libphobos/libdruntime/core/sys/windows/imagehlp.d
new file mode 100644
index 00000000000..1a1676ca248
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/imagehlp.d
@@ -0,0 +1,379 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_imagehlp.d)
+ */
+module core.sys.windows.imagehlp;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+/* Comment from MinGW
+    NOTE: This strictly does not belong in the Win32 API since it's
+    really part of Platform SDK. However, GDB needs it and we might
+    as well provide it here.
+*/
+
+private import core.sys.windows.winbase, core.sys.windows.windef;
+
+// FIXME: check types of constants
+
+enum API_VERSION_NUMBER = 7;
+
+enum BIND_NO_BOUND_IMPORTS  = 1;
+enum BIND_NO_UPDATE         = 2;
+enum BIND_ALL_IMAGES        = 4;
+enum BIND_CACHE_IMPORT_DLLS = 8;
+
+enum {
+    CBA_DEFERRED_SYMBOL_LOAD_START = 1,
+    CBA_DEFERRED_SYMBOL_LOAD_COMPLETE,
+    CBA_DEFERRED_SYMBOL_LOAD_FAILURE,
+    CBA_SYMBOLS_UNLOADED,
+    CBA_DUPLICATE_SYMBOL
+}
+
+enum CERT_PE_IMAGE_DIGEST_DEBUG_INFO      = 1;
+enum CERT_PE_IMAGE_DIGEST_RESOURCES       = 2;
+enum CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO = 4;
+enum CERT_PE_IMAGE_DIGEST_NON_PE_INFO     = 8;
+
+enum CERT_SECTION_TYPE_ANY = 255;
+
+enum {
+    CHECKSUM_SUCCESS = 0,
+    CHECKSUM_OPEN_FAILURE,
+    CHECKSUM_MAP_FAILURE,
+    CHECKSUM_MAPVIEW_FAILURE,
+    CHECKSUM_UNICODE_FAILURE
+}
+
+enum IMAGE_SEPARATION = 65536;
+
+enum SPLITSYM_REMOVE_PRIVATE    = 1;
+enum SPLITSYM_EXTRACT_ALL       = 2;
+enum SPLITSYM_SYMBOLPATH_IS_SRC = 4;
+
+enum SYMF_OMAP_GENERATED = 1;
+enum SYMF_OMAP_MODIFIED  = 2;
+
+enum SYMOPT_CASE_INSENSITIVE  =  1;
+enum SYMOPT_UNDNAME           =  2;
+enum SYMOPT_DEFERRED_LOADS    =  4;
+enum SYMOPT_NO_CPP            =  8;
+//const SYMOPT_LOAD_LINES        = 16;
+//const SYMOPT_OMAP_FIND_NEAREST = 32;
+public import core.sys.windows.dbghelp_types :
+    SYMOPT_DEFERRED_LOAD,
+    SYMOPT_FAIL_CRITICAL_ERRORS,
+    SYMOPT_LOAD_LINES,
+    SYMOPT_DEBUG;
+
+enum UNDNAME_COMPLETE               =     0;
+enum UNDNAME_NO_LEADING_UNDERSCORES =     1;
+enum UNDNAME_NO_MS_KEYWORDS         =     2;
+enum UNDNAME_NO_FUNCTION_RETURNS    =     4;
+enum UNDNAME_NO_ALLOCATION_MODEL    =     8;
+enum UNDNAME_NO_ALLOCATION_LANGUAGE =    16;
+enum UNDNAME_NO_MS_THISTYPE         =    32;
+enum UNDNAME_NO_CV_THISTYPE         =    64;
+enum UNDNAME_NO_THISTYPE            =    96;
+enum UNDNAME_NO_ACCESS_SPECIFIERS   =   128;
+enum UNDNAME_NO_THROW_SIGNATURES    =   256;
+enum UNDNAME_NO_MEMBER_TYPE         =   512;
+enum UNDNAME_NO_RETURN_UDT_MODEL    =  1024;
+enum UNDNAME_32_BIT_DECODE          =  2048;
+enum UNDNAME_NAME_ONLY              =  4096;
+enum UNDNAME_NO_ARGUMENTS           =  8192;
+enum UNDNAME_NO_SPECIAL_SYMS        = 16384;
+
+enum IMAGEHLP_STATUS_REASON {
+    BindOutOfMemory,
+    BindRvaToVaFailed,
+    BindNoRoomInImage,
+    BindImportModuleFailed,
+    BindImportProcedureFailed,
+    BindImportModule,
+    BindImportProcedure,
+    BindForwarder,
+    BindForwarderNOT,
+    BindImageModified,
+    BindExpandFileHeaders,
+    BindImageComplete,
+    BindMismatchedSymbols,
+    BindSymbolsNotUpdated
+}
+
+struct LOADED_IMAGE {
+    LPSTR                 ModuleName;
+    HANDLE                hFile;
+    PUCHAR                MappedAddress;
+    PIMAGE_NT_HEADERS     FileHeader;
+    PIMAGE_SECTION_HEADER LastRvaSection;
+    ULONG                 NumberOfSections;
+    PIMAGE_SECTION_HEADER Sections;
+    ULONG                 Characteristics;
+    BOOLEAN               fSystemImage;
+    BOOLEAN               fDOSImage;
+    LIST_ENTRY            Links;
+    ULONG                 SizeOfImage;
+}
+alias LOADED_IMAGE* PLOADED_IMAGE;
+
+struct IMAGE_DEBUG_INFORMATION {
+    LIST_ENTRY                 List;
+    DWORD                      Size;
+    PVOID                      MappedBase;
+    USHORT                     Machine;
+    USHORT                     Characteristics;
+    DWORD                      CheckSum;
+    DWORD                      ImageBase;
+    DWORD                      SizeOfImage;
+    DWORD                      NumberOfSections;
+    PIMAGE_SECTION_HEADER      Sections;
+    DWORD                      ExportedNamesSize;
+    LPSTR                      ExportedNames;
+    DWORD                      NumberOfFunctionTableEntries;
+    PIMAGE_FUNCTION_ENTRY      FunctionTableEntries;
+    DWORD                      LowestFunctionStartingAddress;
+    DWORD                      HighestFunctionEndingAddress;
+    DWORD                      NumberOfFpoTableEntries;
+    PFPO_DATA                  FpoTableEntries;
+    DWORD                      SizeOfCoffSymbols;
+    PIMAGE_COFF_SYMBOLS_HEADER CoffSymbols;
+    DWORD                      SizeOfCodeViewSymbols;
+    PVOID                      CodeViewSymbols;
+    LPSTR                      ImageFilePath;
+    LPSTR                      ImageFileName;
+    LPSTR                      DebugFilePath;
+    DWORD                      TimeDateStamp;
+    BOOL                       RomImage;
+    PIMAGE_DEBUG_DIRECTORY     DebugDirectory;
+    DWORD                      NumberOfDebugDirectories;
+    DWORD[3]                   Reserved;
+}
+alias IMAGE_DEBUG_INFORMATION* PIMAGE_DEBUG_INFORMATION;
+
+enum ADDRESS_MODE {
+    AddrMode1616,
+    AddrMode1632,
+    AddrModeReal,
+    AddrModeFlat
+}
+
+struct ADDRESS {
+    DWORD        Offset;
+    WORD         Segment;
+    ADDRESS_MODE Mode;
+}
+alias ADDRESS* LPADDRESS;
+
+struct KDHELP {
+    DWORD Thread;
+    DWORD ThCallbackStack;
+    DWORD NextCallback;
+    DWORD FramePointer;
+    DWORD KiCallUserMode;
+    DWORD KeUserCallbackDispatcher;
+    DWORD SystemRangeStart;
+    DWORD ThCallbackBStore;
+    DWORD KiUserExceptionDispatcher;
+    DWORD StackBase;
+    DWORD StackLimit;
+    DWORD[5] Reserved;
+}
+alias KDHELP* PKDHELP;
+
+struct STACKFRAME {
+    ADDRESS  AddrPC;
+    ADDRESS  AddrReturn;
+    ADDRESS  AddrFrame;
+    ADDRESS  AddrStack;
+    LPVOID   FuncTableEntry;
+    DWORD[4] Params;
+    BOOL     Far;
+    BOOL     Virtual;
+    DWORD[3] Reserved;
+    KDHELP   KdHelp;
+    ADDRESS  AddrBStore;
+}
+alias STACKFRAME* LPSTACKFRAME;
+
+/*
+struct API_VERSION {
+    USHORT MajorVersion;
+    USHORT MinorVersion;
+    USHORT Revision;
+    USHORT Reserved;
+}
+*/
+public import core.sys.windows.dbghelp_types : API_VERSION;
+alias API_VERSION* LPAPI_VERSION;
+
+enum SYM_TYPE {
+    SymNone,
+    SymCoff,
+    SymCv,
+    SymPdb,
+    SymExport,
+    SymDeferred,
+    SymSym
+}
+
+struct IMAGEHLP_SYMBOL {
+    DWORD   SizeOfStruct;
+    DWORD   Address;
+    DWORD   Size;
+    DWORD   Flags;
+    DWORD   MaxNameLength;
+    CHAR[1] Name;
+}
+alias IMAGEHLP_SYMBOL* PIMAGEHLP_SYMBOL;
+
+struct IMAGEHLP_MODULE {
+    DWORD     SizeOfStruct;
+    DWORD     BaseOfImage;
+    DWORD     ImageSize;
+    DWORD     TimeDateStamp;
+    DWORD     CheckSum;
+    DWORD     NumSyms;
+    SYM_TYPE  SymType;
+    CHAR[32]  ModuleName;
+    CHAR[256] ImageName;
+    CHAR[256] LoadedImageName;
+}
+alias IMAGEHLP_MODULE* PIMAGEHLP_MODULE;
+
+struct IMAGEHLP_LINE {
+    DWORD SizeOfStruct;
+    DWORD Key;
+    DWORD LineNumber;
+    PCHAR FileName;
+    DWORD Address;
+}
+alias IMAGEHLP_LINE* PIMAGEHLP_LINE;
+
+struct IMAGEHLP_DEFERRED_SYMBOL_LOAD {
+    DWORD          SizeOfStruct;
+    DWORD          BaseOfImage;
+    DWORD          CheckSum;
+    DWORD          TimeDateStamp;
+    CHAR[MAX_PATH] FileName;
+    BOOLEAN        Reparse;
+}
+alias IMAGEHLP_DEFERRED_SYMBOL_LOAD* PIMAGEHLP_DEFERRED_SYMBOL_LOAD;
+
+struct IMAGEHLP_DUPLICATE_SYMBOL {
+    DWORD            SizeOfStruct;
+    DWORD            NumberOfDups;
+    PIMAGEHLP_SYMBOL Symbol;
+    ULONG            SelectedSymbol;
+}
+alias IMAGEHLP_DUPLICATE_SYMBOL* PIMAGEHLP_DUPLICATE_SYMBOL;
+
+mixin DECLARE_HANDLE!("DIGEST_HANDLE");
+
+extern (Windows) {
+    alias BOOL function(IMAGEHLP_STATUS_REASON, LPSTR, LPSTR, ULONG, ULONG)
+      PIMAGEHLP_STATUS_ROUTINE;
+    alias BOOL function(HANDLE , LPCVOID, LPVOID, DWORD, LPDWORD)
+      PREAD_PROCESS_MEMORY_ROUTINE;
+    alias LPVOID function(HANDLE, DWORD) PFUNCTION_TABLE_ACCESS_ROUTINE;
+    alias DWORD function(HANDLE, DWORD) PGET_MODULE_BASE_ROUTINE;
+    alias DWORD function(HANDLE, HANDLE, LPADDRESS)
+      PTRANSLATE_ADDRESS_ROUTINE;
+    alias BOOL function(LPSTR, ULONG, PVOID) PSYM_ENUMMODULES_CALLBACK;
+    alias BOOL function(LPSTR, ULONG, ULONG, PVOID) PSYM_ENUMSYMBOLS_CALLBACK;
+    alias BOOL function(LPSTR, ULONG, ULONG, PVOID)
+      PENUMLOADED_MODULES_CALLBACK;
+    alias BOOL function(HANDLE, ULONG, PVOID, PVOID)
+      PSYMBOL_REGISTERED_CALLBACK;
+    alias BOOL function(DIGEST_HANDLE refdata, PBYTE pData, DWORD dwLength)
+      DIGEST_FUNCTION;
+
+    PIMAGE_NT_HEADERS CheckSumMappedFile(LPVOID, DWORD, LPDWORD, LPDWORD);
+    DWORD MapFileAndCheckSumA(LPSTR, LPDWORD, LPDWORD);
+    DWORD MapFileAndCheckSumW(PWSTR, LPDWORD, LPDWORD);
+    BOOL TouchFileTimes(HANDLE, LPSYSTEMTIME);
+    BOOL SplitSymbols(LPSTR, LPSTR, LPSTR, DWORD);
+    HANDLE FindDebugInfoFile(LPSTR, LPSTR, LPSTR);
+    HANDLE FindExecutableImage(LPSTR, LPSTR, LPSTR);
+    BOOL UpdateDebugInfoFile(LPSTR, LPSTR, LPSTR, PIMAGE_NT_HEADERS);
+    BOOL UpdateDebugInfoFileEx(LPSTR, LPSTR, LPSTR, PIMAGE_NT_HEADERS, DWORD);
+    BOOL BindImage(LPSTR, LPSTR, LPSTR);
+    BOOL BindImageEx(DWORD, LPSTR, LPSTR, LPSTR, PIMAGEHLP_STATUS_ROUTINE);
+    BOOL ReBaseImage(LPSTR, LPSTR, BOOL, BOOL, BOOL, ULONG, ULONG*, ULONG*,
+      ULONG*, ULONG*, ULONG);
+    PLOADED_IMAGE ImageLoad(LPSTR, LPSTR);
+    BOOL ImageUnload(PLOADED_IMAGE);
+    PIMAGE_NT_HEADERS ImageNtHeader(PVOID);
+    PVOID ImageDirectoryEntryToData(PVOID, BOOLEAN, USHORT, PULONG);
+    PIMAGE_SECTION_HEADER ImageRvaToSection(PIMAGE_NT_HEADERS, PVOID, ULONG);
+    PVOID ImageRvaToVa(PIMAGE_NT_HEADERS, PVOID, ULONG,
+      PIMAGE_SECTION_HEADER*);
+    BOOL MapAndLoad(LPSTR, LPSTR, PLOADED_IMAGE, BOOL, BOOL);
+    BOOL GetImageConfigInformation(PLOADED_IMAGE,
+      PIMAGE_LOAD_CONFIG_DIRECTORY);
+    DWORD GetImageUnusedHeaderBytes(PLOADED_IMAGE, LPDWORD);
+    BOOL SetImageConfigInformation(PLOADED_IMAGE,
+      PIMAGE_LOAD_CONFIG_DIRECTORY);
+    BOOL UnMapAndLoad(PLOADED_IMAGE);
+    PIMAGE_DEBUG_INFORMATION MapDebugInformation(HANDLE, LPSTR, LPSTR, DWORD);
+    BOOL UnmapDebugInformation(PIMAGE_DEBUG_INFORMATION);
+    HANDLE FindExecutableImage(LPSTR, LPSTR, LPSTR);
+    BOOL SearchTreeForFile(LPSTR, LPSTR, LPSTR);
+    BOOL MakeSureDirectoryPathExists(LPCSTR);
+    DWORD UnDecorateSymbolName(LPCSTR, LPSTR, DWORD, DWORD);
+    BOOL StackWalk(DWORD, HANDLE, HANDLE, LPSTACKFRAME, LPVOID,
+      PREAD_PROCESS_MEMORY_ROUTINE, PFUNCTION_TABLE_ACCESS_ROUTINE,
+      PGET_MODULE_BASE_ROUTINE, PTRANSLATE_ADDRESS_ROUTINE);
+    LPAPI_VERSION ImagehlpApiVersion();
+    LPAPI_VERSION ImagehlpApiVersionEx(LPAPI_VERSION);
+    DWORD GetTimestampForLoadedLibrary(HMODULE);
+    BOOL RemovePrivateCvSymbolic(PCHAR, PCHAR*, ULONG*);
+    VOID RemoveRelocations(PCHAR);
+    DWORD SymSetOptions(DWORD);
+    DWORD SymGetOptions();
+    BOOL SymCleanup(HANDLE);
+    BOOL SymEnumerateModules(HANDLE, PSYM_ENUMMODULES_CALLBACK, PVOID);
+    BOOL SymEnumerateSymbols(HANDLE, DWORD, PSYM_ENUMSYMBOLS_CALLBACK, PVOID);
+    BOOL EnumerateLoadedModules(HANDLE, PENUMLOADED_MODULES_CALLBACK, PVOID);
+    LPVOID SymFunctionTableAccess(HANDLE, DWORD);
+    BOOL SymGetModuleInfo(HANDLE, DWORD, PIMAGEHLP_MODULE);
+    DWORD SymGetModuleBase(HANDLE, DWORD);
+    BOOL SymGetSymFromAddr(HANDLE, DWORD, PDWORD, PIMAGEHLP_SYMBOL);
+    BOOL SymGetSymFromName(HANDLE, LPSTR, PIMAGEHLP_SYMBOL);
+    BOOL SymGetSymNext(HANDLE, PIMAGEHLP_SYMBOL);
+    BOOL SymGetSymPrev(HANDLE, PIMAGEHLP_SYMBOL);
+    BOOL SymGetLineFromAddr(HANDLE, DWORD, PDWORD, PIMAGEHLP_LINE);
+    BOOL SymGetLineFromName(HANDLE, LPSTR, LPSTR, DWORD, PLONG,
+      PIMAGEHLP_LINE);
+    BOOL SymGetLineNext(HANDLE, PIMAGEHLP_LINE);
+    BOOL SymGetLinePrev(HANDLE, PIMAGEHLP_LINE);
+    BOOL SymMatchFileName(LPSTR, LPSTR, LPSTR*, LPSTR*);
+    BOOL SymInitialize(HANDLE, LPSTR, BOOL);
+    BOOL SymGetSearchPath(HANDLE, LPSTR, DWORD);
+    BOOL SymSetSearchPath(HANDLE, LPSTR);
+    BOOL SymLoadModule(HANDLE, HANDLE, PSTR, PSTR, DWORD, DWORD);
+    BOOL SymUnloadModule(HANDLE, DWORD);
+    BOOL SymUnDName(PIMAGEHLP_SYMBOL, LPSTR, DWORD);
+    BOOL SymRegisterCallback(HANDLE, PSYMBOL_REGISTERED_CALLBACK, PVOID);
+    BOOL ImageGetDigestStream(HANDLE, DWORD, DIGEST_FUNCTION, DIGEST_HANDLE);
+    BOOL ImageAddCertificate(HANDLE, LPWIN_CERTIFICATE, PDWORD);
+    BOOL ImageRemoveCertificate(HANDLE, DWORD);
+    BOOL ImageEnumerateCertificates(HANDLE, WORD, PDWORD, PDWORD, DWORD);
+    BOOL ImageGetCertificateData(HANDLE, DWORD, LPWIN_CERTIFICATE, PDWORD);
+    BOOL ImageGetCertificateHeader(HANDLE, DWORD, LPWIN_CERTIFICATE);
+    BOOL CopyPdb(CHAR*, CHAR*, BOOL);
+    BOOL RemovePrivateCvSymbolicEx(PCHAR, ULONG, PCHAR*, ULONG*);
+}
+
+version (Unicode) {
+    alias MapFileAndCheckSumW MapFileAndCheckSum;
+} else {
+    alias MapFileAndCheckSumA MapFileAndCheckSum;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/imm.d b/libphobos/libdruntime/core/sys/windows/imm.d
new file mode 100644
index 00000000000..6f8f25a5574
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/imm.d
@@ -0,0 +1,484 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_imm.d)
+ */
+module core.sys.windows.imm;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "imm32");
+
+import core.sys.windows.windef, core.sys.windows.wingdi;
+import core.sys.windows.winuser; // for the MFS_xxx enums.
+private import core.sys.windows.w32api;
+
+enum WM_CONVERTREQUESTEX     = 0x108;
+enum WM_IME_STARTCOMPOSITION = 0x10D;
+enum WM_IME_ENDCOMPOSITION   = 0x10E;
+enum WM_IME_COMPOSITION      = 0x10F;
+enum WM_IME_KEYLAST          = 0x10F;
+enum WM_IME_SETCONTEXT       = 0x281;
+enum WM_IME_NOTIFY           = 0x282;
+enum WM_IME_CONTROL          = 0x283;
+enum WM_IME_COMPOSITIONFULL  = 0x284;
+enum WM_IME_SELECT           = 0x285;
+enum WM_IME_CHAR             = 0x286;
+//static if (_WIN32_WINNT >= 0x500) {
+enum WM_IME_REQUEST      = 0x288;
+//}
+enum WM_IME_KEYDOWN          = 0x290;
+enum WM_IME_KEYUP            = 0x291;
+
+
+enum IMC_GETCANDIDATEPOS=7;
+enum IMC_SETCANDIDATEPOS=8;
+enum IMC_GETCOMPOSITIONFONT=9;
+enum IMC_SETCOMPOSITIONFONT=10;
+enum IMC_GETCOMPOSITIONWINDOW=11;
+enum IMC_SETCOMPOSITIONWINDOW=12;
+enum IMC_GETSTATUSWINDOWPOS=15;
+enum IMC_SETSTATUSWINDOWPOS=16;
+enum IMC_CLOSESTATUSWINDOW=0x21;
+enum IMC_OPENSTATUSWINDOW=0x22;
+enum IMN_CLOSESTATUSWINDOW=1;
+enum IMN_OPENSTATUSWINDOW=2;
+enum IMN_CHANGECANDIDATE=3;
+enum IMN_CLOSECANDIDATE=4;
+enum IMN_OPENCANDIDATE=5;
+enum IMN_SETCONVERSIONMODE=6;
+enum IMN_SETSENTENCEMODE=7;
+enum IMN_SETOPENSTATUS=8;
+enum IMN_SETCANDIDATEPOS=9;
+enum IMN_SETCOMPOSITIONFONT=10;
+enum IMN_SETCOMPOSITIONWINDOW=11;
+enum IMN_SETSTATUSWINDOWPOS=12;
+enum IMN_GUIDELINE=13;
+enum IMN_PRIVATE=14;
+
+enum NI_OPENCANDIDATE=16;
+enum NI_CLOSECANDIDATE=17;
+enum NI_SELECTCANDIDATESTR=18;
+enum NI_CHANGECANDIDATELIST=19;
+enum NI_FINALIZECONVERSIONRESULT=20;
+enum NI_COMPOSITIONSTR=21;
+enum NI_SETCANDIDATE_PAGESTART=22;
+enum NI_SETCANDIDATE_PAGESIZE=23;
+enum NI_IMEMENUSELECTED=24;
+
+enum ISC_SHOWUICANDIDATEWINDOW=1;
+enum ISC_SHOWUICOMPOSITIONWINDOW=0x80000000;
+enum ISC_SHOWUIGUIDELINE=0x40000000;
+enum ISC_SHOWUIALLCANDIDATEWINDOW=15;
+enum ISC_SHOWUIALL=0xC000000F;
+
+enum CPS_COMPLETE=1;
+enum CPS_CONVERT=2;
+enum CPS_REVERT=3;
+enum CPS_CANCEL=4;
+
+enum IME_CHOTKEY_IME_NONIME_TOGGLE=16;
+enum IME_CHOTKEY_SHAPE_TOGGLE=17;
+enum IME_CHOTKEY_SYMBOL_TOGGLE=18;
+enum IME_JHOTKEY_CLOSE_OPEN=0x30;
+enum IME_KHOTKEY_SHAPE_TOGGLE=0x50;
+enum IME_KHOTKEY_HANJACONVERT=0x51;
+enum IME_KHOTKEY_ENGLISH=0x52;
+enum IME_THOTKEY_IME_NONIME_TOGGLE=0x70;
+enum IME_THOTKEY_SHAPE_TOGGLE=0x71;
+enum IME_THOTKEY_SYMBOL_TOGGLE=0x72;
+enum IME_HOTKEY_DSWITCH_FIRST=256;
+enum IME_HOTKEY_DSWITCH_LAST=0x11F;
+enum IME_ITHOTKEY_RESEND_RESULTSTR=512;
+enum IME_ITHOTKEY_PREVIOUS_COMPOSITION=513;
+enum IME_ITHOTKEY_UISTYLE_TOGGLE=514;
+
+enum GCS_COMPREADSTR=1;
+enum GCS_COMPREADATTR=2;
+enum GCS_COMPREADCLAUSE=4;
+enum GCS_COMPSTR=8;
+enum GCS_COMPATTR=16;
+enum GCS_COMPCLAUSE=32;
+enum GCS_CURSORPOS=128;
+enum GCS_DELTASTART=256;
+enum GCS_RESULTREADSTR=512;
+enum GCS_RESULTREADCLAUSE=1024;
+enum GCS_RESULTSTR=2048;
+enum GCS_RESULTCLAUSE=4096;
+
+enum CS_INSERTCHAR=0x2000;
+enum CS_NOMOVECARET=0x4000;
+
+enum IMEVER_0310=0x3000A;
+enum IMEVER_0400=0x40000;
+
+enum IME_PROP_AT_CARET=0x10000;
+enum IME_PROP_SPECIAL_UI=0x20000;
+enum IME_PROP_CANDLIST_START_FROM_1=0x40000;
+enum IME_PROP_UNICODE=0x80000;
+
+enum UI_CAP_2700=1;
+enum UI_CAP_ROT90=2;
+enum UI_CAP_ROTANY=4;
+
+enum SCS_CAP_COMPSTR=1;
+enum SCS_CAP_MAKEREAD=2;
+enum SELECT_CAP_CONVERSION=1;
+enum SELECT_CAP_SENTENCE=2;
+enum GGL_LEVEL=1;
+enum GGL_INDEX=2;
+enum GGL_STRING=3;
+enum GGL_PRIVATE=4;
+enum GL_LEVEL_NOGUIDELINE=0;
+enum GL_LEVEL_FATAL=1;
+enum GL_LEVEL_ERROR=2;
+enum GL_LEVEL_WARNING=3;
+enum GL_LEVEL_INFORMATION=4;
+enum GL_ID_UNKNOWN=0;
+enum GL_ID_NOMODULE=1;
+enum GL_ID_NODICTIONARY=16;
+enum GL_ID_CANNOTSAVE=17;
+enum GL_ID_NOCONVERT=32;
+enum GL_ID_TYPINGERROR=33;
+enum GL_ID_TOOMANYSTROKE=34;
+enum GL_ID_READINGCONFLICT=35;
+enum GL_ID_INPUTREADING=36;
+enum GL_ID_INPUTRADICAL=37;
+enum GL_ID_INPUTCODE=38;
+enum GL_ID_INPUTSYMBOL=39;
+enum GL_ID_CHOOSECANDIDATE=40;
+enum GL_ID_REVERSECONVERSION=41;
+enum GL_ID_PRIVATE_FIRST=0x8000;
+enum GL_ID_PRIVATE_LAST=0xFFFF;
+
+enum DWORD IGP_GETIMEVERSION = -4;
+enum IGP_PROPERTY=4;
+enum IGP_CONVERSION=8;
+enum IGP_SENTENCE=12;
+enum IGP_UI=16;
+enum IGP_SETCOMPSTR=0x14;
+enum IGP_SELECT=0x18;
+
+enum SCS_SETSTR       = GCS_COMPREADSTR|GCS_COMPSTR;
+enum SCS_CHANGEATTR   = GCS_COMPREADATTR|GCS_COMPATTR;
+enum SCS_CHANGECLAUSE = GCS_COMPREADCLAUSE|GCS_COMPCLAUSE;
+
+enum ATTR_INPUT=0;
+enum ATTR_TARGET_CONVERTED=1;
+enum ATTR_CONVERTED=2;
+enum ATTR_TARGET_NOTCONVERTED=3;
+enum ATTR_INPUT_ERROR=4;
+enum ATTR_FIXEDCONVERTED=5;
+enum CFS_DEFAULT=0;
+enum CFS_RECT=1;
+enum CFS_POINT=2;
+enum CFS_SCREEN=4;
+enum CFS_FORCE_POSITION=32;
+enum CFS_CANDIDATEPOS=64;
+enum CFS_EXCLUDE=128;
+enum GCL_CONVERSION=1;
+enum GCL_REVERSECONVERSION=2;
+enum GCL_REVERSE_LENGTH=3;
+
+enum IME_CMODE_ALPHANUMERIC=0;
+enum IME_CMODE_NATIVE=1;
+enum IME_CMODE_CHINESE=IME_CMODE_NATIVE;
+enum IME_CMODE_HANGEUL=IME_CMODE_NATIVE;
+enum IME_CMODE_HANGUL=IME_CMODE_NATIVE;
+enum IME_CMODE_JAPANESE=IME_CMODE_NATIVE;
+enum IME_CMODE_KATAKANA=2;
+enum IME_CMODE_LANGUAGE=3;
+enum IME_CMODE_FULLSHAPE=8;
+enum IME_CMODE_ROMAN=16;
+enum IME_CMODE_CHARCODE=32;
+enum IME_CMODE_HANJACONVERT=64;
+enum IME_CMODE_SOFTKBD=128;
+enum IME_CMODE_NOCONVERSION=256;
+enum IME_CMODE_EUDC=512;
+enum IME_CMODE_SYMBOL=1024;
+enum IME_CMODE_FIXED=2048;
+enum IME_SMODE_NONE=0;
+enum IME_SMODE_PLAURALCLAUSE=1;
+enum IME_SMODE_SINGLECONVERT=2;
+enum IME_SMODE_AUTOMATIC=4;
+enum IME_SMODE_PHRASEPREDICT=8;
+enum IME_CAND_UNKNOWN=0;
+enum IME_CAND_READ=1;
+enum IME_CAND_CODE=2;
+enum IME_CAND_MEANING=3;
+enum IME_CAND_RADICAL=4;
+enum IME_CAND_STROKE=5;
+enum IMM_ERROR_NODATA=(-1);
+enum IMM_ERROR_GENERAL=(-2);
+enum IME_CONFIG_GENERAL=1;
+enum IME_CONFIG_REGISTERWORD=2;
+enum IME_CONFIG_SELECTDICTIONARY=3;
+enum IME_ESC_QUERY_SUPPORT=3;
+enum IME_ESC_RESERVED_FIRST=4;
+enum IME_ESC_RESERVED_LAST=0x7FF;
+enum IME_ESC_PRIVATE_FIRST=0x800;
+enum IME_ESC_PRIVATE_LAST=0xFFF;
+enum IME_ESC_SEQUENCE_TO_INTERNAL=0x1001;
+enum IME_ESC_GET_EUDC_DICTIONARY=0x1003;
+enum IME_ESC_SET_EUDC_DICTIONARY=0x1004;
+enum IME_ESC_MAX_KEY=0x1005;
+enum IME_ESC_IME_NAME=0x1006;
+enum IME_ESC_SYNC_HOTKEY=0x1007;
+enum IME_ESC_HANJA_MODE=0x1008;
+enum IME_ESC_AUTOMATA=0x1009;
+enum IME_REGWORD_STYLE_EUDC=1;
+enum IME_REGWORD_STYLE_USER_FIRST=0x80000000;
+enum IME_REGWORD_STYLE_USER_LAST=0xFFFFFFFF;
+
+enum SOFTKEYBOARD_TYPE_T1=1;
+enum SOFTKEYBOARD_TYPE_C1=2;
+
+enum IMEMENUITEM_STRING_SIZE=80;
+
+enum MOD_ALT=1;
+enum MOD_CONTROL=2;
+enum MOD_SHIFT=4;
+enum MOD_WIN=8;
+enum MOD_IGNORE_ALL_MODIFIER=1024;
+enum MOD_ON_KEYUP=2048;
+enum MOD_RIGHT=16384;
+enum MOD_LEFT=32768;
+
+enum IACE_CHILDREN=1;
+enum IACE_DEFAULT=16;
+enum IACE_IGNORENOCONTEXT=32;
+
+enum IGIMIF_RIGHTMENU=1;
+
+enum IGIMII_CMODE=1;
+enum IGIMII_SMODE=2;
+enum IGIMII_CONFIGURE=4;
+enum IGIMII_TOOLS=8;
+enum IGIMII_HELP=16;
+enum IGIMII_OTHER=32;
+enum IGIMII_INPUTTOOLS=64;
+
+enum IMFT_RADIOCHECK=1;
+enum IMFT_SEPARATOR=2;
+enum IMFT_SUBMENU=4;
+
+enum IMFS_GRAYED=MFS_GRAYED;
+enum IMFS_DISABLED=MFS_DISABLED;
+enum IMFS_CHECKED=MFS_CHECKED;
+enum IMFS_HILITE=MFS_HILITE;
+enum IMFS_ENABLED=MFS_ENABLED;
+enum IMFS_UNCHECKED=MFS_UNCHECKED;
+enum IMFS_UNHILITE=MFS_UNHILITE;
+enum IMFS_DEFAULT=MFS_DEFAULT;
+
+enum STYLE_DESCRIPTION_SIZE=32;
+
+alias DWORD HIMC;
+alias DWORD HIMCC;
+alias HKL* LPHKL;
+
+struct COMPOSITIONFORM{
+    DWORD dwStyle;
+    POINT ptCurrentPos;
+    RECT rcArea;
+}
+alias COMPOSITIONFORM* PCOMPOSITIONFORM, LPCOMPOSITIONFORM;
+
+struct CANDIDATEFORM{
+    DWORD dwIndex;
+    DWORD dwStyle;
+    POINT ptCurrentPos;
+    RECT rcArea;
+}
+alias CANDIDATEFORM* PCANDIDATEFORM, LPCANDIDATEFORM;
+
+struct CANDIDATELIST{
+    DWORD dwSize;
+    DWORD dwStyle;
+    DWORD dwCount;
+    DWORD dwSelection;
+    DWORD dwPageStart;
+    DWORD dwPageSize;
+    DWORD[1] dwOffset;
+}
+alias CANDIDATELIST* PCANDIDATELIST, LPCANDIDATELIST;
+
+struct REGISTERWORDA{
+    LPSTR lpReading;
+    LPSTR lpWord;
+}
+alias REGISTERWORDA* PREGISTERWORDA, LPREGISTERWORDA;
+
+struct REGISTERWORDW{
+    LPWSTR lpReading;
+    LPWSTR lpWord;
+}
+alias REGISTERWORDW* PREGISTERWORDW, LPREGISTERWORDW;
+
+struct STYLEBUFA{
+    DWORD dwStyle;
+    CHAR[STYLE_DESCRIPTION_SIZE] szDescription;
+}
+alias STYLEBUFA* PSTYLEBUFA, LPSTYLEBUFA;
+
+struct STYLEBUFW{
+    DWORD dwStyle;
+    WCHAR[STYLE_DESCRIPTION_SIZE] szDescription;
+}
+alias STYLEBUFW* PSTYLEBUFW, LPSTYLEBUFW;
+
+struct IMEMENUITEMINFOA{
+    UINT cbSize = this.sizeof;
+    UINT fType;
+    UINT fState;
+    UINT wID;
+    HBITMAP hbmpChecked;
+    HBITMAP hbmpUnchecked;
+    DWORD dwItemData;
+    CHAR[IMEMENUITEM_STRING_SIZE] szString;
+    HBITMAP hbmpItem;
+}
+alias IMEMENUITEMINFOA* PIMEMENUITEMINFOA, LPIMEMENUITEMINFOA;
+
+struct IMEMENUITEMINFOW{
+    UINT cbSize = this.sizeof;
+    UINT fType;
+    UINT fState;
+    UINT wID;
+    HBITMAP hbmpChecked;
+    HBITMAP hbmpUnchecked;
+    DWORD dwItemData;
+    WCHAR[IMEMENUITEM_STRING_SIZE] szString;
+    HBITMAP hbmpItem;
+}
+alias IMEMENUITEMINFOW* PIMEMENUITEMINFOW, LPIMEMENUITEMINFOW;
+
+alias int function (LPCSTR, DWORD, LPCSTR, LPVOID)  REGISTERWORDENUMPROCA;
+alias int function (LPCWSTR, DWORD, LPCWSTR, LPVOID) REGISTERWORDENUMPROCW;
+
+version(Unicode) {
+    alias REGISTERWORDENUMPROCW REGISTERWORDENUMPROC;
+    alias REGISTERWORDW REGISTERWORD;
+    alias IMEMENUITEMINFOW IMEMENUITEMINFO;
+    alias STYLEBUFW STYLEBUF;
+} else {
+    alias REGISTERWORDENUMPROCA REGISTERWORDENUMPROC;
+    alias REGISTERWORDA REGISTERWORD;
+    alias IMEMENUITEMINFOA IMEMENUITEMINFO;
+    alias STYLEBUFA STYLEBUF;
+}
+
+alias STYLEBUF* PSTYLEBUF, LPSTYLEBUF;
+alias REGISTERWORD* PREGISTERWORD, LPREGISTERWORD;
+alias IMEMENUITEMINFO* PIMEMENUITEMINFO, LPIMEMENUITEMINFO;
+
+
+extern (Windows):
+HKL ImmInstallIMEA(LPCSTR, LPCSTR);
+HKL ImmInstallIMEW(LPCWSTR, LPCWSTR);
+HWND ImmGetDefaultIMEWnd(HWND);
+UINT ImmGetDescriptionA(HKL, LPSTR, UINT);
+UINT ImmGetDescriptionW(HKL, LPWSTR, UINT);
+UINT ImmGetIMEFileNameA(HKL, LPSTR, UINT);
+UINT ImmGetIMEFileNameW(HKL, LPWSTR, UINT);
+DWORD ImmGetProperty(HKL, DWORD);
+BOOL ImmIsIME(HKL);
+BOOL ImmSimulateHotKey(HWND, DWORD);
+HIMC ImmCreateContext();
+BOOL ImmDestroyContext(HIMC);
+HIMC ImmGetContext(HWND);
+BOOL ImmReleaseContext(HWND, HIMC);
+HIMC ImmAssociateContext(HWND, HIMC);
+LONG ImmGetCompositionStringA(HIMC, DWORD, PVOID, DWORD);
+LONG ImmGetCompositionStringW(HIMC, DWORD, PVOID, DWORD);
+BOOL ImmSetCompositionStringA(HIMC, DWORD, PCVOID, DWORD, PCVOID, DWORD);
+BOOL ImmSetCompositionStringW(HIMC, DWORD, PCVOID, DWORD, PCVOID, DWORD);
+DWORD ImmGetCandidateListCountA(HIMC, PDWORD);
+DWORD ImmGetCandidateListCountW(HIMC, PDWORD);
+DWORD ImmGetCandidateListA(HIMC, DWORD, PCANDIDATELIST, DWORD);
+DWORD ImmGetCandidateListW(HIMC, DWORD, PCANDIDATELIST, DWORD);
+DWORD ImmGetGuideLineA(HIMC, DWORD, LPSTR, DWORD);
+DWORD ImmGetGuideLineW(HIMC, DWORD, LPWSTR, DWORD);
+BOOL ImmGetConversionStatus(HIMC, LPDWORD, PDWORD);
+BOOL ImmSetConversionStatus(HIMC, DWORD, DWORD);
+BOOL ImmGetOpenStatus(HIMC);
+BOOL ImmSetOpenStatus(HIMC, BOOL);
+
+BOOL ImmGetCompositionFontA(HIMC, LPLOGFONTA);
+BOOL ImmGetCompositionFontW(HIMC, LPLOGFONTW);
+BOOL ImmSetCompositionFontA(HIMC, LPLOGFONTA);
+BOOL ImmSetCompositionFontW(HIMC, LPLOGFONTW);
+
+BOOL ImmConfigureIMEA(HKL, HWND, DWORD, PVOID);
+BOOL ImmConfigureIMEW(HKL, HWND, DWORD, PVOID);
+LRESULT ImmEscapeA(HKL, HIMC, UINT, PVOID);
+LRESULT ImmEscapeW(HKL, HIMC, UINT, PVOID);
+DWORD ImmGetConversionListA(HKL, HIMC, LPCSTR, PCANDIDATELIST, DWORD, UINT);
+DWORD ImmGetConversionListW(HKL, HIMC, LPCWSTR, PCANDIDATELIST, DWORD, UINT);
+BOOL ImmNotifyIME(HIMC, DWORD, DWORD, DWORD);
+BOOL ImmGetStatusWindowPos(HIMC, LPPOINT);
+BOOL ImmSetStatusWindowPos(HIMC, LPPOINT);
+BOOL ImmGetCompositionWindow(HIMC, PCOMPOSITIONFORM);
+BOOL ImmSetCompositionWindow(HIMC, PCOMPOSITIONFORM);
+BOOL ImmGetCandidateWindow(HIMC, DWORD, PCANDIDATEFORM);
+BOOL ImmSetCandidateWindow(HIMC, PCANDIDATEFORM);
+BOOL ImmIsUIMessageA(HWND, UINT, WPARAM, LPARAM);
+BOOL ImmIsUIMessageW(HWND, UINT, WPARAM, LPARAM);
+UINT ImmGetVirtualKey(HWND);
+BOOL ImmRegisterWordA(HKL, LPCSTR, DWORD, LPCSTR);
+BOOL ImmRegisterWordW(HKL, LPCWSTR, DWORD, LPCWSTR);
+BOOL ImmUnregisterWordA(HKL, LPCSTR, DWORD, LPCSTR);
+BOOL ImmUnregisterWordW(HKL, LPCWSTR, DWORD, LPCWSTR);
+UINT ImmGetRegisterWordStyleA(HKL, UINT, PSTYLEBUFA);
+UINT ImmGetRegisterWordStyleW(HKL, UINT, PSTYLEBUFW);
+UINT ImmEnumRegisterWordA(HKL, REGISTERWORDENUMPROCA, LPCSTR, DWORD, LPCSTR, PVOID);
+UINT ImmEnumRegisterWordW(HKL, REGISTERWORDENUMPROCW, LPCWSTR, DWORD, LPCWSTR, PVOID);
+BOOL EnableEUDC(BOOL);
+BOOL ImmDisableIME(DWORD);
+DWORD ImmGetImeMenuItemsA(HIMC, DWORD, DWORD, LPIMEMENUITEMINFOA, LPIMEMENUITEMINFOA, DWORD);
+DWORD ImmGetImeMenuItemsW(HIMC, DWORD, DWORD, LPIMEMENUITEMINFOW, LPIMEMENUITEMINFOW, DWORD);
+
+version(Unicode) {
+    alias ImmEnumRegisterWordW ImmEnumRegisterWord;
+    alias ImmGetRegisterWordStyleW ImmGetRegisterWordStyle;
+    alias ImmUnregisterWordW ImmUnregisterWord;
+    alias ImmRegisterWordW ImmRegisterWord;
+    alias ImmInstallIMEW ImmInstallIME;
+    alias ImmIsUIMessageW ImmIsUIMessage;
+    alias ImmGetConversionListW ImmGetConversionList;
+    alias ImmEscapeW ImmEscape;
+    alias ImmConfigureIMEW ImmConfigureIME;
+    alias ImmSetCompositionFontW ImmSetCompositionFont;
+    alias ImmGetCompositionFontW ImmGetCompositionFont;
+    alias ImmGetGuideLineW ImmGetGuideLine;
+    alias ImmGetCandidateListW ImmGetCandidateList;
+    alias ImmGetCandidateListCountW ImmGetCandidateListCount;
+    alias ImmSetCompositionStringW ImmSetCompositionString;
+    alias ImmGetCompositionStringW ImmGetCompositionString;
+    alias ImmGetDescriptionW ImmGetDescription;
+    alias ImmGetIMEFileNameW ImmGetIMEFileName;
+    alias ImmGetImeMenuItemsW ImmGetImeMenuItems;
+} else {
+    alias ImmEnumRegisterWordA ImmEnumRegisterWord;
+    alias ImmGetRegisterWordStyleA ImmGetRegisterWordStyle;
+    alias ImmUnregisterWordA ImmUnregisterWord;
+    alias ImmRegisterWordA ImmRegisterWord;
+    alias ImmInstallIMEA ImmInstallIME;
+    alias ImmIsUIMessageA ImmIsUIMessage;
+    alias ImmGetConversionListA ImmGetConversionList;
+    alias ImmEscapeA ImmEscape;
+    alias ImmConfigureIMEA ImmConfigureIME;
+    alias ImmSetCompositionFontA ImmSetCompositionFont;
+    alias ImmGetCompositionFontA ImmGetCompositionFont;
+    alias ImmGetGuideLineA ImmGetGuideLine;
+    alias ImmGetCandidateListA ImmGetCandidateList;
+    alias ImmGetCandidateListCountA ImmGetCandidateListCount;
+    alias ImmSetCompositionStringA ImmSetCompositionString;
+    alias ImmGetCompositionStringA ImmGetCompositionString;
+    alias ImmGetDescriptionA ImmGetDescription;
+    alias ImmGetIMEFileNameA ImmGetIMEFileName;
+    alias ImmGetImeMenuItemsW ImmGetImeMenuItems;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/intshcut.d b/libphobos/libdruntime/core/sys/windows/intshcut.d
new file mode 100644
index 00000000000..4070577514f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/intshcut.d
@@ -0,0 +1,91 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_intshcut.d)
+ */
+module core.sys.windows.intshcut;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.unknwn, core.sys.windows.windef;
+
+enum : SCODE {
+    E_FLAGS                     = 0x80041000,
+      // = MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x1000)
+    URL_E_INVALID_SYNTAX        = 0x80041001,
+      // = MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x1001)
+    URL_E_UNREGISTERED_PROTOCOL = 0x80041002, // etc.
+    IS_E_EXEC_FAILED            = 0x80042002
+}
+
+enum IURL_SETURL_FLAGS {
+    IURL_SETURL_FL_GUESS_PROTOCOL = 1,
+    IURL_SETURL_FL_USE_DEFAULT_PROTOCOL,
+    ALL_IURL_SETURL_FLAGS
+}
+
+enum IURL_INVOKECOMMAND_FLAGS {
+    IURL_INVOKECOMMAND_FL_ALLOW_UI = 1,
+    IURL_INVOKECOMMAND_FL_USE_DEFAULT_VERB,
+    ALL_IURL_INVOKECOMMAND_FLAGS
+}
+
+enum TRANSLATEURL_IN_FLAGS {
+    TRANSLATEURL_FL_GUESS_PROTOCOL = 1,
+    TRANSLATEURL_FL_USE_DEFAULT_PROTOCOL,
+    ALL_TRANSLATEURL_FLAGS
+}
+
+enum URLASSOCIATIONDIALOG_IN_FLAGS {
+    URLASSOCDLG_FL_USE_DEFAULT_NAME = 1,
+    URLASSOCDLG_FL_REGISTER_ASSOC,
+    ALL_URLASSOCDLG_FLAGS
+}
+
+enum MIMEASSOCIATIONDIALOG_IN_FLAGS {
+    MIMEASSOCDLG_FL_REGISTER_ASSOC = 1,
+    ALL_MIMEASSOCDLG_FLAGS         = MIMEASSOCDLG_FL_REGISTER_ASSOC
+}
+
+struct URLINVOKECOMMANDINFO {
+    DWORD dwcbSize = URLINVOKECOMMANDINFO.sizeof;
+    DWORD dwFlags;
+    HWND  hwndParent;
+    PCSTR pcszVerb;
+}
+alias URLINVOKECOMMANDINFO CURLINVOKECOMMANDINFO;
+alias URLINVOKECOMMANDINFO* PURLINVOKECOMMANDINFO, PCURLINVOKECOMMANDINFO;
+
+interface IUniformResourceLocator : IUnknown {
+    HRESULT SetURL(PCSTR, DWORD);
+    HRESULT GetURL(PSTR*);
+    HRESULT InvokeCommand(PURLINVOKECOMMANDINFO);
+}
+//alias typeof(*(IUniformResourceLocator.init)) CIUniformResourceLocator; // value-type of interface not representable in D
+alias IUniformResourceLocator PIUniformResourceLocator,
+  PCIUniformResourceLocator;
+
+extern (Windows) {
+    BOOL InetIsOffline(DWORD);
+    HRESULT MIMEAssociationDialogA(HWND, DWORD, PCSTR, PCSTR, PSTR, UINT);
+    HRESULT MIMEAssociationDialogW(HWND, DWORD, PCWSTR, PCWSTR, PWSTR, UINT);
+    HRESULT TranslateURLA(PCSTR, DWORD, PSTR*);
+    HRESULT TranslateURLW(PCWSTR, DWORD, PWSTR*);
+    HRESULT URLAssociationDialogA(HWND, DWORD, PCSTR, PCSTR, PSTR, UINT);
+    HRESULT URLAssociationDialogW(HWND, DWORD, PCWSTR, PCWSTR, PWSTR, UINT);
+}
+
+version (Unicode) {
+    alias TranslateURLW TranslateURL;
+    alias MIMEAssociationDialogW MIMEAssociationDialog;
+    alias URLAssociationDialogW URLAssociationDialog;
+} else {
+    alias TranslateURLA TranslateURL;
+    alias MIMEAssociationDialogA MIMEAssociationDialog;
+    alias URLAssociationDialogA URLAssociationDialog;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/ipexport.d b/libphobos/libdruntime/core/sys/windows/ipexport.d
new file mode 100644
index 00000000000..6f4853567c5
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/ipexport.d
@@ -0,0 +1,108 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_ipexport.d)
+ */
+module core.sys.windows.ipexport;
+version (Windows):
+
+private import core.sys.windows.windef;
+
+enum size_t MAX_ADAPTER_NAME = 128;
+
+// IP STATUS flags
+enum : IP_STATUS {
+    IP_SUCCESS         =     0,
+    IP_STATUS_BASE     = 11000,
+    IP_BUF_TOO_SMALL,
+    IP_DEST_NET_UNREACHABLE,
+    IP_DEST_HOST_UNREACHABLE,
+    IP_DEST_PROT_UNREACHABLE,
+    IP_DEST_PORT_UNREACHABLE,
+    IP_NO_RESOURCES,
+    IP_BAD_OPTION,
+    IP_HW_ERROR,
+    IP_PACKET_TOO_BIG,
+    IP_REQ_TIMED_OUT,
+    IP_BAD_REQ,
+    IP_BAD_ROUTE,
+    IP_TTL_EXPIRED_TRANSIT,
+    IP_TTL_EXPIRED_REASSEM,
+    IP_PARAM_PROBLEM,
+    IP_SOURCE_QUENCH,
+    IP_OPTION_TOO_BIG,
+    IP_BAD_DESTINATION,
+    IP_ADDR_DELETED,
+    IP_SPEC_MTU_CHANGE,
+    IP_MTU_CHANGE,
+    IP_UNLOAD,      // = IP_STATUS_BASE + 22
+    IP_GENERAL_FAILURE = IP_STATUS_BASE + 50,
+    MAX_IP_STATUS      = IP_GENERAL_FAILURE,
+    IP_PENDING         = IP_STATUS_BASE + 255
+}
+
+// IP header Flags values
+enum byte IP_FLAG_DF = 2;
+
+// IP Option types
+enum : ubyte {
+    IP_OPT_EOL          = 0,
+    IP_OPT_NOP          = 0x01,
+    IP_OPT_RR           = 0x07,
+    IP_OPT_SECURITY     = 0x82,
+    IP_OPT_LSRR         = 0x83,
+    IP_OPT_SSRR         = 0x89,
+    IP_OPT_TS           = 0x44,
+    IP_OPT_SID          = 0x88,
+    IP_OPT_ROUTER_ALERT = 0x94
+}
+
+enum ubyte MAX_OPT_SIZE = 40;
+
+alias uint IPAddr, IPMask, IP_STATUS;
+
+struct IP_OPTION_INFORMATION {
+    ubyte  Ttl;
+    ubyte  Tos;
+    ubyte  Flags;
+    ubyte  OptionsSize;
+    ubyte* OptionsData;
+}
+alias IP_OPTION_INFORMATION* PIP_OPTION_INFORMATION;
+
+struct ICMP_ECHO_REPLY {
+  IPAddr Address;
+  uint   Status;
+  uint   RoundTripTime;
+  ushort DataSize;
+  ushort Reserved;
+  void*  Data;
+  IP_OPTION_INFORMATION Options;
+}
+alias ICMP_ECHO_REPLY* PICMP_ECHO_REPLY;
+
+struct IP_ADAPTER_INDEX_MAP {
+    ULONG                   Index;
+    WCHAR[MAX_ADAPTER_NAME] Name;
+}
+alias IP_ADAPTER_INDEX_MAP* PIP_ADAPTER_INDEX_MAP;
+
+struct IP_INTERFACE_INFO {
+    LONG                    NumAdapters;
+    IP_ADAPTER_INDEX_MAP[1] _Adapter;
+
+    IP_ADAPTER_INDEX_MAP* Adapter() return { return _Adapter.ptr; }
+}
+alias IP_INTERFACE_INFO* PIP_INTERFACE_INFO;
+
+struct IP_UNIDIRECTIONAL_ADAPTER_ADDRESS {
+    ULONG     NumAdapters;
+    IPAddr[1] _Address;
+
+    IPAddr* Address() return { return _Address.ptr; }
+}
+alias IP_UNIDIRECTIONAL_ADAPTER_ADDRESS* PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS;
diff --git a/libphobos/libdruntime/core/sys/windows/iphlpapi.d b/libphobos/libdruntime/core/sys/windows/iphlpapi.d
new file mode 100644
index 00000000000..6dabd0bc7d2
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/iphlpapi.d
@@ -0,0 +1,62 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_iphlpapi.d)
+ */
+module core.sys.windows.iphlpapi;
+version (Windows):
+
+import core.sys.windows.ipexport, core.sys.windows.iprtrmib, core.sys.windows.iptypes;
+private import core.sys.windows.winbase, core.sys.windows.windef;
+
+extern (Windows) {
+    DWORD AddIPAddress(IPAddr, IPMask, DWORD, PULONG, PULONG);
+    DWORD CreateIpForwardEntry(PMIB_IPFORWARDROW);
+    DWORD CreateIpNetEntry(PMIB_IPNETROW);
+    DWORD CreateProxyArpEntry(DWORD, DWORD, DWORD);
+    DWORD DeleteIPAddress(ULONG);
+    DWORD DeleteIpForwardEntry(PMIB_IPFORWARDROW);
+    DWORD DeleteIpNetEntry(PMIB_IPNETROW);
+    DWORD DeleteProxyArpEntry(DWORD, DWORD, DWORD);
+    DWORD EnableRouter(HANDLE*, OVERLAPPED*);
+    DWORD FlushIpNetTable(DWORD);
+    DWORD GetAdapterIndex(LPWSTR, PULONG);
+    DWORD GetAdaptersInfo(PIP_ADAPTER_INFO, PULONG);
+    DWORD GetBestInterface(IPAddr, PDWORD);
+    DWORD GetBestRoute(DWORD, DWORD, PMIB_IPFORWARDROW);
+    DWORD GetFriendlyIfIndex(DWORD);
+    DWORD GetIcmpStatistics(PMIB_ICMP);
+    DWORD GetIfEntry(PMIB_IFROW);
+    DWORD GetIfTable(PMIB_IFTABLE, PULONG, BOOL);
+    DWORD GetInterfaceInfo(PIP_INTERFACE_INFO, PULONG);
+    DWORD GetIpAddrTable(PMIB_IPADDRTABLE, PULONG, BOOL);
+    DWORD GetIpForwardTable(PMIB_IPFORWARDTABLE, PULONG, BOOL);
+    DWORD GetIpNetTable(PMIB_IPNETTABLE, PULONG, BOOL);
+    DWORD GetIpStatistics(PMIB_IPSTATS);
+    DWORD GetNetworkParams(PFIXED_INFO, PULONG);
+    DWORD GetNumberOfInterfaces(PDWORD);
+    DWORD GetPerAdapterInfo(ULONG, PIP_PER_ADAPTER_INFO, PULONG);
+    BOOL GetRTTAndHopCount(IPAddr, PULONG, ULONG, PULONG);
+    DWORD GetTcpStatistics(PMIB_TCPSTATS);
+    DWORD GetTcpTable(PMIB_TCPTABLE, PDWORD, BOOL);
+    DWORD GetUniDirectionalAdapterInfo(PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS,
+      PULONG);
+    DWORD GetUdpStatistics(PMIB_UDPSTATS);
+    DWORD GetUdpTable(PMIB_UDPTABLE, PDWORD, BOOL);
+    DWORD IpReleaseAddress(PIP_ADAPTER_INDEX_MAP);
+    DWORD IpRenewAddress(PIP_ADAPTER_INDEX_MAP);
+    DWORD NotifyAddrChange(PHANDLE, LPOVERLAPPED);
+    DWORD NotifyRouteChange(PHANDLE, LPOVERLAPPED);
+    DWORD SendARP(IPAddr, IPAddr, PULONG, PULONG);
+    DWORD SetIfEntry(PMIB_IFROW);
+    DWORD SetIpForwardEntry(PMIB_IPFORWARDROW);
+    DWORD SetIpNetEntry(PMIB_IPNETROW);
+    DWORD SetIpStatistics(PMIB_IPSTATS);
+    DWORD SetIpTTL(UINT);
+    DWORD SetTcpEntry(PMIB_TCPROW);
+    DWORD UnenableRouter(OVERLAPPED*, LPDWORD);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/ipifcons.d b/libphobos/libdruntime/core/sys/windows/ipifcons.d
new file mode 100644
index 00000000000..b1de472f0ba
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/ipifcons.d
@@ -0,0 +1,38 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_ipifcons.d)
+ */
+module core.sys.windows.ipifcons;
+version (Windows):
+
+// FIXME: check types of constants
+
+enum {
+    MIB_IF_ADMIN_STATUS_UP = 1,
+    MIB_IF_ADMIN_STATUS_DOWN,
+    MIB_IF_ADMIN_STATUS_TESTING,
+}
+
+enum {
+    MIB_IF_OPER_STATUS_NON_OPERATIONAL,
+    MIB_IF_OPER_STATUS_UNREACHABLE,
+    MIB_IF_OPER_STATUS_DISCONNECTED,
+    MIB_IF_OPER_STATUS_CONNECTING,
+    MIB_IF_OPER_STATUS_CONNECTED,
+    MIB_IF_OPER_STATUS_OPERATIONAL // = 5
+}
+
+enum {
+    MIB_IF_TYPE_OTHER     =  1,
+    MIB_IF_TYPE_ETHERNET  =  6,
+    MIB_IF_TYPE_TOKENRING =  9,
+    MIB_IF_TYPE_FDDI      = 15,
+    MIB_IF_TYPE_PPP       = 23,
+    MIB_IF_TYPE_LOOPBACK  = 24,
+    MIB_IF_TYPE_SLIP      = 28
+}
diff --git a/libphobos/libdruntime/core/sys/windows/iprtrmib.d b/libphobos/libdruntime/core/sys/windows/iprtrmib.d
new file mode 100644
index 00000000000..d4f622dba83
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/iprtrmib.d
@@ -0,0 +1,267 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_iprtrmib.d)
+ */
+module core.sys.windows.iprtrmib;
+version (Windows):
+
+import core.sys.windows.ipifcons;
+private import core.sys.windows.windef;
+
+// FIXME: check types of constants
+
+enum size_t
+    MAXLEN_PHYSADDR        =   8,
+    MAXLEN_IFDESCR         = 256,
+    MAX_INTERFACE_NAME_LEN = 256;
+
+enum {
+    MIB_IPNET_TYPE_OTHER = 1,
+    MIB_IPNET_TYPE_INVALID,
+    MIB_IPNET_TYPE_DYNAMIC,
+    MIB_IPNET_TYPE_STATIC
+}
+
+enum {
+    MIB_TCP_RTO_OTHER = 1,
+    MIB_TCP_RTO_CONSTANT,
+    MIB_TCP_RTO_RSRE,
+    MIB_TCP_RTO_VANJ
+}
+
+enum {
+    MIB_TCP_STATE_CLOSED = 1,
+    MIB_TCP_STATE_LISTEN,
+    MIB_TCP_STATE_SYN_SENT,
+    MIB_TCP_STATE_SYN_RCVD,
+    MIB_TCP_STATE_ESTAB,
+    MIB_TCP_STATE_FIN_WAIT1,
+    MIB_TCP_STATE_FIN_WAIT2,
+    MIB_TCP_STATE_CLOSE_WAIT,
+    MIB_TCP_STATE_CLOSING,
+    MIB_TCP_STATE_LAST_ACK,
+    MIB_TCP_STATE_TIME_WAIT,
+    MIB_TCP_STATE_DELETE_TCB // = 12
+}
+
+enum DWORD
+    MIB_USE_CURRENT_TTL        = -1,
+    MIB_USE_CURRENT_FORWARDING = -1,
+    MIB_TCP_MAXCONN_DYNAMIC    = -1;
+
+struct MIB_IPADDRROW {
+    DWORD  dwAddr;
+    DWORD  dwIndex;
+    DWORD  dwMask;
+    DWORD  dwBCastAddr;
+    DWORD  dwReasmSize;
+    ushort unused1;
+    ushort unused2;
+}
+alias MIB_IPADDRROW* PMIB_IPADDRROW;
+
+struct MIB_IPADDRTABLE {
+    DWORD            dwNumEntries;
+    MIB_IPADDRROW[1] _table;
+
+    MIB_IPADDRROW* table() return { return _table.ptr; }
+}
+alias MIB_IPADDRTABLE* PMIB_IPADDRTABLE;
+
+struct MIB_IPFORWARDROW {
+    DWORD dwForwardDest;
+    DWORD dwForwardMask;
+    DWORD dwForwardPolicy;
+    DWORD dwForwardNextHop;
+    DWORD dwForwardIfIndex;
+    DWORD dwForwardType;
+    DWORD dwForwardProto;
+    DWORD dwForwardAge;
+    DWORD dwForwardNextHopAS;
+    DWORD dwForwardMetric1;
+    DWORD dwForwardMetric2;
+    DWORD dwForwardMetric3;
+    DWORD dwForwardMetric4;
+    DWORD dwForwardMetric5;
+}
+alias MIB_IPFORWARDROW* PMIB_IPFORWARDROW;
+
+struct MIB_IPFORWARDTABLE {
+    DWORD               dwNumEntries;
+    MIB_IPFORWARDROW[1] _table;
+
+    MIB_IPFORWARDROW* table() return { return _table.ptr; }
+}
+alias MIB_IPFORWARDTABLE* PMIB_IPFORWARDTABLE;
+
+struct MIB_IPNETROW {
+    DWORD dwIndex;
+    DWORD dwPhysAddrLen;
+    BYTE[MAXLEN_PHYSADDR] bPhysAddr;
+    DWORD dwAddr;
+    DWORD dwType;
+}
+alias MIB_IPNETROW* PMIB_IPNETROW;
+
+struct MIB_IPNETTABLE {
+    DWORD           dwNumEntries;
+    MIB_IPNETROW[1] _table;
+
+    MIB_IPNETROW* table() return { return _table.ptr; }
+}
+alias MIB_IPNETTABLE* PMIB_IPNETTABLE;
+
+struct MIBICMPSTATS {
+    DWORD dwMsgs;
+    DWORD dwErrors;
+    DWORD dwDestUnreachs;
+    DWORD dwTimeExcds;
+    DWORD dwParmProbs;
+    DWORD dwSrcQuenchs;
+    DWORD dwRedirects;
+    DWORD dwEchos;
+    DWORD dwEchoReps;
+    DWORD dwTimestamps;
+    DWORD dwTimestampReps;
+    DWORD dwAddrMasks;
+    DWORD dwAddrMaskReps;
+}
+alias MIBICMPSTATS* PMIBICMPSTATS;
+
+struct MIBICMPINFO {
+    MIBICMPSTATS icmpInStats;
+    MIBICMPSTATS icmpOutStats;
+}
+alias MIBICMPINFO* PMIBICMPINFO;
+
+struct MIB_ICMP {
+    MIBICMPINFO stats;
+}
+alias MIB_ICMP* PMIB_ICMP;
+
+struct MIB_IFROW {
+    WCHAR[MAX_INTERFACE_NAME_LEN] wszName;
+    DWORD dwIndex;
+    DWORD dwType;
+    DWORD dwMtu;
+    DWORD dwSpeed;
+    DWORD dwPhysAddrLen;
+    BYTE[MAXLEN_PHYSADDR] bPhysAddr;
+    DWORD dwAdminStatus;
+    DWORD dwOperStatus;
+    DWORD dwLastChange;
+    DWORD dwInOctets;
+    DWORD dwInUcastPkts;
+    DWORD dwInNUcastPkts;
+    DWORD dwInDiscards;
+    DWORD dwInErrors;
+    DWORD dwInUnknownProtos;
+    DWORD dwOutOctets;
+    DWORD dwOutUcastPkts;
+    DWORD dwOutNUcastPkts;
+    DWORD dwOutDiscards;
+    DWORD dwOutErrors;
+    DWORD dwOutQLen;
+    DWORD dwDescrLen;
+    BYTE[MAXLEN_IFDESCR] bDescr;
+}
+alias MIB_IFROW* PMIB_IFROW;
+
+struct MIB_IFTABLE {
+    DWORD        dwNumEntries;
+    MIB_IFROW[1] _table;
+
+    MIB_IFROW* table() return { return _table.ptr; }
+}
+alias MIB_IFTABLE* PMIB_IFTABLE;
+
+struct MIB_IPSTATS {
+    DWORD dwForwarding;
+    DWORD dwDefaultTTL;
+    DWORD dwInReceives;
+    DWORD dwInHdrErrors;
+    DWORD dwInAddrErrors;
+    DWORD dwForwDatagrams;
+    DWORD dwInUnknownProtos;
+    DWORD dwInDiscards;
+    DWORD dwInDelivers;
+    DWORD dwOutRequests;
+    DWORD dwRoutingDiscards;
+    DWORD dwOutDiscards;
+    DWORD dwOutNoRoutes;
+    DWORD dwReasmTimeout;
+    DWORD dwReasmReqds;
+    DWORD dwReasmOks;
+    DWORD dwReasmFails;
+    DWORD dwFragOks;
+    DWORD dwFragFails;
+    DWORD dwFragCreates;
+    DWORD dwNumIf;
+    DWORD dwNumAddr;
+    DWORD dwNumRoutes;
+}
+alias MIB_IPSTATS* PMIB_IPSTATS;
+
+struct MIB_TCPSTATS {
+    DWORD dwRtoAlgorithm;
+    DWORD dwRtoMin;
+    DWORD dwRtoMax;
+    DWORD dwMaxConn;
+    DWORD dwActiveOpens;
+    DWORD dwPassiveOpens;
+    DWORD dwAttemptFails;
+    DWORD dwEstabResets;
+    DWORD dwCurrEstab;
+    DWORD dwInSegs;
+    DWORD dwOutSegs;
+    DWORD dwRetransSegs;
+    DWORD dwInErrs;
+    DWORD dwOutRsts;
+    DWORD dwNumConns;
+}
+alias MIB_TCPSTATS* PMIB_TCPSTATS;
+
+struct MIB_TCPROW {
+    DWORD dwState;
+    DWORD dwLocalAddr;
+    DWORD dwLocalPort;
+    DWORD dwRemoteAddr;
+    DWORD dwRemotePort;
+}
+alias MIB_TCPROW* PMIB_TCPROW;
+
+struct MIB_TCPTABLE {
+    DWORD         dwNumEntries;
+    MIB_TCPROW[1] _table;
+
+    MIB_TCPROW* table() return { return _table.ptr; }
+}
+alias MIB_TCPTABLE* PMIB_TCPTABLE;
+
+struct MIB_UDPSTATS {
+    DWORD dwInDatagrams;
+    DWORD dwNoPorts;
+    DWORD dwInErrors;
+    DWORD dwOutDatagrams;
+    DWORD dwNumAddrs;
+}
+alias MIB_UDPSTATS* PMIB_UDPSTATS;
+
+struct MIB_UDPROW {
+    DWORD dwLocalAddr;
+    DWORD dwLocalPort;
+}
+alias MIB_UDPROW* PMIB_UDPROW;
+
+struct MIB_UDPTABLE {
+    DWORD         dwNumEntries;
+    MIB_UDPROW[1] _table;
+
+    MIB_UDPROW* table() return { return _table.ptr; }
+}
+alias MIB_UDPTABLE* PMIB_UDPTABLE;
diff --git a/libphobos/libdruntime/core/sys/windows/iptypes.d b/libphobos/libdruntime/core/sys/windows/iptypes.d
new file mode 100644
index 00000000000..875756f233e
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/iptypes.d
@@ -0,0 +1,103 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_iptypes.d)
+ */
+module core.sys.windows.iptypes;
+version (Windows):
+
+import core.sys.windows.windef;
+version(Tango){
+    private import tango.stdc.time;
+}else{
+    version (D_Version2)
+        import core.stdc.time;
+    else
+        import std.c.time;
+}
+//#include <sys/types.h>
+
+enum size_t
+    DEFAULT_MINIMUM_ENTITIES       =  32,
+    MAX_ADAPTER_ADDRESS_LENGTH     =   8,
+    MAX_ADAPTER_DESCRIPTION_LENGTH = 128,
+    MAX_ADAPTER_NAME_LENGTH        = 256,
+    MAX_DOMAIN_NAME_LEN            = 128,
+    MAX_HOSTNAME_LEN               = 128,
+    MAX_SCOPE_ID_LEN               = 256;
+
+enum UINT
+    BROADCAST_NODETYPE    = 1,
+    PEER_TO_PEER_NODETYPE = 2,
+    MIXED_NODETYPE        = 4,
+    HYBRID_NODETYPE       = 8;
+
+enum : UINT {
+    IF_OTHER_ADAPTERTYPE,
+    IF_ETHERNET_ADAPTERTYPE,
+    IF_TOKEN_RING_ADAPTERTYPE,
+    IF_FDDI_ADAPTERTYPE,
+    IF_PPP_ADAPTERTYPE,
+    IF_LOOPBACK_ADAPTERTYPE // = 5
+}
+
+struct IP_ADDRESS_STRING {
+    char[16] String;
+}
+alias IP_ADDRESS_STRING IP_MASK_STRING;
+alias IP_ADDRESS_STRING* PIP_ADDRESS_STRING, PIP_MASK_STRING;
+
+struct IP_ADDR_STRING {
+    IP_ADDR_STRING*   Next;
+    IP_ADDRESS_STRING IpAddress;
+    IP_MASK_STRING    IpMask;
+    DWORD             Context;
+}
+alias IP_ADDR_STRING* PIP_ADDR_STRING;
+
+struct IP_ADAPTER_INFO {
+    IP_ADAPTER_INFO* Next;
+    DWORD ComboIndex;
+    char[MAX_ADAPTER_NAME_LENGTH+4]        AdapterName;
+    char[MAX_ADAPTER_DESCRIPTION_LENGTH+4] Description;
+    UINT             AddressLength;
+    BYTE[MAX_ADAPTER_ADDRESS_LENGTH]       Address;
+    DWORD            Index;
+    UINT             Type;
+    UINT             DhcpEnabled;
+    PIP_ADDR_STRING  CurrentIpAddress;
+    IP_ADDR_STRING   IpAddressList;
+    IP_ADDR_STRING   GatewayList;
+    IP_ADDR_STRING   DhcpServer;
+    BOOL             HaveWins;
+    IP_ADDR_STRING   PrimaryWinsServer;
+    IP_ADDR_STRING   SecondaryWinsServer;
+    time_t           LeaseObtained;
+    time_t           LeaseExpires;
+}
+alias IP_ADAPTER_INFO* PIP_ADAPTER_INFO;
+
+struct IP_PER_ADAPTER_INFO {
+    UINT AutoconfigEnabled;
+    UINT AutoconfigActive;
+    PIP_ADDR_STRING CurrentDnsServer;
+    IP_ADDR_STRING DnsServerList;
+}
+alias IP_PER_ADAPTER_INFO* PIP_PER_ADAPTER_INFO;
+
+struct FIXED_INFO {
+    char[MAX_HOSTNAME_LEN+4]    HostName;
+    char[MAX_DOMAIN_NAME_LEN+4] DomainName;
+    PIP_ADDR_STRING             CurrentDnsServer;
+    IP_ADDR_STRING              DnsServerList;
+    UINT                        NodeType;
+    char[MAX_SCOPE_ID_LEN+4]    ScopeId;
+    UINT                        EnableRouting;
+    UINT                        EnableProxy;
+    UINT                        EnableDns;
+}
+alias FIXED_INFO* PFIXED_INFO;
diff --git a/libphobos/libdruntime/core/sys/windows/isguids.d b/libphobos/libdruntime/core/sys/windows/isguids.d
new file mode 100644
index 00000000000..b78d3521290
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/isguids.d
@@ -0,0 +1,17 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.10
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_isguids.d)
+ */
+module core.sys.windows.isguids;
+version (Windows):
+
+private import core.sys.windows.basetyps;
+
+extern (C) extern const GUID
+    CLSID_InternetShortcut,
+    IID_IUniformResourceLocator;
diff --git a/libphobos/libdruntime/core/sys/windows/lm.d b/libphobos/libdruntime/core/sys/windows/lm.d
new file mode 100644
index 00000000000..48a6f55c850
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lm.d
@@ -0,0 +1,47 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lm.d)
+ */
+module core.sys.windows.lm;
+version (Windows):
+/* removed - now supporting only Win2k up
+version (WindowsVista) {
+    version = WIN32_WINNT_ONLY;
+} else version (Windows2003) {
+    version = WIN32_WINNT_ONLY;
+} else version (WindowsXP) {
+    version = WIN32_WINNT_ONLY;
+} else version (WindowsNTonly) {
+    version = WIN32_WINNT_ONLY;
+}
+*/
+public import core.sys.windows.lmcons;
+public import core.sys.windows.lmaccess;
+public import core.sys.windows.lmalert;
+public import core.sys.windows.lmat;
+public import core.sys.windows.lmerr;
+public import core.sys.windows.lmshare;
+public import core.sys.windows.lmapibuf;
+public import core.sys.windows.lmremutl;
+public import core.sys.windows.lmrepl;
+public import core.sys.windows.lmuse;
+public import core.sys.windows.lmstats;
+public import core.sys.windows.lmwksta;
+public import core.sys.windows.lmserver;
+
+version (Windows2000) {
+} else {
+    public import core.sys.windows.lmmsg;
+}
+
+// FIXME: Everything in these next files seems to be deprecated!
+import core.sys.windows.lmaudit;
+import core.sys.windows.lmchdev; // can't find many docs for functions from this file.
+import core.sys.windows.lmconfig;
+import core.sys.windows.lmerrlog;
+import core.sys.windows.lmsvc;
+import core.sys.windows.lmsname; // in MinGW, this was publicly included by lm.lmsvc
diff --git a/libphobos/libdruntime/core/sys/windows/lmaccess.d b/libphobos/libdruntime/core/sys/windows/lmaccess.d
new file mode 100644
index 00000000000..5846fa193ba
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmaccess.d
@@ -0,0 +1,759 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmaccess.d)
+ */
+module core.sys.windows.lmaccess;
+version (Windows):
+pragma(lib, "netapi32");
+
+/**
+ Changes relative to MinGW:
+    USER_POSIX_ID_PARMNUM and GROUP_POSIX_ID_PARMNUM aren't in MinGW or in
+    the Platform SDK docs, so they have been dropped from this file.
+*/
+
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+const wchar[]
+    GROUP_SPECIALGRP_USERS  = "USERS",
+    GROUP_SPECIALGRP_ADMINS = "ADMINS",
+    GROUP_SPECIALGRP_GUESTS = "GUESTS",
+    GROUP_SPECIALGRP_LOCAL  = "LOCAL";
+
+enum ACCESS_LETTERS = "RWCXDAP ";
+
+enum NETLOGON_CONTROL_QUERY=1;
+enum NETLOGON_CONTROL_REPLICATE=2;
+enum NETLOGON_CONTROL_SYNCHRONIZE=3;
+enum NETLOGON_CONTROL_PDC_REPLICATE=4;
+enum NETLOGON_CONTROL_REDISCOVER=5;
+enum NETLOGON_CONTROL_TC_QUERY=6;
+enum NETLOGON_CONTROL_BACKUP_CHANGE_LOG=65532;
+enum NETLOGON_CONTROL_TRUNCATE_LOG=65533;
+enum NETLOGON_CONTROL_SET_DBFLAG=65534;
+enum NETLOGON_CONTROL_BREAKPOINT=65535;
+
+enum UF_SCRIPT=1;
+enum UF_ACCOUNTDISABLE=2;
+enum UF_HOMEDIR_REQUIRED=8;
+enum UF_LOCKOUT=16;
+enum UF_PASSWD_NOTREQD=32;
+enum UF_PASSWD_CANT_CHANGE=64;
+enum UF_TEMP_DUPLICATE_ACCOUNT=256;
+enum UF_NORMAL_ACCOUNT=512;
+enum UF_INTERDOMAIN_TRUST_ACCOUNT=2048;
+enum UF_WORKSTATION_TRUST_ACCOUNT=4096;
+enum UF_SERVER_TRUST_ACCOUNT=8192;
+enum UF_MNS_LOGON_ACCOUNT=131072;
+enum UF_MACHINE_ACCOUNT_MASK=UF_INTERDOMAIN_TRUST_ACCOUNT|UF_WORKSTATION_TRUST_ACCOUNT|UF_SERVER_TRUST_ACCOUNT;
+enum UF_ACCOUNT_TYPE_MASK=UF_TEMP_DUPLICATE_ACCOUNT|UF_NORMAL_ACCOUNT|UF_INTERDOMAIN_TRUST_ACCOUNT|UF_WORKSTATION_TRUST_ACCOUNT|UF_SERVER_TRUST_ACCOUNT;
+enum UF_DONT_EXPIRE_PASSWD=65536;
+enum UF_SETTABLE_BITS=UF_SCRIPT|UF_ACCOUNTDISABLE|UF_LOCKOUT|UF_HOMEDIR_REQUIRED|UF_PASSWD_NOTREQD|UF_PASSWD_CANT_CHANGE|UF_ACCOUNT_TYPE_MASK|UF_DONT_EXPIRE_PASSWD;
+
+enum FILTER_TEMP_DUPLICATE_ACCOUNT=1;
+enum FILTER_NORMAL_ACCOUNT=2;
+enum FILTER_INTERDOMAIN_TRUST_ACCOUNT=8;
+enum FILTER_WORKSTATION_TRUST_ACCOUNT=16;
+enum FILTER_SERVER_TRUST_ACCOUNT=32;
+
+enum LG_INCLUDE_INDIRECT=1;
+
+enum AF_OP_PRINT=1;
+enum AF_OP_COMM=2;
+enum AF_OP_SERVER=4;
+enum AF_OP_ACCOUNTS=8;
+enum AF_SETTABLE_BITS=(AF_OP_PRINT|AF_OP_COMM|AF_OP_SERVER|AF_OP_ACCOUNTS);
+
+enum UAS_ROLE_STANDALONE=0;
+enum UAS_ROLE_MEMBER=1;
+enum UAS_ROLE_BACKUP=2;
+enum UAS_ROLE_PRIMARY=3;
+
+enum USER_NAME_PARMNUM=1;
+enum USER_PASSWORD_PARMNUM=3;
+enum USER_PASSWORD_AGE_PARMNUM=4;
+enum USER_PRIV_PARMNUM=5;
+enum USER_HOME_DIR_PARMNUM=6;
+enum USER_COMMENT_PARMNUM=7;
+enum USER_FLAGS_PARMNUM=8;
+enum USER_SCRIPT_PATH_PARMNUM=9;
+enum USER_AUTH_FLAGS_PARMNUM=10;
+enum USER_FULL_NAME_PARMNUM=11;
+enum USER_USR_COMMENT_PARMNUM=12;
+enum USER_PARMS_PARMNUM=13;
+enum USER_WORKSTATIONS_PARMNUM=14;
+enum USER_LAST_LOGON_PARMNUM=15;
+enum USER_LAST_LOGOFF_PARMNUM=16;
+enum USER_ACCT_EXPIRES_PARMNUM=17;
+enum USER_MAX_STORAGE_PARMNUM=18;
+enum USER_UNITS_PER_WEEK_PARMNUM=19;
+enum USER_LOGON_HOURS_PARMNUM=20;
+enum USER_PAD_PW_COUNT_PARMNUM=21;
+enum USER_NUM_LOGONS_PARMNUM=22;
+enum USER_LOGON_SERVER_PARMNUM=23;
+enum USER_COUNTRY_CODE_PARMNUM=24;
+enum USER_CODE_PAGE_PARMNUM=25;
+enum USER_PRIMARY_GROUP_PARMNUM=51;
+enum USER_PROFILE=52;
+enum USER_PROFILE_PARMNUM=52;
+enum USER_HOME_DIR_DRIVE_PARMNUM=53;
+
+enum USER_NAME_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_NAME_PARMNUM;
+enum USER_PASSWORD_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_PASSWORD_PARMNUM;
+enum USER_PASSWORD_AGE_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_PASSWORD_AGE_PARMNUM;
+enum USER_PRIV_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_PRIV_PARMNUM;
+enum USER_HOME_DIR_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_HOME_DIR_PARMNUM;
+enum USER_COMMENT_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_COMMENT_PARMNUM;
+enum USER_FLAGS_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_FLAGS_PARMNUM;
+enum USER_SCRIPT_PATH_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_SCRIPT_PATH_PARMNUM;
+enum USER_AUTH_FLAGS_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_AUTH_FLAGS_PARMNUM;
+enum USER_FULL_NAME_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_FULL_NAME_PARMNUM;
+enum USER_USR_COMMENT_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_USR_COMMENT_PARMNUM;
+enum USER_PARMS_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_PARMS_PARMNUM;
+enum USER_WORKSTATIONS_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_WORKSTATIONS_PARMNUM;
+enum USER_LAST_LOGON_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_LAST_LOGON_PARMNUM;
+enum USER_LAST_LOGOFF_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_LAST_LOGOFF_PARMNUM;
+enum USER_ACCT_EXPIRES_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_ACCT_EXPIRES_PARMNUM;
+enum USER_MAX_STORAGE_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_MAX_STORAGE_PARMNUM;
+enum USER_UNITS_PER_WEEK_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_UNITS_PER_WEEK_PARMNUM;
+enum USER_LOGON_HOURS_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_LOGON_HOURS_PARMNUM;
+enum USER_PAD_PW_COUNT_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_PAD_PW_COUNT_PARMNUM;
+enum USER_NUM_LOGONS_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_NUM_LOGONS_PARMNUM;
+enum USER_LOGON_SERVER_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_LOGON_SERVER_PARMNUM;
+enum USER_COUNTRY_CODE_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_COUNTRY_CODE_PARMNUM;
+enum USER_CODE_PAGE_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_CODE_PAGE_PARMNUM;
+enum USER_PRIMARY_GROUP_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_PRIMARY_GROUP_PARMNUM;
+// USER_POSIX_ID_PARMNUM isn't in MinGW or in the Platform SDK docs.
+//const USER_POSIX_ID_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_POSIX_ID_PARMNUM;
+enum USER_HOME_DIR_DRIVE_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+USER_HOME_DIR_DRIVE_PARMNUM;
+
+enum NULL_USERSETINFO_PASSWD=" ";
+enum ULONG TIMEQ_FOREVER=-1;
+enum ULONG USER_MAXSTORAGE_UNLIMITED=-1;
+enum ULONG USER_NO_LOGOFF=-1;
+enum UNITS_PER_DAY=24;
+enum UNITS_PER_WEEK=168;
+enum USER_PRIV_MASK=3;
+enum USER_PRIV_GUEST=0;
+enum USER_PRIV_USER=1;
+enum USER_PRIV_ADMIN=2;
+enum MAX_PASSWD_LEN=PWLEN;
+enum DEF_MIN_PWLEN=6;
+enum DEF_PWUNIQUENESS=5;
+enum DEF_MAX_PWHIST=8;
+enum DEF_MAX_PWAGE=TIMEQ_FOREVER;
+enum DEF_MIN_PWAGE=0;
+enum ULONG DEF_FORCE_LOGOFF=0xffffffff;
+enum DEF_MAX_BADPW=0;
+enum ONE_DAY=86400;
+enum VALIDATED_LOGON=0;
+enum PASSWORD_EXPIRED=2;
+enum NON_VALIDATED_LOGON=3;
+enum VALID_LOGOFF=1;
+
+enum MODALS_MIN_PASSWD_LEN_PARMNUM=1;
+enum MODALS_MAX_PASSWD_AGE_PARMNUM=2;
+enum MODALS_MIN_PASSWD_AGE_PARMNUM=3;
+enum MODALS_FORCE_LOGOFF_PARMNUM=4;
+enum MODALS_PASSWD_HIST_LEN_PARMNUM=5;
+enum MODALS_ROLE_PARMNUM=6;
+enum MODALS_PRIMARY_PARMNUM=7;
+enum MODALS_DOMAIN_NAME_PARMNUM=8;
+enum MODALS_DOMAIN_ID_PARMNUM=9;
+enum MODALS_LOCKOUT_DURATION_PARMNUM=10;
+enum MODALS_LOCKOUT_OBSERVATION_WINDOW_PARMNUM=11;
+enum MODALS_LOCKOUT_THRESHOLD_PARMNUM=12;
+
+enum MODALS_MIN_PASSWD_LEN_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+MODALS_MIN_PASSWD_LEN_PARMNUM);
+enum MODALS_MAX_PASSWD_AGE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+MODALS_MAX_PASSWD_AGE_PARMNUM);
+enum MODALS_MIN_PASSWD_AGE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+MODALS_MIN_PASSWD_AGE_PARMNUM);
+enum MODALS_FORCE_LOGOFF_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+MODALS_FORCE_LOGOFF_PARMNUM);
+enum MODALS_PASSWD_HIST_LEN_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+MODALS_PASSWD_HIST_LEN_PARMNUM);
+enum MODALS_ROLE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+MODALS_ROLE_PARMNUM);
+enum MODALS_PRIMARY_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+MODALS_PRIMARY_PARMNUM);
+enum MODALS_DOMAIN_NAME_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+MODALS_DOMAIN_NAME_PARMNUM);
+enum MODALS_DOMAIN_ID_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+MODALS_DOMAIN_ID_PARMNUM);
+
+enum GROUPIDMASK=0x8000;
+enum GROUP_ALL_PARMNUM=0;
+enum GROUP_NAME_PARMNUM=1;
+enum GROUP_COMMENT_PARMNUM=2;
+enum GROUP_ATTRIBUTES_PARMNUM=3;
+
+enum GROUP_ALL_INFOLEVEL = PARMNUM_BASE_INFOLEVEL + GROUP_ALL_PARMNUM;
+enum GROUP_NAME_INFOLEVEL = PARMNUM_BASE_INFOLEVEL + GROUP_NAME_PARMNUM;
+enum GROUP_COMMENT_INFOLEVEL = PARMNUM_BASE_INFOLEVEL + GROUP_COMMENT_PARMNUM;
+enum GROUP_ATTRIBUTES_INFOLEVEL = PARMNUM_BASE_INFOLEVEL + GROUP_ATTRIBUTES_PARMNUM;
+// GROUP_POSIX_ID_PARMNUM isn't in MinGW or in the Platform SDK docs.
+//const GROUP_POSIX_ID_INFOLEVEL = PARMNUM_BASE_INFOLEVEL + GROUP_POSIX_ID_PARMNUM;
+
+enum LOCALGROUP_NAME_PARMNUM=1;
+enum LOCALGROUP_COMMENT_PARMNUM=2;
+enum MAXPERMENTRIES=64;
+enum ACCESS_NONE=0;
+enum ACCESS_READ=1;
+enum ACCESS_WRITE=2;
+enum ACCESS_CREATE=4;
+enum ACCESS_EXEC=8;
+enum ACCESS_DELETE=16;
+enum ACCESS_ATRIB=32;
+enum ACCESS_PERM=64;
+enum ACCESS_ALL = ACCESS_READ|ACCESS_WRITE|ACCESS_CREATE|ACCESS_EXEC|ACCESS_DELETE|ACCESS_ATRIB|ACCESS_PERM;
+enum ACCESS_GROUP=0x8000;
+enum ACCESS_AUDIT=1;
+enum ACCESS_SUCCESS_OPEN=16;
+enum ACCESS_SUCCESS_WRITE=32;
+enum ACCESS_SUCCESS_DELETE=64;
+enum ACCESS_SUCCESS_ACL=128;
+enum ACCESS_SUCCESS_MASK=240;
+enum ACCESS_FAIL_OPEN=256;
+enum ACCESS_FAIL_WRITE=512;
+enum ACCESS_FAIL_DELETE=1024;
+enum ACCESS_FAIL_ACL=2048;
+enum ACCESS_FAIL_MASK=3840;
+enum ACCESS_FAIL_SHIFT=4;
+enum ACCESS_RESOURCE_NAME_PARMNUM=1;
+enum ACCESS_ATTR_PARMNUM=2;
+enum ACCESS_COUNT_PARMNUM=3;
+enum ACCESS_ACCESS_LIST_PARMNUM=4;
+
+enum ACCESS_RESOURCE_NAME_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+ACCESS_RESOURCE_NAME_PARMNUM);
+enum ACCESS_ATTR_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+ACCESS_ATTR_PARMNUM);
+enum ACCESS_COUNT_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+ACCESS_COUNT_PARMNUM);
+enum ACCESS_ACCESS_LIST_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+ACCESS_ACCESS_LIST_PARMNUM);
+
+enum NETLOGON_REPLICATION_NEEDED=1;
+enum NETLOGON_REPLICATION_IN_PROGRESS=2;
+enum NETLOGON_FULL_SYNC_REPLICATION=4;
+enum NETLOGON_REDO_NEEDED=8;
+
+struct USER_INFO_0 {
+    LPWSTR usri0_name;
+}
+alias USER_INFO_0* PUSER_INFO_0, LPUSER_INFO_0;
+
+struct USER_INFO_1{
+    LPWSTR usri1_name;
+    LPWSTR usri1_password;
+    DWORD usri1_password_age;
+    DWORD usri1_priv;
+    LPWSTR usri1_home_dir;
+    LPWSTR usri1_comment;
+    DWORD usri1_flags;
+    LPWSTR usri1_script_path;
+}
+alias USER_INFO_1* PUSER_INFO_1, LPUSER_INFO_1;
+
+struct USER_INFO_2{
+    LPWSTR usri2_name;
+    LPWSTR usri2_password;
+    DWORD usri2_password_age;
+    DWORD usri2_priv;
+    LPWSTR usri2_home_dir;
+    LPWSTR usri2_comment;
+    DWORD usri2_flags;
+    LPWSTR usri2_script_path;
+    DWORD usri2_auth_flags;
+    LPWSTR usri2_full_name;
+    LPWSTR usri2_usr_comment;
+    LPWSTR usri2_parms;
+    LPWSTR usri2_workstations;
+    DWORD usri2_last_logon;
+    DWORD usri2_last_logoff;
+    DWORD usri2_acct_expires;
+    DWORD usri2_max_storage;
+    DWORD usri2_units_per_week;
+    PBYTE usri2_logon_hours;
+    DWORD usri2_bad_pw_count;
+    DWORD usri2_num_logons;
+    LPWSTR usri2_logon_server;
+    DWORD usri2_country_code;
+    DWORD usri2_code_page;
+}
+alias USER_INFO_2* PUSER_INFO_2, LPUSER_INFO_2;
+
+struct USER_INFO_3{
+    LPWSTR usri3_name;
+    LPWSTR usri3_password;
+    DWORD usri3_password_age;
+    DWORD usri3_priv;
+    LPWSTR usri3_home_dir;
+    LPWSTR usri3_comment;
+    DWORD usri3_flags;
+    LPWSTR usri3_script_path;
+    DWORD usri3_auth_flags;
+    LPWSTR usri3_full_name;
+    LPWSTR usri3_usr_comment;
+    LPWSTR usri3_parms;
+    LPWSTR usri3_workstations;
+    DWORD usri3_last_logon;
+    DWORD usri3_last_logoff;
+    DWORD usri3_acct_expires;
+    DWORD usri3_max_storage;
+    DWORD usri3_units_per_week;
+    PBYTE usri3_logon_hours;
+    DWORD usri3_bad_pw_count;
+    DWORD usri3_num_logons;
+    LPWSTR usri3_logon_server;
+    DWORD usri3_country_code;
+    DWORD usri3_code_page;
+    DWORD usri3_user_id;
+    DWORD usri3_primary_group_id;
+    LPWSTR usri3_profile;
+    LPWSTR usri3_home_dir_drive;
+    DWORD usri3_password_expired;
+}
+alias USER_INFO_3* PUSER_INFO_3, LPUSER_INFO_3;
+
+struct USER_INFO_10{
+    LPWSTR usri10_name;
+    LPWSTR usri10_comment;
+    LPWSTR usri10_usr_comment;
+    LPWSTR usri10_full_name;
+}
+alias USER_INFO_10* PUSER_INFO_10, LPUSER_INFO_10;
+
+struct USER_INFO_11{
+    LPWSTR usri11_name;
+    LPWSTR usri11_comment;
+    LPWSTR usri11_usr_comment;
+    LPWSTR usri11_full_name;
+    DWORD usri11_priv;
+    DWORD usri11_auth_flags;
+    DWORD usri11_password_age;
+    LPWSTR usri11_home_dir;
+    LPWSTR usri11_parms;
+    DWORD usri11_last_logon;
+    DWORD usri11_last_logoff;
+    DWORD usri11_bad_pw_count;
+    DWORD usri11_num_logons;
+    LPWSTR usri11_logon_server;
+    DWORD usri11_country_code;
+    LPWSTR usri11_workstations;
+    DWORD usri11_max_storage;
+    DWORD usri11_units_per_week;
+    PBYTE usri11_logon_hours;
+    DWORD usri11_code_page;
+}
+alias USER_INFO_11* PUSER_INFO_11, LPUSER_INFO_11;
+
+struct USER_INFO_20 {
+    LPWSTR usri20_name;
+    LPWSTR usri20_full_name;
+    LPWSTR usri20_comment;
+    DWORD usri20_flags;
+    DWORD usri20_user_id;
+}
+alias USER_INFO_20* PUSER_INFO_20, LPUSER_INFO_20;
+
+struct USER_INFO_21 {
+    BYTE[ENCRYPTED_PWLEN] usri21_password;
+}
+alias USER_INFO_21* PUSER_INFO_21, LPUSER_INFO_21;
+
+struct USER_INFO_22{
+    LPWSTR usri22_name;
+    BYTE[ENCRYPTED_PWLEN] usri22_password;
+    DWORD usri22_password_age;
+    DWORD usri22_priv;
+    LPWSTR usri22_home_dir;
+    LPWSTR usri22_comment;
+    DWORD usri22_flags;
+    LPWSTR usri22_script_path;
+    DWORD usri22_auth_flags;
+    LPWSTR usri22_full_name;
+    LPWSTR usri22_usr_comment;
+    LPWSTR usri22_parms;
+    LPWSTR usri22_workstations;
+    DWORD usri22_last_logon;
+    DWORD usri22_last_logoff;
+    DWORD usri22_acct_expires;
+    DWORD usri22_max_storage;
+    DWORD usri22_units_per_week;
+    PBYTE usri22_logon_hours;
+    DWORD usri22_bad_pw_count;
+    DWORD usri22_num_logons;
+    LPWSTR usri22_logon_server;
+    DWORD usri22_country_code;
+    DWORD usri22_code_page;
+}
+alias USER_INFO_22* PUSER_INFO_22, LPUSER_INFO_22;
+
+struct USER_INFO_1003{
+    LPWSTR usri1003_password;
+}
+alias USER_INFO_1003* PUSER_INFO_1003, LPUSER_INFO_1003;
+
+struct USER_INFO_1005{
+    DWORD usri1005_priv;
+}
+alias USER_INFO_1005* PUSER_INFO_1005, LPUSER_INFO_1005;
+
+struct USER_INFO_1006{
+    LPWSTR usri1006_home_dir;
+}
+alias USER_INFO_1006* PUSER_INFO_1006, LPUSER_INFO_1006;
+
+struct USER_INFO_1007{
+    LPWSTR usri1007_comment;
+}
+alias USER_INFO_1007* PUSER_INFO_1007, LPUSER_INFO_1007;
+
+struct USER_INFO_1008{
+    DWORD usri1008_flags;
+}
+alias USER_INFO_1008* PUSER_INFO_1008, LPUSER_INFO_1008;
+
+struct USER_INFO_1009{
+    LPWSTR usri1009_script_path;
+}
+alias USER_INFO_1009* PUSER_INFO_1009, LPUSER_INFO_1009;
+
+struct USER_INFO_1010{
+    DWORD usri1010_auth_flags;
+}
+alias USER_INFO_1010* PUSER_INFO_1010, LPUSER_INFO_1010;
+
+struct USER_INFO_1011{
+    LPWSTR usri1011_full_name;
+}
+alias USER_INFO_1011* PUSER_INFO_1011, LPUSER_INFO_1011;
+
+struct USER_INFO_1012{
+    LPWSTR usri1012_usr_comment;
+}
+alias USER_INFO_1012* PUSER_INFO_1012, LPUSER_INFO_1012;
+
+struct USER_INFO_1013{
+    LPWSTR usri1013_parms;
+}
+alias USER_INFO_1013* PUSER_INFO_1013, LPUSER_INFO_1013;
+
+struct USER_INFO_1014{
+    LPWSTR usri1014_workstations;
+}
+alias USER_INFO_1014* PUSER_INFO_1014, LPUSER_INFO_1014;
+
+struct USER_INFO_1017{
+    DWORD usri1017_acct_expires;
+}
+alias USER_INFO_1017* PUSER_INFO_1017, LPUSER_INFO_1017;
+
+struct USER_INFO_1018{
+    DWORD usri1018_max_storage;
+}
+alias USER_INFO_1018* PUSER_INFO_1018, LPUSER_INFO_1018;
+
+struct USER_INFO_1020{
+    DWORD usri1020_units_per_week;
+    PBYTE usri1020_logon_hours;
+}
+alias USER_INFO_1020* PUSER_INFO_1020, LPUSER_INFO_1020;
+
+struct USER_INFO_1023{
+    LPWSTR usri1023_logon_server;
+}
+alias USER_INFO_1023* PUSER_INFO_1023, LPUSER_INFO_1023;
+
+struct USER_INFO_1024{
+    DWORD usri1024_country_code;
+}
+alias USER_INFO_1024* PUSER_INFO_1024, LPUSER_INFO_1024;
+
+struct USER_INFO_1025{
+    DWORD usri1025_code_page;
+}
+alias USER_INFO_1025* PUSER_INFO_1025, LPUSER_INFO_1025;
+
+struct USER_INFO_1051{
+    DWORD usri1051_primary_group_id;
+}
+alias USER_INFO_1051* PUSER_INFO_1051, LPUSER_INFO_1051;
+
+struct USER_INFO_1052{
+    LPWSTR usri1052_profile;
+}
+alias USER_INFO_1052* PUSER_INFO_1052, LPUSER_INFO_1052;
+
+struct USER_INFO_1053{
+    LPWSTR usri1053_home_dir_drive;
+}
+alias USER_INFO_1053* PUSER_INFO_1053, LPUSER_INFO_1053;
+
+struct USER_MODALS_INFO_0{
+    DWORD usrmod0_min_passwd_len;
+    DWORD usrmod0_max_passwd_age;
+    DWORD usrmod0_min_passwd_age;
+    DWORD usrmod0_force_logoff;
+    DWORD usrmod0_password_hist_len;
+}
+alias USER_MODALS_INFO_0* PUSER_MODALS_INFO_0, LPUSER_MODALS_INFO_0;
+
+struct USER_MODALS_INFO_1{
+    DWORD usrmod1_role;
+    LPWSTR usrmod1_primary;
+}
+alias USER_MODALS_INFO_1* PUSER_MODALS_INFO_1, LPUSER_MODALS_INFO_1;
+
+struct USER_MODALS_INFO_2{
+    LPWSTR usrmod2_domain_name;
+    PSID usrmod2_domain_id;
+}
+alias USER_MODALS_INFO_2* PUSER_MODALS_INFO_2, LPUSER_MODALS_INFO_2;
+
+struct USER_MODALS_INFO_3{
+    DWORD usrmod3_lockout_duration;
+    DWORD usrmod3_lockout_observation_window;
+    DWORD usrmod3_lockout_threshold;
+}
+alias USER_MODALS_INFO_3* PUSER_MODALS_INFO_3, LPUSER_MODALS_INFO_3;
+
+struct USER_MODALS_INFO_1001{
+    DWORD usrmod1001_min_passwd_len;
+}
+alias USER_MODALS_INFO_1001* PUSER_MODALS_INFO_1001, LPUSER_MODALS_INFO_1001;
+
+struct USER_MODALS_INFO_1002{
+    DWORD usrmod1002_max_passwd_age;
+}
+alias USER_MODALS_INFO_1002* PUSER_MODALS_INFO_1002, LPUSER_MODALS_INFO_1002;
+
+struct USER_MODALS_INFO_1003{
+    DWORD usrmod1003_min_passwd_age;
+}
+alias USER_MODALS_INFO_1003* PUSER_MODALS_INFO_1003, LPUSER_MODALS_INFO_1003;
+
+struct USER_MODALS_INFO_1004{
+    DWORD usrmod1004_force_logoff;
+}
+alias USER_MODALS_INFO_1004* PUSER_MODALS_INFO_1004, LPUSER_MODALS_INFO_1004;
+
+struct USER_MODALS_INFO_1005{
+    DWORD usrmod1005_password_hist_len;
+}
+alias USER_MODALS_INFO_1005* PUSER_MODALS_INFO_1005, LPUSER_MODALS_INFO_1005;
+
+struct USER_MODALS_INFO_1006{
+    DWORD usrmod1006_role;
+}
+alias USER_MODALS_INFO_1006* PUSER_MODALS_INFO_1006, LPUSER_MODALS_INFO_1006;
+
+struct USER_MODALS_INFO_1007{
+    LPWSTR usrmod1007_primary;
+}
+alias USER_MODALS_INFO_1007* PUSER_MODALS_INFO_1007, LPUSER_MODALS_INFO_1007;
+
+struct GROUP_INFO_0{
+    LPWSTR grpi0_name;
+}
+alias GROUP_INFO_0* PGROUP_INFO_0, LPGROUP_INFO_0;
+
+struct GROUP_INFO_1{
+    LPWSTR grpi1_name;
+    LPWSTR grpi1_comment;
+}
+alias GROUP_INFO_1* PGROUP_INFO_1, LPGROUP_INFO_1;
+
+struct GROUP_INFO_2{
+    LPWSTR grpi2_name;
+    LPWSTR grpi2_comment;
+    DWORD grpi2_group_id;
+    DWORD grpi2_attributes;
+}
+alias GROUP_INFO_2* PGROUP_INFO_2;
+
+struct GROUP_INFO_1002{
+    LPWSTR grpi1002_comment;
+}
+alias GROUP_INFO_1002* PGROUP_INFO_1002, LPGROUP_INFO_1002;
+
+struct GROUP_INFO_1005{
+    DWORD grpi1005_attributes;
+}
+alias GROUP_INFO_1005* PGROUP_INFO_1005, LPGROUP_INFO_1005;
+
+struct GROUP_USERS_INFO_0{
+    LPWSTR grui0_name;
+}
+alias GROUP_USERS_INFO_0* PGROUP_USERS_INFO_0, LPGROUP_USERS_INFO_0;
+
+struct GROUP_USERS_INFO_1{
+    LPWSTR grui1_name;
+    DWORD grui1_attributes;
+}
+alias GROUP_USERS_INFO_1* PGROUP_USERS_INFO_1, LPGROUP_USERS_INFO_1;
+
+struct LOCALGROUP_INFO_0{
+    LPWSTR lgrpi0_name;
+}
+alias LOCALGROUP_INFO_0* PLOCALGROUP_INFO_0, LPLOCALGROUP_INFO_0;
+
+struct LOCALGROUP_INFO_1{
+    LPWSTR lgrpi1_name;
+    LPWSTR lgrpi1_comment;
+}
+alias LOCALGROUP_INFO_1* PLOCALGROUP_INFO_1, LPLOCALGROUP_INFO_1;
+
+struct LOCALGROUP_INFO_1002{
+    LPWSTR lgrpi1002_comment;
+}
+alias LOCALGROUP_INFO_1002* PLOCALGROUP_INFO_1002, LPLOCALGROUP_INFO_1002;
+
+struct LOCALGROUP_MEMBERS_INFO_0{
+    PSID lgrmi0_sid;
+}
+alias LOCALGROUP_MEMBERS_INFO_0* PLOCALGROUP_MEMBERS_INFO_0, LPLOCALGROUP_MEMBERS_INFO_0;
+
+struct LOCALGROUP_MEMBERS_INFO_1{
+    PSID lgrmi1_sid;
+    SID_NAME_USE lgrmi1_sidusage;
+    LPWSTR lgrmi1_name;
+}
+alias LOCALGROUP_MEMBERS_INFO_1* PLOCALGROUP_MEMBERS_INFO_1, LPLOCALGROUP_MEMBERS_INFO_1;
+
+struct LOCALGROUP_MEMBERS_INFO_2{
+    PSID lgrmi2_sid;
+    SID_NAME_USE lgrmi2_sidusage;
+    LPWSTR lgrmi2_domainandname;
+}
+alias LOCALGROUP_MEMBERS_INFO_2* PLOCALGROUP_MEMBERS_INFO_2, LPLOCALGROUP_MEMBERS_INFO_2;
+
+struct LOCALGROUP_MEMBERS_INFO_3{
+    LPWSTR lgrmi3_domainandname;
+}
+alias LOCALGROUP_MEMBERS_INFO_3* PLOCALGROUP_MEMBERS_INFO_3, LPLOCALGROUP_MEMBERS_INFO_3;
+
+struct LOCALGROUP_USERS_INFO_0{
+    LPWSTR lgrui0_name;
+}
+alias LOCALGROUP_USERS_INFO_0* PLOCALGROUP_USERS_INFO_0, LPLOCALGROUP_USERS_INFO_0;
+
+struct NET_DISPLAY_USER{
+    LPWSTR usri1_name;
+    LPWSTR usri1_comment;
+    DWORD usri1_flags;
+    LPWSTR usri1_full_name;
+    DWORD usri1_user_id;
+    DWORD usri1_next_index;
+}
+alias NET_DISPLAY_USER* PNET_DISPLAY_USER;
+
+struct NET_DISPLAY_MACHINE{
+    LPWSTR usri2_name;
+    LPWSTR usri2_comment;
+    DWORD usri2_flags;
+    DWORD usri2_user_id;
+    DWORD usri2_next_index;
+}
+alias NET_DISPLAY_MACHINE* PNET_DISPLAY_MACHINE;
+
+struct NET_DISPLAY_GROUP{
+    LPWSTR grpi3_name;
+    LPWSTR grpi3_comment;
+    DWORD grpi3_group_id;
+    DWORD grpi3_attributes;
+    DWORD grpi3_next_index;
+}
+alias NET_DISPLAY_GROUP* PNET_DISPLAY_GROUP;
+
+struct ACCESS_INFO_0{
+    LPTSTR acc0_resource_name;
+}
+alias ACCESS_INFO_0* PACCESS_INFO_0, LPACCESS_INFO_0;
+
+struct ACCESS_INFO_1{
+    LPTSTR acc1_resource_name;
+    DWORD acc1_attr;
+    DWORD acc1_count;
+}
+alias ACCESS_INFO_1* PACCESS_INFO_1, LPACCESS_INFO_1;
+
+struct ACCESS_INFO_1002{
+    DWORD acc1002_attr;
+}
+alias ACCESS_INFO_1002* PACCESS_INFO_1002, LPACCESS_INFO_1002;
+
+struct ACCESS_LIST{
+    LPTSTR acl_ugname;
+    DWORD acl_access;
+}
+alias ACCESS_LIST* PACCESS_LIST, LPACCESS_LIST;
+
+struct NETLOGON_INFO_1{
+    DWORD netlog1_flags;
+    NET_API_STATUS netlog1_pdc_connection_status;
+}
+alias NETLOGON_INFO_1* PNETLOGON_INFO_1;
+
+struct NETLOGON_INFO_2{
+    DWORD netlog2_flags;
+    NET_API_STATUS netlog2_pdc_connection_status;
+    LPWSTR netlog2_trusted_dc_name;
+    NET_API_STATUS netlog2_tc_connection_status;
+}
+alias NETLOGON_INFO_2* PNETLOGON_INFO_2;
+
+struct NETLOGON_INFO_3{
+    DWORD netlog3_flags;
+    DWORD netlog3_logon_attempts;
+    DWORD netlog3_reserved1;
+    DWORD netlog3_reserved2;
+    DWORD netlog3_reserved3;
+    DWORD netlog3_reserved4;
+    DWORD netlog3_reserved5;
+}
+alias NETLOGON_INFO_3* PNETLOGON_INFO_3;
+
+extern (Windows) {
+deprecated {
+    /* These are obsolete */
+    NET_API_STATUS NetAccessAdd(LPCWSTR,DWORD,PBYTE,PDWORD);
+    NET_API_STATUS NetAccessEnum(LPCWSTR,LPCWSTR,DWORD,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+    NET_API_STATUS NetAccessGetInfo(LPCWSTR,LPCWSTR,DWORD,PBYTE*);
+    NET_API_STATUS NetAccessSetInfo(LPCWSTR,LPCWSTR,DWORD,PBYTE,PDWORD);
+    NET_API_STATUS NetAccessDel(LPCWSTR,LPCWSTR);
+    NET_API_STATUS NetAccessGetUserPerms(LPCWSTR,LPCWSTR,LPCWSTR,PDWORD);
+}
+NET_API_STATUS NetUserAdd(LPCWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetUserEnum(LPCWSTR,DWORD,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+NET_API_STATUS NetUserGetInfo(LPCWSTR,LPCWSTR,DWORD,PBYTE*);
+NET_API_STATUS NetUserSetInfo(LPCWSTR,LPCWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetUserDel(LPCWSTR,LPCWSTR);
+NET_API_STATUS NetUserGetGroups(LPCWSTR,LPCWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD);
+NET_API_STATUS NetUserSetGroups(LPCWSTR,LPCWSTR,DWORD,PBYTE,DWORD);
+NET_API_STATUS NetUserGetLocalGroups(LPCWSTR,LPCWSTR,DWORD,DWORD,PBYTE*,DWORD,PDWORD,PDWORD);
+NET_API_STATUS NetUserModalsGet(LPCWSTR,DWORD,PBYTE*);
+NET_API_STATUS NetUserModalsSet(LPCWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetUserChangePassword(LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR);
+NET_API_STATUS NetGroupAdd(LPCWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetGroupAddUser(LPCWSTR,LPCWSTR,LPCWSTR);
+NET_API_STATUS NetGroupEnum(LPCWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+NET_API_STATUS NetGroupGetInfo(LPCWSTR,LPCWSTR,DWORD,PBYTE*);
+NET_API_STATUS NetGroupSetInfo(LPCWSTR,LPCWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetGroupDel(LPCWSTR,LPCWSTR);
+NET_API_STATUS NetGroupDelUser(LPCWSTR,LPCWSTR,LPCWSTR);
+NET_API_STATUS NetGroupGetUsers(LPCWSTR,LPCWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+NET_API_STATUS NetGroupSetUsers(LPCWSTR,LPCWSTR,DWORD,PBYTE,DWORD);
+NET_API_STATUS NetLocalGroupAdd(LPCWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetLocalGroupAddMember(LPCWSTR,LPCWSTR,PSID);
+NET_API_STATUS NetLocalGroupEnum(LPCWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+NET_API_STATUS NetLocalGroupGetInfo(LPCWSTR,LPCWSTR,DWORD,PBYTE*);
+NET_API_STATUS NetLocalGroupSetInfo(LPCWSTR,LPCWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetLocalGroupDel(LPCWSTR,LPCWSTR);
+NET_API_STATUS NetLocalGroupDelMember(LPCWSTR,LPCWSTR,PSID);
+NET_API_STATUS NetLocalGroupGetMembers(LPCWSTR,LPCWSTR,DWORD,PBYTE*,DWORD,
+PDWORD,PDWORD,PDWORD);
+NET_API_STATUS NetLocalGroupSetMembers(LPCWSTR,LPCWSTR,DWORD,PBYTE,DWORD);
+NET_API_STATUS NetLocalGroupAddMembers(LPCWSTR,LPCWSTR,DWORD,PBYTE,DWORD);
+NET_API_STATUS NetLocalGroupDelMembers(LPCWSTR,LPCWSTR,DWORD,PBYTE,DWORD);
+NET_API_STATUS NetQueryDisplayInformation(LPCWSTR,DWORD,DWORD,DWORD,DWORD,PDWORD,PVOID*);
+NET_API_STATUS NetGetDisplayInformationIndex(LPCWSTR,DWORD,LPCWSTR,PDWORD);
+NET_API_STATUS NetGetDCName(LPCWSTR,LPCWSTR,PBYTE*);
+NET_API_STATUS NetGetAnyDCName(LPCWSTR,LPCWSTR,PBYTE*);
+NET_API_STATUS I_NetLogonControl(LPCWSTR,DWORD,DWORD,PBYTE*);
+NET_API_STATUS I_NetLogonControl2(LPCWSTR,DWORD,DWORD,PBYTE,PBYTE*);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmalert.d b/libphobos/libdruntime/core/sys/windows/lmalert.d
new file mode 100644
index 00000000000..babc16ad9a5
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmalert.d
@@ -0,0 +1,77 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmalert.d)
+ */
+module core.sys.windows.lmalert;
+version (Windows):
+pragma(lib, "netapi32");
+
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+const TCHAR[]
+    ALERTER_MAILSLOT     = `\\.\MAILSLOT\Alerter`,
+    ALERT_PRINT_EVENT    = "PRINTING",
+    ALERT_MESSAGE_EVENT  = "MESSAGE",
+    ALERT_ERRORLOG_EVENT = "ERRORLOG",
+    ALERT_ADMIN_EVENT    = "ADMIN",
+    ALERT_USER_EVENT     = "USER";
+//MACRO #define ALERT_OTHER_INFO(x) ((PBYTE)(x)+sizeof(STD_ALERT))
+
+//MACRO #define ALERT_VAR_DATA(p) ((PBYTE)(p)+sizeof(*p))
+
+enum PRJOB_QSTATUS     = 3;
+enum PRJOB_DEVSTATUS   = 508;
+enum PRJOB_COMPLETE    = 4;
+enum PRJOB_INTERV      = 8;
+enum PRJOB_            = 16;
+enum PRJOB_DESTOFFLINE = 32;
+enum PRJOB_DESTPAUSED  = 64;
+enum PRJOB_NOTIFY      = 128;
+enum PRJOB_DESTNOPAPER = 256;
+enum PRJOB_DELETED     = 32768;
+enum PRJOB_QS_QUEUED   = 0;
+enum PRJOB_QS_PAUSED   = 1;
+enum PRJOB_QS_SPOOLING = 2;
+enum PRJOB_QS_PRINTING = 3;
+
+struct ADMIN_OTHER_INFO{
+    DWORD alrtad_errcode;
+    DWORD alrtad_numstrings;
+}
+alias ADMIN_OTHER_INFO* PADMIN_OTHER_INFO, LPADMIN_OTHER_INFO;
+
+struct STD_ALERT{
+    DWORD alrt_timestamp;
+    TCHAR[EVLEN+1] alrt_eventname;
+    TCHAR[SNLEN+1] alrt_servicename;
+}
+alias STD_ALERT* PSTD_ALERT, LPSTD_ALERT;
+
+struct ERRLOG_OTHER_INFO{
+    DWORD alrter_errcode;
+    DWORD alrter_offset;
+}
+alias ERRLOG_OTHER_INFO* PERRLOG_OTHER_INFO, LPERRLOG_OTHER_INFO;
+
+struct PRINT_OTHER_INFO{
+    DWORD alrtpr_jobid;
+    DWORD alrtpr_status;
+    DWORD alrtpr_submitted;
+    DWORD alrtpr_size;
+}
+alias PRINT_OTHER_INFO* PPRINT_OTHER_INFO, LPPRINT_OTHER_INFO;
+
+struct USER_OTHER_INFO{
+    DWORD alrtus_errcode;
+    DWORD alrtus_numstrings;
+}
+alias USER_OTHER_INFO* PUSER_OTHER_INFO, LPUSER_OTHER_INFO;
+
+extern (Windows) {
+NET_API_STATUS NetAlertRaise(LPCWSTR,PVOID,DWORD);
+NET_API_STATUS NetAlertRaiseEx(LPCWSTR,PVOID,DWORD,LPCWSTR);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmapibuf.d b/libphobos/libdruntime/core/sys/windows/lmapibuf.d
new file mode 100644
index 00000000000..6c2df771055
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmapibuf.d
@@ -0,0 +1,21 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmapibuf.d)
+ */
+module core.sys.windows.lmapibuf;
+version (Windows):
+pragma(lib, "netapi32");
+
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+extern (Windows) {
+    NET_API_STATUS NetApiBufferAllocate(DWORD, PVOID*);
+    NET_API_STATUS NetApiBufferFree(PVOID);
+    NET_API_STATUS NetApiBufferReallocate(PVOID, DWORD, PVOID*);
+    NET_API_STATUS NetApiBufferSize(PVOID, PDWORD);
+    NET_API_STATUS NetapipBufferAllocate(DWORD, PVOID*);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmat.d b/libphobos/libdruntime/core/sys/windows/lmat.d
new file mode 100644
index 00000000000..d54a60c728a
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmat.d
@@ -0,0 +1,50 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmat.d)
+ */
+module core.sys.windows.lmat;
+version (Windows):
+pragma(lib, "netapi32");
+
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+enum JOB_RUN_PERIODICALLY = 1;
+enum JOB_EXEC_ERROR       = 2;
+enum JOB_RUNS_TODAY       = 4;
+enum JOB_ADD_CURRENT_DATE = 8;
+enum JOB_NONINTERACTIVE   = 16;
+enum JOB_INPUT_FLAGS      = JOB_RUN_PERIODICALLY | JOB_ADD_CURRENT_DATE
+                             | JOB_NONINTERACTIVE;
+enum JOB_OUTPUT_FLAGS     = JOB_RUN_PERIODICALLY | JOB_EXEC_ERROR
+                             | JOB_RUNS_TODAY | JOB_NONINTERACTIVE;
+
+struct AT_ENUM {
+    DWORD JobId;
+    DWORD JobTime;
+    DWORD DaysOfMonth;
+    UCHAR DaysOfWeek;
+    UCHAR Flags;
+    LPWSTR Command;
+}
+alias AT_ENUM* PAT_ENUM, LPAT_ENUM;
+
+struct AT_INFO {
+    DWORD JobTime;
+    DWORD DaysOfMonth;
+    UCHAR DaysOfWeek;
+    UCHAR Flags;
+    LPWSTR Command;
+}
+alias AT_INFO* PAT_INFO, LPAT_INFO;
+
+extern (Windows) {
+    NET_API_STATUS NetScheduleJobAdd(LPWSTR, PBYTE, LPDWORD);
+    NET_API_STATUS NetScheduleJobDel(LPWSTR, DWORD, DWORD);
+    NET_API_STATUS NetScheduleJobEnum(LPWSTR, PBYTE*, DWORD, PDWORD, PDWORD,
+      PDWORD);
+    NET_API_STATUS NetScheduleJobGetInfo(LPWSTR, DWORD, PBYTE*);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmaudit.d b/libphobos/libdruntime/core/sys/windows/lmaudit.d
new file mode 100644
index 00000000000..476ab5b709b
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmaudit.d
@@ -0,0 +1,302 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmaudit.d)
+ */
+// COMMENT: This file may be deprecated.
+module core.sys.windows.lmaudit;
+version (Windows):
+
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+enum LOGFLAGS_FORWARD  = 0;
+enum LOGFLAGS_BACKWARD = 1;
+enum LOGFLAGS_SEEK     = 2;
+
+enum ACTION_LOCKOUT     = 0;
+enum ACTION_ADMINUNLOCK = 1;
+
+enum AE_GUEST=0;
+enum AE_USER=1;
+enum AE_ADMIN=2;
+enum AE_NORMAL=0;
+enum AE_USERLIMIT=0;
+enum AE_GENERAL=0;
+enum AE_ERROR=1;
+enum AE_SESSDIS=1;
+enum AE_BADPW=1;
+enum AE_AUTODIS=2;
+enum AE_UNSHARE=2;
+enum AE_ADMINPRIVREQD=2;
+enum AE_ADMINDIS=3;
+enum AE_NOACCESSPERM=3;
+enum AE_ACCRESTRICT=4;
+enum AE_NORMAL_CLOSE=0;
+enum AE_SES_CLOSE=1;
+enum AE_ADMIN_CLOSE=2;
+enum AE_LIM_UNKNOWN=0;
+enum AE_LIM_LOGONHOURS=1;
+enum AE_LIM_EXPIRED=2;
+enum AE_LIM_INVAL_WKSTA=3;
+enum AE_LIM_DISABLED=4;
+enum AE_LIM_DELETED=5;
+enum AE_MOD=0;
+enum AE_DELETE=1;
+enum AE_ADD=2;
+
+enum AE_UAS_USER   = 0;
+enum AE_UAS_GROUP  = 1;
+enum AE_UAS_MODALS = 2;
+
+enum SVAUD_SERVICE       = 1;
+enum SVAUD_GOODSESSLOGON = 6;
+enum SVAUD_BADSESSLOGON  = 24;
+enum SVAUD_SESSLOGON     = SVAUD_GOODSESSLOGON|SVAUD_BADSESSLOGON;
+enum SVAUD_GOODNETLOGON  = 96;
+enum SVAUD_BADNETLOGON   = 384;
+enum SVAUD_NETLOGON      = SVAUD_GOODNETLOGON|SVAUD_BADNETLOGON;
+enum SVAUD_LOGON         = SVAUD_NETLOGON|SVAUD_SESSLOGON;
+enum SVAUD_GOODUSE       = 0x600;
+enum SVAUD_BADUSE        = 0x1800;
+enum SVAUD_USE           = SVAUD_GOODUSE|SVAUD_BADUSE;
+enum SVAUD_USERLIST      = 8192;
+enum SVAUD_PERMISSIONS   = 16384;
+enum SVAUD_RESOURCE      = 32768;
+enum SVAUD_LOGONLIM      = 65536;
+
+enum AA_AUDIT_ALL=1;
+enum AA_A_OWNER=4;
+enum AA_CLOSE=8;
+enum AA_S_OPEN=16;
+enum AA_S_WRITE=32;
+enum AA_S_CREATE=32;
+enum AA_S_DELETE=64;
+enum AA_S_ACL=128;
+enum AA_S_ALL=253;
+enum AA_F_OPEN=256;
+enum AA_F_WRITE=512;
+enum AA_F_CREATE=512;
+enum AA_F_DELETE=1024;
+enum AA_F_ACL=2048;
+enum AA_F_ALL = AA_F_OPEN|AA_F_WRITE|AA_F_DELETE|AA_F_ACL;
+enum AA_A_OPEN=2048;
+enum AA_A_WRITE=4096;
+enum AA_A_CREATE=8192;
+enum AA_A_DELETE=16384;
+enum AA_A_ACL=32768;
+enum AA_A_ALL = AA_F_OPEN|AA_F_WRITE|AA_F_DELETE|AA_F_ACL;
+
+struct AUDIT_ENTRY{
+    DWORD ae_len;
+    DWORD ae_reserved;
+    DWORD ae_time;
+    DWORD ae_type;
+    DWORD ae_data_offset;
+    DWORD ae_data_size;
+}
+alias AUDIT_ENTRY* PAUDIT_ENTRY, LPAUDIT_ENTRY;
+
+struct HLOG{
+    DWORD time;
+    DWORD last_flags;
+    DWORD offset;
+    DWORD rec_offset;
+}
+alias HLOG* PHLOG, LPHLOG;
+
+struct AE_SRVSTATUS{
+    DWORD ae_sv_status;
+}
+alias AE_SRVSTATUS* PAE_SRVSTATUS, LPAE_SRVSTATUS;
+
+struct AE_SESSLOGON{
+    DWORD ae_so_compname;
+    DWORD ae_so_username;
+    DWORD ae_so_privilege;
+}
+alias AE_SESSLOGON* PAE_SESSLOGON, LPAE_SESSLOGON;
+
+struct AE_SESSLOGOFF{
+    DWORD ae_sf_compname;
+    DWORD ae_sf_username;
+    DWORD ae_sf_reason;
+}
+alias AE_SESSLOGOFF* PAE_SESSLOGOFF, LPAE_SESSLOGOFF;
+
+struct AE_SESSPWERR{
+    DWORD ae_sp_compname;
+    DWORD ae_sp_username;
+}
+alias AE_SESSPWERR* PAE_SESSPWERR, LPAE_SESSPWERR;
+
+struct AE_CONNSTART{
+    DWORD ae_ct_compname;
+    DWORD ae_ct_username;
+    DWORD ae_ct_netname;
+    DWORD ae_ct_connid;
+}
+alias AE_CONNSTART* PAE_CONNSTART, LPAE_CONNSTART;
+
+struct AE_CONNSTOP{
+    DWORD ae_cp_compname;
+    DWORD ae_cp_username;
+    DWORD ae_cp_netname;
+    DWORD ae_cp_connid;
+    DWORD ae_cp_reason;
+}
+alias AE_CONNSTOP* PAE_CONNSTOP, LPAE_CONNSTOP;
+
+struct AE_CONNREJ{
+    DWORD ae_cr_compname;
+    DWORD ae_cr_username;
+    DWORD ae_cr_netname;
+    DWORD ae_cr_reason;
+}
+alias AE_CONNREJ* PAE_CONNREJ, LPAE_CONNREJ;
+
+struct AE_RESACCESS{
+    DWORD ae_ra_compname;
+    DWORD ae_ra_username;
+    DWORD ae_ra_resname;
+    DWORD ae_ra_operation;
+    DWORD ae_ra_returncode;
+    DWORD ae_ra_restype;
+    DWORD ae_ra_fileid;
+}
+alias AE_RESACCESS* PAE_RESACCESS, LPAE_RESACCESS;
+
+struct AE_RESACCESSREJ{
+    DWORD ae_rr_compname;
+    DWORD ae_rr_username;
+    DWORD ae_rr_resname;
+    DWORD ae_rr_operation;
+}
+alias AE_RESACCESSREJ* PAE_RESACCESSREJ, LPAE_RESACCESSREJ;
+
+struct AE_CLOSEFILE{
+    DWORD ae_cf_compname;
+    DWORD ae_cf_username;
+    DWORD ae_cf_resname;
+    DWORD ae_cf_fileid;
+    DWORD ae_cf_duration;
+    DWORD ae_cf_reason;
+}
+alias AE_CLOSEFILE* PAE_CLOSEFILE, LPAE_CLOSEFILE;
+
+struct AE_SERVICESTAT{
+    DWORD ae_ss_compname;
+    DWORD ae_ss_username;
+    DWORD ae_ss_svcname;
+    DWORD ae_ss_status;
+    DWORD ae_ss_code;
+    DWORD ae_ss_text;
+    DWORD ae_ss_returnval;
+}
+alias AE_SERVICESTAT* PAE_SERVICESTAT, LPAE_SERVICESTAT;
+
+struct AE_ACLMOD{
+    DWORD ae_am_compname;
+    DWORD ae_am_username;
+    DWORD ae_am_resname;
+    DWORD ae_am_action;
+    DWORD ae_am_datalen;
+}
+alias AE_ACLMOD* PAE_ACLMOD, LPAE_ACLMOD;
+
+struct AE_UASMOD{
+    DWORD ae_um_compname;
+    DWORD ae_um_username;
+    DWORD ae_um_resname;
+    DWORD ae_um_rectype;
+    DWORD ae_um_action;
+    DWORD ae_um_datalen;
+}
+alias AE_UASMOD* PAE_UASMOD, LPAE_UASMOD;
+
+struct AE_NETLOGON{
+    DWORD ae_no_compname;
+    DWORD ae_no_username;
+    DWORD ae_no_privilege;
+    DWORD ae_no_authflags;
+}
+alias AE_NETLOGON* PAE_NETLOGON, LPAE_NETLOGON;
+
+struct AE_NETLOGOFF{
+    DWORD ae_nf_compname;
+    DWORD ae_nf_username;
+    DWORD ae_nf_reserved1;
+    DWORD ae_nf_reserved2;
+}
+alias AE_NETLOGOFF* PAE_NETLOGOFF, LPAE_NETLOGOFF;
+
+struct AE_ACCLIM{
+    DWORD ae_al_compname;
+    DWORD ae_al_username;
+    DWORD ae_al_resname;
+    DWORD ae_al_limit;
+}
+alias AE_ACCLIM* PAE_ACCLIM, LPAE_ACCLIM;
+
+struct AE_LOCKOUT{
+    DWORD ae_lk_compname;
+    DWORD ae_lk_username;
+    DWORD ae_lk_action;
+    DWORD ae_lk_bad_pw_count;
+}
+alias AE_LOCKOUT* PAE_LOCKOUT, LPAE_LOCKOUT;
+
+struct AE_GENERIC{
+    DWORD ae_ge_msgfile;
+    DWORD ae_ge_msgnum;
+    DWORD ae_ge_params;
+    DWORD ae_ge_param1;
+    DWORD ae_ge_param2;
+    DWORD ae_ge_param3;
+    DWORD ae_ge_param4;
+    DWORD ae_ge_param5;
+    DWORD ae_ge_param6;
+    DWORD ae_ge_param7;
+    DWORD ae_ge_param8;
+    DWORD ae_ge_param9;
+}
+alias AE_GENERIC* PAE_GENERIC, LPAE_GENERIC;
+
+extern (Windows) {
+deprecated {
+NET_API_STATUS NetAuditClear(LPCWSTR,LPCWSTR,LPCWSTR);
+NET_API_STATUS NetAuditRead(LPTSTR,LPTSTR,LPHLOG,DWORD,PDWORD,DWORD,DWORD,PBYTE*,DWORD,PDWORD,PDWORD);
+NET_API_STATUS NetAuditWrite(DWORD,PBYTE,DWORD,LPTSTR,PBYTE);
+}
+}
+
+/+
+/* MinGW: These conflict with struct typedefs, why? */
+enum AE_SRVSTATUS=0;
+enum AE_SESSLOGON=1;
+enum AE_SESSLOGOFF=2;
+enum AE_SESSPWERR=3;
+enum AE_CONNSTART=4;
+enum AE_CONNSTOP=5;
+enum AE_CONNREJ=6;
+enum AE_RESACCESS=7;
+enum AE_RESACCESSREJ=8;
+enum AE_CLOSEFILE=9;
+enum AE_SERVICESTAT=11;
+enum AE_ACLMOD=12;
+enum AE_UASMOD=13;
+enum AE_NETLOGON=14;
+enum AE_NETLOGOFF=15;
+enum AE_NETLOGDENIED=16;
+enum AE_ACCLIMITEXCD=17;
+enum AE_RESACCESS2=18;
+enum AE_ACLMODFAIL=19;
+enum AE_LOCKOUT=20;
+enum AE_GENERIC_TYPE=21;
+enum AE_SRVSTART=0;
+enum AE_SRVPAUSED=1;
+enum AE_SRVCONT=2;
+enum AE_SRVSTOP=3;
++/
diff --git a/libphobos/libdruntime/core/sys/windows/lmbrowsr.d b/libphobos/libdruntime/core/sys/windows/lmbrowsr.d
new file mode 100644
index 00000000000..2bd303f91b0
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmbrowsr.d
@@ -0,0 +1,85 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmbrowsr.d)
+ */
+module core.sys.windows.lmbrowsr;
+version (Windows):
+
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+enum BROWSER_ROLE_PDC = 1;
+enum BROWSER_ROLE_BDC = 2;
+
+struct BROWSER_STATISTICS {
+    LARGE_INTEGER StatisticsStartTime;
+    LARGE_INTEGER NumberOfServerAnnouncements;
+    LARGE_INTEGER NumberOfDomainAnnouncements;
+    ULONG NumberOfElectionPackets;
+    ULONG NumberOfMailslotWrites;
+    ULONG NumberOfGetBrowserServerListRequests;
+    ULONG NumberOfServerEnumerations;
+    ULONG NumberOfDomainEnumerations;
+    ULONG NumberOfOtherEnumerations;
+    ULONG NumberOfMissedServerAnnouncements;
+    ULONG NumberOfMissedMailslotDatagrams;
+    ULONG NumberOfMissedGetBrowserServerListRequests;
+    ULONG NumberOfFailedServerAnnounceAllocations;
+    ULONG NumberOfFailedMailslotAllocations;
+    ULONG NumberOfFailedMailslotReceives;
+    ULONG NumberOfFailedMailslotWrites;
+    ULONG NumberOfFailedMailslotOpens;
+    ULONG NumberOfDuplicateMasterAnnouncements;
+    LARGE_INTEGER NumberOfIllegalDatagrams;
+}
+alias BROWSER_STATISTICS* PBROWSER_STATISTICS, LPBROWSER_STATISTICS;
+
+struct BROWSER_STATISTICS_100 {
+    LARGE_INTEGER StartTime;
+    LARGE_INTEGER NumberOfServerAnnouncements;
+    LARGE_INTEGER NumberOfDomainAnnouncements;
+    ULONG NumberOfElectionPackets;
+    ULONG NumberOfMailslotWrites;
+    ULONG NumberOfGetBrowserServerListRequests;
+    LARGE_INTEGER NumberOfIllegalDatagrams;
+}
+alias BROWSER_STATISTICS_100* PBROWSER_STATISTICS_100;
+
+struct BROWSER_STATISTICS_101 {
+    LARGE_INTEGER StartTime;
+    LARGE_INTEGER NumberOfServerAnnouncements;
+    LARGE_INTEGER NumberOfDomainAnnouncements;
+    ULONG NumberOfElectionPackets;
+    ULONG NumberOfMailslotWrites;
+    ULONG NumberOfGetBrowserServerListRequests;
+    LARGE_INTEGER NumberOfIllegalDatagrams;
+    ULONG NumberOfMissedServerAnnouncements;
+    ULONG NumberOfMissedMailslotDatagrams;
+    ULONG NumberOfMissedGetBrowserServerListRequests;
+    ULONG NumberOfFailedServerAnnounceAllocations;
+    ULONG NumberOfFailedMailslotAllocations;
+    ULONG NumberOfFailedMailslotReceives;
+    ULONG NumberOfFailedMailslotWrites;
+    ULONG NumberOfFailedMailslotOpens;
+    ULONG NumberOfDuplicateMasterAnnouncements;
+}
+alias BROWSER_STATISTICS_101* PBROWSER_STATISTICS_101;
+
+extern (Windows) {
+    NET_API_STATUS I_BrowserServerEnum(LPCWSTR, LPCWSTR, LPCWSTR, DWORD,
+      PBYTE*, DWORD, PDWORD, PDWORD, DWORD, LPCWSTR, PDWORD);
+    NET_API_STATUS I_BrowserServerEnumEx(LPCWSTR, LPCWSTR, LPCWSTR, DWORD,
+      PBYTE*, DWORD, PDWORD, PDWORD, DWORD, LPCWSTR, LPCWSTR);
+    NET_API_STATUS I_BrowserQueryEmulatedDomains(LPWSTR, PBYTE*, PDWORD);
+    NET_API_STATUS I_BrowserQueryOtherDomains(LPCWSTR, PBYTE*, PDWORD, PDWORD);
+    NET_API_STATUS I_BrowserResetNetlogonState(LPCWSTR);
+    NET_API_STATUS I_BrowserSetNetlogonState(LPWSTR, LPWSTR, LPWSTR, DWORD);
+    NET_API_STATUS I_BrowserQueryStatistics(LPCWSTR, LPBROWSER_STATISTICS*);
+    NET_API_STATUS I_BrowserResetStatistics(LPCWSTR);
+    WORD I_BrowserServerEnumForXactsrv(LPCWSTR, LPCWSTR, ULONG, USHORT, PVOID,
+      WORD, DWORD, PDWORD, PDWORD, DWORD, LPCWSTR, LPCWSTR, PWORD);
+    NET_API_STATUS I_BrowserDebugTrace(PWCHAR, PCHAR);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmchdev.d b/libphobos/libdruntime/core/sys/windows/lmchdev.d
new file mode 100644
index 00000000000..2dcf9e314cc
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmchdev.d
@@ -0,0 +1,90 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmchdev.d)
+ */
+module core.sys.windows.lmchdev;
+version (Windows):
+
+// COMMENT: This file might be deprecated.
+
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+enum CHARDEVQ_NO_REQUESTS  = -1;
+enum CHARDEV_CLOSE         = 0;
+enum CHARDEVQ_MAX_PRIORITY = 1;
+enum CHARDEVQ_DEV_PARMNUM  = 1;
+
+enum HANDLE_INFO_LEVEL_1 = 1;
+enum HANDLE_CHARTIME_PARMNUM = 1;
+enum HANDLE_CHARCOUNT_PARMNUM = 2;
+
+enum CHARDEV_STAT_OPENED = 2;
+enum CHARDEVQ_PRIORITY_PARMNUM = 2;
+enum CHARDEVQ_DEVS_PARMNUM = 3;
+enum CHARDEV_STAT_ERROR = 4;
+enum CHARDEVQ_NUMUSERS_PARMNUM = 4;
+enum CHARDEVQ_NUMAHEAD_PARMNUM = 5;
+enum CHARDEVQ_DEF_PRIORITY = 5;
+enum CHARDEVQ_PRIORITY_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+CHARDEVQ_PRIORITY_PARMNUM;
+enum CHARDEVQ_DEVS_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+CHARDEVQ_DEVS_PARMNUM;
+enum CHARDEVQ_MIN_PRIORITY = 9;
+
+struct CHARDEV_INFO_0 {
+ LPWSTR ch0_dev;
+}
+alias CHARDEV_INFO_0* PCHARDEV_INFO_0, LPCHARDEV_INFO_0;
+
+struct CHARDEV_INFO_1{
+    LPWSTR ch1_dev;
+    DWORD ch1_status;
+    LPWSTR ch1_username;
+    DWORD ch1_time;
+}
+alias CHARDEV_INFO_1* PCHARDEV_INFO_1, LPCHARDEV_INFO_1;
+
+struct CHARDEVQ_INFO_0 {
+ LPWSTR cq0_dev;
+}
+alias CHARDEVQ_INFO_0* PCHARDEVQ_INFO_0, LPCHARDEVQ_INFO_0;
+
+struct CHARDEVQ_INFO_1{
+    LPWSTR cq1_dev;
+    DWORD cq1_priority;
+    LPWSTR cq1_devs;
+    DWORD cq1_numusers;
+    DWORD cq1_numahead;
+}
+alias CHARDEVQ_INFO_1* PCHARDEVQ_INFO_1, LPCHARDEVQ_INFO_1;
+
+struct CHARDEVQ_INFO_1002 {
+    DWORD cq1002_priority;
+}
+alias CHARDEVQ_INFO_1002* PCHARDEVQ_INFO_1002, LPCHARDEVQ_INFO_1002;
+
+struct CHARDEVQ_INFO_1003 {
+    LPWSTR cq1003_devs;
+}
+alias CHARDEVQ_INFO_1003* PCHARDEVQ_INFO_1003, LPCHARDEVQ_INFO_1003;
+
+struct HANDLE_INFO_1{
+    DWORD hdli1_chartime;
+    DWORD hdli1_charcount;
+}
+alias HANDLE_INFO_1* PHANDLE_INFO_1, LPHANDLE_INFO_1;
+
+extern (Windows) {
+    NET_API_STATUS NetCharDevEnum(LPCWSTR, DWORD, PBYTE*, DWORD, PDWORD, PDWORD, PDWORD);
+    NET_API_STATUS NetCharDevGetInfo(LPCWSTR, LPCWSTR, DWORD, PBYTE*);
+    NET_API_STATUS NetCharDevControl(LPCWSTR, LPCWSTR, DWORD);
+    NET_API_STATUS NetCharDevQEnum(LPCWSTR, LPCWSTR, DWORD, PBYTE*, DWORD, PDWORD, PDWORD, PDWORD);
+    NET_API_STATUS NetCharDevQGetInfo(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, PBYTE*);
+    NET_API_STATUS NetCharDevQSetInfo(LPCWSTR, LPCWSTR, DWORD, PBYTE, PDWORD);
+    NET_API_STATUS NetCharDevQPurge(LPCWSTR, LPCWSTR);
+    NET_API_STATUS NetCharDevQPurgeSelf(LPCWSTR, LPCWSTR, LPCWSTR);
+    NET_API_STATUS NetHandleGetInfo(HANDLE, DWORD, PBYTE*);
+    NET_API_STATUS NetHandleSetInfo(HANDLE, DWORD, PBYTE, DWORD, PDWORD);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmconfig.d b/libphobos/libdruntime/core/sys/windows/lmconfig.d
new file mode 100644
index 00000000000..64e943ac04a
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmconfig.d
@@ -0,0 +1,30 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmconfig.d)
+ */
+module core.sys.windows.lmconfig;
+version (Windows):
+
+// All functions in this file are deprecated!
+
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+deprecated {
+    struct CONFIG_INFO_0 {
+        LPWSTR cfgi0_key;
+        LPWSTR cfgi0_data;
+    }
+
+    alias CONFIG_INFO_0* PCONFIG_INFO_0, LPCONFIG_INFO_0;
+
+    extern (Windows) {
+        NET_API_STATUS NetConfigGet(LPCWSTR, LPCWSTR, LPCWSTR, PBYTE*);
+        NET_API_STATUS NetConfigGetAll(LPCWSTR, LPCWSTR, PBYTE*);
+        NET_API_STATUS NetConfigSet(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, DWORD,
+          PBYTE, DWORD);
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmcons.d b/libphobos/libdruntime/core/sys/windows/lmcons.d
new file mode 100644
index 00000000000..c0fcb8f802e
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmcons.d
@@ -0,0 +1,88 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmcons.d)
+ */
+module core.sys.windows.lmcons;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.windef;
+private import core.sys.windows.lmerr; // for NERR_BASE
+
+const TCHAR[]
+    MESSAGE_FILENAME = "NETMSG",
+    OS2MSG_FILENAME = "BASE",
+    HELP_MSG_FILENAME = "NETH";
+
+alias DWORD NET_API_STATUS, API_RET_TYPE;
+
+enum MIN_LANMAN_MESSAGE_ID = NERR_BASE;
+enum MAX_LANMAN_MESSAGE_ID = 5799;
+
+enum CNLEN        = 15; /* also in nddeapi.h */
+enum UNCLEN       = CNLEN + 2;
+
+enum DNLEN        = 15;
+enum LM20_CNLEN   = 15;
+enum LM20_DNLEN   = 15;
+enum LM20_SNLEN   = 15;
+enum LM20_STXTLEN = 63;
+enum LM20_UNCLEN  = LM20_CNLEN + 2;
+enum LM20_NNLEN   = 12;
+enum LM20_RMLEN   = LM20_UNCLEN + 1 + LM20_NNLEN;
+enum NNLEN        = 80;
+enum RMLEN        = UNCLEN + 1 + NNLEN;
+enum SNLEN        = 80;
+enum STXTLEN      = 256;
+enum PATHLEN      = 256;
+enum LM20_PATHLEN = 256;
+enum DEVLEN       = 80;
+enum LM20_DEVLEN  = 8;
+enum EVLEN        = 16;
+enum UNLEN        = 256;
+enum LM20_UNLEN   = 20;
+enum GNLEN        = UNLEN;
+enum LM20_GNLEN   = LM20_UNLEN;
+enum PWLEN        = 256;
+enum LM20_PWLEN   = 14;
+enum SHPWLEN      = 8;
+enum CLTYPE_LEN   = 12;
+enum QNLEN        = NNLEN;
+enum LM20_QNLEN   = LM20_NNLEN;
+
+enum MAXCOMMENTSZ = 256;
+enum LM20_MAXCOMMENTSZ = 48;
+enum ALERTSZ      = 128;
+enum MAXDEVENTRIES = 32;// (sizeof(int)*8);
+enum NETBIOS_NAME_LEN = 16;
+enum DWORD MAX_PREFERRED_LENGTH = -1;
+enum CRYPT_KEY_LEN = 7;
+enum CRYPT_TXT_LEN = 8;
+enum ENCRYPTED_PWLEN = 16;
+enum SESSION_PWLEN = 24;
+enum SESSION_CRYPT_KLEN = 21;
+
+enum PARMNUM_ALL = 0;
+enum DWORD PARM_ERROR_UNKNOWN = -1;
+enum PARM_ERROR_NONE = 0;
+enum PARMNUM_BASE_INFOLEVEL = 1000;
+
+enum PLATFORM_ID_DOS = 300;
+enum PLATFORM_ID_OS2 = 400;
+enum PLATFORM_ID_NT  = 500;
+enum PLATFORM_ID_OSF = 600;
+enum PLATFORM_ID_VMS = 700;
+
+// this is a new typedef in W2K, but it should be harmless for earlier Windows versions.
+version (Unicode) {
+    alias LPWSTR LMSTR;
+    alias LPCWSTR LMCSTR;
+} else {
+    alias LPSTR LMSTR;
+    alias LPCSTR LMCSTR;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmerr.d b/libphobos/libdruntime/core/sys/windows/lmerr.d
new file mode 100644
index 00000000000..5af41325352
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmerr.d
@@ -0,0 +1,313 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmerr.d)
+ */
+module core.sys.windows.lmerr;
+version (Windows):
+
+import core.sys.windows.winerror;
+
+enum {
+    NERR_Success                      = 0,
+    NERR_BASE                         = 2100,
+    NERR_NetNotStarted                = NERR_BASE + 2,
+    NERR_UnknownServer,
+    NERR_ShareMem,
+    NERR_NoNetworkResource,
+    NERR_RemoteOnly,
+    NERR_DevNotRedirected,
+    NERR_ServerNotStarted             = NERR_BASE + 14,
+    NERR_ItemNotFound,
+    NERR_UnknownDevDir,
+    NERR_RedirectedPath,
+    NERR_DuplicateShare,
+    NERR_NoRoom,
+    NERR_TooManyItems                 = NERR_BASE + 21,
+    NERR_InvalidMaxUsers,
+    NERR_BufTooSmall,
+    NERR_RemoteErr                    = NERR_BASE + 27,
+    NERR_LanmanIniError               = NERR_BASE + 31,
+    NERR_NetworkError                 = NERR_BASE + 36,
+    NERR_WkstaInconsistentState,
+    NERR_WkstaNotStarted,
+    NERR_BrowserNotStarted,
+    NERR_InternalError,
+    NERR_BadTransactConfig,
+    NERR_InvalidAPI,
+    NERR_BadEventName,
+    NERR_DupNameReboot,
+    NERR_CfgCompNotFound              = NERR_BASE + 46,
+    NERR_CfgParamNotFound,
+    NERR_LineTooLong                  = NERR_BASE + 49,
+    NERR_QNotFound,
+    NERR_JobNotFound,
+    NERR_DestNotFound,
+    NERR_DestExists,
+    NERR_QExists,
+    NERR_QNoRoom,
+    NERR_JobNoRoom,
+    NERR_DestNoRoom,
+    NERR_DestIdle,
+    NERR_DestInvalidOp,
+    NERR_ProcNoRespond,
+    NERR_SpoolerNotLoaded,
+    NERR_DestInvalidState,
+    NERR_QInvalidState,
+    NERR_JobInvalidState,
+    NERR_SpoolNoMemory,
+    NERR_DriverNotFound,
+    NERR_DataTypeInvalid,
+    NERR_ProcNotFound,
+    NERR_ServiceTableLocked           = NERR_BASE + 80,
+    NERR_ServiceTableFull,
+    NERR_ServiceInstalled,
+    NERR_ServiceEntryLocked,
+    NERR_ServiceNotInstalled,
+    NERR_BadServiceName,
+    NERR_ServiceCtlTimeout,
+    NERR_ServiceCtlBusy,
+    NERR_BadServiceProgName,
+    NERR_ServiceNotCtrl,
+    NERR_ServiceKillProc,
+    NERR_ServiceCtlNotValid,
+    NERR_NotInDispatchTbl,
+    NERR_BadControlRecv,
+    NERR_ServiceNotStarting,
+    NERR_AlreadyLoggedOn              = NERR_BASE + 100,
+    NERR_NotLoggedOn,
+    NERR_BadUsername,
+    NERR_BadPassword,
+    NERR_UnableToAddName_W,
+    NERR_UnableToAddName_F,
+    NERR_UnableToDelName_W,
+    NERR_UnableToDelName_F,
+    NERR_LogonsPaused                 = NERR_BASE + 109,
+    NERR_LogonServerConflict,
+    NERR_LogonNoUserPath,
+    NERR_LogonScriptError,
+    NERR_StandaloneLogon              = NERR_BASE + 114,
+    NERR_LogonServerNotFound,
+    NERR_LogonDomainExists,
+    NERR_NonValidatedLogon,
+    NERR_ACFNotFound                  = NERR_BASE + 119,
+    NERR_GroupNotFound,
+    NERR_UserNotFound,
+    NERR_ResourceNotFound,
+    NERR_GroupExists,
+    NERR_UserExists,
+    NERR_ResourceExists,
+    NERR_NotPrimary,
+    NERR_ACFNotLoaded,
+    NERR_ACFNoRoom,
+    NERR_ACFFileIOFail,
+    NERR_ACFTooManyLists,
+    NERR_UserLogon,
+    NERR_ACFNoParent,
+    NERR_CanNotGrowSegment,
+    NERR_SpeGroupOp,
+    NERR_NotInCache,
+    NERR_UserInGroup,
+    NERR_UserNotInGroup,
+    NERR_AccountUndefined,
+    NERR_AccountExpired,
+    NERR_InvalidWorkstation,
+    NERR_InvalidLogonHours,
+    NERR_PasswordExpired,
+    NERR_PasswordCantChange,
+    NERR_PasswordHistConflict,
+    NERR_PasswordTooShort,
+    NERR_PasswordTooRecent,
+    NERR_InvalidDatabase,
+    NERR_DatabaseUpToDate,
+    NERR_SyncRequired,
+    NERR_UseNotFound,
+    NERR_BadAsgType,
+    NERR_DeviceIsShared,
+    NERR_NoComputerName               = NERR_BASE + 170,
+    NERR_MsgAlreadyStarted,
+    NERR_MsgInitFailed,
+    NERR_NameNotFound,
+    NERR_AlreadyForwarded,
+    NERR_AddForwarded,
+    NERR_AlreadyExists,
+    NERR_TooManyNames,
+    NERR_DelComputerName,
+    NERR_LocalForward,
+    NERR_GrpMsgProcessor,
+    NERR_PausedRemote,
+    NERR_BadReceive,
+    NERR_NameInUse,
+    NERR_MsgNotStarted,
+    NERR_NotLocalName,
+    NERR_NoForwardName,
+    NERR_RemoteFull,
+    NERR_NameNotForwarded,
+    NERR_TruncatedBroadcast,
+    NERR_InvalidDevice                = NERR_BASE + 194,
+    NERR_WriteFault,
+    NERR_DuplicateName                = NERR_BASE + 197,
+    NERR_DeleteLater,
+    NERR_IncompleteDel,
+    NERR_MultipleNets,
+    NERR_NetNameNotFound              = NERR_BASE + 210,
+    NERR_DeviceNotShared,
+    NERR_ClientNameNotFound,
+    NERR_FileIdNotFound               = NERR_BASE + 214,
+    NERR_ExecFailure,
+    NERR_TmpFile,
+    NERR_TooMuchData,
+    NERR_DeviceShareConflict,
+    NERR_BrowserTableIncomplete,
+    NERR_NotLocalDomain,
+    NERR_DevInvalidOpCode             = NERR_BASE + 231,
+    NERR_DevNotFound,
+    NERR_DevNotOpen,
+    NERR_BadQueueDevString,
+    NERR_BadQueuePriority,
+    NERR_NoCommDevs                   = NERR_BASE + 237,
+    NERR_QueueNotFound,
+    NERR_BadDevString                 = NERR_BASE + 240,
+    NERR_BadDev,
+    NERR_InUseBySpooler,
+    NERR_CommDevInUse,
+    NERR_InvalidComputer              = NERR_BASE + 251,
+    NERR_MaxLenExceeded               = NERR_BASE + 254,
+    NERR_BadComponent                 = NERR_BASE + 256,
+    NERR_CantType,
+    NERR_TooManyEntries               = NERR_BASE + 262,
+    NERR_ProfileFileTooBig            = NERR_BASE + 270,
+    NERR_ProfileOffset,
+    NERR_ProfileCleanup,
+    NERR_ProfileUnknownCmd,
+    NERR_ProfileLoadErr,
+    NERR_ProfileSaveErr,
+    NERR_LogOverflow                  = NERR_BASE + 277,
+    NERR_LogFileChanged,
+    NERR_LogFileCorrupt,
+    NERR_SourceIsDir,
+    NERR_BadSource,
+    NERR_BadDest,
+    NERR_DifferentServers,
+    NERR_RunSrvPaused                 = NERR_BASE + 285,
+    NERR_ErrCommRunSrv                = NERR_BASE + 289,
+    NERR_ErrorExecingGhost            = NERR_BASE + 291,
+    NERR_ShareNotFound,
+    NERR_InvalidLana                  = NERR_BASE + 300,
+    NERR_OpenFiles,
+    NERR_ActiveConns,
+    NERR_BadPasswordCore,
+    NERR_DevInUse,
+    NERR_LocalDrive,
+    NERR_AlertExists                  = NERR_BASE + 330,
+    NERR_TooManyAlerts,
+    NERR_NoSuchAlert,
+    NERR_BadRecipient,
+    NERR_AcctLimitExceeded,
+    NERR_InvalidLogSeek               = NERR_BASE + 340,
+    NERR_BadUasConfig                 = NERR_BASE + 350,
+    NERR_InvalidUASOp,
+    NERR_LastAdmin,
+    NERR_DCNotFound,
+    NERR_LogonTrackingError,
+    NERR_NetlogonNotStarted,
+    NERR_CanNotGrowUASFile,
+    NERR_TimeDiffAtDC,
+    NERR_PasswordMismatch,
+    NERR_NoSuchServer                 = NERR_BASE + 360,
+    NERR_NoSuchSession,
+    NERR_NoSuchConnection,
+    NERR_TooManyServers,
+    NERR_TooManySessions,
+    NERR_TooManyConnections,
+    NERR_TooManyFiles,
+    NERR_NoAlternateServers,
+    NERR_TryDownLevel                 = NERR_BASE + 370,
+    NERR_UPSDriverNotStarted          = NERR_BASE + 380,
+    NERR_UPSInvalidConfig,
+    NERR_UPSInvalidCommPort,
+    NERR_UPSSignalAsserted,
+    NERR_UPSShutdownFailed,
+    NERR_BadDosRetCode                = NERR_BASE + 400,
+    NERR_ProgNeedsExtraMem,
+    NERR_BadDosFunction,
+    NERR_RemoteBootFailed,
+    NERR_BadFileCheckSum,
+    NERR_NoRplBootSystem,
+    NERR_RplLoadrNetBiosErr,
+    NERR_RplLoadrDiskErr,
+    NERR_ImageParamErr,
+    NERR_TooManyImageParams,
+    NERR_NonDosFloppyUsed,
+    NERR_RplBootRestart,
+    NERR_RplSrvrCallFailed,
+    NERR_CantConnectRplSrvr,
+    NERR_CantOpenImageFile,
+    NERR_CallingRplSrvr,
+    NERR_StartingRplBoot,
+    NERR_RplBootServiceTerm,
+    NERR_RplBootStartFailed,
+    NERR_RPL_CONNECTED,
+    NERR_BrowserConfiguredToNotRun    = NERR_BASE + 450,
+    NERR_RplNoAdaptersStarted         = NERR_BASE + 510,
+    NERR_RplBadRegistry,
+    NERR_RplBadDatabase,
+    NERR_RplRplfilesShare,
+    NERR_RplNotRplServer,
+    NERR_RplCannotEnum,
+    NERR_RplWkstaInfoCorrupted,
+    NERR_RplWkstaNotFound,
+    NERR_RplWkstaNameUnavailable,
+    NERR_RplProfileInfoCorrupted,
+    NERR_RplProfileNotFound,
+    NERR_RplProfileNameUnavailable,
+    NERR_RplProfileNotEmpty,
+    NERR_RplConfigInfoCorrupted,
+    NERR_RplConfigNotFound,
+    NERR_RplAdapterInfoCorrupted,
+    NERR_RplInternal,
+    NERR_RplVendorInfoCorrupted,
+    NERR_RplBootInfoCorrupted,
+    NERR_RplWkstaNeedsUserAcct,
+    NERR_RplNeedsRPLUSERAcct,
+    NERR_RplBootNotFound,
+    NERR_RplIncompatibleProfile,
+    NERR_RplAdapterNameUnavailable,
+    NERR_RplConfigNotEmpty,
+    NERR_RplBootInUse,
+    NERR_RplBackupDatabase,
+    NERR_RplAdapterNotFound,
+    NERR_RplVendorNotFound,
+    NERR_RplVendorNameUnavailable,
+    NERR_RplBootNameUnavailable,
+    NERR_RplConfigNameUnavailable,
+    NERR_DfsInternalCorruption        = NERR_BASE + 560,
+    NERR_DfsVolumeDataCorrupt,
+    NERR_DfsNoSuchVolume,
+    NERR_DfsVolumeAlreadyExists,
+    NERR_DfsAlreadyShared,
+    NERR_DfsNoSuchShare,
+    NERR_DfsNotALeafVolume,
+    NERR_DfsLeafVolume,
+    NERR_DfsVolumeHasMultipleServers,
+    NERR_DfsCantCreateJunctionPoint,
+    NERR_DfsServerNotDfsAware,
+    NERR_DfsBadRenamePath,
+    NERR_DfsVolumeIsOffline,
+    NERR_DfsNoSuchServer,
+    NERR_DfsCyclicalName,
+    NERR_DfsNotSupportedInServerDfs,
+    NERR_DfsDuplicateService,
+    NERR_DfsCantRemoveLastServerShare,
+    NERR_DfsVolumeIsInterDfs,
+    NERR_DfsInconsistent,
+    NERR_DfsServerUpgraded,
+    NERR_DfsDataIsIdentical,
+    NERR_DfsCantRemoveDfsRoot,
+    NERR_DfsChildOrParentInDfs,
+    NERR_DfsInternalError             = NERR_BASE + 590,
+    MAX_NERR                          = NERR_BASE + 899
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmerrlog.d b/libphobos/libdruntime/core/sys/windows/lmerrlog.d
new file mode 100644
index 00000000000..8bc627e4b76
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmerrlog.d
@@ -0,0 +1,222 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmerrlog.d)
+ */
+module core.sys.windows.lmerrlog;
+version (Windows):
+
+// COMMENT: This appears to be only for Win16. All functions are deprecated.
+
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+private import core.sys.windows.lmaudit; // for LPHLOG
+
+enum ERRLOG_BASE=3100;
+enum ERRLOG2_BASE=5700;
+enum LOGFLAGS_FORWARD=0;
+enum LOGFLAGS_BACKWARD=1;
+enum LOGFLAGS_SEEK=2;
+enum NELOG_Internal_Error=ERRLOG_BASE;
+enum NELOG_Resource_Shortage=(ERRLOG_BASE+1);
+enum NELOG_Unable_To_Lock_Segment=(ERRLOG_BASE+2);
+enum NELOG_Unable_To_Unlock_Segment=(ERRLOG_BASE+3);
+enum NELOG_Uninstall_Service=(ERRLOG_BASE+4);
+enum NELOG_Init_Exec_Fail=(ERRLOG_BASE+5);
+enum NELOG_Ncb_Error=(ERRLOG_BASE+6);
+enum NELOG_Net_Not_Started=(ERRLOG_BASE+7);
+enum NELOG_Ioctl_Error=(ERRLOG_BASE+8);
+enum NELOG_System_Semaphore=(ERRLOG_BASE+9);
+enum NELOG_Init_OpenCreate_Err=(ERRLOG_BASE+10);
+enum NELOG_NetBios=(ERRLOG_BASE+11);
+enum NELOG_SMB_Illegal=(ERRLOG_BASE+12);
+enum NELOG_Service_Fail=(ERRLOG_BASE+13);
+enum NELOG_Entries_Lost=(ERRLOG_BASE+14);
+enum NELOG_Init_Seg_Overflow=(ERRLOG_BASE+20);
+enum NELOG_Srv_No_Mem_Grow=(ERRLOG_BASE+21);
+enum NELOG_Access_File_Bad=(ERRLOG_BASE+22);
+enum NELOG_Srvnet_Not_Started=(ERRLOG_BASE+23);
+enum NELOG_Init_Chardev_Err=(ERRLOG_BASE+24);
+enum NELOG_Remote_API=(ERRLOG_BASE+25);
+enum NELOG_Ncb_TooManyErr=(ERRLOG_BASE+26);
+enum NELOG_Mailslot_err=(ERRLOG_BASE+27);
+enum NELOG_ReleaseMem_Alert=(ERRLOG_BASE+28);
+enum NELOG_AT_cannot_write=(ERRLOG_BASE+29);
+enum NELOG_Cant_Make_Msg_File=(ERRLOG_BASE+30);
+enum NELOG_Exec_Netservr_NoMem=(ERRLOG_BASE+31);
+enum NELOG_Server_Lock_Failure=(ERRLOG_BASE+32);
+enum NELOG_Msg_Shutdown=(ERRLOG_BASE+40);
+enum NELOG_Msg_Sem_Shutdown=(ERRLOG_BASE+41);
+enum NELOG_Msg_Log_Err=(ERRLOG_BASE+50);
+enum NELOG_VIO_POPUP_ERR=(ERRLOG_BASE+51);
+enum NELOG_Msg_Unexpected_SMB_Type=(ERRLOG_BASE+52);
+enum NELOG_Wksta_Infoseg=(ERRLOG_BASE+60);
+enum NELOG_Wksta_Compname=(ERRLOG_BASE+61);
+enum NELOG_Wksta_BiosThreadFailure=(ERRLOG_BASE+62);
+enum NELOG_Wksta_IniSeg=(ERRLOG_BASE+63);
+enum NELOG_Wksta_HostTab_Full=(ERRLOG_BASE+64);
+enum NELOG_Wksta_Bad_Mailslot_SMB=(ERRLOG_BASE+65);
+enum NELOG_Wksta_UASInit=(ERRLOG_BASE+66);
+enum NELOG_Wksta_SSIRelogon=(ERRLOG_BASE+67);
+enum NELOG_Build_Name=(ERRLOG_BASE+70);
+enum NELOG_Name_Expansion=(ERRLOG_BASE+71);
+enum NELOG_Message_Send=(ERRLOG_BASE+72);
+enum NELOG_Mail_Slt_Err=(ERRLOG_BASE+73);
+enum NELOG_AT_cannot_read=(ERRLOG_BASE+74);
+enum NELOG_AT_sched_err=(ERRLOG_BASE+75);
+enum NELOG_AT_schedule_file_created=(ERRLOG_BASE+76);
+enum NELOG_Srvnet_NB_Open=(ERRLOG_BASE+77);
+enum NELOG_AT_Exec_Err=(ERRLOG_BASE+78);
+enum NELOG_Lazy_Write_Err=(ERRLOG_BASE+80);
+enum NELOG_HotFix=(ERRLOG_BASE+81);
+enum NELOG_HardErr_From_Server=(ERRLOG_BASE+82);
+enum NELOG_LocalSecFail1=(ERRLOG_BASE+83);
+enum NELOG_LocalSecFail2=(ERRLOG_BASE+84);
+enum NELOG_LocalSecFail3=(ERRLOG_BASE+85);
+enum NELOG_LocalSecGeneralFail=(ERRLOG_BASE+86);
+enum NELOG_NetWkSta_Internal_Error=(ERRLOG_BASE+90);
+enum NELOG_NetWkSta_No_Resource=(ERRLOG_BASE+91);
+enum NELOG_NetWkSta_SMB_Err=(ERRLOG_BASE+92);
+enum NELOG_NetWkSta_VC_Err=(ERRLOG_BASE+93);
+enum NELOG_NetWkSta_Stuck_VC_Err=(ERRLOG_BASE+94);
+enum NELOG_NetWkSta_NCB_Err=(ERRLOG_BASE+95);
+enum NELOG_NetWkSta_Write_Behind_Err=(ERRLOG_BASE+96);
+enum NELOG_NetWkSta_Reset_Err=(ERRLOG_BASE+97);
+enum NELOG_NetWkSta_Too_Many=(ERRLOG_BASE+98);
+enum NELOG_Srv_Thread_Failure=(ERRLOG_BASE+104);
+enum NELOG_Srv_Close_Failure=(ERRLOG_BASE+105);
+enum NELOG_ReplUserCurDir=(ERRLOG_BASE+106);
+enum NELOG_ReplCannotMasterDir=(ERRLOG_BASE+107);
+enum NELOG_ReplUpdateError=(ERRLOG_BASE+108);
+enum NELOG_ReplLostMaster=(ERRLOG_BASE+109);
+enum NELOG_NetlogonAuthDCFail=(ERRLOG_BASE+110);
+enum NELOG_ReplLogonFailed=(ERRLOG_BASE+111);
+enum NELOG_ReplNetErr=(ERRLOG_BASE+112);
+enum NELOG_ReplMaxFiles=(ERRLOG_BASE+113);
+enum NELOG_ReplMaxTreeDepth=(ERRLOG_BASE+114);
+enum NELOG_ReplBadMsg=(ERRLOG_BASE+115);
+enum NELOG_ReplSysErr=(ERRLOG_BASE+116);
+enum NELOG_ReplUserLoged=(ERRLOG_BASE+117);
+enum NELOG_ReplBadImport=(ERRLOG_BASE+118);
+enum NELOG_ReplBadExport=(ERRLOG_BASE+119);
+enum NELOG_ReplSignalFileErr=(ERRLOG_BASE+120);
+enum NELOG_DiskFT=(ERRLOG_BASE+121);
+enum NELOG_ReplAccessDenied=(ERRLOG_BASE+122);
+enum NELOG_NetlogonFailedPrimary=(ERRLOG_BASE+123);
+enum NELOG_NetlogonPasswdSetFailed=(ERRLOG_BASE+124);
+enum NELOG_NetlogonTrackingError=(ERRLOG_BASE+125);
+enum NELOG_NetlogonSyncError=(ERRLOG_BASE+126);
+enum NELOG_UPS_PowerOut=(ERRLOG_BASE+130);
+enum NELOG_UPS_Shutdown=(ERRLOG_BASE+131);
+enum NELOG_UPS_CmdFileError=(ERRLOG_BASE+132);
+enum NELOG_UPS_CannotOpenDriver=(ERRLOG_BASE+133);
+enum NELOG_UPS_PowerBack=(ERRLOG_BASE+134);
+enum NELOG_UPS_CmdFileConfig=(ERRLOG_BASE+135);
+enum NELOG_UPS_CmdFileExec=(ERRLOG_BASE+136);
+enum NELOG_Missing_Parameter=(ERRLOG_BASE+150);
+enum NELOG_Invalid_Config_Line=(ERRLOG_BASE+151);
+enum NELOG_Invalid_Config_File=(ERRLOG_BASE+152);
+enum NELOG_File_Changed=(ERRLOG_BASE+153);
+enum NELOG_Files_Dont_Fit=(ERRLOG_BASE+154);
+enum NELOG_Wrong_DLL_Version=(ERRLOG_BASE+155);
+enum NELOG_Error_in_DLL=(ERRLOG_BASE+156);
+enum NELOG_System_Error=(ERRLOG_BASE+157);
+enum NELOG_FT_ErrLog_Too_Large=(ERRLOG_BASE+158);
+enum NELOG_FT_Update_In_Progress=(ERRLOG_BASE+159);
+enum NELOG_OEM_Code=(ERRLOG_BASE+199);
+enum NELOG_NetlogonSSIInitError=ERRLOG2_BASE;
+enum NELOG_NetlogonFailedToUpdateTrustList=(ERRLOG2_BASE+1);
+enum NELOG_NetlogonFailedToAddRpcInterface=(ERRLOG2_BASE+2);
+enum NELOG_NetlogonFailedToReadMailslot=(ERRLOG2_BASE+3);
+enum NELOG_NetlogonFailedToRegisterSC=(ERRLOG2_BASE+4);
+enum NELOG_NetlogonChangeLogCorrupt=(ERRLOG2_BASE+5);
+enum NELOG_NetlogonFailedToCreateShare=(ERRLOG2_BASE+6);
+enum NELOG_NetlogonDownLevelLogonFailed=(ERRLOG2_BASE+7);
+enum NELOG_NetlogonDownLevelLogoffFailed=(ERRLOG2_BASE+8);
+enum NELOG_NetlogonNTLogonFailed=(ERRLOG2_BASE+9);
+enum NELOG_NetlogonNTLogoffFailed=(ERRLOG2_BASE+10);
+enum NELOG_NetlogonPartialSyncCallSuccess=(ERRLOG2_BASE+11);
+enum NELOG_NetlogonPartialSyncCallFailed=(ERRLOG2_BASE+12);
+enum NELOG_NetlogonFullSyncCallSuccess=(ERRLOG2_BASE+13);
+enum NELOG_NetlogonFullSyncCallFailed=(ERRLOG2_BASE+14);
+enum NELOG_NetlogonPartialSyncSuccess=(ERRLOG2_BASE+15);
+enum NELOG_NetlogonPartialSyncFailed=(ERRLOG2_BASE+16);
+enum NELOG_NetlogonFullSyncSuccess=(ERRLOG2_BASE+17);
+enum NELOG_NetlogonFullSyncFailed=(ERRLOG2_BASE+18);
+enum NELOG_NetlogonAuthNoDomainController=(ERRLOG2_BASE+19);
+enum NELOG_NetlogonAuthNoTrustLsaSecret=(ERRLOG2_BASE+20);
+enum NELOG_NetlogonAuthNoTrustSamAccount=(ERRLOG2_BASE+21);
+enum NELOG_NetlogonServerAuthFailed=(ERRLOG2_BASE+22);
+enum NELOG_NetlogonServerAuthNoTrustSamAccount=(ERRLOG2_BASE+23);
+enum NELOG_FailedToRegisterSC=(ERRLOG2_BASE+24);
+enum NELOG_FailedToSetServiceStatus=(ERRLOG2_BASE+25);
+enum NELOG_FailedToGetComputerName=(ERRLOG2_BASE+26);
+enum NELOG_DriverNotLoaded=(ERRLOG2_BASE+27);
+enum NELOG_NoTranportLoaded=(ERRLOG2_BASE+28);
+enum NELOG_NetlogonFailedDomainDelta=(ERRLOG2_BASE+29);
+enum NELOG_NetlogonFailedGlobalGroupDelta=(ERRLOG2_BASE+30);
+enum NELOG_NetlogonFailedLocalGroupDelta=(ERRLOG2_BASE+31);
+enum NELOG_NetlogonFailedUserDelta=(ERRLOG2_BASE+32);
+enum NELOG_NetlogonFailedPolicyDelta=(ERRLOG2_BASE+33);
+enum NELOG_NetlogonFailedTrustedDomainDelta=(ERRLOG2_BASE+34);
+enum NELOG_NetlogonFailedAccountDelta=(ERRLOG2_BASE+35);
+enum NELOG_NetlogonFailedSecretDelta=(ERRLOG2_BASE+36);
+enum NELOG_NetlogonSystemError=(ERRLOG2_BASE+37);
+enum NELOG_NetlogonDuplicateMachineAccounts=(ERRLOG2_BASE+38);
+enum NELOG_NetlogonTooManyGlobalGroups=(ERRLOG2_BASE+39);
+enum NELOG_NetlogonBrowserDriver=(ERRLOG2_BASE+40);
+enum NELOG_NetlogonAddNameFailure=(ERRLOG2_BASE+41);
+enum NELOG_RplMessages=(ERRLOG2_BASE+42);
+enum NELOG_RplXnsBoot=(ERRLOG2_BASE+43);
+enum NELOG_RplSystem=(ERRLOG2_BASE+44);
+enum NELOG_RplWkstaTimeout=(ERRLOG2_BASE+45);
+enum NELOG_RplWkstaFileOpen=(ERRLOG2_BASE+46);
+enum NELOG_RplWkstaFileRead=(ERRLOG2_BASE+47);
+enum NELOG_RplWkstaMemory=(ERRLOG2_BASE+48);
+enum NELOG_RplWkstaFileChecksum=(ERRLOG2_BASE+49);
+enum NELOG_RplWkstaFileLineCount=(ERRLOG2_BASE+50);
+enum NELOG_RplWkstaBbcFile=(ERRLOG2_BASE+51);
+enum NELOG_RplWkstaFileSize=(ERRLOG2_BASE+52);
+enum NELOG_RplWkstaInternal=(ERRLOG2_BASE+53);
+enum NELOG_RplWkstaWrongVersion=(ERRLOG2_BASE+54);
+enum NELOG_RplWkstaNetwork=(ERRLOG2_BASE+55);
+enum NELOG_RplAdapterResource=(ERRLOG2_BASE+56);
+enum NELOG_RplFileCopy=(ERRLOG2_BASE+57);
+enum NELOG_RplFileDelete=(ERRLOG2_BASE+58);
+enum NELOG_RplFilePerms=(ERRLOG2_BASE+59);
+enum NELOG_RplCheckConfigs=(ERRLOG2_BASE+60);
+enum NELOG_RplCreateProfiles=(ERRLOG2_BASE+61);
+enum NELOG_RplRegistry=(ERRLOG2_BASE+62);
+enum NELOG_RplReplaceRPLDISK=(ERRLOG2_BASE+63);
+enum NELOG_RplCheckSecurity=(ERRLOG2_BASE+64);
+enum NELOG_RplBackupDatabase=(ERRLOG2_BASE+65);
+enum NELOG_RplInitDatabase=(ERRLOG2_BASE+66);
+enum NELOG_RplRestoreDatabaseFailure=(ERRLOG2_BASE+67);
+enum NELOG_RplRestoreDatabaseSuccess=(ERRLOG2_BASE+68);
+enum NELOG_RplInitRestoredDatabase=(ERRLOG2_BASE+69);
+enum NELOG_NetlogonSessionTypeWrong=(ERRLOG2_BASE+70);
+
+struct ERROR_LOG {
+    DWORD el_len;
+    DWORD el_reserved;
+    DWORD el_time;
+    DWORD el_error;
+    LPWSTR el_name;
+    LPWSTR el_text;
+    LPBYTE el_data;
+    DWORD el_data_size;
+    DWORD el_nstrings;
+}
+alias ERROR_LOG* PERROR_LOG, LPERROR_LOG;
+
+extern (Windows) {
+    deprecated {
+        NET_API_STATUS NetErrorLogClear(LPCWSTR, LPCWSTR, LPBYTE);
+        NET_API_STATUS NetErrorLogRead(LPCWSTR, LPWSTR, LPHLOG, DWORD,
+          LPDWORD, DWORD, DWORD, LPBYTE*, DWORD, LPDWORD, LPDWORD);
+        NET_API_STATUS NetErrorLogWrite(LPBYTE, DWORD, LPCWSTR, LPBYTE,
+          DWORD, LPBYTE, DWORD, LPBYTE);
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmmsg.d b/libphobos/libdruntime/core/sys/windows/lmmsg.d
new file mode 100644
index 00000000000..7dfcde737ab
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmmsg.d
@@ -0,0 +1,43 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmmsg.d)
+ */
+module core.sys.windows.lmmsg;
+version (Windows):
+pragma(lib, "netapi32");
+
+private import core.sys.windows.lmcons, core.sys.windows.windef, core.sys.windows.w32api;
+
+static assert (_WIN32_WINNT >= 0x501,
+    "core.sys.windows.lmmsg is available only if version WindowsXP, Windows2003 "
+    "or WindowsVista is set");
+
+enum MSGNAME_NOT_FORWARDED  = 0;
+enum MSGNAME_FORWARDED_TO   = 4;
+enum MSGNAME_FORWARDED_FROM = 16;
+
+struct MSG_INFO_0 {
+    LPWSTR msgi0_name;
+}
+alias MSG_INFO_0* PMSG_INFO_0, LPMSG_INFO_0;
+
+struct MSG_INFO_1 {
+    LPWSTR msgi1_name;
+    DWORD msgi1_forward_flag;
+    LPWSTR msgi1_forward;
+}
+alias MSG_INFO_1* PMSG_INFO_1, LPMSG_INFO_1;
+
+extern (Windows) {
+    NET_API_STATUS NetMessageBufferSend(LPCWSTR, LPCWSTR, LPCWSTR, PBYTE,
+      DWORD);
+    NET_API_STATUS NetMessageNameAdd(LPCWSTR, LPCWSTR);
+    NET_API_STATUS NetMessageNameDel(LPCWSTR, LPCWSTR);
+    NET_API_STATUS NetMessageNameEnum(LPCWSTR, DWORD, PBYTE*, DWORD, PDWORD,
+      PDWORD, PDWORD);
+    NET_API_STATUS NetMessageNameGetInfo(LPCWSTR, LPCWSTR, DWORD, PBYTE*);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmremutl.d b/libphobos/libdruntime/core/sys/windows/lmremutl.d
new file mode 100644
index 00000000000..0d1229e44b7
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmremutl.d
@@ -0,0 +1,60 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmremutl.d)
+ */
+module core.sys.windows.lmremutl;
+version (Windows):
+pragma(lib, "netapi32");
+
+// D Conversion Note: DESC_CHAR is defined as TCHAR.
+
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+enum SUPPORTS_REMOTE_ADMIN_PROTOCOL =  2;
+enum SUPPORTS_RPC                   =  4;
+enum SUPPORTS_SAM_PROTOCOL          =  8;
+enum SUPPORTS_UNICODE               = 16;
+enum SUPPORTS_LOCAL                 = 32;
+enum SUPPORTS_ANY                   = 0xFFFFFFFF;
+
+enum NO_PERMISSION_REQUIRED = 1;
+enum ALLOCATE_RESPONSE      = 2;
+enum USE_SPECIFIC_TRANSPORT = 0x80000000;
+
+//[Yes] #ifndef DESC_CHAR_UNICODE
+//alias CHAR DESC_CHAR;
+//} else {
+//[No] #else
+//[No] typedef WCHAR DESC_CHAR;
+//[No] #endif
+// FIXME (D): Is this OK?
+alias TCHAR DESC_CHAR;
+
+alias DESC_CHAR* LPDESC;
+
+struct TIME_OF_DAY_INFO {
+    DWORD tod_elapsedt;
+    DWORD tod_msecs;
+    DWORD tod_hours;
+    DWORD tod_mins;
+    DWORD tod_secs;
+    DWORD tod_hunds;
+    LONG  tod_timezone;
+    DWORD tod_tinterval;
+    DWORD tod_day;
+    DWORD tod_month;
+    DWORD tod_year;
+    DWORD tod_weekday;
+}
+alias TIME_OF_DAY_INFO* PTIME_OF_DAY_INFO, LPTIME_OF_DAY_INFO;
+
+extern (Windows) {
+    NET_API_STATUS NetRemoteTOD(LPCWSTR, PBYTE*);
+    NET_API_STATUS NetRemoteComputerSupports(LPCWSTR, DWORD, PDWORD);
+    NET_API_STATUS RxRemoteApi(DWORD, LPCWSTR, LPDESC, LPDESC, LPDESC,
+      LPDESC, LPDESC, LPDESC, LPDESC, DWORD, ...);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmrepl.d b/libphobos/libdruntime/core/sys/windows/lmrepl.d
new file mode 100644
index 00000000000..7796728be08
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmrepl.d
@@ -0,0 +1,134 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmrepl.d)
+ */
+module core.sys.windows.lmrepl;
+version (Windows):
+pragma(lib, "netapi32");
+
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+enum REPL_ROLE_EXPORT=1;
+enum REPL_ROLE_IMPORT=2;
+enum REPL_ROLE_BOTH=3;
+
+enum REPL_INTERVAL_INFOLEVEL  = PARMNUM_BASE_INFOLEVEL+0;
+enum REPL_PULSE_INFOLEVEL     = PARMNUM_BASE_INFOLEVEL+1;
+enum REPL_GUARDTIME_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+2;
+enum REPL_RANDOM_INFOLEVEL    = PARMNUM_BASE_INFOLEVEL+3;
+
+enum REPL_UNLOCK_NOFORCE=0;
+enum REPL_UNLOCK_FORCE=1;
+enum REPL_STATE_OK=0;
+enum REPL_STATE_NO_MASTER=1;
+enum REPL_STATE_NO_SYNC=2;
+enum REPL_STATE_NEVER_REPLICATED=3;
+enum REPL_INTEGRITY_FILE=1;
+enum REPL_INTEGRITY_TREE=2;
+enum REPL_EXTENT_FILE=1;
+enum REPL_EXTENT_TREE=2;
+
+enum REPL_EXPORT_INTEGRITY_INFOLEVEL = PARMNUM_BASE_INFOLEVEL+0;
+enum REPL_EXPORT_EXTENT_INFOLEVEL    = PARMNUM_BASE_INFOLEVEL+1;
+
+struct REPL_INFO_0 {
+    DWORD rp0_role;
+    LPWSTR rp0_exportpath;
+    LPWSTR rp0_exportlist;
+    LPWSTR rp0_importpath;
+    LPWSTR rp0_importlist;
+    LPWSTR rp0_logonusername;
+    DWORD rp0_interval;
+    DWORD rp0_pulse;
+    DWORD rp0_guardtime;
+    DWORD rp0_random;
+}
+alias REPL_INFO_0* PREPL_INFO_0, LPREPL_INFO_0;
+
+struct REPL_INFO_1000 {
+    DWORD rp1000_interval;
+}
+alias REPL_INFO_1000* PREPL_INFO_1000, LPREPL_INFO_1000;
+
+struct REPL_INFO_1001 {
+    DWORD rp1001_pulse;
+}
+alias REPL_INFO_1001* PREPL_INFO_1001, LPREPL_INFO_1001;
+
+struct REPL_INFO_1002 {
+    DWORD rp1002_guardtime;
+}
+alias REPL_INFO_1002* PREPL_INFO_1002, LPREPL_INFO_1002;
+
+struct REPL_INFO_1003 {
+    DWORD rp1003_random;
+}
+alias REPL_INFO_1003* PREPL_INFO_1003, LPREPL_INFO_1003;
+
+struct REPL_EDIR_INFO_0 {
+    LPWSTR rped0_dirname;
+}
+alias REPL_EDIR_INFO_0* PREPL_EDIR_INFO_0, LPREPL_EDIR_INFO_0;
+
+struct REPL_EDIR_INFO_1 {
+    LPWSTR rped1_dirname;
+    DWORD rped1_integrity;
+    DWORD rped1_extent;
+}
+alias REPL_EDIR_INFO_1* PREPL_EDIR_INFO_1, LPREPL_EDIR_INFO_1;
+
+struct REPL_EDIR_INFO_2 {
+    LPWSTR rped2_dirname;
+    DWORD rped2_integrity;
+    DWORD rped2_extent;
+    DWORD rped2_lockcount;
+    DWORD rped2_locktime;
+}
+alias REPL_EDIR_INFO_2* PREPL_EDIR_INFO_2, LPREPL_EDIR_INFO_2;
+
+struct REPL_EDIR_INFO_1000 {
+    DWORD rped1000_integrity;
+}
+alias REPL_EDIR_INFO_1000* PREPL_EDIR_INFO_1000, LPREPL_EDIR_INFO_1000;
+
+struct REPL_EDIR_INFO_1001 {
+    DWORD rped1001_extent;
+}
+alias REPL_EDIR_INFO_1001* PREPL_EDIR_INFO_1001, LPREPL_EDIR_INFO_1001;
+
+struct REPL_IDIR_INFO_0 {
+    LPWSTR rpid0_dirname;
+}
+alias REPL_IDIR_INFO_0* PREPL_IDIR_INFO_0, LPREPL_IDIR_INFO_0;
+
+struct REPL_IDIR_INFO_1 {
+    LPWSTR rpid1_dirname;
+    DWORD rpid1_state;
+    LPWSTR rpid1_mastername;
+    DWORD rpid1_last_update_time;
+    DWORD rpid1_lockcount;
+    DWORD rpid1_locktime;
+}
+alias REPL_IDIR_INFO_1* PREPL_IDIR_INFO_1, LPREPL_IDIR_INFO_1;
+
+extern (Windows) {
+NET_API_STATUS NetReplGetInfo(LPCWSTR,DWORD,PBYTE*);
+NET_API_STATUS NetReplSetInfo(LPCWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetReplExportDirAdd(LPCWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetReplExportDirDel(LPCWSTR,LPCWSTR);
+NET_API_STATUS NetReplExportDirEnum(LPCWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+NET_API_STATUS NetReplExportDirGetInfo(LPCWSTR,LPCWSTR,DWORD,PBYTE*);
+NET_API_STATUS NetReplExportDirSetInfo(LPCWSTR,LPCWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetReplExportDirLock(LPCWSTR,LPCWSTR);
+NET_API_STATUS NetReplExportDirUnlock(LPCWSTR,LPCWSTR,DWORD);
+NET_API_STATUS NetReplImportDirAdd(LPCWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetReplImportDirDel(LPCWSTR,LPCWSTR);
+NET_API_STATUS NetReplImportDirEnum(LPCWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+NET_API_STATUS NetReplImportDirGetInfo(LPCWSTR,LPCWSTR,DWORD,PBYTE*);
+NET_API_STATUS NetReplImportDirLock(LPCWSTR,LPCWSTR);
+NET_API_STATUS NetReplImportDirUnlock(LPCWSTR,LPCWSTR,DWORD);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmserver.d b/libphobos/libdruntime/core/sys/windows/lmserver.d
new file mode 100644
index 00000000000..f27c7efdba9
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmserver.d
@@ -0,0 +1,941 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmserver.d)
+ */
+module core.sys.windows.lmserver;
+version (Windows):
+
+import core.sys.windows.winsvc;
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+struct SERVER_INFO_100 {
+    DWORD  sv100_platform_id;
+    LPWSTR sv100_name;
+}
+alias SERVER_INFO_100* PSERVER_INFO_100, LPSERVER_INFO_100;
+
+struct SERVER_INFO_101 {
+    DWORD  sv101_platform_id;
+    LPWSTR sv101_name;
+    DWORD  sv101_version_major;
+    DWORD  sv101_version_minor;
+    DWORD  sv101_type;
+    LPWSTR sv101_comment;
+}
+alias SERVER_INFO_101* PSERVER_INFO_101, LPSERVER_INFO_101;
+
+struct SERVER_INFO_102 {
+    DWORD  sv102_platform_id;
+    LPWSTR sv102_name;
+    DWORD  sv102_version_major;
+    DWORD  sv102_version_minor;
+    DWORD  sv102_type;
+    LPWSTR sv102_comment;
+    DWORD  sv102_users;
+    LONG   sv102_disc;
+    BOOL   sv102_hidden;
+    DWORD  sv102_announce;
+    DWORD  sv102_anndelta;
+    DWORD  sv102_licenses;
+    LPWSTR sv102_userpath;
+}
+alias SERVER_INFO_102* PSERVER_INFO_102, LPSERVER_INFO_102;
+
+struct SERVER_INFO_402 {
+    DWORD  sv402_ulist_mtime;
+    DWORD  sv402_glist_mtime;
+    DWORD  sv402_alist_mtime;
+    LPWSTR sv402_alerts;
+    DWORD  sv402_security;
+    DWORD  sv402_numadmin;
+    DWORD  sv402_lanmask;
+    LPWSTR sv402_guestacct;
+    DWORD  sv402_chdevs;
+    DWORD  sv402_chdevq;
+    DWORD  sv402_chdevjobs;
+    DWORD  sv402_connections;
+    DWORD  sv402_shares;
+    DWORD  sv402_openfiles;
+    DWORD  sv402_sessopens;
+    DWORD  sv402_sessvcs;
+    DWORD  sv402_sessreqs;
+    DWORD  sv402_opensearch;
+    DWORD  sv402_activelocks;
+    DWORD  sv402_numreqbuf;
+    DWORD  sv402_sizreqbuf;
+    DWORD  sv402_numbigbuf;
+    DWORD  sv402_numfiletasks;
+    DWORD  sv402_alertsched;
+    DWORD  sv402_erroralert;
+    DWORD  sv402_logonalert;
+    DWORD  sv402_accessalert;
+    DWORD  sv402_diskalert;
+    DWORD  sv402_netioalert;
+    DWORD  sv402_maxauditsz;
+    LPWSTR sv402_srvheuristics;
+}
+alias SERVER_INFO_402* PSERVER_INFO_402, LPSERVER_INFO_402;
+
+struct SERVER_INFO_403 {
+    DWORD  sv403_ulist_mtime;
+    DWORD  sv403_glist_mtime;
+    DWORD  sv403_alist_mtime;
+    LPWSTR sv403_alerts;
+    DWORD  sv403_security;
+    DWORD  sv403_numadmin;
+    DWORD  sv403_lanmask;
+    LPWSTR sv403_guestacct;
+    DWORD  sv403_chdevs;
+    DWORD  sv403_chdevq;
+    DWORD  sv403_chdevjobs;
+    DWORD  sv403_connections;
+    DWORD  sv403_shares;
+    DWORD  sv403_openfiles;
+    DWORD  sv403_sessopens;
+    DWORD  sv403_sessvcs;
+    DWORD  sv403_sessreqs;
+    DWORD  sv403_opensearch;
+    DWORD  sv403_activelocks;
+    DWORD  sv403_numreqbuf;
+    DWORD  sv403_sizreqbuf;
+    DWORD  sv403_numbigbuf;
+    DWORD  sv403_numfiletasks;
+    DWORD  sv403_alertsched;
+    DWORD  sv403_erroralert;
+    DWORD  sv403_logonalert;
+    DWORD  sv403_accessalert;
+    DWORD  sv403_diskalert;
+    DWORD  sv403_netioalert;
+    DWORD  sv403_maxauditsz;
+    LPWSTR sv403_srvheuristics;
+    DWORD  sv403_auditedevents;
+    DWORD  sv403_autoprofile;
+    LPWSTR sv403_autopath;
+}
+alias SERVER_INFO_403* PSERVER_INFO_403, LPSERVER_INFO_403;
+
+struct SERVER_INFO_502 {
+    DWORD sv502_sessopens;
+    DWORD sv502_sessvcs;
+    DWORD sv502_opensearch;
+    DWORD sv502_sizreqbuf;
+    DWORD sv502_initworkitems;
+    DWORD sv502_maxworkitems;
+    DWORD sv502_rawworkitems;
+    DWORD sv502_irpstacksize;
+    DWORD sv502_maxrawbuflen;
+    DWORD sv502_sessusers;
+    DWORD sv502_sessconns;
+    DWORD sv502_maxpagedmemoryusage;
+    DWORD sv502_maxnonpagedmemoryusage;
+    BOOL  sv502_enablesoftcompat;
+    BOOL  sv502_enableforcedlogoff;
+    BOOL  sv502_timesource;
+    BOOL  sv502_acceptdownlevelapis;
+    BOOL  sv502_lmannounce;
+}
+alias SERVER_INFO_502* PSERVER_INFO_502, LPSERVER_INFO_502;
+
+struct SERVER_INFO_503 {
+    DWORD  sv503_sessopens;
+    DWORD  sv503_sessvcs;
+    DWORD  sv503_opensearch;
+    DWORD  sv503_sizreqbuf;
+    DWORD  sv503_initworkitems;
+    DWORD  sv503_maxworkitems;
+    DWORD  sv503_rawworkitems;
+    DWORD  sv503_irpstacksize;
+    DWORD  sv503_maxrawbuflen;
+    DWORD  sv503_sessusers;
+    DWORD  sv503_sessconns;
+    DWORD  sv503_maxpagedmemoryusage;
+    DWORD  sv503_maxnonpagedmemoryusage;
+    BOOL   sv503_enablesoftcompat;
+    BOOL   sv503_enableforcedlogoff;
+    BOOL   sv503_timesource;
+    BOOL   sv503_acceptdownlevelapis;
+    BOOL   sv503_lmannounce;
+    LPWSTR sv503_domain;
+    DWORD  sv503_maxcopyreadlen;
+    DWORD  sv503_maxcopywritelen;
+    DWORD  sv503_minkeepsearch;
+    DWORD  sv503_maxkeepsearch;
+    DWORD  sv503_minkeepcomplsearch;
+    DWORD  sv503_maxkeepcomplsearch;
+    DWORD  sv503_threadcountadd;
+    DWORD  sv503_numblockthreads;
+    DWORD  sv503_scavtimeout;
+    DWORD  sv503_minrcvqueue;
+    DWORD  sv503_minfreeworkitems;
+    DWORD  sv503_xactmemsize;
+    DWORD  sv503_threadpriority;
+    DWORD  sv503_maxmpxct;
+    DWORD  sv503_oplockbreakwait;
+    DWORD  sv503_oplockbreakresponsewait;
+    BOOL   sv503_enableoplocks;
+    BOOL   sv503_enableoplockforceclose;
+    BOOL   sv503_enablefcbopens;
+    BOOL   sv503_enableraw;
+    BOOL   sv503_enablesharednetdrives;
+    DWORD  sv503_minfreeconnections;
+    DWORD  sv503_maxfreeconnections;
+}
+alias SERVER_INFO_503* PSERVER_INFO_503, LPSERVER_INFO_503;
+
+struct SERVER_INFO_599 {
+    DWORD  sv599_sessopens;
+    DWORD  sv599_sessvcs;
+    DWORD  sv599_opensearch;
+    DWORD  sv599_sizreqbuf;
+    DWORD  sv599_initworkitems;
+    DWORD  sv599_maxworkitems;
+    DWORD  sv599_rawworkitems;
+    DWORD  sv599_irpstacksize;
+    DWORD  sv599_maxrawbuflen;
+    DWORD  sv599_sessusers;
+    DWORD  sv599_sessconns;
+    DWORD  sv599_maxpagedmemoryusage;
+    DWORD  sv599_maxnonpagedmemoryusage;
+    BOOL   sv599_enablesoftcompat;
+    BOOL   sv599_enableforcedlogoff;
+    BOOL   sv599_timesource;
+    BOOL   sv599_acceptdownlevelapis;
+    BOOL   sv599_lmannounce;
+    LPWSTR sv599_domain;
+    DWORD  sv599_maxcopyreadlen;
+    DWORD  sv599_maxcopywritelen;
+    DWORD  sv599_minkeepsearch;
+    DWORD  sv599_maxkeepsearch;
+    DWORD  sv599_minkeepcomplsearch;
+    DWORD  sv599_maxkeepcomplsearch;
+    DWORD  sv599_threadcountadd;
+    DWORD  sv599_numblockthreads;
+    DWORD  sv599_scavtimeout;
+    DWORD  sv599_minrcvqueue;
+    DWORD  sv599_minfreeworkitems;
+    DWORD  sv599_xactmemsize;
+    DWORD  sv599_threadpriority;
+    DWORD  sv599_maxmpxct;
+    DWORD  sv599_oplockbreakwait;
+    DWORD  sv599_oplockbreakresponsewait;
+    BOOL   sv599_enableoplocks;
+    BOOL   sv599_enableoplockforceclose;
+    BOOL   sv599_enablefcbopens;
+    BOOL   sv599_enableraw;
+    BOOL   sv599_enablesharednetdrives;
+    DWORD  sv599_minfreeconnections;
+    DWORD  sv599_maxfreeconnections;
+    DWORD  sv599_initsesstable;
+    DWORD  sv599_initconntable;
+    DWORD  sv599_initfiletable;
+    DWORD  sv599_initsearchtable;
+    DWORD  sv599_alertschedule;
+    DWORD  sv599_errorthreshold;
+    DWORD  sv599_networkerrorthreshold;
+    DWORD  sv599_diskspacethreshold;
+    DWORD  sv599_reserved;
+    DWORD  sv599_maxlinkdelay;
+    DWORD  sv599_minlinkthroughput;
+    DWORD  sv599_linkinfovalidtime;
+    DWORD  sv599_scavqosinfoupdatetime;
+    DWORD  sv599_maxworkitemidletime;
+}
+alias SERVER_INFO_599* PSERVER_INFO_599, LPSERVER_INFO_599;
+
+struct SERVER_INFO_598 {
+    DWORD sv598_maxrawworkitems;
+    DWORD sv598_maxthreadsperqueue;
+    DWORD sv598_producttype;
+    DWORD sv598_serversize;
+    DWORD sv598_connectionlessautodisc;
+    DWORD sv598_sharingviolationretries;
+    DWORD sv598_sharingviolationdelay;
+    DWORD sv598_maxglobalopensearch;
+    DWORD sv598_removeduplicatesearches;
+    DWORD sv598_lockviolationoffset;
+    DWORD sv598_lockviolationdelay;
+    DWORD sv598_mdlreadswitchover;
+    DWORD sv598_cachedopenlimit;
+    DWORD sv598_otherqueueaffinity;
+    BOOL  sv598_restrictnullsessaccess;
+    BOOL  sv598_enablewfw311directipx;
+    DWORD sv598_queuesamplesecs;
+    DWORD sv598_balancecount;
+    DWORD sv598_preferredaffinity;
+    DWORD sv598_maxfreerfcbs;
+    DWORD sv598_maxfreemfcbs;
+    DWORD sv598_maxfreelfcbs;
+    DWORD sv598_maxfreepagedpoolchunks;
+    DWORD sv598_minpagedpoolchunksize;
+    DWORD sv598_maxpagedpoolchunksize;
+    BOOL  sv598_sendsfrompreferredprocessor;
+}
+alias SERVER_INFO_598* PSERVER_INFO_598, LPSERVER_INFO_598;
+
+struct SERVER_INFO_1005 {
+    LPWSTR sv1005_comment;
+}
+alias SERVER_INFO_1005* PSERVER_INFO_1005, LPSERVER_INFO_1005;
+
+struct SERVER_INFO_1107 {
+    DWORD sv1107_users;
+}
+alias SERVER_INFO_1107* PSERVER_INFO_1107, LPSERVER_INFO_1107;
+
+struct SERVER_INFO_1010 {
+    LONG sv1010_disc;
+}
+alias SERVER_INFO_1010* PSERVER_INFO_1010, LPSERVER_INFO_1010;
+
+struct SERVER_INFO_1016 {
+    BOOL sv1016_hidden;
+}
+alias SERVER_INFO_1016* PSERVER_INFO_1016, LPSERVER_INFO_1016;
+
+struct SERVER_INFO_1017 {
+    DWORD sv1017_announce;
+}
+alias SERVER_INFO_1017* PSERVER_INFO_1017, LPSERVER_INFO_1017;
+
+struct SERVER_INFO_1018 {
+    DWORD sv1018_anndelta;
+}
+alias SERVER_INFO_1018* PSERVER_INFO_1018, LPSERVER_INFO_1018;
+
+struct SERVER_INFO_1501 {
+    DWORD sv1501_sessopens;
+}
+alias SERVER_INFO_1501* PSERVER_INFO_1501, LPSERVER_INFO_1501;
+
+struct SERVER_INFO_1502 {
+    DWORD sv1502_sessvcs;
+}
+alias SERVER_INFO_1502* PSERVER_INFO_1502, LPSERVER_INFO_1502;
+
+struct SERVER_INFO_1503 {
+    DWORD sv1503_opensearch;
+}
+alias SERVER_INFO_1503* PSERVER_INFO_1503, LPSERVER_INFO_1503;
+
+struct SERVER_INFO_1506 {
+    DWORD sv1506_maxworkitems;
+}
+alias SERVER_INFO_1506* PSERVER_INFO_1506, LPSERVER_INFO_1506;
+
+struct SERVER_INFO_1509 {
+    DWORD sv1509_maxrawbuflen;
+}
+alias SERVER_INFO_1509* PSERVER_INFO_1509, LPSERVER_INFO_1509;
+
+struct SERVER_INFO_1510 {
+    DWORD sv1510_sessusers;
+}
+alias SERVER_INFO_1510* PSERVER_INFO_1510, LPSERVER_INFO_1510;
+
+struct SERVER_INFO_1511 {
+    DWORD sv1511_sessconns;
+} alias SERVER_INFO_1511* PSERVER_INFO_1511, LPSERVER_INFO_1511;
+
+struct SERVER_INFO_1512 {
+    DWORD sv1512_maxnonpagedmemoryusage;
+}
+alias SERVER_INFO_1512* PSERVER_INFO_1512, LPSERVER_INFO_1512;
+
+struct SERVER_INFO_1513 {
+    DWORD sv1513_maxpagedmemoryusage;
+}
+alias SERVER_INFO_1513* PSERVER_INFO_1513, LPSERVER_INFO_1513;
+
+struct SERVER_INFO_1514 {
+    BOOL sv1514_enablesoftcompat;
+}
+alias SERVER_INFO_1514* PSERVER_INFO_1514, LPSERVER_INFO_1514;
+
+struct SERVER_INFO_1515 {
+    BOOL sv1515_enableforcedlogoff;
+}
+alias SERVER_INFO_1515* PSERVER_INFO_1515, LPSERVER_INFO_1515;
+
+struct SERVER_INFO_1516 {
+    BOOL sv1516_timesource;
+}
+alias SERVER_INFO_1516* PSERVER_INFO_1516, LPSERVER_INFO_1516;
+
+struct SERVER_INFO_1518 {
+    BOOL sv1518_lmannounce;
+}
+alias SERVER_INFO_1518* PSERVER_INFO_1518, LPSERVER_INFO_1518;
+
+struct SERVER_INFO_1520 {
+    DWORD sv1520_maxcopyreadlen;
+}
+alias SERVER_INFO_1520* PSERVER_INFO_1520, LPSERVER_INFO_1520;
+
+struct SERVER_INFO_1521 {
+    DWORD sv1521_maxcopywritelen;
+}
+alias SERVER_INFO_1521* PSERVER_INFO_1521, LPSERVER_INFO_1521;
+
+struct SERVER_INFO_1522 {
+    DWORD sv1522_minkeepsearch;
+}
+alias SERVER_INFO_1522* PSERVER_INFO_1522, LPSERVER_INFO_1522;
+
+struct SERVER_INFO_1523 {
+    DWORD sv1523_maxkeepsearch;
+}
+alias SERVER_INFO_1523* PSERVER_INFO_1523, LPSERVER_INFO_1523;
+
+struct SERVER_INFO_1524 {
+    DWORD sv1524_minkeepcomplsearch;
+}
+alias SERVER_INFO_1524* PSERVER_INFO_1524, LPSERVER_INFO_1524;
+
+struct SERVER_INFO_1525 {
+    DWORD sv1525_maxkeepcomplsearch;
+}
+alias SERVER_INFO_1525* PSERVER_INFO_1525, LPSERVER_INFO_1525;
+
+struct SERVER_INFO_1528 {
+    DWORD sv1528_scavtimeout;
+}
+alias SERVER_INFO_1528* PSERVER_INFO_1528, LPSERVER_INFO_1528;
+
+struct SERVER_INFO_1529 {
+    DWORD sv1529_minrcvqueue;
+}
+alias SERVER_INFO_1529* PSERVER_INFO_1529, LPSERVER_INFO_1529;
+
+struct SERVER_INFO_1530 {
+    DWORD sv1530_minfreeworkitems;
+}
+alias SERVER_INFO_1530* PSERVER_INFO_1530, LPSERVER_INFO_1530;
+
+struct SERVER_INFO_1533 {
+    DWORD sv1533_maxmpxct;
+}
+alias SERVER_INFO_1533* PSERVER_INFO_1533, LPSERVER_INFO_1533;
+
+struct SERVER_INFO_1534 {
+    DWORD sv1534_oplockbreakwait;
+}
+alias SERVER_INFO_1534* PSERVER_INFO_1534, LPSERVER_INFO_1534;
+
+struct SERVER_INFO_1535 {
+    DWORD sv1535_oplockbreakresponsewait;
+}
+alias SERVER_INFO_1535* PSERVER_INFO_1535, LPSERVER_INFO_1535;
+
+struct SERVER_INFO_1536 {
+    BOOL sv1536_enableoplocks;
+}
+alias SERVER_INFO_1536* PSERVER_INFO_1536, LPSERVER_INFO_1536;
+
+struct SERVER_INFO_1537 {
+    BOOL sv1537_enableoplockforceclose;
+}
+alias SERVER_INFO_1537* PSERVER_INFO_1537, LPSERVER_INFO_1537;
+
+struct SERVER_INFO_1538 {
+    BOOL sv1538_enablefcbopens;
+}
+alias SERVER_INFO_1538* PSERVER_INFO_1538, LPSERVER_INFO_1538;
+
+struct SERVER_INFO_1539 {
+    BOOL sv1539_enableraw;
+}
+alias SERVER_INFO_1539* PSERVER_INFO_1539, LPSERVER_INFO_1539;
+
+struct SERVER_INFO_1540 {
+    BOOL sv1540_enablesharednetdrives;
+}
+alias SERVER_INFO_1540* PSERVER_INFO_1540, LPSERVER_INFO_1540;
+
+struct SERVER_INFO_1541 {
+    BOOL sv1541_minfreeconnections;
+}
+alias SERVER_INFO_1541* PSERVER_INFO_1541, LPSERVER_INFO_1541;
+
+struct SERVER_INFO_1542 {
+    BOOL sv1542_maxfreeconnections;
+}
+alias SERVER_INFO_1542* PSERVER_INFO_1542, LPSERVER_INFO_1542;
+
+struct SERVER_INFO_1543 {
+    DWORD sv1543_initsesstable;
+}
+alias SERVER_INFO_1543* PSERVER_INFO_1543, LPSERVER_INFO_1543;
+
+struct SERVER_INFO_1544 {
+    DWORD sv1544_initconntable;
+}
+alias SERVER_INFO_1544* PSERVER_INFO_1544, LPSERVER_INFO_1544;
+
+struct SERVER_INFO_1545 {
+    DWORD sv1545_initfiletable;
+}
+alias SERVER_INFO_1545* PSERVER_INFO_1545, LPSERVER_INFO_1545;
+
+struct SERVER_INFO_1546 {
+    DWORD sv1546_initsearchtable;
+}
+alias SERVER_INFO_1546* PSERVER_INFO_1546, LPSERVER_INFO_1546;
+
+struct SERVER_INFO_1547 {
+    DWORD sv1547_alertschedule;
+}
+alias SERVER_INFO_1547* PSERVER_INFO_1547, LPSERVER_INFO_1547;
+
+struct SERVER_INFO_1548 {
+    DWORD sv1548_errorthreshold;
+}
+alias SERVER_INFO_1548* PSERVER_INFO_1548, LPSERVER_INFO_1548;
+
+struct SERVER_INFO_1549 {
+    DWORD sv1549_networkerrorthreshold;
+}
+alias SERVER_INFO_1549* PSERVER_INFO_1549, LPSERVER_INFO_1549;
+
+struct SERVER_INFO_1550 {
+    DWORD sv1550_diskspacethreshold;
+}
+alias SERVER_INFO_1550* PSERVER_INFO_1550, LPSERVER_INFO_1550;
+
+struct SERVER_INFO_1552 {
+    DWORD sv1552_maxlinkdelay;
+}
+alias SERVER_INFO_1552* PSERVER_INFO_1552, LPSERVER_INFO_1552;
+
+struct SERVER_INFO_1553 {
+    DWORD sv1553_minlinkthroughput;
+}
+alias SERVER_INFO_1553* PSERVER_INFO_1553, LPSERVER_INFO_1553;
+
+struct SERVER_INFO_1554 {
+    DWORD sv1554_linkinfovalidtime;
+}
+alias SERVER_INFO_1554* PSERVER_INFO_1554, LPSERVER_INFO_1554;
+
+struct SERVER_INFO_1555 {
+    DWORD sv1555_scavqosinfoupdatetime;
+}
+alias SERVER_INFO_1555* PSERVER_INFO_1555, LPSERVER_INFO_1555;
+
+struct SERVER_INFO_1556 {
+    DWORD sv1556_maxworkitemidletime;
+}
+alias SERVER_INFO_1556* PSERVER_INFO_1556, LPSERVER_INFO_1556;
+
+struct SERVER_INFO_1557 {
+    DWORD sv1557_maxrawworkitems;
+}
+alias SERVER_INFO_1557* PSERVER_INFO_1557, LPSERVER_INFO_1557;
+
+struct SERVER_INFO_1560 {
+    DWORD sv1560_producttype;
+}
+alias SERVER_INFO_1560* PSERVER_INFO_1560, LPSERVER_INFO_1560;
+
+struct SERVER_INFO_1561 {
+    DWORD sv1561_serversize;
+}
+alias SERVER_INFO_1561* PSERVER_INFO_1561, LPSERVER_INFO_1561;
+
+struct SERVER_INFO_1562 {
+    DWORD sv1562_connectionlessautodisc;
+}
+alias SERVER_INFO_1562* PSERVER_INFO_1562, LPSERVER_INFO_1562;
+
+struct SERVER_INFO_1563 {
+    DWORD sv1563_sharingviolationretries;
+}
+alias SERVER_INFO_1563* PSERVER_INFO_1563, LPSERVER_INFO_1563;
+
+struct SERVER_INFO_1564 {
+    DWORD sv1564_sharingviolationdelay;
+}
+alias SERVER_INFO_1564* PSERVER_INFO_1564, LPSERVER_INFO_1564;
+
+struct SERVER_INFO_1565 {
+    DWORD sv1565_maxglobalopensearch;
+}
+alias SERVER_INFO_1565* PSERVER_INFO_1565, LPSERVER_INFO_1565;
+
+struct SERVER_INFO_1566 {
+    BOOL sv1566_removeduplicatesearches;
+}
+alias SERVER_INFO_1566* PSERVER_INFO_1566, LPSERVER_INFO_1566;
+
+struct SERVER_INFO_1567 {
+    DWORD sv1567_lockviolationretries;
+}
+alias SERVER_INFO_1567* PSERVER_INFO_1567, LPSERVER_INFO_1567;
+
+struct SERVER_INFO_1568 {
+    DWORD sv1568_lockviolationoffset;
+}
+alias SERVER_INFO_1568* PSERVER_INFO_1568, LPSERVER_INFO_1568;
+
+struct SERVER_INFO_1569 {
+    DWORD sv1569_lockviolationdelay;
+}
+alias SERVER_INFO_1569* PSERVER_INFO_1569, LPSERVER_INFO_1569;
+
+struct SERVER_INFO_1570 {
+    DWORD sv1570_mdlreadswitchover;
+}
+alias SERVER_INFO_1570* PSERVER_INFO_1570, LPSERVER_INFO_1570;
+
+struct SERVER_INFO_1571 {
+    DWORD sv1571_cachedopenlimit;
+}
+alias SERVER_INFO_1571* PSERVER_INFO_1571, LPSERVER_INFO_1571;
+
+struct SERVER_INFO_1572 {
+    DWORD sv1572_criticalthreads;
+}
+alias SERVER_INFO_1572* PSERVER_INFO_1572, LPSERVER_INFO_1572;
+
+struct SERVER_INFO_1573 {
+    DWORD sv1573_restrictnullsessaccess;
+}
+alias SERVER_INFO_1573* PSERVER_INFO_1573, LPSERVER_INFO_1573;
+
+struct SERVER_INFO_1574 {
+    DWORD sv1574_enablewfw311directipx;
+}
+alias SERVER_INFO_1574* PSERVER_INFO_1574, LPSERVER_INFO_1574;
+
+struct SERVER_INFO_1575 {
+    DWORD sv1575_otherqueueaffinity;
+}
+alias SERVER_INFO_1575* PSERVER_INFO_1575, LPSERVER_INFO_1575;
+
+struct SERVER_INFO_1576 {
+    DWORD sv1576_queuesamplesecs;
+}
+alias SERVER_INFO_1576* PSERVER_INFO_1576, LPSERVER_INFO_1576;
+
+struct SERVER_INFO_1577 {
+    DWORD sv1577_balancecount;
+}
+alias SERVER_INFO_1577* PSERVER_INFO_1577, LPSERVER_INFO_1577;
+
+struct SERVER_INFO_1578 {
+    DWORD sv1578_preferredaffinity;
+}
+alias SERVER_INFO_1578* PSERVER_INFO_1578, LPSERVER_INFO_1578;
+
+struct SERVER_INFO_1579 {
+    DWORD sv1579_maxfreerfcbs;
+}
+alias SERVER_INFO_1579* PSERVER_INFO_1579, LPSERVER_INFO_1579;
+
+struct SERVER_INFO_1580 {
+    DWORD sv1580_maxfreemfcbs;
+}
+alias SERVER_INFO_1580* PSERVER_INFO_1580, LPSERVER_INFO_1580;
+
+struct SERVER_INFO_1581 {
+    DWORD sv1581_maxfreemlcbs;
+}
+alias SERVER_INFO_1581* PSERVER_INFO_1581, LPSERVER_INFO_1581;
+
+struct SERVER_INFO_1582 {
+    DWORD sv1582_maxfreepagedpoolchunks;
+}
+alias SERVER_INFO_1582* PSERVER_INFO_1582, LPSERVER_INFO_1582;
+
+struct SERVER_INFO_1583 {
+    DWORD sv1583_minpagedpoolchunksize;
+}
+alias SERVER_INFO_1583* PSERVER_INFO_1583, LPSERVER_INFO_1583;
+
+struct SERVER_INFO_1584 {
+    DWORD sv1584_maxpagedpoolchunksize;
+}
+alias SERVER_INFO_1584* PSERVER_INFO_1584, LPSERVER_INFO_1584;
+
+struct SERVER_INFO_1585 {
+    BOOL sv1585_sendsfrompreferredprocessor;
+}
+alias SERVER_INFO_1585* PSERVER_INFO_1585, LPSERVER_INFO_1585;
+
+struct SERVER_INFO_1586 {
+    BOOL sv1586_maxthreadsperqueue;
+}
+alias SERVER_INFO_1586* PSERVER_INFO_1586, LPSERVER_INFO_1586;
+
+struct SERVER_TRANSPORT_INFO_0 {
+    DWORD  svti0_numberofvcs;
+    LPWSTR svti0_transportname;
+    PBYTE  svti0_transportaddress;
+    DWORD  svti0_transportaddresslength;
+    LPWSTR svti0_networkaddress;
+}
+alias SERVER_TRANSPORT_INFO_0* PSERVER_TRANSPORT_INFO_0,
+  LPSERVER_TRANSPORT_INFO_0;
+
+extern (Windows):
+NET_API_STATUS NetServerEnum(LPCWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,DWORD,LPCWSTR,PDWORD);
+NET_API_STATUS NetServerEnumEx(LPCWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,DWORD,LPCWSTR,LPCWSTR);
+NET_API_STATUS NetServerGetInfo(LPWSTR,DWORD,PBYTE*);
+NET_API_STATUS NetServerSetInfo(LPWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetServerSetInfoCommandLine(WORD,LPWSTR*);
+NET_API_STATUS NetServerDiskEnum(LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+NET_API_STATUS NetServerComputerNameAdd(LPWSTR,LPWSTR,LPWSTR);
+NET_API_STATUS NetServerComputerNameDel(LPWSTR,LPWSTR);
+NET_API_STATUS NetServerTransportAdd(LPWSTR,DWORD,PBYTE);
+NET_API_STATUS NetServerTransportAddEx(LPWSTR,DWORD,PBYTE);
+NET_API_STATUS NetServerTransportDel(LPWSTR,DWORD,PBYTE);
+NET_API_STATUS NetServerTransportEnum(LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+BOOL SetServiceBits(SERVICE_STATUS_HANDLE,DWORD,BOOL,BOOL);
+
+enum SVI1_NUM_ELEMENTS=5;
+enum SVI2_NUM_ELEMENTS=40;
+enum SVI3_NUM_ELEMENTS=44;
+enum SV_MAX_CMD_LEN=PATHLEN;
+enum SW_AUTOPROF_LOAD_MASK=1;
+enum SW_AUTOPROF_SAVE_MASK=2;
+enum SV_MAX_SRV_HEUR_LEN=32;
+enum SV_USERS_PER_LICENSE=5;
+enum SV_PLATFORM_ID_OS2=400;
+enum SV_PLATFORM_ID_NT=500;
+enum MAJOR_VERSION_MASK=15;
+enum SV_TYPE_WORKSTATION=1;
+enum SV_TYPE_SERVER=2;
+enum SV_TYPE_SQLSERVER=4;
+enum SV_TYPE_DOMAIN_CTRL=8;
+enum SV_TYPE_DOMAIN_BAKCTRL=16;
+enum SV_TYPE_TIME_SOURCE=32;
+enum SV_TYPE_AFP=64;
+enum SV_TYPE_NOVELL=128;
+enum SV_TYPE_DOMAIN_MEMBER=256;
+enum SV_TYPE_PRINTQ_SERVER=512;
+enum SV_TYPE_DIALIN_SERVER=1024;
+enum SV_TYPE_XENIX_SERVER=2048;
+enum SV_TYPE_SERVER_UNIX=SV_TYPE_XENIX_SERVER;
+enum SV_TYPE_NT=4096;
+enum SV_TYPE_WFW=8192;
+enum SV_TYPE_SERVER_MFPN=16384;
+enum SV_TYPE_SERVER_NT=32768;
+enum SV_TYPE_POTENTIAL_BROWSER=65536;
+enum SV_TYPE_BACKUP_BROWSER=0x20000;
+enum SV_TYPE_MASTER_BROWSER=0x40000;
+enum SV_TYPE_DOMAIN_MASTER=0x80000;
+enum SV_TYPE_SERVER_OSF=0x100000;
+enum SV_TYPE_SERVER_VMS=0x200000;
+enum SV_TYPE_WINDOWS=0x400000;
+enum SV_TYPE_ALTERNATE_XPORT=0x20000000;
+enum SV_TYPE_LOCAL_LIST_ONLY=0x40000000;
+enum SV_TYPE_DOMAIN_ENUM=0x80000000;
+enum SV_TYPE_ALL=0xFFFFFFFF;
+enum SV_NODISC=(-1);
+enum SV_USERSECURITY=1;
+enum SV_SHARESECURITY=0;
+enum SV_HIDDEN=1;
+enum SV_VISIBLE=0;
+enum SV_PLATFORM_ID_PARMNUM=101;
+enum SV_NAME_PARMNUM=102;
+enum SV_VERSION_MAJOR_PARMNUM=103;
+enum SV_VERSION_MINOR_PARMNUM=104;
+enum SV_TYPE_PARMNUM=105;
+enum SV_COMMENT_PARMNUM=5;
+enum SV_USERS_PARMNUM=107;
+enum SV_DISC_PARMNUM=10;
+enum SV_HIDDEN_PARMNUM=16;
+enum SV_ANNOUNCE_PARMNUM=17;
+enum SV_ANNDELTA_PARMNUM=18;
+enum SV_USERPATH_PARMNUM=112;
+enum SV_ULIST_MTIME_PARMNUM=401;
+enum SV_GLIST_MTIME_PARMNUM=402;
+enum SV_ALIST_MTIME_PARMNUM=403;
+enum SV_ALERTS_PARMNUM=11;
+enum SV_SECURITY_PARMNUM=405;
+enum SV_NUMADMIN_PARMNUM=406;
+enum SV_LANMASK_PARMNUM=407;
+enum SV_GUESTACC_PARMNUM=408;
+enum SV_CHDEVQ_PARMNUM=410;
+enum SV_CHDEVJOBS_PARMNUM=411;
+enum SV_CONNECTIONS_PARMNUM=412;
+enum SV_SHARES_PARMNUM=413;
+enum SV_OPENFILES_PARMNUM=414;
+enum SV_SESSREQS_PARMNUM=417;
+enum SV_ACTIVELOCKS_PARMNUM=419;
+enum SV_NUMREQBUF_PARMNUM=420;
+enum SV_NUMBIGBUF_PARMNUM=422;
+enum SV_NUMFILETASKS_PARMNUM=423;
+enum SV_ALERTSCHED_PARMNUM=37;
+enum SV_ERRORALERT_PARMNUM=38;
+enum SV_LOGONALERT_PARMNUM=39;
+enum SV_ACCESSALERT_PARMNUM=40;
+enum SV_DISKALERT_PARMNUM=41;
+enum SV_NETIOALERT_PARMNUM=42;
+enum SV_MAXAUDITSZ_PARMNUM=43;
+enum SV_SRVHEURISTICS_PARMNUM=431;
+enum SV_SESSOPENS_PARMNUM=501;
+enum SV_SESSVCS_PARMNUM=502;
+enum SV_OPENSEARCH_PARMNUM=503;
+enum SV_SIZREQBUF_PARMNUM=504;
+enum SV_INITWORKITEMS_PARMNUM=505;
+enum SV_MAXWORKITEMS_PARMNUM=506;
+enum SV_RAWWORKITEMS_PARMNUM=507;
+enum SV_IRPSTACKSIZE_PARMNUM=508;
+enum SV_MAXRAWBUFLEN_PARMNUM=509;
+enum SV_SESSUSERS_PARMNUM=510;
+enum SV_SESSCONNS_PARMNUM=511;
+enum SV_MAXNONPAGEDMEMORYUSAGE_PARMNUM=512;
+enum SV_MAXPAGEDMEMORYUSAGE_PARMNUM=513;
+enum SV_ENABLESOFTCOMPAT_PARMNUM=514;
+enum SV_ENABLEFORCEDLOGOFF_PARMNUM=515;
+enum SV_TIMESOURCE_PARMNUM=516;
+enum SV_ACCEPTDOWNLEVELAPIS_PARMNUM=517;
+enum SV_LMANNOUNCE_PARMNUM=518;
+enum SV_DOMAIN_PARMNUM=519;
+enum SV_MAXCOPYREADLEN_PARMNUM=520;
+enum SV_MAXCOPYWRITELEN_PARMNUM=521;
+enum SV_MINKEEPSEARCH_PARMNUM=522;
+enum SV_MAXKEEPSEARCH_PARMNUM=523;
+enum SV_MINKEEPCOMPLSEARCH_PARMNUM=524;
+enum SV_MAXKEEPCOMPLSEARCH_PARMNUM=525;
+enum SV_THREADCOUNTADD_PARMNUM=526;
+enum SV_NUMBLOCKTHREADS_PARMNUM=527;
+enum SV_SCAVTIMEOUT_PARMNUM=528;
+enum SV_MINRCVQUEUE_PARMNUM=529;
+enum SV_MINFREEWORKITEMS_PARMNUM=530;
+enum SV_XACTMEMSIZE_PARMNUM=531;
+enum SV_THREADPRIORITY_PARMNUM=532;
+enum SV_MAXMPXCT_PARMNUM=533;
+enum SV_OPLOCKBREAKWAIT_PARMNUM=534;
+enum SV_OPLOCKBREAKRESPONSEWAIT_PARMNUM=535;
+enum SV_ENABLEOPLOCKS_PARMNUM=536;
+enum SV_ENABLEOPLOCKFORCECLOSE_PARMNUM=537;
+enum SV_ENABLEFCBOPENS_PARMNUM=538;
+enum SV_ENABLERAW_PARMNUM=539;
+enum SV_ENABLESHAREDNETDRIVES_PARMNUM=540;
+enum SV_MINFREECONNECTIONS_PARMNUM=541;
+enum SV_MAXFREECONNECTIONS_PARMNUM=542;
+enum SV_INITSESSTABLE_PARMNUM=543;
+enum SV_INITCONNTABLE_PARMNUM=544;
+enum SV_INITFILETABLE_PARMNUM=545;
+enum SV_INITSEARCHTABLE_PARMNUM=546;
+enum SV_ALERTSCHEDULE_PARMNUM=547;
+enum SV_ERRORTHRESHOLD_PARMNUM=548;
+enum SV_NETWORKERRORTHRESHOLD_PARMNUM=549;
+enum SV_DISKSPACETHRESHOLD_PARMNUM=550;
+enum SV_MAXLINKDELAY_PARMNUM=552;
+enum SV_MINLINKTHROUGHPUT_PARMNUM=553;
+enum SV_LINKINFOVALIDTIME_PARMNUM=554;
+enum SV_SCAVQOSINFOUPDATETIME_PARMNUM=555;
+enum SV_MAXWORKITEMIDLETIME_PARMNUM=556;
+enum SV_MAXRAWWORKITEMS_PARMNUM=557;
+enum SV_PRODUCTTYPE_PARMNUM=560;
+enum SV_SERVERSIZE_PARMNUM=561;
+enum SV_CONNECTIONLESSAUTODISC_PARMNUM=562;
+enum SV_SHARINGVIOLATIONRETRIES_PARMNUM=563;
+enum SV_SHARINGVIOLATIONDELAY_PARMNUM=564;
+enum SV_MAXGLOBALOPENSEARCH_PARMNUM=565;
+enum SV_REMOVEDUPLICATESEARCHES_PARMNUM=566;
+enum SV_LOCKVIOLATIONRETRIES_PARMNUM=567;
+enum SV_LOCKVIOLATIONOFFSET_PARMNUM=568;
+enum SV_LOCKVIOLATIONDELAY_PARMNUM=569;
+enum SV_MDLREADSWITCHOVER_PARMNUM=570;
+enum SV_CACHEDOPENLIMIT_PARMNUM=571;
+enum SV_CRITICALTHREADS_PARMNUM=572;
+enum SV_RESTRICTNULLSESSACCESS_PARMNUM=573;
+enum SV_ENABLEWFW311DIRECTIPX_PARMNUM=574;
+enum SV_OTHERQUEUEAFFINITY_PARMNUM=575;
+enum SV_QUEUESAMPLESECS_PARMNUM=576;
+enum SV_BALANCECOUNT_PARMNUM=577;
+enum SV_PREFERREDAFFINITY_PARMNUM=578;
+enum SV_MAXFREERFCBS_PARMNUM=579;
+enum SV_MAXFREEMFCBS_PARMNUM=580;
+enum SV_MAXFREELFCBS_PARMNUM=581;
+enum SV_MAXFREEPAGEDPOOLCHUNKS_PARMNUM=582;
+enum SV_MINPAGEDPOOLCHUNKSIZE_PARMNUM=583;
+enum SV_MAXPAGEDPOOLCHUNKSIZE_PARMNUM=584;
+enum SV_SENDSFROMPREFERREDPROCESSOR_PARMNUM=585;
+enum SV_MAXTHREADSPERQUEUE_PARMNUM=586;
+enum SV_COMMENT_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_COMMENT_PARMNUM);
+enum SV_USERS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_USERS_PARMNUM);
+enum SV_DISC_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_DISC_PARMNUM);
+enum SV_HIDDEN_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_HIDDEN_PARMNUM);
+enum SV_ANNOUNCE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_ANNOUNCE_PARMNUM);
+enum SV_ANNDELTA_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_ANNDELTA_PARMNUM);
+enum SV_SESSOPENS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_SESSOPENS_PARMNUM);
+enum SV_SESSVCS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_SESSVCS_PARMNUM);
+enum SV_OPENSEARCH_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_OPENSEARCH_PARMNUM);
+enum SV_MAXWORKITEMS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXWORKITEMS_PARMNUM);
+enum SV_MAXRAWBUFLEN_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXRAWBUFLEN_PARMNUM);
+enum SV_SESSUSERS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_SESSUSERS_PARMNUM);
+enum SV_SESSCONNS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_SESSCONNS_PARMNUM);
+enum SV_MAXNONPAGEDMEMORYUSAGE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXNONPAGEDMEMORYUSAGE_PARMNUM);
+enum SV_MAXPAGEDMEMORYUSAGE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXPAGEDMEMORYUSAGE_PARMNUM);
+enum SV_ENABLESOFTCOMPAT_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_ENABLESOFTCOMPAT_PARMNUM);
+enum SV_ENABLEFORCEDLOGOFF_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_ENABLEFORCEDLOGOFF_PARMNUM);
+enum SV_TIMESOURCE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_TIMESOURCE_PARMNUM);
+enum SV_LMANNOUNCE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_LMANNOUNCE_PARMNUM);
+enum SV_MAXCOPYREADLEN_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXCOPYREADLEN_PARMNUM);
+enum SV_MAXCOPYWRITELEN_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXCOPYWRITELEN_PARMNUM);
+enum SV_MINKEEPSEARCH_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MINKEEPSEARCH_PARMNUM);
+enum SV_MAXKEEPSEARCH_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXKEEPSEARCH_PARMNUM);
+enum SV_MINKEEPCOMPLSEARCH_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MINKEEPCOMPLSEARCH_PARMNUM);
+enum SV_MAXKEEPCOMPLSEARCH_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXKEEPCOMPLSEARCH_PARMNUM);
+enum SV_SCAVTIMEOUT_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_SCAVTIMEOUT_PARMNUM);
+enum SV_MINRCVQUEUE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MINRCVQUEUE_PARMNUM);
+enum SV_MINFREEWORKITEMS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MINFREEWORKITEMS_PARMNUM);
+enum SV_MAXMPXCT_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXMPXCT_PARMNUM);
+enum SV_OPLOCKBREAKWAIT_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_OPLOCKBREAKWAIT_PARMNUM);
+enum SV_OPLOCKBREAKRESPONSEWAIT_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_OPLOCKBREAKRESPONSEWAIT_PARMNUM);
+enum SV_ENABLEOPLOCKS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_ENABLEOPLOCKS_PARMNUM);
+enum SV_ENABLEOPLOCKFORCECLOSE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_ENABLEOPLOCKFORCECLOSE_PARMNUM);
+enum SV_ENABLEFCBOPENS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_ENABLEFCBOPENS_PARMNUM);
+enum SV_ENABLERAW_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_ENABLERAW_PARMNUM);
+enum SV_ENABLESHAREDNETDRIVES_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_ENABLESHAREDNETDRIVES_PARMNUM);
+enum SV_MINFREECONNECTIONS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MINFREECONNECTIONS_PARMNUM);
+enum SV_MAXFREECONNECTIONS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXFREECONNECTIONS_PARMNUM);
+enum SV_INITSESSTABLE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_INITSESSTABLE_PARMNUM);
+enum SV_INITCONNTABLE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_INITCONNTABLE_PARMNUM);
+enum SV_INITFILETABLE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_INITFILETABLE_PARMNUM);
+enum SV_INITSEARCHTABLE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_INITSEARCHTABLE_PARMNUM);
+enum SV_ALERTSCHEDULE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_ALERTSCHEDULE_PARMNUM);
+enum SV_ERRORTHRESHOLD_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_ERRORTHRESHOLD_PARMNUM);
+enum SV_NETWORKERRORTHRESHOLD_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_NETWORKERRORTHRESHOLD_PARMNUM);
+enum SV_DISKSPACETHRESHOLD_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_DISKSPACETHRESHOLD_PARMNUM);
+enum SV_MAXLINKDELAY_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXLINKDELAY_PARMNUM);
+enum SV_MINLINKTHROUGHPUT_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MINLINKTHROUGHPUT_PARMNUM);
+enum SV_LINKINFOVALIDTIME_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_LINKINFOVALIDTIME_PARMNUM);
+enum SV_SCAVQOSINFOUPDATETIME_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_SCAVQOSINFOUPDATETIME_PARMNUM);
+enum SV_MAXWORKITEMIDLETIME_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXWORKITEMIDLETIME_PARMNUM);
+enum SV_MAXRAWWORKITEMS_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXRAWWORKITEMS_PARMNUM);
+enum SV_PRODUCTTYPE_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_PRODUCTTYPE_PARMNUM);
+enum SV_SERVERSIZE_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_SERVERSIZE_PARMNUM);
+enum SV_CONNECTIONLESSAUTODISC_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_CONNECTIONLESSAUTODISC_PARMNUM);
+enum SV_SHARINGVIOLATIONRETRIES_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_SHARINGVIOLATIONRETRIES_PARMNUM);
+enum SV_SHARINGVIOLATIONDELAY_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_SHARINGVIOLATIONDELAY_PARMNUM);
+enum SV_MAXGLOBALOPENSEARCH_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXGLOBALOPENSEARCH_PARMNUM);
+enum SV_REMOVEDUPLICATESEARCHES_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_REMOVEDUPLICATESEARCHES_PARMNUM);
+enum SV_LOCKVIOLATIONRETRIES_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_LOCKVIOLATIONRETRIES_PARMNUM);
+enum SV_LOCKVIOLATIONOFFSET_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_LOCKVIOLATIONOFFSET_PARMNUM);
+enum SV_LOCKVIOLATIONDELAY_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_LOCKVIOLATIONDELAY_PARMNUM);
+enum SV_MDLREADSWITCHOVER_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MDLREADSWITCHOVER_PARMNUM);
+enum SV_CACHEDOPENLIMIT_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_CACHEDOPENLIMIT_PARMNUM);
+enum SV_CRITICALTHREADS_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_CRITICALTHREADS_PARMNUM);
+enum SV_RESTRICTNULLSESSACCESS_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_RESTRICTNULLSESSACCESS_PARMNUM);
+enum SV_ENABLEWFW311DIRECTIPX_INFOLOEVEL=(PARMNUM_BASE_INFOLEVEL+SV_ENABLEWFW311DIRECTIPX_PARMNUM);
+enum SV_OTHERQUEUEAFFINITY_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_OTHERQUEUEAFFINITY_PARMNUM);
+enum SV_QUEUESAMPLESECS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_QUEUESAMPLESECS_PARMNUM);
+enum SV_BALANCECOUNT_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_BALANCECOUNT_PARMNUM);
+enum SV_PREFERREDAFFINITY_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_PREFERREDAFFINITY_PARMNUM);
+enum SV_MAXFREERFCBS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXFREERFCBS_PARMNUM);
+enum SV_MAXFREEMFCBS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXFREEMFCBS_PARMNUM);
+enum SV_MAXFREELFCBS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXFREELFCBS_PARMNUM);
+enum SV_MAXFREEPAGEDPOOLCHUNKS_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXFREEPAGEDPOOLCHUNKS_PARMNUM);
+enum SV_MINPAGEDPOOLCHUNKSIZE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MINPAGEDPOOLCHUNKSIZE_PARMNUM);
+enum SV_MAXPAGEDPOOLCHUNKSIZE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXPAGEDPOOLCHUNKSIZE_PARMNUM);
+enum SV_SENDSFROMPREFERREDPROCESSOR_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_SENDSFROMPREFERREDPROCESSOR_PARMNUM);
+enum SV_MAXTHREADSPERQUEUE_INFOLEVEL=(PARMNUM_BASE_INFOLEVEL+SV_MAXTHREADSPERQUEUE_PARMNUM);
diff --git a/libphobos/libdruntime/core/sys/windows/lmshare.d b/libphobos/libdruntime/core/sys/windows/lmshare.d
new file mode 100644
index 00000000000..2aacc7e126c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmshare.d
@@ -0,0 +1,197 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmshare.d)
+ */
+module core.sys.windows.lmshare;
+version (Windows):
+pragma(lib, "netapi32");
+
+import core.sys.windows.lmcons;
+private import core.sys.windows.w32api, core.sys.windows.windef;
+
+
+enum SHARE_NETNAME_PARMNUM      = 1;
+enum SHARE_TYPE_PARMNUM         = 3;
+enum SHARE_REMARK_PARMNUM       = 4;
+enum SHARE_PERMISSIONS_PARMNUM  = 5;
+enum SHARE_MAX_USES_PARMNUM     = 6;
+enum SHARE_CURRENT_USES_PARMNUM = 7;
+enum SHARE_PATH_PARMNUM         = 8;
+enum SHARE_PASSWD_PARMNUM       = 9;
+enum SHARE_FILE_SD_PARMNUM      = 501;
+enum SHARE_REMARK_INFOLEVEL   = PARMNUM_BASE_INFOLEVEL + SHARE_REMARK_PARMNUM;
+enum SHARE_MAX_USES_INFOLEVEL = PARMNUM_BASE_INFOLEVEL + SHARE_MAX_USES_PARMNUM;
+enum SHARE_FILE_SD_INFOLEVEL  = PARMNUM_BASE_INFOLEVEL + SHARE_FILE_SD_PARMNUM;
+
+enum SHI1_NUM_ELEMENTS = 4;
+enum SHI2_NUM_ELEMENTS = 10;
+
+enum STYPE_DISKTREE = 0;
+enum STYPE_PRINTQ   = 1;
+enum STYPE_DEVICE   = 2;
+enum STYPE_IPC      = 3;
+enum STYPE_DFS      = 100;
+enum STYPE_SPECIAL  = 0x80000000;
+
+enum DWORD SHI_USES_UNLIMITED = -1;
+
+enum SESS_GUEST = 1;
+enum SESS_NOENCRYPTION = 2;
+enum SESI1_NUM_ELEMENTS = 8;
+enum SESI2_NUM_ELEMENTS = 9;
+
+enum PERM_FILE_READ   = 1;
+enum PERM_FILE_WRITE  = 2;
+enum PERM_FILE_CREATE = 4;
+
+struct FILE_INFO_2 {
+    DWORD fi2_id;
+}
+alias FILE_INFO_2* PFILE_INFO_2, LPFILE_INFO_2;
+
+struct FILE_INFO_3 {
+    DWORD fi3_id;
+    DWORD fi3_permissions;
+    DWORD fi3_num_locks;
+    LPTSTR fi3_pathname;
+    LPTSTR fi3_username;
+}
+alias FILE_INFO_3* PFILE_INFO_3, LPFILE_INFO_3;
+
+struct SHARE_INFO_0 {
+    LPTSTR shi0_netname;
+}
+alias SHARE_INFO_0* PSHARE_INFO_0, LPSHARE_INFO_0;
+
+struct SHARE_INFO_1 {
+    LPTSTR shi1_netname;
+    DWORD shi1_type;
+    LPTSTR shi1_remark;
+}
+alias SHARE_INFO_1* PSHARE_INFO_1, LPSHARE_INFO_1;
+
+struct SHARE_INFO_2 {
+    LPTSTR shi2_netname;
+    DWORD shi2_type;
+    LPTSTR shi2_remark;
+    DWORD shi2_permissions;
+    DWORD shi2_max_uses;
+    DWORD shi2_current_uses;
+    LPTSTR shi2_path;
+    LPTSTR shi2_passwd;
+}
+alias SHARE_INFO_2* PSHARE_INFO_2, LPSHARE_INFO_2;
+
+struct SHARE_INFO_502 {
+    LPTSTR shi502_netname;
+    DWORD shi502_type;
+    LPTSTR shi502_remark;
+    DWORD shi502_permissions;
+    DWORD shi502_max_uses;
+    DWORD shi502_current_uses;
+    LPTSTR shi502_path;
+    LPTSTR shi502_passwd;
+    DWORD shi502_reserved;
+    PSECURITY_DESCRIPTOR shi502_security_descriptor;
+}
+alias SHARE_INFO_502* PSHARE_INFO_502, LPSHARE_INFO_502;
+
+struct SHARE_INFO_1004 {
+    LPTSTR shi1004_remark;
+}
+alias SHARE_INFO_1004* PSHARE_INFO_1004, LPSHARE_INFO_1004;
+
+struct SHARE_INFO_1006 {
+    DWORD shi1006_max_uses;
+}
+alias SHARE_INFO_1006* PSHARE_INFO_1006, LPSHARE_INFO_1006;
+
+struct SHARE_INFO_1501 {
+    DWORD shi1501_reserved;
+    PSECURITY_DESCRIPTOR shi1501_security_descriptor;
+}
+alias SHARE_INFO_1501* PSHARE_INFO_1501, LPSHARE_INFO_1501;
+
+struct SESSION_INFO_0 {
+    LPWSTR sesi0_cname;
+}
+alias SESSION_INFO_0* PSESSION_INFO_0, LPSESSION_INFO_0;
+
+struct SESSION_INFO_1 {
+    LPTSTR sesi1_cname;
+    LPTSTR sesi1_username;
+    DWORD sesi1_num_opens;
+    DWORD sesi1_time;
+    DWORD sesi1_idle_time;
+    DWORD sesi1_user_flags;
+}
+alias SESSION_INFO_1* PSESSION_INFO_1, LPSESSION_INFO_1;
+
+struct SESSION_INFO_2 {
+    LPTSTR sesi2_cname;
+    LPTSTR sesi2_username;
+    DWORD sesi2_num_opens;
+    DWORD sesi2_time;
+    DWORD sesi2_idle_time;
+    DWORD sesi2_user_flags;
+    LPWSTR sesi2_cltype_name;
+}
+alias SESSION_INFO_2* PSESSION_INFO_2, LPSESSION_INFO_2;
+
+struct SESSION_INFO_10 {
+    LPWSTR sesi10_cname;
+    LPWSTR sesi10_username;
+    DWORD sesi10_time;
+    DWORD sesi10_idle_time;
+}
+alias SESSION_INFO_10* PSESSION_INFO_10, LPSESSION_INFO_10;
+
+struct SESSION_INFO_502 {
+    LPWSTR sesi502_cname;
+    LPWSTR sesi502_username;
+    DWORD sesi502_num_opens;
+    DWORD sesi502_time;
+    DWORD sesi502_idle_time;
+    DWORD sesi502_user_flags;
+    LPWSTR sesi502_cltype_name;
+    LPWSTR sesi502_transport;
+}
+alias SESSION_INFO_502* PSESSION_INFO_502, LPSESSION_INFO_502;
+
+struct CONNECTION_INFO_0 {
+    DWORD coni0_id;
+}
+alias CONNECTION_INFO_0* PCONNECTION_INFO_0, LPCONNECTION_INFO_0;
+
+struct CONNECTION_INFO_1 {
+    DWORD coni1_id;
+    DWORD coni1_type;
+    DWORD coni1_num_opens;
+    DWORD coni1_num_users;
+    DWORD coni1_time;
+    LPWSTR coni1_username;
+    LPWSTR coni1_netname;
+}
+alias CONNECTION_INFO_1* PCONNECTION_INFO_1, LPCONNECTION_INFO_1;
+
+extern (Windows) {
+NET_API_STATUS NetShareAdd(LPWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetShareEnum(LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+NET_API_STATUS NetShareEnumSticky(LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD resume_handle);
+NET_API_STATUS NetShareGetInfo(LPWSTR,LPWSTR,DWORD,PBYTE*);
+NET_API_STATUS NetShareSetInfo(LPWSTR,LPWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetShareDel(LPWSTR,LPWSTR,DWORD);
+NET_API_STATUS NetShareDelSticky(LPWSTR,LPWSTR,DWORD);
+NET_API_STATUS NetShareCheck(LPWSTR,LPWSTR,PDWORD);
+NET_API_STATUS NetSessionEnum(LPWSTR,LPWSTR,LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+NET_API_STATUS NetSessionDel(LPWSTR,LPWSTR,LPWSTR);
+NET_API_STATUS NetSessionGetInfo(LPWSTR,LPWSTR,LPWSTR,DWORD,PBYTE*);
+NET_API_STATUS NetConnectionEnum(LPWSTR,LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+NET_API_STATUS NetFileClose(LPWSTR,DWORD);
+NET_API_STATUS NetFileEnum(LPWSTR,LPWSTR,LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+NET_API_STATUS NetFileGetInfo(LPWSTR,DWORD,DWORD,PBYTE*);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmsname.d b/libphobos/libdruntime/core/sys/windows/lmsname.d
new file mode 100644
index 00000000000..01dfe030ddf
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmsname.d
@@ -0,0 +1,65 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmsname.d)
+ */
+module core.sys.windows.lmsname;
+version (Windows):
+
+private import core.sys.windows.windef;
+
+const TCHAR[]
+    SERVICE_WORKSTATION      = "LanmanWorkstation",
+    SERVICE_LM20_WORKSTATION = "WORKSTATION",
+    WORKSTATION_DISPLAY_NAME = "Workstation",
+    SERVICE_SERVER           = "LanmanServer",
+    SERVICE_LM20_SERVER      = "SERVER",
+    SERVER_DISPLAY_NAME      = "Server",
+    SERVICE_BROWSER          = "BROWSER",
+    SERVICE_LM20_BROWSER     = SERVICE_BROWSER,
+    SERVICE_MESSENGER        = "MESSENGER",
+    SERVICE_LM20_MESSENGER   = SERVICE_MESSENGER,
+    SERVICE_NETRUN           = "NETRUN",
+    SERVICE_LM20_NETRUN      = SERVICE_NETRUN,
+    SERVICE_SPOOLER          = "SPOOLER",
+    SERVICE_LM20_SPOOLER     = SERVICE_SPOOLER,
+    SERVICE_ALERTER          = "ALERTER",
+    SERVICE_LM20_ALERTER     = SERVICE_ALERTER,
+    SERVICE_NETLOGON         = "NETLOGON",
+    SERVICE_LM20_NETLOGON    = SERVICE_NETLOGON,
+    SERVICE_NETPOPUP         = "NETPOPUP",
+    SERVICE_LM20_NETPOPUP    = SERVICE_NETPOPUP,
+    SERVICE_SQLSERVER        = "SQLSERVER",
+    SERVICE_LM20_SQLSERVER   = SERVICE_SQLSERVER,
+    SERVICE_REPL             = "REPLICATOR",
+    SERVICE_LM20_REPL        = SERVICE_REPL,
+    SERVICE_RIPL             = "REMOTEBOOT",
+    SERVICE_LM20_RIPL        = SERVICE_RIPL,
+    SERVICE_TIMESOURCE       = "TIMESOURCE",
+    SERVICE_LM20_TIMESOURCE  = SERVICE_TIMESOURCE,
+    SERVICE_AFP              = "AFP",
+    SERVICE_LM20_AFP         = SERVICE_AFP,
+    SERVICE_UPS              = "UPS",
+    SERVICE_LM20_UPS         = SERVICE_UPS,
+    SERVICE_XACTSRV          = "XACTSRV",
+    SERVICE_LM20_XACTSRV     = SERVICE_XACTSRV,
+    SERVICE_TCPIP            = "TCPIP",
+    SERVICE_LM20_TCPIP       = SERVICE_TCPIP,
+    SERVICE_NBT              = "NBT",
+    SERVICE_LM20_NBT         = SERVICE_NBT,
+    SERVICE_LMHOSTS          = "LMHOSTS",
+    SERVICE_LM20_LMHOSTS     = SERVICE_LMHOSTS,
+    SERVICE_TELNET           = "Telnet",
+    SERVICE_LM20_TELNET      = SERVICE_TELNET,
+    SERVICE_SCHEDULE         = "Schedule",
+    SERVICE_LM20_SCHEDULE    = SERVICE_SCHEDULE,
+    SERVICE_NTLMSSP          = "NtLmSsp",
+    SERVICE_DHCP             = "DHCP",
+    SERVICE_LM20_DHCP        = SERVICE_DHCP,
+    SERVICE_NWSAP            = "NwSapAgent",
+    SERVICE_LM20_NWSAP       = SERVICE_NWSAP,
+    NWSAP_DISPLAY_NAME       = "NW Sap Agent",
+    SERVICE_NWCS             = "NWCWorkstation";
diff --git a/libphobos/libdruntime/core/sys/windows/lmstats.d b/libphobos/libdruntime/core/sys/windows/lmstats.d
new file mode 100644
index 00000000000..084c3307bbc
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmstats.d
@@ -0,0 +1,121 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmstats.d)
+ */
+module core.sys.windows.lmstats;
+version (Windows):
+pragma(lib, "netapi32");
+
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+enum ULONG
+    STATSOPT_CLR   = 1,
+    STATS_NO_VALUE = -1,
+    STATS_OVERFLOW = -2;
+
+struct STAT_SERVER_0{
+    DWORD sts0_start;
+    DWORD sts0_fopens;
+    DWORD sts0_devopens;
+    DWORD sts0_jobsqueued;
+    DWORD sts0_sopens;
+    DWORD sts0_stimedout;
+    DWORD sts0_serrorout;
+    DWORD sts0_pwerrors;
+    DWORD sts0_permerrors;
+    DWORD sts0_syserrors;
+    DWORD sts0_bytessent_low;
+    DWORD sts0_bytessent_high;
+    DWORD sts0_bytesrcvd_low;
+    DWORD sts0_bytesrcvd_high;
+    DWORD sts0_avresponse;
+    DWORD sts0_reqbufneed;
+    DWORD sts0_bigbufneed;
+}
+alias STAT_SERVER_0* PSTAT_SERVER_0, LPSTAT_SERVER_0;
+
+// #ifdef LM20_WORKSTATION_STATISTICS
+// typedef struct _STAT_WORKSTATION_0 {
+//  DWORD stw0_start;
+//  DWORD stw0_numNCB_r;
+//  DWORD stw0_numNCB_s;
+//  DWORD stw0_numNCB_a;
+//  DWORD stw0_fiNCB_r;
+//  DWORD stw0_fiNCB_s;
+//  DWORD stw0_fiNCB_a;
+//  DWORD stw0_fcNCB_r;
+//  DWORD stw0_fcNCB_s;
+//  DWORD stw0_fcNCB_a;
+//  DWORD stw0_sesstart;
+//  DWORD stw0_sessfailcon;
+//  DWORD stw0_sessbroke;
+//  DWORD stw0_uses;
+//  DWORD stw0_usefail;
+//  DWORD stw0_autorec;
+//  DWORD stw0_bytessent_r_lo;
+//  DWORD stw0_bytessent_r_hi;
+//  DWORD stw0_bytesrcvd_r_lo;
+//  DWORD stw0_bytesrcvd_r_hi;
+//  DWORD stw0_bytessent_s_lo;
+//  DWORD stw0_bytessent_s_hi;
+//  DWORD stw0_bytesrcvd_s_lo;
+//  DWORD stw0_bytesrcvd_s_hi;
+//  DWORD stw0_bytessent_a_lo;
+//  DWORD stw0_bytessent_a_hi;
+//  DWORD stw0_bytesrcvd_a_lo;
+//  DWORD stw0_bytesrcvd_a_hi;
+//  DWORD stw0_reqbufneed;
+//  DWORD stw0_bigbufneed;
+// } STAT_WORKSTATION_0,*PSTAT_WORKSTATION_0,*LPSTAT_WORKSTATION_0;
+// #else
+
+struct STAT_WORKSTATION_0{
+    LARGE_INTEGER StatisticsStartTime;
+    LARGE_INTEGER BytesReceived;
+    LARGE_INTEGER SmbsReceived;
+    LARGE_INTEGER PagingReadBytesRequested;
+    LARGE_INTEGER NonPagingReadBytesRequested;
+    LARGE_INTEGER CacheReadBytesRequested;
+    LARGE_INTEGER NetworkReadBytesRequested;
+    LARGE_INTEGER BytesTransmitted;
+    LARGE_INTEGER SmbsTransmitted;
+    LARGE_INTEGER PagingWriteBytesRequested;
+    LARGE_INTEGER NonPagingWriteBytesRequested;
+    LARGE_INTEGER CacheWriteBytesRequested;
+    LARGE_INTEGER NetworkWriteBytesRequested;
+    DWORD InitiallyFailedOperations;
+    DWORD FailedCompletionOperations;
+    DWORD ReadOperations;
+    DWORD RandomReadOperations;
+    DWORD ReadSmbs;
+    DWORD LargeReadSmbs;
+    DWORD SmallReadSmbs;
+    DWORD WriteOperations;
+    DWORD RandomWriteOperations;
+    DWORD WriteSmbs;
+    DWORD LargeWriteSmbs;
+    DWORD SmallWriteSmbs;
+    DWORD RawReadsDenied;
+    DWORD RawWritesDenied;
+    DWORD NetworkErrors;
+    DWORD Sessions;
+    DWORD FailedSessions;
+    DWORD Reconnects;
+    DWORD CoreConnects;
+    DWORD Lanman20Connects;
+    DWORD Lanman21Connects;
+    DWORD LanmanNtConnects;
+    DWORD ServerDisconnects;
+    DWORD HungSessions;
+    DWORD UseCount;
+    DWORD FailedUseCount;
+    DWORD CurrentCommands;
+}
+alias STAT_WORKSTATION_0* PSTAT_WORKSTATION_0, LPSTAT_WORKSTATION_0;
+
+extern (Windows):
+NET_API_STATUS NetStatisticsGet(LPWSTR,LPWSTR,DWORD,DWORD,PBYTE*);
diff --git a/libphobos/libdruntime/core/sys/windows/lmsvc.d b/libphobos/libdruntime/core/sys/windows/lmsvc.d
new file mode 100644
index 00000000000..68a15920e22
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmsvc.d
@@ -0,0 +1,156 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmsvc.d)
+ */
+module core.sys.windows.lmsvc;
+version (Windows):
+
+// FIXME: Is this file deprecated? All of the functions are only for Win16.
+/**
+  Changes relative to MinGW:
+  lmsname is not imported publicly (instead, core.sys.windows.lm imports it directly).
+*/
+// TODO: 5 macros
+
+private import core.sys.windows.lmcons, core.sys.windows.lmsname, core.sys.windows.windef;
+
+const TCHAR[] SERVICE_DOS_ENCRYPTION = "ENCRYPT";
+
+enum SERVICE_UNINSTALLED=0;
+enum SERVICE_INSTALL_PENDING=1;
+enum SERVICE_UNINSTALL_PENDING=2;
+enum SERVICE_INSTALLED=3;
+enum SERVICE_INSTALL_STATE=3;
+enum SERVICE_PAUSE_STATE=18;
+enum LM20_SERVICE_ACTIVE=0;
+enum LM20_SERVICE_CONTINUE_PENDING=4;
+enum LM20_SERVICE_PAUSE_PENDING=8;
+enum LM20_SERVICE_PAUSED=18;
+enum SERVICE_NOT_UNINSTALLABLE=0;
+enum SERVICE_UNINSTALLABLE=16;
+enum SERVICE_NOT_PAUSABLE=0;
+enum SERVICE_PAUSABLE=32;
+enum SERVICE_REDIR_PAUSED=0x700;
+enum SERVICE_REDIR_DISK_PAUSED=256;
+enum SERVICE_REDIR_PRINT_PAUSED=512;
+enum SERVICE_REDIR_COMM_PAUSED=1024;
+enum SERVICE_CTRL_INTERROGATE=0;
+enum SERVICE_CTRL_PAUSE=1;
+enum SERVICE_CTRL_CONTINUE=2;
+enum SERVICE_CTRL_UNINSTALL=3;
+enum SERVICE_CTRL_REDIR_DISK=1;
+enum SERVICE_CTRL_REDIR_PRINT=2;
+enum SERVICE_CTRL_REDIR_COMM=4;
+enum SERVICE_IP_NO_HINT=0;
+enum SERVICE_CCP_NO_HINT=0;
+enum SERVICE_IP_QUERY_HINT=0x10000;
+enum SERVICE_CCP_QUERY_HINT=0x10000;
+enum SERVICE_IP_CHKPT_NUM=255;
+enum SERVICE_CCP_CHKPT_NUM=255;
+enum SERVICE_IP_WAIT_TIME=0xFF00;
+enum SERVICE_CCP_WAIT_TIME=0xFF00;
+enum SERVICE_IP_WAITTIME_SHIFT=8;
+enum SERVICE_NTIP_WAITTIME_SHIFT=12;
+enum UPPER_HINT_MASK=0xFF00;
+enum LOWER_HINT_MASK=255;
+enum UPPER_GET_HINT_MASK=0xFF00000;
+enum LOWER_GET_HINT_MASK=0xFF00;
+enum SERVICE_NT_MAXTIME=0xFFFF;
+enum SERVICE_RESRV_MASK=0x1FFFF;
+enum SERVICE_MAXTIME=255;
+enum SERVICE_BASE=3050;
+enum SERVICE_UIC_NORMAL=0;
+
+enum SERVICE_UIC_BADPARMVAL = SERVICE_BASE+1;
+enum SERVICE_UIC_MISSPARM = SERVICE_BASE+2;
+enum SERVICE_UIC_UNKPARM = SERVICE_BASE+3;
+enum SERVICE_UIC_RESOURCE = SERVICE_BASE+4;
+enum SERVICE_UIC_CONFIG = SERVICE_BASE+5;
+enum SERVICE_UIC_SYSTEM = SERVICE_BASE+6;
+enum SERVICE_UIC_INTERNAL = SERVICE_BASE+7;
+enum SERVICE_UIC_AMBIGPARM = SERVICE_BASE+8;
+enum SERVICE_UIC_DUPPARM = SERVICE_BASE+9;
+enum SERVICE_UIC_KILL = SERVICE_BASE+10;
+enum SERVICE_UIC_EXEC = SERVICE_BASE+11;
+enum SERVICE_UIC_SUBSERV = SERVICE_BASE+12;
+enum SERVICE_UIC_CONFLPARM = SERVICE_BASE+13;
+enum SERVICE_UIC_FILE = SERVICE_BASE+14;
+enum SERVICE_UIC_M_NULL=0;
+enum SERVICE_UIC_M_MEMORY = SERVICE_BASE+20;
+enum SERVICE_UIC_M_DISK = SERVICE_BASE+21;
+enum SERVICE_UIC_M_THREADS = SERVICE_BASE+22;
+enum SERVICE_UIC_M_PROCESSES = SERVICE_BASE+23;
+enum SERVICE_UIC_M_SECURITY = SERVICE_BASE+24;
+enum SERVICE_UIC_M_LANROOT = SERVICE_BASE+25;
+enum SERVICE_UIC_M_REDIR = SERVICE_BASE+26;
+enum SERVICE_UIC_M_SERVER = SERVICE_BASE+27;
+enum SERVICE_UIC_M_SEC_FILE_ERR = SERVICE_BASE+28;
+enum SERVICE_UIC_M_FILES = SERVICE_BASE+29;
+enum SERVICE_UIC_M_LOGS = SERVICE_BASE+30;
+enum SERVICE_UIC_M_LANGROUP = SERVICE_BASE+31;
+enum SERVICE_UIC_M_MSGNAME = SERVICE_BASE+32;
+enum SERVICE_UIC_M_ANNOUNCE = SERVICE_BASE+33;
+enum SERVICE_UIC_M_UAS = SERVICE_BASE+34;
+enum SERVICE_UIC_M_SERVER_SEC_ERR = SERVICE_BASE+35;
+enum SERVICE_UIC_M_WKSTA = SERVICE_BASE+37;
+enum SERVICE_UIC_M_ERRLOG = SERVICE_BASE+38;
+enum SERVICE_UIC_M_FILE_UW = SERVICE_BASE+39;
+enum SERVICE_UIC_M_ADDPAK = SERVICE_BASE+40;
+enum SERVICE_UIC_M_LAZY = SERVICE_BASE+41;
+enum SERVICE_UIC_M_UAS_MACHINE_ACCT = SERVICE_BASE+42;
+enum SERVICE_UIC_M_UAS_SERVERS_NMEMB = SERVICE_BASE+43;
+enum SERVICE_UIC_M_UAS_SERVERS_NOGRP = SERVICE_BASE+44;
+enum SERVICE_UIC_M_UAS_INVALID_ROLE = SERVICE_BASE+45;
+enum SERVICE_UIC_M_NETLOGON_NO_DC = SERVICE_BASE+46;
+enum SERVICE_UIC_M_NETLOGON_DC_CFLCT = SERVICE_BASE+47;
+enum SERVICE_UIC_M_NETLOGON_AUTH = SERVICE_BASE+48;
+enum SERVICE_UIC_M_UAS_PROLOG = SERVICE_BASE+49;
+enum SERVICE2_BASE=5600;
+enum SERVICE_UIC_M_NETLOGON_MPATH = SERVICE2_BASE+0;
+enum SERVICE_UIC_M_LSA_MACHINE_ACCT = SERVICE2_BASE+1;
+enum SERVICE_UIC_M_DATABASE_ERROR = SERVICE2_BASE+2;
+
+struct SERVICE_INFO_0 {
+    LPWSTR svci0_name;
+}
+alias SERVICE_INFO_0* PSERVICE_INFO_0, LPSERVICE_INFO_0;
+
+struct SERVICE_INFO_1 {
+    LPWSTR svci1_name;
+    DWORD svci1_status;
+    DWORD svci1_code;
+    DWORD svci1_pid;
+}
+alias SERVICE_INFO_1* PSERVICE_INFO_1, LPSERVICE_INFO_1;
+
+struct SERVICE_INFO_2 {
+    LPWSTR svci2_name;
+    DWORD svci2_status;
+    DWORD svci2_code;
+    DWORD svci2_pid;
+    LPWSTR svci2_text;
+    DWORD svci2_specific_error;
+    LPWSTR svci2_display_name;
+}
+alias SERVICE_INFO_2* PSERVICE_INFO_2, LPSERVICE_INFO_2;
+
+extern (Windows) {
+    deprecated {
+        NET_API_STATUS NetServiceControl(LPCWSTR, LPCWSTR, DWORD, DWORD,
+          PBYTE*);
+        NET_API_STATUS NetServiceEnum(LPCWSTR, DWORD, PBYTE*, DWORD, PDWORD,
+          PDWORD, PDWORD);
+        NET_API_STATUS NetServiceGetInfo(LPCWSTR, LPCWSTR, DWORD, PBYTE*);
+        NET_API_STATUS NetServiceInstall(LPCWSTR, LPCWSTR, DWORD, LPCWSTR*,
+          PBYTE*);
+    }
+}
+//MACRO #define SERVICE_IP_CODE(t, n) ((long)SERVICE_IP_QUERY_HINT|(long)(n|(t<<SERVICE_IP_WAITTIME_SHIFT)))
+//MACRO #define SERVICE_CCP_CODE(t, n) ((long)SERVICE_CCP_QUERY_HINT|(long)(n|(t<<SERVICE_IP_WAITTIME_SHIFT)))
+//MACRO #define SERVICE_UIC_CODE(c, m) ((long)(((long)c<<16)|(long)(USHORT)m))
+//MACRO #define SERVICE_NT_CCP_CODE(t, n) (((long)SERVICE_CCP_QUERY_HINT)|((long)(n))|(((t)&LOWER_HINT_MASK)<<SERVICE_IP_WAITTIME_SHIFT)|(((t)&UPPER_HINT_MASK)<<SERVICE_NTIP_WAITTIME_SHIFT))
+//MACRO #define SERVICE_NT_WAIT_GET(c) ((((c)&UPPER_GET_HINT_MASK)>>SERVICE_NTIP_WAITTIME_SHIFT)|(((c)&LOWER_GET_HINT_MASK)>>SERVICE_IP_WAITTIME_SHIFT))
diff --git a/libphobos/libdruntime/core/sys/windows/lmuse.d b/libphobos/libdruntime/core/sys/windows/lmuse.d
new file mode 100644
index 00000000000..8ceab4771ec
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmuse.d
@@ -0,0 +1,80 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmuse.d)
+ */
+module core.sys.windows.lmuse;
+version (Windows):
+pragma(lib, "netapi32");
+
+import core.sys.windows.lmuseflg;
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+enum {
+    USE_LOCAL_PARMNUM = 1,
+    USE_REMOTE_PARMNUM,
+    USE_PASSWORD_PARMNUM,
+    USE_ASGTYPE_PARMNUM,
+    USE_USERNAME_PARMNUM,
+    USE_DOMAINNAME_PARMNUM
+}
+
+enum {
+    USE_OK,
+    USE_PAUSED,
+    USE_SESSLOST,
+    USE_DISCONN = USE_SESSLOST,
+    USE_NETERR,
+    USE_CONN,
+    USE_RECONN
+}
+
+enum DWORD USE_WILDCARD = -1;
+
+enum {
+    USE_DISKDEV,
+    USE_SPOOLDEV,
+    USE_CHARDEV,
+    USE_IPC
+}
+
+struct USE_INFO_0 {
+    LPWSTR ui0_local;
+    LPWSTR ui0_remote;
+}
+alias USE_INFO_0* PUSE_INFO_0, LPUSE_INFO_0;
+
+struct USE_INFO_1 {
+    LPWSTR ui1_local;
+    LPWSTR ui1_remote;
+    LPWSTR ui1_password;
+    DWORD ui1_status;
+    DWORD ui1_asg_type;
+    DWORD ui1_refcount;
+    DWORD ui1_usecount;
+}
+alias USE_INFO_1* PUSE_INFO_1, LPUSE_INFO_1;
+
+struct USE_INFO_2 {
+    LPWSTR ui2_local;
+    LPWSTR ui2_remote;
+    LPWSTR ui2_password;
+    DWORD ui2_status;
+    DWORD ui2_asg_type;
+    DWORD ui2_refcount;
+    DWORD ui2_usecount;
+    LPWSTR ui2_username;
+    LPWSTR ui2_domainname;
+}
+alias USE_INFO_2* PUSE_INFO_2, LPUSE_INFO_2;
+
+extern (Windows) {
+    NET_API_STATUS NetUseAdd(LPWSTR, DWORD, PBYTE, PDWORD);
+    NET_API_STATUS NetUseDel(LPWSTR, LPWSTR, DWORD);
+    NET_API_STATUS NetUseEnum(LPWSTR, DWORD, PBYTE*, DWORD, PDWORD, PDWORD,
+      PDWORD);
+    NET_API_STATUS NetUseGetInfo(LPWSTR, LPWSTR, DWORD, PBYTE*);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmuseflg.d b/libphobos/libdruntime/core/sys/windows/lmuseflg.d
new file mode 100644
index 00000000000..8157abd04ec
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmuseflg.d
@@ -0,0 +1,16 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.10
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmuseflg.d)
+ */
+module core.sys.windows.lmuseflg;
+version (Windows):
+
+enum : uint {
+    USE_NOFORCE = 0,
+    USE_FORCE,
+    USE_LOTS_OF_FORCE // = 2
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lmwksta.d b/libphobos/libdruntime/core/sys/windows/lmwksta.d
new file mode 100644
index 00000000000..33b57e50472
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lmwksta.d
@@ -0,0 +1,390 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lmwksta.d)
+ */
+module core.sys.windows.lmwksta;
+version (Windows):
+pragma(lib, "netapi32");
+
+import core.sys.windows.lmuseflg;
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+pragma(lib, "Netapi32");
+
+enum {
+    WKSTA_COMPUTERNAME_PARMNUM     = 1,
+    WKSTA_LANGROUP_PARMNUM,     // = 2
+    WKSTA_VER_MAJOR_PARMNUM        = 4,
+    WKSTA_VER_MINOR_PARMNUM,
+    WKSTA_LOGGED_ON_USERS_PARMNUM,
+    WKSTA_LANROOT_PARMNUM,
+    WKSTA_LOGON_DOMAIN_PARMNUM,
+    WKSTA_LOGON_SERVER_PARMNUM,
+    WKSTA_CHARWAIT_PARMNUM,
+    WKSTA_CHARTIME_PARMNUM,
+    WKSTA_CHARCOUNT_PARMNUM,
+    WKSTA_KEEPCONN_PARMNUM,
+    WKSTA_KEEPSEARCH_PARMNUM,
+    WKSTA_MAXCMDS_PARMNUM,
+    WKSTA_NUMWORKBUF_PARMNUM,
+    WKSTA_MAXWRKCACHE_PARMNUM,
+    WKSTA_SESSTIMEOUT_PARMNUM,
+    WKSTA_SIZERROR_PARMNUM,
+    WKSTA_NUMALERTS_PARMNUM,
+    WKSTA_NUMSERVICES_PARMNUM,
+    WKSTA_NUMCHARBUF_PARMNUM,
+    WKSTA_SIZCHARBUF_PARMNUM,     // = 23
+    WKSTA_ERRLOGSZ_PARMNUM           = 27,
+    WKSTA_PRINTBUFTIME_PARMNUM,
+    WKSTA_SIZWORKBUF_PARMNUM,
+    WKSTA_MAILSLOTS_PARMNUM,
+    WKSTA_NUMDGRAMBUF_PARMNUM,
+    WKSTA_WRKHEURISTICS_PARMNUM,
+    WKSTA_MAXTHREADS_PARMNUM,     // = 33
+    WKSTA_LOCKQUOTA_PARMNUM          = 41,
+    WKSTA_LOCKINCREMENT_PARMNUM,
+    WKSTA_LOCKMAXIMUM_PARMNUM,
+    WKSTA_PIPEINCREMENT_PARMNUM,
+    WKSTA_PIPEMAXIMUM_PARMNUM,
+    WKSTA_DORMANTFILELIMIT_PARMNUM,
+    WKSTA_CACHEFILETIMEOUT_PARMNUM,
+    WKSTA_USEOPPORTUNISTICLOCKING_PARMNUM,
+    WKSTA_USEUNLOCKBEHIND_PARMNUM,
+    WKSTA_USECLOSEBEHIND_PARMNUM,
+    WKSTA_BUFFERNAMEDPIPES_PARMNUM,
+    WKSTA_USELOCKANDREADANDUNLOCK_PARMNUM,
+    WKSTA_UTILIZENTCACHING_PARMNUM,
+    WKSTA_USERAWREAD_PARMNUM,
+    WKSTA_USERAWWRITE_PARMNUM,
+    WKSTA_USEWRITERAWWITHDATA_PARMNUM,
+    WKSTA_USEENCRYPTION_PARMNUM,
+    WKSTA_BUFFILESWITHDENYWRITE_PARMNUM,
+    WKSTA_BUFFERREADONLYFILES_PARMNUM,
+    WKSTA_FORCECORECREATEMODE_PARMNUM,
+    WKSTA_USE512BYTESMAXTRANSFER_PARMNUM,
+    WKSTA_READAHEADTHRUPUT_PARMNUM,    // = 62
+    WKSTA_PLATFORM_ID_PARMNUM             = 100,
+    WKSTA_OTH_DOMAINS_PARMNUM             = 101,
+    TRANSPORT_QUALITYOFSERVICE_PARMNUM    = 201,
+    TRANSPORT_NAME_PARMNUM                = 202
+}
+
+struct WKSTA_INFO_100{
+    DWORD wki100_platform_id;
+    LPWSTR wki100_computername;
+    LPWSTR wki100_langroup;
+    DWORD wki100_ver_major;
+    DWORD wki100_ver_minor;
+}
+alias WKSTA_INFO_100* PWKSTA_INFO_100, LPWKSTA_INFO_100;
+
+struct WKSTA_INFO_101{
+    DWORD wki101_platform_id;
+    LPWSTR wki101_computername;
+    LPWSTR wki101_langroup;
+    DWORD wki101_ver_major;
+    DWORD wki101_ver_minor;
+    LPWSTR wki101_lanroot;
+}
+alias WKSTA_INFO_101* PWKSTA_INFO_101, LPWKSTA_INFO_101;
+
+struct WKSTA_INFO_102{
+    DWORD wki102_platform_id;
+    LPWSTR wki102_computername;
+    LPWSTR wki102_langroup;
+    DWORD wki102_ver_major;
+    DWORD wki102_ver_minor;
+    LPWSTR wki102_lanroot;
+    DWORD wki102_logged_on_users;
+}
+alias WKSTA_INFO_102* PWKSTA_INFO_102, LPWKSTA_INFO_102;
+
+struct WKSTA_INFO_302{
+    DWORD wki302_char_wait;
+    DWORD wki302_collection_time;
+    DWORD wki302_maximum_collection_count;
+    DWORD wki302_keep_conn;
+    DWORD wki302_keep_search;
+    DWORD wki302_max_cmds;
+    DWORD wki302_num_work_buf;
+    DWORD wki302_siz_work_buf;
+    DWORD wki302_max_wrk_cache;
+    DWORD wki302_sess_timeout;
+    DWORD wki302_siz_error;
+    DWORD wki302_num_alerts;
+    DWORD wki302_num_services;
+    DWORD wki302_errlog_sz;
+    DWORD wki302_print_buf_time;
+    DWORD wki302_num_char_buf;
+    DWORD wki302_siz_char_buf;
+    LPWSTR wki302_wrk_heuristics;
+    DWORD wki302_mailslots;
+    DWORD wki302_num_dgram_buf;
+}
+alias WKSTA_INFO_302* PWKSTA_INFO_302, LPWKSTA_INFO_302;
+
+struct WKSTA_INFO_402{
+    DWORD wki402_char_wait;
+    DWORD wki402_collection_time;
+    DWORD wki402_maximum_collection_count;
+    DWORD wki402_keep_conn;
+    DWORD wki402_keep_search;
+    DWORD wki402_max_cmds;
+    DWORD wki402_num_work_buf;
+    DWORD wki402_siz_work_buf;
+    DWORD wki402_max_wrk_cache;
+    DWORD wki402_sess_timeout;
+    DWORD wki402_siz_error;
+    DWORD wki402_num_alerts;
+    DWORD wki402_num_services;
+    DWORD wki402_errlog_sz;
+    DWORD wki402_print_buf_time;
+    DWORD wki402_num_char_buf;
+    DWORD wki402_siz_char_buf;
+    LPWSTR wki402_wrk_heuristics;
+    DWORD wki402_mailslots;
+    DWORD wki402_num_dgram_buf;
+    DWORD wki402_max_threads;
+}
+alias WKSTA_INFO_402* PWKSTA_INFO_402, LPWKSTA_INFO_402;
+
+struct WKSTA_INFO_502{
+    DWORD wki502_char_wait;
+    DWORD wki502_collection_time;
+    DWORD wki502_maximum_collection_count;
+    DWORD wki502_keep_conn;
+    DWORD wki502_max_cmds;
+    DWORD wki502_sess_timeout;
+    DWORD wki502_siz_char_buf;
+    DWORD wki502_max_threads;
+    DWORD wki502_lock_quota;
+    DWORD wki502_lock_increment;
+    DWORD wki502_lock_maximum;
+    DWORD wki502_pipe_increment;
+    DWORD wki502_pipe_maximum;
+    DWORD wki502_cache_file_timeout;
+    DWORD wki502_dormant_file_limit;
+    DWORD wki502_read_ahead_throughput;
+    DWORD wki502_num_mailslot_buffers;
+    DWORD wki502_num_srv_announce_buffers;
+    DWORD wki502_max_illegal_datagram_events;
+    DWORD wki502_illegal_datagram_event_reset_frequency;
+    BOOL wki502_log_election_packets;
+    BOOL wki502_use_opportunistic_locking;
+    BOOL wki502_use_unlock_behind;
+    BOOL wki502_use_close_behind;
+    BOOL wki502_buf_named_pipes;
+    BOOL wki502_use_lock_read_unlock;
+    BOOL wki502_utilize_nt_caching;
+    BOOL wki502_use_raw_read;
+    BOOL wki502_use_raw_write;
+    BOOL wki502_use_write_raw_data;
+    BOOL wki502_use_encryption;
+    BOOL wki502_buf_files_deny_write;
+    BOOL wki502_buf_read_only_files;
+    BOOL wki502_force_core_create_mode;
+    BOOL wki502_use_512_byte_max_transfer;
+}
+alias WKSTA_INFO_502* PWKSTA_INFO_502, LPWKSTA_INFO_502;
+
+struct WKSTA_INFO_1010 {
+    DWORD wki1010_char_wait;
+}
+alias WKSTA_INFO_1010* PWKSTA_INFO_1010, LPWKSTA_INFO_1010;
+
+struct WKSTA_INFO_1011 {
+    DWORD wki1011_collection_time;
+}
+alias WKSTA_INFO_1011* PWKSTA_INFO_1011, LPWKSTA_INFO_1011;
+
+struct WKSTA_INFO_1012 {
+    DWORD wki1012_maximum_collection_count;
+}
+alias WKSTA_INFO_1012* PWKSTA_INFO_1012, LPWKSTA_INFO_1012;
+
+struct WKSTA_INFO_1027 {
+    DWORD wki1027_errlog_sz;
+}
+alias WKSTA_INFO_1027* PWKSTA_INFO_1027, LPWKSTA_INFO_1027;
+
+struct WKSTA_INFO_1028 {
+    DWORD wki1028_print_buf_time;
+}
+alias WKSTA_INFO_1028* PWKSTA_INFO_1028, LPWKSTA_INFO_1028;
+
+struct WKSTA_INFO_1032 {
+    DWORD wki1032_wrk_heuristics;
+}
+alias WKSTA_INFO_1032* PWKSTA_INFO_1032, LPWKSTA_INFO_1032;
+
+struct WKSTA_INFO_1013 {
+    DWORD wki1013_keep_conn;
+}
+alias WKSTA_INFO_1013* PWKSTA_INFO_1013, LPWKSTA_INFO_1013;
+
+struct WKSTA_INFO_1018 {
+    DWORD wki1018_sess_timeout;
+}
+alias WKSTA_INFO_1018* PWKSTA_INFO_1018, LPWKSTA_INFO_1018;
+
+struct WKSTA_INFO_1023 {
+    DWORD wki1023_siz_char_buf;
+}
+alias WKSTA_INFO_1023* PWKSTA_INFO_1023, LPWKSTA_INFO_1023;
+
+struct WKSTA_INFO_1033 {
+    DWORD wki1033_max_threads;
+}
+alias WKSTA_INFO_1033* PWKSTA_INFO_1033, LPWKSTA_INFO_1033;
+
+struct WKSTA_INFO_1041 {
+    DWORD wki1041_lock_quota;
+}
+alias WKSTA_INFO_1041* PWKSTA_INFO_1041, LPWKSTA_INFO_1041;
+
+struct WKSTA_INFO_1042 {
+    DWORD wki1042_lock_increment;
+}
+alias WKSTA_INFO_1042* PWKSTA_INFO_1042, LPWKSTA_INFO_1042;
+
+struct WKSTA_INFO_1043 {
+    DWORD wki1043_lock_maximum;
+}
+alias WKSTA_INFO_1043* PWKSTA_INFO_1043, LPWKSTA_INFO_1043;
+
+struct WKSTA_INFO_1044 {
+    DWORD wki1044_pipe_increment;
+}
+alias WKSTA_INFO_1044* PWKSTA_INFO_1044, LPWKSTA_INFO_1044;
+
+struct WKSTA_INFO_1045 {
+    DWORD wki1045_pipe_maximum;
+}
+alias WKSTA_INFO_1045* PWKSTA_INFO_1045, LPWKSTA_INFO_1045;
+
+struct WKSTA_INFO_1046 {
+    DWORD wki1046_dormant_file_limit;
+}
+alias WKSTA_INFO_1046* PWKSTA_INFO_1046, LPWKSTA_INFO_1046;
+
+struct WKSTA_INFO_1047 {
+    DWORD wki1047_cache_file_timeout;
+}
+alias WKSTA_INFO_1047* PWKSTA_INFO_1047, LPWKSTA_INFO_1047;
+
+struct WKSTA_INFO_1048 {
+    BOOL wki1048_use_opportunistic_locking;
+}
+alias WKSTA_INFO_1048* PWKSTA_INFO_1048, LPWKSTA_INFO_1048;
+
+struct WKSTA_INFO_1049 {
+    BOOL wki1049_use_unlock_behind;
+}
+alias WKSTA_INFO_1049* PWKSTA_INFO_1049, LPWKSTA_INFO_1049;
+
+struct WKSTA_INFO_1050 {
+    BOOL wki1050_use_close_behind;
+}
+alias WKSTA_INFO_1050* PWKSTA_INFO_1050, LPWKSTA_INFO_1050;
+
+struct WKSTA_INFO_1051 {
+    BOOL wki1051_buf_named_pipes;
+}
+alias WKSTA_INFO_1051* PWKSTA_INFO_1051, LPWKSTA_INFO_1051;
+
+struct WKSTA_INFO_1052 {
+    BOOL wki1052_use_lock_read_unlock;
+}
+alias WKSTA_INFO_1052* PWKSTA_INFO_1052, LPWKSTA_INFO_1052;
+
+struct WKSTA_INFO_1053 {
+    BOOL wki1053_utilize_nt_caching;
+}
+alias WKSTA_INFO_1053* PWKSTA_INFO_1053, LPWKSTA_INFO_1053;
+
+struct WKSTA_INFO_1054 {
+    BOOL wki1054_use_raw_read;
+}
+alias WKSTA_INFO_1054* PWKSTA_INFO_1054, LPWKSTA_INFO_1054;
+
+struct WKSTA_INFO_1055 {
+    BOOL wki1055_use_raw_write;
+}
+alias WKSTA_INFO_1055* PWKSTA_INFO_1055, LPWKSTA_INFO_1055;
+
+struct WKSTA_INFO_1056 {
+    BOOL wki1056_use_write_raw_data;
+}
+alias WKSTA_INFO_1056* PWKSTA_INFO_1056, LPWKSTA_INFO_1056;
+
+struct WKSTA_INFO_1057 {
+    BOOL wki1057_use_encryption;
+}
+alias WKSTA_INFO_1057* PWKSTA_INFO_1057, LPWKSTA_INFO_1057;
+
+struct WKSTA_INFO_1058 {
+    BOOL wki1058_buf_files_deny_write;
+}
+alias WKSTA_INFO_1058* PWKSTA_INFO_1058, LPWKSTA_INFO_1058;
+
+struct WKSTA_INFO_1059 {
+    BOOL wki1059_buf_read_only_files;
+}
+alias WKSTA_INFO_1059* PWKSTA_INFO_1059, LPWKSTA_INFO_1059;
+
+struct WKSTA_INFO_1060 {
+    BOOL wki1060_force_core_create_mode;
+}
+alias WKSTA_INFO_1060* PWKSTA_INFO_1060, LPWKSTA_INFO_1060;
+
+struct WKSTA_INFO_1061 {
+    BOOL wki1061_use_512_byte_max_transfer;
+}
+alias WKSTA_INFO_1061* PWKSTA_INFO_1061, LPWKSTA_INFO_1061;
+
+struct WKSTA_INFO_1062 {
+    DWORD wki1062_read_ahead_throughput;
+}
+alias WKSTA_INFO_1062* PWKSTA_INFO_1062, LPWKSTA_INFO_1062;
+
+struct WKSTA_USER_INFO_0 {
+    LPWSTR wkui0_username;
+}
+alias WKSTA_USER_INFO_0* PWKSTA_USER_INFO_0, LPWKSTA_USER_INFO_0;
+
+struct WKSTA_USER_INFO_1{
+    LPWSTR wkui1_username;
+    LPWSTR wkui1_logon_domain;
+    LPWSTR wkui1_oth_domains;
+    LPWSTR wkui1_logon_server;
+}
+alias WKSTA_USER_INFO_1* PWKSTA_USER_INFO_1, LPWKSTA_USER_INFO_1;
+
+struct WKSTA_USER_INFO_1101 {
+    LPWSTR wkui1101_oth_domains;
+}
+alias WKSTA_USER_INFO_1101* PWKSTA_USER_INFO_1101, LPWKSTA_USER_INFO_1101;
+
+struct WKSTA_TRANSPORT_INFO_0{
+    DWORD wkti0_quality_of_service;
+    DWORD wkti0_number_of_vcs;
+    LPWSTR wkti0_transport_name;
+    LPWSTR wkti0_transport_address;
+    BOOL wkti0_wan_ish;
+}
+alias WKSTA_TRANSPORT_INFO_0* PWKSTA_TRANSPORT_INFO_0, LPWKSTA_TRANSPORT_INFO_0;
+
+extern (Windows) {
+NET_API_STATUS NetWkstaGetInfo(LPWSTR,DWORD,PBYTE*);
+NET_API_STATUS NetWkstaSetInfo(LPWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetWkstaUserGetInfo(LPWSTR,DWORD,PBYTE*);
+NET_API_STATUS NetWkstaUserSetInfo(LPWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetWkstaUserEnum(LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+NET_API_STATUS NetWkstaTransportAdd(LPWSTR,DWORD,PBYTE,PDWORD);
+NET_API_STATUS NetWkstaTransportDel(LPWSTR,LPWSTR,DWORD);
+NET_API_STATUS NetWkstaTransportEnum(LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/lzexpand.d b/libphobos/libdruntime/core/sys/windows/lzexpand.d
new file mode 100644
index 00000000000..0ed0855c7d4
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/lzexpand.d
@@ -0,0 +1,50 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_lzexpand.d)
+ */
+module core.sys.windows.lzexpand;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "lz32");
+
+private import core.sys.windows.winbase, core.sys.windows.windef;
+
+enum : LONG {
+    LZERROR_BADINHANDLE  = -1,
+    LZERROR_BADOUTHANDLE = -2,
+    LZERROR_READ         = -3,
+    LZERROR_WRITE        = -4,
+    LZERROR_GLOBALLOC    = -5,
+    LZERROR_GLOBLOCK     = -6,
+    LZERROR_BADVALUE     = -7,
+    LZERROR_UNKNOWNALG   = -8
+}
+
+extern (Windows):
+deprecated {
+    LONG CopyLZFile(INT, INT);
+    void LZDone();
+    INT LZStart();
+}
+INT GetExpandedNameA(LPSTR, LPSTR);
+INT GetExpandedNameW(LPWSTR, LPWSTR);
+void LZClose(INT);
+LONG LZCopy(INT, INT);
+INT LZInit(INT);
+INT LZOpenFileA(LPSTR, LPOFSTRUCT, WORD);
+INT LZOpenFileW(LPWSTR, LPOFSTRUCT, WORD);
+INT LZRead(INT, LPSTR, INT);
+LONG LZSeek(INT, LONG, INT);
+
+version (Unicode) {
+    alias GetExpandedNameW GetExpandedName;
+    alias LZOpenFileW LZOpenFile;
+} else {
+    alias GetExpandedNameA GetExpandedName;
+    alias LZOpenFileA LZOpenFile;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/mapi.d b/libphobos/libdruntime/core/sys/windows/mapi.d
new file mode 100644
index 00000000000..a82c927f9ee
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/mapi.d
@@ -0,0 +1,168 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_mapi.d)
+ */
+module core.sys.windows.mapi;
+version (Windows):
+
+private import core.sys.windows.windef;
+
+// FIXME: check types and grouping of constants
+
+enum {
+    SUCCESS_SUCCESS,
+    MAPI_USER_ABORT,
+    MAPI_E_USER_ABORT        = MAPI_USER_ABORT,
+    MAPI_E_FAILURE,
+    MAPI_E_LOGIN_FAILURE,
+    MAPI_E_LOGON_FAILURE     = MAPI_E_LOGIN_FAILURE,
+    MAPI_E_DISK_FULL         = 4,
+    MAPI_E_INSUFFICIENT_MEMORY,
+    MAPI_E_ACCESS_DENIED,
+    MAPI_E_BLK_TOO_SMALL     = MAPI_E_ACCESS_DENIED, // = 6
+    MAPI_E_TOO_MANY_SESSIONS = 8,
+    MAPI_E_TOO_MANY_FILES,
+    MAPI_E_TOO_MANY_RECIPIENTS,
+    MAPI_E_ATTACHMENT_NOT_FOUND,
+    MAPI_E_ATTACHMENT_OPEN_FAILURE,
+    MAPI_E_ATTACHMENT_WRITE_FAILURE,
+    MAPI_E_UNKNOWN_RECIPIENT,
+    MAPI_E_BAD_RECIPTYPE,
+    MAPI_E_NO_MESSAGES,
+    MAPI_E_INVALID_MESSAGE,
+    MAPI_E_TEXT_TOO_LARGE,
+    MAPI_E_INVALID_SESSION,
+    MAPI_E_TYPE_NOT_SUPPORTED,
+    MAPI_E_AMBIGUOUS_RECIPIENT,
+    MAPI_E_AMBIGUOUS_RECIP   = MAPI_E_AMBIGUOUS_RECIPIENT,
+    MAPI_E_MESSAGE_IN_USE,
+    MAPI_E_NETWORK_FAILURE,
+    MAPI_E_INVALID_EDITFIELDS,
+    MAPI_E_INVALID_RECIPS,
+    MAPI_E_NOT_SUPPORTED  // = 26
+}
+
+enum {
+    MAPI_ORIG,
+    MAPI_TO,
+    MAPI_CC,
+    MAPI_BCC
+}
+
+enum MAPI_LOGON_UI          = 0x0001;
+enum MAPI_NEW_SESSION       = 0x0002;
+enum MAPI_FORCE_DOWNLOAD    = 0x1000;
+enum MAPI_LOGOFF_SHARED     = 0x0001;
+enum MAPI_LOGOFF_UI         = 0x0002;
+enum MAPI_DIALOG            = 0x0008;
+enum MAPI_UNREAD_ONLY       = 0x0020;
+enum MAPI_LONG_MSGID        = 0x4000;
+enum MAPI_GUARANTEE_FIFO    = 0x0100;
+enum MAPI_ENVELOPE_ONLY     = 0x0040;
+enum MAPI_PEEK              = 0x0080;
+enum MAPI_BODY_AS_FILE      = 0x0200;
+enum MAPI_SUPPRESS_ATTACH   = 0x0800;
+enum MAPI_AB_NOMODIFY       = 0x0400;
+enum MAPI_OLE               = 0x0001;
+enum MAPI_OLE_STATIC        = 0x0002;
+enum MAPI_UNREAD            = 0x0001;
+enum MAPI_RECEIPT_REQUESTED = 0x0002;
+enum MAPI_SENT              = 0x0004;
+
+alias uint FLAGS, LHANDLE;
+alias uint* LPLHANDLE, LPULONG;
+
+struct MapiRecipDesc {
+    ULONG  ulReserved;
+    ULONG  ulRecipClass;
+    LPSTR  lpszName;
+    LPSTR  lpszAddress;
+    ULONG  ulEIDSize;
+    LPVOID lpEntryID;
+}
+alias MapiRecipDesc* lpMapiRecipDesc;
+
+struct MapiFileDesc {
+    ULONG  ulReserved;
+    ULONG  flFlags;
+    ULONG  nPosition;
+    LPSTR  lpszPathName;
+    LPSTR  lpszFileName;
+    LPVOID lpFileType;
+}
+alias MapiFileDesc* lpMapiFileDesc;
+
+struct MapiFileTagExt {
+    ULONG  ulReserved;
+    ULONG  cbTag;
+    LPBYTE lpTag;
+    ULONG  cbEncoding;
+    LPBYTE lpEncoding;
+}
+alias MapiFileTagExt* lpMapiFileTagExt;
+
+struct MapiMessage {
+    ULONG           ulReserved;
+    LPSTR           lpszSubject;
+    LPSTR           lpszNoteText;
+    LPSTR           lpszMessageType;
+    LPSTR           lpszDateReceived;
+    LPSTR           lpszConversationID;
+    FLAGS           flFlags;
+    lpMapiRecipDesc lpOriginator;
+    ULONG           nRecipCount;
+    lpMapiRecipDesc lpRecips;
+    ULONG           nFileCount;
+    lpMapiFileDesc  lpFiles;
+}
+alias MapiMessage* lpMapiMessage;
+
+extern (Pascal) {
+    ULONG MAPILogon(ULONG, LPSTR, LPSTR, FLAGS, ULONG, LPLHANDLE);
+    ULONG MAPISendMail(LHANDLE, ULONG, lpMapiMessage, FLAGS, ULONG);
+    ULONG MAPISendDocuments(ULONG, LPSTR, LPSTR, LPSTR, ULONG);
+    ULONG MAPIReadMail(LHANDLE, ULONG, LPSTR, FLAGS, ULONG, lpMapiMessage*);
+    ULONG MAPIFindNext(LHANDLE, ULONG, LPSTR, LPSTR, FLAGS, ULONG, LPSTR);
+    ULONG MAPIResolveName(LHANDLE, ULONG, LPSTR, FLAGS, ULONG,
+      lpMapiRecipDesc*);
+    ULONG MAPIAddress(LHANDLE, ULONG, LPSTR, ULONG, LPSTR, ULONG,
+      lpMapiRecipDesc, FLAGS, ULONG, LPULONG, lpMapiRecipDesc*);
+    ULONG MAPIFreeBuffer(LPVOID);
+    ULONG MAPIDetails(LHANDLE, ULONG, lpMapiRecipDesc, FLAGS, ULONG);
+    ULONG MAPISaveMail(LHANDLE, ULONG, lpMapiMessage lpszMessage, FLAGS,
+      ULONG, LPSTR);
+    ULONG MAPIDeleteMail(LHANDLE lpSession, ULONG, LPSTR, FLAGS, ULONG);
+    ULONG MAPILogoff(LHANDLE, ULONG, FLAGS, ULONG);
+    // Netscape extensions
+    ULONG MAPIGetNetscapeVersion();
+    ULONG MAPI_NSCP_SynchronizeClient(LHANDLE, ULONG);
+
+    // Handles for use with GetProcAddress
+    alias ULONG function(ULONG, LPSTR, LPSTR, FLAGS, ULONG, LPLHANDLE)
+      LPMAPILOGON;
+    alias ULONG function(LHANDLE, ULONG, lpMapiMessage, FLAGS, ULONG)
+      LPMAPISENDMAIL;
+    alias ULONG function(ULONG, LPSTR, LPSTR, LPSTR, ULONG)
+      LPMAPISENDDOCUMENTS;
+    alias ULONG function(LHANDLE, ULONG, LPSTR, FLAGS, ULONG, lpMapiMessage*)
+      LPMAPIREADMAIL;
+    alias ULONG function(LHANDLE, ULONG, LPSTR, LPSTR, FLAGS, ULONG, LPSTR)
+      LPMAPIFINDNEXT;
+    alias ULONG function(LHANDLE, ULONG, LPSTR, FLAGS, ULONG,
+      lpMapiRecipDesc*) LPMAPIRESOLVENAME;
+    alias ULONG function(LHANDLE, ULONG, LPSTR, ULONG, LPSTR, ULONG,
+      lpMapiRecipDesc, FLAGS, ULONG, LPULONG, lpMapiRecipDesc*) LPMAPIADDRESS;
+    alias ULONG function(LPVOID lpv) LPMAPIFREEBUFFER;
+    alias ULONG function(LHANDLE, ULONG, lpMapiRecipDesc, FLAGS, ULONG)
+      LPMAPIDETAILS;
+    alias ULONG function(LHANDLE, ULONG, lpMapiMessage, FLAGS, ULONG, LPSTR)
+      LPMAPISAVEMAIL;
+    alias ULONG function(LHANDLE lpSession, ULONG, LPSTR, FLAGS, ULONG)
+      LPMAPIDELETEMAIL;
+    alias ULONG function(LHANDLE, ULONG, FLAGS, ULONG) LPMAPILOGOFF;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/mciavi.d b/libphobos/libdruntime/core/sys/windows/mciavi.d
new file mode 100644
index 00000000000..537bd4829c6
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/mciavi.d
@@ -0,0 +1,40 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_mciavi.d)
+ */
+module core.sys.windows.mciavi;
+version (Windows):
+
+private import core.sys.windows.mmsystem;
+
+// FIXME: check types and grouping of constants
+
+enum MCI_MCIAVI_PLAY_WINDOW     = 0x01000000;
+enum MCI_MCIAVI_PLAY_FULLSCREEN = 0x02000000;
+enum MCI_MCIAVI_PLAY_FULLBY2    = 0x04000000;
+
+enum {
+    MCI_AVI_STATUS_FRAMES_SKIPPED     = 0x00008001,
+    MCI_AVI_STATUS_LAST_PLAY_SPEED    = 0x00008002,
+    MCI_AVI_STATUS_AUDIO_BREAKS       = 0x00008003,
+    MCI_AVI_SETVIDEO_DRAW_PROCEDURE   = 0x00008000,
+    MCI_AVI_SETVIDEO_PALETTE_COLOR    = 0x00008100,
+    MCI_AVI_SETVIDEO_PALETTE_HALFTONE = 0x0000FFFF
+}
+
+enum {
+    MCIERR_AVI_OLDAVIFORMAT  = MCIERR_CUSTOM_DRIVER_BASE + 100,
+    MCIERR_AVI_NOTINTERLEAVED,
+    MCIERR_AVI_NODISPDIB,
+    MCIERR_AVI_CANTPLAYFULLSCREEN,
+    MCIERR_AVI_TOOBIGFORVGA,
+    MCIERR_AVI_NOCOMPRESSOR,
+    MCIERR_AVI_DISPLAYERROR,
+    MCIERR_AVI_AUDIOERROR,
+    MCIERR_AVI_BADPALETTE // = MCIERR_CUSTOM_DRIVER_BASE + 108
+}
diff --git a/libphobos/libdruntime/core/sys/windows/mcx.d b/libphobos/libdruntime/core/sys/windows/mcx.d
new file mode 100644
index 00000000000..11f6a452d81
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/mcx.d
@@ -0,0 +1,99 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_mcx.d)
+ */
+module core.sys.windows.mcx;
+version (Windows):
+
+private import core.sys.windows.windef;
+
+enum DWORD
+    DIALOPTION_BILLING  =  64,
+    DIALOPTION_QUIET    = 128,
+    DIALOPTION_DIALTONE = 256;
+
+enum DWORD
+    MDMVOLFLAG_LOW    = 1,
+    MDMVOLFLAG_MEDIUM = 2,
+    MDMVOLFLAG_HIGH   = 4;
+
+enum : DWORD {
+    MDMVOL_LOW    = 0,
+    MDMVOL_MEDIUM = 1,
+    MDMVOL_HIGH   = 2
+}
+
+enum DWORD
+    MDMSPKRFLAG_OFF       = 1,
+    MDMSPKRFLAG_DIAL      = 2,
+    MDMSPKRFLAG_ON        = 4,
+    MDMSPKRFLAG_CALLSETUP = 8;
+
+enum : DWORD {
+    MDMSPKR_OFF,
+    MDMSPKR_DIAL,
+    MDMSPKR_ON,
+    MDMSPKR_CALLSETUP
+}
+
+enum DWORD
+    MDM_COMPRESSION      = 0x0001,
+    MDM_ERROR_CONTROL    = 0x0002,
+    MDM_FORCED_EC        = 0x0004,
+    MDM_CELLULAR         = 0x0008,
+    MDM_FLOWCONTROL_HARD = 0x0010,
+    MDM_FLOWCONTROL_SOFT = 0x0020,
+    MDM_CCITT_OVERRIDE   = 0x0040,
+    MDM_SPEED_ADJUST     = 0x0080,
+    MDM_TONE_DIAL        = 0x0100,
+    MDM_BLIND_DIAL       = 0x0200,
+    MDM_V23_OVERRIDE     = 0x0400;
+
+struct MODEMDEVCAPS {
+    DWORD dwActualSize;
+    DWORD dwRequiredSize;
+    DWORD dwDevSpecificOffset;
+    DWORD dwDevSpecificSize;
+    DWORD dwModemProviderVersion;
+    DWORD dwModemManufacturerOffset;
+    DWORD dwModemManufacturerSize;
+    DWORD dwModemModelOffset;
+    DWORD dwModemModelSize;
+    DWORD dwModemVersionOffset;
+    DWORD dwModemVersionSize;
+    DWORD dwDialOptions;
+    DWORD dwCallSetupFailTimer;
+    DWORD dwInactivityTimeout;
+    DWORD dwSpeakerVolume;
+    DWORD dwSpeakerMode;
+    DWORD dwModemOptions;
+    DWORD dwMaxDTERate;
+    DWORD dwMaxDCERate;
+    BYTE  _abVariablePortion;
+
+    BYTE* abVariablePortion() return { return &_abVariablePortion; }
+}
+alias MODEMDEVCAPS* PMODEMDEVCAPS, LPMODEMDEVCAPS;
+
+struct MODEMSETTINGS {
+    DWORD dwActualSize;
+    DWORD dwRequiredSize;
+    DWORD dwDevSpecificOffset;
+    DWORD dwDevSpecificSize;
+    DWORD dwCallSetupFailTimer;
+    DWORD dwInactivityTimeout;
+    DWORD dwSpeakerVolume;
+    DWORD dwSpeakerMode;
+    DWORD dwPreferredModemOptions;
+    DWORD dwNegotiatedModemOptions;
+    DWORD dwNegotiatedDCERate;
+    BYTE  _abVariablePortion;
+
+    BYTE* abVariablePortion() return { return &_abVariablePortion; }
+}
+alias MODEMSETTINGS* PMODEMSETTINGS, LPMODEMSETTINGS;
diff --git a/libphobos/libdruntime/core/sys/windows/mgmtapi.d b/libphobos/libdruntime/core/sys/windows/mgmtapi.d
new file mode 100644
index 00000000000..3a11e81bfca
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/mgmtapi.d
@@ -0,0 +1,47 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_mgmtapi.d)
+ */
+module core.sys.windows.mgmtapi;
+version (Windows):
+
+import core.sys.windows.snmp;
+private import core.sys.windows.windef;
+
+enum {
+    SNMP_MGMTAPI_TIMEOUT = 40,
+    SNMP_MGMTAPI_SELECT_FDERRORS,
+    SNMP_MGMTAPI_TRAP_ERRORS,
+    SNMP_MGMTAPI_TRAP_DUPINIT,
+    SNMP_MGMTAPI_NOTRAPS,
+    SNMP_MGMTAPI_AGAIN,
+    SNMP_MGMTAPI_INVALID_CTL,
+    SNMP_MGMTAPI_INVALID_SESSION,
+    SNMP_MGMTAPI_INVALID_BUFFER // = 48
+}
+
+enum MGMCTL_SETAGENTPORT = 1;
+
+alias PVOID LPSNMP_MGR_SESSION;
+
+extern (Windows) {
+    BOOL SnmpMgrClose(LPSNMP_MGR_SESSION);
+    BOOL SnmpMgrCtl(LPSNMP_MGR_SESSION, DWORD, LPVOID, DWORD, LPVOID, DWORD,
+      LPDWORD);
+    BOOL SnmpMgrGetTrap(AsnObjectIdentifier*, AsnNetworkAddress*,
+      AsnInteger*, AsnInteger*, AsnTimeticks*, SnmpVarBindList*);
+    BOOL SnmpMgrGetTrapEx(AsnObjectIdentifier*, AsnNetworkAddress*,
+      AsnNetworkAddress*, AsnInteger*, AsnInteger*, AsnOctetString*,
+      AsnTimeticks*, SnmpVarBindList*);
+    BOOL SnmpMgrOidToStr(AsnObjectIdentifier*, LPSTR*);
+    LPSNMP_MGR_SESSION SnmpMgrOpen(LPSTR, LPSTR, INT, INT);
+    INT SnmpMgrRequest(LPSNMP_MGR_SESSION, BYTE, SnmpVarBindList*,
+      AsnInteger*, AsnInteger*);
+    BOOL SnmpMgrStrToOid(LPSTR, AsnObjectIdentifier*);
+    BOOL SnmpMgrTrapListen(HANDLE*);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/mmsystem.d b/libphobos/libdruntime/core/sys/windows/mmsystem.d
new file mode 100644
index 00000000000..a11a4e1834f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/mmsystem.d
@@ -0,0 +1,2272 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_mmsystem.d)
+ */
+module core.sys.windows.mmsystem;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "winmm");
+
+/*  The #defines MAKEFOURCC, mmioFOURCC, sndAlias are used to define
+ *  compile-time constants, so they are implemented as templates.
+ */
+
+private import core.sys.windows.w32api, core.sys.windows.windef, core.sys.windows.winver;
+
+align(1):
+
+enum MAXPNAMELEN = 32;
+enum MAXERRORLENGTH = 256;
+enum MAX_JOYSTICKOEMVXDNAME = 260;
+
+enum TIME_MS      = 1;
+enum TIME_SAMPLES = 2;
+enum TIME_BYTES   = 4;
+enum TIME_SMPTE   = 8;
+enum TIME_MIDI    = 16;
+enum TIME_TICKS   = 32;
+
+template MAKEFOURCC(char c0, char c1, char c2, char c3)
+{
+enum DWORD MAKEFOURCC = c0 | (c1<<8) | (c2<<16) | (cast(DWORD)c3 <<24);
+}
+
+template mmioFOURCC(char c0, char c1, char c2, char c3)
+{
+enum DWORD mmioFOURCC = c0 | (c1<<8) | (c2<<16) | (cast(DWORD)c3 <<24);
+}
+
+enum {
+    MM_JOY1MOVE            = 0x3A0,
+    MM_JOY2MOVE,
+    MM_JOY1ZMOVE,
+    MM_JOY2ZMOVE,       // = 0x3A3
+    MM_JOY1BUTTONDOWN      = 0x3B5,
+    MM_JOY2BUTTONDOWN,
+    MM_JOY1BUTTONUP,
+    MM_JOY2BUTTONUP,
+    MM_MCINOTIFY,       // = 0x3B9
+    MM_WOM_OPEN            = 0x3BB,
+    MM_WOM_CLOSE,
+    MM_WOM_DONE,
+    MM_WIM_OPEN,
+    MM_WIM_CLOSE,
+    MM_WIM_DATA,
+    MM_MIM_OPEN,
+    MM_MIM_CLOSE,
+    MM_MIM_DATA,
+    MM_MIM_LONGDATA,
+    MM_MIM_ERROR,
+    MM_MIM_LONGERROR,
+    MM_MOM_OPEN,
+    MM_MOM_CLOSE,
+    MM_MOM_DONE,        // = 0x3C9
+    MM_DRVM_OPEN           = 0x3D0,
+    MM_DRVM_CLOSE,
+    MM_DRVM_DATA,
+    MM_DRVM_ERROR,
+    MM_STREAM_OPEN,
+    MM_STREAM_CLOSE,
+    MM_STREAM_DONE,
+    MM_STREAM_ERROR,    // = 0x3D7
+    MM_MOM_POSITIONCB      = 0x3CA,
+    MM_MCISIGNAL,
+    MM_MIM_MOREDATA,    // = 0x3CC
+    MM_MIXM_LINE_CHANGE    = 0x3D0,
+    MM_MIXM_CONTROL_CHANGE = 0x3D1
+}
+
+enum MMSYSERR_BASE     =    0;
+enum WAVERR_BASE       =   32;
+enum MIDIERR_BASE      =   64;
+enum TIMERR_BASE       =   96;
+enum JOYERR_BASE       =  160;
+enum MCIERR_BASE       =  256;
+enum MIXERR_BASE       = 1024;
+enum MCI_STRING_OFFSET =  512;
+enum MCI_VD_OFFSET     = 1024;
+enum MCI_CD_OFFSET     = 1088;
+enum MCI_WAVE_OFFSET   = 1152;
+enum MCI_SEQ_OFFSET    = 1216;
+
+enum {
+    MMSYSERR_NOERROR        = 0,
+    MMSYSERR_ERROR          = MMSYSERR_BASE+1,
+    MMSYSERR_BADDEVICEID,
+    MMSYSERR_NOTENABLED,
+    MMSYSERR_ALLOCATED,
+    MMSYSERR_INVALHANDLE,
+    MMSYSERR_NODRIVER,
+    MMSYSERR_NOMEM,
+    MMSYSERR_NOTSUPPORTED,
+    MMSYSERR_BADERRNUM,
+    MMSYSERR_INVALFLAG,
+    MMSYSERR_INVALPARAM,
+    MMSYSERR_HANDLEBUSY,
+    MMSYSERR_INVALIDALIAS,
+    MMSYSERR_BADDB,
+    MMSYSERR_KEYNOTFOUND,
+    MMSYSERR_READERROR,
+    MMSYSERR_WRITEERROR,
+    MMSYSERR_DELETEERROR,
+    MMSYSERR_VALNOTFOUND,
+    MMSYSERR_NODRIVERCB, // = MMSYSERR_BASE+20
+    MMSYSERR_LASTERROR      = MMSYSERR_NODRIVERCB
+}
+
+enum {
+    DRV_LOAD = 1,
+    DRV_ENABLE,
+    DRV_OPEN,
+    DRV_CLOSE,
+    DRV_DISABLE,
+    DRV_FREE,
+    DRV_CONFIGURE,
+    DRV_QUERYCONFIGURE,
+    DRV_INSTALL,
+    DRV_REMOVE,
+    DRV_EXITSESSION,
+    DRV_POWER
+}
+
+enum DRV_RESERVED = 0x800;
+enum DRV_USER = 0x4000;
+
+enum DRVCNF_CANCEL = 0;
+enum DRVCNF_OK = 1;
+enum DRVCNF_RESTART = 2;
+enum DRV_CANCEL = DRVCNF_CANCEL;
+enum DRV_OK = DRVCNF_OK;
+enum DRV_RESTART = DRVCNF_RESTART;
+enum DRV_MCI_FIRST = DRV_RESERVED;
+enum DRV_MCI_LAST  = DRV_RESERVED + 0xFFF;
+
+enum CALLBACK_TYPEMASK = 0x70000;
+enum CALLBACK_NULL     = 0;
+enum CALLBACK_WINDOW   = 0x10000;
+enum CALLBACK_TASK     = 0x20000;
+enum CALLBACK_FUNCTION = 0x30000;
+enum CALLBACK_THREAD   = CALLBACK_TASK;
+enum CALLBACK_EVENT    = 0x50000;
+
+enum SND_SYNC=0;
+enum SND_ASYNC=1;
+enum SND_NODEFAULT=2;
+enum SND_MEMORY=4;
+enum SND_LOOP=8;
+enum SND_NOSTOP=16;
+enum SND_NOWAIT=0x2000;
+enum SND_ALIAS=0x10000;
+enum SND_ALIAS_ID=0x110000;
+enum SND_FILENAME=0x20000;
+enum SND_RESOURCE=0x40004;
+enum SND_PURGE=0x40;
+enum SND_APPLICATION=0x80;
+enum SND_ALIAS_START=0;
+
+template sndAlias(char c0, char c1)
+{
+enum DWORD sndAlias = SND_ALIAS_START + c0 | (c1<<8);
+}
+
+enum SND_ALIAS_SYSTEMASTERISK    = sndAlias!('S', '*');
+enum SND_ALIAS_SYSTEMQUESTION    = sndAlias!('S', '?');
+enum SND_ALIAS_SYSTEMHAND        = sndAlias!('S', 'H');
+enum SND_ALIAS_SYSTEMEXIT        = sndAlias!('S', 'E');
+enum SND_ALIAS_SYSTEMSTART       = sndAlias!('S', 'S');
+enum SND_ALIAS_SYSTEMWELCOME     = sndAlias!('S', 'W');
+enum SND_ALIAS_SYSTEMEXCLAMATION = sndAlias!('S', '!');
+enum SND_ALIAS_SYSTEMDEFAULT     = sndAlias!('S', 'D');
+
+enum {
+    WAVERR_BADFORMAT  = (WAVERR_BASE + 0),
+    WAVERR_STILLPLAYING,
+    WAVERR_UNPREPARED,
+    WAVERR_SYNC,  // = WAVERR_BASE + 3;
+    WAVERR_LASTERROR = WAVERR_SYNC
+}
+
+enum WOM_OPEN  = MM_WOM_OPEN;
+enum WOM_CLOSE = MM_WOM_CLOSE;
+enum WOM_DONE  = MM_WOM_DONE;
+enum WIM_OPEN  = MM_WIM_OPEN;
+enum WIM_CLOSE = MM_WIM_CLOSE;
+enum WIM_DATA  = MM_WIM_DATA;
+
+enum UINT WAVE_MAPPER= -1;  // FIXME: This doesn't make sense!
+enum WAVE_FORMAT_QUERY=1;
+enum WAVE_ALLOWSYNC=2;
+enum WAVE_MAPPED=4;
+enum WAVE_FORMAT_DIRECT=8;
+enum WAVE_FORMAT_DIRECT_QUERY=(WAVE_FORMAT_QUERY|WAVE_FORMAT_DIRECT);
+enum WHDR_DONE=1;
+enum WHDR_PREPARED=2;
+enum WHDR_BEGINLOOP=4;
+enum WHDR_ENDLOOP=8;
+enum WHDR_INQUEUE=16;
+
+enum WAVECAPS_PITCH=1;
+enum WAVECAPS_PLAYBACKRATE=2;
+enum WAVECAPS_VOLUME=4;
+enum WAVECAPS_LRVOLUME=8;
+enum WAVECAPS_SYNC=16;
+enum WAVECAPS_SAMPLEACCURATE=32;
+enum WAVECAPS_DIRECTSOUND=64;
+
+enum WAVE_INVALIDFORMAT=0;
+enum WAVE_FORMAT_1M08=1;
+enum WAVE_FORMAT_1S08=2;
+enum WAVE_FORMAT_1M16=4;
+enum WAVE_FORMAT_1S16=8;
+enum WAVE_FORMAT_2M08=16;
+enum WAVE_FORMAT_2S08=32;
+enum WAVE_FORMAT_2M16=64;
+enum WAVE_FORMAT_2S16=128;
+enum WAVE_FORMAT_4M08=256;
+enum WAVE_FORMAT_4S08=512;
+enum WAVE_FORMAT_4M16=1024;
+enum WAVE_FORMAT_4S16=2048;
+enum WAVE_FORMAT_PCM=1;
+
+enum {
+    MIDIERR_UNPREPARED = MIDIERR_BASE,
+    MIDIERR_STILLPLAYING,
+    MIDIERR_NOMAP,
+    MIDIERR_NOTREADY,
+    MIDIERR_NODEVICE,
+    MIDIERR_INVALIDSETUP,
+    MIDIERR_BADOPENMODE,
+    MIDIERR_DONT_CONTINUE, // = MIDIERR_BASE+7
+    MIDIERR_LASTERROR = MIDIERR_DONT_CONTINUE
+}
+
+enum MIDIPATCHSIZE=128;
+
+enum MIM_OPEN=MM_MIM_OPEN;
+enum MIM_CLOSE=MM_MIM_CLOSE;
+enum MIM_DATA=MM_MIM_DATA;
+enum MIM_LONGDATA=MM_MIM_LONGDATA;
+enum MIM_ERROR=MM_MIM_ERROR;
+enum MIM_LONGERROR=MM_MIM_LONGERROR;
+enum MOM_OPEN=MM_MOM_OPEN;
+enum MOM_CLOSE=MM_MOM_CLOSE;
+enum MOM_DONE=MM_MOM_DONE;
+enum MIM_MOREDATA=MM_MIM_MOREDATA;
+enum MOM_POSITIONCB=MM_MOM_POSITIONCB;
+
+enum UINT MIDIMAPPER= -1; // FIXME: uint is nonsense for this!
+enum UINT MIDI_MAPPER= -1; // FIXME: uint is nonsense for this!
+enum MIDI_IO_STATUS=32;
+enum MIDI_CACHE_ALL=1;
+enum MIDI_CACHE_BESTFIT=2;
+enum MIDI_CACHE_QUERY=3;
+enum MIDI_UNCACHE=4;
+enum MOD_MIDIPORT=1;
+enum MOD_SYNTH=2;
+enum MOD_SQSYNTH=3;
+enum MOD_FMSYNTH=4;
+enum MOD_MAPPER=5;
+enum MIDICAPS_VOLUME=1;
+enum MIDICAPS_LRVOLUME=2;
+enum MIDICAPS_CACHE=4;
+enum MIDICAPS_STREAM=8;
+enum MHDR_DONE=1;
+enum MHDR_PREPARED=2;
+enum MHDR_INQUEUE=4;
+enum MHDR_ISSTRM=8;
+enum MEVT_F_SHORT=0;
+enum MEVT_F_LONG=0x80000000;
+enum MEVT_F_CALLBACK=0x40000000;
+
+BYTE MEVT_EVENTTYPE(DWORD x) { return cast(BYTE)((x>>24) &0xFF); }
+DWORD MEVT_EVENTPARM(DWORD x) { return x & 0xFFFFFF; }
+
+enum MEVT_SHORTMSG=0;
+enum MEVT_TEMPO=1;
+enum MEVT_NOP=2;
+
+enum BYTE MEVT_LONGMSG = 0x80;
+enum BYTE MEVT_COMMENT = 0x82;
+enum BYTE MEVT_VERSION = 0x84;
+
+enum MIDISTRM_ERROR = -2;
+
+enum MIDIPROP_SET = 0x80000000;
+enum MIDIPROP_GET = 0x40000000;
+enum MIDIPROP_TIMEDIV = 1;
+enum MIDIPROP_TEMPO = 2;
+
+enum UINT AUX_MAPPER = -1;
+
+enum AUXCAPS_CDAUDIO=1;
+enum AUXCAPS_AUXIN=2;
+enum AUXCAPS_VOLUME=1;
+enum AUXCAPS_LRVOLUME=2;
+enum MIXER_SHORT_NAME_CHARS=16;
+enum MIXER_LONG_NAME_CHARS=64;
+enum MIXERR_INVALLINE=MIXERR_BASE;
+enum MIXERR_INVALCONTROL=(MIXERR_BASE+1);
+enum MIXERR_INVALVALUE=(MIXERR_BASE+2);
+enum MIXERR_LASTERROR=(MIXERR_BASE+2);
+
+enum MIXER_OBJECTF_HANDLE=0x80000000;
+enum MIXER_OBJECTF_MIXER=0;
+enum MIXER_OBJECTF_HMIXER=(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_MIXER);
+enum MIXER_OBJECTF_WAVEOUT=0x10000000;
+enum MIXER_OBJECTF_HWAVEOUT=(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_WAVEOUT);
+enum MIXER_OBJECTF_WAVEIN=0x20000000;
+enum MIXER_OBJECTF_HWAVEIN=(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_WAVEIN);
+enum MIXER_OBJECTF_MIDIOUT=0x30000000;
+enum MIXER_OBJECTF_HMIDIOUT=(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_MIDIOUT);
+enum MIXER_OBJECTF_MIDIIN=0x40000000;
+enum MIXER_OBJECTF_HMIDIIN=(MIXER_OBJECTF_HANDLE|MIXER_OBJECTF_MIDIIN);
+enum MIXER_OBJECTF_AUX=0x50000000;
+
+enum MIXERLINE_LINEF_ACTIVE=1;
+enum MIXERLINE_LINEF_DISCONNECTED=0x8000;
+enum MIXERLINE_LINEF_SOURCE=0x80000000;
+
+enum MIXERLINE_COMPONENTTYPE_DST_FIRST=0;
+enum MIXERLINE_COMPONENTTYPE_DST_UNDEFINED=MIXERLINE_COMPONENTTYPE_DST_FIRST;
+enum MIXERLINE_COMPONENTTYPE_DST_DIGITAL=(MIXERLINE_COMPONENTTYPE_DST_FIRST+1);
+enum MIXERLINE_COMPONENTTYPE_DST_LINE=(MIXERLINE_COMPONENTTYPE_DST_FIRST+2);
+enum MIXERLINE_COMPONENTTYPE_DST_MONITOR=(MIXERLINE_COMPONENTTYPE_DST_FIRST+3);
+enum MIXERLINE_COMPONENTTYPE_DST_SPEAKERS=(MIXERLINE_COMPONENTTYPE_DST_FIRST+4);
+enum MIXERLINE_COMPONENTTYPE_DST_HEADPHONES=(MIXERLINE_COMPONENTTYPE_DST_FIRST+5);
+enum MIXERLINE_COMPONENTTYPE_DST_TELEPHONE=(MIXERLINE_COMPONENTTYPE_DST_FIRST+6);
+enum MIXERLINE_COMPONENTTYPE_DST_WAVEIN=(MIXERLINE_COMPONENTTYPE_DST_FIRST+7);
+enum MIXERLINE_COMPONENTTYPE_DST_VOICEIN=(MIXERLINE_COMPONENTTYPE_DST_FIRST+8);
+enum MIXERLINE_COMPONENTTYPE_DST_LAST=(MIXERLINE_COMPONENTTYPE_DST_FIRST+8);
+enum MIXERLINE_COMPONENTTYPE_SRC_FIRST=0x1000;
+enum MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED=MIXERLINE_COMPONENTTYPE_SRC_FIRST;
+enum MIXERLINE_COMPONENTTYPE_SRC_DIGITAL=(MIXERLINE_COMPONENTTYPE_SRC_FIRST+1);
+enum MIXERLINE_COMPONENTTYPE_SRC_LINE=(MIXERLINE_COMPONENTTYPE_SRC_FIRST+2);
+enum MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE=(MIXERLINE_COMPONENTTYPE_SRC_FIRST+3);
+enum MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER=(MIXERLINE_COMPONENTTYPE_SRC_FIRST+4);
+enum MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC=(MIXERLINE_COMPONENTTYPE_SRC_FIRST+5);
+enum MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE=(MIXERLINE_COMPONENTTYPE_SRC_FIRST+6);
+enum MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER=(MIXERLINE_COMPONENTTYPE_SRC_FIRST+7);
+enum MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT=(MIXERLINE_COMPONENTTYPE_SRC_FIRST+8);
+enum MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY=(MIXERLINE_COMPONENTTYPE_SRC_FIRST+9);
+enum MIXERLINE_COMPONENTTYPE_SRC_ANALOG=(MIXERLINE_COMPONENTTYPE_SRC_FIRST+10);
+enum MIXERLINE_COMPONENTTYPE_SRC_LAST=(MIXERLINE_COMPONENTTYPE_SRC_FIRST+10);
+
+enum {
+    MIXERLINE_TARGETTYPE_UNDEFINED = 0,
+    MIXERLINE_TARGETTYPE_WAVEOUT,
+    MIXERLINE_TARGETTYPE_WAVEIN,
+    MIXERLINE_TARGETTYPE_MIDIOUT,
+    MIXERLINE_TARGETTYPE_MIDIIN,
+    MIXERLINE_TARGETTYPE_AUX // =5
+}
+
+enum MIXER_GETLINEINFOF_DESTINATION=0;
+enum MIXER_GETLINEINFOF_SOURCE=1;
+enum MIXER_GETLINEINFOF_LINEID=2;
+enum MIXER_GETLINEINFOF_COMPONENTTYPE=3;
+enum MIXER_GETLINEINFOF_TARGETTYPE=4;
+enum MIXER_GETLINEINFOF_QUERYMASK=15;
+
+enum MIXERCONTROL_CONTROLF_UNIFORM=1;
+enum MIXERCONTROL_CONTROLF_MULTIPLE=2;
+enum MIXERCONTROL_CONTROLF_DISABLED=0x80000000;
+enum MIXERCONTROL_CT_CLASS_MASK=0xF0000000;
+enum MIXERCONTROL_CT_CLASS_CUSTOM=0;
+enum MIXERCONTROL_CT_CLASS_METER=0x10000000;
+enum MIXERCONTROL_CT_CLASS_SWITCH=0x20000000;
+enum MIXERCONTROL_CT_CLASS_NUMBER=0x30000000;
+enum MIXERCONTROL_CT_CLASS_SLIDER=0x40000000;
+enum MIXERCONTROL_CT_CLASS_FADER=0x50000000;
+enum MIXERCONTROL_CT_CLASS_TIME=0x60000000;
+enum MIXERCONTROL_CT_CLASS_LIST=0x70000000;
+enum MIXERCONTROL_CT_SUBCLASS_MASK=0xF000000;
+enum MIXERCONTROL_CT_SC_SWITCH_BOOLEAN=0;
+enum MIXERCONTROL_CT_SC_SWITCH_BUTTON=0x1000000;
+enum MIXERCONTROL_CT_SC_METER_POLLED=0;
+enum MIXERCONTROL_CT_SC_TIME_MICROSECS=0;
+enum MIXERCONTROL_CT_SC_TIME_MILLISECS=0x1000000;
+enum MIXERCONTROL_CT_SC_LIST_SINGLE=0;
+enum MIXERCONTROL_CT_SC_LIST_MULTIPLE=0x1000000;
+enum MIXERCONTROL_CT_UNITS_MASK=0xFF0000;
+enum MIXERCONTROL_CT_UNITS_CUSTOM=0;
+enum MIXERCONTROL_CT_UNITS_BOOLEAN=0x10000;
+enum MIXERCONTROL_CT_UNITS_SIGNED=0x20000;
+enum MIXERCONTROL_CT_UNITS_UNSIGNED=0x30000;
+enum MIXERCONTROL_CT_UNITS_DECIBELS=0x40000;
+enum MIXERCONTROL_CT_UNITS_PERCENT=0x50000;
+
+enum MIXERCONTROL_CONTROLTYPE_CUSTOM=(MIXERCONTROL_CT_CLASS_CUSTOM|MIXERCONTROL_CT_UNITS_CUSTOM);
+enum MIXERCONTROL_CONTROLTYPE_BOOLEANMETER=(MIXERCONTROL_CT_CLASS_METER|MIXERCONTROL_CT_SC_METER_POLLED|MIXERCONTROL_CT_UNITS_BOOLEAN);
+enum MIXERCONTROL_CONTROLTYPE_SIGNEDMETER=(MIXERCONTROL_CT_CLASS_METER|MIXERCONTROL_CT_SC_METER_POLLED|MIXERCONTROL_CT_UNITS_SIGNED);
+enum MIXERCONTROL_CONTROLTYPE_PEAKMETER=(MIXERCONTROL_CONTROLTYPE_SIGNEDMETER+1);
+enum MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER=(MIXERCONTROL_CT_CLASS_METER|MIXERCONTROL_CT_SC_METER_POLLED|MIXERCONTROL_CT_UNITS_UNSIGNED);
+enum MIXERCONTROL_CONTROLTYPE_BOOLEAN=(MIXERCONTROL_CT_CLASS_SWITCH|MIXERCONTROL_CT_SC_SWITCH_BOOLEAN|MIXERCONTROL_CT_UNITS_BOOLEAN);
+enum MIXERCONTROL_CONTROLTYPE_ONOFF=(MIXERCONTROL_CONTROLTYPE_BOOLEAN+1);
+enum MIXERCONTROL_CONTROLTYPE_MUTE=(MIXERCONTROL_CONTROLTYPE_BOOLEAN+2);
+enum MIXERCONTROL_CONTROLTYPE_MONO=(MIXERCONTROL_CONTROLTYPE_BOOLEAN+3);
+enum MIXERCONTROL_CONTROLTYPE_LOUDNESS=(MIXERCONTROL_CONTROLTYPE_BOOLEAN+4);
+enum MIXERCONTROL_CONTROLTYPE_STEREOENH=(MIXERCONTROL_CONTROLTYPE_BOOLEAN+5);
+enum MIXERCONTROL_CONTROLTYPE_BUTTON=(MIXERCONTROL_CT_CLASS_SWITCH|MIXERCONTROL_CT_SC_SWITCH_BUTTON|MIXERCONTROL_CT_UNITS_BOOLEAN);
+enum MIXERCONTROL_CONTROLTYPE_DECIBELS=(MIXERCONTROL_CT_CLASS_NUMBER|MIXERCONTROL_CT_UNITS_DECIBELS);
+enum MIXERCONTROL_CONTROLTYPE_SIGNED=(MIXERCONTROL_CT_CLASS_NUMBER|MIXERCONTROL_CT_UNITS_SIGNED);
+enum MIXERCONTROL_CONTROLTYPE_UNSIGNED=(MIXERCONTROL_CT_CLASS_NUMBER|MIXERCONTROL_CT_UNITS_UNSIGNED);
+enum MIXERCONTROL_CONTROLTYPE_PERCENT=(MIXERCONTROL_CT_CLASS_NUMBER|MIXERCONTROL_CT_UNITS_PERCENT);
+enum MIXERCONTROL_CONTROLTYPE_SLIDER=(MIXERCONTROL_CT_CLASS_SLIDER|MIXERCONTROL_CT_UNITS_SIGNED);
+enum MIXERCONTROL_CONTROLTYPE_PAN=(MIXERCONTROL_CONTROLTYPE_SLIDER+1);
+enum MIXERCONTROL_CONTROLTYPE_QSOUNDPAN=(MIXERCONTROL_CONTROLTYPE_SLIDER+2);
+enum MIXERCONTROL_CONTROLTYPE_FADER=(MIXERCONTROL_CT_CLASS_FADER|MIXERCONTROL_CT_UNITS_UNSIGNED);
+enum MIXERCONTROL_CONTROLTYPE_VOLUME=(MIXERCONTROL_CONTROLTYPE_FADER+1);
+enum MIXERCONTROL_CONTROLTYPE_BASS=(MIXERCONTROL_CONTROLTYPE_FADER+2);
+enum MIXERCONTROL_CONTROLTYPE_TREBLE=(MIXERCONTROL_CONTROLTYPE_FADER+3);
+enum MIXERCONTROL_CONTROLTYPE_EQUALIZER=(MIXERCONTROL_CONTROLTYPE_FADER+4);
+enum MIXERCONTROL_CONTROLTYPE_SINGLESELECT=(MIXERCONTROL_CT_CLASS_LIST|MIXERCONTROL_CT_SC_LIST_SINGLE|MIXERCONTROL_CT_UNITS_BOOLEAN);
+enum MIXERCONTROL_CONTROLTYPE_MUX=(MIXERCONTROL_CONTROLTYPE_SINGLESELECT+1);
+enum MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT=(MIXERCONTROL_CT_CLASS_LIST|MIXERCONTROL_CT_SC_LIST_MULTIPLE|MIXERCONTROL_CT_UNITS_BOOLEAN);
+enum MIXERCONTROL_CONTROLTYPE_MIXER=(MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT+1);
+enum MIXERCONTROL_CONTROLTYPE_MICROTIME=(MIXERCONTROL_CT_CLASS_TIME|MIXERCONTROL_CT_SC_TIME_MICROSECS|MIXERCONTROL_CT_UNITS_UNSIGNED);
+enum MIXERCONTROL_CONTROLTYPE_MILLITIME=(MIXERCONTROL_CT_CLASS_TIME|MIXERCONTROL_CT_SC_TIME_MILLISECS|MIXERCONTROL_CT_UNITS_UNSIGNED);
+
+enum MIXER_GETLINECONTROLSF_ALL=0;
+enum MIXER_GETLINECONTROLSF_ONEBYID=1;
+enum MIXER_GETLINECONTROLSF_ONEBYTYPE=2;
+enum MIXER_GETLINECONTROLSF_QUERYMASK=15;
+enum MIXER_GETCONTROLDETAILSF_VALUE=0;
+enum MIXER_GETCONTROLDETAILSF_LISTTEXT=1;
+enum MIXER_GETCONTROLDETAILSF_QUERYMASK=15;
+enum MIXER_SETCONTROLDETAILSF_VALUE=0;
+enum MIXER_SETCONTROLDETAILSF_CUSTOM=1;
+enum MIXER_SETCONTROLDETAILSF_QUERYMASK=15;
+
+enum TIMERR_NOERROR=0;
+enum TIMERR_NOCANDO=(TIMERR_BASE+1);
+enum TIMERR_STRUCT=(TIMERR_BASE+33);
+enum TIME_ONESHOT=0;
+enum TIME_PERIODIC=1;
+enum TIME_CALLBACK_FUNCTION=0;
+enum TIME_CALLBACK_EVENT_SET=16;
+enum TIME_CALLBACK_EVENT_PULSE=32;
+
+static if (_WIN32_WINNT >= 0x501) {
+
+enum TIME_KILL_SYNCHRONOUS=0x0100;
+
+}
+
+enum JOYERR_NOERROR = 0;
+enum JOYERR_PARMS=(JOYERR_BASE+5);
+enum JOYERR_NOCANDO=(JOYERR_BASE+6);
+enum JOYERR_UNPLUGGED=(JOYERR_BASE+7);
+
+enum JOY_BUTTON1=1;
+enum JOY_BUTTON2=2;
+enum JOY_BUTTON3=4;
+enum JOY_BUTTON4=8;
+enum JOY_BUTTON1CHG=256;
+enum JOY_BUTTON2CHG=512;
+enum JOY_BUTTON3CHG=1024;
+enum JOY_BUTTON4CHG=2048;
+enum JOY_BUTTON5=257;
+enum JOY_BUTTON6=513;
+enum JOY_BUTTON7=1025;
+enum JOY_BUTTON8=2049;
+enum JOY_BUTTON9=256;
+enum JOY_BUTTON10=512;
+enum JOY_BUTTON11=1024;
+enum JOY_BUTTON12=2048;
+enum JOY_BUTTON13=4096;
+enum JOY_BUTTON14=8192;
+enum JOY_BUTTON15=16384;
+enum JOY_BUTTON16=32768;
+enum JOY_BUTTON17=65536;
+enum JOY_BUTTON18=0x20000;
+enum JOY_BUTTON19=0x40000;
+enum JOY_BUTTON20=0x80000;
+enum JOY_BUTTON21=0x100000;
+enum JOY_BUTTON22=0x200000;
+enum JOY_BUTTON23=0x400000;
+enum JOY_BUTTON24=0x800000;
+enum JOY_BUTTON25=0x1000000;
+enum JOY_BUTTON26=0x2000000;
+enum JOY_BUTTON27=0x4000000;
+enum JOY_BUTTON28=0x8000000;
+enum JOY_BUTTON29=0x10000000;
+enum JOY_BUTTON30=0x20000000;
+enum JOY_BUTTON31=0x40000000;
+enum JOY_BUTTON32=0x80000000;
+
+enum  : DWORD {
+    JOY_POVCENTERED = -1,
+    JOY_POVFORWARD  = 0,
+    JOY_POVBACKWARD = 18000,
+    JOY_POVLEFT     = 27000,
+    JOY_POVRIGHT    = 9000
+}
+
+enum DWORD
+    JOY_RETURNX        = 0x00000001,
+    JOY_RETURNY        = 0x00000002,
+    JOY_RETURNZ        = 0x00000004,
+    JOY_RETURNR        = 0x00000008,
+    JOY_RETURNU        = 0x00000010,
+    JOY_RETURNV        = 0x00000020,
+    JOY_RETURNPOV      = 0x00000040,
+    JOY_RETURNBUTTONS  = 0x00000080,
+    JOY_RETURNRAWDATA  = 0x00000100,
+    JOY_RETURNPOVCTS   = 0x00000200,
+    JOY_RETURNCENTERED = 0x00000400,
+    JOY_USEDEADZONE    = 0x00000800,
+    JOY_RETURNALL      = JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ | JOY_RETURNR
+                         | JOY_RETURNU | JOY_RETURNV | JOY_RETURNPOV
+                         | JOY_RETURNBUTTONS,
+    JOY_CAL_READALWAYS = 0x00010000,
+    JOY_CAL_READXYONLY = 0x00020000,
+    JOY_CAL_READ3      = 0x00040000,
+    JOY_CAL_READ4      = 0x00080000,
+    JOY_CAL_READXONLY  = 0x00100000,
+    JOY_CAL_READYONLY  = 0x00200000,
+    JOY_CAL_READ5      = 0x00400000,
+    JOY_CAL_READ6      = 0x00800000,
+    JOY_CAL_READZONLY  = 0x01000000,
+    JOY_CAL_READRONLY  = 0x02000000,
+    JOY_CAL_READUONLY  = 0x04000000,
+    JOY_CAL_READVONLY  = 0x08000000;
+
+enum JOYSTICKID1=0;
+enum JOYSTICKID2=1;
+
+enum JOYCAPS_HASZ=1;
+enum JOYCAPS_HASR=2;
+enum JOYCAPS_HASU=4;
+enum JOYCAPS_HASV=8;
+enum JOYCAPS_HASPOV=16;
+enum JOYCAPS_POV4DIR=32;
+enum JOYCAPS_POVCTS=64;
+
+enum MMIOERR_BASE=256;
+enum MMIOERR_FILENOTFOUND=(MMIOERR_BASE+1);
+enum MMIOERR_OUTOFMEMORY=(MMIOERR_BASE+2);
+enum MMIOERR_CANNOTOPEN=(MMIOERR_BASE+3);
+enum MMIOERR_CANNOTCLOSE=(MMIOERR_BASE+4);
+enum MMIOERR_CANNOTREAD=(MMIOERR_BASE+5);
+enum MMIOERR_CANNOTWRITE=(MMIOERR_BASE+6);
+enum MMIOERR_CANNOTSEEK=(MMIOERR_BASE+7);
+enum MMIOERR_CANNOTEXPAND=(MMIOERR_BASE+8);
+enum MMIOERR_CHUNKNOTFOUND=(MMIOERR_BASE+9);
+enum MMIOERR_UNBUFFERED=(MMIOERR_BASE+10);
+enum MMIOERR_PATHNOTFOUND=(MMIOERR_BASE+11);
+enum MMIOERR_ACCESSDENIED=(MMIOERR_BASE+12);
+enum MMIOERR_SHARINGVIOLATION=(MMIOERR_BASE+13);
+enum MMIOERR_NETWORKERROR=(MMIOERR_BASE+14);
+enum MMIOERR_TOOMANYOPENFILES=(MMIOERR_BASE+15);
+enum MMIOERR_INVALIDFILE=(MMIOERR_BASE+16);
+
+enum CFSEPCHAR='+';
+
+enum MMIO_RWMODE=3;
+enum MMIO_SHAREMODE=0x70;
+enum MMIO_CREATE=0x1000;
+enum MMIO_PARSE=256;
+enum MMIO_DELETE=512;
+enum MMIO_EXIST=0x4000;
+enum MMIO_ALLOCBUF=0x10000;
+enum MMIO_GETTEMP=0x20000;
+enum MMIO_DIRTY=0x10000000;
+enum MMIO_READ=0;
+enum MMIO_WRITE=1;
+enum MMIO_READWRITE=2;
+enum MMIO_COMPAT=0;
+enum MMIO_EXCLUSIVE=16;
+enum MMIO_DENYWRITE=32;
+enum MMIO_DENYREAD=0x30;
+enum MMIO_DENYNONE=64;
+enum MMIO_FHOPEN=16;
+enum MMIO_EMPTYBUF=16;
+enum MMIO_TOUPPER=16;
+enum MMIO_INSTALLPROC=0x10000;
+enum MMIO_GLOBALPROC=0x10000000;
+enum MMIO_REMOVEPROC=0x20000;
+enum MMIO_UNICODEPROC=0x1000000;
+enum MMIO_FINDPROC=0x40000;
+enum MMIO_FINDCHUNK=16;
+enum MMIO_FINDRIFF=32;
+enum MMIO_FINDLIST=64;
+enum MMIO_CREATERIFF=32;
+enum MMIO_CREATELIST=64;
+enum MMIOM_READ=MMIO_READ;
+enum MMIOM_WRITE=MMIO_WRITE;
+enum MMIOM_SEEK=2;
+enum MMIOM_OPEN=3;
+enum MMIOM_CLOSE=4;
+enum MMIOM_WRITEFLUSH=5;
+enum MMIOM_RENAME=6;
+enum MMIOM_USER=0x8000;
+
+enum FOURCC_RIFF = mmioFOURCC!('R', 'I', 'F', 'F');
+enum FOURCC_LIST = mmioFOURCC!('L', 'I', 'S', 'T');
+enum FOURCC_DOS  = mmioFOURCC!('D', 'O', 'S', ' ');
+enum FOURCC_MEM  = mmioFOURCC!('M', 'E', 'M', ' ');
+
+enum MMIO_DEFAULTBUFFER=8192;
+
+enum {
+    MCIERR_INVALID_DEVICE_ID = MCIERR_BASE + 1,
+    MCIERR_UNRECOGNIZED_KEYWORD = MCIERR_BASE + 3,
+    MCIERR_UNRECOGNIZED_COMMAND = MCIERR_BASE + 5,
+    MCIERR_HARDWARE,
+    MCIERR_INVALID_DEVICE_NAME,
+    MCIERR_OUT_OF_MEMORY,
+    MCIERR_DEVICE_OPEN,
+    MCIERR_CANNOT_LOAD_DRIVER,
+    MCIERR_MISSING_COMMAND_STRING,
+    MCIERR_PARAM_OVERFLOW,
+    MCIERR_MISSING_STRING_ARGUMENT,
+    MCIERR_BAD_INTEGER,
+    MCIERR_PARSER_INTERNAL,
+    MCIERR_DRIVER_INTERNAL,
+    MCIERR_MISSING_PARAMETER,
+    MCIERR_UNSUPPORTED_FUNCTION,
+    MCIERR_FILE_NOT_FOUND,
+    MCIERR_DEVICE_NOT_READY,
+    MCIERR_INTERNAL,
+    MCIERR_DRIVER,
+    MCIERR_CANNOT_USE_ALL,
+    MCIERR_MULTIPLE,
+    MCIERR_EXTENSION_NOT_FOUND,
+    MCIERR_OUTOFRANGE, // = MCIERR_BASE+26
+    MCIERR_FLAGS_NOT_COMPATIBLE = MCIERR_BASE + 28,
+    MCIERR_FILE_NOT_SAVED = MCIERR_BASE + 30,
+    MCIERR_DEVICE_TYPE_REQUIRED,
+    MCIERR_DEVICE_LOCKED,
+    MCIERR_DUPLICATE_ALIAS,
+    MCIERR_BAD_CONSTANT,
+    MCIERR_MUST_USE_SHAREABLE,
+    MCIERR_MISSING_DEVICE_NAME,
+    MCIERR_BAD_TIME_FORMAT,
+    MCIERR_NO_CLOSING_QUOTE,
+    MCIERR_DUPLICATE_FLAGS,
+    MCIERR_INVALID_FILE,
+    MCIERR_NULL_PARAMETER_BLOCK,
+    MCIERR_UNNAMED_RESOURCE,
+    MCIERR_NEW_REQUIRES_ALIAS,
+    MCIERR_NOTIFY_ON_AUTO_OPEN,
+    MCIERR_NO_ELEMENT_ALLOWED,
+    MCIERR_NONAPPLICABLE_FUNCTION,
+    MCIERR_ILLEGAL_FOR_AUTO_OPEN,
+    MCIERR_FILENAME_REQUIRED,
+    MCIERR_EXTRA_CHARACTERS,
+    MCIERR_DEVICE_NOT_INSTALLED,
+    MCIERR_GET_CD,
+    MCIERR_SET_CD,
+    MCIERR_SET_DRIVE,
+    MCIERR_DEVICE_LENGTH,
+    MCIERR_DEVICE_ORD_LENGTH,
+    MCIERR_NO_INTEGER, // = MCIERR_BASE + 56
+    MCIERR_WAVE_OUTPUTSINUSE = MCIERR_BASE + 64,
+    MCIERR_WAVE_SETOUTPUTINUSE,
+    MCIERR_WAVE_INPUTSINUSE,
+    MCIERR_WAVE_SETINPUTINUSE,
+    MCIERR_WAVE_OUTPUTUNSPECIFIED,
+    MCIERR_WAVE_INPUTUNSPECIFIED,
+    MCIERR_WAVE_OUTPUTSUNSUITABLE,
+    MCIERR_WAVE_SETOUTPUTUNSUITABLE,
+    MCIERR_WAVE_INPUTSUNSUITABLE,
+    MCIERR_WAVE_SETINPUTUNSUITABLE, // = MCIERR_BASE + 73
+    MCIERR_SEQ_DIV_INCOMPATIBLE = MCIERR_BASE + 80,
+    MCIERR_SEQ_PORT_INUSE,
+    MCIERR_SEQ_PORT_NONEXISTENT,
+    MCIERR_SEQ_PORT_MAPNODEVICE,
+    MCIERR_SEQ_PORT_MISCERROR,
+    MCIERR_SEQ_TIMER,
+    MCIERR_SEQ_PORTUNSPECIFIED,
+    MCIERR_SEQ_NOMIDIPRESENT, // = MCIERR_BASE + 87
+    MCIERR_NO_WINDOW = MCIERR_BASE + 90,
+    MCIERR_CREATEWINDOW,
+    MCIERR_FILE_READ,
+    MCIERR_FILE_WRITE,
+    MCIERR_NO_IDENTITY // = MCIERR_BASE + 94
+}
+enum MCIERR_CUSTOM_DRIVER_BASE = MCIERR_BASE + 256;
+
+enum MCI_FIRST=DRV_MCI_FIRST;
+enum MCI_OPEN=0x803;
+enum MCI_CLOSE=0x804;
+enum MCI_ESCAPE=0x805;
+enum MCI_PLAY=0x806;
+enum MCI_SEEK=0x807;
+enum MCI_STOP=0x808;
+enum MCI_PAUSE=0x809;
+enum MCI_INFO=0x80A;
+enum MCI_GETDEVCAPS=0x80B;
+enum MCI_SPIN=0x80C;
+enum MCI_SET=0x80D;
+enum MCI_STEP=0x80E;
+enum MCI_RECORD=0x80F;
+enum MCI_SYSINFO=0x810;
+enum MCI_BREAK=0x811;
+enum MCI_SAVE=0x813;
+enum MCI_STATUS=0x814;
+enum MCI_CUE=0x830;
+enum MCI_REALIZE=0x840;
+enum MCI_WINDOW=0x841;
+enum MCI_PUT=0x842;
+enum MCI_WHERE=0x843;
+enum MCI_FREEZE=0x844;
+enum MCI_UNFREEZE=0x845;
+enum MCI_LOAD=0x850;
+enum MCI_CUT=0x851;
+enum MCI_COPY=0x852;
+enum MCI_PASTE=0x853;
+enum MCI_UPDATE=0x854;
+enum MCI_RESUME=0x855;
+enum MCI_DELETE=0x856;
+enum MCI_USER_MESSAGES=(DRV_MCI_FIRST+0x400);
+enum MCI_LAST=0xFFF;
+
+enum MCIDEVICEID MCI_ALL_DEVICE_ID = -1;
+
+enum MCI_DEVTYPE_VCR=513;
+enum MCI_DEVTYPE_VIDEODISC=514;
+enum MCI_DEVTYPE_OVERLAY=515;
+enum MCI_DEVTYPE_CD_AUDIO=516;
+enum MCI_DEVTYPE_DAT=517;
+enum MCI_DEVTYPE_SCANNER=518;
+enum MCI_DEVTYPE_ANIMATION=519;
+enum MCI_DEVTYPE_DIGITAL_VIDEO=520;
+enum MCI_DEVTYPE_OTHER=521;
+enum MCI_DEVTYPE_WAVEFORM_AUDIO=522;
+enum MCI_DEVTYPE_SEQUENCER=523;
+enum MCI_DEVTYPE_FIRST=MCI_DEVTYPE_VCR;
+enum MCI_DEVTYPE_LAST=MCI_DEVTYPE_SEQUENCER;
+enum MCI_DEVTYPE_FIRST_USER=0x1000;
+enum MCI_MODE_NOT_READY=(MCI_STRING_OFFSET+12);
+enum MCI_MODE_STOP=(MCI_STRING_OFFSET+13);
+enum MCI_MODE_PLAY=(MCI_STRING_OFFSET+14);
+enum MCI_MODE_RECORD=(MCI_STRING_OFFSET+15);
+enum MCI_MODE_SEEK=(MCI_STRING_OFFSET+16);
+enum MCI_MODE_PAUSE=(MCI_STRING_OFFSET+17);
+enum MCI_MODE_OPEN=(MCI_STRING_OFFSET+18);
+enum MCI_FORMAT_MILLISECONDS=0;
+enum MCI_FORMAT_HMS=1;
+enum MCI_FORMAT_MSF=2;
+enum MCI_FORMAT_FRAMES=3;
+enum MCI_FORMAT_SMPTE_24=4;
+enum MCI_FORMAT_SMPTE_25=5;
+enum MCI_FORMAT_SMPTE_30=6;
+enum MCI_FORMAT_SMPTE_30DROP=7;
+enum MCI_FORMAT_BYTES=8;
+enum MCI_FORMAT_SAMPLES=9;
+enum MCI_FORMAT_TMSF=10;
+
+
+
+
+// Macros
+BYTE MCI_HMS_HOUR(DWORD t) { return cast(BYTE)(t); }
+BYTE MCI_HMS_MINUTE(DWORD t) { return cast(BYTE)(t>>>8); }
+BYTE MCI_HMS_SECOND(DWORD t) { return cast(BYTE)( t>>>16); }
+DWORD MCI_MAKE_HMS(BYTE h, BYTE m, BYTE s) { return h |(m<<8)|(cast(DWORD)(s)<<16); }
+DWORD MCI_MAKE_MSF(BYTE m, BYTE s, BYTE f) { return m |(s<<8)|(cast(DWORD)(f)<<16); }
+DWORD MCI_MAKE_TMSF(BYTE t, BYTE m, BYTE s, BYTE f) {
+ return t |(m<<8)|(s<<16)|(cast(DWORD)(f)<< 24); }
+
+BYTE MCI_MSF_MINUTE(DWORD t) { return cast(BYTE)(t); }
+BYTE MCI_MSF_SECOND(DWORD t) { return cast(BYTE)(t >>> 8); }
+BYTE MCI_MSF_FRAME(DWORD t)  {  return cast(BYTE)(t >>> 16); }
+
+BYTE MCI_TMSF_TRACK(DWORD t)  { return cast(BYTE)(t); }
+BYTE MCI_TMSF_MINUTE(DWORD t) { return cast(BYTE)(t>>8); }
+BYTE MCI_TMSF_SECOND(DWORD t) { return cast(BYTE)(t>>16); }
+BYTE MCI_TMSF_FRAME(DWORD t)  { return cast(BYTE)(t>>24); }
+
+
+enum MCI_NOTIFY_SUCCESSFUL=1;
+enum MCI_NOTIFY_SUPERSEDED=2;
+enum MCI_NOTIFY_ABORTED=4;
+enum MCI_NOTIFY_FAILURE=8;
+enum MCI_NOTIFY=1;
+enum MCI_WAIT=2;
+enum MCI_FROM=4;
+enum MCI_TO=8;
+enum MCI_TRACK=16;
+enum MCI_OPEN_SHAREABLE=256;
+enum MCI_OPEN_ELEMENT=512;
+enum MCI_OPEN_ALIAS=1024;
+enum MCI_OPEN_ELEMENT_ID=2048;
+enum MCI_OPEN_TYPE_ID=0x1000;
+enum MCI_OPEN_TYPE=0x2000;
+enum MCI_SEEK_TO_START=256;
+enum MCI_SEEK_TO_END=512;
+enum MCI_STATUS_ITEM=256;
+enum MCI_STATUS_START=512;
+enum MCI_STATUS_LENGTH=1;
+enum MCI_STATUS_POSITION=2;
+enum MCI_STATUS_NUMBER_OF_TRACKS=3;
+enum MCI_STATUS_MODE=4;
+enum MCI_STATUS_MEDIA_PRESENT=5;
+enum MCI_STATUS_TIME_FORMAT=6;
+enum MCI_STATUS_READY=7;
+enum MCI_STATUS_CURRENT_TRACK=8;
+enum MCI_INFO_PRODUCT=256;
+enum MCI_INFO_FILE=512;
+enum MCI_INFO_MEDIA_UPC=1024;
+enum MCI_INFO_MEDIA_IDENTITY=2048;
+enum MCI_INFO_NAME=0x1000;
+enum MCI_INFO_COPYRIGHT=0x2000;
+
+enum MCI_GETDEVCAPS_ITEM=256;
+enum MCI_GETDEVCAPS_CAN_RECORD=1;
+enum MCI_GETDEVCAPS_HAS_AUDIO=2;
+enum MCI_GETDEVCAPS_HAS_VIDEO=3;
+enum MCI_GETDEVCAPS_DEVICE_TYPE=4;
+enum MCI_GETDEVCAPS_USES_FILES=5;
+enum MCI_GETDEVCAPS_COMPOUND_DEVICE=6;
+enum MCI_GETDEVCAPS_CAN_EJECT=7;
+enum MCI_GETDEVCAPS_CAN_PLAY=8;
+enum MCI_GETDEVCAPS_CAN_SAVE=9;
+
+enum MCI_SYSINFO_QUANTITY=256;
+enum MCI_SYSINFO_OPEN=512;
+enum MCI_SYSINFO_NAME=1024;
+enum MCI_SYSINFO_INSTALLNAME=2048;
+enum MCI_SET_DOOR_OPEN=256;
+enum MCI_SET_DOOR_CLOSED=512;
+enum MCI_SET_TIME_FORMAT=1024;
+enum MCI_SET_AUDIO=2048;
+enum MCI_SET_VIDEO=0x1000;
+enum MCI_SET_ON=0x2000;
+enum MCI_SET_OFF=0x4000;
+
+enum MCI_SET_AUDIO_ALL=0;
+enum MCI_SET_AUDIO_LEFT=1;
+enum MCI_SET_AUDIO_RIGHT=2;
+
+enum MCI_BREAK_KEY=256;
+enum MCI_BREAK_HWND=512;
+enum MCI_BREAK_OFF=1024;
+
+enum MCI_RECORD_INSERT=256;
+enum MCI_RECORD_OVERWRITE=512;
+enum MCI_SAVE_FILE=256;
+enum MCI_LOAD_FILE=256;
+
+enum MCI_VD_MODE_PARK=(MCI_VD_OFFSET+1);
+enum MCI_VD_MEDIA_CLV=(MCI_VD_OFFSET+2);
+enum MCI_VD_MEDIA_CAV=(MCI_VD_OFFSET+3);
+enum MCI_VD_MEDIA_OTHER=(MCI_VD_OFFSET+4);
+
+enum MCI_VD_FORMAT_TRACK=0x4001;
+enum MCI_VD_PLAY_REVERSE=0x10000;
+enum MCI_VD_PLAY_FAST=0x20000;
+enum MCI_VD_PLAY_SPEED=0x40000;
+enum MCI_VD_PLAY_SCAN=0x80000;
+enum MCI_VD_PLAY_SLOW=0x100000;
+enum MCI_VD_SEEK_REVERSE=0x10000;
+enum MCI_VD_STATUS_SPEED=0x4002;
+enum MCI_VD_STATUS_FORWARD=0x4003;
+enum MCI_VD_STATUS_MEDIA_TYPE=0x4004;
+enum MCI_VD_STATUS_SIDE=0x4005;
+enum MCI_VD_STATUS_DISC_SIZE=0x4006;
+enum MCI_VD_GETDEVCAPS_CLV=0x10000;
+enum MCI_VD_GETDEVCAPS_CAV=0x20000;
+enum MCI_VD_SPIN_UP=0x10000;
+enum MCI_VD_SPIN_DOWN=0x20000;
+enum MCI_VD_GETDEVCAPS_CAN_REVERSE=0x4002;
+enum MCI_VD_GETDEVCAPS_FAST_RATE=0x4003;
+enum MCI_VD_GETDEVCAPS_SLOW_RATE=0x4004;
+enum MCI_VD_GETDEVCAPS_NORMAL_RATE=0x4005;
+enum MCI_VD_STEP_FRAMES=0x10000;
+enum MCI_VD_STEP_REVERSE=0x20000;
+enum MCI_VD_ESCAPE_STRING=256;
+
+enum MCI_CDA_STATUS_TYPE_TRACK=0x4001;
+enum MCI_CDA_TRACK_AUDIO=MCI_CD_OFFSET;
+enum MCI_CDA_TRACK_OTHER=(MCI_CD_OFFSET+1);
+
+enum MCI_WAVE_PCM=MCI_WAVE_OFFSET;
+enum MCI_WAVE_MAPPER=(MCI_WAVE_OFFSET+1);
+enum MCI_WAVE_OPEN_BUFFER=0x10000;
+enum MCI_WAVE_SET_FORMATTAG=0x10000;
+enum MCI_WAVE_SET_CHANNELS=0x20000;
+enum MCI_WAVE_SET_SAMPLESPERSEC=0x40000;
+enum MCI_WAVE_SET_AVGBYTESPERSEC=0x80000;
+enum MCI_WAVE_SET_BLOCKALIGN=0x100000;
+enum MCI_WAVE_SET_BITSPERSAMPLE=0x200000;
+enum MCI_WAVE_INPUT=0x400000;
+enum MCI_WAVE_OUTPUT=0x800000;
+enum MCI_WAVE_STATUS_FORMATTAG=0x4001;
+enum MCI_WAVE_STATUS_CHANNELS=0x4002;
+enum MCI_WAVE_STATUS_SAMPLESPERSEC=0x4003;
+enum MCI_WAVE_STATUS_AVGBYTESPERSEC=0x4004;
+enum MCI_WAVE_STATUS_BLOCKALIGN=0x4005;
+enum MCI_WAVE_STATUS_BITSPERSAMPLE=0x4006;
+enum MCI_WAVE_STATUS_LEVEL=0x4007;
+enum MCI_WAVE_SET_ANYINPUT=0x4000000;
+enum MCI_WAVE_SET_ANYOUTPUT=0x8000000;
+enum MCI_WAVE_GETDEVCAPS_INPUTS=0x4001;
+enum MCI_WAVE_GETDEVCAPS_OUTPUTS=0x4002;
+
+enum MCI_SEQ_DIV_PPQN=MCI_SEQ_OFFSET;
+enum MCI_SEQ_DIV_SMPTE_24=(MCI_SEQ_OFFSET+1);
+enum MCI_SEQ_DIV_SMPTE_25=(MCI_SEQ_OFFSET+2);
+enum MCI_SEQ_DIV_SMPTE_30DROP=(MCI_SEQ_OFFSET+3);
+enum MCI_SEQ_DIV_SMPTE_30=(MCI_SEQ_OFFSET+4);
+enum MCI_SEQ_FORMAT_SONGPTR=0x4001;
+enum MCI_SEQ_FILE=0x4002;
+enum MCI_SEQ_MIDI=0x4003;
+enum MCI_SEQ_SMPTE=0x4004;
+enum MCI_SEQ_NONE=65533;
+enum MCI_SEQ_MAPPER=65535;
+
+enum MCI_SEQ_STATUS_TEMPO=0x4002;
+enum MCI_SEQ_STATUS_PORT=0x4003;
+enum MCI_SEQ_STATUS_SLAVE=0x4007;
+enum MCI_SEQ_STATUS_MASTER=0x4008;
+enum MCI_SEQ_STATUS_OFFSET=0x4009;
+enum MCI_SEQ_STATUS_DIVTYPE=0x400A;
+enum MCI_SEQ_STATUS_NAME=0x400B;
+enum MCI_SEQ_STATUS_COPYRIGHT=0x400C;
+
+enum MCI_SEQ_SET_TEMPO=0x10000;
+enum MCI_SEQ_SET_PORT=0x20000;
+enum MCI_SEQ_SET_SLAVE=0x40000;
+enum MCI_SEQ_SET_MASTER=0x80000;
+enum MCI_SEQ_SET_OFFSET=0x1000000;
+
+enum MCI_ANIM_OPEN_WS=0x10000;
+enum MCI_ANIM_OPEN_PARENT=0x20000;
+enum MCI_ANIM_OPEN_NOSTATIC=0x40000;
+enum MCI_ANIM_PLAY_SPEED=0x10000;
+enum MCI_ANIM_PLAY_REVERSE=0x20000;
+enum MCI_ANIM_PLAY_FAST=0x40000;
+enum MCI_ANIM_PLAY_SLOW=0x80000;
+enum MCI_ANIM_PLAY_SCAN=0x100000;
+enum MCI_ANIM_STEP_REVERSE=0x10000;
+enum MCI_ANIM_STEP_FRAMES=0x20000;
+enum MCI_ANIM_STATUS_SPEED=0x4001;
+enum MCI_ANIM_STATUS_FORWARD=0x4002;
+enum MCI_ANIM_STATUS_HWND=0x4003;
+enum MCI_ANIM_STATUS_HPAL=0x4004;
+enum MCI_ANIM_STATUS_STRETCH=0x4005;
+enum MCI_ANIM_INFO_TEXT=0x10000;
+
+enum MCI_ANIM_GETDEVCAPS_CAN_REVERSE=0x4001;
+enum MCI_ANIM_GETDEVCAPS_FAST_RATE=0x4002;
+enum MCI_ANIM_GETDEVCAPS_SLOW_RATE=0x4003;
+enum MCI_ANIM_GETDEVCAPS_NORMAL_RATE=0x4004;
+enum MCI_ANIM_GETDEVCAPS_PALETTES=0x4006;
+enum MCI_ANIM_GETDEVCAPS_CAN_STRETCH=0x4007;
+enum MCI_ANIM_GETDEVCAPS_MAX_WINDOWS=0x4008;
+
+enum MCI_ANIM_REALIZE_NORM=0x10000;
+enum MCI_ANIM_REALIZE_BKGD=0x20000;
+
+enum MCI_ANIM_WINDOW_HWND=0x10000;
+enum MCI_ANIM_WINDOW_STATE=0x40000;
+enum MCI_ANIM_WINDOW_TEXT=0x80000;
+enum MCI_ANIM_WINDOW_ENABLE_STRETCH=0x100000;
+enum MCI_ANIM_WINDOW_DISABLE_STRETCH=0x200000;
+enum MCI_ANIM_WINDOW_DEFAULT=0x0;
+
+enum MCI_ANIM_RECT=0x10000;
+enum MCI_ANIM_PUT_SOURCE=0x20000;
+enum MCI_ANIM_PUT_DESTINATION=0x40000;
+enum MCI_ANIM_WHERE_SOURCE=0x20000;
+enum MCI_ANIM_WHERE_DESTINATION=0x40000;
+enum MCI_ANIM_UPDATE_HDC=0x20000;
+
+enum MCI_OVLY_OPEN_WS=0x10000;
+enum MCI_OVLY_OPEN_PARENT=0x20000;
+enum MCI_OVLY_STATUS_HWND=0x4001;
+enum MCI_OVLY_STATUS_STRETCH=0x4002;
+enum MCI_OVLY_INFO_TEXT=0x10000;
+enum MCI_OVLY_GETDEVCAPS_CAN_STRETCH=0x4001;
+enum MCI_OVLY_GETDEVCAPS_CAN_FREEZE=0x4002;
+enum MCI_OVLY_GETDEVCAPS_MAX_WINDOWS=0x4003;
+enum MCI_OVLY_WINDOW_HWND=0x10000;
+enum MCI_OVLY_WINDOW_STATE=0x40000;
+enum MCI_OVLY_WINDOW_TEXT=0x80000;
+enum MCI_OVLY_WINDOW_ENABLE_STRETCH=0x100000;
+enum MCI_OVLY_WINDOW_DISABLE_STRETCH=0x200000;
+enum MCI_OVLY_WINDOW_DEFAULT=0x0;
+enum MCI_OVLY_RECT=0x10000;
+enum MCI_OVLY_PUT_SOURCE=0x20000;
+enum MCI_OVLY_PUT_DESTINATION=0x40000;
+enum MCI_OVLY_PUT_FRAME=0x80000;
+enum MCI_OVLY_PUT_VIDEO=0x100000;
+enum MCI_OVLY_WHERE_SOURCE=0x20000;
+enum MCI_OVLY_WHERE_DESTINATION=0x40000;
+enum MCI_OVLY_WHERE_FRAME=0x80000;
+enum MCI_OVLY_WHERE_VIDEO=0x100000;
+
+enum NEWTRANSPARENT=3;
+enum QUERYROPSUPPORT=40;
+enum SELECTDIB=41;
+
+LONG DIBINDEX(WORD n) {
+    return MAKELONG(n, 0x10FF);
+}
+enum CAPS1=94;
+enum C1_TRANSPARENT=1;
+
+//const SEEK_SET=0;
+//const SEEK_CUR=1;
+//const SEEK_END=2;
+public import core.stdc.stdio : SEEK_SET, SEEK_CUR, SEEK_END;
+
+alias DWORD MCIERROR;
+alias UINT MCIDEVICEID;
+alias UINT function (MCIDEVICEID, DWORD) YIELDPROC;
+alias UINT MMVERSION;
+alias UINT MMRESULT;
+
+struct MMTIME {
+    UINT wType;
+    union {
+        DWORD ms;
+        DWORD sample;
+        DWORD cb;
+        DWORD ticks;
+        struct smpte {
+            BYTE hour;
+            BYTE min;
+            BYTE sec;
+            BYTE frame;
+            BYTE fps;
+            BYTE dummy;
+            BYTE[2] pad;
+        };
+        struct midi {
+            DWORD songptrpos;
+        }
+    }
+}
+alias MMTIME* PMMTIME, LPMMTIME;
+
+alias TypeDef!(HANDLE) HDRVR;
+
+struct DRVCONFIGINFO {
+    DWORD dwDCISize;
+    LPCWSTR lpszDCISectionName;
+    LPCWSTR lpszDCIAliasName;
+}
+alias DRVCONFIGINFO * PDRVCONFIGINFO, LPDRVCONFIGINFO;
+
+struct DRVCONFIGINFOEX {
+    DWORD dwDCISize;
+    LPCWSTR lpszDCISectionName;
+    LPCWSTR lpszDCIAliasName;
+    DWORD dnDevNode;
+}
+alias DRVCONFIGINFOEX* PDRVCONFIGINFOEX, LPDRVCONFIGINFOEX;
+
+extern(Windows):
+
+/+FIXME: I couldn't find these in MSDN.
+alias void function (HDRVR, UINT, DWORD, DWORD, DWORD) DRVCALLBACK;
+LRESULT DRIVERPROC (DWORD, HDRVR, UINT, LPARAM, LPARAM);
+alias DRVCALLBACK* LPDRVCALLBACK, PDRVCALLBACK;
+
+alias DRVCALLBACK WAVECALLBACK;
+alias WAVECALLBACK* LPWAVECALLBACK;
+
+alias DRVCALLBACK MIDICALLBACK;
+alias MIDICALLBACK* LPMIDICALLBACK;
+
++/
+
+alias TypeDef!(HANDLE) HWAVE;
+alias TypeDef!(HANDLE) HWAVEIN;
+alias TypeDef!(HANDLE) HWAVEOUT;
+
+alias HWAVEIN* LPHWAVEIN;
+alias HWAVEOUT* LPHWAVEOUT;
+
+struct WAVEHDR {
+    LPSTR lpData;
+    DWORD dwBufferLength;
+    DWORD dwBytesRecorded;
+    DWORD dwUser;
+    DWORD dwFlags;
+    DWORD dwLoops;
+    WAVEHDR *lpNext;
+    DWORD reserved;
+}
+alias WAVEHDR* PWAVEHDR, LPWAVEHDR;
+
+struct WAVEOUTCAPSA {
+    WORD wMid;
+    WORD wPid;
+    MMVERSION vDriverVersion;
+    CHAR[MAXPNAMELEN] szPname;
+    DWORD dwFormats;
+    WORD wChannels;
+    WORD wReserved1;
+    DWORD dwSupport;
+}
+alias WAVEOUTCAPSA* PWAVEOUTCAPSA, LPWAVEOUTCAPSA;
+
+struct WAVEOUTCAPSW {
+    WORD wMid;
+    WORD wPid;
+    MMVERSION vDriverVersion;
+    WCHAR[MAXPNAMELEN] szPname;
+    DWORD dwFormats;
+    WORD wChannels;
+    WORD wReserved1;
+    DWORD dwSupport;
+}
+alias WAVEOUTCAPSW* PWAVEOUTCAPSW, LPWAVEOUTCAPSW;
+
+struct WAVEINCAPSA {
+    WORD wMid;
+    WORD wPid;
+    MMVERSION vDriverVersion;
+    CHAR[MAXPNAMELEN] szPname;
+    DWORD dwFormats;
+    WORD wChannels;
+    WORD wReserved1;
+}
+alias WAVEINCAPSA* PWAVEINCAPSA, LPWAVEINCAPSA;
+
+struct WAVEINCAPSW {
+    WORD wMid;
+    WORD wPid;
+    MMVERSION vDriverVersion;
+    WCHAR[MAXPNAMELEN] szPname;
+    DWORD dwFormats;
+    WORD wChannels;
+    WORD wReserved1;
+}
+alias WAVEINCAPSW* PWAVEINCAPSW, LPWAVEINCAPSW;
+
+struct WAVEFORMAT {
+    WORD wFormatTag;
+    WORD nChannels;
+    DWORD nSamplesPerSec;
+    DWORD nAvgBytesPerSec;
+    WORD nBlockAlign;
+}
+alias WAVEFORMAT* PWAVEFORMAT, LPWAVEFORMAT;
+
+struct PCMWAVEFORMAT {
+    WAVEFORMAT wf;
+    WORD wBitsPerSample;
+}
+alias PCMWAVEFORMAT* PPCMWAVEFORMAT, LPPCMWAVEFORMAT;
+
+struct WAVEFORMATEX {
+    WORD wFormatTag;
+    WORD nChannels;
+    DWORD nSamplesPerSec;
+    DWORD nAvgBytesPerSec;
+    WORD nBlockAlign;
+    WORD wBitsPerSample;
+    WORD cbSize;
+}
+alias WAVEFORMATEX* PWAVEFORMATEX, LPWAVEFORMATEX;
+alias const(WAVEFORMATEX)* LPCWAVEFORMATEX;
+
+alias TypeDef!(HANDLE) HMIDI;
+alias TypeDef!(HANDLE) HMIDIIN;
+alias TypeDef!(HANDLE) HMIDIOUT;
+alias TypeDef!(HANDLE) HMIDISTRM;
+
+alias HMIDI* LPHMIDI;
+alias HMIDIIN* LPHMIDIIN;
+alias HMIDIOUT* LPHMIDIOUT;
+alias HMIDISTRM* LPHMIDISTRM;
+
+alias WORD[MIDIPATCHSIZE] PATCHARRAY;
+alias WORD* LPPATCHARRAY;
+alias WORD[MIDIPATCHSIZE] KEYARRAY;
+alias WORD* LPKEYARRAY;
+
+struct MIDIOUTCAPSA {
+    WORD wMid;
+    WORD wPid;
+    MMVERSION vDriverVersion;
+    CHAR[MAXPNAMELEN] szPname;
+    WORD wTechnology;
+    WORD wVoices;
+    WORD wNotes;
+    WORD wChannelMask;
+    DWORD dwSupport;
+}
+alias MIDIOUTCAPSA* PMIDIOUTCAPSA, LPMIDIOUTCAPSA;
+
+struct MIDIOUTCAPSW {
+    WORD wMid;
+    WORD wPid;
+    MMVERSION vDriverVersion;
+    WCHAR[MAXPNAMELEN] szPname;
+    WORD wTechnology;
+    WORD wVoices;
+    WORD wNotes;
+    WORD wChannelMask;
+    DWORD dwSupport;
+}
+alias MIDIOUTCAPSW* PMIDIOUTCAPSW, LPMIDIOUTCAPSW;
+
+struct MIDIINCAPSA {
+    WORD wMid;
+    WORD wPid;
+    MMVERSION vDriverVersion;
+    CHAR[MAXPNAMELEN] szPname;
+    DWORD dwSupport;
+}
+alias MIDIINCAPSA* PMIDIINCAPSA, LPMIDIINCAPSA;
+
+struct MIDIINCAPSW {
+    WORD wMid;
+    WORD wPid;
+    MMVERSION vDriverVersion;
+    WCHAR[MAXPNAMELEN] szPname;
+    DWORD dwSupport;
+}
+alias MIDIINCAPSW* PMIDIINCAPSW, LPMIDIINCAPSW;
+
+struct MIDIHDR {
+    LPSTR lpData;
+    DWORD dwBufferLength;
+    DWORD dwBytesRecorded;
+    DWORD dwUser;
+    DWORD dwFlags;
+    MIDIHDR *lpNext;
+    DWORD reserved;
+    DWORD dwOffset;
+    DWORD[8] dwReserved;
+}
+alias MIDIHDR* PMIDIHDR, LPMIDIHDR;
+
+struct MIDIEVENT {
+    DWORD dwDeltaTime;
+    DWORD dwStreamID;
+    DWORD dwEvent;
+    DWORD[1] dwParms;
+}
+
+struct MIDISTRMBUFFVER {
+    DWORD dwVersion;
+    DWORD dwMid;
+    DWORD dwOEMVersion;
+}
+
+struct MIDIPROPTIMEDIV {
+    DWORD cbStruct;
+    DWORD dwTimeDiv;
+}
+alias MIDIPROPTIMEDIV* LPMIDIPROPTIMEDIV;
+
+struct MIDIPROPTEMPO {
+    DWORD cbStruct;
+    DWORD dwTempo;
+}
+alias MIDIPROPTEMPO* LPMIDIPROPTEMPO;
+
+struct AUXCAPSA {
+    WORD wMid;
+    WORD wPid;
+    MMVERSION vDriverVersion;
+    CHAR[MAXPNAMELEN] szPname;
+    WORD wTechnology;
+    WORD wReserved1;
+    DWORD dwSupport;
+}
+alias AUXCAPSA* PAUXCAPSA, LPAUXCAPSA;
+
+struct AUXCAPSW {
+    WORD wMid;
+    WORD wPid;
+    MMVERSION vDriverVersion;
+    WCHAR[MAXPNAMELEN] szPname;
+    WORD wTechnology;
+    WORD wReserved1;
+    DWORD dwSupport;
+}
+alias AUXCAPSW* PAUXCAPSW, LPAUXCAPSW;
+
+alias TypeDef!(HANDLE) HMIXEROBJ;
+alias HMIXEROBJ* LPHMIXEROBJ;
+
+alias TypeDef!(HANDLE) HMIXER;
+alias HMIXER* LPHMIXER;
+
+struct MIXERCAPSA {
+    WORD wMid;
+    WORD wPid;
+    MMVERSION vDriverVersion;
+    CHAR[MAXPNAMELEN] szPname;
+    DWORD fdwSupport;
+    DWORD cDestinations;
+}
+alias MIXERCAPSA* PMIXERCAPSA, LPMIXERCAPSA;
+
+struct MIXERCAPSW {
+    WORD wMid;
+    WORD wPid;
+    MMVERSION vDriverVersion;
+    WCHAR[MAXPNAMELEN] szPname;
+    DWORD fdwSupport;
+    DWORD cDestinations;
+}
+alias MIXERCAPSW* PMIXERCAPSW, LPMIXERCAPSW;
+
+struct MIXERLINEA {
+    DWORD cbStruct;
+    DWORD dwDestination;
+    DWORD dwSource;
+    DWORD dwLineID;
+    DWORD fdwLine;
+    DWORD dwUser;
+    DWORD dwComponentType;
+    DWORD cChannels;
+    DWORD cConnections;
+    DWORD cControls;
+    CHAR[MIXER_SHORT_NAME_CHARS] szShortName;
+    CHAR[MIXER_LONG_NAME_CHARS] szName;
+    struct Target {
+        DWORD dwType;
+        DWORD dwDeviceID;
+        WORD wMid;
+        WORD wPid;
+        MMVERSION vDriverVersion;
+        CHAR[MAXPNAMELEN] szPname;
+    }
+}
+alias MIXERLINEA* PMIXERLINEA, LPMIXERLINEA;
+
+struct MIXERLINEW {
+    DWORD cbStruct;
+    DWORD dwDestination;
+    DWORD dwSource;
+    DWORD dwLineID;
+    DWORD fdwLine;
+    DWORD dwUser;
+    DWORD dwComponentType;
+    DWORD cChannels;
+    DWORD cConnections;
+    DWORD cControls;
+    WCHAR[MIXER_SHORT_NAME_CHARS] szShortName;
+    WCHAR[MIXER_LONG_NAME_CHARS] szName;
+    struct Target {
+        DWORD dwType;
+        DWORD dwDeviceID;
+        WORD wMid;
+        WORD wPid;
+        MMVERSION vDriverVersion;
+        WCHAR[MAXPNAMELEN] szPname;
+    }
+}
+alias MIXERLINEW* PMIXERLINEW, LPMIXERLINEW;
+
+struct MIXERCONTROLA {
+    DWORD cbStruct;
+    DWORD dwControlID;
+    DWORD dwControlType;
+    DWORD fdwControl;
+    DWORD cMultipleItems;
+    CHAR[MIXER_SHORT_NAME_CHARS] szShortName;
+    CHAR[MIXER_LONG_NAME_CHARS] szName;
+    union _Bounds {
+        struct {
+            LONG lMinimum;
+            LONG lMaximum;
+        }
+        struct {
+            DWORD dwMinimum;
+            DWORD dwMaximum;
+        }
+        DWORD[6] dwReserved;
+    }
+    _Bounds Bounds;
+    union _Metrics {
+        DWORD cSteps;
+        DWORD cbCustomData;
+        DWORD[6] dwReserved;
+    }
+    _Metrics Metrics;
+}
+alias MIXERCONTROLA* PMIXERCONTROLA, LPMIXERCONTROLA;
+
+struct MIXERCONTROLW {
+    DWORD cbStruct;
+    DWORD dwControlID;
+    DWORD dwControlType;
+    DWORD fdwControl;
+    DWORD cMultipleItems;
+    WCHAR[MIXER_SHORT_NAME_CHARS] szShortName;
+    WCHAR[MIXER_LONG_NAME_CHARS] szName;
+    union _Bounds {
+        struct {
+            LONG lMinimum;
+            LONG lMaximum;
+        }
+        struct {
+            DWORD dwMinimum;
+            DWORD dwMaximum;
+        }
+        DWORD[6] dwReserved;
+    }
+    _Bounds Bounds;
+    union _Metrics {
+        DWORD cSteps;
+        DWORD cbCustomData;
+        DWORD[6] dwReserved;
+    }
+    _Metrics Metrics;
+}
+
+alias MIXERCONTROLW* PMIXERCONTROLW, LPMIXERCONTROLW;
+
+struct MIXERLINECONTROLSA {
+    DWORD cbStruct;
+    DWORD dwLineID;
+    union {
+        DWORD dwControlID;
+        DWORD dwControlType;
+    }
+    DWORD cControls;
+    DWORD cbmxctrl;
+    LPMIXERCONTROLA pamxctrl;
+}
+alias MIXERLINECONTROLSA* PMIXERLINECONTROLSA, LPMIXERLINECONTROLSA;
+
+struct MIXERLINECONTROLSW {
+    DWORD cbStruct;
+    DWORD dwLineID;
+    union {
+        DWORD dwControlID;
+        DWORD dwControlType;
+    }
+    DWORD cControls;
+    DWORD cbmxctrl;
+    LPMIXERCONTROLW pamxctrl;
+}
+alias MIXERLINECONTROLSW* PMIXERLINECONTROLSW, LPMIXERLINECONTROLSW;
+
+struct MIXERCONTROLDETAILS {
+    DWORD cbStruct;
+    DWORD dwControlID;
+    DWORD cChannels;
+    union {
+        HWND hwndOwner;
+        DWORD cMultipleItems;
+    }
+    DWORD cbDetails;
+    PVOID paDetails;
+}
+alias MIXERCONTROLDETAILS* PMIXERCONTROLDETAILS, LPMIXERCONTROLDETAILS;
+
+struct MIXERCONTROLDETAILS_LISTTEXTA {
+    DWORD dwParam1;
+    DWORD dwParam2;
+    CHAR[MIXER_LONG_NAME_CHARS] szName;
+}
+alias MIXERCONTROLDETAILS_LISTTEXTA* PMIXERCONTROLDETAILS_LISTTEXTA, LPMIXERCONTROLDETAILS_LISTTEXTA;
+
+struct MIXERCONTROLDETAILS_LISTTEXTW {
+    DWORD dwParam1;
+    DWORD dwParam2;
+    WCHAR[MIXER_LONG_NAME_CHARS] szName;
+}
+alias MIXERCONTROLDETAILS_LISTTEXTW* PMIXERCONTROLDETAILS_LISTTEXTW, LPMIXERCONTROLDETAILS_LISTTEXTW;
+
+struct MIXERCONTROLDETAILS_BOOLEAN {
+    LONG fValue;
+}
+alias MIXERCONTROLDETAILS_BOOLEAN* PMIXERCONTROLDETAILS_BOOLEAN, LPMIXERCONTROLDETAILS_BOOLEAN;
+
+struct MIXERCONTROLDETAILS_SIGNED {
+    LONG lValue;
+}
+alias MIXERCONTROLDETAILS_SIGNED* PMIXERCONTROLDETAILS_SIGNED, LPMIXERCONTROLDETAILS_SIGNED;
+
+struct MIXERCONTROLDETAILS_UNSIGNED {
+    DWORD dwValue;
+}
+alias MIXERCONTROLDETAILS_UNSIGNED* PMIXERCONTROLDETAILS_UNSIGNED, LPMIXERCONTROLDETAILS_UNSIGNED;
+
+alias void function (UINT, UINT, DWORD, DWORD, DWORD) LPTIMECALLBACK;
+
+struct TIMECAPS {
+    UINT wPeriodMin;
+    UINT wPeriodMax;
+}
+alias TIMECAPS* PTIMECAPS, LPTIMECAPS;
+
+struct JOYCAPSA {
+    WORD wMid;
+    WORD wPid;
+    CHAR[MAXPNAMELEN] szPname;
+    UINT wXmin;
+    UINT wXmax;
+    UINT wYmin;
+    UINT wYmax;
+    UINT wZmin;
+    UINT wZmax;
+    UINT wNumButtons;
+    UINT wPeriodMin;
+    UINT wPeriodMax;
+    UINT wRmin;
+    UINT wRmax;
+    UINT wUmin;
+    UINT wUmax;
+    UINT wVmin;
+    UINT wVmax;
+    UINT wCaps;
+    UINT wMaxAxes;
+    UINT wNumAxes;
+    UINT wMaxButtons;
+    CHAR[MAXPNAMELEN] szRegKey;
+    CHAR[MAX_JOYSTICKOEMVXDNAME] szOEMVxD;
+}
+alias JOYCAPSA* PJOYCAPSA, LPJOYCAPSA;
+
+struct JOYCAPSW {
+    WORD wMid;
+    WORD wPid;
+    WCHAR[MAXPNAMELEN] szPname;
+    UINT wXmin;
+    UINT wXmax;
+    UINT wYmin;
+    UINT wYmax;
+    UINT wZmin;
+    UINT wZmax;
+    UINT wNumButtons;
+    UINT wPeriodMin;
+    UINT wPeriodMax;
+    UINT wRmin;
+    UINT wRmax;
+    UINT wUmin;
+    UINT wUmax;
+    UINT wVmin;
+    UINT wVmax;
+    UINT wCaps;
+    UINT wMaxAxes;
+    UINT wNumAxes;
+    UINT wMaxButtons;
+    WCHAR[MAXPNAMELEN] szRegKey;
+    WCHAR[MAX_JOYSTICKOEMVXDNAME] szOEMVxD;
+}
+alias JOYCAPSW* PJOYCAPSW, LPJOYCAPSW;
+
+struct JOYINFO {
+    UINT wXpos;
+    UINT wYpos;
+    UINT wZpos;
+    UINT wButtons;
+}
+alias JOYINFO* PJOYINFO, LPJOYINFO;
+
+struct JOYINFOEX {
+    DWORD dwSize;
+    DWORD dwFlags;
+    DWORD dwXpos;
+    DWORD dwYpos;
+    DWORD dwZpos;
+    DWORD dwRpos;
+    DWORD dwUpos;
+    DWORD dwVpos;
+    DWORD dwButtons;
+    DWORD dwButtonNumber;
+    DWORD dwPOV;
+    DWORD dwReserved1;
+    DWORD dwReserved2;
+}
+alias JOYINFOEX* PJOYINFOEX, LPJOYINFOEX;
+
+alias DWORD FOURCC;
+alias char* HPSTR;
+
+alias TypeDef!(HANDLE) HMMIO;
+
+alias LRESULT function (LPSTR, UINT, LPARAM, LPARAM) LPMMIOPROC;
+
+struct MMIOINFO {
+    DWORD dwFlags;
+    FOURCC fccIOProc;
+    LPMMIOPROC pIOProc;
+    UINT wErrorRet;
+    HTASK htask;
+    LONG cchBuffer;
+    HPSTR pchBuffer;
+    HPSTR pchNext;
+    HPSTR pchEndRead;
+    HPSTR pchEndWrite;
+    LONG lBufOffset;
+    LONG lDiskOffset;
+    DWORD[3] adwInfo;
+    DWORD dwReserved1;
+    DWORD dwReserved2;
+    HMMIO hmmio;
+}
+alias MMIOINFO* PMMIOINFO, LPMMIOINFO;
+alias const(MMIOINFO)* LPCMMIOINFO;
+
+struct MMCKINFO {
+    FOURCC ckid;
+    DWORD cksize;
+    FOURCC fccType;
+    DWORD dwDataOffset;
+    DWORD dwFlags;
+}
+alias MMCKINFO* PMMCKINFO, LPMMCKINFO;
+alias const(MMCKINFO)* LPCMMCKINFO;
+
+struct MCI_GENERIC_PARMS {
+    DWORD dwCallback;
+}
+alias MCI_GENERIC_PARMS* PMCI_GENERIC_PARMS, LPMCI_GENERIC_PARMS;
+
+struct MCI_OPEN_PARMSA {
+    DWORD dwCallback;
+    MCIDEVICEID wDeviceID;
+    LPCSTR lpstrDeviceType;
+    LPCSTR lpstrElementName;
+    LPCSTR lpstrAlias;
+}
+alias MCI_OPEN_PARMSA* PMCI_OPEN_PARMSA, LPMCI_OPEN_PARMSA;
+
+struct MCI_OPEN_PARMSW {
+    DWORD dwCallback;
+    MCIDEVICEID wDeviceID;
+    LPCWSTR lpstrDeviceType;
+    LPCWSTR lpstrElementName;
+    LPCWSTR lpstrAlias;
+}
+alias MCI_OPEN_PARMSW* PMCI_OPEN_PARMSW, LPMCI_OPEN_PARMSW;
+
+struct MCI_PLAY_PARMS {
+    DWORD dwCallback;
+    DWORD dwFrom;
+    DWORD dwTo;
+}
+alias MCI_PLAY_PARMS* PMCI_PLAY_PARMS, LPMCI_PLAY_PARMS;
+
+struct MCI_SEEK_PARMS {
+    DWORD dwCallback;
+    DWORD dwTo;
+}
+alias MCI_SEEK_PARMS* PMCI_SEEK_PARMS, LPMCI_SEEK_PARMS;
+
+struct MCI_STATUS_PARMS {
+    DWORD dwCallback;
+    DWORD dwReturn;
+    DWORD dwItem;
+    DWORD dwTrack;
+}
+alias MCI_STATUS_PARMS* PMCI_STATUS_PARMS, LPMCI_STATUS_PARMS;
+
+struct MCI_INFO_PARMSA {
+    DWORD dwCallback;
+    LPSTR lpstrReturn;
+    DWORD dwRetSize;
+}
+alias MCI_INFO_PARMSA* LPMCI_INFO_PARMSA;
+
+struct MCI_INFO_PARMSW {
+    DWORD dwCallback;
+    LPWSTR lpstrReturn;
+    DWORD dwRetSize;
+}
+alias MCI_INFO_PARMSW* LPMCI_INFO_PARMSW;
+
+struct MCI_GETDEVCAPS_PARMS {
+    DWORD dwCallback;
+    DWORD dwReturn;
+    DWORD dwItem;
+}
+alias MCI_GETDEVCAPS_PARMS* PMCI_GETDEVCAPS_PARMS, LPMCI_GETDEVCAPS_PARMS;
+
+struct MCI_SYSINFO_PARMSA {
+    DWORD dwCallback;
+    LPSTR lpstrReturn;
+    DWORD dwRetSize;
+    DWORD dwNumber;
+    UINT wDeviceType;
+}
+alias MCI_SYSINFO_PARMSA* PMCI_SYSINFO_PARMSA, LPMCI_SYSINFO_PARMSA;
+
+struct MCI_SYSINFO_PARMSW {
+    DWORD dwCallback;
+    LPWSTR lpstrReturn;
+    DWORD dwRetSize;
+    DWORD dwNumber;
+    UINT wDeviceType;
+}
+alias MCI_SYSINFO_PARMSW* PMCI_SYSINFO_PARMSW, LPMCI_SYSINFO_PARMSW;
+
+struct MCI_SET_PARMS {
+    DWORD dwCallback;
+    DWORD dwTimeFormat;
+    DWORD dwAudio;
+}
+alias MCI_SET_PARMS* PMCI_SET_PARMS, LPMCI_SET_PARMS;
+
+struct MCI_BREAK_PARMS {
+    DWORD dwCallback;
+    int nVirtKey;
+    HWND hwndBreak;
+}
+alias MCI_BREAK_PARMS* PMCI_BREAK_PARMS, LPMCI_BREAK_PARMS;
+
+struct MCI_SAVE_PARMSA {
+    DWORD dwCallback;
+    LPCSTR lpfilename;
+}
+alias MCI_SAVE_PARMSA* PMCI_SAVE_PARMSA, LPMCI_SAVE_PARMSA;
+
+struct MCI_SAVE_PARMSW {
+    DWORD dwCallback;
+    LPCWSTR lpfilename;
+}
+alias MCI_SAVE_PARMSW* PMCI_SAVE_PARMSW, LPMCI_SAVE_PARMSW;
+
+struct MCI_LOAD_PARMSA {
+    DWORD dwCallback;
+    LPCSTR lpfilename;
+}
+alias MCI_LOAD_PARMSA* PMCI_LOAD_PARMSA, LPMCI_LOAD_PARMSA;
+
+struct MCI_LOAD_PARMSW {
+    DWORD dwCallback;
+    LPCWSTR lpfilename;
+}
+alias MCI_LOAD_PARMSW* PMCI_LOAD_PARMSW, LPMCI_LOAD_PARMSW;
+
+struct MCI_RECORD_PARMS {
+    DWORD dwCallback;
+    DWORD dwFrom;
+    DWORD dwTo;
+}
+alias MCI_RECORD_PARMS* LPMCI_RECORD_PARMS;
+
+struct MCI_VD_PLAY_PARMS {
+    DWORD dwCallback;
+    DWORD dwFrom;
+    DWORD dwTo;
+    DWORD dwSpeed;
+}
+alias MCI_VD_PLAY_PARMS* PMCI_VD_PLAY_PARMS, LPMCI_VD_PLAY_PARMS;
+
+struct MCI_VD_STEP_PARMS {
+    DWORD dwCallback;
+    DWORD dwFrames;
+}
+alias MCI_VD_STEP_PARMS* PMCI_VD_STEP_PARMS, LPMCI_VD_STEP_PARMS;
+
+struct MCI_VD_ESCAPE_PARMSA {
+    DWORD dwCallback;
+    LPCSTR lpstrCommand;
+}
+alias MCI_VD_ESCAPE_PARMSA* PMCI_VD_ESCAPE_PARMSA, LPMCI_VD_ESCAPE_PARMSA;
+
+struct MCI_VD_ESCAPE_PARMSW {
+    DWORD dwCallback;
+    LPCWSTR lpstrCommand;
+}
+alias MCI_VD_ESCAPE_PARMSW* PMCI_VD_ESCAPE_PARMSW, LPMCI_VD_ESCAPE_PARMSW;
+
+struct MCI_WAVE_OPEN_PARMSA {
+    DWORD dwCallback;
+    MCIDEVICEID wDeviceID;
+    LPCSTR lpstrDeviceType;
+    LPCSTR lpstrElementName;
+    LPCSTR lpstrAlias;
+    DWORD dwBufferSeconds;
+}
+alias MCI_WAVE_OPEN_PARMSA* PMCI_WAVE_OPEN_PARMSA, LPMCI_WAVE_OPEN_PARMSA;
+
+struct MCI_WAVE_OPEN_PARMSW {
+    DWORD dwCallback;
+    MCIDEVICEID wDeviceID;
+    LPCWSTR lpstrDeviceType;
+    LPCWSTR lpstrElementName;
+    LPCWSTR lpstrAlias;
+    DWORD dwBufferSeconds;
+}
+alias MCI_WAVE_OPEN_PARMSW* PMCI_WAVE_OPEN_PARMSW, LPMCI_WAVE_OPEN_PARMSW;
+
+struct MCI_WAVE_DELETE_PARMS {
+    DWORD dwCallback;
+    DWORD dwFrom;
+    DWORD dwTo;
+}
+alias MCI_WAVE_DELETE_PARMS* PMCI_WAVE_DELETE_PARMS, LPMCI_WAVE_DELETE_PARMS;
+
+struct MCI_WAVE_SET_PARMS {
+    DWORD dwCallback;
+    DWORD dwTimeFormat;
+    DWORD dwAudio;
+    UINT wInput;
+    UINT wOutput;
+    WORD wFormatTag;
+    WORD wReserved2;
+    WORD nChannels;
+    WORD wReserved3;
+    DWORD nSamplesPerSec;
+    DWORD nAvgBytesPerSec;
+    WORD nBlockAlign;
+    WORD wReserved4;
+    WORD wBitsPerSample;
+    WORD wReserved5;
+}
+alias MCI_WAVE_SET_PARMS* PMCI_WAVE_SET_PARMS, LPMCI_WAVE_SET_PARMS;
+
+extern (Windows) nothrow @nogc:
+LRESULT CloseDriver(HDRVR, LONG, LONG);
+HDRVR OpenDriver(LPCWSTR, LPCWSTR, LONG);
+LRESULT SendDriverMessage(HDRVR, UINT, LONG, LONG);
+HMODULE DrvGetModuleHandle(HDRVR);
+HMODULE GetDriverModuleHandle(HDRVR);
+LRESULT DefDriverProc(DWORD, HDRVR, UINT, LPARAM, LPARAM);
+UINT mmsystemGetVersion();
+// FIXME: I believe this next line is a mistake
+//alias OutputDebugString OutputDebugStr;
+BOOL sndPlaySoundA(LPCSTR, UINT);
+BOOL sndPlaySoundW(LPCWSTR, UINT);
+BOOL PlaySoundA(LPCSTR, HMODULE, DWORD);
+BOOL PlaySoundW(LPCWSTR, HMODULE, DWORD);
+UINT waveOutGetNumDevs();
+MMRESULT waveOutGetDevCapsA(UINT, LPWAVEOUTCAPSA, UINT);
+MMRESULT waveOutGetDevCapsW(UINT, LPWAVEOUTCAPSW, UINT);
+MMRESULT waveOutGetVolume(HWAVEOUT, PDWORD);
+MMRESULT waveOutSetVolume(HWAVEOUT, DWORD);
+MMRESULT waveOutGetErrorTextA(MMRESULT, LPSTR, UINT);
+MMRESULT waveOutGetErrorTextW(MMRESULT, LPWSTR, UINT);
+MMRESULT waveOutOpen(LPHWAVEOUT, UINT, LPCWAVEFORMATEX, DWORD, DWORD, DWORD);
+MMRESULT waveOutClose(HWAVEOUT);
+MMRESULT waveOutPrepareHeader(HWAVEOUT, LPWAVEHDR, UINT);
+MMRESULT waveOutUnprepareHeader(HWAVEOUT, LPWAVEHDR, UINT);
+MMRESULT waveOutWrite(HWAVEOUT, LPWAVEHDR, UINT);
+MMRESULT waveOutPause(HWAVEOUT);
+MMRESULT waveOutRestart(HWAVEOUT);
+MMRESULT waveOutReset(HWAVEOUT);
+MMRESULT waveOutBreakLoop(HWAVEOUT);
+MMRESULT waveOutGetPosition(HWAVEOUT, LPMMTIME, UINT);
+MMRESULT waveOutGetPitch(HWAVEOUT, PDWORD);
+MMRESULT waveOutSetPitch(HWAVEOUT, DWORD);
+MMRESULT waveOutGetPlaybackRate(HWAVEOUT, PDWORD);
+MMRESULT waveOutSetPlaybackRate(HWAVEOUT, DWORD);
+MMRESULT waveOutGetID(HWAVEOUT, LPUINT);
+MMRESULT waveOutMessage(HWAVEOUT, UINT, DWORD, DWORD);
+UINT waveInGetNumDevs();
+MMRESULT waveInGetDevCapsA(UINT, LPWAVEINCAPSA, UINT);
+MMRESULT waveInGetDevCapsW(UINT, LPWAVEINCAPSW, UINT);
+MMRESULT waveInGetErrorTextA(MMRESULT, LPSTR, UINT);
+MMRESULT waveInGetErrorTextW(MMRESULT, LPWSTR, UINT);
+MMRESULT waveInOpen(LPHWAVEIN, UINT, LPCWAVEFORMATEX, DWORD, DWORD, DWORD);
+MMRESULT waveInClose(HWAVEIN);
+MMRESULT waveInPrepareHeader(HWAVEIN, LPWAVEHDR, UINT);
+MMRESULT waveInUnprepareHeader(HWAVEIN, LPWAVEHDR, UINT);
+MMRESULT waveInAddBuffer(HWAVEIN, LPWAVEHDR, UINT);
+MMRESULT waveInStart(HWAVEIN);
+MMRESULT waveInStop(HWAVEIN);
+MMRESULT waveInReset(HWAVEIN);
+MMRESULT waveInGetPosition(HWAVEIN, LPMMTIME, UINT);
+MMRESULT waveInGetID(HWAVEIN, LPUINT);
+MMRESULT waveInMessage(HWAVEIN, UINT, DWORD, DWORD);
+UINT midiOutGetNumDevs();
+MMRESULT midiStreamOpen(LPHMIDISTRM, LPUINT, DWORD, DWORD, DWORD, DWORD);
+MMRESULT midiStreamClose(HMIDISTRM);
+MMRESULT midiStreamProperty(HMIDISTRM, LPBYTE, DWORD);
+MMRESULT midiStreamPosition(HMIDISTRM, LPMMTIME, UINT);
+MMRESULT midiStreamOut(HMIDISTRM, LPMIDIHDR, UINT);
+MMRESULT midiStreamPause(HMIDISTRM);
+MMRESULT midiStreamRestart(HMIDISTRM);
+MMRESULT midiStreamStop(HMIDISTRM);
+MMRESULT midiConnect(HMIDI, HMIDIOUT, PVOID);
+MMRESULT midiDisconnect(HMIDI, HMIDIOUT, PVOID);
+MMRESULT midiOutGetDevCapsA(UINT, LPMIDIOUTCAPSA, UINT);
+MMRESULT midiOutGetDevCapsW(UINT, LPMIDIOUTCAPSW, UINT);
+MMRESULT midiOutGetVolume(HMIDIOUT, PDWORD);
+MMRESULT midiOutSetVolume(HMIDIOUT, DWORD);
+MMRESULT midiOutGetErrorTextA(MMRESULT, LPSTR, UINT);
+MMRESULT midiOutGetErrorTextW(MMRESULT, LPWSTR, UINT);
+MMRESULT midiOutOpen(LPHMIDIOUT, UINT, DWORD, DWORD, DWORD);
+MMRESULT midiOutClose(HMIDIOUT);
+MMRESULT midiOutPrepareHeader(HMIDIOUT, LPMIDIHDR, UINT);
+MMRESULT midiOutUnprepareHeader(HMIDIOUT, LPMIDIHDR, UINT);
+MMRESULT midiOutShortMsg(HMIDIOUT, DWORD);
+MMRESULT midiOutLongMsg(HMIDIOUT, LPMIDIHDR, UINT);
+MMRESULT midiOutReset(HMIDIOUT);
+MMRESULT midiOutCachePatches(HMIDIOUT, UINT, LPWORD, UINT);
+MMRESULT midiOutCacheDrumPatches(HMIDIOUT, UINT, LPWORD, UINT);
+MMRESULT midiOutGetID(HMIDIOUT, LPUINT);
+MMRESULT midiOutMessage(HMIDIOUT, UINT, DWORD, DWORD);
+UINT midiInGetNumDevs();
+MMRESULT midiInGetDevCapsA(UINT, LPMIDIINCAPSA, UINT);
+MMRESULT midiInGetDevCapsW(UINT, LPMIDIINCAPSW, UINT);
+MMRESULT midiInGetErrorTextA(MMRESULT, LPSTR, UINT);
+MMRESULT midiInGetErrorTextW(MMRESULT, LPWSTR, UINT);
+MMRESULT midiInOpen(LPHMIDIIN, UINT, DWORD, DWORD, DWORD);
+MMRESULT midiInClose(HMIDIIN);
+MMRESULT midiInPrepareHeader(HMIDIIN, LPMIDIHDR, UINT);
+MMRESULT midiInUnprepareHeader(HMIDIIN, LPMIDIHDR, UINT);
+MMRESULT midiInAddBuffer(HMIDIIN, LPMIDIHDR, UINT);
+MMRESULT midiInStart(HMIDIIN);
+MMRESULT midiInStop(HMIDIIN);
+MMRESULT midiInReset(HMIDIIN);
+MMRESULT midiInGetID(HMIDIIN, LPUINT);
+MMRESULT midiInMessage(HMIDIIN, UINT, DWORD, DWORD);
+UINT auxGetNumDevs();
+MMRESULT auxGetDevCapsA(UINT, LPAUXCAPSA, UINT);
+MMRESULT auxGetDevCapsW(UINT, LPAUXCAPSW, UINT);
+MMRESULT auxSetVolume(UINT, DWORD);
+MMRESULT auxGetVolume(UINT, PDWORD);
+MMRESULT auxOutMessage(UINT, UINT, DWORD, DWORD);
+UINT mixerGetNumDevs();
+MMRESULT mixerGetDevCapsA(UINT, LPMIXERCAPSA, UINT);
+MMRESULT mixerGetDevCapsW(UINT, LPMIXERCAPSW, UINT);
+MMRESULT mixerOpen(LPHMIXER, UINT, DWORD, DWORD, DWORD);
+MMRESULT mixerClose(HMIXER);
+DWORD mixerMessage(HMIXER, UINT, DWORD, DWORD);
+MMRESULT mixerGetLineInfoA(HMIXEROBJ, LPMIXERLINEA, DWORD);
+MMRESULT mixerGetLineInfoW(HMIXEROBJ, LPMIXERLINEW, DWORD);
+MMRESULT mixerGetID(HMIXEROBJ, PUINT, DWORD);
+MMRESULT mixerGetLineControlsA(HMIXEROBJ, LPMIXERLINECONTROLSA, DWORD);
+MMRESULT mixerGetLineControlsW(HMIXEROBJ, LPMIXERLINECONTROLSW, DWORD);
+MMRESULT mixerGetControlDetailsA(HMIXEROBJ, LPMIXERCONTROLDETAILS, DWORD);
+MMRESULT mixerGetControlDetailsW(HMIXEROBJ, LPMIXERCONTROLDETAILS, DWORD);
+MMRESULT mixerSetControlDetails(HMIXEROBJ, LPMIXERCONTROLDETAILS, DWORD);
+MMRESULT timeGetSystemTime(LPMMTIME, UINT);
+DWORD timeGetTime();
+MMRESULT timeSetEvent(UINT, UINT, LPTIMECALLBACK, DWORD, UINT);
+MMRESULT timeKillEvent(UINT);
+MMRESULT timeGetDevCaps(LPTIMECAPS, UINT);
+MMRESULT timeBeginPeriod(UINT);
+MMRESULT timeEndPeriod(UINT);
+UINT joyGetNumDevs();
+MMRESULT joyGetDevCapsA(UINT, LPJOYCAPSA, UINT);
+MMRESULT joyGetDevCapsW(UINT, LPJOYCAPSW, UINT);
+MMRESULT joyGetPos(UINT, LPJOYINFO);
+MMRESULT joyGetPosEx(UINT, LPJOYINFOEX);
+MMRESULT joyGetThreshold(UINT, LPUINT);
+MMRESULT joyReleaseCapture(UINT);
+MMRESULT joySetCapture(HWND, UINT, UINT, BOOL);
+MMRESULT joySetThreshold(UINT, UINT);
+FOURCC mmioStringToFOURCCA(LPCSTR, UINT);
+FOURCC mmioStringToFOURCCW(LPCWSTR, UINT);
+LPMMIOPROC mmioInstallIOProcA(FOURCC, LPMMIOPROC, DWORD);
+LPMMIOPROC mmioInstallIOProcW(FOURCC, LPMMIOPROC, DWORD);
+HMMIO mmioOpenA(LPSTR, LPMMIOINFO, DWORD);
+HMMIO mmioOpenW(LPWSTR, LPMMIOINFO, DWORD);
+MMRESULT mmioRenameA(LPCSTR, LPCSTR, LPCMMIOINFO, DWORD);
+MMRESULT mmioRenameW(LPCWSTR, LPCWSTR, LPCMMIOINFO, DWORD);
+MMRESULT mmioClose(HMMIO, UINT);
+LONG mmioRead(HMMIO, HPSTR, LONG);
+LONG mmioWrite(HMMIO, LPCSTR, LONG);
+LONG mmioSeek(HMMIO, LONG, int);
+MMRESULT mmioGetInfo(HMMIO, LPMMIOINFO, UINT);
+MMRESULT mmioSetInfo(HMMIO, LPCMMIOINFO, UINT);
+MMRESULT mmioSetBuffer(HMMIO, LPSTR, LONG, UINT);
+MMRESULT mmioFlush(HMMIO, UINT);
+MMRESULT mmioAdvance(HMMIO, LPMMIOINFO, UINT);
+LRESULT mmioSendMessage(HMMIO, UINT, LPARAM, LPARAM);
+MMRESULT mmioDescend(HMMIO, LPMMCKINFO, const(MMCKINFO)*, UINT);
+MMRESULT mmioAscend(HMMIO, LPMMCKINFO, UINT);
+MMRESULT mmioCreateChunk(HMMIO, LPMMCKINFO, UINT);
+MCIERROR mciSendCommandA(MCIDEVICEID, UINT, DWORD, DWORD);
+MCIERROR mciSendCommandW(MCIDEVICEID, UINT, DWORD, DWORD);
+MCIERROR mciSendStringA(LPCSTR, LPSTR, UINT, HWND);
+MCIERROR mciSendStringW(LPCWSTR, LPWSTR, UINT, HWND);
+MCIDEVICEID mciGetDeviceIDA(LPCSTR);
+MCIDEVICEID mciGetDeviceIDW(LPCWSTR);
+MCIDEVICEID mciGetDeviceIDFromElementIDA(DWORD, LPCSTR);
+MCIDEVICEID mciGetDeviceIDFromElementIDW(DWORD, LPCWSTR);
+BOOL mciGetErrorStringA(MCIERROR, LPSTR, UINT);
+BOOL mciGetErrorStringW(MCIERROR, LPWSTR, UINT);
+BOOL mciSetYieldProc(MCIDEVICEID, YIELDPROC, DWORD);
+HTASK mciGetCreatorTask(MCIDEVICEID);
+YIELDPROC mciGetYieldProc(MCIDEVICEID, PDWORD);
+
+struct MCI_SEQ_SET_PARMS {
+    DWORD dwCallback;
+    DWORD dwTimeFormat;
+    DWORD dwAudio;
+    DWORD dwTempo;
+    DWORD dwPort;
+    DWORD dwSlave;
+    DWORD dwMaster;
+    DWORD dwOffset;
+}
+alias MCI_SEQ_SET_PARMS* PMCI_SEQ_SET_PARMS, LPMCI_SEQ_SET_PARMS;
+
+struct MCI_ANIM_OPEN_PARMSA {
+    DWORD dwCallback;
+    MCIDEVICEID wDeviceID;
+    LPCSTR lpstrDeviceType;
+    LPCSTR lpstrElementName;
+    LPCSTR lpstrAlias;
+    DWORD dwStyle;
+    HWND hWndParent;
+}
+alias MCI_ANIM_OPEN_PARMSA* PMCI_ANIM_OPEN_PARMSA, LPMCI_ANIM_OPEN_PARMSA;
+
+struct MCI_ANIM_OPEN_PARMSW {
+    DWORD dwCallback;
+    MCIDEVICEID wDeviceID;
+    LPCWSTR lpstrDeviceType;
+    LPCWSTR lpstrElementName;
+    LPCWSTR lpstrAlias;
+    DWORD dwStyle;
+    HWND hWndParent;
+}
+alias MCI_ANIM_OPEN_PARMSW* PMCI_ANIM_OPEN_PARMSW, LPMCI_ANIM_OPEN_PARMSW;
+
+struct MCI_ANIM_PLAY_PARMS {
+    DWORD dwCallback;
+    DWORD dwFrom;
+    DWORD dwTo;
+    DWORD dwSpeed;
+}
+alias MCI_ANIM_PLAY_PARMS* PMCI_ANIM_PLAY_PARMS, LPMCI_ANIM_PLAY_PARMS;
+
+struct MCI_ANIM_STEP_PARMS {
+    DWORD dwCallback;
+    DWORD dwFrames;
+}
+alias MCI_ANIM_STEP_PARMS* PMCI_ANIM_STEP_PARMS, LPMCI_ANIM_STEP_PARMS;
+
+struct MCI_ANIM_WINDOW_PARMSA {
+    DWORD dwCallback;
+    HWND hWnd;
+    UINT nCmdShow;
+    LPCSTR lpstrText;
+}
+alias MCI_ANIM_WINDOW_PARMSA* PMCI_ANIM_WINDOW_PARMSA, LPMCI_ANIM_WINDOW_PARMSA;
+
+struct MCI_ANIM_WINDOW_PARMSW {
+    DWORD dwCallback;
+    HWND hWnd;
+    UINT nCmdShow;
+    LPCWSTR lpstrText;
+}
+alias MCI_ANIM_WINDOW_PARMSW* PMCI_ANIM_WINDOW_PARMSW, LPMCI_ANIM_WINDOW_PARMSW;
+
+struct MCI_ANIM_RECT_PARMS {
+    DWORD dwCallback;
+    //#ifdef MCI_USE_OFFEXT
+    //  POINT ptOffset;
+    //  POINT ptExtent;
+    //#else
+    RECT rc;
+    //#endif
+}
+alias MCI_ANIM_RECT_PARMS* PMCI_ANIM_RECT_PARMS, LPMCI_ANIM_RECT_PARMS;
+
+struct MCI_ANIM_UPDATE_PARMS {
+    DWORD dwCallback;
+    RECT rc;
+    HDC hDC;
+}
+alias MCI_ANIM_UPDATE_PARMS* PMCI_ANIM_UPDATE_PARMS, LPMCI_ANIM_UPDATE_PARMS;
+
+struct MCI_OVLY_OPEN_PARMSA {
+    DWORD dwCallback;
+    MCIDEVICEID wDeviceID;
+    LPCSTR lpstrDeviceType;
+    LPCSTR lpstrElementName;
+    LPCSTR lpstrAlias;
+    DWORD dwStyle;
+    HWND hWndParent;
+}
+alias MCI_OVLY_OPEN_PARMSA* PMCI_OVLY_OPEN_PARMSA, LPMCI_OVLY_OPEN_PARMSA;
+
+struct MCI_OVLY_OPEN_PARMSW {
+    DWORD dwCallback;
+    MCIDEVICEID wDeviceID;
+    LPCWSTR lpstrDeviceType;
+    LPCWSTR lpstrElementName;
+    LPCWSTR lpstrAlias;
+    DWORD dwStyle;
+    HWND hWndParent;
+}
+alias MCI_OVLY_OPEN_PARMSW* PMCI_OVLY_OPEN_PARMSW, LPMCI_OVLY_OPEN_PARMSW;
+
+struct MCI_OVLY_WINDOW_PARMSA {
+    DWORD dwCallback;
+    HWND hWnd;
+    UINT nCmdShow;
+    LPCSTR lpstrText;
+}
+alias MCI_OVLY_WINDOW_PARMSA* PMCI_OVLY_WINDOW_PARMSA, LPMCI_OVLY_WINDOW_PARMSA;
+
+struct MCI_OVLY_WINDOW_PARMSW {
+    DWORD dwCallback;
+    HWND hWnd;
+    UINT nCmdShow;
+    LPCWSTR lpstrText;
+}
+alias MCI_OVLY_WINDOW_PARMSW* PMCI_OVLY_WINDOW_PARMSW, LPMCI_OVLY_WINDOW_PARMSW;
+
+struct MCI_OVLY_RECT_PARMS {
+    DWORD dwCallback;
+    //#ifdef MCI_USE_OFFEXT
+    //  POINT ptOffset;
+    //  POINT ptExtent;
+    //#else
+    RECT rc;
+    //#endif
+}
+alias MCI_OVLY_RECT_PARMS* PMCI_OVLY_RECT_PARMS, LPMCI_OVLY_RECT_PARMS;
+
+struct MCI_OVLY_SAVE_PARMSA {
+    DWORD dwCallback;
+    LPCSTR lpfilename;
+    RECT rc;
+}
+alias MCI_OVLY_SAVE_PARMSA* PMCI_OVLY_SAVE_PARMSA, LPMCI_OVLY_SAVE_PARMSA;
+
+struct MCI_OVLY_SAVE_PARMSW {
+    DWORD dwCallback;
+    LPCWSTR lpfilename;
+    RECT rc;
+}
+alias MCI_OVLY_SAVE_PARMSW* PMCI_OVLY_SAVE_PARMSW, LPMCI_OVLY_SAVE_PARMSW;
+
+struct MCI_OVLY_LOAD_PARMSA {
+    DWORD dwCallback;
+    LPCSTR lpfilename;
+    RECT rc;
+}
+alias MCI_OVLY_LOAD_PARMSA* PMCI_OVLY_LOAD_PARMSA, LPMCI_OVLY_LOAD_PARMSA;
+
+struct MCI_OVLY_LOAD_PARMSW {
+    DWORD dwCallback;
+    LPCWSTR lpfilename;
+    RECT rc;
+}
+alias MCI_OVLY_LOAD_PARMSW* PMCI_OVLY_LOAD_PARMSW, LPMCI_OVLY_LOAD_PARMSW;
+
+version(Unicode) {
+    alias WAVEOUTCAPSW WAVEOUTCAPS;
+    alias WAVEINCAPSW WAVEINCAPS;
+    alias MIDIOUTCAPSW MIDIOUTCAPS;
+    alias MIDIINCAPSW MIDIINCAPS;
+    alias AUXCAPSW AUXCAPS;
+    alias MIXERCAPSW MIXERCAPS;
+    alias MIXERLINEW MIXERLINE;
+    alias MIXERCONTROLA MIXERCONTROL;
+    alias MIXERLINECONTROLSW MIXERLINECONTROLS;
+    alias MIXERCONTROLDETAILS_LISTTEXTW MIXERCONTROLDETAILS_LISTTEXT;
+    alias JOYCAPSW JOYCAPS;
+    alias MCI_OPEN_PARMSW MCI_OPEN_PARMS;
+    alias MCI_INFO_PARMSW MCI_INFO_PARMS;
+    alias MCI_SYSINFO_PARMSW MCI_SYSINFO_PARMS;
+    alias MCI_SAVE_PARMSW MCI_SAVE_PARMS;
+    alias MCI_LOAD_PARMSW MCI_LOAD_PARMS;
+    alias MCI_VD_ESCAPE_PARMSW MCI_VD_ESCAPE_PARMS;
+    alias MCI_WAVE_OPEN_PARMSW MCI_WAVE_OPEN_PARMS;
+    alias MCI_ANIM_OPEN_PARMSW MCI_ANIM_OPEN_PARMS;
+    alias MCI_ANIM_WINDOW_PARMSW MCI_ANIM_WINDOW_PARMS;
+    alias MCI_OVLY_OPEN_PARMSW MCI_OVLY_OPEN_PARMS;
+    alias MCI_OVLY_WINDOW_PARMSW MCI_OVLY_WINDOW_PARMS;
+    alias MCI_OVLY_SAVE_PARMSW MCI_OVLY_SAVE_PARMS;
+
+    alias sndPlaySoundW sndPlaySound;
+    alias PlaySoundW PlaySound;
+    alias waveOutGetDevCapsW waveOutGetDevCaps;
+    alias waveOutGetErrorTextW waveOutGetErrorText;
+    alias waveInGetDevCapsW waveInGetDevCaps;
+    alias waveInGetErrorTextW waveInGetErrorText;
+    alias midiOutGetDevCapsW midiOutGetDevCaps;
+    alias midiOutGetErrorTextW midiOutGetErrorText;
+    alias midiInGetDevCapsW midiInGetDevCaps;
+    alias midiInGetErrorTextW midiInGetErrorText;
+    alias auxGetDevCapsW auxGetDevCaps;
+    alias mixerGetDevCapsW mixerGetDevCaps;
+    alias mixerGetLineInfoW mixerGetLineInfo;
+    alias mixerGetLineControlsW mixerGetLineControls;
+    alias mixerGetControlDetailsW mixerGetControlDetails;
+    alias joyGetDevCapsW joyGetDevCaps;
+    alias mmioInstallIOProcW mmioInstallIOProc;
+    alias mmioStringToFOURCCW mmioStringToFOURCC;
+    alias mmioOpenW mmioOpen;
+    alias mmioRenameW mmioRename;
+    alias mciSendCommandW mciSendCommand;
+    alias mciSendStringW mciSendString;
+    alias mciGetDeviceIDW mciGetDeviceID;
+    alias mciGetDeviceIDFromElementIDW mciGetDeviceIDFromElementID;
+    alias mciGetErrorStringW mciGetErrorString;
+
+} else {
+    alias WAVEOUTCAPSA WAVEOUTCAPS;
+    alias WAVEINCAPSA WAVEINCAPS;
+    alias MIDIOUTCAPSA MIDIOUTCAPS;
+    alias MIDIINCAPSA MIDIINCAPS;
+    alias AUXCAPSA AUXCAPS;
+    alias MIXERCAPSA MIXERCAPS;
+    alias MIXERLINEA MIXERLINE;
+    alias MIXERCONTROLA MIXERCONTROL;
+    alias MIXERLINECONTROLSA MIXERLINECONTROLS;
+    alias MIXERCONTROLDETAILS_LISTTEXTA MIXERCONTROLDETAILS_LISTTEXT;
+    alias JOYCAPSA JOYCAPS;
+    alias MCI_OPEN_PARMSA MCI_OPEN_PARMS;
+    alias MCI_INFO_PARMSA MCI_INFO_PARMS;
+    alias MCI_SYSINFO_PARMSA MCI_SYSINFO_PARMS;
+    alias MCI_SAVE_PARMSA MCI_SAVE_PARMS;
+    alias MCI_LOAD_PARMSA MCI_LOAD_PARMS;
+    alias MCI_VD_ESCAPE_PARMSA MCI_VD_ESCAPE_PARMS;
+    alias MCI_WAVE_OPEN_PARMSA MCI_WAVE_OPEN_PARMS;
+    alias MCI_ANIM_OPEN_PARMSA MCI_ANIM_OPEN_PARMS;
+    alias MCI_ANIM_WINDOW_PARMSA MCI_ANIM_WINDOW_PARMS;
+    alias MCI_OVLY_OPEN_PARMSA MCI_OVLY_OPEN_PARMS;
+    alias MCI_OVLY_WINDOW_PARMSA MCI_OVLY_WINDOW_PARMS;
+    alias MCI_OVLY_SAVE_PARMSA MCI_OVLY_SAVE_PARMS;
+
+    alias sndPlaySoundA sndPlaySound;
+    alias PlaySoundA PlaySound;
+    alias waveOutGetDevCapsA waveOutGetDevCaps;
+    alias waveOutGetErrorTextA waveOutGetErrorText;
+    alias waveInGetDevCapsA waveInGetDevCaps;
+    alias waveInGetErrorTextA waveInGetErrorText;
+    alias midiOutGetDevCapsA midiOutGetDevCaps;
+    alias midiOutGetErrorTextA midiOutGetErrorText;
+    alias midiInGetDevCapsA midiInGetDevCaps;
+    alias midiInGetErrorTextA midiInGetErrorText;
+    alias auxGetDevCapsA auxGetDevCaps;
+    alias mixerGetDevCapsA mixerGetDevCaps;
+    alias mixerGetLineInfoA mixerGetLineInfo;
+    alias mixerGetLineControlsA mixerGetLineControls;
+    alias mixerGetControlDetailsA mixerGetControlDetails;
+    alias joyGetDevCapsA joyGetDevCaps;
+    alias mmioInstallIOProcA mmioInstallIOProc;
+    alias mmioStringToFOURCCA mmioStringToFOURCC;
+    alias mmioOpenA mmioOpen;
+    alias mmioRenameA mmioRename;
+    alias mciSendCommandA mciSendCommand;
+    alias mciSendStringA mciSendString;
+    alias mciGetDeviceIDA mciGetDeviceID;
+    alias mciGetDeviceIDFromElementIDA mciGetDeviceIDFromElementID;
+    alias mciGetErrorStringA mciGetErrorString;
+}
+
+alias WAVEOUTCAPS* PWAVEOUTCAPS, LPWAVEOUTCAPS;
+alias WAVEINCAPS* PWAVEINCAPS, LPWAVEINCAPS;
+alias MIDIOUTCAPS* PMIDIOUTCAPS, LPMIDIOUTCAPS;
+alias MIDIINCAPS* PMIDIINCAPS, LPMIDIINCAPS;
+alias AUXCAPS* PAUXCAPS, LPAUXCAPS;
+alias MIXERCAPS* PMIXERCAPS, LPMIXERCAPS;
+alias MIXERLINE* PMIXERLINE, LPMIXERLINE;
+alias MIXERCONTROL* PMIXERCONTROL, LPMIXERCONTROL;
+alias MIXERLINECONTROLS* PMIXERLINECONTROLS, LPMIXERLINECONTROLS;
+alias MIXERCONTROLDETAILS_LISTTEXT* PMIXERCONTROLDETAILS_LISTTEXT, LPMIXERCONTROLDETAILS_LISTTEXT;
+alias JOYCAPS* PJOYCAPS, LPJOYCAPS;
+alias MCI_OPEN_PARMS* PMCI_OPEN_PARMS, LPMCI_OPEN_PARMS;
+alias MCI_INFO_PARMS* LPMCI_INFO_PARMS;
+alias MCI_SYSINFO_PARMS* PMCI_SYSINFO_PARMS, LPMCI_SYSINFO_PARMS;
+alias MCI_SAVE_PARMS* PMCI_SAVE_PARMS, LPMCI_SAVE_PARMS;
+alias MCI_LOAD_PARMS* PMCI_LOAD_PARMS, LPMCI_LOAD_PARMS;
+alias MCI_VD_ESCAPE_PARMS* PMCI_VD_ESCAPE_PARMS, LPMCI_VD_ESCAPE_PARMS;
+alias MCI_WAVE_OPEN_PARMS* PMCI_WAVE_OPEN_PARMS, LPMCI_WAVE_OPEN_PARMS;
+alias MCI_ANIM_OPEN_PARMS* PMCI_ANIM_OPEN_PARMS, LPMCI_ANIM_OPEN_PARMS;
+alias MCI_ANIM_WINDOW_PARMS* PMCI_ANIM_WINDOW_PARMS, LPMCI_ANIM_WINDOW_PARMS;
+alias MCI_OVLY_OPEN_PARMS* PMCI_OVLY_OPEN_PARMS, LPMCI_OVLY_OPEN_PARMS;
+alias MCI_OVLY_WINDOW_PARMS* PMCI_OVLY_WINDOW_PARMS, LPMCI_OVLY_WINDOW_PARMS;
+alias MCI_OVLY_SAVE_PARMS* PMCI_OVLY_SAVE_PARMS, LPMCI_OVLY_SAVE_PARMS;
diff --git a/libphobos/libdruntime/core/sys/windows/msacm.d b/libphobos/libdruntime/core/sys/windows/msacm.d
new file mode 100644
index 00000000000..b00900491b6
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/msacm.d
@@ -0,0 +1,175 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_msacm.d)
+ */
+module core.sys.windows.msacm;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.basetsd, core.sys.windows.mmsystem, core.sys.windows.windef;
+
+mixin DECLARE_HANDLE!("HACMDRIVERID");
+mixin DECLARE_HANDLE!("HACMDRIVER");
+alias HACMDRIVER* LPHACMDRIVER;
+
+/* Comment from MinGW
+    found through experimentation
+ */
+enum size_t
+    ACMDRIVERDETAILS_SHORTNAME_CHARS =  32,
+    ACMDRIVERDETAILS_LONGNAME_CHARS  = 128,
+    ACMDRIVERDETAILS_COPYRIGHT_CHARS =  80,
+    ACMDRIVERDETAILS_LICENSING_CHARS = 128;
+
+/* Comment from MinGW
+    I don't know the right values for these macros
+ */
+enum size_t
+    ACMFORMATDETAILS_FORMAT_CHARS       = 256,
+    ACMFORMATTAGDETAILS_FORMATTAG_CHARS = 256,
+    ACMDRIVERDETAILS_FEATURES_CHARS     = 256;
+
+struct ACMFORMATDETAILSA {
+    DWORD          cbStruct = ACMFORMATDETAILSA.sizeof;  // are they?
+    DWORD          dwFormatIndex;
+    DWORD          dwFormatTag;
+    DWORD          fdwSupport;
+    LPWAVEFORMATEX pwfx;
+    DWORD          cbwfx;
+    char[ACMFORMATDETAILS_FORMAT_CHARS] szFormat;
+}
+alias ACMFORMATDETAILSA* LPACMFORMATDETAILSA;
+
+struct ACMFORMATDETAILSW {
+    DWORD          cbStruct = ACMFORMATDETAILSW.sizeof;
+    DWORD          dwFormatIndex;
+    DWORD          dwFormatTag;
+    DWORD          fdwSupport;
+    LPWAVEFORMATEX pwfx;
+    DWORD          cbwfx;
+    WCHAR[ACMFORMATDETAILS_FORMAT_CHARS] szFormat;
+}
+alias ACMFORMATDETAILSW* LPACMFORMATDETAILSW;
+
+struct ACMFORMATTAGDETAILSA {
+    DWORD cbStruct = ACMFORMATTAGDETAILSA.sizeof;
+    DWORD dwFormatTagIndex;
+    DWORD dwFormatTag;
+    DWORD cbFormatSize;
+    DWORD fdwSupport;
+    DWORD cStandardFormats;
+    char[ACMFORMATTAGDETAILS_FORMATTAG_CHARS] szFormatTag;
+}
+alias ACMFORMATTAGDETAILSA* LPACMFORMATTAGDETAILSA;
+
+struct ACMFORMATTAGDETAILSW {
+    DWORD cbStruct = ACMFORMATTAGDETAILSW.sizeof;
+    DWORD dwFormatTagIndex;
+    DWORD dwFormatTag;
+    DWORD cbFormatSize;
+    DWORD fdwSupport;
+    DWORD cStandardFormats;
+    WCHAR[ACMFORMATTAGDETAILS_FORMATTAG_CHARS] szFormatTag;
+}
+alias ACMFORMATTAGDETAILSW* LPACMFORMATTAGDETAILSW;
+
+struct ACMDRIVERDETAILSA {
+    DWORD  cbStruct = ACMDRIVERDETAILSA.sizeof;
+    FOURCC fccType;
+    FOURCC fccComp;
+    WORD   wMid;
+    WORD   wPid;
+    DWORD  vdwACM;
+    DWORD  vdwDriver;
+    DWORD  fdwSupport;
+    DWORD  cFormatTags;
+    DWORD  cFilterTags;
+    HICON  hicon;
+    char[ACMDRIVERDETAILS_SHORTNAME_CHARS] szShortName;
+    char[ACMDRIVERDETAILS_LONGNAME_CHARS]  szLongName;
+    char[ACMDRIVERDETAILS_COPYRIGHT_CHARS] szCopyright;
+    char[ACMDRIVERDETAILS_LICENSING_CHARS] szLicensing;
+    char[ACMDRIVERDETAILS_FEATURES_CHARS]  szFeatures;
+}
+alias ACMDRIVERDETAILSA* LPACMDRIVERDETAILSA;
+
+struct ACMDRIVERDETAILSW {
+    DWORD  cbStruct = ACMDRIVERDETAILSW.sizeof;
+    FOURCC fccType;
+    FOURCC fccComp;
+    WORD   wMid;
+    WORD   wPid;
+    DWORD  vdwACM;
+    DWORD  vdwDriver;
+    DWORD  fdwSupport;
+    DWORD  cFormatTags;
+    DWORD  cFilterTags;
+    HICON  hicon;
+    WCHAR[ACMDRIVERDETAILS_SHORTNAME_CHARS] szShortName;
+    WCHAR[ACMDRIVERDETAILS_LONGNAME_CHARS]  szLongName;
+    WCHAR[ACMDRIVERDETAILS_COPYRIGHT_CHARS] szCopyright;
+    WCHAR[ACMDRIVERDETAILS_LICENSING_CHARS] szLicensing;
+    WCHAR[ACMDRIVERDETAILS_FEATURES_CHARS]  szFeatures;
+}
+alias ACMDRIVERDETAILSW* LPACMDRIVERDETAILSW;
+
+extern (Windows) {
+    alias BOOL function(HACMDRIVERID hadid, LPACMFORMATDETAILSA pafd,
+      DWORD_PTR dwInstance, DWORD fdwSupport) ACMFORMATENUMCBA;
+    alias BOOL function(HACMDRIVERID hadid, LPACMFORMATDETAILSW pafd,
+      DWORD_PTR dwInstance, DWORD fdwSupport) ACMFORMATENUMCBW;
+    alias BOOL function(HACMDRIVERID hadid, LPACMFORMATTAGDETAILSA paftd,
+      DWORD_PTR dwInstance, DWORD fdwSupport) ACMFORMATTAGENUMCBA;
+    alias BOOL function(HACMDRIVERID hadid, LPACMFORMATTAGDETAILSW paftd,
+      DWORD_PTR dwInstance, DWORD fdwSupport) ACMFORMATTAGENUMCBW;
+    alias BOOL function(HACMDRIVERID hadid, DWORD_PTR dwInstance,
+      DWORD fdwSupport) ACMDRIVERENUMCB;
+
+    MMRESULT acmDriverOpen(LPHACMDRIVER phad, HACMDRIVERID hadid,
+      DWORD fdwOpen);
+    MMRESULT acmDriverEnum(ACMDRIVERENUMCB fnCallback, DWORD_PTR dwInstance,
+      DWORD fdwEnum);
+    MMRESULT acmFormatEnumA(HACMDRIVER had, LPACMFORMATDETAILSA pafd,
+      ACMFORMATENUMCBA fnCallback, DWORD_PTR dwInstance, DWORD fdwEnum);
+    MMRESULT acmFormatEnumW(HACMDRIVER had, LPACMFORMATDETAILSW pafd,
+      ACMFORMATENUMCBW fnCallback, DWORD_PTR dwInstance, DWORD fdwEnum);
+    MMRESULT acmDriverClose(HACMDRIVER had, DWORD fdwClose);
+    MMRESULT acmDriverDetailsA(HACMDRIVERID hadid, LPACMDRIVERDETAILSA padd,
+      DWORD fdwDetails);
+    MMRESULT acmDriverDetailsW(HACMDRIVERID hadid, LPACMDRIVERDETAILSW padd,
+      DWORD fdwDetails);
+    MMRESULT acmFormatTagEnumA(HACMDRIVER had, LPACMFORMATTAGDETAILSA paftd,
+      ACMFORMATTAGENUMCBA fnCallback, DWORD_PTR dwInstance, DWORD fdwEnum);
+    MMRESULT acmFormatTagEnumW(HACMDRIVER had, LPACMFORMATTAGDETAILSW paftd,
+      ACMFORMATTAGENUMCBW fnCallback, DWORD_PTR dwInstance, DWORD fdwEnum);
+}
+
+version (Unicode) {
+    alias ACMFORMATDETAILSW ACMFORMATDETAILS;
+    alias ACMFORMATTAGDETAILSW ACMFORMATTAGDETAILS;
+    alias ACMDRIVERDETAILSW ACMDRIVERDETAILS;
+    alias ACMFORMATENUMCBW ACMFORMATENUMCB;
+    alias ACMFORMATTAGENUMCBW ACMFORMATTAGENUMCB;
+    alias acmFormatEnumW acmFormatEnum;
+    alias acmDriverDetailsW acmDriverDetails;
+    alias acmFormatTagEnumW acmFormatTagEnum;
+} else {
+    alias ACMFORMATDETAILSA ACMFORMATDETAILS;
+    alias ACMFORMATTAGDETAILSA ACMFORMATTAGDETAILS;
+    alias ACMDRIVERDETAILSA ACMDRIVERDETAILS;
+    alias ACMFORMATENUMCBA ACMFORMATENUMCB;
+    alias ACMFORMATTAGENUMCBA ACMFORMATTAGENUMCB;
+    alias acmFormatEnumA acmFormatEnum;
+    alias acmDriverDetailsA acmDriverDetails;
+    alias acmFormatTagEnumA acmFormatTagEnum;
+}
+
+alias ACMFORMATDETAILS* LPACMFORMATDETAILS;
+alias ACMFORMATTAGDETAILS* LPACMFORMATTAGDETAILS;
+alias ACMDRIVERDETAILS* LPACMDRIVERDETAILS;
diff --git a/libphobos/libdruntime/core/sys/windows/mshtml.d b/libphobos/libdruntime/core/sys/windows/mshtml.d
new file mode 100644
index 00000000000..796f1d3083f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/mshtml.d
@@ -0,0 +1,536 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_mshtml.d)
+ */
+module core.sys.windows.mshtml;
+version (Windows):
+
+private import core.sys.windows.basetyps, core.sys.windows.oaidl, core.sys.windows.unknwn,
+  core.sys.windows.windef, core.sys.windows.wtypes;
+
+// These are used in this file, but not defined in MinGW.
+interface IHTMLStyleSheet {};
+alias IHTMLStyle LPHTMLSTYLE;
+alias IHTMLStyleSheet LPHTMLSTYLESHEET;
+interface IHTMLLocation {};
+alias IHTMLLocation LPHTMLLOCATION;
+interface IHTMLFramesCollection {};
+alias IHTMLFramesCollection LPHTMLFRAMESCOLLECTION;
+interface IHTMLStyleSheetsCollection {};
+alias IHTMLStyleSheetsCollection LPHTMLSTYLESHEETSCOLLECTION;
+interface IHTMLStyle {};
+interface IHTMLFiltersCollection {};
+alias IHTMLFiltersCollection LPHTMLFILTERSCOLLECTION;
+interface IOmHistory : IDispatch {
+    HRESULT get_length(short* p);
+    HRESULT back(VARIANT*);
+    HRESULT forward(VARIANT*);
+    HRESULT go(VARIANT*);
+};
+alias IOmHistory LPOMHISTORY;
+interface IOmNavigator {};
+alias IOmNavigator LPOMNAVIGATOR;
+interface IHTMLImageElementFactory {};
+alias IHTMLImageElementFactory LPHTMLIMAGEELEMENTFACTORY;
+interface IHTMLEventObj {};
+alias IHTMLEventObj LPHTMLEVENTOBJ;
+interface IHTMLScreen {};
+alias IHTMLScreen LPHTMLSCREEN;
+interface IHTMLOptionElementFactory {};
+alias IHTMLOptionElementFactory LPHTMLOPTIONELEMENTFACTORY;
+
+interface IHTMLLinkElement : IDispatch {
+    HRESULT put_href(BSTR);
+    HRESULT get_href(BSTR*);
+    HRESULT put_rel(BSTR);
+    HRESULT get_rel(BSTR*);
+    HRESULT put_rev(BSTR);
+    HRESULT get_rev(BSTR*);
+    HRESULT put_type(BSTR);
+    HRESULT get_type(BSTR*);
+    HRESULT get_readyState(BSTR*);
+    HRESULT put_onreadystatechange(VARIANT);
+    HRESULT get_onreadystatechange(VARIANT*);
+    HRESULT put_onload(VARIANT);
+    HRESULT get_onload(VARIANT*);
+    HRESULT put_onerror(VARIANT);
+    HRESULT get_onerror(VARIANT*);
+    HRESULT get_styleSheet(LPHTMLSTYLESHEET*);
+    HRESULT put_disabled(VARIANT_BOOL);
+    HRESULT get_disabled(VARIANT_BOOL*);
+    HRESULT put_media(BSTR);
+    HRESULT get_media(BSTR*);
+}
+alias IHTMLLinkElement LPHTMLLINKELEMENT;
+
+interface IHTMLImgElement : IDispatch {
+    HRESULT put_isMap(VARIANT_BOOL);
+    HRESULT get_isMap(VARIANT_BOOL*);
+    HRESULT put_useMap(BSTR);
+    HRESULT get_useMap(BSTR*);
+    HRESULT get_mimeType(BSTR*);
+    HRESULT get_fileSize(BSTR*);
+    HRESULT get_fileCreatedDate(BSTR*);
+    HRESULT get_fileModifiedDate(BSTR*);
+    HRESULT get_fileUpdatedDate(BSTR*);
+    HRESULT get_protocol(BSTR*);
+    HRESULT get_href(BSTR*);
+    HRESULT get_nameProp(BSTR*);
+    HRESULT put_border(VARIANT);
+    HRESULT get_border(VARIANT*);
+    HRESULT put_vspace(LONG);
+    HRESULT get_vspace(LONG*);
+    HRESULT put_hspace(LONG);
+    HRESULT get_hspace(LONG*);
+    HRESULT put_alt(BSTR);
+    HRESULT get_alt(BSTR*);
+    HRESULT put_src(BSTR);
+    HRESULT get_src(BSTR*);
+    HRESULT put_lowsrc(BSTR);
+    HRESULT get_lowsrc(BSTR*);
+    HRESULT put_vrml(BSTR);
+    HRESULT get_vrml(BSTR*);
+    HRESULT put_dynsrc(BSTR);
+    HRESULT get_dynsrc(BSTR*);
+    HRESULT get_readyState(BSTR*);
+    HRESULT get_complete(VARIANT_BOOL*);
+    HRESULT put_loop(VARIANT);
+    HRESULT get_loop(VARIANT*);
+    HRESULT put_align(BSTR);
+    HRESULT get_align(BSTR*);
+    HRESULT put_onload(VARIANT);
+    HRESULT get_onload(VARIANT*);
+    HRESULT put_onerror(VARIANT);
+    HRESULT get_onerror(VARIANT*);
+    HRESULT put_onabort(VARIANT);
+    HRESULT get_onabort(VARIANT*);
+    HRESULT put_name(BSTR);
+    HRESULT get_name(BSTR*);
+    HRESULT put_width(LONG);
+    HRESULT get_width(LONG*);
+    HRESULT put_height(LONG);
+    HRESULT get_height(LONG*);
+    HRESULT put_start(BSTR);
+    HRESULT get_start(BSTR*);
+}
+alias IHTMLImgElement LPHTMLIMGELEMENT;
+
+interface IHTMLElementCollection : IDispatch {
+    HRESULT toString(BSTR*);
+    HRESULT put_length(LONG);
+    HRESULT get_length(LONG*);
+    HRESULT get__newEnum(IUnknown*);
+    HRESULT item(VARIANT,VARIANT,IDispatch* pDisp);
+    HRESULT tags(VARIANT,IDispatch* pdisp);
+}
+alias IHTMLElementCollection LPHTMLELEMENTCOLLECTION;
+
+interface IHTMLDocument : IDispatch {
+    HRESULT get_Script(IDispatch*);
+}
+
+interface IHTMLDocument2 : IHTMLDocument {
+    HRESULT get_all(LPHTMLELEMENTCOLLECTION*);
+    HRESULT get_body(LPHTMLELEMENT*);
+    HRESULT get_activeElement(LPHTMLELEMENT*);
+    HRESULT get_images(LPHTMLELEMENTCOLLECTION*);
+    HRESULT get_applets(LPHTMLELEMENTCOLLECTION*);
+    HRESULT get_links(LPHTMLELEMENTCOLLECTION*);
+    HRESULT get_forms(LPHTMLELEMENTCOLLECTION*);
+    HRESULT get_anchors(LPHTMLELEMENTCOLLECTION*);
+    HRESULT put_title(BSTR);
+    HRESULT get_title(BSTR*);
+    HRESULT get_scripts(LPHTMLELEMENTCOLLECTION*);
+    HRESULT put_designMode(BSTR);
+    HRESULT get_designMode(BSTR*);
+    HRESULT get_selection(LPHTMLSELECTIONOBJECT*);
+    HRESULT get_readyState(BSTR*);
+    HRESULT get_frames(IHTMLFramesCollection2*);
+    HRESULT get_embeds(LPHTMLELEMENTCOLLECTION*);
+    HRESULT get_plugins(LPHTMLELEMENTCOLLECTION*);
+    HRESULT put_alinkColor(VARIANT);
+    HRESULT get_alinkColor(VARIANT*);
+    HRESULT put_bgColor(VARIANT);
+    HRESULT get_bgColor(VARIANT*);
+    HRESULT put_fgColor(VARIANT);
+    HRESULT get_fgColor(VARIANT*);
+    HRESULT put_linkColor(VARIANT);
+    HRESULT get_linkColor(VARIANT*);
+    HRESULT put_vlinkColor(VARIANT);
+    HRESULT get_vlinkColor(VARIANT*);
+    HRESULT get_referrer(BSTR*);
+    HRESULT get_location(LPHTMLLOCATION*);
+    HRESULT get_lastModified(BSTR*);
+    HRESULT put_url(BSTR);
+    HRESULT get_url(BSTR*);
+    HRESULT put_domain(BSTR);
+    HRESULT get_domain(BSTR*);
+    HRESULT put_cookie(BSTR);
+    HRESULT get_cookie(BSTR*);
+    HRESULT put_expands(VARIANT_BOOL);
+    HRESULT get_expands(VARIANT_BOOL*);
+    HRESULT put_charset(BSTR);
+    HRESULT get_charset(BSTR*);
+    HRESULT put_defaultCharset(BSTR);
+    HRESULT get_defaultCharset(BSTR*);
+    HRESULT get_mimeType(BSTR*);
+    HRESULT get_fileSize(BSTR*);
+    HRESULT get_fileCreatedDate(BSTR*);
+    HRESULT get_fileModifiedDate(BSTR*);
+    HRESULT get_fileUpdatedDate(BSTR*);
+    HRESULT get_security(BSTR*);
+    HRESULT get_protocol(BSTR*);
+    HRESULT get_nameProp(BSTR*);
+    HRESULT write(SAFEARRAY*);
+    HRESULT writeln(SAFEARRAY*);
+    HRESULT open(BSTR,VARIANT,VARIANT,VARIANT,IDispatch*);
+    HRESULT close();
+    HRESULT clear();
+    HRESULT queryCommandSupported(BSTR,VARIANT_BOOL*);
+    HRESULT queryCommandEnabled(BSTR,VARIANT_BOOL*);
+    HRESULT queryCommandState(BSTR,VARIANT_BOOL*);
+    HRESULT queryCommandIndeterm(BSTR,VARIANT_BOOL*);
+    HRESULT queryCommandText(BSTR,BSTR*);
+    HRESULT queryCommandValue(BSTR,VARIANT*);
+    HRESULT execCommand(BSTR,VARIANT_BOOL,VARIANT,VARIANT_BOOL*);
+    HRESULT execCommandShowHelp(BSTR,VARIANT_BOOL*);
+    HRESULT createElement(BSTR,LPHTMLELEMENT*);
+    HRESULT put_onhelp(VARIANT);
+    HRESULT get_onhelp(VARIANT*);
+    HRESULT put_onclick(VARIANT);
+    HRESULT get_onclick(VARIANT*);
+    HRESULT put_ondblclick(VARIANT);
+    HRESULT get_ondblclick(VARIANT*);
+    HRESULT put_onkeyup(VARIANT);
+    HRESULT get_onkeyup(VARIANT*);
+    HRESULT put_onkeydown(VARIANT);
+    HRESULT get_onkeydown(VARIANT*);
+    HRESULT put_onkeypress(VARIANT);
+    HRESULT get_onkeypress(VARIANT*);
+    HRESULT put_onmouseup(VARIANT);
+    HRESULT get_onmouseup(VARIANT*);
+    HRESULT put_onmousedown(VARIANT);
+    HRESULT get_onmousedown(VARIANT*);
+    HRESULT put_onmousemove(VARIANT);
+    HRESULT get_onmousemove(VARIANT*);
+    HRESULT put_onmouseout(VARIANT);
+    HRESULT get_onmouseout(VARIANT*);
+    HRESULT put_onmouseover(VARIANT);
+    HRESULT get_onmouseover(VARIANT*);
+    HRESULT put_onreadystatechange(VARIANT);
+    HRESULT get_onreadystatechange(VARIANT*);
+    HRESULT put_onafterupdate(VARIANT);
+    HRESULT get_onafterupdate(VARIANT*);
+    HRESULT put_onrowexit(VARIANT);
+    HRESULT get_onrowexit(VARIANT*);
+    HRESULT put_onrowenter(VARIANT);
+    HRESULT get_onrowenter(VARIANT*);
+    HRESULT put_ondragstart(VARIANT);
+    HRESULT get_ondragstart(VARIANT*);
+    HRESULT put_onselectstart(VARIANT);
+    HRESULT get_onselectstart(VARIANT*);
+    HRESULT elementFromPoint(LONG,LONG,LPHTMLELEMENT*);
+    HRESULT get_parentWindow(LPHTMLWINDOW2*);
+    HRESULT get_styleSheets(LPHTMLSTYLESHEETSCOLLECTION*);
+    HRESULT put_onbeforeupdate(VARIANT);
+    HRESULT get_onbeforeupdate(VARIANT*);
+    HRESULT put_onerrorupdate(VARIANT);
+    HRESULT get_onerrorupdate(VARIANT*);
+    HRESULT toString(BSTR*);
+    HRESULT createStyleSheet(BSTR,LONG,LPHTMLSTYLESHEET*);
+}
+
+interface IHTMLSelectionObject : IDispatch {
+    HRESULT createRange(IDispatch*);
+    HRESULT empty();
+    HRESULT clear();
+    HRESULT get_type(BSTR*);
+}
+alias IHTMLSelectionObject LPHTMLSELECTIONOBJECT;
+
+interface IHTMLTxtRange : IDispatch {
+    HRESULT get_htmlText(BSTR*);
+    HRESULT put_text(BSTR);
+    HRESULT get_text(BSTR*);
+    HRESULT parentElement(LPHTMLELEMENT*);
+    HRESULT duplicate(IHTMLTxtRange*);
+    HRESULT inRange(IHTMLTxtRange,VARIANT_BOOL*);
+    HRESULT isEqual(IHTMLTxtRange,VARIANT_BOOL*);
+    HRESULT scrollIntoView(VARIANT_BOOL);
+    HRESULT collapse(VARIANT_BOOL);
+    HRESULT expand(BSTR,VARIANT_BOOL*);
+    HRESULT move(BSTR,LONG,LONG*);
+    HRESULT moveStart(BSTR,LONG,LONG*);
+    HRESULT moveEnd(BSTR,LONG,LONG*);
+    HRESULT select();
+    HRESULT pasteHTML(BSTR);
+    HRESULT moveToElementText(LPHTMLELEMENT);
+    HRESULT setEndPoint(BSTR,IHTMLTxtRange);
+    HRESULT compareEndPoints(BSTR,IHTMLTxtRange,LONG*);
+    HRESULT findText(BSTR,LONG,LONG,VARIANT_BOOL*);
+    HRESULT moveToPoint(LONG,LONG);
+    HRESULT getBookmark(BSTR*);
+    HRESULT moveToBookbark(BSTR,VARIANT_BOOL*);
+    HRESULT queryCommandSupported(BSTR,VARIANT_BOOL*);
+    HRESULT queryCommandEnabled(BSTR,VARIANT_BOOL*);
+    HRESULT queryCommandState(BSTR,VARIANT_BOOL*);
+    HRESULT queryCommandIndeterm(BSTR,VARIANT_BOOL*);
+    HRESULT queryCommandText(BSTR,BSTR*);
+    HRESULT queryCommandValue(BSTR,VARIANT*);
+    HRESULT execCommand(BSTR,VARIANT_BOOL,VARIANT,VARIANT_BOOL*);
+    HRESULT execCommandShowHelp(BSTR,VARIANT_BOOL*);
+}
+
+interface IHTMLElement : IDispatch {
+    HRESULT setAttribute(BSTR,VARIANT,LONG);
+    HRESULT getAttribute(BSTR,LONG,VARIANT*);
+    HRESULT removeAttribute(BSTR,LONG,VARIANT_BOOL*);
+    HRESULT put_className(BSTR);
+    HRESULT get_className(BSTR*);
+    HRESULT put_id(BSTR);
+    HRESULT get_id(BSTR*);
+    HRESULT get_tagName(BSTR*);
+    HRESULT get_parentElement(LPHTMLELEMENT*);
+    HRESULT get_style(LPHTMLSTYLE*);
+    HRESULT put_onhelp(VARIANT);
+    HRESULT get_onhelp(VARIANT*);
+    HRESULT put_onclick(VARIANT);
+    HRESULT get_onclick(VARIANT*);
+    HRESULT put_ondblclick(VARIANT);
+    HRESULT get_ondblclick(VARIANT*);
+    HRESULT put_onkeydown(VARIANT);
+    HRESULT get_onkeydown(VARIANT*);
+    HRESULT put_onkeyup(VARIANT);
+    HRESULT get_onkeyup(VARIANT*);
+    HRESULT put_onkeypress(VARIANT);
+    HRESULT get_onkeypress(VARIANT*);
+    HRESULT put_onmouseout(VARIANT);
+    HRESULT get_onmouseout(VARIANT*);
+    HRESULT put_onmouseover(VARIANT);
+    HRESULT get_onmouseover(VARIANT*);
+    HRESULT put_onmousemove(VARIANT);
+    HRESULT get_onmousemove(VARIANT*);
+    HRESULT put_onmousedown(VARIANT);
+    HRESULT get_onmousedown(VARIANT*);
+    HRESULT put_onmouseup(VARIANT);
+    HRESULT get_onmouseup(VARIANT*);
+    HRESULT get_document(IDispatch*);
+    HRESULT put_title(BSTR);
+    HRESULT get_title(BSTR*);
+    HRESULT put_language(BSTR);
+    HRESULT get_language(BSTR*);
+    HRESULT put_onselectstart(VARIANT);
+    HRESULT get_onselectstart(VARIANT*);
+    HRESULT scrollIntoView(VARIANT);
+    HRESULT contains(LPHTMLELEMENT,VARIANT_BOOL*);
+    HRESULT get_source3Index(LONG*);
+    HRESULT get_recordNumber(VARIANT*);
+    HRESULT put_lang(BSTR);
+    HRESULT get_lang(BSTR*);
+    HRESULT get_offsetLeft(LONG*);
+    HRESULT get_offsetTop(LONG*);
+    HRESULT get_offsetWidth(LONG*);
+    HRESULT get_offsetHeight(LONG*);
+    HRESULT get_offsetParent(LPHTMLELEMENT*);
+    HRESULT put_innerHTML(BSTR);
+    HRESULT get_innerHTML(BSTR*);
+    HRESULT put_innerText(BSTR);
+    HRESULT get_innerText(BSTR*);
+    HRESULT put_outerHTML(BSTR);
+    HRESULT get_outerHTML(BSTR*);
+    HRESULT put_outerText(BSTR);
+    HRESULT get_outerText(BSTR*);
+    HRESULT insertAdjacentHTML(BSTR,BSTR);
+    HRESULT insertAdjacentText(BSTR,BSTR);
+    HRESULT get_parentTextEdit(LPHTMLELEMENT*);
+    HRESULT isTextEdit(VARIANT_BOOL*);
+    HRESULT click();
+    HRESULT get_filters(LPHTMLFILTERSCOLLECTION*);
+    HRESULT put_ondragstart(VARIANT);
+    HRESULT get_ondragstart(VARIANT*);
+    HRESULT toString(BSTR*);
+    HRESULT put_onbeforeupdate(VARIANT);
+    HRESULT get_onbeforeupdate(VARIANT*);
+    HRESULT put_onafterupdate(VARIANT);
+    HRESULT get_onafterupdate(VARIANT*);
+    HRESULT put_onerrorupdate(VARIANT);
+    HRESULT get_onerrorupdate(VARIANT*);
+    HRESULT put_onrowexit(VARIANT);
+    HRESULT get_onrowexit(VARIANT*);
+    HRESULT put_onrowenter(VARIANT);
+    HRESULT get_onrowenter(VARIANT*);
+    HRESULT put_ondatasetchanged(VARIANT);
+    HRESULT get_ondatasetchanged(VARIANT*);
+    HRESULT put_ondataavailable(VARIANT);
+    HRESULT get_ondataavailable(VARIANT*);
+    HRESULT put_ondatasetcomplete(VARIANT);
+    HRESULT get_ondatasetcomplete(VARIANT*);
+    HRESULT put_onfilterchange(VARIANT);
+    HRESULT get_onfilterchange(VARIANT*);
+    HRESULT get_children(IDispatch*);
+    HRESULT get_all(IDispatch*);
+}
+alias IHTMLElement LPHTMLELEMENT;
+
+interface IHTMLFramesCollection2 : IDispatch {
+    HRESULT item(VARIANT*,VARIANT*);
+    HRESULT get_length(LONG*);
+}
+
+interface IHTMLWindow2 : IHTMLFramesCollection2 {
+    HRESULT get_frames(IHTMLFramesCollection2*);
+    HRESULT put_defaultStatus(BSTR);
+    HRESULT get_defaultStatus(BSTR*);
+    HRESULT put_status(BSTR);
+    HRESULT get_status(BSTR*);
+    HRESULT setTimeout(BSTR,LONG,VARIANT*,LONG*);
+    HRESULT clearTimeout(LONG);
+    HRESULT alert(BSTR);
+    HRESULT confirm(BSTR,VARIANT_BOOL*);
+    HRESULT prompt(BSTR,BSTR,VARIANT*);
+    HRESULT get_Image(LPHTMLIMAGEELEMENTFACTORY*);
+    HRESULT get_location(LPHTMLLOCATION*);
+    HRESULT get_history(LPOMHISTORY*);
+    HRESULT close();
+    HRESULT put_opener(VARIANT);
+    HRESULT get_opener(VARIANT*);
+    HRESULT get_navigator(LPOMNAVIGATOR*);
+    HRESULT put_name(BSTR);
+    HRESULT get_name(BSTR*);
+    HRESULT get_parent(LPHTMLWINDOW2*);
+    HRESULT open(BSTR,BSTR,BSTR,VARIANT_BOOL,LPHTMLWINDOW2*);
+    HRESULT get_self(LPHTMLWINDOW2*);
+    HRESULT get_top(LPHTMLWINDOW2*);
+    HRESULT get_window(LPHTMLWINDOW2*);
+    HRESULT navigate(BSTR);
+    HRESULT put_onfocus(VARIANT);
+    HRESULT get_onfocus(VARIANT*);
+    HRESULT put_onblur(VARIANT);
+    HRESULT get_onblur(VARIANT*);
+    HRESULT put_onload(VARIANT);
+    HRESULT get_onload(VARIANT*);
+    HRESULT put_onbeforeunload(VARIANT);
+    HRESULT get_onbeforeunload(VARIANT*);
+    HRESULT put_onunload(VARIANT);
+    HRESULT get_onunload(VARIANT*);
+    HRESULT put_onhelp(VARIANT);
+    HRESULT get_onhelp(VARIANT*);
+    HRESULT put_onerror(VARIANT);
+    HRESULT get_onerror(VARIANT*);
+    HRESULT put_onresize(VARIANT);
+    HRESULT get_onresize(VARIANT*);
+    HRESULT put_onscroll(VARIANT);
+    HRESULT get_onscroll(VARIANT*);
+    HRESULT get_document(IHTMLDocument2*);
+    HRESULT get_event(LPHTMLEVENTOBJ*);
+    HRESULT get__newEnum(IUnknown*);
+    HRESULT showModalDialog(BSTR,VARIANT*,VARIANT*,VARIANT*);
+    HRESULT showHelp(BSTR,VARIANT,BSTR);
+    HRESULT get_screen(LPHTMLSCREEN*);
+    HRESULT get_Option(LPHTMLOPTIONELEMENTFACTORY*);
+    HRESULT focus();
+    HRESULT get_closed(VARIANT_BOOL*);
+    HRESULT blur();
+    HRESULT scroll(long,long);
+    HRESULT get_clientInformation(LPOMNAVIGATOR*);
+    HRESULT setInterval(BSTR,long,VARIANT*,long*);
+    HRESULT clearInterval(long);
+    HRESULT put_offscreenBuffering(VARIANT);
+    HRESULT get_offscreenBuffering(VARIANT*);
+    HRESULT execScript(BSTR,BSTR,VARIANT*);
+    HRESULT toString(BSTR*);
+    HRESULT scrollBy(LONG,LONG);
+    HRESULT scrollTo(LONG,LONG);
+    HRESULT moveTo(LONG,LONG);
+    HRESULT moveBy(LONG,LONG);
+    HRESULT resizeTo(LONG,LONG);
+    HRESULT resizeBy(LONG,LONG);
+    HRESULT get_external(IDispatch*);
+}
+alias IHTMLWindow2 LPHTMLWINDOW2;
+
+interface IHTMLFrameBase : IDispatch {
+    HRESULT put_src(BSTR);
+    HRESULT get_src(BSTR*);
+    HRESULT put_name(BSTR);
+    HRESULT get_name(BSTR*);
+    HRESULT put_border(VARIANT);
+    HRESULT get_border(VARIANT*);
+    HRESULT put_frameBorder(BSTR);
+    HRESULT get_frameBorder(BSTR*);
+    HRESULT put_frameSpacing(VARIANT);
+    HRESULT get_frameSpacing(VARIANT*);
+    HRESULT put_marginWidth(VARIANT);
+    HRESULT get_marginWidth(VARIANT*);
+    HRESULT put_marginHeight(VARIANT);
+    HRESULT get_marginHeight(VARIANT*);
+    HRESULT put_noResize(VARIANT_BOOL);
+    HRESULT get_noResize(VARIANT_BOOL*);
+    HRESULT put_scrolling(BSTR);
+    HRESULT get_scrolling(BSTR*);
+}
+
+interface IHTMLFrameBase2 : IDispatch {
+    HRESULT get_contentWindow(IHTMLWindow2*);
+    HRESULT put_onload(VARIANT);
+    HRESULT get_onload(VARIANT*);
+    HRESULT put_onreadystatechange(VARIANT);
+    HRESULT get_onreadystatechange(VARIANT*);
+    HRESULT get_readyState(BSTR*);
+    HRESULT put_allowTransparency(VARIANT_BOOL);
+    HRESULT get_allowTransparency(VARIANT_BOOL*);
+}
+
+interface IHTMLFrameBase3 : IDispatch {
+    HRESULT put_longDesc(BSTR);
+    HRESULT get_longDesc(BSTR*);
+}
+
+interface IHTMLBodyElement : IDispatch {
+    HRESULT put_background(BSTR);
+    HRESULT get_background(BSTR*);
+    HRESULT put_bgProperties(BSTR);
+    HRESULT get_bgProperties(BSTR*);
+    HRESULT put_leftMargin(VARIANT);
+    HRESULT get_leftMargin(VARIANT*);
+    HRESULT put_topMargin(VARIANT);
+    HRESULT get_topMargin(VARIANT*);
+    HRESULT put_rightMargin(VARIANT);
+    HRESULT get_rightMargin(VARIANT*);
+    HRESULT put_bottomMargin(VARIANT);
+    HRESULT get_bottomMargin(VARIANT*);
+    HRESULT put_noWrap(VARIANT_BOOL);
+    HRESULT get_noWrap(VARIANT_BOOL*);
+    HRESULT put_bgColor(VARIANT);
+    HRESULT get_bgColor(VARIANT*);
+    HRESULT put_text(VARIANT);
+    HRESULT get_text(VARIANT*);
+    HRESULT put_link(VARIANT);
+    HRESULT get_link(VARIANT*);
+    HRESULT put_vLink(VARIANT);
+    HRESULT get_vLink(VARIANT*);
+    HRESULT put_aLink(VARIANT);
+    HRESULT get_aLink(VARIANT*);
+    HRESULT put_onload(VARIANT);
+    HRESULT get_onload(VARIANT*);
+    HRESULT put_onunload(VARIANT);
+    HRESULT get_onunload(VARIANT*);
+    HRESULT put_scroll(BSTR);
+    HRESULT get_scroll(BSTR*);
+    HRESULT put_onselect(VARIANT);
+    HRESULT get_onselect(VARIANT*);
+    HRESULT put_onbeforeunload(VARIANT);
+    HRESULT get_onbeforeunload(VARIANT*);
+    HRESULT createTextRange(IHTMLTxtRange*);
+}
+
+interface IHTMLBodyElement2 : IDispatch {
+    HRESULT put_onbeforeprint(VARIANT);
+    HRESULT get_onbeforeprint(VARIANT*);
+    HRESULT put_onafterprint(VARIANT);
+    HRESULT get_onafterprint(VARIANT*);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/mswsock.d b/libphobos/libdruntime/core/sys/windows/mswsock.d
new file mode 100644
index 00000000000..7b10977b7e7
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/mswsock.d
@@ -0,0 +1,197 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Daniel Keep
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_mswsock.d)
+ */
+module core.sys.windows.mswsock;
+version (Windows):
+
+import core.sys.windows.winbase, core.sys.windows.windef;
+private import core.sys.windows.basetyps, core.sys.windows.w32api;
+
+// FIXME: clean up Windows version support
+
+version (Win32_Winsock2) pragma(msg,
+ "Version Win32_Winsock2 is deprecated; Winsock2 is now imported by default");
+
+// Pull in Winsock1 if the user has put "Win32_Winsock1" on the compile
+// line; otherwise, default to Winsock2.
+version (Win32_Winsock1) {
+    import core.sys.windows.winsock;
+} else {
+    import core.sys.windows.winsock2;
+}
+
+//static if (_WIN32_WINNT >= 0x500) {
+    enum {
+        /* WinNT5+:
+           ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/socket_options.htm */
+        SO_MAXDG             = 0x7009,
+        SO_MAXPATHDG         = 0x700A,
+    }
+//}
+
+enum {
+    /* WinNT4+:
+       ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/socket_options_for_windows_nt_4_0_2.htm */
+    SO_CONNDATA              = 0x7000,
+    SO_CONNOPT               = 0x7001,
+    SO_DISCDATA              = 0x7002,
+    SO_DISCOPT               = 0x7003,
+    SO_CONNDATALEN           = 0x7004,
+    SO_CONNOPTLEN            = 0x7005,
+    SO_DISCDATALEN           = 0x7006,
+    SO_DISCOPTLEN            = 0x7007,
+
+    /* WinNT4:
+       ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/socket_options.htm */
+    SO_UPDATE_ACCEPT_CONTENT = 0x700B,
+}
+
+enum {
+    /* Win95+, WinNT4+ but apparently shouldn't used: mark as deprecated?
+       ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/socket_options.htm */
+    SO_OPENTYPE                  = 0x7008,
+
+    /* Win95+; these two are passed to the SO_OPENTYPE option as arguments,
+       so would they be deprecated as well?
+       ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/socket_options.htm */
+    SO_SYNCHRONOUS_ALERT         = 0x0010,
+    SO_SYNCHRONOUS_NONALERT      = 0x0020,
+
+    /* Win95:
+       ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/socket_options.htm */
+    SO_CONNECT_TIME              = 0x700C,
+}
+
+
+enum {
+    TCP_BSDURGENT = 0x7000,
+}
+
+/* These *appear* to be constants for passing to the TransmitFile /
+   TransmitPackets functions, which are available in WinNT3.51+
+   ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/transmitfile_2.htm */
+enum {
+    TF_DISCONNECT         = 1,
+    TF_REUSE_SOCKET       = 2,
+    TF_WRITE_BEHIND       = 4,
+    TF_USE_DEFAULT_WORKER = 0,
+    TF_USE_SYSTEM_THREAD  = 16,
+    TF_USE_KERNEL_APC     = 32
+}
+
+/* Win95+, WinNT3.51+
+   ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/transmit_file_buffers_2.htm */
+struct TRANSMIT_FILE_BUFFERS {
+    PVOID Head;
+    DWORD HeadLength;
+    PVOID Tail;
+    DWORD TailLength;
+}
+alias TRANSMIT_FILE_BUFFERS* PTRANSMIT_FILE_BUFFERS, LPTRANSMIT_FILE_BUFFERS;
+
+extern(Windows) {
+    /* Win95+, WinNT3.51+
+       ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/wsarecvex_2.htm */
+    int WSARecvEx(SOCKET, char*, int, int*);
+
+    /* Win95+, WinNT3.51+
+       ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/getacceptexSOCKADDRs_2.htm */
+    VOID GetAcceptExSockaddrs(PVOID, DWORD, DWORD, DWORD, SOCKADDR**, LPINT, SOCKADDR**, LPINT);
+
+    /* WinNT3.51+
+       ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/transmitfile_2.htm */
+    BOOL TransmitFile(SOCKET, HANDLE, DWORD, DWORD, LPOVERLAPPED, LPTRANSMIT_FILE_BUFFERS, DWORD);
+
+    /* WinNT3.51+
+       ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/acceptex_2.htm */
+    alias BOOL function(SOCKET, SOCKET, PVOID, DWORD, DWORD, DWORD, LPDWORD, LPOVERLAPPED) LPFN_ACCEPTEX;
+enum GUID WSAID_ACCEPTEX = {0xb5367df1,0xcbac,0x11cf,[0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92]};
+
+    alias BOOL function(SOCKET, SOCKADDR*, int, PVOID, DWORD, LPDWORD, LPOVERLAPPED) LPFN_CONNECTEX;
+enum GUID WSAID_CONNECTEX = {0x25a207b9,0xddf3,0x4660,[0x8e,0xe9,0x76,0xe5,0x8c,0x74,0x06,0x3e]};
+}
+
+version(Win32_Winsock1) {
+} else {
+    static if (_WIN32_WINNT > 0x501) {
+        /*  These appear to be constants for the TRANSMIT_PACKETS_ELEMENT
+         *  structure below, so I've given them the same minimum version
+         */
+        enum {
+            TP_ELEMENT_FILE   = 1,
+            TP_ELEMENT_MEMORY = 2,
+            TP_ELEMENT_EOP    = 4
+        }
+
+        /*  WinXP+, Srv2k3+
+         *  ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/transmit_packets_element_2.htm
+         */
+        struct TRANSMIT_PACKETS_ELEMENT {
+            ULONG dwElFlags;
+            ULONG cLength;
+            union {
+                struct {
+                    LARGE_INTEGER nFileOffset;
+                    HANDLE        hFile;
+                }
+                PVOID pBuffer;
+            }
+        }
+
+        /*  WinXP+, Server2003+:
+         *  ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/wsamsg_2.htm
+         */
+        struct WSAMSG {
+            LPSOCKADDR name;
+            INT        namelen;
+            LPWSABUF   lpBuffers;
+            DWORD      dwBufferCount;
+            WSABUF     Control;
+            DWORD      dwFlags;
+        }
+
+        alias WSAMSG* PWSAMSG, LPWSAMSG;
+
+        /* According to MSDN docs, the WSAMSG.Control buffer starts with a
+           cmsghdr header of the following form.  See also RFC 2292. */
+        /* DK: Confirmed.  So I suppose these should get the same version as
+           WSAMSG... */
+        struct WSACMSGHDR {
+            UINT cmsg_len;
+            INT  cmsg_level;
+            INT  cmsg_type;
+            // followed by UCHAR cmsg_data[];
+        }
+
+        /* TODO: Standard Posix.1g macros as per RFC 2292, with WSA_uglification. */
+        /* DK: MinGW doesn't define these, and neither does the MSDN docs.  Might have
+           to actually look up RFC 2292... */
+        /+
+        #if 0
+        #define WSA_CMSG_FIRSTHDR(mhdr)
+        #define WSA_CMSG_NXTHDR(mhdr, cmsg)
+        #define WSA_CMSG_SPACE(length)
+        #define WSA_CMSG_LEN(length)
+        #endif
+        +/
+
+        extern(Windows)
+        {
+            /*  WinXP+, Srv2k3+
+             *  ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/disconnectex_2.htm
+             */
+            BOOL DisconnectEx(SOCKET, LPOVERLAPPED, DWORD, DWORD);
+
+            /*  WinXP+, Srv2k3+
+             *  ms-help://MS.MSDNQTR.2003FEB.1033/winsock/winsock/wsarecvmsg_2.htm
+             */
+            int WSARecvMsg(SOCKET, LPWSAMSG, LPDWORD, LPWSAOVERLAPPED, LPWSAOVERLAPPED_COMPLETION_ROUTINE);
+        }
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/windows/nb30.d b/libphobos/libdruntime/core/sys/windows/nb30.d
new file mode 100644
index 00000000000..db382dda038
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/nb30.d
@@ -0,0 +1,237 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_nb30.d)
+ */
+module core.sys.windows.nb30;
+version (Windows):
+
+private import core.sys.windows.windef;
+
+enum size_t
+    NCBNAMSZ =  16,
+    MAX_LANA = 254;
+
+// FIXME: are these really two sets of constants?
+enum : UCHAR {
+    REGISTERING     = 0,
+    REGISTERED      = 4,
+    DEREGISTERED,
+    DUPLICATE,
+    DUPLICATE_DEREG, // = 7
+    UNIQUE_NAME     = 0,
+    GROUP_NAME      = 0x80,
+    NAME_FLAGS_MASK = 0x87
+}
+
+enum : UCHAR {
+    LISTEN_OUTSTANDING = 1,
+    CALL_PENDING,
+    SESSION_ESTABLISHED,
+    HANGUP_PENDING,
+    HANGUP_COMPLETE,
+    SESSION_ABORTED // = 6
+}
+
+enum char[4]
+    ALL_TRANSPORTS = "M\0\0\0",
+    MS_NBF         = "MNBF";
+
+enum : UCHAR {
+    NCBCALL        = 0x10,
+    NCBLISTEN,
+    NCBHANGUP,  // = 0x12
+    NCBSEND        = 0x14,
+    NCBRECV,
+    NCBRECVANY,
+    NCBCHAINSEND, // = 0x17
+    NCBDGSEND      = 0x20,
+    NCBDGRECV,
+    NCBDGSENDBC,
+    NCBDGRECVBC, // = 0x23,
+    NCBADDNAME     = 0x30,
+    NCBDELNAME,
+    NCBRESET,
+    NCBASTAT,
+    NCBSSTAT,
+    NCBCANCEL,
+    NCBADDGRNAME,
+    NCBENUM,    // = 0x37
+    NCBUNLINK      = 0x70,
+    NCBSENDNA,
+    NCBCHAINSENDNA,
+    NCBLANSTALERT, // = 0x73
+    NCBACTION      = 0x77,
+    NCBFINDNAME,
+    NCBTRACE    // = 0x79
+}
+
+enum UCHAR ASYNCH = 0x80;
+
+enum : UCHAR {
+    NRC_GOODRET     = 0x00,
+    NRC_BUFLEN      = 0x01,
+    NRC_ILLCMD      = 0x03,
+    NRC_CMDTMO      = 0x05,
+    NRC_INCOMP,
+    NRC_BADDR,
+    NRC_SNUMOUT,
+    NRC_NORES,
+    NRC_SCLOSED,
+    NRC_CMDCAN,  // = 0x0b
+    NRC_DUPNAME     = 0x0d,
+    NRC_NAMTFUL,
+    NRC_ACTSES,  // = 0x0f,
+    NRC_LOCTFUL     = 0x11,
+    NRC_REMTFUL,
+    NRC_ILLNN,
+    NRC_NOCALL,
+    NRC_NOWILD,
+    NRC_INUSE,
+    NRC_NAMERR,
+    NRC_SABORT,
+    NRC_NAMCONF, // = 0x19
+    NRC_IFBUSY      = 0x21,
+    NRC_TOOMANY,
+    NRC_BRIDGE,
+    NRC_CANOCCR, // = 0x24
+    NRC_CANCEL      = 0x26,
+    NRC_DUPENV      = 0x30,
+    NRC_ENVNOTDEF   = 0x34,
+    NRC_OSRESNOTAV,
+    NRC_MAXAPPS,
+    NRC_NOSAPS,
+    NRC_NORESOURCES,
+    NRC_INVADDRESS, // = 0x39
+    NRC_INVDDID     = 0x3B,
+    NRC_LOCKFAIL    = 0x3C,
+    NRC_OPENERR     = 0x3f,
+    NRC_SYSTEM      = 0x40,
+    NRC_PENDING     = 0xff
+}
+
+struct ACTION_HEADER {
+    union {
+        /*  transport_id is defined as a ULONG, but both the above constants
+         *  and the documented description suggest it should be a char[4]
+         */
+        ULONG   transport_id;
+        char[4] c_transport_id;
+    }
+    USHORT action_code;
+    USHORT reserved;
+}
+alias ACTION_HEADER* PACTION_HEADER;
+
+struct ADAPTER_STATUS {
+    UCHAR[6] adapter_address;
+    UCHAR    rev_major;
+    UCHAR    reserved0;
+    UCHAR    adapter_type;
+    UCHAR    rev_minor;
+    WORD     duration;
+    WORD     frmr_recv;
+    WORD     frmr_xmit;
+    WORD     iframe_recv_err;
+    WORD     xmit_aborts;
+    DWORD    xmit_success;
+    DWORD    recv_success;
+    WORD     iframe_xmit_err;
+    WORD     recv_buff_unavail;
+    WORD     t1_timeouts;
+    WORD     ti_timeouts;
+    DWORD    reserved1;
+    WORD     free_ncbs;
+    WORD     max_cfg_ncbs;
+    WORD     max_ncbs;
+    WORD     xmit_buf_unavail;
+    WORD     max_dgram_size;
+    WORD     pending_sess;
+    WORD     max_cfg_sess;
+    WORD     max_sess;
+    WORD     max_sess_pkt_size;
+    WORD     name_count;
+}
+alias ADAPTER_STATUS* PADAPTER_STATUS;
+
+struct FIND_NAME_BUFFER {
+    /*  From Win32 API docs
+     *
+     *  length
+     *      Specifies the length, in bytes, of the FIND_NAME_BUFFER
+     *      structure. Although this structure always occupies 33 bytes,
+     *      not all of the structure is necessarily valid.
+     *
+     *  On this basis, should length be initialised?
+     */
+    UCHAR     length;
+    UCHAR     access_control;
+    UCHAR     frame_control;
+    UCHAR[6]  destination_addr;
+    UCHAR[6]  source_addr;
+    UCHAR[18] routing_info;
+}
+alias FIND_NAME_BUFFER* PFIND_NAME_BUFFER;
+
+struct FIND_NAME_HEADER {
+    WORD  node_count;
+    UCHAR reserved;
+    UCHAR unique_group;
+}
+alias FIND_NAME_HEADER* PFIND_NAME_HEADER;
+
+struct LANA_ENUM {
+    UCHAR             length;
+    UCHAR[MAX_LANA+1] lana;
+}
+alias LANA_ENUM* PLANA_ENUM;
+
+struct NAME_BUFFER {
+    UCHAR[NCBNAMSZ] name;
+    UCHAR           name_num;
+    UCHAR           name_flags;
+}
+alias NAME_BUFFER* PNAME_BUFFER;
+
+struct NCB {
+    UCHAR           ncb_command;
+    UCHAR           ncb_retcode;
+    UCHAR           ncb_lsn;
+    UCHAR           ncb_num;
+    PUCHAR          ncb_buffer;
+    WORD            ncb_length;
+    UCHAR[NCBNAMSZ] ncb_callname;
+    UCHAR[NCBNAMSZ] ncb_name;
+    UCHAR           ncb_rto;
+    UCHAR           ncb_sto;
+    extern (Windows) void function(NCB*) ncb_post;
+    UCHAR           ncb_lana_num;
+    UCHAR           ncb_cmd_cplt;
+    UCHAR[10]       ncb_reserve;
+    HANDLE          ncb_event;
+}
+alias NCB* PNCB;
+
+struct SESSION_BUFFER {
+    UCHAR           lsn;
+    UCHAR           state;
+    UCHAR[NCBNAMSZ] local_name;
+    UCHAR[NCBNAMSZ] remote_name;
+    UCHAR           rcvs_outstanding;
+    UCHAR           sends_outstanding;
+}
+alias SESSION_BUFFER* PSESSION_BUFFER;
+
+struct SESSION_HEADER {
+    UCHAR sess_name;
+    UCHAR num_sess;
+    UCHAR rcv_dg_outstanding;
+    UCHAR rcv_any_outstanding;
+}
+alias SESSION_HEADER* PSESSION_HEADER;
+
+extern (Windows) UCHAR Netbios(PNCB);
diff --git a/libphobos/libdruntime/core/sys/windows/nddeapi.d b/libphobos/libdruntime/core/sys/windows/nddeapi.d
new file mode 100644
index 00000000000..b50e6ccc7e3
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/nddeapi.d
@@ -0,0 +1,164 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_nddeapi.d)
+ */
+module core.sys.windows.nddeapi;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.windef;
+
+// FIXME: check types and grouping of constants
+
+/+
+#ifndef CNLEN /* also in lmcons.h */
+#define CNLEN 15
+#define UNCLEN (CNLEN + 2)
+#endif
++/
+
+enum char    SEP_CHAR  = ',';
+const char[]  BAR_CHAR  = "|";
+enum wchar   SEP_WCHAR = ',';
+const wchar[] BAR_WCHAR = "|";
+
+enum {
+    NDDE_NO_ERROR,
+    NDDE_ACCESS_DENIED,
+    NDDE_BUF_TOO_SMALL,
+    NDDE_ERROR_MORE_DATA,
+    NDDE_INVALID_SERVER,
+    NDDE_INVALID_SHARE,
+    NDDE_INVALID_PARAMETER,
+    NDDE_INVALID_LEVEL,
+    NDDE_INVALID_PASSWORD,
+    NDDE_INVALID_ITEMNAME,
+    NDDE_INVALID_TOPIC,
+    NDDE_INTERNAL_ERROR,
+    NDDE_OUT_OF_MEMORY,
+    NDDE_INVALID_APPNAME,
+    NDDE_NOT_IMPLEMENTED,
+    NDDE_SHARE_ALREADY_EXIST,
+    NDDE_SHARE_NOT_EXIST,
+    NDDE_INVALID_FILENAME,
+    NDDE_NOT_RUNNING,
+    NDDE_INVALID_WINDOW,
+    NDDE_INVALID_SESSION,
+    NDDE_INVALID_ITEM_LIST,
+    NDDE_SHARE_DATA_CORRUPTED,
+    NDDE_REGISTRY_ERROR,
+    NDDE_CANT_ACCESS_SERVER,
+    NDDE_INVALID_SPECIAL_COMMAND,
+    NDDE_INVALID_SECURITY_DESC,
+    NDDE_TRUST_SHARE_FAIL
+}
+
+enum size_t
+    MAX_NDDESHARENAME = 256,
+    MAX_DOMAINNAME = 15,
+    MAX_USERNAME = 15,
+    MAX_APPNAME = 255,
+    MAX_TOPICNAME = 255,
+    MAX_ITEMNAME = 255;
+
+enum NDDEF_NOPASSWORDPROMPT = 1;
+enum NDDEF_NOCACHELOOKUP    = 2;
+enum NDDEF_STRIP_NDDE       = 4;
+
+enum SHARE_TYPE_OLD         = 1;
+enum SHARE_TYPE_NEW         = 2;
+enum SHARE_TYPE_STATIC      = 4;
+
+enum uint
+    NDDE_CMD_SHOW_MASK     = 0x0000FFFF,
+    NDDE_TRUST_CMD_SHOW    = 0x10000000,
+    NDDE_TRUST_SHARE_DEL   = 0x20000000,
+    NDDE_TRUST_SHARE_INIT  = 0x40000000,
+    NDDE_TRUST_SHARE_START = 0x80000000;
+
+struct NDdeShareInfo_tag {
+    LONG    lRevision;
+    LPTSTR  lpszShareName;
+    LONG    lShareType;
+    LPTSTR  lpszAppTopicList;
+    LONG    fSharedFlag;
+    LONG    fService;
+    LONG    fStartAppFlag;
+    LONG    nCmdShow;
+    LONG[2] qModifyId;
+    LONG    cNumItems;
+    LPTSTR  lpszItemList;
+}
+extern (C) {    // huh?
+    NDdeShareInfo_tag  NDDESHAREINFO;
+    NDdeShareInfo_tag* PNDDESHAREINFO;
+}
+
+extern (Windows) {
+    UINT NDdeGetErrorStringA(UINT, LPSTR, DWORD);
+    UINT NDdeGetErrorStringW(UINT, LPWSTR, DWORD);
+    UINT NDdeGetShareSecurityA(LPSTR, LPSTR, SECURITY_INFORMATION,
+      PSECURITY_DESCRIPTOR, DWORD, PDWORD);
+    UINT NDdeGetShareSecurityW(LPWSTR, LPWSTR, SECURITY_INFORMATION,
+      PSECURITY_DESCRIPTOR, DWORD, PDWORD);
+    UINT NDdeGetTrustedShareA(LPSTR, LPSTR, PDWORD, PDWORD, PDWORD);
+    UINT NDdeGetTrustedShareW(LPWSTR, LPWSTR, PDWORD, PDWORD, PDWORD);
+    BOOL NDdeIsValidShareNameA(LPSTR);
+    BOOL NDdeIsValidShareNameW(LPWSTR);
+    BOOL NDdeIsValidAppTopicListA(LPSTR);
+    BOOL NDdeIsValidAppTopicListW(LPWSTR);
+    UINT NDdeSetShareSecurityA(LPSTR, LPSTR, SECURITY_INFORMATION,
+      PSECURITY_DESCRIPTOR);
+    UINT NDdeSetShareSecurityW(LPWSTR, LPWSTR, SECURITY_INFORMATION,
+      PSECURITY_DESCRIPTOR);
+    UINT NDdeSetTrustedShareA(LPSTR, LPSTR, DWORD);
+    UINT NDdeSetTrustedShareW(LPWSTR, LPWSTR, DWORD);
+    UINT NDdeShareAddA(LPSTR, UINT, PSECURITY_DESCRIPTOR, PBYTE, DWORD);
+    UINT NDdeShareAddW(LPWSTR, UINT, PSECURITY_DESCRIPTOR, PBYTE, DWORD);
+    UINT NDdeShareDelA(LPSTR, LPSTR, UINT);
+    UINT NDdeShareDelW(LPWSTR, LPWSTR, UINT);
+    UINT NDdeShareEnumA(LPSTR, UINT, PBYTE, DWORD, PDWORD, PDWORD);
+    UINT NDdeShareEnumW(LPWSTR, UINT, PBYTE, DWORD, PDWORD, PDWORD);
+    UINT NDdeShareGetInfoA(LPSTR, LPSTR, UINT, PBYTE, DWORD, PDWORD, PWORD);
+    UINT NDdeShareGetInfoW(LPWSTR, LPWSTR, UINT, PBYTE, DWORD, PDWORD, PWORD);
+    UINT NDdeShareSetInfoA(LPSTR, LPSTR, UINT, PBYTE, DWORD, WORD);
+    UINT NDdeShareSetInfoW(LPWSTR, LPWSTR, UINT, PBYTE, DWORD, WORD);
+    UINT NDdeTrustedShareEnumA(LPSTR, UINT, PBYTE, DWORD, PDWORD, PDWORD);
+    UINT NDdeTrustedShareEnumW(LPWSTR, UINT, PBYTE, DWORD, PDWORD, PDWORD);
+}
+
+version (Unicode) {
+    alias NDdeShareAddW NDdeShareAdd;
+    alias NDdeShareDelW NDdeShareDel;
+    alias NDdeSetShareSecurityW NDdeSetShareSecurity;
+    alias NDdeGetShareSecurityW NDdeGetShareSecurity;
+    alias NDdeShareEnumW NDdeShareEnum;
+    alias NDdeShareGetInfoW NDdeShareGetInfo;
+    alias NDdeShareSetInfoW NDdeShareSetInfo;
+    alias NDdeGetErrorStringW NDdeGetErrorString;
+    alias NDdeIsValidShareNameW NDdeIsValidShareName;
+    alias NDdeIsValidAppTopicListW NDdeIsValidAppTopicList;
+    alias NDdeSetTrustedShareW NDdeSetTrustedShare;
+    alias NDdeGetTrustedShareW NDdeGetTrustedShare;
+    alias NDdeTrustedShareEnumW NDdeTrustedShareEnum;
+} else {
+    alias NDdeShareAddA NDdeShareAdd;
+    alias NDdeShareDelA NDdeShareDel;
+    alias NDdeSetShareSecurityA NDdeSetShareSecurity;
+    alias NDdeGetShareSecurityA NDdeGetShareSecurity;
+    alias NDdeShareEnumA NDdeShareEnum;
+    alias NDdeShareGetInfoA NDdeShareGetInfo;
+    alias NDdeShareSetInfoA NDdeShareSetInfo;
+    alias NDdeGetErrorStringA NDdeGetErrorString;
+    alias NDdeIsValidShareNameA NDdeIsValidShareName;
+    alias NDdeIsValidAppTopicListA NDdeIsValidAppTopicList;
+    alias NDdeSetTrustedShareA NDdeSetTrustedShare;
+    alias NDdeGetTrustedShareA NDdeGetTrustedShare;
+    alias NDdeTrustedShareEnumA NDdeTrustedShareEnum;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/nspapi.d b/libphobos/libdruntime/core/sys/windows/nspapi.d
new file mode 100644
index 00000000000..07120bbb687
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/nspapi.d
@@ -0,0 +1,150 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_nspapi.d)
+ */
+module core.sys.windows.nspapi;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.basetyps, core.sys.windows.windef;
+
+// FIXME: check types of constants
+
+enum {
+    NS_ALL         =  0,
+
+    NS_SAP,
+    NS_NDS,
+    NS_PEER_BROWSE,
+
+    NS_TCPIP_LOCAL = 10,
+    NS_TCPIP_HOSTS,
+    NS_DNS,
+    NS_NETBT,
+    NS_WINS,
+
+    NS_NBP         = 20,
+
+    NS_MS          = 30,
+    NS_STDA,
+    NS_NTDS,
+
+    NS_X500        = 40,
+    NS_NIS,
+    NS_NISPLUS,
+
+    NS_WRQ         = 50
+}
+
+enum {
+    SERVICE_REGISTER   = 1,
+    SERVICE_DEREGISTER = 2,
+    SERVICE_FLUSH      = 3,
+    SERVICE_FLAG_HARD  = 2
+}
+
+/*  MinGW makes the next section conditional on winsock.h or winsock2.h
+ *  being included.  But that doesn't translate well into D.
+ */
+version (Win32_Winsock1) {
+    import core.sys.windows.winsock;
+} else {
+    import core.sys.windows.winsock2;
+}
+
+struct SOCKET_ADDRESS {
+    LPSOCKADDR lpSockaddr;
+    INT        iSockaddrLength;
+}
+alias SOCKET_ADDRESS* PSOCKET_ADDRESS, LPSOCKET_ADDRESS;
+
+struct CSADDR_INFO {
+    SOCKET_ADDRESS LocalAddr;
+    SOCKET_ADDRESS RemoteAddr;
+    INT            iSocketType;
+    INT            iProtocol;
+}
+alias CSADDR_INFO* PCSADDR_INFO, LPCSADDR_INFO;
+
+struct BLOB {
+    ULONG cbSize;
+    BYTE* pBlobData;
+}
+alias BLOB* PBLOB, LPBLOB;
+
+struct SERVICE_ADDRESS {
+    DWORD dwAddressType;
+    DWORD dwAddressFlags;
+    DWORD dwAddressLength;
+    DWORD dwPrincipalLength;
+    BYTE* lpAddress;
+    BYTE* lpPrincipal;
+}
+
+struct SERVICE_ADDRESSES {
+    DWORD           dwAddressCount;
+    SERVICE_ADDRESS _Addresses;
+
+    SERVICE_ADDRESS* Addresses() return { return &_Addresses; }
+}
+alias SERVICE_ADDRESSES* PSERVICE_ADDRESSES, LPSERVICE_ADDRESSES;
+
+struct SERVICE_INFOA {
+    LPGUID lpServiceType;
+    LPSTR  lpServiceName;
+    LPSTR  lpComment;
+    LPSTR  lpLocale;
+    DWORD  dwDisplayHint;
+    DWORD  dwVersion;
+    DWORD  dwTime;
+    LPSTR  lpMachineName;
+    LPSERVICE_ADDRESSES lpServiceAddress;
+    BLOB   ServiceSpecificInfo;
+}
+alias SERVICE_INFOA* LPSERVICE_INFOA;
+
+struct SERVICE_INFOW {
+    LPGUID lpServiceType;
+    LPWSTR lpServiceName;
+    LPWSTR lpComment;
+    LPWSTR lpLocale;
+    DWORD  dwDisplayHint;
+    DWORD  dwVersion;
+    DWORD  dwTime;
+    LPWSTR lpMachineName;
+    LPSERVICE_ADDRESSES lpServiceAddress;
+    BLOB   ServiceSpecificInfo;
+}
+alias SERVICE_INFOW* LPSERVICE_INFOW;
+
+alias void* LPSERVICE_ASYNC_INFO;
+
+extern (Windows) {
+    INT SetServiceA(DWORD, DWORD, DWORD, LPSERVICE_INFOA,
+      LPSERVICE_ASYNC_INFO, LPDWORD);
+    INT SetServiceW(DWORD, DWORD, DWORD, LPSERVICE_INFOW,
+      LPSERVICE_ASYNC_INFO, LPDWORD);
+    INT GetAddressByNameA(DWORD, LPGUID, LPSTR, LPINT, DWORD,
+      LPSERVICE_ASYNC_INFO, LPVOID, LPDWORD, LPSTR, LPDWORD);
+    INT GetAddressByNameW(DWORD, LPGUID, LPWSTR, LPINT, DWORD,
+      LPSERVICE_ASYNC_INFO, LPVOID, LPDWORD, LPWSTR, LPDWORD);
+}
+
+version (Unicode) {
+    alias SERVICE_INFOW SERVICE_INFO;
+    alias SetServiceW SetService;
+    alias GetAddressByNameW GetAddressByName;
+} else {
+    alias SERVICE_INFOA SERVICE_INFO;
+    alias SetServiceA SetService;
+    alias GetAddressByNameA GetAddressByName;
+}
+
+alias SERVICE_INFO _SERVICE_INFO;
+alias SERVICE_INFO* LPSERVICE_INFO;
diff --git a/libphobos/libdruntime/core/sys/windows/ntdef.d b/libphobos/libdruntime/core/sys/windows/ntdef.d
new file mode 100644
index 00000000000..3dc875e18c9
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/ntdef.d
@@ -0,0 +1,80 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_ntdef.d)
+ */
+module core.sys.windows.ntdef;
+version (Windows):
+
+private import core.sys.windows.basetsd, core.sys.windows.subauth, core.sys.windows.windef, core.sys.windows.winnt;
+
+enum uint
+    OBJ_INHERIT          = 0x0002,
+    OBJ_PERMANENT        = 0x0010,
+    OBJ_EXCLUSIVE        = 0x0020,
+    OBJ_CASE_INSENSITIVE = 0x0040,
+    OBJ_OPENIF           = 0x0080,
+    OBJ_OPENLINK         = 0x0100,
+    OBJ_VALID_ATTRIBUTES = 0x01F2;
+
+void InitializeObjectAttributes(OBJECT_ATTRIBUTES* p, UNICODE_STRING* n,
+      uint a, HANDLE r, void* s) {
+    with (*p) {
+        Length = OBJECT_ATTRIBUTES.sizeof;
+        RootDirectory = r;
+        Attributes = a;
+        ObjectName = n;
+        SecurityDescriptor = s;
+        SecurityQualityOfService = null;
+    }
+}
+
+bool NT_SUCCESS(int x) { return x >= 0; }
+
+/*  In MinGW, NTSTATUS, UNICODE_STRING, STRING and their associated pointer
+ *  type aliases are defined in ntdef.h, ntsecapi.h and subauth.h, each of
+ *  which checks that none of the others is already included.
+ */
+alias int  NTSTATUS;
+alias int* PNTSTATUS;
+
+struct UNICODE_STRING {
+    USHORT Length;
+    USHORT MaximumLength;
+    PWSTR  Buffer;
+}
+alias UNICODE_STRING*        PUNICODE_STRING;
+alias const(UNICODE_STRING)* PCUNICODE_STRING;
+
+struct STRING {
+    USHORT Length;
+    USHORT MaximumLength;
+    PCHAR  Buffer;
+}
+alias STRING  ANSI_STRING, OEM_STRING;
+alias STRING* PSTRING, PANSI_STRING, POEM_STRING;
+
+alias LARGE_INTEGER  PHYSICAL_ADDRESS;
+alias LARGE_INTEGER* PPHYSICAL_ADDRESS;
+
+enum SECTION_INHERIT {
+    ViewShare = 1,
+    ViewUnmap
+}
+
+/*  In MinGW, this is defined in ntdef.h and ntsecapi.h, each of which checks
+ *  that the other isn't already included.
+ */
+struct OBJECT_ATTRIBUTES {
+    ULONG           Length = OBJECT_ATTRIBUTES.sizeof;
+    HANDLE          RootDirectory;
+    PUNICODE_STRING ObjectName;
+    ULONG           Attributes;
+    PVOID           SecurityDescriptor;
+    PVOID           SecurityQualityOfService;
+}
+alias OBJECT_ATTRIBUTES* POBJECT_ATTRIBUTES;
diff --git a/libphobos/libdruntime/core/sys/windows/ntdll.d b/libphobos/libdruntime/core/sys/windows/ntdll.d
new file mode 100644
index 00000000000..72ad54d466c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/ntdll.d
@@ -0,0 +1,22 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.10
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_ntdll.d)
+ */
+module core.sys.windows.ntdll;
+version (Windows):
+
+private import core.sys.windows.w32api;
+
+
+enum SHUTDOWN_ACTION {
+    ShutdownNoReboot,
+    ShutdownReboot,
+    ShutdownPowerOff
+}
+
+extern (Windows) uint NtShutdownSystem(SHUTDOWN_ACTION Action);
diff --git a/libphobos/libdruntime/core/sys/windows/ntldap.d b/libphobos/libdruntime/core/sys/windows/ntldap.d
new file mode 100644
index 00000000000..34376589665
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/ntldap.d
@@ -0,0 +1,60 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_ntldap.d)
+ */
+module core.sys.windows.ntldap;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+/*  TOTHINKABOUT: These constants don't have ANSI/Unicode versioned
+ *  aliases.  Should we merge them anyway?
+ */
+
+const char[]
+    LDAP_SERVER_ASQ_OID                    = "1.2.840.113556.1.4.1504",
+    LDAP_SERVER_DIRSYNC_OID                = "1.2.840.113556.1.4.841",
+    LDAP_SERVER_SD_FLAGS_OID               = "1.2.840.113556.1.4.801",
+    LDAP_SERVER_FAST_BIND_OID              = "1.2.840.113556.1.4.1781",
+    LDAP_MATCHING_RULE_BIT_OR              = "1.2.840.113556.1.4.804",
+    LDAP_MATCHING_RULE_BIT_AND             = "1.2.840.113556.1.4.803",
+    LDAP_SERVER_EXTENDED_DN_OID            = "1.2.840.113556.1.4.529",
+    LDAP_SERVER_LAZY_COMMIT_OID            = "1.2.840.113556.1.4.619",
+    LDAP_SERVER_TREE_DELETE_OID            = "1.2.840.113556.1.4.805",
+    LDAP_SERVER_VERIFY_NAME_OID            = "1.2.840.113556.1.4.1338",
+    LDAP_SERVER_SHOW_DELETED_OID           = "1.2.840.113556.1.4.417",
+    LDAP_SERVER_NOTIFICATION_OID           = "1.2.840.113556.1.4.528",
+    LDAP_SERVER_DOMAIN_SCOPE_OID           = "1.2.840.113556.1.4.1339",
+    LDAP_CAP_ACTIVE_DIRECTORY_OID          = "1.2.840.113556.1.4.800",
+    LDAP_SERVER_SEARCH_OPTIONS_OID         = "1.2.840.113556.1.4.1340",
+    LDAP_CAP_ACTIVE_DIRECTORY_V51_OID      = "1.2.840.113556.1.4.1670",
+    LDAP_SERVER_PERMISSIVE_MODIFY_OID      = "1.2.840.113556.1.4.1413",
+    LDAP_SERVER_CROSSDOM_MOVE_TARGET_OID   = "1.2.840.113556.1.4.521";
+
+const wchar[]
+    LDAP_SERVER_ASQ_OID_W                  = "1.2.840.113556.1.4.1504",
+    LDAP_SERVER_DIRSYNC_OID_W              = "1.2.840.113556.1.4.841",
+    LDAP_SERVER_SD_FLAGS_OID_W             = "1.2.840.113556.1.4.801",
+    LDAP_SERVER_FAST_BIND_OID_W            = "1.2.840.113556.1.4.1781",
+    LDAP_MATCHING_RULE_BIT_OR_W            = "1.2.840.113556.1.4.804",
+    LDAP_MATCHING_RULE_BIT_AND_W           = "1.2.840.113556.1.4.803",
+    LDAP_SERVER_EXTENDED_DN_OID_W          = "1.2.840.113556.1.4.529",
+    LDAP_SERVER_LAZY_COMMIT_OID_W          = "1.2.840.113556.1.4.619",
+    LDAP_SERVER_TREE_DELETE_OID_W          = "1.2.840.113556.1.4.805",
+    LDAP_SERVER_VERIFY_NAME_OID_W          = "1.2.840.113556.1.4.1338",
+    LDAP_SERVER_SHOW_DELETED_OID_W         = "1.2.840.113556.1.4.417",
+    LDAP_SERVER_NOTIFICATION_OID_W         = "1.2.840.113556.1.4.528",
+    LDAP_SERVER_DOMAIN_SCOPE_OID_W         = "1.2.840.113556.1.4.1339",
+    LDAP_CAP_ACTIVE_DIRECTORY_OID_W        = "1.2.840.113556.1.4.800",
+    LDAP_SERVER_SEARCH_OPTIONS_OID_W       = "1.2.840.113556.1.4.1340",
+    LDAP_CAP_ACTIVE_DIRECTORY_V51_OID_W    = "1.2.840.113556.1.4.1670",
+    LDAP_SERVER_PERMISSIVE_MODIFY_OID_W    = "1.2.840.113556.1.4.1413",
+    LDAP_SERVER_CROSSDOM_MOVE_TARGET_OID_W = "1.2.840.113556.1.4.521";
+
+enum SERVER_SEARCH_FLAG_DOMAIN_SCOPE = 1;
+enum SERVER_SEARCH_FLAG_PHANTOM_ROOT = 2;
diff --git a/libphobos/libdruntime/core/sys/windows/ntsecapi.d b/libphobos/libdruntime/core/sys/windows/ntsecapi.d
new file mode 100644
index 00000000000..b043168994c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/ntsecapi.d
@@ -0,0 +1,796 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_ntsecapi.d)
+ */
+module core.sys.windows.ntsecapi;
+version (Windows):
+pragma(lib, "advapi32");
+
+version (ANSI) {} else version = Unicode;
+
+private import
+  core.sys.windows.basetyps, core.sys.windows.ntdef, core.sys.windows.windef, core.sys.windows.winnt, core.sys.windows.w32api;
+
+// FIXME: check types and grouping of constants
+// FIXME: check Windows version support
+
+enum KERB_WRAP_NO_ENCRYPT        = 0x80000001;
+
+enum LOGON_GUEST                 = 0x00000001;
+enum LOGON_NOENCRYPTION          = 0x00000002;
+enum LOGON_CACHED_ACCOUNT        = 0x00000004;
+enum LOGON_USED_LM_PASSWORD      = 0x00000008;
+enum LOGON_EXTRA_SIDS            = 0x00000020;
+enum LOGON_SUBAUTH_SESSION_KEY   = 0x00000040;
+enum LOGON_SERVER_TRUST_ACCOUNT  = 0x00000080;
+enum LOGON_NTLMV2_ENABLED        = 0x00000100;
+enum LOGON_RESOURCE_GROUPS       = 0x00000200;
+enum LOGON_PROFILE_PATH_RETURNED = 0x00000400;
+enum LOGON_GRACE_LOGON           = 0x01000000;
+
+enum {
+    LSA_MODE_PASSWORD_PROTECTED = 1,
+    LSA_MODE_INDIVIDUAL_ACCOUNTS,
+    LSA_MODE_MANDATORY_ACCESS,
+    LSA_MODE_LOG_FULL
+}
+
+bool LSA_SUCCESS(int x) { return x >= 0; }
+
+/*  TOTHINKABOUT: These constants don't have ANSI/Unicode versioned
+ *  aliases.  Should we merge them anyway?
+ */
+const char[]  MICROSOFT_KERBEROS_NAME_A = "Kerberos";
+const wchar[] MICROSOFT_KERBEROS_NAME_W = "Kerberos";
+const char[]  MSV1_0_PACKAGE_NAME  = "MICROSOFT_AUTHENTICATION_PACKAGE_V1_0";
+const wchar[] MSV1_0_PACKAGE_NAMEW = "MICROSOFT_AUTHENTICATION_PACKAGE_V1_0";
+
+enum MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT      =       32;
+enum MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT =     2048;
+enum MSV1_0_CLEARTEXT_PASSWORD_ALLOWED      =        2;
+enum MSV1_0_CRED_LM_PRESENT                 =        1;
+enum MSV1_0_CRED_NT_PRESENT                 =        2;
+enum MSV1_0_CRED_VERSION                    =        0;
+enum MSV1_0_DONT_TRY_GUEST_ACCOUNT          =       16;
+enum MSV1_0_MAX_NTLM3_LIFE                  =     1800;
+enum MSV1_0_MAX_AVL_SIZE                    =    64000;
+enum MSV1_0_MNS_LOGON                       = 16777216;
+
+enum size_t
+    MSV1_0_CHALLENGE_LENGTH          = 8,
+    MSV1_0_LANMAN_SESSION_KEY_LENGTH = 8,
+    MSV1_0_NTLM3_RESPONSE_LENGTH     = 16,
+    MSV1_0_NTLM3_OWF_LENGTH          = 16,
+    MSV1_0_NTLM3_INPUT_LENGTH        = MSV1_0_NTLM3_RESPONSE.sizeof
+                                       - MSV1_0_NTLM3_RESPONSE_LENGTH,
+    MSV1_0_OWF_PASSWORD_LENGTH       = 16,
+    MSV1_0_PACKAGE_NAMEW_LENGTH      = MSV1_0_PACKAGE_NAMEW.sizeof
+                                       - WCHAR.sizeof;
+
+enum MSV1_0_RETURN_USER_PARAMETERS      =          8;
+enum MSV1_0_RETURN_PASSWORD_EXPIRY      =         64;
+enum MSV1_0_RETURN_PROFILE_PATH         =        512;
+enum MSV1_0_SUBAUTHENTICATION_DLL_EX    =    1048576;
+enum MSV1_0_SUBAUTHENTICATION_DLL       = 0xff000000;
+enum MSV1_0_SUBAUTHENTICATION_DLL_SHIFT =         24;
+enum MSV1_0_SUBAUTHENTICATION_DLL_RAS   =          2;
+enum MSV1_0_SUBAUTHENTICATION_DLL_IIS   =        132;
+enum MSV1_0_SUBAUTHENTICATION_FLAGS     = 0xff000000;
+enum MSV1_0_TRY_GUEST_ACCOUNT_ONLY      =        256;
+enum MSV1_0_TRY_SPECIFIED_DOMAIN_ONLY   =       1024;
+enum MSV1_0_UPDATE_LOGON_STATISTICS     =          4;
+enum MSV1_0_USE_CLIENT_CHALLENGE        =        128;
+enum MSV1_0_USER_SESSION_KEY_LENGTH     =         16;
+
+const char[]
+    MSV1_0_SUBAUTHENTICATION_KEY
+      = `System\CurrentControlSet\Control\Lsa\MSV1_0`,
+    MSV1_0_SUBAUTHENTICATION_VALUE = "Auth";
+
+enum ACCESS_MASK
+    POLICY_VIEW_LOCAL_INFORMATION   = 0x0001,
+    POLICY_VIEW_AUDIT_INFORMATION   = 0x0002,
+    POLICY_GET_PRIVATE_INFORMATION  = 0x0004,
+    POLICY_TRUST_ADMIN              = 0x0008,
+    POLICY_CREATE_ACCOUNT           = 0x0010,
+    POLICY_CREATE_SECRET            = 0x0020,
+    POLICY_CREATE_PRIVILEGE         = 0x0040,
+    POLICY_SET_DEFAULT_QUOTA_LIMITS = 0x0080,
+    POLICY_SET_AUDIT_REQUIREMENTS   = 0x0100,
+    POLICY_AUDIT_LOG_ADMIN          = 0x0200,
+    POLICY_SERVER_ADMIN             = 0x0400,
+    POLICY_LOOKUP_NAMES             = 0x0800,
+
+    POLICY_READ                     = STANDARD_RIGHTS_READ     | 0x0006,
+    POLICY_WRITE                    = STANDARD_RIGHTS_WRITE    | 0x07F8,
+    POLICY_EXECUTE                  = STANDARD_RIGHTS_EXECUTE  | 0x0801,
+    POLICY_ALL_ACCESS               = STANDARD_RIGHTS_REQUIRED | 0x0FFF;
+
+enum POLICY_AUDIT_EVENT_UNCHANGED = 0;
+enum POLICY_AUDIT_EVENT_SUCCESS   = 1;
+enum POLICY_AUDIT_EVENT_FAILURE   = 2;
+enum POLICY_AUDIT_EVENT_NONE      = 4;
+enum POLICY_AUDIT_EVENT_MASK      = 7;
+
+enum {
+    POLICY_LOCATION_LOCAL = 1,
+    POLICY_LOCATION_DS
+}
+
+enum : uint {
+    POLICY_MACHINE_POLICY_LOCAL     =          0,
+    POLICY_MACHINE_POLICY_DEFAULTED,
+    POLICY_MACHINE_POLICY_EXPLICIT,
+    POLICY_MACHINE_POLICY_UNKNOWN   = 0xFFFFFFFF
+}
+
+
+enum POLICY_QOS_SCHANEL_REQUIRED            = 0x0001;
+enum POLICY_QOS_OUTBOUND_INTEGRITY          = 0x0002;
+enum POLICY_QOS_OUTBOUND_CONFIDENTIALITY    = 0x0004;
+enum POLICY_QOS_INBOUND_INTEGREITY          = 0x0008;
+enum POLICY_QOS_INBOUND_CONFIDENTIALITY     = 0x0010;
+enum POLICY_QOS_ALLOW_LOCAL_ROOT_CERT_STORE = 0x0020;
+enum POLICY_QOS_RAS_SERVER_ALLOWED          = 0x0040;
+enum POLICY_QOS_DHCP_SERVER_ALLOWD          = 0x0080;
+
+enum POLICY_KERBEROS_FORWARDABLE  = 1;
+enum POLICY_KERBEROS_PROXYABLE    = 2;
+enum POLICY_KERBEROS_RENEWABLE    = 4;
+enum POLICY_KERBEROS_POSTDATEABLE = 8;
+
+const char[]
+    SAM_PASSWORD_CHANGE_NOTIFY_ROUTINE = "PasswordChangeNotify",
+    SAM_INIT_NOTIFICATION_ROUTINE      = "InitializeChangeNotify",
+    SAM_PASSWORD_FILTER_ROUTINE        = "PasswordFilter";
+
+const TCHAR[]
+    SE_INTERACTIVE_LOGON_NAME          = "SeInteractiveLogonRight",
+    SE_NETWORK_LOGON_NAME              = "SeNetworkLogonRight",
+    SE_BATCH_LOGON_NAME                = "SeBatchLogonRight",
+    SE_SERVICE_LOGON_NAME              = "SeServiceLogonRight";
+
+enum {
+    TRUST_ATTRIBUTE_NON_TRANSITIVE =         1,
+    TRUST_ATTRIBUTE_UPLEVEL_ONLY   =         2,
+    TRUST_ATTRIBUTE_TREE_PARENT    =   4194304,
+    TRUST_ATTRIBUTES_VALID         = -16580609
+}
+
+enum {
+    TRUST_AUTH_TYPE_NONE,
+    TRUST_AUTH_TYPE_NT4OWF,
+    TRUST_AUTH_TYPE_CLEAR
+}
+
+enum {
+    TRUST_DIRECTION_DISABLED,
+    TRUST_DIRECTION_INBOUND,
+    TRUST_DIRECTION_OUTBOUND,
+    TRUST_DIRECTION_BIDIRECTIONAL
+}
+
+enum {
+    TRUST_TYPE_DOWNLEVEL = 1,
+    TRUST_TYPE_UPLEVEL,
+    TRUST_TYPE_MIT,
+    TRUST_TYPE_DCE
+}
+
+alias UNICODE_STRING LSA_UNICODE_STRING;
+alias UNICODE_STRING* PLSA_UNICODE_STRING;
+alias STRING LSA_STRING;
+alias STRING* PLSA_STRING;
+
+enum MSV1_0_LOGON_SUBMIT_TYPE {
+    MsV1_0InteractiveLogon       = 2,
+    MsV1_0Lm20Logon,
+    MsV1_0NetworkLogon,
+    MsV1_0SubAuthLogon,
+    MsV1_0WorkstationUnlockLogon = 7
+}
+alias MSV1_0_LOGON_SUBMIT_TYPE* PMSV1_0_LOGON_SUBMIT_TYPE;
+
+enum MSV1_0_PROFILE_BUFFER_TYPE {
+    MsV1_0InteractiveProfile = 2,
+    MsV1_0Lm20LogonProfile,
+    MsV1_0SmartCardProfile
+}
+alias MSV1_0_PROFILE_BUFFER_TYPE* PMSV1_0_PROFILE_BUFFER_TYPE;
+
+
+enum MSV1_0_AVID {
+    MsvAvEOL,
+    MsvAvNbComputerName,
+    MsvAvNbDomainName,
+    MsvAvDnsComputerName,
+    MsvAvDnsDomainName
+}
+
+enum MSV1_0_PROTOCOL_MESSAGE_TYPE {
+    MsV1_0Lm20ChallengeRequest = 0,
+    MsV1_0Lm20GetChallengeResponse,
+    MsV1_0EnumerateUsers,
+    MsV1_0GetUserInfo,
+    MsV1_0ReLogonUsers,
+    MsV1_0ChangePassword,
+    MsV1_0ChangeCachedPassword,
+    MsV1_0GenericPassthrough,
+    MsV1_0CacheLogon,
+    MsV1_0SubAuth,
+    MsV1_0DeriveCredential,
+    MsV1_0CacheLookup
+}
+alias MSV1_0_PROTOCOL_MESSAGE_TYPE* PMSV1_0_PROTOCOL_MESSAGE_TYPE;
+
+enum POLICY_LSA_SERVER_ROLE {
+    PolicyServerRoleBackup = 2,
+    PolicyServerRolePrimary
+}
+alias POLICY_LSA_SERVER_ROLE* PPOLICY_LSA_SERVER_ROLE;
+
+enum POLICY_SERVER_ENABLE_STATE {
+    PolicyServerEnabled = 2,
+    PolicyServerDisabled
+}
+alias POLICY_SERVER_ENABLE_STATE* PPOLICY_SERVER_ENABLE_STATE;
+
+enum POLICY_INFORMATION_CLASS {
+    PolicyAuditLogInformation = 1,
+    PolicyAuditEventsInformation,
+    PolicyPrimaryDomainInformation,
+    PolicyPdAccountInformation,
+    PolicyAccountDomainInformation,
+    PolicyLsaServerRoleInformation,
+    PolicyReplicaSourceInformation,
+    PolicyDefaultQuotaInformation,
+    PolicyModificationInformation,
+    PolicyAuditFullSetInformation,
+    PolicyAuditFullQueryInformation,
+    PolicyDnsDomainInformation,
+    PolicyEfsInformation
+}
+alias POLICY_INFORMATION_CLASS* PPOLICY_INFORMATION_CLASS;
+
+enum POLICY_AUDIT_EVENT_TYPE {
+    AuditCategorySystem,
+    AuditCategoryLogon,
+    AuditCategoryObjectAccess,
+    AuditCategoryPrivilegeUse,
+    AuditCategoryDetailedTracking,
+    AuditCategoryPolicyChange,
+    AuditCategoryAccountManagement,
+    AuditCategoryDirectoryServiceAccess,
+    AuditCategoryAccountLogon
+}
+alias POLICY_AUDIT_EVENT_TYPE* PPOLICY_AUDIT_EVENT_TYPE;
+
+enum POLICY_LOCAL_INFORMATION_CLASS {
+    PolicyLocalAuditEventsInformation = 1,
+    PolicyLocalPdAccountInformation,
+    PolicyLocalAccountDomainInformation,
+    PolicyLocalLsaServerRoleInformation,
+    PolicyLocalReplicaSourceInformation,
+    PolicyLocalModificationInformation,
+    PolicyLocalAuditFullSetInformation,
+    PolicyLocalAuditFullQueryInformation,
+    PolicyLocalDnsDomainInformation,
+    PolicyLocalIPSecReferenceInformation,
+    PolicyLocalMachinePasswordInformation,
+    PolicyLocalQualityOfServiceInformation,
+    PolicyLocalPolicyLocationInformation
+}
+alias POLICY_LOCAL_INFORMATION_CLASS* PPOLICY_LOCAL_INFORMATION_CLASS;
+
+enum POLICY_DOMAIN_INFORMATION_CLASS {
+    PolicyDomainIPSecReferenceInformation = 1,
+    PolicyDomainQualityOfServiceInformation,
+    PolicyDomainEfsInformation,
+    PolicyDomainPublicKeyInformation,
+    PolicyDomainPasswordPolicyInformation,
+    PolicyDomainLockoutInformation,
+    PolicyDomainKerberosTicketInformation
+}
+alias POLICY_DOMAIN_INFORMATION_CLASS* PPOLICY_DOMAIN_INFORMATION_CLASS;
+
+enum SECURITY_LOGON_TYPE {
+    Interactive = 2,
+    Network,
+    Batch,
+    Service,
+    Proxy,
+    Unlock
+}
+alias SECURITY_LOGON_TYPE* PSECURITY_LOGON_TYPE;
+
+enum TRUSTED_INFORMATION_CLASS {
+    TrustedDomainNameInformation = 1,
+    TrustedControllersInformation,
+    TrustedPosixOffsetInformation,
+    TrustedPasswordInformation,
+    TrustedDomainInformationBasic,
+    TrustedDomainInformationEx,
+    TrustedDomainAuthInformation,
+    TrustedDomainFullInformation
+}
+alias TRUSTED_INFORMATION_CLASS* PTRUSTED_INFORMATION_CLASS;
+
+struct DOMAIN_PASSWORD_INFORMATION {
+    USHORT        MinPasswordLength;
+    USHORT        PasswordHistoryLength;
+    ULONG         PasswordProperties;
+    LARGE_INTEGER MaxPasswordAge;
+    LARGE_INTEGER MinPasswordAge;
+}
+alias DOMAIN_PASSWORD_INFORMATION* PDOMAIN_PASSWORD_INFORMATION;
+
+struct LSA_ENUMERATION_INFORMATION {
+    PSID Sid;
+}
+alias LSA_ENUMERATION_INFORMATION* PLSA_ENUMERATION_INFORMATION;
+
+alias OBJECT_ATTRIBUTES LSA_OBJECT_ATTRIBUTES;
+alias OBJECT_ATTRIBUTES* PLSA_OBJECT_ATTRIBUTES;
+
+struct LSA_TRUST_INFORMATION {
+    LSA_UNICODE_STRING Name;
+    PSID               Sid;
+}
+alias LSA_TRUST_INFORMATION TRUSTED_DOMAIN_INFORMATION_BASIC;
+alias LSA_TRUST_INFORMATION* PLSA_TRUST_INFORMATION;
+/*  in MinGW (further down the code):
+ *      typedef PLSA_TRUST_INFORMATION *PTRUSTED_DOMAIN_INFORMATION_BASIC;
+ *  but it doesn't look right....
+ */
+alias LSA_TRUST_INFORMATION** PTRUSTED_DOMAIN_INFORMATION_BASIC;
+
+struct LSA_REFERENCED_DOMAIN_LIST {
+    ULONG                  Entries;
+    PLSA_TRUST_INFORMATION Domains;
+}
+alias LSA_REFERENCED_DOMAIN_LIST* PLSA_REFERENCED_DOMAIN_LIST;
+
+struct LSA_TRANSLATED_SID {
+    SID_NAME_USE Use;
+    ULONG        RelativeId;
+    LONG         DomainIndex;
+}
+alias LSA_TRANSLATED_SID* PLSA_TRANSLATED_SID;
+
+struct LSA_TRANSLATED_NAME {
+    SID_NAME_USE       Use;
+    LSA_UNICODE_STRING Name;
+    LONG               DomainIndex;
+}
+alias LSA_TRANSLATED_NAME* PLSA_TRANSLATED_NAME;
+
+struct MSV1_0_INTERACTIVE_LOGON {
+    MSV1_0_LOGON_SUBMIT_TYPE MessageType;
+    UNICODE_STRING           LogonDomainName;
+    UNICODE_STRING           UserName;
+    UNICODE_STRING           Password;
+}
+alias MSV1_0_INTERACTIVE_LOGON* PMSV1_0_INTERACTIVE_LOGON;
+
+struct MSV1_0_INTERACTIVE_PROFILE {
+    MSV1_0_PROFILE_BUFFER_TYPE MessageType;
+    USHORT                     LogonCount;
+    USHORT                     BadPasswordCount;
+    LARGE_INTEGER              LogonTime;
+    LARGE_INTEGER              LogoffTime;
+    LARGE_INTEGER              KickOffTime;
+    LARGE_INTEGER              PasswordLastSet;
+    LARGE_INTEGER              PasswordCanChange;
+    LARGE_INTEGER              PasswordMustChange;
+    UNICODE_STRING             LogonScript;
+    UNICODE_STRING             HomeDirectory;
+    UNICODE_STRING             FullName;
+    UNICODE_STRING             ProfilePath;
+    UNICODE_STRING             HomeDirectoryDrive;
+    UNICODE_STRING             LogonServer;
+    ULONG                      UserFlags;
+}
+alias MSV1_0_INTERACTIVE_PROFILE* PMSV1_0_INTERACTIVE_PROFILE;
+
+struct MSV1_0_LM20_LOGON {
+    MSV1_0_LOGON_SUBMIT_TYPE       MessageType;
+    UNICODE_STRING                 LogonDomainName;
+    UNICODE_STRING                 UserName;
+    UNICODE_STRING                 Workstation;
+    UCHAR[MSV1_0_CHALLENGE_LENGTH] ChallengeToClient;
+    STRING                         CaseSensitiveChallengeResponse;
+    STRING                         CaseInsensitiveChallengeResponse;
+    ULONG                          ParameterControl;
+}
+alias MSV1_0_LM20_LOGON* PMSV1_0_LM20_LOGON;
+
+//static if (_WIN32_WINNT >= 0x500) {
+    struct MSV1_0_SUBAUTH_LOGON {
+        MSV1_0_LOGON_SUBMIT_TYPE       MessageType;
+        UNICODE_STRING                 LogonDomainName;
+        UNICODE_STRING                 UserName;
+        UNICODE_STRING                 Workstation;
+        UCHAR[MSV1_0_CHALLENGE_LENGTH] ChallengeToClient;
+        STRING                         AuthenticationInfo1;
+        STRING                         AuthenticationInfo2;
+        ULONG                          ParameterControl;
+        ULONG                          SubAuthPackageId;
+    }
+    alias MSV1_0_SUBAUTH_LOGON* PMSV1_0_SUBAUTH_LOGON;
+//}
+
+struct MSV1_0_LM20_LOGON_PROFILE {
+    MSV1_0_PROFILE_BUFFER_TYPE              MessageType;
+    LARGE_INTEGER                           KickOffTime;
+    LARGE_INTEGER                           LogoffTime;
+    ULONG                                   UserFlags;
+    UCHAR[MSV1_0_USER_SESSION_KEY_LENGTH]   UserSessionKey;
+    UNICODE_STRING                          LogonDomainName;
+    UCHAR[MSV1_0_LANMAN_SESSION_KEY_LENGTH] LanmanSessionKey;
+    UNICODE_STRING                          LogonServer;
+    UNICODE_STRING                          UserParameters;
+}
+alias MSV1_0_LM20_LOGON_PROFILE* PMSV1_0_LM20_LOGON_PROFILE;
+
+struct MSV1_0_SUPPLEMENTAL_CREDENTIAL {
+    ULONG Version;
+    ULONG Flags;
+    UCHAR[MSV1_0_OWF_PASSWORD_LENGTH] LmPassword;
+    UCHAR[MSV1_0_OWF_PASSWORD_LENGTH] NtPassword;
+}
+alias MSV1_0_SUPPLEMENTAL_CREDENTIAL* PMSV1_0_SUPPLEMENTAL_CREDENTIAL;
+
+struct MSV1_0_NTLM3_RESPONSE {
+    UCHAR[MSV1_0_NTLM3_RESPONSE_LENGTH] Response;
+    UCHAR     RespType;
+    UCHAR     HiRespType;
+    USHORT    Flags;
+    ULONG     MsgWord;
+    ULONGLONG TimeStamp;
+    UCHAR[MSV1_0_CHALLENGE_LENGTH]      ChallengeFromClient;
+    ULONG     AvPairsOff;
+    UCHAR     _Buffer;
+    UCHAR*    Buffer() return { return &_Buffer; }
+}
+alias MSV1_0_NTLM3_RESPONSE* PMSV1_0_NTLM3_RESPONSE;
+
+struct  MSV1_0_AV_PAIR {
+    USHORT AvId;
+    USHORT AvLen;
+}
+alias MSV1_0_AV_PAIR* PMSV1_0_AV_PAIR;
+
+struct MSV1_0_CHANGEPASSWORD_REQUEST {
+    MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
+    UNICODE_STRING DomainName;
+    UNICODE_STRING AccountName;
+    UNICODE_STRING OldPassword;
+    UNICODE_STRING NewPassword;
+    BOOLEAN        Impersonating;
+}
+alias MSV1_0_CHANGEPASSWORD_REQUEST* PMSV1_0_CHANGEPASSWORD_REQUEST;
+
+struct MSV1_0_CHANGEPASSWORD_RESPONSE {
+    MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
+    BOOLEAN                      PasswordInfoValid;
+    DOMAIN_PASSWORD_INFORMATION  DomainPasswordInfo;
+}
+alias MSV1_0_CHANGEPASSWORD_RESPONSE* PMSV1_0_CHANGEPASSWORD_RESPONSE;
+
+struct MSV1_0_SUBAUTH_REQUEST {
+    MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
+    ULONG  SubAuthPackageId;
+    ULONG  SubAuthInfoLength;
+    PUCHAR SubAuthSubmitBuffer;
+}
+alias MSV1_0_SUBAUTH_REQUEST* PMSV1_0_SUBAUTH_REQUEST;
+
+struct MSV1_0_SUBAUTH_RESPONSE {
+    MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
+    ULONG  SubAuthInfoLength;
+    PUCHAR SubAuthReturnBuffer;
+}
+alias MSV1_0_SUBAUTH_RESPONSE* PMSV1_0_SUBAUTH_RESPONSE;
+
+enum MSV1_0_DERIVECRED_TYPE_SHA1 = 0;
+
+struct MSV1_0_DERIVECRED_REQUEST {
+    MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
+    LUID   LogonId;
+    ULONG  DeriveCredType;
+    ULONG  DeriveCredInfoLength;
+    UCHAR  _DeriveCredSubmitBuffer;
+    UCHAR* DeriveCredSubmitBuffer() return { return &_DeriveCredSubmitBuffer; }
+}
+alias MSV1_0_DERIVECRED_REQUEST* PMSV1_0_DERIVECRED_REQUEST;
+
+struct MSV1_0_DERIVECRED_RESPONSE {
+    MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
+    ULONG  DeriveCredInfoLength;
+    UCHAR  _DeriveCredReturnBuffer;
+    UCHAR* DeriveCredReturnBuffer() return { return &_DeriveCredReturnBuffer; }
+}
+alias MSV1_0_DERIVECRED_RESPONSE* PMSV1_0_DERIVECRED_RESPONSE;
+
+alias uint LSA_ENUMERATION_HANDLE, LSA_OPERATIONAL_MODE,
+  POLICY_AUDIT_EVENT_OPTIONS;
+alias uint* PLSA_ENUMERATION_HANDLE, PLSA_OPERATIONAL_MODE,
+  PPOLICY_AUDIT_EVENT_OPTIONS;
+
+struct POLICY_PRIVILEGE_DEFINITION {
+    LSA_UNICODE_STRING Name;
+    LUID LocalValue;
+}
+alias POLICY_PRIVILEGE_DEFINITION* PPOLICY_PRIVILEGE_DEFINITION;
+
+struct POLICY_AUDIT_LOG_INFO {
+    ULONG         AuditLogPercentFull;
+    ULONG         MaximumLogSize;
+    LARGE_INTEGER AuditRetentionPeriod;
+    BOOLEAN       AuditLogFullShutdownInProgress;
+    LARGE_INTEGER TimeToShutdown;
+    ULONG         NextAuditRecordId;
+}
+alias POLICY_AUDIT_LOG_INFO* PPOLICY_AUDIT_LOG_INFO;
+
+struct POLICY_AUDIT_EVENTS_INFO {
+    BOOLEAN                     AuditingMode;
+    PPOLICY_AUDIT_EVENT_OPTIONS EventAuditingOptions;
+    ULONG                       MaximumAuditEventCount;
+}
+alias POLICY_AUDIT_EVENTS_INFO* PPOLICY_AUDIT_EVENTS_INFO;
+
+struct POLICY_ACCOUNT_DOMAIN_INFO {
+    LSA_UNICODE_STRING DomainName;
+    PSID               DomainSid;
+}
+alias POLICY_ACCOUNT_DOMAIN_INFO* PPOLICY_ACCOUNT_DOMAIN_INFO;
+
+struct POLICY_PRIMARY_DOMAIN_INFO {
+    LSA_UNICODE_STRING Name;
+    PSID               Sid;
+}
+alias POLICY_PRIMARY_DOMAIN_INFO* PPOLICY_PRIMARY_DOMAIN_INFO;
+
+struct POLICY_DNS_DOMAIN_INFO {
+    LSA_UNICODE_STRING Name;
+    LSA_UNICODE_STRING DnsDomainName;
+    LSA_UNICODE_STRING DnsTreeName;
+    GUID               DomainGuid;
+    PSID               Sid;
+}
+alias POLICY_DNS_DOMAIN_INFO* PPOLICY_DNS_DOMAIN_INFO;
+
+struct POLICY_PD_ACCOUNT_INFO {
+    LSA_UNICODE_STRING Name;
+}
+alias POLICY_PD_ACCOUNT_INFO* PPOLICY_PD_ACCOUNT_INFO;
+
+struct POLICY_LSA_SERVER_ROLE_INFO {
+    POLICY_LSA_SERVER_ROLE LsaServerRole;
+}
+alias POLICY_LSA_SERVER_ROLE_INFO* PPOLICY_LSA_SERVER_ROLE_INFO;
+
+struct POLICY_REPLICA_SOURCE_INFO {
+    LSA_UNICODE_STRING ReplicaSource;
+    LSA_UNICODE_STRING ReplicaAccountName;
+}
+alias POLICY_REPLICA_SOURCE_INFO* PPOLICY_REPLICA_SOURCE_INFO;
+
+struct POLICY_DEFAULT_QUOTA_INFO {
+    QUOTA_LIMITS QuotaLimits;
+}
+alias POLICY_DEFAULT_QUOTA_INFO* PPOLICY_DEFAULT_QUOTA_INFO;
+
+struct POLICY_MODIFICATION_INFO {
+    LARGE_INTEGER ModifiedId;
+    LARGE_INTEGER DatabaseCreationTime;
+}
+alias POLICY_MODIFICATION_INFO* PPOLICY_MODIFICATION_INFO;
+
+struct POLICY_AUDIT_FULL_SET_INFO {
+    BOOLEAN ShutDownOnFull;
+}
+alias POLICY_AUDIT_FULL_SET_INFO* PPOLICY_AUDIT_FULL_SET_INFO;
+
+struct POLICY_AUDIT_FULL_QUERY_INFO {
+    BOOLEAN ShutDownOnFull;
+    BOOLEAN LogIsFull;
+}
+alias POLICY_AUDIT_FULL_QUERY_INFO* PPOLICY_AUDIT_FULL_QUERY_INFO;
+
+struct POLICY_EFS_INFO {
+    ULONG InfoLength;
+    PUCHAR EfsBlob;
+}
+alias POLICY_EFS_INFO* PPOLICY_EFS_INFO;
+
+struct POLICY_LOCAL_IPSEC_REFERENCE_INFO {
+    LSA_UNICODE_STRING ObjectPath;
+}
+alias POLICY_LOCAL_IPSEC_REFERENCE_INFO* PPOLICY_LOCAL_IPSEC_REFERENCE_INFO;
+
+struct POLICY_LOCAL_MACHINE_PASSWORD_INFO {
+    LARGE_INTEGER PasswordChangeInterval;
+}
+alias POLICY_LOCAL_MACHINE_PASSWORD_INFO* PPOLICY_LOCAL_MACHINE_PASSWORD_INFO;
+
+struct POLICY_LOCAL_POLICY_LOCATION_INFO {
+    ULONG PolicyLocation;
+}
+alias POLICY_LOCAL_POLICY_LOCATION_INFO* PPOLICY_LOCAL_POLICY_LOCATION_INFO;
+
+struct POLICY_LOCAL_QUALITY_OF_SERVICE_INFO{
+    ULONG QualityOfService;
+}
+alias POLICY_LOCAL_QUALITY_OF_SERVICE_INFO
+  POLICY_DOMAIN_QUALITY_OF_SERVICE_INFO;
+alias POLICY_LOCAL_QUALITY_OF_SERVICE_INFO*
+  PPOLICY_LOCAL_QUALITY_OF_SERVICE_INFO,
+  PPOLICY_DOMAIN_QUALITY_OF_SERVICE_INFO;
+
+struct POLICY_DOMAIN_PUBLIC_KEY_INFO {
+    ULONG  InfoLength;
+    PUCHAR PublicKeyInfo;
+}
+alias POLICY_DOMAIN_PUBLIC_KEY_INFO* PPOLICY_DOMAIN_PUBLIC_KEY_INFO;
+
+struct POLICY_DOMAIN_LOCKOUT_INFO {
+    LARGE_INTEGER LockoutDuration;
+    LARGE_INTEGER LockoutObservationWindow;
+    USHORT        LockoutThreshold;
+}
+alias POLICY_DOMAIN_LOCKOUT_INFO* PPOLICY_DOMAIN_LOCKOUT_INFO;
+
+struct POLICY_DOMAIN_PASSWORD_INFO {
+    USHORT        MinPasswordLength;
+    USHORT        PasswordHistoryLength;
+    ULONG         PasswordProperties;
+    LARGE_INTEGER MaxPasswordAge;
+    LARGE_INTEGER MinPasswordAge;
+}
+alias POLICY_DOMAIN_PASSWORD_INFO* PPOLICY_DOMAIN_PASSWORD_INFO;
+
+struct POLICY_DOMAIN_KERBEROS_TICKET_INFO {
+    ULONG         AuthenticationOptions;
+    LARGE_INTEGER MinTicketAge;
+    LARGE_INTEGER MaxTicketAge;
+    LARGE_INTEGER MaxRenewAge;
+    LARGE_INTEGER ProxyLifetime;
+    LARGE_INTEGER ForceLogoff;
+}
+alias POLICY_DOMAIN_KERBEROS_TICKET_INFO* PPOLICY_DOMAIN_KERBEROS_TICKET_INFO;
+
+mixin DECLARE_HANDLE!("LSA_HANDLE");
+alias LSA_HANDLE* PLSA_HANDLE;
+
+struct TRUSTED_DOMAIN_NAME_INFO {
+    LSA_UNICODE_STRING Name;
+}
+alias TRUSTED_DOMAIN_NAME_INFO* PTRUSTED_DOMAIN_NAME_INFO;
+
+struct TRUSTED_CONTROLLERS_INFO {
+    ULONG               Entries;
+    PLSA_UNICODE_STRING Names;
+}
+alias TRUSTED_CONTROLLERS_INFO* PTRUSTED_CONTROLLERS_INFO;
+
+struct TRUSTED_POSIX_OFFSET_INFO {
+    ULONG Offset;
+}
+alias TRUSTED_POSIX_OFFSET_INFO* PTRUSTED_POSIX_OFFSET_INFO;
+
+struct TRUSTED_PASSWORD_INFO {
+    LSA_UNICODE_STRING Password;
+    LSA_UNICODE_STRING OldPassword;
+}
+alias TRUSTED_PASSWORD_INFO* PTRUSTED_PASSWORD_INFO;
+
+struct TRUSTED_DOMAIN_INFORMATION_EX {
+    LSA_UNICODE_STRING Name;
+    LSA_UNICODE_STRING FlatName;
+    PSID               Sid;
+    ULONG              TrustDirection;
+    ULONG              TrustType;
+    ULONG              TrustAttributes;
+}
+alias TRUSTED_DOMAIN_INFORMATION_EX* PTRUSTED_DOMAIN_INFORMATION_EX;
+
+struct LSA_AUTH_INFORMATION {
+    LARGE_INTEGER LastUpdateTime;
+    ULONG         AuthType;
+    ULONG         AuthInfoLength;
+    PUCHAR        AuthInfo;
+}
+alias LSA_AUTH_INFORMATION* PLSA_AUTH_INFORMATION;
+
+struct TRUSTED_DOMAIN_AUTH_INFORMATION {
+    ULONG                 IncomingAuthInfos;
+    PLSA_AUTH_INFORMATION IncomingAuthenticationInformation;
+    PLSA_AUTH_INFORMATION IncomingPreviousAuthenticationInformation;
+    ULONG                 OutgoingAuthInfos;
+    PLSA_AUTH_INFORMATION OutgoingAuthenticationInformation;
+    PLSA_AUTH_INFORMATION OutgoingPreviousAuthenticationInformation;
+}
+alias TRUSTED_DOMAIN_AUTH_INFORMATION* PTRUSTED_DOMAIN_AUTH_INFORMATION;
+
+struct TRUSTED_DOMAIN_FULL_INFORMATION {
+    TRUSTED_DOMAIN_INFORMATION_EX   Information;
+    TRUSTED_POSIX_OFFSET_INFO       PosixOffset;
+    TRUSTED_DOMAIN_AUTH_INFORMATION AuthInformation;
+}
+alias TRUSTED_DOMAIN_FULL_INFORMATION* PTRUSTED_DOMAIN_FULL_INFORMATION;
+
+extern (Windows) {
+    NTSTATUS LsaAddAccountRights(LSA_HANDLE, PSID, PLSA_UNICODE_STRING,
+      ULONG);
+    NTSTATUS LsaCallAuthenticationPackage(HANDLE, ULONG, PVOID, ULONG,
+      PVOID*, PULONG, PNTSTATUS);
+    NTSTATUS LsaClose(LSA_HANDLE);
+    NTSTATUS LsaConnectUntrusted(PHANDLE);
+    NTSTATUS LsaCreateTrustedDomainEx(LSA_HANDLE,
+      PTRUSTED_DOMAIN_INFORMATION_EX, PTRUSTED_DOMAIN_AUTH_INFORMATION,
+      ACCESS_MASK, PLSA_HANDLE);
+    NTSTATUS LsaDeleteTrustedDomain(LSA_HANDLE, PSID);
+    NTSTATUS LsaDeregisterLogonProcess(HANDLE);
+    NTSTATUS LsaEnumerateAccountRights(LSA_HANDLE, PSID, PLSA_UNICODE_STRING*,
+      PULONG);
+    NTSTATUS LsaEnumerateAccountsWithUserRight(LSA_HANDLE,
+      PLSA_UNICODE_STRING, PVOID*, PULONG);
+    NTSTATUS LsaEnumerateTrustedDomains(LSA_HANDLE, PLSA_ENUMERATION_HANDLE,
+      PVOID*, ULONG, PULONG);
+    NTSTATUS LsaEnumerateTrustedDomainsEx(LSA_HANDLE, PLSA_ENUMERATION_HANDLE,
+      TRUSTED_INFORMATION_CLASS, PVOID*, ULONG, PULONG);
+    NTSTATUS LsaFreeMemory(PVOID);
+    NTSTATUS LsaFreeReturnBuffer(PVOID);
+    NTSTATUS LsaLogonUser(HANDLE, PLSA_STRING, SECURITY_LOGON_TYPE, ULONG,
+      PVOID, ULONG, PTOKEN_GROUPS, PTOKEN_SOURCE, PVOID*, PULONG, PLUID,
+      PHANDLE, PQUOTA_LIMITS, PNTSTATUS);
+    NTSTATUS LsaLookupAuthenticationPackage(HANDLE, PLSA_STRING, PULONG);
+    NTSTATUS LsaLookupNames(LSA_HANDLE, ULONG, PLSA_UNICODE_STRING,
+      PLSA_REFERENCED_DOMAIN_LIST*, PLSA_TRANSLATED_SID*);
+    NTSTATUS LsaLookupSids(LSA_HANDLE, ULONG, PSID*,
+      PLSA_REFERENCED_DOMAIN_LIST*, PLSA_TRANSLATED_NAME*);
+    ULONG LsaNtStatusToWinError(NTSTATUS);
+    NTSTATUS LsaOpenPolicy(PLSA_UNICODE_STRING, PLSA_OBJECT_ATTRIBUTES,
+      ACCESS_MASK, PLSA_HANDLE);
+    NTSTATUS LsaQueryDomainInformationPolicy(LSA_HANDLE,
+      POLICY_DOMAIN_INFORMATION_CLASS, PVOID*);
+    NTSTATUS LsaQueryInformationPolicy(LSA_HANDLE, POLICY_INFORMATION_CLASS,
+      PVOID*);
+    NTSTATUS LsaQueryLocalInformationPolicy(LSA_HANDLE,
+      POLICY_LOCAL_INFORMATION_CLASS, PVOID*);
+    NTSTATUS LsaQueryTrustedDomainInfo(LSA_HANDLE, PSID,
+      TRUSTED_INFORMATION_CLASS, PVOID*);
+    NTSTATUS LsaQueryTrustedDomainInfoByName(LSA_HANDLE, PLSA_UNICODE_STRING,
+      TRUSTED_INFORMATION_CLASS, PVOID*);
+    NTSTATUS LsaRegisterLogonProcess(PLSA_STRING, PHANDLE,
+      PLSA_OPERATIONAL_MODE);
+    NTSTATUS LsaRemoveAccountRights(LSA_HANDLE, PSID, BOOLEAN,
+      PLSA_UNICODE_STRING, ULONG);
+    NTSTATUS LsaRetrievePrivateData(LSA_HANDLE, PLSA_UNICODE_STRING,
+      PLSA_UNICODE_STRING*);
+    NTSTATUS LsaSetDomainInformationPolicy(LSA_HANDLE,
+      POLICY_DOMAIN_INFORMATION_CLASS, PVOID);
+    NTSTATUS LsaSetInformationPolicy(LSA_HANDLE, POLICY_INFORMATION_CLASS,
+      PVOID);
+    NTSTATUS LsaSetLocalInformationPolicy(LSA_HANDLE,
+      POLICY_LOCAL_INFORMATION_CLASS, PVOID);
+    NTSTATUS LsaSetTrustedDomainInformation(LSA_HANDLE, PSID,
+      TRUSTED_INFORMATION_CLASS, PVOID);
+    NTSTATUS LsaSetTrustedDomainInfoByName(LSA_HANDLE, PLSA_UNICODE_STRING,
+      TRUSTED_INFORMATION_CLASS, PVOID);
+    NTSTATUS LsaStorePrivateData(LSA_HANDLE, PLSA_UNICODE_STRING,
+      PLSA_UNICODE_STRING);
+}
+
+alias NTSTATUS function(PUNICODE_STRING, ULONG, PUNICODE_STRING)
+  PSAM_PASSWORD_NOTIFICATION_ROUTINE;
+alias BOOLEAN function() PSAM_INIT_NOTIFICATION_ROUTINE;
+alias BOOLEAN function(PUNICODE_STRING, PUNICODE_STRING,
+  PUNICODE_STRING, BOOLEAN) PSAM_PASSWORD_FILTER_ROUTINE;
diff --git a/libphobos/libdruntime/core/sys/windows/ntsecpkg.d b/libphobos/libdruntime/core/sys/windows/ntsecpkg.d
new file mode 100644
index 00000000000..f0087decf67
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/ntsecpkg.d
@@ -0,0 +1,446 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Ellery Newcomer
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_ntsecpkg.d)
+ */
+module core.sys.windows.ntsecpkg;
+version (Windows):
+
+import core.sys.windows.windef, core.sys.windows.ntsecapi, core.sys.windows.security, core.sys.windows.ntdef, core.sys.windows.sspi;
+import core.sys.windows.basetyps : GUID;
+import core.sys.windows.winbase;
+
+extern(Windows):
+
+enum :ULONG{
+    ISC_REQ_DELEGATE = 1,
+    ISC_REQ_MUTUAL_AUTH = 2,
+    ISC_REQ_REPLAY_DETECT = 4,
+    ISC_REQ_SEQUENCE_DETECT = 8,
+    ISC_REQ_CONFIDENTIALITY  = 16,
+    ISC_REQ_USE_SESSION_KEY = 32,
+    ISC_REQ_PROMPT_FOR_CREDS = 64,
+    ISC_REQ_USE_SUPPLIED_CREDS  = 128,
+    ISC_REQ_ALLOCATE_MEMORY = 256,
+    ISC_REQ_USE_DCE_STYLE = 512,
+    ISC_REQ_DATAGRAM = 1024,
+    ISC_REQ_CONNECTION = 2048,
+    ISC_REQ_EXTENDED_ERROR = 16384,
+    ISC_REQ_STREAM = 32768,
+    ISC_REQ_INTEGRITY = 65536,
+    ISC_REQ_MANUAL_CRED_VALIDATION = 524288,
+    ISC_REQ_HTTP  = 268435456,
+}
+
+enum ISC_RET_EXTENDED_ERROR = 16384;
+
+enum :ULONG{
+    ASC_REQ_DELEGATE = 1,
+    ASC_REQ_MUTUAL_AUTH = 2,
+    ASC_REQ_REPLAY_DETECT = 4,
+    ASC_REQ_SEQUENCE_DETECT = 8,
+    ASC_REQ_CONFIDENTIALITY = 16,
+    ASC_REQ_USE_SESSION_KEY = 32,
+    ASC_REQ_ALLOCATE_MEMORY = 256,
+    ASC_REQ_USE_DCE_STYLE = 512,
+    ASC_REQ_DATAGRAM = 1024,
+    ASC_REQ_CONNECTION = 2048,
+    ASC_REQ_EXTENDED_ERROR = 32768,
+    ASC_REQ_STREAM = 65536,
+    ASC_REQ_INTEGRITY = 131072,
+}
+
+enum SECURITY_NATIVE_DREP  = 16;
+enum SECURITY_NETWORK_DREP = 0;
+
+enum :ULONG{
+    SECPKG_STATE_ENCRYPTION_PERMITTED               = 0x01,
+    SECPKG_STATE_STRONG_ENCRYPTION_PERMITTED        = 0x02,
+    SECPKG_STATE_DOMAIN_CONTROLLER                  = 0x04,
+    SECPKG_STATE_WORKSTATION                        = 0x08,
+    SECPKG_STATE_STANDALONE                         = 0x10,
+}
+
+/* enum definitions for Secure Service Provider/Authentication Packages */
+enum LSA_TOKEN_INFORMATION_TYPE {
+    LsaTokenInformationNull,
+    LsaTokenInformationV1
+}
+alias LSA_TOKEN_INFORMATION_TYPE* PLSA_TOKEN_INFORMATION_TYPE;
+enum SECPKG_EXTENDED_INFORMATION_CLASS
+{
+    SecpkgGssInfo = 1,
+    SecpkgContextThunks,
+    SecpkgMutualAuthLevel,
+    SecpkgMaxInfo
+}
+enum SECPKG_NAME_TYPE {
+    SecNameSamCompatible,
+    SecNameAlternateId,
+    SecNameFlat,
+    SecNameDN
+}
+
+/* struct definitions for SSP/AP */
+struct SECPKG_PRIMARY_CRED {
+    LUID LogonId;
+    UNICODE_STRING DownlevelName;
+    UNICODE_STRING DomainName;
+    UNICODE_STRING Password;
+    UNICODE_STRING OldPassword;
+    PSID UserSid;
+    ULONG Flags;
+    UNICODE_STRING DnsDomainName;
+    UNICODE_STRING Upn;
+    UNICODE_STRING LogonServer;
+    UNICODE_STRING Spare1;
+    UNICODE_STRING Spare2;
+    UNICODE_STRING Spare3;
+    UNICODE_STRING Spare4;
+}
+alias SECPKG_PRIMARY_CRED* PSECPKG_PRIMARY_CRED;
+struct SECPKG_SUPPLEMENTAL_CRED {
+    UNICODE_STRING PackageName;
+    ULONG CredentialSize;
+    PUCHAR Credentials;
+}
+alias SECPKG_SUPPLEMENTAL_CRED* PSECPKG_SUPPLEMENTAL_CRED;
+struct SECPKG_SUPPLEMENTAL_CRED_ARRAY {
+    ULONG CredentialCount;
+    SECPKG_SUPPLEMENTAL_CRED[1] Credentials;
+}
+alias SECPKG_SUPPLEMENTAL_CRED_ARRAY* PSECPKG_SUPPLEMENTAL_CRED_ARRAY;
+struct SECPKG_PARAMETERS {
+    ULONG Version;
+    ULONG MachineState;
+    ULONG SetupMode;
+    PSID DomainSid;
+    UNICODE_STRING DomainName;
+    UNICODE_STRING DnsDomainName;
+    GUID DomainGuid;
+}
+alias SECPKG_PARAMETERS* PSECPKG_PARAMETERS,PSECPKG_EVENT_DOMAIN_CHANGE;
+alias SECPKG_PARAMETERS SECPKG_EVENT_DOMAIN_CHANGE;
+struct SECPKG_CLIENT_INFO {
+  LUID LogonId;
+  ULONG ProcessID;
+  ULONG ThreadID;
+  BOOLEAN HasTcbPrivilege;
+  BOOLEAN Impersonating;
+  BOOLEAN Restricted;
+}
+alias SECPKG_CLIENT_INFO* PSECPKG_CLIENT_INFO;
+struct SECURITY_USER_DATA {
+    SECURITY_STRING UserName;
+    SECURITY_STRING LogonDomainName;
+    SECURITY_STRING LogonServer;
+    PSID pSid;
+}
+alias SECURITY_USER_DATA* PSECURITY_USER_DATA,PSecurityUserData;
+alias SECURITY_USER_DATA SecurityUserData;
+struct SECPKG_GSS_INFO {
+    ULONG EncodedIdLength;
+    UCHAR[4] EncodedId;
+}
+alias SECPKG_GSS_INFO* PSECPKG_GSS_INFO;
+struct SECPKG_CONTEXT_THUNKS {
+    ULONG InfoLevelCount;
+    ULONG[1] Levels;
+}
+alias SECPKG_CONTEXT_THUNKS* PSECPKG_CONTEXT_THUNKS;
+struct SECPKG_MUTUAL_AUTH_LEVEL {
+    ULONG MutualAuthLevel;
+}
+alias SECPKG_MUTUAL_AUTH_LEVEL* PSECPKG_MUTUAL_AUTH_LEVEL;
+struct SECPKG_CALL_INFO {
+    ULONG ProcessId;
+    ULONG ThreadId;
+    ULONG Attributes;
+    ULONG CallCount;
+}
+alias SECPKG_CALL_INFO* PSECPKG_CALL_INFO;
+struct SECPKG_EXTENDED_INFORMATION {
+    SECPKG_EXTENDED_INFORMATION_CLASS Class;
+    union _Info{
+        SECPKG_GSS_INFO GssInfo;
+        SECPKG_CONTEXT_THUNKS ContextThunks;
+        SECPKG_MUTUAL_AUTH_LEVEL MutualAuthLevel;
+    }
+    _Info Info;
+}
+alias SECPKG_EXTENDED_INFORMATION* PSECPKG_EXTENDED_INFORMATION;
+
+/* callbacks implemented by SSP/AP dlls and called by the LSA */
+alias void function(ULONG_PTR, ULONG_PTR, PSecBuffer,
+ PSecBuffer) PLSA_CALLBACK_FUNCTION;
+
+/* misc typedefs used in the below prototypes */
+alias PVOID* PLSA_CLIENT_REQUEST;
+alias ULONG LSA_SEC_HANDLE;
+alias ULONG* PLSA_SEC_HANDLE;
+alias LPTHREAD_START_ROUTINE SEC_THREAD_START;
+alias PSECURITY_ATTRIBUTES SEC_ATTRS;
+
+/* functions used by SSP/AP obtainable by dispatch tables */
+alias NTSTATUS function(ULONG, PLSA_CALLBACK_FUNCTION) PLSA_REGISTER_CALLBACK;
+alias NTSTATUS function(PLUID) PLSA_CREATE_LOGON_SESSION;
+alias NTSTATUS function(PLUID) PLSA_DELETE_LOGON_SESSION;
+alias NTSTATUS function(PLUID, ULONG, PLSA_STRING,
+ PLSA_STRING) PLSA_ADD_CREDENTIAL;
+alias NTSTATUS function(PLUID, ULONG, PULONG, BOOLEAN,
+ PLSA_STRING, PULONG, PLSA_STRING) PLSA_GET_CREDENTIALS;
+alias NTSTATUS function(PLUID, ULONG, PLSA_STRING) PLSA_DELETE_CREDENTIAL;
+alias PVOID function(ULONG) PLSA_ALLOCATE_LSA_HEAP;
+alias void function(PVOID) PLSA_FREE_LSA_HEAP;
+alias NTSTATUS function(PLSA_CLIENT_REQUEST,
+ ULONG, PVOID*) PLSA_ALLOCATE_CLIENT_BUFFER;
+alias NTSTATUS function(PLSA_CLIENT_REQUEST, PVOID) PLSA_FREE_CLIENT_BUFFER;
+alias NTSTATUS function(PLSA_CLIENT_REQUEST, ULONG,
+ PVOID, PVOID) PLSA_COPY_TO_CLIENT_BUFFER;
+alias NTSTATUS function(PLSA_CLIENT_REQUEST,
+ ULONG, PVOID, PVOID) PLSA_COPY_FROM_CLIENT_BUFFER;
+alias NTSTATUS function() PLSA_IMPERSONATE_CLIENT;
+alias NTSTATUS function() PLSA_UNLOAD_PACKAGE;
+alias NTSTATUS function(HANDLE, PHANDLE) PLSA_DUPLICATE_HANDLE;
+alias NTSTATUS function(PLUID, ULONG,
+ PVOID, BOOLEAN) PLSA_SAVE_SUPPLEMENTAL_CREDENTIALS;
+alias HANDLE function(SEC_ATTRS, ULONG, SEC_THREAD_START,
+ PVOID, ULONG, PULONG) PLSA_CREATE_THREAD;
+alias NTSTATUS function(PSECPKG_CLIENT_INFO) PLSA_GET_CLIENT_INFO;
+alias HANDLE function(SEC_THREAD_START, PVOID,
+ ULONG, ULONG, ULONG, ULONG, HANDLE) PLSA_REGISTER_NOTIFICATION;
+alias NTSTATUS function(HANDLE) PLSA_CANCEL_NOTIFICATION;
+alias NTSTATUS function(PSecBuffer, PSecBuffer) PLSA_MAP_BUFFER;
+alias NTSTATUS function(PLUID, PTOKEN_SOURCE,
+ SECURITY_LOGON_TYPE, SECURITY_IMPERSONATION_LEVEL, LSA_TOKEN_INFORMATION_TYPE,
+ PVOID, PTOKEN_GROUPS, PUNICODE_STRING, PUNICODE_STRING, PUNICODE_STRING,
+ PUNICODE_STRING, PHANDLE, PNTSTATUS) PLSA_CREATE_TOKEN;
+alias void function(NTSTATUS, NTSTATUS, PUNICODE_STRING,
+ PUNICODE_STRING, PUNICODE_STRING, PSID, SECURITY_LOGON_TYPE,
+ PTOKEN_SOURCE, PLUID) PLSA_AUDIT_LOGON;
+alias NTSTATUS function(PUNICODE_STRING, PVOID, ULONG,
+ PVOID*, PULONG, PNTSTATUS) PLSA_CALL_PACKAGE;
+alias BOOLEAN function(PSECPKG_CALL_INFO) PLSA_GET_CALL_INFO;
+alias NTSTATUS function(PUNICODE_STRING, PVOID, PVOID,
+ ULONG, PVOID*, PULONG, PNTSTATUS) PLSA_CALL_PACKAGEEX;
+alias PVOID function(ULONG, ULONG) PLSA_CREATE_SHARED_MEMORY;
+alias PVOID function(PVOID, ULONG) PLSA_ALLOCATE_SHARED_MEMORY;
+alias void function(PVOID, PVOID) PLSA_FREE_SHARED_MEMORY;
+alias BOOLEAN function(PVOID) PLSA_DELETE_SHARED_MEMORY;
+alias NTSTATUS function(PSECURITY_STRING, SECPKG_NAME_TYPE,
+ PSECURITY_STRING, BOOLEAN, ULONG, PVOID*) PLSA_OPEN_SAM_USER;
+alias NTSTATUS function(PVOID, PVOID *, PULONG,
+ PVOID *, PULONG) PLSA_GET_USER_CREDENTIALS;
+alias NTSTATUS function(PVOID, PUCHAR *, PULONG) PLSA_GET_USER_AUTH_DATA;
+alias NTSTATUS function(PVOID) PLSA_CLOSE_SAM_USER;
+alias NTSTATUS function(PVOID, ULONG,
+ SECURITY_IMPERSONATION_LEVEL, PTOKEN_SOURCE, SECURITY_LOGON_TYPE,
+ PUNICODE_STRING, PHANDLE, PLUID, PUNICODE_STRING, PNTSTATUS) PLSA_CONVERT_AUTH_DATA_TO_TOKEN;
+alias NTSTATUS function(PCHAR, ULONG_PTR, ULONG_PTR,
+ PSecBuffer, PSecBuffer) PLSA_CLIENT_CALLBACK;
+alias NTSTATUS function(PSECPKG_PRIMARY_CRED, PSECPKG_SUPPLEMENTAL_CRED_ARRAY) PLSA_UPDATE_PRIMARY_CREDENTIALS;
+alias NTSTATUS function(PSECURITY_STRING,
+ SECPKG_NAME_TYPE, PSECURITY_STRING, PUCHAR *, PULONG, PUNICODE_STRING) PLSA_GET_AUTH_DATA_FOR_USER;
+alias NTSTATUS function(ULONG, BOOLEAN,
+ PUNICODE_STRING, PUNICODE_STRING, ULONG, PUNICODE_STRING, PUNICODE_STRING,
+ PULONG) PLSA_CRACK_SINGLE_NAME;
+alias NTSTATUS function(ULONG, BOOLEAN,
+ PUNICODE_STRING, PUNICODE_STRING, PUNICODE_STRING, NTSTATUS) PLSA_AUDIT_ACCOUNT_LOGON;
+alias NTSTATUS function(PUNICODE_STRING, PVOID,
+ PVOID, ULONG, PVOID*, PULONG, PNTSTATUS) PLSA_CALL_PACKAGE_PASSTHROUGH;
+
+/* Dispatch tables of functions used by SSP/AP */
+struct SECPKG_DLL_FUNCTIONS {
+    PLSA_ALLOCATE_LSA_HEAP AllocateHeap;
+    PLSA_FREE_LSA_HEAP FreeHeap;
+    PLSA_REGISTER_CALLBACK RegisterCallback;
+}
+alias SECPKG_DLL_FUNCTIONS* PSECPKG_DLL_FUNCTIONS;
+struct LSA_DISPATCH_TABLE {
+    PLSA_CREATE_LOGON_SESSION CreateLogonSession;
+    PLSA_DELETE_LOGON_SESSION DeleteLogonSession;
+    PLSA_ADD_CREDENTIAL AddCredential;
+    PLSA_GET_CREDENTIALS GetCredentials;
+    PLSA_DELETE_CREDENTIAL DeleteCredential;
+    PLSA_ALLOCATE_LSA_HEAP AllocateLsaHeap;
+    PLSA_FREE_LSA_HEAP FreeLsaHeap;
+    PLSA_ALLOCATE_CLIENT_BUFFER AllocateClientBuffer;
+    PLSA_FREE_CLIENT_BUFFER FreeClientBuffer;
+    PLSA_COPY_TO_CLIENT_BUFFER CopyToClientBuffer;
+    PLSA_COPY_FROM_CLIENT_BUFFER CopyFromClientBuffer;
+}
+alias LSA_DISPATCH_TABLE* PLSA_DISPATCH_TABLE;
+struct LSA_SECPKG_FUNCTION_TABLE {
+    PLSA_CREATE_LOGON_SESSION CreateLogonSession;
+    PLSA_DELETE_LOGON_SESSION DeleteLogonSession;
+    PLSA_ADD_CREDENTIAL AddCredential;
+    PLSA_GET_CREDENTIALS GetCredentials;
+    PLSA_DELETE_CREDENTIAL DeleteCredential;
+    PLSA_ALLOCATE_LSA_HEAP AllocateLsaHeap;
+    PLSA_FREE_LSA_HEAP FreeLsaHeap;
+    PLSA_ALLOCATE_CLIENT_BUFFER AllocateClientBuffer;
+    PLSA_FREE_CLIENT_BUFFER FreeClientBuffer;
+    PLSA_COPY_TO_CLIENT_BUFFER CopyToClientBuffer;
+    PLSA_COPY_FROM_CLIENT_BUFFER CopyFromClientBuffer;
+    PLSA_IMPERSONATE_CLIENT ImpersonateClient;
+    PLSA_UNLOAD_PACKAGE UnloadPackage;
+    PLSA_DUPLICATE_HANDLE DuplicateHandle;
+    PLSA_SAVE_SUPPLEMENTAL_CREDENTIALS SaveSupplementalCredentials;
+    PLSA_CREATE_THREAD CreateThread;
+    PLSA_GET_CLIENT_INFO GetClientInfo;
+    PLSA_REGISTER_NOTIFICATION RegisterNotification;
+    PLSA_CANCEL_NOTIFICATION CancelNotification;
+    PLSA_MAP_BUFFER MapBuffer;
+    PLSA_CREATE_TOKEN CreateToken;
+    PLSA_AUDIT_LOGON AuditLogon;
+    PLSA_CALL_PACKAGE CallPackage;
+    PLSA_FREE_LSA_HEAP FreeReturnBuffer;
+    PLSA_GET_CALL_INFO GetCallInfo;
+    PLSA_CALL_PACKAGEEX CallPackageEx;
+    PLSA_CREATE_SHARED_MEMORY CreateSharedMemory;
+    PLSA_ALLOCATE_SHARED_MEMORY AllocateSharedMemory;
+    PLSA_FREE_SHARED_MEMORY FreeSharedMemory;
+    PLSA_DELETE_SHARED_MEMORY DeleteSharedMemory;
+    PLSA_OPEN_SAM_USER OpenSamUser;
+    PLSA_GET_USER_CREDENTIALS GetUserCredentials;
+    PLSA_GET_USER_AUTH_DATA GetUserAuthData;
+    PLSA_CLOSE_SAM_USER CloseSamUser;
+    PLSA_CONVERT_AUTH_DATA_TO_TOKEN ConvertAuthDataToToken;
+    PLSA_CLIENT_CALLBACK ClientCallback;
+    PLSA_UPDATE_PRIMARY_CREDENTIALS UpdateCredentials;
+    PLSA_GET_AUTH_DATA_FOR_USER GetAuthDataForUser;
+    PLSA_CRACK_SINGLE_NAME CrackSingleName;
+    PLSA_AUDIT_ACCOUNT_LOGON AuditAccountLogon;
+    PLSA_CALL_PACKAGE_PASSTHROUGH CallPackagePassthrough;
+}
+alias LSA_SECPKG_FUNCTION_TABLE* PLSA_SECPKG_FUNCTION_TABLE;
+
+/* functions implemented by SSP/AP obtainable by dispatch tables */
+alias NTSTATUS function(ULONG, PLSA_DISPATCH_TABLE,
+ PLSA_STRING, PLSA_STRING, PLSA_STRING *) PLSA_AP_INITIALIZE_PACKAGE;
+alias NTSTATUS function(LPWSTR, LPWSTR, LPWSTR, LPWSTR,
+ DWORD, DWORD, PHANDLE) PLSA_AP_LOGON_USER;
+alias NTSTATUS function(PUNICODE_STRING, PVOID, ULONG,
+ PVOID *, PULONG, PNTSTATUS) PLSA_AP_CALL_PACKAGE;
+alias void function(PLUID) PLSA_AP_LOGON_TERMINATED;
+alias NTSTATUS function(PLSA_CLIENT_REQUEST,
+ PVOID, PVOID, ULONG, PVOID *, PULONG, PNTSTATUS) PLSA_AP_CALL_PACKAGE_UNTRUSTED;
+alias NTSTATUS function(PUNICODE_STRING,
+ PVOID, PVOID, ULONG, PVOID *, PULONG, PNTSTATUS) PLSA_AP_CALL_PACKAGE_PASSTHROUGH;
+alias NTSTATUS function(PLSA_CLIENT_REQUEST,
+ SECURITY_LOGON_TYPE, PVOID, PVOID, ULONG, PVOID *, PULONG, PLUID, PNTSTATUS,
+ PLSA_TOKEN_INFORMATION_TYPE, PVOID *, PUNICODE_STRING *, PUNICODE_STRING *,
+ PUNICODE_STRING *) PLSA_AP_LOGON_USER_EX;
+alias NTSTATUS function(PLSA_CLIENT_REQUEST,
+ SECURITY_LOGON_TYPE, PVOID, PVOID, ULONG, PVOID *, PULONG, PLUID, PNTSTATUS,
+ PLSA_TOKEN_INFORMATION_TYPE, PVOID *, PUNICODE_STRING *, PUNICODE_STRING *,
+ PUNICODE_STRING *, PSECPKG_PRIMARY_CRED, PSECPKG_SUPPLEMENTAL_CRED_ARRAY *) PLSA_AP_LOGON_USER_EX2;
+alias NTSTATUS function(ULONG_PTR, PSECPKG_PARAMETERS,
+ PLSA_SECPKG_FUNCTION_TABLE) SpInitializeFn;
+alias NTSTATUS function() SpShutDownFn;
+alias NTSTATUS function(PSecPkgInfoW) SpGetInfoFn;
+alias NTSTATUS function(SECURITY_LOGON_TYPE,
+ PUNICODE_STRING, PSECPKG_PRIMARY_CRED, PSECPKG_SUPPLEMENTAL_CRED) SpAcceptCredentialsFn;
+alias NTSTATUS function(PUNICODE_STRING, ULONG,
+ PLUID, PVOID, PVOID, PVOID, PLSA_SEC_HANDLE, PTimeStamp) SpAcquireCredentialsHandleFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, ULONG, PVOID) SpQueryCredentialsAttributesFn;
+alias NTSTATUS function(LSA_SEC_HANDLE) SpFreeCredentialsHandleFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, PSecBuffer) SpSaveCredentialsFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, PSecBuffer) SpGetCredentialsFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, PSecBuffer) SpDeleteCredentialsFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, LSA_SEC_HANDLE,
+ PUNICODE_STRING, ULONG, ULONG, PSecBufferDesc, PLSA_SEC_HANDLE, PSecBufferDesc,
+ PULONG, PTimeStamp, PBOOLEAN, PSecBuffer) SpInitLsaModeContextFn;
+alias NTSTATUS function(LSA_SEC_HANDLE,
+ LSA_SEC_HANDLE, PSecBufferDesc, ULONG, ULONG, PLSA_SEC_HANDLE, PSecBufferDesc,
+ PULONG, PTimeStamp, PBOOLEAN, PSecBuffer) SpAcceptLsaModeContextFn;
+alias NTSTATUS function(LSA_SEC_HANDLE) SpDeleteContextFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, PSecBufferDesc) SpApplyControlTokenFn;
+alias NTSTATUS function(PLUID, ULONG, PSecurityUserData *) SpGetUserInfoFn;
+alias NTSTATUS function(SECPKG_EXTENDED_INFORMATION_CLASS, PSECPKG_EXTENDED_INFORMATION *) SpGetExtendedInformationFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, ULONG, PVOID) SpQueryContextAttributesFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, PUNICODE_STRING,
+ PUNICODE_STRING, ULONG, PVOID, PVOID, PVOID, PTimeStamp) SpAddCredentialsFn;
+alias NTSTATUS function(
+ SECPKG_EXTENDED_INFORMATION_CLASS, PSECPKG_EXTENDED_INFORMATION) SpSetExtendedInformationFn;
+alias NTSTATUS function(ULONG, PSECPKG_DLL_FUNCTIONS,
+ PVOID *) SpInstanceInitFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, PSecBuffer) SpInitUserModeContextFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, ULONG,
+ PSecBufferDesc, ULONG) SpMakeSignatureFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, PSecBufferDesc,
+ ULONG, PULONG) SpVerifySignatureFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, ULONG, PSecBufferDesc,
+ ULONG) SpSealMessageFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, PSecBufferDesc,
+ ULONG, PULONG) SpUnsealMessageFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, PHANDLE) SpGetContextTokenFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, PSecBufferDesc) SpCompleteAuthTokenFn;
+alias NTSTATUS function(PSecBuffer, PSecBuffer) SpFormatCredentialsFn;
+alias NTSTATUS function(ULONG, PUCHAR, PULONG,
+ PVOID *) SpMarshallSupplementalCredsFn;
+alias NTSTATUS function(LSA_SEC_HANDLE, ULONG,
+ PSecBuffer, PHANDLE) SpExportSecurityContextFn;
+alias NTSTATUS function(PSecBuffer, HANDLE,
+ PLSA_SEC_HANDLE) SpImportSecurityContextFn;
+
+/* Dispatch tables of functions implemented by SSP/AP */
+struct SECPKG_FUNCTION_TABLE {
+    PLSA_AP_INITIALIZE_PACKAGE InitializePackage;
+    PLSA_AP_LOGON_USER LogonUser;
+    PLSA_AP_CALL_PACKAGE CallPackage;
+    PLSA_AP_LOGON_TERMINATED LogonTerminated;
+    PLSA_AP_CALL_PACKAGE_UNTRUSTED CallPackageUntrusted;
+    PLSA_AP_CALL_PACKAGE_PASSTHROUGH CallPackagePassthrough;
+    PLSA_AP_LOGON_USER_EX LogonUserEx;
+    PLSA_AP_LOGON_USER_EX2 LogonUserEx2;
+    SpInitializeFn *Initialize;
+    SpShutDownFn *Shutdown;
+    SpGetInfoFn *GetInfo;
+    SpAcceptCredentialsFn *AcceptCredentials;
+    SpAcquireCredentialsHandleFn *AcquireCredentialsHandle;
+    SpQueryCredentialsAttributesFn *QueryCredentialsAttributes;
+    SpFreeCredentialsHandleFn *FreeCredentialsHandle;
+    SpSaveCredentialsFn *SaveCredentials;
+    SpGetCredentialsFn *GetCredentials;
+    SpDeleteCredentialsFn *DeleteCredentials;
+    SpInitLsaModeContextFn *InitLsaModeContext;
+    SpAcceptLsaModeContextFn *AcceptLsaModeContext;
+    SpDeleteContextFn *DeleteContext;
+    SpApplyControlTokenFn *ApplyControlToken;
+    SpGetUserInfoFn *GetUserInfo;
+    SpGetExtendedInformationFn *GetExtendedInformation;
+    SpQueryContextAttributesFn *QueryContextAttributes;
+    SpAddCredentialsFn *AddCredentials;
+    SpSetExtendedInformationFn *SetExtendedInformation;
+}
+alias SECPKG_FUNCTION_TABLE* PSECPKG_FUNCTION_TABLE;
+
+struct SECPKG_USER_FUNCTION_TABLE {
+    SpInstanceInitFn *InstanceInit;
+    SpInitUserModeContextFn *InitUserModeContext;
+    SpMakeSignatureFn *MakeSignature;
+    SpVerifySignatureFn *VerifySignature;
+    SpSealMessageFn *SealMessage;
+    SpUnsealMessageFn *UnsealMessage;
+    SpGetContextTokenFn *GetContextToken;
+    SpQueryContextAttributesFn *QueryContextAttributes;
+    SpCompleteAuthTokenFn *CompleteAuthToken;
+    SpDeleteContextFn *DeleteUserModeContext;
+    SpFormatCredentialsFn *FormatCredentials;
+    SpMarshallSupplementalCredsFn *MarshallSupplementalCreds;
+    SpExportSecurityContextFn *ExportContext;
+    SpImportSecurityContextFn *ImportContext;
+}
+alias SECPKG_USER_FUNCTION_TABLE* PSECPKG_USER_FUNCTION_TABLE;
+
+/* Entry points to SSP/AP */
+alias NTSTATUS function(ULONG, PULONG,
+ PSECPKG_FUNCTION_TABLE *, PULONG) SpLsaModeInitializeFn;
+alias NTSTATUS function(ULONG, PULONG,
+ PSECPKG_USER_FUNCTION_TABLE *, PULONG) SpUserModeInitializeFn;
+
diff --git a/libphobos/libdruntime/core/sys/windows/oaidl.d b/libphobos/libdruntime/core/sys/windows/oaidl.d
new file mode 100644
index 00000000000..7d89901d6aa
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/oaidl.d
@@ -0,0 +1,672 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_oaidl.d)
+ */
+module core.sys.windows.oaidl;
+version (Windows):
+
+private import core.sys.windows.basetyps, core.sys.windows.unknwn, core.sys.windows.windef, core.sys.windows.wtypes;
+
+enum DISPID_UNKNOWN = -1;
+enum DISPID_VALUE = 0;
+enum DISPID_PROPERTYPUT = -3;
+enum DISPID_NEWENUM = -4;
+enum DISPID_EVALUATE = -5;
+enum DISPID_CONSTRUCTOR = -6;
+enum DISPID_DESTRUCTOR = -7;
+enum DISPID_COLLECT = -8;
+
+enum FADF_AUTO = 1;
+enum FADF_STATIC = 2;
+enum FADF_EMBEDDED = 4;
+enum FADF_FIXEDSIZE = 16;
+enum FADF_RECORD = 32;
+enum FADF_HAVEIID = 64;
+enum FADF_HAVEVARTYPE = 128;
+enum FADF_BSTR = 256;
+enum FADF_UNKNOWN = 512;
+enum FADF_DISPATCH = 1024;
+enum FADF_VARIANT = 2048;
+enum FADF_RESERVED = 0xf0e8;
+enum FADF_DATADELETED = 0x1000;
+enum FADF_CREATEVECTOR = 0x2000;
+
+enum PARAMFLAG_NONE = 0;
+enum PARAMFLAG_FIN = 1;
+enum PARAMFLAG_FOUT = 2;
+enum PARAMFLAG_FLCID = 4;
+enum PARAMFLAG_FRETVAL = 8;
+enum PARAMFLAG_FOPT = 16;
+enum PARAMFLAG_FHASDEFAULT = 32;
+
+enum IDLFLAG_NONE = PARAMFLAG_NONE;
+enum IDLFLAG_FIN = PARAMFLAG_FIN;
+enum IDLFLAG_FOUT = PARAMFLAG_FOUT;
+enum IDLFLAG_FLCID = PARAMFLAG_FLCID;
+enum IDLFLAG_FRETVAL = PARAMFLAG_FRETVAL;
+
+enum IMPLTYPEFLAG_FDEFAULT       = 1;
+enum IMPLTYPEFLAG_FSOURCE        = 2;
+enum IMPLTYPEFLAG_FRESTRICTED    = 4;
+enum IMPLTYPEFLAG_FDEFAULTVTABLE = 8;
+
+
+enum SYSKIND {
+    SYS_WIN16,
+    SYS_WIN32,
+    SYS_MAC
+}
+
+enum LIBFLAGS {
+    LIBFLAG_FRESTRICTED   = 1,
+    LIBFLAG_FCONTROL      = 2,
+    LIBFLAG_FHIDDEN       = 4,
+    LIBFLAG_FHASDISKIMAGE = 8
+}
+
+struct TLIBATTR {
+    GUID guid;
+    LCID lcid;
+    SYSKIND syskind;
+    WORD wMajorVerNum;
+    WORD wMinorVerNum;
+    WORD wLibFlags;
+}
+alias TLIBATTR* LPTLIBATTR;
+
+alias CY CURRENCY;
+
+struct SAFEARRAYBOUND {
+    ULONG cElements;
+    LONG lLbound;
+}
+alias SAFEARRAYBOUND* LPSAFEARRAYBOUND;
+
+struct SAFEARR_BSTR {
+    ULONG Size;
+    wireBSTR* aBstr;
+}
+
+struct SAFEARR_UNKNOWN {
+    ULONG Size;
+    IUnknown* apUnknown;
+}
+
+struct SAFEARR_DISPATCH {
+    ULONG Size;
+    LPDISPATCH* apDispatch;
+}
+
+struct SAFEARR_VARIANT {
+    ULONG Size;
+    _wireVARIANT* aVariant;
+}
+
+enum SF_TYPE {
+    SF_ERROR=VARENUM.VT_ERROR,
+    SF_I1=VARENUM.VT_I1,
+    SF_I2=VARENUM.VT_I2,
+    SF_I4=VARENUM.VT_I4,
+    SF_I8=VARENUM.VT_I8,
+    SF_BSTR=VARENUM.VT_BSTR,
+    SF_UNKNOWN=VARENUM.VT_UNKNOWN,
+    SF_DISPATCH=VARENUM.VT_DISPATCH,
+    SF_VARIANT=VARENUM.VT_VARIANT
+}
+
+struct _wireBRECORD {
+    ULONG fFlags;
+    ULONG clSize;
+    LPRECORDINFO* pRecInfo;
+    byte* pRecord;
+}
+alias _wireBRECORD* wireBRECORD;
+
+struct SAFEARR_BRECORD {
+    ULONG Size;
+    wireBRECORD* aRecord;
+}
+
+struct SAFEARR_HAVEIID {
+    ULONG Size;
+    IUnknown* apUnknown;
+    IID iid;
+}
+
+struct SAFEARRAYUNION {
+    ULONG sfType;
+    union _u {
+        SAFEARR_BSTR BstrStr;
+        SAFEARR_UNKNOWN UnknownStr;
+        SAFEARR_DISPATCH DispatchStr;
+        SAFEARR_VARIANT VariantStr;
+        SAFEARR_BRECORD RecordStr;
+        SAFEARR_HAVEIID HaveIidStr;
+        BYTE_SIZEDARR ByteStr;
+        WORD_SIZEDARR WordStr;
+        DWORD_SIZEDARR LongStr;
+        HYPER_SIZEDARR HyperStr;
+    }
+    _u u;
+}
+
+struct _wireSAFEARRAY {
+    USHORT cDims;
+    USHORT fFeatures;
+    ULONG cbElements;
+    ULONG cLocks;
+    SAFEARRAYUNION uArrayStructs;
+    SAFEARRAYBOUND[1] rgsabound;
+}
+alias _wireSAFEARRAY* wireSAFEARRAY;
+
+alias wireSAFEARRAY* wirePSAFEARRAY;
+
+struct SAFEARRAY {
+    USHORT cDims;
+    USHORT fFeatures;
+    ULONG cbElements;
+    ULONG cLocks;
+    PVOID pvData;
+    SAFEARRAYBOUND[1] rgsabound;
+}
+alias SAFEARRAY* LPSAFEARRAY;
+
+struct VARIANT {
+    union {
+        struct {
+            VARTYPE vt;
+            WORD wReserved1;
+            WORD wReserved2;
+            WORD wReserved3;
+            union {
+                int lVal;
+                LONGLONG llVal;
+                ubyte bVal;
+                short iVal;
+                float fltVal;
+                double dblVal;
+                VARIANT_BOOL  boolVal;
+                SCODE scode;
+                CY cyVal;
+                DATE date;
+                BSTR bstrVal;
+                IUnknown punkVal;
+                IDispatch pdispVal;
+                SAFEARRAY* parray;
+                ubyte* pbVal;
+                short* piVal;
+                int* plVal;
+                float* pfltVal;
+                double* pdblVal;
+                VARIANT_BOOL* pboolVal;
+                _VARIANT_BOOL*  pbool;
+                SCODE* pscode;
+                CY* pcyVal;
+                DATE* pdate;
+                BSTR* pbstrVal;
+                IUnknown* ppunkVal;
+                IDispatch* ppdispVal;
+                SAFEARRAY** pparray;
+                VARIANT* pvarVal;
+                void* byref;
+                CHAR cVal;
+                USHORT uiVal;
+                ULONG ulVal;
+                ULONGLONG ullVal;
+                INT intVal;
+                UINT uintVal;
+                DECIMAL* pdecVal;
+                CHAR*  pcVal;
+                USHORT*  puiVal;
+                ULONG*  pulVal;
+                INT*  pintVal;
+                UINT*  puintVal;
+                struct {
+                    PVOID pvRecord;
+                    IRecordInfo pRecInfo;
+                }
+            }
+        }
+        DECIMAL decVal;
+    }
+}
+alias VARIANT* LPVARIANT;
+
+alias VARIANT VARIANTARG;
+alias VARIANT* LPVARIANTARG;
+
+struct _wireVARIANT {
+    DWORD clSize;
+    DWORD rpcReserved;
+    USHORT vt;
+    USHORT wReserved1;
+    USHORT wReserved2;
+    USHORT wReserved3;
+    union {
+        LONG lVal;
+        LONGLONG llVal;
+        BYTE bVal;
+        SHORT iVal;
+        FLOAT fltVal;
+        DOUBLE dblVal;
+        VARIANT_BOOL boolVal;
+        SCODE scode;
+        CY cyVal;
+        DATE date;
+        wireBSTR bstrVal;
+        IUnknown punkVal;
+        LPDISPATCH pdispVal;
+        wirePSAFEARRAY parray;
+        wireBRECORD brecVal;
+        BYTE* pbVal;
+        SHORT* piVal;
+        LONG* plVal;
+        FLOAT* pfltVal;
+        DOUBLE* pdblVal;
+        VARIANT_BOOL* pboolVal;
+        SCODE* pscode;
+        CY* pcyVal;
+        DATE* pdate;
+        wireBSTR* pbstrVal;
+        IUnknown* ppunkVal;
+        LPDISPATCH* ppdispVal;
+        wirePSAFEARRAY* pparray;
+        wireVARIANT* pvarVal;
+        CHAR cVal;
+        USHORT uiVal;
+        ULONG ulVal;
+        ULONGLONG ullVal;
+        INT intVal;
+        UINT uintVal;
+        DECIMAL decVal;
+        DECIMAL* pdecVal;
+        CHAR* pcVal;
+        USHORT* puiVal;
+        ULONG* pulVal;
+        INT* pintVal;
+        UINT* puintVal;
+    }
+}
+alias _wireVARIANT* wireVARIANT;
+
+alias LONG DISPID;
+alias DISPID MEMBERID;
+alias DWORD HREFTYPE;
+
+enum TYPEKIND {
+    TKIND_ENUM, TKIND_RECORD, TKIND_MODULE, TKIND_INTERFACE, TKIND_DISPATCH,
+    TKIND_COCLASS, TKIND_ALIAS, TKIND_UNION, TKIND_MAX
+}
+
+struct TYPEDESC {
+    union {
+        TYPEDESC* lptdesc;
+        ARRAYDESC* lpadesc;
+        HREFTYPE hreftype;
+    }
+    VARTYPE vt;
+}
+
+struct ARRAYDESC {
+    TYPEDESC tdescElem;
+    USHORT cDims;
+    SAFEARRAYBOUND[1] rgbounds;
+}
+
+struct PARAMDESCEX {
+    ULONG cBytes;
+    VARIANTARG varDefaultValue;
+}
+alias PARAMDESCEX* LPPARAMDESCEX;
+
+struct PARAMDESC {
+    LPPARAMDESCEX pparamdescex;
+    USHORT wParamFlags;
+}
+alias PARAMDESC* LPPARAMDESC;
+
+struct IDLDESC {
+    ULONG dwReserved;
+    USHORT wIDLFlags;
+}
+alias IDLDESC* LPIDLDESC;
+
+struct ELEMDESC {
+    TYPEDESC tdesc;
+    union {
+        IDLDESC idldesc;
+        PARAMDESC paramdesc;
+    }
+}
+alias ELEMDESC* LPELEMDESC;
+
+struct TYPEATTR {
+    GUID guid;
+    LCID lcid;
+    DWORD dwReserved;
+    MEMBERID memidConstructor;
+    MEMBERID memidDestructor;
+    LPOLESTR lpstrSchema;
+    ULONG cbSizeInstance;
+    TYPEKIND typekind;
+    WORD cFuncs;
+    WORD cVars;
+    WORD cImplTypes;
+    WORD cbSizeVft;
+    WORD cbAlignment;
+    WORD wTypeFlags;
+    WORD wMajorVerNum;
+    WORD wMinorVerNum;
+    TYPEDESC tdescAlias;
+    IDLDESC idldescType;
+}
+alias TYPEATTR* LPTYPEATTR;
+
+struct DISPPARAMS {
+    VARIANTARG* rgvarg;
+    DISPID* rgdispidNamedArgs;
+    UINT cArgs;
+    UINT cNamedArgs;
+}
+
+struct EXCEPINFO {
+    WORD wCode;
+    WORD wReserved;
+    BSTR bstrSource;
+    BSTR bstrDescription;
+    BSTR bstrHelpFile;
+    DWORD dwHelpContext;
+    PVOID pvReserved;
+    extern (Windows) {
+    HRESULT function (EXCEPINFO* ) pfnDeferredFillIn;
+    }
+    SCODE scode;
+}
+alias EXCEPINFO* LPEXCEPINFO;
+
+enum CALLCONV {
+    CC_FASTCALL,
+    CC_CDECL,
+    CC_MSCPASCAL,
+    CC_PASCAL=CC_MSCPASCAL,
+    CC_MACPASCAL,
+    CC_STDCALL,
+    CC_FPFASTCALL,
+    CC_SYSCALL,
+    CC_MPWCDECL,
+    CC_MPWPASCAL,
+    CC_MAX=CC_MPWPASCAL
+}
+
+enum FUNCKIND {
+    FUNC_VIRTUAL,
+    FUNC_PUREVIRTUAL,
+    FUNC_NONVIRTUAL,
+    FUNC_STATIC,
+    FUNC_DISPATCH
+}
+
+enum INVOKEKIND {
+    INVOKE_FUNC           = 1,
+    INVOKE_PROPERTYGET    = 2,
+    INVOKE_PROPERTYPUT    = 4,
+    INVOKE_PROPERTYPUTREF = 8
+}
+
+struct FUNCDESC {
+    MEMBERID memid;
+    SCODE* lprgscode;
+    ELEMDESC* lprgelemdescParam;
+    FUNCKIND funckind;
+    INVOKEKIND invkind;
+    CALLCONV callconv;
+    SHORT cParams;
+    SHORT cParamsOpt;
+    SHORT oVft;
+    SHORT cScodes;
+    ELEMDESC elemdescFunc;
+    WORD wFuncFlags;
+}
+alias FUNCDESC* LPFUNCDESC;
+
+enum VARKIND {
+    VAR_PERINSTANCE, VAR_STATIC, VAR_CONST, VAR_DISPATCH
+}
+
+struct VARDESC {
+    MEMBERID memid;
+    LPOLESTR lpstrSchema;
+    union {
+        ULONG oInst;
+        VARIANT* lpvarValue;
+    }
+    ELEMDESC elemdescVar;
+    WORD wVarFlags;
+    VARKIND varkind;
+}
+alias VARDESC* LPVARDESC;
+
+enum TYPEFLAGS {
+    TYPEFLAG_FAPPOBJECT     = 1,
+    TYPEFLAG_FCANCREATE     = 2,
+    TYPEFLAG_FLICENSED      = 4,
+    TYPEFLAG_FPREDECLID     = 8,
+    TYPEFLAG_FHIDDEN        = 16,
+    TYPEFLAG_FCONTROL       = 32,
+    TYPEFLAG_FDUAL          = 64,
+    TYPEFLAG_FNONEXTENSIBLE = 128,
+    TYPEFLAG_FOLEAUTOMATION = 256,
+    TYPEFLAG_FRESTRICTED    = 512,
+    TYPEFLAG_FAGGREGATABLE  = 1024,
+    TYPEFLAG_FREPLACEABLE   = 2048,
+    TYPEFLAG_FDISPATCHABLE  = 4096,
+    TYPEFLAG_FREVERSEBIND   = 8192
+}
+
+enum FUNCFLAGS {
+    FUNCFLAG_FRESTRICTED = 1,
+    FUNCFLAG_FSOURCE = 2,
+    FUNCFLAG_FBINDABLE = 4,
+    FUNCFLAG_FREQUESTEDIT = 8,
+    FUNCFLAG_FDISPLAYBIND = 16,
+    FUNCFLAG_FDEFAULTBIND = 32,
+    FUNCFLAG_FHIDDEN = 64,
+    FUNCFLAG_FUSESGETLASTERROR = 128,
+    FUNCFLAG_FDEFAULTCOLLELEM = 256,
+    FUNCFLAG_FUIDEFAULT = 512,
+    FUNCFLAG_FNONBROWSABLE = 1024,
+    FUNCFLAG_FREPLACEABLE = 2048,
+    FUNCFLAG_FIMMEDIATEBIND = 4096
+}
+
+enum VARFLAGS {
+    VARFLAG_FREADONLY = 1,
+    VARFLAG_FSOURCE = 2,
+    VARFLAG_FBINDABLE = 4,
+    VARFLAG_FREQUESTEDIT = 8,
+    VARFLAG_FDISPLAYBIND = 16,
+    VARFLAG_FDEFAULTBIND = 32,
+    VARFLAG_FHIDDEN = 64,
+    VARFLAG_FRESTRICTED = 128,
+    VARFLAG_FDEFAULTCOLLELEM = 256,
+    VARFLAG_FUIDEFAULT = 512,
+    VARFLAG_FNONBROWSABLE = 1024,
+    VARFLAG_FREPLACEABLE = 2048,
+    VARFLAG_FIMMEDIATEBIND = 4096
+}
+
+struct CLEANLOCALSTORAGE {
+    IUnknown pInterface;
+    PVOID pStorage;
+    DWORD flags;
+}
+
+struct CUSTDATAITEM {
+    GUID guid;
+    VARIANTARG varValue;
+}
+alias CUSTDATAITEM* LPCUSTDATAITEM;
+
+struct CUSTDATA {
+    DWORD cCustData;
+    LPCUSTDATAITEM prgCustData;
+}
+alias CUSTDATA* LPCUSTDATA;
+
+enum DESCKIND {
+    DESCKIND_NONE = 0,
+    DESCKIND_FUNCDESC = DESCKIND_NONE+1,
+    DESCKIND_VARDESC = DESCKIND_FUNCDESC+1,
+    DESCKIND_TYPECOMP = DESCKIND_VARDESC+1,
+    DESCKIND_IMPLICITAPPOBJ = DESCKIND_TYPECOMP+1,
+    DESCKIND_MAX = DESCKIND_IMPLICITAPPOBJ+1
+}
+
+union BINDPTR {
+    LPFUNCDESC lpfuncdesc;
+    LPVARDESC lpvardesc;
+    LPTYPECOMP lptcomp;
+}
+alias BINDPTR* LPBINDPTR;
+
+interface IDispatch : IUnknown {
+    HRESULT GetTypeInfoCount(UINT*);
+    HRESULT GetTypeInfo(UINT, LCID, LPTYPEINFO*);
+    HRESULT GetIDsOfNames(REFIID, LPOLESTR*, UINT, LCID, DISPID*);
+    HRESULT Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*);
+}
+alias IDispatch LPDISPATCH;
+
+interface IEnumVARIANT : IUnknown {
+    HRESULT Next(ULONG, VARIANT*, ULONG*);
+    HRESULT Skip(ULONG);
+    HRESULT Reset();
+    HRESULT Clone(IEnumVARIANT*);
+}
+alias IEnumVARIANT LPENUMVARIANT;
+
+interface ITypeComp : IUnknown {
+    HRESULT Bind(LPOLESTR, ULONG, WORD, LPTYPEINFO*, DESCKIND*, LPBINDPTR);
+    HRESULT BindType(LPOLESTR, ULONG, LPTYPEINFO*, LPTYPECOMP*);
+}
+alias ITypeComp LPTYPECOMP;
+
+interface ITypeInfo : IUnknown {
+    HRESULT GetTypeAttr(LPTYPEATTR*);
+    HRESULT GetTypeComp(LPTYPECOMP*);
+    HRESULT GetFuncDesc(UINT, LPFUNCDESC*);
+    HRESULT GetVarDesc(UINT, LPVARDESC*);
+    HRESULT GetNames(MEMBERID, BSTR*, UINT, UINT*);
+    HRESULT GetRefTypeOfImplType(UINT, HREFTYPE*);
+    HRESULT GetImplTypeFlags(UINT, INT*);
+    HRESULT GetIDsOfNames(LPOLESTR*, UINT, MEMBERID*);
+    HRESULT Invoke(PVOID, MEMBERID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*,
+      UINT*);
+    HRESULT GetDocumentation(MEMBERID, BSTR*, BSTR*, DWORD*, BSTR*);
+    HRESULT GetDllEntry(MEMBERID, INVOKEKIND, BSTR*, BSTR*, WORD*);
+    HRESULT GetRefTypeInfo(HREFTYPE, LPTYPEINFO*);
+    HRESULT AddressOfMember(MEMBERID, INVOKEKIND, PVOID*);
+    HRESULT CreateInstance(LPUNKNOWN, REFIID, PVOID*);
+    HRESULT GetMops(MEMBERID, BSTR*);
+    HRESULT GetContainingTypeLib(LPTYPELIB*, UINT*);
+    void ReleaseTypeAttr(LPTYPEATTR);
+    void ReleaseFuncDesc(LPFUNCDESC);
+    void ReleaseVarDesc(LPVARDESC);
+}
+alias ITypeInfo LPTYPEINFO;
+
+interface ITypeInfo2 : ITypeInfo {
+    HRESULT GetTypeKind(TYPEKIND*);
+    HRESULT GetTypeFlags(ULONG*);
+    HRESULT GetFuncIndexOfMemId(MEMBERID, INVOKEKIND, UINT*);
+    HRESULT GetVarIndexOfMemId(MEMBERID, UINT*);
+    HRESULT GetCustData(REFGUID, VARIANT*);
+    HRESULT GetFuncCustData(UINT, REFGUID, VARIANT*);
+    HRESULT GetParamCustData(UINT, UINT, REFGUID, VARIANT*);
+    HRESULT GetVarCustData(UINT, REFGUID, VARIANT*);
+    HRESULT GetImplTypeCustData(UINT, REFGUID, VARIANT*);
+    HRESULT GetDocumentation2(MEMBERID, LCID, BSTR*, DWORD*, BSTR*);
+    HRESULT GetAllCustData(CUSTDATA*);
+    HRESULT GetAllFuncCustData(UINT, CUSTDATA*);
+    HRESULT GetAllParamCustData(UINT, UINT, CUSTDATA*);
+    HRESULT GetAllVarCustData(UINT, CUSTDATA*);
+    HRESULT GetAllImplTypeCustData(UINT, CUSTDATA*);
+}
+alias ITypeInfo2 LPTYPEINFO2;
+
+interface ITypeLib : IUnknown {
+    UINT GetTypeInfoCount();
+    HRESULT GetTypeInfo(UINT, ITypeInfo*);
+    HRESULT GetTypeInfoType(UINT, TYPEKIND*);
+    HRESULT GetTypeInfoOfGuid(REFGUID, ITypeInfo*);
+    HRESULT GetLibAttr(TLIBATTR**);
+    HRESULT GetTypeComp(ITypeComp);
+    HRESULT GetDocumentation(INT, BSTR*, BSTR*, DWORD*, BSTR*);
+    HRESULT IsName(LPOLESTR, ULONG, BOOL*);
+    HRESULT FindName(LPOLESTR, ULONG, ITypeInfo*, MEMBERID*, USHORT*);
+    void ReleaseTLibAttr(TLIBATTR*);
+}
+alias ITypeLib LPTYPELIB;
+
+interface ITypeLib2 : ITypeLib {
+    HRESULT GetCustData(REFGUID, VARIANT*);
+    HRESULT GetLibStatistics(ULONG*, ULONG*);
+    HRESULT GetDocumentation2(INT, LCID, BSTR*, DWORD*, BSTR*);
+    HRESULT GetAllCustData(CUSTDATA*);
+}
+alias ITypeLib2 LPTYPELIB2;
+
+interface IErrorInfo : IUnknown {
+    HRESULT GetGUID(GUID*);
+    HRESULT GetSource(BSTR*);
+    HRESULT GetDescription(BSTR*);
+    HRESULT GetHelpFile(BSTR*);
+    HRESULT GetHelpContext(DWORD*);
+}
+alias IErrorInfo LPERRORINFO;
+
+interface ICreateErrorInfo : IUnknown {
+    HRESULT SetGUID(REFGUID);
+    HRESULT SetSource(LPOLESTR);
+    HRESULT SetDescription(LPOLESTR);
+    HRESULT SetHelpFile(LPOLESTR);
+    HRESULT SetHelpContext(DWORD);
+}
+alias ICreateErrorInfo LPCREATEERRORINFO;
+
+interface ISupportErrorInfo : IUnknown {
+    HRESULT InterfaceSupportsErrorInfo(REFIID);
+}
+alias ISupportErrorInfo LPSUPPORTERRORINFO;
+
+interface IRecordInfo : IUnknown {
+    HRESULT RecordInit(PVOID);
+    HRESULT RecordClear(PVOID);
+    HRESULT RecordCopy(PVOID, PVOID);
+    HRESULT GetGuid(GUID*);
+    HRESULT GetName(BSTR*);
+    HRESULT GetSize(ULONG*);
+    HRESULT GetTypeInfo(ITypeInfo*);
+    HRESULT GetField(PVOID, LPCOLESTR, VARIANT*);
+    HRESULT GetFieldNoCopy(PVOID, LPCOLESTR, VARIANT*, PVOID*);
+    HRESULT PutField (ULONG, PVOID, LPCOLESTR, VARIANT*);
+    HRESULT PutFieldNoCopy(ULONG, PVOID, LPCOLESTR, VARIANT*);
+    HRESULT GetFieldNames(ULONG*, BSTR*);
+    BOOL IsMatchingType();
+    PVOID RecordCreate();
+    HRESULT RecordCreateCopy(PVOID, PVOID*);
+    HRESULT RecordDestroy (PVOID);
+}
+alias IRecordInfo LPRECORDINFO;
+
+interface ITypeMarshal : IUnknown {
+    HRESULT Size(PVOID, DWORD, PVOID, ULONG*);
+    HRESULT Marshal(PVOID, DWORD, PVOID, ULONG, BYTE*, ULONG*);
+    HRESULT Unmarshal(PVOID, DWORD, ULONG, BYTE*, ULONG*);
+    HRESULT Free(PVOID);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/objbase.d b/libphobos/libdruntime/core/sys/windows/objbase.d
new file mode 100644
index 00000000000..e57f554ad5e
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/objbase.d
@@ -0,0 +1,207 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_objbase.d)
+ */
+module core.sys.windows.objbase;
+version (Windows):
+pragma(lib, "ole32");
+
+import core.sys.windows.cguid, core.sys.windows.objidl, core.sys.windows.unknwn, core.sys.windows.wtypes;
+private import core.sys.windows.basetyps, core.sys.windows.objfwd, core.sys.windows.rpcdce, core.sys.windows.winbase,
+  core.sys.windows.windef;
+
+// DAC: Not needed for D?
+//MACRO #define LISet32(li, v) ((li).HighPart=(v)<0?-1:0, (li).LowPart=(v))
+//MACRO #define ULISet32(li, v) ((li).HighPart=0, (li).LowPart=(v))
+
+enum CLSCTX_ALL    = CLSCTX.CLSCTX_INPROC_SERVER|CLSCTX.CLSCTX_INPROC_HANDLER|CLSCTX.CLSCTX_LOCAL_SERVER;
+enum CLSCTX_INPROC = CLSCTX.CLSCTX_INPROC_SERVER|CLSCTX.CLSCTX_INPROC_HANDLER;
+enum CLSCTX_SERVER = CLSCTX.CLSCTX_INPROC_SERVER|CLSCTX.CLSCTX_LOCAL_SERVER|CLSCTX.CLSCTX_REMOTE_SERVER;
+enum MARSHALINTERFACE_MIN=500;
+enum CWCSTORAGENAME=32;
+
+enum STGM_DIRECT           = 0;
+enum STGM_TRANSACTED       = 0x10000L;
+enum STGM_SIMPLE           = 0x8000000L;
+enum STGM_READ             = 0;
+enum STGM_WRITE            = 1;
+enum STGM_READWRITE        = 2;
+enum STGM_SHARE_DENY_NONE  = 0x40;
+enum STGM_SHARE_DENY_READ  = 0x30;
+enum STGM_SHARE_DENY_WRITE = 0x20;
+enum STGM_SHARE_EXCLUSIVE  = 0x10;
+enum STGM_PRIORITY         = 0x40000L;
+enum STGM_DELETEONRELEASE  = 0x4000000;
+enum STGM_NOSCRATCH        = 0x100000;
+enum STGM_CREATE           = 0x1000;
+enum STGM_CONVERT          = 0x20000;
+enum STGM_NOSNAPSHOT       = 0x200000;
+enum STGM_FAILIFTHERE      = 0;
+
+enum ASYNC_MODE_COMPATIBILITY = 1;
+enum ASYNC_MODE_DEFAULT       = 0;
+
+enum STGTY_REPEAT = 256;
+enum STG_TOEND = 0xFFFFFFFF;
+enum STG_LAYOUT_SEQUENTIAL  = 0;
+enum STG_LAYOUT_INTERLEAVED = 1;
+
+enum COM_RIGHTS_EXECUTE            = 1;
+enum COM_RIGHTS_SAFE_FOR_SCRIPTING = 2;
+
+enum STGOPTIONS_VERSION = 2;
+
+enum STGFMT {
+    STGFMT_STORAGE = 0,
+    STGFMT_FILE = 3,
+    STGFMT_ANY = 4,
+    STGFMT_DOCFILE = 5
+}
+
+struct STGOPTIONS {
+    USHORT usVersion;
+    USHORT reserved;
+    ULONG ulSectorSize;
+const(WCHAR)* pwcsTemplateFile;
+}
+
+enum REGCLS {
+    REGCLS_SINGLEUSE = 0,
+    REGCLS_MULTIPLEUSE = 1,
+    REGCLS_MULTI_SEPARATE = 2
+}
+
+/*
+BOOL IsEqualGUID(GUID rguid1, GUID rguid2) {
+    return rguid1 == rguid2;
+}
+*/
+
+extern (Windows) BOOL IsEqualGUID(
+  REFGUID rguid1,
+  REFGUID rguid2
+);
+
+alias IsEqualGUID IsEqualIID;
+alias IsEqualGUID IsEqualCLSID;
+
+enum COINIT {
+    COINIT_APARTMENTTHREADED = 2,
+    COINIT_MULTITHREADED     = 0,
+    COINIT_DISABLE_OLE1DDE   = 4,
+    COINIT_SPEED_OVER_MEMORY = 8
+}
+
+enum STDMSHLFLAGS {
+    SMEXF_SERVER  = 1,
+    SMEXF_HANDLER
+}
+
+extern(Windows) {
+    alias HRESULT function(REFCLSID, REFIID, PVOID*) LPFNGETCLASSOBJECT;
+    alias HRESULT function() LPFNCANUNLOADNOW;
+
+    DWORD CoBuildVersion();
+    HRESULT CoInitialize(PVOID);
+    HRESULT CoInitializeEx(LPVOID, DWORD);
+    void CoUninitialize();
+    HRESULT CoGetMalloc(DWORD, LPMALLOC*);
+    DWORD CoGetCurrentProcess();
+    HRESULT CoRegisterMallocSpy(LPMALLOCSPY);
+    HRESULT CoRevokeMallocSpy();
+    HRESULT CoCreateStandardMalloc(DWORD, IMalloc*);
+    //#ifdef DBG
+    ULONG DebugCoGetRpcFault();
+    void DebugCoSetRpcFault(ULONG);
+    //#endif
+    HRESULT CoGetClassObject(REFCLSID, DWORD, COSERVERINFO*, REFIID, PVOID*);
+    HRESULT CoRegisterClassObject(REFCLSID, LPUNKNOWN, DWORD, DWORD, PDWORD);
+    HRESULT CoRevokeClassObject(DWORD);
+    HRESULT CoGetMarshalSizeMax(ULONG*, REFIID, LPUNKNOWN, DWORD, PVOID, DWORD);
+    HRESULT CoMarshalInterface(LPSTREAM, REFIID, LPUNKNOWN, DWORD, PVOID, DWORD);
+    HRESULT CoUnmarshalInterface(LPSTREAM, REFIID, PVOID*);
+    HRESULT CoMarshalHresult(LPSTREAM, HRESULT);
+    HRESULT CoUnmarshalHresult(LPSTREAM, HRESULT*);
+    HRESULT CoReleaseMarshalData(LPSTREAM);
+    HRESULT CoDisconnectObject(LPUNKNOWN, DWORD);
+    HRESULT CoLockObjectExternal(LPUNKNOWN, BOOL, BOOL);
+    HRESULT CoGetStandardMarshal(REFIID, LPUNKNOWN, DWORD, PVOID, DWORD, LPMARSHAL*);
+    HRESULT CoGetStdMarshalEx(LPUNKNOWN, DWORD, LPUNKNOWN*);
+    BOOL CoIsHandlerConnected(LPUNKNOWN);
+    BOOL CoHasStrongExternalConnections(LPUNKNOWN);
+    HRESULT CoMarshalInterThreadInterfaceInStream(REFIID, LPUNKNOWN, LPSTREAM*);
+    HRESULT CoGetInterfaceAndReleaseStream(LPSTREAM, REFIID, PVOID*);
+    HRESULT CoCreateFreeThreadedMarshaler(LPUNKNOWN, LPUNKNOWN*);
+    HINSTANCE CoLoadLibrary(LPOLESTR, BOOL);
+    void CoFreeLibrary(HINSTANCE);
+    void CoFreeAllLibraries();
+    void CoFreeUnusedLibraries();
+    HRESULT CoCreateInstance(REFCLSID, LPUNKNOWN, DWORD, REFIID, PVOID*);
+    HRESULT CoCreateInstanceEx(REFCLSID, IUnknown, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
+    HRESULT StringFromCLSID(REFCLSID, LPOLESTR*);
+    HRESULT CLSIDFromString(LPOLESTR, LPCLSID);
+    HRESULT StringFromIID(REFIID, LPOLESTR*);
+    HRESULT IIDFromString(LPOLESTR, LPIID);
+    BOOL CoIsOle1Class(REFCLSID);
+    HRESULT ProgIDFromCLSID(REFCLSID, LPOLESTR*);
+    HRESULT CLSIDFromProgID(LPCOLESTR, LPCLSID);
+    int StringFromGUID2(REFGUID, LPOLESTR, int);
+    HRESULT CoCreateGuid(GUID*);
+    BOOL CoFileTimeToDosDateTime(FILETIME*, LPWORD, LPWORD);
+    BOOL CoDosDateTimeToFileTime(WORD, WORD, FILETIME*);
+    HRESULT CoFileTimeNow(FILETIME*);
+    HRESULT CoRegisterMessageFilter(LPMESSAGEFILTER, LPMESSAGEFILTER*);
+    HRESULT CoGetTreatAsClass(REFCLSID, LPCLSID);
+    HRESULT CoTreatAsClass(REFCLSID, REFCLSID);
+    HRESULT DllGetClassObject(REFCLSID, REFIID, PVOID*);
+    HRESULT DllCanUnloadNow();
+    PVOID CoTaskMemAlloc(ULONG);
+    PVOID CoTaskMemRealloc(PVOID, ULONG);
+    void CoTaskMemFree(PVOID);
+    HRESULT CreateDataAdviseHolder(LPDATAADVISEHOLDER*);
+    HRESULT CreateDataCache(LPUNKNOWN, REFCLSID, REFIID, PVOID*);
+    HRESULT StgCreateDocfile(const(OLECHAR)*, DWORD, DWORD, IStorage*);
+    HRESULT StgCreateDocfileOnILockBytes(ILockBytes, DWORD, DWORD, IStorage*);
+    HRESULT StgOpenStorage(const(OLECHAR)*, IStorage, DWORD, SNB, DWORD, IStorage*);
+    HRESULT StgOpenStorageOnILockBytes(ILockBytes, IStorage, DWORD, SNB, DWORD, IStorage*);
+    HRESULT StgIsStorageFile(const(OLECHAR)*);
+    HRESULT StgIsStorageILockBytes(ILockBytes);
+    HRESULT StgSetTimes(OLECHAR *, FILETIME *, FILETIME *, FILETIME *);
+    HRESULT StgCreateStorageEx(const(WCHAR)*, DWORD, DWORD, DWORD, STGOPTIONS*, void*, REFIID, void**);
+    HRESULT StgOpenStorageEx(const(WCHAR)*, DWORD, DWORD, DWORD, STGOPTIONS*, void*, REFIID, void**);
+    HRESULT BindMoniker(LPMONIKER, DWORD, REFIID, PVOID*);
+    HRESULT CoGetObject(LPCWSTR, BIND_OPTS*, REFIID, void**);
+    HRESULT MkParseDisplayName(LPBC, LPCOLESTR, ULONG*, LPMONIKER*);
+    HRESULT MonikerRelativePathTo(LPMONIKER, LPMONIKER, LPMONIKER*, BOOL);
+    HRESULT MonikerCommonPrefixWith(LPMONIKER, LPMONIKER, LPMONIKER*);
+    HRESULT CreateBindCtx(DWORD, LPBC*);
+    HRESULT CreateGenericComposite(LPMONIKER, LPMONIKER, LPMONIKER*);
+    HRESULT GetClassFile (LPCOLESTR, CLSID*);
+    HRESULT CreateFileMoniker(LPCOLESTR, LPMONIKER*);
+    HRESULT CreateItemMoniker(LPCOLESTR, LPCOLESTR, LPMONIKER*);
+    HRESULT CreateAntiMoniker(LPMONIKER*);
+    HRESULT CreatePointerMoniker(LPUNKNOWN, LPMONIKER*);
+    HRESULT GetRunningObjectTable(DWORD, LPRUNNINGOBJECTTABLE*);
+    HRESULT CoInitializeSecurity(PSECURITY_DESCRIPTOR, LONG, SOLE_AUTHENTICATION_SERVICE*, void*, DWORD, DWORD, void*, DWORD, void*);
+    HRESULT CoGetCallContext(REFIID, void**);
+    HRESULT CoQueryProxyBlanket(IUnknown*, DWORD*, DWORD*, OLECHAR**, DWORD*, DWORD*, RPC_AUTH_IDENTITY_HANDLE*, DWORD*);
+    HRESULT CoSetProxyBlanket(IUnknown*, DWORD, DWORD, OLECHAR*, DWORD, DWORD, RPC_AUTH_IDENTITY_HANDLE, DWORD);
+    HRESULT CoCopyProxy(IUnknown*, IUnknown**);
+    HRESULT CoQueryClientBlanket(DWORD*, DWORD*, OLECHAR**, DWORD*, DWORD*, RPC_AUTHZ_HANDLE*, DWORD*);
+    HRESULT CoImpersonateClient();
+    HRESULT CoRevertToSelf();
+    HRESULT CoQueryAuthenticationServices(DWORD*, SOLE_AUTHENTICATION_SERVICE**);
+    HRESULT CoSwitchCallContext(IUnknown*, IUnknown**);
+    HRESULT CoGetInstanceFromFile(COSERVERINFO*, CLSID*, IUnknown*, DWORD, DWORD, OLECHAR*, DWORD, MULTI_QI*);
+    HRESULT CoGetInstanceFromIStorage(COSERVERINFO*, CLSID*, IUnknown*, DWORD, IStorage*, DWORD, MULTI_QI*);
+    ULONG CoAddRefServerProcess();
+    ULONG CoReleaseServerProcess();
+    HRESULT CoResumeClassObjects();
+    HRESULT CoSuspendClassObjects();
+    HRESULT CoGetPSClsid(REFIID, CLSID*);
+    HRESULT CoRegisterPSClsid(REFIID, REFCLSID);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/objfwd.d b/libphobos/libdruntime/core/sys/windows/objfwd.d
new file mode 100644
index 00000000000..70a2a1045f3
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/objfwd.d
@@ -0,0 +1,103 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_objfwd.d)
+ */
+module core.sys.windows.objfwd;
+version (Windows):
+
+private import core.sys.windows.objidl;
+
+/+
+// Forward declararions are not necessary in D.
+extern(Windows) {
+    interface IMoniker;
+    interface IStream;
+    interface IMarshal;
+    interface IMalloc;
+    interface IMallocSpy;
+    interface IMessageFilter;
+    interface IPersist;
+    interface IPersistStream;
+    interface IRunningObjectTable;
+    interface IBindCtx;
+    interface IAdviseSink;
+    interface IAdviseSink2;
+    interface IDataObject;
+    interface IDataAdviseHolder;
+
+    interface IEnumMoniker;
+    interface IEnumFORMATETC;
+    interface IEnumSTATDATA;
+    interface IEnumSTATSTG;
+    interface IEnumSTATPROPSTG;
+    interface IEnumString;
+    interface IEnumUnknown;
+    interface IStorage;
+    interface IPersistStorage;
+    interface ILockBytes;
+    interface IStdMarshalInfo;
+    interface IExternalConnection;
+    interface IRunnableObject;
+    interface IROTData;
+    interface IPersistFile;
+    interface IRootStorage;
+    interface IPropertyStorage;
+    interface IEnumSTATPROPSETSTG;
+    interface IPropertySetStorage;
+    interface IClientSecurity;
+    interface IServerSecurity;
+    interface IClassActivator;
+    interface IFillLockBytes;
+    interface IProgressNotify;
+    interface ILayoutStorage;
+    interface IRpcProxyBuffer;
+    interface IRpcChannelBuffer;
+    interface IRpcStubBuffer;
+}
++/
+alias IMoniker LPMONIKER;
+alias IStream LPSTREAM;
+alias IMarshal LPMARSHAL;
+alias IMalloc LPMALLOC;
+alias IMallocSpy LPMALLOCSPY;
+alias IMessageFilter LPMESSAGEFILTER;
+alias IPersist LPPERSIST;
+alias IPersistStream LPPERSISTSTREAM;
+alias IRunningObjectTable LPRUNNINGOBJECTTABLE;
+alias IBindCtx LPBINDCTX, LPBC;
+alias IAdviseSink LPADVISESINK;
+alias IAdviseSink2 LPADVISESINK2;
+alias IDataObject LPDATAOBJECT;
+alias IDataAdviseHolder LPDATAADVISEHOLDER;
+alias IEnumMoniker LPENUMMONIKER;
+alias IEnumFORMATETC LPENUMFORMATETC;
+alias IEnumSTATDATA LPENUMSTATDATA;
+alias IEnumSTATSTG LPENUMSTATSTG;
+alias IEnumSTATPROPSTG LPENUMSTATPROPSTG;
+alias IEnumString LPENUMSTRING;
+alias IEnumUnknown LPENUMUNKNOWN;
+alias IStorage LPSTORAGE;
+alias IPersistStorage LPPERSISTSTORAGE;
+alias ILockBytes LPLOCKBYTES;
+alias IStdMarshalInfo LPSTDMARSHALINFO;
+alias IExternalConnection LPEXTERNALCONNECTION;
+alias IRunnableObject LPRUNNABLEOBJECT;
+alias IROTData LPROTDATA;
+alias IPersistFile LPPERSISTFILE;
+alias IRootStorage LPROOTSTORAGE;
+alias IRpcChannelBuffer LPRPCCHANNELBUFFER;
+alias IRpcProxyBuffer LPRPCPROXYBUFFER;
+alias IRpcStubBuffer LPRPCSTUBBUFFER;
+alias IPropertyStorage LPPROPERTYSTORAGE;
+alias IEnumSTATPROPSETSTG LPENUMSTATPROPSETSTG;
+alias IPropertySetStorage LPPROPERTYSETSTORAGE;
+alias IClientSecurity LPCLIENTSECURITY;
+alias IServerSecurity LPSERVERSECURITY;
+alias IClassActivator LPCLASSACTIVATOR;
+alias IFillLockBytes LPFILLLOCKBYTES;
+alias IProgressNotify LPPROGRESSNOTIFY;
+alias ILayoutStorage LPLAYOUTSTORAGE;
diff --git a/libphobos/libdruntime/core/sys/windows/objidl.d b/libphobos/libdruntime/core/sys/windows/objidl.d
new file mode 100644
index 00000000000..73b201bb85f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/objidl.d
@@ -0,0 +1,1307 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_objidl.d)
+ */
+// TODO (Don):
+// # why is "alias IPSFactoryBuffer* LPPSFACTORYBUFFER;" in this file,
+// rather than in objfwd ?
+// # do we need the proxies that are defined in this file?
+module core.sys.windows.objidl;
+version (Windows):
+
+import core.sys.windows.unknwn;
+import core.sys.windows.objfwd;
+private import core.sys.windows.windef;
+private import core.sys.windows.basetyps;
+private import core.sys.windows.oleidl;
+private import core.sys.windows.wtypes;
+private import core.sys.windows.winbase; // for FILETIME
+private import core.sys.windows.rpcdce;
+
+struct  STATSTG {
+    LPOLESTR pwcsName;
+    DWORD type;
+    ULARGE_INTEGER cbSize;
+    FILETIME mtime;
+    FILETIME ctime;
+    FILETIME atime;
+    DWORD grfMode;
+    DWORD grfLocksSupported;
+    CLSID clsid;
+    DWORD grfStateBits;
+    DWORD reserved;
+}
+
+enum STGTY {
+    STGTY_STORAGE = 1,
+    STGTY_STREAM,
+    STGTY_LOCKBYTES,
+    STGTY_PROPERTY
+}
+
+enum STREAM_SEEK {
+    STREAM_SEEK_SET,
+    STREAM_SEEK_CUR,
+    STREAM_SEEK_END
+}
+
+struct INTERFACEINFO {
+    LPUNKNOWN pUnk;
+    IID iid;
+    WORD wMethod;
+}
+alias INTERFACEINFO* LPINTERFACEINFO;
+
+enum CALLTYPE {
+    CALLTYPE_TOPLEVEL = 1,
+    CALLTYPE_NESTED,
+    CALLTYPE_ASYNC,
+    CALLTYPE_TOPLEVEL_CALLPENDING,
+    CALLTYPE_ASYNC_CALLPENDING
+}
+
+enum PENDINGTYPE {
+    PENDINGTYPE_TOPLEVEL = 1,
+    PENDINGTYPE_NESTED
+}
+
+enum PENDINGMSG {
+    PENDINGMSG_CANCELCALL = 0,
+    PENDINGMSG_WAITNOPROCESS,
+    PENDINGMSG_WAITDEFPROCESS
+}
+
+alias OLECHAR** SNB;
+
+enum DATADIR {
+    DATADIR_GET = 1,
+    DATADIR_SET
+}
+alias WORD CLIPFORMAT;
+alias CLIPFORMAT* LPCLIPFORMAT;
+
+struct DVTARGETDEVICE {
+    DWORD tdSize;
+    WORD tdDriverNameOffset;
+    WORD tdDeviceNameOffset;
+    WORD tdPortNameOffset;
+    WORD tdExtDevmodeOffset;
+    BYTE[1] tdData;
+}
+
+struct FORMATETC {
+    CLIPFORMAT cfFormat;
+    DVTARGETDEVICE* ptd;
+    DWORD dwAspect;
+    LONG lindex;
+    DWORD tymed;
+}
+alias FORMATETC* LPFORMATETC;
+
+struct RemSTGMEDIUM {
+    DWORD tymed;
+    DWORD dwHandleType;
+    ULONG pData;
+    uint pUnkForRelease;
+    uint cbData;
+    BYTE[1] data;
+}
+
+struct HLITEM {
+    ULONG uHLID;
+    LPWSTR pwzFriendlyName;
+}
+
+struct STATDATA {
+    FORMATETC formatetc;
+    DWORD grfAdvf;
+    IAdviseSink pAdvSink;
+    DWORD dwConnection;
+}
+
+struct STATPROPSETSTG {
+    FMTID fmtid;
+    CLSID clsid;
+    DWORD grfFlags;
+    FILETIME mtime;
+    FILETIME ctime;
+    FILETIME atime;
+}
+
+enum EXTCONN {
+    EXTCONN_STRONG   = 1,
+    EXTCONN_WEAK     = 2,
+    EXTCONN_CALLABLE = 4
+}
+
+struct MULTI_QI {
+const(IID)* pIID;
+    IUnknown    pItf;
+    HRESULT     hr;
+}
+
+struct AUTH_IDENTITY {
+    USHORT* User;
+    ULONG UserLength;
+    USHORT* Domain;
+    ULONG DomainLength;
+    USHORT* Password;
+    ULONG PasswordLength;
+    ULONG Flags;
+}
+
+struct COAUTHINFO {
+    DWORD dwAuthnSvc;
+    DWORD dwAuthzSvc;
+    LPWSTR pwszServerPrincName;
+    DWORD dwAuthnLevel;
+    DWORD dwImpersonationLevel;
+    AUTH_IDENTITY* pAuthIdentityData;
+    DWORD dwCapabilities;
+}
+
+struct  COSERVERINFO {
+    DWORD dwReserved1;
+    LPWSTR pwszName;
+    COAUTHINFO* pAuthInfo;
+    DWORD dwReserved2;
+}
+
+struct BIND_OPTS {
+    DWORD cbStruct;
+    DWORD grfFlags;
+    DWORD grfMode;
+    DWORD dwTickCountDeadline;
+}
+alias BIND_OPTS* LPBIND_OPTS;
+
+struct BIND_OPTS2 {
+    DWORD cbStruct;
+    DWORD grfFlags;
+    DWORD grfMode;
+    DWORD dwTickCountDeadline;
+    DWORD dwTrackFlags;
+    DWORD dwClassContext;
+    LCID locale;
+    COSERVERINFO* pServerInfo;
+}
+alias BIND_OPTS2* LPBIND_OPTS2;
+
+enum BIND_FLAGS {
+    BIND_MAYBOTHERUSER = 1,
+    BIND_JUSTTESTEXISTENCE
+}
+
+struct STGMEDIUM {
+    DWORD tymed;
+    union {
+        HBITMAP hBitmap;
+        PVOID hMetaFilePict;
+        HENHMETAFILE hEnhMetaFile;
+        HGLOBAL hGlobal;
+        LPWSTR lpszFileName;
+        LPSTREAM pstm;
+        LPSTORAGE pstg;
+    }
+    LPUNKNOWN pUnkForRelease;
+}
+alias STGMEDIUM* LPSTGMEDIUM;
+
+enum LOCKTYPE {
+    LOCK_WRITE     = 1,
+    LOCK_EXCLUSIVE = 2,
+    LOCK_ONLYONCE  = 4
+}
+
+alias uint RPCOLEDATAREP;
+
+struct  RPCOLEMESSAGE {
+    PVOID reserved1;
+    RPCOLEDATAREP dataRepresentation;
+    PVOID Buffer;
+    ULONG cbBuffer;
+    ULONG iMethod;
+    PVOID[5] reserved2;
+    ULONG rpcFlags;
+}
+alias RPCOLEMESSAGE* PRPCOLEMESSAGE;
+
+enum MKSYS {
+    MKSYS_NONE,
+    MKSYS_GENERICCOMPOSITE,
+    MKSYS_FILEMONIKER,
+    MKSYS_ANTIMONIKER,
+    MKSYS_ITEMMONIKER,
+    MKSYS_POINTERMONIKER
+}
+
+enum MKREDUCE {
+    MKRREDUCE_ALL,
+    MKRREDUCE_ONE         = 196608,
+    MKRREDUCE_TOUSER      = 131072,
+    MKRREDUCE_THROUGHUSER = 65536
+}
+
+struct RemSNB {
+    uint ulCntStr;
+    uint ulCntChar;
+    OLECHAR[1] rgString;
+}
+
+enum ADVF {
+    ADVF_NODATA            = 1,
+    ADVF_PRIMEFIRST        = 2,
+    ADVF_ONLYONCE          = 4,
+    ADVFCACHE_NOHANDLER    = 8,
+    ADVFCACHE_FORCEBUILTIN = 16,
+    ADVFCACHE_ONSAVE       = 32,
+    ADVF_DATAONSTOP        = 64
+}
+
+enum TYMED {
+    TYMED_HGLOBAL  = 1,
+    TYMED_FILE     = 2,
+    TYMED_ISTREAM  = 4,
+    TYMED_ISTORAGE = 8,
+    TYMED_GDI      = 16,
+    TYMED_MFPICT   = 32,
+    TYMED_ENHMF    = 64,
+    TYMED_NULL     = 0
+}
+
+enum SERVERCALL {
+    SERVERCALL_ISHANDLED,
+    SERVERCALL_REJECTED,
+    SERVERCALL_RETRYLATER
+}
+
+struct CAUB {
+    ULONG cElems;
+    ubyte* pElems;
+}
+
+struct CAI {
+    ULONG cElems;
+    short* pElems;
+}
+
+struct CAUI {
+    ULONG cElems;
+    USHORT* pElems;
+}
+
+struct CAL {
+    ULONG cElems;
+    int* pElems;
+}
+
+struct CAUL {
+    ULONG cElems;
+    ULONG* pElems;
+}
+
+struct CAFLT {
+    ULONG cElems;
+    float* pElems;
+}
+
+struct CADBL {
+    ULONG cElems;
+    double* pElems;
+}
+
+struct CACY {
+    ULONG cElems;
+    CY* pElems;
+}
+
+struct CADATE {
+    ULONG cElems;
+    DATE* pElems;
+}
+
+struct CABSTR {
+    ULONG cElems;
+    BSTR*  pElems;
+}
+
+struct CABSTRBLOB {
+    ULONG cElems;
+    BSTRBLOB* pElems;
+}
+
+struct CABOOL {
+    ULONG cElems;
+    VARIANT_BOOL* pElems;
+}
+
+struct CASCODE {
+    ULONG cElems;
+    SCODE* pElems;
+}
+
+struct CAH {
+    ULONG cElems;
+    LARGE_INTEGER* pElems;
+}
+
+struct CAUH {
+    ULONG cElems;
+    ULARGE_INTEGER* pElems;
+}
+
+struct CALPSTR {
+    ULONG cElems;
+    LPSTR* pElems;
+}
+
+struct CALPWSTR {
+    ULONG cElems;
+    LPWSTR* pElems;
+}
+
+struct CAFILETIME {
+    ULONG cElems;
+    FILETIME* pElems;
+}
+
+struct CACLIPDATA {
+    ULONG cElems;
+    CLIPDATA* pElems;
+}
+
+struct CACLSID {
+    ULONG cElems;
+    CLSID* pElems;
+}
+alias PROPVARIANT* LPPROPVARIANT;
+
+struct CAPROPVARIANT {
+    ULONG cElems;
+    LPPROPVARIANT pElems;
+}
+
+struct PROPVARIANT {
+    VARTYPE vt;
+    WORD wReserved1;
+    WORD wReserved2;
+    WORD wReserved3;
+    union {
+        CHAR cVal;
+        UCHAR bVal;
+        short iVal;
+        USHORT uiVal;
+        VARIANT_BOOL boolVal;
+        int lVal;
+        ULONG ulVal;
+        float fltVal;
+        SCODE scode;
+        LARGE_INTEGER hVal;
+        ULARGE_INTEGER uhVal;
+        double dblVal;
+        CY cyVal;
+        DATE date;
+        FILETIME filetime;
+        CLSID* puuid;
+        BLOB blob;
+        CLIPDATA* pclipdata;
+        LPSTREAM pStream;
+        LPSTORAGE pStorage;
+        BSTR bstrVal;
+        BSTRBLOB bstrblobVal;
+        LPSTR pszVal;
+        LPWSTR pwszVal;
+        CAUB caub;
+        CAI cai;
+        CAUI caui;
+        CABOOL cabool;
+        CAL cal;
+        CAUL caul;
+        CAFLT caflt;
+        CASCODE cascode;
+        CAH cah;
+        CAUH cauh;
+        CADBL cadbl;
+        CACY cacy;
+        CADATE cadate;
+        CAFILETIME cafiletime;
+        CACLSID cauuid;
+        CACLIPDATA caclipdata;
+        CABSTR cabstr;
+        CABSTRBLOB cabstrblob;
+        CALPSTR calpstr;
+        CALPWSTR calpwstr;
+        CAPROPVARIANT capropvar;
+    }
+}
+
+struct PROPSPEC {
+    ULONG ulKind;
+    union {
+        PROPID propid;
+        LPOLESTR lpwstr;
+    }
+}
+
+struct  STATPROPSTG {
+    LPOLESTR lpwstrName;
+    PROPID propid;
+    VARTYPE vt;
+}
+
+enum PROPSETFLAG {
+    PROPSETFLAG_DEFAULT,
+    PROPSETFLAG_NONSIMPLE,
+    PROPSETFLAG_ANSI,
+    PROPSETFLAG_UNBUFFERED = 4
+}
+
+struct STORAGELAYOUT {
+    DWORD LayoutType;
+    OLECHAR* pwcsElementName;
+    LARGE_INTEGER cOffset;
+    LARGE_INTEGER cBytes;
+}
+
+struct SOLE_AUTHENTICATION_SERVICE {
+    DWORD dwAuthnSvc;
+    DWORD dwAuthzSvc;
+    OLECHAR* pPrincipalName;
+    HRESULT hr;
+}
+
+enum OLECHAR* COLE_DEFAULT_PRINCIPAL = cast ( OLECHAR* )(-1);
+
+enum EOLE_AUTHENTICATION_CAPABILITIES {
+    EOAC_NONE              = 0,
+    EOAC_MUTUAL_AUTH       = 0x1,
+    EOAC_SECURE_REFS       = 0x2,
+    EOAC_ACCESS_CONTROL    = 0x4,
+    EOAC_APPID             = 0x8,
+    EOAC_DYNAMIC           = 0x10,
+    EOAC_STATIC_CLOAKING   = 0x20,
+    EOAC_DYNAMIC_CLOAKING  = 0x40,
+    EOAC_ANY_AUTHORITY     = 0x80,
+    EOAC_MAKE_FULLSIC      = 0x100,
+    EOAC_REQUIRE_FULLSIC   = 0x200,
+    EOAC_AUTO_IMPERSONATE  = 0x400,
+    EOAC_DEFAULT           = 0x800,
+    EOAC_DISABLE_AAA       = 0x1000,
+    EOAC_NO_CUSTOM_MARSHAL = 0x2000
+}
+
+struct SOLE_AUTHENTICATION_INFO {
+    DWORD dwAuthnSvc;
+    DWORD dwAuthzSvc;
+    void* pAuthInfo;
+}
+
+enum void* COLE_DEFAULT_AUTHINFO = cast( void* )(-1 );
+
+struct SOLE_AUTHENTICATION_LIST {
+    DWORD cAuthInfo;
+    SOLE_AUTHENTICATION_INFO* aAuthInfo;
+}
+
+interface IEnumFORMATETC : IUnknown {
+      HRESULT Next(ULONG, FORMATETC*, ULONG*);
+      HRESULT Skip(ULONG);
+      HRESULT Reset();
+      HRESULT Clone(IEnumFORMATETC*);
+}
+
+interface IEnumHLITEM : IUnknown {
+      HRESULT Next(ULONG, HLITEM*, ULONG*);
+      HRESULT Skip(ULONG);
+      HRESULT Reset();
+      HRESULT Clone(IEnumHLITEM*);
+}
+
+interface IEnumSTATDATA : IUnknown {
+      HRESULT Next(ULONG, STATDATA*, ULONG*);
+      HRESULT Skip(ULONG);
+      HRESULT Reset();
+      HRESULT Clone(IEnumSTATDATA*);
+}
+
+interface IEnumSTATPROPSETSTG : IUnknown {
+      HRESULT Next(ULONG, STATPROPSETSTG*, ULONG*);
+      HRESULT Skip(ULONG);
+      HRESULT Reset();
+      HRESULT Clone(IEnumSTATPROPSETSTG*);
+}
+
+interface IEnumSTATPROPSTG : IUnknown {
+      HRESULT Next(ULONG, STATPROPSTG*, ULONG*);
+      HRESULT Skip(ULONG);
+      HRESULT Reset();
+      HRESULT Clone(IEnumSTATPROPSTG*);
+}
+
+interface IEnumSTATSTG : IUnknown {
+      HRESULT Next(ULONG, STATSTG*, ULONG*);
+      HRESULT Skip(ULONG);
+      HRESULT Reset();
+      HRESULT Clone(IEnumSTATSTG*);
+}
+
+interface IEnumString : IUnknown {
+      HRESULT Next(ULONG, LPOLESTR*, ULONG*);
+      HRESULT Skip(ULONG);
+      HRESULT Reset();
+      HRESULT Clone(IEnumString*);
+}
+
+interface IEnumMoniker : IUnknown {
+      HRESULT Next(ULONG, IMoniker*, ULONG*);
+      HRESULT Skip(ULONG);
+      HRESULT Reset();
+      HRESULT Clone(IEnumMoniker*);
+}
+
+
+interface IEnumUnknown : IUnknown {
+      HRESULT Next(ULONG, IUnknown*, ULONG*);
+      HRESULT Skip(ULONG);
+      HRESULT Reset();
+      HRESULT Clone(IEnumUnknown*);
+}
+
+interface ISequentialStream : IUnknown {
+    HRESULT Read(void*, ULONG, ULONG*);
+    HRESULT Write(void* , ULONG, ULONG*);
+}
+
+interface IStream : ISequentialStream {
+    HRESULT Seek(LARGE_INTEGER, DWORD, ULARGE_INTEGER*);
+    HRESULT SetSize(ULARGE_INTEGER);
+    HRESULT CopyTo(IStream, ULARGE_INTEGER, ULARGE_INTEGER*, ULARGE_INTEGER*);
+    HRESULT Commit(DWORD);
+    HRESULT Revert();
+    HRESULT LockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD);
+    HRESULT UnlockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD);
+    HRESULT Stat(STATSTG*, DWORD);
+    HRESULT Clone(LPSTREAM*);
+}
+
+interface IMarshal : IUnknown {
+    HRESULT GetUnmarshalClass(REFIID, PVOID, DWORD, PVOID, DWORD, CLSID*);
+    HRESULT GetMarshalSizeMax(REFIID, PVOID, DWORD, PVOID, PDWORD, ULONG*);
+    HRESULT MarshalInterface(IStream, REFIID, PVOID, DWORD, PVOID, DWORD);
+    HRESULT UnmarshalInterface(IStream, REFIID, void**);
+    HRESULT ReleaseMarshalData(IStream);
+    HRESULT DisconnectObject(DWORD);
+}
+
+interface IStdMarshalInfo : IUnknown {
+    HRESULT GetClassForHandler(DWORD, PVOID, CLSID*);
+}
+
+interface IMalloc : IUnknown {
+    void* Alloc(ULONG);
+    void* Realloc(void*, ULONG);
+    void Free(void*);
+    ULONG GetSize(void*);
+    int DidAlloc(void*);
+    void HeapMinimize();
+}
+
+interface IMallocSpy : IUnknown {
+    ULONG PreAlloc(ULONG);
+    void* PostAlloc(void*);
+    void* PreFree(void*, BOOL);
+    void PostFree(BOOL);
+    ULONG PreRealloc(void*, ULONG, void**, BOOL);
+    void* PostRealloc(void*, BOOL);
+    void* PreGetSize(void*, BOOL);
+    ULONG PostGetSize(ULONG, BOOL);
+    void* PreDidAlloc(void*, BOOL);
+    int PostDidAlloc(void*, BOOL, int);
+    void PreHeapMinimize();
+    void PostHeapMinimize();
+}
+
+interface IMessageFilter : IUnknown {
+    DWORD HandleInComingCall(DWORD, HTASK, DWORD, LPINTERFACEINFO);
+    DWORD RetryRejectedCall(HTASK, DWORD, DWORD);
+    DWORD MessagePending(HTASK, DWORD, DWORD);
+}
+
+
+interface IPersist : IUnknown {
+    HRESULT GetClassID(CLSID*);
+}
+
+interface IPersistStream : IPersist {
+    HRESULT IsDirty();
+    HRESULT Load(IStream);
+    HRESULT Save(IStream, BOOL);
+    HRESULT GetSizeMax(PULARGE_INTEGER);
+}
+
+interface IRunningObjectTable : IUnknown {
+    HRESULT Register(DWORD, LPUNKNOWN, LPMONIKER, PDWORD);
+    HRESULT Revoke(DWORD);
+    HRESULT IsRunning(LPMONIKER);
+    HRESULT GetObject(LPMONIKER, LPUNKNOWN*);
+    HRESULT NoteChangeTime(DWORD, LPFILETIME);
+    HRESULT GetTimeOfLastChange(LPMONIKER, LPFILETIME);
+    HRESULT EnumRunning(IEnumMoniker*);
+}
+
+interface IBindCtx : IUnknown {
+    HRESULT RegisterObjectBound(LPUNKNOWN);
+    HRESULT RevokeObjectBound(LPUNKNOWN);
+    HRESULT ReleaseBoundObjects();
+    HRESULT SetBindOptions(LPBIND_OPTS);
+    HRESULT GetBindOptions(LPBIND_OPTS);
+    HRESULT GetRunningObjectTable(IRunningObjectTable*);
+    HRESULT RegisterObjectParam(LPOLESTR, IUnknown);
+    HRESULT GetObjectParam(LPOLESTR, IUnknown*);
+    HRESULT EnumObjectParam(IEnumString*);
+    HRESULT RevokeObjectParam(LPOLESTR);
+}
+
+interface IMoniker: IPersistStream {
+    HRESULT BindToObject(IBindCtx, IMoniker, REFIID, PVOID*);
+    HRESULT BindToStorage(IBindCtx, IMoniker, REFIID, PVOID*);
+    HRESULT Reduce(IBindCtx, DWORD, IMoniker*, IMoniker*);
+    HRESULT ComposeWith(IMoniker, BOOL, IMoniker*);
+    HRESULT Enum(BOOL, IEnumMoniker*);
+    HRESULT IsEqual(IMoniker);
+    HRESULT Hash(PDWORD);
+    HRESULT IsRunning(IBindCtx, IMoniker, IMoniker);
+    HRESULT GetTimeOfLastChange(IBindCtx, IMoniker, LPFILETIME);
+    HRESULT Inverse(IMoniker*);
+    HRESULT CommonPrefixWith(IMoniker, IMoniker*);
+    HRESULT RelativePathTo(IMoniker, IMoniker*);
+    HRESULT GetDisplayName(IBindCtx, IMoniker, LPOLESTR*);
+    HRESULT ParseDisplayName(IBindCtx, IMoniker, LPOLESTR, ULONG*, IMoniker*);
+    HRESULT IsSystemMoniker(PDWORD);
+}
+
+interface IPersistStorage : IPersist
+{
+    HRESULT IsDirty();
+    HRESULT InitNew(LPSTORAGE);
+    HRESULT Load(LPSTORAGE);
+    HRESULT Save(LPSTORAGE, BOOL);
+    HRESULT SaveCompleted(LPSTORAGE);
+    HRESULT HandsOffStorage();
+}
+
+interface IPersistFile : IPersist
+{
+    HRESULT IsDirty();
+    HRESULT Load(LPCOLESTR, DWORD);
+    HRESULT Save(LPCOLESTR, BOOL);
+    HRESULT SaveCompleted(LPCOLESTR);
+    HRESULT GetCurFile(LPOLESTR*);
+}
+
+interface IAdviseSink : IUnknown {
+    HRESULT QueryInterface(REFIID, PVOID*);
+    ULONG AddRef();
+    ULONG Release();
+    void OnDataChange(FORMATETC*, STGMEDIUM*);
+    void OnViewChange(DWORD, LONG);
+    void OnRename(IMoniker);
+    void OnSave();
+    void OnClose();
+}
+
+interface IAdviseSink2 : IAdviseSink
+{
+    void OnLinkSrcChange(IMoniker);
+}
+
+interface IDataObject : IUnknown {
+    HRESULT GetData(FORMATETC*, STGMEDIUM*);
+    HRESULT GetDataHere(FORMATETC*, STGMEDIUM*);
+    HRESULT QueryGetData(FORMATETC*);
+    HRESULT GetCanonicalFormatEtc(FORMATETC*, FORMATETC*);
+    HRESULT SetData(FORMATETC*, STGMEDIUM*, BOOL);
+    HRESULT EnumFormatEtc(DWORD, IEnumFORMATETC*);
+    HRESULT DAdvise(FORMATETC*, DWORD, IAdviseSink, PDWORD);
+    HRESULT DUnadvise(DWORD);
+    HRESULT EnumDAdvise(IEnumSTATDATA*);
+}
+
+interface IDataAdviseHolder : IUnknown {
+    HRESULT Advise(IDataObject, FORMATETC*, DWORD, IAdviseSink, PDWORD);
+    HRESULT Unadvise(DWORD);
+    HRESULT EnumAdvise(IEnumSTATDATA*);
+    HRESULT SendOnDataChange(IDataObject, DWORD, DWORD);
+}
+
+interface IStorage : IUnknown {
+    HRESULT CreateStream(LPCWSTR, DWORD, DWORD, DWORD, IStream);
+    HRESULT OpenStream(LPCWSTR, PVOID, DWORD, DWORD, IStream);
+    HRESULT CreateStorage(LPCWSTR, DWORD, DWORD, DWORD, IStorage);
+    HRESULT OpenStorage(LPCWSTR, IStorage, DWORD, SNB, DWORD, IStorage);
+    HRESULT CopyTo(DWORD, IID* , SNB, IStorage);
+    HRESULT MoveElementTo(LPCWSTR, IStorage, LPCWSTR, DWORD);
+    HRESULT Commit(DWORD);
+    HRESULT Revert();
+    HRESULT EnumElements(DWORD, PVOID, DWORD, IEnumSTATSTG);
+    HRESULT DestroyElement(LPCWSTR);
+    HRESULT RenameElement(LPCWSTR, LPCWSTR);
+    HRESULT SetElementTimes(LPCWSTR, FILETIME* , FILETIME* , FILETIME* );
+    HRESULT SetClass(REFCLSID);
+    HRESULT SetStateBits(DWORD, DWORD);
+    HRESULT Stat(STATSTG*, DWORD);
+}
+
+// FIXME: GetClassID from IPersist not there - what to do about it?
+interface IRootStorage : IPersist {
+    HRESULT QueryInterface(REFIID, PVOID*);
+    ULONG AddRef();
+    ULONG Release();
+    HRESULT SwitchToFile(LPOLESTR);
+}
+
+interface IRpcChannelBuffer : IUnknown {
+    HRESULT GetBuffer(RPCOLEMESSAGE*, REFIID);
+    HRESULT SendReceive(RPCOLEMESSAGE*, PULONG);
+    HRESULT FreeBuffer(RPCOLEMESSAGE*);
+    HRESULT GetDestCtx(PDWORD, PVOID*);
+    HRESULT IsConnected();
+}
+
+interface IRpcProxyBuffer : IUnknown {
+    HRESULT Connect(IRpcChannelBuffer);
+    void Disconnect();
+}
+
+interface IRpcStubBuffer : IUnknown {
+    HRESULT Connect(LPUNKNOWN);
+    void Disconnect();
+    HRESULT Invoke(RPCOLEMESSAGE*, LPRPCSTUBBUFFER);
+    LPRPCSTUBBUFFER IsIIDSupported(REFIID);
+    ULONG CountRefs();
+    HRESULT DebugServerQueryInterface(PVOID*);
+    HRESULT DebugServerRelease(PVOID);
+}
+
+interface IPSFactoryBuffer : IUnknown {
+    HRESULT CreateProxy(LPUNKNOWN, REFIID, LPRPCPROXYBUFFER*, PVOID*);
+    HRESULT CreateStub(REFIID, LPUNKNOWN, LPRPCSTUBBUFFER*);
+}
+alias IPSFactoryBuffer LPPSFACTORYBUFFER;
+
+interface ILockBytes : IUnknown {
+    HRESULT ReadAt(ULARGE_INTEGER, PVOID, ULONG, ULONG*);
+    HRESULT WriteAt(ULARGE_INTEGER, PCVOID, ULONG, ULONG*);
+    HRESULT Flush();
+    HRESULT SetSize(ULARGE_INTEGER);
+    HRESULT LockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD);
+    HRESULT UnlockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD);
+    HRESULT Stat(STATSTG*, DWORD);
+}
+
+interface IExternalConnection : IUnknown {
+    HRESULT AddConnection(DWORD, DWORD);
+    HRESULT ReleaseConnection(DWORD, DWORD, BOOL);
+}
+
+interface IRunnableObject : IUnknown {
+    HRESULT GetRunningClass(LPCLSID);
+    HRESULT Run(LPBC);
+    BOOL IsRunning();
+    HRESULT LockRunning(BOOL, BOOL);
+    HRESULT SetContainedObject(BOOL);
+}
+
+interface IROTData : IUnknown {
+    HRESULT GetComparisonData(PVOID, ULONG, PULONG);
+}
+
+interface IChannelHook : IUnknown {
+    void ClientGetSize(REFGUID, REFIID, PULONG);
+    void ClientFillBuffer(REFGUID, REFIID, PULONG, PVOID);
+    void ClientNotify(REFGUID, REFIID, ULONG, PVOID, DWORD, HRESULT);
+    void ServerNotify(REFGUID, REFIID, ULONG, PVOID, DWORD);
+    void ServerGetSize(REFGUID, REFIID, HRESULT, PULONG);
+    void ServerFillBuffer(REFGUID, REFIID, PULONG, PVOID, HRESULT);
+}
+
+interface IPropertyStorage : IUnknown {
+    HRESULT ReadMultiple(ULONG, PROPSPEC* , PROPVARIANT*);
+    HRESULT WriteMultiple(ULONG, PROPSPEC* , PROPVARIANT*, PROPID);
+    HRESULT DeleteMultiple(ULONG, PROPSPEC* );
+    HRESULT ReadPropertyNames(ULONG, PROPID* , LPWSTR*);
+    HRESULT WritePropertyNames(ULONG, PROPID* , LPWSTR* );
+    HRESULT DeletePropertyNames(ULONG, PROPID* );
+    HRESULT SetClass(REFCLSID);
+    HRESULT Commit(DWORD);
+    HRESULT Revert();
+    HRESULT Enum(IEnumSTATPROPSTG*);
+    HRESULT Stat(STATPROPSTG*);
+    HRESULT SetTimes(FILETIME* , FILETIME* , FILETIME* );
+}
+
+interface IPropertySetStorage : IUnknown {
+    HRESULT Create(REFFMTID, CLSID*, DWORD, DWORD, LPPROPERTYSTORAGE*);
+    HRESULT Open(REFFMTID, DWORD, LPPROPERTYSTORAGE*);
+    HRESULT Delete(REFFMTID);
+    HRESULT Enum(IEnumSTATPROPSETSTG*);
+}
+
+interface IClientSecurity : IUnknown {
+    HRESULT QueryBlanket(PVOID, PDWORD, PDWORD, OLECHAR**, PDWORD, PDWORD, RPC_AUTH_IDENTITY_HANDLE**, PDWORD*);
+    HRESULT SetBlanket(PVOID, DWORD, DWORD, LPWSTR, DWORD, DWORD, RPC_AUTH_IDENTITY_HANDLE*, DWORD);
+    HRESULT CopyProxy(LPUNKNOWN, LPUNKNOWN*);
+}
+
+interface IServerSecurity : IUnknown {
+    HRESULT QueryBlanket(PDWORD, PDWORD, OLECHAR**, PDWORD, PDWORD, RPC_AUTHZ_HANDLE*, PDWORD*);
+    HRESULT ImpersonateClient();
+    HRESULT RevertToSelf();
+    HRESULT IsImpersonating();
+}
+
+interface IClassActivator : IUnknown {
+    HRESULT GetClassObject(REFCLSID, DWORD, LCID, REFIID, PVOID*);
+}
+
+interface IFillLockBytes : IUnknown {
+    HRESULT FillAppend(void* , ULONG, PULONG);
+    HRESULT FillAt(ULARGE_INTEGER, void* , ULONG, PULONG);
+    HRESULT SetFillSize(ULARGE_INTEGER);
+    HRESULT Terminate(BOOL);
+}
+
+interface IProgressNotify : IUnknown {
+    HRESULT OnProgress(DWORD, DWORD, BOOL, BOOL);
+}
+
+interface ILayoutStorage : IUnknown {
+    HRESULT LayoutScript(STORAGELAYOUT*, DWORD, DWORD);
+    HRESULT BeginMonitor();
+    HRESULT EndMonitor();
+    HRESULT ReLayoutDocfile(OLECHAR*);
+}
+
+interface IGlobalInterfaceTable : IUnknown {
+    HRESULT RegisterInterfaceInGlobal(IUnknown, REFIID, DWORD*);
+    HRESULT RevokeInterfaceFromGlobal(DWORD);
+    HRESULT GetInterfaceFromGlobal(DWORD, REFIID, void**);
+}
+
+/+
+// These are probably unnecessary for D.
+extern (Windows) {
+HRESULT IMarshal_GetUnmarshalClass_Proxy(IMarshal, REFIID, void*, DWORD, void*, DWORD, CLSID*);
+void IMarshal_GetUnmarshalClass_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMarshal_GetMarshalSizeMax_Proxy(IMarshal, REFIID, void*, DWORD, void*, DWORD, DWORD*);
+void IMarshal_GetMarshalSizeMax_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMarshal_MarshalInterface_Proxy(IMarshal, IStream, REFIID, void*, DWORD, void*, DWORD);
+void IMarshal_MarshalInterface_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMarshal_UnmarshalInterface_Proxy(IMarshal, IStream, REFIID, void**);
+void IMarshal_UnmarshalInterface_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMarshal_ReleaseMarshalData_Proxy(IMarshal, IStream);
+void IMarshal_ReleaseMarshalData_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMarshal_DisconnectObject_Proxy(IMarshal, DWORD);
+void IMarshal_DisconnectObject_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void* IMalloc_Alloc_Proxy(IMalloc, ULONG);
+void IMalloc_Alloc_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void* IMalloc_Realloc_Proxy(IMalloc, void*, ULONG);
+void IMalloc_Realloc_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IMalloc_Free_Proxy(IMalloc, void*);
+void IMalloc_Free_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+ULONG IMalloc_GetSize_Proxy(IMalloc, void*);
+void IMalloc_GetSize_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+int IMalloc_DidAlloc_Proxy(IMalloc, void*);
+void IMalloc_DidAlloc_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IMalloc_HeapMinimize_Proxy(IMalloc);
+void IMalloc_HeapMinimize_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+ULONG IMallocSpy_PreAlloc_Proxy(IMallocSpy, ULONG cbRequest);
+void IMallocSpy_PreAlloc_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void* IMallocSpy_PostAlloc_Proxy(IMallocSpy, void*);
+void IMallocSpy_PostAlloc_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void* IMallocSpy_PreFree_Proxy(IMallocSpy, void*, BOOL);
+void IMallocSpy_PreFree_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IMallocSpy_PostFree_Proxy(IMallocSpy, BOOL);
+void IMallocSpy_PostFree_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+ULONG IMallocSpy_PreRealloc_Proxy(IMallocSpy, void*, ULONG, void**, BOOL);
+void IMallocSpy_PreRealloc_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void* IMallocSpy_PostRealloc_Proxy(IMallocSpy, void*, BOOL);
+void IMallocSpy_PostRealloc_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void* IMallocSpy_PreGetSize_Proxy(IMallocSpy, void*, BOOL);
+void IMallocSpy_PreGetSize_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+ULONG IMallocSpy_PostGetSize_Proxy(IMallocSpy, ULONG, BOOL);
+void IMallocSpy_PostGetSize_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void* IMallocSpy_PreDidAlloc_Proxy(IMallocSpy, void*, BOOL);
+void IMallocSpy_PreDidAlloc_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+int IMallocSpy_PostDidAlloc_Proxy(IMallocSpy, void*, BOOL, int);
+void IMallocSpy_PostDidAlloc_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IMallocSpy_PreHeapMinimize_Proxy(IMallocSpy );
+void IMallocSpy_PreHeapMinimize_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IMallocSpy_PostHeapMinimize_Proxy(IMallocSpy);
+void IMallocSpy_PostHeapMinimize_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStdMarshalInfo_GetClassForHandler_Proxy(IStdMarshalInfo, DWORD, void*, CLSID*);
+void IStdMarshalInfo_GetClassForHandler_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+DWORD IExternalConnection_AddConnection_Proxy(IExternalConnection, DWORD, DWORD);
+void IExternalConnection_AddConnection_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+DWORD IExternalConnection_ReleaseConnection_Proxy(IExternalConnection, DWORD, DWORD, BOOL);
+void IExternalConnection_ReleaseConnection_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumUnknown_RemoteNext_Proxy(IEnumUnknown, ULONG, IUnknown*, ULONG*);
+void IEnumUnknown_RemoteNext_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumUnknown_Skip_Proxy(IEnumUnknown, ULONG);
+void IEnumUnknown_Skip_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumUnknown_Reset_Proxy(IEnumUnknown );
+void IEnumUnknown_Reset_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumUnknown_Clone_Proxy(IEnumUnknown, IEnumUnknown*);
+void IEnumUnknown_Clone_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IBindCtx_RegisterObjectBound_Proxy(IBindCtx, IUnknownpunk);
+void IBindCtx_RegisterObjectBound_Stub(IRpcStubBuffer, IRpcChannelBuffer_pRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IBindCtx_RevokeObjectBound_Proxy(IBindCtx, IUnknownpunk);
+void IBindCtx_RevokeObjectBound_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IBindCtx_ReleaseBoundObjects_Proxy(IBindCtx);
+void IBindCtx_ReleaseBoundObjects_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IBindCtx_SetBindOptions_Proxy(IBindCtx, BIND_OPTS*);
+void IBindCtx_SetBindOptions_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IBindCtx_GetBindOptions_Proxy(IBindCtx, BIND_OPTS*pbindopts);
+void IBindCtx_GetBindOptions_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IBindCtx_GetRunningObjectTable_Proxy(IBindCtx, IRunningObjectTable*);
+void IBindCtx_GetRunningObjectTable_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IBindCtx_RegisterObjectParam_Proxy(IBindCtx, LPCSTR, IUnknown);
+void IBindCtx_RegisterObjectParam_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IBindCtx_GetObjectParam_Proxy(IBindCtx, LPCSTR, IUnknown*);
+void IBindCtx_GetObjectParam_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IBindCtx_EnumObjectParam_Proxy(IBindCtx, IEnumString*);
+void IBindCtx_EnumObjectParam_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IBindCtx_RevokeObjectParam_Proxy(IBindCtx, LPCSTR);
+void IBindCtx_RevokeObjectParam_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumMoniker_RemoteNext_Proxy(IEnumMoniker, ULONG, IMoniker*, ULONG*);
+void IEnumMoniker_RemoteNext_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumMoniker_Skip_Proxy(IEnumMoniker, ULONG);
+void IEnumMoniker_Skip_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumMoniker_Reset_Proxy(IEnumMoniker);
+void IEnumMoniker_Reset_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumMoniker_Clone_Proxy(IEnumMoniker, IEnumMoniker*);
+void IEnumMoniker_Clone_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRunnableObject_GetRunningClass_Proxy(IRunnableObject, LPCLSID);
+void IRunnableObject_GetRunningClass_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRunnableObject_Run_Proxy(IRunnableObject, LPBINDCTX);
+void IRunnableObject_Run_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+BOOL IRunnableObject_IsRunning_Proxy(IRunnableObject);
+void IRunnableObject_IsRunning_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRunnableObject_LockRunning_Proxy(IRunnableObject, BOOL, BOOL);
+void IRunnableObject_LockRunning_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRunnableObject_SetContainedObject_Proxy(IRunnableObject, BOOL);
+void IRunnableObject_SetContainedObject_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRunningObjectTable_Register_Proxy(IRunningObjectTable, DWORD, IUnknown, IMoniker, DWORD*);
+void IRunningObjectTable_Register_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRunningObjectTable_Revoke_Proxy(IRunningObjectTable, DWORD);
+void IRunningObjectTable_Revoke_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRunningObjectTable_IsRunning_Proxy(IRunningObjectTable, IMoniker);
+void IRunningObjectTable_IsRunning_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRunningObjectTable_GetObject_Proxy(IRunningObjectTable, IMoniker, IUnknown*);
+void IRunningObjectTable_GetObject_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRunningObjectTable_NoteChangeTime_Proxy(IRunningObjectTable, DWORD, FILETIME*);
+void IRunningObjectTable_NoteChangeTime_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRunningObjectTable_GetTimeOfLastChange_Proxy(IRunningObjectTable, IMoniker, FILETIME*);
+void IRunningObjectTable_GetTimeOfLastChange_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRunningObjectTable_EnumRunning_Proxy(IRunningObjectTable, IEnumMoniker*);
+void IRunningObjectTable_EnumRunning_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersist_GetClassID_Proxy(IPersist, CLSID*);
+void IPersist_GetClassID_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistStream_IsDirty_Proxy(IPersistStream);
+void IPersistStream_IsDirty_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistStream_Load_Proxy(IPersistStream, IStream);
+void IPersistStream_Load_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistStream_Save_Proxy(IPersistStream, IStream, BOOL);
+void IPersistStream_Save_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistStream_GetSizeMax_Proxy(IPersistStream, ULARGE_INTEGER*);
+void IPersistStream_GetSizeMax_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_RemoteBindToObject_Proxy(IMoniker, IBindCtx, IMoniker, REFIID, IUnknown*);
+void IMoniker_RemoteBindToObject_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_RemoteBindToStorage_Proxy(IMoniker, IBindCtx, IMoniker, REFIID, IUnknown*);
+void IMoniker_RemoteBindToStorage_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_Reduce_Proxy(IMoniker, IBindCtx, DWORD, IMoniker*, IMoniker*);
+void IMoniker_Reduce_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_ComposeWith_Proxy(IMoniker, IMoniker, BOOL, IMoniker*);
+void IMoniker_ComposeWith_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_Enum_Proxy(IMoniker, BOOL, IEnumMoniker*);
+void IMoniker_Enum_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_IsEqual_Proxy(IMoniker, IMoniker);
+void IMoniker_IsEqual_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_Hash_Proxy(IMoniker, DWORD*);
+void IMoniker_Hash_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_IsRunning_Proxy(IMoniker, IBindCtx, IMoniker, IMoniker);
+void IMoniker_IsRunning_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_GetTimeOfLastChange_Proxy(IMoniker, IBindCtx, IMoniker, FILETIME*);
+void IMoniker_GetTimeOfLastChange_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_Inverse_Proxy(IMoniker, IMoniker*);
+void IMoniker_Inverse_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_CommonPrefixWith_Proxy(IMoniker, IMoniker, IMoniker*);
+void IMoniker_CommonPrefixWith_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_RelativePathTo_Proxy(IMoniker, IMoniker, IMoniker*);
+void IMoniker_RelativePathTo_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_GetDisplayName_Proxy(IMoniker, IBindCtx, IMoniker, LPCSTR*);
+void IMoniker_GetDisplayName_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_ParseDisplayName_Proxy(IMoniker, IBindCtx, IMoniker, LPCSTR, ULONG*, IMoniker*);
+void IMoniker_ParseDisplayName_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IMoniker_IsSystemMoniker_Proxy(IMoniker, DWORD*);
+void IMoniker_IsSystemMoniker_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IROTData_GetComparisonData_Proxy(IROTData, BYTE*, ULONG cbMax, ULONG*);
+void IROTData_GetComparisonData_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumString_RemoteNext_Proxy(IEnumString, ULONG, LPCSTR*rgelt, ULONG*);
+void IEnumString_RemoteNext_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumString_Skip_Proxy(IEnumString, ULONG);
+void IEnumString_Skip_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumString_Reset_Proxy(IEnumString);
+void IEnumString_Reset_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumString_Clone_Proxy(IEnumString, IEnumString*);
+void IEnumString_Clone_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStream_RemoteRead_Proxy(IStream, BYTE*, ULONG, ULONG*);
+void IStream_RemoteRead_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStream_RemoteWrite_Proxy(IStream, BYTE*pv, ULONG, ULONG*);
+void IStream_RemoteWrite_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStream_RemoteSeek_Proxy(IStream, LARGE_INTEGER, DWORD, ULARGE_INTEGER*);
+void IStream_RemoteSeek_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStream_SetSize_Proxy(IStream, ULARGE_INTEGER);
+void IStream_SetSize_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStream_RemoteCopyTo_Proxy(IStream, IStream, ULARGE_INTEGER, ULARGE_INTEGER*, ULARGE_INTEGER*);
+void IStream_RemoteCopyTo_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStream_Commit_Proxy(IStream, DWORD);
+void IStream_Commit_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStream_Revert_Proxy(IStream);
+void IStream_Revert_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStream_LockRegion_Proxy(IStream, ULARGE_INTEGER, ULARGE_INTEGER, DWORD);
+void IStream_LockRegion_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStream_UnlockRegion_Proxy(IStream, ULARGE_INTEGER, ULARGE_INTEGER, DWORD);
+void IStream_UnlockRegion_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStream_Stat_Proxy(IStream, STATSTG*, DWORD);
+void IStream_Stat_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStream_Clone_Proxy(IStream, IStream*);
+void IStream_Clone_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumSTATSTG_RemoteNext_Proxy(IEnumSTATSTG, ULONG, STATSTG*, ULONG*);
+void IEnumSTATSTG_RemoteNext_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumSTATSTG_Skip_Proxy(IEnumSTATSTG, ULONG celt);
+void IEnumSTATSTG_Skip_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumSTATSTG_Reset_Proxy(IEnumSTATSTG);
+void IEnumSTATSTG_Reset_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumSTATSTG_Clone_Proxy(IEnumSTATSTG, IEnumSTATSTG*);
+void IEnumSTATSTG_Clone_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_CreateStream_Proxy(IStorage, OLECHAR*, DWORD, DWORD, DWORD, IStream*);
+void IStorage_CreateStream_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_RemoteOpenStream_Proxy(IStorage, const(OLECHAR)*, uint, BYTE*, DWORD, DWORD, IStream*);
+void IStorage_RemoteOpenStream_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_CreateStorage_Proxy(IStorage, OLECHAR*, DWORD, DWORD, DWORD, IStorage*);
+void IStorage_CreateStorage_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_OpenStorage_Proxy(IStorage, OLECHAR*, IStorage, DWORD, SNB, DWORD, IStorage*);
+void IStorage_OpenStorage_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_CopyTo_Proxy(IStorage, DWORD, const(IID)*, SNB, IStorage);
+void IStorage_CopyTo_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_MoveElementTo_Proxy(IStorage, const(OLECHAR)*, IStorage, const(OLECHAR)*, DWORD);
+void IStorage_MoveElementTo_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_Commit_Proxy(IStorage, DWORD);
+void IStorage_Commit_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_Revert_Proxy(IStorage);
+void IStorage_Revert_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_RemoteEnumElements_Proxy(IStorage, DWORD, uint, BYTE*, DWORD, IEnumSTATSTG*);
+void IStorage_RemoteEnumElements_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_DestroyElement_Proxy(IStorage, OLECHAR*);
+void IStorage_DestroyElement_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_RenameElement_Proxy(IStorage, const(OLECHAR)*, const(OLECHAR)*);
+void IStorage_RenameElement_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_SetElementTimes_Proxy(IStorage, const(OLECHAR)*, const(FILETIME)*, const(FILETIME)*, const(FILETIME)*);
+void IStorage_SetElementTimes_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_SetClass_Proxy(IStorage, REFCLSID);
+void IStorage_SetClass_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_SetStateBits_Proxy(IStorage, DWORD, DWORD);
+void IStorage_SetStateBits_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IStorage_Stat_Proxy(IStorage, STATSTG*, DWORD);
+void IStorage_Stat_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistFile_IsDirty_Proxy(IPersistFile);
+void IPersistFile_IsDirty_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistFile_Load_Proxy(IPersistFile, LPCOLESTR, DWORD);
+void IPersistFile_Load_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistFile_Save_Proxy(IPersistFile, LPCOLESTR pszFileName, BOOL);
+void IPersistFile_Save_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistFile_SaveCompleted_Proxy(IPersistFile, LPCOLESTR);
+void IPersistFile_SaveCompleted_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistFile_GetCurFile_Proxy(IPersistFile, LPCSTR*);
+void IPersistFile_GetCurFile_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistStorage_IsDirty_Proxy(IPersistStorage);
+void IPersistStorage_IsDirty_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistStorage_InitNew_Proxy(IPersistStorage, IStorage);
+void IPersistStorage_InitNew_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistStorage_Load_Proxy(IPersistStorage, IStorage);
+void IPersistStorage_Load_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistStorage_Save_Proxy(IPersistStorage, IStorage, BOOL);
+void IPersistStorage_Save_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistStorage_SaveCompleted_Proxy(IPersistStorage, IStorage);
+void IPersistStorage_SaveCompleted_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPersistStorage_HandsOffStorage_Proxy(IPersistStorage);
+void IPersistStorage_HandsOffStorage_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT ILockBytes_RemoteReadAt_Proxy(ILockBytes, ULARGE_INTEGER, BYTE*, ULONG, ULONG*);
+void ILockBytes_RemoteReadAt_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT ILockBytes_RemoteWriteAt_Proxy(ILockBytes, ULARGE_INTEGER, BYTE*pv, ULONG, ULONG*);
+void ILockBytes_RemoteWriteAt_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT ILockBytes_Flush_Proxy(ILockBytes);
+void ILockBytes_Flush_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT ILockBytes_SetSize_Proxy(ILockBytes, ULARGE_INTEGER);
+void ILockBytes_SetSize_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT ILockBytes_LockRegion_Proxy(ILockBytes, ULARGE_INTEGER, ULARGE_INTEGER, DWORD);
+void ILockBytes_LockRegion_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT ILockBytes_UnlockRegion_Proxy(ILockBytes, ULARGE_INTEGER, ULARGE_INTEGER, DWORD);
+void ILockBytes_UnlockRegion_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT ILockBytes_Stat_Proxy(ILockBytes, STATSTG*, DWORD);
+void ILockBytes_Stat_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumFORMATETC_RemoteNext_Proxy(IEnumFORMATETC, ULONG, FORMATETC*, ULONG*);
+void IEnumFORMATETC_RemoteNext_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumFORMATETC_Skip_Proxy(IEnumFORMATETC, ULONG);
+void IEnumFORMATETC_Skip_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumFORMATETC_Reset_Proxy(IEnumFORMATETC);
+void IEnumFORMATETC_Reset_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumFORMATETC_Clone_Proxy(IEnumFORMATETC, IEnumFORMATETC*);
+void IEnumFORMATETC_Clone_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumFORMATETC_Next_Proxy(IEnumFORMATETC, ULONG, FORMATETC*, ULONG*);
+HRESULT IEnumFORMATETC_Next_Stub(IEnumFORMATETC, ULONG, FORMATETC*, ULONG*);
+HRESULT IEnumSTATDATA_RemoteNext_Proxy(IEnumSTATDATA, ULONG, STATDATA*, ULONG*);
+void IEnumSTATDATA_RemoteNext_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumSTATDATA_Skip_Proxy(IEnumSTATDATA, ULONG);
+void IEnumSTATDATA_Skip_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumSTATDATA_Reset_Proxy(IEnumSTATDATA);
+void IEnumSTATDATA_Reset_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumSTATDATA_Clone_Proxy(IEnumSTATDATA, IEnumSTATDATA*);
+void IEnumSTATDATA_Clone_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IEnumSTATDATA_Next_Proxy(IEnumSTATDATA, ULONG, STATDATA*, ULONG*);
+HRESULT IEnumSTATDATA_Next_Stub(IEnumSTATDATA, ULONG, STATDATA*, ULONG*);
+HRESULT IRootStorage_SwitchToFile_Proxy(IRootStorage, LPCSTR);
+void IRootStorage_SwitchToFile_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IAdviseSink_RemoteOnDataChange_Proxy(IAdviseSink, FORMATETC*, RemSTGMEDIUM*);
+void IAdviseSink_RemoteOnDataChange_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IAdviseSink_RemoteOnViewChange_Proxy(IAdviseSink, DWORD, LONG);
+void IAdviseSink_RemoteOnViewChange_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IAdviseSink_RemoteOnRename_Proxy(IAdviseSink, IMoniker);
+void IAdviseSink_RemoteOnRename_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IAdviseSink_RemoteOnSave_Proxy(IAdviseSink);
+void IAdviseSink_RemoteOnSave_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IAdviseSink_RemoteOnClose_Proxy(IAdviseSink);
+void IAdviseSink_RemoteOnClose_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IAdviseSink_OnDataChange_Proxy(IAdviseSink, FORMATETC*, STGMEDIUM*);
+void IAdviseSink_OnDataChange_Stub(IAdviseSink, FORMATETC*, RemSTGMEDIUM*);
+void IAdviseSink_OnViewChange_Proxy(IAdviseSink, DWORD, LONG);
+void IAdviseSink_OnViewChange_Stub(IAdviseSink, DWORD, LONG);
+void IAdviseSink_OnRename_Proxy(IAdviseSink, IMoniker);
+void IAdviseSink_OnRename_Stub(IAdviseSink, IMoniker);
+void IAdviseSink_OnSave_Proxy(IAdviseSink);
+void IAdviseSink_OnSave_Stub(IAdviseSink);
+void IAdviseSink_OnClose_Proxy(IAdviseSink);
+HRESULT IAdviseSink_OnClose_Stub(IAdviseSink);
+void IAdviseSink2_RemoteOnLinkSrcChange_Proxy(IAdviseSink2, IMoniker);
+void IAdviseSink2_RemoteOnLinkSrcChange_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IAdviseSink2_OnLinkSrcChange_Proxy(IAdviseSink2, IMoniker);
+void IAdviseSink2_OnLinkSrcChange_Stub(IAdviseSink2, IMoniker);
+HRESULT IDataObject_RemoteGetData_Proxy(IDataObject, FORMATETC*, RemSTGMEDIUM**);
+void IDataObject_RemoteGetData_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IDataObject_RemoteGetDataHere_Proxy(IDataObject, FORMATETC*, RemSTGMEDIUM**);
+void IDataObject_RemoteGetDataHere_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IDataObject_QueryGetData_Proxy(IDataObject, FORMATETC*);
+void IDataObject_QueryGetData_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IDataObject_GetCanonicalFormatEtc_Proxy(IDataObject, FORMATETC*, FORMATETC*);
+void IDataObject_GetCanonicalFormatEtc_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IDataObject_RemoteSetData_Proxy(IDataObject, FORMATETC*, RemSTGMEDIUM*, BOOL);
+void IDataObject_RemoteSetData_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IDataObject_EnumFormatEtc_Proxy(IDataObject, DWORD, IEnumFORMATETC*);
+void IDataObject_EnumFormatEtc_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IDataObject_DAdvise_Proxy(IDataObject, FORMATETC*, DWORD, IAdviseSink, DWORD*);
+void IDataObject_DAdvise_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IDataObject_DUnadvise_Proxy(IDataObject, DWORD);
+void IDataObject_DUnadvise_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IDataObject_EnumDAdvise_Proxy(IDataObject, IEnumSTATDATA*);
+void IDataObject_EnumDAdvise_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IDataObject_GetData_Proxy(IDataObject, FORMATETC*, STGMEDIUM*);
+HRESULT IDataObject_GetData_Stub(IDataObject, FORMATETC*, RemSTGMEDIUM**);
+HRESULT IDataObject_GetDataHere_Proxy(IDataObject, FORMATETC*, STGMEDIUM*);
+HRESULT IDataObject_GetDataHere_Stub(IDataObject, FORMATETC*, RemSTGMEDIUM**);
+HRESULT IDataObject_SetData_Proxy(IDataObject, FORMATETC*, STGMEDIUM*, BOOL);
+HRESULT IDataObject_SetData_Stub(IDataObject, FORMATETC*, RemSTGMEDIUM*, BOOL);
+HRESULT IDataAdviseHolder_Advise_Proxy(IDataAdviseHolder, IDataObject, FORMATETC*, DWORD, IAdviseSink, DWORD*);
+void IDataAdviseHolder_Advise_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IDataAdviseHolder_Unadvise_Proxy(IDataAdviseHolder, DWORD);
+void IDataAdviseHolder_Unadvise_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IDataAdviseHolder_EnumAdvise_Proxy(IDataAdviseHolder, IEnumSTATDATA*);
+void IDataAdviseHolder_EnumAdvise_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IDataAdviseHolder_SendOnDataChange_Proxy(IDataAdviseHolder, IDataObject, DWORD, DWORD);
+void IDataAdviseHolder_SendOnDataChange_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+DWORD IMessageFilter_HandleInComingCall_Proxy(IMessageFilter, DWORD, HTASK, DWORD, LPINTERFACEINFO);
+void IMessageFilter_HandleInComingCall_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+DWORD IMessageFilter_RetryRejectedCall_Proxy(IMessageFilter, HTASK, DWORD, DWORD);
+void IMessageFilter_RetryRejectedCall_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+DWORD IMessageFilter_MessagePending_Proxy(IMessageFilter, HTASK, DWORD, DWORD);
+void IMessageFilter_MessagePending_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRpcChannelBuffer_GetBuffer_Proxy(IRpcChannelBuffer, RPCOLEMESSAGE*, REFIID);
+void IRpcChannelBuffer_GetBuffer_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRpcChannelBuffer_SendReceive_Proxy(IRpcChannelBuffer, RPCOLEMESSAGE*, ULONG*);
+void IRpcChannelBuffer_SendReceive_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRpcChannelBuffer_FreeBuffer_Proxy(IRpcChannelBuffer, RPCOLEMESSAGE*);
+void IRpcChannelBuffer_FreeBuffer_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRpcChannelBuffer_GetDestCtx_Proxy(IRpcChannelBuffer, DWORD*, void**);
+void IRpcChannelBuffer_GetDestCtx_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRpcChannelBuffer_IsConnected_Proxy(IRpcChannelBuffer);
+void IRpcChannelBuffer_IsConnected_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRpcProxyBuffer_Connect_Proxy(IRpcProxyBuffer, IRpcChannelBufferpRpcChannelBuffer);
+void IRpcProxyBuffer_Connect_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IRpcProxyBuffer_Disconnect_Proxy(IRpcProxyBuffer);
+void IRpcProxyBuffer_Disconnect_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRpcStubBuffer_Connect_Proxy(IRpcStubBuffer, IUnknown);
+void IRpcStubBuffer_Connect_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IRpcStubBuffer_Disconnect_Proxy(IRpcStubBuffer);
+void IRpcStubBuffer_Disconnect_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRpcStubBuffer_Invoke_Proxy(IRpcStubBuffer, RPCOLEMESSAGE*, IRpcChannelBuffer);
+void IRpcStubBuffer_Invoke_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+IRpcStubBufferIRpcStubBuffer_IsIIDSupported_Proxy(IRpcStubBuffer, REFIID);
+void IRpcStubBuffer_IsIIDSupported_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+ULONG IRpcStubBuffer_CountRefs_Proxy(IRpcStubBuffer);
+void IRpcStubBuffer_CountRefs_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IRpcStubBuffer_DebugServerQueryInterface_Proxy(IRpcStubBuffer, void**);
+void IRpcStubBuffer_DebugServerQueryInterface_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void IRpcStubBuffer_DebugServerRelease_Proxy(IRpcStubBuffer, void*);
+void IRpcStubBuffer_DebugServerRelease_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPSFactoryBuffer_CreateProxy_Proxy(IPSFactoryBuffer, IUnknown, REFIID, IRpcProxyBuffer*, void**);
+void IPSFactoryBuffer_CreateProxy_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+HRESULT IPSFactoryBuffer_CreateStub_Proxy(IPSFactoryBuffer, REFIID, IUnknown, IRpcStubBuffer*);
+void IPSFactoryBuffer_CreateStub_Stub(IRpcStubBuffer, IRpcChannelBuffer, PRPC_MESSAGE, PDWORD);
+void SNB_to_xmit(SNB*, RemSNB**);
+void SNB_from_xmit(RemSNB*, SNB*);
+void SNB_free_inst(SNB*);
+void SNB_free_xmit(RemSNB*);
+HRESULT IEnumUnknown_Next_Proxy(IEnumUnknown, ULONG, IUnknown*, ULONG*);
+HRESULT IEnumUnknown_Next_Stub(IEnumUnknown, ULONG, IUnknown*, ULONG*);
+HRESULT IEnumMoniker_Next_Proxy(IEnumMoniker, ULONG, IMoniker*, ULONG*);
+HRESULT IEnumMoniker_Next_Stub(IEnumMoniker, ULONG, IMoniker*, ULONG*);
+HRESULT IMoniker_BindToObject_Proxy(IMoniker, IBindCtx, IMoniker, REFIID, void**);
+HRESULT IMoniker_BindToObject_Stub(IMoniker, IBindCtx, IMoniker, REFIID, IUnknown*);
+HRESULT IMoniker_BindToStorage_Proxy(IMoniker, IBindCtx, IMoniker, REFIID, void**);
+HRESULT IMoniker_BindToStorage_Stub(IMoniker, IBindCtx, IMoniker, REFIID, IUnknown*);
+HRESULT IEnumString_Next_Proxy(IEnumString, ULONG, LPCSTR*, ULONG*);
+HRESULT IEnumString_Next_Stub(IEnumString, ULONG, LPCSTR*, ULONG*);
+HRESULT IStream_Read_Proxy(IStream, void*, ULONG, ULONG*);
+HRESULT IStream_Read_Stub(IStream, BYTE*, ULONG, ULONG*);
+HRESULT IStream_Write_Proxy(IStream, void*, ULONG, ULONG*);
+HRESULT IStream_Write_Stub(IStream, BYTE*, ULONG, ULONG*);
+HRESULT IStream_Seek_Proxy(IStream, LARGE_INTEGER, DWORD, ULARGE_INTEGER*);
+HRESULT IStream_Seek_Stub(IStream, LARGE_INTEGER, DWORD, ULARGE_INTEGER*);
+HRESULT IStream_CopyTo_Proxy(IStream, IStream, ULARGE_INTEGER, ULARGE_INTEGER*, ULARGE_INTEGER*);
+HRESULT IStream_CopyTo_Stub(IStream, IStream, ULARGE_INTEGER, ULARGE_INTEGER*, ULARGE_INTEGER*);
+HRESULT IEnumSTATSTG_Next_Proxy(IEnumSTATSTG, ULONG, STATSTG*, ULONG*);
+HRESULT IEnumSTATSTG_Next_Stub(IEnumSTATSTG, ULONG, STATSTG*, ULONG*);
+HRESULT IStorage_OpenStream_Proxy(IStorage, OLECHAR*, void*, DWORD, DWORD, IStream*);
+HRESULT IStorage_OpenStream_Stub(IStorage, OLECHAR*, uint, BYTE*, DWORD, DWORD, IStream* );
+HRESULT IStorage_EnumElements_Proxy(IStorage, DWORD, void*, DWORD, IEnumSTATSTG*);
+HRESULT IStorage_EnumElements_Stub(IStorage, DWORD, uint, BYTE*, DWORD, IEnumSTATSTG*);
+HRESULT ILockBytes_ReadAt_Proxy(ILockBytes, ULARGE_INTEGER, void*, ULONG, ULONG*);
+HRESULT ILockBytes_ReadAt_Stub(ILockBytes, ULARGE_INTEGER, BYTE*, ULONG, ULONG*);
+HRESULT ILockBytes_WriteAt_Proxy(ILockBytes, ULARGE_INTEGER, const(void)*, ULONG, ULONG*);
+HRESULT ILockBytes_WriteAt_Stub(ILockBytes, ULARGE_INTEGER, BYTE*, ULONG, ULONG*);
+}
++/
diff --git a/libphobos/libdruntime/core/sys/windows/objsafe.d b/libphobos/libdruntime/core/sys/windows/objsafe.d
new file mode 100644
index 00000000000..25569845e7d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/objsafe.d
@@ -0,0 +1,23 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_objsafe.d)
+ */
+module core.sys.windows.objsafe;
+version (Windows):
+
+private import core.sys.windows.basetyps, core.sys.windows.unknwn, core.sys.windows.windef;
+
+enum {
+    INTERFACESAFE_FOR_UNTRUSTED_CALLER = 1,
+    INTERFACESAFE_FOR_UNTRUSTED_DATA
+}
+
+interface IObjectSafety : IUnknown {
+    HRESULT GetInterfaceSafetyOptions(REFIID, DWORD*, DWORD*);
+    HRESULT SetInterfaceSafetyOptions(REFIID, DWORD, DWORD);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/ocidl.d b/libphobos/libdruntime/core/sys/windows/ocidl.d
new file mode 100644
index 00000000000..4244ba1a6c2
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/ocidl.d
@@ -0,0 +1,472 @@
+/**
+ * Windows API header module
+ *
+ * Part of the Internet Development SDK
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_ocidl.d)
+ */
+module core.sys.windows.ocidl;
+version (Windows):
+
+private import core.sys.windows.ole2, core.sys.windows.oleidl, core.sys.windows.oaidl, core.sys.windows.objfwd,
+  core.sys.windows.windef, core.sys.windows.wtypes;
+private import core.sys.windows.objidl;  // for CLIPFORMAT
+private import core.sys.windows.wingdi;  // for TEXTMETRICW
+private import core.sys.windows.winuser; // for LPMSG
+
+interface IBindHost : IUnknown {}
+
+interface IServiceProvider : IUnknown{
+    HRESULT QueryService(REFGUID,REFIID,void**);
+}
+
+/*
+// TODO:
+//private import core.sys.windows.servprov; // for IServiceProvider
+// private import core.sys.windows.urlmon; // for IBindHost. This is not included in MinGW.
+
+// core.sys.windows.urlmon should contain:
+interface IBindHost : IUnknown
+{
+    HRESULT CreateMoniker(LPOLESTR szName, IBindCtx pBC, IMoniker* ppmk, DWORD);
+    HRESULT MonikerBindToObject(IMoniker pMk, IBindCtx pBC, IBindStatusCallback pBSC, REFIID, void** );
+    HRESULT MonikerBindToStorage(IMoniker pMk, IBindCtx pBC, IBindStatusCallback pBSC, REFIID, void** );
+}
+*/
+
+
+
+
+//[Yes] #ifndef OLE2ANSI
+alias TEXTMETRICW TEXTMETRICOLE;
+//} else {
+//alias TEXTMETRIC TEXTMETRICOLE;
+//}
+alias TEXTMETRICOLE* LPTEXTMETRICOLE;
+
+alias DWORD OLE_COLOR;
+alias UINT OLE_HANDLE;
+alias int OLE_XPOS_HIMETRIC;
+alias int OLE_YPOS_HIMETRIC;
+alias int OLE_XSIZE_HIMETRIC;
+alias int OLE_YSIZE_HIMETRIC;
+
+enum READYSTATE {
+    READYSTATE_UNINITIALIZED = 0,
+    READYSTATE_LOADING = 1,
+    READYSTATE_LOADED = 2,
+    READYSTATE_INTERACTIVE = 3,
+    READYSTATE_COMPLETE = 4
+}
+
+enum PROPBAG2_TYPE {
+    PROPBAG2_TYPE_UNDEFINED,
+    PROPBAG2_TYPE_DATA,
+    PROPBAG2_TYPE_URL,
+    PROPBAG2_TYPE_OBJECT,
+    PROPBAG2_TYPE_STREAM,
+    PROPBAG2_TYPE_STORAGE,
+    PROPBAG2_TYPE_MONIKER // = 6
+}
+
+struct PROPBAG2 {
+    DWORD dwType;
+    VARTYPE vt;
+    CLIPFORMAT cfType;
+    DWORD dwHint;
+    LPOLESTR pstrName;
+    CLSID clsid;
+}
+
+enum QACONTAINERFLAGS {
+    QACONTAINER_SHOWHATCHING = 1,
+    QACONTAINER_SHOWGRABHANDLES = 2,
+    QACONTAINER_USERMODE = 4,
+    QACONTAINER_DISPLAYASDEFAULT = 8,
+    QACONTAINER_UIDEAD = 16,
+    QACONTAINER_AUTOCLIP = 32,
+    QACONTAINER_MESSAGEREFLECT = 64,
+    QACONTAINER_SUPPORTSMNEMONICS = 128
+}
+
+struct QACONTAINER {
+    ULONG cbSize = this.sizeof;
+    IOleClientSite pClientSite;
+    IAdviseSinkEx pAdviseSink;
+    IPropertyNotifySink pPropertyNotifySink;
+    IUnknown pUnkEventSink;
+    DWORD dwAmbientFlags;
+    OLE_COLOR colorFore;
+    OLE_COLOR colorBack;
+    IFont pFont;
+    IOleUndoManager pUndoMgr;
+    DWORD dwAppearance;
+    LONG lcid;
+    HPALETTE hpal;
+    IBindHost pBindHost;
+    IOleControlSite pOleControlSite;
+    IServiceProvider pServiceProvider;
+}
+
+struct QACONTROL {
+    ULONG cbSize = this.sizeof;
+    DWORD dwMiscStatus;
+    DWORD dwViewStatus;
+    DWORD dwEventCookie;
+    DWORD dwPropNotifyCookie;
+    DWORD dwPointerActivationPolicy;
+}
+
+struct POINTF {
+    float x;
+    float y;
+}
+alias POINTF* LPPOINTF;
+
+struct CONTROLINFO {
+    ULONG cb;
+    HACCEL hAccel;
+    USHORT cAccel;
+    DWORD dwFlags;
+}
+alias CONTROLINFO* LPCONTROLINFO;
+
+struct CONNECTDATA {
+    LPUNKNOWN pUnk;
+    DWORD dwCookie;
+}
+alias CONNECTDATA* LPCONNECTDATA;
+
+struct LICINFO {
+    int cbLicInfo;
+    BOOL fRuntimeKeyAvail;
+    BOOL fLicVerified;
+}
+alias LICINFO* LPLICINFO;
+
+struct CAUUID {
+    ULONG cElems;
+    GUID* pElems;
+}
+alias CAUUID* LPCAUUID;
+
+struct CALPOLESTR {
+    ULONG cElems;
+    LPOLESTR* pElems;
+}
+alias CALPOLESTR* LPCALPOLESTR;
+
+struct CADWORD {
+    ULONG cElems;
+    DWORD* pElems;
+}
+alias CADWORD* LPCADWORD;
+
+struct PROPPAGEINFO {
+    ULONG cb;
+    LPOLESTR pszTitle;
+    SIZE size;
+    LPOLESTR pszDocString;
+    LPOLESTR pszHelpFile;
+    DWORD dwHelpContext;
+}
+alias PROPPAGEINFO* LPPROPPAGEINFO;
+
+interface IOleControl : IUnknown {
+    HRESULT GetControlInfo(LPCONTROLINFO);
+    HRESULT OnMnemonic(LPMSG);
+    HRESULT OnAmbientPropertyChange(DISPID);
+    HRESULT FreezeEvents(BOOL);
+}
+
+interface IOleControlSite : IUnknown {
+    HRESULT OnControlInfoChanged();
+    HRESULT LockInPlaceActive(BOOL);
+    HRESULT GetExtendedControl(LPDISPATCH*);
+    HRESULT TransformCoords(POINTL*, POINTF*, DWORD);
+    HRESULT TranslateAccelerator(LPMSG, DWORD);
+    HRESULT OnFocus(BOOL);
+    HRESULT ShowPropertyFrame();
+}
+
+interface ISimpleFrameSite : IUnknown {
+    HRESULT PreMessageFilter(HWND, UINT, WPARAM, LPARAM, LRESULT*, PDWORD);
+    HRESULT PostMessageFilter(HWND, UINT, WPARAM, LPARAM, LRESULT*, DWORD);
+}
+
+interface IErrorLog : IUnknown {
+    HRESULT AddError(LPCOLESTR, LPEXCEPINFO);
+}
+alias IErrorLog LPERRORLOG;
+
+interface IPropertyBag : IUnknown {
+    HRESULT Read(LPCOLESTR, LPVARIANT, LPERRORLOG);
+    HRESULT Write(LPCOLESTR, LPVARIANT);
+}
+alias IPropertyBag LPPROPERTYBAG;
+
+interface IPropertyBag2 : IUnknown {
+    HRESULT Read(ULONG, PROPBAG2*, LPERRORLOG, VARIANT*, HRESULT*);
+    HRESULT Write(ULONG, PROPBAG2*, VARIANT*);
+    HRESULT CountProperties(ULONG*);
+    HRESULT GetPropertyInfo(ULONG, ULONG, PROPBAG2*, ULONG*);
+    HRESULT LoadObject(LPCOLESTR, DWORD, IUnknown, LPERRORLOG);
+}
+alias IPropertyBag2 LPPROPERTYBAG2;
+
+interface IPersistPropertyBag : IPersist {
+    HRESULT InitNew();
+    HRESULT Load(LPPROPERTYBAG, LPERRORLOG);
+    HRESULT Save(LPPROPERTYBAG, BOOL, BOOL);
+}
+
+interface IPersistPropertyBag2 : IPersist {
+    HRESULT InitNew();
+    HRESULT Load(LPPROPERTYBAG2, LPERRORLOG);
+    HRESULT Save(LPPROPERTYBAG2, BOOL, BOOL);
+    HRESULT IsDirty();
+}
+
+interface IPersistStreamInit : IPersist {
+    HRESULT IsDirty();
+    HRESULT Load(LPSTREAM);
+    HRESULT Save(LPSTREAM, BOOL);
+    HRESULT GetSizeMax(PULARGE_INTEGER);
+    HRESULT InitNew();
+}
+
+interface IPersistMemory : IPersist {
+    HRESULT IsDirty();
+    HRESULT Load(PVOID, ULONG);
+    HRESULT Save(PVOID, BOOL, ULONG);
+    HRESULT GetSizeMax(PULONG);
+    HRESULT InitNew();
+}
+
+interface IPropertyNotifySink : IUnknown {
+    HRESULT OnChanged(DISPID);
+    HRESULT OnRequestEdit(DISPID);
+}
+
+interface IProvideClassInfo : IUnknown {
+    HRESULT GetClassInfo(LPTYPEINFO*);
+}
+
+interface IProvideClassInfo2 : IProvideClassInfo {
+    HRESULT GetGUID(DWORD, GUID*);
+}
+
+interface IConnectionPointContainer : IUnknown {
+    HRESULT EnumConnectionPoints(LPENUMCONNECTIONPOINTS*);
+    HRESULT FindConnectionPoint(REFIID, LPCONNECTIONPOINT*);
+}
+
+interface IEnumConnectionPoints : IUnknown {
+    HRESULT Next(ULONG, LPCONNECTIONPOINT*, ULONG*);
+    HRESULT Skip(ULONG);
+    HRESULT Reset();
+    HRESULT Clone(LPENUMCONNECTIONPOINTS*);
+}
+alias IEnumConnectionPoints LPENUMCONNECTIONPOINTS;
+
+interface IConnectionPoint : IUnknown {
+    HRESULT GetConnectionInterface(IID*);
+    HRESULT GetConnectionPointContainer(IConnectionPointContainer*);
+    HRESULT Advise(LPUNKNOWN, PDWORD);
+    HRESULT Unadvise(DWORD);
+    HRESULT EnumConnections(LPENUMCONNECTIONS*);
+}
+alias IConnectionPoint LPCONNECTIONPOINT;
+
+interface IEnumConnections : IUnknown {
+    HRESULT Next(ULONG, LPCONNECTDATA, PULONG);
+    HRESULT Skip(ULONG);
+    HRESULT Reset();
+    HRESULT Clone(LPENUMCONNECTIONS*);
+}
+alias IEnumConnections LPENUMCONNECTIONS;
+
+interface IClassFactory2 : IClassFactory {
+    HRESULT GetLicInfo(LPLICINFO);
+    HRESULT RequestLicKey(DWORD, BSTR*);
+    HRESULT CreateInstanceLic(LPUNKNOWN, LPUNKNOWN, REFIID, BSTR, PVOID*);
+}
+
+interface ISpecifyPropertyPages : IUnknown {
+    HRESULT GetPages(CAUUID*);
+}
+
+interface IPerPropertyBrowsing : IUnknown {
+    HRESULT GetDisplayString(DISPID, BSTR*);
+    HRESULT MapPropertyToPage(DISPID, LPCLSID);
+    HRESULT GetPredefinedStrings(DISPID, CALPOLESTR*, CADWORD*);
+    HRESULT GetPredefinedValue(DISPID, DWORD, VARIANT*);
+}
+
+interface IPropertyPageSite : IUnknown {
+    HRESULT OnStatusChange(DWORD);
+    HRESULT GetLocaleID(LCID*);
+    HRESULT GetPageContainer(LPUNKNOWN*);
+    HRESULT TranslateAccelerator(LPMSG);
+}
+alias IPropertyPageSite LPPROPERTYPAGESITE;
+
+interface IPropertyPage : IUnknown {
+    HRESULT SetPageSite(LPPROPERTYPAGESITE);
+    HRESULT Activate(HWND, LPCRECT, BOOL);
+    HRESULT Deactivate();
+    HRESULT GetPageInfo(LPPROPPAGEINFO);
+    HRESULT SetObjects(ULONG, LPUNKNOWN*);
+    HRESULT Show(UINT);
+    HRESULT Move(LPCRECT);
+    HRESULT IsPageDirty();
+    HRESULT Apply();
+    HRESULT Help(LPCOLESTR);
+    HRESULT TranslateAccelerator(LPMSG);
+}
+
+
+interface IPropertyPage2 : IPropertyPage
+{ HRESULT EditProperty(DISPID);
+}
+
+interface IFont : IUnknown {
+    HRESULT get_Name(BSTR*);
+    HRESULT put_Name(BSTR);
+    HRESULT get_Size(CY*);
+    HRESULT put_Size(CY);
+    HRESULT get_Bold(BOOL*);
+    HRESULT put_Bold(BOOL);
+    HRESULT get_Italic(BOOL*);
+    HRESULT put_Italic(BOOL);
+    HRESULT get_Underline(BOOL*);
+    HRESULT put_Underline(BOOL);
+    HRESULT get_Strikethrough(BOOL*);
+    HRESULT put_Strikethrough(BOOL);
+    HRESULT get_Weight(short*);
+    HRESULT put_Weight(short);
+    HRESULT get_Charset(short*);
+    HRESULT put_Charset(short);
+    HRESULT get_hFont(HFONT*);
+    HRESULT Clone(IFont*);
+    HRESULT IsEqual(IFont);
+    HRESULT SetRatio(int, int);
+    HRESULT QueryTextMetrics(LPTEXTMETRICOLE);
+    HRESULT AddRefHfont(HFONT);
+    HRESULT ReleaseHfont(HFONT);
+    HRESULT SetHdc(HDC);
+}
+alias IFont LPFONT;
+
+interface IFontDisp : IDispatch {
+}
+alias IFontDisp LPFONTDISP;
+
+interface IPicture : IUnknown {
+    HRESULT get_Handle(OLE_HANDLE*);
+    HRESULT get_hPal(OLE_HANDLE*);
+    HRESULT get_Type(short*);
+    HRESULT get_Width(OLE_XSIZE_HIMETRIC*);
+    HRESULT get_Height(OLE_YSIZE_HIMETRIC*);
+    HRESULT Render(HDC, int, int, int, int, OLE_XPOS_HIMETRIC,
+      OLE_YPOS_HIMETRIC, OLE_XSIZE_HIMETRIC, OLE_YSIZE_HIMETRIC, LPCRECT);
+    HRESULT set_hPal(OLE_HANDLE);
+    HRESULT get_CurDC(HDC*);
+    HRESULT SelectPicture(HDC, HDC*, OLE_HANDLE*);
+    HRESULT get_KeepOriginalFormat(BOOL*);
+    HRESULT put_KeepOriginalFormat(BOOL);
+    HRESULT PictureChanged();
+    HRESULT SaveAsFile(LPSTREAM, BOOL, LONG*);
+    HRESULT get_Attributes(PDWORD);
+}
+
+interface IPictureDisp : IDispatch {
+}
+
+interface IOleInPlaceSiteEx : IOleInPlaceSite {
+    HRESULT OnInPlaceActivateEx(BOOL*, DWORD);
+    HRESULT OnInPlaceDeactivateEx(BOOL);
+    HRESULT RequestUIActivate();
+}
+
+interface IObjectWithSite : IUnknown {
+    HRESULT SetSite(IUnknown);
+    HRESULT GetSite(REFIID, void**);
+}
+
+interface IOleInPlaceSiteWindowless : IOleInPlaceSiteEx {
+    HRESULT CanWindowlessActivate();
+    HRESULT GetCapture();
+    HRESULT SetCapture(BOOL);
+    HRESULT GetFocus();
+    HRESULT SetFocus(BOOL);
+    HRESULT GetDC(LPCRECT, DWORD, HDC*);
+    HRESULT ReleaseDC(HDC);
+    HRESULT InvalidateRect(LPCRECT, BOOL);
+    HRESULT InvalidateRgn(HRGN, BOOL);
+    HRESULT ScrollRect(INT, INT, LPCRECT, LPCRECT);
+    HRESULT AdjustRect(LPCRECT);
+    HRESULT OnDefWindowMessage(UINT, WPARAM, LPARAM, LRESULT*);
+}
+
+interface IAdviseSinkEx : IUnknown {
+    void OnDataChange(FORMATETC*, STGMEDIUM*);
+    void OnViewChange(DWORD, LONG);
+    void OnRename(IMoniker);
+    void OnSave();
+    void OnClose();
+    HRESULT OnViewStatusChange(DWORD);
+}
+
+interface IPointerInactive : IUnknown {
+    HRESULT GetActivationPolicy(DWORD*);
+    HRESULT OnInactiveMouseMove(LPCRECT, LONG, LONG, DWORD);
+    HRESULT OnInactiveSetCursor(LPCRECT, LONG, LONG, DWORD, BOOL);
+}
+
+interface IOleUndoUnit : IUnknown {
+    HRESULT Do(LPOLEUNDOMANAGER);
+    HRESULT GetDescription(BSTR*);
+    HRESULT GetUnitType(CLSID*, LONG*);
+    HRESULT OnNextAdd();
+}
+
+interface IOleParentUndoUnit : IOleUndoUnit {
+    HRESULT Open(IOleParentUndoUnit);
+    HRESULT Close(IOleParentUndoUnit, BOOL);
+    HRESULT Add(IOleUndoUnit);
+    HRESULT FindUnit(IOleUndoUnit);
+    HRESULT GetParentState(DWORD*);
+}
+
+interface IEnumOleUndoUnits : IUnknown {
+    HRESULT Next(ULONG, IOleUndoUnit*, ULONG*);
+    HRESULT Skip(ULONG);
+    HRESULT Reset();
+    HRESULT Clone(IEnumOleUndoUnits*);
+}
+
+interface IOleUndoManager : IUnknown {
+    HRESULT Open(IOleParentUndoUnit);
+    HRESULT Close(IOleParentUndoUnit, BOOL);
+    HRESULT Add(IOleUndoUnit);
+    HRESULT GetOpenParentState(DWORD*);
+    HRESULT DiscardFrom(IOleUndoUnit);
+    HRESULT UndoTo(IOleUndoUnit);
+    HRESULT RedoTo(IOleUndoUnit);
+    HRESULT EnumUndoable(IEnumOleUndoUnits*);
+    HRESULT EnumRedoable(IEnumOleUndoUnits*);
+    HRESULT GetLastUndoDescription(BSTR*);
+    HRESULT GetLastRedoDescription(BSTR*);
+    HRESULT Enable(BOOL);
+}
+alias IOleUndoManager LPOLEUNDOMANAGER;
+
+interface IQuickActivate : IUnknown {
+    HRESULT QuickActivate(QACONTAINER*, QACONTROL*);
+    HRESULT SetContentExtent(LPSIZEL);
+    HRESULT GetContentExtent(LPSIZEL);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/odbcinst.d b/libphobos/libdruntime/core/sys/windows/odbcinst.d
new file mode 100644
index 00000000000..9cf7921e1a1
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/odbcinst.d
@@ -0,0 +1,168 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_odbcinst.d)
+ */
+module core.sys.windows.odbcinst;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+import core.sys.windows.sql;
+private import core.sys.windows.windef;
+
+/*  FIXME: The Unicode/Ansi functions situation is a mess. How do the xxxA
+ *  versions of these functions fit into the scheme?
+ */
+
+// SQLConfigDataSource()
+enum : WORD {
+    ODBC_ADD_DSN            = 1,
+    ODBC_CONFIG_DSN         = 2,
+    ODBC_REMOVE_DSN         = 3,
+    ODBC_ADD_SYS_DSN        = 4,
+    ODBC_CONFIG_SYS_DSN     = 5,
+    ODBC_REMOVE_SYS_DSN     = 6,
+    ODBC_REMOVE_DEFAULT_DSN = 7
+}
+
+// ODBC 3.0+
+enum : WORD {
+    ODBC_INSTALL_INQUIRY  = 1,
+    ODBC_INSTALL_COMPLETE = 2
+}
+
+// ODBC 2.5+
+enum : WORD {
+    ODBC_INSTALL_DRIVER    = 1,
+    ODBC_REMOVE_DRIVER     = 2,
+    ODBC_CONFIG_DRIVER     = 3,
+    ODBC_CONFIG_DRIVER_MAX = 100
+}
+
+// ODBC 3.0+
+// SQLSetConfigMode()
+enum : UWORD {
+    ODBC_BOTH_DSN   = 0,
+    ODBC_USER_DSN   = 1,
+    ODBC_SYSTEM_DSN = 2
+}
+
+enum : DWORD {
+    ODBC_ERROR_GENERAL_ERR             = 1,
+    ODBC_ERROR_INVALID_BUFF_LEN        = 2,
+    ODBC_ERROR_INVALID_HWND            = 3,
+    ODBC_ERROR_INVALID_STR             = 4,
+    ODBC_ERROR_INVALID_REQUEST_TYPE    = 5,
+    ODBC_ERROR_COMPONENT_NOT_FOUND     = 6,
+    ODBC_ERROR_INVALID_NAME            = 7,
+    ODBC_ERROR_INVALID_KEYWORD_VALUE   = 8,
+    ODBC_ERROR_INVALID_DSN             = 9,
+    ODBC_ERROR_INVALID_INF             = 10,
+    ODBC_ERROR_REQUEST_FAILED          = 11,
+    ODBC_ERROR_INVALID_PATH            = 12,
+    ODBC_ERROR_LOAD_LIB_FAILED         = 13,
+    ODBC_ERROR_INVALID_PARAM_SEQUENCE  = 14,
+    ODBC_ERROR_INVALID_LOG_FILE        = 15,
+    ODBC_ERROR_USER_CANCELED           = 16,
+    ODBC_ERROR_USAGE_UPDATE_FAILED     = 17,
+    ODBC_ERROR_CREATE_DSN_FAILED       = 18,
+    ODBC_ERROR_WRITING_SYSINFO_FAILED  = 19,
+    ODBC_ERROR_REMOVE_DSN_FAILED       = 20,
+    ODBC_ERROR_OUT_OF_MEM              = 21,
+    ODBC_ERROR_OUTPUT_STRING_TRUNCATED = 22
+}
+
+extern (Windows):
+BOOL  ConfigDSN(HWND,WORD,LPCSTR,LPCSTR);
+BOOL  ConfigDSNW(HWND,WORD,LPCWSTR,LPCWSTR);
+BOOL  ConfigTranslator(HWND,DWORD*);
+BOOL  SQLConfigDataSource(HWND,WORD,LPCSTR,LPCSTR);
+BOOL  SQLConfigDataSourceW(HWND,WORD,LPCWSTR,LPCWSTR);
+BOOL  SQLCreateDataSource(HWND,LPCSTR);
+BOOL  SQLCreateDataSourceW(HWND,LPCWSTR);
+BOOL  SQLGetAvailableDrivers(LPCSTR,LPSTR,WORD,WORD*);
+BOOL  SQLGetAvailableDriversW(LPCWSTR,LPWSTR,WORD,WORD*);
+BOOL  SQLGetInstalledDrivers(LPSTR,WORD,WORD*);
+BOOL  SQLGetInstalledDriversW(LPWSTR,WORD,WORD*);
+int  SQLGetPrivateProfileString(LPCSTR,LPCSTR,LPCSTR,LPSTR,int,LPCSTR);
+int  SQLGetPrivateProfileStringW(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,int,LPCWSTR);
+BOOL  SQLGetTranslator(HWND,LPSTR,WORD,WORD*,LPSTR,WORD,WORD*,DWORD*);
+BOOL  SQLGetTranslatorW(HWND,LPWSTR,WORD,WORD*,LPWSTR,WORD,WORD*,DWORD*);
+BOOL  SQLInstallDriver(LPCSTR,LPCSTR,LPSTR,WORD,WORD*);
+BOOL  SQLInstallDriverManager(LPSTR,WORD,WORD*);
+BOOL  SQLInstallDriverManagerW(LPWSTR,WORD,WORD*);
+BOOL  SQLInstallDriverW(LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*);
+BOOL  SQLInstallODBC(HWND,LPCSTR,LPCSTR,LPCSTR);
+BOOL  SQLInstallODBCW(HWND,LPCWSTR,LPCWSTR,LPCWSTR);
+BOOL  SQLManageDataSources(HWND);
+BOOL  SQLRemoveDefaultDataSource();
+BOOL  SQLRemoveDSNFromIni(LPCSTR);
+BOOL  SQLRemoveDSNFromIniW(LPCWSTR);
+BOOL  SQLValidDSN(LPCSTR);
+BOOL  SQLValidDSNW(LPCWSTR);
+BOOL  SQLWriteDSNToIni(LPCSTR,LPCSTR);
+BOOL  SQLWriteDSNToIniW(LPCWSTR,LPCWSTR);
+BOOL  SQLWritePrivateProfileString(LPCSTR,LPCSTR,LPCSTR,LPCSTR);
+BOOL  SQLWritePrivateProfileStringW(LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR);
+
+static if (ODBCVER >= 0x0250) {
+    BOOL  ConfigDriver(HWND,WORD,LPCSTR,LPCSTR,LPSTR,WORD,WORD*);
+    BOOL  ConfigDriverW(HWND,WORD,LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*);
+    BOOL  SQLConfigDriver(HWND,WORD,LPCSTR,LPCSTR,LPSTR,WORD,WORD*);
+    BOOL  SQLConfigDriverW(HWND,WORD,LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*);
+    deprecated {
+        BOOL  SQLInstallTranslator(LPCSTR,LPCSTR,LPCSTR,LPSTR,WORD,WORD*,WORD,LPDWORD);
+        BOOL  SQLInstallTranslatorW(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*,WORD,LPDWORD);
+    }
+    BOOL  SQLRemoveDriver(LPCSTR,BOOL,LPDWORD);
+    BOOL  SQLRemoveDriverManager(LPDWORD);
+    BOOL  SQLRemoveDriverW(LPCWSTR,BOOL,LPDWORD);
+    BOOL  SQLRemoveTranslator(LPCSTR,LPDWORD);
+    BOOL  SQLRemoveTranslatorW(LPCWSTR,LPDWORD);
+}
+static if (ODBCVER >= 0x0300) {
+    BOOL  SQLGetConfigMode(UWORD*);
+    BOOL  SQLInstallDriverEx(LPCSTR,LPCSTR,LPSTR,WORD,WORD*,WORD,LPDWORD);
+    BOOL  SQLInstallDriverExW(LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*,WORD,LPDWORD);
+    SQLRETURN  SQLInstallerError(WORD,DWORD*,LPSTR,WORD,WORD*);
+    SQLRETURN  SQLInstallerErrorW(WORD,DWORD*,LPWSTR,WORD,WORD*);
+    BOOL  SQLInstallTranslatorEx(LPCSTR,LPCSTR,LPSTR,WORD,WORD*,WORD,LPDWORD);
+    BOOL  SQLInstallTranslatorExW(LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*,WORD,LPDWORD);
+    SQLRETURN  SQLPostInstallerError(DWORD,LPCSTR);
+    SQLRETURN  SQLPostInstallerErrorW(DWORD,LPCWSTR);
+    BOOL  SQLReadFileDSN(LPCSTR,LPCSTR,LPCSTR,LPSTR,WORD,WORD*);
+    BOOL  SQLReadFileDSNW(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,WORD,WORD*);
+    BOOL  SQLSetConfigMode(UWORD);
+    BOOL  SQLWriteFileDSN(LPCSTR,LPCSTR,LPCSTR,LPCSTR);
+    BOOL  SQLWriteFileDSNW(LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR);
+}
+
+version (Unicode) {
+    alias SQLConfigDataSourceW SQLConfigDataSource;
+    alias SQLConfigDriverW SQLConfigDriver;
+    alias SQLCreateDataSourceW SQLCreateDataSource;
+    alias SQLGetAvailableDriversW SQLGetAvailableDrivers;
+    alias SQLGetInstalledDriversW SQLGetInstalledDrivers;
+    alias SQLGetPrivateProfileStringW SQLGetPrivateProfileString;
+    alias SQLGetTranslatorW SQLGetTranslator;
+    alias SQLInstallDriverW SQLInstallDriver;
+    alias SQLInstallDriverExW SQLInstallDriverEx;
+    alias SQLInstallDriverManagerW SQLInstallDriverManager;
+    alias SQLInstallerErrorW SQLInstallerError;
+    alias SQLInstallODBCW SQLInstallODBC;
+    deprecated alias SQLInstallTranslatorW SQLInstallTranslator;
+    alias SQLInstallTranslatorExW SQLInstallTranslatorEx;
+    alias SQLPostInstallerErrorW SQLPostInstallerError;
+    alias SQLReadFileDSNW SQLReadFileDSN;
+    alias SQLRemoveDriverW SQLRemoveDriver;
+    alias SQLRemoveDSNFromIniW SQLRemoveDSNFromIni;
+    alias SQLRemoveTranslatorW SQLRemoveTranslator;
+    alias SQLValidDSNW SQLValidDSN;
+    alias SQLWriteDSNToIniW SQLWriteDSNToIni;
+    alias SQLWriteFileDSNW SQLWriteFileDSN;
+    alias SQLWritePrivateProfileStringW SQLWritePrivateProfileString;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/ole.d b/libphobos/libdruntime/core/sys/windows/ole.d
new file mode 100644
index 00000000000..02dc2555b3c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/ole.d
@@ -0,0 +1,363 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_ole.d)
+ */
+module core.sys.windows.ole;
+version (Windows):
+pragma(lib, "ole32");
+
+private import core.sys.windows.windef, core.sys.windows.wingdi, core.sys.windows.uuid;
+
+alias LPCSTR OLE_LPCSTR;
+
+/+#define LRESULT LONG
+#define HGLOBAL HANDLE+/
+
+enum {
+    OT_LINK = 1,
+    OT_EMBEDDED,
+    OT_STATIC
+}
+
+enum OLEVERB_PRIMARY = 0;
+enum OF_SET          = 1;
+enum OF_GET          = 2;
+enum OF_HANDLER      = 4;
+
+struct OLETARGETDEVICE {
+    USHORT otdDeviceNameOffset;
+    USHORT otdDriverNameOffset;
+    USHORT otdPortNameOffset;
+    USHORT otdExtDevmodeOffset;
+    USHORT otdExtDevmodeSize;
+    USHORT otdEnvironmentOffset;
+    USHORT otdEnvironmentSize;
+    BYTE   _otdData;
+    BYTE*  otdData() return { return &_otdData; }
+}
+alias OLETARGETDEVICE* LPOLETARGETDEVICE;
+
+enum OLESTATUS {
+    OLE_OK,
+    OLE_WAIT_FOR_RELEASE,
+    OLE_BUSY,
+    OLE_ERROR_PROTECT_ONLY,
+    OLE_ERROR_MEMORY,
+    OLE_ERROR_STREAM,
+    OLE_ERROR_STATIC,
+    OLE_ERROR_BLANK,
+    OLE_ERROR_DRAW,
+    OLE_ERROR_METAFILE,
+    OLE_ERROR_ABORT,
+    OLE_ERROR_CLIPBOARD,
+    OLE_ERROR_FORMAT,
+    OLE_ERROR_OBJECT,
+    OLE_ERROR_OPTION,
+    OLE_ERROR_PROTOCOL,
+    OLE_ERROR_ADDRESS,
+    OLE_ERROR_NOT_EQUAL,
+    OLE_ERROR_HANDLE,
+    OLE_ERROR_GENERIC,
+    OLE_ERROR_CLASS,
+    OLE_ERROR_SYNTAX,
+    OLE_ERROR_DATATYPE,
+    OLE_ERROR_PALETTE,
+    OLE_ERROR_NOT_LINK,
+    OLE_ERROR_NOT_EMPTY,
+    OLE_ERROR_SIZE,
+    OLE_ERROR_DRIVE,
+    OLE_ERROR_NETWORK,
+    OLE_ERROR_NAME,
+    OLE_ERROR_TEMPLATE,
+    OLE_ERROR_NEW,
+    OLE_ERROR_EDIT,
+    OLE_ERROR_OPEN,
+    OLE_ERROR_NOT_OPEN,
+    OLE_ERROR_LAUNCH,
+    OLE_ERROR_COMM,
+    OLE_ERROR_TERMINATE,
+    OLE_ERROR_COMMAND,
+    OLE_ERROR_SHOW,
+    OLE_ERROR_DOVERB,
+    OLE_ERROR_ADVISE_NATIVE,
+    OLE_ERROR_ADVISE_PICT,
+    OLE_ERROR_ADVISE_RENAME,
+    OLE_ERROR_POKE_NATIVE,
+    OLE_ERROR_REQUEST_NATIVE,
+    OLE_ERROR_REQUEST_PICT,
+    OLE_ERROR_SERVER_BLOCKED,
+    OLE_ERROR_REGISTRATION,
+    OLE_ERROR_ALREADY_REGISTERED,
+    OLE_ERROR_TASK,
+    OLE_ERROR_OUTOFDATE,
+    OLE_ERROR_CANT_UPDATE_CLIENT,
+    OLE_ERROR_UPDATE,
+    OLE_ERROR_SETDATA_FORMAT,
+    OLE_ERROR_STATIC_FROM_OTHER_OS,
+    OLE_ERROR_FILE_VER,
+    OLE_WARN_DELETE_DATA = 1000
+}
+
+enum OLE_NOTIFICATION {
+    OLE_CHANGED,
+    OLE_SAVED,
+    OLE_CLOSED,
+    OLE_RENAMED,
+    OLE_QUERY_PAINT,
+    OLE_RELEASE,
+    OLE_QUERY_RETRY
+}
+
+enum OLE_RELEASE_METHOD {
+    OLE_NONE,
+    OLE_DELETE,
+    OLE_LNKPASTE,
+    OLE_EMBPASTE,
+    OLE_SHOW,
+    OLE_RUN,
+    OLE_ACTIVATE,
+    OLE_UPDATE,
+    OLE_CLOSE,
+    OLE_RECONNECT,
+    OLE_SETUPDATEOPTIONS,
+    OLE_SERVERUNLAUNCH,
+    OLE_LOADFROMSTREAM,
+    OLE_SETDATA,
+    OLE_REQUESTDATA,
+    OLE_OTHER,
+    OLE_CREATE,
+    OLE_CREATEFROMTEMPLATE,
+    OLE_CREATELINKFROMFILE,
+    OLE_COPYFROMLNK,
+    OLE_CREATEFROMFILE,
+    OLE_CREATEINVISIBLE
+}
+
+enum OLEOPT_RENDER {
+    olerender_none,
+    olerender_draw,
+    olerender_format
+}
+
+alias WORD OLECLIPFORMAT;
+
+enum OLEOPT_UPDATE {
+    oleupdate_always,
+    oleupdate_onsave,
+    oleupdate_oncall,
+// #ifdef OLE_INTERNAL
+    oleupdate_onclose
+// #endif
+}
+
+mixin DECLARE_HANDLE!("HOBJECT");
+alias LONG LHSERVER, LHCLIENTDOC, LHSERVERDOC;
+
+struct OLEOBJECTVTBL {
+    extern (Windows) {
+        void* function(LPOLEOBJECT, OLE_LPCSTR) QueryProtocol;
+        OLESTATUS function(LPOLEOBJECT) Release;
+        OLESTATUS function(LPOLEOBJECT, BOOL) Show;
+        OLESTATUS function(LPOLEOBJECT, UINT, BOOL, BOOL) DoVerb;
+        OLESTATUS function(LPOLEOBJECT, OLECLIPFORMAT, HANDLE*) GetData;
+        OLESTATUS function(LPOLEOBJECT, OLECLIPFORMAT, HANDLE) SetData;
+        OLESTATUS function(LPOLEOBJECT, HGLOBAL) SetTargetDevice;
+        OLESTATUS function(LPOLEOBJECT, RECT*) SetBounds;
+        OLECLIPFORMAT function(LPOLEOBJECT, OLECLIPFORMAT) EnumFormats;
+        OLESTATUS function(LPOLEOBJECT, LOGPALETTE*) SetColorScheme;
+//#ifndef SERVERONLY
+        OLESTATUS function(LPOLEOBJECT) Delete;
+        OLESTATUS function(LPOLEOBJECT, OLE_LPCSTR, OLE_LPCSTR) SetHostNames;
+        OLESTATUS function(LPOLEOBJECT, LPOLESTREAM) SaveToStream;
+        OLESTATUS function(LPOLEOBJECT, LPOLECLIENT, LHCLIENTDOC, OLE_LPCSTR,
+          LPOLEOBJECT*) Clone;
+        OLESTATUS function(LPOLEOBJECT, LPOLECLIENT, LHCLIENTDOC, OLE_LPCSTR,
+          LPOLEOBJECT*) CopyFromLink;
+        OLESTATUS function(LPOLEOBJECT, LPOLEOBJECT) Equal;
+        OLESTATUS function(LPOLEOBJECT) CopyToClipboard;
+        OLESTATUS function(LPOLEOBJECT, HDC, RECT*, RECT*, HDC) Draw;
+        OLESTATUS function(LPOLEOBJECT, UINT, BOOL, BOOL, HWND, RECT*)
+          Activate;
+        OLESTATUS function(LPOLEOBJECT, HGLOBAL, UINT) Execute;
+        OLESTATUS function(LPOLEOBJECT) Close;
+        OLESTATUS function(LPOLEOBJECT) Update;
+        OLESTATUS function(LPOLEOBJECT) Reconnect;
+        OLESTATUS function(LPOLEOBJECT, OLE_LPCSTR, LPOLECLIENT, LHCLIENTDOC,
+          OLE_LPCSTR, LPOLEOBJECT*) ObjectConvert;
+        OLESTATUS function(LPOLEOBJECT, OLEOPT_UPDATE*) GetLinkUpdateOptions;
+        OLESTATUS function(LPOLEOBJECT, OLEOPT_UPDATE) SetLinkUpdateOptions;
+        OLESTATUS function(LPOLEOBJECT, OLE_LPCSTR) Rename;
+        OLESTATUS function(LPOLEOBJECT, LPSTR, UINT*) QueryName;
+        OLESTATUS function(LPOLEOBJECT, LONG*) QueryType;
+        OLESTATUS function(LPOLEOBJECT, RECT*) QueryBounds;
+        OLESTATUS function(LPOLEOBJECT, DWORD*) QuerySize;
+        OLESTATUS function(LPOLEOBJECT) QueryOpen;
+        OLESTATUS function(LPOLEOBJECT) QueryOutOfDate;
+        OLESTATUS function(LPOLEOBJECT) QueryReleaseStatus;
+        OLESTATUS function(LPOLEOBJECT) QueryReleaseError;
+        OLE_RELEASE_METHOD function(LPOLEOBJECT) QueryReleaseMethod;
+        OLESTATUS function(LPOLEOBJECT, OLECLIPFORMAT) RequestData;
+        OLESTATUS function(LPOLEOBJECT, UINT, LONG*) ObjectLong;
+        OLESTATUS function(LPOLEOBJECT, HANDLE, LPOLECLIENT, BOOL) ChangeData;
+//#endif
+    }
+}
+alias OLEOBJECTVTBL* LPOLEOBJECTVTBL;
+
+//#ifndef OLE_INTERNAL
+struct OLEOBJECT {
+    LPOLEOBJECTVTBL lpvtbl;
+}
+alias OLEOBJECT* LPOLEOBJECT;
+//#endif
+
+struct OLECLIENTVTBL {
+    int function(LPOLECLIENT, OLE_NOTIFICATION, LPOLEOBJECT) CallBack;
+}
+alias OLECLIENTVTBL* LPOLECLIENTVTBL;
+
+struct OLECLIENT {
+    LPOLECLIENTVTBL lpvtbl;
+}
+alias OLECLIENT* LPOLECLIENT;
+
+struct OLESTREAMVTBL {
+    DWORD function(LPOLESTREAM, void*, DWORD) Get;
+    DWORD function(LPOLESTREAM, void*, DWORD) Put;
+}
+alias OLESTREAMVTBL* LPOLESTREAMVTBL;
+
+struct OLESTREAM {
+    LPOLESTREAMVTBL lpstbl;
+}
+alias OLESTREAM* LPOLESTREAM;
+
+enum OLE_SERVER_USE {
+    OLE_SERVER_MULTI,
+    OLE_SERVER_SINGLE
+}
+
+struct OLESERVERVTBL {
+    OLESTATUS function(LPOLESERVER, LHSERVERDOC, OLE_LPCSTR, LPOLESERVERDOC*)
+      Open;
+    OLESTATUS function(LPOLESERVER, LHSERVERDOC, OLE_LPCSTR, OLE_LPCSTR,
+      LPOLESERVERDOC*) Create;
+    OLESTATUS function(LPOLESERVER, LHSERVERDOC, OLE_LPCSTR, OLE_LPCSTR,
+      OLE_LPCSTR, LPOLESERVERDOC*) CreateFromTemplate;
+    OLESTATUS function(LPOLESERVER, LHSERVERDOC, OLE_LPCSTR, OLE_LPCSTR,
+      LPOLESERVERDOC*) Edit;
+    OLESTATUS function(LPOLESERVER) Exit;
+    OLESTATUS function(LPOLESERVER) Release;
+    OLESTATUS function(LPOLESERVER, HGLOBAL) Execute;
+}
+alias TypeDef!(OLESERVERVTBL*) LPOLESERVERVTBL;
+
+struct OLESERVER {
+    LPOLESERVERVTBL lpvtbl;
+}
+alias OLESERVER* LPOLESERVER;
+
+struct OLESERVERDOCVTBL {
+    OLESTATUS function(LPOLESERVERDOC) Save;
+    OLESTATUS function(LPOLESERVERDOC) Close;
+    OLESTATUS function(LPOLESERVERDOC, OLE_LPCSTR, OLE_LPCSTR) SetHostNames;
+    OLESTATUS function(LPOLESERVERDOC, RECT*) SetDocDimensions;
+    OLESTATUS function(LPOLESERVERDOC, OLE_LPCSTR, LPOLEOBJECT*, LPOLECLIENT)
+      GetObject;
+    OLESTATUS function(LPOLESERVERDOC) Release;
+    OLESTATUS function(LPOLESERVERDOC, LOGPALETTE*) SetColorScheme;
+    OLESTATUS function(LPOLESERVERDOC, HGLOBAL) Execute;
+}
+alias OLESERVERDOCVTBL* LPOLESERVERDOCVTBL;
+
+struct OLESERVERDOC {
+    LPOLESERVERDOCVTBL lpvtbl;
+}
+alias OLESERVERDOC* LPOLESERVERDOC;
+
+extern (Windows) {
+    OLESTATUS OleDelete(LPOLEOBJECT);
+    OLESTATUS OleRelease(LPOLEOBJECT);
+    OLESTATUS OleSaveToStream(LPOLEOBJECT, LPOLESTREAM);
+    OLESTATUS OleEqual(LPOLEOBJECT, LPOLEOBJECT);
+    OLESTATUS OleCopyToClipboard(LPOLEOBJECT);
+    OLESTATUS OleSetHostNames(LPOLEOBJECT, LPCSTR, LPCSTR);
+    OLESTATUS OleSetTargetDevice(LPOLEOBJECT, HGLOBAL);
+    OLESTATUS OleSetBounds(LPOLEOBJECT, LPCRECT);
+    OLESTATUS OleSetColorScheme(LPOLEOBJECT, const(LOGPALETTE)*);
+    OLESTATUS OleQueryBounds(LPOLEOBJECT, RECT*);
+    OLESTATUS OleQuerySize(LPOLEOBJECT, DWORD*);
+    OLESTATUS OleDraw(LPOLEOBJECT, HDC, LPCRECT, LPCRECT, HDC);
+    OLESTATUS OleQueryOpen(LPOLEOBJECT);
+    OLESTATUS OleActivate(LPOLEOBJECT, UINT, BOOL, BOOL, HWND, LPCRECT);
+    OLESTATUS OleExecute(LPOLEOBJECT, HGLOBAL, UINT);
+    OLESTATUS OleClose(LPOLEOBJECT);
+    OLESTATUS OleUpdate(LPOLEOBJECT);
+    OLESTATUS OleReconnect(LPOLEOBJECT);
+    OLESTATUS OleGetLinkUpdateOptions(LPOLEOBJECT, OLEOPT_UPDATE*);
+    OLESTATUS OleSetLinkUpdateOptions(LPOLEOBJECT, OLEOPT_UPDATE);
+    void* OleQueryProtocol(LPOLEOBJECT, LPCSTR);
+    OLESTATUS OleQueryReleaseStatus(LPOLEOBJECT);
+    OLESTATUS OleQueryReleaseError(LPOLEOBJECT);
+    OLE_RELEASE_METHOD OleQueryReleaseMethod(LPOLEOBJECT);
+    OLESTATUS OleQueryType(LPOLEOBJECT, LONG*);
+    DWORD OleQueryClientVersion();
+    DWORD OleQueryServerVersion();
+    OLECLIPFORMAT OleEnumFormats(LPOLEOBJECT, OLECLIPFORMAT);
+    OLESTATUS OleGetData(LPOLEOBJECT, OLECLIPFORMAT, HANDLE*);
+    OLESTATUS OleSetData(LPOLEOBJECT, OLECLIPFORMAT, HANDLE);
+    OLESTATUS OleQueryOutOfDate(LPOLEOBJECT);
+    OLESTATUS OleRequestData(LPOLEOBJECT, OLECLIPFORMAT);
+    OLESTATUS OleQueryLinkFromClip(LPCSTR, OLEOPT_RENDER, OLECLIPFORMAT);
+    OLESTATUS OleQueryCreateFromClip(LPCSTR, OLEOPT_RENDER, OLECLIPFORMAT);
+    OLESTATUS OleCreateFromClip(LPCSTR, LPOLECLIENT, LHCLIENTDOC, LPCSTR,
+      LPOLEOBJECT*, OLEOPT_RENDER, OLECLIPFORMAT);
+    OLESTATUS OleCreateLinkFromClip(LPCSTR, LPOLECLIENT, LHCLIENTDOC, LPCSTR,
+      LPOLEOBJECT*, OLEOPT_RENDER, OLECLIPFORMAT);
+    OLESTATUS OleCreateFromFile(LPCSTR, LPOLECLIENT, LPCSTR, LPCSTR,
+      LHCLIENTDOC, LPCSTR, LPOLEOBJECT*, OLEOPT_RENDER, OLECLIPFORMAT);
+    OLESTATUS OleCreateLinkFromFile(LPCSTR, LPOLECLIENT, LPCSTR, LPCSTR,
+      LPCSTR, LHCLIENTDOC, LPCSTR, LPOLEOBJECT*, OLEOPT_RENDER, OLECLIPFORMAT);
+    OLESTATUS OleLoadFromStream(LPOLESTREAM, LPCSTR, LPOLECLIENT, LHCLIENTDOC,
+      LPCSTR, LPOLEOBJECT*);
+    OLESTATUS OleCreate(LPCSTR, LPOLECLIENT, LPCSTR, LHCLIENTDOC, LPCSTR,
+      LPOLEOBJECT*, OLEOPT_RENDER, OLECLIPFORMAT);
+    OLESTATUS OleCreateInvisible(LPCSTR, LPOLECLIENT, LPCSTR, LHCLIENTDOC,
+      LPCSTR, LPOLEOBJECT*, OLEOPT_RENDER, OLECLIPFORMAT, BOOL);
+    OLESTATUS OleCreateFromTemplate(LPCSTR, LPOLECLIENT, LPCSTR, LHCLIENTDOC,
+      LPCSTR, LPOLEOBJECT*, OLEOPT_RENDER, OLECLIPFORMAT);
+    OLESTATUS OleClone(LPOLEOBJECT, LPOLECLIENT, LHCLIENTDOC, LPCSTR,
+      LPOLEOBJECT*);
+    OLESTATUS OleCopyFromLink(LPOLEOBJECT, LPCSTR, LPOLECLIENT, LHCLIENTDOC,
+      LPCSTR, LPOLEOBJECT*);
+    OLESTATUS OleObjectConvert(LPOLEOBJECT, LPCSTR, LPOLECLIENT, LHCLIENTDOC,
+      LPCSTR, LPOLEOBJECT*);
+    OLESTATUS OleRename(LPOLEOBJECT, LPCSTR);
+    OLESTATUS OleQueryName(LPOLEOBJECT, LPSTR, UINT*);
+    OLESTATUS OleRevokeObject(LPOLECLIENT);
+    BOOL OleIsDcMeta(HDC);
+    OLESTATUS OleRegisterClientDoc(LPCSTR, LPCSTR, LONG, LHCLIENTDOC*);
+    OLESTATUS OleRevokeClientDoc(LHCLIENTDOC);
+    OLESTATUS OleRenameClientDoc(LHCLIENTDOC, LPCSTR);
+    OLESTATUS OleRevertClientDoc(LHCLIENTDOC);
+    OLESTATUS OleSavedClientDoc(LHCLIENTDOC);
+    OLESTATUS OleEnumObjects(LHCLIENTDOC, LPOLEOBJECT*);
+    OLESTATUS OleRegisterServer(LPCSTR, LPOLESERVER, LHSERVER*, HINSTANCE,
+      OLE_SERVER_USE);
+    OLESTATUS OleRevokeServer(LHSERVER);
+    OLESTATUS OleBlockServer(LHSERVER);
+    OLESTATUS OleUnblockServer(LHSERVER, BOOL*);
+    OLESTATUS OleLockServer(LPOLEOBJECT, LHSERVER*);
+    OLESTATUS OleUnlockServer(LHSERVER);
+    OLESTATUS OleRegisterServerDoc(LHSERVER, LPCSTR, LPOLESERVERDOC,
+      LHSERVERDOC*);
+    OLESTATUS OleRevokeServerDoc(LHSERVERDOC);
+    OLESTATUS OleRenameServerDoc(LHSERVERDOC, LPCSTR);
+    OLESTATUS OleRevertServerDoc(LHSERVERDOC);
+    OLESTATUS OleSavedServerDoc(LHSERVERDOC);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/ole2.d b/libphobos/libdruntime/core/sys/windows/ole2.d
new file mode 100644
index 00000000000..0f216af547c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/ole2.d
@@ -0,0 +1,118 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_ole2.d)
+ */
+module core.sys.windows.ole2;
+version (Windows):
+pragma(lib, "ole32");
+
+public import core.sys.windows.basetyps, core.sys.windows.objbase, core.sys.windows.oleauto, core.sys.windows.olectlid,
+  core.sys.windows.oleidl, core.sys.windows.unknwn, core.sys.windows.winerror, core.sys.windows.uuid;
+private import core.sys.windows.objfwd, core.sys.windows.objidl, core.sys.windows.windef, core.sys.windows.wtypes;
+private import core.sys.windows.winuser; // for LPMSG
+
+enum E_DRAW = VIEW_E_DRAW;
+
+enum DATA_E_FORMATETC = DV_E_FORMATETC;
+
+enum {
+    OLEIVERB_PRIMARY = 0,
+    OLEIVERB_SHOW = -1,
+    OLEIVERB_OPEN = -2,
+    OLEIVERB_HIDE = -3,
+    OLEIVERB_UIACTIVATE = -4,
+    OLEIVERB_INPLACEACTIVATE = -5,
+    OLEIVERB_DISCARDUNDOSTATE = -6
+}
+
+enum EMBDHLP_INPROC_HANDLER = 0x0000L;
+enum EMBDHLP_INPROC_SERVER  = 0x0001L;
+enum EMBDHLP_CREATENOW      = 0x00000000L;
+enum EMBDHLP_DELAYCREATE    = 0x00010000L;
+
+align(8):
+struct OLESTREAM {
+    LPOLESTREAMVTBL lpstbl;
+}
+alias OLESTREAM* LPOLESTREAM;
+
+extern (Windows) {
+    struct OLESTREAMVTBL {
+        DWORD function (LPOLESTREAM, void*, DWORD) Get;
+        DWORD function (LPOLESTREAM, const(void)*, DWORD) Put;
+    }
+}
+alias OLESTREAMVTBL* LPOLESTREAMVTBL;
+
+extern (Windows) {
+    HRESULT CreateDataAdviseHolder(LPDATAADVISEHOLDER*);
+    DWORD OleBuildVersion();
+    HRESULT ReadClassStg(LPSTORAGE, CLSID*);
+    HRESULT WriteClassStg(LPSTORAGE, REFCLSID);
+    HRESULT ReadClassStm(LPSTREAM, CLSID*);
+    HRESULT WriteClassStm(LPSTREAM, REFCLSID);
+    HRESULT WriteFmtUserTypeStg(LPSTORAGE, CLIPFORMAT, LPOLESTR);
+    HRESULT ReadFmtUserTypeStg(LPSTORAGE, CLIPFORMAT*, LPOLESTR*);
+    HRESULT OleInitialize(PVOID);
+    void OleUninitialize();
+    HRESULT OleQueryLinkFromData(LPDATAOBJECT);
+    HRESULT OleQueryCreateFromData(LPDATAOBJECT);
+    HRESULT OleCreate(REFCLSID, REFIID, DWORD, LPFORMATETC, LPOLECLIENTSITE, LPSTORAGE, PVOID*);
+    HRESULT OleCreateFromData(LPDATAOBJECT, REFIID, DWORD, LPFORMATETC, LPOLECLIENTSITE, LPSTORAGE, PVOID*);
+    HRESULT OleCreateLinkFromData(LPDATAOBJECT, REFIID, DWORD, LPFORMATETC, LPOLECLIENTSITE, LPSTORAGE, PVOID*);
+    HRESULT OleCreateStaticFromData(LPDATAOBJECT, REFIID, DWORD, LPFORMATETC, LPOLECLIENTSITE, LPSTORAGE, PVOID*);
+    HRESULT OleCreateLink(LPMONIKER, REFIID, DWORD, LPFORMATETC, LPOLECLIENTSITE, LPSTORAGE, PVOID*);
+    HRESULT OleCreateLinkToFile(LPCOLESTR, REFIID, DWORD, LPFORMATETC, LPOLECLIENTSITE, LPSTORAGE, PVOID*);
+    HRESULT OleCreateFromFile(REFCLSID, LPCOLESTR, REFIID, DWORD, LPFORMATETC, LPOLECLIENTSITE, LPSTORAGE, PVOID*);
+    HRESULT OleLoad(LPSTORAGE, REFIID, LPOLECLIENTSITE, PVOID*);
+    HRESULT OleSave(LPPERSISTSTORAGE, LPSTORAGE, BOOL);
+    HRESULT OleLoadFromStream(LPSTREAM, REFIID, PVOID*);
+    HRESULT OleSaveToStream(LPPERSISTSTREAM, LPSTREAM);
+    HRESULT OleSetContainedObject(LPUNKNOWN, BOOL);
+    HRESULT OleNoteObjectVisible(LPUNKNOWN, BOOL);
+    HRESULT RegisterDragDrop(HWND, LPDROPTARGET);
+    HRESULT RevokeDragDrop(HWND);
+    HRESULT DoDragDrop(LPDATAOBJECT, LPDROPSOURCE, DWORD, PDWORD);
+    HRESULT OleSetClipboard(LPDATAOBJECT);
+    HRESULT OleGetClipboard(LPDATAOBJECT*);
+    HRESULT OleFlushClipboard();
+    HRESULT OleIsCurrentClipboard(LPDATAOBJECT);
+    HOLEMENU OleCreateMenuDescriptor(HMENU, LPOLEMENUGROUPWIDTHS);
+    HRESULT OleSetMenuDescriptor(HOLEMENU, HWND, HWND, LPOLEINPLACEFRAME, LPOLEINPLACEACTIVEOBJECT);
+    HRESULT OleDestroyMenuDescriptor(HOLEMENU);
+    HRESULT OleTranslateAccelerator(LPOLEINPLACEFRAME, LPOLEINPLACEFRAMEINFO, LPMSG);
+    HANDLE OleDuplicateData(HANDLE, CLIPFORMAT, UINT);
+    HRESULT OleDraw(LPUNKNOWN, DWORD, HDC, LPCRECT);
+    HRESULT OleRun(LPUNKNOWN);
+    BOOL OleIsRunning(LPOLEOBJECT);
+    HRESULT OleLockRunning(LPUNKNOWN, BOOL, BOOL);
+    void ReleaseStgMedium(LPSTGMEDIUM);
+    HRESULT CreateOleAdviseHolder(LPOLEADVISEHOLDER*);
+    HRESULT OleCreateDefaultHandler(REFCLSID, LPUNKNOWN, REFIID, PVOID*);
+    HRESULT OleCreateEmbeddingHelper(REFCLSID, LPUNKNOWN, DWORD, LPCLASSFACTORY, REFIID, PVOID*);
+    BOOL IsAccelerator(HACCEL, int, LPMSG, WORD*);
+    HGLOBAL OleGetIconOfFile(LPOLESTR, BOOL);
+    HGLOBAL OleGetIconOfClass(REFCLSID, LPOLESTR, BOOL);
+    HGLOBAL OleMetafilePictFromIconAndLabel(HICON, LPOLESTR, LPOLESTR, UINT);
+    HRESULT OleRegGetUserType(REFCLSID, DWORD, LPOLESTR*);
+    HRESULT OleRegGetMiscStatus(REFCLSID, DWORD, DWORD*);
+    HRESULT OleRegEnumFormatEtc (REFCLSID, DWORD, LPENUMFORMATETC*);
+    HRESULT OleRegEnumVerbs (REFCLSID, LPENUMOLEVERB*);
+    HRESULT OleConvertOLESTREAMToIStorage(LPOLESTREAM, LPSTORAGE, const(DVTARGETDEVICE)*);
+    HRESULT OleConvertIStorageToOLESTREAM(LPSTORAGE, LPOLESTREAM);
+    HRESULT GetHGlobalFromILockBytes(LPLOCKBYTES, HGLOBAL*);
+    HRESULT CreateILockBytesOnHGlobal(HGLOBAL, BOOL, LPLOCKBYTES*);
+    HRESULT GetHGlobalFromStream(LPSTREAM, HGLOBAL*);
+    HRESULT CreateStreamOnHGlobal(HGLOBAL, BOOL, LPSTREAM*);
+    HRESULT OleDoAutoConvert(LPSTORAGE, LPCLSID);
+    HRESULT OleGetAutoConvert(REFCLSID, LPCLSID);
+    HRESULT OleSetAutoConvert(REFCLSID, REFCLSID);
+    HRESULT GetConvertStg(LPSTORAGE);
+    HRESULT SetConvertStg(LPSTORAGE, BOOL);
+    HRESULT OleConvertIStorageToOLESTREAMEx(LPSTORAGE, CLIPFORMAT, LONG, LONG, DWORD, LPSTGMEDIUM, LPOLESTREAM);
+    HRESULT OleConvertOLESTREAMToIStorageEx(LPOLESTREAM, LPSTORAGE, CLIPFORMAT*, LONG*, LONG*, DWORD*, LPSTGMEDIUM);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/ole2ver.d b/libphobos/libdruntime/core/sys/windows/ole2ver.d
new file mode 100644
index 00000000000..9e3badcaed9
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/ole2ver.d
@@ -0,0 +1,14 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.10
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_ole2ver.d)
+ */
+module core.sys.windows.ole2ver;
+version (Windows):
+
+// These are apparently not documented on the MSDN site
+enum rmm = 23;
+enum rup = 639;
diff --git a/libphobos/libdruntime/core/sys/windows/oleacc.d b/libphobos/libdruntime/core/sys/windows/oleacc.d
new file mode 100644
index 00000000000..f37904c97be
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/oleacc.d
@@ -0,0 +1,216 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_oleacc.d)
+ */
+module core.sys.windows.oleacc;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "oleacc");
+
+private import core.sys.windows.basetyps, core.sys.windows.oaidl, core.sys.windows.unknwn, core.sys.windows.wtypes,
+  core.sys.windows.windef;
+
+enum {
+    DISPID_ACC_PARENT           = -5000,
+    DISPID_ACC_CHILDCOUNT       = -5001,
+    DISPID_ACC_CHILD            = -5002,
+    DISPID_ACC_NAME             = -5003,
+    DISPID_ACC_VALUE            = -5004,
+    DISPID_ACC_DESCRIPTION      = -5005,
+    DISPID_ACC_ROLE             = -5006,
+    DISPID_ACC_STATE            = -5007,
+    DISPID_ACC_HELP             = -5008,
+    DISPID_ACC_HELPTOPIC        = -5009,
+    DISPID_ACC_KEYBOARDSHORTCUT = -5010,
+    DISPID_ACC_FOCUS            = -5011,
+    DISPID_ACC_SELECTION        = -5012,
+    DISPID_ACC_DEFAULTACTION    = -5013,
+    DISPID_ACC_SELECT           = -5014,
+    DISPID_ACC_LOCATION         = -5015,
+    DISPID_ACC_NAVIGATE         = -5016,
+    DISPID_ACC_HITTEST          = -5017,
+    DISPID_ACC_DODEFAULTACTION  = -5018
+}
+
+enum {
+    NAVDIR_UP = 1,
+    NAVDIR_DOWN,
+    NAVDIR_LEFT,
+    NAVDIR_RIGHT,
+    NAVDIR_NEXT,
+    NAVDIR_PREVIOUS,
+    NAVDIR_FIRSTCHILD,
+    NAVDIR_LASTCHILD // = 8
+}
+
+enum {
+    ROLE_SYSTEM_TITLEBAR = 1,
+    ROLE_SYSTEM_MENUBAR,
+    ROLE_SYSTEM_SCROLLBAR,
+    ROLE_SYSTEM_GRIP,
+    ROLE_SYSTEM_SOUND,
+    ROLE_SYSTEM_CURSOR,
+    ROLE_SYSTEM_CARET,
+    ROLE_SYSTEM_ALERT,
+    ROLE_SYSTEM_WINDOW,
+    ROLE_SYSTEM_CLIENT,
+    ROLE_SYSTEM_MENUPOPUP,
+    ROLE_SYSTEM_MENUITEM,
+    ROLE_SYSTEM_TOOLTIP,
+    ROLE_SYSTEM_APPLICATION,
+    ROLE_SYSTEM_DOCUMENT,
+    ROLE_SYSTEM_PANE,
+    ROLE_SYSTEM_CHART,
+    ROLE_SYSTEM_DIALOG,
+    ROLE_SYSTEM_BORDER,
+    ROLE_SYSTEM_GROUPING,
+    ROLE_SYSTEM_SEPARATOR,
+    ROLE_SYSTEM_TOOLBAR,
+    ROLE_SYSTEM_STATUSBAR,
+    ROLE_SYSTEM_TABLE,
+    ROLE_SYSTEM_COLUMNHEADER,
+    ROLE_SYSTEM_ROWHEADER,
+    ROLE_SYSTEM_COLUMN,
+    ROLE_SYSTEM_ROW,
+    ROLE_SYSTEM_CELL,
+    ROLE_SYSTEM_LINK,
+    ROLE_SYSTEM_HELPBALLOON,
+    ROLE_SYSTEM_CHARACTER,
+    ROLE_SYSTEM_LIST,
+    ROLE_SYSTEM_LISTITEM,
+    ROLE_SYSTEM_OUTLINE,
+    ROLE_SYSTEM_OUTLINEITEM,
+    ROLE_SYSTEM_PAGETAB,
+    ROLE_SYSTEM_PROPERTYPAGE,
+    ROLE_SYSTEM_INDICATOR,
+    ROLE_SYSTEM_GRAPHIC,
+    ROLE_SYSTEM_STATICTEXT,
+    ROLE_SYSTEM_TEXT,
+    ROLE_SYSTEM_PUSHBUTTON,
+    ROLE_SYSTEM_CHECKBUTTON,
+    ROLE_SYSTEM_RADIOBUTTON,
+    ROLE_SYSTEM_COMBOBOX,
+    ROLE_SYSTEM_DROPLIST,
+    ROLE_SYSTEM_PROGRESSBAR,
+    ROLE_SYSTEM_DIAL,
+    ROLE_SYSTEM_HOTKEYFIELD,
+    ROLE_SYSTEM_SLIDER,
+    ROLE_SYSTEM_SPINBUTTON,
+    ROLE_SYSTEM_DIAGRAM,
+    ROLE_SYSTEM_ANIMATION,
+    ROLE_SYSTEM_EQUATION,
+    ROLE_SYSTEM_BUTTONDROPDOWN,
+    ROLE_SYSTEM_BUTTONMENU,
+    ROLE_SYSTEM_BUTTONDROPDOWNGRID,
+    ROLE_SYSTEM_WHITESPACE,
+    ROLE_SYSTEM_PAGETABLIST,
+    ROLE_SYSTEM_CLOCK // = 61
+}
+
+enum {
+    STATE_SYSTEM_UNAVAILABLE     = 0x00000001,
+    STATE_SYSTEM_SELECTED        = 0x00000002,
+    STATE_SYSTEM_FOCUSED         = 0x00000004,
+    STATE_SYSTEM_PRESSED         = 0x00000008,
+    STATE_SYSTEM_CHECKED         = 0x00000010,
+    STATE_SYSTEM_MIXED           = 0x00000020,
+    STATE_SYSTEM_READONLY        = 0x00000040,
+    STATE_SYSTEM_HOTTRACKED      = 0x00000080,
+    STATE_SYSTEM_DEFAULT         = 0x00000100,
+    STATE_SYSTEM_EXPANDED        = 0x00000200,
+    STATE_SYSTEM_COLLAPSED       = 0x00000400,
+    STATE_SYSTEM_BUSY            = 0x00000800,
+    STATE_SYSTEM_FLOATING        = 0x00001000,
+    STATE_SYSTEM_MARQUEED        = 0x00002000,
+    STATE_SYSTEM_ANIMATED        = 0x00004000,
+    STATE_SYSTEM_INVISIBLE       = 0x00008000,
+    STATE_SYSTEM_OFFSCREEN       = 0x00010000,
+    STATE_SYSTEM_SIZEABLE        = 0x00020000,
+    STATE_SYSTEM_MOVEABLE        = 0x00040000,
+    STATE_SYSTEM_SELFVOICING     = 0x00080000,
+    STATE_SYSTEM_FOCUSABLE       = 0x00100000,
+    STATE_SYSTEM_SELECTABLE      = 0x00200000,
+    STATE_SYSTEM_LINKED          = 0x00400000,
+    STATE_SYSTEM_TRAVERSED       = 0x00800000,
+    STATE_SYSTEM_MULTISELECTABLE = 0x01000000,
+    STATE_SYSTEM_EXTSELECTABLE   = 0x02000000,
+    STATE_SYSTEM_ALERT_LOW       = 0x04000000,
+    STATE_SYSTEM_ALERT_MEDIUM    = 0x08000000,
+    STATE_SYSTEM_ALERT_HIGH      = 0x10000000,
+    STATE_SYSTEM_VALID           = 0x1fffffff
+}
+
+enum SELFLAG
+{
+    SELFLAG_NONE            = 0,
+    SELFLAG_TAKEFOCUS       = 1,
+    SELFLAG_TAKESELECTION   = 2,
+    SELFLAG_EXTENDSELECTION = 4,
+    SELFLAG_ADDSELECTION    = 8,
+    SELFLAG_REMOVESELECTION = 16
+}
+
+enum SELFLAG_VALID = 0x0000001F;
+
+
+interface IAccessible : IDispatch {
+    HRESULT get_accParent(IDispatch*);
+    HRESULT get_accChildCount(int*);
+    HRESULT get_accChild(VARIANT, IDispatch*);
+    HRESULT get_accName(VARIANT, BSTR*);
+    HRESULT get_accValue(VARIANT, BSTR*);
+    HRESULT get_accDescription(VARIANT, BSTR*);
+    HRESULT get_accRole(VARIANT, VARIANT*);
+    HRESULT get_accState(VARIANT, VARIANT*);
+    HRESULT get_accHelp(VARIANT, BSTR*);
+    HRESULT get_accHelpTopic(BSTR*, VARIANT, int*);
+    HRESULT get_accKeyboardShortcut(VARIANT, BSTR*);
+    HRESULT get_accFocus(VARIANT*);
+    HRESULT get_accSelection(VARIANT*);
+    HRESULT get_accDefaultAction(VARIANT, BSTR*);
+
+    HRESULT accSelect(int, VARIANT);
+    HRESULT accLocation(int*, int*, int*, int*, VARIANT);
+    HRESULT accNavigate(int, VARIANT, VARIANT*);
+    HRESULT accHitTest(int, int, VARIANT*);
+    HRESULT accDoDefaultAction(VARIANT);
+
+    HRESULT put_accName(VARIANT, BSTR);
+    HRESULT put_accValue(VARIANT, BSTR);
+}
+
+alias IAccessible LPACCESSIBLE;
+
+extern (Windows) {
+    HRESULT AccessibleChildren(IAccessible, LONG, LONG, VARIANT*, LONG*);
+    HRESULT AccessibleObjectFromEvent(HWND, DWORD, DWORD, IAccessible, VARIANT*);
+    HRESULT AccessibleObjectFromPoint(POINT, IAccessible*, VARIANT*);
+    HRESULT AccessibleObjectFromWindow(HWND, DWORD, REFIID, void**);
+    HRESULT CreateStdAccessibleObject(HWND, LONG, REFIID, void**);
+    HRESULT CreateStdAccessibleProxyA(HWND, LPCSTR, LONG, REFIID, void**);
+    HRESULT CreateStdAccessibleProxyW(HWND, LPCWSTR, LONG, REFIID, void**);
+
+    void GetOleaccVersionInfo(DWORD*, DWORD*);
+    UINT GetRoleTextA(DWORD, LPSTR, UINT);
+    UINT GetRoleTextW(DWORD, LPWSTR, UINT);
+    UINT GetStateTextA(DWORD, LPSTR, UINT);
+    UINT GetStateTextW(DWORD, LPWSTR, UINT);
+    LRESULT LresultFromObject(REFIID, WPARAM, LPUNKNOWN);
+    HRESULT ObjectFromLresult(LRESULT, REFIID, WPARAM, void**);
+    HRESULT WindowFromAccessibleObject(IAccessible, HWND*);
+}
+
+version(Unicode) {
+    alias CreateStdAccessibleProxyW CreateStdAccessibleProxy;
+    alias GetRoleTextW GetRoleText;
+    alias GetStateTextW GetStateText;
+} else {
+    alias CreateStdAccessibleProxyA CreateStdAccessibleProxy;
+    alias GetRoleTextA GetRoleText;
+    alias GetStateTextA GetStateText;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/oleauto.d b/libphobos/libdruntime/core/sys/windows/oleauto.d
new file mode 100644
index 00000000000..113456c1c81
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/oleauto.d
@@ -0,0 +1,684 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_oleauto.d)
+ */
+module core.sys.windows.oleauto;
+version (Windows):
+pragma(lib, "oleaut32");
+
+import core.sys.windows.oaidl;
+private import core.sys.windows.basetyps, core.sys.windows.unknwn, core.sys.windows.windef, core.sys.windows.wtypes;
+private import core.sys.windows.winbase; // for SYSTEMTIME
+
+align(8):
+enum STDOLE_MAJORVERNUM = 1;
+enum STDOLE_MINORVERNUM = 0;
+enum STDOLE_LCID = 0;
+
+enum VARIANT_NOVALUEPROP = 0x01;
+enum VARIANT_ALPHABOOL = 0x02;
+enum VARIANT_NOUSEOVERRIDE = 0x04;
+enum VARIANT_LOCALBOOL = 0x08;
+
+enum VAR_TIMEVALUEONLY = 0x0001;
+enum VAR_DATEVALUEONLY = 0x0002;
+enum VAR_VALIDDATE = 0x0004;
+enum VAR_CALENDAR_HIJRI = 0x0008;
+enum VAR_LOCALBOOL = 0x0010;
+enum VAR_FORMAT_NOSUBSTITUTE = 0x0020;
+enum VAR_FOURDIGITYEARS = 0x0040;
+enum VAR_CALENDAR_THAI = 0x0080;
+enum VAR_CALENDAR_GREGORIAN = 0x0100;
+
+enum MEMBERID_NIL = DISPID_UNKNOWN;
+enum ID_DEFAULTINST =  -2;
+enum DISPATCH_METHOD = 1;
+enum DISPATCH_PROPERTYGET = 2;
+enum DISPATCH_PROPERTYPUT = 4;
+enum DISPATCH_PROPERTYPUTREF = 8;
+
+//ULONG LHashValOfName(LCID l, OLECHAR* n) { return LHashValOfNameSys(SYSKIND.SYS_WIN32, l, n); }
+
+// DAC: These aren't in the 2003 SDK.
+//MACRO #define WHashValOfLHashVal(h) ((unsigned short)(0x0000ffff&(h)))
+//MACRO #define IsHashValCompatible(h1, h2) ((BOOL)((0x00ff0000&(h1))==(0x00ff0000&(h2))))
+
+enum {
+    ACTIVEOBJECT_STRONG = 0,
+    ACTIVEOBJECT_WEAK   = 1
+}
+
+// DAC: These seem to be irrelevant for D.
+//#define V_UNION(X, Y) ((X)->Y)
+//#define V_VT(X) ((X)->vt)
+//#define V_BOOL(X) V_UNION(X, boolVal)
+//#define V_ISBYREF(X) (V_VT(X)&VT_BYREF)
+//#define V_ISARRAY(X) (V_VT(X)&VT_ARRAY)
+//#define V_ISVECTOR(X) (V_VT(X)&VT_VECTOR)
+//#define V_NONE(X) V_I2(X)
+//#define V_UI1(X) V_UNION(X, bVal)
+//#define V_UI1REF(X) V_UNION(X, pbVal)
+//#define V_I2(X) V_UNION(X, iVal)
+//#define V_UI2(X) V_UNION(X, uiVal)
+//#define V_I2REF(X) V_UNION(X, piVal)
+//#define V_I4(X) V_UNION(X, lVal)
+//#define V_UI4(X) V_UNION(X, ulVal)
+//#define V_I4REF(X) V_UNION(X, plVal)
+//#define V_UI4REF(X) V_UNION(X, pulVal)
+//#define V_I8(X) V_UNION(X, llVal)
+//#define V_UI8(X) V_UNION(X, ullVal)
+//#define V_I8REF(X) V_UNION(X, pllVal)
+//#define V_UI8REF(X) V_UNION(X, pullVal)
+//#define V_R4(X) V_UNION(X, fltVal)
+//#define V_R4REF(X) V_UNION(X, pfltVal)
+//#define V_R8(X) V_UNION(X, dblVal)
+//#define V_R8REF(X) V_UNION(X, pdblVal)
+//#define V_CY(X) V_UNION(X, cyVal)
+//#define V_CYREF(X) V_UNION(X, pcyVal)
+//#define V_DATE(X) V_UNION(X, date)
+//#define V_DATEREF(X) V_UNION(X, pdate)
+//#define V_BSTR(X) V_UNION(X, bstrVal)
+//#define V_BSTRREF(X) V_UNION(X, pbstrVal)
+//#define V_DISPATCH(X) V_UNION(X, pdispVal)
+//#define V_DISPATCHREF(X) V_UNION(X, ppdispVal)
+//#define V_ERROR(X) V_UNION(X, scode)
+//#define V_ERRORREF(X) V_UNION(X, pscode)
+//#define V_BOOLREF(X) V_UNION(X, pboolVal)
+//#define V_UNKNOWN(X) V_UNION(X, punkVal)
+//#define V_UNKNOWNREF(X) V_UNION(X, ppunkVal)
+//#define V_VARIANTREF(X) V_UNION(X, pvarVal)
+//#define V_LPSTR(X) V_UNION(X, pszVal)
+//#define V_LPSTRREF(X) V_UNION(X, ppszVal)
+//#define V_LPWSTR(X) V_UNION(X, pwszVal)
+//#define V_LPWSTRREF(X) V_UNION(X, ppwszVal)
+//#define V_FILETIME(X) V_UNION(X, filetime)
+//#define V_FILETIMEREF(X) V_UNION(X, pfiletime)
+//#define V_BLOB(X) V_UNION(X, blob)
+//#define V_UUID(X) V_UNION(X, puuid)
+//#define V_CLSID(X) V_UNION(X, puuid)
+//#define V_ARRAY(X) V_UNION(X, parray)
+//#define V_ARRAYREF(X) V_UNION(X, pparray)
+//#define V_BYREF(X) V_UNION(X, byref)
+//#define V_DECIMAL(X) ((X)->decVal)
+//#define V_DECIMALREF(X) V_UNION(X, pdecVal)
+//#define V_I1(X) V_UNION(X, cVal)
+
+//#ifdef _WIN64
+//#define V_INT_PTR(X) V_I8(X)
+//#define V_UINT_PTR(X) V_UI8(X)
+//#define V_INT_PTRREF(X) V_I8REF(X)
+//#define V_UINT_PTRREF(X) V_UI8REF(X)
+//#else
+//#define V_INT_PTR(X) V_I4(X)
+//#define V_UINT_PTR(X) V_UI4(X)
+//#define V_INT_PTRREF(X) V_I4REF(X)
+//#define V_UINT_PTRREF(X) V_UI4REF(X)
+//#endif
+
+enum {
+    VARCMP_LT = 0,
+    VARCMP_EQ,
+    VARCMP_GT,
+    VARCMP_NULL // = 3
+}
+
+enum LOCALE_USE_NLS = 0x10000000;
+
+enum VARIANT_NOUSEROVERRIDE     = 0x04;
+enum VARIANT_CALENDAR_HIJRI     = 0x08;
+enum VARIANT_CALENDAR_THAI      = 0x20;
+enum VARIANT_CALENDAR_GREGORIAN = 0x40;
+enum VARIANT_USE_NLS            = 0x80;
+
+enum NUMPRS_LEADING_WHITE  = 0x00001;
+enum NUMPRS_TRAILING_WHITE = 0x00002;
+enum NUMPRS_LEADING_PLUS   = 0x00004;
+enum NUMPRS_TRAILING_PLUS  = 0x00008;
+enum NUMPRS_LEADING_MINUS  = 0x00010;
+enum NUMPRS_TRAILING_MINUS = 0x00020;
+enum NUMPRS_HEX_OCT        = 0x00040;
+enum NUMPRS_PARENS         = 0x00080;
+enum NUMPRS_DECIMAL        = 0x00100;
+enum NUMPRS_THOUSANDS      = 0x00200;
+enum NUMPRS_CURRENCY       = 0x00400;
+enum NUMPRS_EXPONENT       = 0x00800;
+enum NUMPRS_USE_ALL        = 0x01000;
+enum NUMPRS_STD            = 0x01FFF;
+enum NUMPRS_NEG            = 0x10000;
+enum NUMPRS_INEXACT        = 0x20000;
+
+enum VTBIT_I1 = 1 << VARENUM.VT_I1;
+enum VTBIT_UI1 = 1 << VARENUM.VT_UI1;
+enum VTBIT_I2 = 1 << VARENUM.VT_I2;
+enum VTBIT_UI2 = 1 << VARENUM.VT_UI2;
+enum VTBIT_I4 = 1 << VARENUM.VT_I4;
+enum VTBIT_UI4 = 1 << VARENUM.VT_UI4;
+enum VTBIT_I8 = 1 << VARENUM.VT_I8;
+enum VTBIT_UI8 = 1 << VARENUM.VT_UI8;
+enum VTBIT_R4 = 1 << VARENUM.VT_R4;
+enum VTBIT_R8 = 1 << VARENUM.VT_R8;
+enum VTBIT_CY = 1 << VARENUM.VT_CY;
+enum VTBIT_DECIMAL = 1 << VARENUM.VT_DECIMAL;
+
+
+enum REGKIND{
+    REGKIND_DEFAULT,
+    REGKIND_REGISTER,
+    REGKIND_NONE
+}
+
+struct PARAMDATA{
+    OLECHAR* szName;
+    VARTYPE vt;
+}
+alias PARAMDATA* LPPARAMDATA;
+
+struct METHODDATA{
+    OLECHAR* szName;
+    PARAMDATA* ppdata;
+    DISPID dispid;
+    UINT iMeth;
+    CALLCONV cc;
+    UINT cArgs;
+    WORD wFlags;
+    VARTYPE vtReturn;
+}
+alias METHODDATA* LPMETHODDATA;
+
+struct INTERFACEDATA{
+    METHODDATA* pmethdata;
+    UINT cMembers;
+}
+alias INTERFACEDATA* LPINTERFACEDATA;
+
+struct UDATE {
+    SYSTEMTIME st;
+    USHORT wDayOfYear;
+}
+
+struct NUMPARSE {
+    int cDig;
+    uint dwInFlags;
+    uint dwOutFlags;
+    int cchUsed;
+    int nBaseShift;
+    int nPwr10;
+}
+
+
+// DAC: In MinGW, these were declared but not defined in oaidl.
+// The SDK docs suggest they belong in this file instead.
+
+deprecated {  // not actually deprecated, but they aren't converted yet.
+              // (will need to reinstate CreateTypeLib as well)
+    interface ICreateTypeInfo {};
+    interface ICreateTypeInfo2 {};
+    interface ICreateTypeLib {};
+    interface ICreateTypeLib2 {};
+
+    alias ICreateTypeInfo LPCREATETYPEINFO;
+    alias ICreateTypeInfo2 LPCREATETYPEINFO2;
+    alias ICreateTypeLib LPCREATETYPELIB;
+    alias ICreateTypeLib2 LPCREATETYPELIB2;
+}
+
+extern (Windows) {
+    BSTR SysAllocString(const(OLECHAR)*);
+    int SysReAllocString(BSTR*, const(OLECHAR)*);
+    BSTR SysAllocStringLen(const(OLECHAR)*, uint);
+    int SysReAllocStringLen(BSTR*, const(OLECHAR)*, uint);
+    void SysFreeString(BSTR);
+    uint SysStringLen(BSTR);
+    uint SysStringByteLen(BSTR);
+    BSTR SysAllocStringByteLen(const(char)*, uint);
+    int DosDateTimeToVariantTime(ushort, ushort, double*);
+    int VariantTimeToDosDateTime(double, ushort*, ushort*);
+    int VariantTimeToSystemTime(double, LPSYSTEMTIME);
+    int SystemTimeToVariantTime(LPSYSTEMTIME, double*);
+    HRESULT VarDateFromUdate(UDATE*, ULONG, DATE*);
+    HRESULT VarDateFromUdateEx(UDATE*, LCID, ULONG, DATE*);
+    HRESULT VarUdateFromDate(DATE, ULONG, UDATE*);
+    HRESULT SafeArrayAllocDescriptor(uint, SAFEARRAY**);
+    HRESULT SafeArrayAllocData(SAFEARRAY*);
+    SAFEARRAY* SafeArrayCreate(VARTYPE, uint, SAFEARRAYBOUND*);
+    HRESULT SafeArrayDestroyDescriptor(SAFEARRAY*);
+    HRESULT SafeArrayDestroyData(SAFEARRAY*);
+    HRESULT SafeArrayDestroy(SAFEARRAY*);
+    HRESULT SafeArrayRedim(SAFEARRAY*, SAFEARRAYBOUND*);
+    uint SafeArrayGetDim(SAFEARRAY*);
+    uint SafeArrayGetElemsize(SAFEARRAY*);
+    HRESULT SafeArrayGetUBound(SAFEARRAY*, uint, int*);
+    HRESULT SafeArrayGetLBound(SAFEARRAY*, uint, int*);
+    HRESULT SafeArrayLock(SAFEARRAY*);
+    HRESULT SafeArrayUnlock(SAFEARRAY*);
+    HRESULT SafeArrayAccessData(SAFEARRAY*, void**);
+    HRESULT SafeArrayUnaccessData(SAFEARRAY*);
+    HRESULT SafeArrayGetElement(SAFEARRAY*, int*, void*);
+    HRESULT SafeArrayPutElement(SAFEARRAY*, int*, void*);
+    HRESULT SafeArrayCopy(SAFEARRAY*, SAFEARRAY**);
+    HRESULT SafeArrayPtrOfIndex(SAFEARRAY*, int*, void**);
+    SAFEARRAY* SafeArrayCreateVector(VARTYPE, LONG, ULONG);
+    SAFEARRAY* SafeArrayCreateVectorEx(VARTYPE, LONG, ULONG, LPVOID);
+    HRESULT SafeArrayAllocDescriptorEx(VARTYPE, UINT, SAFEARRAY**);
+    HRESULT SafeArrayGetVartype(SAFEARRAY*, VARTYPE*);
+    HRESULT SafeArraySetRecordInfo(SAFEARRAY*, IRecordInfo);
+    HRESULT SafeArrayGetRecordInfo(SAFEARRAY*, IRecordInfo*);
+    HRESULT SafeArraySetIID(SAFEARRAY*, REFGUID);
+    HRESULT SafeArrayGetIID(SAFEARRAY*, GUID*);
+    void VariantInit(VARIANTARG*);
+    HRESULT VariantClear(VARIANTARG*);
+    HRESULT VariantCopy(VARIANTARG*, VARIANTARG*);
+    HRESULT VariantCopyInd(VARIANT*, VARIANTARG*);
+    HRESULT VariantChangeType(VARIANTARG*, VARIANTARG*, ushort, VARTYPE);
+    HRESULT VariantChangeTypeEx(VARIANTARG*, VARIANTARG*, LCID, ushort, VARTYPE);
+    HRESULT VarUI1FromI2(short, ubyte*);
+    HRESULT VarUI1FromI4(int, ubyte*);
+    HRESULT VarUI1FromR4(float, ubyte*);
+    HRESULT VarUI1FromR8(double, ubyte*);
+    HRESULT VarUI1FromCy(CY, ubyte*);
+    HRESULT VarUI1FromDate(DATE, ubyte*);
+    HRESULT VarUI1FromStr(OLECHAR*, LCID, uint, ubyte*);
+    HRESULT VarUI1FromDisp(LPDISPATCH, LCID, ubyte*);
+    HRESULT VarUI1FromBool(VARIANT_BOOL, ubyte*);
+    HRESULT VarI2FromUI1(ubyte, short*);
+    HRESULT VarI2FromI4(int, short*);
+    HRESULT VarI2FromR4(float, short*);
+    HRESULT VarI2FromR8(double, short*);
+    HRESULT VarI2FromCy(CY cyIn, short*);
+    HRESULT VarI2FromDate(DATE, short*);
+    HRESULT VarI2FromStr(OLECHAR*, LCID, uint, short*);
+    HRESULT VarI2FromDisp(LPDISPATCH, LCID, short*);
+    HRESULT VarI2FromBool(VARIANT_BOOL, short*);
+    HRESULT VarI4FromUI1(ubyte, int*);
+    HRESULT VarI4FromI2(short, int*);
+    HRESULT VarI4FromR4(float, int*);
+    HRESULT VarI4FromR8(double, int*);
+    HRESULT VarI4FromCy(CY, int*);
+    HRESULT VarI4FromDate(DATE, int*);
+    HRESULT VarI4FromStr(OLECHAR*, LCID, uint, int*);
+    HRESULT VarI4FromDisp(LPDISPATCH, LCID, int*);
+    HRESULT VarI4FromBool(VARIANT_BOOL, int*);
+    HRESULT VarR4FromUI1(ubyte, float*);
+    HRESULT VarR4FromI2(short, float*);
+    HRESULT VarR4FromI4(int, float*);
+    HRESULT VarR4FromR8(double, float*);
+    HRESULT VarR4FromCy(CY, float*);
+    HRESULT VarR4FromDate(DATE, float*);
+    HRESULT VarR4FromStr(OLECHAR*, LCID, uint, float*);
+    HRESULT VarR4FromDisp(LPDISPATCH, LCID, float*);
+    HRESULT VarR4FromBool(VARIANT_BOOL, float*);
+    HRESULT VarR8FromUI1(ubyte, double*);
+    HRESULT VarR8FromI2(short, double*);
+    HRESULT VarR8FromI4(int, double*);
+    HRESULT VarR8FromR4(float, double*);
+    HRESULT VarR8FromCy(CY, double*);
+    HRESULT VarR8FromDate(DATE, double*);
+    HRESULT VarR8FromStr(OLECHAR*, LCID, uint, double*);
+    HRESULT VarR8FromDisp(LPDISPATCH, LCID, double*);
+    HRESULT VarR8FromBool(VARIANT_BOOL, double*);
+    HRESULT VarR8FromDec(DECIMAL*, double*);
+    HRESULT VarDateFromUI1(ubyte, DATE*);
+    HRESULT VarDateFromI2(short, DATE*);
+    HRESULT VarDateFromI4(int, DATE*);
+    HRESULT VarDateFromR4(float, DATE*);
+    HRESULT VarDateFromR8(double, DATE*);
+    HRESULT VarDateFromCy(CY, DATE*);
+    HRESULT VarDateFromStr(OLECHAR*, LCID, uint, DATE*);
+    HRESULT VarDateFromDisp(LPDISPATCH, LCID, DATE*);
+    HRESULT VarDateFromBool(VARIANT_BOOL, DATE*);
+    HRESULT VarCyFromUI1(ubyte, CY*);
+    HRESULT VarCyFromI2(short, CY*);
+    HRESULT VarCyFromI4(int, CY*);
+    HRESULT VarCyFromR4(float, CY*);
+    HRESULT VarCyFromR8(double, CY*);
+    HRESULT VarCyFromDate(DATE, CY*);
+    HRESULT VarCyFromStr(OLECHAR*, LCID, uint, CY*);
+    HRESULT VarCyFromDisp(LPDISPATCH, LCID, CY*);
+    HRESULT VarCyFromBool(VARIANT_BOOL, CY*);
+    HRESULT VarBstrFromUI1(ubyte, LCID, uint, BSTR*);
+    HRESULT VarBstrFromI2(short, LCID, uint, BSTR*);
+    HRESULT VarBstrFromI4(int, LCID, uint, BSTR*);
+    HRESULT VarBstrFromR4(float, LCID, uint, BSTR*);
+    HRESULT VarBstrFromR8(double, LCID, uint, BSTR*);
+    HRESULT VarBstrFromCy(CY, LCID, uint, BSTR*);
+    HRESULT VarBstrFromDate(DATE, LCID, uint, BSTR*);
+    HRESULT VarBstrFromDisp(LPDISPATCH, LCID, uint, BSTR*);
+    HRESULT VarBstrFromBool(VARIANT_BOOL, LCID, uint, BSTR*);
+    HRESULT VarBoolFromUI1(ubyte, VARIANT_BOOL*);
+    HRESULT VarBoolFromI2(short, VARIANT_BOOL*);
+    HRESULT VarBoolFromI4(int, VARIANT_BOOL*);
+    HRESULT VarBoolFromR4(float, VARIANT_BOOL*);
+    HRESULT VarBoolFromR8(double, VARIANT_BOOL*);
+    HRESULT VarBoolFromDate(DATE, VARIANT_BOOL*);
+    HRESULT VarBoolFromCy(CY, VARIANT_BOOL*);
+    HRESULT VarBoolFromStr(OLECHAR*, LCID, uint, VARIANT_BOOL*);
+    HRESULT VarBoolFromDisp(LPDISPATCH, LCID, VARIANT_BOOL*);
+    HRESULT VarDecFromR8(double, DECIMAL*);
+    ULONG LHashValOfNameSysA(SYSKIND, LCID, const(char)*);
+    ULONG LHashValOfNameSys(SYSKIND, LCID, const(OLECHAR)*);
+    HRESULT LoadTypeLib(const(OLECHAR)*, LPTYPELIB*);
+    HRESULT LoadTypeLibEx(LPCOLESTR, REGKIND, LPTYPELIB*);
+    HRESULT LoadRegTypeLib(REFGUID, WORD, WORD, LCID, LPTYPELIB*);
+    HRESULT QueryPathOfRegTypeLib(REFGUID, ushort, ushort, LCID, LPBSTR);
+    HRESULT RegisterTypeLib(LPTYPELIB, OLECHAR*, OLECHAR*);
+    HRESULT UnRegisterTypeLib(REFGUID, WORD, WORD, LCID, SYSKIND);
+    // not actually deprecated, but depends on unconverted ICreateTypeLib
+    deprecated HRESULT CreateTypeLib(SYSKIND, const(OLECHAR)*, LPCREATETYPELIB*);
+    HRESULT DispGetParam(DISPPARAMS*, UINT, VARTYPE, VARIANT*, UINT*);
+    HRESULT DispGetIDsOfNames(LPTYPEINFO, OLECHAR**, UINT, DISPID*);
+    HRESULT DispInvoke(void*, LPTYPEINFO, DISPID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*);
+    HRESULT CreateDispTypeInfo(INTERFACEDATA*, LCID, LPTYPEINFO*);
+    HRESULT CreateStdDispatch(IUnknown, void*, LPTYPEINFO, IUnknown*);
+    HRESULT RegisterActiveObject(IUnknown, REFCLSID, DWORD, DWORD*);
+    HRESULT RevokeActiveObject(DWORD, void*);
+    HRESULT GetActiveObject(REFCLSID, void*, IUnknown*);
+    HRESULT SetErrorInfo(uint, LPERRORINFO);
+    HRESULT GetErrorInfo(uint, LPERRORINFO*);
+    HRESULT CreateErrorInfo(LPCREATEERRORINFO*);
+    uint OaBuildVersion();
+    HRESULT VectorFromBstr (BSTR, SAFEARRAY**);
+    HRESULT BstrFromVector (SAFEARRAY*, BSTR*);
+    HRESULT VarParseNumFromStr(OLECHAR*, LCID, ULONG, NUMPARSE*, BYTE*);
+    HRESULT VarNumFromParseNum(NUMPARSE*, BYTE*, ULONG, VARIANT*);
+
+    HRESULT VarAdd(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarSub(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarMul(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarDiv(LPVARIANT, LPVARIANT, LPVARIANT);
+
+    HRESULT VarUI1FromI2(SHORT, BYTE*);
+    HRESULT VarUI1FromI4(LONG, BYTE*);
+    HRESULT VarUI1FromI8(LONG64, BYTE*);
+    HRESULT VarUI1FromR4(FLOAT, BYTE*);
+    HRESULT VarUI1FromR8(DOUBLE, BYTE*);
+    HRESULT VarUI1FromDate(DATE, BYTE*);
+    HRESULT VarUI1FromBool(VARIANT_BOOL, BYTE*);
+    HRESULT VarUI1FromI1(byte, BYTE*);
+    HRESULT VarUI1FromUI2(USHORT, BYTE*);
+    HRESULT VarUI1FromUI4(ULONG, BYTE*);
+    HRESULT VarUI1FromUI8(ULONG64, BYTE*);
+    HRESULT VarUI1FromStr(OLECHAR*, LCID, ULONG, BYTE*);
+    HRESULT VarUI1FromCy(CY, BYTE*);
+    HRESULT VarUI1FromDec(DECIMAL*, BYTE*);
+    HRESULT VarUI1FromDisp(IDispatch, LCID, BYTE*);
+
+    HRESULT VarI2FromUI1(BYTE, SHORT*);
+    HRESULT VarI2FromI4(LONG, SHORT*);
+    HRESULT VarI2FromI8(LONG64, SHORT*);
+    HRESULT VarI2FromR4(FLOAT, SHORT*);
+    HRESULT VarI2FromR8(DOUBLE, SHORT*);
+    HRESULT VarI2FromDate(DATE, SHORT*);
+    HRESULT VarI2FromBool(VARIANT_BOOL, SHORT*);
+    HRESULT VarI2FromI1(byte, SHORT*);
+    HRESULT VarI2FromUI2(USHORT, SHORT*);
+    HRESULT VarI2FromUI4(ULONG, SHORT*);
+    HRESULT VarI2FromUI8(ULONG64, SHORT*);
+    HRESULT VarI2FromStr(OLECHAR*, LCID, ULONG, SHORT*);
+    HRESULT VarI2FromCy(CY, SHORT*);
+    HRESULT VarI2FromDec(DECIMAL*, SHORT*);
+    HRESULT VarI2FromDisp(IDispatch, LCID, SHORT*);
+
+    HRESULT VarI4FromUI1(BYTE, LONG*);
+    HRESULT VarI4FromI2(SHORT, LONG*);
+    HRESULT VarI4FromI8(LONG64, LONG*);
+    HRESULT VarI4FromR4(FLOAT, LONG*);
+    HRESULT VarI4FromR8(DOUBLE, LONG*);
+    HRESULT VarI4FromDate(DATE, LONG*);
+    HRESULT VarI4FromBool(VARIANT_BOOL, LONG*);
+    HRESULT VarI4FromI1(byte, LONG*);
+    HRESULT VarI4FromUI2(USHORT, LONG*);
+    HRESULT VarI4FromUI4(ULONG, LONG*);
+    HRESULT VarI4FromUI8(ULONG64, LONG*);
+    HRESULT VarI4FromStr(OLECHAR*, LCID, ULONG, LONG*);
+    HRESULT VarI4FromCy(CY, LONG*);
+    HRESULT VarI4FromDec(DECIMAL*, LONG*);
+    HRESULT VarI4FromDisp(IDispatch, LCID, LONG*);
+
+    HRESULT VarI8FromUI1(BYTE, LONG64*);
+    HRESULT VarI8FromI2(SHORT, LONG64*);
+    HRESULT VarI8FromI4(LONG, LONG64*);
+    HRESULT VarI8FromR4(FLOAT, LONG64*);
+    HRESULT VarI8FromR8(DOUBLE, LONG64*);
+    HRESULT VarI8FromDate(DATE, LONG64*);
+    HRESULT VarI8FromStr(OLECHAR*, LCID, ULONG, LONG64*);
+    HRESULT VarI8FromBool(VARIANT_BOOL, LONG64*);
+    HRESULT VarI8FromI1(byte, LONG64*);
+    HRESULT VarI8FromUI2(USHORT, LONG64*);
+    HRESULT VarI8FromUI4(ULONG, LONG64*);
+    HRESULT VarI8FromUI8(ULONG64, LONG64*);
+    HRESULT VarI8FromDec(DECIMAL* pdecIn, LONG64*);
+    HRESULT VarI8FromInt(INT intIn, LONG64*);
+    HRESULT VarI8FromCy(CY, LONG64*);
+    HRESULT VarI8FromDisp(IDispatch, LCID, LONG64*);
+
+    HRESULT VarR4FromUI1(BYTE, FLOAT*);
+    HRESULT VarR4FromI2(SHORT, FLOAT*);
+    HRESULT VarR4FromI4(LONG, FLOAT*);
+    HRESULT VarR4FromI8(LONG64, FLOAT*);
+    HRESULT VarR4FromR8(DOUBLE, FLOAT*);
+    HRESULT VarR4FromDate(DATE, FLOAT*);
+    HRESULT VarR4FromBool(VARIANT_BOOL, FLOAT*);
+    HRESULT VarR4FromI1(byte, FLOAT*);
+    HRESULT VarR4FromUI2(USHORT, FLOAT*);
+    HRESULT VarR4FromUI4(ULONG, FLOAT*);
+    HRESULT VarR4FromUI8(ULONG64, FLOAT*);
+    HRESULT VarR4FromStr(OLECHAR*, LCID, ULONG, FLOAT*);
+    HRESULT VarR4FromCy(CY, FLOAT*);
+    HRESULT VarR4FromDec(DECIMAL*, FLOAT*);
+    HRESULT VarR4FromDisp(IDispatch, LCID, FLOAT*);
+
+    HRESULT VarR8FromUI1(BYTE, double*);
+    HRESULT VarR8FromI2(SHORT, double*);
+    HRESULT VarR8FromI4(LONG, double*);
+    HRESULT VarR8FromI8(LONG64, double*);
+    HRESULT VarR8FromR4(FLOAT, double*);
+    HRESULT VarR8FromDate(DATE, double*);
+    HRESULT VarR8FromBool(VARIANT_BOOL, double*);
+    HRESULT VarR8FromI1(byte, double*);
+    HRESULT VarR8FromUI2(USHORT, double*);
+    HRESULT VarR8FromUI4(ULONG, double*);
+    HRESULT VarR8FromUI8(ULONG64, double*);
+    HRESULT VarR8FromStr(OLECHAR*, LCID, ULONG, double*);
+    HRESULT VarR8FromCy(CY, double*);
+    HRESULT VarR8FromDec(DECIMAL*, double*);
+    HRESULT VarR8FromDisp(IDispatch, LCID, double*);
+
+    HRESULT VarDateFromUI1(BYTE, DATE*);
+    HRESULT VarDateFromI2(SHORT, DATE*);
+    HRESULT VarDateFromI4(LONG, DATE*);
+    HRESULT VarDateFromI8(LONG64, DATE*);
+    HRESULT VarDateFromR4(FLOAT, DATE*);
+    HRESULT VarDateFromR8(DOUBLE, DATE*);
+    HRESULT VarDateFromStr(OLECHAR*, LCID, ULONG, DATE*);
+    HRESULT VarDateFromI1(byte, DATE*);
+    HRESULT VarDateFromUI2(USHORT, DATE*);
+    HRESULT VarDateFromUI4(ULONG, DATE*);
+    HRESULT VarDateFromUI8(ULONG64, DATE*);
+    HRESULT VarDateFromBool(VARIANT_BOOL, DATE*);
+    HRESULT VarDateFromCy(CY, DATE*);
+    HRESULT VarDateFromDec(DECIMAL*, DATE*);
+    HRESULT VarDateFromDisp(IDispatch, LCID, DATE*);
+
+    HRESULT VarCyFromUI1(BYTE, CY*);
+    HRESULT VarCyFromI2(SHORT sIn, CY*);
+    HRESULT VarCyFromI4(LONG, CY*);
+    HRESULT VarCyFromI8(LONG64, CY*);
+    HRESULT VarCyFromR4(FLOAT, CY*);
+    HRESULT VarCyFromR8(DOUBLE, CY*);
+    HRESULT VarCyFromDate(DATE, CY*);
+    HRESULT VarCyFromStr(OLECHAR*, LCID, ULONG, CY*);
+    HRESULT VarCyFromBool(VARIANT_BOOL, CY*);
+    HRESULT VarCyFromI1(byte, CY*);
+    HRESULT VarCyFromUI2(USHORT, CY*);
+    HRESULT VarCyFromUI4(ULONG, CY*);
+    HRESULT VarCyFromUI8(ULONG64, CY*);
+    HRESULT VarCyFromDec(DECIMAL*, CY*);
+    HRESULT VarCyFromStr(OLECHAR*, LCID, ULONG, CY*);
+    HRESULT VarCyFromDisp(IDispatch, LCID, CY*);
+
+    HRESULT VarBstrFromUI1(BYTE, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromI2(SHORT, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromI4(LONG, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromI8(LONG64, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromR4(FLOAT, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromR8(DOUBLE, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromDate(DATE, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromBool(VARIANT_BOOL, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromI1(byte, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromUI2(USHORT, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromUI8(ULONG64, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromUI4(ULONG, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromCy(CY, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromDec(DECIMAL*, LCID, ULONG, BSTR*);
+    HRESULT VarBstrFromDisp(IDispatch, LCID, ULONG, BSTR*);
+
+    HRESULT VarBoolFromUI1(BYTE, VARIANT_BOOL*);
+    HRESULT VarBoolFromI2(SHORT, VARIANT_BOOL*);
+    HRESULT VarBoolFromI4(LONG, VARIANT_BOOL*);
+    HRESULT VarBoolFromI8(LONG64, VARIANT_BOOL*);
+    HRESULT VarBoolFromR4(FLOAT, VARIANT_BOOL*);
+    HRESULT VarBoolFromR8(DOUBLE, VARIANT_BOOL*);
+    HRESULT VarBoolFromDate(DATE, VARIANT_BOOL*);
+    HRESULT VarBoolFromStr(OLECHAR*, LCID, ULONG, VARIANT_BOOL*);
+    HRESULT VarBoolFromI1(byte, VARIANT_BOOL*);
+    HRESULT VarBoolFromUI2(USHORT, VARIANT_BOOL*);
+    HRESULT VarBoolFromUI4(ULONG, VARIANT_BOOL*);
+    HRESULT VarBoolFromUI8(ULONG64, VARIANT_BOOL*);
+    HRESULT VarBoolFromCy(CY, VARIANT_BOOL*);
+    HRESULT VarBoolFromDec(DECIMAL*, VARIANT_BOOL*);
+    HRESULT VarBoolFromDisp(IDispatch, LCID, VARIANT_BOOL*);
+
+    HRESULT VarI1FromUI1(BYTE, byte*);
+    HRESULT VarI1FromI2(SHORT, byte*);
+    HRESULT VarI1FromI4(LONG, byte*);
+    HRESULT VarI1FromI8(LONG64, byte*);
+    HRESULT VarI1FromR4(FLOAT, byte*);
+    HRESULT VarI1FromR8(DOUBLE, byte*);
+    HRESULT VarI1FromDate(DATE, byte*);
+    HRESULT VarI1FromStr(OLECHAR*, LCID, ULONG, byte*);
+    HRESULT VarI1FromBool(VARIANT_BOOL, byte*);
+    HRESULT VarI1FromUI2(USHORT, byte*);
+    HRESULT VarI1FromUI4(ULONG, byte*);
+    HRESULT VarI1FromUI8(ULONG64, byte*);
+    HRESULT VarI1FromCy(CY, byte*);
+    HRESULT VarI1FromDec(DECIMAL*, byte*);
+    HRESULT VarI1FromDisp(IDispatch, LCID, byte*);
+
+    HRESULT VarUI2FromUI1(BYTE, USHORT*);
+    HRESULT VarUI2FromI2(SHORT, USHORT*);
+    HRESULT VarUI2FromI4(LONG, USHORT*);
+    HRESULT VarUI2FromI8(LONG64, USHORT*);
+    HRESULT VarUI2FromR4(FLOAT, USHORT*);
+    HRESULT VarUI2FromR8(DOUBLE, USHORT*);
+    HRESULT VarUI2FromDate(DATE, USHORT*);
+    HRESULT VarUI2FromStr(OLECHAR*, LCID, ULONG, USHORT*);
+    HRESULT VarUI2FromBool(VARIANT_BOOL, USHORT*);
+    HRESULT VarUI2FromI1(byte, USHORT*);
+    HRESULT VarUI2FromUI4(ULONG, USHORT*);
+    HRESULT VarUI2FromUI8(ULONG64, USHORT*);
+    HRESULT VarUI2FromCy(CY, USHORT*);
+    HRESULT VarUI2FromDec(DECIMAL*, USHORT*);
+    HRESULT VarUI2FromDisp(IDispatch, LCID, USHORT*);
+
+    HRESULT VarUI4FromStr(OLECHAR*, LCID, ULONG, ULONG*);
+    HRESULT VarUI4FromUI1(BYTE, ULONG*);
+    HRESULT VarUI4FromI2(SHORT, ULONG*);
+    HRESULT VarUI4FromI4(LONG, ULONG*);
+    HRESULT VarUI4FromI8(LONG64, ULONG*);
+    HRESULT VarUI4FromR4(FLOAT, ULONG*);
+    HRESULT VarUI4FromR8(DOUBLE, ULONG*);
+    HRESULT VarUI4FromDate(DATE, ULONG*);
+    HRESULT VarUI4FromBool(VARIANT_BOOL, ULONG*);
+    HRESULT VarUI4FromI1(byte, ULONG*);
+    HRESULT VarUI4FromUI2(USHORT, ULONG*);
+    HRESULT VarUI4FromUI8(ULONG64, ULONG*);
+    HRESULT VarUI4FromCy(CY, ULONG*);
+    HRESULT VarUI4FromDec(DECIMAL*, ULONG*);
+    HRESULT VarUI4FromDisp(IDispatch, LCID, ULONG*);
+
+    HRESULT VarUI8FromUI1(BYTE, ULONG64*);
+    HRESULT VarUI8FromI2(SHORT, ULONG64*);
+    HRESULT VarUI8FromI4(LONG, ULONG64*);
+    HRESULT VarUI8FromI8(LONG64, ULONG64*);
+    HRESULT VarUI8FromR4(FLOAT, ULONG64*);
+    HRESULT VarUI8FromR8(DOUBLE, ULONG64*);
+    HRESULT VarUI8FromDate(DATE, ULONG64*);
+    HRESULT VarUI8FromStr(OLECHAR*, LCID, ULONG, ULONG64*);
+    HRESULT VarUI8FromBool(VARIANT_BOOL, ULONG64*);
+    HRESULT VarUI8FromI1(byte, ULONG64*);
+    HRESULT VarUI8FromUI2(USHORT, ULONG64*);
+    HRESULT VarUI8FromUI4(ULONG, ULONG64*);
+    HRESULT VarUI8FromDec(DECIMAL*, ULONG64*);
+    HRESULT VarUI8FromInt(INT, ULONG64*);
+    HRESULT VarUI8FromCy(CY, ULONG64*);
+    HRESULT VarUI8FromDisp(IDispatch, LCID, ULONG64*);
+
+    HRESULT VarDecFromUI1(BYTE, DECIMAL*);
+    HRESULT VarDecFromI2(SHORT, DECIMAL*);
+    HRESULT VarDecFromI4(LONG, DECIMAL*);
+    HRESULT VarDecFromI8(LONG64, DECIMAL*);
+    HRESULT VarDecFromR4(FLOAT, DECIMAL*);
+    HRESULT VarDecFromR8(DOUBLE, DECIMAL*);
+    HRESULT VarDecFromDate(DATE, DECIMAL*);
+    HRESULT VarDecFromStr(OLECHAR*, LCID, ULONG, DECIMAL*);
+    HRESULT VarDecFromBool(VARIANT_BOOL, DECIMAL*);
+    HRESULT VarDecFromI1(byte, DECIMAL*);
+    HRESULT VarDecFromUI2(USHORT, DECIMAL*);
+    HRESULT VarDecFromUI4(ULONG, DECIMAL*);
+    HRESULT VarDecFromUI8(ULONG64, DECIMAL*);
+    HRESULT VarDecFromCy(CY, DECIMAL*);
+    HRESULT VarDecFromDisp(IDispatch, LCID, DECIMAL*);
+
+    HRESULT VarDecNeg(const(DECIMAL)*, DECIMAL*);
+    HRESULT VarR4CmpR8(float, double);
+    HRESULT VarR8Pow(double, double, double*);
+    HRESULT VarR8Round(double, int, double*);
+    HRESULT VarDecAbs(const(DECIMAL)*, DECIMAL*);
+    HRESULT VarDecAdd(const(DECIMAL)*, const(DECIMAL)*, DECIMAL*);
+    HRESULT VarDecCmp(const(DECIMAL)*, const(DECIMAL)*);
+    HRESULT VarDecCmpR8(const(DECIMAL)*, DOUBLE);
+    HRESULT VarDecDiv(const(DECIMAL)*, const(DECIMAL)*, DECIMAL*);
+    HRESULT VarDecFix(const(DECIMAL)*, DECIMAL*);
+    HRESULT VarDecInt(const(DECIMAL)*, DECIMAL*);
+    HRESULT VarDecMul(const(DECIMAL)*, const(DECIMAL)*, DECIMAL*);
+    HRESULT VarDecRound(const(DECIMAL)*, int, DECIMAL*);
+    HRESULT VarDecSub(const(DECIMAL)*, const(DECIMAL)*, DECIMAL*);
+    HRESULT VarCyAbs(CY, CY*);
+    HRESULT VarCyAdd(CY, CY, CY*);
+    HRESULT VarCyCmp(CY, CY);
+    HRESULT VarCyCmpR8(CY, DOUBLE);
+    HRESULT VarCyFix(CY, CY*);
+    HRESULT VarCyInt(CY, CY*);
+    HRESULT VarCyMul(CY, CY, CY*);
+    HRESULT VarCyMulI4(CY, LONG, CY*);
+    HRESULT VarCyMulI8(CY, LONG64, CY*);
+    HRESULT VarCyNeg(CY, CY*);
+    HRESULT VarCyRound(CY, INT, CY*);
+    HRESULT VarCySub(CY, CY, CY*);
+    HRESULT VarAdd(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarAnd(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarCat(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarDiv(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarEqv(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarIdiv(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarImp(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarMod(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarMul(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarOr(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarPow(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarSub(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarXor(LPVARIANT, LPVARIANT, LPVARIANT);
+    HRESULT VarAbs(LPVARIANT, LPVARIANT);
+    HRESULT VarFix(LPVARIANT, LPVARIANT);
+    HRESULT VarInt(LPVARIANT, LPVARIANT);
+    HRESULT VarNeg(LPVARIANT, LPVARIANT);
+    HRESULT VarNot(LPVARIANT, LPVARIANT);
+    HRESULT VarRound(LPVARIANT, int, LPVARIANT);
+    HRESULT VarCmp(LPVARIANT, LPVARIANT, LCID, ULONG);
+    HRESULT VarBstrCmp(BSTR, BSTR, LCID, ULONG);
+    HRESULT VarBstrCat(BSTR, BSTR, BSTR*);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/olectl.d b/libphobos/libdruntime/core/sys/windows/olectl.d
new file mode 100644
index 00000000000..a3368ff2f41
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/olectl.d
@@ -0,0 +1,398 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_olectl.d)
+ */
+module core.sys.windows.olectl;
+version (Windows):
+
+// In conversion from MinGW, the following was deleted:
+//#define FONTSIZE(n) {n##0000, 0}
+
+import core.sys.windows.ocidl, core.sys.windows.olectlid;
+private import core.sys.windows.basetyps, core.sys.windows.oaidl, core.sys.windows.oleauto, core.sys.windows.unknwn,
+  core.sys.windows.windef, core.sys.windows.wingdi, core.sys.windows.winuser, core.sys.windows.wtypes;
+private import core.sys.windows.ntdef;     // for NTSTATUS
+private import core.sys.windows.objfwd;    // for LPSTREAM
+private import core.sys.windows.winerror;  // for SCODE
+
+
+private {
+    // These replace C macros.
+    template ITF_ERROR_SCODE_FOR_D(int c)
+    {
+enum SCODE ITF_ERROR_SCODE_FOR_D
+          = (SEVERITY_ERROR << 31) | (FACILITY_ITF << 16) | c;
+    }
+
+    template ITF_SUCCESS_SCODE_FOR_D(int c)
+    {
+enum SCODE ITF_SUCCESS_SCODE_FOR_D
+          = (SEVERITY_SUCCESS << 31) | (FACILITY_ITF << 16) | c;
+    }
+
+    template STD_CTL_SCODE(int c)
+    {
+enum SCODE STD_CTL_SCODE
+          = (SEVERITY_ERROR << 31) | (FACILITY_CONTROL << 16) | c;
+    }
+}
+
+enum : SCODE {
+    CTL_E_ILLEGALFUNCTIONCALL       = STD_CTL_SCODE!(5),
+    CTL_E_OVERFLOW                  = STD_CTL_SCODE!(6),
+    CTL_E_OUTOFMEMORY               = STD_CTL_SCODE!(7),
+    CTL_E_DIVISIONBYZERO            = STD_CTL_SCODE!(11),
+    CTL_E_OUTOFSTRINGSPACE          = STD_CTL_SCODE!(14),
+    CTL_E_OUTOFSTACKSPACE           = STD_CTL_SCODE!(28),
+    CTL_E_BADFILENAMEORNUMBER       = STD_CTL_SCODE!(52),
+    CTL_E_FILENOTFOUND              = STD_CTL_SCODE!(53),
+    CTL_E_BADFILEMODE               = STD_CTL_SCODE!(54),
+    CTL_E_FILEALREADYOPEN           = STD_CTL_SCODE!(55),
+    CTL_E_DEVICEIOERROR             = STD_CTL_SCODE!(57),
+    CTL_E_FILEALREADYEXISTS         = STD_CTL_SCODE!(58),
+    CTL_E_BADRECORDLENGTH           = STD_CTL_SCODE!(59),
+    CTL_E_DISKFULL                  = STD_CTL_SCODE!(61),
+    CTL_E_BADRECORDNUMBER           = STD_CTL_SCODE!(63),
+    CTL_E_BADFILENAME               = STD_CTL_SCODE!(64),
+    CTL_E_TOOMANYFILES              = STD_CTL_SCODE!(67),
+    CTL_E_DEVICEUNAVAILABLE         = STD_CTL_SCODE!(68),
+    CTL_E_PERMISSIONDENIED          = STD_CTL_SCODE!(70),
+    CTL_E_DISKNOTREADY              = STD_CTL_SCODE!(71),
+    CTL_E_PATHFILEACCESSERROR       = STD_CTL_SCODE!(75),
+    CTL_E_PATHNOTFOUND              = STD_CTL_SCODE!(76),
+    CTL_E_INVALIDPATTERNSTRING      = STD_CTL_SCODE!(93),
+    CTL_E_INVALIDUSEOFNULL          = STD_CTL_SCODE!(94),
+    CTL_E_INVALIDFILEFORMAT         = STD_CTL_SCODE!(321),
+    CTL_E_INVALIDPROPERTYVALUE      = STD_CTL_SCODE!(380),
+    CTL_E_INVALIDPROPERTYARRAYINDEX = STD_CTL_SCODE!(381),
+    CTL_E_SETNOTSUPPORTEDATRUNTIME  = STD_CTL_SCODE!(382),
+    CTL_E_SETNOTSUPPORTED           = STD_CTL_SCODE!(383),
+    CTL_E_NEEDPROPERTYARRAYINDEX    = STD_CTL_SCODE!(385),
+    CTL_E_SETNOTPERMITTED           = STD_CTL_SCODE!(387),
+    CTL_E_GETNOTSUPPORTEDATRUNTIME  = STD_CTL_SCODE!(393),
+    CTL_E_GETNOTSUPPORTED           = STD_CTL_SCODE!(394),
+    CTL_E_PROPERTYNOTFOUND          = STD_CTL_SCODE!(422),
+    CTL_E_INVALIDCLIPBOARDFORMAT    = STD_CTL_SCODE!(460),
+    CTL_E_INVALIDPICTURE            = STD_CTL_SCODE!(481),
+    CTL_E_PRINTERERROR              = STD_CTL_SCODE!(482),
+    CTL_E_CANTSAVEFILETOTEMP        = STD_CTL_SCODE!(735),
+    CTL_E_SEARCHTEXTNOTFOUND        = STD_CTL_SCODE!(744),
+    CTL_E_REPLACEMENTSTOOLONG       = STD_CTL_SCODE!(746),
+    CTL_E_CUSTOM_FIRST              = STD_CTL_SCODE!(600)
+}
+
+enum SCODE CLASS_E_NOTLICENSED = CLASSFACTORY_E_FIRST+2;
+
+enum : SCODE {
+    CONNECT_E_FIRST           = ITF_ERROR_SCODE_FOR_D!(0x200),
+    CONNECT_E_LAST            = ITF_ERROR_SCODE_FOR_D!(0x20F),
+    CONNECT_S_FIRST           = ITF_SUCCESS_SCODE_FOR_D!(0x200),
+    CONNECT_S_LAST            = ITF_SUCCESS_SCODE_FOR_D!(0x20F),
+    CONNECT_E_NOCONNECTION    = CONNECT_E_FIRST + 0,
+    CONNECT_E_ADVISELIMIT     = CONNECT_E_FIRST + 1,
+    CONNECT_E_CANNOTCONNECT   = CONNECT_E_FIRST + 2,
+    CONNECT_E_OVERRIDDEN      = CONNECT_E_FIRST + 3,
+
+    SELFREG_E_FIRST           = ITF_ERROR_SCODE_FOR_D!(0x200),
+    SELFREG_E_LAST            = ITF_ERROR_SCODE_FOR_D!(0x20F),
+    SELFREG_S_FIRST           = ITF_SUCCESS_SCODE_FOR_D!(0x200),
+    SELFREG_S_LAST            = ITF_SUCCESS_SCODE_FOR_D!(0x20F),
+    SELFREG_E_TYPELIB         = SELFREG_E_FIRST + 0,
+    SELFREG_E_CLASS           = SELFREG_E_FIRST + 1,
+
+    PERPROP_E_FIRST           = ITF_ERROR_SCODE_FOR_D!(0x200),
+    PERPROP_E_LAST            = ITF_ERROR_SCODE_FOR_D!(0x20F),
+    PERPROP_S_FIRST           = ITF_SUCCESS_SCODE_FOR_D!(0x200),
+    PERPROP_S_LAST            = ITF_SUCCESS_SCODE_FOR_D!(0x20F),
+    PERPROP_E_NOPAGEAVAILABLE = PERPROP_E_FIRST
+}
+
+enum {
+    OLEMISC_RECOMPOSEONRESIZE            = 0x1,
+    OLEMISC_ONLYICONIC                   = 0x2,
+    OLEMISC_INSERTNOTREPLACE             = 0x4,
+    OLEMISC_STATIC                       = 0x8,
+    OLEMISC_CANTLINKINSIDE               = 0x10,
+    OLEMISC_CANLINKBYOLE1                = 0x20,
+    OLEMISC_ISLINKOBJECT                 = 0x40,
+    OLEMISC_INSIDEOUT                    = 0x80,
+    OLEMISC_ACTIVATEWHENVISIBLE          = 0x100,
+    OLEMISC_RENDERINGISDEVICEINDEPENDENT = 0x200,
+    OLEMISC_INVISIBLEATRUNTIME           = 0x400,
+    OLEMISC_ALWAYSRUN                    = 0x800,
+    OLEMISC_ACTSLIKEBUTTON               = 0x1000,
+    OLEMISC_ACTSLIKELABEL                = 0x2000,
+    OLEMISC_NOUIACTIVATE                 = 0x4000,
+    OLEMISC_ALIGNABLE                    = 0x8000,
+    OLEMISC_SIMPLEFRAME                  = 0x10000,
+    OLEMISC_SETCLIENTSITEFIRST           = 0x20000,
+    OLEMISC_IMEMODE                      = 0x40000,
+    OLEMISC_IGNOREACTIVATEWHENVISIBLE    = 0x80000,
+    OLEMISC_WANTSTOMENUMERGE             = 0x100000,
+    OLEMISC_SUPPORTSMULTILEVELUNDO       = 0x200000
+}
+enum OLEIVERB_PROPERTIES = -7;
+
+enum VT_STREAMED_PROPSET = 73;
+enum VT_STORED_PROPSET = 74;
+enum VT_BLOB_PROPSET = 75;
+enum VT_VERBOSE_ENUM = 76;
+enum VT_COLOR = VARENUM.VT_I4;
+enum VT_XPOS_PIXELS = VARENUM.VT_I4;
+enum VT_YPOS_PIXELS = VARENUM.VT_I4;
+enum VT_XSIZE_PIXELS = VARENUM.VT_I4;
+enum VT_YSIZE_PIXELS = VARENUM.VT_I4;
+enum VT_XPOS_HIMETRIC = VARENUM.VT_I4;
+enum VT_YPOS_HIMETRIC = VARENUM.VT_I4;
+enum VT_XSIZE_HIMETRIC = VARENUM.VT_I4;
+enum VT_YSIZE_HIMETRIC = VARENUM.VT_I4;
+enum VT_TRISTATE = VARENUM.VT_I2;
+enum VT_OPTEXCLUSIVE = VARENUM.VT_BOOL;
+enum VT_FONT = VARENUM.VT_DISPATCH;
+enum VT_PICTURE = VARENUM.VT_DISPATCH;
+enum VT_HANDLE = VARENUM.VT_I4;
+
+enum {
+    OCM__BASE = WM_USER + 0x1c00,
+    OCM_COMMAND = OCM__BASE + WM_COMMAND,
+    OCM_CTLCOLORBTN = OCM__BASE + WM_CTLCOLORBTN,
+    OCM_CTLCOLOREDIT = OCM__BASE + WM_CTLCOLOREDIT,
+    OCM_CTLCOLORDLG = OCM__BASE + WM_CTLCOLORDLG,
+    OCM_CTLCOLORLISTBOX = OCM__BASE + WM_CTLCOLORLISTBOX,
+    OCM_CTLCOLORMSGBOX = OCM__BASE + WM_CTLCOLORMSGBOX,
+    OCM_CTLCOLORSCROLLBAR = OCM__BASE + WM_CTLCOLORSCROLLBAR,
+    OCM_CTLCOLORSTATIC = OCM__BASE + WM_CTLCOLORSTATIC,
+    OCM_DRAWITEM = OCM__BASE + WM_DRAWITEM,
+    OCM_MEASUREITEM = OCM__BASE + WM_MEASUREITEM,
+    OCM_DELETEITEM = OCM__BASE + WM_DELETEITEM,
+    OCM_VKEYTOITEM = OCM__BASE + WM_VKEYTOITEM,
+    OCM_CHARTOITEM = OCM__BASE + WM_CHARTOITEM,
+    OCM_COMPAREITEM = OCM__BASE + WM_COMPAREITEM,
+    OCM_HSCROLL = OCM__BASE + WM_HSCROLL,
+    OCM_VSCROLL = OCM__BASE + WM_VSCROLL,
+    OCM_PARENTNOTIFY = OCM__BASE + WM_PARENTNOTIFY,
+    OCM_NOTIFY = OCM__BASE + WM_NOTIFY
+}
+
+enum {
+    CTRLINFO_EATS_RETURN = 1,
+    CTRLINFO_EATS_ESCAPE
+}
+
+enum {
+    XFORMCOORDS_POSITION            = 1,
+    XFORMCOORDS_SIZE                = 2,
+    XFORMCOORDS_HIMETRICTOCONTAINER = 4,
+    XFORMCOORDS_CONTAINERTOHIMETRIC = 8
+}
+
+enum GUIDKIND_DEFAULT_SOURCE_DISP_IID = 1;
+
+enum {
+    PROPPAGESTATUS_DIRTY = 1,
+    PROPPAGESTATUS_VALIDATE = 2
+}
+
+enum {
+    PICTURE_SCALABLE = 1,
+    PICTURE_TRANSPARENT = 2
+}
+
+enum {
+    PICTYPE_UNINITIALIZED  =  -1,
+    PICTYPE_NONE,       // = 0
+    PICTYPE_BITMAP,
+    PICTYPE_METAFILE,
+    PICTYPE_ICON,
+    PICTYPE_ENHMETAFILE // = 4
+}
+
+enum {
+    DISPID_AUTOSIZE = -500,
+    DISPID_BACKCOLOR = -501,
+    DISPID_BACKSTYLE = -502,
+    DISPID_BORDERCOLOR = -503,
+    DISPID_BORDERSTYLE = -504,
+    DISPID_BORDERWIDTH = -505,
+    DISPID_DRAWMODE = -507,
+    DISPID_DRAWSTYLE = -508,
+    DISPID_DRAWWIDTH = -509,
+    DISPID_FILLCOLOR = -510,
+    DISPID_FILLSTYLE = -511,
+    DISPID_FONT = -512,
+    DISPID_FORECOLOR = -513,
+    DISPID_ENABLED = -514,
+    DISPID_HWND = -515,
+    DISPID_TABSTOP = -516,
+    DISPID_TEXT = -517,
+    DISPID_CAPTION = -518,
+    DISPID_BORDERVISIBLE = -519,
+    DISPID_APPEARANCE = -520,
+    DISPID_MOUSEPOINTER = -521,
+    DISPID_MOUSEICON = -522,
+    DISPID_PICTURE = -523,
+    DISPID_VALID = -524,
+    DISPID_REFRESH = -550,
+    DISPID_DOCLICK = -551,
+    DISPID_ABOUTBOX = -552,
+    DISPID_CLICK = -600,
+    DISPID_DBLCLICK = -601,
+    DISPID_KEYDOWN = -602,
+    DISPID_KEYPRESS = -603,
+    DISPID_KEYUP = -604,
+    DISPID_MOUSEDOWN = -605,
+    DISPID_MOUSEMOVE = -606,
+    DISPID_MOUSEUP = -607,
+    DISPID_ERROREVENT = -608,
+    DISPID_AMBIENT_BACKCOLOR = -701,
+    DISPID_AMBIENT_DISPLAYNAME = -702,
+    DISPID_AMBIENT_FONT = -703,
+    DISPID_AMBIENT_FORECOLOR = -704,
+    DISPID_AMBIENT_LOCALEID = -705,
+    DISPID_AMBIENT_MESSAGEREFLECT = -706,
+    DISPID_AMBIENT_SCALEUNITS = -707,
+    DISPID_AMBIENT_TEXTALIGN = -708,
+    DISPID_AMBIENT_USERMODE = -709,
+    DISPID_AMBIENT_UIDEAD = -710,
+    DISPID_AMBIENT_SHOWGRABHANDLES = -711,
+    DISPID_AMBIENT_SHOWHATCHING = -712,
+    DISPID_AMBIENT_DISPLAYASDEFAULT = -713,
+    DISPID_AMBIENT_SUPPORTSMNEMONICS = -714,
+    DISPID_AMBIENT_AUTOCLIP = -715,
+    DISPID_AMBIENT_APPEARANCE = -716,
+    DISPID_AMBIENT_CODEPAGE = -725,
+    DISPID_AMBIENT_PALETTE = -726,
+    DISPID_AMBIENT_CHARSET = -727,
+    DISPID_AMBIENT_RIGHTTOLEFT = -732,
+    DISPID_AMBIENT_TOPTOBOTTOM = -733
+}
+
+enum {
+    DISPID_FONT_NAME = 0,
+    DISPID_FONT_SIZE = 2,
+    DISPID_FONT_BOLD,
+    DISPID_FONT_ITALIC,
+    DISPID_FONT_UNDER,
+    DISPID_FONT_STRIKE,
+    DISPID_FONT_WEIGHT,
+    DISPID_FONT_CHARSET // = 8
+}
+
+enum {
+    DISPID_PICT_HANDLE = 0,
+    DISPID_PICT_HPAL   = 2,
+    DISPID_PICT_TYPE,
+    DISPID_PICT_WIDTH,
+    DISPID_PICT_HEIGHT,
+    DISPID_PICT_RENDER // = 6
+}
+
+alias IOleControl LPOLECONTROL;
+alias IOleControlSite LPOLECONTROLSITE;
+alias ISimpleFrameSite LPSIMPLEFRAMESITE;
+alias IPersistPropertyBag LPPERSISTPROPERTYBAG;
+alias IPersistStreamInit LPPERSISTSTREAMINIT;
+alias IPersistMemory LPPERSISTMEMORY;
+alias IPropertyNotifySink LPPROPERTYNOTIFYSINK;
+alias IProvideClassInfo LPPROVIDECLASSINFO;
+alias IProvideClassInfo2 LPPROVIDECLASSINFO2;
+alias IConnectionPointContainer LPCONNECTIONPOINTCONTAINER;
+alias IClassFactory2 LPCLASSFACTORY2;
+alias ISpecifyPropertyPages LPSPECIFYPROPERTYPAGES;
+alias IPerPropertyBrowsing LPPERPROPERTYBROWSING;
+alias IPropertyPage LPPROPERTYPAGE;
+alias IPropertyPage2 LPPROPERTYPAGE2;
+
+alias IPicture LPPICTURE;
+alias IPictureDisp LPPICTUREDISP;
+alias int OLE_XPOS_PIXELS;
+alias int OLE_YPOS_PIXELS;
+alias int OLE_XSIZE_PIXELS;
+alias int OLE_YSIZE_PIXELS;
+alias float OLE_XPOS_CONTAINER;
+alias float OLE_YPOS_CONTAINER;
+alias float OLE_XSIZE_CONTAINER;
+
+alias VARIANT_BOOL OLE_OPTEXCLUSIVE;
+alias VARIANT_BOOL OLE_CANCELBOOL;
+alias VARIANT_BOOL OLE_ENABLEDEFAULTBOOL;
+
+align(8):
+
+enum OLE_TRISTATE {
+    triUnchecked,
+    triChecked1,
+    triGray
+}
+
+struct OCPFIPARAMS {
+    ULONG cbStructSize;
+    HWND hWndOwner;
+    int x;
+    int y;
+    LPCOLESTR lpszCaption;
+    ULONG cObjects;
+    LPUNKNOWN *lplpUnk;
+    ULONG cPages;
+    CLSID *lpPages;
+    LCID lcid;
+    DISPID dispidInitialProperty;
+}
+alias OCPFIPARAMS* LPOCPFIPARAMS;
+
+struct FONTDESC {
+    UINT cbSizeofstruct;
+    LPOLESTR lpstrName;
+    CY cySize;
+    SHORT sWeight;
+    SHORT sCharset;
+    BOOL fItalic;
+    BOOL fUnderline;
+    BOOL fStrikethrough;
+}
+alias FONTDESC* LPFONTDESC;
+
+struct PICTDESC
+{
+    UINT cbSizeofstruct;
+    UINT picType;
+    union {
+        struct bmp {
+            HBITMAP hbitmap;
+            HPALETTE hpal;
+        }
+        struct wmf {
+            HMETAFILE hmeta;
+            int xExt;
+            int yExt;
+        }
+        struct icon {
+            HICON hicon;
+        }
+        struct emf {
+            HENHMETAFILE hemf;
+        }
+    }
+}
+alias PICTDESC* LPPICTDESC;
+
+extern(Windows) {
+    HRESULT DllRegisterServer();
+    HRESULT DllUnregisterServer();
+    HRESULT OleCreateFontIndirect(LPFONTDESC, REFIID, PVOID*);
+    HRESULT OleCreatePictureIndirect(LPPICTDESC, REFIID, BOOL, PVOID*);
+    HRESULT OleCreatePropertyFrame(HWND, UINT, UINT, LPCOLESTR, ULONG, LPUNKNOWN*, ULONG, LPCLSID, LCID, DWORD, PVOID);
+    HRESULT OleCreatePropertyFrameIndirect(LPOCPFIPARAMS);
+    HCURSOR OleIconToCursor(HINSTANCE, HICON);
+    HRESULT OleLoadPicture(LPSTREAM, LONG, BOOL, REFIID, PVOID*);
+    HRESULT OleLoadPictureEx(LPSTREAM, LONG, BOOL, REFIID, DWORD, DWORD, DWORD, LPVOID*);
+    HRESULT OleLoadPicturePath(LPOLESTR, LPUNKNOWN, DWORD, OLE_COLOR, REFIID, LPVOID*);
+    HRESULT OleLoadPictureFile(VARIANT, LPDISPATCH*);
+    HRESULT OleLoadPictureFileEx(VARIANT, DWORD, DWORD, DWORD, LPDISPATCH*);
+    HRESULT OleSavePictureFile(LPDISPATCH, BSTR);
+    HRESULT OleTranslateColor(OLE_COLOR, HPALETTE, COLORREF*);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/olectlid.d b/libphobos/libdruntime/core/sys/windows/olectlid.d
new file mode 100644
index 00000000000..72156a1062b
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/olectlid.d
@@ -0,0 +1,13 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_olectlid.d)
+ */
+module core.sys.windows.olectlid;
+version (Windows):
+
+private import core.sys.windows.basetyps;
+
diff --git a/libphobos/libdruntime/core/sys/windows/oledlg.d b/libphobos/libdruntime/core/sys/windows/oledlg.d
new file mode 100644
index 00000000000..6461fc1de80
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/oledlg.d
@@ -0,0 +1,992 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_oledlg.d)
+ */
+module core.sys.windows.oledlg;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+import core.sys.windows.commdlg, core.sys.windows.dlgs, core.sys.windows.ole2, core.sys.windows.prsht, core.sys.windows.shellapi,
+  core.sys.windows.windows;
+private import core.sys.windows.winbase, core.sys.windows.objidl, core.sys.windows.objfwd, core.sys.windows.winnt;
+
+// FIXME: remove inherited methods from interface definitions
+
+enum PS_MAXLINKTYPES=8;
+
+const TCHAR[] OLESTDDELIM = "\\";
+const TCHAR[] SZOLEUI_MSG_HELP = "OLEUI_MSG_HELP";
+const TCHAR[] SZOLEUI_MSG_ENDDIALOG = "OLEUI_MSG_ENDDIALOG";
+const TCHAR[] SZOLEUI_MSG_BROWSE = "OLEUI_MSG_BROWSE";
+const TCHAR[] SZOLEUI_MSG_CHANGEICON = "OLEUI_MSG_CHANGEICON";
+const TCHAR[] SZOLEUI_MSG_CLOSEBUSYDIALOG = "OLEUI_MSG_CLOSEBUSYDIALOG";
+const TCHAR[] SZOLEUI_MSG_CONVERT = "OLEUI_MSG_CONVERT";
+const TCHAR[] SZOLEUI_MSG_CHANGESOURCE = "OLEUI_MSG_CHANGESOURCE";
+const TCHAR[] SZOLEUI_MSG_ADDCONTROL = "OLEUI_MSG_ADDCONTROL";
+const TCHAR[] SZOLEUI_MSG_BROWSE_OFN = "OLEUI_MSG_BROWSE_OFN";
+
+const TCHAR[] PROP_HWND_CHGICONDLG = "HWND_CIDLG";
+
+enum IDC_OLEUIHELP=99;
+
+enum {
+    IDC_IO_CREATENEW = 2100,
+    IDC_IO_CREATEFROMFILE,
+    IDC_IO_LINKFILE,
+    IDC_IO_OBJECTTYPELIST,
+    IDC_IO_DISPLAYASICON,
+    IDC_IO_CHANGEICON,
+    IDC_IO_FILE,
+    IDC_IO_FILEDISPLAY,
+    IDC_IO_RESULTIMAGE,
+    IDC_IO_RESULTTEXT,
+    IDC_IO_ICONDISPLAY,
+    IDC_IO_OBJECTTYPETEXT,
+    IDC_IO_FILETEXT,
+    IDC_IO_FILETYPE,
+    IDC_IO_INSERTCONTROL,
+    IDC_IO_ADDCONTROL,
+    IDC_IO_CONTROLTYPELIST // = 2116
+}
+
+enum IDC_PS_PASTE=500;
+enum IDC_PS_PASTELINK=501;
+enum IDC_PS_SOURCETEXT=502;
+enum IDC_PS_PASTELIST=503;
+enum IDC_PS_PASTELINKLIST=504;
+enum IDC_PS_DISPLAYLIST=505;
+enum IDC_PS_DISPLAYASICON=506;
+enum IDC_PS_ICONDISPLAY=507;
+enum IDC_PS_CHANGEICON=508;
+enum IDC_PS_RESULTIMAGE=509;
+enum IDC_PS_RESULTTEXT=510;
+
+enum IDC_CI_GROUP=120;
+enum IDC_CI_CURRENT=121;
+enum IDC_CI_CURRENTICON=122;
+enum IDC_CI_DEFAULT=123;
+enum IDC_CI_DEFAULTICON=124;
+enum IDC_CI_FROMFILE=125;
+enum IDC_CI_FROMFILEEDIT=126;
+enum IDC_CI_ICONLIST=127;
+enum IDC_CI_LABEL=128;
+enum IDC_CI_LABELEDIT=129;
+enum IDC_CI_BROWSE=130;
+enum IDC_CI_ICONDISPLAY=131;
+
+enum IDC_CV_OBJECTTYPE=150;
+enum IDC_CV_DISPLAYASICON=152;
+enum IDC_CV_CHANGEICON=153;
+enum IDC_CV_ACTIVATELIST=154;
+enum IDC_CV_CONVERTTO=155;
+enum IDC_CV_ACTIVATEAS=156;
+enum IDC_CV_RESULTTEXT=157;
+enum IDC_CV_CONVERTLIST=158;
+enum IDC_CV_ICONDISPLAY=165;
+
+enum IDC_EL_CHANGESOURCE=201;
+enum IDC_EL_AUTOMATIC=202;
+enum IDC_EL_CANCELLINK=209;
+enum IDC_EL_UPDATENOW=210;
+enum IDC_EL_OPENSOURCE=211;
+enum IDC_EL_MANUAL=212;
+enum IDC_EL_LINKSOURCE=216;
+enum IDC_EL_LINKTYPE=217;
+enum IDC_EL_LINKSLISTBOX=206;
+enum IDC_EL_COL1=220;
+enum IDC_EL_COL2=221;
+enum IDC_EL_COL3=222;
+
+enum IDC_BZ_RETRY=600;
+enum IDC_BZ_ICON=601;
+enum IDC_BZ_MESSAGE1=602;
+enum IDC_BZ_SWITCHTO=604;
+
+enum IDC_UL_METER=1029;
+enum IDC_UL_STOP=1030;
+enum IDC_UL_PERCENT=1031;
+enum IDC_UL_PROGRESS=1032;
+
+enum IDC_PU_LINKS=900;
+enum IDC_PU_TEXT=901;
+enum IDC_PU_CONVERT=902;
+enum IDC_PU_ICON=908;
+
+enum IDC_GP_OBJECTNAME=1009;
+enum IDC_GP_OBJECTTYPE=1010;
+enum IDC_GP_OBJECTSIZE=1011;
+enum IDC_GP_CONVERT=1013;
+enum IDC_GP_OBJECTICON=1014;
+enum IDC_GP_OBJECTLOCATION=1022;
+
+enum IDC_VP_PERCENT=1000;
+enum IDC_VP_CHANGEICON=1001;
+enum IDC_VP_EDITABLE=1002;
+enum IDC_VP_ASICON=1003;
+enum IDC_VP_RELATIVE=1005;
+enum IDC_VP_SPIN=1006;
+enum IDC_VP_SCALETXT=1034;
+enum IDC_VP_ICONDISPLAY=1021;
+enum IDC_VP_RESULTIMAGE=1033;
+
+enum IDC_LP_OPENSOURCE=1006;
+enum IDC_LP_UPDATENOW=1007;
+enum IDC_LP_BREAKLINK=1008;
+enum IDC_LP_LINKSOURCE=1012;
+enum IDC_LP_CHANGESOURCE=1015;
+enum IDC_LP_AUTOMATIC=1016;
+enum IDC_LP_MANUAL=1017;
+enum IDC_LP_DATE=1018;
+enum IDC_LP_TIME=1019;
+
+enum IDD_INSERTOBJECT=1000;
+enum IDD_CHANGEICON=1001;
+enum IDD_CONVERT=1002;
+enum IDD_PASTESPECIAL=1003;
+enum IDD_EDITLINKS=1004;
+enum IDD_BUSY=1006;
+enum IDD_UPDATELINKS=1007;
+enum IDD_CHANGESOURCE=1009;
+enum IDD_INSERTFILEBROWSE=1010;
+enum IDD_CHANGEICONBROWSE=1011;
+enum IDD_CONVERTONLY=1012;
+enum IDD_CHANGESOURCE4=1013;
+enum IDD_GNRLPROPS=1100;
+enum IDD_VIEWPROPS=1101;
+enum IDD_LINKPROPS=1102;
+enum IDD_CANNOTUPDATELINK=1008;
+enum IDD_LINKSOURCEUNAVAILABLE=1020;
+enum IDD_SERVERNOTFOUND=1023;
+enum IDD_OUTOFMEMORY=1024;
+enum IDD_SERVERNOTREGW=1021;
+enum IDD_LINKTYPECHANGEDW=1022;
+enum IDD_SERVERNOTREGA=1025;
+enum IDD_LINKTYPECHANGEDA=1026;
+
+enum ID_BROWSE_CHANGEICON=1;
+enum ID_BROWSE_INSERTFILE=2;
+enum ID_BROWSE_ADDCONTROL=3;
+enum ID_BROWSE_CHANGESOURCE=4;
+
+enum OLEUI_FALSE=0;
+enum OLEUI_SUCCESS=1;
+enum OLEUI_OK=1;
+enum OLEUI_CANCEL=2;
+
+enum OLEUI_ERR_STANDARDMIN=100;
+enum OLEUI_ERR_STRUCTURENULL=101;
+enum OLEUI_ERR_STRUCTUREINVALID=102;
+enum OLEUI_ERR_CBSTRUCTINCORRECT=103;
+enum OLEUI_ERR_HWNDOWNERINVALID=104;
+enum OLEUI_ERR_LPSZCAPTIONINVALID=105;
+enum OLEUI_ERR_LPFNHOOKINVALID=106;
+enum OLEUI_ERR_HINSTANCEINVALID=107;
+enum OLEUI_ERR_LPSZTEMPLATEINVALID=108;
+enum OLEUI_ERR_HRESOURCEINVALID=109;
+enum OLEUI_ERR_FINDTEMPLATEFAILURE=110;
+enum OLEUI_ERR_LOADTEMPLATEFAILURE=111;
+enum OLEUI_ERR_DIALOGFAILURE=112;
+enum OLEUI_ERR_LOCALMEMALLOC=113;
+enum OLEUI_ERR_GLOBALMEMALLOC=114;
+enum OLEUI_ERR_LOADSTRING=115;
+enum OLEUI_ERR_OLEMEMALLOC=116;
+enum OLEUI_ERR_STANDARDMAX=116;
+
+enum OPF_OBJECTISLINK=1;
+enum OPF_NOFILLDEFAULT=2;
+enum OPF_SHOWHELP=4;
+enum OPF_DISABLECONVERT=8;
+
+enum OLEUI_OPERR_SUBPROPNULL=OLEUI_ERR_STANDARDMAX;
+enum OLEUI_OPERR_SUBPROPINVALID=(OLEUI_ERR_STANDARDMAX+1);
+enum OLEUI_OPERR_PROPSHEETNULL=(OLEUI_ERR_STANDARDMAX+2);
+enum OLEUI_OPERR_PROPSHEETINVALID=(OLEUI_ERR_STANDARDMAX+3);
+enum OLEUI_OPERR_SUPPROP=(OLEUI_ERR_STANDARDMAX+4);
+enum OLEUI_OPERR_PROPSINVALID=(OLEUI_ERR_STANDARDMAX+5);
+enum OLEUI_OPERR_PAGESINCORRECT=(OLEUI_ERR_STANDARDMAX+6);
+enum OLEUI_OPERR_INVALIDPAGES=(OLEUI_ERR_STANDARDMAX+7);
+enum OLEUI_OPERR_NOTSUPPORTED=(OLEUI_ERR_STANDARDMAX+8);
+enum OLEUI_OPERR_DLGPROCNOTNULL=(OLEUI_ERR_STANDARDMAX+9);
+enum OLEUI_OPERR_LPARAMNOTZERO=(OLEUI_ERR_STANDARDMAX+10);
+enum OLEUI_GPERR_STRINGINVALID=(OLEUI_ERR_STANDARDMAX+11);
+enum OLEUI_GPERR_CLASSIDINVALID=(OLEUI_ERR_STANDARDMAX+12);
+enum OLEUI_GPERR_LPCLSIDEXCLUDEINVALID=(OLEUI_ERR_STANDARDMAX+13);
+enum OLEUI_GPERR_CBFORMATINVALID=(OLEUI_ERR_STANDARDMAX+14);
+enum OLEUI_VPERR_METAPICTINVALID=(OLEUI_ERR_STANDARDMAX+15);
+enum OLEUI_VPERR_DVASPECTINVALID=(OLEUI_ERR_STANDARDMAX+16);
+enum OLEUI_LPERR_LINKCNTRNULL=(OLEUI_ERR_STANDARDMAX+17);
+enum OLEUI_LPERR_LINKCNTRINVALID=(OLEUI_ERR_STANDARDMAX+18);
+enum OLEUI_OPERR_PROPERTYSHEET=(OLEUI_ERR_STANDARDMAX+19);
+enum OLEUI_OPERR_OBJINFOINVALID=(OLEUI_ERR_STANDARDMAX+20);
+enum OLEUI_OPERR_LINKINFOINVALID=(OLEUI_ERR_STANDARDMAX+21);
+
+enum OLEUI_QUERY_GETCLASSID=65280;
+enum OLEUI_QUERY_LINKBROKEN=65281;
+
+enum IOF_SHOWHELP=1;
+enum IOF_SELECTCREATENEW=2;
+enum IOF_SELECTCREATEFROMFILE=4;
+enum IOF_CHECKLINK=8;
+enum IOF_CHECKDISPLAYASICON=16;
+enum IOF_CREATENEWOBJECT=32;
+enum IOF_CREATEFILEOBJECT=64;
+enum IOF_CREATELINKOBJECT=128;
+enum IOF_DISABLELINK=256;
+enum IOF_VERIFYSERVERSEXIST=512;
+enum IOF_DISABLEDISPLAYASICON=1024;
+enum IOF_HIDECHANGEICON=2048;
+enum IOF_SHOWINSERTCONTROL=4096;
+enum IOF_SELECTCREATECONTROL=8192;
+
+enum OLEUI_IOERR_LPSZFILEINVALID=OLEUI_ERR_STANDARDMAX;
+enum OLEUI_IOERR_LPSZLABELINVALID=(OLEUI_ERR_STANDARDMAX+1);
+enum OLEUI_IOERR_HICONINVALID=(OLEUI_ERR_STANDARDMAX+2);
+enum OLEUI_IOERR_LPFORMATETCINVALID=(OLEUI_ERR_STANDARDMAX+3);
+enum OLEUI_IOERR_PPVOBJINVALID=(OLEUI_ERR_STANDARDMAX+4);
+enum OLEUI_IOERR_LPIOLECLIENTSITEINVALID=(OLEUI_ERR_STANDARDMAX+5);
+enum OLEUI_IOERR_LPISTORAGEINVALID=(OLEUI_ERR_STANDARDMAX+6);
+enum OLEUI_IOERR_SCODEHASERROR=(OLEUI_ERR_STANDARDMAX+7);
+enum OLEUI_IOERR_LPCLSIDEXCLUDEINVALID=(OLEUI_ERR_STANDARDMAX+8);
+enum OLEUI_IOERR_CCHFILEINVALID=(OLEUI_ERR_STANDARDMAX+9);
+
+enum PSF_SHOWHELP=1;
+enum PSF_SELECTPASTE=2;
+enum PSF_SELECTPASTELINK=4;
+enum PSF_CHECKDISPLAYASICON=8;
+enum PSF_DISABLEDISPLAYASICON=16;
+enum PSF_HIDECHANGEICON=32;
+enum PSF_STAYONCLIPBOARDCHANGE=64;
+enum PSF_NOREFRESHDATAOBJECT=128;
+
+enum OLEUI_IOERR_SRCDATAOBJECTINVALID=OLEUI_ERR_STANDARDMAX;
+enum OLEUI_IOERR_ARRPASTEENTRIESINVALID=(OLEUI_ERR_STANDARDMAX+1);
+enum OLEUI_IOERR_ARRLINKTYPESINVALID=(OLEUI_ERR_STANDARDMAX+2);
+enum OLEUI_PSERR_CLIPBOARDCHANGED=(OLEUI_ERR_STANDARDMAX+3);
+enum OLEUI_PSERR_GETCLIPBOARDFAILED=(OLEUI_ERR_STANDARDMAX+4);
+enum OLEUI_ELERR_LINKCNTRNULL=OLEUI_ERR_STANDARDMAX;
+enum OLEUI_ELERR_LINKCNTRINVALID=(OLEUI_ERR_STANDARDMAX+1);
+
+enum ELF_SHOWHELP=1;
+enum ELF_DISABLEUPDATENOW=2;
+enum ELF_DISABLEOPENSOURCE=4;
+enum ELF_DISABLECHANGESOURCE=8;
+enum ELF_DISABLECANCELLINK=16;
+
+enum CIF_SHOWHELP=1;
+enum CIF_SELECTCURRENT=2;
+enum CIF_SELECTDEFAULT=4;
+enum CIF_SELECTFROMFILE=8;
+enum CIF_USEICONEXE=16;
+
+enum OLEUI_CIERR_MUSTHAVECLSID=OLEUI_ERR_STANDARDMAX;
+enum OLEUI_CIERR_MUSTHAVECURRENTMETAFILE=OLEUI_ERR_STANDARDMAX+1;
+enum OLEUI_CIERR_SZICONEXEINVALID=OLEUI_ERR_STANDARDMAX+2;
+
+enum CF_SHOWHELPBUTTON=1;
+enum CF_SETCONVERTDEFAULT=2;
+enum CF_SETACTIVATEDEFAULT=4;
+enum CF_SELECTCONVERTTO=8;
+enum CF_SELECTACTIVATEAS=16;
+enum CF_DISABLEDISPLAYASICON=32;
+enum CF_DISABLEACTIVATEAS=64;
+enum CF_HIDECHANGEICON=128;
+enum CF_CONVERTONLY=256;
+
+enum OLEUI_CTERR_CLASSIDINVALID = OLEUI_ERR_STANDARDMAX+1;
+enum OLEUI_CTERR_DVASPECTINVALID = OLEUI_ERR_STANDARDMAX+2;
+enum OLEUI_CTERR_CBFORMATINVALID = OLEUI_ERR_STANDARDMAX+3;
+enum OLEUI_CTERR_HMETAPICTINVALID = OLEUI_ERR_STANDARDMAX+4;
+enum OLEUI_CTERR_STRINGINVALID = OLEUI_ERR_STANDARDMAX+5;
+
+enum BZ_DISABLECANCELBUTTON = 1;
+enum BZ_DISABLESWITCHTOBUTTON = 2;
+enum BZ_DISABLERETRYBUTTON = 4;
+enum BZ_NOTRESPONDINGDIALOG = 8;
+
+enum OLEUI_BZERR_HTASKINVALID = OLEUI_ERR_STANDARDMAX;
+enum OLEUI_BZ_SWITCHTOSELECTED = OLEUI_ERR_STANDARDMAX+1;
+enum OLEUI_BZ_RETRYSELECTED = OLEUI_ERR_STANDARDMAX+2;
+enum OLEUI_BZ_CALLUNBLOCKED = OLEUI_ERR_STANDARDMAX+3;
+
+enum CSF_SHOWHELP = 1;
+enum CSF_VALIDSOURCE = 2;
+enum CSF_ONLYGETSOURCE = 4;
+enum CSF_EXPLORER = 8;
+
+enum OLEUI_CSERR_LINKCNTRNULL = OLEUI_ERR_STANDARDMAX;
+enum OLEUI_CSERR_LINKCNTRINVALID = OLEUI_ERR_STANDARDMAX+1;
+enum OLEUI_CSERR_FROMNOTNULL = OLEUI_ERR_STANDARDMAX+2;
+enum OLEUI_CSERR_TONOTNULL = OLEUI_ERR_STANDARDMAX+3;
+enum OLEUI_CSERR_SOURCENULL = OLEUI_ERR_STANDARDMAX+4;
+enum OLEUI_CSERR_SOURCEINVALID = OLEUI_ERR_STANDARDMAX+5;
+enum OLEUI_CSERR_SOURCEPARSERROR = OLEUI_ERR_STANDARDMAX+6;
+enum OLEUI_CSERR_SOURCEPARSEERROR = OLEUI_ERR_STANDARDMAX+7;
+
+enum VPF_SELECTRELATIVE=1;
+enum VPF_DISABLERELATIVE=2;
+enum VPF_DISABLESCALE=4;
+
+align(8):
+extern (Windows) {
+    alias UINT function(HWND, UINT, WPARAM, LPARAM) LPFNOLEUIHOOK;
+}
+
+struct OLEUIINSERTOBJECTW {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCWSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCWSTR lpszTemplate;
+    HRSRC hResource;
+    CLSID clsid;
+    LPWSTR lpszFile;
+    UINT cchFile;
+    UINT cClsidExclude;
+    LPCLSID lpClsidExclude;
+    IID iid;
+    DWORD oleRender;
+    LPFORMATETC lpFormatEtc;
+    LPOLECLIENTSITE lpIOleClientSite;
+    LPSTORAGE lpIStorage;
+    PVOID *ppvObj;
+    SCODE sc;
+    HGLOBAL hMetaPict;
+}
+alias OLEUIINSERTOBJECTW* POLEUIINSERTOBJECTW, LPOLEUIINSERTOBJECTW;
+
+struct OLEUIINSERTOBJECTA {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCSTR lpszTemplate;
+    HRSRC hResource;
+    CLSID clsid;
+    LPSTR lpszFile;
+    UINT cchFile;
+    UINT cClsidExclude;
+    LPCLSID lpClsidExclude;
+    IID iid;
+    DWORD oleRender;
+    LPFORMATETC lpFormatEtc;
+    LPOLECLIENTSITE lpIOleClientSite;
+    LPSTORAGE lpIStorage;
+    PVOID *ppvObj;
+    SCODE sc;
+    HGLOBAL hMetaPict;
+}
+alias OLEUIINSERTOBJECTA* POLEUIINSERTOBJECTA, LPOLEUIINSERTOBJECTA;
+
+UINT OleUIInsertObjectW(LPOLEUIINSERTOBJECTW);
+UINT OleUIInsertObjectA(LPOLEUIINSERTOBJECTA);
+
+enum OLEUIPASTEFLAG {
+    OLEUIPASTE_PASTEONLY,
+    OLEUIPASTE_LINKTYPE1,
+    OLEUIPASTE_LINKTYPE2,
+    OLEUIPASTE_LINKTYPE3 = 4,
+    OLEUIPASTE_LINKTYPE4 = 8,
+    OLEUIPASTE_LINKTYPE5 = 16,
+    OLEUIPASTE_LINKTYPE6 = 32,
+    OLEUIPASTE_LINKTYPE7 = 64,
+    OLEUIPASTE_LINKTYPE8 = 128,
+    OLEUIPASTE_PASTE = 512,
+    OLEUIPASTE_LINKANYTYPE = 1024,
+    OLEUIPASTE_ENABLEICON = 2048
+}
+
+struct OLEUIPASTEENTRYW {
+    FORMATETC fmtetc;
+    LPCWSTR lpstrFormatName;
+    LPCWSTR lpstrResultText;
+    DWORD dwFlags;
+    DWORD dwScratchSpace;
+}
+alias OLEUIPASTEENTRYW* POLEUIPASTEENTRYW, LPOLEUIPASTEENTRYW;
+
+struct OLEUIPASTEENTRYA {
+    FORMATETC fmtetc;
+    LPCSTR lpstrFormatName;
+    LPCSTR lpstrResultText;
+    DWORD dwFlags;
+    DWORD dwScratchSpace;
+}
+alias OLEUIPASTEENTRYA* POLEUIPASTEENTRYA, LPOLEUIPASTEENTRYA;
+
+struct OLEUIPASTESPECIALW {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCWSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCWSTR lpszTemplate;
+    HRSRC hResource;
+    LPDATAOBJECT lpSrcDataObj;
+    LPOLEUIPASTEENTRYW arrPasteEntries;
+    int cPasteEntries;
+    UINT *arrLinkTypes;
+    int cLinkTypes;
+    UINT cClsidExclude;
+    LPCLSID lpClsidExclude;
+    int nSelectedIndex;
+    BOOL fLink;
+    HGLOBAL hMetaPict;
+    SIZEL sizel;
+}
+alias OLEUIPASTESPECIALW* POLEUIPASTESPECIALW, LPOLEUIPASTESPECIALW;
+
+struct OLEUIPASTESPECIALA {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCSTR lpszTemplate;
+    HRSRC hResource;
+    LPDATAOBJECT lpSrcDataObj;
+    LPOLEUIPASTEENTRYA arrPasteEntries;
+    int cPasteEntries;
+    UINT* arrLinkTypes;
+    int cLinkTypes;
+    UINT cClsidExclude;
+    LPCLSID lpClsidExclude;
+    int nSelectedIndex;
+    BOOL fLink;
+    HGLOBAL hMetaPict;
+    SIZEL sizel;
+}
+alias OLEUIPASTESPECIALA* POLEUIPASTESPECIALA, LPOLEUIPASTESPECIALA;
+
+interface IOleUILinkContainerW : IUnknown
+{
+    HRESULT QueryInterface(REFIID, PVOID*);
+    ULONG AddRef();
+    ULONG Release();
+    DWORD GetNextLink(DWORD dwLink);
+    HRESULT SetLinkUpdateOptions(DWORD, DWORD);
+    HRESULT GetLinkUpdateOptions(DWORD, PDWORD);
+    HRESULT SetLinkSource(DWORD, LPWSTR, ULONG, PULONG, BOOL);
+    HRESULT GetLinkSource(DWORD, LPWSTR*, PULONG, LPWSTR*, LPWSTR*, BOOL*, BOOL*);
+    HRESULT OpenLinkSource(DWORD);
+    HRESULT UpdateLink(DWORD, BOOL, BOOL);
+    HRESULT CancelLink(DWORD);
+}
+alias IOleUILinkContainerW LPOLEUILINKCONTAINERW;
+
+interface IOleUILinkContainerA : IUnknown
+{
+    HRESULT QueryInterface(REFIID, PVOID*);
+    ULONG AddRef();
+    ULONG Release();
+    DWORD GetNextLink(DWORD);
+    HRESULT SetLinkUpdateOptions(DWORD, DWORD);
+    HRESULT GetLinkUpdateOptions(DWORD, PDWORD);
+    HRESULT SetLinkSource(DWORD, LPSTR, ULONG, PULONG, BOOL);
+    HRESULT GetLinkSource(DWORD, LPSTR*, PULONG, LPSTR*, LPSTR*, BOOL*, BOOL*);
+    HRESULT OpenLinkSource(DWORD);
+    HRESULT UpdateLink(DWORD, BOOL, BOOL);
+    HRESULT CancelLink(DWORD);
+}
+alias IOleUILinkContainerA LPOLEUILINKCONTAINERA;
+
+struct OLEUIEDITLINKSW {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCWSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCWSTR lpszTemplate;
+    HRSRC hResource;
+    LPOLEUILINKCONTAINERW lpOleUILinkContainer;
+}
+alias OLEUIEDITLINKSW* POLEUIEDITLINKSW, LPOLEUIEDITLINKSW;
+
+struct OLEUIEDITLINKSA {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCSTR lpszTemplate;
+    HRSRC hResource;
+    LPOLEUILINKCONTAINERA lpOleUILinkContainer;
+}
+alias OLEUIEDITLINKSA* POLEUIEDITLINKSA, LPOLEUIEDITLINKSA;
+
+struct OLEUICHANGEICONW {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCWSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCWSTR lpszTemplate;
+    HRSRC hResource;
+    HGLOBAL hMetaPict;
+    CLSID clsid;
+    WCHAR[MAX_PATH] szIconExe;
+    int cchIconExe;
+}
+alias OLEUICHANGEICONW* POLEUICHANGEICONW, LPOLEUICHANGEICONW;
+
+struct OLEUICHANGEICONA {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCSTR lpszTemplate;
+    HRSRC hResource;
+    HGLOBAL hMetaPict;
+    CLSID clsid;
+    CHAR[MAX_PATH] szIconExe;
+    int cchIconExe;
+}
+alias OLEUICHANGEICONA* POLEUICHANGEICONA, LPOLEUICHANGEICONA;
+
+struct OLEUICONVERTW {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCWSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCWSTR lpszTemplate;
+    HRSRC hResource;
+    CLSID clsid;
+    CLSID clsidConvertDefault;
+    CLSID clsidActivateDefault;
+    CLSID clsidNew;
+    DWORD dvAspect;
+    WORD wFormat;
+    BOOL fIsLinkedObject;
+    HGLOBAL hMetaPict;
+    LPWSTR lpszUserType;
+    BOOL fObjectsIconChanged;
+    LPWSTR lpszDefLabel;
+    UINT cClsidExclude;
+    LPCLSID lpClsidExclude;
+}
+alias OLEUICONVERTW* POLEUICONVERTW, LPOLEUICONVERTW;
+
+struct OLEUICONVERTA {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCSTR lpszTemplate;
+    HRSRC hResource;
+    CLSID clsid;
+    CLSID clsidConvertDefault;
+    CLSID clsidActivateDefault;
+    CLSID clsidNew;
+    DWORD dvAspect;
+    WORD wFormat;
+    BOOL fIsLinkedObject;
+    HGLOBAL hMetaPict;
+    LPSTR lpszUserType;
+    BOOL fObjectsIconChanged;
+    LPSTR lpszDefLabel;
+    UINT cClsidExclude;
+    LPCLSID lpClsidExclude;
+}
+alias OLEUICONVERTA* POLEUICONVERTA, LPOLEUICONVERTA;
+
+struct OLEUIBUSYW {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCWSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCWSTR lpszTemplate;
+    HRSRC hResource;
+    HTASK hTask;
+    HWND *lphWndDialog;
+}
+alias OLEUIBUSYW* POLEUIBUSYW, LPOLEUIBUSYW;
+
+struct OLEUIBUSYA {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCSTR lpszTemplate;
+    HRSRC hResource;
+    HTASK hTask;
+    HWND *lphWndDialog;
+}
+alias OLEUIBUSYA* POLEUIBUSYA, LPOLEUIBUSYA;
+
+struct OLEUICHANGESOURCEW {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCWSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCWSTR lpszTemplate;
+    HRSRC hResource;
+    OPENFILENAMEW* lpOFN;
+    DWORD[4] dwReserved1;
+    LPOLEUILINKCONTAINERW lpOleUILinkContainer;
+    DWORD dwLink;
+    LPWSTR lpszDisplayName;
+    ULONG nFileLength;
+    LPWSTR lpszFrom;
+    LPWSTR lpszTo;
+}
+alias OLEUICHANGESOURCEW* POLEUICHANGESOURCEW, LPOLEUICHANGESOURCEW;
+
+struct OLEUICHANGESOURCEA {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    HWND hWndOwner;
+    LPCSTR lpszCaption;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    HINSTANCE hInstance;
+    LPCSTR lpszTemplate;
+    HRSRC hResource;
+    OPENFILENAMEA *lpOFN;
+    DWORD[4] dwReserved1;
+    LPOLEUILINKCONTAINERA lpOleUILinkContainer;
+    DWORD dwLink;
+    LPSTR lpszDisplayName;
+    ULONG nFileLength;
+    LPSTR lpszFrom;
+    LPSTR lpszTo;
+}
+alias OLEUICHANGESOURCEA* POLEUICHANGESOURCEA, LPOLEUICHANGESOURCEA;
+
+interface IOleUIObjInfoW : IUnknown
+{
+    HRESULT QueryInterface(REFIID, PVOID*);
+    ULONG AddRef();
+    ULONG Release();
+    HRESULT GetObjectInfo(DWORD, PDWORD, LPWSTR*, LPWSTR*, LPWSTR*, LPWSTR*);
+    HRESULT GetConvertInfo(DWORD, CLSID*, PWORD, CLSID*, LPCLSID*, UINT*);
+    HRESULT ConvertObject(DWORD, REFCLSID);
+    HRESULT GetViewInfo(DWORD, HGLOBAL*, PDWORD, int*);
+    HRESULT SetViewInfo(DWORD, HGLOBAL, DWORD, int, BOOL);
+}
+alias IOleUIObjInfoW LPOLEUIOBJINFOW;
+
+interface IOleUIObjInfoA : IUnknown
+{
+    HRESULT QueryInterface(REFIID, PVOID*);
+    ULONG AddRef();
+    ULONG Release();
+    HRESULT GetObjectInfo(DWORD, PDWORD, LPSTR*, LPSTR*, LPSTR*, LPSTR*);
+    HRESULT GetConvertInfo(DWORD, CLSID*, PWORD, CLSID*, LPCLSID*, UINT*);
+    HRESULT ConvertObject(DWORD, REFCLSID);
+    HRESULT GetViewInfo(DWORD, HGLOBAL*, PDWORD, int*);
+    HRESULT SetViewInfo(DWORD, HGLOBAL, DWORD, int, BOOL);
+}
+alias IOleUIObjInfoA LPOLEUIOBJINFOA;
+
+interface IOleUILinkInfoW : IOleUILinkContainerW
+{
+    HRESULT QueryInterface(REFIID, PVOID*);
+    ULONG AddRef();
+    ULONG Release();
+    DWORD GetNextLink(DWORD);
+    HRESULT SetLinkUpdateOptions(DWORD, DWORD);
+    HRESULT GetLinkUpdateOptions(DWORD, DWORD*);
+    HRESULT SetLinkSource(DWORD, LPWSTR, ULONG, PULONG, BOOL);
+    HRESULT GetLinkSource(DWORD, LPWSTR*, PULONG, LPWSTR*, LPWSTR*, BOOL*, BOOL*);
+    HRESULT OpenLinkSource(DWORD);
+    HRESULT UpdateLink(DWORD, BOOL, BOOL);
+    HRESULT CancelLink(DWORD);
+    HRESULT GetLastUpdate(DWORD, FILETIME*);
+}
+alias IOleUILinkInfoW LPOLEUILINKINFOW;
+
+interface IOleUILinkInfoA : IOleUILinkContainerA
+{
+    HRESULT QueryInterface(REFIID, PVOID*);
+    ULONG AddRef();
+    ULONG Release();
+    DWORD GetNextLink(DWORD);
+    HRESULT SetLinkUpdateOptions(DWORD, DWORD);
+    HRESULT GetLinkUpdateOptions(DWORD, DWORD*);
+    HRESULT SetLinkSource(DWORD, LPSTR, ULONG, PULONG, BOOL);
+    HRESULT GetLinkSource(DWORD, LPSTR*, PULONG, LPSTR*, LPSTR*, BOOL*, BOOL*);
+    HRESULT OpenLinkSource(DWORD);
+    HRESULT UpdateLink(DWORD, BOOL, BOOL);
+    HRESULT CancelLink(DWORD);
+    HRESULT GetLastUpdate(DWORD, FILETIME*);
+}
+alias IOleUILinkInfoA LPOLEUILINKINFOA;
+
+struct OLEUIGNRLPROPSW {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    DWORD[2] dwReserved1;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    DWORD[3] dwReserved2;
+    OLEUIOBJECTPROPSW* lpOP;
+}
+alias OLEUIGNRLPROPSW* POLEUIGNRLPROPSW, LPOLEUIGNRLPROPSW;
+
+struct OLEUIGNRLPROPSA {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    DWORD[2] dwReserved1;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    DWORD[3] dwReserved2;
+    OLEUIOBJECTPROPSA* lpOP;
+}
+alias OLEUIGNRLPROPSA* POLEUIGNRLPROPSA, LPOLEUIGNRLPROPSA;
+
+struct OLEUIVIEWPROPSW {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    DWORD[2] dwReserved1;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    DWORD[3] dwReserved2;
+    OLEUIOBJECTPROPSW* lpOP;
+    int nScaleMin;
+    int nScaleMax;
+}
+alias OLEUIVIEWPROPSW* POLEUIVIEWPROPSW, LPOLEUIVIEWPROPSW;
+
+struct OLEUIVIEWPROPSA {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    DWORD[2] dwReserved1;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    DWORD[3] dwReserved2;
+    OLEUIOBJECTPROPSA *lpOP;
+    int nScaleMin;
+    int nScaleMax;
+}
+alias OLEUIVIEWPROPSA* POLEUIVIEWPROPSA, LPOLEUIVIEWPROPSA;
+
+struct OLEUILINKPROPSW {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    DWORD[2] dwReserved1;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    DWORD[3] dwReserved2;
+    OLEUIOBJECTPROPSW *lpOP;
+}
+alias OLEUILINKPROPSW* POLEUILINKPROPSW, LPOLEUILINKPROPSW;
+
+struct OLEUILINKPROPSA {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    DWORD[2] dwReserved1;
+    LPFNOLEUIHOOK lpfnHook;
+    LPARAM lCustData;
+    DWORD[3] dwReserved2;
+    OLEUIOBJECTPROPSA* lpOP;
+}
+alias OLEUILINKPROPSA*  POLEUILINKPROPSA, LPOLEUILINKPROPSA;
+
+struct OLEUIOBJECTPROPSW {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    LPPROPSHEETHEADERW lpPS;
+    DWORD dwObject;
+    LPOLEUIOBJINFOW lpObjInfo;
+    DWORD dwLink;
+    LPOLEUILINKINFOW lpLinkInfo;
+    LPOLEUIGNRLPROPSW lpGP;
+    LPOLEUIVIEWPROPSW lpVP;
+    LPOLEUILINKPROPSW lpLP;
+}
+alias OLEUIOBJECTPROPSW* POLEUIOBJECTPROPSW, LPOLEUIOBJECTPROPSW;
+
+struct OLEUIOBJECTPROPSA {
+    DWORD cbStruct;
+    DWORD dwFlags;
+    LPPROPSHEETHEADERA lpPS;
+    DWORD dwObject;
+    LPOLEUIOBJINFOA lpObjInfo;
+    DWORD dwLink;
+    LPOLEUILINKINFOA lpLinkInfo;
+    LPOLEUIGNRLPROPSA lpGP;
+    LPOLEUIVIEWPROPSA lpVP;
+    LPOLEUILINKPROPSA lpLP;
+}
+alias OLEUIOBJECTPROPSA* POLEUIOBJECTPROPSA, LPOLEUIOBJECTPROPSA;
+
+extern (Windows) {
+    BOOL OleUIAddVerbMenuW(LPOLEOBJECT, LPCWSTR, HMENU, UINT, UINT, UINT, BOOL, UINT, HMENU*);
+    BOOL OleUIAddVerbMenuA(LPOLEOBJECT, LPCSTR, HMENU, UINT, UINT, UINT, BOOL, UINT, HMENU*);
+    UINT OleUIBusyW(LPOLEUIBUSYW);
+    UINT OleUIBusyA(LPOLEUIBUSYA);
+    BOOL OleUICanConvertOrActivateAs(REFCLSID, BOOL, WORD);
+    UINT OleUIChangeIconW(LPOLEUICHANGEICONW);
+    UINT OleUIChangeIconA(LPOLEUICHANGEICONA);
+    UINT OleUIChangeSourceW(LPOLEUICHANGESOURCEW);
+    UINT OleUIChangeSourceA(LPOLEUICHANGESOURCEA);
+    UINT OleUIConvertW(LPOLEUICONVERTW);
+    UINT OleUIConvertA(LPOLEUICONVERTA);
+    UINT OleUIEditLinksW(LPOLEUIEDITLINKSW);
+    UINT OleUIEditLinksA(LPOLEUIEDITLINKSA);
+    UINT OleUIObjectPropertiesW(LPOLEUIOBJECTPROPSW);
+    UINT OleUIObjectPropertiesA(LPOLEUIOBJECTPROPSA);
+    UINT OleUIPasteSpecialW(LPOLEUIPASTESPECIALW);
+    UINT OleUIPasteSpecialA(LPOLEUIPASTESPECIALA);
+    BOOL OleUIUpdateLinksW(LPOLEUILINKCONTAINERW, HWND, LPWSTR, int);
+    BOOL OleUIUpdateLinksA(LPOLEUILINKCONTAINERA, HWND, LPSTR, int);
+}
+
+extern (C) {
+    int OleUIPromptUserW(int, HWND, ...);
+    int OleUIPromptUserA(int, HWND, ...);
+}
+
+version(Unicode) {
+    alias IDD_SERVERNOTREGW IDD_SERVERNOTREG;
+    alias IDD_LINKTYPECHANGEDW IDD_LINKTYPECHANGED;
+    alias OleUIUpdateLinksW OleUIUpdateLinks;
+    alias OleUIAddVerbMenuW OleUIAddVerbMenu;
+    alias OLEUIOBJECTPROPSW OLEUIOBJECTPROPS;
+    alias POLEUIOBJECTPROPSW POLEUIOBJECTPROPS;
+    alias LPOLEUIOBJECTPROPSW LPOLEUIOBJECTPROPS;
+    alias OleUIObjectPropertiesW OleUIObjectProperties;
+    alias OLEUIINSERTOBJECTW OLEUIINSERTOBJECT;
+    alias POLEUIINSERTOBJECTW POLEUIINSERTOBJECT;
+    alias LPOLEUIINSERTOBJECTW LPOLEUIINSERTOBJECT;
+    alias OleUIInsertObjectW OleUIInsertObject;
+    alias OleUIPromptUserW OleUIPromptUser;
+    alias OLEUIPASTEENTRYW OLEUIPASTEENTRY;
+    alias POLEUIPASTEENTRYW POLEUIPASTEENTRY;
+    alias LPOLEUIPASTEENTRYW LPOLEUIPASTEENTRY;
+    alias OLEUIPASTESPECIALW OLEUIPASTESPECIAL;
+    alias POLEUIPASTESPECIALW POLEUIPASTESPECIAL;
+    alias LPOLEUIPASTESPECIALW LPOLEUIPASTESPECIAL;
+    alias OleUIPasteSpecialW OleUIPasteSpecial;
+    alias IOleUILinkContainerW IOleUILinkContainer;
+    alias LPOLEUILINKCONTAINERW LPOLEUILINKCONTAINER;
+    alias OLEUIEDITLINKSW OLEUIEDITLINKS;
+    alias POLEUIEDITLINKSW POLEUIEDITLINKS;
+    alias LPOLEUIEDITLINKSW LPOLEUIEDITLINKS;
+    alias OleUIEditLinksW OleUIEditLinks;
+    alias OLEUICHANGEICONW OLEUICHANGEICON;
+    alias POLEUICHANGEICONW POLEUICHANGEICON;
+    alias LPOLEUICHANGEICONW LPOLEUICHANGEICON;
+    alias OleUIChangeIconW OleUIChangeIcon;
+    alias OLEUICONVERTW OLEUICONVERT;
+    alias POLEUICONVERTW POLEUICONVERT;
+    alias LPOLEUICONVERTW LPOLEUICONVERT;
+    alias OleUIConvertW OleUIConvert;
+    alias OLEUIBUSYW OLEUIBUSY;
+    alias POLEUIBUSYW POLEUIBUSY;
+    alias LPOLEUIBUSYW LPOLEUIBUSY;
+    alias OleUIBusyW OleUIBusy;
+    alias OLEUICHANGESOURCEW OLEUICHANGESOURCE;
+    alias POLEUICHANGESOURCEW POLEUICHANGESOURCE;
+    alias LPOLEUICHANGESOURCEW LPOLEUICHANGESOURCE;
+    alias OleUIChangeSourceW OleUIChangeSource;
+    alias IOleUIObjInfoW IOleUIObjInfo;
+    alias LPOLEUIOBJINFOW LPOLEUIOBJINFO;
+    alias IOleUILinkInfoW IOleUILinkInfo;
+    //alias IOleUILinkInfoWVtbl IOleUILinkInfoVtbl;
+    alias LPOLEUILINKINFOW LPOLEUILINKINFO;
+    alias OLEUIGNRLPROPSW OLEUIGNRLPROPS;
+    alias POLEUIGNRLPROPSW POLEUIGNRLPROPS;
+    alias LPOLEUIGNRLPROPSW LPOLEUIGNRLPROPS;
+    alias OLEUIVIEWPROPSW OLEUIVIEWPROPS;
+    alias POLEUIVIEWPROPSW POLEUIVIEWPROPS;
+    alias LPOLEUIVIEWPROPSW LPOLEUIVIEWPROPS;
+    alias OLEUILINKPROPSW OLEUILINKPROPS;
+    alias POLEUILINKPROPSW POLEUILINKPROPS;
+    alias LPOLEUILINKPROPSW LPOLEUILINKPROPS;
+} else {
+    alias IDD_SERVERNOTREGA IDD_SERVERNOTREG;
+    alias IDD_LINKTYPECHANGEDA IDD_LINKTYPECHANGED;
+    alias OleUIUpdateLinksA OleUIUpdateLinks;
+    alias OleUIAddVerbMenuA OleUIAddVerbMenu;
+    alias OLEUIOBJECTPROPSA OLEUIOBJECTPROPS;
+    alias POLEUIOBJECTPROPSA POLEUIOBJECTPROPS;
+    alias LPOLEUIOBJECTPROPSA LPOLEUIOBJECTPROPS;
+    alias OleUIObjectPropertiesA OleUIObjectProperties;
+    alias OLEUIINSERTOBJECTA OLEUIINSERTOBJECT;
+    alias POLEUIINSERTOBJECTA POLEUIINSERTOBJECT;
+    alias LPOLEUIINSERTOBJECTA LPOLEUIINSERTOBJECT;
+    alias OleUIInsertObjectA OleUIInsertObject;
+    alias OleUIPromptUserA OleUIPromptUser;
+    alias OLEUIPASTEENTRYA OLEUIPASTEENTRY;
+    alias POLEUIPASTEENTRYA POLEUIPASTEENTRY;
+    alias LPOLEUIPASTEENTRYA LPOLEUIPASTEENTRY;
+    alias OLEUIPASTESPECIALA OLEUIPASTESPECIAL;
+    alias POLEUIPASTESPECIALA POLEUIPASTESPECIAL;
+    alias LPOLEUIPASTESPECIALA LPOLEUIPASTESPECIAL;
+    alias OleUIPasteSpecialA OleUIPasteSpecial;
+    alias IOleUILinkContainerA IOleUILinkContainer;
+    alias LPOLEUILINKCONTAINERA LPOLEUILINKCONTAINER;
+    alias OLEUIEDITLINKSA OLEUIEDITLINKS;
+    alias POLEUIEDITLINKSA POLEUIEDITLINKS;
+    alias LPOLEUIEDITLINKSA LPOLEUIEDITLINKS;
+    alias OleUIEditLinksA OleUIEditLinks;
+    alias OLEUICHANGEICONA OLEUICHANGEICON;
+    alias POLEUICHANGEICONA POLEUICHANGEICON;
+    alias LPOLEUICHANGEICONA LPOLEUICHANGEICON;
+    alias OleUIChangeIconA OleUIChangeIcon;
+    alias OLEUICONVERTA OLEUICONVERT;
+    alias POLEUICONVERTA POLEUICONVERT;
+    alias LPOLEUICONVERTA LPOLEUICONVERT;
+    alias OleUIConvertA OleUIConvert;
+    alias OLEUIBUSYA OLEUIBUSY;
+    alias POLEUIBUSYA POLEUIBUSY;
+    alias LPOLEUIBUSYA LPOLEUIBUSY;
+    alias OleUIBusyA OleUIBusy;
+    alias OLEUICHANGESOURCEA OLEUICHANGESOURCE;
+    alias POLEUICHANGESOURCEA POLEUICHANGESOURCE;
+    alias LPOLEUICHANGESOURCEA LPOLEUICHANGESOURCE;
+    alias OleUIChangeSourceA OleUIChangeSource;
+    alias IOleUIObjInfoA IOleUIObjInfo;
+    alias LPOLEUIOBJINFOA LPOLEUIOBJINFO;
+    alias IOleUILinkInfoA IOleUILinkInfo;
+    //alias IOleUILinkInfoAVtbl IOleUILinkInfoVtbl;
+    alias LPOLEUILINKINFOA LPOLEUILINKINFO;
+    alias OLEUIGNRLPROPSA OLEUIGNRLPROPS;
+    alias POLEUIGNRLPROPSA POLEUIGNRLPROPS;
+    alias LPOLEUIGNRLPROPSA LPOLEUIGNRLPROPS;
+    alias OLEUIVIEWPROPSA OLEUIVIEWPROPS;
+    alias POLEUIVIEWPROPSA POLEUIVIEWPROPS;
+    alias LPOLEUIVIEWPROPSA LPOLEUIVIEWPROPS;
+    alias OLEUILINKPROPSA OLEUILINKPROPS;
+    alias POLEUILINKPROPSA POLEUILINKPROPS;
+    alias LPOLEUILINKPROPSA LPOLEUILINKPROPS;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/oleidl.d b/libphobos/libdruntime/core/sys/windows/oleidl.d
new file mode 100644
index 00000000000..044e7d27bb9
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/oleidl.d
@@ -0,0 +1,270 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_oleidl.d)
+ */
+module core.sys.windows.oleidl;
+version (Windows):
+
+// DAC: This is defined in ocidl !!
+// what is it doing in here?
+//alias IEnumOleUndoUnits LPENUMOLEUNDOUNITS;
+
+private import core.sys.windows.basetyps, core.sys.windows.objidl, core.sys.windows.unknwn, core.sys.windows.windef,
+  core.sys.windows.winuser, core.sys.windows.wtypes;
+private import core.sys.windows.objfwd; // for LPMONIKER
+private import core.sys.windows.wingdi; // for LPLOGPALETTE
+
+enum MK_ALT = 32;
+
+enum BINDSPEED {
+    BINDSPEED_INDEFINITE = 1,
+    BINDSPEED_MODERATE,
+    BINDSPEED_IMMEDIATE
+}
+
+enum OLEWHICHMK {
+    OLEWHICHMK_CONTAINER = 1,
+    OLEWHICHMK_OBJREL,
+    OLEWHICHMK_OBJFULL
+}
+
+enum OLEGETMONIKER {
+    OLEGETMONIKER_ONLYIFTHERE = 1,
+    OLEGETMONIKER_FORCEASSIGN,
+    OLEGETMONIKER_UNASSIGN,
+    OLEGETMONIKER_TEMPFORUSER
+}
+
+enum USERCLASSTYPE {
+    USERCLASSTYPE_FULL = 1,
+    USERCLASSTYPE_SHORT,
+    USERCLASSTYPE_APPNAME
+}
+
+enum DROPEFFECT {
+    DROPEFFECT_NONE   = 0,
+    DROPEFFECT_COPY   = 1,
+    DROPEFFECT_MOVE   = 2,
+    DROPEFFECT_LINK   = 4,
+    DROPEFFECT_SCROLL = 0x80000000
+}
+
+struct OLEMENUGROUPWIDTHS {
+    LONG[6] width;
+}
+alias OLEMENUGROUPWIDTHS* LPOLEMENUGROUPWIDTHS;
+
+alias HGLOBAL HOLEMENU;
+
+enum OLECLOSE {
+    OLECLOSE_SAVEIFDIRTY,
+    OLECLOSE_NOSAVE,
+    OLECLOSE_PROMPTSAVE
+}
+
+struct OLEVERB {
+    LONG lVerb;
+    LPWSTR lpszVerbName;
+    DWORD fuFlags;
+    DWORD grfAttribs;
+}
+alias OLEVERB* LPOLEVERB;
+
+alias RECT BORDERWIDTHS;
+alias LPRECT LPBORDERWIDTHS;
+alias LPCRECT LPCBORDERWIDTHS;
+
+struct OLEINPLACEFRAMEINFO {
+    UINT cb;
+    BOOL fMDIApp;
+    HWND hwndFrame;
+    HACCEL haccel;
+    UINT cAccelEntries;
+}
+alias OLEINPLACEFRAMEINFO* LPOLEINPLACEFRAMEINFO;
+
+interface IEnumOLEVERB : IUnknown
+{
+      HRESULT Next(ULONG,OLEVERB*,ULONG*);
+      HRESULT Skip(ULONG);
+      HRESULT Reset();
+      HRESULT Clone(IEnumOLEVERB*);
+}
+//alias IEnumOLEVERB IEnumOleVerb;
+alias IEnumOLEVERB LPENUMOLEVERB;
+
+
+interface IParseDisplayName : IUnknown {
+    HRESULT ParseDisplayName(IBindCtx,LPOLESTR,ULONG*,IMoniker*);
+}
+alias IParseDisplayName LPPARSEDISPLAYNAME;
+
+interface IOleContainer : IParseDisplayName {
+    HRESULT EnumObjects(DWORD,IEnumUnknown*);
+    HRESULT LockContainer(BOOL);
+}
+alias IOleContainer LPOLECONTAINER;
+
+interface IOleItemContainer : IOleContainer {
+    HRESULT GetObject(LPOLESTR,DWORD,IBindCtx,REFIID,void**);
+    HRESULT GetObjectStorage(LPOLESTR,IBindCtx,REFIID,void**);
+    HRESULT IsRunning(LPOLESTR);
+}
+
+
+interface IOleClientSite : IUnknown {
+    HRESULT SaveObject();
+    HRESULT GetMoniker(DWORD,DWORD,LPMONIKER*);
+    HRESULT GetContainer(LPOLECONTAINER*);
+    HRESULT ShowObject();
+    HRESULT OnShowWindow(BOOL);
+    HRESULT RequestNewObjectLayout();
+}
+alias IOleClientSite LPOLECLIENTSITE;
+
+interface IOleObject : IUnknown {
+    HRESULT SetClientSite(LPOLECLIENTSITE);
+    HRESULT GetClientSite(LPOLECLIENTSITE*);
+    HRESULT SetHostNames(LPCOLESTR,LPCOLESTR);
+    HRESULT Close(DWORD);
+    HRESULT SetMoniker(DWORD,LPMONIKER);
+    HRESULT GetMoniker(DWORD,DWORD,LPMONIKER*);
+    HRESULT InitFromData(LPDATAOBJECT,BOOL,DWORD);
+    HRESULT GetClipboardData(DWORD,LPDATAOBJECT*);
+    HRESULT DoVerb(LONG,LPMSG,LPOLECLIENTSITE,LONG,HWND,LPCRECT);
+    HRESULT EnumVerbs(LPENUMOLEVERB*);
+    HRESULT Update();
+    HRESULT IsUpToDate();
+    HRESULT GetUserClassID(LPCLSID);
+    HRESULT GetUserType(DWORD,LPOLESTR*);
+    HRESULT SetExtent(DWORD,SIZEL*);
+    HRESULT GetExtent(DWORD,SIZEL*);
+    HRESULT Advise(LPADVISESINK,PDWORD);
+    HRESULT Unadvise(DWORD);
+    HRESULT EnumAdvise(LPENUMSTATDATA*);
+    HRESULT GetMiscStatus(DWORD,PDWORD);
+    HRESULT SetColorScheme(LPLOGPALETTE);
+}
+alias IOleObject LPOLEOBJECT;
+
+interface IOleWindow : IUnknown {
+    HRESULT GetWindow(HWND*);
+    HRESULT ContextSensitiveHelp(BOOL);
+}
+alias IOleWindow LPOLEWINDOW;
+
+interface IOleInPlaceUIWindow : IOleWindow {
+    HRESULT GetBorder(LPRECT);
+    HRESULT RequestBorderSpace(LPCBORDERWIDTHS);
+    HRESULT SetBorderSpace(LPCBORDERWIDTHS);
+    HRESULT SetActiveObject(LPOLEINPLACEACTIVEOBJECT,LPCOLESTR);
+}
+alias IOleInPlaceUIWindow LPOLEINPLACEUIWINDOW;
+
+interface IOleInPlaceObject : IOleWindow {
+    HRESULT InPlaceDeactivate();
+    HRESULT UIDeactivate();
+    HRESULT SetObjectRects(LPCRECT,LPCRECT);
+    HRESULT ReactivateAndUndo();
+}
+
+
+interface IOleInPlaceActiveObject : IOleWindow {
+    HRESULT TranslateAccelerator(LPMSG);
+    HRESULT OnFrameWindowActivate(BOOL);
+    HRESULT OnDocWindowActivate(BOOL);
+    HRESULT ResizeBorder(LPCRECT,LPOLEINPLACEUIWINDOW,BOOL);
+    HRESULT EnableModeless(BOOL);
+}
+alias IOleInPlaceActiveObject LPOLEINPLACEACTIVEOBJECT;
+
+interface IOleInPlaceFrame : IOleInPlaceUIWindow {
+    HRESULT InsertMenus(HMENU,LPOLEMENUGROUPWIDTHS);
+    HRESULT SetMenu(HMENU,HOLEMENU,HWND);
+    HRESULT RemoveMenus(HMENU);
+    HRESULT SetStatusText(LPCOLESTR);
+    HRESULT EnableModeless(BOOL);
+    HRESULT TranslateAccelerator(LPMSG,WORD);
+}
+alias IOleInPlaceFrame LPOLEINPLACEFRAME;
+
+interface IOleInPlaceSite  : IOleWindow {
+    HRESULT CanInPlaceActivate();
+    HRESULT OnInPlaceActivate();
+    HRESULT OnUIActivate();
+    HRESULT GetWindowContext(IOleInPlaceFrame,IOleInPlaceUIWindow,LPRECT,LPRECT,LPOLEINPLACEFRAMEINFO);
+    HRESULT Scroll(SIZE);
+    HRESULT OnUIDeactivate(BOOL);
+    HRESULT OnInPlaceDeactivate();
+    HRESULT DiscardUndoState();
+    HRESULT DeactivateAndUndo();
+    HRESULT OnPosRectChange(LPCRECT);
+}
+
+interface IOleAdviseHolder : IUnknown {
+    HRESULT Advise(LPADVISESINK,PDWORD);
+    HRESULT Unadvise(DWORD);
+    HRESULT EnumAdvise(LPENUMSTATDATA*);
+    HRESULT SendOnRename(LPMONIKER);
+    HRESULT SendOnSave();
+    HRESULT SendOnClose();
+}
+alias IOleAdviseHolder LPOLEADVISEHOLDER;
+
+interface IDropSource : IUnknown {
+    HRESULT QueryContinueDrag(BOOL,DWORD);
+    HRESULT GiveFeedback(DWORD);
+}
+alias IDropSource LPDROPSOURCE;
+
+interface IDropTarget : IUnknown {
+    HRESULT DragEnter(LPDATAOBJECT,DWORD,POINTL,PDWORD);
+    HRESULT DragOver(DWORD,POINTL,PDWORD);
+    HRESULT DragLeave();
+    HRESULT Drop(LPDATAOBJECT,DWORD,POINTL,PDWORD);
+}
+alias IDropTarget LPDROPTARGET;
+
+extern (Windows) {
+    alias BOOL function(DWORD) __IView_pfncont;
+}
+
+interface IViewObject : IUnknown {
+    HRESULT Draw(DWORD,LONG,PVOID,DVTARGETDEVICE*,HDC,HDC,LPCRECTL,LPCRECTL,__IView_pfncont pfnContinue,DWORD);
+    HRESULT GetColorSet(DWORD,LONG,PVOID,DVTARGETDEVICE*,HDC,LPLOGPALETTE*);
+    HRESULT Freeze(DWORD,LONG,PVOID,PDWORD);
+    HRESULT Unfreeze(DWORD);
+    HRESULT SetAdvise(DWORD,DWORD,IAdviseSink);
+    HRESULT GetAdvise(PDWORD,PDWORD,IAdviseSink*);
+}
+alias IViewObject LPVIEWOBJECT;
+
+interface IViewObject2 : IViewObject {
+    HRESULT GetExtent(DWORD,LONG,DVTARGETDEVICE*,LPSIZEL);
+}
+alias IViewObject2 LPVIEWOBJECT2;
+
+interface IOleCache : IUnknown {
+    HRESULT Cache(FORMATETC*,DWORD,DWORD*);
+    HRESULT Uncache(DWORD);
+    HRESULT EnumCache(IEnumSTATDATA*);
+    HRESULT InitCache(LPDATAOBJECT);
+    HRESULT SetData(FORMATETC*,STGMEDIUM*,BOOL);
+}
+alias IOleCache LPOLECACHE;
+
+interface IOleCache2 : IOleCache {
+    HRESULT UpdateCache(LPDATAOBJECT,DWORD,LPVOID);
+    HRESULT DiscardCache(DWORD);
+}
+alias IOleCache2 LPOLECACHE2;
+
+interface IOleCacheControl : IUnknown {
+    HRESULT OnRun(LPDATAOBJECT);
+    HRESULT OnStop();
+}
+alias IOleCacheControl LPOLECACHECONTROL;
diff --git a/libphobos/libdruntime/core/sys/windows/pbt.d b/libphobos/libdruntime/core/sys/windows/pbt.d
new file mode 100644
index 00000000000..e6b7814eee2
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/pbt.d
@@ -0,0 +1,30 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_pbt.d)
+ */
+module core.sys.windows.pbt;
+version (Windows):
+
+private import core.sys.windows.windef;
+
+enum : WPARAM {
+    PBT_APMQUERYSUSPEND,
+    PBT_APMQUERYSTANDBY,
+    PBT_APMQUERYSUSPENDFAILED,
+    PBT_APMQUERYSTANDBYFAILED,
+    PBT_APMSUSPEND,
+    PBT_APMSTANDBY,
+    PBT_APMRESUMECRITICAL,
+    PBT_APMRESUMESUSPEND,
+    PBT_APMRESUMESTANDBY,
+    PBT_APMBATTERYLOW,
+    PBT_APMPOWERSTATUSCHANGE,
+    PBT_APMOEMEVENT // = 11
+}
+
+enum LPARAM PBTF_APMRESUMEFROMFAILURE = 1;
diff --git a/libphobos/libdruntime/core/sys/windows/powrprof.d b/libphobos/libdruntime/core/sys/windows/powrprof.d
new file mode 100644
index 00000000000..59a90c55a5d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/powrprof.d
@@ -0,0 +1,140 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_powrprof.d)
+ */
+module core.sys.windows.powrprof;
+version (Windows):
+pragma(lib, "powrprof");
+
+private import core.sys.windows.windef;
+private import core.sys.windows.ntdef;
+
+// FIXME: look up Windows version support
+
+enum ULONG
+    EnableSysTrayBatteryMeter =  1,
+    EnableMultiBatteryDisplay =  2,
+    EnablePasswordLogon       =  4,
+    EnableWakeOnRing          =  8,
+    EnableVideoDimDisplay     = 16;
+
+enum UINT NEWSCHEME = -1;
+
+struct GLOBAL_MACHINE_POWER_POLICY {
+    ULONG              Revision;
+    SYSTEM_POWER_STATE LidOpenWakeAc;
+    SYSTEM_POWER_STATE LidOpenWakeDc;
+    ULONG              BroadcastCapacityResolution;
+}
+alias GLOBAL_MACHINE_POWER_POLICY* PGLOBAL_MACHINE_POWER_POLICY;
+
+struct GLOBAL_USER_POWER_POLICY {
+    ULONG               Revision;
+    POWER_ACTION_POLICY PowerButtonAc;
+    POWER_ACTION_POLICY PowerButtonDc;
+    POWER_ACTION_POLICY SleepButtonAc;
+    POWER_ACTION_POLICY SleepButtonDc;
+    POWER_ACTION_POLICY LidCloseAc;
+    POWER_ACTION_POLICY LidCloseDc;
+    SYSTEM_POWER_LEVEL[NUM_DISCHARGE_POLICIES] DischargePolicy;
+    ULONG GlobalFlags;
+}
+alias GLOBAL_USER_POWER_POLICY* PGLOBAL_USER_POWER_POLICY;
+
+struct GLOBAL_POWER_POLICY {
+    GLOBAL_USER_POWER_POLICY    user;
+    GLOBAL_MACHINE_POWER_POLICY mach;
+}
+alias GLOBAL_POWER_POLICY* PGLOBAL_POWER_POLICY;
+
+struct MACHINE_POWER_POLICY {
+    ULONG               Revision;
+    SYSTEM_POWER_STATE  MinSleepAc;
+    SYSTEM_POWER_STATE  MinSleepDc;
+    SYSTEM_POWER_STATE  ReducedLatencySleepAc;
+    SYSTEM_POWER_STATE  ReducedLatencySleepDc;
+    ULONG               DozeTimeoutAc;
+    ULONG               DozeTimeoutDc;
+    ULONG               DozeS4TimeoutAc;
+    ULONG               DozeS4TimeoutDc;
+    UCHAR               MinThrottleAc;
+    UCHAR               MinThrottleDc;
+    UCHAR[2]            pad1;
+    POWER_ACTION_POLICY OverThrottledAc;
+    POWER_ACTION_POLICY OverThrottledDc;
+}
+alias MACHINE_POWER_POLICY* PMACHINE_POWER_POLICY;
+
+struct MACHINE_PROCESSOR_POWER_POLICY {
+    ULONG Revision;
+    PROCESSOR_POWER_POLICY ProcessorPolicyAc;
+    PROCESSOR_POWER_POLICY ProcessorPolicyDc;
+}
+alias MACHINE_PROCESSOR_POWER_POLICY* PMACHINE_PROCESSOR_POWER_POLICY;
+
+struct USER_POWER_POLICY {
+   ULONG               Revision;
+   POWER_ACTION_POLICY IdleAc;
+   POWER_ACTION_POLICY IdleDc;
+   ULONG               IdleTimeoutAc;
+   ULONG               IdleTimeoutDc;
+   UCHAR               IdleSensitivityAc;
+   UCHAR               IdleSensitivityDc;
+   UCHAR               ThrottlePolicyAc;
+   UCHAR               ThrottlePolicyDc;
+   SYSTEM_POWER_STATE  MaxSleepAc;
+   SYSTEM_POWER_STATE  MaxSleepDc;
+   ULONG[2]            Reserved;
+   ULONG               VideoTimeoutAc;
+   ULONG               VideoTimeoutDc;
+   ULONG               SpindownTimeoutAc;
+   ULONG               SpindownTimeoutDc;
+   BOOLEAN             OptimizeForPowerAc;
+   BOOLEAN             OptimizeForPowerDc;
+   UCHAR               FanThrottleToleranceAc;
+   UCHAR               FanThrottleToleranceDc;
+   UCHAR               ForcedThrottleAc;
+   UCHAR               ForcedThrottleDc;
+}
+alias USER_POWER_POLICY* PUSER_POWER_POLICY;
+
+struct POWER_POLICY {
+    USER_POWER_POLICY    user;
+    MACHINE_POWER_POLICY mach;
+}
+alias POWER_POLICY* PPOWER_POLICY;
+
+extern (Windows) {
+    alias BOOLEAN function(UINT, DWORD, LPTSTR, DWORD, LPTSTR, PPOWER_POLICY,
+      LPARAM) PWRSCHEMESENUMPROC;
+    alias BOOLEAN function(POWER_ACTION, SYSTEM_POWER_STATE, ULONG, BOOLEAN)
+      PFNNTINITIATEPWRACTION;
+
+    NTSTATUS CallNtPowerInformation(POWER_INFORMATION_LEVEL, PVOID, ULONG,
+      PVOID, ULONG);
+    BOOLEAN CanUserWritePwrScheme();
+    BOOLEAN DeletePwrScheme(UINT);
+    BOOLEAN EnumPwrSchemes(PWRSCHEMESENUMPROC, LPARAM);
+    BOOLEAN GetActivePwrScheme(PUINT);
+    BOOLEAN GetCurrentPowerPolicies(PGLOBAL_POWER_POLICY, PPOWER_POLICY);
+    BOOLEAN GetPwrCapabilities(PSYSTEM_POWER_CAPABILITIES);
+    BOOLEAN GetPwrDiskSpindownRange(PUINT, PUINT);
+    BOOLEAN IsAdminOverrideActive(PADMINISTRATOR_POWER_POLICY);
+    BOOLEAN IsPwrHibernateAllowed();
+    BOOLEAN IsPwrShutdownAllowed();
+    BOOLEAN IsPwrSuspendAllowed();
+    BOOLEAN ReadGlobalPwrPolicy(PGLOBAL_POWER_POLICY);
+    BOOLEAN ReadProcessorPwrScheme(UINT, PMACHINE_PROCESSOR_POWER_POLICY);
+    BOOLEAN ReadPwrScheme(UINT, PPOWER_POLICY);
+    BOOLEAN SetActivePwrScheme(UINT, PGLOBAL_POWER_POLICY, PPOWER_POLICY);
+    BOOLEAN SetSuspendState(BOOLEAN, BOOLEAN, BOOLEAN);
+    BOOLEAN WriteGlobalPwrPolicy(PGLOBAL_POWER_POLICY);
+    BOOLEAN WriteProcessorPwrScheme(UINT, PMACHINE_PROCESSOR_POWER_POLICY);
+    BOOLEAN ValidatePowerPolicies(PGLOBAL_POWER_POLICY, PPOWER_POLICY);
+    BOOLEAN WritePwrScheme(PUINT, LPTSTR, LPTSTR, PPOWER_POLICY);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/prsht.d b/libphobos/libdruntime/core/sys/windows/prsht.d
new file mode 100644
index 00000000000..c24fe3adb00
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/prsht.d
@@ -0,0 +1,444 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Vladimir Vlasov
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_prsht.d)
+ */
+module core.sys.windows.prsht;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "comctl32");
+
+private import core.sys.windows.w32api, core.sys.windows.windef, core.sys.windows.winuser;
+
+enum MAXPROPPAGES = 100;
+
+enum {
+    PSP_DEFAULT      = 0x00000000,
+    PSP_DLGINDIRECT  = 0x00000001,
+    PSP_USEHICON     = 0x00000002,
+    PSP_USEICONID    = 0x00000004,
+    PSP_USETITLE     = 0x00000008,
+    PSP_RTLREADING   = 0x00000010,
+    PSP_HASHELP      = 0x00000020,
+    PSP_USEREFPARENT = 0x00000040,
+    PSP_USECALLBACK  = 0x00000080,
+    PSP_PREMATURE    = 0x00000400
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        PSP_HIDEHEADER        = 0x00000800,
+        PSP_USEHEADERTITLE    = 0x00001000,
+        PSP_USEHEADERSUBTITLE = 0x00002000
+    }
+}
+
+enum {
+    PSPCB_RELEASE = 1,
+    PSPCB_CREATE
+}
+
+enum {
+    PSH_DEFAULT           = 0x00000000,
+    PSH_PROPTITLE         = 0x00000001,
+    PSH_USEHICON          = 0x00000002,
+    PSH_USEICONID         = 0x00000004,
+    PSH_PROPSHEETPAGE     = 0x00000008,
+    PSH_WIZARDHASFINISH   = 0x00000010,
+    PSH_WIZARD            = 0x00000020,
+    PSH_USEPSTARTPAGE     = 0x00000040,
+    PSH_NOAPPLYNOW        = 0x00000080,
+    PSH_USECALLBACK       = 0x00000100,
+    PSH_HASHELP           = 0x00000200,
+    PSH_MODELESS          = 0x00000400,
+    PSH_RTLREADING        = 0x00000800,
+    PSH_WIZARDCONTEXTHELP = 0x00001000
+}
+
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        PSH_WATERMARK        = 0x00008000,
+        PSH_USEHBMWATERMARK  = 0x00010000,
+        PSH_USEHPLWATERMARK  = 0x00020000,
+        PSH_STRETCHWATERMARK = 0x00040000,
+        PSH_HEADER           = 0x00080000,
+        PSH_USEHBMHEADER     = 0x00100000,
+        PSH_USEPAGELANG      = 0x00200000
+    }
+    static if (_WIN32_IE < 0x0500) {
+        enum {
+            PSH_WIZARD97 = 0x00002000
+        }
+    } else {
+        enum {
+            PSH_WIZARD97 = 0x01000000
+        }
+    }
+}
+
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        PSH_WIZARD_LITE   = 0x00400000,
+        PSH_NOCONTEXTHELP = 0x02000000
+    }
+}
+
+enum {
+    PSCB_INITIALIZED = 1,
+    PSCB_PRECREATE
+}
+
+enum {
+    PSN_FIRST       = (-200),
+    PSN_LAST        = (-299),
+    PSN_SETACTIVE   = (-200),
+    PSN_KILLACTIVE  = (-201),
+    PSN_APPLY       = (-202),
+    PSN_RESET       = (-203),
+    PSN_HELP        = (-205),
+    PSN_WIZBACK     = (-206),
+    PSN_WIZNEXT     = (-207),
+    PSN_WIZFINISH   = (-208),
+    PSN_QUERYCANCEL = (-209)
+}
+static if (_WIN32_IE >= 0x400) {
+    enum {
+        PSN_GETOBJECT = (-210)
+    }
+}
+static if (_WIN32_IE >= 0x500) {
+    enum {
+        PSN_TRANSLATEACCELERATOR = (-212),
+        PSN_QUERYINITIALFOCUS    = (-213)
+    }
+}
+
+enum {
+    PSNRET_NOERROR,
+    PSNRET_INVALID,
+    PSNRET_INVALID_NOCHANGEPAGE,
+    PSNRET_MESSAGEHANDLED
+}
+
+enum {
+    ID_PSRESTARTWINDOWS = 0x2,
+    ID_PSREBOOTSYSTEM   = ID_PSRESTARTWINDOWS | 0x1
+}
+
+enum {
+    WIZ_CXDLG  = 276,
+    WIZ_CYDLG  = 140,
+    WIZ_CXBMP  = 80,
+    WIZ_BODYX  = 92,
+    WIZ_BODYCX = 184
+}
+
+enum {
+    PROP_SM_CXDLG  = 212,
+    PROP_SM_CYDLG  = 188,
+    PROP_MED_CXDLG = 227,
+    PROP_MED_CYDLG = 215,
+    PROP_LG_CXDLG  = 252,
+    PROP_LG_CYDLG  = 218
+}
+
+enum {
+    PSBTN_BACK,
+    PSBTN_NEXT,
+    PSBTN_FINISH,
+    PSBTN_OK,
+    PSBTN_APPLYNOW,
+    PSBTN_CANCEL,
+    PSBTN_HELP,
+    PSBTN_MAX = 6
+}
+
+enum {
+    PSWIZB_BACK           = 1,
+    PSWIZB_NEXT           = 2,
+    PSWIZB_FINISH         = 4,
+    PSWIZB_DISABLEDFINISH = 8
+}
+
+enum {
+    PSM_SETCURSEL = WM_USER + 101,
+    PSM_REMOVEPAGE,
+    PSM_ADDPAGE,
+    PSM_CHANGED,
+    PSM_RESTARTWINDOWS,
+    PSM_REBOOTSYSTEM,
+    PSM_CANCELTOCLOSE,
+    PSM_QUERYSIBLINGS,
+    PSM_UNCHANGED,
+    PSM_APPLY,
+    PSM_SETTITLEA,
+    PSM_SETWIZBUTTONS,
+    PSM_PRESSBUTTON,
+    PSM_SETCURSELID,
+    PSM_SETFINISHTEXTA,
+    PSM_GETTABCONTROL,
+    PSM_ISDIALOGMESSAGE,
+    PSM_GETCURRENTPAGEHWND,
+    PSM_INSERTPAGE,
+    PSM_SETTITLEW,
+    PSM_SETFINISHTEXTW // = WM_USER + 121,
+}
+
+alias UINT function(HWND, UINT, LPPROPSHEETPAGEA) LPFNPSPCALLBACKA;
+alias UINT function(HWND, UINT, LPPROPSHEETPAGEW) LPFNPSPCALLBACKW;
+alias int function(HWND, UINT, LPARAM) PFNPROPSHEETCALLBACK;
+
+align(4):
+
+struct PROPSHEETPAGEA {
+    DWORD dwSize = PROPSHEETPAGEA.sizeof;
+    DWORD dwFlags;
+    HINSTANCE hInstance;
+    union {
+        LPCSTR         pszTemplate;
+        LPCDLGTEMPLATE pResource;
+    }
+    union {
+        HICON  hIcon;
+        LPCSTR pszIcon;
+    }
+    LPCSTR  pszTitle;
+    DLGPROC pfnDlgProc;
+    LPARAM  lParam;
+    LPFNPSPCALLBACKA pfnCallback;
+    UINT*     pcRefParent;
+    static if (_WIN32_IE >= 0x400) {
+        LPCSTR pszHeaderTitle;
+        LPCSTR pszHeaderSubTitle;
+    }
+}
+alias PROPSHEETPAGEA*        LPPROPSHEETPAGEA;
+alias const(PROPSHEETPAGEA)* LPCPROPSHEETPAGEA;
+
+struct PROPSHEETPAGEW {
+    DWORD     dwSize = PROPSHEETPAGEW.sizeof;
+    DWORD     dwFlags;
+    HINSTANCE hInstance;
+    union {
+        LPCWSTR        pszTemplate;
+        LPCDLGTEMPLATE pResource;
+    }
+    union {
+        HICON   hIcon;
+        LPCWSTR pszIcon;
+    }
+    LPCWSTR   pszTitle;
+    DLGPROC   pfnDlgProc;
+    LPARAM    lParam;
+    LPFNPSPCALLBACKW pfnCallback;
+    UINT*     pcRefParent;
+    static if (_WIN32_IE >= 0x400) {
+        LPCWSTR pszHeaderTitle;
+        LPCWSTR pszHeaderSubTitle;
+    }
+}
+alias PROPSHEETPAGEW*        LPPROPSHEETPAGEW;
+alias const(PROPSHEETPAGEW)* LPCPROPSHEETPAGEW;
+
+mixin DECLARE_HANDLE!("HPROPSHEETPAGE");
+
+struct PROPSHEETHEADERA {
+    DWORD dwSize = PROPSHEETHEADERA.sizeof;
+    DWORD dwFlags;
+    HWND  hwndParent;
+    HINSTANCE hInstance;
+    union {
+        HICON   hIcon;
+        LPCSTR  pszIcon;
+    }
+    LPCSTR pszCaption;
+    UINT   nPages;
+    union {
+        UINT   nStartPage;
+        LPCSTR pStartPage;
+    }
+    union {
+        LPCPROPSHEETPAGEA ppsp;
+        HPROPSHEETPAGE*   phpage;
+    }
+    PFNPROPSHEETCALLBACK pfnCallback;
+    static if (_WIN32_IE >= 0x400) {
+        union {
+            HBITMAP hbmWatermark;
+            LPCSTR  pszbmWatermark;
+        }
+        HPALETTE hplWatermark;
+        union {
+            HBITMAP hbmHeader;
+            LPCSTR  pszbmHeader;
+        }
+    }
+}
+alias PROPSHEETHEADERA*        LPPROPSHEETHEADERA;
+alias const(PROPSHEETHEADERA)* LPCPROPSHEETHEADERA;
+
+struct PROPSHEETHEADERW {
+    DWORD     dwSize = PROPSHEETHEADERW.sizeof;
+    DWORD     dwFlags;
+    HWND      hwndParent;
+    HINSTANCE hInstance;
+    union {
+        HICON   hIcon;
+        LPCWSTR pszIcon;
+    }
+    LPCWSTR   pszCaption;
+    UINT      nPages;
+    union {
+        UINT    nStartPage;
+        LPCWSTR pStartPage;
+    }
+    union {
+        LPCPROPSHEETPAGEW ppsp;
+        HPROPSHEETPAGE*   phpage;
+    }
+    PFNPROPSHEETCALLBACK pfnCallback;
+    static if (_WIN32_IE >= 0x400) {
+        union {
+            HBITMAP hbmWatermark;
+            LPCWSTR pszbmWatermark;
+        }
+        HPALETTE hplWatermark;
+        union {
+            HBITMAP hbmHeader;
+            LPCWSTR pszbmHeader;
+        }
+    }
+}
+alias PROPSHEETHEADERW*        LPPROPSHEETHEADERW;
+alias const(PROPSHEETHEADERW)* LPCPROPSHEETHEADERW;
+
+alias BOOL function(HPROPSHEETPAGE, LPARAM) LPFNADDPROPSHEETPAGE;
+alias BOOL function(LPVOID, LPFNADDPROPSHEETPAGE, LPARAM)
+  LPFNADDPROPSHEETPAGES;
+
+struct PSHNOTIFY {
+    NMHDR  hdr;
+    LPARAM lParam;
+}
+alias PSHNOTIFY* LPPSHNOTIFY;
+
+extern (Windows) {
+    HPROPSHEETPAGE CreatePropertySheetPageA(LPCPROPSHEETPAGEA);
+    HPROPSHEETPAGE CreatePropertySheetPageW(LPCPROPSHEETPAGEW);
+    BOOL DestroyPropertySheetPage(HPROPSHEETPAGE);
+    int PropertySheetA(LPCPROPSHEETHEADERA);
+    int PropertySheetW(LPCPROPSHEETHEADERW);
+}
+
+version (Unicode) {
+    alias LPFNPSPCALLBACKW         LPFNPSPCALLBACK;
+    alias PROPSHEETPAGEW           PROPSHEETPAGE;
+    alias LPPROPSHEETPAGEW         LPPROPSHEETPAGE;
+    alias LPCPROPSHEETPAGEW        LPCPROPSHEETPAGE;
+    alias PROPSHEETHEADERW         PROPSHEETHEADER;
+    alias LPPROPSHEETHEADERW       LPPROPSHEETHEADER;
+    alias LPCPROPSHEETHEADERW      LPCPROPSHEETHEADER;
+    alias PSM_SETTITLEW            PSM_SETTITLE;
+    alias PSM_SETFINISHTEXTW       PSM_SETFINISHTEXT;
+    alias CreatePropertySheetPageW CreatePropertySheetPage;
+    alias PropertySheetW           PropertySheet;
+} else {
+    alias LPFNPSPCALLBACKA         LPFNPSPCALLBACK;
+    alias PROPSHEETPAGEA           PROPSHEETPAGE;
+    alias LPPROPSHEETPAGEA         LPPROPSHEETPAGE;
+    alias LPCPROPSHEETPAGEA        LPCPROPSHEETPAGE;
+    alias PROPSHEETHEADERA         PROPSHEETHEADER;
+    alias LPPROPSHEETHEADERA       LPPROPSHEETHEADER;
+    alias LPCPROPSHEETHEADERA      LPCPROPSHEETHEADER;
+    alias PSM_SETTITLEA            PSM_SETTITLE;
+    alias PSM_SETFINISHTEXTA       PSM_SETFINISHTEXT;
+    alias CreatePropertySheetPageA CreatePropertySheetPage;
+    alias PropertySheetA           PropertySheet;
+}
+
+BOOL PropSheet_SetCurSel(HWND hPropSheetDlg, HPROPSHEETPAGE hpage,
+      HPROPSHEETPAGE index) {
+    return cast(BOOL) SendMessage(hPropSheetDlg, PSM_SETCURSEL,
+      cast(WPARAM) index, cast(LPARAM) hpage);
+}
+
+VOID PropSheet_RemovePage(HWND hPropSheetDlg, int index, HPROPSHEETPAGE hpage) {
+    SendMessage(hPropSheetDlg, PSM_REMOVEPAGE, index, cast(LPARAM) hpage);
+}
+
+BOOL PropSheet_AddPage(HWND hPropSheetDlg, HPROPSHEETPAGE hpage) {
+        return cast(BOOL) SendMessage(hPropSheetDlg, PSM_ADDPAGE,
+          0, cast(LPARAM) hpage);
+}
+
+VOID PropSheet_Changed(HWND hPropSheetDlg, HWND hwndPage) {
+    SendMessage(hPropSheetDlg, PSM_CHANGED, cast(WPARAM) hwndPage, 0);
+}
+
+VOID PropSheet_RestartWindows(HWND hPropSheetDlg) {
+    SendMessage(hPropSheetDlg, PSM_RESTARTWINDOWS, 0, 0);
+}
+
+VOID PropSheet_RebootSystem(HWND hPropSheetDlg) {
+    SendMessage(hPropSheetDlg, PSM_REBOOTSYSTEM, 0, 0);
+}
+
+VOID PropSheet_CancelToClose(HWND hPropSheetDlg) {
+    SendMessage(hPropSheetDlg, PSM_CANCELTOCLOSE, 0, 0);
+}
+
+int PropSheet_QuerySiblings(HWND hPropSheetDlg, WPARAM param1, LPARAM param2) {
+    return cast(int) SendMessage(hPropSheetDlg, PSM_QUERYSIBLINGS, param1, param2);
+}
+
+VOID PropSheet_UnChanged(HWND hPropSheetDlg, HWND hwndPage) {
+    SendMessage(hPropSheetDlg, PSM_UNCHANGED, cast(WPARAM) hwndPage, 0);
+}
+
+BOOL PropSheet_Apply(HWND hPropSheetDlg) {
+    return cast(BOOL) SendMessage(hPropSheetDlg, PSM_APPLY, 0, 0);
+}
+
+VOID PropSheet_SetTitle(HWND hPropSheetDlg, DWORD wStyle, LPTSTR lpszText) {
+    SendMessage(hPropSheetDlg, PSM_SETTITLE, wStyle, cast(LPARAM) lpszText);
+}
+
+VOID PropSheet_SetWizButtons(HWND hPropSheetDlg, DWORD dwFlags) {
+    PostMessage(hPropSheetDlg, PSM_SETWIZBUTTONS, 0, cast(LPARAM) dwFlags);
+}
+
+BOOL PropSheet_PressButton(HWND hPropSheetDlg, int iButton) {
+    return cast(BOOL) SendMessage(hPropSheetDlg, PSM_PRESSBUTTON, iButton, 0);
+}
+
+BOOL PropSheet_SetCurSelByID(HWND hPropSheetDlg, int id) {
+    return cast(BOOL) SendMessage(hPropSheetDlg, PSM_SETCURSELID, 0, id);
+}
+
+VOID PropSheet_SetFinishText(HWND hPropSheetDlg, LPTSTR lpszText) {
+    SendMessage(hPropSheetDlg, PSM_SETFINISHTEXT, 0, cast(LPARAM) lpszText);
+}
+
+HWND PropSheet_GetTabControl(HWND hPropSheetDlg) {
+    return cast(HWND) SendMessage(hPropSheetDlg, PSM_GETTABCONTROL, 0, 0);
+}
+
+BOOL PropSheet_IsDialogMessage(HWND hDlg, LPMSG pMsg) {
+    return cast(BOOL) SendMessage(hDlg, PSM_ISDIALOGMESSAGE,
+      0, cast(LPARAM) pMsg);
+}
+
+HWND PropSheet_GetCurrentPageHwnd(HWND hDlg) {
+    return cast(HWND) SendMessage(hDlg, PSM_GETCURRENTPAGEHWND, 0, 0);
+}
+
+BOOL PropSheet_InsertPage(HWND hPropSheetDlg, WPARAM wInsertAfter,
+      HPROPSHEETPAGE hpage) {
+    return cast(BOOL) SendMessage(hPropSheetDlg, PSM_INSERTPAGE,
+      wInsertAfter, cast(LPARAM) hpage);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/psapi.d b/libphobos/libdruntime/core/sys/windows/psapi.d
new file mode 100644
index 00000000000..ed28515ad37
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/psapi.d
@@ -0,0 +1,160 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_psapi.d)
+ */
+/* Comment from MinGW
+ *   Process status API (PSAPI)
+ *   http://windowssdk.msdn.microsoft.com/library/ms684884.aspx
+ */
+
+module core.sys.windows.psapi;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.w32api;
+private import core.sys.windows.winbase;
+private import core.sys.windows.windef;
+
+struct MODULEINFO {
+    LPVOID lpBaseOfDll;
+    DWORD SizeOfImage;
+    LPVOID EntryPoint;
+}
+alias MODULEINFO* LPMODULEINFO;
+
+struct PSAPI_WS_WATCH_INFORMATION {
+    LPVOID FaultingPc;
+    LPVOID FaultingVa;
+}
+alias PSAPI_WS_WATCH_INFORMATION* PPSAPI_WS_WATCH_INFORMATION;
+
+struct PSAPI_WS_WATCH_INFORMATION_EX {
+    PSAPI_WS_WATCH_INFORMATION BasicInfo;
+    ULONG_PTR FaultingThreadId;
+    ULONG_PTR Flags;
+}
+alias PSAPI_WS_WATCH_INFORMATION_EX* PPSAPI_WS_WATCH_INFORMATION_EX;
+
+struct PROCESS_MEMORY_COUNTERS {
+    DWORD cb;
+    DWORD PageFaultCount;
+    DWORD PeakWorkingSetSize;
+    DWORD WorkingSetSize;
+    DWORD QuotaPeakPagedPoolUsage;
+    DWORD QuotaPagedPoolUsage;
+    DWORD QuotaPeakNonPagedPoolUsage;
+    DWORD QuotaNonPagedPoolUsage;
+    DWORD PagefileUsage;
+    DWORD PeakPagefileUsage;
+}
+alias PROCESS_MEMORY_COUNTERS* PPROCESS_MEMORY_COUNTERS;
+
+struct PERFORMANCE_INFORMATION {
+    DWORD cb;
+    SIZE_T CommitTotal;
+    SIZE_T CommitLimit;
+    SIZE_T CommitPeak;
+    SIZE_T PhysicalTotal;
+    SIZE_T PhysicalAvailable;
+    SIZE_T SystemCache;
+    SIZE_T KernelTotal;
+    SIZE_T KernelPaged;
+    SIZE_T KernelNonpaged;
+    SIZE_T PageSize;
+    DWORD HandleCount;
+    DWORD ProcessCount;
+    DWORD ThreadCount;
+}
+alias PERFORMANCE_INFORMATION* PPERFORMANCE_INFORMATION;
+
+struct ENUM_PAGE_FILE_INFORMATION {
+    DWORD cb;
+    DWORD Reserved;
+    SIZE_T TotalSize;
+    SIZE_T TotalInUse;
+    SIZE_T PeakUsage;
+}
+alias ENUM_PAGE_FILE_INFORMATION* PENUM_PAGE_FILE_INFORMATION;
+
+/* application-defined callback function used with the EnumPageFiles()
+ * http://windowssdk.msdn.microsoft.com/library/ms682627.aspx */
+version (Unicode) {
+    alias BOOL function(LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCWSTR)
+      PENUM_PAGE_FILE_CALLBACK;
+} else {
+    alias BOOL function(LPVOID, PENUM_PAGE_FILE_INFORMATION, LPCSTR)
+      PENUM_PAGE_FILE_CALLBACK;
+}
+
+// Grouped by application, not in alphabetical order.
+extern (Windows) {
+    /* Process Information
+     * http://windowssdk.msdn.microsoft.com/library/ms684870.aspx */
+    BOOL EnumProcesses(DWORD*, DWORD, DWORD*); /* NT/2000/XP/Server2003/Vista/Longhorn */
+    DWORD GetProcessImageFileNameA(HANDLE, LPSTR, DWORD); /* XP/Server2003/Vista/Longhorn */
+    DWORD GetProcessImageFileNameW(HANDLE, LPWSTR, DWORD); /* XP/Server2003/Vista/Longhorn */
+
+    /* Module Information
+     * http://windowssdk.msdn.microsoft.com/library/ms684232.aspx */
+    BOOL EnumProcessModules(HANDLE, HMODULE*, DWORD, LPDWORD);
+    BOOL EnumProcessModulesEx(HANDLE, HMODULE*, DWORD, LPDWORD, DWORD); /* Vista/Longhorn */
+    DWORD GetModuleBaseNameA(HANDLE, HMODULE, LPSTR, DWORD);
+    DWORD GetModuleBaseNameW(HANDLE, HMODULE, LPWSTR, DWORD);
+    DWORD GetModuleFileNameExA(HANDLE, HMODULE, LPSTR, DWORD);
+    DWORD GetModuleFileNameExW(HANDLE, HMODULE, LPWSTR, DWORD);
+    BOOL GetModuleInformation(HANDLE, HMODULE, LPMODULEINFO, DWORD);
+
+    /* Device Driver Information
+     * http://windowssdk.msdn.microsoft.com/library/ms682578.aspx */
+    BOOL EnumDeviceDrivers(LPVOID*, DWORD, LPDWORD);
+    DWORD GetDeviceDriverBaseNameA(LPVOID, LPSTR, DWORD);
+    DWORD GetDeviceDriverBaseNameW(LPVOID, LPWSTR, DWORD);
+    DWORD GetDeviceDriverFileNameA(LPVOID, LPSTR, DWORD);
+    DWORD GetDeviceDriverFileNameW(LPVOID, LPWSTR, DWORD);
+
+    /* Process Memory Usage Information
+     * http://windowssdk.msdn.microsoft.com/library/ms684879.aspx */
+    BOOL GetProcessMemoryInfo(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD);
+
+    /* Working Set Information
+     * http://windowssdk.msdn.microsoft.com/library/ms687398.aspx */
+    BOOL EmptyWorkingSet(HANDLE);
+    BOOL GetWsChanges(HANDLE, PPSAPI_WS_WATCH_INFORMATION, DWORD);
+    BOOL GetWsChangesEx(HANDLE, PPSAPI_WS_WATCH_INFORMATION_EX, DWORD); /* Vista/Longhorn */
+    BOOL InitializeProcessForWsWatch(HANDLE);
+    BOOL QueryWorkingSet(HANDLE, PVOID, DWORD);
+    BOOL QueryWorkingSetEx(HANDLE, PVOID, DWORD);
+
+    /* Memory-Mapped File Information
+     * http://windowssdk.msdn.microsoft.com/library/ms684212.aspx */
+    DWORD GetMappedFileNameW(HANDLE, LPVOID, LPWSTR, DWORD);
+    DWORD GetMappedFileNameA(HANDLE, LPVOID, LPSTR, DWORD);
+
+    /* Resources Information */
+    BOOL GetPerformanceInfo(PPERFORMANCE_INFORMATION, DWORD); /* XP/Server2003/Vista/Longhorn */
+    BOOL EnumPageFilesW(PENUM_PAGE_FILE_CALLBACK, LPVOID); /* 2000/XP/Server2003/Vista/Longhorn */
+    BOOL EnumPageFilesA(PENUM_PAGE_FILE_CALLBACK, LPVOID); /* 2000/XP/Server2003/Vista/Longhorn */
+}
+
+version (Unicode) {
+    alias GetModuleBaseNameW GetModuleBaseName;
+    alias GetModuleFileNameExW GetModuleFileNameEx;
+    alias GetMappedFileNameW GetMappedFileName;
+    alias GetDeviceDriverBaseNameW GetDeviceDriverBaseName;
+    alias GetDeviceDriverFileNameW GetDeviceDriverFileName;
+    alias EnumPageFilesW EnumPageFiles;
+    alias GetProcessImageFileNameW GetProcessImageFileName;
+} else {
+    alias GetModuleBaseNameA GetModuleBaseName;
+    alias GetModuleFileNameExA GetModuleFileNameEx;
+    alias GetMappedFileNameA GetMappedFileName;
+    alias GetDeviceDriverBaseNameA GetDeviceDriverBaseName;
+    alias GetDeviceDriverFileNameA GetDeviceDriverFileName;
+    alias EnumPageFilesA EnumPageFiles;
+    alias GetProcessImageFileNameA GetProcessImageFileName;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/rapi.d b/libphobos/libdruntime/core/sys/windows/rapi.d
new file mode 100644
index 00000000000..b60a14b7e46
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/rapi.d
@@ -0,0 +1,54 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_rapi.d)
+ */
+module core.sys.windows.rapi;
+version (Windows):
+
+/* Comment from MinGW
+   NOTE: This strictly does not belong in the Win32 API since it's
+   really part of Platform SDK.
+ */
+
+private import core.sys.windows.winbase, core.sys.windows.windef;
+
+extern (Windows):
+
+enum RAPISTREAMFLAG
+{
+    STREAM_TIMEOUT_READ
+}
+
+interface IRAPIStream
+{
+    HRESULT SetRapiStat(RAPISTREAMFLAG, DWORD);
+    HRESULT GetRapiStat(RAPISTREAMFLAG, DWORD*);
+}
+
+alias HRESULT function(DWORD, BYTE, DWORD, BYTE, IRAPIStream) RAPIEXT;
+
+struct RAPIINIT
+{
+    DWORD   cbSize = this.sizeof;
+    HANDLE  heRapiInit;
+    HRESULT hrRapiInit;
+}
+
+HRESULT CeRapiInit();
+HRESULT CeRapiInitEx(RAPIINIT*);
+BOOL CeCreateProcess(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES,
+  LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPWSTR, LPSTARTUPINFO,
+  LPPROCESS_INFORMATION);
+HRESULT CeRapiUninit();
+BOOL CeWriteFile(HANDLE, LPCVOID, DWORD, LPDWORD, LPOVERLAPPED);
+HANDLE CeCreateFile(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD,
+  DWORD, HANDLE);
+BOOL CeCreateDirectory(LPCWSTR, LPSECURITY_ATTRIBUTES);
+DWORD CeGetLastError();
+BOOL CeGetFileTime(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME);
+BOOL CeCloseHandle(HANDLE);
diff --git a/libphobos/libdruntime/core/sys/windows/ras.d b/libphobos/libdruntime/core/sys/windows/ras.d
new file mode 100644
index 00000000000..05085400c44
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/ras.d
@@ -0,0 +1,1008 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_ras.d)
+ */
+module core.sys.windows.ras;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "rasapi32");
+
+private import core.sys.windows.basetyps, core.sys.windows.lmcons, core.sys.windows.w32api, core.sys.windows.windef;
+
+align(4):
+
+enum RAS_MaxDeviceType = 16;
+enum RAS_MaxPhoneNumber = 128;
+enum RAS_MaxIpAddress = 15;
+enum RAS_MaxIpxAddress = 21;
+enum RAS_MaxEntryName = 256;
+enum RAS_MaxDeviceName = 128;
+enum RAS_MaxCallbackNumber = RAS_MaxPhoneNumber;
+enum RAS_MaxAreaCode = 10;
+enum RAS_MaxPadType = 32;
+enum RAS_MaxX25Address = 200;
+enum RAS_MaxFacilities = 200;
+enum RAS_MaxUserData = 200;
+enum RAS_MaxReplyMessage = 1024;
+
+enum RDEOPT_UsePrefixSuffix           = 0x00000001;
+enum RDEOPT_PausedStates              = 0x00000002;
+enum RDEOPT_IgnoreModemSpeaker        = 0x00000004;
+enum RDEOPT_SetModemSpeaker           = 0x00000008;
+enum RDEOPT_IgnoreSoftwareCompression = 0x00000010;
+enum RDEOPT_SetSoftwareCompression    = 0x00000020;
+enum RDEOPT_DisableConnectedUI        = 0x00000040;
+enum RDEOPT_DisableReconnectUI        = 0x00000080;
+enum RDEOPT_DisableReconnect          = 0x00000100;
+enum RDEOPT_NoUser                    = 0x00000200;
+enum RDEOPT_PauseOnScript             = 0x00000400;
+enum RDEOPT_Router                    = 0x00000800;
+
+enum REN_User = 0x00000000;
+enum REN_AllUsers = 0x00000001;
+enum VS_Default = 0;
+enum VS_PptpOnly = 1;
+enum VS_PptpFirst = 2;
+enum VS_L2tpOnly = 3;
+enum VS_L2tpFirst = 4;
+
+enum RASDIALEVENT = "RasDialEvent";
+enum WM_RASDIALEVENT = 0xCCCD;
+
+enum RASEO_UseCountryAndAreaCodes = 0x00000001;
+enum RASEO_SpecificIpAddr = 0x00000002;
+enum RASEO_SpecificNameServers = 0x00000004;
+enum RASEO_IpHeaderCompression = 0x00000008;
+enum RASEO_RemoteDefaultGateway = 0x00000010;
+enum RASEO_DisableLcpExtensions = 0x00000020;
+enum RASEO_TerminalBeforeDial = 0x00000040;
+enum RASEO_TerminalAfterDial = 0x00000080;
+enum RASEO_ModemLights = 0x00000100;
+enum RASEO_SwCompression = 0x00000200;
+enum RASEO_RequireEncryptedPw = 0x00000400;
+enum RASEO_RequireMsEncryptedPw = 0x00000800;
+enum RASEO_RequireDataEncryption = 0x00001000;
+enum RASEO_NetworkLogon = 0x00002000;
+enum RASEO_UseLogonCredentials = 0x00004000;
+enum RASEO_PromoteAlternates = 0x00008000;
+enum RASNP_NetBEUI = 0x00000001;
+enum RASNP_Ipx = 0x00000002;
+enum RASNP_Ip = 0x00000004;
+enum RASFP_Ppp = 0x00000001;
+enum RASFP_Slip = 0x00000002;
+enum RASFP_Ras = 0x00000004;
+
+const TCHAR[]
+    RASDT_Modem = "modem",
+    RASDT_Isdn = "isdn",
+    RASDT_X25 = "x25",
+    RASDT_Vpn = "vpn",
+    RASDT_Pad = "pad",
+    RASDT_Generic = "GENERIC",
+    RASDT_Serial = "SERIAL",
+    RASDT_FrameRelay = "FRAMERELAY",
+    RASDT_Atm = "ATM",
+    RASDT_Sonet = "SONET",
+    RASDT_SW56 = "SW56",
+    RASDT_Irda = "IRDA",
+    RASDT_Parallel = "PARALLEL";
+
+enum RASET_Phone = 1;
+enum RASET_Vpn = 2;
+enum RASET_Direct = 3;
+enum RASET_Internet = 4;
+
+static if (_WIN32_WINNT >= 0x401) {
+enum RASEO_SecureLocalFiles = 0x00010000;
+enum RASCN_Connection = 0x00000001;
+enum RASCN_Disconnection = 0x00000002;
+enum RASCN_BandwidthAdded = 0x00000004;
+enum RASCN_BandwidthRemoved = 0x00000008;
+enum RASEDM_DialAll = 1;
+enum RASEDM_DialAsNeeded = 2;
+enum RASIDS_Disabled = 0xffffffff;
+enum RASIDS_UseGlobalValue = 0;
+enum RASADFLG_PositionDlg = 0x00000001;
+enum RASCM_UserName = 0x00000001;
+enum RASCM_Password = 0x00000002;
+enum RASCM_Domain = 0x00000004;
+enum RASADP_DisableConnectionQuery = 0;
+enum RASADP_LoginSessionDisable = 1;
+enum RASADP_SavedAddressesLimit = 2;
+enum RASADP_FailedConnectionTimeout = 3;
+enum RASADP_ConnectionQueryTimeout = 4;
+}
+//static if (_WIN32_WINNT >= 0x500) {
+enum RDEOPT_CustomDial = 0x00001000;
+enum RASLCPAP_PAP = 0xC023;
+enum RASLCPAP_SPAP = 0xC027;
+enum RASLCPAP_CHAP = 0xC223;
+enum RASLCPAP_EAP = 0xC227;
+enum RASLCPAD_CHAP_MD5 = 0x05;
+enum RASLCPAD_CHAP_MS = 0x80;
+enum RASLCPAD_CHAP_MSV2 = 0x81;
+enum RASLCPO_PFC    = 0x00000001;
+enum RASLCPO_ACFC   = 0x00000002;
+enum RASLCPO_SSHF   = 0x00000004;
+enum RASLCPO_DES_56 = 0x00000008;
+enum RASLCPO_3_DES  = 0x00000010;
+
+enum RASCCPCA_MPPC = 0x00000006;
+enum RASCCPCA_STAC = 0x00000005;
+
+enum RASCCPO_Compression      = 0x00000001;
+enum RASCCPO_HistoryLess      = 0x00000002;
+enum RASCCPO_Encryption56bit  = 0x00000010;
+enum RASCCPO_Encryption40bit  = 0x00000020;
+enum RASCCPO_Encryption128bit = 0x00000040;
+
+enum RASEO_RequireEAP          = 0x00020000;
+enum RASEO_RequirePAP          = 0x00040000;
+enum RASEO_RequireSPAP         = 0x00080000;
+enum RASEO_Custom              = 0x00100000;
+enum RASEO_PreviewPhoneNumber  = 0x00200000;
+enum RASEO_SharedPhoneNumbers  = 0x00800000;
+enum RASEO_PreviewUserPw       = 0x01000000;
+enum RASEO_PreviewDomain       = 0x02000000;
+enum RASEO_ShowDialingProgress = 0x04000000;
+enum RASEO_RequireCHAP         = 0x08000000;
+enum RASEO_RequireMsCHAP       = 0x10000000;
+enum RASEO_RequireMsCHAP2      = 0x20000000;
+enum RASEO_RequireW95MSCHAP    = 0x40000000;
+enum RASEO_CustomScript        = 0x80000000;
+
+enum RASIPO_VJ = 0x00000001;
+enum RCD_SingleUser = 0;
+enum RCD_AllUsers = 0x00000001;
+enum RCD_Eap = 0x00000002;
+enum RASEAPF_NonInteractive = 0x00000002;
+enum RASEAPF_Logon = 0x00000004;
+enum RASEAPF_Preview = 0x00000008;
+enum ET_40Bit = 1;
+enum ET_128Bit = 2;
+enum ET_None = 0;
+enum ET_Require = 1;
+enum ET_RequireMax = 2;
+enum ET_Optional = 3;
+//}
+
+enum RASCS_PAUSED = 0x1000;
+enum RASCS_DONE = 0x2000;
+enum RASCONNSTATE {
+    RASCS_OpenPort = 0,
+    RASCS_PortOpened,
+    RASCS_ConnectDevice,
+    RASCS_DeviceConnected,
+    RASCS_AllDevicesConnected,
+    RASCS_Authenticate,
+    RASCS_AuthNotify,
+    RASCS_AuthRetry,
+    RASCS_AuthCallback,
+    RASCS_AuthChangePassword,
+    RASCS_AuthProject,
+    RASCS_AuthLinkSpeed,
+    RASCS_AuthAck,
+    RASCS_ReAuthenticate,
+    RASCS_Authenticated,
+    RASCS_PrepareForCallback,
+    RASCS_WaitForModemReset,
+    RASCS_WaitForCallback,
+    RASCS_Projected,
+    RASCS_StartAuthentication,
+    RASCS_CallbackComplete,
+    RASCS_LogonNetwork,
+    RASCS_SubEntryConnected,
+    RASCS_SubEntryDisconnected,
+    RASCS_Interactive = RASCS_PAUSED,
+    RASCS_RetryAuthentication,
+    RASCS_CallbackSetByCaller,
+    RASCS_PasswordExpired,
+//  static if (_WIN32_WINNT >= 0x500) {
+        RASCS_InvokeEapUI,
+//  }
+    RASCS_Connected = RASCS_DONE,
+    RASCS_Disconnected
+}
+alias RASCONNSTATE* LPRASCONNSTATE;
+
+enum RASPROJECTION {
+    RASP_Amb =      0x10000,
+    RASP_PppNbf =   0x803F,
+    RASP_PppIpx =   0x802B,
+    RASP_PppIp =    0x8021,
+//  static if (_WIN32_WINNT >= 0x500) {
+        RASP_PppCcp =   0x80FD,
+//  }
+    RASP_PppLcp =   0xC021,
+    RASP_Slip =     0x20000
+}
+alias RASPROJECTION* LPRASPROJECTION;
+
+alias TypeDef!(HANDLE) HRASCONN;
+alias HRASCONN* LPHRASCONN;
+
+struct RASCONNW {
+    DWORD dwSize;
+    HRASCONN hrasconn;
+    WCHAR[RAS_MaxEntryName + 1] szEntryName;
+    WCHAR[RAS_MaxDeviceType + 1] szDeviceType;
+    WCHAR[RAS_MaxDeviceName + 1] szDeviceName;
+    //static if (_WIN32_WINNT >= 0x401) {
+        WCHAR[MAX_PATH] szPhonebook;
+        DWORD dwSubEntry;
+    //}
+    //static if (_WIN32_WINNT >= 0x500) {
+        GUID guidEntry;
+    //}
+    static if (_WIN32_WINNT >= 0x501) {
+        DWORD dwFlags;
+        LUID luid;
+    }
+}
+alias RASCONNW* LPRASCONNW;
+
+struct RASCONNA {
+    DWORD dwSize;
+    HRASCONN hrasconn;
+    CHAR[RAS_MaxEntryName + 1] szEntryName;
+    CHAR[RAS_MaxDeviceType + 1] szDeviceType;
+    CHAR[RAS_MaxDeviceName + 1] szDeviceName;
+    //static if (_WIN32_WINNT >= 0x401) {
+        CHAR[MAX_PATH] szPhonebook;
+        DWORD dwSubEntry;
+    //}
+    //static if (_WIN32_WINNT >= 0x500) {
+        GUID guidEntry;
+    //}
+    static if (_WIN32_WINNT >= 0x501) {
+        DWORD dwFlags;
+        LUID luid;
+    }
+}
+alias RASCONNA* LPRASCONNA;
+
+struct RASCONNSTATUSW {
+    DWORD dwSize;
+    RASCONNSTATE rasconnstate;
+    DWORD dwError;
+    WCHAR[RAS_MaxDeviceType + 1] szDeviceType;
+    WCHAR[RAS_MaxDeviceName + 1] szDeviceName;
+    static if (_WIN32_WINNT >= 0x401) {
+        WCHAR[RAS_MaxPhoneNumber + 1] szPhoneNumber;
+    }
+}
+alias RASCONNSTATUSW* LPRASCONNSTATUSW;
+
+struct RASCONNSTATUSA {
+    DWORD dwSize;
+    RASCONNSTATE rasconnstate;
+    DWORD dwError;
+    CHAR[RAS_MaxDeviceType + 1] szDeviceType;
+    CHAR[RAS_MaxDeviceName + 1] szDeviceName;
+    static if (_WIN32_WINNT >= 0x401) {
+        CHAR[RAS_MaxPhoneNumber + 1] szPhoneNumber;
+    }
+}
+alias RASCONNSTATUSA* LPRASCONNSTATUSA;
+
+struct RASDIALPARAMSW {
+    DWORD dwSize;
+    WCHAR[RAS_MaxEntryName + 1] szEntryName;
+    WCHAR[RAS_MaxPhoneNumber + 1] szPhoneNumber;
+    WCHAR[RAS_MaxCallbackNumber + 1] szCallbackNumber;
+    WCHAR[UNLEN + 1] szUserName;
+    WCHAR[PWLEN + 1] szPassword;
+    WCHAR[DNLEN + 1] szDomain;
+    static if (_WIN32_WINNT >= 0x401) {
+        DWORD dwSubEntry;
+        ULONG_PTR dwCallbackId;
+    }
+}
+alias RASDIALPARAMSW* LPRASDIALPARAMSW;
+
+struct RASDIALPARAMSA{
+    DWORD dwSize;
+    CHAR[RAS_MaxEntryName + 1] szEntryName;
+    CHAR[RAS_MaxPhoneNumber + 1] szPhoneNumber;
+    CHAR[RAS_MaxCallbackNumber + 1] szCallbackNumber;
+    CHAR[UNLEN + 1] szUserName;
+    CHAR[PWLEN + 1] szPassword;
+    CHAR[DNLEN + 1] szDomain;
+    static if (_WIN32_WINNT >= 0x401) {
+        DWORD dwSubEntry;
+        ULONG_PTR dwCallbackId;
+    }
+}
+alias RASDIALPARAMSA* LPRASDIALPARAMSA;
+
+//static if (_WIN32_WINNT >= 0x500) {
+    struct RASEAPINFO {
+        DWORD dwSizeofEapInfo;
+        BYTE *pbEapInfo;
+    }
+//}
+
+struct RASDIALEXTENSIONS {
+    DWORD dwSize;
+    DWORD dwfOptions;
+    HWND hwndParent;
+    ULONG_PTR reserved;
+    //static if (_WIN32_WINNT >= 0x500) {
+        ULONG_PTR reserved1;
+        RASEAPINFO RasEapInfo;
+    //}
+}
+alias RASDIALEXTENSIONS* LPRASDIALEXTENSIONS;
+
+struct RASENTRYNAMEW {
+    DWORD dwSize;
+    WCHAR[RAS_MaxEntryName + 1] szEntryName;
+    //static if (_WIN32_WINNT >= 0x500) {
+        DWORD dwFlags;
+        WCHAR[MAX_PATH + 1] szPhonebookPath;
+    //}
+}
+alias RASENTRYNAMEW* LPRASENTRYNAMEW;
+
+struct RASENTRYNAMEA{
+    DWORD dwSize;
+    CHAR[RAS_MaxEntryName + 1] szEntryName;
+    //static if (_WIN32_WINNT >= 0x500) {
+        DWORD dwFlags;
+        CHAR[MAX_PATH + 1] szPhonebookPath;
+    //}
+}
+alias RASENTRYNAMEA* LPRASENTRYNAMEA;
+
+struct RASAMBW{
+    DWORD dwSize;
+    DWORD dwError;
+    WCHAR[NETBIOS_NAME_LEN + 1] szNetBiosError;
+    BYTE bLana;
+}
+alias RASAMBW* LPRASAMBW;
+
+struct RASAMBA{
+    DWORD dwSize;
+    DWORD dwError;
+    CHAR[NETBIOS_NAME_LEN + 1] szNetBiosError;
+    BYTE bLana;
+}
+alias RASAMBA* LPRASAMBA;
+
+struct RASPPPNBFW{
+    DWORD dwSize;
+    DWORD dwError;
+    DWORD dwNetBiosError;
+    WCHAR[NETBIOS_NAME_LEN + 1] szNetBiosError;
+    WCHAR[NETBIOS_NAME_LEN + 1] szWorkstationName;
+    BYTE bLana;
+}
+alias RASPPPNBFW* LPRASPPPNBFW;
+
+struct RASPPPNBFA{
+    DWORD dwSize;
+    DWORD dwError;
+    DWORD dwNetBiosError;
+    CHAR[NETBIOS_NAME_LEN + 1] szNetBiosError;
+    CHAR[NETBIOS_NAME_LEN + 1] szWorkstationName;
+    BYTE bLana;
+}
+alias RASPPPNBFA* LPRASPPPNBFA;
+
+struct RASPPPIPXW {
+    DWORD dwSize;
+    DWORD dwError;
+    WCHAR[RAS_MaxIpxAddress + 1] szIpxAddress;
+}
+alias RASPPPIPXW* LPRASPPPIPXW;
+
+struct RASPPPIPXA {
+    DWORD dwSize;
+    DWORD dwError;
+    CHAR[RAS_MaxIpxAddress + 1] szIpxAddress;
+}
+alias RASPPPIPXA* LPRASPPPIPXA;
+
+struct RASPPPIPW{
+    DWORD dwSize;
+    DWORD dwError;
+    WCHAR[RAS_MaxIpAddress + 1] szIpAddress;
+    //#ifndef WINNT35COMPATIBLE
+    WCHAR[RAS_MaxIpAddress + 1] szServerIpAddress;
+    //#endif
+    //static if (_WIN32_WINNT >= 0x500) {
+        DWORD dwOptions;
+        DWORD dwServerOptions;
+    //}
+}
+alias RASPPPIPW* LPRASPPPIPW;
+
+struct RASPPPIPA{
+    DWORD dwSize;
+    DWORD dwError;
+    CHAR[RAS_MaxIpAddress + 1] szIpAddress;
+    //#ifndef WINNT35COMPATIBLE
+    CHAR[RAS_MaxIpAddress + 1] szServerIpAddress;
+    //#endif
+    //static if (_WIN32_WINNT >= 0x500) {
+        DWORD dwOptions;
+        DWORD dwServerOptions;
+    //}
+}
+alias RASPPPIPA* LPRASPPPIPA;
+
+struct RASPPPLCPW{
+    DWORD dwSize;
+    BOOL fBundled;
+    //static if (_WIN32_WINNT >= 0x500) {
+        DWORD dwError;
+        DWORD dwAuthenticationProtocol;
+        DWORD dwAuthenticationData;
+        DWORD dwEapTypeId;
+        DWORD dwServerAuthenticationProtocol;
+        DWORD dwServerAuthenticationData;
+        DWORD dwServerEapTypeId;
+        BOOL fMultilink;
+        DWORD dwTerminateReason;
+        DWORD dwServerTerminateReason;
+        WCHAR[RAS_MaxReplyMessage] szReplyMessage;
+        DWORD dwOptions;
+        DWORD dwServerOptions;
+    //}
+}
+alias RASPPPLCPW* LPRASPPPLCPW;
+
+struct RASPPPLCPA{
+    DWORD dwSize;
+    BOOL fBundled;
+    //static if (_WIN32_WINNT >= 0x500) {
+        DWORD dwError;
+        DWORD dwAuthenticationProtocol;
+        DWORD dwAuthenticationData;
+        DWORD dwEapTypeId;
+        DWORD dwServerAuthenticationProtocol;
+        DWORD dwServerAuthenticationData;
+        DWORD dwServerEapTypeId;
+        BOOL fMultilink;
+        DWORD dwTerminateReason;
+        DWORD dwServerTerminateReason;
+        CHAR[RAS_MaxReplyMessage] szReplyMessage;
+        DWORD dwOptions;
+        DWORD dwServerOptions;
+    //}
+}
+alias RASPPPLCPA* LPRASPPPLCPA;
+
+struct RASSLIPW{
+    DWORD dwSize;
+    DWORD dwError;
+    WCHAR[RAS_MaxIpAddress + 1] szIpAddress;
+}
+alias RASSLIPW* LPRASSLIPW;
+
+struct RASSLIPA{
+    DWORD dwSize;
+    DWORD dwError;
+    CHAR[RAS_MaxIpAddress + 1] szIpAddress;
+}
+alias RASSLIPA* LPRASSLIPA;
+
+struct RASDEVINFOW{
+    DWORD dwSize;
+    WCHAR[RAS_MaxDeviceType + 1] szDeviceType;
+    WCHAR[RAS_MaxDeviceName + 1] szDeviceName;
+}
+alias RASDEVINFOW* LPRASDEVINFOW;
+
+struct RASDEVINFOA{
+    DWORD dwSize;
+    CHAR[RAS_MaxDeviceType + 1] szDeviceType;
+    CHAR[RAS_MaxDeviceName + 1] szDeviceName;
+}
+alias RASDEVINFOA* LPRASDEVINFOA;
+
+struct RASCTRYINFO {
+    DWORD dwSize;
+    DWORD dwCountryID;
+    DWORD dwNextCountryID;
+    DWORD dwCountryCode;
+    DWORD dwCountryNameOffset;
+}
+alias RASCTRYINFO* LPRASCTRYINFO;
+alias RASCTRYINFO  RASCTRYINFOW, RASCTRYINFOA;
+alias RASCTRYINFOW* LPRASCTRYINFOW;
+alias RASCTRYINFOA* LPRASCTRYINFOA;
+
+struct RASIPADDR {
+    BYTE a;
+    BYTE b;
+    BYTE c;
+    BYTE d;
+}
+
+struct RASENTRYW {
+    DWORD dwSize;
+    DWORD dwfOptions;
+    DWORD dwCountryID;
+    DWORD dwCountryCode;
+    WCHAR[RAS_MaxAreaCode + 1] szAreaCode;
+    WCHAR[RAS_MaxPhoneNumber + 1] szLocalPhoneNumber;
+    DWORD dwAlternateOffset;
+    RASIPADDR ipaddr;
+    RASIPADDR ipaddrDns;
+    RASIPADDR ipaddrDnsAlt;
+    RASIPADDR ipaddrWins;
+    RASIPADDR ipaddrWinsAlt;
+    DWORD dwFrameSize;
+    DWORD dwfNetProtocols;
+    DWORD dwFramingProtocol;
+    WCHAR[MAX_PATH] szScript;
+    WCHAR[MAX_PATH] szAutodialDll;
+    WCHAR[MAX_PATH] szAutodialFunc;
+    WCHAR[RAS_MaxDeviceType + 1] szDeviceType;
+    WCHAR[RAS_MaxDeviceName + 1] szDeviceName;
+    WCHAR[RAS_MaxPadType + 1] szX25PadType;
+    WCHAR[RAS_MaxX25Address + 1] szX25Address;
+    WCHAR[RAS_MaxFacilities + 1] szX25Facilities;
+    WCHAR[RAS_MaxUserData + 1] szX25UserData;
+    DWORD dwChannels;
+    DWORD dwReserved1;
+    DWORD dwReserved2;
+    //static if (_WIN32_WINNT >= 0x401) {
+        DWORD dwSubEntries;
+        DWORD dwDialMode;
+        DWORD dwDialExtraPercent;
+        DWORD dwDialExtraSampleSeconds;
+        DWORD dwHangUpExtraPercent;
+        DWORD dwHangUpExtraSampleSeconds;
+        DWORD dwIdleDisconnectSeconds;
+    //}
+    //static if (_WIN32_WINNT >= 0x500) {
+        DWORD dwType;
+        DWORD dwEncryptionType;
+        DWORD dwCustomAuthKey;
+        GUID guidId;
+        WCHAR[MAX_PATH] szCustomDialDll;
+        DWORD dwVpnStrategy;
+    //}
+}
+alias RASENTRYW* LPRASENTRYW;
+
+struct RASENTRYA {
+    DWORD dwSize;
+    DWORD dwfOptions;
+    DWORD dwCountryID;
+    DWORD dwCountryCode;
+    CHAR[RAS_MaxAreaCode + 1] szAreaCode;
+    CHAR[RAS_MaxPhoneNumber + 1] szLocalPhoneNumber;
+    DWORD dwAlternateOffset;
+    RASIPADDR ipaddr;
+    RASIPADDR ipaddrDns;
+    RASIPADDR ipaddrDnsAlt;
+    RASIPADDR ipaddrWins;
+    RASIPADDR ipaddrWinsAlt;
+    DWORD dwFrameSize;
+    DWORD dwfNetProtocols;
+    DWORD dwFramingProtocol;
+    CHAR[MAX_PATH] szScript;
+    CHAR[MAX_PATH] szAutodialDll;
+    CHAR[MAX_PATH] szAutodialFunc;
+    CHAR[RAS_MaxDeviceType + 1] szDeviceType;
+    CHAR[RAS_MaxDeviceName + 1] szDeviceName;
+    CHAR[RAS_MaxPadType + 1] szX25PadType;
+    CHAR[RAS_MaxX25Address + 1] szX25Address;
+    CHAR[RAS_MaxFacilities + 1] szX25Facilities;
+    CHAR[RAS_MaxUserData + 1] szX25UserData;
+    DWORD dwChannels;
+    DWORD dwReserved1;
+    DWORD dwReserved2;
+    //static if (_WIN32_WINNT >= 0x401) {
+        DWORD dwSubEntries;
+        DWORD dwDialMode;
+        DWORD dwDialExtraPercent;
+        DWORD dwDialExtraSampleSeconds;
+        DWORD dwHangUpExtraPercent;
+        DWORD dwHangUpExtraSampleSeconds;
+        DWORD dwIdleDisconnectSeconds;
+    //}
+    //static if (_WIN32_WINNT >= 0x500) {
+        DWORD dwType;
+        DWORD dwEncryptionType;
+        DWORD dwCustomAuthKey;
+        GUID guidId;
+        CHAR[MAX_PATH] szCustomDialDll;
+        DWORD dwVpnStrategy;
+    //}
+}
+alias RASENTRYA* LPRASENTRYA;
+
+
+//static if (_WIN32_WINNT >= 0x401) {
+    struct RASADPARAMS {
+        DWORD dwSize;
+        HWND hwndOwner;
+        DWORD dwFlags;
+        LONG xDlg;
+        LONG yDlg;
+    }
+    alias RASADPARAMS* LPRASADPARAMS;
+
+    struct RASSUBENTRYW{
+        DWORD dwSize;
+        DWORD dwfFlags;
+        WCHAR[RAS_MaxDeviceType + 1] szDeviceType;
+        WCHAR[RAS_MaxDeviceName + 1] szDeviceName;
+        WCHAR[RAS_MaxPhoneNumber + 1] szLocalPhoneNumber;
+        DWORD dwAlternateOffset;
+    }
+    alias RASSUBENTRYW* LPRASSUBENTRYW;
+
+    struct RASSUBENTRYA{
+        DWORD dwSize;
+        DWORD dwfFlags;
+        CHAR[RAS_MaxDeviceType + 1] szDeviceType;
+        CHAR[RAS_MaxDeviceName + 1] szDeviceName;
+        CHAR[RAS_MaxPhoneNumber + 1] szLocalPhoneNumber;
+        DWORD dwAlternateOffset;
+    }
+    alias RASSUBENTRYA* LPRASSUBENTRYA;
+
+    struct RASCREDENTIALSW{
+        DWORD dwSize;
+        DWORD dwMask;
+        WCHAR[UNLEN + 1] szUserName;
+        WCHAR[PWLEN + 1] szPassword;
+        WCHAR[DNLEN + 1] szDomain;
+    }
+    alias RASCREDENTIALSW* LPRASCREDENTIALSW;
+
+    struct RASCREDENTIALSA{
+        DWORD dwSize;
+        DWORD dwMask;
+        CHAR[UNLEN + 1] szUserName;
+        CHAR[PWLEN + 1] szPassword;
+        CHAR[DNLEN + 1] szDomain;
+    }
+    alias RASCREDENTIALSA* LPRASCREDENTIALSA;
+
+    struct RASAUTODIALENTRYW{
+        DWORD dwSize;
+        DWORD dwFlags;
+        DWORD dwDialingLocation;
+        WCHAR[RAS_MaxEntryName + 1] szEntry;
+    }
+    alias RASAUTODIALENTRYW* LPRASAUTODIALENTRYW;
+
+    struct RASAUTODIALENTRYA{
+        DWORD dwSize;
+        DWORD dwFlags;
+        DWORD dwDialingLocation;
+        CHAR[RAS_MaxEntryName + 1] szEntry;
+    }
+    alias RASAUTODIALENTRYA* LPRASAUTODIALENTRYA;
+//}
+
+//static if (_WIN32_WINNT >= 0x500) {
+    struct RASPPPCCP{
+        DWORD dwSize;
+        DWORD dwError;
+        DWORD dwCompressionAlgorithm;
+        DWORD dwOptions;
+        DWORD dwServerCompressionAlgorithm;
+        DWORD dwServerOptions;
+    }
+    alias RASPPPCCP* LPRASPPPCCP;
+
+    struct RASEAPUSERIDENTITYW{
+        WCHAR[UNLEN + 1] szUserName;
+        DWORD dwSizeofEapInfo;
+        BYTE[1] pbEapInfo;
+    }
+    alias RASEAPUSERIDENTITYW* LPRASEAPUSERIDENTITYW;
+
+    struct RASEAPUSERIDENTITYA{
+        CHAR[UNLEN + 1] szUserName;
+        DWORD dwSizeofEapInfo;
+        BYTE[1] pbEapInfo;
+    }
+    alias RASEAPUSERIDENTITYA* LPRASEAPUSERIDENTITYA;
+
+    struct RAS_STATS{
+        DWORD dwSize;
+        DWORD dwBytesXmited;
+        DWORD dwBytesRcved;
+        DWORD dwFramesXmited;
+        DWORD dwFramesRcved;
+        DWORD dwCrcErr;
+        DWORD dwTimeoutErr;
+        DWORD dwAlignmentErr;
+        DWORD dwHardwareOverrunErr;
+        DWORD dwFramingErr;
+        DWORD dwBufferOverrunErr;
+        DWORD dwCompressionRatioIn;
+        DWORD dwCompressionRatioOut;
+        DWORD dwBps;
+        DWORD dwConnectDuration;
+    }
+    alias RAS_STATS* PRAS_STATS;
+//}
+
+
+/* UNICODE typedefs for structures*/
+version (Unicode) {
+    alias RASCONNW RASCONN;
+    alias RASENTRYW RASENTRY;
+    alias RASCONNSTATUSW RASCONNSTATUS;
+    alias RASDIALPARAMSW RASDIALPARAMS;
+    alias RASAMBW RASAMB;
+    alias RASPPPNBFW RASPPPNBF;
+    alias RASPPPIPXW RASPPPIPX;
+    alias RASPPPIPW RASPPPIP;
+    alias RASPPPLCPW RASPPPLCP;
+    alias RASSLIPW RASSLIP;
+    alias RASDEVINFOW RASDEVINFO;
+    alias RASENTRYNAMEW RASENTRYNAME;
+
+    //static if (_WIN32_WINNT >= 0x401) {
+        alias RASSUBENTRYW RASSUBENTRY;
+        alias RASCREDENTIALSW RASCREDENTIALS;
+        alias RASAUTODIALENTRYW RASAUTODIALENTRY;
+    //}
+
+    //static if (_WIN32_WINNT >= 0x500) {
+        alias RASEAPUSERIDENTITYW RASEAPUSERIDENTITY;
+    //}
+
+} else { // ! defined UNICODE
+
+    alias RASCONNA RASCONN;
+    alias RASENTRYA  RASENTRY;
+    alias RASCONNSTATUSA RASCONNSTATUS;
+    alias RASDIALPARAMSA RASDIALPARAMS;
+    alias RASAMBA RASAMB;
+    alias RASPPPNBFA RASPPPNBF;
+    alias RASPPPIPXA RASPPPIPX;
+    alias RASPPPIPA RASPPPIP;
+    alias RASPPPLCPA RASPPPLCP;
+    alias RASSLIPA RASSLIP;
+    alias RASDEVINFOA  RASDEVINFO;
+    alias RASENTRYNAMEA RASENTRYNAME;
+
+    //static if (_WIN32_WINNT >= 0x401) {
+        alias RASSUBENTRYA RASSUBENTRY;
+        alias RASCREDENTIALSA RASCREDENTIALS;
+        alias RASAUTODIALENTRYA RASAUTODIALENTRY;
+    //}
+    //static if (_WIN32_WINNT >= 0x500) {
+        alias RASEAPUSERIDENTITYA RASEAPUSERIDENTITY;
+    //}
+}// ! UNICODE
+
+
+alias RASCONN* LPRASCONN;
+alias RASENTRY* LPRASENTRY;
+alias RASCONNSTATUS* LPRASCONNSTATUS;
+alias RASDIALPARAMS* LPRASDIALPARAMS;
+alias RASAMB* LPRASAM;
+alias RASPPPNBF* LPRASPPPNBF;
+alias RASPPPIPX* LPRASPPPIPX;
+alias RASPPPIP* LPRASPPPIP;
+alias RASPPPLCP* LPRASPPPLCP;
+alias RASSLIP* LPRASSLIP;
+alias RASDEVINFO* LPRASDEVINFO;
+alias RASENTRYNAME* LPRASENTRYNAME;
+
+//static if (_WIN32_WINNT >= 0x401) {
+    alias RASSUBENTRY* LPRASSUBENTRY;
+    alias RASCREDENTIALS* LPRASCREDENTIALS;
+    alias RASAUTODIALENTRY* LPRASAUTODIALENTRY;
+//}
+//static if (_WIN32_WINNT >= 0x500) {
+    alias RASEAPUSERIDENTITY* LPRASEAPUSERIDENTITY;
+//}
+
+/* Callback prototypes */
+deprecated {
+    alias BOOL function (HWND, LPSTR, DWORD, LPDWORD) ORASADFUNC;
+}
+
+alias void function (UINT, RASCONNSTATE, DWORD) RASDIALFUNC;
+alias void function(HRASCONN, UINT, RASCONNSTATE, DWORD, DWORD) RASDIALFUNC1;
+alias DWORD function (ULONG_PTR, DWORD, HRASCONN, UINT,
+RASCONNSTATE, DWORD, DWORD) RASDIALFUNC2;
+
+/* External functions */
+DWORD RasDialA(LPRASDIALEXTENSIONS, LPCSTR, LPRASDIALPARAMSA, DWORD, LPVOID, LPHRASCONN);
+DWORD RasDialW(LPRASDIALEXTENSIONS, LPCWSTR, LPRASDIALPARAMSW, DWORD, LPVOID, LPHRASCONN);
+DWORD RasEnumConnectionsA(LPRASCONNA, LPDWORD, LPDWORD);
+DWORD RasEnumConnectionsW(LPRASCONNW, LPDWORD, LPDWORD);
+DWORD RasEnumEntriesA(LPCSTR, LPCSTR, LPRASENTRYNAMEA, LPDWORD, LPDWORD);
+DWORD RasEnumEntriesW(LPCWSTR, LPCWSTR, LPRASENTRYNAMEW, LPDWORD, LPDWORD);
+DWORD RasGetConnectStatusA(HRASCONN, LPRASCONNSTATUSA);
+DWORD RasGetConnectStatusW(HRASCONN, LPRASCONNSTATUSW);
+DWORD RasGetErrorStringA(UINT, LPSTR, DWORD);
+DWORD RasGetErrorStringW(UINT, LPWSTR, DWORD);
+DWORD RasHangUpA(HRASCONN);
+DWORD RasHangUpW(HRASCONN);
+DWORD RasGetProjectionInfoA(HRASCONN, RASPROJECTION, LPVOID, LPDWORD);
+DWORD RasGetProjectionInfoW(HRASCONN, RASPROJECTION, LPVOID, LPDWORD);
+DWORD RasCreatePhonebookEntryA(HWND, LPCSTR);
+DWORD RasCreatePhonebookEntryW(HWND, LPCWSTR);
+DWORD RasEditPhonebookEntryA(HWND, LPCSTR, LPCSTR);
+DWORD RasEditPhonebookEntryW(HWND, LPCWSTR, LPCWSTR);
+DWORD RasSetEntryDialParamsA(LPCSTR, LPRASDIALPARAMSA, BOOL);
+DWORD RasSetEntryDialParamsW(LPCWSTR, LPRASDIALPARAMSW, BOOL);
+DWORD RasGetEntryDialParamsA(LPCSTR, LPRASDIALPARAMSA, LPBOOL);
+DWORD RasGetEntryDialParamsW(LPCWSTR, LPRASDIALPARAMSW, LPBOOL);
+DWORD RasEnumDevicesA(LPRASDEVINFOA, LPDWORD, LPDWORD);
+DWORD RasEnumDevicesW(LPRASDEVINFOW, LPDWORD, LPDWORD);
+DWORD RasGetCountryInfoA(LPRASCTRYINFOA, LPDWORD);
+DWORD RasGetCountryInfoW(LPRASCTRYINFOW, LPDWORD);
+DWORD RasGetEntryPropertiesA(LPCSTR, LPCSTR, LPRASENTRYA, LPDWORD, LPBYTE, LPDWORD);
+DWORD RasGetEntryPropertiesW(LPCWSTR, LPCWSTR, LPRASENTRYW, LPDWORD, LPBYTE, LPDWORD);
+DWORD RasSetEntryPropertiesA(LPCSTR, LPCSTR, LPRASENTRYA, DWORD, LPBYTE, DWORD);
+DWORD RasSetEntryPropertiesW(LPCWSTR, LPCWSTR, LPRASENTRYW, DWORD, LPBYTE, DWORD);
+DWORD RasRenameEntryA(LPCSTR, LPCSTR, LPCSTR);
+DWORD RasRenameEntryW(LPCWSTR, LPCWSTR, LPCWSTR);
+DWORD RasDeleteEntryA(LPCSTR, LPCSTR);
+DWORD RasDeleteEntryW(LPCWSTR, LPCWSTR);
+DWORD RasValidateEntryNameA(LPCSTR, LPCSTR);
+DWORD RasValidateEntryNameW(LPCWSTR, LPCWSTR);
+
+//static if(_WIN32_WINNT >= 0x401) {
+    alias BOOL function(LPSTR, LPSTR, LPRASADPARAMS, LPDWORD) RASADFUNCA;
+    alias BOOL function(LPWSTR, LPWSTR, LPRASADPARAMS, LPDWORD) RASADFUNCW;
+
+    DWORD RasGetSubEntryHandleA(HRASCONN, DWORD, LPHRASCONN);
+    DWORD RasGetSubEntryHandleW(HRASCONN, DWORD, LPHRASCONN);
+    DWORD RasGetCredentialsA(LPCSTR, LPCSTR, LPRASCREDENTIALSA);
+    DWORD RasGetCredentialsW(LPCWSTR, LPCWSTR, LPRASCREDENTIALSW);
+    DWORD RasSetCredentialsA(LPCSTR, LPCSTR, LPRASCREDENTIALSA, BOOL);
+    DWORD RasSetCredentialsW(LPCWSTR, LPCWSTR, LPRASCREDENTIALSW, BOOL);
+    DWORD RasConnectionNotificationA(HRASCONN, HANDLE, DWORD);
+    DWORD RasConnectionNotificationW(HRASCONN, HANDLE, DWORD);
+    DWORD RasGetSubEntryPropertiesA(LPCSTR, LPCSTR, DWORD, LPRASSUBENTRYA, LPDWORD, LPBYTE, LPDWORD);
+    DWORD RasGetSubEntryPropertiesW(LPCWSTR, LPCWSTR, DWORD, LPRASSUBENTRYW, LPDWORD, LPBYTE, LPDWORD);
+    DWORD RasSetSubEntryPropertiesA(LPCSTR, LPCSTR, DWORD, LPRASSUBENTRYA, DWORD, LPBYTE, DWORD);
+    DWORD RasSetSubEntryPropertiesW(LPCWSTR, LPCWSTR, DWORD, LPRASSUBENTRYW, DWORD, LPBYTE, DWORD);
+    DWORD RasGetAutodialAddressA(LPCSTR, LPDWORD, LPRASAUTODIALENTRYA, LPDWORD, LPDWORD);
+    DWORD RasGetAutodialAddressW(LPCWSTR, LPDWORD, LPRASAUTODIALENTRYW, LPDWORD, LPDWORD);
+    DWORD RasSetAutodialAddressA(LPCSTR, DWORD, LPRASAUTODIALENTRYA, DWORD, DWORD);
+    DWORD RasSetAutodialAddressW(LPCWSTR, DWORD, LPRASAUTODIALENTRYW, DWORD, DWORD);
+    DWORD RasEnumAutodialAddressesA(LPSTR*, LPDWORD, LPDWORD);
+    DWORD RasEnumAutodialAddressesW(LPWSTR*, LPDWORD, LPDWORD);
+    DWORD RasGetAutodialEnableA(DWORD, LPBOOL);
+    DWORD RasGetAutodialEnableW(DWORD, LPBOOL);
+    DWORD RasSetAutodialEnableA(DWORD, BOOL);
+    DWORD RasSetAutodialEnableW(DWORD, BOOL);
+    DWORD RasGetAutodialParamA(DWORD, LPVOID, LPDWORD);
+    DWORD RasGetAutodialParamW(DWORD, LPVOID, LPDWORD);
+    DWORD RasSetAutodialParamA(DWORD, LPVOID, DWORD);
+    DWORD RasSetAutodialParamW(DWORD, LPVOID, DWORD);
+//}
+
+static if (_WIN32_WINNT >= 0x500) {
+    alias DWORD function(HRASCONN) RasCustomHangUpFn;
+    alias DWORD function(LPCTSTR, LPCTSTR, DWORD) RasCustomDeleteEntryNotifyFn;
+    alias DWORD function(HINSTANCE, LPRASDIALEXTENSIONS, LPCTSTR, LPRASDIALPARAMS, DWORD, LPVOID,
+                         LPHRASCONN, DWORD) RasCustomDialFn;
+
+    DWORD RasInvokeEapUI(HRASCONN, DWORD, LPRASDIALEXTENSIONS, HWND);
+    DWORD RasGetLinkStatistics(HRASCONN, DWORD, RAS_STATS*);
+    DWORD RasGetConnectionStatistics(HRASCONN, RAS_STATS*);
+    DWORD RasClearLinkStatistics(HRASCONN, DWORD);
+    DWORD RasClearConnectionStatistics(HRASCONN);
+    DWORD RasGetEapUserDataA(HANDLE, LPCSTR, LPCSTR, BYTE*, DWORD*);
+    DWORD RasGetEapUserDataW(HANDLE, LPCWSTR, LPCWSTR, BYTE*, DWORD*);
+    DWORD RasSetEapUserDataA(HANDLE, LPCSTR, LPCSTR, BYTE*, DWORD);
+    DWORD RasSetEapUserDataW(HANDLE, LPCWSTR, LPCWSTR, BYTE*, DWORD);
+    DWORD RasGetCustomAuthDataA(LPCSTR, LPCSTR, BYTE*, DWORD*);
+    DWORD RasGetCustomAuthDataW(LPCWSTR, LPCWSTR, BYTE*, DWORD*);
+    DWORD RasSetCustomAuthDataA(LPCSTR, LPCSTR, BYTE*, DWORD);
+    DWORD RasSetCustomAuthDataW(LPCWSTR, LPCWSTR, BYTE*, DWORD);
+    DWORD RasGetEapUserIdentityW(LPCWSTR, LPCWSTR, DWORD, HWND, LPRASEAPUSERIDENTITYW*);
+    DWORD RasGetEapUserIdentityA(LPCSTR, LPCSTR, DWORD, HWND, LPRASEAPUSERIDENTITYA*);
+    void RasFreeEapUserIdentityW(LPRASEAPUSERIDENTITYW);
+    void RasFreeEapUserIdentityA(LPRASEAPUSERIDENTITYA);
+}
+
+
+/* UNICODE defines for functions */
+version(Unicode) {
+    alias RasDialW RasDial;
+    alias RasEnumConnectionsW RasEnumConnections;
+    alias RasEnumEntriesW RasEnumEntries;
+    alias RasGetConnectStatusW RasGetConnectStatus;
+    alias RasGetErrorStringW RasGetErrorString;
+    alias RasHangUpW RasHangUp;
+    alias RasGetProjectionInfoW RasGetProjectionInfo;
+    alias RasCreatePhonebookEntryW RasCreatePhonebookEntry;
+    alias RasEditPhonebookEntryW RasEditPhonebookEntry;
+    alias RasSetEntryDialParamsW RasSetEntryDialParams;
+    alias RasGetEntryDialParamsW RasGetEntryDialParams;
+    alias RasEnumDevicesW RasEnumDevices;
+    alias RasGetCountryInfoW RasGetCountryInfo;
+    alias RasGetEntryPropertiesW RasGetEntryProperties;
+    alias RasSetEntryPropertiesW RasSetEntryProperties;
+    alias RasRenameEntryW RasRenameEntry;
+    alias RasDeleteEntryW RasDeleteEntry;
+    alias RasValidateEntryNameW RasValidateEntryName;
+
+    //static if (_WIN32_WINNT >= 0x401) {
+        alias RASADFUNCW RASADFUNC;
+        alias RasGetSubEntryHandleW RasGetSubEntryHandle;
+        alias RasConnectionNotificationW RasConnectionNotification;
+        alias RasGetSubEntryPropertiesW RasGetSubEntryProperties;
+        alias RasSetSubEntryPropertiesW RasSetSubEntryProperties;
+        alias RasGetCredentialsW RasGetCredentials;
+        alias RasSetCredentialsW RasSetCredentials;
+        alias RasGetAutodialAddressW RasGetAutodialAddress;
+        alias RasSetAutodialAddressW RasSetAutodialAddress;
+        alias RasEnumAutodialAddressesW RasEnumAutodialAddresses;
+        alias RasGetAutodialEnableW RasGetAutodialEnable;
+        alias RasSetAutodialEnableW RasSetAutodialEnable;
+        alias RasGetAutodialParamW RasGetAutodialParam;
+        alias RasSetAutodialParamW RasSetAutodialParam;
+    //}
+
+    //static if (_WIN32_WINNT >= 0x500) {
+        alias RasGetEapUserDataW RasGetEapUserData;
+        alias RasSetEapUserDataW RasSetEapUserData;
+        alias RasGetCustomAuthDataW RasGetCustomAuthData;
+        alias RasSetCustomAuthDataW RasSetCustomAuthData;
+        alias RasGetEapUserIdentityW RasGetEapUserIdentity;
+        alias RasFreeEapUserIdentityW RasFreeEapUserIdentity;
+    //}
+
+} else { // !Unicode
+    alias RasDialA RasDial;
+    alias RasEnumConnectionsA RasEnumConnections;
+    alias RasEnumEntriesA RasEnumEntries;
+    alias RasGetConnectStatusA RasGetConnectStatus;
+    alias RasGetErrorStringA RasGetErrorString;
+    alias RasHangUpA RasHangUp;
+    alias RasGetProjectionInfoA RasGetProjectionInfo;
+    alias RasCreatePhonebookEntryA RasCreatePhonebookEntry;
+    alias RasEditPhonebookEntryA RasEditPhonebookEntry;
+    alias RasSetEntryDialParamsA RasSetEntryDialParams;
+    alias RasGetEntryDialParamsA RasGetEntryDialParams;
+    alias RasEnumDevicesA RasEnumDevices;
+    alias RasGetCountryInfoA RasGetCountryInfo;
+    alias RasGetEntryPropertiesA RasGetEntryProperties;
+    alias RasSetEntryPropertiesA RasSetEntryProperties;
+    alias RasRenameEntryA RasRenameEntry;
+    alias RasDeleteEntryA RasDeleteEntry;
+    alias RasValidateEntryNameA RasValidateEntryName;
+
+    //static if (_WIN32_WINNT >= 0x401) {
+        alias RASADFUNCA RASADFUNC;
+        alias RasGetSubEntryHandleA RasGetSubEntryHandle;
+        alias RasConnectionNotificationA RasConnectionNotification;
+        alias RasGetSubEntryPropertiesA RasGetSubEntryProperties;
+        alias RasSetSubEntryPropertiesA RasSetSubEntryProperties;
+        alias RasGetCredentialsA RasGetCredentials;
+        alias RasSetCredentialsA RasSetCredentials;
+        alias RasGetAutodialAddressA RasGetAutodialAddress;
+        alias RasSetAutodialAddressA RasSetAutodialAddress;
+        alias RasEnumAutodialAddressesA RasEnumAutodialAddresses;
+        alias RasGetAutodialEnableA RasGetAutodialEnable;
+        alias RasSetAutodialEnableA RasSetAutodialEnable;
+        alias RasGetAutodialParamA RasGetAutodialParam;
+        alias RasSetAutodialParamA RasSetAutodialParam;
+    //}
+
+    //static if (_WIN32_WINNT >= 0x500) {
+        alias RasGetEapUserDataA RasGetEapUserData;
+        alias RasSetEapUserDataA RasSetEapUserData;
+        alias RasGetCustomAuthDataA RasGetCustomAuthData;
+        alias RasSetCustomAuthDataA RasSetCustomAuthData;
+        alias RasGetEapUserIdentityA RasGetEapUserIdentity;
+        alias RasFreeEapUserIdentityA RasFreeEapUserIdentity;
+    //}
+} //#endif // !Unicode
diff --git a/libphobos/libdruntime/core/sys/windows/rasdlg.d b/libphobos/libdruntime/core/sys/windows/rasdlg.d
new file mode 100644
index 00000000000..0f35327c04d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/rasdlg.d
@@ -0,0 +1,161 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_rasdlg.d)
+ */
+module core.sys.windows.rasdlg;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+import core.sys.windows.ras;
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+enum {
+    RASPBDEVENT_AddEntry = 1,
+    RASPBDEVENT_EditEntry,
+    RASPBDEVENT_RemoveEntry,
+    RASPBDEVENT_DialEntry,
+    RASPBDEVENT_EditGlobals,
+    RASPBDEVENT_NoUser,
+    RASPBDEVENT_NoUserEdit
+}
+
+enum RASPBDFLAG_PositionDlg      =  1;
+enum RASPBDFLAG_ForceCloseOnDial =  2;
+enum RASPBDFLAG_NoUser           = 16;
+
+enum RASEDFLAG_PositionDlg = 1;
+enum RASEDFLAG_NewEntry    = 2;
+enum RASEDFLAG_CloneEntry  = 4;
+
+enum RASDDFLAG_PositionDlg = 1;
+
+align(4):
+
+struct RASENTRYDLGA {
+    DWORD     dwSize = RASENTRYDLGA.sizeof;
+    HWND      hwndOwner;
+    DWORD     dwFlags;
+    LONG      xDlg;
+    LONG      yDlg;
+    CHAR[RAS_MaxEntryName + 1] szEntry;
+    DWORD     dwError;
+    ULONG_PTR reserved;
+    ULONG_PTR reserved2;
+}
+alias RASENTRYDLGA* LPRASENTRYDLGA;
+
+struct RASENTRYDLGW {
+    DWORD     dwSize = RASENTRYDLGW.sizeof;
+    HWND      hwndOwner;
+    DWORD     dwFlags;
+    LONG      xDlg;
+    LONG      yDlg;
+    WCHAR[RAS_MaxEntryName + 1] szEntry;
+    DWORD     dwError;
+    ULONG_PTR reserved;
+    ULONG_PTR reserved2;
+}
+alias RASENTRYDLGW* LPRASENTRYDLGW;
+
+struct RASDIALDLG {
+    DWORD     dwSize;
+    HWND      hwndOwner;
+    DWORD     dwFlags;
+    LONG      xDlg;
+    LONG      yDlg;
+    DWORD     dwSubEntry;
+    DWORD     dwError;
+    ULONG_PTR reserved;
+    ULONG_PTR reserved2;
+}
+alias RASDIALDLG* LPRASDIALDLG;
+
+// Application-defined callback functions
+extern (Windows) {
+    alias VOID function(DWORD, DWORD, LPWSTR, LPVOID) RASPBDLGFUNCW;
+    alias VOID function(DWORD, DWORD, LPSTR, LPVOID) RASPBDLGFUNCA;
+}
+
+struct RASPBDLGA {
+    DWORD         dwSize = RASPBDLGA.sizeof;
+    HWND          hwndOwner;
+    DWORD         dwFlags;
+    LONG          xDlg;
+    LONG          yDlg;
+    ULONG_PTR     dwCallbackId;
+    RASPBDLGFUNCA pCallback;
+    DWORD         dwError;
+    ULONG_PTR     reserved;
+    ULONG_PTR     reserved2;
+}
+alias RASPBDLGA* LPRASPBDLGA;
+
+struct RASPBDLGW {
+    DWORD         dwSize = RASPBDLGW.sizeof;
+    HWND          hwndOwner;
+    DWORD         dwFlags;
+    LONG          xDlg;
+    LONG          yDlg;
+    ULONG_PTR     dwCallbackId;
+    RASPBDLGFUNCW pCallback;
+    DWORD         dwError;
+    ULONG_PTR     reserved;
+    ULONG_PTR     reserved2;
+}
+alias RASPBDLGW* LPRASPBDLGW;
+
+struct RASNOUSERA
+{
+    DWORD           dwSize = RASNOUSERA.sizeof;
+    DWORD           dwFlags;
+    DWORD           dwTimeoutMs;
+    CHAR[UNLEN + 1] szUserName;
+    CHAR[PWLEN + 1] szPassword;
+    CHAR[DNLEN + 1] szDomain;
+}
+alias RASNOUSERA* LPRASNOUSERA;
+
+struct RASNOUSERW {
+    DWORD            dwSize = RASNOUSERW.sizeof;
+    DWORD            dwFlags;
+    DWORD            dwTimeoutMs;
+    WCHAR[UNLEN + 1] szUserName;
+    WCHAR[PWLEN + 1] szPassword;
+    WCHAR[DNLEN + 1] szDomain;
+}
+alias RASNOUSERW* LPRASNOUSERW;
+
+extern (Windows) {
+    BOOL RasDialDlgA(LPSTR, LPSTR, LPSTR, LPRASDIALDLG);
+    BOOL RasDialDlgW(LPWSTR, LPWSTR, LPWSTR, LPRASDIALDLG);
+    BOOL RasEntryDlgA(LPSTR, LPSTR, LPRASENTRYDLGA);
+    BOOL RasEntryDlgW(LPWSTR, LPWSTR, LPRASENTRYDLGW);
+    BOOL RasPhonebookDlgA(LPSTR, LPSTR, LPRASPBDLGA);
+    BOOL RasPhonebookDlgW(LPWSTR, LPWSTR, LPRASPBDLGW);
+}
+
+version (Unicode) {
+    alias RASENTRYDLGW RASENTRYDLG;
+    alias RASPBDLGW RASPBDLG;
+    alias RASNOUSERW RASNOUSER;
+    alias RasDialDlgW RasDialDlg;
+    alias RasEntryDlgW RasEntryDlg;
+    alias RasPhonebookDlgW RasPhonebookDlg;
+} else {
+    alias RASENTRYDLGA RASENTRYDLG;
+    alias RASPBDLGA RASPBDLG;
+    alias RASNOUSERA RASNOUSER;
+    alias RasDialDlgA RasDialDlg;
+    alias RasEntryDlgA RasEntryDlg;
+    alias RasPhonebookDlgA RasPhonebookDlg;
+}
+
+alias RASENTRYDLG* LPRASENTRYDLG;
+alias RASPBDLG* LPRASPBDLG;
+alias RASNOUSER* LPRASNOUSER;
diff --git a/libphobos/libdruntime/core/sys/windows/raserror.d b/libphobos/libdruntime/core/sys/windows/raserror.d
new file mode 100644
index 00000000000..9004444e9ec
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/raserror.d
@@ -0,0 +1,215 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_raserror.d)
+ */
+module core.sys.windows.raserror;
+version (Windows):
+
+enum {
+    SUCCESS = 0,
+    RASBASE = 600,
+    PENDING = RASBASE,
+    ERROR_INVALID_PORT_HANDLE,
+    ERROR_PORT_ALREADY_OPEN,
+    ERROR_BUFFER_TOO_SMALL,
+    ERROR_WRONG_INFO_SPECIFIED,
+    ERROR_CANNOT_SET_PORT_INFO,
+    ERROR_PORT_NOT_CONNECTED,
+    ERROR_EVENT_INVALID,
+    ERROR_DEVICE_DOES_NOT_EXIST,
+    ERROR_DEVICETYPE_DOES_NOT_EXIST,
+    ERROR_BUFFER_INVALID,
+    ERROR_ROUTE_NOT_AVAILABLE,
+    ERROR_ROUTE_NOT_ALLOCATED,
+    ERROR_INVALID_COMPRESSION_SPECIFIED,
+    ERROR_OUT_OF_BUFFERS,
+    ERROR_PORT_NOT_FOUND,
+    ERROR_ASYNC_REQUEST_PENDING,
+    ERROR_ALREADY_DISCONNECTING,
+    ERROR_PORT_NOT_OPEN,
+    ERROR_PORT_DISCONNECTED,
+    ERROR_NO_ENDPOINTS,
+    ERROR_CANNOT_OPEN_PHONEBOOK,
+    ERROR_CANNOT_LOAD_PHONEBOOK,
+    ERROR_CANNOT_FIND_PHONEBOOK_ENTRY,
+    ERROR_CANNOT_WRITE_PHONEBOOK,
+    ERROR_CORRUPT_PHONEBOOK,
+    ERROR_CANNOT_LOAD_STRING,
+    ERROR_KEY_NOT_FOUND,
+    ERROR_DISCONNECTION,
+    ERROR_REMOTE_DISCONNECTION,
+    ERROR_HARDWARE_FAILURE,
+    ERROR_USER_DISCONNECTION,
+    ERROR_INVALID_SIZE,
+    ERROR_PORT_NOT_AVAILABLE,
+    ERROR_CANNOT_PROJECT_CLIENT,
+    ERROR_UNKNOWN,
+    ERROR_WRONG_DEVICE_ATTACHED,
+    ERROR_BAD_STRING,
+    ERROR_REQUEST_TIMEOUT,
+    ERROR_CANNOT_GET_LANA,
+    ERROR_NETBIOS_ERROR,
+    ERROR_SERVER_OUT_OF_RESOURCES,
+    ERROR_NAME_EXISTS_ON_NET,
+    ERROR_SERVER_GENERAL_NET_FAILURE,
+    WARNING_MSG_ALIAS_NOT_ADDED,
+    ERROR_AUTH_INTERNAL,
+    ERROR_RESTRICTED_LOGON_HOURS,
+    ERROR_ACCT_DISABLED,
+    ERROR_PASSWD_EXPIRED,
+    ERROR_NO_DIALIN_PERMISSION,
+    ERROR_SERVER_NOT_RESPONDING,
+    ERROR_FROM_DEVICE,
+    ERROR_UNRECOGNIZED_RESPONSE,
+    ERROR_MACRO_NOT_FOUND,
+    ERROR_MACRO_NOT_DEFINED,
+    ERROR_MESSAGE_MACRO_NOT_FOUND,
+    ERROR_DEFAULTOFF_MACRO_NOT_FOUND,
+    ERROR_FILE_COULD_NOT_BE_OPENED,
+    ERROR_DEVICENAME_TOO_LONG,
+    ERROR_DEVICENAME_NOT_FOUND,
+    ERROR_NO_RESPONSES,
+    ERROR_NO_COMMAND_FOUND,
+    ERROR_WRONG_KEY_SPECIFIED,
+    ERROR_UNKNOWN_DEVICE_TYPE,
+    ERROR_ALLOCATING_MEMORY,
+    ERROR_PORT_NOT_CONFIGURED,
+    ERROR_DEVICE_NOT_READY,
+    ERROR_READING_INI_FILE,
+    ERROR_NO_CONNECTION,
+    ERROR_BAD_USAGE_IN_INI_FILE,
+    ERROR_READING_SECTIONNAME,
+    ERROR_READING_DEVICETYPE,
+    ERROR_READING_DEVICENAME,
+    ERROR_READING_USAGE,
+    ERROR_READING_MAXCONNECTBPS,
+    ERROR_READING_MAXCARRIERBPS,
+    ERROR_LINE_BUSY,
+    ERROR_VOICE_ANSWER,
+    ERROR_NO_ANSWER,
+    ERROR_NO_CARRIER,
+    ERROR_NO_DIALTONE,
+    ERROR_IN_COMMAND,
+    ERROR_WRITING_SECTIONNAME,
+    ERROR_WRITING_DEVICETYPE,
+    ERROR_WRITING_DEVICENAME,
+    ERROR_WRITING_MAXCONNECTBPS,
+    ERROR_WRITING_MAXCARRIERBPS,
+    ERROR_WRITING_USAGE,
+    ERROR_WRITING_DEFAULTOFF,
+    ERROR_READING_DEFAULTOFF,
+    ERROR_EMPTY_INI_FILE,
+    ERROR_AUTHENTICATION_FAILURE,
+    ERROR_PORT_OR_DEVICE,
+    ERROR_NOT_BINARY_MACRO,
+    ERROR_DCB_NOT_FOUND,
+    ERROR_STATE_MACHINES_NOT_STARTED,
+    ERROR_STATE_MACHINES_ALREADY_STARTED,
+    ERROR_PARTIAL_RESPONSE_LOOPING,
+    ERROR_UNKNOWN_RESPONSE_KEY,
+    ERROR_RECV_BUF_FULL,
+    ERROR_CMD_TOO_LONG,
+    ERROR_UNSUPPORTED_BPS,
+    ERROR_UNEXPECTED_RESPONSE,
+    ERROR_INTERACTIVE_MODE,
+    ERROR_BAD_CALLBACK_NUMBER,
+    ERROR_INVALID_AUTH_STATE,
+    ERROR_WRITING_INITBPS,
+    ERROR_X25_DIAGNOSTIC,
+    ERROR_ACCT_EXPIRED,
+    ERROR_CHANGING_PASSWORD,
+    ERROR_OVERRUN,
+    ERROR_RASMAN_CANNOT_INITIALIZE,
+    ERROR_BIPLEX_PORT_NOT_AVAILABLE,
+    ERROR_NO_ACTIVE_ISDN_LINES,
+    ERROR_NO_ISDN_CHANNELS_AVAILABLE,
+    ERROR_TOO_MANY_LINE_ERRORS,
+    ERROR_IP_CONFIGURATION,
+    ERROR_NO_IP_ADDRESSES,
+    ERROR_PPP_TIMEOUT,
+    ERROR_PPP_REMOTE_TERMINATED,
+    ERROR_PPP_NO_PROTOCOLS_CONFIGURED,
+    ERROR_PPP_NO_RESPONSE,
+    ERROR_PPP_INVALID_PACKET,
+    ERROR_PHONE_NUMBER_TOO_LONG,
+    ERROR_IPXCP_NO_DIALOUT_CONFIGURED,
+    ERROR_IPXCP_NO_DIALIN_CONFIGURED,
+    ERROR_IPXCP_DIALOUT_ALREADY_ACTIVE,
+    ERROR_ACCESSING_TCPCFGDLL,
+    ERROR_NO_IP_RAS_ADAPTER,
+    ERROR_SLIP_REQUIRES_IP,
+    ERROR_PROJECTION_NOT_COMPLETE,
+    ERROR_PROTOCOL_NOT_CONFIGURED,
+    ERROR_PPP_NOT_CONVERGING,
+    ERROR_PPP_CP_REJECTED,
+    ERROR_PPP_LCP_TERMINATED,
+    ERROR_PPP_REQUIRED_ADDRESS_REJECTED,
+    ERROR_PPP_NCP_TERMINATED,
+    ERROR_PPP_LOOPBACK_DETECTED,
+    ERROR_PPP_NO_ADDRESS_ASSIGNED,
+    ERROR_CANNOT_USE_LOGON_CREDENTIALS,
+    ERROR_TAPI_CONFIGURATION,
+    ERROR_NO_LOCAL_ENCRYPTION,
+    ERROR_NO_REMOTE_ENCRYPTION,
+    ERROR_REMOTE_REQUIRES_ENCRYPTION,
+    ERROR_IPXCP_NET_NUMBER_CONFLICT,
+    ERROR_INVALID_SMM,
+    ERROR_SMM_UNINITIALIZED,
+    ERROR_NO_MAC_FOR_PORT,
+    ERROR_SMM_TIMEOUT,
+    ERROR_BAD_PHONE_NUMBER,
+    ERROR_WRONG_MODULE,
+    ERROR_INVALID_CALLBACK_NUMBER,
+    ERROR_SCRIPT_SYNTAX,
+    ERROR_HANGUP_FAILED,
+    ERROR_BUNDLE_NOT_FOUND,
+    ERROR_CANNOT_DO_CUSTOMDIAL,
+    ERROR_DIAL_ALREADY_IN_PROGRESS,
+    ERROR_RASAUTO_CANNOT_INITIALIZE,
+    ERROR_CONNECTION_ALREADY_SHARED,
+    ERROR_SHARING_CHANGE_FAILED,
+    ERROR_SHARING_ROUTER_INSTALL,
+    ERROR_SHARE_CONNECTION_FAILED,
+    ERROR_SHARING_PRIVATE_INSTALL,
+    ERROR_CANNOT_SHARE_CONNECTION,
+    ERROR_NO_SMART_CARD_READER,
+    ERROR_SHARING_ADDRESS_EXISTS,
+    ERROR_NO_CERTIFICATE,
+    ERROR_SHARING_MULTIPLE_ADDRESSES,
+    ERROR_FAILED_TO_ENCRYPT,
+    ERROR_BAD_ADDRESS_SPECIFIED,
+    ERROR_CONNECTION_REJECT,
+    ERROR_CONGESTION,
+    ERROR_INCOMPATIBLE,
+    ERROR_NUMBERCHANGED,
+    ERROR_TEMPFAILURE,
+    ERROR_BLOCKED,
+    ERROR_DONOTDISTURB,
+    ERROR_OUTOFORDER,
+    ERROR_UNABLE_TO_AUTHENTICATE_SERVER,
+    ERROR_SMART_CARD_REQUIRED,
+    ERROR_INVALID_FUNCTION_FOR_ENTRY,
+    ERROR_CERT_FOR_ENCRYPTION_NOT_FOUND,
+    ERROR_SHARING_RRAS_CONFLICT,
+    ERROR_SHARING_NO_PRIVATE_LAN,
+    ERROR_NO_DIFF_USER_AT_LOGON,
+    ERROR_NO_REG_CERT_AT_LOGON,
+    ERROR_OAKLEY_NO_CERT,
+    ERROR_OAKLEY_AUTH_FAIL,
+    ERROR_OAKLEY_ATTRIB_FAIL,
+    ERROR_OAKLEY_GENERAL_PROCESSING,
+    ERROR_OAKLEY_NO_PEER_CERT,
+    ERROR_OAKLEY_NO_POLICY,
+    ERROR_OAKLEY_TIMED_OUT,
+    ERROR_OAKLEY_ERROR,
+    ERROR_UNKNOWN_FRAMED_PROTOCOL,
+    ERROR_WRONG_TUNNEL_TYPE,
+    ERROR_UNKNOWN_SERVICE_TYPE,
+    ERROR_CONNECTING_DEVICE_NOT_FOUND,
+    ERROR_NO_EAPTLS_CERTIFICATE, // = RASBASE+198
+    RASBASEEND = ERROR_NO_EAPTLS_CERTIFICATE
+}
diff --git a/libphobos/libdruntime/core/sys/windows/rassapi.d b/libphobos/libdruntime/core/sys/windows/rassapi.d
new file mode 100644
index 00000000000..11d5bb4ad92
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/rassapi.d
@@ -0,0 +1,220 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_rassapi.d)
+ */
+module core.sys.windows.rassapi;
+version (Windows):
+
+private import core.sys.windows.lmcons, core.sys.windows.windef;
+
+// FIXME: check types of constants
+
+enum size_t
+    RASSAPI_MAX_PHONENUMBER_SIZE = 128,
+    RASSAPI_MAX_MEDIA_NAME       =  16,
+    RASSAPI_MAX_PORT_NAME        =  16,
+    RASSAPI_MAX_DEVICE_NAME      = 128,
+    RASSAPI_MAX_DEVICETYPE_NAME  =  16,
+    RASSAPI_MAX_PARAM_KEY_SIZE   =  32;
+
+enum RASPRIV_NoCallback        = 0x01;
+enum RASPRIV_AdminSetCallback  = 0x02;
+enum RASPRIV_CallerSetCallback = 0x04;
+enum RASPRIV_DialinPrivilege   = 0x08;
+enum RASPRIV_CallbackType      = 0x07;
+
+enum {
+    RAS_MODEM_OPERATIONAL = 1,
+    RAS_MODEM_NOT_RESPONDING,
+    RAS_MODEM_HARDWARE_FAILURE,
+    RAS_MODEM_INCORRECT_RESPONSE,
+    RAS_MODEM_UNKNOWN  // = 5
+}
+
+enum {
+    RAS_PORT_NON_OPERATIONAL = 1,
+    RAS_PORT_DISCONNECTED,
+    RAS_PORT_CALLING_BACK,
+    RAS_PORT_LISTENING,
+    RAS_PORT_AUTHENTICATING,
+    RAS_PORT_AUTHENTICATED,
+    RAS_PORT_INITIALIZING // = 7
+}
+
+enum {
+    MEDIA_UNKNOWN,
+    MEDIA_SERIAL,
+    MEDIA_RAS10_SERIAL,
+    MEDIA_X25,
+    MEDIA_ISDN
+}
+
+enum USER_AUTHENTICATED = 0x0001;
+enum MESSENGER_PRESENT  = 0x0002;
+enum PPP_CLIENT         = 0x0004;
+enum GATEWAY_ACTIVE     = 0x0008;
+enum REMOTE_LISTEN      = 0x0010;
+enum PORT_MULTILINKED   = 0x0020;
+
+enum size_t
+    RAS_IPADDRESSLEN  = 15,
+    RAS_IPXADDRESSLEN = 22,
+    RAS_ATADDRESSLEN  = 32;
+
+// FIXME: should these be grouped together?
+enum {
+    RASDOWNLEVEL     = 10,
+    RASADMIN_35      = 35,
+    RASADMIN_CURRENT = 40
+}
+
+alias ULONG IPADDR;
+
+enum RAS_PARAMS_FORMAT {
+    ParamNumber = 0,
+    ParamString
+}
+
+union RAS_PARAMS_VALUE {
+    DWORD Number;
+    struct _String {
+        DWORD Length;
+        PCHAR Data;
+    }
+    _String String;
+}
+
+struct RAS_PARAMETERS {
+    CHAR[RASSAPI_MAX_PARAM_KEY_SIZE] P_Key;
+    RAS_PARAMS_FORMAT                P_Type;
+    BYTE                             P_Attributes;
+    RAS_PARAMS_VALUE                 P_Value;
+}
+
+struct RAS_USER_0 {
+    BYTE                                    bfPrivilege;
+    WCHAR[RASSAPI_MAX_PHONENUMBER_SIZE + 1] szPhoneNumber;
+}
+alias RAS_USER_0* PRAS_USER_0;
+
+struct RAS_PORT_0 {
+    WCHAR[RASSAPI_MAX_PORT_NAME]       wszPortName;
+    WCHAR[RASSAPI_MAX_DEVICETYPE_NAME] wszDeviceType;
+    WCHAR[RASSAPI_MAX_DEVICE_NAME]     wszDeviceName;
+    WCHAR[RASSAPI_MAX_MEDIA_NAME]      wszMediaName;
+    DWORD                              reserved;
+    DWORD                              Flags;
+    WCHAR[UNLEN + 1]                   wszUserName;
+    WCHAR[NETBIOS_NAME_LEN]            wszComputer;
+    DWORD                              dwStartSessionTime; // seconds from 1/1/1970
+    WCHAR[DNLEN + 1]                   wszLogonDomain;
+    BOOL                               fAdvancedServer;
+}
+alias RAS_PORT_0* PRAS_PORT_0;
+
+struct RAS_PPP_NBFCP_RESULT {
+    DWORD dwError;
+    DWORD dwNetBiosError;
+    CHAR[NETBIOS_NAME_LEN + 1]  szName;
+    WCHAR[NETBIOS_NAME_LEN + 1] wszWksta;
+}
+
+struct RAS_PPP_IPCP_RESULT {
+    DWORD dwError;
+    WCHAR[RAS_IPADDRESSLEN + 1] wszAddress;
+}
+
+struct RAS_PPP_IPXCP_RESULT {
+    DWORD dwError;
+    WCHAR[RAS_IPXADDRESSLEN + 1] wszAddress;
+}
+
+struct RAS_PPP_ATCP_RESULT {
+    DWORD dwError;
+    WCHAR[RAS_ATADDRESSLEN + 1] wszAddress;
+}
+
+struct RAS_PPP_PROJECTION_RESULT {
+    RAS_PPP_NBFCP_RESULT nbf;
+    RAS_PPP_IPCP_RESULT  ip;
+    RAS_PPP_IPXCP_RESULT ipx;
+    RAS_PPP_ATCP_RESULT  at;
+}
+
+struct RAS_PORT_1 {
+    RAS_PORT_0 rasport0;
+    DWORD      LineCondition;
+    DWORD      HardwareCondition;
+    DWORD      LineSpeed;
+    WORD       NumStatistics;
+    WORD       NumMediaParms;
+    DWORD      SizeMediaParms;
+    RAS_PPP_PROJECTION_RESULT ProjResult;
+}
+alias RAS_PORT_1* PRAS_PORT_1;
+
+struct RAS_PORT_STATISTICS {
+    DWORD dwBytesXmited;
+    DWORD dwBytesRcved;
+    DWORD dwFramesXmited;
+    DWORD dwFramesRcved;
+    DWORD dwCrcErr;
+    DWORD dwTimeoutErr;
+    DWORD dwAlignmentErr;
+    DWORD dwHardwareOverrunErr;
+    DWORD dwFramingErr;
+    DWORD dwBufferOverrunErr;
+    DWORD dwBytesXmitedUncompressed;
+    DWORD dwBytesRcvedUncompressed;
+    DWORD dwBytesXmitedCompressed;
+    DWORD dwBytesRcvedCompressed;
+    DWORD dwPortBytesXmited;
+    DWORD dwPortBytesRcved;
+    DWORD dwPortFramesXmited;
+    DWORD dwPortFramesRcved;
+    DWORD dwPortCrcErr;
+    DWORD dwPortTimeoutErr;
+    DWORD dwPortAlignmentErr;
+    DWORD dwPortHardwareOverrunErr;
+    DWORD dwPortFramingErr;
+    DWORD dwPortBufferOverrunErr;
+    DWORD dwPortBytesXmitedUncompressed;
+    DWORD dwPortBytesRcvedUncompressed;
+    DWORD dwPortBytesXmitedCompressed;
+    DWORD dwPortBytesRcvedCompressed;
+}
+alias RAS_PORT_STATISTICS* PRAS_PORT_STATISTICS;
+
+struct RAS_SERVER_0 {
+    WORD TotalPorts;
+    WORD PortsInUse;
+    DWORD RasVersion;
+}
+alias RAS_SERVER_0* PRAS_SERVER_0;
+
+extern (Windows) {
+    DWORD RasAdminServerGetInfo(const(WCHAR)*, PRAS_SERVER_0);
+    DWORD RasAdminGetUserAccountServer(const(WCHAR)*, const(WCHAR)*, LPWSTR);
+    DWORD RasAdminUserGetInfo(const(WCHAR)*, const(WCHAR)*, PRAS_USER_0);
+    DWORD RasAdminUserSetInfo(const(WCHAR)*, const(WCHAR)*, PRAS_USER_0);
+    DWORD RasAdminPortEnum(WCHAR*, PRAS_PORT_0*, WORD*);
+    DWORD RasAdminPortGetInfo(const(WCHAR)*, const(WCHAR)*, RAS_PORT_1*,
+     RAS_PORT_STATISTICS*, RAS_PARAMETERS**);
+    DWORD RasAdminPortClearStatistics(const(WCHAR)*, const(WCHAR)*);
+    DWORD RasAdminPortDisconnect(const(WCHAR)*, const(WCHAR)*);
+    DWORD RasAdminFreeBuffer(PVOID);
+    DWORD RasAdminGetErrorString(UINT, WCHAR*, DWORD);
+    BOOL RasAdminAcceptNewConnection(RAS_PORT_1*, RAS_PORT_STATISTICS*,
+     RAS_PARAMETERS*);
+    VOID RasAdminConnectionHangupNotification(RAS_PORT_1*,
+      RAS_PORT_STATISTICS*, RAS_PARAMETERS*);
+    DWORD RasAdminGetIpAddressForUser (WCHAR*, WCHAR*, IPADDR*, BOOL*);
+    VOID RasAdminReleaseIpAddress (WCHAR*, WCHAR*,IPADDR*);
+    DWORD RasAdminGetUserParms(WCHAR*, PRAS_USER_0);
+    DWORD RasAdminSetUserParms(WCHAR*, DWORD, PRAS_USER_0);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/reason.d b/libphobos/libdruntime/core/sys/windows/reason.d
new file mode 100644
index 00000000000..752f28e5c2d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/reason.d
@@ -0,0 +1,63 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_reason.d)
+ */
+module core.sys.windows.reason;
+version (Windows):
+
+private import core.sys.windows.w32api, core.sys.windows.windef;
+
+static assert (_WIN32_WINNT >= 0x501,
+  "core.sys.windows.reason is only available on WindowsXP and later");
+
+
+enum : DWORD {
+    SHTDN_REASON_MAJOR_OTHER           = 0x00000000,
+    SHTDN_REASON_MAJOR_HARDWARE        = 0x00010000,
+    SHTDN_REASON_MAJOR_OPERATINGSYSTEM = 0x00020000,
+    SHTDN_REASON_MAJOR_SOFTWARE        = 0x00030000,
+    SHTDN_REASON_MAJOR_APPLICATION     = 0x00040000,
+    SHTDN_REASON_MAJOR_SYSTEM          = 0x00050000,
+    SHTDN_REASON_MAJOR_POWER           = 0x00060000,
+    SHTDN_REASON_MAJOR_LEGACY_API      = 0x00070000
+}
+
+enum : DWORD {
+    SHTDN_REASON_MINOR_OTHER,
+    SHTDN_REASON_MINOR_MAINTENANCE,
+    SHTDN_REASON_MINOR_INSTALLATION,
+    SHTDN_REASON_MINOR_UPGRADE,
+    SHTDN_REASON_MINOR_RECONFIG,
+    SHTDN_REASON_MINOR_HUNG,
+    SHTDN_REASON_MINOR_UNSTABLE,
+    SHTDN_REASON_MINOR_DISK,
+    SHTDN_REASON_MINOR_PROCESSOR,
+    SHTDN_REASON_MINOR_NETWORKCARD,
+    SHTDN_REASON_MINOR_POWER_SUPPLY,
+    SHTDN_REASON_MINOR_CORDUNPLUGGED,
+    SHTDN_REASON_MINOR_ENVIRONMENT,
+    SHTDN_REASON_MINOR_HARDWARE_DRIVER,
+    SHTDN_REASON_MINOR_OTHERDRIVER,
+    SHTDN_REASON_MINOR_BLUESCREEN,
+    SHTDN_REASON_MINOR_SERVICEPACK,
+    SHTDN_REASON_MINOR_HOTFIX,
+    SHTDN_REASON_MINOR_SECURITYFIX,
+    SHTDN_REASON_MINOR_SECURITY,
+    SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY,
+    SHTDN_REASON_MINOR_WMI,
+    SHTDN_REASON_MINOR_SERVICEPACK_UNINSTALL,
+    SHTDN_REASON_MINOR_HOTFIX_UNINSTALL,
+    SHTDN_REASON_MINOR_SECURITYFIX_UNINSTALL,
+    SHTDN_REASON_MINOR_MMC,         // = 0x00000019
+    SHTDN_REASON_MINOR_TERMSRV         = 0x00000020
+}
+
+enum : DWORD {
+    SHTDN_REASON_FLAG_USER_DEFINED     = 0x40000000,
+    SHTDN_REASON_FLAG_PLANNED          = 0x80000000
+}
diff --git a/libphobos/libdruntime/core/sys/windows/regstr.d b/libphobos/libdruntime/core/sys/windows/regstr.d
new file mode 100644
index 00000000000..23029647ce2
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/regstr.d
@@ -0,0 +1,816 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_regstr.d)
+ */
+module core.sys.windows.regstr;
+version (Windows):
+
+// TODO: fix possible conflict with shloj. Sort out NEC_98 issue.
+
+private import core.sys.windows.windef;
+
+enum REGSTR_MAX_VALUE_LENGTH = 256;
+
+enum {
+    IT_COMPACT = 0,
+    IT_TYPICAL,
+    IT_PORTABLE,
+    IT_CUSTOM // = 3
+}
+
+enum DOSOPTGF_DEFCLEAN = 1;
+
+enum DOSOPTF_DEFAULT     = 0x01;
+enum DOSOPTF_SUPPORTED   = 0x02;
+enum DOSOPTF_ALWAYSUSE   = 0x04;
+enum DOSOPTF_USESPMODE   = 0x08;
+enum DOSOPTF_PROVIDESUMB = 0x10;
+enum DOSOPTF_NEEDSETUP   = 0x20;
+enum DOSOPTF_INDOSSTART  = 0x40;
+enum DOSOPTF_MULTIPLE    = 0x80;
+
+enum SUF_FIRSTTIME  = 0x0001;
+enum SUF_EXPRESS    = 0x0002;
+enum SUF_BATCHINF   = 0x0004;
+enum SUF_CLEAN      = 0x0008;
+enum SUF_INSETUP    = 0x0010;
+enum SUF_NETSETUP   = 0x0020;
+enum SUF_NETHDBOOT  = 0x0040;
+enum SUF_NETRPLBOOT = 0x0080;
+enum SUF_SBSCOPYOK  = 0x0100;
+
+enum VPDF_DISABLEPWRMGMT       = 1;
+enum VPDF_FORCEAPM10MODE       = 2;
+enum VPDF_SKIPINTELSLCHECK     = 4;
+enum VPDF_DISABLEPWRSTATUSPOLL = 8;
+
+enum PCMCIA_OPT_HAVE_SOCKET  = 0x01;
+enum PCMCIA_OPT_AUTOMEM      = 0x04;
+enum PCMCIA_OPT_NO_SOUND     = 0x08;
+enum PCMCIA_OPT_NO_AUDIO     = 0x10;
+enum PCMCIA_OPT_NO_APMREMOVE = 0x20;
+
+enum PCMCIA_DEF_MEMBEGIN   = 0x0C0000;
+enum PCMCIA_DEF_MEMEND     = 0xFFFFFF;
+enum PCMCIA_DEF_MEMLEN     = 0x001000;
+enum PCMCIA_DEF_MIN_REGION = 0x010000;
+
+enum {
+    PCI_OPTIONS_USE_BIOS         = 1,
+    PCI_OPTIONS_USE_IRQ_STEERING = 2
+}
+
+enum PCI_FLAG_NO_VIDEO_IRQ      = 0x0001;
+enum PCI_FLAG_PCMCIA_WANT_IRQ   = 0x0002;
+enum PCI_FLAG_DUAL_IDE          = 0x0004;
+enum PCI_FLAG_NO_ENUM_AT_ALL    = 0x0008;
+enum PCI_FLAG_ENUM_NO_RESOURCE  = 0x0010;
+enum PCI_FLAG_NEED_DWORD_ACCESS = 0x0020;
+enum PCI_FLAG_SINGLE_FUNCTION   = 0x0040;
+enum PCI_FLAG_ALWAYS_ENABLED    = 0x0080;
+enum PCI_FLAG_IS_IDE            = 0x0100;
+enum PCI_FLAG_IS_VIDEO          = 0x0200;
+enum PCI_FLAG_FAIL_START        = 0x0400;
+
+enum size_t REGSTR_VAL_MAX_HCID_LEN = 1024;
+
+enum REGDF_NOTDETIO        = 0x00000001;
+enum REGDF_NOTDETMEM       = 0x00000002;
+enum REGDF_NOTDETIRQ       = 0x00000004;
+enum REGDF_NOTDETDMA       = 0x00000008;
+enum REGDF_NOTDETALL       = REGDF_NOTDETIO | REGDF_NOTDETMEM | REGDF_NOTDETIRQ | REGDF_NOTDETDMA;
+enum REGDF_NEEDFULLCONFIG  = 0x00000010;
+enum REGDF_GENFORCEDCONFIG = 0x00000020;
+enum REGDF_NODETCONFIG     = 0x00008000;
+enum REGDF_CONFLICTIO      = 0x00010000;
+enum REGDF_CONFLICTMEM     = 0x00020000;
+enum REGDF_CONFLICTIRQ     = 0x00040000;
+enum REGDF_CONFLICTDMA     = 0x00080000;
+enum REGDF_CONFLICTALL     = REGDF_CONFLICTIO | REGDF_CONFLICTMEM | REGDF_CONFLICTIRQ | REGDF_CONFLICTDMA;
+enum REGDF_MAPIRQ2TO9      = 0x00100000;
+enum REGDF_NOTVERIFIED     = 0x80000000;
+
+enum CONFIGFLAG_DISABLED       = 0x0001;
+enum CONFIGFLAG_REMOVED        = 0x0002;
+enum CONFIGFLAG_MANUAL_INSTALL = 0x0004;
+enum CONFIGFLAG_IGNORE_BOOT_LC = 0x0008;
+enum CONFIGFLAG_NET_BOOT       = 0x0010;
+enum CONFIGFLAG_REINSTALL      = 0x0020;
+enum CONFIGFLAG_FAILEDINSTALL  = 0x0040;
+enum CONFIGFLAG_CANTSTOPACHILD = 0x0080;
+enum CONFIGFLAG_OKREMOVEROM    = 0x0100;
+enum CONFIGFLAG_NOREMOVEEXIT   = 0x0200;
+
+enum CSCONFIGFLAG_DISABLED      = 1;
+enum CSCONFIGFLAG_DO_NOT_CREATE = 2;
+enum CSCONFIGFLAG_DO_NOT_START  = 4;
+enum CSCONFIGFLAG_BITS          = 7;
+
+enum DMSTATEFLAG_APPLYTOALL = 1;
+
+enum NUM_RESOURCE_MAP = 256;
+
+enum MF_FLAGS_EVEN_IF_NO_RESOURCE         = 1;
+enum MF_FLAGS_NO_CREATE_IF_NO_RESOURCE    = 2;
+enum MF_FLAGS_FILL_IN_UNKNOWN_RESOURCE    = 4;
+enum MF_FLAGS_CREATE_BUT_NO_SHOW_DISABLED = 8;
+
+enum EISAFLAG_NO_IO_MERGE   = 1;
+enum EISAFLAG_SLOT_IO_FIRST = 2;
+
+enum EISA_NO_MAX_FUNCTION   = 0xFF;
+
+enum NUM_EISA_RANGES = 4;
+
+enum APMMENUSUSPEND_DISABLED = 0;
+enum APMMENUSUSPEND_ENABLED  = 1;
+enum APMMENUSUSPEND_UNDOCKED = 2;
+enum APMMENUSUSPEND_NOCHANGE = 128;
+
+//#ifndef NEC_98
+const TCHAR[]
+    REGSTR_KEY_ISAENUM             = "ISAPnP",
+    REGSTR_KEY_EISAENUM            = "EISA",
+    REGSTR_VAL_EISA_RANGES         = "EISARanges",
+    REGSTR_VAL_EISA_FUNCTIONS      = "EISAFunctions",
+    REGSTR_VAL_EISA_FUNCTIONS_MASK = "EISAFunctionsMask",
+    REGSTR_VAL_EISA_FLAGS          = "EISAFlags",
+    REGSTR_VAL_EISA_SIMULATE_INT15 = "EISASimulateInt15";
+// #else
+// #define REGSTR_KEY_ISAENUM   TEXT("C98PnP")
+// #define REGSTR_KEY_EISAENUM  TEXT("NESA")
+// #define  REGSTR_VAL_EISA_RANGES  TEXT("NESARanges")
+// #define  REGSTR_VAL_EISA_FUNCTIONS   TEXT("NESAFunctions")
+// #define  REGSTR_VAL_EISA_FUNCTIONS_MASK  TEXT("NESAFunctionsMask")
+// #define  REGSTR_VAL_EISA_FLAGS   TEXT("NESAFlags")
+// #define  REGSTR_VAL_EISA_SIMULATE_INT15  TEXT("NESASimulateInt15")
+// #endif
+
+const TCHAR[]
+    REGSTR_KEY_CLASS                     = `Class`,
+    REGSTR_KEY_CONFIG                    = `Config`,
+    REGSTR_KEY_ENUM                      = `Enum`,
+    REGSTR_KEY_ROOTENUM                  = `Root`,
+    REGSTR_KEY_BIOSENUM                  = `BIOS`,
+    REGSTR_KEY_PCMCIAENUM                = `PCMCIA`,
+    REGSTR_KEY_PCIENUM                   = `PCI`,
+    REGSTR_KEY_LOGCONFIG                 = `LogConfig`,
+    REGSTR_KEY_SYSTEMBOARD               = `*PNP0C01`,
+    REGSTR_KEY_APM                       = `*PNP0C05`,
+    REGSTR_KEY_INIUPDATE                 = `IniUpdate`,
+    REG_KEY_INSTDEV                      = `Installed`,
+    REGSTR_KEY_DOSOPTCDROM               = `CD-ROM`,
+    REGSTR_KEY_DOSOPTMOUSE               = `MOUSE`,
+    REGSTR_DEFAULT_INSTANCE              = `0000`,
+    REGSTR_PATH_MOTHERBOARD              = REGSTR_KEY_SYSTEMBOARD ~ `\` ~ REGSTR_DEFAULT_INSTANCE,
+    REGSTR_PATH_SETUP                    = `Software\Microsoft\Windows\CurrentVersion`,
+    REGSTR_PATH_PIFCONVERT               = `Software\Microsoft\Windows\CurrentVersion\PIFConvert`,
+    REGSTR_PATH_MSDOSOPTS                = `Software\Microsoft\Windows\CurrentVersion\MS-DOSOptions`,
+    REGSTR_PATH_MSDOSEMU                 = `Software\Microsoft\Windows\CurrentVersion\MS-DOS Emulation`,
+    REGSTR_PATH_NEWDOSBOX                = `Software\Microsoft\Windows\CurrentVersion\MS-DOS Emulation\AppCompat`,
+    REGSTR_PATH_RUNONCE                  = `Software\Microsoft\Windows\CurrentVersion\RunOnce`,
+    REGSTR_PATH_RUN                      = `Software\Microsoft\Windows\CurrentVersion\Run`,
+    REGSTR_PATH_RUNSERVICESONCE          = `Software\Microsoft\Windows\CurrentVersion\RunServicesOnce`,
+    REGSTR_PATH_RUNSERVICES              = `Software\Microsoft\Windows\CurrentVersion\RunServices`,
+
+//#ifndef REGSTR_PATH_EXPLORER /* also in shlobj.h */
+    REGSTR_PATH_EXPLORER                 = `Software\Microsoft\Windows\CurrentVersion\Explorer`,
+//#endif
+
+    REGSTR_PATH_DETECT                   = `Software\Microsoft\Windows\CurrentVersion\Detect`,
+    REGSTR_PATH_APPPATHS                 = `Software\Microsoft\Windows\CurrentVersion\App Paths`,
+    REGSTR_PATH_UNINSTALL                = `Software\Microsoft\Windows\CurrentVersion\Uninstall`,
+    REGSTR_PATH_REALMODENET              = `Software\Microsoft\Windows\CurrentVersion\Network\Real Mode Net`,
+    REGSTR_PATH_NETEQUIV                 = `Software\Microsoft\Windows\CurrentVersion\Network\Equivalent`,
+    REGSTR_PATH_CVNETWORK                = `Software\Microsoft\Windows\CurrentVersion\Network`,
+    REGSTR_PATH_IDCONFIGDB               = `System\CurrentControlSet\Control\IDConfigDB`,
+    REGSTR_PATH_CLASS                    = `System\CurrentControlSet\Services\Class`,
+    REGSTR_PATH_DISPLAYSETTINGS          = `Display\Settings`,
+    REGSTR_PATH_FONTS                    = `Display\Fonts`,
+    REGSTR_PATH_ENUM                     = `Enum`,
+    REGSTR_PATH_ROOT                     = `Enum\Root`,
+    REGSTR_PATH_SERVICES                 = `System\CurrentControlSet\Services`,
+    REGSTR_PATH_VXD                      = `System\CurrentControlSet\Services\VxD`,
+    REGSTR_PATH_IOS                      = `System\CurrentControlSet\Services\VxD\IOS`,
+    REGSTR_PATH_VMM                      = `System\CurrentControlSet\Services\VxD\VMM`,
+    REGSTR_PATH_VPOWERD                  = `System\CurrentControlSet\Services\VxD\VPOWERD`,
+    REGSTR_PATH_VNETSUP                  = `System\CurrentControlSet\Services\VxD\VNETSUP`,
+    REGSTR_PATH_NWREDIR                  = `System\CurrentControlSet\Services\VxD\NWREDIR`,
+    REGSTR_PATH_NCPSERVER                = `System\CurrentControlSet\Services\NcpServer\Parameters`,
+    REGSTR_PATH_IOARB                    = `System\CurrentControlSet\Services\Arbitrators\IOArb`,
+    REGSTR_PATH_ADDRARB                  = `System\CurrentControlSet\Services\Arbitrators\AddrArb`,
+    REGSTR_PATH_DMAARB                   = `System\CurrentControlSet\Services\Arbitrators\DMAArb`,
+    REGSTR_PATH_IRQARB                   = `System\CurrentControlSet\Services\Arbitrators\IRQArb`,
+    REGSTR_PATH_CODEPAGE                 = `System\CurrentControlSet\Control\Nls\Codepage`,
+    REGSTR_PATH_FILESYSTEM               = `System\CurrentControlSet\Control\FileSystem`,
+    REGSTR_PATH_FILESYSTEM_NOVOLTRACK    = `System\CurrentControlSet\Control\FileSystem\NoVolTrack`,
+    REGSTR_PATH_CDFS                     = `System\CurrentControlSet\Control\FileSystem\CDFS`,
+    REGSTR_PATH_WINBOOT                  = `System\CurrentControlSet\Control\WinBoot`,
+    REGSTR_PATH_INSTALLEDFILES           = `System\CurrentControlSet\Control\InstalledFiles`,
+    REGSTR_PATH_VMM32FILES               = `System\CurrentControlSet\Control\VMM32Files`,
+
+    REGSTR_VAL_BITSPERPIXEL              = `BitsPerPixel`,
+    REGSTR_VAL_RESOLUTION                = `Resolution`,
+    REGSTR_VAL_DPILOGICALX               = `DPILogicalX`,
+    REGSTR_VAL_DPILOGICALY               = `DPILogicalY`,
+    REGSTR_VAL_DPIPHYSICALX              = `DPIPhysicalX`,
+    REGSTR_VAL_DPIPHYSICALY              = `DPIPhysicalY`,
+    REGSTR_VAL_REFRESHRATE               = `RefreshRate`,
+    REGSTR_VAL_DISPLAYFLAGS              = `DisplayFlags`,
+    REGSTR_PATH_CONTROLPANEL             = `Control Panel`,
+    REGSTR_PATH_CONTROLSFOLDER           = `Software\Microsoft\Windows\CurrentVersion\Controls Folder`,
+    REGSTR_VAL_DOSCP                     = `OEMCP`,
+    REGSTR_VAL_WINCP                     = `ACP`,
+    REGSTR_PATH_DYNA_ENUM                = `Config Manager\Enum`,
+    REGSTR_VAL_HARDWARE_KEY              = `HardWareKey`,
+    REGSTR_VAL_ALLOCATION                = `Allocation`,
+    REGSTR_VAL_PROBLEM                   = `Problem`,
+    REGSTR_VAL_STATUS                    = `Status`,
+    REGSTR_VAL_DONTUSEMEM                = `DontAllocLastMem`,
+    REGSTR_VAL_SYSTEMROOT                = `SystemRoot`,
+    REGSTR_VAL_BOOTCOUNT                 = `BootCount`,
+    REGSTR_VAL_REALNETSTART              = `RealNetStart`,
+    REGSTR_VAL_MEDIA                     = `MediaPath`,
+    REGSTR_VAL_CONFIG                    = `ConfigPath`,
+    REGSTR_VAL_DEVICEPATH                = `DevicePath`,
+    REGSTR_VAL_SRCPATH                   = `SourcePath`,
+    REGSTR_VAL_OLDWINDIR                 = `OldWinDir`,
+    REGSTR_VAL_SETUPFLAGS                = `SetupFlags`,
+    REGSTR_VAL_REGOWNER                  = `RegisteredOwner`,
+    REGSTR_VAL_REGORGANIZATION           = `RegisteredOrganization`,
+    REGSTR_VAL_LICENSINGINFO             = `LicensingInfo`,
+    REGSTR_VAL_OLDMSDOSVER               = `OldMSDOSVer`,
+    REGSTR_VAL_FIRSTINSTALLDATETIME      = `FirstInstallDateTime`,
+    REGSTR_VAL_INSTALLTYPE               = `InstallType`,
+    REGSTR_VAL_WRAPPER                   = `Wrapper`,
+
+    REGSTR_KEY_SETUP                     = `\Setup`,
+    REGSTR_VAL_BOOTDIR                   = `BootDir`,
+    REGSTR_VAL_WINBOOTDIR                = `WinbootDir`,
+    REGSTR_VAL_WINDIR                    = `WinDir`,
+    REGSTR_VAL_APPINSTPATH               = `AppInstallPath`,
+    REGSTR_PATH_EBD                      = REGSTR_PATH_SETUP ~ REGSTR_KEY_SETUP ~ `\EBD`,
+    REGSTR_KEY_EBDFILESLOCAL             = `EBDFilesLocale`,
+    REGSTR_KEY_EBDFILESKEYBOARD          = `EBDFilesKeyboard`,
+    REGSTR_KEY_EBDAUTOEXECBATLOCAL       = `EBDAutoexecBatLocale`,
+    REGSTR_KEY_EBDAUTOEXECBATKEYBOARD    = `EBDAutoexecBatKeyboard`,
+    REGSTR_KEY_EBDCONFIGSYSLOCAL         = `EBDConfigSysLocale`,
+    REGSTR_KEY_EBDCONFIGSYSKEYBOARD      = `EBDConfigSysKeyboard`,
+    REGSTR_VAL_MSDOSMODE                 = `MSDOSMode`,
+    REGSTR_VAL_MSDOSMODEDISCARD          = `Discard`,
+    REGSTR_VAL_DOSOPTGLOBALFLAGS         = `GlobalFlags`,
+    REGSTR_VAL_DOSOPTFLAGS               = `Flags`,
+    REGSTR_VAL_OPTORDER                  = `Order`,
+    REGSTR_VAL_CONFIGSYS                 = `Config.Sys`,
+    REGSTR_VAL_AUTOEXEC                  = `Autoexec.Bat`,
+    REGSTR_VAL_STDDOSOPTION              = `StdOption`,
+    REGSTR_VAL_DOSOPTTIP                 = `TipText`,
+
+    REGSTR_VAL_DOSPAGER                  = `DOSPager`,
+    REGSTR_VAL_VXDGROUPS                 = `VXDGroups`,
+    REGSTR_VAL_VPOWERDFLAGS              = `Flags`,
+
+    REGSTR_VAL_WORKGROUP                 = `Workgroup`,
+    REGSTR_VAL_DIRECTHOST                = `DirectHost`,
+    REGSTR_VAL_FILESHARING               = `FileSharing`,
+    REGSTR_VAL_PRINTSHARING              = `PrintSharing`,
+    REGSTR_VAL_FIRSTNETDRIVE             = `FirstNetworkDrive`,
+    REGSTR_VAL_MAXCONNECTIONS            = `MaxConnections`,
+    REGSTR_VAL_APISUPPORT                = `APISupport`,
+    REGSTR_VAL_MAXRETRY                  = `MaxRetry`,
+    REGSTR_VAL_MINRETRY                  = `MinRetry`,
+    REGSTR_VAL_SUPPORTLFN                = `SupportLFN`,
+    REGSTR_VAL_SUPPORTBURST              = `SupportBurst`,
+    REGSTR_VAL_SUPPORTTUNNELLING         = `SupportTunnelling`,
+    REGSTR_VAL_FULLTRACE                 = `FullTrace`,
+    REGSTR_VAL_READCACHING               = `ReadCaching`,
+    REGSTR_VAL_SHOWDOTS                  = `ShowDots`,
+    REGSTR_VAL_GAPTIME                   = `GapTime`,
+    REGSTR_VAL_SEARCHMODE                = `SearchMode`,
+    REGSTR_VAL_SHELLVERSION              = `ShellVersion`,
+    REGSTR_VAL_MAXLIP                    = `MaxLIP`,
+    REGSTR_VAL_PRESERVECASE              = `PreserveCase`,
+    REGSTR_VAL_OPTIMIZESFN               = `OptimizeSFN`,
+    REGSTR_VAL_NCP_BROWSEMASTER          = `BrowseMaster`,
+    REGSTR_VAL_NCP_USEPEERBROWSING       = `Use_PeerBrowsing`,
+    REGSTR_VAL_NCP_USESAP                = `Use_Sap`,
+    REGSTR_VAL_WIN31FILESYSTEM           = `Win31FileSystem`,
+    REGSTR_VAL_PRESERVELONGNAMES         = `PreserveLongNames`,
+    REGSTR_VAL_DRIVEWRITEBEHIND          = `DriveWriteBehind`,
+    REGSTR_VAL_ASYNCFILECOMMIT           = `AsyncFileCommit`,
+    REGSTR_VAL_PATHCACHECOUNT            = `PathCache`,
+    REGSTR_VAL_NAMECACHECOUNT            = `NameCache`,
+    REGSTR_VAL_CONTIGFILEALLOC           = `ContigFileAllocSize`,
+    REGSTR_VAL_VOLIDLETIMEOUT            = `VolumeIdleTimeout`,
+    REGSTR_VAL_BUFFIDLETIMEOUT           = `BufferIdleTimeout`,
+    REGSTR_VAL_BUFFAGETIMEOUT            = `BufferAgeTimeout`,
+    REGSTR_VAL_NAMENUMERICTAIL           = `NameNumericTail`,
+    REGSTR_VAL_READAHEADTHRESHOLD        = `ReadAheadThreshold`,
+    REGSTR_VAL_DOUBLEBUFFER              = `DoubleBuffer`,
+    REGSTR_VAL_SOFTCOMPATMODE            = `SoftCompatMode`,
+    REGSTR_VAL_DRIVESPINDOWN             = `DriveSpinDown`,
+    REGSTR_VAL_FORCEPMIO                 = `ForcePMIO`,
+    REGSTR_VAL_FORCERMIO                 = `ForceRMIO`,
+    REGSTR_VAL_LASTBOOTPMDRVS            = `LastBootPMDrvs`,
+    REGSTR_VAL_VIRTUALHDIRQ              = `VirtualHDIRQ`,
+    REGSTR_VAL_SRVNAMECACHECOUNT         = `ServerNameCacheMax`,
+    REGSTR_VAL_SRVNAMECACHE              = `ServerNameCache`,
+    REGSTR_VAL_SRVNAMECACHENETPROV       = `ServerNameCacheNumNets`,
+    REGSTR_VAL_AUTOMOUNT                 = `AutoMountDrives`,
+    REGSTR_VAL_COMPRESSIONMETHOD         = `CompressionAlgorithm`,
+    REGSTR_VAL_COMPRESSIONTHRESHOLD      = `CompressionThreshold`,
+    REGSTR_VAL_CDCACHESIZE               = `CacheSize`,
+    REGSTR_VAL_CDPREFETCH                = `Prefetch`,
+    REGSTR_VAL_CDPREFETCHTAIL            = `PrefetchTail`,
+    REGSTR_VAL_CDRAWCACHE                = `RawCache`,
+    REGSTR_VAL_CDEXTERRORS               = `ExtendedErrors`,
+    REGSTR_VAL_CDSVDSENSE                = `SVDSense`,
+    REGSTR_VAL_CDSHOWVERSIONS            = `ShowVersions`,
+    REGSTR_VAL_CDCOMPATNAMES             = `MSCDEXCompatNames`,
+    REGSTR_VAL_CDNOREADAHEAD             = `NoReadAhead`,
+    REGSTR_VAL_SCSI                      = `SCSI\`,
+    REGSTR_VAL_ESDI                      = `ESDI\`,
+    REGSTR_VAL_FLOP                      = `FLOP\`,
+    REGSTR_VAL_DISK                      = `GenDisk`,
+    REGSTR_VAL_CDROM                     = `GenCD`,
+    REGSTR_VAL_TAPE                      = `TAPE`,
+    REGSTR_VAL_SCANNER                   = `SCANNER`,
+    REGSTR_VAL_FLOPPY                    = `FLOPPY`,
+    REGSTR_VAL_SCSITID                   = `SCSITargetID`,
+    REGSTR_VAL_SCSILUN                   = `SCSILUN`,
+    REGSTR_VAL_REVLEVEL                  = `RevisionLevel`,
+    REGSTR_VAL_PRODUCTID                 = `ProductId`,
+    REGSTR_VAL_PRODUCTTYPE               = `ProductType`,
+    REGSTR_VAL_DEVTYPE                   = `DeviceType`,
+    REGSTR_VAL_REMOVABLE                 = `Removable`,
+    REGSTR_VAL_CURDRVLET                 = `CurrentDriveLetterAssignment`,
+    REGSTR_VAL_USRDRVLET                 = `UserDriveLetterAssignment`,
+    REGSTR_VAL_SYNCDATAXFER              = `SyncDataXfer`,
+    REGSTR_VAL_AUTOINSNOTE               = `AutoInsertNotification`,
+    REGSTR_VAL_DISCONNECT                = `Disconnect`,
+    REGSTR_VAL_INT13                     = `Int13`,
+    REGSTR_VAL_PMODE_INT13               = `PModeInt13`,
+    REGSTR_VAL_USERSETTINGS              = `AdapterSettings`,
+    REGSTR_VAL_NOIDE                     = `NoIDE`,
+    REGSTR_VAL_DISKCLASSNAME             = `DiskDrive`,
+    REGSTR_VAL_CDROMCLASSNAME            = `CDROM`,
+    REGSTR_VAL_FORCELOAD                 = `ForceLoadPD`,
+    REGSTR_VAL_FORCEFIFO                 = `ForceFIFO`,
+    REGSTR_VAL_FORCECL                   = `ForceChangeLine`,
+    REGSTR_VAL_NOUSECLASS                = `NoUseClass`,
+    REGSTR_VAL_NOINSTALLCLASS            = `NoInstallClass`,
+    REGSTR_VAL_NODISPLAYCLASS            = `NoDisplayClass`,
+    REGSTR_VAL_SILENTINSTALL             = `SilentInstall`,
+    REGSTR_KEY_PCMCIA_CLASS              = `PCMCIA`,
+    REGSTR_KEY_SCSI_CLASS                = `SCSIAdapter`,
+    REGSTR_KEY_PORTS_CLASS               = `ports`,
+    REGSTR_KEY_MEDIA_CLASS               = `MEDIA`,
+    REGSTR_KEY_DISPLAY_CLASS             = `Display`,
+    REGSTR_KEY_KEYBOARD_CLASS            = `Keyboard`,
+    REGSTR_KEY_MOUSE_CLASS               = `Mouse`,
+    REGSTR_KEY_MONITOR_CLASS             = `Monitor`,
+    REGSTR_VAL_PCMCIA_OPT                = `Options`,
+    REGSTR_VAL_PCMCIA_MEM                = `Memory`,
+    REGSTR_VAL_PCMCIA_ALLOC              = `AllocMemWin`,
+    REGSTR_VAL_PCMCIA_ATAD               = `ATADelay`,
+    REGSTR_VAL_PCMCIA_SIZ                = `MinRegionSize`,
+    REGSTR_VAL_P1284MDL                  = `Model`,
+    REGSTR_VAL_P1284MFG                  = `Manufacturer`,
+    REGSTR_VAL_ISAPNP                    = `ISAPNP`,
+    REGSTR_VAL_ISAPNP_RDP_OVERRIDE       = `RDPOverRide`,
+    REGSTR_VAL_PCI                       = `PCI`,
+    REGSTR_PCI_OPTIONS                   = `Options`,
+    REGSTR_PCI_DUAL_IDE                  = `PCIDualIDE`,
+
+    REGSTR_KEY_CRASHES                   = `Crashes`,
+    REGSTR_KEY_DANGERS                   = `Dangers`,
+    REGSTR_KEY_DETMODVARS                = `DetModVars`,
+    REGSTR_KEY_NDISINFO                  = `NDISInfo`,
+    REGSTR_VAL_PROTINIPATH               = `ProtIniPath`,
+    REGSTR_VAL_RESOURCES                 = `Resources`,
+    REGSTR_VAL_CRASHFUNCS                = `CrashFuncs`,
+    REGSTR_VAL_CLASS                     = `Class`,
+    REGSTR_VAL_DEVDESC                   = `DeviceDesc`,
+    REGSTR_VAL_BOOTCONFIG                = `BootConfig`,
+    REGSTR_VAL_DETFUNC                   = `DetFunc`,
+    REGSTR_VAL_DETFLAGS                  = `DetFlags`,
+    REGSTR_VAL_COMPATIBLEIDS             = `CompatibleIDs`,
+    REGSTR_VAL_DETCONFIG                 = `DetConfig`,
+    REGSTR_VAL_VERIFYKEY                 = `VerifyKey`,
+    REGSTR_VAL_COMINFO                   = `ComInfo`,
+    REGSTR_VAL_INFNAME                   = `InfName`,
+    REGSTR_VAL_CARDSPECIFIC              = `CardSpecific`,
+    REGSTR_VAL_NETOSTYPE                 = `NetOSType`,
+    REGSTR_DATA_NETOS_NDIS               = `NDIS`,
+    REGSTR_DATA_NETOS_ODI                = `ODI`,
+    REGSTR_DATA_NETOS_IPX                = `IPX`,
+    REGSTR_VAL_MFG                       = `Mfg`,
+    REGSTR_VAL_SCAN_ONLY_FIRST           = `ScanOnlyFirstDrive`,
+    REGSTR_VAL_SHARE_IRQ                 = `ForceIRQSharing`,
+    REGSTR_VAL_NONSTANDARD_ATAPI         = `NonStandardATAPI`,
+    REGSTR_VAL_IDE_FORCE_SERIALIZE       = `ForceSerialization`,
+    REGSTR_VAL_HWREV                     = `HWRevision`,
+    REGSTR_VAL_ENABLEINTS                = `EnableInts`,
+
+    REGSTR_VAL_APMBIOSVER                = `APMBiosVer`,
+    REGSTR_VAL_APMFLAGS                  = `APMFlags`,
+    REGSTR_VAL_SLSUPPORT                 = `SLSupport`,
+    REGSTR_VAL_MACHINETYPE               = `MachineType`,
+    REGSTR_VAL_SETUPMACHINETYPE          = `SetupMachineType`,
+    REGSTR_MACHTYPE_UNKNOWN              = `Unknown`,
+    REGSTR_MACHTYPE_IBMPC                = `IBM PC`,
+    REGSTR_MACHTYPE_IBMPCJR              = `IBM PCjr`,
+    REGSTR_MACHTYPE_IBMPCCONV            = `IBM PC Convertible`,
+    REGSTR_MACHTYPE_IBMPCXT              = `IBM PC/XT`,
+    REGSTR_MACHTYPE_IBMPCXT_286          = `IBM PC/XT 286`,
+    REGSTR_MACHTYPE_IBMPCAT              = `IBM PC/AT`,
+    REGSTR_MACHTYPE_IBMPS2_25            = `IBM PS/2-25`,
+    REGSTR_MACHTYPE_IBMPS2_30_286        = `IBM PS/2-30 286`,
+    REGSTR_MACHTYPE_IBMPS2_30            = `IBM PS/2-30`,
+    REGSTR_MACHTYPE_IBMPS2_50            = `IBM PS/2-50`,
+    REGSTR_MACHTYPE_IBMPS2_50Z           = `IBM PS/2-50Z`,
+    REGSTR_MACHTYPE_IBMPS2_55SX          = `IBM PS/2-55SX`,
+    REGSTR_MACHTYPE_IBMPS2_60            = `IBM PS/2-60`,
+    REGSTR_MACHTYPE_IBMPS2_65SX          = `IBM PS/2-65SX`,
+    REGSTR_MACHTYPE_IBMPS2_70            = `IBM PS/2-70`,
+    REGSTR_MACHTYPE_IBMPS2_P70           = `IBM PS/2-P70`,
+    REGSTR_MACHTYPE_IBMPS2_70_80         = `IBM PS/2-70/80`,
+    REGSTR_MACHTYPE_IBMPS2_80            = `IBM PS/2-80`,
+    REGSTR_MACHTYPE_IBMPS2_90            = `IBM PS/2-90`,
+    REGSTR_MACHTYPE_IBMPS1               = `IBM PS/1`,
+    REGSTR_MACHTYPE_PHOENIX_PCAT         = `Phoenix PC/AT Compatible`,
+    REGSTR_MACHTYPE_HP_VECTRA            = `HP Vectra`,
+    REGSTR_MACHTYPE_ATT_PC               = `AT&T PC`,
+    REGSTR_MACHTYPE_ZENITH_PC            = `Zenith PC`,
+    REGSTR_VAL_APMMENUSUSPEND            = `APMMenuSuspend`,
+
+    REGSTR_VAL_BUSTYPE                   = `BusType`,
+    REGSTR_VAL_CPU                       = `CPU`,
+    REGSTR_VAL_NDP                       = `NDP`,
+    REGSTR_VAL_PNPBIOSVER                = `PnPBIOSVer`,
+    REGSTR_VAL_PNPSTRUCOFFSET            = `PnPStrucOffset`,
+    REGSTR_VAL_PCIBIOSVER                = `PCIBIOSVer`,
+    REGSTR_VAL_HWMECHANISM               = `HWMechanism`,
+    REGSTR_VAL_LASTPCIBUSNUM             = `LastPCIBusNum`,
+    REGSTR_VAL_CONVMEM                   = `ConvMem`,
+    REGSTR_VAL_EXTMEM                    = `ExtMem`,
+    REGSTR_VAL_COMPUTERNAME              = `ComputerName`,
+    REGSTR_VAL_BIOSNAME                  = `BIOSName`,
+    REGSTR_VAL_BIOSVERSION               = `BIOSVersion`,
+    REGSTR_VAL_BIOSDATE                  = `BIOSDate`,
+    REGSTR_VAL_MODEL                     = `Model`,
+    REGSTR_VAL_SUBMODEL                  = `Submodel`,
+    REGSTR_VAL_REVISION                  = `Revision`,
+    REGSTR_VAL_FIFODEPTH                 = `FIFODepth`,
+    REGSTR_VAL_RDINTTHRESHOLD            = `RDIntThreshold`,
+    REGSTR_VAL_WRINTTHRESHOLD            = `WRIntThreshold`,
+    REGSTR_VAL_PRIORITY                  = `Priority`,
+    REGSTR_VAL_DRIVER                    = `Driver`,
+    REGSTR_VAL_FUNCDESC                  = `FunctionDesc`,
+    REGSTR_VAL_FORCEDCONFIG              = `ForcedConfig`,
+    REGSTR_VAL_CONFIGFLAGS               = `ConfigFlags`,
+    REGSTR_VAL_CSCONFIGFLAGS             = `CSConfigFlags`,
+
+    REGSTR_VAL_ROOT_DEVNODE              = `HTREE\ROOT\0`,
+    REGSTR_VAL_RESERVED_DEVNODE          = `HTREE\RESERVED\0`,
+    REGSTR_PATH_READDATAPORT             = REGSTR_KEY_ISAENUM ~ `\ReadDataPort\0`,
+    REGSTR_PATH_MULTI_FUNCTION           = `MF`,
+    REGSTR_VAL_RESOURCE_MAP              = `ResourceMap`,
+    REGSTR_PATH_CHILD_PREFIX             = `Child`,
+    REGSTR_VAL_MF_FLAGS                  = `MFFlags`,
+    REGSTR_VAL_DRVDESC                   = `DriverDesc`,
+    REGSTR_VAL_DEVLOADER                 = `DevLoader`,
+    REGSTR_VAL_STATICVXD                 = `StaticVxD`,
+    REGSTR_VAL_PROPERTIES                = `Properties`,
+    REGSTR_VAL_MANUFACTURER              = `Manufacturer`,
+    REGSTR_VAL_EXISTS                    = `Exists`,
+    REGSTR_VAL_CMENUMFLAGS               = `CMEnumFlags`,
+    REGSTR_VAL_CMDRIVFLAGS               = `CMDrivFlags`,
+    REGSTR_VAL_ENUMERATOR                = `Enumerator`,
+    REGSTR_VAL_DEVICEDRIVER              = `DeviceDriver`,
+    REGSTR_VAL_PORTNAME                  = `PortName`,
+    REGSTR_VAL_INFPATH                   = `InfPath`,
+    REGSTR_VAL_INFSECTION                = `InfSection`,
+    REGSTR_VAL_POLLING                   = `Polling`,
+    REGSTR_VAL_DONTLOADIFCONFLICT        = `DontLoadIfConflict`,
+    REGSTR_VAL_PORTSUBCLASS              = `PortSubClass`,
+    REGSTR_VAL_NETCLEAN                  = `NetClean`,
+    REGSTR_VAL_IDE_NO_SERIALIZE          = `IDENoSerialize`,
+    REGSTR_VAL_NOCMOSORFDPT              = `NoCMOSorFDPT`,
+    REGSTR_VAL_COMVERIFYBASE             = `COMVerifyBase`,
+    REGSTR_KEY_OVERRIDE                  = `Override`,
+    REGSTR_VAL_CONFIGMG                  = `CONFIGMG`,
+    REGSTR_VAL_SYSDM                     = `SysDM`,
+    REGSTR_VAL_SYSDMFUNC                 = `SysDMFunc`,
+    REGSTR_VAL_PRIVATE                   = `Private`,
+    REGSTR_VAL_PRIVATEFUNC               = `PrivateFunc`,
+    REGSTR_VAL_DETECT                    = `Detect`,
+    REGSTR_VAL_DETECTFUNC                = `DetectFunc`,
+    REGSTR_VAL_ASKFORCONFIG              = `AskForConfig`,
+    REGSTR_VAL_ASKFORCONFIGFUNC          = `AskForConfigFunc`,
+    REGSTR_VAL_WAITFORUNDOCK             = `WaitForUndock`,
+    REGSTR_VAL_WAITFORUNDOCKFUNC         = `WaitForUndockFunc`,
+    REGSTR_VAL_REMOVEROMOKAY             = `RemoveRomOkay`,
+    REGSTR_VAL_REMOVEROMOKAYFUNC         = `RemoveRomOkayFunc`,
+    REGSTR_VAL_CURCONFIG                 = `CurrentConfig`,
+    REGSTR_VAL_FRIENDLYNAME              = `FriendlyName`,
+    REGSTR_VAL_CURRENTCONFIG             = `CurrentConfig`,
+    REGSTR_VAL_MAP                       = `Map`,
+    REGSTR_VAL_ID                        = `CurrentID`,
+    REGSTR_VAL_DOCKED                    = `CurrentDockedState`,
+    REGSTR_VAL_CHECKSUM                  = `CurrentChecksum`,
+    REGSTR_VAL_HWDETECT                  = `HardwareDetect`,
+    REGSTR_VAL_INHIBITRESULTS            = `InhibitResults`,
+    REGSTR_VAL_PROFILEFLAGS              = `ProfileFlags`,
+    REGSTR_KEY_PCMCIA                    = `PCMCIA\`,
+    REGSTR_KEY_PCUNKNOWN                 = `UNKNOWN_MANUFACTURER`,
+    REGSTR_VAL_PCSSDRIVER                = `Driver`,
+    REGSTR_KEY_PCMTD                     = `MTD-`,
+    REGSTR_VAL_PCMTDRIVER                = `MTD`,
+    REGSTR_VAL_HARDWAREID                = `HardwareID`,
+    REGSTR_VAL_INSTALLER                 = `Installer`,
+    REGSTR_VAL_INSICON                   = `Icon`,
+    REGSTR_VAL_ENUMPROPPAGES             = `EnumPropPages`,
+    REGSTR_VAL_BASICPROPERTIES           = `BasicProperties`,
+    REGSTR_VAL_PRIVATEPROBLEM            = `PrivateProblem`,
+    REGSTR_KEY_CURRENT                   = `Current`,
+    REGSTR_KEY_DEFAULT                   = `Default`,
+    REGSTR_KEY_MODES                     = `Modes`,
+    REGSTR_VAL_MODE                      = `Mode`,
+    REGSTR_VAL_BPP                       = `BPP`,
+    REGSTR_VAL_HRES                      = `HRes`,
+    REGSTR_VAL_VRES                      = `VRes`,
+    REGSTR_VAL_FONTSIZE                  = `FontSize`,
+    REGSTR_VAL_DRV                       = `drv`,
+    REGSTR_VAL_GRB                       = `grb`,
+    REGSTR_VAL_VDD                       = `vdd`,
+    REGSTR_VAL_VER                       = `Ver`,
+    REGSTR_VAL_MAXRES                    = `MaxResolution`,
+    REGSTR_VAL_DPMS                      = `DPMS`,
+    REGSTR_VAL_RESUMERESET               = `ResumeReset`,
+    REGSTR_VAL_DESCRIPTION               = `Description`,
+    REGSTR_KEY_SYSTEM                    = `System`,
+    REGSTR_KEY_USER                      = `User`,
+    REGSTR_VAL_DPI                       = `dpi`,
+    REGSTR_VAL_PCICOPTIONS               = `PCICOptions`,
+
+    REGSTR_VAL_PCICIRQMAP                = `PCICIRQMap`,
+    REGSTR_PATH_APPEARANCE               = `Control Panel\Appearance`,
+    REGSTR_PATH_LOOKSCHEMES              = `Control Panel\Appearance\Schemes`,
+    REGSTR_VAL_CUSTOMCOLORS              = `CustomColors`,
+    REGSTR_PATH_SCREENSAVE               = `Control Panel\Desktop`,
+    REGSTR_VALUE_USESCRPASSWORD          = `ScreenSaveUsePassword`,
+    REGSTR_VALUE_SCRPASSWORD             = `ScreenSave_Data`,
+    REGSTR_VALUE_LOWPOWERTIMEOUT         = `ScreenSaveLowPowerTimeout`,
+    REGSTR_VALUE_POWEROFFTIMEOUT         = `ScreenSavePowerOffTimeout`,
+    REGSTR_VALUE_LOWPOWERACTIVE          = `ScreenSaveLowPowerActive`,
+    REGSTR_VALUE_POWEROFFACTIVE          = `ScreenSavePowerOffActive`,
+    REGSTR_PATH_WINDOWSAPPLETS           = `Software\Microsoft\Windows\CurrentVersion\Applets`,
+    REGSTR_PATH_SYSTRAY                  = `Software\Microsoft\Windows\CurrentVersion\Applets\SysTray`,
+    REGSTR_VAL_SYSTRAYSVCS               = `Services`,
+    REGSTR_VAL_SYSTRAYBATFLAGS           = `PowerFlags`,
+    REGSTR_VAL_SYSTRAYPCCARDFLAGS        = `PCMCIAFlags`,
+    REGSTR_PATH_NETWORK_USERSETTINGS     = `Network`,
+    REGSTR_KEY_NETWORK_PERSISTENT        = `\Persistent`,
+    REGSTR_KEY_NETWORK_RECENT            = `\Recent`,
+    REGSTR_VAL_REMOTE_PATH               = `RemotePath`,
+    REGSTR_VAL_USER_NAME                 = `UserName`,
+    REGSTR_VAL_PROVIDER_NAME             = `ProviderName`,
+    REGSTR_VAL_CONNECTION_TYPE           = `ConnectionType`,
+    REGSTR_VAL_UPGRADE                   = `Upgrade`,
+    REGSTR_KEY_LOGON                     = `\Logon`,
+    REGSTR_VAL_MUSTBEVALIDATED           = `MustBeValidated`,
+    REGSTR_VAL_RUNLOGINSCRIPT            = `ProcessLoginScript`,
+    REGSTR_KEY_NETWORKPROVIDER           = `\NetworkProvider`,
+    REGSTR_PATH_NW32NETPROVIDER          =REGSTR_PATH_SERVICES ~ `\NWNP32` ~ REGSTR_KEY_NETWORKPROVIDER,
+    REGSTR_PATH_MS32NETPROVIDER          =REGSTR_PATH_SERVICES ~ `\MSNP32` ~ REGSTR_KEY_NETWORKPROVIDER,
+    REGSTR_VAL_AUTHENT_AGENT             = `AuthenticatingAgent`,
+    REGSTR_VAL_PREFREDIR                 = `PreferredRedir`,
+    REGSTR_VAL_AUTOSTART                 = `AutoStart`,
+    REGSTR_VAL_AUTOLOGON                 = `AutoLogon`,
+    REGSTR_VAL_NETCARD                   = `Netcard`,
+    REGSTR_VAL_TRANSPORT                 = `Transport`,
+    REGSTR_VAL_DYNAMIC                   = `Dynamic`,
+    REGSTR_VAL_TRANSITION                = `Transition`,
+    REGSTR_VAL_STATICDRIVE               = `StaticDrive`,
+    REGSTR_VAL_LOADHI                    = `LoadHi`,
+    REGSTR_VAL_LOADRMDRIVERS             = `LoadRMDrivers`,
+    REGSTR_VAL_SETUPN                    = `SetupN`,
+    REGSTR_VAL_SETUPNPATH                = `SetupNPath`,
+    REGSTR_VAL_WRKGRP_FORCEMAPPING       = `WrkgrpForceMapping`,
+    REGSTR_VAL_WRKGRP_REQUIRED           = `WrkgrpRequired`,
+    REGSTR_PATH_CURRENT_CONTROL_SET      = `System\CurrentControlSet\Control`,
+    REGSTR_VAL_CURRENT_USER              = `Current User`,
+    REGSTR_PATH_PWDPROVIDER              = `System\CurrentControlSet\Control\PwdProvider`,
+    REGSTR_VAL_PWDPROVIDER_PATH          = `ProviderPath`,
+    REGSTR_VAL_PWDPROVIDER_DESC          = `Description`,
+    REGSTR_VAL_PWDPROVIDER_CHANGEPWD     = `ChangePassword`,
+    REGSTR_VAL_PWDPROVIDER_CHANGEPWDHWND = `ChangePasswordHwnd`,
+    REGSTR_VAL_PWDPROVIDER_GETPWDSTATUS  = `GetPasswordStatus`,
+    REGSTR_VAL_PWDPROVIDER_ISNP          = `NetworkProvider`,
+    REGSTR_VAL_PWDPROVIDER_CHANGEORDER   = `ChangeOrder`,
+    REGSTR_PATH_POLICIES                 = `Software\Microsoft\Windows\CurrentVersion\Policies`,
+    REGSTR_PATH_UPDATE                   = `System\CurrentControlSet\Control\Update`,
+    REGSTR_VALUE_ENABLE                  = `Enable`,
+    REGSTR_VALUE_VERBOSE                 = `Verbose`,
+    REGSTR_VALUE_NETPATH                 = `NetworkPath`,
+    REGSTR_VALUE_DEFAULTLOC              = `UseDefaultNetLocation`,
+    REGSTR_KEY_NETWORK                   = `Network`,
+// [Redefined] REGSTR_KEY_SYSTEM         = `System`)
+    REGSTR_KEY_PRINTERS                  = `Printers`,
+    REGSTR_KEY_WINOLDAPP                 = `WinOldApp`,
+    REGSTR_VAL_NOFILESHARING             = `NoFileSharing`,
+    REGSTR_VAL_NOPRINTSHARING            = `NoPrintSharing`,
+    REGSTR_VAL_NOFILESHARINGCTRL         = `NoFileSharingControl`,
+    REGSTR_VAL_NOPRINTSHARINGCTRL        = `NoPrintSharingControl`,
+    REGSTR_VAL_HIDESHAREPWDS             = `HideSharePwds`,
+    REGSTR_VAL_DISABLEPWDCACHING         = `DisablePwdCaching`,
+    REGSTR_VAL_ALPHANUMPWDS              = `AlphanumPwds`,
+    REGSTR_VAL_NETSETUP_DISABLE          = `NoNetSetup`,
+    REGSTR_VAL_NETSETUP_NOCONFIGPAGE     = `NoNetSetupConfigPage`,
+    REGSTR_VAL_NETSETUP_NOIDPAGE         = `NoNetSetupIDPage`,
+    REGSTR_VAL_NETSETUP_NOSECURITYPAGE   = `NoNetSetupSecurityPage`,
+    REGSTR_VAL_SYSTEMCPL_NOVIRTMEMPAGE   = `NoVirtMemPage`,
+    REGSTR_VAL_SYSTEMCPL_NODEVMGRPAGE    = `NoDevMgrPage`,
+    REGSTR_VAL_SYSTEMCPL_NOCONFIGPAGE    = `NoConfigPage`,
+    REGSTR_VAL_SYSTEMCPL_NOFILESYSPAGE   = `NoFileSysPage`,
+    REGSTR_VAL_DISPCPL_NODISPCPL         = `NoDispCPL`,
+    REGSTR_VAL_DISPCPL_NOBACKGROUNDPAGE  = `NoDispBackgroundPage`,
+    REGSTR_VAL_DISPCPL_NOSCRSAVPAGE      = `NoDispScrSavPage`,
+    REGSTR_VAL_DISPCPL_NOAPPEARANCEPAGE  = `NoDispAppearancePage`,
+    REGSTR_VAL_DISPCPL_NOSETTINGSPAGE    = `NoDispSettingsPage`,
+    REGSTR_VAL_SECCPL_NOSECCPL           = `NoSecCPL`,
+    REGSTR_VAL_SECCPL_NOPWDPAGE          = `NoPwdPage`,
+    REGSTR_VAL_SECCPL_NOADMINPAGE        = `NoAdminPage`,
+    REGSTR_VAL_SECCPL_NOPROFILEPAGE      = `NoProfilePage`,
+    REGSTR_VAL_PRINTERS_HIDETABS         = `NoPrinterTabs`,
+    REGSTR_VAL_PRINTERS_NODELETE         = `NoDeletePrinter`,
+    REGSTR_VAL_PRINTERS_NOADD            = `NoAddPrinter`,
+    REGSTR_VAL_WINOLDAPP_DISABLED        = `Disabled`,
+    REGSTR_VAL_WINOLDAPP_NOREALMODE      = `NoRealMode`,
+    REGSTR_VAL_NOENTIRENETWORK           = `NoEntireNetwork`,
+    REGSTR_VAL_NOWORKGROUPCONTENTS       = `NoWorkgroupContents`,
+    REGSTR_VAL_MINPWDLEN                 = `MinPwdLen`,
+    REGSTR_VAL_PWDEXPIRATION             = `PwdExpiration`,
+    REGSTR_VAL_WIN31PROVIDER             = `Win31Provider`,
+    REGSTR_VAL_DISABLEREGTOOLS           = `DisableRegistryTools`,
+    REGSTR_PATH_WINLOGON                 = `Software\Microsoft\Windows\CurrentVersion\Winlogon`,
+    REGSTR_VAL_LEGALNOTICECAPTION        = `LegalNoticeCaption`,
+    REGSTR_VAL_LEGALNOTICETEXT           = `LegalNoticeText`,
+    REGSTR_VAL_RESTRICTRUN               = `RestrictRun`,
+    REGSTR_KEY_POL_USERS                 = `Users`,
+    REGSTR_KEY_POL_COMPUTERS             = `Computers`,
+    REGSTR_KEY_POL_USERGROUPS            = `UserGroups`,
+    REGSTR_KEY_POL_DEFAULT               = `.default`,
+    REGSTR_KEY_POL_USERGROUPDATA         = `GroupData\UserGroups\Priority`,
+    REGSTR_PATH_TIMEZONE                 = `System\CurrentControlSet\Control\TimeZoneInformation`,
+    REGSTR_VAL_TZBIAS                    = `Bias`,
+    REGSTR_VAL_TZDLTBIAS                 = `DaylightBias`,
+    REGSTR_VAL_TZSTDBIAS                 = `StandardBias`,
+    REGSTR_VAL_TZACTBIAS                 = `ActiveTimeBias`,
+    REGSTR_VAL_TZDLTFLAG                 = `DaylightFlag`,
+    REGSTR_VAL_TZSTDSTART                = `StandardStart`,
+    REGSTR_VAL_TZDLTSTART                = `DaylightStart`,
+    REGSTR_VAL_TZDLTNAME                 = `DaylightName`,
+    REGSTR_VAL_TZSTDNAME                 = `StandardName`,
+    REGSTR_VAL_TZNOCHANGESTART           = `NoChangeStart`,
+    REGSTR_VAL_TZNOCHANGEEND             = `NoChangeEnd`,
+    REGSTR_VAL_TZNOAUTOTIME              = `DisableAutoDaylightTimeSet`,
+    REGSTR_PATH_FLOATINGPOINTPROCESSOR   = `HARDWARE\DESCRIPTION\System\FloatingPointProcessor`,
+    REGSTR_PATH_FLOATINGPOINTPROCESSOR0  = `HARDWARE\DESCRIPTION\System\FloatingPointProcessor\0`,
+    REGSTR_PATH_COMPUTRNAME              = `System\CurrentControlSet\Control\ComputerName\ComputerName`,
+    REGSTR_VAL_COMPUTRNAME               = `ComputerName`,
+    REGSTR_PATH_SHUTDOWN                 = `System\CurrentControlSet\Control\Shutdown`,
+    REGSTR_VAL_FORCEREBOOT               = `ForceReboot`,
+    REGSTR_VAL_SETUPPROGRAMRAN           = `SetupProgramRan`,
+    REGSTR_VAL_DOES_POLLING              = `PollingSupportNeeded`,
+    REGSTR_PATH_KNOWNDLLS                = `System\CurrentControlSet\Control\SessionManager\KnownDLLs`,
+    REGSTR_PATH_KNOWN16DLLS              = `System\CurrentControlSet\Control\SessionManager\Known16DLLs`,
+    REGSTR_PATH_CHECKVERDLLS             = `System\CurrentControlSet\Control\SessionManager\CheckVerDLLs`,
+    REGSTR_PATH_WARNVERDLLS              = `System\CurrentControlSet\Control\SessionManager\WarnVerDLLs`,
+    REGSTR_PATH_HACKINIFILE              = `System\CurrentControlSet\Control\SessionManager\HackIniFiles`,
+    REGSTR_PATH_CHECKBADAPPS             = `System\CurrentControlSet\Control\SessionManager\CheckBadApps`,
+    REGSTR_PATH_APPPATCH                 = `System\CurrentControlSet\Control\SessionManager\AppPatches`,
+    REGSTR_PATH_KNOWNVXDS                = `System\CurrentControlSet\Control\SessionManager\KnownVxDs`,
+    REGSTR_VAL_UNINSTALLER_DISPLAYNAME   = `DisplayName`,
+    REGSTR_VAL_UNINSTALLER_COMMANDLINE   = `UninstallString`,
+    REGSTR_PATH_DESKTOP                  = REGSTR_PATH_SCREENSAVE,
+    REGSTR_PATH_MOUSE                    = `Control Panel\Mouse`,
+    REGSTR_PATH_KEYBOARD                 = `Control Panel\Keyboard`,
+    REGSTR_PATH_COLORS                   = `Control Panel\Colors`,
+    REGSTR_PATH_SOUND                    = `Control Panel\Sound`,
+    REGSTR_PATH_METRICS                  = `Control Panel\Desktop\WindowMetrics`,
+    REGSTR_PATH_ICONS                    = `Control Panel\Icons`,
+    REGSTR_PATH_CURSORS                  = `Control Panel\Cursors`,
+    REGSTR_PATH_CHECKDISK                = `Software\Microsoft\Windows\CurrentVersion\Applets\Check Drive`,
+    REGSTR_PATH_CHECKDISKSET             = `Settings`,
+    REGSTR_PATH_CHECKDISKUDRVS           = `NoUnknownDDErrDrvs`,
+    REGSTR_PATH_FAULT                    = `Software\Microsoft\Windows\CurrentVersion\Fault`,
+    REGSTR_VAL_FAULT_LOGFILE             = `LogFile`,
+    REGSTR_PATH_AEDEBUG                  = `Software\Microsoft\Windows NT\CurrentVersion\AeDebug`,
+    REGSTR_VAL_AEDEBUG_DEBUGGER          = `Debugger`,
+    REGSTR_VAL_AEDEBUG_AUTO              = `Auto`,
+    REGSTR_PATH_GRPCONV                  = `Software\Microsoft\Windows\CurrentVersion\GrpConv`,
+    REGSTR_VAL_REGITEMDELETEMESSAGE      = `Removal Message`,
+    REGSTR_PATH_LASTCHECK                = `Software\Microsoft\Windows\CurrentVersion\Explorer\LastCheck`,
+    REGSTR_PATH_LASTOPTIMIZE             = `Software\Microsoft\Windows\CurrentVersion\Explorer\LastOptimize`,
+    REGSTR_PATH_LASTBACKUP               = `Software\Microsoft\Windows\CurrentVersion\Explorer\LastBackup`,
+    REGSTR_PATH_CHKLASTCHECK             = `Software\Microsoft\Windows\CurrentVersion\Applets\Check Drive\LastCheck`,
+    REGSTR_PATH_CHKLASTSURFAN            = `Software\Microsoft\Windows\CurrentVersion\Applets\Check Drive\LastSurfaceAnalysis`,
+    REGSTR_KEY_SHARES                    = `Software\Microsoft\Windows\CurrentVersion\Network\LanMan`,
+    REGSTR_VAL_SHARES_FLAGS              = `Flags`,
+    REGSTR_VAL_SHARES_TYPE               = `Type`,
+    REGSTR_VAL_SHARES_PATH               = `Path`,
+    REGSTR_VAL_SHARES_REMARK             = `Remark`,
+    REGSTR_VAL_SHARES_RW_PASS            = `Parm1`,
+    REGSTR_VAL_SHARES_RO_PASS            = `Parm2`,
+    REGSTR_PATH_PRINT                    = `System\CurrentControlSet\Control\Print`,
+    REGSTR_PATH_PRINTERS                 = `System\CurrentControlSet\Control\Print\Printers`,
+    REGSTR_PATH_PROVIDERS                = `System\CurrentControlSet\Control\Print\Providers`,
+    REGSTR_PATH_MONITORS                 = `System\CurrentControlSet\Control\Print\Monitors`,
+    REGSTR_PATH_ENVIRONMENTS             = `System\CurrentControlSet\Control\Print\Environments`,
+    REGSTR_VAL_START_ON_BOOT             = `StartOnBoot`,
+    REGSTR_VAL_PRINTERS_MASK             = `PrintersMask`,
+    REGSTR_VAL_DOS_SPOOL_MASK            = `DOSSpoolMask`,
+    REGSTR_KEY_CURRENT_ENV               = `\Windows 4.0`,
+    REGSTR_KEY_DRIVERS                   = `\Drivers`,
+    REGSTR_KEY_PRINT_PROC                = `\Print Processors`,
+    REGSTR_PATH_EVENTLABELS              = `AppEvents\EventLabels`,
+    REGSTR_PATH_SCHEMES                  = `AppEvents\Schemes`,
+    REGSTR_PATH_APPS                     = REGSTR_PATH_SCHEMES ~ `\Apps`,
+    REGSTR_PATH_APPS_DEFAULT             = REGSTR_PATH_SCHEMES ~ `\Apps\.Default`,
+    REGSTR_PATH_NAMES                    = REGSTR_PATH_SCHEMES ~ `\Names`,
+    REGSTR_PATH_MULTIMEDIA               = REGSTR_PATH_SETUP ~ `\Multimedia`,
+    REGSTR_PATH_MULTIMEDIA_AUDIO         = `Software\Microsoft\Multimedia\Audio`,
+    REGSTR_PATH_MEDIARESOURCES           = REGSTR_PATH_CURRENT_CONTROL_SET ~ `\MediaResources`,
+    REGSTR_PATH_MEDIAPROPERTIES          = REGSTR_PATH_CURRENT_CONTROL_SET ~ `\MediaProperties`,
+    REGSTR_PATH_PRIVATEPROPERTIES        = REGSTR_PATH_MEDIAPROPERTIES ~ `\PrivateProperties`,
+    REGSTR_PATH_PUBLICPROPERTIES         = REGSTR_PATH_MEDIAPROPERTIES ~ `\PublicProperties`,
+    REGSTR_PATH_JOYOEM                   = REGSTR_PATH_PRIVATEPROPERTIES ~ `\Joystick\OEM`,
+    REGSTR_PATH_JOYCONFIG                = REGSTR_PATH_MEDIARESOURCES ~ `\Joystick`,
+    REGSTR_KEY_JOYCURR                   = `CurrentJoystickSettings`,
+    REGSTR_KEY_JOYSETTINGS               = `JoystickSettings`,
+    REGSTR_VAL_JOYUSERVALUES             = `JoystickUserValues`,
+    REGSTR_VAL_JOYCALLOUT                = `JoystickCallout`,
+    REGSTR_VAL_JOYNCONFIG                = `Joystick%dConfiguration`,
+    REGSTR_VAL_JOYNOEMNAME               = `Joystick%dOEMName`,
+    REGSTR_VAL_JOYNOEMCALLOUT            = `Joystick%dOEMCallout`,
+    REGSTR_VAL_JOYOEMCALLOUT             = `OEMCallout`,
+    REGSTR_VAL_JOYOEMNAME                = `OEMName`,
+    REGSTR_VAL_JOYOEMDATA                = `OEMData`,
+    REGSTR_VAL_JOYOEMXYLABEL             = `OEMXYLabel`,
+    REGSTR_VAL_JOYOEMZLABEL              = `OEMZLabel`,
+    REGSTR_VAL_JOYOEMRLABEL              = `OEMRLabel`,
+    REGSTR_VAL_JOYOEMPOVLABEL            = `OEMPOVLabel`,
+    REGSTR_VAL_JOYOEMULABEL              = `OEMULabel`,
+    REGSTR_VAL_JOYOEMVLABEL              = `OEMVLabel`,
+    REGSTR_VAL_JOYOEMTESTMOVEDESC        = `OEMTestMoveDesc`,
+    REGSTR_VAL_JOYOEMTESTBUTTONDESC      = `OEMTestButtonDesc`,
+    REGSTR_VAL_JOYOEMTESTMOVECAP         = `OEMTestMoveCap`,
+    REGSTR_VAL_JOYOEMTESTBUTTONCAP       = `OEMTestButtonCap`,
+    REGSTR_VAL_JOYOEMTESTWINCAP          = `OEMTestWinCap`,
+    REGSTR_VAL_JOYOEMCALCAP              = `OEMCalCap`,
+    REGSTR_VAL_JOYOEMCALWINCAP           = `OEMCalWinCap`,
+    REGSTR_VAL_JOYOEMCAL1                = `OEMCal1`,
+    REGSTR_VAL_JOYOEMCAL2                = `OEMCal2`,
+    REGSTR_VAL_JOYOEMCAL3                = `OEMCal3`,
+    REGSTR_VAL_JOYOEMCAL4                = `OEMCal4`,
+    REGSTR_VAL_JOYOEMCAL5                = `OEMCal5`,
+    REGSTR_VAL_JOYOEMCAL6                = `OEMCal6`,
+    REGSTR_VAL_JOYOEMCAL7                = `OEMCal7`,
+    REGSTR_VAL_JOYOEMCAL8                = `OEMCal8`,
+    REGSTR_VAL_JOYOEMCAL9                = `OEMCal9`,
+    REGSTR_VAL_JOYOEMCAL10               = `OEMCal10`,
+    REGSTR_VAL_JOYOEMCAL11               = `OEMCal11`,
+    REGSTR_VAL_JOYOEMCAL12               = `OEMCal12`;
+
+enum {
+    DTRESULTOK,
+    DTRESULTFIX,
+    DTRESULTPROB,
+    DTRESULTPART
+}
+
+//#ifndef NEC_98
+enum PCIC_DEFAULT_IRQMASK = 0x4EB8;
+//#else
+//#define PCIC_DEFAULT_IRQMASK  0x1468
+//#endif
+enum PCIC_DEFAULT_NUMSOCKETS = 0;
+
+struct DSKTLSYSTEMTIME {
+    WORD wYear;
+    WORD wMonth;
+    WORD wDayOfWeek;
+    WORD wDay;
+    WORD wHour;
+    WORD wMinute;
+    WORD wSecond;
+    WORD wMilliseconds;
+    WORD wResult;
+}
+alias DSKTLSYSTEMTIME* PDSKTLSYSTEMTIME, LPDSKTLSYSTEMTIME;
diff --git a/libphobos/libdruntime/core/sys/windows/richedit.d b/libphobos/libdruntime/core/sys/windows/richedit.d
new file mode 100644
index 00000000000..a31b13d36b2
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/richedit.d
@@ -0,0 +1,592 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_richedit.d)
+ */
+module core.sys.windows.richedit;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.windef, core.sys.windows.winuser;
+private import core.sys.windows.wingdi; // for LF_FACESIZE
+
+align(4):
+
+version(Unicode) {
+const wchar[] RICHEDIT_CLASS = "RichEdit20W";
+} else {
+const char[] RICHEDIT_CLASS  = "RichEdit20A";
+}
+
+enum RICHEDIT_CLASS10A = "RICHEDIT";
+
+const TCHAR[]
+    CF_RTF       = "Rich Text Format",
+    CF_RTFNOOBJS = "Rich Text Format Without Objects",
+    CF_RETEXTOBJ = "RichEdit Text and Objects";
+
+enum DWORD
+    CFM_BOLD        = 1,
+    CFM_ITALIC      = 2,
+    CFM_UNDERLINE   = 4,
+    CFM_STRIKEOUT   = 8,
+    CFM_PROTECTED   = 16,
+    CFM_LINK        = 32,
+    CFM_SIZE        = 0x80000000,
+    CFM_COLOR       = 0x40000000,
+    CFM_FACE        = 0x20000000,
+    CFM_OFFSET      = 0x10000000,
+    CFM_CHARSET     = 0x08000000,
+    CFM_SUBSCRIPT   = 0x00030000,
+    CFM_SUPERSCRIPT = 0x00030000;
+
+enum DWORD
+    CFE_BOLD        = 1,
+    CFE_ITALIC      = 2,
+    CFE_UNDERLINE   = 4,
+    CFE_STRIKEOUT   = 8,
+    CFE_PROTECTED   = 16,
+    CFE_SUBSCRIPT   = 0x00010000,
+    CFE_SUPERSCRIPT = 0x00020000,
+    CFE_AUTOCOLOR   = 0x40000000;
+
+enum CFM_EFFECTS = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_COLOR
+  | CFM_STRIKEOUT | CFE_PROTECTED | CFM_LINK;
+
+// flags for EM_SETIMEOPTIONS
+enum LPARAM
+    IMF_FORCENONE         = 1,
+    IMF_FORCEENABLE       = 2,
+    IMF_FORCEDISABLE      = 4,
+    IMF_CLOSESTATUSWINDOW = 8,
+    IMF_VERTICAL          = 32,
+    IMF_FORCEACTIVE       = 64,
+    IMF_FORCEINACTIVE     = 128,
+    IMF_FORCEREMEMBER     = 256;
+
+enum SEL_EMPTY=0;
+enum SEL_TEXT=1;
+enum SEL_OBJECT=2;
+enum SEL_MULTICHAR=4;
+enum SEL_MULTIOBJECT=8;
+
+enum MAX_TAB_STOPS=32;
+
+enum PFM_ALIGNMENT=8;
+enum PFM_NUMBERING=32;
+enum PFM_OFFSET=4;
+enum PFM_OFFSETINDENT=0x80000000;
+enum PFM_RIGHTINDENT=2;
+enum PFM_STARTINDENT=1;
+enum PFM_TABSTOPS=16;
+enum PFM_BORDER=2048;
+enum PFM_LINESPACING=256;
+enum PFM_NUMBERINGSTART=32768;
+enum PFM_NUMBERINGSTYLE=8192;
+enum PFM_NUMBERINGTAB=16384;
+enum PFM_SHADING=4096;
+enum PFM_SPACEAFTER=128;
+enum PFM_SPACEBEFORE=64;
+enum PFM_STYLE=1024;
+enum PFM_DONOTHYPHEN=4194304;
+enum PFM_KEEP=131072;
+enum PFM_KEEPNEXT=262144;
+enum PFM_NOLINENUMBER=1048576;
+enum PFM_NOWIDOWCONTROL=2097152;
+enum PFM_PAGEBREAKBEFORE=524288;
+enum PFM_RTLPARA=65536;
+enum PFM_SIDEBYSIDE=8388608;
+enum PFM_TABLE=1073741824;
+enum PFN_BULLET=1;
+
+enum PFE_DONOTHYPHEN=64;
+enum PFE_KEEP=2;
+enum PFE_KEEPNEXT=4;
+enum PFE_NOLINENUMBER=16;
+enum PFE_NOWIDOWCONTROL=32;
+enum PFE_PAGEBREAKBEFORE=8;
+enum PFE_RTLPARA=1;
+enum PFE_SIDEBYSIDE=128;
+enum PFE_TABLE=16384;
+enum PFA_LEFT=1;
+enum PFA_RIGHT=2;
+enum PFA_CENTER=3;
+enum PFA_JUSTIFY=4;
+enum PFA_FULL_INTERWORD=4;
+
+enum SF_TEXT=1;
+enum SF_RTF=2;
+enum SF_RTFNOOBJS=3;
+enum SF_TEXTIZED=4;
+enum SF_UNICODE=16;
+enum SF_USECODEPAGE=32;
+enum SF_NCRFORNONASCII=64;
+enum SF_RTFVAL=0x0700;
+
+enum SFF_PWD=0x0800;
+enum SFF_KEEPDOCINFO=0x1000;
+enum SFF_PERSISTVIEWSCALE=0x2000;
+enum SFF_PLAINRTF=0x4000;
+enum SFF_SELECTION=0x8000;
+
+enum WB_CLASSIFY      = 3;
+enum WB_MOVEWORDLEFT  = 4;
+enum WB_MOVEWORDRIGHT = 5;
+enum WB_LEFTBREAK     = 6;
+enum WB_RIGHTBREAK    = 7;
+enum WB_MOVEWORDPREV  = 4;
+enum WB_MOVEWORDNEXT  = 5;
+enum WB_PREVBREAK     = 6;
+enum WB_NEXTBREAK     = 7;
+
+enum WBF_WORDWRAP  = 16;
+enum WBF_WORDBREAK = 32;
+enum WBF_OVERFLOW  = 64;
+enum WBF_LEVEL1    = 128;
+enum WBF_LEVEL2    = 256;
+enum WBF_CUSTOM    = 512;
+
+enum ES_DISABLENOSCROLL  = 8192;
+enum ES_SUNKEN           = 16384;
+enum ES_SAVESEL          = 32768;
+enum ES_EX_NOCALLOLEINIT = 16777216;
+enum ES_NOIME            = 524288;
+enum ES_NOOLEDRAGDROP    = 8;
+enum ES_SELECTIONBAR     = 16777216;
+enum ES_SELFIME          = 262144;
+enum ES_VERTICAL         = 4194304;
+
+enum EM_CANPASTE = WM_USER+50;
+enum EM_DISPLAYBAND = WM_USER+51;
+enum EM_EXGETSEL = WM_USER+52;
+enum EM_EXLIMITTEXT = WM_USER+53;
+enum EM_EXLINEFROMCHAR = WM_USER+54;
+enum EM_EXSETSEL = WM_USER+55;
+enum EM_FINDTEXT = WM_USER+56;
+enum EM_FORMATRANGE = WM_USER+57;
+enum EM_GETCHARFORMAT = WM_USER+58;
+enum EM_GETEVENTMASK = WM_USER+59;
+enum EM_GETOLEINTERFACE = WM_USER+60;
+enum EM_GETPARAFORMAT = WM_USER+61;
+enum EM_GETSELTEXT = WM_USER+62;
+enum EM_HIDESELECTION = WM_USER+63;
+enum EM_PASTESPECIAL = WM_USER+64;
+enum EM_REQUESTRESIZE = WM_USER+65;
+enum EM_SELECTIONTYPE = WM_USER+66;
+enum EM_SETBKGNDCOLOR = WM_USER+67;
+enum EM_SETCHARFORMAT = WM_USER+68;
+enum EM_SETEVENTMASK = WM_USER+69;
+enum EM_SETOLECALLBACK = WM_USER+70;
+enum EM_SETPARAFORMAT = WM_USER+71;
+enum EM_SETTARGETDEVICE = WM_USER+72;
+enum EM_STREAMIN = WM_USER+73;
+enum EM_STREAMOUT = WM_USER+74;
+enum EM_GETTEXTRANGE = WM_USER+75;
+enum EM_FINDWORDBREAK = WM_USER+76;
+enum EM_SETOPTIONS = WM_USER+77;
+enum EM_GETOPTIONS = WM_USER+78;
+enum EM_FINDTEXTEX = WM_USER+79;
+enum EM_GETWORDBREAKPROCEX = WM_USER+80;
+enum EM_SETWORDBREAKPROCEX = WM_USER+81;
+/* RichEdit 2.0 messages */
+enum EM_SETUNDOLIMIT = WM_USER+82;
+enum EM_REDO = WM_USER+84;
+enum EM_CANREDO = WM_USER+85;
+enum EM_GETUNDONAME = WM_USER+86;
+enum EM_GETREDONAME = WM_USER+87;
+enum EM_STOPGROUPTYPING = WM_USER+88;
+enum EM_SETTEXTMODE = WM_USER+89;
+enum EM_GETTEXTMODE = WM_USER+90;
+enum EM_AUTOURLDETECT = WM_USER+91;
+enum EM_GETAUTOURLDETECT = WM_USER + 92;
+enum EM_SETPALETTE = WM_USER + 93;
+enum EM_GETTEXTEX = WM_USER+94;
+enum EM_GETTEXTLENGTHEX = WM_USER+95;
+enum EM_SHOWSCROLLBAR = WM_USER+96;
+enum EM_SETTEXTEX = WM_USER + 97;
+enum EM_SETPUNCTUATION = WM_USER + 100;
+enum EM_GETPUNCTUATION = WM_USER + 101;
+enum EM_SETWORDWRAPMODE = WM_USER + 102;
+enum EM_GETWORDWRAPMODE = WM_USER + 103;
+enum EM_SETIMECOLOR = WM_USER + 104;
+enum EM_GETIMECOLOR = WM_USER + 105;
+enum EM_SETIMEOPTIONS = WM_USER + 106;
+enum EM_GETIMEOPTIONS = WM_USER + 107;
+enum EM_SETLANGOPTIONS = WM_USER+120;
+enum EM_GETLANGOPTIONS = WM_USER+121;
+enum EM_GETIMECOMPMODE = WM_USER+122;
+enum EM_FINDTEXTW = WM_USER + 123;
+enum EM_FINDTEXTEXW = WM_USER + 124;
+enum EM_RECONVERSION = WM_USER + 125;
+enum EM_SETBIDIOPTIONS = WM_USER + 200;
+enum EM_GETBIDIOPTIONS = WM_USER + 201;
+enum EM_SETTYPOGRAPHYOPTIONS = WM_USER+202;
+enum EM_GETTYPOGRAPHYOPTIONS = WM_USER+203;
+enum EM_SETEDITSTYLE = WM_USER + 204;
+enum EM_GETEDITSTYLE = WM_USER + 205;
+enum EM_GETSCROLLPOS = WM_USER+221;
+enum EM_SETSCROLLPOS = WM_USER+222;
+enum EM_SETFONTSIZE = WM_USER+223;
+enum EM_GETZOOM = WM_USER+224;
+enum EM_SETZOOM = WM_USER+225;
+
+enum EN_MSGFILTER     = 1792;
+enum EN_REQUESTRESIZE = 1793;
+enum EN_SELCHANGE     = 1794;
+enum EN_DROPFILES     = 1795;
+enum EN_PROTECTED     = 1796;
+enum EN_CORRECTTEXT   = 1797;
+enum EN_STOPNOUNDO    = 1798;
+enum EN_IMECHANGE     = 1799;
+enum EN_SAVECLIPBOARD = 1800;
+enum EN_OLEOPFAILED   = 1801;
+enum EN_LINK          = 1803;
+
+enum ENM_NONE            = 0;
+enum ENM_CHANGE          = 1;
+enum ENM_UPDATE          = 2;
+enum ENM_SCROLL          = 4;
+enum ENM_SCROLLEVENTS    = 8;
+enum ENM_DRAGDROPDONE    = 16;
+enum ENM_KEYEVENTS       = 65536;
+enum ENM_MOUSEEVENTS     = 131072;
+enum ENM_REQUESTRESIZE   = 262144;
+enum ENM_SELCHANGE       = 524288;
+enum ENM_DROPFILES       = 1048576;
+enum ENM_PROTECTED       = 2097152;
+enum ENM_CORRECTTEXT     = 4194304;
+enum ENM_IMECHANGE       = 8388608;
+enum ENM_LANGCHANGE      = 16777216;
+enum ENM_OBJECTPOSITIONS = 33554432;
+enum ENM_LINK            = 67108864;
+
+enum ECO_AUTOWORDSELECTION=1;
+enum ECO_AUTOVSCROLL=64;
+enum ECO_AUTOHSCROLL=128;
+enum ECO_NOHIDESEL=256;
+enum ECO_READONLY=2048;
+enum ECO_WANTRETURN=4096;
+enum ECO_SAVESEL=0x8000;
+enum ECO_SELECTIONBAR=0x1000000;
+enum ECO_VERTICAL=0x400000;
+
+enum {
+    ECOOP_SET = 1,
+    ECOOP_OR,
+    ECOOP_AND,
+    ECOOP_XOR
+}
+
+enum SCF_DEFAULT    = 0;
+enum SCF_SELECTION  = 1;
+enum SCF_WORD       = 2;
+enum SCF_ALL        = 4;
+enum SCF_USEUIRULES = 8;
+
+alias DWORD TEXTMODE;
+enum TM_PLAINTEXT=1;
+enum TM_RICHTEXT=2;
+enum TM_SINGLELEVELUNDO=4;
+enum TM_MULTILEVELUNDO=8;
+enum TM_SINGLECODEPAGE=16;
+enum TM_MULTICODEPAGE=32;
+
+enum GT_DEFAULT=0;
+enum GT_USECRLF=1;
+
+enum yHeightCharPtsMost=1638;
+enum lDefaultTab=720;
+
+alias DWORD UNDONAMEID;
+enum UID_UNKNOWN    = 0;
+enum UID_TYPING     = 1;
+enum UID_DELETE     = 2;
+enum UID_DRAGDROP   = 3;
+enum UID_CUT        = 4;
+enum UID_PASTE      = 5;
+
+struct CHARFORMATA {
+    UINT cbSize = this.sizeof;
+    DWORD dwMask;
+    DWORD dwEffects;
+    LONG yHeight;
+    LONG yOffset;
+    COLORREF crTextColor;
+    BYTE bCharSet;
+    BYTE bPitchAndFamily;
+    char[LF_FACESIZE] szFaceName;
+}
+struct CHARFORMATW {
+    UINT cbSize = this.sizeof;
+    DWORD dwMask;
+    DWORD dwEffects;
+    LONG yHeight;
+    LONG yOffset;
+    COLORREF crTextColor;
+    BYTE bCharSet;
+    BYTE bPitchAndFamily;
+    WCHAR[LF_FACESIZE] szFaceName;
+}
+
+struct CHARFORMAT2A {
+    UINT cbSize = this.sizeof;
+    DWORD dwMask;
+    DWORD dwEffects;
+    LONG yHeight;
+    LONG yOffset;
+    COLORREF crTextColor;
+    BYTE bCharSet;
+    BYTE bPitchAndFamily;
+    char[LF_FACESIZE] szFaceName;
+    WORD wWeight;
+    SHORT sSpacing;
+    COLORREF crBackColor;
+    LCID lcid;
+    DWORD dwReserved;
+    SHORT sStyle;
+    WORD wKerning;
+    BYTE bUnderlineType;
+    BYTE bAnimation;
+    BYTE bRevAuthor;
+}
+
+struct CHARFORMAT2W {
+    UINT cbSize = this.sizeof;
+    DWORD dwMask;
+    DWORD dwEffects;
+    LONG yHeight;
+    LONG yOffset;
+    COLORREF crTextColor;
+    BYTE bCharSet;
+    BYTE bPitchAndFamily;
+    WCHAR[LF_FACESIZE] szFaceName;
+    WORD wWeight;
+    SHORT sSpacing;
+    COLORREF crBackColor;
+    LCID lcid;
+    DWORD dwReserved;
+    SHORT sStyle;
+    WORD wKerning;
+    BYTE bUnderlineType;
+    BYTE bAnimation;
+    BYTE bRevAuthor;
+}
+
+struct CHARRANGE {
+    LONG cpMin;
+    LONG cpMax;
+}
+
+struct COMPCOLOR {
+    COLORREF crText;
+    COLORREF crBackground;
+    DWORD dwEffects;
+}
+
+extern (Windows) {
+    alias DWORD function(DWORD,PBYTE,LONG,LONG*) EDITSTREAMCALLBACK;
+}
+
+struct EDITSTREAM {
+    DWORD dwCookie;
+    DWORD dwError;
+    EDITSTREAMCALLBACK pfnCallback;
+}
+
+struct ENCORRECTTEXT {
+    NMHDR nmhdr;
+    CHARRANGE chrg;
+    WORD seltyp;
+}
+
+struct ENDROPFILES {
+    NMHDR nmhdr;
+    HANDLE hDrop;
+    LONG cp;
+    BOOL fProtected;
+}
+
+struct ENLINK {
+    NMHDR nmhdr;
+    UINT msg;
+    WPARAM wParam;
+    LPARAM lParam;
+    CHARRANGE chrg;
+}
+
+struct ENOLEOPFAILED {
+    NMHDR nmhdr;
+    LONG iob;
+    LONG lOper;
+    HRESULT hr;
+}
+
+struct ENPROTECTED {
+    NMHDR nmhdr;
+    UINT msg;
+    WPARAM wParam;
+    LPARAM lParam;
+    CHARRANGE chrg;
+}
+alias ENPROTECTED* LPENPROTECTED;
+
+struct ENSAVECLIPBOARD {
+    NMHDR nmhdr;
+    LONG cObjectCount;
+    LONG cch;
+}
+
+struct FINDTEXTA {
+    CHARRANGE chrg;
+    LPSTR lpstrText;
+}
+
+struct FINDTEXTW {
+    CHARRANGE chrg;
+    LPWSTR lpstrText;
+}
+
+struct FINDTEXTEXA {
+    CHARRANGE chrg;
+    LPSTR lpstrText;
+    CHARRANGE chrgText;
+}
+
+struct FINDTEXTEXW {
+    CHARRANGE chrg;
+    LPWSTR lpstrText;
+    CHARRANGE chrgText;
+}
+
+struct FORMATRANGE {
+    HDC hdc;
+    HDC hdcTarget;
+    RECT rc;
+    RECT rcPage;
+    CHARRANGE chrg;
+}
+
+struct MSGFILTER {
+    NMHDR nmhdr;
+    UINT msg;
+    WPARAM wParam;
+    LPARAM lParam;
+}
+
+struct PARAFORMAT {
+    UINT cbSize = this.sizeof;
+    DWORD dwMask;
+    WORD wNumbering;
+    WORD wReserved;
+    LONG dxStartIndent;
+    LONG dxRightIndent;
+    LONG dxOffset;
+    WORD wAlignment;
+    SHORT cTabCount;
+    LONG[MAX_TAB_STOPS] rgxTabs;
+}
+
+struct PARAFORMAT2 {
+    UINT cbSize = this.sizeof;
+    DWORD dwMask;
+    WORD wNumbering;
+    WORD wEffects;
+    LONG dxStartIndent;
+    LONG dxRightIndent;
+    LONG dxOffset;
+    WORD wAlignment;
+    SHORT cTabCount;
+    LONG[MAX_TAB_STOPS] rgxTabs;
+    LONG dySpaceBefore;
+    LONG dySpaceAfter;
+    LONG dyLineSpacing;
+    SHORT sStype;
+    BYTE bLineSpacingRule;
+    BYTE bOutlineLevel;
+    WORD wShadingWeight;
+    WORD wShadingStyle;
+    WORD wNumberingStart;
+    WORD wNumberingStyle;
+    WORD wNumberingTab;
+    WORD wBorderSpace;
+    WORD wBorderWidth;
+    WORD wBorders;
+}
+
+struct SELCHANGE {
+    NMHDR nmhdr;
+    CHARRANGE chrg;
+    WORD seltyp;
+}
+
+struct TEXTRANGEA {
+    CHARRANGE chrg;
+    LPSTR lpstrText;
+}
+
+struct TEXTRANGEW {
+    CHARRANGE chrg;
+    LPWSTR lpstrText;
+}
+
+struct REQRESIZE {
+    NMHDR nmhdr;
+    RECT rc;
+}
+
+struct REPASTESPECIAL {
+    DWORD dwAspect;
+    DWORD dwParam;
+}
+
+struct PUNCTUATION {
+    UINT iSize;
+    LPSTR szPunctuation;
+}
+
+struct GETTEXTEX {
+    DWORD cb;
+    DWORD flags;
+    UINT codepage;
+    LPCSTR lpDefaultChar;
+    LPBOOL lpUsedDefChar;
+}
+
+extern (Windows) {
+alias LONG function(char*,LONG,BYTE,INT) EDITWORDBREAKPROCEX;
+}
+
+/* Defines for EM_SETTYPOGRAPHYOPTIONS */
+enum TO_ADVANCEDTYPOGRAPHY = 1;
+enum TO_SIMPLELINEBREAK    = 2;
+
+/* Defines for GETTEXTLENGTHEX */
+enum GTL_DEFAULT  = 0;
+enum GTL_USECRLF  = 1;
+enum GTL_PRECISE  = 2;
+enum GTL_CLOSE    = 4;
+enum GTL_NUMCHARS = 8;
+enum GTL_NUMBYTES = 16;
+
+struct GETTEXTLENGTHEX {
+    DWORD flags;
+    UINT codepage;
+}
+
+version(Unicode) {
+    alias CHARFORMATW CHARFORMAT;
+    alias CHARFORMAT2W CHARFORMAT2;
+    alias FINDTEXTW FINDTEXT;
+    alias FINDTEXTEXW FINDTEXTEX;
+    alias TEXTRANGEW TEXTRANGE;
+} else {
+    alias CHARFORMATA CHARFORMAT;
+    alias CHARFORMAT2A CHARFORMAT2;
+    alias FINDTEXTA FINDTEXT;
+    alias FINDTEXTEXA FINDTEXTEX;
+    alias TEXTRANGEA TEXTRANGE;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/richole.d b/libphobos/libdruntime/core/sys/windows/richole.d
new file mode 100644
index 00000000000..83933149d3b
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/richole.d
@@ -0,0 +1,101 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_richole.d)
+ */
+module core.sys.windows.richole;
+version (Windows):
+
+private import core.sys.windows.objfwd, core.sys.windows.objidl, core.sys.windows.ole2, core.sys.windows.unknwn,
+  core.sys.windows.windef;
+private import core.sys.windows.richedit; // for CHARRANGE
+
+align(4):
+
+enum ULONG
+    REO_GETOBJ_NO_INTERFACES = 0,
+    REO_GETOBJ_POLEOBJ = 1,
+    REO_GETOBJ_PSTG = 2,
+    REO_GETOBJ_POLESITE = 4,
+    REO_GETOBJ_ALL_INTERFACES = 7,
+    REO_CP_SELECTION = -1,
+    REO_IOB_SELECTION = -1,
+    REO_IOB_USE_CP = -2,
+    REO_NULL = 0,
+    REO_READWRITEMASK = 0x3F,
+    REO_DONTNEEDPALETTE = 32,
+    REO_BLANK = 16,
+    REO_DYNAMICSIZE = 8,
+    REO_INVERTEDSELECT = 4,
+    REO_BELOWBASELINE = 2,
+    REO_RESIZABLE = 1,
+    REO_LINK = 0x80000000,
+    REO_STATIC = 0x40000000,
+    REO_SELECTED = 0x08000000,
+    REO_OPEN = 0x4000000,
+    REO_INPLACEACTIVE = 0x2000000,
+    REO_HILITED = 0x1000000,
+    REO_LINKAVAILABLE = 0x800000,
+    REO_GETMETAFILE = 0x400000;
+
+enum {
+    RECO_PASTE = 0,
+    RECO_DROP,
+    RECO_COPY,
+    RECO_CUT,
+    RECO_DRAG // = 4
+}
+
+extern (C) extern const GUID
+    IID_IRichEditOle,
+    IID_IRichEditOleCallback;
+
+struct REOBJECT {
+    DWORD           cbStruct = REOBJECT.sizeof;
+    LONG            cp;
+    CLSID           clsid;
+    LPOLEOBJECT     poleobj;
+    LPSTORAGE       pstg;
+    LPOLECLIENTSITE polesite;
+    SIZEL           sizel;
+    DWORD           dvaspect;
+    DWORD           dwFlags;
+    DWORD           dwUser;
+}
+
+interface IRichEditOle : IUnknown {
+    HRESULT GetClientSite(LPOLECLIENTSITE*);
+    LONG GetObjectCount();
+    LONG GetLinkCount();
+    HRESULT GetObject(LONG, REOBJECT*, DWORD);
+    HRESULT InsertObject(REOBJECT*);
+    HRESULT ConvertObject(LONG, REFCLSID, LPCSTR);
+    HRESULT ActivateAs(REFCLSID, REFCLSID);
+    HRESULT SetHostNames(LPCSTR, LPCSTR);
+    HRESULT SetLinkAvailable(LONG, BOOL);
+    HRESULT SetDvaspect(LONG, DWORD);
+    HRESULT HandsOffStorage(LONG);
+    HRESULT SaveCompleted(LONG, LPSTORAGE);
+    HRESULT InPlaceDeactivate();
+    HRESULT ContextSensitiveHelp(BOOL);
+    HRESULT GetClipboardData(CHARRANGE*, DWORD, LPDATAOBJECT*);
+    HRESULT ImportDataObject(LPDATAOBJECT, CLIPFORMAT, HGLOBAL);
+};
+alias IRichEditOle LPRICHEDITOLE;
+
+interface IRichEditOleCallback : IUnknown {
+    HRESULT GetNewStorage(LPSTORAGE*);
+    HRESULT GetInPlaceContext(LPOLEINPLACEFRAME*, LPOLEINPLACEUIWINDOW*, LPOLEINPLACEFRAMEINFO);
+    HRESULT ShowContainerUI(BOOL);
+    HRESULT QueryInsertObject(LPCLSID, LPSTORAGE, LONG);
+    HRESULT DeleteObject(LPOLEOBJECT);
+    HRESULT QueryAcceptData(LPDATAOBJECT, CLIPFORMAT*, DWORD, BOOL, HGLOBAL);
+    HRESULT ContextSensitiveHelp(BOOL);
+    HRESULT GetClipboardData(CHARRANGE*, DWORD, LPDATAOBJECT*);
+    HRESULT GetDragDropEffect(BOOL, DWORD, PDWORD);
+    HRESULT GetContextMenu(WORD, LPOLEOBJECT, CHARRANGE*, HMENU*);
+};
+alias IRichEditOleCallback LPRICHEDITOLECALLBACK;
diff --git a/libphobos/libdruntime/core/sys/windows/rpc.d b/libphobos/libdruntime/core/sys/windows/rpc.d
new file mode 100644
index 00000000000..6097184e2dd
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/rpc.d
@@ -0,0 +1,31 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_rpc.d)
+ */
+module core.sys.windows.rpc;
+version (Windows):
+
+/* Moved to rpcdecp (duplicate definition).
+    typedef void *I_RPC_HANDLE;
+    alias long RPC_STATUS;
+    // Moved to rpcdce:
+    RpcImpersonateClient
+    RpcRevertToSelf
+*/
+
+public import core.sys.windows.unknwn;
+public import core.sys.windows.rpcdce;  // also pulls in rpcdcep
+public import core.sys.windows.rpcnsi;
+public import core.sys.windows.rpcnterr;
+public import core.sys.windows.winerror;
+
+alias MIDL_user_allocate midl_user_allocate;
+alias MIDL_user_free midl_user_free;
+
+extern (Windows) {
+    int I_RpcMapWin32Status(RPC_STATUS);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/rpcdce.d b/libphobos/libdruntime/core/sys/windows/rpcdce.d
new file mode 100644
index 00000000000..3f7e2a4cb4b
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/rpcdce.d
@@ -0,0 +1,413 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_rpcdce.d)
+ */
+module core.sys.windows.rpcdce;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "Rpcrt4");
+
+// TODO: I think MinGW got this wrong. RPC_UNICODE_SUPPORTED should be
+// replaced aliases for version(Unicode)
+
+public import core.sys.windows.rpcdcep;
+private import core.sys.windows.basetyps, core.sys.windows.w32api, core.sys.windows.windef;
+
+// FIXME: clean up Windows version support
+
+alias UUID uuid_t;
+alias UUID_VECTOR uuid_vector_t;
+alias void RPC_MGR_EPV;
+
+// for RpcMgmtSetComTimeout()
+enum : uint {
+    RPC_C_BINDING_MIN_TIMEOUT      = 0,
+    RPC_C_BINDING_DEFAULT_TIMEOUT  = 5,
+    RPC_C_BINDING_MAX_TIMEOUT      = 9,
+    RPC_C_BINDING_INFINITE_TIMEOUT = 10
+}
+
+enum RPC_C_CANCEL_INFINITE_TIMEOUT= -1;
+enum RPC_C_LISTEN_MAX_CALLS_DEFAULT=1234;
+enum RPC_C_PROTSEQ_MAX_REQS_DEFAULT=10;
+enum RPC_C_BIND_TO_ALL_NICS=1;
+enum RPC_C_USE_INTERNET_PORT=1;
+enum RPC_C_USE_INTRANET_PORT=2;
+
+// for RPC_STATS_VECTOR, used by RpcMgmyInqStats
+enum : uint {
+    RPC_C_STATS_CALLS_IN  = 0,
+    RPC_C_STATS_CALLS_OUT,
+    RPC_C_STATS_PKTS_IN,
+    RPC_C_STATS_PKTS_OUT
+}
+
+enum RPC_IF_AUTOLISTEN=0x0001;
+enum RPC_IF_OLE=2;
+enum RPC_C_MGMT_INQ_IF_IDS=0;
+enum RPC_C_MGMT_INQ_PRINC_NAME=1;
+enum RPC_C_MGMT_INQ_STATS=2;
+enum RPC_C_MGMT_IS_SERVER_LISTEN=3;
+enum RPC_C_MGMT_STOP_SERVER_LISTEN=4;
+
+// Inquiry Type for RpcMgmtEpEltInqBegin()
+enum : uint {
+    RPC_C_EP_ALL_ELTS = 0,
+    RPC_C_EP_MATCH_BY_IF,
+    RPC_C_EP_MATCH_BY_OBJ,
+    RPC_C_EP_MATCH_BY_BOTH
+}
+
+// for RpcMgmtEpEltInqNext()
+enum : uint {
+    RPC_C_VERS_ALL = 1,
+    RPC_C_VERS_COMPATIBLE,
+    RPC_C_VERS_EXACT,
+    RPC_C_VERS_MAJOR_ONLY,
+    RPC_C_VERS_UPTO
+}
+
+enum DCE_C_ERROR_STRING_LEN=256;
+enum RPC_C_PARM_MAX_PACKET_LENGTH=1;
+enum RPC_C_PARM_BUFFER_LENGTH=2;
+enum RPC_C_AUTHN_LEVEL_DEFAULT=0;
+enum RPC_C_AUTHN_LEVEL_NONE=1;
+enum RPC_C_AUTHN_LEVEL_CONNECT=2;
+enum RPC_C_AUTHN_LEVEL_CALL=3;
+enum RPC_C_AUTHN_LEVEL_PKT=4;
+enum RPC_C_AUTHN_LEVEL_PKT_INTEGRITY=5;
+enum RPC_C_AUTHN_LEVEL_PKT_PRIVACY=6;
+enum RPC_C_IMP_LEVEL_ANONYMOUS=1;
+enum RPC_C_IMP_LEVEL_IDENTIFY=2;
+enum RPC_C_IMP_LEVEL_IMPERSONATE=3;
+enum RPC_C_IMP_LEVEL_DELEGATE=4;
+enum RPC_C_QOS_IDENTITY_STATIC=0;
+enum RPC_C_QOS_IDENTITY_DYNAMIC=1;
+enum RPC_C_QOS_CAPABILITIES_DEFAULT=0;
+enum RPC_C_QOS_CAPABILITIES_MUTUAL_AUTH=1;
+
+// These enums were buggy in MinGW !
+enum RPC_C_PROTECT_LEVEL_DEFAULT = RPC_C_AUTHN_LEVEL_DEFAULT;
+enum RPC_C_PROTECT_LEVEL_NONE = RPC_C_AUTHN_LEVEL_NONE;
+enum RPC_C_PROTECT_LEVEL_CONNECT = RPC_C_AUTHN_LEVEL_CONNECT;
+enum RPC_C_PROTECT_LEVEL_CALL = RPC_C_AUTHN_LEVEL_CALL;
+enum RPC_C_PROTECT_LEVEL_PKT = RPC_C_AUTHN_LEVEL_PKT;
+enum RPC_C_PROTECT_LEVEL_PKT_INTEGRITY = RPC_C_AUTHN_LEVEL_PKT_INTEGRITY;
+enum RPC_C_PROTECT_LEVEL_PKT_PRIVACY = RPC_C_AUTHN_LEVEL_PKT_PRIVACY;
+
+enum RPC_C_AUTHN_NONE=0;
+enum RPC_C_AUTHN_DCE_PRIVATE=1;
+enum RPC_C_AUTHN_DCE_PUBLIC=2;
+enum RPC_C_AUTHN_DEC_PUBLIC=4;
+enum RPC_C_AUTHN_WINNT=10;
+enum RPC_C_AUTHN_DEFAULT=0xFFFFFFFF;
+//const RPC_C_SECURITY_QOS_VERSION=L; // FIXME(MinGW): This is nonsense!
+enum SEC_WINNT_AUTH_IDENTITY_ANSI=0x1;
+enum SEC_WINNT_AUTH_IDENTITY_UNICODE=0x2;
+enum RPC_C_AUTHZ_NONE=0;
+enum RPC_C_AUTHZ_NAME=1;
+enum RPC_C_AUTHZ_DCE=2;
+enum RPC_C_AUTHZ_DEFAULT=0xFFFFFFFF;
+
+alias I_RPC_HANDLE RPC_BINDING_HANDLE;
+alias RPC_BINDING_HANDLE handle_t;
+
+struct RPC_BINDING_VECTOR {
+    uint Count;
+    RPC_BINDING_HANDLE[1] BindingH;
+}
+
+alias RPC_BINDING_HANDLE rpc_binding_handle_t;
+alias RPC_BINDING_VECTOR rpc_binding_vector_t;
+
+
+struct UUID_VECTOR {
+    uint Count;
+    UUID*[1] Uuid;
+}
+
+alias void* RPC_IF_HANDLE;
+
+struct RPC_IF_ID {
+    UUID Uuid;
+    ushort VersMajor;
+    ushort VersMinor;
+}
+
+struct RPC_POLICY {
+    uint Length;
+    uint EndpointFlags;
+    uint NICFlags;
+}
+alias RPC_POLICY* PRPC_POLICY;
+
+extern (Windows) {
+    alias void function(UUID*, UUID*, RPC_STATUS*) RPC_OBJECT_INQ_FN;
+    alias RPC_STATUS function(RPC_IF_HANDLE, void*) RPC_IF_CALLBACK_FN;
+}
+
+struct RPC_STATS_VECTOR {
+    uint    Count;
+    uint[1] Stats;
+}
+
+struct RPC_IF_ID_VECTOR {
+    uint          Count;
+    RPC_IF_ID*[1] IfId;
+}
+mixin DECLARE_HANDLE!("RPC_AUTH_IDENTITY_HANDLE");
+mixin DECLARE_HANDLE!("RPC_AUTHZ_HANDLE");
+
+struct RPC_SECURITY_QOS {
+    uint Version;
+    uint Capabilities;
+    uint IdentityTracking;
+    uint ImpersonationType;
+}
+alias RPC_SECURITY_QOS* PRPC_SECURITY_QOS;
+
+struct SEC_WINNT_AUTH_IDENTITY_W {
+    ushort* User;
+    uint UserLength;
+    ushort* Domain;
+    uint DomainLength;
+    ushort* Password;
+    uint PasswordLength;
+    uint Flags;
+}
+alias SEC_WINNT_AUTH_IDENTITY_W* PSEC_WINNT_AUTH_IDENTITY_W;
+
+struct SEC_WINNT_AUTH_IDENTITY_A {
+    ubyte* User;
+    uint UserLength;
+    ubyte* Domain;
+    uint DomainLength;
+    ubyte* Password;
+    uint PasswordLength;
+    uint Flags;
+}
+alias SEC_WINNT_AUTH_IDENTITY_A* PSEC_WINNT_AUTH_IDENTITY_A;
+
+struct RPC_CLIENT_INFORMATION1 {
+    ubyte* UserName;
+    ubyte* ComputerName;
+    ushort Privilege;
+    uint AuthFlags;
+}
+alias RPC_CLIENT_INFORMATION1* PRPC_CLIENT_INFORMATION1;
+alias I_RPC_HANDLE* RPC_EP_INQ_HANDLE;
+extern (Windows) {
+    alias int function(RPC_BINDING_HANDLE, uint, RPC_STATUS*) RPC_MGMT_AUTHORIZATION_FN;
+}
+
+struct RPC_PROTSEQ_VECTORA {
+    uint Count;
+    ubyte*[1] Protseq;
+}
+
+struct RPC_PROTSEQ_VECTORW {
+    uint Count;
+    ushort*[1] Protseq;
+}
+
+extern (Windows) {
+    RPC_STATUS RpcBindingFromStringBindingA(char*, RPC_BINDING_HANDLE*);
+    RPC_STATUS RpcBindingFromStringBindingW(wchar*, RPC_BINDING_HANDLE*);
+    RPC_STATUS RpcBindingToStringBindingA(RPC_BINDING_HANDLE, char**);
+    RPC_STATUS RpcBindingToStringBindingW(RPC_BINDING_HANDLE, wchar**);
+    RPC_STATUS RpcStringBindingComposeA(char*, char*, char*, char*, char*, char**);
+    RPC_STATUS RpcStringBindingComposeW(wchar*, wchar*, wchar*, wchar*, wchar*, wchar**);
+    RPC_STATUS RpcStringBindingParseA(char*, char**, char**, char**, char**, char**);
+    RPC_STATUS RpcStringBindingParseW(wchar*, wchar**, wchar**, wchar**, wchar**, wchar**);
+    RPC_STATUS RpcStringFreeA(char**);
+    RPC_STATUS RpcStringFreeW(wchar**);
+    RPC_STATUS RpcNetworkIsProtseqValidA(char*);
+    RPC_STATUS RpcNetworkIsProtseqValidW(wchar*);
+    RPC_STATUS RpcNetworkInqProtseqsA(RPC_PROTSEQ_VECTORA**);
+    RPC_STATUS RpcNetworkInqProtseqsW(RPC_PROTSEQ_VECTORW**);
+    RPC_STATUS RpcProtseqVectorFreeA(RPC_PROTSEQ_VECTORA**);
+    RPC_STATUS RpcProtseqVectorFreeW(RPC_PROTSEQ_VECTORW**);
+    RPC_STATUS RpcServerUseProtseqA(char*, uint, void*);
+    RPC_STATUS RpcServerUseProtseqW(wchar*, uint, void*);
+    RPC_STATUS RpcServerUseProtseqExA(char*, uint MaxCalls, void*, PRPC_POLICY);
+    RPC_STATUS RpcServerUseProtseqExW(wchar*, uint, void*, PRPC_POLICY);
+    RPC_STATUS RpcServerUseProtseqEpA(char*, uint, char*, void*);
+    RPC_STATUS RpcServerUseProtseqEpExA(char*, uint, char*, void*, PRPC_POLICY);
+    RPC_STATUS RpcServerUseProtseqEpW(wchar*, uint, wchar*, void*);
+    RPC_STATUS RpcServerUseProtseqEpExW(wchar*, uint, wchar*, void*, PRPC_POLICY);
+    RPC_STATUS RpcServerUseProtseqIfA(char*, uint, RPC_IF_HANDLE, void*);
+    RPC_STATUS RpcServerUseProtseqIfExA(char*, uint, RPC_IF_HANDLE, void*, PRPC_POLICY);
+    RPC_STATUS RpcServerUseProtseqIfW(wchar*, uint, RPC_IF_HANDLE, void*);
+    RPC_STATUS RpcServerUseProtseqIfExW(wchar*, uint, RPC_IF_HANDLE, void*, PRPC_POLICY);
+    RPC_STATUS RpcMgmtInqServerPrincNameA(RPC_BINDING_HANDLE, uint, char**);
+    RPC_STATUS RpcMgmtInqServerPrincNameW(RPC_BINDING_HANDLE, uint, wchar**);
+    RPC_STATUS RpcServerInqDefaultPrincNameA(uint, char**);
+    RPC_STATUS RpcServerInqDefaultPrincNameW(uint, wchar**);
+    RPC_STATUS RpcNsBindingInqEntryNameA(RPC_BINDING_HANDLE, uint, char**);
+    RPC_STATUS RpcNsBindingInqEntryNameW(RPC_BINDING_HANDLE, uint, wchar**);
+    RPC_STATUS RpcBindingInqAuthClientA(RPC_BINDING_HANDLE, RPC_AUTHZ_HANDLE*, char**, uint*, uint*, uint*);
+    RPC_STATUS RpcBindingInqAuthClientW(RPC_BINDING_HANDLE, RPC_AUTHZ_HANDLE*, wchar**, uint*, uint*, uint*);
+    RPC_STATUS RpcBindingInqAuthInfoA(RPC_BINDING_HANDLE, char**, uint*, uint*, RPC_AUTH_IDENTITY_HANDLE*, uint*);
+    RPC_STATUS RpcBindingInqAuthInfoW(RPC_BINDING_HANDLE, wchar**, uint*, uint*, RPC_AUTH_IDENTITY_HANDLE*, uint*);
+    RPC_STATUS RpcBindingSetAuthInfoA(RPC_BINDING_HANDLE, char*, uint, uint, RPC_AUTH_IDENTITY_HANDLE, uint);
+    RPC_STATUS RpcBindingSetAuthInfoExA(RPC_BINDING_HANDLE, char*, uint, uint, RPC_AUTH_IDENTITY_HANDLE, uint, RPC_SECURITY_QOS*);
+    RPC_STATUS RpcBindingSetAuthInfoW(RPC_BINDING_HANDLE, wchar*, uint, uint, RPC_AUTH_IDENTITY_HANDLE, uint);
+    RPC_STATUS RpcBindingSetAuthInfoExW(RPC_BINDING_HANDLE, wchar*, uint, uint, RPC_AUTH_IDENTITY_HANDLE, uint, RPC_SECURITY_QOS*);
+    RPC_STATUS RpcBindingInqAuthInfoExA(RPC_BINDING_HANDLE, char**, uint*, uint*, RPC_AUTH_IDENTITY_HANDLE*, uint*, uint, RPC_SECURITY_QOS*);
+    RPC_STATUS RpcBindingInqAuthInfoExW(RPC_BINDING_HANDLE, wchar**, uint*, uint*, RPC_AUTH_IDENTITY_HANDLE*, uint*, uint, RPC_SECURITY_QOS*);
+    alias void function(void*, wchar*, uint, void**, RPC_STATUS*) RPC_AUTH_KEY_RETRIEVAL_FN;
+    RPC_STATUS RpcServerRegisterAuthInfoA(char*, uint, RPC_AUTH_KEY_RETRIEVAL_FN, void*);
+    RPC_STATUS RpcServerRegisterAuthInfoW(wchar*, uint, RPC_AUTH_KEY_RETRIEVAL_FN, void*);
+    RPC_STATUS UuidToStringA(UUID*, char**);
+    RPC_STATUS UuidFromStringA(char*, UUID*);
+    RPC_STATUS UuidToStringW(UUID*, wchar**);
+    RPC_STATUS UuidFromStringW(wchar*, UUID*);
+    RPC_STATUS RpcEpRegisterNoReplaceA(RPC_IF_HANDLE, RPC_BINDING_VECTOR*, UUID_VECTOR*, char*);
+    RPC_STATUS RpcEpRegisterNoReplaceW(RPC_IF_HANDLE, RPC_BINDING_VECTOR*, UUID_VECTOR*, wchar*);
+    RPC_STATUS RpcEpRegisterA(RPC_IF_HANDLE, RPC_BINDING_VECTOR*, UUID_VECTOR*, char*);
+    RPC_STATUS RpcEpRegisterW(RPC_IF_HANDLE, RPC_BINDING_VECTOR*, UUID_VECTOR*, wchar*);
+    RPC_STATUS DceErrorInqTextA(RPC_STATUS, char*);
+    RPC_STATUS DceErrorInqTextW(RPC_STATUS, wchar*);
+    RPC_STATUS RpcMgmtEpEltInqNextA(RPC_EP_INQ_HANDLE, RPC_IF_ID*, RPC_BINDING_HANDLE*, UUID*, char**);
+    RPC_STATUS RpcMgmtEpEltInqNextW(RPC_EP_INQ_HANDLE, RPC_IF_ID*, RPC_BINDING_HANDLE*, UUID*, wchar**);
+
+    // MinGW erroneously had these in rpc.h
+    RPC_STATUS RpcImpersonateClient(RPC_BINDING_HANDLE);
+    RPC_STATUS RpcRevertToSelf();
+}
+
+version (Unicode) {
+    alias RPC_PROTSEQ_VECTORW RPC_PROTSEQ_VECTOR;
+    alias SEC_WINNT_AUTH_IDENTITY_W SEC_WINNT_AUTH_IDENTITY;
+    alias PSEC_WINNT_AUTH_IDENTITY_W PSEC_WINNT_AUTH_IDENTITY;
+    alias RpcMgmtEpEltInqNextW RpcMgmtEpEltInqNext;
+    alias RpcBindingFromStringBindingW RpcBindingFromStringBinding;
+    alias RpcBindingToStringBindingW RpcBindingToStringBinding;
+    alias RpcStringBindingComposeW RpcStringBindingCompose;
+    alias RpcStringBindingParseW RpcStringBindingParse;
+    alias RpcStringFreeW RpcStringFree;
+    alias RpcNetworkIsProtseqValidW RpcNetworkIsProtseqValid;
+    alias RpcNetworkInqProtseqsW RpcNetworkInqProtseqs;
+    alias RpcProtseqVectorFreeW RpcProtseqVectorFree;
+    alias RpcServerUseProtseqW RpcServerUseProtseq;
+    alias RpcServerUseProtseqExW RpcServerUseProtseqEx;
+    alias RpcServerUseProtseqEpW RpcServerUseProtseqEp;
+    alias RpcServerUseProtseqEpExW RpcServerUseProtseqEpEx;
+    alias RpcServerUseProtseqIfW RpcServerUseProtseqIf;
+    alias RpcServerUseProtseqIfExW RpcServerUseProtseqIfEx;
+    alias RpcMgmtInqServerPrincNameW RpcMgmtInqServerPrincName;
+    alias RpcServerInqDefaultPrincNameW RpcServerInqDefaultPrincName;
+    alias RpcNsBindingInqEntryNameW RpcNsBindingInqEntryName;
+    alias RpcBindingInqAuthClientW RpcBindingInqAuthClient;
+    alias RpcBindingInqAuthInfoW RpcBindingInqAuthInfo;
+    alias RpcBindingSetAuthInfoW RpcBindingSetAuthInfo;
+    alias RpcServerRegisterAuthInfoW RpcServerRegisterAuthInfo;
+    alias RpcBindingInqAuthInfoExW RpcBindingInqAuthInfoEx;
+    alias RpcBindingSetAuthInfoExW RpcBindingSetAuthInfoEx;
+    alias UuidFromStringW UuidFromString;
+    alias UuidToStringW UuidToString;
+    alias RpcEpRegisterNoReplaceW RpcEpRegisterNoReplace;
+    alias RpcEpRegisterW RpcEpRegister;
+    alias DceErrorInqTextW DceErrorInqText;
+} else { // Ansi
+    alias RPC_PROTSEQ_VECTORA RPC_PROTSEQ_VECTOR;
+    alias SEC_WINNT_AUTH_IDENTITY_A SEC_WINNT_AUTH_IDENTITY;
+    alias PSEC_WINNT_AUTH_IDENTITY_A PSEC_WINNT_AUTH_IDENTITY;
+    alias RpcMgmtEpEltInqNextA RpcMgmtEpEltInqNext;
+    alias RpcBindingFromStringBindingA RpcBindingFromStringBinding;
+    alias RpcBindingToStringBindingA RpcBindingToStringBinding;
+    alias RpcStringBindingComposeA RpcStringBindingCompose;
+    alias RpcStringBindingParseA RpcStringBindingParse;
+    alias RpcStringFreeA RpcStringFree;
+    alias RpcNetworkIsProtseqValidA RpcNetworkIsProtseqValid;
+    alias RpcNetworkInqProtseqsA RpcNetworkInqProtseqs;
+    alias RpcProtseqVectorFreeA RpcProtseqVectorFree;
+    alias RpcServerUseProtseqA RpcServerUseProtseq;
+    alias RpcServerUseProtseqExA RpcServerUseProtseqEx;
+    alias RpcServerUseProtseqEpA RpcServerUseProtseqEp;
+    alias RpcServerUseProtseqEpExA RpcServerUseProtseqEpEx;
+    alias RpcServerUseProtseqIfA RpcServerUseProtseqIf;
+    alias RpcServerUseProtseqIfExA RpcServerUseProtseqIfEx;
+    alias RpcMgmtInqServerPrincNameA RpcMgmtInqServerPrincName;
+    alias RpcServerInqDefaultPrincNameA RpcServerInqDefaultPrincName;
+    alias RpcNsBindingInqEntryNameA RpcNsBindingInqEntryName;
+    alias RpcBindingInqAuthClientA RpcBindingInqAuthClient;
+    alias RpcBindingInqAuthInfoA RpcBindingInqAuthInfo;
+    alias RpcBindingSetAuthInfoA RpcBindingSetAuthInfo;
+    alias RpcServerRegisterAuthInfoA RpcServerRegisterAuthInfo;
+    alias RpcBindingInqAuthInfoExA RpcBindingInqAuthInfoEx;
+    alias RpcBindingSetAuthInfoExA RpcBindingSetAuthInfoEx;
+    alias UuidFromStringA UuidFromString;
+    alias UuidToStringA UuidToString;
+    alias RpcEpRegisterNoReplaceA RpcEpRegisterNoReplace;
+    alias RpcEpRegisterA RpcEpRegister;
+    alias DceErrorInqTextA DceErrorInqText;
+} //#endif // UNICODE
+
+
+RPC_STATUS RpcBindingCopy(RPC_BINDING_HANDLE, RPC_BINDING_HANDLE*);
+RPC_STATUS RpcBindingFree(RPC_BINDING_HANDLE*);
+RPC_STATUS RpcBindingInqObject(RPC_BINDING_HANDLE, UUID*);
+RPC_STATUS RpcBindingReset(RPC_BINDING_HANDLE);
+RPC_STATUS RpcBindingSetObject(RPC_BINDING_HANDLE, UUID*);
+RPC_STATUS RpcMgmtInqDefaultProtectLevel(uint, uint*);
+RPC_STATUS RpcBindingVectorFree(RPC_BINDING_VECTOR**);
+RPC_STATUS RpcIfInqId(RPC_IF_HANDLE, RPC_IF_ID*);
+RPC_STATUS RpcMgmtInqComTimeout(RPC_BINDING_HANDLE, uint*);
+RPC_STATUS RpcMgmtSetComTimeout(RPC_BINDING_HANDLE, uint);
+RPC_STATUS RpcMgmtSetCancelTimeout(int Timeout);
+RPC_STATUS RpcObjectInqType(UUID*, UUID*);
+RPC_STATUS RpcObjectSetInqFn(RPC_OBJECT_INQ_FN*);
+RPC_STATUS RpcObjectSetType(UUID*, UUID*);
+RPC_STATUS RpcProtseqVectorFree(RPC_PROTSEQ_VECTOR**);
+RPC_STATUS RpcServerInqIf(RPC_IF_HANDLE, UUID*, RPC_MGR_EPV**);
+RPC_STATUS RpcServerListen(uint, uint, uint);
+RPC_STATUS RpcServerRegisterIf(RPC_IF_HANDLE, UUID*, RPC_MGR_EPV*);
+RPC_STATUS RpcServerRegisterIfEx(RPC_IF_HANDLE, UUID*, RPC_MGR_EPV*, uint, uint, RPC_IF_CALLBACK_FN*);
+RPC_STATUS RpcServerRegisterIf2(RPC_IF_HANDLE, UUID*, RPC_MGR_EPV*, uint, uint, uint, RPC_IF_CALLBACK_FN*);
+RPC_STATUS RpcServerUnregisterIf(RPC_IF_HANDLE, UUID*, uint);
+RPC_STATUS RpcServerUseAllProtseqs(uint, void*);
+RPC_STATUS RpcServerUseAllProtseqsEx(uint, void*, PRPC_POLICY);
+RPC_STATUS RpcServerUseAllProtseqsIf(uint, RPC_IF_HANDLE, void*);
+RPC_STATUS RpcServerUseAllProtseqsIfEx(uint, RPC_IF_HANDLE, void*, PRPC_POLICY);
+RPC_STATUS RpcMgmtStatsVectorFree(RPC_STATS_VECTOR**);
+RPC_STATUS RpcMgmtInqStats(RPC_BINDING_HANDLE, RPC_STATS_VECTOR**);
+RPC_STATUS RpcMgmtIsServerListening(RPC_BINDING_HANDLE);
+RPC_STATUS RpcMgmtStopServerListening(RPC_BINDING_HANDLE);
+RPC_STATUS RpcMgmtWaitServerListen();
+RPC_STATUS RpcMgmtSetServerStackSize(uint);
+void RpcSsDontSerializeContext();
+RPC_STATUS RpcMgmtEnableIdleCleanup();
+RPC_STATUS RpcMgmtInqIfIds(RPC_BINDING_HANDLE, RPC_IF_ID_VECTOR**);
+RPC_STATUS RpcIfIdVectorFree(RPC_IF_ID_VECTOR**);
+RPC_STATUS RpcEpResolveBinding(RPC_BINDING_HANDLE, RPC_IF_HANDLE);
+RPC_STATUS RpcBindingServerFromClient(RPC_BINDING_HANDLE, RPC_BINDING_HANDLE*);
+
+// never returns
+void RpcRaiseException(RPC_STATUS);
+RPC_STATUS RpcTestCancel();
+RPC_STATUS RpcCancelThread(void*);
+RPC_STATUS UuidCreate(UUID*);
+int UuidCompare(UUID*, UUID*, RPC_STATUS*);
+RPC_STATUS UuidCreateNil(UUID*);
+int UuidEqual(UUID*, UUID*, RPC_STATUS*);
+ushort UuidHash(UUID*, RPC_STATUS*);
+int UuidIsNil(UUID*, RPC_STATUS*);
+RPC_STATUS RpcEpUnregister(RPC_IF_HANDLE, RPC_BINDING_VECTOR*, UUID_VECTOR*);
+RPC_STATUS RpcMgmtEpEltInqBegin(RPC_BINDING_HANDLE, uint, RPC_IF_ID*, uint, UUID*, RPC_EP_INQ_HANDLE*);
+RPC_STATUS RpcMgmtEpEltInqDone(RPC_EP_INQ_HANDLE*);
+RPC_STATUS RpcMgmtEpUnregister(RPC_BINDING_HANDLE, RPC_IF_ID*, RPC_BINDING_HANDLE, UUID*);
+RPC_STATUS RpcMgmtSetAuthorizationFn(RPC_MGMT_AUTHORIZATION_FN);
+RPC_STATUS RpcMgmtInqParameter(uint, uint*);
+RPC_STATUS RpcMgmtSetParameter(uint, uint);
+RPC_STATUS RpcMgmtBindingInqParameter(RPC_BINDING_HANDLE, uint, uint*);
+RPC_STATUS RpcMgmtBindingSetParameter(RPC_BINDING_HANDLE, uint, uint);
+
+//static if (_WIN32_WINNT >= 0x500) {
+    RPC_STATUS UuidCreateSequential(UUID*);
+//}
diff --git a/libphobos/libdruntime/core/sys/windows/rpcdce2.d b/libphobos/libdruntime/core/sys/windows/rpcdce2.d
new file mode 100644
index 00000000000..1d7312adf73
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/rpcdce2.d
@@ -0,0 +1,80 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_rpcdce2.d)
+ */
+module core.sys.windows.rpcdce2;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+import core.sys.windows.rpcdce;
+private import core.sys.windows.basetyps;
+
+// FIXME: deal with RPC_UNICODE_SUPPORTED
+// FIXME: check types of constants
+
+enum {
+    RPC_C_EP_ALL_ELTS,
+    RPC_C_EP_MATCH_BY_IF,
+    RPC_C_EP_MATCH_BY_OBJ,
+    RPC_C_EP_MATCH_BY_BOTH
+}
+
+enum {
+    RPC_C_VERS_ALL = 1,
+    RPC_C_VERS_COMPATIBLE,
+    RPC_C_VERS_EXACT,
+    RPC_C_VERS_MAJOR_ONLY,
+    RPC_C_VERS_UPTO
+}
+
+enum size_t DCE_C_ERROR_STRING_LEN = 256;
+
+enum {
+    RPC_C_MGMT_INQ_IF_IDS,
+    RPC_C_MGMT_INQ_PRINC_NAME,
+    RPC_C_MGMT_INQ_STATS,
+    RPC_C_MGMT_IS_SERVER_LISTEN,
+    RPC_C_MGMT_STOP_SERVER_LISTEN
+}
+
+extern (Windows) {
+    int UuidCompare(UUID*, UUID*, RPC_STATUS*);
+    RPC_STATUS UuidCreateNil(UUID*);
+    int UuidEqual(UUID*, UUID*, RPC_STATUS*);
+    ushort UuidHash(UUID*, RPC_STATUS*);
+    int UuidIsNil(UUID*, RPC_STATUS*);
+
+    RPC_STATUS RpcMgmtEpEltInqBegin(RPC_BINDING_HANDLE, uint, RPC_IF_ID*,
+      uint, UUID*, RPC_EP_INQ_HANDLE*);
+    RPC_STATUS RpcMgmtEpEltInqDone(RPC_EP_INQ_HANDLE*);
+    RPC_STATUS RpcMgmtEpUnregister(RPC_BINDING_HANDLE, RPC_IF_ID*,
+      RPC_BINDING_HANDLE, UUID*);
+    RPC_STATUS RpcMgmtSetAuthorizationFn(RPC_MGMT_AUTHORIZATION_FN);
+}
+
+
+//#ifdef RPC_UNICODE_SUPPORTED
+RPC_STATUS DceErrorInqTextA(RPC_STATUS, char*);
+RPC_STATUS DceErrorInqTextW(RPC_STATUS, wchar*);
+RPC_STATUS RpcMgmtEpEltInqNextA(RPC_EP_INQ_HANDLE, RPC_IF_ID*,
+  RPC_BINDING_HANDLE*, UUID*, char**);
+RPC_STATUS RpcMgmtEpEltInqNextW(RPC_EP_INQ_HANDLE, RPC_IF_ID*,
+  RPC_BINDING_HANDLE*, UUID*, wchar**);
+version (Unicode) {
+    alias RpcMgmtEpEltInqNextW RpcMgmtEpEltInqNext;
+    alias DceErrorInqTextW DceErrorInqText;
+} else {
+    alias RpcMgmtEpEltInqNextA RpcMgmtEpEltInqNext;
+    alias DceErrorInqTextA DceErrorInqText;
+}
+/+
+#else /* RPC_UNICODE_SUPPORTED */
+    RPC_STATUS RPC_ENTRY DceErrorInqText(RPC_STATUS,unsigned char*);
+    RPC_STATUS RPC_ENTRY RpcMgmtEpEltInqNext(RPC_EP_INQ_HANDLE,RPC_IF_ID*,RPC_BINDING_HANDLE*,UUID*,unsigned char**);
+#endif
++/
diff --git a/libphobos/libdruntime/core/sys/windows/rpcdcep.d b/libphobos/libdruntime/core/sys/windows/rpcdcep.d
new file mode 100644
index 00000000000..90e7c11aaca
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/rpcdcep.d
@@ -0,0 +1,153 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_rpcdcep.d)
+ */
+module core.sys.windows.rpcdcep;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.basetyps;
+private import core.sys.windows.w32api;
+private import core.sys.windows.windef;
+
+mixin DECLARE_HANDLE!("I_RPC_HANDLE");
+alias long RPC_STATUS;
+
+enum RPC_NCA_FLAGS_DEFAULT=0;
+enum RPC_NCA_FLAGS_IDEMPOTENT=1;
+enum RPC_NCA_FLAGS_BROADCAST=2;
+enum RPC_NCA_FLAGS_MAYBE=4;
+enum RPCFLG_ASYNCHRONOUS=0x40000000;
+enum RPCFLG_INPUT_SYNCHRONOUS=0x20000000;
+enum RPC_FLAGS_VALID_BIT=0x8000;
+
+enum TRANSPORT_TYPE_CN=1;
+enum TRANSPORT_TYPE_DG=2;
+enum TRANSPORT_TYPE_LPC=4;
+enum TRANSPORT_TYPE_WMSG=8;
+
+struct RPC_VERSION {
+    ushort MajorVersion;
+    ushort MinorVersion;
+}
+struct RPC_SYNTAX_IDENTIFIER {
+    GUID        SyntaxGUID;
+    RPC_VERSION SyntaxVersion;
+}
+alias RPC_SYNTAX_IDENTIFIER* PRPC_SYNTAX_IDENTIFIER;
+
+struct RPC_MESSAGE {
+    HANDLE Handle;
+    uint  DataRepresentation;
+    void* Buffer;
+    uint  BufferLength;
+    uint  ProcNum;
+    PRPC_SYNTAX_IDENTIFIER TransferSyntax;
+    void* RpcInterfaceInformation;
+    void* ReservedForRuntime;
+    void* ManagerEpv;
+    void* ImportContext;
+    uint  RpcFlags;
+}
+alias RPC_MESSAGE* PRPC_MESSAGE;
+
+extern (Windows) {
+alias void function (PRPC_MESSAGE Message) RPC_DISPATCH_FUNCTION;
+}
+
+struct RPC_DISPATCH_TABLE {
+    uint DispatchTableCount;
+    RPC_DISPATCH_FUNCTION* DispatchTable;
+    int  Reserved;
+}
+alias RPC_DISPATCH_TABLE* PRPC_DISPATCH_TABLE;
+
+struct RPC_PROTSEQ_ENDPOINT {
+    ubyte* RpcProtocolSequence;
+    ubyte* Endpoint;
+}
+alias RPC_PROTSEQ_ENDPOINT* PRPC_PROTSEQ_ENDPOINT;
+
+struct RPC_SERVER_INTERFACE {
+    uint                  Length;
+    RPC_SYNTAX_IDENTIFIER InterfaceId;
+    RPC_SYNTAX_IDENTIFIER TransferSyntax;
+    PRPC_DISPATCH_TABLE   DispatchTable;
+    uint                  RpcProtseqEndpointCount;
+    PRPC_PROTSEQ_ENDPOINT RpcProtseqEndpoint;
+    void*                 DefaultManagerEpv;
+const(void)*          InterpreterInfo;
+}
+alias RPC_SERVER_INTERFACE* PRPC_SERVER_INTERFACE;
+
+struct RPC_CLIENT_INTERFACE {
+    uint                  Length;
+    RPC_SYNTAX_IDENTIFIER InterfaceId;
+    RPC_SYNTAX_IDENTIFIER TransferSyntax;
+    PRPC_DISPATCH_TABLE   DispatchTable;
+    uint                  RpcProtseqEndpointCount;
+    PRPC_PROTSEQ_ENDPOINT RpcProtseqEndpoint;
+    uint                  Reserved;
+const(void)*          InterpreterInfo;
+}
+alias RPC_CLIENT_INTERFACE* PRPC_CLIENT_INTERFACE;
+
+alias TypeDef!(void*) I_RPC_MUTEX;
+
+struct RPC_TRANSFER_SYNTAX {
+    GUID   Uuid;
+    ushort VersMajor;
+    ushort VersMinor;
+}
+alias RPC_STATUS function(void*, void*, void*) RPC_BLOCKING_FN;
+
+extern (Windows) {
+    alias void function(void*) PRPC_RUNDOWN;
+
+    int    I_RpcGetBuffer(RPC_MESSAGE*);
+    int    I_RpcSendReceive(RPC_MESSAGE*);
+    int    I_RpcSend(RPC_MESSAGE*);
+    int    I_RpcFreeBuffer(RPC_MESSAGE*);
+    void   I_RpcRequestMutex(I_RPC_MUTEX*);
+    void   I_RpcClearMutex(I_RPC_MUTEX);
+    void   I_RpcDeleteMutex(I_RPC_MUTEX);
+    void*  I_RpcAllocate(uint);
+    void   I_RpcFree(void*);
+    void   I_RpcPauseExecution(uint);
+    int    I_RpcMonitorAssociation(HANDLE, PRPC_RUNDOWN, void*);
+    int    I_RpcStopMonitorAssociation(HANDLE);
+    HANDLE I_RpcGetCurrentCallHandle();
+    int    I_RpcGetAssociationContext(void**);
+    int    I_RpcSetAssociationContext(void*);
+    int    I_RpcNsBindingSetEntryName(HANDLE, uint, wchar*);
+    int    I_RpcBindingInqDynamicEndpoint(HANDLE, wchar**);
+    int    I_RpcBindingInqTransportType(HANDLE, uint*);
+    int    I_RpcIfInqTransferSyntaxes(HANDLE, RPC_TRANSFER_SYNTAX*, uint,
+             uint*);
+    int    I_UuidCreate(GUID*);
+    int    I_RpcBindingCopy(HANDLE, HANDLE*);
+    int    I_RpcBindingIsClientLocal(HANDLE, uint*);
+    void   I_RpcSsDontSerializeContext();
+    int    I_RpcServerRegisterForwardFunction(int function (GUID*,
+             RPC_VERSION*, GUID*, ubyte*, void**));
+    int    I_RpcConnectionInqSockBuffSize(uint*, uint*);
+    int    I_RpcConnectionSetSockBuffSize(uint, uint);
+    int    I_RpcBindingSetAsync(HANDLE, RPC_BLOCKING_FN);
+    int    I_RpcAsyncSendReceive(RPC_MESSAGE*, void*);
+    int    I_RpcGetThreadWindowHandle(void**);
+    int    I_RpcServerThreadPauseListening();
+    int    I_RpcServerThreadContinueListening();
+    int    I_RpcServerUnregisterEndpointA(ubyte*, ubyte*);
+    int    I_RpcServerUnregisterEndpointW(ushort*, ushort*);
+}
+
+version(Unicode) {
+    alias I_RpcServerUnregisterEndpointW I_RpcServerUnregisterEndpoint;
+} else {
+    alias I_RpcServerUnregisterEndpointA I_RpcServerUnregisterEndpoint;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/rpcndr.d b/libphobos/libdruntime/core/sys/windows/rpcndr.d
new file mode 100644
index 00000000000..0ab2159b8b0
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/rpcndr.d
@@ -0,0 +1,573 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_rpcndr.d)
+ */
+module core.sys.windows.rpcndr;
+version (Windows):
+pragma(lib, "rpcrt4");
+
+/* Translation notes:
+ RPC_CLIENT_ALLOC*, RPC_CLIENT_FREE* were replaced with PRPC_CLIENT_ALLOC, PRPC_CLIENT_FREE
+*/
+
+// TODO: Bitfields in MIDL_STUB_MESSAGE.
+//       Macros need to be converted.
+enum __RPCNDR_H_VERSION__= 450;
+
+import core.sys.windows.rpcnsip;
+private import core.sys.windows.rpc, core.sys.windows.rpcdce, core.sys.windows.unknwn, core.sys.windows.windef;
+private import core.sys.windows.objidl; // for IRpcChannelBuffer, IRpcStubBuffer
+private import core.sys.windows.basetyps;
+
+extern (Windows):
+
+enum uint NDR_CHAR_REP_MASK      = 0xF,
+    NDR_INT_REP_MASK              = 0xF0,
+    NDR_FLOAT_REP_MASK            = 0xFF00,
+    NDR_LITTLE_ENDIAN             = 0x10,
+    NDR_BIG_ENDIAN                = 0,
+    NDR_IEEE_FLOAT                = 0,
+    NDR_VAX_FLOAT                 = 0x100,
+    NDR_ASCII_CHAR                = 0,
+    NDR_EBCDIC_CHAR               = 1,
+    NDR_LOCAL_DATA_REPRESENTATION = 0x10,
+    NDR_LOCAL_ENDIAN              = NDR_LITTLE_ENDIAN;
+
+alias MIDL_user_allocate midl_user_allocate;
+alias MIDL_user_free midl_user_free;
+
+alias long hyper;
+alias ulong MIDL_uhyper;
+alias char small;
+
+enum cbNDRContext=20;
+//MACRO #define NDRSContextValue(hContext) (&(hContext)->userContext)
+//MACRO #define byte_from_ndr(source, target) { *(target) = *(*(char**)&(source)->Buffer)++; }
+
+//MACRO #define byte_array_from_ndr(Source, LowerIndex, UpperIndex, Target) { NDRcopy ((((char *)(Target))+(LowerIndex)), (Source)->Buffer, (unsigned int)((UpperIndex)-(LowerIndex))); *(unsigned long *)&(Source)->Buffer += ((UpperIndex)-(LowerIndex)); }
+
+//MACRO #define boolean_from_ndr(source, target) { *(target) = *(*(char**)&(source)->Buffer)++; }
+
+//MACRO #define boolean_array_from_ndr(Source, LowerIndex, UpperIndex, Target) { NDRcopy ((((char *)(Target))+(LowerIndex)), (Source)->Buffer, (unsigned int)((UpperIndex)-(LowerIndex))); *(unsigned long *)&(Source)->Buffer += ((UpperIndex)-(LowerIndex)); }
+
+//MACRO #define small_from_ndr(source, target) { *(target) = *(*(char**)&(source)->Buffer)++; }
+
+//MACRO #define small_from_ndr_temp(source, target, format) { *(target) = *(*(char**)(source))++; }
+
+//MACRO #define small_array_from_ndr(Source, LowerIndex, UpperIndex, Target) { NDRcopy ((((char *)(Target))+(LowerIndex)), (Source)->Buffer, (unsigned int)((UpperIndex)-(LowerIndex))); *(unsigned long *)&(Source)->Buffer += ((UpperIndex)-(LowerIndex)); }
+
+//MACRO #define MIDL_ascii_strlen(string) strlen(string)
+
+//MACRO #define MIDL_ascii_strcpy(target,source) strcpy(target,source)
+
+//MACRO #define MIDL_memset(s,c,n) memset(s,c,n)
+
+//MACRO #define _midl_ma1( p, cast ) *(*( cast **)&p)++
+//MACRO #define _midl_ma2( p, cast ) *(*( cast **)&p)++
+//MACRO #define _midl_ma4( p, cast ) *(*( cast **)&p)++
+//MACRO #define _midl_ma8( p, cast ) *(*( cast **)&p)++
+//MACRO #define _midl_unma1( p, cast ) *(( cast *)p)++
+//MACRO #define _midl_unma2( p, cast ) *(( cast *)p)++
+//MACRO #define _midl_unma3( p, cast ) *(( cast *)p)++
+//MACRO #define _midl_unma4( p, cast ) *(( cast *)p)++
+//MACRO #define _midl_fa2( p ) (p = (RPC_BUFPTR )((unsigned long)(p+1) & 0xfffffffe))
+//MACRO #define _midl_fa4( p ) (p = (RPC_BUFPTR )((unsigned long)(p+3) & 0xfffffffc))
+//MACRO #define _midl_fa8( p ) (p = (RPC_BUFPTR )((unsigned long)(p+7) & 0xfffffff8))
+//MACRO #define _midl_addp( p, n ) (p += n)
+//MACRO #define _midl_marsh_lhs( p, cast ) *(*( cast **)&p)++
+//MACRO #define _midl_marsh_up( mp, p ) *(*(unsigned long **)&mp)++ = (unsigned long)p
+//MACRO #define _midl_advmp( mp ) *(*(unsigned long **)&mp)++
+//MACRO #define _midl_unmarsh_up( p ) (*(*(unsigned long **)&p)++)
+
+//MACRO #define NdrMarshConfStringHdr( p, s, l ) (_midl_ma4( p, unsigned long) = s, _midl_ma4( p, unsigned long) = 0, _midl_ma4( p, unsigned long) = l)
+
+//MACRO #define NdrUnMarshConfStringHdr(p, s, l) ((s=_midl_unma4(p,unsigned long), (_midl_addp(p,4)), (l=_midl_unma4(p,unsigned long))
+
+//MACRO #define NdrMarshCCtxtHdl(pc,p) (NDRCContextMarshall( (NDR_CCONTEXT)pc, p ),p+20)
+//MACRO #define NdrUnMarshCCtxtHdl(pc,p,h,drep) (NDRCContextUnmarshall((NDR_CONTEXT)pc,h,p,drep), p+20)
+//MACRO #define NdrUnMarshSCtxtHdl(pc, p,drep) (pc = NdrSContextUnMarshall(p,drep ))
+//MACRO #define NdrMarshSCtxtHdl(pc,p,rd) (NdrSContextMarshall((NDR_SCONTEXT)pc,p, (NDR_RUNDOWN)rd)
+
+//MACRO #define NdrFieldOffset(s,f) (long)(& (((s *)0)->f))
+//MACRO #define NdrFieldPad(s,f,p,t) (NdrFieldOffset(s,f) - NdrFieldOffset(s,p) - sizeof(t))
+//MACRO #define NdrFcShort(s) (unsigned char)(s & 0xff), (unsigned char)(s >> 8)
+//MACRO #define NdrFcLong(s) (unsigned char)(s & 0xff), (unsigned char)((s & 0x0000ff00) >> 8), (unsigned char)((s & 0x00ff0000) >> 16), (unsigned char)(s >> 24)
+
+alias void * NDR_CCONTEXT;
+struct tagNDR_SCONTEXT {
+    void*[2] pad;
+    void *userContext;
+}
+alias tagNDR_SCONTEXT * NDR_SCONTEXT;
+
+struct SCONTEXT_QUEUE {
+    uint NumberOfObjects;
+    NDR_SCONTEXT *ArrayOfObjects;
+}
+alias SCONTEXT_QUEUE * PSCONTEXT_QUEUE;
+
+struct _MIDL_STUB_MESSAGE;
+struct _MIDL_STUB_DESC;
+struct _FULL_PTR_XLAT_TABLES;
+
+alias ubyte *RPC_BUFPTR;
+alias uint RPC_LENGTH;
+
+alias const(char)* PFORMAT_STRING;
+
+struct ARRAY_INFO {
+    int Dimension;
+    uint *BufferConformanceMark;
+    uint *BufferVarianceMark;
+    uint *MaxCountArray;
+    uint *OffsetArray;
+    uint *ActualCountArray;
+}
+alias ARRAY_INFO * PARRAY_INFO;
+
+RPC_BINDING_HANDLE  NDRCContextBinding(NDR_CCONTEXT);
+void  NDRCContextMarshall(NDR_CCONTEXT,void*);
+void  NDRCContextUnmarshall(NDR_CCONTEXT*,RPC_BINDING_HANDLE,void*,uint);
+void  NDRSContextMarshall(NDR_SCONTEXT,void*,NDR_RUNDOWN);
+NDR_SCONTEXT  NDRSContextUnmarshall(void*pBuff,uint);
+void  RpcSsDestroyClientContext(void**);
+void  NDRcopy(void*,void*,uint);
+uint  MIDL_wchar_strlen(wchar *);
+void  MIDL_wchar_strcpy(void*,wchar *);
+void  char_from_ndr(PRPC_MESSAGE,ubyte*);
+void  char_array_from_ndr(PRPC_MESSAGE,uint,uint,ubyte*);
+void  short_from_ndr(PRPC_MESSAGE,ushort*);
+void  short_array_from_ndr(PRPC_MESSAGE,uint,uint,ushort*);
+void  short_from_ndr_temp(ubyte**,ushort*,uint);
+void  int_from_ndr(PRPC_MESSAGE,uint*);
+void  int_array_from_ndr(PRPC_MESSAGE,uint,uint,uint*);
+void  int_from_ndr_temp(ubyte**,uint*,uint);
+void  enum_from_ndr(PRPC_MESSAGE,uint*);
+void  float_from_ndr(PRPC_MESSAGE,void*);
+void  float_array_from_ndr(PRPC_MESSAGE,uint,uint,void*);
+void  double_from_ndr(PRPC_MESSAGE,void*);
+void  double_array_from_ndr(PRPC_MESSAGE,uint,uint,void*);
+void  hyper_from_ndr(PRPC_MESSAGE,hyper*);
+void  hyper_array_from_ndr(PRPC_MESSAGE,uint,uint,hyper*);
+void  hyper_from_ndr_temp(ubyte**,hyper*,uint);
+void  data_from_ndr(PRPC_MESSAGE,void*,char*,ubyte);
+void  data_into_ndr(void*,PRPC_MESSAGE,char*,ubyte);
+void  tree_into_ndr(void*,PRPC_MESSAGE,char*,ubyte);
+void  data_size_ndr(void*,PRPC_MESSAGE,char*,ubyte);
+void  tree_size_ndr(void*,PRPC_MESSAGE,char*,ubyte);
+void  tree_peek_ndr(PRPC_MESSAGE,ubyte**,char*,ubyte);
+void * midl_allocate(int);
+
+align(4):
+struct MIDL_STUB_MESSAGE {
+    PRPC_MESSAGE RpcMsg;
+    ubyte *Buffer;
+    ubyte *BufferStart;
+    ubyte *BufferEnd;
+    ubyte *BufferMark;
+    uint BufferLength;
+    uint MemorySize;
+    ubyte *Memory;
+    int IsClient;
+    int ReuseBuffer;
+    ubyte *AllocAllNodesMemory;
+    ubyte *AllocAllNodesMemoryEnd;
+    int IgnoreEmbeddedPointers;
+    ubyte *PointerBufferMark;
+    ubyte fBufferValid;
+    ubyte Unused;
+    uint MaxCount;
+    uint Offset;
+    uint ActualCount;
+    void* function (uint) pfnAllocate;
+    void function (void*) pfnFree;
+    ubyte * StackTop;
+    ubyte * pPresentedType;
+    ubyte * pTransmitType;
+    handle_t SavedHandle;
+const(_MIDL_STUB_DESC)* StubDesc;
+    _FULL_PTR_XLAT_TABLES *FullPtrXlatTables;
+    uint FullPtrRefId;
+    int fCheckBounds;
+    // FIXME:
+    byte bit_fields_for_D; // FIXME: Bitfields
+//  int fInDontFree :1;
+//  int fDontCallFreeInst :1;
+//  int fInOnlyParam :1;
+//  int fHasReturn :1;
+    uint dwDestContext;
+    void* pvDestContext;
+    NDR_SCONTEXT * SavedContextHandles;
+    int ParamNumber;
+    IRpcChannelBuffer  pRpcChannelBuffer;
+    PARRAY_INFO pArrayInfo;
+    uint * SizePtrCountArray;
+    uint * SizePtrOffsetArray;
+    uint * SizePtrLengthArray;
+    void* pArgQueue;
+    uint dwStubPhase;
+    uint[5] w2kReserved;
+}
+alias MIDL_STUB_MESSAGE * PMIDL_STUB_MESSAGE;
+
+extern (Windows) {
+    alias void* function (void*) GENERIC_BINDING_ROUTINE;
+    alias void function (void*,ubyte*) GENERIC_UNBIND_ROUTINE;
+    alias uint function (uint *,uint,void *) USER_MARSHAL_SIZING_ROUTINE;
+    alias ubyte * function (uint *,ubyte *,void *) USER_MARSHAL_MARSHALLING_ROUTINE;
+    alias ubyte * function (uint *,ubyte *,void *) USER_MARSHAL_UNMARSHALLING_ROUTINE;
+    alias void function (uint *,void *) USER_MARSHAL_FREEING_ROUTINE;
+    alias void function () NDR_NOTIFY_ROUTINE;
+}
+
+align:
+struct GENERIC_BINDING_ROUTINE_PAIR {
+    GENERIC_BINDING_ROUTINE pfnBind;
+    GENERIC_UNBIND_ROUTINE pfnUnbind;
+}
+alias GENERIC_BINDING_ROUTINE_PAIR * PGENERIC_BINDING_ROUTINE_PAIR;
+
+struct GENERIC_BINDING_INFO {
+    void *pObj;
+    uint Size;
+    GENERIC_BINDING_ROUTINE pfnBind;
+    GENERIC_UNBIND_ROUTINE pfnUnbind;
+}
+alias GENERIC_BINDING_INFO * PGENERIC_BINDING_INFO;
+
+
+struct XMIT_ROUTINE_QUINTUPLE {
+    XMIT_HELPER_ROUTINE pfnTranslateToXmit;
+    XMIT_HELPER_ROUTINE pfnTranslateFromXmit;
+    XMIT_HELPER_ROUTINE pfnFreeXmit;
+    XMIT_HELPER_ROUTINE pfnFreeInst;
+}
+alias XMIT_ROUTINE_QUINTUPLE * PXMIT_ROUTINE_QUINTUPLE;
+
+struct MALLOC_FREE_STRUCT {
+    void* function (uint) pfnAllocate;
+    void function (void*) pfnFree;
+}
+
+struct COMM_FAULT_OFFSETS {
+    short CommOffset;
+    short FaultOffset;
+}
+
+struct USER_MARSHAL_ROUTINE_QUADRUPLE {
+    USER_MARSHAL_SIZING_ROUTINE pfnBufferSize;
+    USER_MARSHAL_MARSHALLING_ROUTINE pfnMarshall;
+    USER_MARSHAL_UNMARSHALLING_ROUTINE pfnUnmarshall;
+    USER_MARSHAL_FREEING_ROUTINE pfnFree;
+}
+
+enum IDL_CS_CONVERT {
+    IDL_CS_NO_CONVERT,
+    IDL_CS_IN_PLACE_CONVERT,
+    IDL_CS_NEW_BUFFER_CONVERT
+}
+
+struct NDR_CS_SIZE_CONVERT_ROUTINES {
+    CS_TYPE_NET_SIZE_ROUTINE pfnNetSize;
+    CS_TYPE_TO_NETCS_ROUTINE pfnToNetCs;
+    CS_TYPE_LOCAL_SIZE_ROUTINE pfnLocalSize;
+    CS_TYPE_FROM_NETCS_ROUTINE pfnFromNetCs;
+}
+
+struct NDR_CS_ROUTINES {
+    NDR_CS_SIZE_CONVERT_ROUTINES *pSizeConvertRoutines;
+    CS_TAG_GETTING_ROUTINE *pTagGettingRoutines;
+}
+
+struct MIDL_STUB_DESC {
+    void* RpcInterfaceInformation;
+    void* function(uint) pfnAllocate;
+    void function (void*) pfnFree;
+    union _IMPLICIT_HANDLE_INFO {
+        handle_t *pAutoHandle;
+        handle_t *pPrimitiveHandle;
+        PGENERIC_BINDING_INFO pGenericBindingInfo;
+    }
+    _IMPLICIT_HANDLE_INFO IMPLICIT_HANDLE_INFO;
+const(NDR_RUNDOWN)* apfnNdrRundownRoutines;
+const(GENERIC_BINDING_ROUTINE_PAIR)* aGenericBindingRoutinePairs;
+const(EXPR_EVAL)* apfnExprEval;
+const(XMIT_ROUTINE_QUINTUPLE)* aXmitQuintuple;
+const(char)* *pFormatTypes;
+    int fCheckBounds;
+    uint Version;
+    MALLOC_FREE_STRUCT *pMallocFreeStruct;
+    int MIDLVersion;
+const(COMM_FAULT_OFFSETS)* CommFaultOffsets;
+const(USER_MARSHAL_ROUTINE_QUADRUPLE)* aUserMarshalQuadruple;
+const(NDR_NOTIFY_ROUTINE)* NotifyRoutineTable;
+    ULONG_PTR mFlags;
+const(NDR_CS_ROUTINES)* CsRoutineTables;
+    void *Reserved4;
+    ULONG_PTR Reserved5;
+}
+alias const(MIDL_STUB_DESC)* PMIDL_STUB_DESC;
+
+alias void * PMIDL_XMIT_TYPE;
+
+struct MIDL_FORMAT_STRING {
+    short Pad;
+    ubyte[1] Format;
+}
+
+struct MIDL_SERVER_INFO {
+    PMIDL_STUB_DESC pStubDesc;
+const(SERVER_ROUTINE)* DispatchTable;
+    PFORMAT_STRING ProcString;
+const(ushort)* FmtStringOffset;
+const(STUB_THUNK)* ThunkTable;
+}
+alias MIDL_SERVER_INFO * PMIDL_SERVER_INFO;
+
+struct MIDL_STUBLESS_PROXY_INFO {
+    PMIDL_STUB_DESC pStubDesc;
+    PFORMAT_STRING ProcFormatString;
+const(ushort)* FormatStringOffset;
+}
+alias MIDL_STUBLESS_PROXY_INFO *PMIDL_STUBLESS_PROXY_INFO;
+
+union CLIENT_CALL_RETURN {
+    void *Pointer;
+    int Simple;
+}
+
+enum XLAT_SIDE {
+    XLAT_SERVER = 1,
+    XLAT_CLIENT
+}
+struct FULL_PTR_TO_REFID_ELEMENT {
+    FULL_PTR_TO_REFID_ELEMENT * Next;
+    void* Pointer;
+    uint RefId;
+    ubyte State;
+}
+alias FULL_PTR_TO_REFID_ELEMENT * PFULL_PTR_TO_REFID_ELEMENT;
+
+struct FULL_PTR_XLAT_TABLES {
+    struct RefIdToPointer {
+        void **XlatTable;
+        ubyte *StateTable;
+        uint NumberOfEntries;
+    }
+    struct PointerToRefId {
+        PFULL_PTR_TO_REFID_ELEMENT *XlatTable;
+        uint NumberOfBuckets;
+        uint HashMask;
+    }
+    uint NextRefId;
+    XLAT_SIDE XlatSide;
+}
+alias FULL_PTR_XLAT_TABLES * PFULL_PTR_XLAT_TABLES;
+
+
+enum STUB_PHASE {
+    STUB_UNMARSHAL,
+    STUB_CALL_SERVER,
+    STUB_MARSHAL,
+    STUB_CALL_SERVER_NO_HRESULT
+}
+
+enum PROXY_PHASE {
+    PROXY_CALCSIZE,
+    PROXY_GETBUFFER,
+    PROXY_MARSHAL,
+    PROXY_SENDRECEIVE,
+    PROXY_UNMARSHAL
+}
+
+alias TypeDef!(void *) RPC_SS_THREAD_HANDLE;
+
+extern (Windows) {
+alias void function (void*) NDR_RUNDOWN;
+alias void function (_MIDL_STUB_MESSAGE*) EXPR_EVAL;
+alias void function(PMIDL_STUB_MESSAGE) XMIT_HELPER_ROUTINE;
+alias void function (RPC_BINDING_HANDLE,uint,uint,IDL_CS_CONVERT*,uint*,error_status_t*) CS_TYPE_NET_SIZE_ROUTINE;
+alias void function (RPC_BINDING_HANDLE,uint,uint,IDL_CS_CONVERT*,uint*,error_status_t*) CS_TYPE_LOCAL_SIZE_ROUTINE;
+alias void function (RPC_BINDING_HANDLE,uint,void*,uint,byte*,uint*,error_status_t*) CS_TYPE_TO_NETCS_ROUTINE;
+alias void function (RPC_BINDING_HANDLE,uint,byte*,uint,uint,void*,uint*,error_status_t*) CS_TYPE_FROM_NETCS_ROUTINE;
+alias void function (RPC_BINDING_HANDLE,int,uint*,uint*,uint*,error_status_t*) CS_TAG_GETTING_ROUTINE;
+
+//alias void* RPC_CLIENT_ALLOC(uint);
+//alias void RPC_CLIENT_FREE(void*);
+alias void* function(uint) PRPC_CLIENT_ALLOC;
+alias void function(void*) PRPC_CLIENT_FREE;
+
+    alias void function (PMIDL_STUB_MESSAGE) STUB_THUNK;
+    alias int function() SERVER_ROUTINE;
+}
+
+void  NdrSimpleTypeMarshall(PMIDL_STUB_MESSAGE,ubyte*,ubyte);
+ubyte * NdrPointerMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING pFormat);
+ubyte * NdrSimpleStructMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrConformantStructMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrConformantVaryingStructMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrHardStructMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrComplexStructMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrFixedArrayMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrConformantArrayMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrConformantVaryingArrayMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrVaryingArrayMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrComplexArrayMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrNonConformantStringMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrConformantStringMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrNonEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrByteCountPointerMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrXmitOrRepAsMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte * NdrInterfacePointerMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrClientContextMarshall(PMIDL_STUB_MESSAGE,NDR_CCONTEXT,int);
+void  NdrServerContextMarshall(PMIDL_STUB_MESSAGE,NDR_SCONTEXT,NDR_RUNDOWN);
+void  NdrSimpleTypeUnmarshall(PMIDL_STUB_MESSAGE,ubyte*,ubyte);
+ubyte * NdrPointerUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrSimpleStructUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrConformantVaryingStructUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrHardStructUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrFixedArrayUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrConformantArrayUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrConformantVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrNonConformantStringUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrConformantStringUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrNonEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrByteCountPointerUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrXmitOrRepAsUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+ubyte * NdrInterfacePointerUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+void  NdrClientContextUnmarshall(PMIDL_STUB_MESSAGE,NDR_CCONTEXT*,RPC_BINDING_HANDLE);
+NDR_SCONTEXT  NdrServerContextUnmarshall(PMIDL_STUB_MESSAGE);
+void  NdrPointerBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrConformantVaryingStructBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrHardStructBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrFixedArrayBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrConformantVaryingArrayBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrVaryingArrayBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrNonConformantStringBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrXmitOrRepAsBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrInterfacePointerBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrContextHandleSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+uint  NdrPointerMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrSimpleStructMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrConformantStructMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrConformantVaryingStructMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrHardStructMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrComplexStructMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrFixedArrayMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrConformantArrayMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrConformantVaryingArrayMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrVaryingArrayMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrComplexArrayMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrConformantStringMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrNonConformantStringMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrNonEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrXmitOrRepAsMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+uint  NdrInterfacePointerMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+void  NdrPointerFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrSimpleStructFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrConformantStructFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrConformantVaryingStructFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrHardStructFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrComplexStructFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrFixedArrayFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrConformantArrayFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrConformantVaryingArrayFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrVaryingArrayFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrComplexArrayFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrEncapsulatedUnionFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrNonEncapsulatedUnionFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrByteCountPointerFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrXmitOrRepAsFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrInterfacePointerFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+void  NdrConvert(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+void  NdrClientInitializeNew(PRPC_MESSAGE,PMIDL_STUB_MESSAGE,PMIDL_STUB_DESC,uint);
+ubyte * NdrServerInitializeNew(PRPC_MESSAGE,PMIDL_STUB_MESSAGE,PMIDL_STUB_DESC);
+void  NdrClientInitialize(PRPC_MESSAGE,PMIDL_STUB_MESSAGE,PMIDL_STUB_DESC,uint);
+ubyte * NdrServerInitialize(PRPC_MESSAGE,PMIDL_STUB_MESSAGE,PMIDL_STUB_DESC);
+ubyte * NdrServerInitializeUnmarshall(PMIDL_STUB_MESSAGE,PMIDL_STUB_DESC,PRPC_MESSAGE);
+void  NdrServerInitializeMarshall(PRPC_MESSAGE,PMIDL_STUB_MESSAGE);
+ubyte * NdrGetBuffer(PMIDL_STUB_MESSAGE,uint,RPC_BINDING_HANDLE);
+ubyte * NdrNsGetBuffer(PMIDL_STUB_MESSAGE,uint,RPC_BINDING_HANDLE);
+ubyte * NdrSendReceive(PMIDL_STUB_MESSAGE,ubyte*);
+ubyte * NdrNsSendReceive(PMIDL_STUB_MESSAGE,ubyte*,RPC_BINDING_HANDLE*);
+void  NdrFreeBuffer(PMIDL_STUB_MESSAGE);
+
+CLIENT_CALL_RETURN  NdrClientCall(PMIDL_STUB_DESC,PFORMAT_STRING,...);
+
+int  NdrStubCall(IRpcStubBuffer, IRpcChannelBuffer,PRPC_MESSAGE,uint*);
+void  NdrServerCall(PRPC_MESSAGE);
+int  NdrServerUnmarshall(IRpcChannelBuffer, PRPC_MESSAGE,PMIDL_STUB_MESSAGE,PMIDL_STUB_DESC,PFORMAT_STRING,void*);
+void  NdrServerMarshall(IRpcStubBuffer, IRpcChannelBuffer,PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+RPC_STATUS  NdrMapCommAndFaultStatus(PMIDL_STUB_MESSAGE,uint*,uint*,RPC_STATUS);
+int  NdrSH_UPDecision(PMIDL_STUB_MESSAGE,ubyte**,RPC_BUFPTR);
+int  NdrSH_TLUPDecision(PMIDL_STUB_MESSAGE,ubyte**);
+int  NdrSH_TLUPDecisionBuffer(PMIDL_STUB_MESSAGE,ubyte**);
+int  NdrSH_IfAlloc(PMIDL_STUB_MESSAGE,ubyte**,uint);
+int  NdrSH_IfAllocRef(PMIDL_STUB_MESSAGE,ubyte**,uint);
+int  NdrSH_IfAllocSet(PMIDL_STUB_MESSAGE,ubyte**,uint);
+RPC_BUFPTR  NdrSH_IfCopy(PMIDL_STUB_MESSAGE,ubyte**,uint);
+RPC_BUFPTR  NdrSH_IfAllocCopy(PMIDL_STUB_MESSAGE,ubyte**,uint);
+uint  NdrSH_Copy(ubyte*,ubyte*,uint);
+void  NdrSH_IfFree(PMIDL_STUB_MESSAGE,ubyte*);
+RPC_BUFPTR  NdrSH_StringMarshall(PMIDL_STUB_MESSAGE,ubyte*,uint,int);
+RPC_BUFPTR  NdrSH_StringUnMarshall(PMIDL_STUB_MESSAGE,ubyte**,int);
+void* RpcSsAllocate(uint);
+void  RpcSsDisableAllocate();
+void  RpcSsEnableAllocate();
+void  RpcSsFree(void*);
+RPC_SS_THREAD_HANDLE  RpcSsGetThreadHandle();
+void  RpcSsSetClientAllocFree(PRPC_CLIENT_ALLOC,PRPC_CLIENT_FREE);
+void  RpcSsSetThreadHandle(RPC_SS_THREAD_HANDLE);
+void  RpcSsSwapClientAllocFree(PRPC_CLIENT_ALLOC,PRPC_CLIENT_FREE,PRPC_CLIENT_ALLOC*,PRPC_CLIENT_FREE*);
+void* RpcSmAllocate(uint,RPC_STATUS*);
+RPC_STATUS  RpcSmClientFree(void*);
+RPC_STATUS  RpcSmDestroyClientContext(void**);
+RPC_STATUS  RpcSmDisableAllocate();
+RPC_STATUS  RpcSmEnableAllocate();
+RPC_STATUS  RpcSmFree(void*);
+RPC_SS_THREAD_HANDLE  RpcSmGetThreadHandle(RPC_STATUS*);
+RPC_STATUS  RpcSmSetClientAllocFree(PRPC_CLIENT_ALLOC,PRPC_CLIENT_FREE);
+RPC_STATUS  RpcSmSetThreadHandle(RPC_SS_THREAD_HANDLE);
+RPC_STATUS  RpcSmSwapClientAllocFree(PRPC_CLIENT_ALLOC,PRPC_CLIENT_FREE,PRPC_CLIENT_ALLOC*,PRPC_CLIENT_FREE*);
+void  NdrRpcSsEnableAllocate(PMIDL_STUB_MESSAGE);
+void  NdrRpcSsDisableAllocate(PMIDL_STUB_MESSAGE);
+void  NdrRpcSmSetClientToOsf(PMIDL_STUB_MESSAGE);
+void* NdrRpcSmClientAllocate(uint);
+void  NdrRpcSmClientFree(void*);
+void* NdrRpcSsDefaultAllocate(uint);
+void  NdrRpcSsDefaultFree(void*);
+PFULL_PTR_XLAT_TABLES  NdrFullPointerXlatInit(uint,XLAT_SIDE);
+void  NdrFullPointerXlatFree(PFULL_PTR_XLAT_TABLES);
+int  NdrFullPointerQueryPointer(PFULL_PTR_XLAT_TABLES,void*,ubyte,uint*);
+int  NdrFullPointerQueryRefId(PFULL_PTR_XLAT_TABLES,uint,ubyte,void**);
+void  NdrFullPointerInsertRefId(PFULL_PTR_XLAT_TABLES,uint,void*);
+int  NdrFullPointerFree(PFULL_PTR_XLAT_TABLES,void*);
+void* NdrAllocate(PMIDL_STUB_MESSAGE,uint);
+void  NdrClearOutParameters(PMIDL_STUB_MESSAGE,PFORMAT_STRING,void*);
+void* NdrOleAllocate(uint);
+void  NdrOleFree(void*);
+ubyte* NdrUserMarshalMarshall(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+ubyte* NdrUserMarshalUnmarshall(PMIDL_STUB_MESSAGE,ubyte**,PFORMAT_STRING,ubyte);
+void  NdrUserMarshalBufferSize(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
+uint  NdrUserMarshalMemorySize(PMIDL_STUB_MESSAGE,PFORMAT_STRING);
+void  NdrUserMarshalFree(PMIDL_STUB_MESSAGE,ubyte*,PFORMAT_STRING);
diff --git a/libphobos/libdruntime/core/sys/windows/rpcnsi.d b/libphobos/libdruntime/core/sys/windows/rpcnsi.d
new file mode 100644
index 00000000000..058e2566e99
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/rpcnsi.d
@@ -0,0 +1,152 @@
+/**
+ * Windows API header module
+ *
+ * RPC Name Service (RpcNs APIs)
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_rpcnsi.d)
+ */
+module core.sys.windows.rpcnsi;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "rpcns4");
+
+private import core.sys.windows.basetyps, core.sys.windows.rpcdcep, core.sys.windows.rpcnsi, core.sys.windows.rpcdce,
+  core.sys.windows.w32api;
+private import core.sys.windows.windef;  // for HANDLE
+
+mixin DECLARE_HANDLE!("RPC_NS_HANDLE");
+
+enum RPC_C_NS_SYNTAX_DEFAULT=0;
+enum RPC_C_NS_SYNTAX_DCE=3;
+enum RPC_C_PROFILE_DEFAULT_ELT=0;
+enum RPC_C_PROFILE_ALL_ELT=1;
+enum RPC_C_PROFILE_MATCH_BY_IF=2;
+enum RPC_C_PROFILE_MATCH_BY_MBR=3;
+enum RPC_C_PROFILE_MATCH_BY_BOTH=4;
+enum RPC_C_NS_DEFAULT_EXP_AGE=-1;
+
+extern (Windows) {
+    RPC_STATUS RpcNsBindingExportA(uint, ubyte*, RPC_IF_HANDLE,
+      RPC_BINDING_VECTOR*, UUID_VECTOR*);
+    RPC_STATUS RpcNsBindingUnexportA(uint, ubyte*, RPC_IF_HANDLE,
+      UUID_VECTOR*);
+    RPC_STATUS RpcNsBindingLookupBeginA(uint, ubyte*, RPC_IF_HANDLE, UUID*,
+      uint, RPC_NS_HANDLE*);
+    RPC_STATUS RpcNsBindingLookupNext(RPC_NS_HANDLE, RPC_BINDING_VECTOR**);
+    RPC_STATUS RpcNsBindingLookupDone(RPC_NS_HANDLE*);
+    RPC_STATUS RpcNsGroupDeleteA(uint, ubyte*);
+    RPC_STATUS RpcNsGroupMbrAddA(uint, ubyte*, uint, ubyte*);
+    RPC_STATUS RpcNsGroupMbrRemoveA(uint, ubyte*, uint, ubyte*);
+    RPC_STATUS RpcNsGroupMbrInqBeginA(uint, ubyte*, uint, RPC_NS_HANDLE*);
+    RPC_STATUS RpcNsGroupMbrInqNextA(RPC_NS_HANDLE, ubyte**);
+    RPC_STATUS RpcNsGroupMbrInqDone(RPC_NS_HANDLE*);
+    RPC_STATUS RpcNsProfileDeleteA(uint, ubyte*);
+    RPC_STATUS RpcNsProfileEltAddA(uint, ubyte*, RPC_IF_ID*, uint, ubyte*,
+      uint, ubyte*);
+    RPC_STATUS RpcNsProfileEltRemoveA(uint, ubyte*, RPC_IF_ID*, uint, ubyte*);
+    RPC_STATUS RpcNsProfileEltInqBeginA(uint, ubyte*, uint, RPC_IF_ID*, uint,
+      uint, ubyte*, RPC_NS_HANDLE*);
+    RPC_STATUS RpcNsProfileEltInqNextA(RPC_NS_HANDLE, RPC_IF_ID*, ubyte**,
+      uint*, ubyte**);
+    RPC_STATUS RpcNsProfileEltInqDone(RPC_NS_HANDLE*);
+    RPC_STATUS RpcNsEntryObjectInqNext(RPC_NS_HANDLE, UUID*);
+    RPC_STATUS RpcNsEntryObjectInqDone(RPC_NS_HANDLE*);
+    RPC_STATUS RpcNsEntryExpandNameA(uint, ubyte*, ubyte**);
+    RPC_STATUS RpcNsMgmtBindingUnexportA(uint, ubyte*, RPC_IF_ID*, uint,
+      UUID_VECTOR*);
+    RPC_STATUS RpcNsMgmtEntryCreateA(uint, ubyte*);
+    RPC_STATUS RpcNsMgmtEntryDeleteA(uint, ubyte*);
+    RPC_STATUS RpcNsMgmtEntryInqIfIdsA(uint, ubyte*, RPC_IF_ID_VECTOR**);
+    RPC_STATUS RpcNsMgmtHandleSetExpAge(RPC_NS_HANDLE, uint);
+    RPC_STATUS RpcNsMgmtInqExpAge(uint*);
+    RPC_STATUS RpcNsMgmtSetExpAge(uint);
+    RPC_STATUS RpcNsBindingImportNext(RPC_NS_HANDLE, RPC_BINDING_HANDLE*);
+    RPC_STATUS RpcNsBindingImportDone(RPC_NS_HANDLE*);
+    RPC_STATUS RpcNsBindingSelect(RPC_BINDING_VECTOR*, RPC_BINDING_HANDLE*);
+}
+
+
+version (Unicode) {
+} else {
+    RPC_STATUS RpcNsEntryObjectInqBeginA(uint, ubyte*, RPC_NS_HANDLE*);
+    RPC_STATUS RpcNsBindingImportBeginA(uint, ubyte*, RPC_IF_HANDLE, UUID*,
+      RPC_NS_HANDLE*);
+}
+
+RPC_STATUS RpcNsBindingExportW(uint, ushort*, RPC_IF_HANDLE,
+  RPC_BINDING_VECTOR*, UUID_VECTOR*);
+RPC_STATUS RpcNsBindingUnexportW(uint, ushort*, RPC_IF_HANDLE,
+  UUID_VECTOR*);
+RPC_STATUS RpcNsBindingLookupBeginW(uint, ushort*, RPC_IF_HANDLE, UUID*,
+  uint, RPC_NS_HANDLE*);
+RPC_STATUS RpcNsGroupDeleteW(uint, ushort*);
+RPC_STATUS RpcNsGroupMbrAddW(uint, ushort*, uint, ushort*);
+RPC_STATUS RpcNsGroupMbrRemoveW(uint, ushort*, uint, ushort*);
+RPC_STATUS RpcNsGroupMbrInqBeginW(uint, ushort*, uint, RPC_NS_HANDLE*);
+RPC_STATUS RpcNsGroupMbrInqNextW(RPC_NS_HANDLE, ushort**);
+RPC_STATUS RpcNsProfileDeleteW(uint, ushort*);
+RPC_STATUS RpcNsProfileEltAddW(uint, ushort*, RPC_IF_ID*, uint, ushort*,
+  uint, ushort*);
+RPC_STATUS RpcNsProfileEltRemoveW(uint, ushort*, RPC_IF_ID*, uint,
+  ushort*);
+RPC_STATUS RpcNsProfileEltInqBeginW(uint, ushort*, uint, RPC_IF_ID*,
+  uint, uint, ushort*, RPC_NS_HANDLE*);
+RPC_STATUS RpcNsProfileEltInqNextW(RPC_NS_HANDLE, RPC_IF_ID*, ushort**,
+  uint*, ushort**);
+RPC_STATUS RpcNsEntryObjectInqBeginW(uint, ushort*, RPC_NS_HANDLE*);
+RPC_STATUS RpcNsEntryExpandNameW(uint, ushort*, ushort**);
+RPC_STATUS RpcNsMgmtBindingUnexportW(uint, ushort*, RPC_IF_ID*, uint,
+  UUID_VECTOR*);
+RPC_STATUS RpcNsMgmtEntryCreateW(uint, ushort*);
+RPC_STATUS RpcNsMgmtEntryDeleteW(uint, ushort*);
+RPC_STATUS RpcNsMgmtEntryInqIfIdsW(uint, ushort , RPC_IF_ID_VECTOR**);
+RPC_STATUS RpcNsBindingImportBeginW(uint, ushort*, RPC_IF_HANDLE, UUID*,
+  RPC_NS_HANDLE*);
+
+version (Unicode) {
+    alias RpcNsBindingLookupBeginW RpcNsBindingLookupBegin;
+    alias RpcNsBindingImportBeginW RpcNsBindingImportBegin;
+    alias RpcNsBindingExportW RpcNsBindingExport;
+    alias RpcNsBindingUnexportW RpcNsBindingUnexport;
+    alias RpcNsGroupDeleteW RpcNsGroupDelete;
+    alias RpcNsGroupMbrAddW RpcNsGroupMbrAdd;
+    alias RpcNsGroupMbrRemoveW RpcNsGroupMbrRemove;
+    alias RpcNsGroupMbrInqBeginW RpcNsGroupMbrInqBegin;
+    alias RpcNsGroupMbrInqNextW RpcNsGroupMbrInqNext;
+    alias RpcNsEntryExpandNameW RpcNsEntryExpandName;
+    alias RpcNsEntryObjectInqBeginW RpcNsEntryObjectInqBegin;
+    alias RpcNsMgmtBindingUnexportW RpcNsMgmtBindingUnexport;
+    alias RpcNsMgmtEntryCreateW RpcNsMgmtEntryCreate;
+    alias RpcNsMgmtEntryDeleteW RpcNsMgmtEntryDelete;
+    alias RpcNsMgmtEntryInqIfIdsW RpcNsMgmtEntryInqIfIds;
+    alias RpcNsProfileDeleteW RpcNsProfileDelete;
+    alias RpcNsProfileEltAddW RpcNsProfileEltAdd;
+    alias RpcNsProfileEltRemoveW RpcNsProfileEltRemove;
+    alias RpcNsProfileEltInqBeginW RpcNsProfileEltInqBegin;
+    alias RpcNsProfileEltInqNextW RpcNsProfileEltInqNext;
+} else {
+    alias RpcNsBindingLookupBeginA RpcNsBindingLookupBegin;
+    alias RpcNsBindingImportBeginA RpcNsBindingImportBegin;
+    alias RpcNsBindingExportA RpcNsBindingExport;
+    alias RpcNsBindingUnexportA RpcNsBindingUnexport;
+    alias RpcNsGroupDeleteA RpcNsGroupDelete;
+    alias RpcNsGroupMbrAddA RpcNsGroupMbrAdd;
+    alias RpcNsGroupMbrRemoveA RpcNsGroupMbrRemove;
+    alias RpcNsGroupMbrInqBeginA RpcNsGroupMbrInqBegin;
+    alias RpcNsGroupMbrInqNextA RpcNsGroupMbrInqNext;
+    alias RpcNsEntryExpandNameA RpcNsEntryExpandName;
+    alias RpcNsEntryObjectInqBeginA RpcNsEntryObjectInqBegin;
+    alias RpcNsMgmtBindingUnexportA RpcNsMgmtBindingUnexport;
+    alias RpcNsMgmtEntryCreateA RpcNsMgmtEntryCreate;
+    alias RpcNsMgmtEntryDeleteA RpcNsMgmtEntryDelete;
+    alias RpcNsMgmtEntryInqIfIdsA RpcNsMgmtEntryInqIfIds;
+    alias RpcNsProfileDeleteA RpcNsProfileDelete;
+    alias RpcNsProfileEltAddA RpcNsProfileEltAdd;
+    alias RpcNsProfileEltRemoveA RpcNsProfileEltRemove;
+    alias RpcNsProfileEltInqBeginA RpcNsProfileEltInqBegin;
+    alias RpcNsProfileEltInqNextA RpcNsProfileEltInqNext;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/rpcnsip.d b/libphobos/libdruntime/core/sys/windows/rpcnsip.d
new file mode 100644
index 00000000000..fcf43898366
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/rpcnsip.d
@@ -0,0 +1,29 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_rpcnsip.d)
+ */
+module core.sys.windows.rpcnsip;
+version (Windows):
+
+private import core.sys.windows.rpcdce, core.sys.windows.rpcdcep, core.sys.windows.rpcnsi;
+
+struct RPC_IMPORT_CONTEXT_P {
+    RPC_NS_HANDLE       LookupContext;
+    RPC_BINDING_HANDLE  ProposedHandle;
+    RPC_BINDING_VECTOR* Bindings;
+}
+alias RPC_IMPORT_CONTEXT_P* PRPC_IMPORT_CONTEXT_P;
+
+extern(Windows) {
+    RPC_STATUS I_RpcNsGetBuffer(PRPC_MESSAGE);
+    RPC_STATUS I_RpcNsSendReceive(PRPC_MESSAGE, RPC_BINDING_HANDLE*);
+    void I_RpcNsRaiseException(PRPC_MESSAGE, RPC_STATUS);
+    RPC_STATUS I_RpcReBindBuffer(PRPC_MESSAGE);
+    RPC_STATUS I_NsServerBindSearch();
+    RPC_STATUS I_NsClientBindSearch();
+    void I_NsClientBindDone();
+}
diff --git a/libphobos/libdruntime/core/sys/windows/rpcnterr.d b/libphobos/libdruntime/core/sys/windows/rpcnterr.d
new file mode 100644
index 00000000000..8b1e5835b01
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/rpcnterr.d
@@ -0,0 +1,31 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_rpcnterr.d)
+ */
+module core.sys.windows.rpcnterr;
+version (Windows):
+
+import core.sys.windows.winerror;
+
+enum : uint {
+    RPC_S_OK                     = ERROR_SUCCESS,
+    RPC_S_INVALID_ARG            = ERROR_INVALID_PARAMETER,
+    RPC_S_OUT_OF_MEMORY          = ERROR_OUTOFMEMORY,
+    RPC_S_OUT_OF_THREADS         = ERROR_MAX_THRDS_REACHED,
+    RPC_S_INVALID_LEVEL          = ERROR_INVALID_PARAMETER,
+    RPC_S_BUFFER_TOO_SMALL       = ERROR_INSUFFICIENT_BUFFER,
+    RPC_S_INVALID_SECURITY_DESC  = ERROR_INVALID_SECURITY_DESCR,
+    RPC_S_ACCESS_DENIED          = ERROR_ACCESS_DENIED,
+    RPC_S_SERVER_OUT_OF_MEMORY   = ERROR_NOT_ENOUGH_SERVER_MEMORY,
+    RPC_X_NO_MEMORY              = RPC_S_OUT_OF_MEMORY,
+    RPC_X_INVALID_BOUND          = RPC_S_INVALID_BOUND,
+    RPC_X_INVALID_TAG            = RPC_S_INVALID_TAG,
+    RPC_X_ENUM_VALUE_TOO_LARGE   = RPC_X_ENUM_VALUE_OUT_OF_RANGE,
+    RPC_X_SS_CONTEXT_MISMATCH    = ERROR_INVALID_HANDLE,
+    RPC_X_INVALID_BUFFER         = ERROR_INVALID_USER_BUFFER,
+    RPC_X_INVALID_PIPE_OPERATION = RPC_X_WRONG_PIPE_ORDER
+}
diff --git a/libphobos/libdruntime/core/sys/windows/schannel.d b/libphobos/libdruntime/core/sys/windows/schannel.d
new file mode 100644
index 00000000000..c7622387a9d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/schannel.d
@@ -0,0 +1,106 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_schannel.d)
+ */
+module core.sys.windows.schannel;
+version (Windows):
+
+import core.sys.windows.wincrypt;
+private import core.sys.windows.windef;
+
+enum DWORD SCHANNEL_CRED_VERSION = 4;
+enum SCHANNEL_SHUTDOWN           = 1;
+/* Comment from MinGW
+    ? Do these belong here or in wincrypt.h
+ */
+enum : DWORD {
+    AUTHTYPE_CLIENT = 1,
+    AUTHTYPE_SERVER = 2
+}
+
+enum DWORD
+    SP_PROT_PCT1_SERVER = 0x01,
+    SP_PROT_PCT1_CLIENT = 0x02,
+    SP_PROT_SSL2_SERVER = 0x04,
+    SP_PROT_SSL2_CLIENT = 0x08,
+    SP_PROT_SSL3_SERVER = 0x10,
+    SP_PROT_SSL3_CLIENT = 0x20,
+    SP_PROT_TLS1_SERVER = 0x40,
+    SP_PROT_TLS1_CLIENT = 0x80,
+    SP_PROT_PCT1        = SP_PROT_PCT1_CLIENT | SP_PROT_PCT1_SERVER,
+    SP_PROT_TLS1        = SP_PROT_TLS1_CLIENT | SP_PROT_TLS1_SERVER,
+    SP_PROT_SSL2        = SP_PROT_SSL2_CLIENT | SP_PROT_SSL2_SERVER,
+    SP_PROT_SSL3        = SP_PROT_SSL3_CLIENT | SP_PROT_SSL3_SERVER;
+
+enum DWORD
+    SCH_CRED_NO_SYSTEM_MAPPER                    = 0x0002,
+    SCH_CRED_NO_SERVERNAME_CHECK                 = 0x0004,
+    SCH_CRED_MANUAL_CRED_VALIDATION              = 0x0008,
+    SCH_CRED_NO_DEFAULT_CREDS                    = 0x0010,
+    SCH_CRED_AUTO_CRED_VALIDATION                = 0x0020,
+    SCH_CRED_USE_DEFAULT_CREDS                   = 0x0040,
+    SCH_CRED_REVOCATION_CHECK_END_CERT           = 0x0100,
+    SCH_CRED_REVOCATION_CHECK_CHAIN              = 0x0200,
+    SCH_CRED_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT = 0x0400,
+    SCH_CRED_IGNORE_NO_REVOCATION_CHECK          = 0x0800,
+    SCH_CRED_IGNORE_REVOCATION_OFFLINE           = 0x1000;
+
+// No definition - presumably an opaque structure
+struct _HMAPPER;
+
+struct SCHANNEL_CRED {
+    DWORD           dwVersion = SCHANNEL_CRED_VERSION;
+    DWORD           cCreds;
+    PCCERT_CONTEXT* paCred;
+    HCERTSTORE      hRootStore;
+    DWORD           cMappers;
+    _HMAPPER**      aphMappers;
+    DWORD           cSupportedAlgs;
+    ALG_ID*         palgSupportedAlgs;
+    DWORD           grbitEnabledProtocols;
+    DWORD           dwMinimumCypherStrength;
+    DWORD           dwMaximumCypherStrength;
+    DWORD           dwSessionLifespan;
+    DWORD           dwFlags;
+    DWORD           reserved;
+}
+alias SCHANNEL_CRED* PSCHANNEL_CRED;
+
+struct SecPkgCred_SupportedAlgs {
+    DWORD   cSupportedAlgs;
+    ALG_ID* palgSupportedAlgs;
+}
+alias SecPkgCred_SupportedAlgs* PSecPkgCred_SupportedAlgs;
+
+struct SecPkgCred_CypherStrengths {
+    DWORD dwMinimumCypherStrength;
+    DWORD dwMaximumCypherStrength;
+}
+alias SecPkgCred_CypherStrengths* PSecPkgCred_CypherStrengths;
+
+struct SecPkgCred_SupportedProtocols {
+    DWORD grbitProtocol;
+}
+alias SecPkgCred_SupportedProtocols* PSecPkgCred_SupportedProtocols;
+
+struct SecPkgContext_IssuerListInfoEx {
+    PCERT_NAME_BLOB aIssuers;
+    DWORD           cIssuers;
+}
+alias SecPkgContext_IssuerListInfoEx* PSecPkgContext_IssuerListInfoEx;
+
+struct SecPkgContext_ConnectionInfo {
+    DWORD  dwProtocol;
+    ALG_ID aiCipher;
+    DWORD  dwCipherStrength;
+    ALG_ID aiHash;
+    DWORD  dwHashStrength;
+    ALG_ID aiExch;
+    DWORD  dwExchStrength;
+}
+alias SecPkgContext_ConnectionInfo* PSecPkgContext_ConnectionInfo;
diff --git a/libphobos/libdruntime/core/sys/windows/secext.d b/libphobos/libdruntime/core/sys/windows/secext.d
new file mode 100644
index 00000000000..486025d05ca
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/secext.d
@@ -0,0 +1,54 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_secext.d)
+ */
+// Don't include this file directly, use core.sys.windows.security instead.
+module core.sys.windows.secext;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "secur32");
+
+private import core.sys.windows.w32api, core.sys.windows.windef;
+
+static assert (_WIN32_WINNT >= 0x501,
+  "SecExt is only available on WindowsXP and later");
+
+enum EXTENDED_NAME_FORMAT {
+    NameUnknown,
+    NameFullyQualifiedDN,
+    NameSamCompatible,
+    NameDisplay,          // =  3
+    NameUniqueId             =  6,
+    NameCanonical,
+    NameUserPrincipal,
+    NameCanonicalEx,
+    NameServicePrincipal, // = 10
+    NameDnsDomain            = 12
+}
+alias EXTENDED_NAME_FORMAT* PEXTENDED_NAME_FORMAT;
+
+extern (Windows) {
+    BOOLEAN GetComputerObjectNameA(EXTENDED_NAME_FORMAT, LPSTR, PULONG);
+    BOOLEAN GetComputerObjectNameW(EXTENDED_NAME_FORMAT, LPWSTR, PULONG);
+    BOOLEAN GetUserNameExA(EXTENDED_NAME_FORMAT, LPSTR, PULONG);
+    BOOLEAN GetUserNameExW(EXTENDED_NAME_FORMAT, LPWSTR, PULONG);
+    BOOLEAN TranslateNameA(LPCSTR, EXTENDED_NAME_FORMAT,
+      EXTENDED_NAME_FORMAT, LPSTR, PULONG);
+    BOOLEAN TranslateNameW(LPCWSTR, EXTENDED_NAME_FORMAT,
+      EXTENDED_NAME_FORMAT, LPWSTR, PULONG);
+}
+
+version (Unicode) {
+    alias GetComputerObjectNameW GetComputerObjectName;
+    alias GetUserNameExW GetUserNameEx;
+    alias TranslateNameW TranslateName;
+} else {
+    alias GetComputerObjectNameA GetComputerObjectName;
+    alias GetUserNameExA GetUserNameEx;
+    alias TranslateNameA TranslateName;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/security.d b/libphobos/libdruntime/core/sys/windows/security.d
new file mode 100644
index 00000000000..a5f57851ccb
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/security.d
@@ -0,0 +1,46 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Ellery Newcomer
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_security.d)
+ */
+module core.sys.windows.security;
+version (Windows):
+
+enum :SECURITY_STATUS{
+    SEC_E_OK = 0,
+    SEC_E_CERT_EXPIRED = (-2146893016),
+    SEC_E_INCOMPLETE_MESSAGE = (-2146893032),
+    SEC_E_INSUFFICIENT_MEMORY = (-2146893056),
+    SEC_E_INTERNAL_ERROR = (-2146893052),
+    SEC_E_INVALID_HANDLE = (-2146893055),
+    SEC_E_INVALID_TOKEN = (-2146893048),
+    SEC_E_LOGON_DENIED = (-2146893044),
+    SEC_E_NO_AUTHENTICATING_AUTHORITY = (-2146893039),
+    SEC_E_NO_CREDENTIALS = (-2146893042),
+    SEC_E_TARGET_UNKNOWN = (-2146893053),
+    SEC_E_UNSUPPORTED_FUNCTION = (-2146893054),
+    SEC_E_UNTRUSTED_ROOT = (-2146893019),
+    SEC_E_WRONG_PRINCIPAL = (-2146893022),
+    SEC_E_SECPKG_NOT_FOUND = (-2146893051),
+    SEC_E_QOP_NOT_SUPPORTED = (-2146893046),
+    SEC_E_UNKNOWN_CREDENTIALS = (-2146893043),
+    SEC_E_NOT_OWNER = (-2146893050),
+}
+enum :SECURITY_STATUS {
+    SEC_I_RENEGOTIATE = 590625,
+    SEC_I_COMPLETE_AND_CONTINUE = 590612,
+    SEC_I_COMPLETE_NEEDED = 590611,
+    SEC_I_CONTINUE_NEEDED = 590610,
+    SEC_I_INCOMPLETE_CREDENTIALS = 590624,
+}
+
+/* always a char */
+alias char SEC_CHAR;
+alias wchar SEC_WCHAR;
+
+alias int SECURITY_STATUS;
+
diff --git a/libphobos/libdruntime/core/sys/windows/servprov.d b/libphobos/libdruntime/core/sys/windows/servprov.d
new file mode 100644
index 00000000000..91a0a118453
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/servprov.d
@@ -0,0 +1,16 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.10
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_servprov.d)
+ */
+module core.sys.windows.servprov;
+version (Windows):
+
+private import core.sys.windows.basetyps, core.sys.windows.unknwn, core.sys.windows.windef, core.sys.windows.wtypes;
+
+interface IServiceProvider : IUnknown {
+    HRESULT QueryService(REFGUID, REFIID, void**);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/setupapi.d b/libphobos/libdruntime/core/sys/windows/setupapi.d
new file mode 100644
index 00000000000..f6a0ded19b6
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/setupapi.d
@@ -0,0 +1,1981 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Vladimir Vlasov
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_setupapi.d)
+ */
+module core.sys.windows.setupapi;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "setupapi");
+
+private import core.sys.windows.basetyps, core.sys.windows.commctrl, core.sys.windows.prsht, core.sys.windows.w32api,
+  core.sys.windows.winreg, core.sys.windows.windef;
+private import core.sys.windows.winbase; // for SYSTEMTIME
+
+/*static if(_WIN32_WINNT < _WIN32_WINDOWS) {
+enum UINT _SETUPAPI_VER = _WIN32_WINNT; // SetupAPI version follows Windows NT version
+} else static if(_WIN32_WINDOWS) {
+    static if(_WIN32_WINDOWS >= 0x0490) {
+enum UINT _SETUPAPI_VER = 0x0500;     // WinME uses same version of SetupAPI as Win2k
+    } else static if(_WIN32_WINDOWS >= 0x0410) {
+enum UINT _SETUPAPI_VER = 0x0410;     // Indicates version of SetupAPI shipped with Win98
+    } else {
+enum UINT _SETUPAPI_VER = 0x0400;     // Earliest SetupAPI version
+    }
+} else {
+enum UINT _SETUPAPI_VER = 0x0501;
+}
+
+version (WindowsNTonly) {
+    static if (_WIN32_WINNT >= 0x500) {
+enum UINT USE_SP_DRVINFO_DATA_V1 = 0;
+    } else {
+enum UINT USE_SP_DRVINFO_DATA_V1 = 1;
+    }
+} else {
+enum UINT USE_SP_DRVINFO_DATA_V1 = 1;
+}*/
+/+
+enum UINT _SETUPAPI_VER = 0x0400;     // Earliest SetupAPI version
+enum UINT USE_SP_DRVINFO_DATA_V1 = 1;
++/
+enum UINT _SETUPAPI_VER          = _WIN32_WINNT;
+enum bool USE_SP_DRVINFO_DATA_V1 = _WIN32_WINNT < 0x500;
+
+enum : uint {
+    LINE_LEN                  = 256,
+    MAX_INF_STRING_LENGTH     = 4096,
+    MAX_TITLE_LEN             = 60,
+    MAX_INSTRUCTION_LEN       = 256,
+    MAX_LABEL_LEN             = 30,
+    MAX_SERVICE_NAME_LEN      = 256,
+    MAX_SUBTITLE_LEN          = 256,
+    SP_MAX_MACHINENAME_LENGTH = MAX_PATH + 3
+}
+
+enum : DWORD {
+    COPYFLG_WARN_IF_SKIP         = 0x00000001,
+    COPYFLG_NOSKIP               = 0x00000002,
+    COPYFLG_NOVERSIONCHECK       = 0x00000004,
+    COPYFLG_FORCE_FILE_IN_USE    = 0x00000008,
+    COPYFLG_NO_OVERWRITE         = 0x00000010,
+    COPYFLG_NO_VERSION_DIALOG    = 0x00000020,
+    COPYFLG_OVERWRITE_OLDER_ONLY = 0x00000040,
+    COPYFLG_REPLACEONLY          = 0x00000400,
+    COPYFLG_NODECOMP             = 0x00000800,
+    COPYFLG_REPLACE_BOOT_FILE    = 0x00001000,
+    COPYFLG_NOPRUNE              = 0x00002000
+}
+
+enum : DWORD {
+    DELFLG_IN_USE  = 0x00000001,
+    DELFLG_IN_USE1 = 0x00010000
+}
+
+enum : DWORD {
+    DI_REMOVEDEVICE_GLOBAL              = 0x00000001,
+    DI_REMOVEDEVICE_CONFIGSPECIFIC      = 0x00000002,
+    DI_UNREMOVEDEVICE_CONFIGSPECIFIC    = 0x00000002,
+    DI_SHOWOEM                          = 0x00000001,
+    DI_SHOWCOMPAT                       = 0x00000002,
+    DI_SHOWCLASS                        = 0x00000004,
+    DI_SHOWALL                          = 0x00000007,
+    DI_NOVCP                            = 0x00000008,
+    DI_DIDCOMPAT                        = 0x00000010,
+    DI_DIDCLASS                         = 0x00000020,
+    DI_AUTOASSIGNRES                    = 0x00000040,
+    DI_NEEDRESTART                      = 0x00000080,
+    DI_NEEDREBOOT                       = 0x00000100,
+    DI_NOBROWSE                         = 0x00000200,
+    DI_MULTMFGS                         = 0x00000400,
+    DI_DISABLED                         = 0x00000800,
+    DI_GENERALPAGE_ADDED                = 0x00001000,
+    DI_RESOURCEPAGE_ADDED               = 0x00002000,
+    DI_PROPERTIES_CHANGE                = 0x00004000,
+    DI_INF_IS_SORTED                    = 0x00008000,
+    DI_ENUMSINGLEINF                    = 0x00010000,
+    DI_DONOTCALLCONFIGMG                = 0x00020000,
+    DI_INSTALLDISABLED                  = 0x00040000,
+    DI_COMPAT_FROM_CLASS                = 0x00080000,
+    DI_CLASSINSTALLPARAMS               = 0x00100000,
+    DI_NODI_DEFAULTACTION               = 0x00200000,
+    DI_QUIETINSTALL                     = 0x00800000,
+    DI_NOFILECOPY                       = 0x01000000,
+    DI_FORCECOPY                        = 0x02000000,
+    DI_DRIVERPAGE_ADDED                 = 0x04000000,
+    DI_USECI_SELECTSTRINGS              = 0x08000000,
+    DI_OVERRIDE_INFFLAGS                = 0x10000000,
+    DI_PROPS_NOCHANGEUSAGE              = 0x20000000,
+    DI_NOSELECTICONS                    = 0x40000000,
+    DI_NOWRITE_IDS                      = 0x80000000,
+    DI_FLAGSEX_USEOLDINFSEARCH          = 0x00000001,
+    DI_FLAGSEX_AUTOSELECTRANK0          = 0x00000002,
+    DI_FLAGSEX_CI_FAILED                = 0x00000004,
+    DI_FLAGSEX_DIDINFOLIST              = 0x00000010,
+    DI_FLAGSEX_DIDCOMPATINFO            = 0x00000020,
+    DI_FLAGSEX_FILTERCLASSES            = 0x00000040,
+    DI_FLAGSEX_SETFAILEDINSTALL         = 0x00000080,
+    DI_FLAGSEX_DEVICECHANGE             = 0x00000100,
+    DI_FLAGSEX_ALWAYSWRITEIDS           = 0x00000200,
+    DI_FLAGSEX_PROPCHANGE_PENDING       = 0x00000400,
+    DI_FLAGSEX_ALLOWEXCLUDEDDRVS        = 0x00000800,
+    DI_FLAGSEX_NOUIONQUERYREMOVE        = 0x00001000,
+    DI_FLAGSEX_USECLASSFORCOMPAT        = 0x00002000,
+    DI_FLAGSEX_OLDINF_IN_CLASSLIST      = 0x00004000,
+    DI_FLAGSEX_NO_DRVREG_MODIFY         = 0x00008000,
+    DI_FLAGSEX_IN_SYSTEM_SETUP          = 0x00010000,
+    DI_FLAGSEX_INET_DRIVER              = 0x00020000,
+    DI_FLAGSEX_APPENDDRIVERLIST         = 0x00040000,
+    DI_FLAGSEX_PREINSTALLBACKUP         = 0x00080000,
+    DI_FLAGSEX_BACKUPONREPLACE          = 0x00100000,
+    DI_FLAGSEX_DRIVERLIST_FROM_URL      = 0x00200000,
+    DI_FLAGSEX_RESERVED1                = 0x00400000,
+    DI_FLAGSEX_EXCLUDE_OLD_INET_DRIVERS = 0x00800000,
+    DI_FLAGSEX_POWERPAGE_ADDED          = 0x01000000
+}
+
+enum : DWORD {
+    DIBCI_NOINSTALLCLASS = 0x00000001,
+    DIBCI_NODISPLAYCLASS = 0x00000002
+}
+
+enum : DWORD {
+    DICD_GENERATE_ID       = 0x00000001,
+    DICD_INHERIT_CLASSDRVS = 0x00000002
+}
+
+enum : DWORD {
+    DICS_ENABLE = 1,
+    DICS_DISABLE,
+    DICS_PROPCHANGE,
+    DICS_START,
+    DICS_STOP // = 5
+}
+
+enum : DWORD {
+    DICS_FLAG_GLOBAL         = 1,
+    DICS_FLAG_CONFIGSPECIFIC = 2,
+    DICS_FLAG_CONFIGGENERAL  = 4
+}
+
+alias UINT DI_FUNCTION;
+
+enum : DI_FUNCTION {
+    DIF_SELECTDEVICE = 1,
+    DIF_INSTALLDEVICE,
+    DIF_ASSIGNRESOURCES,
+    DIF_PROPERTIES,
+    DIF_REMOVE,
+    DIF_FIRSTTIMESETUP,
+    DIF_FOUNDDEVICE,
+    DIF_SELECTCLASSDRIVERS,
+    DIF_VALIDATECLASSDRIVERS,
+    DIF_INSTALLCLASSDRIVERS,
+    DIF_CALCDISKSPACE,
+    DIF_DESTROYPRIVATEDATA,
+    DIF_VALIDATEDRIVER,
+    DIF_MOVEDEVICE,
+    DIF_DETECT,
+    DIF_INSTALLWIZARD,
+    DIF_DESTROYWIZARDDATA,
+    DIF_PROPERTYCHANGE,
+    DIF_ENABLECLASS,
+    DIF_DETECTVERIFY,
+    DIF_INSTALLDEVICEFILES,
+    DIF_UNREMOVE,
+    DIF_SELECTBESTCOMPATDRV,
+    DIF_ALLOW_INSTALL,
+    DIF_REGISTERDEVICE,
+    DIF_NEWDEVICEWIZARD_PRESELECT,
+    DIF_NEWDEVICEWIZARD_SELECT,
+    DIF_NEWDEVICEWIZARD_PREANALYZE,
+    DIF_NEWDEVICEWIZARD_POSTANALYZE,
+    DIF_NEWDEVICEWIZARD_FINISHINSTALL,
+    DIF_UNUSED1,
+    DIF_INSTALLINTERFACES,
+    DIF_DETECTCANCEL,
+    DIF_REGISTER_COINSTALLERS,
+    DIF_ADDPROPERTYPAGE_ADVANCED,
+    DIF_ADDPROPERTYPAGE_BASIC,
+    DIF_RESERVED1,
+    DIF_TROUBLESHOOTER,
+    DIF_POWERMESSAGEWAKE // = 39
+}
+
+enum : DWORD {
+    DIGCF_DEFAULT         = 0x00000001,
+    DIGCF_PRESENT         = 0x00000002,
+    DIGCF_ALLCLASSES      = 0x00000004,
+    DIGCF_PROFILE         = 0x00000008,
+    DIGCF_DEVICEINTERFACE = 0x00000010
+}
+
+deprecated enum : DWORD {
+    DIGCF_INTERFACEDEVICE = DIGCF_DEVICEINTERFACE
+}
+
+enum : DWORD {
+    DIGCDP_FLAG_BASIC    = 0x00000001,
+    DIGCDP_FLAG_ADVANCED = 0x00000002
+}
+
+enum : DWORD {
+    DIOCR_INSTALLER = 0x00000001,
+    DIOCR_INTERFACE = 0x00000002
+}
+
+enum : DWORD {
+    DIODI_NO_ADD = 0x00000001
+}
+
+enum : DWORD {
+    DIOD_INHERIT_CLASSDRVS = 0x00000002,
+    DIOD_CANCEL_REMOVE     = 0x00000004
+}
+
+enum : DWORD {
+    DIREG_DEV  = 0x00000001,
+    DIREG_DRV  = 0x00000002,
+    DIREG_BOTH = 0x00000004
+}
+
+enum : int {
+    DIRID_ABSOLUTE       = -1,
+    DIRID_NULL           = 0,
+    DIRID_SRCPATH        = 1,
+    DIRID_WINDOWS        = 10,
+    DIRID_SYSTEM         = 11,
+    DIRID_DRIVERS        = 12,
+    DIRID_IOSUBSYS       = DIRID_DRIVERS,
+    DIRID_INF            = 17,
+    DIRID_HELP           = 18,
+    DIRID_FONTS          = 20,
+    DIRID_VIEWERS        = 21,
+    DIRID_COLOR          = 23,
+    DIRID_APPS           = 24,
+    DIRID_SHARED         = 25,
+    DIRID_BOOT           = 30,
+    DIRID_SYSTEM16       = 50,
+    DIRID_SPOOL          = 51,
+    DIRID_SPOOLDRIVERS   = 52,
+    DIRID_USERPROFILE    = 53,
+    DIRID_LOADER         = 54,
+    DIRID_PRINTPROCESSOR = 55,
+    DIRID_DEFAULT        = DIRID_SYSTEM
+}
+
+enum : int {
+    DIRID_COMMON_STARTMENU        = 16406,
+    DIRID_COMMON_PROGRAMS         = 16407,
+    DIRID_COMMON_STARTUP          = 16408,
+    DIRID_COMMON_DESKTOPDIRECTORY = 16409,
+    DIRID_COMMON_FAVORITES        = 16415,
+    DIRID_COMMON_APPDATA          = 16419,
+    DIRID_PROGRAM_FILES           = 16422,
+    DIRID_SYSTEM_X86              = 16425,
+    DIRID_PROGRAM_FILES_X86       = 16426,
+    DIRID_PROGRAM_FILES_COMMON    = 16427,
+    DIRID_PROGRAM_FILES_COMMONX86 = 16428,
+    DIRID_COMMON_TEMPLATES        = 16429,
+    DIRID_COMMON_DOCUMENTS        = 16430,
+    DIRID_USER                    = 0x8000,
+    DIRID_ABSOLUTE_16BIT          = 0xffff
+}
+
+enum : DWORD {
+    DMI_MASK    = 0x00000001,
+    DMI_BKCOLOR = 0x00000002,
+    DMI_USERECT = 0x00000004
+}
+
+enum : DWORD {
+    DNF_DUPDESC           = 0x00000001,
+    DNF_OLDDRIVER         = 0x00000002,
+    DNF_EXCLUDEFROMLIST   = 0x00000004,
+    DNF_NODRIVER          = 0x00000008,
+    DNF_LEGACYINF         = 0x00000010,
+    DNF_CLASS_DRIVER      = 0x00000020,
+    DNF_COMPATIBLE_DRIVER = 0x00000040,
+    DNF_INET_DRIVER       = 0x00000080,
+    DNF_UNUSED1           = 0x00000100,
+    DNF_INDEXED_DRIVER    = 0x00000200,
+    DNF_OLD_INET_DRIVER   = 0x00000400,
+    DNF_BAD_DRIVER        = 0x00000800,
+    DNF_DUPPROVIDER       = 0x00001000
+}
+
+enum : UINT {
+    DPROMPT_SUCCESS,
+    DPROMPT_CANCEL,
+    DPROMPT_SKIPFILE,
+    DPROMPT_BUFFERTOOSMALL,
+    DPROMPT_OUTOFMEMORY // = 4
+}
+
+enum : DWORD {
+    DRIVER_HARDWAREID_RANK             = 0x00000FFF,
+    DRIVER_COMPATID_RANK               = 0x00003FFF,
+    DRIVER_UNTRUSTED_RANK              = 0x00008000,
+    DRIVER_UNTRUSTED_HARDWAREID_RANK   = 0x00008FFF,
+    DRIVER_UNTRUSTED_COMPATID_RANK     = 0x0000BFFF,
+    DRIVER_W9X_SUSPECT_RANK            = 0x0000C000,
+    DRIVER_W9X_SUSPECT_HARDWAREID_RANK = 0x0000CFFF,
+    DRIVER_W9X_SUSPECT_COMPATID_RANK   = 0x0000FFFF
+}
+
+enum : DWORD {
+    DYNAWIZ_FLAG_PAGESADDED             = 0x00000001,
+    DYNAWIZ_FLAG_INSTALLDET_NEXT        = 0x00000002,
+    DYNAWIZ_FLAG_INSTALLDET_PREV        = 0x00000004,
+    DYNAWIZ_FLAG_ANALYZE_HANDLECONFLICT = 0x00000008
+}
+
+enum : WORD {
+    ENABLECLASS_QUERY,
+    ENABLECLASS_SUCCESS,
+    ENABLECLASS_FAILURE // = 2
+}
+
+enum : DWORD {
+    ERROR_EXPECTED_SECTION_NAME       = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0,
+    ERROR_BAD_SECTION_NAME_LINE       = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 1,
+    ERROR_SECTION_NAME_TOO_LONG       = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 2,
+    ERROR_GENERAL_SYNTAX              = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 3,
+    ERROR_WRONG_INF_STYLE             = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x100,
+    ERROR_NOT_INSTALLED               = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x1000,
+    ERROR_SECTION_NOT_FOUND           = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x101,
+    ERROR_LINE_NOT_FOUND              = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x102,
+    ERROR_NO_BACKUP                   = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x103,
+    ERROR_NO_ASSOCIATED_CLASS         = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x200,
+    ERROR_CLASS_MISMATCH              = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x201,
+    ERROR_DUPLICATE_FOUND             = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x202,
+    ERROR_NO_DRIVER_SELECTED          = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x203,
+    ERROR_KEY_DOES_NOT_EXIST          = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x204,
+    ERROR_INVALID_DEVINST_NAME        = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x205,
+    ERROR_INVALID_CLASS               = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x206,
+    ERROR_DEVINST_ALREADY_EXISTS      = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x207,
+    ERROR_DEVINFO_NOT_REGISTERED      = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x208,
+    ERROR_INVALID_REG_PROPERTY        = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x209,
+    ERROR_NO_INF                      = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20A,
+    ERROR_NO_SUCH_DEVINST             = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20B,
+    ERROR_CANT_LOAD_CLASS_ICON        = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20C,
+    ERROR_INVALID_CLASS_INSTALLER     = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20D,
+    ERROR_DI_DO_DEFAULT               = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20E,
+    ERROR_DI_NOFILECOPY               = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x20F,
+    ERROR_INVALID_HWPROFILE           = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x210,
+    ERROR_NO_DEVICE_SELECTED          = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x211,
+    ERROR_DEVINFO_LIST_LOCKED         = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x212,
+    ERROR_DEVINFO_DATA_LOCKED         = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x213,
+    ERROR_DI_BAD_PATH                 = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x214,
+    ERROR_NO_CLASSINSTALL_PARAMS      = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x215,
+    ERROR_FILEQUEUE_LOCKED            = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x216,
+    ERROR_BAD_SERVICE_INSTALLSECT     = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x217,
+    ERROR_NO_CLASS_DRIVER_LIST        = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x218,
+    ERROR_NO_ASSOCIATED_SERVICE       = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x219,
+    ERROR_NO_DEFAULT_DEVICE_INTERFACE = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x21A,
+    ERROR_DEVICE_INTERFACE_ACTIVE     = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x21B,
+    ERROR_DEVICE_INTERFACE_REMOVED    = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x21C,
+    ERROR_BAD_INTERFACE_INSTALLSECT   = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x21D,
+    ERROR_NO_SUCH_INTERFACE_CLASS     = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x21E,
+    ERROR_INVALID_REFERENCE_STRING    = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x21F,
+    ERROR_INVALID_MACHINENAME         = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x220,
+    ERROR_REMOTE_COMM_FAILURE         = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x221,
+    ERROR_MACHINE_UNAVAILABLE         = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x222,
+    ERROR_NO_CONFIGMGR_SERVICES       = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x223,
+    ERROR_INVALID_PROPPAGE_PROVIDER   = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x224,
+    ERROR_NO_SUCH_DEVICE_INTERFACE    = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x225,
+    ERROR_DI_POSTPROCESSING_REQUIRED  = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x226,
+    ERROR_INVALID_COINSTALLER         = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x227,
+    ERROR_NO_COMPAT_DRIVERS           = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x228,
+    ERROR_NO_DEVICE_ICON              = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x229,
+    ERROR_INVALID_INF_LOGCONFIG       = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22A,
+    ERROR_DI_DONT_INSTALL             = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22B,
+    ERROR_INVALID_FILTER_DRIVER       = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22C,
+    ERROR_NON_WINDOWS_NT_DRIVER       = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22D,
+    ERROR_NON_WINDOWS_DRIVER          = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22E,
+    ERROR_NO_CATALOG_FOR_OEM_INF      = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x22F,
+    ERROR_DEVINSTALL_QUEUE_NONNATIVE  = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x230,
+    ERROR_NOT_DISABLEABLE             = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x231,
+    ERROR_CANT_REMOVE_DEVINST         = APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x232
+}
+
+deprecated enum : DWORD {
+    ERROR_NO_DEFAULT_INTERFACE_DEVICE = ERROR_NO_DEFAULT_DEVICE_INTERFACE,
+    ERROR_INTERFACE_DEVICE_ACTIVE     = ERROR_DEVICE_INTERFACE_ACTIVE,
+    ERROR_INTERFACE_DEVICE_REMOVED    = ERROR_DEVICE_INTERFACE_REMOVED,
+    ERROR_NO_SUCH_INTERFACE_DEVICE    = ERROR_NO_SUCH_DEVICE_INTERFACE,
+}
+
+enum : UINT {
+    FILEOP_COPY,
+    FILEOP_RENAME,
+    FILEOP_DELETE,
+    FILEOP_BACKUP,
+    FILEOP_NEWPATH, // = 4
+    FILEOP_ABORT = 0,
+    FILEOP_DOIT,
+    FILEOP_SKIP, // = 2
+    FILEOP_RETRY = FILEOP_DOIT
+}
+
+enum : UINT {
+    FILE_COMPRESSION_NONE,
+    FILE_COMPRESSION_WINLZA,
+    FILE_COMPRESSION_MSZIP,
+    FILE_COMPRESSION_NTCAB // = 3
+}
+
+enum : DWORD {
+    FLG_ADDREG_TYPE_SZ        = 0x00000000,
+    FLG_ADDREG_BINVALUETYPE   = 0x00000001,
+    FLG_ADDREG_NOCLOBBER      = 0x00000002,
+    FLG_ADDREG_DELVAL         = 0x00000004,
+    FLG_ADDREG_APPEND         = 0x00000008,
+    FLG_ADDREG_KEYONLY        = 0x00000010,
+    FLG_ADDREG_OVERWRITEONLY  = 0x00000020,
+    FLG_ADDREG_TYPE_MULTI_SZ  = 0x00010000,
+    FLG_ADDREG_TYPE_EXPAND_SZ = 0x00020000,
+    FLG_ADDREG_TYPE_BINARY    = 0x00000000 | FLG_ADDREG_BINVALUETYPE,
+    FLG_ADDREG_TYPE_DWORD     = 0x00010000 | FLG_ADDREG_BINVALUETYPE,
+    FLG_ADDREG_TYPE_NONE      = 0x00020000 | FLG_ADDREG_BINVALUETYPE,
+    FLG_ADDREG_TYPE_MASK      = 0xFFFF0000 | FLG_ADDREG_BINVALUETYPE
+}
+
+static if(_SETUPAPI_VER >= 0x0501) {
+    enum : DWORD {
+        FLG_ADDREG_64BITKEY       = 0x00001000,
+        FLG_ADDREG_KEYONLY_COMMON = 0x00002000,
+        FLG_ADDREG_32BITKEY       = 0x00004000,
+        FLG_ADDREG_DELREG_BIT     = 0x00008000
+    }
+}
+
+enum : DWORD {
+    FLG_DELREG_VALUE = 0x00000000
+}
+
+static if(_SETUPAPI_VER >= 0x0501) {
+    enum : DWORD {
+        FLG_DELREG_TYPE_MASK          = FLG_ADDREG_TYPE_MASK,
+        FLG_DELREG_TYPE_SZ            = FLG_ADDREG_TYPE_SZ,
+        FLG_DELREG_TYPE_MULTI_SZ      = FLG_ADDREG_TYPE_MULTI_SZ,
+        FLG_DELREG_TYPE_EXPAND_SZ     = FLG_ADDREG_TYPE_EXPAND_SZ,
+        FLG_DELREG_TYPE_BINARY        = FLG_ADDREG_TYPE_BINARY,
+        FLG_DELREG_TYPE_DWORD         = FLG_ADDREG_TYPE_DWORD,
+        FLG_DELREG_TYPE_NONE          = FLG_ADDREG_TYPE_NONE,
+        FLG_DELREG_64BITKEY           = FLG_ADDREG_64BITKEY,
+        FLG_DELREG_KEYONLY_COMMON     = FLG_ADDREG_KEYONLY_COMMON,
+        FLG_DELREG_32BITKEY           = FLG_ADDREG_32BITKEY,
+        FLG_DELREG_OPERATION_MASK     = 0x000000FE,
+        FLG_DELREG_MULTI_SZ_DELSTRING = 0x00000002 | FLG_DELREG_TYPE_MULTI_SZ | FLG_ADDREG_DELREG_BIT
+    }
+}
+
+enum : DWORD {
+    FLG_BITREG_CLEARBITS = 0x00000000,
+    FLG_BITREG_SETBITS   = 0x00000001
+}
+
+static if(_SETUPAPI_VER >= 0x0501) {
+    enum : DWORD {
+        FLG_BITREG_64BITKEY = 0x00001000,
+        FLG_BITREG_32BITKEY = 0x00004000
+    }
+}
+
+enum : DWORD {
+    FLG_PROFITEM_CURRENTUSER = 0x00000001,
+    FLG_PROFITEM_DELETE      = 0x00000002,
+    FLG_PROFITEM_GROUP       = 0x00000004,
+    FLG_PROFITEM_CSIDL       = 0x00000008
+}
+
+enum : DWORD {
+    FLG_REGSVR_DLLREGISTER = 0x00000001,
+    FLG_REGSVR_DLLINSTALL  = 0x00000002
+}
+
+enum {
+    IDD_DYNAWIZ_FIRSTPAGE = 10000,
+    IDD_DYNAWIZ_SELECT_PREVPAGE,
+    IDD_DYNAWIZ_SELECT_NEXTPAGE,
+    IDD_DYNAWIZ_ANALYZE_PREVPAGE,
+    IDD_DYNAWIZ_ANALYZE_NEXTPAGE, // = 1004
+    IDD_DYNAWIZ_INSTALLDETECTED_PREVPAGE = 10006,
+    IDD_DYNAWIZ_INSTALLDETECTED_NEXTPAGE,
+    IDD_DYNAWIZ_INSTALLDETECTED_NODEVS,
+    IDD_DYNAWIZ_SELECTDEV_PAGE,
+    IDD_DYNAWIZ_ANALYZEDEV_PAGE,
+    IDD_DYNAWIZ_INSTALLDETECTEDDEVS_PAGE,
+    IDD_DYNAWIZ_SELECTCLASS_PAGE, // = 10012
+    MIN_IDD_DYNAWIZ_RESOURCE_ID = 10000,
+    MAX_IDD_DYNAWIZ_RESOURCE_ID = 11000
+}
+
+enum : DWORD {
+    IDF_NOBROWSE     = 0x00000001,
+    IDF_NOSKIP       = 0x00000002,
+    IDF_NODETAILS    = 0x00000004,
+    IDF_NOCOMPRESSED = 0x00000008,
+    IDF_CHECKFIRST   = 0x00000100,
+    IDF_NOBEEP       = 0x00000200,
+    IDF_NOFOREGROUND = 0x00000400,
+    IDF_WARNIFSKIP   = 0x00000800
+}
+
+static if(_SETUPAPI_VER >= 0x0501) {
+    enum : DWORD {
+        IDF_NOREMOVABLEMEDIAPROMPT = 0x00001000,
+        IDF_USEDISKNAMEASPROMPT    = 0x00002000,
+        IDF_OEMDISK                = 0x80000000
+    }
+}
+
+enum {
+    IDI_RESOURCEFIRST          = 159,
+    IDI_RESOURCE               = 159,
+    IDI_RESOURCELAST           = 161,
+    IDI_RESOURCEOVERLAYFIRST   = 161,
+    IDI_RESOURCEOVERLAYLAST    = 161,
+    IDI_CONFLICT               = 161,
+    IDI_PROBLEM_OVL            = 500,
+    IDI_DISABLED_OVL           = 501,
+    IDI_FORCED_OVL             = 502,
+    IDI_CLASSICON_OVERLAYFIRST = 500,
+    IDI_CLASSICON_OVERLAYLAST  = 502
+}
+
+enum : DWORD {
+    INF_STYLE_NONE          = 0x00000000,
+    INF_STYLE_OLDNT         = 0x00000001,
+    INF_STYLE_WIN4          = 0x00000002,
+    INF_STYLE_CACHE_ENABLE  = 0x00000010,
+    INF_STYLE_CACHE_DISABLE = 0x00000020
+}
+
+enum : DWORD {
+    INFINFO_INF_SPEC_IS_HINF = 1,
+    INFINFO_INF_NAME_IS_ABSOLUTE,
+    INFINFO_DEFAULT_SEARCH,
+    INFINFO_REVERSE_DEFAULT_SEARCH,
+    INFINFO_INF_PATH_LIST_SEARCH // = 5
+}
+
+alias DWORD LogSeverity;
+enum : LogSeverity {
+    LogSevInformation,
+    LogSevWarning,
+    LogSevError,
+    LogSevFatalError,
+    LogSevMaximum // = 4
+}
+
+enum MAX_INSTALLWIZARD_DYNAPAGES = 20;
+
+enum : DWORD {
+    NDW_INSTALLFLAG_DIDFACTDEFS        = 0x00000001,
+    NDW_INSTALLFLAG_HARDWAREALLREADYIN = 0x00000002,
+    NDW_INSTALLFLAG_NEEDSHUTDOWN       = 0x00000200,
+    NDW_INSTALLFLAG_EXPRESSINTRO       = 0x00000400,
+    NDW_INSTALLFLAG_SKIPISDEVINSTALLED = 0x00000800,
+    NDW_INSTALLFLAG_NODETECTEDDEVS     = 0x00001000,
+    NDW_INSTALLFLAG_INSTALLSPECIFIC    = 0x00002000,
+    NDW_INSTALLFLAG_SKIPCLASSLIST      = 0x00004000,
+    NDW_INSTALLFLAG_CI_PICKED_OEM      = 0x00008000,
+    NDW_INSTALLFLAG_PCMCIAMODE         = 0x00010000,
+    NDW_INSTALLFLAG_PCMCIADEVICE       = 0x00020000,
+    NDW_INSTALLFLAG_USERCANCEL         = 0x00040000,
+    NDW_INSTALLFLAG_KNOWNCLASS         = 0x00080000,
+    NDW_INSTALLFLAG_NEEDRESTART        = 0x00000080,
+    NDW_INSTALLFLAG_NEEDREBOOT         = 0x00000100
+}
+
+enum : DWORD {
+    SETDIRID_NOT_FULL_PATH = 0x00000001
+}
+
+enum : DWORD {
+    SP_COPY_DELETESOURCE        = 0x0000001,
+    SP_COPY_REPLACEONLY         = 0x0000002,
+    SP_COPY_NEWER               = 0x0000004,
+    SP_COPY_NEWER_OR_SAME       = 0x0000004,
+    SP_COPY_NOOVERWRITE         = 0x0000008,
+    SP_COPY_NODECOMP            = 0x0000010,
+    SP_COPY_LANGUAGEAWARE       = 0x0000020,
+    SP_COPY_SOURCE_ABSOLUTE     = 0x0000040,
+    SP_COPY_SOURCEPATH_ABSOLUTE = 0x0000080,
+    SP_COPY_IN_USE_NEEDS_REBOOT = 0x0000100,
+    SP_COPY_FORCE_IN_USE        = 0x0000200,
+    SP_COPY_NOSKIP              = 0x0000400,
+    SP_FLAG_CABINETCONTINUATION = 0x0000800,
+    SP_COPY_FORCE_NOOVERWRITE   = 0x0001000,
+    SP_COPY_FORCE_NEWER         = 0x0002000,
+    SP_COPY_WARNIFSKIP          = 0x0004000,
+    SP_COPY_NOBROWSE            = 0x0008000,
+    SP_COPY_NEWER_ONLY          = 0x0010000,
+    SP_COPY_SOURCE_SIS_MASTER   = 0x0020000,
+    SP_COPY_OEMINF_CATALOG_ONLY = 0x0040000,
+    SP_COPY_REPLACE_BOOT_FILE   = 0x0080000,
+    SP_COPY_NOPRUNE             = 0x0100000
+}
+
+static if(_SETUPAPI_VER >= 0x0501) {
+    enum : DWORD {
+        SP_COPY_OEM_F6_INF = 0x0200000
+    }
+}
+
+enum : DWORD {
+    SPCRP_SECURITY = 23,
+    SPCRP_SECURITY_SDS,
+    SPCRP_DEVTYPE,
+    SPCRP_EXCLUSIVE,
+    SPCRP_CHARACTERISTICS,
+    SPCRP_MAXIMUM_PROPERTY // = 28
+}
+
+enum : DWORD {
+    SPDIT_NODRIVER,
+    SPDIT_CLASSDRIVER,
+    SPDIT_COMPATDRIVER // = 2
+}
+
+enum : DWORD {
+    SPDRP_DEVICEDESC,
+    SPDRP_HARDWAREID,
+    SPDRP_COMPATIBLEIDS,
+    SPDRP_UNUSED0,
+    SPDRP_SERVICE,
+    SPDRP_UNUSED1,
+    SPDRP_UNUSED2,
+    SPDRP_CLASS,
+    SPDRP_CLASSGUID,
+    SPDRP_DRIVER,
+    SPDRP_CONFIGFLAGS,
+    SPDRP_MFG,
+    SPDRP_FRIENDLYNAME,
+    SPDRP_LOCATION_INFORMATION,
+    SPDRP_PHYSICAL_DEVICE_OBJECT_NAME,
+    SPDRP_CAPABILITIES,
+    SPDRP_UI_NUMBER,
+    SPDRP_UPPERFILTERS,
+    SPDRP_LOWERFILTERS,
+    SPDRP_BUSTYPEGUID,
+    SPDRP_LEGACYBUSTYPE,
+    SPDRP_BUSNUMBER,
+    SPDRP_ENUMERATOR_NAME,
+    SPDRP_SECURITY,
+    SPDRP_SECURITY_SDS,
+    SPDRP_DEVTYPE,
+    SPDRP_EXCLUSIVE,
+    SPDRP_CHARACTERISTICS,
+    SPDRP_ADDRESS, // = 28
+    SPDRP_UI_NUMBER_DESC_FORMAT = 30,
+    SPDRP_MAXIMUM_PROPERTY      = 31
+}
+
+enum : UINT {
+    SPDSL_IGNORE_DISK = 1,
+    SPDSL_DISALLOW_NEGATIVE_ADJUST
+}
+
+enum : UINT {
+    SPFILENOTIFY_STARTQUEUE = 1,
+    SPFILENOTIFY_ENDQUEUE,
+    SPFILENOTIFY_STARTSUBQUEUE,
+    SPFILENOTIFY_ENDSUBQUEUE,
+    SPFILENOTIFY_STARTDELETE,
+    SPFILENOTIFY_ENDDELETE,
+    SPFILENOTIFY_DELETEERROR,
+    SPFILENOTIFY_STARTRENAME,
+    SPFILENOTIFY_ENDRENAME,
+    SPFILENOTIFY_RENAMEERROR,
+    SPFILENOTIFY_STARTCOPY,
+    SPFILENOTIFY_ENDCOPY,
+    SPFILENOTIFY_COPYERROR,
+    SPFILENOTIFY_NEEDMEDIA,
+    SPFILENOTIFY_QUEUESCAN,
+    SPFILENOTIFY_CABINETINFO,
+    SPFILENOTIFY_FILEINCABINET,
+    SPFILENOTIFY_NEEDNEWCABINET,
+    SPFILENOTIFY_FILEEXTRACTED,
+    SPFILENOTIFY_FILEOPDELAYED,
+    SPFILENOTIFY_STARTBACKUP,
+    SPFILENOTIFY_BACKUPERROR,
+    SPFILENOTIFY_ENDBACKUP,
+    SPFILENOTIFY_QUEUESCAN_EX,
+    SPFILENOTIFY_STARTREGISTRATION, // = 25
+    SPFILENOTIFY_ENDREGISTRATION = 32,
+    SPFILENOTIFY_LANGMISMATCH    = 0x00010000,
+    SPFILENOTIFY_TARGETEXISTS    = 0x00020000,
+    SPFILENOTIFY_TARGETNEWER     = 0x00040000
+}
+
+static if(_SETUPAPI_VER >= 0x0501) {
+    enum : UINT {
+        SPFILENOTIFY_QUEUESCAN_SIGNERINFO = 0x00000040
+    }
+}
+
+enum : DWORD {
+    SPFILELOG_SYSTEMLOG = 0x00000001,
+    SPFILELOG_OEMFILE   = 0x00000001,
+    SPFILELOG_FORCENEW  = 0x00000002,
+    SPFILELOG_QUERYONLY = 0x00000004
+}
+
+enum : INT {
+    SPFILEQ_FILE_IN_USE        = 0x00000001,
+    SPFILEQ_REBOOT_RECOMMENDED = 0x00000002,
+    SPFILEQ_REBOOT_IN_PROGRESS = 0x00000004
+}
+
+enum : DWORD {
+    SPINT_ACTIVE  = 0x00000001,
+    SPINT_DEFAULT = 0x00000002,
+    SPINT_REMOVED = 0x00000004
+}
+
+deprecated enum : DWORD {
+    SPID_ACTIVE  = SPINT_ACTIVE,
+    SPID_DEFAULT = SPINT_DEFAULT,
+    SPID_REMOVED = SPINT_REMOVED
+}
+
+enum : UINT {
+    SPINST_LOGCONFIG                = 0x00000001,
+    SPINST_INIFILES                 = 0x00000002,
+    SPINST_REGISTRY                 = 0x00000004,
+    SPINST_INI2REG                  = 0x00000008,
+    SPINST_FILES                    = 0x00000010,
+    SPINST_BITREG                   = 0x00000020,
+    SPINST_REGSVR                   = 0x00000040,
+    SPINST_UNREGSVR                 = 0x00000080,
+    SPINST_PROFILEITEMS             = 0x00000100,
+    SPINST_SINGLESECTION            = 0x00010000,
+    SPINST_LOGCONFIG_IS_FORCED      = 0x00020000,
+    SPINST_LOGCONFIGS_ARE_OVERRIDES = 0x00040000
+}
+
+static if(_SETUPAPI_VER >= 0x0501) {
+    enum : UINT {
+        SPINST_COPYINF               = 0x00000200,
+        SPINST_ALL                   = 0x000003ff,
+        SPINST_REGISTERCALLBACKAWARE = 0x00080000
+    }
+} else {
+    enum : UINT {
+        SPINST_ALL = 0x000001ff
+    }
+}
+
+enum : DWORD {
+    SPOST_NONE,
+    SPOST_PATH,
+    SPOST_URL,
+    SPOST_MAX // = 3
+}
+
+enum : DWORD {
+    SPPSR_SELECT_DEVICE_RESOURCES = 1,
+    SPPSR_ENUM_BASIC_DEVICE_PROPERTIES,
+    SPPSR_ENUM_ADV_DEVICE_PROPERTIES
+}
+
+enum : DWORD {
+    SPQ_SCAN_FILE_PRESENCE    = 0x00000001,
+    SPQ_SCAN_FILE_VALIDITY    = 0x00000002,
+    SPQ_SCAN_USE_CALLBACK     = 0x00000004,
+    SPQ_SCAN_USE_CALLBACKEX   = 0x00000008,
+    SPQ_SCAN_INFORM_USER      = 0x00000010,
+    SPQ_SCAN_PRUNE_COPY_QUEUE = 0x00000020
+}
+
+static if(_SETUPAPI_VER >= 0x0501) {
+    enum : DWORD {
+        SPQ_SCAN_USE_CALLBACK_SIGNERINFO = 0x00000040,
+        SPQ_SCAN_PRUNE_DELREN            = 0x00000080
+    }
+}
+
+enum : UINT_PTR {
+    SPQ_DELAYED_COPY = 0x00000001
+}
+
+enum : DWORD {
+    SPRDI_FIND_DUPS = 0x00000001,
+}
+
+enum : DWORD {
+    SPSVCINST_TAGTOFRONT               = 0x00000001,
+    SPSVCINST_ASSOCSERVICE             = 0x00000002,
+    SPSVCINST_DELETEEVENTLOGENTRY      = 0x00000004,
+    SPSVCINST_NOCLOBBER_DISPLAYNAME    = 0x00000008,
+    SPSVCINST_NOCLOBBER_STARTTYPE      = 0x00000010,
+    SPSVCINST_NOCLOBBER_ERRORCONTROL   = 0x00000020,
+    SPSVCINST_NOCLOBBER_LOADORDERGROUP = 0x00000040,
+    SPSVCINST_NOCLOBBER_DEPENDENCIES   = 0x00000080,
+    SPSVCINST_NOCLOBBER_DESCRIPTION    = 0x00000100,
+    SPSVCINST_STOPSERVICE              = 0x00000200
+}
+
+static if(_SETUPAPI_VER >= 0x0501) {
+    enum : DWORD {
+        SPSVCINST_CLOBBER_SECURITY = 0x00000400
+    }
+}
+
+enum : DWORD {
+    SPWPT_SELECTDEVICE = 0x00000001
+}
+
+enum : DWORD {
+    SPWP_USE_DEVINFO_DATA = 0x00000001
+}
+
+enum : UINT {
+    SRCINFO_PATH = 1,
+    SRCINFO_TAGFILE,
+    SRCINFO_DESCRIPTION,
+    SRCINFO_FLAGS // = 4
+}
+
+enum : DWORD {
+    SRCLIST_TEMPORARY       = 0x00000001,
+    SRCLIST_NOBROWSE        = 0x00000002,
+    SRCLIST_SYSTEM          = 0x00000010,
+    SRCLIST_USER            = 0x00000020,
+    SRCLIST_SYSIFADMIN      = 0x00000040,
+    SRCLIST_SUBDIRS         = 0x00000100,
+    SRCLIST_APPEND          = 0x00000200,
+    SRCLIST_NOSTRIPPLATFORM = 0x00000400
+}
+
+alias PVOID HINF;
+alias PVOID HDSKSPC;
+mixin DECLARE_HANDLE!("HDEVINFO");
+alias PVOID HSPFILEQ;
+alias PVOID HSPFILELOG;
+
+enum SetupFileLogInfo {
+    SetupFileLogSourceFilename,
+    SetupFileLogChecksum,
+    SetupFileLogDiskTagfile,
+    SetupFileLogDiskDescription,
+    SetupFileLogOtherInfo,
+    SetupFileLogMax
+}
+
+align(1):
+
+struct INFCONTEXT {
+    PVOID Inf;
+    PVOID CurrentInf;
+    UINT  Section;
+    UINT  Line;
+}
+alias INFCONTEXT* PINFCONTEXT;
+
+struct SP_INF_INFORMATION {
+    DWORD InfStyle;
+    DWORD InfCount;
+    BYTE[1] _VersionData;
+    BYTE* VersionData() return { return _VersionData.ptr; }
+}
+alias SP_INF_INFORMATION* PSP_INF_INFORMATION;
+
+struct SP_ALTPLATFORM_INFO {
+    DWORD cbSize = SP_ALTPLATFORM_INFO.sizeof;
+    DWORD Platform;
+    DWORD MajorVersion;
+    DWORD MinorVersion;
+    WORD  ProcessorArchitecture;
+    WORD  Reserved;
+}
+alias SP_ALTPLATFORM_INFO* PSP_ALTPLATFORM_INFO;
+
+struct SP_ORIGINAL_FILE_INFO_A {
+    DWORD cbSize = SP_ORIGINAL_FILE_INFO_A.sizeof;
+    CHAR[MAX_PATH] OriginalInfName;
+    CHAR[MAX_PATH] OriginalCatalogName;
+}
+alias SP_ORIGINAL_FILE_INFO_A* PSP_ORIGINAL_FILE_INFO_A;
+
+struct SP_ORIGINAL_FILE_INFO_W {
+    DWORD cbSize = SP_ORIGINAL_FILE_INFO_W.sizeof;
+    WCHAR[MAX_PATH] OriginalInfName;
+    WCHAR[MAX_PATH] OriginalCatalogName;
+}
+alias SP_ORIGINAL_FILE_INFO_W* PSP_ORIGINAL_FILE_INFO_W;
+
+struct FILEPATHS_A {
+    PCSTR Target;
+    PCSTR Source;
+    UINT  Win32Error;
+    DWORD Flags;
+}
+alias FILEPATHS_A* PFILEPATHS_A;
+
+struct FILEPATHS_W {
+    PCWSTR Target;
+    PCWSTR Source;
+    UINT   Win32Error;
+    DWORD  Flags;
+}
+alias FILEPATHS_W* PFILEPATHS_W;
+
+struct SOURCE_MEDIA_A {
+    PCSTR Reserved;
+    PCSTR Tagfile;
+    PCSTR Description;
+    PCSTR SourcePath;
+    PCSTR SourceFile;
+    DWORD Flags;
+}
+alias SOURCE_MEDIA_A* PSOURCE_MEDIA_A;
+
+struct SOURCE_MEDIA_W {
+    PCWSTR Reserved;
+    PCWSTR Tagfile;
+    PCWSTR Description;
+    PCWSTR SourcePath;
+    PCWSTR SourceFile;
+    DWORD  Flags;
+}
+alias SOURCE_MEDIA_W* PSOURCE_MEDIA_W;
+
+struct CABINET_INFO_A {
+    PCSTR  CabinetPath;
+    PCSTR  CabinetFile;
+    PCSTR  DiskName;
+    USHORT SetId;
+    USHORT CabinetNumber;
+}
+alias CABINET_INFO_A* PCABINET_INFO_A;
+
+struct CABINET_INFO_W {
+    PCWSTR CabinetPath;
+    PCWSTR CabinetFile;
+    PCWSTR DiskName;
+    USHORT SetId;
+    USHORT CabinetNumber;
+}
+alias CABINET_INFO_W* PCABINET_INFO_W;
+
+struct FILE_IN_CABINET_INFO_A {
+    PCSTR NameInCabinet;
+    DWORD FileSize;
+    DWORD Win32Error;
+    WORD  DosDate;
+    WORD  DosTime;
+    WORD  DosAttribs;
+    CHAR[MAX_PATH] FullTargetName;
+}
+alias FILE_IN_CABINET_INFO_A* PFILE_IN_CABINET_INFO_A;
+
+struct FILE_IN_CABINET_INFO_W {
+    PCWSTR NameInCabinet;
+    DWORD  FileSize;
+    DWORD  Win32Error;
+    WORD   DosDate;
+    WORD   DosTime;
+    WORD   DosAttribs;
+    WCHAR[MAX_PATH] FullTargetName;
+}
+alias FILE_IN_CABINET_INFO_W* PFILE_IN_CABINET_INFO_W;
+
+struct SP_FILE_COPY_PARAMS_A {
+    DWORD    cbSize = SP_FILE_COPY_PARAMS_A.sizeof;
+    HSPFILEQ QueueHandle;
+    PCSTR    SourceRootPath;
+    PCSTR    SourcePath;
+    PCSTR    SourceFilename;
+    PCSTR    SourceDescription;
+    PCSTR    SourceTagfile;
+    PCSTR    TargetDirectory;
+    PCSTR    TargetFilename;
+    DWORD    CopyStyle;
+    HINF     LayoutInf;
+    PCSTR    SecurityDescriptor;
+}
+alias SP_FILE_COPY_PARAMS_A* PSP_FILE_COPY_PARAMS_A;
+
+struct SP_FILE_COPY_PARAMS_W {
+    DWORD    cbSize = SP_FILE_COPY_PARAMS_W.sizeof;
+    HSPFILEQ QueueHandle;
+    PCWSTR   SourceRootPath;
+    PCWSTR   SourcePath;
+    PCWSTR   SourceFilename;
+    PCWSTR   SourceDescription;
+    PCWSTR   SourceTagfile;
+    PCWSTR   TargetDirectory;
+    PCWSTR   TargetFilename;
+    DWORD    CopyStyle;
+    HINF     LayoutInf;
+    PCWSTR   SecurityDescriptor;
+}
+alias SP_FILE_COPY_PARAMS_W* PSP_FILE_COPY_PARAMS_W;
+
+struct SP_DEVINFO_DATA {
+    DWORD     cbSize = SP_DEVINFO_DATA.sizeof;
+    GUID      ClassGuid;
+    DWORD     DevInst;
+    ULONG_PTR Reserved;
+}
+alias SP_DEVINFO_DATA* PSP_DEVINFO_DATA;
+
+struct SP_DEVICE_INTERFACE_DATA {
+    DWORD     cbSize = SP_DEVICE_INTERFACE_DATA.sizeof;
+    GUID      InterfaceClassGuid;
+    DWORD     Flags;
+    ULONG_PTR Reserved;
+}
+alias SP_DEVICE_INTERFACE_DATA* PSP_DEVICE_INTERFACE_DATA;
+deprecated alias SP_DEVICE_INTERFACE_DATA SP_INTERFACE_DEVICE_DATA;
+deprecated alias SP_DEVICE_INTERFACE_DATA* PSP_INTERFACE_DEVICE_DATA;
+
+struct SP_DEVICE_INTERFACE_DETAIL_DATA_A {
+    DWORD cbSize = SP_DEVICE_INTERFACE_DETAIL_DATA_A.sizeof;
+    CHAR[1] _DevicePath;
+    CHAR* DevicePath() return { return _DevicePath.ptr; }
+}
+alias SP_DEVICE_INTERFACE_DETAIL_DATA_A* PSP_DEVICE_INTERFACE_DETAIL_DATA_A;
+
+struct SP_DEVICE_INTERFACE_DETAIL_DATA_W {
+    DWORD  cbSize = SP_DEVICE_INTERFACE_DETAIL_DATA_W.sizeof;
+    WCHAR[1] _DevicePath;
+    WCHAR* DevicePath() return { return _DevicePath.ptr; }
+}
+alias SP_DEVICE_INTERFACE_DETAIL_DATA_W* PSP_DEVICE_INTERFACE_DETAIL_DATA_W;
+
+deprecated alias SP_DEVICE_INTERFACE_DETAIL_DATA_A SP_INTERFACE_DEVICE_DETAIL_DATA_A;
+deprecated alias SP_DEVICE_INTERFACE_DETAIL_DATA_A* PSP_INTERFACE_DEVICE_DETAIL_DATA_A;
+deprecated alias SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_INTERFACE_DEVICE_DETAIL_DATA_W;
+deprecated alias SP_DEVICE_INTERFACE_DETAIL_DATA_W* PSP_INTERFACE_DEVICE_DETAIL_DATA_W;
+
+struct SP_DEVINFO_LIST_DETAIL_DATA_A {
+    DWORD  cbSize = SP_DEVINFO_LIST_DETAIL_DATA_A.sizeof;
+    GUID   ClassGuid;
+    HANDLE RemoteMachineHandle;
+    CHAR[SP_MAX_MACHINENAME_LENGTH] RemoteMachineName;
+}
+alias SP_DEVINFO_LIST_DETAIL_DATA_A* PSP_DEVINFO_LIST_DETAIL_DATA_A;
+
+struct SP_DEVINFO_LIST_DETAIL_DATA_W {
+    DWORD  cbSize = SP_DEVINFO_LIST_DETAIL_DATA_W.sizeof;
+    GUID   ClassGuid;
+    HANDLE RemoteMachineHandle;
+    WCHAR[SP_MAX_MACHINENAME_LENGTH] RemoteMachineName;
+}
+alias SP_DEVINFO_LIST_DETAIL_DATA_W* PSP_DEVINFO_LIST_DETAIL_DATA_W;
+
+extern(Windows) alias UINT function(PVOID, UINT, UINT_PTR, UINT_PTR) PSP_FILE_CALLBACK_A;
+extern(Windows) alias UINT function(PVOID, UINT, UINT_PTR, UINT_PTR) PSP_FILE_CALLBACK_W;
+
+struct SP_DEVINSTALL_PARAMS_A {
+    DWORD               cbSize = SP_DEVINSTALL_PARAMS_A.sizeof;
+    DWORD               Flags;
+    DWORD               FlagsEx;
+    HWND                hwndParent;
+    PSP_FILE_CALLBACK_A InstallMsgHandler;
+    PVOID               InstallMsgHandlerContext;
+    HSPFILEQ            FileQueue;
+    ULONG_PTR           ClassInstallReserved;
+    DWORD               Reserved;
+    CHAR[MAX_PATH]      DriverPath;
+}
+alias SP_DEVINSTALL_PARAMS_A* PSP_DEVINSTALL_PARAMS_A;
+
+struct SP_DEVINSTALL_PARAMS_W {
+    DWORD               cbSize = SP_DEVINSTALL_PARAMS_W.sizeof;
+    DWORD               Flags;
+    DWORD               FlagsEx;
+    HWND                hwndParent;
+    PSP_FILE_CALLBACK_W InstallMsgHandler;
+    PVOID               InstallMsgHandlerContext;
+    HSPFILEQ            FileQueue;
+    ULONG_PTR           ClassInstallReserved;
+    DWORD               Reserved;
+    WCHAR[MAX_PATH]     DriverPath;
+}
+alias SP_DEVINSTALL_PARAMS_W* PSP_DEVINSTALL_PARAMS_W;
+
+struct SP_CLASSINSTALL_HEADER {
+    DWORD       cbSize = SP_CLASSINSTALL_HEADER.sizeof;
+    DI_FUNCTION InstallFunction;
+}
+alias SP_CLASSINSTALL_HEADER* PSP_CLASSINSTALL_HEADER;
+
+struct SP_ENABLECLASS_PARAMS {
+    SP_CLASSINSTALL_HEADER ClassInstallHeader;
+    GUID                   ClassGuid;
+    DWORD                  EnableMessage;
+}
+alias SP_ENABLECLASS_PARAMS* PSP_ENABLECLASS_PARAMS;
+
+struct SP_MOVEDEV_PARAMS {
+    SP_CLASSINSTALL_HEADER ClassInstallHeader;
+    SP_DEVINFO_DATA        SourceDeviceInfoData;
+}
+alias SP_MOVEDEV_PARAMS* PSP_MOVEDEV_PARAMS;
+
+struct SP_PROPCHANGE_PARAMS {
+    SP_CLASSINSTALL_HEADER ClassInstallHeader;
+    DWORD                  StateChange;
+    DWORD                  Scope;
+    DWORD                  HwProfile;
+}
+alias SP_PROPCHANGE_PARAMS* PSP_PROPCHANGE_PARAMS;
+
+struct SP_REMOVEDEVICE_PARAMS {
+    SP_CLASSINSTALL_HEADER ClassInstallHeader;
+    DWORD                  Scope;
+    DWORD                  HwProfile;
+}
+alias SP_REMOVEDEVICE_PARAMS* PSP_REMOVEDEVICE_PARAMS;
+
+struct SP_UNREMOVEDEVICE_PARAMS {
+    SP_CLASSINSTALL_HEADER ClassInstallHeader;
+    DWORD                  Scope;
+    DWORD                  HwProfile;
+}
+alias SP_UNREMOVEDEVICE_PARAMS* PSP_UNREMOVEDEVICE_PARAMS;
+
+struct SP_SELECTDEVICE_PARAMS_A {
+    SP_CLASSINSTALL_HEADER    ClassInstallHeader;
+    CHAR[MAX_TITLE_LEN]       Title;
+    CHAR[MAX_INSTRUCTION_LEN] Instructions;
+    CHAR[MAX_LABEL_LEN]       ListLabel;
+    CHAR[MAX_SUBTITLE_LEN]    SubTitle;
+    BYTE[2]                   Reserved;
+}
+alias SP_SELECTDEVICE_PARAMS_A* PSP_SELECTDEVICE_PARAMS_A;
+
+struct SP_SELECTDEVICE_PARAMS_W {
+    SP_CLASSINSTALL_HEADER     ClassInstallHeader;
+    WCHAR[MAX_TITLE_LEN]       Title;
+    WCHAR[MAX_INSTRUCTION_LEN] Instructions;
+    WCHAR[MAX_LABEL_LEN]       ListLabel;
+    WCHAR[MAX_SUBTITLE_LEN]    SubTitle;
+}
+alias SP_SELECTDEVICE_PARAMS_W* PSP_SELECTDEVICE_PARAMS_W;
+
+extern(Windows) alias BOOL function(PVOID, DWORD) PDETECT_PROGRESS_NOTIFY;
+
+struct SP_DETECTDEVICE_PARAMS {
+    SP_CLASSINSTALL_HEADER  ClassInstallHeader;
+    PDETECT_PROGRESS_NOTIFY DetectProgressNotify;
+    PVOID                   ProgressNotifyParam;
+}
+alias SP_DETECTDEVICE_PARAMS* PSP_DETECTDEVICE_PARAMS;
+
+struct SP_INSTALLWIZARD_DATA {
+    SP_CLASSINSTALL_HEADER ClassInstallHeader;
+    DWORD                  Flags;
+    HPROPSHEETPAGE[MAX_INSTALLWIZARD_DYNAPAGES] DynamicPages;
+    DWORD                  NumDynamicPages;
+    DWORD                  DynamicPageFlags;
+    DWORD                  PrivateFlags;
+    LPARAM                 PrivateData;
+    HWND                   hwndWizardDlg;
+}
+alias SP_INSTALLWIZARD_DATA* PSP_INSTALLWIZARD_DATA;
+
+struct SP_NEWDEVICEWIZARD_DATA {
+    SP_CLASSINSTALL_HEADER ClassInstallHeader;
+    DWORD                  Flags;
+    HPROPSHEETPAGE[MAX_INSTALLWIZARD_DYNAPAGES]  DynamicPages;
+    DWORD                  NumDynamicPages;
+    HWND                   hwndWizardDlg;
+}
+alias SP_NEWDEVICEWIZARD_DATA* PSP_NEWDEVICEWIZARD_DATA;
+alias SP_NEWDEVICEWIZARD_DATA SP_ADDPROPERTYPAGE_DATA;
+alias SP_NEWDEVICEWIZARD_DATA* PSP_ADDPROPERTYPAGE_DATA;
+
+struct SP_TROUBLESHOOTER_PARAMS_A {
+    SP_CLASSINSTALL_HEADER ClassInstallHeader;
+    CHAR[MAX_PATH]         ChmFile;
+    CHAR[MAX_PATH]         HtmlTroubleShooter;
+}
+alias SP_TROUBLESHOOTER_PARAMS_A* PSP_TROUBLESHOOTER_PARAMS_A;
+
+struct SP_TROUBLESHOOTER_PARAMS_W {
+    SP_CLASSINSTALL_HEADER ClassInstallHeader;
+    WCHAR[MAX_PATH]        ChmFile;
+    WCHAR[MAX_PATH]        HtmlTroubleShooter;
+}
+alias SP_TROUBLESHOOTER_PARAMS_W* PSP_TROUBLESHOOTER_PARAMS_W;
+
+struct SP_POWERMESSAGEWAKE_PARAMS_A {
+    SP_CLASSINSTALL_HEADER ClassInstallHeader;
+    CHAR[LINE_LEN*2]       PowerMessageWake;
+}
+alias SP_POWERMESSAGEWAKE_PARAMS_A* PSP_POWERMESSAGEWAKE_PARAMS_A;
+
+struct SP_POWERMESSAGEWAKE_PARAMS_W {
+    SP_CLASSINSTALL_HEADER ClassInstallHeader;
+    WCHAR[LINE_LEN*2]      PowerMessageWake;
+}
+alias SP_POWERMESSAGEWAKE_PARAMS_W* PSP_POWERMESSAGEWAKE_PARAMS_W;
+
+struct SP_DRVINFO_DATA_V2_A {
+    DWORD          cbSize = SP_DRVINFO_DATA_V2_A.sizeof;
+    DWORD          DriverType;
+    ULONG_PTR      Reserved;
+    CHAR[LINE_LEN] Description;
+    CHAR[LINE_LEN] MfgName;
+    CHAR[LINE_LEN] ProviderName;
+    FILETIME       DriverDate;
+    DWORDLONG      DriverVersion;
+}
+alias SP_DRVINFO_DATA_V2_A* PSP_DRVINFO_DATA_V2_A;
+
+struct SP_DRVINFO_DATA_V2_W {
+    DWORD           cbSize = SP_DRVINFO_DATA_V2_A.sizeof;
+    DWORD           DriverType;
+    ULONG_PTR       Reserved;
+    WCHAR[LINE_LEN] Description;
+    WCHAR[LINE_LEN] MfgName;
+    WCHAR[LINE_LEN] ProviderName;
+    FILETIME        DriverDate;
+    DWORDLONG       DriverVersion;
+}
+alias SP_DRVINFO_DATA_V2_W* PSP_DRVINFO_DATA_V2_W;
+
+struct SP_DRVINFO_DATA_V1_A {
+    DWORD          cbSize = SP_DRVINFO_DATA_V1_A.sizeof;
+    DWORD          DriverType;
+    ULONG_PTR      Reserved;
+    CHAR[LINE_LEN] Description;
+    CHAR[LINE_LEN] MfgName;
+    CHAR[LINE_LEN] ProviderName;
+}
+alias SP_DRVINFO_DATA_V1_A* PSP_DRVINFO_DATA_V1_A;
+
+struct SP_DRVINFO_DATA_V1_W {
+    DWORD           cbSize = SP_DRVINFO_DATA_V1_W.sizeof;
+    DWORD           DriverType;
+    ULONG_PTR       Reserved;
+    WCHAR[LINE_LEN] Description;
+    WCHAR[LINE_LEN] MfgName;
+    WCHAR[LINE_LEN] ProviderName;
+}
+alias SP_DRVINFO_DATA_V1_W* PSP_DRVINFO_DATA_V1_W;
+
+version (Unicode) {
+    alias SP_DRVINFO_DATA_V1_W SP_DRVINFO_DATA_V1;
+    alias SP_DRVINFO_DATA_V2_W SP_DRVINFO_DATA_V2;
+} else {
+    alias SP_DRVINFO_DATA_V1_A SP_DRVINFO_DATA_V1;
+    alias SP_DRVINFO_DATA_V2_A SP_DRVINFO_DATA_V2;
+}
+alias SP_DRVINFO_DATA_V1* PSP_DRVINFO_DATA_V1;
+alias SP_DRVINFO_DATA_V2* PSP_DRVINFO_DATA_V2;
+
+static if(USE_SP_DRVINFO_DATA_V1) {
+    alias SP_DRVINFO_DATA_V1_A SP_DRVINFO_DATA_A;
+    alias SP_DRVINFO_DATA_V1_A* PSP_DRVINFO_DATA_A;
+    alias SP_DRVINFO_DATA_V1_W SP_DRVINFO_DATA_W;
+    alias SP_DRVINFO_DATA_V1_W* PSP_DRVINFO_DATA_W;
+    alias SP_DRVINFO_DATA_V1 SP_DRVINFO_DATA;
+    alias SP_DRVINFO_DATA_V1* PSP_DRVINFO_DATA;
+} else {
+    alias SP_DRVINFO_DATA_V2_A SP_DRVINFO_DATA_A;
+    alias SP_DRVINFO_DATA_V2_A* PSP_DRVINFO_DATA_A;
+    alias SP_DRVINFO_DATA_V2_W SP_DRVINFO_DATA_W;
+    alias SP_DRVINFO_DATA_V2_W* PSP_DRVINFO_DATA_W;
+    alias SP_DRVINFO_DATA_V2 SP_DRVINFO_DATA;
+    alias SP_DRVINFO_DATA_V2* PSP_DRVINFO_DATA;
+}
+
+extern(Windows) alias DWORD function(HDEVINFO, PSP_DEVINFO_DATA, PSP_DEVINFO_DATA, PVOID) PSP_DETSIG_CMPPROC;
+
+struct SP_DRVINFO_DETAIL_DATA_A {
+    DWORD          cbSize = SP_DRVINFO_DETAIL_DATA_A.sizeof;
+    FILETIME       InfDate;
+    DWORD          CompatIDsOffset;
+    DWORD          CompatIDsLength;
+    ULONG_PTR      Reserved;
+    CHAR[LINE_LEN] SectionName;
+    CHAR[MAX_PATH] InfFileName;
+    CHAR[LINE_LEN] DrvDescription;
+    CHAR[1]        _HardwareID;
+    CHAR*          HardwareID() return { return _HardwareID.ptr; }
+}
+alias SP_DRVINFO_DETAIL_DATA_A* PSP_DRVINFO_DETAIL_DATA_A;
+
+struct SP_DRVINFO_DETAIL_DATA_W {
+    DWORD           cbSize = SP_DRVINFO_DETAIL_DATA_W.sizeof;
+    FILETIME        InfDate;
+    DWORD           CompatIDsOffset;
+    DWORD           CompatIDsLength;
+    ULONG_PTR       Reserved;
+    WCHAR[LINE_LEN] SectionName;
+    WCHAR[MAX_PATH] InfFileName;
+    WCHAR[LINE_LEN] DrvDescription;
+    WCHAR[1]        _HardwareID;
+    WCHAR*          HardwareID() return { return _HardwareID.ptr; }
+}
+alias SP_DRVINFO_DETAIL_DATA_W* PSP_DRVINFO_DETAIL_DATA_W;
+
+struct SP_DRVINSTALL_PARAMS {
+    DWORD cbSize = SP_DRVINSTALL_PARAMS.sizeof;
+    DWORD Rank;
+    DWORD Flags;
+    DWORD_PTR PrivateData;
+    DWORD Reserved;
+}
+alias SP_DRVINSTALL_PARAMS* PSP_DRVINSTALL_PARAMS;
+
+struct COINSTALLER_CONTEXT_DATA {
+    BOOL  PostProcessing;
+    DWORD InstallResult;
+    PVOID PrivateData;
+}
+alias COINSTALLER_CONTEXT_DATA* PCOINSTALLER_CONTEXT_DATA;
+
+struct SP_CLASSIMAGELIST_DATA {
+    DWORD      cbSize = SP_CLASSIMAGELIST_DATA.sizeof;
+    HIMAGELIST ImageList;
+    ULONG_PTR  Reserved;
+}
+alias SP_CLASSIMAGELIST_DATA* PSP_CLASSIMAGELIST_DATA;
+
+struct SP_PROPSHEETPAGE_REQUEST {
+    DWORD            cbSize = SP_PROPSHEETPAGE_REQUEST.sizeof;
+    DWORD            PageRequested;
+    HDEVINFO         DeviceInfoSet;
+    PSP_DEVINFO_DATA DeviceInfoData;
+}
+alias SP_PROPSHEETPAGE_REQUEST* PSP_PROPSHEETPAGE_REQUEST;
+
+struct SP_BACKUP_QUEUE_PARAMS_A {
+    DWORD cbSize = SP_BACKUP_QUEUE_PARAMS_A.sizeof;
+    CHAR[MAX_PATH] FullInfPath;
+    INT FilenameOffset;
+}
+alias SP_BACKUP_QUEUE_PARAMS_A* PSP_BACKUP_QUEUE_PARAMS_A;
+
+struct SP_BACKUP_QUEUE_PARAMS_W {
+    DWORD cbSize = SP_BACKUP_QUEUE_PARAMS_W.sizeof;
+    WCHAR[MAX_PATH] FullInfPath;
+    INT FilenameOffset;
+}
+alias SP_BACKUP_QUEUE_PARAMS_W* PSP_BACKUP_QUEUE_PARAMS_W;
+
+version (Unicode) {
+    alias SP_ORIGINAL_FILE_INFO_W SP_ORIGINAL_FILE_INFO;
+    alias SP_ORIGINAL_FILE_INFO_W* PSP_ORIGINAL_FILE_INFO;
+    alias FILEPATHS_W FILEPATHS;
+    alias FILEPATHS_W* PFILEPATHS;
+    alias SOURCE_MEDIA_W SOURCE_MEDIA;
+    alias SOURCE_MEDIA_W* PSOURCE_MEDIA;
+    alias CABINET_INFO_W CABINET_INFO;
+    alias CABINET_INFO_W* PCABINET_INFO;
+    alias FILE_IN_CABINET_INFO_W FILE_IN_CABINET_INFO;
+    alias FILE_IN_CABINET_INFO_W* PFILE_IN_CABINET_INFO;
+    alias SP_FILE_COPY_PARAMS_W SP_FILE_COPY_PARAMS;
+    alias SP_FILE_COPY_PARAMS_W* PSP_FILE_COPY_PARAMS;
+    alias SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_DEVICE_INTERFACE_DETAIL_DATA;
+    alias SP_DEVICE_INTERFACE_DETAIL_DATA_W* PSP_DEVICE_INTERFACE_DETAIL_DATA;
+    deprecated {
+        alias SP_DEVICE_INTERFACE_DETAIL_DATA_W SP_INTERFACE_DEVICE_DETAIL_DATA;
+        alias SP_DEVICE_INTERFACE_DETAIL_DATA_W* PSP_INTERFACE_DEVICE_DETAIL_DATA;
+    }
+    alias SP_DEVINFO_LIST_DETAIL_DATA_W SP_DEVINFO_LIST_DETAIL_DATA;
+    alias SP_DEVINFO_LIST_DETAIL_DATA_W *PSP_DEVINFO_LIST_DETAIL_DATA;
+    alias SP_DEVINSTALL_PARAMS_W SP_DEVINSTALL_PARAMS;
+    alias SP_DEVINSTALL_PARAMS_W* PSP_DEVINSTALL_PARAMS;
+    alias SP_SELECTDEVICE_PARAMS_W SP_SELECTDEVICE_PARAMS;
+    alias SP_SELECTDEVICE_PARAMS_W* PSP_SELECTDEVICE_PARAMS;
+    alias SP_TROUBLESHOOTER_PARAMS_W SP_TROUBLESHOOTER_PARAMS;
+    alias SP_TROUBLESHOOTER_PARAMS_W* PSP_TROUBLESHOOTER_PARAMS;
+    alias SP_POWERMESSAGEWAKE_PARAMS_W SP_POWERMESSAGEWAKE_PARAMS;
+    alias SP_POWERMESSAGEWAKE_PARAMS_W* PSP_POWERMESSAGEWAKE_PARAMS;
+    alias SP_DRVINFO_DETAIL_DATA_W SP_DRVINFO_DETAIL_DATA;
+    alias SP_DRVINFO_DETAIL_DATA_W* PSP_DRVINFO_DETAIL_DATA;
+    alias SP_BACKUP_QUEUE_PARAMS_W SP_BACKUP_QUEUE_PARAMS;
+    alias SP_BACKUP_QUEUE_PARAMS_W* PSP_BACKUP_QUEUE_PARAMS;
+} else {
+    alias SP_ORIGINAL_FILE_INFO_A SP_ORIGINAL_FILE_INFO;
+    alias SP_ORIGINAL_FILE_INFO_A* PSP_ORIGINAL_FILE_INFO;
+    alias FILEPATHS_A FILEPATHS;
+    alias FILEPATHS_A* PFILEPATHS;
+    alias SOURCE_MEDIA_A SOURCE_MEDIA;
+    alias SOURCE_MEDIA_A* PSOURCE_MEDIA;
+    alias CABINET_INFO_A CABINET_INFO;
+    alias CABINET_INFO_A* PCABINET_INFO;
+    alias FILE_IN_CABINET_INFO_A FILE_IN_CABINET_INFO;
+    alias FILE_IN_CABINET_INFO_A* PFILE_IN_CABINET_INFO;
+    alias SP_FILE_COPY_PARAMS_A SP_FILE_COPY_PARAMS;
+    alias SP_FILE_COPY_PARAMS_A* PSP_FILE_COPY_PARAMS;
+    alias SP_DEVICE_INTERFACE_DETAIL_DATA_A SP_DEVICE_INTERFACE_DETAIL_DATA;
+    alias SP_DEVICE_INTERFACE_DETAIL_DATA_A* PSP_DEVICE_INTERFACE_DETAIL_DATA;
+    deprecated {
+        alias SP_DEVICE_INTERFACE_DETAIL_DATA_A SP_INTERFACE_DEVICE_DETAIL_DATA;
+        alias SP_DEVICE_INTERFACE_DETAIL_DATA_A* PSP_INTERFACE_DEVICE_DETAIL_DATA;
+    }
+    alias SP_DEVINFO_LIST_DETAIL_DATA_A SP_DEVINFO_LIST_DETAIL_DATA;
+    alias SP_DEVINFO_LIST_DETAIL_DATA_A* PSP_DEVINFO_LIST_DETAIL_DATA;
+    alias SP_DEVINSTALL_PARAMS_A SP_DEVINSTALL_PARAMS;
+    alias SP_DEVINSTALL_PARAMS_A* PSP_DEVINSTALL_PARAMS;
+    alias SP_SELECTDEVICE_PARAMS_A SP_SELECTDEVICE_PARAMS;
+    alias SP_SELECTDEVICE_PARAMS_A* PSP_SELECTDEVICE_PARAMS;
+    alias SP_TROUBLESHOOTER_PARAMS_A SP_TROUBLESHOOTER_PARAMS;
+    alias SP_TROUBLESHOOTER_PARAMS_A* PSP_TROUBLESHOOTER_PARAMS;
+    alias SP_POWERMESSAGEWAKE_PARAMS_A SP_POWERMESSAGEWAKE_PARAMS;
+    alias SP_POWERMESSAGEWAKE_PARAMS_A* PSP_POWERMESSAGEWAKE_PARAMS;
+    alias SP_DRVINFO_DETAIL_DATA_A SP_DRVINFO_DETAIL_DATA;
+    alias SP_DRVINFO_DETAIL_DATA_A* PSP_DRVINFO_DETAIL_DATA;
+    alias SP_BACKUP_QUEUE_PARAMS_A SP_BACKUP_QUEUE_PARAMS;
+    alias SP_BACKUP_QUEUE_PARAMS_A* PSP_BACKUP_QUEUE_PARAMS;
+}
+
+extern (Windows) {
+    BOOL SetupAddInstallSectionToDiskSpaceListA(HDSKSPC, HINF, HINF, PCSTR, PVOID, UINT);
+    BOOL SetupAddInstallSectionToDiskSpaceListW(HDSKSPC, HINF, HINF, PCWSTR, PVOID, UINT);
+    BOOL SetupAddSectionToDiskSpaceListA(HDSKSPC, HINF, HINF, PCSTR, UINT, PVOID, UINT);
+    BOOL SetupAddSectionToDiskSpaceListW(HDSKSPC, HINF, HINF, PCWSTR, UINT, PVOID, UINT);
+    BOOL SetupAddToDiskSpaceListA(HDSKSPC, PCSTR, LONGLONG, UINT, PVOID, UINT);
+    BOOL SetupAddToDiskSpaceListW(HDSKSPC, PCWSTR, LONGLONG, UINT, PVOID, UINT);
+    BOOL SetupAddToSourceListA(DWORD, PCSTR);
+    BOOL SetupAddToSourceListW(DWORD, PCWSTR);
+    BOOL SetupQuerySourceListA(DWORD, PCSTR**List, PUINT);
+    BOOL SetupQuerySourceListW(DWORD, PCWSTR**List, PUINT);
+    BOOL SetupFreeSourceListA(PCSTR**List, UINT);
+    BOOL SetupFreeSourceListW(PCWSTR**List, UINT);
+    BOOL SetupAdjustDiskSpaceListA(HDSKSPC, LPCSTR, LONGLONG, PVOID, UINT);
+    BOOL SetupAdjustDiskSpaceListW(HDSKSPC, LPCWSTR, LONGLONG, PVOID, UINT);
+    UINT SetupBackupErrorA(HWND, PCSTR, PCSTR, PCSTR, UINT, DWORD);
+    UINT SetupBackupErrorW(HWND, PCWSTR, PCWSTR, PCWSTR, UINT, DWORD);
+    BOOL SetupCancelTemporary();
+    BOOL SetupCloseFileQueue(HSPFILEQ);
+    VOID SetupCloseInfFile(HINF);
+    VOID SetupCloseLog();
+    BOOL SetupCommitFileQueueA(HWND, HSPFILEQ, PSP_FILE_CALLBACK_A, PVOID);
+    BOOL SetupCommitFileQueueW(HWND, HSPFILEQ, PSP_FILE_CALLBACK_W, PVOID);
+    UINT SetupCopyErrorA(HWND, PCSTR, PCSTR, PCSTR, PCSTR, PCSTR, UINT, DWORD, PSTR, DWORD, PDWORD);
+    UINT SetupCopyErrorW(HWND, PCWSTR, PCWSTR, PCWSTR, PCWSTR, PCWSTR, UINT, DWORD, PWSTR, DWORD, PDWORD);
+    BOOL SetupCopyOEMInfA(PCSTR, PCSTR, DWORD, DWORD, PSTR, DWORD, PDWORD, PSTR*);
+    BOOL SetupCopyOEMInfW(PCWSTR, PCWSTR, DWORD, DWORD, PWSTR, DWORD, PDWORD, PWSTR*);
+    HDSKSPC SetupCreateDiskSpaceListA(PVOID, DWORD, UINT);
+    HDSKSPC SetupCreateDiskSpaceListW(PVOID, DWORD, UINT);
+    DWORD SetupDecompressOrCopyFileA(PCSTR, PCSTR, PUINT);
+    DWORD SetupDecompressOrCopyFileW(PCWSTR, PCWSTR, PUINT);
+    UINT SetupDefaultQueueCallbackA(PVOID, UINT, UINT_PTR, UINT_PTR);
+    UINT SetupDefaultQueueCallbackW(PVOID, UINT, UINT_PTR, UINT_PTR);
+    UINT SetupDeleteErrorA(HWND, PCSTR, PCSTR, UINT, DWORD);
+    UINT SetupDeleteErrorW(HWND, PCWSTR, PCWSTR, UINT, DWORD);
+    BOOL SetupDestroyDiskSpaceList(HDSKSPC);
+    BOOL SetupDiAskForOEMDisk(HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiBuildClassInfoList(DWORD, LPGUID, DWORD, PDWORD);
+    BOOL SetupDiBuildClassInfoListExA(DWORD, LPGUID, DWORD, PDWORD, PCSTR, PVOID);
+    BOOL SetupDiBuildClassInfoListExW(DWORD, LPGUID, DWORD, PDWORD, PCWSTR, PVOID);
+    BOOL SetupDiBuildDriverInfoList(HDEVINFO, PSP_DEVINFO_DATA, DWORD);
+    BOOL SetupDiCallClassInstaller(DI_FUNCTION, HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiCancelDriverInfoSearch(HDEVINFO);
+    BOOL SetupDiChangeState(HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiClassGuidsFromNameA(PCSTR, LPGUID, DWORD, PDWORD);
+    BOOL SetupDiClassGuidsFromNameW(PCWSTR, LPGUID, DWORD, PDWORD);
+    BOOL SetupDiClassGuidsFromNameExA(PCSTR, LPGUID, DWORD, PDWORD, PCSTR, PVOID);
+    BOOL SetupDiClassGuidsFromNameExW(PCWSTR, LPGUID, DWORD, PDWORD, PCWSTR, PVOID);
+    BOOL SetupDiClassNameFromGuidA(const(GUID)*, PSTR, DWORD, PDWORD);
+    BOOL SetupDiClassNameFromGuidW(const(GUID)*, PWSTR, DWORD, PDWORD);
+    BOOL SetupDiClassNameFromGuidExA(const(GUID)*, PSTR, DWORD, PDWORD, PCSTR, PVOID);
+    BOOL SetupDiClassNameFromGuidExW(const(GUID)*, PWSTR, DWORD, PDWORD, PCWSTR, PVOID);
+    BOOL SetupDiCreateDeviceInfoA(HDEVINFO, PCSTR, const(GUID)*, PCSTR, HWND, DWORD, PSP_DEVINFO_DATA);
+    BOOL SetupDiCreateDeviceInfoW(HDEVINFO, PCWSTR, const(GUID)*, PCWSTR, HWND, DWORD, PSP_DEVINFO_DATA);
+    HDEVINFO SetupDiCreateDeviceInfoList(const(GUID)*, HWND);
+    HDEVINFO SetupDiCreateDeviceInfoListExA(const(GUID)*, HWND, PCSTR, PVOID);
+    HDEVINFO SetupDiCreateDeviceInfoListExW(const(GUID)*, HWND, PCWSTR, PVOID);
+    BOOL SetupDiCreateDeviceInterfaceA(HDEVINFO, PSP_DEVINFO_DATA, const(GUID)*, PCSTR, DWORD, PSP_DEVICE_INTERFACE_DATA);
+    BOOL SetupDiCreateDeviceInterfaceW(HDEVINFO, PSP_DEVINFO_DATA, const(GUID)*, PCWSTR, DWORD, PSP_DEVICE_INTERFACE_DATA);
+    HKEY SetupDiCreateDeviceInterfaceRegKeyA(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, DWORD, REGSAM, HINF, PCSTR);
+    HKEY SetupDiCreateDeviceInterfaceRegKeyW(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, DWORD, REGSAM, HINF, PCWSTR);
+    HKEY SetupDiCreateDevRegKeyA(HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, DWORD, HINF, PCSTR);
+    HKEY SetupDiCreateDevRegKeyW(HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, DWORD, HINF, PCWSTR);
+    BOOL SetupDiDeleteDeviceInfo(HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiDeleteDeviceInterfaceData(HDEVINFO, PSP_DEVICE_INTERFACE_DATA);
+    BOOL SetupDiDeleteDeviceInterfaceRegKey(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, DWORD);
+    BOOL SetupDiDeleteDevRegKey(HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, DWORD);
+    BOOL SetupDiDestroyClassImageList(PSP_CLASSIMAGELIST_DATA);
+    BOOL SetupDiDestroyDeviceInfoList(HDEVINFO);
+    BOOL SetupDiDestroyDriverInfoList(HDEVINFO, PSP_DEVINFO_DATA, DWORD);
+    INT SetupDiDrawMiniIcon(HDC, RECT, INT, DWORD);
+    BOOL SetupDiEnumDeviceInfo(HDEVINFO, DWORD, PSP_DEVINFO_DATA);
+    BOOL SetupDiEnumDeviceInterfaces(HDEVINFO, PSP_DEVINFO_DATA, const(GUID)*, DWORD, PSP_DEVICE_INTERFACE_DATA);
+    BOOL SetupDiEnumDriverInfoA(HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, PSP_DRVINFO_DATA_A);
+    BOOL SetupDiEnumDriverInfoW(HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, PSP_DRVINFO_DATA_W);
+    BOOL SetupDiGetActualSectionToInstallA(HINF, PCSTR, PSTR, DWORD, PDWORD, PSTR*);
+    BOOL SetupDiGetActualSectionToInstallW(HINF, PCWSTR, PWSTR, DWORD, PDWORD, PWSTR*);
+    BOOL SetupDiGetClassBitmapIndex(const(GUID)*, PINT);
+    BOOL SetupDiGetClassDescriptionA(const(GUID)*, PSTR, DWORD, PDWORD);
+    BOOL SetupDiGetClassDescriptionW(const(GUID)*, PWSTR, DWORD, PDWORD);
+    BOOL SetupDiGetClassDescriptionExA(const(GUID)*, PSTR, DWORD, PDWORD, PCSTR, PVOID);
+    BOOL SetupDiGetClassDescriptionExW(const(GUID)*, PWSTR, DWORD, PDWORD, PCWSTR, PVOID);
+    BOOL SetupDiGetClassDevPropertySheetsA(HDEVINFO, PSP_DEVINFO_DATA, LPPROPSHEETHEADERA, DWORD, PDWORD, DWORD);
+    BOOL SetupDiGetClassDevPropertySheetsW(HDEVINFO, PSP_DEVINFO_DATA, LPPROPSHEETHEADERW, DWORD, PDWORD, DWORD);
+    HDEVINFO SetupDiGetClassDevsA(const(GUID)*, PCSTR, HWND, DWORD);
+    HDEVINFO SetupDiGetClassDevsW(const(GUID)*, PCWSTR, HWND, DWORD);
+    HDEVINFO SetupDiGetClassDevsExA(const(GUID)*, PCSTR, HWND, DWORD, HDEVINFO, PCSTR, PVOID);
+    HDEVINFO SetupDiGetClassDevsExW(const(GUID)*, PCWSTR, HWND, DWORD, HDEVINFO, PCWSTR, PVOID);
+    BOOL SetupDiGetClassImageIndex(PSP_CLASSIMAGELIST_DATA, const(GUID)*, PINT);
+    BOOL SetupDiGetClassImageList(PSP_CLASSIMAGELIST_DATA);
+    BOOL SetupDiGetClassImageListExA(PSP_CLASSIMAGELIST_DATA, PCSTR, PVOID);
+    BOOL SetupDiGetClassImageListExW(PSP_CLASSIMAGELIST_DATA, PCWSTR, PVOID);
+    BOOL SetupDiGetClassInstallParamsA(HDEVINFO, PSP_DEVINFO_DATA, PSP_CLASSINSTALL_HEADER, DWORD, PDWORD);
+    BOOL SetupDiGetClassInstallParamsW(HDEVINFO, PSP_DEVINFO_DATA, PSP_CLASSINSTALL_HEADER, DWORD, PDWORD);
+    BOOL SetupDiGetClassRegistryPropertyA(LPGUID, DWORD, PDWORD, PBYTE, DWORD, PDWORD, PCSTR, PVOID);
+    BOOL SetupDiGetClassRegistryPropertyW(LPGUID, DWORD, PDWORD, PBYTE, DWORD, PDWORD, PCWSTR, PVOID);
+    BOOL SetupDiGetDeviceInfoListClass(HDEVINFO, LPGUID);
+    BOOL SetupDiGetDeviceInfoListDetailA(HDEVINFO, PSP_DEVINFO_LIST_DETAIL_DATA_A);
+    BOOL SetupDiGetDeviceInfoListDetailW(HDEVINFO, PSP_DEVINFO_LIST_DETAIL_DATA_W);
+    BOOL SetupDiGetDeviceInstallParamsA(HDEVINFO, PSP_DEVINFO_DATA, PSP_DEVINSTALL_PARAMS_A);
+    BOOL SetupDiGetDeviceInstallParamsW(HDEVINFO, PSP_DEVINFO_DATA, PSP_DEVINSTALL_PARAMS_W);
+    BOOL SetupDiGetDeviceInstanceIdA(HDEVINFO, PSP_DEVINFO_DATA, PSTR, DWORD, PDWORD);
+    BOOL SetupDiGetDeviceInstanceIdW(HDEVINFO, PSP_DEVINFO_DATA, PWSTR, DWORD, PDWORD);
+    BOOL SetupDiGetDeviceInterfaceAlias(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, const(GUID)*, PSP_DEVICE_INTERFACE_DATA);
+    BOOL SetupDiGetDeviceInterfaceDetailA(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, PSP_DEVICE_INTERFACE_DETAIL_DATA_A, DWORD, PDWORD, PSP_DEVINFO_DATA);
+    BOOL SetupDiGetDeviceInterfaceDetailW(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, PSP_DEVICE_INTERFACE_DETAIL_DATA_W, DWORD, PDWORD, PSP_DEVINFO_DATA);
+    BOOL SetupDiGetDeviceRegistryPropertyA(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PDWORD, PBYTE, DWORD, PDWORD);
+    BOOL SetupDiGetDeviceRegistryPropertyW(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PDWORD, PBYTE, DWORD, PDWORD);
+    BOOL SetupDiGetDriverInfoDetailA(HDEVINFO, PSP_DEVINFO_DATA, PSP_DRVINFO_DATA_A, PSP_DRVINFO_DETAIL_DATA_A, DWORD, PDWORD);
+    BOOL SetupDiGetDriverInfoDetailW(HDEVINFO, PSP_DEVINFO_DATA, PSP_DRVINFO_DATA_W, PSP_DRVINFO_DETAIL_DATA_W, DWORD, PDWORD);
+    BOOL SetupDiGetDriverInstallParamsA(HDEVINFO, PSP_DEVINFO_DATA, PSP_DRVINFO_DATA_A, PSP_DRVINSTALL_PARAMS);
+    BOOL SetupDiGetDriverInstallParamsW(HDEVINFO, PSP_DEVINFO_DATA, PSP_DRVINFO_DATA_W, PSP_DRVINSTALL_PARAMS);
+    BOOL SetupDiGetHwProfileFriendlyNameA(DWORD, PSTR, DWORD, PDWORD);
+    BOOL SetupDiGetHwProfileFriendlyNameExA(DWORD, PSTR, DWORD, PDWORD, PCSTR, PVOID);
+    BOOL SetupDiGetHwProfileFriendlyNameExW(DWORD, PWSTR, DWORD, PDWORD, PCWSTR, PVOID);
+    BOOL SetupDiGetHwProfileFriendlyNameW(DWORD, PWSTR, DWORD, PDWORD);
+    BOOL SetupDiGetHwProfileList(PDWORD, DWORD, PDWORD, PDWORD);
+    BOOL SetupDiGetHwProfileListExA(PDWORD, DWORD, PDWORD, PDWORD, PCSTR, PVOID);
+    BOOL SetupDiGetHwProfileListExW(PDWORD, DWORD, PDWORD, PDWORD, PCWSTR, PVOID);
+    BOOL SetupDiGetINFClassA(PCSTR, LPGUID, PSTR, DWORD, PDWORD);
+    BOOL SetupDiGetINFClassW(PCWSTR, LPGUID, PWSTR, DWORD, PDWORD);
+    BOOL SetupDiGetSelectedDevice(HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiGetSelectedDriverA(HDEVINFO, PSP_DEVINFO_DATA, PSP_DRVINFO_DATA_A);
+    BOOL SetupDiGetSelectedDriverW(HDEVINFO, PSP_DEVINFO_DATA, PSP_DRVINFO_DATA_W);
+    HPROPSHEETPAGE SetupDiGetWizardage(HDEVINFO, PSP_DEVINFO_DATA, PSP_INSTALLWIZARD_DATA, DWORD, DWORD);
+    BOOL SetupDiInstallClassA(HWND, PCSTR, DWORD, HSPFILEQ);
+    BOOL SetupDiInstallClassW(HWND, PCWSTR, DWORD, HSPFILEQ);
+    BOOL SetupDiInstallClassExA(HWND, PCSTR, DWORD, HSPFILEQ, const(GUID)*, PVOID, PVOID);
+    BOOL SetupDiInstallClassExW(HWND, PCWSTR, DWORD, HSPFILEQ, const(GUID)*, PVOID, PVOID);
+    BOOL SetupDiInstallDevice(HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiInstallDeviceInterfaces(HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiInstallDriverFiles(HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiLoadClassIcon(const(GUID)*, HICON*, PINT);
+    BOOL SetupDiMoveDuplicateDevice(HDEVINFO, PSP_DEVINFO_DATA);
+    HKEY SetupDiOpenClassRegKey(const(GUID)*, REGSAM);
+    HKEY SetupDiOpenClassRegKeyExA(const(GUID)*, REGSAM, DWORD, PCSTR, PVOID);
+    HKEY SetupDiOpenClassRegKeyExW(const(GUID)*, REGSAM, DWORD, PCWSTR, PVOID);
+    BOOL SetupDiOpenDeviceInfoA(HDEVINFO, PCSTR, HWND, DWORD, PSP_DEVINFO_DATA);
+    BOOL SetupDiOpenDeviceInfoW(HDEVINFO, PCWSTR, HWND, DWORD, PSP_DEVINFO_DATA);
+    BOOL SetupDiOpenDeviceInterfaceA(HDEVINFO, PCSTR, DWORD, PSP_DEVICE_INTERFACE_DATA);
+    BOOL SetupDiOpenDeviceInterfaceW(HDEVINFO, PCWSTR, DWORD, PSP_DEVICE_INTERFACE_DATA);
+    HKEY SetupDiOpenDeviceInterfaceRegKey(HDEVINFO, PSP_DEVICE_INTERFACE_DATA, DWORD, REGSAM);
+    HKEY SetupDiOpenDevRegKey(HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, DWORD, REGSAM);
+    BOOL SetupDiRegisterCoDeviceInstallers(HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiRegisterDeviceInfo(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PSP_DETSIG_CMPPROC, PVOID, PSP_DEVINFO_DATA);
+    BOOL SetupDiRemoveDevice(HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiRemoveDeviceInterface(HDEVINFO, PSP_DEVICE_INTERFACE_DATA);
+    BOOL SetupDiSelectBestCompatDrv(HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiSelectDevice(HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiSelectOEMDrv(HWND, HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiSetClassInstallParamsA(HDEVINFO, PSP_DEVINFO_DATA, PSP_CLASSINSTALL_HEADER, DWORD);
+    BOOL SetupDiSetClassInstallParamsW(HDEVINFO, PSP_DEVINFO_DATA, PSP_CLASSINSTALL_HEADER, DWORD);
+    BOOL SetupDiSetClassRegistryPropertyA(LPGUID, DWORD, const(BYTE)*, DWORD, PCSTR, PVOID);
+    BOOL SetupDiSetClassRegistryPropertyW(LPGUID, DWORD, const(BYTE)*, DWORD, PCWSTR, PVOID);
+    BOOL SetupDiSetDeviceInstallParamsA(HDEVINFO, PSP_DEVINFO_DATA, PSP_DEVINSTALL_PARAMS_A);
+    BOOL SetupDiSetDeviceInstallParamsW(HDEVINFO, PSP_DEVINFO_DATA, PSP_DEVINSTALL_PARAMS_W);
+    BOOL SetupDiSetDeviceRegistryPropertyA(HDEVINFO, PSP_DEVINFO_DATA, DWORD, const(BYTE)*, DWORD);
+    BOOL SetupDiSetDeviceRegistryPropertyW(HDEVINFO, PSP_DEVINFO_DATA, DWORD, const(BYTE)*, DWORD);
+    BOOL SetupDiSetDriverInstallParamsA(HDEVINFO, PSP_DEVINFO_DATA, PSP_DRVINFO_DATA_A, PSP_DRVINSTALL_PARAMS);
+    BOOL SetupDiSetDriverInstallParamsW(HDEVINFO, PSP_DEVINFO_DATA, PSP_DRVINFO_DATA_W, PSP_DRVINSTALL_PARAMS);
+    BOOL SetupDiSetSelectedDevice(HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupDiSetSelectedDriverA(HDEVINFO, PSP_DEVINFO_DATA, PSP_DRVINFO_DATA_A);
+    BOOL SetupDiSetSelectedDriverW(HDEVINFO, PSP_DEVINFO_DATA, PSP_DRVINFO_DATA_W);
+    BOOL SetupDiUnremoveDevice(HDEVINFO, PSP_DEVINFO_DATA);
+    HDSKSPC SetupDuplicateDiskSpaceListA(HDSKSPC, PVOID, DWORD, UINT);
+    HDSKSPC SetupDuplicateDiskSpaceListW(HDSKSPC, PVOID, DWORD, UINT);
+    BOOL SetupFindFirstLineA(HINF, PCSTR, PCSTR, PINFCONTEXT);
+    BOOL SetupFindFirstLineW(HINF, PCWSTR, PCWSTR, PINFCONTEXT);
+    BOOL SetupFindNextLine(PINFCONTEXT, PINFCONTEXT);
+    BOOL SetupFindNextMatchLineA(PINFCONTEXT, PCSTR, PINFCONTEXT);
+    BOOL SetupFindNextMatchLineW(PINFCONTEXT, PCWSTR, PINFCONTEXT);
+    BOOL SetupFreeA(PCSTR**, UINT);
+    BOOL SetupFreeW(PCWSTR**, UINT);
+    BOOL SetupGetBackupInformationA(HSPFILEQ, PSP_BACKUP_QUEUE_PARAMS_A);
+    BOOL SetupGetBackupInformationW(HSPFILEQ, PSP_BACKUP_QUEUE_PARAMS_W);
+    BOOL SetupGetBinaryField(PINFCONTEXT, DWORD, PBYTE, DWORD, LPDWORD);
+    DWORD SetupGetFieldCount(PINFCONTEXT);
+    DWORD SetupGetFileCompressionInfoA(PCSTR, PSTR*, PDWORD, PDWORD, PUINT);
+    DWORD SetupGetFileCompressionInfoW(PCWSTR, PWSTR*, PDWORD, PDWORD, PUINT);
+    BOOL SetupGetInfFileListA(PCSTR, DWORD, PSTR, DWORD, PDWORD);
+    BOOL SetupGetInfFileListW(PCWSTR, DWORD, PWSTR, DWORD, PDWORD);
+    BOOL SetupGetInfInformationA(LPCVOID, DWORD, PSP_INF_INFORMATION, DWORD, PDWORD);
+    BOOL SetupGetInfInformationW(LPCVOID, DWORD, PSP_INF_INFORMATION, DWORD, PDWORD);
+    BOOL SetupGetIntField(PINFCONTEXT, DWORD, PINT);
+    BOOL SetupGetLineByIndexA(HINF, PCSTR, DWORD, PINFCONTEXT);
+    BOOL SetupGetLineByIndexW(HINF, PCWSTR, DWORD, PINFCONTEXT);
+    LONG SetupGetLineCountA(HINF, PCSTR);
+    LONG SetupGetLineCountW(HINF, PCWSTR);
+    BOOL SetupGetLineTextA(PINFCONTEXT, HINF, PCSTR, PCSTR, PSTR, DWORD, PDWORD);
+    BOOL SetupGetLineTextW(PINFCONTEXT, HINF, PCWSTR, PCWSTR, PWSTR, DWORD, PDWORD);
+    BOOL SetupGetMultiSzFieldA(PINFCONTEXT, DWORD, PSTR, DWORD, LPDWORD);
+    BOOL SetupGetMultiSzFieldW(PINFCONTEXT, DWORD, PWSTR, DWORD, LPDWORD);
+    BOOL SetupGetSourceFileLocationA(HINF, PINFCONTEXT, PCSTR, PUINT, PSTR, DWORD, PDWORD);
+    BOOL SetupGetSourceFileLocationW(HINF, PINFCONTEXT, PCWSTR, PUINT, PWSTR, DWORD, PDWORD);
+    BOOL SetupGetSourceFileSizeA(HINF, PINFCONTEXT, PCSTR, PCSTR, PDWORD, UINT);
+    BOOL SetupGetSourceFileSizeW(HINF, PINFCONTEXT, PCWSTR, PCWSTR, PDWORD, UINT);
+    BOOL SetupGetSourceInfoA(HINF, UINT, UINT, PSTR, DWORD, PDWORD);
+    BOOL SetupGetSourceInfoW(HINF, UINT, UINT, PWSTR, DWORD, PDWORD);
+    BOOL SetupGetStringFieldA(PINFCONTEXT, DWORD, PSTR, DWORD, PDWORD);
+    BOOL SetupGetStringFieldW(PINFCONTEXT, DWORD, PWSTR, DWORD, PDWORD);
+    BOOL SetupGetTargetPathA(HINF, PINFCONTEXT, PCSTR, PSTR, DWORD, PDWORD);
+    BOOL SetupGetTargetPathW(HINF, PINFCONTEXT, PCWSTR, PWSTR, DWORD, PDWORD);
+    PVOID SetupInitDefaultQueueCallback(HWND);
+    PVOID SetupInitDefaultQueueCallbackEx(HWND, HWND, UINT, DWORD, PVOID);
+    HSPFILELOG SetupInitializeFileLogA(PCSTR, DWORD);
+    HSPFILELOG SetupInitializeFileLogW(PCWSTR, DWORD);
+    BOOL SetupInstallFileA(HINF, PINFCONTEXT, PCSTR, PCSTR, PCSTR, DWORD, PSP_FILE_CALLBACK_A, PVOID);
+    BOOL SetupInstallFileW(HINF, PINFCONTEXT, PCWSTR, PCWSTR, PCWSTR, DWORD, PSP_FILE_CALLBACK_W, PVOID);
+    BOOL SetupInstallFileExA(HINF, PINFCONTEXT, PCSTR, PCSTR, PCSTR, DWORD, PSP_FILE_CALLBACK_A, PVOID, PBOOL);
+    BOOL SetupInstallFileExW(HINF, PINFCONTEXT, PCWSTR, PCWSTR, PCWSTR, DWORD, PSP_FILE_CALLBACK_W, PVOID, PBOOL);
+    BOOL SetupInstallFilesFromInfSectionA(HINF, HINF, HSPFILEQ, PCSTR, PCSTR, UINT);
+    BOOL SetupInstallFilesFromInfSectionW(HINF, HINF, HSPFILEQ, PCWSTR, PCWSTR, UINT);
+    BOOL SetupInstallFromInfSectionA(HWND, HINF, PCSTR, UINT, HKEY, PCSTR, UINT, PSP_FILE_CALLBACK_A, PVOID, HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupInstallFromInfSectionW(HWND, HINF, PCWSTR, UINT, HKEY, PCWSTR, UINT, PSP_FILE_CALLBACK_W, PVOID, HDEVINFO, PSP_DEVINFO_DATA);
+    BOOL SetupInstallServicesFromInfSectionA(HINF, PCSTR, DWORD);
+    BOOL SetupInstallServicesFromInfSectionW(HINF, PCWSTR, DWORD);
+    BOOL SetupInstallServicesFromInfSectionExA(HINF, PCSTR, DWORD, HDEVINFO, PSP_DEVINFO_DATA, PVOID, PVOID);
+    BOOL SetupInstallServicesFromInfSectionExW(HINF, PCWSTR, DWORD, HDEVINFO, PSP_DEVINFO_DATA, PVOID, PVOID);
+    BOOL SetupIterateCabinetA(PCSTR, DWORD, PSP_FILE_CALLBACK_A, PVOID);
+    BOOL SetupIterateCabinetW(PCWSTR, DWORD, PSP_FILE_CALLBACK_W, PVOID);
+    BOOL SetupLogErrorA(LPCSTR, LogSeverity);
+    BOOL SetupLogErrorW(LPCWSTR, LogSeverity);
+    BOOL SetupLogFileA(HSPFILELOG, PCSTR, PCSTR, PCSTR, DWORD, PCSTR, PCSTR, PCSTR, DWORD);
+    BOOL SetupLogFileW(HSPFILELOG, PCWSTR, PCWSTR, PCWSTR, DWORD, PCWSTR, PCWSTR, PCWSTR, DWORD);
+    BOOL SetupOpenAppendInfFileA(PCSTR, HINF, PUINT);
+    BOOL SetupOpenAppendInfFileW(PCWSTR, HINF, PUINT);
+    HSPFILEQ SetupOpenFileQueue();
+    HINF SetupOpenInfFileA(PCSTR, PCSTR, DWORD, PUINT);
+    HINF SetupOpenInfFileW(PCWSTR, PCWSTR, DWORD, PUINT);
+    BOOL SetupOpenLog(BOOL);
+    HINF SetupOpenMasterInf();
+    UINT SetupPromptForDiskA(HWND, PCSTR, PCSTR, PCSTR, PCSTR, PCSTR, DWORD, PSTR, DWORD, PDWORD);
+    UINT SetupPromptForDiskW(HWND, PCWSTR, PCWSTR, PCWSTR, PCWSTR, PCWSTR, DWORD, PWSTR, DWORD, PDWORD);
+    INT SetupPromptReboot(HSPFILEQ, HWND, BOOL);
+    BOOL SetupQueryA(DWORD, PCSTR**, PUINT);
+    BOOL SetupQueryW(DWORD, PCWSTR**, PUINT);
+    BOOL SetupQueryDrivesInDiskSpaceListA(HDSKSPC, PSTR, DWORD, PDWORD);
+    BOOL SetupQueryDrivesInDiskSpaceListW(HDSKSPC, PWSTR, DWORD, PDWORD);
+    BOOL SetupQueryFileLogA(HSPFILELOG, PCSTR, PCSTR, SetupFileLogInfo, PSTR, DWORD, PDWORD);
+    BOOL SetupQueryFileLogW(HSPFILELOG, PCWSTR, PCWSTR, SetupFileLogInfo, PWSTR, DWORD, PDWORD);
+    BOOL SetupQueryInfFileInformationA(PSP_INF_INFORMATION, UINT, PSTR, DWORD, PDWORD);
+    BOOL SetupQueryInfFileInformationW(PSP_INF_INFORMATION, UINT, PWSTR, DWORD, PDWORD);
+    BOOL SetupQueryInfOriginalFileInformationA(PSP_INF_INFORMATION, UINT, PSP_ALTPLATFORM_INFO, PSP_ORIGINAL_FILE_INFO_A);
+    BOOL SetupQueryInfOriginalFileInformationW(PSP_INF_INFORMATION, UINT, PSP_ALTPLATFORM_INFO, PSP_ORIGINAL_FILE_INFO_W);
+    BOOL SetupQueryInfVersionInformationA(PSP_INF_INFORMATION, UINT, PSTR, PSTR, DWORD, PDWORD);
+    BOOL SetupQueryInfVersionInformationW(PSP_INF_INFORMATION, UINT, PCWSTR, PWSTR, DWORD, PDWORD);
+    BOOL SetupQuerySpaceRequiredOnDriveA(HDSKSPC, PCSTR, LONGLONG*, PVOID, UINT);
+    BOOL SetupQuerySpaceRequiredOnDriveW(HDSKSPC, PCWSTR, LONGLONG*, PVOID, UINT);
+    BOOL SetupQueueCopyA(HSPFILEQ, PCSTR, PCSTR, PCSTR, PCSTR, PCSTR, PCSTR, PCSTR, DWORD);
+    BOOL SetupQueueCopyW(HSPFILEQ, PCWSTR, PCWSTR, PCWSTR, PCWSTR, PCWSTR, PCWSTR, PCWSTR, DWORD);
+    BOOL SetupQueueCopyIndirectA(PSP_FILE_COPY_PARAMS_A);
+    BOOL SetupQueueCopyIndirectW(PSP_FILE_COPY_PARAMS_W);
+    BOOL SetupQueueCopySectionA(HSPFILEQ, PCSTR, HINF, HINF, PCSTR, DWORD);
+    BOOL SetupQueueCopySectionW(HSPFILEQ, PCWSTR, HINF, HINF, PCWSTR, DWORD);
+    BOOL SetupQueueDefaultCopyA(HSPFILEQ, HINF, PCSTR, PCSTR, PCSTR, DWORD);
+    BOOL SetupQueueDefaultCopyW(HSPFILEQ, HINF, PCWSTR, PCWSTR, PCWSTR, DWORD);
+    BOOL SetupQueueDeleteA(HSPFILEQ, PCSTR, PCSTR);
+    BOOL SetupQueueDeleteW(HSPFILEQ, PCWSTR, PCWSTR);
+    BOOL SetupQueueDeleteSectionA(HSPFILEQ, HINF, HINF, PCSTR);
+    BOOL SetupQueueDeleteSectionW(HSPFILEQ, HINF, HINF, PCWSTR);
+    BOOL SetupQueueRenameA(HSPFILEQ, PCSTR, PCSTR, PCSTR, PCSTR);
+    BOOL SetupQueueRenameW(HSPFILEQ, PCWSTR, PCWSTR, PCWSTR, PCWSTR);
+    BOOL SetupQueueRenameSectionA(HSPFILEQ, HINF, HINF, PCSTR);
+    BOOL SetupQueueRenameSectionW(HSPFILEQ, HINF, HINF, PCWSTR);
+    BOOL SetupRemoveFileLogEntryA(HSPFILELOG, PCSTR, PCSTR);
+    BOOL SetupRemoveFileLogEntryW(HSPFILELOG, PCWSTR, PCWSTR);
+    BOOL SetupRemoveFromDiskSpaceListA(HDSKSPC, PCSTR, UINT, PVOID, UINT);
+    BOOL SetupRemoveFromDiskSpaceListW(HDSKSPC, PCWSTR, UINT, PVOID, UINT);
+    BOOL SetupRemoveFromSourceListA(DWORD, PCSTR);
+    BOOL SetupRemoveFromSourceListW(DWORD, PCWSTR);
+    BOOL SetupRemoveInstallSectionFromDiskSpaceListA(HDSKSPC, HINF, HINF, PCSTR, PVOID, UINT);
+    BOOL SetupRemoveInstallSectionFromDiskSpaceListW(HDSKSPC, HINF, HINF, PCWSTR, PVOID, UINT);
+    BOOL SetupRemoveSectionFromDiskSpaceListA(HDSKSPC, HINF, HINF, PCSTR, UINT, PVOID, UINT);
+    BOOL SetupRemoveSectionFromDiskSpaceListW(HDSKSPC, HINF, HINF, PCWSTR, UINT, PVOID, UINT);
+    UINT SetupRenameErrorA(HWND, PCSTR, PCSTR, PCSTR, UINT, DWORD);
+    UINT SetupRenameErrorW(HWND, PCWSTR, PCWSTR, PCWSTR, UINT, DWORD);
+    BOOL SetupScanFileQueueA(HSPFILEQ, DWORD, HWND, PSP_FILE_CALLBACK_A, PVOID, PDWORD);
+    BOOL SetupScanFileQueueW(HSPFILEQ, DWORD, HWND, PSP_FILE_CALLBACK_W, PVOID, PDWORD);
+    BOOL SetupSetDirectoryIdA(HINF, DWORD, PCSTR);
+    BOOL SetupSetDirectoryIdW(HINF, DWORD, PCWSTR);
+    BOOL SetupSetDirectoryIdExA(HINF, DWORD, PCSTR, DWORD, DWORD, PVOID);
+    BOOL SetupSetDirectoryIdExW(HINF, DWORD, PCWSTR, DWORD, DWORD, PVOID);
+    BOOL SetupSetFileQueueAlternatePlatformA(HSPFILEQ, PSP_ALTPLATFORM_INFO, PCSTR);
+    BOOL SetupSetFileQueueAlternatePlatformW(HSPFILEQ, PSP_ALTPLATFORM_INFO, PCWSTR);
+    BOOL SetupSetPlatformPathOverrideA(PCSTR);
+    BOOL SetupSetPlatformPathOverrideW(PCWSTR);
+    BOOL SetupSetSourceListA(DWORD, PCSTR*, UINT);
+    BOOL SetupSetSourceListW(DWORD, PCWSTR*, UINT);
+    VOID SetupTermDefaultQueueCallback(PVOID);
+    BOOL SetupTerminateFileLog(HSPFILELOG);
+}
+
+deprecated {
+    alias SetupDiCreateDeviceInterfaceW SetupDiCreateInterfaceDeviceW;
+    alias SetupDiCreateDeviceInterfaceRegKeyW SetupDiCreateInterfaceDeviceRegKeyW;
+    alias SetupDiOpenDeviceInterfaceW SetupDiOpenInterfaceDeviceW;
+    alias SetupDiGetDeviceInterfaceDetailW SetupDiGetInterfaceDeviceDetailW;
+    alias SetupDiCreateDeviceInterfaceA SetupDiCreateInterfaceDeviceA;
+    alias SetupDiCreateDeviceInterfaceRegKeyA SetupDiCreateInterfaceDeviceRegKeyA;
+    alias SetupDiOpenDeviceInterfaceA SetupDiOpenInterfaceDeviceA;
+    alias SetupDiGetDeviceInterfaceDetailA SetupDiGetInterfaceDeviceDetailA;
+}
+
+version (Unicode) {
+    alias PSP_FILE_CALLBACK_W PSP_FILE_CALLBACK;
+    alias SetupAddInstallSectionToDiskSpaceListW SetupAddInstallSectionToDiskSpaceList;
+    alias SetupAddSectionToDiskSpaceListW SetupAddSectionToDiskSpaceList;
+    alias SetupAddToDiskSpaceListW SetupAddToDiskSpaceList;
+    alias SetupAddToSourceListW SetupAddToSourceList;
+    alias SetupAdjustDiskSpaceListW SetupAdjustDiskSpaceList;
+    alias SetupBackupErrorW SetupBackupError;
+    alias SetupCommitFileQueueW SetupCommitFileQueue;
+    alias SetupCopyErrorW SetupCopyError;
+    alias SetupCopyOEMInfW SetupCopyOEMInf;
+    alias SetupCreateDiskSpaceListW SetupCreateDiskSpaceList;
+    alias SetupDecompressOrCopyFileW SetupDecompressOrCopyFile;
+    alias SetupDefaultQueueCallbackW SetupDefaultQueueCallback;
+    alias SetupDeleteErrorW SetupDeleteError;
+    alias SetupDiBuildClassInfoListExW SetupDiBuildClassInfoListEx;
+    alias SetupDiClassGuidsFromNameExW SetupDiClassGuidsFromNameEx;
+    alias SetupDiClassGuidsFromNameW SetupDiClassGuidsFromName;
+    alias SetupDiClassNameFromGuidExW SetupDiClassNameFromGuidEx;
+    alias SetupDiClassNameFromGuidW SetupDiClassNameFromGuid;
+    alias SetupDiCreateDeviceInfoListExW SetupDiCreateDeviceInfoListEx;
+    alias SetupDiCreateDeviceInfoW SetupDiCreateDeviceInfo;
+    alias SetupDiCreateDeviceInterfaceRegKeyW SetupDiCreateDeviceInterfaceRegKey;
+    deprecated alias SetupDiCreateDeviceInterfaceRegKeyW SetupDiCreateInterfaceDeviceRegKey;
+    alias SetupDiCreateDeviceInterfaceW SetupDiCreateDeviceInterface;
+    deprecated alias SetupDiCreateDeviceInterfaceW SetupDiCreateInterfaceDevice;
+    alias SetupDiCreateDevRegKeyW SetupDiCreateDevRegKey;
+    alias SetupDiEnumDriverInfoW SetupDiEnumDriverInfo;
+    alias SetupDiGetActualSectionToInstallW SetupDiGetActualSectionToInstall;
+    alias SetupDiGetClassDescriptionExW SetupDiGetClassDescriptionEx;
+    alias SetupDiGetClassDescriptionW SetupDiGetClassDescription;
+    alias SetupDiGetClassDevPropertySheetsW SetupDiGetClassDevPropertySheets;
+    alias SetupDiGetClassDevsExW SetupDiGetClassDevsEx;
+    alias SetupDiGetClassDevsW SetupDiGetClassDevs;
+    alias SetupDiGetClassImageListExW SetupDiGetClassImageListEx;
+    alias SetupDiGetClassInstallParamsW SetupDiGetClassInstallParams;
+    alias SetupDiGetClassRegistryPropertyW SetupDiGetClassRegistryProperty;
+    alias SetupDiGetDeviceInfoListDetailW SetupDiGetDeviceInfoListDetail;
+    alias SetupDiGetDeviceInstallParamsW SetupDiGetDeviceInstallParams;
+    alias SetupDiGetDeviceInstanceIdW SetupDiGetDeviceInstanceId;
+    alias SetupDiGetDeviceInterfaceDetailW SetupDiGetDeviceInterfaceDetail;
+    deprecated alias SetupDiGetDeviceInterfaceDetailW SetupDiGetInterfaceDeviceDetail;
+    alias SetupDiGetDeviceRegistryPropertyW SetupDiGetDeviceRegistryProperty;
+    alias SetupDiGetDriverInfoDetailW SetupDiGetDriverInfoDetail;
+    alias SetupDiGetDriverInstallParamsW SetupDiGetDriverInstallParams;
+    alias SetupDiGetHwProfileFriendlyNameExW SetupDiGetHwProfileFriendlyNameEx;
+    alias SetupDiGetHwProfileFriendlyNameW SetupDiGetHwProfileFriendlyName;
+    alias SetupDiGetHwProfileListExW SetupDiGetHwProfileListEx;
+    alias SetupDiGetINFClassW SetupDiGetINFClass;
+    alias SetupDiGetSelectedDriverW SetupDiGetSelectedDriver;
+    alias SetupDiInstallClassExW SetupDiInstallClassEx;
+    alias SetupDiInstallClassW SetupDiInstallClass;
+    alias SetupDiOpenClassRegKeyExW SetupDiOpenClassRegKeyEx;
+    alias SetupDiOpenDeviceInfoW SetupDiOpenDeviceInfo;
+    alias SetupDiOpenDeviceInterfaceW SetupDiOpenDeviceInterface;
+    deprecated alias SetupDiOpenDeviceInterfaceW SetupDiOpenInterfaceDevice;
+    alias SetupDiSetClassInstallParamsW SetupDiSetClassInstallParams;
+    alias SetupDiSetClassRegistryPropertyW SetupDiSetClassRegistryProperty;
+    alias SetupDiSetDeviceInstallParamsW SetupDiSetDeviceInstallParams;
+    alias SetupDiSetDeviceRegistryPropertyW SetupDiSetDeviceRegistryProperty;
+    alias SetupDiSetDriverInstallParamsW SetupDiSetDriverInstallParams;
+    alias SetupDiSetSelectedDriverW SetupDiSetSelectedDriver;
+    alias SetupDuplicateDiskSpaceListW SetupDuplicateDiskSpaceList;
+    alias SetupFindFirstLineW SetupFindFirstLine;
+    alias SetupFindNextMatchLineW SetupFindNextMatchLine;
+    alias SetupFreeSourceListW SetupFreeSourceList;
+    alias SetupGetBackupInformationW SetupGetBackupInformation;
+    alias SetupGetFileCompressionInfoW SetupGetFileCompressionInfo;
+    alias SetupGetInfFileListW SetupGetInfFileList;
+    alias SetupGetInfInformationW SetupGetInfInformation;
+    alias SetupGetLineByIndexW SetupGetLineByIndex;
+    alias SetupGetLineCountW SetupGetLineCount;
+    alias SetupGetLineTextW SetupGetLineText;
+    alias SetupGetMultiSzFieldW SetupGetMultiSzField;
+    alias SetupGetSourceFileLocationW SetupGetSourceFileLocation;
+    alias SetupGetSourceFileSizeW SetupGetSourceFileSize;
+    alias SetupGetSourceInfoW SetupGetSourceInfo;
+    alias SetupGetStringFieldW SetupGetStringField;
+    alias SetupGetTargetPathW SetupGetTargetPath;
+    alias SetupInitializeFileLogW SetupInitializeFileLog;
+    alias SetupInstallFileExW SetupInstallFileEx;
+    alias SetupInstallFilesFromInfSectionW SetupInstallFilesFromInfSection;
+    alias SetupInstallFileW SetupInstallFile;
+    alias SetupInstallFromInfSectionW SetupInstallFromInfSection;
+    alias SetupInstallServicesFromInfSectionExW SetupInstallServicesFromInfSectionEx;
+    alias SetupInstallServicesFromInfSectionW SetupInstallServicesFromInfSection;
+    alias SetupIterateCabinetW SetupIterateCabinet;
+    alias SetupLogErrorW SetupLogError;
+    alias SetupLogFileW SetupLogFile;
+    alias SetupOpenAppendInfFileW SetupOpenAppendInfFile;
+    alias SetupOpenInfFileW SetupOpenInfFile;
+    alias SetupPromptForDiskW SetupPromptForDisk;
+    alias SetupQueryDrivesInDiskSpaceListW SetupQueryDrivesInDiskSpaceList;
+    alias SetupQueryFileLogW SetupQueryFileLog;
+    alias SetupQueryInfFileInformationW SetupQueryInfFileInformation;
+    alias SetupQueryInfOriginalFileInformationW SetupQueryInfOriginalFileInformation;
+    alias SetupQueryInfVersionInformationW SetupQueryInfVersionInformation;
+    alias SetupQuerySourceListW SetupQuerySourceList;
+    alias SetupQuerySpaceRequiredOnDriveW SetupQuerySpaceRequiredOnDrive;
+    alias SetupQueueCopyIndirectW SetupQueueCopyIndirect;
+    alias SetupQueueCopySectionW SetupQueueCopySection;
+    alias SetupQueueCopyW SetupQueueCopy;
+    alias SetupQueueDefaultCopyW SetupQueueDefaultCopy;
+    alias SetupQueueDeleteSectionW SetupQueueDeleteSection;
+    alias SetupQueueDeleteW SetupQueueDelete;
+    alias SetupQueueRenameSectionW SetupQueueRenameSection;
+    alias SetupQueueRenameW SetupQueueRename;
+    alias SetupRemoveFileLogEntryW SetupRemoveFileLogEntry;
+    alias SetupRemoveFromDiskSpaceListW SetupRemoveFromDiskSpaceList;
+    alias SetupRemoveFromSourceListW SetupRemoveFromSourceList;
+    alias SetupRemoveInstallSectionFromDiskSpaceListW SetupRemoveInstallSectionFromDiskSpaceList;
+    alias SetupRemoveSectionFromDiskSpaceListW SetupRemoveSectionFromDiskSpaceList;
+    alias SetupRenameErrorW SetupRenameError;
+    alias SetupScanFileQueueW SetupScanFileQueue;
+    alias SetupSetDirectoryIdExW SetupSetDirectoryIdEx;
+    alias SetupSetDirectoryIdW SetupSetDirectoryId;
+    alias SetupSetFileQueueAlternatePlatformW SetupSetFileQueueAlternatePlatform;
+    alias SetupSetPlatformPathOverrideW SetupSetPlatformPathOverride;
+    alias SetupSetSourceListW SetupSetSourceList;
+} else {
+    alias PSP_FILE_CALLBACK_A PSP_FILE_CALLBACK;
+    alias SetupAddInstallSectionToDiskSpaceListA SetupAddInstallSectionToDiskSpaceList;
+    alias SetupAddSectionToDiskSpaceListA SetupAddSectionToDiskSpaceList;
+    alias SetupAddToDiskSpaceListA SetupAddToDiskSpaceList;
+    alias SetupAddToSourceListA SetupAddToSourceList;
+    alias SetupAdjustDiskSpaceListA SetupAdjustDiskSpaceList;
+    alias SetupBackupErrorA SetupBackupError;
+    alias SetupCommitFileQueueA SetupCommitFileQueue;
+    alias SetupCopyErrorA SetupCopyError;
+    alias SetupCopyOEMInfA SetupCopyOEMInf;
+    alias SetupCreateDiskSpaceListA SetupCreateDiskSpaceList;
+    alias SetupDecompressOrCopyFileA SetupDecompressOrCopyFile;
+    alias SetupDefaultQueueCallbackA SetupDefaultQueueCallback;
+    alias SetupDeleteErrorA SetupDeleteError;
+    alias SetupDiBuildClassInfoListExA SetupDiBuildClassInfoListEx;
+    alias SetupDiClassGuidsFromNameA SetupDiClassGuidsFromName;
+    alias SetupDiClassGuidsFromNameExA SetupDiClassGuidsFromNameEx;
+    alias SetupDiClassNameFromGuidA SetupDiClassNameFromGuid;
+    alias SetupDiClassNameFromGuidExA SetupDiClassNameFromGuidEx;
+    alias SetupDiCreateDeviceInfoA SetupDiCreateDeviceInfo;
+    alias SetupDiCreateDeviceInfoListExA SetupDiCreateDeviceInfoListEx;
+    alias SetupDiCreateDeviceInterfaceA SetupDiCreateDeviceInterface;
+    deprecated alias SetupDiCreateDeviceInterfaceA SetupDiCreateInterfaceDevice;
+    alias SetupDiCreateDeviceInterfaceRegKeyA SetupDiCreateDeviceInterfaceRegKey;
+    deprecated alias SetupDiCreateDeviceInterfaceRegKeyA SetupDiCreateInterfaceDeviceRegKey;
+    alias SetupDiCreateDevRegKeyA SetupDiCreateDevRegKey;
+    alias SetupDiDeleteDeviceInterfaceData SetupDiDeleteInterfaceDeviceData;
+    alias SetupDiEnumDriverInfoA SetupDiEnumDriverInfo;
+    alias SetupDiGetActualSectionToInstallA SetupDiGetActualSectionToInstall;
+    alias SetupDiGetClassDescriptionA SetupDiGetClassDescription;
+    alias SetupDiGetClassDescriptionExA SetupDiGetClassDescriptionEx;
+    alias SetupDiGetClassDevPropertySheetsA SetupDiGetClassDevPropertySheets;
+    alias SetupDiGetClassDevsA SetupDiGetClassDevs;
+    alias SetupDiGetClassDevsExA SetupDiGetClassDevsEx;
+    alias SetupDiGetClassImageListExA SetupDiGetClassImageListEx;
+    alias SetupDiGetClassInstallParamsA SetupDiGetClassInstallParams;
+    alias SetupDiGetClassRegistryPropertyA SetupDiGetClassRegistryProperty;
+    alias SetupDiGetDeviceInfoListDetailA SetupDiGetDeviceInfoListDetail;
+    alias SetupDiGetDeviceInstallParamsA SetupDiGetDeviceInstallParams;
+    alias SetupDiGetDeviceInstanceIdA SetupDiGetDeviceInstanceId;
+    alias SetupDiGetDeviceInterfaceDetailA SetupDiGetDeviceInterfaceDetail;
+    deprecated alias SetupDiGetDeviceInterfaceDetailA SetupDiGetInterfaceDeviceDetail;
+    alias SetupDiGetDeviceRegistryPropertyA SetupDiGetDeviceRegistryProperty;
+    alias SetupDiGetDriverInfoDetailA SetupDiGetDriverInfoDetail;
+    alias SetupDiGetDriverInstallParamsA SetupDiGetDriverInstallParams;
+    alias SetupDiGetHwProfileFriendlyNameA SetupDiGetHwProfileFriendlyName;
+    alias SetupDiGetHwProfileFriendlyNameExA SetupDiGetHwProfileFriendlyNameEx;
+    alias SetupDiGetHwProfileListExA SetupDiGetHwProfileListEx;
+    alias SetupDiGetINFClassA SetupDiGetINFClass;
+    alias SetupDiGetSelectedDriverA SetupDiGetSelectedDriver;
+    alias SetupDiInstallClassA SetupDiInstallClass;
+    alias SetupDiInstallClassExA SetupDiInstallClassEx;
+    alias SetupDiOpenClassRegKeyExA SetupDiOpenClassRegKeyEx;
+    alias SetupDiOpenDeviceInfoA SetupDiOpenDeviceInfo;
+    alias SetupDiOpenDeviceInterfaceA SetupDiOpenDeviceInterface;
+    deprecated alias SetupDiOpenDeviceInterfaceA SetupDiOpenInterfaceDevice;
+    alias SetupDiSetClassInstallParamsA SetupDiSetClassInstallParams;
+    alias SetupDiSetClassRegistryPropertyA SetupDiSetClassRegistryProperty;
+    alias SetupDiSetDeviceInstallParamsA SetupDiSetDeviceInstallParams;
+    alias SetupDiSetDeviceRegistryPropertyA SetupDiSetDeviceRegistryProperty;
+    alias SetupDiSetDriverInstallParamsA SetupDiSetDriverInstallParams;
+    alias SetupDiSetSelectedDriverA SetupDiSetSelectedDriver;
+    alias SetupDuplicateDiskSpaceListA SetupDuplicateDiskSpaceList;
+    alias SetupFindFirstLineA SetupFindFirstLine;
+    alias SetupFindNextMatchLineA SetupFindNextMatchLine;
+    alias SetupFreeSourceListA SetupFreeSourceList;
+    alias SetupGetBackupInformationA SetupGetBackupInformation;
+    alias SetupGetFileCompressionInfoA SetupGetFileCompressionInfo;
+    alias SetupGetInfFileListA SetupGetInfFileList;
+    alias SetupGetInfInformationA SetupGetInfInformation;
+    alias SetupGetLineByIndexA SetupGetLineByIndex;
+    alias SetupGetLineCountA SetupGetLineCount;
+    alias SetupGetLineTextA SetupGetLineText;
+    alias SetupGetMultiSzFieldA SetupGetMultiSzField;
+    alias SetupGetSourceFileLocationA SetupGetSourceFileLocation;
+    alias SetupGetSourceFileSizeA SetupGetSourceFileSize;
+    alias SetupGetSourceInfoA SetupGetSourceInfo;
+    alias SetupGetStringFieldA SetupGetStringField;
+    alias SetupGetTargetPathA SetupGetTargetPath;
+    alias SetupInitializeFileLogA SetupInitializeFileLog;
+    alias SetupInstallFileA SetupInstallFile;
+    alias SetupInstallFileExA SetupInstallFileEx;
+    alias SetupInstallFilesFromInfSectionA SetupInstallFilesFromInfSection;
+    alias SetupInstallFromInfSectionA SetupInstallFromInfSection;
+    alias SetupInstallServicesFromInfSectionA SetupInstallServicesFromInfSection;
+    alias SetupInstallServicesFromInfSectionExA SetupInstallServicesFromInfSectionEx;
+    alias SetupIterateCabinetA SetupIterateCabinet;
+    alias SetupLogErrorA SetupLogError;
+    alias SetupLogFileA SetupLogFile;
+    alias SetupOpenAppendInfFileA SetupOpenAppendInfFile;
+    alias SetupOpenInfFileA SetupOpenInfFile;
+    alias SetupPromptForDiskA SetupPromptForDisk;
+    alias SetupQueryDrivesInDiskSpaceListA SetupQueryDrivesInDiskSpaceList;
+    alias SetupQueryFileLogA SetupQueryFileLog;
+    alias SetupQueryInfFileInformationA SetupQueryInfFileInformation;
+    alias SetupQueryInfOriginalFileInformationA SetupQueryInfOriginalFileInformation;
+    alias SetupQueryInfVersionInformationA SetupQueryInfVersionInformation;
+    alias SetupQuerySourceListA SetupQuerySourceList;
+    alias SetupQuerySpaceRequiredOnDriveA SetupQuerySpaceRequiredOnDrive;
+    alias SetupQueueCopyA SetupQueueCopy;
+    alias SetupQueueCopyIndirectA SetupQueueCopyIndirect;
+    alias SetupQueueCopySectionA SetupQueueCopySection;
+    alias SetupQueueDefaultCopyA SetupQueueDefaultCopy;
+    alias SetupQueueDeleteA SetupQueueDelete;
+    alias SetupQueueDeleteSectionA SetupQueueDeleteSection;
+    alias SetupQueueRenameA SetupQueueRename;
+    alias SetupQueueRenameSectionA SetupQueueRenameSection;
+    alias SetupRemoveFileLogEntryA SetupRemoveFileLogEntry;
+    alias SetupRemoveFromDiskSpaceListA SetupRemoveFromDiskSpaceList;
+    alias SetupRemoveFromSourceListA SetupRemoveFromSourceList;
+    alias SetupRemoveInstallSectionFromDiskSpaceListA SetupRemoveInstallSectionFromDiskSpaceList;
+    alias SetupRemoveSectionFromDiskSpaceListA SetupRemoveSectionFromDiskSpaceList;
+    alias SetupRenameErrorA SetupRenameError;
+    alias SetupScanFileQueueA SetupScanFileQueue;
+    alias SetupSetDirectoryIdA SetupSetDirectoryId;
+    alias SetupSetDirectoryIdExA SetupSetDirectoryIdEx;
+    alias SetupSetFileQueueAlternatePlatformA SetupSetFileQueueAlternatePlatform;
+    alias SetupSetPlatformPathOverrideA SetupSetPlatformPathOverride;
+    alias SetupSetSourceListA SetupSetSourceList;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/shellapi.d b/libphobos/libdruntime/core/sys/windows/shellapi.d
new file mode 100644
index 00000000000..ae8a494462c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/shellapi.d
@@ -0,0 +1,420 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_shellapi.d)
+ */
+module core.sys.windows.shellapi;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "shell32");
+
+private import core.sys.windows.w32api, core.sys.windows.windef, core.sys.windows.basetyps;
+
+enum : UINT {
+    ABE_LEFT,
+    ABE_TOP,
+    ABE_RIGHT,
+    ABE_BOTTOM // = 3
+}
+
+enum : UINT {
+    ABS_AUTOHIDE    = 1,
+    ABS_ALWAYSONTOP
+}
+
+enum ULONG
+    SEE_MASK_CLASSNAME      =        1,
+    SEE_MASK_CLASSKEY       =        3,
+    SEE_MASK_IDLIST         =        4,
+    SEE_MASK_INVOKEIDLIST   =       12,
+    SEE_MASK_ICON           = 0x000010,
+    SEE_MASK_HOTKEY         = 0x000020,
+    SEE_MASK_NOCLOSEPROCESS = 0x000040,
+    SEE_MASK_CONNECTNETDRV  = 0x000080,
+    SEE_MASK_FLAG_DDEWAIT   = 0x000100,
+    SEE_MASK_DOENVSUBST     = 0x000200,
+    SEE_MASK_FLAG_NO_UI     = 0x000400,
+    SEE_MASK_NO_CONSOLE     = 0x008000,
+    SEE_MASK_UNICODE        = 0x010000,
+    SEE_MASK_ASYNCOK        = 0x100000,
+    SEE_MASK_HMONITOR       = 0x200000;
+
+enum : DWORD {
+    ABM_NEW,
+    ABM_REMOVE,
+    ABM_QUERYPOS,
+    ABM_SETPOS,
+    ABM_GETSTATE,
+    ABM_GETTASKBARPOS,
+    ABM_ACTIVATE,
+    ABM_GETAUTOHIDEBAR,
+    ABM_SETAUTOHIDEBAR,
+    ABM_WINDOWPOSCHANGED // = 9
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+enum DWORD ABM_SETSTATE = 10;
+}
+
+enum : UINT {
+    ABN_STATECHANGE,
+    ABN_POSCHANGED,
+    ABN_FULLSCREENAPP,
+    ABN_WINDOWARRANGE
+}
+
+enum : DWORD {
+    NIM_ADD,
+    NIM_MODIFY,
+    NIM_DELETE
+}
+
+static if (_WIN32_IE >= 0x500) {
+enum NOTIFYICON_VERSION = 3;
+
+    enum : DWORD {
+        NIM_SETFOCUS = 3,
+        NIM_SETVERSION
+    }
+}
+
+enum UINT
+    NIF_MESSAGE = 1,
+    NIF_ICON    = 2,
+    NIF_TIP     = 4,
+    NIF_STATE   = 8;
+
+static if (_WIN32_IE >= 0x500) {
+enum UINT NIF_INFO = 0x00000010;
+}
+
+static if (_WIN32_IE >= 0x600) {
+enum UINT NIF_GUID = 0x00000020;
+}
+
+static if (_WIN32_IE >= 0x500) {
+    enum : DWORD {
+        NIIF_NONE,
+        NIIF_INFO,
+        NIIF_WARNING,
+        NIIF_ERROR
+    }
+}
+
+static if (_WIN32_IE >= 0x600) {
+    enum : DWORD {
+        NIIF_ICON_MASK = 15,
+        NIIF_NOSOUND
+    }
+}
+
+enum DWORD
+    NIS_HIDDEN     = 1,
+    NIS_SHAREDICON = 2;
+
+enum HINSTANCE
+    SE_ERR_FNF             = cast(HINSTANCE)  2,
+    SE_ERR_PNF             = cast(HINSTANCE)  3,
+    SE_ERR_ACCESSDENIED    = cast(HINSTANCE)  5,
+    SE_ERR_OOM             = cast(HINSTANCE)  8,
+    SE_ERR_DLLNOTFOUND     = cast(HINSTANCE) 32,
+    SE_ERR_SHARE           = cast(HINSTANCE) 26,
+    SE_ERR_ASSOCINCOMPLETE = cast(HINSTANCE) 27,
+    SE_ERR_DDETIMEOUT      = cast(HINSTANCE) 28,
+    SE_ERR_DDEFAIL         = cast(HINSTANCE) 29,
+    SE_ERR_DDEBUSY         = cast(HINSTANCE) 30,
+    SE_ERR_NOASSOC         = cast(HINSTANCE) 31;
+
+enum : UINT {
+    FO_MOVE = 1,
+    FO_COPY,
+    FO_DELETE,
+    FO_RENAME
+}
+
+enum FILEOP_FLAGS
+    FOF_MULTIDESTFILES        = 0x0001,
+    FOF_CONFIRMMOUSE          = 0x0002,
+    FOF_SILENT                = 0x0004,
+    FOF_RENAMEONCOLLISION     = 0x0008,
+    FOF_NOCONFIRMATION        = 0x0010,
+    FOF_WANTMAPPINGHANDLE     = 0x0020,
+    FOF_ALLOWUNDO             = 0x0040,
+    FOF_FILESONLY             = 0x0080,
+    FOF_SIMPLEPROGRESS        = 0x0100,
+    FOF_NOCONFIRMMKDIR        = 0x0200,
+    FOF_NOERRORUI             = 0x0400,
+    FOF_NOCOPYSECURITYATTRIBS = 0x0800;
+
+// these are not documented on the MSDN site
+enum {
+    PO_DELETE     = 19,
+    PO_RENAME     = 20,
+    PO_PORTCHANGE = 32,
+    PO_REN_PORT   = 52
+}
+
+enum UINT
+    SHGFI_LARGEICON         = 0x000000,
+    SHGFI_SMALLICON         = 0x000001,
+    SHGFI_OPENICON          = 0x000002,
+    SHGFI_SHELLICONSIZE     = 0x000004,
+    SHGFI_PIDL              = 0x000008,
+    SHGFI_USEFILEATTRIBUTES = 0x000010,
+    SHGFI_ICON              = 0x000100,
+    SHGFI_DISPLAYNAME       = 0x000200,
+    SHGFI_TYPENAME          = 0x000400,
+    SHGFI_ATTRIBUTES        = 0x000800,
+    SHGFI_ICONLOCATION      = 0x001000,
+    SHGFI_EXETYPE           = 0x002000,
+    SHGFI_SYSICONINDEX      = 0x004000,
+    SHGFI_LINKOVERLAY       = 0x008000,
+    SHGFI_SELECTED          = 0x010000,
+    SHGFI_ATTR_SPECIFIED    = 0x020000;
+
+static if (_WIN32_IE >= 0x500) {
+enum uint
+        SHGFI_ADDOVERLAYS   = 0x000020,
+        SHGFI_OVERLAYINDEX  = 0x000040;
+}
+
+enum SHERB_NOCONFIRMATION = 1;
+enum SHERB_NOPROGRESSUI   = 2;
+enum SHERB_NOSOUND        = 4;
+
+alias WORD FILEOP_FLAGS, PRINTEROP_FLAGS;
+mixin DECLARE_HANDLE!("HDROP");
+
+align(2):
+
+struct APPBARDATA {
+    DWORD  cbSize = APPBARDATA.sizeof;
+    HWND   hWnd;
+    UINT   uCallbackMessage;
+    UINT   uEdge;
+    RECT   rc;
+    LPARAM lParam;
+}
+alias APPBARDATA* PAPPBARDATA;
+
+struct NOTIFYICONDATAA {
+    DWORD cbSize = NOTIFYICONDATAA.sizeof;
+    HWND  hWnd;
+    UINT  uID;
+    UINT  uFlags;
+    UINT  uCallbackMessage;
+    HICON hIcon;
+    static if (_WIN32_IE >= 0x500) {
+        CHAR[128] szTip;
+        DWORD     dwState;
+        DWORD     dwStateMask;
+        CHAR[256] szInfo;
+        union {
+            UINT  uTimeout;
+            UINT  uVersion;
+        }
+        CHAR[64]  szInfoTitle;
+        DWORD     dwInfoFlags;
+    } else {
+        CHAR[64]  szTip;
+    }
+    static if (_WIN32_IE >= 0x600) {
+        GUID      guidItem;
+    }
+}
+alias NOTIFYICONDATAA* PNOTIFYICONDATAA;
+
+struct NOTIFYICONDATAW {
+    DWORD cbSize = NOTIFYICONDATAW.sizeof;
+    HWND  hWnd;
+    UINT  uID;
+    UINT  uFlags;
+    UINT  uCallbackMessage;
+    HICON hIcon;
+    static if (_WIN32_IE >= 0x500) {
+        WCHAR[128] szTip;
+        DWORD      dwState;
+        DWORD      dwStateMask;
+        WCHAR[256] szInfo;
+        union {
+            UINT   uTimeout;
+            UINT   uVersion;
+        }
+        WCHAR[64]  szInfoTitle;
+        DWORD      dwInfoFlags;
+    } else {
+        WCHAR[64]  szTip;
+    }
+    static if (_WIN32_IE >= 0x600) {
+        GUID guidItem;
+    }
+}
+alias NOTIFYICONDATAW* PNOTIFYICONDATAW;
+
+struct SHELLEXECUTEINFOA {
+    DWORD     cbSize = SHELLEXECUTEINFOA.sizeof;
+    ULONG     fMask;
+    HWND      hwnd;
+    LPCSTR    lpVerb;
+    LPCSTR    lpFile;
+    LPCSTR    lpParameters;
+    LPCSTR    lpDirectory;
+    int       nShow;
+    HINSTANCE hInstApp;
+    PVOID     lpIDList;
+    LPCSTR    lpClass;
+    HKEY      hkeyClass;
+    DWORD     dwHotKey;
+    HANDLE    hIcon;
+    HANDLE    hProcess;
+}
+alias SHELLEXECUTEINFOA* LPSHELLEXECUTEINFOA;
+
+struct SHELLEXECUTEINFOW {
+    DWORD     cbSize = SHELLEXECUTEINFOW.sizeof;
+    ULONG     fMask;
+    HWND      hwnd;
+    LPCWSTR   lpVerb;
+    LPCWSTR   lpFile;
+    LPCWSTR   lpParameters;
+    LPCWSTR   lpDirectory;
+    int       nShow;
+    HINSTANCE hInstApp;
+    PVOID     lpIDList;
+    LPCWSTR   lpClass;
+    HKEY      hkeyClass;
+    DWORD     dwHotKey;
+    HANDLE    hIcon;
+    HANDLE    hProcess;
+}
+alias SHELLEXECUTEINFOW* LPSHELLEXECUTEINFOW;
+
+struct SHFILEOPSTRUCTA {
+    HWND         hwnd;
+    UINT         wFunc;
+    LPCSTR       pFrom;
+    LPCSTR       pTo;
+    FILEOP_FLAGS fFlags;
+    BOOL         fAnyOperationsAborted;
+    PVOID        hNameMappings;
+    LPCSTR       lpszProgressTitle;
+}
+alias SHFILEOPSTRUCTA* LPSHFILEOPSTRUCTA;
+
+struct SHFILEOPSTRUCTW {
+    HWND         hwnd;
+    UINT         wFunc;
+    LPCWSTR      pFrom;
+    LPCWSTR      pTo;
+    FILEOP_FLAGS fFlags;
+    BOOL         fAnyOperationsAborted;
+    PVOID        hNameMappings;
+    LPCWSTR      lpszProgressTitle;
+}
+alias SHFILEOPSTRUCTW* LPSHFILEOPSTRUCTW;
+
+struct SHFILEINFOA {
+    HICON          hIcon;
+    int            iIcon;
+    DWORD          dwAttributes;
+    CHAR[MAX_PATH] szDisplayName;
+    CHAR[80]       szTypeName;
+}
+
+struct SHFILEINFOW {
+    HICON           hIcon;
+    int             iIcon;
+    DWORD           dwAttributes;
+    WCHAR[MAX_PATH] szDisplayName;
+    WCHAR[80]       szTypeName;
+}
+
+align(1) struct SHQUERYRBINFO {
+    DWORD cbSize = SHQUERYRBINFO.sizeof;
+    long  i64Size;
+    long  i64NumItems;
+}
+alias SHQUERYRBINFO* LPSHQUERYRBINFO;
+
+extern (Windows) nothrow @nogc {
+    LPWSTR* CommandLineToArgvW(LPCWSTR, int*);
+    void DragAcceptFiles(HWND, BOOL);
+    void DragFinish(HDROP);
+    UINT DragQueryFileA(HDROP, UINT, LPSTR, UINT);
+    UINT DragQueryFileW(HDROP, UINT, LPWSTR, UINT);
+    BOOL DragQueryPoint(HDROP, LPPOINT);
+    HICON DuplicateIcon(HINSTANCE, HICON);
+    HICON ExtractAssociatedIconA(HINSTANCE, LPCSTR, PWORD);
+    HICON ExtractAssociatedIconW(HINSTANCE, LPCWSTR, PWORD);
+    HICON ExtractIconA(HINSTANCE, LPCSTR, UINT);
+    HICON ExtractIconW(HINSTANCE, LPCWSTR, UINT);
+    UINT ExtractIconExA(LPCSTR, int, HICON*, HICON*, UINT);
+    UINT ExtractIconExW(LPCWSTR, int, HICON*, HICON*, UINT);
+    HINSTANCE FindExecutableA(LPCSTR, LPCSTR, LPSTR);
+    HINSTANCE FindExecutableW(LPCWSTR, LPCWSTR, LPWSTR);
+    UINT SHAppBarMessage(DWORD, PAPPBARDATA);
+    BOOL Shell_NotifyIconA(DWORD, PNOTIFYICONDATAA);
+    BOOL Shell_NotifyIconW(DWORD, PNOTIFYICONDATAW);
+    int ShellAboutA(HWND, LPCSTR, LPCSTR, HICON);
+    int ShellAboutW(HWND, LPCWSTR, LPCWSTR, HICON);
+    HINSTANCE ShellExecuteA(HWND, LPCSTR, LPCSTR, LPCSTR, LPCSTR, INT);
+    HINSTANCE ShellExecuteW(HWND, LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, INT);
+    BOOL ShellExecuteExA(LPSHELLEXECUTEINFOA);
+    BOOL ShellExecuteExW(LPSHELLEXECUTEINFOW);
+    int SHFileOperationA(LPSHFILEOPSTRUCTA);
+    int SHFileOperationW(LPSHFILEOPSTRUCTW);
+    void SHFreeNameMappings(HANDLE);
+    DWORD SHGetFileInfoA(LPCSTR, DWORD, SHFILEINFOA*, UINT, UINT);
+    DWORD SHGetFileInfoW(LPCWSTR, DWORD, SHFILEINFOW*, UINT, UINT);
+    HRESULT SHQueryRecycleBinA(LPCSTR,  LPSHQUERYRBINFO);
+    HRESULT SHQueryRecycleBinW(LPCWSTR,  LPSHQUERYRBINFO);
+    HRESULT SHEmptyRecycleBinA(HWND, LPCSTR, DWORD);
+    HRESULT SHEmptyRecycleBinW(HWND, LPCWSTR, DWORD);
+}
+
+version (Unicode) {
+    alias NOTIFYICONDATAW NOTIFYICONDATA;
+    alias SHELLEXECUTEINFOW SHELLEXECUTEINFO;
+    alias SHFILEOPSTRUCTW SHFILEOPSTRUCT;
+    alias SHFILEINFOW SHFILEINFO;
+    alias DragQueryFileW DragQueryFile;
+    alias ExtractAssociatedIconW ExtractAssociatedIcon;
+    alias ExtractIconW ExtractIcon;
+    alias ExtractIconExW ExtractIconEx;
+    alias FindExecutableW FindExecutable;
+    alias Shell_NotifyIconW Shell_NotifyIcon;
+    alias ShellAboutW ShellAbout;
+    alias ShellExecuteW ShellExecute;
+    alias ShellExecuteExW ShellExecuteEx;
+    alias SHFileOperationW SHFileOperation;
+    alias SHGetFileInfoW SHGetFileInfo;
+    alias SHQueryRecycleBinW SHQueryRecycleBin;
+    alias SHEmptyRecycleBinW SHEmptyRecycleBin;
+} else {
+    alias NOTIFYICONDATAA NOTIFYICONDATA;
+    alias SHELLEXECUTEINFOA SHELLEXECUTEINFO;
+    alias SHFILEOPSTRUCTA SHFILEOPSTRUCT;
+    alias SHFILEINFOA SHFILEINFO;
+    alias DragQueryFileA DragQueryFile;
+    alias ExtractAssociatedIconA ExtractAssociatedIcon;
+    alias ExtractIconA ExtractIcon;
+    alias ExtractIconExA ExtractIconEx;
+    alias FindExecutableA FindExecutable;
+    alias Shell_NotifyIconA Shell_NotifyIcon;
+    alias ShellAboutA ShellAbout;
+    alias ShellExecuteA ShellExecute;
+    alias ShellExecuteExA ShellExecuteEx;
+    alias SHFileOperationA SHFileOperation;
+    alias SHGetFileInfoA SHGetFileInfo;
+    alias SHQueryRecycleBinA SHQueryRecycleBin;
+    alias SHEmptyRecycleBinA SHEmptyRecycleBin;
+}
+
+alias NOTIFYICONDATA* PNOTIFYICONDATA;
+alias SHELLEXECUTEINFO* LPSHELLEXECUTEINFO;
+alias SHFILEOPSTRUCT* LPSHFILEOPSTRUCT;
diff --git a/libphobos/libdruntime/core/sys/windows/shldisp.d b/libphobos/libdruntime/core/sys/windows/shldisp.d
new file mode 100644
index 00000000000..876d4d784ef
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/shldisp.d
@@ -0,0 +1,27 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_shldisp.d)
+ */
+module core.sys.windows.shldisp;
+version (Windows):
+
+private import core.sys.windows.unknwn, core.sys.windows.windef, core.sys.windows.wtypes;
+
+// options for IAutoComplete2
+enum DWORD ACO_AUTOSUGGEST = 0x01;
+
+interface IAutoComplete : IUnknown {
+    HRESULT Init(HWND, IUnknown, LPCOLESTR, LPCOLESTR);
+    HRESULT Enable(BOOL);
+}
+alias IAutoComplete LPAUTOCOMPLETE;
+
+interface IAutoComplete2 : IAutoComplete {
+    HRESULT SetOptions(DWORD);
+    HRESULT GetOptions(DWORD*);
+}
+alias IAutoComplete2 LPAUTOCOMPLETE2;
diff --git a/libphobos/libdruntime/core/sys/windows/shlguid.d b/libphobos/libdruntime/core/sys/windows/shlguid.d
new file mode 100644
index 00000000000..e2bbf020af8
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/shlguid.d
@@ -0,0 +1,18 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_shlguid.d)
+ */
+module core.sys.windows.shlguid;
+version (Windows):
+
+private import core.sys.windows.basetyps, core.sys.windows.w32api;
+
+// FIXME: clean up Windows version support
+
+// I think this is just a helper macro for other win32 headers?
+//MACRO #define DEFINE_SHLGUID(n,l,w1,w2) DEFINE_GUID(n,l,w1,w2,0xC0,0,0,0,0,0,0,0x46)
+
diff --git a/libphobos/libdruntime/core/sys/windows/shlobj.d b/libphobos/libdruntime/core/sys/windows/shlobj.d
new file mode 100644
index 00000000000..4200ee8d4b2
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/shlobj.d
@@ -0,0 +1,1355 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 4.0
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_shlobj.d)
+ */
+module core.sys.windows.shlobj;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "shell32");
+
+// TODO: fix bitfields
+// TODO: CMIC_VALID_SEE_FLAGS
+// SHGetFolderPath in shfolder.dll on W9x, NT4, also in shell32.dll on W2K
+
+import core.sys.windows.commctrl, core.sys.windows.ole2, core.sys.windows.shlguid, core.sys.windows.shellapi;
+private import core.sys.windows.prsht, core.sys.windows.unknwn, core.sys.windows.w32api, core.sys.windows.winbase,
+  core.sys.windows.winnt, core.sys.windows.winuser, core.sys.windows.wtypes, core.sys.windows.objfwd, core.sys.windows.objidl;
+private import core.sys.windows.winnetwk; // for NETRESOURCE
+private import core.sys.windows.oaidl : VARIANT;
+
+
+// FIXME: clean up Windows version support
+
+align(1):
+
+enum BIF_RETURNONLYFSDIRS = 1;
+enum BIF_DONTGOBELOWDOMAIN = 2;
+enum BIF_STATUSTEXT = 4;
+enum BIF_RETURNFSANCESTORS = 8;
+enum BIF_EDITBOX = 16;
+enum BIF_VALIDATE = 32;
+enum BIF_NEWDIALOGSTYLE = 64;
+enum BIF_BROWSEINCLUDEURLS = 128;
+enum BIF_USENEWUI =  BIF_EDITBOX | BIF_NEWDIALOGSTYLE;
+enum BIF_BROWSEFORCOMPUTER = 0x1000;
+enum BIF_BROWSEFORPRINTER = 0x2000;
+enum BIF_BROWSEINCLUDEFILES = 0x4000;
+enum BIF_SHAREABLE = 0x8000;
+enum BFFM_INITIALIZED = 1;
+enum BFFM_SELCHANGED = 2;
+enum BFFM_VALIDATEFAILEDA = 3;
+enum BFFM_VALIDATEFAILEDW = 4;
+enum BFFM_SETSTATUSTEXTA = WM_USER + 100;
+enum BFFM_ENABLEOK = WM_USER + 101;
+enum BFFM_SETSELECTIONA = WM_USER + 102;
+enum BFFM_SETSELECTIONW = WM_USER + 103;
+enum BFFM_SETSTATUSTEXTW = WM_USER + 104;
+enum BFFM_SETOKTEXT = WM_USER + 105;
+enum BFFM_SETEXPANDED = WM_USER + 106;
+
+version(Unicode) {
+    alias BFFM_SETSTATUSTEXTW BFFM_SETSTATUSTEXT;
+    alias BFFM_SETSELECTIONW BFFM_SETSELECTION;
+    alias BFFM_VALIDATEFAILEDW BFFM_VALIDATEFAILED;
+} else {
+    alias BFFM_SETSTATUSTEXTA BFFM_SETSTATUSTEXT;
+    alias BFFM_SETSELECTIONA BFFM_SETSELECTION;
+    alias BFFM_VALIDATEFAILEDA BFFM_VALIDATEFAILED;
+}
+
+enum DVASPECT_SHORTNAME = 2;
+
+enum SHARD {
+    SHARD_PIDL            = 1,
+    SHARD_PATHA,
+    SHARD_PATHW,
+    SHARD_APPIDINFO,
+    SHARD_APPIDINFOIDLIST,
+    SHARD_LINK,
+    SHARD_APPIDINFOLINK,
+    SHARD_SHELLITEM,   // = 8
+    SHARD_PATH = (_WIN32_UNICODE ? SHARD_PATHW : SHARD_PATHA)
+}
+
+enum SHCNE_RENAMEITEM = 1;
+enum SHCNE_CREATE = 2;
+enum SHCNE_DELETE = 4;
+enum SHCNE_MKDIR = 8;
+enum SHCNE_RMDIR = 16;
+enum SHCNE_MEDIAINSERTED = 32;
+enum SHCNE_MEDIAREMOVED = 64;
+enum SHCNE_DRIVEREMOVED = 128;
+enum SHCNE_DRIVEADD = 256;
+enum SHCNE_NETSHARE = 512;
+enum SHCNE_NETUNSHARE = 1024;
+enum SHCNE_ATTRIBUTES = 2048;
+enum SHCNE_UPDATEDIR = 4096;
+enum SHCNE_UPDATEITEM = 8192;
+enum SHCNE_SERVERDISCONNECT = 16384;
+enum SHCNE_UPDATEIMAGE = 32768;
+enum SHCNE_DRIVEADDGUI = 65536;
+enum SHCNE_RENAMEFOLDER = 0x20000;
+enum SHCNE_FREESPACE = 0x40000;
+enum SHCNE_ASSOCCHANGED = 0x8000000;
+enum SHCNE_DISKEVENTS = 0x2381F;
+enum SHCNE_GLOBALEVENTS = 0xC0581E0;
+enum SHCNE_ALLEVENTS = 0x7FFFFFFF;
+enum SHCNE_INTERRUPT = 0x80000000;
+
+enum SHCNF_IDLIST = 0;
+enum SHCNF_PATHA = 1;
+enum SHCNF_PRINTERA = 2;
+enum SHCNF_DWORD = 3;
+enum SHCNF_PATHW = 5;
+enum SHCNF_PRINTERW = 6;
+enum SHCNF_TYPE = 0xFF;
+enum SHCNF_FLUSH = 0x1000;
+enum SHCNF_FLUSHNOWAIT = 0x2000;
+
+version(Unicode) {
+    alias SHCNF_PATHW SHCNF_PATH;
+    alias SHCNF_PRINTERW SHCNF_PRINTER;
+} else {
+    alias SHCNF_PATHA SHCNF_PATH;
+    alias SHCNF_PRINTERA SHCNF_PRINTER;
+}
+
+enum SFGAOF : DWORD {
+    SFGAO_CANCOPY         = DROPEFFECT.DROPEFFECT_COPY,
+    SFGAO_CANMOVE         = DROPEFFECT.DROPEFFECT_MOVE,
+    SFGAO_CANLINK         = DROPEFFECT.DROPEFFECT_LINK,
+    SFGAO_CANRENAME       = 0x00000010L,
+    SFGAO_CANDELETE       = 0x00000020L,
+    SFGAO_HASPROPSHEET    = 0x00000040L,
+    SFGAO_DROPTARGET      = 0x00000100L,
+    SFGAO_CAPABILITYMASK  = 0x00000177L,
+    SFGAO_ISSLOW          = 0x00004000L,
+    SFGAO_GHOSTED         = 0x00008000L,
+    SFGAO_LINK            = 0x00010000L,
+    SFGAO_SHARE           = 0x00020000L,
+    SFGAO_READONLY        = 0x00040000L,
+    SFGAO_HIDDEN          = 0x00080000L,
+    SFGAO_DISPLAYATTRMASK = (SFGAO_ISSLOW | SFGAO_GHOSTED | SFGAO_LINK
+                            | SFGAO_SHARE | SFGAO_READONLY | SFGAO_HIDDEN),
+    SFGAO_FILESYSANCESTOR = 0x10000000L,
+    SFGAO_FOLDER          = 0x20000000L,
+    SFGAO_FILESYSTEM      = 0x40000000L,
+    SFGAO_HASSUBFOLDER    = 0x80000000L,
+    SFGAO_CONTENTSMASK    = 0x80000000L,
+    SFGAO_VALIDATE        = 0x01000000L,
+    SFGAO_REMOVABLE       = 0x02000000L,
+    SFGAO_COMPRESSED      = 0x04000000L
+}
+enum STRRET_WSTR = 0;
+enum STRRET_OFFSET = 1;
+enum STRRET_CSTR = 2;
+
+enum {
+    SHGDFIL_FINDDATA = 1,
+    SHGDFIL_NETRESOURCE,
+    SHGDFIL_DESCRIPTIONID
+}
+
+enum {
+    SHDID_ROOT_REGITEM = 1,
+    SHDID_FS_FILE,
+    SHDID_FS_DIRECTORY,
+    SHDID_FS_OTHER,
+    SHDID_COMPUTER_DRIVE35,
+    SHDID_COMPUTER_DRIVE525,
+    SHDID_COMPUTER_REMOVABLE,
+    SHDID_COMPUTER_FIXED,
+    SHDID_COMPUTER_NETDRIVE,
+    SHDID_COMPUTER_CDROM,
+    SHDID_COMPUTER_RAMDISK,
+    SHDID_COMPUTER_OTHER,
+    SHDID_NET_DOMAIN,
+    SHDID_NET_SERVER,
+    SHDID_NET_SHARE,
+    SHDID_NET_RESTOFNET,
+    SHDID_NET_OTHER
+}
+
+const TCHAR[] REGSTR_PATH_EXPLORER = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer";
+const TCHAR[] REGSTR_PATH_SPECIAL_FOLDERS=REGSTR_PATH_EXPLORER ~ "\\Shell Folders";
+
+enum {
+    CSIDL_DESKTOP            =  0,
+    CSIDL_INTERNET,
+    CSIDL_PROGRAMS,
+    CSIDL_CONTROLS,
+    CSIDL_PRINTERS,
+    CSIDL_PERSONAL,
+    CSIDL_FAVORITES,
+    CSIDL_STARTUP,
+    CSIDL_RECENT,
+    CSIDL_SENDTO,
+    CSIDL_BITBUCKET,
+    CSIDL_STARTMENU,      // = 11
+    CSIDL_MYMUSIC            = 13,
+    CSIDL_MYVIDEO,        // = 14
+    CSIDL_DESKTOPDIRECTORY   = 16,
+    CSIDL_DRIVES,
+    CSIDL_NETWORK,
+    CSIDL_NETHOOD,
+    CSIDL_FONTS,
+    CSIDL_TEMPLATES,
+    CSIDL_COMMON_STARTMENU,
+    CSIDL_COMMON_PROGRAMS,
+    CSIDL_COMMON_STARTUP,
+    CSIDL_COMMON_DESKTOPDIRECTORY,
+    CSIDL_APPDATA,
+    CSIDL_PRINTHOOD,
+    CSIDL_LOCAL_APPDATA,
+    CSIDL_ALTSTARTUP,
+    CSIDL_COMMON_ALTSTARTUP,
+    CSIDL_COMMON_FAVORITES,
+    CSIDL_INTERNET_CACHE,
+    CSIDL_COOKIES,
+    CSIDL_HISTORY,
+    CSIDL_COMMON_APPDATA,
+    CSIDL_WINDOWS,
+    CSIDL_SYSTEM,
+    CSIDL_PROGRAM_FILES,
+    CSIDL_MYPICTURES,
+    CSIDL_PROFILE,
+    CSIDL_SYSTEMX86,
+    CSIDL_PROGRAM_FILESX86,
+    CSIDL_PROGRAM_FILES_COMMON,
+    CSIDL_PROGRAM_FILES_COMMONX86,
+    CSIDL_COMMON_TEMPLATES,
+    CSIDL_COMMON_DOCUMENTS,
+    CSIDL_COMMON_ADMINTOOLS,
+    CSIDL_ADMINTOOLS,
+    CSIDL_CONNECTIONS,  // = 49
+    CSIDL_COMMON_MUSIC     = 53,
+    CSIDL_COMMON_PICTURES,
+    CSIDL_COMMON_VIDEO,
+    CSIDL_RESOURCES,
+    CSIDL_RESOURCES_LOCALIZED,
+    CSIDL_COMMON_OEM_LINKS,
+    CSIDL_CDBURN_AREA,  // = 59
+    CSIDL_COMPUTERSNEARME  = 61,
+    CSIDL_FLAG_DONT_VERIFY = 0x4000,
+    CSIDL_FLAG_CREATE      = 0x8000,
+    CSIDL_FLAG_MASK        = 0xFF00
+}
+
+const TCHAR[]
+    CFSTR_SHELLIDLIST       = "Shell IDList Array",
+    CFSTR_SHELLIDLISTOFFSET = "Shell Object Offsets",
+    CFSTR_NETRESOURCES      = "Net Resource",
+    CFSTR_FILECONTENTS      = "FileContents",
+    CFSTR_FILENAMEA         = "FileName",
+    CFSTR_FILENAMEMAPA      = "FileNameMap",
+    CFSTR_FILEDESCRIPTORA   = "FileGroupDescriptor",
+    CFSTR_INETURLA          = "UniformResourceLocator",
+    CFSTR_SHELLURL          = CFSTR_INETURLA,
+    CFSTR_FILENAMEW         = "FileNameW",
+    CFSTR_FILENAMEMAPW      = "FileNameMapW",
+    CFSTR_FILEDESCRIPTORW   = "FileGroupDescriptorW",
+    CFSTR_INETURLW          = "UniformResourceLocatorW";
+
+version(Unicode) {
+    alias CFSTR_FILENAMEW CFSTR_FILENAME;
+    alias CFSTR_FILENAMEMAPW CFSTR_FILENAMEMAP;
+    alias CFSTR_FILEDESCRIPTORW CFSTR_FILEDESCRIPTOR;
+    alias CFSTR_INETURLW CFSTR_INETURL;
+} else {
+    alias CFSTR_FILENAMEA CFSTR_FILENAME;
+    alias CFSTR_FILENAMEMAPA CFSTR_FILENAMEMAP;
+    alias CFSTR_FILEDESCRIPTORA CFSTR_FILEDESCRIPTOR;
+    alias CFSTR_INETURLA CFSTR_INETURL;
+}
+const TCHAR[]
+    CFSTR_PRINTERGROUP        = "PrinterFriendlyName",
+    CFSTR_INDRAGLOOP          = "InShellDragLoop",
+    CFSTR_PASTESUCCEEDED      = "Paste Succeeded",
+    CFSTR_PERFORMEDDROPEFFECT = "Performed DropEffect",
+    CFSTR_PREFERREDDROPEFFECT = "Preferred DropEffect";
+
+enum CMF_NORMAL=0;
+enum CMF_DEFAULTONLY=1;
+enum CMF_VERBSONLY=2;
+enum CMF_EXPLORE=4;
+enum CMF_NOVERBS=8;
+enum CMF_CANRENAME=16;
+enum CMF_NODEFAULT=32;
+enum CMF_INCLUDESTATIC=64;
+enum CMF_RESERVED=0xffff0000;
+enum GCS_VERBA=0;
+enum GCS_HELPTEXTA=1;
+enum GCS_VALIDATEA=2;
+enum GCS_VERBW=4;
+enum GCS_HELPTEXTW=5;
+enum GCS_VALIDATEW=6;
+enum GCS_UNICODE=4;
+
+version(Unicode) {
+    alias GCS_VERBW GCS_VERB;
+    alias GCS_HELPTEXTW GCS_HELPTEXT;
+    alias GCS_VALIDATEW GCS_VALIDATE;
+} else {
+    alias GCS_VERBA GCS_VERB;
+    alias GCS_HELPTEXTA GCS_HELPTEXT;
+    alias GCS_VALIDATEA GCS_VALIDATE;
+}
+
+const TCHAR[]
+    CMDSTR_NEWFOLDER   = "NewFolder",
+    CMDSTR_VIEWLIST    = "ViewList",
+    CMDSTR_VIEWDETAILS = "ViewDetails";
+
+enum CMIC_MASK_HOTKEY     = SEE_MASK_HOTKEY;
+enum CMIC_MASK_ICON       = SEE_MASK_ICON;
+enum CMIC_MASK_FLAG_NO_UI = SEE_MASK_FLAG_NO_UI;
+enum CMIC_MASK_MODAL      = 0x80000000;
+// TODO: This isn't defined anywhere in MinGW.
+//const CMIC_VALID_SEE_FLAGS=SEE_VALID_CMIC_FLAGS;
+
+enum GIL_OPENICON = 1;
+enum GIL_FORSHELL = 2;
+enum GIL_SIMULATEDOC = 1;
+enum GIL_PERINSTANCE = 2;
+enum GIL_PERCLASS = 4;
+enum GIL_NOTFILENAME = 8;
+enum GIL_DONTCACHE = 16;
+
+enum FVSIF_RECT = 1;
+enum FVSIF_PINNED = 2;
+enum FVSIF_NEWFAILED = 0x8000000;
+enum FVSIF_NEWFILE = 0x80000000;
+enum FVSIF_CANVIEWIT = 0x40000000;
+
+enum CDBOSC_SETFOCUS = 0;
+enum CDBOSC_KILLFOCUS = 1;
+enum CDBOSC_SELCHANGE = 2;
+enum CDBOSC_RENAME = 3;
+
+enum FCIDM_SHVIEWFIRST = 0;
+enum FCIDM_SHVIEWLAST = 0x7fff;
+enum FCIDM_BROWSERFIRST = 0xa000;
+enum FCIDM_BROWSERLAST = 0xbf00;
+enum FCIDM_GLOBALFIRST = 0x8000;
+enum FCIDM_GLOBALLAST = 0x9fff;
+enum FCIDM_MENU_FILE = FCIDM_GLOBALFIRST;
+enum FCIDM_MENU_EDIT = FCIDM_GLOBALFIRST+0x0040;
+enum FCIDM_MENU_VIEW = FCIDM_GLOBALFIRST+0x0080;
+enum FCIDM_MENU_VIEW_SEP_OPTIONS = FCIDM_GLOBALFIRST+0x0081;
+enum FCIDM_MENU_TOOLS = FCIDM_GLOBALFIRST+0x00c0;
+enum FCIDM_MENU_TOOLS_SEP_GOTO = FCIDM_GLOBALFIRST+0x00c1;
+enum FCIDM_MENU_HELP = FCIDM_GLOBALFIRST+0x0100;
+enum FCIDM_MENU_FIND = FCIDM_GLOBALFIRST+0x0140;
+enum FCIDM_MENU_EXPLORE = FCIDM_GLOBALFIRST+0x0150;
+enum FCIDM_MENU_FAVORITES = FCIDM_GLOBALFIRST+0x0170;
+enum FCIDM_TOOLBAR = FCIDM_BROWSERFIRST;
+enum FCIDM_STATUS = FCIDM_BROWSERFIRST+1;
+
+enum SBSP_DEFBROWSER = 0;
+enum SBSP_SAMEBROWSER = 1;
+enum SBSP_NEWBROWSER = 2;
+enum SBSP_DEFMODE = 0;
+enum SBSP_OPENMODE = 16;
+enum SBSP_EXPLOREMODE = 32;
+enum SBSP_ABSOLUTE = 0;
+enum SBSP_RELATIVE = 0x1000;
+enum SBSP_PARENT = 0x2000;
+enum SBSP_INITIATEDBYHLINKFRAME = 0x80000000;
+enum SBSP_REDIRECT = 0x40000000;
+
+enum {
+    FCW_STATUS=1,
+    FCW_TOOLBAR,
+    FCW_TREE
+}
+
+enum FCT_MERGE=1;
+enum FCT_CONFIGABLE=2;
+enum FCT_ADDTOEND=4;
+
+enum SVSI_DESELECT=0;
+enum SVSI_SELECT=1;
+enum SVSI_EDIT=3;
+enum SVSI_DESELECTOTHERS=4;
+enum SVSI_ENSUREVISIBLE=8;
+enum SVSI_FOCUSED=16;
+
+enum SVGIO_BACKGROUND=0;
+enum SVGIO_SELECTION=1;
+enum SVGIO_ALLVIEW=2;
+
+enum UINT SV2GV_CURRENTVIEW=-1;
+enum UINT SV2GV_DEFAULTVIEW=-2;
+
+alias DWORD SHGDNF;
+
+struct CIDA {
+    UINT    cidl;
+    UINT[1] aoffset;
+}
+alias CIDA* LPIDA;
+
+struct SHITEMID {
+    USHORT  cb;
+    BYTE[1] abID;
+}
+alias SHITEMID*        LPSHITEMID;
+alias const(SHITEMID)* LPCSHITEMID;
+
+struct ITEMIDLIST {
+    SHITEMID mkid;
+}
+alias ITEMIDLIST*        LPITEMIDLIST;
+alias const(ITEMIDLIST)* LPCITEMIDLIST;
+
+alias int function(HWND, UINT, LPARAM, LPARAM) BFFCALLBACK;
+
+struct BROWSEINFOA {
+    HWND          hwndOwner;
+    LPCITEMIDLIST pidlRoot;
+    LPSTR         pszDisplayName;
+    LPCSTR        lpszTitle;
+    UINT          ulFlags;
+    BFFCALLBACK   lpfn;
+    LPARAM        lParam;
+    int           iImage;
+}
+alias BROWSEINFOA* PBROWSEINFOA, LPBROWSEINFOA;
+
+struct BROWSEINFOW {
+    HWND          hwndOwner;
+    LPCITEMIDLIST pidlRoot;
+    LPWSTR        pszDisplayName;
+    LPCWSTR       lpszTitle;
+    UINT          ulFlags;
+    BFFCALLBACK   lpfn;
+    LPARAM        lParam;
+    int           iImage;
+}
+alias BROWSEINFOW* PBROWSEINFOW, LPBROWSEINFOW;
+
+struct CMINVOKECOMMANDINFO {
+    DWORD cbSize = this.sizeof;
+    DWORD fMask;
+    HWND hwnd;
+    LPCSTR lpVerb;
+    LPCSTR lpParameters;
+    LPCSTR lpDirectory;
+    int nShow;
+    DWORD dwHotKey;
+    HANDLE hIcon;
+}
+alias CMINVOKECOMMANDINFO* LPCMINVOKECOMMANDINFO;
+
+struct DROPFILES {
+    DWORD pFiles;
+    POINT pt;
+    BOOL fNC;
+    BOOL fWide;
+}
+alias DROPFILES* LPDROPFILES;
+
+enum SHGNO {
+    SHGDN_NORMAL             = 0,
+    SHGDN_INFOLDER,
+    SHGDN_FOREDITING         = 0x1000,
+    SHGDN_INCLUDE_NONFILESYS = 0x2000,
+    SHGDN_FORADDRESSBAR      = 0x4000,
+    SHGDN_FORPARSING         = 0x8000
+}
+
+enum SHCONTF {
+    SHCONTF_FOLDERS            = 32,
+    SHCONTF_NONFOLDERS         = 64,
+    SHCONTF_INCLUDEHIDDEN      = 128,
+    SHCONTF_INIT_ON_FIRST_NEXT = 256,
+    SHCONTF_NETPRINTERSRCH     = 512,
+    SHCONTF_SHAREABLE          = 1024,
+    SHCONTF_STORAGE            = 2048
+}
+
+struct STRRET {
+    UINT uType;
+    union {
+        LPWSTR pOleStr;
+        UINT uOffset;
+        char[MAX_PATH] cStr;
+    }
+}
+alias STRRET* LPSTRRET;
+
+enum FD_FLAGS {
+    FD_CLSID      = 1,
+    FD_SIZEPOINT  = 2,
+    FD_ATTRIBUTES = 4,
+    FD_CREATETIME = 8,
+    FD_ACCESSTIME = 16,
+    FD_WRITESTIME = 32,
+    FD_FILESIZE   = 64,
+    FD_LINKUI     = 0x8000
+}
+
+struct FILEDESCRIPTORA {
+    DWORD dwFlags;
+    CLSID clsid;
+    SIZEL sizel;
+    POINTL pointl;
+    DWORD dwFileAttributes;
+    FILETIME ftCreationTime;
+    FILETIME ftLastAccessTime;
+    FILETIME ftLastWriteTime;
+    DWORD nFileSizeHigh;
+    DWORD nFileSizeLow;
+    CHAR[MAX_PATH] cFileName;
+}
+alias FILEDESCRIPTORA* LPFILEDESCRIPTORA;
+
+struct FILEDESCRIPTORW {
+    DWORD dwFlags;
+    CLSID clsid;
+    SIZEL sizel;
+    POINTL pointl;
+    DWORD dwFileAttributes;
+    FILETIME ftCreationTime;
+    FILETIME ftLastAccessTime;
+    FILETIME ftLastWriteTime;
+    DWORD nFileSizeHigh;
+    DWORD nFileSizeLow;
+    WCHAR[MAX_PATH] cFileName;
+}
+alias FILEDESCRIPTORW* LPFILEDESCRIPTORW;
+
+struct FILEGROUPDESCRIPTORA {
+    UINT cItems;
+    FILEDESCRIPTORA[1] fgd;
+}
+alias FILEGROUPDESCRIPTORA* LPFILEGROUPDESCRIPTORA;
+
+struct FILEGROUPDESCRIPTORW {
+    UINT cItems;
+    FILEDESCRIPTORW[1] fgd;
+}
+alias FILEGROUPDESCRIPTORW* LPFILEGROUPDESCRIPTORW;
+
+enum SLR_FLAGS {
+    SLR_NO_UI      = 1,
+    SLR_ANY_MATCH  = 2,
+    SLR_UPDATE     = 4,
+    SLR_NOUPDATE   = 8,
+    SLR_NOSEARCH   = 16,
+    SLR_NOTRACK    = 32,
+    SLR_NOLINKINFO = 64,
+    SLR_INVOKE_MSI = 128
+}
+
+enum SLGP_FLAGS {
+    SLGP_SHORTPATH=1,
+    SLGP_UNCPRIORITY=2,
+    SLGP_RAWPATH=4
+}
+
+alias PBYTE LPVIEWSETTINGS;
+
+enum FOLDERFLAGS {
+    FWF_AUTOARRANGE         = 1,
+    FWF_ABBREVIATEDNAMES    = 2,
+    FWF_SNAPTOGRID          = 4,
+    FWF_OWNERDATA           = 8,
+    FWF_BESTFITWINDOW       = 16,
+    FWF_DESKTOP             = 32,
+    FWF_SINGLESEL           = 64,
+    FWF_NOSUBFOLDERS        = 128,
+    FWF_TRANSPARENT         = 256,
+    FWF_NOCLIENTEDGE        = 512,
+    FWF_NOSCROLL            = 0x400,
+    FWF_ALIGNLEFT           = 0x800,
+    FWF_SINGLECLICKACTIVATE = 0x8000
+}
+
+enum FOLDERVIEWMODE {
+    FVM_ICON      = 1,
+    FVM_SMALLICON,
+    FVM_LIST,
+    FVM_DETAILS
+}
+
+struct FOLDERSETTINGS {
+    UINT ViewMode;
+    UINT fFlags;
+}
+alias FOLDERSETTINGS*        LPFOLDERSETTINGS;
+alias const(FOLDERSETTINGS)* LPCFOLDERSETTINGS;
+
+struct FVSHOWINFO {
+    DWORD cbSize = this.sizeof;
+    HWND hwndOwner;
+    int iShow;
+    DWORD dwFlags;
+    RECT rect;
+    LPUNKNOWN punkRel;
+    OLECHAR[MAX_PATH] strNewFile;
+}
+alias FVSHOWINFO* LPFVSHOWINFO;
+
+struct NRESARRAY {
+    UINT cItems;
+    NETRESOURCE[1] nr;
+}
+alias NRESARRAY* LPNRESARRAY;
+
+enum {
+    SBSC_HIDE,
+    SBSC_SHOW,
+    SBSC_TOGGLE,
+    SBSC_QUERY
+}
+
+enum {
+    SBCMDID_ENABLESHOWTREE,
+    SBCMDID_SHOWCONTROL,
+    SBCMDID_CANCELNAVIGATION,
+    SBCMDID_MAYSAVECHANGES,
+    SBCMDID_SETHLINKFRAME,
+    SBCMDID_ENABLESTOP,
+    SBCMDID_OPTIONS
+}
+enum SVUIA_STATUS {
+    SVUIA_DEACTIVATE,
+    SVUIA_ACTIVATE_NOFOCUS,
+    SVUIA_ACTIVATE_FOCUS,
+    SVUIA_INPLACEACTIVATE
+}
+
+static if (_WIN32_IE >= 0x500) {
+
+    struct EXTRASEARCH
+     {
+        GUID guidSearch;
+        WCHAR[80] wszFriendlyName;
+        WCHAR[2084] wszUrl;
+    }
+    alias EXTRASEARCH* LPEXTRASEARCH;
+
+    alias DWORD SHCOLSTATEF;
+
+    struct SHCOLUMNID {
+        GUID fmtid;
+        DWORD pid;
+    }
+    alias SHCOLUMNID*        LPSHCOLUMNID;
+    alias const(SHCOLUMNID)* LPCSHCOLUMNID;
+
+    struct SHELLDETAILS {
+        int fmt;
+        int cxChar;
+        STRRET str;
+    }
+    alias SHELLDETAILS* LPSHELLDETAILS;
+
+    struct PERSIST_FOLDER_TARGET_INFO
+     {
+        LPITEMIDLIST pidlTargetFolder;
+        WCHAR[MAX_PATH] szTargetParsingName;
+        WCHAR[MAX_PATH] szNetworkProvider;
+        DWORD dwAttributes;
+        int csidl;
+    }
+
+    enum SHGFP_TYPE {
+        SHGFP_TYPE_CURRENT = 0,
+        SHGFP_TYPE_DEFAULT = 1,
+    }
+
+}
+
+interface IEnumIDList : IUnknown {
+    HRESULT Next(ULONG, LPITEMIDLIST*, ULONG*);
+    HRESULT Skip(ULONG);
+    HRESULT Reset();
+    HRESULT Clone(IEnumIDList*);
+}
+alias IEnumIDList LPENUMIDLIST;
+
+interface IObjMgr : IUnknown {
+    HRESULT Append(IUnknown);
+    HRESULT Remove(IUnknown);
+}
+
+interface IContextMenu : IUnknown {
+    HRESULT QueryContextMenu(HMENU, UINT, UINT, UINT, UINT);
+    HRESULT InvokeCommand(LPCMINVOKECOMMANDINFO);
+    HRESULT GetCommandString(UINT, UINT, PUINT, LPSTR, UINT);
+}
+alias IContextMenu LPCONTEXTMENU;
+
+interface IContextMenu2 : IContextMenu {
+    HRESULT HandleMenuMsg(UINT, WPARAM, LPARAM);
+};
+alias IContextMenu2 LPCONTEXTMENU2;
+
+static if (_WIN32_IE >= 0x500) {
+    align(8) {
+        struct SHCOLUMNINIT {
+            ULONG dwFlags;
+            ULONG dwReserved;
+            WCHAR[MAX_PATH] wszFolder;
+        }
+        alias SHCOLUMNINIT*        LPSHCOLUMNINIT;
+        alias const(SHCOLUMNINIT)* LPCSHCOLUMNINIT;
+
+        struct SHCOLUMNDATA {
+            ULONG dwFlags;
+            DWORD dwFileAttributes;
+            ULONG dwReserved;
+            WCHAR *pwszExt;
+            WCHAR[MAX_PATH] wszFile;
+        }
+        alias SHCOLUMNDATA*        LPSHCOLUMNDATA;
+        alias const(SHCOLUMNDATA)* LPCSHCOLUMNDATA;
+    }
+
+enum MAX_COLUMN_NAME_LEN = 80;
+enum MAX_COLUMN_DESC_LEN = 128;
+
+    align(1) struct SHCOLUMNINFO {
+        SHCOLUMNID scid;
+        VARTYPE vt;
+        DWORD fmt;
+        UINT cChars;
+        DWORD csFlags;
+        WCHAR[MAX_COLUMN_NAME_LEN] wszTitle;
+        WCHAR[MAX_COLUMN_DESC_LEN] wszDescription;
+    }
+    alias SHCOLUMNINFO*        LPSHCOLUMNINFO;
+    alias const(SHCOLUMNINFO)* LPCSHCOLUMNINFO;
+
+    enum SHCOLSTATE {
+        SHCOLSTATE_TYPE_STR      = 0x00000001,
+        SHCOLSTATE_TYPE_INT      = 0x00000002,
+        SHCOLSTATE_TYPE_DATE     = 0x00000003,
+        SHCOLSTATE_TYPEMASK      = 0x0000000f,
+        SHCOLSTATE_ONBYDEFAULT   = 0x00000010,
+        SHCOLSTATE_SLOW          = 0x00000020,
+        SHCOLSTATE_EXTENDED      = 0x00000040,
+        SHCOLSTATE_SECONDARYUI   = 0x00000080,
+        SHCOLSTATE_HIDDEN        = 0x00000100,
+        SHCOLSTATE_PREFER_VARCMP = 0x00000200
+    }
+
+    interface IColumnProvider : IUnknown {
+        HRESULT Initialize(LPCSHCOLUMNINIT);
+        HRESULT GetColumnInfo(DWORD, SHCOLUMNINFO*);
+        HRESULT GetItemData(LPCSHCOLUMNID, LPCSHCOLUMNDATA, VARIANT*);
+    }
+}/* _WIN32_IE >= 0x500 */
+
+interface IQueryInfo : IUnknown {
+    HRESULT GetInfoTip(DWORD, WCHAR**);
+    HRESULT GetInfoFlags(DWORD*);
+}
+
+interface IShellExtInit : IUnknown {
+    HRESULT Initialize(LPCITEMIDLIST, LPDATAOBJECT, HKEY);
+}
+alias IShellExtInit LPSHELLEXTINIT;
+
+interface IShellPropSheetExt : IUnknown {
+    HRESULT AddPages(LPFNADDPROPSHEETPAGE, LPARAM);
+    HRESULT ReplacePage(UINT, LPFNADDPROPSHEETPAGE, LPARAM);
+}
+alias IShellPropSheetExt LPSHELLPROPSHEETEXT;
+
+interface IExtractIconA : IUnknown {
+    HRESULT GetIconLocation(UINT, LPSTR, UINT, int*, PUINT);
+    HRESULT Extract(LPCSTR, UINT, HICON*, HICON*, UINT);
+};
+alias IExtractIconA LPEXTRACTICONA;
+
+interface IExtractIconW : IUnknown {
+    HRESULT GetIconLocation(UINT, LPWSTR, UINT, int*, PUINT);
+    HRESULT Extract(LPCWSTR, UINT, HICON*, HICON*, UINT);
+}
+alias IExtractIconW LPEXTRACTICONW;
+
+version(Unicode) {
+    alias IExtractIconW IExtractIcon;
+    alias LPEXTRACTICONW LPEXTRACTICON;
+} else {
+    alias IExtractIconA IExtractIcon;
+    alias LPEXTRACTICONA LPEXTRACTICON;
+}
+
+interface IShellLinkA : IUnknown {
+    HRESULT GetPath(LPSTR, int, WIN32_FIND_DATAA*, DWORD);
+    HRESULT GetIDList(LPITEMIDLIST*);
+    HRESULT SetIDList(LPCITEMIDLIST);
+    HRESULT GetDescription(LPSTR, int);
+    HRESULT SetDescription(LPCSTR);
+    HRESULT GetWorkingDirectory(LPSTR, int);
+    HRESULT SetWorkingDirectory(LPCSTR);
+    HRESULT GetArguments(LPSTR, int);
+    HRESULT SetArguments(LPCSTR);
+    HRESULT GetHotkey(PWORD);
+    HRESULT SetHotkey(WORD);
+    HRESULT GetShowCmd(int*);
+    HRESULT SetShowCmd(int);
+    HRESULT GetIconLocation(LPSTR, int, int*);
+    HRESULT SetIconLocation(LPCSTR, int);
+    HRESULT SetRelativePath(LPCSTR , DWORD);
+    HRESULT Resolve(HWND, DWORD);
+    HRESULT SetPath(LPCSTR);
+}
+
+interface IShellLinkW : IUnknown {
+    HRESULT GetPath(LPWSTR, int, WIN32_FIND_DATAW*, DWORD);
+    HRESULT GetIDList(LPITEMIDLIST*);
+    HRESULT SetIDList(LPCITEMIDLIST);
+    HRESULT GetDescription(LPWSTR, int);
+    HRESULT SetDescription(LPCWSTR);
+    HRESULT GetWorkingDirectory(LPWSTR, int);
+    HRESULT SetWorkingDirectory(LPCWSTR);
+    HRESULT GetArguments(LPWSTR, int);
+    HRESULT SetArguments(LPCWSTR);
+    HRESULT GetHotkey(PWORD);
+    HRESULT SetHotkey(WORD);
+    HRESULT GetShowCmd(int*);
+    HRESULT SetShowCmd(int);
+    HRESULT GetIconLocation(LPWSTR, int, int*);
+    HRESULT SetIconLocation(LPCWSTR, int);
+    HRESULT SetRelativePath(LPCWSTR , DWORD);
+    HRESULT Resolve(HWND, DWORD);
+    HRESULT SetPath(LPCWSTR);
+}
+
+
+interface IShellFolder : IUnknown {
+    HRESULT ParseDisplayName(HWND, LPBC, LPOLESTR, PULONG, LPITEMIDLIST*, PULONG);
+    HRESULT EnumObjects(HWND, DWORD, LPENUMIDLIST*);
+    HRESULT BindToObject(LPCITEMIDLIST, LPBC, REFIID, PVOID*);
+    HRESULT BindToStorage(LPCITEMIDLIST, LPBC, REFIID, PVOID*);
+    HRESULT CompareIDs(LPARAM, LPCITEMIDLIST, LPCITEMIDLIST);
+    HRESULT CreateViewObject(HWND, REFIID, PVOID*);
+    HRESULT GetAttributesOf(UINT, LPCITEMIDLIST*, PULONG);
+    HRESULT GetUIObjectOf(HWND, UINT, LPCITEMIDLIST*, REFIID, PUINT, PVOID*);
+    HRESULT GetDisplayNameOf(LPCITEMIDLIST, DWORD, LPSTRRET);
+    HRESULT SetNameOf(HWND, LPCITEMIDLIST, LPCOLESTR, DWORD, LPITEMIDLIST*);
+}
+alias IShellFolder LPSHELLFOLDER;
+
+static if (_WIN32_IE >= 0x500) {
+
+interface IEnumExtraSearch: IUnknown {
+    HRESULT Next(ULONG, LPEXTRASEARCH*, ULONG*);
+    HRESULT Skip(ULONG);
+    HRESULT Reset();
+    HRESULT Clone(IEnumExtraSearch*);
+}
+alias IEnumExtraSearch LPENUMEXTRASEARCH;
+
+interface IShellFolder2 : IShellFolder {
+    HRESULT ParseDisplayName(HWND, LPBC, LPOLESTR, PULONG, LPITEMIDLIST*, PULONG);
+    HRESULT EnumObjects(HWND, DWORD, LPENUMIDLIST*);
+    HRESULT BindToObject(LPCITEMIDLIST, LPBC, REFIID, PVOID*);
+    HRESULT BindToStorage(LPCITEMIDLIST, LPBC, REFIID, PVOID*);
+    HRESULT CompareIDs(LPARAM, LPCITEMIDLIST, LPCITEMIDLIST);
+    HRESULT CreateViewObject(HWND, REFIID, PVOID*);
+    HRESULT GetAttributesOf(UINT, LPCITEMIDLIST*, PULONG);
+    HRESULT GetUIObjectOf(HWND, UINT, LPCITEMIDLIST*, REFIID, PUINT, PVOID*);
+    HRESULT GetDisplayNameOf(LPCITEMIDLIST, DWORD, LPSTRRET);
+    HRESULT SetNameOf(HWND, LPCITEMIDLIST, LPCOLESTR, DWORD, LPITEMIDLIST*);
+    HRESULT GetDefaultSearchGUID(GUID*);
+    HRESULT EnumSearches(IEnumExtraSearch*);
+    HRESULT GetDefaultColumn(DWORD, ULONG*, ULONG*);
+    HRESULT GetDefaultColumnState(UINT, SHCOLSTATEF*);
+    HRESULT GetDetailsEx(LPCITEMIDLIST, const(SHCOLUMNID)*, VARIANT*);
+    HRESULT GetDetailsOf(LPCITEMIDLIST, UINT, SHELLDETAILS*);
+    HRESULT MapColumnToSCID(UINT, SHCOLUMNID*);
+}
+alias IShellFolder2 LPSHELLFOLDER2;
+
+} /* _WIN32_IE >= 0x500 */
+
+interface ICopyHook : IUnknown {
+    UINT CopyCallback(HWND, UINT, UINT, LPCSTR, DWORD, LPCSTR, DWORD);
+}
+alias ICopyHook LPCOPYHOOK;
+
+interface IFileViewerSite : IUnknown {
+    HRESULT SetPinnedWindow(HWND);
+    HRESULT GetPinnedWindow(HWND*);
+}
+alias IFileViewerSite LPFILEVIEWERSITE;
+
+interface IFileViewer : IUnknown {
+    HRESULT ShowInitialize(LPFILEVIEWERSITE);
+    HRESULT Show(LPFVSHOWINFO);
+    HRESULT PrintTo(LPSTR, BOOL);
+}
+alias IFileViewer LPFILEVIEWER;
+
+interface IFileSystemBindData : IUnknown {
+    HRESULT SetFindData(const(WIN32_FIND_DATAW)*);
+    HRESULT GetFindData(WIN32_FIND_DATAW*);
+}
+
+interface IPersistFolder : IPersist {
+    HRESULT GetClassID(CLSID*);
+    HRESULT Initialize(LPCITEMIDLIST);
+}
+alias IPersistFolder LPPERSISTFOLDER;
+
+static if (_WIN32_IE >= 0x400 || _WIN32_WINNT >= 0x500) {
+
+interface IPersistFolder2 : IPersistFolder {
+    HRESULT GetClassID(CLSID*);
+    HRESULT Initialize(LPCITEMIDLIST);
+    HRESULT GetCurFolder(LPITEMIDLIST*);
+}
+alias IPersistFolder2 LPPERSISTFOLDER2;
+
+}/* _WIN32_IE >= 0x400 || _WIN32_WINNT >= 0x500 */
+
+static if (_WIN32_IE >= 0x500) {
+
+interface IPersistFolder3 : IPersistFolder2 {
+    HRESULT GetClassID(CLSID*);
+    HRESULT Initialize(LPCITEMIDLIST);
+    HRESULT GetCurFolder(LPITEMIDLIST*);
+    HRESULT InitializeEx(IBindCtx, LPCITEMIDLIST, const(PERSIST_FOLDER_TARGET_INFO)*);
+    HRESULT GetFolderTargetInfo(PERSIST_FOLDER_TARGET_INFO*);
+}
+alias IPersistFolder3 LPPERSISTFOLDER3;
+
+} /* _WIN32_IE >= 0x500 */
+
+alias IShellBrowser LPSHELLBROWSER;
+alias IShellView LPSHELLVIEW;
+
+interface IShellBrowser : IOleWindow {
+    HRESULT GetWindow(HWND*);
+    HRESULT ContextSensitiveHelp(BOOL);
+    HRESULT InsertMenusSB(HMENU, LPOLEMENUGROUPWIDTHS);
+    HRESULT SetMenuSB(HMENU, HOLEMENU, HWND);
+    HRESULT RemoveMenusSB(HMENU);
+    HRESULT SetStatusTextSB(LPCOLESTR);
+    HRESULT EnableModelessSB(BOOL);
+    HRESULT TranslateAcceleratorSB(LPMSG, WORD);
+    HRESULT BrowseObject(LPCITEMIDLIST, UINT);
+    HRESULT GetViewStateStream(DWORD, LPSTREAM*);
+    HRESULT GetControlWindow(UINT, HWND*);
+    HRESULT SendControlMsg(UINT, UINT, WPARAM, LPARAM, LRESULT*);
+    HRESULT QueryActiveShellView(LPSHELLVIEW*);
+    HRESULT OnViewWindowActive(LPSHELLVIEW);
+    HRESULT SetToolbarItems(LPTBBUTTON, UINT, UINT);
+}
+
+interface IShellView : IOleWindow {
+    HRESULT GetWindow(HWND*);
+    HRESULT ContextSensitiveHelp(BOOL);
+    HRESULT TranslateAccelerator(LPMSG);
+//[No] #ifdef _FIX_ENABLEMODELESS_CONFLICT
+//[No]  STDMETHOD(EnableModelessSV)(THIS_ BOOL) PURE;
+//[Yes] #else
+    HRESULT EnableModeless(BOOL);
+//[Yes] #endif
+    HRESULT UIActivate(UINT);
+    HRESULT Refresh();
+    HRESULT CreateViewWindow(IShellView, LPCFOLDERSETTINGS, LPSHELLBROWSER, RECT*, HWND*);
+    HRESULT DestroyViewWindow();
+    HRESULT GetCurrentInfo(LPFOLDERSETTINGS);
+    HRESULT AddPropertySheetPages(DWORD, LPFNADDPROPSHEETPAGE, LPARAM);
+    HRESULT SaveViewState();
+    HRESULT SelectItem(LPCITEMIDLIST, UINT);
+    HRESULT GetItemObject(UINT, REFIID, PVOID*);
+}
+
+interface ICommDlgBrowser : IUnknown {
+    HRESULT OnDefaultCommand(IShellView);
+    HRESULT OnStateChange(IShellView, ULONG);
+    HRESULT IncludeObject(IShellView, LPCITEMIDLIST);
+}
+alias ICommDlgBrowser LPCOMMDLGBROWSER;
+
+alias GUID SHELLVIEWID;
+
+struct SV2CVW2_PARAMS {
+    DWORD cbSize = this.sizeof;
+    IShellView psvPrev;
+    FOLDERSETTINGS  *pfs;
+    IShellBrowser psbOwner;
+    RECT *prcView;
+const(SHELLVIEWID)* pvid;
+    HWND hwndView;
+}
+alias SV2CVW2_PARAMS* LPSV2CVW2_PARAMS;
+
+interface IShellView2 : IShellView {
+    HRESULT GetWindow(HWND*);
+    HRESULT ContextSensitiveHelp(BOOL);
+    HRESULT TranslateAccelerator(LPMSG);
+//[No] #ifdef _FIX_ENABLEMODELESS_CONFLICT
+//[No]  STDMETHOD(EnableModelessSV)(THIS_ BOOL) PURE;
+//[Yes] #else
+    HRESULT EnableModeless(BOOL);
+//[Yes] #endif
+    HRESULT UIActivate(UINT);
+    HRESULT Refresh();
+    HRESULT CreateViewWindow(IShellView, LPCFOLDERSETTINGS, LPSHELLBROWSER, RECT*, HWND*);
+    HRESULT DestroyViewWindow();
+    HRESULT GetCurrentInfo(LPFOLDERSETTINGS);
+    HRESULT AddPropertySheetPages(DWORD, LPFNADDPROPSHEETPAGE, LPARAM);
+    HRESULT SaveViewState();
+    HRESULT SelectItem(LPCITEMIDLIST, UINT);
+    HRESULT GetItemObject(UINT, REFIID, PVOID*);
+    HRESULT GetView(SHELLVIEWID*, ULONG);
+    HRESULT CreateViewWindow2(LPSV2CVW2_PARAMS);
+}
+
+interface IShellExecuteHookA : IUnknown {
+    HRESULT Execute(LPSHELLEXECUTEINFOA);
+}
+
+interface IShellExecuteHookW : IUnknown {
+    HRESULT Execute(LPSHELLEXECUTEINFOW);
+}
+
+interface IShellIcon : IUnknown {
+    HRESULT GetIconOf(LPCITEMIDLIST, UINT, PINT);
+}
+alias IShellIcon LPSHELLICON;
+
+struct SHELLFLAGSTATE {
+    short _bf;
+/*
+    BOOL fShowAllObjects : 1;
+    BOOL fShowExtensions : 1;
+    BOOL fNoConfirmRecycle : 1;
+    BOOL fShowSysFiles : 1;
+    BOOL fShowCompColor : 1;
+    BOOL fDoubleClickInWebView : 1;
+    BOOL fDesktopHTML : 1;
+    BOOL fWin95Classic : 1;
+    BOOL fDontPrettyPath : 1;
+    BOOL fShowAttribCol : 1;
+    BOOL fMapNetDrvBtn : 1;
+    BOOL fShowInfoTip : 1;
+    BOOL fHideIcons : 1;
+    UINT fRestFlags : 3;
+*/
+    @property bool fShowAllObjects()       { return cast(bool) (_bf & 0x0001); }
+    @property bool fShowExtensions()       { return cast(bool) (_bf & 0x0002); }
+    @property bool fNoConfirmRecycle()     { return cast(bool) (_bf & 0x0004); }
+    @property bool fShowSysFiles()         { return cast(bool) (_bf & 0x0008); }
+    @property bool fShowCompColor()        { return cast(bool) (_bf & 0x0010); }
+    @property bool fDoubleClickInWebView() { return cast(bool) (_bf & 0x0020); }
+    @property bool fDesktopHTML()          { return cast(bool) (_bf & 0x0040); }
+    @property bool fWin95Classic()         { return cast(bool) (_bf & 0x0080); }
+    @property bool fDontPrettyPath()       { return cast(bool) (_bf & 0x0100); }
+    @property bool fShowAttribCol()        { return cast(bool) (_bf & 0x0200); }
+    @property bool fMapNetDrvBtn()         { return cast(bool) (_bf & 0x0400); }
+    @property bool fShowInfoTip()          { return cast(bool) (_bf & 0x0800); }
+    @property bool fHideIcons()            { return cast(bool) (_bf & 0x1000); }
+    @property ubyte fRestFlags()           { return cast(ubyte) (_bf >> 13); }
+
+    @property bool fShowAllObjects(bool f)       { _bf = cast(ushort) ((_bf & ~0xFFFE) | f);        return f; }
+    @property bool fShowExtensions(bool f)       { _bf = cast(ushort) ((_bf & ~0xFFFD) | (f <<  1)); return f; }
+    @property bool fNoConfirmRecycle(bool f)     { _bf = cast(ushort) ((_bf & ~0xFFFB) | (f <<  2)); return f; }
+    @property bool fShowSysFiles(bool f)         { _bf = cast(ushort) ((_bf & ~0xFFF8) | (f <<  3)); return f; }
+    @property bool fShowCompColor(bool f)        { _bf = cast(ushort) ((_bf & ~0xFFEF) | (f <<  4)); return f; }
+    @property bool fDoubleClickInWebView(bool f) { _bf = cast(ushort) ((_bf & ~0xFFDF) | (f <<  5)); return f; }
+    @property bool fDesktopHTML(bool f)          { _bf = cast(ushort) ((_bf & ~0xFFBF) | (f <<  6)); return f; }
+    @property bool fWin95Classic(bool f)         { _bf = cast(ushort) ((_bf & ~0xFF8F) | (f <<  7)); return f; }
+    @property bool fDontPrettyPath(bool f)       { _bf = cast(ushort) ((_bf & ~0xFEFF) | (f <<  8)); return f; }
+    @property bool fShowAttribCol(bool f)        { _bf = cast(ushort) ((_bf & ~0xFDFF) | (f <<  9)); return f; }
+    @property bool fMapNetDrvBtn(bool f)         { _bf = cast(ushort) ((_bf & ~0xFBFF) | (f << 10)); return f; }
+    @property bool fShowInfoTip(bool f)          { _bf = cast(ushort) ((_bf & ~0xF8FF) | (f << 11)); return f; }
+    @property bool fHideIcons(bool f)            { _bf = cast(ushort) ((_bf & ~0xEFFF) | (f << 12)); return f; }
+    @property ubyte fRestFlags(ubyte f)          { _bf = cast(ushort) ((_bf & ~0x1FFF) | (f << 13)); return cast(ubyte) (f & 7); }
+}
+alias SHELLFLAGSTATE* LPSHELLFLAGSTATE;
+
+enum SSF_SHOWALLOBJECTS = 0x1;
+enum SSF_SHOWEXTENSIONS = 0x2;
+enum SSF_SHOWCOMPCOLOR = 0x8;
+enum SSF_SHOWSYSFILES = 0x20;
+enum SSF_DOUBLECLICKINWEBVIEW = 0x80;
+enum SSF_SHOWATTRIBCOL = 0x100;
+enum SSF_DESKTOPHTML = 0x200;
+enum SSF_WIN95CLASSIC = 0x400;
+enum SSF_DONTPRETTYPATH = 0x800;
+enum SSF_MAPNETDRVBUTTON = 0x1000;
+enum SSF_SHOWINFOTIP = 0x2000;
+enum SSF_HIDEICONS = 0x4000;
+enum SSF_NOCONFIRMRECYCLE = 0x8000;
+
+interface IShellIconOverlayIdentifier : IUnknown {
+    HRESULT IsMemberOf(LPCWSTR, DWORD);
+    HRESULT GetOverlayInfo(LPWSTR, int, int*, DWORD*);
+    HRESULT GetPriority(int*);
+}
+
+enum ISIOI_ICONFILE  = 0x00000001;
+enum ISIOI_ICONINDEX = 0x00000002;
+
+static if (_WIN32_WINNT >= 0x500) {
+    struct SHELLSTATE {
+        uint _bf1;
+        DWORD dwWin95Unused;
+        UINT uWin95Unused;
+        LONG lParamSort;
+        int iSortDirection;
+        UINT _version;
+        UINT uNotUsed;
+        uint _bf2;
+    /*
+        BOOL fShowAllObjects : 1;
+        BOOL fShowExtensions : 1;
+        BOOL fNoConfirmRecycle : 1;
+        BOOL fShowSysFiles : 1;
+        BOOL fShowCompColor : 1;
+        BOOL fDoubleClickInWebView : 1;
+        BOOL fDesktopHTML : 1;
+        BOOL fWin95Classic : 1;
+        BOOL fDontPrettyPath : 1;
+        BOOL fShowAttribCol : 1;
+        BOOL fMapNetDrvBtn : 1;
+        BOOL fShowInfoTip : 1;
+        BOOL fHideIcons : 1;
+        BOOL fWebView : 1;
+        BOOL fFilter : 1;
+        BOOL fShowSuperHidden : 1;
+        BOOL fNoNetCrawling : 1;
+    */
+        @property bool fShowAllObjects()       { return cast(bool) (_bf1 & 0x00000001); }
+        @property bool fShowExtensions()       { return cast(bool) (_bf1 & 0x00000002); }
+        @property bool fNoConfirmRecycle()     { return cast(bool) (_bf1 & 0x00000004); }
+        @property bool fShowSysFiles()         { return cast(bool) (_bf1 & 0x00000008); }
+        @property bool fShowCompColor()        { return cast(bool) (_bf1 & 0x00000010); }
+        @property bool fDoubleClickInWebView() { return cast(bool) (_bf1 & 0x00000020); }
+        @property bool fDesktopHTML()          { return cast(bool) (_bf1 & 0x00000040); }
+        @property bool fWin95Classic()         { return cast(bool) (_bf1 & 0x00000080); }
+        @property bool fDontPrettyPath()       { return cast(bool) (_bf1 & 0x00000100); }
+        @property bool fShowAttribCol()        { return cast(bool) (_bf1 & 0x00000200); }
+        @property bool fMapNetDrvBtn()         { return cast(bool) (_bf1 & 0x00000400); }
+        @property bool fShowInfoTip()          { return cast(bool) (_bf1 & 0x00000800); }
+        @property bool fHideIcons()            { return cast(bool) (_bf1 & 0x00001000); }
+        @property bool fWebView()              { return cast(bool) (_bf1 & 0x00002000); }
+        @property bool fFilter()               { return cast(bool) (_bf1 & 0x00004000); }
+        @property bool fShowSuperHidden()      { return cast(bool) (_bf1 & 0x00008000); }
+        @property bool fNoNetCrawling()        { return cast(bool) (_bf1 & 0x00010000); }
+
+        @property bool fShowAllObjects(bool f)       { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFFE) | f);         return f; }
+        @property bool fShowExtensions(bool f)       { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFFD) | (f <<  1)); return f; }
+        @property bool fNoConfirmRecycle(bool f)     { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFFB) | (f <<  2)); return f; }
+        @property bool fShowSysFiles(bool f)         { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFF8) | (f <<  3)); return f; }
+        @property bool fShowCompColor(bool f)        { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFEF) | (f <<  4)); return f; }
+        @property bool fDoubleClickInWebView(bool f) { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFDF) | (f <<  5)); return f; }
+        @property bool fDesktopHTML(bool f)          { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFFBF) | (f <<  6)); return f; }
+        @property bool fWin95Classic(bool f)         { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFF8F) | (f <<  7)); return f; }
+        @property bool fDontPrettyPath(bool f)       { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFEFF) | (f <<  8)); return f; }
+        @property bool fShowAttribCol(bool f)        { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFDFF) | (f <<  9)); return f; }
+        @property bool fMapNetDrvBtn(bool f)         { _bf1 = cast(uint) ((_bf1 & ~0xFFFFFBFF) | (f << 10)); return f; }
+        @property bool fShowInfoTip(bool f)          { _bf1 = cast(uint) ((_bf1 & ~0xFFFFF8FF) | (f << 11)); return f; }
+        @property bool fHideIcons(bool f)            { _bf1 = cast(uint) ((_bf1 & ~0xFFFFEFFF) | (f << 12)); return f; }
+        @property bool fWebView(bool f)              { _bf1 = cast(uint) ((_bf1 & ~0xFFFFDFFF) | (f << 13)); return f; }
+        @property bool fFilter(bool f)               { _bf1 = cast(uint) ((_bf1 & ~0xFFFFBFFF) | (f << 14)); return f; }
+        @property bool fShowSuperHidden(bool f)      { _bf1 = cast(uint) ((_bf1 & ~0xFFFF8FFF) | (f << 15)); return f; }
+        @property bool fNoNetCrawling(bool f)        { _bf1 = cast(uint) ((_bf1 & ~0xFFFEFFFF) | (f << 16)); return f; }
+    /*
+        BOOL fSepProcess : 1;
+        BOOL fStartPanelOn : 1;
+        BOOL fShowStartPage : 1;
+        UINT fSpareFlags : 13;
+    */
+        @property bool fSepProcess()           { return cast(bool) (_bf2 & 0x00000001); }
+        @property bool fStartPanelOn()         { return cast(bool) (_bf2 & 0x00000002); }
+        @property bool fShowStartPage()        { return cast(bool) (_bf2 & 0x00000004); }
+        @property ushort fSpareFlags()         { return cast(ushort) ((_bf2 & 0x0000FFF8) >> 3); }
+
+        @property bool fSepProcess(bool f)     { _bf2 = cast(uint) ((_bf2 & ~0xFFFFFFFE) | f);        return f; }
+        @property bool fStartPanelOn(bool f)   { _bf2 = cast(uint) ((_bf2 & ~0xFFFFFFFD) | (f << 1)); return f; }
+        @property bool fShowStartPage(bool f)  { _bf2 = cast(uint) ((_bf2 & ~0xFFFFFFFB) | (f << 2)); return f; }
+        @property ushort fSpareFlags(ushort f) {
+            _bf2 = cast(ushort) ((_bf2 & ~0xFFFF0007) | ((f & 0x1FFF) << 3));
+            return cast(ushort) (f & 0x1FFF);
+        }
+    }
+    alias SHELLSTATE* LPSHELLSTATE;
+}
+
+static if (_WIN32_IE >= 0x500) {
+    align(8) {
+        struct SHDRAGIMAGE {
+            SIZE sizeDragImage;
+            POINT ptOffset;
+            HBITMAP hbmpDragImage;
+            COLORREF crColorKey;
+        }
+        alias SHDRAGIMAGE* LPSHDRAGIMAGE;
+    }
+
+    interface IDragSourceHelper : IUnknown {
+        HRESULT InitializeFromBitmap(LPSHDRAGIMAGE pshdi, IDataObject pDataObject);
+        HRESULT InitializeFromWindow(HWND hwnd, POINT* ppt, IDataObject pDataObject);
+    }
+
+    interface IDropTargetHelper : IUnknown {
+        HRESULT DragEnter(HWND hwndTarget, IDataObject pDataObject, POINT* ppt, DWORD dwEffect);
+        HRESULT DragLeave();
+        HRESULT DragOver(POINT* ppt, DWORD dwEffect);
+        HRESULT Drop(IDataObject pDataObject, POINT* ppt, DWORD dwEffect);
+        HRESULT Show(BOOL fShow);
+    }
+}
+
+extern (Windows):
+void SHAddToRecentDocs(UINT, PCVOID);
+LPITEMIDLIST SHBrowseForFolderA(PBROWSEINFOA);
+LPITEMIDLIST SHBrowseForFolderW(PBROWSEINFOW);
+void SHChangeNotify(LONG, UINT, PCVOID, PCVOID);
+HRESULT SHGetDataFromIDListA(LPSHELLFOLDER, LPCITEMIDLIST, int, PVOID, int);
+HRESULT SHGetDataFromIDListW(LPSHELLFOLDER, LPCITEMIDLIST, int, PVOID, int);
+HRESULT SHGetDesktopFolder(LPSHELLFOLDER*);
+HRESULT SHGetInstanceExplorer(IUnknown*);
+HRESULT SHGetMalloc(LPMALLOC*);
+BOOL SHGetPathFromIDListA(LPCITEMIDLIST, LPSTR);
+BOOL SHGetPathFromIDListW(LPCITEMIDLIST, LPWSTR);
+HRESULT SHGetSpecialFolderLocation(HWND, int, LPITEMIDLIST*);
+HRESULT SHLoadInProc(REFCLSID);
+
+static if (_WIN32_IE >= 0x400) {
+    BOOL SHGetSpecialFolderPathA(HWND, LPSTR, int, BOOL);
+    BOOL SHGetSpecialFolderPathW(HWND, LPWSTR, int, BOOL);
+}
+
+/* SHGetFolderPath in shfolder.dll on W9x, NT4, also in shell32.dll on W2K */
+HRESULT SHGetFolderPathA(HWND, int, HANDLE, DWORD, LPSTR);
+HRESULT SHGetFolderPathW(HWND, int, HANDLE, DWORD, LPWSTR);
+
+static if (_WIN32_WINNT >= 0x500) {
+    INT SHGetIconOverlayIndexW(LPCWSTR pszIconPath, int iIconIndex);
+    INT SHGetIconOverlayIndexA(LPCSTR pszIconPath, int iIconIndex);
+    HRESULT SHGetFolderLocation(HWND, int, HANDLE, DWORD, LPITEMIDLIST*);
+    INT SHCreateDirectoryExA(HWND, LPCSTR, LPSECURITY_ATTRIBUTES);
+    INT SHCreateDirectoryExW(HWND, LPCWSTR, LPSECURITY_ATTRIBUTES);
+    HRESULT SHBindToParent(LPCITEMIDLIST, REFIID, VOID**, LPCITEMIDLIST*);
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        PRF_VERIFYEXISTS         = 0x0001,
+        PRF_TRYPROGRAMEXTENSIONS = (0x0002 | PRF_VERIFYEXISTS),
+        PRF_FIRSTDIRDEF          = 0x0004,
+        PRF_DONTFINDLNK          = 0x0008,
+        IDO_SHGIOI_SHARE         = 0x0FFFFFFF,
+        IDO_SHGIOI_LINK          = 0x0FFFFFFE,
+        IDO_SHGIOI_SLOWFILE      = 0x0FFFFFFD,
+        IDO_SHGIOI_DEFAULT       = 0x0FFFFFFC
+    }
+
+    struct SHDESCRIPTIONID {
+        DWORD dwDescriptionId;
+        CLSID clsid;
+    }
+    alias SHDESCRIPTIONID* LPSHDESCRIPTIONID;
+
+    BOOL PathResolve(LPWSTR, LPCWSTR*, UINT);
+    HRESULT SHGetFolderPathAndSubDirA(HWND, int, HANDLE, DWORD, LPCSTR, LPSTR);
+    HRESULT SHGetFolderPathAndSubDirW(HWND, int, HANDLE, DWORD, LPCWSTR, LPWSTR);
+    HRESULT SHParseDisplayName(LPCWSTR, IBindCtx, LPITEMIDLIST, SFGAOF, SFGAOF*);
+}
+
+void SHGetSettings(LPSHELLFLAGSTATE, DWORD);
+
+static if (_WIN32_WINNT >= 0x500) {
+    void SHGetSetSettings(LPSHELLSTATE, DWORD, BOOL);
+    BOOL ILIsEqual(LPCITEMIDLIST, LPCITEMIDLIST);
+    BOOL ILIsParent(LPCITEMIDLIST, LPCITEMIDLIST, BOOL);
+    BOOL ILRemoveLastID(LPITEMIDLIST);
+    HRESULT ILLoadFromStream(IStream, LPITEMIDLIST*);
+    HRESULT ILSaveToStream(IStream, LPCITEMIDLIST);
+    LPITEMIDLIST ILAppendID(LPITEMIDLIST, LPCSHITEMID, BOOL);
+    LPITEMIDLIST ILClone(LPCITEMIDLIST);
+    LPITEMIDLIST ILCloneFirst(LPCITEMIDLIST);
+    LPITEMIDLIST ILCombine(LPCITEMIDLIST, LPCITEMIDLIST);
+    LPITEMIDLIST ILFindChild(LPCITEMIDLIST, LPCITEMIDLIST);
+    LPITEMIDLIST ILFindLastID(LPCITEMIDLIST);
+    LPITEMIDLIST ILGetNext(LPCITEMIDLIST);
+    UINT ILGetSize(LPCITEMIDLIST);
+    void ILFree(LPITEMIDLIST);
+
+    HRESULT SHCoCreateInstance(LPCWSTR, REFCLSID, IUnknown, REFIID, void**);
+}
+
+version(Unicode) {
+    alias IShellExecuteHookW IShellExecuteHook;
+    alias IShellLinkW IShellLink;
+    alias BROWSEINFOW BROWSEINFO;
+    alias SHBrowseForFolderW SHBrowseForFolder;
+    alias SHGetDataFromIDListW SHGetDataFromIDList;
+    alias SHGetPathFromIDListW SHGetPathFromIDList;
+    static if (_WIN32_IE >= 0x400) {
+        alias SHGetSpecialFolderPathW SHGetSpecialFolderPath;
+    }
+    alias SHGetFolderPathW SHGetFolderPath;
+    static if (_WIN32_WINNT >= 0x500) {
+        alias SHGetIconOverlayIndexW SHGetIconOverlayIndex;
+        alias SHCreateDirectoryExW SHCreateDirectoryEx;
+    }
+    static if (_WIN32_WINNT >= 0x501) {
+        alias SHGetFolderPathAndSubDirW SHGetFolderPathAndSubDir;
+    }
+    alias FILEDESCRIPTORW FILEDESCRIPTOR;
+    alias LPFILEDESCRIPTORW LPFILEDESCRIPTOR;
+    alias FILEGROUPDESCRIPTORW FILEGROUPDESCRIPTOR;
+    alias LPFILEGROUPDESCRIPTORW LPFILEGROUPDESCRIPTOR;
+
+} else {
+    alias IShellExecuteHookA IShellExecuteHook;
+    alias IShellLinkA IShellLink;
+    alias BROWSEINFOA BROWSEINFO;
+    alias SHBrowseForFolderA SHBrowseForFolder;
+    alias SHGetDataFromIDListA SHGetDataFromIDList;
+    alias SHGetPathFromIDListA SHGetPathFromIDList;
+    static if (_WIN32_IE >= 0x400) {
+        alias SHGetSpecialFolderPathA SHGetSpecialFolderPath;
+    }
+    alias SHGetFolderPathA SHGetFolderPath;
+    static if (_WIN32_WINNT >= 0x500) {
+        alias SHGetIconOverlayIndexA SHGetIconOverlayIndex;
+        alias SHCreateDirectoryExA SHCreateDirectoryEx;
+    }
+    static if (_WIN32_WINNT >= 0x501) {
+        alias SHGetFolderPathAndSubDirA SHGetFolderPathAndSubDir;
+    }
+    alias FILEDESCRIPTORA FILEDESCRIPTOR;
+    alias LPFILEDESCRIPTORA LPFILEDESCRIPTOR;
+    alias FILEGROUPDESCRIPTORA FILEGROUPDESCRIPTOR;
+    alias LPFILEGROUPDESCRIPTORA LPFILEGROUPDESCRIPTOR;
+}
+alias BROWSEINFO* PBROWSEINFO, LPBROWSEINFO;
+
+static if (_WIN32_WINNT >= 0x501) {
+    interface IFolderView : IUnknown {
+       HRESULT GetAutoArrange();
+       HRESULT GetCurrentViewMode(UINT);
+       HRESULT GetDefaultSpacing(POINT*);
+       HRESULT GetFocusedItem(int*);
+       HRESULT GetFolder(REFIID, PVOID*);
+       HRESULT GetItemPosition(LPCITEMIDLIST, POINT*);
+       HRESULT GetSelectionMarkedItem(int*);
+       HRESULT GetSpacing(POINT*);
+       HRESULT Item(int, LPITEMIDLIST*);
+       HRESULT ItemCount(UINT, int*);
+       HRESULT Items(UINT, REFIID, PVOID*);
+       HRESULT SelectAndPositionItems(UINT, LPCITEMIDLIST*, POINT*, DWORD);
+       HRESULT SelectItem(int, DWORD);
+       HRESULT SetCurrentViewMode(UINT);
+    }
+    alias IFolderView LPFOLDERVIEW;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/shlwapi.d b/libphobos/libdruntime/core/sys/windows/shlwapi.d
new file mode 100644
index 00000000000..5d223153b49
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/shlwapi.d
@@ -0,0 +1,732 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_shlwapi.d)
+ */
+module core.sys.windows.shlwapi;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "shlwapi");
+
+/* Changes compared to MinGW:
+wnsprintf functions are not included.
+// Macros unneeded for D
+#define StrCmpIA lstrcmpiA;
+#define StrCmpA lstrcmpA;
+#define StrCpyA lstrcpyA;
+#define StrCpyNA lstrcpynA;
+#define MAKEDLLVERULL(major, minor, build, qfe) \
+        (((ULONGLONG)(major) << 48) | \
+         ((ULONGLONG)(minor) << 32) | \
+         ((ULONGLONG)(build) << 16) | \
+         ((ULONGLONG)(  qfe) <<  0))
+*/
+
+import core.sys.windows.objbase, core.sys.windows.shlobj;
+private import core.sys.windows.basetyps, core.sys.windows.objidl, core.sys.windows.unknwn, core.sys.windows.windef,
+  core.sys.windows.winbase, core.sys.windows.winreg;
+
+enum DLLVER_PLATFORM_WINDOWS = 0x00000001;
+enum DLLVER_PLATFORM_NT      = 0x00000002;
+
+enum URL_DONT_ESCAPE_EXTRA_INFO  = 0x02000000;
+enum URL_DONT_SIMPLIFY           = 0x08000000;
+enum URL_ESCAPE_PERCENT          = 0x00001000;
+enum URL_ESCAPE_SEGMENT_ONLY     = 0x00002000;
+enum URL_ESCAPE_SPACES_ONLY      = 0x04000000;
+enum URL_ESCAPE_UNSAFE           = 0x20000000;
+enum URL_INTERNAL_PATH           = 0x00800000;
+enum URL_PARTFLAG_KEEPSCHEME     = 0x00000001;
+enum URL_PLUGGABLE_PROTOCOL      = 0x40000000;
+enum URL_UNESCAPE                = 0x10000000;
+enum URL_UNESCAPE_HIGH_ANSI_ONLY = 0x00400000;
+enum URL_UNESCAPE_INPLACE        = 0x00100000;
+
+align(1):
+struct DLLVERSIONINFO
+{
+    DWORD cbSize = this.sizeof;
+    DWORD dwMajorVersion;
+    DWORD dwMinorVersion;
+    DWORD dwBuildNumber;
+    DWORD dwPlatformID;
+}
+
+struct DLLVERSIONINFO2
+{
+    DLLVERSIONINFO info1;
+    DWORD dwFlags;
+    ULONGLONG ullVersion;
+}
+
+enum ASSOCSTR {
+    ASSOCSTR_COMMAND,
+    ASSOCSTR_EXECUTABLE,
+    ASSOCSTR_FRIENDLYDOCNAME,
+    ASSOCSTR_FRIENDLYAPPNAME,
+    ASSOCSTR_NOOPEN,
+    ASSOCSTR_SHELLNEWVALUE,
+    ASSOCSTR_DDECOMMAND,
+    ASSOCSTR_DDEIFEXEC,
+    ASSOCSTR_DDEAPPLICATION,
+    ASSOCSTR_DDETOPIC
+}
+
+enum ASSOCKEY
+{
+    ASSOCKEY_SHELLEXECCLASS = 1,
+    ASSOCKEY_APP,
+    ASSOCKEY_CLASS,
+    ASSOCKEY_BASECLASS
+}
+
+enum ASSOCDATA
+{
+    ASSOCDATA_MSIDESCRIPTOR = 1,
+    ASSOCDATA_NOACTIVATEHANDLER,
+    ASSOCDATA_QUERYCLASSSTORE
+}
+
+alias DWORD ASSOCF;
+
+enum SHREGDEL_FLAGS
+{
+    SHREGDEL_DEFAULT = 0x00000000,
+    SHREGDEL_HKCU    = 0x00000001,
+    SHREGDEL_HKLM    = 0x00000010,
+    SHREGDEL_BOTH    = 0x00000011
+}
+
+enum SHREGENUM_FLAGS
+{
+    SHREGENUM_DEFAULT = 0x00000000,
+    SHREGENUM_HKCU    = 0x00000001,
+    SHREGENUM_HKLM    = 0x00000010,
+    SHREGENUM_BOTH    = 0x00000011
+}
+
+enum URLIS
+{
+    URLIS_URL,
+    URLIS_OPAQUE,
+    URLIS_NOHISTORY,
+    URLIS_FILEURL,
+    URLIS_APPLIABLE,
+    URLIS_DIRECTORY,
+    URLIS_HASQUERY
+}
+
+mixin DECLARE_HANDLE!("HUSKEY");
+alias HUSKEY* PHUSKEY;
+
+extern (Windows)
+{
+    alias HRESULT function (DLLVERSIONINFO *) DLLGETVERSIONPROC;
+}
+
+
+BOOL IntlStrEqNA(LPCSTR pStr1, LPCSTR pStr2, int nChar)
+{
+    return IntlStrEqWorkerA(TRUE, pStr1, pStr2, nChar);
+}
+
+BOOL IntlStrEqNW(LPCWSTR pStr1, LPCWSTR pStr2, int nChar)
+{
+    return IntlStrEqWorkerW(TRUE, pStr1, pStr2, nChar);
+}
+
+BOOL IntlStrEqNIA(LPCSTR pStr1, LPCSTR pStr2, int nChar)
+{
+    return IntlStrEqWorkerA(FALSE, pStr1, pStr2, nChar);
+}
+
+BOOL IntlStrEqNIW(LPCWSTR pStr1, LPCWSTR pStr2, int nChar)
+{
+    return IntlStrEqWorkerW(FALSE, pStr1, pStr2, nChar);
+}
+
+BOOL UrlIsFileUrlA(LPCSTR pszURL)
+{
+    return UrlIsA(pszURL, URLIS.URLIS_FILEURL);
+}
+
+BOOL UrlIsFileUrlW(LPCWSTR pszURL)
+{
+    return UrlIsW(pszURL, URLIS.URLIS_FILEURL);
+}
+
+HRESULT UrlUnescapeInPlaceA(LPSTR pszUrl, DWORD dwFlags)
+{
+    return UrlUnescapeA(pszUrl, null, null, dwFlags | URL_UNESCAPE_INPLACE);
+}
+HRESULT UrlUnescapeInPlaceW(LPWSTR pszUrl, DWORD dwFlags)
+{
+    return UrlUnescapeW(pszUrl, null, null, dwFlags | URL_UNESCAPE_INPLACE);
+}
+
+extern (Windows):
+BOOL ChrCmpIA(WORD, WORD);
+BOOL ChrCmpIW(WCHAR, WCHAR);
+BOOL IntlStrEqWorkerA(BOOL, LPCSTR, LPCSTR, int);
+BOOL IntlStrEqWorkerW(BOOL, LPCWSTR, LPCWSTR, int);
+HRESULT SHStrDupA(LPCSTR, LPWSTR*);
+HRESULT SHStrDupW(LPCWSTR, LPWSTR*);
+LPSTR StrCatA(LPSTR, LPCSTR);
+LPWSTR StrCatW(LPWSTR, LPCWSTR);
+LPSTR StrCatBuffA(LPSTR, LPCSTR, int);
+LPWSTR StrCatBuffW(LPWSTR, LPCWSTR, int);
+DWORD StrCatChainW(LPWSTR, DWORD, DWORD, LPCWSTR);
+LPSTR StrChrA(LPCSTR, WORD);
+LPWSTR StrChrW(LPCWSTR, WCHAR);
+LPSTR StrChrIA(LPCSTR, WORD);
+LPWSTR StrChrIW(LPCWSTR, WCHAR);
+int StrCmpIW(LPCWSTR, LPCWSTR);
+int StrCmpW(LPCWSTR, LPCWSTR);
+LPWSTR StrCpyW(LPWSTR, LPCWSTR);
+LPWSTR StrCpyNW(LPWSTR, LPCWSTR, int);
+int StrCmpNA(LPCSTR, LPCSTR, int);
+int StrCmpNW(LPCWSTR, LPCWSTR, int);
+int StrCmpNIA(LPCSTR, LPCSTR, int);
+int StrCmpNIW(LPCWSTR, LPCWSTR, int);
+int StrCSpnA(LPCSTR, LPCSTR);
+int StrCSpnW(LPCWSTR, LPCWSTR);
+int StrCSpnIA(LPCSTR, LPCSTR);
+int StrCSpnIW(LPCWSTR, LPCWSTR);
+LPSTR StrDupA(LPCSTR);
+LPWSTR StrDupW(LPCWSTR);
+LPSTR StrFormatByteSize64A(LONGLONG, LPSTR, UINT);
+LPSTR StrFormatByteSizeA(DWORD, LPSTR, UINT);
+LPWSTR StrFormatByteSizeW(LONGLONG, LPWSTR, UINT);
+LPSTR StrFormatKBSizeA(LONGLONG, LPSTR, UINT);
+LPWSTR StrFormatKBSizeW(LONGLONG, LPWSTR, UINT);
+int StrFromTimeIntervalA(LPSTR, UINT, DWORD, int);
+int StrFromTimeIntervalW(LPWSTR, UINT, DWORD, int);
+BOOL StrIsIntlEqualA(BOOL, LPCSTR, LPCSTR, int);
+BOOL StrIsIntlEqualW(BOOL, LPCWSTR, LPCWSTR, int);
+LPSTR StrNCatA(LPSTR, LPCSTR, int);
+LPWSTR StrNCatW(LPWSTR, LPCWSTR, int);
+LPSTR StrPBrkA(LPCSTR, LPCSTR);
+LPWSTR StrPBrkW(LPCWSTR, LPCWSTR);
+LPSTR StrRChrA(LPCSTR, LPCSTR, WORD);
+LPWSTR StrRChrW(LPCWSTR, LPCWSTR, WCHAR);
+LPSTR StrRChrIA(LPCSTR, LPCSTR, WORD);
+LPWSTR StrRChrIW(LPCWSTR, LPCWSTR, WCHAR);
+LPSTR StrRStrIA(LPCSTR, LPCSTR, LPCSTR);
+LPWSTR StrRStrIW(LPCWSTR, LPCWSTR, LPCWSTR);
+int StrSpnA(LPCSTR, LPCSTR);
+int StrSpnW(LPCWSTR, LPCWSTR);
+LPSTR StrStrA(LPCSTR, LPCSTR);
+LPSTR StrStrIA(LPCSTR, LPCSTR);
+LPWSTR StrStrIW(LPCWSTR, LPCWSTR);
+LPWSTR StrStrW(LPCWSTR, LPCWSTR);
+int StrToIntA(LPCSTR);
+int StrToIntW(LPCWSTR);
+BOOL StrToIntExA(LPCSTR, DWORD, int*);
+BOOL StrToIntExW(LPCWSTR, DWORD, int*);
+BOOL StrTrimA(LPSTR, LPCSTR);
+BOOL StrTrimW(LPWSTR, LPCWSTR);
+LPSTR PathAddBackslashA(LPSTR);
+LPWSTR PathAddBackslashW(LPWSTR);
+BOOL PathAddExtensionA(LPSTR, LPCSTR);
+BOOL PathAddExtensionW(LPWSTR, LPCWSTR);
+BOOL PathAppendA(LPSTR, LPCSTR);
+BOOL PathAppendW(LPWSTR, LPCWSTR);
+LPSTR PathBuildRootA(LPSTR, int);
+LPWSTR PathBuildRootW(LPWSTR, int);
+BOOL PathCanonicalizeA(LPSTR, LPCSTR);
+BOOL PathCanonicalizeW(LPWSTR, LPCWSTR);
+LPSTR PathCombineA(LPSTR, LPCSTR, LPCSTR);
+LPWSTR PathCombineW(LPWSTR, LPCWSTR, LPCWSTR);
+int PathCommonPrefixA(LPCSTR, LPCSTR, LPSTR);
+int PathCommonPrefixW(LPCWSTR, LPCWSTR, LPWSTR);
+BOOL PathCompactPathA(HDC, LPSTR, UINT);
+BOOL PathCompactPathW(HDC, LPWSTR, UINT);
+BOOL PathCompactPathExA(LPSTR, LPCSTR, UINT, DWORD);
+BOOL PathCompactPathExW(LPWSTR, LPCWSTR, UINT, DWORD);
+HRESULT PathCreateFromUrlA(LPCSTR, LPSTR, LPDWORD, DWORD);
+HRESULT PathCreateFromUrlW(LPCWSTR, LPWSTR, LPDWORD, DWORD);
+BOOL PathFileExistsA(LPCSTR);
+BOOL PathFileExistsW(LPCWSTR);
+LPSTR PathFindExtensionA(LPCSTR);
+LPWSTR PathFindExtensionW(LPCWSTR);
+LPSTR PathFindFileNameA(LPCSTR);
+LPWSTR PathFindFileNameW(LPCWSTR);
+LPSTR PathFindNextComponentA(LPCSTR);
+LPWSTR PathFindNextComponentW(LPCWSTR);
+BOOL PathFindOnPathA(LPSTR, LPCSTR*);
+BOOL PathFindOnPathW(LPWSTR, LPCWSTR*);
+LPCSTR PathFindSuffixArrayA(LPCSTR, LPCSTR*, int);
+LPCWSTR PathFindSuffixArrayW(LPCWSTR, LPCWSTR*, int);
+LPSTR PathGetArgsA(LPCSTR);
+LPWSTR PathGetArgsW(LPCWSTR);
+UINT PathGetCharTypeA(UCHAR);
+UINT PathGetCharTypeW(WCHAR);
+int PathGetDriveNumberA(LPCSTR);
+int PathGetDriveNumberW(LPCWSTR);
+BOOL PathIsContentTypeA(LPCSTR, LPCSTR);
+BOOL PathIsContentTypeW(LPCWSTR, LPCWSTR);
+BOOL PathIsDirectoryA(LPCSTR);
+BOOL PathIsDirectoryEmptyA(LPCSTR);
+BOOL PathIsDirectoryEmptyW(LPCWSTR);
+BOOL PathIsDirectoryW(LPCWSTR);
+BOOL PathIsFileSpecA(LPCSTR);
+BOOL PathIsFileSpecW(LPCWSTR);
+BOOL PathIsLFNFileSpecA(LPCSTR);
+BOOL PathIsLFNFileSpecW(LPCWSTR);
+BOOL PathIsNetworkPathA(LPCSTR);
+BOOL PathIsNetworkPathW(LPCWSTR);
+BOOL PathIsPrefixA(LPCSTR, LPCSTR);
+BOOL PathIsPrefixW(LPCWSTR, LPCWSTR);
+BOOL PathIsRelativeA(LPCSTR);
+BOOL PathIsRelativeW(LPCWSTR);
+BOOL PathIsRootA(LPCSTR);
+BOOL PathIsRootW(LPCWSTR);
+BOOL PathIsSameRootA(LPCSTR, LPCSTR);
+BOOL PathIsSameRootW(LPCWSTR, LPCWSTR);
+BOOL PathIsSystemFolderA(LPCSTR, DWORD);
+BOOL PathIsSystemFolderW(LPCWSTR, DWORD);
+BOOL PathIsUNCA(LPCSTR);
+BOOL PathIsUNCServerA(LPCSTR);
+BOOL PathIsUNCServerShareA(LPCSTR);
+BOOL PathIsUNCServerShareW(LPCWSTR);
+BOOL PathIsUNCServerW(LPCWSTR);
+BOOL PathIsUNCW(LPCWSTR);
+BOOL PathIsURLA(LPCSTR);
+BOOL PathIsURLW(LPCWSTR);
+BOOL PathMakePrettyA(LPSTR);
+BOOL PathMakePrettyW(LPWSTR);
+BOOL PathMakeSystemFolderA(LPSTR);
+BOOL PathMakeSystemFolderW(LPWSTR);
+BOOL PathMatchSpecA(LPCSTR, LPCSTR);
+BOOL PathMatchSpecW(LPCWSTR, LPCWSTR);
+int PathParseIconLocationA(LPSTR);
+int PathParseIconLocationW(LPWSTR);
+void PathQuoteSpacesA(LPSTR);
+void PathQuoteSpacesW(LPWSTR);
+BOOL PathRelativePathToA(LPSTR, LPCSTR, DWORD, LPCSTR, DWORD);
+BOOL PathRelativePathToW(LPWSTR, LPCWSTR, DWORD, LPCWSTR, DWORD);
+void PathRemoveArgsA(LPSTR);
+void PathRemoveArgsW(LPWSTR);
+LPSTR PathRemoveBackslashA(LPSTR);
+LPWSTR PathRemoveBackslashW(LPWSTR);
+void PathRemoveBlanksA(LPSTR);
+void PathRemoveBlanksW(LPWSTR);
+void PathRemoveExtensionA(LPSTR);
+void PathRemoveExtensionW(LPWSTR);
+BOOL PathRemoveFileSpecA(LPSTR);
+BOOL PathRemoveFileSpecW(LPWSTR);
+BOOL PathRenameExtensionA(LPSTR, LPCSTR);
+BOOL PathRenameExtensionW(LPWSTR, LPCWSTR);
+BOOL PathSearchAndQualifyA(LPCSTR, LPSTR, UINT);
+BOOL PathSearchAndQualifyW(LPCWSTR, LPWSTR, UINT);
+void PathSetDlgItemPathA(HWND, int, LPCSTR);
+void PathSetDlgItemPathW(HWND, int, LPCWSTR);
+LPSTR PathSkipRootA(LPCSTR);
+LPWSTR PathSkipRootW(LPCWSTR);
+void PathStripPathA(LPSTR);
+void PathStripPathW(LPWSTR);
+BOOL PathStripToRootA(LPSTR);
+BOOL PathStripToRootW(LPWSTR);
+void PathUndecorateA(LPSTR);
+void PathUndecorateW(LPWSTR);
+BOOL PathUnExpandEnvStringsA(LPCSTR, LPSTR, UINT);
+BOOL PathUnExpandEnvStringsW(LPCWSTR, LPWSTR, UINT);
+BOOL PathUnmakeSystemFolderA(LPSTR);
+BOOL PathUnmakeSystemFolderW(LPWSTR);
+void PathUnquoteSpacesA(LPSTR);
+void PathUnquoteSpacesW(LPWSTR);
+HRESULT SHAutoComplete(HWND, DWORD);
+BOOL SHCreateThread(LPTHREAD_START_ROUTINE, void*, DWORD, LPTHREAD_START_ROUTINE);
+DWORD SHCopyKeyA(HKEY, LPCSTR, HKEY, DWORD);
+DWORD SHCopyKeyW(HKEY, LPCWSTR, HKEY, DWORD);
+DWORD SHDeleteEmptyKeyA(HKEY, LPCSTR);
+DWORD SHDeleteEmptyKeyW(HKEY, LPCWSTR);
+DWORD SHDeleteKeyA(HKEY, LPCSTR);
+DWORD SHDeleteKeyW(HKEY, LPCWSTR);
+DWORD SHEnumKeyExA(HKEY, DWORD, LPSTR, LPDWORD);
+DWORD SHEnumKeyExW(HKEY, DWORD, LPWSTR, LPDWORD);
+DWORD SHQueryInfoKeyA(HKEY, LPDWORD, LPDWORD, LPDWORD, LPDWORD);
+DWORD SHQueryInfoKeyW(HKEY, LPDWORD, LPDWORD, LPDWORD, LPDWORD);
+DWORD SHQueryValueExA(HKEY, LPCSTR, LPDWORD, LPDWORD, LPVOID, LPDWORD);
+DWORD SHQueryValueExW(HKEY, LPCWSTR, LPDWORD, LPDWORD, LPVOID, LPDWORD);
+HRESULT SHGetThreadRef(IUnknown*);
+HRESULT SHSetThreadRef(IUnknown);
+BOOL SHSkipJunction(IBindCtx, const(CLSID)*);
+DWORD SHEnumValueA(HKEY, DWORD, LPSTR, LPDWORD, LPDWORD, LPVOID, LPDWORD);
+DWORD SHEnumValueW(HKEY, DWORD, LPWSTR, LPDWORD, LPDWORD, LPVOID, LPDWORD);
+DWORD SHGetValueA(HKEY, LPCSTR, LPCSTR, LPDWORD, LPVOID, LPDWORD);
+DWORD SHGetValueW(HKEY, LPCWSTR, LPCWSTR, LPDWORD, LPVOID, LPDWORD);
+DWORD SHSetValueA(HKEY, LPCSTR, LPCSTR, DWORD, LPCVOID, DWORD);
+DWORD SHSetValueW(HKEY, LPCWSTR, LPCWSTR, DWORD, LPCVOID, DWORD);
+DWORD SHDeleteValueA(HKEY, LPCSTR, LPCSTR);
+DWORD SHDeleteValueW(HKEY, LPCWSTR, LPCWSTR);
+HRESULT AssocCreate(CLSID, const(IID)* , const(LPVOID)*);
+HRESULT AssocQueryKeyA(ASSOCF, ASSOCKEY, LPCSTR, LPCSTR, HKEY*);
+HRESULT AssocQueryKeyW(ASSOCF, ASSOCKEY, LPCWSTR, LPCWSTR, HKEY*);
+HRESULT AssocQueryStringA(ASSOCF, ASSOCSTR, LPCSTR, LPCSTR, LPSTR, DWORD*);
+HRESULT AssocQueryStringByKeyA(ASSOCF, ASSOCSTR, HKEY, LPCSTR, LPSTR, DWORD*);
+HRESULT AssocQueryStringByKeyW(ASSOCF, ASSOCSTR, HKEY, LPCWSTR, LPWSTR, DWORD*);
+HRESULT AssocQueryStringW(ASSOCF, ASSOCSTR, LPCWSTR, LPCWSTR, LPWSTR, DWORD*);
+HRESULT UrlApplySchemeA(LPCSTR, LPSTR, LPDWORD, DWORD);
+HRESULT UrlApplySchemeW(LPCWSTR, LPWSTR, LPDWORD, DWORD);
+HRESULT UrlCanonicalizeA(LPCSTR, LPSTR, LPDWORD, DWORD);
+HRESULT UrlCanonicalizeW(LPCWSTR, LPWSTR, LPDWORD, DWORD);
+HRESULT UrlCombineA(LPCSTR, LPCSTR, LPSTR, LPDWORD, DWORD);
+HRESULT UrlCombineW(LPCWSTR, LPCWSTR, LPWSTR, LPDWORD, DWORD);
+int UrlCompareA(LPCSTR, LPCSTR, BOOL);
+int UrlCompareW(LPCWSTR, LPCWSTR, BOOL);
+HRESULT UrlCreateFromPathA(LPCSTR, LPSTR, LPDWORD, DWORD);
+HRESULT UrlCreateFromPathW(LPCWSTR, LPWSTR, LPDWORD, DWORD);
+HRESULT UrlEscapeA(LPCSTR, LPSTR, LPDWORD, DWORD);
+HRESULT UrlEscapeW(LPCWSTR, LPWSTR, LPDWORD, DWORD);
+LPCSTR UrlGetLocationA(LPCSTR);
+LPCWSTR UrlGetLocationW(LPCWSTR);
+HRESULT UrlGetPartA(LPCSTR, LPSTR, LPDWORD, DWORD, DWORD);
+HRESULT UrlGetPartW(LPCWSTR, LPWSTR, LPDWORD, DWORD, DWORD);
+HRESULT UrlHashA(LPCSTR, LPBYTE, DWORD);
+HRESULT UrlHashW(LPCWSTR, LPBYTE, DWORD);
+BOOL UrlIsA(LPCSTR, URLIS);
+BOOL UrlIsW(LPCWSTR, URLIS);
+BOOL UrlIsNoHistoryA(LPCSTR);
+BOOL UrlIsNoHistoryW(LPCWSTR);
+BOOL UrlIsOpaqueA(LPCSTR);
+BOOL UrlIsOpaqueW(LPCWSTR);
+HRESULT UrlUnescapeA(LPSTR, LPSTR, LPDWORD, DWORD);
+HRESULT UrlUnescapeW(LPWSTR, LPWSTR, LPDWORD, DWORD);
+DWORD SHRegCloseUSKey(HUSKEY);
+LONG SHRegCreateUSKeyA(LPCSTR, REGSAM, HUSKEY, PHUSKEY, DWORD);
+LONG SHRegCreateUSKeyW(LPCWSTR, REGSAM, HUSKEY, PHUSKEY, DWORD);
+LONG SHRegDeleteEmptyUSKeyA(HUSKEY, LPCSTR, SHREGDEL_FLAGS);
+LONG SHRegDeleteEmptyUSKeyW(HUSKEY, LPCWSTR, SHREGDEL_FLAGS);
+LONG SHRegDeleteUSValueA(HUSKEY, LPCSTR, SHREGDEL_FLAGS);
+LONG SHRegDeleteUSValueW(HUSKEY, LPCWSTR, SHREGDEL_FLAGS);
+HKEY SHRegDuplicateHKey(HKEY);
+DWORD SHRegEnumUSKeyA(HUSKEY, DWORD, LPSTR, LPDWORD, SHREGENUM_FLAGS);
+DWORD SHRegEnumUSKeyW(HUSKEY, DWORD, LPWSTR, LPDWORD, SHREGENUM_FLAGS);
+DWORD SHRegEnumUSValueA(HUSKEY, DWORD, LPSTR, LPDWORD, LPDWORD, LPVOID, LPDWORD, SHREGENUM_FLAGS);
+DWORD SHRegEnumUSValueW(HUSKEY, DWORD, LPWSTR, LPDWORD, LPDWORD, LPVOID, LPDWORD, SHREGENUM_FLAGS);
+BOOL SHRegGetBoolUSValueA(LPCSTR, LPCSTR, BOOL, BOOL);
+BOOL SHRegGetBoolUSValueW(LPCWSTR, LPCWSTR, BOOL, BOOL);
+DWORD SHRegGetPathA(HKEY, LPCSTR, LPCSTR, LPSTR, DWORD);
+DWORD SHRegGetPathW(HKEY, LPCWSTR, LPCWSTR, LPWSTR, DWORD);
+LONG SHRegGetUSValueA(LPCSTR, LPCSTR, LPDWORD, LPVOID, LPDWORD, BOOL, LPVOID, DWORD);
+LONG SHRegGetUSValueW(LPCWSTR, LPCWSTR, LPDWORD, LPVOID, LPDWORD, BOOL, LPVOID, DWORD);
+LONG SHRegOpenUSKeyA(LPCSTR, REGSAM, HUSKEY, PHUSKEY, BOOL);
+LONG SHRegOpenUSKeyW(LPCWSTR, REGSAM, HUSKEY, PHUSKEY, BOOL);
+DWORD SHRegQueryInfoUSKeyA(HUSKEY, LPDWORD, LPDWORD, LPDWORD, LPDWORD, SHREGENUM_FLAGS);
+DWORD SHRegQueryInfoUSKeyW(HUSKEY, LPDWORD, LPDWORD, LPDWORD, LPDWORD, SHREGENUM_FLAGS);
+LONG SHRegQueryUSValueA(HUSKEY, LPCSTR, LPDWORD, LPVOID, LPDWORD, BOOL, LPVOID, DWORD);
+LONG SHRegQueryUSValueW(HUSKEY, LPCWSTR, LPDWORD, LPVOID, LPDWORD, BOOL, LPVOID, DWORD);
+DWORD SHRegSetPathA(HKEY, LPCSTR, LPCSTR, LPCSTR, DWORD);
+DWORD SHRegSetPathW(HKEY, LPCWSTR, LPCWSTR, LPCWSTR, DWORD);
+LONG SHRegSetUSValueA(LPCSTR, LPCSTR, DWORD, LPVOID, DWORD, DWORD);
+LONG SHRegSetUSValueW(LPCWSTR, LPCWSTR, DWORD, LPVOID, DWORD, DWORD);
+LONG SHRegWriteUSValueA(HUSKEY, LPCSTR, DWORD, LPVOID, DWORD, DWORD);
+LONG SHRegWriteUSValueW(HUSKEY, LPCWSTR, DWORD, LPVOID, DWORD, DWORD);
+HRESULT HashData(LPBYTE, DWORD, LPBYTE, DWORD);
+HPALETTE SHCreateShellPalette(HDC);
+COLORREF ColorHLSToRGB(WORD, WORD, WORD);
+COLORREF ColorAdjustLuma(COLORREF, int, BOOL);
+void ColorRGBToHLS(COLORREF, WORD*, WORD*, WORD*);
+/** Should not be necessary for D?
+extern (C):
+int  wnsprintfA(LPSTR, int, LPCSTR, ...);
+int  wnsprintfW(LPWSTR, int, LPCWSTR, ...);
+extern (Windows):
+int wvnsprintfA(LPSTR, int, LPCSTR, va_list);
+int wvnsprintfW(LPWSTR, int, LPCWSTR, va_list);
+*/
+
+HINSTANCE MLLoadLibraryA(LPCSTR, HANDLE, DWORD, LPCSTR, BOOL);
+HINSTANCE MLLoadLibraryW(LPCWSTR, HANDLE, DWORD, LPCWSTR, BOOL);
+
+HRESULT DllInstall(BOOL, LPCWSTR);
+
+HRESULT StrRetToBufA(LPSTRRET, LPCITEMIDLIST, LPSTR, UINT);
+HRESULT StrRetToBufW(LPSTRRET, LPCITEMIDLIST, LPWSTR, UINT);
+HRESULT StrRetToStrA(LPSTRRET, LPCITEMIDLIST, LPSTR*);
+HRESULT StrRetToStrW(LPSTRRET, LPCITEMIDLIST, LPWSTR*);
+HRESULT SHCreateStreamOnFileA(LPCSTR, DWORD, IStream*);
+HRESULT SHCreateStreamOnFileW(LPCWSTR, DWORD, IStream*);
+IStream SHOpenRegStream2A(HKEY, LPCSTR, LPCSTR, DWORD);
+IStream SHOpenRegStream2W(HKEY, LPCWSTR, LPCWSTR, DWORD);
+IStream SHOpenRegStreamA(HKEY, LPCSTR, LPCSTR, DWORD);
+IStream SHOpenRegStreamW(HKEY, LPCWSTR, LPCWSTR, DWORD);
+
+version(Unicode) {
+alias ChrCmpIW ChrCmpI;
+alias IntlStrEqNW IntlStrEqN;
+alias IntlStrEqNIW IntlStrEqNI;
+alias IntlStrEqWorkerW IntlStrEqWorker;
+alias SHStrDupW SHStrDup;
+alias StrCatW StrCat;
+alias StrCatBuffW StrCatBuff;
+alias StrChrW StrChr;
+alias StrChrIW StrChrI;
+alias StrCmpW StrCmp;
+alias StrCmpIW StrCmpI;
+alias StrCmpNIW StrCmpNI;
+alias StrCmpNW StrCmpN;
+alias StrCpyNW StrCpyN;
+alias StrCpyW StrCpy;
+alias StrCSpnIW StrCSpnI;
+alias StrCSpnW StrCSpn;
+alias StrDupW StrDup;
+alias StrFormatByteSizeW StrFormatByteSize;
+alias StrFormatKBSizeW StrFormatKBSize;
+alias StrFromTimeIntervalW StrFromTimeInterval;
+alias StrIsIntlEqualW StrIsIntlEqual;
+alias StrNCatW StrNCat;
+alias StrPBrkW StrPBrk;
+alias StrRChrW StrRChr;
+alias StrRChrIW StrRChrI;
+alias StrRetToBufW StrRetToBuf;
+alias StrRetToStrW StrRetToStr;
+alias StrRStrIW StrRStrI;
+alias StrSpnW StrSpn;
+alias StrStrIW StrStrI;
+alias StrStrW StrStr;
+alias StrToIntW StrToInt;
+alias StrToIntExW StrToIntEx;
+alias StrTrimW StrTrim;
+alias PathAddBackslashW PathAddBackslash;
+alias PathAddExtensionW PathAddExtension;
+alias PathAppendW PathAppend;
+alias PathBuildRootW PathBuildRoot;
+alias PathCanonicalizeW PathCanonicalize;
+alias PathCombineW PathCombine;
+alias PathCommonPrefixW PathCommonPrefix;
+alias PathCompactPathW PathCompactPath;
+alias PathCompactPathExW PathCompactPathEx;
+alias PathCreateFromUrlW PathCreateFromUrl;
+alias PathFileExistsW PathFileExists;
+alias PathFindExtensionW PathFindExtension;
+alias PathFindFileNameW PathFindFileName;
+alias PathFindNextComponentW PathFindNextComponent;
+alias PathFindOnPathW PathFindOnPath;
+alias PathFindSuffixArrayW PathFindSuffixArray;
+alias PathGetArgsW PathGetArgs;
+alias PathGetCharTypeW PathGetCharType;
+alias PathGetDriveNumberW PathGetDriveNumber;
+alias PathIsContentTypeW PathIsContentType;
+alias PathIsDirectoryEmptyW PathIsDirectoryEmpty;
+alias PathIsDirectoryW PathIsDirectory;
+alias PathIsFileSpecW PathIsFileSpec;
+alias PathIsLFNFileSpecW PathIsLFNFileSpec;
+alias PathIsNetworkPathW PathIsNetworkPath;
+alias PathIsPrefixW PathIsPrefix;
+alias PathIsRelativeW PathIsRelative;
+alias PathIsRootW PathIsRoot;
+alias PathIsSameRootW PathIsSameRoot;
+alias PathIsSystemFolderW PathIsSystemFolder;
+alias PathIsUNCServerShareW PathIsUNCServerShare;
+alias PathIsUNCServerW PathIsUNCServer;
+alias PathIsUNCW PathIsUNC;
+alias PathIsURLW PathIsURL;
+alias PathMakePrettyW PathMakePretty;
+alias PathMakeSystemFolderW PathMakeSystemFolder;
+alias PathMatchSpecW PathMatchSpec;
+alias PathParseIconLocationW PathParseIconLocation;
+alias PathQuoteSpacesW PathQuoteSpaces;
+alias PathRelativePathToW PathRelativePathTo;
+alias PathRemoveArgsW PathRemoveArgs;
+alias PathRemoveBackslashW PathRemoveBackslash;
+alias PathRemoveBlanksW PathRemoveBlanks;
+alias PathRemoveExtensionW PathRemoveExtension;
+alias PathRemoveFileSpecW PathRemoveFileSpec;
+alias PathRenameExtensionW PathRenameExtension;
+alias PathSearchAndQualifyW PathSearchAndQualify;
+alias PathSetDlgItemPathW PathSetDlgItemPath;
+alias PathSkipRootW PathSkipRoot;
+alias PathStripPathW PathStripPath;
+alias PathStripToRootW PathStripToRoot;
+alias PathUndecorateW PathUndecorate;
+alias PathUnExpandEnvStringsW PathUnExpandEnvStrings;
+alias PathUnmakeSystemFolderW PathUnmakeSystemFolder;
+alias PathUnquoteSpacesW PathUnquoteSpaces;
+alias SHCreateStreamOnFileW SHCreateStreamOnFile;
+alias SHOpenRegStreamW SHOpenRegStream;
+alias SHOpenRegStream2W SHOpenRegStream2;
+alias SHCopyKeyW SHCopyKey;
+alias SHDeleteEmptyKeyW SHDeleteEmptyKey;
+alias SHDeleteKeyW SHDeleteKey;
+alias SHEnumKeyExW SHEnumKeyEx;
+alias SHQueryInfoKeyW SHQueryInfoKey;
+alias SHQueryValueExW SHQueryValueEx;
+alias SHEnumValueW SHEnumValue;
+alias SHGetValueW SHGetValue;
+alias SHSetValueW SHSetValue;
+alias SHDeleteValueW SHDeleteValue;
+alias AssocQueryKeyW AssocQueryKey;
+alias AssocQueryStringByKeyW AssocQueryStringByKey;
+alias AssocQueryStringW AssocQueryString;
+alias UrlApplySchemeW UrlApplyScheme;
+alias UrlCanonicalizeW UrlCanonicalize;
+alias UrlCombineW UrlCombine;
+alias UrlCompareW UrlCompare;
+alias UrlCreateFromPathW UrlCreateFromPath;
+alias UrlEscapeW UrlEscape;
+alias UrlGetLocationW UrlGetLocation;
+alias UrlGetPartW UrlGetPart;
+alias UrlHashW UrlHash;
+alias UrlIsW UrlIs;
+alias UrlIsFileUrlW UrlIsFileUrl;
+alias UrlIsNoHistoryW UrlIsNoHistory;
+alias UrlIsOpaqueW UrlIsOpaque;
+alias UrlUnescapeW UrlUnescape;
+alias UrlUnescapeInPlaceW UrlUnescapeInPlace;
+alias SHRegCreateUSKeyW SHRegCreateUSKey;
+alias SHRegDeleteEmptyUSKeyW SHRegDeleteEmptyUSKey;
+alias SHRegDeleteUSValueW SHRegDeleteUSValue;
+alias SHRegEnumUSKeyW SHRegEnumUSKey;
+alias SHRegEnumUSValueW SHRegEnumUSValue;
+alias SHRegGetBoolUSValueW SHRegGetBoolUSValue;
+alias SHRegGetPathW SHRegGetPath;
+alias SHRegGetUSValueW SHRegGetUSValue;
+alias SHRegOpenUSKeyW SHRegOpenUSKey;
+alias SHRegQueryInfoUSKeyW SHRegQueryInfoUSKey;
+alias SHRegQueryUSValueW SHRegQueryUSValue;
+alias SHRegSetPathW SHRegSetPath;
+alias SHRegSetUSValueW SHRegSetUSValue;
+alias SHRegWriteUSValueW SHRegWriteUSValue;
+//alias wnsprintfW wnsprintf;
+//alias wvnsprintfW wvnsprintf;
+} else {
+alias ChrCmpIA ChrCmpI;
+alias IntlStrEqNA IntlStrEqN;
+alias IntlStrEqNIA IntlStrEqNI;
+alias IntlStrEqWorkerA IntlStrEqWorker;
+alias SHStrDupA SHStrDup;
+alias StrCatBuffA StrCatBuff;
+alias StrChrA StrChr;
+alias StrChrIA StrChrI;
+alias StrCmpNIA StrCmpNI;
+alias StrCmpNA StrCmpN;
+alias StrCSpnIA StrCSpnI;
+alias StrCSpnA StrCSpn;
+alias StrDupA StrDup;
+alias StrFormatByteSizeA StrFormatByteSize;
+alias StrFormatKBSizeA StrFormatKBSize;
+alias StrFromTimeIntervalA StrFromTimeInterval;
+alias StrIsIntlEqualA StrIsIntlEqual;
+alias StrNCatA StrNCat;
+alias StrPBrkA StrPBrk;
+alias StrRChrA StrRChr;
+alias StrRChrIA StrRChrI;
+alias StrRetToBufA StrRetToBuf;
+alias StrRetToStrA StrRetToStr;
+alias StrRStrIA StrRStrI;
+alias StrSpnA StrSpn;
+alias StrStrIA StrStrI;
+alias StrStrA StrStr;
+alias StrToIntA StrToInt;
+alias StrToIntExA StrToIntEx;
+alias StrTrimA StrTrim;
+alias PathAddBackslashA PathAddBackslash;
+alias PathAddExtensionA PathAddExtension;
+alias PathAppendA PathAppend;
+alias PathBuildRootA PathBuildRoot;
+alias PathCanonicalizeA PathCanonicalize;
+alias PathCombineA PathCombine;
+alias PathCommonPrefixA PathCommonPrefix;
+alias PathCompactPathA PathCompactPath;
+alias PathCompactPathExA PathCompactPathEx;
+alias PathCreateFromUrlA PathCreateFromUrl;
+alias PathFileExistsA PathFileExists;
+alias PathFindExtensionA PathFindExtension;
+alias PathFindFileNameA PathFindFileName;
+alias PathFindNextComponentA PathFindNextComponent;
+alias PathFindOnPathA PathFindOnPath;
+alias PathFindSuffixArrayA PathFindSuffixArray;
+alias PathGetArgsA PathGetArgs;
+alias PathGetCharTypeA PathGetCharType;
+alias PathGetDriveNumberA PathGetDriveNumber;
+alias PathIsContentTypeA PathIsContentType;
+alias PathIsDirectoryEmptyA PathIsDirectoryEmpty;
+alias PathIsDirectoryA PathIsDirectory;
+alias PathIsFileSpecA PathIsFileSpec;
+alias PathIsLFNFileSpecA PathIsLFNFileSpec;
+alias PathIsNetworkPathA PathIsNetworkPath;
+alias PathIsPrefixA PathIsPrefix;
+alias PathIsRelativeA PathIsRelative;
+alias PathIsRootA PathIsRoot;
+alias PathIsSameRootA PathIsSameRoot;
+alias PathIsSystemFolderA PathIsSystemFolder;
+alias PathIsUNCServerShareA PathIsUNCServerShare;
+alias PathIsUNCServerA PathIsUNCServer;
+alias PathIsUNCA PathIsUNC;
+alias PathIsURLA PathIsURL;
+alias PathMakePrettyA PathMakePretty;
+alias PathMakeSystemFolderA PathMakeSystemFolder;
+alias PathMatchSpecA PathMatchSpec;
+alias PathParseIconLocationA PathParseIconLocation;
+alias PathQuoteSpacesA PathQuoteSpaces;
+alias PathRelativePathToA PathRelativePathTo;
+alias PathRemoveArgsA PathRemoveArgs;
+alias PathRemoveBackslashA PathRemoveBackslash;
+alias PathRemoveBlanksA PathRemoveBlanks;
+alias PathRemoveExtensionA PathRemoveExtension;
+alias PathRemoveFileSpecA PathRemoveFileSpec;
+alias PathRenameExtensionA PathRenameExtension;
+alias PathSearchAndQualifyA PathSearchAndQualify;
+alias PathSetDlgItemPathA PathSetDlgItemPath;
+alias PathSkipRootA PathSkipRoot;
+alias PathStripPathA PathStripPath;
+alias PathStripToRootA PathStripToRoot;
+alias PathUndecorateA PathUndecorate;
+alias PathUnExpandEnvStringsA PathUnExpandEnvStrings;
+alias PathUnmakeSystemFolderA PathUnmakeSystemFolder;
+alias PathUnquoteSpacesA PathUnquoteSpaces;
+alias SHCreateStreamOnFileA SHCreateStreamOnFile;
+alias SHOpenRegStreamA SHOpenRegStream;
+alias SHOpenRegStream2A SHOpenRegStream2;
+alias SHCopyKeyA SHCopyKey;
+alias SHDeleteEmptyKeyA SHDeleteEmptyKey;
+alias SHDeleteKeyA SHDeleteKey;
+alias SHEnumKeyExA SHEnumKeyEx;
+alias SHQueryInfoKeyA SHQueryInfoKey;
+alias SHQueryValueExA SHQueryValueEx;
+alias SHEnumValueA SHEnumValue;
+alias SHGetValueA SHGetValue;
+alias SHSetValueA SHSetValue;
+alias SHDeleteValueA SHDeleteValue;
+alias AssocQueryKeyA AssocQueryKey;
+alias AssocQueryStringByKeyA AssocQueryStringByKey;
+alias AssocQueryStringA AssocQueryString;
+alias UrlApplySchemeA UrlApplyScheme;
+alias UrlCanonicalizeA UrlCanonicalize;
+alias UrlCombineA UrlCombine;
+alias UrlCompareA UrlCompare;
+alias UrlCreateFromPathA UrlCreateFromPath;
+alias UrlEscapeA UrlEscape;
+alias UrlGetLocationA UrlGetLocation;
+alias UrlGetPartA UrlGetPart;
+alias UrlHashA UrlHash;
+alias UrlIsA UrlIs;
+alias UrlIsNoHistoryA UrlIsNoHistory;
+alias UrlIsOpaqueA UrlIsOpaque;
+alias UrlUnescapeA UrlUnescape;
+alias UrlUnescapeInPlaceA UrlUnescapeInPlace;
+alias SHRegCreateUSKeyA SHRegCreateUSKey;
+alias SHRegDeleteEmptyUSKeyA SHRegDeleteEmptyUSKey;
+alias SHRegDeleteUSValueA SHRegDeleteUSValue;
+alias SHRegEnumUSKeyA SHRegEnumUSKey;
+alias SHRegEnumUSValueA SHRegEnumUSValue;
+alias SHRegGetBoolUSValueA SHRegGetBoolUSValue;
+alias SHRegGetPathA SHRegGetPath;
+alias SHRegGetUSValueA SHRegGetUSValue;
+alias SHRegOpenUSKeyA SHRegOpenUSKey;
+alias SHRegQueryInfoUSKeyA SHRegQueryInfoUSKey;
+alias SHRegQueryUSValueA SHRegQueryUSValue;
+alias SHRegSetPathA SHRegSetPath;
+alias SHRegSetUSValueA SHRegSetUSValue;
+alias SHRegWriteUSValueA SHRegWriteUSValue;
+//alias wnsprintfA wnsprintf;
+//alias wvnsprintfA wvnsprintf;
+}
+
+alias StrToInt StrToLong;
diff --git a/libphobos/libdruntime/core/sys/windows/snmp.d b/libphobos/libdruntime/core/sys/windows/snmp.d
new file mode 100644
index 00000000000..ae0fa159116
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/snmp.d
@@ -0,0 +1,269 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_snmp.d)
+ */
+module core.sys.windows.snmp;
+version (Windows):
+
+private import core.sys.windows.windows;
+
+// These are not documented on MSDN
+enum {
+    DEFAULT_SNMP_PORT_UDP     =   161,
+    DEFAULT_SNMP_PORT_IPX     = 36879,
+    DEFAULT_SNMPTRAP_PORT_UDP =   162,
+    DEFAULT_SNMPTRAP_PORT_IPX = 36880
+}
+
+enum : BYTE {
+    ASN_UNIVERSAL                 = 0x00,
+    ASN_PRIMITIVE                 = 0x00,
+    ASN_CONSTRUCTOR               = 0x20,
+    ASN_APPLICATION               = 0x40,
+    ASN_CONTEXT                   = 0x80,
+    ASN_PRIVATE                   = 0xC0,
+
+    SNMP_PDU_GET                  = ASN_CONTEXT | ASN_CONSTRUCTOR,
+    SNMP_PDU_GETNEXT,
+    SNMP_PDU_RESPONSE,
+    SNMP_PDU_SET,
+    SNMP_PDU_GETBULK,          // = ASN_CONTEXT | ASN_CONSTRUCTOR | 4
+    SNMP_PDU_V1TRAP               = ASN_CONTEXT | ASN_CONSTRUCTOR | 4,
+    SNMP_PDU_INFORM               = ASN_CONTEXT | ASN_CONSTRUCTOR | 6,
+    SNMP_PDU_TRAP,
+    SNMP_PDU_REPORT,
+    ASN_INTEGER                   = ASN_UNIVERSAL | ASN_PRIMITIVE | 2,
+    ASN_BITS,
+    ASN_OCTETSTRING,
+    ASN_NULL,
+    ASN_OBJECTIDENTIFIER,      // = ASN_UNIVERSAL | ASN_PRIMITIVE | 6
+    ASN_INTEGER32                 = ASN_INTEGER,
+    ASN_SEQUENCE                  = ASN_UNIVERSAL | ASN_CONSTRUCTOR | 0x10,
+    ASN_SEQUENCEOF                = ASN_SEQUENCE,
+    ASN_IPADDRESS                 = ASN_APPLICATION | ASN_PRIMITIVE,
+    ASN_COUNTER32,
+    ASN_GAUGE32,
+    ASN_TIMETICKS,
+    ASN_OPAQUE,                // = ASN_APPLICATION | ASN_PRIMITIVE | 4
+    ASN_COUNTER64                 = ASN_APPLICATION | ASN_PRIMITIVE | 6,
+    ASN_UNSIGNED32,            // = ASN_APPLICATION | ASN_PRIMITIVE | 7
+    SNMP_EXCEPTION_NOSUCHOBJECT   = ASN_CONTEXT | ASN_PRIMITIVE,
+    SNMP_EXCEPTION_NOSUCHINSTANCE,
+    SNMP_EXCEPTION_ENDOFMIBVIEW,
+    SNMP_EXTENSION_GET            = SNMP_PDU_GET,
+    SNMP_EXTENSION_GET_NEXT       = SNMP_PDU_GETNEXT,
+    SNMP_EXTENSION_GET_BULK       = SNMP_PDU_GETBULK,
+    SNMP_EXTENSION_SET_TEST       = ASN_PRIVATE | ASN_CONSTRUCTOR,
+    SNMP_EXTENSION_SET_COMMIT     = SNMP_PDU_SET,
+    SNMP_EXTENSION_SET_UNDO       = ASN_PRIVATE | ASN_CONSTRUCTOR | 1,
+    SNMP_EXTENSION_SET_CLEANUP
+}
+
+
+enum : AsnInteger {
+    SNMP_ERRORSTATUS_NOERROR,
+    SNMP_ERRORSTATUS_TOOBIG,
+    SNMP_ERRORSTATUS_NOSUCHNAME,
+    SNMP_ERRORSTATUS_BADVALUE,
+    SNMP_ERRORSTATUS_READONLY,
+    SNMP_ERRORSTATUS_GENERR,
+    SNMP_ERRORSTATUS_NOACCESS,
+    SNMP_ERRORSTATUS_WRONGTYPE,
+    SNMP_ERRORSTATUS_WRONGLENGTH,
+    SNMP_ERRORSTATUS_WRONGENCODING,
+    SNMP_ERRORSTATUS_WRONGVALUE,
+    SNMP_ERRORSTATUS_NOCREATION,
+    SNMP_ERRORSTATUS_INCONSISTENTVALUE,
+    SNMP_ERRORSTATUS_RESOURCEUNAVAILABLE,
+    SNMP_ERRORSTATUS_COMMITFAILED,
+    SNMP_ERRORSTATUS_UNDOFAILED,
+    SNMP_ERRORSTATUS_AUTHORIZATIONERROR,
+    SNMP_ERRORSTATUS_NOTWRITABLE,
+    SNMP_ERRORSTATUS_INCONSISTENTNAME
+}
+
+enum : AsnInteger {
+    SNMP_GENERICTRAP_COLDSTART,
+    SNMP_GENERICTRAP_WARMSTART,
+    SNMP_GENERICTRAP_LINKDOWN,
+    SNMP_GENERICTRAP_LINKUP,
+    SNMP_GENERICTRAP_AUTHFAILURE,
+    SNMP_GENERICTRAP_EGPNEIGHLOSS,
+    SNMP_GENERICTRAP_ENTERSPECIFIC
+}
+
+// These are not documented on MSDN
+enum {
+    SNMP_ACCESS_NONE,
+    SNMP_ACCESS_NOTIFY,
+    SNMP_ACCESS_READ_ONLY,
+    SNMP_ACCESS_READ_WRITE,
+    SNMP_ACCESS_READ_CREATE
+}
+
+enum : BOOL {
+    SNMPAPI_ERROR   = false,
+    SNMPAPI_NOERROR = true
+}
+
+enum : INT {
+    SNMP_LOG_SILENT,
+    SNMP_LOG_FATAL,
+    SNMP_LOG_ERROR,
+    SNMP_LOG_WARNING,
+    SNMP_LOG_TRACE,
+    SNMP_LOG_VERBOSE
+}
+
+enum INT
+    SNMP_OUTPUT_TO_CONSOLE  = 1,
+    SNMP_OUTPUT_TO_LOGFILE  = 2,
+    SNMP_OUTPUT_TO_EVENTLOG = 4,
+    SNMP_OUTPUT_TO_DEBUGGER = 8;
+
+enum size_t SNMP_MAX_OID_LEN = 128;
+
+enum : DWORD {
+    SNMP_MEM_ALLOC_ERROR          =  1,
+    SNMP_BERAPI_INVALID_LENGTH    = 10,
+    SNMP_BERAPI_INVALID_TAG,
+    SNMP_BERAPI_OVERFLOW,
+    SNMP_BERAPI_SHORT_BUFFER,
+    SNMP_BERAPI_INVALID_OBJELEM,
+    SNMP_PDUAPI_UNRECOGNIZED_PDU  = 20,
+    SNMP_PDUAPI_INVALID_ES,
+    SNMP_PDUAPI_INVALID_GT,
+    SNMP_AUTHAPI_INVALID_VERSION  = 30,
+    SNMP_AUTHAPI_INVALID_MSG_TYPE,
+    SNMP_AUTHAPI_TRIV_AUTH_FAILED,
+}
+
+alias INT SNMPAPI;
+alias LONG AsnInteger32;
+alias ULONG AsnUnsigned32, AsnCounter32, AsnGauge32, AsnTimeticks;
+alias ULARGE_INTEGER AsnCounter64;
+
+align (4):
+
+struct AsnOctetString {
+    BYTE* stream;
+    UINT  length;
+    BOOL  dynamic;
+}
+alias AsnOctetString AsnBits, AsnSequence, AsnImplicitSequence,
+  AsnIPAddress, AsnNetworkAddress, AsnDisplayString, AsnOpaque;
+
+struct AsnObjectIdentifier {
+    UINT  idLength;
+    UINT* ids;
+}
+alias AsnObjectIdentifier AsnObjectName;
+
+struct AsnAny {
+    BYTE      asnType;
+    union _asnValue {
+        AsnInteger32        number;
+        AsnUnsigned32       unsigned32;
+        AsnCounter64        counter64;
+        AsnOctetString      string;
+        AsnBits             bits;
+        AsnObjectIdentifier object;
+        AsnSequence         sequence;
+        AsnIPAddress        address;
+        AsnCounter32        counter;
+        AsnGauge32          gauge;
+        AsnTimeticks        ticks;
+        AsnOpaque           arbitrary;
+    }
+    _asnValue asnValue;
+}
+alias AsnAny AsnObjectSyntax;
+
+struct SnmpVarBind {
+    AsnObjectName   name;
+    AsnObjectSyntax value;
+}
+
+struct SnmpVarBindList {
+    SnmpVarBind* list;
+    UINT         len;
+}
+
+extern (Windows) {
+    VOID SnmpExtensionClose();
+    BOOL SnmpExtensionInit(DWORD, HANDLE*, AsnObjectIdentifier*);
+    BOOL SnmpExtensionInitEx(AsnObjectIdentifier*);
+    BOOL SnmpExtensionMonitor(LPVOID);
+    BOOL SnmpExtensionQuery(BYTE, SnmpVarBindList*, AsnInteger32*,
+      AsnInteger32*);
+    BOOL SnmpExtensionQueryEx(DWORD, DWORD, SnmpVarBindList*, AsnOctetString*,
+      AsnInteger32*, AsnInteger32*);
+    BOOL SnmpExtensionTrap(AsnObjectIdentifier*, AsnInteger32*, AsnInteger32*,
+      AsnTimeticks*, SnmpVarBindList*);
+    DWORD SnmpSvcGetUptime();
+    VOID SnmpSvcSetLogLevel(INT);
+    VOID SnmpSvcSetLogType(INT);
+    SNMPAPI SnmpUtilAsnAnyCpy(AsnAny*, AsnAny*);
+    VOID SnmpUtilAsnAnyFree(AsnAny*);
+    VOID SnmpUtilDbgPrint(INT, LPSTR, ...);
+    LPSTR SnmpUtilIdsToA(UINT*, UINT);
+    LPVOID SnmpUtilMemAlloc(UINT);
+    VOID SnmpUtilMemFree(LPVOID);
+    LPVOID SnmpUtilMemReAlloc(LPVOID, UINT);
+    SNMPAPI SnmpUtilOctetsCmp(AsnOctetString*, AsnOctetString*);
+    SNMPAPI SnmpUtilOctetsCpy(AsnOctetString*, AsnOctetString*);
+    VOID SnmpUtilOctetsFree(AsnOctetString*);
+    SNMPAPI SnmpUtilOctetsNCmp(AsnOctetString*, AsnOctetString*, UINT);
+    SNMPAPI SnmpUtilOidAppend(AsnObjectIdentifier*, AsnObjectIdentifier*);
+    SNMPAPI SnmpUtilOidCmp(AsnObjectIdentifier*, AsnObjectIdentifier*);
+    SNMPAPI SnmpUtilOidCpy(AsnObjectIdentifier*, AsnObjectIdentifier*);
+    VOID SnmpUtilOidFree(AsnObjectIdentifier*);
+    SNMPAPI SnmpUtilOidNCmp(AsnObjectIdentifier*, AsnObjectIdentifier*, UINT);
+    LPSTR SnmpUtilOidToA(AsnObjectIdentifier*);
+    VOID SnmpUtilPrintAsnAny(AsnAny*);
+    VOID SnmpUtilPrintOid(AsnObjectIdentifier*);
+    SNMPAPI SnmpUtilVarBindCpy(SnmpVarBind*, SnmpVarBind*);
+    SNMPAPI SnmpUtilVarBindListCpy(SnmpVarBindList*, SnmpVarBindList*);
+    VOID SnmpUtilVarBindFree(SnmpVarBind*);
+    VOID SnmpUtilVarBindListFree(SnmpVarBindList*);
+}
+
+alias SnmpUtilMemAlloc SNMP_malloc;
+alias SnmpUtilMemFree SNMP_free;
+alias SnmpUtilMemReAlloc SNMP_realloc;
+alias SnmpUtilMemAlloc SNMP_DBG_malloc;
+alias SnmpUtilMemFree SNMP_DBG_free;
+alias SnmpUtilMemReAlloc SNMP_DBG_realloc;
+alias SnmpUtilOidAppend SNMP_oidappend;
+alias SnmpUtilOidCmp SNMP_oidcmp;
+alias SnmpUtilOidCpy SNMP_oidcpy;
+alias SnmpUtilOidFree SNMP_oidfree;
+alias SnmpUtilOidNCmp SNMP_oidncmp;
+alias SnmpUtilPrintAsnAny SNMP_printany;
+alias SnmpUtilVarBindCpy SNMP_CopyVarBind;
+alias SnmpUtilVarBindListCpy SNMP_CopyVarBindList;
+alias SnmpUtilVarBindFree SNMP_FreeVarBind;
+alias SnmpUtilVarBindListFree SNMP_FreeVarBindList;
+alias ASN_IPADDRESS ASN_RFC1155_IPADDRESS;
+alias ASN_COUNTER32 ASN_RFC1155_COUNTER;
+alias ASN_GAUGE32 ASN_RFC1155_GAUGE;
+alias ASN_TIMETICKS ASN_RFC1155_TIMETICKS;
+alias ASN_OPAQUE ASN_RFC1155_OPAQUE;
+alias ASN_OCTETSTRING ASN_RFC1213_DISPSTRING;
+alias SNMP_PDU_GET ASN_RFC1157_GETREQUEST;
+alias SNMP_PDU_GETNEXT ASN_RFC1157_GETNEXTREQUEST;
+alias SNMP_PDU_RESPONSE ASN_RFC1157_GETRESPONSE;
+alias SNMP_PDU_SET ASN_RFC1157_SETREQUEST;
+alias SNMP_PDU_V1TRAP ASN_RFC1157_TRAP;
+alias ASN_CONTEXT ASN_CONTEXTSPECIFIC;
+alias ASN_PRIMITIVE ASN_PRIMATIVE;
+alias SnmpVarBindList RFC1157VarBindList;
+alias SnmpVarBind RFC1157VarBind;
+alias AsnInteger32 AsnInteger;
+alias AsnCounter32 AsnCounter;
+alias AsnGauge32 AsnGauge;
diff --git a/libphobos/libdruntime/core/sys/windows/sql.d b/libphobos/libdruntime/core/sys/windows/sql.d
new file mode 100644
index 00000000000..4eb2cfb514e
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/sql.d
@@ -0,0 +1,434 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_sql.d)
+ */
+module core.sys.windows.sql;
+version (Windows):
+
+public import core.sys.windows.sqltypes;
+private import core.sys.windows.windef;
+
+enum ODBCVER = 0x0351;
+
+enum SQL_ACCESSIBLE_PROCEDURES=20;
+enum SQL_ACCESSIBLE_TABLES=19;
+enum SQL_ALL_TYPES=0;
+enum SQL_ALTER_TABLE=86;
+enum SQL_API_SQLALLOCCONNECT=1;
+enum SQL_API_SQLALLOCENV=2;
+enum SQL_API_SQLALLOCSTMT=3;
+enum SQL_API_SQLBINDCOL=4;
+enum SQL_API_SQLCANCEL=5;
+enum SQL_API_SQLCOLUMNS=40;
+enum SQL_API_SQLCONNECT=7;
+enum SQL_API_SQLDATASOURCES=57;
+enum SQL_API_SQLDESCRIBECOL=8;
+enum SQL_API_SQLDISCONNECT=9;
+enum SQL_API_SQLERROR=10;
+enum SQL_API_SQLEXECDIRECT=11;
+enum SQL_API_SQLEXECUTE=12;
+enum SQL_API_SQLFETCH=13;
+enum SQL_API_SQLFREECONNECT=14;
+enum SQL_API_SQLFREEENV=15;
+enum SQL_API_SQLFREESTMT=16;
+enum SQL_API_SQLGETCONNECTOPTION=42;
+enum SQL_API_SQLGETCURSORNAME=17;
+enum SQL_API_SQLGETDATA=43;
+enum SQL_API_SQLGETFUNCTIONS=44;
+enum SQL_API_SQLGETINFO=45;
+enum SQL_API_SQLGETSTMTOPTION=46;
+enum SQL_API_SQLGETTYPEINFO=47;
+enum SQL_API_SQLNUMRESULTCOLS=18;
+enum SQL_API_SQLPARAMDATA=48;
+enum SQL_API_SQLPREPARE=19;
+enum SQL_API_SQLPUTDATA=49;
+enum SQL_API_SQLROWCOUNT=20;
+enum SQL_API_SQLSETCONNECTOPTION=50;
+enum SQL_API_SQLSETCURSORNAME=21;
+enum SQL_API_SQLSETPARAM=22;
+enum SQL_API_SQLSETSTMTOPTION=51;
+enum SQL_API_SQLSPECIALCOLUMNS=52;
+enum SQL_API_SQLSTATISTICS=53;
+enum SQL_API_SQLTABLES=54;
+enum SQL_API_SQLTRANSACT=23;
+
+enum SQL_CB_DELETE=0;
+enum SQL_CB_CLOSE=1;
+enum SQL_CB_PRESERVE=2;
+
+enum SQL_CHAR=1;
+enum SQL_CLOSE=0;
+enum SQL_COMMIT=0;
+enum SQL_CURSOR_COMMIT_BEHAVIOR=23;
+enum SQL_DATA_AT_EXEC=-2;
+enum SQL_DATA_SOURCE_NAME=2;
+enum SQL_DATA_SOURCE_READ_ONLY=25;
+enum SQL_DBMS_NAME=17;
+enum SQL_DBMS_VER=18;
+enum SQL_DECIMAL=3;
+enum SQL_DEFAULT_TXN_ISOLATION=26;
+enum SQL_DOUBLE=8;
+enum SQL_DROP=1;
+enum SQL_ERROR=-1;
+
+enum SQL_FD_FETCH_NEXT=1;
+enum SQL_FD_FETCH_FIRST=2;
+enum SQL_FD_FETCH_LAST=4;
+enum SQL_FD_FETCH_PRIOR=8;
+enum SQL_FD_FETCH_ABSOLUTE=16;
+enum SQL_FD_FETCH_RELATIVE=32;
+
+enum SQL_FETCH_ABSOLUTE=5;
+enum SQL_FETCH_DIRECTION=8;
+enum SQL_FETCH_FIRST=2;
+enum SQL_FETCH_LAST=3;
+enum SQL_FETCH_NEXT=1;
+enum SQL_FETCH_PRIOR=4;
+enum SQL_FETCH_RELATIVE=6;
+enum SQL_FLOAT=6;
+enum SQL_GD_ANY_COLUMN=1;
+enum SQL_GD_ANY_ORDER=2;
+enum SQL_GETDATA_EXTENSIONS=81;
+enum SQL_IC_LOWER=2;
+enum SQL_IC_MIXED=4;
+enum SQL_IC_SENSITIVE=3;
+enum SQL_IC_UPPER=1;
+enum SQL_IDENTIFIER_CASE=28;
+enum SQL_IDENTIFIER_QUOTE_CHAR=29;
+
+enum SQL_INDEX_ALL=1;
+enum SQL_INDEX_CLUSTERED=1;
+enum SQL_INDEX_HASHED=2;
+enum SQL_INDEX_OTHER=3;
+enum SQL_INDEX_UNIQUE=0;
+
+enum SQL_INTEGER=4;
+enum SQL_INTEGRITY=73;
+enum SQL_INVALID_HANDLE=-2;
+
+enum SQL_MAX_CATALOG_NAME_LEN=34;
+enum SQL_MAX_COLUMN_NAME_LEN=30;
+enum SQL_MAX_COLUMNS_IN_GROUP_BY=97;
+enum SQL_MAX_COLUMNS_IN_INDEX=98;
+enum SQL_MAX_COLUMNS_IN_ORDER_BY=99;
+enum SQL_MAX_COLUMNS_IN_SELECT=100;
+enum SQL_MAX_COLUMNS_IN_TABLE=101;
+enum SQL_MAX_CURSOR_NAME_LEN=31;
+enum SQL_MAX_INDEX_SIZE=102;
+enum SQL_MAX_MESSAGE_LENGTH=512;
+enum SQL_MAX_ROW_SIZE=104;
+enum SQL_MAX_SCHEMA_NAME_LEN=32;
+enum SQL_MAX_STATEMENT_LEN=105;
+enum SQL_MAX_TABLE_NAME_LEN=35;
+enum SQL_MAX_TABLES_IN_SELECT=106;
+enum SQL_MAX_USER_NAME_LEN=107;
+
+enum SQL_MAXIMUM_CATALOG_NAME_LENGTH=SQL_MAX_CATALOG_NAME_LEN;
+enum SQL_MAXIMUM_COLUMN_NAME_LENGTH=SQL_MAX_COLUMN_NAME_LEN;
+enum SQL_MAXIMUM_COLUMNS_IN_GROUP_BY=SQL_MAX_COLUMNS_IN_GROUP_BY;
+enum SQL_MAXIMUM_COLUMNS_IN_INDEX=SQL_MAX_COLUMNS_IN_INDEX;
+enum SQL_MAXIMUM_COLUMNS_IN_ORDER_BY=SQL_MAX_COLUMNS_IN_ORDER_BY;
+enum SQL_MAXIMUM_COLUMNS_IN_SELECT=SQL_MAX_COLUMNS_IN_SELECT;
+enum SQL_MAXIMUM_CURSOR_NAME_LENGTH=SQL_MAX_CURSOR_NAME_LEN;
+enum SQL_MAXIMUM_INDEX_SIZE=SQL_MAX_INDEX_SIZE;
+enum SQL_MAXIMUM_ROW_SIZE=SQL_MAX_ROW_SIZE;
+enum SQL_MAXIMUM_SCHEMA_NAME_LENGTH=SQL_MAX_SCHEMA_NAME_LEN;
+enum SQL_MAXIMUM_STATEMENT_LENGTH=SQL_MAX_STATEMENT_LEN;
+enum SQL_MAXIMUM_TABLES_IN_SELECT=SQL_MAX_TABLES_IN_SELECT;
+enum SQL_MAXIMUM_USER_NAME_LENGTH=SQL_MAX_USER_NAME_LEN;
+
+enum SQL_NC_HIGH=0;
+enum SQL_NC_LOW=1;
+enum SQL_NEED_DATA=99;
+enum SQL_NO_NULLS=0;
+enum SQL_NTS=-3;
+enum LONG SQL_NTSL=-3;
+enum SQL_NULL_COLLATION=85;
+enum SQL_NULL_DATA=-1;
+enum SQL_NULL_HDBC=0;
+enum SQL_NULL_HENV=0;
+enum SQL_NULL_HSTMT=0;
+enum SQL_NULLABLE=1;
+enum SQL_NULLABLE_UNKNOWN=2;
+enum SQL_NUMERIC=2;
+enum SQL_ORDER_BY_COLUMNS_IN_SELECT=90;
+enum SQL_PC_PSEUDO=2;
+enum SQL_PC_UNKNOWN=0;
+enum SQL_REAL=7;
+enum SQL_RESET_PARAMS=3;
+enum SQL_ROLLBACK=1;
+enum SQL_SCCO_LOCK=2;
+enum SQL_SCCO_OPT_ROWVER=4;
+enum SQL_SCCO_OPT_VALUES=8;
+enum SQL_SCCO_READ_ONLY=1;
+enum SQL_SCOPE_CURROW=0;
+enum SQL_SCOPE_SESSION=2;
+enum SQL_SCOPE_TRANSACTION=1;
+enum SQL_SCROLL_CONCURRENCY=43;
+enum SQL_SEARCH_PATTERN_ESCAPE=14;
+enum SQL_SERVER_NAME=13;
+enum SQL_SMALLINT=5;
+enum SQL_SPECIAL_CHARACTERS=94;
+enum SQL_STILL_EXECUTING=2;
+//MACRO #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0)
+
+enum SQL_SUCCESS=0;
+enum SQL_SUCCESS_WITH_INFO=1;
+
+enum SQL_TC_ALL=2;
+enum SQL_TC_DDL_COMMIT=3;
+enum SQL_TC_DDL_IGNORE=4;
+enum SQL_TC_DML=1;
+enum SQL_TC_NONE=0;
+
+
+enum SQL_TXN_CAPABLE=46;
+enum SQL_TXN_ISOLATION_OPTION=72;
+enum SQL_TXN_READ_COMMITTED=2;
+enum SQL_TXN_READ_UNCOMMITTED=1;
+enum SQL_TXN_REPEATABLE_READ=4;
+enum SQL_TXN_SERIALIZABLE=8;
+
+enum SQL_TRANSACTION_CAPABLE=SQL_TXN_CAPABLE;
+enum SQL_TRANSACTION_ISOLATION_OPTION=SQL_TXN_ISOLATION_OPTION;
+enum SQL_TRANSACTION_READ_COMMITTED=SQL_TXN_READ_COMMITTED;
+enum SQL_TRANSACTION_READ_UNCOMMITTED=SQL_TXN_READ_UNCOMMITTED;
+enum SQL_TRANSACTION_REPEATABLE_READ=SQL_TXN_REPEATABLE_READ;
+enum SQL_TRANSACTION_SERIALIZABLE=SQL_TXN_SERIALIZABLE;
+
+enum SQL_UNBIND=2;
+enum SQL_UNKNOWN_TYPE=0;
+enum SQL_USER_NAME=47;
+enum SQL_VARCHAR=12;
+
+static if (ODBCVER >= 0x0200) {
+enum SQL_AT_ADD_COLUMN  = 1;
+enum SQL_AT_DROP_COLUMN = 2;
+}
+
+static if (ODBCVER >= 0x0201) {
+enum SQL_OJ_LEFT               =  1;
+enum SQL_OJ_RIGHT              =  2;
+enum SQL_OJ_FULL               =  4;
+enum SQL_OJ_NESTED             =  8;
+enum SQL_OJ_NOT_ORDERED        = 16;
+enum SQL_OJ_INNER              = 32;
+enum SQL_OJ_ALL_COMPARISON_OPS = 64;
+}
+
+static if (ODBCVER >= 0x0300) {
+enum SQL_AM_CONNECTION=1;
+enum SQL_AM_NONE=0;
+enum SQL_AM_STATEMENT=2;
+enum SQL_API_SQLALLOCHANDLE=1001;
+enum SQL_API_SQLBINDPARAM=1002;
+enum SQL_API_SQLCLOSECURSOR=1003;
+enum SQL_API_SQLCOLATTRIBUTE=6;
+enum SQL_API_SQLCOPYDESC=1004;
+enum SQL_API_SQLENDTRAN=1005;
+enum SQL_API_SQLFETCHSCROLL=1021;
+enum SQL_API_SQLFREEHANDLE=1006;
+enum SQL_API_SQLGETCONNECTATTR=1007;
+enum SQL_API_SQLGETDESCFIELD=1008;
+enum SQL_API_SQLGETDESCREC=1009;
+enum SQL_API_SQLGETDIAGFIELD=1010;
+enum SQL_API_SQLGETDIAGREC=1011;
+enum SQL_API_SQLGETENVATTR=1012;
+enum SQL_API_SQLGETSTMTATTR=1014;
+enum SQL_API_SQLSETCONNECTATTR=1016;
+enum SQL_API_SQLSETDESCFIELD=1017;
+enum SQL_API_SQLSETDESCREC=1018;
+enum SQL_API_SQLSETENVATTR=1019;
+enum SQL_API_SQLSETSTMTATTR=1020;
+enum SQL_ARD_TYPE=-99;
+enum SQL_AT_ADD_CONSTRAINT=8;
+enum SQL_ATTR_APP_PARAM_DESC=10011;
+enum SQL_ATTR_APP_ROW_DESC=10010;
+enum SQL_ATTR_AUTO_IPD=10001;
+enum SQL_ATTR_CURSOR_SCROLLABLE=-1;
+enum SQL_ATTR_CURSOR_SENSITIVITY=-2;
+enum SQL_ATTR_IMP_PARAM_DESC=10013;
+enum SQL_ATTR_IMP_ROW_DESC=10012;
+enum SQL_ATTR_METADATA_ID=10014;
+enum SQL_ATTR_OUTPUT_NTS=10001;
+enum SQL_CATALOG_NAME=10003;
+enum SQL_CODE_DATE=1;
+enum SQL_CODE_TIME=2;
+enum SQL_CODE_TIMESTAMP=3;
+enum SQL_COLLATION_SEQ=10004;
+enum SQL_CURSOR_SENSITIVITY=10001;
+enum SQL_DATE_LEN=10;
+enum SQL_DATETIME=9;
+enum SQL_DEFAULT=99;
+
+enum SQL_DESC_ALLOC_AUTO=1;
+enum SQL_DESC_ALLOC_USER=2;
+enum SQL_DESC_ALLOC_TYPE=1099;
+enum SQL_DESC_COUNT=1001;
+enum SQL_DESC_TYPE=1002;
+enum SQL_DESC_LENGTH=1003;
+enum SQL_DESC_OCTET_LENGTH_PTR=1004;
+enum SQL_DESC_PRECISION=1005;
+enum SQL_DESC_SCALE=1006;
+enum SQL_DESC_DATETIME_INTERVAL_CODE=1007;
+enum SQL_DESC_NULLABLE=1008;
+enum SQL_DESC_INDICATOR_PTR=1009;
+enum SQL_DESC_DATA_PTR=1010;
+enum SQL_DESC_NAME=1011;
+enum SQL_DESC_UNNAMED=1012;
+enum SQL_DESC_OCTET_LENGTH=1013;
+
+enum SQL_DESCRIBE_PARAMETER=10002;
+
+enum SQL_DIAG_ALTER_DOMAIN=3;
+enum SQL_DIAG_ALTER_TABLE=4;
+enum SQL_DIAG_CALL=7;
+enum SQL_DIAG_CLASS_ORIGIN=8;
+enum SQL_DIAG_CONNECTION_NAME=10;
+enum SQL_DIAG_CREATE_ASSERTION=6;
+enum SQL_DIAG_CREATE_CHARACTER_SET=8;
+enum SQL_DIAG_CREATE_COLLATION=10;
+enum SQL_DIAG_CREATE_DOMAIN=23;
+enum SQL_DIAG_CREATE_INDEX=-1;
+enum SQL_DIAG_CREATE_SCHEMA=64;
+enum SQL_DIAG_CREATE_TABLE=77;
+enum SQL_DIAG_CREATE_TRANSLATION=79;
+enum SQL_DIAG_CREATE_VIEW=84;
+enum SQL_DIAG_DELETE_WHERE=19;
+enum SQL_DIAG_DROP_ASSERTION=24;
+enum SQL_DIAG_DROP_CHARACTER_SET=25;
+enum SQL_DIAG_DROP_COLLATION=26;
+enum SQL_DIAG_DROP_DOMAIN=27;
+enum SQL_DIAG_DROP_INDEX=(-2);
+enum SQL_DIAG_DROP_SCHEMA=31;
+enum SQL_DIAG_DROP_TABLE=32;
+enum SQL_DIAG_DROP_TRANSLATION=33;
+enum SQL_DIAG_DROP_VIEW=36;
+enum SQL_DIAG_DYNAMIC_DELETE_CURSOR=38;
+enum SQL_DIAG_DYNAMIC_FUNCTION=7;
+enum SQL_DIAG_DYNAMIC_FUNCTION_CODE=12;
+enum SQL_DIAG_DYNAMIC_UPDATE_CURSOR=81;
+enum SQL_DIAG_GRANT=48;
+enum SQL_DIAG_INSERT=50;
+enum SQL_DIAG_MESSAGE_TEXT=6;
+enum SQL_DIAG_NATIVE=5;
+enum SQL_DIAG_NUMBER=2;
+enum SQL_DIAG_RETURNCODE=1;
+enum SQL_DIAG_REVOKE=59;
+enum SQL_DIAG_ROW_COUNT=3;
+enum SQL_DIAG_SELECT_CURSOR=85;
+enum SQL_DIAG_SERVER_NAME=11;
+enum SQL_DIAG_SQLSTATE=4;
+enum SQL_DIAG_SUBCLASS_ORIGIN=9;
+enum SQL_DIAG_UNKNOWN_STATEMENT=0;
+enum SQL_DIAG_UPDATE_WHERE=82;
+
+enum SQL_FALSE=0;
+enum SQL_HANDLE_DBC=2;
+enum SQL_HANDLE_DESC=4;
+enum SQL_HANDLE_ENV=1;
+enum SQL_HANDLE_STMT=3;
+enum SQL_INSENSITIVE=1;
+enum SQL_MAX_CONCURRENT_ACTIVITIES=1;
+enum SQL_MAX_DRIVER_CONNECTIONS=0;
+enum SQL_MAX_IDENTIFIER_LEN=10005;
+enum SQL_MAXIMUM_CONCURRENT_ACTIVITIES=SQL_MAX_CONCURRENT_ACTIVITIES;
+enum SQL_MAXIMUM_DRIVER_CONNECTIONS=SQL_MAX_DRIVER_CONNECTIONS;
+enum SQL_MAXIMUM_IDENTIFIER_LENGTH=SQL_MAX_IDENTIFIER_LEN;
+enum SQL_NAMED=0;
+enum SQL_NO_DATA=100;
+enum SQL_NONSCROLLABLE=0;
+enum SQL_NULL_HANDLE=0L;
+enum SQL_NULL_HDESC=0;
+enum SQL_OJ_CAPABILITIES=115;
+enum SQL_OUTER_JOIN_CAPABILITIES=SQL_OJ_CAPABILITIES;
+enum SQL_PC_NON_PSEUDO=1;
+
+enum SQL_PRED_NONE=0;
+enum SQL_PRED_CHAR=1;
+enum SQL_PRED_BASIC=2;
+
+enum SQL_ROW_IDENTIFIER=1;
+enum SQL_SCROLLABLE=1;
+enum SQL_SENSITIVE=2;
+enum SQL_TIME_LEN=8;
+enum SQL_TIMESTAMP_LEN=19;
+enum SQL_TRUE=1;
+enum SQL_TYPE_DATE=91;
+enum SQL_TYPE_TIME=92;
+enum SQL_TYPE_TIMESTAMP=93;
+enum SQL_UNNAMED=1;
+enum SQL_UNSPECIFIED=0;
+enum SQL_XOPEN_CLI_YEAR=10000;
+}//#endif /* ODBCVER >= 0x0300 */
+
+extern (Windows) {
+    deprecated {
+        SQLRETURN SQLAllocConnect(SQLHENV, SQLHDBC*);
+        SQLRETURN SQLAllocEnv(SQLHENV*);
+        SQLRETURN SQLAllocStmt(SQLHDBC, SQLHSTMT*);
+        SQLRETURN SQLError(SQLHENV, SQLHDBC, SQLHSTMT, SQLCHAR*, SQLINTEGER*, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
+        SQLRETURN SQLFreeConnect(SQLHDBC);
+        SQLRETURN SQLFreeEnv(SQLHENV);
+        SQLRETURN SQLSetParam(SQLHSTMT, SQLUSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLULEN, SQLSMALLINT, SQLPOINTER, SQLLEN*);
+        SQLRETURN SQLGetConnectOption(SQLHDBC, SQLUSMALLINT, SQLPOINTER);
+        SQLRETURN SQLGetStmtOption(SQLHSTMT, SQLUSMALLINT, SQLPOINTER);
+        SQLRETURN SQLSetConnectOption(SQLHDBC, SQLUSMALLINT, SQLULEN);
+        SQLRETURN SQLSetStmtOption(SQLHSTMT, SQLUSMALLINT, SQLROWCOUNT);
+    }
+    SQLRETURN SQLBindCol(SQLHSTMT, SQLUSMALLINT, SQLSMALLINT, SQLPOINTER, SQLLEN, SQLLEN*);
+    SQLRETURN SQLCancel(SQLHSTMT);
+    SQLRETURN SQLConnect(SQLHDBC, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLDescribeCol(SQLHSTMT, SQLUSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLSMALLINT*, SQLULEN*, SQLSMALLINT*, SQLSMALLINT*);
+    SQLRETURN SQLDisconnect(SQLHDBC);
+    SQLRETURN SQLExecDirect(SQLHSTMT, SQLCHAR*, SQLINTEGER);
+    SQLRETURN SQLExecute(SQLHSTMT);
+    SQLRETURN SQLFetch(SQLHSTMT);
+    SQLRETURN SQLFreeStmt(SQLHSTMT, SQLUSMALLINT);
+    SQLRETURN SQLGetCursorName(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLNumResultCols(SQLHSTMT, SQLSMALLINT*);
+    SQLRETURN SQLPrepare(SQLHSTMT, SQLCHAR*, SQLINTEGER);
+    SQLRETURN SQLRowCount(SQLHSTMT, SQLLEN*);
+    SQLRETURN SQLSetCursorName(SQLHSTMT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLTransact(SQLHENV, SQLHDBC, SQLUSMALLINT);
+    SQLRETURN SQLColumns(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLGetData(SQLHSTMT, SQLUSMALLINT, SQLSMALLINT, SQLPOINTER, SQLLEN, SQLLEN*);
+    SQLRETURN SQLGetFunctions(SQLHDBC, SQLUSMALLINT, SQLUSMALLINT*);
+    SQLRETURN SQLGetInfo(SQLHDBC, SQLUSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLGetTypeInfo(SQLHSTMT, SQLSMALLINT);
+    SQLRETURN SQLParamData(SQLHSTMT, SQLPOINTER*);
+    SQLRETURN SQLPutData(SQLHSTMT, SQLPOINTER, SQLLEN);
+    SQLRETURN SQLSpecialColumns(SQLHSTMT, SQLUSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLUSMALLINT, SQLUSMALLINT);
+    SQLRETURN SQLStatistics(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLUSMALLINT, SQLUSMALLINT);
+    SQLRETURN SQLTables(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLDataSources(SQLHENV, SQLUSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
+
+    static if (ODBCVER >= 0x0300) {
+        SQLRETURN SQLAllocHandle(SQLSMALLINT, SQLHANDLE, SQLHANDLE*);
+        SQLRETURN SQLBindParam(SQLHSTMT, SQLUSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLULEN, SQLSMALLINT, SQLPOINTER, SQLLEN*);
+        SQLRETURN SQLCloseCursor(SQLHSTMT);
+        SQLRETURN SQLColAttribute(SQLHSTMT, SQLUSMALLINT, SQLUSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*, SQLPOINTER);
+        SQLRETURN SQLCopyDesc(SQLHDESC, SQLHDESC);
+        SQLRETURN SQLEndTran(SQLSMALLINT, SQLHANDLE, SQLSMALLINT);
+        SQLRETURN SQLFetchScroll(SQLHSTMT, SQLSMALLINT, SQLROWOFFSET);
+        SQLRETURN SQLFreeHandle(SQLSMALLINT, SQLHANDLE);
+        SQLRETURN SQLGetConnectAttr(SQLHDBC, SQLINTEGER, SQLPOINTER, SQLINTEGER, SQLINTEGER*);
+        SQLRETURN SQLGetDescField(SQLHDESC, SQLSMALLINT, SQLSMALLINT, SQLPOINTER, SQLINTEGER, SQLINTEGER*);
+        SQLRETURN SQLGetDescRec(SQLHDESC, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*,
+          SQLSMALLINT*, SQLSMALLINT*, SQLLEN*, SQLSMALLINT*, SQLSMALLINT*, SQLSMALLINT*);
+        SQLRETURN SQLGetDiagField(SQLSMALLINT, SQLHANDLE, SQLSMALLINT, SQLSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*);
+        SQLRETURN SQLGetDiagRec(SQLSMALLINT, SQLHANDLE, SQLSMALLINT, SQLCHAR*, SQLINTEGER*, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
+        SQLRETURN SQLGetEnvAttr(SQLHENV, SQLINTEGER, SQLPOINTER, SQLINTEGER, SQLINTEGER*);
+        SQLRETURN SQLGetStmtAttr(SQLHSTMT, SQLINTEGER, SQLPOINTER, SQLINTEGER, SQLINTEGER*);
+        SQLRETURN SQLSetConnectAttr(SQLHDBC, SQLINTEGER, SQLPOINTER, SQLINTEGER);
+        SQLRETURN SQLSetDescField(SQLHDESC, SQLSMALLINT, SQLSMALLINT, SQLPOINTER, SQLINTEGER);
+        SQLRETURN SQLSetDescRec(SQLHDESC, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLLEN, SQLSMALLINT,
+            SQLSMALLINT, SQLPOINTER, SQLLEN*, SQLLEN*);
+        SQLRETURN SQLSetEnvAttr(SQLHENV, SQLINTEGER, SQLPOINTER, SQLINTEGER);
+        SQLRETURN SQLSetStmtAttr(SQLHSTMT, SQLINTEGER, SQLPOINTER, SQLINTEGER);
+    }/* (ODBCVER >= 0x0300) */
+}
diff --git a/libphobos/libdruntime/core/sys/windows/sqlext.d b/libphobos/libdruntime/core/sys/windows/sqlext.d
new file mode 100644
index 00000000000..842f721205b
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/sqlext.d
@@ -0,0 +1,1295 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_sqlext.d)
+ */
+module core.sys.windows.sqlext;
+version (Windows):
+
+/* Conversion notes:
+   The MinGW file was a horrible mess. All of the #defines were sorted alphabetically,
+   which is crazy. This file needs a lot of work.
+   In MinGW, sqlext #includes sqlucode, but sqlucode #includes sqlext,
+   creating a circular dependency!
+*/
+
+public import core.sys.windows.sql;
+private import core.sys.windows.windef;
+
+enum SQL_SPEC_MAJOR = 3;
+enum SQL_SPEC_MINOR = 51;
+const char[] SQL_SPEC_STRING = "03.51";
+enum SQL_ACCESS_MODE = 101;
+enum SQL_ACTIVE_CONNECTIONS = 0;
+enum SQL_ACTIVE_STATEMENTS  = 1;
+
+enum SQL_DATE = 9;
+enum SQL_TIME = 10;
+enum SQL_SIGNED_OFFSET = -20;
+enum SQL_TINYINT = -6;
+enum SQL_TIMESTAMP = 11;
+enum SQL_UNSIGNED_OFFSET = -22;
+
+enum SQL_ADD = 4;
+enum SQL_ALL_EXCEPT_LIKE = 2;
+
+enum SQL_API_ALL_FUNCTIONS       =   0;
+enum SQL_API_SQLCOLATTRIBUTES    =   6;
+enum SQL_API_SQLDRIVERCONNECT    =  41;
+enum SQL_API_SQLBROWSECONNECT    =  55;
+enum SQL_API_SQLCOLUMNPRIVILEGES =  56;
+enum SQL_API_SQLDESCRIBEPARAM    =  58;
+enum SQL_API_SQLEXTENDEDFETCH    =  59;
+enum SQL_API_SQLFOREIGNKEYS      =  60;
+enum SQL_API_SQLMORERESULTS      =  61;
+enum SQL_API_SQLNATIVESQL        =  62;
+enum SQL_API_SQLNUMPARAMS        =  63;
+enum SQL_API_SQLPARAMOPTIONS     =  64;
+enum SQL_API_SQLPRIMARYKEYS      =  65;
+enum SQL_API_SQLPROCEDURECOLUMNS =  66;
+enum SQL_API_SQLPROCEDURES       =  67;
+enum SQL_API_SQLSETPOS           =  68;
+enum SQL_API_SQLSETSCROLLOPTIONS =  69;
+enum SQL_API_SQLTABLEPRIVILEGES  =  70;
+enum SQL_API_SQLDRIVERS          =  71;
+enum SQL_API_SQLBINDPARAMETER    =  72;
+enum SQL_API_LOADBYORDINAL       = 199;
+
+enum SQL_ASYNC_ENABLE = 4;
+enum SQL_ASYNC_ENABLE_OFF = 0UL;
+enum SQL_ASYNC_ENABLE_ON = 1UL;
+enum SQL_ASYNC_ENABLE_DEFAULT = SQL_ASYNC_ENABLE_OFF;
+
+enum SQL_ATTR_CONNECTION_DEAD = 1209;
+enum SQL_ATTR_READONLY = 0;
+enum SQL_ATTR_READWRITE_UNKNOWN = 2;
+enum SQL_ATTR_WRITE = 1;
+
+enum SQL_AUTOCOMMIT = 102;
+enum SQL_AUTOCOMMIT_OFF = 0UL;
+enum SQL_AUTOCOMMIT_ON = 1UL;
+enum SQL_AUTOCOMMIT_DEFAULT = SQL_AUTOCOMMIT_ON;
+enum SQL_BEST_ROWID = 1;
+enum SQL_BIGINT = -5;
+enum SQL_BINARY = -2;
+enum SQL_BIND_BY_COLUMN = 0UL;
+enum SQL_BIND_TYPE = 5;
+enum SQL_BIND_TYPE_DEFAULT = SQL_BIND_BY_COLUMN;
+enum SQL_BIT = -7;
+
+enum SQL_BOOKMARK_PERSISTENCE = 82;
+
+// for BOOKMARK_PERSISTENCE
+enum SQL_BP_CLOSE       = 1;
+enum SQL_BP_DELETE      = 2;
+enum SQL_BP_DROP        = 4;
+enum SQL_BP_TRANSACTION = 8;
+enum SQL_BP_UPDATE      = 16;
+enum SQL_BP_OTHER_HSTMT = 32;
+enum SQL_BP_SCROLL      = 64;
+
+enum SQL_C_BINARY    = SQL_BINARY;
+enum SQL_C_BIT       = SQL_BIT;
+enum SQL_C_CHAR      = SQL_CHAR;
+enum SQL_C_DATE      = SQL_DATE;
+enum SQL_C_DOUBLE    = SQL_DOUBLE;
+enum SQL_C_FLOAT     = SQL_REAL;
+enum SQL_C_LONG      = SQL_INTEGER;
+enum SQL_C_SHORT     = SQL_SMALLINT;
+enum SQL_C_SLONG     = SQL_C_LONG+SQL_SIGNED_OFFSET;
+enum SQL_C_SSHORT    = SQL_C_SHORT+SQL_SIGNED_OFFSET;
+enum SQL_C_STINYINT  = SQL_TINYINT+SQL_SIGNED_OFFSET;
+enum SQL_C_TIME      = SQL_TIME;
+enum SQL_C_TIMESTAMP = SQL_TIMESTAMP;
+enum SQL_C_TINYINT   = SQL_TINYINT;
+enum SQL_C_ULONG     = SQL_C_LONG+SQL_UNSIGNED_OFFSET;
+enum SQL_C_USHORT    = SQL_C_SHORT+SQL_UNSIGNED_OFFSET;
+enum SQL_C_UTINYINT  = SQL_TINYINT+SQL_UNSIGNED_OFFSET;
+enum SQL_C_BOOKMARK  = SQL_C_ULONG;
+enum SQL_C_DEFAULT   = 99;
+
+enum SQL_CASCADE = 0;
+enum SQL_CB_NON_NULL = 1;
+enum SQL_CB_NULL = 0;
+deprecated {
+enum SQL_CC_CLOSE = SQL_CB_CLOSE;/* deprecated */
+enum SQL_CC_DELETE = SQL_CB_DELETE;/* deprecated */
+enum SQL_CC_PRESERVE = SQL_CB_PRESERVE;/* deprecated */
+}
+enum SQL_CD_FALSE = 0L;
+enum SQL_CD_TRUE = 1L;
+
+enum SQL_CN_ANY = 2;
+enum SQL_CN_DIFFERENT = 1;
+enum SQL_CN_NONE = 0;
+
+enum SQL_COLUMN_ALIAS = 87;
+
+enum SQL_COLUMN_COUNT = 0;
+enum SQL_COLUMN_NAME = 1;
+enum SQL_COLUMN_DISPLAY_SIZE = 6;
+enum SQL_COLUMN_LABEL = 18;
+enum SQL_COLUMN_LENGTH = 3;
+enum SQL_COLUMN_MONEY = 9;
+enum SQL_COLUMN_NULLABLE = 7;
+enum SQL_COLUMN_OWNER_NAME = 16;
+enum SQL_COLUMN_PRECISION = 4;
+enum SQL_COLUMN_QUALIFIER_NAME = 17;
+enum SQL_COLUMN_SCALE = 5;
+enum SQL_COLUMN_UNSIGNED = 8;
+enum SQL_COLUMN_UPDATABLE = 10;
+enum SQL_COLUMN_AUTO_INCREMENT = 11;
+enum SQL_COLUMN_CASE_SENSITIVE = 12;
+enum SQL_COLUMN_SEARCHABLE = 13;
+enum SQL_COLUMN_TYPE = 2;
+enum SQL_COLUMN_TYPE_NAME = 14;
+enum SQL_COLUMN_TABLE_NAME = 15;
+
+enum SQL_CONCAT_NULL_BEHAVIOR = 22;
+
+enum SQL_CONCUR_READ_ONLY = 1;
+enum SQL_CONCUR_DEFAULT   = SQL_CONCUR_READ_ONLY;
+enum SQL_CONCUR_LOCK      = 2;
+enum SQL_CONCUR_ROWVER    = 3;
+enum SQL_CONCUR_TIMESTAMP = SQL_CONCUR_ROWVER;/* deprecated */
+enum SQL_CONCUR_VALUES    = 4;
+
+enum SQL_CONCURRENCY = 7;
+enum SQL_CONVERT_BIGINT = 53;
+enum SQL_CONVERT_BINARY = 54;
+enum SQL_CONVERT_BIT = 55;
+enum SQL_CONVERT_CHAR = 56;
+enum SQL_CONVERT_DATE = 57;
+enum SQL_CONVERT_DECIMAL = 58;
+enum SQL_CONVERT_DOUBLE = 59;
+enum SQL_CONVERT_FLOAT = 60;
+enum SQL_CONVERT_FUNCTIONS = 48;
+enum SQL_CONVERT_INTEGER = 61;
+enum SQL_CONVERT_LONGVARBINARY = 71;
+enum SQL_CONVERT_LONGVARCHAR = 62;
+enum SQL_CONVERT_NUMERIC = 63;
+enum SQL_CONVERT_REAL = 64;
+enum SQL_CONVERT_SMALLINT = 65;
+enum SQL_CONVERT_TIME = 66;
+enum SQL_CONVERT_TIMESTAMP = 67;
+enum SQL_CONVERT_TINYINT = 68;
+enum SQL_CONVERT_VARBINARY = 69;
+enum SQL_CONVERT_VARCHAR = 70;
+enum SQL_CORRELATION_NAME = 74;
+enum SQL_CR_CLOSE = SQL_CB_CLOSE;/* deprecated */
+enum SQL_CR_DELETE = SQL_CB_DELETE;/* deprecated */
+enum SQL_CR_PRESERVE = SQL_CB_PRESERVE;/* deprecated */
+
+enum : ULONG {
+    SQL_CUR_USE_IF_NEEDED = 0,
+    SQL_CUR_USE_ODBC,
+    SQL_CUR_USE_DRIVER,
+    SQL_CUR_DEFAULT = SQL_CUR_USE_DRIVER
+}
+
+enum SQL_CURRENT_QUALIFIER = 109;
+enum SQL_CURSOR_DYNAMIC = 2UL;
+enum SQL_CURSOR_FORWARD_ONLY = 0UL;
+enum SQL_CURSOR_KEYSET_DRIVEN = 1UL;
+enum SQL_CURSOR_ROLLBACK_BEHAVIOR = 24;
+enum SQL_CURSOR_STATIC = 3UL;
+enum SQL_CURSOR_TYPE = 6;
+enum SQL_CURSOR_TYPE_DEFAULT = SQL_CURSOR_FORWARD_ONLY;
+
+enum SQL_CV_CASCADED = 0x00000004L;
+enum SQL_CV_CHECK_OPTION = 0x00000002L;
+enum SQL_CV_CREATE_VIEW = 0x00000001L;
+enum SQL_CV_LOCAL = 0x00000008L;
+enum SQL_CVT_BIGINT = 0x00004000L;
+enum SQL_CVT_BINARY = 0x00000400L;
+enum SQL_CVT_BIT = 0x00001000L;
+enum SQL_CVT_CHAR = 0x00000001L;
+enum SQL_CVT_DATE = 0x00008000L;
+enum SQL_CVT_DECIMAL = 0x00000004L;
+enum SQL_CVT_DOUBLE = 0x00000080L;
+enum SQL_CVT_FLOAT = 0x00000020L;
+enum SQL_CVT_INTEGER = 0x00000008L;
+enum SQL_CVT_LONGVARBINARY = 0x00040000L;
+enum SQL_CVT_LONGVARCHAR = 0x00000200L;
+enum SQL_CVT_NUMERIC = 0x00000002L;
+enum SQL_CVT_REAL = 0x00000040L;
+enum SQL_CVT_SMALLINT = 0x00000010L;
+enum SQL_CVT_TIME = 0x00010000L;
+enum SQL_CVT_TIMESTAMP = 0x00020000L;
+enum SQL_CVT_TINYINT = 0x00002000L;
+enum SQL_CVT_VARBINARY = 0x00000800L;
+enum SQL_CVT_VARCHAR = 0x00000100L;
+enum SQL_DATABASE_NAME = 16;/* deprecated */
+
+enum SQL_DEFAULT_PARAM = -5;
+enum SQL_DELETE = 3;
+
+enum SQL_DRIVER_COMPLETE = 1;
+enum SQL_DRIVER_COMPLETE_REQUIRED = 3;
+enum SQL_DRIVER_HDBC = 3;
+enum SQL_DRIVER_HENV = 4;
+enum SQL_DRIVER_HLIB = 76;
+enum SQL_DRIVER_HSTMT = 5;
+enum SQL_DRIVER_NAME = 6;
+enum SQL_DRIVER_NOPROMPT = 0;
+enum SQL_DRIVER_ODBC_VER = 77;
+enum SQL_DRIVER_PROMPT = 2;
+enum SQL_DRIVER_VER = 7;
+
+enum SQL_DTC_ENLIST_EXPENSIVE = 1;
+enum SQL_DTC_UNENLIST_EXPENSIVE = 2;
+enum SQL_DTC_TRANSITION_COST = 1750;
+enum SQL_ENSURE = 1;
+enum SQL_ENTIRE_ROWSET = 0;
+enum SQL_EXPRESSIONS_IN_ORDERBY = 27;
+enum SQL_FD_FETCH_BOOKMARK = 128;
+enum SQL_FD_FETCH_PREV = SQL_FD_FETCH_PRIOR;/* deprecated */
+enum SQL_FD_FETCH_RESUME = 64;
+enum SQL_FETCH_BOOKMARK = 8;
+enum SQL_FETCH_PREV = SQL_FETCH_PRIOR;/* deprecated */
+enum SQL_FETCH_RESUME = 7;/* deprecated */
+
+enum SQL_FILE_NOT_SUPPORTED = 0x0000;
+enum SQL_FILE_TABLE = 0x0001;
+enum SQL_FILE_QUALIFIER = 0x0002;
+enum SQL_FILE_CATALOG = SQL_FILE_QUALIFIER;
+enum SQL_FILE_USAGE = 84;
+
+enum SQL_FN_CVT_CONVERT = 0x00000001L;
+enum SQL_FN_NUM_ABS = 0x00000001L;
+enum SQL_FN_NUM_ACOS = 0x00000002L;
+enum SQL_FN_NUM_ASIN = 0x00000004L;
+enum SQL_FN_NUM_ATAN = 0x00000008L;
+enum SQL_FN_NUM_ATAN2 = 0x00000010L;
+enum SQL_FN_NUM_CEILING = 0x00000020L;
+enum SQL_FN_NUM_COS = 0x00000040L;
+enum SQL_FN_NUM_COT = 0x00000080L;
+enum SQL_FN_NUM_DEGREES = 0x00040000L;
+enum SQL_FN_NUM_EXP = 0x00000100L;
+enum SQL_FN_NUM_FLOOR = 0x00000200L;
+enum SQL_FN_NUM_LOG = 0x00000400L;
+enum SQL_FN_NUM_LOG10 = 0x00080000L;
+enum SQL_FN_NUM_MOD = 0x00000800L;
+enum SQL_FN_NUM_PI = 0x00010000L;
+enum SQL_FN_NUM_POWER = 0x00100000L;
+enum SQL_FN_NUM_RADIANS = 0x00200000L;
+enum SQL_FN_NUM_RAND = 0x00020000L;
+enum SQL_FN_NUM_ROUND = 0x00400000L;
+enum SQL_FN_NUM_SIGN = 0x00001000L;
+enum SQL_FN_NUM_SIN = 0x00002000L;
+enum SQL_FN_NUM_SQRT = 0x00004000L;
+enum SQL_FN_NUM_TAN = 0x00008000L;
+enum SQL_FN_NUM_TRUNCATE = 0x00800000L;
+enum SQL_FN_STR_ASCII = 0x00002000L;
+enum SQL_FN_STR_CHAR = 0x00004000L;
+enum SQL_FN_STR_CONCAT = 0x00000001L;
+enum SQL_FN_STR_DIFFERENCE = 0x00008000L;
+enum SQL_FN_STR_INSERT = 0x00000002L;
+enum SQL_FN_STR_LCASE = 0x00000040L;
+enum SQL_FN_STR_LEFT = 0x00000004L;
+enum SQL_FN_STR_LENGTH = 0x00000010L;
+enum SQL_FN_STR_LOCATE = 0x00000020L;
+enum SQL_FN_STR_LOCATE_2 = 0x00010000L;
+enum SQL_FN_STR_LTRIM = 0x00000008L;
+enum SQL_FN_STR_REPEAT = 0x00000080L;
+enum SQL_FN_STR_REPLACE = 0x00000100L;
+enum SQL_FN_STR_RIGHT = 0x00000200L;
+enum SQL_FN_STR_RTRIM = 0x00000400L;
+enum SQL_FN_STR_SOUNDEX = 0x00020000L;
+enum SQL_FN_STR_SPACE = 0x00040000L;
+enum SQL_FN_STR_SUBSTRING = 0x00000800L;
+enum SQL_FN_STR_UCASE = 0x00001000L;
+enum SQL_FN_SYS_DBNAME = 0x00000002L;
+enum SQL_FN_SYS_IFNULL = 0x00000004L;
+enum SQL_FN_SYS_USERNAME = 0x00000001L;
+enum SQL_FN_TD_CURDATE = 0x00000002L;
+enum SQL_FN_TD_CURTIME = 0x00000200L;
+enum SQL_FN_TD_DAYNAME = 0x00008000L;
+enum SQL_FN_TD_DAYOFMONTH = 0x00000004L;
+enum SQL_FN_TD_DAYOFWEEK = 0x00000008L;
+enum SQL_FN_TD_DAYOFYEAR = 0x00000010L;
+enum SQL_FN_TD_HOUR = 0x00000400L;
+enum SQL_FN_TD_MINUTE = 0x00000800L;
+enum SQL_FN_TD_MONTH = 0x00000020L;
+enum SQL_FN_TD_MONTHNAME = 0x00010000L;
+enum SQL_FN_TD_NOW = 0x00000001L;
+enum SQL_FN_TD_QUARTER = 0x00000040L;
+enum SQL_FN_TD_SECOND = 0x00001000L;
+enum SQL_FN_TD_TIMESTAMPADD = 0x00002000L;
+enum SQL_FN_TD_TIMESTAMPDIFF = 0x00004000L;
+enum SQL_FN_TD_WEEK = 0x00000080L;
+enum SQL_FN_TD_YEAR = 0x00000100L;
+enum SQL_FN_TSI_DAY = 0x00000010L;
+enum SQL_FN_TSI_FRAC_SECOND = 0x00000001L;
+enum SQL_FN_TSI_HOUR = 0x00000008L;
+enum SQL_FN_TSI_MINUTE = 0x00000004L;
+enum SQL_FN_TSI_MONTH = 0x00000040L;
+enum SQL_FN_TSI_QUARTER = 0x00000080L;
+enum SQL_FN_TSI_SECOND = 0x00000002L;
+enum SQL_FN_TSI_WEEK = 0x00000020L;
+enum SQL_FN_TSI_YEAR = 0x00000100L;
+enum SQL_GB_GROUP_BY_CONTAINS_SELECT = 2;
+enum SQL_GB_GROUP_BY_EQUALS_SELECT = 1;
+enum SQL_GB_NO_RELATION = 3;
+enum SQL_GB_NOT_SUPPORTED = 0;
+enum SQL_GD_BLOCK = 4;
+enum SQL_GD_BOUND = 8;
+enum SQL_GET_BOOKMARK = 13;
+enum SQL_GROUP_BY = 88;
+enum SQL_IGNORE = -6;
+enum SQL_INFO_FIRST = 0;
+enum SQL_KEYSET_SIZE = 8;
+enum SQL_KEYSET_SIZE_DEFAULT = 0UL;
+enum SQL_KEYWORDS = 89;
+enum SQL_LCK_EXCLUSIVE = 2;
+enum SQL_LCK_NO_CHANGE = 1;
+enum SQL_LCK_UNLOCK = 4;
+
+enum SQL_LEN_BINARY_ATTR_OFFSET  = -100;
+enum SQL_LEN_DATA_AT_EXEC_OFFSET = -100;
+//MACRO #define SQL_LEN_BINARY_ATTR(length) (-(length)+SQL_LEN_BINARY_ATTR_OFFSET)
+//MACRO #define SQL_LEN_DATA_AT_EXEC(length) (-(length)+SQL_LEN_DATA_AT_EXEC_OFFSET)
+
+enum SQL_LIKE_ESCAPE_CLAUSE = 113;
+enum SQL_LIKE_ONLY = 1;
+enum SQL_LOCK_EXCLUSIVE = 1;
+enum SQL_LOCK_NO_CHANGE = 0;
+enum SQL_LOCK_TYPES = 78;
+enum SQL_LOCK_UNLOCK = 2;
+enum SQL_LOGIN_TIMEOUT = 103;
+enum SQL_LOGIN_TIMEOUT_DEFAULT = 15UL;
+enum SQL_LONGVARBINARY = -4;
+enum SQL_LONGVARCHAR = -1;
+enum SQL_MAX_BINARY_LITERAL_LEN = 112;
+enum SQL_MAX_CHAR_LITERAL_LEN = 108;
+enum SQL_MAX_DSN_LENGTH = 32;
+enum SQL_MAX_LENGTH = 3;
+enum SQL_MAX_LENGTH_DEFAULT = 0UL;
+enum SQL_MAX_OPTION_STRING_LENGTH = 256;
+enum SQL_MAX_OWNER_NAME_LEN = 32;
+enum SQL_MAX_PROCEDURE_NAME_LEN = 33;
+enum SQL_MAX_QUALIFIER_NAME_LEN = 34;
+enum SQL_MAX_ROW_SIZE_INCLUDES_LONG = 103;
+enum SQL_MAX_ROWS = 1;
+enum SQL_MAX_ROWS_DEFAULT = 0UL;
+
+enum SQL_MODE_READ_WRITE = 0UL;
+enum SQL_MODE_READ_ONLY = 1UL;
+enum SQL_MODE_DEFAULT = SQL_MODE_READ_WRITE;
+
+enum SQL_MULT_RESULT_SETS = 36;
+enum SQL_MULTIPLE_ACTIVE_TXN = 37;
+enum SQL_NC_END = 0x0004;
+enum SQL_NC_START = 0x0002;
+enum SQL_NEED_LONG_DATA_LEN = 111;
+enum SQL_NNC_NON_NULL = 0x0001;
+enum SQL_NNC_NULL = 0x0000;
+enum SQL_NO_TOTAL = -4;
+enum SQL_NON_NULLABLE_COLUMNS = 75;
+
+enum SQL_NOSCAN_OFF = 0UL;
+enum SQL_NOSCAN_ON = 1UL;
+enum SQL_NOSCAN = 2;
+enum SQL_NOSCAN_DEFAULT = SQL_NOSCAN_OFF;
+
+enum SQL_NUMERIC_FUNCTIONS = 49;
+enum SQL_OAC_LEVEL1 = 0x0001;
+enum SQL_OAC_LEVEL2 = 0x0002;
+enum SQL_OAC_NONE = 0x0000;
+enum SQL_ODBC_API_CONFORMANCE = 9;
+enum SQL_ODBC_CURSORS = 110;
+enum SQL_ODBC_SAG_CLI_CONFORMANCE = 12;
+enum SQL_ODBC_SQL_CONFORMANCE = 15;
+enum SQL_ODBC_SQL_OPT_IEF = 73;
+enum SQL_ODBC_VER = 10;
+enum SQL_OPT_TRACE = 104;
+
+enum SQL_OPT_TRACE_FILE_DEFAULT = "\\SQL.LOG";
+enum SQL_OPT_TRACE_OFF = 0UL;
+enum SQL_OPT_TRACE_DEFAULT = SQL_OPT_TRACE_OFF;
+enum SQL_OPT_TRACE_ON = 1UL;
+
+enum SQL_OPT_TRACEFILE = 105;
+enum SQL_OSC_CORE = 1;
+enum SQL_OSC_EXTENDED = 2;
+enum SQL_OSC_MINIMUM = 0;
+enum SQL_OSCC_COMPLIANT = 1;
+enum SQL_OSCC_NOT_COMPLIANT = 0;
+enum SQL_OU_DML_STATEMENTS = 1;
+enum SQL_OU_INDEX_DEFINITION = 8;
+enum SQL_OU_PRIVILEGE_DEFINITION = 16;
+enum SQL_OU_PROCEDURE_INVOCATION = 2;
+enum SQL_OU_TABLE_DEFINITION = 4;
+enum SQL_OUTER_JOINS = 38;
+enum SQL_OWNER_TERM = 39;
+enum SQL_OWNER_USAGE = 91;
+enum SQL_PACKET_SIZE = 112;
+enum SQL_PARAM_INPUT = 1;
+enum SQL_PARAM_INPUT_OUTPUT = 2;
+enum SQL_PARAM_OUTPUT = 4;
+enum SQL_PARAM_TYPE_DEFAULT = SQL_PARAM_INPUT_OUTPUT;
+enum SQL_PARAM_TYPE_UNKNOWN = 0;
+enum SQL_PC_NOT_PSEUDO = 1;
+enum SQL_POS_ADD = 16;
+enum SQL_POS_DELETE = 8;
+enum SQL_POS_OPERATIONS = 79;
+enum SQL_POS_POSITION = 1;
+enum SQL_POS_REFRESH = 2;
+enum SQL_POS_UPDATE = 4;
+enum SQL_POSITION = 0;
+enum SQL_POSITIONED_STATEMENTS = 80;
+enum SQL_PROCEDURE_TERM = 40;
+enum SQL_PROCEDURES = 21;
+enum SQL_PS_POSITIONED_DELETE = 1;
+enum SQL_PS_POSITIONED_UPDATE = 2;
+enum SQL_PS_SELECT_FOR_UPDATE = 4;
+enum SQL_PT_FUNCTION = 2;
+enum SQL_PT_PROCEDURE = 1;
+enum SQL_PT_UNKNOWN = 0;
+enum SQL_QL_END = 0x0002;
+enum SQL_QL_START = 0x0001;
+enum SQL_QU_DML_STATEMENTS = 1;
+enum SQL_QU_INDEX_DEFINITION = 8;
+enum SQL_QU_PRIVILEGE_DEFINITION = 16;
+enum SQL_QU_PROCEDURE_INVOCATION = 2;
+enum SQL_QU_TABLE_DEFINITION = 4;
+enum SQL_QUALIFIER_LOCATION = 114;
+enum SQL_QUALIFIER_NAME_SEPARATOR = 41;
+enum SQL_QUALIFIER_TERM = 42;
+enum SQL_QUALIFIER_USAGE = 92;
+enum SQL_QUERY_TIMEOUT = 0;
+enum SQL_QUERY_TIMEOUT_DEFAULT = 0UL;
+enum SQL_QUICK = 0;
+enum SQL_QUIET_MODE = 111;
+enum SQL_QUOTED_IDENTIFIER_CASE = 93;
+
+enum SQL_RD_OFF = 0UL;
+enum SQL_RD_ON = 1UL;
+enum SQL_RD_DEFAULT = SQL_RD_ON;
+
+enum SQL_REFRESH = 1;
+enum SQL_RESTRICT = 1;
+enum SQL_RESULT_COL = 3;
+enum SQL_RETRIEVE_DATA = 11;
+enum SQL_RETURN_VALUE = 5;
+enum SQL_ROW_ADDED = 4;
+enum SQL_ROW_DELETED = 1;
+enum SQL_ROW_ERROR = 5;
+enum SQL_ROW_NOROW = 3;
+enum SQL_ROW_NUMBER = 14;
+enum SQL_ROW_SUCCESS = 0;
+enum SQL_ROW_UPDATED = 2;
+enum SQL_ROW_UPDATES = 11;
+enum SQL_ROWSET_SIZE = 9;
+enum SQL_ROWSET_SIZE_DEFAULT = 1UL;
+enum SQL_ROWVER = 2;
+enum SQL_SC_NON_UNIQUE = 0UL;
+enum SQL_SC_TRY_UNIQUE = 1UL;
+enum SQL_SC_UNIQUE = 2UL;
+enum SQL_SCCO_OPT_TIMESTAMP = SQL_SCCO_OPT_ROWVER;/* deprecated */
+enum SQL_SCROLL_DYNAMIC = -2L;/* deprecated */
+enum SQL_SCROLL_FORWARD_ONLY = 0L;/* deprecated */
+enum SQL_SCROLL_KEYSET_DRIVEN = -1L;/* deprecated */
+enum SQL_SCROLL_OPTIONS = 44;
+enum SQL_SCROLL_STATIC = -3L;/* deprecated */
+enum SQL_SEARCHABLE = 3;
+enum SQL_SET_NULL = 2;
+enum SQL_SETPARAM_VALUE_MAX = -1L;
+enum SQL_SETPOS_MAX_LOCK_VALUE = SQL_LOCK_UNLOCK;
+enum SQL_SETPOS_MAX_OPTION_VALUE = SQL_ADD;
+enum SQL_SIMULATE_CURSOR = 10;
+enum SQL_SO_DYNAMIC = 4;
+enum SQL_SO_FORWARD_ONLY = 1;
+enum SQL_SO_KEYSET_DRIVEN = 2;
+enum SQL_SO_MIXED = 8;
+enum SQL_SO_STATIC = 16;
+enum SQL_SQ_COMPARISON = 1;
+enum SQL_SQ_CORRELATED_SUBQUERIES = 16;
+enum SQL_SQ_EXISTS = 2;
+enum SQL_SQ_IN = 4;
+enum SQL_SQ_QUANTIFIED = 8;
+enum SQL_SQLSTATE_SIZE = 5;
+enum SQL_SS_ADDITIONS = 1;
+enum SQL_SS_DELETIONS = 2;
+enum SQL_SS_UPDATES = 4;
+enum SQL_STATIC_SENSITIVITY = 83;
+enum SQL_STRING_FUNCTIONS = 50;
+enum SQL_SUBQUERIES = 95;
+enum SQL_SYSTEM_FUNCTIONS = 51;
+enum SQL_TABLE_STAT = 0;
+enum SQL_TABLE_TERM = 45;
+enum SQL_TIMEDATE_ADD_INTERVALS = 109;
+enum SQL_TIMEDATE_DIFF_INTERVALS = 110;
+enum SQL_TIMEDATE_FUNCTIONS = 52;
+enum SQL_TRANSLATE_DLL = 106;
+enum SQL_TRANSLATE_OPTION = 107;
+enum SQL_TXN_ISOLATION = 108;
+enum SQL_TXN_VERSIONING = 16;
+enum SQL_TYPE_NULL = 0;
+enum SQL_U_UNION = 1;
+enum SQL_U_UNION_ALL = 2;
+
+enum SQL_UB_OFF = 0UL;
+enum SQL_UB_DEFAULT = SQL_UB_OFF;
+enum SQL_UB_ON = 01UL;
+
+enum SQL_UNION = 96;
+enum SQL_UNSEARCHABLE = 0;
+enum SQL_UPDATE = 2;
+enum SQL_USE_BOOKMARKS = 12;
+enum SQL_VARBINARY = -3;
+
+enum SQL_COLATT_OPT_MAX = SQL_COLUMN_LABEL;
+enum SQL_COLATT_OPT_MIN = SQL_COLUMN_COUNT;
+enum SQL_PRED_SEARCHABLE = SQL_SEARCHABLE;
+
+//MACRO #define SQL_POSITION_TO(s, r) SQLSetPos(s, r, SQL_POSITION, SQL_LOCK_NO_CHANGE)
+
+//MACRO #define SQL_LOCK_RECORD(s, r, l) SQLSetPos(s, r, SQL_POSITION, l)
+
+//MACRO #define SQL_REFRESH_RECORD(s, r, l) SQLSetPos(s, r, SQL_REFRESH, l)
+
+//MACRO #define SQL_UPDATE_RECORD(s, r) SQLSetPos(s, r, SQL_UPDATE, SQL_LOCK_NO_CHANGE)
+
+//MACRO #define SQL_DELETE_RECORD(s, r) SQLSetPos(s, r, SQL_DELETE, SQL_LOCK_NO_CHANGE)
+
+//MACRO #define SQL_ADD_RECORD(s, r) SQLSetPos(s, r, SQL_ADD, SQL_LOCK_NO_CHANGE)
+
+
+static if (ODBCVER < 0x0300) {
+enum SQL_CONNECT_OPT_DRVR_START = 1000;
+enum SQL_CONN_OPT_MAX = SQL_PACKET_SIZE;
+enum SQL_CONN_OPT_MIN = SQL_ACCESS_MODE;
+enum SQL_STMT_OPT_MAX = SQL_ROW_NUMBER;
+enum SQL_STMT_OPT_MIN = SQL_QUERY_TIMEOUT;
+enum SQL_TYPE_DRIVER_START = SQL_INTERVAL_YEAR;
+enum SQL_TYPE_DRIVER_END = SQL_UNICODE_LONGVARCHAR;
+enum SQL_TYPE_MIN = SQL_BIT;
+enum SQL_TYPE_MAX = SQL_VARCHAR;
+}
+
+static if (ODBCVER < 0x0300) {
+enum SQL_NO_DATA_FOUND = 100;
+enum SQL_INTERVAL_YEAR = -80;
+enum SQL_INTERVAL_MONTH = -81;
+enum SQL_INTERVAL_YEAR_TO_MONTH = -82;
+enum SQL_INTERVAL_DAY = -83;
+enum SQL_INTERVAL_HOUR = -84;
+enum SQL_INTERVAL_MINUTE = -85;
+enum SQL_INTERVAL_SECOND = -86;
+enum SQL_INTERVAL_DAY_TO_HOUR = -87;
+enum SQL_INTERVAL_DAY_TO_MINUTE = -88;
+enum SQL_INTERVAL_DAY_TO_SECOND = -89;
+enum SQL_INTERVAL_HOUR_TO_MINUTE = -90;
+enum SQL_INTERVAL_HOUR_TO_SECOND = -91;
+enum SQL_INTERVAL_MINUTE_TO_SECOND = -92;
+} else {
+enum SQL_NO_DATA_FOUND = SQL_NO_DATA;
+enum SQL_CODE_YEAR = 1;
+enum SQL_CODE_MONTH = 2;
+enum SQL_CODE_DAY = 3;
+enum SQL_CODE_HOUR = 4;
+enum SQL_CODE_MINUTE = 5;
+enum SQL_CODE_SECOND = 6;
+enum SQL_CODE_YEAR_TO_MONTH = 7;
+enum SQL_CODE_DAY_TO_HOUR = 8;
+enum SQL_CODE_DAY_TO_MINUTE = 9;
+enum SQL_CODE_DAY_TO_SECOND = 10;
+enum SQL_CODE_HOUR_TO_MINUTE = 11;
+enum SQL_CODE_HOUR_TO_SECOND = 12;
+enum SQL_CODE_MINUTE_TO_SECOND = 13;
+enum SQL_INTERVAL_YEAR = 100 + SQL_CODE_YEAR;
+enum SQL_INTERVAL_MONTH = 100 + SQL_CODE_MONTH;
+enum SQL_INTERVAL_DAY = 100 + SQL_CODE_DAY;
+enum SQL_INTERVAL_HOUR = 100 + SQL_CODE_HOUR;
+enum SQL_INTERVAL_MINUTE = 100 + SQL_CODE_MINUTE;
+enum SQL_INTERVAL_SECOND = 100 + SQL_CODE_SECOND;
+enum SQL_INTERVAL_YEAR_TO_MONTH = 100 + SQL_CODE_YEAR_TO_MONTH;
+enum SQL_INTERVAL_DAY_TO_HOUR = 100 + SQL_CODE_DAY_TO_HOUR;
+enum SQL_INTERVAL_DAY_TO_MINUTE = 100 + SQL_CODE_DAY_TO_MINUTE;
+enum SQL_INTERVAL_DAY_TO_SECOND = 100 + SQL_CODE_DAY_TO_SECOND;
+enum SQL_INTERVAL_HOUR_TO_MINUTE = 100 + SQL_CODE_HOUR_TO_MINUTE;
+enum SQL_INTERVAL_HOUR_TO_SECOND = 100 + SQL_CODE_HOUR_TO_SECOND;
+enum SQL_INTERVAL_MINUTE_TO_SECOND = 100 + SQL_CODE_MINUTE_TO_SECOND;
+}//[Yes] #endif
+
+
+static if ((ODBCVER >= 0x0201) && (ODBCVER < 0x0300)) {
+enum SQL_OJ_CAPABILITIES = 65003;
+}
+
+static if (ODBCVER >= 0x0250) {
+enum SQL_NO_ACTION   = 3;
+enum SQL_SET_DEFAULT = 4;
+}
+
+static if (ODBCVER >= 0x0300) {
+enum SQL_ACTIVE_ENVIRONMENTS = 116;
+enum SQL_AD_ADD_CONSTRAINT_DEFERRABLE = 0x00000080L;
+enum SQL_AD_ADD_CONSTRAINT_INITIALLY_DEFERRED = 0x00000020L;
+enum SQL_AD_ADD_CONSTRAINT_INITIALLY_IMMEDIATE = 0x00000040L;
+enum SQL_AD_ADD_CONSTRAINT_NON_DEFERRABLE = 0x00000100L;
+enum SQL_AD_ADD_DOMAIN_CONSTRAINT = 0x00000002L;
+enum SQL_AD_ADD_DOMAIN_DEFAULT = 0x00000008L;
+enum SQL_AD_CONSTRAINT_NAME_DEFINITION = 0x00000001L;
+enum SQL_AD_DROP_DOMAIN_CONSTRAINT = 0x00000004L;
+enum SQL_AD_DROP_DOMAIN_DEFAULT = 0x00000010L;
+enum SQL_AF_ALL = 0x00000040L;
+enum SQL_AF_AVG = 0x00000001L;
+enum SQL_AF_COUNT = 0x00000002L;
+enum SQL_AF_DISTINCT = 0x00000020L;
+enum SQL_AF_MAX = 0x00000004L;
+enum SQL_AF_MIN = 0x00000008L;
+enum SQL_AF_SUM = 0x00000010L;
+enum SQL_AGGREGATE_FUNCTIONS = 169;
+enum SQL_ALL_CATALOGS = "%";
+enum SQL_ALL_SCHEMAS = "%";
+enum SQL_ALL_TABLE_TYPES = "%";
+enum SQL_ALTER_DOMAIN = 117;
+enum SQL_AM_CONNECTION = 1;
+enum SQL_AM_NONE = 0;
+enum SQL_AM_STATEMENT = 2;
+enum SQL_API_ODBC3_ALL_FUNCTIONS = 999;
+enum SQL_API_ODBC3_ALL_FUNCTIONS_SIZE = 250;
+enum SQL_API_SQLALLOCHANDLESTD = 73;
+enum SQL_API_SQLBULKOPERATIONS = 24;
+enum SQL_ASYNC_MODE = 10021;
+enum SQL_AT_ADD_COLUMN_COLLATION = 0x00000080L;
+enum SQL_AT_ADD_COLUMN_DEFAULT = 0x00000040L;
+enum SQL_AT_ADD_COLUMN_SINGLE = 0x00000020L;
+enum SQL_AT_ADD_TABLE_CONSTRAINT = 0x00001000L;
+enum SQL_AT_CONSTRAINT_DEFERRABLE = 0x00040000L;
+enum SQL_AT_CONSTRAINT_INITIALLY_DEFERRED = 0x00010000L;
+enum SQL_AT_CONSTRAINT_INITIALLY_IMMEDIATE = 0x00020000L;
+enum SQL_AT_CONSTRAINT_NAME_DEFINITION = 0x00008000L;
+enum SQL_AT_CONSTRAINT_NON_DEFERRABLE = 0x00080000L;
+enum SQL_AT_DROP_COLUMN_CASCADE = 0x00000400L;
+enum SQL_AT_DROP_COLUMN_DEFAULT = 0x00000200L;
+enum SQL_AT_DROP_COLUMN_RESTRICT = 0x00000800L;
+enum SQL_AT_DROP_TABLE_CONSTRAINT_CASCADE = 0x00002000L;
+enum SQL_AT_DROP_TABLE_CONSTRAINT_RESTRICT = 0x00004000L;
+enum SQL_AT_SET_COLUMN_DEFAULT = 0x00000100L;
+enum SQL_ATTR_ACCESS_MODE = SQL_ACCESS_MODE;
+enum SQL_ATTR_ASYNC_ENABLE = 4;
+enum SQL_ATTR_AUTOCOMMIT = SQL_AUTOCOMMIT;
+enum SQL_ATTR_CONCURRENCY = SQL_CONCURRENCY;
+enum SQL_ATTR_CONNECTION_POOLING = 201;
+enum SQL_ATTR_CONNECTION_TIMEOUT = 113;
+enum SQL_ATTR_CP_MATCH = 202;
+enum SQL_ATTR_CURRENT_CATALOG = SQL_CURRENT_QUALIFIER;
+enum SQL_ATTR_CURSOR_TYPE = SQL_CURSOR_TYPE;
+enum SQL_ATTR_DISCONNECT_BEHAVIOR = 114;
+enum SQL_ATTR_ENABLE_AUTO_IPD = 15;
+enum SQL_ATTR_ENLIST_IN_DTC = 1207;
+enum SQL_ATTR_ENLIST_IN_XA = 1208;
+enum SQL_ATTR_FETCH_BOOKMARK_PTR = 16;
+enum SQL_ATTR_KEYSET_SIZE = SQL_KEYSET_SIZE;
+enum SQL_ATTR_LOGIN_TIMEOUT = SQL_LOGIN_TIMEOUT;
+enum SQL_ATTR_MAX_LENGTH = SQL_MAX_LENGTH;
+enum SQL_ATTR_MAX_ROWS = SQL_MAX_ROWS;
+enum SQL_ATTR_NOSCAN = SQL_NOSCAN;
+enum SQL_ATTR_ODBC_CURSORS = SQL_ODBC_CURSORS;
+enum SQL_ATTR_ODBC_VERSION = 200;
+enum SQL_ATTR_PACKET_SIZE = SQL_PACKET_SIZE;
+enum SQL_ATTR_PARAM_BIND_OFFSET_PTR = 17;
+enum SQL_ATTR_PARAM_BIND_TYPE = 18;
+enum SQL_ATTR_PARAM_OPERATION_PTR = 19;
+enum SQL_ATTR_PARAM_STATUS_PTR = 20;
+enum SQL_ATTR_PARAMS_PROCESSED_PTR = 21;
+enum SQL_ATTR_PARAMSET_SIZE = 22;
+enum SQL_ATTR_QUERY_TIMEOUT = SQL_QUERY_TIMEOUT;
+enum SQL_ATTR_QUIET_MODE = SQL_QUIET_MODE;
+enum SQL_ATTR_RETRIEVE_DATA = SQL_RETRIEVE_DATA;
+enum SQL_ATTR_ROW_ARRAY_SIZE = 27;
+enum SQL_ATTR_ROW_BIND_OFFSET_PTR = 23;
+enum SQL_ATTR_ROW_BIND_TYPE = SQL_BIND_TYPE;
+enum SQL_ATTR_ROW_NUMBER = SQL_ROW_NUMBER;
+enum SQL_ATTR_ROW_OPERATION_PTR = 24;
+enum SQL_ATTR_ROW_STATUS_PTR = 25;
+enum SQL_ATTR_ROWS_FETCHED_PTR = 26;
+enum SQL_ATTR_SIMULATE_CURSOR = SQL_SIMULATE_CURSOR;
+enum SQL_ATTR_TRACE = SQL_OPT_TRACE;
+enum SQL_ATTR_TRACEFILE = SQL_OPT_TRACEFILE;
+enum SQL_ATTR_TRANSLATE_LIB = SQL_TRANSLATE_DLL;
+enum SQL_ATTR_TRANSLATE_OPTION = SQL_TRANSLATE_OPTION;
+enum SQL_ATTR_TXN_ISOLATION = SQL_TXN_ISOLATION;
+enum SQL_ATTR_USE_BOOKMARKS = SQL_USE_BOOKMARKS;
+enum SQL_BATCH_ROW_COUNT = 120;
+enum SQL_BATCH_SUPPORT = 121;
+enum SQL_BRC_EXPLICIT = 0x0000002;
+enum SQL_BRC_PROCEDURES = 0x0000001;
+enum SQL_BRC_ROLLED_UP = 0x0000004;
+enum SQL_BS_ROW_COUNT_EXPLICIT = 0x00000002L;
+enum SQL_BS_ROW_COUNT_PROC = 0x00000008L;
+enum SQL_BS_SELECT_EXPLICIT = 0x00000001L;
+enum SQL_BS_SELECT_PROC = 0x00000004L;
+enum SQL_C_INTERVAL_DAY = SQL_INTERVAL_DAY;
+enum SQL_C_INTERVAL_DAY_TO_HOUR = SQL_INTERVAL_DAY_TO_HOUR;
+enum SQL_C_INTERVAL_DAY_TO_MINUTE = SQL_INTERVAL_DAY_TO_MINUTE;
+enum SQL_C_INTERVAL_DAY_TO_SECOND = SQL_INTERVAL_DAY_TO_SECOND;
+enum SQL_C_INTERVAL_HOUR = SQL_INTERVAL_HOUR;
+enum SQL_C_INTERVAL_HOUR_TO_MINUTE = SQL_INTERVAL_HOUR_TO_MINUTE;
+enum SQL_C_INTERVAL_HOUR_TO_SECOND = SQL_INTERVAL_HOUR_TO_SECOND;
+enum SQL_C_INTERVAL_MINUTE = SQL_INTERVAL_MINUTE;
+enum SQL_C_INTERVAL_MINUTE_TO_SECOND = SQL_INTERVAL_MINUTE_TO_SECOND;
+enum SQL_C_INTERVAL_MONTH = SQL_INTERVAL_MONTH;
+enum SQL_C_INTERVAL_SECOND = SQL_INTERVAL_SECOND;
+enum SQL_C_INTERVAL_YEAR = SQL_INTERVAL_YEAR;
+enum SQL_C_INTERVAL_YEAR_TO_MONTH = SQL_INTERVAL_YEAR_TO_MONTH;
+enum SQL_C_NUMERIC = SQL_NUMERIC;
+enum SQL_C_SBIGINT = SQL_BIGINT+SQL_SIGNED_OFFSET;
+enum SQL_C_TYPE_DATE = SQL_TYPE_DATE;
+enum SQL_C_TYPE_TIME = SQL_TYPE_TIME;
+enum SQL_C_TYPE_TIMESTAMP = SQL_TYPE_TIMESTAMP;
+enum SQL_C_UBIGINT = SQL_BIGINT+SQL_UNSIGNED_OFFSET;
+enum SQL_C_VARBOOKMARK = SQL_C_BINARY;
+enum SQL_CA_CONSTRAINT_DEFERRABLE = 0x00000040L;
+enum SQL_CA_CONSTRAINT_INITIALLY_DEFERRED = 0x00000010L;
+enum SQL_CA_CONSTRAINT_INITIALLY_IMMEDIATE = 0x00000020L;
+enum SQL_CA_CONSTRAINT_NON_DEFERRABLE = 0x00000080L;
+enum SQL_CA_CREATE_ASSERTION = 0x00000001L;
+enum SQL_CA1_ABSOLUTE = 0x00000002L;
+enum SQL_CA1_BOOKMARK = 0x00000008L;
+enum SQL_CA1_BULK_ADD = 0x00010000L;
+enum SQL_CA1_BULK_DELETE_BY_BOOKMARK = 0x00040000L;
+enum SQL_CA1_BULK_FETCH_BY_BOOKMARK = 0x00080000L;
+enum SQL_CA1_BULK_UPDATE_BY_BOOKMARK = 0x00020000L;
+enum SQL_CA1_LOCK_EXCLUSIVE = 0x00000080L;
+enum SQL_CA1_LOCK_NO_CHANGE = 0x00000040L;
+enum SQL_CA1_LOCK_UNLOCK = 0x00000100L;
+enum SQL_CA1_NEXT = 0x00000001L;
+enum SQL_CA1_POS_DELETE = 0x00000800L;
+enum SQL_CA1_POS_POSITION = 0x00000200L;
+enum SQL_CA1_POS_REFRESH = 0x00001000L;
+enum SQL_CA1_POS_UPDATE = 0x00000400L;
+enum SQL_CA1_POSITIONED_DELETE = 0x00004000L;
+enum SQL_CA1_POSITIONED_UPDATE = 0x00002000L;
+enum SQL_CA1_RELATIVE = 0x00000004L;
+enum SQL_CA1_SELECT_FOR_UPDATE = 0x00008000L;
+enum SQL_CA2_CRC_APPROXIMATE = 0x00002000L;
+enum SQL_CA2_CRC_EXACT = 0x00001000L;
+enum SQL_CA2_LOCK_CONCURRENCY = 0x00000002L;
+
+enum SQL_CA2_MAX_ROWS_CATALOG = 0x00000800L;
+enum SQL_CA2_MAX_ROWS_DELETE  = 0x00000200L;
+enum SQL_CA2_MAX_ROWS_INSERT  = 0x00000100L;
+enum SQL_CA2_MAX_ROWS_SELECT  = 0x00000080L;
+enum SQL_CA2_MAX_ROWS_UPDATE  = 0x00000400L;
+enum SQL_CA2_MAX_ROWS_AFFECTS_ALL = SQL_CA2_MAX_ROWS_SELECT | SQL_CA2_MAX_ROWS_INSERT |
+        SQL_CA2_MAX_ROWS_DELETE | SQL_CA2_MAX_ROWS_UPDATE | SQL_CA2_MAX_ROWS_CATALOG;
+
+enum SQL_CA2_OPT_ROWVER_CONCURRENCY = 0x00000004L;
+enum SQL_CA2_OPT_VALUES_CONCURRENCY = 0x00000008L;
+enum SQL_CA2_READ_ONLY_CONCURRENCY = 0x00000001L;
+enum SQL_CA2_SENSITIVITY_ADDITIONS = 0x00000010L;
+enum SQL_CA2_SENSITIVITY_DELETIONS = 0x00000020L;
+enum SQL_CA2_SENSITIVITY_UPDATES = 0x00000040L;
+enum SQL_CA2_SIMULATE_NON_UNIQUE = 0x00004000L;
+enum SQL_CA2_SIMULATE_TRY_UNIQUE = 0x00008000L;
+enum SQL_CA2_SIMULATE_UNIQUE = 0x00010000L;
+enum SQL_CATALOG_LOCATION = SQL_QUALIFIER_LOCATION;
+enum SQL_CATALOG_NAME_SEPARATOR = SQL_QUALIFIER_NAME_SEPARATOR;
+enum SQL_CATALOG_TERM = SQL_QUALIFIER_TERM;
+enum SQL_CATALOG_USAGE = SQL_QUALIFIER_USAGE;
+enum SQL_CCOL_CREATE_COLLATION = 0x00000001L;
+enum SQL_CCS_COLLATE_CLAUSE = 0x00000002L;
+enum SQL_CCS_CREATE_CHARACTER_SET = 0x00000001L;
+enum SQL_CCS_LIMITED_COLLATION = 0x00000004L;
+enum SQL_CDO_COLLATION = 0x00000008L;
+enum SQL_CDO_CONSTRAINT = 0x00000004L;
+enum SQL_CDO_CONSTRAINT_DEFERRABLE = 0x00000080L;
+enum SQL_CDO_CONSTRAINT_INITIALLY_DEFERRED = 0x00000020L;
+enum SQL_CDO_CONSTRAINT_INITIALLY_IMMEDIATE = 0x00000040L;
+enum SQL_CDO_CONSTRAINT_NAME_DEFINITION = 0x00000010L;
+enum SQL_CDO_CONSTRAINT_NON_DEFERRABLE = 0x00000100L;
+enum SQL_CDO_CREATE_DOMAIN = 0x00000001L;
+enum SQL_CDO_DEFAULT = 0x00000002L;
+enum SQL_CL_END = SQL_QL_END;
+enum SQL_CL_START = SQL_QL_START;
+enum SQL_COL_PRED_BASIC = SQL_ALL_EXCEPT_LIKE;
+enum SQL_COL_PRED_CHAR = SQL_LIKE_ONLY;
+enum SQL_COLUMN_DRIVER_START = 1000;
+enum SQL_COLUMN_IGNORE = SQL_IGNORE;
+enum SQL_COLUMN_NUMBER_UNKNOWN = -2;
+enum SQL_CONVERT_GUID = 173;
+
+enum SQL_CONVERT_WCHAR               = 122;
+enum SQL_CONVERT_INTERVAL_DAY_TIME   = 123;
+enum SQL_CONVERT_INTERVAL_YEAR_MONTH = 124;
+enum SQL_CONVERT_WLONGVARCHAR        = 125;
+enum SQL_CONVERT_WVARCHAR            = 126;
+
+enum SQL_CREATE_ASSERTION     = 127;
+enum SQL_CREATE_CHARACTER_SET = 128;
+enum SQL_CREATE_COLLATION     = 129;
+enum SQL_CREATE_DOMAIN        = 130;
+enum SQL_CREATE_SCHEMA        = 131;
+enum SQL_CREATE_TABLE         = 132;
+enum SQL_CREATE_TRANSLATION   = 133;
+enum SQL_CREATE_VIEW          = 134;
+
+
+enum SQL_CP_OFF            = 0UL;
+enum SQL_CP_DEFAULT        = SQL_CP_OFF;
+enum SQL_CP_ONE_PER_DRIVER = 1UL;
+enum SQL_CP_ONE_PER_HENV   = 2UL;
+
+enum SQL_CP_STRICT_MATCH  = 0UL;
+enum SQL_CP_MATCH_DEFAULT = SQL_CP_STRICT_MATCH;
+enum SQL_CP_RELAXED_MATCH = 1UL;
+
+enum SQL_CS_CREATE_SCHEMA         = 0x00000001L;
+enum SQL_CS_AUTHORIZATION         = 0x00000002L;
+enum SQL_CS_DEFAULT_CHARACTER_SET = 0x00000004L;
+
+enum SQL_CT_COLUMN_COLLATION = 0x00000800L;
+enum SQL_CT_COLUMN_CONSTRAINT = 0x00000200L;
+enum SQL_CT_COLUMN_DEFAULT = 0x00000400L;
+enum SQL_CT_COMMIT_DELETE = 0x00000004L;
+enum SQL_CT_COMMIT_PRESERVE = 0x00000002L;
+enum SQL_CT_CONSTRAINT_DEFERRABLE = 0x00000080L;
+enum SQL_CT_CONSTRAINT_INITIALLY_DEFERRED = 0x00000020L;
+enum SQL_CT_CONSTRAINT_INITIALLY_IMMEDIATE = 0x00000040L;
+enum SQL_CT_CONSTRAINT_NAME_DEFINITION = 0x00002000L;
+enum SQL_CT_CONSTRAINT_NON_DEFERRABLE = 0x00000100L;
+enum SQL_CT_CREATE_TABLE = 0x00000001L;
+enum SQL_CT_GLOBAL_TEMPORARY = 0x00000008L;
+enum SQL_CT_LOCAL_TEMPORARY = 0x00000010L;
+enum SQL_CT_TABLE_CONSTRAINT = 0x00001000L;
+
+enum SQL_CTR_CREATE_TRANSLATION = 0x00000001L;
+
+enum SQL_CU_DML_STATEMENTS = SQL_QU_DML_STATEMENTS;
+enum SQL_CU_INDEX_DEFINITION = SQL_QU_INDEX_DEFINITION;
+enum SQL_CU_PRIVILEGE_DEFINITION = SQL_QU_PRIVILEGE_DEFINITION;
+enum SQL_CU_PROCEDURE_INVOCATION = SQL_QU_PROCEDURE_INVOCATION;
+enum SQL_CU_TABLE_DEFINITION = SQL_QU_TABLE_DEFINITION;
+
+enum SQL_CVT_INTERVAL_YEAR_MONTH = 0x00080000L;
+enum SQL_CVT_INTERVAL_DAY_TIME   = 0x00100000L;
+enum SQL_CVT_WCHAR               = 0x00200000L;
+enum SQL_CVT_WLONGVARCHAR        = 0x00400000L;
+enum SQL_CVT_WVARCHAR            = 0x00800000L;
+enum SQL_CVT_GUID                = 0x01000000L;
+
+enum SQL_DA_DROP_ASSERTION = 0x00000001L;
+enum SQL_DATETIME_LITERALS = 119;
+
+enum SQL_DB_DISCONNECT     = 1UL;
+enum SQL_DB_RETURN_TO_POOL = 0UL;
+enum SQL_DB_DEFAULT        = SQL_DB_RETURN_TO_POOL;
+
+enum SQL_DC_DROP_COLLATION = 0x00000001L;
+enum SQL_DCS_DROP_CHARACTER_SET = 0x00000001L;
+enum SQL_DD_CASCADE = 0x00000004L;
+enum SQL_DD_DROP_DOMAIN = 0x00000001L;
+enum SQL_DD_RESTRICT = 0x00000002L;
+enum SQL_DDL_INDEX = 170;
+enum SQL_DELETE_BY_BOOKMARK = 6;
+enum SQL_DESC_ARRAY_SIZE = 20;
+enum SQL_DESC_ARRAY_STATUS_PTR = 21;
+enum SQL_DESC_AUTO_UNIQUE_VALUE = SQL_COLUMN_AUTO_INCREMENT;
+enum SQL_DESC_BASE_COLUMN_NAME = 22;
+enum SQL_DESC_BASE_TABLE_NAME = 23;
+enum SQL_DESC_BIND_OFFSET_PTR = 24;
+enum SQL_DESC_BIND_TYPE = 25;
+enum SQL_DESC_CASE_SENSITIVE = SQL_COLUMN_CASE_SENSITIVE;
+enum SQL_DESC_CATALOG_NAME = SQL_COLUMN_QUALIFIER_NAME;
+enum SQL_DESC_CONCISE_TYPE = SQL_COLUMN_TYPE;
+enum SQL_DESC_DATETIME_INTERVAL_PRECISION = 26;
+enum SQL_DESC_DISPLAY_SIZE = SQL_COLUMN_DISPLAY_SIZE;
+enum SQL_DESC_FIXED_PREC_SCALE = SQL_COLUMN_MONEY;
+enum SQL_DESC_LABEL = SQL_COLUMN_LABEL;
+enum SQL_DESC_LITERAL_PREFIX = 27;
+enum SQL_DESC_LITERAL_SUFFIX = 28;
+enum SQL_DESC_LOCAL_TYPE_NAME = 29;
+enum SQL_DESC_MAXIMUM_SCALE = 30;
+enum SQL_DESC_MINIMUM_SCALE = 31;
+enum SQL_DESC_NUM_PREC_RADIX = 32;
+enum SQL_DESC_PARAMETER_TYPE = 33;
+enum SQL_DESC_ROWS_PROCESSED_PTR = 34;
+enum SQL_DESC_SCHEMA_NAME = SQL_COLUMN_OWNER_NAME;
+enum SQL_DESC_SEARCHABLE = SQL_COLUMN_SEARCHABLE;
+enum SQL_DESC_TABLE_NAME = SQL_COLUMN_TABLE_NAME;
+enum SQL_DESC_TYPE_NAME = SQL_COLUMN_TYPE_NAME;
+enum SQL_DESC_UNSIGNED = SQL_COLUMN_UNSIGNED;
+enum SQL_DESC_UPDATABLE = SQL_COLUMN_UPDATABLE;
+enum SQL_DI_CREATE_INDEX = 0x00000001L;
+enum SQL_DI_DROP_INDEX = 0x00000002L;
+
+enum SQL_DIAG_COLUMN_NUMBER = -1247;
+enum SQL_DIAG_ROW_NUMBER = -1248;
+enum SQL_DIAG_CURSOR_ROW_COUNT = -1249;
+
+enum SQL_DL_SQL92_DATE = 0x00000001L;
+enum SQL_DL_SQL92_INTERVAL_DAY = 0x00000020L;
+enum SQL_DL_SQL92_INTERVAL_DAY_TO_HOUR = 0x00000400L;
+enum SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTE = 0x00000800L;
+enum SQL_DL_SQL92_INTERVAL_DAY_TO_SECOND = 0x00001000L;
+enum SQL_DL_SQL92_INTERVAL_HOUR = 0x00000040L;
+enum SQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTE = 0x00002000L;
+enum SQL_DL_SQL92_INTERVAL_HOUR_TO_SECOND = 0x00004000L;
+enum SQL_DL_SQL92_INTERVAL_MINUTE = 0x00000080L;
+enum SQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND = 0x00008000L;
+enum SQL_DL_SQL92_INTERVAL_MONTH = 0x00000010L;
+enum SQL_DL_SQL92_INTERVAL_SECOND = 0x00000100L;
+enum SQL_DL_SQL92_INTERVAL_YEAR = 0x00000008L;
+enum SQL_DL_SQL92_INTERVAL_YEAR_TO_MONTH = 0x00000200L;
+enum SQL_DL_SQL92_TIME = 0x00000002L;
+enum SQL_DL_SQL92_TIMESTAMP = 0x00000004L;
+enum SQL_DM_VER = 171;
+enum SQL_DRIVER_HDESC = 135;
+enum SQL_DROP_ASSERTION = 136;
+enum SQL_DROP_CHARACTER_SET = 137;
+enum SQL_DROP_COLLATION = 138;
+enum SQL_DROP_DOMAIN = 139;
+enum SQL_DROP_SCHEMA = 140;
+enum SQL_DROP_TABLE = 141;
+enum SQL_DROP_TRANSLATION = 142;
+enum SQL_DROP_VIEW = 143;
+enum SQL_DS_CASCADE = 0x00000004L;
+enum SQL_DS_DROP_SCHEMA = 0x00000001L;
+enum SQL_DS_RESTRICT = 0x00000002L;
+enum SQL_DT_CASCADE = 0x00000004L;
+enum SQL_DT_DROP_TABLE = 0x00000001L;
+enum SQL_DT_RESTRICT = 0x00000002L;
+enum SQL_DTC_DONE = 0L;
+enum SQL_DTR_DROP_TRANSLATION = 0x00000001L;
+enum SQL_DV_CASCADE = 0x00000004L;
+enum SQL_DV_DROP_VIEW = 0x00000001L;
+enum SQL_DV_RESTRICT = 0x00000002L;
+enum SQL_DYNAMIC_CURSOR_ATTRIBUTES1 = 144;
+enum SQL_DYNAMIC_CURSOR_ATTRIBUTES2 = 145;
+enum SQL_EXT_API_LAST = SQL_API_SQLBINDPARAMETER;
+enum SQL_EXT_API_START = 40;
+enum SQL_FETCH_BY_BOOKMARK = 7;
+enum SQL_FETCH_FIRST_SYSTEM = 32;
+enum SQL_FETCH_FIRST_USER = 31;
+enum SQL_FN_CVT_CAST = 0x00000002L;
+enum SQL_FN_STR_BIT_LENGTH = 0x00080000L;
+enum SQL_FN_STR_CHAR_LENGTH = 0x00100000L;
+enum SQL_FN_STR_CHARACTER_LENGTH = 0x00200000L;
+enum SQL_FN_STR_OCTET_LENGTH = 0x00400000L;
+enum SQL_FN_STR_POSITION = 0x00800000L;
+enum SQL_FN_TD_CURRENT_DATE = 0x00020000L;
+enum SQL_FN_TD_CURRENT_TIME = 0x00040000L;
+enum SQL_FN_TD_CURRENT_TIMESTAMP = 0x00080000L;
+enum SQL_FN_TD_EXTRACT = 0x00100000L;
+enum SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1 = 146;
+enum SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 = 147;
+    /* #define SQL_FUNC_EXISTS(exists, api)
+       ((*(((UWORD*) (exists)) + ((api) >> 4)) & (1 << ((api) & 15)) ) ?
+       SQL_TRUE : SQL_FALSE )
+    */
+enum SQL_GB_COLLATE = 0x0004;
+enum SQL_HANDLE_SENV = 5;
+
+enum SQL_IK_NONE = 0;
+enum SQL_IK_ASC = 1;
+enum SQL_IK_DESC = 2;
+enum SQL_IK_ALL = SQL_IK_ASC | SQL_IK_DESC;
+
+enum SQL_INDEX_KEYWORDS = 148;
+enum SQL_INFO_DRIVER_START = 1000;
+enum SQL_INFO_LAST = SQL_QUALIFIER_LOCATION;
+enum SQL_INFO_SCHEMA_VIEWS = 149;
+enum SQL_INITIALLY_DEFERRED = 5;
+enum SQL_INITIALLY_IMMEDIATE = 6;
+enum SQL_INSERT_STATEMENT = 172;
+enum SQL_INTERVAL = 10;
+enum SQL_IS_INSERT_LITERALS = 0x00000001L;
+enum SQL_IS_INSERT_SEARCHED = 0x00000002L;
+enum SQL_IS_INTEGER = -6;
+enum SQL_IS_POINTER = -4;
+enum SQL_IS_SELECT_INTO = 0x00000004L;
+enum SQL_IS_SMALLINT = -8;
+enum SQL_IS_UINTEGER = -5;
+enum SQL_IS_USMALLINT = -7;
+enum SQL_ISV_ASSERTIONS = 0x00000001L;
+enum SQL_ISV_CHARACTER_SETS = 0x00000002L;
+enum SQL_ISV_CHECK_CONSTRAINTS = 0x00000004L;
+enum SQL_ISV_COLLATIONS = 0x00000008L;
+enum SQL_ISV_COLUMN_DOMAIN_USAGE = 0x00000010L;
+enum SQL_ISV_COLUMN_PRIVILEGES = 0x00000020L;
+enum SQL_ISV_COLUMNS = 0x00000040L;
+enum SQL_ISV_CONSTRAINT_COLUMN_USAGE = 0x00000080L;
+enum SQL_ISV_CONSTRAINT_TABLE_USAGE = 0x00000100L;
+enum SQL_ISV_DOMAIN_CONSTRAINTS = 0x00000200L;
+enum SQL_ISV_DOMAINS = 0x00000400L;
+enum SQL_ISV_KEY_COLUMN_USAGE = 0x00000800L;
+enum SQL_ISV_REFERENTIAL_CONSTRAINTS = 0x00001000L;
+enum SQL_ISV_SCHEMATA = 0x00002000L;
+enum SQL_ISV_SQL_LANGUAGES = 0x00004000L;
+enum SQL_ISV_TABLE_CONSTRAINTS = 0x00008000L;
+enum SQL_ISV_TABLE_PRIVILEGES = 0x00010000L;
+enum SQL_ISV_TABLES = 0x00020000L;
+enum SQL_ISV_TRANSLATIONS = 0x00040000L;
+enum SQL_ISV_USAGE_PRIVILEGES = 0x00080000L;
+enum SQL_ISV_VIEW_COLUMN_USAGE = 0x00100000L;
+enum SQL_ISV_VIEW_TABLE_USAGE = 0x00200000L;
+enum SQL_ISV_VIEWS = 0x00400000L;
+enum SQL_KEYSET_CURSOR_ATTRIBUTES1 = 150;
+enum SQL_KEYSET_CURSOR_ATTRIBUTES2 = 151;
+enum SQL_MAX_ASYNC_CONCURRENT_STATEMENTS = 10022;
+enum SQL_NO_COLUMN_NUMBER = -1;
+enum SQL_NO_ROW_NUMBER = -1;
+enum SQL_NOT_DEFERRABLE = 7;
+enum SQL_NUM_EXTENSIONS = SQL_EXT_API_LAST-SQL_EXT_API_START+1;
+enum SQL_NUM_FUNCTIONS = 23;
+enum SQL_ODBC_INTERFACE_CONFORMANCE = 152;
+
+    enum : ULONG {
+        SQL_OIC_CORE = 1,
+        SQL_OIC_LEVEL1,
+        SQL_OIC_LEVEL2
+    }
+    enum : ULONG {
+        SQL_OV_ODBC2 = 2,
+        SQL_OV_ODBC3 = 3
+    }
+
+enum ULONG
+        SQL_PARAM_BIND_BY_COLUMN = 0,
+        SQL_PARAM_BIND_TYPE_DEFAULT = SQL_PARAM_BIND_BY_COLUMN;
+
+enum SQL_PARAM_ARRAY_ROW_COUNTS = 153;
+enum SQL_PARAM_ARRAY_SELECTS = 154;
+enum SQL_PARAM_DIAG_UNAVAILABLE = 1;
+enum SQL_PARAM_ERROR = 5;
+enum SQL_PARAM_IGNORE = 1;
+enum SQL_PARAM_PROCEED = 0;
+enum SQL_PARAM_SUCCESS = 0;
+enum SQL_PARAM_SUCCESS_WITH_INFO = 6;
+enum SQL_PARAM_UNUSED = 7;
+
+enum SQL_PARC_BATCH = 1;
+enum SQL_PARC_NO_BATCH = 2;
+enum SQL_PAS_BATCH = 1;
+enum SQL_PAS_NO_BATCH = 2;
+enum SQL_PAS_NO_SELECT = 3;
+
+enum SQL_ROW_IGNORE = 1;
+enum SQL_ROW_NUMBER_UNKNOWN = -2;
+enum SQL_ROW_PROCEED = 0;
+enum SQL_ROW_SUCCESS_WITH_INFO = 6;
+
+enum SQL_SC_FIPS127_2_TRANSITIONAL = 0x00000002L;
+enum SQL_SC_SQL92_ENTRY = 0x00000001L;
+enum SQL_SC_SQL92_FULL = 0x00000008L;
+enum SQL_SC_SQL92_INTERMEDIATE = 0x00000004L;
+
+enum SQL_SCC_ISO92_CLI = 0x00000002L;
+enum SQL_SCC_XOPEN_CLI_VERSION1 = 0x00000001L;
+
+enum SQL_SCHEMA_TERM = SQL_OWNER_TERM;
+enum SQL_SCHEMA_USAGE = SQL_OWNER_USAGE;
+enum SQL_SDF_CURRENT_DATE = 0x00000001L;
+enum SQL_SDF_CURRENT_TIME = 0x00000002L;
+enum SQL_SDF_CURRENT_TIMESTAMP = 0x00000004L;
+enum SQL_SFKD_CASCADE = 0x00000001L;
+enum SQL_SFKD_NO_ACTION = 0x00000002L;
+enum SQL_SFKD_SET_DEFAULT = 0x00000004L;
+enum SQL_SFKD_SET_NULL = 0x00000008L;
+enum SQL_SFKU_CASCADE = 0x00000001L;
+enum SQL_SFKU_NO_ACTION = 0x00000002L;
+enum SQL_SFKU_SET_DEFAULT = 0x00000004L;
+enum SQL_SFKU_SET_NULL = 0x00000008L;
+enum SQL_SG_DELETE_TABLE = 0x00000020L;
+enum SQL_SG_INSERT_COLUMN = 0x00000080L;
+enum SQL_SG_INSERT_TABLE = 0x00000040L;
+enum SQL_SG_REFERENCES_COLUMN = 0x00000200L;
+enum SQL_SG_REFERENCES_TABLE = 0x00000100L;
+enum SQL_SG_SELECT_TABLE = 0x00000400L;
+enum SQL_SG_UPDATE_COLUMN = 0x00001000L;
+enum SQL_SG_UPDATE_TABLE = 0x00000800L;
+enum SQL_SG_USAGE_ON_CHARACTER_SET = 0x00000002L;
+enum SQL_SG_USAGE_ON_COLLATION = 0x00000004L;
+enum SQL_SG_USAGE_ON_DOMAIN = 0x00000001L;
+enum SQL_SG_USAGE_ON_TRANSLATION = 0x00000008L;
+enum SQL_SG_WITH_GRANT_OPTION = 0x00000010L;
+enum SQL_SNVF_BIT_LENGTH = 0x00000001L;
+enum SQL_SNVF_CHAR_LENGTH = 0x00000002L;
+enum SQL_SNVF_CHARACTER_LENGTH = 0x00000004L;
+enum SQL_SNVF_EXTRACT = 0x00000008L;
+enum SQL_SNVF_OCTET_LENGTH = 0x00000010L;
+enum SQL_SNVF_POSITION = 0x00000020L;
+enum SQL_SP_BETWEEN = 0x00000800L;
+enum SQL_SP_COMPARISON = 0x00001000L;
+enum SQL_SP_EXISTS = 0x00000001L;
+enum SQL_SP_IN = 0x00000400L;
+enum SQL_SP_ISNOTNULL = 0x00000002L;
+enum SQL_SP_ISNULL = 0x00000004L;
+enum SQL_SP_LIKE = 0x00000200L;
+enum SQL_SP_MATCH_FULL = 0x00000008L;
+enum SQL_SP_MATCH_PARTIAL = 0x00000010L;
+enum SQL_SP_MATCH_UNIQUE_FULL = 0x00000020L;
+enum SQL_SP_MATCH_UNIQUE_PARTIAL = 0x00000040L;
+enum SQL_SP_OVERLAPS = 0x00000080L;
+enum SQL_SP_QUANTIFIED_COMPARISON = 0x00002000L;
+enum SQL_SP_UNIQUE = 0x00000100L;
+enum SQL_SQL_CONFORMANCE = 118;
+enum SQL_SQL92_DATETIME_FUNCTIONS = 155;
+enum SQL_SQL92_FOREIGN_KEY_DELETE_RULE = 156;
+enum SQL_SQL92_FOREIGN_KEY_UPDATE_RULE = 157;
+enum SQL_SQL92_GRANT = 158;
+enum SQL_SQL92_NUMERIC_VALUE_FUNCTIONS = 159;
+enum SQL_SQL92_PREDICATES = 160;
+enum SQL_SQL92_RELATIONAL_JOIN_OPERATORS = 161;
+enum SQL_SQL92_REVOKE = 162;
+enum SQL_SQL92_ROW_VALUE_CONSTRUCTOR = 163;
+enum SQL_SQL92_STRING_FUNCTIONS = 164;
+enum SQL_SQL92_VALUE_EXPRESSIONS = 165;
+enum SQL_SR_CASCADE = 0x00000020L;
+enum SQL_SR_DELETE_TABLE = 0x00000080L;
+enum SQL_SR_GRANT_OPTION_FOR = 0x00000010L;
+enum SQL_SR_INSERT_COLUMN = 0x00000200L;
+enum SQL_SR_INSERT_TABLE = 0x00000100L;
+enum SQL_SR_REFERENCES_COLUMN = 0x00000800L;
+enum SQL_SR_REFERENCES_TABLE = 0x00000400L;
+enum SQL_SR_RESTRICT = 0x00000040L;
+enum SQL_SR_SELECT_TABLE = 0x00001000L;
+enum SQL_SR_UPDATE_COLUMN = 0x00004000L;
+enum SQL_SR_UPDATE_TABLE = 0x00002000L;
+enum SQL_SR_USAGE_ON_CHARACTER_SET = 0x00000002L;
+enum SQL_SR_USAGE_ON_COLLATION = 0x00000004L;
+enum SQL_SR_USAGE_ON_DOMAIN = 0x00000001L;
+enum SQL_SR_USAGE_ON_TRANSLATION = 0x00000008L;
+enum SQL_SRJO_CORRESPONDING_CLAUSE = 0x00000001L;
+enum SQL_SRJO_CROSS_JOIN = 0x00000002L;
+enum SQL_SRJO_EXCEPT_JOIN = 0x00000004L;
+enum SQL_SRJO_FULL_OUTER_JOIN = 0x00000008L;
+enum SQL_SRJO_INNER_JOIN = 0x00000010L;
+enum SQL_SRJO_INTERSECT_JOIN = 0x00000020L;
+enum SQL_SRJO_LEFT_OUTER_JOIN = 0x00000040L;
+enum SQL_SRJO_NATURAL_JOIN = 0x00000080L;
+enum SQL_SRJO_RIGHT_OUTER_JOIN = 0x00000100L;
+enum SQL_SRJO_UNION_JOIN = 0x00000200L;
+enum SQL_SRVC_DEFAULT = 0x00000004L;
+enum SQL_SRVC_NULL = 0x00000002L;
+enum SQL_SRVC_ROW_SUBQUERY = 0x00000008L;
+enum SQL_SRVC_VALUE_EXPRESSION = 0x00000001L;
+enum SQL_SSF_CONVERT = 0x00000001L;
+enum SQL_SSF_LOWER = 0x00000002L;
+enum SQL_SSF_SUBSTRING = 0x00000008L;
+enum SQL_SSF_TRANSLATE = 0x00000010L;
+enum SQL_SSF_TRIM_BOTH = 0x00000020L;
+enum SQL_SSF_TRIM_LEADING = 0x00000040L;
+enum SQL_SSF_TRIM_TRAILING = 0x00000080L;
+enum SQL_SSF_UPPER = 0x00000004L;
+enum SQL_STANDARD_CLI_CONFORMANCE = 166;
+enum SQL_STATIC_CURSOR_ATTRIBUTES1 = 167;
+enum SQL_STATIC_CURSOR_ATTRIBUTES2 = 168;
+enum SQL_SU_DML_STATEMENTS = SQL_OU_DML_STATEMENTS;
+enum SQL_SU_INDEX_DEFINITION = SQL_OU_INDEX_DEFINITION;
+enum SQL_SU_PRIVILEGE_DEFINITION = SQL_OU_PRIVILEGE_DEFINITION;
+enum SQL_SU_PROCEDURE_INVOCATION = SQL_OU_PROCEDURE_INVOCATION;
+enum SQL_SU_TABLE_DEFINITION = SQL_OU_TABLE_DEFINITION;
+enum SQL_SVE_CASE = 0x00000001L;
+enum SQL_SVE_CAST = 0x00000002L;
+enum SQL_SVE_COALESCE = 0x00000004L;
+enum SQL_SVE_NULLIF = 0x00000008L;
+enum SQL_UB_FIXED = SQL_UB_ON;
+enum SQL_UB_VARIABLE = 2UL;
+enum SQL_UNION_STATEMENT = SQL_UNION;
+enum SQL_UPDATE_BY_BOOKMARK = 5;
+enum SQL_US_UNION = SQL_U_UNION;
+enum SQL_US_UNION_ALL = SQL_U_UNION_ALL;
+}//[Yes] #endif /* ODBCVER >= 0x300 */
+static if (ODBCVER >= 0x0350) {
+enum SQL_DESC_ROWVER = 35;
+enum SQL_GUID = -11;
+enum SQL_C_GUID = SQL_GUID;
+    //#ifdef ODBC_STD
+    //#define SQLAllocHandle SQLAllocHandleStd
+    //#define SQLAllocEnv(p) SQLAllocHandleStd(SQL_HANDLE_ENV, SQL_NULL_HANDLE, p)
+    //#define SQL_YEAR SQL_CODE_YEAR
+    //#define SQL_MONTH SQL_CODE_MONTH
+    //#define SQL_DAY SQL_CODE_DAY
+    //#define SQL_HOUR SQL_CODE_HOUR
+    //#define SQL_MINUTE SQL_CODE_MINUTE
+    //#define SQL_SECOND SQL_CODE_SECOND
+    //#define SQL_YEAR_TO_MONTH SQL_CODE_YEAR_TO_MONTH
+    //#define SQL_DAY_TO_HOUR SQL_CODE_DAY_TO_HOUR
+    //#define SQL_DAY_TO_MINUTE SQL_CODE_DAY_TO_MINUTE
+    //#define SQL_DAY_TO_SECOND SQL_CODE_DAY_TO_SECOND
+    //#define SQL_HOUR_TO_MINUTE SQL_CODE_HOUR_TO_MINUTE
+    //#define SQL_HOUR_TO_SECOND SQL_CODE_HOUR_TO_SECOND
+    //#define SQL_MINUTE_TO_SECOND SQL_CODE_MINUTE_TO_SECOND
+    //#endif /* ODBC_STD */
+}//#endif /* ODBCVER >= 0x0350 */
+
+//static if (ODBCVER >= 0x0351) {
+enum SQL_ATTR_ANSI_APP=115;
+enum SQL_AA_TRUE=1L;
+enum SQL_AA_FALSE=0L;
+//}//[Yes] #endif
+
+enum TRACE_VERSION=1000;
+enum TRACE_ON=1;
+
+const char [] SQL_ODBC_KEYWORDS =
+    "ABSOLUTE, ACTION, ADA, ADD, ALL, ALLOCATE, ALTER, AND, ANY, ARE, AS, "
+    ~ "ASC, ASSERTION, AT, AUTHORIZATION, AVG, "
+    ~ "BEGIN, BETWEEN, BIT, BIT_LENGTH, BOTH, BY, CASCADE, CASCADED, CASE, CAST, CATALOG, "
+    ~ "CHAR, CHAR_LENGTH, CHARACTER, CHARACTER_LENGTH, CHECK, CLOSE, COALESCE, "
+    ~ "COLLATE, COLLATION, COLUMN, COMMIT, CONNECT, CONNECTION, CONSTRAINT, "
+    ~ "CONSTRAINTS, CONTINUE, CONVERT, CORRESPONDING, COUNT, CREATE, CROSS, CURRENT, "
+    ~ "CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, CURRENT_USER, CURSOR, "
+    ~ "DATE, DAY, DEALLOCATE, DEC, DECIMAL, DECLARE, DEFAULT, DEFERRABLE, "
+    ~ "DEFERRED, DELETE, DESC, DESCRIBE, DESCRIPTOR, DIAGNOSTICS, DISCONNECT, "
+    ~ "DISTINCT, DOMAIN, DOUBLE, DROP, "
+    ~ "ELSE, END, END-EXEC, ESCAPE, EXCEPT, EXCEPTION, EXEC, EXECUTE, "
+    ~ "EXISTS, EXTERNAL, EXTRACT, "
+    ~ "FALSE, FETCH, FIRST, FLOAT, FOR, FOREIGN, FORTRAN, FOUND, FROM, FULL, "
+    ~ "GET, GLOBAL, GO, GOTO, GRANT, GROUP, HAVING, HOUR, "
+    ~ "IDENTITY, IMMEDIATE, IN, INCLUDE, INDEX, INDICATOR, INITIALLY, INNER, "
+    ~ "INPUT, INSENSITIVE, INSERT, INT, INTEGER, INTERSECT, INTERVAL, INTO, IS, ISOLATION, "
+    ~ "JOIN, KEY, LANGUAGE, LAST, LEADING, LEFT, LEVEL, LIKE, LOCAL, LOWER, "
+    ~ "MATCH, MAX, MIN, MINUTE, MODULE, MONTH, "
+    ~ "NAMES, NATIONAL, NATURAL, NCHAR, NEXT, NO, NONE, NOT, NULL, NULLIF, NUMERIC, "
+    ~ "OCTET_LENGTH, OF, ON, ONLY, OPEN, OPTION, OR, ORDER, OUTER, OUTPUT, OVERLAPS, "
+    ~ "PAD, PARTIAL, PASCAL, PLI, POSITION, PRECISION, PREPARE, PRESERVE, "
+    ~ "PRIMARY, PRIOR, PRIVILEGES, PROCEDURE, PUBLIC, "
+    ~ "READ, REAL, REFERENCES, RELATIVE, RESTRICT, REVOKE, RIGHT, ROLLBACK, ROWS"
+    ~ "SCHEMA, SCROLL, SECOND, SECTION, SELECT, SESSION, SESSION_USER, SET, SIZE, "
+    ~ "SMALLINT, SOME, SPACE, SQL, SQLCA, SQLCODE, SQLERROR, SQLSTATE, SQLWARNING, "
+    ~ "SUBSTRING, SUM, SYSTEM_USER, "
+    ~ "TABLE, TEMPORARY, THEN, TIME, TIMESTAMP, TIMEZONE_HOUR, TIMEZONE_MINUTE, "
+    ~ "TO, TRAILING, TRANSACTION, TRANSLATE, TRANSLATION, TRIM, TRUE, "
+    ~ "UNION, UNIQUE, UNKNOWN, UPDATE, UPPER, USAGE, USER, USING, "
+    ~ "VALUE, VALUES, VARCHAR, VARYING, VIEW, WHEN, WHENEVER, WHERE, WITH, WORK, WRITE, "
+    ~ "YEAR, ZONE";
+extern (Windows) {
+    SQLRETURN SQLDriverConnect(SQLHDBC, SQLHWND, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLUSMALLINT);
+    SQLRETURN SQLBrowseConnect(SQLHDBC, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLColumnPrivileges(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLColAttributes(SQLHSTMT, SQLUSMALLINT, SQLUSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*, SQLLEN*);
+    SQLRETURN SQLDescribeParam(SQLHSTMT, SQLUSMALLINT, SQLSMALLINT*, SQLULEN*, SQLSMALLINT*, SQLSMALLINT*);
+    SQLRETURN SQLExtendedFetch(SQLHSTMT, SQLUSMALLINT, SQLINTEGER, SQLUINTEGER*, SQLUSMALLINT*);
+    SQLRETURN SQLForeignKeys(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLMoreResults(SQLHSTMT);
+    SQLRETURN SQLNativeSql(SQLHDBC, SQLCHAR*, SQLINTEGER, SQLCHAR*, SQLINTEGER, SQLINTEGER*);
+    SQLRETURN SQLNumParams(SQLHSTMT, SQLSMALLINT*);
+    SQLRETURN SQLParamOptions(SQLHSTMT, SQLUINTEGER, SQLUINTEGER*);
+    SQLRETURN SQLPrimaryKeys(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLProcedureColumns(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLProcedures(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLSetPos(SQLHSTMT, SQLUSMALLINT, SQLUSMALLINT, SQLUSMALLINT);
+    SQLRETURN SQLTablePrivileges(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLDrivers(SQLHENV, SQLUSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLBindParameter(SQLHSTMT, SQLUSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLULEN, SQLSMALLINT, SQLPOINTER, SQLLEN, SQLLEN*);
+    SQLRETURN SQLSetScrollOptions(SQLHSTMT, SQLUSMALLINT, SQLLEN, SQLUSMALLINT);/* deprecated */
+    DWORD ODBCGetTryWaitValue();
+    BOOL ODBCSetTryWaitValue(DWORD);
+    RETCODE TraceOpenLogFile(LPWSTR, LPWSTR, DWORD);
+    RETCODE TraceCloseLogFile();
+    VOID TraceReturn(RETCODE, RETCODE);
+    DWORD TraceVersion();
+    //static if (ODBCVER >= 0x0300) {
+    SQLRETURN SQLBulkOperations(SQLHSTMT, SQLSMALLINT);
+    SQLRETURN SQLAllocHandleStd( SQLSMALLINT, SQLHANDLE, SQLHANDLE*);
+    //}
+}
diff --git a/libphobos/libdruntime/core/sys/windows/sqltypes.d b/libphobos/libdruntime/core/sys/windows/sqltypes.d
new file mode 100644
index 00000000000..68e49757909
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/sqltypes.d
@@ -0,0 +1,144 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_sqltypes.d)
+ */
+module core.sys.windows.sqltypes;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+/* Conversion notes:
+  It's assumed that ODBC >= 0x0300.
+*/
+
+private import core.sys.windows.windef;
+private import core.sys.windows.basetyps; // for GUID
+
+alias byte SCHAR, SQLSCHAR;
+alias int SDWORD, SLONG, SQLINTEGER;
+alias short SWORD, SSHORT, RETCODE, SQLSMALLINT;
+alias ULONG UDWORD;
+alias USHORT UWORD, SQLUSMALLINT;
+alias double SDOUBLE, LDOUBLE;
+alias float SFLOAT;
+alias PVOID PTR, HENV, HDBC, HSTMT, SQLPOINTER;
+alias UCHAR SQLCHAR;
+// #ifndef _WIN64
+alias UDWORD SQLUINTEGER;
+// #endif
+
+//static if (ODBCVER >= 0x0300) {
+alias TypeDef!(HANDLE) SQLHANDLE;
+alias SQLHANDLE SQLHENV, SQLHDBC, SQLHSTMT, SQLHDESC;
+/*
+} else {
+alias void* SQLHENV;
+alias void* SQLHDBC;
+alias void* SQLHSTMT;
+}
+*/
+alias SQLSMALLINT SQLRETURN;
+alias HWND SQLHWND;
+alias ULONG BOOKMARK;
+
+alias SQLINTEGER SQLLEN, SQLROWOFFSET;
+alias SQLUINTEGER SQLROWCOUNT, SQLULEN;
+alias DWORD SQLTRANSID;
+alias SQLUSMALLINT SQLSETPOSIROW;
+alias wchar SQLWCHAR;
+
+version(Unicode) {
+    alias SQLWCHAR SQLTCHAR;
+} else {
+    alias SQLCHAR  SQLTCHAR;
+}
+//static if (ODBCVER >= 0x0300) {
+alias ubyte  SQLDATE, SQLDECIMAL;
+alias double SQLDOUBLE, SQLFLOAT;
+alias ubyte  SQLNUMERIC;
+alias float  SQLREAL;
+alias ubyte  SQLTIME, SQLTIMESTAMP, SQLVARCHAR;
+alias long   ODBCINT64, SQLBIGINT;
+alias ulong  SQLUBIGINT;
+//}
+
+struct DATE_STRUCT {
+    SQLSMALLINT year;
+    SQLUSMALLINT month;
+    SQLUSMALLINT day;
+}
+
+struct TIME_STRUCT {
+    SQLUSMALLINT hour;
+    SQLUSMALLINT minute;
+    SQLUSMALLINT second;
+}
+
+struct TIMESTAMP_STRUCT {
+    SQLSMALLINT year;
+    SQLUSMALLINT month;
+    SQLUSMALLINT day;
+    SQLUSMALLINT hour;
+    SQLUSMALLINT minute;
+    SQLUSMALLINT second;
+    SQLUINTEGER fraction;
+}
+
+//static if (ODBCVER >= 0x0300) {
+alias DATE_STRUCT SQL_DATE_STRUCT;
+alias TIME_STRUCT SQL_TIME_STRUCT;
+alias TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT;
+
+enum SQLINTERVAL {
+    SQL_IS_YEAR = 1,
+    SQL_IS_MONTH,
+    SQL_IS_DAY,
+    SQL_IS_HOUR,
+    SQL_IS_MINUTE,
+    SQL_IS_SECOND,
+    SQL_IS_YEAR_TO_MONTH,
+    SQL_IS_DAY_TO_HOUR,
+    SQL_IS_DAY_TO_MINUTE,
+    SQL_IS_DAY_TO_SECOND,
+    SQL_IS_HOUR_TO_MINUTE,
+    SQL_IS_HOUR_TO_SECOND,
+    SQL_IS_MINUTE_TO_SECOND
+}
+
+struct SQL_YEAR_MONTH_STRUCT {
+    SQLUINTEGER year;
+    SQLUINTEGER month;
+}
+
+struct SQL_DAY_SECOND_STRUCT {
+    SQLUINTEGER day;
+    SQLUINTEGER hour;
+    SQLUINTEGER minute;
+    SQLUINTEGER second;
+    SQLUINTEGER fraction;
+}
+
+struct SQL_INTERVAL_STRUCT {
+    SQLINTERVAL interval_type;
+    SQLSMALLINT interval_sign;
+    union _intval {
+        SQL_YEAR_MONTH_STRUCT year_month;
+        SQL_DAY_SECOND_STRUCT day_second;
+    }
+    _intval intval;
+}
+
+enum SQL_MAX_NUMERIC_LEN = 16;
+
+struct SQL_NUMERIC_STRUCT {
+    SQLCHAR precision;
+    SQLSCHAR scale;
+    SQLCHAR sign;
+    SQLCHAR[SQL_MAX_NUMERIC_LEN] val;
+}
+// } ODBCVER >= 0x0300
+alias GUID SQLGUID;
diff --git a/libphobos/libdruntime/core/sys/windows/sqlucode.d b/libphobos/libdruntime/core/sys/windows/sqlucode.d
new file mode 100644
index 00000000000..ea21f1e5481
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/sqlucode.d
@@ -0,0 +1,158 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_sqlucode.d)
+ */
+module core.sys.windows.sqlucode;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.sqlext;
+
+enum SQL_WCHAR        = -8;
+enum SQL_WVARCHAR     = -9;
+enum SQL_WLONGVARCHAR = -10;
+enum SQL_C_WCHAR      = SQL_WCHAR;
+
+enum SQL_SQLSTATE_SIZEW = 10;
+version(Unicode) {
+enum SQL_C_TCHAR = SQL_C_WCHAR;
+} else {
+enum SQL_C_TCHAR = SQL_C_CHAR;
+}
+
+// Moved from sqlext
+static if (ODBCVER <= 0x0300) {
+enum SQL_UNICODE             = -95;
+enum SQL_UNICODE_VARCHAR     = -96;
+enum SQL_UNICODE_LONGVARCHAR = -97;
+enum SQL_UNICODE_CHAR        = SQL_UNICODE;
+} else {
+enum SQL_UNICODE             = SQL_WCHAR;
+enum SQL_UNICODE_VARCHAR     = SQL_WVARCHAR;
+enum SQL_UNICODE_LONGVARCHAR = SQL_WLONGVARCHAR;
+enum SQL_UNICODE_CHAR        = SQL_WCHAR;
+}
+
+extern (Windows) {
+    SQLRETURN SQLBrowseConnectA(SQLHDBC, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLBrowseConnectW(SQLHDBC, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLColAttributeA(SQLHSTMT, SQLSMALLINT, SQLSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*, SQLPOINTER);
+    SQLRETURN SQLColAttributeW(SQLHSTMT, SQLUSMALLINT, SQLUSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*, SQLPOINTER);
+    SQLRETURN SQLColAttributesA(SQLHSTMT, SQLUSMALLINT, SQLUSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*, SQLLEN*);
+    SQLRETURN SQLColAttributesW(SQLHSTMT, SQLUSMALLINT, SQLUSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*, SQLLEN*);
+    SQLRETURN SQLColumnPrivilegesA( SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT , SQLCHAR*, SQLSMALLINT );
+    SQLRETURN SQLColumnPrivilegesW( SQLHSTMT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT );
+    SQLRETURN SQLColumnsA(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT , SQLCHAR*, SQLSMALLINT );
+    SQLRETURN SQLColumnsW(SQLHSTMT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT , SQLWCHAR*, SQLSMALLINT );
+    SQLRETURN SQLConnectA(SQLHDBC, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLConnectW(SQLHDBC, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT);
+    SQLRETURN SQLDataSourcesA(SQLHENV, SQLUSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLDataSourcesW(SQLHENV, SQLUSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLWCHAR*, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLDescribeColA(SQLHSTMT, SQLUSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLSMALLINT*, SQLULEN*, SQLSMALLINT*, SQLSMALLINT*);
+    SQLRETURN SQLDescribeColW(SQLHSTMT, SQLUSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLSMALLINT*, SQLULEN*, SQLSMALLINT*, SQLSMALLINT*);
+    SQLRETURN SQLDriverConnectA(SQLHDBC, SQLHWND, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLUSMALLINT);
+    SQLRETURN SQLDriverConnectW(SQLHDBC, SQLHWND, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLUSMALLINT);
+    SQLRETURN SQLDriversA(SQLHENV, SQLUSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLDriversW(SQLHENV, SQLUSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLWCHAR*, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLErrorA(SQLHENV, SQLHDBC, SQLHSTMT, SQLCHAR*, SQLINTEGER*, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLErrorW(SQLHENV, SQLHDBC, SQLHSTMT, SQLWCHAR*, SQLINTEGER*, SQLWCHAR*, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLExecDirectA(SQLHSTMT, SQLCHAR*, SQLINTEGER);
+    SQLRETURN SQLExecDirectW(SQLHSTMT, SQLWCHAR*, SQLINTEGER);
+    SQLRETURN SQLForeignKeysA(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLForeignKeysW(SQLHSTMT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT);
+    SQLRETURN SQLGetConnectAttrA(SQLHDBC, SQLINTEGER, SQLPOINTER, SQLINTEGER, SQLINTEGER*);
+    SQLRETURN SQLGetConnectAttrW(SQLHDBC, SQLINTEGER, SQLPOINTER, SQLINTEGER, SQLINTEGER*);
+    SQLRETURN SQLGetConnectOptionA(SQLHDBC, SQLUSMALLINT, SQLPOINTER);
+    SQLRETURN SQLGetConnectOptionW(SQLHDBC, SQLUSMALLINT, SQLPOINTER);
+    SQLRETURN SQLGetCursorNameA(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLGetCursorNameW(SQLHSTMT, SQLWCHAR*, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLGetInfoA(SQLHDBC, SQLUSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLGetInfoW(SQLHDBC, SQLUSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*);
+    SQLRETURN SQLGetTypeInfoA(SQLHSTMT, SQLSMALLINT);
+    SQLRETURN SQLGetTypeInfoW(SQLHSTMT, SQLSMALLINT);
+    SQLRETURN SQLNativeSqlA(SQLHDBC, SQLCHAR*, SQLINTEGER, SQLCHAR*, SQLINTEGER, SQLINTEGER*);
+    SQLRETURN SQLNativeSqlW(SQLHDBC, SQLWCHAR*, SQLINTEGER, SQLWCHAR*, SQLINTEGER, SQLINTEGER*);
+    SQLRETURN SQLPrepareA(SQLHSTMT, SQLCHAR*, SQLINTEGER);
+    SQLRETURN SQLPrepareW(SQLHSTMT, SQLWCHAR*, SQLINTEGER);
+    SQLRETURN SQLPrimaryKeysA(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT );
+    SQLRETURN SQLPrimaryKeysW(SQLHSTMT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT);
+    SQLRETURN SQLProcedureColumnsA(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLProcedureColumnsW(SQLHSTMT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT);
+    SQLRETURN SQLProceduresA(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLProceduresW(SQLHSTMT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT);
+    SQLRETURN SQLSetConnectAttrA(SQLHDBC, SQLINTEGER, SQLPOINTER, SQLINTEGER);
+    SQLRETURN SQLSetConnectAttrW(SQLHDBC, SQLINTEGER, SQLPOINTER, SQLINTEGER);
+    SQLRETURN SQLSetConnectOptionA(SQLHDBC, SQLUSMALLINT, SQLULEN);
+    SQLRETURN SQLSetConnectOptionW(SQLHDBC, SQLUSMALLINT, SQLULEN);
+    SQLRETURN SQLSetCursorNameA(SQLHSTMT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLSetCursorNameW(SQLHSTMT, SQLWCHAR*, SQLSMALLINT);
+    SQLRETURN SQLSpecialColumnsA(SQLHSTMT, SQLUSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT , SQLUSMALLINT, SQLUSMALLINT);
+    SQLRETURN SQLSpecialColumnsW(SQLHSTMT, SQLUSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT , SQLUSMALLINT, SQLUSMALLINT);
+    SQLRETURN SQLStatisticsA(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT , SQLUSMALLINT, SQLUSMALLINT);
+    SQLRETURN SQLStatisticsW(SQLHSTMT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT , SQLUSMALLINT, SQLUSMALLINT);
+    SQLRETURN SQLTablePrivilegesA(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLTablePrivilegesW(SQLHSTMT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT );
+    SQLRETURN SQLTablesA(SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
+    SQLRETURN SQLTablesW(SQLHSTMT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT);
+    static if (ODBCVER >= 0x0300) {
+        SQLRETURN SQLGetDescFieldA(SQLHDESC, SQLSMALLINT, SQLSMALLINT, SQLPOINTER, SQLINTEGER, SQLINTEGER*);
+        SQLRETURN SQLGetDescFieldW(SQLHDESC, SQLSMALLINT, SQLSMALLINT, SQLPOINTER, SQLINTEGER, SQLINTEGER*);
+        SQLRETURN SQLSetDescFieldA(SQLHDESC, SQLSMALLINT, SQLSMALLINT, SQLPOINTER, SQLINTEGER);
+        SQLRETURN SQLSetDescFieldW(SQLHDESC, SQLSMALLINT, SQLSMALLINT, SQLPOINTER, SQLINTEGER);
+        SQLRETURN SQLGetDescRecA(SQLHDESC, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLSMALLINT*, SQLSMALLINT*, SQLLEN*, SQLSMALLINT*, SQLSMALLINT*, SQLSMALLINT*);
+        SQLRETURN SQLGetDescRecW(SQLHDESC, SQLSMALLINT, SQLWCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLSMALLINT*, SQLSMALLINT*, SQLLEN*, SQLSMALLINT*, SQLSMALLINT*, SQLSMALLINT*);
+        SQLRETURN SQLGetDiagFieldA(SQLSMALLINT, SQLHANDLE, SQLSMALLINT, SQLSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*);
+        SQLRETURN SQLGetDiagFieldW(SQLSMALLINT, SQLHANDLE, SQLSMALLINT, SQLSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT*);
+        SQLRETURN SQLGetDiagRecA(SQLSMALLINT, SQLHANDLE, SQLSMALLINT, SQLCHAR*, SQLINTEGER*, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
+        SQLRETURN SQLGetDiagRecW(SQLSMALLINT, SQLHANDLE, SQLSMALLINT, SQLWCHAR*, SQLINTEGER*, SQLWCHAR*, SQLSMALLINT, SQLSMALLINT*);
+        SQLRETURN SQLGetStmtAttrA(SQLHSTMT, SQLINTEGER, SQLPOINTER, SQLINTEGER, SQLINTEGER*);
+        SQLRETURN SQLGetStmtAttrW(SQLHSTMT, SQLINTEGER, SQLPOINTER, SQLINTEGER, SQLINTEGER*);
+        SQLRETURN SQLSetStmtAttrA(SQLHSTMT, SQLINTEGER, SQLPOINTER, SQLINTEGER);
+        SQLRETURN SQLSetStmtAttrW(SQLHSTMT, SQLINTEGER, SQLPOINTER, SQLINTEGER);
+    } // #endif /* (ODBCVER >= 0x0300) */
+}
+
+version (Unicode) {
+    alias SQLBrowseConnectW SQLBrowseConnect;
+    alias SQLColAttributeW SQLColAttribute;
+    alias SQLColAttributesW SQLColAttributes;
+    alias SQLColumnPrivilegesW SQLColumnPrivileges;
+    alias SQLColumnsW SQLColumns;
+    alias SQLConnectW SQLConnect;
+    alias SQLDataSourcesW SQLDataSources;
+    alias SQLDescribeColW SQLDescribeCol;
+    alias SQLDriverConnectW SQLDriverConnect;
+    alias SQLDriversW SQLDrivers;
+    alias SQLErrorW SQLError;
+    alias SQLExecDirectW SQLExecDirect;
+    alias SQLForeignKeysW SQLForeignKeys;
+    alias SQLGetConnectAttrW SQLGetConnectAttr;
+    alias SQLGetConnectOptionW SQLGetConnectOption;
+    alias SQLGetCursorNameW SQLGetCursorName;
+    alias SQLGetDescFieldW SQLGetDescField;
+    alias SQLGetDescRecW SQLGetDescRec;
+    alias SQLGetDiagFieldW SQLGetDiagField;
+    alias SQLGetDiagRecW SQLGetDiagRec;
+    alias SQLGetInfoW SQLGetInfo;
+    alias SQLGetStmtAttrW SQLGetStmtAttr;
+    alias SQLGetTypeInfoW SQLGetTypeInfo;
+    alias SQLNativeSqlW SQLNativeSql;
+    alias SQLPrepareW SQLPrepare;
+    alias SQLPrimaryKeysW SQLPrimaryKeys;
+    alias SQLProcedureColumnsW SQLProcedureColumns;
+    alias SQLProceduresW SQLProcedures;
+    alias SQLSetConnectAttrW SQLSetConnectAttr;
+    alias SQLSetConnectOptionW SQLSetConnectOption;
+    alias SQLSetCursorNameW SQLSetCursorName;
+    alias SQLSetDescFieldW SQLSetDescField;
+    alias SQLSetStmtAttrW SQLSetStmtAttr;
+    alias SQLSpecialColumnsW SQLSpecialColumns;
+    alias SQLStatisticsW SQLStatistics;
+    alias SQLTablePrivilegesW SQLTablePrivileges;
+    alias SQLTablesW SQLTables;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/sspi.d b/libphobos/libdruntime/core/sys/windows/sspi.d
new file mode 100644
index 00000000000..4354139ca0d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/sspi.d
@@ -0,0 +1,382 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Ellery Newcomer
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_sspi.d)
+ */
+module core.sys.windows.sspi;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+import core.sys.windows.windef;
+import core.sys.windows.ntdef;
+import core.sys.windows.w32api;
+import core.sys.windows.security;
+import core.sys.windows.ntsecapi;
+import core.sys.windows.subauth;
+
+enum :ULONG{
+    SECPKG_CRED_INBOUND = 1,
+    SECPKG_CRED_OUTBOUND = 2,
+    SECPKG_CRED_BOTH = (SECPKG_CRED_OUTBOUND|SECPKG_CRED_INBOUND),
+    SECPKG_CRED_ATTR_NAMES = 1,
+}
+
+enum :ULONG{
+    SECPKG_FLAG_INTEGRITY = 1,
+    SECPKG_FLAG_PRIVACY = 2,
+    SECPKG_FLAG_TOKEN_ONLY = 4,
+    SECPKG_FLAG_DATAGRAM = 8,
+    SECPKG_FLAG_CONNECTION = 16,
+    SECPKG_FLAG_MULTI_REQUIRED = 32,
+    SECPKG_FLAG_CLIENT_ONLY = 64,
+    SECPKG_FLAG_EXTENDED_ERROR = 128,
+    SECPKG_FLAG_IMPERSONATION = 256,
+    SECPKG_FLAG_ACCEPT_WIN32_NAME = 512,
+    SECPKG_FLAG_STREAM = 1024,
+}
+
+enum :ULONG{
+    SECPKG_ATTR_AUTHORITY = 6,
+    SECPKG_ATTR_CONNECTION_INFO = 90,
+    SECPKG_ATTR_ISSUER_LIST = 80,
+    SECPKG_ATTR_ISSUER_LIST_EX = 89,
+    SECPKG_ATTR_KEY_INFO = 5,
+    SECPKG_ATTR_LIFESPAN = 2,
+    SECPKG_ATTR_LOCAL_CERT_CONTEXT = 84,
+    SECPKG_ATTR_LOCAL_CRED = 82,
+    SECPKG_ATTR_NAMES = 1,
+    SECPKG_ATTR_PROTO_INFO = 7,
+    SECPKG_ATTR_REMOTE_CERT_CONTEXT = 83,
+    SECPKG_ATTR_REMOTE_CRED = 81,
+    SECPKG_ATTR_SIZES = 0,
+    SECPKG_ATTR_STREAM_SIZES = 4,
+}
+
+enum :ULONG{
+    SECBUFFER_EMPTY = 0,
+    SECBUFFER_DATA = 1,
+    SECBUFFER_TOKEN = 2,
+    SECBUFFER_PKG_PARAMS = 3,
+    SECBUFFER_MISSING = 4,
+    SECBUFFER_EXTRA = 5,
+    SECBUFFER_STREAM_TRAILER = 6,
+    SECBUFFER_STREAM_HEADER = 7,
+    SECBUFFER_PADDING = 9,
+    SECBUFFER_STREAM = 10,
+    SECBUFFER_READONLY = 0x80000000,
+    SECBUFFER_ATTRMASK = 0xf0000000,
+}
+
+enum UNISP_NAME_A = "Microsoft Unified Security Protocol Provider";
+enum UNISP_NAME_W = "Microsoft Unified Security Protocol Provider"w;
+enum SECBUFFER_VERSION = 0;
+
+alias UNICODE_STRING SECURITY_STRING;
+alias UNICODE_STRING* PSECURITY_STRING;
+
+extern(Windows):
+
+struct SecHandle {
+    ULONG_PTR dwLower;
+    ULONG_PTR dwUpper;
+}
+alias SecHandle* PSecHandle;
+struct SecBuffer {
+    ULONG cbBuffer;
+    ULONG BufferType;
+    PVOID pvBuffer;
+}
+alias SecBuffer* PSecBuffer;
+alias SecHandle CredHandle;
+alias PSecHandle PCredHandle;
+alias SecHandle CtxtHandle;
+alias PSecHandle PCtxtHandle;
+struct SECURITY_INTEGER {
+    uint LowPart;
+    int HighPart;
+}
+alias SECURITY_INTEGER TimeStamp;
+alias SECURITY_INTEGER* PTimeStamp;
+struct SecBufferDesc {
+    ULONG ulVersion;
+    ULONG cBuffers;
+    PSecBuffer pBuffers;
+}
+alias SecBufferDesc* PSecBufferDesc;
+struct SecPkgContext_StreamSizes {
+    ULONG cbHeader;
+    ULONG cbTrailer;
+    ULONG cbMaximumMessage;
+    ULONG cBuffers;
+    ULONG cbBlockSize;
+}
+alias SecPkgContext_StreamSizes* PSecPkgContext_StreamSizes;
+struct SecPkgContext_Sizes {
+    ULONG cbMaxToken;
+    ULONG cbMaxSignature;
+    ULONG cbBlockSize;
+    ULONG cbSecurityTrailer;
+}
+alias SecPkgContext_Sizes* PSecPkgContext_Sizes;
+struct SecPkgContext_AuthorityW {
+    SEC_WCHAR* sAuthorityName;
+}
+alias SecPkgContext_AuthorityW* PSecPkgContext_AuthorityW;
+struct SecPkgContext_AuthorityA {
+    SEC_CHAR* sAuthorityName;
+}
+alias SecPkgContext_AuthorityA* PSecPkgContext_AuthorityA;
+struct SecPkgContext_KeyInfoW {
+    SEC_WCHAR* sSignatureAlgorithmName;
+    SEC_WCHAR* sEncryptAlgorithmName;
+    ULONG KeySize;
+    ULONG SignatureAlgorithm;
+    ULONG EncryptAlgorithm;
+}
+alias SecPkgContext_KeyInfoW* PSecPkgContext_KeyInfoW;
+struct SecPkgContext_KeyInfoA {
+    SEC_CHAR* sSignatureAlgorithmName;
+    SEC_CHAR* sEncryptAlgorithmName;
+    ULONG KeySize;
+    ULONG SignatureAlgorithm;
+    ULONG EncryptAlgorithm;
+}
+alias SecPkgContext_KeyInfoA* PSecPkgContext_KeyInfoA;
+struct SecPkgContext_LifeSpan {
+    TimeStamp tsStart;
+    TimeStamp tsExpiry;
+}
+alias SecPkgContext_LifeSpan* PSecPkgContext_LifeSpan;
+struct SecPkgContext_NamesW {
+    SEC_WCHAR* sUserName;
+}
+alias SecPkgContext_NamesW* PSecPkgContext_NamesW;
+struct SecPkgContext_NamesA {
+    SEC_CHAR* sUserName;
+}
+alias SecPkgContext_NamesA* PSecPkgContext_NamesA;
+struct SecPkgInfoW {
+    ULONG fCapabilities;
+    USHORT wVersion;
+    USHORT wRPCID;
+    ULONG cbMaxToken;
+    SEC_WCHAR* Name;
+    SEC_WCHAR* Comment;
+}
+alias SecPkgInfoW* PSecPkgInfoW;
+struct SecPkgInfoA {
+    ULONG fCapabilities;
+    USHORT wVersion;
+    USHORT wRPCID;
+    ULONG cbMaxToken;
+    SEC_CHAR* Name;
+    SEC_CHAR* Comment;
+}
+alias SecPkgInfoA* PSecPkgInfoA;
+/* supported only in win2k+, so it should be a PSecPkgInfoW */
+/* PSDK does not say it has ANSI/Unicode versions */
+struct SecPkgContext_PackageInfo {
+    PSecPkgInfoW PackageInfo;
+}
+alias SecPkgContext_PackageInfo* PSecPkgContext_PackageInfo;
+struct SecPkgCredentials_NamesW {
+    SEC_WCHAR* sUserName;
+}
+alias SecPkgCredentials_NamesW* PSecPkgCredentials_NamesW;
+struct SecPkgCredentials_NamesA {
+    SEC_CHAR* sUserName;
+}
+alias SecPkgCredentials_NamesA* PSecPkgCredentials_NamesA;
+
+/* TODO: missing type in SDK */
+alias void function() SEC_GET_KEY_FN;
+
+alias SECURITY_STATUS function(PULONG,PSecPkgInfoW*) ENUMERATE_SECURITY_PACKAGES_FN_W;
+alias SECURITY_STATUS function(PULONG,PSecPkgInfoA*) ENUMERATE_SECURITY_PACKAGES_FN_A;
+alias SECURITY_STATUS function(PCredHandle,ULONG,PVOID) QUERY_CREDENTIALS_ATTRIBUTES_FN_W;
+alias SECURITY_STATUS function(PCredHandle,ULONG,PVOID) QUERY_CREDENTIALS_ATTRIBUTES_FN_A;
+alias SECURITY_STATUS function(SEC_WCHAR*,SEC_WCHAR*,ULONG,PLUID,PVOID,SEC_GET_KEY_FN,PVOID,PCredHandle,PTimeStamp) ACQUIRE_CREDENTIALS_HANDLE_FN_W;
+alias SECURITY_STATUS function(SEC_CHAR*,SEC_CHAR*,ULONG,PLUID,PVOID,SEC_GET_KEY_FN,PVOID,PCredHandle,PTimeStamp) ACQUIRE_CREDENTIALS_HANDLE_FN_A;
+alias SECURITY_STATUS function(PCredHandle) FREE_CREDENTIALS_HANDLE_FN;
+alias SECURITY_STATUS function(PCredHandle,PCtxtHandle,SEC_WCHAR*,ULONG,ULONG,ULONG,PSecBufferDesc,ULONG,PCtxtHandle,PSecBufferDesc,PULONG,PTimeStamp) INITIALIZE_SECURITY_CONTEXT_FN_W;
+alias SECURITY_STATUS function(PCredHandle,PCtxtHandle,SEC_CHAR*,ULONG,ULONG,ULONG,PSecBufferDesc,ULONG,PCtxtHandle,PSecBufferDesc,PULONG,PTimeStamp) INITIALIZE_SECURITY_CONTEXT_FN_A;
+alias SECURITY_STATUS function(PCredHandle,PCtxtHandle,PSecBufferDesc,ULONG,ULONG,PCtxtHandle,PSecBufferDesc,PULONG,PTimeStamp) ACCEPT_SECURITY_CONTEXT_FN;
+alias SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc) COMPLETE_AUTH_TOKEN_FN;
+alias SECURITY_STATUS function(PCtxtHandle) DELETE_SECURITY_CONTEXT_FN;
+alias SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc) APPLY_CONTROL_TOKEN_FN_W;
+alias SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc) APPLY_CONTROL_TOKEN_FN_A;
+alias SECURITY_STATUS function(PCtxtHandle,ULONG,PVOID) QUERY_CONTEXT_ATTRIBUTES_FN_A;
+alias SECURITY_STATUS function(PCtxtHandle,ULONG,PVOID) QUERY_CONTEXT_ATTRIBUTES_FN_W;
+alias SECURITY_STATUS function(PCtxtHandle) IMPERSONATE_SECURITY_CONTEXT_FN;
+alias SECURITY_STATUS function(PCtxtHandle) REVERT_SECURITY_CONTEXT_FN;
+alias SECURITY_STATUS function(PCtxtHandle,ULONG,PSecBufferDesc,ULONG) MAKE_SIGNATURE_FN;
+alias SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc,ULONG,PULONG) VERIFY_SIGNATURE_FN;
+alias SECURITY_STATUS function(PVOID) FREE_CONTEXT_BUFFER_FN;
+alias SECURITY_STATUS function(SEC_CHAR*,PSecPkgInfoA*) QUERY_SECURITY_PACKAGE_INFO_FN_A;
+alias SECURITY_STATUS function(PCtxtHandle,HANDLE*) QUERY_SECURITY_CONTEXT_TOKEN_FN;
+alias SECURITY_STATUS function(SEC_WCHAR*,PSecPkgInfoW*) QUERY_SECURITY_PACKAGE_INFO_FN_W;
+alias SECURITY_STATUS function(PCtxtHandle,ULONG,PSecBufferDesc,ULONG) ENCRYPT_MESSAGE_FN;
+alias SECURITY_STATUS function(PCtxtHandle,PSecBufferDesc,ULONG,PULONG) DECRYPT_MESSAGE_FN;
+
+/* No, it really is FreeCredentialsHandle, see the thread beginning
+ * http://sourceforge.net/mailarchive/message.php?msg_id=4321080 for a
+ * discovery discussion. */
+struct SecurityFunctionTableW{
+    uint dwVersion;
+    ENUMERATE_SECURITY_PACKAGES_FN_W EnumerateSecurityPackagesW;
+    QUERY_CREDENTIALS_ATTRIBUTES_FN_W QueryCredentialsAttributesW;
+    ACQUIRE_CREDENTIALS_HANDLE_FN_W AcquireCredentialsHandleW;
+    FREE_CREDENTIALS_HANDLE_FN FreeCredentialsHandle;
+    void* Reserved2;
+    INITIALIZE_SECURITY_CONTEXT_FN_W InitializeSecurityContextW;
+    ACCEPT_SECURITY_CONTEXT_FN AcceptSecurityContext;
+    COMPLETE_AUTH_TOKEN_FN CompleteAuthToken;
+    DELETE_SECURITY_CONTEXT_FN DeleteSecurityContext;
+    APPLY_CONTROL_TOKEN_FN_W ApplyControlTokenW;
+    QUERY_CONTEXT_ATTRIBUTES_FN_W QueryContextAttributesW;
+    IMPERSONATE_SECURITY_CONTEXT_FN ImpersonateSecurityContext;
+    REVERT_SECURITY_CONTEXT_FN RevertSecurityContext;
+    MAKE_SIGNATURE_FN MakeSignature;
+    VERIFY_SIGNATURE_FN VerifySignature;
+    FREE_CONTEXT_BUFFER_FN FreeContextBuffer;
+    QUERY_SECURITY_PACKAGE_INFO_FN_W QuerySecurityPackageInfoW;
+    void* Reserved3;
+    void* Reserved4;
+    void* Reserved5;
+    void* Reserved6;
+    void* Reserved7;
+    void* Reserved8;
+    QUERY_SECURITY_CONTEXT_TOKEN_FN QuerySecurityContextToken;
+    ENCRYPT_MESSAGE_FN EncryptMessage;
+    DECRYPT_MESSAGE_FN DecryptMessage;
+}
+alias SecurityFunctionTableW* PSecurityFunctionTableW;
+struct SecurityFunctionTableA{
+    uint dwVersion;
+    ENUMERATE_SECURITY_PACKAGES_FN_A EnumerateSecurityPackagesA;
+    QUERY_CREDENTIALS_ATTRIBUTES_FN_A QueryCredentialsAttributesA;
+    ACQUIRE_CREDENTIALS_HANDLE_FN_A AcquireCredentialsHandleA;
+    FREE_CREDENTIALS_HANDLE_FN FreeCredentialsHandle;
+    void* Reserved2;
+    INITIALIZE_SECURITY_CONTEXT_FN_A InitializeSecurityContextA;
+    ACCEPT_SECURITY_CONTEXT_FN AcceptSecurityContext;
+    COMPLETE_AUTH_TOKEN_FN CompleteAuthToken;
+    DELETE_SECURITY_CONTEXT_FN DeleteSecurityContext;
+    APPLY_CONTROL_TOKEN_FN_A ApplyControlTokenA;
+    QUERY_CONTEXT_ATTRIBUTES_FN_A QueryContextAttributesA;
+    IMPERSONATE_SECURITY_CONTEXT_FN ImpersonateSecurityContext;
+    REVERT_SECURITY_CONTEXT_FN RevertSecurityContext;
+    MAKE_SIGNATURE_FN MakeSignature;
+    VERIFY_SIGNATURE_FN VerifySignature;
+    FREE_CONTEXT_BUFFER_FN FreeContextBuffer;
+    QUERY_SECURITY_PACKAGE_INFO_FN_A QuerySecurityPackageInfoA;
+    void* Reserved3;
+    void* Reserved4;
+    void* Unknown1;
+    void* Unknown2;
+    void* Unknown3;
+    void* Unknown4;
+    void* Unknown5;
+    ENCRYPT_MESSAGE_FN EncryptMessage;
+    DECRYPT_MESSAGE_FN DecryptMessage;
+}
+alias SecurityFunctionTableA* PSecurityFunctionTableA;
+alias PSecurityFunctionTableA function() INIT_SECURITY_INTERFACE_A;
+alias PSecurityFunctionTableW function() INIT_SECURITY_INTERFACE_W;
+
+SECURITY_STATUS FreeCredentialsHandle(PCredHandle);
+SECURITY_STATUS EnumerateSecurityPackagesA(PULONG,PSecPkgInfoA*);
+SECURITY_STATUS EnumerateSecurityPackagesW(PULONG,PSecPkgInfoW*);
+SECURITY_STATUS AcquireCredentialsHandleA(SEC_CHAR*,SEC_CHAR*,ULONG,PLUID,PVOID,SEC_GET_KEY_FN,PVOID,PCredHandle,PTimeStamp);
+SECURITY_STATUS AcquireCredentialsHandleW(SEC_WCHAR*,SEC_WCHAR*,ULONG,PLUID,PVOID,SEC_GET_KEY_FN,PVOID,PCredHandle,PTimeStamp);
+SECURITY_STATUS AcceptSecurityContext(PCredHandle,PCtxtHandle,PSecBufferDesc,ULONG,ULONG,PCtxtHandle,PSecBufferDesc,PULONG,PTimeStamp);
+SECURITY_STATUS InitializeSecurityContextA(PCredHandle,PCtxtHandle,SEC_CHAR*,ULONG,ULONG,ULONG,PSecBufferDesc,ULONG,PCtxtHandle,PSecBufferDesc,PULONG,PTimeStamp);
+SECURITY_STATUS InitializeSecurityContextW(PCredHandle,PCtxtHandle,SEC_WCHAR*,ULONG,ULONG,ULONG,PSecBufferDesc,ULONG,PCtxtHandle,PSecBufferDesc,PULONG,PTimeStamp);
+SECURITY_STATUS FreeContextBuffer(PVOID);
+SECURITY_STATUS QueryContextAttributesA(PCtxtHandle,ULONG,PVOID);
+SECURITY_STATUS QueryContextAttributesW(PCtxtHandle,ULONG,PVOID);
+SECURITY_STATUS QueryCredentialsAttributesA(PCredHandle,ULONG,PVOID);
+SECURITY_STATUS QueryCredentialsAttributesW(PCredHandle,ULONG,PVOID);
+static if(_WIN32_WINNT >= 0x500){
+    SECURITY_STATUS QuerySecurityContextToken(PCtxtHandle,HANDLE*);
+}
+SECURITY_STATUS DecryptMessage(PCtxtHandle,PSecBufferDesc,ULONG,PULONG);
+SECURITY_STATUS EncryptMessage(PCtxtHandle,ULONG,PSecBufferDesc,ULONG);
+SECURITY_STATUS DeleteSecurityContext(PCtxtHandle);
+SECURITY_STATUS CompleteAuthToken(PCtxtHandle,PSecBufferDesc);
+SECURITY_STATUS ApplyControlTokenA(PCtxtHandle,PSecBufferDesc);
+SECURITY_STATUS ApplyControlTokenW(PCtxtHandle,PSecBufferDesc);
+SECURITY_STATUS ImpersonateSecurityContext(PCtxtHandle);
+SECURITY_STATUS RevertSecurityContext(PCtxtHandle);
+SECURITY_STATUS MakeSignature(PCtxtHandle,ULONG,PSecBufferDesc,ULONG);
+SECURITY_STATUS VerifySignature(PCtxtHandle,PSecBufferDesc,ULONG,PULONG);
+SECURITY_STATUS QuerySecurityPackageInfoA(SEC_CHAR*,PSecPkgInfoA*);
+SECURITY_STATUS QuerySecurityPackageInfoW(SEC_WCHAR*,PSecPkgInfoW*);
+PSecurityFunctionTableA InitSecurityInterfaceA();
+PSecurityFunctionTableW InitSecurityInterfaceW();
+
+version(Unicode) {
+    alias UNISP_NAME_W UNISP_NAME;
+    alias SecPkgInfoW SecPkgInfo;
+    alias PSecPkgInfoW PSecPkgInfo;
+    alias SecPkgCredentials_NamesW SecPkgCredentials_Names;
+    alias PSecPkgCredentials_NamesW PSecPkgCredentials_Names;
+    alias SecPkgContext_AuthorityW SecPkgContext_Authority;
+    alias PSecPkgContext_AuthorityW PSecPkgContext_Authority;
+    alias SecPkgContext_KeyInfoW SecPkgContext_KeyInfo;
+    alias PSecPkgContext_KeyInfoW PSecPkgContext_KeyInfo;
+    alias SecPkgContext_NamesW SecPkgContext_Names;
+    alias PSecPkgContext_NamesW PSecPkgContext_Names;
+    alias SecurityFunctionTableW SecurityFunctionTable;
+    alias PSecurityFunctionTableW PSecurityFunctionTable;
+    alias AcquireCredentialsHandleW AcquireCredentialsHandle;
+    alias EnumerateSecurityPackagesW EnumerateSecurityPackages;
+    alias InitializeSecurityContextW InitializeSecurityContext;
+    alias QueryContextAttributesW QueryContextAttributes;
+    alias QueryCredentialsAttributesW QueryCredentialsAttributes;
+    alias QuerySecurityPackageInfoW QuerySecurityPackageInfo;
+    alias ApplyControlTokenW ApplyControlToken;
+    alias ENUMERATE_SECURITY_PACKAGES_FN_W ENUMERATE_SECURITY_PACKAGES_FN;
+    alias QUERY_CREDENTIALS_ATTRIBUTES_FN_W QUERY_CREDENTIALS_ATTRIBUTES_FN;
+    alias ACQUIRE_CREDENTIALS_HANDLE_FN_W ACQUIRE_CREDENTIALS_HANDLE_FN;
+    alias INITIALIZE_SECURITY_CONTEXT_FN_W INITIALIZE_SECURITY_CONTEXT_FN;
+    alias APPLY_CONTROL_TOKEN_FN_W APPLY_CONTROL_TOKEN_FN;
+    alias QUERY_CONTEXT_ATTRIBUTES_FN_W QUERY_CONTEXT_ATTRIBUTES_FN;
+    alias QUERY_SECURITY_PACKAGE_INFO_FN_W QUERY_SECURITY_PACKAGE_INFO_FN;
+    alias INIT_SECURITY_INTERFACE_W INIT_SECURITY_INTERFACE;
+}else{
+    alias UNISP_NAME_A UNISP_NAME;
+    alias SecPkgInfoA SecPkgInfo;
+    alias PSecPkgInfoA PSecPkgInfo;
+    alias SecPkgCredentials_NamesA SecPkgCredentials_Names;
+    alias PSecPkgCredentials_NamesA PSecPkgCredentials_Names;
+    alias SecPkgContext_AuthorityA SecPkgContext_Authority;
+    alias PSecPkgContext_AuthorityA PSecPkgContext_Authority;
+    alias SecPkgContext_KeyInfoA SecPkgContext_KeyInfo;
+    alias PSecPkgContext_KeyInfoA PSecPkgContext_KeyInfo;
+    alias SecPkgContext_NamesA SecPkgContext_Names;
+    alias PSecPkgContext_NamesA PSecPkgContext_Names;
+    alias SecurityFunctionTableA SecurityFunctionTable;
+    alias PSecurityFunctionTableA PSecurityFunctionTable;
+    alias AcquireCredentialsHandleA AcquireCredentialsHandle;
+    alias EnumerateSecurityPackagesA EnumerateSecurityPackages;
+    alias InitializeSecurityContextA InitializeSecurityContext;
+    alias QueryContextAttributesA QueryContextAttributes;
+    alias QueryCredentialsAttributesA QueryCredentialsAttributes;
+    alias QuerySecurityPackageInfoA QuerySecurityPackageInfo;
+    alias ApplyControlTokenA ApplyControlToken;
+    alias ENUMERATE_SECURITY_PACKAGES_FN_A ENUMERATE_SECURITY_PACKAGES_FN;
+    alias QUERY_CREDENTIALS_ATTRIBUTES_FN_A QUERY_CREDENTIALS_ATTRIBUTES_FN;
+    alias ACQUIRE_CREDENTIALS_HANDLE_FN_A ACQUIRE_CREDENTIALS_HANDLE_FN;
+    alias INITIALIZE_SECURITY_CONTEXT_FN_A INITIALIZE_SECURITY_CONTEXT_FN;
+    alias APPLY_CONTROL_TOKEN_FN_A APPLY_CONTROL_TOKEN_FN;
+    alias QUERY_CONTEXT_ATTRIBUTES_FN_A QUERY_CONTEXT_ATTRIBUTES_FN;
+    alias QUERY_SECURITY_PACKAGE_INFO_FN_A QUERY_SECURITY_PACKAGE_INFO_FN;
+    alias INIT_SECURITY_INTERFACE_A INIT_SECURITY_INTERFACE;
+}
+
diff --git a/libphobos/libdruntime/core/sys/windows/stacktrace.d b/libphobos/libdruntime/core/sys/windows/stacktrace.d
new file mode 100644
index 00000000000..7695ddc448d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/stacktrace.d
@@ -0,0 +1,417 @@
+/**
+ * ...
+ *
+ * Copyright: Copyright Benjamin Thaut 2010 - 2013.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Benjamin Thaut, Sean Kelly
+ * Source:    $(DRUNTIMESRC core/sys/windows/_stacktrace.d)
+ */
+
+module core.sys.windows.stacktrace;
+version (Windows):
+
+import core.demangle;
+import core.runtime;
+import core.stdc.stdlib;
+import core.stdc.string;
+import core.sys.windows.dbghelp;
+import core.sys.windows.windows;
+
+//debug=PRINTF;
+debug(PRINTF) import core.stdc.stdio;
+
+
+extern(Windows) void RtlCaptureContext(CONTEXT* ContextRecord);
+extern(Windows) DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR pBuffer, DWORD nSize);
+
+extern(Windows) alias USHORT function(ULONG FramesToSkip, ULONG FramesToCapture, PVOID *BackTrace, PULONG BackTraceHash) RtlCaptureStackBackTraceFunc;
+
+private __gshared RtlCaptureStackBackTraceFunc RtlCaptureStackBackTrace;
+private __gshared immutable bool initialized;
+
+
+class StackTrace : Throwable.TraceInfo
+{
+public:
+    /**
+     * Constructor
+     * Params:
+     *  skip = The number of stack frames to skip.
+     *  context = The context to receive the stack trace from. Can be null.
+     */
+    this(size_t skip, CONTEXT* context)
+    {
+        if(context is null)
+        {
+            version(Win64)
+                static enum INTERNALFRAMES = 3;
+            else version(Win32)
+                static enum INTERNALFRAMES = 2;
+
+            skip += INTERNALFRAMES; //skip the stack frames within the StackTrace class
+        }
+        else
+        {
+            //When a exception context is given the first stack frame is repeated for some reason
+            version(Win64)
+                static enum INTERNALFRAMES = 1;
+            else version(Win32)
+                static enum INTERNALFRAMES = 1;
+
+            skip += INTERNALFRAMES;
+        }
+        if( initialized )
+            m_trace = trace(skip, context);
+    }
+
+    int opApply( scope int delegate(ref const(char[])) dg ) const
+    {
+        return opApply( (ref size_t, ref const(char[]) buf)
+                        {
+                            return dg( buf );
+                        });
+    }
+
+
+    int opApply( scope int delegate(ref size_t, ref const(char[])) dg ) const
+    {
+        int result;
+        foreach( i, e; resolve(m_trace) )
+        {
+            if( (result = dg( i, e )) != 0 )
+                break;
+        }
+        return result;
+    }
+
+
+    override string toString() const
+    {
+        string result;
+
+        foreach( e; this )
+        {
+            result ~= e ~ "\n";
+        }
+        return result;
+    }
+
+    /**
+     * Receive a stack trace in the form of an address list.
+     * Params:
+     *  skip = How many stack frames should be skipped.
+     *  context = The context that should be used. If null the current context is used.
+     * Returns:
+     *  A list of addresses that can be passed to resolve at a later point in time.
+     */
+    static ulong[] trace(size_t skip = 0, CONTEXT* context = null)
+    {
+        synchronized( typeid(StackTrace) )
+        {
+            return traceNoSync(skip, context);
+        }
+    }
+
+    /**
+     * Resolve a stack trace.
+     * Params:
+     *  addresses = A list of addresses to resolve.
+     * Returns:
+     *  An array of strings with the results.
+     */
+    static char[][] resolve(const(ulong)[] addresses)
+    {
+        synchronized( typeid(StackTrace) )
+        {
+            return resolveNoSync(addresses);
+        }
+    }
+
+private:
+    ulong[] m_trace;
+
+
+    static ulong[] traceNoSync(size_t skip, CONTEXT* context)
+    {
+        auto dbghelp  = DbgHelp.get();
+        if(dbghelp is null)
+            return []; // dbghelp.dll not available
+
+        if(RtlCaptureStackBackTrace !is null && context is null)
+        {
+            size_t[63] buffer = void; // On windows xp the sum of "frames to skip" and "frames to capture" can't be greater then 63
+            auto backtraceLength = RtlCaptureStackBackTrace(cast(ULONG)skip, cast(ULONG)(buffer.length - skip), cast(void**)buffer.ptr, null);
+
+            // If we get a backtrace and it does not have the maximum length use it.
+            // Otherwise rely on tracing through StackWalk64 which is slower but works when no frame pointers are available.
+            if(backtraceLength > 1 && backtraceLength < buffer.length - skip)
+            {
+                debug(PRINTF) printf("Using result from RtlCaptureStackBackTrace\n");
+                version(Win64)
+                {
+                    return buffer[0..backtraceLength].dup;
+                }
+                else version(Win32)
+                {
+                    auto result = new ulong[backtraceLength];
+                    foreach(i, ref e; result)
+                    {
+                        e = buffer[i];
+                    }
+                    return result;
+                }
+            }
+        }
+
+        HANDLE       hThread  = GetCurrentThread();
+        HANDLE       hProcess = GetCurrentProcess();
+        CONTEXT      ctxt;
+
+        if(context is null)
+        {
+            ctxt.ContextFlags = CONTEXT_FULL;
+            RtlCaptureContext(&ctxt);
+        }
+        else
+        {
+            ctxt = *context;
+        }
+
+        //x86
+        STACKFRAME64 stackframe;
+        with (stackframe)
+        {
+            version(X86)
+            {
+                enum Flat = ADDRESS_MODE.AddrModeFlat;
+                AddrPC.Offset    = ctxt.Eip;
+                AddrPC.Mode      = Flat;
+                AddrFrame.Offset = ctxt.Ebp;
+                AddrFrame.Mode   = Flat;
+                AddrStack.Offset = ctxt.Esp;
+                AddrStack.Mode   = Flat;
+            }
+        else version(X86_64)
+            {
+                enum Flat = ADDRESS_MODE.AddrModeFlat;
+                AddrPC.Offset    = ctxt.Rip;
+                AddrPC.Mode      = Flat;
+                AddrFrame.Offset = ctxt.Rbp;
+                AddrFrame.Mode   = Flat;
+                AddrStack.Offset = ctxt.Rsp;
+                AddrStack.Mode   = Flat;
+            }
+        }
+
+        version (X86)         enum imageType = IMAGE_FILE_MACHINE_I386;
+        else version (X86_64) enum imageType = IMAGE_FILE_MACHINE_AMD64;
+        else                  static assert(0, "unimplemented");
+
+        ulong[] result;
+        size_t frameNum = 0;
+
+        // do ... while so that we don't skip the first stackframe
+        do
+        {
+            if( stackframe.AddrPC.Offset == stackframe.AddrReturn.Offset )
+            {
+                debug(PRINTF) printf("Endless callstack\n");
+                break;
+            }
+            if(frameNum >= skip)
+            {
+                result ~= stackframe.AddrPC.Offset;
+            }
+            frameNum++;
+        }
+        while (dbghelp.StackWalk64(imageType, hProcess, hThread, &stackframe,
+                                   &ctxt, null, null, null, null));
+        return result;
+    }
+
+    static char[][] resolveNoSync(const(ulong)[] addresses)
+    {
+        auto dbghelp  = DbgHelp.get();
+        if(dbghelp is null)
+            return []; // dbghelp.dll not available
+
+        HANDLE hProcess = GetCurrentProcess();
+
+        static struct BufSymbol
+        {
+        align(1):
+            IMAGEHLP_SYMBOLA64 _base;
+            TCHAR[1024] _buf;
+        }
+        BufSymbol bufSymbol=void;
+        IMAGEHLP_SYMBOLA64* symbol = &bufSymbol._base;
+        symbol.SizeOfStruct = IMAGEHLP_SYMBOLA64.sizeof;
+        symbol.MaxNameLength = bufSymbol._buf.length;
+
+        char[][] trace;
+        foreach(pc; addresses)
+        {
+            if( pc != 0 )
+            {
+                char[] res;
+                if (dbghelp.SymGetSymFromAddr64(hProcess, pc, null, symbol) &&
+                    *symbol.Name.ptr)
+                {
+                    DWORD disp;
+                    IMAGEHLP_LINEA64 line=void;
+                    line.SizeOfStruct = IMAGEHLP_LINEA64.sizeof;
+
+                    if (dbghelp.SymGetLineFromAddr64(hProcess, pc, &disp, &line))
+                        res = formatStackFrame(cast(void*)pc, symbol.Name.ptr,
+                                               line.FileName, line.LineNumber);
+                    else
+                        res = formatStackFrame(cast(void*)pc, symbol.Name.ptr);
+                }
+                else
+                    res = formatStackFrame(cast(void*)pc);
+                trace ~= res;
+            }
+        }
+        return trace;
+    }
+
+    static char[] formatStackFrame(void* pc)
+    {
+        import core.stdc.stdio : snprintf;
+        char[2+2*size_t.sizeof+1] buf=void;
+
+        immutable len = snprintf(buf.ptr, buf.length, "0x%p", pc);
+        cast(uint)len < buf.length || assert(0);
+        return buf[0 .. len].dup;
+    }
+
+    static char[] formatStackFrame(void* pc, char* symName)
+    {
+        char[2048] demangleBuf=void;
+
+        auto res = formatStackFrame(pc);
+        res ~= " in ";
+const(char)[] tempSymName = symName[0 .. strlen(symName)];
+        //Deal with dmd mangling of long names
+        version(DigitalMars) version(Win32)
+        {
+            size_t decodeIndex = 0;
+            tempSymName = decodeDmdString(tempSymName, decodeIndex);
+        }
+        res ~= demangle(tempSymName, demangleBuf);
+        return res;
+    }
+
+    static char[] formatStackFrame(void* pc, char* symName,
+                                   in char* fileName, uint lineNum)
+    {
+        import core.stdc.stdio : snprintf;
+        char[11] buf=void;
+
+        auto res = formatStackFrame(pc, symName);
+        res ~= " at ";
+        res ~= fileName[0 .. strlen(fileName)];
+        res ~= "(";
+        immutable len = snprintf(buf.ptr, buf.length, "%u", lineNum);
+        cast(uint)len < buf.length || assert(0);
+        res ~= buf[0 .. len];
+        res ~= ")";
+        return res;
+    }
+}
+
+
+// Workaround OPTLINK bug (Bugzilla 8263)
+extern(Windows) BOOL FixupDebugHeader(HANDLE hProcess, ULONG ActionCode,
+                                      ulong CallbackContext, ulong UserContext)
+{
+    if (ActionCode == CBA_READ_MEMORY)
+    {
+        auto p = cast(IMAGEHLP_CBA_READ_MEMORY*)CallbackContext;
+        if (!(p.addr & 0xFF) && p.bytes == 0x1C &&
+            // IMAGE_DEBUG_DIRECTORY.PointerToRawData
+            (*cast(DWORD*)(p.addr + 24) & 0xFF) == 0x20)
+        {
+            immutable base = DbgHelp.get().SymGetModuleBase64(hProcess, p.addr);
+            // IMAGE_DEBUG_DIRECTORY.AddressOfRawData
+            if (base + *cast(DWORD*)(p.addr + 20) == p.addr + 0x1C &&
+                *cast(DWORD*)(p.addr + 0x1C) == 0 &&
+                *cast(DWORD*)(p.addr + 0x20) == ('N'|'B'<<8|'0'<<16|'9'<<24))
+            {
+                debug(PRINTF) printf("fixup IMAGE_DEBUG_DIRECTORY.AddressOfRawData\n");
+                memcpy(p.buf, cast(void*)p.addr, 0x1C);
+                *cast(DWORD*)(p.buf + 20) = cast(DWORD)(p.addr - base) + 0x20;
+                *p.bytesread = 0x1C;
+                return TRUE;
+            }
+        }
+    }
+    return FALSE;
+}
+
+private string generateSearchPath()
+{
+    __gshared string[3] defaultPathList = ["_NT_SYMBOL_PATH",
+                                           "_NT_ALTERNATE_SYMBOL_PATH",
+                                           "SYSTEMROOT"];
+
+    string path;
+    char[2048] temp;
+    DWORD len;
+
+    foreach( e; defaultPathList )
+    {
+        if( (len = GetEnvironmentVariableA( e.ptr, temp.ptr, temp.length )) > 0 )
+        {
+            path ~= temp[0 .. len];
+            path ~= ";";
+        }
+    }
+    path ~= "\0";
+    return path;
+}
+
+
+shared static this()
+{
+    auto dbghelp = DbgHelp.get();
+
+    if( dbghelp is null )
+        return; // dbghelp.dll not available
+
+    auto kernel32Handle = LoadLibraryA( "kernel32.dll" );
+    if(kernel32Handle !is null)
+    {
+        RtlCaptureStackBackTrace = cast(RtlCaptureStackBackTraceFunc) GetProcAddress(kernel32Handle, "RtlCaptureStackBackTrace");
+        debug(PRINTF)
+        {
+            if(RtlCaptureStackBackTrace !is null)
+                printf("Found RtlCaptureStackBackTrace\n");
+        }
+    }
+
+    debug(PRINTF)
+    {
+        API_VERSION* dbghelpVersion = dbghelp.ImagehlpApiVersion();
+        printf("DbgHelp Version %d.%d.%d\n", dbghelpVersion.MajorVersion, dbghelpVersion.MinorVersion, dbghelpVersion.Revision);
+    }
+
+    HANDLE hProcess = GetCurrentProcess();
+
+    DWORD symOptions = dbghelp.SymGetOptions();
+    symOptions |= SYMOPT_LOAD_LINES;
+    symOptions |= SYMOPT_FAIL_CRITICAL_ERRORS;
+    symOptions |= SYMOPT_DEFERRED_LOAD;
+    symOptions  = dbghelp.SymSetOptions( symOptions );
+
+    debug(PRINTF) printf("Search paths: %s\n", generateSearchPath().ptr);
+
+    if (!dbghelp.SymInitialize(hProcess, generateSearchPath().ptr, TRUE))
+        return;
+
+    dbghelp.SymRegisterCallback64(hProcess, &FixupDebugHeader, 0);
+
+    initialized = true;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/stat.d b/libphobos/libdruntime/core/sys/windows/stat.d
new file mode 100644
index 00000000000..9612793afc9
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/stat.d
@@ -0,0 +1,50 @@
+
+/// $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+/// Author: Walter Bright
+
+module core.sys.windows.stat;
+version (Windows):
+
+extern (C) nothrow @nogc:
+
+// Posix version is in core.sys.posix.sys.stat
+
+enum S_IFMT   = 0xF000;
+enum S_IFDIR  = 0x4000;
+enum S_IFCHR  = 0x2000;
+enum S_IFIFO  = 0x1000;
+enum S_IFREG  = 0x8000;
+enum S_IREAD  = 0x0100;
+enum S_IWRITE = 0x0080;
+enum S_IEXEC  = 0x0040;
+enum S_IFBLK  = 0x6000;
+enum S_IFNAM  = 0x5000;
+
+@safe pure
+{
+int S_ISREG(int m)  { return (m & S_IFMT) == S_IFREG; }
+int S_ISBLK(int m)  { return (m & S_IFMT) == S_IFBLK; }
+int S_ISNAM(int m)  { return (m & S_IFMT) == S_IFNAM; }
+int S_ISDIR(int m)  { return (m & S_IFMT) == S_IFDIR; }
+int S_ISCHR(int m)  { return (m & S_IFMT) == S_IFCHR; }
+}
+
+struct struct_stat
+{
+    short st_dev;
+    ushort st_ino;
+    ushort st_mode;
+    short st_nlink;
+    ushort st_uid;
+    ushort st_gid;
+    short st_rdev;
+    short dummy;
+    int st_size;
+    int st_atime;
+    int st_mtime;
+    int st_ctime;
+}
+
+int  stat(char *, struct_stat *);
+int  fstat(int, struct_stat *) @trusted;
+int  _wstat(wchar *, struct_stat *);
diff --git a/libphobos/libdruntime/core/sys/windows/subauth.d b/libphobos/libdruntime/core/sys/windows/subauth.d
new file mode 100644
index 00000000000..39e8beb6c2b
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/subauth.d
@@ -0,0 +1,275 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_subauth.d)
+ */
+module core.sys.windows.subauth;
+version (Windows):
+
+private import core.sys.windows.ntdef, core.sys.windows.windef;
+
+/+
+alias LONG NTSTATUS;
+alias NTSTATUS* PNTSTATUS;
++/
+
+enum : ULONG {
+    MSV1_0_PASSTHRU    = 1,
+    MSV1_0_GUEST_LOGON = 2
+}
+
+// USER_ALL_INFORMATION.WhichFields (Undocumented)
+enum ULONG
+    MSV1_0_VALIDATION_LOGOFF_TIME  = 1,
+    MSV1_0_VALIDATION_KICKOFF_TIME = 2,
+    MSV1_0_VALIDATION_LOGON_SERVER = 4,
+    MSV1_0_VALIDATION_LOGON_DOMAIN = 8,
+    MSV1_0_VALIDATION_SESSION_KEY  = 16,
+    MSV1_0_VALIDATION_USER_FLAGS   = 32,
+    MSV1_0_VALIDATION_USER_ID      = 64;
+
+// ?ActionsPerformed? (Undocumented)
+enum MSV1_0_SUBAUTH_ACCOUNT_DISABLED = 1;
+enum MSV1_0_SUBAUTH_PASSWORD         = 2;
+enum MSV1_0_SUBAUTH_WORKSTATIONS = 4;
+enum MSV1_0_SUBAUTH_LOGON_HOURS = 8;
+enum MSV1_0_SUBAUTH_ACCOUNT_EXPIRY = 16;
+enum MSV1_0_SUBAUTH_PASSWORD_EXPIRY = 32;
+enum MSV1_0_SUBAUTH_ACCOUNT_TYPE = 64;
+enum MSV1_0_SUBAUTH_LOCKOUT = 128;
+
+enum NEXT_FREE_ACCOUNT_CONTROL_BIT = 131072;
+
+enum SAM_DAYS_PER_WEEK    = 7;
+enum SAM_HOURS_PER_WEEK   = 168;
+enum SAM_MINUTES_PER_WEEK = 10080;
+
+enum : NTSTATUS {
+    STATUS_SUCCESS                = 0,
+    STATUS_INVALID_INFO_CLASS     = 0xC0000003,
+    STATUS_NO_SUCH_USER           = 0xC0000064,
+    STATUS_WRONG_PASSWORD         = 0xC000006A,
+    STATUS_PASSWORD_RESTRICTION   = 0xC000006C,
+    STATUS_LOGON_FAILURE          = 0xC000006D,
+    STATUS_ACCOUNT_RESTRICTION    = 0xC000006E,
+    STATUS_INVALID_LOGON_HOURS    = 0xC000006F,
+    STATUS_INVALID_WORKSTATION    = 0xC0000070,
+    STATUS_PASSWORD_EXPIRED       = 0xC0000071,
+    STATUS_ACCOUNT_DISABLED       = 0xC0000072,
+    STATUS_INSUFFICIENT_RESOURCES = 0xC000009A,
+    STATUS_ACCOUNT_EXPIRED        = 0xC0000193,
+    STATUS_PASSWORD_MUST_CHANGE   = 0xC0000224,
+    STATUS_ACCOUNT_LOCKED_OUT     = 0xC0000234
+}
+
+// Note: undocumented in MSDN
+// USER_ALL_INFORMATION.UserAccountControl
+enum ULONG
+    USER_ACCOUNT_DISABLED                = 1,
+    USER_HOME_DIRECTORY_REQUIRED         = 2,
+    USER_PASSWORD_NOT_REQUIRED           = 4,
+    USER_TEMP_DUPLICATE_ACCOUNT          = 8,
+    USER_NORMAL_ACCOUNT                  = 16,
+    USER_MNS_LOGON_ACCOUNT               = 32,
+    USER_INTERDOMAIN_TRUST_ACCOUNT       = 64,
+    USER_WORKSTATION_TRUST_ACCOUNT       = 128,
+    USER_SERVER_TRUST_ACCOUNT            = 256,
+    USER_DONT_EXPIRE_PASSWORD            = 512,
+    USER_ACCOUNT_AUTO_LOCKED             = 1024,
+    USER_ENCRYPTED_TEXT_PASSWORD_ALLOWED = 2048,
+    USER_SMARTCARD_REQUIRED              = 4096,
+    USER_TRUSTED_FOR_DELEGATION          = 8192,
+    USER_NOT_DELEGATED                   = 16384,
+    USER_USE_DES_KEY_ONLY                = 32768,
+    USER_DONT_REQUIRE_PREAUTH            = 65536,
+
+    USER_MACHINE_ACCOUNT_MASK            = 448,
+    USER_ACCOUNT_TYPE_MASK               = 472,
+    USER_ALL_PARAMETERS                  = 2097152;
+
+/+
+struct UNICODE_STRING {
+    USHORT Length;
+    USHORT MaximumLength;
+    PWSTR Buffer;
+}
+alias UNICODE_STRING* PUNICODE_STRING;
+
+struct STRING {
+    USHORT Length;
+    USHORT MaximumLength;
+    PCHAR Buffer;
+}
+alias STRING* PSTRING;
++/
+
+mixin DECLARE_HANDLE!("SAM_HANDLE");
+alias SAM_HANDLE* PSAM_HANDLE;
+
+struct OLD_LARGE_INTEGER {
+    ULONG LowPart;
+    LONG HighPart;
+}
+alias OLD_LARGE_INTEGER* POLD_LARGE_INTEGER;
+
+enum NETLOGON_LOGON_INFO_CLASS {
+    NetlogonInteractiveInformation = 1,
+    NetlogonNetworkInformation,
+    NetlogonServiceInformation,
+    NetlogonGenericInformation,
+    NetlogonInteractiveTransitiveInformation,
+    NetlogonNetworkTransitiveInformation,
+    NetlogonServiceTransitiveInformation
+}
+
+
+enum CYPHER_BLOCK_LENGTH = 8;
+enum USER_SESSION_KEY_LENGTH = CYPHER_BLOCK_LENGTH * 2;
+enum CLEAR_BLOCK_LENGTH = 8;
+
+struct CYPHER_BLOCK {
+    CHAR[CYPHER_BLOCK_LENGTH] data;
+}
+alias CYPHER_BLOCK* PCYPHER_BLOCK;
+
+struct CLEAR_BLOCK {
+    CHAR[CLEAR_BLOCK_LENGTH] data;
+}
+alias CLEAR_BLOCK* PCLEAR_BLOCK;
+
+struct LM_OWF_PASSWORD {
+    CYPHER_BLOCK[2] data;
+}
+alias LM_OWF_PASSWORD* PLM_OWF_PASSWORD;
+
+struct USER_SESSION_KEY {
+    CYPHER_BLOCK[2] data;
+}
+alias USER_SESSION_KEY* PUSER_SESSION_KEY;
+
+alias CLEAR_BLOCK LM_CHALLENGE;
+alias LM_CHALLENGE* PLM_CHALLENGE;
+
+alias LM_OWF_PASSWORD NT_OWF_PASSWORD;
+alias NT_OWF_PASSWORD* PNT_OWF_PASSWORD;
+alias LM_CHALLENGE NT_CHALLENGE;
+alias NT_CHALLENGE* PNT_CHALLENGE;
+
+struct LOGON_HOURS {
+    USHORT UnitsPerWeek;
+    PUCHAR LogonHours;
+}
+alias LOGON_HOURS* PLOGON_HOURS;
+
+struct SR_SECURITY_DESCRIPTOR {
+    ULONG Length;
+    PUCHAR SecurityDescriptor;
+}
+alias SR_SECURITY_DESCRIPTOR* PSR_SECURITY_DESCRIPTOR;
+
+align(4):
+struct USER_ALL_INFORMATION {
+    LARGE_INTEGER LastLogon;
+    LARGE_INTEGER LastLogoff;
+    LARGE_INTEGER PasswordLastSet;
+    LARGE_INTEGER AccountExpires;
+    LARGE_INTEGER PasswordCanChange;
+    LARGE_INTEGER PasswordMustChange;
+    UNICODE_STRING UserName;
+    UNICODE_STRING FullName;
+    UNICODE_STRING HomeDirectory;
+    UNICODE_STRING HomeDirectoryDrive;
+    UNICODE_STRING ScriptPath;
+    UNICODE_STRING ProfilePath;
+    UNICODE_STRING AdminComment;
+    UNICODE_STRING WorkStations;
+    UNICODE_STRING UserComment;
+    UNICODE_STRING Parameters;
+    UNICODE_STRING LmPassword;
+    UNICODE_STRING NtPassword;
+    UNICODE_STRING PrivateData;
+    SR_SECURITY_DESCRIPTOR SecurityDescriptor;
+    ULONG UserId;
+    ULONG PrimaryGroupId;
+    ULONG UserAccountControl;
+    ULONG WhichFields;
+    LOGON_HOURS LogonHours;
+    USHORT BadPasswordCount;
+    USHORT LogonCount;
+    USHORT CountryCode;
+    USHORT CodePage;
+    BOOLEAN LmPasswordPresent;
+    BOOLEAN NtPasswordPresent;
+    BOOLEAN PasswordExpired;
+    BOOLEAN PrivateDataSensitive;
+}
+alias USER_ALL_INFORMATION* PUSER_ALL_INFORMATION;
+align:
+
+struct MSV1_0_VALIDATION_INFO {
+    LARGE_INTEGER LogoffTime;
+    LARGE_INTEGER KickoffTime;
+    UNICODE_STRING LogonServer;
+    UNICODE_STRING LogonDomainName;
+    USER_SESSION_KEY SessionKey;
+    BOOLEAN Authoritative;
+    ULONG UserFlags;
+    ULONG WhichFields;
+    ULONG UserId;
+}
+alias MSV1_0_VALIDATION_INFO* PMSV1_0_VALIDATION_INFO;
+
+struct NETLOGON_LOGON_IDENTITY_INFO {
+    UNICODE_STRING LogonDomainName;
+    ULONG ParameterControl;
+    OLD_LARGE_INTEGER LogonId;
+    UNICODE_STRING UserName;
+    UNICODE_STRING Workstation;
+}
+alias NETLOGON_LOGON_IDENTITY_INFO* PNETLOGON_LOGON_IDENTITY_INFO;
+
+struct NETLOGON_INTERACTIVE_INFO {
+    NETLOGON_LOGON_IDENTITY_INFO Identity;
+    LM_OWF_PASSWORD LmOwfPassword;
+    NT_OWF_PASSWORD NtOwfPassword;
+}
+alias NETLOGON_INTERACTIVE_INFO* PNETLOGON_INTERACTIVE_INFO;
+
+struct NETLOGON_GENERIC_INFO {
+    NETLOGON_LOGON_IDENTITY_INFO Identity;
+    UNICODE_STRING PackageName;
+    ULONG DataLength;
+    PUCHAR LogonData;
+}
+alias NETLOGON_GENERIC_INFO* PNETLOGON_GENERIC_INFO;
+
+struct NETLOGON_NETWORK_INFO {
+    NETLOGON_LOGON_IDENTITY_INFO Identity;
+    LM_CHALLENGE LmChallenge;
+    STRING NtChallengeResponse;
+    STRING LmChallengeResponse;
+}
+alias NETLOGON_NETWORK_INFO* PNETLOGON_NETWORK_INFO;
+
+struct NETLOGON_SERVICE_INFO {
+    NETLOGON_LOGON_IDENTITY_INFO Identity;
+    LM_OWF_PASSWORD LmOwfPassword;
+    NT_OWF_PASSWORD NtOwfPassword;
+}
+alias NETLOGON_SERVICE_INFO* PNETLOGON_SERVICE_INFO;
+
+extern (Windows) {
+NTSTATUS Msv1_0SubAuthenticationRoutine(NETLOGON_LOGON_INFO_CLASS,PVOID,
+    ULONG,PUSER_ALL_INFORMATION,PULONG,PULONG,
+    PBOOLEAN,PLARGE_INTEGER,PLARGE_INTEGER);
+NTSTATUS Msv1_0SubAuthenticationFilter(NETLOGON_LOGON_INFO_CLASS,PVOID,
+    ULONG,PUSER_ALL_INFORMATION,PULONG,PULONG,
+    PBOOLEAN,PLARGE_INTEGER,PLARGE_INTEGER);
+NTSTATUS Msv1_0SubAuthenticationRoutineGeneric(PVOID,ULONG,PULONG,PVOID*);
+NTSTATUS Msv1_0SubAuthenticationRoutineEx(NETLOGON_LOGON_INFO_CLASS,PVOID,
+    ULONG,PUSER_ALL_INFORMATION,SAM_HANDLE,
+    PMSV1_0_VALIDATION_INFO,PULONG);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/threadaux.d b/libphobos/libdruntime/core/sys/windows/threadaux.d
new file mode 100644
index 00000000000..ae70c9aff4b
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/threadaux.d
@@ -0,0 +1,354 @@
+/**
+ * This module provides OS specific helper function for threads support
+ *
+ * Copyright: Copyright Digital Mars 2010 - 2010.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Source:    $(DRUNTIMESRC core/sys/windows/_threadaux.d)
+ * Authors:   Rainer Schuetze
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module core.sys.windows.threadaux;
+version (Windows):
+
+import core.sys.windows.windows;
+import core.stdc.stdlib;
+
+public import core.thread;
+
+extern(Windows)
+HANDLE OpenThread(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId) nothrow;
+
+extern (C) extern __gshared int _tls_index;
+
+extern (C) // rt.minfo
+{
+    void rt_moduleTlsCtor();
+    void rt_moduleTlsDtor();
+}
+
+private:
+///////////////////////////////////////////////////////////////////
+struct thread_aux
+{
+    // don't let symbols leak into other modules
+
+    enum SystemProcessInformation = 5;
+    enum STATUS_INFO_LENGTH_MISMATCH = 0xc0000004;
+
+    // structs subject to change according to MSDN, more info at http://undocumented.ntinternals.net
+    // declarations according to http://processhacker.sourceforge.net/doc/ntexapi_8h_source.html
+    // NOTE: the declarations assume default alignment for Win64 and contain some padding data
+    struct UNICODE_STRING
+    {
+        short Length;
+        short MaximumLength;
+        wchar* Buffer;
+    }
+    // process or thread ID, documentation says it is a HANDLE, but it's actually the ID (a DWORD)
+    alias size_t PTID;
+
+    struct _SYSTEM_PROCESS_INFORMATION
+    {
+        int     NextEntryOffset; // When this entry is 0, there are no more processes to be read.
+        int     NumberOfThreads;
+        long    WorkingSetPrivateSize;
+        uint    HardFaultCount;
+        uint    NumberOfThreadsHighWatermark;
+        ulong   CycleTime;
+        long    CreateTime;
+        long    UserTime;
+        long    KernelTime;
+        UNICODE_STRING      ImageName;
+        int     BasePriority;
+        PTID    /*Unique*/ProcessId;
+        PTID    InheritedFromUniqueProcessId;
+        uint    HandleCount;
+        uint    SessionId;
+        size_t  UniqueProcessKey;
+        size_t  PeakVirtualSize;
+        size_t  VirtualSize;
+        uint    PageFaultCount;
+        size_t  PeakWorkingSetSize;
+        size_t  WorkingSetSize;
+        size_t  QuotaPeakPagedPoolUsage;
+        size_t  QuotaPagedPoolUsage;
+        size_t  QuotaPeakNonPagedPoolUsage;
+        size_t  QuotaNonPagedPoolUsage;
+        size_t  PagefileUsage;
+        size_t  PeakPagefileUsage;
+        size_t  PrivatePageCount;
+        long    ReadOperationCount;
+        long    WriteOperationCount;
+        long    OtherOperationCount;
+        long    ReadTransferCount;
+        long    WriteTransferCount;
+        long    OtherTransferCount;
+
+        // SYSTEM_THREAD_INFORMATION or SYSTEM_EXTENDED_THREAD_INFORMATION structures follow.
+    }
+
+    struct _SYSTEM_THREAD_INFORMATION
+    {
+        long    KernelTime;
+        long    UserTime;
+        long    CreateTime;
+        uint    WaitTime;
+        void*   StartAddress;
+        PTID    ProcessId;
+        PTID    ThreadId;
+        int     Priority;
+        int     BasePriority;
+        uint    ContextSwitches;
+        uint    ThreadState;
+        int     WaitReason;
+        int     reserved;
+    }
+
+    alias fnNtQuerySystemInformation = extern(Windows)
+    HRESULT function( uint SystemInformationClass, void* info, uint infoLength, uint* ReturnLength ) nothrow;
+
+    enum ThreadBasicInformation = 0;
+
+    struct THREAD_BASIC_INFORMATION
+    {
+        int    ExitStatus;
+        void** TebBaseAddress;
+        PTID   ProcessId;
+        PTID   ThreadId;
+        size_t AffinityMask;
+        int    Priority;
+        int    BasePriority;
+    }
+
+    alias fnNtQueryInformationThread = extern(Windows)
+    int function( HANDLE ThreadHandle, uint ThreadInformationClass, void* buf, uint size, uint* ReturnLength ) nothrow;
+
+    enum SYNCHRONIZE = 0x00100000;
+    enum THREAD_GET_CONTEXT = 8;
+    enum THREAD_QUERY_INFORMATION = 0x40;
+    enum THREAD_SUSPEND_RESUME = 2;
+
+    ///////////////////////////////////////////////////////////////////
+    // get the thread environment block (TEB) of the thread with the given handle
+    static void** getTEB( HANDLE hnd ) nothrow
+    {
+        HANDLE nthnd = GetModuleHandleA( "NTDLL" );
+        assert( nthnd, "cannot get module handle for ntdll" );
+        fnNtQueryInformationThread fn = cast(fnNtQueryInformationThread) GetProcAddress( nthnd, "NtQueryInformationThread" );
+        assert( fn, "cannot find NtQueryInformationThread in ntdll" );
+
+        THREAD_BASIC_INFORMATION tbi;
+        int Status = (*fn)(hnd, ThreadBasicInformation, &tbi, tbi.sizeof, null);
+        assert(Status == 0);
+
+        return tbi.TebBaseAddress;
+    }
+
+    // get the thread environment block (TEB) of the thread with the given identifier
+    static void** getTEB( uint id ) nothrow
+    {
+        HANDLE hnd = OpenThread( THREAD_QUERY_INFORMATION, FALSE, id );
+        assert( hnd, "OpenThread failed" );
+
+        void** teb = getTEB( hnd );
+        CloseHandle( hnd );
+        return teb;
+    }
+
+    // get linear address of TEB of current thread
+    static void** getTEB() nothrow
+    {
+        version(Win32)
+        {
+            version(GNU_InlineAsm)
+            {
+                void** teb;
+                asm pure nothrow @nogc { "movl %%fs:0x18, %0;" : "=r" teb; }
+                return teb;
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    naked;
+                    mov EAX,FS:[0x18];
+                    ret;
+                }
+            }
+        }
+        else version(Win64)
+        {
+            version(GNU_InlineAsm)
+            {
+                void** teb;
+                asm pure nothrow @nogc { "movq %%gs:0x30, %0;" : "=r" teb; }
+                return teb;
+            }
+            else
+            {
+                asm pure nothrow @nogc
+                {
+                    naked;
+                    mov RAX,0x30;
+                    mov RAX,GS:[RAX]; // immediate value causes fixup
+                    ret;
+                }
+            }
+        }
+        else
+        {
+            static assert(false);
+        }
+    }
+
+    // get the stack bottom (the top address) of the thread with the given handle
+    static void* getThreadStackBottom( HANDLE hnd ) nothrow
+    {
+        void** teb = getTEB( hnd );
+        return teb[1];
+    }
+
+    // get the stack bottom (the top address) of the thread with the given identifier
+    static void* getThreadStackBottom( uint id ) nothrow
+    {
+        void** teb = getTEB( id );
+        return teb[1];
+    }
+
+    // create a thread handle with full access to the thread with the given identifier
+    static HANDLE OpenThreadHandle( uint id ) nothrow
+    {
+        return OpenThread( SYNCHRONIZE|THREAD_GET_CONTEXT|THREAD_QUERY_INFORMATION|THREAD_SUSPEND_RESUME, FALSE, id );
+    }
+
+    ///////////////////////////////////////////////////////////////////
+    // enumerate threads of the given process calling the passed function on each thread
+    // using function instead of delegate here to avoid allocating closure
+    static bool enumProcessThreads( uint procid, bool function( uint id, void* context ) dg, void* context )
+    {
+        HANDLE hnd = GetModuleHandleA( "NTDLL" );
+        fnNtQuerySystemInformation fn = cast(fnNtQuerySystemInformation) GetProcAddress( hnd, "NtQuerySystemInformation" );
+        if( !fn )
+            return false;
+
+        uint sz = 16384;
+        uint retLength;
+        HRESULT rc;
+        char* buf;
+        for( ; ; )
+        {
+            buf = cast(char*) core.stdc.stdlib.malloc(sz);
+            if(!buf)
+                return false;
+            rc = fn( SystemProcessInformation, buf, sz, &retLength );
+            if( rc != STATUS_INFO_LENGTH_MISMATCH )
+                break;
+            core.stdc.stdlib.free( buf );
+            sz *= 2;
+        }
+        scope(exit) core.stdc.stdlib.free( buf );
+
+        if(rc != 0)
+            return false;
+
+        auto pinfo = cast(_SYSTEM_PROCESS_INFORMATION*) buf;
+        auto pend  = cast(_SYSTEM_PROCESS_INFORMATION*) (buf + retLength);
+        for( ; pinfo < pend; )
+        {
+            if( pinfo.ProcessId == procid )
+            {
+                auto tinfo = cast(_SYSTEM_THREAD_INFORMATION*)(pinfo + 1);
+                for( int i = 0; i < pinfo.NumberOfThreads; i++, tinfo++ )
+                    if( tinfo.ProcessId == procid )
+                        if( !dg( cast(uint) tinfo.ThreadId, context ) ) // IDs are actually DWORDs
+                            return false;
+            }
+            if( pinfo.NextEntryOffset == 0 )
+                break;
+            pinfo = cast(_SYSTEM_PROCESS_INFORMATION*) (cast(char*) pinfo + pinfo.NextEntryOffset);
+        }
+        return true;
+    }
+
+    static bool enumProcessThreads( bool function( uint id, void* context ) dg, void* context )
+    {
+        return enumProcessThreads( GetCurrentProcessId(), dg, context );
+    }
+
+    // execute function on the TLS for the given thread
+    alias extern(C) void function() externCVoidFunc;
+    static void impersonate_thread( uint id, externCVoidFunc fn )
+    {
+        impersonate_thread(id, () => fn());
+    }
+
+    static void impersonate_thread( uint id, scope void delegate() dg)
+    {
+        if( id == GetCurrentThreadId() )
+        {
+            dg();
+            return;
+        }
+
+        // temporarily set current TLS array pointer to the array pointer of the referenced thread
+        void** curteb = getTEB();
+        void** teb    = getTEB( id );
+        assert( teb && curteb );
+
+        void** curtlsarray = cast(void**) curteb[11];
+        void** tlsarray    = cast(void**) teb[11];
+        if( !curtlsarray || !tlsarray )
+            return;
+
+        curteb[11] = tlsarray;
+        dg();
+        curteb[11] = curtlsarray;
+    }
+}
+
+public:
+// forward as few symbols as possible into the "global" name space
+alias thread_aux.getTEB getTEB;
+alias thread_aux.getThreadStackBottom getThreadStackBottom;
+alias thread_aux.OpenThreadHandle OpenThreadHandle;
+alias thread_aux.enumProcessThreads enumProcessThreads;
+alias thread_aux.impersonate_thread impersonate_thread;
+
+// get the start of the TLS memory of the thread with the given handle
+void* GetTlsDataAddress( HANDLE hnd ) nothrow
+{
+    if( void** teb = getTEB( hnd ) )
+        if( void** tlsarray = cast(void**) teb[11] )
+            return tlsarray[_tls_index];
+    return null;
+}
+
+// get the start of the TLS memory of the thread with the given identifier
+void* GetTlsDataAddress( uint id ) nothrow
+{
+    HANDLE hnd = OpenThread( thread_aux.THREAD_QUERY_INFORMATION, FALSE, id );
+    assert( hnd, "OpenThread failed" );
+
+    void* tls = GetTlsDataAddress( hnd );
+    CloseHandle( hnd );
+    return tls;
+}
+
+///////////////////////////////////////////////////////////////////
+// run rt_moduleTlsCtor in the context of the given thread
+void thread_moduleTlsCtor( uint id )
+{
+    thread_aux.impersonate_thread(id, &rt_moduleTlsCtor);
+}
+
+///////////////////////////////////////////////////////////////////
+// run rt_moduleTlsDtor in the context of the given thread
+void thread_moduleTlsDtor( uint id )
+{
+    thread_aux.impersonate_thread(id, &rt_moduleTlsDtor);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/tlhelp32.d b/libphobos/libdruntime/core/sys/windows/tlhelp32.d
new file mode 100644
index 00000000000..fc682c9d72c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/tlhelp32.d
@@ -0,0 +1,172 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_tlhelp32.d)
+ */
+module core.sys.windows.tlhelp32;
+version (Windows):
+pragma(lib, "kernel32");
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.windef;
+
+enum : uint {
+    HF32_DEFAULT = 1,
+    HF32_SHARED
+}
+
+enum : uint {
+    LF32_FIXED    = 0x1,
+    LF32_FREE     = 0x2,
+    LF32_MOVEABLE = 0x4
+}
+
+enum MAX_MODULE_NAME32 = 255;
+
+enum : uint {
+    TH32CS_SNAPHEAPLIST = 0x1,
+    TH32CS_SNAPPROCESS  = 0x2,
+    TH32CS_SNAPTHREAD   = 0x4,
+    TH32CS_SNAPMODULE   = 0x8,
+    TH32CS_SNAPALL      = (TH32CS_SNAPHEAPLIST|TH32CS_SNAPPROCESS|TH32CS_SNAPTHREAD|TH32CS_SNAPMODULE),
+    TH32CS_INHERIT      = 0x80000000
+}
+
+struct HEAPLIST32 {
+    SIZE_T dwSize;
+    DWORD th32ProcessID;
+    ULONG_PTR th32HeapID;
+    DWORD dwFlags;
+}
+alias HEAPLIST32* PHEAPLIST32;
+alias HEAPLIST32* LPHEAPLIST32;
+
+struct HEAPENTRY32 {
+    SIZE_T dwSize;
+    HANDLE hHandle;
+    ULONG_PTR dwAddress;
+    SIZE_T dwBlockSize;
+    DWORD dwFlags;
+    DWORD dwLockCount;
+    DWORD dwResvd;
+    DWORD th32ProcessID;
+    ULONG_PTR th32HeapID;
+}
+alias HEAPENTRY32* PHEAPENTRY32;
+alias HEAPENTRY32* LPHEAPENTRY32;
+
+struct PROCESSENTRY32W {
+    DWORD dwSize;
+    DWORD cntUsage;
+    DWORD th32ProcessID;
+    ULONG_PTR th32DefaultHeapID;
+    DWORD th32ModuleID;
+    DWORD cntThreads;
+    DWORD th32ParentProcessID;
+    LONG pcPriClassBase;
+    DWORD dwFlags;
+    WCHAR[MAX_PATH] szExeFile;
+}
+alias PROCESSENTRY32W* PPROCESSENTRY32W;
+alias PROCESSENTRY32W* LPPROCESSENTRY32W;
+
+struct THREADENTRY32 {
+    DWORD dwSize;
+    DWORD cntUsage;
+    DWORD th32ThreadID;
+    DWORD th32OwnerProcessID;
+    LONG tpBasePri;
+    LONG tpDeltaPri;
+    DWORD dwFlags;
+}
+alias THREADENTRY32* PTHREADENTRY32;
+alias THREADENTRY32* LPTHREADENTRY32;
+
+struct MODULEENTRY32W {
+    DWORD dwSize;
+    DWORD th32ModuleID;
+    DWORD th32ProcessID;
+    DWORD GlblcntUsage;
+    DWORD ProccntUsage;
+    BYTE *modBaseAddr;
+    DWORD modBaseSize;
+    HMODULE hModule;
+    WCHAR[MAX_MODULE_NAME32 + 1] szModule;
+    WCHAR[MAX_PATH] szExePath;
+}
+alias MODULEENTRY32W* PMODULEENTRY32W;
+alias MODULEENTRY32W* LPMODULEENTRY32W;
+
+version(Unicode) {
+    alias PROCESSENTRY32W PROCESSENTRY32;
+    alias PPROCESSENTRY32W PPROCESSENTRY32;
+    alias LPPROCESSENTRY32W LPPROCESSENTRY32;
+
+    alias MODULEENTRY32W MODULEENTRY32;
+    alias PMODULEENTRY32W PMODULEENTRY32;
+    alias LPMODULEENTRY32W LPMODULEENTRY32;
+} else {
+    struct PROCESSENTRY32 {
+        DWORD dwSize;
+        DWORD cntUsage;
+        DWORD th32ProcessID;
+        ULONG_PTR th32DefaultHeapID;
+        DWORD th32ModuleID;
+        DWORD cntThreads;
+        DWORD th32ParentProcessID;
+        LONG pcPriClassBase;
+        DWORD dwFlags;
+        CHAR[MAX_PATH] szExeFile;
+    }
+    alias PROCESSENTRY32* PPROCESSENTRY32;
+    alias PROCESSENTRY32* LPPROCESSENTRY32;
+
+    struct MODULEENTRY32 {
+        DWORD dwSize;
+        DWORD th32ModuleID;
+        DWORD th32ProcessID;
+        DWORD GlblcntUsage;
+        DWORD ProccntUsage;
+        BYTE *modBaseAddr;
+        DWORD modBaseSize;
+        HMODULE hModule;
+        char[MAX_MODULE_NAME32 + 1] szModule;
+        char[MAX_PATH] szExePath;
+    }
+    alias MODULEENTRY32* PMODULEENTRY32;
+    alias MODULEENTRY32* LPMODULEENTRY32;
+}
+
+
+extern(Windows) nothrow @nogc {
+    BOOL Heap32First(LPHEAPENTRY32,DWORD,DWORD);
+    BOOL Heap32ListFirst(HANDLE,LPHEAPLIST32);
+    BOOL Heap32ListNext(HANDLE,LPHEAPLIST32);
+    BOOL Heap32Next(LPHEAPENTRY32);
+    BOOL Thread32First(HANDLE,LPTHREADENTRY32);
+    BOOL Thread32Next(HANDLE,LPTHREADENTRY32);
+    BOOL Toolhelp32ReadProcessMemory(DWORD,LPCVOID,LPVOID,DWORD,LPDWORD);
+    HANDLE CreateToolhelp32Snapshot(DWORD,DWORD);
+    BOOL Module32FirstW(HANDLE,LPMODULEENTRY32W);
+    BOOL Module32NextW(HANDLE,LPMODULEENTRY32W);
+    BOOL Process32FirstW(HANDLE,LPPROCESSENTRY32W);
+    BOOL Process32NextW(HANDLE,LPPROCESSENTRY32W);
+}
+
+version(Unicode) {
+    alias Module32FirstW Module32First;
+    alias Module32NextW Module32Next;
+    alias Process32FirstW Process32First;
+    alias Process32NextW Process32Next;
+} else {
+    extern(Windows) nothrow @nogc {
+        BOOL Module32First(HANDLE,LPMODULEENTRY32);
+        BOOL Module32Next(HANDLE,LPMODULEENTRY32);
+        BOOL Process32First(HANDLE,LPPROCESSENTRY32);
+        BOOL Process32Next(HANDLE,LPPROCESSENTRY32);
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/windows/tmschema.d b/libphobos/libdruntime/core/sys/windows/tmschema.d
new file mode 100644
index 00000000000..ad62d0e40b3
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/tmschema.d
@@ -0,0 +1,758 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_tmschema.d)
+ */
+module core.sys.windows.tmschema;
+version (Windows):
+
+/* BUTTON parts */
+enum {
+    BP_PUSHBUTTON = 1,
+    BP_RADIOBUTTON = 2,
+    BP_CHECKBOX = 3,
+    BP_GROUPBOX = 4,
+    BP_USERBUTTON = 5
+}
+
+enum {
+    CBS_UNCHECKEDNORMAL = 1,
+    CBS_UNCHECKEDHOT = 2,
+    CBS_UNCHECKEDPRESSED = 3,
+    CBS_UNCHECKEDDISABLED = 4,
+    CBS_CHECKEDNORMAL = 5,
+    CBS_CHECKEDHOT = 6,
+    CBS_CHECKEDPRESSED = 7,
+    CBS_CHECKEDDISABLED = 8,
+    CBS_MIXEDNORMAL = 9,
+    CBS_MIXEDHOT = 10,
+    CBS_MIXEDPRESSED = 11,
+    CBS_MIXEDDISABLED = 12
+}
+
+enum {
+    GBS_NORMAL = 1,
+    GBS_DISABLED = 2
+}
+
+enum {
+    PBS_NORMAL = 1,
+    PBS_HOT = 2,
+    PBS_PRESSED = 3,
+    PBS_DISABLED = 4,
+    PBS_DEFAULTED = 5
+}
+
+enum {
+    RBS_UNCHECKEDNORMAL = 1,
+    RBS_UNCHECKEDHOT = 2,
+    RBS_UNCHECKEDPRESSED = 3,
+    RBS_UNCHECKEDDISABLED = 4,
+    RBS_CHECKEDNORMAL = 5,
+    RBS_CHECKEDHOT = 6,
+    RBS_CHECKEDPRESSED = 7,
+    RBS_CHECKEDDISABLED = 8
+}
+
+/* CLOCK parts */
+enum {
+    CLP_TIME = 1
+}
+
+enum {
+    CLS_NORMAL = 1
+}
+
+/* COMBOBOX parts */
+enum {
+    CP_DROPDOWNBUTTON = 1
+}
+
+enum {
+    CBXS_NORMAL = 1,
+    CBXS_HOT = 2,
+    CBXS_PRESSED = 3,
+    CBXS_DISABLED = 4
+}
+
+/* EDIT parts */
+enum {
+    EP_EDITTEXT = 1,
+    EP_CARET = 2
+}
+
+enum {
+    ETS_NORMAL = 1,
+    ETS_HOT = 2,
+    ETS_SELECTED = 3,
+    ETS_DISABLED = 4,
+    ETS_FOCUSED = 5,
+    ETS_READONLY = 6,
+    ETS_ASSIST = 7
+}
+/* EXPLORERBAR parts */
+enum {
+    EBP_HEADERBACKGROUND = 1,
+    EBP_HEADERCLOSE = 2,
+    EBP_HEADERPIN = 3,
+    EBP_IEBARMENU = 4,
+    EBP_NORMALGROUPBACKGROUND = 5,
+    EBP_NORMALGROUPCOLLAPSE = 6,
+    EBP_NORMALGROUPEXPAND = 7,
+    EBP_NORMALGROUPHEAD = 8,
+    EBP_SPECIALGROUPBACKGROUND = 9,
+    EBP_SPECIALGROUPCOLLAPSE = 10,
+    EBP_SPECIALGROUPEXPAND = 11,
+    EBP_SPECIALGROUPHEAD = 12
+}
+
+enum {
+    EBHC_NORMAL = 1,
+    EBHC_HOT = 2,
+    EBHC_PRESSED = 3
+}
+
+enum {
+    EBHP_NORMAL = 1,
+    EBHP_HOT = 2,
+    EBHP_PRESSED = 3,
+    EBHP_SELECTEDNORMAL = 4,
+    EBHP_SELECTEDHOT = 5,
+    EBHP_SELECTEDPRESSED = 6
+}
+
+enum {
+    EBM_NORMAL = 1,
+    EBM_HOT = 2,
+    EBM_PRESSED = 3
+}
+
+enum {
+    EBNGC_NORMAL = 1,
+    EBNGC_HOT = 2,
+    EBNGC_PRESSED = 3
+}
+
+enum {
+    EBNGE_NORMAL = 1,
+    EBNGE_HOT = 2,
+    EBNGE_PRESSED = 3
+}
+
+enum {
+    EBSGC_NORMAL = 1,
+    EBSGC_HOT = 2,
+    EBSGC_PRESSED = 3
+}
+
+enum {
+    EBSGE_NORMAL = 1,
+    EBSGE_HOT = 2,
+    EBSGE_PRESSED = 3
+}
+
+/* HEADER parts */
+enum {
+    HP_HEADERITEM = 1,
+    HP_HEADERITEMLEFT = 2,
+    HP_HEADERITEMRIGHT = 3,
+    HP_HEADERSORTARROW = 4
+}
+
+enum {
+    HIS_NORMAL = 1,
+    HIS_HOT = 2,
+    HIS_PRESSED = 3
+}
+
+enum {
+    HILS_NORMAL = 1,
+    HILS_HOT = 2,
+    HILS_PRESSED = 3
+}
+
+enum {
+    HIRS_NORMAL = 1,
+    HIRS_HOT = 2,
+    HIRS_PRESSED = 3
+}
+
+enum {
+    HSAS_SORTEDUP = 1,
+    HSAS_SORTEDDOWN = 2
+}
+
+/* LISTVIEW parts */
+enum {
+    LVP_LISTITEM = 1,
+    LVP_LISTGROUP = 2,
+    LVP_LISTDETAIL = 3,
+    LVP_LISTSORTEDDETAIL = 4,
+    LVP_EMPTYTEXT = 5
+}
+
+enum {
+    LIS_NORMAL = 1,
+    LIS_HOT = 2,
+    LIS_SELECTED = 3,
+    LIS_DISABLED = 4,
+    LIS_SELECTEDNOTFOCUS = 5
+}
+
+/* MENU parts */
+enum {
+    MP_MENUITEM = 1,
+    MP_MENUDROPDOWN = 2,
+    MP_MENUBARITEM = 3,
+    MP_MENUBARDROPDOWN = 4,
+    MP_CHEVRON = 5,
+    MP_SEPARATOR = 6
+}
+
+enum {
+    MS_NORMAL = 1,
+    MS_SELECTED = 2,
+    MS_DEMOTED = 3
+}
+/* MENUBAND parts */
+enum {
+    MDP_NEWAPPBUTTON = 1,
+    MDP_SEPERATOR = 2
+}
+
+enum {
+    MDS_NORMAL = 1,
+    MDS_HOT = 2,
+    MDS_PRESSED = 3,
+    MDS_DISABLED = 4,
+    MDS_CHECKED = 5,
+    MDS_HOTCHECKED = 6
+}
+
+/* PAGE parts */
+enum {
+    PGRP_UP = 1,
+    PGRP_DOWN = 2,
+    PGRP_UPHORZ = 3,
+    PGRP_DOWNHORZ = 4
+}
+
+enum {
+    DNS_NORMAL = 1,
+    DNS_HOT = 2,
+    DNS_PRESSED = 3,
+    DNS_DISABLED = 4
+}
+
+enum {
+    DNHZS_NORMAL = 1,
+    DNHZS_HOT = 2,
+    DNHZS_PRESSED = 3,
+    DNHZS_DISABLED = 4
+}
+
+enum {
+    UPS_NORMAL = 1,
+    UPS_HOT = 2,
+    UPS_PRESSED = 3,
+    UPS_DISABLED = 4
+}
+
+enum {
+    UPHZS_NORMAL = 1,
+    UPHZS_HOT = 2,
+    UPHZS_PRESSED = 3,
+    UPHZS_DISABLED = 4
+}
+
+/* PROGRESS parts */
+enum {
+    PP_BAR = 1,
+    PP_BARVERT = 2,
+    PP_CHUNK = 3,
+    PP_CHUNKVERT = 4
+}
+
+/* REBAR parts */
+enum {
+    RP_GRIPPER = 1,
+    RP_GRIPPERVERT = 2,
+    RP_BAND = 3,
+    RP_CHEVRON = 4,
+    RP_CHEVRONVERT = 5
+}
+
+enum {
+    CHEVS_NORMAL = 1,
+    CHEVS_HOT = 2,
+    CHEVS_PRESSED = 3
+}
+
+/* SCROLLBAR parts */
+enum {
+    SBP_ARROWBTN = 1,
+    SBP_THUMBBTNHORZ = 2,
+    SBP_THUMBBTNVERT = 3,
+    SBP_LOWERTRACKHORZ = 4,
+    SBP_UPPERTRACKHORZ = 5,
+    SBP_LOWERTRACKVERT = 6,
+    SBP_UPPERTRACKVERT = 7,
+    SBP_GRIPPERHORZ = 8,
+    SBP_GRIPPERVERT = 9,
+    SBP_SIZEBOX = 10
+}
+
+enum {
+    ABS_UPNORMAL = 1,
+    ABS_UPHOT = 2,
+    ABS_UPPRESSED = 3,
+    ABS_UPDISABLED = 4,
+    ABS_DOWNNORMAL = 5,
+    ABS_DOWNHOT = 6,
+    ABS_DOWNPRESSED = 7,
+    ABS_DOWNDISABLED = 8,
+    ABS_LEFTNORMAL = 9,
+    ABS_LEFTHOT = 10,
+    ABS_LEFTPRESSED = 11,
+    ABS_LEFTDISABLED = 12,
+    ABS_RIGHTNORMAL = 13,
+    ABS_RIGHTHOT = 14,
+    ABS_RIGHTPRESSED = 15,
+    ABS_RIGHTDISABLED = 16
+}
+
+enum {
+    SCRBS_NORMAL = 1,
+    SCRBS_HOT = 2,
+    SCRBS_PRESSED = 3,
+    SCRBS_DISABLED = 4
+}
+
+enum {
+    SZB_RIGHTALIGN = 1,
+    SZB_LEFTALIGN = 2
+}
+
+/* SPIN parts */
+enum {
+    SPNP_UP = 1,
+    SPNP_DOWN = 2,
+    SPNP_UPHORZ = 3,
+    SPNP_DOWNHORZ = 4
+}
+
+/* STARTPANEL parts */
+enum {
+    SPP_USERPANE = 1,
+    SPP_MOREPROGRAMS = 2,
+    SPP_MOREPROGRAMSARROW = 3,
+    SPP_PROGLIST = 4,
+    SPP_PROGLISTSEPARATOR = 5,
+    SPP_PLACESLIST = 6,
+    SPP_PLACESLISTSEPARATOR = 7,
+    SPP_LOGOFF = 8,
+    SPP_LOGOFFBUTTONS = 9,
+    SPP_USERPICTURE = 10,
+    SPP_PREVIEW = 11
+}
+
+enum {
+    SPLS_NORMAL = 1,
+    SPLS_HOT = 2,
+    SPLS_PRESSED = 3
+}
+
+enum {
+    SPS_NORMAL = 1,
+    SPS_HOT = 2,
+    SPS_PRESSED = 3
+}
+
+/* STATUS parts */
+enum {
+    SP_PANE = 1,
+    SP_GRIPPERPANE = 2,
+    SP_GRIPPER = 3
+}
+
+/* TAB parts */
+enum {
+    TABP_TABITEM = 1,
+    TABP_TABITEMLEFTEDGE = 2,
+    TABP_TABITEMRIGHTEDGE = 3,
+    TABP_TABITEMBOTHEDGE = 4,
+    TABP_TOPTABITEM = 5,
+    TABP_TOPTABITEMLEFTEDGE = 6,
+    TABP_TOPTABITEMRIGHTEDGE = 7,
+    TABP_TOPTABITEMBOTHEDGE = 8,
+    TABP_PANE = 9,
+    TABP_BODY = 10
+}
+
+enum {
+    TIS_NORMAL = 1,
+    TIS_HOT = 2,
+    TIS_SELECTED = 3,
+    TIS_DISABLED = 4,
+    TIS_FOCUSED = 5
+}
+
+enum {
+    TIBES_NORMAL = 1,
+    TIBES_HOT = 2,
+    TIBES_SELECTED = 3,
+    TIBES_DISABLED = 4,
+    TIBES_FOCUSED = 5
+}
+
+enum {
+    TILES_NORMAL = 1,
+    TILES_HOT = 2,
+    TILES_SELECTED = 3,
+    TILES_DISABLED = 4,
+    TILES_FOCUSED = 5
+}
+
+enum {
+    TIRES_NORMAL = 1,
+    TIRES_HOT = 2,
+    TIRES_SELECTED = 3,
+    TIRES_DISABLED = 4,
+    TIRES_FOCUSED = 5
+}
+
+enum {
+    TTIS_NORMAL = 1,
+    TTIS_HOT = 2,
+    TTIS_SELECTED = 3,
+    TTIS_DISABLED = 4,
+    TTIS_FOCUSED = 5
+}
+
+enum {
+    TTIBES_NORMAL = 1,
+    TTIBES_HOT = 2,
+    TTIBES_SELECTED = 3,
+    TTIBES_DISABLED = 4,
+    TTIBES_FOCUSED = 5
+}
+
+enum {
+    TTILES_NORMAL = 1,
+    TTILES_HOT = 2,
+    TTILES_SELECTED = 3,
+    TTILES_DISABLED = 4,
+    TTILES_FOCUSED = 5
+}
+
+enum {
+    TTIRES_NORMAL = 1,
+    TTIRES_HOT = 2,
+    TTIRES_SELECTED = 3,
+    TTIRES_DISABLED = 4,
+    TTIRES_FOCUSED = 5
+}
+
+/* TASKBAND parts */
+enum {
+    TDP_GROUPCOUNT = 1,
+    TDP_FLASHBUTTON = 2,
+    TDP_FLASHBUTTONGROUPMENU = 3
+}
+
+/* TASKBAR parts */
+enum {
+    TBP_BACKGROUNDBOTTOM = 1,
+    TBP_BACKGROUNDRIGHT = 2,
+    TBP_BACKGROUNDTOP = 3,
+    TBP_BACKGROUNDLEFT = 4,
+    TBP_SIZINGBARBOTTOM = 5,
+    TBP_SIZINGBARRIGHT = 6,
+    TBP_SIZINGBARTOP = 7,
+    TBP_SIZINGBARLEFT = 8
+}
+
+/* TOOLBAR parts */
+enum {
+    TP_BUTTON = 1,
+    TP_DROPDOWNBUTTON = 2,
+    TP_SPLITBUTTON = 3,
+    TP_SPLITBUTTONDROPDOWN = 4,
+    TP_SEPARATOR = 5,
+    TP_SEPARATORVERT = 6
+}
+
+enum {
+    TS_NORMAL = 1,
+    TS_HOT = 2,
+    TS_PRESSED = 3,
+    TS_DISABLED = 4,
+    TS_CHECKED = 5,
+    TS_HOTCHECKED = 6
+}
+
+/* TOOLTIP parts */
+enum {
+    TTP_STANDARD = 1,
+    TTP_STANDARDTITLE = 2,
+    TTP_BALLOON = 3,
+    TTP_BALLOONTITLE = 4,
+    TTP_CLOSE = 5
+}
+
+enum {
+    TTBS_NORMAL = 1,
+    TTBS_LINK = 2
+}
+
+enum {
+    TTCS_NORMAL = 1,
+    TTCS_HOT = 2,
+    TTCS_PRESSED = 3
+}
+
+enum {
+    TTSS_NORMAL = 1,
+    TTSS_LINK = 2
+}
+
+/* TRACKBAR parts */
+enum {
+    TKP_TRACK = 1,
+    TKP_TRACKVERT = 2,
+    TKP_THUMB = 3,
+    TKP_THUMBBOTTOM = 4,
+    TKP_THUMBTOP = 5,
+    TKP_THUMBVERT = 6,
+    TKP_THUMBLEFT = 7,
+    TKP_THUMBRIGHT = 8,
+    TKP_TICS = 9,
+    TKP_TICSVERT = 10
+}
+
+enum {
+    TUS_NORMAL = 1,
+    TUS_HOT = 2,
+    TUS_PRESSED = 3,
+    TUS_FOCUSED = 4,
+    TUS_DISABLED = 5
+}
+
+enum {
+    TUBS_NORMAL = 1,
+    TUBS_HOT = 2,
+    TUBS_PRESSED = 3,
+    TUBS_FOCUSED = 4,
+    TUBS_DISABLED = 5
+}
+
+enum {
+    TUVLS_NORMAL = 1,
+    TUVLS_HOT = 2,
+    TUVLS_PRESSED = 3,
+    TUVLS_FOCUSED = 4,
+    TUVLS_DISABLED = 5
+}
+
+enum {
+    TUVRS_NORMAL = 1,
+    TUVRS_HOT = 2,
+    TUVRS_PRESSED = 3,
+    TUVRS_FOCUSED = 4,
+    TUVRS_DISABLED = 5
+}
+
+enum {
+    TUTS_NORMAL = 1,
+    TUTS_HOT = 2,
+    TUTS_PRESSED = 3,
+    TUTS_FOCUSED = 4,
+    TUTS_DISABLED = 5
+}
+
+enum {
+    TUVS_NORMAL = 1,
+    TUVS_HOT = 2,
+    TUVS_PRESSED = 3,
+    TUVS_FOCUSED = 4,
+    TUVS_DISABLED = 5
+}
+
+enum {
+    TSS_NORMAL = 1
+}
+
+enum {
+    TSVS_NORMAL = 1
+}
+
+enum {
+    TRS_NORMAL = 1
+}
+
+enum {
+    TRVS_NORMAL = 1
+}
+
+/* TRAYNOTIFY parts */
+enum {
+    TNP_BACKGROUND = 1,
+    TNP_ANIMBACKGROUND = 2
+}
+
+/* TREEVIEW parts */
+enum {
+    TVP_TREEITEM = 1,
+    TVP_GLYPH = 2,
+    TVP_BRANCH = 3
+}
+
+enum {
+    GLPS_CLOSED = 1,
+    GLPS_OPENED = 2
+}
+
+enum {
+    TREIS_NORMAL = 1,
+    TREIS_HOT = 2,
+    TREIS_SELECTED = 3,
+    TREIS_DISABLED = 4,
+    TREIS_SELECTEDNOTFOCUS = 5
+}
+
+/* WINDOW parts */
+enum {
+    WP_CAPTION = 1,
+    WP_SMALLCAPTION = 2,
+    WP_MINCAPTION = 3,
+    WP_SMALLMINCAPTION = 4,
+    WP_MAXCAPTION = 5,
+    WP_SMALLMAXCAPTION = 6,
+    WP_FRAMELEFT = 7,
+    WP_FRAMERIGHT = 8,
+    WP_FRAMEBOTTOM = 9,
+    WP_SMALLFRAMELEFT = 10,
+    WP_SMALLFRAMERIGHT = 11,
+    WP_SMALLFRAMEBOTTOM = 12,
+    WP_SYSBUTTON = 13,
+    WP_MDISYSBUTTON = 14,
+    WP_MINBUTTON = 15,
+    WP_MDIMINBUTTON = 16,
+    WP_MAXBUTTON = 17,
+    WP_CLOSEBUTTON = 18,
+    WP_SMALLCLOSEBUTTON = 19,
+    WP_MDICLOSEBUTTON = 20,
+    WP_RESTOREBUTTON = 21,
+    WP_MDIRESTOREBUTTON = 22,
+    WP_HELPBUTTON = 23,
+    WP_MDIHELPBUTTON = 24,
+    WP_HORZSCROLL = 25,
+    WP_HORZTHUMB = 26,
+    WP_VERTSCROLL = 27,
+    WP_VERTTHUMB = 28,
+    WP_DIALOG = 29,
+    WP_CAPTIONSIZINGTEMPLATE = 30,
+    WP_SMALLCAPTIONSIZINGTEMPLATE = 31,
+    WP_FRAMELEFTSIZINGTEMPLATE = 32,
+    WP_SMALLFRAMELEFTSIZINGTEMPLATE = 33,
+    WP_FRAMERIGHTSIZINGTEMPLATE = 34,
+    WP_SMALLFRAMERIGHTSIZINGTEMPLATE = 35,
+    WP_FRAMEBOTTOMSIZINGTEMPLATE = 36,
+    WP_SMALLFRAMEBOTTOMSIZINGTEMPLATE = 37
+}
+
+enum {
+    CS_ACTIVE = 1,
+    CS_INACTIVE = 2,
+    CS_DISABLED = 3
+}
+
+enum {
+    CBS_NORMAL = 1,
+    CBS_HOT = 2,
+    CBS_PUSHED = 3,
+    CBS_DISABLED = 4
+}
+
+enum {
+    FS_ACTIVE = 1,
+    FS_INACTIVE = 2
+}
+
+enum {
+    HBS_NORMAL = 1,
+    HBS_HOT = 2,
+    HBS_PUSHED = 3,
+    HBS_DISABLED = 4
+}
+
+enum {
+    HSS_NORMAL = 1,
+    HSS_HOT = 2,
+    HSS_PUSHED = 3,
+    HSS_DISABLED = 4
+}
+
+enum {
+    HTS_NORMAL = 1,
+    HTS_HOT = 2,
+    HTS_PUSHED = 3,
+    HTS_DISABLED = 4
+}
+
+enum {
+    MAXBS_NORMAL = 1,
+    MAXBS_HOT = 2,
+    MAXBS_PUSHED = 3,
+    MAXBS_DISABLED = 4
+}
+
+enum {
+    MXCS_ACTIVE = 1,
+    MXCS_INACTIVE = 2,
+    MXCS_DISABLED = 3
+}
+
+enum {
+    MINBS_NORMAL = 1,
+    MINBS_HOT = 2,
+    MINBS_PUSHED = 3,
+    MINBS_DISABLED = 4
+}
+
+enum {
+    RBS_NORMAL = 1,
+    RBS_HOT = 2,
+    RBS_PUSHED = 3,
+    RBS_DISABLED = 4
+}
+
+enum {
+    SBS_NORMAL = 1,
+    SBS_HOT = 2,
+    SBS_PUSHED = 3,
+    SBS_DISABLED = 4
+}
+
+enum {
+    MNCS_ACTIVE = 1,
+    MNCS_INACTIVE = 2,
+    MNCS_DISABLED = 3
+}
+
+enum {
+    VSS_NORMAL = 1,
+    VSS_HOT = 2,
+    VSS_PUSHED = 3,
+    VSS_DISABLED = 4
+}
+
+enum {
+    VTS_NORMAL = 1,
+    VTS_HOT = 2,
+    VTS_PUSHED = 3,
+    VTS_DISABLED = 4
+}
diff --git a/libphobos/libdruntime/core/sys/windows/unknwn.d b/libphobos/libdruntime/core/sys/windows/unknwn.d
new file mode 100644
index 00000000000..8bcbc3c6074
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/unknwn.d
@@ -0,0 +1,55 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_unknwn.d)
+ */
+module core.sys.windows.unknwn;
+version (Windows):
+
+import core.sys.windows.objfwd, core.sys.windows.windef, core.sys.windows.wtypes;
+private import core.sys.windows.basetyps;
+
+extern (Windows) {
+    void* MIDL_user_allocate(size_t);
+    void MIDL_user_free(void*);
+}
+
+
+extern (Windows) {
+
+    interface IUnknown {
+        HRESULT QueryInterface(IID* riid, void** pvObject);
+        ULONG AddRef();
+        ULONG Release();
+    }
+
+    alias IUnknown LPUNKNOWN;
+
+    interface IClassFactory : IUnknown {
+        HRESULT CreateInstance(IUnknown UnkOuter, IID* riid, void** pvObject);
+        HRESULT LockServer(BOOL fLock);
+    }
+    alias IClassFactory LPCLASSFACTORY;
+
+    /+
+    // These do not seem to be necessary (or desirable) for D.
+    HRESULT IUnknown_QueryInterface_Proxy(IUnknown,REFIID,void**);
+    ULONG IUnknown_AddRef_Proxy(IUnknown);
+    ULONG IUnknown_Release_Proxy(IUnknown);
+    HRESULT IClassFactory_RemoteCreateInstance_Proxy(IClassFactory,REFIID,IUnknown*);
+    HRESULT IClassFactory_RemoteLockServer_Proxy(IClassFactory,BOOL);
+    HRESULT IClassFactory_CreateInstance_Proxy(IClassFactory,IUnknown,REFIID,void**);
+    HRESULT IClassFactory_CreateInstance_Stub(IClassFactory,REFIID,IUnknown*);
+    HRESULT IClassFactory_LockServer_Proxy(IClassFactory,BOOL);
+    HRESULT IClassFactory_LockServer_Stub(IClassFactory,BOOL);
+
+    void IUnknown_QueryInterface_Stub(LPRPCSTUBBUFFER,LPRPCCHANNELBUFFER,PRPC_MESSAGE,PDWORD);
+    void IUnknown_AddRef_Stub(LPRPCSTUBBUFFER,LPRPCCHANNELBUFFER,PRPC_MESSAGE,PDWORD);
+    void IUnknown_Release_Stub(LPRPCSTUBBUFFER,LPRPCCHANNELBUFFER,PRPC_MESSAGE,PDWORD);
+    void IClassFactory_RemoteCreateInstance_Stub(LPRPCSTUBBUFFER,LPRPCCHANNELBUFFER,PRPC_MESSAGE,PDWORD);
+    void IClassFactory_RemoteLockServer_Stub(LPRPCSTUBBUFFER,LPRPCCHANNELBUFFER,PRPC_MESSAGE,PDWORD);
+    +/
+}
diff --git a/libphobos/libdruntime/core/sys/windows/uuid.d b/libphobos/libdruntime/core/sys/windows/uuid.d
new file mode 100644
index 00000000000..fe857ecfe15
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/uuid.d
@@ -0,0 +1,4070 @@
+module core.sys.windows.uuid;
+version (Windows):
+
+import core.sys.windows.basetyps;
+
+export
+extern(C) {
+enum IID _DBBMKGUID = {0xF6304BB0, 0xD188, 0x11CD, [0xAD, 0x48, 0x00, 0xAA, 0x00, 0x3C, 0x9C, 0xB6]};
+enum IID _DBCIDGUID = {0xFE284700, 0xD188, 0x11CD, [0xAD, 0x48, 0x00, 0xAA, 0x00, 0x3C, 0x9C, 0xB6]};
+enum IID _GUID_NAMEONLY = {0xE8BF1170, 0xD188, 0x11CD, [0xAD, 0x48, 0x00, 0xAA, 0x00, 0x3C, 0x9C, 0xB6]};
+enum IID ARRAYID_PathProperties = {0x7ECBBA04, 0x2D97, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID BFID_GRAY_16 = {0xF9D6BC00, 0x449C, 0x11D0, [0x91, 0x8C, 0x00, 0xAA, 0x00, 0x6C, 0x1A, 0x01]};
+enum IID BFID_GRAY_8 = {0xD93DE910, 0x449C, 0x11D0, [0x91, 0x8C, 0x00, 0xAA, 0x00, 0x6C, 0x1A, 0x01]};
+enum IID BFID_MONOCHROME = {0xE436EB78, 0x524F, 0x11CE, [0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70]};
+enum IID BFID_RGB_24 = {0xE436EB7D, 0x524F, 0x11CE, [0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70]};
+enum IID BFID_RGB_32 = {0xE436EB7E, 0x524F, 0x11CE, [0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70]};
+enum IID BFID_RGB_4 = {0xE436EB79, 0x524F, 0x11CE, [0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70]};
+enum IID BFID_RGB_555 = {0xE436EB7C, 0x524F, 0x11CE, [0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70]};
+enum IID BFID_RGB_565 = {0xE436EB7B, 0x524F, 0x11CE, [0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70]};
+enum IID BFID_RGB_8 = {0xE436EB7A, 0x524F, 0x11CE, [0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70]};
+enum IID BFID_RGBA_32 = {0x773C9AC0, 0x3274, 0x11D0, [0xB7, 0x24, 0x00, 0xAA, 0x00, 0x6C, 0x1A, 0x01]};
+enum IID BHID_LinkTargetItem = {0x3981E228, 0xF559, 0x11D3, [0x8E, 0x3A, 0x00, 0xC0, 0x4F, 0x68, 0x37, 0xD5]};
+enum IID BHID_SFObject = {0x3981E224, 0xF559, 0x11D3, [0x8E, 0x3A, 0x00, 0xC0, 0x4F, 0x68, 0x37, 0xD5]};
+enum IID BHID_SFUIObject = {0x3981E225, 0xF559, 0x11D3, [0x8E, 0x3A, 0x00, 0xC0, 0x4F, 0x68, 0x37, 0xD5]};
+enum IID BHID_SFViewObject = {0x3981E226, 0xF559, 0x11D3, [0x8E, 0x3A, 0x00, 0xC0, 0x4F, 0x68, 0x37, 0xD5]};
+enum IID BHID_Storage = {0x3981E227, 0xF559, 0x11D3, [0x8E, 0x3A, 0x00, 0xC0, 0x4F, 0x68, 0x37, 0xD5]};
+enum IID BHID_StorageEnum = {0x4621A4E3, 0xF0D6, 0x4773, [0x8A, 0x9C, 0x46, 0xE7, 0x7B, 0x17, 0x48, 0x40]};
+enum IID BHID_Stream = {0x1CEBB3AB, 0x7C10, 0x499A, [0xA4, 0x17, 0x92, 0xCA, 0x16, 0xC4, 0xCB, 0x83]};
+enum IID CATID_BrowsableShellExt = {0x00021490, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CATID_BrowseInPlace = {0x00021491, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CATID_ClusCfgCapabilities = {0x4653EEC4, 0x2788, 0x4EBD, [0xA8, 0x31, 0x7E, 0x0D, 0x9F, 0x82, 0xD6, 0xE7]};
+enum IID CATID_ClusCfgMemberSetChangeListener = {0x8A43EAD4, 0x10F1, 0x440D, [0x8D, 0xAA, 0x1F, 0xE3, 0x8D, 0x16, 0x98, 0xCD]};
+enum IID CATID_ClusCfgResourceTypes = {0x7C4CAE52, 0xCAC9, 0x499D, [0x82, 0xC6, 0xBC, 0x6A, 0x21, 0x77, 0xE5, 0x56]};
+enum IID CATID_ClusCfgStartupListeners = {0xDF406DB4, 0x7872, 0x4A99, [0xBB, 0x3C, 0x14, 0xA9, 0xC3, 0x39, 0x33, 0xD1]};
+enum IID CATID_CommBand = {0x00021494, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CATID_Control = {0x40FC6ED4, 0x2438, 0x11CF, [0xA3, 0xDB, 0x08, 0x00, 0x36, 0xF1, 0x25, 0x02]};
+enum IID CATID_DesignTimeUIActivatableControl = {0xF2BB56D1, 0xDB07, 0x11D1, [0xAA, 0x6B, 0x00, 0x60, 0x97, 0xDB, 0x95, 0x39]};
+enum IID CATID_DeskBand = {0x00021492, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CATID_DocObject = {0x40FC6ED8, 0x2438, 0x11CF, [0xA3, 0xDB, 0x08, 0x00, 0x36, 0xF1, 0x25, 0x02]};
+enum IID CATID_EnumClusCfgManagedResources = {0x02A34F88, 0xD31A, 0x4688, [0xBD, 0xDD, 0x38, 0xA7, 0x39, 0xE4, 0xF8, 0x9B]};
+enum IID CATID_InfoBand = {0x00021493, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CATID_Insertable = {0x40FC6ED3, 0x2438, 0x11CF, [0xA3, 0xDB, 0x08, 0x00, 0x36, 0xF1, 0x25, 0x02]};
+enum IID CATID_InternetAware = {0x0DE86A58, 0x2BAA, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID CATID_IsShortcut = {0x40FC6ED6, 0x2438, 0x11CF, [0xA3, 0xDB, 0x08, 0x00, 0x36, 0xF1, 0x25, 0x02]};
+enum IID CATID_MARSHALER = {0x00000003, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CATID_NeverShowExt = {0x40FC6ED7, 0x2438, 0x11CF, [0xA3, 0xDB, 0x08, 0x00, 0x36, 0xF1, 0x25, 0x02]};
+enum IID CATID_PersistsToFile = {0x0DE86A56, 0x2BAA, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID CATID_PersistsToMemory = {0x0DE86A55, 0x2BAA, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID CATID_PersistsToMoniker = {0x0DE86A51, 0x2BAA, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID CATID_PersistsToPropertyBag = {0x0DE86A57, 0x2BAA, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID CATID_PersistsToStorage = {0x0DE86A52, 0x2BAA, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID CATID_PersistsToStream = {0x0DE86A54, 0x2BAA, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID CATID_PersistsToStreamInit = {0x0DE86A53, 0x2BAA, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID CATID_Printable = {0x40FC6ED9, 0x2438, 0x11CF, [0xA3, 0xDB, 0x08, 0x00, 0x36, 0xF1, 0x25, 0x02]};
+enum IID CATID_Programmable = {0x40FC6ED5, 0x2438, 0x11CF, [0xA3, 0xDB, 0x08, 0x00, 0x36, 0xF1, 0x25, 0x02]};
+enum IID CATID_RequiresDataPathHost = {0x0DE86A50, 0x2BAA, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID CATID_SafeForInitializing = {0x7DD95802, 0x9882, 0x11CF, [0x9F, 0xA9, 0x00, 0xAA, 0x00, 0x6C, 0x42, 0xC4]};
+enum IID CATID_SafeForScripting = {0x7DD95801, 0x9882, 0x11CF, [0x9F, 0xA9, 0x00, 0xAA, 0x00, 0x6C, 0x42, 0xC4]};
+enum IID CGID_DocHostCommandHandler = {0xF38BC242, 0xB950, 0x11D1, [0x89, 0x18, 0x00, 0xC0, 0x4F, 0xC2, 0xC8, 0x36]};
+enum IID CGID_DownloadHost = {0xE0608728, 0xAE4C, 0x11D1, [0xBA, 0x40, 0x00, 0xC0, 0x4F, 0xB9, 0x2D, 0x79]};
+enum IID CGID_Explorer = {0x000214D0, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CGID_ExplorerBarDoc = {0x000214D3, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CGID_InternetExplorer = {0xEB7EED00, 0xF74D, 0x11D2, [0xBB, 0x7F, 0x00, 0x10, 0x4B, 0x35, 0xE7, 0xF9]};
+enum IID CGID_MSHTML = {0xDE4BA900, 0x59CA, 0x11CF, [0x95, 0x92, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID CGID_ShellDocView = {0x000214D1, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CGID_ShellServiceObject = {0x000214D2, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CGID_ShortCut = {0x93A68750, 0x951A, 0x11D1, [0x94, 0x6F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]};
+enum IID CLSID_1 = {0xD34F1813, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_2 = {0xD34F1814, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_3 = {0xD34F1815, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_4 = {0xD34F1816, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_5 = {0xD34F1817, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_6 = {0xD34F1818, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_7 = {0xD34F1819, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_8 = {0xD34F181A, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_9 = {0xD34F181B, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_a = {0xD34F181C, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_AboutProtocol = {0x3050F406, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_AccessControlEntry = {0xB75AC000, 0x9BDD, 0x11D0, [0x85, 0x2C, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID CLSID_AccessControlList = {0xB85EA052, 0x9BDD, 0x11D0, [0x85, 0x2C, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID CLSID_AccountDiscovery = {0x3DAB30ED, 0x8132, 0x40BF, [0xA8, 0xBA, 0x7B, 0x50, 0x57, 0xF0, 0xCD, 0x10]};
+enum IID CLSID_ACLCustomMRU = {0x6935DB93, 0x21E8, 0x4CCC, [0xBE, 0xB9, 0x9F, 0xE3, 0xC7, 0x7A, 0x29, 0x7A]};
+enum IID CLSID_ACLHistory = {0x00BB2764, 0x6A77, 0x11D0, [0xA5, 0x35, 0x00, 0xC0, 0x4F, 0xD7, 0xD0, 0x62]};
+enum IID CLSID_ACListISF = {0x03C036F1, 0xA186, 0x11D0, [0x82, 0x4A, 0x00, 0xAA, 0x00, 0x5B, 0x43, 0x83]};
+enum IID CLSID_ACLMRU = {0x6756A641, 0xDE71, 0x11D0, [0x83, 0x1B, 0x00, 0xAA, 0x00, 0x5B, 0x43, 0x83]};
+enum IID CLSID_ACLMulti = {0x00BB2765, 0x6A77, 0x11D0, [0xA5, 0x35, 0x00, 0xC0, 0x4F, 0xD7, 0xD0, 0x62]};
+enum IID CLSID_ActiveDesktop = {0x75048700, 0xEF1F, 0x11D0, [0x98, 0x88, 0x00, 0x60, 0x97, 0xDE, 0xAC, 0xF9]};
+enum IID CLSID_AdapterInfo = {0x6F9942C9, 0xC1B1, 0x4AB5, [0x93, 0xDA, 0x60, 0x58, 0x99, 0x1D, 0xC8, 0xF3]};
+enum IID CLSID_AddrControl = {0x00000348, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_AddressBarParser = {0xE0E11A09, 0x5CB8, 0x4B6C, [0x83, 0x32, 0xE0, 0x07, 0x20, 0xA1, 0x68, 0xF2]};
+enum IID CLSID_ADsDSOObject = {0x549365D0, 0xEC26, 0x11CF, [0x83, 0x10, 0x00, 0xAA, 0x00, 0xB5, 0x05, 0xDB]};
+enum IID CLSID_ADsSecurityUtility = {0xF270C64A, 0xFFB8, 0x4AE4, [0x85, 0xFE, 0x3A, 0x75, 0xE5, 0x34, 0x79, 0x66]};
+enum IID CLSID_ADSystemInfo = {0x50B6327F, 0xAFD1, 0x11D2, [0x9C, 0xB9, 0x00, 0x00, 0xF8, 0x7A, 0x36, 0x9E]};
+enum IID CLSID_AlgSetup = {0x27D0BCCC, 0x344D, 0x4287, [0xAF, 0x37, 0x0C, 0x72, 0xC1, 0x61, 0xC1, 0x4C]};
+enum IID CLSID_AllClasses = {0x00000330, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_AlphabeticalCategorizer = {0x3C2654C6, 0x7372, 0x4F6B, [0xB3, 0x10, 0x55, 0xD6, 0x12, 0x8F, 0x49, 0xD2]};
+enum IID CLSID_AnchorClick = {0x13D5413C, 0x33B9, 0x11D2, [0x95, 0xA7, 0x00, 0xC0, 0x4F, 0x8E, 0xCB, 0x02]};
+enum IID CLSID_AnimationComposerFactory = {0x332B2A56, 0xF86C, 0x47E7, [0x86, 0x02, 0xFC, 0x42, 0xAC, 0x8B, 0x99, 0x20]};
+enum IID CLSID_AnimationComposerSiteFactory = {0x16911A65, 0xD41D, 0x4431, [0x87, 0xF7, 0xE7, 0x57, 0xF4, 0xD0, 0x3B, 0xD8]};
+enum IID CLSID_ApplicationGatewayServices = {0xF8ADE1D3, 0x49DF, 0x4B75, [0x90, 0x05, 0xEF, 0x95, 0x08, 0xE6, 0xA3, 0x37]};
+enum IID CLSID_AutoComplete = {0x00BB2763, 0x6A77, 0x11D0, [0xA5, 0x35, 0x00, 0xC0, 0x4F, 0xD7, 0xD0, 0x62]};
+enum IID CLSID_AutoDiscoveryProvider = {0xC4F3D5BF, 0x4809, 0x44E3, [0x84, 0xA4, 0x36, 0x8B, 0x6B, 0x33, 0xB0, 0xB4]};
+enum IID CLSID_AutoplayForSlideShow = {0x00E7B358, 0xF65B, 0x4DCF, [0x83, 0xDF, 0xCD, 0x02, 0x6B, 0x94, 0xBF, 0xD4]};
+enum IID CLSID_b = {0xD34F181D, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_BackgroundCopyManager = {0x4991D34B, 0x80A1, 0x4291, [0x83, 0xB6, 0x33, 0x28, 0x36, 0x6B, 0x90, 0x97]};
+enum IID CLSID_BackgroundCopyManager1_5 = {0xF087771F, 0xD74F, 0x4C1A, [0xBB, 0x8A, 0xE1, 0x6A, 0xCA, 0x91, 0x24, 0xEA]};
+enum IID CLSID_BackgroundCopyQMgr = {0x69AD4AEE, 0x51BE, 0x439B, [0xA9, 0x2C, 0x86, 0xAE, 0x49, 0x0E, 0x8B, 0x30]};
+enum IID CLSID_BackLink = {0xFCBF906F, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_BasicImageEffects = {0x16B280C8, 0xEE70, 0x11D1, [0x90, 0x66, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID CLSID_BasicImageEffectsPP = {0x16B280C9, 0xEE70, 0x11D1, [0x90, 0x66, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID CLSID_BlockFormats = {0x3050F831, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_BridgeTerminal = {0x8EBAE7A3, 0x8943, 0x11D1, [0x96, 0xB8, 0x00, 0xC0, 0x4F, 0xB6, 0xE8, 0x66]};
+enum IID CLSID_c = {0xD34F181E, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_CAccPropServices = {0xB5F8350B, 0x0548, 0x48B1, [0xA6, 0xEE, 0x88, 0xBD, 0x00, 0xB4, 0xA5, 0xE7]};
+enum IID CLSID_CActiveIMM = {0x4955DD33, 0xB159, 0x11D0, [0x8F, 0xCF, 0x00, 0xAA, 0x00, 0x6B, 0xCC, 0x59]};
+enum IID CLSID_CAnchorBrowsePropertyPage = {0x3050F3BB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CaseIgnoreList = {0x15F88A55, 0x4680, 0x11D1, [0xA3, 0xB4, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_CCheckBox = {0x3050F686, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CColorPropPage = {0x0BE35201, 0x8F91, 0x11CE, [0x9D, 0xE3, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]};
+enum IID CLSID_CCombobox = {0x3050F678, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CDBurn = {0xFBEB8A05, 0xBEEE, 0x4442, [0x80, 0x4E, 0x40, 0x9D, 0x6C, 0x45, 0x15, 0xE9]};
+enum IID CLSID_CDebugDocumentHelper = {0x83B8BCA6, 0x687C, 0x11D0, [0xA4, 0x05, 0x00, 0xAA, 0x00, 0x60, 0x27, 0x5C]};
+enum IID CLSID_CDeviceRect = {0x3050F6D4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CDirect3DRM = {0x4516EC41, 0x8F20, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID CLSID_CDirect3DRMAnimation = {0x4FA35698, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirect3DRMAnimationSet = {0x4FA35699, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirect3DRMClippedVisual = {0x5434E72D, 0x6D66, 0x11D1, [0xBB, 0x0B, 0x00, 0x00, 0xF8, 0x75, 0x86, 0x5A]};
+enum IID CLSID_CDirect3DRMDevice = {0x4FA3568E, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirect3DRMFace = {0x4FA35693, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirect3DRMFrame = {0x4FA35690, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirect3DRMFrameInterpolator = {0x0DE9EAA2, 0x3B84, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID CLSID_CDirect3DRMLight = {0x4FA35694, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirect3DRMLightInterpolator = {0x0DE9EAA6, 0x3B84, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID CLSID_CDirect3DRMMaterial = {0x4FA35697, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirect3DRMMaterialInterpolato = {0x0DE9EAA7, 0x3B84, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID CLSID_CDirect3DRMMesh = {0x4FA35691, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirect3DRMMeshBuilder = {0x4FA35692, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirect3DRMMeshInterpolator = {0x0DE9EAA3, 0x3B84, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID CLSID_CDirect3DRMProgressiveMesh = {0x4516EC40, 0x8F20, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID CLSID_CDirect3DRMShadow = {0x4FA3569B, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirect3DRMTexture = {0x4FA35695, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirect3DRMTextureInterpolator = {0x0DE9EAA8, 0x3B84, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID CLSID_CDirect3DRMUserVisual = {0x4FA3569A, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirect3DRMViewport = {0x4FA3568F, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirect3DRMViewportInterpolato = {0x0DE9EAA1, 0x3B84, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID CLSID_CDirect3DRMWrap = {0x4FA35696, 0x623F, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID CLSID_CDirectXFile = {0x4516EC43, 0x8F20, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID CLSID_CDLAgent = {0x7D559C10, 0x9FE9, 0x11D0, [0x93, 0xF7, 0x00, 0xAA, 0x00, 0x59, 0xCE, 0x02]};
+enum IID CLSID_CdlProtocol = {0x3DD53D40, 0x7B8B, 0x11D0, [0xB0, 0x13, 0x00, 0xAA, 0x00, 0x59, 0xCE, 0x02]};
+enum IID CLSID_CDocBrowsePropertyPage = {0x3050F3B4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CDownloadBehavior = {0x3050F5BE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CEnroll = {0x43F8F289, 0x7A20, 0x11D0, [0x8F, 0x06, 0x00, 0xC0, 0x4F, 0xC2, 0x95, 0xE1]};
+enum IID CLSID_CEventObj = {0x3050F48A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CFontPropPage = {0x0BE35200, 0x8F91, 0x11CE, [0x9D, 0xE3, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]};
+enum IID CLSID_CFSIconOverlayManager = {0x63B51F81, 0xC868, 0x11D0, [0x99, 0x9C, 0x00, 0xC0, 0x4F, 0xD6, 0x55, 0xE1]};
+enum IID CLSID_ChannelAgent = {0xE3A8BDE6, 0xABCE, 0x11D0, [0xBC, 0x4B, 0x00, 0xC0, 0x4F, 0xD9, 0x29, 0xDB]};
+enum IID CLSID_ChannelMgr = {0xB3CDAE90, 0xD170, 0x11D0, [0x80, 0x2B, 0x00, 0xC0, 0x4F, 0xD7, 0x5D, 0x13]};
+enum IID CLSID_CHeaderFooter = {0x3050F6CD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CHtmlArea = {0x3050F64F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CIEOptionElement = {0x3050F698, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CIESelectElement = {0x3050F688, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CImageBrowsePropertyPage = {0x3050F3B3, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_ClassInstallFilter = {0x32B533BB, 0xEDAE, 0x11D0, [0xBD, 0x5A, 0x00, 0xAA, 0x00, 0xB9, 0x2A, 0xF1]};
+enum IID CLSID_CLayoutRect = {0x3050F664, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_ClientCaps = {0x7E8BC44E, 0xAEFF, 0x11D1, [0x89, 0xC2, 0x00, 0xC0, 0x4F, 0xB6, 0xBF, 0xC4]};
+enum IID CLSID_ClusAppWiz = {0x24F97150, 0x6689, 0x11D1, [0x9A, 0xA7, 0x00, 0xC0, 0x4F, 0xB9, 0x3A, 0x80]};
+enum IID CLSID_ClusCfgAsyncEvictCleanup = {0x08F35A72, 0xD7C4, 0x42F4, [0xBC, 0x81, 0x51, 0x88, 0xE1, 0x9D, 0xFA, 0x39]};
+enum IID CLSID_ClusCfgEvictCleanup = {0x32152BE9, 0xDE8C, 0x4D0F, [0x81, 0xB0, 0xBC, 0xE5, 0xD1, 0x1E, 0xCB, 0x00]};
+enum IID CLSID_ClusCfgResTypeGenScript = {0xD513C4F4, 0x1D34, 0x44A3, [0x83, 0xD4, 0x81, 0x26, 0x51, 0xDB, 0x89, 0x18]};
+enum IID CLSID_ClusCfgResTypeMajorityNodeSet = {0xB6870B44, 0x0BDF, 0x4B46, [0xAC, 0x1F, 0x6C, 0x69, 0x1B, 0x62, 0x2E, 0xDF]};
+enum IID CLSID_ClusCfgResTypeServices = {0x6A370489, 0xBB52, 0x4727, [0xB7, 0x40, 0x08, 0xF4, 0x94, 0x16, 0x34, 0x78]};
+enum IID CLSID_ClusCfgStartupNotify = {0x105EEEB6, 0x32FD, 0x4EA9, [0x89, 0x12, 0x84, 0x3A, 0x7F, 0xF3, 0xCA, 0x2D]};
+enum IID CLSID_ClusCfgWizard = {0x1919C4FE, 0x6F46, 0x4027, [0x97, 0x7D, 0x0E, 0xF1, 0xC8, 0xF2, 0x63, 0x72]};
+enum IID CLSID_ClusterConfigurationType = {0xBF3768C2, 0xE0E5, 0x448F, [0x95, 0x2B, 0x25, 0xD4, 0x33, 0x2D, 0xEF, 0xA3]};
+enum IID CLSID_CMimeTypes = {0x3050F3FE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CMLangConvertCharset = {0xD66D6F99, 0xCDAA, 0x11D0, [0xB8, 0x22, 0x00, 0xC0, 0x4F, 0xC9, 0xB3, 0x1F]};
+enum IID CLSID_CMLangString = {0xC04D65CF, 0xB70D, 0x11D0, [0xB1, 0x88, 0x00, 0xAA, 0x00, 0x38, 0xC9, 0x69]};
+enum IID CLSID_CMultiLanguage = {0x275C23E2, 0x3747, 0x11D0, [0x9F, 0xEA, 0x00, 0xAA, 0x00, 0x3F, 0x86, 0x46]};
+enum IID CLSID_CNetCfg = {0x5B035261, 0x40F9, 0x11D1, [0xAA, 0xEC, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID CLSID_CoDitherToRGB8 = {0xA860CE50, 0x3910, 0x11D0, [0x86, 0xFC, 0x00, 0xA0, 0xC9, 0x13, 0xF7, 0x50]};
+enum IID CLSID_CoMapMIMEToCLSID = {0x30C3B080, 0x30FB, 0x11D0, [0xB7, 0x24, 0x00, 0xAA, 0x00, 0x6C, 0x1A, 0x01]};
+enum IID CLSID_ComBinding = {0x00000328, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_CommonQuery = {0x83BC5EC0, 0x6F2A, 0x11D0, [0xA1, 0xC4, 0x00, 0xAA, 0x00, 0xC1, 0x6E, 0x65]};
+enum IID CLSID_CompositePP = {0x25B33660, 0xFD83, 0x11D1, [0x8A, 0xDE, 0x44, 0x45, 0x53, 0x54, 0x00, 0x01]};
+enum IID CLSID_ConnectionCommonUi = {0x7007ACD1, 0x3202, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID CLSID_ConnectionManager = {0xBA126AD1, 0x2166, 0x11D1, [0xB1, 0xD0, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID CLSID_ConnectionManager2 = {0xBA126AE5, 0x2166, 0x11D1, [0xB1, 0xD0, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID CLSID_ControlPanel = {0x21EC2020, 0x3AEA, 0x1069, [0xA2, 0xDD, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D]};
+enum IID CLSID_ConvertVBX = {0xFB8F0822, 0x0164, 0x101B, [0x84, 0xED, 0x08, 0x00, 0x2B, 0x2E, 0xC7, 0x13]};
+enum IID CLSID_ConvolvePP = {0x25B33661, 0xFD83, 0x11D1, [0x8A, 0xDE, 0x44, 0x45, 0x53, 0x54, 0x00, 0x01]};
+enum IID CLSID_COpsProfile = {0x3050F402, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CoSniffStream = {0x6A01FDA0, 0x30DF, 0x11D0, [0xB7, 0x24, 0x00, 0xAA, 0x00, 0x6C, 0x1A, 0x01]};
+enum IID CLSID_CPersistDataPeer = {0x3050F487, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CPersistHistory = {0x3050F4C8, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CPersistShortcut = {0x3050F4C6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CPersistSnapshot = {0x3050F4C9, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CPersistUserData = {0x3050F48E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CPicturePropPage = {0x0BE35202, 0x8F91, 0x11CE, [0x9D, 0xE3, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]};
+enum IID CLSID_CPlugins = {0x3050F3FF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CRadioButton = {0x3050F69C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CrBarn = {0xC3BDF740, 0x0B58, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID CLSID_CrBarnPP = {0xFCAD7436, 0xF151, 0x4110, [0xB9, 0x7E, 0x32, 0xBD, 0x60, 0x7F, 0xBD, 0xB8]};
+enum IID CLSID_CrBlindPP = {0x213052C1, 0x100D, 0x11D2, [0x8B, 0x82, 0x00, 0xA0, 0xC9, 0x3C, 0x09, 0xB2]};
+enum IID CLSID_CrBlinds = {0x00C429C0, 0x0BA9, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID CLSID_CrBlur = {0x7312498D, 0xE87A, 0x11D1, [0x81, 0xE0, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID CLSID_CrBlurPP = {0x623E287E, 0xFC0E, 0x11D1, [0x9A, 0x77, 0x00, 0x00, 0xF8, 0x75, 0x6A, 0x10]};
+enum IID CLSID_CrEmboss = {0xF515306D, 0x0156, 0x11D2, [0x81, 0xEA, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID CLSID_CrEngrave = {0xF515306E, 0x0156, 0x11D2, [0x81, 0xEA, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID CLSID_CrInset = {0x93073C40, 0x0BA5, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID CLSID_CrIris = {0x3F69F351, 0x0379, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID CLSID_CrIrisPP = {0x80DE22C4, 0x0F44, 0x11D2, [0x8B, 0x82, 0x00, 0xA0, 0xC9, 0x3C, 0x09, 0xB2]};
+enum IID CLSID_CrRadialWipe = {0x424B71AF, 0x0695, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID CLSID_CrRadialWipePP = {0x33D932E0, 0x0F48, 0x11D2, [0x8B, 0x82, 0x00, 0xA0, 0xC9, 0x3C, 0x09, 0xB2]};
+enum IID CLSID_CrSlide = {0x810E402F, 0x056B, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID CLSID_CrSlidePP = {0xCC8CEDE1, 0x1003, 0x11D2, [0x8B, 0x82, 0x00, 0xA0, 0xC9, 0x3C, 0x09, 0xB2]};
+enum IID CLSID_CrSpiral = {0xACA97E00, 0x0C7D, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID CLSID_CrSpiralPP = {0xC6A4FE81, 0x1022, 0x11D2, [0x8B, 0x82, 0x00, 0xA0, 0xC9, 0x3C, 0x09, 0xB2]};
+enum IID CLSID_CrStretch = {0x7658F2A2, 0x0A83, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID CLSID_CrStretchPP = {0x15FB95E0, 0x0F77, 0x11D2, [0x8B, 0x82, 0x00, 0xA0, 0xC9, 0x3C, 0x09, 0xB2]};
+enum IID CLSID_CrWheel = {0x5AE1DAE0, 0x1461, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID CLSID_CrWheelPP = {0xFA9F6180, 0x1464, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID CLSID_CrZigzag = {0xE6E73D20, 0x0C8A, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID CLSID_CrZigzagPP = {0x1559A3C1, 0x102B, 0x11D2, [0x8B, 0x82, 0x00, 0xA0, 0xC9, 0x3C, 0x09, 0xB2]};
+enum IID CLSID_CScriptErrorList = {0xEFD01300, 0x160F, 0x11D2, [0xBB, 0x2E, 0x00, 0x80, 0x5F, 0xF7, 0xEF, 0xCA]};
+enum IID CLSID_CScrollBar = {0x3050F68A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CSliderBar = {0x3050F68E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CSpinButton = {0x3050F68C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CTemplatePrinter = {0x3050F6B3, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_CUrlHistory = {0x3C374A40, 0xBAE4, 0x11CF, [0xBF, 0x7D, 0x00, 0xAA, 0x00, 0x69, 0x46, 0xEE]};
+enum IID CLSID_CURLSearchHook = {0xCFBFAE00, 0x17A6, 0x11D0, [0x99, 0xCB, 0x00, 0xC0, 0x4F, 0xD6, 0x44, 0x97]};
+enum IID CLSID_CurrentUserClasses = {0x00000332, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_CUtilityButton = {0x3050F6B0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_d = {0xD34F181F, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_DAArray = {0x9CDE7340, 0x3C20, 0x11D0, [0xA3, 0x30, 0x00, 0xAA, 0x00, 0xB9, 0x2C, 0x03]};
+enum IID CLSID_DABbox2 = {0x50B4791E, 0x4731, 0x11D0, [0x89, 0x12, 0x00, 0xC0, 0x4F, 0xC2, 0xA0, 0xCA]};
+enum IID CLSID_DABbox3 = {0x4A933703, 0xE36F, 0x11D0, [0x9B, 0x99, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x1D]};
+enum IID CLSID_DABehavior = {0xC46C1BF2, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DABoolean = {0x25B0F91D, 0xD23D, 0x11D0, [0x9B, 0x85, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x1D]};
+enum IID CLSID_DACamera = {0xC46C1BD9, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DAColor = {0xC46C1BC9, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DADashStyle = {0x9CADDC0C, 0xAD56, 0x11D1, [0x9F, 0xF8, 0x00, 0xC0, 0x4F, 0xA3, 0x21, 0x95]};
+enum IID CLSID_DAEndStyle = {0xFC54BEAB, 0x5B12, 0x11D1, [0x8E, 0x7B, 0x00, 0xC0, 0x4F, 0xC2, 0x9D, 0x46]};
+enum IID CLSID_DAEvent = {0x3E2487C4, 0x8709, 0x11D0, [0xB1, 0x77, 0x00, 0xC0, 0x4F, 0xC2, 0xA0, 0xCA]};
+enum IID CLSID_DAFontStyle = {0x3F3DA01A, 0x4705, 0x11D0, [0x87, 0x10, 0x00, 0xC0, 0x4F, 0xC2, 0x9D, 0x46]};
+enum IID CLSID_DAGeometry = {0xC46C1BDB, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DAImage = {0xC46C1BCB, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DAImportationResult = {0x283807B3, 0x2C60, 0x11D0, [0xA3, 0x1D, 0x00, 0xAA, 0x00, 0xB9, 0x2C, 0x03]};
+enum IID CLSID_DAJoinStyle = {0xFC54BEAA, 0x5B12, 0x11D1, [0x8E, 0x7B, 0x00, 0xC0, 0x4F, 0xC2, 0x9D, 0x46]};
+enum IID CLSID_DALineStyle = {0x283807B8, 0x2C60, 0x11D0, [0xA3, 0x1D, 0x00, 0xAA, 0x00, 0xB9, 0x2C, 0x03]};
+enum IID CLSID_DAMatte = {0xC46C1BC3, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DAMicrophone = {0xC46C1BE3, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DAMontage = {0xC46C1BD7, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DANumber = {0xC46C1BC7, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DAPair = {0xBC0BFD34, 0xD21D, 0x11D0, [0x93, 0x85, 0x00, 0xC0, 0x4F, 0xB6, 0xBD, 0x36]};
+enum IID CLSID_DAPath2 = {0xC46C1BCF, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DAPickableResult = {0x34F681D0, 0x3640, 0x11CF, [0x92, 0x94, 0x00, 0xAA, 0x00, 0xB8, 0xA7, 0x33]};
+enum IID CLSID_DAPoint2 = {0xC46C1BD5, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DAPoint3 = {0xC46C1BE5, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DarwinAppPublisher = {0xCFCCC7A0, 0xA282, 0x11D1, [0x90, 0x82, 0x00, 0x60, 0x08, 0x05, 0x93, 0x82]};
+enum IID CLSID_DASound = {0xC46C1BD1, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DAStatics = {0xC46C1BF3, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DAString = {0xC46C1BD3, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DataChannel = {0xBBB36F15, 0x408D, 0x4056, [0x8C, 0x27, 0x92, 0x08, 0x43, 0xD4, 0x0B, 0xE5]};
+enum IID CLSID_DATransform2 = {0xC46C1BDF, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DATransform3 = {0xC46C1BC5, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DATuple = {0x283807B7, 0x2C60, 0x11D0, [0xA3, 0x1D, 0x00, 0xAA, 0x00, 0xB9, 0x2C, 0x03]};
+enum IID CLSID_DAUserData = {0x283807B4, 0x2C60, 0x11D0, [0xA3, 0x1D, 0x00, 0xAA, 0x00, 0xB9, 0x2C, 0x03]};
+enum IID CLSID_DAVector2 = {0xC46C1BE1, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DAVector3 = {0xC46C1BC0, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DAView = {0x960D8EFF, 0xE494, 0x11D1, [0xAB, 0x75, 0x00, 0xC0, 0x4F, 0xD9, 0x2B, 0x6B]};
+enum IID CLSID_DAViewerControl = {0xC46C1BEB, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DAViewerControlWindowed = {0xC46C1BF1, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID CLSID_DCOMAccessControl = {0x0000031D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_DebugHelper = {0x0BFCC060, 0x8C1D, 0x11D0, [0xAC, 0xCD, 0x00, 0xAA, 0x00, 0x60, 0x27, 0x5C]};
+enum IID CLSID_DeCompMimeFilter = {0x8F6B0360, 0xB80D, 0x11D0, [0xA9, 0xB3, 0x00, 0x60, 0x97, 0x94, 0x23, 0x11]};
+enum IID CLSID_DefaultDebugSessionProvider = {0x834128A2, 0x51F4, 0x11D0, [0x8F, 0x20, 0x00, 0x80, 0x5F, 0x2C, 0xD0, 0x64]};
+enum IID CLSID_DirectDraw = {0xD7B70EE0, 0x4340, 0x11CF, [0xB0, 0x63, 0x00, 0x20, 0xAF, 0xC2, 0xCD, 0x35]};
+enum IID CLSID_DirectDrawClipper = {0x593817A0, 0x7DB3, 0x11CF, [0xA2, 0xDE, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56]};
+enum IID CLSID_DirectDrawFactory2 = {0xB9DC4790, 0x4AF1, 0x11D1, [0x8C, 0x4C, 0x00, 0xC0, 0x4F, 0xD9, 0x30, 0xC5]};
+enum IID CLSID_DirectInput = {0x25E609E0, 0xB259, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID CLSID_DirectInputDevice = {0x25E609E1, 0xB259, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID CLSID_DirectMusic = {0x636B9F10, 0x0C7D, 0x11D1, [0x95, 0xB2, 0x00, 0x20, 0xAF, 0xDC, 0x74, 0x21]};
+enum IID CLSID_DirectMusicBand = {0x79BA9E00, 0xB6EE, 0x11D1, [0x86, 0xBE, 0x00, 0xC0, 0x4F, 0xBF, 0x8F, 0xEF]};
+enum IID CLSID_DirectMusicBandTrack = {0xD2AC2894, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicChordMap = {0xD2AC288F, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicChordMapTrack = {0xD2AC2896, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicChordTrack = {0xD2AC288B, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicCollection = {0x480FF4B0, 0x28B2, 0x11D1, [0xBE, 0xF7, 0x00, 0xC0, 0x4F, 0xBF, 0x8F, 0xEF]};
+enum IID CLSID_DirectMusicCommandTrack = {0xD2AC288C, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicComposer = {0xD2AC2890, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicGraph = {0xD2AC2884, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicLoader = {0xD2AC2892, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicMotifTrack = {0xD2AC288E, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicMuteTrack = {0xD2AC2898, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicPerformance = {0xD2AC2881, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicSegment = {0xD2AC2882, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicSegmentState = {0xD2AC2883, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicSeqTrack = {0xD2AC2886, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicSignPostTrack = {0xF17E8672, 0xC3B4, 0x11D1, [0x87, 0x0B, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicStyle = {0xD2AC288A, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicStyleTrack = {0xD2AC288D, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicSynth = {0x58C2B4D0, 0x46E7, 0x11D1, [0x89, 0xAC, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x29]};
+enum IID CLSID_DirectMusicSysExTrack = {0xD2AC2887, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicTempoTrack = {0xD2AC2885, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectMusicTimeSigTrack = {0xD2AC2888, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID CLSID_DirectPlay = {0xD1EB6D20, 0x8923, 0x11D0, [0x9D, 0x97, 0x00, 0xA0, 0xC9, 0x0A, 0x43, 0xCB]};
+enum IID CLSID_DirectPlayLobby = {0x2FE8F810, 0xB2A5, 0x11D0, [0xA7, 0x87, 0x00, 0x00, 0xF8, 0x03, 0xAB, 0xFC]};
+enum IID CLSID_DirectSound = {0x47D4D946, 0x62E8, 0x11CF, [0x93, 0xBC, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID CLSID_DirectSoundCapture = {0xB0210780, 0x89CD, 0x11D0, [0xAF, 0x08, 0x00, 0xA0, 0xC9, 0x25, 0xCD, 0x16]};
+enum IID CLSID_DispatchMapper = {0xE9225296, 0xC759, 0x11D1, [0xA0, 0x2B, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID CLSID_DNWithBinary = {0x7E99C0A3, 0xF935, 0x11D2, [0xBA, 0x96, 0x00, 0xC0, 0x4F, 0xB6, 0xD0, 0xD1]};
+enum IID CLSID_DNWithString = {0x334857CC, 0xF934, 0x11D2, [0xBA, 0x96, 0x00, 0xC0, 0x4F, 0xB6, 0xD0, 0xD1]};
+enum IID CLSID_DocFileColumnProvider = {0x24F14F01, 0x7B1C, 0x11D1, [0x83, 0x8F, 0x00, 0x00, 0xF8, 0x04, 0x61, 0xCF]};
+enum IID CLSID_DocHostUIHandler = {0x7057E952, 0xBD1B, 0x11D1, [0x89, 0x19, 0x00, 0xC0, 0x4F, 0xC2, 0xC8, 0x36]};
+enum IID CLSID_DOMChildrenCollection = {0x3050F5AA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_DOMDocument = {0x2933BF90, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID CLSID_DOMFreeThreadedDocument = {0x2933BF91, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID CLSID_DragDropHelper = {0x4657278A, 0x411B, 0x11D2, [0x83, 0x9A, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0]};
+enum IID CLSID_DriveSizeCategorizer = {0x94357B53, 0xCA29, 0x4B78, [0x83, 0xAE, 0xE8, 0xFE, 0x74, 0x09, 0x13, 0x4F]};
+enum IID CLSID_DriveTypeCategorizer = {0xB0A8F3CF, 0x4333, 0x4BAB, [0x88, 0x73, 0x1C, 0xCB, 0x1C, 0xAD, 0xA4, 0x8B]};
+enum IID CLSID_DsDisplaySpecifier = {0x1AB4A8C0, 0x6A0B, 0x11D2, [0xAD, 0x49, 0x00, 0xC0, 0x4F, 0xA3, 0x1A, 0x86]};
+enum IID CLSID_DsDomainTreeBrowser = {0x1698790A, 0xE2B4, 0x11D0, [0xB0, 0xB1, 0x00, 0xC0, 0x4F, 0xD8, 0xDC, 0xA6]};
+enum IID CLSID_DsFindAdvanced = {0x83EE3FE3, 0x57D9, 0x11D0, [0xB9, 0x32, 0x00, 0xA0, 0x24, 0xAB, 0x2D, 0xBB]};
+enum IID CLSID_DsFindComputer = {0x16006700, 0x87AD, 0x11D0, [0x91, 0x40, 0x00, 0xAA, 0x00, 0xC1, 0x6E, 0x65]};
+enum IID CLSID_DsFindContainer = {0xC1B3CBF2, 0x886A, 0x11D0, [0x91, 0x40, 0x00, 0xAA, 0x00, 0xC1, 0x6E, 0x65]};
+enum IID CLSID_DsFindDomainController = {0x538C7B7E, 0xD25E, 0x11D0, [0x97, 0x42, 0x00, 0xA0, 0xC9, 0x06, 0xAF, 0x45]};
+enum IID CLSID_DsFindFrsMembers = {0x94CE4B18, 0xB3D3, 0x11D1, [0xB9, 0xB4, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0xB0]};
+enum IID CLSID_DsFindObjects = {0x83EE3FE1, 0x57D9, 0x11D0, [0xB9, 0x32, 0x00, 0xA0, 0x24, 0xAB, 0x2D, 0xBB]};
+enum IID CLSID_DsFindPeople = {0x83EE3FE2, 0x57D9, 0x11D0, [0xB9, 0x32, 0x00, 0xA0, 0x24, 0xAB, 0x2D, 0xBB]};
+enum IID CLSID_DsFindPrinter = {0xB577F070, 0x7EE2, 0x11D0, [0x91, 0x3F, 0x00, 0xAA, 0x00, 0xC1, 0x6E, 0x65]};
+enum IID CLSID_DsFindVolume = {0xC1B3CBF1, 0x886A, 0x11D0, [0x91, 0x40, 0x00, 0xAA, 0x00, 0xC1, 0x6E, 0x65]};
+enum IID CLSID_DsFolderProperties = {0x9E51E0D0, 0x6E0F, 0x11D2, [0x96, 0x01, 0x00, 0xC0, 0x4F, 0xA3, 0x1A, 0x86]};
+enum IID CLSID_DsPropertyPages = {0x0D45D530, 0x764B, 0x11D0, [0xA1, 0xCA, 0x00, 0xAA, 0x00, 0xC1, 0x6E, 0x65]};
+enum IID CLSID_DsQuery = {0x8A23E65E, 0x31C2, 0x11D0, [0x89, 0x1C, 0x00, 0xA0, 0x24, 0xAB, 0x2D, 0xBB]};
+enum IID CLSID_DWbemClassObject = {0x64AB3751, 0x12BC, 0x11D1, [0x9E, 0x61, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID CLSID_DWbemContext = {0x752FF212, 0xF7B7, 0x11D0, [0x9E, 0x4D, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID CLSID_DWbemLocator = {0xCB7CA032, 0xF729, 0x11D0, [0x9E, 0x4D, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID CLSID_DX2D = {0x473AA80B, 0x4577, 0x11D1, [0x81, 0xA8, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID CLSID_DXFade = {0x16B280C5, 0xEE70, 0x11D1, [0x90, 0x66, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID CLSID_DXGradient = {0xC6365470, 0xF667, 0x11D1, [0x90, 0x67, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID CLSID_DXLUTBuilder = {0x1E54333B, 0x2A00, 0x11D1, [0x81, 0x98, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID CLSID_DXRasterizer = {0x8652CE55, 0x9E80, 0x11D1, [0x90, 0x53, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID CLSID_DXSurface = {0x0E890F83, 0x5F79, 0x11D1, [0x90, 0x43, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID CLSID_DXSurfaceModifier = {0x3E669F1D, 0x9C23, 0x11D1, [0x90, 0x53, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID CLSID_DXTAlpha = {0xADC6CB82, 0x424C, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID CLSID_DXTAlphaImageLoader = {0x0C7EFBDE, 0x0303, 0x4C6F, [0xA4, 0xF7, 0x31, 0xFA, 0x2B, 0xE5, 0xE3, 0x97]};
+enum IID CLSID_DXTAlphaImageLoaderPP = {0x8C80CE2D, 0x850D, 0x47DA, [0x8E, 0xCD, 0x55, 0x02, 0x35, 0x62, 0xD1, 0x67]};
+enum IID CLSID_DXTAlphaPP = {0xD687A7E0, 0x4BA4, 0x11D2, [0x8A, 0xDE, 0x00, 0xA0, 0xC9, 0x8E, 0x65, 0x27]};
+enum IID CLSID_DXTaskManager = {0x4CB26C03, 0xFF93, 0x11D0, [0x81, 0x7E, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID CLSID_DXTBarn = {0xEC9BA17D, 0x60B5, 0x462B, [0xA6, 0xD8, 0x14, 0xB8, 0x90, 0x57, 0xE2, 0x2A]};
+enum IID CLSID_DXTBlinds = {0x9A4A4A51, 0xFB3A, 0x4F4B, [0x9B, 0x57, 0xA2, 0x91, 0x2A, 0x28, 0x97, 0x69]};
+enum IID CLSID_DXTCheckerBoard = {0xB3EE7802, 0x8224, 0x4787, [0xA1, 0xEA, 0xF0, 0xDE, 0x16, 0xDE, 0xAB, 0xD3]};
+enum IID CLSID_DXTCheckerBoardPP = {0xCBF47525, 0x98D2, 0x45EA, [0xB8, 0x43, 0xFD, 0x21, 0x3D, 0x93, 0x2B, 0x10]};
+enum IID CLSID_DXTChroma = {0x421516C1, 0x3CF8, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID CLSID_DXTChromaPP = {0xEC7E0760, 0x4C76, 0x11D2, [0x8A, 0xDE, 0x00, 0xA0, 0xC9, 0x8E, 0x65, 0x27]};
+enum IID CLSID_DXTComposite = {0x9A43A844, 0x0831, 0x11D1, [0x81, 0x7F, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID CLSID_DXTConvolution = {0x2BC0EF29, 0xE6BA, 0x11D1, [0x81, 0xDD, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID CLSID_DXTDropShadow = {0xADC6CB86, 0x424C, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID CLSID_DXTDropShadowPP = {0xEC7E0761, 0x4C76, 0x11D2, [0x8A, 0xDE, 0x00, 0xA0, 0xC9, 0x8E, 0x65, 0x27]};
+enum IID CLSID_DXTFilter = {0x385A91BC, 0x1E8A, 0x4E4A, [0xA7, 0xA6, 0xF4, 0xFC, 0x1E, 0x6C, 0xA1, 0xBD]};
+enum IID CLSID_DXTFilterBehavior = {0x649EEC1E, 0xB579, 0x4E8C, [0xBB, 0x3B, 0x49, 0x97, 0xF8, 0x42, 0x65, 0x36]};
+enum IID CLSID_DXTFilterCollection = {0xA7EE7F34, 0x3BD1, 0x427F, [0x92, 0x31, 0xF9, 0x41, 0xE9, 0xB7, 0xE1, 0xFE]};
+enum IID CLSID_DXTFilterFactory = {0x81397204, 0xF51A, 0x4571, [0x8D, 0x7B, 0xDC, 0x03, 0x05, 0x21, 0xAA, 0xBD]};
+enum IID CLSID_DXTGlow = {0x9F8E6421, 0x3D9B, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID CLSID_DXTGlowPP = {0xEC7E0764, 0x4C76, 0x11D2, [0x8A, 0xDE, 0x00, 0xA0, 0xC9, 0x8E, 0x65, 0x27]};
+enum IID CLSID_DXTGradientD = {0x623E2882, 0xFC0E, 0x11D1, [0x9A, 0x77, 0x00, 0x00, 0xF8, 0x75, 0x6A, 0x10]};
+enum IID CLSID_DXTGradientWipe = {0xB96F67A2, 0x30C2, 0x47E8, [0xBD, 0x85, 0x70, 0xA2, 0xC9, 0x48, 0xB5, 0x0F]};
+enum IID CLSID_DXTICMFilter = {0xA1BFB370, 0x5A9F, 0x4429, [0xBB, 0x72, 0xB1, 0x3E, 0x2F, 0xEA, 0xED, 0xEF]};
+enum IID CLSID_DXTICMFilterPP = {0x1958FB12, 0x31E6, 0x47E5, [0xAA, 0x49, 0xB2, 0x3D, 0x12, 0xC8, 0x53, 0xE6]};
+enum IID CLSID_DXTInset = {0x76F363F2, 0x7E9F, 0x4ED7, [0xA6, 0xA7, 0xEE, 0x30, 0x35, 0x1B, 0x66, 0x28]};
+enum IID CLSID_DXTIris = {0x049F2CE6, 0xD996, 0x4721, [0x89, 0x7A, 0xDB, 0x15, 0xCE, 0x9E, 0xB7, 0x3D]};
+enum IID CLSID_DXTLabel = {0x54702535, 0x2606, 0x11D1, [0x99, 0x9C, 0x00, 0x00, 0xF8, 0x75, 0x6A, 0x10]};
+enum IID CLSID_DXTLight = {0xF9EFBEC2, 0x4302, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID CLSID_DXTLightPP = {0x694AF25F, 0x124D, 0x11D3, [0x91, 0xD5, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID CLSID_DXTMaskFilter = {0x3A04D93B, 0x1EDD, 0x4F3F, [0xA3, 0x75, 0xA0, 0x3E, 0xC1, 0x95, 0x72, 0xC4]};
+enum IID CLSID_DXTMatrix = {0x4ABF5A06, 0x5568, 0x4834, [0xBE, 0xE3, 0x32, 0x7A, 0x6D, 0x95, 0xA6, 0x85]};
+enum IID CLSID_DXTMatrixPP = {0xC591103A, 0xB3A8, 0x4D47, [0xA3, 0xF7, 0x2A, 0xEE, 0xE4, 0xB8, 0x01, 0x3F]};
+enum IID CLSID_DXTMetaBurnFilm = {0x107045D1, 0x06E0, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID CLSID_DXTMetaCenterPeel = {0xAA0D4D0C, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID CLSID_DXTMetaColorFade = {0x2A54C908, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID CLSID_DXTMetaFlowMotion = {0x2A54C90B, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID CLSID_DXTMetaGriddler = {0x2A54C911, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID CLSID_DXTMetaGriddler2 = {0x2A54C913, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID CLSID_DXTMetaJaws = {0x2A54C904, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID CLSID_DXTMetaLightWipe = {0x107045C8, 0x06E0, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID CLSID_DXTMetaLiquid = {0xAA0D4D0A, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID CLSID_DXTMetaPageTurn = {0xAA0D4D08, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID CLSID_DXTMetaPeelPiece = {0xAA0D4D10, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID CLSID_DXTMetaPeelSmall = {0xAA0D4D0E, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID CLSID_DXTMetaPeelSplit = {0xAA0D4D12, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID CLSID_DXTMetaRadialScaleWipe = {0x107045CA, 0x06E0, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID CLSID_DXTMetaRipple = {0xAA0D4D03, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID CLSID_DXTMetaRoll = {0x9C61F46E, 0x0530, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID CLSID_DXTMetaThreshold = {0x2A54C915, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID CLSID_DXTMetaTwister = {0x107045CF, 0x06E0, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID CLSID_DXTMetaVacuum = {0x2A54C90D, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID CLSID_DXTMetaWater = {0x107045C5, 0x06E0, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID CLSID_DXTMetaWhiteOut = {0x107045CC, 0x06E0, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID CLSID_DXTMetaWormHole = {0x0E6AE022, 0x0C83, 0x11D2, [0x8C, 0xD4, 0x00, 0x10, 0x4B, 0xC7, 0x5D, 0x9A]};
+enum IID CLSID_DXTMotionBlur = {0xDD13DE77, 0xD3BA, 0x42D4, [0xB5, 0xC6, 0x77, 0x45, 0xFA, 0x4E, 0x2D, 0x4B]};
+enum IID CLSID_DXTMotionBlurPP = {0x926433E1, 0x7F8F, 0x4BC6, [0xBE, 0xC4, 0x8C, 0x12, 0x6C, 0x6B, 0x7D, 0xC4]};
+enum IID CLSID_DXTRadialWipe = {0x164484A9, 0x35D9, 0x4FB7, [0x9F, 0xAB, 0x48, 0x27, 0x3B, 0x96, 0xAA, 0x1D]};
+enum IID CLSID_DXTRandomBars = {0x2E7700B7, 0x27C4, 0x437F, [0x9F, 0xBF, 0x1E, 0x8B, 0xE2, 0x81, 0x75, 0x66]};
+enum IID CLSID_DXTRandomBarsPP = {0xE3E6AE11, 0x7FDC, 0x40C4, [0xAF, 0xBF, 0x1D, 0xCE, 0xA8, 0x28, 0x62, 0xCC]};
+enum IID CLSID_DXTRandomDissolve = {0xF7F4A1B6, 0x8E87, 0x452F, [0xA2, 0xD7, 0x30, 0x77, 0xF5, 0x08, 0xDB, 0xC0]};
+enum IID CLSID_DXTransformFactory = {0xD1FE6762, 0xFC48, 0x11D0, [0x88, 0x3A, 0x3C, 0x8B, 0x00, 0xC1, 0x00, 0x00]};
+enum IID CLSID_DXTRedirect = {0x42B07B28, 0x2280, 0x4937, [0xB0, 0x35, 0x02, 0x93, 0xFB, 0x81, 0x27, 0x81]};
+enum IID CLSID_DXTRevealTrans = {0xE31E87C4, 0x86EA, 0x4940, [0x9B, 0x8A, 0x5B, 0xD5, 0xD1, 0x79, 0xA7, 0x37]};
+enum IID CLSID_DXTScale = {0x555278E2, 0x05DB, 0x11D1, [0x88, 0x3A, 0x3C, 0x8B, 0x00, 0xC1, 0x00, 0x00]};
+enum IID CLSID_DXTShadow = {0xE71B4063, 0x3E59, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID CLSID_DXTShadowPP = {0xEC7E0765, 0x4C76, 0x11D2, [0x8A, 0xDE, 0x00, 0xA0, 0xC9, 0x8E, 0x65, 0x27]};
+enum IID CLSID_DXTSlide = {0xD1C5A1E7, 0xCC47, 0x4E32, [0xBD, 0xD2, 0x4B, 0x3C, 0x5F, 0xC5, 0x0A, 0xF5]};
+enum IID CLSID_DXTSpiral = {0x4A03DCB9, 0x6E17, 0x4A39, [0x88, 0x45, 0x4E, 0xE7, 0xDC, 0x53, 0x31, 0xA5]};
+enum IID CLSID_DXTStretch = {0xF088DE73, 0xBDD0, 0x4E3C, [0x81, 0xF8, 0x6D, 0x32, 0xF4, 0xFE, 0x9D, 0x28]};
+enum IID CLSID_DXTStrips = {0x63A4B1FC, 0x259A, 0x4A5B, [0x81, 0x29, 0xA8, 0x3B, 0x8C, 0x9E, 0x6F, 0x4F]};
+enum IID CLSID_DXTStripsPP = {0xFEC0B7EE, 0x7AEC, 0x4067, [0x9E, 0xE1, 0xFA, 0xCF, 0xB7, 0xCE, 0x9A, 0xF9]};
+enum IID CLSID_DXTWave = {0xADC6CB88, 0x424C, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID CLSID_DXTWavePP = {0xF12456C0, 0x4C9E, 0x11D2, [0x8A, 0xDE, 0x00, 0xA0, 0xC9, 0x8E, 0x65, 0x27]};
+enum IID CLSID_DXTWipe = {0xAF279B30, 0x86EB, 0x11D1, [0x81, 0xBF, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID CLSID_DXTWipePP = {0x7FFE4D08, 0xFBFD, 0x11D1, [0x9A, 0x77, 0x00, 0x00, 0xF8, 0x75, 0x6A, 0x10]};
+enum IID CLSID_DXTZigzag = {0x23E26328, 0x3928, 0x40F2, [0x95, 0xE5, 0x93, 0xCA, 0xD6, 0x90, 0x16, 0xEB]};
+enum IID CLSID_EAPOLManager = {0xBA126AE4, 0x2166, 0x11D1, [0xB1, 0xD0, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID CLSID_Email = {0x8F92A857, 0x478E, 0x11D1, [0xA3, 0xB4, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_EnumAdapterInfo = {0x6F9942CA, 0xC1B1, 0x4AB5, [0x93, 0xDA, 0x60, 0x58, 0x99, 0x1D, 0xC8, 0xF3]};
+enum IID CLSID_EVENTQUEUE = {0x6E0FF466, 0x339E, 0x11D1, [0xBE, 0x5B, 0x00, 0xC0, 0x4F, 0xC9, 0xE2, 0xBB]};
+enum IID CLSID_EXTENDEDERRORINFO = {0xC8B522CF, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID CLSID_FadePP = {0x16B280C6, 0xEE70, 0x11D1, [0x90, 0x66, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID CLSID_FaxNumber = {0xA5062215, 0x4681, 0x11D1, [0xA3, 0xB4, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_FilePlaybackTerminal = {0x0CB9914C, 0x79CD, 0x47DC, [0xAD, 0xB0, 0x32, 0x7F, 0x47, 0xCE, 0xFB, 0x20]};
+enum IID CLSID_FileProtocol = {0x79EAC9E7, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID CLSID_FileRecordingTerminal = {0x521F3D06, 0xC3D0, 0x4511, [0x86, 0x17, 0x86, 0xB9, 0xA7, 0x83, 0xDA, 0x77]};
+enum IID CLSID_FileRecordingTrack = {0xBF14A2E4, 0xE88B, 0x4EF5, [0x97, 0x40, 0x5A, 0xC5, 0xD0, 0x22, 0xF8, 0xC9]};
+enum IID CLSID_FileSearchBand = {0xC4EE31F3, 0x4768, 0x11D2, [0xBE, 0x5C, 0x00, 0xA0, 0xC9, 0xA8, 0x3D, 0xA1]};
+enum IID CLSID_FileSysColumnProvider = {0x0D2E74C4, 0x3C34, 0x11D2, [0xA2, 0x7E, 0x00, 0xC0, 0x4F, 0xC3, 0x08, 0x71]};
+enum IID CLSID_FileTerminal = {0xAAF578F1, 0xDC70, 0x11D0, [0x8E, 0xD3, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID CLSID_FolderShortcut = {0x0AFACED1, 0xE828, 0x11D1, [0x91, 0x87, 0xB5, 0x32, 0xF1, 0xE9, 0x57, 0x5D]};
+enum IID CLSID_FolderViewHost = {0x20B1CB23, 0x6968, 0x4EB9, [0xB7, 0xD4, 0xA6, 0x6D, 0x00, 0xD0, 0x7C, 0xEE]};
+enum IID CLSID_FontNames = {0x3050F83A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_FramesCollection = {0x3050F7F6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_FreeSpaceCategorizer = {0xB5607793, 0x24AC, 0x44C7, [0x82, 0xE2, 0x83, 0x17, 0x26, 0xAA, 0x6C, 0xB7]};
+enum IID CLSID_FtpProtocol = {0x79EAC9E3, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID CLSID_GblComponentCategoriesMgr = {0x0002E006, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_GLOBAL_BROADCAST = {0xD34F1810, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_GopherProtocol = {0x79EAC9E4, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID CLSID_GradientPP = {0x623E2880, 0xFC0E, 0x11D1, [0x9A, 0x77, 0x00, 0x00, 0xF8, 0x75, 0x6A, 0x10]};
+enum IID CLSID_HandsetTerminal = {0xAAF578EB, 0xDC70, 0x11D0, [0x8E, 0xD3, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID CLSID_HeadsetTerminal = {0xAAF578ED, 0xDC70, 0x11D0, [0x8E, 0xD3, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID CLSID_HNetCfgMgr = {0x46C166AA, 0x3108, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID CLSID_Hold = {0xB3AD3E13, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_HomeNetAutoConfigService = {0x9A8EA3B5, 0x572E, 0x4CB3, [0x9E, 0xB9, 0xEC, 0x68, 0x9A, 0xC5, 0x75, 0xAE]};
+enum IID CLSID_HomePage = {0x766BF2AE, 0xD650, 0x11D1, [0x98, 0x11, 0x00, 0xC0, 0x4F, 0xC3, 0x1D, 0x2E]};
+enum IID CLSID_HostDialogHelper = {0x429AF92C, 0xA51F, 0x11D2, [0x86, 0x1E, 0x00, 0xC0, 0x4F, 0xA3, 0x5C, 0x89]};
+enum IID CLSID_HTADocument = {0x3050F5C8, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTCAttachBehavior = {0x3050F5F5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTCDefaultDispatch = {0x3050F4FC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTCDescBehavior = {0x3050F5DD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTCEventBehavior = {0x3050F4FE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTCMethodBehavior = {0x3050F630, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTCPropertyBehavior = {0x3050F5DE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLAnchorElement = {0x3050F248, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLAppBehavior = {0x3050F5CB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLApplication = {0x3050F4D8, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLAreaElement = {0x3050F283, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLAreasCollection = {0x3050F4CA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLAttributeCollection = {0x3050F4CC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLBaseElement = {0x3050F276, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLBaseFontElement = {0x3050F282, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLBGsound = {0x3050F370, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLBlockElement = {0x3050F281, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLBody = {0x3050F24A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLBRElement = {0x3050F280, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLButtonElement = {0x3050F2C6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLCommentElement = {0x3050F317, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLCurrentStyle = {0x3050F3DC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLDDElement = {0x3050F27F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLDefaults = {0x3050F6C8, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLDialog = {0x3050F28A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLDivElement = {0x3050F27E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLDivPosition = {0x3050F249, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HtmlDlgSafeHelper = {0x3050F819, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLDListElement = {0x3050F27D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLDocument = {0x25336920, 0x03F9, 0x11CF, [0x8F, 0xD0, 0x00, 0xAA, 0x00, 0x68, 0x6F, 0x13]};
+enum IID CLSID_HTMLDOMAttribute = {0x3050F4B2, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLDOMImplementation = {0x3050F80E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLDOMTextNode = {0x3050F4BA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLDTElement = {0x3050F27C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLElementCollection = {0x3050F4CB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLEmbed = {0x3050F25D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLFieldSetElement = {0x3050F3E8, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLFontElement = {0x3050F27B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLFormElement = {0x3050F251, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLFrameBase = {0x3050F312, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLFrameElement = {0x3050F314, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLFrameSetSite = {0x3050F31A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLGenericElement = {0x3050F4B8, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLHeadElement = {0x3050F493, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLHeaderElement = {0x3050F27A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLHistory = {0xFECEAAA3, 0x8405, 0x11CF, [0x8B, 0xA1, 0x00, 0xAA, 0x00, 0x47, 0x6D, 0xA6]};
+enum IID CLSID_HTMLHRElement = {0x3050F252, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLHtmlElement = {0x3050F491, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLIFrame = {0x3050F316, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLImageElementFactory = {0x3050F38F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLImg = {0x3050F241, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLInputButtonElement = {0x3050F2B4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLInputElement = {0x3050F5D8, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLInputFileElement = {0x3050F2AE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLInputImage = {0x3050F2C4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLInputTextElement = {0x3050F2AB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLIsIndexElement = {0x3050F278, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLLabelElement = {0x3050F32B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLLegendElement = {0x3050F3E9, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLLIElement = {0x3050F273, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLLinkElement = {0x3050F277, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLListElement = {0x3050F272, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLLoadOptions = {0x18845040, 0x0FA5, 0x11D1, [0xBA, 0x19, 0x00, 0xC0, 0x4F, 0xD9, 0x12, 0xD0]};
+enum IID CLSID_HTMLLocation = {0x163BB1E1, 0x6E00, 0x11CF, [0x83, 0x7A, 0x48, 0xDC, 0x04, 0xC1, 0x00, 0x00]};
+enum IID CLSID_HTMLMapElement = {0x3050F271, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLMarqueeElement = {0x3050F2B9, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLMetaElement = {0x3050F275, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLNamespace = {0x3050F6BC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLNamespaceCollection = {0x3050F6B9, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLNavigator = {0xFECEAAA6, 0x8405, 0x11CF, [0x8B, 0xA1, 0x00, 0xAA, 0x00, 0x47, 0x6D, 0xA6]};
+enum IID CLSID_HTMLNextIdElement = {0x3050F279, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLNoShowElement = {0x3050F38B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLObjectElement = {0x3050F24E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLOListElement = {0x3050F270, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLOptionButtonElement = {0x3050F2BE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLOptionElement = {0x3050F24D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLOptionElementFactory = {0x3050F38D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLParaElement = {0x3050F26F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLParamElement = {0x3050F83E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLPhraseElement = {0x3050F26E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLPluginDocument = {0x25336921, 0x03F9, 0x11CF, [0x8F, 0xD0, 0x00, 0xAA, 0x00, 0x68, 0x6F, 0x13]};
+enum IID CLSID_HTMLPopup = {0x3050F667, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLRenderStyle = {0x3050F6AA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLRichtextElement = {0x3050F2DF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLRuleStyle = {0x3050F3D0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLScreen = {0x3050F35D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLScriptElement = {0x3050F28C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLSelectElement = {0x3050F245, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLSpanElement = {0x3050F3F5, 0x98B4, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLSpanFlow = {0x3050F3E6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLStyle = {0x3050F285, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLStyleElement = {0x3050F37D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLStyleFontFace = {0x3050F3D4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLStyleSheet = {0x3050F2E4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLStyleSheetPage = {0x3050F7EF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLStyleSheetPagesCollection = {0x3050F7F1, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLStyleSheetRule = {0x3050F3CE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLStyleSheetRulesCollection = {0x3050F3CD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLStyleSheetsCollection = {0x3050F37F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLTable = {0x3050F26B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLTableCaption = {0x3050F2EC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLTableCell = {0x3050F246, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLTableCol = {0x3050F26C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLTableRow = {0x3050F26D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLTableSection = {0x3050F2E9, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLTextAreaElement = {0x3050F2AC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLTextElement = {0x3050F26A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLTitleElement = {0x3050F284, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLUListElement = {0x3050F269, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLUnknownElement = {0x3050F268, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLUrnCollection = {0x3050F580, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HTMLWindow2 = {0xD48A6EC6, 0x6A4A, 0x11CF, [0x94, 0xA7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID CLSID_HTMLWindowProxy = {0x3050F391, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_HttpProtocol = {0x79EAC9E2, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID CLSID_HttpSProtocol = {0x79EAC9E5, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID CLSID_HWShellExecute = {0xFFB8655F, 0x81B9, 0x4FCE, [0xB8, 0x9C, 0x9A, 0x6B, 0xA7, 0x6D, 0x13, 0xE7]};
+enum IID CLSID_IActiveXSafetyProvider = {0xAAF8C6CE, 0xF972, 0x11D0, [0x97, 0xEB, 0x00, 0xAA, 0x00, 0x61, 0x53, 0x33]};
+enum IID CLSID_IImageDecodeFilter = {0x607FD4E8, 0x0A03, 0x11D1, [0xAB, 0x1D, 0x00, 0xC0, 0x4F, 0xC9, 0xB3, 0x04]};
+enum IID CLSID_IImgCtx = {0x3050F3D6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_ImageList = {0x7C476BA2, 0x02B1, 0x48F4, [0x80, 0x48, 0xB2, 0x46, 0x19, 0xDD, 0xC0, 0x58]};
+enum IID CLSID_ImageProperties = {0x7AB770C7, 0x0E23, 0x4D7A, [0x8A, 0xA2, 0x19, 0xBF, 0xAD, 0x47, 0x98, 0x29]};
+enum IID CLSID_InProcFreeMarshaler = {0x0000033A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_IntDitherer = {0x05F6FE1A, 0xECEF, 0x11D0, [0xAA, 0xE7, 0x00, 0xC0, 0x4F, 0xC9, 0xB3, 0x04]};
+enum IID CLSID_IntelliForms = {0x613AB92E, 0x16BF, 0x11D2, [0xBC, 0xA5, 0x00, 0xC0, 0x4F, 0xD9, 0x29, 0xDB]};
+enum IID CLSID_Internet = {0x871C5380, 0x42A0, 0x1069, [0xA2, 0xEA, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D]};
+enum IID CLSID_InternetButtons = {0x1E796980, 0x9CC5, 0x11D1, [0xA8, 0x3F, 0x00, 0xC0, 0x4F, 0xC9, 0x9D, 0x61]};
+enum IID CLSID_InternetConnectionBeaconServic = {0x04DF613A, 0x5610, 0x11D4, [0x9E, 0xC8, 0x00, 0xB0, 0xD0, 0x22, 0xDD, 0x1F]};
+enum IID CLSID_InternetExplorer = {0x0002DF01, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_InternetPrintOrdering = {0xADD36AA8, 0x751A, 0x4579, [0xA2, 0x66, 0xD6, 0x6F, 0x52, 0x02, 0xCC, 0xBB]};
+enum IID CLSID_InternetSecurityManager = {0x7B8A2D94, 0x0AC9, 0x11D1, [0x89, 0x6C, 0x00, 0xC0, 0x4F, 0xB6, 0xBF, 0xC4]};
+enum IID CLSID_InternetShortcut = {0xFBF23B40, 0xE3F0, 0x101B, [0x84, 0x88, 0x00, 0xAA, 0x00, 0x3E, 0x56, 0xF8]};
+enum IID CLSID_InternetZoneManager = {0x7B8A2D95, 0x0AC9, 0x11D1, [0x89, 0x6C, 0x00, 0xC0, 0x4F, 0xB6, 0xBF, 0xC4]};
+enum IID CLSID_LanConnectionManager = {0xBA126AD3, 0x2166, 0x11D1, [0xB1, 0xD0, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID CLSID_LargeInteger = {0x927971F5, 0x0939, 0x11D1, [0x8B, 0xE1, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID CLSID_LDAPConnectionObject = {0x7DA2A9C4, 0x0C46, 0x43BD, [0xB0, 0x4E, 0xD9, 0x2B, 0x1B, 0xE2, 0x7C, 0x45]};
+enum IID CLSID_LDAPObject = {0x05709878, 0x5195, 0x466C, [0x9E, 0x64, 0x48, 0x7C, 0xE3, 0xCA, 0x20, 0xBF]};
+enum IID CLSID_LinkColumnProvider = {0x24F14F02, 0x7B1C, 0x11D1, [0x83, 0x8F, 0x00, 0x00, 0xF8, 0x04, 0x61, 0xCF]};
+enum IID CLSID_LocalMachineClasses = {0x00000331, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_LogManager = {0x8FDA8FA4, 0x8763, 0x479F, [0xB9, 0xB1, 0x22, 0x02, 0xB2, 0x80, 0xD2, 0x93]};
+enum IID CLSID_LUTBuilderPP = {0x25B33662, 0xFD83, 0x11D1, [0x8A, 0xDE, 0x44, 0x45, 0x53, 0x54, 0x00, 0x01]};
+enum IID CLSID_MachineDebugManager = {0x0C0A3666, 0x30C9, 0x11D0, [0x8F, 0x20, 0x00, 0x80, 0x5F, 0x2C, 0xD0, 0x64]};
+enum IID CLSID_MailAutoDiscovery = {0x008FD5DD, 0x6DBB, 0x48E3, [0x99, 0x1B, 0x2D, 0x3E, 0xD6, 0x58, 0x51, 0x6A]};
+enum IID CLSID_MailProtocolADEntry = {0x61A5D6F3, 0xC131, 0x4C35, [0xBF, 0x40, 0x90, 0xA5, 0x0F, 0x21, 0x41, 0x22]};
+enum IID CLSID_ManualResetEvent = {0x0000032C, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_McastAddressAllocation = {0xDF0DAEF2, 0xA289, 0x11D1, [0x86, 0x97, 0x00, 0x60, 0x08, 0xB0, 0xE5, 0xD2]};
+enum IID CLSID_MediaStreamTerminal = {0xE2F7AEF7, 0x4971, 0x11D1, [0xA6, 0x71, 0x00, 0x60, 0x97, 0xC9, 0xA2, 0xE8]};
+enum IID CLSID_MergedCategorizer = {0x8E827C11, 0x33E7, 0x4BC1, [0xB2, 0x42, 0x8C, 0xD9, 0xA1, 0xC2, 0xB3, 0x04]};
+enum IID CLSID_MHTMLDocument = {0x3050F3D9, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_MicrophoneTerminal = {0xAAF578EF, 0xDC70, 0x11D0, [0x8E, 0xD3, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID CLSID_MicrosoftDS = {0xFE1290F0, 0xCFBD, 0x11CF, [0xA3, 0x30, 0x00, 0xAA, 0x00, 0xC1, 0x6E, 0x65]};
+enum IID CLSID_MigrationWizardAuto = {0x67331D85, 0xBE17, 0x42F6, [0x8D, 0x3F, 0x47, 0xB8, 0xE8, 0xB2, 0x66, 0x37]};
+enum IID CLSID_MkProtocol = {0x79EAC9E6, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID CLSID_MofCompiler = {0x6DAF9757, 0x2E37, 0x11D2, [0xAE, 0xC9, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID CLSID_MountedVolume = {0x12518493, 0x00B2, 0x11D2, [0x9F, 0xA5, 0x9E, 0x34, 0x20, 0x52, 0x41, 0x53]};
+enum IID CLSID_MSBurnEngineObj = {0x520CCA67, 0x51A5, 0x11D3, [0x91, 0x44, 0x00, 0x10, 0x4B, 0xA1, 0x1C, 0x5E]};
+enum IID CLSID_MSDATT = {0xC8B522CE, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID CLSID_MSDAVTM = {0x0C733A8E, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID CLSID_MSDiscMasterObj = {0x520CCA63, 0x51A5, 0x11D3, [0x91, 0x44, 0x00, 0x10, 0x4B, 0xA1, 0x1C, 0x5E]};
+enum IID CLSID_MSDiscRecorderObj = {0x520CCA61, 0x51A5, 0x11D3, [0x91, 0x44, 0x00, 0x10, 0x4B, 0xA1, 0x1C, 0x5E]};
+enum IID CLSID_MSDiscStashObj = {0x520CCA65, 0x51A5, 0x11D3, [0x91, 0x44, 0x00, 0x10, 0x4B, 0xA1, 0x1C, 0x5E]};
+enum IID CLSID_MSEnumDiscRecordersObj = {0x8A03567A, 0x63CB, 0x4BA8, [0xBA, 0xF6, 0x52, 0x11, 0x98, 0x16, 0xD1, 0xEF]};
+enum IID CLSID_MSOButtons = {0x178F34B8, 0xA282, 0x11D2, [0x86, 0xC5, 0x00, 0xC0, 0x4F, 0x8E, 0xEA, 0x99]};
+enum IID CLSID_MyComputer = {0x20D04FE0, 0x3AEA, 0x1069, [0xA2, 0xD8, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D]};
+enum IID CLSID_MyDocuments = {0x450D8FBA, 0xAD25, 0x11D0, [0x98, 0xA8, 0x08, 0x00, 0x36, 0x1B, 0x11, 0x03]};
+enum IID CLSID_NameTranslate = {0x274FAE1F, 0x3626, 0x11D1, [0xA3, 0xA4, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_NetAddress = {0xB0B71247, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_NetConnectionHNetUtil = {0xBA126AE3, 0x2166, 0x11D1, [0xB1, 0xD0, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID CLSID_NetConnectionUiUtilities = {0x7007ACD3, 0x3202, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID CLSID_NetCrawler = {0x601AC3DC, 0x786A, 0x4EB0, [0xBF, 0x40, 0xEE, 0x35, 0x21, 0xE7, 0x0B, 0xFB]};
+enum IID CLSID_NetSharingManager = {0x5C63C1AD, 0x3956, 0x4FF8, [0x84, 0x86, 0x40, 0x03, 0x47, 0x58, 0x31, 0x5B]};
+enum IID CLSID_NetworkDomain = {0x46E06680, 0x4BF0, 0x11D1, [0x83, 0xEE, 0x00, 0xA0, 0xC9, 0x0D, 0xC8, 0x49]};
+enum IID CLSID_NetworkPlaces = {0x208D2C60, 0x3AEA, 0x1069, [0xA2, 0xD7, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D]};
+enum IID CLSID_NetworkServer = {0xC0542A90, 0x4BF0, 0x11D1, [0x83, 0xEE, 0x00, 0xA0, 0xC9, 0x0D, 0xC8, 0x49]};
+enum IID CLSID_NetworkShare = {0x54A754C0, 0x4BF0, 0x11D1, [0x83, 0xEE, 0x00, 0xA0, 0xC9, 0x0D, 0xC8, 0x49]};
+enum IID CLSID_NetworkType = {0xD4F3D51B, 0x1755, 0x4953, [0x9C, 0x8B, 0x24, 0x95, 0xAB, 0xE5, 0xE0, 0x7E]};
+enum IID CLSID_NodeType = {0x1AAA3D11, 0x4792, 0x44E4, [0x9D, 0x49, 0x78, 0xFE, 0xD3, 0x69, 0x1A, 0x14]};
+enum IID CLSID_NotificaitonTest1 = {0xC733E501, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_NotificaitonTest2 = {0xC733E502, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_NotificaitonTest3 = {0xC733E503, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_NotificaitonTest4 = {0xC733E504, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_NotificationManager = {0xE1813DD0, 0xAADA, 0x4738, [0xB5, 0xFF, 0x96, 0xB4, 0x18, 0x9C, 0x50, 0x19]};
+enum IID CLSID_ObjectManager = {0x955661BD, 0xCCA2, 0x4EAC, [0x91, 0xD0, 0xA0, 0x39, 0x6A, 0x28, 0xAE, 0xFD]};
+enum IID CLSID_OctetList = {0x1241400F, 0x4680, 0x11D1, [0xA3, 0xB4, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_OldHTMLDocument = {0xD48A6EC9, 0x6A4A, 0x11CF, [0x94, 0xA7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID CLSID_OldHTMLFormElement = {0x0D04D285, 0x6BEC, 0x11CF, [0x8B, 0x97, 0x00, 0xAA, 0x00, 0x47, 0x6D, 0xA6]};
+enum IID CLSID_OLEDB_CONVERSIONLIBRARY = {0xC8B522D1, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID CLSID_OLEDB_ENUMERATOR = {0xC8B522D0, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID CLSID_OLEDB_ROWPOSITIONLIBRARY = {0x2048EEE6, 0x7FA2, 0x11D0, [0x9E, 0x6A, 0x00, 0xA0, 0xC9, 0x13, 0x8C, 0x29]};
+enum IID CLSID_PassportClientServices = {0x2D2307C8, 0x7DB4, 0x40D6, [0x91, 0x00, 0xD5, 0x2A, 0xF4, 0xF9, 0x7A, 0x5B]};
+enum IID CLSID_Path = {0xB2538919, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_Pathname = {0x080D0D78, 0xF421, 0x11D0, [0xA3, 0x6E, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_PeerFactory = {0x3050F4CF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_PendingProxyConnection = {0xD8A68E5E, 0x2B37, 0x426C, [0xA3, 0x29, 0xC1, 0x17, 0xC1, 0x4C, 0x42, 0x9E]};
+enum IID CLSID_PersistentDataChannel = {0xBC9B54AB, 0x7883, 0x4C13, [0x90, 0x9F, 0x03, 0x3D, 0x03, 0x26, 0x79, 0x90]};
+enum IID CLSID_PersistPropset = {0xFB8F0821, 0x0164, 0x101B, [0x84, 0xED, 0x08, 0x00, 0x2B, 0x2E, 0xC7, 0x13]};
+enum IID CLSID_Picture_Dib = {0x00000316, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_Picture_EnhMetafile = {0x00000319, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_Picture_Metafile = {0x00000315, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_Pixelate = {0x4CCEA634, 0xFBE0, 0x11D1, [0x90, 0x6A, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID CLSID_PixelatePP = {0x4CCEA635, 0xFBE0, 0x11D1, [0x90, 0x6A, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID CLSID_PluggableSuperclassRegistratio = {0xBB918E32, 0x2A5C, 0x4986, [0xAB, 0x40, 0x16, 0x86, 0xA0, 0x34, 0x39, 0x0A]};
+enum IID CLSID_PluggableTerminalRegistration = {0x45234E3E, 0x61CC, 0x4311, [0xA3, 0xAB, 0x24, 0x80, 0x82, 0x55, 0x44, 0x82]};
+enum IID CLSID_PostAgent = {0xD8BD2030, 0x6FC9, 0x11D0, [0x86, 0x4F, 0x00, 0xAA, 0x00, 0x68, 0x09, 0xD9]};
+enum IID CLSID_PostalAddress = {0x0A75AFCD, 0x4680, 0x11D1, [0xA3, 0xB4, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_PrimaryControlChannel = {0x3CEB5509, 0xC1CD, 0x432F, [0x9D, 0x8F, 0x65, 0xD1, 0xE2, 0x86, 0xAA, 0x80]};
+enum IID CLSID_Printers = {0x2227A280, 0x3AEA, 0x1069, [0xA2, 0xDE, 0x08, 0x00, 0x2B, 0x30, 0x30, 0x9D]};
+enum IID CLSID_PROCESS_BROADCAST = {0xD34F1811, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_ProcessDebugManager = {0x78A51822, 0x51F4, 0x11D0, [0x8F, 0x20, 0x00, 0x80, 0x5F, 0x2C, 0xD0, 0x64]};
+enum IID CLSID_ProgressDialog = {0xF8383852, 0xFCD3, 0x11D1, [0xA6, 0xB9, 0x00, 0x60, 0x97, 0xDF, 0x5B, 0xD4]};
+enum IID CLSID_PropertiesUI = {0xD912F8CF, 0x0396, 0x4915, [0x88, 0x4E, 0xFB, 0x42, 0x5D, 0x32, 0x94, 0x3B]};
+enum IID CLSID_PropertyEntry = {0x72D3EDC2, 0xA4C4, 0x11D0, [0x85, 0x33, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID CLSID_PropertyValue = {0x7B9E38B0, 0xA97C, 0x11D0, [0x85, 0x34, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID CLSID_PSBindCtx = {0x00000312, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_PSClassObject = {0x0000030E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_PSClientSite = {0x0000030D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_PSDragDrop = {0x00000311, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_PSEnumerators = {0x00000313, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_PseudoSink = {0xE002E4F0, 0xE6EA, 0x11D2, [0x9C, 0xB3, 0x00, 0x10, 0x5A, 0x1F, 0x48, 0x01]};
+enum IID CLSID_PSGenObject = {0x0000030C, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_PSInPlaceActive = {0x0000030F, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_PSInPlaceFrame = {0x00000310, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_PSUrlMonProxy = {0x79EAC9F1, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID CLSID_PublishDropTarget = {0xCC6EEFFB, 0x43F6, 0x46C5, [0x96, 0x19, 0x51, 0xD5, 0x71, 0x96, 0x7F, 0x7D]};
+enum IID CLSID_PublishingWizard = {0x6B33163C, 0x76A5, 0x4B6C, [0xBF, 0x21, 0x45, 0xDE, 0x9C, 0xD5, 0x03, 0xA1]};
+enum IID CLSID_QueryAssociations = {0xA07034FD, 0x6CAA, 0x4954, [0xAC, 0x3F, 0x97, 0xA2, 0x72, 0x16, 0xF9, 0x8A]};
+enum IID CLSID_QueryCancelAutoPlay = {0x331F1768, 0x05A9, 0x4DDD, [0xB8, 0x6E, 0xDA, 0xE3, 0x4D, 0xDC, 0x99, 0x8A]};
+enum IID CLSID_RecycleBin = {0x645FF040, 0x5081, 0x101B, [0x9F, 0x08, 0x00, 0xAA, 0x00, 0x2F, 0x95, 0x4E]};
+enum IID CLSID_RemoteUnknownPSFactory = {0x00000340, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_Rendezvous = {0xF1029E5B, 0xCB5B, 0x11D0, [0x8D, 0x59, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID CLSID_ReplicaPointer = {0xF5D1BADF, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_Request = {0x6BC096B1, 0x0CE6, 0x11D1, [0xBA, 0xAE, 0x00, 0xC0, 0x4F, 0xC2, 0xE2, 0x0D]};
+enum IID CLSID_RequestMakeCall = {0xAC48FFE0, 0xF8C4, 0x11D1, [0xA0, 0x30, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID CLSID_ResProtocol = {0x3050F3BC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_RTCClient = {0x7A42EA29, 0xA2B7, 0x40C4, [0xB0, 0x91, 0xF6, 0xF0, 0x24, 0xAA, 0x89, 0xBE]};
+enum IID CLSID_Scriptlet = {0xAE24FDAE, 0x03C6, 0x11D1, [0x8B, 0x76, 0x00, 0x80, 0xC7, 0x44, 0xF3, 0x89]};
+enum IID CLSID_SdoMachine = {0xE9218AE7, 0x9E91, 0x11D1, [0xBF, 0x60, 0x00, 0x80, 0xC7, 0x84, 0x6B, 0xC0]};
+enum IID CLSID_SdpConferenceBlob = {0x9B2719DD, 0xB696, 0x11D0, [0xA4, 0x89, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID CLSID_SearchAssistantOC = {0xB45FF030, 0x4447, 0x11D2, [0x85, 0xDE, 0x00, 0xC0, 0x4F, 0xA3, 0x5C, 0x89]};
+enum IID CLSID_SearchCommand = {0xB005E690, 0x678D, 0x11D1, [0xB7, 0x58, 0x00, 0xA0, 0xC9, 0x05, 0x64, 0xFE]};
+enum IID CLSID_SecondaryControlChannel = {0x7B3181A0, 0xC92F, 0x4567, [0xB0, 0xFA, 0xCD, 0x9A, 0x10, 0xEC, 0xD7, 0xD1]};
+enum IID CLSID_SecurityDescriptor = {0xB958F73C, 0x9BDD, 0x11D0, [0x85, 0x2C, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID CLSID_SENS = {0xD597CAFE, 0x5B9F, 0x11D1, [0x8D, 0xD2, 0x00, 0xAA, 0x00, 0x4A, 0xBD, 0x5E]};
+enum IID CLSID_ServiceManager = {0xABD0388A, 0xDEC1, 0x44F3, [0x98, 0xE1, 0x8D, 0x5C, 0xC8, 0x0B, 0x97, 0xEB]};
+enum IID CLSID_SharingApplicationDefinition = {0x46C166B0, 0x3108, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID CLSID_SharingConfiguration = {0x46C166B1, 0x3108, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID CLSID_SharingManagerEnumApplicationDe = {0x46C166AE, 0x3108, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID CLSID_SharingManagerEnumPortMapping = {0x46C166AF, 0x3108, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID CLSID_SharingManagerEnumPrivateConnec = {0x46C166AD, 0x3108, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID CLSID_SharingManagerEnumPublicConnect = {0x46C166AC, 0x3108, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID CLSID_Shell = {0x13709620, 0xC279, 0x11CE, [0xA4, 0x9E, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID CLSID_ShellBrowserWindow = {0xC08AFD90, 0xF2A1, 0x11D1, [0x84, 0x55, 0x00, 0xA0, 0xC9, 0x1F, 0x38, 0x80]};
+enum IID CLSID_ShellDesktop = {0x00021400, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_ShellDispatchInproc = {0x0A89A860, 0xD7B1, 0x11CE, [0x83, 0x50, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID CLSID_ShellFolderItem = {0x2FE352EA, 0xFD1F, 0x11D2, [0xB1, 0xF4, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x3E]};
+enum IID CLSID_ShellFolderView = {0x62112AA1, 0xEBE4, 0x11CF, [0xA5, 0xFB, 0x00, 0x20, 0xAF, 0xE7, 0x29, 0x2D]};
+enum IID CLSID_ShellFolderViewOC = {0x9BA05971, 0xF6A8, 0x11CF, [0xA4, 0x42, 0x00, 0xA0, 0xC9, 0x0A, 0x8F, 0x39]};
+enum IID CLSID_ShellFSFolder = {0xF3364BA0, 0x65B9, 0x11CE, [0xA9, 0xBA, 0x00, 0xAA, 0x00, 0x4A, 0xE8, 0x37]};
+enum IID CLSID_ShellImageDataFactory = {0x66E4E4FB, 0xF385, 0x4DD0, [0x8D, 0x74, 0xA2, 0xEF, 0xD1, 0xBC, 0x61, 0x78]};
+enum IID CLSID_ShellLink = {0x00021401, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_ShellLinkObject = {0x11219420, 0x1768, 0x11D1, [0x95, 0xBE, 0x00, 0x60, 0x97, 0x97, 0xEA, 0x4F]};
+enum IID CLSID_ShellLocalMachine = {0x60664CAF, 0xAF0D, 0x0005, [0xA3, 0x00, 0x5C, 0x7D, 0x25, 0xFF, 0x22, 0xA0]};
+enum IID CLSID_ShellLogonEnumUsers = {0x60664CAF, 0xAF0D, 0x0004, [0xA3, 0x00, 0x5C, 0x7D, 0x25, 0xFF, 0x22, 0xA0]};
+enum IID CLSID_ShellLogonStatusHost = {0x60664CAF, 0xAF0D, 0x0007, [0xA3, 0x00, 0x5C, 0x7D, 0x25, 0xFF, 0x22, 0xA0]};
+enum IID CLSID_ShellLogonUser = {0x60664CAF, 0xAF0D, 0x0003, [0xA3, 0x00, 0x5C, 0x7D, 0x25, 0xFF, 0x22, 0xA0]};
+enum IID CLSID_ShellNameSpace = {0x55136805, 0xB2DE, 0x11D1, [0xB9, 0xF2, 0x00, 0xA0, 0xC9, 0x8B, 0xC5, 0x47]};
+enum IID CLSID_ShellUIHelper = {0x64AB4BB7, 0x111E, 0x11D1, [0x8F, 0x79, 0x00, 0xC0, 0x4F, 0xC2, 0xFB, 0xE1]};
+enum IID CLSID_ShellWindows = {0x9BA05972, 0xF6A8, 0x11CF, [0xA4, 0x42, 0x00, 0xA0, 0xC9, 0x0A, 0x8F, 0x39]};
+enum IID CLSID_SizeCategorizer = {0x55D7B852, 0xF6D1, 0x42F2, [0xAA, 0x75, 0x87, 0x28, 0xA1, 0xB2, 0xD2, 0x64]};
+enum IID CLSID_SoftDistExt = {0xB15B8DC0, 0xC7E1, 0x11D0, [0x86, 0x80, 0x00, 0xAA, 0x00, 0xBD, 0xCB, 0x71]};
+enum IID CLSID_SpeakerphoneTerminal = {0xAAF578EE, 0xDC70, 0x11D0, [0x8E, 0xD3, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID CLSID_SpeakersTerminal = {0xAAF578F0, 0xDC70, 0x11D0, [0x8E, 0xD3, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID CLSID_SpeechUIServer = {0x1443904B, 0x34E4, 0x40F6, [0xB3, 0x0F, 0x6B, 0xEB, 0x81, 0x26, 0x7B, 0x80]};
+enum IID CLSID_StaticDib = {0x00000316, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_StaticMetafile = {0x00000315, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_StdAsyncActManager = {0x00000329, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_StdComponentCategoriesMgr = {0x0002E005, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_StdEncodingFilterFac = {0x54C37CD0, 0xD944, 0x11D0, [0xA9, 0xF4, 0x00, 0x60, 0x97, 0x94, 0x23, 0x11]};
+enum IID CLSID_StdEvent = {0x0000032B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_StdFont = {0x0BE35203, 0x8F91, 0x11CE, [0x9D, 0xE3, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]};
+enum IID CLSID_StdGlobalInterfaceTable = {0x00000323, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_StdHlink = {0x79EAC9D0, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID CLSID_StdHlinkBrowseContext = {0x79EAC9D1, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID CLSID_StdMarshal = {0x00000017, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_StdNotificationMgr = {0xC733E4AF, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_StdPicture = {0x0BE35204, 0x8F91, 0x11CE, [0x9D, 0xE3, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]};
+enum IID CLSID_StdURLMoniker = {0x79EAC9E0, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID CLSID_StdURLProtocol = {0x79EAC9E1, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID CLSID_StgFolder = {0xE773F1AF, 0x3A65, 0x4866, [0x85, 0x7D, 0x84, 0x6F, 0xC9, 0xC4, 0x59, 0x8A]};
+enum IID CLSID_StockColorPage = {0x7EBDAAE1, 0x8120, 0x11CF, [0x89, 0x9F, 0x00, 0xAA, 0x00, 0x68, 0x8B, 0x10]};
+enum IID CLSID_StockFontPage = {0x7EBDAAE0, 0x8120, 0x11CF, [0x89, 0x9F, 0x00, 0xAA, 0x00, 0x68, 0x8B, 0x10]};
+enum IID CLSID_StockPicturePage = {0x7EBDAAE2, 0x8120, 0x11CF, [0x89, 0x9F, 0x00, 0xAA, 0x00, 0x68, 0x8B, 0x10]};
+enum IID CLSID_SubscriptionMgr = {0xABBE31D0, 0x6DAE, 0x11D0, [0xBE, 0xCA, 0x00, 0xC0, 0x4F, 0xD9, 0x40, 0xBE]};
+enum IID CLSID_SubscriptionThrottler = {0x1E9B00E5, 0x9846, 0x11D1, [0xA1, 0xEE, 0x00, 0xC0, 0x4F, 0xC2, 0xFB, 0xE1]};
+enum IID CLSID_SWbemDateTime = {0x47DFBE54, 0xCF76, 0x11D3, [0xB3, 0x8F, 0x00, 0x10, 0x5A, 0x1F, 0x47, 0x3A]};
+enum IID CLSID_SWbemEventSource = {0x04B83D58, 0x21AE, 0x11D2, [0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemLastError = {0xC2FEEEAC, 0xCFCD, 0x11D1, [0x8B, 0x05, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemLocator = {0x76A64158, 0xCB41, 0x11D1, [0x8B, 0x02, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemMethod = {0x04B83D5B, 0x21AE, 0x11D2, [0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemMethodSet = {0x04B83D5A, 0x21AE, 0x11D2, [0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemNamedValue = {0x04B83D60, 0x21AE, 0x11D2, [0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemNamedValueSet = {0x9AED384E, 0xCE8B, 0x11D1, [0x8B, 0x05, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemObject = {0x04B83D62, 0x21AE, 0x11D2, [0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemObjectEx = {0xD6BDAFB2, 0x9435, 0x491F, [0xBB, 0x87, 0x6A, 0xA0, 0xF0, 0xBC, 0x31, 0xA2]};
+enum IID CLSID_SWbemObjectPath = {0x5791BC26, 0xCE9C, 0x11D1, [0x97, 0xBF, 0x00, 0x00, 0xF8, 0x1E, 0x84, 0x9C]};
+enum IID CLSID_SWbemObjectSet = {0x04B83D61, 0x21AE, 0x11D2, [0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemPrivilege = {0x26EE67BC, 0x5804, 0x11D2, [0x8B, 0x4A, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemPrivilegeSet = {0x26EE67BE, 0x5804, 0x11D2, [0x8B, 0x4A, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemProperty = {0x04B83D5D, 0x21AE, 0x11D2, [0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemPropertySet = {0x04B83D5C, 0x21AE, 0x11D2, [0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemQualifier = {0x04B83D5F, 0x21AE, 0x11D2, [0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemQualifierSet = {0x04B83D5E, 0x21AE, 0x11D2, [0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemRefreshableItem = {0x8C6854BC, 0xDE4B, 0x11D3, [0xB3, 0x90, 0x00, 0x10, 0x5A, 0x1F, 0x47, 0x3A]};
+enum IID CLSID_SWbemRefresher = {0xD269BF5C, 0xD9C1, 0x11D3, [0xB3, 0x8F, 0x00, 0x10, 0x5A, 0x1F, 0x47, 0x3A]};
+enum IID CLSID_SWbemSecurity = {0xB54D66E9, 0x2287, 0x11D2, [0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemServices = {0x04B83D63, 0x21AE, 0x11D2, [0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID CLSID_SWbemServicesEx = {0x62E522DC, 0x8CF3, 0x40A8, [0x8B, 0x2E, 0x37, 0xD5, 0x95, 0x65, 0x1E, 0x40]};
+enum IID CLSID_SWbemSink = {0x75718C9A, 0xF029, 0x11D1, [0xA1, 0xAC, 0x00, 0xC0, 0x4F, 0xB6, 0xC2, 0x23]};
+enum IID CLSID_SynchronizeContainer = {0x0000032D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID CLSID_SyncMgr = {0x6295DF27, 0x35EE, 0x11D1, [0x87, 0x07, 0x00, 0xC0, 0x4F, 0xD9, 0x33, 0x27]};
+enum IID CLSID_TAPI = {0x21D6D48E, 0xA88B, 0x11D0, [0x83, 0xDD, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID CLSID_TaskbarList = {0x56FDF344, 0xFD6D, 0x11D0, [0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90]};
+enum IID CLSID_TaskManager = {0xC0F615A7, 0xF874, 0x4521, [0x87, 0x91, 0xED, 0x3B, 0x84, 0x01, 0x7E, 0xF7]};
+enum IID CLSID_TerminalManager = {0x7170F2E0, 0x9BE3, 0x11D0, [0xA0, 0x09, 0x00, 0xAA, 0x00, 0xB6, 0x05, 0xA4]};
+enum IID CLSID_THREAD_BROADCAST = {0xD34F1812, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_ThreadDialogProcParam = {0x3050F5EB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID CLSID_ThumbnailFCNHandler = {0xCEFC65D8, 0x66D8, 0x11D1, [0x8D, 0x8C, 0x00, 0x00, 0xF8, 0x04, 0xB0, 0x57]};
+enum IID CLSID_ThumbnailUpdater = {0xA3C63918, 0x889D, 0x11D1, [0x83, 0xE9, 0x00, 0xC0, 0x4F, 0xC2, 0xC6, 0xD4]};
+enum IID CLSID_TIME = {0xE32EF57B, 0x7FDE, 0x4765, [0x9B, 0xC5, 0xA1, 0xBA, 0x97, 0x05, 0xC4, 0x4E]};
+enum IID CLSID_TIMEAnimation = {0xF99D135A, 0xC07C, 0x449E, [0x96, 0x5C, 0x7D, 0xBB, 0x7C, 0x55, 0x4A, 0x51]};
+enum IID CLSID_TimeCategorizer = {0x3BB4118F, 0xDDFD, 0x4D30, [0xA3, 0x48, 0x9F, 0xB5, 0xD6, 0xBF, 0x1A, 0xFE]};
+enum IID CLSID_TIMEColorAnimation = {0x62F75052, 0xF3EC, 0x4A64, [0x84, 0xFB, 0xAB, 0x18, 0xE0, 0x74, 0x6E, 0xD8]};
+enum IID CLSID_TIMEFactory = {0x17237A20, 0x3ADB, 0x48EC, [0xB1, 0x82, 0x35, 0x29, 0x1F, 0x11, 0x57, 0x90]};
+enum IID CLSID_TIMEFilterAnimation = {0xC54515D0, 0xF2E5, 0x4BDD, [0xAA, 0x86, 0x1E, 0x4F, 0x23, 0xE4, 0x80, 0xE7]};
+enum IID CLSID_TIMEMotionAnimation = {0x0019A09D, 0x1A81, 0x41C5, [0x89, 0xEC, 0xD9, 0xE7, 0x37, 0x81, 0x13, 0x03]};
+enum IID CLSID_TIMESetAnimation = {0xBA91CE53, 0xBAEB, 0x4F05, [0x86, 0x1C, 0x0A, 0x2A, 0x09, 0x34, 0xF8, 0x2E]};
+enum IID CLSID_Timestamp = {0xB2BED2EB, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_ToolbarExtButtons = {0x2CE4B5D8, 0xA28F, 0x11D2, [0x86, 0xC5, 0x00, 0xC0, 0x4F, 0x8E, 0xEA, 0x99]};
+enum IID CLSID_TrackFile = {0x8790C947, 0xA30B, 0x11D0, [0x8C, 0xAB, 0x00, 0xC0, 0x4F, 0xD9, 0x0F, 0x85]};
+enum IID CLSID_TrkForceOwnership = {0xA2531F45, 0xC67D, 0x11D0, [0x8C, 0xB1, 0x00, 0xC0, 0x4F, 0xD9, 0x0F, 0x85]};
+enum IID CLSID_TrkRestoreNotify = {0xD0056F6C, 0xE2A0, 0x11D0, [0xB1, 0xC2, 0x00, 0xC0, 0x4F, 0xB9, 0x38, 0x6D]};
+enum IID CLSID_TrkRestoreParser = {0x755939E4, 0xE381, 0x11D0, [0xB1, 0xC5, 0x00, 0xC0, 0x4F, 0xB9, 0x38, 0x6D]};
+enum IID CLSID_TypedName = {0xB33143CB, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID CLSID_UmiLDAPQueryObject = {0xCD5D4D76, 0xA818, 0x4F95, [0xB9, 0x58, 0x79, 0x70, 0xFD, 0x94, 0x12, 0xCA]};
+enum IID CLSID_UnsecuredApartment = {0x49BD2028, 0x1523, 0x11D1, [0xAD, 0x79, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID CLSID_UPnPDescriptionDocument = {0x1D8A9B47, 0x3A28, 0x4CE2, [0x8A, 0x4B, 0xBD, 0x34, 0xE4, 0x5B, 0xCE, 0xEB]};
+enum IID CLSID_UPnPDevice = {0xA32552C5, 0xBA61, 0x457A, [0xB5, 0x9A, 0xA2, 0x56, 0x1E, 0x12, 0x5E, 0x33]};
+enum IID CLSID_UPnPDeviceFinder = {0xE2085F28, 0xFEB7, 0x404A, [0xB8, 0xE7, 0xE6, 0x59, 0xBD, 0xEA, 0xAA, 0x02]};
+enum IID CLSID_UPnPDeviceHostICSSupport = {0x797A9BB1, 0x9E49, 0x4E63, [0xAF, 0xE1, 0x1B, 0x45, 0xB9, 0xDC, 0x81, 0x62]};
+enum IID CLSID_UPnPDeviceHostSetup = {0xB4609411, 0xC81C, 0x4CCE, [0x8C, 0x76, 0xC6, 0xB5, 0x0C, 0x94, 0x02, 0xC6]};
+enum IID CLSID_UPnPDevices = {0xB9E84FFD, 0xAD3C, 0x40A4, [0xB8, 0x35, 0x08, 0x82, 0xEB, 0xCB, 0xAA, 0xA8]};
+enum IID CLSID_UPnPNAT = {0xAE1E00AA, 0x3FD5, 0x403C, [0x8A, 0x27, 0x2B, 0xBD, 0xC3, 0x0C, 0xD0, 0xE1]};
+enum IID CLSID_UPnPRegistrar = {0x204810B9, 0x73B2, 0x11D4, [0xBF, 0x42, 0x00, 0xB0, 0xD0, 0x11, 0x8B, 0x56]};
+enum IID CLSID_UPnPService = {0xC624BA95, 0xFBCB, 0x4409, [0x8C, 0x03, 0x8C, 0xCE, 0xEC, 0x53, 0x3E, 0xF1]};
+enum IID CLSID_UPnPServices = {0xC0BC4B4A, 0xA406, 0x4EFC, [0x93, 0x2F, 0xB8, 0x54, 0x6B, 0x81, 0x00, 0xCC]};
+enum IID CLSID_UrlMkBindCtx = {0x79EAC9F2, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID CLSID_UserEventTimer = {0x864A1288, 0x354C, 0x4D19, [0x9D, 0x68, 0xC2, 0x74, 0x2B, 0xB1, 0x49, 0x97]};
+enum IID CLSID_UserEventTimerCallback = {0x15FFFD13, 0x5140, 0x41B8, [0xB8, 0x9A, 0xC8, 0xD5, 0x75, 0x9C, 0xD2, 0xB2]};
+enum IID CLSID_UserNotification = {0x0010890E, 0x8789, 0x413C, [0xAD, 0xBC, 0x48, 0xF5, 0xB5, 0x11, 0xB3, 0xAF]};
+enum IID CLSID_VideoInputTerminal = {0xAAF578EC, 0xDC70, 0x11D0, [0x8E, 0xD3, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID CLSID_VideoWindowTerm = {0xF7438990, 0xD6EB, 0x11D0, [0x82, 0xA6, 0x00, 0xAA, 0x00, 0xB5, 0xCA, 0x1B]};
+enum IID CLSID_VirusScan = {0xE88E5DE0, 0xBD3E, 0x11CF, [0xAA, 0xFA, 0x00, 0xAA, 0x00, 0xB6, 0x01, 0x5C]};
+enum IID CLSID_WbemAdministrativeLocator = {0xCB8555CC, 0x9128, 0x11D1, [0xAD, 0x9B, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID CLSID_WbemAuthenticatedLocator = {0xCD184336, 0x9128, 0x11D1, [0xAD, 0x9B, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID CLSID_WbemBackupRestore = {0xC49E32C6, 0xBC8B, 0x11D2, [0x85, 0xD4, 0x00, 0x10, 0x5A, 0x1F, 0x83, 0x04]};
+enum IID CLSID_WbemClassObject = {0x9A653086, 0x174F, 0x11D2, [0xB5, 0xF9, 0x00, 0x10, 0x4B, 0x70, 0x3E, 0xFD]};
+enum IID CLSID_WbemContext = {0x674B6698, 0xEE92, 0x11D0, [0xAD, 0x71, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID CLSID_WbemDCOMTransport = {0xF7CE2E13, 0x8C90, 0x11D1, [0x9E, 0x7B, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID CLSID_WbemDecoupledBasicEventProvide = {0xF5F75737, 0x2843, 0x4F22, [0x93, 0x3D, 0xC7, 0x6A, 0x97, 0xCD, 0xA6, 0x2F]};
+enum IID CLSID_WbemDecoupledRegistrar = {0x4CFC7932, 0x0F9D, 0x4BEF, [0x9C, 0x32, 0x8E, 0xA2, 0xA6, 0xB5, 0x6F, 0xCB]};
+enum IID CLSID_WbemDefPath = {0xCF4CC405, 0xE2C5, 0x4DDD, [0xB3, 0xCE, 0x5E, 0x75, 0x82, 0xD8, 0xC9, 0xFA]};
+enum IID CLSID_WbemLevel1Login = {0x8BC3F05E, 0xD86B, 0x11D0, [0xA0, 0x75, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID CLSID_WbemLocalAddrRes = {0xA1044801, 0x8F7E, 0x11D1, [0x9E, 0x7C, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID CLSID_WbemLocator = {0x4590F811, 0x1D3A, 0x11D0, [0x89, 0x1F, 0x00, 0xAA, 0x00, 0x4B, 0x2E, 0x24]};
+enum IID CLSID_WbemObjectTextSrc = {0x8D1C559D, 0x84F0, 0x4BB3, [0xA7, 0xD5, 0x56, 0xA7, 0x43, 0x5A, 0x9B, 0xA6]};
+enum IID CLSID_WbemQuery = {0xEAC8A024, 0x21E2, 0x4523, [0xAD, 0x73, 0xA7, 0x1A, 0x0A, 0xA2, 0xF5, 0x6A]};
+enum IID CLSID_WbemRefresher = {0xC71566F2, 0x561E, 0x11D1, [0xAD, 0x87, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID CLSID_WbemStatusCodeText = {0xEB87E1BD, 0x3233, 0x11D2, [0xAE, 0xC9, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID CLSID_WbemUnauthenticatedLocator = {0x443E7B79, 0xDE31, 0x11D2, [0xB3, 0x40, 0x00, 0x10, 0x4B, 0xCC, 0x4B, 0x4A]};
+enum IID CLSID_WbemUninitializedClassObject = {0x7A0227F6, 0x7108, 0x11D1, [0xAD, 0x90, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID CLSID_WebBrowser = {0x8856F961, 0x340A, 0x11D0, [0xA9, 0x6B, 0x00, 0xC0, 0x4F, 0xD7, 0x05, 0xA2]};
+enum IID CLSID_WebBrowser_V1 = {0xEAB22AC3, 0x30C1, 0x11CF, [0xA7, 0xEB, 0x00, 0x00, 0xC0, 0x5B, 0xAE, 0x0B]};
+enum IID CLSID_WebCheck = {0xE6FB5E20, 0xDE35, 0x11CF, [0x9C, 0x87, 0x00, 0xAA, 0x00, 0x51, 0x27, 0xED]};
+enum IID CLSID_WebCheckDefaultProcess = {0xC733E4B0, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID CLSID_WebCheckOfflineSync = {0x7FC0B86E, 0x5FA7, 0x11D1, [0xBC, 0x7C, 0x00, 0xC0, 0x4F, 0xD9, 0x29, 0xDB]};
+enum IID CLSID_WebCrawlerAgent = {0x08165EA0, 0xE946, 0x11CF, [0x9C, 0x87, 0x00, 0xAA, 0x00, 0x51, 0x27, 0xED]};
+enum IID CLSID_WebViewFolderContents = {0x1820FED0, 0x473E, 0x11D0, [0xA9, 0x6C, 0x00, 0xC0, 0x4F, 0xD7, 0x05, 0xA2]};
+enum IID CLSID_WebWizardHost = {0xC827F149, 0x55C1, 0x4D28, [0x93, 0x5E, 0x57, 0xE4, 0x7C, 0xAE, 0xD9, 0x73]};
+enum IID CLSID_wfolders = {0xBAE31F9A, 0x1B81, 0x11D2, [0xA9, 0x7A, 0x00, 0xC0, 0x4F, 0x8E, 0xCB, 0x02]};
+enum IID CLSID_WinNTConnectionObject = {0x7992C6EB, 0xD142, 0x4332, [0x83, 0x1E, 0x31, 0x54, 0xC5, 0x0A, 0x83, 0x16]};
+enum IID CLSID_WinNTObject = {0xB8324185, 0x4050, 0x4220, [0x98, 0x0A, 0xAB, 0x14, 0x62, 0x3E, 0x06, 0x3A]};
+enum IID CLSID_WinNTSystemInfo = {0x66182EC4, 0xAFD1, 0x11D2, [0x9C, 0xB9, 0x00, 0x00, 0xF8, 0x7A, 0x36, 0x9E]};
+enum IID CLSID_WMIExtension = {0xF0975AFE, 0x5C7F, 0x11D2, [0x8B, 0x74, 0x00, 0x10, 0x4B, 0x2A, 0xFB, 0x41]};
+enum IID CLSID_XMLDocument = {0xCFC399AF, 0xD876, 0x11D0, [0x9C, 0x10, 0x00, 0xC0, 0x4F, 0xC9, 0x9C, 0x8E]};
+enum IID CLSID_XMLDSOControl = {0x550DDA30, 0x0541, 0x11D2, [0x9C, 0xA9, 0x00, 0x60, 0xB0, 0xEC, 0x3D, 0x39]};
+enum IID CLSID_XMLHTTPRequest = {0xED8C108E, 0x4349, 0x11D2, [0x91, 0xA4, 0x00, 0xC0, 0x4F, 0x79, 0x69, 0xE8]};
+enum IID CLSID_XMLParser = {0xD2423620, 0x51A0, 0x11D2, [0x9C, 0xAF, 0x00, 0x60, 0xB0, 0xEC, 0x3D, 0x39]};
+enum IID DB_PROPERTY_AUTOMATICUPDATE = {0xC8B52209, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_BTREE = {0xC8B52201, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_CHECK_OPTION = {0xC8B5220B, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_CLUSTERED = {0xC8B521FF, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_CONSTRAINT_CHECK_DEFERRE = {0xC8B521F0, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_DISALLOWNULL = {0xC8B52205, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_DROP_CASCADE = {0xC8B521F3, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_EXPLICITUPDATE = {0xC8B5220A, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_FILLFACTOR = {0xC8B52203, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_HASH = {0xC8B52202, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_IGNOREANYNULL = {0xC8B52207, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_IGNORENULL = {0xC8B52206, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_INITIALSIZE = {0xC8B52204, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_NONCLUSTERED = {0xC8B52200, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_ON_COMMIT_PRESERVE_ROWS = {0xC8B52230, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_PRIMARY = {0xC8B521FC, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_SORTBOOKMARKS = {0xC8B52208, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DB_PROPERTY_UNIQUE = {0xC8B521F5, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBCOL_SELFCOLUMNS = {0xC8B52231, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBCOL_SPECIALCOL = {0xC8B52232, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_COMMAND = {0xC8B522F8, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_CONTAINEROBJECT = {0xC8B522FB, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_DBSQL = {0xC8B521FB, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_DEFAULT = {0xC8B521FB, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_DSO = {0xC8B522F4, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_HISTOGRAM_ROWSET = {0xC8B52300, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_LDAPDialect = {0xEFF65380, 0x9C98, 0x11CF, [0xB9, 0x63, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_LIKE_DOS = {0xC8B521F7, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_LIKE_MAPI = {0xC8B521F9, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_LIKE_OFS = {0xC8B521F8, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_LIKE_SQL = {0xC8B521F6, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_MDX = {0xA07CCCD0, 0x8148, 0x11D0, [0x87, 0xBB, 0x00, 0xC0, 0x4F, 0xC3, 0x39, 0x42]};
+enum IID DBGUID_ROW = {0xC8B522F7, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_ROWSET = {0xC8B522F6, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_SESSION = {0xC8B522F5, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_SQL = {0xC8B522D7, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBGUID_STREAM = {0xC8B522F9, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBOBJECT_CHARACTERSET = {0xC8B522ED, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBOBJECT_COLLATION = {0xC8B522EA, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBOBJECT_COLUMN = {0xC8B522E4, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBOBJECT_DATABASE = {0xC8B522E5, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBOBJECT_DOMAIN = {0xC8B522E9, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBOBJECT_PROCEDURE = {0xC8B522E6, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBOBJECT_SCHEMA = {0xC8B522E8, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBOBJECT_SCHEMAROWSET = {0xC8B522EC, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBOBJECT_TABLE = {0xC8B522E2, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBOBJECT_TRANSLATION = {0xC8B522EE, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBOBJECT_TRUSTEE = {0xC8B522EB, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBOBJECT_VIEW = {0xC8B522E7, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_ADSIBIND = {0x6DA66DC8, 0xB7E8, 0x11D2, [0x9D, 0x60, 0x00, 0xC0, 0x4F, 0x68, 0x93, 0x45]};
+enum IID DBPROPSET_ADSISEARCH = {0xCFCFC928, 0x9AA2, 0x11D0, [0xA7, 0x9A, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0xA8]};
+enum IID DBPROPSET_COLUMN = {0xC8B522B9, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_COLUMNALL = {0xC8B522F0, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_CONSTRAINTALL = {0xC8B522FA, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_DATASOURCE = {0xC8B522BA, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_DATASOURCEALL = {0xC8B522C0, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_DATASOURCEINFO = {0xC8B522BB, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_DATASOURCEINFOALL = {0xC8B522C1, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_DBINIT = {0xC8B522BC, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_DBINITALL = {0xC8B522CA, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_INDEX = {0xC8B522BD, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_INDEXALL = {0xC8B522F1, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_PROPERTIESINERROR = {0xC8B522D4, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_ROWSET = {0xC8B522BE, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_ROWSETALL = {0xC8B522C2, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_SESSION = {0xC8B522C6, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_SESSIONALL = {0xC8B522C7, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_STREAM = {0xC8B522FD, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_STREAMALL = {0xC8B522FE, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_TABLE = {0xC8B522BF, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_TABLEALL = {0xC8B522F2, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_TRUSTEE = {0xC8B522E1, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_TRUSTEEALL = {0xC8B522F3, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_VIEW = {0xC8B522DF, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBPROPSET_VIEWALL = {0xC8B522FC, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_ASSERTIONS = {0xC8B52210, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_CATALOGS = {0xC8B52211, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_CHARACTER_SETS = {0xC8B52212, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_CHECK_CONSTRAINTS = {0xC8B52215, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_CHECK_CONSTRAINTS_BY_TABLE = {0xC8B52301, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_COLLATIONS = {0xC8B52213, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_COLUMN_DOMAIN_USAGE = {0xC8B5221B, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_COLUMN_PRIVILEGES = {0xC8B52221, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_COLUMNS = {0xC8B52214, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_CONSTRAINT_COLUMN_USAGE = {0xC8B52216, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_CONSTRAINT_TABLE_USAGE = {0xC8B52217, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_FOREIGN_KEYS = {0xC8B522C4, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_INDEXES = {0xC8B5221E, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_KEY_COLUMN_USAGE = {0xC8B52218, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_PRIMARY_KEYS = {0xC8B522C5, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_PROCEDURE_COLUMNS = {0xC8B522C9, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_PROCEDURE_PARAMETERS = {0xC8B522B8, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_PROCEDURES = {0xC8B52224, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_PROVIDER_TYPES = {0xC8B5222C, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_REFERENTIAL_CONSTRAINTS = {0xC8B52219, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_SCHEMATA = {0xC8B52225, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_SQL_LANGUAGES = {0xC8B52226, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_STATISTICS = {0xC8B52227, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_TABLE_CONSTRAINTS = {0xC8B5221A, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_TABLE_PRIVILEGES = {0xC8B52222, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_TABLE_STATISTICS = {0xC8B522FF, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_TABLES = {0xC8B52229, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_TABLES_INFO = {0xC8B522E0, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_TRANSLATIONS = {0xC8B5222A, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_TRUSTEE = {0xC8B522EF, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_USAGE_PRIVILEGES = {0xC8B52223, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_VIEW_COLUMN_USAGE = {0xC8B5222E, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_VIEW_TABLE_USAGE = {0xC8B5222F, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DBSCHEMA_VIEWS = {0xC8B5222D, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID DDVPTYPE_BROOKTREE = {0x1352A560, 0xDA61, 0x11CF, [0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8]};
+enum IID DDVPTYPE_CCIR656 = {0xFCA326A0, 0xDA60, 0x11CF, [0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8]};
+enum IID DDVPTYPE_E_HREFH_VREFL = {0x92783220, 0xDA60, 0x11CF, [0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8]};
+enum IID DDVPTYPE_E_HREFL_VREFL = {0xE09C77E0, 0xDA60, 0x11CF, [0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8]};
+enum IID DDVPTYPE_PHILIPS = {0x332CF160, 0xDA61, 0x11CF, [0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8]};
+enum IID DIID__SearchAssistantEvents = {0x1611FDDA, 0x445B, 0x11D2, [0x85, 0xDE, 0x00, 0xC0, 0x4F, 0xA3, 0x5C, 0x89]};
+enum IID DIID_DispCEventObj = {0x3050F558, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispDOMChildrenCollection = {0x3050F577, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTCAttachBehavior = {0x3050F583, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTCDefaultDispatch = {0x3050F573, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTCDescBehavior = {0x3050F57E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTCEventBehavior = {0x3050F574, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTCMethodBehavior = {0x3050F587, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTCPropertyBehavior = {0x3050F57F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLAnchorElement = {0x3050F502, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLAppBehavior = {0x3050F57C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLAreaElement = {0x3050F503, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLAreasCollection = {0x3050F56A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLAttributeCollection = {0x3050F56C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLBaseElement = {0x3050F518, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLBaseFontElement = {0x3050F504, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLBGsound = {0x3050F53C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLBlockElement = {0x3050F506, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLBody = {0x3050F507, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLBRElement = {0x3050F53A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLButtonElement = {0x3050F51F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLCommentElement = {0x3050F50A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLCurrentStyle = {0x3050F557, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLDDElement = {0x3050F50B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLDefaults = {0x3050F58C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLDivElement = {0x3050F50C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLDivPosition = {0x3050F50F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLDListElement = {0x3050F53B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLDocument = {0x3050F55F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLDOMAttribute = {0x3050F564, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLDOMImplementation = {0x3050F58F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLDOMTextNode = {0x3050F565, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLDTElement = {0x3050F50D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLElementCollection = {0x3050F56B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLEmbed = {0x3050F52E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLFieldSetElement = {0x3050F545, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLFontElement = {0x3050F512, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLFormElement = {0x3050F510, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLFrameBase = {0x3050F541, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLFrameElement = {0x3050F513, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLFrameSetSite = {0x3050F514, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLGenericElement = {0x3050F563, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLHeadElement = {0x3050F561, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLHeaderElement = {0x3050F515, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLHRElement = {0x3050F53D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLHtmlElement = {0x3050F560, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLIFrame = {0x3050F51B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLImg = {0x3050F51C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLInputElement = {0x3050F57D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLIsIndexElement = {0x3050F519, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLLabelElement = {0x3050F522, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLLegendElement = {0x3050F546, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLLIElement = {0x3050F523, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLLinkElement = {0x3050F524, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLListElement = {0x3050F525, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLMapElement = {0x3050F526, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLMarqueeElement = {0x3050F527, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLMetaElement = {0x3050F517, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLNextIdElement = {0x3050F51A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLNoShowElement = {0x3050F528, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLObjectElement = {0x3050F529, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLOListElement = {0x3050F52A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLOptionElement = {0x3050F52B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLParaElement = {0x3050F52C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLParamElement = {0x3050F590, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLPhraseElement = {0x3050F52D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLPopup = {0x3050F589, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLRenderStyle = {0x3050F58B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLRichtextElement = {0x3050F54D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLRuleStyle = {0x3050F55C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLScreen = {0x3050F591, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLScriptElement = {0x3050F530, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLSelectElement = {0x3050F531, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLSpanElement = {0x3050F548, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLSpanFlow = {0x3050F544, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLStyle = {0x3050F55A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLStyleElement = {0x3050F511, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLStyleSheet = {0x3050F58D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLTable = {0x3050F532, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLTableCaption = {0x3050F508, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLTableCell = {0x3050F536, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLTableCol = {0x3050F533, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLTableRow = {0x3050F535, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLTableSection = {0x3050F534, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLTextAreaElement = {0x3050F521, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLTextElement = {0x3050F537, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLTitleElement = {0x3050F516, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLUListElement = {0x3050F538, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLUnknownElement = {0x3050F539, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLWindow2 = {0x3050F55D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispHTMLWindowProxy = {0x3050F55E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispIHTMLInputButtonElement = {0x3050F51E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispIHTMLInputFileElement = {0x3050F542, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispIHTMLInputImage = {0x3050F51D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispIHTMLInputTextElement = {0x3050F520, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DispIHTMLOptionButtonElement = {0x3050F509, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_DMigrationWizardAutoEvents = {0xD2AC137D, 0xA6D8, 0x43B6, [0x98, 0x79, 0xEA, 0x34, 0xB6, 0x7E, 0x18, 0x80]};
+enum IID DIID_DSearchCommandEvents = {0x60890160, 0x69F0, 0x11D1, [0xB7, 0x58, 0x00, 0xA0, 0xC9, 0x05, 0x64, 0xFE]};
+enum IID DIID_DShellFolderViewEvents = {0x62112AA2, 0xEBE4, 0x11CF, [0xA5, 0xFB, 0x00, 0x20, 0xAF, 0xE7, 0x29, 0x2D]};
+enum IID DIID_DShellNameSpaceEvents = {0x55136806, 0xB2DE, 0x11D1, [0xB9, 0xF2, 0x00, 0xA0, 0xC9, 0x8B, 0xC5, 0x47]};
+enum IID DIID_DShellWindowsEvents = {0xFE4106E0, 0x399A, 0x11D0, [0xA4, 0x8C, 0x00, 0xA0, 0xC9, 0x0A, 0x8F, 0x39]};
+enum IID DIID_DWebBridgeEvents = {0xA6D897FF, 0x0A95, 0x11D1, [0xB0, 0xBA, 0x00, 0x60, 0x08, 0x16, 0x6E, 0x11]};
+enum IID DIID_DWebBrowserEvents = {0xEAB22AC2, 0x30C1, 0x11CF, [0xA7, 0xEB, 0x00, 0x00, 0xC0, 0x5B, 0xAE, 0x0B]};
+enum IID DIID_DWebBrowserEvents2 = {0x34A715A0, 0x6587, 0x11D0, [0x92, 0x4A, 0x00, 0x20, 0xAF, 0xC7, 0xAC, 0x4D]};
+enum IID DIID_HTMLAnchorEvents = {0x3050F29D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLAnchorEvents2 = {0x3050F610, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLAreaEvents = {0x3050F366, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLAreaEvents2 = {0x3050F611, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLButtonElementEvents = {0x3050F2B3, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLButtonElementEvents2 = {0x3050F617, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLControlElementEvents = {0x3050F4EA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLControlElementEvents2 = {0x3050F612, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLDocumentEvents = {0x3050F260, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLDocumentEvents2 = {0x3050F613, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLElementEvents = {0x3050F33C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLElementEvents2 = {0x3050F60F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLFormElementEvents = {0x3050F364, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLFormElementEvents2 = {0x3050F614, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLFrameSiteEvents = {0x3050F800, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLFrameSiteEvents2 = {0x3050F7FF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLImgEvents = {0x3050F25B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLImgEvents2 = {0x3050F616, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLInputFileElementEvents = {0x3050F2AF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLInputFileElementEvents2 = {0x3050F61A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLInputImageEvents = {0x3050F2C3, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLInputImageEvents2 = {0x3050F61B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLInputTextElementEvents = {0x3050F2A7, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLInputTextElementEvents2 = {0x3050F618, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLLabelEvents = {0x3050F329, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLLabelEvents2 = {0x3050F61C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLLinkElementEvents = {0x3050F3CC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLLinkElementEvents2 = {0x3050F61D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLMapEvents = {0x3050F3BA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLMapEvents2 = {0x3050F61E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLMarqueeElementEvents = {0x3050F2B8, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLMarqueeElementEvents2 = {0x3050F61F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLNamespaceEvents = {0x3050F6BD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLObjectElementEvents = {0x3050F3C4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLObjectElementEvents2 = {0x3050F620, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLOptionButtonElementEvents = {0x3050F2BD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLOptionButtonElementEvents2 = {0x3050F619, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLPersistEvents = {0x3050F4C7, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLScriptEvents = {0x3050F3E2, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLScriptEvents2 = {0x3050F621, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLSelectElementEvents = {0x3050F302, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLSelectElementEvents2 = {0x3050F622, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLStyleElementEvents = {0x3050F3CB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLStyleElementEvents2 = {0x3050F615, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLTableEvents = {0x3050F407, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLTableEvents2 = {0x3050F623, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLTextContainerEvents = {0x1FF6AA72, 0x5842, 0x11CF, [0xA7, 0x07, 0x00, 0xAA, 0x00, 0xC0, 0x09, 0x8D]};
+enum IID DIID_HTMLTextContainerEvents2 = {0x3050F624, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_HTMLWindowEvents = {0x96A0A4E0, 0xD062, 0x11CF, [0x94, 0xB6, 0x00, 0xAA, 0x00, 0x60, 0x27, 0x5C]};
+enum IID DIID_HTMLWindowEvents2 = {0x3050F625, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_IRTCDispatchEventNotification = {0x176DDFBE, 0xFEC0, 0x4D55, [0xBC, 0x87, 0x84, 0xCF, 0xF1, 0xEF, 0x7F, 0x91]};
+enum IID DIID_ISWbemSinkEvents = {0x75718CA0, 0xF029, 0x11D1, [0xA1, 0xAC, 0x00, 0xC0, 0x4F, 0xB6, 0xC2, 0x23]};
+enum IID DIID_ITTAPIDispatchEventNotification = {0x9F34325B, 0x7E62, 0x11D2, [0x94, 0x57, 0x00, 0xC0, 0x4F, 0x8E, 0xC8, 0x88]};
+enum IID DIID_LayoutRectEvents = {0x3050F674, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID DIID_XMLDOMDocumentEvents = {0x3EFAA427, 0x272F, 0x11D2, [0x83, 0x6F, 0x00, 0x00, 0xF8, 0x7A, 0x77, 0x82]};
+enum IID DPAID_ComPort = {0xF2F0CE00, 0xE0AF, 0x11CF, [0x9C, 0x4E, 0x00, 0xA0, 0xC9, 0x05, 0x42, 0x5E]};
+enum IID DPAID_INet = {0xC4A54DA0, 0xE0AF, 0x11CF, [0x9C, 0x4E, 0x00, 0xA0, 0xC9, 0x05, 0x42, 0x5E]};
+enum IID DPAID_INetPort = {0xE4524541, 0x8EA5, 0x11D1, [0x8A, 0x96, 0x00, 0x60, 0x97, 0xB0, 0x14, 0x11]};
+enum IID DPAID_INetW = {0xE63232A0, 0x9DBF, 0x11D0, [0x9C, 0xC1, 0x00, 0xA0, 0xC9, 0x05, 0x42, 0x5E]};
+enum IID DPAID_LobbyProvider = {0x59B95640, 0x9667, 0x11D0, [0xA7, 0x7D, 0x00, 0x00, 0xF8, 0x03, 0xAB, 0xFC]};
+enum IID DPAID_Modem = {0xF6DCC200, 0xA2FE, 0x11D0, [0x9C, 0x4F, 0x00, 0xA0, 0xC9, 0x05, 0x42, 0x5E]};
+enum IID DPAID_ModemW = {0x01FD92E0, 0xA2FF, 0x11D0, [0x9C, 0x4F, 0x00, 0xA0, 0xC9, 0x05, 0x42, 0x5E]};
+enum IID DPAID_Phone = {0x78EC89A0, 0xE0AF, 0x11CF, [0x9C, 0x4E, 0x00, 0xA0, 0xC9, 0x05, 0x42, 0x5E]};
+enum IID DPAID_PhoneW = {0xBA5A7A70, 0x9DBF, 0x11D0, [0x9C, 0xC1, 0x00, 0xA0, 0xC9, 0x05, 0x42, 0x5E]};
+enum IID DPAID_ServiceProvider = {0x07D916C0, 0xE0AF, 0x11CF, [0x9C, 0x4E, 0x00, 0xA0, 0xC9, 0x05, 0x42, 0x5E]};
+enum IID DPAID_TotalSize = {0x1318F560, 0x912C, 0x11D0, [0x9D, 0xAA, 0x00, 0xA0, 0xC9, 0x0A, 0x43, 0xCB]};
+enum IID DPLPROPERTY_LobbyGuid = {0xF56920A0, 0xD218, 0x11D0, [0xBA, 0x39, 0x00, 0xC0, 0x4F, 0xD7, 0xED, 0x67]};
+enum IID DPLPROPERTY_MessagesSupported = {0x762CCDA1, 0xD916, 0x11D0, [0xBA, 0x39, 0x00, 0xC0, 0x4F, 0xD7, 0xED, 0x67]};
+enum IID DPLPROPERTY_PlayerGuid = {0xB4319322, 0xD20D, 0x11D0, [0xBA, 0x39, 0x00, 0xC0, 0x4F, 0xD7, 0xED, 0x67]};
+enum IID DPLPROPERTY_PlayerScore = {0x48784000, 0xD219, 0x11D0, [0xBA, 0x39, 0x00, 0xC0, 0x4F, 0xD7, 0xED, 0x67]};
+enum IID DPSPGUID_IPX = {0x685BC400, 0x9D2C, 0x11CF, [0xA9, 0xCD, 0x00, 0xAA, 0x00, 0x68, 0x86, 0xE3]};
+enum IID DPSPGUID_MODEM = {0x44EAA760, 0xCB68, 0x11CF, [0x9C, 0x4E, 0x00, 0xA0, 0xC9, 0x05, 0x42, 0x5E]};
+enum IID DPSPGUID_SERIAL = {0x0F1D6860, 0x88D9, 0x11CF, [0x9C, 0x4E, 0x00, 0xA0, 0xC9, 0x05, 0x42, 0x5E]};
+enum IID DPSPGUID_TCPIP = {0x36E95EE0, 0x8577, 0x11CF, [0x96, 0x0C, 0x00, 0x80, 0xC7, 0x53, 0x4E, 0x82]};
+enum IID DS3DALG_HRTF_FULL = {0xC2413340, 0x1C1B, 0x11D2, [0x94, 0xF5, 0x00, 0xC0, 0x4F, 0xC2, 0x8A, 0xCA]};
+enum IID DS3DALG_HRTF_LIGHT = {0xC2413342, 0x1C1B, 0x11D2, [0x94, 0xF5, 0x00, 0xC0, 0x4F, 0xC2, 0x8A, 0xCA]};
+enum IID DS3DALG_NO_VIRTUALIZATION = {0xC241333F, 0x1C1B, 0x11D2, [0x94, 0xF5, 0x00, 0xC0, 0x4F, 0xC2, 0x8A, 0xCA]};
+enum IID FLAGID_Internet = {0x96300DA0, 0x2BAB, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID FMTID_AudioSummaryInformation = {0x64440490, 0x4C8B, 0x11D1, [0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03]};
+enum IID FMTID_Briefcase = {0x328D8B21, 0x7729, 0x4BFC, [0x95, 0x4C, 0x90, 0x2B, 0x32, 0x9D, 0x56, 0xB0]};
+enum IID FMTID_DiscardableInformation = {0xD725EBB0, 0xC9B8, 0x11D1, [0x89, 0xBC, 0x00, 0x00, 0xF8, 0x04, 0xB0, 0x57]};
+enum IID FMTID_Displaced = {0x9B174B33, 0x40FF, 0x11D2, [0xA2, 0x7E, 0x00, 0xC0, 0x4F, 0xC3, 0x08, 0x71]};
+enum IID FMTID_DocSummaryInformation = {0xD5CDD502, 0x2E9C, 0x101B, [0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE]};
+enum IID FMTID_DRM = {0xAEAC19E4, 0x89AE, 0x4508, [0xB9, 0xB7, 0xBB, 0x86, 0x7A, 0xBE, 0xE2, 0xED]};
+enum IID FMTID_ImageProperties = {0x14B81DA1, 0x0135, 0x4D31, [0x96, 0xD9, 0x6C, 0xBF, 0xC9, 0x67, 0x1A, 0x99]};
+enum IID FMTID_ImageSummaryInformation = {0x6444048F, 0x4C8B, 0x11D1, [0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03]};
+enum IID FMTID_InternetSite = {0x000214A1, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID FMTID_Intshcut = {0x000214A0, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID FMTID_MediaFileSummaryInformation = {0x64440492, 0x4C8B, 0x11D1, [0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03]};
+enum IID FMTID_Misc = {0x9B174B34, 0x40FF, 0x11D2, [0xA2, 0x7E, 0x00, 0xC0, 0x4F, 0xC3, 0x08, 0x71]};
+enum IID FMTID_MUSIC = {0x56A3372E, 0xCE9C, 0x11D2, [0x9F, 0x0E, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6]};
+enum IID FMTID_PropertyBag = {0x20001801, 0x5DE6, 0x11D1, [0x8E, 0x38, 0x00, 0xC0, 0x4F, 0xB9, 0x38, 0x6D]};
+enum IID FMTID_Query = {0x49691C90, 0x7E17, 0x101A, [0xA9, 0x1C, 0x08, 0x00, 0x2B, 0x2E, 0xCD, 0xA9]};
+enum IID FMTID_ShellDetails = {0x28636AA6, 0x953D, 0x11D2, [0xB5, 0xD6, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0]};
+enum IID FMTID_Storage = {0xB725F130, 0x47EF, 0x101A, [0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC]};
+enum IID FMTID_SummaryInformation = {0xF29F85E0, 0x4FF9, 0x1068, [0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9]};
+enum IID FMTID_UserDefinedProperties = {0xD5CDD505, 0x2E9C, 0x101B, [0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE]};
+enum IID FMTID_VideoSummaryInformation = {0x64440491, 0x4C8B, 0x11D1, [0x8B, 0x70, 0x08, 0x00, 0x36, 0xB1, 0x1A, 0x03]};
+enum IID FMTID_Volume = {0x9B174B35, 0x40FF, 0x11D2, [0xA2, 0x7E, 0x00, 0xC0, 0x4F, 0xC3, 0x08, 0x71]};
+enum IID FMTID_WebView = {0xF2275480, 0xF782, 0x4291, [0xBD, 0x94, 0xF1, 0x36, 0x93, 0x51, 0x3A, 0xEC]};
+enum IID GUID_ACPI_CMOS_INTERFACE_STANDARD = {0x3A8D0384, 0x6505, 0x40CA, [0xBC, 0x39, 0x56, 0xC1, 0x5F, 0x8C, 0x5F, 0xED]};
+enum IID GUID_ACPI_INTERFACE_STANDARD = {0xB091A08A, 0xBA97, 0x11D0, [0xBD, 0x14, 0x00, 0xAA, 0x00, 0xB7, 0xB3, 0x2A]};
+enum IID GUID_ACPI_PORT_RANGES_INTERFACE_STAND = {0xF14F609B, 0xCBBD, 0x4957, [0xA6, 0x74, 0xBC, 0x00, 0x21, 0x3F, 0x1C, 0x97]};
+enum IID GUID_ACPI_REGS_INTERFACE_STANDARD = {0x06141966, 0x7245, 0x6369, [0x46, 0x2E, 0x4E, 0x65, 0x6C, 0x73, 0x6F, 0x6E]};
+enum IID GUID_ARBITER_INTERFACE_STANDARD = {0xE644F185, 0x8C0E, 0x11D0, [0xBE, 0xCF, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F]};
+enum IID GUID_BUS_INTERFACE_STANDARD = {0x496B8280, 0x6F25, 0x11D0, [0xBE, 0xAF, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F]};
+enum IID GUID_BUS_TYPE_1394 = {0xF74E73EB, 0x9AC5, 0x45EB, [0xBE, 0x4D, 0x77, 0x2C, 0xC7, 0x1D, 0xDF, 0xB3]};
+enum IID GUID_BUS_TYPE_AVC = {0xC06FF265, 0xAE09, 0x48F0, [0x81, 0x2C, 0x16, 0x75, 0x3D, 0x7C, 0xBA, 0x83]};
+enum IID GUID_BUS_TYPE_DOT4PRT = {0x441EE001, 0x4342, 0x11D5, [0xA1, 0x84, 0x00, 0xC0, 0x4F, 0x60, 0x52, 0x4D]};
+enum IID GUID_BUS_TYPE_EISA = {0xDDC35509, 0xF3FC, 0x11D0, [0xA5, 0x37, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xD1]};
+enum IID GUID_BUS_TYPE_HID = {0xEEAF37D0, 0x1963, 0x47C4, [0xAA, 0x48, 0x72, 0x47, 0x6D, 0xB7, 0xCF, 0x49]};
+enum IID GUID_BUS_TYPE_INTERNAL = {0x1530EA73, 0x086B, 0x11D1, [0xA0, 0x9F, 0x00, 0xC0, 0x4F, 0xC3, 0x40, 0xB1]};
+enum IID GUID_BUS_TYPE_IRDA = {0x7AE17DC1, 0xC944, 0x44D6, [0x88, 0x1F, 0x4C, 0x2E, 0x61, 0x05, 0x3B, 0xC1]};
+enum IID GUID_BUS_TYPE_ISAPNP = {0xE676F854, 0xD87D, 0x11D0, [0x92, 0xB2, 0x00, 0xA0, 0xC9, 0x05, 0x5F, 0xC5]};
+enum IID GUID_BUS_TYPE_LPTENUM = {0xC4CA1000, 0x2DDC, 0x11D5, [0xA1, 0x7A, 0x00, 0xC0, 0x4F, 0x60, 0x52, 0x4D]};
+enum IID GUID_BUS_TYPE_MCA = {0x1C75997A, 0xDC33, 0x11D0, [0x92, 0xB2, 0x00, 0xA0, 0xC9, 0x05, 0x5F, 0xC5]};
+enum IID GUID_BUS_TYPE_PCI = {0xC8EBDFB0, 0xB510, 0x11D0, [0x80, 0xE5, 0x00, 0xA0, 0xC9, 0x25, 0x42, 0xE3]};
+enum IID GUID_BUS_TYPE_PCMCIA = {0x09343630, 0xAF9F, 0x11D0, [0x92, 0xE9, 0x00, 0x00, 0xF8, 0x1E, 0x1B, 0x30]};
+enum IID GUID_BUS_TYPE_SERENUM = {0x77114A87, 0x8944, 0x11D1, [0xBD, 0x90, 0x00, 0xA0, 0xC9, 0x06, 0xBE, 0x2D]};
+enum IID GUID_BUS_TYPE_USB = {0x9D7DEBBC, 0xC85D, 0x11D1, [0x9E, 0xB4, 0x00, 0x60, 0x08, 0xC3, 0xA1, 0x9A]};
+enum IID GUID_BUS_TYPE_USBPRINT = {0x441EE000, 0x4342, 0x11D5, [0xA1, 0x84, 0x00, 0xC0, 0x4F, 0x60, 0x52, 0x4D]};
+enum IID GUID_Button = {0xA36D02F0, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_CHECKVALUEEXCLUSIVE = {0x6650430C, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_ChordParam = {0xD2AC289E, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_Clear_All_Bands = {0xD2AC28AB, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_COLOR = {0x66504301, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_ColorControlCallbacks = {0xEFD60CC2, 0x49E7, 0x11D0, [0x88, 0x9D, 0x00, 0xAA, 0x00, 0xBB, 0xB7, 0x6A]};
+enum IID GUID_CommandParam = {0xD2AC289D, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_CommandParam2 = {0x28F97EF7, 0x9538, 0x11D2, [0x97, 0xA9, 0x00, 0xC0, 0x4F, 0xA3, 0x6E, 0x58]};
+enum IID GUID_ConnectToDLSCollection = {0x1DB1AE6B, 0xE92E, 0x11D1, [0xA8, 0xC5, 0x00, 0xC0, 0x4F, 0xA3, 0x72, 0x6E]};
+enum IID GUID_ConstantForce = {0x13541C20, 0x8E33, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID GUID_CustomForce = {0x13541C2B, 0x8E33, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID GUID_D3DCallbacks2 = {0x0BA584E1, 0x70B6, 0x11D0, [0x88, 0x9D, 0x00, 0xAA, 0x00, 0xBB, 0xB7, 0x6A]};
+enum IID GUID_D3DCallbacks3 = {0xDDF41230, 0xEC0A, 0x11D0, [0xA9, 0xB6, 0x00, 0xAA, 0x00, 0xC0, 0x99, 0x3E]};
+enum IID GUID_D3DExtendedCaps = {0x7DE41F80, 0x9D93, 0x11D0, [0x89, 0xAB, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x29]};
+enum IID GUID_D3DParseUnknownCommandCallback = {0x2E04FFA0, 0x98E4, 0x11D1, [0x8C, 0xE1, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8]};
+enum IID GUID_Damper = {0x13541C28, 0x8E33, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID GUID_DDMoreCaps = {0x880BAF30, 0xB030, 0x11D0, [0x8E, 0xA7, 0x00, 0x60, 0x97, 0x97, 0xEA, 0x5B]};
+enum IID GUID_DDMoreSurfaceCaps = {0x3B8A0466, 0xF269, 0x11D1, [0x88, 0x0B, 0x00, 0xC0, 0x4F, 0xD9, 0x30, 0xC5]};
+enum IID GUID_DDStereoMode = {0xF828169C, 0xA8E8, 0x11D2, [0xA1, 0xF2, 0x00, 0xA0, 0xC9, 0x83, 0xEA, 0xF6]};
+enum IID GUID_DefaultGMCollection = {0xF17E8673, 0xC3B4, 0x11D1, [0x87, 0x0B, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_DEVCLASS_1394 = {0x6BDD1FC1, 0x810F, 0x11D0, [0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F]};
+enum IID GUID_DEVCLASS_1394DEBUG = {0x66F250D6, 0x7801, 0x4A64, [0xB1, 0x39, 0xEE, 0xA8, 0x0A, 0x45, 0x0B, 0x24]};
+enum IID GUID_DEVCLASS_61883 = {0x7EBEFBC0, 0x3200, 0x11D2, [0xB4, 0xC2, 0x00, 0xA0, 0xC9, 0x69, 0x7D, 0x07]};
+enum IID GUID_DEVCLASS_ADAPTER = {0x4D36E964, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_APMSUPPORT = {0xD45B1C18, 0xC8FA, 0x11D1, [0x9F, 0x77, 0x00, 0x00, 0xF8, 0x05, 0xF5, 0x30]};
+enum IID GUID_DEVCLASS_AVC = {0xC06FF265, 0xAE09, 0x48F0, [0x81, 0x2C, 0x16, 0x75, 0x3D, 0x7C, 0xBA, 0x83]};
+enum IID GUID_DEVCLASS_BATTERY = {0x72631E54, 0x78A4, 0x11D0, [0xBC, 0xF7, 0x00, 0xAA, 0x00, 0xB7, 0xB3, 0x2A]};
+enum IID GUID_DEVCLASS_BLUETOOTH = {0xE0CBF06C, 0xCD8B, 0x4647, [0xBB, 0x8A, 0x26, 0x3B, 0x43, 0xF0, 0xF9, 0x74]};
+enum IID GUID_DEVCLASS_CDROM = {0x4D36E965, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_COMPUTER = {0x4D36E966, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_DECODER = {0x6BDD1FC2, 0x810F, 0x11D0, [0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F]};
+enum IID GUID_DEVCLASS_DISKDRIVE = {0x4D36E967, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_DISPLAY = {0x4D36E968, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_DOT4 = {0x48721B56, 0x6795, 0x11D2, [0xB1, 0xA8, 0x00, 0x80, 0xC7, 0x2E, 0x74, 0xA2]};
+enum IID GUID_DEVCLASS_DOT4PRINT = {0x49CE6AC8, 0x6F86, 0x11D2, [0xB1, 0xE5, 0x00, 0x80, 0xC7, 0x2E, 0x74, 0xA2]};
+enum IID GUID_DEVCLASS_ENUM1394 = {0xC459DF55, 0xDB08, 0x11D1, [0xB0, 0x09, 0x00, 0xA0, 0xC9, 0x08, 0x1F, 0xF6]};
+enum IID GUID_DEVCLASS_FDC = {0x4D36E969, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_FLOPPYDISK = {0x4D36E980, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_FSFILTER_ACTIVITYMONIT = {0xB86DFF51, 0xA31E, 0x4BAC, [0xB3, 0xCF, 0xE8, 0xCF, 0xE7, 0x5C, 0x9F, 0xC2]};
+enum IID GUID_DEVCLASS_FSFILTER_ANTIVIRUS = {0xB1D1A169, 0xC54F, 0x4379, [0x81, 0xDB, 0xBE, 0xE7, 0xD8, 0x8D, 0x74, 0x54]};
+enum IID GUID_DEVCLASS_FSFILTER_CFSMETADATASER = {0xCDCF0939, 0xB75B, 0x4630, [0xBF, 0x76, 0x80, 0xF7, 0xBA, 0x65, 0x58, 0x84]};
+enum IID GUID_DEVCLASS_FSFILTER_COMPRESSION = {0xF3586BAF, 0xB5AA, 0x49B5, [0x8D, 0x6C, 0x05, 0x69, 0x28, 0x4C, 0x63, 0x9F]};
+enum IID GUID_DEVCLASS_FSFILTER_CONTENTSCREEN = {0x3E3F0674, 0xC83C, 0x4558, [0xBB, 0x26, 0x98, 0x20, 0xE1, 0xEB, 0xA5, 0xC5]};
+enum IID GUID_DEVCLASS_FSFILTER_CONTINUOUSBACK = {0x71AA14F8, 0x6FAD, 0x4622, [0xAD, 0x77, 0x92, 0xBB, 0x9D, 0x7E, 0x69, 0x47]};
+enum IID GUID_DEVCLASS_FSFILTER_COPYPROTECTIO = {0x89786FF1, 0x9C12, 0x402F, [0x9C, 0x9E, 0x17, 0x75, 0x3C, 0x7F, 0x43, 0x75]};
+enum IID GUID_DEVCLASS_FSFILTER_ENCRYPTION = {0xA0A701C0, 0xA511, 0x42FF, [0xAA, 0x6C, 0x06, 0xDC, 0x03, 0x95, 0x57, 0x6F]};
+enum IID GUID_DEVCLASS_FSFILTER_HSM = {0xD546500A, 0x2AEB, 0x45F6, [0x94, 0x82, 0xF4, 0xB1, 0x79, 0x9C, 0x31, 0x77]};
+enum IID GUID_DEVCLASS_FSFILTER_INFRASTRUCTUR = {0xE55FA6F9, 0x128C, 0x4D04, [0xAB, 0xAB, 0x63, 0x0C, 0x74, 0xB1, 0x45, 0x3A]};
+enum IID GUID_DEVCLASS_FSFILTER_OPENFILEBACKU = {0xF8ECAFA6, 0x66D1, 0x41A5, [0x89, 0x9B, 0x66, 0x58, 0x5D, 0x72, 0x16, 0xB7]};
+enum IID GUID_DEVCLASS_FSFILTER_PHYSICALQUOTAM = {0x6A0A8E78, 0xBBA6, 0x4FC4, [0xA7, 0x09, 0x1E, 0x33, 0xCD, 0x09, 0xD6, 0x7E]};
+enum IID GUID_DEVCLASS_FSFILTER_QUOTAMANAGEME = {0x8503C911, 0xA6C7, 0x4919, [0x8F, 0x79, 0x50, 0x28, 0xF5, 0x86, 0x6B, 0x0C]};
+enum IID GUID_DEVCLASS_FSFILTER_REPLICATION = {0x48D3EBC4, 0x4CF8, 0x48FF, [0xB8, 0x69, 0x9C, 0x68, 0xAD, 0x42, 0xEB, 0x9F]};
+enum IID GUID_DEVCLASS_FSFILTER_SECURITYENHANC = {0xD02BC3DA, 0x0C8E, 0x4945, [0x9B, 0xD5, 0xF1, 0x88, 0x3C, 0x22, 0x6C, 0x8C]};
+enum IID GUID_DEVCLASS_FSFILTER_SYSTEM = {0x5D1B9AAA, 0x01E2, 0x46AF, [0x84, 0x9F, 0x27, 0x2B, 0x3F, 0x32, 0x4C, 0x46]};
+enum IID GUID_DEVCLASS_FSFILTER_SYSTEMRECOVER = {0x2DB15374, 0x706E, 0x4131, [0xA0, 0xC7, 0xD7, 0xC7, 0x8E, 0xB0, 0x28, 0x9A]};
+enum IID GUID_DEVCLASS_FSFILTER_UNDELETE = {0xFE8F1572, 0xC67A, 0x48C0, [0xBB, 0xAC, 0x0B, 0x5C, 0x6D, 0x66, 0xCA, 0xFB]};
+enum IID GUID_DEVCLASS_GPS = {0x6BDD1FC3, 0x810F, 0x11D0, [0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F]};
+enum IID GUID_DEVCLASS_HDC = {0x4D36E96A, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_HIDCLASS = {0x745A17A0, 0x74D3, 0x11D0, [0xB6, 0xFE, 0x00, 0xA0, 0xC9, 0x0F, 0x57, 0xDA]};
+enum IID GUID_DEVCLASS_IMAGE = {0x6BDD1FC6, 0x810F, 0x11D0, [0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F]};
+enum IID GUID_DEVCLASS_INFRARED = {0x6BDD1FC5, 0x810F, 0x11D0, [0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F]};
+enum IID GUID_DEVCLASS_KEYBOARD = {0x4D36E96B, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_LEGACYDRIVER = {0x8ECC055D, 0x047F, 0x11D1, [0xA5, 0x37, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xD1]};
+enum IID GUID_DEVCLASS_MEDIA = {0x4D36E96C, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_MEDIUM_CHANGER = {0xCE5939AE, 0xEBDE, 0x11D0, [0xB1, 0x81, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xC4]};
+enum IID GUID_DEVCLASS_MODEM = {0x4D36E96D, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_MONITOR = {0x4D36E96E, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_MOUSE = {0x4D36E96F, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_MTD = {0x4D36E970, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_MULTIFUNCTION = {0x4D36E971, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_MULTIPORTSERIAL = {0x50906CB8, 0xBA12, 0x11D1, [0xBF, 0x5D, 0x00, 0x00, 0xF8, 0x05, 0xF5, 0x30]};
+enum IID GUID_DEVCLASS_NET = {0x4D36E972, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_NETCLIENT = {0x4D36E973, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_NETSERVICE = {0x4D36E974, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_NETTRANS = {0x4D36E975, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_NODRIVER = {0x4D36E976, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_PCMCIA = {0x4D36E977, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_PNPPRINTERS = {0x4658EE7E, 0xF050, 0x11D1, [0xB6, 0xBD, 0x00, 0xC0, 0x4F, 0xA3, 0x72, 0xA7]};
+enum IID GUID_DEVCLASS_PORTS = {0x4D36E978, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_PRINTER = {0x4D36E979, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_PRINTERUPGRADE = {0x4D36E97A, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_PROCESSOR = {0x50127DC3, 0x0F36, 0x415E, [0xA6, 0xCC, 0x4C, 0xB3, 0xBE, 0x91, 0x0B, 0x65]};
+enum IID GUID_DEVCLASS_SBP2 = {0xD48179BE, 0xEC20, 0x11D1, [0xB6, 0xB8, 0x00, 0xC0, 0x4F, 0xA3, 0x72, 0xA7]};
+enum IID GUID_DEVCLASS_SCSIADAPTER = {0x4D36E97B, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_SMARTCARDREADER = {0x50DD5230, 0xBA8A, 0x11D1, [0xBF, 0x5D, 0x00, 0x00, 0xF8, 0x05, 0xF5, 0x30]};
+enum IID GUID_DEVCLASS_SOUND = {0x4D36E97C, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_SYSTEM = {0x4D36E97D, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_TAPEDRIVE = {0x6D807884, 0x7D21, 0x11CF, [0x80, 0x1C, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_UNKNOWN = {0x4D36E97E, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVCLASS_USB = {0x36FC9E60, 0xC465, 0x11CF, [0x80, 0x56, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_DEVCLASS_VOLUME = {0x71A27CDD, 0x812A, 0x11D0, [0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F]};
+enum IID GUID_DEVCLASS_VOLUMESNAPSHOT = {0x533C5B84, 0xEC70, 0x11D2, [0x95, 0x05, 0x00, 0xC0, 0x4F, 0x79, 0xDE, 0xAF]};
+enum IID GUID_DEVCLASS_WCEUSBS = {0x25DBCE51, 0x6C8F, 0x4A72, [0x8A, 0x6D, 0xB5, 0x4C, 0x2B, 0x4F, 0xC8, 0x35]};
+enum IID GUID_DEVICE_INTERFACE_ARRIVAL = {0xCB3A4004, 0x46F0, 0x11D0, [0xB0, 0x8F, 0x00, 0x60, 0x97, 0x13, 0x05, 0x3F]};
+enum IID GUID_DEVICE_INTERFACE_REMOVAL = {0xCB3A4005, 0x46F0, 0x11D0, [0xB0, 0x8F, 0x00, 0x60, 0x97, 0x13, 0x05, 0x3F]};
+enum IID GUID_DEVINTERFACE_CDCHANGER = {0x53F56312, 0xB6BF, 0x11D0, [0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B]};
+enum IID GUID_DEVINTERFACE_CDROM = {0x53F56308, 0xB6BF, 0x11D0, [0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B]};
+enum IID GUID_DEVINTERFACE_COMPORT = {0x86E0D1E0, 0x8089, 0x11D0, [0x9C, 0xE4, 0x08, 0x00, 0x3E, 0x30, 0x1F, 0x73]};
+enum IID GUID_DEVINTERFACE_DISK = {0x53F56307, 0xB6BF, 0x11D0, [0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B]};
+enum IID GUID_DEVINTERFACE_FLOPPY = {0x53F56311, 0xB6BF, 0x11D0, [0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B]};
+enum IID GUID_DEVINTERFACE_MEDIUMCHANGER = {0x53F56310, 0xB6BF, 0x11D0, [0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B]};
+enum IID GUID_DEVINTERFACE_PARTITION = {0x53F5630A, 0xB6BF, 0x11D0, [0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B]};
+enum IID GUID_DEVINTERFACE_SERENUM_BUS_ENUMERA = {0x4D36E978, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_DEVINTERFACE_STORAGEPORT = {0x2ACCFE60, 0xC130, 0x11D2, [0xB0, 0x82, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B]};
+enum IID GUID_DEVINTERFACE_TAPE = {0x53F5630B, 0xB6BF, 0x11D0, [0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B]};
+enum IID GUID_DEVINTERFACE_VOLUME = {0x53F5630D, 0xB6BF, 0x11D0, [0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B]};
+enum IID GUID_DEVINTERFACE_WRITEONCEDISK = {0x53F5630C, 0xB6BF, 0x11D0, [0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B]};
+enum IID GUID_DirectDrawPaletteStream = {0x730C7FFC, 0x5347, 0x11D1, [0x8C, 0x4D, 0x00, 0xC0, 0x4F, 0xD9, 0x30, 0xC5]};
+enum IID GUID_DirectDrawSurfaceStream = {0xE043BC46, 0x5317, 0x11D1, [0x8C, 0x4D, 0x00, 0xC0, 0x4F, 0xD9, 0x30, 0xC5]};
+enum IID GUID_DirectMusicAllTypes = {0xD2AC2893, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_Disable_Auto_Download = {0xD2AC28AA, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_DisableTempo = {0x45FC707D, 0x1DB4, 0x11D2, [0xBC, 0xAC, 0x00, 0xA0, 0xC9, 0x22, 0xE6, 0xEB]};
+enum IID GUID_DisableTimeSig = {0x45FC707B, 0x1DB4, 0x11D2, [0xBC, 0xAC, 0x00, 0xA0, 0xC9, 0x22, 0xE6, 0xEB]};
+enum IID GUID_DMUS_PROP_DLS1 = {0x178F2F27, 0xC364, 0x11D1, [0xA7, 0x60, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12]};
+enum IID GUID_DMUS_PROP_DLS2 = {0xF14599E5, 0x4689, 0x11D2, [0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6]};
+enum IID GUID_DMUS_PROP_Effects = {0xCDA8D611, 0x684A, 0x11D2, [0x87, 0x1E, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_DMUS_PROP_GM_Hardware = {0x178F2F24, 0xC364, 0x11D1, [0xA7, 0x60, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12]};
+enum IID GUID_DMUS_PROP_GS_Capable = {0x6496ABA2, 0x61B0, 0x11D2, [0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6]};
+enum IID GUID_DMUS_PROP_GS_Hardware = {0x178F2F25, 0xC364, 0x11D1, [0xA7, 0x60, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12]};
+enum IID GUID_DMUS_PROP_INSTRUMENT2 = {0x865FD372, 0x9F67, 0x11D2, [0x87, 0x2A, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_DMUS_PROP_LegacyCaps = {0xCFA7CDC2, 0x00A1, 0x11D2, [0xAA, 0xD5, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12]};
+enum IID GUID_DMUS_PROP_MemorySize = {0x178F2F28, 0xC364, 0x11D1, [0xA7, 0x60, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12]};
+enum IID GUID_DMUS_PROP_SampleMemorySize = {0x178F2F28, 0xC364, 0x11D1, [0xA7, 0x60, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12]};
+enum IID GUID_DMUS_PROP_SamplePlaybackRate = {0x2A91F713, 0xA4BF, 0x11D2, [0xBB, 0xDF, 0x00, 0x60, 0x08, 0x33, 0xDB, 0xD8]};
+enum IID GUID_DMUS_PROP_SynthSink_DSOUND = {0x0AA97844, 0xC877, 0x11D1, [0x87, 0x0C, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_DMUS_PROP_SynthSink_WAVE = {0x0AA97845, 0xC877, 0x11D1, [0x87, 0x0C, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_DMUS_PROP_Volume = {0xFEDFAE25, 0xE46E, 0x11D1, [0xAA, 0xCE, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12]};
+enum IID GUID_DMUS_PROP_WavesReverb = {0x04CB5622, 0x32E5, 0x11D2, [0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6]};
+enum IID GUID_DMUS_PROP_WriteLatency = {0x268A0FA0, 0x60F2, 0x11D2, [0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6]};
+enum IID GUID_DMUS_PROP_WritePeriod = {0x268A0FA1, 0x60F2, 0x11D2, [0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6]};
+enum IID GUID_DMUS_PROP_XG_Capable = {0x6496ABA1, 0x61B0, 0x11D2, [0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6]};
+enum IID GUID_DMUS_PROP_XG_Hardware = {0x178F2F26, 0xC364, 0x11D1, [0xA7, 0x60, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12]};
+enum IID GUID_Download = {0xD2AC28A7, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_Enable_Auto_Download = {0xD2AC28A9, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_EnableTempo = {0x45FC707E, 0x1DB4, 0x11D2, [0xBC, 0xAC, 0x00, 0xA0, 0xC9, 0x22, 0xE6, 0xEB]};
+enum IID GUID_EnableTimeSig = {0x45FC707C, 0x1DB4, 0x11D2, [0xBC, 0xAC, 0x00, 0xA0, 0xC9, 0x22, 0xE6, 0xEB]};
+enum IID GUID_FONTBOLD = {0x6650430F, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_FONTITALIC = {0x66504310, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_FONTNAME = {0x6650430D, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_FONTSIZE = {0x6650430E, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_FONTSTRIKETHROUGH = {0x66504312, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_FONTUNDERSCORE = {0x66504311, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_Friction = {0x13541C2A, 0x8E33, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID GUID_HANDLE = {0x66504313, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_HasPathProperties = {0x0002DE81, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID GUID_HIDClass = {0x745A17A0, 0x74D3, 0x11D0, [0xB6, 0xFE, 0x00, 0xA0, 0xC9, 0x0F, 0x57, 0xDA]};
+enum IID GUID_HIMETRIC = {0x66504300, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_HWPROFILE_CHANGE_CANCELLED = {0xCB3A4002, 0x46F0, 0x11D0, [0xB0, 0x8F, 0x00, 0x60, 0x97, 0x13, 0x05, 0x3F]};
+enum IID GUID_HWPROFILE_CHANGE_COMPLETE = {0xCB3A4003, 0x46F0, 0x11D0, [0xB0, 0x8F, 0x00, 0x60, 0x97, 0x13, 0x05, 0x3F]};
+enum IID GUID_HWPROFILE_QUERY_CHANGE = {0xCB3A4001, 0x46F0, 0x11D0, [0xB0, 0x8F, 0x00, 0x60, 0x97, 0x13, 0x05, 0x3F]};
+enum IID GUID_IDirectMusicBand = {0xD2AC28AC, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_IDirectMusicChordMap = {0xD2AC28AD, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_IDirectMusicStyle = {0xD2AC28A1, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_Inertia = {0x13541C29, 0x8E33, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID GUID_INT_ROUTE_INTERFACE_STANDARD = {0x70941BF4, 0x0073, 0x11D1, [0xA0, 0x9E, 0x00, 0xC0, 0x4F, 0xC3, 0x40, 0xB1]};
+enum IID GUID_Joystick = {0x6F1D2B70, 0xD5A0, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_KernelCallbacks = {0x80863800, 0x6B06, 0x11D0, [0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8]};
+enum IID GUID_KernelCaps = {0xFFAA7540, 0x7AA8, 0x11D0, [0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8]};
+enum IID GUID_Key = {0x55728220, 0xD33C, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_KeyboardClass = {0x4D36E96B, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_LEGACY_DEVICE_DETECTION_STANDAR = {0x50FEB0DE, 0x596A, 0x11D2, [0xA5, 0xB8, 0x00, 0x00, 0xF8, 0x1A, 0x46, 0x19]};
+enum IID GUID_MediaClass = {0x4D36E96C, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_MF_ENUMERATION_INTERFACE = {0xAEB895F0, 0x5586, 0x11D1, [0x8D, 0x84, 0x00, 0xA0, 0xC9, 0x06, 0xB2, 0x44]};
+enum IID GUID_Miscellaneous2Callbacks = {0x406B2F00, 0x3E5A, 0x11D1, [0xB6, 0x40, 0x00, 0xAA, 0x00, 0xA1, 0xF9, 0x6A]};
+enum IID GUID_MiscellaneousCallbacks = {0xEFD60CC0, 0x49E7, 0x11D0, [0x88, 0x9D, 0x00, 0xAA, 0x00, 0xBB, 0xB7, 0x6A]};
+enum IID GUID_MotionCompCallbacks = {0xB1122B40, 0x5DA5, 0x11D1, [0x8F, 0xCF, 0x00, 0xC0, 0x4F, 0xC2, 0x9B, 0x4E]};
+enum IID GUID_MouseClass = {0x4D36E96F, 0xE325, 0x11CE, [0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18]};
+enum IID GUID_MuteParam = {0xD2AC28AF, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_NDIS_802_11_ADD_WEP = {0x4307BFF0, 0x2129, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_AUTHENTICATION_MODE = {0x43920A24, 0x2129, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_BASIC_RATES = {0x4A198516, 0x2068, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_BSSID = {0x2504B6C2, 0x1FA5, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_BSSID_LIST = {0x69526F9A, 0x2062, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_BSSID_LIST_SCAN = {0x0D9E01E1, 0xBA70, 0x11D4, [0xB6, 0x75, 0x00, 0x20, 0x48, 0x57, 0x03, 0x37]};
+enum IID GUID_NDIS_802_11_CONFIGURATION = {0x4A4DF982, 0x2068, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_DESIRED_RATES = {0x452EE08E, 0x2536, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_DISASSOCIATE = {0x43671F40, 0x2129, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_FRAGMENTATION_THRESH = {0x69AAA7C4, 0x2062, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_INFRASTRUCTURE_MODE = {0x697D5A7E, 0x2062, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_NETWORK_TYPE_IN_USE = {0x857E2326, 0x2041, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_NETWORK_TYPES_SUPPOR = {0x8531D6E6, 0x2041, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_NUMBER_OF_ANTENNAS = {0x01779336, 0x2064, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_POWER_MODE = {0x85BE837C, 0x2041, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_PRIVACY_FILTER = {0x6733C4E9, 0x4792, 0x11D4, [0x97, 0xF1, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_REMOVE_WEP = {0x433C345C, 0x2129, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_RSSI = {0x1507DB16, 0x2053, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_RSSI_TRIGGER = {0x155689B8, 0x2053, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_RTS_THRESHOLD = {0x0134D07E, 0x2064, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_RX_ANTENNA_SELECTED = {0x01AC07A2, 0x2064, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_SSID = {0x7D2A90EA, 0x2041, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_STATISTICS = {0x42BB73B0, 0x2129, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_SUPPORTED_RATES = {0x49DB8722, 0x2068, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_TX_ANTENNA_SELECTED = {0x01DBB74A, 0x2064, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_TX_POWER_LEVEL = {0x11E6BA76, 0x2053, 0x11D4, [0x97, 0xEB, 0x00, 0xC0, 0x4F, 0x79, 0xC4, 0x03]};
+enum IID GUID_NDIS_802_11_WEP_STATUS = {0xB027A21F, 0x3CFA, 0x4125, [0x80, 0x0B, 0x3F, 0x7A, 0x18, 0xFD, 0xDC, 0xDC]};
+enum IID GUID_NDIS_802_3_CURRENT_ADDRESS = {0x44795700, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_3_MAC_OPTIONS = {0x44795703, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_3_MAXIMUM_LIST_SIZE = {0x44795702, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_3_MULTICAST_LIST = {0x44795701, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_3_PERMANENT_ADDRESS = {0x447956FF, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_3_RCV_ERROR_ALIGNMENT = {0x44795704, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_3_XMIT_MORE_COLLISIONS = {0x44795706, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_3_XMIT_ONE_COLLISION = {0x44795705, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_5_CURRENT_ADDRESS = {0x44795708, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_5_CURRENT_FUNCTIONAL = {0x44795709, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_5_CURRENT_GROUP = {0x4479570A, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_5_CURRENT_RING_STATE = {0xACF14032, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_5_CURRENT_RING_STATUS = {0x890A36EC, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_5_LAST_OPEN_STATUS = {0x4479570B, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_5_LINE_ERRORS = {0xACF14033, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_5_LOST_FRAMES = {0xACF14034, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_802_5_PERMANENT_ADDRESS = {0x44795707, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_HW_CURRENT_ADDRESS = {0x791AD1A1, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_MAX_AAL0_PACKET_SIZE = {0x791AD1A5, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_MAX_AAL1_PACKET_SIZE = {0x791AD1A6, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_MAX_AAL34_PACKET_SIZE = {0x791AD1A7, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_MAX_AAL5_PACKET_SIZE = {0x791AD191, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_MAX_ACTIVE_VCI_BITS = {0x791AD1A3, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_MAX_ACTIVE_VCS = {0x791AD1A2, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_MAX_ACTIVE_VPI_BITS = {0x791AD1A4, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_RCV_CELLS_DROPPED = {0x0A21480C, 0xE35F, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_RCV_CELLS_OK = {0x0A21480A, 0xE35F, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_SUPPORTED_AAL_TYPES = {0x791AD1A0, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_SUPPORTED_SERVICE_CATEG = {0x791AD19F, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_SUPPORTED_VC_RATES = {0x791AD19E, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ATM_XMIT_CELLS_OK = {0x0A21480B, 0xE35F, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ENUMERATE_ADAPTER = {0x981F2D7F, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_ENUMERATE_VC = {0x981F2D82, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_ATTACHMENT_TYPE = {0xACF1403D, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_DOWNSTREAM_NODE_LONG = {0xACF1403F, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_FRAME_ERRORS = {0xACF14040, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_FRAMES_LOST = {0xACF14041, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_LCONNECTION_STATE = {0xACF14045, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_LCT_FAILURES = {0xACF14043, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_LEM_REJECTS = {0xACF14044, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_LONG_CURRENT_ADDR = {0xACF14036, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_LONG_MAX_LIST_SIZE = {0xACF14038, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_LONG_MULTICAST_LIST = {0xACF14037, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_LONG_PERMANENT_ADDR = {0xACF14035, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_RING_MGT_STATE = {0xACF14042, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_SHORT_CURRENT_ADDR = {0xACF1403A, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_SHORT_MAX_LIST_SIZE = {0xACF1403C, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_SHORT_MULTICAST_LIST = {0xACF1403B, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_SHORT_PERMANENT_ADDR = {0xACF14039, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_FDDI_UPSTREAM_NODE_LONG = {0xACF1403E, 0xA61C, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_DRIVER_VERSION = {0x791AD198, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_HARDWARE_STATUS = {0x791AD192, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_LINK_SPEED = {0x791AD195, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_MAC_OPTIONS = {0x791AD19A, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_MEDIA_CONNECT_STATU = {0x791AD19B, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_MEDIA_IN_USE = {0x791AD194, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_MEDIA_SUPPORTED = {0x791AD193, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_MINIMUM_LINK_SPEED = {0x791AD19D, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_RCV_PDUS_ERROR = {0x0A214808, 0xE35F, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_RCV_PDUS_NO_BUFFER = {0x0A214809, 0xE35F, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_RCV_PDUS_OK = {0x0A214806, 0xE35F, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_VENDOR_DESCRIPTION = {0x791AD197, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_VENDOR_DRIVER_VERSI = {0x791AD19C, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_VENDOR_ID = {0x791AD196, 0xE35C, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_XMIT_PDUS_ERROR = {0x0A214807, 0xE35F, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CO_XMIT_PDUS_OK = {0x0A214805, 0xE35F, 0x11D0, [0x96, 0x92, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CURRENT_LOOKAHEAD = {0x5EC10361, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_CURRENT_PACKET_FILTER = {0x5EC10360, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_DRIVER_VERSION = {0x5EC10362, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_HARDWARE_STATUS = {0x5EC10354, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_LINK_SPEED = {0x5EC10359, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_MAC_OPTIONS = {0x5EC10365, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_MAXIMUM_FRAME_SIZE = {0x5EC10358, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_MAXIMUM_LOOKAHEAD = {0x5EC10357, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_MAXIMUM_SEND_PACKETS = {0x5EC10367, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_MAXIMUM_TOTAL_SIZE = {0x5EC10363, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_MEDIA_CONNECT_STATUS = {0x5EC10366, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_MEDIA_IN_USE = {0x5EC10356, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_MEDIA_SUPPORTED = {0x5EC10355, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_PHYSICAL_MEDIUM = {0x418CA16D, 0x3937, 0x4208, [0x94, 0x0A, 0xEC, 0x61, 0x96, 0x27, 0x80, 0x85]};
+enum IID GUID_NDIS_GEN_RCV_ERROR = {0x447956FD, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_RCV_NO_BUFFER = {0x447956FE, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_RCV_OK = {0x447956FB, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_RECEIVE_BLOCK_SIZE = {0x5EC1035D, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_RECEIVE_BUFFER_SPACE = {0x5EC1035B, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_TRANSMIT_BLOCK_SIZE = {0x5EC1035C, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_TRANSMIT_BUFFER_SPACE = {0x5EC1035A, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_VENDOR_DESCRIPTION = {0x5EC1035F, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_VENDOR_DRIVER_VERSION = {0x447956F9, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_VENDOR_ID = {0x5EC1035E, 0xA61A, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_VLAN_ID = {0x765DC702, 0xC5E8, 0x4B67, [0x84, 0x3B, 0x3F, 0x5A, 0x4F, 0xF2, 0x64, 0x8B]};
+enum IID GUID_NDIS_GEN_XMIT_ERROR = {0x447956FC, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_GEN_XMIT_OK = {0x447956FA, 0xA61B, 0x11D0, [0x8D, 0xD4, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_LAN_CLASS = {0xAD498944, 0x762F, 0x11D0, [0x8D, 0xCB, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_NOTIFY_ADAPTER_ARRIVAL = {0x981F2D81, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_NOTIFY_ADAPTER_REMOVAL = {0x981F2D80, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_NOTIFY_BIND = {0x5413531C, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_NOTIFY_UNBIND = {0x6E3CE1EC, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_NOTIFY_VC_ARRIVAL = {0x182F9E0C, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_NOTIFY_VC_REMOVAL = {0x981F2D79, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_STATUS_LINK_SPEED_CHANGE = {0x981F2D85, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_STATUS_MEDIA_CONNECT = {0x981F2D7D, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_STATUS_MEDIA_DISCONNECT = {0x981F2D7E, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_STATUS_MEDIA_SPECIFIC_INDIC = {0x981F2D84, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_STATUS_RESET_END = {0x981F2D77, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_STATUS_RESET_START = {0x981F2D76, 0xB1F3, 0x11D0, [0x8D, 0xD7, 0x00, 0xC0, 0x4F, 0xC3, 0x35, 0x8C]};
+enum IID GUID_NDIS_WAKE_ON_MAGIC_PACKET_ONLY = {0xA14F1C97, 0x8839, 0x4F8A, [0x99, 0x96, 0xA2, 0x89, 0x96, 0xEB, 0xBF, 0x1D]};
+enum IID GUID_NETSHELL_PROPS = {0x2D15A9A1, 0xA556, 0x4189, [0x91, 0xAD, 0x02, 0x74, 0x58, 0xF1, 0x1A, 0x07]};
+enum IID GUID_NonLocalVidMemCaps = {0x86C4FA80, 0x8D84, 0x11D0, [0x94, 0xE8, 0x00, 0xC0, 0x4F, 0xC3, 0x41, 0x37]};
+enum IID GUID_NOTIFICATION_CHORD = {0xD2AC289B, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_NOTIFICATION_COMMAND = {0xD2AC289C, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_NOTIFICATION_MEASUREANDBEAT = {0xD2AC289A, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_NOTIFICATION_PERFORMANCE = {0x81F75BC5, 0x4E5D, 0x11D2, [0xBC, 0xC7, 0x00, 0xA0, 0xC9, 0x22, 0xE6, 0xEB]};
+enum IID GUID_NOTIFICATION_SEGMENT = {0xD2AC2899, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_NULL = {0x00000000, 0x0000, 0x0000, [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]};
+enum IID GUID_OPTIONVALUEEXCLUSIVE = {0x6650430B, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_OptSurfaceKmodeInfo = {0xE05C8472, 0x51D4, 0x11D1, [0x8C, 0xCE, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8]};
+enum IID GUID_OptSurfaceUmodeInfo = {0x9D792804, 0x5FA8, 0x11D1, [0x8C, 0xD0, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8]};
+enum IID GUID_PathProperty = {0x0002DE80, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID GUID_PCI_BUS_INTERFACE_STANDARD = {0x496B8281, 0x6F25, 0x11D0, [0xBE, 0xAF, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F]};
+enum IID GUID_PCI_DEVICE_PRESENT_INTERFACE = {0xD1B82C26, 0xBF49, 0x45EF, [0xB2, 0x16, 0x71, 0xCB, 0xD7, 0x88, 0x9B, 0x57]};
+enum IID GUID_PCMCIA_BUS_INTERFACE_STANDARD = {0x76173AF0, 0xC504, 0x11D1, [0x94, 0x7F, 0x00, 0xC0, 0x4F, 0xB9, 0x60, 0xEE]};
+enum IID GUID_PerfAutoDownload = {0xFB09565B, 0x3631, 0x11D2, [0xBC, 0xB8, 0x00, 0xA0, 0xC9, 0x22, 0xE6, 0xEB]};
+enum IID GUID_PerfMasterGrooveLevel = {0xD2AC28B2, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_PerfMasterTempo = {0xD2AC28B0, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_PerfMasterVolume = {0xD2AC28B1, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_PNP_CUSTOM_NOTIFICATION = {0xACA73F8E, 0x8D23, 0x11D1, [0xAC, 0x7D, 0x00, 0x00, 0xF8, 0x75, 0x71, 0xD0]};
+enum IID GUID_PNP_POWER_NOTIFICATION = {0xC2CF0660, 0xEB7A, 0x11D1, [0xBD, 0x7F, 0x00, 0x00, 0xF8, 0x75, 0x71, 0xD0]};
+enum IID GUID_POV = {0xA36D02F2, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_POWER_DEVICE_ENABLE = {0x827C0A6F, 0xFEB0, 0x11D0, [0xBD, 0x26, 0x00, 0xAA, 0x00, 0xB7, 0xB3, 0x2A]};
+enum IID GUID_POWER_DEVICE_TIMEOUTS = {0xA45DA735, 0xFEB0, 0x11D0, [0xBD, 0x26, 0x00, 0xAA, 0x00, 0xB7, 0xB3, 0x2A]};
+enum IID GUID_POWER_DEVICE_WAKE_ENABLE = {0xA9546A82, 0xFEB0, 0x11D0, [0xBD, 0x26, 0x00, 0xAA, 0x00, 0xB7, 0xB3, 0x2A]};
+enum IID GUID_QOS_BESTEFFORT_BANDWIDTH = {0xED885290, 0x40EC, 0x11D1, [0x2C, 0x91, 0x00, 0xAA, 0x00, 0x57, 0x49, 0x15]};
+enum IID GUID_QOS_ENABLE_AVG_STATS = {0xBAFB6D11, 0x27C4, 0x4801, [0xA4, 0x6F, 0xEF, 0x80, 0x80, 0xC1, 0x88, 0xC8]};
+enum IID GUID_QOS_ENABLE_WINDOW_ADJUSTMENT = {0xAA966725, 0xD3E9, 0x4C55, [0xB3, 0x35, 0x2A, 0x00, 0x27, 0x9A, 0x1E, 0x64]};
+enum IID GUID_QOS_FLOW_8021P_CONFORMING = {0x08C1E013, 0xFCD2, 0x11D2, [0xBE, 0x1E, 0x00, 0xA0, 0xC9, 0x9E, 0xE6, 0x3B]};
+enum IID GUID_QOS_FLOW_8021P_NONCONFORMING = {0x09023F91, 0xFCD2, 0x11D2, [0xBE, 0x1E, 0x00, 0xA0, 0xC9, 0x9E, 0xE6, 0x3B]};
+enum IID GUID_QOS_FLOW_COUNT = {0x1147F880, 0x40ED, 0x11D1, [0x2C, 0x91, 0x00, 0xAA, 0x00, 0x57, 0x49, 0x15]};
+enum IID GUID_QOS_FLOW_IP_CONFORMING = {0x07F99A8B, 0xFCD2, 0x11D2, [0xBE, 0x1E, 0x00, 0xA0, 0xC9, 0x9E, 0xE6, 0x3B]};
+enum IID GUID_QOS_FLOW_IP_NONCONFORMING = {0x087A5987, 0xFCD2, 0x11D2, [0xBE, 0x1E, 0x00, 0xA0, 0xC9, 0x9E, 0xE6, 0x3B]};
+enum IID GUID_QOS_FLOW_MODE = {0x5C82290A, 0x515A, 0x11D2, [0x8E, 0x58, 0x00, 0xC0, 0x4F, 0xC9, 0xBF, 0xCB]};
+enum IID GUID_QOS_ISSLOW_FLOW = {0xABF273A4, 0xEE07, 0x11D2, [0xBE, 0x1B, 0x00, 0xA0, 0xC9, 0x9E, 0xE6, 0x3B]};
+enum IID GUID_QOS_LATENCY = {0xFC408EF0, 0x40EC, 0x11D1, [0x2C, 0x91, 0x00, 0xAA, 0x00, 0x57, 0x49, 0x15]};
+enum IID GUID_QOS_MAX_OUTSTANDING_SENDS = {0x161FFA86, 0x6120, 0x11D1, [0x2C, 0x91, 0x00, 0xAA, 0x00, 0x57, 0x49, 0x15]};
+enum IID GUID_QOS_NON_BESTEFFORT_LIMIT = {0x185C44E0, 0x40ED, 0x11D1, [0x2C, 0x91, 0x00, 0xAA, 0x00, 0x57, 0x49, 0x15]};
+enum IID GUID_QOS_REMAINING_BANDWIDTH = {0xC4C51720, 0x40EC, 0x11D1, [0x2C, 0x91, 0x00, 0xAA, 0x00, 0x57, 0x49, 0x15]};
+enum IID GUID_QOS_STATISTICS_BUFFER = {0xBB2C0980, 0xE900, 0x11D1, [0xB0, 0x7E, 0x00, 0x80, 0xC7, 0x13, 0x82, 0xBF]};
+enum IID GUID_QOS_TIMER_RESOLUTION = {0xBA10CC88, 0xF13E, 0x11D2, [0xBE, 0x1B, 0x00, 0xA0, 0xC9, 0x9E, 0xE6, 0x3B]};
+enum IID GUID_RampForce = {0x13541C21, 0x8E33, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID GUID_RhythmParam = {0xD2AC289F, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_RxAxis = {0xA36D02F4, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_RyAxis = {0xA36D02F5, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_RzAxis = {0xA36D02E3, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_SawtoothDown = {0x13541C26, 0x8E33, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID GUID_SawtoothUp = {0x13541C25, 0x8E33, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID GUID_SeedVariations = {0x65B76FA5, 0xFF37, 0x11D2, [0x81, 0x4E, 0x00, 0xC0, 0x4F, 0xA3, 0x6E, 0x58]};
+enum IID GUID_Sine = {0x13541C23, 0x8E33, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID GUID_Slider = {0xA36D02E4, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_Spring = {0x13541C27, 0x8E33, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID GUID_Square = {0x13541C22, 0x8E33, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID GUID_StandardMIDIFile = {0x06621075, 0xE92E, 0x11D1, [0xA8, 0xC5, 0x00, 0xC0, 0x4F, 0xA3, 0x72, 0x6E]};
+enum IID GUID_SysKeyboard = {0x6F1D2B61, 0xD5A0, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_SysKeyboardEm = {0x6F1D2B82, 0xD5A0, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_SysKeyboardEm2 = {0x6F1D2B83, 0xD5A0, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_SysMouse = {0x6F1D2B60, 0xD5A0, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_SysMouseEm = {0x6F1D2B80, 0xD5A0, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_SysMouseEm2 = {0x6F1D2B81, 0xD5A0, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_TARGET_DEVICE_QUERY_REMOVE = {0xCB3A4006, 0x46F0, 0x11D0, [0xB0, 0x8F, 0x00, 0x60, 0x97, 0x13, 0x05, 0x3F]};
+enum IID GUID_TARGET_DEVICE_REMOVE_CANCELLED = {0xCB3A4007, 0x46F0, 0x11D0, [0xB0, 0x8F, 0x00, 0x60, 0x97, 0x13, 0x05, 0x3F]};
+enum IID GUID_TARGET_DEVICE_REMOVE_COMPLETE = {0xCB3A4008, 0x46F0, 0x11D0, [0xB0, 0x8F, 0x00, 0x60, 0x97, 0x13, 0x05, 0x3F]};
+enum IID GUID_TempoParam = {0xD2AC28A5, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_TimeSignature = {0xD2AC28A4, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_TRANSLATOR_INTERFACE_STANDARD = {0x6C154A92, 0xAACF, 0x11D0, [0x8D, 0x2A, 0x00, 0xA0, 0xC9, 0x06, 0xB2, 0x44]};
+enum IID GUID_Triangle = {0x13541C24, 0x8E33, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID GUID_TRISTATE = {0x6650430A, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_Unknown = {0xA36D02F3, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_Unload = {0xD2AC28A8, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID GUID_UserModeDriverInfo = {0xF0B0E8E2, 0x5F97, 0x11D1, [0x8C, 0xD0, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8]};
+enum IID GUID_UserModeDriverPassword = {0x97F861B6, 0x60A1, 0x11D1, [0x8C, 0xD0, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8]};
+enum IID GUID_VideoPortCallbacks = {0xEFD60CC1, 0x49E7, 0x11D0, [0x88, 0x9D, 0x00, 0xAA, 0x00, 0xBB, 0xB7, 0x6A]};
+enum IID GUID_VideoPortCaps = {0xEFD60CC3, 0x49E7, 0x11D0, [0x88, 0x9D, 0x00, 0xAA, 0x00, 0xBB, 0xB7, 0x6A]};
+enum IID GUID_XAxis = {0xA36D02E0, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_XPOS = {0x66504306, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_XPOSPIXEL = {0x66504302, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_XSIZE = {0x66504308, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_XSIZEPIXEL = {0x66504304, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_YAxis = {0xA36D02E1, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_YPOS = {0x66504307, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_YPOSPIXEL = {0x66504303, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_YSIZE = {0x66504309, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_YSIZEPIXEL = {0x66504305, 0xBE0F, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID GUID_ZAxis = {0xA36D02E2, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID GUID_ZPixelFormats = {0x93869880, 0x36CF, 0x11D1, [0x9B, 0x1B, 0x00, 0xAA, 0x00, 0xBB, 0xB8, 0xAE]};
+enum IID IID_AsyncIAdviseSink = {0x00000150, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_AsyncIAdviseSink2 = {0x00000151, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_AsyncIBackgroundCopyCallback = {0xCA29D251, 0xB4BB, 0x4679, [0xA3, 0xD9, 0xAE, 0x80, 0x06, 0x11, 0x9D, 0x54]};
+enum IID IID_AsyncIClusCfgBaseCluster = {0xA8A5C614, 0x2518, 0x47F5, [0x96, 0xCA, 0xCA, 0xFA, 0x7F, 0xFB, 0xAF, 0x68]};
+enum IID IID_AsyncIClusCfgCallback = {0xEBCE8945, 0xAC69, 0x4B3A, [0x86, 0x5D, 0xE2, 0xD4, 0xEB, 0x33, 0xE4, 0x1B]};
+enum IID IID_AsyncIClusCfgClusterInfo = {0x8BDBA247, 0x04F5, 0x4114, [0x83, 0x7E, 0xB2, 0x63, 0x41, 0x2A, 0x4B, 0x64]};
+enum IID IID_AsyncIClusCfgCredentials = {0x54AA9406, 0xA409, 0x4B49, [0xB3, 0x14, 0x5F, 0x0A, 0x0C, 0xE4, 0xC8, 0x8F]};
+enum IID IID_AsyncIClusCfgEvictCleanup = {0x6FE3E362, 0xD373, 0x4C5F, [0xA0, 0xAF, 0x1D, 0xFE, 0x84, 0x93, 0xC6, 0x55]};
+enum IID IID_AsyncIClusCfgInitialize = {0x2A0EB82E, 0xF878, 0x492A, [0x95, 0x1E, 0xAE, 0x00, 0x09, 0x18, 0xC4, 0xA6]};
+enum IID IID_AsyncIClusCfgIPAddressInfo = {0xAAEAF0A5, 0xE310, 0x4604, [0xA5, 0x5E, 0x2F, 0x9D, 0xDC, 0x41, 0x57, 0xA9]};
+enum IID IID_AsyncIClusCfgManagedResourceInfo = {0x73616028, 0x1243, 0x4749, [0xAD, 0x84, 0x0B, 0x5E, 0xB3, 0x58, 0xFF, 0xA0]};
+enum IID IID_AsyncIClusCfgMemberSetChangeListe = {0x2B645350, 0x2643, 0x4ABC, [0xA4, 0xE5, 0x82, 0x4D, 0x88, 0x1B, 0x75, 0x82]};
+enum IID IID_AsyncIClusCfgNetworkInfo = {0xED71FD2D, 0xAD02, 0x4DFC, [0xB3, 0x76, 0x5F, 0xFA, 0x5F, 0x5A, 0x7C, 0x2C]};
+enum IID IID_AsyncIClusCfgNodeInfo = {0x4F3BB40B, 0xDF27, 0x40A0, [0xB3, 0x1A, 0xBA, 0x18, 0x32, 0x4C, 0xEB, 0x9D]};
+enum IID IID_AsyncIClusCfgPartitionInfo = {0xEC1EBD9F, 0x5866, 0x4846, [0x89, 0x52, 0xEC, 0x36, 0xC3, 0x96, 0x1E, 0xEF]};
+enum IID IID_AsyncIClusCfgResourceTypeCreate = {0x3AFCE3B9, 0x5F3E, 0x4DDF, [0xA8, 0xF4, 0x4B, 0x4F, 0xCB, 0xF2, 0x8F, 0x8F]};
+enum IID IID_AsyncIClusCfgResourceTypeInfo = {0xC649A282, 0xC847, 0x4F5C, [0x98, 0x41, 0xD2, 0xF7, 0x3B, 0x5A, 0xA7, 0x1D]};
+enum IID IID_AsyncIClusCfgServer = {0x2A1640AA, 0x4561, 0x4A08, [0xB5, 0xD9, 0x0A, 0xA3, 0x8C, 0x6B, 0xE6, 0x28]};
+enum IID IID_AsyncIClusCfgStartupListener = {0xD282CAF0, 0x2EDE, 0x4AB9, [0xA5, 0xD5, 0xF7, 0xBD, 0xE3, 0xD2, 0x3F, 0x10]};
+enum IID IID_AsyncIClusCfgStartupNotify = {0xC2B0D06A, 0x6353, 0x4EE1, [0xB2, 0x53, 0x6B, 0x0D, 0x75, 0xDB, 0x2C, 0xD3]};
+enum IID IID_AsyncIEnumClusCfgIPAddresses = {0xBD5F35BA, 0x0BC0, 0x455F, [0x92, 0x6D, 0xC3, 0xD3, 0x56, 0x41, 0x94, 0x87]};
+enum IID IID_AsyncIEnumClusCfgManagedResource = {0xB138483F, 0x9695, 0x4FA6, [0xA9, 0x8F, 0x0D, 0xE2, 0xFB, 0x35, 0x54, 0x49]};
+enum IID IID_AsyncIEnumClusCfgNetworks = {0xF56B9B0D, 0xE7B8, 0x49EC, [0xA8, 0x43, 0x54, 0x75, 0x07, 0x6B, 0x94, 0x7D]};
+enum IID IID_AsyncIEnumClusCfgPartitions = {0x4440BB6A, 0xB0AC, 0x479D, [0xB5, 0x34, 0x72, 0x65, 0xA3, 0x1D, 0x6C, 0x56]};
+enum IID IID_AsyncIMultiQI = {0x000E0020, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_AsyncIPipeByte = {0xDB2F3ACB, 0x2F86, 0x11D1, [0x8E, 0x04, 0x00, 0xC0, 0x4F, 0xB9, 0x98, 0x9A]};
+enum IID IID_AsyncIPipeDouble = {0xDB2F3ACF, 0x2F86, 0x11D1, [0x8E, 0x04, 0x00, 0xC0, 0x4F, 0xB9, 0x98, 0x9A]};
+enum IID IID_AsyncIPipeLong = {0xDB2F3ACD, 0x2F86, 0x11D1, [0x8E, 0x04, 0x00, 0xC0, 0x4F, 0xB9, 0x98, 0x9A]};
+enum IID IID_AsyncIUnknown = {0x000E0000, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_DFConstraint = {0x4A3DF050, 0x23BD, 0x11D2, [0x93, 0x9F, 0x00, 0xA0, 0xC9, 0x1E, 0xED, 0xBA]};
+enum IID IID_DIEnumWbemClassObject = {0xCB7CA037, 0xF729, 0x11D0, [0x9E, 0x4D, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID IID_DIWbemCallResult = {0xCB7CA039, 0xF729, 0x11D0, [0x9E, 0x4D, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID IID_DIWbemClassObject = {0xCB7CA033, 0xF729, 0x11D0, [0x9E, 0x4D, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID IID_DIWbemContext = {0xCB7CA038, 0xF729, 0x11D0, [0x9E, 0x4D, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID IID_DIWbemLocator = {0xCB7CA035, 0xF729, 0x11D0, [0x9E, 0x4D, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID IID_DIWbemObjectSink = {0xCB7CA036, 0xF729, 0x11D0, [0x9E, 0x4D, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID IID_DIWbemQualifierSet = {0xCB7CA034, 0xF729, 0x11D0, [0x9E, 0x4D, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID IID_DIWbemServices = {0xCB7CA03A, 0xF729, 0x11D0, [0x9E, 0x4D, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID IID_Folder = {0xBBCBDE60, 0xC3FF, 0x11CE, [0x83, 0x50, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_Folder2 = {0xF0D2D8EF, 0x3890, 0x11D2, [0xBF, 0x8B, 0x00, 0xC0, 0x4F, 0xB9, 0x36, 0x61]};
+enum IID IID_Folder3 = {0xA7AE5F64, 0xC4D7, 0x4D7F, [0x93, 0x07, 0x4D, 0x24, 0xEE, 0x54, 0xB8, 0x41]};
+enum IID IID_FolderItem = {0xFAC32C80, 0xCBE4, 0x11CE, [0x83, 0x50, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_FolderItem2 = {0xEDC817AA, 0x92B8, 0x11D1, [0xB0, 0x75, 0x00, 0xC0, 0x4F, 0xC3, 0x3A, 0xA5]};
+enum IID IID_FolderItems = {0x744129E0, 0xCBE5, 0x11CE, [0x83, 0x50, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_FolderItems2 = {0xC94F0AD0, 0xF363, 0x11D2, [0xA3, 0x27, 0x00, 0xC0, 0x4F, 0x8E, 0xEC, 0x7F]};
+enum IID IID_FolderItems3 = {0xEAA7C309, 0xBBEC, 0x49D5, [0x82, 0x1D, 0x64, 0xD9, 0x66, 0xCB, 0x66, 0x7F]};
+enum IID IID_FolderItemVerb = {0x08EC3E00, 0x50B0, 0x11CF, [0x96, 0x0C, 0x00, 0x80, 0xC7, 0xF4, 0xEE, 0x85]};
+enum IID IID_FolderItemVerbs = {0x1F8352C0, 0x50B0, 0x11CF, [0x96, 0x0C, 0x00, 0x80, 0xC7, 0xF4, 0xEE, 0x85]};
+enum IID IID_IAccessControl = {0xEEDD23E0, 0x8410, 0x11CE, [0xA1, 0xC3, 0x08, 0x00, 0x2B, 0x2B, 0x8D, 0x8F]};
+enum IID IID_IAccessible = {0x618736E0, 0x3C3D, 0x11CF, [0x81, 0x0C, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71]};
+enum IID IID_IAccessibleHandler = {0x03022430, 0xABC4, 0x11D0, [0xBD, 0xE2, 0x00, 0xAA, 0x00, 0x1A, 0x19, 0x53]};
+enum IID IID_IAccessor = {0x0C733A8C, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IAccIdentity = {0x7852B78D, 0x1CFD, 0x41C1, [0xA6, 0x15, 0x9C, 0x0C, 0x85, 0x96, 0x0B, 0x5F]};
+enum IID IID_IAccountDiscovery = {0xFA202BBC, 0x6ABE, 0x4C17, [0xB1, 0x84, 0x57, 0x0B, 0x6C, 0xF2, 0x56, 0xA6]};
+enum IID IID_IAccPropServer = {0x76C0DBBB, 0x15E0, 0x4E7B, [0xB6, 0x1B, 0x20, 0xEE, 0xEA, 0x20, 0x01, 0xE0]};
+enum IID IID_IAccPropServices = {0x6E26E776, 0x04F0, 0x495D, [0x80, 0xE4, 0x33, 0x30, 0x35, 0x2E, 0x31, 0x69]};
+enum IID IID_IACList = {0x77A130B0, 0x94FD, 0x11D0, [0xA5, 0x44, 0x00, 0xC0, 0x4F, 0xD7, 0xD0, 0x62]};
+enum IID IID_IACList2 = {0x470141A0, 0x5186, 0x11D2, [0xBB, 0xB6, 0x00, 0x60, 0x97, 0x7B, 0x46, 0x4C]};
+enum IID IID_IActionProgress = {0x49FF1173, 0xEADC, 0x446D, [0x92, 0x85, 0x15, 0x64, 0x53, 0xA6, 0x43, 0x1C]};
+enum IID IID_IActionProgressDialog = {0x49FF1172, 0xEADC, 0x446D, [0x92, 0x85, 0x15, 0x64, 0x53, 0xA6, 0x43, 0x1C]};
+enum IID IID_IActiveDesktop = {0xF490EB00, 0x1240, 0x11D1, [0x98, 0x88, 0x00, 0x60, 0x97, 0xDE, 0xAC, 0xF9]};
+enum IID IID_IActiveIME = {0x6FE20962, 0xD077, 0x11D0, [0x8F, 0xE7, 0x00, 0xAA, 0x00, 0x6B, 0xCC, 0x59]};
+enum IID IID_IActiveIME2 = {0xE1C4BF0E, 0x2D53, 0x11D2, [0x93, 0xE1, 0x00, 0x60, 0xB0, 0x67, 0xB8, 0x6E]};
+enum IID IID_IActiveIMMApp = {0x08C0E040, 0x62D1, 0x11D1, [0x93, 0x26, 0x00, 0x60, 0xB0, 0x67, 0xB8, 0x6E]};
+enum IID IID_IActiveIMMIME = {0x08C03411, 0xF96B, 0x11D0, [0xA4, 0x75, 0x00, 0xAA, 0x00, 0x6B, 0xCC, 0x59]};
+enum IID IID_IActiveIMMMessagePumpOwner = {0xB5CF2CFA, 0x8AEB, 0x11D1, [0x93, 0x64, 0x00, 0x60, 0xB0, 0x67, 0xB8, 0x6E]};
+enum IID IID_IActiveIMMRegistrar = {0xB3458082, 0xBD00, 0x11D1, [0x93, 0x9B, 0x00, 0x60, 0xB0, 0x67, 0xB8, 0x6E]};
+enum IID IID_IActiveScript = {0xBB1A2AE1, 0xA4F9, 0x11CF, [0x8F, 0x20, 0x00, 0x80, 0x5F, 0x2C, 0xD0, 0x64]};
+enum IID IID_IActiveScriptAuthor = {0x9C109DA0, 0x7006, 0x11D1, [0xB3, 0x6C, 0x00, 0xA0, 0xC9, 0x11, 0xE8, 0xB2]};
+enum IID IID_IActiveScriptAuthorProcedure = {0x7E2D4B70, 0xBD9A, 0x11D0, [0x93, 0x36, 0x00, 0xA0, 0xC9, 0x0D, 0xCA, 0xA9]};
+enum IID IID_IActiveScriptDebug = {0x51973C10, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IActiveScriptDebug32 = {0x51973C10, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IActiveScriptDebug64 = {0xBC437E23, 0xF5B8, 0x47F4, [0xBB, 0x79, 0x7D, 0x1C, 0xE5, 0x48, 0x3B, 0x86]};
+enum IID IID_IActiveScriptEncode = {0xBB1A2AE3, 0xA4F9, 0x11CF, [0x8F, 0x20, 0x00, 0x80, 0x5F, 0x2C, 0xD0, 0x64]};
+enum IID IID_IActiveScriptError = {0xEAE1BA61, 0xA4ED, 0x11CF, [0x8F, 0x20, 0x00, 0x80, 0x5F, 0x2C, 0xD0, 0x64]};
+enum IID IID_IActiveScriptError64 = {0xB21FB2A1, 0x5B8F, 0x4963, [0x8C, 0x21, 0x21, 0x45, 0x0F, 0x84, 0xED, 0x7F]};
+enum IID IID_IActiveScriptErrorDebug = {0x51973C12, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IActiveScriptGarbageCollector = {0x6AA2C4A0, 0x2B53, 0x11D4, [0xA2, 0xA0, 0x00, 0x10, 0x4B, 0xD3, 0x50, 0x90]};
+enum IID IID_IActiveScriptHostEncode = {0xBEE9B76E, 0xCFE3, 0x11D1, [0xB7, 0x47, 0x00, 0xC0, 0x4F, 0xC2, 0xB0, 0x85]};
+enum IID IID_IActiveScriptParse = {0xBB1A2AE2, 0xA4F9, 0x11CF, [0x8F, 0x20, 0x00, 0x80, 0x5F, 0x2C, 0xD0, 0x64]};
+enum IID IID_IActiveScriptParse32 = {0xBB1A2AE2, 0xA4F9, 0x11CF, [0x8F, 0x20, 0x00, 0x80, 0x5F, 0x2C, 0xD0, 0x64]};
+enum IID IID_IActiveScriptParse64 = {0xC7EF7658, 0xE1EE, 0x480E, [0x97, 0xEA, 0xD5, 0x2C, 0xB4, 0xD7, 0x6D, 0x17]};
+enum IID IID_IActiveScriptParseProcedure = {0xAA5B6A80, 0xB834, 0x11D0, [0x93, 0x2F, 0x00, 0xA0, 0xC9, 0x0D, 0xCA, 0xA9]};
+enum IID IID_IActiveScriptParseProcedure2_32 = {0x71EE5B20, 0xFB04, 0x11D1, [0xB3, 0xA8, 0x00, 0xA0, 0xC9, 0x11, 0xE8, 0xB2]};
+enum IID IID_IActiveScriptParseProcedure2_64 = {0xFE7C4271, 0x210C, 0x448D, [0x9F, 0x54, 0x76, 0xDA, 0xB7, 0x04, 0x7B, 0x28]};
+enum IID IID_IActiveScriptParseProcedure32 = {0xAA5B6A80, 0xB834, 0x11D0, [0x93, 0x2F, 0x00, 0xA0, 0xC9, 0x0D, 0xCA, 0xA9]};
+enum IID IID_IActiveScriptParseProcedure64 = {0xC64713B6, 0xE029, 0x4CC5, [0x92, 0x00, 0x43, 0x8B, 0x72, 0x89, 0x0B, 0x6A]};
+enum IID IID_IActiveScriptParseProcedureOld = {0x1CFF0050, 0x6FDD, 0x11D0, [0x93, 0x28, 0x00, 0xA0, 0xC9, 0x0D, 0xCA, 0xA9]};
+enum IID IID_IActiveScriptParseProcedureOld32 = {0x1CFF0050, 0x6FDD, 0x11D0, [0x93, 0x28, 0x00, 0xA0, 0xC9, 0x0D, 0xCA, 0xA9]};
+enum IID IID_IActiveScriptParseProcedureOld64 = {0x21F57128, 0x08C9, 0x4638, [0xBA, 0x12, 0x22, 0xD1, 0x5D, 0x88, 0xDC, 0x5C]};
+enum IID IID_IActiveScriptProperty = {0x4954E0D0, 0xFBC7, 0x11D1, [0x84, 0x10, 0x00, 0x60, 0x08, 0xC3, 0xFB, 0xFC]};
+enum IID IID_IActiveScriptSIPInfo = {0x764651D0, 0x38DE, 0x11D4, [0xA2, 0xA3, 0x00, 0x10, 0x4B, 0xD3, 0x50, 0x90]};
+enum IID IID_IActiveScriptSite = {0xDB01A1E3, 0xA42B, 0x11CF, [0x8F, 0x20, 0x00, 0x80, 0x5F, 0x2C, 0xD0, 0x64]};
+enum IID IID_IActiveScriptSiteDebug32 = {0x51973C11, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IActiveScriptSiteDebug64 = {0xD6B96B0A, 0x7463, 0x402C, [0x92, 0xAC, 0x89, 0x98, 0x42, 0x26, 0x94, 0x2F]};
+enum IID IID_IActiveScriptSiteInterruptPoll = {0x539698A0, 0xCDCA, 0x11CF, [0xA5, 0xEB, 0x00, 0xAA, 0x00, 0x47, 0xA0, 0x63]};
+enum IID IID_IActiveScriptSiteWindow = {0xD10F6761, 0x83E9, 0x11CF, [0x8F, 0x20, 0x00, 0x80, 0x5F, 0x2C, 0xD0, 0x64]};
+enum IID IID_IActiveScriptStats = {0xB8DA6310, 0xE19B, 0x11D0, [0x93, 0x3C, 0x00, 0xA0, 0xC9, 0x0D, 0xCA, 0xA9]};
+enum IID IID_IActiveXSafetyProvider = {0x69FF5101, 0xFC63, 0x11D0, [0x97, 0xEB, 0x00, 0xAA, 0x00, 0x61, 0x53, 0x33]};
+enum IID IID_IAdapterInfo = {0x480BF94A, 0x09FD, 0x4F8A, [0xA3, 0xE0, 0xB0, 0x70, 0x02, 0x82, 0xD8, 0x4D]};
+enum IID IID_IAdapterNotificationSink = {0x44AB2DC3, 0x23B2, 0x47DE, [0x82, 0x28, 0x2E, 0x1C, 0xCE, 0xEB, 0x99, 0x11]};
+enum IID IID_IAddEvents = {0xD710A6AE, 0x3371, 0x11D1, [0xBE, 0x5B, 0x00, 0xC0, 0x4F, 0xC9, 0xE2, 0xBB]};
+enum IID IID_IAddressBarParser = {0xC9D81948, 0x443A, 0x40C7, [0x94, 0x5C, 0x5E, 0x17, 0x1B, 0x8C, 0x66, 0xB4]};
+enum IID IID_IAddrExclusionControl = {0x00000148, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IAddrTrackingControl = {0x00000147, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IADs = {0xFD8256D0, 0xFD15, 0x11CE, [0xAB, 0xC4, 0x02, 0x60, 0x8C, 0x9E, 0x75, 0x53]};
+enum IID IID_IADsAccessControlEntry = {0xB4F3A14C, 0x9BDD, 0x11D0, [0x85, 0x2C, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IADsAccessControlList = {0xB7EE91CC, 0x9BDD, 0x11D0, [0x85, 0x2C, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IADsAcePrivate = {0xFD145DF2, 0xFD96, 0x4135, [0x9B, 0x22, 0x68, 0xFF, 0x0F, 0x6B, 0xF5, 0xBB]};
+enum IID IID_IADsAcl = {0x8452D3AB, 0x0869, 0x11D1, [0xA3, 0x77, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsADSystemInfo = {0x5BB11929, 0xAFD1, 0x11D2, [0x9C, 0xB9, 0x00, 0x00, 0xF8, 0x7A, 0x36, 0x9E]};
+enum IID IID_IADsBackLink = {0xFD1302BD, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsCaseIgnoreList = {0x7B66B533, 0x4680, 0x11D1, [0xA3, 0xB4, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsClass = {0xC8F93DD0, 0x4AE0, 0x11CF, [0x9E, 0x73, 0x00, 0xAA, 0x00, 0x4A, 0x56, 0x91]};
+enum IID IID_IADsCollection = {0x72B945E0, 0x253B, 0x11CF, [0xA9, 0x88, 0x00, 0xAA, 0x00, 0x6B, 0xC1, 0x49]};
+enum IID IID_IADsComputer = {0xEFE3CC70, 0x1D9F, 0x11CF, [0xB1, 0xF3, 0x02, 0x60, 0x8C, 0x9E, 0x75, 0x53]};
+enum IID IID_IADsComputerOperations = {0xEF497680, 0x1D9F, 0x11CF, [0xB1, 0xF3, 0x02, 0x60, 0x8C, 0x9E, 0x75, 0x53]};
+enum IID IID_IADsContainer = {0x001677D0, 0xFD16, 0x11CE, [0xAB, 0xC4, 0x02, 0x60, 0x8C, 0x9E, 0x75, 0x53]};
+enum IID IID_IADsDeleteOps = {0xB2BD0902, 0x8878, 0x11D1, [0x8C, 0x21, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IADsDNWithBinary = {0x7E99C0A2, 0xF935, 0x11D2, [0xBA, 0x96, 0x00, 0xC0, 0x4F, 0xB6, 0xD0, 0xD1]};
+enum IID IID_IADsDNWithString = {0x370DF02E, 0xF934, 0x11D2, [0xBA, 0x96, 0x00, 0xC0, 0x4F, 0xB6, 0xD0, 0xD1]};
+enum IID IID_IADsDomain = {0x00E4C220, 0xFD16, 0x11CE, [0xAB, 0xC4, 0x02, 0x60, 0x8C, 0x9E, 0x75, 0x53]};
+enum IID IID_IADsEmail = {0x97AF011A, 0x478E, 0x11D1, [0xA3, 0xB4, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsExtension = {0x3D35553C, 0xD2B0, 0x11D1, [0xB1, 0x7B, 0x00, 0x00, 0xF8, 0x75, 0x93, 0xA0]};
+enum IID IID_IADsFaxNumber = {0xA910DEA9, 0x4680, 0x11D1, [0xA3, 0xB4, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsFileService = {0xA89D1900, 0x31CA, 0x11CF, [0xA9, 0x8A, 0x00, 0xAA, 0x00, 0x6B, 0xC1, 0x49]};
+enum IID IID_IADsFileServiceOperations = {0xA02DED10, 0x31CA, 0x11CF, [0xA9, 0x8A, 0x00, 0xAA, 0x00, 0x6B, 0xC1, 0x49]};
+enum IID IID_IADsFileShare = {0xEB6DCAF0, 0x4B83, 0x11CF, [0xA9, 0x95, 0x00, 0xAA, 0x00, 0x6B, 0xC1, 0x49]};
+enum IID IID_IADsGroup = {0x27636B00, 0x410F, 0x11CF, [0xB1, 0xFF, 0x02, 0x60, 0x8C, 0x9E, 0x75, 0x53]};
+enum IID IID_IADsHold = {0xB3EB3B37, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsLargeInteger = {0x9068270B, 0x0939, 0x11D1, [0x8B, 0xE1, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IADsLocality = {0xA05E03A2, 0xEFFE, 0x11CF, [0x8A, 0xBC, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IADsMembers = {0x451A0030, 0x72EC, 0x11CF, [0xB0, 0x3B, 0x00, 0xAA, 0x00, 0x6E, 0x09, 0x75]};
+enum IID IID_IADsNamespaces = {0x28B96BA0, 0xB330, 0x11CF, [0xA9, 0xAD, 0x00, 0xAA, 0x00, 0x6B, 0xC1, 0x49]};
+enum IID IID_IADsNameTranslate = {0xB1B272A3, 0x3625, 0x11D1, [0xA3, 0xA4, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsNetAddress = {0xB21A50A9, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsO = {0xA1CD2DC6, 0xEFFE, 0x11CF, [0x8A, 0xBC, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IADsObjectOptions = {0x46F14FDA, 0x232B, 0x11D1, [0xA8, 0x08, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0xA8]};
+enum IID IID_IADsObjOptPrivate = {0x81CBB829, 0x1867, 0x11D2, [0x92, 0x20, 0x00, 0xC0, 0x4F, 0xB6, 0xD0, 0xD1]};
+enum IID IID_IADsOctetList = {0x7B28B80F, 0x4680, 0x11D1, [0xA3, 0xB4, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsOpenDSObject = {0xDDF2891E, 0x0F9C, 0x11D0, [0x8A, 0xD4, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IADsOU = {0xA2F733B8, 0xEFFE, 0x11CF, [0x8A, 0xBC, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IADsPath = {0xB287FCD5, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsPathname = {0xD592AED4, 0xF420, 0x11D0, [0xA3, 0x6E, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsPathnameProvider = {0xAACD1D30, 0x8BD0, 0x11D2, [0x92, 0xA9, 0x00, 0xC0, 0x4F, 0x79, 0xF8, 0x34]};
+enum IID IID_IADsPostalAddress = {0x7ADECF29, 0x4680, 0x11D1, [0xA3, 0xB4, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsPrintJob = {0x32FB6780, 0x1ED0, 0x11CF, [0xA9, 0x88, 0x00, 0xAA, 0x00, 0x6B, 0xC1, 0x49]};
+enum IID IID_IADsPrintJobOperations = {0x9A52DB30, 0x1ECF, 0x11CF, [0xA9, 0x88, 0x00, 0xAA, 0x00, 0x6B, 0xC1, 0x49]};
+enum IID IID_IADsPrintQueue = {0xB15160D0, 0x1226, 0x11CF, [0xA9, 0x85, 0x00, 0xAA, 0x00, 0x6B, 0xC1, 0x49]};
+enum IID IID_IADsPrintQueueOperations = {0x124BE5C0, 0x156E, 0x11CF, [0xA9, 0x86, 0x00, 0xAA, 0x00, 0x6B, 0xC1, 0x49]};
+enum IID IID_IADsProperty = {0xC8F93DD3, 0x4AE0, 0x11CF, [0x9E, 0x73, 0x00, 0xAA, 0x00, 0x4A, 0x56, 0x91]};
+enum IID IID_IADsPropertyEntry = {0x05792C8E, 0x941F, 0x11D0, [0x85, 0x29, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IADsPropertyList = {0xC6F602B6, 0x8F69, 0x11D0, [0x85, 0x28, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IADsPropertyValue = {0x79FA9AD0, 0xA97C, 0x11D0, [0x85, 0x34, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IADsPropertyValue2 = {0x306E831C, 0x5BC7, 0x11D1, [0xA3, 0xB8, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsReplicaPointer = {0xF60FB803, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsResource = {0x34A05B20, 0x4AAB, 0x11CF, [0xAE, 0x2C, 0x00, 0xAA, 0x00, 0x6E, 0xBF, 0xB9]};
+enum IID IID_IADsSearch = {0xC69F7780, 0x4008, 0x11D0, [0xB9, 0x4C, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0xA8]};
+enum IID IID_IADsSecurityDescriptor = {0xB8C787CA, 0x9BDD, 0x11D0, [0x85, 0x2C, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IADsSecurityUtility = {0xA63251B2, 0x5F21, 0x474B, [0xAB, 0x52, 0x4A, 0x8E, 0xFA, 0xD1, 0x08, 0x95]};
+enum IID IID_IADsService = {0x68AF66E0, 0x31CA, 0x11CF, [0xA9, 0x8A, 0x00, 0xAA, 0x00, 0x6B, 0xC1, 0x49]};
+enum IID IID_IADsServiceOperations = {0x5D7B33F0, 0x31CA, 0x11CF, [0xA9, 0x8A, 0x00, 0xAA, 0x00, 0x6B, 0xC1, 0x49]};
+enum IID IID_IADsSession = {0x398B7DA0, 0x4AAB, 0x11CF, [0xAE, 0x2C, 0x00, 0xAA, 0x00, 0x6E, 0xBF, 0xB9]};
+enum IID IID_IADsSyntax = {0xC8F93DD2, 0x4AE0, 0x11CF, [0x9E, 0x73, 0x00, 0xAA, 0x00, 0x4A, 0x56, 0x91]};
+enum IID IID_IADsTimestamp = {0xB2F5A901, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsTypedName = {0xB371A349, 0x4080, 0x11D1, [0xA3, 0xAC, 0x00, 0xC0, 0x4F, 0xB9, 0x50, 0xDC]};
+enum IID IID_IADsUmiHelperPrivate = {0x4FE243F0, 0xAD89, 0x4CBC, [0x9B, 0x14, 0x48, 0x61, 0x26, 0x44, 0x6A, 0xE0]};
+enum IID IID_IADsUser = {0x3E37E320, 0x17E2, 0x11CF, [0xAB, 0xC4, 0x02, 0x60, 0x8C, 0x9E, 0x75, 0x53]};
+enum IID IID_IADsValue = {0x1E3EF0AA, 0xAEF5, 0x11D0, [0x85, 0x37, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IADsWinNTSystemInfo = {0x6C6D65DC, 0xAFD1, 0x11D2, [0x9C, 0xB9, 0x00, 0x00, 0xF8, 0x7A, 0x36, 0x9E]};
+enum IID IID_IAdviseSink = {0x0000010F, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IAdviseSink2 = {0x00000125, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IAdviseSinkEx = {0x3AF24290, 0x0C96, 0x11CE, [0xA0, 0xCF, 0x00, 0xAA, 0x00, 0x60, 0x0A, 0xB8]};
+enum IID IID_IAlertReport = {0x4E81DFE8, 0x4CA0, 0x101A, [0x82, 0x06, 0x08, 0x00, 0x2B, 0x2F, 0xC0, 0x9B]};
+enum IID IID_IAlertTarget = {0x589B61C0, 0x54E6, 0x11CE, [0x94, 0xDD, 0x00, 0xAA, 0x00, 0x51, 0xE4, 0x0F]};
+enum IID IID_IAlgSetup = {0xA779AF1A, 0x009A, 0x4C44, [0xB9, 0xF0, 0x8F, 0x0F, 0x4C, 0xF2, 0xAE, 0x49]};
+enum IID IID_IAlterIndex = {0x0C733AA6, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IAlterTable = {0x0C733AA5, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IAnchorClick = {0x13D5413B, 0x33B9, 0x11D2, [0x95, 0xA7, 0x00, 0xC0, 0x4F, 0x8E, 0xCB, 0x02]};
+enum IID IID_IAnimationComposer = {0x5459C83D, 0x322B, 0x44B3, [0x8D, 0xAA, 0x24, 0xC9, 0x47, 0xE7, 0xB2, 0x75]};
+enum IID IID_IAnimationComposer2 = {0x1A4F0E79, 0x09CD, 0x47F3, [0xAF, 0xF1, 0x48, 0x3B, 0xF3, 0xA2, 0x22, 0xDC]};
+enum IID IID_IAnimationComposerFactory = {0xBEEB3233, 0xF71F, 0x4683, [0x8B, 0x05, 0x9A, 0x53, 0x14, 0xC9, 0x7D, 0xBC]};
+enum IID IID_IAnimationComposerSite = {0x488FCB56, 0x8FD6, 0x4CDA, [0xA0, 0x6A, 0x5B, 0xB2, 0x32, 0x93, 0x0E, 0xCA]};
+enum IID IID_IAnimationComposerSiteFactory = {0xB4EA5681, 0xED72, 0x4EFE, [0xBB, 0xD7, 0x7C, 0x47, 0xD1, 0x32, 0x56, 0x96]};
+enum IID IID_IAnimationComposerSiteSink = {0x8EF76C64, 0x71CD, 0x480F, [0x96, 0xFC, 0xBA, 0x26, 0x96, 0xE6, 0x59, 0xBE]};
+enum IID IID_IAnimationFragment = {0x319DFD88, 0x0AC6, 0x4AB1, [0xA1, 0x9F, 0x90, 0x22, 0x3B, 0xA2, 0xDA, 0x16]};
+enum IID IID_IAnimationRoot = {0x29DF6387, 0x30B4, 0x4A62, [0x89, 0x1B, 0xA9, 0xC5, 0xBE, 0x37, 0xBE, 0x88]};
+enum IID IID_IApplicationDebugger = {0x51973C2A, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IApplicationDebuggerUI = {0x51973C2B, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IApplicationGateway = {0x5134842B, 0xFDCE, 0x485D, [0x93, 0xCD, 0xDE, 0x16, 0x40, 0x64, 0x3B, 0xBE]};
+enum IID IID_IApplicationGatewayServices = {0x5134842A, 0xFDCE, 0x485D, [0x93, 0xCD, 0xDE, 0x16, 0x40, 0x64, 0x3B, 0xBE]};
+enum IID IID_IAppPublisher = {0x07250A10, 0x9CF9, 0x11D1, [0x90, 0x76, 0x00, 0x60, 0x08, 0x05, 0x93, 0x82]};
+enum IID IID_IAsyncBindCtx = {0x79EAC9D4, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IAsyncManager = {0x0000002A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IAsyncMoniker = {0x79EAC9D3, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IAsyncOperation = {0x3D8B0590, 0xF691, 0x11D2, [0x8E, 0xA9, 0x00, 0x60, 0x97, 0xDF, 0x5B, 0xD4]};
+enum IID IID_IAsyncRpcChannelBuffer = {0xA5029FB6, 0x3C34, 0x11D1, [0x9C, 0x99, 0x00, 0xC0, 0x4F, 0xB9, 0x98, 0xAA]};
+enum IID IID_IAttributesRaw = {0x6BC096A8, 0x0CE6, 0x11D1, [0xBA, 0xAE, 0x00, 0xC0, 0x4F, 0xC2, 0xE2, 0x0D]};
+enum IID IID_IAuditControl = {0x1DA6292F, 0xBC66, 0x11CE, [0xAA, 0xE3, 0x00, 0xAA, 0x00, 0x4C, 0x27, 0x37]};
+enum IID IID_IAuthenticate = {0x79EAC9D0, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IAutoComplete = {0x00BB2762, 0x6A77, 0x11D0, [0xA5, 0x35, 0x00, 0xC0, 0x4F, 0xD7, 0xD0, 0x62]};
+enum IID IID_IAutoComplete2 = {0xEAC04BC0, 0x3791, 0x11D2, [0xBB, 0x95, 0x00, 0x60, 0x97, 0x7B, 0x46, 0x4C]};
+enum IID IID_IAutoCompleteDropDown = {0x3CD141F4, 0x3C6A, 0x11D2, [0xBC, 0xAA, 0x00, 0xC0, 0x4F, 0xD9, 0x29, 0xDB]};
+enum IID IID_IAutoCompList = {0x00BB2760, 0x6A77, 0x11D0, [0xA5, 0x35, 0x00, 0xC0, 0x4F, 0xD7, 0xD0, 0x62]};
+enum IID IID_IAutoDiscoveryProvider = {0x9DCF4A37, 0x01DE, 0x4549, [0xA9, 0xCB, 0x3A, 0xC3, 0x1E, 0xC2, 0x3C, 0x4F]};
+enum IID IID_IBackgroundCopyCallback = {0x97EA99C7, 0x0186, 0x4AD4, [0x8D, 0xF9, 0xC5, 0xB4, 0xE0, 0xED, 0x6B, 0x22]};
+enum IID IID_IBackgroundCopyCallback1 = {0x084F6593, 0x3800, 0x4E08, [0x9B, 0x59, 0x99, 0xFA, 0x59, 0xAD, 0xDF, 0x82]};
+enum IID IID_IBackgroundCopyError = {0x19C613A0, 0xFCB8, 0x4F28, [0x81, 0xAE, 0x89, 0x7C, 0x3D, 0x07, 0x8F, 0x81]};
+enum IID IID_IBackgroundCopyFile = {0x01B7BD23, 0xFB88, 0x4A77, [0x84, 0x90, 0x58, 0x91, 0xD3, 0xE4, 0x65, 0x3A]};
+enum IID IID_IBackgroundCopyGroup = {0x1DED80A7, 0x53EA, 0x424F, [0x8A, 0x04, 0x17, 0xFE, 0xA9, 0xAD, 0xC4, 0xF5]};
+enum IID IID_IBackgroundCopyJob = {0x37668D37, 0x507E, 0x4160, [0x93, 0x16, 0x26, 0x30, 0x6D, 0x15, 0x0B, 0x12]};
+enum IID IID_IBackgroundCopyJob1 = {0x59F5553C, 0x2031, 0x4629, [0xBB, 0x18, 0x26, 0x45, 0xA6, 0x97, 0x09, 0x47]};
+enum IID IID_IBackgroundCopyJob2 = {0x54B50739, 0x686F, 0x45EB, [0x9D, 0xFF, 0xD6, 0xA9, 0xA0, 0xFA, 0xA9, 0xAF]};
+enum IID IID_IBackgroundCopyManager = {0x5CE34C0D, 0x0DC9, 0x4C1F, [0x89, 0x7C, 0xDA, 0xA1, 0xB7, 0x8C, 0xEE, 0x7C]};
+enum IID IID_IBackgroundCopyQMgr = {0x16F41C69, 0x09F5, 0x41D2, [0x8C, 0xD8, 0x3C, 0x08, 0xC4, 0x7B, 0xC8, 0xA8]};
+enum IID IID_IBidiRequestSpl = {0x9C007000, 0xFFA8, 0x44FF, [0xB2, 0xB3, 0xAE, 0x91, 0x02, 0xC7, 0x4D, 0x4C]};
+enum IID IID_IBindCtx = {0x0000000E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IBindEventHandler = {0x63CDBCB0, 0xC1B1, 0x11D0, [0x93, 0x36, 0x00, 0xA0, 0xC9, 0x0D, 0xCA, 0xA9]};
+enum IID IID_IBindHost = {0xFC4801A1, 0x2BA9, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID IID_IBinding = {0x79EAC9C0, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IBindProtocol = {0x79EAC9CD, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IBindResource = {0x0C733AB1, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IBindStatusCallback = {0x79EAC9C1, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IBindStatusCallbackHolder = {0x79EAC9CC, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IBindStatusCallbackMsg = {0x79EAC9D5, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IBitsTest1 = {0x51A183DB, 0x67E0, 0x4472, [0x86, 0x02, 0x3D, 0xBC, 0x73, 0x0B, 0x7E, 0xF5]};
+enum IID IID_IBlockFormats = {0x3050F830, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IBlockingLock = {0x30F3D47A, 0x6447, 0x11D1, [0x8E, 0x3C, 0x00, 0xC0, 0x4F, 0xB9, 0x38, 0x6D]};
+enum IID IID_IBoundObject = {0x9BFBBC00, 0xEFF1, 0x101A, [0x84, 0xED, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IBoundObjectSite = {0x9BFBBC01, 0xEFF1, 0x101A, [0x84, 0xED, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IBriefcaseStg = {0x8BCE1FA1, 0x0921, 0x101B, [0xB1, 0xFF, 0x00, 0xDD, 0x01, 0x0C, 0xCC, 0x48]};
+enum IID IID_IBurnEngine = {0x520CCA66, 0x51A5, 0x11D3, [0x91, 0x44, 0x00, 0x10, 0x4B, 0xA1, 0x1C, 0x5E]};
+enum IID IID_ICallFactory = {0x1C733A30, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICallFrame = {0xD573B4B0, 0x894E, 0x11D2, [0xB8, 0xB6, 0x00, 0xC0, 0x4F, 0xB9, 0x61, 0x8A]};
+enum IID IID_ICallFrameEvents = {0xFD5E0843, 0xFC91, 0x11D0, [0x97, 0xD7, 0x00, 0xC0, 0x4F, 0xB9, 0x61, 0x8A]};
+enum IID IID_ICallFrameWalker = {0x08B23919, 0x392D, 0x11D2, [0xB8, 0xA4, 0x00, 0xC0, 0x4F, 0xB9, 0x61, 0x8A]};
+enum IID IID_ICallIndirect = {0xD573B4B1, 0x894E, 0x11D2, [0xB8, 0xB6, 0x00, 0xC0, 0x4F, 0xB9, 0x61, 0x8A]};
+enum IID IID_ICallInterceptor = {0x60C7CA75, 0x896D, 0x11D2, [0xB8, 0xB6, 0x00, 0xC0, 0x4F, 0xB9, 0x61, 0x8A]};
+enum IID IID_ICallUnmarshal = {0x5333B003, 0x2E42, 0x11D2, [0xB8, 0x9D, 0x00, 0xC0, 0x4F, 0xB9, 0x61, 0x8A]};
+enum IID IID_ICancelMethodCalls = {0x00000029, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ICatalogFileInfo = {0x711C7600, 0x6B48, 0x11D1, [0xB4, 0x03, 0x00, 0xAA, 0x00, 0xB9, 0x2A, 0xF1]};
+enum IID IID_ICategorizer = {0xA3B14589, 0x9174, 0x49A8, [0x89, 0xA3, 0x06, 0xA1, 0xAE, 0x2B, 0x9B, 0xA7]};
+enum IID IID_ICategoryProvider = {0x9AF64809, 0x5864, 0x4C26, [0xA7, 0x20, 0xC1, 0xF7, 0x8C, 0x08, 0x6E, 0xE3]};
+enum IID IID_ICatInformation = {0x0002E013, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ICatRegister = {0x0002E012, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ICDBurn = {0x3D73A659, 0xE5D0, 0x4D42, [0xAF, 0xC0, 0x51, 0x21, 0xBA, 0x42, 0x5C, 0x8D]};
+enum IID IID_ICEnroll = {0x43F8F288, 0x7A20, 0x11D0, [0x8F, 0x06, 0x00, 0xC0, 0x4F, 0xC2, 0x95, 0xE1]};
+enum IID IID_ICEnroll2 = {0x704CA730, 0xC90B, 0x11D1, [0x9B, 0xEC, 0x00, 0xC0, 0x4F, 0xC2, 0x95, 0xE1]};
+enum IID IID_ICEnroll3 = {0xC28C2D95, 0xB7DE, 0x11D2, [0xA4, 0x21, 0x00, 0xC0, 0x4F, 0x79, 0xFE, 0x8E]};
+enum IID IID_ICEnroll4 = {0xC1F1188A, 0x2EB5, 0x4A80, [0x84, 0x1B, 0x7E, 0x72, 0x9A, 0x35, 0x6D, 0x90]};
+enum IID IID_IChannelHook = {0x1008C4A0, 0x7613, 0x11CF, [0x9A, 0xF1, 0x00, 0x20, 0xAF, 0x6E, 0x72, 0xF4]};
+enum IID IID_IChannelMgr = {0x85BD8E82, 0x0FBA, 0x11D1, [0x90, 0xC3, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x68]};
+enum IID IID_IChapteredRowset = {0x0C733A93, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICheckBox = {0x3050F685, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ICiAdmin = {0xAE67C7D8, 0x85D3, 0x11D0, [0x8C, 0x45, 0x00, 0xC0, 0x4F, 0xC2, 0xDB, 0x8D]};
+enum IID IID_ICiAdminParams = {0xA82D48C6, 0x3F0F, 0x11D0, [0x8C, 0x91, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCAdviseStatus = {0xCA05734A, 0x1218, 0x11D3, [0xAE, 0x7A, 0x00, 0xC0, 0x4F, 0x72, 0xF8, 0x31]};
+enum IID IID_ICiCDeferredPropRetriever = {0xC273AF70, 0x6D72, 0x11D0, [0x8D, 0x64, 0x00, 0xA0, 0xC9, 0x08, 0xDB, 0xF1]};
+enum IID IID_ICiCDocName = {0x76615076, 0x3C2B, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCDocNameToWorkidTranslator = {0x25FC3F54, 0x3CB4, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCDocNameToWorkidTranslatorEx = {0x7BBA76E6, 0xA0E3, 0x11D2, [0xBC, 0x5D, 0x00, 0xC0, 0x4F, 0xA3, 0x54, 0xBA]};
+enum IID IID_ICiCDocStore = {0x46625468, 0x3C32, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCDocStoreEx = {0xF98282A7, 0xFA72, 0x11D1, [0x97, 0x98, 0x00, 0xC0, 0x4F, 0xC2, 0xF4, 0x10]};
+enum IID IID_ICiCDocStoreLocator = {0x97EE7C06, 0x5908, 0x11D0, [0x8C, 0x9B, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCEventLogItem = {0x44CC886A, 0x4314, 0x11D0, [0x8C, 0x91, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCFilterClient = {0xA1E0BCB6, 0x3C24, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCFilterStatus = {0xBC5F3D60, 0x8BBC, 0x11D1, [0x8F, 0x73, 0x00, 0xA0, 0xC9, 0x19, 0x17, 0xF5]};
+enum IID IID_ICiCIndexNotificationStatus = {0x5FFF3840, 0x8E76, 0x11D0, [0x8D, 0x69, 0x00, 0xA0, 0xC9, 0x08, 0xDB, 0xF1]};
+enum IID IID_ICiCLangRes = {0x914C2E6C, 0x43FE, 0x11D0, [0x8C, 0x91, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiControl = {0x63DEB7F4, 0x3CCB, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCOpenedDoc = {0x151EDFBE, 0x3C2F, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCPropertyStorage = {0x4C46225A, 0x3CB5, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCPropRetriever = {0x77D9B2DA, 0x4401, 0x11D0, [0x8C, 0x91, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCQueryNotification = {0x0A9E9F6C, 0x3CE2, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCQuerySession = {0xAE461FD6, 0x4E1D, 0x11D0, [0x8C, 0x94, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCResourceMonitor = {0xF700FF8E, 0x20EE, 0x11D2, [0x80, 0xF7, 0x00, 0xC0, 0x4F, 0xA3, 0x54, 0xBA]};
+enum IID IID_ICiCScope = {0x1021C882, 0x3CC0, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCScopeChecker = {0x7D820C9C, 0x3CBC, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCScopeEnumerator = {0xCF8505EA, 0x3CCA, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCSecurityChecker = {0xCA130CF4, 0x3CC2, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiCUserSecurity = {0x5D01D9CE, 0x3CC2, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiDocChangeNotifySink = {0x8BFA1386, 0x3CE5, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiEnumWorkids = {0x77900150, 0xA09C, 0x11D0, [0xA8, 0x0D, 0x00, 0xA0, 0xC9, 0x06, 0x24, 0x1A]};
+enum IID IID_ICiFrameworkQuery = {0xAE67C7D9, 0x85D3, 0x11D0, [0x8C, 0x45, 0x00, 0xC0, 0x4F, 0xC2, 0xDB, 0x8D]};
+enum IID IID_ICiIndexNotification = {0x4F2CD6E0, 0x8E74, 0x11D0, [0x8D, 0x69, 0x00, 0xA0, 0xC9, 0x08, 0xDB, 0xF1]};
+enum IID IID_ICiIndexNotificationEntry = {0x210769D0, 0x8E75, 0x11D0, [0x8D, 0x69, 0x00, 0xA0, 0xC9, 0x08, 0xDB, 0xF1]};
+enum IID IID_ICiISearchCreator = {0x7DC07FA0, 0x902E, 0x11D0, [0xA8, 0x0C, 0x00, 0xA0, 0xC9, 0x06, 0x24, 0x1A]};
+enum IID IID_ICiManager = {0xCF0FCF56, 0x3CCE, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiPersistIncrFile = {0x31B311E2, 0x4498, 0x11D0, [0x8C, 0x91, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_ICiQueryPropertyMapper = {0xD2333EB0, 0x756B, 0x11D0, [0x8D, 0x66, 0x00, 0xA0, 0xC9, 0x08, 0xDB, 0xF1]};
+enum IID IID_ICiStartup = {0x68232CB8, 0x3CCC, 0x11D0, [0x8C, 0x90, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_IClassActivator = {0x00000140, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IClassFactory2 = {0xB196B28F, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IClassFactoryEx = {0x342D1EA0, 0xAE25, 0x11D1, [0x89, 0xC5, 0x00, 0x60, 0x08, 0xC3, 0xFB, 0xFC]};
+enum IID IID_IClientCaps = {0x7E8BC44D, 0xAEFF, 0x11D1, [0x89, 0xC2, 0x00, 0xC0, 0x4F, 0xB6, 0xBF, 0xC4]};
+enum IID IID_IClientSecurity = {0x0000013D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IClusCfgAsyncEvictCleanup = {0x52C80B95, 0xC1AD, 0x4240, [0x8D, 0x89, 0x72, 0xE9, 0xFA, 0x84, 0x02, 0x5E]};
+enum IID IID_IClusCfgBaseCluster = {0xA8A5C613, 0x2518, 0x47F5, [0x96, 0xCA, 0xCA, 0xFA, 0x7F, 0xFB, 0xAF, 0x68]};
+enum IID IID_IClusCfgCallback = {0x238DCA63, 0xE2EF, 0x4F32, [0xA2, 0x4D, 0xAC, 0xBF, 0x97, 0x5B, 0xE8, 0x42]};
+enum IID IID_IClusCfgCapabilities = {0xD94AB253, 0x36C7, 0x41C1, [0xB5, 0x2E, 0x26, 0xB4, 0x51, 0x97, 0x5C, 0x8D]};
+enum IID IID_IClusCfgClusterConnection = {0xCE6EF90C, 0x3602, 0x41E7, [0x95, 0xBD, 0xAA, 0xFD, 0x37, 0xA6, 0x76, 0xDF]};
+enum IID IID_IClusCfgClusterInfo = {0x85B4BBC0, 0xDDC4, 0x4AE7, [0x82, 0x68, 0xF4, 0x85, 0x0B, 0xB2, 0xA6, 0xEE]};
+enum IID IID_IClusCfgCredentials = {0x54AA9406, 0xA409, 0x4B49, [0xB3, 0x14, 0x5F, 0x0A, 0x0C, 0xE4, 0xC8, 0x8E]};
+enum IID IID_IClusCfgEvictCleanup = {0x6FE3E361, 0xD373, 0x4C5F, [0xA0, 0xAF, 0x1D, 0xFE, 0x84, 0x93, 0xC6, 0x55]};
+enum IID IID_IClusCfgGroupCfg = {0xDCB6D3D2, 0xA55F, 0x49E5, [0xA6, 0x4A, 0x0C, 0xCF, 0xEB, 0x01, 0xED, 0x3A]};
+enum IID IID_IClusCfgInitialize = {0x2A0EB82D, 0xF878, 0x492A, [0x95, 0x1E, 0xAE, 0x00, 0x09, 0x18, 0xC4, 0xA6]};
+enum IID IID_IClusCfgIPAddressInfo = {0xAAEAF0A5, 0xE310, 0x4604, [0xA5, 0x5E, 0x2F, 0x9D, 0xDC, 0x41, 0x57, 0xA8]};
+enum IID IID_IClusCfgManagedResourceCfg = {0x60300A0F, 0x77E1, 0x440C, [0xBD, 0x94, 0x6B, 0xFB, 0x0D, 0xBF, 0xDB, 0x3A]};
+enum IID IID_IClusCfgManagedResourceInfo = {0xE0324847, 0x1520, 0x41B0, [0xB9, 0x60, 0x54, 0x19, 0x8D, 0xA5, 0xF8, 0xAF]};
+enum IID IID_IClusCfgMemberSetChangeListener = {0x2B64534F, 0x2643, 0x4ABC, [0xA4, 0xE5, 0x82, 0x4D, 0x88, 0x1B, 0x75, 0x82]};
+enum IID IID_IClusCfgNetworkInfo = {0x19FC7580, 0x950A, 0x44A6, [0x96, 0x6E, 0x74, 0xB1, 0x4B, 0x20, 0x91, 0x8F]};
+enum IID IID_IClusCfgNodeInfo = {0xE4B5FA15, 0xDD07, 0x439E, [0xA6, 0x23, 0x88, 0x23, 0x52, 0x4E, 0x3D, 0x19]};
+enum IID IID_IClusCfgPartitionInfo = {0xEC1EBD9F, 0x5866, 0x4846, [0x89, 0x52, 0xEC, 0x36, 0xC3, 0x96, 0x1E, 0xEE]};
+enum IID IID_IClusCfgPollingCallback = {0xC72DB1FD, 0x51A2, 0x43E6, [0xB7, 0x08, 0xD9, 0xDB, 0x7D, 0xA7, 0x96, 0x30]};
+enum IID IID_IClusCfgPollingCallbackInfo = {0x2AF55DA7, 0xCB6F, 0x40DE, [0xBB, 0x11, 0x66, 0x73, 0x46, 0x4B, 0x2C, 0x54]};
+enum IID IID_IClusCfgResourceCreate = {0x0647B41A, 0xC777, 0x443C, [0x94, 0x32, 0x02, 0xCC, 0xCF, 0x4F, 0xF4, 0x43]};
+enum IID IID_IClusCfgResourcePostCreate = {0x72A9BF54, 0x13B6, 0x451F, [0x91, 0x0D, 0x69, 0x13, 0xEB, 0xF0, 0x25, 0xAB]};
+enum IID IID_IClusCfgResourcePreCreate = {0x4240F6A1, 0x9D49, 0x427E, [0x8F, 0x3D, 0x09, 0x38, 0x4E, 0x1F, 0x59, 0xE4]};
+enum IID IID_IClusCfgResourceTypeCreate = {0x3AFCE3B8, 0x5F3E, 0x4DDF, [0xA8, 0xF4, 0x4B, 0x4F, 0xCB, 0xF2, 0x8F, 0x8F]};
+enum IID IID_IClusCfgResourceTypeInfo = {0xC649A281, 0xC847, 0x4F5C, [0x98, 0x41, 0xD2, 0xF7, 0x3B, 0x5A, 0xA7, 0x1D]};
+enum IID IID_IClusCfgResTypeServicesInitializ = {0x6E109698, 0xDFC4, 0x4471, [0xAC, 0xE1, 0x04, 0x14, 0x93, 0x1B, 0x3B, 0xB3]};
+enum IID IID_IClusCfgServer = {0x4C06EAE6, 0x990E, 0x4051, [0x8A, 0xA1, 0xAD, 0x4B, 0x4E, 0xAE, 0x9C, 0xAF]};
+enum IID IID_IClusCfgSetCredentials = {0x58E6E5B9, 0x4788, 0x4D9A, [0x82, 0x55, 0x1E, 0x27, 0x4E, 0x5D, 0xCC, 0xB0]};
+enum IID IID_IClusCfgStartupListener = {0xD282CAEF, 0x2EDE, 0x4AB9, [0xA5, 0xD5, 0xF7, 0xBD, 0xE3, 0xD2, 0x3F, 0x0F]};
+enum IID IID_IClusCfgStartupNotify = {0xC2B0D069, 0x6353, 0x4EE1, [0xB2, 0x53, 0x6B, 0x0D, 0x75, 0xDB, 0x2C, 0xD3]};
+enum IID IID_IClusCfgVerify = {0xD47BBEEC, 0x2286, 0x4514, [0xAA, 0x90, 0x7E, 0x88, 0xBD, 0x0F, 0xE5, 0x43]};
+enum IID IID_IClusCfgWizard = {0x2EB57A3B, 0xDA8D, 0x4B56, [0x97, 0xCF, 0xA3, 0x19, 0x1B, 0xF8, 0xFD, 0x5B]};
+enum IID IID_IClusterApplicationWizard = {0x24F97151, 0x6689, 0x11D1, [0x9A, 0xA7, 0x00, 0xC0, 0x4F, 0xB9, 0x3A, 0x80]};
+enum IID IID_ICodeInstall = {0x79EAC9D1, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IColumnMapper = {0x0B63E37A, 0x9CCC, 0x11D0, [0xBC, 0xDB, 0x00, 0x80, 0x5F, 0xCC, 0xCE, 0x04]};
+enum IID IID_IColumnMapperCreator = {0x0B63E37B, 0x9CCC, 0x11D0, [0xBC, 0xDB, 0x00, 0x80, 0x5F, 0xCC, 0xCE, 0x04]};
+enum IID IID_IColumnProvider = {0xE8025004, 0x1C42, 0x11D2, [0xBE, 0x2C, 0x00, 0xA0, 0xC9, 0xA8, 0x3D, 0xA1]};
+enum IID IID_IColumnsInfo = {0x0C733A11, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IColumnsInfo2 = {0x0C733AB8, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IColumnsRowset = {0x0C733A10, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICombobox = {0x3050F677, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ICommand = {0x0C733A63, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICommandCost = {0x0C733A4E, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICommandPersist = {0x0C733AA7, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICommandPrepare = {0x0C733A26, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICommandProperties = {0x0C733A79, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICommandStream = {0x0C733ABF, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICommandText = {0x0C733A27, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICommandTree = {0x0C733A87, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICommandValidate = {0x0C733A18, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICommandWithParameters = {0x0C733A64, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICommDlgBrowser = {0x000214F1, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ICommDlgBrowser2 = {0x10339516, 0x2894, 0x11D2, [0x90, 0x39, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x3E]};
+enum IID IID_ICommonQuery = {0xAB50DEC0, 0x6F1D, 0x11D0, [0xA1, 0xC4, 0x00, 0xAA, 0x00, 0xC1, 0x6E, 0x65]};
+enum IID IID_IComThreadingInfo = {0x000001CE, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IConfigurationConnection = {0xDDAD8191, 0x66C5, 0x4A30, [0xA4, 0xDF, 0xCB, 0x6C, 0x21, 0x67, 0x04, 0xCA]};
+enum IID IID_IConnectionInfo = {0x15182CE3, 0x82D7, 0x473F, [0x92, 0xDE, 0x70, 0x6E, 0x2B, 0xCE, 0xA9, 0x02]};
+enum IID IID_IConnectionManager = {0xC0017768, 0x1BF3, 0x4352, [0x8D, 0x6C, 0x3A, 0x8C, 0x1D, 0x0F, 0xB4, 0x77]};
+enum IID IID_IConnectionPoint = {0xB196B286, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IConnectionPointContainer = {0xB196B284, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IContextCallback = {0x000001DA, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IContextMenu = {0x000214E4, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IContextMenu2 = {0x000214F4, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IContextMenu3 = {0xBCFCE0A0, 0xEC17, 0x11D0, [0x8D, 0x10, 0x00, 0xA0, 0xC9, 0x0F, 0x27, 0x19]};
+enum IID IID_IContinue = {0x0000012A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IContinueCallback = {0xB722BCCA, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]};
+enum IID IID_IConvertType = {0x0C733A88, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICrBarn = {0x276A2EE0, 0x0B5D, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID IID_ICrBarn2 = {0xB66A7A1B, 0x8FC6, 0x448C, [0xA2, 0xEB, 0x3C, 0x55, 0x95, 0x74, 0x78, 0xA1]};
+enum IID IID_ICrBlinds = {0x5AF5C340, 0x0BA9, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID IID_ICrBlinds2 = {0x7059D403, 0x599A, 0x4264, [0x81, 0x40, 0x64, 0x1E, 0xB8, 0xAE, 0x1F, 0x64]};
+enum IID IID_ICrBlur = {0x9F7C7827, 0xE87A, 0x11D1, [0x81, 0xE0, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID IID_ICreateErrorInfo = {0x22F03340, 0x547D, 0x101B, [0x8E, 0x65, 0x08, 0x00, 0x2B, 0x2B, 0xD1, 0x19]};
+enum IID IID_ICreateRow = {0x0C733AB2, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ICreateTypeInfo = {0x00020405, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ICreateTypeInfo2 = {0x0002040E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ICreateTypeLib = {0x00020406, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ICreateTypeLib2 = {0x0002040F, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ICrEmboss = {0xE4ACFB80, 0x053E, 0x11D2, [0x81, 0xEA, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID IID_ICrEngrave = {0xE4ACFB7F, 0x053E, 0x11D2, [0x81, 0xEA, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID IID_ICrInset = {0x05C5EE20, 0x0BA6, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID IID_ICrIris = {0x3F69F350, 0x0379, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID IID_ICrIris2 = {0xF7B06961, 0xBA8C, 0x4970, [0x91, 0x8B, 0x1C, 0x60, 0xCB, 0x9F, 0xF1, 0x80]};
+enum IID IID_ICrRadialWipe = {0x424B71AE, 0x0695, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID IID_ICrSlide = {0x810E402E, 0x056B, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID IID_ICrSpiral = {0x0DE527A0, 0x0C7E, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID IID_ICrStretch = {0x6684AF00, 0x0A87, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID IID_ICrWheel = {0x3943DE80, 0x1464, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID IID_ICrZigzag = {0x4E5A64A0, 0x0C8B, 0x11D2, [0xA4, 0x84, 0x00, 0xC0, 0x4F, 0x8E, 0xFB, 0x69]};
+enum IID IID_ICSSFilter = {0x3050F3EC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ICSSFilterDispatch = {0x9519152B, 0x9484, 0x4A6C, [0xB6, 0xA7, 0x4F, 0x25, 0xE9, 0x2D, 0x6C, 0x6B]};
+enum IID IID_ICSSFilterSite = {0x3050F3ED, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ICurrentWorkingDirectory = {0x91956D21, 0x9276, 0x11D1, [0x92, 0x1A, 0x00, 0x60, 0x97, 0xDF, 0x5B, 0xD4]};
+enum IID IID_ICursor = {0x9F6AA700, 0xD188, 0x11CD, [0xAD, 0x48, 0x00, 0xAA, 0x00, 0x3C, 0x9C, 0xB6]};
+enum IID IID_ICursorFind = {0xE01D7850, 0xD188, 0x11CD, [0xAD, 0x48, 0x00, 0xAA, 0x00, 0x3C, 0x9C, 0xB6]};
+enum IID IID_ICursorMove = {0xACFF0690, 0xD188, 0x11CD, [0xAD, 0x48, 0x00, 0xAA, 0x00, 0x3C, 0x9C, 0xB6]};
+enum IID IID_ICursorScroll = {0xBB87E420, 0xD188, 0x11CD, [0xAD, 0x48, 0x00, 0xAA, 0x00, 0x3C, 0x9C, 0xB6]};
+enum IID IID_ICursorUpdateARow = {0xD14216A0, 0xD188, 0x11CD, [0xAD, 0x48, 0x00, 0xAA, 0x00, 0x3C, 0x9C, 0xB6]};
+enum IID IID_ICustomDoc = {0x3050F3F0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ICustomRatingHelper = {0xD0D9842D, 0xE211, 0x4B2C, [0x88, 0xDC, 0xBC, 0x72, 0x93, 0x42, 0xDF, 0xCB]};
+enum IID IID_IDA2Array = {0x2A8F0B06, 0xBE2B, 0x11D1, [0xB2, 0x19, 0x00, 0xC0, 0x4F, 0xC2, 0xA0, 0xCA]};
+enum IID IID_IDA2Behavior = {0xC46C1BF0, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDA2Event = {0x69B5BC70, 0x9B19, 0x11D0, [0x9B, 0x60, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x1D]};
+enum IID IID_IDA2FontStyle = {0x283807B5, 0x2C60, 0x11D0, [0xA3, 0x1D, 0x00, 0xAA, 0x00, 0xB9, 0x2C, 0x03]};
+enum IID IID_IDA2Geometry = {0x4A933702, 0xE36F, 0x11D0, [0x9B, 0x99, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x1D]};
+enum IID IID_IDA2Image = {0x45393DF0, 0x54B9, 0x11CF, [0x92, 0xA2, 0x00, 0xAA, 0x00, 0xB8, 0xA7, 0x33]};
+enum IID IID_IDA2LineStyle = {0x2AE71568, 0x4B34, 0x11D1, [0xB1, 0xE3, 0x00, 0xC0, 0x4F, 0xC2, 0xA0, 0xCA]};
+enum IID IID_IDA2Statics = {0xD17506C2, 0x6B26, 0x11D0, [0x89, 0x14, 0x00, 0xC0, 0x4F, 0xC2, 0xA0, 0xCA]};
+enum IID IID_IDA2View = {0x5F00F545, 0xDF18, 0x11D1, [0xAB, 0x6F, 0x00, 0xC0, 0x4F, 0xD9, 0x2B, 0x6B]};
+enum IID IID_IDA2ViewerControl = {0xC46C1BEF, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDA2ViewerControlWindowed = {0xC46C1BED, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAArray = {0xFA261CF0, 0xC44E, 0x11D1, [0x9B, 0xE4, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x1D]};
+enum IID IID_IDABbox2 = {0xBA8B033E, 0x1E91, 0x11D1, [0x88, 0x09, 0x00, 0xC0, 0x4F, 0xC2, 0x9D, 0x46]};
+enum IID IID_IDABbox3 = {0x0E41257B, 0x812D, 0x11D0, [0x9B, 0x4A, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x1D]};
+enum IID IID_IDABehavior = {0x5DFB2651, 0x9668, 0x11D0, [0xB1, 0x7B, 0x00, 0xC0, 0x4F, 0xC2, 0xA0, 0xCA]};
+enum IID IID_IDABoolean = {0xC46C1BDA, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDABvrHook = {0x50B4791F, 0x4731, 0x11D0, [0x89, 0x12, 0x00, 0xC0, 0x4F, 0xC2, 0xA0, 0xCA]};
+enum IID IID_IDACamera = {0xC46C1BCA, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAColor = {0xC46C1BDC, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDADashStyle = {0xF3E1B522, 0xD8A6, 0x11D1, [0x9B, 0xE5, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x1D]};
+enum IID IID_IDADrawingSurface = {0xC46C1BF4, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDADXTransformResult = {0xAF868305, 0xAB0B, 0x11D0, [0x87, 0x6A, 0x00, 0xC0, 0x4F, 0xC2, 0x9D, 0x46]};
+enum IID IID_IDAEndStyle = {0xB6FFC24C, 0x7E13, 0x11D0, [0x9B, 0x47, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x1D]};
+enum IID IID_IDAEvent = {0xC46C1BCE, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAFontStyle = {0xC46C1BC1, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAGeometry = {0xC46C1BCC, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAImage = {0xC46C1BC4, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAImport = {0xC46C1BEE, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAImportationResult = {0xB90E5258, 0x574A, 0x11D1, [0x8E, 0x7B, 0x00, 0xC0, 0x4F, 0xC2, 0x9D, 0x46]};
+enum IID IID_IDAJoinStyle = {0xA3034056, 0xEC1C, 0x11D1, [0x9B, 0xE8, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x1D]};
+enum IID IID_IDALineStyle = {0x69AD90EF, 0x1C20, 0x11D1, [0x88, 0x01, 0x00, 0xC0, 0x4F, 0xC2, 0x9D, 0x46]};
+enum IID IID_IDAMatte = {0xC46C1BE4, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAMicrophone = {0xC46C1BD8, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAModifiableBehavior = {0xC46C1BEC, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAMontage = {0xC46C1BC8, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDANumber = {0xD17506C3, 0x6B26, 0x11D0, [0x89, 0x14, 0x00, 0xC0, 0x4F, 0xC2, 0xA0, 0xCA]};
+enum IID IID_IDAPair = {0x542FB453, 0x5003, 0x11CF, [0x92, 0xA2, 0x00, 0xAA, 0x00, 0xB8, 0xA7, 0x33]};
+enum IID IID_IDAPath2 = {0xC46C1BD0, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAPickableResult = {0xC46C1BDE, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAPoint2 = {0x9CDE7341, 0x3C20, 0x11D0, [0xA3, 0x30, 0x00, 0xAA, 0x00, 0xB9, 0x2C, 0x03]};
+enum IID IID_IDAPoint3 = {0xC46C1BD6, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAPreferences = {0xB90E525A, 0x574A, 0x11D1, [0x8E, 0x7B, 0x00, 0xC0, 0x4F, 0xC2, 0x9D, 0x46]};
+enum IID IID_IDASite = {0xB90E5259, 0x574A, 0x11D1, [0x8E, 0x7B, 0x00, 0xC0, 0x4F, 0xC2, 0x9D, 0x46]};
+enum IID IID_IDASound = {0xC46C1BE6, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAStatics = {0x5DFB2650, 0x9668, 0x11D0, [0xB1, 0x7B, 0x00, 0xC0, 0x4F, 0xC2, 0xA0, 0xCA]};
+enum IID IID_IDAString = {0xC46C1BD2, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDataAdviseHolder = {0x00000110, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IDataChannel = {0xAD42D12A, 0x4AD0, 0x4856, [0x91, 0x9E, 0xE8, 0x54, 0xC9, 0x1D, 0x18, 0x56]};
+enum IID IID_IDataConvert = {0x0C733A8D, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IDataFilter = {0x69D14C80, 0xC18E, 0x11D0, [0xA9, 0xCE, 0x00, 0x60, 0x97, 0x94, 0x23, 0x11]};
+enum IID IID_IDataObject = {0x0000010E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IDATransform2 = {0xC46C1BD4, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDATransform3 = {0xC46C1BE0, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDATuple = {0x542FB452, 0x5003, 0x11CF, [0x92, 0xA2, 0x00, 0xAA, 0x00, 0xB8, 0xA7, 0x33]};
+enum IID IID_IDAUntilNotifier = {0x25B0F91C, 0xD23D, 0x11D0, [0x9B, 0x85, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x1D]};
+enum IID IID_IDAUserData = {0xBACD4D86, 0x4A4F, 0x11D1, [0x9B, 0xC8, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x1D]};
+enum IID IID_IDAVector2 = {0xC46C1BC6, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAVector3 = {0xC46C1BE2, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAView = {0xAF868304, 0xAB0B, 0x11D0, [0x87, 0x6A, 0x00, 0xC0, 0x4F, 0xC2, 0x9D, 0x46]};
+enum IID IID_IDAViewerControl = {0xC46C1BDD, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAViewerControlWindowed = {0xC46C1BCD, 0x3C52, 0x11D0, [0x92, 0x00, 0x84, 0x8C, 0x1D, 0x00, 0x00, 0x00]};
+enum IID IID_IDAViewSite = {0xBCBB1F75, 0xE384, 0x11D0, [0x9B, 0x99, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x1D]};
+enum IID IID_IDBAsynchNotify = {0x0C733A96, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IDBAsynchStatus = {0x0C733A95, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IDBBinderProperties = {0x0C733AB3, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IDBCreateCommand = {0x0C733A1D, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IDBCreateSession = {0x0C733A5D, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IDBDataSourceAdmin = {0x0C733A7A, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IDBInfo = {0x0C733A89, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IDBInitialize = {0x0C733A8B, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IDBProperties = {0x0C733A8A, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IDBSchemaCommand = {0x0C733A50, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IDBSchemaRowset = {0x0C733A7B, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IDCInfo = {0x0C733A9C, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IDDVideoAcceleratorContainer = {0xACA12120, 0x3356, 0x11D1, [0x8F, 0xCF, 0x00, 0xC0, 0x4F, 0xC2, 0x9B, 0x4E]};
+enum IID IID_IDDVideoPortContainer = {0x6C142760, 0xA733, 0x11CE, [0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60]};
+enum IID IID_IDebug = {0x00000123, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IDebugApplication = {0x51973C32, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugApplication32 = {0x51973C32, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugApplication64 = {0x4DEDC754, 0x04C7, 0x4F10, [0x9E, 0x60, 0x16, 0xA3, 0x90, 0xFE, 0x6E, 0x62]};
+enum IID IID_IDebugApplicationEx = {0x51973C00, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugApplicationNode = {0x51973C34, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugApplicationNodeEvents = {0x51973C35, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugApplicationThread = {0x51973C38, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugApplicationThread64 = {0x9DAC5886, 0xDBAD, 0x456D, [0x9D, 0xEE, 0x5D, 0xEC, 0x39, 0xAB, 0x3D, 0xDA]};
+enum IID IID_IDebugAsyncOperation = {0x51973C1B, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugAsyncOperationCallBack = {0x51973C1C, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugCodeContext = {0x51973C13, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugCookie = {0x51973C39, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugDocument = {0x51973C21, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugDocumentContext = {0x51973C28, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugDocumentHelper32 = {0x51973C26, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugDocumentHelper64 = {0xC4C7363C, 0x20FD, 0x47F9, [0xBD, 0x82, 0x48, 0x55, 0xE0, 0x15, 0x08, 0x71]};
+enum IID IID_IDebugDocumentHelperEx = {0x51973C02, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugDocumentHost = {0x51973C27, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugDocumentInfo = {0x51973C1F, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugDocumentProvider = {0x51973C20, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugDocumentText = {0x51973C22, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugDocumentTextAuthor = {0x51973C24, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugDocumentTextEvents = {0x51973C23, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugDocumentTextExternalAuthor = {0x51973C25, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugExpression = {0x51973C14, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugExpressionCallBack = {0x51973C16, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugExpressionContext = {0x51973C15, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugExtendedProperty = {0x51973C52, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugFormatter = {0x51973C05, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugHelper = {0x51973C3F, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugHelperEx = {0x51973C08, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugOut = {0xC733E4F1, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_IDebugProperty = {0x51973C50, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugPropertyEnumType_All = {0x51973C55, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugPropertyEnumType_Arguments = {0x51973C57, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugPropertyEnumType_Locals = {0x51973C56, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugPropertyEnumType_LocalsPlus = {0x51973C58, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugPropertyEnumType_Registers = {0x51973C59, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugRegister = {0xC733E4F0, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_IDebugSessionProvider = {0x51973C29, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugSessionProviderEx = {0x51973C09, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugSetValueCallback = {0x51973C06, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugStackFrame = {0x51973C17, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugStackFrameSniffer = {0x51973C18, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugStackFrameSnifferEx = {0x51973C19, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugStackFrameSnifferEx32 = {0x51973C19, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugStackFrameSnifferEx64 = {0x8CD12AF4, 0x49C1, 0x4D52, [0x8D, 0x8A, 0xC1, 0x46, 0xF4, 0x75, 0x81, 0xAA]};
+enum IID IID_IDebugStream = {0x00000124, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IDebugSyncOperation = {0x51973C1A, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugThreadCall = {0x51973C36, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugThreadCall32 = {0x51973C36, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IDebugThreadCall64 = {0xCB3FA335, 0xE979, 0x42FD, [0x9F, 0xCF, 0xA7, 0x54, 0x6A, 0x0F, 0x39, 0x05]};
+enum IID IID_IDelaydC = {0xBFF9C030, 0xB58F, 0x11CE, [0xB5, 0xB0, 0x00, 0xAA, 0x00, 0x6C, 0xB3, 0x7D]};
+enum IID IID_IDelayedRelease = {0x000214ED, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IDelegateFolder = {0xADD8BA80, 0x002B, 0x11D0, [0x8F, 0x0F, 0x00, 0xC0, 0x4F, 0xD7, 0xD0, 0x62]};
+enum IID IID_IDeskBand = {0xEB0FE172, 0x1A3A, 0x11D0, [0x89, 0xB3, 0x00, 0xA0, 0xC9, 0x0A, 0x90, 0xAC]};
+enum IID IID_IDeviceRect = {0x3050F6D5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IDfReserved1 = {0x00000013, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IDfReserved2 = {0x00000014, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IDfReserved3 = {0x00000015, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IDialBranding = {0x8AECAFA9, 0x4306, 0x43CC, [0x8C, 0x5A, 0x76, 0x5F, 0x29, 0x79, 0xCC, 0x16]};
+enum IID IID_IDialEngine = {0x39FD782B, 0x7905, 0x40D5, [0x91, 0x48, 0x3C, 0x9B, 0x19, 0x04, 0x23, 0xD5]};
+enum IID IID_IDialEventSink = {0x2D86F4FF, 0x6E2D, 0x4488, [0xB2, 0xE9, 0x69, 0x34, 0xAF, 0xD4, 0x1B, 0xEA]};
+enum IID IID_IDifferencing = {0x994F0AF0, 0x2977, 0x11CE, [0xBB, 0x80, 0x08, 0x00, 0x2B, 0x36, 0xB2, 0xB0]};
+enum IID IID_IDirect3D = {0x3BBA0080, 0x2421, 0x11CF, [0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56]};
+enum IID IID_IDirect3D2 = {0x6AAE1EC1, 0x662A, 0x11D0, [0x88, 0x9D, 0x00, 0xAA, 0x00, 0xBB, 0xB7, 0x6A]};
+enum IID IID_IDirect3D3 = {0xBB223240, 0xE72B, 0x11D0, [0xA9, 0xB4, 0x00, 0xAA, 0x00, 0xC0, 0x99, 0x3E]};
+enum IID IID_IDirect3D7 = {0xF5049E77, 0x4861, 0x11D2, [0xA4, 0x07, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8]};
+enum IID IID_IDirect3DDevice = {0x64108800, 0x957D, 0x11D0, [0x89, 0xAB, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x29]};
+enum IID IID_IDirect3DDevice2 = {0x93281501, 0x8CF8, 0x11D0, [0x89, 0xAB, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x29]};
+enum IID IID_IDirect3DDevice3 = {0xB0AB3B60, 0x33D7, 0x11D1, [0xA9, 0x81, 0x00, 0xC0, 0x4F, 0xD7, 0xB1, 0x74]};
+enum IID IID_IDirect3DDevice7 = {0xF5049E79, 0x4861, 0x11D2, [0xA4, 0x07, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8]};
+enum IID IID_IDirect3DExecuteBuffer = {0x4417C145, 0x33AD, 0x11CF, [0x81, 0x6F, 0x00, 0x00, 0xC0, 0x20, 0x15, 0x6E]};
+enum IID IID_IDirect3DHALDevice = {0x84E63DE0, 0x46AA, 0x11CF, [0x81, 0x6F, 0x00, 0x00, 0xC0, 0x20, 0x15, 0x6E]};
+enum IID IID_IDirect3DLight = {0x4417C142, 0x33AD, 0x11CF, [0x81, 0x6F, 0x00, 0x00, 0xC0, 0x20, 0x15, 0x6E]};
+enum IID IID_IDirect3DMaterial = {0x4417C144, 0x33AD, 0x11CF, [0x81, 0x6F, 0x00, 0x00, 0xC0, 0x20, 0x15, 0x6E]};
+enum IID IID_IDirect3DMaterial2 = {0x93281503, 0x8CF8, 0x11D0, [0x89, 0xAB, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x29]};
+enum IID IID_IDirect3DMaterial3 = {0xCA9C46F4, 0xD3C5, 0x11D1, [0xB7, 0x5A, 0x00, 0x60, 0x08, 0x52, 0xB3, 0x12]};
+enum IID IID_IDirect3DMMXDevice = {0x881949A1, 0xD6F3, 0x11D0, [0x89, 0xAB, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x29]};
+enum IID IID_IDirect3DNullDevice = {0x8767DF22, 0xBACC, 0x11D1, [0x89, 0x69, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8]};
+enum IID IID_IDirect3DRampDevice = {0xF2086B20, 0x259F, 0x11CF, [0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56]};
+enum IID IID_IDirect3DRefDevice = {0x50936643, 0x13E9, 0x11D1, [0x89, 0xAA, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x29]};
+enum IID IID_IDirect3DRGBDevice = {0xA4665C60, 0x2673, 0x11CF, [0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56]};
+enum IID IID_IDirect3DRM = {0x2BC49361, 0x8327, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRM2 = {0x4516ECC8, 0x8F20, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID IID_IDirect3DRM3 = {0x4516EC83, 0x8F20, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID IID_IDirect3DRMAnimation = {0xEB16CB0D, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMAnimation2 = {0xFF6B7F77, 0xA40E, 0x11D1, [0x91, 0xF9, 0x00, 0x00, 0xF8, 0x75, 0x8E, 0x66]};
+enum IID IID_IDirect3DRMAnimationArray = {0xD5F1CAE0, 0x4BD7, 0x11D1, [0xB9, 0x74, 0x00, 0x60, 0x08, 0x3E, 0x45, 0xF3]};
+enum IID IID_IDirect3DRMAnimationSet = {0xEB16CB0E, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMAnimationSet2 = {0xFF6B7F79, 0xA40E, 0x11D1, [0x91, 0xF9, 0x00, 0x00, 0xF8, 0x75, 0x8E, 0x66]};
+enum IID IID_IDirect3DRMClippedVisual = {0x5434E733, 0x6D66, 0x11D1, [0xBB, 0x0B, 0x00, 0x00, 0xF8, 0x75, 0x86, 0x5A]};
+enum IID IID_IDirect3DRMDevice = {0xE9E19280, 0x6E05, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMDevice2 = {0x4516EC78, 0x8F20, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID IID_IDirect3DRMDevice3 = {0x549F498B, 0xBFEB, 0x11D1, [0x8E, 0xD8, 0x00, 0xA0, 0xC9, 0x67, 0xA4, 0x82]};
+enum IID IID_IDirect3DRMDeviceArray = {0xEB16CB10, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMFace = {0xEB16CB07, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMFace2 = {0x4516EC81, 0x8F20, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID IID_IDirect3DRMFaceArray = {0xEB16CB17, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMFrame = {0xEB16CB03, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMFrame2 = {0xC3DFBD60, 0x3988, 0x11D0, [0x9E, 0xC2, 0x00, 0x00, 0xC0, 0x29, 0x1A, 0xC3]};
+enum IID IID_IDirect3DRMFrame3 = {0xFF6B7F70, 0xA40E, 0x11D1, [0x91, 0xF9, 0x00, 0x00, 0xF8, 0x75, 0x8E, 0x66]};
+enum IID IID_IDirect3DRMFrameArray = {0xEB16CB12, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMInterpolator = {0x242F6BC1, 0x3849, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID IID_IDirect3DRMLight = {0xEB16CB08, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMLightArray = {0xEB16CB14, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMMaterial = {0xEB16CB0B, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMMaterial2 = {0xFF6B7F75, 0xA40E, 0x11D1, [0x91, 0xF9, 0x00, 0x00, 0xF8, 0x75, 0x8E, 0x66]};
+enum IID IID_IDirect3DRMMesh = {0xA3A80D01, 0x6E12, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMMeshBuilder = {0xA3A80D02, 0x6E12, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMMeshBuilder2 = {0x4516EC77, 0x8F20, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID IID_IDirect3DRMMeshBuilder3 = {0x4516EC82, 0x8F20, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID IID_IDirect3DRMObject = {0xEB16CB00, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMObject2 = {0x4516EC7C, 0x8F20, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID IID_IDirect3DRMObjectArray = {0x242F6BC2, 0x3849, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID IID_IDirect3DRMPicked2Array = {0x4516EC7B, 0x8F20, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID IID_IDirect3DRMPickedArray = {0xEB16CB16, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMProgressiveMesh = {0x4516EC79, 0x8F20, 0x11D0, [0x9B, 0x6D, 0x00, 0x00, 0xC0, 0x78, 0x1B, 0xC3]};
+enum IID IID_IDirect3DRMShadow = {0xAF359780, 0x6BA3, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMShadow2 = {0x86B44E25, 0x9C82, 0x11D1, [0xBB, 0x0B, 0x00, 0xA0, 0xC9, 0x81, 0xA0, 0xA6]};
+enum IID IID_IDirect3DRMTexture = {0xEB16CB09, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMTexture2 = {0x120F30C0, 0x1629, 0x11D0, [0x94, 0x1C, 0x00, 0x80, 0xC8, 0x0C, 0xFA, 0x7B]};
+enum IID IID_IDirect3DRMTexture3 = {0xFF6B7F73, 0xA40E, 0x11D1, [0x91, 0xF9, 0x00, 0x00, 0xF8, 0x75, 0x8E, 0x66]};
+enum IID IID_IDirect3DRMUserVisual = {0x59163DE0, 0x6D43, 0x11CF, [0xAC, 0x4A, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMViewport = {0xEB16CB02, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMViewport2 = {0x4A1B1BE6, 0xBFED, 0x11D1, [0x8E, 0xD8, 0x00, 0xA0, 0xC9, 0x67, 0xA4, 0x82]};
+enum IID IID_IDirect3DRMViewportArray = {0xEB16CB11, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMVisual = {0xEB16CB04, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMVisualArray = {0xEB16CB13, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMWinDevice = {0xC5016CC0, 0xD273, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DRMWrap = {0xEB16CB0A, 0xD271, 0x11CE, [0xAC, 0x48, 0x00, 0x00, 0xC0, 0x38, 0x25, 0xA1]};
+enum IID IID_IDirect3DTexture = {0x2CDCD9E0, 0x25A0, 0x11CF, [0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56]};
+enum IID IID_IDirect3DTexture2 = {0x93281502, 0x8CF8, 0x11D0, [0x89, 0xAB, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x29]};
+enum IID IID_IDirect3DTnLHalDevice = {0xF5049E78, 0x4861, 0x11D2, [0xA4, 0x07, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8]};
+enum IID IID_IDirect3DVertexBuffer = {0x7A503555, 0x4A83, 0x11D1, [0xA5, 0xDB, 0x00, 0xA0, 0xC9, 0x03, 0x67, 0xF8]};
+enum IID IID_IDirect3DVertexBuffer7 = {0xF5049E7D, 0x4861, 0x11D2, [0xA4, 0x07, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8]};
+enum IID IID_IDirect3DViewport = {0x4417C146, 0x33AD, 0x11CF, [0x81, 0x6F, 0x00, 0x00, 0xC0, 0x20, 0x15, 0x6E]};
+enum IID IID_IDirect3DViewport2 = {0x93281500, 0x8CF8, 0x11D0, [0x89, 0xAB, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x29]};
+enum IID IID_IDirect3DViewport3 = {0xB0AB3B61, 0x33D7, 0x11D1, [0xA9, 0x81, 0x00, 0xC0, 0x4F, 0xD7, 0xB1, 0x74]};
+enum IID IID_IDirectDraw = {0x6C14DB80, 0xA733, 0x11CE, [0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60]};
+enum IID IID_IDirectDraw2 = {0xB3A6F3E0, 0x2B43, 0x11CF, [0xA2, 0xDE, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56]};
+enum IID IID_IDirectDraw4 = {0x9C59509A, 0x39BD, 0x11D1, [0x8C, 0x4A, 0x00, 0xC0, 0x4F, 0xD9, 0x30, 0xC5]};
+enum IID IID_IDirectDraw7 = {0x15E65EC0, 0x3B9C, 0x11D2, [0xB9, 0x2F, 0x00, 0x60, 0x97, 0x97, 0xEA, 0x5B]};
+enum IID IID_IDirectDrawClipper = {0x6C14DB85, 0xA733, 0x11CE, [0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60]};
+enum IID IID_IDirectDrawColorControl = {0x4B9F0EE0, 0x0D7E, 0x11D0, [0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8]};
+enum IID IID_IDirectDrawFactory2 = {0x89B2C488, 0x4AF4, 0x11D1, [0x8C, 0x4C, 0x00, 0xC0, 0x4F, 0xD9, 0x30, 0xC5]};
+enum IID IID_IDirectDrawGammaControl = {0x69C11C3E, 0xB46B, 0x11D1, [0xAD, 0x7A, 0x00, 0xC0, 0x4F, 0xC2, 0x9B, 0x4E]};
+enum IID IID_IDirectDrawKernel = {0x8D56C120, 0x6A08, 0x11D0, [0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8]};
+enum IID IID_IDirectDrawOptSurface = {0x51191F1E, 0x4F2B, 0x11D1, [0x8C, 0xC3, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0xA8]};
+enum IID IID_IDirectDrawPalette = {0x6C14DB84, 0xA733, 0x11CE, [0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60]};
+enum IID IID_IDirectDrawPalette2 = {0xC03C477E, 0x6519, 0x11D1, [0x8C, 0x52, 0x00, 0xC0, 0x4F, 0xD9, 0x30, 0xC5]};
+enum IID IID_IDirectDrawSurface = {0x6C14DB81, 0xA733, 0x11CE, [0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60]};
+enum IID IID_IDirectDrawSurface2 = {0x57805885, 0x6EEC, 0x11CF, [0x94, 0x41, 0xA8, 0x23, 0x03, 0xC1, 0x0E, 0x27]};
+enum IID IID_IDirectDrawSurface3 = {0xDA044E00, 0x69B2, 0x11D0, [0xA1, 0xD5, 0x00, 0xAA, 0x00, 0xB8, 0xDF, 0xBB]};
+enum IID IID_IDirectDrawSurface4 = {0x0B2B8630, 0xAD35, 0x11D0, [0x8E, 0xA6, 0x00, 0x60, 0x97, 0x97, 0xEA, 0x5B]};
+enum IID IID_IDirectDrawSurface7 = {0x06675A80, 0x3B9B, 0x11D2, [0xB9, 0x2F, 0x00, 0x60, 0x97, 0x97, 0xEA, 0x5B]};
+enum IID IID_IDirectDrawSurfaceKernel = {0x60755DA0, 0x6A40, 0x11D0, [0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8]};
+enum IID IID_IDirectDrawVideoAccelerator = {0xC9B2D740, 0x3356, 0x11D1, [0x8F, 0xCF, 0x00, 0xC0, 0x4F, 0xC2, 0x9B, 0x4E]};
+enum IID IID_IDirectDrawVideoPort = {0xB36D93E0, 0x2B43, 0x11CF, [0xA2, 0xDE, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56]};
+enum IID IID_IDirectInput2A = {0x5944E662, 0xAA8A, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IDirectInput2W = {0x5944E663, 0xAA8A, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IDirectInput7A = {0x9A4CB684, 0x236D, 0x11D3, [0x8E, 0x9D, 0x00, 0xC0, 0x4F, 0x68, 0x44, 0xAE]};
+enum IID IID_IDirectInput7W = {0x9A4CB685, 0x236D, 0x11D3, [0x8E, 0x9D, 0x00, 0xC0, 0x4F, 0x68, 0x44, 0xAE]};
+enum IID IID_IDirectInputA = {0x89521360, 0xAA8A, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IDirectInputDevice2A = {0x5944E682, 0xC92E, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IDirectInputDevice2W = {0x5944E683, 0xC92E, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IDirectInputDevice7A = {0x57D7C6BC, 0x2356, 0x11D3, [0x8E, 0x9D, 0x00, 0xC0, 0x4F, 0x68, 0x44, 0xAE]};
+enum IID IID_IDirectInputDevice7W = {0x57D7C6BD, 0x2356, 0x11D3, [0x8E, 0x9D, 0x00, 0xC0, 0x4F, 0x68, 0x44, 0xAE]};
+enum IID IID_IDirectInputDeviceA = {0x5944E680, 0xC92E, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IDirectInputDeviceW = {0x5944E681, 0xC92E, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IDirectInputEffect = {0xE7E1F7C0, 0x88D2, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID IID_IDirectInputEffectDriver = {0x02538130, 0x898F, 0x11D0, [0x9A, 0xD0, 0x00, 0xA0, 0xC9, 0xA0, 0x6E, 0x35]};
+enum IID IID_IDirectInputJoyConfig = {0x1DE12AB1, 0xC9F5, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IDirectInputPIDDriver = {0xEEC6993A, 0xB3FD, 0x11D2, [0xA9, 0x16, 0x00, 0xC0, 0x4F, 0xB9, 0x86, 0x38]};
+enum IID IID_IDirectInputW = {0x89521361, 0xAA8A, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IDirectMusic = {0x6536115A, 0x7B2D, 0x11D2, [0xBA, 0x18, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12]};
+enum IID IID_IDirectMusic2 = {0x6FC2CAE1, 0xBC78, 0x11D2, [0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6]};
+enum IID IID_IDirectMusicBand = {0xD2AC28C0, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicBuffer = {0xD2AC2878, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicChordMap = {0xD2AC28BE, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicCollection = {0xD2AC287C, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicComposer = {0xD2AC28BF, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicDownload = {0xD2AC287B, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicDownloadedInstrument = {0xD2AC287E, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicGetLoader = {0x68A04844, 0xD13D, 0x11D1, [0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6]};
+enum IID IID_IDirectMusicGraph = {0x2BEFC277, 0x5497, 0x11D2, [0xBC, 0xCB, 0x00, 0xA0, 0xC9, 0x22, 0xE6, 0xEB]};
+enum IID IID_IDirectMusicInstrument = {0xD2AC287D, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicLoader = {0x2FFAACA2, 0x5DCA, 0x11D2, [0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6]};
+enum IID IID_IDirectMusicObject = {0xD2AC28B5, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicPerformance = {0x07D43D03, 0x6523, 0x11D2, [0x87, 0x1D, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicPerformance2 = {0x6FC2CAE0, 0xBC78, 0x11D2, [0xAF, 0xA6, 0x00, 0xAA, 0x00, 0x24, 0xD8, 0xB6]};
+enum IID IID_IDirectMusicPort = {0x08F2D8C9, 0x37C2, 0x11D2, [0xB9, 0xF9, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12]};
+enum IID IID_IDirectMusicPortDownload = {0xD2AC287A, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicSegment = {0xF96029A2, 0x4282, 0x11D2, [0x87, 0x17, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicSegment2 = {0xD38894D1, 0xC052, 0x11D2, [0x87, 0x2F, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicSegmentState = {0xA3AFDCC7, 0xD3EE, 0x11D1, [0xBC, 0x8D, 0x00, 0xA0, 0xC9, 0x22, 0xE6, 0xEB]};
+enum IID IID_IDirectMusicStyle = {0xD2AC28BD, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicThru = {0xCED153E7, 0x3606, 0x11D2, [0xB9, 0xF9, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12]};
+enum IID IID_IDirectMusicTool = {0xD2AC28BA, 0xB39B, 0x11D1, [0x87, 0x04, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectMusicTrack = {0xF96029A1, 0x4282, 0x11D2, [0x87, 0x17, 0x00, 0x60, 0x08, 0x93, 0xB1, 0xBD]};
+enum IID IID_IDirectoryObject = {0xE798DE2C, 0x22E4, 0x11D0, [0x84, 0xFE, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IDirectorySchemaMgmt = {0x75DB3B9C, 0xA4D8, 0x11D0, [0xA7, 0x9C, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0xA8]};
+enum IID IID_IDirectorySearch = {0x109BA8EC, 0x92F0, 0x11D0, [0xA7, 0x90, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0xA8]};
+enum IID IID_IDirectPlay = {0x5454E9A0, 0xDB65, 0x11CE, [0x92, 0x1C, 0x00, 0xAA, 0x00, 0x6C, 0x49, 0x72]};
+enum IID IID_IDirectPlay2 = {0x2B74F7C0, 0x9154, 0x11CF, [0xA9, 0xCD, 0x00, 0xAA, 0x00, 0x68, 0x86, 0xE3]};
+enum IID IID_IDirectPlay2A = {0x9D460580, 0xA822, 0x11CF, [0x96, 0x0C, 0x00, 0x80, 0xC7, 0x53, 0x4E, 0x82]};
+enum IID IID_IDirectPlay3 = {0x133EFE40, 0x32DC, 0x11D0, [0x9C, 0xFB, 0x00, 0xA0, 0xC9, 0x0A, 0x43, 0xCB]};
+enum IID IID_IDirectPlay3A = {0x133EFE41, 0x32DC, 0x11D0, [0x9C, 0xFB, 0x00, 0xA0, 0xC9, 0x0A, 0x43, 0xCB]};
+enum IID IID_IDirectPlay4 = {0x0AB1C530, 0x4745, 0x11D1, [0xA7, 0xA1, 0x00, 0x00, 0xF8, 0x03, 0xAB, 0xFC]};
+enum IID IID_IDirectPlay4A = {0x0AB1C531, 0x4745, 0x11D1, [0xA7, 0xA1, 0x00, 0x00, 0xF8, 0x03, 0xAB, 0xFC]};
+enum IID IID_IDirectPlayLobby = {0xAF465C71, 0x9588, 0x11CF, [0xA0, 0x20, 0x00, 0xAA, 0x00, 0x61, 0x57, 0xAC]};
+enum IID IID_IDirectPlayLobby2 = {0x0194C220, 0xA303, 0x11D0, [0x9C, 0x4F, 0x00, 0xA0, 0xC9, 0x05, 0x42, 0x5E]};
+enum IID IID_IDirectPlayLobby2A = {0x1BB4AF80, 0xA303, 0x11D0, [0x9C, 0x4F, 0x00, 0xA0, 0xC9, 0x05, 0x42, 0x5E]};
+enum IID IID_IDirectPlayLobby3 = {0x2DB72490, 0x652C, 0x11D1, [0xA7, 0xA8, 0x00, 0x00, 0xF8, 0x03, 0xAB, 0xFC]};
+enum IID IID_IDirectPlayLobby3A = {0x2DB72491, 0x652C, 0x11D1, [0xA7, 0xA8, 0x00, 0x00, 0xF8, 0x03, 0xAB, 0xFC]};
+enum IID IID_IDirectPlayLobbyA = {0x26C66A70, 0xB367, 0x11CF, [0xA0, 0x24, 0x00, 0xAA, 0x00, 0x61, 0x57, 0xAC]};
+enum IID IID_IDirectSound = {0x279AFA83, 0x4981, 0x11CE, [0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60]};
+enum IID IID_IDirectSound3DBuffer = {0x279AFA86, 0x4981, 0x11CE, [0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60]};
+enum IID IID_IDirectSound3DListener = {0x279AFA84, 0x4981, 0x11CE, [0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60]};
+enum IID IID_IDirectSoundBuffer = {0x279AFA85, 0x4981, 0x11CE, [0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60]};
+enum IID IID_IDirectSoundCapture = {0xB0210781, 0x89CD, 0x11D0, [0xAF, 0x08, 0x00, 0xA0, 0xC9, 0x25, 0xCD, 0x16]};
+enum IID IID_IDirectSoundCaptureBuffer = {0xB0210782, 0x89CD, 0x11D0, [0xAF, 0x08, 0x00, 0xA0, 0xC9, 0x25, 0xCD, 0x16]};
+enum IID IID_IDirectSoundNotify = {0xB0210783, 0x89CD, 0x11D0, [0xAF, 0x08, 0x00, 0xA0, 0xC9, 0x25, 0xCD, 0x16]};
+enum IID IID_IDirectWriterLock = {0x0E6D4D92, 0x6738, 0x11CF, [0x96, 0x08, 0x00, 0xAA, 0x00, 0x68, 0x0D, 0xB4]};
+enum IID IID_IDirectXFile = {0x3D82AB40, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID IID_IDirectXFileBinary = {0x3D82AB46, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID IID_IDirectXFileData = {0x3D82AB44, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID IID_IDirectXFileDataReference = {0x3D82AB45, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID IID_IDirectXFileEnumObject = {0x3D82AB41, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID IID_IDirectXFileObject = {0x3D82AB43, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID IID_IDirectXFileSaveObject = {0x3D82AB42, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID IID_IDiscardableBrowserProperty = {0x49C3DE7C, 0xD329, 0x11D0, [0xAB, 0x73, 0x00, 0xC0, 0x4F, 0xC3, 0x3E, 0x80]};
+enum IID IID_IDiscMaster = {0x520CCA62, 0x51A5, 0x11D3, [0x91, 0x44, 0x00, 0x10, 0x4B, 0xA1, 0x1C, 0x5E]};
+enum IID IID_IDiscMasterProgressEvents = {0xEC9E51C1, 0x4E5D, 0x11D3, [0x91, 0x44, 0x00, 0x10, 0x4B, 0xA1, 0x1C, 0x5E]};
+enum IID IID_IDiscRecorder = {0x85AC9776, 0xCA88, 0x4CF2, [0x89, 0x4E, 0x09, 0x59, 0x8C, 0x07, 0x8A, 0x41]};
+enum IID IID_IDiscStash = {0x520CCA64, 0x51A5, 0x11D3, [0x91, 0x44, 0x00, 0x10, 0x4B, 0xA1, 0x1C, 0x5E]};
+enum IID IID_IDispatch = {0x00020400, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IDispatchEx = {0xA6EF9860, 0xC720, 0x11D0, [0x93, 0x37, 0x00, 0xA0, 0xC9, 0x0D, 0xCA, 0xA9]};
+enum IID IID_IDispError = {0xA6EF9861, 0xC720, 0x11D0, [0x93, 0x37, 0x00, 0xA0, 0xC9, 0x0D, 0xCA, 0xA9]};
+enum IID IID_IDisplayPointer = {0x3050F69E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IDisplayServices = {0x3050F69D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IDithererImpl = {0x7C48E840, 0x3910, 0x11D0, [0x86, 0xFC, 0x00, 0xA0, 0xC9, 0x13, 0xF7, 0x50]};
+enum IID IID_IDocHostShowUI = {0xC4D244B0, 0xD43E, 0x11CF, [0x89, 0x3B, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x1A]};
+enum IID IID_IDocHostUIHandler = {0xBD3F23C0, 0xD43E, 0x11CF, [0x89, 0x3B, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x1A]};
+enum IID IID_IDocHostUIHandler2 = {0x3050F6D0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IDockingWindow = {0x012DD920, 0x7B26, 0x11D0, [0x8C, 0xA9, 0x00, 0xA0, 0xC9, 0x2D, 0xBF, 0xE8]};
+enum IID IID_IDockingWindowFrame = {0x47D2657A, 0x7B27, 0x11D0, [0x8C, 0xA9, 0x00, 0xA0, 0xC9, 0x2D, 0xBF, 0xE8]};
+enum IID IID_IDockingWindowSite = {0x2A342FC2, 0x7B26, 0x11D0, [0x8C, 0xA9, 0x00, 0xA0, 0xC9, 0x2D, 0xBF, 0xE8]};
+enum IID IID_IDoTask = {0x0230C9F8, 0xEE7F, 0x4307, [0x98, 0xDB, 0x72, 0x6E, 0xBC, 0xAE, 0x55, 0xD6]};
+enum IID IID_IDownloadBehavior = {0x3050F5BD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IDownloadManager = {0x988934A4, 0x064B, 0x11D3, [0xBB, 0x80, 0x00, 0x10, 0x4B, 0x35, 0xE7, 0xF9]};
+enum IID IID_IDownloadNotify = {0xCAEB5D28, 0xAE4C, 0x11D1, [0xBA, 0x40, 0x00, 0xC0, 0x4F, 0xB9, 0x2D, 0x79]};
+enum IID IID_IDragSourceHelper = {0xDE5BF786, 0x477A, 0x11D2, [0x83, 0x9D, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0]};
+enum IID IID_IDropSource = {0x00000121, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IDropTarget = {0x00000122, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IDropTargetHelper = {0x4657278B, 0x411B, 0x11D2, [0x83, 0x9A, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xD0]};
+enum IID IID_IDsBrowseDomainTree = {0x7CABCF1E, 0x78F5, 0x11D2, [0x96, 0x0C, 0x00, 0xC0, 0x4F, 0xA3, 0x1A, 0x86]};
+enum IID IID_IDsQueryColumnHandler = {0xC072999E, 0xFA49, 0x11D1, [0xA0, 0xAF, 0x00, 0xC0, 0x4F, 0xA3, 0x1A, 0x86]};
+enum IID IID_IDummy = {0x0D7CA54A, 0xD252, 0x4FCB, [0x91, 0x04, 0xF6, 0xDD, 0xD3, 0x10, 0xB3, 0xF9]};
+enum IID IID_IDummyHICONIncluder = {0x947990DE, 0xCC28, 0x11D2, [0xA0, 0xF7, 0x00, 0x80, 0x5F, 0x85, 0x8F, 0xB1]};
+enum IID IID_IDX2D = {0x9EFD02A9, 0xA996, 0x11D1, [0x81, 0xC9, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID IID_IDX2DDebug = {0x03BB2457, 0xA279, 0x11D1, [0x81, 0xC6, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID IID_IDXARGBReadPtr = {0xEAAAC2D6, 0xC290, 0x11D1, [0x90, 0x5D, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXARGBReadWritePtr = {0xEAAAC2D7, 0xC290, 0x11D1, [0x90, 0x5D, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXARGBSurfaceInit = {0x9EA3B63A, 0xC37D, 0x11D1, [0x90, 0x5E, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXBaseObject = {0x17B59B2B, 0x9CC8, 0x11D1, [0x90, 0x53, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXBasicImage = {0x16B280C7, 0xEE70, 0x11D1, [0x90, 0x66, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXDCLock = {0x0F619456, 0xCF39, 0x11D1, [0x90, 0x5E, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXDLUTBuilder = {0x73068231, 0x35EE, 0x11D1, [0x81, 0xA1, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID IID_IDXDMapper = {0x7FD9088B, 0x35ED, 0x11D1, [0x81, 0xA1, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID IID_IDXEffect = {0xE31FB81B, 0x1335, 0x11D1, [0x81, 0x89, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID IID_IDXGradient = {0xB2024B51, 0xEE77, 0x11D1, [0x90, 0x66, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXGradient2 = {0xD0EF2A80, 0x61DC, 0x11D2, [0xB2, 0xEB, 0x00, 0xA0, 0xC9, 0x36, 0xB2, 0x12]};
+enum IID IID_IDXLookupTable = {0x01BAFC7F, 0x9E63, 0x11D1, [0x90, 0x53, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXLUTBuilder = {0xF4370FC1, 0xCADB, 0x11D0, [0xB5, 0x2C, 0x00, 0xA0, 0xC9, 0x05, 0x43, 0x73]};
+enum IID IID_IDXMapper = {0x555278E5, 0x05DB, 0x11D1, [0x88, 0x3A, 0x3C, 0x8B, 0x00, 0xC1, 0x00, 0x00]};
+enum IID IID_IDXPixelate = {0xD33E180F, 0xFBE9, 0x11D1, [0x90, 0x6A, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXRasterizer = {0x9EA3B635, 0xC37D, 0x11D1, [0x90, 0x5E, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXRawSurface = {0x09756C8A, 0xD96A, 0x11D1, [0x90, 0x62, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXSurface = {0xB39FD73F, 0xE139, 0x11D1, [0x90, 0x65, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXSurfaceFactory = {0x144946F5, 0xC4D4, 0x11D1, [0x81, 0xD1, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID IID_IDXSurfaceInit = {0x9EA3B639, 0xC37D, 0x11D1, [0x90, 0x5E, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXSurfaceModifier = {0x9EA3B637, 0xC37D, 0x11D1, [0x90, 0x5E, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXSurfacePick = {0x30A5FB79, 0xE11F, 0x11D1, [0x90, 0x64, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXTAlpha = {0x1D4637E0, 0x383C, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID IID_IDXTAlphaImageLoader = {0xA5F2D3E8, 0x7A7E, 0x48E5, [0xBC, 0x75, 0x40, 0x79, 0x0B, 0xE4, 0xA9, 0x41]};
+enum IID IID_IDXTaskManager = {0x254DBBC1, 0xF922, 0x11D0, [0x88, 0x3A, 0x3C, 0x8B, 0x00, 0xC1, 0x00, 0x00]};
+enum IID IID_IDXTBindHost = {0xD26BCE55, 0xE9DC, 0x11D1, [0x90, 0x66, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXTCheckerBoard = {0xAD3C2576, 0x117C, 0x4510, [0x84, 0xDD, 0xB6, 0x68, 0x97, 0x1D, 0xCF, 0xD1]};
+enum IID IID_IDXTChroma = {0x1D4637E2, 0x383C, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID IID_IDXTClipOrigin = {0xEE1663D8, 0x0988, 0x4C48, [0x9F, 0xD6, 0xDB, 0x44, 0x50, 0x88, 0x56, 0x68]};
+enum IID IID_IDXTComposite = {0x9A43A843, 0x0831, 0x11D1, [0x81, 0x7F, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID IID_IDXTConvolution = {0x7BA7F8AF, 0xE5EA, 0x11D1, [0x81, 0xDD, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID IID_IDXTDropShadow = {0x1D4637E3, 0x383C, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID IID_IDXTFade = {0x16B280C4, 0xEE70, 0x11D1, [0x90, 0x66, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXTFilter = {0x6187E5A2, 0xA445, 0x4608, [0x8F, 0xC0, 0xBE, 0x7A, 0x6C, 0x8D, 0xB3, 0x86]};
+enum IID IID_IDXTFilterBehavior = {0x14D7DDDD, 0xACA2, 0x4E45, [0x95, 0x04, 0x38, 0x08, 0xAB, 0xEB, 0x4F, 0x92]};
+enum IID IID_IDXTFilterBehaviorSite = {0x909B23C2, 0x9018, 0x499F, [0xA8, 0x6D, 0x4E, 0x7D, 0xA9, 0x37, 0xE9, 0x31]};
+enum IID IID_IDXTFilterCollection = {0x22B07B33, 0x8BFB, 0x49D4, [0x9B, 0x90, 0x09, 0x38, 0x37, 0x0C, 0x90, 0x19]};
+enum IID IID_IDXTFilterController = {0x5CF315F2, 0x273D, 0x47B6, [0xB9, 0xED, 0xF7, 0x5D, 0xC3, 0xB0, 0x15, 0x0B]};
+enum IID IID_IDXTGlow = {0x1D4637E4, 0x383C, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID IID_IDXTGradientD = {0x623E2881, 0xFC0E, 0x11D1, [0x9A, 0x77, 0x00, 0x00, 0xF8, 0x75, 0x6A, 0x10]};
+enum IID IID_IDXTGridSize = {0xD6BBE91E, 0xFF60, 0x11D2, [0x8F, 0x6E, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x74]};
+enum IID IID_IDXTICMFilter = {0x734321ED, 0x1E7B, 0x4E1C, [0xBB, 0xFA, 0x89, 0xC8, 0x19, 0x80, 0x0E, 0x2F]};
+enum IID IID_IDXTLabel = {0xC0C17F0E, 0xAE41, 0x11D1, [0x9A, 0x3B, 0x00, 0x00, 0xF8, 0x75, 0x6A, 0x10]};
+enum IID IID_IDXTLight = {0xF9EFBEC1, 0x4302, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID IID_IDXTMask = {0xA1067146, 0xB063, 0x47D7, [0xA5, 0x4A, 0x2C, 0x23, 0x09, 0xE9, 0x88, 0x9D]};
+enum IID IID_IDXTMatrix = {0xAC66A493, 0x0F0C, 0x4C76, [0x82, 0x5C, 0x9D, 0x68, 0xBE, 0xDE, 0x91, 0x88]};
+enum IID IID_IDXTMetaBurnFilm = {0x107045D0, 0x06E0, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID IID_IDXTMetaCenterPeel = {0xAA0D4D0B, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID IID_IDXTMetaColorFade = {0x2A54C907, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID IID_IDXTMetaFlowMotion = {0x2A54C90A, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID IID_IDXTMetaGriddler = {0x2A54C910, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID IID_IDXTMetaGriddler2 = {0x2A54C912, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID IID_IDXTMetaJaws = {0x2A54C903, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID IID_IDXTMetaLightWipe = {0x107045C7, 0x06E0, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID IID_IDXTMetaLiquid = {0xAA0D4D09, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID IID_IDXTMetaPageTurn = {0xAA0D4D07, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID IID_IDXTMetaPeelPiece = {0xAA0D4D0F, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID IID_IDXTMetaPeelSmall = {0xAA0D4D0D, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID IID_IDXTMetaPeelSplit = {0xAA0D4D11, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID IID_IDXTMetaRadialScaleWipe = {0x107045C9, 0x06E0, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID IID_IDXTMetaRipple = {0xAA0D4D02, 0x06A3, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID IID_IDXTMetaRoll = {0x9C61F46D, 0x0530, 0x11D2, [0x8F, 0x98, 0x00, 0xC0, 0x4F, 0xB9, 0x2E, 0xB7]};
+enum IID IID_IDXTMetaThreshold = {0x2A54C914, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID IID_IDXTMetaTwister = {0x107045CE, 0x06E0, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID IID_IDXTMetaVacuum = {0x2A54C90C, 0x07AA, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID IID_IDXTMetaWater = {0x107045C4, 0x06E0, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID IID_IDXTMetaWhiteOut = {0x107045CB, 0x06E0, 0x11D2, [0x8D, 0x6D, 0x00, 0xC0, 0x4F, 0x8E, 0xF8, 0xE0]};
+enum IID IID_IDXTMetaWormHole = {0x0E6AE021, 0x0C83, 0x11D2, [0x8C, 0xD4, 0x00, 0x10, 0x4B, 0xC7, 0x5D, 0x9A]};
+enum IID IID_IDXTMotionBlur = {0x089057BE, 0xD3F5, 0x4A2C, [0xB1, 0x0A, 0xA5, 0x13, 0x01, 0x84, 0xA0, 0xF7]};
+enum IID IID_IDXTRandomBars = {0x8A6D2022, 0x4A8F, 0x4EB9, [0xBB, 0x25, 0xAA, 0x05, 0x20, 0x1F, 0x9C, 0x84]};
+enum IID IID_IDXTransform = {0x30A5FB78, 0xE11F, 0x11D1, [0x90, 0x64, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXTransformFactory = {0x6A950B2B, 0xA971, 0x11D1, [0x81, 0xC8, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID IID_IDXTRedirect = {0x02F5140B, 0x626F, 0x4019, [0x9C, 0x9E, 0x2D, 0xAA, 0x1E, 0x93, 0xE8, 0xFC]};
+enum IID IID_IDXTRedirectFilterInit = {0xD1A57094, 0x21F7, 0x4E6C, [0x93, 0xE5, 0xF5, 0xF7, 0x7F, 0x74, 0x82, 0x93]};
+enum IID IID_IDXTRevealTrans = {0xB8095006, 0xA128, 0x464B, [0x8B, 0x2D, 0x90, 0x58, 0x0A, 0xEE, 0x2B, 0x05]};
+enum IID IID_IDXTScale = {0xB39FD742, 0xE139, 0x11D1, [0x90, 0x65, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXTScaleOutput = {0xB2024B50, 0xEE77, 0x11D1, [0x90, 0x66, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0x9D]};
+enum IID IID_IDXTShadow = {0x1D4637E6, 0x383C, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID IID_IDXTStrips = {0xA83C9B5C, 0xFB11, 0x4AF5, [0x8F, 0x65, 0xD0, 0x3F, 0x15, 0x1D, 0x3E, 0xD5]};
+enum IID IID_IDXTWave = {0x1D4637E7, 0x383C, 0x11D2, [0x95, 0x2A, 0x00, 0xC0, 0x4F, 0xA3, 0x4F, 0x05]};
+enum IID IID_IDXTWipe = {0xAF279B2F, 0x86EB, 0x11D1, [0x81, 0xBF, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID IID_IDXTWipe2 = {0xE1FF8091, 0x442B, 0x4801, [0x88, 0xB6, 0x2B, 0x47, 0xB1, 0x61, 0x1F, 0xD2]};
+enum IID IID_IDynamicPortMapping = {0x4FC80282, 0x23B6, 0x4378, [0x9A, 0x27, 0xCD, 0x8F, 0x17, 0xC9, 0x40, 0x0C]};
+enum IID IID_IDynamicPortMappingCollection = {0xB60DE00F, 0x156E, 0x4E8D, [0x9E, 0xC1, 0x3A, 0x23, 0x42, 0xC1, 0x08, 0x99]};
+enum IID IID_IEditDebugServices = {0x3050F60B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementAdorner = {0x3050F607, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehavior = {0x3050F425, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorCategory = {0x3050F4ED, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorFactory = {0x3050F429, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorFocus = {0x3050F6B6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorLayout = {0x3050F6BA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorLayout2 = {0x3050F846, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorRender = {0x3050F4AA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorSite = {0x3050F427, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorSiteCategory = {0x3050F4EE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorSiteLayout = {0x3050F6B7, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorSiteLayout2 = {0x3050F847, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorSiteOM = {0x3050F489, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorSiteOM2 = {0x3050F659, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorSiteRender = {0x3050F4A7, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorSubmit = {0x3050F646, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementBehaviorUI = {0x3050F4BF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementNamespace = {0x3050F671, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementNamespaceFactory = {0x3050F672, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementNamespaceFactory2 = {0x3050F805, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementNamespaceFactoryCallback = {0x3050F7FD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementNamespacePrivate = {0x3050F7FF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementNamespaceTable = {0x3050F670, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IElementSegment = {0x3050F68F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IEmptyVolumeCache = {0x8FCE5227, 0x04DA, 0x11D1, [0xA0, 0x04, 0x00, 0x80, 0x5F, 0x8A, 0xBE, 0x06]};
+enum IID IID_IEmptyVolumeCache2 = {0x02B7E3BA, 0x4DB3, 0x11D2, [0xB2, 0xD9, 0x00, 0xC0, 0x4F, 0x8E, 0xEC, 0x8C]};
+enum IID IID_IEmptyVolumeCacheCallBack = {0x6E793361, 0x73C6, 0x11D0, [0x84, 0x69, 0x00, 0xAA, 0x00, 0x44, 0x29, 0x01]};
+enum IID IID_IEncodingFilterFactory = {0x70BDDE00, 0xC18E, 0x11D0, [0xA9, 0xCE, 0x00, 0x60, 0x97, 0x94, 0x23, 0x11]};
+enum IID IID_IEnroll = {0xACAA7838, 0x4585, 0x11D1, [0xAB, 0x57, 0x00, 0xC0, 0x4F, 0xC2, 0x95, 0xE1]};
+enum IID IID_IEnroll2 = {0xC080E199, 0xB7DF, 0x11D2, [0xA4, 0x21, 0x00, 0xC0, 0x4F, 0x79, 0xFE, 0x8E]};
+enum IID IID_IEnroll4 = {0xF8053FE5, 0x78F4, 0x448F, [0xA0, 0xDB, 0x41, 0xD6, 0x1B, 0x73, 0x44, 0x6B]};
+enum IID IID_IEntryID = {0xE4D19810, 0xD188, 0x11CD, [0xAD, 0x48, 0x00, 0xAA, 0x00, 0x3C, 0x9C, 0xB6]};
+enum IID IID_IEnumACDGroup = {0x5AFC3157, 0x4BCC, 0x11D1, [0xBF, 0x80, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_IEnumACString = {0x8E74C210, 0xCF9D, 0x4EAF, [0xA4, 0x03, 0x73, 0x56, 0x42, 0x8F, 0x0A, 0x5A]};
+enum IID IID_IEnumAdapterInfo = {0xA23F9D11, 0x714C, 0x41FE, [0x84, 0x71, 0xFF, 0xB1, 0x9B, 0xC2, 0x84, 0x54]};
+enum IID IID_IEnumAddress = {0x1666FCA1, 0x9363, 0x11D0, [0x83, 0x5C, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID IID_IEnumAgent = {0x5AFC314D, 0x4BCC, 0x11D1, [0xBF, 0x80, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_IEnumAgentHandler = {0x587E8C28, 0x9802, 0x11D1, [0xA0, 0xA4, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_IEnumAgentSession = {0x5AFC314E, 0x4BCC, 0x11D1, [0xBF, 0x80, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_IEnumBackgroundCopyFiles = {0xCA51E165, 0xC365, 0x424C, [0x8D, 0x41, 0x24, 0xAA, 0xA4, 0xFF, 0x3C, 0x40]};
+enum IID IID_IEnumBackgroundCopyGroups = {0xD993E603, 0x4AA4, 0x47C5, [0x86, 0x65, 0xC2, 0x0D, 0x39, 0xC2, 0xBA, 0x4F]};
+enum IID IID_IEnumBackgroundCopyJobs = {0x1AF4F612, 0x3B71, 0x466F, [0x8F, 0x58, 0x7B, 0x6F, 0x73, 0xAC, 0x57, 0xAD]};
+enum IID IID_IEnumBackgroundCopyJobs1 = {0x8BAEBA9D, 0x8F1C, 0x42C4, [0xB8, 0x2C, 0x09, 0xAE, 0x79, 0x98, 0x0D, 0x25]};
+enum IID IID_IEnumBstr = {0x35372049, 0x0BC6, 0x11D2, [0xA0, 0x33, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_IEnumCall = {0xAE269CF6, 0x935E, 0x11D0, [0x83, 0x5C, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID IID_IEnumCallback = {0x00000108, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumCallHub = {0xA3C15450, 0x5B92, 0x11D1, [0x8F, 0x4E, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_IEnumCallingCard = {0x0C4D8F02, 0x8DDB, 0x11D1, [0xA0, 0x9E, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_IEnumCATEGORYINFO = {0x0002E011, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumChannels = {0xA4C65425, 0x0F82, 0x11D1, [0x90, 0xC3, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x68]};
+enum IID IID_IEnumClusCfgIPAddresses = {0xBD5F35BA, 0x0BC0, 0x455F, [0x92, 0x6D, 0xC3, 0xD3, 0x56, 0x41, 0x94, 0x86]};
+enum IID IID_IEnumClusCfgManagedResources = {0x7DBE11EB, 0xA5DF, 0x4534, [0xAB, 0xF6, 0x8B, 0xAC, 0x7B, 0x53, 0xFC, 0x95]};
+enum IID IID_IEnumClusCfgNetworks = {0xCF3FAED8, 0x1322, 0x4BCB, [0x99, 0x23, 0xB5, 0xB7, 0x45, 0xA6, 0x9E, 0x36]};
+enum IID IID_IEnumClusCfgPartitions = {0x4440BB6A, 0xB0AC, 0x479D, [0xB5, 0x34, 0x72, 0x65, 0xA3, 0x1D, 0x6C, 0x55]};
+enum IID IID_IEnumCodePage = {0x275C23E3, 0x3747, 0x11D0, [0x9F, 0xEA, 0x00, 0xAA, 0x00, 0x3F, 0x86, 0x46]};
+enum IID IID_IEnumConnectionPoints = {0xB196B285, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IEnumConnections = {0xB196B287, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IEnumCookies = {0x5E3E482E, 0x3C22, 0x482C, [0xB6, 0x64, 0x69, 0x30, 0x51, 0xAD, 0x0A, 0x5D]};
+enum IID IID_IEnumDebugApplicationNodes = {0x51973C3A, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IEnumDebugCodeContexts = {0x51973C1D, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IEnumDebugExpressionContexts = {0x51973C40, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IEnumDebugExtendedPropertyInfo = {0x51973C53, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IEnumDebugPropertyInfo = {0x51973C51, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IEnumDebugStackFrames = {0x51973C1E, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IEnumDebugStackFrames64 = {0x0DC38853, 0xC1B0, 0x4176, [0xA9, 0x84, 0xB2, 0x98, 0x36, 0x10, 0x27, 0xAF]};
+enum IID IID_IEnumDialableAddrs = {0x34621D70, 0x6CFF, 0x11D1, [0xAF, 0xF7, 0x00, 0xC0, 0x4F, 0xC3, 0x1F, 0xEE]};
+enum IID IID_IEnumDirectory = {0x34621D6D, 0x6CFF, 0x11D1, [0xAF, 0xF7, 0x00, 0xC0, 0x4F, 0xC3, 0x1F, 0xEE]};
+enum IID IID_IEnumDirectoryObject = {0x06C9B64A, 0x306D, 0x11D1, [0x97, 0x74, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID IID_IEnumDiscMasterFormats = {0xDDF445E1, 0x54BA, 0x11D3, [0x91, 0x44, 0x00, 0x10, 0x4B, 0xA1, 0x1C, 0x5E]};
+enum IID IID_IEnumDiscRecorders = {0x9B1921E1, 0x54AC, 0x11D3, [0x91, 0x44, 0x00, 0x10, 0x4B, 0xA1, 0x1C, 0x5E]};
+enum IID IID_IEnumExtraSearch = {0x0E700BE1, 0x9DB6, 0x11D1, [0xA1, 0xCE, 0x00, 0xC0, 0x4F, 0xD7, 0x5D, 0x13]};
+enum IID IID_IEnumFORMATETC = {0x00000103, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumGeneric = {0x00000106, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumGUID = {0x0002E000, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumHLITEM = {0x79EAC9C6, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IEnumHNetApplicationProtocols = {0x85D18B7B, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IEnumHNetBridgedConnections = {0x85D18B7D, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IEnumHNetBridges = {0x85D18B77, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IEnumHNetFirewalledConnections = {0x85D18B78, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IEnumHNetIcsPrivateConnections = {0x85D18B7A, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IEnumHNetIcsPublicConnections = {0x85D18B79, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IEnumHNetPortMappingBindings = {0x85D18B81, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IEnumHNetPortMappingProtocols = {0x85D18B7C, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IEnumHolder = {0x00000107, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumIDList = {0x000214F2, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumInputContext = {0x09B5EAB0, 0xF997, 0x11D1, [0x93, 0xD4, 0x00, 0x60, 0xB0, 0x67, 0xB8, 0x6E]};
+enum IID IID_IEnumItemProperties = {0xF72C8D96, 0x6DBD, 0x11D1, [0xA1, 0xE8, 0x00, 0xC0, 0x4F, 0xC2, 0xFB, 0xE1]};
+enum IID IID_IEnumLocation = {0x0C4D8F01, 0x8DDB, 0x11D1, [0xA0, 0x9E, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_IEnumMcastScope = {0xDF0DAF09, 0xA289, 0x11D1, [0x86, 0x97, 0x00, 0x60, 0x08, 0xB0, 0xE5, 0xD2]};
+enum IID IID_IEnumMedia = {0xCA8397BE, 0x2FA4, 0x11D1, [0x97, 0x74, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID IID_IEnumMoniker = {0x00000102, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumNetCfgBindingInterface = {0xC0E8AE90, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_IEnumNetCfgBindingPath = {0xC0E8AE91, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_IEnumNetCfgComponent = {0xC0E8AE92, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_IEnumNetConnection = {0xC08956A0, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_IEnumNetSharingEveryConnection = {0xC08956B8, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_IEnumNetSharingPortMapping = {0xC08956B0, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_IEnumNetSharingPrivateConnection = {0xC08956B5, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_IEnumNetSharingPublicConnection = {0xC08956B4, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_IEnumNodes = {0xC477E363, 0xAF0A, 0x4203, [0xA6, 0x04, 0x45, 0xCD, 0x60, 0x7D, 0xD7, 0x10]};
+enum IID IID_IEnumNotification = {0xC733E4A8, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_IEnumNotificationSinkItem = {0xC733E4AA, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_IEnumOleDocumentViews = {0xB722BCC8, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]};
+enum IID IID_IEnumOleUndoUnits = {0xB3E7C340, 0xEF97, 0x11CE, [0x9B, 0xC9, 0x00, 0xAA, 0x00, 0x60, 0x8E, 0x01]};
+enum IID IID_IEnumOLEVERB = {0x00000104, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumParticipant = {0x0A91B56C, 0x5A35, 0x11D2, [0x95, 0xA0, 0x00, 0xA0, 0x24, 0x4D, 0x22, 0x98]};
+enum IID IID_IEnumPhone = {0xF15B7669, 0x4780, 0x4595, [0x8C, 0x89, 0xFB, 0x36, 0x9C, 0x8C, 0xF7, 0xAA]};
+enum IID IID_IEnumPluggableSuperclassInfo = {0xE9586A80, 0x89E6, 0x4CFF, [0x93, 0x1D, 0x47, 0x8D, 0x57, 0x51, 0xF4, 0xC0]};
+enum IID IID_IEnumPluggableTerminalClassInfo = {0x4567450C, 0xDBEE, 0x4E3F, [0xAA, 0xF5, 0x37, 0xBF, 0x9E, 0xBF, 0x5E, 0x29]};
+enum IID IID_IEnumPrivacyRecords = {0x3050F844, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IEnumPropertyMap = {0xC733E4A1, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_IEnumPublishedApps = {0x0B124F8C, 0x91F0, 0x11D1, [0xB8, 0xB5, 0x00, 0x60, 0x08, 0x05, 0x93, 0x82]};
+enum IID IID_IEnumQueue = {0x5AFC3158, 0x4BCC, 0x11D1, [0xBF, 0x80, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_IEnumRegisterWordA = {0x08C03412, 0xF96B, 0x11D0, [0xA4, 0x75, 0x00, 0xAA, 0x00, 0x6B, 0xCC, 0x59]};
+enum IID IID_IEnumRegisterWordW = {0x4955DD31, 0xB159, 0x11D0, [0x8F, 0xCF, 0x00, 0xAA, 0x00, 0x6B, 0xCC, 0x59]};
+enum IID IID_IEnumRemoteDebugApplications = {0x51973C3B, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IEnumRemoteDebugApplicationThrea = {0x51973C3C, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IEnumRfc1766 = {0x3DC39D1D, 0xC030, 0x11D0, [0xB8, 0x1B, 0x00, 0xC0, 0x4F, 0xC9, 0xB3, 0x1F]};
+enum IID IID_IEnumScheduleGroup = {0xC733E4A9, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_IEnumScript = {0xAE5F1430, 0x388B, 0x11D2, [0x83, 0x80, 0x00, 0xC0, 0x4F, 0x8F, 0x5D, 0xA1]};
+enum IID IID_IEnumSTATDATA = {0x00000105, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumSTATPROPBAG = {0x20021801, 0x5DE6, 0x11D1, [0x8E, 0x38, 0x00, 0xC0, 0x4F, 0xB9, 0x38, 0x6D]};
+enum IID IID_IEnumSTATPROPSETSTG = {0x0000013B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumSTATPROPSTG = {0x00000139, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumSTATSTG = {0x0000000D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumSTATURL = {0x3C374A42, 0xBAE4, 0x11CF, [0xBF, 0x7D, 0x00, 0xAA, 0x00, 0x69, 0x46, 0xEE]};
+enum IID IID_IEnumStream = {0xEE3BD606, 0x3868, 0x11D2, [0xA0, 0x45, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_IEnumString = {0x00000101, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumSubscription = {0xF72C8D97, 0x6DBD, 0x11D1, [0xA1, 0xE8, 0x00, 0xC0, 0x4F, 0xC2, 0xFB, 0xE1]};
+enum IID IID_IEnumSubStream = {0xEE3BD609, 0x3868, 0x11D2, [0xA0, 0x45, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_IEnumSyncItems = {0xF0E1589A, 0xA700, 0x11D1, [0x98, 0x31, 0x00, 0xC0, 0x4F, 0xD9, 0x10, 0xDD]};
+enum IID IID_IEnumSyncSchedules = {0xF0E15898, 0xA700, 0x11D1, [0x98, 0x31, 0x00, 0xC0, 0x4F, 0xD9, 0x10, 0xDD]};
+enum IID IID_IEnumTerminal = {0xAE269CF4, 0x935E, 0x11D0, [0x83, 0x5C, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID IID_IEnumTerminalClass = {0xAE269CF5, 0x935E, 0x11D0, [0x83, 0x5C, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID IID_IEnumTime = {0x9055322E, 0x2FA8, 0x11D1, [0x97, 0x74, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID IID_IEnumTravelLogEntry = {0x7EBFDD85, 0xAD18, 0x11D3, [0xA4, 0xC5, 0x00, 0xC0, 0x4F, 0x72, 0xD6, 0xB8]};
+enum IID IID_IEnumUnknown = {0x00000100, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumVARIANT = {0x00020404, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IEnumWbemClassObject = {0x027947E1, 0xD731, 0x11CE, [0xA3, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]};
+enum IID IID_IErrorInfo = {0x1CF2B120, 0x547D, 0x101B, [0x8E, 0x65, 0x08, 0x00, 0x2B, 0x2B, 0xD1, 0x19]};
+enum IID IID_IErrorLog = {0x3127CA40, 0x446E, 0x11CE, [0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]};
+enum IID IID_IErrorLookup = {0x0C733A66, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IErrorRecords = {0x0C733A67, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IESP = {0xE99A04AA, 0xAB95, 0x11D0, [0xBE, 0x96, 0x00, 0xA0, 0xC9, 0x49, 0x89, 0xDE]};
+enum IID IID_IExtendObjectManager = {0xCA7BB0B9, 0x700C, 0x4DC5, [0x99, 0x1E, 0x75, 0xF9, 0xE6, 0x5E, 0xE9, 0x75]};
+enum IID IID_IExtensionServices = {0x79EAC9CB, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IExternalConnection = {0x00000019, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IExtractIconA = {0x000214EB, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IExtractIconW = {0x000214FA, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IExtractImage = {0xBB2E617C, 0x0920, 0x11D1, [0x9A, 0x0B, 0x00, 0xC0, 0x4F, 0xC2, 0xD6, 0xC1]};
+enum IID IID_IExtractImage2 = {0x953BB1EE, 0x93B4, 0x11D1, [0x98, 0xA3, 0x00, 0xC0, 0x4F, 0xB6, 0x87, 0xDA]};
+enum IID IID_IFileSearchBand = {0x2D91EEA1, 0x9932, 0x11D2, [0xBE, 0x86, 0x00, 0xA0, 0xC9, 0xA8, 0x3D, 0xA1]};
+enum IID IID_IFileSystemBindData = {0x01E18D10, 0x4D8B, 0x11D2, [0x85, 0x5D, 0x00, 0x60, 0x08, 0x05, 0x93, 0x67]};
+enum IID IID_IFileViewerA = {0x000214F0, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IFileViewerSite = {0x000214F3, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IFileViewerW = {0x000214F8, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IFillLockBytes = {0x99CAF010, 0x415E, 0x11CF, [0x88, 0x14, 0x00, 0xAA, 0x00, 0xB5, 0x69, 0xF5]};
+enum IID IID_IFilter = {0x89BCB740, 0x6119, 0x101A, [0xBC, 0xB7, 0x00, 0xDD, 0x01, 0x06, 0x55, 0xAF]};
+enum IID IID_IFilterAnimationInfo = {0x02E29300, 0xC758, 0x49B4, [0x9E, 0x11, 0xC5, 0x8B, 0xFE, 0x90, 0x55, 0x8B]};
+enum IID IID_IFilterStatus = {0xF4EB8260, 0x8DDA, 0x11D1, [0xB3, 0xAA, 0x00, 0xA0, 0xC9, 0x06, 0x37, 0x96]};
+enum IID IID_IFolderFilter = {0x9CC22886, 0xDC8E, 0x11D2, [0xB1, 0xD0, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x3E]};
+enum IID IID_IFolderFilterSite = {0xC0A651F5, 0xB48B, 0x11D2, [0xB5, 0xED, 0x00, 0x60, 0x97, 0xC6, 0x86, 0xF6]};
+enum IID IID_IFolderView = {0xCDE725B0, 0xCCC9, 0x4519, [0x91, 0x7E, 0x32, 0x5D, 0x72, 0xFA, 0xB4, 0xCE]};
+enum IID IID_IFolderViewHost = {0x1EA58F02, 0xD55A, 0x411D, [0xB0, 0x9E, 0x9E, 0x65, 0xAC, 0x21, 0x60, 0x5B]};
+enum IID IID_IFolderViewOC = {0x9BA05970, 0xF6A8, 0x11CF, [0xA4, 0x42, 0x00, 0xA0, 0xC9, 0x0A, 0x8F, 0x39]};
+enum IID IID_IFont = {0xBEF6E002, 0xA874, 0x101A, [0x8B, 0xBA, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID IID_IFontDisp = {0xBEF6E003, 0xA874, 0x101A, [0x8B, 0xBA, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID IID_IFontEventsDisp = {0x4EF6100A, 0xAF88, 0x11D0, [0x98, 0x46, 0x00, 0xC0, 0x4F, 0xC2, 0x99, 0x93]};
+enum IID IID_IFontNames = {0x3050F839, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IForegroundTransfer = {0x00000145, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IFsCiAdmin = {0x75398C30, 0x7A26, 0x11D0, [0xA8, 0x0A, 0x00, 0xA0, 0xC9, 0x06, 0x24, 0x1A]};
+enum IID IID_IGatherData = {0x65318F4A, 0xB63C, 0x4E21, [0xAD, 0xDC, 0xBD, 0xCF, 0xB9, 0x69, 0xE1, 0x81]};
+enum IID IID_IGetClusterDataInfo = {0x97DEDE51, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IGetClusterGroupInfo = {0x97DEDE54, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IGetClusterNetInterfaceInfo = {0x97DEDE57, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IGetClusterNetworkInfo = {0x97DEDE56, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IGetClusterNodeInfo = {0x97DEDE53, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IGetClusterObjectInfo = {0x97DEDE52, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IGetClusterResourceInfo = {0x97DEDE55, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IGetClusterUIInfo = {0x97DEDE50, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IGetDataSource = {0x0C733A75, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IGetRow = {0x0C733AAF, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IGetSession = {0x0C733ABA, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IGetSourceRow = {0x0C733ABB, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IGlobalInterfaceTable = {0x00000146, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IH26XEncodeOptions = {0x65698D40, 0x282D, 0x11D0, [0x88, 0x00, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IH26XEncoderControl = {0xF9B78AA1, 0xEA12, 0x11CF, [0x9F, 0xEC, 0x00, 0xAA, 0x00, 0xA5, 0x9F, 0x69]};
+enum IID IID_IH26XRTPControl = {0x1FC3F2C0, 0x2BFD, 0x11D0, [0x88, 0x00, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IH26XSnapshot = {0x3CB194A0, 0x10AA, 0x11D0, [0x88, 0x00, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IH26XVideoEffects = {0x21555140, 0x9C2B, 0x11CF, [0x90, 0xFA, 0x00, 0xAA, 0x00, 0xA7, 0x29, 0xEA]};
+enum IID IID_IH323LineEx = {0x44CF6A9D, 0xCB40, 0x4BBC, [0xB2, 0xD3, 0xB6, 0xAA, 0x93, 0x32, 0x2C, 0x71]};
+enum IID IID_IHeaderFooter = {0x3050F6CE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHighlightRenderingServices = {0x3050F606, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHighlightSegment = {0x3050F690, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHlink = {0x79EAC9C3, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IHlinkBrowseContext = {0x79EAC9C7, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IHlinkFrame = {0x79EAC9C5, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IHlinkSite = {0x79EAC9C2, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IHlinkTarget = {0x79EAC9C4, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IHNetApplicationProtocol = {0x85D18B7F, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHNetBridge = {0x85D18B75, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHNetBridgedConnection = {0x85D18B76, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHNetBridgeSettings = {0x85D18B6D, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHNetCfgMgr = {0x85D18B6C, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHNetConnection = {0x85D18B71, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHNetFirewalledConnection = {0x85D18B72, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHNetFirewallSettings = {0x85D18B6E, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHNetIcsPrivateConnection = {0x85D18B74, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHNetIcsPublicConnection = {0x85D18B73, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHNetIcsSettings = {0x85D18B6F, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHNetPortMappingBinding = {0x85D18B80, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHNetPortMappingProtocol = {0x85D18B7E, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHNetProtocolSettings = {0x85D18B70, 0x3032, 0x11D4, [0x93, 0x48, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x71]};
+enum IID IID_IHomePage = {0x766BF2AF, 0xD650, 0x11D1, [0x98, 0x11, 0x00, 0xC0, 0x4F, 0xC3, 0x1D, 0x2E]};
+enum IID IID_IHostBehaviorInit = {0x3050F842, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHostDialogHelper = {0x53DEC138, 0xA51E, 0x11D2, [0x86, 0x1E, 0x00, 0xC0, 0x4F, 0xA3, 0x5C, 0x89]};
+enum IID IID_IHTCAttachBehavior = {0x3050F5F4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTCAttachBehavior2 = {0x3050F7EB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTCDefaultDispatch = {0x3050F4FD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTCDescBehavior = {0x3050F5DC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTCEventBehavior = {0x3050F4FF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTCMethodBehavior = {0x3050F631, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTCPropertyBehavior = {0x3050F5DF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLAnchorElement = {0x3050F1DA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLAnchorElement2 = {0x3050F825, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLAppBehavior = {0x3050F5CA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLAppBehavior2 = {0x3050F5C9, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLAppBehavior3 = {0x3050F5CD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHtmlArea = {0x3050F64E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLAreaElement = {0x3050F265, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLAreasCollection = {0x3050F383, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLAreasCollection2 = {0x3050F5EC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLAreasCollection3 = {0x3050F837, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLAttributeCollection = {0x3050F4C3, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLAttributeCollection2 = {0x3050F80A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLBaseElement = {0x3050F204, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLBaseFontElement = {0x3050F202, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLBGsound = {0x3050F369, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLBlockElement = {0x3050F208, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLBlockElement2 = {0x3050F823, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLBodyElement = {0x3050F1D8, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLBodyElement2 = {0x3050F5C5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLBookmarkCollection = {0x3050F4CE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLBRElement = {0x3050F1F0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLButtonElement = {0x3050F2BB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLCaret = {0x3050F604, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLChangeLog = {0x3050F649, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLChangePlayback = {0x3050F6E0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLChangeSink = {0x3050F64A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLCommentElement = {0x3050F20C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLCommentElement2 = {0x3050F813, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLComputedStyle = {0x3050F6C3, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLControlElement = {0x3050F4E9, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLControlRange = {0x3050F29C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLControlRange2 = {0x3050F65E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLCurrentStyle = {0x3050F3DB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLCurrentStyle2 = {0x3050F658, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLCurrentStyle3 = {0x3050F818, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDatabinding = {0x3050F3F2, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDataTransfer = {0x3050F4B3, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDDElement = {0x3050F1F2, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDialog = {0x3050F216, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDialog2 = {0x3050F5E0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDialog3 = {0x3050F388, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDivElement = {0x3050F200, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDivPosition = {0x3050F212, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHtmlDlgSafeHelper = {0x3050F81A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDListElement = {0x3050F1F1, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDocument = {0x626FC520, 0xA41E, 0x11CF, [0xA7, 0x31, 0x00, 0xA0, 0xC9, 0x08, 0x26, 0x37]};
+enum IID IID_IHTMLDocument2 = {0x332C4425, 0x26CB, 0x11D0, [0xB4, 0x83, 0x00, 0xC0, 0x4F, 0xD9, 0x01, 0x19]};
+enum IID IID_IHTMLDocument3 = {0x3050F485, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDocument4 = {0x3050F69A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDocument5 = {0x3050F80C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDOMAttribute = {0x3050F4B0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDOMAttribute2 = {0x3050F810, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDOMChildrenCollection = {0x3050F5AB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDOMImplementation = {0x3050F80D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDOMNode = {0x3050F5DA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDOMNode2 = {0x3050F80B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDOMTextNode = {0x3050F4B1, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDOMTextNode2 = {0x3050F809, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDTElement = {0x3050F1F3, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLDXTransform = {0x30E2AB7D, 0x4FDD, 0x4159, [0xB7, 0xEA, 0xDC, 0x72, 0x2B, 0xF4, 0xAD, 0xE5]};
+enum IID IID_IHTMLEditDesigner = {0x3050F662, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLEditHost = {0x3050F6A0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLEditHost2 = {0x3050F848, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0D]};
+enum IID IID_IHTMLEditingServices = {0x3050F7FB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLEditor = {0x3050F7FA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLEditServices = {0x3050F663, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLEditServices2 = {0x3050F812, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLElement = {0x3050F1FF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLElement2 = {0x3050F434, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLElement3 = {0x3050F673, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLElement4 = {0x3050F80F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLElementCollection = {0x3050F21F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLElementCollection2 = {0x3050F5EE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLElementCollection3 = {0x3050F835, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLElementDefaults = {0x3050F6C9, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLElementRender = {0x3050F669, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLEmbedElement = {0x3050F25F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLEventObj = {0x3050F32D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLEventObj2 = {0x3050F48B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLEventObj3 = {0x3050F680, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLEventObj4 = {0x3050F814, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFieldSetElement = {0x3050F3E7, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFieldSetElement2 = {0x3050F833, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFilterPainter = {0x3050F6DE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFilterPaintSite = {0x3050F6D3, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFiltersCollection = {0x3050F3EE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFontElement = {0x3050F1D9, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFontNamesCollection = {0x3050F376, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFontSizesCollection = {0x3050F377, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFormElement = {0x3050F1F7, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFormElement2 = {0x3050F4F6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFormElement3 = {0x3050F836, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFrameBase = {0x3050F311, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFrameBase2 = {0x3050F6DB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFrameBase3 = {0x3050F82E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFrameElement = {0x3050F313, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFrameElement2 = {0x3050F7F5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFramesCollection2 = {0x332C4426, 0x26CB, 0x11D0, [0xB4, 0x83, 0x00, 0xC0, 0x4F, 0xD9, 0x01, 0x19]};
+enum IID IID_IHTMLFrameSetElement = {0x3050F319, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLFrameSetElement2 = {0x3050F5C6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLGenericElement = {0x3050F4B7, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLHeadElement = {0x3050F81D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLHeaderElement = {0x3050F1F6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLHRElement = {0x3050F1F4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLHtmlElement = {0x3050F81C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLIFrameElement = {0x3050F315, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLIFrameElement2 = {0x3050F4E6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLImageElementFactory = {0x3050F38E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLImgElement = {0x3050F240, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLImgElement2 = {0x3050F826, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLInputButtonElement = {0x3050F2B2, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLInputElement = {0x3050F5D2, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLInputElement2 = {0x3050F821, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLInputFileElement = {0x3050F2AD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLInputHiddenElement = {0x3050F2A4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLInputImage = {0x3050F2C2, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLInputTextElement = {0x3050F2A6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLIPrintCollection = {0x3050F6B5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLIsIndexElement = {0x3050F206, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLIsIndexElement2 = {0x3050F82F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLLabelElement = {0x3050F32A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLLabelElement2 = {0x3050F832, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLLegendElement = {0x3050F3EA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLLegendElement2 = {0x3050F834, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLLIElement = {0x3050F1E0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLLinkElement = {0x3050F205, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLLinkElement2 = {0x3050F4E5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLLinkElement3 = {0x3050F81E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLListElement = {0x3050F20E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLListElement2 = {0x3050F822, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHtmlLoadOptions = {0xA71A0808, 0x0F88, 0x11D1, [0xBA, 0x19, 0x00, 0xC0, 0x4F, 0xD9, 0x12, 0xD0]};
+enum IID IID_IHTMLLocation = {0x163BB1E0, 0x6E00, 0x11CF, [0x83, 0x7A, 0x48, 0xDC, 0x04, 0xC1, 0x00, 0x00]};
+enum IID IID_IHTMLMapElement = {0x3050F266, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLMarqueeElement = {0x3050F2B5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLMetaElement = {0x3050F203, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLMetaElement2 = {0x3050F81F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLMimeTypesCollection = {0x3050F3FC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLModelessInit = {0x3050F5E4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLNamespace = {0x3050F6BB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLNamespaceCollection = {0x3050F6B8, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLNextIdElement = {0x3050F207, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLNoShowElement = {0x3050F38A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLObjectElement = {0x3050F24F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLObjectElement2 = {0x3050F4CD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLObjectElement3 = {0x3050F827, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLOListElement = {0x3050F1DE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLOMWindowServices = {0x3050F5FC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLOpsProfile = {0x3050F401, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLOptionButtonElement = {0x3050F2BC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLOptionElement = {0x3050F211, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLOptionElement2 = {0x3050F697, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLOptionElement3 = {0x3050F820, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLOptionElementFactory = {0x3050F38C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLOptionsHolder = {0x3050F378, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLPainter = {0x3050F6A6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLPainterEventInfo = {0x3050F6DF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLPainterOverlay = {0x3050F7E3, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLPaintSite = {0x3050F6A7, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLParaElement = {0x3050F1F5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLParamElement = {0x3050F83D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLPersistData = {0x3050F4C5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLPersistDataOM = {0x3050F4C0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLPhraseElement = {0x3050F20A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLPhraseElement2 = {0x3050F824, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLPluginsCollection = {0x3050F3FD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLPopup = {0x3050F666, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLPrivateWindow = {0x3050F6DC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLPrivateWindow2 = {0x3050F7E5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLPrivateWindow3 = {0x3050F840, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLRect = {0x3050F4A3, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLRectCollection = {0x3050F4A4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLRenderStyle = {0x3050F6AE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLRuleStyle = {0x3050F3CF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLRuleStyle2 = {0x3050F4AC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLRuleStyle3 = {0x3050F657, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLRuleStyle4 = {0x3050F817, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLScreen = {0x3050F35C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLScreen2 = {0x3050F84A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLScriptElement = {0x3050F28B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLScriptElement2 = {0x3050F828, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLSelectElement = {0x3050F244, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLSelectElement2 = {0x3050F5ED, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLSelectElement3 = {0x3050F687, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLSelectElement4 = {0x3050F838, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLSelectionObject = {0x3050F25A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLSelectionObject2 = {0x3050F7EC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLSpanElement = {0x3050F3F3, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLSpanFlow = {0x3050F3E5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLStyle = {0x3050F25E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLStyle2 = {0x3050F4A2, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLStyle3 = {0x3050F656, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLStyle4 = {0x3050F816, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLStyleElement = {0x3050F375, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLStyleFontFace = {0x3050F3D5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLStyleSheet = {0x3050F2E3, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLStyleSheet2 = {0x3050F3D1, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLStyleSheetPage = {0x3050F7EE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLStyleSheetPagesCollection = {0x3050F7F0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLStyleSheetRule = {0x3050F357, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLStyleSheetRulesCollection = {0x3050F2E5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLStyleSheetsCollection = {0x3050F37E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLSubmitData = {0x3050F645, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTable = {0x3050F21E, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTable2 = {0x3050F4AD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTable3 = {0x3050F829, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTableCaption = {0x3050F2EB, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTableCell = {0x3050F23D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTableCell2 = {0x3050F82D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTableCol = {0x3050F23A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTableCol2 = {0x3050F82A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTableRow = {0x3050F23C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTableRow2 = {0x3050F4A1, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTableRow3 = {0x3050F82C, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTableRowMetrics = {0x3050F413, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTableSection = {0x3050F23B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTableSection2 = {0x3050F5C7, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTableSection3 = {0x3050F82B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTextAreaElement = {0x3050F2AA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTextContainer = {0x3050F230, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTextElement = {0x3050F218, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTextRangeMetrics = {0x3050F40B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTextRangeMetrics2 = {0x3050F4A6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTitleElement = {0x3050F322, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTxtRange = {0x3050F220, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLTxtRangeCollection = {0x3050F7ED, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLUListElement = {0x3050F1DD, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLUniqueName = {0x3050F4D0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLUnknownElement = {0x3050F209, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLUrnCollection = {0x3050F5E2, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLUserDataOM = {0x3050F48F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLViewFilter = {0x3050F2F1, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLViewFilterSite = {0x3050F2F4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLWindow2 = {0x332C4427, 0x26CB, 0x11D0, [0xB4, 0x83, 0x00, 0xC0, 0x4F, 0xD9, 0x01, 0x19]};
+enum IID IID_IHTMLWindow3 = {0x3050F4AE, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHTMLWindow4 = {0x3050F6CF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IHttpNegotiate = {0x79EAC9D2, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IHttpNegotiate2 = {0x4F9F9FCB, 0xE0F4, 0x48EB, [0xB7, 0xAB, 0xFA, 0x2E, 0xA9, 0x36, 0x5C, 0xB4]};
+enum IID IID_IHttpSecurity = {0x79EAC9D7, 0xBAFA, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IHWEventHandler = {0xC1FB73D0, 0xEC3A, 0x4BA2, [0xB5, 0x12, 0x8C, 0xDB, 0x91, 0x87, 0xB6, 0xD1]};
+enum IID IID_IImageDecodeEventSink = {0xBAA342A0, 0x2DED, 0x11D0, [0x86, 0xF4, 0x00, 0xA0, 0xC9, 0x13, 0xF7, 0x50]};
+enum IID IID_IImageDecodeFilter = {0xA3CCEDF3, 0x2DE2, 0x11D0, [0x86, 0xF4, 0x00, 0xA0, 0xC9, 0x13, 0xF7, 0x50]};
+enum IID IID_IImageList = {0x46EB5926, 0x582E, 0x4017, [0x9F, 0xDF, 0xE8, 0x99, 0x8D, 0xAA, 0x09, 0x50]};
+enum IID IID_IIMEServices = {0x3050F6CA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IImgCtx = {0x3050F3D7, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IIndexDefinition = {0x0C733A68, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IInputObject = {0x68284FAA, 0x6A48, 0x11D0, [0x8C, 0x78, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xB4]};
+enum IID IID_IInputObjectSite = {0xF1DB8392, 0x7331, 0x11D0, [0x8C, 0x99, 0x00, 0xA0, 0xC9, 0x2D, 0xBF, 0xE8]};
+enum IID IID_IIntDitherer = {0x06670CA0, 0xECEF, 0x11D0, [0xAA, 0xE7, 0x00, 0xC0, 0x4F, 0xC9, 0xB3, 0x04]};
+enum IID IID_IIntelliForms = {0x9B9F68E6, 0x1AAA, 0x11D2, [0xBC, 0xA5, 0x00, 0xC0, 0x4F, 0xD9, 0x29, 0xDB]};
+enum IID IID_IInterfaceRelated = {0xD1FB5A79, 0x7706, 0x11D1, [0xAD, 0xBA, 0x00, 0xC0, 0x4F, 0xC2, 0xAD, 0xC0]};
+enum IID IID_IInternalMoniker = {0x00000011, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IInternalUnknown = {0x00000021, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IInternet = {0x79EAC9E0, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IInternetBindInfo = {0x79EAC9E1, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IInternetConnectionDevice = {0x04DF6137, 0x5610, 0x11D4, [0x9E, 0xC8, 0x00, 0xB0, 0xD0, 0x22, 0xDD, 0x1F]};
+enum IID IID_IInternetConnectionDeviceClient = {0x04DF6139, 0x5610, 0x11D4, [0x9E, 0xC8, 0x00, 0xB0, 0xD0, 0x22, 0xDD, 0x1F]};
+enum IID IID_IInternetConnectionDeviceSharedCo = {0x04DF6138, 0x5610, 0x11D4, [0x9E, 0xC8, 0x00, 0xB0, 0xD0, 0x22, 0xDD, 0x1F]};
+enum IID IID_IInternetHostSecurityManager = {0x3AF280B6, 0xCB3F, 0x11D0, [0x89, 0x1E, 0x00, 0xC0, 0x4F, 0xB6, 0xBF, 0xC4]};
+enum IID IID_IInternetPriority = {0x79EAC9EB, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IInternetProtocol = {0x79EAC9E4, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IInternetProtocolInfo = {0x79EAC9EC, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IInternetProtocolRoot = {0x79EAC9E3, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IInternetProtocolSink = {0x79EAC9E5, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IInternetProtocolSinkStackable = {0x79EAC9F0, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IInternetSecurityManager = {0x79EAC9EE, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IInternetSecurityMgrSite = {0x79EAC9ED, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IInternetSession = {0x79EAC9E7, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IInternetThreadSwitch = {0x79EAC9E8, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IInternetZoneManager = {0x79EAC9EF, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IIpxAdapterInfo = {0x98133270, 0x4B20, 0x11D1, [0xAB, 0x01, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_IItemNameLimits = {0x1DF0D7F1, 0xB267, 0x4D28, [0x8B, 0x10, 0x12, 0xE2, 0x32, 0x02, 0xA5, 0xC4]};
+enum IID IID_IJolietDiscMaster = {0xE3BC42CE, 0x4E5C, 0x11D3, [0x91, 0x44, 0x00, 0x10, 0x4B, 0xA1, 0x1C, 0x5E]};
+enum IID IID_IKeyFrameControl = {0xC3341386, 0xAF91, 0x4EF9, [0x83, 0xB6, 0xBE, 0x37, 0x62, 0xE4, 0x2E, 0xCB]};
+enum IID IID_IKsControl = {0x28F54685, 0x06FD, 0x11D2, [0xB2, 0x7A, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96]};
+enum IID IID_IKsPropertySet = {0x31EFAC30, 0x515C, 0x11D0, [0xA9, 0xAA, 0x00, 0xAA, 0x00, 0x61, 0xBE, 0x93]};
+enum IID IID_ILayoutRect = {0x3050F665, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ILayoutStorage = {0x0E6D4D90, 0x6738, 0x11CF, [0x96, 0x08, 0x00, 0xAA, 0x00, 0x68, 0x0D, 0xB4]};
+enum IID IID_ILineInfo = {0x3050F7E2, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ILocalMachine = {0x60664CAF, 0xAF0D, 0x1005, [0xA3, 0x00, 0x5C, 0x7D, 0x25, 0xFF, 0x22, 0xA0]};
+enum IID IID_ILockBytes = {0x0000000A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ILogger = {0xD9598418, 0x304E, 0x4F94, [0xB6, 0xA1, 0xE6, 0x42, 0xFE, 0x95, 0xED, 0x57]};
+enum IID IID_ILogManager = {0x4759DC11, 0x8DA0, 0x4261, [0xBB, 0xFB, 0xEC, 0x32, 0x19, 0x11, 0xD1, 0xC9]};
+enum IID IID_ILogonEnumUsers = {0x60664CAF, 0xAF0D, 0x1004, [0xA3, 0x00, 0x5C, 0x7D, 0x25, 0xFF, 0x22, 0xA0]};
+enum IID IID_ILogonStatusHost = {0x60664CAF, 0xAF0D, 0x1007, [0xA3, 0x00, 0x5C, 0x7D, 0x25, 0xFF, 0x22, 0xA0]};
+enum IID IID_ILogonUser = {0x60664CAF, 0xAF0D, 0x1003, [0xA3, 0x00, 0x5C, 0x7D, 0x25, 0xFF, 0x22, 0xA0]};
+enum IID IID_IMachineDebugManager = {0x51973C2C, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IMachineDebugManagerCookie = {0x51973C2D, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IMachineDebugManagerEvents = {0x51973C2E, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IMailAutoDiscovery = {0x80402DEE, 0xB114, 0x4D32, [0xB4, 0x4E, 0x82, 0xFD, 0x82, 0x34, 0xC9, 0x2A]};
+enum IID IID_IMailProtocolADEntry = {0x40EF8C68, 0xD554, 0x47ED, [0xAA, 0x37, 0xE5, 0xFB, 0x6B, 0xC9, 0x10, 0x75]};
+enum IID IID_IMalloc = {0x00000002, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IMallocSpy = {0x0000001D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IMapMIMEToCLSID = {0xD9E89500, 0x30FA, 0x11D0, [0xB7, 0x24, 0x00, 0xAA, 0x00, 0x6C, 0x1A, 0x01]};
+enum IID IID_IMarkupContainer = {0x3050F5F9, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IMarkupContainer2 = {0x3050F648, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IMarkupPointer = {0x3050F49F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IMarkupPointer2 = {0x3050F675, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IMarkupServices = {0x3050F4A0, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IMarkupServices2 = {0x3050F682, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IMarkupTextFrags = {0x3050F5FA, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IMarshal = {0x00000003, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IMarshal2 = {0x000001CF, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IMcastAddressAllocation = {0xDF0DAEF1, 0xA289, 0x11D1, [0x86, 0x97, 0x00, 0x60, 0x08, 0xB0, 0xE5, 0xD2]};
+enum IID IID_IMcastLeaseInfo = {0xDF0DAEFD, 0xA289, 0x11D1, [0x86, 0x97, 0x00, 0x60, 0x08, 0xB0, 0xE5, 0xD2]};
+enum IID IID_IMcastScope = {0xDF0DAEF4, 0xA289, 0x11D1, [0x86, 0x97, 0x00, 0x60, 0x08, 0xB0, 0xE5, 0xD2]};
+enum IID IID_IMDDataset = {0xA07CCCD1, 0x8148, 0x11D0, [0x87, 0xBB, 0x00, 0xC0, 0x4F, 0xC3, 0x39, 0x42]};
+enum IID IID_IMDFind = {0xA07CCCD2, 0x8148, 0x11D0, [0x87, 0xBB, 0x00, 0xC0, 0x4F, 0xC3, 0x39, 0x42]};
+enum IID IID_IMDRangeRowset = {0x0C733AA0, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IMessageFilter = {0x00000016, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IMigrationWizardAuto = {0xCE20DAB9, 0xB353, 0x469B, [0x8B, 0x4D, 0x6D, 0xBB, 0x3A, 0x7B, 0xA0, 0x16]};
+enum IID IID_IMimeInfo = {0xF77459A0, 0xBF9A, 0x11CF, [0xBA, 0x4E, 0x00, 0xC0, 0x4F, 0xD7, 0x08, 0x16]};
+enum IID IID_IMLangCodePages = {0x359F3443, 0xBD4A, 0x11D0, [0xB1, 0x88, 0x00, 0xAA, 0x00, 0x38, 0xC9, 0x69]};
+enum IID IID_IMLangConvertCharset = {0xD66D6F98, 0xCDAA, 0x11D0, [0xB8, 0x22, 0x00, 0xC0, 0x4F, 0xC9, 0xB3, 0x1F]};
+enum IID IID_IMLangFontLink = {0x359F3441, 0xBD4A, 0x11D0, [0xB1, 0x88, 0x00, 0xAA, 0x00, 0x38, 0xC9, 0x69]};
+enum IID IID_IMLangFontLink2 = {0xDCCFC162, 0x2B38, 0x11D2, [0xB7, 0xEC, 0x00, 0xC0, 0x4F, 0x8F, 0x5D, 0x9A]};
+enum IID IID_IMLangLineBreakConsole = {0xF5BE2EE1, 0xBFD7, 0x11D0, [0xB1, 0x88, 0x00, 0xAA, 0x00, 0x38, 0xC9, 0x69]};
+enum IID IID_IMLangString = {0xC04D65CE, 0xB70D, 0x11D0, [0xB1, 0x88, 0x00, 0xAA, 0x00, 0x38, 0xC9, 0x69]};
+enum IID IID_IMLangStringAStr = {0xC04D65D2, 0xB70D, 0x11D0, [0xB1, 0x88, 0x00, 0xAA, 0x00, 0x38, 0xC9, 0x69]};
+enum IID IID_IMLangStringBufA = {0xD24ACD23, 0xBA72, 0x11D0, [0xB1, 0x88, 0x00, 0xAA, 0x00, 0x38, 0xC9, 0x69]};
+enum IID IID_IMLangStringBufW = {0xD24ACD21, 0xBA72, 0x11D0, [0xB1, 0x88, 0x00, 0xAA, 0x00, 0x38, 0xC9, 0x69]};
+enum IID IID_IMLangStringWStr = {0xC04D65D0, 0xB70D, 0x11D0, [0xB1, 0x88, 0x00, 0xAA, 0x00, 0x38, 0xC9, 0x69]};
+enum IID IID_IMofCompiler = {0x6DAF974E, 0x2E37, 0x11D2, [0xAE, 0xC9, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID IID_IMoniker = {0x0000000F, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IMonikerProp = {0xA5CA5F7F, 0x1847, 0x4D87, [0x9C, 0x5B, 0x91, 0x85, 0x09, 0xF7, 0x51, 0x1D]};
+enum IID IID_IMountedVolume = {0x12518492, 0x00B2, 0x11D2, [0x9F, 0xA5, 0x9E, 0x34, 0x20, 0x52, 0x41, 0x53]};
+enum IID IID_IMulticastControl = {0x410FA507, 0x4DC6, 0x415A, [0x90, 0x14, 0x63, 0x38, 0x75, 0xD5, 0x40, 0x6E]};
+enum IID IID_IMultiLanguage = {0x275C23E1, 0x3747, 0x11D0, [0x9F, 0xEA, 0x00, 0xAA, 0x00, 0x3F, 0x86, 0x46]};
+enum IID IID_IMultiLanguage2 = {0xDCCFC164, 0x2B38, 0x11D2, [0xB7, 0xEC, 0x00, 0xC0, 0x4F, 0x8F, 0x5D, 0x9A]};
+enum IID IID_IMultiLanguage3 = {0x4E5868AB, 0xB157, 0x4623, [0x9A, 0xCC, 0x6A, 0x1D, 0x9C, 0xAE, 0xBE, 0x04]};
+enum IID IID_IMultiplePropertyAccess = {0xEC81FEDE, 0xD432, 0x11CE, [0x92, 0x44, 0x00, 0x20, 0xAF, 0x6E, 0x72, 0xDB]};
+enum IID IID_IMultipleResults = {0x0C733A90, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IMultiQI = {0x00000020, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_INamedPropertyBag = {0xFB700430, 0x952C, 0x11D1, [0x94, 0x6F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]};
+enum IID IID_INATEventManager = {0x624BD588, 0x9060, 0x4109, [0xB0, 0xB0, 0x1A, 0xDB, 0xBC, 0xAC, 0x32, 0xDF]};
+enum IID IID_INATExternalIPAddressCallback = {0x9C416740, 0xA34E, 0x446F, [0xBA, 0x06, 0xAB, 0xD0, 0x4C, 0x31, 0x49, 0xAE]};
+enum IID IID_INATNumberOfEntriesCallback = {0xC83A0A74, 0x91EE, 0x41B6, [0xB6, 0x7A, 0x67, 0xE0, 0xF0, 0x0B, 0xBD, 0x78]};
+enum IID IID_INetCfg = {0xC0E8AE93, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetCfgBindingInterface = {0xC0E8AE94, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetCfgBindingPath = {0xC0E8AE96, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetCfgClass = {0xC0E8AE97, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetCfgClassSetup = {0xC0E8AE9D, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetCfgComponent = {0xC0E8AE99, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetCfgComponentBindings = {0xC0E8AE9E, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetCfgComponentControl = {0x932238DF, 0xBEA1, 0x11D0, [0x92, 0x98, 0x00, 0xC0, 0x4F, 0xC9, 0x9D, 0xCF]};
+enum IID IID_INetCfgComponentNotifyBinding = {0x932238E1, 0xBEA1, 0x11D0, [0x92, 0x98, 0x00, 0xC0, 0x4F, 0xC9, 0x9D, 0xCF]};
+enum IID IID_INetCfgComponentNotifyGlobal = {0x932238E2, 0xBEA1, 0x11D0, [0x92, 0x98, 0x00, 0xC0, 0x4F, 0xC9, 0x9D, 0xCF]};
+enum IID IID_INetCfgComponentPrivate = {0x98133273, 0x4B20, 0x11D1, [0xAB, 0x01, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetCfgComponentPropertyUi = {0x932238E0, 0xBEA1, 0x11D0, [0x92, 0x98, 0x00, 0xC0, 0x4F, 0xC9, 0x9D, 0xCF]};
+enum IID IID_INetCfgComponentSetup = {0x932238E3, 0xBEA1, 0x11D0, [0x92, 0x98, 0x00, 0xC0, 0x4F, 0xC9, 0x9D, 0xCF]};
+enum IID IID_INetCfgComponentSysPrep = {0xC0E8AE9A, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetCfgComponentUpperEdge = {0x932238E4, 0xBEA1, 0x11D0, [0x92, 0x98, 0x00, 0xC0, 0x4F, 0xC9, 0x9D, 0xCF]};
+enum IID IID_INetCfgInternalSetup = {0x98133276, 0x4B20, 0x11D1, [0xAB, 0x01, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetCfgLock = {0xC0E8AE9F, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetCfgPnpReconfigCallback = {0x8D84BD35, 0xE227, 0x11D2, [0xB7, 0x00, 0x00, 0xA0, 0xC9, 0x8A, 0x6A, 0x85]};
+enum IID IID_INetCfgSpecialCase = {0xC0E8AE95, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetCfgSysPrep = {0xC0E8AE98, 0x306E, 0x11D1, [0xAA, 0xCF, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnection = {0xC08956A1, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnection2 = {0xFAEDCF6A, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionBrandingInfo = {0xFAEDCF5B, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionCMUtil = {0xFAEDCF60, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionCommonUi = {0xC08956A5, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionConnectUi = {0xC08956A3, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionHNetUtil = {0xFAEDCF64, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionManager = {0xC08956A2, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionManager2 = {0xFAEDCF69, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionManagerDebug = {0xFAEDCF5D, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionManagerEvents = {0xC08956BA, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionNotifySink = {0xFAEDCF5C, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionPropertyUi = {0xC08956A4, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionPropertyUi2 = {0xC08956B9, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionProps = {0xF4277C95, 0xCE5B, 0x463D, [0x81, 0x67, 0x56, 0x62, 0xD9, 0xBC, 0xAA, 0x72]};
+enum IID IID_INetConnectionRefresh = {0xFAEDCF5F, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionSysTray = {0xFAEDCF65, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionUiLock = {0xFAEDCF50, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionUiUtilities = {0xFAEDCF5E, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionWizardUi = {0xFAEDCF51, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetConnectionWizardUiContext = {0xFAEDCF52, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetCrawler = {0x49C929EE, 0xA1B7, 0x4C58, [0xB5, 0x39, 0xE6, 0x3B, 0xE3, 0x92, 0xB6, 0xF3]};
+enum IID IID_INetDefaultConnection = {0xFAEDCF66, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetInboundConnection = {0xFAEDCF53, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetInstallQueue = {0x98133274, 0x4B20, 0x11D1, [0xAB, 0x01, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetLanConnection = {0xFAEDCF54, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetLanConnectionUiInfo = {0xC08956A6, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetLanConnectionWizardUi = {0xFAEDCF56, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetMachinePolicies = {0xFAEDCF68, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetRasConnection = {0xFAEDCF57, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetRasConnectionIpUiInfo = {0xFAEDCF58, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetSharedAccessConnection = {0xFAEDCF55, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetSharingConfiguration = {0xC08956B6, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetSharingEveryConnectionCollect = {0x33C4643C, 0x7811, 0x46FA, [0xA8, 0x9A, 0x76, 0x85, 0x97, 0xBD, 0x72, 0x23]};
+enum IID IID_INetSharingManager = {0xC08956B7, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetSharingPortMapping = {0xC08956B1, 0x1CD3, 0x11D1, [0xB1, 0xC5, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_INetSharingPortMappingCollection = {0x02E4A2DE, 0xDA20, 0x4E34, [0x89, 0xC8, 0xAC, 0x22, 0x27, 0x5A, 0x01, 0x0B]};
+enum IID IID_INetSharingPortMappingProps = {0x24B7E9B5, 0xE38F, 0x4685, [0x85, 0x1B, 0x00, 0x89, 0x2C, 0xF5, 0xF9, 0x40]};
+enum IID IID_INetSharingPrivateConnectionColle = {0x38AE69E0, 0x4409, 0x402A, [0xA2, 0xCB, 0xE9, 0x65, 0xC7, 0x27, 0xF8, 0x40]};
+enum IID IID_INetSharingPublicConnectionCollec = {0x7D7A6355, 0xF372, 0x4971, [0xA1, 0x49, 0xBF, 0xC9, 0x27, 0xBE, 0x76, 0x2A]};
+enum IID IID_INewShortcutHookA = {0x000214E1, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_INewShortcutHookW = {0x000214F7, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_INewWDEvents = {0x0751C551, 0x7568, 0x41C9, [0x8E, 0x5B, 0xE2, 0x2E, 0x38, 0x91, 0x92, 0x36]};
+enum IID IID_INotification = {0xC733E4A3, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_INotificationHelper = {0xC733E4AB, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_INotificationManager = {0x95531501, 0x8782, 0x4845, [0x90, 0x1D, 0x31, 0x2F, 0x36, 0xBA, 0x6C, 0x6E]};
+enum IID IID_INotificationMgr = {0xC733E4A4, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_INotificationPing = {0xC733E4AC, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_INotificationProcessMgr0 = {0xC733E4AE, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_INotificationReport = {0xC733E4A7, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_INotificationRunning = {0xC733E4AD, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_INotificationSink = {0xC733E4A5, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_INotifyDBEvents = {0xDB526CC0, 0xD188, 0x11CD, [0xAD, 0x48, 0x00, 0xAA, 0x00, 0x3C, 0x9C, 0xB6]};
+enum IID IID_INotifyReplica = {0x99180163, 0xDA16, 0x101A, [0x93, 0x5C, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_INotifyUI = {0xE5E8D401, 0x1A37, 0x4FBF, [0x88, 0x0C, 0x82, 0x6C, 0xC8, 0x95, 0x16, 0xFD]};
+enum IID IID_IObjectAccessControl = {0x0C733AA3, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IObjectIdentity = {0xCA04B7E6, 0x0D21, 0x11D1, [0x8C, 0xC5, 0x00, 0xC0, 0x4F, 0xC2, 0xB0, 0x85]};
+enum IID IID_IObjectManager = {0xD51351DF, 0x6394, 0x4236, [0x97, 0x83, 0x65, 0xED, 0x05, 0x63, 0x10, 0x68]};
+enum IID IID_IObjectSafety = {0xCB5BDC81, 0x93C1, 0x11CF, [0x8F, 0x20, 0x00, 0x80, 0x5F, 0x2C, 0xD0, 0x64]};
+enum IID IID_IObjectWithSite = {0xFC4801A3, 0x2BA9, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID IID_IObjMgr = {0x00BB2761, 0x6A77, 0x11D0, [0xA5, 0x35, 0x00, 0xC0, 0x4F, 0xD7, 0xD0, 0x62]};
+enum IID IID_IOInet = {0x79EAC9E0, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IOInetBindClient = {0x79EAC9E2, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IOInetBindInfo = {0x79EAC9E1, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IOInetCache = {0x79EAC9EA, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IOInetPriority = {0x79EAC9EB, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IOInetProtocol = {0x79EAC9E4, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IOInetProtocolInfo = {0x79EAC9EC, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IOInetProtocolRoot = {0x79EAC9E3, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IOInetProtocolSink = {0x79EAC9E5, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IOInetSession = {0x79EAC967, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IOInetThreadSwitch = {0x79EAC968, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IOldSyncMgrRegister = {0x894D8C55, 0xBDDF, 0x11D1, [0xB8, 0x5D, 0x00, 0xC0, 0x4F, 0xB9, 0x39, 0x81]};
+enum IID IID_IOldSyncMgrSynchronize = {0x6295DF28, 0x35EE, 0x11D1, [0x87, 0x07, 0x00, 0xC0, 0x4F, 0xD9, 0x33, 0x27]};
+enum IID IID_IOldSyncMgrSynchronizeCallback = {0x6295DF29, 0x35EE, 0x11D1, [0x87, 0x07, 0x00, 0xC0, 0x4F, 0xD9, 0x33, 0x27]};
+enum IID IID_IOleAdviseHolder = {0x00000111, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleCache = {0x0000011E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleCache2 = {0x00000128, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleCacheControl = {0x00000129, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleClientSite = {0x00000118, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleCommandTarget = {0xB722BCCB, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]};
+enum IID IID_IOleContainer = {0x0000011B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleControl = {0xB196B288, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IOleControlSite = {0xB196B289, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IOleDocument = {0xB722BCC5, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]};
+enum IID IID_IOleDocumentSite = {0xB722BCC7, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]};
+enum IID IID_IOleDocumentView = {0xB722BCC6, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]};
+enum IID IID_IOleInPlaceActiveObject = {0x00000117, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleInPlaceFrame = {0x00000116, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleInPlaceObject = {0x00000113, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleInPlaceObjectWindowless = {0x1C2056CC, 0x5EF4, 0x101B, [0x8B, 0xC8, 0x00, 0xAA, 0x00, 0x3E, 0x3B, 0x29]};
+enum IID IID_IOleInPlaceSite = {0x00000119, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleInPlaceSiteEx = {0x9C2CAD80, 0x3424, 0x11CF, [0xB6, 0x70, 0x00, 0xAA, 0x00, 0x4C, 0xD6, 0xD8]};
+enum IID IID_IOleInPlaceSiteWindowless = {0x922EADA0, 0x3424, 0x11CF, [0xB6, 0x70, 0x00, 0xAA, 0x00, 0x4C, 0xD6, 0xD8]};
+enum IID IID_IOleInPlaceUIWindow = {0x00000115, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleItemContainer = {0x0000011C, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleLink = {0x0000011D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleManager = {0x0000011F, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleObject = {0x00000112, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleParentUndoUnit = {0xA1FAF330, 0xEF97, 0x11CE, [0x9B, 0xC9, 0x00, 0xAA, 0x00, 0x60, 0x8E, 0x01]};
+enum IID IID_IOlePresObj = {0x00000120, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOleUndoManager = {0xD001F200, 0xEF97, 0x11CE, [0x9B, 0xC9, 0x00, 0xAA, 0x00, 0x60, 0x8E, 0x01]};
+enum IID IID_IOleUndoUnit = {0x894AD3B0, 0xEF97, 0x11CE, [0x9B, 0xC9, 0x00, 0xAA, 0x00, 0x60, 0x8E, 0x01]};
+enum IID IID_IOleWindow = {0x00000114, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOmHistory = {0xFECEAAA2, 0x8405, 0x11CF, [0x8B, 0xA1, 0x00, 0xAA, 0x00, 0x47, 0x6D, 0xA6]};
+enum IID IID_IOmNavigator = {0xFECEAAA5, 0x8405, 0x11CF, [0x8B, 0xA1, 0x00, 0xAA, 0x00, 0x47, 0x6D, 0xA6]};
+enum IID IID_IOpaqueDataInfo = {0x000001A9, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IOpenRowset = {0x0C733A69, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IOplockStorage = {0x8D19C834, 0x8879, 0x11D1, [0x83, 0xE9, 0x00, 0xC0, 0x4F, 0xC2, 0xC6, 0xD4]};
+enum IID IID_IOpsProfileSimple = {0x7DD1362C, 0x28B6, 0x11D2, [0xBC, 0xA7, 0x00, 0xC0, 0x4F, 0xD9, 0x29, 0xDB]};
+enum IID IID_IOptionArray = {0x22B6D492, 0x0F88, 0x11D1, [0xBA, 0x19, 0x00, 0xC0, 0x4F, 0xD9, 0x12, 0xD0]};
+enum IID IID_IOverlappedCompletion = {0x521A28F0, 0xE40B, 0x11CE, [0xB2, 0xC9, 0x00, 0xAA, 0x00, 0x68, 0x09, 0x37]};
+enum IID IID_IOverlappedStream = {0x49384070, 0xE40A, 0x11CE, [0xB2, 0xC9, 0x00, 0xAA, 0x00, 0x68, 0x09, 0x37]};
+enum IID IID_IParentRowset = {0x0C733AAA, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IParseDisplayName = {0x0000011A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IParser = {0x186442B0, 0x472E, 0x11D1, [0x89, 0x52, 0x00, 0xC0, 0x4F, 0xD6, 0x11, 0xD7]};
+enum IID IID_IParserSession = {0x186442B1, 0x472E, 0x11D1, [0x89, 0x52, 0x00, 0xC0, 0x4F, 0xD6, 0x11, 0xD7]};
+enum IID IID_IParserTreeProperties = {0x186442B2, 0x472E, 0x11D1, [0x89, 0x52, 0x00, 0xC0, 0x4F, 0xD6, 0x11, 0xD7]};
+enum IID IID_IParserVerify = {0x186442B3, 0x472E, 0x11D1, [0x89, 0x52, 0x00, 0xC0, 0x4F, 0xD6, 0x11, 0xD7]};
+enum IID IID_IPassportClientServices = {0xB30F7305, 0x5967, 0x45D1, [0xB7, 0xBC, 0xD6, 0xEB, 0x71, 0x63, 0xD7, 0x70]};
+enum IID IID_IPeerFactory = {0x6663F9D3, 0xB482, 0x11D1, [0x89, 0xC6, 0x00, 0xC0, 0x4F, 0xB6, 0xBF, 0xC4]};
+enum IID IID_IPendingProxyConnection = {0xB68E5043, 0x3E3D, 0x4CC2, [0xB9, 0xC1, 0x5F, 0x8F, 0x88, 0xFE, 0xE8, 0x1C]};
+enum IID IID_IPerPropertyBrowsing = {0x376BD3AA, 0x3845, 0x101B, [0x84, 0xED, 0x08, 0x00, 0x2B, 0x2E, 0xC7, 0x13]};
+enum IID IID_IPerPropertyBrowsing2 = {0x51973C54, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IPersist = {0x0000010C, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IPersistentDataChannel = {0xA180E934, 0xD92A, 0x415D, [0x91, 0x44, 0x75, 0x9F, 0x80, 0x54, 0xE8, 0xF6]};
+enum IID IID_IPersistFile = {0x0000010B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IPersistFolder = {0x000214EA, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IPersistFolder2 = {0x1AC3D9F0, 0x175C, 0x11D1, [0x95, 0xBE, 0x00, 0x60, 0x97, 0x97, 0xEA, 0x4F]};
+enum IID IID_IPersistFolder3 = {0xCEF04FDF, 0xFE72, 0x11D2, [0x87, 0xA5, 0x00, 0xC0, 0x4F, 0x68, 0x37, 0xCF]};
+enum IID IID_IPersistHistory = {0x91A565C1, 0xE38F, 0x11D0, [0x94, 0xBF, 0x00, 0xA0, 0xC9, 0x05, 0x5C, 0xBF]};
+enum IID IID_IPersistIDList = {0x1079ACFC, 0x29BD, 0x11D3, [0x8E, 0x0D, 0x00, 0xC0, 0x4F, 0x68, 0x37, 0xD5]};
+enum IID IID_IPersistMemory = {0xBD1AE5E0, 0xA6AE, 0x11CE, [0xBD, 0x37, 0x50, 0x42, 0x00, 0xC1, 0x00, 0x00]};
+enum IID IID_IPersistMoniker = {0x79EAC9C9, 0xBAF9, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IPersistNetConnection = {0xFAEDCF59, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_IPersistPropertyBag = {0x37D84F60, 0x42CB, 0x11CE, [0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]};
+enum IID IID_IPersistPropertyBag2 = {0x22F55881, 0x280B, 0x11D0, [0xA8, 0xA9, 0x00, 0xA0, 0xC9, 0x0C, 0x20, 0x04]};
+enum IID IID_IPersistQuery = {0x1A3114B8, 0xA62E, 0x11D0, [0xA6, 0xC5, 0x00, 0xA0, 0xC9, 0x06, 0xAF, 0x45]};
+enum IID IID_IPersistStorage = {0x0000010A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IPersistStream = {0x00000109, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IPersistStreamInit = {0x7FD52380, 0x4E07, 0x101B, [0xAE, 0x2D, 0x08, 0x00, 0x2B, 0x2E, 0xC7, 0x13]};
+enum IID IID_IPhraseSink = {0xCC906FF0, 0xC058, 0x101A, [0xB5, 0x54, 0x08, 0x00, 0x2B, 0x33, 0xB0, 0xE6]};
+enum IID IID_IPicture = {0x7BF80980, 0xBF32, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID IID_IPictureDisp = {0x7BF80981, 0xBF32, 0x101A, [0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID IID_IPipeByte = {0xDB2F3ACA, 0x2F86, 0x11D1, [0x8E, 0x04, 0x00, 0xC0, 0x4F, 0xB9, 0x98, 0x9A]};
+enum IID IID_IPipeDouble = {0xDB2F3ACE, 0x2F86, 0x11D1, [0x8E, 0x04, 0x00, 0xC0, 0x4F, 0xB9, 0x98, 0x9A]};
+enum IID IID_IPipeLong = {0xDB2F3ACC, 0x2F86, 0x11D1, [0x8E, 0x04, 0x00, 0xC0, 0x4F, 0xB9, 0x98, 0x9A]};
+enum IID IID_IPointerInactive = {0x55980BA0, 0x35AA, 0x11CF, [0xB6, 0x71, 0x00, 0xAA, 0x00, 0x4C, 0xD6, 0xD8]};
+enum IID IID_IPrimaryControlChannel = {0x1A2E8B62, 0x9012, 0x4BE6, [0x84, 0xAE, 0x32, 0xBD, 0x66, 0xBA, 0x65, 0x7A]};
+enum IID IID_IPrint = {0xB722BCC9, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]};
+enum IID IID_IPrintDialogCallback = {0x5852A2C3, 0x6530, 0x11D1, [0xB6, 0xA3, 0x00, 0x00, 0xF8, 0x75, 0x7B, 0xF9]};
+enum IID IID_IPrintDialogServices = {0x509AAEDA, 0x5639, 0x11D1, [0xB6, 0xA1, 0x00, 0x00, 0xF8, 0x75, 0x7B, 0xF9]};
+enum IID IID_IPrivacyServices = {0x3050F84B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IPrivateDispatch = {0x86AB4BBE, 0x65F6, 0x11D1, [0x8C, 0x13, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IPrivateUnknown = {0x89126BAB, 0x6EAD, 0x11D1, [0x8C, 0x18, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0x03]};
+enum IID IID_IPrivSyncMgrSynchronizeInvoke = {0x6295DF2E, 0x35EE, 0x11D1, [0x87, 0x07, 0x00, 0xC0, 0x4F, 0xD9, 0x33, 0x27]};
+enum IID IID_IProcessDebugManager = {0x51973C2F, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IProcessDebugManager32 = {0x51973C2F, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IProcessDebugManager64 = {0x56B9FC1C, 0x63A9, 0x4CC1, [0xAC, 0x21, 0x08, 0x7D, 0x69, 0xA1, 0x7F, 0xAB]};
+enum IID IID_IProcessInitControl = {0x72380D55, 0x8D2B, 0x43A3, [0x85, 0x13, 0x2B, 0x6E, 0xF3, 0x14, 0x34, 0xE9]};
+enum IID IID_IProfferService = {0xCB728B20, 0xF786, 0x11CE, [0x92, 0xAD, 0x00, 0xAA, 0x00, 0xA7, 0x4C, 0xD0]};
+enum IID IID_IProgressDialog = {0xEBBC7C04, 0x315E, 0x11D2, [0xB6, 0x2F, 0x00, 0x60, 0x97, 0xDF, 0x5B, 0xD4]};
+enum IID IID_IProgressNotify = {0xA9D758A0, 0x4617, 0x11CF, [0x95, 0xFC, 0x00, 0xAA, 0x00, 0x68, 0x0D, 0xB4]};
+enum IID IID_IProgSink = {0x3050F371, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IPropertyBag = {0x55272A00, 0x42CB, 0x11CE, [0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]};
+enum IID IID_IPropertyBag2 = {0x22F55882, 0x280B, 0x11D0, [0xA8, 0xA9, 0x00, 0xA0, 0xC9, 0x0C, 0x20, 0x04]};
+enum IID IID_IPropertyBagEx = {0x20011801, 0x5DE6, 0x11D1, [0x8E, 0x38, 0x00, 0xC0, 0x4F, 0xB9, 0x38, 0x6D]};
+enum IID IID_IPropertyFrame = {0xB196B28A, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IPropertyMap = {0xC733E4A2, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_IPropertyMapper = {0xB324B226, 0x41A0, 0x11D0, [0x8C, 0x91, 0x00, 0x20, 0xAF, 0x1D, 0x74, 0x0E]};
+enum IID IID_IPropertyNotifySink = {0x9BFBBC02, 0xEFF1, 0x101A, [0x84, 0xED, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IPropertyPage = {0xB196B28D, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IPropertyPage2 = {0x01E44665, 0x24AC, 0x101B, [0x84, 0xED, 0x08, 0x00, 0x2B, 0x2E, 0xC7, 0x13]};
+enum IID IID_IPropertyPageSite = {0xB196B28C, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IPropertySetContainer = {0xB4FFAE60, 0xA7CA, 0x11CD, [0xB5, 0x8B, 0x00, 0x00, 0x6B, 0x82, 0x91, 0x56]};
+enum IID IID_IPropertySetStorage = {0x0000013A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IPropertyStorage = {0x00000138, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IPropertyUI = {0x757A7D9F, 0x919A, 0x4118, [0x99, 0xD7, 0xDB, 0xB2, 0x08, 0xC8, 0xCC, 0x66]};
+enum IID IID_IPropSheetPage = {0x000214F6, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IProvideClassInfo = {0xB196B283, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_IProvideClassInfo2 = {0xA6BC3AC0, 0xDBAA, 0x11CE, [0x9D, 0xE3, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51]};
+enum IID IID_IProvideExpressionContexts = {0x51973C41, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IProvideMoniker = {0x0C733A4D, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IProvideMultipleClassInfo = {0xA7ABA9C1, 0x8983, 0x11CF, [0x8F, 0x20, 0x00, 0x80, 0x5F, 0x2C, 0xD0, 0x64]};
+enum IID IID_IProxy = {0x00000027, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IProxyManager = {0x00000008, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IPSFactory = {0x00000009, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IPSFactoryBuffer = {0xD5F569D0, 0x593B, 0x101A, [0xB5, 0x69, 0x08, 0x00, 0x2B, 0x2D, 0xBF, 0x7A]};
+enum IID IID_IPublishedApp = {0x1BC752E0, 0x9046, 0x11D1, [0xB8, 0xB3, 0x00, 0x60, 0x08, 0x05, 0x93, 0x82]};
+enum IID IID_IPublishingWizard = {0xAA9198BB, 0xCCEC, 0x472D, [0xBE, 0xED, 0x19, 0xA4, 0xF6, 0x73, 0x3F, 0x7A]};
+enum IID IID_IQualityControl = {0x6BC096AB, 0x0CE6, 0x11D1, [0xBA, 0xAE, 0x00, 0xC0, 0x4F, 0xC2, 0xE2, 0x0D]};
+enum IID IID_IQuery = {0x0C733A51, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IQueryAssociations = {0xC46CA590, 0x3C3F, 0x11D2, [0xBE, 0xE6, 0x00, 0x00, 0xF8, 0x05, 0xCA, 0x57]};
+enum IID IID_IQueryCancelAutoPlay = {0xDDEFE873, 0x6997, 0x4E68, [0xBE, 0x26, 0x39, 0xB6, 0x33, 0xAD, 0xBE, 0x12]};
+enum IID IID_IQueryContinue = {0x7307055C, 0xB24A, 0x486B, [0x9F, 0x25, 0x16, 0x3E, 0x59, 0x7A, 0x28, 0xA9]};
+enum IID IID_IQueryForm = {0x8CFCEE30, 0x39BD, 0x11D0, [0xB8, 0xD1, 0x00, 0xA0, 0x24, 0xAB, 0x2D, 0xBB]};
+enum IID IID_IQueryFrame = {0x7E8C7C20, 0x7C9D, 0x11D0, [0x91, 0x3F, 0x00, 0xAA, 0x00, 0xC1, 0x6E, 0x65]};
+enum IID IID_IQueryHandler = {0xA60CC73F, 0xE0FC, 0x11D0, [0x97, 0x50, 0x00, 0xA0, 0xC9, 0x06, 0xAF, 0x45]};
+enum IID IID_IQueryInfo = {0x00021500, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IQuickActivate = {0xCF51ED10, 0x62FE, 0x11CF, [0xBF, 0x86, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0x36]};
+enum IID IID_IRadioButton = {0x3050F69B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IRatingNotification = {0x639447BD, 0xB2D3, 0x44B9, [0x9F, 0xB0, 0x51, 0x0F, 0x23, 0xCB, 0x45, 0xE4]};
+enum IID IID_IReadData = {0x0C733A6A, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IReadEvents = {0xF64AEFDE, 0x3376, 0x11D1, [0xBE, 0x5B, 0x00, 0xC0, 0x4F, 0xC9, 0xE2, 0xBB]};
+enum IID IID_IRecalcEngine = {0x3050F496, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IRecalcHost = {0x3050F497, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IRecalcHostDebug = {0x3050F5F7, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IRecalcProperty = {0x3050F5D6, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IReconcilableObject = {0x99180162, 0xDA16, 0x101A, [0x93, 0x5C, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IReconcileInitiator = {0x99180161, 0xDA16, 0x101A, [0x93, 0x5C, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IRecordInfo = {0x0000002F, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IRedbookDiscMaster = {0xE3BC42CD, 0x4E5C, 0x11D3, [0x91, 0x44, 0x00, 0x10, 0x4B, 0xA1, 0x1C, 0x5E]};
+enum IID IID_IReferenceClock = {0x56A86897, 0x0AD4, 0x11CE, [0xB0, 0x3A, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70]};
+enum IID IID_IRegisterProvider = {0x0C733AB9, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRegisterVirusScanEngine = {0x0825E060, 0xB961, 0x11CF, [0xAA, 0xFA, 0x00, 0xAA, 0x00, 0xB6, 0x01, 0x5C]};
+enum IID IID_IReleaseMarshalBuffers = {0xEB0CB9E8, 0x7996, 0x11D2, [0x87, 0x2E, 0x00, 0x00, 0xF8, 0x08, 0x08, 0x59]};
+enum IID IID_IRemoteCallBack = {0x8947C648, 0x3833, 0x11D1, [0x86, 0x82, 0x00, 0xC0, 0x4F, 0xBF, 0xE1, 0x71]};
+enum IID IID_IRemoteComputer = {0x000214FE, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IRemoteDebugApplication = {0x51973C30, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IRemoteDebugApplicationEvents = {0x51973C33, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IRemoteDebugApplicationEx = {0x51973C01, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IRemoteDebugApplicationThread = {0x51973C37, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_IRemoteDebugApplicationThreadEx = {0xB9B32B0C, 0x9147, 0x11D1, [0x94, 0xEA, 0x00, 0xC0, 0x4F, 0xA3, 0x02, 0xA1]};
+enum IID IID_IRemoteDelaydC = {0x394540A0, 0x6FCF, 0x11D0, [0xAC, 0xE0, 0x00, 0x00, 0xF8, 0x01, 0x14, 0xD3]};
+enum IID IID_IRemoteESP = {0xE99A04AB, 0xAB95, 0x11D0, [0xBE, 0x96, 0x00, 0xA0, 0xC9, 0x49, 0x89, 0xDE]};
+enum IID IID_IRemoteFinder = {0x944AD532, 0xB09D, 0x11CE, [0xB5, 0x9C, 0x00, 0xAA, 0x00, 0x6C, 0xB3, 0x7D]};
+enum IID IID_IRemoteStats = {0x944AD531, 0xB09D, 0x11CE, [0xB5, 0x9C, 0x00, 0xAA, 0x00, 0x6C, 0xB3, 0x7D]};
+enum IID IID_IRequest = {0x6BC096A7, 0x0CE6, 0x11D1, [0xBA, 0xAE, 0x00, 0xC0, 0x4F, 0xC2, 0xE2, 0x0D]};
+enum IID IID_IRequestHandler = {0x6BC096AA, 0x0CE6, 0x11D1, [0xBA, 0xAE, 0x00, 0xC0, 0x4F, 0xC2, 0xE2, 0x0D]};
+enum IID IID_IRequestSource = {0x6BC096A9, 0x0CE6, 0x11D1, [0xBA, 0xAE, 0x00, 0xC0, 0x4F, 0xC2, 0xE2, 0x0D]};
+enum IID IID_IRequestState = {0x6BC096BA, 0x0CE6, 0x11D1, [0xBA, 0xAE, 0x00, 0xC0, 0x4F, 0xC2, 0xE2, 0x0D]};
+enum IID IID_IResolveShellLink = {0x5CD52983, 0x9449, 0x11D2, [0x96, 0x3A, 0x00, 0xC0, 0x4F, 0x79, 0xAD, 0xF0]};
+enum IID IID_IRichEditOle = {0x00020D00, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IRichEditOleCallback = {0x00020D03, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IRootStorage = {0x00000012, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IROTData = {0xF29F6BC0, 0x5021, 0x11CE, [0xAA, 0x15, 0x00, 0x00, 0x69, 0x01, 0x29, 0x3F]};
+enum IID IID_IRow = {0x0C733AB4, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowChange = {0x0C733AB5, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowInfo = {0x0C733AC1, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowPosition = {0x0C733A94, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowPositionChange = {0x0997A571, 0x126E, 0x11D0, [0x9F, 0x8A, 0x00, 0xA0, 0xC9, 0xA0, 0x63, 0x1E]};
+enum IID IID_IRowSchemaChange = {0x0C733AAE, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowset = {0x0C733A7C, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetAsynch = {0x0C733A0F, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetBookmark = {0x0C733AC2, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetChange = {0x0C733A05, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetChapterMember = {0x0C733AA8, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetCopyRows = {0x0C733A6B, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetCurrentIndex = {0x0C733ABD, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetExactScroll = {0x0C733A7F, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetFind = {0x0C733A9D, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetIdentity = {0x0C733A09, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetIndex = {0x0C733A82, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetInfo = {0x0C733A55, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetKeys = {0x0C733A12, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetLocate = {0x0C733A7D, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetNewRowAfter = {0x0C733A71, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetNextRowset = {0x0C733A72, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetNotify = {0x0C733A83, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetQueryStatus = {0xA7AC77ED, 0xF8D7, 0x11CE, [0xA7, 0x98, 0x00, 0x20, 0xF8, 0x00, 0x80, 0x24]};
+enum IID IID_IRowsetRefresh = {0x0C733AA9, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetResynch = {0x0C733A84, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetScroll = {0x0C733A7E, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetUpdate = {0x0C733A6D, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetView = {0x0C733A99, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetWatchAll = {0x0C733A73, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetWatchNotify = {0x0C733A44, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetWatchRegion = {0x0C733A45, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRowsetWithParameters = {0x0C733A6E, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IRpcChannel = {0x00000004, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IRpcChannelBuffer = {0xD5F56B60, 0x593B, 0x101A, [0xB5, 0x69, 0x08, 0x00, 0x2B, 0x2D, 0xBF, 0x7A]};
+enum IID IID_IRpcChannelBuffer2 = {0x594F31D0, 0x7F19, 0x11D0, [0xB1, 0x94, 0x00, 0xA0, 0xC9, 0x0D, 0xC8, 0xBF]};
+enum IID IID_IRpcChannelBuffer3 = {0x25B15600, 0x0115, 0x11D0, [0xBF, 0x0D, 0x00, 0xAA, 0x00, 0xB8, 0xDF, 0xD2]};
+enum IID IID_IRpcHelper = {0x00000149, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IRpcOptions = {0x00000144, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IRpcProxy = {0x00000007, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IRpcProxyBuffer = {0xD5F56A34, 0x593B, 0x101A, [0xB5, 0x69, 0x08, 0x00, 0x2B, 0x2D, 0xBF, 0x7A]};
+enum IID IID_IRpcStub = {0x00000005, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IRpcStubBuffer = {0xD5F56AFC, 0x593B, 0x101A, [0xB5, 0x69, 0x08, 0x00, 0x2B, 0x2D, 0xBF, 0x7A]};
+enum IID IID_IRpcSyntaxNegotiate = {0x58A08519, 0x24C8, 0x4935, [0xB4, 0x82, 0x3F, 0xD8, 0x23, 0x33, 0x3A, 0x4F]};
+enum IID IID_IRTC = {0x4811EA40, 0xB582, 0x11CE, [0xB5, 0xAF, 0x00, 0xAA, 0x00, 0x6C, 0xB3, 0x7D]};
+enum IID IID_IRTCBuddy = {0xFCB136C8, 0x7B90, 0x4E0C, [0xBE, 0xFE, 0x56, 0xED, 0xF0, 0xBA, 0x6F, 0x1C]};
+enum IID IID_IRTCBuddyEvent = {0xF36D755D, 0x17E6, 0x404E, [0x95, 0x4F, 0x0F, 0xC0, 0x75, 0x74, 0xC7, 0x8D]};
+enum IID IID_IRTCClient = {0x07829E45, 0x9A34, 0x408E, [0xA0, 0x11, 0xBD, 0xDF, 0x13, 0x48, 0x7C, 0xD1]};
+enum IID IID_IRTCClientEvent = {0x2B493B7A, 0x3CBA, 0x4170, [0x9C, 0x8B, 0x76, 0xA9, 0xDA, 0xCD, 0xD6, 0x44]};
+enum IID IID_IRTCClientPresence = {0x11C3CBCC, 0x0744, 0x42D1, [0x96, 0x8A, 0x51, 0xAA, 0x1B, 0xB2, 0x74, 0xC6]};
+enum IID IID_IRTCClientProvisioning = {0xB9F5CF06, 0x65B9, 0x4A80, [0xA0, 0xE6, 0x73, 0xCA, 0xE3, 0xEF, 0x38, 0x22]};
+enum IID IID_IRTCCollection = {0xEC7C8096, 0xB918, 0x4044, [0x94, 0xF1, 0xE4, 0xFB, 0xA0, 0x36, 0x1D, 0x5C]};
+enum IID IID_IRTCEnumBuddies = {0xF7296917, 0x5569, 0x4B3B, [0xB3, 0xAF, 0x98, 0xD1, 0x14, 0x4B, 0x2B, 0x87]};
+enum IID IID_IRTCEnumParticipants = {0xFCD56F29, 0x4A4F, 0x41B2, [0xBA, 0x5C, 0xF5, 0xBC, 0xCC, 0x06, 0x0B, 0xF6]};
+enum IID IID_IRTCEnumProfiles = {0x29B7C41C, 0xED82, 0x4BCA, [0x84, 0xAD, 0x39, 0xD5, 0x10, 0x1B, 0x58, 0xE3]};
+enum IID IID_IRTCEnumWatchers = {0xA87D55D7, 0xDB74, 0x4ED1, [0x9C, 0xA4, 0x77, 0xA0, 0xE4, 0x1B, 0x41, 0x3E]};
+enum IID IID_IRTCEventNotification = {0x13FA24C7, 0x5748, 0x4B21, [0x91, 0xF5, 0x73, 0x97, 0x60, 0x9C, 0xE7, 0x47]};
+enum IID IID_IRTCIntensityEvent = {0x4C23BF51, 0x390C, 0x4992, [0xA4, 0x1D, 0x41, 0xEE, 0xC0, 0x5B, 0x2A, 0x4B]};
+enum IID IID_IRTCMediaEvent = {0x099944FB, 0xBCDA, 0x453E, [0x8C, 0x41, 0xE1, 0x3D, 0xA2, 0xAD, 0xF7, 0xF3]};
+enum IID IID_IRTCMessagingEvent = {0xD3609541, 0x1B29, 0x4DE5, [0xA4, 0xAD, 0x5A, 0xEB, 0xAF, 0x31, 0x95, 0x12]};
+enum IID IID_IRTCParticipant = {0xAE86ADD5, 0x26B1, 0x4414, [0xAF, 0x1D, 0xB9, 0x4C, 0xD9, 0x38, 0xD7, 0x39]};
+enum IID IID_IRTCParticipantStateChangeEvent = {0x09BCB597, 0xF0FA, 0x48F9, [0xB4, 0x20, 0x46, 0x8C, 0xEA, 0x7F, 0xDE, 0x04]};
+enum IID IID_IRTCPresenceContact = {0x8B22F92C, 0xCD90, 0x42DB, [0xA7, 0x33, 0x21, 0x22, 0x05, 0xC3, 0xE3, 0xDF]};
+enum IID IID_IRTCProfile = {0xD07ECA9E, 0x4062, 0x4DD4, [0x9E, 0x7D, 0x72, 0x2A, 0x49, 0xBA, 0x73, 0x03]};
+enum IID IID_IRTCProfileEvent = {0xD6D5AB3B, 0x770E, 0x43E8, [0x80, 0x0A, 0x79, 0xB0, 0x62, 0x39, 0x5F, 0xCA]};
+enum IID IID_IRTCRegistrationStateChangeEvent = {0x62D0991B, 0x50AB, 0x4F02, [0xB9, 0x48, 0xCA, 0x94, 0xF2, 0x6F, 0x8F, 0x95]};
+enum IID IID_IRTCSession = {0x387C8086, 0x99BE, 0x42FB, [0x99, 0x73, 0x7C, 0x0F, 0xC0, 0xCA, 0x9F, 0xA8]};
+enum IID IID_IRTCSessionOperationCompleteEven = {0xA6BFF4C0, 0xF7C8, 0x4D3C, [0x9A, 0x41, 0x35, 0x50, 0xF7, 0x8A, 0x95, 0xB0]};
+enum IID IID_IRTCSessionStateChangeEvent = {0xB5BAD703, 0x5952, 0x48B3, [0x93, 0x21, 0x7F, 0x45, 0x00, 0x52, 0x15, 0x06]};
+enum IID IID_IRTCWatcher = {0xC7CEDAD8, 0x346B, 0x4D1B, [0xAC, 0x02, 0xA2, 0x08, 0x8D, 0xF9, 0xBE, 0x4F]};
+enum IID IID_IRTCWatcherEvent = {0xF30D7261, 0x587A, 0x424F, [0x82, 0x2C, 0x31, 0x27, 0x88, 0xF4, 0x35, 0x48]};
+enum IID IID_IRunnableObject = {0x00000126, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IRunnableTask = {0x85788D00, 0x6807, 0x11D0, [0xB8, 0x10, 0x00, 0xC0, 0x4F, 0xD7, 0x06, 0xEC]};
+enum IID IID_IRunningObjectTable = {0x00000010, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IScheduleGroup = {0xC733E4A6, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID IID_IScopedOperations = {0x0C733AB0, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IScriptEntry = {0x0AEE2A95, 0xBCBB, 0x11D0, [0x8C, 0x72, 0x00, 0xC0, 0x4F, 0xC2, 0xB0, 0x85]};
+enum IID IID_IScriptErrorList = {0xF3470F24, 0x15FD, 0x11D2, [0xBB, 0x2E, 0x00, 0x80, 0x5F, 0xF7, 0xEF, 0xCA]};
+enum IID IID_IScriptNode = {0x0AEE2A94, 0xBCBB, 0x11D0, [0x8C, 0x72, 0x00, 0xC0, 0x4F, 0xC2, 0xB0, 0x85]};
+enum IID IID_IScriptScriptlet = {0x0AEE2A96, 0xBCBB, 0x11D0, [0x8C, 0x72, 0x00, 0xC0, 0x4F, 0xC2, 0xB0, 0x85]};
+enum IID IID_IScrollBar = {0x3050F689, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ISdo = {0x56BC53DE, 0x96DB, 0x11D1, [0xBF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]};
+enum IID IID_ISdoCollection = {0x56BC53E2, 0x96DB, 0x11D1, [0xBF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]};
+enum IID IID_ISdoDictionaryOld = {0xD432E5F4, 0x53D8, 0x11D2, [0x9A, 0x3A, 0x00, 0xC0, 0x4F, 0xB9, 0x98, 0xAC]};
+enum IID IID_ISdoMachine = {0x479F6E75, 0x49A2, 0x11D2, [0x8E, 0xCA, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x19]};
+enum IID IID_ISdoServiceControl = {0x479F6E74, 0x49A2, 0x11D2, [0x8E, 0xCA, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x19]};
+enum IID IID_ISearch = {0xBA9239A4, 0x3DD5, 0x11D2, [0xBF, 0x8B, 0x00, 0xC0, 0x4F, 0xB9, 0x36, 0x61]};
+enum IID IID_ISearchAssistantOC = {0x72423E8F, 0x8011, 0x11D2, [0xBE, 0x79, 0x00, 0xA0, 0xC9, 0xA8, 0x3D, 0xA1]};
+enum IID IID_ISearchAssistantOC2 = {0x72423E8F, 0x8011, 0x11D2, [0xBE, 0x79, 0x00, 0xA0, 0xC9, 0xA8, 0x3D, 0xA2]};
+enum IID IID_ISearchAssistantOC3 = {0x72423E8F, 0x8011, 0x11D2, [0xBE, 0x79, 0x00, 0xA0, 0xC9, 0xA8, 0x3D, 0xA3]};
+enum IID IID_ISearchCommandExt = {0x1D2EFD50, 0x75CE, 0x11D1, [0xB7, 0x5A, 0x00, 0xA0, 0xC9, 0x05, 0x64, 0xFE]};
+enum IID IID_ISearchContext = {0x09F656A2, 0x41AF, 0x480C, [0x88, 0xF7, 0x16, 0xCC, 0x0D, 0x16, 0x46, 0x15]};
+enum IID IID_ISearches = {0x47C922A2, 0x3DD5, 0x11D2, [0xBF, 0x8B, 0x00, 0xC0, 0x4F, 0xB9, 0x36, 0x61]};
+enum IID IID_ISearchQueryHits = {0xED8CE7E0, 0x106C, 0x11CE, [0x84, 0xE2, 0x00, 0xAA, 0x00, 0x4B, 0x99, 0x86]};
+enum IID IID_ISecondaryControlChannel = {0xA23F9D10, 0x714C, 0x41FE, [0x84, 0x71, 0xFF, 0xB1, 0x9B, 0xC2, 0x84, 0x54]};
+enum IID IID_ISecureUrlHost = {0xC81984C4, 0x74C8, 0x11D2, [0xBA, 0xA9, 0x00, 0xC0, 0x4F, 0xC2, 0x04, 0x0E]};
+enum IID IID_ISecurityInfo = {0x0C733AA4, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ISegment = {0x3050F683, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ISegmentList = {0x3050F605, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ISegmentListIterator = {0x3050F692, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ISelectionObject2 = {0x3050F7FC, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ISelectionServices = {0x3050F684, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ISelectionServicesListener = {0x3050F699, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ISensLogon = {0xD597BAB3, 0x5B9F, 0x11D1, [0x8D, 0xD2, 0x00, 0xAA, 0x00, 0x4A, 0xBD, 0x5E]};
+enum IID IID_ISensLogon2 = {0xD597BAB4, 0x5B9F, 0x11D1, [0x8D, 0xD2, 0x00, 0xAA, 0x00, 0x4A, 0xBD, 0x5E]};
+enum IID IID_ISensNetwork = {0xD597BAB1, 0x5B9F, 0x11D1, [0x8D, 0xD2, 0x00, 0xAA, 0x00, 0x4A, 0xBD, 0x5E]};
+enum IID IID_ISensOnNow = {0xD597BAB2, 0x5B9F, 0x11D1, [0x8D, 0xD2, 0x00, 0xAA, 0x00, 0x4A, 0xBD, 0x5E]};
+enum IID IID_ISequenceNumber = {0x3050F6C1, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ISequentialStream = {0x0C733A30, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IServerSecurity = {0x0000013E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IServiceProvider = {0x6D5140C1, 0x7436, 0x11CE, [0x80, 0x34, 0x00, 0xAA, 0x00, 0x60, 0x09, 0xFA]};
+enum IID IID_ISessionProperties = {0x0C733A85, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ISetNextStatement = {0x51973C03, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_ISharedAccessBeacon = {0xFAEDCF6B, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_ISharedAccessBeaconFinder = {0xFAEDCF67, 0x31FE, 0x11D1, [0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_IShellApp = {0xA3E14960, 0x935F, 0x11D1, [0xB8, 0xB8, 0x00, 0x60, 0x08, 0x05, 0x93, 0x82]};
+enum IID IID_IShellBrowser = {0x000214E2, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IShellChangeNotify = {0xD82BE2B1, 0x5764, 0x11D0, [0xA9, 0x6E, 0x00, 0xC0, 0x4F, 0xD7, 0x05, 0xA2]};
+enum IID IID_IShellCopyHookA = {0x000214EF, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IShellCopyHookW = {0x000214FC, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IShellDetails = {0x000214EC, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IShellDetails3 = {0xD2A105C0, 0x87D5, 0x11D1, [0x83, 0x91, 0x00, 0x00, 0xF8, 0x04, 0x61, 0xCF]};
+enum IID IID_IShellDispatch = {0xD8F015C0, 0xC278, 0x11CE, [0xA4, 0x9E, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IShellDispatch2 = {0xA4C6892C, 0x3BA9, 0x11D2, [0x9D, 0xEA, 0x00, 0xC0, 0x4F, 0xB1, 0x61, 0x62]};
+enum IID IID_IShellDispatch3 = {0x177160CA, 0xBB5A, 0x411C, [0x84, 0x1D, 0xBD, 0x38, 0xFA, 0xCD, 0xEA, 0xA0]};
+enum IID IID_IShellDispatch4 = {0xEFD84B2D, 0x4BCF, 0x4298, [0xBE, 0x25, 0xEB, 0x54, 0x2A, 0x59, 0xFB, 0xDA]};
+enum IID IID_IShellExecuteHookA = {0x000214F5, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IShellExecuteHookW = {0x000214FB, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IShellExtInit = {0x000214E8, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IShellFavoritesNameSpace = {0x55136804, 0xB2DE, 0x11D1, [0xB9, 0xF2, 0x00, 0xA0, 0xC9, 0x8B, 0xC5, 0x47]};
+enum IID IID_IShellFolder = {0x000214E6, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IShellFolder2 = {0x93F2F68C, 0x1D1B, 0x11D3, [0xA3, 0x0E, 0x00, 0xC0, 0x4F, 0x79, 0xAB, 0xD1]};
+enum IID IID_IShellFolderViewCB = {0x2047E320, 0xF2A9, 0x11CE, [0xAE, 0x65, 0x08, 0x00, 0x2B, 0x2E, 0x12, 0x62]};
+enum IID IID_IShellFolderViewDual = {0xE7A1AF80, 0x4D96, 0x11CF, [0x96, 0x0C, 0x00, 0x80, 0xC7, 0xF4, 0xEE, 0x85]};
+enum IID IID_IShellFolderViewDual2 = {0x31C147B6, 0x0ADE, 0x4A3C, [0xB5, 0x14, 0xDD, 0xF9, 0x32, 0xEF, 0x6D, 0x17]};
+enum IID IID_IShellIcon = {0x000214E5, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IShellIconOverlay = {0x7D688A70, 0xC613, 0x11D0, [0x99, 0x9B, 0x00, 0xC0, 0x4F, 0xD6, 0x55, 0xE1]};
+enum IID IID_IShellIconOverlayIdentifier = {0x0C6C4200, 0xC589, 0x11D0, [0x99, 0x9A, 0x00, 0xC0, 0x4F, 0xD6, 0x55, 0xE1]};
+enum IID IID_IShellImageData = {0xBFDEEC12, 0x8040, 0x4403, [0xA5, 0xEA, 0x9E, 0x07, 0xDA, 0xFC, 0xF5, 0x30]};
+enum IID IID_IShellImageDataAbort = {0x53FB8E58, 0x50C0, 0x4003, [0xB4, 0xAA, 0x0C, 0x8D, 0xF2, 0x8E, 0x7F, 0x3A]};
+enum IID IID_IShellImageDataFactory = {0x9BE8ED5C, 0xEDAB, 0x4D75, [0x90, 0xF3, 0xBD, 0x5B, 0xDB, 0xB2, 0x1C, 0x82]};
+enum IID IID_IShellLinkA = {0x000214EE, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IShellLinkDataList = {0x45E2B4AE, 0xB1C3, 0x11D0, [0xB9, 0x2F, 0x00, 0xA0, 0xC9, 0x03, 0x12, 0xE1]};
+enum IID IID_IShellLinkDual = {0x88A05C00, 0xF000, 0x11CE, [0x83, 0x50, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]};
+enum IID IID_IShellLinkDual2 = {0x317EE249, 0xF12E, 0x11D2, [0xB1, 0xE4, 0x00, 0xC0, 0x4F, 0x8E, 0xEB, 0x3E]};
+enum IID IID_IShellLinkW = {0x000214F9, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IShellNameSpace = {0xE572D3C9, 0x37BE, 0x4AE2, [0x82, 0x5D, 0xD5, 0x21, 0x76, 0x3E, 0x31, 0x08]};
+enum IID IID_IShellPropSheetExt = {0x000214E9, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IShellUIHelper = {0x729FE2F8, 0x1EA8, 0x11D1, [0x8F, 0x85, 0x00, 0xC0, 0x4F, 0xC2, 0xFB, 0xE1]};
+enum IID IID_IShellView = {0x000214E3, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IShellView2 = {0x88E39E80, 0x3578, 0x11CF, [0xAE, 0x69, 0x08, 0x00, 0x2B, 0x2E, 0x12, 0x62]};
+enum IID IID_IShellWindows = {0x85CB6900, 0x4D95, 0x11CF, [0x96, 0x0C, 0x00, 0x80, 0xC7, 0xF4, 0xEE, 0x85]};
+enum IID IID_ISimpleCommandCreator = {0x5E341AB7, 0x02D0, 0x11D1, [0x90, 0x0C, 0x00, 0xA0, 0xC9, 0x06, 0x37, 0x96]};
+enum IID IID_ISimpleConnectionPoint = {0x51973C3E, 0xCB0C, 0x11D0, [0xB5, 0xC9, 0x00, 0xA0, 0x24, 0x4A, 0x0E, 0x7A]};
+enum IID IID_ISimpleFrameSite = {0x742B0E01, 0x14E6, 0x101B, [0x91, 0x4E, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB]};
+enum IID IID_ISliderBar = {0x3050F68D, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ISniffStream = {0x4EF17940, 0x30E0, 0x11D0, [0xB7, 0x24, 0x00, 0xAA, 0x00, 0x6C, 0x1A, 0x01]};
+enum IID IID_ISOAPRequest = {0xAD194525, 0x6E01, 0x4BCA, [0x92, 0x9C, 0x23, 0xC7, 0x38, 0x33, 0x36, 0xAF]};
+enum IID IID_ISoftDistExt = {0xB15B8DC1, 0xC7E1, 0x11D0, [0x86, 0x80, 0x00, 0xAA, 0x00, 0xBD, 0xCB, 0x71]};
+enum IID IID_ISourcesRowset = {0x0C733A1E, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ISpecialSystemProperties = {0x000001B9, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ISpecifyPropertyPages = {0xB196B28B, 0xBAB4, 0x101A, [0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07]};
+enum IID IID_ISpinButton = {0x3050F68B, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ISQLErrorInfo = {0x0C733A74, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IStandardActivator = {0x000001B8, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IStandardInfo = {0xF1D9C1A5, 0x9589, 0x40DD, [0xB6, 0x3D, 0x9B, 0xB0, 0xB3, 0x8A, 0x10, 0x22]};
+enum IID IID_IStaticPortMapping = {0x6F10711F, 0x729B, 0x41E5, [0x93, 0xB8, 0xF2, 0x1D, 0x0F, 0x81, 0x8D, 0xF1]};
+enum IID IID_IStaticPortMappingCollection = {0xCD1F3E77, 0x66D6, 0x4664, [0x82, 0xC7, 0x36, 0xDB, 0xB6, 0x41, 0xD0, 0xF1]};
+enum IID IID_IStats = {0x944AD530, 0xB09D, 0x11CE, [0xB5, 0x9C, 0x00, 0xAA, 0x00, 0x6C, 0xB3, 0x7D]};
+enum IID IID_IStdMarshalInfo = {0x00000018, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IStemmer = {0xEFBAF140, 0x7F42, 0x11CE, [0xBE, 0x57, 0x00, 0xAA, 0x00, 0x51, 0xFE, 0x20]};
+enum IID IID_IStemSink = {0xFE77C330, 0x7F42, 0x11CE, [0xBE, 0x57, 0x00, 0xAA, 0x00, 0x51, 0xFE, 0x20]};
+enum IID IID_IStorage = {0x0000000B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IStream = {0x0000000C, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IStub = {0x00000026, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IStubManager = {0x00000006, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ISubDivisionProvider = {0x3050F4D2, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ISubscriptionAgentControl = {0xA89E8FF0, 0x70F4, 0x11D1, [0xBC, 0x7F, 0x00, 0xC0, 0x4F, 0xD9, 0x29, 0xDB]};
+enum IID IID_ISubscriptionAgentEvents = {0xA89E8FF1, 0x70F4, 0x11D1, [0xBC, 0x7F, 0x00, 0xC0, 0x4F, 0xD9, 0x29, 0xDB]};
+enum IID IID_ISubscriptionAgentShellExt = {0x81B184BA, 0xB302, 0x11D1, [0x85, 0x52, 0x00, 0xC0, 0x4F, 0xA3, 0x5C, 0x89]};
+enum IID IID_ISubscriptionItem = {0xA97559F8, 0x6C4A, 0x11D1, [0xA1, 0xE8, 0x00, 0xC0, 0x4F, 0xC2, 0xFB, 0xE1]};
+enum IID IID_ISubscriptionMgr = {0x085FB2C0, 0x0DF8, 0x11D1, [0x8F, 0x4B, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x3F]};
+enum IID IID_ISubscriptionMgr2 = {0x614BC270, 0xAEDF, 0x11D1, [0xA1, 0xF9, 0x00, 0xC0, 0x4F, 0xC2, 0xFB, 0xE1]};
+enum IID IID_ISubscriptionMgrPriv = {0xD66B399E, 0xAF1D, 0x11D1, [0xA1, 0xF9, 0x00, 0xC0, 0x4F, 0xC2, 0xFB, 0xE1]};
+enum IID IID_ISubscriptionThrottler = {0x1E9B00E4, 0x9846, 0x11D1, [0xA1, 0xEE, 0x00, 0xC0, 0x4F, 0xC2, 0xFB, 0xE1]};
+enum IID IID_ISupportErrorInfo = {0xDF0B3D60, 0x548F, 0x101B, [0x8E, 0x65, 0x08, 0x00, 0x2B, 0x2B, 0xD1, 0x19]};
+enum IID IID_ISurrogate = {0x00000022, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ISWbemDateTime = {0x5E97458A, 0xCF77, 0x11D3, [0xB3, 0x8F, 0x00, 0x10, 0x5A, 0x1F, 0x47, 0x3A]};
+enum IID IID_ISWbemEventSource = {0x27D54D92, 0x0EBE, 0x11D2, [0x8B, 0x22, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemLastError = {0xD962DB84, 0xD4BB, 0x11D1, [0x8B, 0x09, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemLocator = {0x76A6415B, 0xCB41, 0x11D1, [0x8B, 0x02, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemMethod = {0x422E8E90, 0xD955, 0x11D1, [0x8B, 0x09, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemMethodSet = {0xC93BA292, 0xD955, 0x11D1, [0x8B, 0x09, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemNamedValue = {0x76A64164, 0xCB41, 0x11D1, [0x8B, 0x02, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemNamedValueSet = {0xCF2376EA, 0xCE8C, 0x11D1, [0x8B, 0x05, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemObject = {0x76A6415A, 0xCB41, 0x11D1, [0x8B, 0x02, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemObjectEx = {0x269AD56A, 0x8A67, 0x4129, [0xBC, 0x8C, 0x05, 0x06, 0xDC, 0xFE, 0x98, 0x80]};
+enum IID IID_ISWbemObjectPath = {0x5791BC27, 0xCE9C, 0x11D1, [0x97, 0xBF, 0x00, 0x00, 0xF8, 0x1E, 0x84, 0x9C]};
+enum IID IID_ISWbemObjectSet = {0x76A6415F, 0xCB41, 0x11D1, [0x8B, 0x02, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemPrivilege = {0x26EE67BD, 0x5804, 0x11D2, [0x8B, 0x4A, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemPrivilegeSet = {0x26EE67BF, 0x5804, 0x11D2, [0x8B, 0x4A, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemProperty = {0x1A388F98, 0xD4BA, 0x11D1, [0x8B, 0x09, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemPropertySet = {0xDEA0A7B2, 0xD4BA, 0x11D1, [0x8B, 0x09, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemQualifier = {0x79B05932, 0xD3B7, 0x11D1, [0x8B, 0x06, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemQualifierSet = {0x9B16ED16, 0xD3DF, 0x11D1, [0x8B, 0x08, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemRefreshableItem = {0x5AD4BF92, 0xDAAB, 0x11D3, [0xB3, 0x8F, 0x00, 0x10, 0x5A, 0x1F, 0x47, 0x3A]};
+enum IID IID_ISWbemRefresher = {0x14D8250E, 0xD9C2, 0x11D3, [0xB3, 0x8F, 0x00, 0x10, 0x5A, 0x1F, 0x47, 0x3A]};
+enum IID IID_ISWbemSecurity = {0xB54D66E6, 0x2287, 0x11D2, [0x8B, 0x33, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemServices = {0x76A6415C, 0xCB41, 0x11D1, [0x8B, 0x02, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID IID_ISWbemServicesEx = {0xD2F68443, 0x85DC, 0x427E, [0x91, 0xD8, 0x36, 0x65, 0x54, 0xCC, 0x75, 0x4C]};
+enum IID IID_ISWbemSink = {0x75718C9F, 0xF029, 0x11D1, [0xA1, 0xAC, 0x00, 0xC0, 0x4F, 0xB6, 0xC2, 0x23]};
+enum IID IID_ISynchronize = {0x00000030, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ISynchronizeContainer = {0x00000033, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ISynchronizedCallBack = {0x74C26041, 0x70D1, 0x11D1, [0xB7, 0x5A, 0x00, 0xA0, 0xC9, 0x05, 0x64, 0xFE]};
+enum IID IID_ISynchronizeEvent = {0x00000032, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ISynchronizeHandle = {0x00000031, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ISynchronizeMutex = {0x00000025, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ISyncMgrEnumItems = {0x6295DF2A, 0x35EE, 0x11D1, [0x87, 0x07, 0x00, 0xC0, 0x4F, 0xD9, 0x33, 0x27]};
+enum IID IID_ISyncMgrRegisterCSC = {0x47681A61, 0xBC74, 0x11D2, [0xB5, 0xC5, 0x00, 0xC0, 0x4F, 0xB9, 0x39, 0x81]};
+enum IID IID_ISyncMgrSynchronizeInvoke = {0x6295DF2C, 0x35EE, 0x11D1, [0x87, 0x07, 0x00, 0xC0, 0x4F, 0xD9, 0x33, 0x27]};
+enum IID IID_ISyncSchedule = {0xF0E15899, 0xA700, 0x11D1, [0x98, 0x31, 0x00, 0xC0, 0x4F, 0xD9, 0x10, 0xDD]};
+enum IID IID_ISyncScheduleMgr = {0xF0E15897, 0xA700, 0x11D1, [0x98, 0x31, 0x00, 0xC0, 0x4F, 0xD9, 0x10, 0xDD]};
+enum IID IID_ISyncSchedulep = {0xF0E1589B, 0xA700, 0x11D1, [0x98, 0x31, 0x00, 0xC0, 0x4F, 0xD9, 0x10, 0xDD]};
+enum IID IID_ITableCreation = {0x0C733ABC, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ITableDefinition = {0x0C733A86, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ITableDefinitionWithConstraints = {0x0C733AAB, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ITableRename = {0x0C733A77, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ITACDGroup = {0x5AFC3148, 0x4BCC, 0x11D1, [0xBF, 0x80, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITACDGroupEvent = {0x297F3032, 0xBD11, 0x11D1, [0xA0, 0xA7, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITAddress = {0xB1EFC386, 0x9355, 0x11D0, [0x83, 0x5C, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID IID_ITAddress2 = {0xB0AE5D9B, 0xBE51, 0x46C9, [0xB0, 0xF7, 0xDF, 0xA8, 0xA2, 0x2A, 0x8B, 0xC4]};
+enum IID IID_ITAddressCapabilities = {0x8DF232F5, 0x821B, 0x11D1, [0xBB, 0x5C, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITAddressDeviceSpecificEvent = {0x3ACB216B, 0x40BD, 0x487A, [0x86, 0x72, 0x5C, 0xE7, 0x7B, 0xD7, 0xE3, 0xA3]};
+enum IID IID_ITAddressEvent = {0x831CE2D1, 0x83B5, 0x11D1, [0xBB, 0x5C, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITAddressTranslation = {0x0C4D8F03, 0x8DDB, 0x11D1, [0xA0, 0x9E, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITAddressTranslationInfo = {0xAFC15945, 0x8D40, 0x11D1, [0xA0, 0x9E, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITAgent = {0x5770ECE5, 0x4B27, 0x11D1, [0xBF, 0x80, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITAgentEvent = {0x5AFC314A, 0x4BCC, 0x11D1, [0xBF, 0x80, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITAgentHandler = {0x587E8C22, 0x9802, 0x11D1, [0xA0, 0xA4, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITAgentHandlerEvent = {0x297F3034, 0xBD11, 0x11D1, [0xA0, 0xA7, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITAgentSession = {0x5AFC3147, 0x4BCC, 0x11D1, [0xBF, 0x80, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITAgentSessionEvent = {0x5AFC314B, 0x4BCC, 0x11D1, [0xBF, 0x80, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITAllocatorProperties = {0xC1BC3C90, 0xBCFE, 0x11D1, [0x97, 0x45, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID IID_ITAMMediaFormat = {0x0364EB00, 0x4A77, 0x11D1, [0xA6, 0x71, 0x00, 0x60, 0x97, 0xC9, 0xA2, 0xE8]};
+enum IID IID_ITargetContainer = {0x7847EC01, 0x2BEC, 0x11D0, [0x82, 0xB4, 0x00, 0xA0, 0xC9, 0x0C, 0x29, 0xC5]};
+enum IID IID_ITargetEmbedding = {0x548793C0, 0x9E74, 0x11CF, [0x96, 0x55, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0x23]};
+enum IID IID_ITargetFrame = {0xD5F78C80, 0x5252, 0x11CF, [0x90, 0xFA, 0x00, 0xAA, 0x00, 0x42, 0x10, 0x6E]};
+enum IID IID_ITargetFrame2 = {0x86D52E11, 0x94A8, 0x11D0, [0x82, 0xAF, 0x00, 0xC0, 0x4F, 0xD5, 0xAE, 0x38]};
+enum IID IID_ITargetFramePriv = {0x9216E421, 0x2BF5, 0x11D0, [0x82, 0xB4, 0x00, 0xA0, 0xC9, 0x0C, 0x29, 0xC5]};
+enum IID IID_ITargetNotify = {0x863A99A0, 0x21BC, 0x11D0, [0x82, 0xB4, 0x00, 0xA0, 0xC9, 0x0C, 0x29, 0xC5]};
+enum IID IID_ITargetNotify2 = {0x3050F6B1, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ITaskAnalyzeCluster = {0x795737A1, 0xE13A, 0x45EB, [0x8D, 0xFD, 0x81, 0x85, 0xC4, 0xB7, 0xAD, 0x4E]};
+enum IID IID_ITaskbarList = {0x56FDF342, 0xFD6D, 0x11D0, [0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90]};
+enum IID IID_ITaskbarList2 = {0x602D4995, 0xB13A, 0x429B, [0xA6, 0x6E, 0x19, 0x35, 0xE4, 0x4F, 0x43, 0x17]};
+enum IID IID_ITaskCommitClusterChanges = {0x1BF12DDE, 0xF8B0, 0x49B1, [0xA4, 0x58, 0x67, 0x47, 0xDB, 0x78, 0x8A, 0x47]};
+enum IID IID_ITaskCompareAndPushInformation = {0xD4F1C2AF, 0xB370, 0x49DE, [0x87, 0x68, 0x40, 0x10, 0xB5, 0x68, 0x63, 0x6C]};
+enum IID IID_ITaskGatherClusterInfo = {0xE167965C, 0xC5D6, 0x493C, [0xA3, 0x43, 0x4C, 0x10, 0x5C, 0x01, 0xDD, 0xE7]};
+enum IID IID_ITaskGatherInformation = {0xB9AAF3F8, 0x238E, 0x4993, [0xBA, 0x31, 0x14, 0x85, 0x98, 0x04, 0xF9, 0x2C]};
+enum IID IID_ITaskGatherNodeInfo = {0xF19A2E01, 0x2CB3, 0x47B4, [0x8F, 0x5D, 0xB9, 0x77, 0x17, 0x6B, 0x45, 0xC8]};
+enum IID IID_ITaskGetDomains = {0xDFCB4ACD, 0xC4DB, 0x4DB4, [0x8E, 0xBB, 0x1D, 0xD0, 0x7A, 0x9D, 0x5B, 0x82]};
+enum IID IID_ITaskGetDomainsCallback = {0x85402E44, 0x6834, 0x41DF, [0x85, 0x90, 0x01, 0x82, 0x7D, 0x12, 0x4E, 0x1B]};
+enum IID IID_ITaskLoginDomain = {0x76AD8E51, 0x53C3, 0x4347, [0x89, 0x5D, 0x6C, 0x30, 0xF4, 0x13, 0x93, 0x74]};
+enum IID IID_ITaskLoginDomainCallback = {0xEFAF3C43, 0x7A8F, 0x469B, [0xB8, 0xBB, 0xC8, 0x0C, 0x57, 0x47, 0xCE, 0x05]};
+enum IID IID_ITaskManager = {0x16116694, 0xDFC5, 0x470B, [0xAC, 0x12, 0x46, 0xFB, 0xB0, 0x1C, 0xEF, 0x10]};
+enum IID IID_ITaskPollingCallback = {0x49E92395, 0x66AF, 0x4ADD, [0xA4, 0x1E, 0x43, 0x51, 0x2C, 0xB5, 0x19, 0xB3]};
+enum IID IID_ITaskVerifyIPAddress = {0x0C95E1B1, 0x0CFF, 0x4740, [0x8A, 0xBD, 0x69, 0x91, 0x2D, 0x10, 0x5B, 0xD1]};
+enum IID IID_ITASRTerminalEvent = {0xEE016A02, 0x4FA9, 0x467C, [0x93, 0x3F, 0x5A, 0x15, 0xB1, 0x23, 0x77, 0xD7]};
+enum IID IID_ITAttributeList = {0x5037FB82, 0xCAE9, 0x11D0, [0x8D, 0x58, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID IID_ITAudioDeviceControl = {0x6C0AB6C5, 0x21E3, 0x11D3, [0xA5, 0x77, 0x00, 0xC0, 0x4F, 0x8E, 0xF6, 0xE3]};
+enum IID IID_ITAudioSettings = {0x6C0AB6C6, 0x21E3, 0x11D3, [0xA5, 0x77, 0x00, 0xC0, 0x4F, 0x8E, 0xF6, 0xE3]};
+enum IID IID_ITAutomatedPhoneControl = {0x1EE1AF0E, 0x6159, 0x4A61, [0xB7, 0x9B, 0x6A, 0x4B, 0xA3, 0xFC, 0x9D, 0xFC]};
+enum IID IID_ITBasicAudioTerminal = {0xB1EFC38D, 0x9355, 0x11D0, [0x83, 0x5C, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID IID_ITBasicCallControl = {0xB1EFC389, 0x9355, 0x11D0, [0x83, 0x5C, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID IID_ITBasicCallControl2 = {0x161A4A56, 0x1E99, 0x4B3F, [0xA4, 0x6A, 0x16, 0x8F, 0x38, 0xA5, 0xEE, 0x4C]};
+enum IID IID_ITCallHub = {0xA3C1544E, 0x5B92, 0x11D1, [0x8F, 0x4E, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITCallHubEvent = {0xA3C15451, 0x5B92, 0x11D1, [0x8F, 0x4E, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITCallInfo = {0x350F85D1, 0x1227, 0x11D3, [0x83, 0xD4, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITCallInfo2 = {0x94D70CA6, 0x7AB0, 0x4DAA, [0x81, 0xCA, 0xB8, 0xF8, 0x64, 0x3F, 0xAE, 0xC1]};
+enum IID IID_ITCallInfoChangeEvent = {0x5D4B65F9, 0xE51C, 0x11D1, [0xA0, 0x2F, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITCallingCard = {0x0C4D8F00, 0x8DDB, 0x11D1, [0xA0, 0x9E, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITCallMediaEvent = {0xFF36B87F, 0xEC3A, 0x11D0, [0x8E, 0xE4, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITCallNotificationEvent = {0x895801DF, 0x3DD6, 0x11D1, [0x8F, 0x30, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITCallQualityControl = {0xFE1D8AE0, 0xEDC4, 0x49B5, [0x8F, 0x8C, 0x4D, 0xE4, 0x0F, 0x9C, 0xDF, 0xAF]};
+enum IID IID_ITCallStateEvent = {0x62F47097, 0x95C9, 0x11D0, [0x83, 0x5D, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID IID_ITCollection = {0x5EC5ACF2, 0x9C02, 0x11D0, [0x83, 0x62, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID IID_ITCollection2 = {0xE6DDDDA5, 0xA6D3, 0x48FF, [0x87, 0x37, 0xD3, 0x2F, 0xC4, 0xD9, 0x54, 0x77]};
+enum IID IID_ITConferenceBlob = {0xC259D7AA, 0xC8AB, 0x11D0, [0x8D, 0x58, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID IID_ITConnection = {0x8FA381D4, 0xC8C2, 0x11D0, [0x8D, 0x58, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID IID_ITcpipProperties = {0x98133271, 0x4B20, 0x11D1, [0xAB, 0x01, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E]};
+enum IID IID_ITCustomTone = {0x357AD764, 0xB3C6, 0x4B2A, [0x8F, 0xA5, 0x07, 0x22, 0x82, 0x7A, 0x92, 0x54]};
+enum IID IID_ITDetectTone = {0x961F79BD, 0x3097, 0x49DF, [0xA1, 0xD6, 0x90, 0x9B, 0x77, 0xE8, 0x9C, 0xA0]};
+enum IID IID_ITDigitDetectionEvent = {0x80D3BFAC, 0x57D9, 0x11D2, [0xA0, 0x4A, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITDigitGenerationEvent = {0x80D3BFAD, 0x57D9, 0x11D2, [0xA0, 0x4A, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITDigitsGatheredEvent = {0xE52EC4C1, 0xCBA3, 0x441A, [0x9E, 0x6A, 0x93, 0xCB, 0x90, 0x9E, 0x97, 0x24]};
+enum IID IID_ITDirectory = {0x34621D6C, 0x6CFF, 0x11D1, [0xAF, 0xF7, 0x00, 0xC0, 0x4F, 0xC3, 0x1F, 0xEE]};
+enum IID IID_ITDirectoryObject = {0x34621D6E, 0x6CFF, 0x11D1, [0xAF, 0xF7, 0x00, 0xC0, 0x4F, 0xC3, 0x1F, 0xEE]};
+enum IID IID_ITDirectoryObjectConference = {0xF1029E5D, 0xCB5B, 0x11D0, [0x8D, 0x59, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID IID_ITDirectoryObjectUser = {0x34621D6F, 0x6CFF, 0x11D1, [0xAF, 0xF7, 0x00, 0xC0, 0x4F, 0xC3, 0x1F, 0xEE]};
+enum IID IID_ITDispatchMapper = {0xE9225295, 0xC759, 0x11D1, [0xA0, 0x2B, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITemplatePrinter = {0x3050F6B4, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ITemplatePrinter2 = {0x3050F83F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ITFileTerminalEvent = {0xE4A7FBAC, 0x8C17, 0x4427, [0x9F, 0x55, 0x9F, 0x58, 0x9A, 0xC8, 0xAF, 0x00]};
+enum IID IID_ITFileTrack = {0x31CA6EA9, 0xC08A, 0x4BEA, [0x88, 0x11, 0x8E, 0x9C, 0x1B, 0xA3, 0xEA, 0x3A]};
+enum IID IID_ITfLangBarAddIn = {0xC9ADDAC3, 0x15CB, 0x4957, [0xB9, 0x3C, 0xDB, 0x08, 0x73, 0xFF, 0x98, 0xBB]};
+enum IID IID_ITFormatControl = {0x6C0AB6C1, 0x21E3, 0x11D3, [0xA5, 0x77, 0x00, 0xC0, 0x4F, 0x8E, 0xF6, 0xE3]};
+enum IID IID_ITForwardInformation = {0x449F659E, 0x88A3, 0x11D1, [0xBB, 0x5D, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITForwardInformation2 = {0x5229B4ED, 0xB260, 0x4382, [0x8E, 0x1A, 0x5D, 0xF3, 0xA8, 0xA4, 0xCC, 0xC0]};
+enum IID IID_ITfSpeechUIServer = {0x90E9A944, 0x9244, 0x489F, [0xA7, 0x8F, 0xDE, 0x67, 0xAF, 0xC0, 0x13, 0xA7]};
+enum IID IID_IThumbnailCapture = {0x4EA39266, 0x7211, 0x409F, [0xB6, 0x22, 0xF6, 0x3D, 0xBD, 0x16, 0xC5, 0x33]};
+enum IID IID_IThumbnailExtractor = {0x969DC708, 0x5C76, 0x11D1, [0x8D, 0x86, 0x00, 0x00, 0xF8, 0x04, 0xB0, 0x57]};
+enum IID IID_ITILSConfig = {0x34621D72, 0x6CFF, 0x11D1, [0xAF, 0xF7, 0x00, 0xC0, 0x4F, 0xC3, 0x1F, 0xEE]};
+enum IID IID_ITIMEActiveElementCollection = {0x403E2540, 0x4520, 0x11D3, [0x93, 0xAB, 0x00, 0xA0, 0xC9, 0x67, 0xA4, 0x38]};
+enum IID IID_ITimeAndNoticeControl = {0xBC0BF6AE, 0x8878, 0x11D1, [0x83, 0xE9, 0x00, 0xC0, 0x4F, 0xC2, 0xC6, 0xD4]};
+enum IID IID_ITIMEAnimationElement = {0xA74F14B1, 0xB6A2, 0x430A, [0xA5, 0xE8, 0x1F, 0x4E, 0x53, 0xF7, 0x10, 0xFE]};
+enum IID IID_ITIMEAnimationElement2 = {0x29CE8661, 0xBD43, 0x421A, [0xB6, 0x16, 0xE9, 0xB3, 0x1F, 0x33, 0xA5, 0x72]};
+enum IID IID_ITIMEBodyElement = {0x8C90E348, 0xEC0A, 0x4229, [0x90, 0xB0, 0xE5, 0x7D, 0x2C, 0xA4, 0x5C, 0xCB]};
+enum IID IID_ITIMEDMusicPlayerObject = {0x407954F5, 0x2BAB, 0x4CFA, [0x95, 0x4D, 0x24, 0x9F, 0x9F, 0xCE, 0x43, 0xA1]};
+enum IID IID_ITIMEDVDPlayerObject = {0x3AF7AB68, 0x4F29, 0x462C, [0xAA, 0x6E, 0x58, 0x72, 0x44, 0x88, 0x99, 0xE3]};
+enum IID IID_ITIMEElement = {0x1C2EF64E, 0xF07D, 0x4338, [0x97, 0x71, 0x91, 0x54, 0x49, 0x1C, 0xD8, 0xB9]};
+enum IID IID_ITIMEElementCollection = {0x50ABC224, 0x6D53, 0x4F83, [0x91, 0x35, 0x24, 0x40, 0xA4, 0x1B, 0x7B, 0xC8]};
+enum IID IID_ITIMEFactory = {0xCD51E446, 0x3006, 0x434F, [0x90, 0xE2, 0xE3, 0x7E, 0x8F, 0xB8, 0xCA, 0x8F]};
+enum IID IID_ITIMEMediaElement = {0x47A6972F, 0xAE65, 0x4A6B, [0xAE, 0x63, 0xD0, 0xC1, 0xD5, 0x30, 0x7B, 0x58]};
+enum IID IID_ITIMEMediaElement2 = {0x9EE29400, 0x7EE6, 0x453A, [0x85, 0xB3, 0x4E, 0xC2, 0x8E, 0x03, 0x05, 0xB4]};
+enum IID IID_ITIMEMediaPlayer = {0xEA4A95BE, 0xACC9, 0x4BF0, [0x85, 0xA4, 0x1B, 0xF3, 0xC5, 0x1E, 0x43, 0x1C]};
+enum IID IID_ITIMEMediaPlayerAudio = {0xFFAACFDA, 0xB374, 0x4F22, [0xAC, 0x9A, 0xC5, 0xBB, 0x94, 0x37, 0xCB, 0x56]};
+enum IID IID_ITIMEMediaPlayerControl = {0x897A99E7, 0xF386, 0x45C8, [0xB5, 0x1B, 0x3A, 0x25, 0xBB, 0xCB, 0xBA, 0x69]};
+enum IID IID_ITIMEMediaPlayerNetwork = {0xB9987FCA, 0x7FBB, 0x4015, [0xBD, 0x3D, 0x74, 0x18, 0x60, 0x55, 0x14, 0xDA]};
+enum IID IID_ITIMEMediaPlayerSite = {0xBF0571ED, 0x344F, 0x4F58, [0x82, 0xC7, 0x74, 0x31, 0xED, 0x0F, 0xD8, 0x34]};
+enum IID IID_ITIMEPlayItem = {0x2A6096D9, 0x2CE0, 0x47DC, [0xA8, 0x13, 0x90, 0x99, 0xA2, 0x46, 0x63, 0x09]};
+enum IID IID_ITIMEPlayItem2 = {0x4262CD38, 0x6BDC, 0x40A4, [0xBC, 0x50, 0x4C, 0xC5, 0x03, 0x66, 0xE7, 0x02]};
+enum IID IID_ITIMEPlayList = {0xE9B75B62, 0xDD97, 0x4B19, [0x8F, 0xD9, 0x96, 0x46, 0x29, 0x29, 0x52, 0xE0]};
+enum IID IID_ITimer = {0x3050F360, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ITimerService = {0x3050F35F, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ITimerSink = {0x3050F361, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ITIMEState = {0xDD5EC62A, 0x9D77, 0x4573, [0x80, 0xA8, 0x75, 0x85, 0x94, 0xE6, 0x9C, 0xEA]};
+enum IID IID_ITIMETransitionElement = {0xF383D66F, 0x5E68, 0x4FC2, [0xB6, 0x41, 0x03, 0x67, 0x2B, 0x54, 0x3A, 0x49]};
+enum IID IID_ITLegacyAddressMediaControl = {0xAB493640, 0x4C0B, 0x11D2, [0xA0, 0x46, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITLegacyAddressMediaControl2 = {0xB0EE512B, 0xA531, 0x409E, [0x9D, 0xD9, 0x40, 0x99, 0xFE, 0x86, 0xC7, 0x38]};
+enum IID IID_ITLegacyCallMediaControl = {0xD624582F, 0xCC23, 0x4436, [0xB8, 0xA5, 0x47, 0xC6, 0x25, 0xC8, 0x04, 0x5D]};
+enum IID IID_ITLegacyCallMediaControl2 = {0x57CA332D, 0x7BC2, 0x44F1, [0xA6, 0x0C, 0x93, 0x6F, 0xE8, 0xD7, 0xCE, 0x73]};
+enum IID IID_ITLegacyWaveSupport = {0x207823EA, 0xE252, 0x11D2, [0xB7, 0x7E, 0x00, 0x80, 0xC7, 0x13, 0x53, 0x81]};
+enum IID IID_ITLocalParticipant = {0x39CBF055, 0xF77A, 0x11D2, [0xA8, 0x24, 0x00, 0xC0, 0x4F, 0x8E, 0xF6, 0xE3]};
+enum IID IID_ITLocationInfo = {0x0C4D8EFF, 0x8DDB, 0x11D1, [0xA0, 0x9E, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITMedia = {0x0CC1F053, 0xCAEB, 0x11D0, [0x8D, 0x58, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID IID_ITMediaCollection = {0x6A8E16A2, 0x0ABC, 0x11D1, [0x97, 0x6D, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID IID_ITMediaControl = {0xC445DDE8, 0x5199, 0x4BC7, [0x98, 0x07, 0x5F, 0xFB, 0x92, 0xE4, 0x2E, 0x09]};
+enum IID IID_ITMediaPlayback = {0x627E8AE6, 0xAE4C, 0x4A69, [0xBB, 0x63, 0x2A, 0xD6, 0x25, 0x40, 0x4B, 0x77]};
+enum IID IID_ITMediaRecord = {0xF5DD4592, 0x5476, 0x4CC1, [0x9D, 0x4D, 0xFA, 0xD3, 0xEE, 0xFE, 0x7D, 0xB2]};
+enum IID IID_ITMediaSupport = {0xB1EFC384, 0x9355, 0x11D0, [0x83, 0x5C, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID IID_ITMSPAddress = {0xEE3BD600, 0x3868, 0x11D2, [0xA0, 0x45, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITMultiTrackTerminal = {0xFE040091, 0xADE8, 0x4072, [0x95, 0xC9, 0xBF, 0x7D, 0xE8, 0xC5, 0x4B, 0x44]};
+enum IID IID_ITParticipant = {0x5899B820, 0x5A34, 0x11D2, [0x95, 0xA0, 0x00, 0xA0, 0x24, 0x4D, 0x22, 0x98]};
+enum IID IID_ITParticipantControl = {0xD2EE6684, 0x5A34, 0x11D2, [0x95, 0xA0, 0x00, 0xA0, 0x24, 0x4D, 0x22, 0x98]};
+enum IID IID_ITParticipantEvent = {0x8BB35070, 0x2DAD, 0x11D3, [0xA5, 0x80, 0x00, 0xC0, 0x4F, 0x8E, 0xF6, 0xE3]};
+enum IID IID_ITParticipantSubStreamControl = {0x2C679108, 0x5A35, 0x11D2, [0x95, 0xA0, 0x00, 0xA0, 0x24, 0x4D, 0x22, 0x98]};
+enum IID IID_ITPhone = {0x09D48DB4, 0x10CC, 0x4388, [0x9D, 0xE7, 0xA8, 0x46, 0x56, 0x18, 0x97, 0x5A]};
+enum IID IID_ITPhoneDeviceSpecificEvent = {0x63FFB2A6, 0x872B, 0x4CD3, [0xA5, 0x01, 0x32, 0x6E, 0x8F, 0xB4, 0x0A, 0xF7]};
+enum IID IID_ITPhoneEvent = {0x8F942DD8, 0x64ED, 0x4AAF, [0xA7, 0x7D, 0xB2, 0x3D, 0xB0, 0x83, 0x7E, 0xAD]};
+enum IID IID_ITPluggableTerminalClassInfo = {0x41757F4A, 0xCF09, 0x4B34, [0xBC, 0x96, 0x0A, 0x79, 0xD2, 0x39, 0x00, 0x76]};
+enum IID IID_ITPluggableTerminalClassRegistrat = {0x924A3723, 0xA00B, 0x4F5F, [0x9F, 0xEE, 0x8E, 0x9A, 0xEB, 0x9E, 0x82, 0xAA]};
+enum IID IID_ITPluggableTerminalEventSink = {0x6E0887BE, 0xBA1A, 0x492E, [0xBD, 0x10, 0x40, 0x20, 0xEC, 0x5E, 0x33, 0xE0]};
+enum IID IID_ITPluggableTerminalEventSinkRegis = {0xF7115709, 0xA216, 0x4957, [0xA7, 0x59, 0x06, 0x0A, 0xB3, 0x2A, 0x90, 0xD1]};
+enum IID IID_ITPluggableTerminalInitializatio = {0xAED6483C, 0x3304, 0x11D2, [0x86, 0xF1, 0x00, 0x60, 0x08, 0xB0, 0xE5, 0xD2]};
+enum IID IID_ITPluggableTerminalSuperclassInf = {0x6D54E42C, 0x4625, 0x4359, [0xA6, 0xF7, 0x63, 0x19, 0x99, 0x10, 0x7E, 0x05]};
+enum IID IID_ITPluggableTerminalSuperclassRegi = {0x60D3C08A, 0xC13E, 0x4195, [0x9A, 0xB0, 0x8D, 0xE7, 0x68, 0x09, 0x0F, 0x25]};
+enum IID IID_ITPrivateEvent = {0x0E269CD0, 0x10D4, 0x4121, [0x9C, 0x22, 0x9C, 0x85, 0xD6, 0x25, 0x65, 0x0D]};
+enum IID IID_ITQOSApplicationID = {0xE8C89D27, 0xA3BD, 0x47D5, [0xA6, 0xFC, 0xD2, 0xAE, 0x40, 0xCD, 0xBC, 0x6E]};
+enum IID IID_ITQOSEvent = {0xCFA3357C, 0xAD77, 0x11D1, [0xBB, 0x68, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITQueue = {0x5AFC3149, 0x4BCC, 0x11D1, [0xBF, 0x80, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITQueueEvent = {0x297F3033, 0xBD11, 0x11D1, [0xA0, 0xA7, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITrackFile = {0x8790C948, 0xA30B, 0x11D0, [0x8C, 0xAB, 0x00, 0xC0, 0x4F, 0xD9, 0x0F, 0x85]};
+enum IID IID_ITransaction = {0x0FB15084, 0xAF41, 0x11CE, [0xBD, 0x2B, 0x20, 0x4C, 0x4F, 0x4F, 0x50, 0x20]};
+enum IID IID_ITransaction2 = {0x34021548, 0x0065, 0x11D3, [0xBA, 0xC1, 0x00, 0xC0, 0x4F, 0x79, 0x7B, 0xE2]};
+enum IID IID_ITransactionCloner = {0x02656950, 0x2152, 0x11D0, [0x94, 0x4C, 0x00, 0xA0, 0xC9, 0x05, 0x41, 0x6E]};
+enum IID IID_ITransactionDispenser = {0x3A6AD9E1, 0x23B9, 0x11CF, [0xAD, 0x60, 0x00, 0xAA, 0x00, 0xA7, 0x4C, 0xCD]};
+enum IID IID_ITransactionJoin = {0x0C733A5E, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ITransactionLocal = {0x0C733A5F, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ITransactionObject = {0x0C733A60, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ITransactionOptions = {0x3A6AD9E0, 0x23B9, 0x11CF, [0xAD, 0x60, 0x00, 0xAA, 0x00, 0xA7, 0x4C, 0xCD]};
+enum IID IID_ITransactionOutcomeEvents = {0x3A6AD9E2, 0x23B9, 0x11CF, [0xAD, 0x60, 0x00, 0xAA, 0x00, 0xA7, 0x4C, 0xCD]};
+enum IID IID_ITransmt = {0xB3C9F150, 0xB593, 0x11CE, [0xB5, 0xB0, 0x00, 0xAA, 0x00, 0x6C, 0xB3, 0x7D]};
+enum IID IID_ITravelEntry = {0xF46EDB3B, 0xBC2F, 0x11D0, [0x94, 0x12, 0x00, 0xAA, 0x00, 0xA3, 0xEB, 0xD3]};
+enum IID IID_ITravelLog = {0x66A9CB08, 0x4802, 0x11D2, [0xA5, 0x61, 0x00, 0xA0, 0xC9, 0x2D, 0xBF, 0xE8]};
+enum IID IID_ITravelLogClient = {0x3050F67A, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ITravelLogClient2 = {0x0AD364CE, 0xADCB, 0x11D3, [0x82, 0x69, 0x00, 0x80, 0x5F, 0xC7, 0x32, 0xC0]};
+enum IID IID_ITravelLogEntry = {0x7EBFDD87, 0xAD18, 0x11D3, [0xA4, 0xC5, 0x00, 0xC0, 0x4F, 0x72, 0xD6, 0xB8]};
+enum IID IID_ITravelLogEx = {0x3050F679, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_ITravelLogStg = {0x7EBFDD80, 0xAD18, 0x11D3, [0xA4, 0xC5, 0x00, 0xC0, 0x4F, 0x72, 0xD6, 0xB8]};
+enum IID IID_ITRendezvous = {0x34621D6B, 0x6CFF, 0x11D1, [0xAF, 0xF7, 0x00, 0xC0, 0x4F, 0xC3, 0x1F, 0xEE]};
+enum IID IID_ITRequest = {0xAC48FFDF, 0xF8C4, 0x11D1, [0xA0, 0x30, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITRequestEvent = {0xAC48FFDE, 0xF8C4, 0x11D1, [0xA0, 0x30, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITridentEventSink = {0x1DC9CA50, 0x06EF, 0x11D2, [0x84, 0x15, 0x00, 0x60, 0x08, 0xC3, 0xFB, 0xFC]};
+enum IID IID_ITrkForceOwnership = {0xA2531F44, 0xC67D, 0x11D0, [0x8C, 0xB1, 0x00, 0xC0, 0x4F, 0xD9, 0x0F, 0x85]};
+enum IID IID_ITrkRestoreNotify = {0xD0056F6B, 0xE2A0, 0x11D0, [0xB1, 0xC2, 0x00, 0xC0, 0x4F, 0xB9, 0x38, 0x6D]};
+enum IID IID_ITrkRestoreParser = {0x755939E3, 0xE381, 0x11D0, [0xB1, 0xC5, 0x00, 0xC0, 0x4F, 0xB9, 0x38, 0x6D]};
+enum IID IID_ITrusteeAdmin = {0x0C733AA1, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ITrusteeGroupAdmin = {0x0C733AA2, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_ITScriptableAudioFormat = {0xB87658BD, 0x3C59, 0x4F64, [0xBE, 0x74, 0xAE, 0xDE, 0x3E, 0x86, 0xA8, 0x1E]};
+enum IID IID_ITSdp = {0x9B2719D8, 0xB696, 0x11D0, [0xA4, 0x89, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID IID_ITStaticAudioTerminal = {0xA86B7871, 0xD14C, 0x48E6, [0x92, 0x2E, 0xA8, 0xD1, 0x5F, 0x98, 0x48, 0x00]};
+enum IID IID_ITStream = {0xEE3BD605, 0x3868, 0x11D2, [0xA0, 0x45, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITStreamControl = {0xEE3BD604, 0x3868, 0x11D2, [0xA0, 0x45, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITStreamQualityControl = {0x6C0AB6C2, 0x21E3, 0x11D3, [0xA5, 0x77, 0x00, 0xC0, 0x4F, 0x8E, 0xF6, 0xE3]};
+enum IID IID_ITSubStream = {0xEE3BD608, 0x3868, 0x11D2, [0xA0, 0x45, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITSubStreamControl = {0xEE3BD607, 0x3868, 0x11D2, [0xA0, 0x45, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITTAPI = {0xB1EFC382, 0x9355, 0x11D0, [0x83, 0x5C, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID IID_ITTAPI2 = {0x54FBDC8C, 0xD90F, 0x4DAD, [0x96, 0x95, 0xB3, 0x73, 0x09, 0x7F, 0x09, 0x4B]};
+enum IID IID_ITTAPICallCenter = {0x5AFC3154, 0x4BCC, 0x11D1, [0xBF, 0x80, 0x00, 0x80, 0x5F, 0xC1, 0x47, 0xD3]};
+enum IID IID_ITTAPIEventNotification = {0xEDDB9426, 0x3B91, 0x11D1, [0x8F, 0x30, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITTAPIObjectEvent = {0xF4854D48, 0x937A, 0x11D1, [0xBB, 0x58, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID IID_ITTAPIObjectEvent2 = {0x359DDA6E, 0x68CE, 0x4383, [0xBF, 0x0B, 0x16, 0x91, 0x33, 0xC4, 0x1B, 0x46]};
+enum IID IID_ITTerminal = {0xB1EFC38A, 0x9355, 0x11D0, [0x83, 0x5C, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID IID_ITTerminalControl = {0xAED6483B, 0x3304, 0x11D2, [0x86, 0xF1, 0x00, 0x60, 0x08, 0xB0, 0xE5, 0xD2]};
+enum IID IID_ITTerminalManager = {0x7170F2DE, 0x9BE3, 0x11D0, [0xA0, 0x09, 0x00, 0xAA, 0x00, 0xB6, 0x05, 0xA4]};
+enum IID IID_ITTerminalManager2 = {0xBB33DEC6, 0xB2C7, 0x46E6, [0x9E, 0xD1, 0x49, 0x8B, 0x91, 0xFA, 0x85, 0xAC]};
+enum IID IID_ITTerminalSupport = {0xB1EFC385, 0x9355, 0x11D0, [0x83, 0x5C, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID IID_ITTerminalSupport2 = {0xF3EB39BC, 0x1B1F, 0x4E99, [0xA0, 0xC0, 0x56, 0x30, 0x5C, 0x4D, 0xD5, 0x91]};
+enum IID IID_ITTime = {0x2652BB78, 0x1516, 0x11D1, [0x97, 0x71, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID IID_ITTimeCollection = {0x0CC1F04F, 0xCAEB, 0x11D0, [0x8D, 0x58, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID IID_ITToneDetectionEvent = {0x407E0FAF, 0xD047, 0x4753, [0xB0, 0xC6, 0x8E, 0x06, 0x03, 0x73, 0xFE, 0xCD]};
+enum IID IID_ITToneTerminalEvent = {0xE6F56009, 0x611F, 0x4945, [0xBB, 0xD2, 0x2D, 0x0C, 0xE5, 0x61, 0x20, 0x56]};
+enum IID IID_ITTTSTerminalEvent = {0xD964788F, 0x95A5, 0x461D, [0xAB, 0x0C, 0xB9, 0x90, 0x0A, 0x6C, 0x27, 0x13]};
+enum IID IID_ITypeChangeEvents = {0x00020410, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ITypeComp = {0x00020403, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ITypeFactory = {0x0000002E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ITypeInfo = {0x00020401, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ITypeInfo2 = {0x00020412, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ITypeLib = {0x00020402, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ITypeLib2 = {0x00020411, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_ITypeMarshal = {0x0000002D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IUmiADSIPrivate = {0xCFCECB01, 0x3123, 0x4926, [0xB5, 0xE3, 0x62, 0x78, 0x08, 0x27, 0x26, 0x43]};
+enum IID IID_IUniformResourceLocatorA = {0xFBF23B80, 0xE3F0, 0x101B, [0x84, 0x88, 0x00, 0xAA, 0x00, 0x3E, 0x56, 0xF8]};
+enum IID IID_IUniformResourceLocatorW = {0xCABB0DA0, 0xDA57, 0x11CF, [0x99, 0x74, 0x00, 0x20, 0xAF, 0xD7, 0x97, 0x62]};
+enum IID IID_IUnknown = {0x00000000, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IUnsecuredApartment = {0x1CFABA8C, 0x1523, 0x11D1, [0xAD, 0x79, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID IID_IUPnPDescriptionDocument = {0x11D1C1B2, 0x7DAA, 0x4C9E, [0x95, 0x95, 0x7F, 0x82, 0xED, 0x20, 0x6D, 0x1E]};
+enum IID IID_IUPnPDescriptionDocumentCallback = {0x77394C69, 0x5486, 0x40D6, [0x9B, 0xC3, 0x49, 0x91, 0x98, 0x3E, 0x02, 0xDA]};
+enum IID IID_IUPnPDevice = {0x3D44D0D1, 0x98C9, 0x4889, [0xAC, 0xD1, 0xF9, 0xD6, 0x74, 0xBF, 0x22, 0x21]};
+enum IID IID_IUPnPDeviceControl = {0x204810BA, 0x73B2, 0x11D4, [0xBF, 0x42, 0x00, 0xB0, 0xD0, 0x11, 0x8B, 0x56]};
+enum IID IID_IUPnPDeviceDocumentAccess = {0xE7772804, 0x3287, 0x418E, [0x90, 0x72, 0xCF, 0x2B, 0x47, 0x23, 0x89, 0x81]};
+enum IID IID_IUPnPDeviceFinder = {0xADDA3D55, 0x6F72, 0x4319, [0xBF, 0xF9, 0x18, 0x60, 0x0A, 0x53, 0x9B, 0x10]};
+enum IID IID_IUPnPDeviceFinderAddCallbackWithI = {0x983DFC0B, 0x1796, 0x44DF, [0x89, 0x75, 0xCA, 0x54, 0x5B, 0x62, 0x0E, 0xE5]};
+enum IID IID_IUPnPDeviceFinderCallback = {0x415A984A, 0x88B3, 0x49F3, [0x92, 0xAF, 0x05, 0x08, 0xBE, 0xDF, 0x0D, 0x6C]};
+enum IID IID_IUPnPDeviceHostICSSupport = {0x3FFC5AE5, 0xA66B, 0x499C, [0xA1, 0x80, 0xC7, 0x39, 0x3D, 0xB6, 0xBA, 0x8D]};
+enum IID IID_IUPnPDeviceHostSetup = {0x6BD34909, 0x54E7, 0x4FBF, [0x85, 0x62, 0x7B, 0x89, 0x70, 0x9A, 0x58, 0x9A]};
+enum IID IID_IUPnPDeviceProvider = {0x204810B8, 0x73B2, 0x11D4, [0xBF, 0x42, 0x00, 0xB0, 0xD0, 0x11, 0x8B, 0x56]};
+enum IID IID_IUPnPDevices = {0xFDBC0C73, 0xBDA3, 0x4C66, [0xAC, 0x4F, 0xF2, 0xD9, 0x6F, 0xDA, 0xD6, 0x8C]};
+enum IID IID_IUPnPEventSink = {0x204810B4, 0x73B2, 0x11D4, [0xBF, 0x42, 0x00, 0xB0, 0xD0, 0x11, 0x8B, 0x56]};
+enum IID IID_IUPnPEventSource = {0x204810B5, 0x73B2, 0x11D4, [0xBF, 0x42, 0x00, 0xB0, 0xD0, 0x11, 0x8B, 0x56]};
+enum IID IID_IUPnPNAT = {0xB171C812, 0xCC76, 0x485A, [0x94, 0xD8, 0xB6, 0xB3, 0xA2, 0x79, 0x4E, 0x99]};
+enum IID IID_IUPnPPrivateCallbackHelper = {0x8DCC8327, 0xDBE9, 0x48E6, [0x84, 0x6C, 0x33, 0x72, 0x58, 0x65, 0xD5, 0x0C]};
+enum IID IID_IUPnPPrivateDocumentCallbackHelp = {0x19432A8E, 0x4A32, 0x4860, [0xB8, 0xFB, 0x95, 0xB1, 0x11, 0x7C, 0xD4, 0xE5]};
+enum IID IID_IUPnPPrivateServiceHelper2 = {0x340F4076, 0x6856, 0x48F9, [0xB3, 0xC4, 0x97, 0xB9, 0x1B, 0x68, 0xD7, 0x7E]};
+enum IID IID_IUPnPRegistrar = {0x204810B6, 0x73B2, 0x11D4, [0xBF, 0x42, 0x00, 0xB0, 0xD0, 0x11, 0x8B, 0x56]};
+enum IID IID_IUPnPReregistrar = {0x204810B7, 0x73B2, 0x11D4, [0xBF, 0x42, 0x00, 0xB0, 0xD0, 0x11, 0x8B, 0x56]};
+enum IID IID_IUPnPService = {0xA295019C, 0xDC65, 0x47DD, [0x90, 0xDC, 0x7F, 0xE9, 0x18, 0xA1, 0xAB, 0x44]};
+enum IID IID_IUPnPServiceCallback = {0x31FADCA9, 0xAB73, 0x464B, [0xB6, 0x7D, 0x5C, 0x1D, 0x0F, 0x83, 0xC8, 0xB8]};
+enum IID IID_IUPnPServiceCallbackPrivate = {0x24EA2515, 0xF612, 0x4528, [0xBA, 0x82, 0x7B, 0xD3, 0xDB, 0xBA, 0xD3, 0x03]};
+enum IID IID_IUPnPServices = {0x3F8C8E9E, 0x9A7A, 0x4DC8, [0xBC, 0x41, 0xFF, 0x31, 0xFA, 0x37, 0x49, 0x56]};
+enum IID IID_IUrlHistoryNotify = {0xBC40BEC1, 0xC493, 0x11D0, [0x83, 0x1B, 0x00, 0xC0, 0x4F, 0xD5, 0xAE, 0x38]};
+enum IID IID_IUrlHistoryStg = {0x3C374A41, 0xBAE4, 0x11CF, [0xBF, 0x7D, 0x00, 0xAA, 0x00, 0x69, 0x46, 0xEE]};
+enum IID IID_IUrlHistoryStg2 = {0xAFA0DC11, 0xC313, 0x11D0, [0x83, 0x1A, 0x00, 0xC0, 0x4F, 0xD5, 0xAE, 0x38]};
+enum IID IID_IUrlMon = {0x00000026, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IURLSearchHook = {0xAC60F6A0, 0x0FD9, 0x11D0, [0x99, 0xCB, 0x00, 0xC0, 0x4F, 0xD6, 0x44, 0x97]};
+enum IID IID_IURLSearchHook2 = {0x5EE44DA4, 0x6D32, 0x46E3, [0x86, 0xBC, 0x07, 0x54, 0x0D, 0xED, 0xD0, 0xE0]};
+enum IID IID_IUrlTrackingStg = {0xF2F8CBB3, 0xB040, 0x11D0, [0xBB, 0x16, 0x00, 0xC0, 0x4F, 0xB6, 0x6F, 0x63]};
+enum IID IID_IUserEventTimer = {0x0F504B94, 0x6E42, 0x42E6, [0x99, 0xE0, 0xE2, 0x0F, 0xAF, 0xE5, 0x2A, 0xB4]};
+enum IID IID_IUserEventTimerCallback = {0xE9EAD8E6, 0x2A25, 0x410E, [0x9B, 0x58, 0xA9, 0xFB, 0xEF, 0x1D, 0xD1, 0xA2]};
+enum IID IID_IUserNotification = {0xBA9711BA, 0x5893, 0x4787, [0xA7, 0xE1, 0x41, 0x27, 0x71, 0x51, 0x55, 0x0B]};
+enum IID IID_IUtilityButton = {0x3050F6AF, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID IID_IVariantChangeType = {0xA6EF9862, 0xC720, 0x11D0, [0x93, 0x37, 0x00, 0xA0, 0xC9, 0x0D, 0xCA, 0xA9]};
+enum IID IID_IVersionHost = {0x667115AC, 0xDC02, 0x11D1, [0xBA, 0x57, 0x00, 0xC0, 0x4F, 0xC2, 0x04, 0x0E]};
+enum IID IID_IVersionVector = {0x4EB01410, 0xDB1A, 0x11D1, [0xBA, 0x53, 0x00, 0xC0, 0x4F, 0xC2, 0x04, 0x0E]};
+enum IID IID_IViewChapter = {0x0C733A98, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IViewFilter = {0x0C733A9B, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IViewObject = {0x0000010D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IViewObject2 = {0x00000127, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IViewObjectEx = {0x3AF24292, 0x0C96, 0x11CE, [0xA0, 0xCF, 0x00, 0xAA, 0x00, 0x60, 0x0A, 0xB8]};
+enum IID IID_IViewRowset = {0x0C733A97, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IViewSort = {0x0C733A9A, 0x2A1C, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID IID_IVirusScanEngine = {0x083DB180, 0xB4A8, 0x11CF, [0xAA, 0xFA, 0x00, 0xAA, 0x00, 0xB6, 0x01, 0x5C]};
+enum IID IID_IVirusScanner = {0x4589BEE0, 0xB4B1, 0x11CF, [0xAA, 0xFA, 0x00, 0xAA, 0x00, 0xB6, 0x01, 0x5C]};
+enum IID IID_IWaitMultiple = {0x0000002B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IWbemAddressResolution = {0xF7CE2E12, 0x8C90, 0x11D1, [0x9E, 0x7B, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID IID_IWbemBackupRestore = {0xC49E32C7, 0xBC8B, 0x11D2, [0x85, 0xD4, 0x00, 0x10, 0x5A, 0x1F, 0x83, 0x04]};
+enum IID IID_IWbemBackupRestoreEx = {0xA359DEC5, 0xE813, 0x4834, [0x8A, 0x2A, 0xBA, 0x7F, 0x1D, 0x77, 0x7D, 0x76]};
+enum IID IID_IWbemCallResult = {0x44ACA675, 0xE8FC, 0x11D0, [0xA0, 0x7C, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID IID_IWbemCallStatus = {0x4212DC47, 0x142E, 0x4C6C, [0xBC, 0x49, 0x6C, 0xA2, 0x32, 0xDD, 0x09, 0x59]};
+enum IID IID_IWbemClassObject = {0xDC12A681, 0x737F, 0x11CF, [0x88, 0x4D, 0x00, 0xAA, 0x00, 0x4B, 0x2E, 0x24]};
+enum IID IID_IWbemClientConnectionTransport = {0xA889C72A, 0xFCC1, 0x4A9E, [0xAF, 0x61, 0xED, 0x07, 0x13, 0x33, 0xFB, 0x5B]};
+enum IID IID_IWbemClientTransport = {0xF7CE2E11, 0x8C90, 0x11D1, [0x9E, 0x7B, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID IID_IWbemConfigure = {0x9A368276, 0x26CF, 0x11D0, [0xAD, 0x3C, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID IID_IWbemConfigureRefresher = {0x49353C92, 0x516B, 0x11D1, [0xAE, 0xA6, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID IID_IWbemConnectorLogin = {0xD8EC9CB1, 0xB135, 0x4F10, [0x8B, 0x1B, 0xC7, 0x18, 0x8B, 0xB0, 0xD1, 0x86]};
+enum IID IID_IWbemConstructClassObject = {0x9EF76194, 0x70D5, 0x11D1, [0xAD, 0x90, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID IID_IWbemContext = {0x44ACA674, 0xE8FC, 0x11D0, [0xA0, 0x7C, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID IID_IWbemDecoupledBasicEventProvider = {0x86336D20, 0xCA11, 0x4786, [0x9E, 0xF1, 0xBC, 0x8A, 0x94, 0x6B, 0x42, 0xFC]};
+enum IID IID_IWbemDecoupledEventSink = {0xCD94EBF2, 0xE622, 0x11D2, [0x9C, 0xB3, 0x00, 0x10, 0x5A, 0x1F, 0x48, 0x01]};
+enum IID IID_IWbemDecoupledRegistrar = {0x1005CBCF, 0xE64F, 0x4646, [0xBC, 0xD3, 0x3A, 0x08, 0x9D, 0x8A, 0x84, 0xB4]};
+enum IID IID_IWbemEventConsumerProvider = {0xE246107A, 0xB06E, 0x11D0, [0xAD, 0x61, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID IID_IWbemEventConsumerProviderEx = {0x17CF534A, 0xD8A3, 0x4AD0, [0xAC, 0x92, 0x5E, 0x3D, 0x01, 0x71, 0x71, 0x51]};
+enum IID IID_IWbemEventProvider = {0xE245105B, 0xB06E, 0x11D0, [0xAD, 0x61, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID IID_IWbemEventProviderQuerySink = {0x580ACAF8, 0xFA1C, 0x11D0, [0xAD, 0x72, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID IID_IWbemEventProviderSecurity = {0x631F7D96, 0xD993, 0x11D2, [0xB3, 0x39, 0x00, 0x10, 0x5A, 0x1F, 0x4A, 0xAF]};
+enum IID IID_IWbemEventSink = {0x3AE0080A, 0x7E3A, 0x4366, [0xBF, 0x89, 0x0F, 0xEE, 0xDC, 0x93, 0x16, 0x59]};
+enum IID IID_IWbemHiPerfEnum = {0x2705C288, 0x79AE, 0x11D2, [0xB3, 0x48, 0x00, 0x10, 0x5A, 0x1F, 0x81, 0x77]};
+enum IID IID_IWbemHiPerfProvider = {0x49353C93, 0x516B, 0x11D1, [0xAE, 0xA6, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID IID_IWbemLevel1Login = {0xF309AD18, 0xD86A, 0x11D0, [0xA0, 0x75, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID IID_IWbemLocator = {0xDC12A687, 0x737F, 0x11CF, [0x88, 0x4D, 0x00, 0xAA, 0x00, 0x4B, 0x2E, 0x24]};
+enum IID IID_IWbemObjectAccess = {0x49353C9A, 0x516B, 0x11D1, [0xAE, 0xA6, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID IID_IWbemObjectSink = {0x7C857801, 0x7381, 0x11CF, [0x88, 0x4D, 0x00, 0xAA, 0x00, 0x4B, 0x2E, 0x24]};
+enum IID IID_IWbemObjectTextSrc = {0xBFBF883A, 0xCAD7, 0x11D3, [0xA1, 0x1B, 0x00, 0x10, 0x5A, 0x1F, 0x51, 0x5A]};
+enum IID IID_IWbemPath = {0x3BC15AF2, 0x736C, 0x477E, [0x9E, 0x51, 0x23, 0x8A, 0xF8, 0x66, 0x7D, 0xCC]};
+enum IID IID_IWbemPathKeyList = {0x9AE62877, 0x7544, 0x4BB0, [0xAA, 0x26, 0xA1, 0x38, 0x24, 0x65, 0x9E, 0xD6]};
+enum IID IID_IWbemPropertyProvider = {0xCE61E841, 0x65BC, 0x11D0, [0xB6, 0xBD, 0x00, 0xAA, 0x00, 0x32, 0x40, 0xC7]};
+enum IID IID_IWbemProviderIdentity = {0x631F7D97, 0xD993, 0x11D2, [0xB3, 0x39, 0x00, 0x10, 0x5A, 0x1F, 0x4A, 0xAF]};
+enum IID IID_IWbemProviderInit = {0x1BE41572, 0x91DD, 0x11D1, [0xAE, 0xB2, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID IID_IWbemProviderInitSink = {0x1BE41571, 0x91DD, 0x11D1, [0xAE, 0xB2, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID IID_IWbemQualifierSet = {0xDC12A680, 0x737F, 0x11CF, [0x88, 0x4D, 0x00, 0xAA, 0x00, 0x4B, 0x2E, 0x24]};
+enum IID IID_IWbemQuery = {0x81166F58, 0xDD98, 0x11D3, [0xA1, 0x20, 0x00, 0x10, 0x5A, 0x1F, 0x51, 0x5A]};
+enum IID IID_IWbemRawSdAccessor = {0xC1E2D759, 0xCABD, 0x11D3, [0xA1, 0x1B, 0x00, 0x10, 0x5A, 0x1F, 0x51, 0x5A]};
+enum IID IID_IWbemRefresher = {0x49353C99, 0x516B, 0x11D1, [0xAE, 0xA6, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID IID_IWbemServices = {0x9556DC99, 0x828C, 0x11CF, [0xA3, 0x7E, 0x00, 0xAA, 0x00, 0x32, 0x40, 0xC7]};
+enum IID IID_IWbemShutdown = {0xB7B31DF9, 0xD515, 0x11D3, [0xA1, 0x1C, 0x00, 0x10, 0x5A, 0x1F, 0x51, 0x5A]};
+enum IID IID_IWbemStatusCodeText = {0xEB87E1BC, 0x3233, 0x11D2, [0xAE, 0xC9, 0x00, 0xC0, 0x4F, 0xB6, 0x88, 0x20]};
+enum IID IID_IWbemTransport = {0x553FE584, 0x2156, 0x11D0, [0xB6, 0xAE, 0x00, 0xAA, 0x00, 0x32, 0x40, 0xC7]};
+enum IID IID_IWbemUnboundObjectSink = {0xE246107B, 0xB06E, 0x11D0, [0xAD, 0x61, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID IID_IWBScriptControl = {0xA5170870, 0x0CF8, 0x11D1, [0x8B, 0x91, 0x00, 0x80, 0xC7, 0x44, 0xF3, 0x89]};
+enum IID IID_IWCContextMenuCallback = {0x97DEDE64, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IWCPropertySheetCallback = {0x97DEDE60, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IWCWizard97Callback = {0x97DEDE67, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IWCWizardCallback = {0x97DEDE62, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IWebBridge = {0xAE24FDAD, 0x03C6, 0x11D1, [0x8B, 0x76, 0x00, 0x80, 0xC7, 0x44, 0xF3, 0x89]};
+enum IID IID_IWebBrowser = {0xEAB22AC1, 0x30C1, 0x11CF, [0xA7, 0xEB, 0x00, 0x00, 0xC0, 0x5B, 0xAE, 0x0B]};
+enum IID IID_IWebBrowser2 = {0xD30C1661, 0xCDAF, 0x11D0, [0x8A, 0x3E, 0x00, 0xC0, 0x4F, 0xC9, 0xE2, 0x6E]};
+enum IID IID_IWebBrowserApp = {0x0002DF05, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID IID_IWebWizardExtension = {0x0E6B3F66, 0x98D1, 0x48C0, [0xA2, 0x22, 0xFB, 0xDE, 0x74, 0xE2, 0xFB, 0xC5]};
+enum IID IID_IWebWizardHost = {0x18BCC359, 0x4990, 0x4BFB, [0xB9, 0x51, 0x3C, 0x83, 0x70, 0x2B, 0xE5, 0xF9]};
+enum IID IID_IWEExtendContextMenu = {0x97DEDE65, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IWEExtendPropertySheet = {0x97DEDE61, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IWEExtendWizard = {0x97DEDE63, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IWEExtendWizard97 = {0x97DEDE68, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_IWEInvokeCommand = {0x97DEDE66, 0xFC6B, 0x11CF, [0xB5, 0xF5, 0x00, 0xA0, 0xC9, 0x0A, 0xB5, 0x05]};
+enum IID IID_Iwfolders = {0xBAE31F98, 0x1B81, 0x11D2, [0xA9, 0x7A, 0x00, 0xC0, 0x4F, 0x8E, 0xCB, 0x02]};
+enum IID IID_IWindowForBindingUI = {0x79EAC9D5, 0xBAFA, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IWinInetHttpInfo = {0x79EAC9D8, 0xBAFA, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IWinInetInfo = {0x79EAC9D6, 0xBAFA, 0x11CE, [0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B]};
+enum IID IID_IWizardExtension = {0xC02EA696, 0x86CC, 0x491E, [0x9B, 0x23, 0x74, 0x39, 0x4A, 0x04, 0x44, 0xA8]};
+enum IID IID_IWizardSite = {0x88960F5B, 0x422F, 0x4E7B, [0x80, 0x13, 0x73, 0x41, 0x53, 0x81, 0xC3, 0xC3]};
+enum IID IID_IWMIExtension = {0xADC1F06E, 0x5C7E, 0x11D2, [0x8B, 0x74, 0x00, 0x10, 0x4B, 0x2A, 0xFB, 0x41]};
+enum IID IID_IWordBreaker = {0xD53552C8, 0x77E3, 0x101A, [0xB5, 0x52, 0x08, 0x00, 0x2B, 0x33, 0xB0, 0xE6]};
+enum IID IID_IWordSink = {0xCC907054, 0xC058, 0x101A, [0xB5, 0x54, 0x08, 0x00, 0x2B, 0x33, 0xB0, 0xE6]};
+enum IID IID_IWrappedProtocol = {0x53C84785, 0x8425, 0x4DC5, [0x97, 0x1B, 0xE5, 0x8D, 0x9C, 0x19, 0xF9, 0xB6]};
+enum IID IID_IXMLAttribute = {0xD4D4A0FC, 0x3B73, 0x11D1, [0xB2, 0xB4, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0x96]};
+enum IID IID_IXMLDocument = {0xF52E2B61, 0x18A1, 0x11D1, [0xB1, 0x05, 0x00, 0x80, 0x5F, 0x49, 0x91, 0x6B]};
+enum IID IID_IXMLDocument2 = {0x2B8DE2FE, 0x8D2D, 0x11D1, [0xB2, 0xFC, 0x00, 0xC0, 0x4F, 0xD9, 0x15, 0xA9]};
+enum IID IID_IXMLDOMAttribute = {0x2933BF85, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMCDATASection = {0x2933BF8A, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMCharacterData = {0x2933BF84, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMComment = {0x2933BF88, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMDocument = {0x2933BF81, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMDocumentFragment = {0x3EFAA413, 0x272F, 0x11D2, [0x83, 0x6F, 0x00, 0x00, 0xF8, 0x7A, 0x77, 0x82]};
+enum IID IID_IXMLDOMDocumentType = {0x2933BF8B, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMElement = {0x2933BF86, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMEntity = {0x2933BF8D, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMEntityReference = {0x2933BF8E, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMImplementation = {0x2933BF8F, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMNamedNodeMap = {0x2933BF83, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMNode = {0x2933BF80, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMNodeList = {0x2933BF82, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMNotation = {0x2933BF8C, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMParseError = {0x3EFAA426, 0x272F, 0x11D2, [0x83, 0x6F, 0x00, 0x00, 0xF8, 0x7A, 0x77, 0x82]};
+enum IID IID_IXMLDOMProcessingInstruction = {0x2933BF89, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDOMText = {0x2933BF87, 0x7B36, 0x11D2, [0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60]};
+enum IID IID_IXMLDSOControl = {0x310AFA62, 0x0575, 0x11D2, [0x9C, 0xA9, 0x00, 0x60, 0xB0, 0xEC, 0x3D, 0x39]};
+enum IID IID_IXMLElement = {0x3F7F31AC, 0xE15F, 0x11D0, [0x9C, 0x25, 0x00, 0xC0, 0x4F, 0xC9, 0x9C, 0x8E]};
+enum IID IID_IXMLElement2 = {0x2B8DE2FF, 0x8D2D, 0x11D1, [0xB2, 0xFC, 0x00, 0xC0, 0x4F, 0xD9, 0x15, 0xA9]};
+enum IID IID_IXMLElementCollection = {0x65725580, 0x9B5D, 0x11D0, [0x9B, 0xFE, 0x00, 0xC0, 0x4F, 0xC9, 0x9C, 0x8E]};
+enum IID IID_IXMLError = {0x948C5AD3, 0xC58D, 0x11D0, [0x9C, 0x0B, 0x00, 0xC0, 0x4F, 0xC9, 0x9C, 0x8E]};
+enum IID IID_IXMLGenericParse = {0xE4E23071, 0x4D07, 0x11D2, [0xAE, 0x76, 0x00, 0x80, 0xC7, 0x3B, 0xC1, 0x99]};
+enum IID IID_IXMLHttpRequest = {0xED8C108D, 0x4349, 0x11D2, [0x91, 0xA4, 0x00, 0xC0, 0x4F, 0x79, 0x69, 0xE8]};
+enum IID IID_IXMLNodeFactory = {0xD242361F, 0x51A0, 0x11D2, [0x9C, 0xAF, 0x00, 0x60, 0xB0, 0xEC, 0x3D, 0x39]};
+enum IID IID_IXMLNodeSource = {0xD242361D, 0x51A0, 0x11D2, [0x9C, 0xAF, 0x00, 0x60, 0xB0, 0xEC, 0x3D, 0x39]};
+enum IID IID_IXMLParser = {0xD242361E, 0x51A0, 0x11D2, [0x9C, 0xAF, 0x00, 0x60, 0xB0, 0xEC, 0x3D, 0x39]};
+enum IID IID_IXTLRuntime = {0x3EFAA425, 0x272F, 0x11D2, [0x83, 0x6F, 0x00, 0x00, 0xF8, 0x7A, 0x77, 0x82]};
+enum IID IID_StdOle = {0x00020430, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID KSDATAFORMAT_SUBTYPE_DIRECTMUSIC = {0x1A82F8BC, 0x3F8B, 0x11D2, [0xB7, 0x74, 0x00, 0x60, 0x08, 0x33, 0x16, 0xC1]};
+enum IID KSDATAFORMAT_SUBTYPE_MIDI = {0x1D262760, 0xE957, 0x11CF, [0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00]};
+enum IID LIBID_Accessibility = {0x1EA4DBF0, 0x3C3B, 0x11CF, [0x81, 0x0C, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71]};
+enum IID LIBID_ActiveIMM = {0x4955DD30, 0xB159, 0x11D0, [0x8F, 0xCF, 0x00, 0xAA, 0x00, 0x6B, 0xCC, 0x59]};
+enum IID LIBID_ADs = {0x97D25DB0, 0x0363, 0x11CF, [0xAB, 0xC4, 0x02, 0x60, 0x8C, 0x9E, 0x75, 0x53]};
+enum IID LIBID_ALGLib = {0xB6D1D098, 0xE235, 0x4B99, [0xBA, 0x98, 0x7C, 0x62, 0x4F, 0xD8, 0x75, 0xDB]};
+enum IID LIBID_AutoDiscovery = {0x4EAFB888, 0x81CB, 0x4EBA, [0xBA, 0xC9, 0xDA, 0x25, 0x4E, 0x57, 0x21, 0xF1]};
+enum IID LIBID_BackgroundCopyManager = {0x1DEEB74F, 0x7915, 0x4560, [0xB5, 0x58, 0x91, 0x8C, 0x83, 0xF1, 0x76, 0xA6]};
+enum IID LIBID_BackgroundCopyManager1_5 = {0xEA9319EA, 0xC628, 0x480F, [0x83, 0x31, 0x76, 0x8F, 0xAC, 0x39, 0x7E, 0x4E]};
+enum IID LIBID_BackgroundCopyQMgr = {0xF5B26DCB, 0xB37E, 0x4D7C, [0xAE, 0x7A, 0x1C, 0xB3, 0xFB, 0xEB, 0x18, 0x3E]};
+enum IID LIBID_CHANNELMGR = {0x4804F2E0, 0xD16E, 0x11D0, [0x80, 0x2B, 0x00, 0xC0, 0x4F, 0xD7, 0x5D, 0x13]};
+enum IID LIBID_CLADMWIZLib = {0x24F97140, 0x6689, 0x11D1, [0x9A, 0xA7, 0x00, 0xC0, 0x4F, 0xB9, 0x3A, 0x80]};
+enum IID LIBID_ClusCfgWizard = {0x6D01FEDC, 0x8D34, 0x4728, [0xAD, 0x0B, 0xB3, 0xA2, 0x1A, 0x10, 0x3B, 0x42]};
+enum IID LIBID_CommonControlObjects = {0xBCADA15B, 0xB428, 0x420C, [0x8D, 0x28, 0x02, 0x35, 0x90, 0x92, 0x4C, 0x9F]};
+enum IID LIBID_DirectAnimation = {0xBCBB1F74, 0xE384, 0x11D0, [0x9B, 0x99, 0x00, 0xC0, 0x4F, 0xC2, 0xF5, 0x1D]};
+enum IID LIBID_DWbemServices_v3 = {0xCB7CA031, 0xF729, 0x11D0, [0x9E, 0x4D, 0x00, 0xC0, 0x4F, 0xC3, 0x24, 0xA8]};
+enum IID LIBID_DXTMSFTLib = {0x5E77EB03, 0x937C, 0x11D1, [0xB0, 0x47, 0x00, 0xAA, 0x00, 0x3B, 0x60, 0x61]};
+enum IID LIBID_DXTRANSLib = {0x54314D1D, 0x35FE, 0x11D1, [0x81, 0xA1, 0x00, 0x00, 0xF8, 0x75, 0x57, 0xDB]};
+enum IID LIBID_DXTRANSPLib = {0x527A4DA4, 0x7F2C, 0x11D2, [0xB1, 0x2D, 0x00, 0x00, 0xF8, 0x1F, 0x59, 0x95]};
+enum IID LIBID_EventQLib = {0xA70080F2, 0x403B, 0x11D1, [0x88, 0x36, 0x00, 0xA0, 0xC9, 0x49, 0xAC, 0x67]};
+enum IID LIBID_IASPolicyLib = {0x6BC096A5, 0x0CE6, 0x11D1, [0xBA, 0xAE, 0x00, 0xC0, 0x4F, 0xC2, 0xE2, 0x0D]};
+enum IID LIBID_IEXTagLib = {0x7E8BC440, 0xAEFF, 0x11D1, [0x89, 0xC2, 0x00, 0xC0, 0x4F, 0xB6, 0xBF, 0xC4]};
+enum IID LIBID_IMAPILib = {0xC49F2184, 0x50A7, 0x11D3, [0x91, 0x44, 0x00, 0x10, 0x4B, 0xA1, 0x1C, 0x5E]};
+enum IID LIBID_ImgUtilLib = {0xCF790840, 0x2DC4, 0x11D0, [0xB7, 0x24, 0x00, 0xAA, 0x00, 0x6C, 0x1A, 0x01]};
+enum IID LIBID_ITRKADMNLib = {0xA2531F35, 0xC67D, 0x11D0, [0x8C, 0xB1, 0x00, 0xC0, 0x4F, 0xD9, 0x0F, 0x85]};
+enum IID LIBID_McastLib = {0x64217CC0, 0xA285, 0x11D1, [0x86, 0x97, 0x00, 0x60, 0x08, 0xB0, 0xE5, 0xD2]};
+enum IID LIBID_MSHTML = {0x3050F1C5, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID LIBID_MSHTMLINTERNAL = {0x3050F7E1, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID LIBID_MSTIME = {0x87C96271, 0xADDB, 0x4745, [0xB2, 0xE8, 0xDF, 0x88, 0xA8, 0x47, 0x2F, 0xD1]};
+enum IID LIBID_MSXML = {0xD63E0CE2, 0xA0A2, 0x11D0, [0x9C, 0x02, 0x00, 0xC0, 0x4F, 0xC9, 0x9C, 0x8E]};
+enum IID LIBID_MultiLanguage = {0x275C23E0, 0x3747, 0x11D0, [0x9F, 0xEA, 0x00, 0xAA, 0x00, 0x3F, 0x86, 0x46]};
+enum IID LIBID_NATUPNPLib = {0x1C565858, 0xF302, 0x471E, [0xB4, 0x09, 0xF1, 0x80, 0xAA, 0x4A, 0xBE, 0xC6]};
+enum IID LIBID_NETCONLib = {0x43E734CA, 0x043D, 0x4A70, [0x9A, 0x2C, 0xA8, 0xF2, 0x54, 0x06, 0x3D, 0x91]};
+enum IID LIBID_PassiveSink = {0xE002EEEF, 0xE6EA, 0x11D2, [0x9C, 0xB3, 0x00, 0x10, 0x5A, 0x1F, 0x48, 0x01]};
+enum IID LIBID_ProcessDebugManagerLib = {0x78A51821, 0x51F4, 0x11D0, [0x8F, 0x20, 0x00, 0x80, 0x5F, 0x2C, 0xD0, 0x64]};
+enum IID LIBID_RENDLib = {0xF1029E4D, 0xCB5B, 0x11D0, [0x8D, 0x59, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID LIBID_RTCCORELib = {0xCD260094, 0xDE10, 0x4AEE, [0xAC, 0x73, 0xEF, 0x87, 0xF6, 0xE1, 0x26, 0x83]};
+enum IID LIBID_SDOIASLib = {0x81DDF732, 0x4AA8, 0x4A35, [0xBD, 0xFF, 0x8B, 0x42, 0xEF, 0xE7, 0xC6, 0x24]};
+enum IID LIBID_SDPBLBLib = {0xC259D79A, 0xC8AB, 0x11D0, [0x8D, 0x58, 0x00, 0xC0, 0x4F, 0xD9, 0x1A, 0xC0]};
+enum IID LIBID_SensEvents = {0xD597DEED, 0x5B9F, 0x11D1, [0x8D, 0xD2, 0x00, 0xAA, 0x00, 0x4A, 0xBD, 0x5E]};
+enum IID LIBID_SHDocVw = {0xEAB22AC0, 0x30C1, 0x11CF, [0xA7, 0xEB, 0x00, 0x00, 0xC0, 0x5B, 0xAE, 0x0B]};
+enum IID LIBID_Shell32 = {0x50A7E9B0, 0x70EF, 0x11D1, [0xB7, 0x5A, 0x00, 0xA0, 0xC9, 0x05, 0x64, 0xFE]};
+enum IID LIBID_ShellImageData = {0x0B8AFF06, 0x8DF0, 0x4F13, [0x8E, 0x25, 0x25, 0xB2, 0x31, 0x9C, 0x43, 0x6A]};
+enum IID LIBID_ShellObjects = {0x50A7E9B1, 0x70EF, 0x11D1, [0xB7, 0x5A, 0x00, 0xA0, 0xC9, 0x05, 0x64, 0xFE]};
+enum IID LIBID_SHGINALib = {0x0A055C02, 0xBABE, 0x4480, [0xBB, 0x7B, 0xA8, 0xEC, 0x72, 0x3C, 0xE9, 0xC0]};
+enum IID LIBID_SubscriptionMgr = {0xC54FD88A, 0xFFA1, 0x11D0, [0xBC, 0x5E, 0x00, 0xC0, 0x4F, 0xD9, 0x29, 0xDB]};
+enum IID LIBID_TAPI3Lib = {0x21D6D480, 0xA88B, 0x11D0, [0x83, 0xDD, 0x00, 0xAA, 0x00, 0x3C, 0xCA, 0xBD]};
+enum IID LIBID_TERMMGRLib = {0x28DCD85B, 0xACA4, 0x11D0, [0xA0, 0x28, 0x00, 0xAA, 0x00, 0xB6, 0x05, 0xA4]};
+enum IID LIBID_UPnPHostLib = {0x204810B3, 0x73B2, 0x11D4, [0xBF, 0x42, 0x00, 0xB0, 0xD0, 0x11, 0x8B, 0x56]};
+enum IID LIBID_UPNPLib = {0xDB3442A7, 0xA2E9, 0x4A59, [0x9C, 0xB5, 0xF5, 0xC1, 0xA5, 0xD9, 0x01, 0xE5]};
+enum IID LIBID_VIRUSSCAN = {0x5F47DB70, 0xD9FE, 0x11D0, [0x95, 0x64, 0x00, 0x60, 0x97, 0x97, 0xEA, 0x4F]};
+enum IID LIBID_WbemClient_v1 = {0x7EC196FE, 0x7005, 0x11D1, [0xAD, 0x90, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID LIBID_WbemProviders_v1 = {0x092DF710, 0x7010, 0x11D1, [0xAD, 0x90, 0x00, 0xC0, 0x4F, 0xD8, 0xFD, 0xFF]};
+enum IID LIBID_WbemScripting = {0x565783C6, 0xCB41, 0x11D1, [0x8B, 0x02, 0x00, 0x60, 0x08, 0x06, 0xD9, 0xB6]};
+enum IID LIBID_WbemTransports_v1 = {0x027947F3, 0xD731, 0x11CE, [0xA3, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]};
+enum IID LIBID_WbemUtilities_v1 = {0x226C9290, 0xDD96, 0x11D3, [0xA1, 0x20, 0x00, 0x10, 0x5A, 0x1F, 0x51, 0x5A]};
+enum IID LIBID_WebCheck = {0x10BD2E25, 0xF235, 0x11CF, [0xB5, 0xDD, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xEC]};
+enum IID LIBID_WMIEXTENSIONLib = {0xE503D000, 0x5C7F, 0x11D2, [0x8B, 0x74, 0x00, 0x10, 0x4B, 0x2A, 0xFB, 0x41]};
+enum IID LIBID_XENROLLLib = {0x43F8F27B, 0x7A20, 0x11D0, [0x8F, 0x06, 0x00, 0xC0, 0x4F, 0xC2, 0x95, 0xE1]};
+enum IID LIBID_XMLPSR = {0xD242361C, 0x51A0, 0x11D2, [0x9C, 0xAF, 0x00, 0x60, 0xB0, 0xEC, 0x3D, 0x39]};
+enum IID MDGUID_MDX = {0xA07CCCD0, 0x8148, 0x11D0, [0x87, 0xBB, 0x00, 0xC0, 0x4F, 0xC3, 0x39, 0x42]};
+enum IID MDSCHEMA_ACTIONS = {0xA07CCD08, 0x8148, 0x11D0, [0x87, 0xBB, 0x00, 0xC0, 0x4F, 0xC3, 0x39, 0x42]};
+enum IID MDSCHEMA_COMMANDS = {0xA07CCD09, 0x8148, 0x11D0, [0x87, 0xBB, 0x00, 0xC0, 0x4F, 0xC3, 0x39, 0x42]};
+enum IID MDSCHEMA_CUBES = {0xC8B522D8, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID MDSCHEMA_DIMENSIONS = {0xC8B522D9, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID MDSCHEMA_FUNCTIONS = {0xA07CCD07, 0x8148, 0x11D0, [0x87, 0xBB, 0x00, 0xC0, 0x4F, 0xC3, 0x39, 0x42]};
+enum IID MDSCHEMA_HIERARCHIES = {0xC8B522DA, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID MDSCHEMA_LEVELS = {0xC8B522DB, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID MDSCHEMA_MEASURES = {0xC8B522DC, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID MDSCHEMA_MEMBERS = {0xC8B522DE, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID MDSCHEMA_PROPERTIES = {0xC8B522DD, 0x5CF3, 0x11CE, [0xAD, 0xE5, 0x00, 0xAA, 0x00, 0x44, 0x77, 0x3D]};
+enum IID MDSCHEMA_SETS = {0xA07CCD0B, 0x8148, 0x11D0, [0x87, 0xBB, 0x00, 0xC0, 0x4F, 0xC3, 0x39, 0x42]};
+enum IID NAMEDTIMER_DRAW = {0x3050F362, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID NOTFCOOKIE_SCHEDULE_GROUP_DAILY = {0xD34F18B0, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTFCOOKIE_SCHEDULE_GROUP_MANUAL = {0xD34F18B3, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTFCOOKIE_SCHEDULE_GROUP_MONTHLY = {0xD34F18B2, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTFCOOKIE_SCHEDULE_GROUP_WEEKLY = {0xD34F18B1, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_11 = {0xD34F17FB, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_12 = {0xD34F17FC, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_13 = {0xD34F17FD, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_14 = {0xD34F17FE, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_15 = {0xD34F17FF, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_AGENT_INIT = {0x1E4A7390, 0xC70B, 0x11D0, [0x95, 0xF8, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xEC]};
+enum IID NOTIFICATIONTYPE_AGENT_START = {0xD34F17EC, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_ALERT = {0xD34F17E3, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_ANOUNCMENT = {0xD34F17E1, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_BEGIN_REPORT = {0xD34F17EE, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_CONFIG_CHANGED = {0xD34F17F2, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_CONNECT_TO_INTERNET = {0xD34F17F0, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_d = {0xD34F17F8, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_DISCONNECT_FROM_INTE = {0xD34F17F1, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_e = {0xD34F17F9, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_END_REPORT = {0xD34F17EF, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_f = {0xD34F17FA, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_GROUP_DONE = {0xD34F1885, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_GROUP_RESTART = {0xD34F1884, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_GROUP_START = {0xD34F1883, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_i6 = {0xD34F1886, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_i7 = {0xD34F1887, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_i8 = {0xD34F1888, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_i9 = {0xD34F1889, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_iA = {0xD34F188A, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_iB = {0xD34F188B, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_iC = {0xD34F188C, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_iD = {0xD34F188D, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_iE = {0xD34F188E, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_iF = {0xD34F188F, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_INET_IDLE = {0xD34F17E4, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_INET_OFFLINE = {0xD34F17E5, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_INET_ONLINE = {0xD34F17E6, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_ITEM_DONE = {0xD34F1882, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_ITEM_RESTART = {0xD34F1881, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_ITEM_START = {0xD34F1880, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_NULL = {0xD34F17E0, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_PROGRESS_REPORT = {0xD34F17F3, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_0 = {0xD34F1800, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_1 = {0xD34F1801, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_2 = {0xD34F1802, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_3 = {0xD34F1803, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_4 = {0xD34F1804, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_5 = {0xD34F1805, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_6 = {0xD34F1806, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_7 = {0xD34F1807, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_8 = {0xD34F1808, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_9 = {0xD34F1809, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_A = {0xD34F180A, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_B = {0xD34F180B, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_C = {0xD34F180C, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_D = {0xD34F180D, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_E = {0xD34F180E, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_START_F = {0xD34F180F, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_TASK = {0xD34F17E2, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_TASKS_ABORT = {0xD34F17E9, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_TASKS_COMPLETED = {0xD34F17EA, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_TASKS_ERROR = {0xD34F17F7, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_TASKS_PROGRESS = {0xD34F17EB, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_TASKS_RESUME = {0xD34F17E8, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_TASKS_STARTED = {0xD34F17F6, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_TASKS_SUSPEND = {0xD34F17E7, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_USER_IDLE_BEGIN = {0xD34F17F4, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID NOTIFICATIONTYPE_USER_IDLE_END = {0xD34F17F5, 0x576E, 0x11D0, [0xB2, 0x8C, 0x00, 0xC0, 0x4F, 0xD7, 0xCD, 0x22]};
+enum IID OLE_DATAPATH_ALLIMAGE = {0x0002DE0E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_ALLMM = {0x0002DE18, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_ALLTEXT = {0x0002DE1E, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_ANSITEXT = {0x0002DE19, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_AVI = {0x0002DE0F, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_BASICAUDIO = {0x0002DE12, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_BIFF = {0x0002DE21, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_BMP = {0x0002DE01, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_CGM = {0x0002DE0B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_COMMONIMAGE = {0x0002DE0D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_DIB = {0x0002DE02, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_DIF = {0x0002DE1F, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_ENHMF = {0x0002DE04, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_EPS = {0x0002DE0C, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_GIF = {0x0002DE05, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_HTML = {0x0002DE1C, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_JPEG = {0x0002DE06, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_MIDI = {0x0002DE13, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_MPEG = {0x0002DE10, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_PALETTE = {0x0002DE22, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_PCX = {0x0002DE09, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_PENDATA = {0x0002DE23, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_PICT = {0x0002DE0A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_POSTSCRIPT = {0x0002DE1D, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_QUICKTIME = {0x0002DE11, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_RIFF = {0x0002DE15, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_RTF = {0x0002DE1B, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_SOUND = {0x0002DE16, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_SYLK = {0x0002DE20, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_TIFF = {0x0002DE07, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_UNICODE = {0x0002DE1A, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_VIDEO = {0x0002DE17, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_WAV = {0x0002DE14, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_WMF = {0x0002DE03, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLE_DATAPATH_XBM = {0x0002DE08, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};
+enum IID OLEDB_SVC_DSLPropertyPages = {0x51740C02, 0x7E8E, 0x11D2, [0xA0, 0x2D, 0x00, 0xC0, 0x4F, 0xA3, 0x73, 0x48]};
+enum IID PSGUID_QUERY = {0x49691C90, 0x7E17, 0x101A, [0xA9, 0x1C, 0x08, 0x00, 0x2B, 0x2E, 0xCD, 0xA9]};
+enum IID RESCLASSTYPE_IPAddress = {0x57A80E0F, 0x6F18, 0x458B, [0xA7, 0x2A, 0xD1, 0x17, 0x0C, 0x47, 0x93, 0x90]};
+enum IID RESCLASSTYPE_NetworkName = {0xBBA69EB9, 0xF5D0, 0x487B, [0x92, 0xAE, 0x1B, 0xA1, 0x0F, 0x39, 0x21, 0x58]};
+enum IID RESCLASSTYPE_StorageDevice = {0x12453A47, 0x8C5E, 0x4837, [0xBA, 0xC6, 0xB2, 0x54, 0xB8, 0xF2, 0x64, 0xCC]};
+enum IID RESTYPE_ClusterIPAddress = {0xE50DF832, 0x477C, 0x440C, [0xB7, 0xA3, 0x38, 0x23, 0xA6, 0xEF, 0x6C, 0xCB]};
+enum IID RESTYPE_ClusterNetName = {0xB2897CCF, 0x8D2C, 0x4BC1, [0xB4, 0x96, 0x6E, 0x2B, 0xC7, 0xA0, 0xBB, 0x38]};
+enum IID RESTYPE_ClusterQuorumDisk = {0xD9DDFB80, 0x0BDC, 0x40D4, [0xB3, 0x96, 0x1A, 0xFD, 0x77, 0xDD, 0xD1, 0x9C]};
+enum IID RESTYPE_GenericScript = {0xF372184D, 0xDFDB, 0x4370, [0xA0, 0x05, 0xE1, 0xEF, 0x30, 0x1B, 0x23, 0xA4]};
+enum IID RESTYPE_IPAddress = {0xE61ADE71, 0xC79A, 0x4FDA, [0xB1, 0xDB, 0xA9, 0xB8, 0xD2, 0x0C, 0x8B, 0x14]};
+enum IID RESTYPE_LocalQuorum = {0xF004656D, 0x5B48, 0x4580, [0xA1, 0xF4, 0xC3, 0xEC, 0x14, 0x98, 0x3D, 0x1E]};
+enum IID RESTYPE_MajorityNodeSet = {0x56BFAE11, 0xD2F7, 0x4F4F, [0x99, 0x52, 0x55, 0xAF, 0x19, 0xBA, 0xC3, 0xE9]};
+enum IID RESTYPE_NetworkName = {0xC1D2FE1E, 0xD332, 0x445F, [0x8D, 0xA1, 0x12, 0xE5, 0xE2, 0xD3, 0x7C, 0xBF]};
+enum IID RESTYPE_PhysicalDisk = {0xCC558763, 0x3386, 0x42EF, [0xB1, 0x50, 0xBE, 0x79, 0x33, 0x44, 0xD4, 0x5F]};
+enum IID SID_CtxQueryAssociations = {0xFAADFC40, 0xB777, 0x4B69, [0xAA, 0x81, 0x77, 0x03, 0x5E, 0xF0, 0xE6, 0xE8]};
+enum IID SID_SContainerDispatch = {0xB722BE00, 0x4E68, 0x101B, [0xA2, 0xBC, 0x00, 0xAA, 0x00, 0x40, 0x47, 0x70]};
+enum IID SID_SDataPathBrowser = {0xFC4801A5, 0x2BA9, 0x11CF, [0xA2, 0x29, 0x00, 0xAA, 0x00, 0x3D, 0x73, 0x52]};
+enum IID SID_SGetViewFromViewDual = {0x889A935D, 0x971E, 0x4B12, [0xB9, 0x0C, 0x24, 0xDF, 0xC9, 0xE1, 0xE5, 0xE8]};
+enum IID SID_SHTMLEditServices = {0x3050F7F9, 0x98B5, 0x11CF, [0xBB, 0x82, 0x00, 0xAA, 0x00, 0xBD, 0xCE, 0x0B]};
+enum IID SID_STopLevelBrowser = {0x4C96BE40, 0x915C, 0x11CF, [0x99, 0xD3, 0x00, 0xAA, 0x00, 0x4A, 0xE8, 0x37]};
+enum IID SID_STopWindow = {0x49E1B500, 0x4636, 0x11D3, [0x97, 0xF7, 0x00, 0xC0, 0x4F, 0x45, 0xD0, 0xB3]};
+enum IID SID_SVersionHost = {0x371EA634, 0xDC5C, 0x11D1, [0xBA, 0x57, 0x00, 0xC0, 0x4F, 0xC2, 0x04, 0x0E]};
+enum IID TAPIMEDIATYPE_Audio = {0x028ED8C2, 0xDC7A, 0x11D0, [0x8E, 0xD3, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID TAPIMEDIATYPE_DataModem = {0x028ED8C6, 0xDC7A, 0x11D0, [0x8E, 0xD3, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID TAPIMEDIATYPE_G3Fax = {0x028ED8C7, 0xDC7A, 0x11D0, [0x8E, 0xD3, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID TAPIMEDIATYPE_Video = {0x028ED8C4, 0xDC7A, 0x11D0, [0x8E, 0xD3, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID TAPIPROTOCOL_H323 = {0x831CE2D7, 0x83B5, 0x11D1, [0xBB, 0x5C, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID TAPIPROTOCOL_Multicast = {0x831CE2D8, 0x83B5, 0x11D1, [0xBB, 0x5C, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID TAPIPROTOCOL_PSTN = {0x831CE2D6, 0x83B5, 0x11D1, [0xBB, 0x5C, 0x00, 0xC0, 0x4F, 0xB6, 0x80, 0x9F]};
+enum IID TASK_AnalyzeCluster = {0x3140B5A6, 0x9AFA, 0x4588, [0x8C, 0xA0, 0x9B, 0xE8, 0xF8, 0xB6, 0x15, 0x06]};
+enum IID TASK_CommitClusterChanges = {0x2D03030B, 0xF084, 0x4807, [0xBB, 0xAC, 0x94, 0x26, 0x9E, 0x50, 0xB5, 0x6F]};
+enum IID TASKID_Major_Check_Cluster_Feasibili = {0xEBC8AEFF, 0x10C3, 0x4D5B, [0xAC, 0x17, 0xFC, 0x0F, 0x4C, 0x38, 0x71, 0xB7]};
+enum IID TASKID_Major_Check_Node_Feasibility = {0xCC5E57B1, 0x4520, 0x4672, [0xB4, 0xBA, 0xA2, 0x88, 0xEC, 0x42, 0x94, 0x6E]};
+enum IID TASKID_Major_Checking_For_Existing_Cl = {0xB8453B8F, 0x92FD, 0x4350, [0xA6, 0xD9, 0x55, 0x1F, 0xD0, 0x18, 0xB7, 0x91]};
+enum IID TASKID_Major_Client_And_Server_Log = {0xCD36919C, 0x9F31, 0x46B4, [0xA2, 0x9D, 0xAC, 0x87, 0xF4, 0xE6, 0xCC, 0x93]};
+enum IID TASKID_Major_Client_Log = {0x64ECA0EA, 0x9CB6, 0x4324, [0x97, 0x02, 0xDF, 0x15, 0xC6, 0x96, 0xC3, 0x0A]};
+enum IID TASKID_Major_Configure_Cluster_Servic = {0x7C5F0774, 0x1611, 0x42B5, [0xAF, 0x3C, 0x6E, 0x12, 0x4A, 0xC4, 0xD3, 0x6B]};
+enum IID TASKID_Major_Configure_Resource_Type = {0x6D47AF1F, 0x7F17, 0x4B80, [0x8F, 0xAB, 0x3A, 0x2D, 0x19, 0xB1, 0x23, 0x3D]};
+enum IID TASKID_Major_Configure_Resources = {0x411BCDEC, 0x69D3, 0x4485, [0x8D, 0x5D, 0xE1, 0x9E, 0xE7, 0x7A, 0x6D, 0xD4]};
+enum IID TASKID_Major_Establish_Connection = {0x93C32F99, 0x39CA, 0x4D38, [0x9D, 0x7F, 0x27, 0x07, 0xCA, 0x0E, 0xAF, 0x46]};
+enum IID TASKID_Major_Find_Devices = {0x036BF567, 0x2377, 0x4BB3, [0x8A, 0xE1, 0xE4, 0x10, 0x4E, 0x2E, 0xB3, 0xC5]};
+enum IID TASKID_Major_Reanalyze = {0xE25968DA, 0x9C7B, 0x42DB, [0xAD, 0xA9, 0xBC, 0x4E, 0x34, 0xF1, 0x7E, 0x6E]};
+enum IID TASKID_Major_Server_Log = {0x05AA0768, 0x5F49, 0x49CD, [0xAF, 0xDC, 0x96, 0xF9, 0xD5, 0x18, 0x02, 0xD4]};
+enum IID TASKID_Minor_Update_Progress = {0x2362D3DA, 0xA6A4, 0x4551, [0xB8, 0x46, 0x7B, 0xB3, 0xA1, 0x36, 0x5F, 0x56]};
+enum IID TID_D3DRMAnimation = {0x3D82AB4F, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID TID_D3DRMAnimationKey = {0x10DD46A8, 0x775B, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMAnimationOptions = {0xE2BF56C0, 0x840F, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMAnimationSet = {0x3D82AB50, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID TID_D3DRMAppData = {0xE5745280, 0xB24F, 0x11CF, [0x9D, 0xD5, 0x00, 0xAA, 0x00, 0xA7, 0x1A, 0x2F]};
+enum IID TID_D3DRMBoolean = {0x537DA6A0, 0xCA37, 0x11D0, [0x94, 0x1C, 0x00, 0x80, 0xC8, 0x0C, 0xFA, 0x7B]};
+enum IID TID_D3DRMBoolean2d = {0x4885AE63, 0x78E8, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMCamera = {0x3D82AB51, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID TID_D3DRMColorRGB = {0xD3E16E81, 0x7835, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMColorRGBA = {0x35FF44E0, 0x6C7C, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMCoords2d = {0xF6F23F44, 0x7686, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMExternalVisual = {0x98116AA0, 0xBDBA, 0x11D1, [0x82, 0xC0, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x71]};
+enum IID TID_D3DRMFloatKeys = {0x10DD46A9, 0x775B, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMFrame = {0x3D82AB46, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID TID_D3DRMFramePosition = {0xE2BF56C1, 0x840F, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMFrameRotation = {0xE2BF56C3, 0x840F, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMFrameTransformMatrix = {0xF6F23F41, 0x7686, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMFrameVelocity = {0xE2BF56C2, 0x840F, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMGuid = {0xA42790E0, 0x7810, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMIndexedColor = {0x1630B820, 0x7842, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMInfo = {0x2B957100, 0x9E9A, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID TID_D3DRMInlineData = {0x3A23EEA0, 0x94B1, 0x11D0, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID TID_D3DRMLight = {0x3D82AB4A, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID TID_D3DRMLightAttenuation = {0xA8A98BA0, 0xC5E5, 0x11CF, [0xB9, 0x41, 0x00, 0x80, 0xC8, 0x0C, 0xFA, 0x7B]};
+enum IID TID_D3DRMLightPenumbra = {0xAED22741, 0xB31F, 0x11CF, [0x9D, 0xD5, 0x00, 0xAA, 0x00, 0xA7, 0x1A, 0x2F]};
+enum IID TID_D3DRMLightRange = {0xAED22742, 0xB31F, 0x11CF, [0x9D, 0xD5, 0x00, 0xAA, 0x00, 0xA7, 0x1A, 0x2F]};
+enum IID TID_D3DRMLightUmbra = {0xAED22740, 0xB31F, 0x11CF, [0x9D, 0xD5, 0x00, 0xAA, 0x00, 0xA7, 0x1A, 0x2F]};
+enum IID TID_D3DRMMaterial = {0x3D82AB4D, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID TID_D3DRMMaterialAmbientColor = {0x01411840, 0x7786, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMMaterialArray = {0x35FF44E1, 0x6C7C, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMMaterialDiffuseColor = {0x01411841, 0x7786, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMMaterialEmissiveColor = {0xD3E16E80, 0x7835, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMMaterialPower = {0x01411843, 0x7786, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMMaterialSpecularColor = {0x01411842, 0x7786, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMMaterialWrap = {0x4885AE60, 0x78E8, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMMatrix4x4 = {0xF6F23F45, 0x7686, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMMesh = {0x3D82AB44, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID TID_D3DRMMeshFace = {0x3D82AB5F, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID TID_D3DRMMeshFaceWraps = {0xED1EC5C0, 0xC0A8, 0x11D0, [0x94, 0x1C, 0x00, 0x80, 0xC8, 0x0C, 0xFA, 0x7B]};
+enum IID TID_D3DRMMeshMaterialList = {0xF6F23F42, 0x7686, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMMeshNormals = {0xF6F23F43, 0x7686, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMMeshTextureCoords = {0xF6F23F40, 0x7686, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMMeshVertexColors = {0x1630B821, 0x7842, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMProgressiveMesh = {0x8A63C360, 0x997D, 0x11D0, [0x94, 0x1C, 0x00, 0x80, 0xC8, 0x0C, 0xFA, 0x7B]};
+enum IID TID_D3DRMPropertyBag = {0x7F0F21E1, 0xBFE1, 0x11D1, [0x82, 0xC0, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x71]};
+enum IID TID_D3DRMRightHanded = {0x7F5D5EA0, 0xD53A, 0x11D1, [0x82, 0xC0, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x71]};
+enum IID TID_D3DRMStringProperty = {0x7F0F21E0, 0xBFE1, 0x11D1, [0x82, 0xC0, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x71]};
+enum IID TID_D3DRMTextureFilename = {0xA42790E1, 0x7810, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMTextureReference = {0xA42790E2, 0x7810, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMTimedFloatKeys = {0xF406B180, 0x7B3B, 0x11CF, [0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3]};
+enum IID TID_D3DRMUrl = {0x3A23EEA1, 0x94B1, 0x11D0, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID TID_D3DRMVector = {0x3D82AB5E, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+enum IID TID_DXFILEHeader = {0x3D82AB43, 0x62DA, 0x11CF, [0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33]};
+}
diff --git a/libphobos/libdruntime/core/sys/windows/vfw.d b/libphobos/libdruntime/core/sys/windows/vfw.d
new file mode 100644
index 00000000000..2fc2547675f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/vfw.d
@@ -0,0 +1,2398 @@
+/**
+ * Windows API header module
+ *
+ * written in the D programming language
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_vfw.d)
+ */
+
+module core.sys.windows.vfw;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "vfw32");
+
+private import
+    core.sys.windows.commdlg,
+    core.sys.windows.wingdi,
+    core.sys.windows.mmsystem,
+    core.sys.windows.unknwn,
+    core.sys.windows.w32api,
+    core.sys.windows.windef,
+    core.sys.windows.winuser;
+
+extern(Windows) {
+    DWORD VideoForWindowsVersion();
+    LONG InitVFW();
+    LONG TermVFW();
+}
+
+DWORD MKFOURCC(char ch0, char ch1, char ch2, char ch3) {
+    return (cast(DWORD)ch0) | ((cast(DWORD)ch1) << 8) | ((cast(DWORD)ch2) << 16) | ((cast(DWORD)ch3) << 24);
+}
+
+/**
+ * COMPMAN - Installable Compression Manager.
+ */
+
+enum ICVERSION = 0x0104;
+
+alias TypeDef!(HANDLE) HIC;
+
+enum BI_1632 = 0x32333631;
+
+template aviTWOCC(char c0, char c1) {
+enum WORD aviTWOCC = c0 | (c1 << 8);
+}
+
+enum ICTYPE_VIDEO  = mmioFOURCC!('v', 'i', 'd', 'c');
+enum ICTYPE_AUDIO  = mmioFOURCC!('a', 'u', 'd', 'c');
+
+enum {
+    ICERR_OK            = 0,
+    ICERR_DONTDRAW      = 1,
+    ICERR_NEWPALETTE    = 2,
+    ICERR_GOTOKEYFRAME  = 3,
+    ICERR_STOPDRAWING   = 4,
+}
+
+enum ICERR_UNSUPPORTED = -1;
+enum ICERR_BADFORMAT   = -2;
+enum ICERR_MEMORY      = -3;
+enum ICERR_INTERNAL    = -4;
+enum ICERR_BADFLAGS    = -5;
+enum ICERR_BADPARAM    = -6;
+enum ICERR_BADSIZE     = -7;
+enum ICERR_BADHANDLE   = -8;
+enum ICERR_CANTUPDATE  = -9;
+enum ICERR_ABORT       = -10;
+enum ICERR_ERROR       = -100;
+enum ICERR_BADBITDEPTH = -200;
+enum ICERR_BADIMAGESIZE = -201;
+
+enum ICERR_CUSTOM = -400;
+
+enum {
+    ICMODE_COMPRESS         = 1,
+    ICMODE_DECOMPRESS,
+    ICMODE_FASTDECOMPRESS,
+    ICMODE_QUERY,
+    ICMODE_FASTCOMPRESS,
+    ICMODE_DRAW             = 8,
+}
+
+enum ICMODE_INTERNALF_FUNCTION32   = 0x8000;
+enum ICMODE_INTERNALF_MASK         = 0x8000;
+
+enum {
+    AVIIF_LIST      = 0x00000001,
+    AVIIF_TWOCC     = 0x00000002,
+    AVIIF_KEYFRAME  = 0x00000010,
+}
+
+enum ICQUALITY_LOW     = 0;
+enum ICQUALITY_HIGH    = 10000;
+enum ICQUALITY_DEFAULT = -1;
+
+enum {
+    ICM_USER            = DRV_USER + 0x0000,
+    ICM_RESERVED_LOW    = DRV_USER + 0x1000,
+    ICM_RESERVED_HIGH   = DRV_USER + 0x2000,
+    ICM_RESERVED        = ICM_RESERVED_LOW,
+}
+
+// messages
+
+enum {
+    ICM_GETSTATE            = ICM_RESERVED + 0,
+    ICM_SETSTATE            = ICM_RESERVED + 1,
+    ICM_GETINFO             = ICM_RESERVED + 2,
+    ICM_CONFIGURE           = ICM_RESERVED + 10,
+    ICM_ABOUT               = ICM_RESERVED + 11,
+    ICM_GETERRORTEXT        = ICM_RESERVED + 12,
+    ICM_GETFORMATNAME       = ICM_RESERVED + 20,
+    ICM_ENUMFORMATS         = ICM_RESERVED + 21,
+    ICM_GETDEFAULTQUALITY   = ICM_RESERVED + 30,
+    ICM_GETQUALITY          = ICM_RESERVED + 31,
+    ICM_SETQUALITY          = ICM_RESERVED + 32,
+    ICM_SET                 = ICM_RESERVED + 40,
+    ICM_GET                 = ICM_RESERVED + 41,
+}
+
+enum ICM_FRAMERATE     = mmioFOURCC!('F','r','m','R');
+enum ICM_KEYFRAMERATE  = mmioFOURCC!('K','e','y','R');
+
+// ICM specific messages.
+
+enum {
+    ICM_COMPRESS_GET_FORMAT     = ICM_USER + 4,
+    ICM_COMPRESS_GET_SIZE       = ICM_USER + 5,
+    ICM_COMPRESS_QUERY          = ICM_USER + 6,
+    ICM_COMPRESS_BEGIN          = ICM_USER + 7,
+    ICM_COMPRESS                = ICM_USER + 8,
+    ICM_COMPRESS_END            = ICM_USER + 9,
+    ICM_DECOMPRESS_GET_FORMAT   = ICM_USER + 10,
+    ICM_DECOMPRESS_QUERY        = ICM_USER + 11,
+    ICM_DECOMPRESS_BEGIN        = ICM_USER + 12,
+    ICM_DECOMPRESS              = ICM_USER + 13,
+    ICM_DECOMPRESS_END          = ICM_USER + 14,
+    ICM_DECOMPRESS_SET_PALETTE  = ICM_USER + 29,
+    ICM_DECOMPRESS_GET_PALETTE  = ICM_USER + 30,
+    ICM_DRAW_QUERY              = ICM_USER + 31,
+    ICM_DRAW_BEGIN              = ICM_USER + 15,
+    ICM_DRAW_GET_PALETTE        = ICM_USER + 16,
+    ICM_DRAW_UPDATE             = ICM_USER + 17,
+    ICM_DRAW_START              = ICM_USER + 18,
+    ICM_DRAW_STOP               = ICM_USER + 19,
+    ICM_DRAW_BITS               = ICM_USER + 20,
+    ICM_DRAW_END                = ICM_USER + 21,
+    ICM_DRAW_GETTIME            = ICM_USER + 32,
+    ICM_DRAW                    = ICM_USER + 33,
+    ICM_DRAW_WINDOW             = ICM_USER + 34,
+    ICM_DRAW_SETTIME            = ICM_USER + 35,
+    ICM_DRAW_REALIZE            = ICM_USER + 36,
+    ICM_DRAW_FLUSH              = ICM_USER + 37,
+    ICM_DRAW_RENDERBUFFER       = ICM_USER + 38,
+    ICM_DRAW_START_PLAY         = ICM_USER + 39,
+    ICM_DRAW_STOP_PLAY          = ICM_USER + 40,
+    ICM_DRAW_SUGGESTFORMAT      = ICM_USER + 50,
+    ICM_DRAW_CHANGEPALETTE      = ICM_USER + 51,
+    ICM_DRAW_IDLE               = ICM_USER + 52,
+    ICM_GETBUFFERSWANTED        = ICM_USER + 41,
+    ICM_GETDEFAULTKEYFRAMERATE  = ICM_USER + 42,
+    ICM_DECOMPRESSEX_BEGIN      = ICM_USER + 60,
+    ICM_DECOMPRESSEX_QUERY      = ICM_USER + 61,
+    ICM_DECOMPRESSEX            = ICM_USER + 62,
+    ICM_DECOMPRESSEX_END        = ICM_USER + 63,
+    ICM_COMPRESS_FRAMES_INFO    = ICM_USER + 70,
+    ICM_COMPRESS_FRAMES         = ICM_USER + 71,
+    ICM_SET_STATUS_PROC         = ICM_USER + 72,
+}
+
+struct ICOPEN {
+    DWORD   dwSize;
+    DWORD   fccType;
+    DWORD   fccHandler;
+    DWORD   dwVersion;
+    DWORD   dwFlags;
+    LRESULT dwError;
+    LPVOID  pV1Reserved;
+    LPVOID  pV2Reserved;
+    DWORD   dnDevNode;
+}
+
+struct ICINFO {
+    DWORD   dwSize;
+    DWORD   fccType;
+    DWORD   fccHandler;
+    DWORD   dwFlags;
+    DWORD   dwVersion;
+    DWORD   dwVersionICM;
+    WCHAR[16]   szName;
+    WCHAR[128]  szDescription;
+    WCHAR[128]  szDriver;
+}
+
+enum {
+    VIDCF_QUALITY           = 0x0001,
+    VIDCF_CRUNCH            = 0x0002,
+    VIDCF_TEMPORAL          = 0x0004,
+    VIDCF_COMPRESSFRAMES    = 0x0008,
+    VIDCF_DRAW              = 0x0010,
+    VIDCF_FASTTEMPORALC     = 0x0020,
+    VIDCF_FASTTEMPORALD     = 0x0080,
+}
+
+enum ICCOMPRESS_KEYFRAME = 0x00000001L;
+
+struct ICCOMPRESS {
+    DWORD               dwFlags;
+    LPBITMAPINFOHEADER  lpbiOutput;
+    LPVOID              lpOutput;
+    LPBITMAPINFOHEADER  lpbiInput;
+    LPVOID              lpInput;
+    LPDWORD             lpckid;
+    LPDWORD             lpdwFlags;
+    LONG                lFrameNum;
+    DWORD               dwFrameSize;
+    DWORD               dwQuality;
+    LPBITMAPINFOHEADER  lpbiPrev;
+    LPVOID              lpPrev;
+}
+
+enum ICCOMPRESSFRAMES_PADDING = 0x00000001;
+
+struct ICCOMPRESSFRAMES {
+    DWORD               dwFlags;
+    LPBITMAPINFOHEADER  lpbiOutput;
+    LPARAM              lOutput;
+    LPBITMAPINFOHEADER  lpbiInput;
+    LPARAM              lInput;
+    LONG                lStartFrame;
+    LONG                lFrameCount;
+    LONG                lQuality;
+    LONG                lDataRate;
+    LONG                lKeyRate;
+    DWORD               dwRate;
+    DWORD               dwScale;    DWORD       dwOverheadPerFrame;
+    DWORD               dwReserved2;
+
+    LONG function(LPARAM lInput, LONG lFrame, LPVOID lpBits, LONG len) GetData;
+    LONG function(LPARAM lOutput, LONG lFrame, LPVOID lpBits, LONG len) PutData;
+}
+
+enum {
+    ICSTATUS_START  = 0,
+    ICSTATUS_STATUS = 1,
+    ICSTATUS_END    = 2,
+    ICSTATUS_ERROR  = 3,
+    ICSTATUS_YIELD  = 4,
+}
+
+struct ICSETSTATUSPROC {
+    DWORD   dwFlags;
+    LPARAM  lParam;
+    LONG function(LPARAM lParam, UINT message, LONG l) Status;
+}
+
+enum {
+    ICDECOMPRESS_NOTKEYFRAME    = 0x08000000,
+    ICDECOMPRESS_NULLFRAME      = 0x10000000,
+    ICDECOMPRESS_PREROLL        = 0x20000000,
+    ICDECOMPRESS_UPDATE         = 0x40000000,
+    ICDECOMPRESS_HURRYUP        = 0x80000000,
+}
+
+struct ICDECOMPRESS {
+    DWORD               dwFlags;
+    LPBITMAPINFOHEADER  lpbiInput;
+    LPVOID              lpInput;
+    LPBITMAPINFOHEADER  lpbiOutput;
+    LPVOID              lpOutput;
+    DWORD               ckid;
+}
+
+struct ICDECOMPRESSEX {
+    DWORD               dwFlags;
+    LPBITMAPINFOHEADER  lpbiSrc;
+    LPVOID              lpSrc;
+    LPBITMAPINFOHEADER  lpbiDst;
+    LPVOID              lpDst;
+    int                 xDst;
+    int                 yDst;
+    int                 dxDst;
+    int                 dyDst;
+    int                 xSrc;
+    int                 ySrc;
+    int                 dxSrc;
+    int                 dySrc;
+}
+
+enum {
+    ICDRAW_QUERY        = 0x00000001,
+    ICDRAW_FULLSCREEN   = 0x00000002,
+    ICDRAW_HDC          = 0x00000004,
+    ICDRAW_ANIMATE      = 0x00000008,
+    ICDRAW_CONTINUE     = 0x00000010,
+    ICDRAW_MEMORYDC     = 0x00000020,
+    ICDRAW_UPDATING     = 0x00000040,
+    ICDRAW_RENDER       = 0x00000080,
+    ICDRAW_BUFFER       = 0x00000100,
+}
+
+struct ICDRAWBEGIN {
+    DWORD               dwFlags;
+    HPALETTE            hpal;
+    HWND                hwnd;
+    HDC                 hdc;
+    int                 xDst;
+    int                 yDst;
+    int                 dxDst;
+    int                 dyDst;
+    LPBITMAPINFOHEADER  lpbi;
+    int                 xSrc;
+    int                 ySrc;
+    int                 dxSrc;
+    int                 dySrc;
+    DWORD               dwRate;
+    DWORD               dwScale;
+}
+
+enum {
+    ICDRAW_NOTKEYFRAME  = 0x08000000,
+    ICDRAW_NULLFRAME    = 0x10000000,
+    ICDRAW_PREROLL      = 0x20000000,
+    ICDRAW_UPDATE       = 0x40000000,
+    ICDRAW_HURRYUP      = 0x80000000,
+}
+
+struct ICDRAW {
+    DWORD           dwFlags;
+    LPVOID          lpFormat;
+    LPVOID          lpData;
+    DWORD           cbData;
+    LONG            lTime;
+}
+
+struct ICDRAWSUGGEST {
+    LPBITMAPINFOHEADER  lpbiIn;
+    LPBITMAPINFOHEADER  lpbiSuggest;
+    int                 dxSrc;
+    int                 dySrc;
+    int                 dxDst;
+    int                 dyDst;
+    HIC                 hicDecompressor;
+}
+
+struct ICPALETTE {
+    DWORD           dwFlags;
+    int             iStart;
+    int             iLen;
+    LPPALETTEENTRY  lppe;
+}
+
+
+/**
+ * ICM function declarations
+ */
+
+extern (Windows) {
+    BOOL ICInfo(DWORD fccType, DWORD fccHandler, ICINFO *lpicinfo);
+    BOOL ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDesc, UINT wFlags);
+    BOOL ICRemove(DWORD fccType, DWORD fccHandler, UINT wFlags);
+    LRESULT ICGetInfo(HIC hic, ICINFO *picinfo, DWORD cb);
+    HIC ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode);
+    HIC ICOpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, FARPROC lpfnHandler);
+    LRESULT ICClose(HIC hic);
+    LRESULT ICSendMessage(HIC hic, UINT msg, DWORD_PTR dw1, DWORD_PTR dw2);
+}
+
+enum {
+    ICINSTALL_FUNCTION  = 0x0001,
+    ICINSTALL_DRIVER    = 0x0002,
+    ICINSTALL_HDRV      = 0x0004,
+    ICINSTALL_UNICODE   = 0x8000,
+    ICINSTALL_DRIVERW   = 0x8002,
+}
+
+// query macros
+
+enum ICMF_CONFIGURE_QUERY  = 0x00000001;
+enum ICMF_ABOUT_QUERY      = 0x00000001;
+
+DWORD ICQueryAbout(HIC hic) {
+    return ICSendMessage(hic, ICM_ABOUT, -1, ICMF_ABOUT_QUERY) == ICERR_OK;
+}
+
+DWORD ICAbout(HIC hic, HWND hwnd) {
+    return cast(DWORD) ICSendMessage(hic, ICM_ABOUT, cast(DWORD_PTR) cast(UINT_PTR) hwnd, 0);
+}
+
+DWORD ICQueryConfigure(HIC hic) {
+    return (ICSendMessage(hic, ICM_CONFIGURE, -1, ICMF_CONFIGURE_QUERY) == ICERR_OK);
+}
+
+DWORD ICConfigure(HIC hic, HWND hwnd) {
+    return cast(DWORD) ICSendMessage(hic, ICM_CONFIGURE, cast(DWORD_PTR) cast(UINT_PTR) hwnd, 0);
+}
+
+DWORD ICGetState(HIC hic, LPVOID pv, DWORD_PTR cb) {
+    return cast(DWORD) ICSendMessage(hic, ICM_GETSTATE, cast(DWORD_PTR) pv, cb);
+}
+
+DWORD ICSetState(HIC hic, LPVOID pv, DWORD_PTR cb) {
+    return cast(DWORD) ICSendMessage(hic, ICM_SETSTATE, cast(DWORD_PTR) pv, cb);
+}
+
+DWORD ICGetStateSize(HIC hic) {
+    return ICGetState(hic, null, 0);
+}
+
+DWORD dwICValue;
+
+DWORD ICGetDefaultQuality(HIC hic) {
+    ICSendMessage(hic, ICM_GETDEFAULTQUALITY, cast(DWORD_PTR)&dwICValue, DWORD.sizeof);
+    return dwICValue;
+}
+
+DWORD ICGetDefaultKeyFrameRate(HIC hic) {
+    ICSendMessage(hic, ICM_GETDEFAULTKEYFRAMERATE, cast(DWORD_PTR)&dwICValue, DWORD.sizeof);
+    return dwICValue;
+}
+
+DWORD ICDrawWindow(HIC hic, LPVOID prc) {
+    return cast(DWORD) ICSendMessage(hic, ICM_DRAW_WINDOW, cast(DWORD_PTR) prc, RECT.sizeof);
+}
+
+extern (Windows) {
+    DWORD ICCompress(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiOutput, LPVOID lpData,
+        LPBITMAPINFOHEADER lpbiInput, LPVOID lpBits, LPDWORD lpckid, LPDWORD lpdwFlags,
+        LONG lFrameNum, DWORD dwFrameSize, DWORD dwQuality, LPBITMAPINFOHEADER lpbiPrev, LPVOID lpPrev);
+}
+
+LRESULT ICCompressBegin(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
+    return ICSendMessage(hic, ICM_COMPRESS_BEGIN, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
+}
+LRESULT ICCompressQuery(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
+    return ICSendMessage(hic, ICM_COMPRESS_QUERY, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
+}
+LRESULT ICCompressGetFormat(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
+    return ICSendMessage(hic, ICM_COMPRESS_GET_FORMAT, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
+}
+DWORD ICCompressGetFormatSize(HIC hic, LPVOID lpbi) {
+    return cast(DWORD)ICCompressGetFormat(hic, lpbi, null);
+}
+DWORD ICCompressGetSize(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
+    return cast(DWORD)ICSendMessage(hic, ICM_COMPRESS_GET_SIZE, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
+}
+LRESULT ICCompressEnd(HIC hic) {
+    return ICSendMessage(hic, ICM_COMPRESS_END, 0, 0);
+}
+
+extern (Windows) {
+    DWORD ICDecompress(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiFormat, LPVOID lpData, LPBITMAPINFOHEADER lpbi, LPVOID lpBits);
+}
+
+LRESULT ICDecompressBegin(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
+    return ICSendMessage(hic, ICM_DECOMPRESS_BEGIN, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
+}
+LRESULT ICDecompressQuery(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
+    return ICSendMessage(hic, ICM_DECOMPRESS_QUERY, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
+}
+LONG ICDecompressGetFormat(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
+    return cast(LONG)ICSendMessage(hic, ICM_DECOMPRESS_GET_FORMAT, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
+}
+LONG ICDecompressGetFormatSize(HIC hic, LPVOID lpbi) {
+    return ICDecompressGetFormat(hic, lpbi, null);
+}
+LRESULT ICDecompressGetPalette(HIC hic, LPVOID lpbiInput, LPVOID lpbiOutput) {
+    return ICSendMessage(hic, ICM_DECOMPRESS_GET_PALETTE, cast(DWORD_PTR)lpbiInput, cast(DWORD_PTR)lpbiOutput);
+}
+LRESULT ICDecompressSetPalette(HIC hic, LPVOID lpbiPalette) {
+    return ICSendMessage(hic, ICM_DECOMPRESS_SET_PALETTE, cast(DWORD_PTR)lpbiPalette, 0);
+}
+LRESULT ICDecompressEnd(HIC hic) {
+    return ICSendMessage(hic, ICM_DECOMPRESS_END, 0, 0);
+}
+
+LRESULT ICDecompressEx(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiSrc,
+    LPVOID lpSrc, int xSrc, int ySrc, int dxSrc, int dySrc, LPBITMAPINFOHEADER lpbiDst,
+    LPVOID lpDst, int xDst, int yDst, int dxDst, int dyDst) {
+    ICDECOMPRESSEX ic;
+
+    ic.dwFlags = dwFlags;
+    ic.lpbiSrc = lpbiSrc;
+    ic.lpSrc = lpSrc;
+    ic.xSrc = xSrc;
+    ic.ySrc = ySrc;
+    ic.dxSrc = dxSrc;
+    ic.dySrc = dySrc;
+    ic.lpbiDst = lpbiDst;
+    ic.lpDst = lpDst;
+    ic.xDst = xDst;
+    ic.yDst = yDst;
+    ic.dxDst = dxDst;
+    ic.dyDst = dyDst;
+
+    return ICSendMessage(hic, ICM_DECOMPRESSEX, cast(DWORD_PTR)&ic, ic.sizeof);
+}
+
+LRESULT ICDecompressExBegin(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiSrc,
+    LPVOID lpSrc, int xSrc, int ySrc, int dxSrc, int dySrc, LPBITMAPINFOHEADER lpbiDst,
+    LPVOID lpDst, int xDst, int yDst, int dxDst, int dyDst) {
+    ICDECOMPRESSEX ic;
+
+    ic.dwFlags = dwFlags;
+    ic.lpbiSrc = lpbiSrc;
+    ic.lpSrc = lpSrc;
+    ic.xSrc = xSrc;
+    ic.ySrc = ySrc;
+    ic.dxSrc = dxSrc;
+    ic.dySrc = dySrc;
+    ic.lpbiDst = lpbiDst;
+    ic.lpDst = lpDst;
+    ic.xDst = xDst;
+    ic.yDst = yDst;
+    ic.dxDst = dxDst;
+    ic.dyDst = dyDst;
+
+    return ICSendMessage(hic, ICM_DECOMPRESSEX_BEGIN, cast(DWORD_PTR)&ic, ic.sizeof);
+}
+
+LRESULT ICDecompressExQuery(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiSrc,
+    LPVOID lpSrc, int xSrc, int ySrc, int dxSrc, int dySrc, LPBITMAPINFOHEADER lpbiDst,
+    LPVOID lpDst, int xDst, int yDst, int dxDst, int dyDst) {
+    ICDECOMPRESSEX ic;
+
+    ic.dwFlags = dwFlags;
+    ic.lpbiSrc = lpbiSrc;
+    ic.lpSrc = lpSrc;
+    ic.xSrc = xSrc;
+    ic.ySrc = ySrc;
+    ic.dxSrc = dxSrc;
+    ic.dySrc = dySrc;
+    ic.lpbiDst = lpbiDst;
+    ic.lpDst = lpDst;
+    ic.xDst = xDst;
+    ic.yDst = yDst;
+    ic.dxDst = dxDst;
+    ic.dyDst = dyDst;
+
+    return ICSendMessage(hic, ICM_DECOMPRESSEX_QUERY, cast(DWORD_PTR)&ic, ic.sizeof);
+}
+
+LRESULT ICDecompressExEnd(HIC hic) {
+    return ICSendMessage(hic, ICM_DECOMPRESSEX_END, 0, 0);
+}
+
+extern (Windows) {
+    DWORD ICDrawBegin(HIC hic, DWORD dwFlags, HPALETTE hpal, HWND hwnd, HDC hdc,
+        int xDst, int yDst, int dxDst, int dyDst, LPBITMAPINFOHEADER lpbi,
+        int xSrc, int ySrc, int dxSrc, int dySrc, DWORD dwRate, DWORD dwScale);
+}
+
+extern (Windows) {
+    DWORD ICDraw(HIC hic, DWORD dwFlags, LPVOID lpFormat, LPVOID lpData, DWORD cbData, LONG lTime);
+}
+
+LRESULT ICDrawSuggestFormat(HIC hic, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut,
+    int dxSrc, int dySrc, int dxDst, int dyDst, HIC hicDecomp) {
+    ICDRAWSUGGEST ic;
+
+    ic.lpbiIn = lpbiIn;
+    ic.lpbiSuggest = lpbiOut;
+    ic.dxSrc = dxSrc;
+    ic.dySrc = dySrc;
+    ic.dxDst = dxDst;
+    ic.dyDst = dyDst;
+    ic.hicDecompressor = hicDecomp;
+
+    return ICSendMessage(hic, ICM_DRAW_SUGGESTFORMAT, cast(DWORD_PTR)&ic, ic.sizeof);
+}
+
+LRESULT ICDrawQuery(HIC hic, LPVOID lpbiInput) {
+    return ICSendMessage(hic, ICM_DRAW_QUERY, cast(DWORD_PTR)lpbiInput, 0L);
+}
+LRESULT ICDrawChangePalette(HIC hic, LPVOID lpbiInput) {
+    return ICSendMessage(hic, ICM_DRAW_CHANGEPALETTE, cast(DWORD_PTR)lpbiInput, 0L);
+}
+LRESULT ICGetBuffersWanted(HIC hic, LPVOID lpdwBuffers) {
+    return ICSendMessage(hic, ICM_GETBUFFERSWANTED, cast(DWORD_PTR)lpdwBuffers, 0);
+}
+LRESULT ICDrawEnd(HIC hic) {
+    return ICSendMessage(hic, ICM_DRAW_END, 0, 0);
+}
+LRESULT ICDrawStart(HIC hic) {
+    return ICSendMessage(hic, ICM_DRAW_START, 0, 0);
+}
+LRESULT ICDrawStartPlay(HIC hic, DWORD lFrom, DWORD lTo) {
+    return ICSendMessage(hic, ICM_DRAW_START_PLAY, cast(DWORD_PTR)lFrom, cast(DWORD_PTR)lTo);
+}
+LRESULT ICDrawStop(HIC hic) {
+    return ICSendMessage(hic, ICM_DRAW_STOP, 0, 0);
+}
+LRESULT ICDrawStopPlay(HIC hic) {
+    return ICSendMessage(hic, ICM_DRAW_STOP_PLAY, 0, 0);
+}
+LRESULT ICDrawGetTime(HIC hic, LPVOID lplTime) {
+    return ICSendMessage(hic, ICM_DRAW_GETTIME, cast(DWORD_PTR)lplTime, 0);
+}
+LRESULT ICDrawSetTime(HIC hic, DWORD lTime) {
+    return ICSendMessage(hic, ICM_DRAW_SETTIME, cast(DWORD_PTR)lTime, 0);
+}
+LRESULT ICDrawRealize(HIC hic, HDC hdc, BOOL fBackground) {
+    return ICSendMessage(hic, ICM_DRAW_REALIZE, cast(DWORD_PTR)hdc, cast(DWORD_PTR)fBackground);
+}
+LRESULT ICDrawFlush(HIC hic) {
+    return ICSendMessage(hic, ICM_DRAW_FLUSH, 0, 0);
+}
+LRESULT ICDrawRenderBuffer(HIC hic) {
+    return ICSendMessage(hic, ICM_DRAW_RENDERBUFFER, 0, 0);
+}
+
+LRESULT ICSetStatusProc(HIC hic, DWORD dwFlags, LRESULT lParam, LONG function(LPARAM, UINT, LONG) fpfnStatus) {
+    ICSETSTATUSPROC ic;
+
+    ic.dwFlags = dwFlags;
+    ic.lParam = lParam;
+    ic.Status = fpfnStatus;
+
+    return ICSendMessage(hic, ICM_SET_STATUS_PROC, cast(DWORD_PTR)&ic, ic.sizeof);
+}
+
+HIC ICDecompressOpen(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut) {
+    return ICLocate(fccType, fccHandler, lpbiIn, lpbiOut, ICMODE_DECOMPRESS);
+}
+
+HIC ICDrawOpen(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn) {
+    return ICLocate(fccType, fccHandler, lpbiIn, null, ICMODE_DRAW);
+}
+
+extern (Windows) {
+    HIC ICLocate(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, WORD wFlags);
+    HIC ICGetDisplayFormat(HIC hic, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, int BitDepth, int dx, int dy);
+    HANDLE ICImageCompress(HIC hic, UINT uiFlags, LPBITMAPINFO lpbiIn, LPVOID lpBits, LPBITMAPINFO lpbiOut, LONG lQuality, LONG* plSize);
+    HANDLE ICImageDecompress(HIC hic, UINT uiFlags, LPBITMAPINFO lpbiIn, LPVOID lpBits, LPBITMAPINFO lpbiOut);
+}
+
+struct COMPVARS {
+    LONG        cbSize = this.sizeof;
+    DWORD       dwFlags;
+    HIC         hic;
+    DWORD               fccType;
+    DWORD               fccHandler;
+    LPBITMAPINFO    lpbiIn;
+    LPBITMAPINFO    lpbiOut;
+    LPVOID      lpBitsOut;
+    LPVOID      lpBitsPrev;
+    LONG        lFrame;
+    LONG        lKey;
+    LONG        lDataRate;
+    LONG        lQ;
+    LONG        lKeyCount;
+    LPVOID      lpState;
+    LONG        cbState;
+}
+alias COMPVARS* PCOMPVARS;
+
+enum ICMF_COMPVARS_VALID = 0x00000001;
+
+extern (Windows) {
+    BOOL ICCompressorChoose(HWND hwnd, UINT uiFlags, LPVOID pvIn, LPVOID lpData, PCOMPVARS pc, LPSTR lpszTitle);
+}
+
+enum {
+    ICMF_CHOOSE_KEYFRAME        = 0x0001,
+    ICMF_CHOOSE_DATARATE        = 0x0002,
+    ICMF_CHOOSE_PREVIEW         = 0x0004,
+    ICMF_CHOOSE_ALLCOMPRESSORS  = 0x0008,
+}
+
+extern (Windows) {
+    BOOL ICSeqCompressFrameStart(PCOMPVARS pc, LPBITMAPINFO lpbiIn);
+    void ICSeqCompressFrameEnd(PCOMPVARS pc);
+    LPVOID ICSeqCompressFrame(PCOMPVARS pc, UINT uiFlags, LPVOID lpBits, BOOL* pfKey, LONG* plSize);
+    void ICCompressorFree(PCOMPVARS pc);
+}
+
+mixin DECLARE_HANDLE!("HDRAWDIB");
+
+enum {
+    DDF_0001            = 0x0001,
+    DDF_UPDATE          = 0x0002,
+    DDF_SAME_HDC        = 0x0004,
+    DDF_SAME_DRAW       = 0x0008,
+    DDF_DONTDRAW        = 0x0010,
+    DDF_ANIMATE         = 0x0020,
+    DDF_BUFFER          = 0x0040,
+    DDF_JUSTDRAWIT      = 0x0080,
+    DDF_FULLSCREEN      = 0x0100,
+    DDF_BACKGROUNDPAL   = 0x0200,
+    DDF_NOTKEYFRAME     = 0x0400,
+    DDF_HURRYUP         = 0x0800,
+    DDF_HALFTONE        = 0x1000,
+    DDF_2000            = 0x2000,
+    DDF_PREROLL         = DDF_DONTDRAW,
+    DDF_SAME_DIB        = DDF_SAME_DRAW,
+    DDF_SAME_SIZE       = DDF_SAME_DRAW,
+}
+
+extern (Windows) {
+    BOOL DrawDibInit();
+    HDRAWDIB DrawDibOpen();
+    BOOL DrawDibClose(HDRAWDIB hdd);
+    LPVOID DrawDibGetBuffer(HDRAWDIB hdd, LPBITMAPINFOHEADER lpbi, DWORD dwSize, DWORD dwFlags);
+    UINT DrawDibError(HDRAWDIB hdd);
+    HPALETTE DrawDibGetPalette(HDRAWDIB hdd);
+    BOOL DrawDibSetPalette(HDRAWDIB hdd, HPALETTE hpal);
+    BOOL DrawDibChangePalette(HDRAWDIB hdd, int iStart, int iLen, LPPALETTEENTRY lppe);
+    UINT DrawDibRealize(HDRAWDIB hdd, HDC hdc, BOOL fBackground);
+    BOOL DrawDibStart(HDRAWDIB hdd, DWORD rate);
+    BOOL DrawDibStop(HDRAWDIB hdd);
+    BOOL DrawDibBegin(HDRAWDIB hdd, HDC hdc, int dxDst, int dyDst, LPBITMAPINFOHEADER lpbi, int dxSrc, int dySrc, UINT wFlags);
+    BOOL DrawDibDraw(HDRAWDIB hdd, HDC hdc, int xDst, int yDst, int dxDst, int dyDst, LPBITMAPINFOHEADER lpbi,
+        LPVOID lpBits, int xSrc, int ySrc, int dxSrc, int dySrc, UINT wFlags);
+}
+
+BOOL DrawDibUpdate(HDRAWDIB hdd, HDC hdc, int x, int y) {
+    return DrawDibDraw(hdd, hdc, x, y, 0, 0, null, null, 0, 0, 0, 0, DDF_UPDATE);
+}
+
+extern (Windows) {
+    BOOL DrawDibEnd(HDRAWDIB hdd);
+}
+
+struct DRAWDIBTIME {
+    LONG    timeCount;
+    LONG    timeDraw;
+    LONG    timeDecompress;
+    LONG    timeDither;
+    LONG    timeStretch;
+    LONG    timeBlt;
+    LONG    timeSetDIBits;
+}
+alias DRAWDIBTIME* LPDRAWDIBTIME;
+
+extern (Windows) {
+    BOOL DrawDibTime(HDRAWDIB hdd, LPDRAWDIBTIME lpddtime);
+}
+
+enum {
+    PD_CAN_DRAW_DIB         = 0x0001,
+    PD_CAN_STRETCHDIB       = 0x0002,
+    PD_STRETCHDIB_1_1_OK    = 0x0004,
+    PD_STRETCHDIB_1_2_OK    = 0x0008,
+    PD_STRETCHDIB_1_N_OK    = 0x0010,
+}
+
+extern (Windows) {
+    LRESULT DrawDibProfileDisplay(LPBITMAPINFOHEADER lpbi);
+    void StretchDIB(LPBITMAPINFOHEADER biDst, LPVOID lpDst, int DstX, int DstY,
+        int DstXE, int DstYE, LPBITMAPINFOHEADER biSrc, LPVOID lpSrc,
+        int SrcX, int SrcY, int SrcXE, int SrcYE);
+}
+
+alias DWORD FOURCC;
+
+alias WORD TWOCC;
+
+enum formtypeAVI           = mmioFOURCC!('A', 'V', 'I', ' ');
+enum listtypeAVIHEADER     = mmioFOURCC!('h', 'd', 'r', 'l');
+enum ckidAVIMAINHDR        = mmioFOURCC!('a', 'v', 'i', 'h');
+enum listtypeSTREAMHEADER  = mmioFOURCC!('s', 't', 'r', 'l');
+enum ckidSTREAMHEADER      = mmioFOURCC!('s', 't', 'r', 'h');
+enum ckidSTREAMFORMAT      = mmioFOURCC!('s', 't', 'r', 'f');
+enum ckidSTREAMHANDLERDATA = mmioFOURCC!('s', 't', 'r', 'd');
+enum ckidSTREAMNAME        = mmioFOURCC!('s', 't', 'r', 'n');
+enum listtypeAVIMOVIE      = mmioFOURCC!('m', 'o', 'v', 'i');
+enum listtypeAVIRECORD     = mmioFOURCC!('r', 'e', 'c', ' ');
+enum ckidAVINEWINDEX       = mmioFOURCC!('i', 'd', 'x', '1');
+enum streamtypeVIDEO       = mmioFOURCC!('v', 'i', 'd', 's');
+enum streamtypeAUDIO       = mmioFOURCC!('a', 'u', 'd', 's');
+enum streamtypeMIDI        = mmioFOURCC!('m', 'i', 'd', 's');
+enum streamtypeTEXT        = mmioFOURCC!('t', 'x', 't', 's');
+
+enum cktypeDIBbits         = aviTWOCC!('d', 'b');
+enum cktypeDIBcompressed   = aviTWOCC!('d', 'c');
+enum cktypePALchange       = aviTWOCC!('p', 'c');
+enum cktypeWAVEbytes       = aviTWOCC!('w', 'b');
+
+enum ckidAVIPADDING        = mmioFOURCC!('J', 'U', 'N', 'K');
+
+DWORD FromHex(char n) {
+    return (n >= 'A') ? n + 10 - 'A' : n - '0';
+}
+
+WORD StreamFromFOURCC(DWORD fcc) {
+    return cast(WORD)((FromHex(LOBYTE(LOWORD(fcc))) << 4) + (FromHex(HIBYTE(LOWORD(fcc)))));
+}
+
+WORD TWOCCFromFOURCC(DWORD fcc) {
+    return HIWORD(fcc);
+}
+
+BYTE ToHex(DWORD n) {
+    return cast(BYTE)((n > 9) ? n - 10 + 'A' : n + '0');
+}
+
+DWORD MAKEAVICKID(WORD tcc, WORD stream) {
+    return MAKELONG(cast(WORD)((ToHex(stream & 0x0f) << 8) | (ToHex((stream & 0xf0) >> 4))), tcc);
+}
+
+enum {
+    AVIF_HASINDEX       = 0x00000010,
+    AVIF_MUSTUSEINDEX   = 0x00000020,
+    AVIF_ISINTERLEAVED  = 0x00000100,
+    AVIF_WASCAPTUREFILE = 0x00010000,
+    AVIF_COPYRIGHTED    = 0x00020000,
+}
+
+enum AVI_HEADERSIZE = 2048;
+
+struct MainAVIHeader {
+    DWORD dwMicroSecPerFrame;
+    DWORD dwMaxBytesPerSec;
+    DWORD dwPaddingGranularity;
+    DWORD dwFlags;
+    DWORD dwTotalFrames;
+    DWORD dwInitialFrames;
+    DWORD dwStreams;
+    DWORD dwSuggestedBufferSize;
+    DWORD dwWidth;
+    DWORD dwHeight;
+    DWORD[4] dwReserved;
+}
+
+enum AVISF_DISABLED = 0x00000001;
+
+enum AVISF_VIDEO_PALCHANGES = 0x00010000;
+
+struct AVIStreamHeader {
+    FOURCC      fccType;
+    FOURCC      fccHandler;
+    DWORD       dwFlags;
+    WORD        wPriority;
+    WORD        wLanguage;
+    DWORD       dwInitialFrames;
+    DWORD       dwScale;
+    DWORD       dwRate;
+    DWORD       dwStart;
+    DWORD       dwLength;
+    DWORD       dwSuggestedBufferSize;
+    DWORD       dwQuality;
+    DWORD       dwSampleSize;
+    RECT        rcFrame;
+}
+
+enum {
+    AVIIF_FIRSTPART = 0x00000020L,
+    AVIIF_LASTPART  = 0x00000040L,
+    AVIIF_MIDPART   = (AVIIF_LASTPART|AVIIF_FIRSTPART),
+    AVIIF_NOTIME    = 0x00000100L,
+    AVIIF_COMPUSE   = 0x0FFF0000L,
+}
+
+struct AVIINDEXENTRY {
+    DWORD       ckid;
+    DWORD       dwFlags;
+    DWORD       dwChunkOffset;
+    DWORD       dwChunkLength;
+}
+
+struct AVIPALCHANGE {
+    BYTE        bFirstEntry;
+    BYTE        bNumEntries;
+    WORD        wFlags;
+    PALETTEENTRY[1] _peNew;
+    PALETTEENTRY* peNew() return { return _peNew.ptr; }
+}
+
+enum AVIGETFRAMEF_BESTDISPLAYFMT = 1;
+
+struct AVISTREAMINFOW {
+    DWORD   fccType;
+    DWORD   fccHandler;
+    DWORD   dwFlags;
+    DWORD   dwCaps;
+    WORD    wPriority;
+    WORD    wLanguage;
+    DWORD   dwScale;
+    DWORD   dwRate;
+    DWORD   dwStart;
+    DWORD   dwLength;
+    DWORD   dwInitialFrames;
+    DWORD   dwSuggestedBufferSize;
+    DWORD   dwQuality;
+    DWORD   dwSampleSize;
+    RECT    rcFrame;
+    DWORD   dwEditCount;
+    DWORD   dwFormatChangeCount;
+    WCHAR[64]   szName;
+}
+alias AVISTREAMINFOW* LPAVISTREAMINFOW;
+
+struct AVISTREAMINFOA {
+    DWORD   fccType;
+    DWORD   fccHandler;
+    DWORD   dwFlags;
+    DWORD   dwCaps;
+    WORD    wPriority;
+    WORD    wLanguage;
+    DWORD   dwScale;
+    DWORD   dwRate;
+    DWORD   dwStart;
+    DWORD   dwLength;
+    DWORD   dwInitialFrames;
+    DWORD   dwSuggestedBufferSize;
+    DWORD   dwQuality;
+    DWORD   dwSampleSize;
+    RECT    rcFrame;
+    DWORD   dwEditCount;
+    DWORD   dwFormatChangeCount;
+    char[64]    szName;
+}
+alias AVISTREAMINFOA* LPAVISTREAMINFOA;
+
+version(Unicode) {
+    alias AVISTREAMINFOW    AVISTREAMINFO;
+    alias LPAVISTREAMINFOW  LPAVISTREAMINFO;
+} else { // Unicode
+    alias AVISTREAMINFOA    AVISTREAMINFO;
+    alias LPAVISTREAMINFOA  LPAVISTREAMINFO;
+}
+
+enum AVISTREAMINFO_DISABLED        = 0x00000001;
+enum AVISTREAMINFO_FORMATCHANGES   = 0x00010000;
+
+struct AVIFILEINFOW {
+    DWORD   dwMaxBytesPerSec;
+    DWORD   dwFlags;
+    DWORD   dwCaps;
+    DWORD   dwStreams;
+    DWORD   dwSuggestedBufferSize;
+    DWORD   dwWidth;
+    DWORD   dwHeight;
+    DWORD   dwScale;
+    DWORD   dwRate;
+    DWORD   dwLength;
+    DWORD   dwEditCount;
+    WCHAR[64]   szFileType;
+}
+alias AVIFILEINFOW* LPAVIFILEINFOW;
+
+struct AVIFILEINFOA {
+    DWORD   dwMaxBytesPerSec;
+    DWORD   dwFlags;
+    DWORD   dwCaps;
+    DWORD   dwStreams;
+    DWORD   dwSuggestedBufferSize;
+    DWORD   dwWidth;
+    DWORD   dwHeight;
+    DWORD   dwScale;
+    DWORD   dwRate;
+    DWORD   dwLength;
+    DWORD   dwEditCount;
+    char[64]    szFileType;
+}
+alias AVIFILEINFOA* LPAVIFILEINFOA;
+
+version(Unicode) {
+    alias AVIFILEINFOW  AVIFILEINFO;
+    alias LPAVIFILEINFOW    LPAVIFILEINFO;
+} else { // Unicode
+    alias AVIFILEINFOA  AVIFILEINFO;
+    alias LPAVIFILEINFOA    LPAVIFILEINFO;
+}
+
+enum {
+    AVIFILEINFO_HASINDEX        = 0x00000010,
+    AVIFILEINFO_MUSTUSEINDEX    = 0x00000020,
+    AVIFILEINFO_ISINTERLEAVED   = 0x00000100,
+    AVIFILEINFO_WASCAPTUREFILE  = 0x00010000,
+    AVIFILEINFO_COPYRIGHTED     = 0x00020000,
+}
+
+enum {
+    AVIFILECAPS_CANREAD         = 0x00000001,
+    AVIFILECAPS_CANWRITE        = 0x00000002,
+    AVIFILECAPS_ALLKEYFRAMES    = 0x00000010,
+    AVIFILECAPS_NOCOMPRESSION   = 0x00000020,
+}
+
+extern (Windows) {
+    alias BOOL function(int) AVISAVECALLBACK;
+}
+
+struct AVICOMPRESSOPTIONS {
+    DWORD   fccType;
+    DWORD   fccHandler;
+    DWORD   dwKeyFrameEvery;
+    DWORD   dwQuality;
+    DWORD   dwBytesPerSecond;
+    DWORD   dwFlags;
+    LPVOID  lpFormat;
+    DWORD   cbFormat;
+    LPVOID  lpParms;
+    DWORD   cbParms;
+    DWORD   dwInterleaveEvery;
+}
+alias AVICOMPRESSOPTIONS* LPAVICOMPRESSOPTIONS;
+
+enum {
+    AVICOMPRESSF_INTERLEAVE = 0x00000001,
+    AVICOMPRESSF_DATARATE   = 0x00000002,
+    AVICOMPRESSF_KEYFRAMES  = 0x00000004,
+    AVICOMPRESSF_VALID      = 0x00000008,
+}
+
+/+ TODO:
+DECLARE_INTERFACE_(IAVIStream, IUnknown)
+{
+    STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
+    STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
+    STDMETHOD_(ULONG,Release) (THIS) PURE;
+
+    STDMETHOD(Create)      (THIS_ LPARAM lParam1, LPARAM lParam2) PURE ;
+    STDMETHOD(Info)        (THIS_ AVISTREAMINFOW FAR * psi, LONG lSize) PURE ;
+    STDMETHOD_(LONG, FindSample)(THIS_ LONG lPos, LONG lFlags) PURE ;
+    STDMETHOD(ReadFormat)  (THIS_ LONG lPos,
+                LPVOID lpFormat, LONG FAR *lpcbFormat) PURE ;
+    STDMETHOD(SetFormat)   (THIS_ LONG lPos,
+                LPVOID lpFormat, LONG cbFormat) PURE ;
+    STDMETHOD(Read)        (THIS_ LONG lStart, LONG lSamples,
+                LPVOID lpBuffer, LONG cbBuffer,
+                LONG FAR * plBytes, LONG FAR * plSamples) PURE ;
+    STDMETHOD(Write)       (THIS_ LONG lStart, LONG lSamples,
+                LPVOID lpBuffer, LONG cbBuffer,
+                DWORD dwFlags,
+                LONG FAR *plSampWritten,
+                LONG FAR *plBytesWritten) PURE ;
+    STDMETHOD(Delete)      (THIS_ LONG lStart, LONG lSamples) PURE;
+    STDMETHOD(ReadData)    (THIS_ DWORD fcc, LPVOID lp, LONG FAR *lpcb) PURE ;
+    STDMETHOD(WriteData)   (THIS_ DWORD fcc, LPVOID lp, LONG cb) PURE ;
+#ifdef _WIN32
+    STDMETHOD(SetInfo) (THIS_ AVISTREAMINFOW FAR * lpInfo,
+                LONG cbInfo) PURE;
+#else
+    STDMETHOD(Reserved1)            (THIS) PURE;
+    STDMETHOD(Reserved2)            (THIS) PURE;
+    STDMETHOD(Reserved3)            (THIS) PURE;
+    STDMETHOD(Reserved4)            (THIS) PURE;
+    STDMETHOD(Reserved5)            (THIS) PURE;
+#endif
+};
+
+alias TypeDef!(IAVIStream FAR*) PAVISTREAM;
+
+#undef  INTERFACE
+#define INTERFACE   IAVIStreaming
+
+DECLARE_INTERFACE_(IAVIStreaming, IUnknown)
+{
+    STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
+    STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
+    STDMETHOD_(ULONG,Release) (THIS) PURE;
+
+    STDMETHOD(Begin) (THIS_
+              LONG  lStart,
+              LONG  lEnd,
+              LONG  lRate) PURE;
+    STDMETHOD(End)   (THIS) PURE;
+};
+
+alias TypeDef!(IAVIStreaming FAR*) PAVISTREAMING;
+
+
+#undef  INTERFACE
+#define INTERFACE   IAVIEditStream
+
+DECLARE_INTERFACE_(IAVIEditStream, IUnknown)
+{
+    STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
+    STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
+    STDMETHOD_(ULONG,Release) (THIS) PURE;
+
+    STDMETHOD(Cut) (THIS_ LONG FAR *plStart,
+              LONG FAR *plLength,
+              PAVISTREAM FAR * ppResult) PURE;
+    STDMETHOD(Copy) (THIS_ LONG FAR *plStart,
+               LONG FAR *plLength,
+               PAVISTREAM FAR * ppResult) PURE;
+    STDMETHOD(Paste) (THIS_ LONG FAR *plPos,
+                LONG FAR *plLength,
+                PAVISTREAM pstream,
+                LONG lStart,
+                LONG lEnd) PURE;
+    STDMETHOD(Clone) (THIS_ PAVISTREAM FAR *ppResult) PURE;
+    STDMETHOD(SetInfo) (THIS_ AVISTREAMINFOW FAR * lpInfo,
+                LONG cbInfo) PURE;
+};
+
+alias TypeDef!(IAVIEditStream FAR*) PAVIEDITSTREAM;
+
+#undef  INTERFACE
+#define INTERFACE   IAVIPersistFile
+
+DECLARE_INTERFACE_(IAVIPersistFile, IPersistFile)
+{
+    STDMETHOD(Reserved1)(THIS) PURE;
+};
+
+alias TypeDef!(IAVIPersistFile FAR*) PAVIPERSISTFILE;
+
+#undef  INTERFACE
+#define INTERFACE   IAVIFile
+#define PAVIFILE IAVIFile FAR*
+
+DECLARE_INTERFACE_(IAVIFile, IUnknown)
+{
+    STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
+    STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
+    STDMETHOD_(ULONG,Release) (THIS) PURE;
+
+    STDMETHOD(Info)                 (THIS_
+                                     AVIFILEINFOW FAR * pfi,
+                                     LONG lSize) PURE;
+    STDMETHOD(GetStream)            (THIS_
+                                     PAVISTREAM FAR * ppStream,
+                     DWORD fccType,
+                                     LONG lParam) PURE;
+    STDMETHOD(CreateStream)         (THIS_
+                                     PAVISTREAM FAR * ppStream,
+                                     AVISTREAMINFOW FAR * psi) PURE;
+    STDMETHOD(WriteData)            (THIS_
+                                     DWORD ckid,
+                                     LPVOID lpData,
+                                     LONG cbData) PURE;
+    STDMETHOD(ReadData)             (THIS_
+                                     DWORD ckid,
+                                     LPVOID lpData,
+                                     LONG FAR *lpcbData) PURE;
+    STDMETHOD(EndRecord)            (THIS) PURE;
+    STDMETHOD(DeleteStream)         (THIS_
+                     DWORD fccType,
+                                     LONG lParam) PURE;
+};
+
+#undef PAVIFILE
+alias TypeDef!(IAVIFile FAR*) PAVIFILE;
+
+#undef  INTERFACE
+#define INTERFACE   IGetFrame
+#define PGETFRAME   IGetFrame FAR*
+
+DECLARE_INTERFACE_(IGetFrame, IUnknown)
+{
+    STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
+    STDMETHOD_(ULONG,AddRef) (THIS)  PURE;
+    STDMETHOD_(ULONG,Release) (THIS) PURE;
+
+    STDMETHOD_(LPVOID,GetFrame) (THIS_ LONG lPos) PURE;
+
+    STDMETHOD(Begin) (THIS_ LONG lStart, LONG lEnd, LONG lRate) PURE;
+    STDMETHOD(End) (THIS) PURE;
+
+    STDMETHOD(SetFormat) (THIS_ LPBITMAPINFOHEADER lpbi, LPVOID lpBits, int x, int y, int dx, int dy) PURE;
+};
+
+#undef PGETFRAME
+alias TypeDef!(IGetFrame FAR*) PGETFRAME;
+
+#define DEFINE_AVIGUID(name, l, w1, w2)    DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
+
+DEFINE_AVIGUID(IID_IAVIFile,            0x00020020, 0, 0);
+DEFINE_AVIGUID(IID_IAVIStream,          0x00020021, 0, 0);
+DEFINE_AVIGUID(IID_IAVIStreaming,       0x00020022, 0, 0);
+DEFINE_AVIGUID(IID_IGetFrame,           0x00020023, 0, 0);
+DEFINE_AVIGUID(IID_IAVIEditStream,      0x00020024, 0, 0);
+DEFINE_AVIGUID(IID_IAVIPersistFile,     0x00020025, 0, 0);
+#ifndef UNICODE
+DEFINE_AVIGUID(CLSID_AVISimpleUnMarshal,        0x00020009, 0, 0);
+#endif
+
+DEFINE_AVIGUID(CLSID_AVIFile,           0x00020000, 0, 0);
+
+#define AVIFILEHANDLER_CANREAD      0x0001
+#define AVIFILEHANDLER_CANWRITE     0x0002
+#define AVIFILEHANDLER_CANACCEPTNONRGB  0x0004
+
+STDAPI_(void) AVIFileInit(void);
+STDAPI_(void) AVIFileExit(void);
+
+STDAPI_(ULONG) AVIFileAddRef       (PAVIFILE pfile);
+STDAPI_(ULONG) AVIFileRelease      (PAVIFILE pfile);
+
+#ifdef _WIN32
+STDAPI AVIFileOpenA       (PAVIFILE FAR * ppfile, LPCSTR szFile,
+              UINT uMode, LPCLSID lpHandler);
+STDAPI AVIFileOpenW       (PAVIFILE FAR * ppfile, LPCWSTR szFile,
+              UINT uMode, LPCLSID lpHandler);
+#ifdef UNICODE
+#define AVIFileOpen   AVIFileOpenW
+#else
+#define AVIFileOpen   AVIFileOpenA
+#endif
+#else
+STDAPI AVIFileOpen       (PAVIFILE FAR * ppfile, LPCSTR szFile,
+              UINT uMode, LPCLSID lpHandler);
+#define AVIFileOpenW    AVIFileOpen
+#endif
+
+#ifdef _WIN32
+STDAPI AVIFileInfoW (PAVIFILE pfile, LPAVIFILEINFOW pfi, LONG lSize);
+STDAPI AVIFileInfoA (PAVIFILE pfile, LPAVIFILEINFOA pfi, LONG lSize);
+#ifdef UNICODE
+#define AVIFileInfo AVIFileInfoW
+#else
+#define AVIFileInfo AVIFileInfoA
+#endif
+#else
+STDAPI AVIFileInfo (PAVIFILE pfile, LPAVIFILEINFO pfi, LONG lSize);
+#define AVIFileInfoW AVIFileInfo
+#endif
+
+
+STDAPI AVIFileGetStream     (PAVIFILE pfile, PAVISTREAM FAR * ppavi, DWORD fccType, LONG lParam);
+
+
+#ifdef _WIN32
+STDAPI AVIFileCreateStreamW (PAVIFILE pfile, PAVISTREAM FAR *ppavi, AVISTREAMINFOW FAR * psi);
+STDAPI AVIFileCreateStreamA (PAVIFILE pfile, PAVISTREAM FAR *ppavi, AVISTREAMINFOA FAR * psi);
+#ifdef UNICODE
+#define AVIFileCreateStream AVIFileCreateStreamW
+#else
+#define AVIFileCreateStream AVIFileCreateStreamA
+#endif
+#else
+STDAPI AVIFileCreateStream(PAVIFILE pfile, PAVISTREAM FAR *ppavi, AVISTREAMINFO FAR * psi);
+#define AVIFileCreateStreamW AVIFileCreateStream
+#endif
+
+STDAPI AVIFileWriteData (PAVIFILE pfile,
+                     DWORD ckid,
+                     LPVOID lpData,
+                     LONG cbData);
+STDAPI AVIFileReadData  (PAVIFILE pfile,
+                     DWORD ckid,
+                     LPVOID lpData,
+                     LONG FAR *lpcbData);
+STDAPI AVIFileEndRecord (PAVIFILE pfile);
+
+STDAPI_(ULONG) AVIStreamAddRef       (PAVISTREAM pavi);
+STDAPI_(ULONG) AVIStreamRelease      (PAVISTREAM pavi);
+
+STDAPI AVIStreamInfoW (PAVISTREAM pavi, LPAVISTREAMINFOW psi, LONG lSize);
+STDAPI AVIStreamInfoA (PAVISTREAM pavi, LPAVISTREAMINFOA psi, LONG lSize);
+#ifdef UNICODE
+#define AVIStreamInfo   AVIStreamInfoW
+#else
+#define AVIStreamInfo   AVIStreamInfoA
+#endif
+
+STDAPI_(LONG) AVIStreamFindSample(PAVISTREAM pavi, LONG lPos, LONG lFlags);
+STDAPI AVIStreamReadFormat   (PAVISTREAM pavi, LONG lPos,LPVOID lpFormat,LONG FAR *lpcbFormat);
+STDAPI AVIStreamSetFormat    (PAVISTREAM pavi, LONG lPos,LPVOID lpFormat,LONG cbFormat);
+STDAPI AVIStreamReadData     (PAVISTREAM pavi, DWORD fcc, LPVOID lp, LONG FAR *lpcb);
+STDAPI AVIStreamWriteData    (PAVISTREAM pavi, DWORD fcc, LPVOID lp, LONG cb);
+
+STDAPI AVIStreamRead         (PAVISTREAM pavi,
+                  LONG lStart,
+                  LONG lSamples,
+                  LPVOID lpBuffer,
+                  LONG cbBuffer,
+                  LONG FAR * plBytes,
+                  LONG FAR * plSamples);
+#define AVISTREAMREAD_CONVENIENT    (-1L)
+
+STDAPI AVIStreamWrite        (PAVISTREAM pavi,
+                  LONG lStart, LONG lSamples,
+                  LPVOID lpBuffer, LONG cbBuffer, DWORD dwFlags,
+                  LONG FAR *plSampWritten,
+                  LONG FAR *plBytesWritten);
+
+STDAPI_(LONG) AVIStreamStart        (PAVISTREAM pavi);
+STDAPI_(LONG) AVIStreamLength       (PAVISTREAM pavi);
+STDAPI_(LONG) AVIStreamTimeToSample (PAVISTREAM pavi, LONG lTime);
+STDAPI_(LONG) AVIStreamSampleToTime (PAVISTREAM pavi, LONG lSample);
+
+
+STDAPI AVIStreamBeginStreaming(PAVISTREAM pavi, LONG lStart, LONG lEnd, LONG lRate);
+STDAPI AVIStreamEndStreaming(PAVISTREAM pavi);
+
+STDAPI_(PGETFRAME) AVIStreamGetFrameOpen(PAVISTREAM pavi,
+                     LPBITMAPINFOHEADER lpbiWanted);
+STDAPI_(LPVOID) AVIStreamGetFrame(PGETFRAME pg, LONG lPos);
+STDAPI AVIStreamGetFrameClose(PGETFRAME pg);
+
+STDAPI AVIStreamOpenFromFileA(PAVISTREAM FAR *ppavi, LPCSTR szFile,
+                 DWORD fccType, LONG lParam,
+                 UINT mode, CLSID FAR *pclsidHandler);
+STDAPI AVIStreamOpenFromFileW(PAVISTREAM FAR *ppavi, LPCWSTR szFile,
+                 DWORD fccType, LONG lParam,
+                 UINT mode, CLSID FAR *pclsidHandler);
+#ifdef UNICODE
+#define AVIStreamOpenFromFile   AVIStreamOpenFromFileW
+#else
+#define AVIStreamOpenFromFile   AVIStreamOpenFromFileA
+#endif
+
+STDAPI AVIStreamCreate(PAVISTREAM FAR *ppavi, LONG lParam1, LONG lParam2,
+               CLSID FAR *pclsidHandler);
+
+
+
+#define FIND_DIR        0x0000000FL
+#define FIND_NEXT       0x00000001L
+#define FIND_PREV       0x00000004L
+#define FIND_FROM_START 0x00000008L
+
+#define FIND_TYPE       0x000000F0L
+#define FIND_KEY        0x00000010L
+#define FIND_ANY        0x00000020L
+#define FIND_FORMAT     0x00000040L
+
+#define FIND_RET        0x0000F000L
+#define FIND_POS        0x00000000L
+#define FIND_LENGTH     0x00001000L
+#define FIND_OFFSET     0x00002000L
+#define FIND_SIZE       0x00003000L
+#define FIND_INDEX      0x00004000L
+
+#define AVIStreamFindKeyFrame AVIStreamFindSample
+#define FindKeyFrame    FindSample
+
+#define AVIStreamClose AVIStreamRelease
+#define AVIFileClose   AVIFileRelease
+#define AVIStreamInit  AVIFileInit
+#define AVIStreamExit  AVIFileExit
+
+#define SEARCH_NEAREST  FIND_PREV
+#define SEARCH_BACKWARD FIND_PREV
+#define SEARCH_FORWARD  FIND_NEXT
+#define SEARCH_KEY      FIND_KEY
+#define SEARCH_ANY      FIND_ANY
+
+#define     AVIStreamSampleToSample(pavi1, pavi2, l)            AVIStreamTimeToSample(pavi1,AVIStreamSampleToTime(pavi2, l))
+
+#define     AVIStreamNextSample(pavi, l)            AVIStreamFindSample(pavi,l+1,FIND_NEXT|FIND_ANY)
+
+#define     AVIStreamPrevSample(pavi, l)            AVIStreamFindSample(pavi,l-1,FIND_PREV|FIND_ANY)
+
+#define     AVIStreamNearestSample(pavi, l)            AVIStreamFindSample(pavi,l,FIND_PREV|FIND_ANY)
+
+#define     AVIStreamNextKeyFrame(pavi,l)            AVIStreamFindSample(pavi,l+1,FIND_NEXT|FIND_KEY)
+
+#define     AVIStreamPrevKeyFrame(pavi, l)            AVIStreamFindSample(pavi,l-1,FIND_PREV|FIND_KEY)
+
+#define     AVIStreamNearestKeyFrame(pavi, l)            AVIStreamFindSample(pavi,l,FIND_PREV|FIND_KEY)
+
+#define     AVIStreamIsKeyFrame(pavi, l)            (AVIStreamNearestKeyFrame(pavi,l) == l)
+
+#define     AVIStreamPrevSampleTime(pavi, t)            AVIStreamSampleToTime(pavi, AVIStreamPrevSample(pavi,AVIStreamTimeToSample(pavi,t)))
+
+#define     AVIStreamNextSampleTime(pavi, t)            AVIStreamSampleToTime(pavi, AVIStreamNextSample(pavi,AVIStreamTimeToSample(pavi,t)))
+
+#define     AVIStreamNearestSampleTime(pavi, t)            AVIStreamSampleToTime(pavi, AVIStreamNearestSample(pavi,AVIStreamTimeToSample(pavi,t)))
+
+#define     AVIStreamNextKeyFrameTime(pavi, t)            AVIStreamSampleToTime(pavi, AVIStreamNextKeyFrame(pavi,AVIStreamTimeToSample(pavi, t)))
+
+#define     AVIStreamPrevKeyFrameTime(pavi, t)            AVIStreamSampleToTime(pavi, AVIStreamPrevKeyFrame(pavi,AVIStreamTimeToSample(pavi, t)))
+
+#define     AVIStreamNearestKeyFrameTime(pavi, t)            AVIStreamSampleToTime(pavi, AVIStreamNearestKeyFrame(pavi,AVIStreamTimeToSample(pavi, t)))
+
+#define     AVIStreamStartTime(pavi)            AVIStreamSampleToTime(pavi, AVIStreamStart(pavi))
+
+#define     AVIStreamLengthTime(pavi)            AVIStreamSampleToTime(pavi, AVIStreamLength(pavi))
+
+#define     AVIStreamEnd(pavi)            (AVIStreamStart(pavi) + AVIStreamLength(pavi))
+
+#define     AVIStreamEndTime(pavi)            AVIStreamSampleToTime(pavi, AVIStreamEnd(pavi))
+
+#define     AVIStreamSampleSize(pavi, lPos, plSize)     AVIStreamRead(pavi,lPos,1,NULL,0,plSize,NULL)
+
+#define     AVIStreamFormatSize(pavi, lPos, plSize)            AVIStreamReadFormat(pavi,lPos,NULL,plSize)
+
+#define     AVIStreamDataSize(pavi, fcc, plSize)            AVIStreamReadData(pavi,fcc,NULL,plSize)
+
+#ifndef comptypeDIB
+#define comptypeDIB         mmioFOURCC('D', 'I', 'B', ' ')
+#endif
+
+STDAPI AVIMakeCompressedStream(
+        PAVISTREAM FAR *        ppsCompressed,
+        PAVISTREAM          ppsSource,
+        AVICOMPRESSOPTIONS FAR *    lpOptions,
+        CLSID FAR *pclsidHandler);
+
+EXTERN_C HRESULT CDECL AVISaveA (LPCSTR               szFile,
+        CLSID FAR *pclsidHandler,
+        AVISAVECALLBACK     lpfnCallback,
+        int                 nStreams,
+        PAVISTREAM      pfile,
+        LPAVICOMPRESSOPTIONS lpOptions,
+        ...);
+
+STDAPI AVISaveVA(LPCSTR               szFile,
+        CLSID FAR *pclsidHandler,
+        AVISAVECALLBACK     lpfnCallback,
+        int                 nStreams,
+        PAVISTREAM FAR *    ppavi,
+        LPAVICOMPRESSOPTIONS FAR *plpOptions);
+EXTERN_C HRESULT CDECL AVISaveW (LPCWSTR               szFile,
+        CLSID FAR *pclsidHandler,
+        AVISAVECALLBACK     lpfnCallback,
+        int                 nStreams,
+        PAVISTREAM      pfile,
+        LPAVICOMPRESSOPTIONS lpOptions,
+        ...);
+
+STDAPI AVISaveVW(LPCWSTR               szFile,
+        CLSID FAR *pclsidHandler,
+        AVISAVECALLBACK     lpfnCallback,
+        int                 nStreams,
+        PAVISTREAM FAR *    ppavi,
+        LPAVICOMPRESSOPTIONS FAR *plpOptions);
+#ifdef UNICODE
+#define AVISave     AVISaveW
+#define AVISaveV    AVISaveVW
+#else
+#define AVISave     AVISaveA
+#define AVISaveV    AVISaveVA
+#endif
+
+
+
+STDAPI_(INT_PTR) AVISaveOptions(HWND hwnd,
+                 UINT   uiFlags,
+                 int    nStreams,
+                 PAVISTREAM FAR *ppavi,
+                 LPAVICOMPRESSOPTIONS FAR *plpOptions);
+
+STDAPI AVISaveOptionsFree(int nStreams,
+                 LPAVICOMPRESSOPTIONS FAR *plpOptions);
+
+STDAPI AVIBuildFilterW(LPWSTR lpszFilter, LONG cbFilter, BOOL fSaving);
+STDAPI AVIBuildFilterA(LPSTR lpszFilter, LONG cbFilter, BOOL fSaving);
+#ifdef UNICODE
+#define AVIBuildFilter  AVIBuildFilterW
+#else
+#define AVIBuildFilter  AVIBuildFilterA
+#endif
+STDAPI AVIMakeFileFromStreams(PAVIFILE FAR *    ppfile,
+                   int      nStreams,
+                   PAVISTREAM FAR * papStreams);
+
+STDAPI AVIMakeStreamFromClipboard(UINT cfFormat, HANDLE hGlobal, PAVISTREAM FAR *ppstream);
+
+STDAPI AVIPutFileOnClipboard(PAVIFILE pf);
+
+STDAPI AVIGetFromClipboard(PAVIFILE FAR * lppf);
+
+STDAPI AVIClearClipboard(void);
+
+STDAPI CreateEditableStream(
+        PAVISTREAM FAR *        ppsEditable,
+        PAVISTREAM          psSource);
+
+STDAPI EditStreamCut(PAVISTREAM pavi, LONG FAR *plStart, LONG FAR *plLength, PAVISTREAM FAR * ppResult);
+
+STDAPI EditStreamCopy(PAVISTREAM pavi, LONG FAR *plStart, LONG FAR *plLength, PAVISTREAM FAR * ppResult);
+
+STDAPI EditStreamPaste(PAVISTREAM pavi, LONG FAR *plPos, LONG FAR *plLength, PAVISTREAM pstream, LONG lStart, LONG lEnd);
+
+STDAPI EditStreamClone(PAVISTREAM pavi, PAVISTREAM FAR *ppResult);
+
+
+STDAPI EditStreamSetNameA(PAVISTREAM pavi, LPCSTR lpszName);
+STDAPI EditStreamSetNameW(PAVISTREAM pavi, LPCWSTR lpszName);
+STDAPI EditStreamSetInfoW(PAVISTREAM pavi, LPAVISTREAMINFOW lpInfo, LONG cbInfo);
+STDAPI EditStreamSetInfoA(PAVISTREAM pavi, LPAVISTREAMINFOA lpInfo, LONG cbInfo);
+#ifdef UNICODE
+#define EditStreamSetInfo   EditStreamSetInfoW
+#define EditStreamSetName   EditStreamSetNameW
+#else
+#define EditStreamSetInfo   EditStreamSetInfoA
+#define EditStreamSetName   EditStreamSetNameA
+#endif
++/
+enum AVIERR_OK = 0L;
+
+SCODE MAKE_AVIERR(DWORD error) {
+    return MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x4000 + error);
+}
+
+enum AVIERR_UNSUPPORTED    = MAKE_AVIERR(101);
+enum AVIERR_BADFORMAT      = MAKE_AVIERR(102);
+enum AVIERR_MEMORY         = MAKE_AVIERR(103);
+enum AVIERR_INTERNAL       = MAKE_AVIERR(104);
+enum AVIERR_BADFLAGS       = MAKE_AVIERR(105);
+enum AVIERR_BADPARAM       = MAKE_AVIERR(106);
+enum AVIERR_BADSIZE        = MAKE_AVIERR(107);
+enum AVIERR_BADHANDLE      = MAKE_AVIERR(108);
+enum AVIERR_FILEREAD       = MAKE_AVIERR(109);
+enum AVIERR_FILEWRITE      = MAKE_AVIERR(110);
+enum AVIERR_FILEOPEN       = MAKE_AVIERR(111);
+enum AVIERR_COMPRESSOR     = MAKE_AVIERR(112);
+enum AVIERR_NOCOMPRESSOR   = MAKE_AVIERR(113);
+enum AVIERR_READONLY       = MAKE_AVIERR(114);
+enum AVIERR_NODATA         = MAKE_AVIERR(115);
+enum AVIERR_BUFFERTOOSMALL = MAKE_AVIERR(116);
+enum AVIERR_CANTCOMPRESS   = MAKE_AVIERR(117);
+enum AVIERR_USERABORT      = MAKE_AVIERR(198);
+enum AVIERR_ERROR          = MAKE_AVIERR(199);
+
+const TCHAR[] MCIWND_WINDOW_CLASS = "MCIWndClass";
+
+extern (Windows) {
+    HWND MCIWndCreateA(HWND hwndParent, HINSTANCE hInstance, DWORD dwStyle, LPCSTR szFile);
+    HWND MCIWndCreateW(HWND hwndParent, HINSTANCE hInstance, DWORD dwStyle, LPCWSTR szFile);
+}
+
+version(Unicode) {
+    alias MCIWndCreateW MCIWndCreate;
+} else { // Unicode
+    alias MCIWndCreateA MCIWndCreate;
+}
+
+extern(Windows) {
+    BOOL MCIWndRegisterClass();
+}
+
+enum {
+    MCIWNDOPENF_NEW             = 0x0001,
+    MCIWNDF_NOAUTOSIZEWINDOW    = 0x0001,
+    MCIWNDF_NOPLAYBAR           = 0x0002,
+    MCIWNDF_NOAUTOSIZEMOVIE     = 0x0004,
+    MCIWNDF_NOMENU              = 0x0008,
+    MCIWNDF_SHOWNAME            = 0x0010,
+    MCIWNDF_SHOWPOS             = 0x0020,
+    MCIWNDF_SHOWMODE            = 0x0040,
+    MCIWNDF_SHOWALL             = 0x0070,
+    MCIWNDF_NOTIFYMODE          = 0x0100,
+    MCIWNDF_NOTIFYPOS           = 0x0200,
+    MCIWNDF_NOTIFYSIZE          = 0x0400,
+    MCIWNDF_NOTIFYERROR         = 0x1000,
+    MCIWNDF_NOTIFYALL           = 0x1F00,
+    MCIWNDF_NOTIFYANSI          = 0x0080,
+    MCIWNDF_NOTIFYMEDIAA        = 0x0880,
+    MCIWNDF_NOTIFYMEDIAW        = 0x0800,
+}
+
+version(Unicode) {
+    alias MCIWNDF_NOTIFYMEDIAW  MCIWNDF_NOTIFYMEDIA;
+} else { // Unicode
+    alias MCIWNDF_NOTIFYMEDIAA  MCIWNDF_NOTIFYMEDIA;
+}
+
+enum {
+    MCIWNDF_RECORD      = 0x2000,
+    MCIWNDF_NOERRORDLG  = 0x4000,
+    MCIWNDF_NOOPEN      = 0x8000,
+}
+
+// can macros
+
+BOOL MCIWndCanPlay(HWND hwnd)
+    { return cast(BOOL)SendMessage(hwnd, MCIWNDM_CAN_PLAY, 0, 0); }
+BOOL MCIWndCanRecord(HWND hwnd)
+    { return cast(BOOL)SendMessage(hwnd, MCIWNDM_CAN_RECORD, 0, 0); }
+BOOL MCIWndCanSave(HWND hwnd)
+    { return cast(BOOL)SendMessage(hwnd, MCIWNDM_CAN_SAVE, 0, 0); }
+BOOL MCIWndCanWindow(HWND hwnd)
+    { return cast(BOOL)SendMessage(hwnd, MCIWNDM_CAN_WINDOW, 0, 0); }
+BOOL MCIWndCanEject(HWND hwnd)
+    { return cast(BOOL)SendMessage(hwnd, MCIWNDM_CAN_EJECT, 0, 0); }
+BOOL MCIWndCanConfig(HWND hwnd)
+    { return cast(BOOL)SendMessage(hwnd, MCIWNDM_CAN_CONFIG, 0, 0); }
+BOOL MCIWndPaletteKick(HWND hwnd)
+    { return cast(BOOL)SendMessage(hwnd, MCIWNDM_PALETTEKICK, 0, 0); }
+LONG MCIWndSave(HWND hwnd, LPVOID szFile)
+    { return cast(LONG)SendMessage(hwnd, MCI_SAVE, 0, cast(LPARAM)szFile); }
+LONG MCIWndSaveDialog(HWND hwnd)
+    { return MCIWndSave(hwnd, cast(LPVOID)-1); }
+LONG MCIWndNew(HWND hwnd, LPVOID lp)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_NEW, 0, cast(LPARAM)lp); }
+LONG MCIWndRecord(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCI_RECORD, 0, 0); }
+LONG MCIWndOpen(HWND hwnd, LPVOID sz, UINT f)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_OPEN, cast(WPARAM)f, cast(LPARAM)sz); }
+LONG MCIWndOpenDialog(HWND hwnd)
+    { return MCIWndOpen(hwnd, cast(LPVOID)-1, 0); }
+LONG MCIWndClose(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCI_CLOSE, 0, 0); }
+LONG MCIWndPlay(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCI_PLAY, 0, 0); }
+LONG MCIWndStop(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCI_STOP, 0, 0); }
+LONG MCIWndPause(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCI_PAUSE, 0, 0); }
+LONG MCIWndResume(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCI_RESUME, 0, 0); }
+LONG MCIWndSeek(HWND hwnd, LONG lPos)
+    { return cast(LONG)SendMessage(hwnd, MCI_SEEK, 0, cast(LPARAM)lPos); }
+LONG MCIWndHome(HWND hwnd)
+    { return MCIWndSeek(hwnd, MCIWND_START); }
+LONG MCIWndEnd(HWND hwnd)
+    { return MCIWndSeek(hwnd, MCIWND_END); }
+LONG MCIWndEject(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_EJECT, 0, 0); }
+LONG MCIWndGetSource(HWND hwnd, LPRECT prc)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_GET_SOURCE, 0, cast(LPARAM)prc); }
+LONG MCIWndPutSource(HWND hwnd, LPRECT prc)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_PUT_SOURCE, 0, cast(LPARAM)prc); }
+LONG MCIWndGetDest(HWND hwnd, LPRECT prc)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_GET_DEST, 0, cast(LPARAM)prc); }
+LONG MCIWndPutDest(HWND hwnd, LPRECT prc)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_PUT_DEST, 0, cast(LPARAM)prc); }
+LONG MCIWndPlayReverse(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_PLAYREVERSE, 0, 0); }
+LONG MCIWndPlayFrom(HWND hwnd, LONG lPos)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_PLAYFROM, 0, cast(LPARAM)lPos); }
+LONG MCIWndPlayTo(HWND hwnd, LONG lPos)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_PLAYTO, 0, cast(LPARAM)lPos); }
+LONG MCIWndPlayFromTo(HWND hwnd, LONG lStart, LONG lEnd)
+    { MCIWndSeek(hwnd, lStart); return MCIWndPlayTo(hwnd, lEnd); }
+UINT MCIWndGetDeviceID(HWND hwnd)
+    { return cast(UINT)SendMessage(hwnd, MCIWNDM_GETDEVICEID, 0, 0); }
+UINT MCIWndGetAlias(HWND hwnd)
+    { return cast(UINT)SendMessage(hwnd, MCIWNDM_GETALIAS, 0, 0); }
+LONG MCIWndGetMode(HWND hwnd, LPTSTR lp, UINT len)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_GETMODE, cast(WPARAM)len, cast(LPARAM)lp); }
+LONG MCIWndGetPosition(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_GETPOSITION, 0, 0); }
+LONG MCIWndGetPositionString(HWND hwnd, LPTSTR lp, UINT len)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_GETPOSITION, cast(WPARAM)len, cast(LPARAM)lp); }
+LONG MCIWndGetStart(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_GETSTART, 0, 0); }
+LONG MCIWndGetLength(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_GETLENGTH, 0, 0); }
+LONG MCIWndGetEnd(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_GETEND, 0, 0); }
+LONG MCIWndStep(HWND hwnd, LONG n)
+    { return cast(LONG)SendMessage(hwnd, MCI_STEP, 0, cast(LPARAM)n); }
+void MCIWndDestroy(HWND hwnd)
+    { SendMessage(hwnd, WM_CLOSE, 0, 0); }
+void MCIWndSetZoom(HWND hwnd, UINT iZoom)
+    { SendMessage(hwnd, MCIWNDM_SETZOOM, 0, cast(LPARAM)iZoom); }
+UINT MCIWndGetZoom(HWND hwnd)
+    { return cast(UINT)SendMessage(hwnd, MCIWNDM_GETZOOM, 0, 0); }
+LONG MCIWndSetVolume(HWND hwnd, UINT iVol)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_SETVOLUME, 0, cast(LPARAM)iVol); }
+LONG MCIWndGetVolume(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_GETVOLUME, 0, 0); }
+LONG MCIWndSetSpeed(HWND hwnd, UINT iSpeed)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_SETSPEED, 0, cast(LPARAM)iSpeed); }
+LONG MCIWndGetSpeed(HWND hwnd)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_GETSPEED, 0, 0); }
+LONG MCIWndSetTimeFormat(HWND hwnd, LPTSTR lp)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_SETTIMEFORMAT, 0, cast(LPARAM)lp); }
+LONG MCIWndUseFrames(HWND hwnd)
+    { return MCIWndSetTimeFormat(hwnd, (cast(TCHAR[])"frames").ptr); }
+LONG MCIWndUseTime(HWND hwnd)
+    { return MCIWndSetTimeFormat(hwnd, (cast(TCHAR[])"ms").ptr); }
+LONG MCIWndGetTimeFormat(HWND hwnd, LPTSTR lp, UINT len)
+    { return cast(LONG)SendMessage(hwnd, MCIWNDM_GETTIMEFORMAT, cast(WPARAM)len, cast(LPARAM)lp); }
+void MCIWndValidateMedia(HWND hwnd)
+    { SendMessage(hwnd, MCIWNDM_VALIDATEMEDIA, 0, 0); }
+void MCIWndSetRepeat(HWND hwnd, BOOL f)
+    { SendMessage(hwnd, MCIWNDM_SETREPEAT, 0, cast(LPARAM)f); }
+BOOL MCIWndGetRepeat(HWND hwnd)
+    { return cast(BOOL)SendMessage(hwnd, MCIWNDM_GETREPEAT, 0, 0); }
+void MCIWndSetActiveTimer(HWND hwnd, UINT active)
+    { SendMessage(hwnd, MCIWNDM_SETACTIVETIMER, cast(WPARAM)active, 0); }
+void MCIWndSetInactiveTimer(HWND hwnd, UINT inactive)
+    { SendMessage(hwnd, MCIWNDM_SETINACTIVETIMER, cast(WPARAM)inactive, 0); }
+void MCIWndSetTimers(HWND hwnd, UINT active, UINT inactive)
+    { SendMessage(hwnd, MCIWNDM_SETTIMERS, cast(WPARAM)active, cast(LPARAM)inactive); }
+UINT MCIWndGetActiveTimer(HWND hwnd)
+    { return cast(UINT)SendMessage(hwnd, MCIWNDM_GETACTIVETIMER, 0, 0); }
+UINT MCIWndGetInactiveTimer(HWND hwnd)
+    { return cast(UINT)SendMessage(hwnd, MCIWNDM_GETINACTIVETIMER, 0, 0); }
+LONG MCIWndRealize(HWND hwnd, BOOL fBkgnd)
+    { return cast(LONG) SendMessage(hwnd, MCIWNDM_REALIZE, cast(WPARAM)fBkgnd, 0); }
+LONG MCIWndSendString(HWND hwnd, LPTSTR sz)
+    { return cast(LONG) SendMessage(hwnd, MCIWNDM_SENDSTRING, 0, cast(LPARAM)sz); }
+LONG MCIWndReturnString(HWND hwnd, LPVOID lp, UINT len)
+    { return cast(LONG) SendMessage(hwnd, MCIWNDM_RETURNSTRING, cast(WPARAM)len, cast(LPARAM)lp); }
+LONG MCIWndGetError(HWND hwnd, LPVOID lp, UINT len)
+    { return cast(LONG) SendMessage(hwnd, MCIWNDM_GETERROR, cast(WPARAM)len, cast(LPARAM)lp); }
+HPALETTE MCIWndGetPalette(HWND hwnd)
+    { return cast(HPALETTE)SendMessage(hwnd, MCIWNDM_GETPALETTE, 0, 0); }
+LONG MCIWndSetPalette(HWND hwnd, HPALETTE hpal)
+    { return cast(LONG) SendMessage(hwnd, MCIWNDM_SETPALETTE, cast(WPARAM)hpal, 0); }
+LONG MCIWndGetFileName(HWND hwnd, LPVOID lp, UINT len)
+    { return cast(LONG) SendMessage(hwnd, MCIWNDM_GETFILENAME, cast(WPARAM)len, cast(LPARAM)lp); }
+LONG MCIWndGetDevice(HWND hwnd, LPVOID lp, UINT len)
+    { return cast(LONG) SendMessage(hwnd, MCIWNDM_GETDEVICE, cast(WPARAM)len, cast(LPARAM)lp); }
+UINT MCIWndGetStyles(HWND hwnd)
+    { return cast(UINT) SendMessage(hwnd, MCIWNDM_GETSTYLES, 0, 0); }
+LONG MCIWndChangeStyles(HWND hwnd, UINT mask, LONG value)
+    { return cast(LONG) SendMessage(hwnd, MCIWNDM_CHANGESTYLES, cast(WPARAM)mask, cast(LPARAM)value); }
+LONG MCIWndOpenInterface(HWND hwnd, LPUNKNOWN pUnk)
+    { return cast(LONG) SendMessage(hwnd, MCIWNDM_OPENINTERFACE, 0, cast(LPARAM)cast(void*)pUnk); }
+LONG MCIWndSetOwner(HWND hwnd, HWND hwndP)
+    { return cast(LONG) SendMessage(hwnd, MCIWNDM_SETOWNER, cast(WPARAM)hwndP, 0); }
+
+enum {
+    MCIWNDM_GETDEVICEID         = WM_USER + 100,
+    MCIWNDM_SENDSTRINGA         = WM_USER + 101,
+    MCIWNDM_GETPOSITIONA        = WM_USER + 102,
+    MCIWNDM_GETSTART            = WM_USER + 103,
+    MCIWNDM_GETLENGTH           = WM_USER + 104,
+    MCIWNDM_GETEND              = WM_USER + 105,
+    MCIWNDM_GETMODEA            = WM_USER + 106,
+    MCIWNDM_EJECT               = WM_USER + 107,
+    MCIWNDM_SETZOOM             = WM_USER + 108,
+    MCIWNDM_GETZOOM             = WM_USER + 109,
+    MCIWNDM_SETVOLUME           = WM_USER + 110,
+    MCIWNDM_GETVOLUME           = WM_USER + 111,
+    MCIWNDM_SETSPEED            = WM_USER + 112,
+    MCIWNDM_GETSPEED            = WM_USER + 113,
+    MCIWNDM_SETREPEAT           = WM_USER + 114,
+    MCIWNDM_GETREPEAT           = WM_USER + 115,
+    MCIWNDM_REALIZE             = WM_USER + 118,
+    MCIWNDM_SETTIMEFORMATA      = WM_USER + 119,
+    MCIWNDM_GETTIMEFORMATA      = WM_USER + 120,
+    MCIWNDM_VALIDATEMEDIA       = WM_USER + 121,
+    MCIWNDM_PLAYFROM            = WM_USER + 122,
+    MCIWNDM_PLAYTO              = WM_USER + 123,
+    MCIWNDM_GETFILENAMEA        = WM_USER + 124,
+    MCIWNDM_GETDEVICEA          = WM_USER + 125,
+    MCIWNDM_GETPALETTE          = WM_USER + 126,
+    MCIWNDM_SETPALETTE          = WM_USER + 127,
+    MCIWNDM_GETERRORA           = WM_USER + 128,
+    MCIWNDM_SETTIMERS           = WM_USER + 129,
+    MCIWNDM_SETACTIVETIMER      = WM_USER + 130,
+    MCIWNDM_SETINACTIVETIMER    = WM_USER + 131,
+    MCIWNDM_GETACTIVETIMER      = WM_USER + 132,
+    MCIWNDM_GETINACTIVETIMER    = WM_USER + 133,
+    MCIWNDM_NEWA                = WM_USER + 134,
+    MCIWNDM_CHANGESTYLES        = WM_USER + 135,
+    MCIWNDM_GETSTYLES           = WM_USER + 136,
+    MCIWNDM_GETALIAS            = WM_USER + 137,
+    MCIWNDM_RETURNSTRINGA       = WM_USER + 138,
+    MCIWNDM_PLAYREVERSE         = WM_USER + 139,
+    MCIWNDM_GET_SOURCE          = WM_USER + 140,
+    MCIWNDM_PUT_SOURCE          = WM_USER + 141,
+    MCIWNDM_GET_DEST            = WM_USER + 142,
+    MCIWNDM_PUT_DEST            = WM_USER + 143,
+    MCIWNDM_CAN_PLAY            = WM_USER + 144,
+    MCIWNDM_CAN_WINDOW          = WM_USER + 145,
+    MCIWNDM_CAN_RECORD          = WM_USER + 146,
+    MCIWNDM_CAN_SAVE            = WM_USER + 147,
+    MCIWNDM_CAN_EJECT           = WM_USER + 148,
+    MCIWNDM_CAN_CONFIG          = WM_USER + 149,
+    MCIWNDM_PALETTEKICK         = WM_USER + 150,
+    MCIWNDM_OPENINTERFACE       = WM_USER + 151,
+    MCIWNDM_SETOWNER            = WM_USER + 152,
+    MCIWNDM_OPENA               = WM_USER + 153,
+    MCIWNDM_SENDSTRINGW         = WM_USER + 201,
+    MCIWNDM_GETPOSITIONW        = WM_USER + 202,
+    MCIWNDM_GETMODEW            = WM_USER + 206,
+    MCIWNDM_SETTIMEFORMATW      = WM_USER + 219,
+    MCIWNDM_GETTIMEFORMATW      = WM_USER + 220,
+    MCIWNDM_GETFILENAMEW        = WM_USER + 224,
+    MCIWNDM_GETDEVICEW          = WM_USER + 225,
+    MCIWNDM_GETERRORW           = WM_USER + 228,
+    MCIWNDM_NEWW                = WM_USER + 234,
+    MCIWNDM_RETURNSTRINGW       = WM_USER + 238,
+    MCIWNDM_OPENW               = WM_USER + 252,
+}
+
+version(Unicode) {
+    alias MCIWNDM_SENDSTRINGW       MCIWNDM_SENDSTRING;
+    alias MCIWNDM_GETPOSITIONW      MCIWNDM_GETPOSITION;
+    alias MCIWNDM_GETMODEW          MCIWNDM_GETMODE;
+    alias MCIWNDM_SETTIMEFORMATW    MCIWNDM_SETTIMEFORMAT;
+    alias MCIWNDM_GETTIMEFORMATW    MCIWNDM_GETTIMEFORMAT;
+    alias MCIWNDM_GETFILENAMEW      MCIWNDM_GETFILENAME;
+    alias MCIWNDM_GETDEVICEW        MCIWNDM_GETDEVICE;
+    alias MCIWNDM_GETERRORW         MCIWNDM_GETERROR;
+    alias MCIWNDM_NEWW              MCIWNDM_NEW;
+    alias MCIWNDM_RETURNSTRINGW     MCIWNDM_RETURNSTRING;
+    alias MCIWNDM_OPENW             MCIWNDM_OPEN;
+} else { // Unicode
+    alias MCIWNDM_SENDSTRINGA       MCIWNDM_SENDSTRING;
+    alias MCIWNDM_GETPOSITIONA      MCIWNDM_GETPOSITION;
+    alias MCIWNDM_GETMODEA          MCIWNDM_GETMODE;
+    alias MCIWNDM_SETTIMEFORMATA    MCIWNDM_SETTIMEFORMAT;
+    alias MCIWNDM_GETTIMEFORMATA    MCIWNDM_GETTIMEFORMAT;
+    alias MCIWNDM_GETFILENAMEA      MCIWNDM_GETFILENAME;
+    alias MCIWNDM_GETDEVICEA        MCIWNDM_GETDEVICE;
+    alias MCIWNDM_GETERRORA         MCIWNDM_GETERROR;
+    alias MCIWNDM_NEWA              MCIWNDM_NEW;
+    alias MCIWNDM_RETURNSTRINGA     MCIWNDM_RETURNSTRING;
+    alias MCIWNDM_OPENA             MCIWNDM_OPEN;
+}
+
+enum {
+    MCIWNDM_NOTIFYMODE  = WM_USER + 200,
+    MCIWNDM_NOTIFYPOS   = WM_USER + 201,
+    MCIWNDM_NOTIFYSIZE  = WM_USER + 202,
+    MCIWNDM_NOTIFYMEDIA = WM_USER + 203,
+    MCIWNDM_NOTIFYERROR = WM_USER + 205,
+}
+
+enum MCIWND_START  = -1;
+enum MCIWND_END    = -2;
+
+enum {
+    MCI_CLOSE   = 0x0804,
+    MCI_PLAY    = 0x0806,
+    MCI_SEEK    = 0x0807,
+    MCI_STOP    = 0x0808,
+    MCI_PAUSE   = 0x0809,
+    MCI_STEP    = 0x080E,
+    MCI_RECORD  = 0x080F,
+    MCI_SAVE    = 0x0813,
+    MCI_CUT     = 0x0851,
+    MCI_COPY    = 0x0852,
+    MCI_PASTE   = 0x0853,
+    MCI_RESUME  = 0x0855,
+    MCI_DELETE  = 0x0856,
+}
+
+enum {
+    MCI_MODE_NOT_READY  = 524,
+    MCI_MODE_STOP,
+    MCI_MODE_PLAY,
+    MCI_MODE_RECORD,
+    MCI_MODE_SEEK,
+    MCI_MODE_PAUSE,
+    MCI_MODE_OPEN,
+}
+
+alias TypeDef!(HANDLE) HVIDEO;
+alias HVIDEO* LPHVIDEO;
+
+// Error Return Values
+
+enum {
+    DV_ERR_OK               = 0,
+    DV_ERR_BASE             = 1,
+    DV_ERR_NONSPECIFIC      = DV_ERR_BASE,
+    DV_ERR_BADFORMAT        = DV_ERR_BASE + 1,
+    DV_ERR_STILLPLAYING     = DV_ERR_BASE + 2,
+    DV_ERR_UNPREPARED       = DV_ERR_BASE + 3,
+    DV_ERR_SYNC             = DV_ERR_BASE + 4,
+    DV_ERR_TOOMANYCHANNELS  = DV_ERR_BASE + 5,
+    DV_ERR_NOTDETECTED      = DV_ERR_BASE + 6,
+    DV_ERR_BADINSTALL       = DV_ERR_BASE + 7,
+    DV_ERR_CREATEPALETTE    = DV_ERR_BASE + 8,
+    DV_ERR_SIZEFIELD        = DV_ERR_BASE + 9,
+    DV_ERR_PARAM1           = DV_ERR_BASE + 10,
+    DV_ERR_PARAM2           = DV_ERR_BASE + 11,
+    DV_ERR_CONFIG1          = DV_ERR_BASE + 12,
+    DV_ERR_CONFIG2          = DV_ERR_BASE + 13,
+    DV_ERR_FLAGS            = DV_ERR_BASE + 14,
+    DV_ERR_13               = DV_ERR_BASE + 15,
+    DV_ERR_NOTSUPPORTED     = DV_ERR_BASE + 16,
+    DV_ERR_NOMEM            = DV_ERR_BASE + 17,
+    DV_ERR_ALLOCATED        = DV_ERR_BASE + 18,
+    DV_ERR_BADDEVICEID      = DV_ERR_BASE + 19,
+    DV_ERR_INVALHANDLE      = DV_ERR_BASE + 20,
+    DV_ERR_BADERRNUM        = DV_ERR_BASE + 21,
+    DV_ERR_NO_BUFFERS       = DV_ERR_BASE + 22,
+    DV_ERR_MEM_CONFLICT     = DV_ERR_BASE + 23,
+    DV_ERR_IO_CONFLICT      = DV_ERR_BASE + 24,
+    DV_ERR_DMA_CONFLICT     = DV_ERR_BASE + 25,
+    DV_ERR_INT_CONFLICT     = DV_ERR_BASE + 26,
+    DV_ERR_PROTECT_ONLY     = DV_ERR_BASE + 27,
+    DV_ERR_LASTERROR        = DV_ERR_BASE + 27,
+    DV_ERR_USER_MSG         = DV_ERR_BASE + 1000,
+}
+
+// Callback Messages
+
+enum {
+    MM_DRVM_OPEN    = 0x3D0,
+    MM_DRVM_CLOSE,
+    MM_DRVM_DATA,
+    MM_DRVM_ERROR,
+}
+
+enum {
+    DV_VM_OPEN  = MM_DRVM_OPEN,
+    DV_VM_CLOSE = MM_DRVM_CLOSE,
+    DV_VM_DATA  = MM_DRVM_DATA,
+    DV_VM_ERROR = MM_DRVM_ERROR,
+}
+
+/**
+ * Structures
+ */
+
+struct VIDEOHDR {
+    LPBYTE      lpData;
+    DWORD       dwBufferLength;
+    DWORD       dwBytesUsed;
+    DWORD       dwTimeCaptured;
+    DWORD_PTR   dwUser;
+    DWORD       dwFlags;
+    DWORD_PTR[4]dwReserved;
+}
+alias VIDEOHDR* PVIDEOHDR, LPVIDEOHDR;
+
+enum {
+    VHDR_DONE       = 0x00000001,
+    VHDR_PREPARED   = 0x00000002,
+    VHDR_INQUEUE    = 0x00000004,
+    VHDR_KEYFRAME   = 0x00000008,
+    VHDR_VALID      = 0x0000000F,
+}
+
+struct CHANNEL_CAPS {
+    DWORD   dwFlags;
+    DWORD   dwSrcRectXMod;
+    DWORD   dwSrcRectYMod;
+    DWORD   dwSrcRectWidthMod;
+    DWORD   dwSrcRectHeightMod;
+    DWORD   dwDstRectXMod;
+    DWORD   dwDstRectYMod;
+    DWORD   dwDstRectWidthMod;
+    DWORD   dwDstRectHeightMod;
+}
+alias CHANNEL_CAPS* PCHANNEL_CAPS, LPCHANNEL_CAPS;
+
+enum {
+    VCAPS_OVERLAY       = 0x00000001,
+    VCAPS_SRC_CAN_CLIP  = 0x00000002,
+    VCAPS_DST_CAN_CLIP  = 0x00000004,
+    VCAPS_CAN_SCALE     = 0x00000008,
+}
+
+/**
+ * API Flags
+ */
+
+enum {
+    VIDEO_EXTERNALIN            = 0x0001,
+    VIDEO_EXTERNALOUT           = 0x0002,
+    VIDEO_IN                    = 0x0004,
+    VIDEO_OUT                   = 0x0008,
+    VIDEO_DLG_QUERY             = 0x0010,
+}
+
+enum {
+    VIDEO_CONFIGURE_QUERYSIZE   = 0x0001,
+    VIDEO_CONFIGURE_CURRENT     = 0x0010,
+    VIDEO_CONFIGURE_NOMINAL     = 0x0020,
+    VIDEO_CONFIGURE_MIN         = 0x0040,
+    VIDEO_CONFIGURE_MAX         = 0x0080,
+    VIDEO_CONFIGURE_SET         = 0x1000,
+    VIDEO_CONFIGURE_GET         = 0x2000,
+    VIDEO_CONFIGURE_QUERY       = 0x8000,
+}
+
+/**
+ * CONFIGURE MESSAGES
+ */
+
+enum {
+    DVM_USER            = 0x4000,
+    DVM_CONFIGURE_START = 0x1000,
+    DVM_CONFIGURE_END   = 0x1FFF,
+    DVM_PALETTE         = DVM_CONFIGURE_START + 1,
+    DVM_FORMAT          = DVM_CONFIGURE_START + 2,
+    DVM_PALETTERGB555   = DVM_CONFIGURE_START + 3,
+    DVM_SRC_RECT        = DVM_CONFIGURE_START + 4,
+    DVM_DST_RECT        = DVM_CONFIGURE_START + 5,
+}
+
+/**
+ * AVICap window class
+ */
+
+LRESULT AVICapSM(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
+    if (IsWindow(hWnd)) {
+        return SendMessage(hWnd, msg, wParam, lParam);
+    }
+    return 0;
+}
+
+enum {
+    WM_CAP_START                = WM_USER,
+    WM_CAP_UNICODE_START        = WM_USER + 100,
+
+    WM_CAP_GET_CAPSTREAMPTR     = WM_CAP_START + 1,
+    WM_CAP_SET_CALLBACK_ERRORA  = WM_CAP_START + 2,
+    WM_CAP_SET_CALLBACK_STATUSA = WM_CAP_START + 3,
+
+    WM_CAP_SET_CALLBACK_ERRORW  = WM_CAP_UNICODE_START + 2,
+    WM_CAP_SET_CALLBACK_STATUSW = WM_CAP_UNICODE_START + 3,
+}
+
+version(Unicode) {
+    alias WM_CAP_SET_CALLBACK_ERRORW    WM_CAP_SET_CALLBACK_ERROR;
+    alias WM_CAP_SET_CALLBACK_STATUSW   WM_CAP_SET_CALLBACK_STATUS;
+} else { // Unicode
+    alias WM_CAP_SET_CALLBACK_ERRORA    WM_CAP_SET_CALLBACK_ERROR;
+    alias WM_CAP_SET_CALLBACK_STATUSA   WM_CAP_SET_CALLBACK_STATUS;
+}
+
+enum {
+    WM_CAP_SET_CALLBACK_YIELD       = WM_CAP_START + 4,
+    WM_CAP_SET_CALLBACK_FRAME       = WM_CAP_START + 5,
+    WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6,
+    WM_CAP_SET_CALLBACK_WAVESTREAM  = WM_CAP_START + 7,
+    WM_CAP_GET_USER_DATA            = WM_CAP_START + 8,
+    WM_CAP_SET_USER_DATA            = WM_CAP_START + 9,
+    WM_CAP_DRIVER_CONNECT           = WM_CAP_START + 10,
+    WM_CAP_DRIVER_DISCONNECT        = WM_CAP_START + 11,
+    WM_CAP_DRIVER_GET_NAMEA         = WM_CAP_START + 12,
+    WM_CAP_DRIVER_GET_VERSIONA      = WM_CAP_START + 13,
+
+    WM_CAP_DRIVER_GET_NAMEW         = WM_CAP_UNICODE_START + 12,
+    WM_CAP_DRIVER_GET_VERSIONW      = WM_CAP_UNICODE_START + 13,
+}
+
+version(Unicode) {
+    alias WM_CAP_DRIVER_GET_NAMEW       WM_CAP_DRIVER_GET_NAME;
+    alias WM_CAP_DRIVER_GET_VERSIONW    WM_CAP_DRIVER_GET_VERSION;
+} else { // Unicode
+    alias WM_CAP_DRIVER_GET_NAMEA       WM_CAP_DRIVER_GET_NAME;
+    alias WM_CAP_DRIVER_GET_VERSIONA    WM_CAP_DRIVER_GET_VERSION;
+}
+
+enum {
+    WM_CAP_DRIVER_GET_CAPS          = WM_CAP_START + 14,
+    WM_CAP_FILE_SET_CAPTURE_FILEA   = WM_CAP_START + 20,
+    WM_CAP_FILE_GET_CAPTURE_FILEA   = WM_CAP_START + 21,
+    WM_CAP_FILE_SAVEASA             = WM_CAP_START + 23,
+    WM_CAP_FILE_SAVEDIBA            = WM_CAP_START + 25,
+
+    WM_CAP_FILE_SET_CAPTURE_FILEW   = WM_CAP_UNICODE_START + 20,
+    WM_CAP_FILE_GET_CAPTURE_FILEW   = WM_CAP_UNICODE_START + 21,
+    WM_CAP_FILE_SAVEASW             = WM_CAP_UNICODE_START + 23,
+    WM_CAP_FILE_SAVEDIBW            = WM_CAP_UNICODE_START + 25,
+}
+
+version(Unicode) {
+    alias WM_CAP_FILE_SET_CAPTURE_FILEW WM_CAP_FILE_SET_CAPTURE_FILE;
+    alias WM_CAP_FILE_GET_CAPTURE_FILEW WM_CAP_FILE_GET_CAPTURE_FILE;
+    alias WM_CAP_FILE_SAVEASW           WM_CAP_FILE_SAVEAS;
+    alias WM_CAP_FILE_SAVEDIBW          WM_CAP_FILE_SAVEDIB;
+} else { // Unicode
+    alias WM_CAP_FILE_SET_CAPTURE_FILEA WM_CAP_FILE_SET_CAPTURE_FILE;
+    alias WM_CAP_FILE_GET_CAPTURE_FILEA WM_CAP_FILE_GET_CAPTURE_FILE;
+    alias WM_CAP_FILE_SAVEASA           WM_CAP_FILE_SAVEAS;
+    alias WM_CAP_FILE_SAVEDIBA          WM_CAP_FILE_SAVEDIB;
+}
+
+enum {
+    WM_CAP_FILE_ALLOCATE        = WM_CAP_START + 22,
+    WM_CAP_FILE_SET_INFOCHUNK   = WM_CAP_START + 24,
+    WM_CAP_EDIT_COPY            = WM_CAP_START + 30,
+    WM_CAP_SET_AUDIOFORMAT      = WM_CAP_START + 35,
+    WM_CAP_GET_AUDIOFORMAT      = WM_CAP_START + 36,
+    WM_CAP_DLG_VIDEOFORMAT      = WM_CAP_START + 41,
+    WM_CAP_DLG_VIDEOSOURCE      = WM_CAP_START + 42,
+    WM_CAP_DLG_VIDEODISPLAY     = WM_CAP_START + 43,
+    WM_CAP_GET_VIDEOFORMAT      = WM_CAP_START + 44,
+    WM_CAP_SET_VIDEOFORMAT      = WM_CAP_START + 45,
+    WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46,
+    WM_CAP_SET_PREVIEW          = WM_CAP_START + 50,
+    WM_CAP_SET_OVERLAY          = WM_CAP_START + 51,
+    WM_CAP_SET_PREVIEWRATE      = WM_CAP_START + 52,
+    WM_CAP_SET_SCALE            = WM_CAP_START + 53,
+    WM_CAP_GET_STATUS           = WM_CAP_START + 54,
+    WM_CAP_SET_SCROLL           = WM_CAP_START + 55,
+    WM_CAP_GRAB_FRAME           = WM_CAP_START + 60,
+    WM_CAP_GRAB_FRAME_NOSTOP    = WM_CAP_START + 61,
+    WM_CAP_SEQUENCE             = WM_CAP_START + 62,
+    WM_CAP_SEQUENCE_NOFILE      = WM_CAP_START + 63,
+    WM_CAP_SET_SEQUENCE_SETUP   = WM_CAP_START + 64,
+    WM_CAP_GET_SEQUENCE_SETUP   = WM_CAP_START + 65,
+    WM_CAP_SET_MCI_DEVICEA      = WM_CAP_START + 66,
+    WM_CAP_GET_MCI_DEVICEA      = WM_CAP_START + 67,
+
+    WM_CAP_SET_MCI_DEVICEW      = WM_CAP_UNICODE_START + 66,
+    WM_CAP_GET_MCI_DEVICEW      = WM_CAP_UNICODE_START + 67,
+}
+
+version(Unicode) {
+    alias WM_CAP_SET_MCI_DEVICEW    WM_CAP_SET_MCI_DEVICE;
+    alias WM_CAP_GET_MCI_DEVICEW    WM_CAP_GET_MCI_DEVICE;
+} else { // Unicode
+    alias WM_CAP_SET_MCI_DEVICEA    WM_CAP_SET_MCI_DEVICE;
+    alias WM_CAP_GET_MCI_DEVICEA    WM_CAP_GET_MCI_DEVICE;
+}
+
+enum {
+    WM_CAP_STOP                 = WM_CAP_START + 68,
+    WM_CAP_ABORT                = WM_CAP_START + 69,
+    WM_CAP_SINGLE_FRAME_OPEN    = WM_CAP_START + 70,
+    WM_CAP_SINGLE_FRAME_CLOSE   = WM_CAP_START + 71,
+    WM_CAP_SINGLE_FRAME         = WM_CAP_START + 72,
+    WM_CAP_PAL_OPENA            = WM_CAP_START + 80,
+    WM_CAP_PAL_SAVEA            = WM_CAP_START + 81,
+
+    WM_CAP_PAL_OPENW            = WM_CAP_UNICODE_START + 80,
+    WM_CAP_PAL_SAVEW            = WM_CAP_UNICODE_START + 81,
+}
+
+version(Unicode) {
+    alias WM_CAP_PAL_OPENW  WM_CAP_PAL_OPEN;
+    alias WM_CAP_PAL_SAVEW  WM_CAP_PAL_SAVE;
+} else { // Unicode
+    alias WM_CAP_PAL_OPENA  WM_CAP_PAL_OPEN;
+    alias WM_CAP_PAL_SAVEA  WM_CAP_PAL_SAVE;
+}
+
+enum {
+    WM_CAP_PAL_PASTE                = WM_CAP_START + 82,
+    WM_CAP_PAL_AUTOCREATE           = WM_CAP_START + 83,
+    WM_CAP_PAL_MANUALCREATE         = WM_CAP_START + 84,
+    WM_CAP_SET_CALLBACK_CAPCONTROL  = WM_CAP_START + 85,
+    WM_CAP_UNICODE_END              = WM_CAP_PAL_SAVEW,
+    WM_CAP_END                      = WM_CAP_UNICODE_END,
+}
+
+/**
+ * message wrapper
+ */
+
+BOOL capSetCallbackOnError(HWND hWnd, LPVOID fpProc)                { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_ERROR, 0, cast(LPARAM)fpProc); }
+BOOL capSetCallbackOnStatus(HWND hWnd, LPVOID fpProc)               { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_STATUS, 0, cast(LPARAM)fpProc); }
+BOOL capSetCallbackOnYield(HWND hWnd, LPVOID fpProc)                { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_YIELD, 0, cast(LPARAM)fpProc); }
+BOOL capSetCallbackOnFrame(HWND hWnd, LPVOID fpProc)                { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_FRAME, 0, cast(LPARAM)fpProc); }
+BOOL capSetCallbackOnVideoStream(HWND hWnd, LPVOID fpProc)          { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, cast(LPARAM)fpProc); }
+BOOL capSetCallbackOnWaveStream(HWND hWnd, LPVOID fpProc)           { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_WAVESTREAM, 0, cast(LPARAM)fpProc); }
+BOOL capSetCallbackOnCapControl(HWND hWnd, LPVOID fpProc)           { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_CALLBACK_CAPCONTROL, 0, cast(LPARAM)fpProc); }
+
+BOOL capSetUserData(HWND hWnd, LPARAM lUser)                        { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_USER_DATA, 0, lUser); }
+BOOL capGetUserData(HWND hWnd)                                      { return cast(BOOL)AVICapSM(hWnd, WM_CAP_GET_USER_DATA, 0, 0); }
+
+BOOL capDriverConnect(HWND hWnd, WPARAM i)                          { return cast(BOOL)AVICapSM(hWnd, WM_CAP_DRIVER_CONNECT, i, 0); }
+BOOL capDriverDisconnect(HWND hWnd)                                 { return cast(BOOL)AVICapSM(hWnd, WM_CAP_DRIVER_DISCONNECT, 0, 0); }
+BOOL capDriverGetName(HWND hWnd, LPTSTR szName, WPARAM wSize)       { return cast(BOOL)AVICapSM(hWnd, WM_CAP_DRIVER_GET_NAME, wSize, cast(LPARAM)szName); }
+BOOL capDriverGetVersion(HWND hWnd, LPTSTR szVer, WPARAM wSize)     { return cast(BOOL)AVICapSM(hWnd, WM_CAP_DRIVER_GET_VERSION, wSize, cast(LPARAM)szVer); }
+BOOL capDriverGetCaps(HWND hWnd, LPCAPDRIVERCAPS s, WPARAM wSize)   { return cast(BOOL)AVICapSM(hWnd, WM_CAP_DRIVER_GET_CAPS, wSize, cast(LPARAM)s); }
+
+BOOL capFileSetCaptureFile(HWND hWnd, LPTSTR szName)                { return cast(BOOL)AVICapSM(hWnd, WM_CAP_FILE_SET_CAPTURE_FILE, 0, cast(LPARAM)szName); }
+BOOL capFileGetCaptureFile(HWND hWnd, LPTSTR szName, WPARAM wSize)  { return cast(BOOL)AVICapSM(hWnd, WM_CAP_FILE_GET_CAPTURE_FILE, wSize, cast(LPARAM)szName); }
+BOOL capFileAlloc(HWND hWnd, WPARAM wSize)                          { return cast(BOOL)AVICapSM(hWnd, WM_CAP_FILE_ALLOCATE, wSize, 0); }
+BOOL capFileSaveAs(HWND hWnd, LPTSTR szName)                        { return cast(BOOL)AVICapSM(hWnd, WM_CAP_FILE_SAVEAS, 0, cast(LPARAM)szName); }
+BOOL capFileSetInfoChunk(HWND hWnd, LPCAPINFOCHUNK lpInfoChunk)     { return cast(BOOL)AVICapSM(hWnd, WM_CAP_FILE_SET_INFOCHUNK, 0, cast(LPARAM)lpInfoChunk); }
+BOOL capFileSaveDIB(HWND hWnd, LPTSTR szName)                       { return cast(BOOL)AVICapSM(hWnd, WM_CAP_FILE_SAVEDIB, 0, cast(LPARAM)szName); }
+
+BOOL capEditCopy(HWND hWnd)                                         { return cast(BOOL)AVICapSM(hWnd, WM_CAP_EDIT_COPY, 0, 0); }
+
+BOOL capSetAudioFormat(HWND hWnd, LPWAVEFORMATEX s, WPARAM wSize)   { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_AUDIOFORMAT, wSize, cast(LPARAM)s); }
+DWORD capGetAudioFormat(HWND hWnd, LPWAVEFORMATEX s, WPARAM wSize)  { return cast(DWORD)AVICapSM(hWnd, WM_CAP_GET_AUDIOFORMAT, wSize, cast(LPARAM)s); }
+DWORD capGetAudioFormatSize(HWND hWnd)                              { return cast(DWORD)AVICapSM(hWnd, WM_CAP_GET_AUDIOFORMAT, 0, 0); }
+
+BOOL capDlgVideoFormat(HWND hWnd)                                   { return cast(BOOL)AVICapSM(hWnd, WM_CAP_DLG_VIDEOFORMAT, 0, 0); }
+BOOL capDlgVideoSource(HWND hWnd)                                   { return cast(BOOL)AVICapSM(hWnd, WM_CAP_DLG_VIDEOSOURCE, 0, 0); }
+BOOL capDlgVideoDisplay(HWND hWnd)                                  { return cast(BOOL)AVICapSM(hWnd, WM_CAP_DLG_VIDEODISPLAY, 0, 0); }
+BOOL capDlgVideoCompression(HWND hWnd)                              { return cast(BOOL)AVICapSM(hWnd, WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0); }
+
+DWORD capGetVideoFormat(HWND hWnd, void* s, WPARAM wSize)           { return cast(DWORD)AVICapSM(hWnd, WM_CAP_GET_VIDEOFORMAT, wSize, cast(LPARAM)s); }
+DWORD capGetVideoFormatSize(HWND hWnd)                              { return cast(DWORD)AVICapSM(hWnd, WM_CAP_GET_VIDEOFORMAT, 0, 0); }
+BOOL capSetVideoFormat(HWND hWnd, void* s, WPARAM wSize)            { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_VIDEOFORMAT, wSize, cast(LPARAM)s); }
+
+BOOL capPreview(HWND hWnd, BOOL f)                                  { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_PREVIEW, cast(WPARAM)f, 0); }
+BOOL capPreviewRate(HWND hWnd, WPARAM wMS)                          { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_PREVIEWRATE, wMS, 0); }
+BOOL capOverlay(HWND hWnd, BOOL f)                                  { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_OVERLAY, cast(WPARAM)f, 0); }
+BOOL capPreviewScale(HWND hWnd, BOOL f)                             { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_SCALE, cast(WPARAM)f, 0); }
+BOOL capGetStatus(HWND hWnd, LPCAPSTATUS s, WPARAM wSize)           { return cast(BOOL)AVICapSM(hWnd, WM_CAP_GET_STATUS, wSize, cast(LPARAM)s); }
+BOOL capSetScrollPos(HWND hWnd, LPPOINT lpP)                        { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_SCROLL, 0, cast(LPARAM)lpP); }
+
+BOOL capGrabFrame(HWND hWnd)                                        { return cast(BOOL)AVICapSM(hWnd, WM_CAP_GRAB_FRAME, 0, 0); }
+BOOL capGrabFrameNoStop(HWND hWnd)                                  { return cast(BOOL)AVICapSM(hWnd, WM_CAP_GRAB_FRAME_NOSTOP, 0, 0); }
+
+BOOL capCaptureSequence(HWND hWnd)                                  { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SEQUENCE, 0, 0); }
+BOOL capCaptureSequenceNoFile(HWND hWnd)                            { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SEQUENCE_NOFILE, 0, 0); }
+BOOL capCaptureStop(HWND hWnd)                                      { return cast(BOOL)AVICapSM(hWnd, WM_CAP_STOP, 0, 0); }
+BOOL capCaptureAbort(HWND hWnd)                                     { return cast(BOOL)AVICapSM(hWnd, WM_CAP_ABORT, 0, 0); }
+
+BOOL capCaptureSingleFrameOpen(HWND hWnd)                           { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SINGLE_FRAME_OPEN, 0, 0); }
+BOOL capCaptureSingleFrameClose(HWND hWnd)                          { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SINGLE_FRAME_CLOSE, 0, 0); }
+BOOL capCaptureSingleFrame(HWND hWnd)                               { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SINGLE_FRAME, 0, 0); }
+
+BOOL capCaptureGetSetup(HWND hWnd, LPCAPTUREPARMS s, WPARAM wSize)  { return cast(BOOL)AVICapSM(hWnd, WM_CAP_GET_SEQUENCE_SETUP, wSize, cast(LPARAM)s); }
+BOOL capCaptureSetSetup(HWND hWnd, LPCAPTUREPARMS s, WPARAM wSize)  { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_SEQUENCE_SETUP, wSize, cast(LPARAM)s); }
+
+BOOL capSetMCIDeviceName(HWND hWnd, LPTSTR szName)                  { return cast(BOOL)AVICapSM(hWnd, WM_CAP_SET_MCI_DEVICE, 0, cast(LPARAM)szName); }
+BOOL capGetMCIDeviceName(HWND hWnd, LPTSTR szName, WPARAM wSize)    { return cast(BOOL)AVICapSM(hWnd, WM_CAP_GET_MCI_DEVICE, wSize, cast(LPARAM)szName); }
+
+BOOL capPaletteOpen(HWND hWnd, LPTSTR szName)                       { return cast(BOOL)AVICapSM(hWnd, WM_CAP_PAL_OPEN, 0, cast(LPARAM)szName); }
+BOOL capPaletteSave(HWND hWnd, LPTSTR szName)                       { return cast(BOOL)AVICapSM(hWnd, WM_CAP_PAL_SAVE, 0, cast(LPARAM)szName); }
+BOOL capPalettePaste(HWND hWnd)                                     { return cast(BOOL)AVICapSM(hWnd, WM_CAP_PAL_PASTE, 0, 0); }
+BOOL capPaletteAuto(HWND hWnd, WPARAM iFrames, LPARAM iColors)      { return cast(BOOL)AVICapSM(hWnd, WM_CAP_PAL_AUTOCREATE, iFrames, iColors); }
+BOOL capPaletteManual(HWND hWnd, WPARAM fGrab, LPARAM iColors)      { return cast(BOOL)AVICapSM(hWnd, WM_CAP_PAL_MANUALCREATE, fGrab, iColors); }
+
+/**
+ * structs
+ */
+
+struct CAPDRIVERCAPS {
+    UINT    wDeviceIndex;
+    BOOL    fHasOverlay;
+    BOOL    fHasDlgVideoSource;
+    BOOL    fHasDlgVideoFormat;
+    BOOL    fHasDlgVideoDisplay;
+    BOOL    fCaptureInitialized;
+    BOOL    fDriverSuppliesPalettes;
+    HANDLE  hVideoIn;
+    HANDLE  hVideoOut;
+    HANDLE  hVideoExtIn;
+    HANDLE  hVideoExtOut;
+}
+alias CAPDRIVERCAPS* PCAPDRIVERCAPS, LPCAPDRIVERCAPS;
+
+struct CAPSTATUS {
+    UINT        uiImageWidth;
+    UINT        uiImageHeight;
+    BOOL        fLiveWindow;
+    BOOL        fOverlayWindow;
+    BOOL        fScale;
+    POINT       ptScroll;
+    BOOL        fUsingDefaultPalette;
+    BOOL        fAudioHardware;
+    BOOL        fCapFileExists;
+    DWORD       dwCurrentVideoFrame;
+    DWORD       dwCurrentVideoFramesDropped;
+    DWORD       dwCurrentWaveSamples;
+    DWORD       dwCurrentTimeElapsedMS;
+    HPALETTE    hPalCurrent;
+    BOOL        fCapturingNow;
+    DWORD       dwReturn;
+    UINT        wNumVideoAllocated;
+    UINT        wNumAudioAllocated;
+}
+alias CAPSTATUS* PCAPSTATUS, LPCAPSTATUS;
+
+struct CAPTUREPARMS {
+    DWORD   dwRequestMicroSecPerFrame;
+    BOOL    fMakeUserHitOKToCapture;
+    UINT    wPercentDropForError;
+    BOOL    fYield;
+    DWORD   dwIndexSize;
+    UINT    wChunkGranularity;
+    BOOL    fUsingDOSMemory;
+    UINT    wNumVideoRequested;
+    BOOL    fCaptureAudio;
+    UINT    wNumAudioRequested;
+    UINT    vKeyAbort;
+    BOOL    fAbortLeftMouse;
+    BOOL    fAbortRightMouse;
+    BOOL    fLimitEnabled;
+    UINT    wTimeLimit;
+    BOOL    fMCIControl;
+    BOOL    fStepMCIDevice;
+    DWORD   dwMCIStartTime;
+    DWORD   dwMCIStopTime;
+    BOOL    fStepCaptureAt2x;
+    UINT    wStepCaptureAverageFrames;
+    DWORD   dwAudioBufferSize;
+    BOOL    fDisableWriteCache;
+    UINT    AVStreamMaster;
+}
+alias CAPTUREPARMS* PCAPTUREPARMS, LPCAPTUREPARMS;
+
+enum AVSTREAMMASTER_AUDIO = 0;
+enum AVSTREAMMASTER_NONE  = 1;
+
+struct CAPINFOCHUNK {
+    FOURCC  fccInfoID;
+    LPVOID  lpData;
+    LONG    cbData;
+}
+alias CAPINFOCHUNK* PCAPINFOCHUNK, LPCAPINFOCHUNK;
+
+// Callback Definitions
+
+extern (Windows) {
+    alias LRESULT function(HWND hWnd) CAPYIELDCALLBACK;
+    alias LRESULT function(HWND hWnd, int nID, LPCWSTR lpsz) CAPSTATUSCALLBACKW;
+    alias LRESULT function(HWND hWnd, int nID, LPCWSTR lpsz) CAPERRORCALLBACKW;
+    alias LRESULT function(HWND hWnd, int nID, LPCSTR lpsz) CAPSTATUSCALLBACKA;
+    alias LRESULT function(HWND hWnd, int nID, LPCSTR lpsz) CAPERRORCALLBACKA;
+}
+
+version(Unicode) {
+    alias CAPSTATUSCALLBACKW    CAPSTATUSCALLBACK;
+    alias CAPERRORCALLBACKW     CAPERRORCALLBACK;
+} else { // Unicode
+    alias CAPSTATUSCALLBACKA    CAPSTATUSCALLBACK;
+    alias CAPERRORCALLBACKA     CAPERRORCALLBACK;
+}
+
+extern (Windows) {
+    alias LRESULT function(HWND hWnd, LPVIDEOHDR lpVHdr) CAPVIDEOCALLBACK;
+    alias LRESULT function(HWND hWnd, LPWAVEHDR lpWHdr) CAPWAVECALLBACK;
+    alias LRESULT function(HWND hWnd, int nState) CAPCONTROLCALLBACK;
+}
+
+//  CapControlCallback states
+enum CONTROLCALLBACK_PREROLL   = 1;
+enum CONTROLCALLBACK_CAPTURING = 2;
+
+extern (Windows) {
+    HWND capCreateCaptureWindowA(LPCSTR lpszWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hwndParent, int nID);
+    BOOL capGetDriverDescriptionA(UINT wDriverIndex, LPSTR lpszName, int cbName, LPSTR lpszVer, int cbVer);
+    HWND capCreateCaptureWindowW(LPCWSTR lpszWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hwndParent, int nID);
+    BOOL capGetDriverDescriptionW(UINT wDriverIndex, LPWSTR lpszName, int cbName, LPWSTR lpszVer, int cbVer);
+}
+
+version(Unicode) {
+    alias capCreateCaptureWindowW   capCreateCaptureWindow;
+    alias capGetDriverDescriptionW  capGetDriverDescription;
+} else { // Unicode
+    alias capCreateCaptureWindowA   capCreateCaptureWindow;
+    alias capGetDriverDescriptionA  capGetDriverDescription;
+}
+
+// New Information chunk IDs
+enum infotypeDIGITIZATION_TIME = mmioFOURCC!('I', 'D', 'I', 'T');
+enum infotypeSMPTE_TIME        = mmioFOURCC!('I', 'S', 'M', 'P');
+
+// status and error callbacks
+enum {
+    IDS_CAP_BEGIN                   = 300,
+    IDS_CAP_END                     = 301,
+
+    IDS_CAP_INFO                    = 401,
+    IDS_CAP_OUTOFMEM                = 402,
+    IDS_CAP_FILEEXISTS              = 403,
+    IDS_CAP_ERRORPALOPEN            = 404,
+    IDS_CAP_ERRORPALSAVE            = 405,
+    IDS_CAP_ERRORDIBSAVE            = 406,
+    IDS_CAP_DEFAVIEXT               = 407,
+    IDS_CAP_DEFPALEXT               = 408,
+    IDS_CAP_CANTOPEN                = 409,
+    IDS_CAP_SEQ_MSGSTART            = 410,
+    IDS_CAP_SEQ_MSGSTOP             = 411,
+
+    IDS_CAP_VIDEDITERR              = 412,
+    IDS_CAP_READONLYFILE            = 413,
+    IDS_CAP_WRITEERROR              = 414,
+    IDS_CAP_NODISKSPACE             = 415,
+    IDS_CAP_SETFILESIZE             = 416,
+    IDS_CAP_SAVEASPERCENT           = 417,
+
+    IDS_CAP_DRIVER_ERROR            = 418,
+
+    IDS_CAP_WAVE_OPEN_ERROR         = 419,
+    IDS_CAP_WAVE_ALLOC_ERROR        = 420,
+    IDS_CAP_WAVE_PREPARE_ERROR      = 421,
+    IDS_CAP_WAVE_ADD_ERROR          = 422,
+    IDS_CAP_WAVE_SIZE_ERROR         = 423,
+
+    IDS_CAP_VIDEO_OPEN_ERROR        = 424,
+    IDS_CAP_VIDEO_ALLOC_ERROR       = 425,
+    IDS_CAP_VIDEO_PREPARE_ERROR     = 426,
+    IDS_CAP_VIDEO_ADD_ERROR         = 427,
+    IDS_CAP_VIDEO_SIZE_ERROR        = 428,
+
+    IDS_CAP_FILE_OPEN_ERROR         = 429,
+    IDS_CAP_FILE_WRITE_ERROR        = 430,
+    IDS_CAP_RECORDING_ERROR         = 431,
+    IDS_CAP_RECORDING_ERROR2        = 432,
+    IDS_CAP_AVI_INIT_ERROR          = 433,
+    IDS_CAP_NO_FRAME_CAP_ERROR      = 434,
+    IDS_CAP_NO_PALETTE_WARN         = 435,
+    IDS_CAP_MCI_CONTROL_ERROR       = 436,
+    IDS_CAP_MCI_CANT_STEP_ERROR     = 437,
+    IDS_CAP_NO_AUDIO_CAP_ERROR      = 438,
+    IDS_CAP_AVI_DRAWDIB_ERROR       = 439,
+    IDS_CAP_COMPRESSOR_ERROR        = 440,
+    IDS_CAP_AUDIO_DROP_ERROR        = 441,
+    IDS_CAP_AUDIO_DROP_COMPERROR    = 442,
+
+    IDS_CAP_STAT_LIVE_MODE          = 500,
+    IDS_CAP_STAT_OVERLAY_MODE       = 501,
+    IDS_CAP_STAT_CAP_INIT           = 502,
+    IDS_CAP_STAT_CAP_FINI           = 503,
+    IDS_CAP_STAT_PALETTE_BUILD      = 504,
+    IDS_CAP_STAT_OPTPAL_BUILD       = 505,
+    IDS_CAP_STAT_I_FRAMES           = 506,
+    IDS_CAP_STAT_L_FRAMES           = 507,
+    IDS_CAP_STAT_CAP_L_FRAMES       = 508,
+    IDS_CAP_STAT_CAP_AUDIO          = 509,
+    IDS_CAP_STAT_VIDEOCURRENT       = 510,
+    IDS_CAP_STAT_VIDEOAUDIO         = 511,
+    IDS_CAP_STAT_VIDEOONLY          = 512,
+    IDS_CAP_STAT_FRAMESDROPPED      = 513,
+}
+
+/**
+ * FilePreview dialog.
+ */
+
+extern (Windows) {
+    BOOL GetOpenFileNamePreviewA(LPOPENFILENAMEA lpofn);
+    BOOL GetSaveFileNamePreviewA(LPOPENFILENAMEA lpofn);
+    BOOL GetOpenFileNamePreviewW(LPOPENFILENAMEW lpofn);
+    BOOL GetSaveFileNamePreviewW(LPOPENFILENAMEW lpofn);
+}
+
+version(Unicode) {
+    alias GetOpenFileNamePreviewW   GetOpenFileNamePreview;
+    alias GetSaveFileNamePreviewW   GetSaveFileNamePreview;
+} else { // Unicode
+    alias GetOpenFileNamePreviewA   GetOpenFileNamePreview;
+    alias GetSaveFileNamePreviewA   GetSaveFileNamePreview;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/w32api.d b/libphobos/libdruntime/core/sys/windows/w32api.d
new file mode 100644
index 00000000000..33807c9daa7
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/w32api.d
@@ -0,0 +1,97 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 4.0
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_w32api.d)
+ */
+module core.sys.windows.w32api;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+enum __W32API_VERSION = 3.17;
+enum __W32API_MAJOR_VERSION = 3;
+enum __W32API_MINOR_VERSION = 17;
+
+/*  These version identifiers are used to specify the minimum version of Windows that an
+ *  application will support.
+ *
+ *  Previously the minimum Windows 9x and Windows NT versions could be specified.  However, since
+ *  Windows 9x is no longer supported, either by Microsoft or by DMD, this distinction has been
+ *  removed in order to simplify the bindings.
+ */
+ version (Windows10) {
+    enum uint _WIN32_WINNT = 0x604;
+} else version (Windows8_1) {    // also Windows2012R2
+    enum uint _WIN32_WINNT = 0x603;
+} else version (Windows8) {      // also Windows2012
+    enum uint _WIN32_WINNT = 0x602;
+} else version (Windows7) {      // also Windows2008R2
+    enum uint _WIN32_WINNT = 0x601;
+} else version (WindowsVista) {  // also Windows2008
+    enum uint _WIN32_WINNT = 0x600;
+} else version (Windows2003) {   // also WindowsHomeServer, WindowsXP64
+    enum uint _WIN32_WINNT = 0x502;
+} else version (WindowsXP) {
+    enum uint _WIN32_WINNT = 0x501;
+} else version (Windows2000) {
+    // Current DMD doesn't support any version of Windows older than XP,
+    // but third-party compilers could use this
+    enum uint _WIN32_WINNT = 0x500;
+} else {
+    enum uint _WIN32_WINNT = 0x501;
+}
+
+version (IE10) {
+    enum uint _WIN32_IE = 0xA00;
+} else version (IE9) {
+    enum uint _WIN32_IE = 0x900;
+} else version (IE8) {
+    enum uint _WIN32_IE = 0x800;
+} else version (IE7) {
+    enum uint _WIN32_IE = 0x700;
+} else version (IE602) {
+    enum uint _WIN32_IE = 0x603;
+} else version (IE601) {
+    enum uint _WIN32_IE = 0x601;
+} else version (IE6) {
+    enum uint _WIN32_IE = 0x600;
+} else version (IE56) {
+    enum uint _WIN32_IE = 0x560;
+} else version (IE501) {
+    enum uint _WIN32_IE = 0x501;
+} else version (IE5) {
+    enum uint _WIN32_IE = 0x500;
+} else version (IE401) {
+    enum uint _WIN32_IE = 0x401;
+} else version (IE4) {
+    enum uint _WIN32_IE = 0x400;
+} else version (IE3) {
+    enum uint _WIN32_IE = 0x300;
+} else static if (_WIN32_WINNT >= 0x410) {
+    enum uint _WIN32_IE = 0x400;
+} else {
+    enum uint _WIN32_IE = 0;
+}
+
+debug (WindowsUnitTest) {
+    unittest {
+        printf("Windows NT version: %03x\n", _WIN32_WINNT);
+        printf("IE version:         %03x\n", _WIN32_IE);
+    }
+}
+
+version (Unicode) {
+    enum bool _WIN32_UNICODE = true;
+    package template DECLARE_AW(string name) {
+        mixin("alias " ~ name ~ "W " ~ name ~ ";");
+    }
+} else {
+    enum bool _WIN32_UNICODE = false;
+    package template DECLARE_AW(string name) {
+        mixin("alias " ~ name ~ "A " ~ name ~ ";");
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/windows/winbase.d b/libphobos/libdruntime/core/sys/windows/winbase.d
new file mode 100644
index 00000000000..5e0285d840d
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winbase.d
@@ -0,0 +1,2858 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.10
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winbase.d)
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module core.sys.windows.winbase;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "kernel32");
+
+/**
+Translation Notes:
+The following macros are obsolete, and have no effect.
+
+LockSegment(w), MakeProcInstance(p, i), UnlockResource(h), UnlockSegment(w)
+FreeModule(m), FreeProcInstance(p), GetFreeSpace(w), DefineHandleTable(w)
+SetSwapAreaSize(w), LimitEmsPages(n), Yield()
+
+// These are not required for DMD.
+
+//FIXME:
+// #ifndef UNDER_CE
+    int WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
+#else
+    int WinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
+#endif
+int wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
+
+*/
+
+import core.sys.windows.windef, core.sys.windows.winver;
+private import core.sys.windows.basetyps, core.sys.windows.w32api, core.sys.windows.winnt;
+
+// FIXME:
+//alias void va_list;
+import core.stdc.stdarg : va_list;
+
+
+// COMMPROP structure, used by GetCommProperties()
+// -----------------------------------------------
+
+// Communications provider type
+enum : DWORD {
+    PST_UNSPECIFIED,
+    PST_RS232,
+    PST_PARALLELPORT,
+    PST_RS422,
+    PST_RS423,
+    PST_RS449,
+    PST_MODEM,      // =      6
+    PST_FAX            = 0x0021,
+    PST_SCANNER        = 0x0022,
+    PST_NETWORK_BRIDGE = 0x0100,
+    PST_LAT            = 0x0101,
+    PST_TCPIP_TELNET   = 0x0102,
+    PST_X25            = 0x0103
+}
+
+// Max baud rate
+enum : DWORD {
+    BAUD_075    = 0x00000001,
+    BAUD_110    = 0x00000002,
+    BAUD_134_5  = 0x00000004,
+    BAUD_150    = 0x00000008,
+    BAUD_300    = 0x00000010,
+    BAUD_600    = 0x00000020,
+    BAUD_1200   = 0x00000040,
+    BAUD_1800   = 0x00000080,
+    BAUD_2400   = 0x00000100,
+    BAUD_4800   = 0x00000200,
+    BAUD_7200   = 0x00000400,
+    BAUD_9600   = 0x00000800,
+    BAUD_14400  = 0x00001000,
+    BAUD_19200  = 0x00002000,
+    BAUD_38400  = 0x00004000,
+    BAUD_56K    = 0x00008000,
+    BAUD_128K   = 0x00010000,
+    BAUD_115200 = 0x00020000,
+    BAUD_57600  = 0x00040000,
+    BAUD_USER   = 0x10000000
+}
+
+// Comm capabilities
+enum : DWORD {
+    PCF_DTRDSR        = 0x0001,
+    PCF_RTSCTS        = 0x0002,
+    PCF_RLSD          = 0x0004,
+    PCF_PARITY_CHECK  = 0x0008,
+    PCF_XONXOFF       = 0x0010,
+    PCF_SETXCHAR      = 0x0020,
+    PCF_TOTALTIMEOUTS = 0x0040,
+    PCF_INTTIMEOUTS   = 0x0080,
+    PCF_SPECIALCHARS  = 0x0100,
+    PCF_16BITMODE     = 0x0200
+}
+
+enum  : DWORD {
+    SP_PARITY       = 1,
+    SP_BAUD         = 2,
+    SP_DATABITS     = 4,
+    SP_STOPBITS     = 8,
+    SP_HANDSHAKING  = 16,
+    SP_PARITY_CHECK = 32,
+    SP_RLSD         = 64
+}
+
+enum : DWORD {
+    DATABITS_5   = 1,
+    DATABITS_6   = 2,
+    DATABITS_7   = 4,
+    DATABITS_8   = 8,
+    DATABITS_16  = 16,
+    DATABITS_16X = 32
+}
+
+enum : WORD {
+    STOPBITS_10  = 0x0001,
+    STOPBITS_15  = 0x0002,
+    STOPBITS_20  = 0x0004,
+    PARITY_NONE  = 0x0100,
+    PARITY_ODD   = 0x0200,
+    PARITY_EVEN  = 0x0400,
+    PARITY_MARK  = 0x0800,
+    PARITY_SPACE = 0x1000
+}
+
+// used by dwServiceMask
+enum SP_SERIALCOMM = 1;
+
+struct COMMPROP {
+    WORD  wPacketLength;
+    WORD  wPacketVersion;
+    DWORD dwServiceMask;
+    DWORD dwReserved1;
+    DWORD dwMaxTxQueue;
+    DWORD dwMaxRxQueue;
+    DWORD dwMaxBaud;
+    DWORD dwProvSubType;
+    DWORD dwProvCapabilities;
+    DWORD dwSettableParams;
+    DWORD dwSettableBaud;
+    WORD  wSettableData;
+    WORD  wSettableStopParity;
+    DWORD dwCurrentTxQueue;
+    DWORD dwCurrentRxQueue;
+    DWORD dwProvSpec1;
+    DWORD dwProvSpec2;
+    WCHAR _wcProvChar;
+
+    WCHAR* wcProvChar() return { return &_wcProvChar; }
+}
+alias COMMPROP* LPCOMMPROP;
+
+// ----------
+
+// for DEBUG_EVENT
+enum : DWORD {
+    EXCEPTION_DEBUG_EVENT = 1,
+    CREATE_THREAD_DEBUG_EVENT,
+    CREATE_PROCESS_DEBUG_EVENT,
+    EXIT_THREAD_DEBUG_EVENT,
+    EXIT_PROCESS_DEBUG_EVENT,
+    LOAD_DLL_DEBUG_EVENT,
+    UNLOAD_DLL_DEBUG_EVENT,
+    OUTPUT_DEBUG_STRING_EVENT,
+    RIP_EVENT
+}
+
+enum HFILE HFILE_ERROR = cast(HFILE) (-1);
+
+// for SetFilePointer()
+enum : DWORD {
+    FILE_BEGIN   = 0,
+    FILE_CURRENT = 1,
+    FILE_END     = 2
+}
+enum DWORD INVALID_SET_FILE_POINTER = -1;
+
+
+// for OpenFile()
+deprecated enum : UINT {
+    OF_READ             = 0,
+    OF_WRITE            = 0x0001,
+    OF_READWRITE        = 0x0002,
+    OF_SHARE_COMPAT     = 0,
+    OF_SHARE_EXCLUSIVE  = 0x0010,
+    OF_SHARE_DENY_WRITE = 0x0020,
+    OF_SHARE_DENY_READ  = 0x0030,
+    OF_SHARE_DENY_NONE  = 0x0040,
+    OF_PARSE            = 0x0100,
+    OF_DELETE           = 0x0200,
+    OF_VERIFY           = 0x0400,
+    OF_CANCEL           = 0x0800,
+    OF_CREATE           = 0x1000,
+    OF_PROMPT           = 0x2000,
+    OF_EXIST            = 0x4000,
+    OF_REOPEN           = 0x8000
+}
+
+enum : DWORD {
+    NMPWAIT_NOWAIT           =  1,
+    NMPWAIT_WAIT_FOREVER     = -1,
+    NMPWAIT_USE_DEFAULT_WAIT =  0
+}
+
+// for ClearCommError()
+enum DWORD
+    CE_RXOVER   = 0x0001,
+    CE_OVERRUN  = 0x0002,
+    CE_RXPARITY = 0x0004,
+    CE_FRAME    = 0x0008,
+    CE_BREAK    = 0x0010,
+    CE_TXFULL   = 0x0100,
+    CE_PTO      = 0x0200,
+    CE_IOE      = 0x0400,
+    CE_DNS      = 0x0800,
+    CE_OOP      = 0x1000,
+    CE_MODE     = 0x8000;
+
+// for CopyProgressRoutine callback.
+enum : DWORD {
+    PROGRESS_CONTINUE = 0,
+    PROGRESS_CANCEL   = 1,
+    PROGRESS_STOP     = 2,
+    PROGRESS_QUIET    = 3
+}
+
+enum : DWORD {
+    CALLBACK_CHUNK_FINISHED = 0,
+    CALLBACK_STREAM_SWITCH  = 1
+}
+
+// CopyFileEx()
+enum : DWORD {
+    COPY_FILE_FAIL_IF_EXISTS = 1,
+    COPY_FILE_RESTARTABLE    = 2
+}
+
+enum : DWORD {
+    FILE_MAP_COPY       = 1,
+    FILE_MAP_WRITE      = 2,
+    FILE_MAP_READ       = 4,
+    FILE_MAP_ALL_ACCESS = 0x000F001F
+}
+
+enum : DWORD {
+    MUTEX_ALL_ACCESS       = 0x001f0001,
+    MUTEX_MODIFY_STATE     = 0x00000001,
+    SEMAPHORE_ALL_ACCESS   = 0x001f0003,
+    SEMAPHORE_MODIFY_STATE = 0x00000002,
+    EVENT_ALL_ACCESS       = 0x001f0003,
+    EVENT_MODIFY_STATE     = 0x00000002
+}
+
+// CreateNamedPipe()
+enum : DWORD {
+    PIPE_ACCESS_INBOUND  = 1,
+    PIPE_ACCESS_OUTBOUND = 2,
+    PIPE_ACCESS_DUPLEX   = 3
+}
+
+enum DWORD
+    PIPE_TYPE_BYTE        = 0,
+    PIPE_TYPE_MESSAGE     = 4,
+    PIPE_READMODE_BYTE    = 0,
+    PIPE_READMODE_MESSAGE = 2,
+    PIPE_WAIT             = 0,
+    PIPE_NOWAIT           = 1;
+
+// GetNamedPipeInfo()
+enum DWORD
+    PIPE_CLIENT_END  = 0,
+    PIPE_SERVER_END  = 1;
+
+enum DWORD PIPE_UNLIMITED_INSTANCES = 255;
+
+// dwCreationFlags for CreateProcess() and CreateProcessAsUser()
+enum : DWORD {
+    DEBUG_PROCESS               = 0x00000001,
+    DEBUG_ONLY_THIS_PROCESS     = 0x00000002,
+    CREATE_SUSPENDED            = 0x00000004,
+    DETACHED_PROCESS            = 0x00000008,
+    CREATE_NEW_CONSOLE          = 0x00000010,
+    NORMAL_PRIORITY_CLASS       = 0x00000020,
+    IDLE_PRIORITY_CLASS         = 0x00000040,
+    HIGH_PRIORITY_CLASS         = 0x00000080,
+    REALTIME_PRIORITY_CLASS     = 0x00000100,
+    CREATE_NEW_PROCESS_GROUP    = 0x00000200,
+    CREATE_UNICODE_ENVIRONMENT  = 0x00000400,
+    CREATE_SEPARATE_WOW_VDM     = 0x00000800,
+    CREATE_SHARED_WOW_VDM       = 0x00001000,
+    CREATE_FORCEDOS             = 0x00002000,
+    BELOW_NORMAL_PRIORITY_CLASS = 0x00004000,
+    ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000,
+    CREATE_BREAKAWAY_FROM_JOB   = 0x01000000,
+    CREATE_WITH_USERPROFILE     = 0x02000000,
+    CREATE_DEFAULT_ERROR_MODE   = 0x04000000,
+    CREATE_NO_WINDOW            = 0x08000000,
+    PROFILE_USER                = 0x10000000,
+    PROFILE_KERNEL              = 0x20000000,
+    PROFILE_SERVER              = 0x40000000
+}
+
+enum DWORD CONSOLE_TEXTMODE_BUFFER = 1;
+
+// CreateFile()
+enum : DWORD {
+    CREATE_NEW = 1,
+    CREATE_ALWAYS,
+    OPEN_EXISTING,
+    OPEN_ALWAYS,
+    TRUNCATE_EXISTING
+}
+
+// CreateFile()
+enum DWORD
+    FILE_FLAG_WRITE_THROUGH      = 0x80000000,
+    FILE_FLAG_OVERLAPPED         = 0x40000000,
+    FILE_FLAG_NO_BUFFERING       = 0x20000000,
+    FILE_FLAG_RANDOM_ACCESS      = 0x10000000,
+    FILE_FLAG_SEQUENTIAL_SCAN    = 0x08000000,
+    FILE_FLAG_DELETE_ON_CLOSE    = 0x04000000,
+    FILE_FLAG_BACKUP_SEMANTICS   = 0x02000000,
+    FILE_FLAG_POSIX_SEMANTICS    = 0x01000000,
+    FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000,
+    FILE_FLAG_OPEN_NO_RECALL     = 0x00100000;
+
+static if (_WIN32_WINNT >= 0x500) {
+enum DWORD FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000;
+}
+
+// for CreateFile()
+enum DWORD
+    SECURITY_ANONYMOUS        = SECURITY_IMPERSONATION_LEVEL.SecurityAnonymous<<16,
+    SECURITY_IDENTIFICATION   = SECURITY_IMPERSONATION_LEVEL.SecurityIdentification<<16,
+    SECURITY_IMPERSONATION    = SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation<<16,
+    SECURITY_DELEGATION       = SECURITY_IMPERSONATION_LEVEL.SecurityDelegation<<16,
+    SECURITY_CONTEXT_TRACKING = 0x00040000,
+    SECURITY_EFFECTIVE_ONLY   = 0x00080000,
+    SECURITY_SQOS_PRESENT     = 0x00100000,
+    SECURITY_VALID_SQOS_FLAGS = 0x001F0000;
+
+
+// Thread exit code
+enum DWORD STILL_ACTIVE = 0x103;
+
+/*  ??? The only documentation of this seems to be about Windows CE and to
+ *  state what _doesn't_ support it.
+ */
+enum DWORD FIND_FIRST_EX_CASE_SENSITIVE = 1;
+
+// GetBinaryType()
+enum : DWORD {
+    SCS_32BIT_BINARY = 0,
+    SCS_DOS_BINARY,
+    SCS_WOW_BINARY,
+    SCS_PIF_BINARY,
+    SCS_POSIX_BINARY,
+    SCS_OS216_BINARY
+}
+
+enum size_t
+    MAX_COMPUTERNAME_LENGTH = 15,
+    HW_PROFILE_GUIDLEN      = 39,
+    MAX_PROFILE_LEN         = 80;
+
+// HW_PROFILE_INFO
+enum DWORD
+    DOCKINFO_UNDOCKED      = 1,
+    DOCKINFO_DOCKED        = 2,
+    DOCKINFO_USER_SUPPLIED = 4,
+    DOCKINFO_USER_UNDOCKED = DOCKINFO_USER_SUPPLIED | DOCKINFO_UNDOCKED,
+    DOCKINFO_USER_DOCKED   = DOCKINFO_USER_SUPPLIED | DOCKINFO_DOCKED;
+
+// DriveType(), RealDriveType()
+enum : int {
+    DRIVE_UNKNOWN = 0,
+    DRIVE_NO_ROOT_DIR,
+    DRIVE_REMOVABLE,
+    DRIVE_FIXED,
+    DRIVE_REMOTE,
+    DRIVE_CDROM,
+    DRIVE_RAMDISK
+}
+
+// GetFileType()
+enum : DWORD {
+    FILE_TYPE_UNKNOWN = 0,
+    FILE_TYPE_DISK,
+    FILE_TYPE_CHAR,
+    FILE_TYPE_PIPE,
+    FILE_TYPE_REMOTE = 0x8000
+}
+
+// Get/SetHandleInformation()
+enum DWORD
+    HANDLE_FLAG_INHERIT            = 0x01,
+    HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x02;
+
+enum : DWORD {
+    STD_INPUT_HANDLE  = 0xFFFFFFF6,
+    STD_OUTPUT_HANDLE = 0xFFFFFFF5,
+    STD_ERROR_HANDLE  = 0xFFFFFFF4
+}
+
+enum HANDLE INVALID_HANDLE_VALUE = cast(HANDLE) (-1);
+
+enum : DWORD {
+    GET_TAPE_MEDIA_INFORMATION = 0,
+    GET_TAPE_DRIVE_INFORMATION = 1
+}
+
+enum : DWORD {
+    SET_TAPE_MEDIA_INFORMATION = 0,
+    SET_TAPE_DRIVE_INFORMATION = 1
+}
+
+// SetThreadPriority()/GetThreadPriority()
+enum : int {
+    THREAD_PRIORITY_IDLE          = -15,
+    THREAD_PRIORITY_LOWEST        =  -2,
+    THREAD_PRIORITY_BELOW_NORMAL  =  -1,
+    THREAD_PRIORITY_NORMAL        =   0,
+    THREAD_PRIORITY_ABOVE_NORMAL  =   1,
+    THREAD_PRIORITY_HIGHEST       =   2,
+    THREAD_PRIORITY_TIME_CRITICAL =  15,
+    THREAD_PRIORITY_ERROR_RETURN  = 2147483647
+}
+
+enum : DWORD {
+    TIME_ZONE_ID_UNKNOWN,
+    TIME_ZONE_ID_STANDARD,
+    TIME_ZONE_ID_DAYLIGHT,
+    TIME_ZONE_ID_INVALID = 0xFFFFFFFF
+}
+
+enum DWORD
+    FS_CASE_SENSITIVE         =     1,
+    FS_CASE_IS_PRESERVED      =     2,
+    FS_UNICODE_STORED_ON_DISK =     4,
+    FS_PERSISTENT_ACLS        =     8,
+    FS_FILE_COMPRESSION       =    16,
+    FS_VOL_IS_COMPRESSED      = 32768;
+
+// Flags for GlobalAlloc
+enum UINT
+    GMEM_FIXED       = 0,
+    GMEM_MOVEABLE    = 0x0002,
+    GMEM_ZEROINIT    = 0x0040,
+    GPTR             = 0x0040,
+    GHND             = 0x0042,
+    GMEM_MODIFY      = 0x0080,  // used only for GlobalRealloc
+    GMEM_VALID_FLAGS = 0x7F72;
+
+/+  // Obselete flags (Win16 only)
+    GMEM_NOCOMPACT=16;
+    GMEM_NODISCARD=32;
+    GMEM_DISCARDABLE=256;
+    GMEM_NOT_BANKED=4096;
+    GMEM_LOWER=4096;
+    GMEM_SHARE=8192;
+    GMEM_DDESHARE=8192;
+
+    GMEM_LOCKCOUNT=255;
+
+// for GlobalFlags()
+    GMEM_DISCARDED      = 16384;
+    GMEM_INVALID_HANDLE = 32768;
+
+    GMEM_NOTIFY         = 16384;
++/
+
+enum UINT
+    LMEM_FIXED          = 0,
+    LMEM_MOVEABLE       = 0x0002,
+    LMEM_NONZEROLPTR    = 0,
+    NONZEROLPTR         = 0,
+    LMEM_NONZEROLHND    = 0x0002,
+    NONZEROLHND         = 0x0002,
+    LMEM_DISCARDABLE    = 0x0F00,
+    LMEM_NOCOMPACT      = 0x0010,
+    LMEM_NODISCARD      = 0x0020,
+    LMEM_ZEROINIT       = 0x0040,
+    LPTR                = 0x0040,
+    LHND                = 0x0042,
+    LMEM_MODIFY         = 0x0080,
+    LMEM_LOCKCOUNT      = 0x00FF,
+    LMEM_DISCARDED      = 0x4000,
+    LMEM_INVALID_HANDLE = 0x8000;
+
+
+
+// used in EXCEPTION_RECORD
+enum : DWORD {
+    STATUS_WAIT_0                      = 0,
+    STATUS_ABANDONED_WAIT_0            = 0x00000080,
+    STATUS_USER_APC                    = 0x000000C0,
+    STATUS_TIMEOUT                     = 0x00000102,
+    STATUS_PENDING                     = 0x00000103,
+
+    STATUS_SEGMENT_NOTIFICATION        = 0x40000005,
+    STATUS_GUARD_PAGE_VIOLATION        = 0x80000001,
+    STATUS_DATATYPE_MISALIGNMENT       = 0x80000002,
+    STATUS_BREAKPOINT                  = 0x80000003,
+    STATUS_SINGLE_STEP                 = 0x80000004,
+
+    STATUS_ACCESS_VIOLATION            = 0xC0000005,
+    STATUS_IN_PAGE_ERROR               = 0xC0000006,
+    STATUS_INVALID_HANDLE              = 0xC0000008,
+
+    STATUS_NO_MEMORY                   = 0xC0000017,
+    STATUS_ILLEGAL_INSTRUCTION         = 0xC000001D,
+    STATUS_NONCONTINUABLE_EXCEPTION    = 0xC0000025,
+    STATUS_INVALID_DISPOSITION         = 0xC0000026,
+    STATUS_ARRAY_BOUNDS_EXCEEDED       = 0xC000008C,
+    STATUS_FLOAT_DENORMAL_OPERAND      = 0xC000008D,
+    STATUS_FLOAT_DIVIDE_BY_ZERO        = 0xC000008E,
+    STATUS_FLOAT_INEXACT_RESULT        = 0xC000008F,
+    STATUS_FLOAT_INVALID_OPERATION     = 0xC0000090,
+    STATUS_FLOAT_OVERFLOW              = 0xC0000091,
+    STATUS_FLOAT_STACK_CHECK           = 0xC0000092,
+    STATUS_FLOAT_UNDERFLOW             = 0xC0000093,
+    STATUS_INTEGER_DIVIDE_BY_ZERO      = 0xC0000094,
+    STATUS_INTEGER_OVERFLOW            = 0xC0000095,
+    STATUS_PRIVILEGED_INSTRUCTION      = 0xC0000096,
+    STATUS_STACK_OVERFLOW              = 0xC00000FD,
+    STATUS_CONTROL_C_EXIT              = 0xC000013A,
+    STATUS_DLL_INIT_FAILED             = 0xC0000142,
+    STATUS_DLL_INIT_FAILED_LOGOFF      = 0xC000026B,
+
+    CONTROL_C_EXIT                     = STATUS_CONTROL_C_EXIT,
+
+    EXCEPTION_ACCESS_VIOLATION         = STATUS_ACCESS_VIOLATION,
+    EXCEPTION_DATATYPE_MISALIGNMENT    = STATUS_DATATYPE_MISALIGNMENT,
+    EXCEPTION_BREAKPOINT               = STATUS_BREAKPOINT,
+    EXCEPTION_SINGLE_STEP              = STATUS_SINGLE_STEP,
+    EXCEPTION_ARRAY_BOUNDS_EXCEEDED    = STATUS_ARRAY_BOUNDS_EXCEEDED,
+    EXCEPTION_FLT_DENORMAL_OPERAND     = STATUS_FLOAT_DENORMAL_OPERAND,
+    EXCEPTION_FLT_DIVIDE_BY_ZERO       = STATUS_FLOAT_DIVIDE_BY_ZERO,
+    EXCEPTION_FLT_INEXACT_RESULT       = STATUS_FLOAT_INEXACT_RESULT,
+    EXCEPTION_FLT_INVALID_OPERATION    = STATUS_FLOAT_INVALID_OPERATION,
+    EXCEPTION_FLT_OVERFLOW             = STATUS_FLOAT_OVERFLOW,
+    EXCEPTION_FLT_STACK_CHECK          = STATUS_FLOAT_STACK_CHECK,
+    EXCEPTION_FLT_UNDERFLOW            = STATUS_FLOAT_UNDERFLOW,
+    EXCEPTION_INT_DIVIDE_BY_ZERO       = STATUS_INTEGER_DIVIDE_BY_ZERO,
+    EXCEPTION_INT_OVERFLOW             = STATUS_INTEGER_OVERFLOW,
+    EXCEPTION_PRIV_INSTRUCTION         = STATUS_PRIVILEGED_INSTRUCTION,
+    EXCEPTION_IN_PAGE_ERROR            = STATUS_IN_PAGE_ERROR,
+    EXCEPTION_ILLEGAL_INSTRUCTION      = STATUS_ILLEGAL_INSTRUCTION,
+    EXCEPTION_NONCONTINUABLE_EXCEPTION = STATUS_NONCONTINUABLE_EXCEPTION,
+    EXCEPTION_STACK_OVERFLOW           = STATUS_STACK_OVERFLOW,
+    EXCEPTION_INVALID_DISPOSITION      = STATUS_INVALID_DISPOSITION,
+    EXCEPTION_GUARD_PAGE               = STATUS_GUARD_PAGE_VIOLATION,
+    EXCEPTION_INVALID_HANDLE           = STATUS_INVALID_HANDLE
+}
+
+// for PROCESS_HEAP_ENTRY
+enum WORD
+    PROCESS_HEAP_REGION            =  1,
+    PROCESS_HEAP_UNCOMMITTED_RANGE =  2,
+    PROCESS_HEAP_ENTRY_BUSY        =  4,
+    PROCESS_HEAP_ENTRY_MOVEABLE    = 16,
+    PROCESS_HEAP_ENTRY_DDESHARE    = 32;
+
+// for LoadLibraryEx()
+enum DWORD
+    DONT_RESOLVE_DLL_REFERENCES   = 0x01, // not for WinME and earlier
+    LOAD_LIBRARY_AS_DATAFILE      = 0x02,
+    LOAD_WITH_ALTERED_SEARCH_PATH = 0x08,
+    LOAD_IGNORE_CODE_AUTHZ_LEVEL  = 0x10; // only for XP and later
+
+// for LockFile()
+enum DWORD
+    LOCKFILE_FAIL_IMMEDIATELY = 1,
+    LOCKFILE_EXCLUSIVE_LOCK   = 2;
+
+enum MAXIMUM_WAIT_OBJECTS  = 64;
+enum MAXIMUM_SUSPEND_COUNT = 0x7F;
+
+enum WAIT_OBJECT_0    = 0;
+enum WAIT_ABANDONED_0 = 128;
+
+//const WAIT_TIMEOUT=258;  // also in winerror.h
+
+enum : DWORD {
+    WAIT_IO_COMPLETION = 0x000000C0,
+    WAIT_ABANDONED     = 0x00000080,
+    WAIT_FAILED        = 0xFFFFFFFF
+}
+
+// PurgeComm()
+enum DWORD
+    PURGE_TXABORT = 1,
+    PURGE_RXABORT = 2,
+    PURGE_TXCLEAR = 4,
+    PURGE_RXCLEAR = 8;
+
+// ReadEventLog()
+enum DWORD
+    EVENTLOG_SEQUENTIAL_READ = 1,
+    EVENTLOG_SEEK_READ       = 2,
+    EVENTLOG_FORWARDS_READ   = 4,
+    EVENTLOG_BACKWARDS_READ  = 8;
+
+// ReportEvent()
+enum : WORD {
+    EVENTLOG_SUCCESS          = 0,
+    EVENTLOG_ERROR_TYPE       = 1,
+    EVENTLOG_WARNING_TYPE     = 2,
+    EVENTLOG_INFORMATION_TYPE = 4,
+    EVENTLOG_AUDIT_SUCCESS    = 8,
+    EVENTLOG_AUDIT_FAILURE    = 16
+}
+
+// FormatMessage()
+enum DWORD
+    FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x0100,
+    FORMAT_MESSAGE_IGNORE_INSERTS  = 0x0200,
+    FORMAT_MESSAGE_FROM_STRING     = 0x0400,
+    FORMAT_MESSAGE_FROM_HMODULE    = 0x0800,
+    FORMAT_MESSAGE_FROM_SYSTEM     = 0x1000,
+    FORMAT_MESSAGE_ARGUMENT_ARRAY  = 0x2000;
+
+enum DWORD FORMAT_MESSAGE_MAX_WIDTH_MASK = 255;
+
+// also in ddk/ntapi.h
+// To restore default error mode, call SetErrorMode(0)
+enum {
+    SEM_FAILCRITICALERRORS     = 0x0001,
+    SEM_NOGPFAULTERRORBOX      = 0x0002,
+    SEM_NOALIGNMENTFAULTEXCEPT = 0x0004,
+    SEM_NOOPENFILEERRORBOX     = 0x8000
+}
+// end ntapi.h
+
+enum {
+    SLE_ERROR = 1,
+    SLE_MINORERROR,
+    SLE_WARNING
+}
+
+enum SHUTDOWN_NORETRY = 1;
+
+// Return type for exception filters.
+enum : LONG {
+    EXCEPTION_EXECUTE_HANDLER    =  1,
+    EXCEPTION_CONTINUE_EXECUTION = -1,
+    EXCEPTION_CONTINUE_SEARCH    =  0
+}
+
+enum  : ATOM {
+    MAXINTATOM   = 0xC000,
+    INVALID_ATOM = 0
+}
+
+enum IGNORE   = 0;
+enum INFINITE = 0xFFFFFFFF;
+
+// EscapeCommFunction()
+enum {
+    SETXOFF    = 1,
+    SETXON,
+    SETRTS,
+    CLRRTS,
+    SETDTR,
+    CLRDTR, // = 6
+    SETBREAK   = 8,
+    CLRBREAK   = 9
+}
+
+
+// for SetCommMask()
+enum DWORD
+    EV_RXCHAR   = 0x0001,
+    EV_RXFLAG   = 0x0002,
+    EV_TXEMPTY  = 0x0004,
+    EV_CTS      = 0x0008,
+    EV_DSR      = 0x0010,
+    EV_RLSD     = 0x0020,
+    EV_BREAK    = 0x0040,
+    EV_ERR      = 0x0080,
+    EV_RING     = 0x0100,
+    EV_PERR     = 0x0200,
+    EV_RX80FULL = 0x0400,
+    EV_EVENT1   = 0x0800,
+    EV_EVENT2   = 0x1000;
+
+// GetCommModemStatus()
+enum DWORD
+    MS_CTS_ON  = 0x0010,
+    MS_DSR_ON  = 0x0020,
+    MS_RING_ON = 0x0040,
+    MS_RLSD_ON = 0x0080;
+
+
+// DCB
+enum : BYTE {
+    NOPARITY = 0,
+    ODDPARITY,
+    EVENPARITY,
+    MARKPARITY,
+    SPACEPARITY
+}
+// DCB
+enum : BYTE {
+    ONESTOPBIT = 0,
+    ONE5STOPBITS,
+    TWOSTOPBITS
+}
+// DCB
+enum : DWORD {
+    CBR_110    =    110,
+    CBR_300    =    300,
+    CBR_600    =    600,
+    CBR_1200   =   1200,
+    CBR_2400   =   2400,
+    CBR_4800   =   4800,
+    CBR_9600   =   9600,
+    CBR_14400  =  14400,
+    CBR_19200  =  19200,
+    CBR_38400  =  38400,
+    CBR_56000  =  56000,
+    CBR_57600  =  57600,
+    CBR_115200 = 115200,
+    CBR_128000 = 128000,
+    CBR_256000 = 256000
+}
+// DCB, 2-bit bitfield
+enum {
+    DTR_CONTROL_DISABLE = 0,
+    DTR_CONTROL_ENABLE,
+    DTR_CONTROL_HANDSHAKE
+}
+
+// DCB, 2-bit bitfield
+enum {
+    RTS_CONTROL_DISABLE = 0,
+    RTS_CONTROL_ENABLE,
+    RTS_CONTROL_HANDSHAKE,
+    RTS_CONTROL_TOGGLE,
+}
+
+// WIN32_STREAM_ID
+enum : DWORD {
+    BACKUP_INVALID = 0,
+    BACKUP_DATA,
+    BACKUP_EA_DATA,
+    BACKUP_SECURITY_DATA,
+    BACKUP_ALTERNATE_DATA,
+    BACKUP_LINK,
+    BACKUP_PROPERTY_DATA,
+    BACKUP_OBJECT_ID,
+    BACKUP_REPARSE_DATA,
+    BACKUP_SPARSE_BLOCK
+}
+
+// WIN32_STREAM_ID
+enum : DWORD {
+    STREAM_NORMAL_ATTRIBUTE    = 0,
+    STREAM_MODIFIED_WHEN_READ  = 1,
+    STREAM_CONTAINS_SECURITY   = 2,
+    STREAM_CONTAINS_PROPERTIES = 4
+}
+
+// STARTUPINFO
+enum DWORD
+    STARTF_USESHOWWINDOW    = 0x0001,
+    STARTF_USESIZE          = 0x0002,
+    STARTF_USEPOSITION      = 0x0004,
+    STARTF_USECOUNTCHARS    = 0x0008,
+    STARTF_USEFILLATTRIBUTE = 0x0010,
+    STARTF_RUNFULLSCREEN    = 0x0020,
+    STARTF_FORCEONFEEDBACK  = 0x0040,
+    STARTF_FORCEOFFFEEDBACK = 0x0080,
+    STARTF_USESTDHANDLES    = 0x0100,
+    STARTF_USEHOTKEY        = 0x0200;
+
+// ???
+enum {
+    TC_NORMAL  = 0,
+    TC_HARDERR = 1,
+    TC_GP_TRAP = 2,
+    TC_SIGNAL  = 3
+}
+
+/+ These seem to be Windows CE-specific
+enum {
+    AC_LINE_OFFLINE      = 0,
+    AC_LINE_ONLINE       = 1,
+    AC_LINE_BACKUP_POWER = 2,
+    AC_LINE_UNKNOWN      = 255
+}
+
+enum {
+    BATTERY_FLAG_HIGH          = 1,
+    BATTERY_FLAG_LOW           = 2,
+    BATTERY_FLAG_CRITICAL      = 4,
+    BATTERY_FLAG_CHARGING      = 8,
+    BATTERY_FLAG_NO_BATTERY    = 128,
+    BATTERY_FLAG_UNKNOWN       = 255,
+    BATTERY_PERCENTAGE_UNKNOWN = 255,
+    BATTERY_LIFE_UNKNOWN       = 0xFFFFFFFF
+}
++/
+
+// ???
+enum HINSTANCE_ERROR = 32;
+
+// returned from GetFileSize()
+enum DWORD INVALID_FILE_SIZE = 0xFFFFFFFF;
+
+enum DWORD TLS_OUT_OF_INDEXES = 0xFFFFFFFF;
+
+// GetWriteWatch()
+enum DWORD WRITE_WATCH_FLAG_RESET = 1;
+
+// for LogonUser()
+enum : DWORD {
+    LOGON32_LOGON_INTERACTIVE = 2,
+    LOGON32_LOGON_NETWORK     = 3,
+    LOGON32_LOGON_BATCH       = 4,
+    LOGON32_LOGON_SERVICE     = 5,
+    LOGON32_LOGON_UNLOCK      = 7
+}
+
+// for LogonUser()
+enum : DWORD {
+    LOGON32_PROVIDER_DEFAULT,
+    LOGON32_PROVIDER_WINNT35,
+    LOGON32_PROVIDER_WINNT40,
+    LOGON32_PROVIDER_WINNT50
+}
+
+// for MoveFileEx()
+enum DWORD
+    MOVEFILE_REPLACE_EXISTING   = 1,
+    MOVEFILE_COPY_ALLOWED       = 2,
+    MOVEFILE_DELAY_UNTIL_REBOOT = 4,
+    MOVEFILE_WRITE_THROUGH      = 8;
+
+// DefineDosDevice()
+enum DWORD
+    DDD_RAW_TARGET_PATH       = 1,
+    DDD_REMOVE_DEFINITION     = 2,
+    DDD_EXACT_MATCH_ON_REMOVE = 4;
+
+static if (_WIN32_WINNT >= 0x500) {
+    enum : DWORD {
+        LOGON32_LOGON_NETWORK_CLEARTEXT = 8,
+        LOGON32_LOGON_NEW_CREDENTIALS   = 9
+    }
+
+    // ReplaceFile()
+enum DWORD
+        REPLACEFILE_WRITE_THROUGH       = 1,
+        REPLACEFILE_IGNORE_MERGE_ERRORS = 2;
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+enum DWORD
+        GET_MODULE_HANDLE_EX_FLAG_PIN                = 1,
+        GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 2,
+        GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS       = 4;
+
+    // for ACTCTX
+enum DWORD
+        ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID = 0x01,
+        ACTCTX_FLAG_LANGID_VALID                 = 0x02,
+        ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID     = 0x04,
+        ACTCTX_FLAG_RESOURCE_NAME_VALID          = 0x08,
+        ACTCTX_FLAG_SET_PROCESS_DEFAULT          = 0x10,
+        ACTCTX_FLAG_APPLICATION_NAME_VALID       = 0x20,
+        ACTCTX_FLAG_HMODULE_VALID                = 0x80;
+
+    // DeactivateActCtx()
+enum DWORD DEACTIVATE_ACTCTX_FLAG_FORCE_EARLY_DEACTIVATION = 1;
+    // FindActCtxSectionString()
+enum DWORD FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX          = 1;
+    // QueryActCtxW()
+enum DWORD
+        QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX             = 0x04,
+        QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE             = 0x08,
+        QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS             = 0x10;
+
+    enum {
+        LOGON_WITH_PROFILE        = 1,
+        LOGON_NETCREDENTIALS_ONLY
+    }
+}
+
+// ----
+
+struct FILETIME {
+    DWORD dwLowDateTime;
+    DWORD dwHighDateTime;
+}
+alias FILETIME* PFILETIME, LPFILETIME;
+
+struct BY_HANDLE_FILE_INFORMATION {
+    DWORD    dwFileAttributes;
+    FILETIME ftCreationTime;
+    FILETIME ftLastAccessTime;
+    FILETIME ftLastWriteTime;
+    DWORD    dwVolumeSerialNumber;
+    DWORD    nFileSizeHigh;
+    DWORD    nFileSizeLow;
+    DWORD    nNumberOfLinks;
+    DWORD    nFileIndexHigh;
+    DWORD    nFileIndexLow;
+}
+alias BY_HANDLE_FILE_INFORMATION* LPBY_HANDLE_FILE_INFORMATION;
+
+struct DCB {
+    DWORD DCBlength = DCB.sizeof;
+    DWORD BaudRate;
+/+
+    DWORD fBinary:1;              // Binary Mode (skip EOF check)
+    DWORD fParity:1;              // Enable parity checking
+    DWORD fOutxCtsFlow:1;         // CTS handshaking on output
+    DWORD fOutxDsrFlow:1;         // DSR handshaking on output
+    DWORD fDtrControl:2;          // DTR Flow control
+    DWORD fDsrSensitivity:1;      // DSR Sensitivity
+    DWORD fTXContinueOnXoff:1;    // Continue TX when Xoff sent
+    DWORD fOutX:1;                // Enable output X-ON/X-OFF
+    DWORD fInX:1;                 // Enable input X-ON/X-OFF
+    DWORD fErrorChar:1;           // Enable Err Replacement
+    DWORD fNull:1;                // Enable Null stripping
+    DWORD fRtsControl:2;          // Rts Flow control
+    DWORD fAbortOnError:1;        // Abort all reads and writes on Error
+    DWORD fDummy2:17;             // Reserved
++/
+    uint _bf;
+    bool fBinary(bool f)           { _bf = (_bf & ~0x0001) | f; return f; }
+    bool fParity(bool f)           { _bf = (_bf & ~0x0002) | (f<<1); return f; }
+    bool fOutxCtsFlow(bool f)      { _bf = (_bf & ~0x0004) | (f<<2); return f; }
+    bool fOutxDsrFlow(bool f)      { _bf = (_bf & ~0x0008) | (f<<3); return f; }
+    byte fDtrControl(byte x)       { _bf = (_bf & ~0x0030) | (x<<4); return cast(byte)(x & 3); }
+    bool fDsrSensitivity(bool f)   { _bf = (_bf & ~0x0040) | (f<<6); return f; }
+    bool fTXContinueOnXoff(bool f) { _bf = (_bf & ~0x0080) | (f<<7); return f; }
+    bool fOutX(bool f)             { _bf = (_bf & ~0x0100) | (f<<8); return f; }
+    bool fInX(bool f)              { _bf = (_bf & ~0x0200) | (f<<9); return f; }
+    bool fErrorChar(bool f)        { _bf = (_bf & ~0x0400) | (f<<10); return f; }
+    bool fNull(bool f)             { _bf = (_bf & ~0x0800) | (f<<11); return f; }
+    byte fRtsControl(byte x)       { _bf = (_bf & ~0x3000) | (x<<12); return cast(byte)(x & 3); }
+    bool fAbortOnError(bool f)     { _bf = (_bf & ~0x4000) | (f<<14); return f; }
+
+    bool fBinary()           { return cast(bool) (_bf & 1); }
+    bool fParity()           { return cast(bool) (_bf & 2); }
+    bool fOutxCtsFlow()      { return cast(bool) (_bf & 4); }
+    bool fOutxDsrFlow()      { return cast(bool) (_bf & 8); }
+    byte fDtrControl()       { return cast(byte) ((_bf & (32+16))>>4); }
+    bool fDsrSensitivity()   { return cast(bool) (_bf & 64); }
+    bool fTXContinueOnXoff() { return cast(bool) (_bf & 128); }
+    bool fOutX()             { return cast(bool) (_bf & 256); }
+    bool fInX()              { return cast(bool) (_bf & 512); }
+    bool fErrorChar()        { return cast(bool) (_bf & 1024); }
+    bool fNull()             { return cast(bool) (_bf & 2048); }
+    byte fRtsControl()       { return cast(byte) ((_bf & (4096+8192))>>12); }
+    bool fAbortOnError()     { return cast(bool) (_bf & 16384); }
+
+    WORD wReserved;
+    WORD XonLim;
+    WORD XoffLim;
+    BYTE ByteSize;
+    BYTE Parity;
+    BYTE StopBits;
+    char XonChar;
+    char XoffChar;
+    char ErrorChar;
+    char EofChar;
+    char EvtChar;
+    WORD wReserved1;
+}
+alias DCB* LPDCB;
+
+struct COMMCONFIG {
+    DWORD dwSize = COMMCONFIG.sizeof;
+    WORD  wVersion;
+    WORD  wReserved;
+    DCB   dcb;
+    DWORD dwProviderSubType;
+    DWORD dwProviderOffset;
+    DWORD dwProviderSize;
+    WCHAR _wcProviderData;
+
+    WCHAR* wcProviderData() return { return &_wcProviderData; }
+}
+alias COMMCONFIG* LPCOMMCONFIG;
+
+struct COMMTIMEOUTS {
+    DWORD ReadIntervalTimeout;
+    DWORD ReadTotalTimeoutMultiplier;
+    DWORD ReadTotalTimeoutConstant;
+    DWORD WriteTotalTimeoutMultiplier;
+    DWORD WriteTotalTimeoutConstant;
+}
+alias COMMTIMEOUTS* LPCOMMTIMEOUTS;
+
+struct COMSTAT {
+/+
+    DWORD fCtsHold:1;
+    DWORD fDsrHold:1;
+    DWORD fRlsdHold:1;
+    DWORD fXoffHold:1;
+    DWORD fXoffSent:1;
+    DWORD fEof:1;
+    DWORD fTxim:1;
+    DWORD fReserved:25;
++/
+    DWORD _bf;
+    bool fCtsHold(bool f)  { _bf = (_bf & ~1) | f; return f; }
+    bool fDsrHold(bool f)  { _bf = (_bf & ~2) | (f<<1); return f; }
+    bool fRlsdHold(bool f) { _bf = (_bf & ~4) | (f<<2); return f; }
+    bool fXoffHold(bool f) { _bf = (_bf & ~8) | (f<<3); return f; }
+    bool fXoffSent(bool f) { _bf = (_bf & ~16) | (f<<4); return f; }
+    bool fEof(bool f)      { _bf = (_bf & ~32) | (f<<5); return f; }
+    bool fTxim(bool f)     { _bf = (_bf & ~64) | (f<<6); return f; }
+
+    bool fCtsHold()  { return cast(bool) (_bf & 1); }
+    bool fDsrHold()  { return cast(bool) (_bf & 2); }
+    bool fRlsdHold() { return cast(bool) (_bf & 4); }
+    bool fXoffHold() { return cast(bool) (_bf & 8); }
+    bool fXoffSent() { return cast(bool) (_bf & 16); }
+    bool fEof()      { return cast(bool) (_bf & 32); }
+    bool fTxim()     { return cast(bool) (_bf & 64); }
+
+    DWORD cbInQue;
+    DWORD cbOutQue;
+}
+alias COMSTAT* LPCOMSTAT;
+
+struct CREATE_PROCESS_DEBUG_INFO {
+    HANDLE hFile;
+    HANDLE hProcess;
+    HANDLE hThread;
+    LPVOID lpBaseOfImage;
+    DWORD  dwDebugInfoFileOffset;
+    DWORD  nDebugInfoSize;
+    LPVOID lpThreadLocalBase;
+    LPTHREAD_START_ROUTINE lpStartAddress;
+    LPVOID lpImageName;
+    WORD   fUnicode;
+}
+alias CREATE_PROCESS_DEBUG_INFO* LPCREATE_PROCESS_DEBUG_INFO;
+
+struct CREATE_THREAD_DEBUG_INFO {
+    HANDLE hThread;
+    LPVOID lpThreadLocalBase;
+    LPTHREAD_START_ROUTINE lpStartAddress;
+}
+alias CREATE_THREAD_DEBUG_INFO* LPCREATE_THREAD_DEBUG_INFO;
+
+struct EXCEPTION_DEBUG_INFO {
+    EXCEPTION_RECORD ExceptionRecord;
+    DWORD            dwFirstChance;
+}
+alias EXCEPTION_DEBUG_INFO* LPEXCEPTION_DEBUG_INFO;
+
+struct EXIT_THREAD_DEBUG_INFO {
+    DWORD dwExitCode;
+}
+alias EXIT_THREAD_DEBUG_INFO* LPEXIT_THREAD_DEBUG_INFO;
+
+struct EXIT_PROCESS_DEBUG_INFO {
+    DWORD dwExitCode;
+}
+alias EXIT_PROCESS_DEBUG_INFO* LPEXIT_PROCESS_DEBUG_INFO;
+
+struct LOAD_DLL_DEBUG_INFO {
+    HANDLE hFile;
+    LPVOID lpBaseOfDll;
+    DWORD  dwDebugInfoFileOffset;
+    DWORD  nDebugInfoSize;
+    LPVOID lpImageName;
+    WORD   fUnicode;
+}
+alias LOAD_DLL_DEBUG_INFO* LPLOAD_DLL_DEBUG_INFO;
+
+struct UNLOAD_DLL_DEBUG_INFO {
+    LPVOID lpBaseOfDll;
+}
+alias UNLOAD_DLL_DEBUG_INFO* LPUNLOAD_DLL_DEBUG_INFO;
+
+struct OUTPUT_DEBUG_STRING_INFO {
+    LPSTR lpDebugStringData;
+    WORD  fUnicode;
+    WORD  nDebugStringLength;
+}
+alias OUTPUT_DEBUG_STRING_INFO* LPOUTPUT_DEBUG_STRING_INFO;
+
+struct RIP_INFO {
+    DWORD dwError;
+    DWORD dwType;
+}
+alias RIP_INFO* LPRIP_INFO;
+
+struct DEBUG_EVENT {
+    DWORD dwDebugEventCode;
+    DWORD dwProcessId;
+    DWORD dwThreadId;
+    union {
+        EXCEPTION_DEBUG_INFO      Exception;
+        CREATE_THREAD_DEBUG_INFO  CreateThread;
+        CREATE_PROCESS_DEBUG_INFO CreateProcessInfo;
+        EXIT_THREAD_DEBUG_INFO    ExitThread;
+        EXIT_PROCESS_DEBUG_INFO   ExitProcess;
+        LOAD_DLL_DEBUG_INFO       LoadDll;
+        UNLOAD_DLL_DEBUG_INFO     UnloadDll;
+        OUTPUT_DEBUG_STRING_INFO  DebugString;
+        RIP_INFO                  RipInfo;
+    }
+}
+alias DEBUG_EVENT* LPDEBUG_EVENT;
+
+struct OVERLAPPED {
+    ULONG_PTR Internal;
+    ULONG_PTR InternalHigh;
+    union {
+        struct {
+            DWORD     Offset;
+            DWORD     OffsetHigh;
+        }
+        PVOID     Pointer;
+    }
+    HANDLE    hEvent;
+}
+alias OVERLAPPED* POVERLAPPED, LPOVERLAPPED;
+
+struct STARTUPINFOA {
+    DWORD  cb = STARTUPINFOA.sizeof;
+    LPSTR  lpReserved;
+    LPSTR  lpDesktop;
+    LPSTR  lpTitle;
+    DWORD  dwX;
+    DWORD  dwY;
+    DWORD  dwXSize;
+    DWORD  dwYSize;
+    DWORD  dwXCountChars;
+    DWORD  dwYCountChars;
+    DWORD  dwFillAttribute;
+    DWORD  dwFlags;
+    WORD   wShowWindow;
+    WORD   cbReserved2;
+    PBYTE  lpReserved2;
+    HANDLE hStdInput;
+    HANDLE hStdOutput;
+    HANDLE hStdError;
+}
+alias STARTUPINFOA* LPSTARTUPINFOA;
+
+struct STARTUPINFOW {
+    DWORD  cb = STARTUPINFOW.sizeof;
+    LPWSTR lpReserved;
+    LPWSTR lpDesktop;
+    LPWSTR lpTitle;
+    DWORD  dwX;
+    DWORD  dwY;
+    DWORD  dwXSize;
+    DWORD  dwYSize;
+    DWORD  dwXCountChars;
+    DWORD  dwYCountChars;
+    DWORD  dwFillAttribute;
+    DWORD  dwFlags;
+    WORD   wShowWindow;
+    WORD   cbReserved2;
+    PBYTE  lpReserved2;
+    HANDLE hStdInput;
+    HANDLE hStdOutput;
+    HANDLE hStdError;
+}
+alias STARTUPINFOW STARTUPINFO_W;
+alias STARTUPINFOW* LPSTARTUPINFOW, LPSTARTUPINFO_W;
+
+struct PROCESS_INFORMATION {
+    HANDLE hProcess;
+    HANDLE hThread;
+    DWORD  dwProcessId;
+    DWORD  dwThreadId;
+}
+alias PROCESS_INFORMATION* PPROCESS_INFORMATION, LPPROCESS_INFORMATION;
+
+/*
+struct CRITICAL_SECTION_DEBUG {
+    WORD              Type;
+    WORD              CreatorBackTraceIndex;
+    CRITICAL_SECTION* CriticalSection;
+    LIST_ENTRY        ProcessLocksList;
+    DWORD             EntryCount;
+    DWORD             ContentionCount;
+    DWORD[2]          Spare;
+}
+alias CRITICAL_SECTION_DEBUG* PCRITICAL_SECTION_DEBUG;
+
+struct CRITICAL_SECTION {
+    PCRITICAL_SECTION_DEBUG DebugInfo;
+    LONG   LockCount;
+    LONG   RecursionCount;
+    HANDLE OwningThread;
+    HANDLE LockSemaphore;
+    DWORD  SpinCount;
+}
+alias CRITICAL_SECTION* PCRITICAL_SECTION, LPCRITICAL_SECTION;
+*/
+
+alias CRITICAL_SECTION_DEBUG = RTL_CRITICAL_SECTION_DEBUG;
+alias CRITICAL_SECTION_DEBUG* PCRITICAL_SECTION_DEBUG;
+
+alias CRITICAL_SECTION = RTL_CRITICAL_SECTION;
+alias CRITICAL_SECTION* PCRITICAL_SECTION, LPCRITICAL_SECTION;
+
+struct SYSTEMTIME {
+    WORD wYear;
+    WORD wMonth;
+    WORD wDayOfWeek;
+    WORD wDay;
+    WORD wHour;
+    WORD wMinute;
+    WORD wSecond;
+    WORD wMilliseconds;
+}
+alias SYSTEMTIME* LPSYSTEMTIME;
+
+struct WIN32_FILE_ATTRIBUTE_DATA {
+    DWORD    dwFileAttributes;
+    FILETIME ftCreationTime;
+    FILETIME ftLastAccessTime;
+    FILETIME ftLastWriteTime;
+    DWORD    nFileSizeHigh;
+    DWORD    nFileSizeLow;
+}
+alias WIN32_FILE_ATTRIBUTE_DATA* LPWIN32_FILE_ATTRIBUTE_DATA;
+
+struct WIN32_FIND_DATAA {
+    DWORD          dwFileAttributes;
+    FILETIME       ftCreationTime;
+    FILETIME       ftLastAccessTime;
+    FILETIME       ftLastWriteTime;
+    DWORD          nFileSizeHigh;
+    DWORD          nFileSizeLow;
+// #ifdef _WIN32_WCE
+//  DWORD dwOID;
+// #else
+    DWORD          dwReserved0;
+    DWORD          dwReserved1;
+// #endif
+    CHAR[MAX_PATH] cFileName;
+// #ifndef _WIN32_WCE
+    CHAR[14]       cAlternateFileName;
+// #endif
+}
+alias WIN32_FIND_DATAA* PWIN32_FIND_DATAA, LPWIN32_FIND_DATAA;
+
+struct WIN32_FIND_DATAW {
+    DWORD           dwFileAttributes;
+    FILETIME        ftCreationTime;
+    FILETIME        ftLastAccessTime;
+    FILETIME        ftLastWriteTime;
+    DWORD           nFileSizeHigh;
+    DWORD           nFileSizeLow;
+// #ifdef _WIN32_WCE
+//  DWORD dwOID;
+// #else
+    DWORD           dwReserved0;
+    DWORD           dwReserved1;
+// #endif
+    WCHAR[MAX_PATH] cFileName;
+// #ifndef _WIN32_WCE
+    WCHAR[14]       cAlternateFileName;
+// #endif
+}
+alias WIN32_FIND_DATAW* PWIN32_FIND_DATAW, LPWIN32_FIND_DATAW;
+
+struct WIN32_STREAM_ID {
+    DWORD         dwStreamId;
+    DWORD         dwStreamAttributes;
+    LARGE_INTEGER Size;
+    DWORD         dwStreamNameSize;
+    WCHAR         _cStreamName;
+
+    WCHAR* cStreamName() return { return &_cStreamName; }
+}
+alias WIN32_STREAM_ID* LPWIN32_STREAM_ID;
+
+enum FINDEX_INFO_LEVELS {
+    FindExInfoStandard,
+    FindExInfoMaxInfoLevel
+}
+
+enum FINDEX_SEARCH_OPS {
+    FindExSearchNameMatch,
+    FindExSearchLimitToDirectories,
+    FindExSearchLimitToDevices,
+    FindExSearchMaxSearchOp
+}
+
+enum ACL_INFORMATION_CLASS {
+    AclRevisionInformation = 1,
+    AclSizeInformation
+}
+
+struct HW_PROFILE_INFOA {
+    DWORD dwDockInfo;
+    CHAR[HW_PROFILE_GUIDLEN] szHwProfileGuid;
+    CHAR[MAX_PROFILE_LEN]    szHwProfileName;
+}
+alias HW_PROFILE_INFOA* LPHW_PROFILE_INFOA;
+
+struct HW_PROFILE_INFOW {
+    DWORD dwDockInfo;
+    WCHAR[HW_PROFILE_GUIDLEN] szHwProfileGuid;
+    WCHAR[MAX_PROFILE_LEN]    szHwProfileName;
+}
+alias HW_PROFILE_INFOW* LPHW_PROFILE_INFOW;
+
+/*  ??? MSDN documents this only for Windows CE/Mobile, but it's used by
+ *  GetFileAttributesEx, which is in desktop Windows.
+ */
+enum GET_FILEEX_INFO_LEVELS {
+    GetFileExInfoStandard,
+    GetFileExMaxInfoLevel
+}
+
+struct SYSTEM_INFO {
+    union {
+        DWORD dwOemId;
+        struct {
+            WORD wProcessorArchitecture;
+            WORD wReserved;
+        }
+    }
+    DWORD dwPageSize;
+    PVOID lpMinimumApplicationAddress;
+    PVOID lpMaximumApplicationAddress;
+    DWORD_PTR dwActiveProcessorMask;
+    DWORD dwNumberOfProcessors;
+    DWORD dwProcessorType;
+    DWORD dwAllocationGranularity;
+    WORD  wProcessorLevel;
+    WORD  wProcessorRevision;
+}
+alias SYSTEM_INFO* LPSYSTEM_INFO;
+
+static if (_WIN32_WINNT >= 0x500) {
+    struct SYSTEM_POWER_STATUS {
+        BYTE ACLineStatus;
+        BYTE BatteryFlag;
+        BYTE BatteryLifePercent;
+        BYTE Reserved1;
+        DWORD BatteryLifeTime;
+        DWORD BatteryFullLifeTime;
+    }
+    alias SYSTEM_POWER_STATUS* LPSYSTEM_POWER_STATUS;
+}
+
+struct TIME_ZONE_INFORMATION {
+    LONG       Bias;
+    WCHAR[32]  StandardName;
+    SYSTEMTIME StandardDate;
+    LONG       StandardBias;
+    WCHAR[32]  DaylightName;
+    SYSTEMTIME DaylightDate;
+    LONG       DaylightBias;
+}
+alias TIME_ZONE_INFORMATION* LPTIME_ZONE_INFORMATION;
+
+// Does not exist in Windows headers, only MSDN
+// documentation (for TIME_ZONE_INFORMATION).
+// Provided solely for compatibility with the old
+// core.sys.windows.windows
+struct REG_TZI_FORMAT {
+    LONG Bias;
+    LONG StandardBias;
+    LONG DaylightBias;
+    SYSTEMTIME StandardDate;
+    SYSTEMTIME DaylightDate;
+}
+
+// MSDN documents this, possibly erroneously, as Win2000+.
+struct MEMORYSTATUS {
+    DWORD dwLength;
+    DWORD dwMemoryLoad;
+    DWORD dwTotalPhys;
+    DWORD dwAvailPhys;
+    DWORD dwTotalPageFile;
+    DWORD dwAvailPageFile;
+    DWORD dwTotalVirtual;
+    DWORD dwAvailVirtual;
+}
+alias MEMORYSTATUS* LPMEMORYSTATUS;
+
+static if (_WIN32_WINNT >= 0x500) {
+    struct MEMORYSTATUSEX {
+        DWORD     dwLength;
+        DWORD     dwMemoryLoad;
+        DWORDLONG ullTotalPhys;
+        DWORDLONG ullAvailPhys;
+        DWORDLONG ullTotalPageFile;
+        DWORDLONG ullAvailPageFile;
+        DWORDLONG ullTotalVirtual;
+        DWORDLONG ullAvailVirtual;
+        DWORDLONG ullAvailExtendedVirtual;
+    }
+    alias MEMORYSTATUSEX* LPMEMORYSTATUSEX;
+}
+
+struct LDT_ENTRY {
+    WORD LimitLow;
+    WORD BaseLow;
+    struct {
+        BYTE BaseMid;
+        BYTE Flags1;
+        BYTE Flags2;
+        BYTE BaseHi;
+
+        byte Type(byte f)        { Flags1 = cast(BYTE) ((Flags1 & 0xE0) | f); return cast(byte)(f & 0x1F); }
+        byte Dpl(byte f)         { Flags1 = cast(BYTE) ((Flags1 & 0x9F) | (f<<5)); return cast(byte)(f & 3); }
+        bool Pres(bool f)        { Flags1 = cast(BYTE) ((Flags1 & 0x7F) | (f<<7)); return f; }
+
+        byte LimitHi(byte f)     { Flags2 = cast(BYTE) ((Flags2 & 0xF0) | (f&0x0F)); return cast(byte)(f & 0x0F); }
+        bool Sys(bool f)         { Flags2 = cast(BYTE) ((Flags2 & 0xEF) | (f<<4)); return f; }
+        // Next bit is reserved
+        bool Default_Big(bool f) { Flags2 = cast(BYTE) ((Flags2 & 0xBF) | (f<<6)); return f; }
+        bool Granularity(bool f) { Flags2 = cast(BYTE) ((Flags2 & 0x7F) | (f<<7)); return f; }
+
+        byte Type()        { return cast(byte) (Flags1 & 0x1F); }
+        byte Dpl()         { return cast(byte) ((Flags1 & 0x60)>>5); }
+        bool Pres()        { return cast(bool) (Flags1 & 0x80); }
+
+        byte LimitHi()     { return cast(byte) (Flags2 & 0x0F); }
+        bool Sys()         { return cast(bool) (Flags2 & 0x10); }
+        bool Default_Big() { return cast(bool) (Flags2 & 0x40); }
+        bool Granularity() { return cast(bool) (Flags2 & 0x80); }
+    }
+/+
+    union  HighWord {
+        struct Bytes {
+            BYTE BaseMid;
+            BYTE Flags1;
+            BYTE Flags2;
+            BYTE BaseHi;
+        }
+    struct Bits {
+        DWORD BaseMid:8;
+        DWORD Type:5;
+        DWORD Dpl:2;
+        DWORD Pres:1;
+        DWORD LimitHi:4;
+        DWORD Sys:1;
+        DWORD Reserved_0:1;
+        DWORD Default_Big:1;
+        DWORD Granularity:1;
+        DWORD BaseHi:8;
+    }
+    }
++/
+}
+alias LDT_ENTRY* PLDT_ENTRY, LPLDT_ENTRY;
+
+/*  As with the other memory management functions and structures, MSDN's
+ *  Windows version info shall be taken with a cup of salt.
+ */
+struct PROCESS_HEAP_ENTRY {
+    PVOID lpData;
+    DWORD cbData;
+    BYTE  cbOverhead;
+    BYTE  iRegionIndex;
+    WORD  wFlags;
+    union {
+        struct Block {
+            HANDLE   hMem;
+            DWORD[3] dwReserved;
+        }
+        struct Region {
+            DWORD    dwCommittedSize;
+            DWORD    dwUnCommittedSize;
+            LPVOID   lpFirstBlock;
+            LPVOID   lpLastBlock;
+        }
+    }
+}
+alias PROCESS_HEAP_ENTRY* LPPROCESS_HEAP_ENTRY;
+
+struct OFSTRUCT {
+    BYTE      cBytes = OFSTRUCT.sizeof;
+    BYTE      fFixedDisk;
+    WORD      nErrCode;
+    WORD      Reserved1;
+    WORD      Reserved2;
+    CHAR[128] szPathName; // const OFS_MAXPATHNAME = 128;
+}
+alias OFSTRUCT* LPOFSTRUCT, POFSTRUCT;
+
+/*  ??? MSDN documents this only for Windows CE, but it's used by
+ *  ImageGetCertificateData, which is in desktop Windows.
+ */
+struct WIN_CERTIFICATE {
+    DWORD dwLength;
+    WORD  wRevision;
+    WORD  wCertificateType;
+    BYTE  _bCertificate;
+
+    BYTE* bCertificate() return { return &_bCertificate; }
+}
+alias WIN_CERTIFICATE* LPWIN_CERTIFICATE;
+
+static if (_WIN32_WINNT >= 0x500) {
+    enum COMPUTER_NAME_FORMAT {
+        ComputerNameNetBIOS,
+        ComputerNameDnsHostname,
+        ComputerNameDnsDomain,
+        ComputerNameDnsFullyQualified,
+        ComputerNamePhysicalNetBIOS,
+        ComputerNamePhysicalDnsHostname,
+        ComputerNamePhysicalDnsDomain,
+        ComputerNamePhysicalDnsFullyQualified,
+        ComputerNameMax
+    }
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    struct ACTCTXA {
+        ULONG cbSize = this.sizeof;
+        DWORD dwFlags;
+        LPCSTR lpSource;
+        USHORT wProcessorArchitecture;
+        LANGID wLangId;
+        LPCSTR lpAssemblyDirectory;
+        LPCSTR lpResourceName;
+        LPCSTR lpApplicationName;
+        HMODULE hModule;
+    }
+    alias ACTCTXA*        PACTCTXA;
+    alias const(ACTCTXA)* PCACTCTXA;
+
+    struct ACTCTXW {
+        ULONG cbSize = this.sizeof;
+        DWORD dwFlags;
+        LPCWSTR lpSource;
+        USHORT wProcessorArchitecture;
+        LANGID wLangId;
+        LPCWSTR lpAssemblyDirectory;
+        LPCWSTR lpResourceName;
+        LPCWSTR lpApplicationName;
+        HMODULE hModule;
+    }
+    alias ACTCTXW*        PACTCTXW;
+    alias const(ACTCTXW)* PCACTCTXW;
+
+    struct ACTCTX_SECTION_KEYED_DATA {
+        ULONG cbSize = this.sizeof;
+        ULONG ulDataFormatVersion;
+        PVOID lpData;
+        ULONG ulLength;
+        PVOID lpSectionGlobalData;
+        ULONG ulSectionGlobalDataLength;
+        PVOID lpSectionBase;
+        ULONG ulSectionTotalLength;
+        HANDLE hActCtx;
+        HANDLE ulAssemblyRosterIndex;
+    }
+    alias ACTCTX_SECTION_KEYED_DATA*        PACTCTX_SECTION_KEYED_DATA;
+    alias const(ACTCTX_SECTION_KEYED_DATA)* PCACTCTX_SECTION_KEYED_DATA;
+
+    enum MEMORY_RESOURCE_NOTIFICATION_TYPE {
+        LowMemoryResourceNotification,
+        HighMemoryResourceNotification
+    }
+
+} // (_WIN32_WINNT >= 0x501)
+
+static if (_WIN32_WINNT >= 0x410) {
+    /*  apparently used only by SetThreadExecutionState (Win2000+)
+     *  and DDK functions (version compatibility not established)
+     */
+    alias DWORD EXECUTION_STATE;
+}
+
+// Callbacks
+extern (Windows) {
+    alias DWORD function(LPVOID) LPTHREAD_START_ROUTINE;
+    alias DWORD function(LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER, LARGE_INTEGER,
+        DWORD, DWORD, HANDLE, HANDLE, LPVOID)  LPPROGRESS_ROUTINE;
+    alias void function(PVOID) LPFIBER_START_ROUTINE;
+
+    alias BOOL function(HMODULE, LPCSTR, LPCSTR, WORD, LONG) ENUMRESLANGPROCA;
+    alias BOOL function(HMODULE, LPCWSTR, LPCWSTR, WORD, LONG) ENUMRESLANGPROCW;
+    alias BOOL function(HMODULE, LPCSTR, LPSTR, LONG) ENUMRESNAMEPROCA;
+    alias BOOL function(HMODULE, LPCWSTR, LPWSTR, LONG) ENUMRESNAMEPROCW;
+    alias BOOL function(HMODULE, LPSTR, LONG) ENUMRESTYPEPROCA;
+    alias BOOL function(HMODULE, LPWSTR, LONG) ENUMRESTYPEPROCW;
+    alias void function(DWORD, DWORD, LPOVERLAPPED) LPOVERLAPPED_COMPLETION_ROUTINE;
+    alias LONG function(LPEXCEPTION_POINTERS) PTOP_LEVEL_EXCEPTION_FILTER;
+    alias PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
+
+    alias void function(ULONG_PTR) PAPCFUNC;
+    alias void function(PVOID, DWORD, DWORD) PTIMERAPCROUTINE;
+
+    static if (_WIN32_WINNT >= 0x500) {
+        alias void function(PVOID, BOOLEAN) WAITORTIMERCALLBACK;
+    }
+}
+
+LPTSTR MAKEINTATOM()(ushort i) {
+    return cast(LPTSTR) cast(size_t) i;
+}
+
+extern (Windows) nothrow @nogc {
+    // The following Win16 functions are obselete in Win32.
+    int _hread(HFILE, LPVOID, int);
+    int _hwrite(HFILE, LPCSTR, int);
+    HFILE _lclose(HFILE);
+    HFILE _lcreat(LPCSTR, int);
+    LONG _llseek(HFILE, LONG, int);
+    HFILE _lopen(LPCSTR, int);
+    UINT _lread(HFILE, LPVOID, UINT);
+    UINT _lwrite(HFILE, LPCSTR, UINT);
+    SIZE_T GlobalCompact(DWORD);
+    VOID GlobalFix(HGLOBAL);
+
+    // MSDN contradicts itself on GlobalFlags:
+    // "This function is provided only for compatibility with 16-bit versions of Windows."
+    // but also requires Windows 2000 or above
+    UINT GlobalFlags(HGLOBAL);
+    VOID GlobalUnfix(HGLOBAL);
+    BOOL GlobalUnWire(HGLOBAL);
+    PVOID GlobalWire(HGLOBAL);
+    SIZE_T LocalCompact(UINT);
+    UINT LocalFlags(HLOCAL);
+    SIZE_T LocalShrink(HLOCAL, UINT);
+
+    /+
+    //--------------------------------------
+    // These functions are problematic
+
+    version(UseNtoSKernel) {}else {
+        /* CAREFUL: These are exported from ntoskrnl.exe and declared in winddk.h
+           as __fastcall functions, but are  exported from kernel32.dll as __stdcall */
+        static if (_WIN32_WINNT >= 0x501) {
+         VOID InitializeSListHead(PSLIST_HEADER);
+        }
+        LONG InterlockedCompareExchange(LPLONG, LONG, LONG);
+        // PVOID WINAPI InterlockedCompareExchangePointer(PVOID*, PVOID, PVOID);
+        (PVOID)InterlockedCompareExchange((LPLONG)(d)    (PVOID)InterlockedCompareExchange((LPLONG)(d), (LONG)(e), (LONG)(c))
+        LONG InterlockedDecrement(LPLONG);
+        LONG InterlockedExchange(LPLONG, LONG);
+        // PVOID WINAPI InterlockedExchangePointer(PVOID*, PVOID);
+        (PVOID)InterlockedExchange((LPLONG)((PVOID)InterlockedExchange((LPLONG)(t), (LONG)(v))
+        LONG InterlockedExchangeAdd(LPLONG, LONG);
+
+        static if (_WIN32_WINNT >= 0x501) {
+        PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER);
+        }
+        LONG InterlockedIncrement(LPLONG);
+        static if (_WIN32_WINNT >= 0x501) {
+        PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER);
+        PSLIST_ENTRY InterlockedPushEntrySList(PSLIST_HEADER, PSLIST_ENTRY);
+        }
+    } // #endif //  __USE_NTOSKRNL__
+    //--------------------------------------
+    +/
+
+    version (MinGW)
+    {
+        LONG _InterlockedIncrement(LPLONG lpAddend);
+        LONG _InterlockedDecrement(LPLONG lpAddend);
+        LONG _InterlockedExchange(LPLONG Target, LONG Value);
+        LONG _InterlockedExchangeAdd(LPLONG Addend, LONG Value);
+        LONG _InterlockedCompareExchange(LONG *Destination, LONG Exchange, LONG Comperand);
+
+        alias InterlockedIncrement =  _InterlockedIncrement;
+        alias InterlockedDecrement = _InterlockedDecrement;
+        alias InterlockedExchange = _InterlockedExchange;
+        alias InterlockedExchangeAdd = _InterlockedExchangeAdd;
+        alias InterlockedCompareExchange = _InterlockedCompareExchange;
+    }
+    else
+    {
+        LONG InterlockedIncrement(LPLONG lpAddend);
+        LONG InterlockedDecrement(LPLONG lpAddend);
+        LONG InterlockedExchange(LPLONG Target, LONG Value);
+        LONG InterlockedExchangeAdd(LPLONG Addend, LONG Value);
+        LONG InterlockedCompareExchange(LONG *Destination, LONG Exchange, LONG Comperand);
+    }
+
+    ATOM AddAtomA(LPCSTR);
+    ATOM AddAtomW(LPCWSTR);
+    BOOL AreFileApisANSI();
+    BOOL Beep(DWORD, DWORD);
+    HANDLE BeginUpdateResourceA(LPCSTR, BOOL);
+    HANDLE BeginUpdateResourceW(LPCWSTR, BOOL);
+    BOOL BuildCommDCBA(LPCSTR, LPDCB);
+    BOOL BuildCommDCBW(LPCWSTR, LPDCB);
+    BOOL BuildCommDCBAndTimeoutsA(LPCSTR, LPDCB, LPCOMMTIMEOUTS);
+    BOOL BuildCommDCBAndTimeoutsW(LPCWSTR, LPDCB, LPCOMMTIMEOUTS);
+    BOOL CallNamedPipeA(LPCSTR, PVOID, DWORD, PVOID, DWORD, PDWORD, DWORD);
+    BOOL CallNamedPipeW(LPCWSTR, PVOID, DWORD, PVOID, DWORD, PDWORD, DWORD);
+    BOOL CancelDeviceWakeupRequest(HANDLE);
+    BOOL CheckTokenMembership(HANDLE, PSID, PBOOL);
+    BOOL ClearCommBreak(HANDLE);
+    BOOL ClearCommError(HANDLE, PDWORD, LPCOMSTAT);
+    BOOL CloseHandle(HANDLE) @trusted;
+    BOOL CommConfigDialogA(LPCSTR, HWND, LPCOMMCONFIG);
+    BOOL CommConfigDialogW(LPCWSTR, HWND, LPCOMMCONFIG);
+    LONG CompareFileTime(const(FILETIME)*, const(FILETIME)*);
+    BOOL ContinueDebugEvent(DWORD, DWORD, DWORD);
+    BOOL CopyFileA(LPCSTR, LPCSTR, BOOL);
+    BOOL CopyFileW(LPCWSTR, LPCWSTR, BOOL);
+    BOOL CopyFileExA(LPCSTR, LPCSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD);
+    BOOL CopyFileExW(LPCWSTR, LPCWSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD);
+
+    /+ FIXME
+    alias memmove RtlMoveMemory;
+    alias memcpy RtlCopyMemory;
+
+    void RtlFillMemory(PVOID dest, SIZE_T len, BYTE fill) {
+        memset(dest, fill, len);
+    }
+
+    void RtlZeroMemory(PVOID dest, SIZE_T len) {
+        RtlFillMemory(dest, len, 0);
+    }
+
+    alias RtlMoveMemory MoveMemory;
+    alias RtlCopyMemory CopyMemory;
+    alias RtlFillMemory FillMemory;
+    alias RtlZeroMemory ZeroMemory;
+    +/
+    BOOL CreateDirectoryA(LPCSTR, LPSECURITY_ATTRIBUTES);
+    BOOL CreateDirectoryW(LPCWSTR, LPSECURITY_ATTRIBUTES);
+    BOOL CreateDirectoryExA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES);
+    BOOL CreateDirectoryExW(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
+    HANDLE CreateEventA(LPSECURITY_ATTRIBUTES, BOOL, BOOL, LPCSTR);
+    HANDLE CreateEventW(LPSECURITY_ATTRIBUTES, BOOL, BOOL, LPCWSTR);
+    HANDLE CreateFileA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
+    HANDLE CreateFileW(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
+    HANDLE CreateIoCompletionPort(HANDLE, HANDLE, ULONG_PTR, DWORD);
+    HANDLE CreateMailslotA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
+    HANDLE CreateMailslotW(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
+    HANDLE CreateMutexA(LPSECURITY_ATTRIBUTES, BOOL, LPCSTR);
+    HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES, BOOL, LPCWSTR);
+    BOOL CreatePipe(PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD);
+    BOOL CreateProcessA(LPCSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCSTR, LPSTARTUPINFOA, LPPROCESS_INFORMATION);
+    BOOL CreateProcessW(LPCWSTR, LPWSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION);
+    HANDLE CreateSemaphoreA(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCSTR) @trusted;
+    HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCWSTR) @trusted;
+    HANDLE CreateThread(LPSECURITY_ATTRIBUTES, DWORD, LPTHREAD_START_ROUTINE, PVOID, DWORD, PDWORD);
+    BOOL DebugActiveProcess(DWORD);
+    void DebugBreak();
+    ATOM DeleteAtom(ATOM);
+    void DeleteCriticalSection(PCRITICAL_SECTION);
+    BOOL DeleteFileA(LPCSTR);
+    BOOL DeleteFileW(LPCWSTR);
+    BOOL DisableThreadLibraryCalls(HMODULE);
+    BOOL DosDateTimeToFileTime(WORD, WORD, LPFILETIME);
+    BOOL DuplicateHandle(HANDLE, HANDLE, HANDLE, PHANDLE, DWORD, BOOL, DWORD);
+    BOOL EndUpdateResourceA(HANDLE, BOOL);
+    BOOL EndUpdateResourceW(HANDLE, BOOL);
+    void EnterCriticalSection(LPCRITICAL_SECTION);
+    BOOL EnumResourceLanguagesA(HMODULE, LPCSTR, LPCSTR, ENUMRESLANGPROC, LONG_PTR);
+    BOOL EnumResourceLanguagesW(HMODULE, LPCWSTR, LPCWSTR, ENUMRESLANGPROC, LONG_PTR);
+    BOOL EnumResourceNamesA(HMODULE, LPCSTR, ENUMRESNAMEPROC, LONG_PTR);
+    BOOL EnumResourceNamesW(HMODULE, LPCWSTR, ENUMRESNAMEPROC, LONG_PTR);
+    BOOL EnumResourceTypesA(HMODULE, ENUMRESTYPEPROC, LONG_PTR);
+    BOOL EnumResourceTypesW(HMODULE, ENUMRESTYPEPROC, LONG_PTR);
+    BOOL EscapeCommFunction(HANDLE, DWORD);
+    void ExitProcess(UINT); // Never returns
+    void ExitThread(DWORD); // Never returns
+    DWORD ExpandEnvironmentStringsA(LPCSTR, LPSTR, DWORD);
+    DWORD ExpandEnvironmentStringsW(LPCWSTR, LPWSTR, DWORD);
+    void FatalAppExitA(UINT, LPCSTR);
+    void FatalAppExitW(UINT, LPCWSTR);
+    void FatalExit(int);
+    BOOL FileTimeToDosDateTime(const(FILETIME)*, LPWORD, LPWORD);
+    BOOL FileTimeToLocalFileTime(const(FILETIME)*, LPFILETIME);
+    BOOL FileTimeToSystemTime(const(FILETIME)*, LPSYSTEMTIME);
+    ATOM FindAtomA(LPCSTR);
+    ATOM FindAtomW(LPCWSTR);
+    BOOL FindClose(HANDLE);
+    BOOL FindCloseChangeNotification(HANDLE);
+    HANDLE FindFirstChangeNotificationA(LPCSTR, BOOL, DWORD);
+    HANDLE FindFirstChangeNotificationW(LPCWSTR, BOOL, DWORD);
+    HANDLE FindFirstFileA(LPCSTR, LPWIN32_FIND_DATAA);
+    HANDLE FindFirstFileW(LPCWSTR, LPWIN32_FIND_DATAW);
+    BOOL FindNextChangeNotification(HANDLE);
+    BOOL FindNextFileA(HANDLE, LPWIN32_FIND_DATAA);
+    BOOL FindNextFileW(HANDLE, LPWIN32_FIND_DATAW);
+    HRSRC FindResourceA(HMODULE, LPCSTR, LPCSTR);
+    HRSRC FindResourceW(HINSTANCE, LPCWSTR, LPCWSTR);
+    HRSRC FindResourceExA(HINSTANCE, LPCSTR, LPCSTR, WORD);
+    HRSRC FindResourceExW(HINSTANCE, LPCWSTR, LPCWSTR, WORD);
+    BOOL FlushFileBuffers(HANDLE);
+    BOOL FlushInstructionCache(HANDLE, PCVOID, DWORD);
+    DWORD FormatMessageA(DWORD, PCVOID, DWORD, DWORD, LPSTR, DWORD, va_list*);
+    DWORD FormatMessageW(DWORD, PCVOID, DWORD, DWORD, LPWSTR, DWORD, va_list*);
+    BOOL FreeEnvironmentStringsA(LPSTR);
+    BOOL FreeEnvironmentStringsW(LPWSTR);
+    BOOL FreeLibrary(HMODULE);
+    void FreeLibraryAndExitThread(HMODULE, DWORD); // never returns
+    BOOL FreeResource(HGLOBAL);
+    UINT GetAtomNameA(ATOM, LPSTR, int);
+    UINT GetAtomNameW(ATOM, LPWSTR, int);
+    LPSTR GetCommandLineA();
+    LPWSTR GetCommandLineW();
+    BOOL GetCommConfig(HANDLE, LPCOMMCONFIG, PDWORD);
+    BOOL GetCommMask(HANDLE, PDWORD);
+    BOOL GetCommModemStatus(HANDLE, PDWORD);
+    BOOL GetCommProperties(HANDLE, LPCOMMPROP);
+    BOOL GetCommState(HANDLE, LPDCB);
+    BOOL GetCommTimeouts(HANDLE, LPCOMMTIMEOUTS);
+    BOOL GetComputerNameA(LPSTR, PDWORD);
+    BOOL GetComputerNameW(LPWSTR, PDWORD);
+    DWORD GetCurrentDirectoryA(DWORD, LPSTR);
+    DWORD GetCurrentDirectoryW(DWORD, LPWSTR);
+    HANDLE GetCurrentProcess();
+    DWORD GetCurrentProcessId();
+    HANDLE GetCurrentThread();
+/* In MinGW:
+#ifdef _WIN32_WCE
+extern DWORD GetCurrentThreadId(void);
+#else
+WINBASEAPI DWORD WINAPI GetCurrentThreadId(void);
+#endif
+*/
+    DWORD GetCurrentThreadId();
+
+    alias GetTickCount GetCurrentTime;
+
+    BOOL GetDefaultCommConfigA(LPCSTR, LPCOMMCONFIG, PDWORD);
+    BOOL GetDefaultCommConfigW(LPCWSTR, LPCOMMCONFIG, PDWORD);
+    BOOL GetDiskFreeSpaceA(LPCSTR, PDWORD, PDWORD, PDWORD, PDWORD);
+    BOOL GetDiskFreeSpaceW(LPCWSTR, PDWORD, PDWORD, PDWORD, PDWORD);
+    BOOL GetDiskFreeSpaceExA(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
+    BOOL GetDiskFreeSpaceExW(LPCWSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
+    UINT GetDriveTypeA(LPCSTR);
+    UINT GetDriveTypeW(LPCWSTR);
+    LPSTR GetEnvironmentStrings(); // ???
+    LPSTR GetEnvironmentStringsA();
+    LPWSTR GetEnvironmentStringsW();
+    DWORD GetEnvironmentVariableA(LPCSTR, LPSTR, DWORD);
+    DWORD GetEnvironmentVariableW(LPCWSTR, LPWSTR, DWORD);
+    BOOL GetExitCodeProcess(HANDLE, PDWORD);
+    BOOL GetExitCodeThread(HANDLE, PDWORD);
+    DWORD GetFileAttributesA(LPCSTR);
+    DWORD GetFileAttributesW(LPCWSTR);
+    BOOL GetFileInformationByHandle(HANDLE, LPBY_HANDLE_FILE_INFORMATION);
+    DWORD GetFileSize(HANDLE, PDWORD);
+    BOOL GetFileTime(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME);
+    DWORD GetFileType(HANDLE);
+    DWORD GetFullPathNameA(LPCSTR, DWORD, LPSTR, LPSTR*);
+    DWORD GetFullPathNameW(LPCWSTR, DWORD, LPWSTR, LPWSTR*);
+    DWORD GetLastError() @trusted;
+    void GetLocalTime(LPSYSTEMTIME);
+    DWORD GetLogicalDrives();
+    DWORD GetLogicalDriveStringsA(DWORD, LPSTR);
+    DWORD GetLogicalDriveStringsW(DWORD, LPWSTR);
+    BOOL GetMailslotInfo(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD);
+    DWORD GetModuleFileNameA(HINSTANCE, LPSTR, DWORD);
+    DWORD GetModuleFileNameW(HINSTANCE, LPWSTR, DWORD);
+    HMODULE GetModuleHandleA(LPCSTR);
+    HMODULE GetModuleHandleW(LPCWSTR);
+    BOOL GetNamedPipeHandleStateA(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD, LPSTR, DWORD);
+    BOOL GetNamedPipeHandleStateW(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD, LPWSTR, DWORD);
+    BOOL GetNamedPipeInfo(HANDLE, PDWORD, PDWORD, PDWORD, PDWORD);
+    BOOL GetOverlappedResult(HANDLE, LPOVERLAPPED, PDWORD, BOOL);
+    DWORD GetPriorityClass(HANDLE);
+    UINT GetPrivateProfileIntA(LPCSTR, LPCSTR, INT, LPCSTR);
+    UINT GetPrivateProfileIntW(LPCWSTR, LPCWSTR, INT, LPCWSTR);
+    DWORD GetPrivateProfileSectionA(LPCSTR, LPSTR, DWORD, LPCSTR);
+    DWORD GetPrivateProfileSectionW(LPCWSTR, LPWSTR, DWORD, LPCWSTR);
+    DWORD GetPrivateProfileSectionNamesA(LPSTR, DWORD, LPCSTR);
+    DWORD GetPrivateProfileSectionNamesW(LPWSTR, DWORD, LPCWSTR);
+    DWORD GetPrivateProfileStringA(LPCSTR, LPCSTR, LPCSTR, LPSTR, DWORD, LPCSTR);
+    DWORD GetPrivateProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, DWORD, LPCWSTR);
+    BOOL GetPrivateProfileStructA(LPCSTR, LPCSTR, LPVOID, UINT, LPCSTR);
+    BOOL GetPrivateProfileStructW(LPCWSTR, LPCWSTR, LPVOID, UINT, LPCWSTR);
+    FARPROC GetProcAddress(HMODULE, LPCSTR); // 1st param wrongly HINSTANCE in MinGW
+    BOOL GetProcessAffinityMask(HANDLE, PDWORD, PDWORD);
+    DWORD GetProcessVersion(DWORD);
+    UINT GetProfileIntA(LPCSTR, LPCSTR, INT);
+    UINT GetProfileIntW(LPCWSTR, LPCWSTR, INT);
+    DWORD GetProfileSectionA(LPCSTR, LPSTR, DWORD);
+    DWORD GetProfileSectionW(LPCWSTR, LPWSTR, DWORD);
+    DWORD GetProfileStringA(LPCSTR, LPCSTR, LPCSTR, LPSTR, DWORD);
+    DWORD GetProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, DWORD);
+    DWORD GetShortPathNameA(LPCSTR, LPSTR, DWORD);
+    DWORD GetShortPathNameW(LPCWSTR, LPWSTR, DWORD);
+    VOID GetStartupInfoA(LPSTARTUPINFOA);
+    VOID GetStartupInfoW(LPSTARTUPINFOW);
+    HANDLE GetStdHandle(DWORD);
+    UINT GetSystemDirectoryA(LPSTR, UINT);
+    UINT GetSystemDirectoryW(LPWSTR, UINT);
+    VOID GetSystemInfo(LPSYSTEM_INFO);
+    VOID GetSystemTime(LPSYSTEMTIME);
+    BOOL GetSystemTimeAdjustment(PDWORD, PDWORD, PBOOL);
+    void GetSystemTimeAsFileTime(LPFILETIME);
+    UINT GetTempFileNameA(LPCSTR, LPCSTR, UINT, LPSTR);
+    UINT GetTempFileNameW(LPCWSTR, LPCWSTR, UINT, LPWSTR);
+    DWORD GetTempPathA(DWORD, LPSTR);
+    DWORD GetTempPathW(DWORD, LPWSTR);
+    BOOL GetThreadContext(HANDLE, LPCONTEXT);
+    int GetThreadPriority(HANDLE);
+    BOOL GetThreadSelectorEntry(HANDLE, DWORD, LPLDT_ENTRY);
+    DWORD GetTickCount();
+    DWORD GetTimeZoneInformation(LPTIME_ZONE_INFORMATION);
+    BOOL GetUserNameA (LPSTR, PDWORD);
+    BOOL GetUserNameW(LPWSTR, PDWORD);
+    DWORD GetVersion();
+    BOOL GetVersionExA(LPOSVERSIONINFOA);
+    BOOL GetVersionExW(LPOSVERSIONINFOW);
+    BOOL GetVolumeInformationA(LPCSTR, LPSTR, DWORD, PDWORD, PDWORD, PDWORD, LPSTR, DWORD);
+    BOOL GetVolumeInformationW(LPCWSTR, LPWSTR, DWORD, PDWORD, PDWORD, PDWORD, LPWSTR, DWORD);
+    UINT GetWindowsDirectoryA(LPSTR, UINT);
+    UINT GetWindowsDirectoryW(LPWSTR, UINT);
+    DWORD GetWindowThreadProcessId(HWND, PDWORD);
+    ATOM GlobalAddAtomA(LPCSTR);
+    ATOM GlobalAddAtomW(LPCWSTR);
+    ATOM GlobalDeleteAtom(ATOM);
+    ATOM GlobalFindAtomA(LPCSTR);
+    ATOM GlobalFindAtomW(LPCWSTR);
+    UINT GlobalGetAtomNameA(ATOM, LPSTR, int);
+    UINT GlobalGetAtomNameW(ATOM, LPWSTR, int);
+
+    bool HasOverlappedIoCompleted(LPOVERLAPPED lpOverlapped) {
+        return lpOverlapped.Internal != STATUS_PENDING;
+    }
+
+    BOOL InitAtomTable(DWORD);
+    VOID InitializeCriticalSection(LPCRITICAL_SECTION) @trusted;
+    /*  ??? The next two are allegedly obsolete and "supported only for
+     *  backward compatibility with the 16-bit Windows API".  Yet the
+     *  replacements IsBadReadPtr and IsBadWritePtr are apparently Win2000+
+     *  only.  Where's the mistake?
+     */
+    BOOL IsBadHugeReadPtr(PCVOID, UINT_PTR);
+    BOOL IsBadHugeWritePtr(PVOID, UINT_PTR);
+    BOOL IsBadReadPtr(PCVOID, UINT_PTR);
+    BOOL IsBadStringPtrA(LPCSTR, UINT_PTR);
+    BOOL IsBadStringPtrW(LPCWSTR, UINT_PTR);
+    BOOL IsBadWritePtr(PVOID, UINT_PTR);
+    void LeaveCriticalSection(LPCRITICAL_SECTION);
+    HINSTANCE LoadLibraryA(LPCSTR);
+    HINSTANCE LoadLibraryW(LPCWSTR);
+    HINSTANCE LoadLibraryExA(LPCSTR, HANDLE, DWORD);
+    HINSTANCE LoadLibraryExW(LPCWSTR, HANDLE, DWORD);
+    DWORD LoadModule(LPCSTR, PVOID);
+    HGLOBAL LoadResource(HINSTANCE, HRSRC);
+    BOOL LocalFileTimeToFileTime(const(FILETIME)*, LPFILETIME);
+    BOOL LockFile(HANDLE, DWORD, DWORD, DWORD, DWORD);
+    PVOID LockResource(HGLOBAL);
+
+    LPSTR lstrcatA(LPSTR, LPCSTR);
+    LPWSTR lstrcatW(LPWSTR, LPCWSTR);
+    int lstrcmpA(LPCSTR, LPCSTR);
+    int lstrcmpiA(LPCSTR, LPCSTR);
+    int lstrcmpiW(LPCWSTR, LPCWSTR);
+    int lstrcmpW(LPCWSTR, LPCWSTR);
+    LPSTR lstrcpyA(LPSTR, LPCSTR);
+    LPSTR lstrcpynA(LPSTR, LPCSTR, int);
+    LPWSTR lstrcpynW(LPWSTR, LPCWSTR, int);
+    LPWSTR lstrcpyW(LPWSTR, LPCWSTR);
+    int lstrlenA(LPCSTR);
+    int lstrlenW(LPCWSTR);
+
+    BOOL MoveFileA(LPCSTR, LPCSTR);
+    BOOL MoveFileW(LPCWSTR, LPCWSTR);
+    int MulDiv(int, int, int);
+    HANDLE OpenEventA(DWORD, BOOL, LPCSTR);
+    HANDLE OpenEventW(DWORD, BOOL, LPCWSTR);
+    deprecated HFILE OpenFile(LPCSTR, LPOFSTRUCT, UINT);
+    HANDLE OpenMutexA(DWORD, BOOL, LPCSTR);
+    HANDLE OpenMutexW(DWORD, BOOL, LPCWSTR);
+    HANDLE OpenProcess(DWORD, BOOL, DWORD);
+    HANDLE OpenSemaphoreA(DWORD, BOOL, LPCSTR);
+    HANDLE OpenSemaphoreW(DWORD, BOOL, LPCWSTR);
+    void OutputDebugStringA(LPCSTR);
+    void OutputDebugStringW(LPCWSTR);
+    BOOL PeekNamedPipe(HANDLE, PVOID, DWORD, PDWORD, PDWORD, PDWORD);
+    BOOL PulseEvent(HANDLE);
+    BOOL PurgeComm(HANDLE, DWORD);
+    BOOL QueryPerformanceCounter(PLARGE_INTEGER);
+    BOOL QueryPerformanceFrequency(PLARGE_INTEGER);
+    DWORD QueueUserAPC(PAPCFUNC, HANDLE, ULONG_PTR);
+    void RaiseException(DWORD, DWORD, DWORD, const(DWORD)*);
+    BOOL ReadFile(HANDLE, PVOID, DWORD, PDWORD, LPOVERLAPPED);
+    BOOL ReadFileEx(HANDLE, PVOID, DWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE);
+    BOOL ReadProcessMemory(HANDLE, PCVOID, PVOID, SIZE_T, SIZE_T*);
+    BOOL ReleaseMutex(HANDLE);
+    BOOL ReleaseSemaphore(HANDLE, LONG, LPLONG);
+    BOOL RemoveDirectoryA(LPCSTR);
+    BOOL RemoveDirectoryW(LPCWSTR);
+/* In MinGW:
+#ifdef _WIN32_WCE
+extern BOOL ResetEvent(HANDLE);
+#else
+WINBASEAPI BOOL WINAPI ResetEvent(HANDLE);
+#endif
+*/
+    BOOL ResetEvent(HANDLE);
+    DWORD ResumeThread(HANDLE);
+    DWORD SearchPathA(LPCSTR, LPCSTR, LPCSTR, DWORD, LPSTR, LPSTR*);
+    DWORD SearchPathW(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPWSTR, LPWSTR*);
+    BOOL SetCommBreak(HANDLE);
+    BOOL SetCommConfig(HANDLE, LPCOMMCONFIG, DWORD);
+    BOOL SetCommMask(HANDLE, DWORD);
+    BOOL SetCommState(HANDLE, LPDCB);
+    BOOL SetCommTimeouts(HANDLE, LPCOMMTIMEOUTS);
+    BOOL SetComputerNameA(LPCSTR);
+    BOOL SetComputerNameW(LPCWSTR);
+    BOOL SetCurrentDirectoryA(LPCSTR);
+    BOOL SetCurrentDirectoryW(LPCWSTR);
+    BOOL SetDefaultCommConfigA(LPCSTR, LPCOMMCONFIG, DWORD);
+    BOOL SetDefaultCommConfigW(LPCWSTR, LPCOMMCONFIG, DWORD);
+    BOOL SetEndOfFile(HANDLE);
+    BOOL SetEnvironmentVariableA(LPCSTR, LPCSTR);
+    BOOL SetEnvironmentVariableW(LPCWSTR, LPCWSTR);
+    UINT SetErrorMode(UINT);
+/* In MinGW:
+#ifdef _WIN32_WCE
+extern BOOL SetEvent(HANDLE);
+#else
+WINBASEAPI BOOL WINAPI SetEvent(HANDLE);
+#endif
+*/
+    BOOL SetEvent(HANDLE);
+    VOID SetFileApisToANSI();
+    VOID SetFileApisToOEM();
+    BOOL SetFileAttributesA(LPCSTR, DWORD);
+    BOOL SetFileAttributesW(LPCWSTR, DWORD);
+    DWORD SetFilePointer(HANDLE, LONG, PLONG, DWORD);
+    BOOL SetFileTime(HANDLE, const(FILETIME)*, const(FILETIME)*, const(FILETIME)*);
+    deprecated UINT SetHandleCount(UINT);
+    void SetLastError(DWORD);
+    void SetLastErrorEx(DWORD, DWORD);
+    BOOL SetLocalTime(const(SYSTEMTIME)*);
+    BOOL SetMailslotInfo(HANDLE, DWORD);
+    BOOL SetNamedPipeHandleState(HANDLE, PDWORD, PDWORD, PDWORD);
+    BOOL SetPriorityClass(HANDLE, DWORD);
+    BOOL SetStdHandle(DWORD, HANDLE);
+    BOOL SetSystemTime(const(SYSTEMTIME)*);
+    DWORD SetThreadAffinityMask(HANDLE, DWORD);
+    BOOL SetThreadContext(HANDLE, const(CONTEXT)*);
+    BOOL SetThreadPriority(HANDLE, int);
+    BOOL SetTimeZoneInformation(const(TIME_ZONE_INFORMATION)*);
+    LPTOP_LEVEL_EXCEPTION_FILTER SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER);
+    BOOL SetupComm(HANDLE, DWORD, DWORD);
+    BOOL SetVolumeLabelA(LPCSTR, LPCSTR);
+    BOOL SetVolumeLabelW(LPCWSTR, LPCWSTR);
+
+    DWORD SizeofResource(HINSTANCE, HRSRC);
+    void Sleep(DWORD);
+    DWORD SleepEx(DWORD, BOOL);
+    DWORD SuspendThread(HANDLE);
+    BOOL SystemTimeToFileTime(const(SYSTEMTIME)*, LPFILETIME);
+    BOOL TerminateProcess(HANDLE, UINT);
+    BOOL TerminateThread(HANDLE, DWORD);
+    DWORD TlsAlloc();
+    BOOL TlsFree(DWORD);
+    PVOID TlsGetValue(DWORD);
+    BOOL TlsSetValue(DWORD, PVOID);
+    BOOL TransactNamedPipe(HANDLE, PVOID, DWORD, PVOID, DWORD, PDWORD, LPOVERLAPPED);
+    BOOL TransmitCommChar(HANDLE, char);
+    LONG UnhandledExceptionFilter(LPEXCEPTION_POINTERS);
+    BOOL UnlockFile(HANDLE, DWORD, DWORD, DWORD, DWORD);
+    BOOL WaitCommEvent(HANDLE, PDWORD, LPOVERLAPPED);
+    BOOL WaitForDebugEvent(LPDEBUG_EVENT, DWORD);
+    DWORD WaitForMultipleObjects(DWORD, const(HANDLE)*, BOOL, DWORD);
+    DWORD WaitForMultipleObjectsEx(DWORD, const(HANDLE)*, BOOL, DWORD, BOOL);
+    DWORD WaitForSingleObject(HANDLE, DWORD);
+    DWORD WaitForSingleObjectEx(HANDLE, DWORD, BOOL);
+    BOOL WaitNamedPipeA(LPCSTR, DWORD);
+    BOOL WaitNamedPipeW(LPCWSTR, DWORD);
+    // undocumented on MSDN
+    BOOL WinLoadTrustProvider(GUID*);
+    BOOL WriteFile(HANDLE, PCVOID, DWORD, PDWORD, LPOVERLAPPED);
+    BOOL WriteFileEx(HANDLE, PCVOID, DWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE);
+    BOOL WritePrivateProfileSectionA(LPCSTR, LPCSTR, LPCSTR);
+    BOOL WritePrivateProfileSectionW(LPCWSTR, LPCWSTR, LPCWSTR);
+    BOOL WritePrivateProfileStringA(LPCSTR, LPCSTR, LPCSTR, LPCSTR);
+    BOOL WritePrivateProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR);
+    BOOL WritePrivateProfileStructA(LPCSTR, LPCSTR, LPVOID, UINT, LPCSTR);
+    BOOL WritePrivateProfileStructW(LPCWSTR, LPCWSTR, LPVOID, UINT, LPCWSTR);
+    BOOL WriteProcessMemory(HANDLE, LPVOID, LPCVOID, SIZE_T, SIZE_T*);
+    BOOL WriteProfileSectionA(LPCSTR, LPCSTR);
+    BOOL WriteProfileSectionW(LPCWSTR, LPCWSTR);
+    BOOL WriteProfileStringA(LPCSTR, LPCSTR, LPCSTR);
+    BOOL WriteProfileStringW(LPCWSTR, LPCWSTR, LPCWSTR);
+
+    /*  Memory allocation functions.
+     *  MSDN documents these erroneously as Win2000+; thus it is uncertain what
+     *  version compatibility they really have.
+     */
+    HGLOBAL GlobalAlloc(UINT, SIZE_T);
+    HGLOBAL GlobalDiscard(HGLOBAL);
+    HGLOBAL GlobalFree(HGLOBAL);
+    HGLOBAL GlobalHandle(PCVOID);
+    LPVOID GlobalLock(HGLOBAL);
+    VOID GlobalMemoryStatus(LPMEMORYSTATUS);
+    HGLOBAL GlobalReAlloc(HGLOBAL, SIZE_T, UINT);
+    SIZE_T GlobalSize(HGLOBAL);
+    BOOL GlobalUnlock(HGLOBAL);
+    PVOID HeapAlloc(HANDLE, DWORD, SIZE_T);
+    SIZE_T HeapCompact(HANDLE, DWORD);
+    HANDLE HeapCreate(DWORD, SIZE_T, SIZE_T);
+    BOOL HeapDestroy(HANDLE);
+    BOOL HeapFree(HANDLE, DWORD, PVOID);
+    BOOL HeapLock(HANDLE);
+    PVOID HeapReAlloc(HANDLE, DWORD, PVOID, SIZE_T);
+    SIZE_T HeapSize(HANDLE, DWORD, PCVOID);
+    BOOL HeapUnlock(HANDLE);
+    BOOL HeapValidate(HANDLE, DWORD, PCVOID);
+    BOOL HeapWalk(HANDLE, LPPROCESS_HEAP_ENTRY);
+    HLOCAL LocalAlloc(UINT, SIZE_T);
+    HLOCAL LocalDiscard(HLOCAL);
+    HLOCAL LocalFree(HLOCAL);
+    HLOCAL LocalHandle(LPCVOID);
+    PVOID LocalLock(HLOCAL);
+    HLOCAL LocalReAlloc(HLOCAL, SIZE_T, UINT);
+    UINT LocalSize(HLOCAL);
+    BOOL LocalUnlock(HLOCAL);
+    PVOID VirtualAlloc(PVOID, SIZE_T, DWORD, DWORD);
+    PVOID VirtualAllocEx(HANDLE, PVOID, SIZE_T, DWORD, DWORD);
+    BOOL VirtualFree(PVOID, SIZE_T, DWORD);
+    BOOL VirtualFreeEx(HANDLE, PVOID, SIZE_T, DWORD);
+    BOOL VirtualLock(PVOID, SIZE_T);
+    BOOL VirtualProtect(PVOID, SIZE_T, DWORD, PDWORD);
+    BOOL VirtualProtectEx(HANDLE, PVOID, SIZE_T, DWORD, PDWORD);
+    SIZE_T VirtualQuery(LPCVOID, PMEMORY_BASIC_INFORMATION, SIZE_T);
+    SIZE_T VirtualQueryEx(HANDLE, LPCVOID, PMEMORY_BASIC_INFORMATION, SIZE_T);
+    BOOL VirtualUnlock(PVOID, SIZE_T);
+// not in MinGW 4.0 - ???
+    static if (_WIN32_WINNT >= 0x600) {
+        BOOL CancelIoEx(HANDLE, LPOVERLAPPED);
+    }
+
+    BOOL CancelIo(HANDLE);
+    BOOL CancelWaitableTimer(HANDLE);
+    PVOID ConvertThreadToFiber(PVOID);
+    LPVOID CreateFiber(SIZE_T, LPFIBER_START_ROUTINE, LPVOID);
+    HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES, BOOL, LPCSTR);
+    HANDLE CreateWaitableTimerW(LPSECURITY_ATTRIBUTES, BOOL, LPCWSTR);
+    void DeleteFiber(PVOID);
+    BOOL GetFileAttributesExA(LPCSTR, GET_FILEEX_INFO_LEVELS, PVOID);
+    BOOL GetFileAttributesExW(LPCWSTR, GET_FILEEX_INFO_LEVELS, PVOID);
+    DWORD GetLongPathNameA(LPCSTR, LPSTR, DWORD);
+    DWORD GetLongPathNameW(LPCWSTR, LPWSTR, DWORD);
+    BOOL InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION, DWORD);
+    BOOL IsDebuggerPresent();
+    HANDLE OpenWaitableTimerA(DWORD, BOOL, LPCSTR);
+    HANDLE OpenWaitableTimerW(DWORD, BOOL, LPCWSTR);
+    DWORD QueryDosDeviceA(LPCSTR, LPSTR, DWORD);
+    DWORD QueryDosDeviceW(LPCWSTR, LPWSTR, DWORD);
+    BOOL SetWaitableTimer(HANDLE, const(LARGE_INTEGER)*, LONG, PTIMERAPCROUTINE, PVOID, BOOL);
+    void SwitchToFiber(PVOID);
+
+    static if (_WIN32_WINNT >= 0x500) {
+        HANDLE OpenThread(DWORD, BOOL, DWORD);
+    }
+
+    BOOL AccessCheck(PSECURITY_DESCRIPTOR, HANDLE, DWORD, PGENERIC_MAPPING, PPRIVILEGE_SET, PDWORD, PDWORD, PBOOL);
+    BOOL AccessCheckAndAuditAlarmA(LPCSTR, LPVOID, LPSTR, LPSTR, PSECURITY_DESCRIPTOR, DWORD, PGENERIC_MAPPING, BOOL, PDWORD, PBOOL, PBOOL);
+    BOOL AccessCheckAndAuditAlarmW(LPCWSTR, LPVOID, LPWSTR, LPWSTR, PSECURITY_DESCRIPTOR, DWORD, PGENERIC_MAPPING, BOOL, PDWORD, PBOOL, PBOOL);
+    BOOL AddAccessAllowedAce(PACL, DWORD, DWORD, PSID);
+    BOOL AddAccessDeniedAce(PACL, DWORD, DWORD, PSID);
+    BOOL AddAce(PACL, DWORD, DWORD, PVOID, DWORD);
+    BOOL AddAuditAccessAce(PACL, DWORD, DWORD, PSID, BOOL, BOOL);
+    BOOL AdjustTokenGroups(HANDLE, BOOL, PTOKEN_GROUPS, DWORD, PTOKEN_GROUPS, PDWORD);
+    BOOL AdjustTokenPrivileges(HANDLE, BOOL, PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD);
+    BOOL AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*);
+    BOOL AllocateLocallyUniqueId(PLUID);
+    BOOL AreAllAccessesGranted(DWORD, DWORD);
+    BOOL AreAnyAccessesGranted(DWORD, DWORD);
+    BOOL BackupEventLogA(HANDLE, LPCSTR);
+    BOOL BackupEventLogW(HANDLE, LPCWSTR);
+    BOOL BackupRead(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*);
+    BOOL BackupSeek(HANDLE, DWORD, DWORD, LPDWORD, LPDWORD, LPVOID*);
+    BOOL BackupWrite(HANDLE, LPBYTE, DWORD, LPDWORD, BOOL, BOOL, LPVOID*);
+    BOOL ClearEventLogA(HANDLE, LPCSTR);
+    BOOL ClearEventLogW(HANDLE, LPCWSTR);
+    BOOL CloseEventLog(HANDLE);
+    BOOL ConnectNamedPipe(HANDLE, LPOVERLAPPED);
+    BOOL CopySid(DWORD, PSID, PSID);
+    HANDLE CreateNamedPipeA(LPCSTR, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
+    HANDLE CreateNamedPipeW(LPCWSTR, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
+    BOOL CreatePrivateObjectSecurity(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR*, BOOL, HANDLE, PGENERIC_MAPPING);
+    BOOL CreateProcessAsUserA(HANDLE, LPCSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCSTR, LPSTARTUPINFOA, LPPROCESS_INFORMATION);
+    BOOL CreateProcessAsUserW(HANDLE, LPCWSTR, LPWSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, PVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION);
+    HANDLE CreateRemoteThread(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD);
+    DWORD CreateTapePartition(HANDLE, DWORD, DWORD, DWORD);
+    BOOL DefineDosDeviceA(DWORD, LPCSTR, LPCSTR);
+    BOOL DefineDosDeviceW(DWORD, LPCWSTR, LPCWSTR);
+    BOOL DeleteAce(PACL, DWORD);
+    BOOL DeregisterEventSource(HANDLE);
+    BOOL DestroyPrivateObjectSecurity(PSECURITY_DESCRIPTOR*);
+    BOOL DeviceIoControl(HANDLE, DWORD, PVOID, DWORD, PVOID, DWORD, PDWORD, POVERLAPPED);
+    BOOL DisconnectNamedPipe(HANDLE);
+    BOOL DuplicateToken(HANDLE, SECURITY_IMPERSONATION_LEVEL, PHANDLE);
+    BOOL DuplicateTokenEx(HANDLE, DWORD, LPSECURITY_ATTRIBUTES, SECURITY_IMPERSONATION_LEVEL, TOKEN_TYPE, PHANDLE);
+    BOOL EqualPrefixSid(PSID, PSID);
+    BOOL EqualSid(PSID, PSID);
+    DWORD EraseTape(HANDLE, DWORD, BOOL);
+    HANDLE FindFirstFileExA(LPCSTR, FINDEX_INFO_LEVELS, PVOID, FINDEX_SEARCH_OPS, PVOID, DWORD);
+    HANDLE FindFirstFileExW(LPCWSTR, FINDEX_INFO_LEVELS, PVOID, FINDEX_SEARCH_OPS, PVOID, DWORD);
+    BOOL FindFirstFreeAce(PACL, PVOID*);
+    PVOID FreeSid(PSID);
+    BOOL GetAce(PACL, DWORD, LPVOID*);
+    BOOL GetAclInformation(PACL, PVOID, DWORD, ACL_INFORMATION_CLASS);
+    BOOL GetBinaryTypeA(LPCSTR, PDWORD);
+    BOOL GetBinaryTypeW(LPCWSTR, PDWORD);
+    DWORD GetCompressedFileSizeA(LPCSTR, PDWORD);
+    DWORD GetCompressedFileSizeW(LPCWSTR, PDWORD);
+    BOOL GetCurrentHwProfileA(LPHW_PROFILE_INFOA);
+    BOOL GetCurrentHwProfileW(LPHW_PROFILE_INFOW);
+    BOOL GetFileSecurityA(LPCSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
+    BOOL GetFileSecurityW(LPCWSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
+    BOOL GetHandleInformation(HANDLE, PDWORD);
+    BOOL GetKernelObjectSecurity(HANDLE, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
+    DWORD GetLengthSid(PSID);
+    BOOL GetNumberOfEventLogRecords(HANDLE, PDWORD);
+    BOOL GetOldestEventLogRecord(HANDLE, PDWORD);
+    BOOL GetPrivateObjectSecurity(PSECURITY_DESCRIPTOR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
+    BOOL GetProcessPriorityBoost(HANDLE, PBOOL);
+    BOOL GetProcessShutdownParameters(PDWORD, PDWORD);
+    BOOL GetProcessTimes(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME);
+    HWINSTA GetProcessWindowStation();
+    BOOL GetProcessWorkingSetSize(HANDLE, PSIZE_T, PSIZE_T);
+    BOOL GetQueuedCompletionStatus(HANDLE, PDWORD, PULONG_PTR, LPOVERLAPPED*, DWORD);
+    BOOL GetSecurityDescriptorControl(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR_CONTROL, PDWORD);
+    BOOL GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR, LPBOOL, PACL*, LPBOOL);
+    BOOL GetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR, PSID*, LPBOOL);
+    DWORD GetSecurityDescriptorLength(PSECURITY_DESCRIPTOR);
+    BOOL GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR, PSID*, LPBOOL);
+    BOOL GetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR, LPBOOL, PACL*, LPBOOL);
+    PSID_IDENTIFIER_AUTHORITY GetSidIdentifierAuthority(PSID);
+    DWORD GetSidLengthRequired(UCHAR);
+    PDWORD GetSidSubAuthority(PSID, DWORD);
+    PUCHAR GetSidSubAuthorityCount(PSID);
+    DWORD GetTapeParameters(HANDLE, DWORD, PDWORD, PVOID);
+    DWORD GetTapePosition(HANDLE, DWORD, PDWORD, PDWORD, PDWORD);
+    DWORD GetTapeStatus(HANDLE);
+    BOOL GetThreadPriorityBoost(HANDLE, PBOOL);
+    BOOL GetThreadTimes(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME);
+    BOOL GetTokenInformation(HANDLE, TOKEN_INFORMATION_CLASS, PVOID, DWORD, PDWORD);
+    BOOL ImpersonateLoggedOnUser(HANDLE);
+    BOOL ImpersonateNamedPipeClient(HANDLE);
+    BOOL ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL);
+    BOOL InitializeAcl(PACL, DWORD, DWORD);
+    DWORD SetCriticalSectionSpinCount(LPCRITICAL_SECTION, DWORD);
+    BOOL InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR, DWORD);
+    BOOL InitializeSid(PSID, PSID_IDENTIFIER_AUTHORITY, BYTE);
+    BOOL IsProcessorFeaturePresent(DWORD);
+    BOOL IsTextUnicode(PCVOID, int, LPINT);
+    BOOL IsValidAcl(PACL);
+    BOOL IsValidSecurityDescriptor(PSECURITY_DESCRIPTOR);
+    BOOL IsValidSid(PSID);
+    BOOL LockFileEx(HANDLE, DWORD, DWORD, DWORD, DWORD, LPOVERLAPPED);
+    BOOL LogonUserA(LPSTR, LPSTR, LPSTR, DWORD, DWORD, PHANDLE);
+    BOOL LogonUserW(LPWSTR, LPWSTR, LPWSTR, DWORD, DWORD, PHANDLE);
+    BOOL LookupAccountNameA(LPCSTR, LPCSTR, PSID, PDWORD, LPSTR, PDWORD, PSID_NAME_USE);
+    BOOL LookupAccountNameW(LPCWSTR, LPCWSTR, PSID, PDWORD, LPWSTR, PDWORD, PSID_NAME_USE);
+    BOOL LookupAccountSidA(LPCSTR, PSID, LPSTR, PDWORD, LPSTR, PDWORD, PSID_NAME_USE);
+    BOOL LookupAccountSidW(LPCWSTR, PSID, LPWSTR, PDWORD, LPWSTR, PDWORD, PSID_NAME_USE);
+    BOOL LookupPrivilegeDisplayNameA(LPCSTR, LPCSTR, LPSTR, PDWORD, PDWORD);
+    BOOL LookupPrivilegeDisplayNameW(LPCWSTR, LPCWSTR, LPWSTR, PDWORD, PDWORD);
+    BOOL LookupPrivilegeNameA(LPCSTR, PLUID, LPSTR, PDWORD);
+    BOOL LookupPrivilegeNameW(LPCWSTR, PLUID, LPWSTR, PDWORD);
+    BOOL LookupPrivilegeValueA(LPCSTR, LPCSTR, PLUID);
+    BOOL LookupPrivilegeValueW(LPCWSTR, LPCWSTR, PLUID);
+    BOOL MakeAbsoluteSD(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR, PDWORD, PACL, PDWORD, PACL, PDWORD, PSID, PDWORD, PSID, PDWORD);
+    BOOL MakeSelfRelativeSD(PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR, PDWORD);
+    VOID MapGenericMask(PDWORD, PGENERIC_MAPPING);
+    BOOL MoveFileExA(LPCSTR, LPCSTR, DWORD);
+    BOOL MoveFileExW(LPCWSTR, LPCWSTR, DWORD);
+    BOOL NotifyChangeEventLog(HANDLE, HANDLE);
+    BOOL ObjectCloseAuditAlarmA(LPCSTR, PVOID, BOOL);
+    BOOL ObjectCloseAuditAlarmW(LPCWSTR, PVOID, BOOL);
+    BOOL ObjectDeleteAuditAlarmA(LPCSTR, PVOID, BOOL);
+    BOOL ObjectDeleteAuditAlarmW(LPCWSTR, PVOID, BOOL);
+    BOOL ObjectOpenAuditAlarmA(LPCSTR, PVOID, LPSTR, LPSTR, PSECURITY_DESCRIPTOR, HANDLE, DWORD, DWORD, PPRIVILEGE_SET, BOOL, BOOL, PBOOL);
+    BOOL ObjectOpenAuditAlarmW(LPCWSTR, PVOID, LPWSTR, LPWSTR, PSECURITY_DESCRIPTOR, HANDLE, DWORD, DWORD, PPRIVILEGE_SET, BOOL, BOOL, PBOOL);
+    BOOL ObjectPrivilegeAuditAlarmA(LPCSTR, PVOID, HANDLE, DWORD, PPRIVILEGE_SET, BOOL);
+    BOOL ObjectPrivilegeAuditAlarmW(LPCWSTR, PVOID, HANDLE, DWORD, PPRIVILEGE_SET, BOOL);
+    HANDLE OpenBackupEventLogA(LPCSTR, LPCSTR);
+    HANDLE OpenBackupEventLogW(LPCWSTR, LPCWSTR);
+    HANDLE OpenEventLogA(LPCSTR, LPCSTR);
+    HANDLE OpenEventLogW(LPCWSTR, LPCWSTR);
+    BOOL OpenProcessToken(HANDLE, DWORD, PHANDLE);
+    BOOL OpenThreadToken(HANDLE, DWORD, BOOL, PHANDLE);
+    BOOL PostQueuedCompletionStatus(HANDLE, DWORD, ULONG_PTR, LPOVERLAPPED);
+    DWORD PrepareTape(HANDLE, DWORD, BOOL);
+    BOOL PrivilegeCheck(HANDLE, PPRIVILEGE_SET, PBOOL);
+    BOOL PrivilegedServiceAuditAlarmA(LPCSTR, LPCSTR, HANDLE, PPRIVILEGE_SET, BOOL);
+    BOOL PrivilegedServiceAuditAlarmW(LPCWSTR, LPCWSTR, HANDLE, PPRIVILEGE_SET, BOOL);
+    BOOL ReadDirectoryChangesW(HANDLE, PVOID, DWORD, BOOL, DWORD, PDWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE);
+    BOOL ReadEventLogA(HANDLE, DWORD, DWORD, PVOID, DWORD, DWORD*, DWORD*);
+    BOOL ReadEventLogW(HANDLE, DWORD, DWORD, PVOID, DWORD, DWORD*, DWORD*);
+    BOOL ReadFileScatter(HANDLE, FILE_SEGMENT_ELEMENT*, DWORD, LPDWORD, LPOVERLAPPED);
+    HANDLE RegisterEventSourceA (LPCSTR, LPCSTR);
+    HANDLE RegisterEventSourceW(LPCWSTR, LPCWSTR);
+    BOOL ReportEventA(HANDLE, WORD, WORD, DWORD, PSID, WORD, DWORD, LPCSTR*, PVOID);
+    BOOL ReportEventW(HANDLE, WORD, WORD, DWORD, PSID, WORD, DWORD, LPCWSTR*, PVOID);
+    BOOL RevertToSelf();
+    BOOL SetAclInformation(PACL, PVOID, DWORD, ACL_INFORMATION_CLASS);
+    BOOL SetFileSecurityA(LPCSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
+    BOOL SetFileSecurityW(LPCWSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
+    BOOL SetHandleInformation(HANDLE, DWORD, DWORD);
+    BOOL SetKernelObjectSecurity(HANDLE, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
+    BOOL SetPrivateObjectSecurity(SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, PSECURITY_DESCRIPTOR*, PGENERIC_MAPPING, HANDLE);
+    BOOL SetProcessAffinityMask(HANDLE, DWORD);
+    BOOL SetProcessPriorityBoost(HANDLE, BOOL);
+    BOOL SetProcessShutdownParameters(DWORD, DWORD);
+    BOOL SetProcessWorkingSetSize(HANDLE, SIZE_T, SIZE_T);
+    BOOL SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR, BOOL, PACL, BOOL);
+    BOOL SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR, PSID, BOOL);
+    BOOL SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR, PSID, BOOL);
+    BOOL SetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR, BOOL, PACL, BOOL);
+    BOOL SetSystemTimeAdjustment(DWORD, BOOL);
+    DWORD SetTapeParameters(HANDLE, DWORD, PVOID);
+    DWORD SetTapePosition(HANDLE, DWORD, DWORD, DWORD, DWORD, BOOL);
+    BOOL SetThreadPriorityBoost(HANDLE, BOOL);
+    BOOL SetThreadToken(PHANDLE, HANDLE);
+    BOOL SetTokenInformation(HANDLE, TOKEN_INFORMATION_CLASS, PVOID, DWORD);
+    DWORD SignalObjectAndWait(HANDLE, HANDLE, DWORD, BOOL);
+    BOOL SwitchToThread();
+    BOOL SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION, LPSYSTEMTIME, LPSYSTEMTIME);
+    BOOL TzSpecificLocalTimeToSystemTime(LPTIME_ZONE_INFORMATION, LPSYSTEMTIME, LPSYSTEMTIME);
+    BOOL TryEnterCriticalSection(LPCRITICAL_SECTION);
+    BOOL UnlockFileEx(HANDLE, DWORD, DWORD, DWORD, LPOVERLAPPED);
+    BOOL UpdateResourceA(HANDLE, LPCSTR, LPCSTR, WORD, PVOID, DWORD);
+    BOOL UpdateResourceW(HANDLE, LPCWSTR, LPCWSTR, WORD, PVOID, DWORD);
+    BOOL WriteFileGather(HANDLE, FILE_SEGMENT_ELEMENT*, DWORD, LPDWORD, LPOVERLAPPED);
+    DWORD WriteTapemark(HANDLE, DWORD, DWORD, BOOL);
+
+    static if (_WIN32_WINNT >= 0x500) {
+        BOOL AddAccessAllowedAceEx(PACL, DWORD, DWORD, DWORD, PSID);
+        BOOL AddAccessDeniedAceEx(PACL, DWORD, DWORD, DWORD, PSID);
+        PVOID AddVectoredExceptionHandler(ULONG, PVECTORED_EXCEPTION_HANDLER);
+        BOOL AllocateUserPhysicalPages(HANDLE, PULONG_PTR, PULONG_PTR);
+        BOOL AssignProcessToJobObject(HANDLE, HANDLE);
+        BOOL ChangeTimerQueueTimer(HANDLE,HANDLE,ULONG,ULONG);
+        LPVOID CreateFiberEx(SIZE_T, SIZE_T, DWORD, LPFIBER_START_ROUTINE, LPVOID);
+        HANDLE CreateFileMappingA(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCSTR);
+        HANDLE CreateFileMappingW(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCWSTR);
+        BOOL CreateHardLinkA(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES);
+        BOOL CreateHardLinkW(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
+        HANDLE CreateJobObjectA(LPSECURITY_ATTRIBUTES, LPCSTR);
+        HANDLE CreateJobObjectW(LPSECURITY_ATTRIBUTES, LPCWSTR);
+        BOOL CreateProcessWithLogonW(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPCWSTR, LPWSTR, DWORD, LPVOID, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION);
+        HANDLE CreateTimerQueue();
+        BOOL CreateTimerQueueTimer(PHANDLE, HANDLE, WAITORTIMERCALLBACK, PVOID, DWORD, DWORD, ULONG);
+        BOOL DeleteTimerQueue(HANDLE);
+        BOOL DeleteTimerQueueEx(HANDLE, HANDLE);
+        BOOL DeleteTimerQueueTimer(HANDLE, HANDLE, HANDLE);
+        BOOL DeleteVolumeMountPointA(LPCSTR);
+        BOOL DeleteVolumeMountPointW(LPCWSTR);
+        BOOL DnsHostnameToComputerNameA(LPCSTR, LPSTR, LPDWORD);
+        BOOL DnsHostnameToComputerNameW(LPCWSTR, LPWSTR, LPDWORD);
+        BOOL EncryptFileA(LPCSTR);
+        BOOL EncryptFileW(LPCWSTR);
+        BOOL FileEncryptionStatusA(LPCSTR, LPDWORD);
+        BOOL FileEncryptionStatusW(LPCWSTR, LPDWORD);
+        HANDLE FindFirstVolumeA(LPCSTR, DWORD);
+        HANDLE FindFirstVolumeMountPointA(LPSTR, LPSTR, DWORD);
+        HANDLE FindFirstVolumeMountPointW(LPWSTR, LPWSTR, DWORD);
+        HANDLE FindFirstVolumeW(LPCWSTR, DWORD);
+        BOOL FindNextVolumeA(HANDLE, LPCSTR, DWORD);
+        BOOL FindNextVolumeW(HANDLE, LPWSTR, DWORD);
+        BOOL FindNextVolumeMountPointA(HANDLE, LPSTR, DWORD);
+        BOOL FindNextVolumeMountPointW(HANDLE, LPWSTR, DWORD);
+        BOOL FindVolumeClose(HANDLE);
+        BOOL FindVolumeMountPointClose(HANDLE);
+        BOOL FlushViewOfFile(PCVOID, SIZE_T);
+        BOOL FreeUserPhysicalPages(HANDLE, PULONG_PTR, PULONG_PTR);
+        BOOL GetComputerNameExA(COMPUTER_NAME_FORMAT, LPSTR, LPDWORD);
+        BOOL GetComputerNameExW(COMPUTER_NAME_FORMAT, LPWSTR, LPDWORD);
+        BOOL GetFileSizeEx(HANDLE, PLARGE_INTEGER);
+        BOOL GetModuleHandleExA(DWORD, LPCSTR, HMODULE*);
+        BOOL GetModuleHandleExW(DWORD, LPCWSTR, HMODULE*);
+        HANDLE GetProcessHeap();
+        DWORD GetProcessHeaps(DWORD, PHANDLE);
+        BOOL GetProcessIoCounters(HANDLE, PIO_COUNTERS);
+        BOOL GetSystemPowerStatus(LPSYSTEM_POWER_STATUS);
+        UINT GetSystemWindowsDirectoryA(LPSTR, UINT);
+        UINT GetSystemWindowsDirectoryW(LPWSTR, UINT);
+        BOOL GetVolumeNameForVolumeMountPointA(LPCSTR, LPSTR, DWORD);
+        BOOL GetVolumeNameForVolumeMountPointW(LPCWSTR, LPWSTR, DWORD);
+        BOOL GetVolumePathNameA(LPCSTR, LPSTR, DWORD);
+        BOOL GetVolumePathNameW(LPCWSTR, LPWSTR, DWORD);
+        BOOL GlobalMemoryStatusEx(LPMEMORYSTATUSEX);
+        BOOL IsBadCodePtr(FARPROC);
+        BOOL IsSystemResumeAutomatic();
+        BOOL MapUserPhysicalPages(PVOID, ULONG_PTR, PULONG_PTR);
+        BOOL MapUserPhysicalPagesScatter(PVOID*, ULONG_PTR, PULONG_PTR);
+        PVOID MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);
+        PVOID MapViewOfFileEx(HANDLE, DWORD, DWORD, DWORD, SIZE_T, PVOID);
+        HANDLE OpenFileMappingA(DWORD, BOOL, LPCSTR);
+        HANDLE OpenFileMappingW(DWORD, BOOL, LPCWSTR);
+        BOOL ProcessIdToSessionId(DWORD, DWORD*);
+        BOOL QueryInformationJobObject(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD, LPDWORD);
+        ULONG RemoveVectoredExceptionHandler(PVOID);
+        BOOL ReplaceFileA(LPCSTR, LPCSTR, LPCSTR, DWORD, LPVOID, LPVOID);
+        BOOL ReplaceFileW(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID);
+        BOOL SetComputerNameExA(COMPUTER_NAME_FORMAT, LPCSTR);
+        BOOL SetComputerNameExW(COMPUTER_NAME_FORMAT, LPCWSTR);
+        BOOL SetFilePointerEx(HANDLE, LARGE_INTEGER, PLARGE_INTEGER, DWORD);
+        BOOL SetInformationJobObject(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD);
+        BOOL SetSecurityDescriptorControl(PSECURITY_DESCRIPTOR, SECURITY_DESCRIPTOR_CONTROL, SECURITY_DESCRIPTOR_CONTROL);
+        BOOL SetSystemPowerState(BOOL, BOOL);
+        EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE);
+        DWORD SetThreadIdealProcessor(HANDLE, DWORD);
+        BOOL SetVolumeMountPointA(LPCSTR, LPCSTR);
+        BOOL SetVolumeMountPointW(LPCWSTR, LPCWSTR);
+        BOOL TerminateJobObject(HANDLE, UINT);
+        BOOL UnmapViewOfFile(PCVOID);
+        BOOL UnregisterWait(HANDLE);
+        BOOL UnregisterWaitEx(HANDLE, HANDLE);
+        BOOL VerifyVersionInfoA(LPOSVERSIONINFOEXA, DWORD, DWORDLONG);
+        BOOL VerifyVersionInfoW(LPOSVERSIONINFOEXW, DWORD, DWORDLONG);
+    }
+
+    static if (_WIN32_WINNT >= 0x501) {
+        BOOL ActivateActCtx(HANDLE, ULONG_PTR*);
+        void AddRefActCtx(HANDLE);
+        BOOL CheckNameLegalDOS8Dot3A(LPCSTR, LPSTR, DWORD, PBOOL, PBOOL);
+        BOOL CheckNameLegalDOS8Dot3W(LPCWSTR, LPSTR, DWORD, PBOOL, PBOOL);
+        BOOL CheckRemoteDebuggerPresent(HANDLE, PBOOL);
+        BOOL ConvertFiberToThread();
+        HANDLE CreateActCtxA(PCACTCTXA);
+        HANDLE CreateActCtxW(PCACTCTXW);
+        HANDLE CreateMemoryResourceNotification(MEMORY_RESOURCE_NOTIFICATION_TYPE);
+        BOOL DeactivateActCtx(DWORD, ULONG_PTR);
+        BOOL DebugActiveProcessStop(DWORD);
+        BOOL DebugBreakProcess(HANDLE);
+        BOOL DebugSetProcessKillOnExit(BOOL);
+        BOOL FindActCtxSectionGuid(DWORD, const(GUID)*, ULONG, const(GUID)*,
+          PACTCTX_SECTION_KEYED_DATA);
+        BOOL FindActCtxSectionStringA(DWORD, const(GUID)*, ULONG, LPCSTR,
+          PACTCTX_SECTION_KEYED_DATA);
+        BOOL FindActCtxSectionStringW(DWORD, const(GUID)*, ULONG, LPCWSTR,
+          PACTCTX_SECTION_KEYED_DATA);
+        BOOL GetCurrentActCtx(HANDLE*);
+        VOID GetNativeSystemInfo(LPSYSTEM_INFO);
+        BOOL GetProcessHandleCount(HANDLE, PDWORD);
+        BOOL GetSystemRegistryQuota(PDWORD, PDWORD);
+        BOOL GetSystemTimes(LPFILETIME, LPFILETIME, LPFILETIME);
+        UINT GetSystemWow64DirectoryA(LPSTR, UINT);
+        UINT GetSystemWow64DirectoryW(LPWSTR, UINT);
+        BOOL GetThreadIOPendingFlag(HANDLE, PBOOL);
+        BOOL GetVolumePathNamesForVolumeNameA(LPCSTR, LPSTR, DWORD, PDWORD);
+        BOOL GetVolumePathNamesForVolumeNameW(LPCWSTR, LPWSTR, DWORD, PDWORD);
+        UINT GetWriteWatch(DWORD, PVOID, SIZE_T, PVOID*, PULONG_PTR, PULONG);
+        BOOL HeapQueryInformation(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T);
+        BOOL HeapSetInformation(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T);
+        BOOL IsProcessInJob(HANDLE, HANDLE, PBOOL);
+        BOOL IsWow64Process(HANDLE, PBOOL);
+        BOOL QueryActCtxW(DWORD, HANDLE, PVOID, ULONG, PVOID, SIZE_T, SIZE_T*);
+        BOOL QueryMemoryResourceNotification(HANDLE, PBOOL);
+        void ReleaseActCtx(HANDLE);
+        UINT ResetWriteWatch(LPVOID, SIZE_T);
+        BOOL SetFileShortNameA(HANDLE, LPCSTR);
+        BOOL SetFileShortNameW(HANDLE, LPCWSTR);
+        BOOL SetFileValidData(HANDLE, LONGLONG);
+        BOOL ZombifyActCtx(HANDLE);
+    }
+
+    static if (_WIN32_WINNT >= 0x502) {
+        DWORD GetFirmwareEnvironmentVariableA(LPCSTR, LPCSTR, PVOID, DWORD);
+        DWORD GetFirmwareEnvironmentVariableW(LPCWSTR, LPCWSTR, PVOID, DWORD);
+        DWORD GetDllDirectoryA(DWORD, LPSTR);
+        DWORD GetDllDirectoryW(DWORD, LPWSTR);
+        DWORD GetThreadId(HANDLE);
+        DWORD GetProcessId(HANDLE);
+        HANDLE ReOpenFile(HANDLE, DWORD, DWORD, DWORD);
+        BOOL SetDllDirectoryA(LPCSTR);
+        BOOL SetDllDirectoryW(LPCWSTR);
+        BOOL SetFirmwareEnvironmentVariableA(LPCSTR, LPCSTR, PVOID, DWORD);
+        BOOL SetFirmwareEnvironmentVariableW(LPCWSTR, LPCWSTR, PVOID, DWORD);
+    }
+
+    // ???
+    static if (_WIN32_WINNT >= 0x510) {
+        VOID RestoreLastError(DWORD);
+    }
+}
+
+// For compatibility with old core.sys.windows.windows:
+version (LittleEndian) nothrow @nogc
+{
+    BOOL QueryPerformanceCounter(long* lpPerformanceCount) { return QueryPerformanceCounter(cast(PLARGE_INTEGER)lpPerformanceCount); }
+    BOOL QueryPerformanceFrequency(long* lpFrequency) { return QueryPerformanceFrequency(cast(PLARGE_INTEGER)lpFrequency); }
+}
+
+mixin DECLARE_AW!("STARTUPINFO");
+version (Unicode) {
+    //alias STARTUPINFOW STARTUPINFO;
+    alias WIN32_FIND_DATAW WIN32_FIND_DATA;
+    alias ENUMRESLANGPROCW ENUMRESLANGPROC;
+    alias ENUMRESNAMEPROCW ENUMRESNAMEPROC;
+    alias ENUMRESTYPEPROCW ENUMRESTYPEPROC;
+    alias AddAtomW AddAtom;
+    alias BeginUpdateResourceW BeginUpdateResource;
+    alias BuildCommDCBW BuildCommDCB;
+    alias BuildCommDCBAndTimeoutsW BuildCommDCBAndTimeouts;
+    alias CallNamedPipeW CallNamedPipe;
+    alias CommConfigDialogW CommConfigDialog;
+    alias CopyFileW CopyFile;
+    alias CopyFileExW CopyFileEx;
+    alias CreateDirectoryW CreateDirectory;
+    alias CreateDirectoryExW CreateDirectoryEx;
+    alias CreateEventW CreateEvent;
+    alias CreateFileW CreateFile;
+    alias CreateMailslotW CreateMailslot;
+    alias CreateMutexW CreateMutex;
+    alias CreateProcessW CreateProcess;
+    alias CreateSemaphoreW CreateSemaphore;
+    alias DeleteFileW DeleteFile;
+    alias EndUpdateResourceW EndUpdateResource;
+    alias EnumResourceLanguagesW EnumResourceLanguages;
+    alias EnumResourceNamesW EnumResourceNames;
+    alias EnumResourceTypesW EnumResourceTypes;
+    alias ExpandEnvironmentStringsW ExpandEnvironmentStrings;
+    alias FatalAppExitW FatalAppExit;
+    alias FindAtomW FindAtom;
+    alias FindFirstChangeNotificationW FindFirstChangeNotification;
+    alias FindFirstFileW FindFirstFile;
+    alias FindNextFileW FindNextFile;
+    alias FindResourceW FindResource;
+    alias FindResourceExW FindResourceEx;
+    alias FormatMessageW FormatMessage;
+    alias FreeEnvironmentStringsW FreeEnvironmentStrings;
+    alias GetAtomNameW GetAtomName;
+    alias GetCommandLineW GetCommandLine;
+    alias GetComputerNameW GetComputerName;
+    alias GetCurrentDirectoryW GetCurrentDirectory;
+    alias GetDefaultCommConfigW GetDefaultCommConfig;
+    alias GetDiskFreeSpaceW GetDiskFreeSpace;
+    alias GetDiskFreeSpaceExW GetDiskFreeSpaceEx;
+    alias GetDriveTypeW GetDriveType;
+    alias GetEnvironmentStringsW GetEnvironmentStrings;
+    alias GetEnvironmentVariableW GetEnvironmentVariable;
+    alias GetFileAttributesW GetFileAttributes;
+    alias GetFullPathNameW GetFullPathName;
+    alias GetLogicalDriveStringsW GetLogicalDriveStrings;
+    alias GetModuleFileNameW GetModuleFileName;
+    alias GetModuleHandleW GetModuleHandle;
+    alias GetNamedPipeHandleStateW GetNamedPipeHandleState;
+    alias GetPrivateProfileIntW GetPrivateProfileInt;
+    alias GetPrivateProfileSectionW GetPrivateProfileSection;
+    alias GetPrivateProfileSectionNamesW GetPrivateProfileSectionNames;
+    alias GetPrivateProfileStringW GetPrivateProfileString;
+    alias GetPrivateProfileStructW GetPrivateProfileStruct;
+    alias GetProfileIntW GetProfileInt;
+    alias GetProfileSectionW GetProfileSection;
+    alias GetProfileStringW GetProfileString;
+    alias GetShortPathNameW GetShortPathName;
+    alias GetStartupInfoW GetStartupInfo;
+    alias GetSystemDirectoryW GetSystemDirectory;
+    alias GetTempFileNameW GetTempFileName;
+    alias GetTempPathW GetTempPath;
+    alias GetUserNameW GetUserName;
+    alias GetVersionExW GetVersionEx;
+    alias GetVolumeInformationW GetVolumeInformation;
+    alias GetWindowsDirectoryW GetWindowsDirectory;
+    alias GlobalAddAtomW GlobalAddAtom;
+    alias GlobalFindAtomW GlobalFindAtom;
+    alias GlobalGetAtomNameW GlobalGetAtomName;
+    alias IsBadStringPtrW IsBadStringPtr;
+    alias LoadLibraryW LoadLibrary;
+    alias LoadLibraryExW LoadLibraryEx;
+    alias lstrcatW lstrcat;
+    alias lstrcmpW lstrcmp;
+    alias lstrcmpiW lstrcmpi;
+    alias lstrcpyW lstrcpy;
+    alias lstrcpynW lstrcpyn;
+    alias lstrlenW lstrlen;
+    alias MoveFileW MoveFile;
+    alias OpenEventW OpenEvent;
+    alias OpenMutexW OpenMutex;
+    alias OpenSemaphoreW OpenSemaphore;
+    alias OutputDebugStringW OutputDebugString;
+    alias RemoveDirectoryW RemoveDirectory;
+    alias SearchPathW SearchPath;
+    alias SetComputerNameW SetComputerName;
+    alias SetCurrentDirectoryW SetCurrentDirectory;
+    alias SetDefaultCommConfigW SetDefaultCommConfig;
+    alias SetEnvironmentVariableW SetEnvironmentVariable;
+    alias SetFileAttributesW SetFileAttributes;
+    alias SetVolumeLabelW SetVolumeLabel;
+    alias WaitNamedPipeW WaitNamedPipe;
+    alias WritePrivateProfileSectionW WritePrivateProfileSection;
+    alias WritePrivateProfileStringW WritePrivateProfileString;
+    alias WritePrivateProfileStructW WritePrivateProfileStruct;
+    alias WriteProfileSectionW WriteProfileSection;
+    alias WriteProfileStringW WriteProfileString;
+    alias CreateWaitableTimerW CreateWaitableTimer;
+    alias GetFileAttributesExW GetFileAttributesEx;
+    alias GetLongPathNameW GetLongPathName;
+    alias QueryDosDeviceW QueryDosDevice;
+
+    alias HW_PROFILE_INFOW HW_PROFILE_INFO;
+    alias AccessCheckAndAuditAlarmW AccessCheckAndAuditAlarm;
+    alias BackupEventLogW BackupEventLog;
+    alias ClearEventLogW ClearEventLog;
+    alias CreateNamedPipeW CreateNamedPipe;
+    alias CreateProcessAsUserW CreateProcessAsUser;
+    alias DefineDosDeviceW DefineDosDevice;
+    alias FindFirstFileExW FindFirstFileEx;
+    alias GetBinaryTypeW GetBinaryType;
+    alias GetCompressedFileSizeW GetCompressedFileSize;
+    alias GetFileSecurityW GetFileSecurity;
+    alias LogonUserW LogonUser;
+    alias LookupAccountNameW LookupAccountName;
+    alias LookupAccountSidW LookupAccountSid;
+    alias LookupPrivilegeDisplayNameW LookupPrivilegeDisplayName;
+    alias LookupPrivilegeNameW LookupPrivilegeName;
+    alias LookupPrivilegeValueW LookupPrivilegeValue;
+    alias MoveFileExW MoveFileEx;
+    alias ObjectCloseAuditAlarmW ObjectCloseAuditAlarm;
+    alias ObjectDeleteAuditAlarmW ObjectDeleteAuditAlarm;
+    alias ObjectOpenAuditAlarmW ObjectOpenAuditAlarm;
+    alias ObjectPrivilegeAuditAlarmW ObjectPrivilegeAuditAlarm;
+    alias OpenBackupEventLogW OpenBackupEventLog;
+    alias OpenEventLogW OpenEventLog;
+    alias PrivilegedServiceAuditAlarmW PrivilegedServiceAuditAlarm;
+    alias ReadEventLogW ReadEventLog;
+    alias RegisterEventSourceW RegisterEventSource;
+    alias ReportEventW ReportEvent;
+    alias SetFileSecurityW SetFileSecurity;
+    alias UpdateResourceW UpdateResource;
+
+    static if (_WIN32_WINNT >= 0x500) {
+        alias CreateFileMappingW CreateFileMapping;
+        alias CreateHardLinkW CreateHardLink;
+        alias CreateJobObjectW CreateJobObject;
+        alias DeleteVolumeMountPointW DeleteVolumeMountPoint;
+        alias DnsHostnameToComputerNameW DnsHostnameToComputerName;
+        alias EncryptFileW EncryptFile;
+        alias FileEncryptionStatusW FileEncryptionStatus;
+        alias FindFirstVolumeW FindFirstVolume;
+        alias FindFirstVolumeMountPointW FindFirstVolumeMountPoint;
+        alias FindNextVolumeW FindNextVolume;
+        alias FindNextVolumeMountPointW FindNextVolumeMountPoint;
+        alias GetModuleHandleExW GetModuleHandleEx;
+        alias GetSystemWindowsDirectoryW GetSystemWindowsDirectory;
+        alias GetVolumeNameForVolumeMountPointW GetVolumeNameForVolumeMountPoint;
+        alias GetVolumePathNameW GetVolumePathName;
+        alias OpenFileMappingW OpenFileMapping;
+        alias ReplaceFileW ReplaceFile;
+        alias SetVolumeMountPointW SetVolumeMountPoint;
+        alias VerifyVersionInfoW VerifyVersionInfo;
+    }
+
+    static if (_WIN32_WINNT >= 0x501) {
+        alias ACTCTXW ACTCTX;
+        alias CheckNameLegalDOS8Dot3W CheckNameLegalDOS8Dot3;
+        alias CreateActCtxW CreateActCtx;
+        alias FindActCtxSectionStringW FindActCtxSectionString;
+        alias GetSystemWow64DirectoryW GetSystemWow64Directory;
+        alias GetVolumePathNamesForVolumeNameW GetVolumePathNamesForVolumeName;
+        alias SetFileShortNameW SetFileShortName;
+    }
+
+    static if (_WIN32_WINNT >= 0x502) {
+        alias SetFirmwareEnvironmentVariableW SetFirmwareEnvironmentVariable;
+        alias SetDllDirectoryW SetDllDirectory;
+        alias GetDllDirectoryW GetDllDirectory;
+    }
+
+} else {
+    //alias STARTUPINFOA STARTUPINFO;
+    alias WIN32_FIND_DATAA WIN32_FIND_DATA;
+    alias ENUMRESLANGPROCW ENUMRESLANGPROC;
+    alias ENUMRESNAMEPROCW ENUMRESNAMEPROC;
+    alias ENUMRESTYPEPROCW ENUMRESTYPEPROC;
+    alias AddAtomA AddAtom;
+    alias BeginUpdateResourceA BeginUpdateResource;
+    alias BuildCommDCBA BuildCommDCB;
+    alias BuildCommDCBAndTimeoutsA BuildCommDCBAndTimeouts;
+    alias CallNamedPipeA CallNamedPipe;
+    alias CommConfigDialogA CommConfigDialog;
+    alias CopyFileA CopyFile;
+    alias CopyFileExA CopyFileEx;
+    alias CreateDirectoryA CreateDirectory;
+    alias CreateDirectoryExA CreateDirectoryEx;
+    alias CreateEventA CreateEvent;
+    alias CreateFileA CreateFile;
+    alias CreateMailslotA CreateMailslot;
+    alias CreateMutexA CreateMutex;
+    alias CreateProcessA CreateProcess;
+    alias CreateSemaphoreA CreateSemaphore;
+    alias DeleteFileA DeleteFile;
+    alias EndUpdateResourceA EndUpdateResource;
+    alias EnumResourceLanguagesA EnumResourceLanguages;
+    alias EnumResourceNamesA EnumResourceNames;
+    alias EnumResourceTypesA EnumResourceTypes;
+    alias ExpandEnvironmentStringsA ExpandEnvironmentStrings;
+    alias FatalAppExitA FatalAppExit;
+    alias FindAtomA FindAtom;
+    alias FindFirstChangeNotificationA FindFirstChangeNotification;
+    alias FindFirstFileA FindFirstFile;
+    alias FindNextFileA FindNextFile;
+    alias FindResourceA FindResource;
+    alias FindResourceExA FindResourceEx;
+    alias FormatMessageA FormatMessage;
+    alias FreeEnvironmentStringsA FreeEnvironmentStrings;
+    alias GetAtomNameA GetAtomName;
+    alias GetCommandLineA GetCommandLine;
+    alias GetComputerNameA GetComputerName;
+    alias GetCurrentDirectoryA GetCurrentDirectory;
+    alias GetDefaultCommConfigA GetDefaultCommConfig;
+    alias GetDiskFreeSpaceA GetDiskFreeSpace;
+    alias GetDiskFreeSpaceExA GetDiskFreeSpaceEx;
+    alias GetDriveTypeA GetDriveType;
+    alias GetEnvironmentVariableA GetEnvironmentVariable;
+    alias GetFileAttributesA GetFileAttributes;
+    alias GetFullPathNameA GetFullPathName;
+    alias GetLogicalDriveStringsA GetLogicalDriveStrings;
+    alias GetNamedPipeHandleStateA GetNamedPipeHandleState;
+    alias GetModuleHandleA GetModuleHandle;
+    alias GetModuleFileNameA GetModuleFileName;
+    alias GetPrivateProfileIntA GetPrivateProfileInt;
+    alias GetPrivateProfileSectionA GetPrivateProfileSection;
+    alias GetPrivateProfileSectionNamesA GetPrivateProfileSectionNames;
+    alias GetPrivateProfileStringA GetPrivateProfileString;
+    alias GetPrivateProfileStructA GetPrivateProfileStruct;
+    alias GetProfileIntA GetProfileInt;
+    alias GetProfileSectionA GetProfileSection;
+    alias GetProfileStringA GetProfileString;
+    alias GetShortPathNameA GetShortPathName;
+    alias GetStartupInfoA GetStartupInfo;
+    alias GetSystemDirectoryA GetSystemDirectory;
+    alias GetTempFileNameA GetTempFileName;
+    alias GetTempPathA GetTempPath;
+    alias GetUserNameA GetUserName;
+    alias GetVersionExA GetVersionEx;
+    alias GetVolumeInformationA GetVolumeInformation;
+    alias GetWindowsDirectoryA GetWindowsDirectory;
+    alias GlobalAddAtomA GlobalAddAtom;
+    alias GlobalFindAtomA GlobalFindAtom;
+    alias GlobalGetAtomNameA GlobalGetAtomName;
+    alias IsBadStringPtrA IsBadStringPtr;
+    alias LoadLibraryA LoadLibrary;
+    alias LoadLibraryExA LoadLibraryEx;
+    alias lstrcatA lstrcat;
+    alias lstrcmpA lstrcmp;
+    alias lstrcmpiA lstrcmpi;
+    alias lstrcpyA lstrcpy;
+    alias lstrcpynA lstrcpyn;
+    alias lstrlenA lstrlen;
+    alias MoveFileA MoveFile;
+    alias OpenEventA OpenEvent;
+    alias OpenMutexA OpenMutex;
+    alias OpenSemaphoreA OpenSemaphore;
+    alias OutputDebugStringA OutputDebugString;
+    alias RemoveDirectoryA RemoveDirectory;
+    alias SearchPathA SearchPath;
+    alias SetComputerNameA SetComputerName;
+    alias SetCurrentDirectoryA SetCurrentDirectory;
+    alias SetDefaultCommConfigA SetDefaultCommConfig;
+    alias SetEnvironmentVariableA SetEnvironmentVariable;
+    alias SetFileAttributesA SetFileAttributes;
+    alias SetVolumeLabelA SetVolumeLabel;
+    alias WaitNamedPipeA WaitNamedPipe;
+    alias WritePrivateProfileSectionA WritePrivateProfileSection;
+    alias WritePrivateProfileStringA WritePrivateProfileString;
+    alias WritePrivateProfileStructA WritePrivateProfileStruct;
+    alias WriteProfileSectionA WriteProfileSection;
+    alias WriteProfileStringA WriteProfileString;
+    alias CreateWaitableTimerA CreateWaitableTimer;
+    alias GetFileAttributesExA GetFileAttributesEx;
+    alias GetLongPathNameA GetLongPathName;
+    alias QueryDosDeviceA QueryDosDevice;
+
+    alias HW_PROFILE_INFOA HW_PROFILE_INFO;
+    alias AccessCheckAndAuditAlarmA AccessCheckAndAuditAlarm;
+    alias BackupEventLogA BackupEventLog;
+    alias ClearEventLogA ClearEventLog;
+    alias CreateNamedPipeA CreateNamedPipe;
+    alias CreateProcessAsUserA CreateProcessAsUser;
+    alias DefineDosDeviceA DefineDosDevice;
+    alias FindFirstFileExA FindFirstFileEx;
+    alias GetBinaryTypeA GetBinaryType;
+    alias GetCompressedFileSizeA GetCompressedFileSize;
+    alias GetFileSecurityA GetFileSecurity;
+    alias LogonUserA LogonUser;
+    alias LookupAccountNameA LookupAccountName;
+    alias LookupAccountSidA LookupAccountSid;
+    alias LookupPrivilegeDisplayNameA LookupPrivilegeDisplayName;
+    alias LookupPrivilegeNameA LookupPrivilegeName;
+    alias LookupPrivilegeValueA LookupPrivilegeValue;
+    alias MoveFileExA MoveFileEx;
+    alias ObjectCloseAuditAlarmA ObjectCloseAuditAlarm;
+    alias ObjectDeleteAuditAlarmA ObjectDeleteAuditAlarm;
+    alias ObjectOpenAuditAlarmA ObjectOpenAuditAlarm;
+    alias ObjectPrivilegeAuditAlarmA ObjectPrivilegeAuditAlarm;
+    alias OpenBackupEventLogA OpenBackupEventLog;
+    alias OpenEventLogA OpenEventLog;
+    alias PrivilegedServiceAuditAlarmA PrivilegedServiceAuditAlarm;
+    alias ReadEventLogA ReadEventLog;
+    alias RegisterEventSourceA RegisterEventSource;
+    alias ReportEventA ReportEvent;
+    alias SetFileSecurityA SetFileSecurity;
+    alias UpdateResourceA UpdateResource;
+
+    static if (_WIN32_WINNT >= 0x500) {
+        alias CreateFileMappingA CreateFileMapping;
+        alias CreateHardLinkA CreateHardLink;
+        alias CreateJobObjectA CreateJobObject;
+        alias DeleteVolumeMountPointA DeleteVolumeMountPoint;
+        alias DnsHostnameToComputerNameA DnsHostnameToComputerName;
+        alias EncryptFileA EncryptFile;
+        alias FileEncryptionStatusA FileEncryptionStatus;
+        alias FindFirstVolumeA FindFirstVolume;
+        alias FindFirstVolumeMountPointA FindFirstVolumeMountPoint;
+        alias FindNextVolumeA FindNextVolume;
+        alias FindNextVolumeMountPointA FindNextVolumeMountPoint;
+        alias GetModuleHandleExA GetModuleHandleEx;
+        alias GetSystemWindowsDirectoryA GetSystemWindowsDirectory;
+        alias GetVolumeNameForVolumeMountPointA GetVolumeNameForVolumeMountPoint;
+        alias GetVolumePathNameA GetVolumePathName;
+        alias OpenFileMappingA OpenFileMapping;
+        alias ReplaceFileA ReplaceFile;
+        alias SetVolumeMountPointA SetVolumeMountPoint;
+        alias VerifyVersionInfoA VerifyVersionInfo;
+    }
+
+    static if (_WIN32_WINNT >= 0x501) {
+        alias ACTCTXA ACTCTX;
+        alias CheckNameLegalDOS8Dot3A CheckNameLegalDOS8Dot3;
+        alias CreateActCtxA CreateActCtx;
+        alias FindActCtxSectionStringA FindActCtxSectionString;
+        alias GetSystemWow64DirectoryA GetSystemWow64Directory;
+        alias GetVolumePathNamesForVolumeNameA GetVolumePathNamesForVolumeName;
+        alias SetFileShortNameA SetFileShortName;
+    }
+
+    static if (_WIN32_WINNT >= 0x502) {
+        alias GetDllDirectoryA GetDllDirectory;
+        alias SetDllDirectoryA SetDllDirectory;
+        alias SetFirmwareEnvironmentVariableA SetFirmwareEnvironmentVariable;
+    }
+}
+
+alias STARTUPINFO* LPSTARTUPINFO;
+alias WIN32_FIND_DATA* LPWIN32_FIND_DATA;
+
+alias HW_PROFILE_INFO* LPHW_PROFILE_INFO;
+
+static if (_WIN32_WINNT >= 0x501) {
+    alias ACTCTX* PACTCTX, PCACTCTX;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/winber.d b/libphobos/libdruntime/core/sys/windows/winber.d
new file mode 100644
index 00000000000..9ff3231b208
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winber.d
@@ -0,0 +1,70 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winber.d)
+ */
+module core.sys.windows.winber;
+version (Windows):
+
+/* Comment from MinGW
+  winber.h - Header file for the Windows LDAP Basic Encoding Rules API
+
+  Written by Filip Navara <xnavara@volny.cz>
+
+  References:
+    The C LDAP Application Program Interface
+    http://www.watersprings.org/pub/id/draft-ietf-ldapext-ldap-c-api-05.txt
+
+    Lightweight Directory Access Protocol Reference
+    http://msdn.microsoft.com/library/en-us/netdir/ldap/ldap_reference.asp
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+ import core.sys.windows.basetsd;
+
+/* Opaque structure
+ *  http://msdn.microsoft.com/library/en-us/ldap/ldap/berelement.asp
+ */
+struct BerElement;
+
+alias int ber_int_t, ber_slen_t;
+alias uint ber_uint_t, ber_len_t, ber_tag_t;
+
+align(4):
+struct BerValue {
+    ber_len_t bv_len;
+    char*     bv_val;
+}
+alias BerValue LDAP_BERVAL, BERVAL;
+alias BerValue* PLDAP_BERVAL, PBERVAL;
+
+enum ber_tag_t
+    LBER_ERROR   = -1,
+    LBER_DEFAULT = -1,
+    LBER_USE_DER =  1;
+
+/*  FIXME: In MinGW, these are WINBERAPI == DECLSPEC_IMPORT.  Linkage
+ *  attribute?
+ */
+extern (C) {
+    BerElement* ber_init(const(BerValue)*);
+    int ber_printf(BerElement*, const(char)*, ...);
+    int ber_flatten(BerElement*, BerValue**);
+    ber_tag_t ber_scanf(BerElement*, const(char)*, ...);
+    ber_tag_t ber_peek_tag(BerElement*, ber_len_t*);
+    ber_tag_t ber_skip_tag(BerElement*, ber_len_t*);
+    ber_tag_t ber_first_element(BerElement*, ber_len_t*, char**);
+    ber_tag_t ber_next_element(BerElement*, ber_len_t*, char*);
+    void ber_bvfree(BerValue*);
+    void ber_bvecfree(BerValue**);
+    void ber_free(BerElement*, int);
+    BerValue* ber_bvdup(BerValue*);
+    BerElement* ber_alloc_t(int);
+}
diff --git a/libphobos/libdruntime/core/sys/windows/wincon.d b/libphobos/libdruntime/core/sys/windows/wincon.d
new file mode 100644
index 00000000000..5c32b7ba8bc
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/wincon.d
@@ -0,0 +1,298 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_wincon.d)
+ */
+module core.sys.windows.wincon;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "kernel32");
+
+private import core.sys.windows.w32api, core.sys.windows.windef;
+
+// FIXME: clean up Windows version support
+
+enum {
+    FOREGROUND_BLUE      = 1,
+    FOREGROUND_GREEN     = 2,
+    FOREGROUND_RED       = 4,
+    FOREGROUND_INTENSITY = 8,
+    BACKGROUND_BLUE      = 16,
+    BACKGROUND_GREEN     = 32,
+    BACKGROUND_RED       = 64,
+    BACKGROUND_INTENSITY = 128
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        CONSOLE_FULLSCREEN_MODE = 1,
+        CONSOLE_WINDOWED_MODE   = 0
+    }
+}
+
+enum {
+    CTRL_C_EVENT        = 0,
+    CTRL_BREAK_EVENT    = 1,
+    CTRL_CLOSE_EVENT    = 2,
+    CTRL_LOGOFF_EVENT   = 5,
+    CTRL_SHUTDOWN_EVENT = 6
+}
+
+enum {
+    ENABLE_PROCESSED_INPUT  = 1,
+    ENABLE_LINE_INPUT       = 2,
+    ENABLE_ECHO_INPUT       = 4,
+    ENABLE_WINDOW_INPUT     = 8,
+    ENABLE_MOUSE_INPUT      = 16
+}
+
+enum {
+    ENABLE_PROCESSED_OUTPUT    = 1,
+    ENABLE_WRAP_AT_EOL_OUTPUT  = 2
+}
+
+enum {
+    KEY_EVENT                 = 1,
+    MOUSE_EVENT               = 2,
+    WINDOW_BUFFER_SIZE_EVENT  = 4,
+    MENU_EVENT                = 8,
+    FOCUS_EVENT               = 16
+}
+enum {
+    RIGHT_ALT_PRESSED  = 1,
+    LEFT_ALT_PRESSED   = 2,
+    RIGHT_CTRL_PRESSED = 4,
+    LEFT_CTRL_PRESSED  = 8,
+    SHIFT_PRESSED      = 16,
+    NUMLOCK_ON         = 32,
+    SCROLLLOCK_ON      = 64,
+    CAPSLOCK_ON        = 128,
+    ENHANCED_KEY       = 256
+}
+enum {
+    FROM_LEFT_1ST_BUTTON_PRESSED  = 1,
+    RIGHTMOST_BUTTON_PRESSED      = 2,
+    FROM_LEFT_2ND_BUTTON_PRESSED  = 4,
+    FROM_LEFT_3RD_BUTTON_PRESSED  = 8,
+    FROM_LEFT_4TH_BUTTON_PRESSED  = 16
+}
+
+enum {
+    MOUSE_MOVED   = 1,
+    DOUBLE_CLICK  = 2,
+    MOUSE_WHEELED = 4
+}
+
+struct CHAR_INFO {
+    union _Char {
+        WCHAR UnicodeChar;
+        CHAR AsciiChar;
+    }
+    union {
+        _Char Char;
+        WCHAR UnicodeChar;
+        CHAR AsciiChar;
+    }
+    WORD Attributes;
+}
+alias CHAR_INFO* PCHAR_INFO;
+
+struct SMALL_RECT {
+    SHORT Left;
+    SHORT Top;
+    SHORT Right;
+    SHORT Bottom;
+}
+alias SMALL_RECT* PSMALL_RECT;
+
+struct CONSOLE_CURSOR_INFO {
+    DWORD dwSize;
+    BOOL  bVisible;
+}
+alias CONSOLE_CURSOR_INFO* PCONSOLE_CURSOR_INFO;
+
+struct COORD {
+    SHORT X;
+    SHORT Y;
+}
+alias COORD* PCOORD;
+
+struct CONSOLE_FONT_INFO {
+    DWORD nFont;
+    COORD dwFontSize;
+}
+alias CONSOLE_FONT_INFO* PCONSOLE_FONT_INFO;
+
+struct CONSOLE_SCREEN_BUFFER_INFO {
+    COORD      dwSize;
+    COORD      dwCursorPosition;
+    WORD       wAttributes;
+    SMALL_RECT srWindow;
+    COORD      dwMaximumWindowSize;
+}
+alias CONSOLE_SCREEN_BUFFER_INFO* PCONSOLE_SCREEN_BUFFER_INFO;
+
+alias extern(Windows) BOOL function(DWORD) nothrow PHANDLER_ROUTINE;
+
+struct KEY_EVENT_RECORD {
+    BOOL  bKeyDown;
+    WORD  wRepeatCount;
+    WORD  wVirtualKeyCode;
+    WORD  wVirtualScanCode;
+    union _uChar {
+        WCHAR UnicodeChar;
+        CHAR  AsciiChar;
+    }
+    union {
+        WCHAR UnicodeChar;
+        CHAR  AsciiChar;
+        _uChar uChar;
+    }
+    DWORD dwControlKeyState;
+}
+alias KEY_EVENT_RECORD* PKEY_EVENT_RECORD;
+
+struct MOUSE_EVENT_RECORD {
+    COORD dwMousePosition;
+    DWORD dwButtonState;
+    DWORD dwControlKeyState;
+    DWORD dwEventFlags;
+}
+alias MOUSE_EVENT_RECORD* PMOUSE_EVENT_RECORD;
+
+struct WINDOW_BUFFER_SIZE_RECORD {
+    COORD dwSize;
+}
+alias WINDOW_BUFFER_SIZE_RECORD* PWINDOW_BUFFER_SIZE_RECORD;
+
+struct MENU_EVENT_RECORD {
+    UINT dwCommandId;
+}
+alias MENU_EVENT_RECORD* PMENU_EVENT_RECORD;
+
+struct FOCUS_EVENT_RECORD {
+    BOOL bSetFocus;
+}
+alias FOCUS_EVENT_RECORD* PFOCUS_EVENT_RECORD;
+
+struct INPUT_RECORD {
+    WORD EventType;
+    union _Event {
+        KEY_EVENT_RECORD KeyEvent;
+        MOUSE_EVENT_RECORD MouseEvent;
+        WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
+        MENU_EVENT_RECORD MenuEvent;
+        FOCUS_EVENT_RECORD FocusEvent;
+    }
+    union {
+        KEY_EVENT_RECORD KeyEvent;
+        MOUSE_EVENT_RECORD MouseEvent;
+        WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
+        MENU_EVENT_RECORD MenuEvent;
+        FOCUS_EVENT_RECORD FocusEvent;
+        _Event Event;
+    }
+}
+alias INPUT_RECORD* PINPUT_RECORD;
+
+extern (Windows) nothrow @nogc:
+
+BOOL AllocConsole();
+HANDLE CreateConsoleScreenBuffer(DWORD, DWORD, const(SECURITY_ATTRIBUTES)*, DWORD, LPVOID);
+BOOL FillConsoleOutputAttribute(HANDLE, WORD, DWORD, COORD, PDWORD);
+BOOL FillConsoleOutputCharacterA(HANDLE, CHAR, DWORD, COORD, PDWORD);
+BOOL FillConsoleOutputCharacterW(HANDLE, WCHAR, DWORD, COORD, PDWORD);
+BOOL FlushConsoleInputBuffer(HANDLE);
+BOOL FreeConsole();
+BOOL GenerateConsoleCtrlEvent(DWORD, DWORD);
+UINT GetConsoleCP();
+BOOL GetConsoleCursorInfo(HANDLE, PCONSOLE_CURSOR_INFO);
+BOOL GetConsoleMode(HANDLE,PDWORD);
+UINT GetConsoleOutputCP();
+BOOL GetConsoleScreenBufferInfo(HANDLE, PCONSOLE_SCREEN_BUFFER_INFO);
+DWORD GetConsoleTitleA(LPSTR, DWORD);
+DWORD GetConsoleTitleW(LPWSTR, DWORD);
+COORD GetLargestConsoleWindowSize(HANDLE);
+BOOL GetNumberOfConsoleInputEvents(HANDLE, PDWORD);
+BOOL GetNumberOfConsoleMouseButtons(PDWORD);
+BOOL PeekConsoleInputA(HANDLE, PINPUT_RECORD, DWORD, PDWORD);
+BOOL PeekConsoleInputW(HANDLE, PINPUT_RECORD, DWORD, PDWORD);
+BOOL ReadConsoleA(HANDLE, PVOID, DWORD, PDWORD, PVOID);
+BOOL ReadConsoleW(HANDLE, PVOID, DWORD, PDWORD, PVOID);
+BOOL ReadConsoleInputA(HANDLE, PINPUT_RECORD, DWORD, PDWORD);
+BOOL ReadConsoleInputW(HANDLE, PINPUT_RECORD, DWORD, PDWORD);
+BOOL ReadConsoleOutputAttribute(HANDLE, LPWORD, DWORD, COORD, LPDWORD);
+BOOL ReadConsoleOutputCharacterA(HANDLE, LPSTR, DWORD, COORD, PDWORD);
+BOOL ReadConsoleOutputCharacterW(HANDLE, LPWSTR, DWORD, COORD, PDWORD);
+BOOL ReadConsoleOutputA(HANDLE, PCHAR_INFO, COORD, COORD, PSMALL_RECT);
+BOOL ReadConsoleOutputW(HANDLE, PCHAR_INFO, COORD, COORD, PSMALL_RECT);
+BOOL ScrollConsoleScreenBufferA(HANDLE, const(SMALL_RECT)*, const(SMALL_RECT)*, COORD, const(CHAR_INFO)*);
+BOOL ScrollConsoleScreenBufferW(HANDLE, const(SMALL_RECT)*, const(SMALL_RECT)*, COORD, const(CHAR_INFO)*);
+BOOL SetConsoleActiveScreenBuffer(HANDLE);
+BOOL SetConsoleCP(UINT);
+BOOL SetConsoleCtrlHandler(PHANDLER_ROUTINE, BOOL);
+BOOL SetConsoleCursorInfo(HANDLE, const(CONSOLE_CURSOR_INFO)*);
+BOOL SetConsoleCursorPosition(HANDLE, COORD);
+
+
+static if (_WIN32_WINNT >= 0x500) {
+BOOL GetConsoleDisplayMode(LPDWORD);
+HWND GetConsoleWindow();
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+BOOL AttachConsole(DWORD);
+BOOL SetConsoleDisplayMode(HANDLE, DWORD, PCOORD);
+enum DWORD ATTACH_PARENT_PROCESS = cast(DWORD)-1;
+}
+
+BOOL SetConsoleMode(HANDLE, DWORD);
+BOOL SetConsoleOutputCP(UINT);
+BOOL SetConsoleScreenBufferSize(HANDLE, COORD);
+BOOL SetConsoleTextAttribute(HANDLE, WORD);
+BOOL SetConsoleTitleA(LPCSTR);
+BOOL SetConsoleTitleW(LPCWSTR);
+BOOL SetConsoleWindowInfo(HANDLE, BOOL, const(SMALL_RECT)*);
+BOOL WriteConsoleA(HANDLE, PCVOID, DWORD, PDWORD, PVOID);
+BOOL WriteConsoleW(HANDLE, PCVOID, DWORD, PDWORD, PVOID);
+BOOL WriteConsoleInputA(HANDLE, const(INPUT_RECORD)*, DWORD, PDWORD);
+BOOL WriteConsoleInputW(HANDLE, const(INPUT_RECORD)*, DWORD, PDWORD);
+BOOL WriteConsoleOutputA(HANDLE, const(CHAR_INFO)*, COORD, COORD, PSMALL_RECT);
+BOOL WriteConsoleOutputW(HANDLE, const(CHAR_INFO)*, COORD, COORD, PSMALL_RECT);
+BOOL WriteConsoleOutputAttribute(HANDLE, const(WORD)*, DWORD, COORD, PDWORD);
+BOOL WriteConsoleOutputCharacterA(HANDLE, LPCSTR, DWORD, COORD, PDWORD);
+BOOL WriteConsoleOutputCharacterW(HANDLE, LPCWSTR, DWORD, COORD, PDWORD);
+
+version (Unicode) {
+    alias FillConsoleOutputCharacterW FillConsoleOutputCharacter;
+    alias GetConsoleTitleW GetConsoleTitle;
+    alias PeekConsoleInputW PeekConsoleInput;
+    alias ReadConsoleW ReadConsole;
+    alias ReadConsoleInputW ReadConsoleInput;
+    alias ReadConsoleOutputW ReadConsoleOutput;
+    alias ReadConsoleOutputCharacterW ReadConsoleOutputCharacter;
+    alias ScrollConsoleScreenBufferW ScrollConsoleScreenBuffer;
+    alias SetConsoleTitleW SetConsoleTitle;
+    alias WriteConsoleW WriteConsole;
+    alias WriteConsoleInputW WriteConsoleInput;
+    alias WriteConsoleOutputW WriteConsoleOutput;
+    alias WriteConsoleOutputCharacterW WriteConsoleOutputCharacter;
+} else {
+    alias FillConsoleOutputCharacterA FillConsoleOutputCharacter;
+    alias GetConsoleTitleA GetConsoleTitle;
+    alias PeekConsoleInputA PeekConsoleInput;
+    alias ReadConsoleA ReadConsole;
+    alias ReadConsoleInputA ReadConsoleInput;
+    alias ReadConsoleOutputA ReadConsoleOutput;
+    alias ReadConsoleOutputCharacterA ReadConsoleOutputCharacter;
+    alias ScrollConsoleScreenBufferA ScrollConsoleScreenBuffer;
+    alias SetConsoleTitleA SetConsoleTitle;
+    alias WriteConsoleA WriteConsole;
+    alias WriteConsoleInputA WriteConsoleInput;
+    alias WriteConsoleOutputA WriteConsoleOutput;
+    alias WriteConsoleOutputCharacterA WriteConsoleOutputCharacter;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/wincrypt.d b/libphobos/libdruntime/core/sys/windows/wincrypt.d
new file mode 100644
index 00000000000..bb18532134f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/wincrypt.d
@@ -0,0 +1,902 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_wincrypt.d)
+ */
+module core.sys.windows.wincrypt;
+version (Windows):
+pragma(lib, "advapi32");
+
+version (ANSI) {} else version = Unicode;
+
+private import core.sys.windows.w32api, core.sys.windows.winbase, core.sys.windows.windef;
+
+/* FIXME:
+ *  Types of some constants
+ *  Types of macros
+ *  Inits of various "size" and "version" members
+ *  Why are some #ifdefs commented out?
+ */
+
+const TCHAR[]
+    MS_DEF_PROV = "Microsoft Base Cryptographic Provider v1.0",
+    MS_ENHANCED_PROV = "Microsoft Enhanced Cryptographic Provider v1.0",
+    MS_STRONG_PROV = "Microsoft Strong Cryptographic Provider",
+    MS_DEF_RSA_SIG_PROV = "Microsoft RSA Signature Cryptographic Provider",
+    MS_DEF_RSA_SCHANNEL_PROV = "Microsoft RSA SChannel Cryptographic Provider",
+    MS_DEF_DSS_PROV = "Microsoft Base DSS Cryptographic Provider",
+    MS_DEF_DSS_DH_PROV
+      = "Microsoft Base DSS and Diffie-Hellman Cryptographic Provider",
+    MS_ENH_DSS_DH_PROV
+      = "Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider",
+    MS_DEF_DH_SCHANNEL_PROV = "Microsoft DH SChannel Cryptographic Provider",
+    MS_SCARD_PROV = "Microsoft Base Smart Card Crypto Provider";
+
+static if (_WIN32_WINNT > 0x501) {
+const TCHAR[] MS_ENH_RSA_AES_PROV
+      = "Microsoft Enhanced RSA and AES Cryptographic Provider";
+} else static if (_WIN32_WINNT == 0x501) {
+const TCHAR[] MS_ENH_RSA_AES_PROV
+      = "Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)";
+}
+
+ALG_ID GET_ALG_CLASS(ALG_ID x) { return x & 0xE000; }
+ALG_ID GET_ALG_TYPE (ALG_ID x) { return x & 0x1E00; }
+ALG_ID GET_ALG_SID  (ALG_ID x) { return x & 0x01FF; }
+
+enum : ALG_ID {
+    ALG_CLASS_ANY           = 0,
+    ALG_CLASS_SIGNATURE     = 0x2000,
+    ALG_CLASS_MSG_ENCRYPT   = 0x4000,
+    ALG_CLASS_DATA_ENCRYPT  = 0x6000,
+    ALG_CLASS_HASH          = 0x8000,
+    ALG_CLASS_KEY_EXCHANGE  = 0xA000,
+    ALG_CLASS_ALL           = 0xE000
+}
+
+enum : ALG_ID {
+    ALG_TYPE_ANY           = 0,
+    ALG_TYPE_DSS           = 0x0200,
+    ALG_TYPE_RSA           = 0x0400,
+    ALG_TYPE_BLOCK         = 0x0600,
+    ALG_TYPE_STREAM        = 0x0800,
+    ALG_TYPE_DH            = 0x0A00,
+    ALG_TYPE_SECURECHANNEL = 0x0C00
+}
+
+enum : ALG_ID {
+    ALG_SID_ANY          =  0,
+    ALG_SID_RSA_ANY      =  0,
+    ALG_SID_RSA_PKCS,
+    ALG_SID_RSA_MSATWORK,
+    ALG_SID_RSA_ENTRUST,
+    ALG_SID_RSA_PGP,  // =  4
+    ALG_SID_DSS_ANY      =  0,
+    ALG_SID_DSS_PKCS,
+    ALG_SID_DSS_DMS,  // =  2
+    ALG_SID_DES          =  1,
+    ALG_SID_3DES         =  3,
+    ALG_SID_DESX,
+    ALG_SID_IDEA,
+    ALG_SID_CAST,
+    ALG_SID_SAFERSK64,
+    ALG_SID_SAFERSK128,
+    ALG_SID_3DES_112,
+    ALG_SID_SKIPJACK,
+    ALG_SID_TEK,
+    ALG_SID_CYLINK_MEK,
+    ALG_SID_RC5,      // = 13
+    ALG_SID_RC2          =  2,
+    ALG_SID_RC4          =  1,
+    ALG_SID_SEAL         =  2,
+    ALG_SID_MD2          =  1,
+    ALG_SID_MD4,
+    ALG_SID_MD5,
+    ALG_SID_SHA,
+    ALG_SID_MAC,
+    ALG_SID_RIPEMD,
+    ALG_SID_RIPEMD160,
+    ALG_SID_SSL3SHAMD5,
+    ALG_SID_HMAC,
+    ALG_SID_TLS1PRF,  // = 10
+    ALG_SID_AES_128      = 14,
+    ALG_SID_AES_192,
+    ALG_SID_AES_256,
+    ALG_SID_AES,      // = 17
+    ALG_SID_EXAMPLE      = 80
+}
+
+enum : ALG_ID {
+    CALG_MD2        = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD2,
+    CALG_MD4        = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD4,
+    CALG_MD5        = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD5,
+    CALG_SHA        = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA,
+    CALG_SHA1       = CALG_SHA,
+    CALG_MAC        = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MAC,
+    CALG_3DES       = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | 3,
+    CALG_CYLINK_MEK = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | 12,
+    CALG_SKIPJACK   = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | 10,
+    CALG_KEA_KEYX   = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_STREAM | ALG_TYPE_DSS | 4,
+    CALG_RSA_SIGN   = ALG_CLASS_SIGNATURE | ALG_TYPE_RSA | ALG_SID_RSA_ANY,
+    CALG_DSS_SIGN   = ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_DSS_ANY,
+    CALG_RSA_KEYX   = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_RSA | ALG_SID_RSA_ANY,
+    CALG_DES        = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DES,
+    CALG_RC2        = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_RC2,
+    CALG_RC4        = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_RC4,
+    CALG_SEAL       = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_SEAL,
+    CALG_DH_EPHEM   = ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_STREAM | ALG_TYPE_DSS
+                      | ALG_SID_DSS_DMS,
+    CALG_DESX       = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DESX,
+// is undefined ALG_CLASS_DHASH in MinGW - presuming typo
+    CALG_TLS1PRF    = ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_TLS1PRF,
+    CALG_AES_128    = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_128,
+    CALG_AES_192    = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_192,
+    CALG_AES_256    = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_256,
+    CALG_AES        = ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES,
+}
+
+enum {
+    CRYPT_VERIFYCONTEXT = 0xF0000000,
+}
+
+enum {
+    CRYPT_NEWKEYSET = 8,
+    CRYPT_DELETEKEYSET = 16,
+    CRYPT_MACHINE_KEYSET = 32,
+    CRYPT_SILENT = 64,
+}
+
+enum {
+    CRYPT_EXPORTABLE = 1,
+    CRYPT_USER_PROTECTED = 2,
+    CRYPT_CREATE_SALT = 4,
+    CRYPT_UPDATE_KEY = 8,
+}
+
+enum {
+    SIMPLEBLOB = 1,
+    PUBLICKEYBLOB = 6,
+    PRIVATEKEYBLOB = 7,
+    PLAINTEXTKEYBLOB = 8,
+    OPAQUEKEYBLOB = 9,
+    PUBLICKEYBLOBEX = 10,
+    SYMMETRICWRAPKEYBLOB = 11,
+}
+
+enum {
+    AT_KEYEXCHANGE = 1,
+    AT_SIGNATURE = 2,
+}
+
+enum {
+    CRYPT_USERDATA = 1,
+}
+
+enum {
+    PKCS5_PADDING = 1,
+}
+
+enum {
+    CRYPT_MODE_CBC = 1,
+    CRYPT_MODE_ECB = 2,
+    CRYPT_MODE_OFB = 3,
+    CRYPT_MODE_CFB = 4,
+    CRYPT_MODE_CTS = 5,
+    CRYPT_MODE_CBCI = 6,
+    CRYPT_MODE_CFBP = 7,
+    CRYPT_MODE_OFBP = 8,
+    CRYPT_MODE_CBCOFM = 9,
+    CRYPT_MODE_CBCOFMI = 10,
+}
+
+enum {
+    CRYPT_ENCRYPT = 1,
+    CRYPT_DECRYPT = 2,
+    CRYPT_EXPORT = 4,
+    CRYPT_READ = 8,
+    CRYPT_WRITE = 16,
+    CRYPT_MAC = 32,
+}
+
+enum {
+    HP_ALGID = 1,
+    HP_HASHVAL = 2,
+    HP_HASHSIZE = 4,
+    HP_HMAC_INFO = 5,
+}
+
+enum {
+    CRYPT_FAILED = FALSE,
+    CRYPT_SUCCEED = TRUE,
+}
+
+bool RCRYPT_SUCCEEDED(BOOL r) { return r==CRYPT_SUCCEED; }
+bool RCRYPT_FAILED(BOOL r) { return r==CRYPT_FAILED; }
+
+enum {
+    PP_ENUMALGS = 1,
+    PP_ENUMCONTAINERS = 2,
+    PP_IMPTYPE = 3,
+    PP_NAME = 4,
+    PP_VERSION = 5,
+    PP_CONTAINER = 6,
+    PP_CHANGE_PASSWORD  = 7,
+    PP_KEYSET_SEC_DESCR = 8,
+    PP_CERTCHAIN    = 9,
+    PP_KEY_TYPE_SUBTYPE = 10,
+    PP_PROVTYPE = 16,
+    PP_KEYSTORAGE   = 17,
+    PP_APPLI_CERT   = 18,
+    PP_SYM_KEYSIZE  = 19,
+    PP_SESSION_KEYSIZE  = 20,
+    PP_UI_PROMPT    = 21,
+    PP_ENUMALGS_EX  = 22,
+    PP_ENUMMANDROOTS = 25,
+    PP_ENUMELECTROOTS = 26,
+    PP_KEYSET_TYPE = 27,
+    PP_ADMIN_PIN = 31,
+    PP_KEYEXCHANGE_PIN = 32,
+    PP_SIGNATURE_PIN = 33,
+    PP_SIG_KEYSIZE_INC = 34,
+    PP_KEYX_KEYSIZE_INC = 35,
+    PP_UNIQUE_CONTAINER = 36,
+    PP_SGC_INFO = 37,
+    PP_USE_HARDWARE_RNG = 38,
+    PP_KEYSPEC = 39,
+    PP_ENUMEX_SIGNING_PROT = 40,
+}
+
+enum {
+    CRYPT_FIRST = 1,
+    CRYPT_NEXT = 2,
+}
+
+enum {
+    CRYPT_IMPL_HARDWARE = 1,
+    CRYPT_IMPL_SOFTWARE = 2,
+    CRYPT_IMPL_MIXED = 3,
+    CRYPT_IMPL_UNKNOWN = 4,
+}
+
+enum {
+    PROV_RSA_FULL = 1,
+    PROV_RSA_SIG = 2,
+    PROV_DSS = 3,
+    PROV_FORTEZZA = 4,
+    PROV_MS_MAIL = 5,
+    PROV_SSL = 6,
+    PROV_STT_MER = 7,
+    PROV_STT_ACQ = 8,
+    PROV_STT_BRND = 9,
+    PROV_STT_ROOT = 10,
+    PROV_STT_ISS = 11,
+    PROV_RSA_SCHANNEL = 12,
+    PROV_DSS_DH = 13,
+    PROV_EC_ECDSA_SIG = 14,
+    PROV_EC_ECNRA_SIG = 15,
+    PROV_EC_ECDSA_FULL = 16,
+    PROV_EC_ECNRA_FULL = 17,
+    PROV_DH_SCHANNEL = 18,
+    PROV_SPYRUS_LYNKS = 20,
+    PROV_RNG = 21,
+    PROV_INTEL_SEC = 22,
+    PROV_RSA_AES = 24,
+    MAXUIDLEN = 64,
+}
+
+enum {
+    CUR_BLOB_VERSION = 2,
+}
+
+enum {
+    X509_ASN_ENCODING = 1,
+    PKCS_7_ASN_ENCODING  = 65536,
+}
+
+enum {
+    CERT_V1 = 0,
+    CERT_V2 = 1,
+    CERT_V3 = 2,
+}
+
+enum {
+    CERT_E_CHAINING = (-2146762486),
+    CERT_E_CN_NO_MATCH = (-2146762481),
+    CERT_E_EXPIRED = (-2146762495),
+    CERT_E_PURPOSE = (-2146762490),
+    CERT_E_REVOCATION_FAILURE = (-2146762482),
+    CERT_E_REVOKED = (-2146762484),
+    CERT_E_ROLE = (-2146762493),
+    CERT_E_UNTRUSTEDROOT = (-2146762487),
+    CERT_E_UNTRUSTEDTESTROOT = (-2146762483),
+    CERT_E_VALIDITYPERIODNESTING = (-2146762494),
+    CERT_E_WRONG_USAGE = (-2146762480),
+    CERT_E_PATHLENCONST = (-2146762492),
+    CERT_E_CRITICAL = (-2146762491),
+    CERT_E_ISSUERCHAINING = (-2146762489),
+    CERT_E_MALFORMED = (-2146762488),
+    CRYPT_E_REVOCATION_OFFLINE = (-2146885613),
+    CRYPT_E_REVOKED = (-2146885616),
+    TRUST_E_BASIC_CONSTRAINTS = (-2146869223),
+    TRUST_E_CERT_SIGNATURE = (-2146869244),
+    TRUST_E_FAIL = (-2146762485),
+}
+
+enum {
+    CERT_TRUST_NO_ERROR = 0,
+    CERT_TRUST_IS_NOT_TIME_VALID = 1,
+    CERT_TRUST_IS_NOT_TIME_NESTED = 2,
+    CERT_TRUST_IS_REVOKED = 4,
+    CERT_TRUST_IS_NOT_SIGNATURE_VALID = 8,
+    CERT_TRUST_IS_NOT_VALID_FOR_USAGE = 16,
+    CERT_TRUST_IS_UNTRUSTED_ROOT = 32,
+    CERT_TRUST_REVOCATION_STATUS_UNKNOWN = 64,
+    CERT_TRUST_IS_CYCLIC = 128,
+    CERT_TRUST_IS_PARTIAL_CHAIN = 65536,
+    CERT_TRUST_CTL_IS_NOT_TIME_VALID = 131072,
+    CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID = 262144,
+    CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE = 524288,
+}
+
+enum {
+    CERT_TRUST_HAS_EXACT_MATCH_ISSUER = 1,
+    CERT_TRUST_HAS_KEY_MATCH_ISSUER = 2,
+    CERT_TRUST_HAS_NAME_MATCH_ISSUER = 4,
+    CERT_TRUST_IS_SELF_SIGNED = 8,
+    CERT_TRUST_IS_COMPLEX_CHAIN = 65536,
+}
+
+enum {
+    CERT_CHAIN_POLICY_BASE              = cast(LPCSTR) 1,
+    CERT_CHAIN_POLICY_AUTHENTICODE      = cast(LPCSTR) 2,
+    CERT_CHAIN_POLICY_AUTHENTICODE_TS   = cast(LPCSTR) 3,
+    CERT_CHAIN_POLICY_SSL               = cast(LPCSTR) 4,
+    CERT_CHAIN_POLICY_BASIC_CONSTRAINTS = cast(LPCSTR) 5,
+    CERT_CHAIN_POLICY_NT_AUTH           = cast(LPCSTR) 6,
+}
+
+enum {
+    USAGE_MATCH_TYPE_AND = 0,
+    USAGE_MATCH_TYPE_OR = 1,
+}
+
+enum {
+    CERT_SIMPLE_NAME_STR = 1,
+    CERT_OID_NAME_STR = 2,
+    CERT_X500_NAME_STR = 3,
+}
+enum {
+    CERT_NAME_STR_SEMICOLON_FLAG = 1073741824,
+    CERT_NAME_STR_CRLF_FLAG = 134217728,
+    CERT_NAME_STR_NO_PLUS_FLAG = 536870912,
+    CERT_NAME_STR_NO_QUOTING_FLAG = 268435456,
+    CERT_NAME_STR_REVERSE_FLAG = 33554432,
+    CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG = 131072,
+}
+
+enum {
+    CERT_FIND_ANY = 0,
+    CERT_FIND_CERT_ID = 1048576,
+    CERT_FIND_CTL_USAGE = 655360,
+    CERT_FIND_ENHKEY_USAGE = 655360,
+    CERT_FIND_EXISTING = 851968,
+    CERT_FIND_HASH = 65536,
+    CERT_FIND_ISSUER_ATTR = 196612,
+    CERT_FIND_ISSUER_NAME = 131076,
+    CERT_FIND_ISSUER_OF = 786432,
+    CERT_FIND_KEY_IDENTIFIER = 983040,
+    CERT_FIND_KEY_SPEC = 589824,
+    CERT_FIND_MD5_HASH = 262144,
+    CERT_FIND_PROPERTY = 327680,
+    CERT_FIND_PUBLIC_KEY = 393216,
+    CERT_FIND_SHA1_HASH = 65536,
+    CERT_FIND_SIGNATURE_HASH = 917504,
+    CERT_FIND_SUBJECT_ATTR = 196615,
+    CERT_FIND_SUBJECT_CERT = 720896,
+    CERT_FIND_SUBJECT_NAME = 131079,
+    CERT_FIND_SUBJECT_STR_A = 458759,
+    CERT_FIND_SUBJECT_STR_W = 524295,
+    CERT_FIND_ISSUER_STR_A = 458756,
+    CERT_FIND_ISSUER_STR_W = 524292,
+}
+
+enum {
+    CERT_FIND_OR_ENHKEY_USAGE_FLAG = 16,
+    CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG  = 1,
+    CERT_FIND_NO_ENHKEY_USAGE_FLAG  = 8,
+    CERT_FIND_VALID_ENHKEY_USAGE_FLAG  = 32,
+    CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG  = 2,
+}
+
+enum {
+    CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG  = 2,
+    CERT_UNICODE_IS_RDN_ATTRS_FLAG = 1,
+    CERT_CHAIN_FIND_BY_ISSUER = 1,
+}
+
+enum {
+    CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG = 1,
+    CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG = 2,
+    CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG = 4,
+    CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG = 8,
+    CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG = 16384,
+    CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG = 32768,
+}
+
+enum {
+    CERT_STORE_PROV_SYSTEM = 10,
+    CERT_SYSTEM_STORE_LOCAL_MACHINE = 131072,
+}
+
+enum {
+    szOID_PKIX_KP_SERVER_AUTH = "4235600",
+    szOID_SERVER_GATED_CRYPTO = "4235658",
+    szOID_SGC_NETSCAPE = "2.16.840.1.113730.4.1",
+    szOID_PKIX_KP_CLIENT_AUTH = "1.3.6.1.5.5.7.3.2",
+}
+
+enum {
+    CRYPT_NOHASHOID = 0x00000001,
+    CRYPT_NO_SALT = 0x10,
+    CRYPT_PREGEN = 0x40,
+}
+
+enum {
+    CRYPT_RECIPIENT = 0x10,
+    CRYPT_INITIATOR = 0x40,
+    CRYPT_ONLINE = 0x80,
+    CRYPT_SF = 0x100,
+    CRYPT_CREATE_IV = 0x200,
+    CRYPT_KEK = 0x400,
+    CRYPT_DATA_KEY = 0x800,
+    CRYPT_VOLATILE = 0x1000,
+    CRYPT_SGCKEY = 0x2000,
+}
+
+enum {
+    KP_IV               = 0x00000001,
+    KP_SALT             = 0x00000002,
+    KP_PADDING          = 0x00000003,
+    KP_MODE             = 0x00000004,
+    KP_MODE_BITS        = 0x00000005,
+    KP_PERMISSIONS      = 0x00000006,
+    KP_ALGID            = 0x00000007,
+    KP_BLOCKLEN         = 0x00000008,
+    KP_KEYLEN           = 0x00000009,
+    KP_SALT_EX          = 0x0000000a,
+    KP_P                = 0x0000000b,
+    KP_G                = 0x0000000c,
+    KP_Q                = 0x0000000d,
+    KP_X                = 0x0000000e,
+    KP_Y                = 0x0000000f,
+    KP_RA               = 0x00000010,
+    KP_RB               = 0x00000011,
+    KP_INFO             = 0x00000012,
+    KP_EFFECTIVE_KEYLEN = 0x00000013,
+    KP_SCHANNEL_ALG     = 0x00000014,
+    KP_PUB_PARAMS       = 0x00000027,
+}
+
+enum {
+    CRYPT_FLAG_PCT1    = 0x0001,
+    CRYPT_FLAG_SSL2    = 0x0002,
+    CRYPT_FLAG_SSL3    = 0x0004,
+    CRYPT_FLAG_TLS1    = 0x0008,
+    CRYPT_FLAG_IPSEC   = 0x0010,
+    CRYPT_FLAG_SIGNING = 0x0020,
+}
+
+enum {
+    SCHANNEL_MAC_KEY    = 0x00000000,
+    SCHANNEL_ENC_KEY    = 0x00000001,
+}
+
+enum {
+    INTERNATIONAL_USAGE = 0x00000001,
+}
+
+
+alias UINT ALG_ID;
+alias ULONG HCRYPTPROV, HCRYPTKEY, HCRYPTHASH;
+alias PVOID HCERTSTORE, HCRYPTMSG, HCERTCHAINENGINE;
+
+struct VTableProvStruc {
+    FARPROC FuncVerifyImage;
+}
+alias VTableProvStruc* PVTableProvStruc;
+
+struct _CRYPTOAPI_BLOB {
+    DWORD cbData;
+    BYTE* pbData;
+}
+alias _CRYPTOAPI_BLOB CRYPT_INTEGER_BLOB, CRYPT_UINT_BLOB,
+  CRYPT_OBJID_BLOB, CERT_NAME_BLOB, CERT_RDN_VALUE_BLOB, CERT_BLOB,
+  CRL_BLOB, DATA_BLOB, CRYPT_DATA_BLOB, CRYPT_HASH_BLOB,
+  CRYPT_DIGEST_BLOB, CRYPT_DER_BLOB, CRYPT_ATTR_BLOB;
+alias _CRYPTOAPI_BLOB* PCRYPT_INTEGER_BLOB, PCRYPT_UINT_BLOB,
+  PCRYPT_OBJID_BLOB, PCERT_NAME_BLOB, PCERT_RDN_VALUE_BLOB, PCERT_BLOB,
+  PCRL_BLOB, PDATA_BLOB, PCRYPT_DATA_BLOB, PCRYPT_HASH_BLOB,
+  PCRYPT_DIGEST_BLOB, PCRYPT_DER_BLOB, PCRYPT_ATTR_BLOB;
+
+// not described in SDK; has the same layout as HTTPSPolicyCallbackData
+struct SSL_EXTRA_CERT_CHAIN_POLICY_PARA {
+    DWORD  cbStruct;
+    DWORD  dwAuthType;
+    DWORD  fdwChecks;
+    LPWSTR pwszServerName;
+}
+alias SSL_EXTRA_CERT_CHAIN_POLICY_PARA HTTPSPolicyCallbackData;
+alias SSL_EXTRA_CERT_CHAIN_POLICY_PARA* PSSL_EXTRA_CERT_CHAIN_POLICY_PARA,
+  PHTTPSPolicyCallbackData;
+
+/* #if (_WIN32_WINNT>=0x500) */
+struct CERT_CHAIN_POLICY_PARA {
+    DWORD cbSize = CERT_CHAIN_POLICY_PARA.sizeof;
+    DWORD dwFlags;
+    void* pvExtraPolicyPara;
+}
+alias CERT_CHAIN_POLICY_PARA* PCERT_CHAIN_POLICY_PARA;
+
+struct CERT_CHAIN_POLICY_STATUS {
+    DWORD cbSize = CERT_CHAIN_POLICY_STATUS.sizeof;
+    DWORD dwError;
+    LONG  lChainIndex;
+    LONG  lElementIndex;
+    void* pvExtraPolicyStatus;
+}
+alias CERT_CHAIN_POLICY_STATUS* PCERT_CHAIN_POLICY_STATUS;
+/* #endif */
+
+struct CRYPT_ALGORITHM_IDENTIFIER {
+    LPSTR pszObjId;
+    CRYPT_OBJID_BLOB Parameters;
+}
+alias CRYPT_ALGORITHM_IDENTIFIER* PCRYPT_ALGORITHM_IDENTIFIER;
+
+struct CRYPT_BIT_BLOB {
+    DWORD cbData;
+    BYTE* pbData;
+    DWORD cUnusedBits;
+}
+alias CRYPT_BIT_BLOB* PCRYPT_BIT_BLOB;
+
+struct CERT_PUBLIC_KEY_INFO {
+    CRYPT_ALGORITHM_IDENTIFIER Algorithm;
+    CRYPT_BIT_BLOB             PublicKey;
+}
+alias CERT_PUBLIC_KEY_INFO* PCERT_PUBLIC_KEY_INFO;
+
+struct CERT_EXTENSION {
+    LPSTR            pszObjId;
+    BOOL             fCritical;
+    CRYPT_OBJID_BLOB Value;
+}
+alias CERT_EXTENSION* PCERT_EXTENSION;
+
+struct CERT_INFO {
+    DWORD dwVersion;
+    CRYPT_INTEGER_BLOB SerialNumber;
+    CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
+    CERT_NAME_BLOB Issuer;
+    FILETIME NotBefore;
+    FILETIME NotAfter;
+    CERT_NAME_BLOB Subject;
+    CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo;
+    CRYPT_BIT_BLOB IssuerUniqueId;
+    CRYPT_BIT_BLOB SubjectUniqueId;
+    DWORD cExtension;
+    PCERT_EXTENSION rgExtension;
+}
+alias CERT_INFO* PCERT_INFO;
+
+struct CERT_CONTEXT {
+    DWORD      dwCertEncodingType;
+    BYTE*      pbCertEncoded;
+    DWORD      cbCertEncoded;
+    PCERT_INFO pCertInfo;
+    HCERTSTORE hCertStore;
+}
+alias CERT_CONTEXT*        PCERT_CONTEXT;
+alias const(CERT_CONTEXT)* PCCERT_CONTEXT;
+
+struct CTL_USAGE {
+    DWORD  cUsageIdentifier;
+    LPSTR* rgpszUsageIdentifier;
+}
+alias CTL_USAGE CERT_ENHKEY_USAGE;
+alias CTL_USAGE* PCTRL_USAGE, PCERT_ENHKEY_USAGE;
+
+struct CERT_USAGE_MATCH {
+    DWORD             dwType;
+    CERT_ENHKEY_USAGE Usage;
+}
+alias CERT_USAGE_MATCH* PCERT_USAGE_MATCH;
+/* #if (_WIN32_WINNT>=0x500) */
+
+struct CERT_CHAIN_PARA {
+    DWORD            cbSize = CERT_CHAIN_PARA.sizeof;
+    CERT_USAGE_MATCH RequestedUsage;
+//#if CERT_CHAIN_PARA_HAS_EXTRA_FIELDS
+    CERT_USAGE_MATCH RequestedIssuancePolicy;
+    DWORD            dwUrlRetrievalTimeout;
+    BOOL             fCheckRevocationFreshnessTime;
+    DWORD            dwRevocationFreshnessTime;
+//#endif
+}
+alias CERT_CHAIN_PARA* PCERT_CHAIN_PARA;
+
+extern (Windows) alias BOOL function(PCCERT_CONTEXT, void*)
+  PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK;
+
+struct CERT_CHAIN_FIND_BY_ISSUER_PARA {
+    DWORD  cbSize = CERT_CHAIN_FIND_BY_ISSUER_PARA.sizeof;
+    LPCSTR pszUsageIdentifier;
+    DWORD  dwKeySpec;
+    DWORD  dwAcquirePrivateKeyFlags;
+    DWORD  cIssuer;
+    CERT_NAME_BLOB* rgIssuer;
+    PFN_CERT_CHAIN_FIND_BY_ISSUER_CALLBACK pfnFIndCallback;
+    void*  pvFindArg;
+    DWORD* pdwIssuerChainIndex;
+    DWORD* pdwIssuerElementIndex;
+}
+alias CERT_CHAIN_FIND_BY_ISSUER_PARA* PCERT_CHAIN_FIND_BY_ISSUER_PARA;
+/* #endif */
+
+struct CERT_TRUST_STATUS {
+    DWORD dwErrorStatus;
+    DWORD dwInfoStatus;
+}
+alias CERT_TRUST_STATUS* PCERT_TRUST_STATUS;
+
+struct CRL_ENTRY {
+    CRYPT_INTEGER_BLOB SerialNumber;
+    FILETIME           RevocationDate;
+    DWORD              cExtension;
+    PCERT_EXTENSION    rgExtension;
+}
+alias CRL_ENTRY* PCRL_ENTRY;
+
+struct CRL_INFO {
+    DWORD           dwVersion;
+    CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
+    CERT_NAME_BLOB  Issuer;
+    FILETIME        ThisUpdate;
+    FILETIME        NextUpdate;
+    DWORD           cCRLEntry;
+    PCRL_ENTRY      rgCRLEntry;
+    DWORD           cExtension;
+    PCERT_EXTENSION rgExtension;
+}
+alias CRL_INFO* PCRL_INFO;
+
+struct CRL_CONTEXT {
+    DWORD      dwCertEncodingType;
+    BYTE*      pbCrlEncoded;
+    DWORD      cbCrlEncoded;
+    PCRL_INFO  pCrlInfo;
+    HCERTSTORE hCertStore;
+}
+alias CRL_CONTEXT*        PCRL_CONTEXT;
+alias const(CRL_CONTEXT)* PCCRL_CONTEXT;
+
+struct CERT_REVOCATION_CRL_INFO {
+    DWORD         cbSize = CERT_REVOCATION_CRL_INFO.sizeof;
+    PCCRL_CONTEXT pBaseCRLContext;
+    PCCRL_CONTEXT pDeltaCRLContext;
+    PCRL_ENTRY    pCrlEntry;
+    BOOL          fDeltaCrlEntry;
+}
+alias CERT_REVOCATION_CRL_INFO* PCERT_REVOCATION_CRL_INFO;
+
+struct CERT_REVOCATION_INFO {
+    DWORD  cbSize = CERT_REVOCATION_INFO.sizeof;
+    DWORD  dwRevocationResult;
+    LPCSTR pszRevocationOid;
+    LPVOID pvOidSpecificInfo;
+    BOOL   fHasFreshnessTime;
+    DWORD  dwFreshnessTime;
+    PCERT_REVOCATION_CRL_INFO pCrlInfo;
+}
+alias CERT_REVOCATION_INFO* PCERT_REVOCATION_INFO;
+
+/* #if (_WIN32_WINNT>=0x500) */
+struct CERT_CHAIN_ELEMENT {
+    DWORD                 cbSize = CERT_CHAIN_ELEMENT.sizeof;
+    PCCERT_CONTEXT        pCertContext;
+    CERT_TRUST_STATUS     TrustStatus;
+    PCERT_REVOCATION_INFO pRevocationInfo;
+    PCERT_ENHKEY_USAGE    pIssuanceUsage;
+    PCERT_ENHKEY_USAGE    pApplicationUsage;
+}
+alias CERT_CHAIN_ELEMENT* PCERT_CHAIN_ELEMENT;
+/* #endif */
+
+struct CRYPT_ATTRIBUTE {
+    LPSTR            pszObjId;
+    DWORD            cValue;
+    PCRYPT_ATTR_BLOB rgValue;
+}
+alias CRYPT_ATTRIBUTE* PCRYPT_ATTRIBUTE;
+
+struct CTL_ENTRY {
+    CRYPT_DATA_BLOB  SubjectIdentifier;
+    DWORD            cAttribute;
+    PCRYPT_ATTRIBUTE rgAttribute;
+}
+alias CTL_ENTRY* PCTL_ENTRY;
+
+struct CTL_INFO {
+    DWORD              dwVersion;
+    CTL_USAGE          SubjectUsage;
+    CRYPT_DATA_BLOB    ListIdentifier;
+    CRYPT_INTEGER_BLOB SequenceNumber;
+    FILETIME           ThisUpdate;
+    FILETIME           NextUpdate;
+    CRYPT_ALGORITHM_IDENTIFIER SubjectAlgorithm;
+    DWORD              cCTLEntry;
+    PCTL_ENTRY         rgCTLEntry;
+    DWORD              cExtension;
+    PCERT_EXTENSION    rgExtension;
+}
+alias CTL_INFO* PCTL_INFO;
+
+struct CTL_CONTEXT {
+    DWORD      dwMsgAndCertEncodingType;
+    BYTE*      pbCtlEncoded;
+    DWORD      cbCtlEncoded;
+    PCTL_INFO  pCtlInfo;
+    HCERTSTORE hCertStore;
+    HCRYPTMSG  hCryptMsg;
+    BYTE*      pbCtlContent;
+    DWORD      cbCtlContent;
+}
+alias CTL_CONTEXT*        PCTL_CONTEXT;
+alias const(CTL_CONTEXT)* PCCTL_CONTEXT;
+
+struct CERT_TRUST_LIST_INFO {
+    DWORD         cbSize = CERT_TRUST_LIST_INFO.sizeof;
+    PCTL_ENTRY    pCtlEntry;
+    PCCTL_CONTEXT pCtlContext;
+}
+alias CERT_TRUST_LIST_INFO* PCERT_TRUST_LIST_INFO;
+
+struct CERT_SIMPLE_CHAIN {
+    DWORD                 cbSize = CERT_SIMPLE_CHAIN.sizeof;
+    CERT_TRUST_STATUS     TrustStatus;
+    DWORD                 cElement;
+    PCERT_CHAIN_ELEMENT*  rgpElement;
+    PCERT_TRUST_LIST_INFO pTrustListInfo;
+    BOOL                  fHasRevocationFreshnessTime;
+    DWORD                 dwRevocationFreshnessTime;
+}
+alias CERT_SIMPLE_CHAIN* PCERT_SIMPLE_CHAIN;
+
+/* #if (_WIN32_WINNT>=0x500) */
+alias const(CERT_CHAIN_CONTEXT)* PCCERT_CHAIN_CONTEXT;
+struct CERT_CHAIN_CONTEXT {
+    DWORD                 cbSize = CERT_CHAIN_CONTEXT.sizeof;
+    CERT_TRUST_STATUS     TrustStatus;
+    DWORD                 cChain;
+    PCERT_SIMPLE_CHAIN*   rgpChain;
+    DWORD                 cLowerQualityChainContext;
+    PCCERT_CHAIN_CONTEXT* rgpLowerQualityChainContext;
+    BOOL                  fHasRevocationFreshnessTime;
+    DWORD                 dwRevocationFreshnessTime;
+}
+alias CERT_CHAIN_CONTEXT* PCERT_CHAIN_CONTEXT;
+/* #endif */
+
+struct PROV_ENUMALGS {
+    ALG_ID   aiAlgid;
+    DWORD    dwBitLen;
+    DWORD    dwNameLen;
+    CHAR[20] szName;
+}
+
+struct PUBLICKEYSTRUC {
+    BYTE   bType;
+    BYTE   bVersion;
+    WORD   reserved;
+    ALG_ID aiKeyAlg;
+}
+alias PUBLICKEYSTRUC BLOBHEADER;
+
+struct RSAPUBKEY {
+    DWORD magic;
+    DWORD bitlen;
+    DWORD pubexp;
+}
+
+struct HMAC_INFO {
+    ALG_ID HashAlgid;
+    BYTE*  pbInnerString;
+    DWORD  cbInnerString;
+    BYTE*  pbOuterString;
+    DWORD  cbOuterString;
+}
+alias HMAC_INFO* PHMAC_INFO;
+
+extern (Windows) {
+    BOOL CertCloseStore(HCERTSTORE, DWORD);
+    BOOL CertGetCertificateChain(HCERTCHAINENGINE, PCCERT_CONTEXT, LPFILETIME,
+      HCERTSTORE, PCERT_CHAIN_PARA, DWORD, LPVOID, PCCERT_CHAIN_CONTEXT*);
+    BOOL CertVerifyCertificateChainPolicy(LPCSTR, PCCERT_CHAIN_CONTEXT,
+      PCERT_CHAIN_POLICY_PARA, PCERT_CHAIN_POLICY_STATUS);
+    void CertFreeCertificateChain(PCCERT_CHAIN_CONTEXT);
+    DWORD CertNameToStrA(DWORD, PCERT_NAME_BLOB, DWORD, LPSTR, DWORD);
+    DWORD CertNameToStrW(DWORD, PCERT_NAME_BLOB, DWORD, LPWSTR, DWORD);
+    HCERTSTORE CertOpenSystemStoreA(HCRYPTPROV, LPCSTR);
+    HCERTSTORE CertOpenSystemStoreW(HCRYPTPROV, LPCWSTR);
+    HCERTSTORE CertOpenStore(LPCSTR, DWORD, HCRYPTPROV, DWORD, const(void)*);
+    PCCERT_CONTEXT CertFindCertificateInStore(HCERTSTORE, DWORD, DWORD, DWORD,
+const(void)*, PCCERT_CONTEXT);
+    BOOL CertFreeCertificateContext(PCCERT_CONTEXT);
+    PCCERT_CONTEXT CertGetIssuerCertificateFromStore(HCERTSTORE,
+      PCCERT_CONTEXT, PCCERT_CONTEXT, DWORD*);
+    PCCERT_CHAIN_CONTEXT CertFindChainInStore(HCERTSTORE, DWORD, DWORD, DWORD,
+const(void)*, PCCERT_CHAIN_CONTEXT);
+
+    BOOL CryptAcquireContextA(HCRYPTPROV*, LPCSTR, LPCSTR, DWORD, DWORD);
+    BOOL CryptAcquireContextW(HCRYPTPROV*, LPCWSTR, LPCWSTR, DWORD, DWORD);
+     BOOL CryptContextAddRef(HCRYPTPROV, DWORD*, DWORD);
+    BOOL CryptReleaseContext(HCRYPTPROV, DWORD);
+    BOOL CryptGenKey(HCRYPTPROV, ALG_ID, DWORD, HCRYPTKEY*);
+    BOOL CryptDeriveKey(HCRYPTPROV, ALG_ID, HCRYPTHASH, DWORD, HCRYPTKEY*);
+    BOOL CryptDestroyKey(HCRYPTKEY);
+    static if (_WIN32_WINNT >= 0x500) {
+        BOOL CryptDuplicateHash(HCRYPTHASH, DWORD*, DWORD, HCRYPTHASH*);
+        BOOL CryptDuplicateKey(HCRYPTKEY, DWORD*, DWORD, HCRYPTKEY*);
+    }
+    BOOL CryptSetKeyParam(HCRYPTKEY, DWORD, PBYTE, DWORD);
+    BOOL CryptGetKeyParam(HCRYPTKEY, DWORD, PBYTE, PDWORD, DWORD);
+    BOOL CryptSetHashParam(HCRYPTHASH, DWORD, PBYTE, DWORD);
+    BOOL CryptGetHashParam(HCRYPTHASH, DWORD, PBYTE, PDWORD, DWORD);
+    BOOL CryptSetProvParam(HCRYPTPROV, DWORD, PBYTE, DWORD);
+    BOOL CryptGetProvParam(HCRYPTPROV, DWORD, PBYTE, PDWORD, DWORD);
+    BOOL CryptGenRandom(HCRYPTPROV, DWORD, PBYTE);
+    BOOL CryptGetUserKey(HCRYPTPROV, DWORD, HCRYPTKEY*);
+    BOOL CryptExportKey(HCRYPTKEY, HCRYPTKEY, DWORD, DWORD, PBYTE, PDWORD);
+    BOOL CryptImportKey(HCRYPTPROV, PBYTE, DWORD, HCRYPTKEY, DWORD,
+      HCRYPTKEY*);
+    BOOL CryptEncrypt(HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, PBYTE, PDWORD,
+      DWORD);
+    BOOL CryptDecrypt(HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, PBYTE, PDWORD);
+    BOOL CryptCreateHash(HCRYPTPROV, ALG_ID, HCRYPTKEY, DWORD, HCRYPTHASH*);
+    BOOL CryptHashData(HCRYPTHASH, PBYTE, DWORD, DWORD);
+    BOOL CryptHashSessionKey(HCRYPTHASH, HCRYPTKEY, DWORD);
+    BOOL CryptGetHashValue(HCRYPTHASH, DWORD, PBYTE, PDWORD);
+    BOOL CryptDestroyHash(HCRYPTHASH);
+    BOOL CryptSignHashA(HCRYPTHASH, DWORD, LPCSTR, DWORD, PBYTE, PDWORD);
+    BOOL CryptSignHashW(HCRYPTHASH, DWORD, LPCWSTR, DWORD, PBYTE, PDWORD);
+    BOOL CryptVerifySignatureA(HCRYPTHASH, PBYTE, DWORD, HCRYPTKEY, LPCSTR,
+      DWORD);
+    BOOL CryptVerifySignatureW(HCRYPTHASH, PBYTE, DWORD, HCRYPTKEY, LPCWSTR,
+      DWORD);
+    BOOL CryptSetProviderA(LPCSTR, DWORD);
+    BOOL CryptSetProviderW(LPCWSTR, DWORD);
+}
+
+version (Unicode) {
+    alias CertNameToStrW CertNameToStr;
+    alias CryptAcquireContextW CryptAcquireContext;
+    alias CryptSignHashW CryptSignHash;
+    alias CryptVerifySignatureW CryptVerifySignature;
+    alias CryptSetProviderW CryptSetProvider;
+    alias CertOpenSystemStoreW CertOpenSystemStore;
+    /+alias CERT_FIND_SUBJECT_STR_W CERT_FIND_SUBJECT_STR;
+    alias CERT_FIND_ISSUER_STR_W CERT_FIND_ISSUER_STR;+/
+} else {
+    alias CertNameToStrA CertNameToStr;
+    alias CryptAcquireContextA CryptAcquireContext;
+    alias CryptSignHashA CryptSignHash;
+    alias CryptVerifySignatureA CryptVerifySignature;
+    alias CryptSetProviderA CryptSetProvider;
+    alias CertOpenSystemStoreA CertOpenSystemStore;
+    /+alias CERT_FIND_SUBJECT_STR_A CERT_FIND_SUBJECT_STR;
+    alias CERT_FIND_ISSUER_STR_A CERT_FIND_ISSUER_STR;+/
+}
diff --git a/libphobos/libdruntime/core/sys/windows/windef.d b/libphobos/libdruntime/core/sys/windows/windef.d
new file mode 100644
index 00000000000..25cf0440657
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/windef.d
@@ -0,0 +1,151 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_windef.d)
+ */
+module core.sys.windows.windef;
+version (Windows):
+
+public import core.sys.windows.winnt;
+private import core.sys.windows.w32api;
+
+enum size_t MAX_PATH = 260;
+
+pure nothrow @nogc {
+    ushort MAKEWORD(ubyte a, ubyte b) {
+        return cast(ushort) ((b << 8) | a);
+    }
+
+    ushort MAKEWORD(ushort a, ushort b) {
+        assert((a & 0xFF00) == 0);
+        assert((b & 0xFF00) == 0);
+        return MAKEWORD(cast(ubyte)a, cast(ubyte)b);
+    }
+
+    uint MAKELONG(ushort a, ushort b) {
+        return cast(uint) ((b << 16) | a);
+    }
+
+    uint MAKELONG(uint a, uint b) {
+        assert((a & 0xFFFF0000) == 0);
+        assert((b & 0xFFFF0000) == 0);
+        return MAKELONG(cast(ushort)a, cast(ushort)b);
+    }
+
+    ushort LOWORD(ulong l) {
+        return cast(ushort) l;
+    }
+
+    ushort HIWORD(ulong l) {
+        return cast(ushort) (l >>> 16);
+    }
+
+    ubyte LOBYTE(ushort w) {
+        return cast(ubyte) w;
+    }
+
+    ubyte HIBYTE(ushort w) {
+        return cast(ubyte) (w >>> 8);
+    }
+}
+
+enum NULL = null;
+static assert (is(typeof({
+    void test(int* p) {}
+    test(NULL);
+})));
+
+alias ubyte        BYTE;
+alias ubyte*       PBYTE, LPBYTE;
+alias ushort       USHORT, WORD, ATOM;
+alias ushort*      PUSHORT, PWORD, LPWORD;
+alias uint         ULONG, DWORD, UINT, COLORREF;
+alias uint*        PULONG, PDWORD, LPDWORD, PUINT, LPUINT, LPCOLORREF;
+alias int          WINBOOL, BOOL, INT, LONG, HFILE, HRESULT;
+alias int*         PWINBOOL, LPWINBOOL, PBOOL, LPBOOL, PINT, LPINT, LPLONG;
+alias float        FLOAT;
+alias float*       PFLOAT;
+alias const(void)* PCVOID, LPCVOID;
+
+alias UINT_PTR WPARAM;
+alias LONG_PTR LPARAM, LRESULT;
+
+mixin DECLARE_HANDLE!("HHOOK");
+mixin DECLARE_HANDLE!("HGLOBAL");
+mixin DECLARE_HANDLE!("HLOCAL");
+mixin DECLARE_HANDLE!("GLOBALHANDLE");
+mixin DECLARE_HANDLE!("LOCALHANDLE");
+mixin DECLARE_HANDLE!("HGDIOBJ");
+mixin DECLARE_HANDLE!("HACCEL");
+mixin DECLARE_HANDLE!("HBITMAP", HGDIOBJ);
+mixin DECLARE_HANDLE!("HBRUSH", HGDIOBJ);
+mixin DECLARE_HANDLE!("HCOLORSPACE");
+mixin DECLARE_HANDLE!("HDC");
+mixin DECLARE_HANDLE!("HGLRC");
+mixin DECLARE_HANDLE!("HDESK");
+mixin DECLARE_HANDLE!("HENHMETAFILE");
+mixin DECLARE_HANDLE!("HFONT", HGDIOBJ);
+mixin DECLARE_HANDLE!("HICON");
+mixin DECLARE_HANDLE!("HINSTANCE");
+mixin DECLARE_HANDLE!("HKEY");
+mixin DECLARE_HANDLE!("HMENU");
+mixin DECLARE_HANDLE!("HMETAFILE");
+mixin DECLARE_HANDLE!("HMODULE");
+mixin DECLARE_HANDLE!("HMONITOR");
+mixin DECLARE_HANDLE!("HPALETTE");
+mixin DECLARE_HANDLE!("HPEN", HGDIOBJ);
+mixin DECLARE_HANDLE!("HRGN", HGDIOBJ);
+mixin DECLARE_HANDLE!("HRSRC");
+mixin DECLARE_HANDLE!("HSTR");
+mixin DECLARE_HANDLE!("HTASK");
+mixin DECLARE_HANDLE!("HWND");
+mixin DECLARE_HANDLE!("HWINSTA");
+mixin DECLARE_HANDLE!("HKL");
+mixin DECLARE_HANDLE!("HCURSOR");
+alias HKEY* PHKEY;
+
+static if (_WIN32_WINNT >= 0x500) {
+    mixin DECLARE_HANDLE!("HTERMINAL");
+    mixin DECLARE_HANDLE!("HWINEVENTHOOK");
+}
+
+alias extern (Windows) INT_PTR function() nothrow FARPROC, NEARPROC, PROC;
+
+struct RECT {
+    LONG left;
+    LONG top;
+    LONG right;
+    LONG bottom;
+}
+alias RECT RECTL;
+alias RECT*        PRECT, NPRECT, LPRECT, PRECTL, LPRECTL;
+alias const(RECT)* LPCRECT, LPCRECTL;
+
+struct POINT {
+    LONG x;
+    LONG y;
+}
+alias POINT POINTL;
+alias POINT* PPOINT, NPPOINT, LPPOINT, PPOINTL, LPPOINTL;
+
+struct SIZE {
+    LONG cx;
+    LONG cy;
+}
+alias SIZE SIZEL;
+alias SIZE* PSIZE, LPSIZE, PSIZEL, LPSIZEL;
+
+struct POINTS {
+    SHORT x;
+    SHORT y;
+}
+alias POINTS* PPOINTS, LPPOINTS;
+
+enum : BOOL {
+    FALSE = 0,
+    TRUE  = 1
+}
diff --git a/libphobos/libdruntime/core/sys/windows/windows.d b/libphobos/libdruntime/core/sys/windows/windows.d
new file mode 100644
index 00000000000..b4747392402
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/windows.d
@@ -0,0 +1,73 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 4.0
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_windows.d)
+ */
+module core.sys.windows.windows;
+version (Windows):
+
+/*
+    windows.h - main header file for the Win32 API
+
+    Written by Anders Norlander <anorland@hem2.passagen.se>
+
+    This file is part of a free library for the Win32 API.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+*/
+
+public import core.sys.windows.w32api;
+public import core.sys.windows.core;
+
+public import core.sys.windows.cderr;
+public import core.sys.windows.dde;
+public import core.sys.windows.ddeml;
+public import core.sys.windows.dlgs;
+public import core.sys.windows.imm;
+public import core.sys.windows.lzexpand;
+public import core.sys.windows.mmsystem;
+public import core.sys.windows.nb30;
+public import core.sys.windows.winsvc;
+
+public import core.sys.windows.rpc;
+public import core.sys.windows.shellapi;
+public import core.sys.windows.winperf;
+public import core.sys.windows.commdlg;
+public import core.sys.windows.winspool;
+public import core.sys.windows.ole2;
+
+public import core.sys.windows.winreg;
+
+
+// Select correct version of winsock.  Importing the incorrect
+// module will cause a static assert to prevent problems later on.
+version (Win32_Winsock1) {
+    public import core.sys.windows.winsock;
+} else {
+    public import core.sys.windows.winsock2;
+    //public import core.sys.windows.ws2tcpip;
+}
+
+/+
+#if (_WIN32_WINNT >= 0x400)
+#include <winsock2.h>
+/*
+ * MS likes to include mswsock.h here as well,
+ * but that can cause undefined symbols if
+ * winsock2.h is included before windows.h
+ */
+#else
+#include <winsock.h>
+#endif /*  (_WIN32_WINNT >= 0x400) */
++/
+
+// For compatibility with previous
+// core.sys.windows.windows...
+public import core.sys.windows.imagehlp;
+public import core.sys.windows.dbghelp_types;
diff --git a/libphobos/libdruntime/core/sys/windows/winerror.d b/libphobos/libdruntime/core/sys/windows/winerror.d
new file mode 100644
index 00000000000..1f9a5e5af37
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winerror.d
@@ -0,0 +1,2312 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winerror.d)
+ */
+module core.sys.windows.winerror;
+version (Windows):
+
+/* Comments from the Mingw header:
+ * WAIT_TIMEOUT is also defined in winbase.h
+ */
+
+private import core.sys.windows.windef;
+
+alias int SCODE; // was in core.sys.windows.wtypes.
+
+enum : uint {
+    ERROR_SUCCESS                                         =     0,
+    NO_ERROR                                              =     0,
+    ERROR_INVALID_FUNCTION,
+    ERROR_FILE_NOT_FOUND,
+    ERROR_PATH_NOT_FOUND,
+    ERROR_TOO_MANY_OPEN_FILES,
+    ERROR_ACCESS_DENIED,
+    ERROR_INVALID_HANDLE,
+    ERROR_ARENA_TRASHED,
+    ERROR_NOT_ENOUGH_MEMORY,
+    ERROR_INVALID_BLOCK,
+    ERROR_BAD_ENVIRONMENT,
+    ERROR_BAD_FORMAT,
+    ERROR_INVALID_ACCESS,
+    ERROR_INVALID_DATA,
+    ERROR_OUTOFMEMORY,
+    ERROR_INVALID_DRIVE,
+    ERROR_CURRENT_DIRECTORY,
+    ERROR_NOT_SAME_DEVICE,
+    ERROR_NO_MORE_FILES,
+    ERROR_WRITE_PROTECT,
+    ERROR_BAD_UNIT,
+    ERROR_NOT_READY,
+    ERROR_BAD_COMMAND,
+    ERROR_CRC,
+    ERROR_BAD_LENGTH,
+    ERROR_SEEK,
+    ERROR_NOT_DOS_DISK,
+    ERROR_SECTOR_NOT_FOUND,
+    ERROR_OUT_OF_PAPER,
+    ERROR_WRITE_FAULT,
+    ERROR_READ_FAULT,
+    ERROR_GEN_FAILURE,
+    ERROR_SHARING_VIOLATION,
+    ERROR_LOCK_VIOLATION,
+    ERROR_WRONG_DISK,                                  // =    34
+    ERROR_SHARING_BUFFER_EXCEEDED                         =    36,
+    ERROR_HANDLE_EOF                                      =    38,
+    ERROR_HANDLE_DISK_FULL,                            // =    39
+    ERROR_NOT_SUPPORTED                                   =    50,
+    ERROR_REM_NOT_LIST,
+    ERROR_DUP_NAME,
+    ERROR_BAD_NETPATH,
+    ERROR_NETWORK_BUSY,
+    ERROR_DEV_NOT_EXIST,
+    ERROR_TOO_MANY_CMDS,
+    ERROR_ADAP_HDW_ERR,
+    ERROR_BAD_NET_RESP,
+    ERROR_UNEXP_NET_ERR,
+    ERROR_BAD_REM_ADAP,
+    ERROR_PRINTQ_FULL,
+    ERROR_NO_SPOOL_SPACE,
+    ERROR_PRINT_CANCELLED,
+    ERROR_NETNAME_DELETED,
+    ERROR_NETWORK_ACCESS_DENIED,
+    ERROR_BAD_DEV_TYPE,
+    ERROR_BAD_NET_NAME,
+    ERROR_TOO_MANY_NAMES,
+    ERROR_TOO_MANY_SESS,
+    ERROR_SHARING_PAUSED,
+    ERROR_REQ_NOT_ACCEP,
+    ERROR_REDIR_PAUSED,                                // =    72
+    ERROR_FILE_EXISTS                                     =    80,
+    ERROR_CANNOT_MAKE                                     =    82,
+    ERROR_FAIL_I24,
+    ERROR_OUT_OF_STRUCTURES,
+    ERROR_ALREADY_ASSIGNED,
+    ERROR_INVALID_PASSWORD,
+    ERROR_INVALID_PARAMETER,
+    ERROR_NET_WRITE_FAULT,
+    ERROR_NO_PROC_SLOTS,                               // =    89
+    ERROR_TOO_MANY_SEMAPHORES                             =   100,
+    ERROR_EXCL_SEM_ALREADY_OWNED,
+    ERROR_SEM_IS_SET,
+    ERROR_TOO_MANY_SEM_REQUESTS,
+    ERROR_INVALID_AT_INTERRUPT_TIME,
+    ERROR_SEM_OWNER_DIED,
+    ERROR_SEM_USER_LIMIT,
+    ERROR_DISK_CHANGE,
+    ERROR_DRIVE_LOCKED,
+    ERROR_BROKEN_PIPE,
+    ERROR_OPEN_FAILED,
+    ERROR_BUFFER_OVERFLOW,
+    ERROR_DISK_FULL,
+    ERROR_NO_MORE_SEARCH_HANDLES,
+    ERROR_INVALID_TARGET_HANDLE,                       // =   114
+    ERROR_INVALID_CATEGORY                                =   117,
+    ERROR_INVALID_VERIFY_SWITCH,
+    ERROR_BAD_DRIVER_LEVEL,
+    ERROR_CALL_NOT_IMPLEMENTED,
+    ERROR_SEM_TIMEOUT,
+    ERROR_INSUFFICIENT_BUFFER,
+    ERROR_INVALID_NAME,
+    ERROR_INVALID_LEVEL,
+    ERROR_NO_VOLUME_LABEL,
+    ERROR_MOD_NOT_FOUND,
+    ERROR_PROC_NOT_FOUND,
+    ERROR_WAIT_NO_CHILDREN,
+    ERROR_CHILD_NOT_COMPLETE,
+    ERROR_DIRECT_ACCESS_HANDLE,
+    ERROR_NEGATIVE_SEEK,
+    ERROR_SEEK_ON_DEVICE,
+    ERROR_IS_JOIN_TARGET,
+    ERROR_IS_JOINED,
+    ERROR_IS_SUBSTED,
+    ERROR_NOT_JOINED,
+    ERROR_NOT_SUBSTED,
+    ERROR_JOIN_TO_JOIN,
+    ERROR_SUBST_TO_SUBST,
+    ERROR_JOIN_TO_SUBST,
+    ERROR_SUBST_TO_JOIN,
+    ERROR_BUSY_DRIVE,
+    ERROR_SAME_DRIVE,
+    ERROR_DIR_NOT_ROOT,
+    ERROR_DIR_NOT_EMPTY,
+    ERROR_IS_SUBST_PATH,
+    ERROR_IS_JOIN_PATH,
+    ERROR_PATH_BUSY,
+    ERROR_IS_SUBST_TARGET,
+    ERROR_SYSTEM_TRACE,
+    ERROR_INVALID_EVENT_COUNT,
+    ERROR_TOO_MANY_MUXWAITERS,
+    ERROR_INVALID_LIST_FORMAT,
+    ERROR_LABEL_TOO_LONG,
+    ERROR_TOO_MANY_TCBS,
+    ERROR_SIGNAL_REFUSED,
+    ERROR_DISCARDED,
+    ERROR_NOT_LOCKED,
+    ERROR_BAD_THREADID_ADDR,
+    ERROR_BAD_ARGUMENTS,
+    ERROR_BAD_PATHNAME,
+    ERROR_SIGNAL_PENDING,                              // =   162
+    ERROR_MAX_THRDS_REACHED                               =   164,
+    ERROR_LOCK_FAILED                                     =   167,
+    ERROR_BUSY                                            =   170,
+    ERROR_CANCEL_VIOLATION                                =   173,
+    ERROR_ATOMIC_LOCKS_NOT_SUPPORTED,                  // =   174
+    ERROR_INVALID_SEGMENT_NUMBER                          =   180,
+    ERROR_INVALID_ORDINAL                                 =   182,
+    ERROR_ALREADY_EXISTS,                              // =   183
+    ERROR_INVALID_FLAG_NUMBER                             =   186,
+    ERROR_SEM_NOT_FOUND,
+    ERROR_INVALID_STARTING_CODESEG,
+    ERROR_INVALID_STACKSEG,
+    ERROR_INVALID_MODULETYPE,
+    ERROR_INVALID_EXE_SIGNATURE,
+    ERROR_EXE_MARKED_INVALID,
+    ERROR_BAD_EXE_FORMAT,
+    ERROR_ITERATED_DATA_EXCEEDS_64k,
+    ERROR_INVALID_MINALLOCSIZE,
+    ERROR_DYNLINK_FROM_INVALID_RING,
+    ERROR_IOPL_NOT_ENABLED,
+    ERROR_INVALID_SEGDPL,
+    ERROR_AUTODATASEG_EXCEEDS_64k,
+    ERROR_RING2SEG_MUST_BE_MOVABLE,
+    ERROR_RELOC_CHAIN_XEEDS_SEGLIM,
+    ERROR_INFLOOP_IN_RELOC_CHAIN,
+    ERROR_ENVVAR_NOT_FOUND,                            // =   203
+    ERROR_NO_SIGNAL_SENT                                  =   205,
+    ERROR_FILENAME_EXCED_RANGE,
+    ERROR_RING2_STACK_IN_USE,
+    ERROR_META_EXPANSION_TOO_LONG,
+    ERROR_INVALID_SIGNAL_NUMBER,
+    ERROR_THREAD_1_INACTIVE,                           // =   210
+    ERROR_LOCKED                                          =   212,
+    ERROR_TOO_MANY_MODULES                                =   214,
+    ERROR_NESTING_NOT_ALLOWED,
+    ERROR_EXE_MACHINE_TYPE_MISMATCH,
+    ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY,
+    ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY,      // =   218
+    ERROR_BAD_PIPE                                        =   230,
+    ERROR_PIPE_BUSY,
+    ERROR_NO_DATA,
+    ERROR_PIPE_NOT_CONNECTED,
+    ERROR_MORE_DATA,                                   // =   234
+    ERROR_VC_DISCONNECTED                                 =   240,
+    ERROR_INVALID_EA_NAME                                 =   254,
+    ERROR_EA_LIST_INCONSISTENT,                        // =   255
+    WAIT_TIMEOUT                                          =   258,
+    ERROR_NO_MORE_ITEMS,                               // =   259
+    ERROR_CANNOT_COPY                                     =   266,
+    ERROR_DIRECTORY,                                   // =   267
+    ERROR_EAS_DIDNT_FIT                                   =   275,
+    ERROR_EA_FILE_CORRUPT,
+    ERROR_EA_TABLE_FULL,
+    ERROR_INVALID_EA_HANDLE,                           // =   278
+    ERROR_EAS_NOT_SUPPORTED                               =   282,
+    ERROR_NOT_OWNER                                       =   288,
+    ERROR_TOO_MANY_POSTS                                  =   298,
+    ERROR_PARTIAL_COPY,
+    ERROR_OPLOCK_NOT_GRANTED,
+    ERROR_INVALID_OPLOCK_PROTOCOL,
+    ERROR_DISK_TOO_FRAGMENTED,
+    ERROR_DELETE_PENDING,                              // =   303
+    ERROR_MR_MID_NOT_FOUND                                =   317,
+    ERROR_SCOPE_NOT_FOUND,                             // =   318
+    ERROR_INVALID_ADDRESS                                 =   487,
+    ERROR_ARITHMETIC_OVERFLOW                             =   534,
+    ERROR_PIPE_CONNECTED,
+    ERROR_PIPE_LISTENING,                              // =   536
+    ERROR_EA_ACCESS_DENIED                                =   994,
+    ERROR_OPERATION_ABORTED,
+    ERROR_IO_INCOMPLETE,
+    ERROR_IO_PENDING,
+    ERROR_NOACCESS,
+    ERROR_SWAPERROR,                                   // =   999
+    ERROR_STACK_OVERFLOW                                  =  1001,
+    ERROR_INVALID_MESSAGE,
+    ERROR_CAN_NOT_COMPLETE,
+    ERROR_INVALID_FLAGS,
+    ERROR_UNRECOGNIZED_VOLUME,
+    ERROR_FILE_INVALID,
+    ERROR_FULLSCREEN_MODE,
+    ERROR_NO_TOKEN,
+    ERROR_BADDB,
+    ERROR_BADKEY,
+    ERROR_CANTOPEN,
+    ERROR_CANTREAD,
+    ERROR_CANTWRITE,
+    ERROR_REGISTRY_RECOVERED,
+    ERROR_REGISTRY_CORRUPT,
+    ERROR_REGISTRY_IO_FAILED,
+    ERROR_NOT_REGISTRY_FILE,
+    ERROR_KEY_DELETED,
+    ERROR_NO_LOG_SPACE,
+    ERROR_KEY_HAS_CHILDREN,
+    ERROR_CHILD_MUST_BE_VOLATILE,
+    ERROR_NOTIFY_ENUM_DIR,                             // =  1022
+    ERROR_DEPENDENT_SERVICES_RUNNING                      =  1051,
+    ERROR_INVALID_SERVICE_CONTROL,
+    ERROR_SERVICE_REQUEST_TIMEOUT,
+    ERROR_SERVICE_NO_THREAD,
+    ERROR_SERVICE_DATABASE_LOCKED,
+    ERROR_SERVICE_ALREADY_RUNNING,
+    ERROR_INVALID_SERVICE_ACCOUNT,
+    ERROR_SERVICE_DISABLED,
+    ERROR_CIRCULAR_DEPENDENCY,
+    ERROR_SERVICE_DOES_NOT_EXIST,
+    ERROR_SERVICE_CANNOT_ACCEPT_CTRL,
+    ERROR_SERVICE_NOT_ACTIVE,
+    ERROR_FAILED_SERVICE_CONTROLLER_CONNECT,
+    ERROR_EXCEPTION_IN_SERVICE,
+    ERROR_DATABASE_DOES_NOT_EXIST,
+    ERROR_SERVICE_SPECIFIC_ERROR,
+    ERROR_PROCESS_ABORTED,
+    ERROR_SERVICE_DEPENDENCY_FAIL,
+    ERROR_SERVICE_LOGON_FAILED,
+    ERROR_SERVICE_START_HANG,
+    ERROR_INVALID_SERVICE_LOCK,
+    ERROR_SERVICE_MARKED_FOR_DELETE,
+    ERROR_SERVICE_EXISTS,
+    ERROR_ALREADY_RUNNING_LKG,
+    ERROR_SERVICE_DEPENDENCY_DELETED,
+    ERROR_BOOT_ALREADY_ACCEPTED,
+    ERROR_SERVICE_NEVER_STARTED,
+    ERROR_DUPLICATE_SERVICE_NAME,
+    ERROR_DIFFERENT_SERVICE_ACCOUNT,
+    ERROR_CANNOT_DETECT_DRIVER_FAILURE,
+    ERROR_CANNOT_DETECT_PROCESS_ABORT,
+    ERROR_NO_RECOVERY_PROGRAM,
+    ERROR_SERVICE_NOT_IN_EXE,
+    ERROR_NOT_SAFEBOOT_SERVICE,                        // =  1084
+    ERROR_END_OF_MEDIA                                    =  1100,
+    ERROR_FILEMARK_DETECTED,
+    ERROR_BEGINNING_OF_MEDIA,
+    ERROR_SETMARK_DETECTED,
+    ERROR_NO_DATA_DETECTED,
+    ERROR_PARTITION_FAILURE,
+    ERROR_INVALID_BLOCK_LENGTH,
+    ERROR_DEVICE_NOT_PARTITIONED,
+    ERROR_UNABLE_TO_LOCK_MEDIA,
+    ERROR_UNABLE_TO_UNLOAD_MEDIA,
+    ERROR_MEDIA_CHANGED,
+    ERROR_BUS_RESET,
+    ERROR_NO_MEDIA_IN_DRIVE,
+    ERROR_NO_UNICODE_TRANSLATION,
+    ERROR_DLL_INIT_FAILED,
+    ERROR_SHUTDOWN_IN_PROGRESS,
+    ERROR_NO_SHUTDOWN_IN_PROGRESS,
+    ERROR_IO_DEVICE,
+    ERROR_SERIAL_NO_DEVICE,
+    ERROR_IRQ_BUSY,
+    ERROR_MORE_WRITES,
+    ERROR_COUNTER_TIMEOUT,
+    ERROR_FLOPPY_ID_MARK_NOT_FOUND,
+    ERROR_FLOPPY_WRONG_CYLINDER,
+    ERROR_FLOPPY_UNKNOWN_ERROR,
+    ERROR_FLOPPY_BAD_REGISTERS,
+    ERROR_DISK_RECALIBRATE_FAILED,
+    ERROR_DISK_OPERATION_FAILED,
+    ERROR_DISK_RESET_FAILED,
+    ERROR_EOM_OVERFLOW,
+    ERROR_NOT_ENOUGH_SERVER_MEMORY,
+    ERROR_POSSIBLE_DEADLOCK,
+    ERROR_MAPPED_ALIGNMENT,                            // =  1132
+    ERROR_SET_POWER_STATE_VETOED                          =  1140,
+    ERROR_SET_POWER_STATE_FAILED,
+    ERROR_TOO_MANY_LINKS,                              // =  1142
+    ERROR_OLD_WIN_VERSION                                 =  1150,
+    ERROR_APP_WRONG_OS,
+    ERROR_SINGLE_INSTANCE_APP,
+    ERROR_RMODE_APP,
+    ERROR_INVALID_DLL,
+    ERROR_NO_ASSOCIATION,
+    ERROR_DDE_FAIL,
+    ERROR_DLL_NOT_FOUND,
+    ERROR_NO_MORE_USER_HANDLES,
+    ERROR_MESSAGE_SYNC_ONLY,
+    ERROR_SOURCE_ELEMENT_EMPTY,
+    ERROR_DESTINATION_ELEMENT_FULL,
+    ERROR_ILLEGAL_ELEMENT_ADDRESS,
+    ERROR_MAGAZINE_NOT_PRESENT,
+    ERROR_DEVICE_REINITIALIZATION_NEEDED,
+    ERROR_DEVICE_REQUIRES_CLEANING,
+    ERROR_DEVICE_DOOR_OPEN,
+    ERROR_DEVICE_NOT_CONNECTED,
+    ERROR_NOT_FOUND,
+    ERROR_NO_MATCH,
+    ERROR_SET_NOT_FOUND,
+    ERROR_POINT_NOT_FOUND,
+    ERROR_NO_TRACKING_SERVICE,
+    ERROR_NO_VOLUME_ID,                                // =  1173
+    ERROR_UNABLE_TO_REMOVE_REPLACED                       =  1175,
+    ERROR_UNABLE_TO_MOVE_REPLACEMENT,
+    ERROR_UNABLE_TO_MOVE_REPLACEMENT_2,
+    ERROR_JOURNAL_DELETE_IN_PROGRESS,
+    ERROR_JOURNAL_NOT_ACTIVE,
+    ERROR_POTENTIAL_FILE_FOUND,
+    ERROR_JOURNAL_ENTRY_DELETED,                       // =  1181
+    ERROR_BAD_DEVICE                                      =  1200,
+    ERROR_CONNECTION_UNAVAIL,
+    ERROR_DEVICE_ALREADY_REMEMBERED,
+    ERROR_NO_NET_OR_BAD_PATH,
+    ERROR_BAD_PROVIDER,
+    ERROR_CANNOT_OPEN_PROFILE,
+    ERROR_BAD_PROFILE,
+    ERROR_NOT_CONTAINER,
+    ERROR_EXTENDED_ERROR,
+    ERROR_INVALID_GROUPNAME,
+    ERROR_INVALID_COMPUTERNAME,
+    ERROR_INVALID_EVENTNAME,
+    ERROR_INVALID_DOMAINNAME,
+    ERROR_INVALID_SERVICENAME,
+    ERROR_INVALID_NETNAME,
+    ERROR_INVALID_SHARENAME,
+    ERROR_INVALID_PASSWORDNAME,
+    ERROR_INVALID_MESSAGENAME,
+    ERROR_INVALID_MESSAGEDEST,
+    ERROR_SESSION_CREDENTIAL_CONFLICT,
+    ERROR_REMOTE_SESSION_LIMIT_EXCEEDED,
+    ERROR_DUP_DOMAINNAME,
+    ERROR_NO_NETWORK,
+    ERROR_CANCELLED,
+    ERROR_USER_MAPPED_FILE,
+    ERROR_CONNECTION_REFUSED,
+    ERROR_GRACEFUL_DISCONNECT,
+    ERROR_ADDRESS_ALREADY_ASSOCIATED,
+    ERROR_ADDRESS_NOT_ASSOCIATED,
+    ERROR_CONNECTION_INVALID,
+    ERROR_CONNECTION_ACTIVE,
+    ERROR_NETWORK_UNREACHABLE,
+    ERROR_HOST_UNREACHABLE,
+    ERROR_PROTOCOL_UNREACHABLE,
+    ERROR_PORT_UNREACHABLE,
+    ERROR_REQUEST_ABORTED,
+    ERROR_CONNECTION_ABORTED,
+    ERROR_RETRY,
+    ERROR_CONNECTION_COUNT_LIMIT,
+    ERROR_LOGIN_TIME_RESTRICTION,
+    ERROR_LOGIN_WKSTA_RESTRICTION,
+    ERROR_INCORRECT_ADDRESS,
+    ERROR_ALREADY_REGISTERED,
+    ERROR_SERVICE_NOT_FOUND,
+    ERROR_NOT_AUTHENTICATED,
+    ERROR_NOT_LOGGED_ON,
+    ERROR_CONTINUE,
+    ERROR_ALREADY_INITIALIZED,
+    ERROR_NO_MORE_DEVICES,
+    ERROR_NO_SUCH_SITE,
+    ERROR_DOMAIN_CONTROLLER_EXISTS,
+    ERROR_ONLY_IF_CONNECTED,
+    ERROR_OVERRIDE_NOCHANGES,
+    ERROR_BAD_USER_PROFILE,
+    ERROR_NOT_SUPPORTED_ON_SBS,
+    ERROR_SERVER_SHUTDOWN_IN_PROGRESS,
+    ERROR_HOST_DOWN,
+    ERROR_NON_ACCOUNT_SID,
+    ERROR_NON_DOMAIN_SID,
+    ERROR_APPHELP_BLOCK,
+    ERROR_ACCESS_DISABLED_BY_POLICY,
+    ERROR_REG_NAT_CONSUMPTION,
+    ERROR_CSCSHARE_OFFLINE,
+    ERROR_PKINIT_FAILURE,
+    ERROR_SMARTCARD_SUBSYSTEM_FAILURE,
+    ERROR_DOWNGRADE_DETECTED,
+    SEC_E_SMARTCARD_CERT_REVOKED,
+    SEC_E_ISSUING_CA_UNTRUSTED,
+    SEC_E_REVOCATION_OFFLINE_C,
+    SEC_E_PKINIT_CLIENT_FAILUR,
+    SEC_E_SMARTCARD_CERT_EXPIRED,
+    ERROR_MACHINE_LOCKED,                              // =  1271
+    ERROR_CALLBACK_SUPPLIED_INVALID_DATA                  =  1273,
+    ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED,
+    ERROR_DRIVER_BLOCKED,
+    ERROR_INVALID_IMPORT_OF_NON_DLL,
+    ERROR_ACCESS_DISABLED_WEBBLADE,
+    ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER,
+    ERROR_RECOVERY_FAILURE,
+    ERROR_ALREADY_FIBER,
+    ERROR_ALREADY_THREAD,
+    ERROR_STACK_BUFFER_OVERRUN,
+    ERROR_PARAMETER_QUOTA_EXCEEDED,
+    ERROR_DEBUGGER_INACTIVE,                           // =  1284
+    ERROR_NOT_ALL_ASSIGNED                                =  1300,
+    ERROR_SOME_NOT_MAPPED,
+    ERROR_NO_QUOTAS_FOR_ACCOUNT,
+    ERROR_LOCAL_USER_SESSION_KEY,
+    ERROR_NULL_LM_PASSWORD,
+    ERROR_UNKNOWN_REVISION,
+    ERROR_REVISION_MISMATCH,
+    ERROR_INVALID_OWNER,
+    ERROR_INVALID_PRIMARY_GROUP,
+    ERROR_NO_IMPERSONATION_TOKEN,
+    ERROR_CANT_DISABLE_MANDATORY,
+    ERROR_NO_LOGON_SERVERS,
+    ERROR_NO_SUCH_LOGON_SESSION,
+    ERROR_NO_SUCH_PRIVILEGE,
+    ERROR_PRIVILEGE_NOT_HELD,
+    ERROR_INVALID_ACCOUNT_NAME,
+    ERROR_USER_EXISTS,
+    ERROR_NO_SUCH_USER,
+    ERROR_GROUP_EXISTS,
+    ERROR_NO_SUCH_GROUP,
+    ERROR_MEMBER_IN_GROUP,
+    ERROR_MEMBER_NOT_IN_GROUP,
+    ERROR_LAST_ADMIN,
+    ERROR_WRONG_PASSWORD,
+    ERROR_ILL_FORMED_PASSWORD,
+    ERROR_PASSWORD_RESTRICTION,
+    ERROR_LOGON_FAILURE,
+    ERROR_ACCOUNT_RESTRICTION,
+    ERROR_INVALID_LOGON_HOURS,
+    ERROR_INVALID_WORKSTATION,
+    ERROR_PASSWORD_EXPIRED,
+    ERROR_ACCOUNT_DISABLED,
+    ERROR_NONE_MAPPED,
+    ERROR_TOO_MANY_LUIDS_REQUESTED,
+    ERROR_LUIDS_EXHAUSTED,
+    ERROR_INVALID_SUB_AUTHORITY,
+    ERROR_INVALID_ACL,
+    ERROR_INVALID_SID,
+    ERROR_INVALID_SECURITY_DESCR,                      // =  1338
+    ERROR_BAD_INHERITANCE_ACL                             =  1340,
+    ERROR_SERVER_DISABLED,
+    ERROR_SERVER_NOT_DISABLED,
+    ERROR_INVALID_ID_AUTHORITY,
+    ERROR_ALLOTTED_SPACE_EXCEEDED,
+    ERROR_INVALID_GROUP_ATTRIBUTES,
+    ERROR_BAD_IMPERSONATION_LEVEL,
+    ERROR_CANT_OPEN_ANONYMOUS,
+    ERROR_BAD_VALIDATION_CLASS,
+    ERROR_BAD_TOKEN_TYPE,
+    ERROR_NO_SECURITY_ON_OBJECT,
+    ERROR_CANT_ACCESS_DOMAIN_INFO,
+    ERROR_INVALID_SERVER_STATE,
+    ERROR_INVALID_DOMAIN_STATE,
+    ERROR_INVALID_DOMAIN_ROLE,
+    ERROR_NO_SUCH_DOMAIN,
+    ERROR_DOMAIN_EXISTS,
+    ERROR_DOMAIN_LIMIT_EXCEEDED,
+    ERROR_INTERNAL_DB_CORRUPTION,
+    ERROR_INTERNAL_ERROR,
+    ERROR_GENERIC_NOT_MAPPED,
+    ERROR_BAD_DESCRIPTOR_FORMAT,
+    ERROR_NOT_LOGON_PROCESS,
+    ERROR_LOGON_SESSION_EXISTS,
+    ERROR_NO_SUCH_PACKAGE,
+    ERROR_BAD_LOGON_SESSION_STATE,
+    ERROR_LOGON_SESSION_COLLISION,
+    ERROR_INVALID_LOGON_TYPE,
+    ERROR_CANNOT_IMPERSONATE,
+    ERROR_RXACT_INVALID_STATE,
+    ERROR_RXACT_COMMIT_FAILURE,
+    ERROR_SPECIAL_ACCOUNT,
+    ERROR_SPECIAL_GROUP,
+    ERROR_SPECIAL_USER,
+    ERROR_MEMBERS_PRIMARY_GROUP,
+    ERROR_TOKEN_ALREADY_IN_USE,
+    ERROR_NO_SUCH_ALIAS,
+    ERROR_MEMBER_NOT_IN_ALIAS,
+    ERROR_MEMBER_IN_ALIAS,
+    ERROR_ALIAS_EXISTS,
+    ERROR_LOGON_NOT_GRANTED,
+    ERROR_TOO_MANY_SECRETS,
+    ERROR_SECRET_TOO_LONG,
+    ERROR_INTERNAL_DB_ERROR,
+    ERROR_TOO_MANY_CONTEXT_IDS,
+    ERROR_LOGON_TYPE_NOT_GRANTED,
+    ERROR_NT_CROSS_ENCRYPTION_REQUIRED,
+    ERROR_NO_SUCH_MEMBER,
+    ERROR_INVALID_MEMBER,
+    ERROR_TOO_MANY_SIDS,
+    ERROR_LM_CROSS_ENCRYPTION_REQUIRED,
+    ERROR_NO_INHERITANCE,
+    ERROR_FILE_CORRUPT,
+    ERROR_DISK_CORRUPT,
+    ERROR_NO_USER_SESSION_KEY,
+    ERROR_LICENSE_QUOTA_EXCEEDED,
+    ERROR_WRONG_TARGET_NAME,
+    ERROR_MUTUAL_AUTH_FAILED,
+    ERROR_TIME_SKEW,
+    ERROR_CURRENT_DOMAIN_NOT_ALLOWED,
+    ERROR_INVALID_WINDOW_HANDLE,
+    ERROR_INVALID_MENU_HANDLE,
+    ERROR_INVALID_CURSOR_HANDLE,
+    ERROR_INVALID_ACCEL_HANDLE,
+    ERROR_INVALID_HOOK_HANDLE,
+    ERROR_INVALID_DWP_HANDLE,
+    ERROR_TLW_WITH_WSCHILD,
+    ERROR_CANNOT_FIND_WND_CLASS,
+    ERROR_WINDOW_OF_OTHER_THREAD,
+    ERROR_HOTKEY_ALREADY_REGISTERED,
+    ERROR_CLASS_ALREADY_EXISTS,
+    ERROR_CLASS_DOES_NOT_EXIST,
+    ERROR_CLASS_HAS_WINDOWS,
+    ERROR_INVALID_INDEX,
+    ERROR_INVALID_ICON_HANDLE,
+    ERROR_PRIVATE_DIALOG_INDEX,
+    ERROR_LISTBOX_ID_NOT_FOUND,
+    ERROR_NO_WILDCARD_CHARACTERS,
+    ERROR_CLIPBOARD_NOT_OPEN,
+    ERROR_HOTKEY_NOT_REGISTERED,
+    ERROR_WINDOW_NOT_DIALOG,
+    ERROR_CONTROL_ID_NOT_FOUND,
+    ERROR_INVALID_COMBOBOX_MESSAGE,
+    ERROR_WINDOW_NOT_COMBOBOX,
+    ERROR_INVALID_EDIT_HEIGHT,
+    ERROR_DC_NOT_FOUND,
+    ERROR_INVALID_HOOK_FILTER,
+    ERROR_INVALID_FILTER_PROC,
+    ERROR_HOOK_NEEDS_HMOD,
+    ERROR_GLOBAL_ONLY_HOOK,
+    ERROR_JOURNAL_HOOK_SET,
+    ERROR_HOOK_NOT_INSTALLED,
+    ERROR_INVALID_LB_MESSAGE,
+    ERROR_SETCOUNT_ON_BAD_LB,
+    ERROR_LB_WITHOUT_TABSTOPS,
+    ERROR_DESTROY_OBJECT_OF_OTHER_THREAD,
+    ERROR_CHILD_WINDOW_MENU,
+    ERROR_NO_SYSTEM_MENU,
+    ERROR_INVALID_MSGBOX_STYLE,
+    ERROR_INVALID_SPI_VALUE,
+    ERROR_SCREEN_ALREADY_LOCKED,
+    ERROR_HWNDS_HAVE_DIFF_PARENT,
+    ERROR_NOT_CHILD_WINDOW,
+    ERROR_INVALID_GW_COMMAND,
+    ERROR_INVALID_THREAD_ID,
+    ERROR_NON_MDICHILD_WINDOW,
+    ERROR_POPUP_ALREADY_ACTIVE,
+    ERROR_NO_SCROLLBARS,
+    ERROR_INVALID_SCROLLBAR_RANGE,
+    ERROR_INVALID_SHOWWIN_COMMAND,
+    ERROR_NO_SYSTEM_RESOURCES,
+    ERROR_NONPAGED_SYSTEM_RESOURCES,
+    ERROR_PAGED_SYSTEM_RESOURCES,
+    ERROR_WORKING_SET_QUOTA,
+    ERROR_PAGEFILE_QUOTA,
+    ERROR_COMMITMENT_LIMIT,
+    ERROR_MENU_ITEM_NOT_FOUND,
+    ERROR_INVALID_KEYBOARD_HANDLE,
+    ERROR_HOOK_TYPE_NOT_ALLOWED,
+    ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION,
+    ERROR_TIMEOUT,
+    ERROR_INVALID_MONITOR_HANDLE,                      // =  1461
+    ERROR_EVENTLOG_FILE_CORRUPT                           =  1500,
+    ERROR_EVENTLOG_CANT_START,
+    ERROR_LOG_FILE_FULL,
+    ERROR_EVENTLOG_FILE_CHANGED,                       // =  1503
+    ERROR_INSTALL_SERVICE_FAILURE                         =  1601,
+    ERROR_INSTALL_USEREXIT,
+    ERROR_INSTALL_FAILURE,
+    ERROR_INSTALL_SUSPEND,
+    ERROR_UNKNOWN_PRODUCT,
+    ERROR_UNKNOWN_FEATURE,
+    ERROR_UNKNOWN_COMPONENT,
+    ERROR_UNKNOWN_PROPERTY,
+    ERROR_INVALID_HANDLE_STATE,
+    ERROR_BAD_CONFIGURATION,
+    ERROR_INDEX_ABSENT,
+    ERROR_INSTALL_SOURCE_ABSENT,
+    ERROR_INSTALL_PACKAGE_VERSION,
+    ERROR_PRODUCT_UNINSTALLED,
+    ERROR_BAD_QUERY_SYNTAX,
+    ERROR_INVALID_FIELD,
+    ERROR_DEVICE_REMOVED,
+    ERROR_INSTALL_ALREADY_RUNNING,
+    ERROR_INSTALL_PACKAGE_OPEN_FAILED,
+    ERROR_INSTALL_PACKAGE_INVALID,
+    ERROR_INSTALL_UI_FAILURE,
+    ERROR_INSTALL_LOG_FAILURE,
+    ERROR_INSTALL_LANGUAGE_UNSUPPORTED,
+    ERROR_INSTALL_TRANSFORM_FAILURE,
+    ERROR_INSTALL_PACKAGE_REJECTED,
+    ERROR_FUNCTION_NOT_CALLED,
+    ERROR_FUNCTION_FAILED,
+    ERROR_INVALID_TABLE,
+    ERROR_DATATYPE_MISMATCH,
+    ERROR_UNSUPPORTED_TYPE,
+    ERROR_CREATE_FAILED,
+    ERROR_INSTALL_TEMP_UNWRITABLE,
+    ERROR_INSTALL_PLATFORM_UNSUPPORTED,
+    ERROR_INSTALL_NOTUSED,
+    ERROR_PATCH_PACKAGE_OPEN_FAILED,
+    ERROR_PATCH_PACKAGE_INVALID,
+    ERROR_PATCH_PACKAGE_UNSUPPORTED,
+    ERROR_PRODUCT_VERSION,
+    ERROR_INVALID_COMMAND_LINE,
+    ERROR_INSTALL_REMOTE_DISALLOWED,
+    ERROR_SUCCESS_REBOOT_INITIATED,
+    ERROR_PATCH_TARGET_NOT_FOUND,
+    ERROR_PATCH_PACKAGE_REJECTED,
+    ERROR_INSTALL_TRANSFORM_REJECTED,
+    ERROR_INSTALL_REMOTE_PROHIBITED,                   // =  1645
+    RPC_S_INVALID_STRING_BINDING                          =  1700,
+    RPC_S_WRONG_KIND_OF_BINDING,
+    RPC_S_INVALID_BINDING,
+    RPC_S_PROTSEQ_NOT_SUPPORTED,
+    RPC_S_INVALID_RPC_PROTSEQ,
+    RPC_S_INVALID_STRING_UUID,
+    RPC_S_INVALID_ENDPOINT_FORMAT,
+    RPC_S_INVALID_NET_ADDR,
+    RPC_S_NO_ENDPOINT_FOUND,
+    RPC_S_INVALID_TIMEOUT,
+    RPC_S_OBJECT_NOT_FOUND,
+    RPC_S_ALREADY_REGISTERED,
+    RPC_S_TYPE_ALREADY_REGISTERED,
+    RPC_S_ALREADY_LISTENING,
+    RPC_S_NO_PROTSEQS_REGISTERED,
+    RPC_S_NOT_LISTENING,
+    RPC_S_UNKNOWN_MGR_TYPE,
+    RPC_S_UNKNOWN_IF,
+    RPC_S_NO_BINDINGS,
+    RPC_S_NO_PROTSEQS,
+    RPC_S_CANT_CREATE_ENDPOINT,
+    RPC_S_OUT_OF_RESOURCES,
+    RPC_S_SERVER_UNAVAILABLE,
+    RPC_S_SERVER_TOO_BUSY,
+    RPC_S_INVALID_NETWORK_OPTIONS,
+    RPC_S_NO_CALL_ACTIVE,
+    RPC_S_CALL_FAILED,
+    RPC_S_CALL_FAILED_DNE,
+    RPC_S_PROTOCOL_ERROR,                              // =  1728
+    RPC_S_UNSUPPORTED_TRANS_SYN                           =  1730,
+    RPC_S_UNSUPPORTED_TYPE                                =  1732,
+    RPC_S_INVALID_TAG,
+    RPC_S_INVALID_BOUND,
+    RPC_S_NO_ENTRY_NAME,
+    RPC_S_INVALID_NAME_SYNTAX,
+    RPC_S_UNSUPPORTED_NAME_SYNTAX,                     // =  1737
+    RPC_S_UUID_NO_ADDRESS                                 =  1739,
+    RPC_S_DUPLICATE_ENDPOINT,
+    RPC_S_UNKNOWN_AUTHN_TYPE,
+    RPC_S_MAX_CALLS_TOO_SMALL,
+    RPC_S_STRING_TOO_LONG,
+    RPC_S_PROTSEQ_NOT_FOUND,
+    RPC_S_PROCNUM_OUT_OF_RANGE,
+    RPC_S_BINDING_HAS_NO_AUTH,
+    RPC_S_UNKNOWN_AUTHN_SERVICE,
+    RPC_S_UNKNOWN_AUTHN_LEVEL,
+    RPC_S_INVALID_AUTH_IDENTITY,
+    RPC_S_UNKNOWN_AUTHZ_SERVICE,
+    EPT_S_INVALID_ENTRY,
+    EPT_S_CANT_PERFORM_OP,
+    EPT_S_NOT_REGISTERED,
+    RPC_S_NOTHING_TO_EXPORT,
+    RPC_S_INCOMPLETE_NAME,
+    RPC_S_INVALID_VERS_OPTION,
+    RPC_S_NO_MORE_MEMBERS,
+    RPC_S_NOT_ALL_OBJS_UNEXPORTED,
+    RPC_S_INTERFACE_NOT_FOUND,
+    RPC_S_ENTRY_ALREADY_EXISTS,
+    RPC_S_ENTRY_NOT_FOUND,
+    RPC_S_NAME_SERVICE_UNAVAILABLE,
+    RPC_S_INVALID_NAF_ID,
+    RPC_S_CANNOT_SUPPORT,
+    RPC_S_NO_CONTEXT_AVAILABLE,
+    RPC_S_INTERNAL_ERROR,
+    RPC_S_ZERO_DIVIDE,
+    RPC_S_ADDRESS_ERROR,
+    RPC_S_FP_DIV_ZERO,
+    RPC_S_FP_UNDERFLOW,
+    RPC_S_FP_OVERFLOW,
+    RPC_X_NO_MORE_ENTRIES,
+    RPC_X_SS_CHAR_TRANS_OPEN_FAIL,
+    RPC_X_SS_CHAR_TRANS_SHORT_FILE,
+    RPC_X_SS_IN_NULL_CONTEXT,                          // =  1775
+    RPC_X_SS_CONTEXT_DAMAGED                              =  1777,
+    RPC_X_SS_HANDLES_MISMATCH,
+    RPC_X_SS_CANNOT_GET_CALL_HANDLE,
+    RPC_X_NULL_REF_POINTER,
+    RPC_X_ENUM_VALUE_OUT_OF_RANGE,
+    RPC_X_BYTE_COUNT_TOO_SMALL,
+    RPC_X_BAD_STUB_DATA,
+    ERROR_INVALID_USER_BUFFER,
+    ERROR_UNRECOGNIZED_MEDIA,
+    ERROR_NO_TRUST_LSA_SECRET,
+    ERROR_NO_TRUST_SAM_ACCOUNT,
+    ERROR_TRUSTED_DOMAIN_FAILURE,
+    ERROR_TRUSTED_RELATIONSHIP_FAILURE,
+    ERROR_TRUST_FAILURE,
+    RPC_S_CALL_IN_PROGRESS,
+    ERROR_NETLOGON_NOT_STARTED,
+    ERROR_ACCOUNT_EXPIRED,
+    ERROR_REDIRECTOR_HAS_OPEN_HANDLES,
+    ERROR_PRINTER_DRIVER_ALREADY_INSTALLED,
+    ERROR_UNKNOWN_PORT,
+    ERROR_UNKNOWN_PRINTER_DRIVER,
+    ERROR_UNKNOWN_PRINTPROCESSOR,
+    ERROR_INVALID_SEPARATOR_FILE,
+    ERROR_INVALID_PRIORITY,
+    ERROR_INVALID_PRINTER_NAME,
+    ERROR_PRINTER_ALREADY_EXISTS,
+    ERROR_INVALID_PRINTER_COMMAND,
+    ERROR_INVALID_DATATYPE,
+    ERROR_INVALID_ENVIRONMENT,
+    RPC_S_NO_MORE_BINDINGS,
+    ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT,
+    ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT,
+    ERROR_NOLOGON_SERVER_TRUST_ACCOUNT,
+    ERROR_DOMAIN_TRUST_INCONSISTENT,
+    ERROR_SERVER_HAS_OPEN_HANDLES,
+    ERROR_RESOURCE_DATA_NOT_FOUND,
+    ERROR_RESOURCE_TYPE_NOT_FOUND,
+    ERROR_RESOURCE_NAME_NOT_FOUND,
+    ERROR_RESOURCE_LANG_NOT_FOUND,
+    ERROR_NOT_ENOUGH_QUOTA,
+    RPC_S_NO_INTERFACES,
+    RPC_S_CALL_CANCELLED,
+    RPC_S_BINDING_INCOMPLETE,
+    RPC_S_COMM_FAILURE,
+    RPC_S_UNSUPPORTED_AUTHN_LEVEL,
+    RPC_S_NO_PRINC_NAME,
+    RPC_S_NOT_RPC_ERROR,
+    RPC_S_UUID_LOCAL_ONLY,
+    RPC_S_SEC_PKG_ERROR,
+    RPC_S_NOT_CANCELLED,
+    RPC_X_INVALID_ES_ACTION,
+    RPC_X_WRONG_ES_VERSION,
+    RPC_X_WRONG_STUB_VERSION,
+    RPC_X_INVALID_PIPE_OBJECT,
+    RPC_X_WRONG_PIPE_ORDER,
+    RPC_X_WRONG_PIPE_VERSION,                          // =  1832
+    RPC_S_GROUP_MEMBER_NOT_FOUND                          =  1898,
+    EPT_S_CANT_CREATE,
+    RPC_S_INVALID_OBJECT,
+    ERROR_INVALID_TIME,
+    ERROR_INVALID_FORM_NAME,
+    ERROR_INVALID_FORM_SIZE,
+    ERROR_ALREADY_WAITING,
+    ERROR_PRINTER_DELETED,
+    ERROR_INVALID_PRINTER_STATE,
+    ERROR_PASSWORD_MUST_CHANGE,
+    ERROR_DOMAIN_CONTROLLER_NOT_FOUND,
+    ERROR_ACCOUNT_LOCKED_OUT,
+    OR_INVALID_OXID,
+    OR_INVALID_OID,
+    OR_INVALID_SET,
+    RPC_S_SEND_INCOMPLETE,
+    RPC_S_INVALID_ASYNC_HANDLE,
+    RPC_S_INVALID_ASYNC_CALL,
+    RPC_X_PIPE_CLOSED,
+    RPC_X_PIPE_DISCIPLINE_ERROR,
+    RPC_X_PIPE_EMPTY,
+    ERROR_NO_SITENAME,
+    ERROR_CANT_ACCESS_FILE,
+    ERROR_CANT_RESOLVE_FILENAME,
+    RPC_S_ENTRY_TYPE_MISMATCH,
+    RPC_S_NOT_ALL_OBJS_EXPORTED,
+    RPC_S_INTERFACE_NOT_EXPORTED,
+    RPC_S_PROFILE_NOT_ADDED,
+    RPC_S_PRF_ELT_NOT_ADDED,
+    RPC_S_PRF_ELT_NOT_REMOVED,
+    RPC_S_GRP_ELT_NOT_ADDED,
+    RPC_S_GRP_ELT_NOT_REMOVED,
+    ERROR_KM_DRIVER_BLOCKED,
+    ERROR_CONTEXT_EXPIRED,
+    ERROR_PER_USER_TRUST_QUOTA_EXCEEDED,
+    ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED,
+    ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED,            // =  1934
+    ERROR_INVALID_PIXEL_FORMAT                            =  2000,
+    ERROR_BAD_DRIVER,
+    ERROR_INVALID_WINDOW_STYLE,
+    ERROR_METAFILE_NOT_SUPPORTED,
+    ERROR_TRANSFORM_NOT_SUPPORTED,
+    ERROR_CLIPPING_NOT_SUPPORTED,                      // =  2005
+    ERROR_INVALID_CMM                                     =  2010,
+    ERROR_INVALID_PROFILE,
+    ERROR_TAG_NOT_FOUND,
+    ERROR_TAG_NOT_PRESENT,
+    ERROR_DUPLICATE_TAG,
+    ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE,
+    ERROR_PROFILE_NOT_FOUND,
+    ERROR_INVALID_COLORSPACE,
+    ERROR_ICM_NOT_ENABLED,
+    ERROR_DELETING_ICM_XFORM,
+    ERROR_INVALID_TRANSFORM,
+    ERROR_COLORSPACE_MISMATCH,
+    ERROR_INVALID_COLORINDEX,                          // =  2022
+    ERROR_CONNECTED_OTHER_PASSWORD                        =  2108,
+    ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT,            // =  2109
+    ERROR_BAD_USERNAME                                    =  2202,
+    ERROR_NOT_CONNECTED                                   =  2250,
+    ERROR_OPEN_FILES                                      =  2401,
+    ERROR_ACTIVE_CONNECTIONS,                          // =  2402
+    ERROR_DEVICE_IN_USE                                   =  2404,
+    ERROR_UNKNOWN_PRINT_MONITOR                           =  3000,
+    ERROR_PRINTER_DRIVER_IN_USE,
+    ERROR_SPOOL_FILE_NOT_FOUND,
+    ERROR_SPL_NO_STARTDOC,
+    ERROR_SPL_NO_ADDJOB,
+    ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED,
+    ERROR_PRINT_MONITOR_ALREADY_INSTALLED,
+    ERROR_INVALID_PRINT_MONITOR,
+    ERROR_PRINT_MONITOR_IN_USE,
+    ERROR_PRINTER_HAS_JOBS_QUEUED,
+    ERROR_SUCCESS_REBOOT_REQUIRED,
+    ERROR_SUCCESS_RESTART_REQUIRED,
+    ERROR_PRINTER_NOT_FOUND,
+    ERROR_PRINTER_DRIVER_WARNED,
+    ERROR_PRINTER_DRIVER_BLOCKED,                      // =  3014
+    ERROR_WINS_INTERNAL                                   =  4000,
+    ERROR_CAN_NOT_DEL_LOCAL_WINS,
+    ERROR_STATIC_INIT,
+    ERROR_INC_BACKUP,
+    ERROR_FULL_BACKUP,
+    ERROR_REC_NON_EXISTENT,
+    ERROR_RPL_NOT_ALLOWED,                             // =  4006
+    ERROR_DHCP_ADDRESS_CONFLICT                           =  4100,
+    ERROR_WMI_GUID_NOT_FOUND                              =  4200,
+    ERROR_WMI_INSTANCE_NOT_FOUND,
+    ERROR_WMI_ITEMID_NOT_FOUND,
+    ERROR_WMI_TRY_AGAIN,
+    ERROR_WMI_DP_NOT_FOUND,
+    ERROR_WMI_UNRESOLVED_INSTANCE_REF,
+    ERROR_WMI_ALREADY_ENABLED,
+    ERROR_WMI_GUID_DISCONNECTED,
+    ERROR_WMI_SERVER_UNAVAILABLE,
+    ERROR_WMI_DP_FAILED,
+    ERROR_WMI_INVALID_MOF,
+    ERROR_WMI_INVALID_REGINFO,
+    ERROR_WMI_ALREADY_DISABLED,
+    ERROR_WMI_READ_ONLY,
+    ERROR_WMI_SET_FAILURE,                             // =  4214
+    ERROR_INVALID_MEDIA                                   =  4300,
+    ERROR_INVALID_LIBRARY,
+    ERROR_INVALID_MEDIA_POOL,
+    ERROR_DRIVE_MEDIA_MISMATCH,
+    ERROR_MEDIA_OFFLINE,
+    ERROR_LIBRARY_OFFLINE,
+    ERROR_EMPTY,
+    ERROR_NOT_EMPTY,
+    ERROR_MEDIA_UNAVAILABLE,
+    ERROR_RESOURCE_DISABLED,
+    ERROR_INVALID_CLEANER,
+    ERROR_UNABLE_TO_CLEAN,
+    ERROR_OBJECT_NOT_FOUND,
+    ERROR_DATABASE_FAILURE,
+    ERROR_DATABASE_FULL,
+    ERROR_MEDIA_INCOMPATIBLE,
+    ERROR_RESOURCE_NOT_PRESENT,
+    ERROR_INVALID_OPERATION,
+    ERROR_MEDIA_NOT_AVAILABLE,
+    ERROR_DEVICE_NOT_AVAILABLE,
+    ERROR_REQUEST_REFUSED,
+    ERROR_INVALID_DRIVE_OBJECT,
+    ERROR_LIBRARY_FULL,
+    ERROR_MEDIUM_NOT_ACCESSIBLE,
+    ERROR_UNABLE_TO_LOAD_MEDIUM,
+    ERROR_UNABLE_TO_INVENTORY_DRIVE,
+    ERROR_UNABLE_TO_INVENTORY_SLOT,
+    ERROR_UNABLE_TO_INVENTORY_TRANSPORT,
+    ERROR_TRANSPORT_FULL,
+    ERROR_CONTROLLING_IEPORT,
+    ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA,
+    ERROR_CLEANER_SLOT_SET,
+    ERROR_CLEANER_SLOT_NOT_SET,
+    ERROR_CLEANER_CARTRIDGE_SPENT,
+    ERROR_UNEXPECTED_OMID,
+    ERROR_CANT_DELETE_LAST_ITEM,
+    ERROR_MESSAGE_EXCEEDS_MAX_SIZE,
+    ERROR_VOLUME_CONTAINS_SYS_FILES,
+    ERROR_INDIGENOUS_TYPE,
+    ERROR_NO_SUPPORTING_DRIVES,
+    ERROR_CLEANER_CARTRIDGE_INSTALLED,                 // =  4340
+    ERROR_FILE_OFFLINE                                    =  4350,
+    ERROR_REMOTE_STORAGE_NOT_ACTIVE,
+    ERROR_REMOTE_STORAGE_MEDIA_ERROR,                  // =  4352
+    ERROR_NOT_A_REPARSE_POINT                             =  4390,
+    ERROR_REPARSE_ATTRIBUTE_CONFLICT,
+    ERROR_INVALID_REPARSE_DATA,
+    ERROR_REPARSE_TAG_INVALID,
+    ERROR_REPARSE_TAG_MISMATCH,                        // =  4394
+    ERROR_VOLUME_NOT_SIS_ENABLED                          =  4500,
+    ERROR_DEPENDENT_RESOURCE_EXISTS                       =  5001,
+    ERROR_DEPENDENCY_NOT_FOUND,
+    ERROR_DEPENDENCY_ALREADY_EXISTS,
+    ERROR_RESOURCE_NOT_ONLINE,
+    ERROR_HOST_NODE_NOT_AVAILABLE,
+    ERROR_RESOURCE_NOT_AVAILABLE,
+    ERROR_RESOURCE_NOT_FOUND,
+    ERROR_SHUTDOWN_CLUSTER,
+    ERROR_CANT_EVICT_ACTIVE_NODE,
+    ERROR_OBJECT_ALREADY_EXISTS,
+    ERROR_OBJECT_IN_LIST,
+    ERROR_GROUP_NOT_AVAILABLE,
+    ERROR_GROUP_NOT_FOUND,
+    ERROR_GROUP_NOT_ONLINE,
+    ERROR_HOST_NODE_NOT_RESOURCE_OWNER,
+    ERROR_HOST_NODE_NOT_GROUP_OWNER,
+    ERROR_RESMON_CREATE_FAILED,
+    ERROR_RESMON_ONLINE_FAILED,
+    ERROR_RESOURCE_ONLINE,
+    ERROR_QUORUM_RESOURCE,
+    ERROR_NOT_QUORUM_CAPABLE,
+    ERROR_CLUSTER_SHUTTING_DOWN,
+    ERROR_INVALID_STATE,
+    ERROR_RESOURCE_PROPERTIES_STORED,
+    ERROR_NOT_QUORUM_CLASS,
+    ERROR_CORE_RESOURCE,
+    ERROR_QUORUM_RESOURCE_ONLINE_FAILED,
+    ERROR_QUORUMLOG_OPEN_FAILED,
+    ERROR_CLUSTERLOG_CORRUPT,
+    ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE,
+    ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE,
+    ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND,
+    ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE,
+    ERROR_QUORUM_OWNER_ALIVE,
+    ERROR_NETWORK_NOT_AVAILABLE,
+    ERROR_NODE_NOT_AVAILABLE,
+    ERROR_ALL_NODES_NOT_AVAILABLE,
+    ERROR_RESOURCE_FAILED,
+    ERROR_CLUSTER_INVALID_NODE,
+    ERROR_CLUSTER_NODE_EXISTS,
+    ERROR_CLUSTER_JOIN_IN_PROGRESS,
+    ERROR_CLUSTER_NODE_NOT_FOUND,
+    ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND,
+    ERROR_CLUSTER_NETWORK_EXISTS,
+    ERROR_CLUSTER_NETWORK_NOT_FOUND,
+    ERROR_CLUSTER_NETINTERFACE_EXISTS,
+    ERROR_CLUSTER_NETINTERFACE_NOT_FOUND,
+    ERROR_CLUSTER_INVALID_REQUEST,
+    ERROR_CLUSTER_INVALID_NETWORK_PROVIDER,
+    ERROR_CLUSTER_NODE_DOWN,
+    ERROR_CLUSTER_NODE_UNREACHABLE,
+    ERROR_CLUSTER_NODE_NOT_MEMBER,
+    ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS,
+    ERROR_CLUSTER_INVALID_NETWORK,                     // =  5054
+    ERROR_CLUSTER_NODE_UP                                 =  5056,
+    ERROR_CLUSTER_IPADDR_IN_USE,
+    ERROR_CLUSTER_NODE_NOT_PAUSED,
+    ERROR_CLUSTER_NO_SECURITY_CONTEXT,
+    ERROR_CLUSTER_NETWORK_NOT_INTERNAL,
+    ERROR_CLUSTER_NODE_ALREADY_UP,
+    ERROR_CLUSTER_NODE_ALREADY_DOWN,
+    ERROR_CLUSTER_NETWORK_ALREADY_ONLINE,
+    ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE,
+    ERROR_CLUSTER_NODE_ALREADY_MEMBER,
+    ERROR_CLUSTER_LAST_INTERNAL_NETWORK,
+    ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS,
+    ERROR_INVALID_OPERATION_ON_QUORUM,
+    ERROR_DEPENDENCY_NOT_ALLOWED,
+    ERROR_CLUSTER_NODE_PAUSED,
+    ERROR_NODE_CANT_HOST_RESOURCE,
+    ERROR_CLUSTER_NODE_NOT_READY,
+    ERROR_CLUSTER_NODE_SHUTTING_DOWN,
+    ERROR_CLUSTER_JOIN_ABORTED,
+    ERROR_CLUSTER_INCOMPATIBLE_VERSIONS,
+    ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED,
+    ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED,
+    ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND,
+    ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED,
+    ERROR_CLUSTER_RESNAME_NOT_FOUND,
+    ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED,
+    ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST,
+    ERROR_CLUSTER_DATABASE_SEQMISMATCH,
+    ERROR_RESMON_INVALID_STATE,
+    ERROR_CLUSTER_GUM_NOT_LOCKER,
+    ERROR_QUORUM_DISK_NOT_FOUND,
+    ERROR_DATABASE_BACKUP_CORRUPT,
+    ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT,
+    ERROR_RESOURCE_PROPERTY_UNCHANGEABLE,              // =  5089
+    ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE                =  5890,
+    ERROR_CLUSTER_QUORUMLOG_NOT_FOUND,
+    ERROR_CLUSTER_MEMBERSHIP_HALT,
+    ERROR_CLUSTER_INSTANCE_ID_MISMATCH,
+    ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP,
+    ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH,
+    ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP,
+    ERROR_CLUSTER_PARAMETER_MISMATCH,
+    ERROR_NODE_CANNOT_BE_CLUSTERED,
+    ERROR_CLUSTER_WRONG_OS_VERSION,
+    ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME,
+    ERROR_CLUSCFG_ALREADY_COMMITTED,
+    ERROR_CLUSCFG_ROLLBACK_FAILED,
+    ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT,
+    ERROR_CLUSTER_OLD_VERSION,
+    ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME,       // =  5905
+    ERROR_ENCRYPTION_FAILED                               =  6000,
+    ERROR_DECRYPTION_FAILED,
+    ERROR_FILE_ENCRYPTED,
+    ERROR_NO_RECOVERY_POLICY,
+    ERROR_NO_EFS,
+    ERROR_WRONG_EFS,
+    ERROR_NO_USER_KEYS,
+    ERROR_FILE_NOT_ENCRYPTED,
+    ERROR_NOT_EXPORT_FORMAT,
+    ERROR_FILE_READ_ONLY,
+    ERROR_DIR_EFS_DISALLOWED,
+    ERROR_EFS_SERVER_NOT_TRUSTED,
+    ERROR_BAD_RECOVERY_POLICY,
+    ERROR_EFS_ALG_BLOB_TOO_BIG,
+    ERROR_VOLUME_NOT_SUPPORT_EFS,
+    ERROR_EFS_DISABLED,
+    ERROR_EFS_VERSION_NOT_SUPPORT,                     // =  6016
+    ERROR_NO_BROWSER_SERVERS_FOUND                        =  6118,
+    SCHED_E_SERVICE_NOT_LOCALSYSTEM                       =  6200,
+
+    ERROR_CTX_WINSTATION_NAME_INVALID                     =  7001,
+    ERROR_CTX_INVALID_PD,
+    ERROR_CTX_PD_NOT_FOUND,
+    ERROR_CTX_WD_NOT_FOUND,
+    ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY,
+    ERROR_CTX_SERVICE_NAME_COLLISION,
+    ERROR_CTX_CLOSE_PENDING,
+    ERROR_CTX_NO_OUTBUF,
+    ERROR_CTX_MODEM_INF_NOT_FOUND,
+    ERROR_CTX_INVALID_MODEMNAME,
+    ERROR_CTX_MODEM_RESPONSE_ERROR,
+    ERROR_CTX_MODEM_RESPONSE_TIMEOUT,
+    ERROR_CTX_MODEM_RESPONSE_NO_CARRIER,
+    ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE,
+    ERROR_CTX_MODEM_RESPONSE_BUSY,
+    ERROR_CTX_MODEM_RESPONSE_VOICE,
+    ERROR_CTX_TD_ERROR,                                // =  7017
+    ERROR_CTX_WINSTATION_NOT_FOUND                        =  7022,
+    ERROR_CTX_WINSTATION_ALREADY_EXISTS,
+    ERROR_CTX_WINSTATION_BUSY,
+    ERROR_CTX_BAD_VIDEO_MODE,                          // =  7025
+    ERROR_CTX_GRAPHICS_INVALID                            =  7035,
+    ERROR_CTX_LOGON_DISABLED                              =  7037,
+    ERROR_CTX_NOT_CONSOLE,                             // =  7038
+    ERROR_CTX_CLIENT_QUERY_TIMEOUT                        =  7040,
+    ERROR_CTX_CONSOLE_DISCONNECT,
+    ERROR_CTX_CONSOLE_CONNECT,                         // =  7042
+    ERROR_CTX_SHADOW_DENIED                               =  7044,
+    ERROR_CTX_WINSTATION_ACCESS_DENIED,                // =  7045
+    ERROR_CTX_INVALID_WD                                  =  7049,
+    ERROR_CTX_SHADOW_INVALID,
+    ERROR_CTX_SHADOW_DISABLED,
+    ERROR_CTX_CLIENT_LICENSE_IN_USE,
+    ERROR_CTX_CLIENT_LICENSE_NOT_SET,
+    ERROR_CTX_LICENSE_NOT_AVAILABLE,
+    ERROR_CTX_LICENSE_CLIENT_INVALID,
+    ERROR_CTX_LICENSE_EXPIRED,
+    ERROR_CTX_SHADOW_NOT_RUNNING,
+    ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE,
+    ERROR_ACTIVATION_COUNT_EXCEEDED,                   // =  7059
+
+    FRS_ERR_INVALID_API_SEQUENCE                          =  8001,
+    FRS_ERR_STARTING_SERVICE,
+    FRS_ERR_STOPPING_SERVICE,
+    FRS_ERR_INTERNAL_API,
+    FRS_ERR_INTERNAL,
+    FRS_ERR_SERVICE_COMM,
+    FRS_ERR_INSUFFICIENT_PRIV,
+    FRS_ERR_AUTHENTICATION,
+    FRS_ERR_PARENT_INSUFFICIENT_PRIV,
+    FRS_ERR_PARENT_AUTHENTICATION,
+    FRS_ERR_CHILD_TO_PARENT_COMM,
+    FRS_ERR_PARENT_TO_CHILD_COMM,
+    FRS_ERR_SYSVOL_POPULATE,
+    FRS_ERR_SYSVOL_POPULATE_TIMEOUT,
+    FRS_ERR_SYSVOL_IS_BUSY,
+    FRS_ERR_SYSVOL_DEMOTE,
+    FRS_ERR_INVALID_SERVICE_PARAMETER,                 // =  8017
+    ERROR_DS_NOT_INSTALLED                                =  8200,
+    ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY,
+    ERROR_DS_NO_ATTRIBUTE_OR_VALUE,
+    ERROR_DS_INVALID_ATTRIBUTE_SYNTAX,
+    ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED,
+    ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS,
+    ERROR_DS_BUSY,
+    ERROR_DS_UNAVAILABLE,
+    ERROR_DS_NO_RIDS_ALLOCATED,
+    ERROR_DS_NO_MORE_RIDS,
+    ERROR_DS_INCORRECT_ROLE_OWNER,
+    ERROR_DS_RIDMGR_INIT_ERROR,
+    ERROR_DS_OBJ_CLASS_VIOLATION,
+    ERROR_DS_CANT_ON_NON_LEAF,
+    ERROR_DS_CANT_ON_RDN,
+    ERROR_DS_CANT_MOD_OBJ_CLASS,
+    ERROR_DS_CROSS_DOM_MOVE_ERROR,
+    ERROR_DS_GC_NOT_AVAILABLE,
+    ERROR_SHARED_POLICY,
+    ERROR_POLICY_OBJECT_NOT_FOUND,
+    ERROR_POLICY_ONLY_IN_DS,
+    ERROR_PROMOTION_ACTIVE,
+    ERROR_NO_PROMOTION_ACTIVE,                         // =  8222
+    ERROR_DS_OPERATIONS_ERROR                             =  8224,
+    ERROR_DS_PROTOCOL_ERROR,
+    ERROR_DS_TIMELIMIT_EXCEEDED,
+    ERROR_DS_SIZELIMIT_EXCEEDED,
+    ERROR_DS_ADMIN_LIMIT_EXCEEDED,
+    ERROR_DS_COMPARE_FALSE,
+    ERROR_DS_COMPARE_TRUE,
+    ERROR_DS_AUTH_METHOD_NOT_SUPPORTED,
+    ERROR_DS_STRONG_AUTH_REQUIRED,
+    ERROR_DS_INAPPROPRIATE_AUTH,
+    ERROR_DS_AUTH_UNKNOWN,
+    ERROR_DS_REFERRAL,
+    ERROR_DS_UNAVAILABLE_CRIT_EXTENSION,
+    ERROR_DS_CONFIDENTIALITY_REQUIRED,
+    ERROR_DS_INAPPROPRIATE_MATCHING,
+    ERROR_DS_CONSTRAINT_VIOLATION,
+    ERROR_DS_NO_SUCH_OBJECT,
+    ERROR_DS_ALIAS_PROBLEM,
+    ERROR_DS_INVALID_DN_SYNTAX,
+    ERROR_DS_IS_LEAF,
+    ERROR_DS_ALIAS_DEREF_PROBLEM,
+    ERROR_DS_UNWILLING_TO_PERFORM,
+    ERROR_DS_LOOP_DETECT,
+    ERROR_DS_NAMING_VIOLATION,
+    ERROR_DS_OBJECT_RESULTS_TOO_LARGE,
+    ERROR_DS_AFFECTS_MULTIPLE_DSAS,
+    ERROR_DS_SERVER_DOWN,
+    ERROR_DS_LOCAL_ERROR,
+    ERROR_DS_ENCODING_ERROR,
+    ERROR_DS_DECODING_ERROR,
+    ERROR_DS_FILTER_UNKNOWN,
+    ERROR_DS_PARAM_ERROR,
+    ERROR_DS_NOT_SUPPORTED,
+    ERROR_DS_NO_RESULTS_RETURNED,
+    ERROR_DS_CONTROL_NOT_FOUND,
+    ERROR_DS_CLIENT_LOOP,
+    ERROR_DS_REFERRAL_LIMIT_EXCEEDED,
+    ERROR_DS_SORT_CONTROL_MISSING,
+    ERROR_DS_OFFSET_RANGE_ERROR,                       // =  8262
+    ERROR_DS_ROOT_MUST_BE_NC                              =  8301,
+    ERROR_DS_ADD_REPLICA_INHIBITED,
+    ERROR_DS_ATT_NOT_DEF_IN_SCHEMA,
+    ERROR_DS_MAX_OBJ_SIZE_EXCEEDED,
+    ERROR_DS_OBJ_STRING_NAME_EXISTS,
+    ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA,
+    ERROR_DS_RDN_DOESNT_MATCH_SCHEMA,
+    ERROR_DS_NO_REQUESTED_ATTS_FOUND,
+    ERROR_DS_USER_BUFFER_TO_SMALL,
+    ERROR_DS_ATT_IS_NOT_ON_OBJ,
+    ERROR_DS_ILLEGAL_MOD_OPERATION,
+    ERROR_DS_OBJ_TOO_LARGE,
+    ERROR_DS_BAD_INSTANCE_TYPE,
+    ERROR_DS_MASTERDSA_REQUIRED,
+    ERROR_DS_OBJECT_CLASS_REQUIRED,
+    ERROR_DS_MISSING_REQUIRED_ATT,
+    ERROR_DS_ATT_NOT_DEF_FOR_CLASS,
+    ERROR_DS_ATT_ALREADY_EXISTS,                       // =  8318
+    ERROR_DS_CANT_ADD_ATT_VALUES                          =  8320,
+    ERROR_DS_SINGLE_VALUE_CONSTRAINT,
+    ERROR_DS_RANGE_CONSTRAINT,
+    ERROR_DS_ATT_VAL_ALREADY_EXISTS,
+    ERROR_DS_CANT_REM_MISSING_ATT,
+    ERROR_DS_CANT_REM_MISSING_ATT_VAL,
+    ERROR_DS_ROOT_CANT_BE_SUBREF,
+    ERROR_DS_NO_CHAINING,
+    ERROR_DS_NO_CHAINED_EVAL,
+    ERROR_DS_NO_PARENT_OBJECT,
+    ERROR_DS_PARENT_IS_AN_ALIAS,
+    ERROR_DS_CANT_MIX_MASTER_AND_REPS,
+    ERROR_DS_CHILDREN_EXIST,
+    ERROR_DS_OBJ_NOT_FOUND,
+    ERROR_DS_ALIASED_OBJ_MISSING,
+    ERROR_DS_BAD_NAME_SYNTAX,
+    ERROR_DS_ALIAS_POINTS_TO_ALIAS,
+    ERROR_DS_CANT_DEREF_ALIAS,
+    ERROR_DS_OUT_OF_SCOPE,
+    ERROR_DS_OBJECT_BEING_REMOVED,
+    ERROR_DS_CANT_DELETE_DSA_OBJ,
+    ERROR_DS_GENERIC_ERROR,
+    ERROR_DS_DSA_MUST_BE_INT_MASTER,
+    ERROR_DS_CLASS_NOT_DSA,
+    ERROR_DS_INSUFF_ACCESS_RIGHTS,
+    ERROR_DS_ILLEGAL_SUPERIOR,
+    ERROR_DS_ATTRIBUTE_OWNED_BY_SAM,
+    ERROR_DS_NAME_TOO_MANY_PARTS,
+    ERROR_DS_NAME_TOO_LONG,
+    ERROR_DS_NAME_VALUE_TOO_LONG,
+    ERROR_DS_NAME_UNPARSEABLE,
+    ERROR_DS_NAME_TYPE_UNKNOWN,
+    ERROR_DS_NOT_AN_OBJECT,
+    ERROR_DS_SEC_DESC_TOO_SHORT,
+    ERROR_DS_SEC_DESC_INVALID,
+    ERROR_DS_NO_DELETED_NAME,
+    ERROR_DS_SUBREF_MUST_HAVE_PARENT,
+    ERROR_DS_NCNAME_MUST_BE_NC,
+    ERROR_DS_CANT_ADD_SYSTEM_ONLY,
+    ERROR_DS_CLASS_MUST_BE_CONCRETE,
+    ERROR_DS_INVALID_DMD,
+    ERROR_DS_OBJ_GUID_EXISTS,
+    ERROR_DS_NOT_ON_BACKLINK,
+    ERROR_DS_NO_CROSSREF_FOR_NC,
+    ERROR_DS_SHUTTING_DOWN,
+    ERROR_DS_UNKNOWN_OPERATION,
+    ERROR_DS_INVALID_ROLE_OWNER,
+    ERROR_DS_COULDNT_CONTACT_FSMO,
+    ERROR_DS_CROSS_NC_DN_RENAME,
+    ERROR_DS_CANT_MOD_SYSTEM_ONLY,
+    ERROR_DS_REPLICATOR_ONLY,
+    ERROR_DS_OBJ_CLASS_NOT_DEFINED,
+    ERROR_DS_OBJ_CLASS_NOT_SUBCLASS,
+    ERROR_DS_NAME_REFERENCE_INVALID,
+    ERROR_DS_CROSS_REF_EXISTS,
+    ERROR_DS_CANT_DEL_MASTER_CROSSREF,
+    ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD,
+    ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX,
+    ERROR_DS_DUP_RDN,
+    ERROR_DS_DUP_OID,
+    ERROR_DS_DUP_MAPI_ID,
+    ERROR_DS_DUP_SCHEMA_ID_GUID,
+    ERROR_DS_DUP_LDAP_DISPLAY_NAME,
+    ERROR_DS_SEMANTIC_ATT_TEST,
+    ERROR_DS_SYNTAX_MISMATCH,
+    ERROR_DS_EXISTS_IN_MUST_HAVE,
+    ERROR_DS_EXISTS_IN_MAY_HAVE,
+    ERROR_DS_NONEXISTENT_MAY_HAVE,
+    ERROR_DS_NONEXISTENT_MUST_HAVE,
+    ERROR_DS_AUX_CLS_TEST_FAIL,
+    ERROR_DS_NONEXISTENT_POSS_SUP,
+    ERROR_DS_SUB_CLS_TEST_FAIL,
+    ERROR_DS_BAD_RDN_ATT_ID_SYNTAX,
+    ERROR_DS_EXISTS_IN_AUX_CLS,
+    ERROR_DS_EXISTS_IN_SUB_CLS,
+    ERROR_DS_EXISTS_IN_POSS_SUP,
+    ERROR_DS_RECALCSCHEMA_FAILED,
+    ERROR_DS_TREE_DELETE_NOT_FINISHED,
+    ERROR_DS_CANT_DELETE,
+    ERROR_DS_ATT_SCHEMA_REQ_ID,
+    ERROR_DS_BAD_ATT_SCHEMA_SYNTAX,
+    ERROR_DS_CANT_CACHE_ATT,
+    ERROR_DS_CANT_CACHE_CLASS,
+    ERROR_DS_CANT_REMOVE_ATT_CACHE,
+    ERROR_DS_CANT_REMOVE_CLASS_CACHE,
+    ERROR_DS_CANT_RETRIEVE_DN,
+    ERROR_DS_MISSING_SUPREF,
+    ERROR_DS_CANT_RETRIEVE_INSTANCE,
+    ERROR_DS_CODE_INCONSISTENCY,
+    ERROR_DS_DATABASE_ERROR,
+    ERROR_DS_GOVERNSID_MISSING,
+    ERROR_DS_MISSING_EXPECTED_ATT,
+    ERROR_DS_NCNAME_MISSING_CR_REF,
+    ERROR_DS_SECURITY_CHECKING_ERROR,
+    ERROR_DS_SCHEMA_NOT_LOADED,
+    ERROR_DS_SCHEMA_ALLOC_FAILED,
+    ERROR_DS_ATT_SCHEMA_REQ_SYNTAX,
+    ERROR_DS_GCVERIFY_ERROR,
+    ERROR_DS_DRA_SCHEMA_MISMATCH,
+    ERROR_DS_CANT_FIND_DSA_OBJ,
+    ERROR_DS_CANT_FIND_EXPECTED_NC,
+    ERROR_DS_CANT_FIND_NC_IN_CACHE,
+    ERROR_DS_CANT_RETRIEVE_CHILD,
+    ERROR_DS_SECURITY_ILLEGAL_MODIFY,
+    ERROR_DS_CANT_REPLACE_HIDDEN_REC,
+    ERROR_DS_BAD_HIERARCHY_FILE,
+    ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED,
+    ERROR_DS_CONFIG_PARAM_MISSING,
+    ERROR_DS_COUNTING_AB_INDICES_FAILED,
+    ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED,
+    ERROR_DS_INTERNAL_FAILURE,
+    ERROR_DS_UNKNOWN_ERROR,
+    ERROR_DS_ROOT_REQUIRES_CLASS_TOP,
+    ERROR_DS_REFUSING_FSMO_ROLES,
+    ERROR_DS_MISSING_FSMO_SETTINGS,
+    ERROR_DS_UNABLE_TO_SURRENDER_ROLES,
+    ERROR_DS_DRA_GENERIC,
+    ERROR_DS_DRA_INVALID_PARAMETER,
+    ERROR_DS_DRA_BUSY,
+    ERROR_DS_DRA_BAD_DN,
+    ERROR_DS_DRA_BAD_NC,
+    ERROR_DS_DRA_DN_EXISTS,
+    ERROR_DS_DRA_INTERNAL_ERROR,
+    ERROR_DS_DRA_INCONSISTENT_DIT,
+    ERROR_DS_DRA_CONNECTION_FAILED,
+    ERROR_DS_DRA_BAD_INSTANCE_TYPE,
+    ERROR_DS_DRA_OUT_OF_MEM,
+    ERROR_DS_DRA_MAIL_PROBLEM,
+    ERROR_DS_DRA_REF_ALREADY_EXISTS,
+    ERROR_DS_DRA_REF_NOT_FOUND,
+    ERROR_DS_DRA_OBJ_IS_REP_SOURCE,
+    ERROR_DS_DRA_DB_ERROR,
+    ERROR_DS_DRA_NO_REPLICA,
+    ERROR_DS_DRA_ACCESS_DENIED,
+    ERROR_DS_DRA_NOT_SUPPORTED,
+    ERROR_DS_DRA_RPC_CANCELLED,
+    ERROR_DS_DRA_SOURCE_DISABLED,
+    ERROR_DS_DRA_SINK_DISABLED,
+    ERROR_DS_DRA_NAME_COLLISION,
+    ERROR_DS_DRA_SOURCE_REINSTALLED,
+    ERROR_DS_DRA_MISSING_PARENT,
+    ERROR_DS_DRA_PREEMPTED,
+    ERROR_DS_DRA_ABANDON_SYNC,
+    ERROR_DS_DRA_SHUTDOWN,
+    ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET,
+    ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA,
+    ERROR_DS_DRA_EXTN_CONNECTION_FAILED,
+    ERROR_DS_INSTALL_SCHEMA_MISMATCH,
+    ERROR_DS_DUP_LINK_ID,
+    ERROR_DS_NAME_ERROR_RESOLVING,
+    ERROR_DS_NAME_ERROR_NOT_FOUND,
+    ERROR_DS_NAME_ERROR_NOT_UNIQUE,
+    ERROR_DS_NAME_ERROR_NO_MAPPING,
+    ERROR_DS_NAME_ERROR_DOMAIN_ONLY,
+    ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING,
+    ERROR_DS_CONSTRUCTED_ATT_MOD,
+    ERROR_DS_WRONG_OM_OBJ_CLASS,
+    ERROR_DS_DRA_REPL_PENDING,
+    ERROR_DS_DS_REQUIRED,
+    ERROR_DS_INVALID_LDAP_DISPLAY_NAME,
+    ERROR_DS_NON_BASE_SEARCH,
+    ERROR_DS_CANT_RETRIEVE_ATTS,
+    ERROR_DS_BACKLINK_WITHOUT_LINK,
+    ERROR_DS_EPOCH_MISMATCH,
+    ERROR_DS_SRC_NAME_MISMATCH,
+    ERROR_DS_SRC_AND_DST_NC_IDENTICAL,
+    ERROR_DS_DST_NC_MISMATCH,
+    ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC,
+    ERROR_DS_SRC_GUID_MISMATCH,
+    ERROR_DS_CANT_MOVE_DELETED_OBJECT,
+    ERROR_DS_PDC_OPERATION_IN_PROGRESS,
+    ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD,
+    ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION,
+    ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS,
+    ERROR_DS_NC_MUST_HAVE_NC_PARENT,
+    ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE,
+    ERROR_DS_DST_DOMAIN_NOT_NATIVE,
+    ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER,
+    ERROR_DS_CANT_MOVE_ACCOUNT_GROUP,
+    ERROR_DS_CANT_MOVE_RESOURCE_GROUP,
+    ERROR_DS_INVALID_SEARCH_FLAG,
+    ERROR_DS_NO_TREE_DELETE_ABOVE_NC,
+    ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE,
+    ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE,
+    ERROR_DS_SAM_INIT_FAILURE,
+    ERROR_DS_SENSITIVE_GROUP_VIOLATION,
+    ERROR_DS_CANT_MOD_PRIMARYGROUPID,
+    ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD,
+    ERROR_DS_NONSAFE_SCHEMA_CHANGE,
+    ERROR_DS_SCHEMA_UPDATE_DISALLOWED,
+    ERROR_DS_CANT_CREATE_UNDER_SCHEMA,
+    ERROR_DS_INSTALL_NO_SRC_SCH_VERSION,
+    ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE,
+    ERROR_DS_INVALID_GROUP_TYPE,
+    ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN,
+    ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN,
+    ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER,
+    ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER,
+    ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER,
+    ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER,
+    ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER,
+    ERROR_DS_HAVE_PRIMARY_MEMBERS,
+    ERROR_DS_STRING_SD_CONVERSION_FAILED,
+    ERROR_DS_NAMING_MASTER_GC,
+    ERROR_DS_LOOKUP_FAILURE,
+    ERROR_DS_COULDNT_UPDATE_SPNS,
+    ERROR_DS_CANT_RETRIEVE_SD,
+    ERROR_DS_KEY_NOT_UNIQUE,
+    ERROR_DS_WRONG_LINKED_ATT_SYNTAX,
+    ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD,
+    ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY,
+    ERROR_DS_CANT_START,
+    ERROR_DS_INIT_FAILURE,
+    ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION,
+    ERROR_DS_SOURCE_DOMAIN_IN_FOREST,
+    ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST,
+    ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED,
+    ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN,
+    ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER,
+    ERROR_DS_SRC_SID_EXISTS_IN_FOREST,
+    ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH,
+    ERROR_SAM_INIT_FAILURE,
+    ERROR_DS_DRA_SCHEMA_INFO_SHIP,
+    ERROR_DS_DRA_SCHEMA_CONFLICT,
+    ERROR_DS_DRA_EARLIER_SCHEMA_CONLICT,
+    ERROR_DS_DRA_OBJ_NC_MISMATCH,
+    ERROR_DS_NC_STILL_HAS_DSAS,
+    ERROR_DS_GC_REQUIRED,
+    ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY,
+    ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS,
+    ERROR_DS_CANT_ADD_TO_GC,
+    ERROR_DS_NO_CHECKPOINT_WITH_PDC,
+    ERROR_DS_SOURCE_AUDITING_NOT_ENABLED,
+    ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC,
+    ERROR_DS_INVALID_NAME_FOR_SPN,
+    ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS,
+    ERROR_DS_UNICODEPWD_NOT_IN_QUOTES,
+    ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED,
+    ERROR_DS_MUST_BE_RUN_ON_DST_DC,
+    ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER,
+    ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ,
+    ERROR_DS_INIT_FAILURE_CONSOLE,
+    ERROR_DS_SAM_INIT_FAILURE_CONSOLE,
+    ERROR_DS_FOREST_VERSION_TOO_HIGH,
+    ERROR_DS_DOMAIN_VERSION_TOO_HIGH,
+    ERROR_DS_FOREST_VERSION_TOO_LOW,
+    ERROR_DS_DOMAIN_VERSION_TOO_LOW,
+    ERROR_DS_INCOMPATIBLE_VERSION,
+    ERROR_DS_LOW_DSA_VERSION,
+    ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN,
+    ERROR_DS_NOT_SUPPORTED_SORT_ORDER,
+    ERROR_DS_NAME_NOT_UNIQUE,
+    ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4,
+    ERROR_DS_OUT_OF_VERSION_STORE,
+    ERROR_DS_INCOMPATIBLE_CONTROLS_USED,
+    ERROR_DS_NO_REF_DOMAIN,
+    ERROR_DS_RESERVED_LINK_ID,
+    ERROR_DS_LINK_ID_NOT_AVAILABLE,
+    ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER,
+    ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE,
+    ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC,
+    ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG,
+    ERROR_DS_MODIFYDN_WRONG_GRANDPARENT,
+    ERROR_DS_NAME_ERROR_TRUST_REFERRAL,
+    ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER,
+    ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD,
+    ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2,
+    ERROR_DS_THREAD_LIMIT_EXCEEDED,
+    ERROR_DS_NOT_CLOSEST,
+    ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF,
+    ERROR_DS_SINGLE_USER_MODE_FAILED,
+    ERROR_DS_NTDSCRIPT_SYNTAX_ERROR,
+    ERROR_DS_NTDSCRIPT_PROCESS_ERROR,
+    ERROR_DS_DIFFERENT_REPL_EPOCHS,
+    ERROR_DS_DRS_EXTENSIONS_CHANGED,
+    ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR,
+    ERROR_DS_NO_MSDS_INTID,
+    ERROR_DS_DUP_MSDS_INTID,
+    ERROR_DS_EXISTS_IN_RDNATTID,
+    ERROR_DS_AUTHORIZATION_FAILED,
+    ERROR_DS_INVALID_SCRIPT,
+    ERROR_DS_REMOTE_CROSSREF_OP_FAILED,
+    ERROR_DS_CROSS_REF_BUSY,
+    ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN,
+    ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC,
+    ERROR_DS_DUPLICATE_ID_FOUND,
+    ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT,
+    ERROR_DS_GROUP_CONVERSION_ERROR,
+    ERROR_DS_CANT_MOVE_APP_BASIC_GROUP,
+    ERROR_DS_CANT_MOVE_APP_QUERY_GROUP,
+    ERROR_DS_ROLE_NOT_VERIFIED,
+    ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL,
+    ERROR_DS_DOMAIN_RENAME_IN_PROGRESS,
+    ERROR_DS_EXISTING_AD_CHILD_NC,                     // =  8613
+    DNS_ERROR_RCODE_FORMAT_ERROR                          =  9001,
+    DNS_ERROR_RCODE_SERVER_FAILURE,
+    DNS_ERROR_RCODE_NAME_ERROR,
+    DNS_ERROR_RCODE_NOT_IMPLEMENTED,
+    DNS_ERROR_RCODE_REFUSED,
+    DNS_ERROR_RCODE_YXDOMAIN,
+    DNS_ERROR_RCODE_YXRRSET,
+    DNS_ERROR_RCODE_NXRRSET,
+    DNS_ERROR_RCODE_NOTAUTH,
+    DNS_ERROR_RCODE_NOTZONE,                           // =  9010
+    DNS_ERROR_RCODE_BADSIG                                =  9016,
+    DNS_ERROR_RCODE_BADKEY,
+    DNS_ERROR_RCODE_BADTIME,                           // =  9018
+    DNS_INFO_NO_RECORDS                                   =  9501,
+    DNS_ERROR_BAD_PACKET,
+    DNS_ERROR_NO_PACKET,
+    DNS_ERROR_RCODE,
+    DNS_ERROR_UNSECURE_PACKET,                         // =  9505
+    DNS_ERROR_INVALID_TYPE                                =  9551,
+    DNS_ERROR_INVALID_IP_ADDRESS,
+    DNS_ERROR_INVALID_PROPERTY,
+    DNS_ERROR_TRY_AGAIN_LATER,
+    DNS_ERROR_NOT_UNIQUE,
+    DNS_ERROR_NON_RFC_NAME,
+    DNS_STATUS_FQDN,
+    DNS_STATUS_DOTTED_NAME,
+    DNS_STATUS_SINGLE_PART_NAME,
+    DNS_ERROR_INVALID_NAME_CHAR,
+    DNS_ERROR_NUMERIC_NAME,
+    DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER,
+    DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION,
+    DNS_ERROR_CANNOT_FIND_ROOT_HINTS,
+    DNS_ERROR_INCONSISTENT_ROOT_HINTS,                 // =  9565
+    DNS_ERROR_ZONE_DOES_NOT_EXIST                         =  9601,
+    DNS_ERROR_NO_ZONE_INFO,
+    DNS_ERROR_INVALID_ZONE_OPERATION,
+    DNS_ERROR_ZONE_CONFIGURATION_ERROR,
+    DNS_ERROR_ZONE_HAS_NO_SOA_RECORD,
+    DNS_ERROR_ZONE_HAS_NO_NS_RECORDS,
+    DNS_ERROR_ZONE_LOCKED,
+    DNS_ERROR_ZONE_CREATION_FAILED,
+    DNS_ERROR_ZONE_ALREADY_EXISTS,
+    DNS_ERROR_AUTOZONE_ALREADY_EXISTS,
+    DNS_ERROR_INVALID_ZONE_TYPE,
+    DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP,
+    DNS_ERROR_ZONE_NOT_SECONDARY,
+    DNS_ERROR_NEED_SECONDARY_ADDRESSES,
+    DNS_ERROR_WINS_INIT_FAILED,
+    DNS_ERROR_NEED_WINS_SERVERS,
+    DNS_ERROR_NBSTAT_INIT_FAILED,
+    DNS_ERROR_SOA_DELETE_INVALID,
+    DNS_ERROR_FORWARDER_ALREADY_EXISTS,
+    DNS_ERROR_ZONE_REQUIRES_MASTER_IP,
+    DNS_ERROR_ZONE_IS_SHUTDOWN,                        // =  9621
+    DNS_ERROR_PRIMARY_REQUIRES_DATAFILE                   =  9651,
+    DNS_ERROR_INVALID_DATAFILE_NAME,
+    DNS_ERROR_DATAFILE_OPEN_FAILURE,
+    DNS_ERROR_FILE_WRITEBACK_FAILED,
+    DNS_ERROR_DATAFILE_PARSING,                        // =  9655
+    DNS_ERROR_RECORD_DOES_NOT_EXIST                       =  9701,
+    DNS_ERROR_RECORD_FORMAT,
+    DNS_ERROR_NODE_CREATION_FAILED,
+    DNS_ERROR_UNKNOWN_RECORD_TYPE,
+    DNS_ERROR_RECORD_TIMED_OUT,
+    DNS_ERROR_NAME_NOT_IN_ZONE,
+    DNS_ERROR_CNAME_LOOP,
+    DNS_ERROR_NODE_IS_CNAME,
+    DNS_ERROR_CNAME_COLLISION,
+    DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT,
+    DNS_ERROR_RECORD_ALREADY_EXISTS,
+    DNS_ERROR_SECONDARY_DATA,
+    DNS_ERROR_NO_CREATE_CACHE_DATA,
+    DNS_ERROR_NAME_DOES_NOT_EXIST,
+    DNS_WARNING_PTR_CREATE_FAILED,
+    DNS_WARNING_DOMAIN_UNDELETED,
+    DNS_ERROR_DS_UNAVAILABLE,
+    DNS_ERROR_DS_ZONE_ALREADY_EXISTS,
+    DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE,                  // =  9719
+    DNS_INFO_AXFR_COMPLETE                                =  9751,
+    DNS_ERROR_AXFR,
+    DNS_INFO_ADDED_LOCAL_WINS,                         // =  9753
+    DNS_STATUS_CONTINUE_NEEDED                            =  9801,
+    DNS_ERROR_NO_TCPIP                                    =  9851,
+    DNS_ERROR_NO_DNS_SERVERS,                          // =  9852
+    DNS_ERROR_DP_DOES_NOT_EXIST                           =  9901,
+    DNS_ERROR_DP_ALREADY_EXISTS,
+    DNS_ERROR_DP_NOT_ENLISTED,
+    DNS_ERROR_DP_ALREADY_ENLISTED,
+    DNS_ERROR_DP_NOT_AVAILABLE,                        // =  9905
+
+/+  already in winsock2.d defined!
+
+    WSABASEERR                                            = 10000,
+    WSAEINTR                                              = 10004,
+    WSAEBADF                                              = 10009,
+    WSAEACCES                                             = 10013,
+    WSAEFAULT,                                         // = 10014
+    WSAEINVAL                                             = 10022,
+    WSAEMFILE                                             = 10024,
+    WSAEWOULDBLOCK                                        = 10035,
+    WSAEINPROGRESS,
+    WSAEALREADY,
+    WSAENOTSOCK,
+    WSAEDESTADDRREQ,
+    WSAEMSGSIZE,
+    WSAEPROTOTYPE,
+    WSAENOPROTOOPT,
+    WSAEPROTONOSUPPORT,
+    WSAESOCKTNOSUPPORT,
+    WSAEOPNOTSUPP,
+    WSAEPFNOSUPPORT,
+    WSAEAFNOSUPPORT,
+    WSAEADDRINUSE,
+    WSAEADDRNOTAVAIL,
+    WSAENETDOWN,
+    WSAENETUNREACH,
+    WSAENETRESET,
+    WSAECONNABORTED,
+    WSAECONNRESET,
+    WSAENOBUFS,
+    WSAEISCONN,
+    WSAENOTCONN,
+    WSAESHUTDOWN,
+    WSAETOOMANYREFS,
+    WSAETIMEDOUT,
+    WSAECONNREFUSED,
+    WSAELOOP,
+    WSAENAMETOOLONG,
+    WSAEHOSTDOWN,
+    WSAEHOSTUNREACH,
+    WSAENOTEMPTY,
+    WSAEPROCLIM,
+    WSAEUSERS,
+    WSAEDQUOT,
+    WSAESTALE,
+    WSAEREMOTE,                                        // = 10071
+    WSASYSNOTREADY                                        = 10091,
+    WSAVERNOTSUPPORTED,
+    WSANOTINITIALISED,                                 // = 10093
+    WSAEDISCON                                            = 10101,
+    WSAENOMORE,
+    WSAECANCELLED,
+    WSAEINVALIDPROCTABLE,
+    WSAEINVALIDPROVIDER,
+    WSAEPROVIDERFAILEDINIT,
+    WSASYSCALLFAILURE,
+    WSASERVICE_NOT_FOUND,
+    WSATYPE_NOT_FOUND,
+    WSA_E_NO_MORE,
+    WSA_E_CANCELLED,
+    WSAEREFUSED,                                       // = 10112
+    WSAHOST_NOT_FOUND                                     = 11001,
+    WSATRY_AGAIN,
+    WSANO_RECOVERY,
+    WSANO_DATA,
+    WSA_QOS_RECEIVERS,
+    WSA_QOS_SENDERS,
+    WSA_QOS_NO_SENDERS,
+    WSA_QOS_NO_RECEIVERS,
+    WSA_QOS_REQUEST_CONFIRMED,
+    WSA_QOS_ADMISSION_FAILURE,
+    WSA_QOS_POLICY_FAILURE,
+    WSA_QOS_BAD_STYLE,
+    WSA_QOS_BAD_OBJECT,
+    WSA_QOS_TRAFFIC_CTRL_ERROR,
+    WSA_QOS_GENERIC_ERROR,
+    WSA_QOS_ESERVICETYPE,
+    WSA_QOS_EFLOWSPEC,
+    WSA_QOS_EPROVSPECBUF,
+    WSA_QOS_EFILTERSTYLE,
+    WSA_QOS_EFILTERTYPE,
+    WSA_QOS_EFILTERCOUNT,
+    WSA_QOS_EOBJLENGTH,
+    WSA_QOS_EFLOWCOUNT,
+    WSA_QOS_EUNKNOWNPSOBJ,
+    WSA_QOS_EPOLICYOBJ,
+    WSA_QOS_EFLOWDESC,
+    WSA_QOS_EPSFLOWSPEC,
+    WSA_QOS_EPSFILTERSPEC,
+    WSA_QOS_ESDMODEOBJ,
+    WSA_QOS_ESHAPERATEOBJ,
+    WSA_QOS_RESERVED_PETYPE,                           // = 11031
+
++/
+
+    ERROR_IPSEC_QM_POLICY_EXISTS                          = 13000,
+    ERROR_IPSEC_QM_POLICY_NOT_FOUND,
+    ERROR_IPSEC_QM_POLICY_IN_USE,
+    ERROR_IPSEC_MM_POLICY_EXISTS,
+    ERROR_IPSEC_MM_POLICY_NOT_FOUND,
+    ERROR_IPSEC_MM_POLICY_IN_USE,
+    ERROR_IPSEC_MM_FILTER_EXISTS,
+    ERROR_IPSEC_MM_FILTER_NOT_FOUND,
+    ERROR_IPSEC_TRANSPORT_FILTER_EXISTS,
+    ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND,
+    ERROR_IPSEC_MM_AUTH_EXISTS,
+    ERROR_IPSEC_MM_AUTH_NOT_FOUND,
+    ERROR_IPSEC_MM_AUTH_IN_USE,
+    ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND,
+    ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND,
+    ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND,
+    ERROR_IPSEC_TUNNEL_FILTER_EXISTS,
+    ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND,
+    ERROR_IPSEC_MM_FILTER_PENDING_DELETION,
+    ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION,
+    ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION,
+    ERROR_IPSEC_MM_POLICY_PENDING_DELETION,
+    ERROR_IPSEC_MM_AUTH_PENDING_DELETION,
+    ERROR_IPSEC_QM_POLICY_PENDING_DELETION,
+    WARNING_IPSEC_MM_POLICY_PRUNED,
+    WARNING_IPSEC_QM_POLICY_PRUNED,                    // = 13025
+    ERROR_IPSEC_IKE_AUTH_FAIL                             = 13801,
+    ERROR_IPSEC_IKE_ATTRIB_FAIL,
+    ERROR_IPSEC_IKE_NEGOTIATION_PENDING,
+    ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR,
+    ERROR_IPSEC_IKE_TIMED_OUT,
+    ERROR_IPSEC_IKE_NO_CERT,
+    ERROR_IPSEC_IKE_SA_DELETED,
+    ERROR_IPSEC_IKE_SA_REAPED,
+    ERROR_IPSEC_IKE_MM_ACQUIRE_DROP,
+    ERROR_IPSEC_IKE_QM_ACQUIRE_DROP,
+    ERROR_IPSEC_IKE_QUEUE_DROP_MM,
+    ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM,
+    ERROR_IPSEC_IKE_DROP_NO_RESPONSE,
+    ERROR_IPSEC_IKE_MM_DELAY_DROP,
+    ERROR_IPSEC_IKE_QM_DELAY_DROP,
+    ERROR_IPSEC_IKE_ERROR,
+    ERROR_IPSEC_IKE_CRL_FAILED,
+    ERROR_IPSEC_IKE_INVALID_KEY_USAGE,
+    ERROR_IPSEC_IKE_INVALID_CERT_TYPE,
+    ERROR_IPSEC_IKE_NO_PRIVATE_KEY,                    // = 13820
+    ERROR_IPSEC_IKE_DH_FAIL                               = 13822,
+    ERROR_IPSEC_IKE_INVALID_HEADER                        = 13824,
+    ERROR_IPSEC_IKE_NO_POLICY,
+    ERROR_IPSEC_IKE_INVALID_SIGNATURE,
+    ERROR_IPSEC_IKE_KERBEROS_ERROR,
+    ERROR_IPSEC_IKE_NO_PUBLIC_KEY,
+    ERROR_IPSEC_IKE_PROCESS_ERR,
+    ERROR_IPSEC_IKE_PROCESS_ERR_SA,
+    ERROR_IPSEC_IKE_PROCESS_ERR_PROP,
+    ERROR_IPSEC_IKE_PROCESS_ERR_TRANS,
+    ERROR_IPSEC_IKE_PROCESS_ERR_KE,
+    ERROR_IPSEC_IKE_PROCESS_ERR_ID,
+    ERROR_IPSEC_IKE_PROCESS_ERR_CERT,
+    ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ,
+    ERROR_IPSEC_IKE_PROCESS_ERR_HASH,
+    ERROR_IPSEC_IKE_PROCESS_ERR_SIG,
+    ERROR_IPSEC_IKE_PROCESS_ERR_NONCE,
+    ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY,
+    ERROR_IPSEC_IKE_PROCESS_ERR_DELETE,
+    ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR,
+    ERROR_IPSEC_IKE_INVALID_PAYLOAD,
+    ERROR_IPSEC_IKE_LOAD_SOFT_SA,
+    ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN,
+    ERROR_IPSEC_IKE_INVALID_COOKIE,
+    ERROR_IPSEC_IKE_NO_PEER_CERT,
+    ERROR_IPSEC_IKE_PEER_CRL_FAILED,
+    ERROR_IPSEC_IKE_POLICY_CHANGE,
+    ERROR_IPSEC_IKE_NO_MM_POLICY,
+    ERROR_IPSEC_IKE_NOTCBPRIV,
+    ERROR_IPSEC_IKE_SECLOADFAIL,
+    ERROR_IPSEC_IKE_FAILSSPINIT,
+    ERROR_IPSEC_IKE_FAILQUERYSSP,
+    ERROR_IPSEC_IKE_SRVACQFAIL,
+    ERROR_IPSEC_IKE_SRVQUERYCRED,
+    ERROR_IPSEC_IKE_GETSPIFAIL,
+    ERROR_IPSEC_IKE_INVALID_FILTER,
+    ERROR_IPSEC_IKE_OUT_OF_MEMORY,
+    ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED,
+    ERROR_IPSEC_IKE_INVALID_POLICY,
+    ERROR_IPSEC_IKE_UNKNOWN_DOI,
+    ERROR_IPSEC_IKE_INVALID_SITUATION,
+    ERROR_IPSEC_IKE_DH_FAILURE,
+    ERROR_IPSEC_IKE_INVALID_GROUP,
+    ERROR_IPSEC_IKE_ENCRYPT,
+    ERROR_IPSEC_IKE_DECRYPT,
+    ERROR_IPSEC_IKE_POLICY_MATCH,
+    ERROR_IPSEC_IKE_UNSUPPORTED_ID,
+    ERROR_IPSEC_IKE_INVALID_HASH,
+    ERROR_IPSEC_IKE_INVALID_HASH_ALG,
+    ERROR_IPSEC_IKE_INVALID_HASH_SIZE,
+    ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG,
+    ERROR_IPSEC_IKE_INVALID_AUTH_ALG,
+    ERROR_IPSEC_IKE_INVALID_SIG,
+    ERROR_IPSEC_IKE_LOAD_FAILED,
+    ERROR_IPSEC_IKE_RPC_DELETE,
+    ERROR_IPSEC_IKE_BENIGN_REINIT,
+    ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY, // = 13879
+    ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN                   = 13881,
+    ERROR_IPSEC_IKE_MM_LIMIT,
+    ERROR_IPSEC_IKE_NEGOTIATION_DISABLED,
+    ERROR_IPSEC_IKE_NEG_STATUS_END,
+    ERROR_SXS_SECTION_NOT_FOUND,
+    ERROR_SXS_CANT_GEN_ACTCTX,
+    ERROR_SXS_INVALID_ACTCTXDATA_FORMAT,
+    ERROR_SXS_ASSEMBLY_NOT_FOUND,
+    ERROR_SXS_MANIFEST_FORMAT_ERROR,
+    ERROR_SXS_MANIFEST_PARSE_ERROR,
+    ERROR_SXS_ACTIVATION_CONTEXT_DISABLED,
+    ERROR_SXS_KEY_NOT_FOUND,
+    ERROR_SXS_VERSION_CONFLICT,
+    ERROR_SXS_WRONG_SECTION_TYPE,
+    ERROR_SXS_THREAD_QUERIES_DISABLED,
+    ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET,
+    ERROR_SXS_UNKNOWN_ENCODING_GROUP,
+    ERROR_SXS_UNKNOWN_ENCODING,
+    ERROR_SXS_INVALID_XML_NAMESPACE_URI,
+    ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED,
+    ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED,
+    ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE,
+    ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE,
+    ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE,
+    ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT,
+    ERROR_SXS_DUPLICATE_DLL_NAME,
+    ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME,
+    ERROR_SXS_DUPLICATE_CLSID,
+    ERROR_SXS_DUPLICATE_IID,
+    ERROR_SXS_DUPLICATE_TLBID,
+    ERROR_SXS_DUPLICATE_PROGID,
+    ERROR_SXS_DUPLICATE_ASSEMBLY_NAME,
+    ERROR_SXS_FILE_HASH_MISMATCH,
+    ERROR_SXS_POLICY_PARSE_ERROR,
+    ERROR_SXS_XML_E_MISSINGQUOTE,
+    ERROR_SXS_XML_E_COMMENTSYNTAX,
+    ERROR_SXS_XML_E_BADSTARTNAMECHAR,
+    ERROR_SXS_XML_E_BADNAMECHAR,
+    ERROR_SXS_XML_E_BADCHARINSTRING,
+    ERROR_SXS_XML_E_XMLDECLSYNTAX,
+    ERROR_SXS_XML_E_BADCHARDATA,
+    ERROR_SXS_XML_E_MISSINGWHITESPACE,
+    ERROR_SXS_XML_E_EXPECTINGTAGEND,
+    ERROR_SXS_XML_E_MISSINGSEMICOLON,
+    ERROR_SXS_XML_E_UNBALANCEDPAREN,
+    ERROR_SXS_XML_E_INTERNALERROR,
+    ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE,
+    ERROR_SXS_XML_E_INCOMPLETE_ENCODING,
+    ERROR_SXS_XML_E_MISSING_PAREN,
+    ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE,
+    ERROR_SXS_XML_E_MULTIPLE_COLONS,
+    ERROR_SXS_XML_E_INVALID_DECIMAL,
+    ERROR_SXS_XML_E_INVALID_HEXIDECIMAL,
+    ERROR_SXS_XML_E_INVALID_UNICODE,
+    ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK,
+    ERROR_SXS_XML_E_UNEXPECTEDENDTAG,
+    ERROR_SXS_XML_E_UNCLOSEDTAG,
+    ERROR_SXS_XML_E_DUPLICATEATTRIBUTE,
+    ERROR_SXS_XML_E_MULTIPLEROOTS,
+    ERROR_SXS_XML_E_INVALIDATROOTLEVEL,
+    ERROR_SXS_XML_E_BADXMLDECL,
+    ERROR_SXS_XML_E_MISSINGROOT,
+    ERROR_SXS_XML_E_UNEXPECTEDEOF,
+    ERROR_SXS_XML_E_BADPEREFINSUBSET,
+    ERROR_SXS_XML_E_UNCLOSEDSTARTTAG,
+    ERROR_SXS_XML_E_UNCLOSEDENDTAG,
+    ERROR_SXS_XML_E_UNCLOSEDSTRING,
+    ERROR_SXS_XML_E_UNCLOSEDCOMMENT,
+    ERROR_SXS_XML_E_UNCLOSEDDECL,
+    ERROR_SXS_XML_E_UNCLOSEDCDATA,
+    ERROR_SXS_XML_E_RESERVEDNAMESPACE,
+    ERROR_SXS_XML_E_INVALIDENCODING,
+    ERROR_SXS_XML_E_INVALIDSWITCH,
+    ERROR_SXS_XML_E_BADXMLCASE,
+    ERROR_SXS_XML_E_INVALID_STANDALONE,
+    ERROR_SXS_XML_E_UNEXPECTED_STANDALONE,
+    ERROR_SXS_XML_E_INVALID_VERSION,
+    ERROR_SXS_XML_E_MISSINGEQUALS,
+    ERROR_SXS_PROTECTION_RECOVERY_FAILED,
+    ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT,
+    ERROR_SXS_PROTECTION_CATALOG_NOT_VALID,
+    ERROR_SXS_UNTRANSLATABLE_HRESULT,
+    ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING,
+    ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE,
+    ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME // = 14080
+}
+
+enum : HRESULT {
+    S_OK                                   = 0x00000000,
+    S_FALSE                                = 0x00000001,
+
+    NOERROR                                = 0x00000000,
+
+    E_PENDING                              = 0x8000000A,
+    E_NOTIMPL                              = 0x80004001,
+    E_NOINTERFACE                          = 0x80004002,
+    E_POINTER                              = 0x80004003,
+    E_ABORT                                = 0x80004004,
+    E_FAIL                                 = 0x80004005,
+    E_ACCESSDENIED                         = 0x80070005,
+    E_HANDLE                               = 0x80070006,
+    E_OUTOFMEMORY                          = 0x8007000E,
+    E_INVALIDARG                           = 0x80070057,
+    E_UNEXPECTED                           = 0x8000FFFF,
+
+    CO_E_INIT_TLS                          = 0x80004006,
+    CO_E_INIT_SHARED_ALLOCATOR             = 0x80004007,
+    CO_E_INIT_MEMORY_ALLOCATOR             = 0x80004008,
+    CO_E_INIT_CLASS_CACHE                  = 0x80004009,
+    CO_E_INIT_RPC_CHANNEL                  = 0x8000400A,
+    CO_E_INIT_TLS_SET_CHANNEL_CONTROL      = 0x8000400B,
+    CO_E_INIT_TLS_CHANNEL_CONTROL          = 0x8000400C,
+    CO_E_INIT_UNACCEPTED_USER_ALLOCATOR    = 0x8000400D,
+    CO_E_INIT_SCM_MUTEX_EXISTS             = 0x8000400E,
+    CO_E_INIT_SCM_FILE_MAPPING_EXISTS      = 0x8000400F,
+    CO_E_INIT_SCM_MAP_VIEW_OF_FILE         = 0x80004010,
+    CO_E_INIT_SCM_EXEC_FAILURE             = 0x80004011,
+    CO_E_INIT_ONLY_SINGLE_THREADED         = 0x80004012,
+
+    RPC_E_CALL_REJECTED                    = 0x80010001,
+    RPC_E_CALL_CANCELED                    = 0x80010002,
+    RPC_E_CANTPOST_INSENDCALL              = 0x80010003,
+    RPC_E_CANTCALLOUT_INASYNCCALL          = 0x80010004,
+    RPC_E_CANTCALLOUT_INEXTERNALCALL       = 0x80010005,
+    RPC_E_CONNECTION_TERMINATED            = 0x80010006,
+    RPC_E_SERVER_DIED                      = 0x80010007,
+    RPC_E_CLIENT_DIED                      = 0x80010008,
+    RPC_E_INVALID_DATAPACKET               = 0x80010009,
+    RPC_E_CANTTRANSMIT_CALL                = 0x8001000A,
+    RPC_E_CLIENT_CANTMARSHAL_DATA          = 0x8001000B,
+    RPC_E_CLIENT_CANTUNMARSHAL_DATA        = 0x8001000C,
+    RPC_E_SERVER_CANTMARSHAL_DATA          = 0x8001000D,
+    RPC_E_SERVER_CANTUNMARSHAL_DATA        = 0x8001000E,
+    RPC_E_INVALID_DATA                     = 0x8001000F,
+    RPC_E_INVALID_PARAMETER                = 0x80010010,
+    RPC_E_CANTCALLOUT_AGAIN                = 0x80010011,
+    RPC_E_SERVER_DIED_DNE                  = 0x80010012,
+    RPC_E_SYS_CALL_FAILED                  = 0x80010100,
+    RPC_E_OUT_OF_RESOURCES                 = 0x80010101,
+    RPC_E_ATTEMPTED_MULTITHREAD            = 0x80010102,
+    RPC_E_NOT_REGISTERED                   = 0x80010103,
+    RPC_E_FAULT                            = 0x80010104,
+    RPC_E_SERVERFAULT                      = 0x80010105,
+    RPC_E_CHANGED_MODE                     = 0x80010106,
+    RPC_E_INVALIDMETHOD                    = 0x80010107,
+    RPC_E_DISCONNECTED                     = 0x80010108,
+    RPC_E_RETRY                            = 0x80010109,
+    RPC_E_SERVERCALL_RETRYLATER            = 0x8001010A,
+    RPC_E_SERVERCALL_REJECTED              = 0x8001010B,
+    RPC_E_INVALID_CALLDATA                 = 0x8001010C,
+    RPC_E_CANTCALLOUT_ININPUTSYNCCALL      = 0x8001010D,
+    RPC_E_WRONG_THREAD                     = 0x8001010E,
+    RPC_E_THREAD_NOT_INIT                  = 0x8001010F,
+    RPC_E_UNEXPECTED                       = 0x8001FFFF,
+
+    DISP_E_UNKNOWNINTERFACE                = 0x80020001,
+    DISP_E_MEMBERNOTFOUND                  = 0x80020003,
+    DISP_E_PARAMNOTFOUND                   = 0x80020004,
+    DISP_E_TYPEMISMATCH                    = 0x80020005,
+    DISP_E_UNKNOWNNAME                     = 0x80020006,
+    DISP_E_NONAMEDARGS                     = 0x80020007,
+    DISP_E_BADVARTYPE                      = 0x80020008,
+    DISP_E_EXCEPTION                       = 0x80020009,
+    DISP_E_OVERFLOW                        = 0x8002000A,
+    DISP_E_BADINDEX                        = 0x8002000B,
+    DISP_E_UNKNOWNLCID                     = 0x8002000C,
+    DISP_E_ARRAYISLOCKED                   = 0x8002000D,
+    DISP_E_BADPARAMCOUNT                   = 0x8002000E,
+    DISP_E_PARAMNOTOPTIONAL                = 0x8002000F,
+    DISP_E_BADCALLEE                       = 0x80020010,
+    DISP_E_NOTACOLLECTION                  = 0x80020011,
+    DISP_E_DIVBYZERO                       = 0x80020012,
+
+    TYPE_E_BUFFERTOOSMALL                  = 0x80028016,
+    TYPE_E_INVDATAREAD                     = 0x80028018,
+    TYPE_E_UNSUPFORMAT                     = 0x80028019,
+    TYPE_E_REGISTRYACCESS                  = 0x8002801C,
+    TYPE_E_LIBNOTREGISTERED                = 0x8002801D,
+    TYPE_E_UNDEFINEDTYPE                   = 0x80028027,
+    TYPE_E_QUALIFIEDNAMEDISALLOWED         = 0x80028028,
+    TYPE_E_INVALIDSTATE                    = 0x80028029,
+    TYPE_E_WRONGTYPEKIND                   = 0x8002802A,
+    TYPE_E_ELEMENTNOTFOUND                 = 0x8002802B,
+    TYPE_E_AMBIGUOUSNAME                   = 0x8002802C,
+    TYPE_E_NAMECONFLICT                    = 0x8002802D,
+    TYPE_E_UNKNOWNLCID                     = 0x8002802E,
+    TYPE_E_DLLFUNCTIONNOTFOUND             = 0x8002802F,
+    TYPE_E_BADMODULEKIND                   = 0x800288BD,
+    TYPE_E_SIZETOOBIG                      = 0x800288C5,
+    TYPE_E_DUPLICATEID                     = 0x800288C6,
+    TYPE_E_INVALIDID                       = 0x800288CF,
+    TYPE_E_TYPEMISMATCH                    = 0x80028CA0,
+    TYPE_E_OUTOFBOUNDS                     = 0x80028CA1,
+    TYPE_E_IOERROR                         = 0x80028CA2,
+    TYPE_E_CANTCREATETMPFILE               = 0x80028CA3,
+    TYPE_E_CANTLOADLIBRARY                 = 0x80029C4A,
+    TYPE_E_INCONSISTENTPROPFUNCS           = 0x80029C83,
+    TYPE_E_CIRCULARTYPE                    = 0x80029C84,
+
+    STG_E_INVALIDFUNCTION                  = 0x80030001,
+    STG_E_FILENOTFOUND                     = 0x80030002,
+    STG_E_PATHNOTFOUND                     = 0x80030003,
+    STG_E_TOOMANYOPENFILES                 = 0x80030004,
+    STG_E_ACCESSDENIED                     = 0x80030005,
+    STG_E_INVALIDHANDLE                    = 0x80030006,
+    STG_E_INSUFFICIENTMEMORY               = 0x80030008,
+    STG_E_INVALIDPOINTER                   = 0x80030009,
+    STG_E_NOMOREFILES                      = 0x80030012,
+    STG_E_DISKISWRITEPROTECTED             = 0x80030013,
+    STG_E_SEEKERROR                        = 0x80030019,
+    STG_E_WRITEFAULT                       = 0x8003001D,
+    STG_E_READFAULT                        = 0x8003001E,
+    STG_E_SHAREVIOLATION                   = 0x80030020,
+    STG_E_LOCKVIOLATION                    = 0x80030021,
+    STG_E_FILEALREADYEXISTS                = 0x80030050,
+    STG_E_INVALIDPARAMETER                 = 0x80030057,
+    STG_E_MEDIUMFULL                       = 0x80030070,
+    STG_E_ABNORMALAPIEXIT                  = 0x800300FA,
+    STG_E_INVALIDHEADER                    = 0x800300FB,
+    STG_E_INVALIDNAME                      = 0x800300FC,
+    STG_E_UNKNOWN                          = 0x800300FD,
+    STG_E_UNIMPLEMENTEDFUNCTION            = 0x800300FE,
+    STG_E_INVALIDFLAG                      = 0x800300FF,
+    STG_E_INUSE                            = 0x80030100,
+    STG_E_NOTCURRENT                       = 0x80030101,
+    STG_E_REVERTED                         = 0x80030102,
+    STG_E_CANTSAVE                         = 0x80030103,
+    STG_E_OLDFORMAT                        = 0x80030104,
+    STG_E_OLDDLL                           = 0x80030105,
+    STG_E_SHAREREQUIRED                    = 0x80030106,
+    STG_E_NOTFILEBASEDSTORAGE              = 0x80030107,
+    STG_E_EXTANTMARSHALLINGS               = 0x80030108,
+    STG_S_CONVERTED                        = 0x00030200,
+
+    OLE_E_FIRST                            = 0x80040000,
+    OLE_S_FIRST                            = 0x00040000,
+    OLE_E_OLEVERB                          = 0x80040000,
+    OLE_S_USEREG                           = 0x00040000,
+    OLE_E_ADVF                             = 0x80040001,
+    OLE_S_STATIC                           = 0x00040001,
+    OLE_E_ENUM_NOMORE                      = 0x80040002,
+    OLE_S_MAC_CLIPFORMAT                   = 0x00040002,
+    OLE_E_ADVISENOTSUPPORTED               = 0x80040003,
+    OLE_E_NOCONNECTION                     = 0x80040004,
+    OLE_E_NOTRUNNING                       = 0x80040005,
+    OLE_E_NOCACHE                          = 0x80040006,
+    OLE_E_BLANK                            = 0x80040007,
+    OLE_E_CLASSDIFF                        = 0x80040008,
+    OLE_E_CANT_GETMONIKER                  = 0x80040009,
+    OLE_E_CANT_BINDTOSOURCE                = 0x8004000A,
+    OLE_E_STATIC                           = 0x8004000B,
+    OLE_E_PROMPTSAVECANCELLED              = 0x8004000C,
+    OLE_E_INVALIDRECT                      = 0x8004000D,
+    OLE_E_WRONGCOMPOBJ                     = 0x8004000E,
+    OLE_E_INVALIDHWND                      = 0x8004000F,
+    OLE_E_NOT_INPLACEACTIVE                = 0x80040010,
+    OLE_E_CANTCONVERT                      = 0x80040011,
+    OLE_E_NOSTORAGE                        = 0x80040012,
+
+    DV_E_FORMATETC                         = 0x80040064,
+    DV_E_DVTARGETDEVICE                    = 0x80040065,
+    DV_E_STGMEDIUM                         = 0x80040066,
+    DV_E_STATDATA                          = 0x80040067,
+    DV_E_LINDEX                            = 0x80040068,
+    DV_E_TYMED                             = 0x80040069,
+    DV_E_CLIPFORMAT                        = 0x8004006A,
+    DV_E_DVASPECT                          = 0x8004006B,
+    DV_E_DVTARGETDEVICE_SIZE               = 0x8004006C,
+    DV_E_NOIVIEWOBJECT                     = 0x8004006D,
+
+    OLE_E_LAST                             = 0x800400FF,
+    OLE_S_LAST                             = 0x000400FF,
+    DRAGDROP_E_FIRST                       = 0x80040100,
+    DRAGDROP_S_FIRST                       = 0x00040100,
+    DRAGDROP_E_NOTREGISTERED               = 0x80040100,
+    DRAGDROP_S_DROP                        = 0x00040100,
+    DRAGDROP_E_ALREADYREGISTERED           = 0x80040101,
+    DRAGDROP_S_CANCEL                      = 0x00040101,
+    DRAGDROP_E_INVALIDHWND                 = 0x80040102,
+    DRAGDROP_S_USEDEFAULTCURSORS           = 0x00040102,
+    DRAGDROP_E_LAST                        = 0x8004010F,
+    DRAGDROP_S_LAST                        = 0x0004010F,
+    CLASSFACTORY_E_FIRST                   = 0x80040110,
+    CLASSFACTORY_S_FIRST                   = 0x00040110,
+    CLASS_E_NOAGGREGATION                  = 0x80040110,
+    CLASS_E_CLASSNOTAVAILABLE              = 0x80040111,
+    CLASSFACTORY_E_LAST                    = 0x8004011F,
+    CLASSFACTORY_S_LAST                    = 0x0004011F,
+    MARSHAL_E_FIRST                        = 0x80040120,
+    MARSHAL_S_FIRST                        = 0x00040120,
+    MARSHAL_E_LAST                         = 0x8004012F,
+    MARSHAL_S_LAST                         = 0x0004012F,
+    DATA_E_FIRST                           = 0x80040130,
+    DATA_S_FIRST                           = 0x00040130,
+    DATA_S_SAMEFORMATETC                   = 0x00040130,
+    DATA_E_LAST                            = 0x8004013F,
+    DATA_S_LAST                            = 0x0004013F,
+    VIEW_E_FIRST                           = 0x80040140,
+    VIEW_S_FIRST                           = 0x00040140,
+    VIEW_E_DRAW                            = 0x80040140,
+    VIEW_S_ALREADY_FROZEN                  = 0x00040140,
+    VIEW_E_LAST                            = 0x8004014F,
+    VIEW_S_LAST                            = 0x0004014F,
+    REGDB_E_FIRST                          = 0x80040150,
+    REGDB_S_FIRST                          = 0x00040150,
+    REGDB_E_READREGDB                      = 0x80040150,
+    REGDB_E_WRITEREGDB                     = 0x80040151,
+    REGDB_E_KEYMISSING                     = 0x80040152,
+    REGDB_E_INVALIDVALUE                   = 0x80040153,
+    REGDB_E_CLASSNOTREG                    = 0x80040154,
+    REGDB_E_IIDNOTREG                      = 0x80040155,
+    REGDB_E_LAST                           = 0x8004015F,
+    REGDB_S_LAST                           = 0x0004015F,
+    CACHE_E_FIRST                          = 0x80040170,
+    CACHE_S_FIRST                          = 0x00040170,
+    CACHE_E_NOCACHE_UPDATED                = 0x80040170,
+    CACHE_S_FORMATETC_NOTSUPPORTED         = 0x00040170,
+    CACHE_S_SAMECACHE                      = 0x00040171,
+    CACHE_S_SOMECACHES_NOTUPDATED          = 0x00040172,
+    CACHE_E_LAST                           = 0x8004017F,
+    CACHE_S_LAST                           = 0x0004017F,
+    OLEOBJ_E_FIRST                         = 0x80040180,
+    OLEOBJ_S_FIRST                         = 0x00040180,
+    OLEOBJ_E_NOVERBS                       = 0x80040180,
+    OLEOBJ_S_INVALIDVERB                   = 0x00040180,
+    OLEOBJ_E_INVALIDVERB                   = 0x80040181,
+    OLEOBJ_S_CANNOT_DOVERB_NOW             = 0x00040181,
+    OLEOBJ_S_INVALIDHWND                   = 0x00040182,
+    OLEOBJ_E_LAST                          = 0x8004018F,
+    OLEOBJ_S_LAST                          = 0x0004018F,
+    CLIENTSITE_E_FIRST                     = 0x80040190,
+    CLIENTSITE_S_FIRST                     = 0x00040190,
+    CLIENTSITE_E_LAST                      = 0x8004019F,
+    CLIENTSITE_S_LAST                      = 0x0004019F,
+    INPLACE_E_NOTUNDOABLE                  = 0x800401A0,
+    INPLACE_E_FIRST                        = 0x800401A0,
+    INPLACE_S_FIRST                        = 0x000401A0,
+    INPLACE_S_TRUNCATED                    = 0x000401A0,
+    INPLACE_E_NOTOOLSPACE                  = 0x800401A1,
+    INPLACE_E_LAST                         = 0x800401AF,
+    INPLACE_S_LAST                         = 0x000401AF,
+    ENUM_E_FIRST                           = 0x800401B0,
+    ENUM_S_FIRST                           = 0x000401B0,
+    ENUM_E_LAST                            = 0x800401BF,
+    ENUM_S_LAST                            = 0x000401BF,
+    CONVERT10_E_FIRST                      = 0x800401C0,
+    CONVERT10_S_FIRST                      = 0x000401C0,
+    CONVERT10_E_OLESTREAM_GET              = 0x800401C0,
+    CONVERT10_S_NO_PRESENTATION            = 0x000401C0,
+    CONVERT10_E_OLESTREAM_PUT              = 0x800401C1,
+    CONVERT10_E_OLESTREAM_FMT              = 0x800401C2,
+    CONVERT10_E_OLESTREAM_BITMAP_TO_DIB    = 0x800401C3,
+    CONVERT10_E_STG_FMT                    = 0x800401C4,
+    CONVERT10_E_STG_NO_STD_STREAM          = 0x800401C5,
+    CONVERT10_E_STG_DIB_TO_BITMAP          = 0x800401C6,
+    CONVERT10_E_LAST                       = 0x800401CF,
+    CONVERT10_S_LAST                       = 0x000401CF,
+    CLIPBRD_E_FIRST                        = 0x800401D0,
+    CLIPBRD_S_FIRST                        = 0x000401D0,
+    CLIPBRD_E_CANT_OPEN                    = 0x800401D0,
+    CLIPBRD_E_CANT_EMPTY                   = 0x800401D1,
+    CLIPBRD_E_CANT_SET                     = 0x800401D2,
+    CLIPBRD_E_BAD_DATA                     = 0x800401D3,
+    CLIPBRD_E_CANT_CLOSE                   = 0x800401D4,
+    CLIPBRD_E_LAST                         = 0x800401DF,
+    CLIPBRD_S_LAST                         = 0x000401DF,
+    MK_E_FIRST                             = 0x800401E0,
+    MK_S_FIRST                             = 0x000401E0,
+    MK_E_CONNECTMANUALLY                   = 0x800401E0,
+    MK_E_EXCEEDEDDEADLINE                  = 0x800401E1,
+    MK_E_NEEDGENERIC                       = 0x800401E2,
+    MK_S_REDUCED_TO_SELF                   = 0x000401E2,
+    MK_E_UNAVAILABLE                       = 0x800401E3,
+    MK_E_SYNTAX                            = 0x800401E4,
+    MK_S_ME                                = 0x000401E4,
+    MK_E_NOOBJECT                          = 0x800401E5,
+    MK_S_HIM                               = 0x000401E5,
+    MK_E_INVALIDEXTENSION                  = 0x800401E6,
+    MK_S_US                                = 0x000401E6,
+    MK_E_INTERMEDIATEINTERFACENOTSUPPORTED = 0x800401E7,
+    MK_S_MONIKERALREADYREGISTERED          = 0x000401E7,
+    MK_E_NOTBINDABLE                       = 0x800401E8,
+    MK_E_NOTBOUND                          = 0x800401E9,
+    MK_E_CANTOPENFILE                      = 0x800401EA,
+    MK_E_MUSTBOTHERUSER                    = 0x800401EB,
+    MK_E_NOINVERSE                         = 0x800401EC,
+    MK_E_NOSTORAGE                         = 0x800401ED,
+    MK_E_NOPREFIX                          = 0x800401EE,
+    MK_E_LAST                              = 0x800401EF,
+    MK_S_LAST                              = 0x000401EF,
+    MK_E_ENUMERATION_FAILED                = 0x800401EF,
+    CO_E_FIRST                             = 0x800401F0,
+    CO_S_FIRST                             = 0x000401F0,
+    CO_E_NOTINITIALIZED                    = 0x800401F0,
+    CO_E_ALREADYINITIALIZED                = 0x800401F1,
+    CO_E_CANTDETERMINECLASS                = 0x800401F2,
+    CO_E_CLASSSTRING                       = 0x800401F3,
+    CO_E_IIDSTRING                         = 0x800401F4,
+    CO_E_APPNOTFOUND                       = 0x800401F5,
+    CO_E_APPSINGLEUSE                      = 0x800401F6,
+    CO_E_ERRORINAPP                        = 0x800401F7,
+    CO_E_DLLNOTFOUND                       = 0x800401F8,
+    CO_E_ERRORINDLL                        = 0x800401F9,
+    CO_E_WRONGOSFORAPP                     = 0x800401FA,
+    CO_E_OBJNOTREG                         = 0x800401FB,
+    CO_E_OBJISREG                          = 0x800401FC,
+    CO_E_OBJNOTCONNECTED                   = 0x800401FD,
+    CO_E_APPDIDNTREG                       = 0x800401FE,
+    CO_E_LAST                              = 0x800401FF,
+    CO_S_LAST                              = 0x000401FF,
+    CO_E_RELEASED                          = 0x800401FF,
+
+    CO_E_CLASS_CREATE_FAILED               = 0x80080001,
+    CO_E_SCM_ERROR                         = 0x80080002,
+    CO_E_SCM_RPC_FAILURE                   = 0x80080003,
+    CO_E_BAD_PATH                          = 0x80080004,
+    CO_E_SERVER_EXEC_FAILURE               = 0x80080005,
+    CO_E_OBJSRV_RPC_FAILURE                = 0x80080006,
+    MK_E_NO_NORMALIZED                     = 0x80080007,
+    CO_E_SERVER_STOPPING                   = 0x80080008,
+    MEM_E_INVALID_ROOT                     = 0x80080009,
+    MEM_E_INVALID_LINK                     = 0x80080010,
+    MEM_E_INVALID_SIZE                     = 0x80080011,
+    CO_S_NOTALLINTERFACES                  = 0x00080012,
+
+    NTE_BAD_UID                            = 0x80090001,
+    NTE_BAD_HASH                           = 0x80090002,
+    NTE_BAD_KEY                            = 0x80090003,
+    NTE_BAD_LEN                            = 0x80090004,
+    NTE_BAD_DATA                           = 0x80090005,
+    NTE_BAD_SIGNATURE                      = 0x80090006,
+    NTE_BAD_VER                            = 0x80090007,
+    NTE_BAD_ALGID                          = 0x80090008,
+    NTE_BAD_FLAGS                          = 0x80090009,
+    NTE_BAD_TYPE                           = 0x8009000A,
+    NTE_BAD_KEY_STATE                      = 0x8009000B,
+    NTE_BAD_HASH_STATE                     = 0x8009000C,
+    NTE_NO_KEY                             = 0x8009000D,
+    NTE_NO_MEMORY                          = 0x8009000E,
+    NTE_EXISTS                             = 0x8009000F,
+    NTE_PERM                               = 0x80090010,
+    NTE_NOT_FOUND                          = 0x80090011,
+    NTE_DOUBLE_ENCRYPT                     = 0x80090012,
+    NTE_BAD_PROVIDER                       = 0x80090013,
+    NTE_BAD_PROV_TYPE                      = 0x80090014,
+    NTE_BAD_PUBLIC_KEY                     = 0x80090015,
+    NTE_BAD_KEYSET                         = 0x80090016,
+    NTE_PROV_TYPE_NOT_DEF                  = 0x80090017,
+    NTE_PROV_TYPE_ENTRY_BAD                = 0x80090018,
+    NTE_KEYSET_NOT_DEF                     = 0x80090019,
+    NTE_KEYSET_ENTRY_BAD                   = 0x8009001A,
+    NTE_PROV_TYPE_NO_MATCH                 = 0x8009001B,
+    NTE_SIGNATURE_FILE_BAD                 = 0x8009001C,
+    NTE_PROVIDER_DLL_FAIL                  = 0x8009001D,
+    NTE_PROV_DLL_NOT_FOUND                 = 0x8009001E,
+    NTE_BAD_KEYSET_PARAM                   = 0x8009001F,
+    NTE_FAIL                               = 0x80090020,
+    NTE_SYS_ERR                            = 0x80090021
+}
+
+
+enum : bool {
+    SEVERITY_SUCCESS = 0,
+    SEVERITY_ERROR   = 1
+}
+
+enum : uint {
+    FACILITY_NULL     =   0,
+    FACILITY_RPC,
+    FACILITY_DISPATCH,
+    FACILITY_STORAGE,
+    FACILITY_ITF,  // =   4
+    FACILITY_WIN32    =   7,
+    FACILITY_WINDOWS  =   8,
+    FACILITY_CONTROL  =  10,
+    FACILITY_NT_BIT   = 0x10000000
+}
+
+// C Macros
+
+pure nothrow @nogc {
+    bool SUCCEEDED(HRESULT Status) {
+        return Status >= 0;
+    }
+
+    bool FAILED(HRESULT Status) {
+        return Status < 0;
+    }
+
+    bool IS_ERROR(HRESULT Status) {
+        return (Status >>> 31) == SEVERITY_ERROR;
+    }
+
+    ushort HRESULT_CODE(HRESULT r) {
+        return cast(ushort) (r & 0xFFFF);
+    }
+
+    ushort SCODE_CODE(SCODE r) {
+        return cast(ushort) (r & 0xFFFF);
+    }
+
+    ushort HRESULT_FACILITY(HRESULT r) {
+        return cast(ushort) ((r>>16) & 0x1fff);
+    }
+
+    ushort SCODE_FACILITY(SCODE r) {
+        return cast(ushort) ((r>>16) & 0x1fff);
+    }
+
+    ushort HRESULT_SEVERITY(HRESULT r) {
+        return cast(ushort) ((r>>31) & 0x1);
+    }
+
+    ushort SCODE_SEVERITY(SCODE r) {
+        return cast(ushort) ((r>>31) & 0x1);
+    }
+
+    HRESULT MAKE_HRESULT(bool s, uint f, uint c) {
+        return (s << 31) | (f << 16) | c;
+    }
+
+    SCODE MAKE_SCODE(bool s, uint f, uint c) {
+        return (s << 31) | (f << 16) | c;
+    }
+
+    SCODE GetScode(HRESULT hr) {
+        return hr;
+    }
+
+    HRESULT ResultFromScode(SCODE c) {
+        return c;
+    }
+
+    HRESULT HRESULT_FROM_NT(HRESULT x) {
+        return x | FACILITY_NT_BIT;
+    }
+
+    HRESULT HRESULT_FROM_WIN32(HRESULT x) {
+        return  x ? (x & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000 : 0;
+    }
+
+    HRESULT PropagateResult(HRESULT hrPrevious, SCODE scBase) {
+        return scBase;
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/windows/wingdi.d b/libphobos/libdruntime/core/sys/windows/wingdi.d
new file mode 100644
index 00000000000..ccfb9887bc4
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/wingdi.d
@@ -0,0 +1,4572 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_wingdi.d)
+ */
+module core.sys.windows.wingdi;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "gdi32");
+
+// FIXME: clean up Windows version support
+
+private import core.sys.windows.w32api, core.sys.windows.windef, core.sys.windows.winver;
+
+// BITMAPINFOHEADER.biCompression
+enum : DWORD {
+    BI_RGB = 0,
+    BI_RLE8,
+    BI_RLE4,
+    BI_BITFIELDS,
+    BI_JPEG,
+    BI_PNG
+}
+
+// ---
+// COLORADJUSTMENT -- only for NT 3.1+, Win2000+
+enum WORD
+    CA_NEGATIVE   = 1,
+    CA_LOG_FILTER = 2;
+
+// COLORADJUSTMENT
+enum : WORD  {
+    ILLUMINANT_DEVICE_DEFAULT = 0,
+    ILLUMINANT_A,
+    ILLUMINANT_B,
+    ILLUMINANT_C,
+    ILLUMINANT_D50,
+    ILLUMINANT_D55,
+    ILLUMINANT_D65,
+    ILLUMINANT_D75,
+    ILLUMINANT_F2,
+    ILLUMINANT_MAX_INDEX   = ILLUMINANT_F2,
+    ILLUMINANT_TUNGSTEN    = ILLUMINANT_A,
+    ILLUMINANT_DAYLIGHT    = ILLUMINANT_C,
+    ILLUMINANT_FLUORESCENT = ILLUMINANT_F2,
+    ILLUMINANT_NTSC        = ILLUMINANT_C
+}
+
+enum {
+    RGB_GAMMA_MIN       = 2500,
+    RGB_GAMMA_MAX       = 65000,
+    REFERENCE_WHITE_MIN = 6000,
+    REFERENCE_WHITE_MAX = 10000,
+    REFERENCE_BLACK_MIN = 0,
+    REFERENCE_BLACK_MAX = 4000,
+    COLOR_ADJ_MIN       = -100,
+    COLOR_ADJ_MAX       = 100,
+}
+//---
+
+/* FIXME: move to core.sys.windows.winuser ? */
+// DrawIconEx()
+enum : UINT {
+    DI_MASK        = 1,
+    DI_IMAGE       = 2,
+    DI_NORMAL      = 3,
+    DI_COMPAT      = 4,
+    DI_DEFAULTSIZE = 8
+}
+
+// DOCINFO
+enum : DWORD {
+    DI_APPBANDING = 1,
+    DI_ROPS_READ_DESTINATION = 2,
+}
+
+// ENHMETAHEADER
+enum : DWORD {
+    EMR_HEADER = 1,
+    EMR_POLYBEZIER,
+    EMR_POLYGON,
+    EMR_POLYLINE,
+    EMR_POLYBEZIERTO,
+    EMR_POLYLINETO,
+    EMR_POLYPOLYLINE,
+    EMR_POLYPOLYGON,
+    EMR_SETWINDOWEXTEX,
+    EMR_SETWINDOWORGEX,
+    EMR_SETVIEWPORTEXTEX,
+    EMR_SETVIEWPORTORGEX,
+    EMR_SETBRUSHORGEX,
+    EMR_EOF,
+    EMR_SETPIXELV,
+    EMR_SETMAPPERFLAGS,
+    EMR_SETMAPMODE,
+    EMR_SETBKMODE,
+    EMR_SETPOLYFILLMODE,
+    EMR_SETROP2,
+    EMR_SETSTRETCHBLTMODE,
+    EMR_SETTEXTALIGN,
+    EMR_SETCOLORADJUSTMENT,
+    EMR_SETTEXTCOLOR,
+    EMR_SETBKCOLOR,
+    EMR_OFFSETCLIPRGN,
+    EMR_MOVETOEX,
+    EMR_SETMETARGN,
+    EMR_EXCLUDECLIPRECT,
+    EMR_INTERSECTCLIPRECT,
+    EMR_SCALEVIEWPORTEXTEX,
+    EMR_SCALEWINDOWEXTEX,
+    EMR_SAVEDC,
+    EMR_RESTOREDC,
+    EMR_SETWORLDTRANSFORM,
+    EMR_MODIFYWORLDTRANSFORM,
+    EMR_SELECTOBJECT,
+    EMR_CREATEPEN,
+    EMR_CREATEBRUSHINDIRECT,
+    EMR_DELETEOBJECT,
+    EMR_ANGLEARC,
+    EMR_ELLIPSE,
+    EMR_RECTANGLE,
+    EMR_ROUNDRECT,
+    EMR_ARC,
+    EMR_CHORD,
+    EMR_PIE,
+    EMR_SELECTPALETTE,
+    EMR_CREATEPALETTE,
+    EMR_SETPALETTEENTRIES,
+    EMR_RESIZEPALETTE,
+    EMR_REALIZEPALETTE,
+    EMR_EXTFLOODFILL,
+    EMR_LINETO,
+    EMR_ARCTO,
+    EMR_POLYDRAW,
+    EMR_SETARCDIRECTION,
+    EMR_SETMITERLIMIT,
+    EMR_BEGINPATH,
+    EMR_ENDPATH,
+    EMR_CLOSEFIGURE,
+    EMR_FILLPATH,
+    EMR_STROKEANDFILLPATH,
+    EMR_STROKEPATH,
+    EMR_FLATTENPATH,
+    EMR_WIDENPATH,
+    EMR_SELECTCLIPPATH,
+    EMR_ABORTPATH, // 68
+    // reserved 69
+    EMR_GDICOMMENT = 70,
+    EMR_FILLRGN,
+    EMR_FRAMERGN,
+    EMR_INVERTRGN,
+    EMR_PAINTRGN,
+    EMR_EXTSELECTCLIPRGN,
+    EMR_BITBLT,
+    EMR_STRETCHBLT,
+    EMR_MASKBLT,
+    EMR_PLGBLT,
+    EMR_SETDIBITSTODEVICE,
+    EMR_STRETCHDIBITS,
+    EMR_EXTCREATEFONTINDIRECTW,
+    EMR_EXTTEXTOUTA,
+    EMR_EXTTEXTOUTW,
+    EMR_POLYBEZIER16,
+    EMR_POLYGON16,
+    EMR_POLYLINE16,
+    EMR_POLYBEZIERTO16,
+    EMR_POLYLINETO16,
+    EMR_POLYPOLYLINE16,
+    EMR_POLYPOLYGON16,
+    EMR_POLYDRAW16,
+    EMR_CREATEMONOBRUSH,
+    EMR_CREATEDIBPATTERNBRUSHPT,
+    EMR_EXTCREATEPEN,
+    EMR_POLYTEXTOUTA,
+    EMR_POLYTEXTOUTW, // 97
+    EMR_SETICMMODE,
+    EMR_CREATECOLORSPACE,
+    EMR_SETCOLORSPACE,
+    EMR_DELETECOLORSPACE,
+    EMR_GLSRECORD,
+    EMR_GLSBOUNDEDRECORD,
+    EMR_PIXELFORMAT, // = 104
+    // reserved 105 - 110
+    EMR_COLORCORRECTPALETTE = 111,
+    EMR_SETICMPROFILEA,
+    EMR_SETICMPROFILEW,
+    EMR_ALPHABLEND,
+    EMR_SETLAYOUT,
+    EMR_TRANSPARENTBLT, // 116
+    // reserved 117
+    EMR_GRADIENTFILL = 118,
+    // reserved 119, 120
+    EMR_COLORMATCHTOTARGETW = 121,
+    EMR_CREATECOLORSPACEW // 122
+}
+
+enum EMR_MIN = EMR_HEADER;
+
+static if (_WIN32_WINNT >= 0x500) {
+enum EMR_MAX = EMR_CREATECOLORSPACEW;
+} else {
+enum EMR_MAX = EMR_PIXELFORMAT;
+}
+
+// ENHMETAHEADER.dSignature, ENHMETAHEADER3.dSignature,
+// EMRFORMAT.dSignature
+enum : DWORD {
+    ENHMETA_SIGNATURE = 1179469088,
+    EPS_SIGNATURE     = 0x46535045
+}
+
+static if (_WIN32_WINNT >= 0x500) {
+    // AddFontResourceEx()
+    enum : DWORD {
+        FR_PRIVATE  = 0x10,
+        FR_NOT_ENUM = 0x20
+    }
+}
+
+enum {
+    META_SAVEDC                = 0x1E,
+    META_REALIZEPALETTE        = 0x35,
+    META_SETPALENTRIES         = 0x37,
+    META_CREATEPALETTE         = 0xf7,
+    META_SETBKMODE             = 0x102,
+    META_SETMAPMODE            = 0x103,
+    META_SETROP2               = 0x104,
+    META_SETRELABS             = 0x105,
+    META_SETPOLYFILLMODE       = 0x106,
+    META_SETSTRETCHBLTMODE     = 0x107,
+    META_SETTEXTCHAREXTRA      = 0x108,
+    META_RESTOREDC             = 0x127,
+    META_INVERTREGION          = 0x12A,
+    META_PAINTREGION           = 0x12B,
+    META_SELECTCLIPREGION      = 0x12C,
+    META_SELECTOBJECT          = 0x12D,
+    META_SETTEXTALIGN          = 0x12E,
+    META_RESIZEPALETTE         = 0x139,
+    META_DIBCREATEPATTERNBRUSH = 0x142,
+    META_SETLAYOUT             = 0x149,
+    META_DELETEOBJECT          = 0x1F0,
+    META_CREATEPATTERNBRUSH    = 0x1F9,
+    META_SETBKCOLOR            = 0x201,
+    META_SETTEXTCOLOR          = 0x209,
+    META_SETTEXTJUSTIFICATION  = 0x20A,
+    META_SETWINDOWORG          = 0x20B,
+    META_SETWINDOWEXT          = 0x20C,
+    META_SETVIEWPORTORG        = 0x20D,
+    META_SETVIEWPORTEXT        = 0x20E,
+    META_OFFSETWINDOWORG       = 0x20F,
+    META_OFFSETVIEWPORTORG     = 0x211,
+    META_LINETO                = 0x213,
+    META_MOVETO                = 0x214,
+    META_OFFSETCLIPRGN         = 0x220,
+    META_FILLREGION            = 0x228,
+    META_SETMAPPERFLAGS        = 0x231,
+    META_SELECTPALETTE         = 0x234,
+    META_CREATEPENINDIRECT     = 0x2FA,
+    META_CREATEFONTINDIRECT    = 0x2FB,
+    META_CREATEBRUSHINDIRECT   = 0x2FC,
+    META_POLYGON               = 0x324,
+    META_POLYLINE              = 0x325,
+    META_SCALEWINDOWEXT        = 0x410,
+    META_SCALEVIEWPORTEXT      = 0x412,
+    META_EXCLUDECLIPRECT       = 0x415,
+    META_INTERSECTCLIPRECT     = 0x416,
+    META_ELLIPSE               = 0x418,
+    META_FLOODFILL             = 0x419,
+    META_RECTANGLE             = 0x41B,
+    META_SETPIXEL              = 0x41F,
+    META_FRAMEREGION           = 0x429,
+    META_ANIMATEPALETTE        = 0x436,
+    META_TEXTOUT               = 0x521,
+    META_POLYPOLYGON           = 0x538,
+    META_EXTFLOODFILL          = 0x548,
+    META_ROUNDRECT             = 0x61C,
+    META_PATBLT                = 0x61D,
+    META_ESCAPE                = 0x626,
+    META_CREATEREGION          = 0x6FF,
+    META_ARC                   = 0x817,
+    META_PIE                   = 0x81A,
+    META_CHORD                 = 0x830,
+    META_BITBLT                = 0x922,
+    META_DIBBITBLT             = 0x940,
+    META_EXTTEXTOUT            = 0xA32,
+    META_STRETCHBLT            = 0xB23,
+    META_DIBSTRETCHBLT         = 0xB41,
+    META_SETDIBTODEV           = 0xD33,
+    META_STRETCHDIB            = 0xF43
+}
+
+// EMRPOLYDRAW
+enum : BYTE {
+    PT_CLOSEFIGURE = 1,
+    PT_LINETO      = 2,
+    PT_BEZIERTO    = 4,
+    PT_MOVETO      = 6
+}
+
+// ----
+// PIXELFORMATDESCRIPTOR.iPixelType
+enum : BYTE {
+    PFD_TYPE_RGBA       = 0,
+    PFD_TYPE_COLORINDEX = 1
+}
+
+//deprecated {
+// PIXELFORMATDESCRIPTOR.
+enum byte
+    PFD_MAIN_PLANE     = 0,
+    PFD_OVERLAY_PLANE  = 1,
+    PFD_UNDERLAY_PLANE = -1;
+//}
+// PIXELFORMATDESCRIPTOR.dwFlags
+enum DWORD
+    PFD_DOUBLEBUFFER          = 0x00000001,
+    PFD_STEREO                = 0x00000002,
+    PFD_DRAW_TO_WINDOW        = 0x00000004,
+    PFD_DRAW_TO_BITMAP        = 0x00000008,
+    PFD_SUPPORT_GDI           = 0x00000010,
+    PFD_SUPPORT_OPENGL        = 0x00000020,
+    PFD_GENERIC_FORMAT        = 0x00000040,
+    PFD_NEED_PALETTE          = 0x00000080,
+    PFD_NEED_SYSTEM_PALETTE   = 0x00000100,
+    PFD_SWAP_EXCHANGE         = 0x00000200,
+    PFD_SWAP_COPY             = 0x00000400,
+    PFD_SWAP_LAYER_BUFFERS    = 0x00000800,
+    PFD_GENERIC_ACCELERATED   = 0x00001000,
+    PFD_SUPPORT_DIRECTDRAW    = 0x00002000,
+    PFD_DIRECT3D_ACCELERATED  = 0x00004000,
+    PFD_SUPPORT_COMPOSITION   = 0x00008000,
+    /* PIXELFORMATDESCRIPTOR flags for use in ChoosePixelFormat only */
+    PFD_DEPTH_DONTCARE        = 0x20000000,
+    PFD_DOUBLEBUFFER_DONTCARE = 0x40000000,
+    PFD_STEREO_DONTCARE       = 0x80000000;
+
+// ----
+
+enum DWORD
+    BLACKNESS   = 0x000042,
+    NOTSRCERASE = 0x1100A6,
+    NOTSRCCOPY  = 0x330008,
+    SRCERASE    = 0x440328,
+    DSTINVERT   = 0x550009,
+    PATINVERT   = 0x5A0049,
+    SRCINVERT   = 0x660046,
+    SRCAND      = 0x8800C6,
+    MERGEPAINT  = 0xBB0226,
+    MERGECOPY   = 0xC000CA,
+    SRCCOPY     = 0xCC0020,
+    SRCPAINT    = 0xEE0086,
+    PATCOPY     = 0xF00021,
+    PATPAINT    = 0xFB0A09,
+    WHITENESS   = 0xFF0062;
+static if (_WIN32_WINNT >= 0x500) {
+enum DWORD
+        NOMIRRORBITMAP = 0x80000000,
+        CAPTUREBLT     = 0x40000000;
+}
+
+// GetROP2(), SetROP2()
+enum : int {
+    R2_BLACK       = 1,
+    R2_NOTMERGEPEN = 2,
+    R2_MASKNOTPEN  = 3,
+    R2_NOTCOPYPEN  = 4,
+    R2_MASKPENNOT  = 5,
+    R2_NOT         = 6,
+    R2_XORPEN      = 7,
+    R2_NOTMASKPEN  = 8,
+    R2_MASKPEN     = 9,
+    R2_NOTXORPEN   = 10,
+    R2_NOP         = 11,
+    R2_MERGENOTPEN = 12,
+    R2_COPYPEN     = 13,
+    R2_MERGEPENNOT = 14,
+    R2_MERGEPEN    = 15,
+    R2_WHITE       = 16
+}
+
+enum R2_LAST = R2_WHITE;
+
+// CheckColorsInGamut()
+enum ubyte
+    CM_IN_GAMUT     = 0,
+    CM_OUT_OF_GAMUT = 255;
+
+/* UpdateICMRegKey Constants               */
+enum int
+    ICM_ADDPROFILE = 1,
+    ICM_DELETEPROFILE = 2,
+    ICM_QUERYPROFILE = 3,
+    ICM_SETDEFAULTPROFILE = 4,
+    ICM_REGISTERICMATCHER = 5,
+    ICM_UNREGISTERICMATCHER = 6,
+    ICM_QUERYMATCH = 7;
+
+enum : int {
+    RGN_AND  = 1,
+    RGN_OR   = 2,
+    RGN_XOR  = 3,
+    RGN_DIFF = 4,
+    RGN_COPY = 5
+}
+
+enum RGN_MIN = RGN_AND;
+enum RGN_MAX = RGN_COPY;
+
+// Return values for CombineRgn()
+enum {
+    NULLREGION    = 1,
+    SIMPLEREGION  = 2,
+    COMPLEXREGION = 3
+}
+
+enum ERROR = 0;
+alias ERROR RGN_ERROR;
+
+// CreateDIBitmap()
+enum DWORD CBM_INIT = 4;
+
+// CreateDIBitmap()
+enum : UINT {
+    DIB_RGB_COLORS = 0,
+    DIB_PAL_COLORS = 1
+}
+
+// ---
+//  Values for LOGFONT and CreateFont()
+
+// FIXME: For D, replace with lfFaceName.length()
+enum LF_FACESIZE     = 32;
+enum LF_FULLFACESIZE = 64;
+
+// FIXME: Not needed for D, only EXTLOGFONT
+enum ELF_VENDOR_SIZE = 4;
+
+// ???
+enum ELF_VERSION = 0;
+enum ELF_CULTURE_LATIN = 0;
+
+// LOGFONT.lfWeight
+enum LONG
+    FW_DONTCARE   = 0,
+    FW_THIN       = 100,
+    FW_EXTRALIGHT = 200,
+    FW_ULTRALIGHT = FW_EXTRALIGHT,
+    FW_LIGHT      = 300,
+    FW_NORMAL     = 400,
+    FW_REGULAR    = FW_NORMAL,
+    FW_MEDIUM     = 500,
+    FW_SEMIBOLD   = 600,
+    FW_DEMIBOLD   = FW_SEMIBOLD,
+    FW_BOLD       = 700,
+    FW_EXTRABOLD  = 800,
+    FW_ULTRABOLD  = FW_EXTRABOLD,
+    FW_HEAVY      = 900,
+    FW_BLACK      = FW_HEAVY;
+
+// LOGFONT.lfCharSet
+enum : DWORD {
+    ANSI_CHARSET        = 0,
+    DEFAULT_CHARSET     = 1,
+    SYMBOL_CHARSET      = 2,
+    MAC_CHARSET         = 77,
+    SHIFTJIS_CHARSET    = 128,
+    HANGEUL_CHARSET     = 129,
+    HANGUL_CHARSET      = 129,
+    JOHAB_CHARSET       = 130,
+    GB2312_CHARSET      = 134,
+    CHINESEBIG5_CHARSET = 136,
+    GREEK_CHARSET       = 161,
+    TURKISH_CHARSET     = 162,
+    VIETNAMESE_CHARSET  = 163,
+    HEBREW_CHARSET      = 177,
+    ARABIC_CHARSET      = 178,
+    BALTIC_CHARSET      = 186,
+    RUSSIAN_CHARSET     = 204,
+    THAI_CHARSET        = 222,
+    EASTEUROPE_CHARSET  = 238,
+    OEM_CHARSET         = 255
+}
+
+// LOGFONT.lfOutPrecision
+enum : BYTE {
+    OUT_DEFAULT_PRECIS = 0,
+    OUT_STRING_PRECIS,
+    OUT_CHARACTER_PRECIS,
+    OUT_STROKE_PRECIS,
+    OUT_TT_PRECIS,
+    OUT_DEVICE_PRECIS,
+    OUT_RASTER_PRECIS,
+    OUT_TT_ONLY_PRECIS,
+    OUT_OUTLINE_PRECIS,
+    OUT_SCREEN_OUTLINE_PRECIS,
+    OUT_PS_ONLY_PRECIS, // 10
+}
+
+// LOGFONT.lfClipPrecision
+enum : BYTE  {
+    CLIP_DEFAULT_PRECIS   = 0,
+    CLIP_CHARACTER_PRECIS = 1,
+    CLIP_STROKE_PRECIS    = 2,
+    CLIP_MASK             = 15,
+    CLIP_LH_ANGLES        = 16,
+    CLIP_TT_ALWAYS        = 32,
+    CLIP_DFA_DISABLE      = 64,
+    CLIP_EMBEDDED         = 128
+}
+
+// LOGFONT.lfQuality
+enum : BYTE {
+    DEFAULT_QUALITY = 0,
+    DRAFT_QUALITY,
+    PROOF_QUALITY,
+    NONANTIALIASED_QUALITY,
+    ANTIALIASED_QUALITY
+}
+
+// LOGFONT.lfPitchAndFamily
+
+enum BYTE
+    DEFAULT_PITCH  = 0,
+    FIXED_PITCH    = 1,
+    VARIABLE_PITCH = 2,
+    MONO_FONT      = 8,
+    FF_DONTCARE    = 0,
+    FF_ROMAN       = 16,
+    FF_SWISS       = 32,
+    FF_SCRIPT      = 64,
+    FF_MODERN      = 48,
+    FF_DECORATIVE  = 80;
+
+// ----
+// Enums for the PANOSE struct
+
+enum PANOSE_COUNT=10;
+
+enum {
+    PAN_FAMILYTYPE_INDEX = 0,
+    PAN_SERIFSTYLE_INDEX,
+    PAN_WEIGHT_INDEX,
+    PAN_PROPORTION_INDEX,
+    PAN_CONTRAST_INDEX,
+    PAN_STROKEVARIATION_INDEX,
+    PAN_ARMSTYLE_INDEX,
+    PAN_LETTERFORM_INDEX,
+    PAN_MIDLINE_INDEX,
+    PAN_XHEIGHT_INDEX
+}
+
+enum PAN_CULTURE_LATIN=0;
+
+// NOTE: the first two values (PAN_ANY and PAN_NO_FIT) apply to all these enums!
+enum : BYTE {
+    PAN_ANY    = 0,
+    PAN_NO_FIT = 1,
+}
+
+enum : BYTE {
+    PAN_FAMILY_TEXT_DISPLAY = 2,
+    PAN_FAMILY_SCRIPT,
+    PAN_FAMILY_DECORATIVE,
+    PAN_FAMILY_PICTORIAL
+}
+enum : BYTE {
+    PAN_SERIF_COVE = 2,
+    PAN_SERIF_OBTUSE_COVE,
+    PAN_SERIF_SQUARE_COVE,
+    PAN_SERIF_OBTUSE_SQUARE_COVE,
+    PAN_SERIF_SQUARE,
+    PAN_SERIF_THIN,
+    PAN_SERIF_BONE,
+    PAN_SERIF_EXAGGERATED,
+    PAN_SERIF_TRIANGLE,
+    PAN_SERIF_NORMAL_SANS,
+    PAN_SERIF_OBTUSE_SANS,
+    PAN_SERIF_PERP_SANS,
+    PAN_SERIF_FLARED,
+    PAN_SERIF_ROUNDED
+}
+
+enum : BYTE {
+    PAN_WEIGHT_VERY_LIGHT = 2,
+    PAN_WEIGHT_LIGHT,
+    PAN_WEIGHT_THIN,
+    PAN_WEIGHT_BOOK,
+    PAN_WEIGHT_MEDIUM,
+    PAN_WEIGHT_DEMI,
+    PAN_WEIGHT_BOLD,
+    PAN_WEIGHT_HEAVY,
+    PAN_WEIGHT_BLACK,
+    PAN_WEIGHT_NORD
+}
+
+enum : BYTE {
+    PAN_PROP_OLD_STYLE = 2,
+    PAN_PROP_MODERN,
+    PAN_PROP_EVEN_WIDTH,
+    PAN_PROP_EXPANDED,
+    PAN_PROP_CONDENSED,
+    PAN_PROP_VERY_EXPANDED,
+    PAN_PROP_VERY_CONDENSED,
+    PAN_PROP_MONOSPACED
+}
+
+enum : BYTE {
+    PAN_CONTRAST_NONE = 2,
+    PAN_CONTRAST_VERY_LOW,
+    PAN_CONTRAST_LOW,
+    PAN_CONTRAST_MEDIUM_LOW,
+    PAN_CONTRAST_MEDIUM,
+    PAN_CONTRAST_MEDIUM_HIGH,
+    PAN_CONTRAST_HIGH,
+    PAN_CONTRAST_VERY_HIGH
+}
+
+// PANOSE.bStrokeVariation
+enum : BYTE {
+    PAN_STROKE_GRADUAL_DIAG = 2,
+    PAN_STROKE_GRADUAL_TRAN,
+    PAN_STROKE_GRADUAL_VERT,
+    PAN_STROKE_GRADUAL_HORZ,
+    PAN_STROKE_RAPID_VERT,
+    PAN_STROKE_RAPID_HORZ,
+    PAN_STROKE_INSTANT_VERT
+}
+
+// PANOSE.bArmStyle
+enum : BYTE {
+    PAN_STRAIGHT_ARMS_HORZ = 2,
+    PAN_STRAIGHT_ARMS_WEDGE,
+    PAN_STRAIGHT_ARMS_VERT,
+    PAN_STRAIGHT_ARMS_SINGLE_SERIF,
+    PAN_STRAIGHT_ARMS_DOUBLE_SERIF,
+    PAN_BENT_ARMS_HORZ,
+    PAN_BENT_ARMS_WEDGE,
+    PAN_BENT_ARMS_VERT,
+    PAN_BENT_ARMS_SINGLE_SERIF,
+    PAN_BENT_ARMS_DOUBLE_SERIF
+}
+
+// PANOSE.bLetterForm
+enum : BYTE {
+    PAN_LETT_NORMAL_CONTACT = 2,
+    PAN_LETT_NORMAL_WEIGHTED,
+    PAN_LETT_NORMAL_BOXED,
+    PAN_LETT_NORMAL_FLATTENED,
+    PAN_LETT_NORMAL_ROUNDED,
+    PAN_LETT_NORMAL_OFF_CENTER,
+    PAN_LETT_NORMAL_SQUARE,
+    PAN_LETT_OBLIQUE_CONTACT,
+    PAN_LETT_OBLIQUE_WEIGHTED,
+    PAN_LETT_OBLIQUE_BOXED,
+    PAN_LETT_OBLIQUE_FLATTENED,
+    PAN_LETT_OBLIQUE_ROUNDED,
+    PAN_LETT_OBLIQUE_OFF_CENTER,
+    PAN_LETT_OBLIQUE_SQUARE
+}
+
+// PANOSE.bMidLine
+enum : BYTE {
+    PAN_MIDLINE_STANDARD_TRIMMED = 2,
+    PAN_MIDLINE_STANDARD_POINTED,
+    PAN_MIDLINE_STANDARD_SERIFED,
+    PAN_MIDLINE_HIGH_TRIMMED,
+    PAN_MIDLINE_HIGH_POINTED,
+    PAN_MIDLINE_HIGH_SERIFED,
+    PAN_MIDLINE_CONSTANT_TRIMMED,
+    PAN_MIDLINE_CONSTANT_POINTED,
+    PAN_MIDLINE_CONSTANT_SERIFED,
+    PAN_MIDLINE_LOW_TRIMMED,
+    PAN_MIDLINE_LOW_POINTED,
+    PAN_MIDLINE_LOW_SERIFED
+}
+
+// PANOSE.bXHeight
+enum : BYTE {
+    PAN_XHEIGHT_CONSTANT_SMALL = 2,
+    PAN_XHEIGHT_CONSTANT_STD,
+    PAN_XHEIGHT_CONSTANT_LARGE,
+    PAN_XHEIGHT_DUCKING_SMALL,
+    PAN_XHEIGHT_DUCKING_STD,
+    PAN_XHEIGHT_DUCKING_LARGE
+}
+
+// ----
+// ???
+enum FS_LATIN1      = 0x00000001;
+enum FS_LATIN2      = 0x00000002;
+enum FS_CYRILLIC    = 0x00000004;
+enum FS_GREEK       = 0x00000008;
+enum FS_TURKISH     = 0x00000010;
+enum FS_HEBREW      = 0x00000020;
+enum FS_ARABIC      = 0x00000040;
+enum FS_BALTIC      = 0x00000080;
+enum FS_VIETNAMESE  = 0x00000100;
+enum FS_THAI        = 0x00010000;
+enum FS_JISJAPAN    = 0x00020000;
+enum FS_CHINESESIMP = 0x00040000;
+enum FS_WANSUNG     = 0x00080000;
+enum FS_CHINESETRAD = 0x00100000;
+enum FS_JOHAB       = 0x00200000;
+enum FS_SYMBOL      = 0x80000000;
+
+// ----
+// Poly Fill Mode
+enum : int {
+    ALTERNATE = 1,
+    WINDING = 2
+}
+enum int POLYFILL_LAST = WINDING;
+
+//---
+// LOGBRUSH
+enum : LONG {
+    HS_HORIZONTAL = 0,
+    HS_VERTICAL,
+    HS_FDIAGONAL,
+    HS_BDIAGONAL,
+    HS_CROSS,
+    HS_DIAGCROSS
+}
+
+//LOGBRUSH.lbStyle
+enum : UINT {
+    BS_SOLID = 0,
+    BS_NULL  = 1,
+    BS_HOLLOW = BS_NULL,
+    BS_HATCHED,
+    BS_PATTERN,
+    BS_INDEXED,
+    BS_DIBPATTERN,
+    BS_DIBPATTERNPT,
+    BS_PATTERN8X8,
+    BS_DIBPATTERN8X8,
+    BS_MONOPATTERN,
+}
+//-----
+// EXTLOGPEN, ExtCreatePen()
+
+// EXTLOGPEN.elpPenStyle
+enum : DWORD {
+    PS_SOLID       = 0,
+    PS_DASH        = 1,
+    PS_DOT         = 2,
+    PS_DASHDOT     = 3,
+    PS_DASHDOTDOT  = 4,
+    PS_NULL        = 5,
+    PS_INSIDEFRAME = 6,
+    PS_USERSTYLE   = 7,
+    PS_ALTERNATE   = 8,
+    PS_STYLE_MASK  = 15,
+}
+
+enum : DWORD {
+    PS_COSMETIC      = 0x00000000,
+    PS_GEOMETRIC     = 0x00010000,
+    PS_TYPE_MASK     = 0x000F0000,
+}
+enum : DWORD {
+    PS_ENDCAP_ROUND  = 0x00000000,
+    PS_ENDCAP_SQUARE = 0x00000100,
+    PS_ENDCAP_FLAT   = 0x00000200,
+    PS_ENDCAP_MASK   = 0x00000F00,
+}
+enum : DWORD {
+    PS_JOIN_ROUND    = 0x00000000,
+    PS_JOIN_BEVEL    = 0x00001000,
+    PS_JOIN_MITER    = 0x00002000,
+    PS_JOIN_MASK     = 0x0000F000,
+}
+
+// ---
+// DeviceCapabilities()
+
+enum : WORD {
+    DC_FIELDS = 1,
+    DC_PAPERS,
+    DC_PAPERSIZE,
+    DC_MINEXTENT,
+    DC_MAXEXTENT,
+    DC_BINS,
+    DC_DUPLEX,
+    DC_SIZE,
+    DC_EXTRA,
+    DC_VERSION,
+    DC_DRIVER,
+    DC_BINNAMES,
+    DC_ENUMRESOLUTIONS,
+    DC_FILEDEPENDENCIES,
+    DC_TRUETYPE,
+    DC_PAPERNAMES,
+    DC_ORIENTATION,
+    DC_COPIES,
+    DC_BINADJUST,
+    DC_EMF_COMPLIANT,
+    DC_DATATYPE_PRODUCED,
+    DC_COLLATE,
+    DC_MANUFACTURER,
+    DC_MODEL,
+}
+
+static if (_WIN32_WINNT >= 0x500) {
+    enum {
+        DC_PERSONALITY = 25,
+        DC_PRINTRATE = 26,
+        DC_PRINTRATEUNIT = 27,
+        DC_PRINTERMEM = 28,
+        DC_MEDIAREADY = 29,
+        DC_STAPLE = 30,
+        DC_PRINTRATEPPM = 31,
+        DC_COLORDEVICE = 32,
+        DC_NUP = 33,
+        DC_MEDIATYPENAMES = 34,
+        DC_MEDIATYPES = 35,
+    }
+    enum {
+        PRINTRATEUNIT_PPM = 1,
+        PRINTRATEUNIT_CPS = 2,
+        PRINTRATEUNIT_LPM = 3,
+        PRINTRATEUNIT_IPM = 4,
+    }
+}
+
+
+// return from DC_TRUETYPE
+enum DWORD
+    DCTT_BITMAP           = 1,
+    DCTT_DOWNLOAD         = 2,
+    DCTT_SUBDEV           = 4,
+    DCTT_DOWNLOAD_OUTLINE = 8;
+
+// return from DC_BINADJUST
+enum : DWORD {
+    DCBA_FACEUPNONE     = 0x0000,
+    DCBA_FACEUPCENTER   = 0x0001,
+    DCBA_FACEUPLEFT     = 0x0002,
+    DCBA_FACEUPRIGHT    = 0x0003,
+    DCBA_FACEDOWNNONE   = 0x0100,
+    DCBA_FACEDOWNCENTER = 0x0101,
+    DCBA_FACEDOWNLEFT   = 0x0102,
+    DCBA_FACEDOWNRIGHT  = 0x0103,
+}
+//---
+
+enum FLOODFILLBORDER  = 0;
+enum FLOODFILLSURFACE = 1;
+
+// ExtTextOut()
+enum UINT
+    ETO_OPAQUE         = 0x0002,
+    ETO_CLIPPED        = 0x0004,
+    ETO_GLYPH_INDEX    = 0x0010,
+    ETO_RTLREADING     = 0x0080,
+    ETO_NUMERICSLOCAL  = 0x0400,
+    ETO_NUMERICSLATIN  = 0x0800,
+    ETO_IGNORELANGUAGE = 0x1000;
+static if (_WIN32_WINNT >= 0x500) {
+enum UINT
+        ETO_PDY = 0x2000;
+}
+
+// GdiComment()
+enum {
+    GDICOMMENT_BEGINGROUP       = 0x00000002,
+    GDICOMMENT_ENDGROUP         = 0x00000003,
+    GDICOMMENT_UNICODE_STRING   = 0x00000040,
+    GDICOMMENT_UNICODE_END      = 0x00000080,
+    GDICOMMENT_MULTIFORMATS     = 0x40000004,
+    GDICOMMENT_IDENTIFIER       = 0x43494447,
+    GDICOMMENT_WINDOWS_METAFILE = 0x80000001,
+}
+
+// Get/SetArcDirection()
+enum : int {
+    AD_COUNTERCLOCKWISE = 1,
+    AD_CLOCKWISE        = 2
+}
+
+enum RDH_RECTANGLES = 1;
+
+// GCPRESULTS.lpClass
+enum {
+    GCPCLASS_LATIN  = 1,
+    GCPCLASS_HEBREW = 2,
+    GCPCLASS_ARABIC = 2,
+    GCPCLASS_NEUTRAL,
+    GCPCLASS_LOCALNUMBER,
+    GCPCLASS_LATINNUMBER,
+    GCPCLASS_LATINNUMERICTERMINATOR,
+    GCPCLASS_LATINNUMERICSEPARATOR,
+    GCPCLASS_NUMERICSEPARATOR, // = 8,
+    GCPCLASS_POSTBOUNDRTL = 16,
+    GCPCLASS_POSTBOUNDLTR = 32,
+    GCPCLASS_PREBOUNDRTL  = 64,
+    GCPCLASS_PREBOUNDLTR  = 128,
+    GCPGLYPH_LINKAFTER    = 0x4000,
+    GCPGLYPH_LINKBEFORE   = 0x8000
+}
+
+// GetBoundsRect(), SetBoundsRect()
+enum UINT
+    DCB_RESET      = 1,
+    DCB_ACCUMULATE = 2,
+    DCB_SET        = DCB_RESET | DCB_ACCUMULATE,
+    DCB_ENABLE     = 4,
+    DCB_DISABLE    = 8,
+    DCB_DIRTY      = DCB_ACCUMULATE;
+
+//---
+// GetObjectType()
+enum : DWORD {
+    OBJ_PEN = 1,
+    OBJ_BRUSH,
+    OBJ_DC,
+    OBJ_METADC,
+    OBJ_PAL,
+    OBJ_FONT,
+    OBJ_BITMAP,
+    OBJ_REGION,
+    OBJ_METAFILE,
+    OBJ_MEMDC,
+    OBJ_EXTPEN,
+    OBJ_ENHMETADC,
+    OBJ_ENHMETAFILE,
+    OBJ_COLORSPACE,
+}
+
+//---------------------
+// Capabilities for GetDeviceCaps(dc, xxx)
+
+enum : int {
+    DRIVERVERSION   = 0,
+    TECHNOLOGY      = 2,
+    HORZSIZE        = 4,
+    VERTSIZE        = 6,
+    HORZRES         = 8,
+    VERTRES         = 10,
+    BITSPIXEL       = 12,
+    PLANES          = 14,
+    NUMBRUSHES      = 16,
+    NUMPENS         = 18,
+    NUMMARKERS      = 20,
+    NUMFONTS        = 22,
+    NUMCOLORS       = 24,
+    PDEVICESIZE     = 26,
+    CURVECAPS       = 28,
+    LINECAPS        = 30,
+    POLYGONALCAPS   = 32,
+    TEXTCAPS        = 34,
+    CLIPCAPS        = 36,
+    RASTERCAPS      = 38,
+    ASPECTX         = 40,
+    ASPECTY         = 42,
+    ASPECTXY        = 44,
+    LOGPIXELSX      = 88,
+    LOGPIXELSY      = 90,
+    SIZEPALETTE     = 104,
+    NUMRESERVED     = 106,
+    COLORRES        = 108,
+    PHYSICALWIDTH   = 110,
+    PHYSICALHEIGHT  = 111,
+    PHYSICALOFFSETX = 112,
+    PHYSICALOFFSETY = 113,
+    SCALINGFACTORX  = 114,
+    SCALINGFACTORY  = 115,
+    VREFRESH        = 116,
+    DESKTOPVERTRES  = 117,
+    DESKTOPHORZRES  = 118,
+    BLTALIGNMENT    = 119
+}
+static if (_WIN32_WINNT >= 0x500) {
+enum : int {
+    SHADEBLENDCAPS  = 120,
+    COLORMGMTCAPS   = 121,
+}
+}
+
+// Return values for GetDeviceCaps(dc, TECHNOLOGY)
+enum : int {
+    DT_PLOTTER = 0,
+    DT_RASDISPLAY,
+    DT_RASPRINTER,
+    DT_RASCAMERA,
+    DT_CHARSTREAM,
+    DT_METAFILE,
+    DT_DISPFILE // = 6
+}
+
+// Return values for GetDeviceCaps(dc, RASTERCAPS)
+enum int
+    RC_NONE         = 0,
+    RC_BITBLT       = 1,
+    RC_BANDING      = 2,
+    RC_SCALING      = 4,
+    RC_BITMAP64     = 8,
+    RC_GDI20_OUTPUT = 16,
+    RC_GDI20_STATE  = 32,
+    RC_SAVEBITMAP   = 64,
+    RC_DI_BITMAP    = 128,
+    RC_PALETTE      = 256,
+    RC_DIBTODEV     = 512,
+    RC_BIGFONT      = 1024,
+    RC_STRETCHBLT   = 2048,
+    RC_FLOODFILL    = 4096,
+    RC_STRETCHDIB   = 8192,
+    RC_OP_DX_OUTPUT = 0x4000,
+    RC_DEVBITS      = 0x8000;
+
+static if (_WIN32_WINNT >= 0x500) {
+    /* Shading and blending caps */
+enum SB_NONE = 0x00000000;
+enum SB_CONST_ALPHA = 0x00000001;
+enum SB_PIXEL_ALPHA = 0x00000002;
+enum SB_PREMULT_ALPHA = 0x00000004;
+enum SB_GRAD_RECT = 0x00000010;
+enum SB_GRAD_TRI = 0x00000020;
+    /* Color Management caps */
+enum CM_NONE = 0x00000000;
+enum CM_DEVICE_ICM = 0x00000001;
+enum CM_GAMMA_RAMP = 0x00000002;
+enum CM_CMYK_COLOR = 0x00000004;
+}
+
+// Return values for GetDeviceCaps(dc, CURVECAPS)
+enum int
+    CC_NONE       = 0,
+    CC_CIRCLES    = 1,
+    CC_PIE        = 2,
+    CC_CHORD      = 4,
+    CC_ELLIPSES   = 8,
+    CC_WIDE       = 16,
+    CC_STYLED     = 32,
+    CC_WIDESTYLED = 64,
+    CC_INTERIORS  = 128,
+    CC_ROUNDRECT  = 256;
+
+// Return values for GetDeviceCaps(dc, LINECAPS)
+
+enum int
+    LC_NONE       = 0,
+    LC_POLYLINE   = 2,
+    LC_MARKER     = 4,
+    LC_POLYMARKER = 8,
+    LC_WIDE       = 16,
+    LC_STYLED     = 32,
+    LC_WIDESTYLED = 64,
+    LC_INTERIORS  = 128;
+
+// Return values for GetDeviceCaps(dc, POLYGONALCAPS)
+
+enum int
+    PC_NONE        = 0,
+    PC_POLYGON     = 1,
+    PC_RECTANGLE   = 2,
+    PC_WINDPOLYGON = 4,
+    PC_TRAPEZOID   = 4,
+    PC_SCANLINE    = 8,
+    PC_WIDE        = 16,
+    PC_STYLED      = 32,
+    PC_WIDESTYLED  = 64,
+    PC_INTERIORS   = 128,
+    PC_POLYPOLYGON = 256,
+    PC_PATHS       = 512;
+
+/* Clipping Capabilities */
+enum int CP_NONE = 0,
+    CP_RECTANGLE = 1,
+    CP_REGION = 2;
+
+// Return values for GetDeviceCaps(dc, TEXTCAPS)
+
+enum int
+    TC_OP_CHARACTER = 1,
+    TC_OP_STROKE    = 2,
+    TC_CP_STROKE    = 4,
+    TC_CR_90        = 8,
+    TC_CR_ANY       = 16,
+    TC_SF_X_YINDEP  = 32,
+    TC_SA_DOUBLE    = 64,
+    TC_SA_INTEGER   = 128,
+    TC_SA_CONTIN    = 256,
+    TC_EA_DOUBLE    = 512,
+    TC_IA_ABLE      = 1024,
+    TC_UA_ABLE      = 2048,
+    TC_SO_ABLE      = 4096,
+    TC_RA_ABLE      = 8192,
+    TC_VA_ABLE      = 16384,
+    TC_RESERVED     = 32768,
+    TC_SCROLLBLT    = 65536;
+
+// End GetDeviceCaps
+//---------------------
+// GetCharacterPlacement(), and GetFontLanguageInfo()
+enum DWORD
+    GCP_DBCS            = 1,
+    GCP_REORDER         = 2,
+    GCP_USEKERNING      = 8,
+    GCP_GLYPHSHAPE      = 16,
+    GCP_LIGATE          = 32,
+    GCP_DIACRITIC       = 256,
+    GCP_KASHIDA         = 1024,
+    GCP_ERROR           = 0x8000,
+    GCP_JUSTIFY         = 0x10000,
+    GCP_CLASSIN         = 0x80000,
+    GCP_MAXEXTENT       = 0x100000,
+    GCP_JUSTIFYIN       = 0x200000,
+    GCP_DISPLAYZWG      = 0x400000,
+    GCP_SYMSWAPOFF      = 0x800000,
+    GCP_NUMERICOVERRIDE = 0x1000000,
+    GCP_NEUTRALOVERRIDE = 0x2000000,
+    GCP_NUMERICSLATIN   = 0x4000000,
+    GCP_NUMERICSLOCAL   = 0x8000000,
+    // Only for GetFontLanguageInfo()
+    FLI_GLYPHS          = 0x40000,
+    FLI_MASK            = 0x103b;
+
+// GetGlyphOutline()
+enum : UINT {
+    GGO_METRICS      = 0,
+    GGO_BITMAP       = 1,
+    GGO_NATIVE       = 2,
+    GGO_BEZIER       = 3,
+    GGO_GRAY2_BITMAP = 4,
+    GGO_GRAY4_BITMAP = 5,
+    GGO_GRAY8_BITMAP = 6,
+    GGO_GLYPH_INDEX  = 128,
+    GGO_UNHINTED     = 256
+}
+
+enum : int {
+    GM_COMPATIBLE = 1,
+    GM_ADVANCED
+}
+enum GM_LAST = GM_ADVANCED;
+
+enum : int {
+    MM_TEXT = 1,
+    MM_LOMETRIC,
+    MM_HIMETRIC,
+    MM_LOENGLISH,
+    MM_HIENGLISH,
+    MM_TWIPS,
+    MM_ISOTROPIC,
+    MM_ANISOTROPIC,
+}
+
+enum int
+    MM_MIN = MM_TEXT,
+    MM_MAX = MM_ANISOTROPIC,
+    MM_MAX_FIXEDSCALE = MM_TWIPS;
+
+enum ABSOLUTE = 1;
+enum RELATIVE = 2;
+
+enum : BYTE {
+    PC_RESERVED   = 1,
+    PC_EXPLICIT   = 2,
+    PC_NOCOLLAPSE = 4
+}
+
+/* FIXME: move to core.sys.windows.commctrl ? */
+// ImageList
+enum COLORREF
+    CLR_NONE    = 0xffffffff,
+    CLR_INVALID = CLR_NONE,
+    CLR_DEFAULT = 0xff000000;
+
+// RASTERIZER_STATUS.wFlags
+enum short
+    TT_AVAILABLE = 1,
+    TT_ENABLED   = 2;
+
+// GetStockObject()
+enum : int {
+    WHITE_BRUSH = 0,
+    LTGRAY_BRUSH,
+    GRAY_BRUSH,
+    DKGRAY_BRUSH,
+    BLACK_BRUSH,
+    HOLLOW_BRUSH, // = 5
+    NULL_BRUSH = HOLLOW_BRUSH,
+    WHITE_PEN = 6,
+    BLACK_PEN,
+    NULL_PEN, // = 8
+    OEM_FIXED_FONT = 10,
+    ANSI_FIXED_FONT,
+    ANSI_VAR_FONT,
+    SYSTEM_FONT,
+    DEVICE_DEFAULT_FONT,
+    DEFAULT_PALETTE,
+    SYSTEM_FIXED_FONT,
+    DEFAULT_GUI_FONT = SYSTEM_FIXED_FONT + 1,
+}
+static if (_WIN32_WINNT >= 0x500) {
+    enum : int {
+        DC_BRUSH = DEFAULT_GUI_FONT + 1,
+        DC_PEN,
+    }
+}
+
+static if (_WIN32_WINNT >= 0x500) {
+enum STOCK_LAST = DC_PEN;
+} else {
+enum STOCK_LAST = DEFAULT_GUI_FONT;
+}
+
+// Get/SetSystemPaletteUse()
+enum : UINT {
+    SYSPAL_ERROR    = 0,
+    SYSPAL_STATIC   = 1,
+    SYSPAL_NOSTATIC = 2,
+    SYSPAL_NOSTATIC256 = 3,
+}
+
+// SetTextAlign()
+enum UINT
+    TA_TOP        = 0,
+    TA_CENTER     = 6,
+    TA_BOTTOM     = 8,
+    TA_BASELINE   = 24,
+    TA_LEFT       = 0,
+    TA_RIGHT      = 2,
+    TA_RTLREADING = 256,
+    TA_NOUPDATECP = 0,
+    TA_UPDATECP   = 1,
+    TA_MASK       = TA_BASELINE+TA_CENTER+TA_UPDATECP+TA_RTLREADING,
+    VTA_BASELINE  = TA_BASELINE,
+    VTA_CENTER    = TA_CENTER,
+    VTA_LEFT      = TA_BOTTOM,
+    VTA_RIGHT     = TA_TOP,
+    VTA_BOTTOM    = TA_RIGHT,
+    VTA_TOP       = TA_LEFT;
+
+// EMRMODIFYWORLDTRANSFORM.iMode
+enum : DWORD {
+    MWT_IDENTITY = 1,
+    MWT_LEFTMULTIPLY,
+    MWT_RIGHTMULTIPLY
+}
+
+enum DWORD
+    MWT_MIN = MWT_IDENTITY,
+    MWT_MAX = MWT_RIGHTMULTIPLY;
+
+enum {
+    TRANSPARENT = 1,
+    OPAQUE      = 2
+}
+
+// Get/SetStretchMode()
+enum : int {
+    BLACKONWHITE = 1,
+    WHITEONBLACK = 2,
+    COLORONCOLOR = 3,
+    HALFTONE     = 4,
+
+    STRETCH_ANDSCANS    = 1,
+    STRETCH_ORSCANS     = 2,
+    STRETCH_DELETESCANS = 3,
+    STRETCH_HALFTONE    = 4,
+
+    MAXSTRETCHBLTMODE   = 4
+}
+
+// TranslateCharsetInfo()
+enum : DWORD {
+    TCI_SRCCHARSET  = 1,
+    TCI_SRCCODEPAGE = 2,
+    TCI_SRCFONTSIG  = 3,
+    TCI_SRCLOCALE   = 0x1000,
+}
+
+// SetICMMode()
+enum : int {
+    ICM_OFF   = 1,
+    ICM_ON    = 2,
+    ICM_QUERY = 3,
+    ICM_DONE_OUTSIDEDC = 4,
+}
+
+// ----
+// Escape() Spooler Error Codes
+enum : int {
+    SP_NOTREPORTED = 0x4000,
+    SP_ERROR       = -1,
+    SP_APPABORT    = -2,
+    SP_USERABORT   = -3,
+    SP_OUTOFDISK   = -4,
+    SP_OUTOFMEMORY = -5
+}
+
+// Escape(), ExtEscape()
+// Most of the following are deprecated (Win16 only)
+enum : int {
+    NEWFRAME      = 1,
+    ABORTDOC      = 2,
+    NEXTBAND      = 3,
+    SETCOLORTABLE = 4,
+    GETCOLORTABLE = 5,
+    FLUSHOUTPUT   = 6,
+    DRAFTMODE     = 7,
+    QUERYESCSUPPORT = 8,
+    SETABORTPROC  = 9,
+    STARTDOC      = 10,
+    ENDDOC        = 11,
+    GETPHYSPAGESIZE   = 12,
+    GETPRINTINGOFFSET = 13,
+    GETSCALINGFACTOR  = 14,
+    MFCOMMENT         = 15,
+    GETPENWIDTH       = 16,
+    SETCOPYCOUNT      = 17,
+    SELECTPAPERSOURCE = 18,
+    DEVICEDATA        = 19,
+    PASSTHROUGH       = 19,
+    GETTECHNOLOGY     = 20,
+    SETLINECAP = 21,
+    SETLINEJOIN = 22,
+    SETMITERLIMIT = 23,
+    BANDINFO = 24,
+    DRAWPATTERNRECT = 25,
+    GETVECTORPENSIZE = 26,
+    GETVECTORBRUSHSIZE = 27,
+    ENABLEDUPLEX = 28,
+    GETSETPAPERBINS = 29,
+    GETSETPRINTORIENT = 30,
+    ENUMPAPERBINS = 31,
+    SETDIBSCALING = 32,
+    EPSPRINTING = 33,
+    ENUMPAPERMETRICS = 34,
+    GETSETPAPERMETRICS = 35,
+    POSTSCRIPT_DATA = 37,
+    POSTSCRIPT_IGNORE = 38,
+    MOUSETRAILS = 39,
+    GETDEVICEUNITS = 42,
+    GETEXTENDEDTEXTMETRICS = 256,
+    GETEXTENTTABLE = 257,
+    GETPAIRKERNTABLE = 258,
+    GETTRACKKERNTABLE = 259,
+    EXTTEXTOUT = 512,
+    GETFACENAME = 513,
+    DOWNLOADFACE = 514,
+    ENABLERELATIVEWIDTHS = 768,
+    ENABLEPAIRKERNING = 769,
+    SETKERNTRACK = 770,
+    SETALLJUSTVALUES = 771,
+    SETCHARSET = 772,
+    STRETCHBLT = 2048,
+    METAFILE_DRIVER = 2049,
+    GETSETSCREENPARAMS = 3072,
+    QUERYDIBSUPPORT = 3073,
+    BEGIN_PATH = 4096,
+    CLIP_TO_PATH = 4097,
+    END_PATH = 4098,
+    EXT_DEVICE_CAPS = 4099,
+    RESTORE_CTM = 4100,
+    SAVE_CTM = 4101,
+    SET_ARC_DIRECTION = 4102,
+    SET_BACKGROUND_COLOR = 4103,
+    SET_POLY_MODE = 4104,
+    SET_SCREEN_ANGLE = 4105,
+    SET_SPREAD = 4106,
+    TRANSFORM_CTM = 4107,
+    SET_CLIP_BOX = 4108,
+    SET_BOUNDS = 4109,
+    SET_MIRROR_MODE = 4110,
+    OPENCHANNEL = 4110,
+    DOWNLOADHEADER = 4111,
+    CLOSECHANNEL = 4112,
+    POSTSCRIPT_PASSTHROUGH  = 4115,
+    ENCAPSULATED_POSTSCRIPT = 4116,
+    POSTSCRIPT_IDENTIFY = 4117,
+    POSTSCRIPT_INJECTION = 4118,
+    CHECKJPEGFORMAT = 4119,
+    CHECKPNGFORMAT = 4120,
+    GET_PS_FEATURESETTING = 4121,
+    SPCLPASSTHROUGH2 = 4568,
+}
+
+enum : int {
+    PSIDENT_GDICENTRIC = 0,
+    PSIDENT_PSCENTRIC = 1,
+}
+
+/*
+ * Header structure for the input buffer to POSTSCRIPT_INJECTION escape
+ */
+struct PSINJECTDATA {
+    DWORD DataBytes;
+    WORD  InjectionPoint;
+    WORD  PageNumber;
+}
+alias PSINJECTDATA* PPSINJECTDATA;
+
+/* Constants for PSINJECTDATA.InjectionPoint field */
+enum {
+    PSINJECT_BEGINSTREAM = 1,
+    PSINJECT_PSADOBE = 2,
+    PSINJECT_PAGESATEND = 3,
+    PSINJECT_PAGES = 4,
+    PSINJECT_DOCNEEDEDRES = 5,
+    PSINJECT_DOCSUPPLIEDRES = 6,
+    PSINJECT_PAGEORDER = 7,
+    PSINJECT_ORIENTATION = 8,
+    PSINJECT_BOUNDINGBOX = 9,
+    PSINJECT_DOCUMENTPROCESSCOLORS = 10,
+    PSINJECT_COMMENTS = 11,
+    PSINJECT_BEGINDEFAULTS = 12,
+    PSINJECT_ENDDEFAULTS = 13,
+    PSINJECT_BEGINPROLOG = 14,
+    PSINJECT_ENDPROLOG = 15,
+    PSINJECT_BEGINSETUP = 16,
+    PSINJECT_ENDSETUP = 17,
+    PSINJECT_TRAILER = 18,
+    PSINJECT_EOF = 19,
+    PSINJECT_ENDSTREAM = 20,
+    PSINJECT_DOCUMENTPROCESSCOLORSATEND = 21,
+
+    PSINJECT_PAGENUMBER = 100,
+    PSINJECT_BEGINPAGESETUP = 101,
+    PSINJECT_ENDPAGESETUP = 102,
+    PSINJECT_PAGETRAILER = 103,
+    PSINJECT_PLATECOLOR = 104,
+    PSINJECT_SHOWPAGE = 105,
+    PSINJECT_PAGEBBOX = 106,
+    PSINJECT_ENDPAGECOMMENTS = 107,
+
+    PSINJECT_VMSAVE = 200,
+    PSINJECT_VMRESTORE = 201,
+}
+
+/* Parameter for GET_PS_FEATURESETTING escape */
+enum {
+    FEATURESETTING_NUP = 0,
+    FEATURESETTING_OUTPUT = 1,
+    FEATURESETTING_PSLEVEL = 2,
+    FEATURESETTING_CUSTPAPER = 3,
+    FEATURESETTING_MIRROR = 4,
+    FEATURESETTING_NEGATIVE = 5,
+    FEATURESETTING_PROTOCOL = 6,
+}
+
+enum {
+    FEATURESETTING_PRIVATE_BEGIN = 0x1000,
+    FEATURESETTING_PRIVATE_END = 0x1FFF,
+}
+
+/* Value returned for FEATURESETTING_PROTOCOL */
+enum PSPROTOCOL_ASCII = 0;
+enum PSPROTOCOL_BCP = 1;
+enum PSPROTOCOL_TBCP = 2;
+enum PSPROTOCOL_BINARY = 3;
+
+// ----
+
+enum WPARAM PR_JOBSTATUS = 0;
+
+// ???
+enum QDI_SETDIBITS   = 1;
+enum QDI_GETDIBITS   = 2;
+enum QDI_DIBTOSCREEN = 4;
+enum QDI_STRETCHDIB  = 8;
+
+enum ASPECT_FILTERING = 1;
+
+// LOGCOLORSPACE.lcsCSType
+enum : LCSCSTYPE {
+    LCS_CALIBRATED_RGB = 0,
+    LCS_DEVICE_RGB,
+    LCS_DEVICE_CMYK
+} /* What this for? */
+
+// LOGCOLORSPACE.lcsIntent
+enum : LCSGAMUTMATCH {
+    LCS_GM_BUSINESS         = 1,
+    LCS_GM_GRAPHICS         = 2,
+    LCS_GM_IMAGES           = 4,
+    LCS_GM_ABS_COLORIMETRIC = 8,
+}
+
+enum DWORD
+    RASTER_FONTTYPE   = 1,
+    DEVICE_FONTTYPE   = 2,
+    TRUETYPE_FONTTYPE = 4;
+
+// ---
+// DEVMODE struct
+
+// FIXME: Not needed for D (use .length instead)
+enum CCHDEVICENAME = 32;
+enum CCHFORMNAME   = 32;
+
+// DEVMODE.dmSpecVersion
+// current version of specification
+enum WORD DM_SPECVERSION = 0x0401;
+
+// DEVMODE.dmOrientation
+enum : short {
+    DMORIENT_PORTRAIT  = 1,
+    DMORIENT_LANDSCAPE = 2
+}
+
+// DEVMODE.dmPaperSize
+enum : short {
+    DMPAPER_LETTER = 1,
+    DMPAPER_LETTERSMALL,
+    DMPAPER_TABLOID,
+    DMPAPER_LEDGER,
+    DMPAPER_LEGAL,
+    DMPAPER_STATEMENT,
+    DMPAPER_EXECUTIVE,
+    DMPAPER_A3,
+    DMPAPER_A4,
+    DMPAPER_A4SMALL,
+    DMPAPER_A5,
+    DMPAPER_B4,
+    DMPAPER_B5,
+    DMPAPER_FOLIO,
+    DMPAPER_QUARTO,
+    DMPAPER_10X14,
+    DMPAPER_11X17,
+    DMPAPER_NOTE,
+    DMPAPER_ENV_9,
+    DMPAPER_ENV_10,
+    DMPAPER_ENV_11,
+    DMPAPER_ENV_12,
+    DMPAPER_ENV_14,
+    DMPAPER_CSHEET,
+    DMPAPER_DSHEET,
+    DMPAPER_ESHEET,
+    DMPAPER_ENV_DL,
+    DMPAPER_ENV_C5,
+    DMPAPER_ENV_C3,
+    DMPAPER_ENV_C4,
+    DMPAPER_ENV_C6,
+    DMPAPER_ENV_C65,
+    DMPAPER_ENV_B4,
+    DMPAPER_ENV_B5,
+    DMPAPER_ENV_B6,
+    DMPAPER_ENV_ITALY,
+    DMPAPER_ENV_MONARCH,
+    DMPAPER_ENV_PERSONAL,
+    DMPAPER_FANFOLD_US,
+    DMPAPER_FANFOLD_STD_GERMAN,
+    DMPAPER_FANFOLD_LGL_GERMAN,
+    DMPAPER_ISO_B4,
+    DMPAPER_JAPANESE_POSTCARD,
+    DMPAPER_9X11,
+    DMPAPER_10X11,
+    DMPAPER_15X11,
+    DMPAPER_ENV_INVITE,
+    DMPAPER_RESERVED_48,
+    DMPAPER_RESERVED_49,
+    DMPAPER_LETTER_EXTRA,
+    DMPAPER_LEGAL_EXTRA,
+    DMPAPER_TABLOID_EXTRA,
+    DMPAPER_A4_EXTRA,
+    DMPAPER_LETTER_TRANSVERSE,
+    DMPAPER_A4_TRANSVERSE,
+    DMPAPER_LETTER_EXTRA_TRANSVERSE,
+    DMPAPER_A_PLUS,
+    DMPAPER_B_PLUS,
+    DMPAPER_LETTER_PLUS,
+    DMPAPER_A4_PLUS,
+    DMPAPER_A5_TRANSVERSE,
+    DMPAPER_B5_TRANSVERSE,
+    DMPAPER_A3_EXTRA,
+    DMPAPER_A5_EXTRA,
+    DMPAPER_B5_EXTRA,
+    DMPAPER_A2,
+    DMPAPER_A3_TRANSVERSE,
+    DMPAPER_A3_EXTRA_TRANSVERSE // = 68
+}
+static if (_WIN32_WINNT >= 0x500) {
+    enum : short {
+        DMPAPER_DBL_JAPANESE_POSTCARD = 69,
+        DMPAPER_A6,
+        DMPAPER_JENV_KAKU2,
+        DMPAPER_JENV_KAKU3,
+        DMPAPER_JENV_CHOU3,
+        DMPAPER_JENV_CHOU4,
+        DMPAPER_LETTER_ROTATED,
+        DMPAPER_A3_ROTATED,
+        DMPAPER_A4_ROTATED,
+        DMPAPER_A5_ROTATED,
+        DMPAPER_B4_JIS_ROTATED,
+        DMPAPER_B5_JIS_ROTATED,
+        DMPAPER_JAPANESE_POSTCARD_ROTATED,
+        DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED,
+        DMPAPER_A6_ROTATED,
+        DMPAPER_JENV_KAKU2_ROTATED,
+        DMPAPER_JENV_KAKU3_ROTATED,
+        DMPAPER_JENV_CHOU3_ROTATED,
+        DMPAPER_JENV_CHOU4_ROTATED,
+        DMPAPER_B6_JIS,
+        DMPAPER_B6_JIS_ROTATED,
+        DMPAPER_12X11,
+        DMPAPER_JENV_YOU4,
+        DMPAPER_JENV_YOU4_ROTATED,
+        DMPAPER_P16K,
+        DMPAPER_P32K,
+        DMPAPER_P32KBIG,
+        DMPAPER_PENV_1,
+        DMPAPER_PENV_2,
+        DMPAPER_PENV_3,
+        DMPAPER_PENV_4,
+        DMPAPER_PENV_5,
+        DMPAPER_PENV_6,
+        DMPAPER_PENV_7,
+        DMPAPER_PENV_8,
+        DMPAPER_PENV_9,
+        DMPAPER_PENV_10,
+        DMPAPER_P16K_ROTATED,
+        DMPAPER_P32K_ROTATED,
+        DMPAPER_P32KBIG_ROTATED,
+        DMPAPER_PENV_1_ROTATED,
+        DMPAPER_PENV_2_ROTATED,
+        DMPAPER_PENV_3_ROTATED,
+        DMPAPER_PENV_4_ROTATED,
+        DMPAPER_PENV_5_ROTATED,
+        DMPAPER_PENV_6_ROTATED,
+        DMPAPER_PENV_7_ROTATED,
+        DMPAPER_PENV_8_ROTATED,
+        DMPAPER_PENV_9_ROTATED,
+        DMPAPER_PENV_10_ROTATED // 118
+    }
+}
+
+enum short DMPAPER_FIRST = DMPAPER_LETTER;
+
+static if (_WIN32_WINNT >= 0x500) {
+enum short DMPAPER_LAST = DMPAPER_PENV_10_ROTATED;
+} else {
+enum short DMPAPER_LAST = DMPAPER_A3_EXTRA_TRANSVERSE;
+}
+
+enum short DMPAPER_USER = 256;
+
+
+// DEVMODE.dmDefaultSource
+enum : short {
+    DMBIN_ONLYONE = 1,
+    DMBIN_UPPER   = 1,
+    DMBIN_LOWER,
+    DMBIN_MIDDLE,
+    DMBIN_MANUAL,
+    DMBIN_ENVELOPE,
+    DMBIN_ENVMANUAL,
+    DMBIN_AUTO,
+    DMBIN_TRACTOR,
+    DMBIN_SMALLFMT,
+    DMBIN_LARGEFMT,
+    DMBIN_LARGECAPACITY, // = 11
+    DMBIN_CASSETTE   = 14,
+    DMBIN_FORMSOURCE,
+}
+enum : short {
+    DMBIN_FIRST = DMBIN_UPPER,
+    DMBIN_LAST = DMBIN_FORMSOURCE,
+    DMBIN_USER = 256,
+}
+
+// DEVMODE.dmPrintQuality
+enum : short {
+    DMRES_DRAFT  = -1,
+    DMRES_LOW    = -2,
+    DMRES_MEDIUM = -3,
+    DMRES_HIGH   = -4
+}
+
+// DEVMODE.dmColor
+enum : short {
+    DMCOLOR_MONOCHROME = 1,
+    DMCOLOR_COLOR      = 2
+}
+
+// DEVMODE.dmDuplex
+enum : short {
+    DMDUP_SIMPLEX    = 1,
+    DMDUP_VERTICAL   = 2,
+    DMDUP_HORIZONTAL = 3
+}
+
+// DEVMODE.dmTTOption
+enum : short {
+    DMTT_BITMAP = 1,
+    DMTT_DOWNLOAD,
+    DMTT_SUBDEV,
+    DMTT_DOWNLOAD_OUTLINE
+}
+
+// DEVMODE.dmCollate
+enum : short {
+    DMCOLLATE_FALSE = 0,
+    DMCOLLATE_TRUE
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    /* DEVMODE dmDisplayOrientation specifiations */
+    enum : short {
+        DMDO_DEFAULT = 0,
+        DMDO_90 = 1,
+        DMDO_180 = 2,
+        DMDO_270 = 3,
+    }
+
+    /* DEVMODE dmDisplayFixedOutput specifiations */
+    enum : short {
+        DMDFO_DEFAULT = 0,
+        DMDFO_STRETCH = 1,
+        DMDFO_CENTER = 2,
+    }
+}
+
+
+/* FIXME: this flags are deprecated ? */
+// DEVMODE.dmDisplayFlags
+enum DWORD
+    DM_GRAYSCALE  = 1,
+    DM_INTERLACED = 2;
+
+enum DWORD
+    DMDISPLAYFLAGS_TEXTMODE = 0x00000004;
+
+/* dmNup , multiple logical page per physical page options */
+enum DWORD
+    DMNUP_SYSTEM = 1,
+    DMNUP_ONEUP = 2;
+
+// DEVMODE.dmFields
+enum DWORD
+    DM_ORIENTATION        = 0x00000001,
+    DM_PAPERSIZE          = 0x00000002,
+    DM_PAPERLENGTH        = 0x00000004,
+    DM_PAPERWIDTH         = 0x00000008,
+    DM_SCALE              = 0x00000010;
+static if (_WIN32_WINNT >= 0x500) {
+enum DWORD
+        DM_POSITION       = 0x00000020,
+        DM_NUP            = 0x00000040;
+}
+static if (_WIN32_WINNT >= 0x501) {
+enum DWORD
+        DM_DISPLAYORIENTATION = 0x00000080;
+}
+enum DWORD
+    DM_COPIES             = 0x00000100,
+    DM_DEFAULTSOURCE      = 0x00000200,
+    DM_PRINTQUALITY       = 0x00000400,
+    DM_COLOR              = 0x00000800,
+    DM_DUPLEX             = 0x00001000,
+    DM_YRESOLUTION        = 0x00002000,
+    DM_TTOPTION           = 0x00004000,
+    DM_COLLATE            = 0x00008000,
+    DM_FORMNAME           = 0x00010000,
+    DM_LOGPIXELS          = 0x00020000,
+    DM_BITSPERPEL         = 0x00040000,
+    DM_PELSWIDTH          = 0x00080000,
+    DM_PELSHEIGHT         = 0x00100000,
+    DM_DISPLAYFLAGS       = 0x00200000,
+    DM_DISPLAYFREQUENCY   = 0x00400000,
+    DM_ICMMETHOD          = 0x00800000,
+    DM_ICMINTENT          = 0x01000000,
+    DM_MEDIATYPE          = 0x02000000,
+    DM_DITHERTYPE         = 0x04000000,
+    DM_PANNINGWIDTH       = 0x08000000,
+    DM_PANNINGHEIGHT      = 0x10000000;
+static if (_WIN32_WINNT >= 0x501) {
+enum DWORD
+        DM_DISPLAYFIXEDOUTPUT = 0x20000000;
+}
+
+// DEVMODE.dmICMMethod
+enum : DWORD {
+    DMICMMETHOD_NONE   = 1,
+    DMICMMETHOD_SYSTEM = 2,
+    DMICMMETHOD_DRIVER = 3,
+    DMICMMETHOD_DEVICE = 4,
+    DMICMMETHOD_USER   = 256
+}
+
+// DEVMODE.dmICMIntent
+enum : DWORD {
+    DMICM_SATURATE    = 1,
+    DMICM_CONTRAST    = 2,
+    DMICM_COLORIMETRIC = 3,
+    DMICM_ABS_COLORIMETRIC = 4,
+    DMICM_USER        = 256
+}
+
+// DEVMODE.dmMediaType
+enum : DWORD {
+    DMMEDIA_STANDARD     = 1,
+    DMMEDIA_TRANSPARENCY = 2,
+    DMMEDIA_GLOSSY       = 3,
+    DMMEDIA_USER         = 256
+}
+
+// DEVMODE.dmDitherType
+enum : DWORD {
+    DMDITHER_NONE = 1,
+    DMDITHER_COARSE,
+    DMDITHER_FINE,
+    DMDITHER_LINEART,
+    DMDITHER_ERRORDIFFUSION,
+    DMDITHER_RESERVED6,
+    DMDITHER_RESERVED7,
+    DMDITHER_RESERVED8,
+    DMDITHER_RESERVED9,
+    DMDITHER_GRAYSCALE,
+    DMDITHER_USER = 256
+}
+
+// ----
+// DocumentProperties()
+enum DWORD
+    DM_UPDATE      = 1,
+    DM_COPY        = 2,
+    DM_PROMPT      = 4,
+    DM_MODIFY      = 8,
+    DM_IN_BUFFER   = DM_MODIFY,
+    DM_IN_PROMPT   = DM_PROMPT,
+    DM_OUT_BUFFER  = DM_COPY,
+    DM_OUT_DEFAULT = DM_UPDATE;
+// ---
+
+enum GDI_ERROR = 0xFFFFFFFF;
+enum HGDI_ERROR= cast(HANDLE)GDI_ERROR;
+
+// TEXTMETRIC.tmPitchAndFamily
+enum BYTE
+    TMPF_FIXED_PITCH = 1,
+    TMPF_VECTOR      = 2,
+    TMPF_TRUETYPE    = 4,
+    TMPF_DEVICE      = 8;
+
+// NEWTEXTMETRIC.ntmFlags
+enum DWORD
+    NTM_ITALIC         = 0x00000001,
+    NTM_BOLD           = 0x00000020,
+    NTM_REGULAR        = 0x00000040,
+    NTM_NONNEGATIVE_AC = 0x00010000,
+    NTM_PS_OPENTYPE    = 0x00020000,
+    NTM_TT_OPENTYPE    = 0x00040000,
+    NTM_MULTIPLEMASTER = 0x00080000,
+    NTM_TYPE1          = 0x00100000,
+    NTM_DSIG           = 0x00200000;
+
+// ---
+enum DWORD TT_POLYGON_TYPE = 24;
+
+// TTPOLYCURVE
+enum : WORD {
+    TT_PRIM_LINE    = 1,
+    TT_PRIM_QSPLINE = 2,
+    TT_PRIM_CSPLINE = 3,
+}
+// ---
+enum FONTMAPPER_MAX = 10;
+enum ENHMETA_STOCK_OBJECT = 0x80000000;
+enum WGL_FONT_LINES = 0;
+enum WGL_FONT_POLYGONS = 1;
+
+// ---
+// LAYERPLANEDESCRIPTOR.dwFlags
+enum DWORD
+    LPD_DOUBLEBUFFER   = 1,
+    LPD_STEREO         = 2,
+    LPD_SUPPORT_GDI    = 16,
+    LPD_SUPPORT_OPENGL = 32,
+    LPD_SHARE_DEPTH    = 64,
+    LPD_SHARE_STENCIL  = 128,
+    LPD_SHARE_ACCUM    = 256,
+    LPD_SWAP_EXCHANGE  = 512,
+    LPD_SWAP_COPY      = 1024,
+    LPD_TRANSPARENT    = 4096;
+
+// LAYERPLANEDESCRIPTOR.iPixelType
+enum : BYTE {
+    LPD_TYPE_RGBA       = 0,
+    LPD_TYPE_COLORINDEX = 1
+}
+
+// ---
+
+// wglSwapLayerBuffers()
+enum UINT
+    WGL_SWAP_MAIN_PLANE = 1,
+    WGL_SWAP_OVERLAY1   = 2,
+    WGL_SWAP_OVERLAY2   = 4,
+    WGL_SWAP_OVERLAY3   = 8,
+    WGL_SWAP_OVERLAY4   = 16,
+    WGL_SWAP_OVERLAY5   = 32,
+    WGL_SWAP_OVERLAY6   = 64,
+    WGL_SWAP_OVERLAY7   = 128,
+    WGL_SWAP_OVERLAY8   = 256,
+    WGL_SWAP_OVERLAY9   = 512,
+    WGL_SWAP_OVERLAY10  = 1024,
+    WGL_SWAP_OVERLAY11  = 2048,
+    WGL_SWAP_OVERLAY12  = 4096,
+    WGL_SWAP_OVERLAY13  = 8192,
+    WGL_SWAP_OVERLAY14  = 16384,
+    WGL_SWAP_OVERLAY15  = 32768,
+    WGL_SWAP_UNDERLAY1  = 65536,
+    WGL_SWAP_UNDERLAY2  = 0x20000,
+    WGL_SWAP_UNDERLAY3  = 0x40000,
+    WGL_SWAP_UNDERLAY4  = 0x80000,
+    WGL_SWAP_UNDERLAY5  = 0x100000,
+    WGL_SWAP_UNDERLAY6  = 0x200000,
+    WGL_SWAP_UNDERLAY7  = 0x400000,
+    WGL_SWAP_UNDERLAY8  = 0x800000,
+    WGL_SWAP_UNDERLAY9  = 0x1000000,
+    WGL_SWAP_UNDERLAY10 = 0x2000000,
+    WGL_SWAP_UNDERLAY11 = 0x4000000,
+    WGL_SWAP_UNDERLAY12 = 0x8000000,
+    WGL_SWAP_UNDERLAY13 = 0x10000000,
+    WGL_SWAP_UNDERLAY14 = 0x20000000,
+    WGL_SWAP_UNDERLAY15 = 0x40000000;
+
+enum AC_SRC_OVER  = 0x00;
+enum AC_SRC_ALPHA = 0x01;
+
+// ???
+enum AC_SRC_NO_PREMULT_ALPHA = 0x01;
+enum AC_SRC_NO_ALPHA         = 0x02;
+enum AC_DST_NO_PREMULT_ALPHA = 0x10;
+enum AC_DST_NO_ALPHA         = 0x20;
+
+enum LAYOUT_RTL = 1;
+enum LAYOUT_BTT = 2;
+enum LAYOUT_VBH = 4;
+enum LAYOUT_BITMAPORIENTATIONPRESERVED = 8;
+
+enum CS_ENABLE = 0x00000001;
+enum CS_DISABLE = 0x00000002;
+enum CS_DELETE_TRANSFORM = 0x00000003;
+
+static if (_WIN32_WINNT > 0x500) {
+enum GRADIENT_FILL_RECT_H=0x00;
+enum GRADIENT_FILL_RECT_V=0x01;
+enum GRADIENT_FILL_TRIANGLE=0x02;
+enum GRADIENT_FILL_OP_FLAG=0xff;
+enum COLORMATCHTOTARGET_EMBEDED=0x00000001;
+enum CREATECOLORSPACE_EMBEDED=0x00000001;
+enum SETICMPROFILE_EMBEDED=0x00000001;
+}
+
+// DISPLAY_DEVICE.StateFlags
+enum DWORD
+    DISPLAY_DEVICE_ATTACHED_TO_DESKTOP = 0x00000001,
+    DISPLAY_DEVICE_MULTI_DRIVER        = 0x00000002,
+    DISPLAY_DEVICE_PRIMARY_DEVICE      = 0x00000004,
+    DISPLAY_DEVICE_MIRRORING_DRIVER    = 0x00000008,
+    DISPLAY_DEVICE_VGA_COMPATIBLE      = 0x00000010,
+    DISPLAY_DEVICE_REMOVABLE           = 0x00000020,
+    DISPLAY_DEVICE_DISCONNECT          = 0x02000000,
+    DISPLAY_DEVICE_REMOTE              = 0x04000000,
+    DISPLAY_DEVICE_MODESPRUNED         = 0x08000000;
+
+/* Child device state */
+enum DWORD
+    DISPLAY_DEVICE_ACTIVE = 0x00000001,
+    DISPLAY_DEVICE_ATTACHED = 0x00000002;
+
+static if (_WIN32_WINNT >= 0x500) {
+enum GGI_MARK_NONEXISTING_GLYPHS = 1;
+}
+
+// ----------
+//   STRUCTS
+// ----------
+
+struct ABC {
+    int  abcA;
+    UINT abcB;
+    int  abcC;
+}
+alias ABC* PABC, NPABC, LPABC;
+
+struct ABCFLOAT {
+    FLOAT abcfA;
+    FLOAT abcfB;
+    FLOAT abcfC;
+}
+alias ABCFLOAT* PABCFLOAT, NPABCFLOAT, LPABCFLOAT;
+
+struct BITMAP {
+    LONG   bmType;
+    LONG   bmWidth;
+    LONG   bmHeight;
+    LONG   bmWidthBytes;
+    WORD   bmPlanes;
+    WORD   bmBitsPixel;
+    LPVOID bmBits;
+}
+alias BITMAP* PBITMAP, NPBITMAP, LPBITMAP;
+
+struct BITMAPCOREHEADER {
+    DWORD bcSize;
+    WORD  bcWidth;
+    WORD  bcHeight;
+    WORD  bcPlanes;
+    WORD  bcBitCount;
+}
+alias BITMAPCOREHEADER* PBITMAPCOREHEADER, LPBITMAPCOREHEADER;
+
+align(1):
+struct RGBTRIPLE {
+    BYTE rgbtBlue;
+    BYTE rgbtGreen;
+    BYTE rgbtRed;
+}
+alias RGBTRIPLE* LPRGBTRIPLE;
+
+align(2):
+struct BITMAPFILEHEADER {
+align(2):
+    WORD  bfType;
+    DWORD bfSize;
+    WORD  bfReserved1;
+    WORD  bfReserved2;
+    DWORD bfOffBits;
+}
+alias BITMAPFILEHEADER* LPBITMAPFILEHEADER, PBITMAPFILEHEADER;
+
+align:
+
+struct BITMAPCOREINFO {
+    BITMAPCOREHEADER bmciHeader;
+    RGBTRIPLE[1]     bmciColors;
+}
+alias BITMAPCOREINFO* LPBITMAPCOREINFO, PBITMAPCOREINFO;
+
+struct BITMAPINFOHEADER {
+    DWORD biSize;
+    LONG  biWidth;
+    LONG  biHeight;
+    WORD  biPlanes;
+    WORD  biBitCount;
+    DWORD biCompression;
+    DWORD biSizeImage;
+    LONG  biXPelsPerMeter;
+    LONG  biYPelsPerMeter;
+    DWORD biClrUsed;
+    DWORD biClrImportant;
+}
+
+alias BITMAPINFOHEADER* LPBITMAPINFOHEADER, PBITMAPINFOHEADER;
+
+struct RGBQUAD {
+    BYTE rgbBlue;
+    BYTE rgbGreen;
+    BYTE rgbRed;
+    BYTE rgbReserved;
+};
+alias RGBQUAD* LPRGBQUAD;
+
+struct BITMAPINFO {
+    BITMAPINFOHEADER bmiHeader;
+    RGBQUAD[1]       bmiColors;
+};
+alias BITMAPINFO* PBITMAPINFO, LPBITMAPINFO;
+
+alias int FXPT16DOT16;
+alias int* LPFXPT16DOT16;
+alias int FXPT2DOT30;
+alias int* LPFXPT2DOT30;
+
+struct CIEXYZ {
+    FXPT2DOT30 ciexyzX;
+    FXPT2DOT30 ciexyzY;
+    FXPT2DOT30 ciexyzZ;
+}
+alias CIEXYZ* LPCIEXYZ;
+
+struct CIEXYZTRIPLE {
+    CIEXYZ ciexyzRed;
+    CIEXYZ ciexyzGreen;
+    CIEXYZ ciexyzBlue;
+}
+alias CIEXYZTRIPLE* LPCIEXYZTRIPLE;
+
+struct BITMAPV4HEADER {
+    DWORD        bV4Size;
+    LONG         bV4Width;
+    LONG         bV4Height;
+    WORD         bV4Planes;
+    WORD         bV4BitCount;
+    DWORD        bV4V4Compression;
+    DWORD        bV4SizeImage;
+    LONG         bV4XPelsPerMeter;
+    LONG         bV4YPelsPerMeter;
+    DWORD        bV4ClrUsed;
+    DWORD        bV4ClrImportant;
+    DWORD        bV4RedMask;
+    DWORD        bV4GreenMask;
+    DWORD        bV4BlueMask;
+    DWORD        bV4AlphaMask;
+    DWORD        bV4CSType;
+    CIEXYZTRIPLE bV4Endpoints;
+    DWORD        bV4GammaRed;
+    DWORD        bV4GammaGreen;
+    DWORD        bV4GammaBlue;
+}
+alias BITMAPV4HEADER* LPBITMAPV4HEADER, PBITMAPV4HEADER;
+
+struct BITMAPV5HEADER {
+    DWORD bV5Size;
+    LONG bV5Width;
+    LONG bV5Height;
+    WORD bV5Planes;
+    WORD bV5BitCount;
+    DWORD bV5Compression;
+    DWORD bV5SizeImage;
+    LONG bV5XPelsPerMeter;
+    LONG bV5YPelsPerMeter;
+    DWORD bV5ClrUsed;
+    DWORD bV5ClrImportant;
+    DWORD bV5RedMask;
+    DWORD bV5GreenMask;
+    DWORD bV5BlueMask;
+    DWORD bV5AlphaMask;
+    DWORD bV5CSType;
+    CIEXYZTRIPLE bV5Endpoints;
+    DWORD bV5GammaRed;
+    DWORD bV5GammaGreen;
+    DWORD bV5GammaBlue;
+    DWORD bV5Intent;
+    DWORD bV5ProfileData;
+    DWORD bV5ProfileSize;
+    DWORD bV5Reserved;
+}
+alias BITMAPV5HEADER* LPBITMAPV5HEADER, PBITMAPV5HEADER;
+
+struct FONTSIGNATURE {
+    DWORD[4] fsUsb;
+    DWORD[2] fsCsb;
+}
+alias FONTSIGNATURE* PFONTSIGNATURE, LPFONTSIGNATURE;
+
+struct CHARSETINFO {
+    UINT ciCharset;
+    UINT ciACP;
+    FONTSIGNATURE fs;
+}
+alias CHARSETINFO* PCHARSETINFO, NPCHARSETINFO, LPCHARSETINFO;
+
+struct COLORADJUSTMENT {
+    WORD  caSize;
+    WORD  caFlags;
+    WORD  caIlluminantIndex;
+    WORD  caRedGamma;
+    WORD  caGreenGamma;
+    WORD  caBlueGamma;
+    WORD  caReferenceBlack;
+    WORD  caReferenceWhite;
+    SHORT caContrast;
+    SHORT caBrightness;
+    SHORT caColorfulness;
+    SHORT caRedGreenTint;
+}
+alias COLORADJUSTMENT* PCOLORADJUSTMENT, LPCOLORADJUSTMENT;
+
+struct DEVMODEA {
+    BYTE[CCHDEVICENAME] dmDeviceName;
+    WORD   dmSpecVersion;
+    WORD   dmDriverVersion;
+    WORD   dmSize;
+    WORD   dmDriverExtra;
+    DWORD  dmFields;
+    union {
+        struct {
+            short dmOrientation;
+            short dmPaperSize;
+            short dmPaperLength;
+            short dmPaperWidth;
+            short dmScale;
+            short dmCopies;
+            short dmDefaultSource;
+            short dmPrintQuality;
+        }
+        struct {
+            POINTL dmPosition;
+            DWORD  dmDisplayOrientation;
+            DWORD  dmDisplayFixedOutput;
+        }
+    }
+    short  dmColor;
+    short  dmDuplex;
+    short  dmYResolution;
+    short  dmTTOption;
+    short  dmCollate;
+    BYTE[CCHFORMNAME]   dmFormName;
+    WORD   dmLogPixels;
+    DWORD  dmBitsPerPel;
+    DWORD  dmPelsWidth;
+    DWORD  dmPelsHeight;
+    union {
+        DWORD  dmDisplayFlags;
+        DWORD  dmNup;
+    }
+    DWORD  dmDisplayFrequency;
+    DWORD  dmICMMethod;
+    DWORD  dmICMIntent;
+    DWORD  dmMediaType;
+    DWORD  dmDitherType;
+    DWORD  dmReserved1;
+    DWORD  dmReserved2;
+    DWORD  dmPanningWidth;
+    DWORD  dmPanningHeight;
+}
+alias DEVMODEA* PDEVMODEA, NPDEVMODEA, LPDEVMODEA;
+
+struct DEVMODEW {
+    WCHAR[CCHDEVICENAME]   dmDeviceName;
+    WORD   dmSpecVersion;
+    WORD   dmDriverVersion;
+    WORD   dmSize;
+    WORD   dmDriverExtra;
+    DWORD  dmFields;
+    union {
+        struct {
+            short dmOrientation;
+            short dmPaperSize;
+            short dmPaperLength;
+            short dmPaperWidth;
+            short dmScale;
+            short dmCopies;
+            short dmDefaultSource;
+            short dmPrintQuality;
+        }
+        struct {
+            POINTL dmPosition;
+            DWORD  dmDisplayOrientation;
+            DWORD  dmDisplayFixedOutput;
+        }
+    }
+
+    short  dmColor;
+    short  dmDuplex;
+    short  dmYResolution;
+    short  dmTTOption;
+    short  dmCollate;
+    WCHAR[CCHFORMNAME]  dmFormName;
+    WORD   dmLogPixels;
+    DWORD  dmBitsPerPel;
+    DWORD  dmPelsWidth;
+    DWORD  dmPelsHeight;
+    union {
+        DWORD  dmDisplayFlags;
+        DWORD  dmNup;
+    }
+    DWORD  dmDisplayFrequency;
+    DWORD  dmICMMethod;
+    DWORD  dmICMIntent;
+    DWORD  dmMediaType;
+    DWORD  dmDitherType;
+    DWORD  dmReserved1;
+    DWORD  dmReserved2;
+    DWORD  dmPanningWidth;
+    DWORD  dmPanningHeight;
+}
+alias DEVMODEW* PDEVMODEW, NPDEVMODEW, LPDEVMODEW;
+
+/*
+ * Information about output options
+ */
+struct PSFEATURE_OUTPUT {
+    BOOL bPageIndependent;
+    BOOL bSetPageDevice;
+}
+alias PSFEATURE_OUTPUT* PPSFEATURE_OUTPUT;
+
+/*
+ * Information about custom paper size
+ */
+struct PSFEATURE_CUSTPAPER {
+    LONG lOrientation;
+    LONG lWidth;
+    LONG lHeight;
+    LONG lWidthOffset;
+    LONG lHeightOffset;
+}
+alias PSFEATURE_CUSTPAPER* PPSFEATURE_CUSTPAPER;
+
+struct DIBSECTION {
+    BITMAP           dsBm;
+    BITMAPINFOHEADER dsBmih;
+    DWORD[3]         dsBitfields;
+    HANDLE           dshSection;
+    DWORD            dsOffset;
+}
+alias DIBSECTION* PDIBSECTION;
+
+struct DOCINFOA {
+    int    cbSize = DOCINFOA.sizeof;
+    LPCSTR lpszDocName;
+    LPCSTR lpszOutput;
+    LPCSTR lpszDatatype;
+    DWORD  fwType;
+}
+alias DOCINFOA* LPDOCINFOA;
+
+struct DOCINFOW {
+    int     cbSize = DOCINFOW.sizeof;
+    LPCWSTR lpszDocName;
+    LPCWSTR lpszOutput;
+    LPCWSTR lpszDatatype;
+    DWORD   fwType;
+}
+alias DOCINFOW* LPDOCINFOW;
+
+
+struct PANOSE {
+    BYTE bFamilyType;
+    BYTE bSerifStyle;
+    BYTE bWeight;
+    BYTE bProportion;
+    BYTE bContrast;
+    BYTE bStrokeVariation;
+    BYTE bArmStyle;
+    BYTE bLetterform;
+    BYTE bMidline;
+    BYTE bXHeight;
+}
+alias PANOSE* LPPANOSE;
+
+struct LOGFONTA {
+    LONG lfHeight;
+    LONG lfWidth;
+    LONG lfEscapement;
+    LONG lfOrientation;
+    LONG lfWeight;
+    BYTE lfItalic;
+    BYTE lfUnderline;
+    BYTE lfStrikeOut;
+    BYTE lfCharSet;
+    BYTE lfOutPrecision;
+    BYTE lfClipPrecision;
+    BYTE lfQuality;
+    BYTE lfPitchAndFamily;
+    CHAR[LF_FACESIZE] lfFaceName;
+}
+alias LOGFONTA* PLOGFONTA, NPLOGFONTA, LPLOGFONTA;
+
+struct LOGFONTW {
+    LONG lfHeight;
+    LONG lfWidth;
+    LONG lfEscapement;
+    LONG lfOrientation;
+    LONG lfWeight;
+    BYTE lfItalic;
+    BYTE lfUnderline;
+    BYTE lfStrikeOut;
+    BYTE lfCharSet;
+    BYTE lfOutPrecision;
+    BYTE lfClipPrecision;
+    BYTE lfQuality;
+    BYTE lfPitchAndFamily;
+    WCHAR[LF_FACESIZE] lfFaceName;
+}
+alias LOGFONTW* PLOGFONTW, NPLOGFONTW, LPLOGFONTW;
+
+struct EXTLOGFONTA {
+    LOGFONTA              elfLogFont;
+    BYTE[LF_FULLFACESIZE] elfFullName;
+    BYTE[LF_FACESIZE]     elfStyle;
+    DWORD                 elfVersion;
+    DWORD                 elfStyleSize;
+    DWORD                 elfMatch;
+    DWORD                 elfReserved;
+    BYTE[ELF_VENDOR_SIZE] elfVendorId;
+    DWORD                 elfCulture;
+    PANOSE                elfPanose;
+}
+alias EXTLOGFONTA* PEXTLOGFONTA, NPEXTLOGFONTA, LPEXTLOGFONTA;
+
+struct EXTLOGFONTW {
+    LOGFONTW               elfLogFont;
+    WCHAR[LF_FULLFACESIZE] elfFullName;
+    WCHAR[LF_FACESIZE]     elfStyle;
+    DWORD                  elfVersion;
+    DWORD                  elfStyleSize;
+    DWORD                  elfMatch;
+    DWORD                  elfReserved;
+    BYTE[ELF_VENDOR_SIZE]  elfVendorId;
+    DWORD                  elfCulture;
+    PANOSE                 elfPanose;
+}
+alias EXTLOGFONTW* PEXTLOGFONTW, NPEXTLOGFONTW, LPEXTLOGFONTW;
+
+struct LOGPEN {
+    UINT     lopnStyle;
+    POINT    lopnWidth;
+    COLORREF lopnColor;
+}
+alias LOGPEN* PLOGPEN, NPLOGPEN, LPLOGPEN;
+
+// ---------------------- EMR ------------
+
+struct EMR {
+    DWORD iType;
+    DWORD nSize;
+}
+alias EMR* PEMR;
+
+struct EMRANGLEARC {
+    EMR    emr;
+    POINTL ptlCenter;
+    DWORD  nRadius;
+    FLOAT  eStartAngle;
+    FLOAT  eSweepAngle;
+}
+alias EMRANGLEARC* PEMRANGLEARC;
+
+struct EMRARC {
+    EMR    emr;
+    RECTL  rclBox;
+    POINTL ptlStart;
+    POINTL ptlEnd;
+}
+alias EMRARC* PEMRARC;
+alias TypeDef!(EMRARC) EMRARCTO;
+alias EMRARCTO* PEMRARCTO;
+alias TypeDef!(EMRARC) EMRCHORD;
+alias EMRCHORD* PEMRCHORD;
+alias TypeDef!(EMRARC) EMRPIE;
+alias EMRPIE* PEMRPIE;
+
+struct XFORM {
+    FLOAT eM11;
+    FLOAT eM12;
+    FLOAT eM21;
+    FLOAT eM22;
+    FLOAT eDx;
+    FLOAT eDy;
+}
+alias XFORM* PXFORM, LPXFORM;
+
+struct EMRBITBLT {
+    EMR      emr;
+    RECTL    rclBounds;
+    LONG     xDest;
+    LONG     yDest;
+    LONG     cxDest;
+    LONG     cyDest;
+    DWORD    dwRop;
+    LONG     xSrc;
+    LONG     ySrc;
+    XFORM    xformSrc;
+    COLORREF crBkColorSrc;
+    DWORD    iUsageSrc;
+    DWORD    offBmiSrc;
+    DWORD    cbBmiSrc;
+    DWORD    offBitsSrc;
+    DWORD    cbBitsSrc;
+}
+alias EMRBITBLT* PEMRBITBLT;
+
+struct LOGBRUSH {
+    UINT     lbStyle;
+    COLORREF lbColor;
+    LONG     lbHatch;
+}
+alias TypeDef!(LOGBRUSH) PATTERN;
+alias LOGBRUSH* PLOGBRUSH, NPLOGBRUSH, LPLOGBRUSH;
+alias PATTERN* PPATTERN, NPPATTERN, LPPATTERN;
+
+struct LOGBRUSH32 {
+    UINT lbStyle;
+    COLORREF lbColor;
+    ULONG lbHatch;
+}
+alias LOGBRUSH32* PLOGBRUSH32, NPLOGBRUSH32, LPLOGBRUSH32;
+
+struct EMRCREATEBRUSHINDIRECT {
+    EMR      emr;
+    DWORD    ihBrush;
+    LOGBRUSH32 lb;
+}
+alias EMRCREATEBRUSHINDIRECT* PEMRCREATEBRUSHINDIRECT;
+
+alias LONG LCSCSTYPE, LCSGAMUTMATCH;
+
+struct LOGCOLORSPACEA {
+    DWORD lcsSignature;
+    DWORD lcsVersion;
+    DWORD lcsSize;
+    LCSCSTYPE lcsCSType;
+    LCSGAMUTMATCH lcsIntent;
+    CIEXYZTRIPLE lcsEndpoints;
+    DWORD lcsGammaRed;
+    DWORD lcsGammaGreen;
+    DWORD lcsGammaBlue;
+    CHAR[MAX_PATH] lcsFilename;
+}
+alias LOGCOLORSPACEA* LPLOGCOLORSPACEA;
+
+struct LOGCOLORSPACEW {
+    DWORD lcsSignature;
+    DWORD lcsVersion;
+    DWORD lcsSize;
+    LCSCSTYPE lcsCSType;
+    LCSGAMUTMATCH lcsIntent;
+    CIEXYZTRIPLE lcsEndpoints;
+    DWORD lcsGammaRed;
+    DWORD lcsGammaGreen;
+    DWORD lcsGammaBlue;
+    WCHAR[MAX_PATH] lcsFilename;
+}
+alias LOGCOLORSPACEW* LPLOGCOLORSPACEW;
+
+alias USHORT COLOR16;
+struct TRIVERTEX {
+    LONG x;
+    LONG y;
+    COLOR16 Red;
+    COLOR16 Green;
+    COLOR16 Blue;
+    COLOR16 Alpha;
+}
+alias TRIVERTEX* PTRIVERTEX, LPTRIVERTEX;
+
+struct EMRGLSRECORD {
+    EMR emr;
+    DWORD cbData;
+    BYTE[1] Data;
+}
+alias EMRGLSRECORD* PEMRGLSRECORD;
+
+struct EMRGLSBOUNDEDRECORD {
+    EMR emr;
+    RECTL rclBounds;
+    DWORD cbData;
+    BYTE[1] Data;
+}
+alias EMRGLSBOUNDEDRECORD* PEMRGLSBOUNDEDRECORD;
+
+struct EMRPIXELFORMAT {
+    EMR emr;
+    PIXELFORMATDESCRIPTOR pfd;
+}
+alias EMRPIXELFORMAT* PEMRPIXELFORMAT;
+
+struct EMRCREATECOLORSPACE {
+    EMR emr;
+    DWORD ihCS;
+    LOGCOLORSPACE lcs;
+}
+alias EMRCREATECOLORSPACE* PEMRCREATECOLORSPACE;
+
+struct EMRSETCOLORSPACE {
+    EMR emr;
+    DWORD ihCS;
+}
+alias EMRSETCOLORSPACE* PEMRSETCOLORSPACE;
+alias TypeDef!(EMRSETCOLORSPACE) EMRSELECTCOLORSPACE;
+alias EMRSELECTCOLORSPACE* PEMRSELECTCOLORSPACE;
+alias TypeDef!(EMRSETCOLORSPACE) EMRDELETECOLORSPACE;
+alias EMRDELETECOLORSPACE* PEMRDELETECOLORSPACE;
+
+static if (_WIN32_WINNT >= 0x500) {
+
+    struct EMREXTESCAPE {
+        EMR emr;
+        INT iEscape;
+        INT cbEscData;
+        BYTE[1] EscData;
+    }
+    alias EMREXTESCAPE* PEMREXTESCAPE;
+    alias TypeDef!(EMREXTESCAPE) EMRDRAWESCAPE;
+    alias EMRDRAWESCAPE* PEMRDRAWESCAPE;
+
+    struct EMRNAMEDESCAPE {
+        EMR emr;
+        INT iEscape;
+        INT cbDriver;
+        INT cbEscData;
+        BYTE[1] EscData;
+    }
+    alias EMRNAMEDESCAPE* PEMRNAMEDESCAPE;
+
+    struct EMRSETICMPROFILE {
+        EMR emr;
+        DWORD dwFlags;
+        DWORD cbName;
+        DWORD cbData;
+        BYTE[1] Data;
+    }
+    alias EMRSETICMPROFILE* PEMRSETICMPROFILE;
+    alias TypeDef!(EMRSETICMPROFILE) EMRSETICMPROFILEA;
+    alias EMRSETICMPROFILEA* PEMRSETICMPROFILEA;
+    alias TypeDef!(EMRSETICMPROFILE) EMRSETICMPROFILEW;
+    alias EMRSETICMPROFILEW* PEMRSETICMPROFILEW;
+
+    struct EMRCREATECOLORSPACEW {
+        EMR emr;
+        DWORD ihCS;
+        LOGCOLORSPACEW lcs;
+        DWORD dwFlags;
+        DWORD cbData;
+        BYTE[1] Data;
+    }
+    alias EMRCREATECOLORSPACEW* PEMRCREATECOLORSPACEW;
+
+    struct EMRCOLORMATCHTOTARGET {
+        EMR emr;
+        DWORD dwAction;
+        DWORD dwFlags;
+        DWORD cbName;
+        DWORD cbData;
+        BYTE[1] Data;
+    }
+    alias EMRCOLORMATCHTOTARGET* PEMRCOLORMATCHTOTARGET;
+
+    struct EMRCOLORCORRECTPALETTE {
+        EMR emr;
+        DWORD ihPalette;
+        DWORD nFirstEntry;
+        DWORD nPalEntries;
+        DWORD nReserved;
+    }
+    alias EMRCOLORCORRECTPALETTE* PEMRCOLORCORRECTPALETTE;
+
+    struct EMRALPHABLEND {
+        EMR emr;
+        RECTL rclBounds;
+        LONG xDest;
+        LONG yDest;
+        LONG cxDest;
+        LONG cyDest;
+        DWORD dwRop;
+        LONG xSrc;
+        LONG ySrc;
+        XFORM xformSrc;
+        COLORREF crBkColorSrc;
+        DWORD iUsageSrc;
+        DWORD offBmiSrc;
+        DWORD cbBmiSrc;
+        DWORD offBitsSrc;
+        DWORD cbBitsSrc;
+        LONG cxSrc;
+        LONG cySrc;
+    }
+    alias EMRALPHABLEND* PEMRALPHABLEND;
+
+    struct EMRGRADIENTFILL {
+        EMR emr;
+        RECTL rclBounds;
+        DWORD nVer;
+        DWORD nTri;
+        ULONG ulMode;
+        TRIVERTEX[1] Ver;
+    }
+    alias EMRGRADIENTFILL* PEMRGRADIENTFILL;
+
+    struct EMRTRANSPARENTBLT {
+        EMR emr;
+        RECTL rclBounds;
+        LONG xDest;
+        LONG yDest;
+        LONG cxDest;
+        LONG cyDest;
+        DWORD dwRop;
+        LONG xSrc;
+        LONG ySrc;
+        XFORM xformSrc;
+        COLORREF crBkColorSrc;
+        DWORD iUsageSrc;
+        DWORD offBmiSrc;
+        DWORD cbBmiSrc;
+        DWORD offBitsSrc;
+        DWORD cbBitsSrc;
+        LONG cxSrc;
+        LONG cySrc;
+    }
+    alias EMRTRANSPARENTBLT* PEMRTRANSPARENTBLT;
+}
+
+struct EMRCREATEDIBPATTERNBRUSHPT {
+    EMR emr;
+    DWORD ihBrush;
+    DWORD iUsage;
+    DWORD offBmi;
+    DWORD cbBmi;
+    DWORD offBits;
+    DWORD cbBits;
+}
+alias EMRCREATEDIBPATTERNBRUSHPT* PEMRCREATEDIBPATTERNBRUSHPT;
+
+struct EMRCREATEMONOBRUSH {
+    EMR emr;
+    DWORD ihBrush;
+    DWORD iUsage;
+    DWORD offBmi;
+    DWORD cbBmi;
+    DWORD offBits;
+    DWORD cbBits;
+}
+alias EMRCREATEMONOBRUSH* PEMRCREATEMONOBRUSH;
+
+struct PALETTEENTRY {
+    BYTE peRed;
+    BYTE peGreen;
+    BYTE peBlue;
+    BYTE peFlags;
+}
+alias PALETTEENTRY* PPALETTEENTRY, LPPALETTEENTRY;
+
+struct LOGPALETTE {
+    WORD palVersion;
+    WORD palNumEntries;
+    PALETTEENTRY[1] palPalEntry;
+}
+alias LOGPALETTE* PLOGPALETTE, NPLOGPALETTE, LPLOGPALETTE;
+
+struct EMRCREATEPALETTE {
+    EMR emr;
+    DWORD ihPal;
+    LOGPALETTE lgpl;
+}
+alias EMRCREATEPALETTE* PEMRCREATEPALETTE;
+
+struct EMRCREATEPEN {
+    EMR emr;
+    DWORD ihPen;
+    LOGPEN lopn;
+}
+alias EMRCREATEPEN* PEMRCREATEPEN;
+
+struct EMRELLIPSE {
+    EMR emr;
+    RECTL rclBox;
+}
+alias EMRELLIPSE* PEMRELLIPSE;
+
+alias TypeDef!(EMRELLIPSE) EMRRECTANGLE;
+alias EMRRECTANGLE* PEMRRECTANGLE;
+
+struct EMREOF {
+    EMR emr;
+    DWORD nPalEntries;
+    DWORD offPalEntries;
+    DWORD nSizeLast;
+}
+alias EMREOF* PEMREOF;
+
+struct EMREXCLUDECLIPRECT {
+    EMR emr;
+    RECTL rclClip;
+}
+alias EMREXCLUDECLIPRECT* PEMREXCLUDECLIPRECT;
+alias TypeDef!(EMREXCLUDECLIPRECT) EMRINTERSECTCLIPRECT;
+alias EMRINTERSECTCLIPRECT* PEMRINTERSECTCLIPRECT;
+
+struct EMREXTCREATEFONTINDIRECTW {
+    EMR emr;
+    DWORD ihFont;
+    EXTLOGFONTW elfw;
+}
+alias EMREXTCREATEFONTINDIRECTW* PEMREXTCREATEFONTINDIRECTW;
+
+struct EXTLOGPEN {
+    UINT elpPenStyle;
+    UINT elpWidth;
+    UINT elpBrushStyle;
+    COLORREF elpColor;
+    LONG elpHatch;
+    DWORD elpNumEntries;
+    DWORD[1] elpStyleEntry;
+}
+alias EXTLOGPEN* PEXTLOGPEN, NPEXTLOGPEN, LPEXTLOGPEN;
+
+struct EMREXTCREATEPEN {
+    EMR emr;
+    DWORD ihPen;
+    DWORD offBmi;
+    DWORD cbBmi;
+    DWORD offBits;
+    DWORD cbBits;
+    EXTLOGPEN elp;
+}
+alias EMREXTCREATEPEN* PEMREXTCREATEPEN;
+
+struct EMREXTFLOODFILL {
+    EMR emr;
+    POINTL ptlStart;
+    COLORREF crColor;
+    DWORD iMode;
+}
+alias EMREXTFLOODFILL* PEMREXTFLOODFILL;
+
+struct EMREXTSELECTCLIPRGN {
+    EMR emr;
+    DWORD cbRgnData;
+    DWORD iMode;
+    BYTE [1]RgnData;
+}
+alias EMREXTSELECTCLIPRGN* PEMREXTSELECTCLIPRGN;
+
+struct EMRTEXT {
+    POINTL ptlReference;
+    DWORD nChars;
+    DWORD offString;
+    DWORD fOptions;
+    RECTL rcl;
+    DWORD offDx;
+}
+alias EMRTEXT* PEMRTEXT;
+
+struct EMREXTTEXTOUTA {
+    EMR emr;
+    RECTL rclBounds;
+    DWORD iGraphicsMode;
+    FLOAT exScale;
+    FLOAT eyScale;
+    EMRTEXT emrtext;
+}
+alias EMREXTTEXTOUTA* PEMREXTTEXTOUTA;
+alias TypeDef!(EMREXTTEXTOUTA) EMREXTTEXTOUTW;
+alias EMREXTTEXTOUTW* PEMREXTTEXTOUTW;
+
+struct EMRFILLPATH {
+    EMR emr;
+    RECTL rclBounds;
+}
+alias EMRFILLPATH* PEMRFILLPATH;
+
+alias TypeDef!(EMRFILLPATH) EMRSTROKEANDFILLPATH;
+alias EMRSTROKEANDFILLPATH* PEMRSTROKEANDFILLPATH;
+
+alias TypeDef!(EMRFILLPATH) EMRSTROKEPATH;
+alias EMRSTROKEPATH* PEMRSTROKEPATH;
+
+struct EMRFILLRGN {
+    EMR emr;
+    RECTL rclBounds;
+    DWORD cbRgnData;
+    DWORD ihBrush;
+    BYTE[1] RgnData;
+}
+alias EMRFILLRGN* PEMRFILLRGN;
+
+struct EMRFORMAT {
+    DWORD dSignature;
+    DWORD nVersion;
+    DWORD cbData;
+    DWORD offData;
+}
+alias EMRFORMAT* PEMRFORMAT;
+
+struct EMRFRAMERGN {
+    EMR emr;
+    RECTL rclBounds;
+    DWORD cbRgnData;
+    DWORD ihBrush;
+    SIZEL szlStroke;
+    BYTE[1] RgnData;
+}
+alias EMRFRAMERGN* PEMRFRAMERGN;
+
+struct EMRGDICOMMENT {
+    EMR emr;
+    DWORD cbData;
+    BYTE[1] Data;
+}
+alias EMRGDICOMMENT* PEMRGDICOMMENT;
+
+struct EMRINVERTRGN {
+    EMR emr;
+    RECTL rclBounds;
+    DWORD cbRgnData;
+    BYTE[1] RgnData;
+}
+alias EMRINVERTRGN* PEMRINVERTRGN;
+alias TypeDef!(EMRINVERTRGN) EMRPAINTRGN;
+alias EMRPAINTRGN* PEMRPAINTRGN;
+
+struct EMRLINETO {
+    EMR emr;
+    POINTL ptl;
+}
+alias EMRLINETO* PEMRLINETO;
+alias TypeDef!(EMRLINETO) EMRMOVETOEX;
+alias EMRMOVETOEX* PEMRMOVETOEX;
+
+struct EMRMASKBLT {
+    EMR emr;
+    RECTL rclBounds;
+    LONG xDest;
+    LONG yDest;
+    LONG cxDest;
+    LONG cyDest;
+    DWORD dwRop;
+    LONG xSrc;
+    LONG ySrc;
+    XFORM xformSrc;
+    COLORREF crBkColorSrc;
+    DWORD iUsageSrc;
+    DWORD offBmiSrc;
+    DWORD cbBmiSrc;
+    DWORD offBitsSrc;
+    DWORD cbBitsSrc;
+    LONG xMask;
+    LONG yMask;
+    DWORD iUsageMask;
+    DWORD offBmiMask;
+    DWORD cbBmiMask;
+    DWORD offBitsMask;
+    DWORD cbBitsMask;
+}
+alias EMRMASKBLT* PEMRMASKBLT;
+
+struct EMRMODIFYWORLDTRANSFORM {
+    EMR emr;
+    XFORM xform;
+    DWORD iMode;
+}
+alias EMRMODIFYWORLDTRANSFORM* PEMRMODIFYWORLDTRANSFORM;
+
+struct EMROFFSETCLIPRGN {
+    EMR emr;
+    POINTL ptlOffset;
+}
+alias EMROFFSETCLIPRGN* PEMROFFSETCLIPRGN;
+
+struct EMRPLGBLT {
+    EMR emr;
+    RECTL rclBounds;
+    POINTL[3] aptlDest;
+    LONG xSrc;
+    LONG ySrc;
+    LONG cxSrc;
+    LONG cySrc;
+    XFORM xformSrc;
+    COLORREF crBkColorSrc;
+    DWORD iUsageSrc;
+    DWORD offBmiSrc;
+    DWORD cbBmiSrc;
+    DWORD offBitsSrc;
+    DWORD cbBitsSrc;
+    LONG xMask;
+    LONG yMask;
+    DWORD iUsageMask;
+    DWORD offBmiMask;
+    DWORD cbBmiMask;
+    DWORD offBitsMask;
+    DWORD cbBitsMask;
+}
+alias EMRPLGBLT* PEMRPLGBLT;
+
+struct EMRPOLYDRAW {
+    EMR emr;
+    RECTL rclBounds;
+    DWORD cptl;
+    POINTL[1] aptl;
+    BYTE[1] abTypes;
+}
+alias EMRPOLYDRAW* PEMRPOLYDRAW;
+
+struct EMRPOLYDRAW16 {
+    EMR emr;
+    RECTL rclBounds;
+    DWORD cpts;
+    POINTS[1] apts;
+    BYTE[1] abTypes;
+}
+alias EMRPOLYDRAW16* PEMRPOLYDRAW16;
+
+struct EMRPOLYLINE {
+    EMR emr;
+    RECTL rclBounds;
+    DWORD cptl;
+    POINTL[1] aptl;
+}
+alias EMRPOLYLINE* PEMRPOLYLINE;
+alias TypeDef!(EMRPOLYLINE) EMRPOLYBEZIER;
+alias EMRPOLYBEZIER* PEMRPOLYBEZIER;
+alias TypeDef!(EMRPOLYLINE) EMRPOLYGON;
+alias EMRPOLYGON* PEMRPOLYGON;
+alias TypeDef!(EMRPOLYLINE) EMRPOLYBEZIERTO;
+alias EMRPOLYBEZIERTO* PEMRPOLYBEZIERTO;
+alias TypeDef!(EMRPOLYLINE) EMRPOLYLINETO;
+alias EMRPOLYLINETO* PEMRPOLYLINETO;
+
+struct EMRPOLYLINE16 {
+    EMR emr;
+    RECTL rclBounds;
+    DWORD cpts;
+    POINTS[1] apts;
+}
+alias EMRPOLYLINE16* PEMRPOLYLINE16;
+alias TypeDef!(EMRPOLYLINE16) EMRPOLYBEZIER16;
+alias EMRPOLYBEZIER16* PEMRPOLYBEZIER16;
+alias TypeDef!(EMRPOLYLINE16) EMRPOLYGON16;
+alias EMRPOLYGON16* PEMRPOLYGON16;
+alias TypeDef!(EMRPOLYLINE16) EMRPOLYBEZIERTO16;
+alias EMRPOLYBEZIERTO16* PEMRPOLYBEZIERTO16;
+alias TypeDef!(EMRPOLYLINE16) EMRPOLYLINETO16;
+alias EMRPOLYLINETO16* PEMRPOLYLINETO16;
+
+struct EMRPOLYPOLYLINE {
+    EMR emr;
+    RECTL rclBounds;
+    DWORD nPolys;
+    DWORD cptl;
+    DWORD[1] aPolyCounts;
+    POINTL[1] aptl;
+}
+alias EMRPOLYPOLYLINE* PEMRPOLYPOLYLINE;
+alias TypeDef!(EMRPOLYPOLYLINE) EMRPOLYPOLYGON;
+alias EMRPOLYPOLYGON* PEMRPOLYPOLYGON;
+
+struct EMRPOLYPOLYLINE16 {
+    EMR emr;
+    RECTL rclBounds;
+    DWORD nPolys;
+    DWORD cpts;
+    DWORD[1] aPolyCounts;
+    POINTS[1] apts;
+}
+alias EMRPOLYPOLYLINE16* PEMRPOLYPOLYLINE16;
+alias TypeDef!(EMRPOLYPOLYLINE16) EMRPOLYPOLYGON16;
+alias EMRPOLYPOLYGON16* PEMRPOLYPOLYGON16;
+
+struct EMRPOLYTEXTOUTA {
+    EMR emr;
+    RECTL rclBounds;
+    DWORD iGraphicsMode;
+    FLOAT exScale;
+    FLOAT eyScale;
+    LONG cStrings;
+    EMRTEXT[1] aemrtext;
+}
+alias EMRPOLYTEXTOUTA* PEMRPOLYTEXTOUTA;
+alias TypeDef!(EMRPOLYTEXTOUTA) EMRPOLYTEXTOUTW;
+alias EMRPOLYTEXTOUTW* PEMRPOLYTEXTOUTW;
+
+struct EMRRESIZEPALETTE {
+    EMR emr;
+    DWORD ihPal;
+    DWORD cEntries;
+}
+alias EMRRESIZEPALETTE* PEMRRESIZEPALETTE;
+
+struct EMRRESTOREDC {
+    EMR emr;
+    LONG iRelative;
+}
+alias EMRRESTOREDC* PEMRRESTOREDC;
+
+struct EMRROUNDRECT {
+    EMR emr;
+    RECTL rclBox;
+    SIZEL szlCorner;
+}
+alias EMRROUNDRECT* PEMRROUNDRECT;
+
+struct EMRSCALEVIEWPORTEXTEX {
+    EMR emr;
+    LONG xNum;
+    LONG xDenom;
+    LONG yNum;
+    LONG yDenom;
+}
+alias EMRSCALEVIEWPORTEXTEX* PEMRSCALEVIEWPORTEXTEX;
+alias TypeDef!(EMRSCALEVIEWPORTEXTEX) EMRSCALEWINDOWEXTEX;
+alias EMRSCALEWINDOWEXTEX* PEMRSCALEWINDOWEXTEX;
+
+struct EMRSELECTOBJECT {
+    EMR emr;
+    DWORD ihObject;
+}
+alias EMRSELECTOBJECT* PEMRSELECTOBJECT;
+alias TypeDef!(EMRSELECTOBJECT) EMRDELETEOBJECT;
+alias EMRDELETEOBJECT* PEMRDELETEOBJECT;
+
+struct EMRSELECTPALETTE {
+    EMR emr;
+    DWORD ihPal;
+}
+alias EMRSELECTPALETTE* PEMRSELECTPALETTE;
+
+struct EMRSETARCDIRECTION {
+    EMR emr;
+    DWORD iArcDirection;
+}
+alias EMRSETARCDIRECTION* PEMRSETARCDIRECTION;
+
+struct EMRSETTEXTCOLOR {
+    EMR emr;
+    COLORREF crColor;
+}
+alias EMRSETTEXTCOLOR* PEMRSETTEXTCOLOR;
+alias TypeDef!(EMRSETTEXTCOLOR) EMRSETBKCOLOR;
+alias EMRSETBKCOLOR* PEMRSETBKCOLOR;
+
+struct EMRSETCOLORADJUSTMENT {
+    EMR emr;
+    COLORADJUSTMENT ColorAdjustment;
+}
+alias EMRSETCOLORADJUSTMENT* PEMRSETCOLORADJUSTMENT;
+
+struct EMRSETDIBITSTODEVICE {
+    EMR emr;
+    RECTL rclBounds;
+    LONG xDest;
+    LONG yDest;
+    LONG xSrc;
+    LONG ySrc;
+    LONG cxSrc;
+    LONG cySrc;
+    DWORD offBmiSrc;
+    DWORD cbBmiSrc;
+    DWORD offBitsSrc;
+    DWORD cbBitsSrc;
+    DWORD iUsageSrc;
+    DWORD iStartScan;
+    DWORD cScans;
+}
+alias EMRSETDIBITSTODEVICE* PEMRSETDIBITSTODEVICE;
+
+struct EMRSETMAPPERFLAGS {
+    EMR emr;
+    DWORD dwFlags;
+}
+alias EMRSETMAPPERFLAGS* PEMRSETMAPPERFLAGS;
+
+struct EMRSETMITERLIMIT {
+    EMR emr;
+    FLOAT eMiterLimit;
+}
+alias EMRSETMITERLIMIT* PEMRSETMITERLIMIT;
+
+struct EMRSETPALETTEENTRIES {
+    EMR emr;
+    DWORD ihPal;
+    DWORD iStart;
+    DWORD cEntries;
+    PALETTEENTRY[1] aPalEntries;
+}
+alias EMRSETPALETTEENTRIES* PEMRSETPALETTEENTRIES;
+
+struct EMRSETPIXELV {
+    EMR emr;
+    POINTL ptlPixel;
+    COLORREF crColor;
+}
+alias EMRSETPIXELV* PEMRSETPIXELV;
+
+struct EMRSETVIEWPORTEXTEX {
+    EMR emr;
+    SIZEL szlExtent;
+}
+alias EMRSETVIEWPORTEXTEX* PEMRSETVIEWPORTEXTEX;
+alias TypeDef!(EMRSETVIEWPORTEXTEX) EMRSETWINDOWEXTEX;
+alias EMRSETWINDOWEXTEX* PEMRSETWINDOWEXTEX;
+
+struct EMRSETVIEWPORTORGEX {
+    EMR emr;
+    POINTL ptlOrigin;
+}
+alias EMRSETVIEWPORTORGEX* PEMRSETVIEWPORTORGEX;
+alias TypeDef!(EMRSETVIEWPORTORGEX) EMRSETWINDOWORGEX;
+alias EMRSETWINDOWORGEX* PEMRSETWINDOWORGEX;
+alias TypeDef!(EMRSETVIEWPORTORGEX) EMRSETBRUSHORGEX;
+alias EMRSETBRUSHORGEX* PEMRSETBRUSHORGEX;
+
+struct EMRSETWORLDTRANSFORM {
+    EMR emr;
+    XFORM xform;
+}
+alias EMRSETWORLDTRANSFORM* PEMRSETWORLDTRANSFORM;
+
+struct EMRSTRETCHBLT {
+    EMR emr;
+    RECTL rclBounds;
+    LONG xDest;
+    LONG yDest;
+    LONG cxDest;
+    LONG cyDest;
+    DWORD dwRop;
+    LONG xSrc;
+    LONG ySrc;
+    XFORM xformSrc;
+    COLORREF crBkColorSrc;
+    DWORD iUsageSrc;
+    DWORD offBmiSrc;
+    DWORD cbBmiSrc;
+    DWORD offBitsSrc;
+    DWORD cbBitsSrc;
+    LONG cxSrc;
+    LONG cySrc;
+}
+alias EMRSTRETCHBLT* PEMRSTRETCHBLT;
+
+struct EMRSTRETCHDIBITS {
+    EMR emr;
+    RECTL rclBounds;
+    LONG xDest;
+    LONG yDest;
+    LONG xSrc;
+    LONG ySrc;
+    LONG cxSrc;
+    LONG cySrc;
+    DWORD offBmiSrc;
+    DWORD cbBmiSrc;
+    DWORD offBitsSrc;
+    DWORD cbBitsSrc;
+    DWORD iUsageSrc;
+    DWORD dwRop;
+    LONG cxDest;
+    LONG cyDest;
+}
+alias EMRSTRETCHDIBITS* PEMRSTRETCHDIBITS;
+
+struct EMRABORTPATH {
+    EMR emr;
+}
+alias EMRABORTPATH* PEMRABORTPATH;
+alias TypeDef!(EMRABORTPATH) EMRBEGINPATH;
+alias EMRBEGINPATH* PEMRBEGINPATH;
+alias TypeDef!(EMRABORTPATH) EMRENDPATH;
+alias EMRENDPATH* PEMRENDPATH;
+alias TypeDef!(EMRABORTPATH) EMRCLOSEFIGURE;
+alias EMRCLOSEFIGURE* PEMRCLOSEFIGURE;
+alias TypeDef!(EMRABORTPATH) EMRFLATTENPATH;
+alias EMRFLATTENPATH* PEMRFLATTENPATH;
+alias TypeDef!(EMRABORTPATH) EMRWIDENPATH;
+alias EMRWIDENPATH* PEMRWIDENPATH;
+alias TypeDef!(EMRABORTPATH) EMRSETMETARGN;
+alias EMRSETMETARGN* PEMRSETMETARGN;
+alias TypeDef!(EMRABORTPATH) EMRSAVEDC;
+alias EMRSAVEDC* PEMRSAVEDC;
+alias TypeDef!(EMRABORTPATH) EMRREALIZEPALETTE;
+alias EMRREALIZEPALETTE* PEMRREALIZEPALETTE;
+
+struct EMRSELECTCLIPPATH {
+    EMR emr;
+    DWORD iMode;
+}
+alias EMRSELECTCLIPPATH* PEMRSELECTCLIPPATH;
+alias TypeDef!(EMRSELECTCLIPPATH) EMRSETBKMODE;
+alias EMRSETBKMODE* PEMRSETBKMODE;
+alias TypeDef!(EMRSELECTCLIPPATH) EMRSETMAPMODE;
+alias EMRSETMAPMODE* PEMRSETMAPMODE;
+alias TypeDef!(EMRSELECTCLIPPATH) EMRSETPOLYFILLMODE;
+alias EMRSETPOLYFILLMODE* PEMRSETPOLYFILLMODE;
+alias TypeDef!(EMRSELECTCLIPPATH) EMRSETROP2;
+alias EMRSETROP2* PEMRSETROP2;
+alias TypeDef!(EMRSELECTCLIPPATH) EMRSETSTRETCHBLTMODE;
+alias EMRSETSTRETCHBLTMODE* PEMRSETSTRETCHBLTMODE;
+alias TypeDef!(EMRSELECTCLIPPATH) EMRSETICMMODE;
+alias EMRSETICMMODE* PEMRSETICMMODE;
+alias TypeDef!(EMRSELECTCLIPPATH) EMRSETTEXTALIGN;
+alias EMRSETTEXTALIGN* PEMRSETTEXTALIGN;
+alias TypeDef!(EMRSELECTCLIPPATH) EMRENABLEICM;
+alias EMRENABLEICM* PEMRENABLEICM;
+static if (_WIN32_WINNT >= 0x500) {
+    alias TypeDef!(EMRSELECTCLIPPATH) EMRSETLAYOUT;
+    alias EMRSETLAYOUT* PEMRSETLAYOUT;
+}
+
+align(2):
+struct METAHEADER {
+align(2):
+    WORD mtType;
+    WORD mtHeaderSize;
+    WORD mtVersion;
+    DWORD mtSize;
+    WORD mtNoObjects;
+    DWORD mtMaxRecord;
+    WORD mtNoParameters;
+}
+alias METAHEADER* PMETAHEADER;
+alias METAHEADER* LPMETAHEADER;
+
+align:
+
+struct ENHMETAHEADER {
+    DWORD iType = EMR_HEADER;
+    DWORD nSize = ENHMETAHEADER.sizeof;
+    RECTL rclBounds;
+    RECTL rclFrame;
+    DWORD dSignature = ENHMETA_SIGNATURE;
+    DWORD nVersion;
+    DWORD nBytes;
+    DWORD nRecords;
+    WORD nHandles;
+    WORD sReserved;
+    DWORD nDescription;
+    DWORD offDescription;
+    DWORD nPalEntries;
+    SIZEL szlDevice;
+    SIZEL szlMillimeters;
+    DWORD cbPixelFormat;
+    DWORD offPixelFormat;
+    DWORD bOpenGL;
+    static if (_WIN32_WINNT >= 0x500) {
+        SIZEL szlMicrometers;
+    }
+}
+alias ENHMETAHEADER* PENHMETAHEADER, LPENHMETAHEADER;
+
+struct METARECORD {
+    DWORD rdSize;
+    WORD rdFunction;
+    WORD[1] rdParm;
+}
+alias METARECORD* PMETARECORD;
+alias METARECORD* LPMETARECORD;
+
+struct ENHMETARECORD {
+    DWORD iType;
+    DWORD nSize;
+    DWORD[1] dParm;
+}
+alias ENHMETARECORD* PENHMETARECORD, LPENHMETARECORD;
+
+// ---
+
+struct HANDLETABLE {
+    HGDIOBJ[1] objectHandle;
+}
+alias HANDLETABLE* PHANDLETABLE, LPHANDLETABLE;
+
+struct TEXTMETRICA {
+    LONG tmHeight;
+    LONG tmAscent;
+    LONG tmDescent;
+    LONG tmInternalLeading;
+    LONG tmExternalLeading;
+    LONG tmAveCharWidth;
+    LONG tmMaxCharWidth;
+    LONG tmWeight;
+    LONG tmOverhang;
+    LONG tmDigitizedAspectX;
+    LONG tmDigitizedAspectY;
+    BYTE tmFirstChar;
+    BYTE tmLastChar;
+    BYTE tmDefaultChar;
+    BYTE tmBreakChar;
+    BYTE tmItalic;
+    BYTE tmUnderlined;
+    BYTE tmStruckOut;
+    BYTE tmPitchAndFamily;
+    BYTE tmCharSet;
+}
+alias TEXTMETRICA* PTEXTMETRICA, NPTEXTMETRICA, LPTEXTMETRICA;
+
+struct TEXTMETRICW {
+    LONG tmHeight;
+    LONG tmAscent;
+    LONG tmDescent;
+    LONG tmInternalLeading;
+    LONG tmExternalLeading;
+    LONG tmAveCharWidth;
+    LONG tmMaxCharWidth;
+    LONG tmWeight;
+    LONG tmOverhang;
+    LONG tmDigitizedAspectX;
+    LONG tmDigitizedAspectY;
+    WCHAR tmFirstChar;
+    WCHAR tmLastChar;
+    WCHAR tmDefaultChar;
+    WCHAR tmBreakChar;
+    BYTE tmItalic;
+    BYTE tmUnderlined;
+    BYTE tmStruckOut;
+    BYTE tmPitchAndFamily;
+    BYTE tmCharSet;
+}
+alias TEXTMETRICW* PTEXTMETRICW, NPTEXTMETRICW, LPTEXTMETRICW;
+
+struct RGNDATAHEADER {
+    DWORD dwSize;
+    DWORD iType;
+    DWORD nCount;
+    DWORD nRgnSize;
+    RECT rcBound;
+}
+alias RGNDATAHEADER* PRGNDATAHEADER;
+
+struct RGNDATA {
+    RGNDATAHEADER rdh;
+    char[1] Buffer;
+}
+alias RGNDATA* PRGNDATA, NPRGNDATA, LPRGNDATA;
+
+/* for GetRandomRgn */
+enum SYSRGN=4;
+struct GCP_RESULTSA {
+    DWORD lStructSize;
+    LPSTR lpOutString;
+    UINT* lpOrder;
+    INT* lpDx;
+    INT* lpCaretPos;
+    LPSTR lpClass;
+    LPWSTR lpGlyphs;
+    UINT nGlyphs;
+    UINT nMaxFit;
+}
+alias GCP_RESULTSA* LPGCP_RESULTSA;
+
+struct GCP_RESULTSW {
+    DWORD lStructSize;
+    LPWSTR lpOutString;
+    UINT* lpOrder;
+    INT* lpDx;
+    INT* lpCaretPos;
+    LPWSTR lpClass;
+    LPWSTR lpGlyphs;
+    UINT nGlyphs;
+    UINT nMaxFit;
+}
+alias GCP_RESULTSW* LPGCP_RESULTSW;
+
+struct GLYPHMETRICS {
+    UINT gmBlackBoxX;
+    UINT gmBlackBoxY;
+    POINT gmptGlyphOrigin;
+    short gmCellIncX;
+    short gmCellIncY;
+}
+alias GLYPHMETRICS* LPGLYPHMETRICS;
+
+static if (_WIN32_WINNT >= 0x500) {
+    struct WCRANGE {
+        WCHAR  wcLow;
+        USHORT cGlyphs;
+    }
+    alias WCRANGE* PWCRANGE, LPWCRANGE;
+
+    struct GLYPHSET {
+        DWORD cbThis;
+        DWORD flAccel;
+        DWORD cGlyphsSupported;
+        DWORD cRanges;
+        WCRANGE[1] ranges;
+    }
+    alias GLYPHSET* PGLYPHSET, LPGLYPHSET;
+
+enum DWORD GS_8BIT_INDICES = 0x00000001;
+}
+
+struct KERNINGPAIR {
+    WORD wFirst;
+    WORD wSecond;
+    int iKernAmount;
+}
+alias KERNINGPAIR* LPKERNINGPAIR;
+
+struct FIXED {
+    WORD fract;
+    short value;
+}
+
+struct MAT2 {
+    FIXED eM11;
+    FIXED eM12;
+    FIXED eM21;
+    FIXED eM22;
+}
+alias MAT2* LPMAT2;
+
+struct OUTLINETEXTMETRICA {
+    UINT otmSize;
+    TEXTMETRICA otmTextMetrics;
+    BYTE otmFiller;
+    PANOSE otmPanoseNumber;
+    UINT otmfsSelection;
+    UINT otmfsType;
+    int otmsCharSlopeRise;
+    int otmsCharSlopeRun;
+    int otmItalicAngle;
+    UINT otmEMSquare;
+    int otmAscent;
+    int otmDescent;
+    UINT otmLineGap;
+    UINT otmsCapEmHeight;
+    UINT otmsXHeight;
+    RECT otmrcFontBox;
+    int otmMacAscent;
+    int otmMacDescent;
+    UINT otmMacLineGap;
+    UINT otmusMinimumPPEM;
+    POINT otmptSubscriptSize;
+    POINT otmptSubscriptOffset;
+    POINT otmptSuperscriptSize;
+    POINT otmptSuperscriptOffset;
+    UINT otmsStrikeoutSize;
+    int otmsStrikeoutPosition;
+    int otmsUnderscoreSize;
+    int otmsUnderscorePosition;
+    PSTR otmpFamilyName;
+    PSTR otmpFaceName;
+    PSTR otmpStyleName;
+    PSTR otmpFullName;
+}
+alias OUTLINETEXTMETRICA* POUTLINETEXTMETRICA, NPOUTLINETEXTMETRICA, LPOUTLINETEXTMETRICA;
+
+struct OUTLINETEXTMETRICW {
+    UINT otmSize;
+    TEXTMETRICW otmTextMetrics;
+    BYTE otmFiller;
+    PANOSE otmPanoseNumber;
+    UINT otmfsSelection;
+    UINT otmfsType;
+    int otmsCharSlopeRise;
+    int otmsCharSlopeRun;
+    int otmItalicAngle;
+    UINT otmEMSquare;
+    int otmAscent;
+    int otmDescent;
+    UINT otmLineGap;
+    UINT otmsCapEmHeight;
+    UINT otmsXHeight;
+    RECT otmrcFontBox;
+    int otmMacAscent;
+    int otmMacDescent;
+    UINT otmMacLineGap;
+    UINT otmusMinimumPPEM;
+    POINT otmptSubscriptSize;
+    POINT otmptSubscriptOffset;
+    POINT otmptSuperscriptSize;
+    POINT otmptSuperscriptOffset;
+    UINT otmsStrikeoutSize;
+    int otmsStrikeoutPosition;
+    int otmsUnderscoreSize;
+    int otmsUnderscorePosition;
+    PSTR otmpFamilyName;
+    PSTR otmpFaceName;
+    PSTR otmpStyleName;
+    PSTR otmpFullName;
+}
+alias OUTLINETEXTMETRICW* POUTLINETEXTMETRICW, NPOUTLINETEXTMETRICW, LPOUTLINETEXTMETRICW;
+
+struct RASTERIZER_STATUS {
+    short nSize;
+    short wFlags;
+    short nLanguageID;
+}
+alias RASTERIZER_STATUS* LPRASTERIZER_STATUS;
+
+struct POLYTEXTA {
+    int x;
+    int y;
+    UINT n;
+    LPCSTR lpstr;
+    UINT uiFlags;
+    RECT rcl;
+    int* pdx;
+}
+alias POLYTEXTA* PPOLYTEXTA, NPPOLYTEXTA, LPPOLYTEXTA;
+
+struct POLYTEXTW {
+    int x;
+    int y;
+    UINT n;
+    LPCWSTR lpstr;
+    UINT uiFlags;
+    RECT rcl;
+    int* pdx;
+}
+alias POLYTEXTW* PPOLYTEXTW, NPPOLYTEXTW, LPPOLYTEXTW;
+
+struct PIXELFORMATDESCRIPTOR {
+    WORD nSize;
+    WORD nVersion;
+    DWORD dwFlags;
+    BYTE iPixelType;
+    BYTE cColorBits;
+    BYTE cRedBits;
+    BYTE cRedShift;
+    BYTE cGreenBits;
+    BYTE cGreenShift;
+    BYTE cBlueBits;
+    BYTE cBlueShift;
+    BYTE cAlphaBits;
+    BYTE cAlphaShift;
+    BYTE cAccumBits;
+    BYTE cAccumRedBits;
+    BYTE cAccumGreenBits;
+    BYTE cAccumBlueBits;
+    BYTE cAccumAlphaBits;
+    BYTE cDepthBits;
+    BYTE cStencilBits;
+    BYTE cAuxBuffers;
+    BYTE iLayerType;
+    BYTE bReserved;
+    DWORD dwLayerMask;
+    DWORD dwVisibleMask;
+    DWORD dwDamageMask;
+}
+alias PIXELFORMATDESCRIPTOR* PPIXELFORMATDESCRIPTOR, LPPIXELFORMATDESCRIPTOR;
+
+struct METAFILEPICT {
+    LONG mm;
+    LONG xExt;
+    LONG yExt;
+    HMETAFILE hMF;
+}
+alias METAFILEPICT* LPMETAFILEPICT;
+
+struct LOCALESIGNATURE {
+    DWORD[4] lsUsb;
+    DWORD[2] lsCsbDefault;
+    DWORD[2] lsCsbSupported;
+}
+alias LOCALESIGNATURE* PLOCALESIGNATURE, LPLOCALESIGNATURE;
+
+alias LONG LCSTYPE; /* What this for? */
+
+align(4):
+struct NEWTEXTMETRICA {
+    LONG tmHeight;
+    LONG tmAscent;
+    LONG tmDescent;
+    LONG tmInternalLeading;
+    LONG tmExternalLeading;
+    LONG tmAveCharWidth;
+    LONG tmMaxCharWidth;
+    LONG tmWeight;
+    LONG tmOverhang;
+    LONG tmDigitizedAspectX;
+    LONG tmDigitizedAspectY;
+    BYTE tmFirstChar;
+    BYTE tmLastChar;
+    BYTE tmDefaultChar;
+    BYTE tmBreakChar;
+    BYTE tmItalic;
+    BYTE tmUnderlined;
+    BYTE tmStruckOut;
+    BYTE tmPitchAndFamily;
+    BYTE tmCharSet;
+    DWORD ntmFlags;
+    UINT ntmSizeEM;
+    UINT ntmCellHeight;
+    UINT ntmAvgWidth;
+}
+alias NEWTEXTMETRICA* PNEWTEXTMETRICA, NPNEWTEXTMETRICA, LPNEWTEXTMETRICA;
+
+struct NEWTEXTMETRICW {
+    LONG tmHeight;
+    LONG tmAscent;
+    LONG tmDescent;
+    LONG tmInternalLeading;
+    LONG tmExternalLeading;
+    LONG tmAveCharWidth;
+    LONG tmMaxCharWidth;
+    LONG tmWeight;
+    LONG tmOverhang;
+    LONG tmDigitizedAspectX;
+    LONG tmDigitizedAspectY;
+    WCHAR tmFirstChar;
+    WCHAR tmLastChar;
+    WCHAR tmDefaultChar;
+    WCHAR tmBreakChar;
+    BYTE tmItalic;
+    BYTE tmUnderlined;
+    BYTE tmStruckOut;
+    BYTE tmPitchAndFamily;
+    BYTE tmCharSet;
+    DWORD ntmFlags;
+    UINT ntmSizeEM;
+    UINT ntmCellHeight;
+    UINT ntmAvgWidth;
+}
+alias NEWTEXTMETRICW* PNEWTEXTMETRICW, NPNEWTEXTMETRICW, LPNEWTEXTMETRICW;
+
+align:
+struct NEWTEXTMETRICEXA {
+    NEWTEXTMETRICA ntmTm;
+    FONTSIGNATURE ntmFontSig;
+}
+
+struct NEWTEXTMETRICEXW {
+    NEWTEXTMETRICW ntmTm;
+    FONTSIGNATURE ntmFontSig;
+}
+
+struct PELARRAY {
+    LONG paXCount;
+    LONG paYCount;
+    LONG paXExt;
+    LONG paYExt;
+    BYTE paRGBs;
+}
+alias PELARRAY* PPELARRAY, NPPELARRAY, LPPELARRAY;
+
+struct ENUMLOGFONTA {
+    LOGFONTA elfLogFont;
+    BYTE[LF_FULLFACESIZE] elfFullName;
+    BYTE[LF_FACESIZE] elfStyle;
+}
+alias ENUMLOGFONTA* LPENUMLOGFONTA;
+
+struct ENUMLOGFONTW {
+    LOGFONTW elfLogFont;
+    WCHAR[LF_FULLFACESIZE] elfFullName;
+    WCHAR[LF_FACESIZE] elfStyle;
+}
+alias ENUMLOGFONTW* LPENUMLOGFONTW;
+
+struct ENUMLOGFONTEXA {
+    LOGFONTA elfLogFont;
+    BYTE[LF_FULLFACESIZE] elfFullName;
+    BYTE[LF_FACESIZE] elfStyle;
+    BYTE[LF_FACESIZE] elfScript;
+}
+alias ENUMLOGFONTEXA* LPENUMLOGFONTEXA;
+
+struct ENUMLOGFONTEXW {
+    LOGFONTW elfLogFont;
+    WCHAR[LF_FULLFACESIZE] elfFullName;
+    WCHAR[LF_FACESIZE] elfStyle;
+    WCHAR[LF_FACESIZE] elfScript;
+}
+alias ENUMLOGFONTEXW* LPENUMLOGFONTEXW;
+
+struct POINTFX {
+    FIXED x;
+    FIXED y;
+}
+alias POINTFX* LPPOINTFX;
+
+struct TTPOLYCURVE {
+    WORD wType;
+    WORD cpfx;
+    POINTFX[1] apfx;
+}
+alias TTPOLYCURVE* LPTTPOLYCURVE;
+
+struct TTPOLYGONHEADER {
+    DWORD cb;
+    DWORD dwType;
+    POINTFX pfxStart;
+}
+alias TTPOLYGONHEADER* LPTTPOLYGONHEADER;
+
+struct POINTFLOAT {
+    FLOAT x;
+    FLOAT y;
+}
+alias POINTFLOAT* PPOINTFLOAT;
+
+struct GLYPHMETRICSFLOAT {
+    FLOAT gmfBlackBoxX;
+    FLOAT gmfBlackBoxY;
+    POINTFLOAT gmfptGlyphOrigin;
+    FLOAT gmfCellIncX;
+    FLOAT gmfCellIncY;
+}
+alias GLYPHMETRICSFLOAT* PGLYPHMETRICSFLOAT, LPGLYPHMETRICSFLOAT;
+
+struct LAYERPLANEDESCRIPTOR {
+    WORD nSize;
+    WORD nVersion;
+    DWORD dwFlags;
+    BYTE iPixelType;
+    BYTE cColorBits;
+    BYTE cRedBits;
+    BYTE cRedShift;
+    BYTE cGreenBits;
+    BYTE cGreenShift;
+    BYTE cBlueBits;
+    BYTE cBlueShift;
+    BYTE cAlphaBits;
+    BYTE cAlphaShift;
+    BYTE cAccumBits;
+    BYTE cAccumRedBits;
+    BYTE cAccumGreenBits;
+    BYTE cAccumBlueBits;
+    BYTE cAccumAlphaBits;
+    BYTE cDepthBits;
+    BYTE cStencilBits;
+    BYTE cAuxBuffers;
+    BYTE iLayerPlane;
+    BYTE bReserved;
+    COLORREF crTransparent;
+}
+alias LAYERPLANEDESCRIPTOR* PLAYERPLANEDESCRIPTOR, LPLAYERPLANEDESCRIPTOR;
+
+struct BLENDFUNCTION {
+    BYTE BlendOp;
+    BYTE BlendFlags;
+    BYTE SourceConstantAlpha;
+    BYTE AlphaFormat;
+}
+alias BLENDFUNCTION* PBLENDFUNCTION, LPBLENDFUNCTION;
+
+enum MM_MAX_NUMAXES = 16;
+
+struct DESIGNVECTOR {
+    DWORD dvReserved;
+    DWORD dvNumAxes;
+    LONG[MM_MAX_NUMAXES] dvValues;
+}
+alias DESIGNVECTOR* PDESIGNVECTOR, LPDESIGNVECTOR;
+enum STAMP_DESIGNVECTOR = 0x8000000 + 'd' + ('v' << 8);
+enum STAMP_AXESLIST     = 0x8000000 + 'a' + ('l' << 8);
+
+static if (_WIN32_WINNT >= 0x500) {
+
+enum MM_MAX_AXES_NAMELEN = 16;
+
+    struct AXISINFOA {
+        LONG axMinValue;
+        LONG axMaxValue;
+        BYTE[MM_MAX_AXES_NAMELEN] axAxisName;
+    }
+    alias AXISINFOA* PAXISINFOA, LPAXISINFOA;
+
+    struct AXISINFOW {
+        LONG axMinValue;
+        LONG axMaxValue;
+        WCHAR[MM_MAX_AXES_NAMELEN] axAxisName;
+    }
+    alias AXISINFOW* PAXISINFOW, LPAXISINFOW;
+
+    version (Unicode) {
+        alias AXISINFOW AXISINFO;
+        alias PAXISINFOW PAXISINFO;
+        alias LPAXISINFOW LPAXISINFO;
+    }
+    else {
+        alias AXISINFOA AXISINFO;
+        alias PAXISINFOA PAXISINFO;
+        alias LPAXISINFOA LPAXISINFO;
+    }
+
+    struct AXESLISTA {
+        DWORD axlReserved;
+        DWORD axlNumAxes;
+        AXISINFOA[MM_MAX_NUMAXES] axlAxisInfo;
+    }
+    alias AXESLISTA* PAXESLISTA, LPAXESLISTA;
+
+    struct AXESLISTW {
+        DWORD axlReserved;
+        DWORD axlNumAxes;
+        AXISINFOW[MM_MAX_NUMAXES] axlAxisInfo;
+    }
+    alias AXESLISTW* PAXESLISTW, LPAXESLISTW;
+
+    version (Unicode) {
+        alias AXESLISTW AXESLIST;
+        alias PAXESLISTW PAXESLIST;
+        alias LPAXESLISTW LPAXESLIST;
+    }
+    else {
+        alias AXESLISTA AXESLIST;
+        alias PAXESLISTA PAXESLIST;
+        alias LPAXESLISTA LPAXESLIST;
+    }
+
+    struct ENUMLOGFONTEXDVA {
+        ENUMLOGFONTEXA elfEnumLogfontEx;
+        DESIGNVECTOR   elfDesignVector;
+    }
+    alias ENUMLOGFONTEXDVA* PENUMLOGFONTEXDVA, LPENUMLOGFONTEXDVA;
+
+    struct ENUMLOGFONTEXDVW {
+        ENUMLOGFONTEXW elfEnumLogfontEx;
+        DESIGNVECTOR   elfDesignVector;
+    }
+    alias ENUMLOGFONTEXDVW* PENUMLOGFONTEXDVW, LPENUMLOGFONTEXDVW;
+
+    HFONT CreateFontIndirectExA(const(ENUMLOGFONTEXDVA)*);
+    HFONT CreateFontIndirectExW(const(ENUMLOGFONTEXDVW)*);
+    version (Unicode)
+        alias CreateFontIndirectExW CreateFontIndirectEx;
+    else
+        alias CreateFontIndirectExA CreateFontIndirectEx;
+
+    struct ENUMTEXTMETRICA {
+        NEWTEXTMETRICEXA etmNewTextMetricEx;
+        AXESLISTA etmAxesList;
+    }
+    alias ENUMTEXTMETRICA* PENUMTEXTMETRICA, LPENUMTEXTMETRICA;
+
+    struct ENUMTEXTMETRICW {
+        NEWTEXTMETRICEXW etmNewTextMetricEx;
+        AXESLISTW etmAxesList;
+    }
+    alias ENUMTEXTMETRICW* PENUMTEXTMETRICW, LPENUMTEXTMETRICW;
+
+    version (Unicode) {
+        alias ENUMTEXTMETRICW ENUMTEXTMETRIC;
+        alias PENUMTEXTMETRICW PENUMTEXTMETRIC;
+        alias LPENUMTEXTMETRICW LPENUMTEXTMETRIC;
+    }
+    else {
+        alias ENUMTEXTMETRICA ENUMTEXTMETRIC;
+        alias PENUMTEXTMETRICA PENUMTEXTMETRIC;
+        alias LPENUMTEXTMETRICA LPENUMTEXTMETRIC;
+    }
+} /* _WIN32_WINNT >= 0x500 */
+
+struct GRADIENT_TRIANGLE {
+    ULONG Vertex1;
+    ULONG Vertex2;
+    ULONG Vertex3;
+}
+alias GRADIENT_TRIANGLE* PGRADIENT_TRIANGLE, LPGRADIENT_TRIANGLE;
+
+struct GRADIENT_RECT {
+    ULONG UpperLeft;
+    ULONG LowerRight;
+}
+alias GRADIENT_RECT* PGRADIENT_RECT, LPGRADIENT_RECT;
+
+struct DISPLAY_DEVICEA {
+    DWORD cb;
+    CHAR[32] DeviceName;
+    CHAR[128] DeviceString;
+    DWORD StateFlags;
+    CHAR[128] DeviceID;
+    CHAR[128] DeviceKey;
+}
+alias DISPLAY_DEVICEA* PDISPLAY_DEVICEA, LPDISPLAY_DEVICEA;
+
+struct DISPLAY_DEVICEW {
+    DWORD cb;
+    WCHAR[32] DeviceName;
+    WCHAR[128] DeviceString;
+    DWORD StateFlags;
+    WCHAR[128] DeviceID;
+    WCHAR[128] DeviceKey;
+}
+alias DISPLAY_DEVICEW* PDISPLAY_DEVICEW, LPDISPLAY_DEVICEW;
+
+struct DRAWPATRECT {
+    POINT ptPosition;
+    POINT ptSize;
+    WORD wStyle;
+    WORD wPattern;
+}
+alias DRAWPATRECT* PDRAWPATRECT;
+
+// ---------
+// Callbacks
+
+alias BOOL function (HDC, int) ABORTPROC;
+alias int function (HDC, HANDLETABLE*, METARECORD*, int, LPARAM) MFENUMPROC;
+alias int function (HDC, HANDLETABLE*, const(ENHMETARECORD)*, int, LPARAM) ENHMFENUMPROC;
+alias int function (const(LOGFONTA)*, const(TEXTMETRICA)*, DWORD, LPARAM) FONTENUMPROCA, OLDFONTENUMPROCA;
+alias int function (const(LOGFONTW)*, const(TEXTMETRICW)*, DWORD, LPARAM) FONTENUMPROCW, OLDFONTENUMPROCW;
+alias int function (LPSTR, LPARAM) ICMENUMPROCA;
+alias int function (LPWSTR, LPARAM) ICMENUMPROCW;
+alias void function (LPVOID, LPARAM) GOBJENUMPROC;
+alias void function (int, int, LPARAM) LINEDDAPROC;
+alias UINT function (HWND, HMODULE, LPDEVMODEA, LPSTR, LPSTR, LPDEVMODEA, LPSTR, UINT) LPFNDEVMODE;
+alias DWORD function (LPSTR, LPSTR, UINT, LPSTR, LPDEVMODEA) LPFNDEVCAPS;
+
+
+// ---------
+// C Macros.
+// FIXME:
+//POINTS MAKEPOINTS(DWORD dwValue) #define MAKEPOINTS(l) (*((POINTS*)&(l)))
+
+nothrow @nogc {
+    DWORD MAKEROP4(DWORD fore, DWORD back) {
+        return ((back<<8) & 0xFF000000) | (fore);
+    }
+
+    COLORREF CMYK(BYTE c, BYTE m, BYTE y, BYTE k) {
+        return cast(COLORREF)(k | (y << 8) | (m << 16) | (c << 24));
+    }
+
+    BYTE GetCValue(COLORREF cmyk) {
+        return cast(BYTE)(cmyk >> 24);
+    }
+
+    BYTE GetMValue(COLORREF cmyk) {
+        return cast(BYTE)(cmyk >> 16);
+    }
+
+    BYTE GetYValue(COLORREF cmyk) {
+        return cast(BYTE)(cmyk >> 8);
+    }
+
+    BYTE GetKValue(COLORREF cmyk) {
+        return cast(BYTE)cmyk;
+    }
+
+    COLORREF RGB(/*BYTE*/uint r, /*BYTE*/uint g, /*BYTE*/uint b) {
+        return cast(COLORREF)(r | (g << 8) | (b << 16));
+    }
+
+    BYTE GetRValue(COLORREF c) {
+        return cast(BYTE)c;
+    }
+
+    BYTE GetGValue(COLORREF c) {
+        return cast(BYTE)(c >> 8);
+    }
+
+    BYTE GetBValue(COLORREF c) {
+        return cast(BYTE)(c >> 16);
+    }
+
+    COLORREF PALETTEINDEX(WORD i) {
+        return 0x01000000 | cast(COLORREF) i;
+    }
+
+    COLORREF PALETTERGB(BYTE r, BYTE g, BYTE b) {
+        return 0x02000000|RGB(r, g, b);
+    }
+}
+
+extern(Windows) nothrow @nogc {
+    int AbortDoc(HDC);
+    BOOL AbortPath(HDC);
+    int AddFontResourceA(LPCSTR);
+    int AddFontResourceW(LPCWSTR);
+    BOOL AngleArc(HDC, int, int, DWORD, FLOAT, FLOAT);
+    BOOL AnimatePalette(HPALETTE, UINT, UINT, const(PALETTEENTRY)*);
+    BOOL Arc(HDC, int, int, int, int, int, int, int, int);
+    BOOL ArcTo(HDC, int, int, int, int, int, int, int, int);
+    BOOL BeginPath(HDC);
+    BOOL BitBlt(HDC, int, int, int, int, HDC, int, int, DWORD);
+    BOOL CancelDC(HDC);
+    BOOL CheckColorsInGamut(HDC, PVOID, PVOID, DWORD);
+    BOOL Chord(HDC, int, int, int, int, int, int, int, int);
+    int ChoosePixelFormat(HDC, const(PIXELFORMATDESCRIPTOR)*);
+    HENHMETAFILE CloseEnhMetaFile(HDC);
+    BOOL CloseFigure(HDC);
+    HMETAFILE CloseMetaFile(HDC);
+    BOOL ColorMatchToTarget(HDC, HDC, DWORD);
+    BOOL ColorCorrectPalette(HDC, HPALETTE, DWORD, DWORD);
+    int CombineRgn(HRGN, HRGN, HRGN, int);
+    BOOL CombineTransform(LPXFORM, const(XFORM)*, const(XFORM)*);
+    HENHMETAFILE CopyEnhMetaFileA(HENHMETAFILE, LPCSTR);
+    HENHMETAFILE CopyEnhMetaFileW(HENHMETAFILE, LPCWSTR);
+    HMETAFILE CopyMetaFileA(HMETAFILE, LPCSTR);
+    HMETAFILE CopyMetaFileW(HMETAFILE, LPCWSTR);
+    HBITMAP CreateBitmap(int, int, UINT, UINT, PCVOID);
+    HBITMAP CreateBitmapIndirect(const(BITMAP)*);
+    HBRUSH CreateBrushIndirect(const(LOGBRUSH)*);
+    HCOLORSPACE CreateColorSpaceA(LPLOGCOLORSPACEA);
+    HCOLORSPACE CreateColorSpaceW(LPLOGCOLORSPACEW);
+    HBITMAP CreateCompatibleBitmap(HDC, int, int);
+    HDC CreateCompatibleDC(HDC);
+    HDC CreateDCA(LPCSTR, LPCSTR, LPCSTR, const(DEVMODEA)*);
+    HDC CreateDCW(LPCWSTR, LPCWSTR, LPCWSTR, const(DEVMODEW)*);
+    HBITMAP CreateDIBitmap(HDC, const(BITMAPINFOHEADER)*, DWORD, PCVOID, const(BITMAPINFO)*, UINT);
+    HBRUSH CreateDIBPatternBrush(HGLOBAL, UINT);
+    HBRUSH CreateDIBPatternBrushPt(PCVOID, UINT);
+    HBITMAP CreateDIBSection(HDC, const(BITMAPINFO)*, UINT, void**, HANDLE, DWORD);
+    HBITMAP CreateDiscardableBitmap(HDC, int, int);
+    HRGN CreateEllipticRgn(int, int, int, int);
+    HRGN CreateEllipticRgnIndirect(LPCRECT);
+    HDC CreateEnhMetaFileA(HDC, LPCSTR, LPCRECT, LPCSTR);
+    HDC CreateEnhMetaFileW(HDC, LPCWSTR, LPCRECT, LPCWSTR);
+    HFONT CreateFontA(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCSTR);
+    HFONT CreateFontW(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCWSTR);
+    HFONT CreateFontIndirectA(const(LOGFONTA)*);
+    HFONT CreateFontIndirectW(const(LOGFONTW)*);
+    HPALETTE CreateHalftonePalette(HDC);
+    HBRUSH CreateHatchBrush(int, COLORREF);
+    HDC CreateICA(LPCSTR, LPCSTR, LPCSTR, const(DEVMODEA)*);
+    HDC CreateICW(LPCWSTR, LPCWSTR, LPCWSTR, const(DEVMODEW)*);
+    HDC CreateMetaFileA(LPCSTR);
+    HDC CreateMetaFileW(LPCWSTR);
+    HPALETTE CreatePalette(const(LOGPALETTE)*);
+    HBRUSH CreatePatternBrush(HBITMAP);
+    HPEN CreatePen(int, int, COLORREF);
+    HPEN CreatePenIndirect(const(LOGPEN)*);
+    HRGN CreatePolygonRgn(const(POINT)*, int, int);
+    HRGN CreatePolyPolygonRgn(const(POINT)*, const(INT)*, int, int);
+    HRGN CreateRectRgn(int, int, int, int);
+    HRGN CreateRectRgnIndirect(LPCRECT);
+    HRGN CreateRoundRectRgn(int, int, int, int, int, int);
+    BOOL CreateScalableFontResourceA(DWORD, LPCSTR, LPCSTR, LPCSTR);
+    BOOL CreateScalableFontResourceW(DWORD, LPCWSTR, LPCWSTR, LPCWSTR);
+    HBRUSH CreateSolidBrush(COLORREF);
+    BOOL DeleteColorSpace(HCOLORSPACE);
+    BOOL DeleteDC(HDC);
+    BOOL DeleteEnhMetaFile(HENHMETAFILE);
+    BOOL DeleteMetaFile(HMETAFILE);
+    BOOL DeleteObject(HGDIOBJ);
+    int DescribePixelFormat(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
+    DWORD DeviceCapabilitiesA(LPCSTR, LPCSTR, WORD, LPSTR, const(DEVMODEA)*);
+    DWORD DeviceCapabilitiesW(LPCWSTR, LPCWSTR, WORD, LPWSTR, const(DEVMODEW)*);
+    BOOL DPtoLP(HDC, LPPOINT, int);
+    int DrawEscape(HDC, int, int, LPCSTR);
+    BOOL Ellipse(HDC, int, int, int, int);
+    int EndDoc(HDC);
+    int EndPage(HDC);
+    BOOL EndPath(HDC);
+    BOOL EnumEnhMetaFile(HDC, HENHMETAFILE, ENHMFENUMPROC, PVOID, LPCRECT);
+    int EnumFontFamiliesA(HDC, LPCSTR, FONTENUMPROCA, LPARAM);
+    int EnumFontFamiliesW(HDC, LPCWSTR, FONTENUMPROCW, LPARAM);
+    int EnumFontFamiliesExA(HDC, PLOGFONTA, FONTENUMPROCA, LPARAM, DWORD);
+    int EnumFontFamiliesExW(HDC, PLOGFONTW, FONTENUMPROCW, LPARAM, DWORD);
+    int EnumFontsA(HDC, LPCSTR, FONTENUMPROCA, LPARAM);
+    int EnumFontsW(HDC, LPCWSTR, FONTENUMPROCW, LPARAM);
+    int EnumICMProfilesA(HDC, ICMENUMPROCA, LPARAM);
+    int EnumICMProfilesW(HDC, ICMENUMPROCW, LPARAM);
+    BOOL EnumMetaFile(HDC, HMETAFILE, MFENUMPROC, LPARAM);
+    int EnumObjects(HDC, int, GOBJENUMPROC, LPARAM);
+    BOOL EqualRgn(HRGN, HRGN);
+    int Escape(HDC, int, int, LPCSTR, PVOID);
+    int ExcludeClipRect(HDC, int, int, int, int);
+    int ExcludeUpdateRgn(HDC, HWND);
+    HPEN ExtCreatePen(DWORD, DWORD, const(LOGBRUSH)*, DWORD, const(DWORD)*);
+    HRGN ExtCreateRegion(const(XFORM)*, DWORD, const(RGNDATA)*);
+    int ExtEscape(HDC, int, int, LPCSTR, int, LPSTR);
+    BOOL ExtFloodFill(HDC, int, int, COLORREF, UINT);
+    int ExtSelectClipRgn(HDC, HRGN, int);
+    BOOL ExtTextOutA(HDC, int, int, UINT, LPCRECT, LPCSTR, UINT, const(INT)*);
+    BOOL ExtTextOutW(HDC, int, int, UINT, LPCRECT, LPCWSTR, UINT, const(INT)*);
+    BOOL FillPath(HDC);
+    int FillRect(HDC, LPCRECT, HBRUSH);
+    int FillRgn(HDC, HRGN, HBRUSH);
+    BOOL FixBrushOrgEx(HDC, int, int, LPPOINT);
+    BOOL FlattenPath(HDC);
+    BOOL FloodFill(HDC, int, int, COLORREF);
+    BOOL FrameRgn(HDC, HRGN, HBRUSH, int, int);
+    BOOL GdiComment(HDC, UINT, const(BYTE)*);
+    BOOL GdiFlush();
+    DWORD GdiGetBatchLimit();
+    DWORD GdiSetBatchLimit(DWORD);
+    int GetArcDirection(HDC);
+    BOOL GetAspectRatioFilterEx(HDC, LPSIZE);
+    LONG GetBitmapBits(HBITMAP, LONG, PVOID);
+    BOOL GetBitmapDimensionEx(HBITMAP, LPSIZE);
+    COLORREF GetBkColor(HDC);
+    int GetBkMode(HDC);
+    UINT GetBoundsRect(HDC, LPRECT, UINT);
+    BOOL GetBrushOrgEx(HDC, LPPOINT);
+    BOOL GetCharABCWidthsA(HDC, UINT, UINT, LPABC);
+    BOOL GetCharABCWidthsW(HDC, UINT, UINT, LPABC);
+    BOOL GetCharABCWidthsFloatA(HDC, UINT, UINT, LPABCFLOAT);
+    BOOL GetCharABCWidthsFloatW(HDC, UINT, UINT, LPABCFLOAT);
+    DWORD GetCharacterPlacementA(HDC, LPCSTR, int, int, LPGCP_RESULTSA, DWORD);
+    DWORD GetCharacterPlacementW(HDC, LPCWSTR, int, int, LPGCP_RESULTSW, DWORD);
+    BOOL GetCharWidth32A(HDC, UINT, UINT, LPINT);
+    BOOL GetCharWidth32W(HDC, UINT, UINT, LPINT);
+    BOOL GetCharWidthA(HDC, UINT, UINT, LPINT);
+    BOOL GetCharWidthW(HDC, UINT, UINT, LPINT);
+    BOOL GetCharWidthFloatA(HDC, UINT, UINT, PFLOAT);
+    BOOL GetCharWidthFloatW(HDC, UINT, UINT, PFLOAT);
+    int GetClipBox(HDC, LPRECT);
+    int GetClipRgn(HDC, HRGN);
+    BOOL GetColorAdjustment(HDC, LPCOLORADJUSTMENT);
+    HANDLE GetColorSpace(HDC);
+    HGDIOBJ GetCurrentObject(HDC, UINT);
+    BOOL GetCurrentPositionEx(HDC, LPPOINT);
+    HCURSOR GetCursor();
+    BOOL GetDCOrgEx(HDC, LPPOINT);
+    static if (_WIN32_WINNT >= 0x500)
+    {
+        DWORD GetDCPenColor(HGDIOBJ);
+        COLORREF GetDCBrushColor(HGDIOBJ);
+    }
+    int GetDeviceCaps(HDC, int);
+    BOOL GetDeviceGammaRamp(HDC, PVOID);
+    UINT GetDIBColorTable(HDC, UINT, UINT, RGBQUAD*);
+    int GetDIBits(HDC, HBITMAP, UINT, UINT, PVOID, LPBITMAPINFO, UINT);
+    HENHMETAFILE GetEnhMetaFileA(LPCSTR);
+    HENHMETAFILE GetEnhMetaFileW(LPCWSTR);
+    UINT GetEnhMetaFileBits(HENHMETAFILE, UINT, LPBYTE);
+    UINT GetEnhMetaFileDescriptionA(HENHMETAFILE, UINT, LPSTR);
+    UINT GetEnhMetaFileDescriptionW(HENHMETAFILE, UINT, LPWSTR);
+    UINT GetEnhMetaFileHeader(HENHMETAFILE, UINT, LPENHMETAHEADER);
+    UINT GetEnhMetaFilePaletteEntries(HENHMETAFILE, UINT, LPPALETTEENTRY);
+    UINT GetEnhMetaFilePixelFormat(HENHMETAFILE, DWORD, const(PIXELFORMATDESCRIPTOR)*);
+    DWORD GetFontData(HDC, DWORD, DWORD, PVOID, DWORD);
+    DWORD GetFontLanguageInfo(HDC);
+    DWORD GetGlyphOutlineA(HDC, UINT, UINT, LPGLYPHMETRICS, DWORD, PVOID, const(MAT2)*);
+    DWORD GetGlyphOutlineW(HDC, UINT, UINT, LPGLYPHMETRICS, DWORD, PVOID, const(MAT2)*);
+    int GetGraphicsMode(HDC);
+    BOOL GetICMProfileA(HDC, DWORD, LPSTR);
+    BOOL GetICMProfileW(HDC, DWORD, LPWSTR);
+    DWORD GetKerningPairsA(HDC, DWORD, LPKERNINGPAIR);
+    DWORD GetKerningPairsW(HDC, DWORD, LPKERNINGPAIR);
+    BOOL GetLogColorSpaceA(HCOLORSPACE, LPLOGCOLORSPACEA, DWORD);
+    BOOL GetLogColorSpaceW(HCOLORSPACE, LPLOGCOLORSPACEW, DWORD);
+    int GetMapMode(HDC);
+    HMETAFILE GetMetaFileA(LPCSTR);
+    HMETAFILE GetMetaFileW(LPCWSTR);
+    UINT GetMetaFileBitsEx(HMETAFILE, UINT, PVOID);
+    int GetMetaRgn(HDC, HRGN);
+    BOOL GetMiterLimit(HDC, PFLOAT);
+    COLORREF GetNearestColor(HDC, COLORREF);
+    UINT GetNearestPaletteIndex(HPALETTE, COLORREF);
+    int GetObjectA(HGDIOBJ, int, PVOID);
+    int GetObjectW(HGDIOBJ, int, PVOID);
+    DWORD GetObjectType(HGDIOBJ);
+    UINT GetOutlineTextMetricsA(HDC, UINT, LPOUTLINETEXTMETRICA);
+    UINT GetOutlineTextMetricsW(HDC, UINT, LPOUTLINETEXTMETRICW);
+    UINT GetPaletteEntries(HPALETTE, UINT, UINT, LPPALETTEENTRY);
+    int GetPath(HDC, LPPOINT, PBYTE, int);
+    COLORREF GetPixel(HDC, int, int);
+    int GetPixelFormat(HDC);
+    int GetPolyFillMode(HDC);
+    BOOL GetRasterizerCaps(LPRASTERIZER_STATUS, UINT);
+    int GetRandomRgn (HDC, HRGN, INT);
+    DWORD GetRegionData(HRGN, DWORD, LPRGNDATA);
+    int GetRgnBox(HRGN, LPRECT);
+    int GetROP2(HDC);
+    HGDIOBJ GetStockObject(int);
+    int GetStretchBltMode(HDC);
+    UINT GetSystemPaletteEntries(HDC, UINT, UINT, LPPALETTEENTRY);
+    UINT GetSystemPaletteUse(HDC);
+    UINT GetTextAlign(HDC);
+    int GetTextCharacterExtra(HDC);
+    int GetTextCharset(HDC);
+    int GetTextCharsetInfo(HDC, LPFONTSIGNATURE, DWORD);
+    COLORREF GetTextColor(HDC);
+    BOOL GetTextExtentExPointA(HDC, LPCSTR, int, int, LPINT, LPINT, LPSIZE);
+    BOOL GetTextExtentExPointW(HDC, LPCWSTR, int, int, LPINT, LPINT, LPSIZE);
+    BOOL GetTextExtentPointA(HDC, LPCSTR, int, LPSIZE);
+    BOOL GetTextExtentPointW(HDC, LPCWSTR, int, LPSIZE);
+    BOOL GetTextExtentPoint32A(HDC, LPCSTR, int, LPSIZE);
+    BOOL GetTextExtentPoint32W(HDC, LPCWSTR, int, LPSIZE);
+    int GetTextFaceA(HDC, int, LPSTR);
+    int GetTextFaceW(HDC, int, LPWSTR);
+    BOOL GetTextMetricsA(HDC, LPTEXTMETRICA);
+    BOOL GetTextMetricsW(HDC, LPTEXTMETRICW);
+    BOOL GetViewportExtEx(HDC, LPSIZE);
+    BOOL GetViewportOrgEx(HDC, LPPOINT);
+    BOOL GetWindowExtEx(HDC, LPSIZE);
+    BOOL GetWindowOrgEx(HDC, LPPOINT);
+    UINT GetWinMetaFileBits(HENHMETAFILE, UINT, LPBYTE, INT, HDC);
+    BOOL GetWorldTransform(HDC, LPXFORM);
+    int IntersectClipRect(HDC, int, int, int, int);
+    BOOL InvertRgn(HDC, HRGN);
+    BOOL LineDDA(int, int, int, int, LINEDDAPROC, LPARAM);
+    BOOL LineTo(HDC, int, int);
+    BOOL LPtoDP(HDC, LPPOINT, int);
+    BOOL MaskBlt(HDC, int, int, int, int, HDC, int, int, HBITMAP, int, int, DWORD);
+    BOOL ModifyWorldTransform(HDC, const(XFORM)*, DWORD);
+    BOOL MoveToEx(HDC, int, int, LPPOINT);
+    int OffsetClipRgn(HDC, int, int);
+    int OffsetRgn(HRGN, int, int);
+    BOOL OffsetViewportOrgEx(HDC, int, int, LPPOINT);
+    BOOL OffsetWindowOrgEx(HDC, int, int, LPPOINT);
+    BOOL PaintRgn(HDC, HRGN);
+    BOOL PatBlt(HDC, int, int, int, int, DWORD);
+    HRGN PathToRegion(HDC);
+    BOOL Pie(HDC, int, int, int, int, int, int, int, int);
+    BOOL PlayEnhMetaFile(HDC, HENHMETAFILE, LPCRECT);
+    BOOL PlayEnhMetaFileRecord(HDC, LPHANDLETABLE, const(ENHMETARECORD)*, UINT);
+    BOOL PlayMetaFile(HDC, HMETAFILE);
+    BOOL PlayMetaFileRecord(HDC, LPHANDLETABLE, LPMETARECORD, UINT);
+    BOOL PlgBlt(HDC, const(POINT)*, HDC, int, int, int, int, HBITMAP, int, int);
+    BOOL PolyBezier(HDC, const(POINT)*, DWORD);
+    BOOL PolyBezierTo(HDC, const(POINT)*, DWORD);
+    BOOL PolyDraw(HDC, const(POINT)*, const(BYTE)*, int);
+    BOOL Polygon(HDC, const(POINT)*, int);
+    BOOL Polyline(HDC, const(POINT)*, int);
+    BOOL PolylineTo(HDC, const(POINT)*, DWORD);
+    BOOL PolyPolygon(HDC, const(POINT)*, const(INT)*, int);
+    BOOL PolyPolyline(HDC, const(POINT)*, const(DWORD)*, DWORD);
+    BOOL PolyTextOutA(HDC, const(POLYTEXTA)*, int);
+    BOOL PolyTextOutW(HDC, const(POLYTEXTW)*, int);
+    BOOL PtInRegion(HRGN, int, int);
+    BOOL PtVisible(HDC, int, int);
+    UINT RealizePalette(HDC);
+    BOOL Rectangle(HDC, int, int, int, int);
+    BOOL RectInRegion(HRGN, LPCRECT);
+    BOOL RectVisible(HDC, LPCRECT);
+    BOOL RemoveFontResourceA(LPCSTR);
+    BOOL RemoveFontResourceW(LPCWSTR);
+
+    HDC ResetDCA(HDC, const(DEVMODEA)*);
+    HDC ResetDCW(HDC, const(DEVMODEW)*);
+    BOOL ResizePalette(HPALETTE, UINT);
+    BOOL RestoreDC(HDC, int);
+    BOOL RoundRect(HDC, int, int, int, int, int, int);
+    int SaveDC(HDC);
+    BOOL ScaleViewportExtEx(HDC, int, int, int, int, LPSIZE);
+    BOOL ScaleWindowExtEx(HDC, int, int, int, int, LPSIZE);
+    BOOL SelectClipPath(HDC, int);
+    int SelectClipRgn(HDC, HRGN);
+    HGDIOBJ SelectObject(HDC, HGDIOBJ);
+    HPALETTE SelectPalette(HDC, HPALETTE, BOOL);
+    int SetAbortProc(HDC, ABORTPROC);
+    int SetArcDirection(HDC, int);
+    LONG SetBitmapBits(HBITMAP, DWORD, PCVOID);
+    BOOL SetBitmapDimensionEx(HBITMAP, int, int, LPSIZE);
+    COLORREF SetBkColor(HDC, COLORREF);
+    int SetBkMode(HDC, int);
+    UINT SetBoundsRect(HDC, LPCRECT, UINT);
+    BOOL SetBrushOrgEx(HDC, int, int, LPPOINT);
+    BOOL SetColorAdjustment(HDC, const(COLORADJUSTMENT)*);
+    BOOL SetColorSpace(HDC, HCOLORSPACE);
+
+    BOOL SetDeviceGammaRamp(HDC, PVOID);
+    UINT SetDIBColorTable(HDC, UINT, UINT, const(RGBQUAD)*);
+    int SetDIBits(HDC, HBITMAP, UINT, UINT, PCVOID, const(BITMAPINFO)*, UINT);
+    int SetDIBitsToDevice(HDC, int, int, DWORD, DWORD, int, int, UINT, UINT, PCVOID, const(BITMAPINFO)*, UINT);
+    HENHMETAFILE SetEnhMetaFileBits(UINT, const(BYTE)*);
+    int SetGraphicsMode(HDC, int);
+    int SetICMMode(HDC, int);
+    BOOL SetICMProfileA(HDC, LPSTR);
+    BOOL SetICMProfileW(HDC, LPWSTR);
+    int SetMapMode(HDC, int);
+
+    static if (_WIN32_WINNT >= 0x500) {
+        DWORD SetLayout(HDC hdc, DWORD l);
+        DWORD GetLayout(HDC hdc);
+    }
+
+    DWORD SetMapperFlags(HDC, DWORD);
+    HMETAFILE SetMetaFileBitsEx(UINT, const(BYTE)*);
+    int SetMetaRgn(HDC);
+    BOOL SetMiterLimit(HDC, FLOAT, PFLOAT);
+    UINT SetPaletteEntries(HPALETTE, UINT, UINT, const(PALETTEENTRY)*);
+    COLORREF SetPixel(HDC, int, int, COLORREF);
+    BOOL SetPixelFormat(HDC, int, const(PIXELFORMATDESCRIPTOR)*);
+    BOOL SetPixelV(HDC, int, int, COLORREF);
+    int SetPolyFillMode(HDC, int);
+    BOOL SetRectRgn(HRGN, int, int, int, int);
+    int SetROP2(HDC, int);
+    int SetStretchBltMode(HDC, int);
+    UINT SetSystemPaletteUse(HDC, UINT);
+    UINT SetTextAlign(HDC, UINT);
+    int SetTextCharacterExtra(HDC, int);
+    COLORREF SetTextColor(HDC, COLORREF);
+    BOOL SetTextJustification(HDC, int, int);
+    BOOL SetViewportExtEx(HDC, int, int, LPSIZE);
+    BOOL SetViewportOrgEx(HDC, int, int, LPPOINT);
+    BOOL SetWindowExtEx(HDC, int, int, LPSIZE);
+    BOOL SetWindowOrgEx(HDC, int, int, LPPOINT);
+    HENHMETAFILE SetWinMetaFileBits(UINT, const(BYTE)*, HDC, const(METAFILEPICT)*);
+    BOOL SetWorldTransform(HDC, const(XFORM)*);
+    int StartDocA(HDC, const(DOCINFOA)*);
+    int StartDocW(HDC, const(DOCINFOW)*);
+    int StartPage(HDC);
+    BOOL StretchBlt(HDC, int, int, int, int, HDC, int, int, int, int, DWORD);
+    int StretchDIBits(HDC, int, int, int, int, int, int, int, int, const(VOID)* , const(BITMAPINFO)* , UINT, DWORD);
+    BOOL StrokeAndFillPath(HDC);
+    BOOL StrokePath(HDC);
+    BOOL SwapBuffers(HDC);
+    BOOL TextOutA(HDC, int, int, LPCSTR, int);
+    BOOL TextOutW(HDC, int, int, LPCWSTR, int);
+    BOOL TranslateCharsetInfo(PDWORD, LPCHARSETINFO, DWORD);
+    BOOL UnrealizeObject(HGDIOBJ);
+    BOOL UpdateColors(HDC);
+    BOOL UpdateICMRegKeyA(DWORD, DWORD, LPSTR, UINT);
+    BOOL UpdateICMRegKeyW(DWORD, DWORD, LPWSTR, UINT);
+    BOOL WidenPath(HDC);
+    BOOL wglCopyContext(HGLRC, HGLRC, UINT);
+    HGLRC wglCreateContext(HDC);
+    HGLRC wglCreateLayerContext(HDC, int);
+    BOOL wglDeleteContext(HGLRC);
+    BOOL wglDescribeLayerPlane(HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR);
+    HGLRC wglGetCurrentContext();
+    HDC wglGetCurrentDC();
+    int wglGetLayerPaletteEntries(HDC, int, int, int, COLORREF*);
+    PROC wglGetProcAddress(LPCSTR);
+    BOOL wglMakeCurrent(HDC, HGLRC);
+    BOOL wglRealizeLayerPalette(HDC, int, BOOL);
+    int wglSetLayerPaletteEntries(HDC, int, int, int, const(COLORREF)*);
+    BOOL wglShareLists(HGLRC, HGLRC);
+    BOOL wglSwapLayerBuffers(HDC, UINT);
+    BOOL wglUseFontBitmapsA(HDC, DWORD, DWORD, DWORD);
+    BOOL wglUseFontBitmapsW(HDC, DWORD, DWORD, DWORD);
+    BOOL wglUseFontOutlinesA(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT);
+    BOOL wglUseFontOutlinesW(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT);
+
+    static if (_WIN32_WINNT >= 0x500) {
+    alias WGLSWAP* PWGLSWAP;
+    struct WGLSWAP {
+        HDC hdc;
+        UINT uiFlags;
+    }
+enum WGL_SWAPMULTIPLE_MAX = 16;
+    DWORD  wglSwapMultipleBuffers(UINT, WGLSWAP*);
+}
+
+static if (_WIN32_WINNT >= 0x500) {
+        BOOL AlphaBlend(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION);
+        BOOL GradientFill(HDC, PTRIVERTEX, ULONG, PVOID, ULONG, ULONG);
+        BOOL TransparentBlt(HDC, int, int, int, int, HDC, int, int, int, int, UINT);
+    }
+
+    static if (_WIN32_WINNT >= 0x500) {
+        COLORREF SetDCBrushColor(HDC, COLORREF);
+        COLORREF SetDCPenColor(HDC, COLORREF);
+        HANDLE AddFontMemResourceEx(PVOID, DWORD, PVOID, DWORD*);
+        int AddFontResourceExA(LPCSTR, DWORD, PVOID);
+        int AddFontResourceExW(LPCWSTR, DWORD, PVOID);
+        BOOL RemoveFontMemResourceEx(HANDLE);
+        BOOL RemoveFontResourceExA(LPCSTR, DWORD, PVOID);
+        BOOL RemoveFontResourceExW(LPCWSTR, DWORD, PVOID);
+        DWORD GetFontUnicodeRanges(HDC, LPGLYPHSET);
+        DWORD GetGlyphIndicesA(HDC, LPCSTR, int, LPWORD, DWORD);
+        DWORD GetGlyphIndicesW(HDC, LPCWSTR, int, LPWORD, DWORD);
+        BOOL GetTextExtentPointI(HDC, LPWORD, int, LPSIZE);
+        BOOL GetTextExtentExPointI(HDC, LPWORD, int, int, LPINT, LPINT, LPSIZE);
+        BOOL GetCharWidthI(HDC, UINT, UINT, LPWORD, LPINT);
+        BOOL GetCharABCWidthsI(HDC, UINT, UINT, LPWORD, LPABC);
+    }
+} // extern (Windows)
+
+version(Unicode) {
+    alias WCHAR BCHAR;
+    alias DOCINFOW DOCINFO;
+    alias LOGFONTW LOGFONT;
+
+    alias TEXTMETRICW TEXTMETRIC;
+    alias NPTEXTMETRICW NPTEXTMETRIC;
+    alias ICMENUMPROCW ICMENUMPROC;
+    alias FONTENUMPROCW FONTENUMPROC;
+    alias DEVMODEW DEVMODE;
+
+    alias EXTLOGFONTW EXTLOGFONT;
+    alias GCP_RESULTSW GCP_RESULTS;
+    alias OUTLINETEXTMETRICW OUTLINETEXTMETRIC;
+    alias POLYTEXTW POLYTEXT;
+    alias LOGCOLORSPACEW LOGCOLORSPACE;
+    alias NEWTEXTMETRICW NEWTEXTMETRIC;
+    alias NEWTEXTMETRICEXW NEWTEXTMETRICEX;
+    alias ENUMLOGFONTW ENUMLOGFONT;
+    alias ENUMLOGFONTEXW ENUMLOGFONTEX;
+    alias DISPLAY_DEVICEW DISPLAY_DEVICE;
+    alias AddFontResourceW AddFontResource;
+
+    alias CopyEnhMetaFileW CopyEnhMetaFile;
+    alias CopyMetaFileW CopyMetaFile;
+    alias CreateColorSpaceW CreateColorSpace;
+    alias CreateDCW CreateDC;
+    alias CreateEnhMetaFileW CreateEnhMetaFile;
+    alias CreateFontW CreateFont;
+    alias CreateFontIndirectW CreateFontIndirect;
+    alias CreateICW CreateIC;
+    alias CreateMetaFileW CreateMetaFile;
+    alias CreateScalableFontResourceW CreateScalableFontResource;
+    alias DeviceCapabilitiesW DeviceCapabilities;
+    alias EnumFontFamiliesW EnumFontFamilies;
+    alias EnumFontFamiliesExW EnumFontFamiliesEx;
+    alias EnumFontsW EnumFonts;
+    alias EnumICMProfilesW EnumICMProfiles;
+    alias ExtTextOutW ExtTextOut;
+    alias GetCharABCWidthsFloatW GetCharABCWidthsFloat;
+    alias GetCharABCWidthsW GetCharABCWidths;
+    alias GetCharacterPlacementW GetCharacterPlacement;
+    alias GetCharWidth32W GetCharWidth32;
+    alias GetCharWidthFloatW GetCharWidthFloat;
+    alias GetCharWidthW GetCharWidth;
+    alias GetEnhMetaFileW GetEnhMetaFile;
+    alias GetEnhMetaFileDescriptionW GetEnhMetaFileDescription;
+    alias GetGlyphOutlineW GetGlyphOutline;
+    alias GetICMProfileW GetICMProfile;
+    alias GetKerningPairsW GetKerningPairs;
+    alias GetLogColorSpaceW GetLogColorSpace;
+    alias GetMetaFileW GetMetaFile;
+    alias GetObjectW GetObject;
+    alias GetOutlineTextMetricsW GetOutlineTextMetrics;
+    alias GetTextExtentPointW GetTextExtentPoint;
+    alias GetTextExtentExPointW GetTextExtentExPoint;
+    alias GetTextExtentPoint32W GetTextExtentPoint32;
+    alias GetTextFaceW GetTextFace;
+    alias GetTextMetricsW GetTextMetrics;
+    alias PolyTextOutW PolyTextOut;
+    alias RemoveFontResourceW RemoveFontResource;
+
+    alias ResetDCW ResetDC;
+    alias SetICMProfileW SetICMProfile;
+    alias StartDocW StartDoc;
+    alias TextOutW TextOut;
+    alias UpdateICMRegKeyW UpdateICMRegKey;
+    alias wglUseFontBitmapsW wglUseFontBitmaps;
+    alias wglUseFontOutlinesW wglUseFontOutlines;
+    static if (_WIN32_WINNT >= 0x500) {
+        alias ENUMLOGFONTEXDVW ENUMLOGFONTEXDV;
+        alias PENUMLOGFONTEXDVW PENUMLOGFONTEXDV;
+        alias LPENUMLOGFONTEXDVW LPENUMLOGFONTEXDV;
+        alias AddFontResourceExW AddFontResourceEx;
+        alias RemoveFontResourceExW RemoveFontResourceEx;
+        alias GetGlyphIndicesW GetGlyphIndices;
+    }
+} else { /* non-unicode build */
+    alias BYTE BCHAR;
+    alias DOCINFOA DOCINFO;
+    alias LOGFONTA LOGFONT;
+    alias TEXTMETRICA TEXTMETRIC;
+    alias NPTEXTMETRICA NPTEXTMETRIC;
+    alias ICMENUMPROCA ICMENUMPROC;
+    alias FONTENUMPROCA FONTENUMPROC;
+    alias DEVMODEA DEVMODE;
+    alias EXTLOGFONTA EXTLOGFONT;
+    alias GCP_RESULTSA GCP_RESULTS;
+    alias OUTLINETEXTMETRICA OUTLINETEXTMETRIC;
+    alias POLYTEXTA POLYTEXT;
+    alias LOGCOLORSPACEA LOGCOLORSPACE;
+    alias NEWTEXTMETRICA NEWTEXTMETRIC;
+    alias NEWTEXTMETRICEXA NEWTEXTMETRICEX;
+    alias ENUMLOGFONTA ENUMLOGFONT;
+    alias ENUMLOGFONTEXA ENUMLOGFONTEX;
+    alias DISPLAY_DEVICEA DISPLAY_DEVICE;
+
+    alias AddFontResourceA AddFontResource;
+    alias CopyEnhMetaFileA CopyEnhMetaFile;
+    alias CopyMetaFileA CopyMetaFile;
+    alias CreateColorSpaceA CreateColorSpace;
+    alias CreateDCA CreateDC;
+    alias CreateEnhMetaFileA CreateEnhMetaFile;
+    alias CreateFontA CreateFont;
+    alias CreateFontIndirectA CreateFontIndirect;
+    alias CreateICA CreateIC;
+    alias CreateMetaFileA CreateMetaFile;
+    alias CreateScalableFontResourceA CreateScalableFontResource;
+    alias DeviceCapabilitiesA DeviceCapabilities;
+    alias EnumFontFamiliesA EnumFontFamilies;
+    alias EnumFontFamiliesExA EnumFontFamiliesEx;
+    alias EnumFontsA EnumFonts;
+    alias EnumICMProfilesA EnumICMProfiles;
+    alias ExtTextOutA ExtTextOut;
+    alias GetCharWidthFloatA GetCharWidthFloat;
+    alias GetCharWidthA GetCharWidth;
+    alias GetCharacterPlacementA GetCharacterPlacement;
+    alias GetCharABCWidthsA GetCharABCWidths;
+    alias GetCharABCWidthsFloatA GetCharABCWidthsFloat;
+    alias GetCharWidth32A GetCharWidth32;
+    alias GetEnhMetaFileA GetEnhMetaFile;
+    alias GetEnhMetaFileDescriptionA GetEnhMetaFileDescription;
+    alias GetGlyphOutlineA GetGlyphOutline;
+    alias GetICMProfileA GetICMProfile;
+    alias GetKerningPairsA GetKerningPairs;
+    alias GetLogColorSpaceA GetLogColorSpace;
+    alias GetMetaFileA GetMetaFile;
+    alias GetObjectA GetObject;
+    alias GetOutlineTextMetricsA GetOutlineTextMetrics;
+    alias GetTextExtentPointA GetTextExtentPoint;
+    alias GetTextExtentExPointA GetTextExtentExPoint;
+    alias GetTextExtentPoint32A GetTextExtentPoint32;
+    alias GetTextFaceA GetTextFace;
+    alias GetTextMetricsA GetTextMetrics;
+    alias PolyTextOutA PolyTextOut;
+    alias RemoveFontResourceA RemoveFontResource;
+    alias ResetDCA ResetDC;
+    alias SetICMProfileA SetICMProfile;
+    alias StartDocA StartDoc;
+    alias TextOutA TextOut;
+    alias UpdateICMRegKeyA UpdateICMRegKey;
+    alias wglUseFontBitmapsA wglUseFontBitmaps;
+    alias wglUseFontOutlinesA wglUseFontOutlines;
+    static if (_WIN32_WINNT >= 0x500) {
+        alias ENUMLOGFONTEXDVA ENUMLOGFONTEXDV;
+        alias PENUMLOGFONTEXDVA PENUMLOGFONTEXDV;
+        alias LPENUMLOGFONTEXDVA LPENUMLOGFONTEXDV;
+        alias AddFontResourceExA AddFontResourceEx;
+        alias RemoveFontResourceExA RemoveFontResourceEx;
+        alias GetGlyphIndicesA GetGlyphIndices;
+    }
+}
+
+// Common to both ASCII & UNICODE
+alias DOCINFO* LPDOCINFO;
+alias LOGFONT* PLOGFONT, NPLOGFONT, LPLOGFONT;
+alias TEXTMETRIC* PTEXTMETRIC, LPTEXTMETRIC;
+alias DEVMODE* PDEVMODE, NPDEVMODE, LPDEVMODE;
+alias EXTLOGFONT* PEXTLOGFONT, NPEXTLOGFONT, LPEXTLOGFONT;
+alias GCP_RESULTS* LPGCP_RESULTS;
+alias OUTLINETEXTMETRIC* POUTLINETEXTMETRIC, NPOUTLINETEXTMETRIC, LPOUTLINETEXTMETRIC;
+alias POLYTEXT* PPOLYTEXT, NPPOLYTEXT, LPPOLYTEXT;
+alias LOGCOLORSPACE* LPLOGCOLORSPACE;
+alias NEWTEXTMETRIC* PNEWTEXTMETRIC, NPNEWTEXTMETRIC, LPNEWTEXTMETRIC;
+alias ENUMLOGFONT* LPENUMLOGFONT;
+alias ENUMLOGFONTEX* LPENUMLOGFONTEX;
+alias DISPLAY_DEVICE* PDISPLAY_DEVICE, LPDISPLAY_DEVICE;
diff --git a/libphobos/libdruntime/core/sys/windows/winhttp.d b/libphobos/libdruntime/core/sys/windows/winhttp.d
new file mode 100644
index 00000000000..9a7592265c5
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winhttp.d
@@ -0,0 +1,844 @@
+/**
+ * Windows API header module
+ *
+ * Translated from Windows SDK Headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winhttp.d)
+ */
+module core.sys.windows.winhttp;
+version (Windows):
+pragma(lib, "winhttp");
+// FIXME: Grouping of constants. Windows SDK doesn't make this entirely clear
+// FIXME: Verify WINHTTP_STATUS_CALLBACK function declaration works correctly
+
+import core.sys.windows.w32api;
+import core.sys.windows.winbase;
+import core.sys.windows.windef;
+import core.sys.windows.winsock2;  // Selective Imports BUG (: SOCKADDR_STORAGE;)
+
+alias HINTERNET = void*;
+alias LPHINTERNET = HINTERNET*;
+alias INTERNET_PORT = WORD;
+alias LPINTERNET_PORT = INTERNET_PORT*;
+alias INTERNET_SCHEME = int;
+alias LPINTERNET_SCHEME = INTERNET_SCHEME*;
+
+// Protocol 'Manifests'
+enum : DWORD {
+    INTERNET_DEFAULT_PORT       = 0,
+    INTERNET_DEFAULT_HTTP_PORT  = 80,
+    INTERNET_DEFAULT_HTTPS_PORT = 443
+}
+
+// WinHttpOpen() Flags:
+enum DWORD WINHTTP_FLAG_ASYNC = 0x10000000;
+
+// WinHttpOpenRequest() Flags:
+enum : DWORD {
+    WINHTTP_FLAG_SECURE               = 0x00800000,
+    WINHTTP_FLAG_ESCAPE_PERCENT       = 0x00000004,
+    WINHTTP_FLAG_NULL_CODEPAGE        = 0x00000008,
+    WINHTTP_FLAG_BYPASS_PROXY_CACHE   = 0x00000100,
+    WINHTTP_FLAG_REFRESH              = WINHTTP_FLAG_BYPASS_PROXY_CACHE,
+    WINHTTP_FLAG_ESCAPE_DISABLE       = 0x00000040,
+    WINHTTP_FLAG_ESCAPE_DISABLE_QUERY = 0x00000080,
+
+    SECURITY_FLAG_IGNORE_UNKNOWN_CA        = 0x00000100,
+    SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000,
+    SECURITY_FLAG_IGNORE_CERT_CN_INVALID   = 0x00001000,
+    SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE  = 0x00000200
+}
+
+struct WINHTTP_ASYNC_RESULT {
+    DWORD_PTR dwResult;
+    DWORD dwError;
+}
+alias LPWINHTTP_ASYNC_RESULT = WINHTTP_ASYNC_RESULT*;
+
+struct HTTP_VERSION_INFO {
+    DWORD dwMajorVersion;
+    DWORD dwMinorVersion;
+}
+alias LPHTTP_VERSION_INFO = HTTP_VERSION_INFO*;
+
+// URL Scheme
+enum : DWORD {
+    INTERNET_SCHEME_HTTP  = 1,
+    INTERNET_SCHEME_HTTPS = 2,
+    INTERNET_SCHEME_FTP   = 3,
+    INTERNET_SCHEME_SOCKS = 4
+}
+
+struct URL_COMPONENTS {
+    DWORD   dwStructSize;
+    LPWSTR  lpszScheme;
+    DWORD   dwSchemeLength;
+    INTERNET_SCHEME nScheme;
+    LPWSTR  lpszHostName;
+    DWORD   dwHostNameLength;
+    INTERNET_PORT nPort;
+    LPWSTR  lpszUserName;
+    DWORD   dwUserNameLength;
+    LPWSTR  lpszPassword;
+    DWORD   dwPasswordLength;
+    LPWSTR  lpszUrlPath;
+    DWORD   dwUrlPathLength;
+    LPWSTR  lpszExtraInfo;
+    DWORD   dwExtraInfoLength;
+}
+alias LPURL_COMPONENTS = URL_COMPONENTS*;
+alias URL_COMPONENTSW = URL_COMPONENTS;
+alias LPURL_COMPONENTSW = URL_COMPONENTS*;
+
+struct WINHTTP_PROXY_INFO {
+    DWORD  dwAccessType;
+    LPWSTR lpszProxy;
+    LPWSTR lpszProxyBypass;
+}
+alias LPWINHTTP_PROXY_INFO = WINHTTP_PROXY_INFO*;
+alias WINHTTP_PROXY_INFOW = WINHTTP_PROXY_INFO;
+alias LPWINHTTP_PROXY_INFOW = WINHTTP_PROXY_INFO*;
+
+struct WINHTTP_AUTOPROXY_OPTIONS {
+    DWORD   dwFlags;
+    DWORD   dwAutoDetectFlags;
+    LPCWSTR lpszAutoConfigUrl;
+    LPVOID  lpvReserved;
+    DWORD   dwReserved;
+    BOOL    fAutoLogonIfChallenged;
+}
+
+enum : DWORD {
+    WINHTTP_AUTOPROXY_AUTO_DETECT           = 0x00000001,
+    WINHTTP_AUTOPROXY_CONFIG_URL            = 0x00000002,
+    WINHTTP_AUTOPROXY_HOST_KEEPCASE         = 0x00000004,
+    WINHTTP_AUTOPROXY_HOST_LOWERCASE        = 0x00000008,
+    WINHTTP_AUTOPROXY_RUN_INPROCESS         = 0x00010000,
+    WINHTTP_AUTOPROXY_RUN_OUTPROCESS_ONLY   = 0x00020000,
+    WINHTTP_AUTOPROXY_NO_DIRECTACCESS       = 0x00040000,
+    WINHTTP_AUTOPROXY_NO_CACHE_CLIENT       = 0x00080000,
+    WINHTTP_AUTOPROXY_NO_CACHE_SVC          = 0x00100000,
+
+    WINHTTP_AUTOPROXY_SORT_RESULTS          = 0x00400000
+}
+
+// dwAutoDetectFlags
+enum : DWORD {
+    WINHTTP_AUTO_DETECT_TYPE_DHCP           = 0x00000001,
+    WINHTTP_AUTO_DETECT_TYPE_DNS_A          = 0x00000002
+}
+
+struct WINHTTP_CERTIFICATE_INFO {
+    FILETIME ftExpiry;
+    FILETIME ftStart;
+    LPWSTR lpszSubjectInfo;
+    LPWSTR lpszIssuerInfo;
+    LPWSTR lpszProtocolName;
+    LPWSTR lpszSignatureAlgName;
+    LPWSTR lpszEncryptionAlgName;
+    DWORD dwKeySize;
+}
+
+// This structure is only defined #if _WS2DEF_ defined (from <ws2def.h>) - per Windows SDK
+struct WINHTTP_CONNECTION_INFO {
+    DWORD cbSize;
+    SOCKADDR_STORAGE LocalAddress;
+    SOCKADDR_STORAGE RemoteAddress;
+}
+
+// WinHttpTimeFromSystemTime
+enum DWORD WINHTTP_TIME_FORMAT_BUFSIZE  = 62;
+
+// CrackUrl, CombineUrl
+enum : DWORD {
+    ICU_NO_ENCODE           = 0x20000000,
+    ICU_DECODE              = 0x10000000,
+    ICU_NO_META             = 0x08000000,
+    ICU_ENCODE_SPACES_ONLY  = 0x04000000,
+    ICU_BROWSER_MODE        = 0x02000000,
+    ICU_ENCODE_PERCENT      = 0x00001000
+}
+// WinHttpCrackUrl, WinHttpCreateUrl
+enum : DWORD {
+    ICU_ESCAPE            = 0x80000000,
+    ICU_ESCAPE_AUTHORITY  = 0x00002000,
+    ICU_REJECT_USERPWD    = 0x00004000
+}
+enum : DWORD {
+    WINHTTP_ACCESS_TYPE_DEFAULT_PROXY             = 0,
+    WINHTTP_ACCESS_TYPE_NO_PROXY                  = 1,
+    WINHTTP_ACCESS_TYPE_NAMED_PROXY               = 3,
+    WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY           = 4
+}
+// WinHttpOpen 'prettifiers'
+enum LPCWSTR WINHTTP_NO_PROXY_NAME         = null;
+enum LPCWSTR WINHTTP_NO_PROXY_BYPASS       = null;
+
+enum LPVOID WINHTTP_NO_CLIENT_CERT_CONTEXT = null;
+
+// WinHttp{Query|Set}Option
+enum : DWORD {
+    WINHTTP_FIRST_OPTION                         = WINHTTP_OPTION_CALLBACK,
+
+    WINHTTP_OPTION_CALLBACK                      = 1,
+    WINHTTP_OPTION_RESOLVE_TIMEOUT               = 2,
+    WINHTTP_OPTION_CONNECT_TIMEOUT               = 3,
+    WINHTTP_OPTION_CONNECT_RETRIES               = 4,
+    WINHTTP_OPTION_SEND_TIMEOUT                  = 5,
+    WINHTTP_OPTION_RECEIVE_TIMEOUT               = 6,
+    WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT      = 7,
+    WINHTTP_OPTION_HANDLE_TYPE                   = 9,
+    WINHTTP_OPTION_READ_BUFFER_SIZE             = 12,
+    WINHTTP_OPTION_WRITE_BUFFER_SIZE            = 13,
+    WINHTTP_OPTION_PARENT_HANDLE                = 21,
+    WINHTTP_OPTION_EXTENDED_ERROR               = 24,
+    WINHTTP_OPTION_SECURITY_FLAGS               = 31,
+    WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT  = 32,
+    WINHTTP_OPTION_URL                          = 34,
+    WINHTTP_OPTION_SECURITY_KEY_BITNESS         = 36,
+    WINHTTP_OPTION_PROXY                        = 38,
+    WINHTTP_OPTION_PROXY_RESULT_ENTRY           = 39,
+
+    WINHTTP_OPTION_USER_AGENT                   = 41,
+    WINHTTP_OPTION_CONTEXT_VALUE                = 45,
+    WINHTTP_OPTION_CLIENT_CERT_CONTEXT          = 47,
+    WINHTTP_OPTION_REQUEST_PRIORITY             = 58,
+    WINHTTP_OPTION_HTTP_VERSION                 = 59,
+    WINHTTP_OPTION_DISABLE_FEATURE              = 63,
+
+    WINHTTP_OPTION_CODEPAGE                     = 68,
+    WINHTTP_OPTION_MAX_CONNS_PER_SERVER         = 73,
+    WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER     = 74,
+    WINHTTP_OPTION_AUTOLOGON_POLICY             = 77,
+    WINHTTP_OPTION_SERVER_CERT_CONTEXT          = 78,
+    WINHTTP_OPTION_ENABLE_FEATURE               = 79,
+    WINHTTP_OPTION_WORKER_THREAD_COUNT          = 80,
+    WINHTTP_OPTION_PASSPORT_COBRANDING_TEXT     = 81,
+    WINHTTP_OPTION_PASSPORT_COBRANDING_URL      = 82,
+    WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH      = 83,
+    WINHTTP_OPTION_SECURE_PROTOCOLS             = 84,
+    WINHTTP_OPTION_ENABLETRACING                = 85,
+    WINHTTP_OPTION_PASSPORT_SIGN_OUT            = 86,
+    WINHTTP_OPTION_PASSPORT_RETURN_URL          = 87,
+    WINHTTP_OPTION_REDIRECT_POLICY              = 88,
+    WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS = 89,
+    WINHTTP_OPTION_MAX_HTTP_STATUS_CONTINUE     = 90,
+    WINHTTP_OPTION_MAX_RESPONSE_HEADER_SIZE     = 91,
+    WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE      = 92,
+    WINHTTP_OPTION_CONNECTION_INFO              = 93,
+    WINHTTP_OPTION_CLIENT_CERT_ISSUER_LIST      = 94,
+    WINHTTP_OPTION_SPN                          = 96,
+
+    WINHTTP_OPTION_GLOBAL_PROXY_CREDS           = 97,
+    WINHTTP_OPTION_GLOBAL_SERVER_CREDS          = 98,
+
+    WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT            = 99,
+    WINHTTP_OPTION_REJECT_USERPWD_IN_URL          = 100,
+    WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS  = 101,
+
+    WINHTTP_OPTION_RECEIVE_PROXY_CONNECT_RESPONSE = 103,
+    WINHTTP_OPTION_IS_PROXY_CONNECT_RESPONSE      = 104,
+
+    WINHTTP_OPTION_SERVER_SPN_USED              = 106,
+    WINHTTP_OPTION_PROXY_SPN_USED               = 107,
+
+    WINHTTP_OPTION_SERVER_CBT                   = 108,
+
+    WINHTTP_OPTION_UNSAFE_HEADER_PARSING          = 110,
+    WINHTTP_OPTION_ASSURED_NON_BLOCKING_CALLBACKS = 111,
+
+    WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET          = 114,
+    WINHTTP_OPTION_WEB_SOCKET_CLOSE_TIMEOUT       = 115,
+    WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL  = 116,
+
+    WINHTTP_OPTION_DECOMPRESSION                  = 118,
+
+    WINHTTP_OPTION_WEB_SOCKET_RECEIVE_BUFFER_SIZE = 122,
+    WINHTTP_OPTION_WEB_SOCKET_SEND_BUFFER_SIZE    = 123,
+
+    //WINHTTP_LAST_OPTION => Moved outside of enum - static if() constraints within enums
+
+    WINHTTP_OPTION_USERNAME                      = 0x1000,
+    WINHTTP_OPTION_PASSWORD                      = 0x1001,
+    WINHTTP_OPTION_PROXY_USERNAME                = 0x1002,
+    WINHTTP_OPTION_PROXY_PASSWORD                = 0x1003,
+
+    WINHTTP_CONNS_PER_SERVER_UNLIMITED    = 0xFFFFFFFF,
+
+    WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM = 0,
+    WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW    = 1,
+    WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH   = 2,
+
+    WINHTTP_AUTOLOGON_SECURITY_LEVEL_DEFAULT = WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM,
+
+    WINHTTP_OPTION_REDIRECT_POLICY_NEVER                      = 0,
+    WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP     = 1,
+    WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS                     = 2,
+
+    WINHTTP_OPTION_REDIRECT_POLICY_LAST      = WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS,
+    WINHTTP_OPTION_REDIRECT_POLICY_DEFAULT   = WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP,
+
+    WINHTTP_DISABLE_PASSPORT_AUTH    = 0x00000000,
+    WINHTTP_ENABLE_PASSPORT_AUTH     = 0x10000000,
+    WINHTTP_DISABLE_PASSPORT_KEYRING = 0x20000000,
+    WINHTTP_ENABLE_PASSPORT_KEYRING  = 0x40000000,
+
+    WINHTTP_DISABLE_COOKIES                   = 0x00000001,
+    WINHTTP_DISABLE_REDIRECTS                 = 0x00000002,
+    WINHTTP_DISABLE_AUTHENTICATION            = 0x00000004,
+    WINHTTP_DISABLE_KEEP_ALIVE                = 0x00000008,
+
+    WINHTTP_ENABLE_SSL_REVOCATION             = 0x00000001,
+    WINHTTP_ENABLE_SSL_REVERT_IMPERSONATION   = 0x00000002,
+
+    WINHTTP_DISABLE_SPN_SERVER_PORT           = 0x00000000,
+    WINHTTP_ENABLE_SPN_SERVER_PORT            = 0x00000001,
+    WINHTTP_OPTION_SPN_MASK                   = WINHTTP_ENABLE_SPN_SERVER_PORT
+}
+
+// Windows 8.1 SDK:
+static if (_WIN32_WINNT >= 0x602) {
+    enum DWORD WINHTTP_LAST_OPTION            = WINHTTP_OPTION_WEB_SOCKET_SEND_BUFFER_SIZE;
+} else {    // Windows 7.0A SDK:
+    enum DWORD WINHTTP_LAST_OPTION            = WINHTTP_OPTION_SERVER_CBT;
+}
+
+enum : DWORD {
+    WINHTTP_DECOMPRESSION_FLAG_GZIP    = 0x00000001,
+    WINHTTP_DECOMPRESSION_FLAG_DEFLATE = 0x00000002,
+    WINHTTP_DECOMPRESSION_FLAG_ALL = (WINHTTP_DECOMPRESSION_FLAG_GZIP | WINHTTP_DECOMPRESSION_FLAG_DEFLATE)
+}
+
+struct WINHTTP_CREDS {
+    LPSTR lpszUserName;
+    LPSTR lpszPassword;
+    LPSTR lpszRealm;
+    DWORD dwAuthScheme;
+    LPSTR lpszHostName;
+    DWORD dwPort;
+}
+alias PWINHTTP_CREDS = WINHTTP_CREDS*;
+
+struct WINHTTP_CREDS_EX {
+    LPSTR lpszUserName;
+    LPSTR lpszPassword;
+    LPSTR lpszRealm;
+    DWORD dwAuthScheme;
+    LPSTR lpszHostName;
+    DWORD dwPort;
+    LPSTR lpszUrl;
+}
+alias PWINHTTP_CREDS_EX = WINHTTP_CREDS_EX*;
+
+enum : DWORD {
+    WINHTTP_HANDLE_TYPE_SESSION                = 1,
+    WINHTTP_HANDLE_TYPE_CONNECT                = 2,
+    WINHTTP_HANDLE_TYPE_REQUEST                = 3,
+
+    WINHTTP_AUTH_SCHEME_BASIC      = 0x00000001,
+    WINHTTP_AUTH_SCHEME_NTLM       = 0x00000002,
+    WINHTTP_AUTH_SCHEME_PASSPORT   = 0x00000004,
+    WINHTTP_AUTH_SCHEME_DIGEST     = 0x00000008,
+    WINHTTP_AUTH_SCHEME_NEGOTIATE  = 0x00000010,
+
+    WINHTTP_AUTH_TARGET_SERVER = 0x00000000,
+    WINHTTP_AUTH_TARGET_PROXY  = 0x00000001,
+
+    SECURITY_FLAG_SECURE                    = 0x00000001,
+    SECURITY_FLAG_STRENGTH_WEAK             = 0x10000000,
+    SECURITY_FLAG_STRENGTH_MEDIUM           = 0x40000000,
+    SECURITY_FLAG_STRENGTH_STRONG           = 0x20000000,
+
+    WINHTTP_CALLBACK_STATUS_FLAG_CERT_REV_FAILED         = 0x00000001,
+    WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CERT            = 0x00000002,
+    WINHTTP_CALLBACK_STATUS_FLAG_CERT_REVOKED            = 0x00000004,
+    WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA              = 0x00000008,
+    WINHTTP_CALLBACK_STATUS_FLAG_CERT_CN_INVALID         = 0x00000010,
+    WINHTTP_CALLBACK_STATUS_FLAG_CERT_DATE_INVALID       = 0x00000020,
+    WINHTTP_CALLBACK_STATUS_FLAG_CERT_WRONG_USAGE        = 0x00000040,
+    WINHTTP_CALLBACK_STATUS_FLAG_SECURITY_CHANNEL_ERROR  = 0x80000000,
+
+    WINHTTP_FLAG_SECURE_PROTOCOL_SSL2   = 0x00000008,
+    WINHTTP_FLAG_SECURE_PROTOCOL_SSL3   = 0x00000020,
+    WINHTTP_FLAG_SECURE_PROTOCOL_TLS1   = 0x00000080,
+    WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 = 0x00000200,
+    WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 = 0x00000800,
+    WINHTTP_FLAG_SECURE_PROTOCOL_ALL    = (WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 |
+                                                 WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 |
+                                                 WINHTTP_FLAG_SECURE_PROTOCOL_TLS1)
+}
+
+alias extern(Windows) int fnWINHTTP_STATUS_CALLBACK(HINTERNET hInternet, DWORD_PTR dwContext,
+                          DWORD dwInternetStatus, LPVOID lpvStatusInformation,DWORD dwStatusInformationLength);
+alias WINHTTP_STATUS_CALLBACK = fnWINHTTP_STATUS_CALLBACK*;
+alias LPWINHTTP_STATUS_CALLBACK = WINHTTP_STATUS_CALLBACK*;
+
+enum : DWORD {
+    WINHTTP_CALLBACK_STATUS_RESOLVING_NAME          = 0x00000001,
+    WINHTTP_CALLBACK_STATUS_NAME_RESOLVED           = 0x00000002,
+    WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER    = 0x00000004,
+    WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER     = 0x00000008,
+    WINHTTP_CALLBACK_STATUS_SENDING_REQUEST         = 0x00000010,
+    WINHTTP_CALLBACK_STATUS_REQUEST_SENT            = 0x00000020,
+    WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE      = 0x00000040,
+    WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED       = 0x00000080,
+    WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION      = 0x00000100,
+    WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED       = 0x00000200,
+    WINHTTP_CALLBACK_STATUS_HANDLE_CREATED          = 0x00000400,
+    WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING          = 0x00000800,
+    WINHTTP_CALLBACK_STATUS_DETECTING_PROXY         = 0x00001000,
+    WINHTTP_CALLBACK_STATUS_REDIRECT                = 0x00004000,
+    WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE   = 0x00008000,
+    WINHTTP_CALLBACK_STATUS_SECURE_FAILURE          = 0x00010000,
+    WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE       = 0x00020000,
+    WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE          = 0x00040000,
+    WINHTTP_CALLBACK_STATUS_READ_COMPLETE           = 0x00080000,
+    WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE          = 0x00100000,
+    WINHTTP_CALLBACK_STATUS_REQUEST_ERROR           = 0x00200000,
+    WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE    = 0x00400000
+}
+
+enum : DWORD {
+    WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE = 0x01000000,
+    WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE          = 0x02000000,
+    WINHTTP_CALLBACK_STATUS_SHUTDOWN_COMPLETE       = 0x04000000
+}
+
+enum : DWORD {
+    API_RECEIVE_RESPONSE        = 1,
+    API_QUERY_DATA_AVAILABLE    = 2,
+    API_READ_DATA               = 3,
+    API_WRITE_DATA              = 4,
+    API_SEND_REQUEST            = 5
+}
+
+enum : DWORD {
+    WINHTTP_CALLBACK_FLAG_RESOLVE_NAME            = (WINHTTP_CALLBACK_STATUS_RESOLVING_NAME | WINHTTP_CALLBACK_STATUS_NAME_RESOLVED),
+    WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER       = (WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER | WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER),
+    WINHTTP_CALLBACK_FLAG_SEND_REQUEST            = (WINHTTP_CALLBACK_STATUS_SENDING_REQUEST | WINHTTP_CALLBACK_STATUS_REQUEST_SENT),
+    WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE        = (WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE | WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED),
+    WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION        = (WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION | WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED),
+    WINHTTP_CALLBACK_FLAG_HANDLES                 = (WINHTTP_CALLBACK_STATUS_HANDLE_CREATED | WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING),
+    WINHTTP_CALLBACK_FLAG_DETECTING_PROXY         = WINHTTP_CALLBACK_STATUS_DETECTING_PROXY,
+    WINHTTP_CALLBACK_FLAG_REDIRECT                = WINHTTP_CALLBACK_STATUS_REDIRECT,
+    WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE   = WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE,
+    WINHTTP_CALLBACK_FLAG_SECURE_FAILURE          = WINHTTP_CALLBACK_STATUS_SECURE_FAILURE,
+    WINHTTP_CALLBACK_FLAG_SENDREQUEST_COMPLETE    = WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE,
+    WINHTTP_CALLBACK_FLAG_HEADERS_AVAILABLE       = WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE,
+    WINHTTP_CALLBACK_FLAG_DATA_AVAILABLE          = WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE,
+    WINHTTP_CALLBACK_FLAG_READ_COMPLETE           = WINHTTP_CALLBACK_STATUS_READ_COMPLETE,
+    WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE          = WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE,
+    WINHTTP_CALLBACK_FLAG_REQUEST_ERROR           = WINHTTP_CALLBACK_STATUS_REQUEST_ERROR
+}
+
+enum DWORD WINHTTP_CALLBACK_FLAG_GETPROXYFORURL_COMPLETE  = WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE;
+
+// Windows 8+/2012+
+static if (_WIN32_WINNT >= 0x602)   {
+  enum DWORD WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS        =  (WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE
+                                                        | WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE
+                                                        | WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE
+                                                        | WINHTTP_CALLBACK_STATUS_READ_COMPLETE
+                                                        | WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE
+                                                        | WINHTTP_CALLBACK_STATUS_REQUEST_ERROR);
+} else {
+  enum DWORD WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS        =  (WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE
+                                                        | WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE
+                                                        | WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE
+                                                        | WINHTTP_CALLBACK_STATUS_READ_COMPLETE
+                                                        | WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE
+                                                        | WINHTTP_CALLBACK_STATUS_REQUEST_ERROR
+                                                        | WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE);
+}
+
+enum DWORD  WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS      =  0xffffffff;
+
+enum WINHTTP_INVALID_STATUS_CALLBACK        = (cast(WINHTTP_STATUS_CALLBACK)(-1L));
+
+enum : DWORD {
+    WINHTTP_QUERY_MIME_VERSION               = 0,
+    WINHTTP_QUERY_CONTENT_TYPE               = 1,
+    WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING  = 2,
+    WINHTTP_QUERY_CONTENT_ID                 = 3,
+    WINHTTP_QUERY_CONTENT_DESCRIPTION        = 4,
+    WINHTTP_QUERY_CONTENT_LENGTH             = 5,
+    WINHTTP_QUERY_CONTENT_LANGUAGE           = 6,
+    WINHTTP_QUERY_ALLOW                      = 7,
+    WINHTTP_QUERY_PUBLIC                     = 8,
+    WINHTTP_QUERY_DATE                       = 9,
+    WINHTTP_QUERY_EXPIRES                    = 10,
+    WINHTTP_QUERY_LAST_MODIFIED              = 11,
+    WINHTTP_QUERY_MESSAGE_ID                 = 12,
+    WINHTTP_QUERY_URI                        = 13,
+    WINHTTP_QUERY_DERIVED_FROM               = 14,
+    WINHTTP_QUERY_COST                       = 15,
+    WINHTTP_QUERY_LINK                       = 16,
+    WINHTTP_QUERY_PRAGMA                     = 17,
+    WINHTTP_QUERY_VERSION                    = 18,
+    WINHTTP_QUERY_STATUS_CODE                = 19,
+    WINHTTP_QUERY_STATUS_TEXT                = 20,
+    WINHTTP_QUERY_RAW_HEADERS                = 21,
+    WINHTTP_QUERY_RAW_HEADERS_CRLF           = 22,
+    WINHTTP_QUERY_CONNECTION                 = 23,
+    WINHTTP_QUERY_ACCEPT                     = 24,
+    WINHTTP_QUERY_ACCEPT_CHARSET             = 25,
+    WINHTTP_QUERY_ACCEPT_ENCODING            = 26,
+    WINHTTP_QUERY_ACCEPT_LANGUAGE            = 27,
+    WINHTTP_QUERY_AUTHORIZATION              = 28,
+    WINHTTP_QUERY_CONTENT_ENCODING           = 29,
+    WINHTTP_QUERY_FORWARDED                  = 30,
+    WINHTTP_QUERY_FROM                       = 31,
+    WINHTTP_QUERY_IF_MODIFIED_SINCE          = 32,
+    WINHTTP_QUERY_LOCATION                   = 33,
+    WINHTTP_QUERY_ORIG_URI                   = 34,
+    WINHTTP_QUERY_REFERER                    = 35,
+    WINHTTP_QUERY_RETRY_AFTER                = 36,
+    WINHTTP_QUERY_SERVER                     = 37,
+    WINHTTP_QUERY_TITLE                      = 38,
+    WINHTTP_QUERY_USER_AGENT                 = 39,
+    WINHTTP_QUERY_WWW_AUTHENTICATE           = 40,
+    WINHTTP_QUERY_PROXY_AUTHENTICATE         = 41,
+    WINHTTP_QUERY_ACCEPT_RANGES              = 42,
+    WINHTTP_QUERY_SET_COOKIE                 = 43,
+    WINHTTP_QUERY_COOKIE                     = 44,
+    WINHTTP_QUERY_REQUEST_METHOD             = 45,
+    WINHTTP_QUERY_REFRESH                    = 46,
+    WINHTTP_QUERY_CONTENT_DISPOSITION        = 47,
+
+    // HTTP 1.1 defined headers
+
+    WINHTTP_QUERY_AGE                        = 48,
+    WINHTTP_QUERY_CACHE_CONTROL              = 49,
+    WINHTTP_QUERY_CONTENT_BASE               = 50,
+    WINHTTP_QUERY_CONTENT_LOCATION           = 51,
+    WINHTTP_QUERY_CONTENT_MD5                = 52,
+    WINHTTP_QUERY_CONTENT_RANGE              = 53,
+    WINHTTP_QUERY_ETAG                       = 54,
+    WINHTTP_QUERY_HOST                       = 55,
+    WINHTTP_QUERY_IF_MATCH                   = 56,
+    WINHTTP_QUERY_IF_NONE_MATCH              = 57,
+    WINHTTP_QUERY_IF_RANGE                   = 58,
+    WINHTTP_QUERY_IF_UNMODIFIED_SINCE        = 59,
+    WINHTTP_QUERY_MAX_FORWARDS               = 60,
+    WINHTTP_QUERY_PROXY_AUTHORIZATION        = 61,
+    WINHTTP_QUERY_RANGE                      = 62,
+    WINHTTP_QUERY_TRANSFER_ENCODING          = 63,
+    WINHTTP_QUERY_UPGRADE                    = 64,
+    WINHTTP_QUERY_VARY                       = 65,
+    WINHTTP_QUERY_VIA                        = 66,
+    WINHTTP_QUERY_WARNING                    = 67,
+    WINHTTP_QUERY_EXPECT                     = 68,
+    WINHTTP_QUERY_PROXY_CONNECTION           = 69,
+    WINHTTP_QUERY_UNLESS_MODIFIED_SINCE      = 70,
+
+    WINHTTP_QUERY_PROXY_SUPPORT              = 75,
+    WINHTTP_QUERY_AUTHENTICATION_INFO        = 76,
+    WINHTTP_QUERY_PASSPORT_URLS              = 77,
+    WINHTTP_QUERY_PASSPORT_CONFIG            = 78,
+
+    WINHTTP_QUERY_MAX                        = 78,
+
+    WINHTTP_QUERY_CUSTOM                     = 65535,
+
+    WINHTTP_QUERY_FLAG_REQUEST_HEADERS         = 0x80000000,
+
+    WINHTTP_QUERY_FLAG_SYSTEMTIME              = 0x40000000,
+
+    WINHTTP_QUERY_FLAG_NUMBER                  = 0x20000000
+}
+
+enum : DWORD {
+    HTTP_STATUS_CONTINUE            = 100,
+    HTTP_STATUS_SWITCH_PROTOCOLS    = 101,
+
+    HTTP_STATUS_OK                  = 200,
+    HTTP_STATUS_CREATED             = 201,
+    HTTP_STATUS_ACCEPTED            = 202,
+    HTTP_STATUS_PARTIAL             = 203,
+    HTTP_STATUS_NO_CONTENT          = 204,
+    HTTP_STATUS_RESET_CONTENT       = 205,
+    HTTP_STATUS_PARTIAL_CONTENT     = 206,
+    HTTP_STATUS_WEBDAV_MULTI_STATUS = 207,
+
+    HTTP_STATUS_AMBIGUOUS           = 300,
+    HTTP_STATUS_MOVED               = 301,
+    HTTP_STATUS_REDIRECT            = 302,
+    HTTP_STATUS_REDIRECT_METHOD     = 303,
+    HTTP_STATUS_NOT_MODIFIED        = 304,
+    HTTP_STATUS_USE_PROXY           = 305,
+    HTTP_STATUS_REDIRECT_KEEP_VERB  = 307,
+
+    HTTP_STATUS_BAD_REQUEST       = 400,
+    HTTP_STATUS_DENIED            = 401,
+    HTTP_STATUS_PAYMENT_REQ       = 402,
+    HTTP_STATUS_FORBIDDEN         = 403,
+    HTTP_STATUS_NOT_FOUND         = 404,
+    HTTP_STATUS_BAD_METHOD        = 405,
+    HTTP_STATUS_NONE_ACCEPTABLE   = 406,
+    HTTP_STATUS_PROXY_AUTH_REQ    = 407,
+    HTTP_STATUS_REQUEST_TIMEOUT   = 408,
+    HTTP_STATUS_CONFLICT          = 409,
+    HTTP_STATUS_GONE              = 410,
+    HTTP_STATUS_LENGTH_REQUIRED   = 411,
+    HTTP_STATUS_PRECOND_FAILED    = 412,
+    HTTP_STATUS_REQUEST_TOO_LARGE = 413,
+    HTTP_STATUS_URI_TOO_LONG      = 414,
+    HTTP_STATUS_UNSUPPORTED_MEDIA = 415,
+    HTTP_STATUS_RETRY_WITH        = 449,
+
+    HTTP_STATUS_SERVER_ERROR      = 500,
+    HTTP_STATUS_NOT_SUPPORTED     = 501,
+    HTTP_STATUS_BAD_GATEWAY       = 502,
+    HTTP_STATUS_SERVICE_UNAVAIL   = 503,
+    HTTP_STATUS_GATEWAY_TIMEOUT   = 504,
+    HTTP_STATUS_VERSION_NOT_SUP   = 505,
+
+    HTTP_STATUS_FIRST             = HTTP_STATUS_CONTINUE,
+    HTTP_STATUS_LAST              = HTTP_STATUS_VERSION_NOT_SUP
+}
+
+enum LPCWSTR WINHTTP_NO_REFERER             = null;
+enum LPCWSTR * WINHTTP_DEFAULT_ACCEPT_TYPES = null;
+
+enum : DWORD {
+    WINHTTP_ADDREQ_INDEX_MASK     = 0x0000FFFF,
+    WINHTTP_ADDREQ_FLAGS_MASK     = 0xFFFF0000,
+
+    WINHTTP_ADDREQ_FLAG_ADD_IF_NEW = 0x10000000,
+
+    WINHTTP_ADDREQ_FLAG_ADD        = 0x20000000,
+
+    WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA       = 0x40000000,
+    WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON   = 0x01000000,
+    WINHTTP_ADDREQ_FLAG_COALESCE                  = WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA,
+
+    WINHTTP_ADDREQ_FLAG_REPLACE    = 0x80000000,
+
+    WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH = 0
+}
+
+enum LPCWSTR WINHTTP_NO_ADDITIONAL_HEADERS = null;
+enum LPVOID WINHTTP_NO_REQUEST_DATA        = null;
+
+enum LPCWSTR WINHTTP_HEADER_NAME_BY_INDEX  = null;
+enum LPVOID WINHTTP_NO_OUTPUT_BUFFER       = null;
+enum LPDWORD WINHTTP_NO_HEADER_INDEX       = null;
+
+struct WINHTTP_CURRENT_USER_IE_PROXY_CONFIG {
+    BOOL    fAutoDetect;
+    LPWSTR  lpszAutoConfigUrl;
+    LPWSTR  lpszProxy;
+    LPWSTR  lpszProxyBypass;
+}
+
+// WinHttp API error returns
+enum : DWORD {
+    WINHTTP_ERROR_BASE                   = 12000,
+
+    ERROR_WINHTTP_OUT_OF_HANDLES         = (WINHTTP_ERROR_BASE + 1),
+    ERROR_WINHTTP_TIMEOUT                = (WINHTTP_ERROR_BASE + 2),
+    ERROR_WINHTTP_INTERNAL_ERROR         = (WINHTTP_ERROR_BASE + 4),
+    ERROR_WINHTTP_INVALID_URL            = (WINHTTP_ERROR_BASE + 5),
+    ERROR_WINHTTP_UNRECOGNIZED_SCHEME    = (WINHTTP_ERROR_BASE + 6),
+    ERROR_WINHTTP_NAME_NOT_RESOLVED      = (WINHTTP_ERROR_BASE + 7),
+    ERROR_WINHTTP_INVALID_OPTION         = (WINHTTP_ERROR_BASE + 9),
+    ERROR_WINHTTP_OPTION_NOT_SETTABLE    = (WINHTTP_ERROR_BASE + 11),
+    ERROR_WINHTTP_SHUTDOWN               = (WINHTTP_ERROR_BASE + 12),
+
+    ERROR_WINHTTP_LOGIN_FAILURE          = (WINHTTP_ERROR_BASE + 15),
+    ERROR_WINHTTP_OPERATION_CANCELLED    = (WINHTTP_ERROR_BASE + 17),
+    ERROR_WINHTTP_INCORRECT_HANDLE_TYPE  = (WINHTTP_ERROR_BASE + 18),
+    ERROR_WINHTTP_INCORRECT_HANDLE_STATE = (WINHTTP_ERROR_BASE + 19),
+    ERROR_WINHTTP_CANNOT_CONNECT         = (WINHTTP_ERROR_BASE + 29),
+    ERROR_WINHTTP_CONNECTION_ERROR       = (WINHTTP_ERROR_BASE + 30),
+    ERROR_WINHTTP_RESEND_REQUEST         = (WINHTTP_ERROR_BASE + 32),
+
+    ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED = (WINHTTP_ERROR_BASE, + 44),
+
+    ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN = (WINHTTP_ERROR_BASE + 100),
+    ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND = (WINHTTP_ERROR_BASE + 101),
+    ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND  = (WINHTTP_ERROR_BASE + 102),
+    ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN  = (WINHTTP_ERROR_BASE + 103),
+
+    ERROR_WINHTTP_HEADER_NOT_FOUND           = (WINHTTP_ERROR_BASE + 150),
+    ERROR_WINHTTP_INVALID_SERVER_RESPONSE    = (WINHTTP_ERROR_BASE + 152),
+    ERROR_WINHTTP_INVALID_HEADER             = (WINHTTP_ERROR_BASE + 153),
+    ERROR_WINHTTP_INVALID_QUERY_REQUEST      = (WINHTTP_ERROR_BASE + 154),
+    ERROR_WINHTTP_HEADER_ALREADY_EXISTS      = (WINHTTP_ERROR_BASE + 155),
+    ERROR_WINHTTP_REDIRECT_FAILED            = (WINHTTP_ERROR_BASE + 156),
+
+    ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR  = (WINHTTP_ERROR_BASE + 178),
+    ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT     = (WINHTTP_ERROR_BASE + 166),
+    ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT = (WINHTTP_ERROR_BASE + 167),
+    ERROR_WINHTTP_UNHANDLED_SCRIPT_TYPE     = (WINHTTP_ERROR_BASE + 176),
+    ERROR_WINHTTP_SCRIPT_EXECUTION_ERROR    = (WINHTTP_ERROR_BASE + 177),
+
+    ERROR_WINHTTP_NOT_INITIALIZED        = (WINHTTP_ERROR_BASE + 172),
+    ERROR_WINHTTP_SECURE_FAILURE         = (WINHTTP_ERROR_BASE + 175),
+
+    ERROR_WINHTTP_SECURE_CERT_DATE_INVALID  = (WINHTTP_ERROR_BASE + 37),
+    ERROR_WINHTTP_SECURE_CERT_CN_INVALID    = (WINHTTP_ERROR_BASE + 38),
+    ERROR_WINHTTP_SECURE_INVALID_CA         = (WINHTTP_ERROR_BASE + 45),
+    ERROR_WINHTTP_SECURE_CERT_REV_FAILED    = (WINHTTP_ERROR_BASE + 57),
+    ERROR_WINHTTP_SECURE_CHANNEL_ERROR      = (WINHTTP_ERROR_BASE + 157),
+    ERROR_WINHTTP_SECURE_INVALID_CERT       = (WINHTTP_ERROR_BASE + 169),
+    ERROR_WINHTTP_SECURE_CERT_REVOKED       = (WINHTTP_ERROR_BASE + 170),
+    ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE   = (WINHTTP_ERROR_BASE + 179),
+
+    ERROR_WINHTTP_AUTODETECTION_FAILED                  = (WINHTTP_ERROR_BASE + 180),
+    ERROR_WINHTTP_HEADER_COUNT_EXCEEDED                 = (WINHTTP_ERROR_BASE + 181),
+    ERROR_WINHTTP_HEADER_SIZE_OVERFLOW                  = (WINHTTP_ERROR_BASE + 182),
+    ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW = (WINHTTP_ERROR_BASE + 183),
+    ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW               = (WINHTTP_ERROR_BASE + 184),
+    ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY            = (WINHTTP_ERROR_BASE + 185),
+    ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY     = (WINHTTP_ERROR_BASE + 186),
+
+    WINHTTP_ERROR_LAST                                  = (WINHTTP_ERROR_BASE + 186)
+}
+
+enum : DWORD {
+    WINHTTP_RESET_STATE                  = 0x00000001,
+    WINHTTP_RESET_SWPAD_CURRENT_NETWORK  = 0x00000002,
+    WINHTTP_RESET_SWPAD_ALL              = 0x00000004,
+    WINHTTP_RESET_SCRIPT_CACHE           = 0x00000008,
+    WINHTTP_RESET_ALL                    = 0x0000FFFF,
+    WINHTTP_RESET_NOTIFY_NETWORK_CHANGED = 0x00010000,
+    WINHTTP_RESET_OUT_OF_PROC            = 0x00020000
+}
+
+enum : DWORD {
+    WINHTTP_WEB_SOCKET_MAX_CLOSE_REASON_LENGTH = 123,
+    WINHTTP_WEB_SOCKET_MIN_KEEPALIVE_VALUE     = 15000
+}
+
+// Version(Windows8) || Version(Windows2012):
+static if (_WIN32_WINNT >= 0x602)
+{
+    enum WINHTTP_WEB_SOCKET_OPERATION : DWORD
+    {
+        WINHTTP_WEB_SOCKET_SEND_OPERATION                   = 0,
+        WINHTTP_WEB_SOCKET_RECEIVE_OPERATION                = 1,
+        WINHTTP_WEB_SOCKET_CLOSE_OPERATION                  = 2,
+        WINHTTP_WEB_SOCKET_SHUTDOWN_OPERATION               = 3
+    }
+    enum WINHTTP_WEB_SOCKET_BUFFER_TYPE : DWORD
+    {
+        WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE       = 0,
+        WINHTTP_WEB_SOCKET_BINARY_FRAGMENT_BUFFER_TYPE      = 1,
+        WINHTTP_WEB_SOCKET_UTF8_MESSAGE_BUFFER_TYPE         = 2,
+        WINHTTP_WEB_SOCKET_UTF8_FRAGMENT_BUFFER_TYPE        = 3,
+        WINHTTP_WEB_SOCKET_CLOSE_BUFFER_TYPE                = 4
+    }
+    enum WINHTTP_WEB_SOCKET_CLOSE_STATUS : DWORD
+    {
+        WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS                = 1000,
+        WINHTTP_WEB_SOCKET_ENDPOINT_TERMINATED_CLOSE_STATUS    = 1001,
+        WINHTTP_WEB_SOCKET_PROTOCOL_ERROR_CLOSE_STATUS         = 1002,
+        WINHTTP_WEB_SOCKET_INVALID_DATA_TYPE_CLOSE_STATUS      = 1003,
+        WINHTTP_WEB_SOCKET_EMPTY_CLOSE_STATUS                  = 1005,
+        WINHTTP_WEB_SOCKET_ABORTED_CLOSE_STATUS                = 1006,
+        WINHTTP_WEB_SOCKET_INVALID_PAYLOAD_CLOSE_STATUS        = 1007,
+        WINHTTP_WEB_SOCKET_POLICY_VIOLATION_CLOSE_STATUS       = 1008,
+        WINHTTP_WEB_SOCKET_MESSAGE_TOO_BIG_CLOSE_STATUS        = 1009,
+        WINHTTP_WEB_SOCKET_UNSUPPORTED_EXTENSIONS_CLOSE_STATUS = 1010,
+        WINHTTP_WEB_SOCKET_SERVER_ERROR_CLOSE_STATUS           = 1011,
+        WINHTTP_WEB_SOCKET_SECURE_HANDSHAKE_ERROR_CLOSE_STATUS = 1015
+    }
+    struct WINHTTP_PROXY_RESULT_ENTRY {
+        BOOL            fProxy;
+        BOOL            fBypass;
+        INTERNET_SCHEME ProxyScheme;
+        PWSTR           pwszProxy;
+        INTERNET_PORT   ProxyPort;
+    }
+    struct WINHTTP_PROXY_RESULT {
+        DWORD cEntries;
+        WINHTTP_PROXY_RESULT_ENTRY *pEntries;
+    }
+    struct WINHTTP_WEB_SOCKET_ASYNC_RESULT {
+        WINHTTP_ASYNC_RESULT AsyncResult;
+        WINHTTP_WEB_SOCKET_OPERATION Operation;
+    }
+    struct WINHTTP_WEB_SOCKET_STATUS {
+        DWORD dwBytesTransferred;
+        WINHTTP_WEB_SOCKET_BUFFER_TYPE eBufferType;
+    }
+}
+
+
+extern (Windows) {
+    BOOL WinHttpAddRequestHeaders(HINTERNET hRequest, LPCWSTR pwszHeaders, DWORD dwHeadersLength, DWORD dwModifiers);
+
+    BOOL WinHttpCheckPlatform();
+
+    BOOL WinHttpCloseHandle(HINTERNET hInternet);
+
+    HINTERNET WinHttpConnect(HINTERNET hSession, LPCWSTR pswzServerName, INTERNET_PORT nServerPort, DWORD dwReserved);
+
+    BOOL WinHttpCrackUrl(LPCWSTR pwszUrl, DWORD dwUrlLength, DWORD dwFlags, LPURL_COMPONENTS lpUrlComponents);
+
+    BOOL WinHttpCreateUrl(LPURL_COMPONENTS lpUrlComponents, DWORD dwFlags, LPWSTR pwszUrl, LPDWORD lpdwUrlLength);
+    BOOL WinHttpDetectAutoProxyConfigUrl(DWORD dwAutoDetectFlags, LPWSTR *ppwszAutoConfigUrl);
+
+    BOOL WinHttpGetDefaultProxyConfiguration(WINHTTP_PROXY_INFO *pProxyInfo);
+    BOOL WinHttpGetIEProxyConfigForCurrentUser(WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *pProxyConfig);
+    BOOL WinHttpGetProxyForUrl(HINTERNET hSession,  LPCWSTR lpcwszUrl,
+                               WINHTTP_AUTOPROXY_OPTIONS *pAutoProxyOptions, WINHTTP_PROXY_INFO *pProxyInfo);
+
+    HINTERNET WinHttpOpen(LPCWSTR pwszUserAgent, DWORD dwAccessType, LPCWSTR pwszProxyName,
+                          LPCWSTR pwszProxyBypass, DWORD dwFlags);
+    HINTERNET WinHttpOpenRequest(HINTERNET hConnect, LPCWSTR pwszVerb, LPCWSTR pwszObjectName,
+                                 LPCWSTR pwszVersion, LPCWSTR pwszReferrer,
+                                 LPCWSTR *ppwszAcceptTypes, DWORD dwFlags);
+
+    BOOL WinHttpQueryAuthSchemes(HINTERNET hRequest, LPDWORD lpdwSupportedSchemes,
+                                 LPDWORD lpdwFirstScheme, LPDWORD pdwAuthTarget);
+    BOOL WinHttpQueryDataAvailable(HINTERNET hRequest, LPDWORD lpdwNumberOfBytesAvailable);
+    BOOL WinHttpQueryHeaders(HINTERNET hRequest, DWORD dwInfoLevel, LPCWSTR pwszName,
+                             LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex);
+    BOOL WinHttpQueryOption(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer,
+                            LPDWORD lpdwBufferLength);
+
+    BOOL WinHttpReadData(HINTERNET hRequest, LPVOID lpBuffer, DWORD dwNumberOfBytesToRead,
+                         LPDWORD lpdwNumberOfBytesRead);
+    BOOL WinHttpReceiveResponse(HINTERNET hRequest, LPVOID lpReserved);
+
+    BOOL WinHttpSendRequest(HINTERNET hRequest, LPCWSTR pwszHeaders, DWORD dwHeadersLength,
+                            LPVOID lpOptional, DWORD dwOptionalLength, DWORD dwTotalLength, DWORD_PTR dwContext);
+
+    BOOL WinHttpSetCredentials(HINTERNET hRequest, DWORD AuthTargets, DWORD AuthScheme,
+                               LPCWSTR pwszUserName, LPCWSTR pwszPassword, LPVOID pAuthParams);
+    BOOL WinHttpSetDefaultProxyConfiguration(WINHTTP_PROXY_INFO *pProxyInfo);
+    BOOL WinHttpSetOption(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength);
+    WINHTTP_STATUS_CALLBACK WinHttpSetStatusCallback(HINTERNET hInternet,
+                                                     WINHTTP_STATUS_CALLBACK lpfnInternetCallback,
+                                                     DWORD dwNotificationFlags, DWORD_PTR dwReserved);
+    BOOL WinHttpSetTimeouts(HINTERNET hInternet, int dwResolveTimeout, int dwConnectTimeout,
+                            int dwSendTimeout, int dwReceiveTimeout);
+
+    BOOL WinHttpTimeFromSystemTime(const SYSTEMTIME *pst, LPWSTR pwszTime);
+    BOOL WinHttpTimeToSystemTime(LPCWSTR pwszTime, SYSTEMTIME *pst);
+
+    BOOL WinHttpWriteData(HINTERNET hRequest, LPCVOID lpBuffer, DWORD dwNumberOfBytesToWrite,
+                          LPDWORD lpdwNumberOfBytesWritten);
+
+  // Version(Windows8) || Version(Windows2012):
+  static if (_WIN32_WINNT >= 0x602) {
+    DWORD WinHttpCreateProxyResolver(HINTERNET hSession, HINTERNET *phResolver);
+    void WinHttpFreeProxyResult(WINHTTP_PROXY_RESULT *pProxyResult);
+    DWORD WinHttpGetProxyForUrlEx(HINTERNET hResolver, PCWSTR pcwszUrl,
+                                  WINHTTP_AUTOPROXY_OPTIONS *pAutoProxyOptions, DWORD_PTR pContext);
+    DWORD WinHttpGetProxyResult(HINTERNET hResolver, WINHTTP_PROXY_RESULT *pProxyResult);
+    DWORD WinHttpResetAutoProxy(HINTERNET hSession, DWORD dwFlags);
+    DWORD WinHttpWebSocketClose(HINTERNET hWebSocket, USHORT usStatus, PVOID pvReason, DWORD dwReasonLength);
+    HINTERNET WinHttpWebSocketCompleteUpgrade(HINTERNET hRequest, DWORD_PTR pContext);
+    DWORD WinHttpWebSocketQueryCloseStatus(HINTERNET hWebSocket, USHORT *pusStatus, PVOID pvReason,
+                                           DWORD dwReasonLength, DWORD *pdwReasonLengthConsumed);
+    DWORD WinHttpWebSocketReceive(HINTERNET hWebSocket, PVOID pvBuffer,  DWORD dwBufferLength,
+                                  DWORD *pdwBytesRead, WINHTTP_WEB_SOCKET_BUFFER_TYPE *peBufferType);
+    DWORD WinHttpWebSocketSend(HINTERNET hWebSocket, WINHTTP_WEB_SOCKET_BUFFER_TYPE eBufferType,
+                               PVOID pvBuffer, DWORD dwBufferLength);
+    DWORD WinHttpWebSocketShutdown(HINTERNET hWebSocket, USHORT usStatus, PVOID pvReason, DWORD dwReasonLength);
+  }
+}
diff --git a/libphobos/libdruntime/core/sys/windows/wininet.d b/libphobos/libdruntime/core/sys/windows/wininet.d
new file mode 100644
index 00000000000..862e405c291
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/wininet.d
@@ -0,0 +1,1248 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_wininet.d)
+ */
+module core.sys.windows.wininet;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "wininet");
+
+// FIXME: check types and grouping of constants
+
+import core.sys.windows.windows;
+
+enum {
+    INTERNET_INVALID_PORT_NUMBER =    0,
+    INTERNET_DEFAULT_FTP_PORT    =   21,
+    INTERNET_DEFAULT_GOPHER_PORT =   70,
+    INTERNET_DEFAULT_HTTP_PORT   =   80,
+    INTERNET_DEFAULT_HTTPS_PORT  =  443,
+    INTERNET_DEFAULT_SOCKS_PORT  = 1080
+}
+
+enum size_t
+    MAX_CACHE_ENTRY_INFO_SIZE       =  4096,
+    INTERNET_MAX_HOST_NAME_LENGTH   =   256,
+    INTERNET_MAX_USER_NAME_LENGTH   =   128,
+    INTERNET_MAX_PASSWORD_LENGTH    =   128,
+    INTERNET_MAX_PORT_NUMBER_LENGTH =     5,
+    INTERNET_MAX_PORT_NUMBER_VALUE  = 65535,
+    INTERNET_MAX_PATH_LENGTH        =  2048,
+    INTERNET_MAX_SCHEME_LENGTH      =    32,
+    INTERNET_MAX_URL_LENGTH         = INTERNET_MAX_SCHEME_LENGTH
+                                      + "://".length
+                                      + INTERNET_MAX_PATH_LENGTH;
+
+enum : DWORD {
+    INTERNET_KEEP_ALIVE_UNKNOWN  = DWORD.max,
+    INTERNET_KEEP_ALIVE_DISABLED = 0,
+    INTERNET_KEEP_ALIVE_ENABLED
+}
+
+enum {
+    INTERNET_REQFLAG_FROM_CACHE = 1,
+    INTERNET_REQFLAG_ASYNC      = 2
+}
+
+enum DWORD
+    INTERNET_FLAG_RELOAD                   = 0x80000000,
+    INTERNET_FLAG_RAW_DATA                 = 0x40000000,
+    INTERNET_FLAG_EXISTING_CONNECT         = 0x20000000,
+    INTERNET_FLAG_ASYNC                    = 0x10000000,
+    INTERNET_FLAG_PASSIVE                  = 0x08000000,
+    INTERNET_FLAG_NO_CACHE_WRITE           = 0x04000000,
+    INTERNET_FLAG_DONT_CACHE               = INTERNET_FLAG_NO_CACHE_WRITE,
+    INTERNET_FLAG_MAKE_PERSISTENT          = 0x02000000,
+    INTERNET_FLAG_OFFLINE                  = 0x01000000,
+    INTERNET_FLAG_SECURE                   = 0x00800000,
+    INTERNET_FLAG_KEEP_CONNECTION          = 0x00400000,
+    INTERNET_FLAG_NO_AUTO_REDIRECT         = 0x00200000,
+    INTERNET_FLAG_READ_PREFETCH            = 0x00100000,
+    INTERNET_FLAG_NO_COOKIES               = 0x00080000,
+    INTERNET_FLAG_NO_AUTH                  = 0x00040000,
+    INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP  = 0x00008000,
+    INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS = 0x00004000,
+    INTERNET_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000,
+    INTERNET_FLAG_IGNORE_CERT_CN_INVALID   = 0x00001000,
+    INTERNET_FLAG_RESYNCHRONIZE            = 0x00000800,
+    INTERNET_FLAG_HYPERLINK                = 0x00000400,
+    INTERNET_FLAG_NO_UI                    = 0x00000200,
+    INTERNET_FLAG_PRAGMA_NOCACHE           = 0x00000100,
+    INTERNET_FLAG_MUST_CACHE_REQUEST       = 0x00000010,
+    INTERNET_FLAG_TRANSFER_ASCII           = FTP_TRANSFER_TYPE_ASCII,
+    INTERNET_FLAG_TRANSFER_BINARY          = FTP_TRANSFER_TYPE_BINARY,
+
+    SECURITY_INTERNET_MASK                 = 0x0000F000,
+    SECURITY_SET_MASK                      = SECURITY_INTERNET_MASK,
+
+    INTERNET_FLAGS_MASK                    = 0xFFFCFE13,
+    INTERNET_OPTIONS_MASK                  = ~INTERNET_FLAGS_MASK;
+
+enum INTERNET_NO_CALLBACK = 0;
+enum INTERNET_RFC1123_FORMAT = 0;
+enum size_t INTERNET_RFC1123_BUFSIZE = 30;
+
+enum DWORD
+    ICU_ESCAPE             = 0x80000000,
+    ICU_USERNAME           = 0x40000000,
+    ICU_NO_ENCODE          = 0x20000000,
+    ICU_DECODE             = 0x10000000,
+    ICU_NO_META            = 0x08000000,
+    ICU_ENCODE_SPACES_ONLY = 0x04000000,
+    ICU_BROWSER_MODE       = 0x02000000;
+
+enum {
+    INTERNET_OPEN_TYPE_PRECONFIG = 0,
+    INTERNET_OPEN_TYPE_DIRECT    = 1,
+    INTERNET_OPEN_TYPE_PROXY     = 3,
+    PRE_CONFIG_INTERNET_ACCESS   = INTERNET_OPEN_TYPE_PRECONFIG,
+    LOCAL_INTERNET_ACCESS        = INTERNET_OPEN_TYPE_DIRECT,
+    GATEWAY_INTERNET_ACCESS      = 2,
+    CERN_PROXY_INTERNET_ACCESS   = INTERNET_OPEN_TYPE_PROXY,
+}
+
+enum ISO_GLOBAL      = 1;
+enum ISO_REGISTRY    = 2;
+enum ISO_VALID_FLAGS = ISO_GLOBAL | ISO_REGISTRY;
+
+enum {
+    INTERNET_OPTION_CALLBACK                    =  1,
+    INTERNET_OPTION_CONNECT_TIMEOUT,
+    INTERNET_OPTION_CONNECT_RETRIES,
+    INTERNET_OPTION_CONNECT_BACKOFF,
+    INTERNET_OPTION_SEND_TIMEOUT,
+    INTERNET_OPTION_CONTROL_SEND_TIMEOUT        = INTERNET_OPTION_SEND_TIMEOUT,
+    INTERNET_OPTION_RECEIVE_TIMEOUT,
+    INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT  = INTERNET_OPTION_RECEIVE_TIMEOUT,
+    INTERNET_OPTION_DATA_SEND_TIMEOUT,
+    INTERNET_OPTION_DATA_RECEIVE_TIMEOUT,
+    INTERNET_OPTION_HANDLE_TYPE,
+    INTERNET_OPTION_CONTEXT_VALUE,
+    INTERNET_OPTION_LISTEN_TIMEOUT,
+    INTERNET_OPTION_READ_BUFFER_SIZE,
+    INTERNET_OPTION_WRITE_BUFFER_SIZE,       // = 13
+    INTERNET_OPTION_ASYNC_ID                    = 15,
+    INTERNET_OPTION_ASYNC_PRIORITY,          // = 16
+    INTERNET_OPTION_PARENT_HANDLE               = 21,
+    INTERNET_OPTION_KEEP_CONNECTION,
+    INTERNET_OPTION_REQUEST_FLAGS,
+    INTERNET_OPTION_EXTENDED_ERROR,          // = 24
+    INTERNET_OPTION_OFFLINE_MODE                = 26,
+    INTERNET_OPTION_CACHE_STREAM_HANDLE,
+    INTERNET_OPTION_USERNAME,
+    INTERNET_OPTION_PASSWORD,
+    INTERNET_OPTION_ASYNC,
+    INTERNET_OPTION_SECURITY_FLAGS,
+    INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT,
+    INTERNET_OPTION_DATAFILE_NAME,
+    INTERNET_OPTION_URL,
+    INTERNET_OPTION_SECURITY_CERTIFICATE,
+    INTERNET_OPTION_SECURITY_KEY_BITNESS,
+    INTERNET_OPTION_REFRESH,
+    INTERNET_OPTION_PROXY,
+    INTERNET_OPTION_SETTINGS_CHANGED,
+    INTERNET_OPTION_VERSION,
+    INTERNET_OPTION_USER_AGENT,
+    INTERNET_OPTION_END_BROWSER_SESSION,
+    INTERNET_OPTION_PROXY_USERNAME,
+    INTERNET_OPTION_PROXY_PASSWORD,          // = 44
+    INTERNET_FIRST_OPTION                       = INTERNET_OPTION_CALLBACK,
+    // why?
+    INTERNET_LAST_OPTION                        = INTERNET_OPTION_USER_AGENT
+}
+
+enum INTERNET_PRIORITY_FOREGROUND = 1000;
+
+enum {
+    INTERNET_HANDLE_TYPE_INTERNET = 1,
+    INTERNET_HANDLE_TYPE_CONNECT_FTP,
+    INTERNET_HANDLE_TYPE_CONNECT_GOPHER,
+    INTERNET_HANDLE_TYPE_CONNECT_HTTP,
+    INTERNET_HANDLE_TYPE_FTP_FIND,
+    INTERNET_HANDLE_TYPE_FTP_FIND_HTML,
+    INTERNET_HANDLE_TYPE_FTP_FILE,
+    INTERNET_HANDLE_TYPE_FTP_FILE_HTML,
+    INTERNET_HANDLE_TYPE_GOPHER_FIND,
+    INTERNET_HANDLE_TYPE_GOPHER_FIND_HTML,
+    INTERNET_HANDLE_TYPE_GOPHER_FILE,
+    INTERNET_HANDLE_TYPE_GOPHER_FILE_HTML,
+    INTERNET_HANDLE_TYPE_HTTP_REQUEST
+}
+
+enum DWORD
+    SECURITY_FLAG_SECURE                   = 0x00000001,
+    SECURITY_FLAG_SSL                      = 0x00000002,
+    SECURITY_FLAG_SSL3                     = 0x00000004,
+    SECURITY_FLAG_PCT                      = 0x00000008,
+    SECURITY_FLAG_PCT4                     = 0x00000010,
+    SECURITY_FLAG_IETFSSL4                 = 0x00000020,
+    SECURITY_FLAG_IGNORE_REVOCATION        = 0x00000080,
+    SECURITY_FLAG_IGNORE_UNKNOWN_CA        = 0x00000100,
+    SECURITY_FLAG_IGNORE_WRONG_USAGE       = 0x00000200,
+    SECURITY_FLAG_40BIT                    = 0x10000000,
+    SECURITY_FLAG_128BIT                   = 0x20000000,
+    SECURITY_FLAG_56BIT                    = 0x40000000,
+    SECURITY_FLAG_UNKNOWNBIT               = 0x80000000,
+    SECURITY_FLAG_NORMALBITNESS            = SECURITY_FLAG_40BIT,
+    SECURITY_FLAG_IGNORE_CERT_CN_INVALID   = INTERNET_FLAG_IGNORE_CERT_CN_INVALID,
+    SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = INTERNET_FLAG_IGNORE_CERT_DATE_INVALID,
+    SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTPS = INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS,
+    SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTP  = INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP;
+
+enum {
+    INTERNET_SERVICE_FTP = 1,
+    INTERNET_SERVICE_GOPHER,
+    INTERNET_SERVICE_HTTP
+}
+
+enum {
+    INTERNET_STATUS_RESOLVING_NAME        =  10,
+    INTERNET_STATUS_NAME_RESOLVED         =  11,
+    INTERNET_STATUS_CONNECTING_TO_SERVER  =  20,
+    INTERNET_STATUS_CONNECTED_TO_SERVER   =  21,
+    INTERNET_STATUS_SENDING_REQUEST       =  30,
+    INTERNET_STATUS_REQUEST_SENT          =  31,
+    INTERNET_STATUS_RECEIVING_RESPONSE    =  40,
+    INTERNET_STATUS_RESPONSE_RECEIVED     =  41,
+    INTERNET_STATUS_CTL_RESPONSE_RECEIVED =  42,
+    INTERNET_STATUS_PREFETCH              =  43,
+    INTERNET_STATUS_CLOSING_CONNECTION    =  50,
+    INTERNET_STATUS_CONNECTION_CLOSED     =  51,
+    INTERNET_STATUS_HANDLE_CREATED        =  60,
+    INTERNET_STATUS_HANDLE_CLOSING        =  70,
+    INTERNET_STATUS_REQUEST_COMPLETE      = 100,
+    INTERNET_STATUS_REDIRECT              = 110
+}
+
+enum {
+    FTP_TRANSFER_TYPE_UNKNOWN = 0,
+    FTP_TRANSFER_TYPE_ASCII   = 1,
+    FTP_TRANSFER_TYPE_BINARY  = 2,
+    FTP_TRANSFER_TYPE_MASK    = 3
+}
+
+enum size_t
+    MAX_GOPHER_DISPLAY_TEXT   = 128,
+    MAX_GOPHER_SELECTOR_TEXT  = 256,
+    MAX_GOPHER_HOST_NAME      = INTERNET_MAX_HOST_NAME_LENGTH,
+    MAX_GOPHER_LOCATOR_LENGTH
+      = 1 + MAX_GOPHER_DISPLAY_TEXT + 1 + MAX_GOPHER_SELECTOR_TEXT + 1
+        + MAX_GOPHER_HOST_NAME + 1 + INTERNET_MAX_PORT_NUMBER_LENGTH + 4;
+
+enum DWORD
+    GOPHER_TYPE_TEXT_FILE      = 0x00000001,
+    GOPHER_TYPE_DIRECTORY      = 0x00000002,
+    GOPHER_TYPE_CSO            = 0x00000004,
+    GOPHER_TYPE_ERROR          = 0x00000008,
+    GOPHER_TYPE_MAC_BINHEX     = 0x00000010,
+    GOPHER_TYPE_DOS_ARCHIVE    = 0x00000020,
+    GOPHER_TYPE_UNIX_UUENCODED = 0x00000040,
+    GOPHER_TYPE_INDEX_SERVER   = 0x00000080,
+    GOPHER_TYPE_TELNET         = 0x00000100,
+    GOPHER_TYPE_BINARY         = 0x00000200,
+    GOPHER_TYPE_REDUNDANT      = 0x00000400,
+    GOPHER_TYPE_TN3270         = 0x00000800,
+    GOPHER_TYPE_GIF            = 0x00001000,
+    GOPHER_TYPE_IMAGE          = 0x00002000,
+    GOPHER_TYPE_BITMAP         = 0x00004000,
+    GOPHER_TYPE_MOVIE          = 0x00008000,
+    GOPHER_TYPE_SOUND          = 0x00010000,
+    GOPHER_TYPE_HTML           = 0x00020000,
+    GOPHER_TYPE_PDF            = 0x00040000,
+    GOPHER_TYPE_CALENDAR       = 0x00080000,
+    GOPHER_TYPE_INLINE         = 0x00100000,
+    GOPHER_TYPE_UNKNOWN        = 0x20000000,
+    GOPHER_TYPE_ASK            = 0x40000000,
+    GOPHER_TYPE_GOPHER_PLUS    = 0x80000000,
+    GOPHER_TYPE_FILE_MASK      = 0x001FF271;
+
+BOOL IS_GOPHER_FILE(DWORD t) {
+    return !!(t & GOPHER_TYPE_FILE_MASK);
+}
+
+BOOL IS_GOPHER_DIRECTORY(DWORD t) {
+    return !!(t & GOPHER_TYPE_DIRECTORY);
+}
+
+BOOL IS_GOPHER_PHONE_SERVER(DWORD t) {
+    return !!(t & GOPHER_TYPE_CSO);
+}
+
+BOOL IS_GOPHER_ERROR(DWORD t) {
+    return !!(t & GOPHER_TYPE_ERROR);
+}
+
+BOOL IS_GOPHER_INDEX_SERVER(DWORD t) {
+    return !!(t & GOPHER_TYPE_INDEX_SERVER);
+}
+
+BOOL IS_GOPHER_TELNET_SESSION(DWORD t) {
+    return !!(t & GOPHER_TYPE_TELNET);
+}
+
+BOOL IS_GOPHER_BACKUP_SERVER(DWORD t) {
+    return !!(t & GOPHER_TYPE_REDUNDANT);
+}
+
+BOOL IS_GOPHER_TN3270_SESSION(DWORD t) {
+    return !!(t & GOPHER_TYPE_TN3270);
+}
+
+BOOL IS_GOPHER_ASK(DWORD t) {
+    return !!(t & GOPHER_TYPE_ASK);
+}
+
+BOOL IS_GOPHER_PLUS(DWORD t) {
+    return !!(t & GOPHER_TYPE_GOPHER_PLUS);
+}
+
+BOOL IS_GOPHER_TYPE_KNOWN(DWORD t) {
+    return !(t & GOPHER_TYPE_UNKNOWN);
+}
+
+enum size_t
+    MAX_GOPHER_CATEGORY_NAME    = 128,
+    MAX_GOPHER_ATTRIBUTE_NAME   = 128,
+    MIN_GOPHER_ATTRIBUTE_LENGTH = 256;
+
+const TCHAR[]
+    GOPHER_INFO_CATEGORY      = "+INFO",
+    GOPHER_ADMIN_CATEGORY     = "+ADMIN",
+    GOPHER_VIEWS_CATEGORY     = "+VIEWS",
+    GOPHER_ABSTRACT_CATEGORY  = "+ABSTRACT",
+    GOPHER_VERONICA_CATEGORY  = "+VERONICA",
+    GOPHER_ADMIN_ATTRIBUTE    = "Admin",
+    GOPHER_MOD_DATE_ATTRIBUTE = "Mod-Date",
+    GOPHER_TTL_ATTRIBUTE      = "TTL",
+    GOPHER_SCORE_ATTRIBUTE    = "Score",
+    GOPHER_RANGE_ATTRIBUTE    = "Score-range",
+    GOPHER_SITE_ATTRIBUTE     = "Site",
+    GOPHER_ORG_ATTRIBUTE      = "Org",
+    GOPHER_LOCATION_ATTRIBUTE = "Loc",
+    GOPHER_GEOG_ATTRIBUTE     = "Geog",
+    GOPHER_TIMEZONE_ATTRIBUTE = "TZ",
+    GOPHER_PROVIDER_ATTRIBUTE = "Provider",
+    GOPHER_VERSION_ATTRIBUTE  = "Version",
+    GOPHER_ABSTRACT_ATTRIBUTE = "Abstract",
+    GOPHER_VIEW_ATTRIBUTE     = "View",
+    GOPHER_TREEWALK_ATTRIBUTE = "treewalk";
+
+enum : DWORD {
+    GOPHER_ATTRIBUTE_ID_BASE = 0xABCCCC00,
+    GOPHER_CATEGORY_ID_ALL,
+    GOPHER_CATEGORY_ID_INFO,
+    GOPHER_CATEGORY_ID_ADMIN,
+    GOPHER_CATEGORY_ID_VIEWS,
+    GOPHER_CATEGORY_ID_ABSTRACT,
+    GOPHER_CATEGORY_ID_VERONICA,
+    GOPHER_CATEGORY_ID_ASK,
+    GOPHER_CATEGORY_ID_UNKNOWN,
+    GOPHER_ATTRIBUTE_ID_ALL,
+    GOPHER_ATTRIBUTE_ID_ADMIN,
+    GOPHER_ATTRIBUTE_ID_MOD_DATE,
+    GOPHER_ATTRIBUTE_ID_TTL,
+    GOPHER_ATTRIBUTE_ID_SCORE,
+    GOPHER_ATTRIBUTE_ID_RANGE,
+    GOPHER_ATTRIBUTE_ID_SITE,
+    GOPHER_ATTRIBUTE_ID_ORG,
+    GOPHER_ATTRIBUTE_ID_LOCATION,
+    GOPHER_ATTRIBUTE_ID_GEOG,
+    GOPHER_ATTRIBUTE_ID_TIMEZONE,
+    GOPHER_ATTRIBUTE_ID_PROVIDER,
+    GOPHER_ATTRIBUTE_ID_VERSION,
+    GOPHER_ATTRIBUTE_ID_ABSTRACT,
+    GOPHER_ATTRIBUTE_ID_VIEW,
+    GOPHER_ATTRIBUTE_ID_TREEWALK,
+    GOPHER_ATTRIBUTE_ID_UNKNOWN
+}
+
+enum HTTP_MAJOR_VERSION   = 1;
+enum HTTP_MINOR_VERSION   = 0;
+const TCHAR[] HTTP_VERSION = "HTTP/1.0";
+
+enum : DWORD {
+    HTTP_QUERY_MIME_VERSION,
+    HTTP_QUERY_CONTENT_TYPE,
+    HTTP_QUERY_CONTENT_TRANSFER_ENCODING,
+    HTTP_QUERY_CONTENT_ID,
+    HTTP_QUERY_CONTENT_DESCRIPTION,
+    HTTP_QUERY_CONTENT_LENGTH,
+    HTTP_QUERY_CONTENT_LANGUAGE,
+    HTTP_QUERY_ALLOW,
+    HTTP_QUERY_PUBLIC,
+    HTTP_QUERY_DATE,
+    HTTP_QUERY_EXPIRES,
+    HTTP_QUERY_LAST_MODIFIED,
+    HTTP_QUERY_MESSAGE_ID,
+    HTTP_QUERY_URI,
+    HTTP_QUERY_DERIVED_FROM,
+    HTTP_QUERY_COST,
+    HTTP_QUERY_LINK,
+    HTTP_QUERY_PRAGMA,
+    HTTP_QUERY_VERSION,
+    HTTP_QUERY_STATUS_CODE,
+    HTTP_QUERY_STATUS_TEXT,
+    HTTP_QUERY_RAW_HEADERS,
+    HTTP_QUERY_RAW_HEADERS_CRLF,
+    HTTP_QUERY_CONNECTION,
+    HTTP_QUERY_ACCEPT,
+    HTTP_QUERY_ACCEPT_CHARSET,
+    HTTP_QUERY_ACCEPT_ENCODING,
+    HTTP_QUERY_ACCEPT_LANGUAGE,
+    HTTP_QUERY_AUTHORIZATION,
+    HTTP_QUERY_CONTENT_ENCODING,
+    HTTP_QUERY_FORWARDED,
+    HTTP_QUERY_FROM,
+    HTTP_QUERY_IF_MODIFIED_SINCE,
+    HTTP_QUERY_LOCATION,
+    HTTP_QUERY_ORIG_URI,
+    HTTP_QUERY_REFERER,
+    HTTP_QUERY_RETRY_AFTER,
+    HTTP_QUERY_SERVER,
+    HTTP_QUERY_TITLE,
+    HTTP_QUERY_USER_AGENT,
+    HTTP_QUERY_WWW_AUTHENTICATE,
+    HTTP_QUERY_PROXY_AUTHENTICATE,
+    HTTP_QUERY_ACCEPT_RANGES,
+    HTTP_QUERY_SET_COOKIE,
+    HTTP_QUERY_COOKIE,
+    HTTP_QUERY_REQUEST_METHOD,
+    HTTP_QUERY_MAX    = 45,
+    HTTP_QUERY_CUSTOM = 65535
+}
+
+enum DWORD
+    HTTP_QUERY_FLAG_REQUEST_HEADERS = 0x80000000,
+    HTTP_QUERY_FLAG_SYSTEMTIME      = 0x40000000,
+    HTTP_QUERY_FLAG_NUMBER          = 0x20000000,
+    HTTP_QUERY_FLAG_COALESCE        = 0x10000000,
+    HTTP_QUERY_MODIFIER_FLAGS_MASK  = 0xF0000000,
+    HTTP_QUERY_HEADER_MASK          = ~HTTP_QUERY_MODIFIER_FLAGS_MASK;
+
+enum {
+    HTTP_STATUS_OK                 = 200,
+    HTTP_STATUS_CREATED,
+    HTTP_STATUS_ACCEPTED,
+    HTTP_STATUS_PARTIAL,
+    HTTP_STATUS_NO_CONTENT,     // = 204
+    HTTP_STATUS_AMBIGUOUS          = 300,
+    HTTP_STATUS_MOVED,
+    HTTP_STATUS_REDIRECT,
+    HTTP_STATUS_REDIRECT_METHOD,
+    HTTP_STATUS_NOT_MODIFIED,   // = 304
+    HTTP_STATUS_BAD_REQUEST        = 400,
+    HTTP_STATUS_DENIED,
+    HTTP_STATUS_PAYMENT_REQ,
+    HTTP_STATUS_FORBIDDEN,
+    HTTP_STATUS_NOT_FOUND,
+    HTTP_STATUS_BAD_METHOD,
+    HTTP_STATUS_NONE_ACCEPTABLE,
+    HTTP_STATUS_PROXY_AUTH_REQ,
+    HTTP_STATUS_REQUEST_TIMEOUT,
+    HTTP_STATUS_CONFLICT,
+    HTTP_STATUS_GONE,
+    HTTP_STATUS_AUTH_REFUSED,   // = 411
+    HTTP_STATUS_SERVER_ERROR       = 500,
+    HTTP_STATUS_NOT_SUPPORTED,
+    HTTP_STATUS_BAD_GATEWAY,
+    HTTP_STATUS_SERVICE_UNAVAIL,
+    HTTP_STATUS_GATEWAY_TIMEOUT // = 504
+}
+
+enum {
+    INTERNET_PREFETCH_PROGRESS,
+    INTERNET_PREFETCH_COMPLETE,
+    INTERNET_PREFETCH_ABORTED
+}
+
+enum FLAGS_ERROR_UI_FILTER_FOR_ERRORS    = 0x01;
+enum FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS = 0x02;
+enum FLAGS_ERROR_UI_FLAGS_GENERATE_DATA  = 0x04;
+enum FLAGS_ERROR_UI_FLAGS_NO_UI          = 0x08;
+
+enum DWORD
+    HTTP_ADDREQ_INDEX_MASK                   = 0x0000FFFF,
+    HTTP_ADDREQ_FLAGS_MASK                   = 0xFFFF0000,
+    HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON = 0x01000000,
+    HTTP_ADDREQ_FLAG_ADD_IF_NEW              = 0x10000000,
+    HTTP_ADDREQ_FLAG_ADD                     = 0x20000000,
+    HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA     = 0x40000000,
+    HTTP_ADDREQ_FLAG_COALESCE          = HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA,
+    HTTP_ADDREQ_FLAG_REPLACE                 = 0x80000000;
+
+enum {
+    INTERNET_ERROR_BASE                       = 12000,
+    ERROR_INTERNET_OUT_OF_HANDLES,
+    ERROR_INTERNET_TIMEOUT,
+    ERROR_INTERNET_EXTENDED_ERROR,
+    ERROR_INTERNET_INTERNAL_ERROR,
+    ERROR_INTERNET_INVALID_URL,
+    ERROR_INTERNET_UNRECOGNIZED_SCHEME,
+    ERROR_INTERNET_NAME_NOT_RESOLVED,
+    ERROR_INTERNET_PROTOCOL_NOT_FOUND,
+    ERROR_INTERNET_INVALID_OPTION,
+    ERROR_INTERNET_BAD_OPTION_LENGTH,
+    ERROR_INTERNET_OPTION_NOT_SETTABLE,
+    ERROR_INTERNET_SHUTDOWN,
+    ERROR_INTERNET_INCORRECT_USER_NAME,
+    ERROR_INTERNET_INCORRECT_PASSWORD,
+    ERROR_INTERNET_LOGIN_FAILURE,
+    ERROR_INTERNET_INVALID_OPERATION,
+    ERROR_INTERNET_OPERATION_CANCELLED,
+    ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
+    ERROR_INTERNET_INCORRECT_HANDLE_STATE,
+    ERROR_INTERNET_NOT_PROXY_REQUEST,
+    ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND,
+    ERROR_INTERNET_BAD_REGISTRY_PARAMETER,
+    ERROR_INTERNET_NO_DIRECT_ACCESS,
+    ERROR_INTERNET_NO_CONTEXT,
+    ERROR_INTERNET_NO_CALLBACK,
+    ERROR_INTERNET_REQUEST_PENDING,
+    ERROR_INTERNET_INCORRECT_FORMAT,
+    ERROR_INTERNET_ITEM_NOT_FOUND,
+    ERROR_INTERNET_CANNOT_CONNECT,
+    ERROR_INTERNET_CONNECTION_ABORTED,
+    ERROR_INTERNET_CONNECTION_RESET,
+    ERROR_INTERNET_FORCE_RETRY,
+    ERROR_INTERNET_INVALID_PROXY_REQUEST,
+    ERROR_INTERNET_NEED_UI,                // = INTERNET_ERROR_BASE +  34
+    ERROR_INTERNET_HANDLE_EXISTS              = INTERNET_ERROR_BASE +  36,
+    ERROR_INTERNET_SEC_CERT_DATE_INVALID,
+    ERROR_INTERNET_SEC_CERT_CN_INVALID,
+    ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR,
+    ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR,
+    ERROR_INTERNET_MIXED_SECURITY,
+    ERROR_INTERNET_CHG_POST_IS_NON_SECURE,
+    ERROR_INTERNET_POST_IS_NON_SECURE,
+    ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED,
+    ERROR_INTERNET_INVALID_CA,
+    ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP,
+    ERROR_INTERNET_ASYNC_THREAD_FAILED,
+    ERROR_INTERNET_REDIRECT_SCHEME_CHANGE, // = INTERNET_ERROR_BASE +  48
+
+    ERROR_FTP_TRANSFER_IN_PROGRESS            = INTERNET_ERROR_BASE + 110,
+    ERROR_FTP_DROPPED,                     // = INTERNET_ERROR_BASE + 111
+    ERROR_GOPHER_PROTOCOL_ERROR               = INTERNET_ERROR_BASE + 130,
+    ERROR_GOPHER_NOT_FILE,
+    ERROR_GOPHER_DATA_ERROR,
+    ERROR_GOPHER_END_OF_DATA,
+    ERROR_GOPHER_INVALID_LOCATOR,
+    ERROR_GOPHER_INCORRECT_LOCATOR_TYPE,
+    ERROR_GOPHER_NOT_GOPHER_PLUS,
+    ERROR_GOPHER_ATTRIBUTE_NOT_FOUND,
+    ERROR_GOPHER_UNKNOWN_LOCATOR,          // = INTERNET_ERROR_BASE + 138,
+    ERROR_HTTP_HEADER_NOT_FOUND               = INTERNET_ERROR_BASE + 150,
+    ERROR_HTTP_DOWNLEVEL_SERVER,
+    ERROR_HTTP_INVALID_SERVER_RESPONSE,
+    ERROR_HTTP_INVALID_HEADER,
+    ERROR_HTTP_INVALID_QUERY_REQUEST,
+    ERROR_HTTP_HEADER_ALREADY_EXISTS,
+    ERROR_HTTP_REDIRECT_FAILED,
+    ERROR_INTERNET_SECURITY_CHANNEL_ERROR,
+    ERROR_INTERNET_UNABLE_TO_CACHE_FILE,
+    ERROR_INTERNET_TCPIP_NOT_INSTALLED,
+    ERROR_HTTP_NOT_REDIRECTED,             // = INTERNET_ERROR_BASE + 160
+    // why?
+    INTERNET_ERROR_LAST                  = ERROR_INTERNET_TCPIP_NOT_INSTALLED
+}
+
+
+enum NORMAL_CACHE_ENTRY     = 0x000001;
+enum STABLE_CACHE_ENTRY     = 0x000002;
+enum STICKY_CACHE_ENTRY     = 0x000004;
+enum SPARSE_CACHE_ENTRY     = 0x010000;
+enum OCX_CACHE_ENTRY        = 0x020000;
+enum COOKIE_CACHE_ENTRY     = 0x100000;
+enum URLHISTORY_CACHE_ENTRY = 0x200000;
+
+enum CACHE_ENTRY_ATTRIBUTE_FC  = 0x0004;
+enum CACHE_ENTRY_HITRATE_FC    = 0x0010;
+enum CACHE_ENTRY_MODTIME_FC    = 0x0040;
+enum CACHE_ENTRY_EXPTIME_FC    = 0x0080;
+enum CACHE_ENTRY_ACCTIME_FC    = 0x0100;
+enum CACHE_ENTRY_SYNCTIME_FC   = 0x0200;
+enum CACHE_ENTRY_HEADERINFO_FC = 0x0400;
+
+enum {
+    WININET_API_FLAG_ASYNC       = 1,
+    WININET_API_FLAG_SYNC        = 4,
+    WININET_API_FLAG_USE_CONTEXT = 8
+}
+
+// FIXME: how should these really be grouped?
+enum {
+    IRF_ASYNC       = WININET_API_FLAG_ASYNC,
+    IRF_SYNC        = WININET_API_FLAG_SYNC,
+    IRF_USE_CONTEXT = WININET_API_FLAG_USE_CONTEXT,
+}
+enum IRF_NO_WAIT = 8;
+
+enum {
+    HSR_ASYNC = WININET_API_FLAG_ASYNC,
+    HSR_SYNC = WININET_API_FLAG_SYNC,
+    HSR_USE_CONTEXT = WININET_API_FLAG_USE_CONTEXT,
+}
+
+enum HSR_INITIATE =  8;
+enum HSR_DOWNLOAD = 16;
+enum HSR_CHUNKED  = 32;
+
+enum INTERNET_DIAL_UNATTENDED              = 0x8000;
+enum INTERNET_DIALSTATE_DISCONNECTED       = 1;
+enum INTERENT_GOONLINE_REFRESH             = 1;
+enum INTERENT_GOONLINE_MASK                = 1;
+enum INTERNET_AUTODIAL_FORCE_ONLINE        = 1;
+enum INTERNET_AUTODIAL_FORCE_UNATTENDED    = 2;
+enum INTERNET_AUTODIAL_FAILIFSECURITYCHECK = 4;
+enum INTERNET_CONNECTION_MODEM             = 0x01;
+enum INTERNET_CONNECTION_LAN               = 0x02;
+enum INTERNET_CONNECTION_PROXY             = 0x04;
+enum INTERNET_CONNECTION_MODEM_BUSY        = 0x08;
+enum INTERNET_RAS_INSTALLED                = 0x10;
+enum INTERNET_CONNECTION_OFFLINE           = 0x20;
+enum INTERNET_CONNECTION_CONFIGURED        = 0x40;
+
+enum {
+    CACHEGROUP_SEARCH_ALL   = 0,
+    CACHEGROUP_SEARCH_BYURL = 1
+}
+
+enum {
+    INTERNET_CACHE_GROUP_ADD    = 0,
+    INTERNET_CACHE_GROUP_REMOVE = 1
+}
+
+mixin DECLARE_HANDLE!("HINTERNET"); // doesn't work - bug
+/*struct HINTERNET {
+    HANDLE h;
+    alias h this;
+}*/
+alias HINTERNET* LPHINTERNET;
+
+alias LONGLONG GROUPID;
+alias WORD INTERNET_PORT;
+alias WORD* LPINTERNET_PORT;
+
+enum INTERNET_SCHEME {
+    INTERNET_SCHEME_PARTIAL = -2,
+    INTERNET_SCHEME_UNKNOWN,
+    INTERNET_SCHEME_DEFAULT,
+    INTERNET_SCHEME_FTP,
+    INTERNET_SCHEME_GOPHER,
+    INTERNET_SCHEME_HTTP,
+    INTERNET_SCHEME_HTTPS,
+    INTERNET_SCHEME_FILE,
+    INTERNET_SCHEME_NEWS,
+    INTERNET_SCHEME_MAILTO,
+    INTERNET_SCHEME_SOCKS,
+    INTERNET_SCHEME_FIRST = INTERNET_SCHEME_FTP,
+    INTERNET_SCHEME_LAST = INTERNET_SCHEME_SOCKS
+}
+alias INTERNET_SCHEME* LPINTERNET_SCHEME;
+
+struct INTERNET_ASYNC_RESULT {
+    DWORD dwResult;
+    DWORD dwError;
+}
+alias INTERNET_ASYNC_RESULT* LPINTERNET_ASYNC_RESULT;
+
+struct INTERNET_PREFETCH_STATUS {
+    DWORD dwStatus;
+    DWORD dwSize;
+}
+alias INTERNET_PREFETCH_STATUS* LPINTERNET_PREFETCH_STATUS;
+
+struct INTERNET_PROXY_INFO {
+    DWORD dwAccessType;
+    LPCTSTR lpszProxy;
+    LPCTSTR lpszProxyBypass;
+}
+alias INTERNET_PROXY_INFO* LPINTERNET_PROXY_INFO;
+
+struct INTERNET_VERSION_INFO {
+    DWORD dwMajorVersion;
+    DWORD dwMinorVersion;
+}
+alias INTERNET_VERSION_INFO* LPINTERNET_VERSION_INFO;
+
+struct URL_COMPONENTSA {
+    DWORD           dwStructSize = URL_COMPONENTSA.sizeof;
+    LPSTR           lpszScheme;
+    DWORD           dwSchemeLength;
+    INTERNET_SCHEME nScheme;
+    LPSTR           lpszHostName;
+    DWORD           dwHostNameLength;
+    INTERNET_PORT   nPort;
+    LPSTR           lpszUserName;
+    DWORD           dwUserNameLength;
+    LPSTR           lpszPassword;
+    DWORD           dwPasswordLength;
+    LPSTR           lpszUrlPath;
+    DWORD           dwUrlPathLength;
+    LPSTR           lpszExtraInfo;
+    DWORD           dwExtraInfoLength;
+}
+alias URL_COMPONENTSA* LPURL_COMPONENTSA;
+
+struct URL_COMPONENTSW {
+    DWORD  dwStructSize = URL_COMPONENTSW.sizeof;
+    LPWSTR lpszScheme;
+    DWORD  dwSchemeLength;
+    INTERNET_SCHEME nScheme;
+    LPWSTR lpszHostName;
+    DWORD  dwHostNameLength;
+    INTERNET_PORT nPort;
+    LPWSTR lpszUserName;
+    DWORD  dwUserNameLength;
+    LPWSTR lpszPassword;
+    DWORD  dwPasswordLength;
+    LPWSTR lpszUrlPath;
+    DWORD  dwUrlPathLength;
+    LPWSTR lpszExtraInfo;
+    DWORD  dwExtraInfoLength;
+}
+alias URL_COMPONENTSW* LPURL_COMPONENTSW;
+
+struct INTERNET_CERTIFICATE_INFO {
+    FILETIME ftExpiry;
+    FILETIME ftStart;
+    LPTSTR   lpszSubjectInfo;
+    LPTSTR   lpszIssuerInfo;
+    LPTSTR   lpszProtocolName;
+    LPTSTR   lpszSignatureAlgName;
+    LPTSTR   lpszEncryptionAlgName;
+    DWORD    dwKeySize;
+}
+alias INTERNET_CERTIFICATE_INFO* LPINTERNET_CERTIFICATE_INFO;
+
+extern (Windows) alias void function(HINTERNET, DWORD, DWORD, PVOID, DWORD)
+  INTERNET_STATUS_CALLBACK;
+alias INTERNET_STATUS_CALLBACK* LPINTERNET_STATUS_CALLBACK;
+
+enum INTERNET_INVALID_STATUS_CALLBACK
+  = cast(INTERNET_STATUS_CALLBACK) -1;
+
+struct GOPHER_FIND_DATAA {
+    CHAR[MAX_GOPHER_DISPLAY_TEXT+1] DisplayString;
+    DWORD    GopherType;
+    DWORD    SizeLow;
+    DWORD    SizeHigh;
+    FILETIME LastModificationTime;
+    CHAR[MAX_GOPHER_LOCATOR_LENGTH+1] Locator;
+}
+alias GOPHER_FIND_DATAA* LPGOPHER_FIND_DATAA;
+
+struct GOPHER_FIND_DATAW {
+    WCHAR[MAX_GOPHER_DISPLAY_TEXT+1] DisplayString;
+    DWORD    GopherType;
+    DWORD    SizeLow;
+    DWORD    SizeHigh;
+    FILETIME LastModificationTime;
+    WCHAR[MAX_GOPHER_LOCATOR_LENGTH+1] Locator;
+}
+alias GOPHER_FIND_DATAW* LPGOPHER_FIND_DATAW;
+
+struct GOPHER_ADMIN_ATTRIBUTE_TYPE {
+    LPCTSTR Comment;
+    LPCTSTR EmailAddress;
+}
+alias GOPHER_ADMIN_ATTRIBUTE_TYPE* LPGOPHER_ADMIN_ATTRIBUTE_TYPE;
+
+struct GOPHER_MOD_DATE_ATTRIBUTE_TYPE {
+    FILETIME DateAndTime;
+}
+alias GOPHER_MOD_DATE_ATTRIBUTE_TYPE* LPGOPHER_MOD_DATE_ATTRIBUTE_TYPE;
+
+struct GOPHER_TTL_ATTRIBUTE_TYPE {
+    DWORD Ttl;
+}
+alias GOPHER_TTL_ATTRIBUTE_TYPE* LPGOPHER_TTL_ATTRIBUTE_TYPE;
+
+struct GOPHER_SCORE_ATTRIBUTE_TYPE {
+    INT Score;
+}
+alias GOPHER_SCORE_ATTRIBUTE_TYPE* LPGOPHER_SCORE_ATTRIBUTE_TYPE;
+
+struct GOPHER_SCORE_RANGE_ATTRIBUTE_TYPE {
+    INT LowerBound;
+    INT UpperBound;
+}
+alias GOPHER_SCORE_RANGE_ATTRIBUTE_TYPE* LPGOPHER_SCORE_RANGE_ATTRIBUTE_TYPE;
+
+struct GOPHER_SITE_ATTRIBUTE_TYPE {
+    LPCTSTR Site;
+}
+alias GOPHER_SITE_ATTRIBUTE_TYPE* LPGOPHER_SITE_ATTRIBUTE_TYPE;
+
+struct GOPHER_ORGANIZATION_ATTRIBUTE_TYPE {
+    LPCTSTR Organization;
+}
+alias GOPHER_ORGANIZATION_ATTRIBUTE_TYPE* LPGOPHER_ORGANIZATION_ATTRIBUTE_TYPE;
+
+struct GOPHER_LOCATION_ATTRIBUTE_TYPE {
+    LPCTSTR Location;
+}
+alias GOPHER_LOCATION_ATTRIBUTE_TYPE* LPGOPHER_LOCATION_ATTRIBUTE_TYPE;
+
+struct GOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE {
+    INT DegreesNorth;
+    INT MinutesNorth;
+    INT SecondsNorth;
+    INT DegreesEast;
+    INT MinutesEast;
+    INT SecondsEast;
+}
+alias GOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE*
+  LPGOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE;
+
+struct GOPHER_TIMEZONE_ATTRIBUTE_TYPE {
+    INT Zone;
+}
+alias GOPHER_TIMEZONE_ATTRIBUTE_TYPE* LPGOPHER_TIMEZONE_ATTRIBUTE_TYPE;
+
+struct GOPHER_PROVIDER_ATTRIBUTE_TYPE {
+    LPCTSTR Provider;
+}
+alias GOPHER_PROVIDER_ATTRIBUTE_TYPE* LPGOPHER_PROVIDER_ATTRIBUTE_TYPE;
+
+struct GOPHER_VERSION_ATTRIBUTE_TYPE {
+    LPCTSTR Version;
+}
+alias GOPHER_VERSION_ATTRIBUTE_TYPE* LPGOPHER_VERSION_ATTRIBUTE_TYPE;
+
+struct GOPHER_ABSTRACT_ATTRIBUTE_TYPE {
+    LPCTSTR ShortAbstract;
+    LPCTSTR AbstractFile;
+}
+alias GOPHER_ABSTRACT_ATTRIBUTE_TYPE* LPGOPHER_ABSTRACT_ATTRIBUTE_TYPE;
+
+struct GOPHER_VIEW_ATTRIBUTE_TYPE {
+    LPCTSTR ContentType;
+    LPCTSTR Language;
+    DWORD   Size;
+}
+alias GOPHER_VIEW_ATTRIBUTE_TYPE* LPGOPHER_VIEW_ATTRIBUTE_TYPE;
+
+struct GOPHER_VERONICA_ATTRIBUTE_TYPE {
+    BOOL TreeWalk;
+}
+alias GOPHER_VERONICA_ATTRIBUTE_TYPE* LPGOPHER_VERONICA_ATTRIBUTE_TYPE;
+
+struct GOPHER_ASK_ATTRIBUTE_TYPE {
+    LPCTSTR QuestionType;
+    LPCTSTR QuestionText;
+}
+alias GOPHER_ASK_ATTRIBUTE_TYPE* LPGOPHER_ASK_ATTRIBUTE_TYPE;
+
+struct GOPHER_UNKNOWN_ATTRIBUTE_TYPE {
+    LPCTSTR Text;
+}
+alias GOPHER_UNKNOWN_ATTRIBUTE_TYPE* LPGOPHER_UNKNOWN_ATTRIBUTE_TYPE;
+
+struct GOPHER_ATTRIBUTE_TYPE {
+    DWORD CategoryId;
+    DWORD AttributeId;
+    union {
+        GOPHER_ADMIN_ATTRIBUTE_TYPE                 Admin;
+        GOPHER_MOD_DATE_ATTRIBUTE_TYPE              ModDate;
+        GOPHER_TTL_ATTRIBUTE_TYPE                   Ttl;
+        GOPHER_SCORE_ATTRIBUTE_TYPE                 Score;
+        GOPHER_SCORE_RANGE_ATTRIBUTE_TYPE           ScoreRange;
+        GOPHER_SITE_ATTRIBUTE_TYPE                  Site;
+        GOPHER_ORGANIZATION_ATTRIBUTE_TYPE          Organization;
+        GOPHER_LOCATION_ATTRIBUTE_TYPE              Location;
+        GOPHER_GEOGRAPHICAL_LOCATION_ATTRIBUTE_TYPE GeographicalLocation;
+        GOPHER_TIMEZONE_ATTRIBUTE_TYPE              TimeZone;
+        GOPHER_PROVIDER_ATTRIBUTE_TYPE              Provider;
+        GOPHER_VERSION_ATTRIBUTE_TYPE               Version;
+        GOPHER_ABSTRACT_ATTRIBUTE_TYPE              Abstract;
+        GOPHER_VIEW_ATTRIBUTE_TYPE                  View;
+        GOPHER_VERONICA_ATTRIBUTE_TYPE              Veronica;
+        GOPHER_ASK_ATTRIBUTE_TYPE                   Ask;
+        GOPHER_UNKNOWN_ATTRIBUTE_TYPE               Unknown;
+    } /+AttributeType;+/
+}
+alias GOPHER_ATTRIBUTE_TYPE* LPGOPHER_ATTRIBUTE_TYPE;
+
+alias BOOL function(LPGOPHER_ATTRIBUTE_TYPE, DWORD)
+  GOPHER_ATTRIBUTE_ENUMERATOR;
+
+struct INTERNET_CACHE_ENTRY_INFOA {
+    DWORD    dwStructSize = INTERNET_CACHE_ENTRY_INFOA.sizeof;
+    LPSTR    lpszSourceUrlName;
+    LPSTR    lpszLocalFileName;
+    DWORD    CacheEntryType;
+    DWORD    dwUseCount;
+    DWORD    dwHitRate;
+    DWORD    dwSizeLow;
+    DWORD    dwSizeHigh;
+    FILETIME LastModifiedTime;
+    FILETIME ExpireTime;
+    FILETIME LastAccessTime;
+    FILETIME LastSyncTime;
+    PBYTE    lpHeaderInfo;
+    DWORD    dwHeaderInfoSize;
+    LPSTR    lpszFileExtension;
+    DWORD    dwReserved;
+}
+alias INTERNET_CACHE_ENTRY_INFOA* LPINTERNET_CACHE_ENTRY_INFOA;
+
+struct INTERNET_CACHE_ENTRY_INFOW {
+    DWORD    dwStructSize = INTERNET_CACHE_ENTRY_INFOW.sizeof;
+    LPWSTR   lpszSourceUrlName;
+    LPWSTR   lpszLocalFileName;
+    DWORD    CacheEntryType;
+    DWORD    dwUseCount;
+    DWORD    dwHitRate;
+    DWORD    dwSizeLow;
+    DWORD    dwSizeHigh;
+    FILETIME LastModifiedTime;
+    FILETIME ExpireTime;
+    FILETIME LastAccessTime;
+    FILETIME LastSyncTime;
+    PBYTE    lpHeaderInfo;
+    DWORD    dwHeaderInfoSize;
+    LPWSTR   lpszFileExtension;
+    DWORD    dwReserved;
+}
+alias INTERNET_CACHE_ENTRY_INFOW* LPINTERNET_CACHE_ENTRY_INFOW;
+
+struct INTERNET_BUFFERSA {
+    DWORD              dwStructSize = INTERNET_BUFFERSA.sizeof;
+    INTERNET_BUFFERSA* Next;
+    LPCSTR             lpcszHeader;
+    DWORD              dwHeadersLength;
+    DWORD              dwHeadersTotal;
+    LPVOID             lpvBuffer;
+    DWORD              dwBufferLength;
+    DWORD              dwBufferTotal;
+    DWORD              dwOffsetLow;
+    DWORD              dwOffsetHigh;
+}
+alias INTERNET_BUFFERSA* LPINTERNET_BUFFERSA;
+
+struct INTERNET_BUFFERSW {
+    DWORD              dwStructSize = INTERNET_BUFFERSW.sizeof;
+    INTERNET_BUFFERSW* Next;
+    LPCWSTR            lpcszHeader;
+    DWORD              dwHeadersLength;
+    DWORD              dwHeadersTotal;
+    LPVOID             lpvBuffer;
+    DWORD              dwBufferLength;
+    DWORD              dwBufferTotal;
+    DWORD              dwOffsetLow;
+    DWORD              dwOffsetHigh;
+}
+alias INTERNET_BUFFERSW* LPINTERNET_BUFFERSW;
+
+enum size_t
+    GROUP_OWNER_STORAGE_SIZE =   4,
+    GROUPNAME_MAX_LENGTH     = 120;
+
+struct INTERNET_CACHE_GROUP_INFOA {
+    DWORD dwGroupSize;
+    DWORD dwGroupFlags;
+    DWORD dwGroupType;
+    DWORD dwDiskUsage;
+    DWORD dwDiskQuota;
+    DWORD[GROUP_OWNER_STORAGE_SIZE] dwOwnerStorage;
+    CHAR[GROUPNAME_MAX_LENGTH]      szGroupName;
+}
+alias INTERNET_CACHE_GROUP_INFOA* LPINTERNET_CACHE_GROUP_INFOA;
+
+struct INTERNET_CACHE_GROUP_INFOW {
+    DWORD dwGroupSize;
+    DWORD dwGroupFlags;
+    DWORD dwGroupType;
+    DWORD dwDiskUsage;
+    DWORD dwDiskQuota;
+    DWORD[GROUP_OWNER_STORAGE_SIZE] dwOwnerStorage;
+    WCHAR[GROUPNAME_MAX_LENGTH]     szGroupName;
+}
+alias INTERNET_CACHE_GROUP_INFOW* LPINTERNET_CACHE_GROUP_INFOW;
+
+extern (Windows) {
+    BOOL InternetTimeFromSystemTime(SYSTEMTIME*, DWORD, LPSTR, DWORD);
+    BOOL InternetTimeToSystemTime(LPCSTR, SYSTEMTIME*, DWORD);
+    BOOL InternetDebugGetLocalTime(SYSTEMTIME*, PDWORD);
+    BOOL InternetCrackUrlA(LPCSTR, DWORD, DWORD, LPURL_COMPONENTSA);
+    BOOL InternetCrackUrlW(LPCWSTR, DWORD, DWORD, LPURL_COMPONENTSW);
+    BOOL InternetCreateUrlA(LPURL_COMPONENTSA, DWORD, LPSTR, PDWORD);
+    BOOL InternetCreateUrlW(LPURL_COMPONENTSW, DWORD, LPWSTR, PDWORD);
+    BOOL InternetCanonicalizeUrlA(LPCSTR, LPSTR, PDWORD, DWORD);
+    BOOL InternetCanonicalizeUrlW(LPCWSTR, LPWSTR, PDWORD, DWORD);
+    BOOL InternetCheckConnectionA(LPCSTR, DWORD, DWORD);
+    BOOL InternetCheckConnectionW(LPCWSTR, DWORD, DWORD);
+    BOOL InternetCombineUrlA(LPCSTR, LPCSTR, LPSTR, PDWORD, DWORD);
+    BOOL InternetCombineUrlW(LPCWSTR, LPCWSTR, LPWSTR, PDWORD, DWORD);
+    HINTERNET InternetOpenA(LPCSTR, DWORD, LPCSTR, LPCSTR, DWORD);
+    HINTERNET InternetOpenW(LPCWSTR, DWORD, LPCWSTR, LPCWSTR, DWORD);
+    BOOL InternetCloseHandle(HINTERNET);
+    HINTERNET InternetConnectA(HINTERNET, LPCSTR, INTERNET_PORT, LPCSTR,
+      LPCSTR, DWORD, DWORD, DWORD);
+    HINTERNET InternetConnectW(HINTERNET, LPCWSTR, INTERNET_PORT, LPCWSTR,
+      LPCWSTR, DWORD, DWORD, DWORD);
+    HINTERNET InternetOpenUrlA(HINTERNET, LPCSTR, LPCSTR, DWORD, DWORD,
+      DWORD);
+    HINTERNET InternetOpenUrlW(HINTERNET, LPCWSTR, LPCWSTR, DWORD, DWORD,
+      DWORD);
+    BOOL InternetReadFile(HINTERNET, PVOID, DWORD, PDWORD);
+    DWORD InternetSetFilePointer(HINTERNET, LONG, PVOID, DWORD, DWORD);
+    BOOL InternetWriteFile(HINTERNET, LPCVOID, DWORD, PDWORD);
+    BOOL InternetQueryDataAvailable(HINTERNET, PDWORD, DWORD, DWORD);
+    BOOL InternetFindNextFileA(HINTERNET, PVOID);
+    BOOL InternetFindNextFileW(HINTERNET, PVOID);
+    BOOL InternetQueryOptionA(HINTERNET, DWORD, PVOID, PDWORD);
+    BOOL InternetQueryOptionW(HINTERNET, DWORD, PVOID, PDWORD);
+    BOOL InternetSetOptionA(HINTERNET, DWORD, PVOID, DWORD);
+    BOOL InternetSetOptionW(HINTERNET, DWORD, PVOID, DWORD);
+    BOOL InternetSetOptionExA(HINTERNET, DWORD, PVOID, DWORD, DWORD);
+    BOOL InternetSetOptionExW(HINTERNET, DWORD, PVOID, DWORD, DWORD);
+    BOOL InternetGetLastResponseInfoA(PDWORD, LPSTR, PDWORD);
+    BOOL InternetGetLastResponseInfoW(PDWORD, LPWSTR, PDWORD);
+    INTERNET_STATUS_CALLBACK InternetSetStatusCallback(HINTERNET,
+      INTERNET_STATUS_CALLBACK);
+    DWORD FtpGetFileSize(HINTERNET, LPDWORD);
+    HINTERNET FtpFindFirstFileA(HINTERNET, LPCSTR, LPWIN32_FIND_DATA, DWORD,
+      DWORD);
+    HINTERNET FtpFindFirstFileW(HINTERNET, LPCWSTR, LPWIN32_FIND_DATA, DWORD,
+      DWORD);
+    BOOL FtpGetFileA(HINTERNET, LPCSTR, LPCSTR, BOOL, DWORD, DWORD, DWORD);
+    BOOL FtpGetFileW(HINTERNET, LPCWSTR, LPCWSTR, BOOL, DWORD, DWORD, DWORD);
+    BOOL FtpPutFileA(HINTERNET, LPCSTR, LPCSTR, DWORD, DWORD);
+    BOOL FtpPutFileW(HINTERNET, LPCWSTR, LPCWSTR, DWORD, DWORD);
+    BOOL FtpDeleteFileA(HINTERNET, LPCSTR);
+    BOOL FtpDeleteFileW(HINTERNET, LPCWSTR);
+    BOOL FtpRenameFileA(HINTERNET, LPCSTR, LPCSTR);
+    BOOL FtpRenameFileW(HINTERNET, LPCWSTR, LPCWSTR);
+    HINTERNET FtpOpenFileA(HINTERNET, LPCSTR, DWORD, DWORD, DWORD);
+    HINTERNET FtpOpenFileW(HINTERNET, LPCWSTR, DWORD, DWORD, DWORD);
+    BOOL FtpCreateDirectoryA(HINTERNET, LPCSTR);
+    BOOL FtpCreateDirectoryW(HINTERNET, LPCWSTR);
+    BOOL FtpRemoveDirectoryA(HINTERNET, LPCSTR);
+    BOOL FtpRemoveDirectoryW(HINTERNET, LPCWSTR);
+    BOOL FtpSetCurrentDirectoryA(HINTERNET, LPCSTR);
+    BOOL FtpSetCurrentDirectoryW(HINTERNET, LPCWSTR);
+    BOOL FtpGetCurrentDirectoryA(HINTERNET, LPSTR, PDWORD);
+    BOOL FtpGetCurrentDirectoryW(HINTERNET, LPWSTR, PDWORD);
+    BOOL FtpCommandA(HINTERNET, BOOL, DWORD, LPCSTR, DWORD_PTR, HINTERNET*);
+    BOOL FtpCommandW(HINTERNET, BOOL, DWORD, LPCWSTR, DWORD_PTR, HINTERNET*);
+    BOOL GopherCreateLocatorA(LPCSTR, INTERNET_PORT, LPCSTR, LPCSTR, DWORD,
+      LPSTR, PDWORD);
+    BOOL GopherCreateLocatorW(LPCWSTR, INTERNET_PORT, LPCWSTR, LPCWSTR, DWORD,
+      LPWSTR, PDWORD);
+    BOOL GopherGetLocatorTypeA(LPCSTR, PDWORD);
+    BOOL GopherGetLocatorTypeW(LPCWSTR, PDWORD);
+    HINTERNET GopherFindFirstFileA(HINTERNET, LPCSTR, LPCSTR,
+      LPGOPHER_FIND_DATAA, DWORD, DWORD);
+    HINTERNET GopherFindFirstFileW(HINTERNET, LPCWSTR, LPCWSTR,
+      LPGOPHER_FIND_DATAW, DWORD, DWORD);
+    HINTERNET GopherOpenFileA(HINTERNET, LPCSTR, LPCSTR, DWORD, DWORD);
+    HINTERNET GopherOpenFileW(HINTERNET, LPCWSTR, LPCWSTR, DWORD, DWORD);
+    BOOL GopherGetAttributeA(HINTERNET, LPCSTR, LPCSTR, LPBYTE, DWORD,
+      PDWORD, GOPHER_ATTRIBUTE_ENUMERATOR, DWORD);
+    BOOL GopherGetAttributeW(HINTERNET, LPCWSTR, LPCWSTR, LPBYTE, DWORD,
+      PDWORD, GOPHER_ATTRIBUTE_ENUMERATOR, DWORD);
+    HINTERNET HttpOpenRequestA(HINTERNET, LPCSTR, LPCSTR, LPCSTR, LPCSTR,
+      LPCSTR*, DWORD, DWORD);
+    HINTERNET HttpOpenRequestW(HINTERNET, LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR,
+      LPCWSTR*, DWORD, DWORD);
+    BOOL HttpAddRequestHeadersA(HINTERNET, LPCSTR, DWORD, DWORD);
+    BOOL HttpAddRequestHeadersW(HINTERNET, LPCWSTR, DWORD, DWORD);
+    BOOL HttpSendRequestA(HINTERNET, LPCSTR, DWORD, PVOID, DWORD);
+    BOOL HttpSendRequestW(HINTERNET, LPCWSTR, DWORD, PVOID, DWORD);
+    BOOL HttpQueryInfoA(HINTERNET, DWORD, PVOID, PDWORD, PDWORD);
+    BOOL HttpQueryInfoW(HINTERNET, DWORD, PVOID, PDWORD, PDWORD);
+    BOOL InternetSetCookieA(LPCSTR, LPCSTR, LPCSTR);
+    BOOL InternetSetCookieW(LPCWSTR, LPCWSTR, LPCWSTR);
+    BOOL InternetGetCookieA(LPCSTR, LPCSTR, LPSTR, PDWORD);
+    BOOL InternetGetCookieW(LPCWSTR, LPCWSTR, LPWSTR, PDWORD);
+    DWORD InternetAttemptConnect(DWORD);
+    DWORD InternetErrorDlg(HWND, HINTERNET, DWORD, DWORD, PVOID*);
+    DWORD InternetConfirmZoneCrossing(HWND, LPSTR, LPSTR, BOOL);
+    BOOL CreateUrlCacheEntryA(LPCSTR, DWORD, LPCSTR, LPSTR, DWORD);
+    BOOL CreateUrlCacheEntryW(LPCWSTR, DWORD, LPCWSTR, LPWSTR, DWORD);
+    BOOL CommitUrlCacheEntryA(LPCSTR, LPCSTR, FILETIME, FILETIME, DWORD,
+      LPBYTE, DWORD, LPCSTR, DWORD);
+    BOOL CommitUrlCacheEntryW(LPCWSTR, LPCWSTR, FILETIME, FILETIME, DWORD,
+      LPBYTE, DWORD, LPCWSTR, DWORD);
+    BOOL RetrieveUrlCacheEntryFileA(LPCSTR, LPINTERNET_CACHE_ENTRY_INFOA,
+      PDWORD, DWORD);
+    BOOL RetrieveUrlCacheEntryFileW(LPCWSTR, LPINTERNET_CACHE_ENTRY_INFOW,
+      PDWORD, DWORD);
+    BOOL UnlockUrlCacheEntryFile(LPCSTR, DWORD);
+    HANDLE RetrieveUrlCacheEntryStreamA(LPCSTR, LPINTERNET_CACHE_ENTRY_INFOA,
+      PDWORD, BOOL, DWORD);
+    HANDLE RetrieveUrlCacheEntryStreamW(LPCWSTR, LPINTERNET_CACHE_ENTRY_INFOW,
+      PDWORD, BOOL, DWORD);
+    BOOL ReadUrlCacheEntryStream(HANDLE, DWORD, PVOID, PDWORD, DWORD);
+    BOOL UnlockUrlCacheEntryStream(HANDLE, DWORD);
+    BOOL GetUrlCacheEntryInfoA(LPCSTR, LPINTERNET_CACHE_ENTRY_INFOA, PDWORD);
+    BOOL GetUrlCacheEntryInfoW(LPCWSTR, LPINTERNET_CACHE_ENTRY_INFOW, PDWORD);
+    BOOL SetUrlCacheEntryInfoA(LPCSTR, LPINTERNET_CACHE_ENTRY_INFOA, DWORD);
+    BOOL SetUrlCacheEntryInfoW(LPCWSTR, LPINTERNET_CACHE_ENTRY_INFOW, DWORD);
+    HANDLE FindFirstUrlCacheEntryA(LPCSTR, LPINTERNET_CACHE_ENTRY_INFOA,
+      PDWORD);
+    HANDLE FindFirstUrlCacheEntryW(LPCWSTR, LPINTERNET_CACHE_ENTRY_INFOW,
+      PDWORD);
+    BOOL FindNextUrlCacheEntryA(HANDLE, LPINTERNET_CACHE_ENTRY_INFOA, PDWORD);
+    BOOL FindNextUrlCacheEntryW(HANDLE, LPINTERNET_CACHE_ENTRY_INFOW, PDWORD);
+    BOOL FindCloseUrlCache(HANDLE);
+    BOOL DeleteUrlCacheEntry(LPCSTR);
+    DWORD AuthenticateUser(PVOID*, LPSTR, LPSTR, DWORD, LPSTR, DWORD, LPSTR,
+      LPSTR);
+    BOOL HttpSendRequestExA(HINTERNET, LPINTERNET_BUFFERSA,
+      LPINTERNET_BUFFERSA, DWORD, DWORD);
+    BOOL HttpSendRequestExW(HINTERNET, LPINTERNET_BUFFERSW,
+      LPINTERNET_BUFFERSW, DWORD, DWORD);
+    BOOL HttpEndRequestA(HINTERNET, LPINTERNET_BUFFERSA, DWORD, DWORD);
+    BOOL HttpEndRequestW(HINTERNET, LPINTERNET_BUFFERSW, DWORD, DWORD);
+    DWORD InternetDial(HWND, LPTSTR, DWORD, LPDWORD, DWORD);
+    DWORD InternetHangUp(DWORD, DWORD);
+    BOOL InternetGoOnline(LPTSTR, HWND, DWORD);
+    BOOL InternetAutodial(DWORD, DWORD);
+    BOOL InternetAutodialHangup(DWORD);
+    BOOL InternetGetConnectedState(LPDWORD, DWORD);
+    BOOL InternetSetDialState(LPCTSTR, DWORD, DWORD);
+    BOOL InternetReadFileExA(HINTERNET, LPINTERNET_BUFFERSA, DWORD, DWORD_PTR);
+    BOOL InternetReadFileExW(HINTERNET, LPINTERNET_BUFFERSW, DWORD, DWORD_PTR);
+    GROUPID CreateUrlCacheGroup(DWORD, LPVOID);
+    BOOL DeleteUrlCacheGroup(GROUPID, DWORD, LPVOID);
+    HANDLE FindFirstUrlCacheGroup(DWORD, DWORD, LPVOID, DWORD, GROUPID*,
+      LPVOID);
+    BOOL FindNextUrlCacheGroup(HANDLE, GROUPID*, LPVOID);
+    BOOL GetUrlCacheGroupAttributeA(GROUPID, DWORD, DWORD,
+      LPINTERNET_CACHE_GROUP_INFOA, LPDWORD, LPVOID);
+    BOOL GetUrlCacheGroupAttributeW(GROUPID, DWORD, DWORD,
+      LPINTERNET_CACHE_GROUP_INFOW, LPDWORD, LPVOID);
+    BOOL SetUrlCacheGroupAttributeA(GROUPID, DWORD, DWORD,
+      LPINTERNET_CACHE_GROUP_INFOA, LPVOID);
+    BOOL SetUrlCacheGroupAttributeW(GROUPID, DWORD, DWORD,
+      LPINTERNET_CACHE_GROUP_INFOW, LPVOID);
+}
+
+version (Unicode) {
+    alias URL_COMPONENTSW URL_COMPONENTS;
+    alias LPURL_COMPONENTSW LPURL_COMPONENTS;
+    alias GOPHER_FIND_DATAW GOPHER_FIND_DATA;
+    alias LPGOPHER_FIND_DATAW LPGOPHER_FIND_DATA;
+    alias INTERNET_CACHE_ENTRY_INFOW INTERNET_CACHE_ENTRY_INFO;
+    alias LPINTERNET_CACHE_ENTRY_INFOW LPINTERNET_CACHE_ENTRY_INFO;
+    alias INTERNET_BUFFERSW INTERNET_BUFFERS;
+    alias INTERNET_CACHE_GROUP_INFOW INTERNET_CACHE_GROUP_INFO;
+    alias LPINTERNET_CACHE_GROUP_INFOW LPINTERNET_CACHE_GROUP_INFO;
+    alias InternetCrackUrlW InternetCrackUrl;
+    alias InternetCreateUrlW InternetCreateUrl;
+    alias InternetCanonicalizeUrlW InternetCanonicalizeUrl;
+    alias InternetCheckConnectionW InternetCheckConnection;
+    alias InternetCombineUrlW InternetCombineUrl;
+    alias InternetOpenW InternetOpen;
+    alias InternetConnectW InternetConnect;
+    alias InternetOpenUrlW InternetOpenUrl;
+    alias InternetFindNextFileW InternetFindNextFile;
+    alias InternetQueryOptionW InternetQueryOption;
+    alias InternetSetOptionW InternetSetOption;
+    alias InternetSetOptionExW InternetSetOptionEx;
+    alias InternetGetLastResponseInfoW InternetGetLastResponseInfo;
+    alias InternetReadFileExW InternetReadFileEx;
+    alias FtpFindFirstFileW FtpFindFirstFile;
+    alias FtpGetFileW FtpGetFile;
+    alias FtpPutFileW FtpPutFile;
+    alias FtpDeleteFileW FtpDeleteFile;
+    alias FtpRenameFileW FtpRenameFile;
+    alias FtpOpenFileW FtpOpenFile;
+    alias FtpCreateDirectoryW FtpCreateDirectory;
+    alias FtpRemoveDirectoryW FtpRemoveDirectory;
+    alias FtpSetCurrentDirectoryW FtpSetCurrentDirectory;
+    alias FtpGetCurrentDirectoryW FtpGetCurrentDirectory;
+    alias FtpCommandW FtpCommand;
+    alias GopherGetLocatorTypeW GopherGetLocatorType;
+    alias GopherCreateLocatorW GopherCreateLocator;
+    alias GopherFindFirstFileW GopherFindFirstFile;
+    alias GopherOpenFileW GopherOpenFile;
+    alias GopherGetAttributeW GopherGetAttribute;
+    alias HttpSendRequestW HttpSendRequest;
+    alias HttpOpenRequestW HttpOpenRequest;
+    alias HttpAddRequestHeadersW HttpAddRequestHeaders;
+    alias HttpQueryInfoW HttpQueryInfo;
+    alias InternetSetCookieW InternetSetCookie;
+    alias InternetGetCookieW InternetGetCookie;
+    alias CreateUrlCacheEntryW CreateUrlCacheEntry;
+    alias RetrieveUrlCacheEntryStreamW RetrieveUrlCacheEntryStream;
+    alias FindNextUrlCacheEntryW FindNextUrlCacheEntry;
+    alias CommitUrlCacheEntryW CommitUrlCacheEntry;
+    alias GetUrlCacheEntryInfoW GetUrlCacheEntryInfo;
+    alias SetUrlCacheEntryInfoW SetUrlCacheEntryInfo;
+    alias FindFirstUrlCacheEntryW FindFirstUrlCacheEntry;
+    alias RetrieveUrlCacheEntryFileW RetrieveUrlCacheEntryFile;
+    alias HttpSendRequestExW HttpSendRequestEx;
+    alias HttpEndRequestW HttpEndRequest;
+    alias GetUrlCacheGroupAttributeW GetUrlCacheGroupAttribute;
+    alias SetUrlCacheGroupAttributeW SetUrlCacheGroupAttribute;
+} else {
+    alias URL_COMPONENTSA URL_COMPONENTS;
+    alias LPURL_COMPONENTSA LPURL_COMPONENTS;
+    alias GOPHER_FIND_DATAA GOPHER_FIND_DATA;
+    alias LPGOPHER_FIND_DATAA LPGOPHER_FIND_DATA;
+    alias INTERNET_CACHE_ENTRY_INFOA INTERNET_CACHE_ENTRY_INFO;
+    alias LPINTERNET_CACHE_ENTRY_INFOA LPINTERNET_CACHE_ENTRY_INFO;
+    alias INTERNET_BUFFERSA INTERNET_BUFFERS;
+    alias INTERNET_CACHE_GROUP_INFOA INTERNET_CACHE_GROUP_INFO;
+    alias LPINTERNET_CACHE_GROUP_INFOA LPINTERNET_CACHE_GROUP_INFO;
+    alias GopherGetAttributeA GopherGetAttribute;
+    alias InternetCrackUrlA InternetCrackUrl;
+    alias InternetCreateUrlA InternetCreateUrl;
+    alias InternetCanonicalizeUrlA InternetCanonicalizeUrl;
+    alias InternetCheckConnectionA InternetCheckConnection;
+    alias InternetCombineUrlA InternetCombineUrl;
+    alias InternetOpenA InternetOpen;
+    alias InternetConnectA InternetConnect;
+    alias InternetOpenUrlA InternetOpenUrl;
+    alias InternetFindNextFileA InternetFindNextFile;
+    alias InternetQueryOptionA InternetQueryOption;
+    alias InternetSetOptionA InternetSetOption;
+    alias InternetSetOptionExA InternetSetOptionEx;
+    alias InternetGetLastResponseInfoA InternetGetLastResponseInfo;
+    alias InternetReadFileExA InternetReadFileEx;
+    alias FtpFindFirstFileA FtpFindFirstFile;
+    alias FtpGetFileA FtpGetFile;
+    alias FtpPutFileA FtpPutFile;
+    alias FtpDeleteFileA FtpDeleteFile;
+    alias FtpRenameFileA FtpRenameFile;
+    alias FtpOpenFileA FtpOpenFile;
+    alias FtpCreateDirectoryA FtpCreateDirectory;
+    alias FtpRemoveDirectoryA FtpRemoveDirectory;
+    alias FtpSetCurrentDirectoryA FtpSetCurrentDirectory;
+    alias FtpGetCurrentDirectoryA FtpGetCurrentDirectory;
+    alias FtpCommandA FtpCommand;
+    alias GopherGetLocatorTypeA GopherGetLocatorType;
+    alias GopherCreateLocatorA GopherCreateLocator;
+    alias GopherFindFirstFileA GopherFindFirstFile;
+    alias GopherOpenFileA GopherOpenFile;
+    alias HttpSendRequestA HttpSendRequest;
+    alias HttpOpenRequestA HttpOpenRequest;
+    alias HttpAddRequestHeadersA HttpAddRequestHeaders;
+    alias HttpQueryInfoA HttpQueryInfo;
+    alias InternetSetCookieA InternetSetCookie;
+    alias InternetGetCookieA InternetGetCookie;
+    alias CreateUrlCacheEntryA CreateUrlCacheEntry;
+    alias RetrieveUrlCacheEntryStreamA RetrieveUrlCacheEntryStream;
+    alias FindNextUrlCacheEntryA FindNextUrlCacheEntry;
+    alias CommitUrlCacheEntryA CommitUrlCacheEntry;
+    alias GetUrlCacheEntryInfoA GetUrlCacheEntryInfo;
+    alias SetUrlCacheEntryInfoA SetUrlCacheEntryInfo;
+    alias FindFirstUrlCacheEntryA FindFirstUrlCacheEntry;
+    alias RetrieveUrlCacheEntryFileA RetrieveUrlCacheEntryFile;
+    alias HttpSendRequestExA HttpSendRequestEx;
+    alias HttpEndRequestA HttpEndRequest;
+    alias GetUrlCacheGroupAttributeA GetUrlCacheGroupAttribute;
+    alias SetUrlCacheGroupAttributeA SetUrlCacheGroupAttribute;
+}
+
+alias INTERNET_BUFFERS* LPINTERNET_BUFFERS;
diff --git a/libphobos/libdruntime/core/sys/windows/winioctl.d b/libphobos/libdruntime/core/sys/windows/winioctl.d
new file mode 100644
index 00000000000..b2cf49cb7a6
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winioctl.d
@@ -0,0 +1,712 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winioctl.d)
+ */
+module core.sys.windows.winioctl;
+version (Windows):
+
+// FIXME: check types of some constants
+
+private import core.sys.windows.basetyps, core.sys.windows.windef;
+
+enum size_t
+    HIST_NO_OF_BUCKETS = 24,
+    HISTOGRAM_BUCKET_SIZE = HISTOGRAM_BUCKET.sizeof,
+    DISK_HISTOGRAM_SIZE = DISK_HISTOGRAM.sizeof;
+
+alias DWORD DEVICE_TYPE;
+
+enum : DEVICE_TYPE {
+    FILE_DEVICE_BEEP               = 1,
+    FILE_DEVICE_CD_ROM,
+    FILE_DEVICE_CD_ROM_FILE_SYSTEM,
+    FILE_DEVICE_CONTROLLER,
+    FILE_DEVICE_DATALINK,
+    FILE_DEVICE_DFS,
+    FILE_DEVICE_DISK,
+    FILE_DEVICE_DISK_FILE_SYSTEM,
+    FILE_DEVICE_FILE_SYSTEM,
+    FILE_DEVICE_INPORT_PORT,
+    FILE_DEVICE_KEYBOARD,
+    FILE_DEVICE_MAILSLOT,
+    FILE_DEVICE_MIDI_IN,
+    FILE_DEVICE_MIDI_OUT,
+    FILE_DEVICE_MOUSE,
+    FILE_DEVICE_MULTI_UNC_PROVIDER,
+    FILE_DEVICE_NAMED_PIPE,
+    FILE_DEVICE_NETWORK,
+    FILE_DEVICE_NETWORK_BROWSER,
+    FILE_DEVICE_NETWORK_FILE_SYSTEM,
+    FILE_DEVICE_NULL,
+    FILE_DEVICE_PARALLEL_PORT,
+    FILE_DEVICE_PHYSICAL_NETCARD,
+    FILE_DEVICE_PRINTER,
+    FILE_DEVICE_SCANNER,
+    FILE_DEVICE_SERIAL_MOUSE_PORT,
+    FILE_DEVICE_SERIAL_PORT,
+    FILE_DEVICE_SCREEN,
+    FILE_DEVICE_SOUND,
+    FILE_DEVICE_STREAMS,
+    FILE_DEVICE_TAPE,
+    FILE_DEVICE_TAPE_FILE_SYSTEM,
+    FILE_DEVICE_TRANSPORT,
+    FILE_DEVICE_UNKNOWN,
+    FILE_DEVICE_VIDEO,
+    FILE_DEVICE_VIRTUAL_DISK,
+    FILE_DEVICE_WAVE_IN,
+    FILE_DEVICE_WAVE_OUT,
+    FILE_DEVICE_8042_PORT,
+    FILE_DEVICE_NETWORK_REDIRECTOR,
+    FILE_DEVICE_BATTERY,
+    FILE_DEVICE_BUS_EXTENDER,
+    FILE_DEVICE_MODEM,
+    FILE_DEVICE_VDM,
+    FILE_DEVICE_MASS_STORAGE,
+    FILE_DEVICE_SMB,
+    FILE_DEVICE_KS,
+    FILE_DEVICE_CHANGER,
+    FILE_DEVICE_SMARTCARD,
+    FILE_DEVICE_ACPI,
+    FILE_DEVICE_DVD,
+    FILE_DEVICE_FULLSCREEN_VIDEO,
+    FILE_DEVICE_DFS_FILE_SYSTEM,
+    FILE_DEVICE_DFS_VOLUME,
+    FILE_DEVICE_SERENUM,
+    FILE_DEVICE_TERMSRV,
+    FILE_DEVICE_KSEC            // = 57
+}
+
+enum {
+    METHOD_BUFFERED,
+    METHOD_IN_DIRECT,
+    METHOD_OUT_DIRECT,
+    METHOD_NEITHER
+}
+
+enum {
+    FILE_ANY_ACCESS,
+    FILE_SPECIAL_ACCESS = 0,
+    FILE_READ_ACCESS,
+    FILE_WRITE_ACCESS
+}
+
+/*  Bit pattern:
+ *  tttttttt tttttttt aaffffff ffffffmm
+ */
+/+
+#define CTL_CODE(t, f, m, a) (((t)<<16)|((a)<<14)|((f)<<2)|(m))
++/
+
+template CTL_CODE_T(DEVICE_TYPE t, uint f, uint m, uint a) {
+enum DWORD CTL_CODE_T = (t << 16) | (a << 14) | (f << 2) | m;
+}
+
+DEVICE_TYPE DEVICE_TYPE_FROM_CTL_CODE(DWORD c) {
+    return (c & 0xFFFF0000) >> 16;
+}
+
+enum DEVICE_TYPE
+    IOCTL_STORAGE_BASE = FILE_DEVICE_MASS_STORAGE,
+    IOCTL_DISK_BASE    = FILE_DEVICE_DISK,
+    IOCTL_VOLUME_BASE  = 'V';
+
+enum : DWORD {
+    IOCTL_STORAGE_CHECK_VERIFY           = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_STORAGE_CHECK_VERIFY2          = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_STORAGE_MEDIA_REMOVAL          = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_STORAGE_EJECT_MEDIA            = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_STORAGE_LOAD_MEDIA             = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_STORAGE_LOAD_MEDIA2            = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_STORAGE_RESERVE                = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_STORAGE_RELEASE                = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_STORAGE_FIND_NEW_DEVICES       = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_STORAGE_EJECTION_CONTROL       = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0250, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_STORAGE_MCN_CONTROL            = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0251, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_STORAGE_GET_MEDIA_TYPES        = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_STORAGE_GET_MEDIA_TYPES_EX     = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_STORAGE_RESET_BUS              = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_STORAGE_RESET_DEVICE           = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_STORAGE_GET_DEVICE_NUMBER      = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_STORAGE_PREDICT_FAILURE        = CTL_CODE_T!(IOCTL_STORAGE_BASE, 0x0440, METHOD_BUFFERED, FILE_ANY_ACCESS),
+
+    IOCTL_DISK_GET_DRIVE_GEOMETRY        = CTL_CODE_T!(IOCTL_DISK_BASE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_GET_PARTITION_INFO        = CTL_CODE_T!(IOCTL_DISK_BASE, 1, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_DISK_SET_PARTITION_INFO        = CTL_CODE_T!(IOCTL_DISK_BASE, 2, METHOD_BUFFERED, FILE_READ_ACCESS|FILE_WRITE_ACCESS),
+    IOCTL_DISK_GET_DRIVE_LAYOUT          = CTL_CODE_T!(IOCTL_DISK_BASE, 3, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_DISK_SET_DRIVE_LAYOUT          = CTL_CODE_T!(IOCTL_DISK_BASE, 4, METHOD_BUFFERED, FILE_READ_ACCESS|FILE_WRITE_ACCESS),
+    IOCTL_DISK_VERIFY                    = CTL_CODE_T!(IOCTL_DISK_BASE, 5, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_FORMAT_TRACKS             = CTL_CODE_T!(IOCTL_DISK_BASE, 6, METHOD_BUFFERED, FILE_READ_ACCESS|FILE_WRITE_ACCESS),
+    IOCTL_DISK_REASSIGN_BLOCKS           = CTL_CODE_T!(IOCTL_DISK_BASE, 7, METHOD_BUFFERED, FILE_READ_ACCESS|FILE_WRITE_ACCESS),
+    IOCTL_DISK_PERFORMANCE               = CTL_CODE_T!(IOCTL_DISK_BASE, 8, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_IS_WRITABLE               = CTL_CODE_T!(IOCTL_DISK_BASE, 9, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_LOGGING                   = CTL_CODE_T!(IOCTL_DISK_BASE, 10, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_FORMAT_TRACKS_EX          = CTL_CODE_T!(IOCTL_DISK_BASE, 11, METHOD_BUFFERED, FILE_READ_ACCESS|FILE_WRITE_ACCESS),
+    IOCTL_DISK_HISTOGRAM_STRUCTURE       = CTL_CODE_T!(IOCTL_DISK_BASE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_HISTOGRAM_DATA            = CTL_CODE_T!(IOCTL_DISK_BASE, 13, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_HISTOGRAM_RESET           = CTL_CODE_T!(IOCTL_DISK_BASE, 14, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_REQUEST_STRUCTURE         = CTL_CODE_T!(IOCTL_DISK_BASE, 15, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_REQUEST_DATA              = CTL_CODE_T!(IOCTL_DISK_BASE, 16, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_GET_PARTITION_INFO_EX     = CTL_CODE_T!(IOCTL_DISK_BASE, 0x12, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_SET_PARTITION_INFO_EX     = CTL_CODE_T!(IOCTL_DISK_BASE, 0x13, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS),
+    IOCTL_DISK_GET_DRIVE_LAYOUT_EX       = CTL_CODE_T!(IOCTL_DISK_BASE, 0x14, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_SET_DRIVE_LAYOUT_EX       = CTL_CODE_T!(IOCTL_DISK_BASE, 0x15, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS),
+    IOCTL_DISK_CREATE_DISK               = CTL_CODE_T!(IOCTL_DISK_BASE, 0x16, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS),
+    IOCTL_DISK_GET_LENGTH_INFO           = CTL_CODE_T!(IOCTL_DISK_BASE, 0x17, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_DISK_PERFORMANCE_OFF           = CTL_CODE_T!(IOCTL_DISK_BASE, 0x18, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_GET_DRIVE_GEOMETRY_EX     = CTL_CODE_T!(IOCTL_DISK_BASE, 0x28, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_GROW_PARTITION            = CTL_CODE_T!(IOCTL_DISK_BASE, 0x34, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS),
+    IOCTL_DISK_GET_CACHE_INFORMATION     = CTL_CODE_T!(IOCTL_DISK_BASE, 0x35, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_DISK_SET_CACHE_INFORMATION     = CTL_CODE_T!(IOCTL_DISK_BASE, 0x36, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS),
+    IOCTL_DISK_DELETE_DRIVE_LAYOUT       = CTL_CODE_T!(IOCTL_DISK_BASE, 0x40, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS),
+    IOCTL_DISK_UPDATE_PROPERTIES         = CTL_CODE_T!(IOCTL_DISK_BASE, 0x50, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_CHECK_VERIFY              = CTL_CODE_T!(IOCTL_DISK_BASE, 0x200, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_DISK_MEDIA_REMOVAL             = CTL_CODE_T!(IOCTL_DISK_BASE, 0x201, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_DISK_EJECT_MEDIA               = CTL_CODE_T!(IOCTL_DISK_BASE, 0x202, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_DISK_LOAD_MEDIA                = CTL_CODE_T!(IOCTL_DISK_BASE, 0x203, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_DISK_RESERVE                   = CTL_CODE_T!(IOCTL_DISK_BASE, 0x204, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_DISK_RELEASE                   = CTL_CODE_T!(IOCTL_DISK_BASE, 0x205, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_DISK_FIND_NEW_DEVICES          = CTL_CODE_T!(IOCTL_DISK_BASE, 0x206, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_DISK_REMOVE_DEVICE             = CTL_CODE_T!(IOCTL_DISK_BASE, 0x207, METHOD_BUFFERED, FILE_READ_ACCESS),
+    IOCTL_DISK_GET_MEDIA_TYPES           = CTL_CODE_T!(IOCTL_DISK_BASE, 0x300, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_DISK_UPDATE_DRIVE_SIZE         = CTL_CODE_T!(IOCTL_DISK_BASE, 0x0032, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS),
+    IOCTL_SERIAL_LSRMST_INSERT           = CTL_CODE_T!(FILE_DEVICE_SERIAL_PORT, 31, METHOD_BUFFERED, FILE_ANY_ACCESS),
+
+    IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS = CTL_CODE_T!(IOCTL_VOLUME_BASE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    IOCTL_VOLUME_IS_CLUSTERED            = CTL_CODE_T!(IOCTL_VOLUME_BASE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS),
+
+    FSCTL_LOCK_VOLUME                    = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    FSCTL_UNLOCK_VOLUME                  = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    FSCTL_DISMOUNT_VOLUME                = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    FSCTL_MOUNT_DBLS_VOLUME              = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 13, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    FSCTL_GET_COMPRESSION                = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    FSCTL_SET_COMPRESSION                = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA|FILE_WRITE_DATA),
+    FSCTL_READ_COMPRESSION               = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 17, METHOD_NEITHER, FILE_READ_DATA),
+    FSCTL_WRITE_COMPRESSION              = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 18, METHOD_NEITHER, FILE_WRITE_DATA),
+    FSCTL_GET_NTFS_VOLUME_DATA           = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    FSCTL_GET_VOLUME_BITMAP              = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 27, METHOD_NEITHER, FILE_ANY_ACCESS),
+    FSCTL_GET_RETRIEVAL_POINTERS         = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 28, METHOD_NEITHER, FILE_ANY_ACCESS),
+    FSCTL_MOVE_FILE                      = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    FSCTL_GET_REPARSE_POINT              = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    FSCTL_SET_REPARSE_POINT              = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    FSCTL_DELETE_REPARSE_POINT           = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_ANY_ACCESS),
+    FSCTL_SET_SPARSE                     = CTL_CODE_T!(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS),
+}
+
+enum : BYTE {
+    PARTITION_ENTRY_UNUSED,
+    PARTITION_FAT_12,
+    PARTITION_XENIX_1,
+    PARTITION_XENIX_2,
+    PARTITION_FAT_16,
+    PARTITION_EXTENDED,
+    PARTITION_HUGE,
+    PARTITION_IFS,         // = 0x07
+    PARTITION_FAT32           = 0x0B,
+    PARTITION_FAT32_XINT13    = 0x0C,
+    PARTITION_XINT13          = 0x0E,
+    PARTITION_XINT13_EXTENDED = 0x0F,
+    PARTITION_PREP            = 0x41,
+    PARTITION_LDM             = 0x42,
+    PARTITION_UNIX            = 0x63
+}
+
+enum BYTE
+    PARTITION_NTFT = 0x80,
+    VALID_NTFT     = 0xC0;
+
+enum {
+    SERIAL_LSRMST_ESCAPE,
+    SERIAL_LSRMST_LSR_DATA,
+    SERIAL_LSRMST_LSR_NODATA,
+    SERIAL_LSRMST_MST
+}
+
+enum {
+    DISK_LOGGING_START,
+    DISK_LOGGING_STOP,
+    DISK_LOGGING_DUMP,
+    DISK_BINNING
+}
+
+alias WORD BAD_TRACK_NUMBER;
+alias WORD* PBAD_TRACK_NUMBER;
+
+enum BIN_TYPES {
+    RequestSize, RequestLocation
+}
+
+struct BIN_RANGE {
+    LARGE_INTEGER StartValue;
+    LARGE_INTEGER Length;
+}
+alias BIN_RANGE* PBIN_RANGE;
+
+struct BIN_COUNT {
+    BIN_RANGE BinRange;
+    DWORD     BinCount;
+}
+alias BIN_COUNT* PBIN_COUNT;
+
+struct BIN_RESULTS {
+    DWORD     NumberOfBins;
+    BIN_COUNT _BinCounts;
+
+    BIN_COUNT* BinCounts() return { return &_BinCounts; }
+}
+alias BIN_RESULTS* PBIN_RESULTS;
+
+enum PARTITION_STYLE {
+    PARTITION_STYLE_MBR,
+    PARTITION_STYLE_GPT,
+    PARTITION_STYLE_RAW
+}
+
+struct CREATE_DISK_GPT {
+    GUID  DiskId;
+    DWORD MaxPartitionCount;
+}
+alias CREATE_DISK_GPT* PCREATE_DISK_GPT;
+
+struct CREATE_DISK_MBR {
+    DWORD Signature;
+}
+alias CREATE_DISK_MBR* PCREATE_DISK_MBR;
+
+struct CREATE_DISK {
+    PARTITION_STYLE PartitionStyle;
+    union {
+        CREATE_DISK_MBR Mbr;
+        CREATE_DISK_GPT Gpt;
+    }
+}
+alias CREATE_DISK* PCREATE_DISK;
+
+enum DISK_CACHE_RETENTION_PRIORITY {
+    EqualPriority,
+    KeepPrefetchedData,
+    KeepReadData
+}
+
+struct DISK_CACHE_INFORMATION {
+    BOOLEAN ParametersSavable;
+    BOOLEAN ReadCacheEnabled;
+    BOOLEAN WriteCacheEnabled;
+    DISK_CACHE_RETENTION_PRIORITY ReadRetentionPriority;
+    DISK_CACHE_RETENTION_PRIORITY WriteRetentionPriority;
+    WORD    DisablePrefetchTransferLength;
+    BOOLEAN PrefetchScalar;
+    union {
+        struct _ScalarPrefetch {
+            WORD Minimum;
+            WORD Maximum;
+            WORD MaximumBlocks;
+        }
+        _ScalarPrefetch ScalarPrefetch;
+        struct _BlockPrefetch {
+            WORD Minimum;
+            WORD Maximum;
+        }
+        _BlockPrefetch BlockPrefetch;
+    }
+}
+alias DISK_CACHE_INFORMATION* PDISK_CACHE_INFORMATION;
+
+enum DETECTION_TYPE {
+    DetectNone,
+    DetectInt13,
+    DetectExInt13
+}
+
+struct DISK_INT13_INFO {
+    WORD  DriveSelect;
+    DWORD MaxCylinders;
+    WORD  SectorsPerTrack;
+    WORD  MaxHeads;
+    WORD  NumberDrives;
+    }
+alias DISK_INT13_INFO* PDISK_INT13_INFO;
+
+struct DISK_EX_INT13_INFO {
+    WORD    ExBufferSize;
+    WORD    ExFlags;
+    DWORD   ExCylinders;
+    DWORD   ExHeads;
+    DWORD   ExSectorsPerTrack;
+    DWORD64 ExSectorsPerDrive;
+    WORD    ExSectorSize;
+    WORD    ExReserved;
+}
+alias DISK_EX_INT13_INFO* PDISK_EX_INT13_INFO;
+
+struct DISK_DETECTION_INFO {
+    DWORD              SizeOfDetectInfo;
+    DETECTION_TYPE     DetectionType;
+    DISK_INT13_INFO    Int13;
+    DISK_EX_INT13_INFO ExInt13;
+}
+alias DISK_DETECTION_INFO* PDISK_DETECTION_INFO;
+
+enum MEDIA_TYPE {
+    Unknown,
+    F5_1Pt2_512,
+    F3_1Pt44_512,
+    F3_2Pt88_512,
+    F3_20Pt8_512,
+    F3_720_512,
+    F5_360_512,
+    F5_320_512,
+    F5_320_1024,
+    F5_180_512,
+    F5_160_512,
+    RemovableMedia,
+    FixedMedia,
+    F3_120M_512,
+    F3_640_512,
+    F5_640_512,
+    F5_720_512,
+    F3_1Pt2_512,
+    F3_1Pt23_1024,
+    F5_1Pt23_1024,
+    F3_128Mb_512,
+    F3_230Mb_512,
+    F8_256_128,
+    F3_200Mb_512,
+    F3_240M_512,
+    F3_32M_512
+}
+alias MEDIA_TYPE* PMEDIA_TYPE;
+
+struct DISK_GEOMETRY {
+    LARGE_INTEGER Cylinders;
+    MEDIA_TYPE    MediaType;
+    DWORD         TracksPerCylinder;
+    DWORD         SectorsPerTrack;
+    DWORD         BytesPerSector;
+}
+alias DISK_GEOMETRY* PDISK_GEOMETRY;
+
+struct DISK_GEOMETRY_EX {
+    DISK_GEOMETRY Geometry;
+    LARGE_INTEGER DiskSize;
+    BYTE          _Data;
+
+    BYTE* Data() return { return &_Data; }
+}
+alias DISK_GEOMETRY_EX* PDISK_GEOMETRY_EX;
+
+struct DISK_GROW_PARTITION {
+    DWORD         PartitionNumber;
+    LARGE_INTEGER BytesToGrow;
+}
+alias DISK_GROW_PARTITION* PDISK_GROW_PARTITION;
+
+struct DISK_PARTITION_INFO {
+    DWORD           SizeOfPartitionInfo;
+    PARTITION_STYLE PartitionStyle;
+    union {
+        //struct {
+            DWORD Signature;
+        //} Mbr;
+        //struct {
+            GUID DiskId;
+        //} Gpt;
+    }
+}
+alias DISK_PARTITION_INFO* PDISK_PARTITION_INFO;
+
+struct DISK_PERFORMANCE {
+    LARGE_INTEGER BytesRead;
+    LARGE_INTEGER BytesWritten;
+    LARGE_INTEGER ReadTime;
+    LARGE_INTEGER WriteTime;
+    DWORD         ReadCount;
+    DWORD         WriteCount;
+    DWORD         QueueDepth;
+}
+alias DISK_PERFORMANCE* PDISK_PERFORMANCE;
+
+struct DISK_RECORD {
+    LARGE_INTEGER ByteOffset;
+    LARGE_INTEGER StartTime;
+    LARGE_INTEGER EndTime;
+    PVOID         VirtualAddress;
+    DWORD         NumberOfBytes;
+    BYTE          DeviceNumber;
+    BOOLEAN       ReadRequest;
+}
+alias DISK_RECORD* PDISK_RECORD;
+
+struct DISK_LOGGING {
+    BYTE  Function;
+    PVOID BufferAddress;
+    DWORD BufferSize;
+}
+alias DISK_LOGGING* PDISK_LOGGING;
+
+struct DISKQUOTA_USER_INFORMATION {
+    LONGLONG QuotaUsed;
+    LONGLONG QuotaThreshold;
+    LONGLONG QuotaLimit;
+}
+alias DISKQUOTA_USER_INFORMATION* PDISKQUOTA_USER_INFORMATION;
+
+struct FORMAT_PARAMETERS {
+    MEDIA_TYPE MediaType;
+    DWORD      StartCylinderNumber;
+    DWORD      EndCylinderNumber;
+    DWORD      StartHeadNumber;
+    DWORD      EndHeadNumber;
+}
+alias FORMAT_PARAMETERS* PFORMAT_PARAMETERS;
+
+struct FORMAT_EX_PARAMETERS {
+    MEDIA_TYPE MediaType;
+    DWORD      StartCylinderNumber;
+    DWORD      EndCylinderNumber;
+    DWORD      StartHeadNumber;
+    DWORD      EndHeadNumber;
+    WORD       FormatGapLength;
+    WORD       SectorsPerTrack;
+    WORD       _SectorNumber;
+
+    WORD* SectorNumber() return { return &_SectorNumber; }
+}
+alias FORMAT_EX_PARAMETERS* PFORMAT_EX_PARAMETERS;
+
+struct GET_LENGTH_INFORMATION {
+    LARGE_INTEGER Length;
+}
+
+struct HISTOGRAM_BUCKET {
+    DWORD Reads;
+    DWORD Writes;
+}
+alias HISTOGRAM_BUCKET* PHISTOGRAM_BUCKET;
+
+struct DISK_HISTOGRAM {
+    LARGE_INTEGER     DiskSize;
+    LARGE_INTEGER     Start;
+    LARGE_INTEGER     End;
+    LARGE_INTEGER     Average;
+    LARGE_INTEGER     AverageRead;
+    LARGE_INTEGER     AverageWrite;
+    DWORD             Granularity;
+    DWORD             Size;
+    DWORD             ReadCount;
+    DWORD             WriteCount;
+    PHISTOGRAM_BUCKET Histogram;
+}
+alias DISK_HISTOGRAM* PDISK_HISTOGRAM;
+
+struct DISK_EXTENT {
+    DWORD         DiskNumber;
+    LARGE_INTEGER StartingOffset;
+    LARGE_INTEGER ExtentLength;
+}
+alias DISK_EXTENT* PDISK_EXTENT;
+
+struct VOLUME_DISK_EXTENTS {
+    DWORD       NumberOfDiskExtents;
+    DISK_EXTENT _Extents;
+
+    DISK_EXTENT* Extents() return { return &_Extents; }
+}
+alias VOLUME_DISK_EXTENTS* PVOLUME_DISK_EXTENTS;
+
+struct PARTITION_INFORMATION {
+    LARGE_INTEGER StartingOffset;
+    LARGE_INTEGER PartitionLength;
+    DWORD         HiddenSectors;
+    DWORD         PartitionNumber;
+    BYTE          PartitionType;
+    BOOLEAN       BootIndicator;
+    BOOLEAN       RecognizedPartition;
+    BOOLEAN       RewritePartition;
+}
+alias PARTITION_INFORMATION* PPARTITION_INFORMATION;
+
+struct DRIVE_LAYOUT_INFORMATION {
+    DWORD                 PartitionCount;
+    DWORD                 Signature;
+    PARTITION_INFORMATION _PartitionEntry;
+
+    PARTITION_INFORMATION* PartitionEntry() return { return &_PartitionEntry; }
+}
+alias DRIVE_LAYOUT_INFORMATION* PDRIVE_LAYOUT_INFORMATION;
+
+struct DRIVE_LAYOUT_INFORMATION_GPT {
+    GUID          DiskId;
+    LARGE_INTEGER StartingUsableOffset;
+    LARGE_INTEGER UsableLength;
+    ULONG         MaxPartitionCount;
+}
+alias DRIVE_LAYOUT_INFORMATION_GPT* PDRIVE_LAYOUT_INFORMATION_GPT;
+
+struct DRIVE_LAYOUT_INFORMATION_MBR {
+    ULONG Signature;
+}
+alias DRIVE_LAYOUT_INFORMATION_MBR* PDRIVE_LAYOUT_INFORMATION_MBR;
+
+struct PARTITION_INFORMATION_MBR {
+    BYTE    PartitionType;
+    BOOLEAN BootIndicator;
+    BOOLEAN RecognizedPartition;
+    DWORD   HiddenSectors;
+}
+
+struct PARTITION_INFORMATION_GPT {
+    GUID      PartitionType;
+    GUID      PartitionId;
+    DWORD64   Attributes;
+    WCHAR[36] Name;
+}
+
+struct PARTITION_INFORMATION_EX {
+    PARTITION_STYLE PartitionStyle;
+    LARGE_INTEGER   StartingOffset;
+    LARGE_INTEGER   PartitionLength;
+    DWORD           PartitionNumber;
+    BOOLEAN         RewritePartition;
+    union {
+        PARTITION_INFORMATION_MBR Mbr;
+        PARTITION_INFORMATION_GPT Gpt;
+    }
+}
+
+struct DRIVE_LAYOUT_INFORMATION_EX {
+    DWORD PartitionStyle;
+    DWORD PartitionCount;
+    union {
+        DRIVE_LAYOUT_INFORMATION_MBR Mbr;
+        DRIVE_LAYOUT_INFORMATION_GPT Gpt;
+    }
+    PARTITION_INFORMATION_EX _PartitionEntry;
+
+    PARTITION_INFORMATION_EX* PartitionEntry() return { return &_PartitionEntry; }
+}
+alias DRIVE_LAYOUT_INFORMATION_EX* PDRIVE_LAYOUT_INFORMATION_EX;
+
+struct MOVE_FILE_DATA {
+    HANDLE FileHandle;
+    LARGE_INTEGER StartingVcn;
+    LARGE_INTEGER StartingLcn;
+    DWORD ClusterCount;
+}
+alias MOVE_FILE_DATA* PMOVE_FILE_DATA;
+
+struct PERF_BIN {
+    DWORD     NumberOfBins;
+    DWORD     TypeOfBin;
+    BIN_RANGE _BinsRanges;
+
+    BIN_RANGE* BinsRanges() return { return &_BinsRanges; }
+}
+alias PERF_BIN* PPERF_BIN;
+
+struct PREVENT_MEDIA_REMOVAL {
+    BOOLEAN PreventMediaRemoval;
+}
+alias PREVENT_MEDIA_REMOVAL* PPREVENT_MEDIA_REMOVAL;
+
+struct RETRIEVAL_POINTERS_BUFFER {
+    DWORD         ExtentCount;
+    LARGE_INTEGER StartingVcn;
+    // In MinGW, this is declared as struct { ... } Extents[1];
+    struct Extent {
+        LARGE_INTEGER NextVcn;
+        LARGE_INTEGER Lcn;
+    }
+    Extent _Extents;
+
+    Extent* Extents() return { return &_Extents; }
+}
+alias RETRIEVAL_POINTERS_BUFFER* PRETRIEVAL_POINTERS_BUFFER;
+
+struct REASSIGN_BLOCKS {
+    WORD  Reserved;
+    WORD  Count;
+    DWORD _BlockNumber;
+
+    DWORD* BlockNumber() return { return &_BlockNumber; }
+}
+alias REASSIGN_BLOCKS* PREASSIGN_BLOCKS;
+
+struct SET_PARTITION_INFORMATION {
+    BYTE PartitionType;
+}
+alias SET_PARTITION_INFORMATION* PSET_PARTITION_INFORMATION;
+
+struct STARTING_LCN_INPUT_BUFFER {
+    LARGE_INTEGER StartingLcn;
+}
+alias STARTING_LCN_INPUT_BUFFER* PSTARTING_LCN_INPUT_BUFFER;
+
+struct STARTING_VCN_INPUT_BUFFER {
+    LARGE_INTEGER StartingVcn;
+}
+alias STARTING_VCN_INPUT_BUFFER* PSTARTING_VCN_INPUT_BUFFER;
+
+struct VERIFY_INFORMATION {
+    LARGE_INTEGER StartingOffset;
+    DWORD         Length;
+}
+alias VERIFY_INFORMATION* PVERIFY_INFORMATION;
+
+struct VOLUME_BITMAP_BUFFER {
+    LARGE_INTEGER StartingLcn;
+    LARGE_INTEGER BitmapSize;
+    BYTE          _Buffer;
+
+    BYTE* Buffer() return { return &_Buffer; }
+}
+alias VOLUME_BITMAP_BUFFER* PVOLUME_BITMAP_BUFFER;
+
+struct NTFS_VOLUME_DATA_BUFFER {
+    LARGE_INTEGER VolumeSerialNumber;
+    LARGE_INTEGER NumberSectors;
+    LARGE_INTEGER TotalClusters;
+    LARGE_INTEGER FreeClusters;
+    LARGE_INTEGER TotalReserved;
+    DWORD         BytesPerSector;
+    DWORD         BytesPerCluster;
+    DWORD         BytesPerFileRecordSegment;
+    DWORD         ClustersPerFileRecordSegment;
+    LARGE_INTEGER MftValidDataLength;
+    LARGE_INTEGER MftStartLcn;
+    LARGE_INTEGER Mft2StartLcn;
+    LARGE_INTEGER MftZoneStart;
+    LARGE_INTEGER MftZoneEnd;
+}
+alias NTFS_VOLUME_DATA_BUFFER* PNTFS_VOLUME_DATA_BUFFER;
+
+
+bool IsRecognizedPartition(BYTE t) {
+    return ((t & PARTITION_NTFT)
+      && ((t & ~VALID_NTFT) == PARTITION_FAT_12
+        || (t & ~VALID_NTFT) == PARTITION_FAT_16
+        || (t & ~VALID_NTFT) == PARTITION_IFS
+        || (t & ~VALID_NTFT) == PARTITION_HUGE
+        || (t & ~VALID_NTFT) == PARTITION_FAT32
+        || (t & ~VALID_NTFT) == PARTITION_FAT32_XINT13
+        || (t & ~VALID_NTFT) == PARTITION_XINT13))
+      || (t & ~PARTITION_NTFT) == PARTITION_FAT_12
+      || (t & ~PARTITION_NTFT) == PARTITION_FAT_16
+      || (t & ~PARTITION_NTFT) == PARTITION_IFS
+      || (t & ~PARTITION_NTFT) == PARTITION_HUGE
+      || (t & ~PARTITION_NTFT) == PARTITION_FAT32
+      || (t & ~PARTITION_NTFT) == PARTITION_FAT32_XINT13
+      || (t & ~PARTITION_NTFT) == PARTITION_XINT13;
+}
+
+bool IsContainerPartition(BYTE t) {
+    return ((t & PARTITION_NTFT)
+      && ((t & ~VALID_NTFT) == PARTITION_EXTENDED
+        || (t & ~VALID_NTFT) == PARTITION_XINT13_EXTENDED))
+      || (t & ~PARTITION_NTFT) == PARTITION_EXTENDED
+      || (t & ~PARTITION_NTFT) == PARTITION_XINT13_EXTENDED;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/winldap.d b/libphobos/libdruntime/core/sys/windows/winldap.d
new file mode 100644
index 00000000000..fb3e8848ce5
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winldap.d
@@ -0,0 +1,856 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winldap.d)
+ */
+module core.sys.windows.winldap;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+/* Comment from MinGW
+  winldap.h - Header file for the Windows LDAP API
+
+  Written by Filip Navara <xnavara@volny.cz>
+
+  References:
+    The C LDAP Application Program Interface
+    http://www.watersprings.org/pub/id/draft-ietf-ldapext-ldap-c-api-05.txt
+
+    Lightweight Directory Access Protocol Reference
+    http://msdn.microsoft.com/library/en-us/netdir/ldap/ldap_reference.asp
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+*/
+
+import core.sys.windows.schannel, core.sys.windows.winber;
+private import core.sys.windows.wincrypt, core.sys.windows.windef;
+version(Tango){
+    private import tango.stdc.stdio;
+}
+
+align(4):
+
+enum {
+    LDAP_VERSION1    = 1,
+    LDAP_VERSION2    = 2,
+    LDAP_VERSION3    = 3,
+    LDAP_VERSION     = LDAP_VERSION2,
+    LDAP_VERSION_MIN = LDAP_VERSION2,
+    LDAP_VERSION_MAX = LDAP_VERSION3
+}
+
+/*  MinGW defines ANSI and Unicode versions as LDAP_VENDOR_NAME and
+ *  LDAP_VENDOR_NAME_W respectively; similarly with other string constants
+ *  defined in this module.
+ */
+const TCHAR[] LDAP_VENDOR_NAME = "Microsoft Corporation.";
+
+enum LDAP_API_VERSION          = 2004;
+enum LDAP_VENDOR_VERSION       =  510;
+enum LDAP_API_INFO_VERSION     =    1;
+enum LDAP_FEATURE_INFO_VERSION =    1;
+
+enum {
+    LDAP_SUCCESS                    = 0x00,
+    LDAP_OPT_SUCCESS                = LDAP_SUCCESS,
+    LDAP_OPERATIONS_ERROR,
+    LDAP_PROTOCOL_ERROR,
+    LDAP_TIMELIMIT_EXCEEDED,
+    LDAP_SIZELIMIT_EXCEEDED,
+    LDAP_COMPARE_FALSE,
+    LDAP_COMPARE_TRUE,
+    LDAP_STRONG_AUTH_NOT_SUPPORTED,
+    LDAP_AUTH_METHOD_NOT_SUPPORTED  = LDAP_STRONG_AUTH_NOT_SUPPORTED,
+    LDAP_STRONG_AUTH_REQUIRED,
+    LDAP_REFERRAL_V2,
+    LDAP_PARTIAL_RESULTS            = LDAP_REFERRAL_V2,
+    LDAP_REFERRAL,
+    LDAP_ADMIN_LIMIT_EXCEEDED,
+    LDAP_UNAVAILABLE_CRIT_EXTENSION,
+    LDAP_CONFIDENTIALITY_REQUIRED,
+    LDAP_SASL_BIND_IN_PROGRESS,  // = 0x0e
+    LDAP_NO_SUCH_ATTRIBUTE          = 0x10,
+    LDAP_UNDEFINED_TYPE,
+    LDAP_INAPPROPRIATE_MATCHING,
+    LDAP_CONSTRAINT_VIOLATION,
+    LDAP_TYPE_OR_VALUE_EXISTS,
+    LDAP_ATTRIBUTE_OR_VALUE_EXISTS  = LDAP_TYPE_OR_VALUE_EXISTS,
+    LDAP_INVALID_SYNTAX,         // = 0x15
+    LDAP_NO_SUCH_OBJECT             = 0x20,
+    LDAP_ALIAS_PROBLEM,
+    LDAP_INVALID_DN_SYNTAX,
+    LDAP_IS_LEAF,
+    LDAP_ALIAS_DEREF_PROBLEM,    // = 0x24
+    LDAP_INAPPROPRIATE_AUTH         = 0x30,
+    LDAP_INVALID_CREDENTIALS,
+    LDAP_INSUFFICIENT_ACCESS,
+    LDAP_INSUFFICIENT_RIGHTS        = LDAP_INSUFFICIENT_ACCESS,
+    LDAP_BUSY,
+    LDAP_UNAVAILABLE,
+    LDAP_UNWILLING_TO_PERFORM,
+    LDAP_LOOP_DETECT,            // = 0x36
+    LDAP_NAMING_VIOLATION           = 0x40,
+    LDAP_OBJECT_CLASS_VIOLATION,
+    LDAP_NOT_ALLOWED_ON_NONLEAF,
+    LDAP_NOT_ALLOWED_ON_RDN,
+    LDAP_ALREADY_EXISTS,
+    LDAP_NO_OBJECT_CLASS_MODS,
+    LDAP_RESULTS_TOO_LARGE,
+    LDAP_AFFECTS_MULTIPLE_DSAS,  // = 0x47
+    LDAP_OTHER                      = 0x50,
+    LDAP_SERVER_DOWN,
+    LDAP_LOCAL_ERROR,
+    LDAP_ENCODING_ERROR,
+    LDAP_DECODING_ERROR,
+    LDAP_TIMEOUT,
+    LDAP_AUTH_UNKNOWN,
+    LDAP_FILTER_ERROR,
+    LDAP_USER_CANCELLED,
+    LDAP_PARAM_ERROR,
+    LDAP_NO_MEMORY,
+    LDAP_CONNECT_ERROR,
+    LDAP_NOT_SUPPORTED,
+    LDAP_CONTROL_NOT_FOUND,
+    LDAP_NO_RESULTS_RETURNED,
+    LDAP_MORE_RESULTS_TO_RETURN,
+    LDAP_CLIENT_LOOP,
+    LDAP_REFERRAL_LIMIT_EXCEEDED // = 0x61
+}
+
+enum {
+    LDAP_PORT        =  389,
+    LDAP_SSL_PORT    =  636,
+    LDAP_GC_PORT     = 3268,
+    LDAP_SSL_GC_PORT = 3269
+}
+
+enum void*
+    LDAP_OPT_OFF = null,
+    LDAP_OPT_ON = cast(void*) 1;
+
+enum {
+    LDAP_OPT_API_INFO               = 0x00,
+    LDAP_OPT_DESC,
+    LDAP_OPT_DEREF,
+    LDAP_OPT_SIZELIMIT,
+    LDAP_OPT_TIMELIMIT,
+    LDAP_OPT_THREAD_FN_PTRS,
+    LDAP_OPT_REBIND_FN,
+    LDAP_OPT_REBIND_ARG,
+    LDAP_OPT_REFERRALS,
+    LDAP_OPT_RESTART,
+    LDAP_OPT_SSL,
+    LDAP_OPT_TLS                    = LDAP_OPT_SSL,
+    LDAP_OPT_IO_FN_PTRS,         // = 0x0b
+    LDAP_OPT_CACHE_FN_PTRS          = 0x0d,
+    LDAP_OPT_CACHE_STRATEGY,
+    LDAP_OPT_CACHE_ENABLE,
+    LDAP_OPT_REFERRAL_HOP_LIMIT,
+    LDAP_OPT_PROTOCOL_VERSION,
+    LDAP_OPT_VERSION                = LDAP_OPT_PROTOCOL_VERSION,
+    LDAP_OPT_SERVER_CONTROLS,
+    LDAP_OPT_CLIENT_CONTROLS,    // = 0x13
+    LDAP_OPT_API_FEATURE_INFO       = 0x15,
+    LDAP_OPT_HOST_NAME              = 0x30,
+    LDAP_OPT_ERROR_NUMBER,
+    LDAP_OPT_ERROR_STRING,
+    LDAP_OPT_SERVER_ERROR,
+    LDAP_OPT_SERVER_EXT_ERROR,   // = 0x34
+    LDAP_OPT_PING_KEEP_ALIVE        = 0x36,
+    LDAP_OPT_PING_WAIT_TIME,
+    LDAP_OPT_PING_LIMIT,         // = 0x38
+    LDAP_OPT_DNSDOMAIN_NAME         = 0x3b,
+    LDAP_OPT_GETDSNAME_FLAGS        = 0x3d,
+    LDAP_OPT_HOST_REACHABLE,
+    LDAP_OPT_PROMPT_CREDENTIALS,
+    LDAP_OPT_TCP_KEEPALIVE,      // = 0x40
+    LDAP_OPT_REFERRAL_CALLBACK      = 0x70,
+    LDAP_OPT_CLIENT_CERTIFICATE     = 0x80,
+    LDAP_OPT_SERVER_CERTIFICATE, // = 0x81
+    LDAP_OPT_AUTO_RECONNECT         = 0x91,
+    LDAP_OPT_SSPI_FLAGS,
+    LDAP_OPT_SSL_INFO,
+    LDAP_OPT_TLS_INFO               = LDAP_OPT_SSL_INFO,
+    LDAP_OPT_REF_DEREF_CONN_PER_MSG,
+    LDAP_OPT_SIGN,
+    LDAP_OPT_ENCRYPT,
+    LDAP_OPT_SASL_METHOD,
+    LDAP_OPT_AREC_EXCLUSIVE,
+    LDAP_OPT_SECURITY_CONTEXT,
+    LDAP_OPT_ROOTDSE_CACHE       // = 0x9a
+}
+
+enum {
+    LDAP_DEREF_NEVER,
+    LDAP_DEREF_SEARCHING,
+    LDAP_DEREF_FINDING,
+    LDAP_DEREF_ALWAYS
+}
+
+enum LDAP_NO_LIMIT = 0;
+
+const TCHAR[] LDAP_CONTROL_REFERRALS = "1.2.840.113556.1.4.616";
+
+// FIXME: check type (declared with U suffix in MinGW)
+enum : uint {
+    LDAP_CHASE_SUBORDINATE_REFERRALS = 0x20,
+    LDAP_CHASE_EXTERNAL_REFERRALS    = 0x40
+}
+
+enum {
+    LDAP_SCOPE_DEFAULT = -1,
+    LDAP_SCOPE_BASE,
+    LDAP_SCOPE_ONELEVEL,
+    LDAP_SCOPE_SUBTREE
+}
+
+enum {
+    LDAP_MOD_ADD,
+    LDAP_MOD_DELETE,
+    LDAP_MOD_REPLACE,
+    LDAP_MOD_BVALUES = 0x80
+}
+
+enum : int {
+    LDAP_RES_BIND             = 0x61,
+    LDAP_RES_SEARCH_ENTRY     = 0x64,
+    LDAP_RES_SEARCH_RESULT    = 0x65,
+    LDAP_RES_MODIFY           = 0x67,
+    LDAP_RES_ADD              = 0x69,
+    LDAP_RES_DELETE           = 0x6b,
+    LDAP_RES_MODRDN           = 0x6d,
+    LDAP_RES_COMPARE          = 0x6f,
+    LDAP_RES_SEARCH_REFERENCE = 0x73,
+    LDAP_RES_EXTENDED         = 0x78,
+    LDAP_RES_ANY              = -1
+}
+
+enum {
+    LDAP_MSG_ONE,
+    LDAP_MSG_ALL,
+    LDAP_MSG_RECEIVED
+}
+
+const TCHAR[]
+    LDAP_SERVER_SORT_OID         = "1.2.840.113556.1.4.473",
+    LDAP_SERVER_RESP_SORT_OID    = "1.2.840.113556.1.4.474",
+    LDAP_PAGED_RESULT_OID_STRING = "1.2.840.113556.1.4.319",
+    LDAP_CONTROL_VLVREQUEST      = "2.16.840.1.113730.3.4.9",
+    LDAP_CONTROL_VLVRESPONSE     = "2.16.840.1.113730.3.4.10",
+    LDAP_START_TLS_OID           = "1.3.6.1.4.1.1466.20037",
+    LDAP_TTL_EXTENDED_OP_OID     = "1.3.6.1.4.1.1466.101.119.1";
+
+enum {
+    LDAP_AUTH_NONE      = 0x00U,
+    LDAP_AUTH_SIMPLE    = 0x80U,
+    LDAP_AUTH_SASL      = 0x83U,
+    LDAP_AUTH_OTHERKIND = 0x86U,
+    LDAP_AUTH_EXTERNAL  = LDAP_AUTH_OTHERKIND | 0x0020U,
+    LDAP_AUTH_SICILY    = LDAP_AUTH_OTHERKIND | 0x0200U,
+    LDAP_AUTH_NEGOTIATE = LDAP_AUTH_OTHERKIND | 0x0400U,
+    LDAP_AUTH_MSN       = LDAP_AUTH_OTHERKIND | 0x0800U,
+    LDAP_AUTH_NTLM      = LDAP_AUTH_OTHERKIND | 0x1000U,
+    LDAP_AUTH_DIGEST    = LDAP_AUTH_OTHERKIND | 0x4000U,
+    LDAP_AUTH_DPA       = LDAP_AUTH_OTHERKIND | 0x2000U,
+    LDAP_AUTH_SSPI      = LDAP_AUTH_NEGOTIATE
+}
+
+enum {
+    LDAP_FILTER_AND        = 0xa0,
+    LDAP_FILTER_OR,
+    LDAP_FILTER_NOT,
+    LDAP_FILTER_EQUALITY,
+    LDAP_FILTER_SUBSTRINGS,
+    LDAP_FILTER_GE,
+    LDAP_FILTER_LE,     // = 0xa6
+    LDAP_FILTER_APPROX     = 0xa8,
+    LDAP_FILTER_EXTENSIBLE,
+    LDAP_FILTER_PRESENT    = 0x87
+}
+
+enum {
+    LDAP_SUBSTRING_INITIAL = 0x80,
+    LDAP_SUBSTRING_ANY,
+    LDAP_SUBSTRING_FINAL
+}
+
+struct LDAP {
+    char[76] Reserved;
+    PCHAR    ld_host;
+    ULONG    ld_version;
+    UCHAR    ld_lberoptions;
+    int      ld_deref;
+    int      ld_timelimit;
+    int      ld_sizelimit;
+    int      ld_errno;
+    PCHAR    ld_matched;
+    PCHAR    ld_error;
+}
+alias LDAP* PLDAP;
+
+struct LDAPMessage {
+    ULONG        lm_msgid;
+    ULONG        lm_msgtype;
+    BerElement*  lm_ber;
+    LDAPMessage* lm_chain;
+    LDAPMessage* lm_next;
+    ULONG        lm_time;
+}
+alias LDAPMessage* PLDAPMessage;
+
+struct LDAP_TIMEVAL {
+    LONG tv_sec;
+    LONG tv_usec;
+}
+alias LDAP_TIMEVAL* PLDAP_TIMEVAL;
+
+struct LDAPAPIInfoA {
+    int    ldapai_info_version;
+    int    ldapai_api_version;
+    int    ldapai_protocol_version;
+    char** ldapai_extensions;
+    char*  ldapai_vendor_name;
+    int    ldapai_vendor_version;
+}
+alias LDAPAPIInfoA* PLDAPAPIInfoA;
+
+struct LDAPAPIInfoW {
+    int     ldapai_info_version;
+    int     ldapai_api_version;
+    int     ldapai_protocol_version;
+    PWCHAR* ldapai_extensions;
+    PWCHAR  ldapai_vendor_name;
+    int     ldapai_vendor_version;
+}
+alias LDAPAPIInfoW* PLDAPAPIInfoW;
+
+struct LDAPAPIFeatureInfoA {
+    int   ldapaif_info_version;
+    char* ldapaif_name;
+    int   ldapaif_version;
+}
+alias LDAPAPIFeatureInfoA* PLDAPAPIFeatureInfoA;
+
+struct LDAPAPIFeatureInfoW {
+    int    ldapaif_info_version;
+    PWCHAR ldapaif_name;
+    int    ldapaif_version;
+}
+alias LDAPAPIFeatureInfoW* PLDAPAPIFeatureInfoW;
+
+struct LDAPControlA {
+    PCHAR    ldctl_oid;
+    BerValue ldctl_value;
+    BOOLEAN  ldctl_iscritical;
+}
+alias LDAPControlA* PLDAPControlA;
+
+struct LDAPControlW {
+    PWCHAR   ldctl_oid;
+    BerValue ldctl_value;
+    BOOLEAN  ldctl_iscritical;
+}
+alias LDAPControlW* PLDAPControlW;
+
+/*  Do we really need these?  In MinGW, LDAPModA/W have only mod_op, mod_type
+ *  and mod_vals, and macros are used to simulate anonymous unions in those
+ *  structures.
+ */
+union mod_vals_u_tA {
+    PCHAR*     modv_strvals;
+    BerValue** modv_bvals;
+}
+
+union mod_vals_u_tW {
+    PWCHAR*    modv_strvals;
+    BerValue** modv_bvals;
+}
+
+struct LDAPModA {
+    ULONG         mod_op;
+    PCHAR         mod_type;
+
+    union {
+        mod_vals_u_tA mod_vals;
+        // The following members are defined as macros in MinGW.
+        PCHAR*        mod_values;
+        BerValue**    mod_bvalues;
+    }
+}
+alias LDAPModA* PLDAPModA;
+
+struct LDAPModW {
+    ULONG         mod_op;
+    PWCHAR        mod_type;
+
+    union {
+        mod_vals_u_tW mod_vals;
+        // The following members are defined as macros in MinGW.
+        PWCHAR*       mod_values;
+        BerValue**    mod_bvalues;
+    }
+}
+alias LDAPModW* PLDAPModW;
+
+/* Opaque structure
+ *  http://msdn.microsoft.com/library/en-us/ldap/ldap/ldapsearch.asp
+ */
+struct LDAPSearch;
+alias LDAPSearch* PLDAPSearch;
+
+struct LDAPSortKeyA {
+    PCHAR   sk_attrtype;
+    PCHAR   sk_matchruleoid;
+    BOOLEAN sk_reverseorder;
+}
+alias LDAPSortKeyA* PLDAPSortKeyA;
+
+struct LDAPSortKeyW {
+    PWCHAR  sk_attrtype;
+    PWCHAR  sk_matchruleoid;
+    BOOLEAN sk_reverseorder;
+}
+alias LDAPSortKeyW* PLDAPSortKeyW;
+
+/*  MinGW defines these as immediate function typedefs, which don't translate
+ *  well into D.
+ */
+extern (C) {
+    alias ULONG function(PLDAP, PLDAP, PWCHAR, PCHAR, ULONG, PVOID, PVOID,
+      PLDAP*) QUERYFORCONNECTION;
+    alias BOOLEAN function(PLDAP, PLDAP, PWCHAR, PCHAR, PLDAP, ULONG, PVOID,
+      PVOID, ULONG) NOTIFYOFNEWCONNECTION;
+    alias ULONG function(PLDAP, PLDAP) DEREFERENCECONNECTION;
+    alias BOOLEAN function(PLDAP, PSecPkgContext_IssuerListInfoEx,
+      PCCERT_CONTEXT*) QUERYCLIENTCERT;
+}
+
+struct LDAP_REFERRAL_CALLBACK {
+    ULONG                  SizeOfCallbacks;
+    QUERYFORCONNECTION*    QueryForConnection;
+    NOTIFYOFNEWCONNECTION* NotifyRoutine;
+    DEREFERENCECONNECTION* DereferenceRoutine;
+}
+alias LDAP_REFERRAL_CALLBACK* PLDAP_REFERRAL_CALLBACK;
+
+struct LDAPVLVInfo {
+    int       ldvlv_version;
+    uint      ldvlv_before_count;
+    uint      ldvlv_after_count;
+    uint      ldvlv_offset;
+    uint      ldvlv_count;
+    BerValue* ldvlv_attrvalue;
+    BerValue* ldvlv_context;
+    void*     ldvlv_extradata;
+}
+
+/*
+ * Under Microsoft WinLDAP the function ldap_error is only stub.
+ * This macro uses LDAP structure to get error string and pass it to the user.
+ */
+private extern (C) int printf(in char* format, ...);
+int ldap_perror(LDAP* handle, char* message) {
+    return printf("%s: %s\n", message, handle.ld_error);
+}
+
+/*  FIXME: In MinGW, these are WINLDAPAPI == DECLSPEC_IMPORT.  Linkage
+ *  attribute?
+ */
+extern (C) {
+    PLDAP ldap_initA(PCHAR, ULONG);
+    PLDAP ldap_initW(PWCHAR, ULONG);
+    PLDAP ldap_openA(PCHAR, ULONG);
+    PLDAP ldap_openW(PWCHAR, ULONG);
+    PLDAP cldap_openA(PCHAR, ULONG);
+    PLDAP cldap_openW(PWCHAR, ULONG);
+    ULONG ldap_connect(LDAP*, LDAP_TIMEVAL*);
+    PLDAP ldap_sslinitA(PCHAR, ULONG, int);
+    PLDAP ldap_sslinitW(PWCHAR, ULONG, int);
+    ULONG ldap_start_tls_sA(LDAP*, PLDAPControlA*, PLDAPControlA*);
+    ULONG ldap_start_tls_sW(LDAP*, PLDAPControlW*, PLDAPControlW*);
+    BOOLEAN ldap_stop_tls_s(LDAP*);
+    ULONG ldap_get_optionA(LDAP*, int, void*);
+    ULONG ldap_get_optionW(LDAP*, int, void*);
+    ULONG ldap_set_optionA(LDAP*, int, void*);
+    ULONG ldap_set_optionW(LDAP*, int, void*);
+    ULONG ldap_control_freeA(LDAPControlA*);
+    ULONG ldap_control_freeW(LDAPControlW*);
+    ULONG ldap_controls_freeA(LDAPControlA**);
+    ULONG ldap_controls_freeW(LDAPControlW**);
+    ULONG ldap_free_controlsA(LDAPControlA**);
+    ULONG ldap_free_controlsW(LDAPControlW**);
+    ULONG ldap_sasl_bindA(LDAP*, PCHAR, PCHAR, BERVAL*, PLDAPControlA*,
+      PLDAPControlA*, int*);
+    ULONG ldap_sasl_bindW(LDAP*, PWCHAR, PWCHAR, BERVAL*, PLDAPControlW*,
+      PLDAPControlW*, int*);
+    ULONG ldap_sasl_bind_sA(LDAP*, PCHAR, PCHAR, BERVAL*, PLDAPControlA*,
+      PLDAPControlA*, PBERVAL*);
+    ULONG ldap_sasl_bind_sW(LDAP*, PWCHAR, PWCHAR, BERVAL*, PLDAPControlW*,
+      PLDAPControlW*, PBERVAL*);
+    ULONG ldap_simple_bindA(LDAP*, PCHAR, PCHAR);
+    ULONG ldap_simple_bindW(LDAP*, PWCHAR, PWCHAR);
+    ULONG ldap_simple_bind_sA(LDAP*, PCHAR, PCHAR);
+    ULONG ldap_simple_bind_sW(LDAP*, PWCHAR, PWCHAR);
+    ULONG ldap_unbind(LDAP*);
+    ULONG ldap_unbind_s(LDAP*);
+    ULONG ldap_search_extA(LDAP*, PCHAR, ULONG, PCHAR, PCHAR[], ULONG,
+      PLDAPControlW*, PLDAPControlW*, ULONG, ULONG, ULONG*);
+    ULONG ldap_search_extW(LDAP*, PWCHAR, ULONG, PWCHAR, PWCHAR[], ULONG,
+      PLDAPControlW*, PLDAPControlW*, ULONG, ULONG, ULONG*);
+    ULONG ldap_search_ext_sA(LDAP*, PCHAR, ULONG, PCHAR, PCHAR[], ULONG,
+      PLDAPControlA*, PLDAPControlA*, LDAP_TIMEVAL*, ULONG, LDAPMessage**);
+    ULONG ldap_search_ext_sW(LDAP*, PWCHAR, ULONG, PWCHAR, PWCHAR[], ULONG,
+      PLDAPControlW*, PLDAPControlW*, LDAP_TIMEVAL*, ULONG, LDAPMessage**);
+    ULONG ldap_searchA(LDAP*, PCHAR, ULONG, PCHAR, PCHAR[], ULONG);
+    ULONG ldap_searchW(LDAP*, PWCHAR, ULONG, PWCHAR, PWCHAR[], ULONG);
+    ULONG ldap_search_sA(LDAP*, PCHAR, ULONG, PCHAR, PCHAR[], ULONG,
+      LDAPMessage**);
+    ULONG ldap_search_sW(LDAP*, PWCHAR, ULONG, PWCHAR, PWCHAR[], ULONG,
+      LDAPMessage**);
+    ULONG ldap_search_stA(LDAP*, PCHAR, ULONG, PCHAR, PCHAR[], ULONG,
+      LDAP_TIMEVAL*, LDAPMessage**);
+    ULONG ldap_search_stW(LDAP*, PWCHAR, ULONG, PWCHAR, PWCHAR[], ULONG,
+      LDAP_TIMEVAL*, LDAPMessage**);
+    ULONG ldap_compare_extA(LDAP*, PCHAR, PCHAR, PCHAR, BerValue*,
+      PLDAPControlA*, PLDAPControlA*, ULONG*);
+    ULONG ldap_compare_extW(LDAP*, PWCHAR, PWCHAR, PWCHAR, BerValue*,
+      PLDAPControlW*, PLDAPControlW*, ULONG*);
+    ULONG ldap_compare_ext_sA(LDAP*, PCHAR, PCHAR, PCHAR, BerValue*,
+      PLDAPControlA*, PLDAPControlA*);
+    ULONG ldap_compare_ext_sW(LDAP*, PWCHAR, PWCHAR, PWCHAR, BerValue*,
+      PLDAPControlW*, PLDAPControlW*);
+    ULONG ldap_compareA(LDAP*, PCHAR, PCHAR, PCHAR);
+    ULONG ldap_compareW(LDAP*, PWCHAR, PWCHAR, PWCHAR);
+    ULONG ldap_compare_sA(LDAP*, PCHAR, PCHAR, PCHAR);
+    ULONG ldap_compare_sW(LDAP*, PWCHAR, PWCHAR, PWCHAR);
+    ULONG ldap_modify_extA(LDAP*, PCHAR, LDAPModA*[], PLDAPControlA*,
+      PLDAPControlA*, ULONG*);
+    ULONG ldap_modify_extW(LDAP*, PWCHAR, LDAPModW*[], PLDAPControlW*,
+      PLDAPControlW*, ULONG*);
+    ULONG ldap_modify_ext_sA(LDAP*, PCHAR, LDAPModA*[], PLDAPControlA*,
+      PLDAPControlA*);
+    ULONG ldap_modify_ext_sW(LDAP*, PWCHAR, LDAPModW*[], PLDAPControlW*,
+      PLDAPControlW*);
+    ULONG ldap_modifyA(LDAP*, PCHAR, LDAPModA*[]);
+    ULONG ldap_modifyW(LDAP*, PWCHAR, LDAPModW*[]);
+    ULONG ldap_modify_sA(LDAP*, PCHAR, LDAPModA*[]);
+    ULONG ldap_modify_sW(LDAP*, PWCHAR, LDAPModW*[]);
+    ULONG ldap_rename_extA(LDAP*, PCHAR, PCHAR, PCHAR, INT, PLDAPControlA*,
+      PLDAPControlA*, ULONG*);
+    ULONG ldap_rename_extW(LDAP*, PWCHAR, PWCHAR, PWCHAR, INT, PLDAPControlW*,
+      PLDAPControlW*, ULONG*);
+    ULONG ldap_rename_ext_sA(LDAP*, PCHAR, PCHAR, PCHAR, INT,
+      PLDAPControlA*, PLDAPControlA*);
+    ULONG ldap_rename_ext_sW(LDAP*, PWCHAR, PWCHAR, PWCHAR, INT,
+      PLDAPControlW*, PLDAPControlW*);
+    ULONG ldap_add_extA(LDAP*, PCHAR, LDAPModA*[], PLDAPControlA*,
+      PLDAPControlA*, ULONG*);
+    ULONG ldap_add_extW(LDAP*, PWCHAR, LDAPModW*[], PLDAPControlW*,
+      PLDAPControlW*, ULONG*);
+    ULONG ldap_add_ext_sA(LDAP*, PCHAR, LDAPModA*[], PLDAPControlA*,
+      PLDAPControlA*);
+    ULONG ldap_add_ext_sW(LDAP*, PWCHAR, LDAPModW*[], PLDAPControlW*,
+      PLDAPControlW*);
+    ULONG ldap_addA(LDAP*, PCHAR, LDAPModA*[]);
+    ULONG ldap_addW(LDAP*, PWCHAR, LDAPModW*[]);
+    ULONG ldap_add_sA(LDAP*, PCHAR, LDAPModA*[]);
+    ULONG ldap_add_sW(LDAP*, PWCHAR, LDAPModW*[]);
+    ULONG ldap_delete_extA(LDAP*, PCHAR, PLDAPControlA*, PLDAPControlA*,
+      ULONG*);
+    ULONG ldap_delete_extW(LDAP*, PWCHAR, PLDAPControlW*, PLDAPControlW*,
+      ULONG*);
+    ULONG ldap_delete_ext_sA(LDAP*, PCHAR, PLDAPControlA*, PLDAPControlA*);
+    ULONG ldap_delete_ext_sW(LDAP*, PWCHAR, PLDAPControlW*, PLDAPControlW*);
+    ULONG ldap_deleteA(LDAP*, PCHAR);
+    ULONG ldap_deleteW(LDAP*, PWCHAR);
+    ULONG ldap_delete_sA(LDAP*, PCHAR);
+    ULONG ldap_delete_sW(LDAP*, PWCHAR);
+    ULONG ldap_extended_operationA(LDAP*, PCHAR, BerValue*, PLDAPControlA*,
+      PLDAPControlA*, ULONG*);
+    ULONG ldap_extended_operationW(LDAP*, PWCHAR, BerValue*, PLDAPControlW*,
+      PLDAPControlW*, ULONG*);
+    ULONG ldap_extended_operation_sA(LDAP*, PCHAR, BerValue*, PLDAPControlA*,
+      PLDAPControlA*, PCHAR*, BerValue**);
+    ULONG ldap_extended_operation_sW(LDAP*, PWCHAR, BerValue*, PLDAPControlW*,
+      PLDAPControlW*, PWCHAR*, BerValue**);
+    ULONG ldap_close_extended_op(LDAP*, ULONG);
+    ULONG ldap_abandon(LDAP*, ULONG);
+    ULONG ldap_result(LDAP*, ULONG, ULONG, LDAP_TIMEVAL*, LDAPMessage**);
+    ULONG ldap_msgfree(LDAPMessage*);
+    ULONG ldap_parse_resultA(LDAP*, LDAPMessage*, ULONG*, PCHAR*, PCHAR*,
+      PCHAR**, PLDAPControlA**, BOOLEAN);
+    ULONG ldap_parse_resultW(LDAP*, LDAPMessage*, ULONG*, PWCHAR*, PWCHAR*,
+      PWCHAR**, PLDAPControlW**, BOOLEAN);
+    ULONG ldap_parse_extended_resultA(LDAP, LDAPMessage*, PCHAR*, BerValue**,
+      BOOLEAN);
+    ULONG ldap_parse_extended_resultW(LDAP, LDAPMessage*, PWCHAR*, BerValue**,
+      BOOLEAN);
+    PCHAR ldap_err2stringA(ULONG);
+    PWCHAR ldap_err2stringW(ULONG);
+    ULONG LdapGetLastError();
+    ULONG LdapMapErrorToWin32(ULONG);
+    ULONG ldap_result2error(LDAP*, LDAPMessage*, ULONG);
+    PLDAPMessage ldap_first_entry(LDAP*, LDAPMessage*);
+    PLDAPMessage ldap_next_entry(LDAP*, LDAPMessage*);
+    PLDAPMessage ldap_first_reference(LDAP*, LDAPMessage*);
+    PLDAPMessage ldap_next_reference(LDAP*, LDAPMessage*);
+    ULONG ldap_count_entries(LDAP*, LDAPMessage*);
+    ULONG ldap_count_references(LDAP*, LDAPMessage*);
+    PCHAR ldap_first_attributeA(LDAP*, LDAPMessage*, BerElement**);
+    PWCHAR ldap_first_attributeW(LDAP*, LDAPMessage*, BerElement**);
+    PCHAR ldap_next_attributeA(LDAP*, LDAPMessage*, BerElement*);
+    PWCHAR ldap_next_attributeW(LDAP*, LDAPMessage*, BerElement*);
+    VOID ldap_memfreeA(PCHAR);
+    VOID ldap_memfreeW(PWCHAR);
+    PCHAR* ldap_get_valuesA(LDAP*, LDAPMessage*, PCHAR);
+    PWCHAR* ldap_get_valuesW(LDAP*, LDAPMessage*, PWCHAR);
+    BerValue** ldap_get_values_lenA(LDAP*, LDAPMessage*, PCHAR);
+    BerValue** ldap_get_values_lenW(LDAP*, LDAPMessage*, PWCHAR);
+    ULONG ldap_count_valuesA(PCHAR*);
+    ULONG ldap_count_valuesW(PWCHAR*);
+    ULONG ldap_count_values_len(BerValue**);
+    ULONG ldap_value_freeA(PCHAR*);
+    ULONG ldap_value_freeW(PWCHAR*);
+    ULONG ldap_value_free_len(BerValue**);
+    PCHAR ldap_get_dnA(LDAP*, LDAPMessage*);
+    PWCHAR ldap_get_dnW(LDAP*, LDAPMessage*);
+    PCHAR ldap_explode_dnA(PCHAR, ULONG);
+    PWCHAR ldap_explode_dnW(PWCHAR, ULONG);
+    PCHAR ldap_dn2ufnA(PCHAR);
+    PWCHAR ldap_dn2ufnW(PWCHAR);
+    ULONG ldap_ufn2dnA(PCHAR, PCHAR*);
+    ULONG ldap_ufn2dnW(PWCHAR, PWCHAR*);
+    ULONG ldap_parse_referenceA(LDAP*, LDAPMessage*, PCHAR**);
+    ULONG ldap_parse_referenceW(LDAP*, LDAPMessage*, PWCHAR**);
+    ULONG ldap_check_filterA(LDAP*, PCHAR);
+    ULONG ldap_check_filterW(LDAP*, PWCHAR);
+    ULONG ldap_create_page_controlA(PLDAP, ULONG, BerValue*, UCHAR,
+      PLDAPControlA*);
+    ULONG ldap_create_page_controlW(PLDAP, ULONG, BerValue*, UCHAR,
+      PLDAPControlW*);
+    ULONG ldap_create_sort_controlA(PLDAP, PLDAPSortKeyA*, UCHAR,
+      PLDAPControlA*);
+    ULONG ldap_create_sort_controlW(PLDAP, PLDAPSortKeyW*, UCHAR,
+    PLDAPControlW*);
+    INT ldap_create_vlv_controlA(LDAP*, LDAPVLVInfo*, UCHAR, LDAPControlA**);
+    INT ldap_create_vlv_controlW(LDAP*, LDAPVLVInfo*, UCHAR, LDAPControlW**);
+    ULONG ldap_encode_sort_controlA(PLDAP, PLDAPSortKeyA*, PLDAPControlA,
+      BOOLEAN);
+    ULONG ldap_encode_sort_controlW(PLDAP, PLDAPSortKeyW*, PLDAPControlW,
+      BOOLEAN);
+    ULONG ldap_escape_filter_elementA(PCHAR, ULONG, PCHAR, ULONG);
+    ULONG ldap_escape_filter_elementW(PWCHAR, ULONG, PWCHAR, ULONG);
+    ULONG ldap_get_next_page(PLDAP, PLDAPSearch, ULONG, ULONG*);
+    ULONG ldap_get_next_page_s(PLDAP, PLDAPSearch, LDAP_TIMEVAL*, ULONG,
+      ULONG*, LDAPMessage**);
+    ULONG ldap_get_paged_count(PLDAP, PLDAPSearch, ULONG*, PLDAPMessage);
+    ULONG ldap_parse_page_controlA(PLDAP, PLDAPControlA*, ULONG*, BerValue**);
+    ULONG ldap_parse_page_controlW(PLDAP, PLDAPControlW*, ULONG*, BerValue**);
+    ULONG ldap_parse_sort_controlA(PLDAP, PLDAPControlA*, ULONG*, PCHAR*);
+    ULONG ldap_parse_sort_controlW(PLDAP, PLDAPControlW*, ULONG*, PWCHAR*);
+    INT ldap_parse_vlv_controlA(LDAP*, LDAPControlA**, uint*, uint*,
+      BerValue**, int*);
+    INT ldap_parse_vlv_controlW(LDAP*, LDAPControlW**, uint*, uint*,
+      BerValue**, int*);
+    PLDAPSearch ldap_search_init_pageA(PLDAP, PCHAR, ULONG, PCHAR, PCHAR[],
+      ULONG, PLDAPControlA*, PLDAPControlA*, ULONG, ULONG, PLDAPSortKeyA*);
+    PLDAPSearch ldap_search_init_pageW(PLDAP, PWCHAR, ULONG, PWCHAR, PWCHAR[],
+      ULONG, PLDAPControlW*, PLDAPControlW*, ULONG, ULONG, PLDAPSortKeyW*);
+    ULONG ldap_search_abandon_page(PLDAP, PLDAPSearch);
+    LDAP ldap_conn_from_msg(LDAP*, LDAPMessage*);
+    INT LdapUnicodeToUTF8(LPCWSTR, int, LPSTR, int);
+    INT LdapUTF8ToUnicode(LPCSTR, int, LPWSTR, int);
+    deprecated {
+        ULONG ldap_bindA(LDAP*, PCHAR, PCHAR, ULONG);
+        ULONG ldap_bindW(LDAP*, PWCHAR, PWCHAR, ULONG);
+        ULONG ldap_bind_sA(LDAP*, PCHAR, PCHAR, ULONG);
+        ULONG ldap_bind_sW(LDAP*, PWCHAR, PWCHAR, ULONG);
+        ULONG ldap_modrdnA(LDAP*, PCHAR, PCHAR);
+        ULONG ldap_modrdnW(LDAP*, PWCHAR, PWCHAR);
+        ULONG ldap_modrdn_sA(LDAP*, PCHAR, PCHAR);
+        ULONG ldap_modrdn_sW(LDAP*, PWCHAR, PWCHAR);
+        ULONG ldap_modrdn2A(LDAP*, PCHAR, PCHAR, INT);
+        ULONG ldap_modrdn2W(LDAP*, PWCHAR, PWCHAR, INT);
+        ULONG ldap_modrdn2_sA(LDAP*, PCHAR, PCHAR, INT);
+        ULONG ldap_modrdn2_sW(LDAP*, PWCHAR, PWCHAR, INT);
+    }
+}
+
+version (Unicode) {
+    alias LDAPControlW LDAPControl;
+    alias PLDAPControlW PLDAPControl;
+    alias LDAPModW LDAPMod;
+    alias LDAPModW PLDAPMod;
+    alias LDAPSortKeyW LDAPSortKey;
+    alias PLDAPSortKeyW PLDAPSortKey;
+    alias LDAPAPIInfoW LDAPAPIInfo;
+    alias PLDAPAPIInfoW PLDAPAPIInfo;
+    alias LDAPAPIFeatureInfoW LDAPAPIFeatureInfo;
+    alias PLDAPAPIFeatureInfoW PLDAPAPIFeatureInfo;
+    alias cldap_openW cldap_open;
+    alias ldap_openW ldap_open;
+    alias ldap_simple_bindW ldap_simple_bind;
+    alias ldap_simple_bind_sW ldap_simple_bind_s;
+    alias ldap_sasl_bindW ldap_sasl_bind;
+    alias ldap_sasl_bind_sW ldap_sasl_bind_s;
+    alias ldap_initW ldap_init;
+    alias ldap_sslinitW ldap_sslinit;
+    alias ldap_get_optionW ldap_get_option;
+    alias ldap_set_optionW ldap_set_option;
+    alias ldap_start_tls_sW ldap_start_tls_s;
+    alias ldap_addW ldap_add;
+    alias ldap_add_extW ldap_add_ext;
+    alias ldap_add_sW ldap_add_s;
+    alias ldap_add_ext_sW ldap_add_ext_s;
+    alias ldap_compareW ldap_compare;
+    alias ldap_compare_extW ldap_compare_ext;
+    alias ldap_compare_sW ldap_compare_s;
+    alias ldap_compare_ext_sW ldap_compare_ext_s;
+    alias ldap_deleteW ldap_delete;
+    alias ldap_delete_extW ldap_delete_ext;
+    alias ldap_delete_sW ldap_delete_s;
+    alias ldap_delete_ext_sW ldap_delete_ext_s;
+    alias ldap_extended_operation_sW ldap_extended_operation_s;
+    alias ldap_extended_operationW ldap_extended_operation;
+    alias ldap_modifyW ldap_modify;
+    alias ldap_modify_extW ldap_modify_ext;
+    alias ldap_modify_sW ldap_modify_s;
+    alias ldap_modify_ext_sW ldap_modify_ext_s;
+    alias ldap_check_filterW ldap_check_filter;
+    alias ldap_count_valuesW ldap_count_values;
+    alias ldap_create_page_controlW ldap_create_page_control;
+    alias ldap_create_sort_controlW ldap_create_sort_control;
+    alias ldap_create_vlv_controlW ldap_create_vlv_control;
+    alias ldap_encode_sort_controlW ldap_encode_sort_control;
+    alias ldap_escape_filter_elementW ldap_escape_filter_element;
+    alias ldap_first_attributeW ldap_first_attribute;
+    alias ldap_next_attributeW ldap_next_attribute;
+    alias ldap_get_valuesW ldap_get_values;
+    alias ldap_get_values_lenW ldap_get_values_len;
+    alias ldap_parse_extended_resultW ldap_parse_extended_result;
+    alias ldap_parse_page_controlW ldap_parse_page_control;
+    alias ldap_parse_referenceW ldap_parse_reference;
+    alias ldap_parse_resultW ldap_parse_result;
+    alias ldap_parse_sort_controlW ldap_parse_sort_control;
+    alias ldap_parse_vlv_controlW ldap_parse_vlv_control;
+    alias ldap_searchW ldap_search;
+    alias ldap_search_sW ldap_search_s;
+    alias ldap_search_stW ldap_search_st;
+    alias ldap_search_extW ldap_search_ext;
+    alias ldap_search_ext_sW ldap_search_ext_s;
+    alias ldap_search_init_pageW ldap_search_init_page;
+    alias ldap_err2stringW ldap_err2string;
+    alias ldap_control_freeW ldap_control_free;
+    alias ldap_controls_freeW ldap_controls_free;
+    alias ldap_free_controlsW ldap_free_controls;
+    alias ldap_memfreeW ldap_memfree;
+    alias ldap_value_freeW ldap_value_free;
+    alias ldap_dn2ufnW ldap_dn2ufn;
+    alias ldap_ufn2dnW ldap_ufn2dn;
+    alias ldap_explode_dnW ldap_explode_dn;
+    alias ldap_get_dnW ldap_get_dn;
+    alias ldap_rename_extW ldap_rename;
+    alias ldap_rename_ext_sW ldap_rename_s;
+    alias ldap_rename_extW ldap_rename_ext;
+    alias ldap_rename_ext_sW ldap_rename_ext_s;
+    deprecated {
+        alias ldap_bindW ldap_bind;
+        alias ldap_bind_sW ldap_bind_s;
+        alias ldap_modrdnW ldap_modrdn;
+        alias ldap_modrdn_sW ldap_modrdn_s;
+        alias ldap_modrdn2W ldap_modrdn2;
+        alias ldap_modrdn2_sW ldap_modrdn2_s;
+    }
+} else {
+    alias LDAPControlA LDAPControl;
+    alias PLDAPControlA PLDAPControl;
+    alias LDAPModA LDAPMod;
+    alias LDAPModA PLDAPMod;
+    alias LDAPSortKeyA LDAPSortKey;
+    alias PLDAPSortKeyA PLDAPSortKey;
+    alias LDAPAPIInfoA LDAPAPIInfo;
+    alias PLDAPAPIInfoA PLDAPAPIInfo;
+    alias LDAPAPIFeatureInfoA LDAPAPIFeatureInfo;
+    alias PLDAPAPIFeatureInfoA PLDAPAPIFeatureInfo;
+    alias cldap_openA cldap_open;
+    alias ldap_openA ldap_open;
+    alias ldap_simple_bindA ldap_simple_bind;
+    alias ldap_simple_bind_sA ldap_simple_bind_s;
+    alias ldap_sasl_bindA ldap_sasl_bind;
+    alias ldap_sasl_bind_sA ldap_sasl_bind_s;
+    alias ldap_initA ldap_init;
+    alias ldap_sslinitA ldap_sslinit;
+    alias ldap_get_optionA ldap_get_option;
+    alias ldap_set_optionA ldap_set_option;
+    alias ldap_start_tls_sA ldap_start_tls_s;
+    alias ldap_addA ldap_add;
+    alias ldap_add_extA ldap_add_ext;
+    alias ldap_add_sA ldap_add_s;
+    alias ldap_add_ext_sA ldap_add_ext_s;
+    alias ldap_compareA ldap_compare;
+    alias ldap_compare_extA ldap_compare_ext;
+    alias ldap_compare_sA ldap_compare_s;
+    alias ldap_compare_ext_sA ldap_compare_ext_s;
+    alias ldap_deleteA ldap_delete;
+    alias ldap_delete_extA ldap_delete_ext;
+    alias ldap_delete_sA ldap_delete_s;
+    alias ldap_delete_ext_sA ldap_delete_ext_s;
+    alias ldap_extended_operation_sA ldap_extended_operation_s;
+    alias ldap_extended_operationA ldap_extended_operation;
+    alias ldap_modifyA ldap_modify;
+    alias ldap_modify_extA ldap_modify_ext;
+    alias ldap_modify_sA ldap_modify_s;
+    alias ldap_modify_ext_sA ldap_modify_ext_s;
+    alias ldap_check_filterA ldap_check_filter;
+    alias ldap_count_valuesA ldap_count_values;
+    alias ldap_create_page_controlA ldap_create_page_control;
+    alias ldap_create_sort_controlA ldap_create_sort_control;
+    alias ldap_create_vlv_controlA ldap_create_vlv_control;
+    alias ldap_encode_sort_controlA ldap_encode_sort_control;
+    alias ldap_escape_filter_elementA ldap_escape_filter_element;
+    alias ldap_first_attributeA ldap_first_attribute;
+    alias ldap_next_attributeA ldap_next_attribute;
+    alias ldap_get_valuesA ldap_get_values;
+    alias ldap_get_values_lenA ldap_get_values_len;
+    alias ldap_parse_extended_resultA ldap_parse_extended_result;
+    alias ldap_parse_page_controlA ldap_parse_page_control;
+    alias ldap_parse_referenceA ldap_parse_reference;
+    alias ldap_parse_resultA ldap_parse_result;
+    alias ldap_parse_sort_controlA ldap_parse_sort_control;
+    alias ldap_parse_vlv_controlA ldap_parse_vlv_control;
+    alias ldap_searchA ldap_search;
+    alias ldap_search_sA ldap_search_s;
+    alias ldap_search_stA ldap_search_st;
+    alias ldap_search_extA ldap_search_ext;
+    alias ldap_search_ext_sA ldap_search_ext_s;
+    alias ldap_search_init_pageA ldap_search_init_page;
+    alias ldap_err2stringA ldap_err2string;
+    alias ldap_control_freeA ldap_control_free;
+    alias ldap_controls_freeA ldap_controls_free;
+    alias ldap_free_controlsA ldap_free_controls;
+    alias ldap_memfreeA ldap_memfree;
+    alias ldap_value_freeA ldap_value_free;
+    alias ldap_dn2ufnA ldap_dn2ufn;
+    alias ldap_ufn2dnA ldap_ufn2dn;
+    alias ldap_explode_dnA ldap_explode_dn;
+    alias ldap_get_dnA ldap_get_dn;
+    alias ldap_rename_extA ldap_rename;
+    alias ldap_rename_ext_sA ldap_rename_s;
+    alias ldap_rename_extA ldap_rename_ext;
+    alias ldap_rename_ext_sA ldap_rename_ext_s;
+    deprecated {
+        alias ldap_bindA ldap_bind;
+        alias ldap_bind_sA ldap_bind_s;
+        alias ldap_modrdnA ldap_modrdn;
+        alias ldap_modrdn_sA ldap_modrdn_s;
+        alias ldap_modrdn2A ldap_modrdn2;
+        alias ldap_modrdn2_sA ldap_modrdn2_s;
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/windows/winnetwk.d b/libphobos/libdruntime/core/sys/windows/winnetwk.d
new file mode 100644
index 00000000000..a9a3ddd044b
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winnetwk.d
@@ -0,0 +1,440 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winnetwk.d)
+ */
+module core.sys.windows.winnetwk;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "mpr");
+
+private import core.sys.windows.winbase, core.sys.windows.winerror, core.sys.windows.winnt;
+
+enum : DWORD {
+    WNNC_NET_MSNET       = 0x00010000,
+    WNNC_NET_LANMAN      = 0x00020000,
+    WNNC_NET_NETWARE     = 0x00030000,
+    WNNC_NET_VINES       = 0x00040000,
+    WNNC_NET_10NET       = 0x00050000,
+    WNNC_NET_LOCUS       = 0x00060000,
+    WNNC_NET_SUN_PC_NFS  = 0x00070000,
+    WNNC_NET_LANSTEP     = 0x00080000,
+    WNNC_NET_9TILES      = 0x00090000,
+    WNNC_NET_LANTASTIC   = 0x000A0000,
+    WNNC_NET_AS400       = 0x000B0000,
+    WNNC_NET_FTP_NFS     = 0x000C0000,
+    WNNC_NET_PATHWORKS   = 0x000D0000,
+    WNNC_NET_LIFENET     = 0x000E0000,
+    WNNC_NET_POWERLAN    = 0x000F0000,
+    WNNC_NET_BWNFS       = 0x00100000,
+    WNNC_NET_COGENT      = 0x00110000,
+    WNNC_NET_FARALLON    = 0x00120000,
+    WNNC_NET_APPLETALK   = 0x00130000,
+    WNNC_NET_INTERGRAPH  = 0x00140000,
+    WNNC_NET_SYMFONET    = 0x00150000,
+    WNNC_NET_CLEARCASE   = 0x00160000,
+    WNNC_NET_FRONTIER    = 0x00170000,
+    WNNC_NET_BMC         = 0x00180000,
+    WNNC_NET_DCE         = 0x00190000,
+    WNNC_NET_AVID        = 0x001A0000,
+    WNNC_NET_DOCUSPACE   = 0x001B0000,
+    WNNC_NET_MANGOSOFT   = 0x001C0000,
+    WNNC_NET_SERNET      = 0x001D0000,
+    WNNC_NET_DECORB      = 0x00200000,
+    WNNC_NET_PROTSTOR    = 0x00210000,
+    WNNC_NET_FJ_REDIR    = 0x00220000,
+    WNNC_NET_DISTINCT    = 0x00230000,
+    WNNC_NET_TWINS       = 0x00240000,
+    WNNC_NET_RDR2SAMPLE  = 0x00250000,
+    WNNC_NET_CSC         = 0x00260000,
+    WNNC_NET_3IN1        = 0x00270000,
+    WNNC_NET_EXTENDNET   = 0x00290000,
+    WNNC_NET_OBJECT_DIRE = 0x00300000,
+    WNNC_NET_MASFAX      = 0x00310000,
+    WNNC_NET_HOB_NFS     = 0x00320000,
+    WNNC_NET_SHIVA       = 0x00330000,
+    WNNC_NET_IBMAL       = 0x00340000,
+    WNNC_CRED_MANAGER    = 0xFFFF0000
+}
+
+enum : DWORD {
+    RESOURCE_CONNECTED  = 1,
+    RESOURCE_GLOBALNET  = 2,
+    RESOURCE_REMEMBERED = 3,
+    RESOURCE_RECENT     = 4,
+    RESOURCE_CONTEXT    = 5
+}
+
+enum DWORD
+    RESOURCETYPE_ANY      = 0,
+    RESOURCETYPE_DISK     = 1,
+    RESOURCETYPE_PRINT    = 2,
+    RESOURCETYPE_RESERVED = 8,
+    RESOURCETYPE_UNKNOWN  = 0xFFFFFFFF;
+
+enum DWORD
+    RESOURCEUSAGE_CONNECTABLE   = 0x00000001,
+    RESOURCEUSAGE_CONTAINER     = 0x00000002,
+    RESOURCEUSAGE_NOLOCALDEVICE = 0x00000004,
+    RESOURCEUSAGE_SIBLING       = 0x00000008,
+    RESOURCEUSAGE_ATTACHED      = 0x00000010,
+    RESOURCEUSAGE_ALL           = (RESOURCEUSAGE_CONNECTABLE
+                                  | RESOURCEUSAGE_CONTAINER
+                                  | RESOURCEUSAGE_ATTACHED),
+    RESOURCEUSAGE_RESERVED      = 0x80000000;
+
+enum : DWORD {
+    RESOURCEDISPLAYTYPE_GENERIC,
+    RESOURCEDISPLAYTYPE_DOMAIN,
+    RESOURCEDISPLAYTYPE_SERVER,
+    RESOURCEDISPLAYTYPE_SHARE,
+    RESOURCEDISPLAYTYPE_FILE,
+    RESOURCEDISPLAYTYPE_GROUP,
+    RESOURCEDISPLAYTYPE_NETWORK,
+    RESOURCEDISPLAYTYPE_ROOT,
+    RESOURCEDISPLAYTYPE_SHAREADMIN,
+    RESOURCEDISPLAYTYPE_DIRECTORY,
+    RESOURCEDISPLAYTYPE_TREE // = 10
+}
+
+enum NETPROPERTY_PERSISTENT = 1;
+
+enum DWORD
+    CONNECT_UPDATE_PROFILE =   1,
+    CONNECT_UPDATE_RECENT  =   2,
+    CONNECT_TEMPORARY      =   4,
+    CONNECT_INTERACTIVE    =   8,
+    CONNECT_PROMPT         =  16,
+    CONNECT_NEED_DRIVE     =  32,
+    CONNECT_REFCOUNT       =  64,
+    CONNECT_REDIRECT       = 128,
+    CONNECT_LOCALDRIVE     = 256,
+    CONNECT_CURRENT_MEDIA  = 512;
+
+enum DWORD
+    CONNDLG_RO_PATH     =  1,
+    CONNDLG_CONN_POINT  =  2,
+    CONNDLG_USE_MRU     =  4,
+    CONNDLG_HIDE_BOX    =  8,
+    CONNDLG_PERSIST     = 16,
+    CONNDLG_NOT_PERSIST = 32;
+
+enum DWORD
+    DISC_UPDATE_PROFILE =  1,
+    DISC_NO_FORCE       = 64;
+
+enum DWORD
+    WNFMT_MULTILINE   =  1,
+    WNFMT_ABBREVIATED =  2,
+    WNFMT_INENUM      = 16,
+    WNFMT_CONNECTION  = 32;
+
+enum : DWORD {
+    WN_SUCCESS                   = NO_ERROR,
+    WN_NO_ERROR                  = NO_ERROR,
+    WN_NOT_SUPPORTED             = ERROR_NOT_SUPPORTED,
+    WN_CANCEL                    = ERROR_CANCELLED,
+    WN_RETRY                     = ERROR_RETRY,
+    WN_NET_ERROR                 = ERROR_UNEXP_NET_ERR,
+    WN_MORE_DATA                 = ERROR_MORE_DATA,
+    WN_BAD_POINTER               = ERROR_INVALID_ADDRESS,
+    WN_BAD_VALUE                 = ERROR_INVALID_PARAMETER,
+    WN_BAD_USER                  = ERROR_BAD_USERNAME,
+    WN_BAD_PASSWORD              = ERROR_INVALID_PASSWORD,
+    WN_ACCESS_DENIED             = ERROR_ACCESS_DENIED,
+    WN_FUNCTION_BUSY             = ERROR_BUSY,
+    WN_WINDOWS_ERROR             = ERROR_UNEXP_NET_ERR,
+    WN_OUT_OF_MEMORY             = ERROR_NOT_ENOUGH_MEMORY,
+    WN_NO_NETWORK                = ERROR_NO_NETWORK,
+    WN_EXTENDED_ERROR            = ERROR_EXTENDED_ERROR,
+    WN_BAD_LEVEL                 = ERROR_INVALID_LEVEL,
+    WN_BAD_HANDLE                = ERROR_INVALID_HANDLE,
+    WN_NOT_INITIALIZING          = ERROR_ALREADY_INITIALIZED,
+    WN_NO_MORE_DEVICES           = ERROR_NO_MORE_DEVICES,
+    WN_NOT_CONNECTED             = ERROR_NOT_CONNECTED,
+    WN_OPEN_FILES                = ERROR_OPEN_FILES,
+    WN_DEVICE_IN_USE             = ERROR_DEVICE_IN_USE,
+    WN_BAD_NETNAME               = ERROR_BAD_NET_NAME,
+    WN_BAD_LOCALNAME             = ERROR_BAD_DEVICE,
+    WN_ALREADY_CONNECTED         = ERROR_ALREADY_ASSIGNED,
+    WN_DEVICE_ERROR              = ERROR_GEN_FAILURE,
+    WN_CONNECTION_CLOSED         = ERROR_CONNECTION_UNAVAIL,
+    WN_NO_NET_OR_BAD_PATH        = ERROR_NO_NET_OR_BAD_PATH,
+    WN_BAD_PROVIDER              = ERROR_BAD_PROVIDER,
+    WN_CANNOT_OPEN_PROFILE       = ERROR_CANNOT_OPEN_PROFILE,
+    WN_BAD_PROFILE               = ERROR_BAD_PROFILE,
+    WN_BAD_DEV_TYPE              = ERROR_BAD_DEV_TYPE,
+    WN_DEVICE_ALREADY_REMEMBERED = ERROR_DEVICE_ALREADY_REMEMBERED,
+    WN_NO_MORE_ENTRIES           = ERROR_NO_MORE_ITEMS,
+    WN_NOT_CONTAINER             = ERROR_NOT_CONTAINER,
+    WN_NOT_AUTHENTICATED         = ERROR_NOT_AUTHENTICATED,
+    WN_NOT_LOGGED_ON             = ERROR_NOT_LOGGED_ON,
+    WN_NOT_VALIDATED             = ERROR_NO_LOGON_SERVERS
+}
+
+enum : DWORD {
+    UNIVERSAL_NAME_INFO_LEVEL = 1,
+    REMOTE_NAME_INFO_LEVEL
+}
+
+enum DWORD
+    NETINFO_DLL16      = 1,
+    NETINFO_DISKRED    = 4,
+    NETINFO_PRINTERRED = 8;
+
+enum DWORD
+    RP_LOGON   = 1,
+    RP_INIFILE = 2;
+
+enum DWORD PP_DISPLAYERRORS = 1;
+
+enum DWORD
+    WNCON_FORNETCARD = 1,
+    WNCON_NOTROUTED  = 2,
+    WNCON_SLOWLINK   = 4,
+    WNCON_DYNAMIC    = 8;
+
+struct NETRESOURCEA {
+    DWORD dwScope;
+    DWORD dwType;
+    DWORD dwDisplayType;
+    DWORD dwUsage;
+    LPSTR lpLocalName;
+    LPSTR lpRemoteName;
+    LPSTR lpComment;
+    LPSTR lpProvider;
+}
+alias NETRESOURCEA* LPNETRESOURCEA;
+
+struct NETRESOURCEW {
+    DWORD  dwScope;
+    DWORD  dwType;
+    DWORD  dwDisplayType;
+    DWORD  dwUsage;
+    LPWSTR lpLocalName;
+    LPWSTR lpRemoteName;
+    LPWSTR lpComment ;
+    LPWSTR lpProvider;
+}
+alias NETRESOURCEW* LPNETRESOURCEW;
+
+struct CONNECTDLGSTRUCTA {
+    DWORD          cbStructure;
+    HWND           hwndOwner;
+    LPNETRESOURCEA lpConnRes;
+    DWORD          dwFlags;
+    DWORD          dwDevNum;
+}
+alias CONNECTDLGSTRUCTA* LPCONNECTDLGSTRUCTA;
+
+struct CONNECTDLGSTRUCTW {
+    DWORD          cbStructure;
+    HWND           hwndOwner;
+    LPNETRESOURCEW lpConnRes;
+    DWORD          dwFlags;
+    DWORD          dwDevNum;
+}
+alias CONNECTDLGSTRUCTW* LPCONNECTDLGSTRUCTW;
+
+struct DISCDLGSTRUCTA {
+    DWORD cbStructure;
+    HWND  hwndOwner;
+    LPSTR lpLocalName;
+    LPSTR lpRemoteName;
+    DWORD dwFlags;
+}
+alias DISCDLGSTRUCTA* LPDISCDLGSTRUCTA;
+
+struct DISCDLGSTRUCTW {
+    DWORD  cbStructure;
+    HWND   hwndOwner;
+    LPWSTR lpLocalName;
+    LPWSTR lpRemoteName;
+    DWORD  dwFlags;
+}
+alias DISCDLGSTRUCTW* LPDISCDLGSTRUCTW;
+
+struct UNIVERSAL_NAME_INFOA {
+    LPSTR lpUniversalName;
+}
+alias UNIVERSAL_NAME_INFOA* LPUNIVERSAL_NAME_INFOA;
+
+struct UNIVERSAL_NAME_INFOW {
+    LPWSTR lpUniversalName;
+}
+alias UNIVERSAL_NAME_INFOW* LPUNIVERSAL_NAME_INFOW;
+
+struct REMOTE_NAME_INFOA {
+    LPSTR lpUniversalName;
+    LPSTR lpConnectionName;
+    LPSTR lpRemainingPath;
+}
+alias REMOTE_NAME_INFOA* LPREMOTE_NAME_INFOA;
+
+struct REMOTE_NAME_INFOW {
+    LPWSTR lpUniversalName;
+    LPWSTR lpConnectionName;
+    LPWSTR lpRemainingPath;
+}
+alias REMOTE_NAME_INFOW* LPREMOTE_NAME_INFOW;
+
+struct NETINFOSTRUCT {
+    DWORD cbStructure;
+    DWORD dwProviderVersion;
+    DWORD dwStatus;
+    DWORD dwCharacteristics;
+    DWORD dwHandle;
+    WORD  wNetType;
+    DWORD dwPrinters;
+    DWORD dwDrives;
+}
+alias NETINFOSTRUCT* LPNETINFOSTRUCT;
+
+extern (Pascal) {
+    alias UINT function(LPCSTR, LPSTR, UINT) PFNGETPROFILEPATHA;
+    alias UINT function(LPCWSTR, LPWSTR, UINT) PFNGETPROFILEPATHW;
+    alias UINT function(LPCSTR, LPCSTR, DWORD) PFNRECONCILEPROFILEA;
+    alias UINT function(LPCWSTR, LPCWSTR, DWORD) PFNRECONCILEPROFILEW;
+    alias BOOL function(HWND, LPCSTR, LPCSTR, LPCSTR, DWORD)
+      PFNPROCESSPOLICIESA;
+    alias BOOL function(HWND, LPCWSTR, LPCWSTR, LPCWSTR, DWORD)
+      PFNPROCESSPOLICIESW;
+}
+
+struct NETCONNECTINFOSTRUCT {
+    DWORD cbStructure;
+    DWORD dwFlags;
+    DWORD dwSpeed;
+    DWORD dwDelay;
+    DWORD dwOptDataSize;
+}
+alias NETCONNECTINFOSTRUCT* LPNETCONNECTINFOSTRUCT;
+
+extern (Windows) {
+    DWORD WNetAddConnection2A(LPNETRESOURCEA, LPCSTR, LPCSTR, DWORD);
+    DWORD WNetAddConnection2W(LPNETRESOURCEW, LPCWSTR, LPCWSTR, DWORD);
+    DWORD WNetAddConnection3A(HWND, LPNETRESOURCEA, LPCSTR, LPCSTR, DWORD);
+    DWORD WNetAddConnection3W(HWND, LPNETRESOURCEW, LPCWSTR, LPCWSTR, DWORD);
+    DWORD WNetCancelConnection2A(LPCSTR, DWORD, BOOL);
+    DWORD WNetCancelConnection2W(LPCWSTR, DWORD, BOOL);
+    DWORD WNetGetConnectionA(LPCSTR, LPSTR, PDWORD);
+    DWORD WNetGetConnectionW(LPCWSTR, LPWSTR, PDWORD);
+    DWORD WNetUseConnectionA(HWND, LPNETRESOURCEA, LPCSTR, LPCSTR, DWORD,
+      LPSTR, PDWORD, PDWORD);
+    DWORD WNetUseConnectionW(HWND, LPNETRESOURCEW, LPCWSTR, LPCWSTR, DWORD,
+      LPWSTR, PDWORD, PDWORD);
+    DWORD WNetSetConnectionA(LPCSTR, DWORD, PVOID);
+    DWORD WNetSetConnectionW(LPCWSTR, DWORD, PVOID);
+    DWORD WNetConnectionDialog(HWND, DWORD);
+    DWORD WNetDisconnectDialog(HWND, DWORD);
+    DWORD WNetConnectionDialog1A(LPCONNECTDLGSTRUCTA);
+    DWORD WNetConnectionDialog1W(LPCONNECTDLGSTRUCTW);
+    DWORD WNetDisconnectDialog1A(LPDISCDLGSTRUCTA);
+    DWORD WNetDisconnectDialog1W(LPDISCDLGSTRUCTW);
+    DWORD WNetOpenEnumA(DWORD, DWORD, DWORD, LPNETRESOURCEA, LPHANDLE);
+    DWORD WNetOpenEnumW(DWORD, DWORD, DWORD, LPNETRESOURCEW, LPHANDLE);
+    DWORD WNetEnumResourceA(HANDLE, PDWORD, PVOID, PDWORD);
+    DWORD WNetEnumResourceW(HANDLE, PDWORD, PVOID, PDWORD);
+    DWORD WNetCloseEnum(HANDLE);
+    DWORD WNetGetUniversalNameA(LPCSTR, DWORD, PVOID, PDWORD);
+    DWORD WNetGetUniversalNameW(LPCWSTR, DWORD, PVOID, PDWORD);
+    DWORD WNetGetUserA(LPCSTR, LPSTR, PDWORD);
+    DWORD WNetGetUserW(LPCWSTR, LPWSTR, PDWORD);
+    DWORD WNetGetProviderNameA(DWORD, LPSTR, PDWORD);
+    DWORD WNetGetProviderNameW(DWORD, LPWSTR, PDWORD);
+    DWORD WNetGetNetworkInformationA(LPCSTR, LPNETINFOSTRUCT);
+    DWORD WNetGetNetworkInformationW(LPCWSTR, LPNETINFOSTRUCT);
+    DWORD WNetGetResourceInformationA(LPNETRESOURCEA, LPVOID, LPDWORD,
+      LPSTR*);
+    DWORD WNetGetResourceInformationW(LPNETRESOURCEA, LPVOID, LPDWORD,
+      LPWSTR*);
+    DWORD WNetGetResourceParentA(LPNETRESOURCEA, LPVOID, LPDWORD);
+    DWORD WNetGetResourceParentW(LPNETRESOURCEW, LPVOID, LPDWORD);
+    DWORD WNetGetLastErrorA(PDWORD, LPSTR, DWORD, LPSTR, DWORD);
+    DWORD WNetGetLastErrorW(PDWORD, LPWSTR, DWORD, LPWSTR, DWORD);
+    DWORD MultinetGetConnectionPerformanceA(LPNETRESOURCEA,
+      LPNETCONNECTINFOSTRUCT);
+    DWORD MultinetGetConnectionPerformanceW(LPNETRESOURCEW,
+      LPNETCONNECTINFOSTRUCT);
+    deprecated {
+        DWORD WNetAddConnectionA(LPCSTR, LPCSTR, LPCSTR);
+        DWORD WNetAddConnectionW(LPCWSTR, LPCWSTR, LPCWSTR);
+        DWORD WNetCancelConnectionA(LPCSTR, BOOL);
+        DWORD WNetCancelConnectionW(LPCWSTR, BOOL);
+    }
+}
+
+version (Unicode) {
+    alias PFNGETPROFILEPATHW PFNGETPROFILEPATH;
+    alias PFNRECONCILEPROFILEW PFNRECONCILEPROFILE;
+    alias PFNPROCESSPOLICIESW PFNPROCESSPOLICIES;
+    alias NETRESOURCEW NETRESOURCE;
+    alias CONNECTDLGSTRUCTW CONNECTDLGSTRUCT;
+    alias DISCDLGSTRUCTW DISCDLGSTRUCT;
+    alias REMOTE_NAME_INFOW REMOTE_NAME_INFO;
+    alias UNIVERSAL_NAME_INFOW UNIVERSAL_NAME_INFO;
+    alias WNetAddConnection2W WNetAddConnection2;
+    alias WNetAddConnection3W WNetAddConnection3;
+    alias WNetCancelConnection2W WNetCancelConnection2;
+    alias WNetGetConnectionW WNetGetConnection;
+    alias WNetUseConnectionW WNetUseConnection;
+    alias WNetSetConnectionW WNetSetConnection;
+    alias WNetConnectionDialog1W WNetConnectionDialog1;
+    alias WNetDisconnectDialog1W WNetDisconnectDialog1;
+    alias WNetOpenEnumW WNetOpenEnum;
+    alias WNetEnumResourceW WNetEnumResource;
+    alias WNetGetUniversalNameW WNetGetUniversalName;
+    alias WNetGetUserW WNetGetUser;
+    alias WNetGetProviderNameW WNetGetProviderName;
+    alias WNetGetNetworkInformationW WNetGetNetworkInformation;
+    alias WNetGetResourceInformationW WNetGetResourceInformation;
+    alias WNetGetResourceParentW WNetGetResourceParent;
+    alias WNetGetLastErrorW WNetGetLastError;
+    alias MultinetGetConnectionPerformanceW MultinetGetConnectionPerformance;
+    deprecated {
+        alias WNetAddConnectionW WNetAddConnection;
+        alias WNetCancelConnectionW WNetCancelConnection;
+    }
+} else {
+    alias PFNGETPROFILEPATHA PFNGETPROFILEPATH;
+    alias PFNRECONCILEPROFILEA PFNRECONCILEPROFILE;
+    alias PFNPROCESSPOLICIESA PFNPROCESSPOLICIES;
+    alias NETRESOURCEA NETRESOURCE;
+    alias CONNECTDLGSTRUCTA CONNECTDLGSTRUCT;
+    alias DISCDLGSTRUCTA DISCDLGSTRUCT;
+    alias REMOTE_NAME_INFOA REMOTE_NAME_INFO;
+    alias UNIVERSAL_NAME_INFOA UNIVERSAL_NAME_INFO;
+    alias WNetAddConnection2A WNetAddConnection2;
+    alias WNetAddConnection3A WNetAddConnection3;
+    alias WNetCancelConnection2A WNetCancelConnection2;
+    alias WNetGetConnectionA WNetGetConnection;
+    alias WNetUseConnectionA WNetUseConnection;
+    alias WNetSetConnectionA WNetSetConnection;
+    alias WNetConnectionDialog1A WNetConnectionDialog1;
+    alias WNetDisconnectDialog1A WNetDisconnectDialog1;
+    alias WNetOpenEnumA WNetOpenEnum;
+    alias WNetEnumResourceA WNetEnumResource;
+    alias WNetGetUniversalNameA WNetGetUniversalName;
+    alias WNetGetUserA WNetGetUser;
+    alias WNetGetProviderNameA WNetGetProviderName;
+    alias WNetGetNetworkInformationA WNetGetNetworkInformation;
+    alias WNetGetResourceInformationA WNetGetResourceInformation;
+    alias WNetGetResourceParentA WNetGetResourceParent;
+    alias WNetGetLastErrorA WNetGetLastError;
+    alias MultinetGetConnectionPerformanceA MultinetGetConnectionPerformance;
+    deprecated {
+        alias WNetAddConnectionA WNetAddConnection;
+        alias WNetCancelConnectionA WNetCancelConnection;
+    }
+}
+
+alias NETRESOURCE* LPNETRESOURCE;
+alias CONNECTDLGSTRUCT* LPCONNECTDLGSTRUCT;
+alias DISCDLGSTRUCT* LPDISCDLGSTRUCT;
+alias REMOTE_NAME_INFO* LPREMOTE_NAME_INFO;
+alias UNIVERSAL_NAME_INFO* LPUNIVERSAL_NAME_INFO;
diff --git a/libphobos/libdruntime/core/sys/windows/winnls.d b/libphobos/libdruntime/core/sys/windows/winnls.d
new file mode 100644
index 00000000000..d36d1f35806
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winnls.d
@@ -0,0 +1,811 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winnls.d)
+ */
+module core.sys.windows.winnls;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "kernel32");
+
+private import core.sys.windows.basetsd, core.sys.windows.w32api, core.sys.windows.winbase, core.sys.windows.windef;
+
+alias DWORD LCTYPE, CALTYPE, CALID, LGRPID, GEOID, GEOTYPE, GEOCLASS;
+
+enum size_t
+    MAX_DEFAULTCHAR =  2,
+    MAX_LEADBYTES   = 12;
+
+enum LCTYPE
+    LOCALE_USE_CP_ACP    = 0x40000000,
+    LOCALE_RETURN_NUMBER = 0x20000000;
+
+enum : LCTYPE {
+    LOCALE_ILANGUAGE = 1,
+    LOCALE_SLANGUAGE,
+    LOCALE_SABBREVLANGNAME,
+    LOCALE_SNATIVELANGNAME,
+    LOCALE_ICOUNTRY,
+    LOCALE_SCOUNTRY,
+    LOCALE_SABBREVCTRYNAME,
+    LOCALE_SNATIVECTRYNAME,
+    LOCALE_IDEFAULTLANGUAGE,
+    LOCALE_IDEFAULTCOUNTRY,
+    LOCALE_IDEFAULTCODEPAGE,
+    LOCALE_SLIST,
+    LOCALE_IMEASURE,
+    LOCALE_SDECIMAL,
+    LOCALE_STHOUSAND,
+    LOCALE_SGROUPING,
+    LOCALE_IDIGITS,
+    LOCALE_ILZERO,
+    LOCALE_SNATIVEDIGITS,
+    LOCALE_SCURRENCY,
+    LOCALE_SINTLSYMBOL,
+    LOCALE_SMONDECIMALSEP,
+    LOCALE_SMONTHOUSANDSEP,
+    LOCALE_SMONGROUPING,
+    LOCALE_ICURRDIGITS,
+    LOCALE_IINTLCURRDIGITS,
+    LOCALE_ICURRENCY,
+    LOCALE_INEGCURR,
+    LOCALE_SDATE,
+    LOCALE_STIME,
+    LOCALE_SSHORTDATE,
+    LOCALE_SLONGDATE,
+    LOCALE_IDATE,
+    LOCALE_ILDATE,
+    LOCALE_ITIME,
+    LOCALE_ICENTURY,
+    LOCALE_ITLZERO,
+    LOCALE_IDAYLZERO,
+    LOCALE_IMONLZERO,
+    LOCALE_S1159,
+    LOCALE_S2359,
+    LOCALE_SDAYNAME1,
+    LOCALE_SDAYNAME2,
+    LOCALE_SDAYNAME3,
+    LOCALE_SDAYNAME4,
+    LOCALE_SDAYNAME5,
+    LOCALE_SDAYNAME6,
+    LOCALE_SDAYNAME7,
+    LOCALE_SABBREVDAYNAME1,
+    LOCALE_SABBREVDAYNAME2,
+    LOCALE_SABBREVDAYNAME3,
+    LOCALE_SABBREVDAYNAME4,
+    LOCALE_SABBREVDAYNAME5,
+    LOCALE_SABBREVDAYNAME6,
+    LOCALE_SABBREVDAYNAME7,
+    LOCALE_SMONTHNAME1,
+    LOCALE_SMONTHNAME2,
+    LOCALE_SMONTHNAME3,
+    LOCALE_SMONTHNAME4,
+    LOCALE_SMONTHNAME5,
+    LOCALE_SMONTHNAME6,
+    LOCALE_SMONTHNAME7,
+    LOCALE_SMONTHNAME8,
+    LOCALE_SMONTHNAME9,
+    LOCALE_SMONTHNAME10,
+    LOCALE_SMONTHNAME11,
+    LOCALE_SMONTHNAME12,
+    LOCALE_SABBREVMONTHNAME1,
+    LOCALE_SABBREVMONTHNAME2,
+    LOCALE_SABBREVMONTHNAME3,
+    LOCALE_SABBREVMONTHNAME4,
+    LOCALE_SABBREVMONTHNAME5,
+    LOCALE_SABBREVMONTHNAME6,
+    LOCALE_SABBREVMONTHNAME7,
+    LOCALE_SABBREVMONTHNAME8,
+    LOCALE_SABBREVMONTHNAME9,
+    LOCALE_SABBREVMONTHNAME10,
+    LOCALE_SABBREVMONTHNAME11,
+    LOCALE_SABBREVMONTHNAME12,
+    LOCALE_SPOSITIVESIGN,
+    LOCALE_SNEGATIVESIGN,
+    LOCALE_IPOSSIGNPOSN,
+    LOCALE_INEGSIGNPOSN,
+    LOCALE_IPOSSYMPRECEDES,
+    LOCALE_IPOSSEPBYSPACE,
+    LOCALE_INEGSYMPRECEDES,
+    LOCALE_INEGSEPBYSPACE,
+    LOCALE_FONTSIGNATURE,
+    LOCALE_SISO639LANGNAME,
+    LOCALE_SISO3166CTRYNAME, // = 90
+    LOCALE_SENGLANGUAGE         = 0x1001,
+    LOCALE_SENGCOUNTRY          = 0x1002,
+    LOCALE_IDEFAULTANSICODEPAGE = 0x1004,
+    LOCALE_INEGNUMBER           = 0x1010,
+    LOCALE_STIMEFORMAT          = 0x1003,
+    LOCALE_ITIMEMARKPOSN        = 0x1005,
+    LOCALE_ICALENDARTYPE        = 0x1009,
+    LOCALE_IOPTIONALCALENDAR    = 0x100B,
+    LOCALE_IFIRSTDAYOFWEEK      = 0x100C,
+    LOCALE_IFIRSTWEEKOFYEAR     = 0x100D,
+    LOCALE_SMONTHNAME13         = 0x100E,
+    LOCALE_SABBREVMONTHNAME13   = 0x100F
+}
+
+enum : LCID {
+    LOCALE_USER_DEFAULT   = 0x400,
+    LOCALE_SYSTEM_DEFAULT = 0x800
+}
+
+enum DWORD
+    NORM_IGNORECASE     =       1,
+    NORM_IGNORENONSPACE =       2,
+    NORM_IGNORESYMBOLS  =       4,
+    SORT_STRINGSORT     = 0x01000,
+    NORM_IGNOREKANATYPE = 0x10000,
+    NORM_IGNOREWIDTH    = 0x20000;
+
+enum DWORD
+    LCMAP_LOWERCASE           = 0x00000100,
+    LCMAP_UPPERCASE           = 0x00000200,
+    LCMAP_SORTKEY             = 0x00000400,
+    LCMAP_BYTEREV             = 0x00000800,
+    LCMAP_HIRAGANA            = 0x00100000,
+    LCMAP_KATAKANA            = 0x00200000,
+    LCMAP_HALFWIDTH           = 0x00400000,
+    LCMAP_FULLWIDTH           = 0x00800000,
+    LCMAP_LINGUISTIC_CASING   = 0x01000000,
+    LCMAP_SIMPLIFIED_CHINESE  = 0x02000000,
+    LCMAP_TRADITIONAL_CHINESE = 0x04000000;
+
+enum CALID ENUM_ALL_CALENDARS = -1;
+
+enum DWORD
+    DATE_SHORTDATE        =          1,
+    DATE_LONGDATE         =          2,
+    DATE_USE_ALT_CALENDAR =          4,
+    LOCALE_NOUSEROVERRIDE = 0x80000000;
+
+enum : DWORD {
+    CP_INSTALLED = 1,
+    CP_SUPPORTED
+}
+
+enum : DWORD {
+    LCID_INSTALLED       = 1,
+    LCID_SUPPORTED       = 2,
+    LCID_ALTERNATE_SORTS = 4
+}
+
+enum DWORD
+    MAP_FOLDCZONE   =  16,
+    MAP_PRECOMPOSED =  32,
+    MAP_COMPOSITE   =  64,
+    MAP_FOLDDIGITS  = 128;
+
+enum : UINT {
+    CP_ACP,
+    CP_OEMCP,
+    CP_MACCP,
+    CP_THREAD_ACP, // =     3
+    CP_SYMBOL         =    42,
+    CP_UTF7           = 65000,
+    CP_UTF8           = 65001
+}
+
+enum : DWORD {
+    CT_CTYPE1 = 1,
+    CT_CTYPE2 = 2,
+    CT_CTYPE3 = 4
+}
+
+enum WORD
+    C1_UPPER  =   1,
+    C1_LOWER  =   2,
+    C1_DIGIT  =   4,
+    C1_SPACE  =   8,
+    C1_PUNCT  =  16,
+    C1_CNTRL  =  32,
+    C1_BLANK  =  64,
+    C1_XDIGIT = 128,
+    C1_ALPHA  = 256;
+
+enum : WORD {
+    C2_NOTAPPLICABLE,
+    C2_LEFTTORIGHT,
+    C2_RIGHTTOLEFT,
+    C2_EUROPENUMBER,
+    C2_EUROPESEPARATOR,
+    C2_EUROPETERMINATOR,
+    C2_ARABICNUMBER,
+    C2_COMMONSEPARATOR,
+    C2_BLOCKSEPARATOR,
+    C2_SEGMENTSEPARATOR,
+    C2_WHITESPACE,
+    C2_OTHERNEUTRAL  // = 11
+}
+
+enum WORD
+    C3_NOTAPPLICABLE =      0,
+    C3_NONSPACING    =      1,
+    C3_DIACRITIC     =      2,
+    C3_VOWELMARK     =      4,
+    C3_SYMBOL        =      8,
+    C3_KATAKANA      = 0x0010,
+    C3_HIRAGANA      = 0x0020,
+    C3_HALFWIDTH     = 0x0040,
+    C3_FULLWIDTH     = 0x0080,
+    C3_IDEOGRAPH     = 0x0100,
+    C3_KASHIDA       = 0x0200,
+    C3_LEXICAL       = 0x0400,
+    C3_ALPHA         = 0x8000;
+
+enum DWORD
+    TIME_NOMINUTESORSECONDS = 1,
+    TIME_NOSECONDS          = 2,
+    TIME_NOTIMEMARKER       = 4,
+    TIME_FORCE24HOURFORMAT  = 8;
+
+enum DWORD
+    MB_PRECOMPOSED       = 1,
+    MB_COMPOSITE         = 2,
+    MB_USEGLYPHCHARS     = 4,
+    MB_ERR_INVALID_CHARS = 8;
+
+enum DWORD
+    WC_DISCARDNS      =  16,
+    WC_SEPCHARS       =  32,
+    WC_DEFAULTCHAR    =  64,
+    WC_COMPOSITECHECK = 512;
+
+enum : LONG {
+    CTRY_DEFAULT            =   0,
+    CTRY_DOMINICAN_REPUBLIC =   1,
+    CTRY_PUERTO_RICO        =   1,
+    CTRY_CARIBBEAN          =   1,
+    CTRY_JAMAICA            =   1,
+    CTRY_UNITED_STATES      =   1,
+    CTRY_TRINIDAD_Y_TOBAGO  =   1,
+    CTRY_CANADA             =   2,
+    CTRY_RUSSIA             =   7,
+    CTRY_UZBEKISTAN         =   7,
+    CTRY_KAZAKSTAN          =   7,
+    CTRY_TATARSTAN          =   7,
+    CTRY_EGYPT              =  20,
+    CTRY_SOUTH_AFRICA       =  27,
+    CTRY_GREECE             =  30,
+    CTRY_NETHERLANDS        =  31,
+    CTRY_BELGIUM            =  32,
+    CTRY_FRANCE             =  33,
+    CTRY_MONACO             =  33,
+    CTRY_SPAIN              =  34,
+    CTRY_HUNGARY            =  36,
+    CTRY_ITALY              =  39,
+    CTRY_ROMANIA            =  40,
+    CTRY_SWITZERLAND        =  41,
+    CTRY_LIECHTENSTEIN      =  41,
+    CTRY_AUSTRIA            =  43,
+    CTRY_UNITED_KINGDOM     =  44,
+    CTRY_DENMARK            =  45,
+    CTRY_SWEDEN             =  46,
+    CTRY_NORWAY             =  47,
+    CTRY_POLAND             =  48,
+    CTRY_GERMANY            =  49,
+    CTRY_PERU               =  51,
+    CTRY_MEXICO             =  52,
+    CTRY_ARGENTINA          =  54,
+    CTRY_BRAZIL             =  55,
+    CTRY_CHILE              =  56,
+    CTRY_COLOMBIA           =  57,
+    CTRY_VENEZUELA          =  58,
+    CTRY_MALAYSIA           =  60,
+    CTRY_AUSTRALIA          =  61,
+    CTRY_INDONESIA          =  62,
+    CTRY_PHILIPPINES        =  63,
+    CTRY_NEW_ZEALAND        =  64,
+    CTRY_SINGAPORE          =  65,
+    CTRY_THAILAND           =  66,
+    CTRY_JAPAN              =  81,
+    CTRY_SOUTH_KOREA        =  82,
+    CTRY_VIET_NAM           =  84,
+    CTRY_PRCHINA            =  86,
+    CTRY_TURKEY             =  90,
+    CTRY_INDIA              =  91,
+    CTRY_PAKISTAN           =  92,
+    CTRY_MOROCCO            = 212,
+    CTRY_ALGERIA            = 213,
+    CTRY_TUNISIA            = 216,
+    CTRY_LIBYA              = 218,
+    CTRY_KENYA              = 254,
+    CTRY_ZIMBABWE           = 263,
+    CTRY_FAEROE_ISLANDS     = 298,
+    CTRY_PORTUGAL           = 351,
+    CTRY_LUXEMBOURG         = 352,
+    CTRY_IRELAND            = 353,
+    CTRY_ICELAND            = 354,
+    CTRY_ALBANIA            = 355,
+    CTRY_FINLAND            = 358,
+    CTRY_BULGARIA           = 359,
+    CTRY_LITHUANIA          = 370,
+    CTRY_LATVIA             = 371,
+    CTRY_ESTONIA            = 372,
+    CTRY_ARMENIA            = 374,
+    CTRY_BELARUS            = 375,
+    CTRY_UKRAINE            = 380,
+    CTRY_SERBIA             = 381,
+    CTRY_CROATIA            = 385,
+    CTRY_SLOVENIA           = 386,
+    CTRY_MACEDONIA          = 389,
+    CTRY_CZECH              = 420,
+    CTRY_SLOVAK             = 421,
+    CTRY_BELIZE             = 501,
+    CTRY_GUATEMALA          = 502,
+    CTRY_EL_SALVADOR        = 503,
+    CTRY_HONDURAS           = 504,
+    CTRY_NICARAGUA          = 505,
+    CTRY_COSTA_RICA         = 506,
+    CTRY_PANAMA             = 507,
+    CTRY_BOLIVIA            = 591,
+    CTRY_ECUADOR            = 593,
+    CTRY_PARAGUAY           = 595,
+    CTRY_URUGUAY            = 598,
+    CTRY_BRUNEI_DARUSSALAM  = 673,
+    CTRY_HONG_KONG          = 852,
+    CTRY_MACAU              = 853,
+    CTRY_TAIWAN             = 886,
+    CTRY_MALDIVES           = 960,
+    CTRY_LEBANON            = 961,
+    CTRY_JORDAN             = 962,
+    CTRY_SYRIA              = 963,
+    CTRY_IRAQ               = 964,
+    CTRY_KUWAIT             = 965,
+    CTRY_SAUDI_ARABIA       = 966,
+    CTRY_YEMEN              = 967,
+    CTRY_OMAN               = 968,
+    CTRY_UAE                = 971,
+    CTRY_ISRAEL             = 972,
+    CTRY_BAHRAIN            = 973,
+    CTRY_QATAR              = 974,
+    CTRY_MONGOLIA           = 976,
+    CTRY_IRAN               = 981,
+    CTRY_AZERBAIJAN         = 994,
+    CTRY_GEORGIA            = 995,
+    CTRY_KYRGYZSTAN         = 996
+}
+
+enum : CALTYPE {
+    CAL_ICALINTVALUE          = 1,
+    CAL_SCALNAME,
+    CAL_IYEAROFFSETRANGE,
+    CAL_SERASTRING,
+    CAL_SSHORTDATE,
+    CAL_SLONGDATE,
+    CAL_SDAYNAME1,
+    CAL_SDAYNAME2,
+    CAL_SDAYNAME3,
+    CAL_SDAYNAME4,
+    CAL_SDAYNAME5,
+    CAL_SDAYNAME6,
+    CAL_SDAYNAME7,
+    CAL_SABBREVDAYNAME1,
+    CAL_SABBREVDAYNAME2,
+    CAL_SABBREVDAYNAME3,
+    CAL_SABBREVDAYNAME4,
+    CAL_SABBREVDAYNAME5,
+    CAL_SABBREVDAYNAME6,
+    CAL_SABBREVDAYNAME7,
+    CAL_SMONTHNAME1,
+    CAL_SMONTHNAME2,
+    CAL_SMONTHNAME3,
+    CAL_SMONTHNAME4,
+    CAL_SMONTHNAME5,
+    CAL_SMONTHNAME6,
+    CAL_SMONTHNAME7,
+    CAL_SMONTHNAME8,
+    CAL_SMONTHNAME9,
+    CAL_SMONTHNAME10,
+    CAL_SMONTHNAME11,
+    CAL_SMONTHNAME12,
+    CAL_SMONTHNAME13,
+    CAL_SABBREVMONTHNAME1,
+    CAL_SABBREVMONTHNAME2,
+    CAL_SABBREVMONTHNAME3,
+    CAL_SABBREVMONTHNAME4,
+    CAL_SABBREVMONTHNAME5,
+    CAL_SABBREVMONTHNAME6,
+    CAL_SABBREVMONTHNAME7,
+    CAL_SABBREVMONTHNAME8,
+    CAL_SABBREVMONTHNAME9,
+    CAL_SABBREVMONTHNAME10,
+    CAL_SABBREVMONTHNAME11,
+    CAL_SABBREVMONTHNAME12,
+    CAL_SABBREVMONTHNAME13 // = 46
+}
+
+
+enum : CALTYPE {
+    CAL_GREGORIAN                =  1,
+    CAL_GREGORIAN_US,
+    CAL_JAPAN,
+    CAL_TAIWAN,
+    CAL_KOREA,
+    CAL_HIJRI,
+    CAL_THAI,
+    CAL_HEBREW,
+    CAL_GREGORIAN_ME_FRENCH,
+    CAL_GREGORIAN_ARABIC,
+    CAL_GREGORIAN_XLIT_ENGLISH,
+    CAL_GREGORIAN_XLIT_FRENCH // = 12
+}
+
+enum : int {
+    CSTR_LESS_THAN    = 1,
+    CSTR_EQUAL,
+    CSTR_GREATER_THAN
+}
+
+enum : DWORD {
+    LGRPID_INSTALLED = 1,
+    LGRPID_SUPPORTED
+}
+
+enum : LGRPID {
+    LGRPID_WESTERN_EUROPE = 1,
+    LGRPID_CENTRAL_EUROPE,
+    LGRPID_BALTIC,
+    LGRPID_GREEK,
+    LGRPID_CYRILLIC,
+    LGRPID_TURKISH,
+    LGRPID_JAPANESE,
+    LGRPID_KOREAN,
+    LGRPID_TRADITIONAL_CHINESE,
+    LGRPID_SIMPLIFIED_CHINESE,
+    LGRPID_THAI,
+    LGRPID_HEBREW,
+    LGRPID_ARABIC,
+    LGRPID_VIETNAMESE,
+    LGRPID_INDIC,
+    LGRPID_GEORGIAN,
+    LGRPID_ARMENIAN // = 17
+}
+
+static if (_WIN32_WINNT >= 0x500) {
+    enum : LCTYPE {
+        LOCALE_SYEARMONTH             = 0x1006,
+        LOCALE_SENGCURRNAME           = 0x1007,
+        LOCALE_SNATIVECURRNAME        = 0x1008,
+        LOCALE_IDEFAULTEBCDICCODEPAGE = 0x1012,
+        LOCALE_SSORTNAME              = 0x1013,
+        LOCALE_IDIGITSUBSTITUTION     = 0x1014,
+        LOCALE_IPAPERSIZE             = 0x100A
+    }
+
+enum DWORD
+        DATE_YEARMONTH  =  8,
+        DATE_LTRREADING = 16,
+        DATE_RTLREADING = 32;
+
+enum DWORD MAP_EXPAND_LIGATURES = 0x2000;
+enum DWORD WC_NO_BEST_FIT_CHARS = 1024;
+
+    enum : CALTYPE {
+        CAL_SYEARMONTH       = 47,
+        CAL_ITWODIGITYEARMAX = 48,
+        CAL_NOUSEROVERRIDE   = LOCALE_NOUSEROVERRIDE,
+        CAL_RETURN_NUMBER    = LOCALE_RETURN_NUMBER,
+        CAL_USE_CP_ACP       = LOCALE_USE_CP_ACP
+    }
+} // (_WIN32_WINNT >= 0x500)
+
+extern (Windows) {
+    alias BOOL function(LPSTR) CALINFO_ENUMPROCA;
+    alias BOOL function(LPWSTR) CALINFO_ENUMPROCW;
+    alias BOOL function(LPSTR, CALID) CALINFO_ENUMPROCEXA;
+    alias BOOL function(LPWSTR, CALID) CALINFO_ENUMPROCEXW;
+    alias BOOL function(LGRPID, LPSTR, LPSTR, DWORD, LONG_PTR)
+      LANGUAGEGROUP_ENUMPROCA;
+    alias BOOL function(LGRPID, LPWSTR, LPWSTR, DWORD, LONG_PTR)
+      LANGUAGEGROUP_ENUMPROCW;
+    alias BOOL function(LGRPID, LCID, LPSTR, LONG_PTR)
+      LANGGROUPLOCALE_ENUMPROCA;
+    alias BOOL function(LGRPID, LCID, LPWSTR, LONG_PTR)
+      LANGGROUPLOCALE_ENUMPROCW;
+    alias BOOL function(LPWSTR, LONG_PTR) UILANGUAGE_ENUMPROCW;
+    alias BOOL function(LPSTR, LONG_PTR) UILANGUAGE_ENUMPROCA;
+    alias BOOL function(LPSTR) LOCALE_ENUMPROCA;
+    alias BOOL function(LPWSTR) LOCALE_ENUMPROCW;
+    alias BOOL function(LPSTR) CODEPAGE_ENUMPROCA;
+    alias BOOL function(LPWSTR) CODEPAGE_ENUMPROCW;
+    alias BOOL function(LPSTR) DATEFMT_ENUMPROCA;
+    alias BOOL function(LPWSTR) DATEFMT_ENUMPROCW;
+    alias BOOL function(LPSTR, CALID) DATEFMT_ENUMPROCEXA;
+    alias BOOL function(LPWSTR, CALID) DATEFMT_ENUMPROCEXW;
+    alias BOOL function(LPSTR) TIMEFMT_ENUMPROCA;
+    alias BOOL function(LPWSTR) TIMEFMT_ENUMPROCW;
+    alias BOOL function(GEOID) GEO_ENUMPROC;
+}
+
+enum NLS_FUNCTION {
+    COMPARE_STRING = 0x0001
+}
+
+enum SYSGEOCLASS {
+    GEOCLASS_NATION = 16,
+    GEOCLASS_REGION = 14
+}
+
+enum SYSGEOTYPE {
+    GEO_NATION            = 0x0001,
+    GEO_LATITUDE          = 0x0002,
+    GEO_LONGITUDE         = 0x0003,
+    GEO_ISO2              = 0x0004,
+    GEO_ISO3              = 0x0005,
+    GEO_RFC1766           = 0x0006,
+    GEO_LCID              = 0x0007,
+    GEO_FRIENDLYNAME      = 0x0008,
+    GEO_OFFICIALNAME      = 0x0009,
+    GEO_TIMEZONES         = 0x000a,
+    GEO_OFFICIALLANGUAGES = 0x000a
+}
+
+struct CPINFO {
+    UINT                  MaxCharSize;
+    BYTE[MAX_DEFAULTCHAR] DefaultChar;
+    BYTE[MAX_LEADBYTES]   LeadByte;
+}
+alias CPINFO* LPCPINFO;
+
+struct CPINFOEXA {
+    UINT                  MaxCharSize;
+    BYTE[MAX_DEFAULTCHAR] DefaultChar;
+    BYTE[MAX_LEADBYTES]   LeadByte;
+    WCHAR                 UnicodeDefaultChar;
+    UINT                  CodePage;
+    CHAR[MAX_PATH]        CodePageName;
+}
+alias CPINFOEXA* LPCPINFOEXA;
+
+struct CPINFOEXW {
+    UINT                  MaxCharSize;
+    BYTE[MAX_DEFAULTCHAR] DefaultChar;
+    BYTE[MAX_LEADBYTES]   LeadByte;
+    WCHAR                 UnicodeDefaultChar;
+    UINT                  CodePage;
+    WCHAR[MAX_PATH]       CodePageName;
+}
+alias CPINFOEXW* LPCPINFOEXW;
+
+struct CURRENCYFMTA {
+    UINT  NumDigits;
+    UINT  LeadingZero;
+    UINT  Grouping;
+    LPSTR lpDecimalSep;
+    LPSTR lpThousandSep;
+    UINT  NegativeOrder;
+    UINT  PositiveOrder;
+    LPSTR lpCurrencySymbol;
+}
+alias CURRENCYFMTA* LPCURRENCYFMTA;
+
+struct CURRENCYFMTW {
+    UINT   NumDigits;
+    UINT   LeadingZero;
+    UINT   Grouping;
+    LPWSTR lpDecimalSep;
+    LPWSTR lpThousandSep;
+    UINT   NegativeOrder;
+    UINT   PositiveOrder;
+    LPWSTR lpCurrencySymbol;
+}
+alias CURRENCYFMTW* LPCURRENCYFMTW;
+
+struct NLSVERSIONINFO {
+    DWORD dwNLSVersionInfoSize;
+    DWORD dwNLSVersion;
+    DWORD dwDefinedVersion;
+}
+alias NLSVERSIONINFO* LPNLSVERSIONINFO;
+
+struct NUMBERFMTA {
+    UINT  NumDigits;
+    UINT  LeadingZero;
+    UINT  Grouping;
+    LPSTR lpDecimalSep;
+    LPSTR lpThousandSep;
+    UINT  NegativeOrder;
+}
+alias NUMBERFMTA* LPNUMBERFMTA;
+
+struct NUMBERFMTW {
+    UINT   NumDigits;
+    UINT   LeadingZero;
+    UINT   Grouping;
+    LPWSTR lpDecimalSep;
+    LPWSTR lpThousandSep;
+    UINT   NegativeOrder;
+}
+alias NUMBERFMTW* LPNUMBERFMTW;
+
+extern (Windows) nothrow @nogc {
+    int CompareStringA(LCID, DWORD, LPCSTR, int, LPCSTR, int);
+    int CompareStringW(LCID, DWORD, LPCWSTR, int, LPCWSTR, int);
+    LCID ConvertDefaultLocale(LCID);
+    BOOL EnumCalendarInfoA(CALINFO_ENUMPROCA, LCID, CALID, CALTYPE);
+    BOOL EnumCalendarInfoW(CALINFO_ENUMPROCW, LCID, CALID, CALTYPE);
+    BOOL EnumDateFormatsA(DATEFMT_ENUMPROCA, LCID, DWORD);
+    BOOL EnumDateFormatsW(DATEFMT_ENUMPROCW, LCID, DWORD);
+    BOOL EnumSystemCodePagesA(CODEPAGE_ENUMPROCA, DWORD);
+    BOOL EnumSystemCodePagesW(CODEPAGE_ENUMPROCW, DWORD);
+    BOOL EnumSystemGeoID(GEOCLASS, GEOID, GEO_ENUMPROC);
+    BOOL EnumSystemLocalesA(LOCALE_ENUMPROCA, DWORD);
+    BOOL EnumSystemLocalesW(LOCALE_ENUMPROCW, DWORD);
+    BOOL EnumTimeFormatsA(TIMEFMT_ENUMPROCA, LCID, DWORD);
+    BOOL EnumTimeFormatsW(TIMEFMT_ENUMPROCW, LCID, DWORD);
+    int FoldStringA(DWORD, LPCSTR, int, LPSTR, int);
+    int FoldStringW(DWORD, LPCWSTR, int, LPWSTR, int);
+    UINT GetACP();
+    int GetCalendarInfoA(LCID, CALID, CALTYPE, LPSTR, int, LPDWORD);
+    int GetCalendarInfoW(LCID, CALID, CALTYPE, LPWSTR, int, LPDWORD);
+    BOOL GetCPInfo(UINT, LPCPINFO);
+    BOOL GetCPInfoExA(UINT, DWORD, LPCPINFOEXA);
+    BOOL GetCPInfoExW(UINT, DWORD, LPCPINFOEXW);
+    int GetCurrencyFormatA(LCID, DWORD, LPCSTR,  const(CURRENCYFMTA)*, LPSTR, int);
+    int GetCurrencyFormatW(LCID, DWORD, LPCWSTR,  const(CURRENCYFMTW)*, LPWSTR,
+      int);
+    int GetDateFormatA(LCID, DWORD,  const(SYSTEMTIME)*, LPCSTR, LPSTR, int);
+    int GetDateFormatW(LCID, DWORD,  const(SYSTEMTIME)*, LPCWSTR, LPWSTR, int);
+    int GetGeoInfoA(GEOID, GEOTYPE, LPSTR, int, LANGID);
+    int GetGeoInfoW(GEOID, GEOTYPE, LPWSTR, int, LANGID);
+    int GetLocaleInfoA(LCID, LCTYPE, LPSTR, int);
+    int GetLocaleInfoW(LCID, LCTYPE, LPWSTR, int);
+    BOOL GetNLSVersion(NLS_FUNCTION, LCID, LPNLSVERSIONINFO);
+    int GetNumberFormatA(LCID, DWORD, LPCSTR,  const(NUMBERFMTA)*, LPSTR, int);
+    int GetNumberFormatW(LCID, DWORD, LPCWSTR,  const(NUMBERFMTW)*, LPWSTR, int);
+    UINT GetOEMCP();
+    BOOL GetStringTypeA(LCID, DWORD, LPCSTR, int, LPWORD);
+    BOOL GetStringTypeW(DWORD, LPCWSTR, int, LPWORD);
+    BOOL GetStringTypeExA(LCID, DWORD, LPCSTR, int, LPWORD);
+    BOOL GetStringTypeExW(LCID, DWORD, LPCWSTR, int, LPWORD);
+    LANGID GetSystemDefaultLangID();
+    LCID GetSystemDefaultLCID();
+    LCID GetThreadLocale();
+    int GetTimeFormatA(LCID, DWORD,  const(SYSTEMTIME)*, LPCSTR, LPSTR, int);
+    int GetTimeFormatW(LCID, DWORD,  const(SYSTEMTIME)*, LPCWSTR, LPWSTR, int);
+    LANGID GetUserDefaultLangID();
+    LCID GetUserDefaultLCID();
+    GEOID GetUserGeoID(GEOCLASS);
+    BOOL IsDBCSLeadByte(BYTE);
+    BOOL IsDBCSLeadByteEx(UINT, BYTE);
+    BOOL IsNLSDefinedString(NLS_FUNCTION, DWORD, LPNLSVERSIONINFO, LPCWSTR,
+      int);
+    BOOL IsValidCodePage(UINT);
+    BOOL IsValidLocale(LCID, DWORD);
+    int LCMapStringA(LCID, DWORD, LPCSTR, int, LPSTR, int);
+    int LCMapStringW(LCID, DWORD, LPCWSTR, int, LPWSTR, int);
+    int MultiByteToWideChar(UINT, DWORD, LPCSTR, int, LPWSTR, int);
+    int SetCalendarInfoA(LCID, CALID, CALTYPE, LPCSTR);
+    int SetCalendarInfoW(LCID, CALID, CALTYPE, LPCWSTR);
+    BOOL SetLocaleInfoA(LCID, LCTYPE, LPCSTR);
+    BOOL SetLocaleInfoW(LCID, LCTYPE, LPCWSTR);
+    BOOL SetThreadLocale(LCID);
+    BOOL SetUserGeoID(GEOID);
+    int WideCharToMultiByte(UINT, DWORD, LPCWSTR, int, LPSTR, int, LPCSTR,
+      LPBOOL);
+
+    static if (_WIN32_WINNT >= 0x410) {
+        BOOL EnumCalendarInfoExA(CALINFO_ENUMPROCEXA, LCID, CALID, CALTYPE);
+        BOOL EnumCalendarInfoExW(CALINFO_ENUMPROCEXW, LCID, CALID, CALTYPE);
+        BOOL EnumDateFormatsExA(DATEFMT_ENUMPROCEXA, LCID, DWORD);
+        BOOL EnumDateFormatsExW(DATEFMT_ENUMPROCEXW, LCID, DWORD);
+        BOOL IsValidLanguageGroup(LGRPID, DWORD);
+    }
+
+    static if (_WIN32_WINNT >= 0x500) {
+        LANGID GetSystemDefaultUILanguage();
+        LANGID GetUserDefaultUILanguage();
+
+        BOOL EnumSystemLanguageGroupsA(LANGUAGEGROUP_ENUMPROCA, DWORD,
+          LONG_PTR);
+        BOOL EnumSystemLanguageGroupsW(LANGUAGEGROUP_ENUMPROCW, DWORD,
+          LONG_PTR);
+        BOOL EnumLanguageGroupLocalesA(LANGGROUPLOCALE_ENUMPROCA, LGRPID,
+          DWORD, LONG_PTR);
+        BOOL EnumLanguageGroupLocalesW(LANGGROUPLOCALE_ENUMPROCW, LGRPID,
+          DWORD, LONG_PTR);
+        BOOL EnumUILanguagesA(UILANGUAGE_ENUMPROCA, DWORD, LONG_PTR);
+        BOOL EnumUILanguagesW(UILANGUAGE_ENUMPROCW, DWORD, LONG_PTR);
+    }
+}
+
+version (Unicode) {
+    alias CALINFO_ENUMPROCW CALINFO_ENUMPROC;
+    alias CALINFO_ENUMPROCEXW CALINFO_ENUMPROCEX;
+    alias LOCALE_ENUMPROCW LOCALE_ENUMPROC;
+    alias CODEPAGE_ENUMPROCW CODEPAGE_ENUMPROC;
+    alias DATEFMT_ENUMPROCW DATEFMT_ENUMPROC;
+    alias DATEFMT_ENUMPROCEXW DATEFMT_ENUMPROCEX;
+    alias TIMEFMT_ENUMPROCW TIMEFMT_ENUMPROC;
+    alias LANGUAGEGROUP_ENUMPROCW LANGUAGEGROUP_ENUMPROC;
+    alias LANGGROUPLOCALE_ENUMPROCW LANGGROUPLOCALE_ENUMPROC;
+    alias UILANGUAGE_ENUMPROCW UILANGUAGE_ENUMPROC;
+    alias CPINFOEXW CPINFOEX;
+    alias LPCPINFOEXW LPCPINFOEX;
+    alias CURRENCYFMTW CURRENCYFMT;
+    alias LPCURRENCYFMTW LPCURRENCYFMT;
+    alias NUMBERFMTW NUMBERFMT;
+    alias LPNUMBERFMTW LPNUMBERFMT;
+    alias CompareStringW CompareString;
+    alias EnumCalendarInfoW EnumCalendarInfo;
+    alias EnumSystemCodePagesW EnumSystemCodePages;
+    alias EnumSystemLocalesW EnumSystemLocales;
+    alias EnumTimeFormatsW EnumTimeFormats;
+    alias FoldStringW FoldString;
+    alias GetCalendarInfoW GetCalendarInfo;
+    alias GetCPInfoExW GetCPInfoEx;
+    alias GetCurrencyFormatW GetCurrencyFormat;
+    alias GetDateFormatW GetDateFormat;
+    alias GetGeoInfoW GetGeoInfo;
+    alias GetLocaleInfoW GetLocaleInfo;
+    alias GetNumberFormatW GetNumberFormat;
+    alias GetStringTypeExW GetStringTypeEx;
+    alias GetTimeFormatW GetTimeFormat;
+    alias LCMapStringW LCMapString;
+    alias SetCalendarInfoW SetCalendarInfo;
+    alias SetLocaleInfoW SetLocaleInfo;
+
+    static if (_WIN32_WINNT >= 0x410) {
+        alias EnumCalendarInfoExW EnumCalendarInfoEx;
+        alias EnumDateFormatsExW EnumDateFormatsEx;
+    }
+
+    static if (_WIN32_WINNT >= 0x500) {
+        alias EnumSystemLanguageGroupsW EnumSystemLanguageGroups;
+        alias EnumLanguageGroupLocalesW EnumLanguageGroupLocales;
+        alias EnumUILanguagesW EnumUILanguages;
+    }
+
+} else {
+    alias CALINFO_ENUMPROCA CALINFO_ENUMPROC;
+    alias CALINFO_ENUMPROCEXA CALINFO_ENUMPROCEX;
+    alias LOCALE_ENUMPROCA LOCALE_ENUMPROC;
+    alias CODEPAGE_ENUMPROCA CODEPAGE_ENUMPROC;
+    alias DATEFMT_ENUMPROCA DATEFMT_ENUMPROC;
+    alias DATEFMT_ENUMPROCEXA DATEFMT_ENUMPROCEX;
+    alias TIMEFMT_ENUMPROCA TIMEFMT_ENUMPROC;
+    alias LANGUAGEGROUP_ENUMPROCA LANGUAGEGROUP_ENUMPROC;
+    alias LANGGROUPLOCALE_ENUMPROCA LANGGROUPLOCALE_ENUMPROC;
+    alias UILANGUAGE_ENUMPROCA UILANGUAGE_ENUMPROC;
+    alias CPINFOEXA CPINFOEX;
+    alias LPCPINFOEXA LPCPINFOEX;
+    alias CURRENCYFMTA CURRENCYFMT;
+    alias LPCURRENCYFMTA LPCURRENCYFMT;
+    alias NUMBERFMTA NUMBERFMT;
+    alias LPNUMBERFMTA LPNUMBERFMT;
+    alias CompareStringA CompareString;
+    alias EnumCalendarInfoA EnumCalendarInfo;
+    alias EnumSystemCodePagesA EnumSystemCodePages;
+    alias EnumSystemLocalesA EnumSystemLocales;
+    alias EnumTimeFormatsA EnumTimeFormats;
+    alias FoldStringA FoldString;
+    alias GetCalendarInfoA GetCalendarInfo;
+    alias GetCPInfoExA GetCPInfoEx;
+    alias GetCurrencyFormatA GetCurrencyFormat;
+    alias GetDateFormatA GetDateFormat;
+    alias GetGeoInfoA GetGeoInfo;
+    alias GetLocaleInfoA GetLocaleInfo;
+    alias GetNumberFormatA GetNumberFormat;
+    alias GetStringTypeExA GetStringTypeEx;
+    alias GetTimeFormatA GetTimeFormat;
+    alias LCMapStringA LCMapString;
+    alias SetCalendarInfoA SetCalendarInfo;
+    alias SetLocaleInfoA SetLocaleInfo;
+
+    static if (_WIN32_WINNT >= 0x410) {
+        alias EnumCalendarInfoExA EnumCalendarInfoEx;
+        alias EnumDateFormatsExA EnumDateFormatsEx;
+    }
+
+    static if (_WIN32_WINNT >= 0x500) {
+        alias EnumSystemLanguageGroupsA EnumSystemLanguageGroups;
+        alias EnumLanguageGroupLocalesA EnumLanguageGroupLocales;
+        alias EnumUILanguagesA EnumUILanguages;
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/windows/winnt.d b/libphobos/libdruntime/core/sys/windows/winnt.d
new file mode 100644
index 00000000000..564ba3c5129
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winnt.d
@@ -0,0 +1,4114 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW API for MS-Windows 3.12
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winnt.d)
+ */
+module core.sys.windows.winnt;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+
+public import core.sys.windows.basetsd, core.sys.windows.windef, core.sys.windows.winerror;
+private import core.sys.windows.w32api;
+
+/* Translation Notes:
+The following macros are unneeded for D:
+FIELD_OFFSET(t,f), CONTAINING_RECORD(address, type, field)
+*/
+
+alias void   VOID;
+alias char   CHAR, CCHAR;
+alias wchar  WCHAR;
+alias bool   BOOLEAN;
+alias byte   FCHAR;
+alias ubyte  UCHAR;
+alias short  SHORT;
+alias ushort LANGID, FSHORT;
+alias uint   LCID, FLONG, ACCESS_MASK;
+alias long   LONGLONG, USN;
+alias ulong  DWORDLONG, ULONGLONG;
+
+alias void*  PVOID, LPVOID;
+alias char*  PSZ, PCHAR, PCCHAR, LPCH, PCH, LPSTR, PSTR;
+alias wchar* PWCHAR, LPWCH, PWCH, LPWSTR, PWSTR;
+alias bool*  PBOOLEAN;
+alias ubyte* PUCHAR;
+alias short* PSHORT;
+alias int*   PLONG;
+alias uint*  PLCID, PACCESS_MASK;
+alias long*  PLONGLONG;
+alias ulong* PDWORDLONG, PULONGLONG;
+
+// FIXME(MinGW) for __WIN64
+alias void*  PVOID64;
+
+// const versions
+alias const(char)*  PCCH, LPCCH, PCSTR, LPCSTR;
+alias const(wchar)* LPCWCH, PCWCH, LPCWSTR, PCWSTR;
+
+version (Unicode) {
+    alias WCHAR TCHAR, _TCHAR;
+} else {
+    alias CHAR TCHAR, _TCHAR;
+}
+
+alias TCHAR         TBYTE;
+alias TCHAR*        PTCH , PTBYTE, LPTCH , PTSTR , LPTSTR , LP, PTCHAR;
+alias const(TCHAR)* PCTCH,         LPCTCH, PCTSTR, LPCTSTR            ;
+
+enum char ANSI_NULL = '\0';
+enum wchar UNICODE_NULL = '\0';
+
+enum APPLICATION_ERROR_MASK       = 0x20000000;
+enum ERROR_SEVERITY_SUCCESS       = 0x00000000;
+enum ERROR_SEVERITY_INFORMATIONAL = 0x40000000;
+enum ERROR_SEVERITY_WARNING       = 0x80000000;
+enum ERROR_SEVERITY_ERROR         = 0xC0000000;
+
+// MinGW: also in ddk/ntifs.h
+enum : USHORT {
+    COMPRESSION_FORMAT_NONE     = 0x0000,
+    COMPRESSION_FORMAT_DEFAULT  = 0x0001,
+    COMPRESSION_FORMAT_LZNT1    = 0x0002,
+    COMPRESSION_ENGINE_STANDARD = 0x0000,
+    COMPRESSION_ENGINE_MAXIMUM  = 0x0100,
+    COMPRESSION_ENGINE_HIBER    = 0x0200
+}
+
+// ACCESS_DENIED_OBJECT_ACE, etc
+enum DWORD
+    ACE_OBJECT_TYPE_PRESENT           = 0x00000001,
+    ACE_INHERITED_OBJECT_TYPE_PRESENT = 0x00000002;
+
+// ACE_HEADER.AceType
+// also in ddk/ntifs.h
+enum : BYTE {
+    ACCESS_ALLOWED_ACE_TYPE,
+    ACCESS_DENIED_ACE_TYPE,
+    SYSTEM_AUDIT_ACE_TYPE,
+    SYSTEM_ALARM_ACE_TYPE
+}
+
+// ACE_HEADER.AceFlags
+enum BYTE
+    OBJECT_INHERIT_ACE         = 0x01,
+    CONTAINER_INHERIT_ACE      = 0x02,
+    NO_PROPAGATE_INHERIT_ACE   = 0x04,
+    INHERIT_ONLY_ACE           = 0x08,
+    INHERITED_ACE              = 0x10,
+    VALID_INHERIT_FLAGS        = 0x1F,
+    SUCCESSFUL_ACCESS_ACE_FLAG = 0x40,
+    FAILED_ACCESS_ACE_FLAG     = 0x80;
+
+// Access Mask Format
+enum ACCESS_MASK
+    DELETE                   = 0x00010000,
+    READ_CONTROL             = 0x00020000,
+    WRITE_DAC                = 0x00040000,
+    WRITE_OWNER              = 0x00080000,
+    SYNCHRONIZE              = 0x00100000,
+    ACCESS_SYSTEM_SECURITY   = 0x01000000,
+    MAXIMUM_ALLOWED          = 0x02000000,
+    GENERIC_READ             = 0x80000000,
+    GENERIC_WRITE            = 0x40000000,
+    GENERIC_EXECUTE          = 0x20000000,
+    GENERIC_ALL              = 0x10000000,
+    STANDARD_RIGHTS_REQUIRED = 0x000F0000,
+    STANDARD_RIGHTS_READ     = 0x00020000,
+    STANDARD_RIGHTS_WRITE    = 0x00020000,
+    STANDARD_RIGHTS_EXECUTE  = 0x00020000,
+    STANDARD_RIGHTS_ALL      = 0x001F0000,
+    SPECIFIC_RIGHTS_ALL      = 0x0000FFFF;
+
+
+enum DWORD INVALID_FILE_ATTRIBUTES = -1;
+
+// MinGW: Also in ddk/winddk.h
+enum DWORD
+    FILE_LIST_DIRECTORY       = 0x00000001,
+    FILE_READ_DATA            = 0x00000001,
+    FILE_ADD_FILE             = 0x00000002,
+    FILE_WRITE_DATA           = 0x00000002,
+    FILE_ADD_SUBDIRECTORY     = 0x00000004,
+    FILE_APPEND_DATA          = 0x00000004,
+    FILE_CREATE_PIPE_INSTANCE = 0x00000004,
+    FILE_READ_EA              = 0x00000008,
+    FILE_READ_PROPERTIES      = 0x00000008,
+    FILE_WRITE_EA             = 0x00000010,
+    FILE_WRITE_PROPERTIES     = 0x00000010,
+    FILE_EXECUTE              = 0x00000020,
+    FILE_TRAVERSE             = 0x00000020,
+    FILE_DELETE_CHILD         = 0x00000040,
+    FILE_READ_ATTRIBUTES      = 0x00000080,
+    FILE_WRITE_ATTRIBUTES     = 0x00000100;
+
+enum DWORD
+    FILE_SHARE_READ        = 0x00000001,
+    FILE_SHARE_WRITE       = 0x00000002,
+    FILE_SHARE_DELETE      = 0x00000004,
+    FILE_SHARE_VALID_FLAGS = 0x00000007;
+
+enum DWORD
+    FILE_ATTRIBUTE_READONLY            = 0x00000001,
+    FILE_ATTRIBUTE_HIDDEN              = 0x00000002,
+    FILE_ATTRIBUTE_SYSTEM              = 0x00000004,
+    FILE_ATTRIBUTE_DIRECTORY           = 0x00000010,
+    FILE_ATTRIBUTE_ARCHIVE             = 0x00000020,
+    FILE_ATTRIBUTE_DEVICE              = 0x00000040,
+    FILE_ATTRIBUTE_NORMAL              = 0x00000080,
+    FILE_ATTRIBUTE_TEMPORARY           = 0x00000100,
+    FILE_ATTRIBUTE_SPARSE_FILE         = 0x00000200,
+    FILE_ATTRIBUTE_REPARSE_POINT       = 0x00000400,
+    FILE_ATTRIBUTE_COMPRESSED          = 0x00000800,
+    FILE_ATTRIBUTE_OFFLINE             = 0x00001000,
+    FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000,
+    FILE_ATTRIBUTE_ENCRYPTED           = 0x00004000,
+    FILE_ATTRIBUTE_VALID_FLAGS         = 0x00007fb7,
+    FILE_ATTRIBUTE_VALID_SET_FLAGS     = 0x000031a7;
+
+// These are not documented on MSDN
+enum FILE_COPY_STRUCTURED_STORAGE = 0x00000041;
+enum FILE_STRUCTURED_STORAGE      = 0x00000441;
+
+// Nor are these
+enum FILE_VALID_OPTION_FLAGS          = 0x00ffffff;
+enum FILE_VALID_PIPE_OPTION_FLAGS     = 0x00000032;
+enum FILE_VALID_MAILSLOT_OPTION_FLAGS = 0x00000032;
+enum FILE_VALID_SET_FLAGS             = 0x00000036;
+
+enum ULONG
+    FILE_SUPERSEDE           = 0x00000000,
+    FILE_OPEN                = 0x00000001,
+    FILE_CREATE              = 0x00000002,
+    FILE_OPEN_IF             = 0x00000003,
+    FILE_OVERWRITE           = 0x00000004,
+    FILE_OVERWRITE_IF        = 0x00000005,
+    FILE_MAXIMUM_DISPOSITION = 0x00000005;
+
+enum ULONG
+    FILE_DIRECTORY_FILE            = 0x00000001,
+    FILE_WRITE_THROUGH             = 0x00000002,
+    FILE_SEQUENTIAL_ONLY           = 0x00000004,
+    FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008,
+    FILE_SYNCHRONOUS_IO_ALERT      = 0x00000010,
+    FILE_SYNCHRONOUS_IO_NONALERT   = 0x00000020,
+    FILE_NON_DIRECTORY_FILE        = 0x00000040,
+    FILE_CREATE_TREE_CONNECTION    = 0x00000080,
+    FILE_COMPLETE_IF_OPLOCKED      = 0x00000100,
+    FILE_NO_EA_KNOWLEDGE           = 0x00000200,
+    FILE_OPEN_FOR_RECOVERY         = 0x00000400,
+    FILE_RANDOM_ACCESS             = 0x00000800,
+    FILE_DELETE_ON_CLOSE           = 0x00001000,
+    FILE_OPEN_BY_FILE_ID           = 0x00002000,
+    FILE_OPEN_FOR_BACKUP_INTENT    = 0x00004000,
+    FILE_NO_COMPRESSION            = 0x00008000,
+    FILE_RESERVE_OPFILTER          = 0x00100000,
+    FILE_OPEN_REPARSE_POINT        = 0x00200000,
+    FILE_OPEN_NO_RECALL            = 0x00400000,
+    FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000;
+
+
+enum ACCESS_MASK
+    FILE_ALL_ACCESS      = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x01FF,
+    FILE_GENERIC_EXECUTE = STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES
+                           | FILE_EXECUTE | SYNCHRONIZE,
+    FILE_GENERIC_READ    = STANDARD_RIGHTS_READ | FILE_READ_DATA
+                           | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE,
+    FILE_GENERIC_WRITE   = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA
+                           | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA
+                           | SYNCHRONIZE;
+
+// MinGW: end winddk.h
+// MinGW: also in ddk/ntifs.h
+enum DWORD
+    FILE_NOTIFY_CHANGE_FILE_NAME    = 0x00000001,
+    FILE_NOTIFY_CHANGE_DIR_NAME     = 0x00000002,
+    FILE_NOTIFY_CHANGE_NAME         = 0x00000003,
+    FILE_NOTIFY_CHANGE_ATTRIBUTES   = 0x00000004,
+    FILE_NOTIFY_CHANGE_SIZE         = 0x00000008,
+    FILE_NOTIFY_CHANGE_LAST_WRITE   = 0x00000010,
+    FILE_NOTIFY_CHANGE_LAST_ACCESS  = 0x00000020,
+    FILE_NOTIFY_CHANGE_CREATION     = 0x00000040,
+    FILE_NOTIFY_CHANGE_EA           = 0x00000080,
+    FILE_NOTIFY_CHANGE_SECURITY     = 0x00000100,
+    FILE_NOTIFY_CHANGE_STREAM_NAME  = 0x00000200,
+    FILE_NOTIFY_CHANGE_STREAM_SIZE  = 0x00000400,
+    FILE_NOTIFY_CHANGE_STREAM_WRITE = 0x00000800,
+    FILE_NOTIFY_VALID_MASK          = 0x00000fff;
+
+enum DWORD
+    FILE_CASE_SENSITIVE_SEARCH      = 0x00000001,
+    FILE_CASE_PRESERVED_NAMES       = 0x00000002,
+    FILE_UNICODE_ON_DISK            = 0x00000004,
+    FILE_PERSISTENT_ACLS            = 0x00000008,
+    FILE_FILE_COMPRESSION           = 0x00000010,
+    FILE_VOLUME_QUOTAS              = 0x00000020,
+    FILE_SUPPORTS_SPARSE_FILES      = 0x00000040,
+    FILE_SUPPORTS_REPARSE_POINTS    = 0x00000080,
+    FILE_SUPPORTS_REMOTE_STORAGE    = 0x00000100,
+    FS_LFN_APIS                     = 0x00004000,
+    FILE_VOLUME_IS_COMPRESSED       = 0x00008000,
+    FILE_SUPPORTS_OBJECT_IDS        = 0x00010000,
+    FILE_SUPPORTS_ENCRYPTION        = 0x00020000,
+    FILE_NAMED_STREAMS              = 0x00040000,
+    FILE_READ_ONLY_VOLUME           = 0x00080000,
+    FILE_SEQUENTIAL_WRITE_ONCE      = 0x00100000,
+    FILE_SUPPORTS_TRANSACTIONS      = 0x00200000;
+
+// These are not documented on MSDN
+enum ACCESS_MASK
+    IO_COMPLETION_QUERY_STATE  = 1,
+    IO_COMPLETION_MODIFY_STATE = 2,
+    IO_COMPLETION_ALL_ACCESS   = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 3;
+// MinGW: end ntifs.h
+
+// MinGW: also in ddk/winddk.h
+enum DWORD
+    DUPLICATE_CLOSE_SOURCE    = 1,
+    DUPLICATE_SAME_ACCESS     = 2,
+    DUPLICATE_SAME_ATTRIBUTES = 4;
+// MinGW: end winddk.k
+
+enum DWORD
+    MAILSLOT_NO_MESSAGE   = -1,
+    MAILSLOT_WAIT_FOREVER = -1;
+
+enum ACCESS_MASK
+    PROCESS_TERMINATE         = 0x0001,
+    PROCESS_CREATE_THREAD     = 0x0002,
+    PROCESS_SET_SESSIONID     = 0x0004,
+    PROCESS_VM_OPERATION      = 0x0008,
+    PROCESS_VM_READ           = 0x0010,
+    PROCESS_VM_WRITE          = 0x0020,
+    PROCESS_DUP_HANDLE        = 0x0040,
+    PROCESS_CREATE_PROCESS    = 0x0080,
+    PROCESS_SET_QUOTA         = 0x0100,
+    PROCESS_SET_INFORMATION   = 0x0200,
+    PROCESS_QUERY_INFORMATION = 0x0400,
+    PROCESS_ALL_ACCESS        = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x0FFF;
+
+enum ACCESS_MASK
+    THREAD_TERMINATE            = 0x0001,
+    THREAD_SUSPEND_RESUME       = 0x0002,
+    THREAD_GET_CONTEXT          = 0x0008,
+    THREAD_SET_CONTEXT          = 0x0010,
+    THREAD_SET_INFORMATION      = 0x0020,
+    THREAD_QUERY_INFORMATION    = 0x0040,
+    THREAD_SET_THREAD_TOKEN     = 0x0080,
+    THREAD_IMPERSONATE          = 0x0100,
+    THREAD_DIRECT_IMPERSONATION = 0x0200,
+    THREAD_ALL_ACCESS           = STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3FF;
+
+// These are not documented on MSDN
+enum THREAD_BASE_PRIORITY_LOWRT =  15;
+enum THREAD_BASE_PRIORITY_MAX   =   2;
+enum THREAD_BASE_PRIORITY_MIN   =  -2;
+enum THREAD_BASE_PRIORITY_IDLE  = -15;
+
+enum DWORD EXCEPTION_NONCONTINUABLE      =  1;
+enum size_t EXCEPTION_MAXIMUM_PARAMETERS = 15;
+
+// These are not documented on MSDN
+enum ACCESS_MASK
+    MUTANT_QUERY_STATE = 1,
+    MUTANT_ALL_ACCESS =  STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | MUTANT_QUERY_STATE;
+
+enum ACCESS_MASK
+    TIMER_QUERY_STATE  = 1,
+    TIMER_MODIFY_STATE = 2,
+    TIMER_ALL_ACCESS   = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | TIMER_QUERY_STATE
+                         | TIMER_MODIFY_STATE;
+
+enum SID_IDENTIFIER_AUTHORITY
+    SECURITY_NULL_SID_AUTHORITY        = {[5: 0]},
+    SECURITY_WORLD_SID_AUTHORITY       = {[5: 1]},
+    SECURITY_LOCAL_SID_AUTHORITY       = {[5: 2]},
+    SECURITY_CREATOR_SID_AUTHORITY     = {[5: 3]},
+    SECURITY_NON_UNIQUE_AUTHORITY      = {[5: 4]},
+    SECURITY_NT_AUTHORITY              = {[5: 5]},
+    SECURITY_MANDATORY_LABEL_AUTHORITY = {[5: 6]};
+
+enum DWORD
+    SECURITY_NULL_RID                   =  0,
+    SECURITY_WORLD_RID                  =  0,
+    SECURITY_LOCAL_RID                  =  0,
+    SECURITY_CREATOR_OWNER_RID          =  0,
+    SECURITY_CREATOR_GROUP_RID          =  1,
+    SECURITY_DIALUP_RID                 =  1,
+    SECURITY_NETWORK_RID                =  2,
+    SECURITY_BATCH_RID                  =  3,
+    SECURITY_INTERACTIVE_RID            =  4,
+    SECURITY_LOGON_IDS_RID              =  5,
+    SECURITY_SERVICE_RID                =  6,
+    SECURITY_LOCAL_SYSTEM_RID           = 18,
+    SECURITY_BUILTIN_DOMAIN_RID         = 32,
+    SECURITY_PRINCIPAL_SELF_RID         = 10,
+    SECURITY_CREATOR_OWNER_SERVER_RID   =  2,
+    SECURITY_CREATOR_GROUP_SERVER_RID   =  3,
+    SECURITY_LOGON_IDS_RID_COUNT        =  3,
+    SECURITY_ANONYMOUS_LOGON_RID        =  7,
+    SECURITY_PROXY_RID                  =  8,
+    SECURITY_ENTERPRISE_CONTROLLERS_RID =  9,
+    SECURITY_SERVER_LOGON_RID           = SECURITY_ENTERPRISE_CONTROLLERS_RID,
+    SECURITY_AUTHENTICATED_USER_RID     = 11,
+    SECURITY_RESTRICTED_CODE_RID        = 12,
+    SECURITY_NT_NON_UNIQUE_RID          = 21,
+    SID_REVISION                        =  1;
+
+enum : DWORD {
+    DOMAIN_USER_RID_ADMIN        = 0x01F4,
+    DOMAIN_USER_RID_GUEST        = 0x01F5,
+    DOMAIN_GROUP_RID_ADMINS      = 0x0200,
+    DOMAIN_GROUP_RID_USERS       = 0x0201,
+    DOMAIN_ALIAS_RID_ADMINS      = 0x0220,
+    DOMAIN_ALIAS_RID_USERS       = 0x0221,
+    DOMAIN_ALIAS_RID_GUESTS      = 0x0222,
+    DOMAIN_ALIAS_RID_POWER_USERS = 0x0223,
+    DOMAIN_ALIAS_RID_ACCOUNT_OPS = 0x0224,
+    DOMAIN_ALIAS_RID_SYSTEM_OPS  = 0x0225,
+    DOMAIN_ALIAS_RID_PRINT_OPS   = 0x0226,
+    DOMAIN_ALIAS_RID_BACKUP_OPS  = 0x0227,
+    DOMAIN_ALIAS_RID_REPLICATOR  = 0x0228
+}
+
+enum : WORD {
+    SECURITY_MANDATORY_UNTRUSTED_RID         = 0,
+    SECURITY_MANDATORY_LOW_RID               = 0x1000,
+    SECURITY_MANDATORY_MEDIUM_RID            = 0x2000,
+    SECURITY_MANDATORY_HIGH_RID              = 0x3000,
+    SECURITY_MANDATORY_SYSTEM_RID            = 0x4000,
+    SECURITY_MANDATORY_PROTECTED_PROCESS_RID = 0x5000,
+    SECURITY_MANDATORY_MAXIMUM_USER_RID      = SECURITY_MANDATORY_SYSTEM_RID
+}
+
+const TCHAR[]
+    SE_CREATE_TOKEN_NAME           = "SeCreateTokenPrivilege",
+    SE_ASSIGNPRIMARYTOKEN_NAME     = "SeAssignPrimaryTokenPrivilege",
+    SE_LOCK_MEMORY_NAME            = "SeLockMemoryPrivilege",
+    SE_INCREASE_QUOTA_NAME         = "SeIncreaseQuotaPrivilege",
+    SE_UNSOLICITED_INPUT_NAME      = "SeUnsolicitedInputPrivilege",
+    SE_MACHINE_ACCOUNT_NAME        = "SeMachineAccountPrivilege",
+    SE_TCB_NAME                    = "SeTcbPrivilege",
+    SE_SECURITY_NAME               = "SeSecurityPrivilege",
+    SE_TAKE_OWNERSHIP_NAME         = "SeTakeOwnershipPrivilege",
+    SE_LOAD_DRIVER_NAME            = "SeLoadDriverPrivilege",
+    SE_SYSTEM_PROFILE_NAME         = "SeSystemProfilePrivilege",
+    SE_SYSTEMTIME_NAME             = "SeSystemtimePrivilege",
+    SE_PROF_SINGLE_PROCESS_NAME    = "SeProfileSingleProcessPrivilege",
+    SE_INC_BASE_PRIORITY_NAME      = "SeIncreaseBasePriorityPrivilege",
+    SE_CREATE_PAGEFILE_NAME        = "SeCreatePagefilePrivilege",
+    SE_CREATE_PERMANENT_NAME       = "SeCreatePermanentPrivilege",
+    SE_BACKUP_NAME                 = "SeBackupPrivilege",
+    SE_RESTORE_NAME                = "SeRestorePrivilege",
+    SE_SHUTDOWN_NAME               = "SeShutdownPrivilege",
+    SE_DEBUG_NAME                  = "SeDebugPrivilege",
+    SE_AUDIT_NAME                  = "SeAuditPrivilege",
+    SE_SYSTEM_ENVIRONMENT_NAME     = "SeSystemEnvironmentPrivilege",
+    SE_CHANGE_NOTIFY_NAME          = "SeChangeNotifyPrivilege",
+    SE_REMOTE_SHUTDOWN_NAME        = "SeRemoteShutdownPrivilege",
+    SE_CREATE_GLOBAL_NAME          = "SeCreateGlobalPrivilege",
+    SE_UNDOCK_NAME                 = "SeUndockPrivilege",
+    SE_MANAGE_VOLUME_NAME          = "SeManageVolumePrivilege",
+    SE_IMPERSONATE_NAME            = "SeImpersonatePrivilege",
+    SE_ENABLE_DELEGATION_NAME      = "SeEnableDelegationPrivilege",
+    SE_SYNC_AGENT_NAME             = "SeSyncAgentPrivilege",
+    SE_TRUSTED_CREDMAN_ACCESS_NAME = "SeTrustedCredManAccessPrivilege",
+    SE_RELABEL_NAME                = "SeRelabelPrivilege",
+    SE_INCREASE_WORKING_SET_NAME   = "SeIncreaseWorkingSetPrivilege",
+    SE_TIME_ZONE_NAME              = "SeTimeZonePrivilege",
+    SE_CREATE_SYMBOLIC_LINK_NAME   = "SeCreateSymbolicLinkPrivilege";
+
+enum DWORD
+    SE_GROUP_MANDATORY          = 0x00000001,
+    SE_GROUP_ENABLED_BY_DEFAULT = 0x00000002,
+    SE_GROUP_ENABLED            = 0x00000004,
+    SE_GROUP_OWNER              = 0x00000008,
+    SE_GROUP_USE_FOR_DENY_ONLY  = 0x00000010,
+    SE_GROUP_INTEGRITY          = 0x00000020,
+    SE_GROUP_INTEGRITY_ENABLED  = 0x00000040,
+    SE_GROUP_RESOURCE           = 0x20000000,
+    SE_GROUP_LOGON_ID           = 0xC0000000;
+
+// Primary language identifiers
+enum : USHORT {
+    LANG_NEUTRAL,
+    LANG_ARABIC,
+    LANG_BULGARIAN,
+    LANG_CATALAN,
+    LANG_CHINESE,
+    LANG_CZECH,
+    LANG_DANISH,
+    LANG_GERMAN,
+    LANG_GREEK,
+    LANG_ENGLISH,
+    LANG_SPANISH,
+    LANG_FINNISH,
+    LANG_FRENCH,
+    LANG_HEBREW,
+    LANG_HUNGARIAN,
+    LANG_ICELANDIC,
+    LANG_ITALIAN,
+    LANG_JAPANESE,
+    LANG_KOREAN,
+    LANG_DUTCH,
+    LANG_NORWEGIAN,
+    LANG_POLISH,
+    LANG_PORTUGUESE,    // = 0x16
+    LANG_ROMANIAN          = 0x18,
+    LANG_RUSSIAN,
+    LANG_CROATIAN,      // = 0x1A
+    LANG_SERBIAN           = 0x1A,
+    LANG_BOSNIAN           = 0x1A,
+    LANG_SLOVAK,
+    LANG_ALBANIAN,
+    LANG_SWEDISH,
+    LANG_THAI,
+    LANG_TURKISH,
+    LANG_URDU,
+    LANG_INDONESIAN,
+    LANG_UKRAINIAN,
+    LANG_BELARUSIAN,
+    LANG_SLOVENIAN,
+    LANG_ESTONIAN,
+    LANG_LATVIAN,
+    LANG_LITHUANIAN,    // = 0x27
+    LANG_FARSI             = 0x29,
+    LANG_PERSIAN           = 0x29,
+    LANG_VIETNAMESE,
+    LANG_ARMENIAN,
+    LANG_AZERI,
+    LANG_BASQUE,
+    LANG_LOWER_SORBIAN, // = 0x2E
+    LANG_UPPER_SORBIAN     = 0x2E,
+    LANG_MACEDONIAN,    // = 0x2F
+    LANG_TSWANA            = 0x32,
+    LANG_XHOSA             = 0x34,
+    LANG_ZULU,
+    LANG_AFRIKAANS,
+    LANG_GEORGIAN,
+    LANG_FAEROESE,
+    LANG_HINDI,
+    LANG_MALTESE,
+    LANG_SAMI,
+    LANG_IRISH,         // = 0x3C
+    LANG_MALAY             = 0x3E,
+    LANG_KAZAK,
+    LANG_KYRGYZ,
+    LANG_SWAHILI,       // = 0x41
+    LANG_UZBEK             = 0x43,
+    LANG_TATAR,
+    LANG_BENGALI,
+    LANG_PUNJABI,
+    LANG_GUJARATI,
+    LANG_ORIYA,
+    LANG_TAMIL,
+    LANG_TELUGU,
+    LANG_KANNADA,
+    LANG_MALAYALAM,
+    LANG_ASSAMESE,
+    LANG_MARATHI,
+    LANG_SANSKRIT,
+    LANG_MONGOLIAN,
+    LANG_TIBETAN,
+    LANG_WELSH,
+    LANG_KHMER,
+    LANG_LAO,           // = 0x54
+    LANG_GALICIAN          = 0x56,
+    LANG_KONKANI,
+    LANG_MANIPURI,
+    LANG_SINDHI,
+    LANG_SYRIAC,
+    LANG_SINHALESE,     // = 0x5B
+    LANG_INUKTITUT         = 0x5D,
+    LANG_AMHARIC,
+    LANG_TAMAZIGHT,
+    LANG_KASHMIRI,
+    LANG_NEPALI,
+    LANG_FRISIAN,
+    LANG_PASHTO,
+    LANG_FILIPINO,
+    LANG_DIVEHI,        // = 0x65
+    LANG_HAUSA             = 0x68,
+    LANG_YORUBA            = 0x6A,
+    LANG_QUECHUA,
+    LANG_SOTHO,
+    LANG_BASHKIR,
+    LANG_LUXEMBOURGISH,
+    LANG_GREENLANDIC,
+    LANG_IGBO,          // = 0x70
+    LANG_TIGRIGNA          = 0x73,
+    LANG_YI                = 0x78,
+    LANG_MAPUDUNGUN        = 0x7A,
+    LANG_MOHAWK            = 0x7C,
+    LANG_BRETON            = 0x7E,
+    LANG_UIGHUR            = 0x80,
+    LANG_MAORI,
+    LANG_OCCITAN,
+    LANG_CORSICAN,
+    LANG_ALSATIAN,
+    LANG_YAKUT,
+    LANG_KICHE,
+    LANG_KINYARWANDA,
+    LANG_WOLOF,         // = 0x88
+    LANG_DARI              = 0x8C,
+    LANG_MALAGASY,      // = 0x8D
+
+    LANG_SERBIAN_NEUTRAL   = 0x7C1A,
+    LANG_BOSNIAN_NEUTRAL   = 0x781A,
+
+    LANG_INVARIANT         = 0x7F
+}
+
+
+// Sublanguage identifiers
+enum : USHORT {
+    SUBLANG_NEUTRAL,
+    SUBLANG_DEFAULT,
+    SUBLANG_SYS_DEFAULT,
+    SUBLANG_CUSTOM_DEFAULT,                  // =  3
+    SUBLANG_UI_CUSTOM_DEFAULT                   =  3,
+    SUBLANG_CUSTOM_UNSPECIFIED,              // =  4
+
+    SUBLANG_AFRIKAANS_SOUTH_AFRICA              =  1,
+    SUBLANG_ALBANIAN_ALBANIA                    =  1,
+    SUBLANG_ALSATIAN_FRANCE                     =  1,
+    SUBLANG_AMHARIC_ETHIOPIA                    =  1,
+
+    SUBLANG_ARABIC_SAUDI_ARABIA                 =  1,
+    SUBLANG_ARABIC_IRAQ,
+    SUBLANG_ARABIC_EGYPT,
+    SUBLANG_ARABIC_LIBYA,
+    SUBLANG_ARABIC_ALGERIA,
+    SUBLANG_ARABIC_MOROCCO,
+    SUBLANG_ARABIC_TUNISIA,
+    SUBLANG_ARABIC_OMAN,
+    SUBLANG_ARABIC_YEMEN,
+    SUBLANG_ARABIC_SYRIA,
+    SUBLANG_ARABIC_JORDAN,
+    SUBLANG_ARABIC_LEBANON,
+    SUBLANG_ARABIC_KUWAIT,
+    SUBLANG_ARABIC_UAE,
+    SUBLANG_ARABIC_BAHRAIN,
+    SUBLANG_ARABIC_QATAR,                    // = 16
+
+    SUBLANG_ARMENIAN_ARMENIA                    =  1,
+    SUBLANG_ASSAMESE_INDIA                      =  1,
+
+    SUBLANG_AZERI_LATIN                         =  1,
+    SUBLANG_AZERI_CYRILLIC,                  // =  2
+
+    SUBLANG_BASHKIR_RUSSIA                      =  1,
+    SUBLANG_BASQUE_BASQUE                       =  1,
+    SUBLANG_BELARUSIAN_BELARUS                  =  1,
+    SUBLANG_BENGALI_INDIA                       =  1,
+
+    SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN    =  5,
+    SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC =  8,
+
+    SUBLANG_BRETON_FRANCE                       =  1,
+    SUBLANG_BULGARIAN_BULGARIA                  =  1,
+    SUBLANG_CATALAN_CATALAN                     =  1,
+
+    SUBLANG_CHINESE_TRADITIONAL                 =  1,
+    SUBLANG_CHINESE_SIMPLIFIED,
+    SUBLANG_CHINESE_HONGKONG,
+    SUBLANG_CHINESE_SINGAPORE,
+    SUBLANG_CHINESE_MACAU,                   // =  5
+
+    SUBLANG_CORSICAN_FRANCE                     =  1,
+
+    SUBLANG_CROATIAN_CROATIA                    =  1,
+    SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN   =  4,
+
+    SUBLANG_CZECH_CZECH_REPUBLIC                =  1,
+    SUBLANG_DANISH_DENMARK                      =  1,
+    SUBLANG_DIVEHI_MALDIVES                     =  1,
+
+    SUBLANG_DUTCH                               =  1,
+    SUBLANG_DUTCH_BELGIAN,                   // =  2
+
+    SUBLANG_ENGLISH_US                          =  1,
+    SUBLANG_ENGLISH_UK,
+    SUBLANG_ENGLISH_AUS,
+    SUBLANG_ENGLISH_CAN,
+    SUBLANG_ENGLISH_NZ,
+    SUBLANG_ENGLISH_EIRE,                    // =  6
+    SUBLANG_ENGLISH_IRELAND                     =  6,
+    SUBLANG_ENGLISH_SOUTH_AFRICA,
+    SUBLANG_ENGLISH_JAMAICA,
+    SUBLANG_ENGLISH_CARIBBEAN,
+    SUBLANG_ENGLISH_BELIZE,
+    SUBLANG_ENGLISH_TRINIDAD,
+    SUBLANG_ENGLISH_ZIMBABWE,
+    SUBLANG_ENGLISH_PHILIPPINES,             // = 13
+    SUBLANG_ENGLISH_INDIA                       = 16,
+    SUBLANG_ENGLISH_MALAYSIA,
+    SUBLANG_ENGLISH_SINGAPORE,               // = 18
+
+    SUBLANG_ESTONIAN_ESTONIA                    =  1,
+    SUBLANG_FAEROESE_FAROE_ISLANDS              =  1,
+    SUBLANG_FILIPINO_PHILIPPINES                =  1,
+    SUBLANG_FINNISH_FINLAND                     =  1,
+
+    SUBLANG_FRENCH                              =  1,
+    SUBLANG_FRENCH_BELGIAN,
+    SUBLANG_FRENCH_CANADIAN,
+    SUBLANG_FRENCH_SWISS,
+    SUBLANG_FRENCH_LUXEMBOURG,
+    SUBLANG_FRENCH_MONACO,                   // =  6
+
+    SUBLANG_FRISIAN_NETHERLANDS                 =  1,
+    SUBLANG_GALICIAN_GALICIAN                   =  1,
+    SUBLANG_GEORGIAN_GEORGIA                    =  1,
+
+    SUBLANG_GERMAN                              =  1,
+    SUBLANG_GERMAN_SWISS,
+    SUBLANG_GERMAN_AUSTRIAN,
+    SUBLANG_GERMAN_LUXEMBOURG,
+    SUBLANG_GERMAN_LIECHTENSTEIN,            // =  5
+
+    SUBLANG_GREEK_GREECE                        =  1,
+    SUBLANG_GREENLANDIC_GREENLAND               =  1,
+    SUBLANG_GUJARATI_INDIA                      =  1,
+    SUBLANG_HAUSA_NIGERIA                       =  1,
+    SUBLANG_HEBREW_ISRAEL                       =  1,
+    SUBLANG_HINDI_INDIA                         =  1,
+    SUBLANG_HUNGARIAN_HUNGARY                   =  1,
+    SUBLANG_ICELANDIC_ICELAND                   =  1,
+    SUBLANG_IGBO_NIGERIA                        =  1,
+    SUBLANG_INDONESIAN_INDONESIA                =  1,
+
+    SUBLANG_INUKTITUT_CANADA                    =  1,
+    SUBLANG_INUKTITUT_CANADA_LATIN              =  1,
+
+    SUBLANG_IRISH_IRELAND                       =  1,
+
+    SUBLANG_ITALIAN                             =  1,
+    SUBLANG_ITALIAN_SWISS,                   // =  2
+
+    SUBLANG_JAPANESE_JAPAN                      =  1,
+
+    SUBLANG_KASHMIRI_INDIA                      =  2,
+    SUBLANG_KASHMIRI_SASIA                      =  2,
+
+    SUBLANG_KAZAK_KAZAKHSTAN                    =  1,
+    SUBLANG_KHMER_CAMBODIA                      =  1,
+    SUBLANG_KICHE_GUATEMALA                     =  1,
+    SUBLANG_KINYARWANDA_RWANDA                  =  1,
+    SUBLANG_KONKANI_INDIA                       =  1,
+    SUBLANG_KOREAN                              =  1,
+    SUBLANG_KOREAN_JOHAB                        =  2,
+    SUBLANG_KYRGYZ_KYRGYZSTAN                   =  1,
+    SUBLANG_LAO_LAO_PDR                         =  1,
+    SUBLANG_LATVIAN_LATVIA                      =  1,
+
+    SUBLANG_LITHUANIAN                          =  1,
+    SUBLANG_LITHUANIAN_LITHUANIA                =  1,
+
+    SUBLANG_LOWER_SORBIAN_GERMANY               =  1,
+    SUBLANG_LUXEMBOURGISH_LUXEMBOURG            =  1,
+    SUBLANG_MACEDONIAN_MACEDONIA                =  1,
+    SUBLANG_MALAYALAM_INDIA                     =  1,
+    SUBLANG_MALTESE_MALTA                       =  1,
+    SUBLANG_MAORI_NEW_ZEALAND                   =  1,
+    SUBLANG_MAPUDUNGUN_CHILE                    =  1,
+    SUBLANG_MARATHI_INDIA                       =  1,
+    SUBLANG_MOHAWK_MOHAWK                       =  1,
+
+    SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA         =  1,
+    SUBLANG_MONGOLIAN_PRC,                   // =  2
+
+    SUBLANG_MALAY_MALAYSIA                      =  1,
+    SUBLANG_MALAY_BRUNEI_DARUSSALAM,         // =  2
+
+    SUBLANG_NEPALI_NEPAL                        =  1,
+    SUBLANG_NEPALI_INDIA,                    // =  2
+
+    SUBLANG_NORWEGIAN_BOKMAL                    =  1,
+    SUBLANG_NORWEGIAN_NYNORSK,               // =  2
+
+    SUBLANG_OCCITAN_FRANCE                      =  1,
+    SUBLANG_ORIYA_INDIA                         =  1,
+    SUBLANG_PASHTO_AFGHANISTAN                  =  1,
+    SUBLANG_PERSIAN_IRAN                        =  1,
+    SUBLANG_POLISH_POLAND                       =  1,
+
+    SUBLANG_PORTUGUESE_BRAZILIAN                =  1,
+    SUBLANG_PORTUGUESE                          =  2,
+    SUBLANG_PORTUGUESE_PORTUGAL,             // =  2
+
+    SUBLANG_PUNJABI_INDIA                       =  1,
+
+    SUBLANG_QUECHUA_BOLIVIA                     =  1,
+    SUBLANG_QUECHUA_ECUADOR,
+    SUBLANG_QUECHUA_PERU,                    // =  3
+
+    SUBLANG_ROMANIAN_ROMANIA                    =  1,
+    SUBLANG_ROMANSH_SWITZERLAND                 =  1,
+    SUBLANG_RUSSIAN_RUSSIA                      =  1,
+
+    SUBLANG_SAMI_NORTHERN_NORWAY                =  1,
+    SUBLANG_SAMI_NORTHERN_SWEDEN,
+    SUBLANG_SAMI_NORTHERN_FINLAND,           // =  3
+    SUBLANG_SAMI_SKOLT_FINLAND                  =  3,
+    SUBLANG_SAMI_INARI_FINLAND                  =  3,
+    SUBLANG_SAMI_LULE_NORWAY,
+    SUBLANG_SAMI_LULE_SWEDEN,
+    SUBLANG_SAMI_SOUTHERN_NORWAY,
+    SUBLANG_SAMI_SOUTHERN_SWEDEN,            // =  7
+
+    SUBLANG_SANSKRIT_INDIA                      =  1,
+
+    SUBLANG_SERBIAN_LATIN                       =  2,
+    SUBLANG_SERBIAN_CYRILLIC,                // =  3
+    SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN    =  6,
+    SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC =  7,
+
+    SUBLANG_SINDHI_AFGHANISTAN                  =  2,
+    SUBLANG_SINHALESE_SRI_LANKA                 =  1,
+    SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA         =  1,
+    SUBLANG_SLOVAK_SLOVAKIA                     =  1,
+    SUBLANG_SLOVENIAN_SLOVENIA                  =  1,
+
+    SUBLANG_SPANISH                             =  1,
+    SUBLANG_SPANISH_MEXICAN,
+    SUBLANG_SPANISH_MODERN,
+    SUBLANG_SPANISH_GUATEMALA,
+    SUBLANG_SPANISH_COSTA_RICA,
+    SUBLANG_SPANISH_PANAMA,
+    SUBLANG_SPANISH_DOMINICAN_REPUBLIC,
+    SUBLANG_SPANISH_VENEZUELA,
+    SUBLANG_SPANISH_COLOMBIA,
+    SUBLANG_SPANISH_PERU,
+    SUBLANG_SPANISH_ARGENTINA,
+    SUBLANG_SPANISH_ECUADOR,
+    SUBLANG_SPANISH_CHILE,
+    SUBLANG_SPANISH_URUGUAY,
+    SUBLANG_SPANISH_PARAGUAY,
+    SUBLANG_SPANISH_BOLIVIA,
+    SUBLANG_SPANISH_EL_SALVADOR,
+    SUBLANG_SPANISH_HONDURAS,
+    SUBLANG_SPANISH_NICARAGUA,
+    SUBLANG_SPANISH_PUERTO_RICO,
+    SUBLANG_SPANISH_US,                      // = 21
+
+    SUBLANG_SWEDISH                             =  1,
+    SUBLANG_SWEDISH_SWEDEN                      =  1,
+    SUBLANG_SWEDISH_FINLAND,                 // =  2
+
+    SUBLANG_SYRIAC                              =  1,
+    SUBLANG_TAJIK_TAJIKISTAN                    =  1,
+    SUBLANG_TAMAZIGHT_ALGERIA_LATIN             =  2,
+    SUBLANG_TAMIL_INDIA                         =  1,
+    SUBLANG_TATAR_RUSSIA                        =  1,
+    SUBLANG_TELUGU_INDIA                        =  1,
+    SUBLANG_THAI_THAILAND                       =  1,
+    SUBLANG_TIBETAN_PRC                         =  1,
+    SUBLANG_TIBETAN_BHUTAN                      =  2,
+    SUBLANG_TIGRIGNA_ERITREA                    =  1,
+    SUBLANG_TSWANA_SOUTH_AFRICA                 =  1,
+    SUBLANG_TURKISH_TURKEY                      =  1,
+    SUBLANG_TURKMEN_TURKMENISTAN                =  1,
+    SUBLANG_UIGHUR_PRC                          =  1,
+    SUBLANG_UKRAINIAN_UKRAINE                   =  1,
+    SUBLANG_UPPER_SORBIAN_GERMANY               =  1,
+
+    SUBLANG_URDU_PAKISTAN                       =  1,
+    SUBLANG_URDU_INDIA,                      // =  2
+
+    SUBLANG_UZBEK_LATIN                         =  1,
+    SUBLANG_UZBEK_CYRILLIC,                  // =  2
+
+    SUBLANG_VIETNAMESE_VIETNAM                  =  1,
+    SUBLANG_WELSH_UNITED_KINGDOM                =  1,
+    SUBLANG_WOLOF_SENEGAL                       =  1,
+    SUBLANG_YORUBA_NIGERIA                      =  1,
+    SUBLANG_XHOSA_SOUTH_AFRICA                  =  1,
+    SUBLANG_YAKUT_RUSSIA                        =  1,
+    SUBLANG_YI_PRC                              =  1,
+    SUBLANG_ZULU_SOUTH_AFRICA                   =  1
+}
+
+// This is not documented on MSDN
+enum NLS_VALID_LOCALE_MASK = 1048575;
+
+// Sorting identifiers
+enum : WORD {
+    SORT_DEFAULT              = 0,
+    SORT_JAPANESE_XJIS        = 0,
+    SORT_JAPANESE_UNICODE     = 1,
+    SORT_CHINESE_BIG5         = 0,
+    SORT_CHINESE_PRCP         = 0,
+    SORT_CHINESE_UNICODE      = 1,
+    SORT_CHINESE_PRC          = 2,
+    SORT_CHINESE_BOPOMOFO     = 3,
+    SORT_KOREAN_KSC           = 0,
+    SORT_KOREAN_UNICODE       = 1,
+    SORT_GERMAN_PHONE_BOOK    = 1,
+    SORT_HUNGARIAN_DEFAULT    = 0,
+    SORT_HUNGARIAN_TECHNICAL  = 1,
+    SORT_GEORGIAN_TRADITIONAL = 0,
+    SORT_GEORGIAN_MODERN      = 1
+}
+
+pure nothrow @nogc {
+    WORD MAKELANGID(/*USHORT*/uint p, /*USHORT*/ uint s) { return cast(WORD)((s << 10) | p); }
+    WORD PRIMARYLANGID(/*WORD*/uint lgid) { return cast(WORD)(lgid & 0x3FF); }
+    WORD SUBLANGID(/*WORD*/uint lgid) { return cast(WORD)(lgid >>> 10); }
+
+    DWORD MAKELCID(/*WORD*/uint lgid, /*WORD*/uint srtid) { return (cast(DWORD) srtid << 16) | cast(DWORD) lgid; }
+    // ???
+    //DWORD MAKESORTLCID(WORD lgid, WORD srtid, WORD ver) { return (MAKELCID(lgid, srtid)) | ((cast(DWORD)ver) << 20); }
+    WORD LANGIDFROMLCID(LCID lcid) { return cast(WORD) lcid; }
+    WORD SORTIDFROMLCID(LCID lcid) { return cast(WORD) ((lcid >>> 16) & 0x0F); }
+    WORD SORTVERSIONFROMLCID(LCID lcid) { return cast(WORD) ((lcid >>> 20) & 0x0F); }
+}
+
+enum WORD LANG_SYSTEM_DEFAULT = (SUBLANG_SYS_DEFAULT << 10) | LANG_NEUTRAL;
+enum WORD LANG_USER_DEFAULT   = (SUBLANG_DEFAULT << 10) | LANG_NEUTRAL;
+enum DWORD LOCALE_NEUTRAL     = (SORT_DEFAULT << 16)
+                                 | (SUBLANG_NEUTRAL << 10) | LANG_NEUTRAL;
+
+// ---
+enum : BYTE {
+    ACL_REVISION    = 2,
+    ACL_REVISION_DS = 4
+}
+
+// These are not documented on MSDN
+enum : BYTE {
+    ACL_REVISION1    = 1,
+    ACL_REVISION2,
+    ACL_REVISION3,
+    ACL_REVISION4 // = 4
+}
+
+enum BYTE
+    MIN_ACL_REVISION = 2,
+    MAX_ACL_REVISION = 4;
+
+/+
+// These aren't necessary for D.
+enum MINCHAR=0x80;
+enum MAXCHAR=0x7f;
+enum MINSHORT=0x8000;
+enum MAXSHORT=0x7fff;
+enum MINLONG=0x80000000;
+enum MAXLONG=0x7fffffff;
+enum MAXBYTE=0xff;
+enum MAXWORD=0xffff;
+enum MAXDWORD=0xffffffff;
++/
+
+// SYSTEM_INFO.dwProcessorType
+enum : DWORD {
+    PROCESSOR_INTEL_386     =   386,
+    PROCESSOR_INTEL_486     =   486,
+    PROCESSOR_INTEL_PENTIUM =   586,
+    PROCESSOR_MIPS_R4000    =  4000,
+    PROCESSOR_ALPHA_21064   = 21064,
+    PROCESSOR_INTEL_IA64    =  2200
+}
+
+// SYSTEM_INFO.wProcessorArchitecture
+enum : WORD {
+    PROCESSOR_ARCHITECTURE_INTEL,
+    PROCESSOR_ARCHITECTURE_MIPS,
+    PROCESSOR_ARCHITECTURE_ALPHA,
+    PROCESSOR_ARCHITECTURE_PPC,
+    PROCESSOR_ARCHITECTURE_SHX,
+    PROCESSOR_ARCHITECTURE_ARM,
+    PROCESSOR_ARCHITECTURE_IA64,
+    PROCESSOR_ARCHITECTURE_ALPHA64,
+    PROCESSOR_ARCHITECTURE_MSIL,
+    PROCESSOR_ARCHITECTURE_AMD64,
+    PROCESSOR_ARCHITECTURE_IA32_ON_WIN64, // = 10
+    PROCESSOR_ARCHITECTURE_UNKNOWN = 0xFFFF
+}
+
+// IsProcessorFeaturePresent()
+enum : DWORD {
+    PF_FLOATING_POINT_PRECISION_ERRATA,
+    PF_FLOATING_POINT_EMULATED,
+    PF_COMPARE_EXCHANGE_DOUBLE,
+    PF_MMX_INSTRUCTIONS_AVAILABLE,
+    PF_PPC_MOVEMEM_64BIT_OK,
+    PF_ALPHA_BYTE_INSTRUCTIONS,
+    PF_XMMI_INSTRUCTIONS_AVAILABLE,
+    PF_3DNOW_INSTRUCTIONS_AVAILABLE,
+    PF_RDTSC_INSTRUCTION_AVAILABLE,
+    PF_PAE_ENABLED,
+    PF_XMMI64_INSTRUCTIONS_AVAILABLE
+}
+
+// MinGW: also in ddk/ntifs.h
+enum : DWORD {
+    FILE_ACTION_ADDED = 1,
+    FILE_ACTION_REMOVED,
+    FILE_ACTION_MODIFIED,
+    FILE_ACTION_RENAMED_OLD_NAME,
+    FILE_ACTION_RENAMED_NEW_NAME,
+    FILE_ACTION_ADDED_STREAM,
+    FILE_ACTION_REMOVED_STREAM,
+    FILE_ACTION_MODIFIED_STREAM,
+    FILE_ACTION_REMOVED_BY_DELETE,
+    FILE_ACTION_ID_NOT_TUNNELLED,
+    FILE_ACTION_TUNNELLED_ID_COLLISION // = 11
+}
+// MinGW: end ntifs.h
+
+enum DWORD
+    HEAP_NO_SERIALIZE             = 0x01,
+    HEAP_GROWABLE                 = 0x02,
+    HEAP_GENERATE_EXCEPTIONS      = 0x04,
+    HEAP_ZERO_MEMORY              = 0x08,
+    HEAP_REALLOC_IN_PLACE_ONLY    = 0x10,
+    HEAP_TAIL_CHECKING_ENABLED    = 0x20,
+    HEAP_FREE_CHECKING_ENABLED    = 0x40,
+    HEAP_DISABLE_COALESCE_ON_FREE = 0x80;
+
+// These are not documented on MSDN
+enum HEAP_CREATE_ALIGN_16       = 0;
+enum HEAP_CREATE_ENABLE_TRACING = 0x020000;
+enum HEAP_MAXIMUM_TAG           = 0x000FFF;
+enum HEAP_PSEUDO_TAG_FLAG       = 0x008000;
+enum HEAP_TAG_SHIFT             = 16;
+// ???
+//MACRO #define HEAP_MAKE_TAG_FLAGS(b,o) ((DWORD)((b)+(o)<<16)))
+
+enum ACCESS_MASK
+    KEY_QUERY_VALUE        = 0x000001,
+    KEY_SET_VALUE          = 0x000002,
+    KEY_CREATE_SUB_KEY     = 0x000004,
+    KEY_ENUMERATE_SUB_KEYS = 0x000008,
+    KEY_NOTIFY             = 0x000010,
+    KEY_CREATE_LINK        = 0x000020,
+    KEY_WRITE              = 0x020006,
+    KEY_EXECUTE            = 0x020019,
+    KEY_READ               = 0x020019,
+    KEY_ALL_ACCESS         = 0x0F003F;
+
+static if (_WIN32_WINNT >= 0x502) {
+enum ACCESS_MASK
+        KEY_WOW64_64KEY    = 0x000100,
+        KEY_WOW64_32KEY    = 0x000200;
+}
+
+enum DWORD
+    REG_WHOLE_HIVE_VOLATILE = 1,
+    REG_REFRESH_HIVE        = 2,
+    REG_NO_LAZY_FLUSH       = 4;
+
+enum DWORD
+    REG_OPTION_RESERVED       =  0,
+    REG_OPTION_NON_VOLATILE   =  0,
+    REG_OPTION_VOLATILE       =  1,
+    REG_OPTION_CREATE_LINK    =  2,
+    REG_OPTION_BACKUP_RESTORE =  4,
+    REG_OPTION_OPEN_LINK      =  8,
+    REG_LEGAL_OPTION          = 15;
+
+enum SECURITY_INFORMATION
+    OWNER_SECURITY_INFORMATION            = 0x00000001,
+    GROUP_SECURITY_INFORMATION            = 0x00000002,
+    DACL_SECURITY_INFORMATION             = 0x00000004,
+    SACL_SECURITY_INFORMATION             = 0x00000008,
+    LABEL_SECURITY_INFORMATION            = 0x00000010,
+    UNPROTECTED_SACL_SECURITY_INFORMATION = 0x10000000,
+    UNPROTECTED_DACL_SECURITY_INFORMATION = 0x20000000,
+    PROTECTED_SACL_SECURITY_INFORMATION   = 0x40000000,
+    PROTECTED_DACL_SECURITY_INFORMATION   = 0x80000000;
+
+enum DWORD MAXIMUM_PROCESSORS = 32;
+
+// VirtualAlloc(), etc
+// -------------------
+
+enum : DWORD {
+    PAGE_NOACCESS          = 0x0001,
+    PAGE_READONLY          = 0x0002,
+    PAGE_READWRITE         = 0x0004,
+    PAGE_WRITECOPY         = 0x0008,
+    PAGE_EXECUTE           = 0x0010,
+    PAGE_EXECUTE_READ      = 0x0020,
+    PAGE_EXECUTE_READWRITE = 0x0040,
+    PAGE_EXECUTE_WRITECOPY = 0x0080,
+    PAGE_GUARD             = 0x0100,
+    PAGE_NOCACHE           = 0x0200
+}
+
+enum : DWORD {
+    MEM_COMMIT      = 0x00001000,
+    MEM_RESERVE     = 0x00002000,
+    MEM_DECOMMIT    = 0x00004000,
+    MEM_RELEASE     = 0x00008000,
+    MEM_FREE        = 0x00010000,
+    MEM_PRIVATE     = 0x00020000,
+    MEM_MAPPED      = 0x00040000,
+    MEM_RESET       = 0x00080000,
+    MEM_TOP_DOWN    = 0x00100000,
+    MEM_WRITE_WATCH = 0x00200000, // MinGW (???): 98/Me
+    MEM_PHYSICAL    = 0x00400000,
+    MEM_4MB_PAGES   = 0x80000000
+}
+
+// MinGW: also in ddk/ntifs.h
+// CreateFileMapping()
+enum DWORD
+    SEC_BASED     = 0x00200000,
+    SEC_NO_CHANGE = 0x00400000,
+    SEC_FILE      = 0x00800000,
+    SEC_IMAGE     = 0x01000000,
+    SEC_VLM       = 0x02000000,
+    SEC_RESERVE   = 0x04000000,
+    SEC_COMMIT    = 0x08000000,
+    SEC_NOCACHE   = 0x10000000,
+    MEM_IMAGE     = SEC_IMAGE;
+// MinGW: end ntifs.h
+
+// ???
+enum ACCESS_MASK
+    SECTION_QUERY       = 0x000001,
+    SECTION_MAP_WRITE   = 0x000002,
+    SECTION_MAP_READ    = 0x000004,
+    SECTION_MAP_EXECUTE = 0x000008,
+    SECTION_EXTEND_SIZE = 0x000010,
+    SECTION_ALL_ACCESS  = 0x0F001F;
+
+// These are not documented on MSDN
+enum MESSAGE_RESOURCE_UNICODE = 1;
+enum RTL_CRITSECT_TYPE        = 0;
+enum RTL_RESOURCE_TYPE        = 1;
+
+// COFF file format
+// ----------------
+
+// IMAGE_FILE_HEADER.Characteristics
+enum WORD
+    IMAGE_FILE_RELOCS_STRIPPED         = 0x0001,
+    IMAGE_FILE_EXECUTABLE_IMAGE        = 0x0002,
+    IMAGE_FILE_LINE_NUMS_STRIPPED      = 0x0004,
+    IMAGE_FILE_LOCAL_SYMS_STRIPPED     = 0x0008,
+    IMAGE_FILE_AGGRESIVE_WS_TRIM       = 0x0010,
+    IMAGE_FILE_LARGE_ADDRESS_AWARE     = 0x0020,
+    IMAGE_FILE_BYTES_REVERSED_LO       = 0x0080,
+    IMAGE_FILE_32BIT_MACHINE           = 0x0100,
+    IMAGE_FILE_DEBUG_STRIPPED          = 0x0200,
+    IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP = 0x0400,
+    IMAGE_FILE_NET_RUN_FROM_SWAP       = 0x0800,
+    IMAGE_FILE_SYSTEM                  = 0x1000,
+    IMAGE_FILE_DLL                     = 0x2000,
+    IMAGE_FILE_UP_SYSTEM_ONLY          = 0x4000,
+    IMAGE_FILE_BYTES_REVERSED_HI       = 0x8000;
+
+// IMAGE_FILE_HEADER.Machine
+enum : WORD {
+    IMAGE_FILE_MACHINE_UNKNOWN   = 0x0000,
+    IMAGE_FILE_MACHINE_I386      = 0x014C,
+    IMAGE_FILE_MACHINE_R3000     = 0x0162,
+    IMAGE_FILE_MACHINE_R4000     = 0x0166,
+    IMAGE_FILE_MACHINE_R10000    = 0x0168,
+    IMAGE_FILE_MACHINE_WCEMIPSV2 = 0x0169,
+    IMAGE_FILE_MACHINE_ALPHA     = 0x0184,
+    IMAGE_FILE_MACHINE_SH3       = 0x01A2,
+    IMAGE_FILE_MACHINE_SH3DSP    = 0x01A3,
+    IMAGE_FILE_MACHINE_SH4       = 0x01A6,
+    IMAGE_FILE_MACHINE_SH5       = 0x01A8,
+    IMAGE_FILE_MACHINE_ARM       = 0x01C0,
+    IMAGE_FILE_MACHINE_THUMB     = 0x01C2,
+    IMAGE_FILE_MACHINE_AM33      = 0x01D3,
+    IMAGE_FILE_MACHINE_POWERPC   = 0x01F0,
+    IMAGE_FILE_MACHINE_POWERPCFP = 0x01F1,
+    IMAGE_FILE_MACHINE_IA64      = 0x0200,
+    IMAGE_FILE_MACHINE_MIPS16    = 0x0266,
+    IMAGE_FILE_MACHINE_MIPSFPU   = 0x0366,
+    IMAGE_FILE_MACHINE_MIPSFPU16 = 0x0466,
+    IMAGE_FILE_MACHINE_EBC       = 0x0EBC,
+    IMAGE_FILE_MACHINE_AMD64     = 0x8664,
+    IMAGE_FILE_MACHINE_M32R      = 0x9041
+}
+
+// ???
+enum  {
+    IMAGE_DOS_SIGNATURE    = 0x5A4D,
+    IMAGE_OS2_SIGNATURE    = 0x454E,
+    IMAGE_OS2_SIGNATURE_LE = 0x454C,
+    IMAGE_VXD_SIGNATURE    = 0x454C,
+    IMAGE_NT_SIGNATURE     = 0x4550
+}
+
+// IMAGE_OPTIONAL_HEADER.Magic
+enum : WORD {
+    IMAGE_NT_OPTIONAL_HDR32_MAGIC = 0x010B,
+    IMAGE_ROM_OPTIONAL_HDR_MAGIC  = 0x0107,
+    IMAGE_NT_OPTIONAL_HDR64_MAGIC = 0x020B
+}
+
+// IMAGE_OPTIONAL_HEADER.Subsystem
+enum : WORD {
+    IMAGE_SUBSYSTEM_UNKNOWN                  =  0,
+    IMAGE_SUBSYSTEM_NATIVE,
+    IMAGE_SUBSYSTEM_WINDOWS_GUI,
+    IMAGE_SUBSYSTEM_WINDOWS_CUI,          // =  3
+    IMAGE_SUBSYSTEM_OS2_CUI                  =  5,
+    IMAGE_SUBSYSTEM_POSIX_CUI                =  7,
+    IMAGE_SUBSYSTEM_NATIVE_WINDOWS,
+    IMAGE_SUBSYSTEM_WINDOWS_CE_GUI,
+    IMAGE_SUBSYSTEM_EFI_APPLICATION,
+    IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER,
+    IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER,
+    IMAGE_SUBSYSTEM_EFI_ROM,
+    IMAGE_SUBSYSTEM_XBOX,                 // = 14
+    IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16
+}
+
+// IMAGE_OPTIONAL_HEADER.DllCharacteristics
+enum WORD
+    IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE         = 0x0040,
+    IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY      = 0x0080,
+    IMAGE_DLL_CHARACTERISTICS_NX_COMPAT            = 0x0100,
+    IMAGE_DLLCHARACTERISTICS_NO_ISOLATION          = 0x0200,
+    IMAGE_DLLCHARACTERISTICS_NO_SEH                = 0x0400,
+    IMAGE_DLLCHARACTERISTICS_NO_BIND               = 0x0800,
+    IMAGE_DLLCHARACTERISTICS_WDM_DRIVER            = 0x2000,
+    IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000;
+
+// ???
+enum IMAGE_SEPARATE_DEBUG_SIGNATURE = 0x4944;
+
+enum size_t
+    IMAGE_NUMBEROF_DIRECTORY_ENTRIES =  16,
+    IMAGE_SIZEOF_ROM_OPTIONAL_HEADER =  56,
+    IMAGE_SIZEOF_STD_OPTIONAL_HEADER =  28,
+    IMAGE_SIZEOF_NT_OPTIONAL_HEADER  = 224,
+    IMAGE_SIZEOF_SHORT_NAME          =   8,
+    IMAGE_SIZEOF_SECTION_HEADER      =  40,
+    IMAGE_SIZEOF_SYMBOL              =  18,
+    IMAGE_SIZEOF_AUX_SYMBOL          =  18,
+    IMAGE_SIZEOF_RELOCATION          =  10,
+    IMAGE_SIZEOF_BASE_RELOCATION     =   8,
+    IMAGE_SIZEOF_LINENUMBER          =   6,
+    IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR  =  60,
+    SIZEOF_RFPO_DATA                 =  16;
+
+PIMAGE_SECTION_HEADER IMAGE_FIRST_SECTION(PIMAGE_NT_HEADERS h) {
+    return cast(PIMAGE_SECTION_HEADER)
+        (&h.OptionalHeader + h.FileHeader.SizeOfOptionalHeader);
+}
+
+// ImageDirectoryEntryToDataEx()
+enum : USHORT {
+    IMAGE_DIRECTORY_ENTRY_EXPORT             =  0,
+    IMAGE_DIRECTORY_ENTRY_IMPORT,
+    IMAGE_DIRECTORY_ENTRY_RESOURCE,
+    IMAGE_DIRECTORY_ENTRY_EXCEPTION,
+    IMAGE_DIRECTORY_ENTRY_SECURITY,
+    IMAGE_DIRECTORY_ENTRY_BASERELOC,
+    IMAGE_DIRECTORY_ENTRY_DEBUG,
+    IMAGE_DIRECTORY_ENTRY_COPYRIGHT,      // =  7
+    IMAGE_DIRECTORY_ENTRY_ARCHITECTURE       =  7,
+    IMAGE_DIRECTORY_ENTRY_GLOBALPTR,
+    IMAGE_DIRECTORY_ENTRY_TLS,
+    IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG,
+    IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT,
+    IMAGE_DIRECTORY_ENTRY_IAT,
+    IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT,
+    IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR, // = 14
+}
+
+// IMAGE_SECTION_HEADER.Characteristics
+enum DWORD
+    IMAGE_SCN_TYPE_REG               = 0x00000000,
+    IMAGE_SCN_TYPE_DSECT             = 0x00000001,
+    IMAGE_SCN_TYPE_NOLOAD            = 0x00000002,
+    IMAGE_SCN_TYPE_GROUP             = 0x00000004,
+    IMAGE_SCN_TYPE_NO_PAD            = 0x00000008,
+    IMAGE_SCN_TYPE_COPY              = 0x00000010,
+    IMAGE_SCN_CNT_CODE               = 0x00000020,
+    IMAGE_SCN_CNT_INITIALIZED_DATA   = 0x00000040,
+    IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080,
+    IMAGE_SCN_LNK_OTHER              = 0x00000100,
+    IMAGE_SCN_LNK_INFO               = 0x00000200,
+    IMAGE_SCN_TYPE_OVER              = 0x00000400,
+    IMAGE_SCN_LNK_REMOVE             = 0x00000800,
+    IMAGE_SCN_LNK_COMDAT             = 0x00001000,
+    IMAGE_SCN_MEM_FARDATA            = 0x00008000,
+    IMAGE_SCN_GPREL                  = 0x00008000,
+    IMAGE_SCN_MEM_PURGEABLE          = 0x00020000,
+    IMAGE_SCN_MEM_16BIT              = 0x00020000,
+    IMAGE_SCN_MEM_LOCKED             = 0x00040000,
+    IMAGE_SCN_MEM_PRELOAD            = 0x00080000,
+    IMAGE_SCN_ALIGN_1BYTES           = 0x00100000,
+    IMAGE_SCN_ALIGN_2BYTES           = 0x00200000,
+    IMAGE_SCN_ALIGN_4BYTES           = 0x00300000,
+    IMAGE_SCN_ALIGN_8BYTES           = 0x00400000,
+    IMAGE_SCN_ALIGN_16BYTES          = 0x00500000,
+    IMAGE_SCN_ALIGN_32BYTES          = 0x00600000,
+    IMAGE_SCN_ALIGN_64BYTES          = 0x00700000,
+    IMAGE_SCN_ALIGN_128BYTES         = 0x00800000,
+    IMAGE_SCN_ALIGN_256BYTES         = 0x00900000,
+    IMAGE_SCN_ALIGN_512BYTES         = 0x00A00000,
+    IMAGE_SCN_ALIGN_1024BYTES        = 0x00B00000,
+    IMAGE_SCN_ALIGN_2048BYTES        = 0x00C00000,
+    IMAGE_SCN_ALIGN_4096BYTES        = 0x00D00000,
+    IMAGE_SCN_ALIGN_8192BYTES        = 0x00E00000,
+    IMAGE_SCN_LNK_NRELOC_OVFL        = 0x01000000,
+    IMAGE_SCN_MEM_DISCARDABLE        = 0x02000000,
+    IMAGE_SCN_MEM_NOT_CACHED         = 0x04000000,
+    IMAGE_SCN_MEM_NOT_PAGED          = 0x08000000,
+    IMAGE_SCN_MEM_SHARED             = 0x10000000,
+    IMAGE_SCN_MEM_EXECUTE            = 0x20000000,
+    IMAGE_SCN_MEM_READ               = 0x40000000,
+    IMAGE_SCN_MEM_WRITE              = 0x80000000;
+
+/*  The following constants are mostlydocumented at
+ *  http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/pecoff.doc
+ *  but don't seem to be defined in the HTML docs.
+ */
+enum : SHORT {
+    IMAGE_SYM_UNDEFINED =  0,
+    IMAGE_SYM_ABSOLUTE  = -1,
+    IMAGE_SYM_DEBUG     = -2
+}
+
+enum : ubyte {
+    IMAGE_SYM_TYPE_NULL,
+    IMAGE_SYM_TYPE_VOID,
+    IMAGE_SYM_TYPE_CHAR,
+    IMAGE_SYM_TYPE_SHORT,
+    IMAGE_SYM_TYPE_INT,
+    IMAGE_SYM_TYPE_LONG,
+    IMAGE_SYM_TYPE_FLOAT,
+    IMAGE_SYM_TYPE_DOUBLE,
+    IMAGE_SYM_TYPE_STRUCT,
+    IMAGE_SYM_TYPE_UNION,
+    IMAGE_SYM_TYPE_ENUM,
+    IMAGE_SYM_TYPE_MOE,
+    IMAGE_SYM_TYPE_BYTE,
+    IMAGE_SYM_TYPE_WORD,
+    IMAGE_SYM_TYPE_UINT,
+    IMAGE_SYM_TYPE_DWORD // = 15
+}
+enum IMAGE_SYM_TYPE_PCODE = 32768; // ???
+
+enum : ubyte {
+    IMAGE_SYM_DTYPE_NULL,
+    IMAGE_SYM_DTYPE_POINTER,
+    IMAGE_SYM_DTYPE_FUNCTION,
+    IMAGE_SYM_DTYPE_ARRAY
+}
+
+enum : BYTE {
+    IMAGE_SYM_CLASS_END_OF_FUNCTION  = 0xFF,
+    IMAGE_SYM_CLASS_NULL             =   0,
+    IMAGE_SYM_CLASS_AUTOMATIC,
+    IMAGE_SYM_CLASS_EXTERNAL,
+    IMAGE_SYM_CLASS_STATIC,
+    IMAGE_SYM_CLASS_REGISTER,
+    IMAGE_SYM_CLASS_EXTERNAL_DEF,
+    IMAGE_SYM_CLASS_LABEL,
+    IMAGE_SYM_CLASS_UNDEFINED_LABEL,
+    IMAGE_SYM_CLASS_MEMBER_OF_STRUCT,
+    IMAGE_SYM_CLASS_ARGUMENT,
+    IMAGE_SYM_CLASS_STRUCT_TAG,
+    IMAGE_SYM_CLASS_MEMBER_OF_UNION,
+    IMAGE_SYM_CLASS_UNION_TAG,
+    IMAGE_SYM_CLASS_TYPE_DEFINITION,
+    IMAGE_SYM_CLASS_UNDEFINED_STATIC,
+    IMAGE_SYM_CLASS_ENUM_TAG,
+    IMAGE_SYM_CLASS_MEMBER_OF_ENUM,
+    IMAGE_SYM_CLASS_REGISTER_PARAM,
+    IMAGE_SYM_CLASS_BIT_FIELD,    // =  18
+    IMAGE_SYM_CLASS_FAR_EXTERNAL     =  68,
+    IMAGE_SYM_CLASS_BLOCK            = 100,
+    IMAGE_SYM_CLASS_FUNCTION,
+    IMAGE_SYM_CLASS_END_OF_STRUCT,
+    IMAGE_SYM_CLASS_FILE,
+    IMAGE_SYM_CLASS_SECTION,
+    IMAGE_SYM_CLASS_WEAK_EXTERNAL,// = 105
+    IMAGE_SYM_CLASS_CLR_TOKEN        = 107
+}
+
+enum : BYTE {
+    IMAGE_COMDAT_SELECT_NODUPLICATES = 1,
+    IMAGE_COMDAT_SELECT_ANY,
+    IMAGE_COMDAT_SELECT_SAME_SIZE,
+    IMAGE_COMDAT_SELECT_EXACT_MATCH,
+    IMAGE_COMDAT_SELECT_ASSOCIATIVE,
+    IMAGE_COMDAT_SELECT_LARGEST,
+    IMAGE_COMDAT_SELECT_NEWEST    // = 7
+}
+
+enum : DWORD {
+    IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY = 1,
+    IMAGE_WEAK_EXTERN_SEARCH_LIBRARY,
+    IMAGE_WEAK_EXTERN_SEARCH_ALIAS
+}
+
+enum : WORD {
+    IMAGE_REL_I386_ABSOLUTE       = 0x0000,
+    IMAGE_REL_I386_DIR16          = 0x0001,
+    IMAGE_REL_I386_REL16          = 0x0002,
+    IMAGE_REL_I386_DIR32          = 0x0006,
+    IMAGE_REL_I386_DIR32NB        = 0x0007,
+    IMAGE_REL_I386_SEG12          = 0x0009,
+    IMAGE_REL_I386_SECTION        = 0x000A,
+    IMAGE_REL_I386_SECREL         = 0x000B,
+    IMAGE_REL_I386_TOKEN          = 0x000C,
+    IMAGE_REL_I386_SECREL7        = 0x000D,
+    IMAGE_REL_I386_REL32          = 0x0014
+}
+
+enum : WORD {
+    IMAGE_REL_AMD64_ABSOLUTE      = 0x0000,
+    IMAGE_REL_AMD64_ADDR64        = 0x0001,
+    IMAGE_REL_AMD64_ADDR32        = 0x0002,
+    IMAGE_REL_AMD64_ADDR32NB      = 0x0003,
+    IMAGE_REL_AMD64_REL32         = 0x0004,
+    IMAGE_REL_AMD64_REL32_1       = 0x0005,
+    IMAGE_REL_AMD64_REL32_2       = 0x0006,
+    IMAGE_REL_AMD64_REL32_3       = 0x0007,
+    IMAGE_REL_AMD64_REL32_4       = 0x0008,
+    IMAGE_REL_AMD64_REL32_5       = 0x0009,
+    IMAGE_REL_AMD64_SECTION       = 0x000A,
+    IMAGE_REL_AMD64_SECREL        = 0x000B,
+    IMAGE_REL_AMD64_SECREL7       = 0x000C,
+    IMAGE_REL_AMD64_TOKEN         = 0x000D,
+    IMAGE_REL_AMD64_SREL32        = 0x000E,
+    IMAGE_REL_AMD64_PAIR          = 0x000F,
+    IMAGE_REL_AMD64_SSPAN32       = 0x0010
+}
+
+enum : WORD {
+    IMAGE_REL_IA64_ABSOLUTE       = 0x0000,
+    IMAGE_REL_IA64_IMM14          = 0x0001,
+    IMAGE_REL_IA64_IMM22          = 0x0002,
+    IMAGE_REL_IA64_IMM64          = 0x0003,
+    IMAGE_REL_IA64_DIR32          = 0x0004,
+    IMAGE_REL_IA64_DIR64          = 0x0005,
+    IMAGE_REL_IA64_PCREL21B       = 0x0006,
+    IMAGE_REL_IA64_PCREL21M       = 0x0007,
+    IMAGE_REL_IA64_PCREL21F       = 0x0008,
+    IMAGE_REL_IA64_GPREL22        = 0x0009,
+    IMAGE_REL_IA64_LTOFF22        = 0x000A,
+    IMAGE_REL_IA64_SECTION        = 0x000B,
+    IMAGE_REL_IA64_SECREL22       = 0x000C,
+    IMAGE_REL_IA64_SECREL64I      = 0x000D,
+    IMAGE_REL_IA64_SECREL32       = 0x000E,
+    IMAGE_REL_IA64_DIR32NB        = 0x0010,
+    IMAGE_REL_IA64_SREL14         = 0x0011,
+    IMAGE_REL_IA64_SREL22         = 0x0012,
+    IMAGE_REL_IA64_SREL32         = 0x0013,
+    IMAGE_REL_IA64_UREL32         = 0x0014,
+    IMAGE_REL_IA64_PCREL60X       = 0x0015,
+    IMAGE_REL_IA64_PCREL60B       = 0x0016,
+    IMAGE_REL_IA64_PCREL60F       = 0x0017,
+    IMAGE_REL_IA64_PCREL60I       = 0x0018,
+    IMAGE_REL_IA64_PCREL60M       = 0x0019,
+    IMAGE_REL_IA64_IMMGPREL64     = 0x001A,
+    IMAGE_REL_IA64_TOKEN          = 0x001B,
+    IMAGE_REL_IA64_GPREL32        = 0x001C,
+    IMAGE_REL_IA64_ADDEND         = 0x001F
+}
+
+enum : WORD {
+    IMAGE_REL_SH3_ABSOLUTE        = 0x0000,
+    IMAGE_REL_SH3_DIRECT16        = 0x0001,
+    IMAGE_REL_SH3_DIRECT32        = 0x0002,
+    IMAGE_REL_SH3_DIRECT8         = 0x0003,
+    IMAGE_REL_SH3_DIRECT8_WORD    = 0x0004,
+    IMAGE_REL_SH3_DIRECT8_LONG    = 0x0005,
+    IMAGE_REL_SH3_DIRECT4         = 0x0006,
+    IMAGE_REL_SH3_DIRECT4_WORD    = 0x0007,
+    IMAGE_REL_SH3_DIRECT4_LONG    = 0x0008,
+    IMAGE_REL_SH3_PCREL8_WORD     = 0x0009,
+    IMAGE_REL_SH3_PCREL8_LONG     = 0x000A,
+    IMAGE_REL_SH3_PCREL12_WORD    = 0x000B,
+    IMAGE_REL_SH3_STARTOF_SECTION = 0x000C,
+    IMAGE_REL_SH3_SIZEOF_SECTION  = 0x000D,
+    IMAGE_REL_SH3_SECTION         = 0x000E,
+    IMAGE_REL_SH3_SECREL          = 0x000F,
+    IMAGE_REL_SH3_DIRECT32_NB     = 0x0010,
+    IMAGE_REL_SH3_GPREL4_LONG     = 0x0011,
+    IMAGE_REL_SH3_TOKEN           = 0x0012,
+    IMAGE_REL_SHM_PCRELPT         = 0x0013,
+    IMAGE_REL_SHM_REFLO           = 0x0014,
+    IMAGE_REL_SHM_REFHALF         = 0x0015,
+    IMAGE_REL_SHM_RELLO           = 0x0016,
+    IMAGE_REL_SHM_RELHALF         = 0x0017,
+    IMAGE_REL_SHM_PAIR            = 0x0018,
+    IMAGE_REL_SHM_NOMODE          = 0x8000
+}
+
+enum : WORD {
+    IMAGE_REL_M32R_ABSOLUTE       = 0x0000,
+    IMAGE_REL_M32R_ADDR32         = 0x0001,
+    IMAGE_REL_M32R_ADDR32NB       = 0x0002,
+    IMAGE_REL_M32R_ADDR24         = 0x0003,
+    IMAGE_REL_M32R_GPREL16        = 0x0004,
+    IMAGE_REL_M32R_PCREL24        = 0x0005,
+    IMAGE_REL_M32R_PCREL16        = 0x0006,
+    IMAGE_REL_M32R_PCREL8         = 0x0007,
+    IMAGE_REL_M32R_REFHALF        = 0x0008,
+    IMAGE_REL_M32R_REFHI          = 0x0009,
+    IMAGE_REL_M32R_REFLO          = 0x000A,
+    IMAGE_REL_M32R_PAIR           = 0x000B,
+    IMAGE_REL_M32R_SECTION        = 0x000C,
+    IMAGE_REL_M32R_SECREL         = 0x000D,
+    IMAGE_REL_M32R_TOKEN          = 0x000E
+}
+
+enum : WORD {
+    IMAGE_REL_MIPS_ABSOLUTE       = 0x0000,
+    IMAGE_REL_MIPS_REFHALF        = 0x0001,
+    IMAGE_REL_MIPS_REFWORD        = 0x0002,
+    IMAGE_REL_MIPS_JMPADDR        = 0x0003,
+    IMAGE_REL_MIPS_REFHI          = 0x0004,
+    IMAGE_REL_MIPS_REFLO          = 0x0005,
+    IMAGE_REL_MIPS_GPREL          = 0x0006,
+    IMAGE_REL_MIPS_LITERAL        = 0x0007,
+    IMAGE_REL_MIPS_SECTION        = 0x000A,
+    IMAGE_REL_MIPS_SECREL         = 0x000B,
+    IMAGE_REL_MIPS_SECRELLO       = 0x000C,
+    IMAGE_REL_MIPS_SECRELHI       = 0x000D,
+    IMAGE_REL_MIPS_JMPADDR16      = 0x0010,
+    IMAGE_REL_MIPS_REFWORDNB      = 0x0022,
+    IMAGE_REL_MIPS_PAIR           = 0x0025
+}
+
+
+enum : WORD {
+    IMAGE_REL_ALPHA_ABSOLUTE,
+    IMAGE_REL_ALPHA_REFLONG,
+    IMAGE_REL_ALPHA_REFQUAD,
+    IMAGE_REL_ALPHA_GPREL32,
+    IMAGE_REL_ALPHA_LITERAL,
+    IMAGE_REL_ALPHA_LITUSE,
+    IMAGE_REL_ALPHA_GPDISP,
+    IMAGE_REL_ALPHA_BRADDR,
+    IMAGE_REL_ALPHA_HINT,
+    IMAGE_REL_ALPHA_INLINE_REFLONG,
+    IMAGE_REL_ALPHA_REFHI,
+    IMAGE_REL_ALPHA_REFLO,
+    IMAGE_REL_ALPHA_PAIR,
+    IMAGE_REL_ALPHA_MATCH,
+    IMAGE_REL_ALPHA_SECTION,
+    IMAGE_REL_ALPHA_SECREL,
+    IMAGE_REL_ALPHA_REFLONGNB,
+    IMAGE_REL_ALPHA_SECRELLO,
+    IMAGE_REL_ALPHA_SECRELHI // = 18
+}
+
+enum : WORD {
+    IMAGE_REL_PPC_ABSOLUTE,
+    IMAGE_REL_PPC_ADDR64,
+    IMAGE_REL_PPC_ADDR32,
+    IMAGE_REL_PPC_ADDR24,
+    IMAGE_REL_PPC_ADDR16,
+    IMAGE_REL_PPC_ADDR14,
+    IMAGE_REL_PPC_REL24,
+    IMAGE_REL_PPC_REL14,
+    IMAGE_REL_PPC_TOCREL16,
+    IMAGE_REL_PPC_TOCREL14,
+    IMAGE_REL_PPC_ADDR32NB,
+    IMAGE_REL_PPC_SECREL,
+    IMAGE_REL_PPC_SECTION,
+    IMAGE_REL_PPC_IFGLUE,
+    IMAGE_REL_PPC_IMGLUE,
+    IMAGE_REL_PPC_SECREL16,
+    IMAGE_REL_PPC_REFHI,
+    IMAGE_REL_PPC_REFLO,
+    IMAGE_REL_PPC_PAIR // = 18
+}
+
+// ???
+enum IMAGE_REL_PPC_TYPEMASK = 0x00FF;
+enum IMAGE_REL_PPC_NEG      = 0x0100;
+enum IMAGE_REL_PPC_BRTAKEN  = 0x0200;
+enum IMAGE_REL_PPC_BRNTAKEN = 0x0400;
+enum IMAGE_REL_PPC_TOCDEFN  = 0x0800;
+
+enum {
+    IMAGE_REL_BASED_ABSOLUTE,
+    IMAGE_REL_BASED_HIGH,
+    IMAGE_REL_BASED_LOW,
+    IMAGE_REL_BASED_HIGHLOW,
+    IMAGE_REL_BASED_HIGHADJ,
+    IMAGE_REL_BASED_MIPS_JMPADDR
+}
+// End of constants documented in pecoff.doc
+
+enum size_t IMAGE_ARCHIVE_START_SIZE = 8;
+
+const TCHAR[]
+    IMAGE_ARCHIVE_START            = "!<arch>\n",
+    IMAGE_ARCHIVE_END              = "`\n",
+    IMAGE_ARCHIVE_PAD              = "\n",
+    IMAGE_ARCHIVE_LINKER_MEMBER    = "/               ",
+    IMAGE_ARCHIVE_LONGNAMES_MEMBER = "//              ";
+
+enum IMAGE_ORDINAL_FLAG32 = 0x80000000;
+
+ulong IMAGE_ORDINAL64(ulong Ordinal) { return Ordinal & 0xFFFF; }
+uint IMAGE_ORDINAL32(uint Ordinal)   { return Ordinal & 0xFFFF; }
+
+bool IMAGE_SNAP_BY_ORDINAL32(uint Ordinal) {
+    return (Ordinal & IMAGE_ORDINAL_FLAG32) != 0;
+}
+
+enum ulong IMAGE_ORDINAL_FLAG64 = 0x8000000000000000;
+
+bool IMAGE_SNAP_BY_ORDINAL64(ulong Ordinal) {
+    return (Ordinal & IMAGE_ORDINAL_FLAG64) != 0;
+}
+
+// ???
+enum IMAGE_RESOURCE_NAME_IS_STRING    = 0x80000000;
+enum IMAGE_RESOURCE_DATA_IS_DIRECTORY = 0x80000000;
+
+enum : DWORD {
+    IMAGE_DEBUG_TYPE_UNKNOWN,
+    IMAGE_DEBUG_TYPE_COFF,
+    IMAGE_DEBUG_TYPE_CODEVIEW,
+    IMAGE_DEBUG_TYPE_FPO,
+    IMAGE_DEBUG_TYPE_MISC,
+    IMAGE_DEBUG_TYPE_EXCEPTION,
+    IMAGE_DEBUG_TYPE_FIXUP,
+    IMAGE_DEBUG_TYPE_OMAP_TO_SRC,
+    IMAGE_DEBUG_TYPE_OMAP_FROM_SRC,
+    IMAGE_DEBUG_TYPE_BORLAND // = 9
+}
+
+enum : ubyte {
+    FRAME_FPO,
+    FRAME_TRAP,
+    FRAME_TSS,
+    FRAME_NONFPO
+}
+
+// ???
+enum IMAGE_DEBUG_MISC_EXENAME = 1;
+
+// ???
+enum N_BTMASK = 0x000F;
+enum N_TMASK  = 0x0030;
+enum N_TMASK1 = 0x00C0;
+enum N_TMASK2 = 0x00F0;
+enum N_BTSHFT = 4;
+enum N_TSHIFT = 2;
+
+enum int
+    IS_TEXT_UNICODE_ASCII16            = 0x0001,
+    IS_TEXT_UNICODE_STATISTICS         = 0x0002,
+    IS_TEXT_UNICODE_CONTROLS           = 0x0004,
+    IS_TEXT_UNICODE_SIGNATURE          = 0x0008,
+    IS_TEXT_UNICODE_REVERSE_ASCII16    = 0x0010,
+    IS_TEXT_UNICODE_REVERSE_STATISTICS = 0x0020,
+    IS_TEXT_UNICODE_REVERSE_CONTROLS   = 0x0040,
+    IS_TEXT_UNICODE_REVERSE_SIGNATURE  = 0x0080,
+    IS_TEXT_UNICODE_ILLEGAL_CHARS      = 0x0100,
+    IS_TEXT_UNICODE_ODD_LENGTH         = 0x0200,
+    IS_TEXT_UNICODE_NULL_BYTES         = 0x1000,
+    IS_TEXT_UNICODE_UNICODE_MASK       = 0x000F,
+    IS_TEXT_UNICODE_REVERSE_MASK       = 0x00F0,
+    IS_TEXT_UNICODE_NOT_UNICODE_MASK   = 0x0F00,
+    IS_TEXT_UNICODE_NOT_ASCII_MASK     = 0xF000;
+
+enum DWORD
+    SERVICE_KERNEL_DRIVER       = 0x0001,
+    SERVICE_FILE_SYSTEM_DRIVER  = 0x0002,
+    SERVICE_ADAPTER             = 0x0004,
+    SERVICE_RECOGNIZER_DRIVER   = 0x0008,
+    SERVICE_WIN32_OWN_PROCESS   = 0x0010,
+    SERVICE_WIN32_SHARE_PROCESS = 0x0020,
+    SERVICE_INTERACTIVE_PROCESS = 0x0100,
+    SERVICE_DRIVER              = 0x000B,
+    SERVICE_WIN32               = 0x0030,
+    SERVICE_TYPE_ALL            = 0x013F;
+
+enum : DWORD {
+    SERVICE_BOOT_START   = 0,
+    SERVICE_SYSTEM_START = 1,
+    SERVICE_AUTO_START   = 2,
+    SERVICE_DEMAND_START = 3,
+    SERVICE_DISABLED     = 4
+}
+
+enum : DWORD {
+    SERVICE_ERROR_IGNORE   = 0,
+    SERVICE_ERROR_NORMAL   = 1,
+    SERVICE_ERROR_SEVERE   = 2,
+    SERVICE_ERROR_CRITICAL = 3
+}
+
+
+enum uint
+    SE_OWNER_DEFAULTED          = 0x0001,
+    SE_GROUP_DEFAULTED          = 0x0002,
+    SE_DACL_PRESENT             = 0x0004,
+    SE_DACL_DEFAULTED           = 0x0008,
+    SE_SACL_PRESENT             = 0x0010,
+    SE_SACL_DEFAULTED           = 0x0020,
+    SE_DACL_AUTO_INHERIT_REQ    = 0x0100,
+    SE_SACL_AUTO_INHERIT_REQ    = 0x0200,
+    SE_DACL_AUTO_INHERITED      = 0x0400,
+    SE_SACL_AUTO_INHERITED      = 0x0800,
+    SE_DACL_PROTECTED           = 0x1000,
+    SE_SACL_PROTECTED           = 0x2000,
+    SE_SELF_RELATIVE            = 0x8000;
+
+enum SECURITY_IMPERSONATION_LEVEL {
+    SecurityAnonymous,
+    SecurityIdentification,
+    SecurityImpersonation,
+    SecurityDelegation
+}
+alias SECURITY_IMPERSONATION_LEVEL* PSECURITY_IMPERSONATION_LEVEL;
+
+alias BOOLEAN SECURITY_CONTEXT_TRACKING_MODE;
+alias BOOLEAN* PSECURITY_CONTEXT_TRACKING_MODE;
+
+enum size_t SECURITY_DESCRIPTOR_MIN_LENGTH = 20;
+
+enum DWORD
+    SECURITY_DESCRIPTOR_REVISION  = 1,
+    SECURITY_DESCRIPTOR_REVISION1 = 1;
+
+enum DWORD
+    SE_PRIVILEGE_ENABLED_BY_DEFAULT = 0x00000001,
+    SE_PRIVILEGE_ENABLED            = 0x00000002,
+    SE_PRIVILEGE_USED_FOR_ACCESS    = 0x80000000;
+
+enum DWORD PRIVILEGE_SET_ALL_NECESSARY = 1;
+
+enum SECURITY_IMPERSONATION_LEVEL
+    SECURITY_MAX_IMPERSONATION_LEVEL = SECURITY_IMPERSONATION_LEVEL.SecurityDelegation,
+    DEFAULT_IMPERSONATION_LEVEL      = SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation;
+
+enum BOOLEAN
+    SECURITY_DYNAMIC_TRACKING = true,
+    SECURITY_STATIC_TRACKING  = false;
+
+// also in ddk/ntifs.h
+enum DWORD
+    TOKEN_ASSIGN_PRIMARY    = 0x0001,
+    TOKEN_DUPLICATE         = 0x0002,
+    TOKEN_IMPERSONATE       = 0x0004,
+    TOKEN_QUERY             = 0x0008,
+    TOKEN_QUERY_SOURCE      = 0x0010,
+    TOKEN_ADJUST_PRIVILEGES = 0x0020,
+    TOKEN_ADJUST_GROUPS     = 0x0040,
+    TOKEN_ADJUST_DEFAULT    = 0x0080,
+
+    TOKEN_ALL_ACCESS        = STANDARD_RIGHTS_REQUIRED
+                              | TOKEN_ASSIGN_PRIMARY
+                              | TOKEN_DUPLICATE
+                              | TOKEN_IMPERSONATE
+                              | TOKEN_QUERY
+                              | TOKEN_QUERY_SOURCE
+                              | TOKEN_ADJUST_PRIVILEGES
+                              | TOKEN_ADJUST_GROUPS
+                              | TOKEN_ADJUST_DEFAULT,
+    TOKEN_READ              = STANDARD_RIGHTS_READ | TOKEN_QUERY,
+    TOKEN_WRITE             = STANDARD_RIGHTS_WRITE
+                              | TOKEN_ADJUST_PRIVILEGES
+                              | TOKEN_ADJUST_GROUPS
+                              | TOKEN_ADJUST_DEFAULT,
+    TOKEN_EXECUTE           = STANDARD_RIGHTS_EXECUTE;
+
+enum size_t TOKEN_SOURCE_LENGTH = 8;
+// end ddk/ntifs.h
+
+enum : DWORD {
+    DLL_PROCESS_DETACH,
+    DLL_PROCESS_ATTACH,
+    DLL_THREAD_ATTACH,
+    DLL_THREAD_DETACH
+}
+
+enum : DWORD {
+    DBG_CONTINUE              = 0x00010002,
+    DBG_TERMINATE_THREAD      = 0x40010003,
+    DBG_TERMINATE_PROCESS     = 0x40010004,
+    DBG_CONTROL_C             = 0x40010005,
+    DBG_CONTROL_BREAK         = 0x40010008,
+    DBG_EXCEPTION_NOT_HANDLED = 0x80010001
+}
+
+enum : DWORD {
+    TAPE_ABSOLUTE_POSITION,
+    TAPE_LOGICAL_POSITION,
+    TAPE_PSEUDO_LOGICAL_POSITION
+}
+
+enum : DWORD {
+    TAPE_REWIND,
+    TAPE_ABSOLUTE_BLOCK,
+    TAPE_LOGICAL_BLOCK,
+    TAPE_PSEUDO_LOGICAL_BLOCK,
+    TAPE_SPACE_END_OF_DATA,
+    TAPE_SPACE_RELATIVE_BLOCKS,
+    TAPE_SPACE_FILEMARKS,
+    TAPE_SPACE_SEQUENTIAL_FMKS,
+    TAPE_SPACE_SETMARKS,
+    TAPE_SPACE_SEQUENTIAL_SMKS
+}
+
+enum DWORD
+    TAPE_DRIVE_FIXED            = 0x00000001,
+    TAPE_DRIVE_SELECT           = 0x00000002,
+    TAPE_DRIVE_INITIATOR        = 0x00000004,
+    TAPE_DRIVE_ERASE_SHORT      = 0x00000010,
+    TAPE_DRIVE_ERASE_LONG       = 0x00000020,
+    TAPE_DRIVE_ERASE_BOP_ONLY   = 0x00000040,
+    TAPE_DRIVE_ERASE_IMMEDIATE  = 0x00000080,
+    TAPE_DRIVE_TAPE_CAPACITY    = 0x00000100,
+    TAPE_DRIVE_TAPE_REMAINING   = 0x00000200,
+    TAPE_DRIVE_FIXED_BLOCK      = 0x00000400,
+    TAPE_DRIVE_VARIABLE_BLOCK   = 0x00000800,
+    TAPE_DRIVE_WRITE_PROTECT    = 0x00001000,
+    TAPE_DRIVE_EOT_WZ_SIZE      = 0x00002000,
+    TAPE_DRIVE_ECC              = 0x00010000,
+    TAPE_DRIVE_COMPRESSION      = 0x00020000,
+    TAPE_DRIVE_PADDING          = 0x00040000,
+    TAPE_DRIVE_REPORT_SMKS      = 0x00080000,
+    TAPE_DRIVE_GET_ABSOLUTE_BLK = 0x00100000,
+    TAPE_DRIVE_GET_LOGICAL_BLK  = 0x00200000,
+    TAPE_DRIVE_SET_EOT_WZ_SIZE  = 0x00400000,
+    TAPE_DRIVE_EJECT_MEDIA      = 0x01000000,
+    TAPE_DRIVE_CLEAN_REQUESTS   = 0x02000000,
+    TAPE_DRIVE_SET_CMP_BOP_ONLY = 0x04000000,
+    TAPE_DRIVE_RESERVED_BIT     = 0x80000000;
+
+enum DWORD
+    TAPE_DRIVE_LOAD_UNLOAD      = 0x80000001,
+    TAPE_DRIVE_TENSION          = 0x80000002,
+    TAPE_DRIVE_LOCK_UNLOCK      = 0x80000004,
+    TAPE_DRIVE_REWIND_IMMEDIATE = 0x80000008,
+    TAPE_DRIVE_SET_BLOCK_SIZE   = 0x80000010,
+    TAPE_DRIVE_LOAD_UNLD_IMMED  = 0x80000020,
+    TAPE_DRIVE_TENSION_IMMED    = 0x80000040,
+    TAPE_DRIVE_LOCK_UNLK_IMMED  = 0x80000080,
+    TAPE_DRIVE_SET_ECC          = 0x80000100,
+    TAPE_DRIVE_SET_COMPRESSION  = 0x80000200,
+    TAPE_DRIVE_SET_PADDING      = 0x80000400,
+    TAPE_DRIVE_SET_REPORT_SMKS  = 0x80000800,
+    TAPE_DRIVE_ABSOLUTE_BLK     = 0x80001000,
+    TAPE_DRIVE_ABS_BLK_IMMED    = 0x80002000,
+    TAPE_DRIVE_LOGICAL_BLK      = 0x80004000,
+    TAPE_DRIVE_LOG_BLK_IMMED    = 0x80008000,
+    TAPE_DRIVE_END_OF_DATA      = 0x80010000,
+    TAPE_DRIVE_RELATIVE_BLKS    = 0x80020000,
+    TAPE_DRIVE_FILEMARKS        = 0x80040000,
+    TAPE_DRIVE_SEQUENTIAL_FMKS  = 0x80080000,
+    TAPE_DRIVE_SETMARKS         = 0x80100000,
+    TAPE_DRIVE_SEQUENTIAL_SMKS  = 0x80200000,
+    TAPE_DRIVE_REVERSE_POSITION = 0x80400000,
+    TAPE_DRIVE_SPACE_IMMEDIATE  = 0x80800000,
+    TAPE_DRIVE_WRITE_SETMARKS   = 0x81000000,
+    TAPE_DRIVE_WRITE_FILEMARKS  = 0x82000000,
+    TAPE_DRIVE_WRITE_SHORT_FMKS = 0x84000000,
+    TAPE_DRIVE_WRITE_LONG_FMKS  = 0x88000000,
+    TAPE_DRIVE_WRITE_MARK_IMMED = 0x90000000,
+    TAPE_DRIVE_FORMAT           = 0xA0000000,
+    TAPE_DRIVE_FORMAT_IMMEDIATE = 0xC0000000,
+    TAPE_DRIVE_HIGH_FEATURES    = 0x80000000;
+
+enum : DWORD {
+    TAPE_FIXED_PARTITIONS     = 0,
+    TAPE_SELECT_PARTITIONS    = 1,
+    TAPE_INITIATOR_PARTITIONS = 2
+}
+
+enum : DWORD {
+    TAPE_SETMARKS,
+    TAPE_FILEMARKS,
+    TAPE_SHORT_FILEMARKS,
+    TAPE_LONG_FILEMARKS
+}
+
+enum : DWORD {
+    TAPE_ERASE_SHORT,
+    TAPE_ERASE_LONG
+}
+
+enum : DWORD {
+    TAPE_LOAD,
+    TAPE_UNLOAD,
+    TAPE_TENSION,
+    TAPE_LOCK,
+    TAPE_UNLOCK,
+    TAPE_FORMAT
+}
+
+enum : ULONG32 {
+    VER_PLATFORM_WIN32s,
+    VER_PLATFORM_WIN32_WINDOWS,
+    VER_PLATFORM_WIN32_NT
+}
+
+enum : UCHAR {
+    VER_NT_WORKSTATION = 1,
+    VER_NT_DOMAIN_CONTROLLER,
+    VER_NT_SERVER
+}
+
+enum USHORT
+    VER_SUITE_SMALLBUSINESS            = 0x0001,
+    VER_SUITE_ENTERPRISE               = 0x0002,
+    VER_SUITE_BACKOFFICE               = 0x0004,
+    VER_SUITE_TERMINAL                 = 0x0010,
+    VER_SUITE_SMALLBUSINESS_RESTRICTED = 0x0020,
+    VER_SUITE_EMBEDDEDNT               = 0x0040,
+    VER_SUITE_DATACENTER               = 0x0080,
+    VER_SUITE_SINGLEUSERTS             = 0x0100,
+    VER_SUITE_PERSONAL                 = 0x0200,
+    VER_SUITE_BLADE                    = 0x0400,
+    VER_SUITE_STORAGE_SERVER           = 0x2000,
+    VER_SUITE_COMPUTE_SERVER           = 0x4000;
+
+enum ULONG
+    WT_EXECUTEDEFAULT            = 0x00000000,
+    WT_EXECUTEINIOTHREAD         = 0x00000001,
+    WT_EXECUTEINWAITTHREAD       = 0x00000004,
+    WT_EXECUTEONLYONCE           = 0x00000008,
+    WT_EXECUTELONGFUNCTION       = 0x00000010,
+    WT_EXECUTEINTIMERTHREAD      = 0x00000020,
+    WT_EXECUTEINPERSISTENTTHREAD = 0x00000080,
+    WT_TRANSFER_IMPERSONATION    = 0x00000100;
+
+static if (_WIN32_WINNT >= 0x500) {
+enum DWORD
+        VER_MINORVERSION     = 0x01,
+        VER_MAJORVERSION     = 0x02,
+        VER_BUILDNUMBER      = 0x04,
+        VER_PLATFORMID       = 0x08,
+        VER_SERVICEPACKMINOR = 0x10,
+        VER_SERVICEPACKMAJOR = 0x20,
+        VER_SUITENAME        = 0x40,
+        VER_PRODUCT_TYPE     = 0x80;
+
+    enum : DWORD {
+        VER_EQUAL = 1,
+        VER_GREATER,
+        VER_GREATER_EQUAL,
+        VER_LESS,
+        VER_LESS_EQUAL,
+        VER_AND,
+        VER_OR // = 7
+    }
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum : ULONG {
+        ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION       = 1,
+        ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
+        ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION,
+        ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION,
+        ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION,
+        ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION,
+        ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION, // = 7
+        ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES             = 9
+    }
+}
+
+// Macros
+BYTE BTYPE(BYTE x) { return cast(BYTE) (x & N_BTMASK); }
+bool ISPTR(uint x) { return (x & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT); }
+bool ISFCN(uint x) { return (x & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT); }
+bool ISARY(uint x) { return (x & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY << N_BTSHFT); }
+bool ISTAG(uint x) {
+    return x == IMAGE_SYM_CLASS_STRUCT_TAG
+        || x == IMAGE_SYM_CLASS_UNION_TAG
+        || x == IMAGE_SYM_CLASS_ENUM_TAG;
+}
+uint INCREF(uint x) {
+    return ((x & ~N_BTMASK) << N_TSHIFT) | (IMAGE_SYM_DTYPE_POINTER << N_BTSHFT)
+      | (x & N_BTMASK);
+}
+uint DECREF(uint x) { return ((x >>> N_TSHIFT) & ~N_BTMASK) | (x & N_BTMASK); }
+
+enum DWORD TLS_MINIMUM_AVAILABLE = 64;
+
+enum ULONG
+    IO_REPARSE_TAG_RESERVED_ZERO  = 0,
+    IO_REPARSE_TAG_RESERVED_ONE   = 1,
+    IO_REPARSE_TAG_RESERVED_RANGE = IO_REPARSE_TAG_RESERVED_ONE,
+    IO_REPARSE_TAG_SYMBOLIC_LINK  = IO_REPARSE_TAG_RESERVED_ZERO,
+    IO_REPARSE_TAG_MOUNT_POINT    = 0xA0000003,
+    IO_REPARSE_TAG_SYMLINK        = 0xA000000C,
+    IO_REPARSE_TAG_VALID_VALUES   = 0xE000FFFF;
+
+/*  Although these are semantically boolean, they are documented and
+ *  implemented to return ULONG; this behaviour is preserved for compatibility
+ */
+ULONG IsReparseTagMicrosoft(ULONG x)     { return x & 0x80000000; }
+ULONG IsReparseTagHighLatency(ULONG x)   { return x & 0x40000000; }
+ULONG IsReparseTagNameSurrogate(ULONG x) { return x & 0x20000000; }
+
+bool IsReparseTagValid(ULONG x) {
+    return !(x & ~IO_REPARSE_TAG_VALID_VALUES) && (x > IO_REPARSE_TAG_RESERVED_RANGE);
+}
+
+// Doesn't seem to make sense, but anyway....
+ULONG WT_SET_MAX_THREADPOOL_THREADS(ref ULONG Flags, ushort Limit) {
+    return Flags |= Limit << 16;
+}
+
+import core.sys.windows.basetyps;
+/* also in core.sys.windows.basetyps
+struct GUID {
+    uint  Data1;
+    ushort Data2;
+    ushort Data3;
+    ubyte  Data4[8];
+}
+alias GUID* REFGUID, LPGUID;
+*/
+
+struct GENERIC_MAPPING {
+    ACCESS_MASK GenericRead;
+    ACCESS_MASK GenericWrite;
+    ACCESS_MASK GenericExecute;
+    ACCESS_MASK GenericAll;
+}
+alias GENERIC_MAPPING* PGENERIC_MAPPING;
+
+struct ACE_HEADER {
+    BYTE AceType;
+    BYTE AceFlags;
+    WORD AceSize;
+}
+alias ACE_HEADER* PACE_HEADER;
+
+struct ACCESS_ALLOWED_ACE {
+    ACE_HEADER  Header;
+    ACCESS_MASK Mask;
+    DWORD       SidStart;
+}
+alias ACCESS_ALLOWED_ACE* PACCESS_ALLOWED_ACE;
+
+struct ACCESS_DENIED_ACE {
+    ACE_HEADER  Header;
+    ACCESS_MASK Mask;
+    DWORD       SidStart;
+}
+alias ACCESS_DENIED_ACE* PACCESS_DENIED_ACE;
+
+struct SYSTEM_AUDIT_ACE {
+    ACE_HEADER  Header;
+    ACCESS_MASK Mask;
+    DWORD       SidStart;
+}
+alias SYSTEM_AUDIT_ACE *PSYSTEM_AUDIT_ACE;
+
+struct SYSTEM_ALARM_ACE {
+    ACE_HEADER  Header;
+    ACCESS_MASK Mask;
+    DWORD       SidStart;
+}
+alias SYSTEM_ALARM_ACE* PSYSTEM_ALARM_ACE;
+
+struct ACCESS_ALLOWED_OBJECT_ACE {
+    ACE_HEADER  Header;
+    ACCESS_MASK Mask;
+    DWORD       Flags;
+    GUID        ObjectType;
+    GUID        InheritedObjectType;
+    DWORD       SidStart;
+}
+alias ACCESS_ALLOWED_OBJECT_ACE* PACCESS_ALLOWED_OBJECT_ACE;
+
+struct ACCESS_DENIED_OBJECT_ACE {
+    ACE_HEADER  Header;
+    ACCESS_MASK Mask;
+    DWORD       Flags;
+    GUID        ObjectType;
+    GUID        InheritedObjectType;
+    DWORD       SidStart;
+}
+alias ACCESS_DENIED_OBJECT_ACE* PACCESS_DENIED_OBJECT_ACE;
+
+struct SYSTEM_AUDIT_OBJECT_ACE {
+    ACE_HEADER  Header;
+    ACCESS_MASK Mask;
+    DWORD       Flags;
+    GUID        ObjectType;
+    GUID        InheritedObjectType;
+    DWORD       SidStart;
+}
+alias SYSTEM_AUDIT_OBJECT_ACE* PSYSTEM_AUDIT_OBJECT_ACE;
+
+struct SYSTEM_ALARM_OBJECT_ACE {
+    ACE_HEADER  Header;
+    ACCESS_MASK Mask;
+    DWORD       Flags;
+    GUID        ObjectType;
+    GUID        InheritedObjectType;
+    DWORD       SidStart;
+}
+alias SYSTEM_ALARM_OBJECT_ACE* PSYSTEM_ALARM_OBJECT_ACE;
+
+struct ACL {
+    BYTE AclRevision;
+    BYTE Sbz1;
+    WORD AclSize;
+    WORD AceCount;
+    WORD Sbz2;
+}
+alias ACL* PACL;
+
+struct ACL_REVISION_INFORMATION {
+    DWORD AclRevision;
+}
+
+struct ACL_SIZE_INFORMATION {
+    DWORD AceCount;
+    DWORD AclBytesInUse;
+    DWORD AclBytesFree;
+}
+
+version (X86) {
+    // ???
+enum SIZE_OF_80387_REGISTERS     = 80;
+enum CONTEXT_i386                = 0x010000;
+enum CONTEXT_i486                = 0x010000;
+enum CONTEXT_CONTROL             = CONTEXT_i386 | 0x01;
+enum CONTEXT_INTEGER             = CONTEXT_i386 | 0x02;
+enum CONTEXT_SEGMENTS            = CONTEXT_i386 | 0x04;
+enum CONTEXT_FLOATING_POINT      = CONTEXT_i386 | 0x08;
+enum CONTEXT_DEBUG_REGISTERS     = CONTEXT_i386 | 0x10;
+enum CONTEXT_EXTENDED_REGISTERS  = CONTEXT_i386 | 0x20;
+enum CONTEXT_FULL                = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS;
+enum CONTEXT_ALL                 = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS |
+                                        CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS |
+                                        CONTEXT_EXTENDED_REGISTERS;
+
+enum MAXIMUM_SUPPORTED_EXTENSION = 512;
+
+    struct FLOATING_SAVE_AREA {
+        DWORD    ControlWord;
+        DWORD    StatusWord;
+        DWORD    TagWord;
+        DWORD    ErrorOffset;
+        DWORD    ErrorSelector;
+        DWORD    DataOffset;
+        DWORD    DataSelector;
+        BYTE[80] RegisterArea;
+        DWORD    Cr0NpxState;
+    }
+
+    struct CONTEXT {
+        DWORD ContextFlags;
+        DWORD Dr0;
+        DWORD Dr1;
+        DWORD Dr2;
+        DWORD Dr3;
+        DWORD Dr6;
+        DWORD Dr7;
+        FLOATING_SAVE_AREA FloatSave;
+        DWORD SegGs;
+        DWORD SegFs;
+        DWORD SegEs;
+        DWORD SegDs;
+        DWORD Edi;
+        DWORD Esi;
+        DWORD Ebx;
+        DWORD Edx;
+        DWORD Ecx;
+        DWORD Eax;
+        DWORD Ebp;
+        DWORD Eip;
+        DWORD SegCs;
+        DWORD EFlags;
+        DWORD Esp;
+        DWORD SegSs;
+        BYTE[MAXIMUM_SUPPORTED_EXTENSION] ExtendedRegisters;
+    }
+
+} else version(X86_64)
+{
+enum CONTEXT_AMD64 = 0x100000;
+
+enum CONTEXT_CONTROL         = (CONTEXT_AMD64 | 0x1L);
+enum CONTEXT_INTEGER         = (CONTEXT_AMD64 | 0x2L);
+enum CONTEXT_SEGMENTS        = (CONTEXT_AMD64 | 0x4L);
+enum CONTEXT_FLOATING_POINT  = (CONTEXT_AMD64 | 0x8L);
+enum CONTEXT_DEBUG_REGISTERS = (CONTEXT_AMD64 | 0x10L);
+
+enum CONTEXT_FULL = (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT);
+enum CONTEXT_ALL  = (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS);
+
+enum CONTEXT_EXCEPTION_ACTIVE    = 0x8000000;
+enum CONTEXT_SERVICE_ACTIVE      = 0x10000000;
+enum CONTEXT_EXCEPTION_REQUEST   = 0x40000000;
+enum CONTEXT_EXCEPTION_REPORTING = 0x80000000;
+
+enum INITIAL_MXCSR = 0x1f80;
+enum INITIAL_FPCSR = 0x027f;
+
+    align(16) struct M128A
+    {
+        ULONGLONG Low;
+        LONGLONG High;
+    }
+    alias M128A* PM128A;
+
+    struct XMM_SAVE_AREA32
+    {
+        WORD ControlWord;
+        WORD StatusWord;
+        BYTE TagWord;
+        BYTE Reserved1;
+        WORD ErrorOpcode;
+        DWORD ErrorOffset;
+        WORD ErrorSelector;
+        WORD Reserved2;
+        DWORD DataOffset;
+        WORD DataSelector;
+        WORD Reserved3;
+        DWORD MxCsr;
+        DWORD MxCsr_Mask;
+        M128A[8] FloatRegisters;
+        M128A[16] XmmRegisters;
+        BYTE[96] Reserved4;
+    }
+    alias XMM_SAVE_AREA32 PXMM_SAVE_AREA32;
+enum LEGACY_SAVE_AREA_LENGTH = XMM_SAVE_AREA32.sizeof;
+
+    align(16) struct CONTEXT
+    {
+        DWORD64 P1Home;
+        DWORD64 P2Home;
+        DWORD64 P3Home;
+        DWORD64 P4Home;
+        DWORD64 P5Home;
+        DWORD64 P6Home;
+        DWORD ContextFlags;
+        DWORD MxCsr;
+        WORD SegCs;
+        WORD SegDs;
+        WORD SegEs;
+        WORD SegFs;
+        WORD SegGs;
+        WORD SegSs;
+        DWORD EFlags;
+        DWORD64 Dr0;
+        DWORD64 Dr1;
+        DWORD64 Dr2;
+        DWORD64 Dr3;
+        DWORD64 Dr6;
+        DWORD64 Dr7;
+        DWORD64 Rax;
+        DWORD64 Rcx;
+        DWORD64 Rdx;
+        DWORD64 Rbx;
+        DWORD64 Rsp;
+        DWORD64 Rbp;
+        DWORD64 Rsi;
+        DWORD64 Rdi;
+        DWORD64 R8;
+        DWORD64 R9;
+        DWORD64 R10;
+        DWORD64 R11;
+        DWORD64 R12;
+        DWORD64 R13;
+        DWORD64 R14;
+        DWORD64 R15;
+        DWORD64 Rip;
+        union
+        {
+            XMM_SAVE_AREA32 FltSave;
+            XMM_SAVE_AREA32 FloatSave;
+            struct
+            {
+                M128A[2] Header;
+                M128A[8] Legacy;
+                M128A Xmm0;
+                M128A Xmm1;
+                M128A Xmm2;
+                M128A Xmm3;
+                M128A Xmm4;
+                M128A Xmm5;
+                M128A Xmm6;
+                M128A Xmm7;
+                M128A Xmm8;
+                M128A Xmm9;
+                M128A Xmm10;
+                M128A Xmm11;
+                M128A Xmm12;
+                M128A Xmm13;
+                M128A Xmm14;
+                M128A Xmm15;
+            };
+        };
+        M128A[26] VectorRegister;
+        DWORD64 VectorControl;
+        DWORD64 DebugControl;
+        DWORD64 LastBranchToRip;
+        DWORD64 LastBranchFromRip;
+        DWORD64 LastExceptionToRip;
+        DWORD64 LastExceptionFromRip;
+    }
+
+} else {
+    static assert(false, "Unsupported CPU");
+    // Versions for PowerPC, Alpha, SHX, and MIPS removed.
+}
+
+alias CONTEXT* PCONTEXT, LPCONTEXT;
+
+struct EXCEPTION_RECORD {
+    DWORD ExceptionCode;
+    DWORD ExceptionFlags;
+    EXCEPTION_RECORD* ExceptionRecord;
+    PVOID ExceptionAddress;
+    DWORD NumberParameters;
+    DWORD[EXCEPTION_MAXIMUM_PARAMETERS] ExceptionInformation;
+}
+alias EXCEPTION_RECORD* PEXCEPTION_RECORD, LPEXCEPTION_RECORD;
+
+struct EXCEPTION_POINTERS {
+    PEXCEPTION_RECORD ExceptionRecord;
+    PCONTEXT          ContextRecord;
+}
+alias EXCEPTION_POINTERS* PEXCEPTION_POINTERS, LPEXCEPTION_POINTERS;
+
+union LARGE_INTEGER {
+    struct {
+        uint LowPart;
+        int  HighPart;
+    }
+    long QuadPart;
+}
+alias LARGE_INTEGER* PLARGE_INTEGER;
+
+union ULARGE_INTEGER {
+    struct {
+        uint LowPart;
+        uint HighPart;
+    }
+    ulong QuadPart;
+}
+alias ULARGE_INTEGER* PULARGE_INTEGER;
+
+alias LARGE_INTEGER LUID;
+alias LUID* PLUID;
+
+enum LUID SYSTEM_LUID = { QuadPart:999 };
+
+align(4) struct LUID_AND_ATTRIBUTES {
+    LUID  Luid;
+    DWORD Attributes;
+}
+alias LUID_AND_ATTRIBUTES* PLUID_AND_ATTRIBUTES;
+
+struct PRIVILEGE_SET {
+    DWORD PrivilegeCount;
+    DWORD Control;
+    LUID_AND_ATTRIBUTES _Privilege;
+
+    LUID_AND_ATTRIBUTES* Privilege() return { return &_Privilege; }
+}
+alias PRIVILEGE_SET* PPRIVILEGE_SET;
+
+struct SECURITY_ATTRIBUTES {
+    DWORD  nLength;
+    LPVOID lpSecurityDescriptor;
+    BOOL   bInheritHandle;
+}
+alias SECURITY_ATTRIBUTES* PSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES;
+
+struct SECURITY_QUALITY_OF_SERVICE {
+    DWORD   Length;
+    SECURITY_IMPERSONATION_LEVEL   ImpersonationLevel;
+    SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
+    BOOLEAN EffectiveOnly;
+}
+alias SECURITY_QUALITY_OF_SERVICE* PSECURITY_QUALITY_OF_SERVICE;
+
+alias PVOID PACCESS_TOKEN;
+
+struct SE_IMPERSONATION_STATE {
+    PACCESS_TOKEN Token;
+    BOOLEAN       CopyOnOpen;
+    BOOLEAN       EffectiveOnly;
+    SECURITY_IMPERSONATION_LEVEL Level;
+}
+alias SE_IMPERSONATION_STATE* PSE_IMPERSONATION_STATE;
+
+struct SID_IDENTIFIER_AUTHORITY {
+    BYTE[6] Value;
+}
+alias SID_IDENTIFIER_AUTHORITY* PSID_IDENTIFIER_AUTHORITY, LPSID_IDENTIFIER_AUTHORITY;
+
+alias PVOID PSID;
+
+struct SID {
+    BYTE  Revision;
+    BYTE  SubAuthorityCount;
+    SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
+    DWORD _SubAuthority;
+
+    DWORD* SubAuthority() return { return &_SubAuthority; }
+}
+alias SID* PISID;
+
+struct SID_AND_ATTRIBUTES {
+    PSID  Sid;
+    DWORD Attributes;
+}
+alias SID_AND_ATTRIBUTES* PSID_AND_ATTRIBUTES;
+
+struct TOKEN_SOURCE {
+    CHAR[TOKEN_SOURCE_LENGTH] SourceName;
+    LUID SourceIdentifier;
+}
+alias TOKEN_SOURCE* PTOKEN_SOURCE;
+
+struct TOKEN_CONTROL {
+    LUID         TokenId;
+    LUID         AuthenticationId;
+    LUID         ModifiedId;
+    TOKEN_SOURCE TokenSource;
+}
+alias TOKEN_CONTROL* PTOKEN_CONTROL;
+
+struct TOKEN_DEFAULT_DACL {
+    PACL DefaultDacl;
+}
+alias TOKEN_DEFAULT_DACL* PTOKEN_DEFAULT_DACL;
+
+struct TOKEN_GROUPS {
+    DWORD GroupCount;
+    SID_AND_ATTRIBUTES _Groups;
+
+    SID_AND_ATTRIBUTES* Groups() return { return &_Groups; }
+}
+alias TOKEN_GROUPS* PTOKEN_GROUPS, LPTOKEN_GROUPS;
+
+struct TOKEN_OWNER {
+    PSID Owner;
+}
+alias TOKEN_OWNER* PTOKEN_OWNER;
+
+struct TOKEN_PRIMARY_GROUP {
+    PSID PrimaryGroup;
+}
+alias TOKEN_PRIMARY_GROUP* PTOKEN_PRIMARY_GROUP;
+
+struct TOKEN_PRIVILEGES {
+    DWORD PrivilegeCount;
+    LUID_AND_ATTRIBUTES _Privileges;
+
+    LUID_AND_ATTRIBUTES* Privileges() return { return &_Privileges; }
+}
+alias TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES, LPTOKEN_PRIVILEGES;
+
+enum TOKEN_TYPE {
+    TokenPrimary = 1,
+    TokenImpersonation
+}
+alias TOKEN_TYPE* PTOKEN_TYPE;
+
+struct TOKEN_STATISTICS {
+    LUID          TokenId;
+    LUID          AuthenticationId;
+    LARGE_INTEGER ExpirationTime;
+    TOKEN_TYPE    TokenType;
+    SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
+    DWORD         DynamicCharged;
+    DWORD         DynamicAvailable;
+    DWORD         GroupCount;
+    DWORD         PrivilegeCount;
+    LUID          ModifiedId;
+}
+alias TOKEN_STATISTICS* PTOKEN_STATISTICS;
+
+struct TOKEN_USER {
+    SID_AND_ATTRIBUTES User;
+}
+alias TOKEN_USER* PTOKEN_USER;
+
+alias DWORD SECURITY_INFORMATION;
+alias SECURITY_INFORMATION* PSECURITY_INFORMATION;
+alias WORD SECURITY_DESCRIPTOR_CONTROL;
+alias SECURITY_DESCRIPTOR_CONTROL* PSECURITY_DESCRIPTOR_CONTROL;
+
+struct SECURITY_DESCRIPTOR {
+    BYTE Revision;
+    BYTE Sbz1;
+    SECURITY_DESCRIPTOR_CONTROL Control;
+    PSID Owner;
+    PSID Group;
+    PACL Sacl;
+    PACL Dacl;
+}
+alias SECURITY_DESCRIPTOR* PSECURITY_DESCRIPTOR, PISECURITY_DESCRIPTOR;
+
+enum TOKEN_INFORMATION_CLASS {
+    TokenUser = 1,
+    TokenGroups,
+    TokenPrivileges,
+    TokenOwner,
+    TokenPrimaryGroup,
+    TokenDefaultDacl,
+    TokenSource,
+    TokenType,
+    TokenImpersonationLevel,
+    TokenStatistics,
+    TokenRestrictedSids,
+    TokenSessionId,
+    TokenGroupsAndPrivileges,
+    TokenSessionReference,
+    TokenSandBoxInert,
+    TokenAuditPolicy,
+    TokenOrigin
+}
+
+enum SID_NAME_USE {
+    SidTypeUser = 1,
+    SidTypeGroup,
+    SidTypeDomain,
+    SidTypeAlias,
+    SidTypeWellKnownGroup,
+    SidTypeDeletedAccount,
+    SidTypeInvalid,
+    SidTypeUnknown,
+    SidTypeComputer
+}
+alias SID_NAME_USE* PSID_NAME_USE;
+
+struct QUOTA_LIMITS {
+    SIZE_T PagedPoolLimit;
+    SIZE_T NonPagedPoolLimit;
+    SIZE_T MinimumWorkingSetSize;
+    SIZE_T MaximumWorkingSetSize;
+    SIZE_T PagefileLimit;
+    LARGE_INTEGER TimeLimit;
+}
+alias QUOTA_LIMITS* PQUOTA_LIMITS;
+
+struct IO_COUNTERS {
+    ULONGLONG ReadOperationCount;
+    ULONGLONG WriteOperationCount;
+    ULONGLONG OtherOperationCount;
+    ULONGLONG ReadTransferCount;
+    ULONGLONG WriteTransferCount;
+    ULONGLONG OtherTransferCount;
+}
+alias IO_COUNTERS* PIO_COUNTERS;
+
+struct FILE_NOTIFY_INFORMATION {
+    DWORD NextEntryOffset;
+    DWORD Action;
+    DWORD FileNameLength;
+    WCHAR _FileName;
+
+    WCHAR* FileName() return { return &_FileName; }
+}
+alias FILE_NOTIFY_INFORMATION* PFILE_NOTIFY_INFORMATION;
+
+struct TAPE_ERASE {
+    DWORD   Type;
+    BOOLEAN Immediate;
+}
+alias TAPE_ERASE* PTAPE_ERASE;
+
+struct TAPE_GET_DRIVE_PARAMETERS {
+    BOOLEAN ECC;
+    BOOLEAN Compression;
+    BOOLEAN DataPadding;
+    BOOLEAN ReportSetmarks;
+    DWORD   DefaultBlockSize;
+    DWORD   MaximumBlockSize;
+    DWORD   MinimumBlockSize;
+    DWORD   MaximumPartitionCount;
+    DWORD   FeaturesLow;
+    DWORD   FeaturesHigh;
+    DWORD   EOTWarningZoneSize;
+}
+alias TAPE_GET_DRIVE_PARAMETERS* PTAPE_GET_DRIVE_PARAMETERS;
+
+struct TAPE_GET_MEDIA_PARAMETERS {
+    LARGE_INTEGER Capacity;
+    LARGE_INTEGER Remaining;
+    DWORD         BlockSize;
+    DWORD         PartitionCount;
+    BOOLEAN       WriteProtected;
+}
+alias TAPE_GET_MEDIA_PARAMETERS* PTAPE_GET_MEDIA_PARAMETERS;
+
+struct TAPE_GET_POSITION {
+    ULONG Type;
+    ULONG Partition;
+    ULONG OffsetLow;
+    ULONG OffsetHigh;
+}
+alias TAPE_GET_POSITION* PTAPE_GET_POSITION;
+
+struct TAPE_PREPARE {
+    DWORD   Operation;
+    BOOLEAN Immediate;
+}
+alias TAPE_PREPARE* PTAPE_PREPARE;
+
+struct TAPE_SET_DRIVE_PARAMETERS {
+    BOOLEAN ECC;
+    BOOLEAN Compression;
+    BOOLEAN DataPadding;
+    BOOLEAN ReportSetmarks;
+    ULONG   EOTWarningZoneSize;
+}
+alias TAPE_SET_DRIVE_PARAMETERS* PTAPE_SET_DRIVE_PARAMETERS;
+
+struct TAPE_SET_MEDIA_PARAMETERS {
+    ULONG BlockSize;
+}
+alias TAPE_SET_MEDIA_PARAMETERS* PTAPE_SET_MEDIA_PARAMETERS;
+
+struct TAPE_SET_POSITION {
+    DWORD         Method;
+    DWORD         Partition;
+    LARGE_INTEGER Offset;
+    BOOLEAN       Immediate;
+}
+alias TAPE_SET_POSITION* PTAPE_SET_POSITION;
+
+struct TAPE_WRITE_MARKS {
+    DWORD   Type;
+    DWORD   Count;
+    BOOLEAN Immediate;
+}
+alias TAPE_WRITE_MARKS* PTAPE_WRITE_MARKS;
+
+struct TAPE_CREATE_PARTITION {
+    DWORD Method;
+    DWORD Count;
+    DWORD Size;
+}
+alias TAPE_CREATE_PARTITION* PTAPE_CREATE_PARTITION;
+
+struct MEMORY_BASIC_INFORMATION {
+    PVOID BaseAddress;
+    PVOID AllocationBase;
+    DWORD AllocationProtect;
+    DWORD RegionSize;
+    DWORD State;
+    DWORD Protect;
+    DWORD Type;
+}
+alias MEMORY_BASIC_INFORMATION* PMEMORY_BASIC_INFORMATION;
+
+struct MESSAGE_RESOURCE_ENTRY {
+    WORD Length;
+    WORD Flags;
+    BYTE _Text;
+
+    BYTE* Text() return { return &_Text; }
+}
+alias MESSAGE_RESOURCE_ENTRY* PMESSAGE_RESOURCE_ENTRY;
+
+struct MESSAGE_RESOURCE_BLOCK {
+    DWORD LowId;
+    DWORD HighId;
+    DWORD OffsetToEntries;
+}
+alias MESSAGE_RESOURCE_BLOCK* PMESSAGE_RESOURCE_BLOCK;
+
+struct MESSAGE_RESOURCE_DATA {
+    DWORD NumberOfBlocks;
+    MESSAGE_RESOURCE_BLOCK _Blocks;
+
+    MESSAGE_RESOURCE_BLOCK* Blocks() return { return &_Blocks; }
+}
+alias MESSAGE_RESOURCE_DATA* PMESSAGE_RESOURCE_DATA;
+
+struct LIST_ENTRY {
+    LIST_ENTRY* Flink;
+    LIST_ENTRY* Blink;
+}
+alias LIST_ENTRY* PLIST_ENTRY;
+alias LIST_ENTRY _LIST_ENTRY;
+
+struct SINGLE_LIST_ENTRY {
+    SINGLE_LIST_ENTRY* Next;
+}
+alias SINGLE_LIST_ENTRY SLIST_ENTRY;
+alias SINGLE_LIST_ENTRY* PSINGLE_LIST_ENTRY, PSLIST_ENTRY;
+
+union SLIST_HEADER {
+    ULONGLONG       Alignment;
+    struct {
+        SLIST_ENTRY Next;
+        WORD        Depth;
+        WORD        Sequence;
+    }
+}
+alias SLIST_HEADER* PSLIST_HEADER;
+
+struct RTL_CRITICAL_SECTION_DEBUG {
+    WORD       Type;
+    WORD       CreatorBackTraceIndex;
+    RTL_CRITICAL_SECTION* CriticalSection;
+    LIST_ENTRY ProcessLocksList;
+    DWORD      EntryCount;
+    DWORD      ContentionCount;
+    DWORD[2]   Spare;
+}
+alias RTL_CRITICAL_SECTION_DEBUG* PRTL_CRITICAL_SECTION_DEBUG;
+alias RTL_CRITICAL_SECTION_DEBUG _RTL_CRITICAL_SECTION_DEBUG;
+
+struct RTL_CRITICAL_SECTION {
+    PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
+    LONG   LockCount;
+    LONG   RecursionCount;
+    HANDLE OwningThread;
+    HANDLE LockSemaphore;
+    ULONG_PTR SpinCount;
+    alias Reserved = SpinCount;
+}
+alias RTL_CRITICAL_SECTION* PRTL_CRITICAL_SECTION;
+alias RTL_CRITICAL_SECTION _RTL_CRITICAL_SECTION;
+
+struct EVENTLOGRECORD {
+    DWORD Length;
+    DWORD Reserved;
+    DWORD RecordNumber;
+    DWORD TimeGenerated;
+    DWORD TimeWritten;
+    DWORD EventID;
+    WORD  EventType;
+    WORD  NumStrings;
+    WORD  EventCategory;
+    WORD  ReservedFlags;
+    DWORD ClosingRecordNumber;
+    DWORD StringOffset;
+    DWORD UserSidLength;
+    DWORD UserSidOffset;
+    DWORD DataLength;
+    DWORD DataOffset;
+}
+alias EVENTLOGRECORD* PEVENTLOGRECORD;
+
+struct OSVERSIONINFOA {
+    DWORD     dwOSVersionInfoSize = OSVERSIONINFOA.sizeof;
+    DWORD     dwMajorVersion;
+    DWORD     dwMinorVersion;
+    DWORD     dwBuildNumber;
+    DWORD     dwPlatformId;
+    CHAR[128] szCSDVersion;
+}
+alias OSVERSIONINFOA* POSVERSIONINFOA, LPOSVERSIONINFOA;
+
+struct OSVERSIONINFOW {
+    DWORD      dwOSVersionInfoSize = OSVERSIONINFOW.sizeof;
+    DWORD      dwMajorVersion;
+    DWORD      dwMinorVersion;
+    DWORD      dwBuildNumber;
+    DWORD      dwPlatformId;
+    WCHAR[128] szCSDVersion;
+}
+alias OSVERSIONINFOW* POSVERSIONINFOW, LPOSVERSIONINFOW;
+
+struct OSVERSIONINFOEXA {
+    DWORD     dwOSVersionInfoSize;
+    DWORD     dwMajorVersion;
+    DWORD     dwMinorVersion;
+    DWORD     dwBuildNumber;
+    DWORD     dwPlatformId;
+    CHAR[128] szCSDVersion;
+    WORD      wServicePackMajor;
+    WORD      wServicePackMinor;
+    WORD      wSuiteMask;
+    BYTE      wProductType;
+    BYTE      wReserved;
+}
+alias OSVERSIONINFOEXA* POSVERSIONINFOEXA, LPOSVERSIONINFOEXA;
+
+struct OSVERSIONINFOEXW {
+    DWORD      dwOSVersionInfoSize;
+    DWORD      dwMajorVersion;
+    DWORD      dwMinorVersion;
+    DWORD      dwBuildNumber;
+    DWORD      dwPlatformId;
+    WCHAR[128] szCSDVersion;
+    WORD       wServicePackMajor;
+    WORD       wServicePackMinor;
+    WORD       wSuiteMask;
+    BYTE       wProductType;
+    BYTE       wReserved;
+}
+alias OSVERSIONINFOEXW* POSVERSIONINFOEXW, LPOSVERSIONINFOEXW;
+
+align(2) struct IMAGE_VXD_HEADER {
+    WORD     e32_magic;
+    BYTE     e32_border;
+    BYTE     e32_worder;
+    DWORD    e32_level;
+    WORD     e32_cpu;
+    WORD     e32_os;
+    DWORD    e32_ver;
+    DWORD    e32_mflags;
+    DWORD    e32_mpages;
+    DWORD    e32_startobj;
+    DWORD    e32_eip;
+    DWORD    e32_stackobj;
+    DWORD    e32_esp;
+    DWORD    e32_pagesize;
+    DWORD    e32_lastpagesize;
+    DWORD    e32_fixupsize;
+    DWORD    e32_fixupsum;
+    DWORD    e32_ldrsize;
+    DWORD    e32_ldrsum;
+    DWORD    e32_objtab;
+    DWORD    e32_objcnt;
+    DWORD    e32_objmap;
+    DWORD    e32_itermap;
+    DWORD    e32_rsrctab;
+    DWORD    e32_rsrccnt;
+    DWORD    e32_restab;
+    DWORD    e32_enttab;
+    DWORD    e32_dirtab;
+    DWORD    e32_dircnt;
+    DWORD    e32_fpagetab;
+    DWORD    e32_frectab;
+    DWORD    e32_impmod;
+    DWORD    e32_impmodcnt;
+    DWORD    e32_impproc;
+    DWORD    e32_pagesum;
+    DWORD    e32_datapage;
+    DWORD    e32_preload;
+    DWORD    e32_nrestab;
+    DWORD    e32_cbnrestab;
+    DWORD    e32_nressum;
+    DWORD    e32_autodata;
+    DWORD    e32_debuginfo;
+    DWORD    e32_debuglen;
+    DWORD    e32_instpreload;
+    DWORD    e32_instdemand;
+    DWORD    e32_heapsize;
+    BYTE[12] e32_res3;
+    DWORD    e32_winresoff;
+    DWORD    e32_winreslen;
+    WORD     e32_devid;
+    WORD     e32_ddkver;
+}
+alias IMAGE_VXD_HEADER* PIMAGE_VXD_HEADER;
+
+align(4):
+struct IMAGE_FILE_HEADER {
+    WORD  Machine;
+    WORD  NumberOfSections;
+    DWORD TimeDateStamp;
+    DWORD PointerToSymbolTable;
+    DWORD NumberOfSymbols;
+    WORD  SizeOfOptionalHeader;
+    WORD  Characteristics;
+}
+alias IMAGE_FILE_HEADER* PIMAGE_FILE_HEADER;
+// const IMAGE_SIZEOF_FILE_HEADER = IMAGE_FILE_HEADER.sizeof;
+
+struct IMAGE_DATA_DIRECTORY {
+    DWORD VirtualAddress;
+    DWORD Size;
+}
+alias IMAGE_DATA_DIRECTORY* PIMAGE_DATA_DIRECTORY;
+
+struct IMAGE_OPTIONAL_HEADER32 {
+    WORD  Magic;
+    BYTE  MajorLinkerVersion;
+    BYTE  MinorLinkerVersion;
+    DWORD SizeOfCode;
+    DWORD SizeOfInitializedData;
+    DWORD SizeOfUninitializedData;
+    DWORD AddressOfEntryPoint;
+    DWORD BaseOfCode;
+    DWORD BaseOfData;
+    DWORD ImageBase;
+    DWORD SectionAlignment;
+    DWORD FileAlignment;
+    WORD  MajorOperatingSystemVersion;
+    WORD  MinorOperatingSystemVersion;
+    WORD  MajorImageVersion;
+    WORD  MinorImageVersion;
+    WORD  MajorSubsystemVersion;
+    WORD  MinorSubsystemVersion;
+    DWORD Win32VersionValue;
+    DWORD SizeOfImage;
+    DWORD SizeOfHeaders;
+    DWORD CheckSum;
+    WORD  Subsystem;
+    WORD  DllCharacteristics;
+    DWORD SizeOfStackReserve;
+    DWORD SizeOfStackCommit;
+    DWORD SizeOfHeapReserve;
+    DWORD SizeOfHeapCommit;
+    DWORD LoaderFlags;
+    DWORD NumberOfRvaAndSizes;
+    IMAGE_DATA_DIRECTORY[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] DataDirectory;
+}
+alias IMAGE_OPTIONAL_HEADER32* PIMAGE_OPTIONAL_HEADER32;
+
+struct IMAGE_OPTIONAL_HEADER64 {
+    WORD      Magic;
+    BYTE      MajorLinkerVersion;
+    BYTE      MinorLinkerVersion;
+    DWORD     SizeOfCode;
+    DWORD     SizeOfInitializedData;
+    DWORD     SizeOfUninitializedData;
+    DWORD     AddressOfEntryPoint;
+    DWORD     BaseOfCode;
+    ULONGLONG ImageBase;
+    DWORD     SectionAlignment;
+    DWORD     FileAlignment;
+    WORD      MajorOperatingSystemVersion;
+    WORD      MinorOperatingSystemVersion;
+    WORD      MajorImageVersion;
+    WORD      MinorImageVersion;
+    WORD      MajorSubsystemVersion;
+    WORD      MinorSubsystemVersion;
+    DWORD     Win32VersionValue;
+    DWORD     SizeOfImage;
+    DWORD     SizeOfHeaders;
+    DWORD     CheckSum;
+    WORD      Subsystem;
+    WORD      DllCharacteristics;
+    ULONGLONG SizeOfStackReserve;
+    ULONGLONG SizeOfStackCommit;
+    ULONGLONG SizeOfHeapReserve;
+    ULONGLONG SizeOfHeapCommit;
+    DWORD     LoaderFlags;
+    DWORD     NumberOfRvaAndSizes;
+    IMAGE_DATA_DIRECTORY[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] DataDirectory;
+}
+alias IMAGE_OPTIONAL_HEADER64* PIMAGE_OPTIONAL_HEADER64;
+
+struct IMAGE_ROM_OPTIONAL_HEADER {
+    WORD     Magic;
+    BYTE     MajorLinkerVersion;
+    BYTE     MinorLinkerVersion;
+    DWORD    SizeOfCode;
+    DWORD    SizeOfInitializedData;
+    DWORD    SizeOfUninitializedData;
+    DWORD    AddressOfEntryPoint;
+    DWORD    BaseOfCode;
+    DWORD    BaseOfData;
+    DWORD    BaseOfBss;
+    DWORD    GprMask;
+    DWORD[4] CprMask;
+    DWORD    GpValue;
+}
+alias IMAGE_ROM_OPTIONAL_HEADER* PIMAGE_ROM_OPTIONAL_HEADER;
+
+align(2):
+struct IMAGE_DOS_HEADER {
+    WORD     e_magic;
+    WORD     e_cblp;
+    WORD     e_cp;
+    WORD     e_crlc;
+    WORD     e_cparhdr;
+    WORD     e_minalloc;
+    WORD     e_maxalloc;
+    WORD     e_ss;
+    WORD     e_sp;
+    WORD     e_csum;
+    WORD     e_ip;
+    WORD     e_cs;
+    WORD     e_lfarlc;
+    WORD     e_ovno;
+    WORD[4] e_res;
+    WORD     e_oemid;
+    WORD     e_oeminfo;
+    WORD[10] e_res2;
+    LONG     e_lfanew;
+}
+alias IMAGE_DOS_HEADER* PIMAGE_DOS_HEADER;
+
+struct IMAGE_OS2_HEADER {
+    WORD ne_magic;
+    CHAR ne_ver;
+    CHAR ne_rev;
+    WORD ne_enttab;
+    WORD ne_cbenttab;
+    LONG ne_crc;
+    WORD ne_flags;
+    WORD ne_autodata;
+    WORD ne_heap;
+    WORD ne_stack;
+    LONG ne_csip;
+    LONG ne_sssp;
+    WORD ne_cseg;
+    WORD ne_cmod;
+    WORD ne_cbnrestab;
+    WORD ne_segtab;
+    WORD ne_rsrctab;
+    WORD ne_restab;
+    WORD ne_modtab;
+    WORD ne_imptab;
+    LONG ne_nrestab;
+    WORD ne_cmovent;
+    WORD ne_align;
+    WORD ne_cres;
+    BYTE ne_exetyp;
+    BYTE ne_flagsothers;
+    WORD ne_pretthunks;
+    WORD ne_psegrefbytes;
+    WORD ne_swaparea;
+    WORD ne_expver;
+}
+alias IMAGE_OS2_HEADER* PIMAGE_OS2_HEADER;
+
+align(4) struct IMAGE_NT_HEADERS32 {
+    DWORD                 Signature;
+    IMAGE_FILE_HEADER     FileHeader;
+    IMAGE_OPTIONAL_HEADER OptionalHeader;
+}
+alias IMAGE_NT_HEADERS32* PIMAGE_NT_HEADERS32;
+
+align(4) struct IMAGE_NT_HEADERS64 {
+    DWORD                 Signature;
+    IMAGE_FILE_HEADER     FileHeader;
+    IMAGE_OPTIONAL_HEADER OptionalHeader;
+}
+alias IMAGE_NT_HEADERS64* PIMAGE_NT_HEADERS64;
+
+struct IMAGE_ROM_HEADERS {
+    IMAGE_FILE_HEADER         FileHeader;
+    IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;
+}
+alias IMAGE_ROM_HEADERS* PIMAGE_ROM_HEADERS;
+
+struct IMAGE_SECTION_HEADER {
+    BYTE[IMAGE_SIZEOF_SHORT_NAME] Name;
+    union _Misc {
+        DWORD PhysicalAddress;
+        DWORD VirtualSize;
+    }
+    _Misc Misc;
+    DWORD VirtualAddress;
+    DWORD SizeOfRawData;
+    DWORD PointerToRawData;
+    DWORD PointerToRelocations;
+    DWORD PointerToLinenumbers;
+    WORD  NumberOfRelocations;
+    WORD  NumberOfLinenumbers;
+    DWORD Characteristics;
+}
+alias IMAGE_SECTION_HEADER* PIMAGE_SECTION_HEADER;
+
+struct IMAGE_SYMBOL {
+    union _N {
+        BYTE[8]   ShortName;
+        struct Name {
+            DWORD Short;
+            DWORD Long;
+        }
+        PBYTE[2]  LongName;
+    }
+    _N    N;
+    DWORD Value;
+    SHORT SectionNumber;
+    WORD  Type;
+    BYTE  StorageClass;
+    BYTE  NumberOfAuxSymbols;
+}
+alias IMAGE_SYMBOL* PIMAGE_SYMBOL;
+
+union IMAGE_AUX_SYMBOL {
+    struct _Sym {
+        DWORD           TagIndex;
+        union _Misc {
+            struct _LnSz {
+                WORD    Linenumber;
+                WORD    Size;
+            }
+            _LnSz       LnSz;
+            DWORD       TotalSize;
+        }
+        _Misc Misc;
+        union _FcnAry {
+            struct _Function {
+                DWORD   PointerToLinenumber;
+                DWORD   PointerToNextFunction;
+            }
+            _Function   Function;
+            struct _Array {
+                WORD[4] Dimension;
+            }
+            _Array      Array;
+        }
+        _FcnAry         FcnAry;
+        WORD            TvIndex;
+    }
+    _Sym                Sym;
+    struct _File {
+        BYTE[IMAGE_SIZEOF_SYMBOL] Name;
+    }
+    _File               File;
+    struct _Section {
+        DWORD           Length;
+        WORD            NumberOfRelocations;
+        WORD            NumberOfLinenumbers;
+        DWORD           CheckSum;
+        SHORT           Number;
+        BYTE            Selection;
+    }
+    _Section            Section;
+}
+alias IMAGE_AUX_SYMBOL* PIMAGE_AUX_SYMBOL;
+
+struct IMAGE_COFF_SYMBOLS_HEADER {
+    DWORD NumberOfSymbols;
+    DWORD LvaToFirstSymbol;
+    DWORD NumberOfLinenumbers;
+    DWORD LvaToFirstLinenumber;
+    DWORD RvaToFirstByteOfCode;
+    DWORD RvaToLastByteOfCode;
+    DWORD RvaToFirstByteOfData;
+    DWORD RvaToLastByteOfData;
+}
+alias IMAGE_COFF_SYMBOLS_HEADER* PIMAGE_COFF_SYMBOLS_HEADER;
+
+struct IMAGE_RELOCATION {
+    union {
+        DWORD VirtualAddress;
+        DWORD RelocCount;
+    }
+    DWORD     SymbolTableIndex;
+    WORD      Type;
+}
+alias IMAGE_RELOCATION* PIMAGE_RELOCATION;
+
+align(4) struct IMAGE_BASE_RELOCATION {
+    DWORD VirtualAddress;
+    DWORD SizeOfBlock;
+}
+alias IMAGE_BASE_RELOCATION* PIMAGE_BASE_RELOCATION;
+
+align(2) struct IMAGE_LINENUMBER {
+    union _Type {
+        DWORD SymbolTableIndex;
+        DWORD VirtualAddress;
+    }
+    _Type Type;
+    WORD  Linenumber;
+}
+alias IMAGE_LINENUMBER* PIMAGE_LINENUMBER;
+
+align(4):
+struct IMAGE_ARCHIVE_MEMBER_HEADER {
+    BYTE[16] Name;
+    BYTE[12] Date;
+    BYTE[6]  UserID;
+    BYTE[6]  GroupID;
+    BYTE[8]  Mode;
+    BYTE[10] Size;
+    BYTE[2]  EndHeader;
+}
+alias IMAGE_ARCHIVE_MEMBER_HEADER* PIMAGE_ARCHIVE_MEMBER_HEADER;
+
+struct IMAGE_EXPORT_DIRECTORY {
+    DWORD Characteristics;
+    DWORD TimeDateStamp;
+    WORD  MajorVersion;
+    WORD  MinorVersion;
+    DWORD Name;
+    DWORD Base;
+    DWORD NumberOfFunctions;
+    DWORD NumberOfNames;
+    DWORD AddressOfFunctions;
+    DWORD AddressOfNames;
+    DWORD AddressOfNameOrdinals;
+}
+alias IMAGE_EXPORT_DIRECTORY* PIMAGE_EXPORT_DIRECTORY;
+
+struct IMAGE_IMPORT_BY_NAME {
+    WORD Hint;
+    BYTE _Name;
+
+    BYTE* Name() return { return &_Name; }
+}
+alias IMAGE_IMPORT_BY_NAME* PIMAGE_IMPORT_BY_NAME;
+
+struct IMAGE_THUNK_DATA32 {
+    union _u1 {
+        DWORD ForwarderString;
+        DWORD Function;
+        DWORD Ordinal;
+        DWORD AddressOfData;
+    }
+    _u1 u1;
+}
+alias IMAGE_THUNK_DATA32* PIMAGE_THUNK_DATA32;
+
+struct IMAGE_THUNK_DATA64 {
+    union _u1 {
+        ULONGLONG ForwarderString;
+        ULONGLONG Function;
+        ULONGLONG Ordinal;
+        ULONGLONG AddressOfData;
+    }
+    _u1 u1;
+}
+alias IMAGE_THUNK_DATA64* PIMAGE_THUNK_DATA64;
+
+struct IMAGE_IMPORT_DESCRIPTOR {
+    union {
+        DWORD Characteristics;
+        DWORD OriginalFirstThunk;
+    }
+    DWORD TimeDateStamp;
+    DWORD ForwarderChain;
+    DWORD Name;
+    DWORD FirstThunk;
+}
+alias IMAGE_IMPORT_DESCRIPTOR* PIMAGE_IMPORT_DESCRIPTOR;
+
+struct IMAGE_BOUND_IMPORT_DESCRIPTOR {
+    DWORD TimeDateStamp;
+    WORD  OffsetModuleName;
+    WORD  NumberOfModuleForwarderRefs;
+}
+alias IMAGE_BOUND_IMPORT_DESCRIPTOR* PIMAGE_BOUND_IMPORT_DESCRIPTOR;
+
+struct IMAGE_BOUND_FORWARDER_REF {
+    DWORD TimeDateStamp;
+    WORD  OffsetModuleName;
+    WORD  Reserved;
+}
+alias IMAGE_BOUND_FORWARDER_REF* PIMAGE_BOUND_FORWARDER_REF;
+
+struct IMAGE_TLS_DIRECTORY32 {
+    DWORD StartAddressOfRawData;
+    DWORD EndAddressOfRawData;
+    DWORD AddressOfIndex;
+    DWORD AddressOfCallBacks;
+    DWORD SizeOfZeroFill;
+    DWORD Characteristics;
+}
+alias IMAGE_TLS_DIRECTORY32* PIMAGE_TLS_DIRECTORY32;
+
+struct IMAGE_TLS_DIRECTORY64 {
+    ULONGLONG StartAddressOfRawData;
+    ULONGLONG EndAddressOfRawData;
+    ULONGLONG AddressOfIndex;
+    ULONGLONG AddressOfCallBacks;
+    DWORD     SizeOfZeroFill;
+    DWORD     Characteristics;
+}
+alias IMAGE_TLS_DIRECTORY64* PIMAGE_TLS_DIRECTORY64;
+
+struct IMAGE_RESOURCE_DIRECTORY {
+    DWORD Characteristics;
+    DWORD TimeDateStamp;
+    WORD  MajorVersion;
+    WORD  MinorVersion;
+    WORD  NumberOfNamedEntries;
+    WORD  NumberOfIdEntries;
+}
+alias IMAGE_RESOURCE_DIRECTORY* PIMAGE_RESOURCE_DIRECTORY;
+
+struct IMAGE_RESOURCE_DIRECTORY_ENTRY {
+    union {
+        /+struct {
+            DWORD NameOffset:31;
+            DWORD NameIsString:1;
+        }+/
+        DWORD Name;
+        WORD Id;
+    }
+    DWORD OffsetToData;
+        /+struct {
+            DWORD OffsetToDirectory:31;
+            DWORD DataIsDirectory:1;
+        }+/
+
+    uint NameOffset()        { return Name & 0x7FFFFFFF; }
+    bool NameIsString()      { return cast(bool)(Name & 0x80000000); }
+    uint OffsetToDirectory() { return OffsetToData & 0x7FFFFFFF; }
+    bool DataIsDirectory()   { return cast(bool)(OffsetToData & 0x80000000); }
+
+    uint NameOffset(uint n) {
+        Name = (Name & 0x80000000) | (n & 0x7FFFFFFF);
+        return n & 0x7FFFFFFF;
+    }
+
+    bool NameIsString(bool n) {
+        Name = (Name & 0x7FFFFFFF) | (n << 31); return n;
+    }
+
+    uint OffsetToDirectory(uint o) {
+        OffsetToData = (OffsetToData & 0x80000000) | (o & 0x7FFFFFFF);
+        return o & 0x7FFFFFFF;
+    }
+
+    bool DataIsDirectory(bool d) {
+        OffsetToData = (OffsetToData & 0x7FFFFFFF) | (d << 31); return d;
+    }
+}
+alias IMAGE_RESOURCE_DIRECTORY_ENTRY* PIMAGE_RESOURCE_DIRECTORY_ENTRY;
+
+struct IMAGE_RESOURCE_DIRECTORY_STRING {
+    WORD Length;
+    CHAR _NameString;
+
+    CHAR* NameString() return { return &_NameString; }
+}
+alias IMAGE_RESOURCE_DIRECTORY_STRING* PIMAGE_RESOURCE_DIRECTORY_STRING;
+
+struct IMAGE_RESOURCE_DIR_STRING_U {
+    WORD  Length;
+    WCHAR _NameString;
+
+    WCHAR* NameString() return { return &_NameString; }
+}
+alias IMAGE_RESOURCE_DIR_STRING_U* PIMAGE_RESOURCE_DIR_STRING_U;
+
+struct IMAGE_RESOURCE_DATA_ENTRY {
+    DWORD OffsetToData;
+    DWORD Size;
+    DWORD CodePage;
+    DWORD Reserved;
+}
+alias IMAGE_RESOURCE_DATA_ENTRY* PIMAGE_RESOURCE_DATA_ENTRY;
+
+struct IMAGE_LOAD_CONFIG_DIRECTORY {
+    DWORD    Characteristics;
+    DWORD    TimeDateStamp;
+    WORD     MajorVersion;
+    WORD     MinorVersion;
+    DWORD    GlobalFlagsClear;
+    DWORD    GlobalFlagsSet;
+    DWORD    CriticalSectionDefaultTimeout;
+    DWORD    DeCommitFreeBlockThreshold;
+    DWORD    DeCommitTotalFreeThreshold;
+    PVOID    LockPrefixTable;
+    DWORD    MaximumAllocationSize;
+    DWORD    VirtualMemoryThreshold;
+    DWORD    ProcessHeapFlags;
+    DWORD[4] Reserved;
+}
+alias IMAGE_LOAD_CONFIG_DIRECTORY* PIMAGE_LOAD_CONFIG_DIRECTORY;
+
+struct IMAGE_LOAD_CONFIG_DIRECTORY64 {
+    DWORD     Characteristics;
+    DWORD     TimeDateStamp;
+    WORD      MajorVersion;
+    WORD      MinorVersion;
+    DWORD     GlobalFlagsClear;
+    DWORD     GlobalFlagsSet;
+    DWORD     CriticalSectionDefaultTimeout;
+    ULONGLONG DeCommitFreeBlockThreshold;
+    ULONGLONG DeCommitTotalFreeThreshold;
+    ULONGLONG LockPrefixTable;
+    ULONGLONG MaximumAllocationSize;
+    ULONGLONG VirtualMemoryThreshold;
+    ULONGLONG ProcessAffinityMask;
+    DWORD     ProcessHeapFlags;
+    WORD      CSDFlags;
+    WORD      Reserved1;
+    ULONGLONG EditList;
+    DWORD[2]  Reserved;
+}
+alias IMAGE_LOAD_CONFIG_DIRECTORY64* PIMAGE_LOAD_CONFIG_DIRECTORY64;
+
+struct IMAGE_RUNTIME_FUNCTION_ENTRY {
+    DWORD BeginAddress;
+    DWORD EndAddress;
+    PVOID ExceptionHandler;
+    PVOID HandlerData;
+    DWORD PrologEndAddress;
+}
+alias IMAGE_RUNTIME_FUNCTION_ENTRY* PIMAGE_RUNTIME_FUNCTION_ENTRY;
+
+struct IMAGE_CE_RUNTIME_FUNCTION_ENTRY {
+    uint      FuncStart;
+    union {
+        ubyte PrologLen;
+        uint  _bf;
+    }
+/+
+    unsigned int FuncLen:22;
+    unsigned int ThirtyTwoBit:1;
+    unsigned int ExceptionFlag:1;
++/
+    uint FuncLen()       { return (_bf >> 8) & 0x3FFFFF; }
+    bool ThirtyTwoBit()  { return cast(bool)(_bf & 0x40000000); }
+    bool ExceptionFlag() { return cast(bool)(_bf & 0x80000000); }
+
+    uint FuncLen(uint f) {
+        _bf = (_bf & ~0x3FFFFF00) | ((f & 0x3FFFFF) << 8); return f & 0x3FFFFF;
+    }
+
+    bool ThirtyTwoBit(bool t) {
+        _bf = (_bf & ~0x40000000) | (t << 30); return t;
+    }
+
+    bool ExceptionFlag(bool e) {
+        _bf = (_bf & ~0x80000000) | (e << 31); return e;
+    }
+}
+alias IMAGE_CE_RUNTIME_FUNCTION_ENTRY* PIMAGE_CE_RUNTIME_FUNCTION_ENTRY;
+
+struct IMAGE_DEBUG_DIRECTORY {
+    DWORD Characteristics;
+    DWORD TimeDateStamp;
+    WORD  MajorVersion;
+    WORD  MinorVersion;
+    DWORD Type;
+    DWORD SizeOfData;
+    DWORD AddressOfRawData;
+    DWORD PointerToRawData;
+}
+alias IMAGE_DEBUG_DIRECTORY* PIMAGE_DEBUG_DIRECTORY;
+
+struct FPO_DATA {
+    DWORD  ulOffStart;
+    DWORD  cbProcSize;
+    DWORD  cdwLocals;
+    WORD   cdwParams;
+    ubyte  cbProlog;
+    ubyte  _bf;
+/+
+    WORD cbRegs:3;
+    WORD fHasSEH:1;
+    WORD fUseBP:1;
+    WORD reserved:1;
+    WORD cbFrame:2;
++/
+    ubyte cbRegs()  { return cast(ubyte)(_bf & 0x07); }
+    bool fHasSEH()  { return cast(bool)(_bf & 0x08); }
+    bool fUseBP()   { return cast(bool)(_bf & 0x10); }
+    bool reserved() { return cast(bool)(_bf & 0x20); }
+    ubyte cbFrame() { return cast(ubyte)(_bf >> 6); }
+
+    ubyte cbRegs(ubyte c) {
+        _bf = cast(ubyte) ((_bf & ~0x07) | (c & 0x07));
+        return cast(ubyte)(c & 0x07);
+    }
+
+    bool fHasSEH(bool f)  { _bf = cast(ubyte)((_bf & ~0x08) | (f << 3)); return f; }
+    bool fUseBP(bool f)   { _bf = cast(ubyte)((_bf & ~0x10) | (f << 4)); return f; }
+    bool reserved(bool r) { _bf = cast(ubyte)((_bf & ~0x20) | (r << 5)); return r; }
+
+    ubyte cbFrame(ubyte c) {
+        _bf = cast(ubyte) ((_bf & ~0xC0) | ((c & 0x03) << 6));
+        return cast(ubyte)(c & 0x03);
+    }
+}
+alias FPO_DATA* PFPO_DATA;
+
+struct IMAGE_DEBUG_MISC {
+    DWORD   DataType;
+    DWORD   Length;
+    BOOLEAN Unicode;
+    BYTE[3] Reserved;
+    BYTE    _Data;
+
+    BYTE*   Data() return { return &_Data; }
+}
+alias IMAGE_DEBUG_MISC* PIMAGE_DEBUG_MISC;
+
+struct IMAGE_FUNCTION_ENTRY {
+    DWORD StartingAddress;
+    DWORD EndingAddress;
+    DWORD EndOfPrologue;
+}
+alias IMAGE_FUNCTION_ENTRY* PIMAGE_FUNCTION_ENTRY;
+
+struct IMAGE_FUNCTION_ENTRY64 {
+    ULONGLONG     StartingAddress;
+    ULONGLONG     EndingAddress;
+    union {
+        ULONGLONG EndOfPrologue;
+        ULONGLONG UnwindInfoAddress;
+    }
+}
+alias IMAGE_FUNCTION_ENTRY64* PIMAGE_FUNCTION_ENTRY64;
+
+struct IMAGE_SEPARATE_DEBUG_HEADER {
+    WORD     Signature;
+    WORD     Flags;
+    WORD     Machine;
+    WORD     Characteristics;
+    DWORD    TimeDateStamp;
+    DWORD    CheckSum;
+    DWORD    ImageBase;
+    DWORD    SizeOfImage;
+    DWORD    NumberOfSections;
+    DWORD    ExportedNamesSize;
+    DWORD    DebugDirectorySize;
+    DWORD    SectionAlignment;
+    DWORD[2] Reserved;
+}
+alias IMAGE_SEPARATE_DEBUG_HEADER* PIMAGE_SEPARATE_DEBUG_HEADER;
+
+enum SERVICE_NODE_TYPE {
+    DriverType               = SERVICE_KERNEL_DRIVER,
+    FileSystemType           = SERVICE_FILE_SYSTEM_DRIVER,
+    Win32ServiceOwnProcess   = SERVICE_WIN32_OWN_PROCESS,
+    Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS,
+    AdapterType              = SERVICE_ADAPTER,
+    RecognizerType           = SERVICE_RECOGNIZER_DRIVER
+}
+
+enum SERVICE_LOAD_TYPE {
+    BootLoad    = SERVICE_BOOT_START,
+    SystemLoad  = SERVICE_SYSTEM_START,
+    AutoLoad    = SERVICE_AUTO_START,
+    DemandLoad  = SERVICE_DEMAND_START,
+    DisableLoad = SERVICE_DISABLED
+}
+
+enum SERVICE_ERROR_TYPE {
+    IgnoreError   = SERVICE_ERROR_IGNORE,
+    NormalError   = SERVICE_ERROR_NORMAL,
+    SevereError   = SERVICE_ERROR_SEVERE,
+    CriticalError = SERVICE_ERROR_CRITICAL
+}
+alias SERVICE_ERROR_TYPE _CM_ERROR_CONTROL_TYPE;
+
+//DAC: According to MSJ, 'UnderTheHood', May 1996, this
+// structure is not documented in any official Microsoft header file.
+alias void EXCEPTION_REGISTRATION_RECORD;
+
+align:
+struct NT_TIB {
+    EXCEPTION_REGISTRATION_RECORD *ExceptionList;
+    PVOID StackBase;
+    PVOID StackLimit;
+    PVOID SubSystemTib;
+    union {
+        PVOID FiberData;
+        DWORD Version;
+    }
+    PVOID ArbitraryUserPointer;
+    NT_TIB *Self;
+}
+alias NT_TIB* PNT_TIB;
+
+struct REPARSE_DATA_BUFFER {
+    DWORD  ReparseTag;
+    WORD   ReparseDataLength;
+    WORD   Reserved;
+    union {
+        struct _GenericReparseBuffer {
+            BYTE  _DataBuffer;
+
+            BYTE* DataBuffer() return { return &_DataBuffer; }
+        }
+        _GenericReparseBuffer GenericReparseBuffer;
+        struct _SymbolicLinkReparseBuffer {
+            WORD  SubstituteNameOffset;
+            WORD  SubstituteNameLength;
+            WORD  PrintNameOffset;
+            WORD  PrintNameLength;
+            // ??? This is in MinGW, but absent in MSDN docs
+            ULONG Flags;
+            WCHAR _PathBuffer;
+
+            WCHAR* PathBuffer() return { return &_PathBuffer; }
+        }
+        _SymbolicLinkReparseBuffer SymbolicLinkReparseBuffer;
+        struct _MountPointReparseBuffer {
+            WORD  SubstituteNameOffset;
+            WORD  SubstituteNameLength;
+            WORD  PrintNameOffset;
+            WORD  PrintNameLength;
+            WCHAR _PathBuffer;
+
+            WCHAR* PathBuffer() return { return &_PathBuffer; }
+        }
+        _MountPointReparseBuffer MountPointReparseBuffer;
+    }
+}
+alias REPARSE_DATA_BUFFER *PREPARSE_DATA_BUFFER;
+
+struct REPARSE_GUID_DATA_BUFFER {
+    DWORD    ReparseTag;
+    WORD     ReparseDataLength;
+    WORD     Reserved;
+    GUID     ReparseGuid;
+    struct _GenericReparseBuffer {
+        BYTE _DataBuffer;
+
+        BYTE* DataBuffer() return { return &_DataBuffer; }
+    }
+    _GenericReparseBuffer GenericReparseBuffer;
+}
+alias REPARSE_GUID_DATA_BUFFER* PREPARSE_GUID_DATA_BUFFER;
+
+enum size_t
+    REPARSE_DATA_BUFFER_HEADER_SIZE = REPARSE_DATA_BUFFER.GenericReparseBuffer.offsetof,
+    REPARSE_GUID_DATA_BUFFER_HEADER_SIZE = REPARSE_GUID_DATA_BUFFER.GenericReparseBuffer.offsetof,
+    MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16384;
+
+
+struct REPARSE_POINT_INFORMATION {
+    WORD ReparseDataLength;
+    WORD UnparsedNameLength;
+}
+alias REPARSE_POINT_INFORMATION* PREPARSE_POINT_INFORMATION;
+
+union FILE_SEGMENT_ELEMENT {
+    PVOID64   Buffer;
+    ULONGLONG Alignment;
+}
+alias FILE_SEGMENT_ELEMENT* PFILE_SEGMENT_ELEMENT;
+
+// JOBOBJECT_BASIC_LIMIT_INFORMATION.LimitFlags constants
+enum DWORD
+    JOB_OBJECT_LIMIT_WORKINGSET                 = 0x0001,
+    JOB_OBJECT_LIMIT_PROCESS_TIME               = 0x0002,
+    JOB_OBJECT_LIMIT_JOB_TIME                   = 0x0004,
+    JOB_OBJECT_LIMIT_ACTIVE_PROCESS             = 0x0008,
+    JOB_OBJECT_LIMIT_AFFINITY                   = 0x0010,
+    JOB_OBJECT_LIMIT_PRIORITY_CLASS             = 0x0020,
+    JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME          = 0x0040,
+    JOB_OBJECT_LIMIT_SCHEDULING_CLASS           = 0x0080,
+    JOB_OBJECT_LIMIT_PROCESS_MEMORY             = 0x0100,
+    JOB_OBJECT_LIMIT_JOB_MEMORY                 = 0x0200,
+    JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION = 0x0400,
+    JOB_OBJECT_BREAKAWAY_OK                     = 0x0800,
+    JOB_OBJECT_SILENT_BREAKAWAY                 = 0x1000;
+
+// JOBOBJECT_BASIC_UI_RESTRICTIONS.UIRestrictionsClass constants
+enum DWORD
+    JOB_OBJECT_UILIMIT_HANDLES          = 0x0001,
+    JOB_OBJECT_UILIMIT_READCLIPBOARD    = 0x0002,
+    JOB_OBJECT_UILIMIT_WRITECLIPBOARD   = 0x0004,
+    JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS = 0x0008,
+    JOB_OBJECT_UILIMIT_DISPLAYSETTINGS  = 0x0010,
+    JOB_OBJECT_UILIMIT_GLOBALATOMS      = 0x0020,
+    JOB_OBJECT_UILIMIT_DESKTOP          = 0x0040,
+    JOB_OBJECT_UILIMIT_EXITWINDOWS      = 0x0080;
+
+// JOBOBJECT_SECURITY_LIMIT_INFORMATION.SecurityLimitFlags constants
+enum DWORD
+    JOB_OBJECT_SECURITY_NO_ADMIN         = 0x0001,
+    JOB_OBJECT_SECURITY_RESTRICTED_TOKEN = 0x0002,
+    JOB_OBJECT_SECURITY_ONLY_TOKEN       = 0x0004,
+    JOB_OBJECT_SECURITY_FILTER_TOKENS    = 0x0008;
+
+// JOBOBJECT_END_OF_JOB_TIME_INFORMATION.EndOfJobTimeAction constants
+enum : DWORD {
+    JOB_OBJECT_TERMINATE_AT_END_OF_JOB,
+    JOB_OBJECT_POST_AT_END_OF_JOB
+}
+
+enum : DWORD {
+    JOB_OBJECT_MSG_END_OF_JOB_TIME = 1,
+    JOB_OBJECT_MSG_END_OF_PROCESS_TIME,
+    JOB_OBJECT_MSG_ACTIVE_PROCESS_LIMIT,
+    JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO,
+    JOB_OBJECT_MSG_NEW_PROCESS,
+    JOB_OBJECT_MSG_EXIT_PROCESS,
+    JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS,
+    JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT,
+    JOB_OBJECT_MSG_JOB_MEMORY_LIMIT
+}
+
+enum JOBOBJECTINFOCLASS {
+    JobObjectBasicAccountingInformation = 1,
+    JobObjectBasicLimitInformation,
+    JobObjectBasicProcessIdList,
+    JobObjectBasicUIRestrictions,
+    JobObjectSecurityLimitInformation,
+    JobObjectEndOfJobTimeInformation,
+    JobObjectAssociateCompletionPortInformation,
+    JobObjectBasicAndIoAccountingInformation,
+    JobObjectExtendedLimitInformation,
+    JobObjectJobSetInformation,
+    MaxJobObjectInfoClass
+}
+
+struct JOBOBJECT_BASIC_ACCOUNTING_INFORMATION {
+    LARGE_INTEGER TotalUserTime;
+    LARGE_INTEGER TotalKernelTime;
+    LARGE_INTEGER ThisPeriodTotalUserTime;
+    LARGE_INTEGER ThisPeriodTotalKernelTime;
+    DWORD         TotalPageFaultCount;
+    DWORD         TotalProcesses;
+    DWORD         ActiveProcesses;
+    DWORD         TotalTerminatedProcesses;
+}
+alias JOBOBJECT_BASIC_ACCOUNTING_INFORMATION* PJOBOBJECT_BASIC_ACCOUNTING_INFORMATION;
+
+struct JOBOBJECT_BASIC_LIMIT_INFORMATION {
+    LARGE_INTEGER PerProcessUserTimeLimit;
+    LARGE_INTEGER PerJobUserTimeLimit;
+    DWORD         LimitFlags;
+    SIZE_T        MinimumWorkingSetSize;
+    SIZE_T        MaximumWorkingSetSize;
+    DWORD         ActiveProcessLimit;
+    ULONG_PTR     Affinity;
+    DWORD         PriorityClass;
+    DWORD         SchedulingClass;
+}
+alias JOBOBJECT_BASIC_LIMIT_INFORMATION* PJOBOBJECT_BASIC_LIMIT_INFORMATION;
+
+struct JOBOBJECT_BASIC_PROCESS_ID_LIST {
+    DWORD     NumberOfAssignedProcesses;
+    DWORD     NumberOfProcessIdsInList;
+    ULONG_PTR _ProcessIdList;
+
+    ULONG_PTR* ProcessIdList() return { return &_ProcessIdList; }
+}
+alias JOBOBJECT_BASIC_PROCESS_ID_LIST* PJOBOBJECT_BASIC_PROCESS_ID_LIST;
+
+struct JOBOBJECT_BASIC_UI_RESTRICTIONS {
+    DWORD UIRestrictionsClass;
+}
+alias JOBOBJECT_BASIC_UI_RESTRICTIONS* PJOBOBJECT_BASIC_UI_RESTRICTIONS;
+
+struct JOBOBJECT_SECURITY_LIMIT_INFORMATION {
+    DWORD             SecurityLimitFlags;
+    HANDLE            JobToken;
+    PTOKEN_GROUPS     SidsToDisable;
+    PTOKEN_PRIVILEGES PrivilegesToDelete;
+    PTOKEN_GROUPS     RestrictedSids;
+}
+alias JOBOBJECT_SECURITY_LIMIT_INFORMATION* PJOBOBJECT_SECURITY_LIMIT_INFORMATION;
+
+struct JOBOBJECT_END_OF_JOB_TIME_INFORMATION {
+    DWORD EndOfJobTimeAction;
+}
+alias JOBOBJECT_END_OF_JOB_TIME_INFORMATION* PJOBOBJECT_END_OF_JOB_TIME_INFORMATION;
+
+struct JOBOBJECT_ASSOCIATE_COMPLETION_PORT {
+    PVOID  CompletionKey;
+    HANDLE CompletionPort;
+}
+alias JOBOBJECT_ASSOCIATE_COMPLETION_PORT* PJOBOBJECT_ASSOCIATE_COMPLETION_PORT;
+
+struct JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION {
+    JOBOBJECT_BASIC_ACCOUNTING_INFORMATION BasicInfo;
+    IO_COUNTERS IoInfo;
+}
+alias JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION *PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION;
+
+struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION {
+    JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
+    IO_COUNTERS IoInfo;
+    SIZE_T      ProcessMemoryLimit;
+    SIZE_T      JobMemoryLimit;
+    SIZE_T      PeakProcessMemoryUsed;
+    SIZE_T      PeakJobMemoryUsed;
+}
+alias JOBOBJECT_EXTENDED_LIMIT_INFORMATION* PJOBOBJECT_EXTENDED_LIMIT_INFORMATION;
+
+struct JOBOBJECT_JOBSET_INFORMATION {
+    DWORD MemberLevel;
+}
+alias JOBOBJECT_JOBSET_INFORMATION* PJOBOBJECT_JOBSET_INFORMATION;
+
+// MinGW: Making these defines conditional on _WIN32_WINNT will break ddk includes
+//static if (_WIN32_WINNT >= 0x500) {
+
+enum DWORD
+    ES_SYSTEM_REQUIRED  = 0x00000001,
+    ES_DISPLAY_REQUIRED = 0x00000002,
+    ES_USER_PRESENT     = 0x00000004,
+    ES_CONTINUOUS       = 0x80000000;
+
+enum LATENCY_TIME {
+    LT_DONT_CARE,
+    LT_LOWEST_LATENCY
+}
+alias LATENCY_TIME* PLATENCY_TIME;
+
+enum SYSTEM_POWER_STATE {
+    PowerSystemUnspecified,
+    PowerSystemWorking,
+    PowerSystemSleeping1,
+    PowerSystemSleeping2,
+    PowerSystemSleeping3,
+    PowerSystemHibernate,
+    PowerSystemShutdown,
+    PowerSystemMaximum
+}
+alias SYSTEM_POWER_STATE* PSYSTEM_POWER_STATE;
+
+enum POWER_SYSTEM_MAXIMUM = SYSTEM_POWER_STATE.PowerSystemMaximum;
+
+enum POWER_ACTION {
+    PowerActionNone,
+    PowerActionReserved,
+    PowerActionSleep,
+    PowerActionHibernate,
+    PowerActionShutdown,
+    PowerActionShutdownReset,
+    PowerActionShutdownOff,
+    PowerActionWarmEject
+}
+alias POWER_ACTION* PPOWER_ACTION;
+
+static if (_WIN32_WINNT >= 0x600) {
+    enum SYSTEM_POWER_CONDITION {
+        PoAc,
+        PoDc,
+        PoHot,
+        PoConditionMaximum
+    }
+    alias SYSTEM_POWER_CONDITION* PSYSTEM_POWER_CONDITION;
+}
+
+enum DEVICE_POWER_STATE {
+    PowerDeviceUnspecified,
+    PowerDeviceD0,
+    PowerDeviceD1,
+    PowerDeviceD2,
+    PowerDeviceD3,
+    PowerDeviceMaximum
+}
+alias DEVICE_POWER_STATE* PDEVICE_POWER_STATE;
+
+align(4):
+struct BATTERY_REPORTING_SCALE {
+    DWORD Granularity;
+    DWORD Capacity;
+}
+alias BATTERY_REPORTING_SCALE* PBATTERY_REPORTING_SCALE;
+
+struct POWER_ACTION_POLICY {
+    POWER_ACTION Action;
+    ULONG        Flags;
+    ULONG        EventCode;
+}
+alias POWER_ACTION_POLICY* PPOWER_ACTION_POLICY;
+
+// POWER_ACTION_POLICY.Flags constants
+enum ULONG
+    POWER_ACTION_QUERY_ALLOWED  = 0x00000001,
+    POWER_ACTION_UI_ALLOWED     = 0x00000002,
+    POWER_ACTION_OVERRIDE_APPS  = 0x00000004,
+    POWER_ACTION_LIGHTEST_FIRST = 0x10000000,
+    POWER_ACTION_LOCK_CONSOLE   = 0x20000000,
+    POWER_ACTION_DISABLE_WAKES  = 0x40000000,
+    POWER_ACTION_CRITICAL       = 0x80000000;
+
+// POWER_ACTION_POLICY.EventCode constants
+enum ULONG
+    POWER_LEVEL_USER_NOTIFY_TEXT  = 0x00000001,
+    POWER_LEVEL_USER_NOTIFY_SOUND = 0x00000002,
+    POWER_LEVEL_USER_NOTIFY_EXEC  = 0x00000004,
+    POWER_USER_NOTIFY_BUTTON      = 0x00000008,
+    POWER_USER_NOTIFY_SHUTDOWN    = 0x00000010,
+    POWER_FORCE_TRIGGER_RESET     = 0x80000000;
+
+enum size_t
+    DISCHARGE_POLICY_CRITICAL = 0,
+    DISCHARGE_POLICY_LOW      = 1,
+    NUM_DISCHARGE_POLICIES    = 4;
+
+enum : BYTE {
+    PO_THROTTLE_NONE,
+    PO_THROTTLE_CONSTANT,
+    PO_THROTTLE_DEGRADE,
+    PO_THROTTLE_ADAPTIVE,
+    PO_THROTTLE_MAXIMUM
+}
+
+struct SYSTEM_POWER_LEVEL {
+    BOOLEAN             Enable;
+    UCHAR[3]            Spare;
+    ULONG               BatteryLevel;
+    POWER_ACTION_POLICY PowerPolicy;
+    SYSTEM_POWER_STATE  MinSystemState;
+}
+alias SYSTEM_POWER_LEVEL* PSYSTEM_POWER_LEVEL;
+
+struct SYSTEM_POWER_POLICY {
+    ULONG               Revision;
+    POWER_ACTION_POLICY PowerButton;
+    POWER_ACTION_POLICY SleepButton;
+    POWER_ACTION_POLICY LidClose;
+    SYSTEM_POWER_STATE  LidOpenWake;
+    ULONG               Reserved;
+    POWER_ACTION_POLICY Idle;
+    ULONG               IdleTimeout;
+    UCHAR               IdleSensitivity;
+    UCHAR               DynamicThrottle;
+    UCHAR[2]            Spare2;
+    SYSTEM_POWER_STATE  MinSleep;
+    SYSTEM_POWER_STATE  MaxSleep;
+    SYSTEM_POWER_STATE  ReducedLatencySleep;
+    ULONG               WinLogonFlags;
+    ULONG               Spare3;
+    ULONG               DozeS4Timeout;
+    ULONG               BroadcastCapacityResolution;
+    SYSTEM_POWER_LEVEL[NUM_DISCHARGE_POLICIES] DischargePolicy;
+    ULONG               VideoTimeout;
+    BOOLEAN             VideoDimDisplay;
+    ULONG[3]            VideoReserved;
+    ULONG               SpindownTimeout;
+    BOOLEAN             OptimizeForPower;
+    UCHAR               FanThrottleTolerance;
+    UCHAR               ForcedThrottle;
+    UCHAR               MinThrottle;
+    POWER_ACTION_POLICY OverThrottled;
+}
+alias SYSTEM_POWER_POLICY* PSYSTEM_POWER_POLICY;
+
+struct SYSTEM_POWER_CAPABILITIES {
+    BOOLEAN                    PowerButtonPresent;
+    BOOLEAN                    SleepButtonPresent;
+    BOOLEAN                    LidPresent;
+    BOOLEAN                    SystemS1;
+    BOOLEAN                    SystemS2;
+    BOOLEAN                    SystemS3;
+    BOOLEAN                    SystemS4;
+    BOOLEAN                    SystemS5;
+    BOOLEAN                    HiberFilePresent;
+    BOOLEAN                    FullWake;
+    BOOLEAN                    VideoDimPresent;
+    BOOLEAN                    ApmPresent;
+    BOOLEAN                    UpsPresent;
+    BOOLEAN                    ThermalControl;
+    BOOLEAN                    ProcessorThrottle;
+    UCHAR                      ProcessorMinThrottle;
+    UCHAR                      ProcessorMaxThrottle;
+    UCHAR[4]                   spare2;
+    BOOLEAN                    DiskSpinDown;
+    UCHAR[8]                   spare3;
+    BOOLEAN                    SystemBatteriesPresent;
+    BOOLEAN                    BatteriesAreShortTerm;
+    BATTERY_REPORTING_SCALE[3] BatteryScale;
+    SYSTEM_POWER_STATE         AcOnLineWake;
+    SYSTEM_POWER_STATE         SoftLidWake;
+    SYSTEM_POWER_STATE         RtcWake;
+    SYSTEM_POWER_STATE         MinDeviceWakeState;
+    SYSTEM_POWER_STATE         DefaultLowLatencyWake;
+}
+alias SYSTEM_POWER_CAPABILITIES* PSYSTEM_POWER_CAPABILITIES;
+
+struct SYSTEM_BATTERY_STATE {
+    BOOLEAN    AcOnLine;
+    BOOLEAN    BatteryPresent;
+    BOOLEAN    Charging;
+    BOOLEAN    Discharging;
+    BOOLEAN[4] Spare1;
+    ULONG      MaxCapacity;
+    ULONG      RemainingCapacity;
+    ULONG      Rate;
+    ULONG      EstimatedTime;
+    ULONG      DefaultAlert1;
+    ULONG      DefaultAlert2;
+}
+alias SYSTEM_BATTERY_STATE* PSYSTEM_BATTERY_STATE;
+
+enum POWER_INFORMATION_LEVEL {
+    SystemPowerPolicyAc,
+    SystemPowerPolicyDc,
+    VerifySystemPolicyAc,
+    VerifySystemPolicyDc,
+    SystemPowerCapabilities,
+    SystemBatteryState,
+    SystemPowerStateHandler,
+    ProcessorStateHandler,
+    SystemPowerPolicyCurrent,
+    AdministratorPowerPolicy,
+    SystemReserveHiberFile,
+    ProcessorInformation,
+    SystemPowerInformation,
+    ProcessorStateHandler2,
+    LastWakeTime,
+    LastSleepTime,
+    SystemExecutionState,
+    SystemPowerStateNotifyHandler,
+    ProcessorPowerPolicyAc,
+    ProcessorPowerPolicyDc,
+    VerifyProcessorPowerPolicyAc,
+    VerifyProcessorPowerPolicyDc,
+    ProcessorPowerPolicyCurrent
+}
+
+//#if 1 /* (WIN32_WINNT >= 0x0500) */
+struct SYSTEM_POWER_INFORMATION {
+    ULONG MaxIdlenessAllowed;
+    ULONG Idleness;
+    ULONG TimeRemaining;
+    UCHAR CoolingMode;
+}
+alias SYSTEM_POWER_INFORMATION* PSYSTEM_POWER_INFORMATION;
+//#endif
+
+struct PROCESSOR_POWER_POLICY_INFO {
+    ULONG    TimeCheck;
+    ULONG    DemoteLimit;
+    ULONG    PromoteLimit;
+    UCHAR    DemotePercent;
+    UCHAR    PromotePercent;
+    UCHAR[2] Spare;
+    uint     _bf;
+
+    bool AllowDemotion()  { return cast(bool)(_bf & 1); }
+    bool AllowPromotion() { return cast(bool)(_bf & 2); }
+
+    bool AllowDemotion(bool a)  { _bf = (_bf & ~1) | a; return a; }
+    bool AllowPromotion(bool a) { _bf = (_bf & ~2) | (a << 1); return a; }
+/+
+    ULONG  AllowDemotion : 1;
+    ULONG  AllowPromotion : 1;
+    ULONG  Reserved : 30;
++/
+}
+alias PROCESSOR_POWER_POLICY_INFO* PPROCESSOR_POWER_POLICY_INFO;
+
+struct PROCESSOR_POWER_POLICY {
+    ULONG    Revision;
+    UCHAR    DynamicThrottle;
+    UCHAR[3] Spare;
+    ULONG    Reserved;
+    ULONG    PolicyCount;
+    PROCESSOR_POWER_POLICY_INFO[3] Policy;
+}
+alias PROCESSOR_POWER_POLICY* PPROCESSOR_POWER_POLICY;
+
+struct ADMINISTRATOR_POWER_POLICY {
+    SYSTEM_POWER_STATE MinSleep;
+    SYSTEM_POWER_STATE MaxSleep;
+    ULONG              MinVideoTimeout;
+    ULONG              MaxVideoTimeout;
+    ULONG              MinSpindownTimeout;
+    ULONG              MaxSpindownTimeout;
+}
+alias ADMINISTRATOR_POWER_POLICY* PADMINISTRATOR_POWER_POLICY;
+
+//}//#endif /* _WIN32_WINNT >= 0x500 */
+
+extern (Windows) {
+    alias void function(PVOID, DWORD, PVOID) PIMAGE_TLS_CALLBACK;
+
+    static if (_WIN32_WINNT >= 0x500) {
+        alias LONG function(PEXCEPTION_POINTERS) PVECTORED_EXCEPTION_HANDLER;
+        alias void function(PVOID, BOOLEAN) WAITORTIMERCALLBACKFUNC;
+    }
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum HEAP_INFORMATION_CLASS {
+        HeapCompatibilityInformation
+    }
+
+    enum ACTIVATION_CONTEXT_INFO_CLASS {
+        ActivationContextBasicInformation = 1,
+        ActivationContextDetailedInformation,
+        AssemblyDetailedInformationInActivationContext,
+        FileInformationInAssemblyOfAssemblyInActivationContext
+    }
+
+    struct ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION {
+        DWORD         ulFlags;
+        DWORD         ulEncodedAssemblyIdentityLength;
+        DWORD         ulManifestPathType;
+        DWORD         ulManifestPathLength;
+        LARGE_INTEGER liManifestLastWriteTime;
+        DWORD         ulPolicyPathType;
+        DWORD         ulPolicyPathLength;
+        LARGE_INTEGER liPolicyLastWriteTime;
+        DWORD         ulMetadataSatelliteRosterIndex;
+        DWORD         ulManifestVersionMajor;
+        DWORD         ulManifestVersionMinor;
+        DWORD         ulPolicyVersionMajor;
+        DWORD         ulPolicyVersionMinor;
+        DWORD         ulAssemblyDirectoryNameLength;
+        PCWSTR        lpAssemblyEncodedAssemblyIdentity;
+        PCWSTR        lpAssemblyManifestPath;
+        PCWSTR        lpAssemblyPolicyPath;
+        PCWSTR        lpAssemblyDirectoryName;
+    }
+    alias ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION*
+      PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
+    alias const(ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION)*
+      PCACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
+
+    struct ACTIVATION_CONTEXT_DETAILED_INFORMATION {
+        DWORD  dwFlags;
+        DWORD  ulFormatVersion;
+        DWORD  ulAssemblyCount;
+        DWORD  ulRootManifestPathType;
+        DWORD  ulRootManifestPathChars;
+        DWORD  ulRootConfigurationPathType;
+        DWORD  ulRootConfigurationPathChars;
+        DWORD  ulAppDirPathType;
+        DWORD  ulAppDirPathChars;
+        PCWSTR lpRootManifestPath;
+        PCWSTR lpRootConfigurationPath;
+        PCWSTR lpAppDirPath;
+    }
+    alias ACTIVATION_CONTEXT_DETAILED_INFORMATION*
+      PACTIVATION_CONTEXT_DETAILED_INFORMATION;
+    alias const(ACTIVATION_CONTEXT_DETAILED_INFORMATION)*
+      PCACTIVATION_CONTEXT_DETAILED_INFORMATION;
+
+    struct ACTIVATION_CONTEXT_QUERY_INDEX {
+        ULONG ulAssemblyIndex;
+        ULONG ulFileIndexInAssembly;
+    }
+    alias ACTIVATION_CONTEXT_QUERY_INDEX*        PACTIVATION_CONTEXT_QUERY_INDEX;
+    alias const(ACTIVATION_CONTEXT_QUERY_INDEX)* PCACTIVATION_CONTEXT_QUERY_INDEX;
+
+    struct ASSEMBLY_FILE_DETAILED_INFORMATION {
+        DWORD  ulFlags;
+        DWORD  ulFilenameLength;
+        DWORD  ulPathLength;
+        PCWSTR lpFileName;
+        PCWSTR lpFilePath;
+    }
+    alias ASSEMBLY_FILE_DETAILED_INFORMATION*
+      PASSEMBLY_FILE_DETAILED_INFORMATION;
+    alias const(ASSEMBLY_FILE_DETAILED_INFORMATION)*
+      PCASSEMBLY_FILE_DETAILED_INFORMATION;
+}
+
+version (Unicode) {
+    alias OSVERSIONINFOW OSVERSIONINFO;
+    alias OSVERSIONINFOEXW OSVERSIONINFOEX;
+} else {
+    alias OSVERSIONINFOA OSVERSIONINFO;
+    alias OSVERSIONINFOEXA OSVERSIONINFOEX;
+}
+
+alias OSVERSIONINFO*   POSVERSIONINFO,   LPOSVERSIONINFO;
+alias OSVERSIONINFOEX* POSVERSIONINFOEX, LPOSVERSIONINFOEX;
+
+
+static if (_WIN32_WINNT >= 0x500) {
+    extern (Windows) ULONGLONG VerSetConditionMask(ULONGLONG, DWORD, BYTE);
+}
+
+version (Win64) {
+enum WORD IMAGE_NT_OPTIONAL_HDR_MAGIC = IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+
+    alias IMAGE_ORDINAL_FLAG64 IMAGE_ORDINAL_FLAG;
+    alias IMAGE_SNAP_BY_ORDINAL64 IMAGE_SNAP_BY_ORDINAL;
+    alias IMAGE_ORDINAL64 IMAGE_ORDINAL;
+    alias IMAGE_OPTIONAL_HEADER64 IMAGE_OPTIONAL_HEADER;
+    alias IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
+    alias IMAGE_THUNK_DATA64 IMAGE_THUNK_DATA;
+    alias IMAGE_TLS_DIRECTORY64 IMAGE_TLS_DIRECTORY;
+} else {
+enum WORD IMAGE_NT_OPTIONAL_HDR_MAGIC = IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+
+    alias IMAGE_ORDINAL_FLAG32 IMAGE_ORDINAL_FLAG;
+    alias IMAGE_ORDINAL32 IMAGE_ORDINAL;
+    alias IMAGE_SNAP_BY_ORDINAL32 IMAGE_SNAP_BY_ORDINAL;
+    alias IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER;
+    alias IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
+    alias IMAGE_THUNK_DATA32 IMAGE_THUNK_DATA;
+    alias IMAGE_TLS_DIRECTORY32 IMAGE_TLS_DIRECTORY;
+}
+
+alias IMAGE_OPTIONAL_HEADER* PIMAGE_OPTIONAL_HEADER;
+alias IMAGE_NT_HEADERS* PIMAGE_NT_HEADERS;
+alias IMAGE_THUNK_DATA* PIMAGE_THUNK_DATA;
+alias IMAGE_TLS_DIRECTORY* PIMAGE_TLS_DIRECTORY;
+
+// TODO: MinGW implements these in assembly.  How to translate?
+PVOID GetCurrentFiber();
+PVOID GetFiberData();
diff --git a/libphobos/libdruntime/core/sys/windows/winperf.d b/libphobos/libdruntime/core/sys/windows/winperf.d
new file mode 100644
index 00000000000..d00f829f35a
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winperf.d
@@ -0,0 +1,152 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winperf.d)
+ */
+module core.sys.windows.winperf;
+version (Windows):
+
+import core.sys.windows.windef;
+import core.sys.windows.winbase; // for SYSTEMTIME
+
+enum PERF_DATA_VERSION=1;
+enum PERF_DATA_REVISION=1;
+enum PERF_NO_INSTANCES=-1;
+enum PERF_SIZE_DWORD=0;
+enum PERF_SIZE_LARGE=256;
+enum PERF_SIZE_ZERO=512;
+enum PERF_SIZE_VARIABLE_LEN=768;
+enum PERF_TYPE_NUMBER=0;
+enum PERF_TYPE_COUNTER=1024;
+enum PERF_TYPE_TEXT=2048;
+enum PERF_TYPE_ZERO=0xC00;
+enum PERF_NUMBER_HEX=0;
+enum PERF_NUMBER_DECIMAL=0x10000;
+enum PERF_NUMBER_DEC_1000=0x20000;
+enum PERF_COUNTER_VALUE=0;
+enum PERF_COUNTER_RATE=0x10000;
+enum PERF_COUNTER_FRACTION=0x20000;
+enum PERF_COUNTER_BASE=0x30000;
+enum PERF_COUNTER_ELAPSED=0x40000;
+enum PERF_COUNTER_QUEUELEN=0x50000;
+enum PERF_COUNTER_HISTOGRAM=0x60000;
+enum PERF_TEXT_UNICODE=0;
+enum PERF_TEXT_ASCII=0x10000;
+enum PERF_TIMER_TICK=0;
+enum PERF_TIMER_100NS=0x100000;
+enum PERF_OBJECT_TIMER=0x200000;
+enum PERF_DELTA_COUNTER=0x400000;
+enum PERF_DELTA_BASE=0x800000;
+enum PERF_INVERSE_COUNTER=0x1000000;
+enum PERF_MULTI_COUNTER=0x2000000;
+enum PERF_DISPLAY_NO_SUFFIX=0;
+enum PERF_DISPLAY_PER_SEC=0x10000000;
+enum PERF_DISPLAY_PERCENT=0x20000000;
+enum PERF_DISPLAY_SECONDS=0x30000000;
+enum PERF_DISPLAY_NOSHOW=0x40000000;
+enum PERF_COUNTER_HISTOGRAM_TYPE=0x80000000;
+enum PERF_NO_UNIQUE_ID=(-1);
+enum PERF_DETAIL_NOVICE=100;
+enum PERF_DETAIL_ADVANCED=200;
+enum PERF_DETAIL_EXPERT=300;
+enum PERF_DETAIL_WIZARD=400;
+enum PERF_COUNTER_COUNTER=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_TICK|PERF_DELTA_COUNTER|PERF_DISPLAY_PER_SEC);
+enum PERF_COUNTER_TIMER=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_TICK|PERF_DELTA_COUNTER|PERF_DISPLAY_PERCENT);
+enum PERF_COUNTER_QUEUELEN_TYPE=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_QUEUELEN|PERF_TIMER_TICK|PERF_DELTA_COUNTER|PERF_DISPLAY_NO_SUFFIX);
+enum PERF_COUNTER_BULK_COUNT=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_TICK|PERF_DELTA_COUNTER|PERF_DISPLAY_PER_SEC);
+enum PERF_COUNTER_TEXT=(PERF_SIZE_VARIABLE_LEN|PERF_TYPE_TEXT|PERF_TEXT_UNICODE|PERF_DISPLAY_NO_SUFFIX);
+enum PERF_COUNTER_RAWCOUNT=(PERF_SIZE_DWORD|PERF_TYPE_NUMBER|PERF_NUMBER_DECIMAL|PERF_DISPLAY_NO_SUFFIX);
+enum PERF_COUNTER_LARGE_RAWCOUNT=(PERF_SIZE_LARGE|PERF_TYPE_NUMBER|PERF_NUMBER_DECIMAL|PERF_DISPLAY_NO_SUFFIX);
+enum PERF_COUNTER_RAWCOUNT_HEX=(PERF_SIZE_DWORD|PERF_TYPE_NUMBER|PERF_NUMBER_HEX|PERF_DISPLAY_NO_SUFFIX);
+enum PERF_COUNTER_LARGE_RAWCOUNT_HEX=(PERF_SIZE_LARGE|PERF_TYPE_NUMBER|PERF_NUMBER_HEX|PERF_DISPLAY_NO_SUFFIX);
+enum PERF_SAMPLE_FRACTION=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_FRACTION|PERF_DELTA_COUNTER|PERF_DELTA_BASE|PERF_DISPLAY_PERCENT);
+enum PERF_SAMPLE_COUNTER=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_TICK|PERF_DELTA_COUNTER|PERF_DISPLAY_NO_SUFFIX);
+enum PERF_COUNTER_NODATA=(PERF_SIZE_ZERO|PERF_DISPLAY_NOSHOW);
+enum PERF_COUNTER_TIMER_INV=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_TICK|PERF_DELTA_COUNTER|PERF_INVERSE_COUNTER|PERF_DISPLAY_PERCENT);
+enum PERF_SAMPLE_BASE=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_BASE|PERF_DISPLAY_NOSHOW|1);
+enum PERF_AVERAGE_TIMER=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_FRACTION|PERF_DISPLAY_SECONDS);
+enum PERF_AVERAGE_BASE=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_BASE|PERF_DISPLAY_NOSHOW|2);
+enum PERF_AVERAGE_BULK=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_FRACTION|PERF_DISPLAY_NOSHOW);
+enum PERF_100NSEC_TIMER=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_100NS|PERF_DELTA_COUNTER|PERF_DISPLAY_PERCENT);
+enum PERF_100NSEC_TIMER_INV=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_100NS|PERF_DELTA_COUNTER|PERF_INVERSE_COUNTER|PERF_DISPLAY_PERCENT);
+enum PERF_COUNTER_MULTI_TIMER=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_DELTA_COUNTER|PERF_TIMER_TICK|PERF_MULTI_COUNTER|PERF_DISPLAY_PERCENT);
+enum PERF_COUNTER_MULTI_TIMER_INV=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_RATE|PERF_DELTA_COUNTER|PERF_MULTI_COUNTER|PERF_TIMER_TICK|PERF_INVERSE_COUNTER|PERF_DISPLAY_PERCENT);
+enum PERF_COUNTER_MULTI_BASE=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_BASE|PERF_MULTI_COUNTER|PERF_DISPLAY_NOSHOW);
+enum PERF_100NSEC_MULTI_TIMER=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_DELTA_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_100NS|PERF_MULTI_COUNTER|PERF_DISPLAY_PERCENT);
+enum PERF_100NSEC_MULTI_TIMER_INV=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_DELTA_COUNTER|PERF_COUNTER_RATE|PERF_TIMER_100NS|PERF_MULTI_COUNTER|PERF_INVERSE_COUNTER|PERF_DISPLAY_PERCENT);
+enum PERF_RAW_FRACTION=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_FRACTION|PERF_DISPLAY_PERCENT);
+enum PERF_RAW_BASE=(PERF_SIZE_DWORD|PERF_TYPE_COUNTER|PERF_COUNTER_BASE|PERF_DISPLAY_NOSHOW|3);
+enum PERF_ELAPSED_TIME=(PERF_SIZE_LARGE|PERF_TYPE_COUNTER|PERF_COUNTER_ELAPSED|PERF_OBJECT_TIMER|PERF_DISPLAY_SECONDS);
+
+struct PERF_DATA_BLOCK {
+    WCHAR[4] Signature;
+    DWORD LittleEndian;
+    DWORD Version;
+    DWORD Revision;
+    DWORD TotalByteLength;
+    DWORD HeaderLength;
+    DWORD NumObjectTypes;
+    LONG DefaultObject;
+    SYSTEMTIME SystemTime;
+    LARGE_INTEGER PerfTime;
+    LARGE_INTEGER PerfFreq;
+    LARGE_INTEGER PerfTime100nSec;
+    DWORD SystemNameLength;
+    DWORD SystemNameOffset;
+}
+alias PERF_DATA_BLOCK * PPERF_DATA_BLOCK;
+
+struct PERF_OBJECT_TYPE {
+    DWORD TotalByteLength;
+    DWORD DefinitionLength;
+    DWORD HeaderLength;
+    DWORD ObjectNameTitleIndex;
+    LPWSTR ObjectNameTitle;
+    DWORD ObjectHelpTitleIndex;
+    LPWSTR ObjectHelpTitle;
+    DWORD DetailLevel;
+    DWORD NumCounters;
+    LONG DefaultCounter;
+    LONG NumInstances;
+    DWORD CodePage;
+    LARGE_INTEGER PerfTime;
+    LARGE_INTEGER PerfFreq;
+}
+alias PERF_OBJECT_TYPE * PPERF_OBJECT_TYPE;
+
+struct PERF_COUNTER_DEFINITION {
+    DWORD ByteLength;
+    DWORD CounterNameTitleIndex;
+    LPWSTR CounterNameTitle;
+    DWORD CounterHelpTitleIndex;
+    LPWSTR CounterHelpTitle;
+    LONG DefaultScale;
+    DWORD DetailLevel;
+    DWORD CounterType;
+    DWORD CounterSize;
+    DWORD CounterOffset;
+}
+alias PERF_COUNTER_DEFINITION * PPERF_COUNTER_DEFINITION;
+
+struct PERF_INSTANCE_DEFINITION {
+    DWORD ByteLength;
+    DWORD ParentObjectTitleIndex;
+    DWORD ParentObjectInstance;
+    LONG UniqueID;
+    DWORD NameOffset;
+    DWORD NameLength;
+}
+alias PERF_INSTANCE_DEFINITION * PPERF_INSTANCE_DEFINITION;
+
+struct PERF_COUNTER_BLOCK {
+    DWORD ByteLength;
+}
+alias PERF_COUNTER_BLOCK * PPERF_COUNTER_BLOCK;
+
+extern (Windows):
+alias DWORD function (LPWSTR) PM_OPEN_PROC;
+alias DWORD function (LPWSTR,PVOID*,PDWORD,PDWORD) PM_COLLECT_PROC;
+alias DWORD function () PM_CLOSE_PROC;
diff --git a/libphobos/libdruntime/core/sys/windows/winreg.d b/libphobos/libdruntime/core/sys/windows/winreg.d
new file mode 100644
index 00000000000..12ac849001a
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winreg.d
@@ -0,0 +1,255 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winreg.d)
+ */
+module core.sys.windows.winreg;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "advapi32");
+
+private import core.sys.windows.w32api, core.sys.windows.winbase, core.sys.windows.windef;
+
+enum : HKEY { // for some reason, DMD errors if I don't give all the values explicitly
+    HKEY_CLASSES_ROOT        = cast(HKEY) 0x80000000,
+    HKEY_CURRENT_USER        = cast(HKEY) 0x80000001,
+    HKEY_LOCAL_MACHINE       = cast(HKEY) 0x80000002,
+    HKEY_USERS               = cast(HKEY) 0x80000003,
+    HKEY_PERFORMANCE_DATA    = cast(HKEY) 0x80000004,
+    HKEY_CURRENT_CONFIG      = cast(HKEY) 0x80000005,
+    HKEY_DYN_DATA            = cast(HKEY) 0x80000006,
+    HKEY_PERFORMANCE_TEXT    = cast(HKEY) 0x80000050,
+    HKEY_PERFORMANCE_NLSTEXT = cast(HKEY) 0x80000060,
+}
+
+//enum : DWORD {
+//    REG_OPTION_NON_VOLATILE,
+//    REG_OPTION_VOLATILE
+//}
+
+enum : DWORD {
+    REG_CREATED_NEW_KEY = 1,
+    REG_OPENED_EXISTING_KEY
+}
+
+enum : DWORD {
+    REG_NONE                       = 0,
+    REG_SZ,
+    REG_EXPAND_SZ,
+    REG_BINARY,
+    REG_DWORD_LITTLE_ENDIAN,
+    REG_DWORD                      = REG_DWORD_LITTLE_ENDIAN,
+    REG_DWORD_BIG_ENDIAN,
+    REG_LINK,
+    REG_MULTI_SZ,
+    REG_RESOURCE_LIST,
+    REG_FULL_RESOURCE_DESCRIPTOR,
+    REG_RESOURCE_REQUIREMENTS_LIST,
+    REG_QWORD_LITTLE_ENDIAN,
+    REG_QWORD                      = REG_QWORD_LITTLE_ENDIAN
+}
+
+enum DWORD
+    REG_NOTIFY_CHANGE_NAME       = 1,
+    REG_NOTIFY_CHANGE_ATTRIBUTES = 2,
+    REG_NOTIFY_CHANGE_LAST_SET   = 4,
+    REG_NOTIFY_CHANGE_SECURITY   = 8;
+
+alias ACCESS_MASK REGSAM;
+
+struct VALENTA {
+    LPSTR ve_valuename;
+    DWORD ve_valuelen;
+    DWORD ve_valueptr;
+    DWORD ve_type;
+}
+alias VALENTA* PVALENTA;
+
+struct VALENTW {
+    LPWSTR ve_valuename;
+    DWORD  ve_valuelen;
+    DWORD  ve_valueptr;
+    DWORD  ve_type;
+}
+alias VALENTW* PVALENTW;
+
+// RRF - Registry Routine Flags (for RegGetValue)
+static if (_WIN32_WINNT >= 0x600) {
+    enum : DWORD {
+        RRF_RT_REG_NONE      = 0x00000001,
+        RRF_RT_REG_SZ        = 0x00000002,
+        RRF_RT_REG_EXPAND_SZ = 0x00000004,
+        RRF_RT_REG_BINARY    = 0x00000008,
+        RRF_RT_REG_DWORD     = 0x00000010,
+        RRF_RT_REG_MULTI_SZ  = 0x00000020,
+        RRF_RT_REG_QWORD     = 0x00000040,
+        RRF_RT_DWORD         = RRF_RT_REG_BINARY | RRF_RT_REG_DWORD,
+        RRF_RT_QWORD         = RRF_RT_REG_BINARY | RRF_RT_REG_QWORD,
+        RRF_RT_ANY           = 0x0000FFFF,
+        RRF_NOEXPAND         = 0x10000000,
+        RRF_ZEROONFAILURE    = 0x20000000
+    }
+}
+
+extern (Windows) nothrow @nogc {
+    LONG RegCloseKey(in HKEY);
+    LONG RegConnectRegistryA(LPCSTR, HKEY, PHKEY);
+    LONG RegConnectRegistryW(LPCWSTR, HKEY, PHKEY);
+    LONG RegCreateKeyExA(in HKEY, LPCSTR, DWORD, LPSTR, DWORD, REGSAM,
+      LPSECURITY_ATTRIBUTES, PHKEY, PDWORD);
+    LONG RegCreateKeyExW(in HKEY, LPCWSTR, DWORD, LPWSTR, DWORD, REGSAM,
+      LPSECURITY_ATTRIBUTES, PHKEY, PDWORD);
+    LONG RegDeleteKeyA(in HKEY, LPCSTR);
+    LONG RegDeleteKeyW(in HKEY, LPCWSTR);
+    LONG RegDeleteValueA(in HKEY, LPCSTR);
+    LONG RegDeleteValueW(in HKEY, LPCWSTR);
+    LONG RegEnumKeyExA(in HKEY, DWORD, LPSTR, PDWORD, PDWORD, LPSTR, PDWORD,
+      PFILETIME);
+    LONG RegEnumKeyExW(in HKEY, DWORD, LPWSTR, PDWORD, PDWORD, LPWSTR, PDWORD,
+      PFILETIME);
+    LONG RegEnumValueA(in HKEY, DWORD, LPSTR, PDWORD, PDWORD, PDWORD, LPBYTE,
+      PDWORD);
+    LONG RegEnumValueW(in HKEY, DWORD, LPWSTR, PDWORD, PDWORD, PDWORD, LPBYTE,
+      PDWORD);
+    LONG RegFlushKey(in HKEY);
+    LONG RegLoadKeyA(in HKEY, LPCSTR, LPCSTR);
+    LONG RegLoadKeyW(in HKEY, LPCWSTR, LPCWSTR);
+    LONG RegOpenKeyExA(in HKEY, LPCSTR, DWORD, REGSAM, PHKEY);
+    LONG RegOpenKeyExW(in HKEY, LPCWSTR, DWORD, REGSAM, PHKEY);
+    LONG RegQueryInfoKeyA(in HKEY, LPSTR, PDWORD, PDWORD, PDWORD, PDWORD,
+      PDWORD, PDWORD, PDWORD, PDWORD, PDWORD, PFILETIME);
+    LONG RegQueryInfoKeyW(in HKEY, LPWSTR, PDWORD, PDWORD, PDWORD, PDWORD,
+      PDWORD, PDWORD, PDWORD, PDWORD, PDWORD, PFILETIME);
+    LONG RegQueryMultipleValuesA(in HKEY, PVALENTA, DWORD, LPSTR, LPDWORD);
+    LONG RegQueryMultipleValuesW(in HKEY, PVALENTW, DWORD, LPWSTR, LPDWORD);
+    LONG RegQueryValueExA(in HKEY, LPCSTR, LPDWORD, LPDWORD, /*LPBYTE*/LPVOID, LPDWORD);
+    LONG RegQueryValueExW(in HKEY, LPCWSTR, LPDWORD, LPDWORD, /*LPBYTE*/LPVOID, LPDWORD);
+    LONG RegReplaceKeyA(in HKEY, LPCSTR, LPCSTR, LPCSTR);
+    LONG RegReplaceKeyW(in HKEY, LPCWSTR, LPCWSTR, LPCWSTR);
+    LONG RegSaveKeyA(in HKEY, LPCSTR, LPSECURITY_ATTRIBUTES);
+    LONG RegSaveKeyW(in HKEY, LPCWSTR, LPSECURITY_ATTRIBUTES);
+    LONG RegSetKeySecurity(in HKEY, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
+    LONG RegSetValueExA(in HKEY, LPCSTR, DWORD, DWORD, const(BYTE)*, DWORD);
+    LONG RegSetValueExW(in HKEY, LPCWSTR, DWORD, DWORD, const(BYTE)*, DWORD);
+    LONG RegUnLoadKeyA(in HKEY, LPCSTR);
+    LONG RegUnLoadKeyW(in HKEY, LPCWSTR);
+    LONG RegNotifyChangeKeyValue(in HKEY, BOOL, DWORD, HANDLE, BOOL);
+
+    BOOL AbortSystemShutdownA(LPCSTR);
+    BOOL AbortSystemShutdownW(LPCWSTR);
+    BOOL InitiateSystemShutdownA(LPSTR, LPSTR, DWORD, BOOL, BOOL);
+    BOOL InitiateSystemShutdownW(LPWSTR, LPWSTR, DWORD, BOOL, BOOL);
+    LONG RegGetKeySecurity(in HKEY, SECURITY_INFORMATION,
+      PSECURITY_DESCRIPTOR, PDWORD);
+    LONG RegRestoreKeyA(in HKEY, LPCSTR, DWORD);
+    LONG RegRestoreKeyW(in HKEY, LPCWSTR, DWORD);
+    LONG RegSetKeySecurity(in HKEY, SECURITY_INFORMATION,
+      PSECURITY_DESCRIPTOR);
+
+    static if (_WIN32_WINNT >= 0x500) {
+        LONG RegDisablePredefinedCache();
+        LONG RegOpenCurrentUser(REGSAM, PHKEY);
+        LONG RegOpenUserClassesRoot(HANDLE, DWORD, REGSAM, PHKEY);
+    }
+
+    static if (_WIN32_WINNT >= 0x501) {
+        LONG RegSaveKeyExA(in HKEY, LPCSTR, LPSECURITY_ATTRIBUTES, DWORD);
+        LONG RegSaveKeyExW(in HKEY, LPCWSTR, LPSECURITY_ATTRIBUTES, DWORD);
+    }
+
+    static if (_WIN32_WINNT >= 0x600) {
+        LONG RegGetValueA(in HKEY hkey, LPCSTR lpSubKey, LPCSTR lpValue,
+          DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData);
+        LONG RegGetValueW(in HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue,
+          DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData);
+    }
+
+    //deprecated {
+        LONG RegCreateKeyA(in HKEY, LPCSTR, PHKEY);
+        LONG RegCreateKeyW(in HKEY, LPCWSTR, PHKEY);
+        LONG RegEnumKeyA(in HKEY, DWORD, LPSTR, DWORD);
+        LONG RegEnumKeyW(in HKEY, DWORD, LPWSTR, DWORD);
+        LONG RegOpenKeyA(in HKEY, LPCSTR, PHKEY);
+        LONG RegOpenKeyW(in HKEY, LPCWSTR, PHKEY);
+        LONG RegQueryValueA(in HKEY, LPCSTR, LPSTR, PLONG);
+        LONG RegQueryValueW(in HKEY, LPCWSTR, LPWSTR, PLONG);
+        LONG RegSetValueA(in HKEY, LPCSTR, DWORD, LPCSTR, DWORD);
+        LONG RegSetValueW(in HKEY, LPCWSTR, DWORD, LPCWSTR, DWORD);
+    //}
+}
+
+version (Unicode) {
+    alias VALENTW VALENT;
+    alias RegConnectRegistryW RegConnectRegistry;
+    alias RegCreateKeyExW RegCreateKeyEx;
+    alias RegDeleteKeyW RegDeleteKey;
+    alias RegDeleteValueW RegDeleteValue;
+    alias RegEnumKeyExW RegEnumKeyEx;
+    alias RegEnumValueW RegEnumValue;
+    alias RegLoadKeyW RegLoadKey;
+    alias RegOpenKeyExW RegOpenKeyEx;
+    alias RegQueryInfoKeyW RegQueryInfoKey;
+    alias RegQueryMultipleValuesW RegQueryMultipleValues;
+    alias RegQueryValueExW RegQueryValueEx;
+    alias RegReplaceKeyW RegReplaceKey;
+    alias RegSaveKeyW RegSaveKey;
+    alias RegSetValueExW RegSetValueEx;
+    alias RegUnLoadKeyW RegUnLoadKey;
+
+    alias AbortSystemShutdownW AbortSystemShutdown;
+    alias InitiateSystemShutdownW InitiateSystemShutdown;
+    alias RegRestoreKeyW RegRestoreKey;
+    static if (_WIN32_WINNT >= 0x501) {
+        alias RegSaveKeyExA RegSaveKeyEx;
+    }
+    static if (_WIN32_WINNT >= 0x600) {
+        alias RegGetValueW RegGetValue;
+    }
+    //deprecated {
+        alias RegCreateKeyW RegCreateKey;
+        alias RegEnumKeyW RegEnumKey;
+        alias RegOpenKeyW RegOpenKey;
+        alias RegQueryValueW RegQueryValue;
+        alias RegSetValueW RegSetValue;
+    //}
+} else {
+    alias VALENTA VALENT;
+    alias RegConnectRegistryA RegConnectRegistry;
+    alias RegCreateKeyExA RegCreateKeyEx;
+    alias RegDeleteKeyA RegDeleteKey;
+    alias RegDeleteValueA RegDeleteValue;
+    alias RegEnumKeyExA RegEnumKeyEx;
+    alias RegEnumValueA RegEnumValue;
+    alias RegLoadKeyA RegLoadKey;
+    alias RegOpenKeyExA RegOpenKeyEx;
+    alias RegQueryInfoKeyA RegQueryInfoKey;
+    alias RegQueryMultipleValuesA RegQueryMultipleValues;
+    alias RegQueryValueExA RegQueryValueEx;
+    alias RegReplaceKeyA RegReplaceKey;
+    alias RegSaveKeyA RegSaveKey;
+    alias RegSetValueExA RegSetValueEx;
+    alias RegUnLoadKeyA RegUnLoadKey;
+    alias AbortSystemShutdownA AbortSystemShutdown;
+    alias InitiateSystemShutdownA InitiateSystemShutdown;
+    alias RegRestoreKeyW RegRestoreKey;
+    static if (_WIN32_WINNT >= 0x501) {
+        alias RegSaveKeyExA RegSaveKeyEx;
+    }
+    static if (_WIN32_WINNT >= 0x600) {
+        alias RegGetValueA RegGetValue;
+    }
+    //deprecated {
+        alias RegCreateKeyA RegCreateKey;
+        alias RegEnumKeyA RegEnumKey;
+        alias RegOpenKeyA RegOpenKey;
+        alias RegQueryValueA RegQueryValue;
+        alias RegSetValueA RegSetValue;
+    //}
+}
+
+alias VALENT* PVALENT;
diff --git a/libphobos/libdruntime/core/sys/windows/winsock2.d b/libphobos/libdruntime/core/sys/windows/winsock2.d
new file mode 100644
index 00000000000..8706e1b0fb3
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winsock2.d
@@ -0,0 +1,762 @@
+/*
+    Written by Christopher E. Miller
+    $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+*/
+
+
+module core.sys.windows.winsock2;
+version (Windows):
+
+extern(Windows):
+nothrow:
+
+alias SOCKET = size_t;
+alias socklen_t = int;
+
+enum SOCKET INVALID_SOCKET = cast(SOCKET)~0;
+enum int SOCKET_ERROR = -1;
+
+enum WSADESCRIPTION_LEN = 256;
+enum WSASYS_STATUS_LEN = 128;
+
+struct WSADATA
+{
+    ushort wVersion;
+    ushort wHighVersion;
+    char[WSADESCRIPTION_LEN + 1] szDescription;
+    char[WSASYS_STATUS_LEN + 1] szSystemStatus;
+    ushort iMaxSockets;
+    ushort iMaxUdpDg;
+    char* lpVendorInfo;
+}
+alias LPWSADATA = WSADATA*;
+
+
+enum int IOCPARM_MASK =  0x7F;
+enum int IOC_IN =        cast(int)0x80000000;
+enum int FIONBIO =       cast(int)(IOC_IN | ((uint.sizeof & IOCPARM_MASK) << 16) | (102 << 8) | 126);
+
+enum NI_MAXHOST = 1025;
+enum NI_MAXSERV = 32;
+
+@nogc
+{
+int WSAStartup(ushort wVersionRequested, LPWSADATA lpWSAData);
+int WSACleanup();
+SOCKET socket(int af, int type, int protocol);
+int ioctlsocket(SOCKET s, int cmd, uint* argp);
+int bind(SOCKET s, const(sockaddr)* name, socklen_t namelen);
+int connect(SOCKET s, const(sockaddr)* name, socklen_t namelen);
+int listen(SOCKET s, int backlog);
+SOCKET accept(SOCKET s, sockaddr* addr, socklen_t* addrlen);
+int closesocket(SOCKET s);
+int shutdown(SOCKET s, int how);
+int getpeername(SOCKET s, sockaddr* name, socklen_t* namelen);
+int getsockname(SOCKET s, sockaddr* name, socklen_t* namelen);
+int send(SOCKET s, const(void)* buf, int len, int flags);
+int sendto(SOCKET s, const(void)* buf, int len, int flags, const(sockaddr)* to, socklen_t tolen);
+int recv(SOCKET s, void* buf, int len, int flags);
+int recvfrom(SOCKET s, void* buf, int len, int flags, sockaddr* from, socklen_t* fromlen);
+int getsockopt(SOCKET s, int level, int optname, void* optval, socklen_t* optlen);
+int setsockopt(SOCKET s, int level, int optname, const(void)* optval, socklen_t optlen);
+uint inet_addr(const char* cp);
+int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* errorfds, const(timeval)* timeout);
+char* inet_ntoa(in_addr ina);
+hostent* gethostbyname(const char* name);
+hostent* gethostbyaddr(const(void)* addr, int len, int type);
+protoent* getprotobyname(const char* name);
+protoent* getprotobynumber(int number);
+servent* getservbyname(const char* name, const char* proto);
+servent* getservbyport(int port, const char* proto);
+}
+
+enum: int
+{
+    NI_NOFQDN =          0x01,
+    NI_NUMERICHOST =     0x02,
+    NI_NAMEREQD =        0x04,
+    NI_NUMERICSERV =     0x08,
+    NI_DGRAM  =          0x10,
+}
+
+@nogc
+{
+int gethostname(const char* name, int namelen);
+int getaddrinfo(const(char)* nodename, const(char)* servname, const(addrinfo)* hints, addrinfo** res);
+void freeaddrinfo(addrinfo* ai);
+int getnameinfo(const(sockaddr)* sa, socklen_t salen, char* host, uint hostlen, char* serv, uint servlen, int flags);
+}
+
+enum WSABASEERR = 10000;
+
+enum: int
+{
+    /*
+     * Windows Sockets definitions of regular Microsoft C error constants
+     */
+    WSAEINTR = (WSABASEERR+4),
+    WSAEBADF = (WSABASEERR+9),
+    WSAEACCES = (WSABASEERR+13),
+    WSAEFAULT = (WSABASEERR+14),
+    WSAEINVAL = (WSABASEERR+22),
+    WSAEMFILE = (WSABASEERR+24),
+
+    /*
+     * Windows Sockets definitions of regular Berkeley error constants
+     */
+    WSAEWOULDBLOCK = (WSABASEERR+35),
+    WSAEINPROGRESS = (WSABASEERR+36),
+    WSAEALREADY = (WSABASEERR+37),
+    WSAENOTSOCK = (WSABASEERR+38),
+    WSAEDESTADDRREQ = (WSABASEERR+39),
+    WSAEMSGSIZE = (WSABASEERR+40),
+    WSAEPROTOTYPE = (WSABASEERR+41),
+    WSAENOPROTOOPT = (WSABASEERR+42),
+    WSAEPROTONOSUPPORT = (WSABASEERR+43),
+    WSAESOCKTNOSUPPORT = (WSABASEERR+44),
+    WSAEOPNOTSUPP = (WSABASEERR+45),
+    WSAEPFNOSUPPORT = (WSABASEERR+46),
+    WSAEAFNOSUPPORT = (WSABASEERR+47),
+    WSAEADDRINUSE = (WSABASEERR+48),
+    WSAEADDRNOTAVAIL = (WSABASEERR+49),
+    WSAENETDOWN = (WSABASEERR+50),
+    WSAENETUNREACH = (WSABASEERR+51),
+    WSAENETRESET = (WSABASEERR+52),
+    WSAECONNABORTED = (WSABASEERR+53),
+    WSAECONNRESET = (WSABASEERR+54),
+    WSAENOBUFS = (WSABASEERR+55),
+    WSAEISCONN = (WSABASEERR+56),
+    WSAENOTCONN = (WSABASEERR+57),
+    WSAESHUTDOWN = (WSABASEERR+58),
+    WSAETOOMANYREFS = (WSABASEERR+59),
+    WSAETIMEDOUT = (WSABASEERR+60),
+    WSAECONNREFUSED = (WSABASEERR+61),
+    WSAELOOP = (WSABASEERR+62),
+    WSAENAMETOOLONG = (WSABASEERR+63),
+    WSAEHOSTDOWN = (WSABASEERR+64),
+    WSAEHOSTUNREACH = (WSABASEERR+65),
+    WSAENOTEMPTY = (WSABASEERR+66),
+    WSAEPROCLIM = (WSABASEERR+67),
+    WSAEUSERS = (WSABASEERR+68),
+    WSAEDQUOT = (WSABASEERR+69),
+    WSAESTALE = (WSABASEERR+70),
+    WSAEREMOTE = (WSABASEERR+71),
+
+    /*
+     * Extended Windows Sockets error constant definitions
+     */
+    WSASYSNOTREADY = (WSABASEERR+91),
+    WSAVERNOTSUPPORTED = (WSABASEERR+92),
+    WSANOTINITIALISED = (WSABASEERR+93),
+
+    /* Authoritative Answer: Host not found */
+    WSAHOST_NOT_FOUND = (WSABASEERR+1001),
+    HOST_NOT_FOUND = WSAHOST_NOT_FOUND,
+
+    /* Non-Authoritative: Host not found, or SERVERFAIL */
+    WSATRY_AGAIN = (WSABASEERR+1002),
+    TRY_AGAIN = WSATRY_AGAIN,
+
+    /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
+    WSANO_RECOVERY = (WSABASEERR+1003),
+    NO_RECOVERY = WSANO_RECOVERY,
+
+    /* Valid name, no data record of requested type */
+    WSANO_DATA = (WSABASEERR+1004),
+    NO_DATA = WSANO_DATA,
+
+    /* no address, look for MX record */
+    WSANO_ADDRESS = WSANO_DATA,
+    NO_ADDRESS = WSANO_ADDRESS
+}
+
+/*
+ * Windows Sockets errors redefined as regular Berkeley error constants
+ */
+enum: int
+{
+    EWOULDBLOCK = WSAEWOULDBLOCK,
+    EINPROGRESS = WSAEINPROGRESS,
+    EALREADY = WSAEALREADY,
+    ENOTSOCK = WSAENOTSOCK,
+    EDESTADDRREQ = WSAEDESTADDRREQ,
+    EMSGSIZE = WSAEMSGSIZE,
+    EPROTOTYPE = WSAEPROTOTYPE,
+    ENOPROTOOPT = WSAENOPROTOOPT,
+    EPROTONOSUPPORT = WSAEPROTONOSUPPORT,
+    ESOCKTNOSUPPORT = WSAESOCKTNOSUPPORT,
+    EOPNOTSUPP = WSAEOPNOTSUPP,
+    EPFNOSUPPORT = WSAEPFNOSUPPORT,
+    EAFNOSUPPORT = WSAEAFNOSUPPORT,
+    EADDRINUSE = WSAEADDRINUSE,
+    EADDRNOTAVAIL = WSAEADDRNOTAVAIL,
+    ENETDOWN = WSAENETDOWN,
+    ENETUNREACH = WSAENETUNREACH,
+    ENETRESET = WSAENETRESET,
+    ECONNABORTED = WSAECONNABORTED,
+    ECONNRESET = WSAECONNRESET,
+    ENOBUFS = WSAENOBUFS,
+    EISCONN = WSAEISCONN,
+    ENOTCONN = WSAENOTCONN,
+    ESHUTDOWN = WSAESHUTDOWN,
+    ETOOMANYREFS = WSAETOOMANYREFS,
+    ETIMEDOUT = WSAETIMEDOUT,
+    ECONNREFUSED = WSAECONNREFUSED,
+    ELOOP = WSAELOOP,
+    ENAMETOOLONG = WSAENAMETOOLONG,
+    EHOSTDOWN = WSAEHOSTDOWN,
+    EHOSTUNREACH = WSAEHOSTUNREACH,
+    ENOTEMPTY = WSAENOTEMPTY,
+    EPROCLIM = WSAEPROCLIM,
+    EUSERS = WSAEUSERS,
+    EDQUOT = WSAEDQUOT,
+    ESTALE = WSAESTALE,
+    EREMOTE = WSAEREMOTE
+}
+
+enum: int
+{
+    EAI_NONAME    = WSAHOST_NOT_FOUND,
+}
+
+int WSAGetLastError() @trusted @nogc;
+
+
+enum: int
+{
+    AF_UNSPEC =     0,
+
+    AF_UNIX =       1,
+    AF_INET =       2,
+    AF_IMPLINK =    3,
+    AF_PUP =        4,
+    AF_CHAOS =      5,
+    AF_NS =         6,
+    AF_IPX =        AF_NS,
+    AF_ISO =        7,
+    AF_OSI =        AF_ISO,
+    AF_ECMA =       8,
+    AF_DATAKIT =    9,
+    AF_CCITT =      10,
+    AF_SNA =        11,
+    AF_DECnet =     12,
+    AF_DLI =        13,
+    AF_LAT =        14,
+    AF_HYLINK =     15,
+    AF_APPLETALK =  16,
+    AF_NETBIOS =    17,
+    AF_VOICEVIEW =  18,
+    AF_FIREFOX =    19,
+    AF_UNKNOWN1 =   20,
+    AF_BAN =        21,
+    AF_ATM =        22,
+    AF_INET6 =      23,
+    AF_CLUSTER =    24,
+    AF_12844 =      25,
+    AF_IRDA =       26,
+    AF_NETDES =     28,
+
+    AF_MAX =        29,
+
+
+    PF_UNSPEC     = AF_UNSPEC,
+
+    PF_UNIX =       AF_UNIX,
+    PF_INET =       AF_INET,
+    PF_IMPLINK =    AF_IMPLINK,
+    PF_PUP =        AF_PUP,
+    PF_CHAOS =      AF_CHAOS,
+    PF_NS =         AF_NS,
+    PF_IPX =        AF_IPX,
+    PF_ISO =        AF_ISO,
+    PF_OSI =        AF_OSI,
+    PF_ECMA =       AF_ECMA,
+    PF_DATAKIT =    AF_DATAKIT,
+    PF_CCITT =      AF_CCITT,
+    PF_SNA =        AF_SNA,
+    PF_DECnet =     AF_DECnet,
+    PF_DLI =        AF_DLI,
+    PF_LAT =        AF_LAT,
+    PF_HYLINK =     AF_HYLINK,
+    PF_APPLETALK =  AF_APPLETALK,
+    PF_VOICEVIEW =  AF_VOICEVIEW,
+    PF_FIREFOX =    AF_FIREFOX,
+    PF_UNKNOWN1 =   AF_UNKNOWN1,
+    PF_BAN =        AF_BAN,
+    PF_INET6 =      AF_INET6,
+
+    PF_MAX        = AF_MAX,
+}
+
+
+enum: int
+{
+    SOL_SOCKET = 0xFFFF,
+}
+
+
+enum: int
+{
+    SO_DEBUG =        0x0001,
+    SO_ACCEPTCONN =   0x0002,
+    SO_REUSEADDR =    0x0004,
+    SO_KEEPALIVE =    0x0008,
+    SO_DONTROUTE =    0x0010,
+    SO_BROADCAST =    0x0020,
+    SO_USELOOPBACK =  0x0040,
+    SO_LINGER =       0x0080,
+    SO_DONTLINGER =   ~SO_LINGER,
+    SO_OOBINLINE =    0x0100,
+    SO_SNDBUF =       0x1001,
+    SO_RCVBUF =       0x1002,
+    SO_SNDLOWAT =     0x1003,
+    SO_RCVLOWAT =     0x1004,
+    SO_SNDTIMEO =     0x1005,
+    SO_RCVTIMEO =     0x1006,
+    SO_ERROR =        0x1007,
+    SO_TYPE =         0x1008,
+    SO_EXCLUSIVEADDRUSE = ~SO_REUSEADDR,
+
+    TCP_NODELAY =    1,
+
+    IP_OPTIONS                  = 1,
+
+    IP_HDRINCL                  = 2,
+    IP_TOS                      = 3,
+    IP_TTL                      = 4,
+    IP_MULTICAST_IF             = 9,
+    IP_MULTICAST_TTL            = 10,
+    IP_MULTICAST_LOOP           = 11,
+    IP_ADD_MEMBERSHIP           = 12,
+    IP_DROP_MEMBERSHIP          = 13,
+    IP_DONTFRAGMENT             = 14,
+    IP_ADD_SOURCE_MEMBERSHIP    = 15,
+    IP_DROP_SOURCE_MEMBERSHIP   = 16,
+    IP_BLOCK_SOURCE             = 17,
+    IP_UNBLOCK_SOURCE           = 18,
+    IP_PKTINFO                  = 19,
+
+    IPV6_UNICAST_HOPS =    4,
+    IPV6_MULTICAST_IF =    9,
+    IPV6_MULTICAST_HOPS =  10,
+    IPV6_MULTICAST_LOOP =  11,
+    IPV6_ADD_MEMBERSHIP =  12,
+    IPV6_DROP_MEMBERSHIP = 13,
+    IPV6_JOIN_GROUP =      IPV6_ADD_MEMBERSHIP,
+    IPV6_LEAVE_GROUP =     IPV6_DROP_MEMBERSHIP,
+    IPV6_V6ONLY = 27,
+}
+
+
+/// Default FD_SETSIZE value.
+/// In C/C++, it is redefinable by #define-ing the macro before #include-ing
+/// winsock.h. In D, use the $(D FD_CREATE) function to allocate a $(D fd_set)
+/// of an arbitrary size.
+enum int FD_SETSIZE = 64;
+
+
+struct fd_set_custom(uint SETSIZE)
+{
+    uint fd_count;
+    SOCKET[SETSIZE] fd_array;
+}
+
+alias fd_set = fd_set_custom!FD_SETSIZE;
+
+// Removes.
+void FD_CLR(SOCKET fd, fd_set* set) pure @nogc
+{
+    uint c = set.fd_count;
+    SOCKET* start = set.fd_array.ptr;
+    SOCKET* stop = start + c;
+
+    for(; start != stop; start++)
+    {
+        if(*start == fd)
+            goto found;
+    }
+    return; //not found
+
+    found:
+    for(++start; start != stop; start++)
+    {
+        *(start - 1) = *start;
+    }
+
+    set.fd_count = c - 1;
+}
+
+
+// Tests.
+int FD_ISSET(SOCKET fd, const(fd_set)* set) pure @nogc
+{
+const(SOCKET)* start = set.fd_array.ptr;
+const(SOCKET)* stop = start + set.fd_count;
+
+    for(; start != stop; start++)
+    {
+        if(*start == fd)
+            return true;
+    }
+    return false;
+}
+
+
+// Adds.
+void FD_SET(SOCKET fd, fd_set* set)     pure @nogc
+{
+    uint c = set.fd_count;
+    set.fd_array.ptr[c] = fd;
+    set.fd_count = c + 1;
+}
+
+
+// Resets to zero.
+void FD_ZERO(fd_set* set) pure @nogc
+{
+    set.fd_count = 0;
+}
+
+
+/// Creates a new $(D fd_set) with the specified capacity.
+fd_set* FD_CREATE(uint capacity) pure
+{
+    // Take into account alignment (SOCKET may be 64-bit and require 64-bit alignment on 64-bit systems)
+    size_t size = (fd_set_custom!1).sizeof - SOCKET.sizeof + (SOCKET.sizeof * capacity);
+    auto data = new ubyte[size];
+    auto set = cast(fd_set*)data.ptr;
+    FD_ZERO(set);
+    return set;
+}
+
+struct linger
+{
+    ushort l_onoff;
+    ushort l_linger;
+}
+
+
+struct protoent
+{
+    char* p_name;
+    char** p_aliases;
+    short p_proto;
+}
+
+
+struct servent
+{
+    char* s_name;
+    char** s_aliases;
+
+    version (Win64)
+    {
+        char* s_proto;
+        short s_port;
+    }
+    else version (Win32)
+    {
+        short s_port;
+        char* s_proto;
+    }
+}
+
+
+/+
+union in6_addr
+{
+    private union _u_t
+    {
+        ubyte[16] Byte;
+        ushort[8] Word;
+    }
+    _u_t u;
+}
+
+
+struct in_addr6
+{
+    ubyte[16] s6_addr;
+}
++/
+
+@safe pure @nogc
+{
+
+version(BigEndian)
+{
+    ushort htons(ushort x)
+    {
+        return x;
+    }
+
+
+    uint htonl(uint x)
+    {
+        return x;
+    }
+}
+else version(LittleEndian)
+{
+    private import core.bitop;
+
+
+    ushort htons(ushort x)
+    {
+        return cast(ushort)((x >> 8) | (x << 8));
+    }
+
+
+    uint htonl(uint x)
+    {
+        return bswap(x);
+    }
+}
+else
+{
+    static assert(0);
+}
+
+
+ushort ntohs(ushort x)
+{
+    return htons(x);
+}
+
+
+uint ntohl(uint x)
+{
+    return htonl(x);
+}
+
+} // @safe pure @nogc
+
+
+enum: int
+{
+    SOCK_STREAM =     1,
+    SOCK_DGRAM =      2,
+    SOCK_RAW =        3,
+    SOCK_RDM =        4,
+    SOCK_SEQPACKET =  5,
+}
+
+
+enum: int
+{
+    IPPROTO_IP =    0,
+    IPPROTO_ICMP =  1,
+    IPPROTO_IGMP =  2,
+    IPPROTO_GGP =   3,
+    IPPROTO_TCP =   6,
+    IPPROTO_PUP =   12,
+    IPPROTO_UDP =   17,
+    IPPROTO_IDP =   22,
+    IPPROTO_IPV6 =  41,
+    IPPROTO_ND =    77,
+    IPPROTO_RAW =   255,
+
+    IPPROTO_MAX =   256,
+}
+
+
+enum: int
+{
+    MSG_OOB =        0x1,
+    MSG_PEEK =       0x2,
+    MSG_DONTROUTE =  0x4
+}
+
+
+enum: int
+{
+    SD_RECEIVE =  0,
+    SD_SEND =     1,
+    SD_BOTH =     2,
+}
+
+
+enum: uint
+{
+    INADDR_ANY =        0,
+    INADDR_LOOPBACK =   0x7F000001,
+    INADDR_BROADCAST =  0xFFFFFFFF,
+    INADDR_NONE =       0xFFFFFFFF,
+    ADDR_ANY =          INADDR_ANY,
+}
+
+
+enum: int
+{
+    AI_PASSIVE = 0x1,
+    AI_CANONNAME = 0x2,
+    AI_NUMERICHOST = 0x4,
+    AI_ADDRCONFIG = 0x0400,
+    AI_NON_AUTHORITATIVE = 0x04000,
+    AI_SECURE = 0x08000,
+    AI_RETURN_PREFERRED_NAMES = 0x010000,
+}
+
+
+struct timeval
+{
+    int tv_sec;
+    int tv_usec;
+}
+
+
+union in_addr
+{
+    private union _S_un_t
+    {
+        private struct _S_un_b_t
+        {
+            ubyte s_b1, s_b2, s_b3, s_b4;
+        }
+        _S_un_b_t S_un_b;
+
+        private struct _S_un_w_t
+        {
+            ushort s_w1, s_w2;
+        }
+        _S_un_w_t S_un_w;
+
+        uint S_addr;
+    }
+    _S_un_t S_un;
+
+    uint s_addr;
+
+    struct
+    {
+        ubyte s_net, s_host;
+
+        union
+        {
+            ushort s_imp;
+
+            struct
+            {
+                ubyte s_lh, s_impno;
+            }
+        }
+    }
+}
+
+
+union in6_addr
+{
+    private union _in6_u_t
+    {
+        ubyte[16] u6_addr8;
+        ushort[8] u6_addr16;
+        uint[4] u6_addr32;
+    }
+    _in6_u_t in6_u;
+
+    ubyte[16] s6_addr8;
+    ushort[8] s6_addr16;
+    uint[4] s6_addr32;
+
+    alias s6_addr = s6_addr8;
+}
+
+
+enum in6_addr IN6ADDR_ANY = { s6_addr8: [0] };
+enum in6_addr IN6ADDR_LOOPBACK = { s6_addr8: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] };
+//alias IN6ADDR_ANY_INIT = IN6ADDR_ANY;
+//alias IN6ADDR_LOOPBACK_INIT = IN6ADDR_LOOPBACK;
+
+enum int INET_ADDRSTRLEN = 16;
+enum int INET6_ADDRSTRLEN = 46;
+
+
+
+
+struct sockaddr
+{
+    short sa_family;
+    ubyte[14] sa_data;
+}
+alias sockaddr SOCKADDR;
+alias SOCKADDR* PSOCKADDR, LPSOCKADDR;
+
+struct SOCKADDR_STORAGE
+{
+    short     ss_family;
+    char[6]   __ss_pad1;
+    long      __ss_align;
+    char[112] __ss_pad2;
+}
+alias SOCKADDR_STORAGE* PSOCKADDR_STORAGE;
+
+struct sockaddr_in
+{
+    short sin_family = AF_INET;
+    ushort sin_port;
+    in_addr sin_addr;
+    ubyte[8] sin_zero;
+}
+alias sockaddr_in SOCKADDR_IN;
+alias SOCKADDR_IN* PSOCKADDR_IN, LPSOCKADDR_IN;
+
+
+struct sockaddr_in6
+{
+    short sin6_family = AF_INET6;
+    ushort sin6_port;
+    uint sin6_flowinfo;
+    in6_addr sin6_addr;
+    uint sin6_scope_id;
+}
+
+
+struct addrinfo
+{
+    int ai_flags;
+    int ai_family;
+    int ai_socktype;
+    int ai_protocol;
+    size_t ai_addrlen;
+    char* ai_canonname;
+    sockaddr* ai_addr;
+    addrinfo* ai_next;
+}
+
+
+struct hostent
+{
+    char* h_name;
+    char** h_aliases;
+    short h_addrtype;
+    short h_length;
+    char** h_addr_list;
+
+
+    char* h_addr() @safe pure nothrow @nogc
+    {
+        return h_addr_list[0];
+    }
+}
+
+// Note: These are Winsock2!!
+struct WSAOVERLAPPED;
+alias LPWSAOVERLAPPED = WSAOVERLAPPED*;
+alias LPWSAOVERLAPPED_COMPLETION_ROUTINE = void function(uint, uint, LPWSAOVERLAPPED, uint);
+int WSAIoctl(SOCKET s, uint dwIoControlCode,
+    void* lpvInBuffer, uint cbInBuffer,
+    void* lpvOutBuffer, uint cbOutBuffer,
+    uint* lpcbBytesReturned,
+    LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
+
+
+enum IOC_VENDOR = 0x18000000;
+enum SIO_KEEPALIVE_VALS = IOC_IN | IOC_VENDOR | 4;
+
+/* Argument structure for SIO_KEEPALIVE_VALS */
+struct tcp_keepalive
+{
+    uint onoff;
+    uint keepalivetime;
+    uint keepaliveinterval;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/winspool.d b/libphobos/libdruntime/core/sys/windows/winspool.d
new file mode 100644
index 00000000000..8d70c4f6717
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winspool.d
@@ -0,0 +1,963 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winspool.d)
+ */
+module core.sys.windows.winspool;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "winspool");
+
+private import core.sys.windows.w32api, core.sys.windows.windef, core.sys.windows.wingdi;
+private import core.sys.windows.winbase; // for SYSTEMTIME
+
+// FIXME: clean up Windows version support
+
+enum DI_CHANNEL=1;
+enum DI_CHANNEL_WRITE=2;
+enum DI_READ_SPOOL_JOB=3;
+
+enum FORM_BUILTIN=1;
+
+enum JOB_CONTROL_PAUSE=1;
+enum JOB_CONTROL_RESUME=2;
+enum JOB_CONTROL_CANCEL=3;
+enum JOB_CONTROL_RESTART=4;
+enum JOB_CONTROL_DELETE=5;
+enum JOB_STATUS_PAUSED=1;
+enum JOB_STATUS_ERROR=2;
+enum JOB_STATUS_DELETING=4;
+enum JOB_STATUS_SPOOLING=8;
+enum JOB_STATUS_PRINTING=16;
+enum JOB_STATUS_OFFLINE=32;
+enum JOB_STATUS_PAPEROUT=0x40;
+enum JOB_STATUS_PRINTED=0x80;
+enum JOB_STATUS_DELETED=0x100;
+enum JOB_STATUS_BLOCKED_DEVQ=0x200;
+enum JOB_STATUS_USER_INTERVENTION=0x400;
+
+enum JOB_POSITION_UNSPECIFIED=0;
+
+enum JOB_NOTIFY_TYPE=1;
+
+enum JOB_NOTIFY_FIELD_PRINTER_NAME=0;
+enum JOB_NOTIFY_FIELD_MACHINE_NAME=1;
+enum JOB_NOTIFY_FIELD_PORT_NAME=2;
+enum JOB_NOTIFY_FIELD_USER_NAME=3;
+enum JOB_NOTIFY_FIELD_NOTIFY_NAME=4;
+enum JOB_NOTIFY_FIELD_DATATYPE=5;
+enum JOB_NOTIFY_FIELD_PRINT_PROCESSOR=6;
+enum JOB_NOTIFY_FIELD_PARAMETERS=7;
+enum JOB_NOTIFY_FIELD_DRIVER_NAME=8;
+enum JOB_NOTIFY_FIELD_DEVMODE=9;
+enum JOB_NOTIFY_FIELD_STATUS=10;
+enum JOB_NOTIFY_FIELD_STATUS_STRING=11;
+enum JOB_NOTIFY_FIELD_SECURITY_DESCRIPTOR=12;
+enum JOB_NOTIFY_FIELD_DOCUMENT=13;
+enum JOB_NOTIFY_FIELD_PRIORITY=14;
+enum JOB_NOTIFY_FIELD_POSITION=15;
+enum JOB_NOTIFY_FIELD_SUBMITTED=16;
+enum JOB_NOTIFY_FIELD_START_TIME=17;
+enum JOB_NOTIFY_FIELD_UNTIL_TIME=18;
+enum JOB_NOTIFY_FIELD_TIME=19;
+enum JOB_NOTIFY_FIELD_TOTAL_PAGES=20;
+enum JOB_NOTIFY_FIELD_PAGES_PRINTED=21;
+enum JOB_NOTIFY_FIELD_TOTAL_BYTES=22;
+enum JOB_NOTIFY_FIELD_BYTES_PRINTED=23;
+
+enum JOB_ACCESS_ADMINISTER = 16;
+enum JOB_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | JOB_ACCESS_ADMINISTER;
+enum JOB_READ       = STANDARD_RIGHTS_READ     | JOB_ACCESS_ADMINISTER;
+enum JOB_WRITE      = STANDARD_RIGHTS_WRITE    | JOB_ACCESS_ADMINISTER;
+enum JOB_EXECUTE    = STANDARD_RIGHTS_EXECUTE  | JOB_ACCESS_ADMINISTER;
+
+enum PRINTER_NOTIFY_OPTIONS_REFRESH=1;
+enum PRINTER_ACCESS_ADMINISTER=4;
+enum PRINTER_ACCESS_USE=8;
+
+enum PRINTER_ERROR_INFORMATION=0x80000000;
+enum PRINTER_ERROR_WARNING=0x40000000;
+enum PRINTER_ERROR_SEVERE=0x20000000;
+enum PRINTER_ERROR_OUTOFPAPER=1;
+enum PRINTER_ERROR_JAM=2;
+enum PRINTER_ERROR_OUTOFTONER=4;
+
+enum PRINTER_CONTROL_PAUSE=1;
+enum PRINTER_CONTROL_RESUME=2;
+enum PRINTER_CONTROL_PURGE=3;
+enum PRINTER_CONTROL_SET_STATUS=4;
+
+enum PRINTER_STATUS_PAUSED = 1;
+enum PRINTER_STATUS_ERROR = 2;
+enum PRINTER_STATUS_PENDING_DELETION = 4;
+enum PRINTER_STATUS_PAPER_JAM = 8;
+enum PRINTER_STATUS_PAPER_OUT = 0x10;
+enum PRINTER_STATUS_MANUAL_FEED = 0x20;
+enum PRINTER_STATUS_PAPER_PROBLEM = 0x40;
+enum PRINTER_STATUS_OFFLINE = 0x80;
+enum PRINTER_STATUS_IO_ACTIVE = 0x100;
+enum PRINTER_STATUS_BUSY = 0x200;
+enum PRINTER_STATUS_PRINTING = 0x400;
+enum PRINTER_STATUS_OUTPUT_BIN_FULL = 0x800;
+enum PRINTER_STATUS_NOT_AVAILABLE = 0x1000;
+enum PRINTER_STATUS_WAITING = 0x2000;
+enum PRINTER_STATUS_PROCESSING = 0x4000;
+enum PRINTER_STATUS_INITIALIZING = 0x8000;
+enum PRINTER_STATUS_WARMING_UP = 0x10000;
+enum PRINTER_STATUS_TONER_LOW = 0x20000;
+enum PRINTER_STATUS_NO_TONER = 0x40000;
+enum PRINTER_STATUS_PAGE_PUNT = 0x80000;
+enum PRINTER_STATUS_USER_INTERVENTION = 0x100000;
+enum PRINTER_STATUS_OUT_OF_MEMORY = 0x200000;
+enum PRINTER_STATUS_DOOR_OPEN = 0x400000;
+enum PRINTER_STATUS_SERVER_UNKNOWN = 0x800000;
+enum PRINTER_STATUS_POWER_SAVE = 0x1000000;
+
+enum PRINTER_ATTRIBUTE_QUEUED=1;
+enum PRINTER_ATTRIBUTE_DIRECT=2;
+enum PRINTER_ATTRIBUTE_DEFAULT=4;
+enum PRINTER_ATTRIBUTE_SHARED=8;
+enum PRINTER_ATTRIBUTE_NETWORK=0x10;
+enum PRINTER_ATTRIBUTE_HIDDEN=0x20;
+enum PRINTER_ATTRIBUTE_LOCAL=0x40;
+enum PRINTER_ATTRIBUTE_ENABLE_DEVQ=0x80;
+enum PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS=0x100;
+enum PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST=0x200;
+enum PRINTER_ATTRIBUTE_WORK_OFFLINE=0x400;
+enum PRINTER_ATTRIBUTE_ENABLE_BIDI=0x800;
+enum PRINTER_ATTRIBUTE_RAW_ONLY=0x1000;
+enum PRINTER_ATTRIBUTE_PUBLISHED=0x2000;
+
+enum PRINTER_ENUM_DEFAULT=1;
+enum PRINTER_ENUM_LOCAL=2;
+enum PRINTER_ENUM_CONNECTIONS=4;
+enum PRINTER_ENUM_FAVORITE=4;
+enum PRINTER_ENUM_NAME=8;
+enum PRINTER_ENUM_REMOTE=16;
+enum PRINTER_ENUM_SHARED=32;
+enum PRINTER_ENUM_NETWORK=0x40;
+enum PRINTER_ENUM_EXPAND=0x4000;
+enum PRINTER_ENUM_CONTAINER=0x8000;
+enum PRINTER_ENUM_ICONMASK=0xff0000;
+enum PRINTER_ENUM_ICON1=0x10000;
+enum PRINTER_ENUM_ICON2=0x20000;
+enum PRINTER_ENUM_ICON3=0x40000;
+enum PRINTER_ENUM_ICON4=0x80000;
+enum PRINTER_ENUM_ICON5=0x100000;
+enum PRINTER_ENUM_ICON6=0x200000;
+enum PRINTER_ENUM_ICON7=0x400000;
+enum PRINTER_ENUM_ICON8=0x800000;
+
+enum PRINTER_NOTIFY_TYPE=0;
+
+enum PRINTER_NOTIFY_FIELD_SERVER_NAME=0;
+enum PRINTER_NOTIFY_FIELD_PRINTER_NAME=1;
+enum PRINTER_NOTIFY_FIELD_SHARE_NAME=2;
+enum PRINTER_NOTIFY_FIELD_PORT_NAME=3;
+enum PRINTER_NOTIFY_FIELD_DRIVER_NAME=4;
+enum PRINTER_NOTIFY_FIELD_COMMENT=5;
+enum PRINTER_NOTIFY_FIELD_LOCATION=6;
+enum PRINTER_NOTIFY_FIELD_DEVMODE=7;
+enum PRINTER_NOTIFY_FIELD_SEPFILE=8;
+enum PRINTER_NOTIFY_FIELD_PRINT_PROCESSOR=9;
+enum PRINTER_NOTIFY_FIELD_PARAMETERS=10;
+enum PRINTER_NOTIFY_FIELD_DATATYPE=11;
+enum PRINTER_NOTIFY_FIELD_SECURITY_DESCRIPTOR=12;
+enum PRINTER_NOTIFY_FIELD_ATTRIBUTES=13;
+enum PRINTER_NOTIFY_FIELD_PRIORITY=14;
+enum PRINTER_NOTIFY_FIELD_DEFAULT_PRIORITY=15;
+enum PRINTER_NOTIFY_FIELD_START_TIME=16;
+enum PRINTER_NOTIFY_FIELD_UNTIL_TIME=17;
+enum PRINTER_NOTIFY_FIELD_STATUS=18;
+enum PRINTER_NOTIFY_FIELD_STATUS_STRING=19;
+enum PRINTER_NOTIFY_FIELD_CJOBS=20;
+enum PRINTER_NOTIFY_FIELD_AVERAGE_PPM=21;
+enum PRINTER_NOTIFY_FIELD_TOTAL_PAGES=22;
+enum PRINTER_NOTIFY_FIELD_PAGES_PRINTED=23;
+enum PRINTER_NOTIFY_FIELD_TOTAL_BYTES=24;
+enum PRINTER_NOTIFY_FIELD_BYTES_PRINTED=25;
+
+enum PRINTER_CHANGE_ADD_PRINTER=1;
+enum PRINTER_CHANGE_SET_PRINTER=2;
+enum PRINTER_CHANGE_DELETE_PRINTER=4;
+enum PRINTER_CHANGE_FAILED_CONNECTION_PRINTER=8;
+enum PRINTER_CHANGE_PRINTER=0xFF;
+enum PRINTER_CHANGE_ADD_JOB=0x100;
+enum PRINTER_CHANGE_SET_JOB=0x200;
+enum PRINTER_CHANGE_DELETE_JOB=0x400;
+enum PRINTER_CHANGE_WRITE_JOB=0x800;
+enum PRINTER_CHANGE_JOB=0xFF00;
+enum PRINTER_CHANGE_ADD_FORM=0x10000;
+enum PRINTER_CHANGE_SET_FORM=0x20000;
+enum PRINTER_CHANGE_DELETE_FORM=0x40000;
+enum PRINTER_CHANGE_FORM=0x70000;
+enum PRINTER_CHANGE_ADD_PORT=0x100000;
+enum PRINTER_CHANGE_CONFIGURE_PORT=0x200000;
+enum PRINTER_CHANGE_DELETE_PORT=0x400000;
+enum PRINTER_CHANGE_PORT=0x700000;
+enum PRINTER_CHANGE_ADD_PRINT_PROCESSOR=0x1000000;
+enum PRINTER_CHANGE_DELETE_PRINT_PROCESSOR=0x4000000;
+enum PRINTER_CHANGE_PRINT_PROCESSOR=0x7000000;
+enum PRINTER_CHANGE_ADD_PRINTER_DRIVER=0x10000000;
+enum PRINTER_CHANGE_SET_PRINTER_DRIVER=0x20000000;
+enum PRINTER_CHANGE_DELETE_PRINTER_DRIVER=0x40000000;
+enum PRINTER_CHANGE_PRINTER_DRIVER=0x70000000;
+enum PRINTER_CHANGE_TIMEOUT=0x80000000;
+enum PRINTER_CHANGE_ALL=0x7777FFFF;
+
+enum PRINTER_NOTIFY_INFO_DISCARDED=1;
+enum PRINTER_ALL_ACCESS=(STANDARD_RIGHTS_REQUIRED|PRINTER_ACCESS_ADMINISTER|PRINTER_ACCESS_USE);
+enum PRINTER_READ=(STANDARD_RIGHTS_READ|PRINTER_ACCESS_USE);
+enum PRINTER_WRITE=(STANDARD_RIGHTS_WRITE|PRINTER_ACCESS_USE);
+enum PRINTER_EXECUTE=(STANDARD_RIGHTS_EXECUTE|PRINTER_ACCESS_USE);
+enum NO_PRIORITY=0;
+enum MAX_PRIORITY=99;
+enum MIN_PRIORITY=1;
+enum DEF_PRIORITY=1;
+enum PORT_TYPE_WRITE=1;
+enum PORT_TYPE_READ=2;
+enum PORT_TYPE_REDIRECTED=4;
+enum PORT_TYPE_NET_ATTACHED=8;
+enum SERVER_ACCESS_ADMINISTER=1;
+enum SERVER_ACCESS_ENUMERATE=2;
+
+enum SERVER_ALL_ACCESS=(STANDARD_RIGHTS_REQUIRED|SERVER_ACCESS_ADMINISTER|SERVER_ACCESS_ENUMERATE);
+enum SERVER_READ=(STANDARD_RIGHTS_READ|SERVER_ACCESS_ENUMERATE);
+enum SERVER_WRITE=(STANDARD_RIGHTS_WRITE|SERVER_ACCESS_ADMINISTER|SERVER_ACCESS_ENUMERATE);
+enum SERVER_EXECUTE=(STANDARD_RIGHTS_EXECUTE|SERVER_ACCESS_ENUMERATE);
+
+enum PORT_STATUS_TYPE_ERROR=1;
+enum PORT_STATUS_TYPE_WARNING=2;
+enum PORT_STATUS_TYPE_INFO=3;
+
+enum PORT_STATUS_OFFLINE=1;
+enum PORT_STATUS_PAPER_JAM=2;
+enum PORT_STATUS_PAPER_OUT=3;
+enum PORT_STATUS_OUTPUT_BIN_FULL=4;
+enum PORT_STATUS_PAPER_PROBLEM=5;
+enum PORT_STATUS_NO_TONER=6;
+enum PORT_STATUS_DOOR_OPEN=7;
+enum PORT_STATUS_USER_INTERVENTION=8;
+enum PORT_STATUS_OUT_OF_MEMORY=9;
+enum PORT_STATUS_TONER_LOW=10;
+enum PORT_STATUS_WARMING_UP=11;
+enum PORT_STATUS_POWER_SAVE=12;
+
+struct ADDJOB_INFO_1A {
+    LPSTR Path;
+    DWORD JobId;
+}
+alias ADDJOB_INFO_1A* PADDJOB_INFO_1A, LPADDJOB_INFO_1A;
+
+struct ADDJOB_INFO_1W {
+    LPWSTR Path;
+    DWORD JobId;
+}
+alias ADDJOB_INFO_1W* PADDJOB_INFO_1W, LPADDJOB_INFO_1W;
+
+struct DATATYPES_INFO_1A {
+    LPSTR pName;
+}
+alias DATATYPES_INFO_1A* PDATATYPES_INFO_1A, LPDATATYPES_INFO_1A;
+
+struct DATATYPES_INFO_1W {
+    LPWSTR pName;
+}
+alias DATATYPES_INFO_1W* PDATATYPES_INFO_1W, LPDATATYPES_INFO_1W;
+
+struct JOB_INFO_1A {
+    DWORD JobId;
+    LPSTR pPrinterName;
+    LPSTR pMachineName;
+    LPSTR pUserName;
+    LPSTR pDocument;
+    LPSTR pDatatype;
+    LPSTR pStatus;
+    DWORD Status;
+    DWORD Priority;
+    DWORD Position;
+    DWORD TotalPages;
+    DWORD PagesPrinted;
+    SYSTEMTIME Submitted;
+}
+alias JOB_INFO_1A* PJOB_INFO_1A, LPJOB_INFO_1A;
+
+struct JOB_INFO_1W {
+    DWORD JobId;
+    LPWSTR pPrinterName;
+    LPWSTR pMachineName;
+    LPWSTR pUserName;
+    LPWSTR pDocument;
+    LPWSTR pDatatype;
+    LPWSTR pStatus;
+    DWORD Status;
+    DWORD Priority;
+    DWORD Position;
+    DWORD TotalPages;
+    DWORD PagesPrinted;
+    SYSTEMTIME Submitted;
+}
+alias JOB_INFO_1W* PJOB_INFO_1W, LPJOB_INFO_1W;
+
+struct JOB_INFO_2A {
+    DWORD JobId;
+    LPSTR pPrinterName;
+    LPSTR pMachineName;
+    LPSTR pUserName;
+    LPSTR pDocument;
+    LPSTR pNotifyName;
+    LPSTR pDatatype;
+    LPSTR pPrintProcessor;
+    LPSTR pParameters;
+    LPSTR pDriverName;
+    LPDEVMODEA pDevMode;
+    LPSTR pStatus;
+    PSECURITY_DESCRIPTOR pSecurityDescriptor;
+    DWORD Status;
+    DWORD Priority;
+    DWORD Position;
+    DWORD StartTime;
+    DWORD UntilTime;
+    DWORD TotalPages;
+    DWORD Size;
+    SYSTEMTIME Submitted;
+    DWORD Time;
+    DWORD PagesPrinted;
+}
+alias JOB_INFO_2A* PJOB_INFO_2A, LPJOB_INFO_2A;
+
+struct JOB_INFO_2W {
+    DWORD JobId;
+    LPWSTR pPrinterName;
+    LPWSTR pMachineName;
+    LPWSTR pUserName;
+    LPWSTR pDocument;
+    LPWSTR pNotifyName;
+    LPWSTR pDatatype;
+    LPWSTR pPrintProcessor;
+    LPWSTR pParameters;
+    LPWSTR pDriverName;
+    LPDEVMODEW pDevMode;
+    LPWSTR pStatus;
+    PSECURITY_DESCRIPTOR pSecurityDescriptor;
+    DWORD Status;
+    DWORD Priority;
+    DWORD Position;
+    DWORD StartTime;
+    DWORD UntilTime;
+    DWORD TotalPages;
+    DWORD Size;
+    SYSTEMTIME Submitted;
+    DWORD Time;
+    DWORD PagesPrinted;
+}
+alias JOB_INFO_2W* PJOB_INFO_2W, LPJOB_INFO_2W;
+
+struct DOC_INFO_1A {
+    LPSTR pDocName;
+    LPSTR pOutputFile;
+    LPSTR pDatatype;
+}
+alias DOC_INFO_1A* PDOC_INFO_1A, LPDOC_INFO_1A;
+
+struct DOC_INFO_1W {
+    LPWSTR pDocName;
+    LPWSTR pOutputFile;
+    LPWSTR pDatatype;
+}
+alias DOC_INFO_1W* PDOC_INFO_1W, LPDOC_INFO_1W;
+
+struct DOC_INFO_2A {
+    LPSTR pDocName;
+    LPSTR pOutputFile;
+    LPSTR pDatatype;
+    DWORD dwMode;
+    DWORD JobId;
+}
+alias DOC_INFO_2A* PDOC_INFO_2A, LPDOC_INFO_2A;
+
+struct DOC_INFO_2W {
+    LPWSTR pDocName;
+    LPWSTR pOutputFile;
+    LPWSTR pDatatype;
+    DWORD  dwMode;
+    DWORD  JobId;
+}
+alias DOC_INFO_2W* PDOC_INFO_2W, LPDOC_INFO_2W;
+
+struct DRIVER_INFO_1A {
+    LPSTR pName;
+}
+alias DRIVER_INFO_1A* PDRIVER_INFO_1A, LPDRIVER_INFO_1A;
+
+struct DRIVER_INFO_1W {
+    LPWSTR pName;
+}
+alias DRIVER_INFO_1W* PDRIVER_INFO_1W, LPDRIVER_INFO_1W;
+
+struct DRIVER_INFO_2A {
+    DWORD cVersion;
+    LPSTR pName;
+    LPSTR pEnvironment;
+    LPSTR pDriverPath;
+    LPSTR pDataFile;
+    LPSTR pConfigFile;
+}
+alias DRIVER_INFO_2A* PDRIVER_INFO_2A, LPDRIVER_INFO_2A;
+
+struct DRIVER_INFO_2W {
+    DWORD  cVersion;
+    LPWSTR pName;
+    LPWSTR pEnvironment;
+    LPWSTR pDriverPath;
+    LPWSTR pDataFile;
+    LPWSTR pConfigFile;
+}
+alias DRIVER_INFO_2W* PDRIVER_INFO_2W, LPDRIVER_INFO_2W;
+
+struct DRIVER_INFO_3A {
+    DWORD cVersion;
+    LPSTR pName;
+    LPSTR pEnvironment;
+    LPSTR pDriverPath;
+    LPSTR pDataFile;
+    LPSTR pConfigFile;
+    LPSTR pHelpFile;
+    LPSTR pDependentFiles;
+    LPSTR pMonitorName;
+    LPSTR pDefaultDataType;
+}
+alias DRIVER_INFO_3A* PDRIVER_INFO_3A, LPDRIVER_INFO_3A;
+
+struct DRIVER_INFO_3W {
+    DWORD  cVersion;
+    LPWSTR pName;
+    LPWSTR pEnvironment;
+    LPWSTR pDriverPath;
+    LPWSTR pDataFile;
+    LPWSTR pConfigFile;
+    LPWSTR pHelpFile;
+    LPWSTR pDependentFiles;
+    LPWSTR pMonitorName;
+    LPWSTR pDefaultDataType;
+}
+alias DRIVER_INFO_3W* PDRIVER_INFO_3W, LPDRIVER_INFO_3W;
+
+struct MONITOR_INFO_1A {
+    LPSTR pName;
+}
+alias MONITOR_INFO_1A* PMONITOR_INFO_1A, LPMONITOR_INFO_1A;
+
+struct MONITOR_INFO_1W {
+    LPWSTR pName;
+}
+alias MONITOR_INFO_1W* PMONITOR_INFO_1W, LPMONITOR_INFO_1W;
+
+struct PORT_INFO_1A {
+    LPSTR pName;
+}
+alias PORT_INFO_1A* PPORT_INFO_1A, LPPORT_INFO_1A;
+
+struct PORT_INFO_1W {
+    LPWSTR pName;
+}
+alias PORT_INFO_1W* PPORT_INFO_1W, LPPORT_INFO_1W;
+
+struct MONITOR_INFO_2A {
+    LPSTR pName;
+    LPSTR pEnvironment;
+    LPSTR pDLLName;
+}
+alias MONITOR_INFO_2A* PMONITOR_INFO_2A, LPMONITOR_INFO_2A;
+
+struct MONITOR_INFO_2W {
+    LPWSTR pName;
+    LPWSTR pEnvironment;
+    LPWSTR pDLLName;
+}
+alias MONITOR_INFO_2W* PMONITOR_INFO_2W, LPMONITOR_INFO_2W;
+
+struct PORT_INFO_2A {
+    LPSTR pPortName;
+    LPSTR pMonitorName;
+    LPSTR pDescription;
+    DWORD fPortType;
+    DWORD Reserved;
+}
+alias PORT_INFO_2A* PPORT_INFO_2A, LPPORT_INFO_2A;
+
+struct PORT_INFO_2W {
+    LPWSTR pPortName;
+    LPWSTR pMonitorName;
+    LPWSTR pDescription;
+    DWORD fPortType;
+    DWORD Reserved;
+}
+alias PORT_INFO_2W* PPORT_INFO_2W, LPPORT_INFO_2W;
+
+struct PORT_INFO_3A {
+    DWORD dwStatus;
+    LPSTR pszStatus;
+    DWORD dwSeverity;
+}
+alias PORT_INFO_3A* PPORT_INFO_3A, LPPORT_INFO_3A;
+
+struct PORT_INFO_3W {
+    DWORD dwStatus;
+    LPWSTR pszStatus;
+    DWORD dwSeverity;
+}
+alias PORT_INFO_3W* PPORT_INFO_3W, LPPORT_INFO_3W;
+
+struct PRINTER_INFO_1A {
+    DWORD Flags;
+    LPSTR pDescription;
+    LPSTR pName;
+    LPSTR pComment;
+}
+alias PRINTER_INFO_1A* PPRINTER_INFO_1A, LPPRINTER_INFO_1A;
+
+struct PRINTER_INFO_1W {
+    DWORD  Flags;
+    LPWSTR pDescription;
+    LPWSTR pName;
+    LPWSTR pComment;
+}
+alias PRINTER_INFO_1W* PPRINTER_INFO_1W, LPPRINTER_INFO_1W;
+
+struct PRINTER_INFO_2A {
+    LPSTR pServerName;
+    LPSTR pPrinterName;
+    LPSTR pShareName;
+    LPSTR pPortName;
+    LPSTR pDriverName;
+    LPSTR pComment;
+    LPSTR pLocation;
+    LPDEVMODEA pDevMode;
+    LPSTR pSepFile;
+    LPSTR pPrintProcessor;
+    LPSTR pDatatype;
+    LPSTR pParameters;
+    PSECURITY_DESCRIPTOR pSecurityDescriptor;
+    DWORD Attributes;
+    DWORD Priority;
+    DWORD DefaultPriority;
+    DWORD StartTime;
+    DWORD UntilTime;
+    DWORD Status;
+    DWORD cJobs;
+    DWORD AveragePPM;
+}
+alias PRINTER_INFO_2A* PPRINTER_INFO_2A, LPPRINTER_INFO_2A;
+
+struct PRINTER_INFO_2W {
+    LPWSTR pServerName;
+    LPWSTR pPrinterName;
+    LPWSTR pShareName;
+    LPWSTR pPortName;
+    LPWSTR pDriverName;
+    LPWSTR pComment;
+    LPWSTR pLocation;
+    LPDEVMODEW pDevMode;
+    LPWSTR pSepFile;
+    LPWSTR pPrintProcessor;
+    LPWSTR pDatatype;
+    LPWSTR pParameters;
+    PSECURITY_DESCRIPTOR pSecurityDescriptor;
+    DWORD Attributes;
+    DWORD Priority;
+    DWORD DefaultPriority;
+    DWORD StartTime;
+    DWORD UntilTime;
+    DWORD Status;
+    DWORD cJobs;
+    DWORD AveragePPM;
+}
+alias PRINTER_INFO_2W* PPRINTER_INFO_2W, LPPRINTER_INFO_2W;
+
+struct PRINTER_INFO_3 {
+    PSECURITY_DESCRIPTOR pSecurityDescriptor;
+}
+alias PRINTER_INFO_3* PPRINTER_INFO_3, LPPRINTER_INFO_3;
+
+struct PRINTER_INFO_4A {
+    LPSTR pPrinterName;
+    LPSTR pServerName;
+    DWORD Attributes;
+}
+alias PRINTER_INFO_4A* PPRINTER_INFO_4A, LPPRINTER_INFO_4A;
+
+struct PRINTER_INFO_4W {
+    LPWSTR pPrinterName;
+    LPWSTR pServerName;
+    DWORD Attributes;
+}
+alias PRINTER_INFO_4W* PPRINTER_INFO_4W, LPPRINTER_INFO_4W;
+
+struct PRINTER_INFO_5A {
+    LPSTR pPrinterName;
+    LPSTR pPortName;
+    DWORD Attributes;
+    DWORD DeviceNotSelectedTimeout;
+    DWORD TransmissionRetryTimeout;
+}
+alias PRINTER_INFO_5A* PPRINTER_INFO_5A, LPPRINTER_INFO_5A;
+
+struct PRINTER_INFO_5W {
+    LPWSTR pPrinterName;
+    LPWSTR pPortName;
+    DWORD Attributes;
+    DWORD DeviceNotSelectedTimeout;
+    DWORD TransmissionRetryTimeout;
+}
+alias PRINTER_INFO_5W* PPRINTER_INFO_5W, LPPRINTER_INFO_5W;
+
+struct PRINTER_INFO_6 {
+    DWORD dwStatus;
+}
+alias PRINTER_INFO_6* PPRINTER_INFO_6, LPPRINTER_INFO_6;
+
+struct PRINTPROCESSOR_INFO_1A {
+    LPSTR pName;
+}
+alias PRINTPROCESSOR_INFO_1A* PPRINTPROCESSOR_INFO_1A, LPPRINTPROCESSOR_INFO_1A;
+
+struct PRINTPROCESSOR_INFO_1W {
+    LPWSTR pName;
+}
+alias PRINTPROCESSOR_INFO_1W* PPRINTPROCESSOR_INFO_1W, LPPRINTPROCESSOR_INFO_1W;
+
+struct PRINTER_NOTIFY_INFO_DATA {
+    WORD  Type;
+    WORD  Field;
+    DWORD Reserved;
+    DWORD Id;
+    union _NotifyData {
+        DWORD[2] adwData;
+        struct Data {
+            DWORD cbBuf;
+            PVOID pBuf;
+        }
+    }
+    _NotifyData NotifyData;
+}
+alias PRINTER_NOTIFY_INFO_DATA* PPRINTER_NOTIFY_INFO_DATA, LPPRINTER_NOTIFY_INFO_DATA;
+
+struct PRINTER_NOTIFY_INFO {
+    DWORD Version;
+    DWORD Flags;
+    DWORD Count;
+    PRINTER_NOTIFY_INFO_DATA[1] aData;
+}
+alias PRINTER_NOTIFY_INFO* PPRINTER_NOTIFY_INFO, LPPRINTER_NOTIFY_INFO;
+
+struct FORM_INFO_1A {
+    DWORD Flags;
+    LPSTR pName;
+    SIZEL Size;
+    RECTL ImageableArea;
+}
+alias FORM_INFO_1A* PFORM_INFO_1A, LPFORM_INFO_1A;
+
+struct FORM_INFO_1W {
+    DWORD  Flags;
+    LPWSTR pName;
+    SIZEL  Size;
+    RECTL  ImageableArea;
+}
+alias FORM_INFO_1W* PFORM_INFO_1W, LPFORM_INFO_1W;
+
+struct PRINTER_DEFAULTSA {
+    LPSTR       pDatatype;
+    LPDEVMODE   pDevMode;
+    ACCESS_MASK DesiredAccess;
+}
+alias PRINTER_DEFAULTSA* PPRINTER_DEFAULTSA, LPPRINTER_DEFAULTSA;
+
+struct PRINTER_DEFAULTSW {
+    LPWSTR pDatatype;
+    LPDEVMODE pDevMode;
+    ACCESS_MASK DesiredAccess;
+}
+alias PRINTER_DEFAULTSW* PPRINTER_DEFAULTSW, LPPRINTER_DEFAULTSW;
+
+extern (Windows):
+BOOL AbortPrinter(HANDLE);
+BOOL AddFormA(HANDLE, DWORD, PBYTE);
+BOOL AddFormW(HANDLE, DWORD, PBYTE);
+BOOL AddJobA(HANDLE, DWORD, PBYTE, DWORD, PDWORD);
+BOOL AddJobW(HANDLE, DWORD, PBYTE, DWORD, PDWORD);
+BOOL AddMonitorA(LPSTR, DWORD, PBYTE);
+BOOL AddMonitorW(LPWSTR, DWORD, PBYTE);
+BOOL AddPortA(LPSTR, HWND, LPSTR);
+BOOL AddPortW(LPWSTR, HWND, LPWSTR);
+HANDLE AddPrinterA(LPSTR, DWORD, PBYTE);
+HANDLE AddPrinterW(LPWSTR, DWORD, PBYTE);
+BOOL AddPrinterConnectionA(LPSTR);
+BOOL AddPrinterConnectionW(LPWSTR);
+BOOL AddPrinterDriverA(LPSTR, DWORD, PBYTE);
+BOOL AddPrinterDriverW(LPWSTR, DWORD, PBYTE);
+BOOL AddPrintProcessorA(LPSTR, LPSTR, LPSTR, LPSTR);
+BOOL AddPrintProcessorW(LPWSTR, LPWSTR, LPWSTR, LPWSTR);
+BOOL AddPrintProvidorA(LPSTR, DWORD, PBYTE);
+BOOL AddPrintProvidorW(LPWSTR, DWORD, PBYTE);
+LONG AdvancedDocumentPropertiesA(HWND, HANDLE, LPSTR, PDEVMODE, PDEVMODEA);
+LONG AdvancedDocumentPropertiesW(HWND, HANDLE, LPWSTR, PDEVMODE, PDEVMODEW);
+BOOL ClosePrinter(HANDLE);
+BOOL ConfigurePortA(LPSTR, HWND, LPSTR);
+BOOL ConfigurePortW(LPWSTR, HWND, LPWSTR);
+HANDLE ConnectToPrinterDlg(HWND, DWORD);
+BOOL DeleteFormA(HANDLE, LPSTR);
+BOOL DeleteFormW(HANDLE, LPWSTR);
+BOOL DeleteMonitorA(LPSTR, LPSTR, LPSTR);
+BOOL DeleteMonitorW(LPWSTR, LPWSTR, LPWSTR);
+BOOL DeletePortA(LPSTR, HWND, LPSTR);
+BOOL DeletePortW(LPWSTR, HWND, LPWSTR);
+BOOL DeletePrinter(HANDLE);
+BOOL DeletePrinterConnectionA(LPSTR);
+BOOL DeletePrinterConnectionW(LPWSTR);
+DWORD DeletePrinterDataA(HANDLE, LPSTR);
+DWORD DeletePrinterDataW(HANDLE, LPWSTR);
+BOOL DeletePrinterDriverA(LPSTR, LPSTR, LPSTR);
+BOOL DeletePrinterDriverW(LPWSTR, LPWSTR, LPWSTR);
+BOOL DeletePrintProcessorA(LPSTR, LPSTR, LPSTR);
+BOOL DeletePrintProcessorW(LPWSTR, LPWSTR, LPWSTR);
+BOOL DeletePrintProvidorA(LPSTR, LPSTR, LPSTR);
+BOOL DeletePrintProvidorW(LPWSTR, LPWSTR, LPWSTR);
+LONG DocumentPropertiesA(HWND, HANDLE, LPSTR, PDEVMODEA, PDEVMODEA, DWORD);
+LONG DocumentPropertiesW(HWND, HANDLE, LPWSTR, PDEVMODEW, PDEVMODEW, DWORD);
+BOOL EndDocPrinter(HANDLE);
+BOOL EndPagePrinter(HANDLE);
+BOOL EnumFormsA(HANDLE, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumFormsW(HANDLE, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumJobsA(HANDLE, DWORD, DWORD, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumJobsW(HANDLE, DWORD, DWORD, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumMonitorsA(LPSTR, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumMonitorsW(LPWSTR, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumPortsA(LPSTR, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumPortsW(LPWSTR, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+DWORD EnumPrinterDataA(HANDLE, DWORD, LPSTR, DWORD, PDWORD, PDWORD, PBYTE, DWORD, PDWORD);
+DWORD EnumPrinterDataW(HANDLE, DWORD, LPWSTR, DWORD, PDWORD, PDWORD, PBYTE, DWORD, PDWORD);
+BOOL EnumPrinterDriversA(LPSTR, LPSTR, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumPrinterDriversW(LPWSTR, LPWSTR, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumPrintersA(DWORD, LPSTR, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumPrintersW(DWORD, LPWSTR, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumPrintProcessorDatatypesA(LPSTR, LPSTR, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumPrintProcessorDatatypesW(LPWSTR, LPWSTR, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumPrintProcessorsA(LPSTR, LPSTR, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL EnumPrintProcessorsW(LPWSTR, LPWSTR, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
+BOOL FindClosePrinterChangeNotification(HANDLE);
+HANDLE FindFirstPrinterChangeNotification(HANDLE, DWORD, DWORD, PVOID);
+HANDLE FindNextPrinterChangeNotification(HANDLE, PDWORD, PVOID, PVOID*);
+BOOL FreePrinterNotifyInfo(PPRINTER_NOTIFY_INFO);
+
+static if (_WIN32_WINNT >= 0x500) {
+BOOL GetDefaultPrinterA(LPSTR, LPDWORD);
+BOOL GetDefaultPrinterW(LPWSTR, LPDWORD);
+}
+
+BOOL GetFormA(HANDLE, LPSTR, DWORD, PBYTE, DWORD, PDWORD);
+BOOL GetFormW(HANDLE, LPWSTR, DWORD, PBYTE, DWORD, PDWORD);
+BOOL GetJobA(HANDLE, DWORD, DWORD, PBYTE, DWORD, PDWORD);
+BOOL GetJobW(HANDLE, DWORD, DWORD, PBYTE, DWORD, PDWORD);
+BOOL GetPrinterA(HANDLE, DWORD, PBYTE, DWORD, PDWORD);
+BOOL GetPrinterW(HANDLE, DWORD, PBYTE, DWORD, PDWORD);
+DWORD GetPrinterDataA(HANDLE, LPSTR, PDWORD, PBYTE, DWORD, PDWORD);
+DWORD GetPrinterDataW(HANDLE, LPWSTR, PDWORD, PBYTE, DWORD, PDWORD);
+DWORD GetPrinterDriverA(HANDLE, LPSTR, DWORD, PBYTE, DWORD, PDWORD);
+DWORD GetPrinterDriverW(HANDLE, LPWSTR, DWORD, PBYTE, DWORD, PDWORD);
+DWORD GetPrinterDriverDirectoryA(LPSTR, LPSTR, DWORD, PBYTE, DWORD, PDWORD);
+DWORD GetPrinterDriverDirectoryW(LPWSTR, LPWSTR, DWORD, PBYTE, DWORD, PDWORD);
+DWORD GetPrintProcessorDirectoryA(LPSTR, LPSTR, DWORD, PBYTE, DWORD, PDWORD);
+DWORD GetPrintProcessorDirectoryW(LPWSTR, LPWSTR, DWORD, PBYTE, DWORD, PDWORD);
+BOOL OpenPrinterA(LPSTR, PHANDLE, LPPRINTER_DEFAULTSA);
+BOOL OpenPrinterW(LPWSTR, PHANDLE, LPPRINTER_DEFAULTSW);
+DWORD PrinterMessageBoxA(HANDLE, DWORD, HWND, LPSTR, LPSTR, DWORD);
+DWORD PrinterMessageBoxW(HANDLE, DWORD, HWND, LPWSTR, LPWSTR, DWORD);
+BOOL PrinterProperties(HWND, HANDLE);
+BOOL ReadPrinter(HANDLE, PVOID, DWORD, PDWORD);
+BOOL ResetPrinterA(HANDLE, LPPRINTER_DEFAULTSA);
+BOOL ResetPrinterW(HANDLE, LPPRINTER_DEFAULTSW);
+BOOL ScheduleJob(HANDLE, DWORD);
+BOOL SetFormA(HANDLE, LPSTR, DWORD, PBYTE);
+BOOL SetFormW(HANDLE, LPWSTR, DWORD, PBYTE);
+BOOL SetJobA(HANDLE, DWORD, DWORD, PBYTE, DWORD);
+BOOL SetJobW(HANDLE, DWORD, DWORD, PBYTE, DWORD);
+BOOL SetPrinterA(HANDLE, DWORD, PBYTE, DWORD);
+BOOL SetPrinterW(HANDLE, DWORD, PBYTE, DWORD);
+BOOL SetPrinterDataA(HANDLE, LPSTR, DWORD, PBYTE, DWORD);
+BOOL SetPrinterDataW(HANDLE, LPWSTR, DWORD, PBYTE, DWORD);
+DWORD StartDocPrinterA(HANDLE, DWORD, PBYTE);
+DWORD StartDocPrinterW(HANDLE, DWORD, PBYTE);
+BOOL StartPagePrinter(HANDLE);
+DWORD WaitForPrinterChange(HANDLE, DWORD);
+BOOL WritePrinter(HANDLE, PVOID, DWORD, PDWORD);
+
+version(Unicode) {
+
+alias JOB_INFO_1W JOB_INFO_1;
+alias JOB_INFO_2W JOB_INFO_2;
+alias ADDJOB_INFO_1W ADDJOB_INFO_1;
+alias DATATYPES_INFO_1W DATATYPES_INFO_1;
+alias MONITOR_INFO_1W MONITOR_INFO_1;
+alias MONITOR_INFO_2W MONITOR_INFO_2;
+alias DOC_INFO_1W DOC_INFO_1;
+alias DOC_INFO_2W DOC_INFO_2;
+alias PORT_INFO_1W PORT_INFO_1;
+alias PORT_INFO_2W PORT_INFO_2;
+alias PORT_INFO_3W PORT_INFO_3;
+alias DRIVER_INFO_2W DRIVER_INFO_2;
+alias PRINTER_INFO_1W PRINTER_INFO_1;
+alias PRINTER_INFO_2W PRINTER_INFO_2;
+alias PRINTER_INFO_4W PRINTER_INFO_4;
+alias PRINTER_INFO_5W PRINTER_INFO_5;
+alias PRINTPROCESSOR_INFO_1W PRINTPROCESSOR_INFO_1;
+alias FORM_INFO_1W FORM_INFO_1;
+alias PRINTER_DEFAULTSW PRINTER_DEFAULTS;
+
+alias AddFormW AddForm;
+alias AddJobW AddJob;
+alias AddMonitorW AddMonitor;
+alias AddPortW AddPort;
+alias AddPrinterW AddPrinter;
+alias AddPrinterConnectionW AddPrinterConnection;
+alias AddPrinterDriverW AddPrinterDriver;
+alias AddPrintProcessorW AddPrintProcessor;
+alias AddPrintProvidorW AddPrintProvidor;
+alias AdvancedDocumentPropertiesW AdvancedDocumentProperties;
+alias ConfigurePortW ConfigurePort;
+alias DeleteFormW DeleteForm;
+alias DeleteMonitorW DeleteMonitor;
+alias DeletePortW DeletePort;
+alias DeletePrinterConnectionW DeletePrinterConnection;
+alias DeletePrinterDataW DeletePrinterData;
+alias DeletePrinterDriverW DeletePrinterDriver;
+alias DeletePrintProcessorW DeletePrintProcessor;
+alias DeletePrintProvidorW DeletePrintProvidor;
+alias DocumentPropertiesW DocumentProperties;
+alias EnumFormsW EnumForms;
+alias EnumJobsW EnumJobs;
+alias EnumMonitorsW EnumMonitors;
+alias EnumPortsW EnumPorts;
+alias EnumPrinterDataW EnumPrinterData;
+alias EnumPrinterDriversW EnumPrinterDrivers;
+alias EnumPrintersW EnumPrinters;
+alias EnumPrintProcessorDatatypesW EnumPrintProcessorDatatypes;
+alias EnumPrintProcessorsW EnumPrintProcessors;
+
+static if (_WIN32_WINNT >= 0x500) {
+alias GetDefaultPrinterW GetDefaultPrinter;
+}
+
+alias GetFormW GetForm;
+alias GetJobW GetJob;
+alias GetPrinterW GetPrinter;
+alias GetPrinterDataW GetPrinterData;
+alias GetPrinterDriverW GetPrinterDriver;
+alias GetPrinterDriverDirectoryW GetPrinterDriverDirectory;
+alias GetPrintProcessorDirectoryW GetPrintProcessorDirectory;
+alias OpenPrinterW OpenPrinter;
+alias PrinterMessageBoxW PrinterMessageBox;
+alias ResetPrinterW ResetPrinter;
+alias SetFormW SetForm;
+alias SetJobW SetJob;
+alias SetPrinterW SetPrinter;
+alias SetPrinterDataW SetPrinterData;
+alias StartDocPrinterW StartDocPrinter;
+
+} else {
+
+alias JOB_INFO_1A JOB_INFO_1;
+alias JOB_INFO_2A JOB_INFO_2;
+alias ADDJOB_INFO_1A ADDJOB_INFO_1;
+alias DATATYPES_INFO_1A DATATYPES_INFO_1;
+alias MONITOR_INFO_1A MONITOR_INFO_1;
+alias MONITOR_INFO_2A MONITOR_INFO_2;
+alias DOC_INFO_1A DOC_INFO_1;
+alias DOC_INFO_2A DOC_INFO_2;
+alias PORT_INFO_1A PORT_INFO_1;
+alias PORT_INFO_2A PORT_INFO_2;
+alias PORT_INFO_3A PORT_INFO_3;
+alias DRIVER_INFO_2A DRIVER_INFO_2;
+alias PRINTER_INFO_1A PRINTER_INFO_1;
+alias PRINTER_INFO_2A PRINTER_INFO_2;
+alias PRINTER_INFO_4A PRINTER_INFO_4;
+alias PRINTER_INFO_5A PRINTER_INFO_5;
+alias PRINTPROCESSOR_INFO_1A PRINTPROCESSOR_INFO_1;
+alias FORM_INFO_1A FORM_INFO_1;
+alias PRINTER_DEFAULTSA PRINTER_DEFAULTS;
+
+alias AddFormA AddForm;
+alias AddJobA AddJob;
+alias AddMonitorA AddMonitor;
+alias AddPortA AddPort;
+alias AddPrinterA AddPrinter;
+alias AddPrinterConnectionA AddPrinterConnection;
+alias AddPrinterDriverA AddPrinterDriver;
+alias AddPrintProcessorA AddPrintProcessor;
+alias AddPrintProvidorA AddPrintProvidor;
+alias AdvancedDocumentPropertiesA AdvancedDocumentProperties;
+alias ConfigurePortA ConfigurePort;
+alias DeleteFormA DeleteForm;
+alias DeleteMonitorA DeleteMonitor;
+alias DeletePortA DeletePort;
+alias DeletePrinterConnectionA DeletePrinterConnection;
+alias DeletePrinterDataA DeletePrinterData;
+alias DeletePrinterDriverA DeletePrinterDriver;
+alias DeletePrintProcessorA DeletePrintProcessor;
+alias DeletePrintProvidorA DeletePrintProvidor;
+alias DocumentPropertiesA DocumentProperties;
+alias EnumFormsA EnumForms;
+alias EnumJobsA EnumJobs;
+alias EnumMonitorsA EnumMonitors;
+alias EnumPortsA EnumPorts;
+alias EnumPrinterDataA EnumPrinterData;
+alias EnumPrinterDriversA EnumPrinterDrivers;
+alias EnumPrintersA EnumPrinters;
+alias EnumPrintProcessorDatatypesA EnumPrintProcessorDatatypes;
+alias EnumPrintProcessorsA EnumPrintProcessors;
+
+static if (_WIN32_WINNT >= 0x500) {
+alias GetDefaultPrinterA GetDefaultPrinter;
+}
+
+alias GetFormA GetForm;
+alias GetJobA GetJob;
+alias GetPrinterA GetPrinter;
+alias GetPrinterDataA GetPrinterData;
+alias GetPrinterDriverA GetPrinterDriver;
+alias GetPrinterDriverDirectoryA GetPrinterDriverDirectory;
+alias GetPrintProcessorDirectoryA GetPrintProcessorDirectory;
+alias OpenPrinterA OpenPrinter;
+alias PrinterMessageBoxA PrinterMessageBox;
+alias ResetPrinterA ResetPrinter;
+alias SetFormA SetForm;
+alias SetJobA SetJob;
+alias SetPrinterA SetPrinter;
+alias SetPrinterDataA SetPrinterData;
+alias StartDocPrinterA StartDocPrinter;
+}
+
+alias JOB_INFO_1* PJOB_INFO_1, LPJOB_INFO_1;
+alias JOB_INFO_2* PJOB_INFO_2, LPJOB_INFO_2;
+alias ADDJOB_INFO_1* PADDJOB_INFO_1, LPADDJOB_INFO_1;
+alias DATATYPES_INFO_1* PDATATYPES_INFO_1, LPDATATYPES_INFO_1;
+alias MONITOR_INFO_1* PMONITOR_INFO_1, LPMONITOR_INFO_1;
+alias MONITOR_INFO_2* PMONITOR_INFO_2, LPMONITOR_INFO_2;
+alias DOC_INFO_1* PDOC_INFO_1, LPDOC_INFO_1;
+alias DOC_INFO_2* PDOC_INFO_2, LPDOC_INFO_2;
+alias PORT_INFO_1* PPORT_INFO_1, LPPORT_INFO_1;
+alias PORT_INFO_2* PPORT_INFO_2, LPPORT_INFO_2;
+alias PORT_INFO_3* PPORT_INFO_3, LPPORT_INFO_3;
+alias DRIVER_INFO_2* PDRIVER_INFO_2, LPDRIVER_INFO_2;
+alias PRINTER_INFO_1* PPRINTER_INFO_1, LPPRINTER_INFO_1;
+alias PRINTER_INFO_2* PPRINTER_INFO_2, LPPRINTER_INFO_2;
+alias PRINTER_INFO_4* PPRINTER_INFO_4, LPPRINTER_INFO_4;
+alias PRINTER_INFO_5* PPRINTER_INFO_5, LPPRINTER_INFO_5;
+alias PRINTPROCESSOR_INFO_1* PPRINTPROCESSOR_INFO_1, LPPRINTPROCESSOR_INFO_1;
+alias FORM_INFO_1* PFORM_INFO_1, LPFORM_INFO_1;
+alias PRINTER_DEFAULTS* PPRINTER_DEFAULTS, LPPRINTER_DEFAULTS;
diff --git a/libphobos/libdruntime/core/sys/windows/winsvc.d b/libphobos/libdruntime/core/sys/windows/winsvc.d
new file mode 100644
index 00000000000..3114807d1ba
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winsvc.d
@@ -0,0 +1,427 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winsvc.d)
+ */
+module core.sys.windows.winsvc;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "advapi32");
+
+private import core.sys.windows.w32api, core.sys.windows.windef;
+
+// FIXME: check Windows version support
+
+const TCHAR[]
+    SERVICES_ACTIVE_DATABASE = "ServicesActive",
+    SERVICES_FAILED_DATABASE = "ServicesFailed";
+
+const TCHAR SC_GROUP_IDENTIFIER = '+';
+
+enum DWORD
+    SC_MANAGER_ALL_ACCESS         = 0xf003f,
+    SC_MANAGER_CONNECT            =  1,
+    SC_MANAGER_CREATE_SERVICE     =  2,
+    SC_MANAGER_ENUMERATE_SERVICE  =  4,
+    SC_MANAGER_LOCK               =  8,
+    SC_MANAGER_QUERY_LOCK_STATUS  = 16,
+    SC_MANAGER_MODIFY_BOOT_CONFIG = 32;
+
+enum DWORD SERVICE_NO_CHANGE = 0xffffffff;
+
+enum : DWORD {
+    SERVICE_STOPPED = 1,
+    SERVICE_START_PENDING,
+    SERVICE_STOP_PENDING,
+    SERVICE_RUNNING,
+    SERVICE_CONTINUE_PENDING,
+    SERVICE_PAUSE_PENDING,
+    SERVICE_PAUSED // = 7
+}
+
+enum DWORD
+    SERVICE_ACCEPT_STOP                  =   1,
+    SERVICE_ACCEPT_PAUSE_CONTINUE        =   2,
+    SERVICE_ACCEPT_SHUTDOWN              =   4,
+    SERVICE_ACCEPT_PARAMCHANGE           =   8,
+    SERVICE_ACCEPT_NETBINDCHANGE         =  16,
+    SERVICE_ACCEPT_HARDWAREPROFILECHANGE =  32,
+    SERVICE_ACCEPT_POWEREVENT            =  64,
+    SERVICE_ACCEPT_SESSIONCHANGE         = 128;
+
+enum : DWORD {
+    SERVICE_CONTROL_STOP = 1,
+    SERVICE_CONTROL_PAUSE,
+    SERVICE_CONTROL_CONTINUE,
+    SERVICE_CONTROL_INTERROGATE,
+    SERVICE_CONTROL_SHUTDOWN,
+    SERVICE_CONTROL_PARAMCHANGE,
+    SERVICE_CONTROL_NETBINDADD,
+    SERVICE_CONTROL_NETBINDREMOVE,
+    SERVICE_CONTROL_NETBINDENABLE,
+    SERVICE_CONTROL_NETBINDDISABLE,
+    SERVICE_CONTROL_DEVICEEVENT,
+    SERVICE_CONTROL_HARDWAREPROFILECHANGE,
+    SERVICE_CONTROL_POWEREVENT,
+    SERVICE_CONTROL_SESSIONCHANGE, // = 14
+}
+
+enum : DWORD {
+    SERVICE_ACTIVE = 1,
+    SERVICE_INACTIVE,
+    SERVICE_STATE_ALL
+}
+
+enum DWORD
+    SERVICE_QUERY_CONFIG         = 0x0001,
+    SERVICE_CHANGE_CONFIG        = 0x0002,
+    SERVICE_QUERY_STATUS         = 0x0004,
+    SERVICE_ENUMERATE_DEPENDENTS = 0x0008,
+    SERVICE_START                = 0x0010,
+    SERVICE_STOP                 = 0x0020,
+    SERVICE_PAUSE_CONTINUE       = 0x0040,
+    SERVICE_INTERROGATE          = 0x0080,
+    SERVICE_USER_DEFINED_CONTROL = 0x0100,
+    SERVICE_ALL_ACCESS           = 0x01FF | STANDARD_RIGHTS_REQUIRED;
+
+// This is not documented on the MSDN site
+enum SERVICE_RUNS_IN_SYSTEM_PROCESS = 1;
+
+enum : DWORD {
+    SERVICE_CONFIG_DESCRIPTION         = 1,
+    SERVICE_CONFIG_FAILURE_ACTIONS,
+    SERVICE_CONFIG_DELAYED_AUTO_START_INFO,
+    SERVICE_CONFIG_FAILURE_ACTIONS_FLAG,
+    SERVICE_CONFIG_SERVICE_SID_INFO,
+    SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO,
+    SERVICE_CONFIG_PRESHUTDOWN_INFO // = 7
+}
+
+struct SERVICE_STATUS {
+    DWORD dwServiceType;
+    DWORD dwCurrentState;
+    DWORD dwControlsAccepted;
+    DWORD dwWin32ExitCode;
+    DWORD dwServiceSpecificExitCode;
+    DWORD dwCheckPoint;
+    DWORD dwWaitHint;
+}
+alias SERVICE_STATUS* LPSERVICE_STATUS;
+
+struct ENUM_SERVICE_STATUSA {
+    LPSTR          lpServiceName;
+    LPSTR          lpDisplayName;
+    SERVICE_STATUS ServiceStatus;
+}
+alias ENUM_SERVICE_STATUSA* LPENUM_SERVICE_STATUSA;
+
+struct ENUM_SERVICE_STATUSW {
+    LPWSTR         lpServiceName;
+    LPWSTR         lpDisplayName;
+    SERVICE_STATUS ServiceStatus;
+}
+alias ENUM_SERVICE_STATUSW* LPENUM_SERVICE_STATUSW;
+
+struct QUERY_SERVICE_CONFIGA {
+    DWORD dwServiceType;
+    DWORD dwStartType;
+    DWORD dwErrorControl;
+    LPSTR lpBinaryPathName;
+    LPSTR lpLoadOrderGroup;
+    DWORD dwTagId;
+    LPSTR lpDependencies;
+    LPSTR lpServiceStartName;
+    LPSTR lpDisplayName;
+}
+alias QUERY_SERVICE_CONFIGA* LPQUERY_SERVICE_CONFIGA;
+
+struct QUERY_SERVICE_CONFIGW {
+    DWORD  dwServiceType;
+    DWORD  dwStartType;
+    DWORD  dwErrorControl;
+    LPWSTR lpBinaryPathName;
+    LPWSTR lpLoadOrderGroup;
+    DWORD  dwTagId;
+    LPWSTR lpDependencies;
+    LPWSTR lpServiceStartName;
+    LPWSTR lpDisplayName;
+}
+alias QUERY_SERVICE_CONFIGW* LPQUERY_SERVICE_CONFIGW;
+
+struct QUERY_SERVICE_LOCK_STATUSA {
+    DWORD fIsLocked;
+    LPSTR lpLockOwner;
+    DWORD dwLockDuration;
+}
+alias QUERY_SERVICE_LOCK_STATUSA* LPQUERY_SERVICE_LOCK_STATUSA;
+
+struct QUERY_SERVICE_LOCK_STATUSW {
+    DWORD  fIsLocked;
+    LPWSTR lpLockOwner;
+    DWORD  dwLockDuration;
+}
+alias QUERY_SERVICE_LOCK_STATUSW* LPQUERY_SERVICE_LOCK_STATUSW;
+
+extern (Windows) {
+    alias void function(DWORD, LPSTR*)  LPSERVICE_MAIN_FUNCTIONA;
+    alias void function(DWORD, LPWSTR*) LPSERVICE_MAIN_FUNCTIONW;
+}
+
+struct SERVICE_TABLE_ENTRYA {
+    LPSTR                    lpServiceName;
+    LPSERVICE_MAIN_FUNCTIONA lpServiceProc;
+}
+alias SERVICE_TABLE_ENTRYA* LPSERVICE_TABLE_ENTRYA;
+
+struct SERVICE_TABLE_ENTRYW {
+    LPWSTR                   lpServiceName;
+    LPSERVICE_MAIN_FUNCTIONW lpServiceProc;
+}
+alias SERVICE_TABLE_ENTRYW* LPSERVICE_TABLE_ENTRYW;
+
+mixin DECLARE_HANDLE!("SC_HANDLE");
+alias SC_HANDLE* LPSC_HANDLE;
+alias void* SC_LOCK;
+mixin DECLARE_HANDLE!("SERVICE_STATUS_HANDLE");
+
+extern (Windows) {
+    alias void function(DWORD) LPHANDLER_FUNCTION;
+    alias DWORD function(DWORD, DWORD, LPVOID, LPVOID) LPHANDLER_FUNCTION_EX;
+}
+
+static if (_WIN32_WINNT >= 0x500) {
+    struct SERVICE_STATUS_PROCESS {
+        DWORD dwServiceType;
+        DWORD dwCurrentState;
+        DWORD dwControlsAccepted;
+        DWORD dwWin32ExitCode;
+        DWORD dwServiceSpecificExitCode;
+        DWORD dwCheckPoint;
+        DWORD dwWaitHint;
+        DWORD dwProcessId;
+        DWORD dwServiceFlags;
+    }
+    alias SERVICE_STATUS_PROCESS* LPSERVICE_STATUS_PROCESS;
+
+    enum SC_STATUS_TYPE {
+        SC_STATUS_PROCESS_INFO = 0
+    }
+
+    enum SC_ENUM_TYPE {
+        SC_ENUM_PROCESS_INFO = 0
+    }
+
+    struct ENUM_SERVICE_STATUS_PROCESSA {
+        LPSTR                  lpServiceName;
+        LPSTR                  lpDisplayName;
+        SERVICE_STATUS_PROCESS ServiceStatusProcess;
+    }
+    alias ENUM_SERVICE_STATUS_PROCESSA* LPENUM_SERVICE_STATUS_PROCESSA;
+
+    struct ENUM_SERVICE_STATUS_PROCESSW {
+        LPWSTR                 lpServiceName;
+        LPWSTR                 lpDisplayName;
+        SERVICE_STATUS_PROCESS ServiceStatusProcess;
+    }
+    alias ENUM_SERVICE_STATUS_PROCESSW* LPENUM_SERVICE_STATUS_PROCESSW;
+
+    struct SERVICE_DESCRIPTIONA {
+        LPSTR lpDescription;
+    }
+    alias SERVICE_DESCRIPTIONA* LPSERVICE_DESCRIPTIONA;
+
+    struct SERVICE_DESCRIPTIONW {
+        LPWSTR lpDescription;
+    }
+    alias SERVICE_DESCRIPTIONW* LPSERVICE_DESCRIPTIONW;
+
+    enum SC_ACTION_TYPE {
+        SC_ACTION_NONE,
+        SC_ACTION_RESTART,
+        SC_ACTION_REBOOT,
+        SC_ACTION_RUN_COMMAND
+    }
+
+    struct SC_ACTION {
+        SC_ACTION_TYPE Type;
+        DWORD          Delay;
+    }
+    alias SC_ACTION* LPSC_ACTION;
+
+    struct SERVICE_FAILURE_ACTIONSA {
+        DWORD      dwResetPeriod;
+        LPSTR      lpRebootMsg;
+        LPSTR      lpCommand;
+        DWORD      cActions;
+        SC_ACTION* lpsaActions;
+    }
+    alias SERVICE_FAILURE_ACTIONSA* LPSERVICE_FAILURE_ACTIONSA;
+
+    struct SERVICE_FAILURE_ACTIONSW {
+        DWORD      dwResetPeriod;
+        LPWSTR     lpRebootMsg;
+        LPWSTR     lpCommand;
+        DWORD      cActions;
+        SC_ACTION* lpsaActions;
+    }
+    alias SERVICE_FAILURE_ACTIONSW* LPSERVICE_FAILURE_ACTIONSW;
+}
+
+extern (Windows) {
+    BOOL ChangeServiceConfigA(SC_HANDLE, DWORD, DWORD, DWORD, LPCSTR,
+      LPCSTR, LPDWORD, LPCSTR, LPCSTR, LPCSTR, LPCSTR);
+    BOOL ChangeServiceConfigW(SC_HANDLE, DWORD, DWORD, DWORD, LPCWSTR,
+      LPCWSTR, LPDWORD, LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR);
+    BOOL CloseServiceHandle(SC_HANDLE);
+    BOOL ControlService(SC_HANDLE, DWORD, LPSERVICE_STATUS);
+    SC_HANDLE CreateServiceA(SC_HANDLE, LPCSTR, LPCSTR, DWORD, DWORD,
+      DWORD, DWORD, LPCSTR, LPCSTR, PDWORD, LPCSTR, LPCSTR, LPCSTR);
+    SC_HANDLE CreateServiceW(SC_HANDLE, LPCWSTR, LPCWSTR, DWORD, DWORD,
+      DWORD, DWORD, LPCWSTR, LPCWSTR, PDWORD, LPCWSTR, LPCWSTR, LPCWSTR);
+    BOOL DeleteService(SC_HANDLE);
+    BOOL EnumDependentServicesA(SC_HANDLE, DWORD, LPENUM_SERVICE_STATUSA,
+      DWORD, PDWORD, PDWORD);
+    BOOL EnumDependentServicesW(SC_HANDLE, DWORD, LPENUM_SERVICE_STATUSW,
+      DWORD, PDWORD, PDWORD);
+    BOOL EnumServicesStatusA(SC_HANDLE, DWORD, DWORD, LPENUM_SERVICE_STATUSA,
+      DWORD, PDWORD, PDWORD, PDWORD);
+    BOOL EnumServicesStatusW(SC_HANDLE, DWORD, DWORD, LPENUM_SERVICE_STATUSW,
+      DWORD, PDWORD, PDWORD, PDWORD);
+    BOOL GetServiceDisplayNameA(SC_HANDLE, LPCSTR, LPSTR, PDWORD);
+    BOOL GetServiceDisplayNameW(SC_HANDLE, LPCWSTR, LPWSTR, PDWORD);
+    BOOL GetServiceKeyNameA(SC_HANDLE, LPCSTR, LPSTR, PDWORD);
+    BOOL GetServiceKeyNameW(SC_HANDLE, LPCWSTR, LPWSTR, PDWORD);
+    SC_LOCK LockServiceDatabase(SC_HANDLE);
+    BOOL NotifyBootConfigStatus(BOOL);
+    SC_HANDLE OpenSCManagerA(LPCSTR, LPCSTR, DWORD);
+    SC_HANDLE OpenSCManagerW(LPCWSTR, LPCWSTR, DWORD);
+    SC_HANDLE OpenServiceA(SC_HANDLE, LPCSTR, DWORD);
+    SC_HANDLE OpenServiceW(SC_HANDLE, LPCWSTR, DWORD);
+    BOOL QueryServiceConfigA(SC_HANDLE, LPQUERY_SERVICE_CONFIGA, DWORD,
+      PDWORD);
+    BOOL QueryServiceConfigW(SC_HANDLE, LPQUERY_SERVICE_CONFIGW, DWORD,
+      PDWORD);
+    BOOL QueryServiceLockStatusA(SC_HANDLE, LPQUERY_SERVICE_LOCK_STATUSA,
+      DWORD, PDWORD);
+    BOOL QueryServiceLockStatusW(SC_HANDLE, LPQUERY_SERVICE_LOCK_STATUSW,
+      DWORD, PDWORD);
+    BOOL QueryServiceObjectSecurity(SC_HANDLE, SECURITY_INFORMATION,
+      PSECURITY_DESCRIPTOR, DWORD, LPDWORD);
+    BOOL QueryServiceStatus(SC_HANDLE, LPSERVICE_STATUS);
+    SERVICE_STATUS_HANDLE RegisterServiceCtrlHandlerA(LPCSTR,
+      LPHANDLER_FUNCTION);
+    SERVICE_STATUS_HANDLE RegisterServiceCtrlHandlerW(LPCWSTR,
+      LPHANDLER_FUNCTION);
+    BOOL SetServiceObjectSecurity(SC_HANDLE, SECURITY_INFORMATION,
+      PSECURITY_DESCRIPTOR);
+    BOOL SetServiceStatus(SERVICE_STATUS_HANDLE, LPSERVICE_STATUS);
+    BOOL StartServiceA(SC_HANDLE, DWORD, LPCSTR*);
+    BOOL StartServiceW(SC_HANDLE, DWORD, LPCWSTR*);
+    BOOL StartServiceCtrlDispatcherA(LPSERVICE_TABLE_ENTRYA);
+    BOOL StartServiceCtrlDispatcherW(LPSERVICE_TABLE_ENTRYW);
+    BOOL UnlockServiceDatabase(SC_LOCK);
+
+    static if (_WIN32_WINNT >= 0x500) {
+        BOOL EnumServicesStatusExA(SC_HANDLE, SC_ENUM_TYPE, DWORD, DWORD, LPBYTE,
+          DWORD, LPDWORD, LPDWORD, LPDWORD, LPCSTR);
+        BOOL EnumServicesStatusExW(SC_HANDLE, SC_ENUM_TYPE, DWORD, DWORD, LPBYTE,
+          DWORD, LPDWORD, LPDWORD, LPDWORD, LPCWSTR);
+        BOOL QueryServiceConfig2A(SC_HANDLE, DWORD, LPBYTE, DWORD, LPDWORD);
+        BOOL QueryServiceConfig2W(SC_HANDLE, DWORD, LPBYTE, DWORD, LPDWORD);
+        BOOL QueryServiceStatusEx(SC_HANDLE, SC_STATUS_TYPE, LPBYTE, DWORD,
+          LPDWORD);
+        SERVICE_STATUS_HANDLE RegisterServiceCtrlHandlerExA(LPCSTR,
+          LPHANDLER_FUNCTION_EX, LPVOID);
+        SERVICE_STATUS_HANDLE RegisterServiceCtrlHandlerExW(LPCWSTR,
+          LPHANDLER_FUNCTION_EX, LPVOID);
+    }
+
+    static if (_WIN32_WINNT >= 0x501) {
+        BOOL ChangeServiceConfig2A(SC_HANDLE, DWORD, LPVOID);
+        BOOL ChangeServiceConfig2W(SC_HANDLE, DWORD, LPVOID);
+    }
+}
+
+version (Unicode) {
+    alias ENUM_SERVICE_STATUSW ENUM_SERVICE_STATUS;
+    alias QUERY_SERVICE_CONFIGW QUERY_SERVICE_CONFIG;
+    alias QUERY_SERVICE_LOCK_STATUSW QUERY_SERVICE_LOCK_STATUS;
+    alias LPSERVICE_MAIN_FUNCTIONW LPSERVICE_MAIN_FUNCTION;
+    alias SERVICE_TABLE_ENTRYW SERVICE_TABLE_ENTRY;
+    alias ChangeServiceConfigW ChangeServiceConfig;
+    alias CreateServiceW CreateService;
+    alias EnumDependentServicesW EnumDependentServices;
+    alias EnumServicesStatusW EnumServicesStatus;
+    alias GetServiceDisplayNameW GetServiceDisplayName;
+    alias GetServiceKeyNameW GetServiceKeyName;
+    alias OpenSCManagerW OpenSCManager;
+    alias OpenServiceW OpenService;
+    alias QueryServiceConfigW QueryServiceConfig;
+    alias QueryServiceLockStatusW QueryServiceLockStatus;
+    alias RegisterServiceCtrlHandlerW RegisterServiceCtrlHandler;
+    alias StartServiceW StartService;
+    alias StartServiceCtrlDispatcherW StartServiceCtrlDispatcher;
+
+    static if (_WIN32_WINNT >= 0x500) {
+        alias ENUM_SERVICE_STATUS_PROCESSW ENUM_SERVICE_STATUS_PROCESS;
+        alias SERVICE_DESCRIPTIONW SERVICE_DESCRIPTION;
+        alias SERVICE_FAILURE_ACTIONSW SERVICE_FAILURE_ACTIONS;
+        alias EnumServicesStatusExW EnumServicesStatusEx;
+        alias QueryServiceConfig2W QueryServiceConfig2;
+        alias RegisterServiceCtrlHandlerExW RegisterServiceCtrlHandlerEx;
+    }
+
+    static if (_WIN32_WINNT >= 0x501) {
+        alias ChangeServiceConfig2W ChangeServiceConfig2;
+    }
+
+} else {
+    alias ENUM_SERVICE_STATUSA ENUM_SERVICE_STATUS;
+    alias QUERY_SERVICE_CONFIGA QUERY_SERVICE_CONFIG;
+    alias QUERY_SERVICE_LOCK_STATUSA QUERY_SERVICE_LOCK_STATUS;
+    alias LPSERVICE_MAIN_FUNCTIONA LPSERVICE_MAIN_FUNCTION;
+    alias SERVICE_TABLE_ENTRYA SERVICE_TABLE_ENTRY;
+    alias ChangeServiceConfigA ChangeServiceConfig;
+    alias CreateServiceA CreateService;
+    alias EnumDependentServicesA EnumDependentServices;
+    alias EnumServicesStatusA EnumServicesStatus;
+    alias GetServiceDisplayNameA GetServiceDisplayName;
+    alias GetServiceKeyNameA GetServiceKeyName;
+    alias OpenSCManagerA OpenSCManager;
+    alias OpenServiceA OpenService;
+    alias QueryServiceConfigA QueryServiceConfig;
+    alias QueryServiceLockStatusA QueryServiceLockStatus;
+    alias RegisterServiceCtrlHandlerA RegisterServiceCtrlHandler;
+    alias StartServiceA StartService;
+    alias StartServiceCtrlDispatcherA StartServiceCtrlDispatcher;
+
+    static if (_WIN32_WINNT >= 0x500) {
+        alias ENUM_SERVICE_STATUS_PROCESSA ENUM_SERVICE_STATUS_PROCESS;
+        alias SERVICE_DESCRIPTIONA SERVICE_DESCRIPTION;
+        alias SERVICE_FAILURE_ACTIONSA SERVICE_FAILURE_ACTIONS;
+        alias EnumServicesStatusExA EnumServicesStatusEx;
+        alias QueryServiceConfig2A QueryServiceConfig2;
+        alias RegisterServiceCtrlHandlerExA RegisterServiceCtrlHandlerEx;
+    }
+
+    static if (_WIN32_WINNT >= 0x501) {
+        alias ChangeServiceConfig2A ChangeServiceConfig2;
+    }
+
+}
+
+alias ENUM_SERVICE_STATUS* LPENUM_SERVICE_STATUS;
+alias QUERY_SERVICE_CONFIG* LPQUERY_SERVICE_CONFIG;
+alias QUERY_SERVICE_LOCK_STATUS* LPQUERY_SERVICE_LOCK_STATUS;
+alias SERVICE_TABLE_ENTRY* LPSERVICE_TABLE_ENTRY;
+
+static if (_WIN32_WINNT >= 0x500) {
+    alias ENUM_SERVICE_STATUS_PROCESS* LPENUM_SERVICE_STATUS_PROCESS;
+    alias SERVICE_DESCRIPTION* LPSERVICE_DESCRIPTION;
+    alias SERVICE_FAILURE_ACTIONS* LPSERVICE_FAILURE_ACTIONS;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/winuser.d b/libphobos/libdruntime/core/sys/windows/winuser.d
new file mode 100644
index 00000000000..4b7d8449c70
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winuser.d
@@ -0,0 +1,4897 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winuser.d)
+ */
+module core.sys.windows.winuser;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "user32");
+
+// Conversion Notes:
+// The following macros were for win16 only, and are not included in this file:
+//#define EnumTaskWindows(h, f, p) EnumThreadWindows((DWORD)h, f, p)
+//#define PostAppMessageA(t, m, w, l) PostThreadMessageA((DWORD)t, m, w, l)
+//#define PostAppMessageW(t, m, w, l) PostThreadMessageW((DWORD)t, m, w, l)
+//#define GetSysModalWindow() (NULL)
+//#define SetSysModalWindow(h) (NULL)
+//#define GetWindowTask(hWnd) ((HANDLE)GetWindowThreadProcessId(hWnd, NULL))
+//#define DefHookProc(c, p, lp, h) CallNextHookEx((HHOOK)*h, c, p, lp)
+
+private import core.sys.windows.w32api, core.sys.windows.winbase, core.sys.windows.wingdi;
+private import core.sys.windows.windef; // for HMONITOR
+
+// FIXME: clean up Windows version support
+
+LPTSTR MAKEINTATOM_T()(int i) {
+    return cast(LPTSTR) i;
+}
+
+enum LPTSTR WC_DIALOG = MAKEINTATOM_T(0x8002);
+
+enum {
+    FAPPCOMMAND_MOUSE = 0x8000,
+    FAPPCOMMAND_KEY   = 0,
+    FAPPCOMMAND_OEM   = 0x1000,
+    FAPPCOMMAND_MASK  = 0xF000
+}
+
+enum {
+    MNGO_NOINTERFACE = 0,
+    MNGO_NOERROR,
+    MNGOF_TOPGAP     = 1,
+    MNGOF_BOTTOMGAP
+}
+
+enum {
+    FVIRTKEY  = 1,
+    FNOINVERT = 2,
+    FSHIFT    = 4,
+    FCONTROL  = 8,
+    FALT      = 16
+}
+
+enum {
+    ATF_TIMEOUTON     = 1,
+    ATF_ONOFFFEEDBACK = 2,
+    ATF_AVAILABLE     = 4 // May be obsolete. Not in recent MS docs.
+}
+
+enum {
+    WH_MIN             = -1,
+    WH_MSGFILTER       = -1,
+    WH_JOURNALRECORD,
+    WH_JOURNALPLAYBACK,
+    WH_KEYBOARD,
+    WH_GETMESSAGE,
+    WH_CALLWNDPROC,
+    WH_CBT,
+    WH_SYSMSGFILTER,
+    WH_MOUSE,
+    WH_HARDWARE,
+    WH_DEBUG,
+    WH_SHELL,
+    WH_FOREGROUNDIDLE,
+    WH_CALLWNDPROCRET,
+    WH_KEYBOARD_LL,
+    WH_MOUSE_LL,    // = 14
+    WH_MAX             = 14,
+    WH_MINHOOK         = WH_MIN,
+    WH_MAXHOOK         = WH_MAX
+}
+
+enum {
+    HC_ACTION       = 0,
+    HC_GETNEXT,
+    HC_SKIP,
+    HC_NOREMOVE, // = 3
+    HC_NOREM        = HC_NOREMOVE,
+    HC_SYSMODALON,
+    HC_SYSMODALOFF
+}
+
+enum {
+    HCBT_MOVESIZE    = 0,
+    HCBT_MINMAX,
+    HCBT_QS,
+    HCBT_CREATEWND,
+    HCBT_DESTROYWND,
+    HCBT_ACTIVATE,
+    HCBT_CLICKSKIPPED,
+    HCBT_KEYSKIPPED,
+    HCBT_SYSCOMMAND,
+    HCBT_SETFOCUS // = 9
+}
+
+enum {
+    CF_TEXT                = 0x0001,
+    CF_BITMAP,
+    CF_METAFILEPICT,
+    CF_SYLK,
+    CF_DIF,
+    CF_TIFF,
+    CF_OEMTEXT,
+    CF_DIB,
+    CF_PALETTE,
+    CF_PENDATA,
+    CF_RIFF,
+    CF_WAVE,
+    CF_UNICODETEXT,
+    CF_ENHMETAFILE,
+    CF_HDROP,
+    CF_LOCALE,
+    CF_DIBV5,
+    CF_MAX,             // = 0x0012
+    CF_OWNERDISPLAY        = 0x0080,
+    CF_DSPTEXT,
+    CF_DSPBITMAP,
+    CF_DSPMETAFILEPICT, // = 0x0083
+    CF_DSPENHMETAFILE      = 0x008E,
+    CF_PRIVATEFIRST        = 0x0200,
+    CF_PRIVATELAST         = 0x02FF,
+    CF_GDIOBJFIRST         = 0x0300,
+    CF_GDIOBJLAST          = 0x03FF
+}
+
+enum HKL_PREV = 0;
+enum HKL_NEXT = 1;
+
+enum KLF_ACTIVATE       = 1;
+enum KLF_SUBSTITUTE_OK  = 2;
+enum KLF_UNLOADPREVIOUS = 4;
+enum KLF_REORDER        = 8;
+enum KLF_REPLACELANG    = 16;
+enum KLF_NOTELLSHELL    = 128;
+enum KLF_SETFORPROCESS  = 256;
+enum KL_NAMELENGTH      = 9;
+
+enum MF_ENABLED = 0;
+enum MF_GRAYED = 1;
+enum MF_DISABLED = 2;
+enum MF_BITMAP = 4;
+enum MF_CHECKED = 8;
+enum MF_MENUBARBREAK = 32;
+enum MF_MENUBREAK = 64;
+enum MF_OWNERDRAW = 256;
+enum MF_POPUP = 16;
+enum MF_SEPARATOR = 0x800;
+enum MF_STRING = 0;
+enum MF_UNCHECKED = 0;
+enum MF_DEFAULT = 4096;
+enum MF_SYSMENU = 0x2000;
+enum MF_HELP = 0x4000;
+enum MF_END = 128;
+enum MF_RIGHTJUSTIFY = 0x4000;
+enum MF_MOUSESELECT = 0x8000;
+enum MF_INSERT = 0;
+enum MF_CHANGE = 128;
+enum MF_APPEND = 256;
+enum MF_DELETE = 512;
+enum MF_REMOVE = 4096;
+enum MF_USECHECKBITMAPS = 512;
+enum MF_UNHILITE = 0;
+enum MF_HILITE = 128;
+
+// Also defined in dbt.h
+enum BSM_ALLCOMPONENTS      = 0;
+enum BSM_VXDS               = 1;
+enum BSM_NETDRIVER          = 2;
+enum BSM_INSTALLABLEDRIVERS = 4;
+enum BSM_APPLICATIONS       = 8;
+enum BSM_ALLDESKTOPS        = 16;
+
+enum {
+    BSF_QUERY              = 0x0001,
+    BSF_IGNORECURRENTTASK  = 0x0002,
+    BSF_FLUSHDISK          = 0x0004,
+    BSF_NOHANG             = 0x0008,
+    BSF_POSTMESSAGE        = 0x0010,
+    BSF_FORCEIFHUNG        = 0x0020,
+    BSF_NOTIMEOUTIFNOTHUNG = 0x0040,
+    BSF_ALLOWSFW           = 0x0080,
+    BSF_SENDNOTIFYMESSAGE  = 0x0100
+}
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        BSF_RETURNHDESK    = 0x0200,
+        BSF_LUID           = 0x0400
+    }
+}
+
+enum BROADCAST_QUERY_DENY = 1112363332;
+enum DWORD ENUM_CURRENT_SETTINGS  = -1;
+enum DWORD ENUM_REGISTRY_SETTINGS = -2;
+
+enum CDS_UPDATEREGISTRY = 1;
+enum CDS_TEST           = 2;
+enum CDS_FULLSCREEN     = 4;
+enum CDS_GLOBAL         = 8;
+enum CDS_SET_PRIMARY    = 16;
+enum CDS_NORESET        = 0x10000000;
+enum CDS_SETRECT        = 0x20000000;
+enum CDS_RESET          = 0x40000000;
+
+enum {
+    DISP_CHANGE_BADPARAM   = -5,
+    DISP_CHANGE_BADFLAGS,
+    DISP_CHANGE_NOTUPDATED,
+    DISP_CHANGE_BADMODE,
+    DISP_CHANGE_FAILED,
+    DISP_CHANGE_SUCCESSFUL,
+    DISP_CHANGE_RESTART // =  1
+}
+
+enum BST_UNCHECKED     = 0;
+enum BST_CHECKED       = 1;
+enum BST_INDETERMINATE = 2;
+enum BST_PUSHED        = 4;
+enum BST_FOCUS         = 8;
+
+enum MF_BYCOMMAND  = 0;
+enum MF_BYPOSITION = 1024;
+// [Redefined] MF_UNCHECKED = 0
+// [Redefined] MF_HILITE = 128
+// [Redefined] MF_UNHILITE = 0
+
+enum CWP_ALL             = 0;
+enum CWP_SKIPINVISIBLE   = 1;
+enum CWP_SKIPDISABLED    = 2;
+enum CWP_SKIPTRANSPARENT = 4;
+
+enum IMAGE_BITMAP = 0;
+enum IMAGE_ICON = 1;
+enum IMAGE_CURSOR = 2;
+enum IMAGE_ENHMETAFILE = 3;
+
+enum DF_ALLOWOTHERACCOUNTHOOK = 1;
+
+enum DESKTOP_READOBJECTS     = 1;
+enum DESKTOP_CREATEWINDOW    = 2;
+enum DESKTOP_CREATEMENU      = 4;
+enum DESKTOP_HOOKCONTROL     = 8;
+enum DESKTOP_JOURNALRECORD   = 16;
+enum DESKTOP_JOURNALPLAYBACK = 32;
+enum DESKTOP_ENUMERATE       = 64;
+enum DESKTOP_WRITEOBJECTS    = 128;
+enum DESKTOP_SWITCHDESKTOP   = 256;
+
+enum int CW_USEDEFAULT = 0x80000000;
+
+enum {
+    WS_OVERLAPPED       = 0,
+    WS_TILED            = WS_OVERLAPPED,
+    WS_MAXIMIZEBOX      = 0x00010000,
+    WS_MINIMIZEBOX      = 0x00020000,
+    WS_TABSTOP          = 0x00010000,
+    WS_GROUP            = 0x00020000,
+    WS_THICKFRAME       = 0x00040000,
+    WS_SIZEBOX          = WS_THICKFRAME,
+    WS_SYSMENU          = 0x00080000,
+    WS_HSCROLL          = 0x00100000,
+    WS_VSCROLL          = 0x00200000,
+    WS_DLGFRAME         = 0x00400000,
+    WS_BORDER           = 0x00800000,
+    WS_CAPTION          = 0x00c00000,
+    WS_OVERLAPPEDWINDOW = WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,
+    WS_TILEDWINDOW      = WS_OVERLAPPEDWINDOW,
+    WS_MAXIMIZE         = 0x01000000,
+    WS_CLIPCHILDREN     = 0x02000000,
+    WS_CLIPSIBLINGS     = 0x04000000,
+    WS_DISABLED         = 0x08000000,
+    WS_VISIBLE          = 0x10000000,
+    WS_MINIMIZE         = 0x20000000,
+    WS_ICONIC           = WS_MINIMIZE,
+    WS_CHILD            = 0x40000000,
+    WS_CHILDWINDOW      = 0x40000000,
+    WS_POPUP            = 0x80000000,
+    WS_POPUPWINDOW      = WS_POPUP|WS_BORDER|WS_SYSMENU,
+}
+
+enum MDIS_ALLCHILDSTYLES = 1;
+
+enum BS_3STATE = 5;
+enum BS_AUTO3STATE = 6;
+enum BS_AUTOCHECKBOX = 3;
+enum BS_AUTORADIOBUTTON = 9;
+enum BS_BITMAP = 128;
+enum BS_BOTTOM = 0x800;
+enum BS_CENTER = 0x300;
+enum BS_CHECKBOX = 2;
+enum BS_DEFPUSHBUTTON = 1;
+enum BS_GROUPBOX = 7;
+enum BS_ICON = 64;
+enum BS_LEFT = 256;
+enum BS_LEFTTEXT = 32;
+enum BS_MULTILINE = 0x2000;
+enum BS_NOTIFY = 0x4000;
+enum BS_OWNERDRAW = 0xb;
+enum BS_PUSHBUTTON = 0;
+enum BS_PUSHLIKE = 4096;
+enum BS_RADIOBUTTON = 4;
+enum BS_RIGHT = 512;
+enum BS_RIGHTBUTTON = 32;
+enum BS_TEXT = 0;
+enum BS_TOP = 0x400;
+enum BS_USERBUTTON = 8;
+enum BS_VCENTER = 0xc00;
+enum BS_FLAT = 0x8000;
+
+enum CBS_AUTOHSCROLL = 64;
+enum CBS_DISABLENOSCROLL = 0x800;
+enum CBS_DROPDOWN = 2;
+enum CBS_DROPDOWNLIST = 3;
+enum CBS_HASSTRINGS = 512;
+enum CBS_LOWERCASE = 0x4000;
+enum CBS_NOINTEGRALHEIGHT = 0x400;
+enum CBS_OEMCONVERT = 128;
+enum CBS_OWNERDRAWFIXED = 16;
+enum CBS_OWNERDRAWVARIABLE = 32;
+enum CBS_SIMPLE = 1;
+enum CBS_SORT = 256;
+enum CBS_UPPERCASE = 0x2000;
+
+enum ES_AUTOHSCROLL = 128;
+enum ES_AUTOVSCROLL = 64;
+enum ES_CENTER = 1;
+enum ES_LEFT = 0;
+enum ES_LOWERCASE = 16;
+enum ES_MULTILINE = 4;
+enum ES_NOHIDESEL = 256;
+enum ES_NUMBER = 0x2000;
+enum ES_OEMCONVERT = 0x400;
+enum ES_PASSWORD = 32;
+enum ES_READONLY = 0x800;
+enum ES_RIGHT = 2;
+enum ES_UPPERCASE = 8;
+enum ES_WANTRETURN = 4096;
+
+enum LBS_DISABLENOSCROLL = 4096;
+enum LBS_EXTENDEDSEL = 0x800;
+enum LBS_HASSTRINGS = 64;
+enum LBS_MULTICOLUMN = 512;
+enum LBS_MULTIPLESEL = 8;
+enum LBS_NODATA = 0x2000;
+enum LBS_NOINTEGRALHEIGHT = 256;
+enum LBS_NOREDRAW = 4;
+enum LBS_NOSEL = 0x4000;
+enum LBS_NOTIFY = 1;
+enum LBS_OWNERDRAWFIXED = 16;
+enum LBS_OWNERDRAWVARIABLE = 32;
+enum LBS_SORT = 2;
+enum LBS_STANDARD = 0xa00003;
+enum LBS_USETABSTOPS = 128;
+enum LBS_WANTKEYBOARDINPUT = 0x400;
+
+enum SBS_BOTTOMALIGN = 4;
+enum SBS_HORZ = 0;
+enum SBS_LEFTALIGN = 2;
+enum SBS_RIGHTALIGN = 4;
+enum SBS_SIZEBOX = 8;
+enum SBS_SIZEBOXBOTTOMRIGHTALIGN = 4;
+enum SBS_SIZEBOXTOPLEFTALIGN = 2;
+enum SBS_SIZEGRIP = 16;
+enum SBS_TOPALIGN = 2;
+enum SBS_VERT = 1;
+
+enum SS_BITMAP = 14;
+enum SS_BLACKFRAME = 7;
+enum SS_BLACKRECT = 4;
+enum SS_CENTER = 1;
+enum SS_CENTERIMAGE = 512;
+enum SS_ENHMETAFILE = 15;
+enum SS_ETCHEDFRAME = 18;
+enum SS_ETCHEDHORZ = 16;
+enum SS_ETCHEDVERT = 17;
+enum SS_GRAYFRAME = 8;
+enum SS_GRAYRECT = 5;
+enum SS_ICON = 3;
+enum SS_LEFT = 0;
+enum SS_LEFTNOWORDWRAP = 0xc;
+enum SS_NOPREFIX = 128;
+enum SS_NOTIFY = 256;
+enum SS_OWNERDRAW = 0xd;
+enum SS_REALSIZEIMAGE = 0x800;
+enum SS_RIGHT = 2;
+enum SS_RIGHTJUST = 0x400;
+enum SS_SIMPLE = 11;
+enum SS_SUNKEN = 4096;
+enum SS_WHITEFRAME = 9;
+enum SS_WHITERECT = 6;
+enum SS_USERITEM = 10;
+enum SS_TYPEMASK = 0x0000001FL;
+enum SS_ENDELLIPSIS = 0x00004000L;
+enum SS_PATHELLIPSIS = 0x00008000L;
+enum SS_WORDELLIPSIS = 0x0000C000L;
+enum SS_ELLIPSISMASK = 0x0000C000L;
+
+enum DS_ABSALIGN      = 0x0001;
+enum DS_3DLOOK        = 0x0004;
+enum DS_SYSMODAL      = 0x0002;
+enum DS_FIXEDSYS      = 0x0008;
+enum DS_NOFAILCREATE  = 0x0010;
+enum DS_LOCALEDIT     = 0x0020;
+enum DS_SETFONT       = 0x0040;
+enum DS_MODALFRAME    = 0x0080;
+enum DS_NOIDLEMSG     = 0x0100;
+enum DS_SETFOREGROUND = 0x0200;
+enum DS_CONTROL       = 0x0400;
+enum DS_CENTER        = 0x0800;
+enum DS_CENTERMOUSE   = 0x1000;
+enum DS_CONTEXTHELP   = 0x2000;
+enum DS_SHELLFONT     = DS_SETFONT | DS_FIXEDSYS;
+
+enum WS_EX_ACCEPTFILES = 16;
+enum WS_EX_APPWINDOW = 0x40000;
+enum WS_EX_CLIENTEDGE = 512;
+enum WS_EX_COMPOSITED = 0x2000000;  // XP
+enum WS_EX_CONTEXTHELP = 0x400;
+enum WS_EX_CONTROLPARENT = 0x10000;
+enum WS_EX_DLGMODALFRAME = 1;
+enum WS_EX_LAYERED = 0x80000;  // w2k
+enum WS_EX_LAYOUTRTL = 0x400000;  // w98, w2k
+enum WS_EX_LEFT = 0;
+enum WS_EX_LEFTSCROLLBAR = 0x4000;
+enum WS_EX_LTRREADING = 0;
+enum WS_EX_MDICHILD = 64;
+enum WS_EX_NOACTIVATE = 0x8000000;  // w2k
+enum WS_EX_NOINHERITLAYOUT = 0x100000;  // w2k
+enum WS_EX_NOPARENTNOTIFY = 4;
+enum WS_EX_OVERLAPPEDWINDOW = 0x300;
+enum WS_EX_PALETTEWINDOW = 0x188;
+enum WS_EX_RIGHT = 0x1000;
+enum WS_EX_RIGHTSCROLLBAR = 0;
+enum WS_EX_RTLREADING = 0x2000;
+enum WS_EX_STATICEDGE = 0x20000;
+enum WS_EX_TOOLWINDOW = 128;
+enum WS_EX_TOPMOST = 8;
+enum WS_EX_TRANSPARENT = 32;
+enum WS_EX_WINDOWEDGE = 256;
+
+enum WINSTA_ENUMDESKTOPS      = 1;
+enum WINSTA_READATTRIBUTES    = 2;
+enum WINSTA_ACCESSCLIPBOARD   = 4;
+enum WINSTA_CREATEDESKTOP     = 8;
+enum WINSTA_WRITEATTRIBUTES   = 16;
+enum WINSTA_ACCESSGLOBALATOMS = 32;
+enum WINSTA_EXITWINDOWS       = 64;
+enum WINSTA_ENUMERATE         = 256;
+enum WINSTA_READSCREEN        = 512;
+
+enum DDL_READWRITE = 0;
+enum DDL_READONLY  = 1;
+enum DDL_HIDDEN    = 2;
+enum DDL_SYSTEM    = 4;
+enum DDL_DIRECTORY = 16;
+enum DDL_ARCHIVE   = 32;
+enum DDL_POSTMSGS  = 8192;
+enum DDL_DRIVES    = 16384;
+enum DDL_EXCLUSIVE = 32768;
+
+enum {
+    DC_ACTIVE       = 0x0001,
+    DC_SMALLCAP     = 0x0002,
+    DC_ICON         = 0x0004,
+    DC_TEXT         = 0x0008,
+    DC_INBUTTON     = 0x0010,
+    DC_GRADIENT     = 0x0020
+}
+static if (_WIN32_WINNT >= 0x501) {
+    enum DC_BUTTONS = 0x1000;
+}
+
+// Where are these documented?
+//enum DC_CAPTION = DC_ICON|DC_TEXT|DC_BUTTONS;
+//enum DC_NC      = DC_CAPTION|DC_FRAME;
+
+enum BDR_RAISEDOUTER = 1;
+enum BDR_SUNKENOUTER = 2;
+enum BDR_RAISEDINNER = 4;
+enum BDR_SUNKENINNER = 8;
+enum BDR_OUTER       = 3;
+enum BDR_INNER       = 0xc;
+enum BDR_RAISED      = 5;
+enum BDR_SUNKEN      = 10;
+
+enum EDGE_RAISED = BDR_RAISEDOUTER|BDR_RAISEDINNER;
+enum EDGE_SUNKEN = BDR_SUNKENOUTER|BDR_SUNKENINNER;
+enum EDGE_ETCHED = BDR_SUNKENOUTER|BDR_RAISEDINNER;
+enum EDGE_BUMP   = BDR_RAISEDOUTER|BDR_SUNKENINNER;
+
+enum BF_LEFT                    = 1;
+enum BF_TOP                     = 2;
+enum BF_RIGHT                   = 4;
+enum BF_BOTTOM                  = 8;
+enum BF_TOPLEFT                 = BF_TOP|BF_LEFT;
+enum BF_TOPRIGHT                = BF_TOP|BF_RIGHT;
+enum BF_BOTTOMLEFT              = BF_BOTTOM|BF_LEFT;
+enum BF_BOTTOMRIGHT             = BF_BOTTOM|BF_RIGHT;
+enum BF_RECT                    = BF_LEFT|BF_TOP|BF_RIGHT|BF_BOTTOM ;
+enum BF_DIAGONAL                = 16;
+enum BF_DIAGONAL_ENDTOPRIGHT    = BF_DIAGONAL|BF_TOP|BF_RIGHT;
+enum BF_DIAGONAL_ENDTOPLEFT     = BF_DIAGONAL|BF_TOP|BF_LEFT;
+enum BF_DIAGONAL_ENDBOTTOMLEFT  = BF_DIAGONAL|BF_BOTTOM|BF_LEFT;
+enum BF_DIAGONAL_ENDBOTTOMRIGHT = BF_DIAGONAL|BF_BOTTOM|BF_RIGHT;
+enum BF_MIDDLE                  = 0x800;
+enum BF_SOFT                    = 0x1000;
+enum BF_ADJUST                  = 0x2000;
+enum BF_FLAT                    = 0x4000;
+enum BF_MONO                    = 0x8000;
+
+enum {
+    DFC_CAPTION      = 1,
+    DFC_MENU,
+    DFC_SCROLL,
+    DFC_BUTTON,
+    DFC_POPUPMENU // = 5
+}
+
+enum {
+    DFCS_CAPTIONCLOSE,
+    DFCS_CAPTIONMIN,
+    DFCS_CAPTIONMAX,
+    DFCS_CAPTIONRESTORE,
+    DFCS_CAPTIONHELP // = 4
+}
+
+enum {
+    DFCS_MENUARROW      = 0,
+    DFCS_MENUCHECK      = 1,
+    DFCS_MENUBULLET     = 2,
+    DFCS_MENUARROWRIGHT = 4
+}
+
+enum {
+    DFCS_SCROLLUP            =  0,
+    DFCS_SCROLLDOWN          =  1,
+    DFCS_SCROLLLEFT          =  2,
+    DFCS_SCROLLRIGHT         =  3,
+    DFCS_SCROLLCOMBOBOX      =  5,
+    DFCS_SCROLLSIZEGRIP      =  8,
+    DFCS_SCROLLSIZEGRIPRIGHT = 16
+}
+
+enum {
+    DFCS_BUTTONCHECK         = 0,
+    DFCS_BUTTONRADIOIMAGE    = 0x0001,
+    DFCS_BUTTONRADIOMASK     = 0x0002,
+    DFCS_BUTTONRADIO         = 0x0004,
+    DFCS_BUTTON3STATE        = 0x0008,
+    DFCS_BUTTONPUSH          = 0x0010,
+    DFCS_INACTIVE            = 0x0100,
+    DFCS_PUSHED              = 0x0200,
+    DFCS_CHECKED             = 0x0400,
+    DFCS_TRANSPARENT         = 0x0800,
+    DFCS_HOT                 = 0x1000,
+    DFCS_ADJUSTRECT          = 0x2000,
+    DFCS_FLAT                = 0x4000,
+    DFCS_MONO                = 0x8000
+}
+
+enum {
+    DST_COMPLEX = 0,
+    DST_TEXT,
+    DST_PREFIXTEXT,
+    DST_ICON,
+    DST_BITMAP // = 4
+}
+
+enum DSS_NORMAL = 0;
+enum DSS_UNION = 16;
+enum DSS_DISABLED = 32;
+enum DSS_MONO = 128;
+enum DSS_RIGHT = 0x8000;
+
+enum DT_BOTTOM = 8;
+enum DT_CALCRECT = 1024;
+enum DT_CENTER = 1;
+enum DT_EDITCONTROL = 8192;
+enum DT_END_ELLIPSIS = 32768;
+enum DT_PATH_ELLIPSIS = 16384;
+enum DT_WORD_ELLIPSIS = 0x40000;
+enum DT_EXPANDTABS = 64;
+enum DT_EXTERNALLEADING = 512;
+enum DT_LEFT = 0;
+enum DT_MODIFYSTRING = 65536;
+enum DT_NOCLIP = 256;
+enum DT_NOPREFIX = 2048;
+enum DT_RIGHT = 2;
+enum DT_RTLREADING = 131072;
+enum DT_SINGLELINE = 32;
+enum DT_TABSTOP = 128;
+enum DT_TOP = 0;
+enum DT_VCENTER = 4;
+enum DT_WORDBREAK = 16;
+enum DT_INTERNAL = 4096;
+
+enum WB_ISDELIMITER = 2;
+enum WB_LEFT = 0;
+enum WB_RIGHT = 1;
+
+enum SB_HORZ = 0;
+enum SB_VERT = 1;
+enum SB_CTL = 2;
+enum SB_BOTH = 3;
+
+enum ESB_DISABLE_BOTH = 3;
+enum ESB_DISABLE_DOWN = 2;
+enum ESB_DISABLE_LEFT = 1;
+enum ESB_DISABLE_LTUP = 1;
+enum ESB_DISABLE_RIGHT = 2;
+enum ESB_DISABLE_RTDN = 2;
+enum ESB_DISABLE_UP = 1;
+enum ESB_ENABLE_BOTH = 0;
+
+enum SB_LINEUP = 0;
+enum SB_LINEDOWN = 1;
+enum SB_LINELEFT = 0;
+enum SB_LINERIGHT = 1;
+enum SB_PAGEUP = 2;
+enum SB_PAGEDOWN = 3;
+enum SB_PAGELEFT = 2;
+enum SB_PAGERIGHT = 3;
+enum SB_THUMBPOSITION = 4;
+enum SB_THUMBTRACK = 5;
+enum SB_ENDSCROLL = 8;
+enum SB_LEFT = 6;
+enum SB_RIGHT = 7;
+enum SB_BOTTOM = 7;
+enum SB_TOP = 6;
+
+//MACRO #define IS_INTRESOURCE(i) (((ULONG_PTR)(i) >> 16) == 0)
+
+template MAKEINTRESOURCE_T(WORD i) {
+    enum LPTSTR MAKEINTRESOURCE_T = cast(LPTSTR)(i);
+}
+
+nothrow @nogc {
+    LPSTR MAKEINTRESOURCEA(/*WORD*/uint i) {
+        return cast(LPSTR) i;
+    }
+
+    LPWSTR MAKEINTRESOURCEW(/*WORD*/uint i) {
+        return cast(LPWSTR) i;
+    }
+}
+
+enum RT_CURSOR       = MAKEINTRESOURCE_T!(1);
+enum RT_BITMAP       = MAKEINTRESOURCE_T!(2);
+enum RT_ICON         = MAKEINTRESOURCE_T!(3);
+enum RT_MENU         = MAKEINTRESOURCE_T!(4);
+enum RT_DIALOG       = MAKEINTRESOURCE_T!(5);
+enum RT_STRING       = MAKEINTRESOURCE_T!(6);
+enum RT_FONTDIR      = MAKEINTRESOURCE_T!(7);
+enum RT_FONT         = MAKEINTRESOURCE_T!(8);
+enum RT_ACCELERATOR  = MAKEINTRESOURCE_T!(9);
+enum RT_RCDATA       = MAKEINTRESOURCE_T!(10);
+enum RT_MESSAGETABLE = MAKEINTRESOURCE_T!(11);
+
+enum RT_GROUP_CURSOR = MAKEINTRESOURCE_T!(12);
+enum RT_GROUP_ICON   = MAKEINTRESOURCE_T!(14);
+enum RT_VERSION      = MAKEINTRESOURCE_T!(16);
+enum RT_DLGINCLUDE   = MAKEINTRESOURCE_T!(17);
+enum RT_PLUGPLAY     = MAKEINTRESOURCE_T!(19);
+enum RT_VXD          = MAKEINTRESOURCE_T!(20);
+enum RT_ANICURSOR    = MAKEINTRESOURCE_T!(21);
+enum RT_ANIICON      = MAKEINTRESOURCE_T!(22);
+enum RT_HTML         = MAKEINTRESOURCE_T!(23);
+enum RT_MANIFEST     = MAKEINTRESOURCE_T!(24);
+
+enum CREATEPROCESS_MANIFEST_RESOURCE_ID                 = MAKEINTRESOURCE_T!(1);
+enum ISOLATIONAWARE_MANIFEST_RESOURCE_ID                = MAKEINTRESOURCE_T!(2);
+enum ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID = MAKEINTRESOURCE_T!(3);
+
+enum {
+    EWX_LOGOFF      =  0,
+    EWX_SHUTDOWN    =  1,
+    EWX_REBOOT      =  2,
+    EWX_FORCE       =  4,
+    EWX_POWEROFF    =  8,
+    EWX_FORCEIFHUNG = 16
+}
+
+enum CS_BYTEALIGNCLIENT = 4096;
+enum CS_BYTEALIGNWINDOW = 8192;
+enum CS_KEYCVTWINDOW = 4;
+enum CS_NOKEYCVT = 256;
+enum CS_CLASSDC = 64;
+enum CS_DBLCLKS = 8;
+enum CS_GLOBALCLASS = 16384;
+enum CS_HREDRAW = 2;
+enum CS_NOCLOSE = 512;
+enum CS_OWNDC = 32;
+enum CS_PARENTDC = 128;
+enum CS_SAVEBITS = 2048;
+enum CS_VREDRAW = 1;
+enum CS_IME = 0x10000;
+
+enum GCW_ATOM = -32;
+enum GCL_CBCLSEXTRA = -20;
+enum GCL_CBWNDEXTRA = -18;
+enum GCL_HBRBACKGROUND = -10;
+enum GCL_HCURSOR = -12;
+enum GCL_HICON = -14;
+enum GCL_HICONSM = -34;
+enum GCL_HMODULE = -16;
+enum GCL_MENUNAME = -8;
+enum GCL_STYLE = -26;
+enum GCL_WNDPROC = -24;
+
+alias GCL_HICONSM GCLP_HICONSM;
+alias GCL_HICON GCLP_HICON;
+alias GCL_HCURSOR GCLP_HCURSOR;
+alias GCL_HBRBACKGROUND GCLP_HBRBACKGROUND;
+alias GCL_HMODULE  GCLP_HMODULE;
+alias GCL_MENUNAME GCLP_MENUNAME;
+alias GCL_WNDPROC  GCLP_WNDPROC;
+
+enum {
+    IDC_ARROW       = MAKEINTRESOURCE_T!(32512),
+    IDC_IBEAM       = MAKEINTRESOURCE_T!(32513),
+    IDC_WAIT        = MAKEINTRESOURCE_T!(32514),
+    IDC_CROSS       = MAKEINTRESOURCE_T!(32515),
+    IDC_UPARROW     = MAKEINTRESOURCE_T!(32516),
+    IDC_SIZE        = MAKEINTRESOURCE_T!(32640),
+    IDC_ICON        = MAKEINTRESOURCE_T!(32641),
+    IDC_SIZENWSE    = MAKEINTRESOURCE_T!(32642),
+    IDC_SIZENESW    = MAKEINTRESOURCE_T!(32643),
+    IDC_SIZEWE      = MAKEINTRESOURCE_T!(32644),
+    IDC_SIZENS      = MAKEINTRESOURCE_T!(32645),
+    IDC_SIZEALL     = MAKEINTRESOURCE_T!(32646),
+    IDC_NO          = MAKEINTRESOURCE_T!(32648),
+    IDC_HAND        = MAKEINTRESOURCE_T!(32649),
+    IDC_APPSTARTING = MAKEINTRESOURCE_T!(32650),
+    IDC_HELP        = MAKEINTRESOURCE_T!(32651),
+    IDI_APPLICATION = MAKEINTRESOURCE_T!(32512),
+    IDI_HAND        = MAKEINTRESOURCE_T!(32513),
+    IDI_QUESTION    = MAKEINTRESOURCE_T!(32514),
+    IDI_EXCLAMATION = MAKEINTRESOURCE_T!(32515),
+    IDI_ASTERISK    = MAKEINTRESOURCE_T!(32516),
+    IDI_WINLOGO     = MAKEINTRESOURCE_T!(32517),
+    IDI_WARNING     = IDI_EXCLAMATION,
+    IDI_ERROR       = IDI_HAND,
+    IDI_INFORMATION = IDI_ASTERISK
+}
+static if (_WIN32_WINNT >= 0x600) {
+    enum IDI_SHIELD = MAKEINTRESOURCE_T!(32518);
+}
+
+enum {
+    MIIM_STATE      = 0x0001,
+    MIIM_ID         = 0x0002,
+    MIIM_SUBMENU    = 0x0004,
+    MIIM_CHECKMARKS = 0x0008,
+    MIIM_TYPE       = 0x0010,
+    MIIM_DATA       = 0x0020,
+    MIIM_STRING     = 0x0040,
+    MIIM_BITMAP     = 0x0080,
+    MIIM_FTYPE      = 0x0100
+}
+
+enum {
+    MFT_BITMAP       = 0x0004,
+    MFT_MENUBARBREAK = 0x0020,
+    MFT_MENUBREAK    = 0x0040,
+    MFT_OWNERDRAW    = 0x0100,
+    MFT_RADIOCHECK   = 0x0200,
+    MFT_RIGHTJUSTIFY = 0x4000,
+    MFT_SEPARATOR    = 0x0800,
+    MFT_RIGHTORDER   = 0x2000,
+    MFT_STRING       = 0
+}
+
+enum {
+    MFS_CHECKED   = 8,
+    MFS_DEFAULT   = 4096,
+    MFS_DISABLED  = 3,
+    MFS_ENABLED   = 0,
+    MFS_GRAYED    = 3,
+    MFS_HILITE    = 128,
+    MFS_UNCHECKED = 0,
+    MFS_UNHILITE  = 0
+}
+
+enum {
+    GW_HWNDFIRST = 0,
+    GW_HWNDLAST,
+    GW_HWNDNEXT,
+    GW_HWNDPREV,
+    GW_OWNER,
+    GW_CHILD  // = 5
+}
+
+enum {
+    SW_HIDE            =  0,
+    SW_NORMAL          =  1,
+    SW_SHOWNORMAL      =  1,
+    SW_SHOWMINIMIZED   =  2,
+    SW_MAXIMIZE        =  3,
+    SW_SHOWMAXIMIZED   =  3,
+    SW_SHOWNOACTIVATE  =  4,
+    SW_SHOW            =  5,
+    SW_MINIMIZE        =  6,
+    SW_SHOWMINNOACTIVE =  7,
+    SW_SHOWNA          =  8,
+    SW_RESTORE         =  9,
+    SW_SHOWDEFAULT     = 10,
+    SW_FORCEMINIMIZE   = 11,
+    SW_MAX             = 11
+}
+
+enum {
+    SW_PARENTCLOSING  = 1,
+    SW_OTHERZOOM,
+    SW_PARENTOPENING,
+    SW_OTHERUNZOOM // = 4
+}
+
+enum { // is this a different SW from the previous?
+    SW_SCROLLCHILDREN = 0x01,
+    SW_INVALIDATE     = 0x02,
+    SW_ERASE          = 0x04,
+    SW_SMOOTHSCROLL   = 0x10
+}
+
+enum {
+    MB_OK                        = 0,
+    MB_OKCANCEL,
+    MB_ABORTRETRYIGNORE,
+    MB_YESNOCANCEL,
+    MB_YESNO,
+    MB_RETRYCANCEL,
+    MB_CANCELTRYCONTINUE,     // = 6
+    MB_TYPEMASK                  = 0x0000000F,
+    MB_ICONHAND                  = 0x00000010,
+    MB_ICONSTOP                  = MB_ICONHAND,
+    MB_ICONERROR                 = MB_ICONHAND,
+    MB_ICONQUESTION              = 0x00000020,
+    MB_ICONEXCLAMATION           = 0x00000030,
+    MB_ICONWARNING               = MB_ICONEXCLAMATION,
+    MB_ICONASTERISK              = 0x00000040,
+    MB_ICONINFORMATION           = MB_ICONASTERISK,
+    MB_USERICON                  = 0x00000080,
+    MB_ICONMASK                  = 0x000000F0,
+
+    MB_DEFBUTTON1                = 0,
+    MB_DEFBUTTON2                = 0x00000100,
+    MB_DEFBUTTON3                = 0x00000200,
+    MB_DEFBUTTON4                = 0x00000300,
+    MB_DEFMASK                   = 0x00000F00,
+
+    MB_APPLMODAL                 = 0,
+    MB_SYSTEMMODAL               = 0x00001000,
+    MB_TASKMODAL                 = 0x00002000,
+    MB_MODEMASK                  = 0x00003000,
+
+    MB_HELP                      = 0x00004000,
+    MB_NOFOCUS                   = 0x00008000,
+    MB_MISCMASK                  = 0x0000C000,
+
+    MB_SETFOREGROUND             = 0x00010000,
+    MB_DEFAULT_DESKTOP_ONLY      = 0x00020000,
+    MB_TOPMOST                   = 0x00040000,
+    MB_SERVICE_NOTIFICATION_NT3X = 0x00040000,
+    MB_RIGHT                     = 0x00080000,
+    MB_RTLREADING                = 0x00100000,
+    MB_SERVICE_NOTIFICATION      = 0x00200000
+}
+
+enum {
+    IDOK          = 1,
+    IDCANCEL,
+    IDABORT,
+    IDRETRY,
+    IDIGNORE,
+    IDYES,
+    IDNO,
+    IDCLOSE,
+    IDHELP,
+    IDTRYAGAIN,
+    IDCONTINUE // = 11
+}
+
+enum GWL_EXSTYLE = -20;
+enum GWL_STYLE = -16;
+enum GWL_WNDPROC = -4;
+enum GWLP_WNDPROC = -4;
+enum GWL_HINSTANCE = -6;
+enum GWLP_HINSTANCE = -6;
+enum GWL_HWNDPARENT = -8;
+enum GWLP_HWNDPARENT = -8;
+enum GWL_ID = -12;
+enum GWLP_ID = -12;
+enum GWL_USERDATA = -21;
+enum GWLP_USERDATA = -21;
+
+enum DWL_DLGPROC = 4;
+enum DWLP_DLGPROC = 4;
+enum DWL_MSGRESULT = 0;
+enum DWLP_MSGRESULT = 0;
+enum DWL_USER = 8;
+enum DWLP_USER = 8;
+
+enum QS_KEY            = 1;
+enum QS_MOUSEMOVE      = 2;
+enum QS_MOUSEBUTTON    = 4;
+enum QS_MOUSE          = 6;
+enum QS_POSTMESSAGE    = 8;
+enum QS_TIMER          = 16;
+enum QS_PAINT          = 32;
+enum QS_SENDMESSAGE    = 64;
+enum QS_HOTKEY         = 128;
+enum QS_ALLPOSTMESSAGE = 256;
+static if (_WIN32_WINNT >= 0x501) {
+enum QS_RAWINPUT       = 1024;
+enum QS_INPUT          = 1031;
+enum QS_ALLEVENTS      = 1215;
+enum QS_ALLINPUT       = 1279;
+} else {
+enum QS_INPUT          = 7;
+enum QS_ALLEVENTS      = 191;
+enum QS_ALLINPUT       = 255;
+}
+
+enum MWMO_WAITALL        = 1;
+enum MWMO_ALERTABLE      = 2;
+enum MWMO_INPUTAVAILABLE = 4;
+
+enum COLOR_3DDKSHADOW = 21;
+enum COLOR_3DFACE = 15;
+enum COLOR_3DHILIGHT = 20;
+enum COLOR_3DHIGHLIGHT = 20;
+enum COLOR_3DLIGHT = 22;
+enum COLOR_BTNHILIGHT = 20;
+enum COLOR_3DSHADOW = 16;
+enum COLOR_ACTIVEBORDER = 10;
+enum COLOR_ACTIVECAPTION = 2;
+enum COLOR_APPWORKSPACE = 12;
+enum COLOR_BACKGROUND = 1;
+enum COLOR_DESKTOP = 1;
+enum COLOR_BTNFACE = 15;
+enum COLOR_BTNHIGHLIGHT = 20;
+enum COLOR_BTNSHADOW = 16;
+enum COLOR_BTNTEXT = 18;
+enum COLOR_CAPTIONTEXT = 9;
+enum COLOR_GRAYTEXT = 17;
+enum COLOR_HIGHLIGHT = 13;
+enum COLOR_HIGHLIGHTTEXT = 14;
+enum COLOR_INACTIVEBORDER = 11;
+enum COLOR_INACTIVECAPTION = 3;
+enum COLOR_INACTIVECAPTIONTEXT = 19;
+enum COLOR_INFOBK = 24;
+enum COLOR_INFOTEXT = 23;
+enum COLOR_MENU = 4;
+enum COLOR_MENUTEXT = 7;
+enum COLOR_SCROLLBAR = 0;
+enum COLOR_WINDOW = 5;
+enum COLOR_WINDOWFRAME = 6;
+enum COLOR_WINDOWTEXT = 8;
+enum COLOR_HOTLIGHT = 26;
+enum COLOR_GRADIENTACTIVECAPTION = 27;
+enum COLOR_GRADIENTINACTIVECAPTION = 28;
+
+enum CTLCOLOR_MSGBOX = 0;
+enum CTLCOLOR_EDIT = 1;
+enum CTLCOLOR_LISTBOX = 2;
+enum CTLCOLOR_BTN = 3;
+enum CTLCOLOR_DLG = 4;
+enum CTLCOLOR_SCROLLBAR = 5;
+enum CTLCOLOR_STATIC = 6;
+enum CTLCOLOR_MAX = 7;
+
+// For GetSystemMetrics()
+enum : int {
+    SM_CXSCREEN = 0,
+    SM_CYSCREEN,
+    SM_CXVSCROLL,
+    SM_CYHSCROLL,
+    SM_CYCAPTION,
+    SM_CXBORDER,
+    SM_CYBORDER,
+    SM_CXDLGFRAME,    // = 7
+    SM_CXFIXEDFRAME      = SM_CXDLGFRAME,
+    SM_CYDLGFRAME,    // = 8
+    SM_CYFIXEDFRAME      = SM_CYDLGFRAME,
+    SM_CYVTHUMB,      // = 9
+    SM_CXHTHUMB,
+    SM_CXICON,
+    SM_CYICON,
+    SM_CXCURSOR,
+    SM_CYCURSOR,
+    SM_CYMENU,
+    SM_CXFULLSCREEN,
+    SM_CYFULLSCREEN,
+    SM_CYKANJIWINDOW,
+    SM_MOUSEPRESENT,
+    SM_CYVSCROLL,
+    SM_CXHSCROLL,
+    SM_DEBUG,
+    SM_SWAPBUTTON,
+    SM_RESERVED1,
+    SM_RESERVED2,
+    SM_RESERVED3,
+    SM_RESERVED4,
+    SM_CXMIN,
+    SM_CYMIN,
+    SM_CXSIZE,
+    SM_CYSIZE,
+    SM_CXSIZEFRAME,   // = 32,
+    SM_CXFRAME           = SM_CXSIZEFRAME,
+    SM_CYSIZEFRAME,   // = 33
+    SM_CYFRAME           = SM_CYSIZEFRAME,
+    SM_CXMINTRACK,
+    SM_CYMINTRACK,
+    SM_CXDOUBLECLK,
+    SM_CYDOUBLECLK,
+    SM_CXICONSPACING,
+    SM_CYICONSPACING,
+    SM_MENUDROPALIGNMENT,
+    SM_PENWINDOWS,
+    SM_DBCSENABLED,
+    SM_CMOUSEBUTTONS,
+    SM_SECURE,
+    SM_CXEDGE,
+    SM_CYEDGE,
+    SM_CXMINSPACING,
+    SM_CYMINSPACING,
+    SM_CXSMICON,
+    SM_CYSMICON,
+    SM_CYSMCAPTION,
+    SM_CXSMSIZE,
+    SM_CYSMSIZE,
+    SM_CXMENUSIZE,
+    SM_CYMENUSIZE,
+    SM_ARRANGE,
+    SM_CXMINIMIZED,
+    SM_CYMINIMIZED,
+    SM_CXMAXTRACK,
+    SM_CYMAXTRACK,
+    SM_CXMAXIMIZED,
+    SM_CYMAXIMIZED,
+    SM_NETWORK,       // = 63
+    SM_CLEANBOOT         = 67,
+    SM_CXDRAG,
+    SM_CYDRAG,
+    SM_SHOWSOUNDS,
+    SM_CXMENUCHECK,
+    SM_CYMENUCHECK,
+    SM_SLOWMACHINE,
+    SM_MIDEASTENABLED,
+    SM_MOUSEWHEELPRESENT,
+    SM_XVIRTUALSCREEN,
+    SM_YVIRTUALSCREEN,
+    SM_CXVIRTUALSCREEN,
+    SM_CYVIRTUALSCREEN,
+    SM_CMONITORS,
+    SM_SAMEDISPLAYFORMAT,
+    SM_IMMENABLED,
+    SM_CXFOCUSBORDER,
+    SM_CYFOCUSBORDER, // = 84
+    SM_TABLETPC          = 86,
+    SM_MEDIACENTER,
+    SM_STARTER,       // = 88
+    SM_CMETRICS          = 88,
+    SM_SERVERR2,
+    SM_REMOTESESSION     = 0x1000,
+}
+static if (_WIN32_WINNT >= 0x501) {
+    enum {  // These are only for WinXP and later
+        SM_SHUTTINGDOWN  = 0x2000,
+        SM_REMOTECONTROL = 0x2001
+    }
+}
+
+enum ARW_BOTTOMLEFT = 0;
+enum ARW_BOTTOMRIGHT = 1;
+enum ARW_HIDE = 8;
+enum ARW_TOPLEFT = 2;
+enum ARW_TOPRIGHT = 3;
+enum ARW_DOWN = 4;
+enum ARW_LEFT = 0;
+enum ARW_RIGHT = 0;
+enum ARW_UP = 4;
+
+enum UOI_FLAGS = 1;
+enum UOI_NAME = 2;
+enum UOI_TYPE = 3;
+enum UOI_USER_SID = 4;
+
+// For the fuLoad parameter of LoadImage()
+enum : UINT {
+    LR_DEFAULTCOLOR     = 0,
+    LR_MONOCHROME       = 0x0001,
+    LR_COLOR            = 0x0002,
+    LR_COPYRETURNORG    = 0x0004,
+    LR_COPYDELETEORG    = 0x0008,
+    LR_LOADFROMFILE     = 0x0010,
+    LR_LOADTRANSPARENT  = 0x0020,
+    LR_DEFAULTSIZE      = 0x0040,
+    LR_VGACOLOR         = 0x0080,
+    LR_LOADREALSIZE     = 0x0080,
+    LR_LOADMAP3DCOLORS  = 0x1000,
+    LR_CREATEDIBSECTION = 0x2000,
+    LR_COPYFROMRESOURCE = 0x4000,
+    LR_SHARED           = 0x8000
+}
+
+enum {
+    KEYEVENTF_EXTENDEDKEY = 1,
+    KEYEVENTF_KEYUP       = 2,
+    KEYEVENTF_UNICODE     = 4,
+    KEYEVENTF_SCANCODE    = 8
+}
+
+enum OBM_BTNCORNERS = 32758;
+enum OBM_BTSIZE = 32761;
+enum OBM_CHECK = 32760;
+enum OBM_CHECKBOXES = 32759;
+enum OBM_CLOSE = 32754;
+enum OBM_COMBO = 32738;
+enum OBM_DNARROW = 32752;
+enum OBM_DNARROWD = 32742;
+enum OBM_DNARROWI = 32736;
+enum OBM_LFARROW = 32750;
+enum OBM_LFARROWI = 32734;
+enum OBM_LFARROWD = 32740;
+enum OBM_MNARROW = 32739;
+enum OBM_OLD_CLOSE = 32767;
+enum OBM_OLD_DNARROW = 32764;
+enum OBM_OLD_LFARROW = 32762;
+enum OBM_OLD_REDUCE = 32757;
+enum OBM_OLD_RESTORE = 32755;
+enum OBM_OLD_RGARROW = 32763;
+enum OBM_OLD_UPARROW = 32765;
+enum OBM_OLD_ZOOM = 32756;
+enum OBM_REDUCE = 32749;
+enum OBM_REDUCED = 32746;
+enum OBM_RESTORE = 32747;
+enum OBM_RESTORED = 32744;
+enum OBM_RGARROW = 32751;
+enum OBM_RGARROWD = 32741;
+enum OBM_RGARROWI = 32735;
+enum OBM_SIZE = 32766;
+enum OBM_UPARROW = 32753;
+enum OBM_UPARROWD = 32743;
+enum OBM_UPARROWI = 32737;
+enum OBM_ZOOM = 32748;
+enum OBM_ZOOMD = 32745;
+
+enum OCR_NORMAL = 32512;
+enum OCR_IBEAM = 32513;
+enum OCR_WAIT = 32514;
+enum OCR_CROSS = 32515;
+enum OCR_UP = 32516;
+enum OCR_SIZE = 32640;
+enum OCR_ICON = 32641;
+enum OCR_SIZENWSE = 32642;
+enum OCR_SIZENESW = 32643;
+enum OCR_SIZEWE = 32644;
+enum OCR_SIZENS = 32645;
+enum OCR_SIZEALL = 32646;
+enum OCR_NO = 32648;
+enum OCR_APPSTARTING = 32650;
+
+enum OIC_SAMPLE = 32512;
+enum OIC_HAND = 32513;
+enum OIC_QUES = 32514;
+enum OIC_BANG = 32515;
+enum OIC_NOTE = 32516;
+enum OIC_WINLOGO = 32517;
+enum OIC_WARNING = OIC_BANG;
+enum OIC_ERROR = OIC_HAND;
+enum OIC_INFORMATION = OIC_NOTE;
+
+enum HELPINFO_MENUITEM = 2;
+enum HELPINFO_WINDOW = 1;
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        WTS_CONSOLE_CONNECT = 1,
+        WTS_CONSOLE_DISCONNECT,
+        WTS_REMOTE_CONNECT,
+        WTS_REMOTE_DISCONNECT,
+        WTS_SESSION_LOGON,
+        WTS_SESSION_LOGOFF,
+        WTS_SESSION_LOCK,
+        WTS_SESSION_UNLOCK,
+        WTS_SESSION_REMOTE_CONTROL // = 9
+    }
+}
+
+enum MSGF_DIALOGBOX = 0;
+enum MSGF_MESSAGEBOX = 1;
+enum MSGF_MENU = 2;
+enum MSGF_MOVE = 3;
+enum MSGF_SIZE = 4;
+enum MSGF_SCROLLBAR = 5;
+enum MSGF_NEXTWINDOW = 6;
+enum MSGF_MAINLOOP = 8;
+enum MSGF_USER = 4096;
+
+enum {
+    MOUSEEVENTF_MOVE       = 0x0001,
+    MOUSEEVENTF_LEFTDOWN   = 0x0002,
+    MOUSEEVENTF_LEFTUP     = 0x0004,
+    MOUSEEVENTF_RIGHTDOWN  = 0x0008,
+    MOUSEEVENTF_RIGHTUP    = 0x0010,
+    MOUSEEVENTF_MIDDLEDOWN = 0x0020,
+    MOUSEEVENTF_MIDDLEUP   = 0x0040,
+    MOUSEEVENTF_XDOWN      = 0x0080,
+    MOUSEEVENTF_XUP        = 0x0100,
+    MOUSEEVENTF_WHEEL      = 0x0800,
+    MOUSEEVENTF_ABSOLUTE   = 0x8000
+}
+
+enum PM_NOREMOVE = 0;
+enum PM_REMOVE = 1;
+enum PM_NOYIELD = 2;
+
+enum : HWND {
+    HWND_BROADCAST = cast(HWND) 0xFFFF,
+    HWND_MESSAGE   = cast(HWND)     -3,
+    HWND_NOTOPMOST = cast(HWND)     -2,
+    HWND_TOPMOST   = cast(HWND)     -1,
+    HWND_TOP       = cast(HWND)      0,
+    HWND_DESKTOP   = cast(HWND)      0,
+    HWND_BOTTOM    = cast(HWND)      1
+}
+
+enum RDW_INVALIDATE      = 1;
+enum RDW_INTERNALPAINT   = 2;
+enum RDW_ERASE           = 4;
+enum RDW_VALIDATE        = 8;
+enum RDW_NOINTERNALPAINT = 16;
+enum RDW_NOERASE         = 32;
+enum RDW_NOCHILDREN      = 64;
+enum RDW_ALLCHILDREN     = 128;
+enum RDW_UPDATENOW       = 256;
+enum RDW_ERASENOW        = 512;
+enum RDW_FRAME           = 1024;
+enum RDW_NOFRAME         = 2048;
+
+enum {
+    SMTO_NORMAL             = 0,
+    SMTO_BLOCK              = 1,
+    SMTO_ABORTIFHUNG        = 2,
+    SMTO_NOTIMEOUTIFNOTHUNG = 8
+}
+
+enum SIF_ALL = 23;
+enum SIF_PAGE = 2;
+enum SIF_POS = 4;
+enum SIF_RANGE = 1;
+enum SIF_DISABLENOSCROLL = 8;
+enum SIF_TRACKPOS = 16;
+
+enum SWP_DRAWFRAME = 32;
+enum SWP_FRAMECHANGED = 32;
+enum SWP_HIDEWINDOW = 128;
+enum SWP_NOACTIVATE = 16;
+enum SWP_NOCOPYBITS = 256;
+enum SWP_NOMOVE = 2;
+enum SWP_NOSIZE = 1;
+enum SWP_NOREDRAW = 8;
+enum SWP_NOZORDER = 4;
+enum SWP_SHOWWINDOW = 64;
+enum SWP_NOOWNERZORDER = 512;
+enum SWP_NOREPOSITION = 512;
+enum SWP_NOSENDCHANGING = 1024;
+enum SWP_DEFERERASE = 8192;
+enum SWP_ASYNCWINDOWPOS = 16384;
+
+enum { // passed variously as int or WPARAM
+    HSHELL_WINDOWCREATED    =     1,
+    HSHELL_WINDOWDESTROYED,
+    HSHELL_ACTIVATESHELLWINDOW,
+    HSHELL_WINDOWACTIVATED,
+    HSHELL_GETMINRECT,
+    HSHELL_REDRAW,
+    HSHELL_TASKMAN,
+    HSHELL_LANGUAGE,     // =     8
+    HSHELL_ENDTASK          =    10,
+    HSHELL_ACCESSIBILITYSTATE,
+    HSHELL_APPCOMMAND,   // =    12
+    HSHELL_RUDEAPPACTIVATED = 32772,
+    HSHELL_FLASH            = 32774
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum {
+        HSHELL_WINDOWREPLACED = 13,
+        HSHELL_WINDOWREPLACING
+    }
+}
+
+enum {
+    SPI_GETBEEP                   = 0x0001,
+    SPI_SETBEEP                   = 0x0002,
+    SPI_GETMOUSE                  = 0x0003,
+    SPI_SETMOUSE                  = 0x0004,
+    SPI_GETBORDER                 = 0x0005,
+    SPI_SETBORDER                 = 0x0006,
+    SPI_GETKEYBOARDSPEED          = 0x000A,
+    SPI_SETKEYBOARDSPEED          = 0x000B,
+    SPI_LANGDRIVER                = 0x000C,
+    SPI_ICONHORIZONTALSPACING     = 0x000D,
+    SPI_GETSCREENSAVETIMEOUT      = 0x000E,
+    SPI_SETSCREENSAVETIMEOUT      = 0x000F,
+    SPI_GETSCREENSAVEACTIVE       = 0x0010,
+    SPI_SETSCREENSAVEACTIVE       = 0x0011,
+    SPI_GETGRIDGRANULARITY        = 0x0012,
+    SPI_SETGRIDGRANULARITY        = 0x0013,
+    SPI_SETDESKWALLPAPER          = 0x0014,
+    SPI_SETDESKPATTERN            = 0x0015,
+    SPI_GETKEYBOARDDELAY          = 0x0016,
+    SPI_SETKEYBOARDDELAY          = 0x0017,
+    SPI_ICONVERTICALSPACING       = 0x0018,
+    SPI_GETICONTITLEWRAP          = 0x0019,
+    SPI_SETICONTITLEWRAP          = 0x001A,
+    SPI_GETMENUDROPALIGNMENT      = 0x001B,
+    SPI_SETMENUDROPALIGNMENT      = 0x001C,
+    SPI_SETDOUBLECLKWIDTH         = 0x001D,
+    SPI_SETDOUBLECLKHEIGHT        = 0x001E,
+    SPI_GETICONTITLELOGFONT       = 0x001F,
+    SPI_SETDOUBLECLICKTIME        = 0x0020,
+    SPI_SETMOUSEBUTTONSWAP        = 0x0021,
+    SPI_SETICONTITLELOGFONT       = 0x0022,
+    SPI_GETFASTTASKSWITCH         = 0x0023,
+    SPI_SETFASTTASKSWITCH         = 0x0024,
+    SPI_SETDRAGFULLWINDOWS        = 0x0025,
+    SPI_GETDRAGFULLWINDOWS        = 0x0026,
+    SPI_GETNONCLIENTMETRICS       = 0x0029,
+    SPI_SETNONCLIENTMETRICS       = 0x002A,
+    SPI_GETMINIMIZEDMETRICS       = 0x002B,
+    SPI_SETMINIMIZEDMETRICS       = 0x002C,
+    SPI_GETICONMETRICS            = 0x002D,
+    SPI_SETICONMETRICS            = 0x002E,
+    SPI_SETWORKAREA               = 0x002F,
+    SPI_GETWORKAREA               = 0x0030,
+    SPI_SETPENWINDOWS             = 0x0031,
+    SPI_GETFILTERKEYS             = 0x0032,
+    SPI_SETFILTERKEYS             = 0x0033,
+    SPI_GETTOGGLEKEYS             = 0x0034,
+    SPI_SETTOGGLEKEYS             = 0x0035,
+    SPI_GETMOUSEKEYS              = 0x0036,
+    SPI_SETMOUSEKEYS              = 0x0037,
+    SPI_GETSHOWSOUNDS             = 0x0038,
+    SPI_SETSHOWSOUNDS             = 0x0039,
+    SPI_GETSTICKYKEYS             = 0x003A,
+    SPI_SETSTICKYKEYS             = 0x003B,
+    SPI_GETACCESSTIMEOUT          = 0x003C,
+    SPI_SETACCESSTIMEOUT          = 0x003D,
+    SPI_GETSERIALKEYS             = 0x003E,
+    SPI_SETSERIALKEYS             = 0x003F,
+    SPI_GETSOUNDSENTRY            = 0x0040,
+    SPI_SETSOUNDSENTRY            = 0x0041,
+    SPI_GETHIGHCONTRAST           = 0x0042,
+    SPI_SETHIGHCONTRAST           = 0x0043,
+    SPI_GETKEYBOARDPREF           = 0x0044,
+    SPI_SETKEYBOARDPREF           = 0x0045,
+    SPI_GETSCREENREADER           = 0x0046,
+    SPI_SETSCREENREADER           = 0x0047,
+    SPI_GETANIMATION              = 0x0048,
+    SPI_SETANIMATION              = 0x0049,
+    SPI_GETFONTSMOOTHING          = 0x004A,
+    SPI_SETFONTSMOOTHING          = 0x004B,
+    SPI_SETDRAGWIDTH              = 0x004C,
+    SPI_SETDRAGHEIGHT             = 0x004D,
+    SPI_SETHANDHELD               = 0x004E,
+    SPI_GETLOWPOWERTIMEOUT        = 0x004F,
+    SPI_GETPOWEROFFTIMEOUT        = 0x0050,
+    SPI_SETLOWPOWERTIMEOUT        = 0x0051,
+    SPI_SETPOWEROFFTIMEOUT        = 0x0052,
+    SPI_GETLOWPOWERACTIVE         = 0x0053,
+    SPI_GETPOWEROFFACTIVE         = 0x0054,
+    SPI_SETLOWPOWERACTIVE         = 0x0055,
+    SPI_SETPOWEROFFACTIVE         = 0x0056,
+    SPI_SETCURSORS                = 0x0057,
+    SPI_SETICONS                  = 0x0058,
+    SPI_GETDEFAULTINPUTLANG       = 0x0059,
+    SPI_SETDEFAULTINPUTLANG       = 0x005A,
+    SPI_SETLANGTOGGLE             = 0x005B,
+    SPI_GETWINDOWSEXTENSION       = 0x005C,
+    SPI_SETMOUSETRAILS            = 0x005D,
+    SPI_GETMOUSETRAILS            = 0x005E,
+    SPI_GETSNAPTODEFBUTTON        = 0x005F,
+    SPI_SETSNAPTODEFBUTTON        = 0x0060,
+    //SPI_SCREENSAVERRUNNING        = 0x0061, // mistake in older MinGW?
+    SPI_SETSCREENSAVERRUNNING     = 0x0061,
+    SPI_GETMOUSEHOVERWIDTH        = 0x0062,
+    SPI_SETMOUSEHOVERWIDTH        = 0x0063,
+    SPI_GETMOUSEHOVERHEIGHT       = 0x0064,
+    SPI_SETMOUSEHOVERHEIGHT       = 0x0065,
+    SPI_GETMOUSEHOVERTIME         = 0x0066,
+    SPI_SETMOUSEHOVERTIME         = 0x0067,
+    SPI_GETWHEELSCROLLLINES       = 0x0068,
+    SPI_SETWHEELSCROLLLINES       = 0x0069,
+    SPI_GETMENUSHOWDELAY          = 0x006A,
+    SPI_SETMENUSHOWDELAY          = 0x006B,
+    SPI_GETSHOWIMEUI              = 0x006E,
+    SPI_SETSHOWIMEUI              = 0x006F,
+    SPI_GETMOUSESPEED             = 0x0070,
+    SPI_SETMOUSESPEED             = 0x0071,
+    SPI_GETSCREENSAVERRUNNING     = 0x0072,
+    SPI_GETDESKWALLPAPER          = 0x0073,
+    SPI_GETACTIVEWINDOWTRACKING   = 0x1000,
+    SPI_SETACTIVEWINDOWTRACKING   = 0x1001,
+    SPI_GETMENUANIMATION          = 0x1002,
+    SPI_SETMENUANIMATION          = 0x1003,
+    SPI_GETCOMBOBOXANIMATION      = 0x1004,
+    SPI_SETCOMBOBOXANIMATION      = 0x1005,
+    SPI_GETLISTBOXSMOOTHSCROLLING = 0x1006,
+    SPI_SETLISTBOXSMOOTHSCROLLING = 0x1007,
+    SPI_GETGRADIENTCAPTIONS       = 0x1008,
+    SPI_SETGRADIENTCAPTIONS       = 0x1009,
+    SPI_GETKEYBOARDCUES           = 0x100A,
+    SPI_GETMENUUNDERLINES         = SPI_GETKEYBOARDCUES,
+    SPI_SETKEYBOARDCUES           = 0x100B,
+    SPI_SETMENUUNDERLINES         = SPI_SETKEYBOARDCUES,
+    SPI_GETACTIVEWNDTRKZORDER     = 0x100C,
+    SPI_SETACTIVEWNDTRKZORDER     = 0x100D,
+    SPI_GETHOTTRACKING            = 0x100E,
+    SPI_SETHOTTRACKING            = 0x100F,
+    SPI_GETMENUFADE               = 0x1012,
+    SPI_SETMENUFADE               = 0x1013,
+    SPI_GETSELECTIONFADE          = 0x1014,
+    SPI_SETSELECTIONFADE          = 0x1015,
+    SPI_GETTOOLTIPANIMATION       = 0x1016,
+    SPI_SETTOOLTIPANIMATION       = 0x1017,
+    SPI_GETTOOLTIPFADE            = 0x1018,
+    SPI_SETTOOLTIPFADE            = 0x1019,
+    SPI_GETCURSORSHADOW           = 0x101A,
+    SPI_SETCURSORSHADOW           = 0x101B,
+    SPI_GETBLOCKSENDINPUTRESETS   = 0x1026,
+    SPI_SETBLOCKSENDINPUTRESETS   = 0x1027,
+    SPI_GETUIEFFECTS              = 0x103E,
+    SPI_SETUIEFFECTS              = 0x103F,
+    SPI_GETFOREGROUNDLOCKTIMEOUT  = 0x2000,
+    SPI_SETFOREGROUNDLOCKTIMEOUT  = 0x2001,
+    SPI_GETACTIVEWNDTRKTIMEOUT    = 0x2002,
+    SPI_SETACTIVEWNDTRKTIMEOUT    = 0x2003,
+    SPI_GETFOREGROUNDFLASHCOUNT   = 0x2004,
+    SPI_SETFOREGROUNDFLASHCOUNT   = 0x2005,
+    SPI_GETCARETWIDTH             = 0x2006,
+    SPI_SETCARETWIDTH             = 0x2007
+}
+
+enum {
+    SPIF_UPDATEINIFILE    = 1,
+    SPIF_SENDWININICHANGE = 2,
+    SPIF_SENDCHANGE       = SPIF_SENDWININICHANGE
+}
+
+// [Redefined] ATF_ONOFFFEEDBACK = 2
+// [Redefined] ATF_TIMEOUTON = 1
+enum WM_APP = 32768;
+enum WM_ACTIVATE = 6;
+enum WM_ACTIVATEAPP = 28;
+enum WM_AFXFIRST = 864;
+enum WM_AFXLAST = 895;
+enum WM_ASKCBFORMATNAME = 780;
+enum WM_CANCELJOURNAL = 75;
+enum WM_CANCELMODE = 31;
+enum WM_CAPTURECHANGED = 533;
+enum WM_CHANGECBCHAIN = 781;
+enum WM_CHAR = 258;
+enum WM_CHARTOITEM = 47;
+enum WM_CHILDACTIVATE = 34;
+enum WM_CLEAR = 771;
+enum WM_CLOSE = 16;
+enum WM_COMMAND = 273;
+enum WM_COMMNOTIFY = 68; // obsolete
+enum WM_COMPACTING = 65;
+enum WM_COMPAREITEM = 57;
+enum WM_CONTEXTMENU = 123;
+enum WM_COPY = 769;
+enum WM_COPYDATA = 74;
+enum WM_CREATE = 1;
+enum WM_CTLCOLORBTN = 309;
+enum WM_CTLCOLORDLG = 310;
+enum WM_CTLCOLOREDIT = 307;
+enum WM_CTLCOLORLISTBOX = 308;
+enum WM_CTLCOLORMSGBOX = 306;
+enum WM_CTLCOLORSCROLLBAR = 311;
+enum WM_CTLCOLORSTATIC = 312;
+enum WM_CUT = 768;
+enum WM_DEADCHAR = 259;
+enum WM_DELETEITEM = 45;
+enum WM_DESTROY = 2;
+enum WM_DESTROYCLIPBOARD = 775;
+enum WM_DEVICECHANGE = 537;
+enum WM_DEVMODECHANGE = 27;
+enum WM_DISPLAYCHANGE = 126;
+enum WM_DRAWCLIPBOARD = 776;
+enum WM_DRAWITEM = 43;
+enum WM_DROPFILES = 563;
+enum WM_ENABLE = 10;
+enum WM_ENDSESSION = 22;
+enum WM_ENTERIDLE = 289;
+enum WM_ENTERMENULOOP = 529;
+enum WM_ENTERSIZEMOVE = 561;
+enum WM_ERASEBKGND = 20;
+enum WM_EXITMENULOOP = 530;
+enum WM_EXITSIZEMOVE = 562;
+enum WM_FONTCHANGE = 29;
+enum WM_GETDLGCODE = 135;
+enum WM_GETFONT = 49;
+enum WM_GETHOTKEY = 51;
+enum WM_GETICON = 127;
+enum WM_GETMINMAXINFO = 36;
+enum WM_GETTEXT = 13;
+enum WM_GETTEXTLENGTH = 14;
+enum WM_HANDHELDFIRST = 856;
+enum WM_HANDHELDLAST = 863;
+enum WM_HELP = 83;
+enum WM_HOTKEY = 786;
+enum WM_HSCROLL = 276;
+enum WM_HSCROLLCLIPBOARD = 782;
+enum WM_ICONERASEBKGND = 39;
+enum WM_INITDIALOG = 272;
+enum WM_INITMENU = 278;
+enum WM_INITMENUPOPUP = 279;
+enum WM_INPUTLANGCHANGE = 81;
+enum WM_INPUTLANGCHANGEREQUEST = 80;
+enum WM_KEYDOWN = 256;
+enum WM_KEYUP = 257;
+enum WM_KILLFOCUS = 8;
+enum WM_MDIACTIVATE = 546;
+enum WM_MDICASCADE = 551;
+enum WM_MDICREATE = 544;
+enum WM_MDIDESTROY = 545;
+enum WM_MDIGETACTIVE = 553;
+enum WM_MDIICONARRANGE = 552;
+enum WM_MDIMAXIMIZE = 549;
+enum WM_MDINEXT = 548;
+enum WM_MDIREFRESHMENU = 564;
+enum WM_MDIRESTORE = 547;
+enum WM_MDISETMENU = 560;
+enum WM_MDITILE = 550;
+enum WM_MEASUREITEM = 44;
+enum WM_UNINITMENUPOPUP = 0x0125;
+enum WM_MENURBUTTONUP = 290;
+enum WM_MENUCOMMAND = 0x0126;
+enum WM_MENUGETOBJECT = 0x0124;
+enum WM_MENUDRAG = 0x0123;
+
+enum WM_CHANGEUISTATE = 0x0127;
+enum WM_UPDATEUISTATE = 0x0128;
+enum WM_QUERYUISTATE  = 0x0129;
+
+// LOWORD(wParam) values in WM_*UISTATE*
+enum {
+    UIS_SET          =  1,
+    UIS_CLEAR        =  2,
+    UIS_INITIALIZE   =  3
+}
+
+// HIWORD(wParam) values in WM_*UISTATE*
+enum {
+    UISF_HIDEFOCUS   =  0x1,
+    UISF_HIDEACCEL   =  0x2
+}
+
+
+static if (_WIN32_WINNT >= 0x501) {
+
+    // HIWORD(wParam) values in WM_*UISTATE*
+    enum {
+        UISF_ACTIVE      =  0x4
+    }
+
+}
+
+enum WM_MENUCHAR = 288;
+enum WM_MENUSELECT = 287;
+enum WM_MOVE = 3;
+enum WM_MOVING = 534;
+enum WM_NCACTIVATE = 134;
+enum WM_NCCALCSIZE = 131;
+enum WM_NCCREATE = 129;
+enum WM_NCDESTROY = 130;
+enum WM_NCHITTEST = 132;
+enum WM_NCLBUTTONDBLCLK = 163;
+enum WM_NCLBUTTONDOWN = 161;
+enum WM_NCLBUTTONUP = 162;
+enum WM_NCMBUTTONDBLCLK = 169;
+enum WM_NCMBUTTONDOWN = 167;
+enum WM_NCMBUTTONUP = 168;
+enum WM_NCXBUTTONDOWN = 171;
+enum WM_NCXBUTTONUP = 172;
+enum WM_NCXBUTTONDBLCLK = 173;
+enum WM_NCMOUSEHOVER = 0x02A0;
+enum WM_NCMOUSELEAVE = 0x02A2;
+enum WM_NCMOUSEMOVE = 160;
+enum WM_NCPAINT = 133;
+enum WM_NCRBUTTONDBLCLK = 166;
+enum WM_NCRBUTTONDOWN = 164;
+enum WM_NCRBUTTONUP = 165;
+enum WM_NEXTDLGCTL = 40;
+enum WM_NEXTMENU = 531;
+enum WM_NOTIFY = 78;
+enum WM_NOTIFYFORMAT = 85;
+enum WM_NULL = 0;
+enum WM_PAINT = 15;
+enum WM_PAINTCLIPBOARD = 777;
+enum WM_PAINTICON = 38;
+enum WM_PALETTECHANGED = 785;
+enum WM_PALETTEISCHANGING = 784;
+enum WM_PARENTNOTIFY = 528;
+enum WM_PASTE = 770;
+enum WM_PENWINFIRST = 896;
+enum WM_PENWINLAST = 911;
+enum WM_POWER = 72;
+enum WM_POWERBROADCAST = 536;
+enum WM_PRINT = 791;
+enum WM_PRINTCLIENT = 792;
+enum WM_APPCOMMAND = 0x0319;
+enum WM_QUERYDRAGICON = 55;
+enum WM_QUERYENDSESSION = 17;
+enum WM_QUERYNEWPALETTE = 783;
+enum WM_QUERYOPEN = 19;
+enum WM_QUEUESYNC = 35;
+enum WM_QUIT = 18;
+enum WM_RENDERALLFORMATS = 774;
+enum WM_RENDERFORMAT = 773;
+enum WM_SETCURSOR = 32;
+enum WM_SETFOCUS = 7;
+enum WM_SETFONT = 48;
+enum WM_SETHOTKEY = 50;
+enum WM_SETICON = 128;
+enum WM_SETREDRAW = 11;
+enum WM_SETTEXT = 12;
+enum WM_SETTINGCHANGE = 26;
+enum WM_SHOWWINDOW = 24;
+enum WM_SIZE = 5;
+enum WM_SIZECLIPBOARD = 779;
+enum WM_SIZING = 532;
+enum WM_SPOOLERSTATUS = 42;
+enum WM_STYLECHANGED = 125;
+enum WM_STYLECHANGING = 124;
+enum WM_SYSCHAR = 262;
+enum WM_SYSCOLORCHANGE = 21;
+enum WM_SYSCOMMAND = 274;
+enum WM_SYSDEADCHAR = 263;
+enum WM_SYSKEYDOWN = 260;
+enum WM_SYSKEYUP = 261;
+static if (_WIN32_WINNT >= 0x501) {
+    enum WM_TABLET_FIRST = 704;
+    enum WM_TABLET_LAST = 735;
+}
+enum WM_TCARD = 82;
+enum WM_THEMECHANGED = 794;
+enum WM_TIMECHANGE = 30;
+enum WM_TIMER = 275;
+enum WM_UNDO = 772;
+enum WM_USER = 1024;
+enum WM_USERCHANGED = 84;
+enum WM_VKEYTOITEM = 46;
+enum WM_VSCROLL = 277;
+enum WM_VSCROLLCLIPBOARD = 778;
+enum WM_WINDOWPOSCHANGED = 71;
+enum WM_WINDOWPOSCHANGING = 70;
+enum WM_WININICHANGE = 26;
+static if(_WIN32_WINNT >= 0x501) {
+enum WM_WTSSESSION_CHANGE = 689;
+}
+enum WM_INPUT = 255;
+enum WM_KEYFIRST = 256;
+static if(_WIN32_WINNT >= 0x501) {
+enum WM_UNICHAR = 265;
+enum WM_KEYLAST = 265;
+enum UNICODE_NOCHAR = 0xFFFF;
+} else {
+enum WM_KEYLAST = 264;
+}
+enum WM_SYNCPAINT = 136;
+enum WM_MOUSEACTIVATE = 33;
+enum WM_MOUSEMOVE = 512;
+enum WM_LBUTTONDOWN = 513;
+enum WM_LBUTTONUP = 514;
+enum WM_LBUTTONDBLCLK = 515;
+enum WM_RBUTTONDOWN = 516;
+enum WM_RBUTTONUP = 517;
+enum WM_RBUTTONDBLCLK = 518;
+enum WM_MBUTTONDOWN = 519;
+enum WM_MBUTTONUP = 520;
+enum WM_MBUTTONDBLCLK = 521;
+enum WM_MOUSEWHEEL = 522;
+enum WM_MOUSEFIRST = 512;
+static if (_WIN32_WINNT >= 0x501) {
+    enum WM_XBUTTONDOWN = 523;
+    enum WM_XBUTTONUP = 524;
+    enum WM_XBUTTONDBLCLK = 525;
+}
+static if (_WIN32_WINNT >= 0x600) { // FIXME: where did this come from? what version is it?
+    enum WM_MOUSEHWHEEL = 526;
+}
+
+static if (_WIN32_WINNT >= 0x600) {
+    enum WM_MOUSELAST = WM_MOUSEHWHEEL;
+} else static if (_WIN32_WINNT >= 0x501) {
+    enum WM_MOUSELAST = WM_XBUTTONDBLCLK;
+} else {
+    enum WM_MOUSELAST = WM_MOUSEWHEEL;
+}
+
+enum WM_MOUSEHOVER = 0x2A1;
+enum WM_MOUSELEAVE = 0x2A3;
+
+enum WHEEL_DELTA = 120;
+
+SHORT GET_WHEEL_DELTA_WPARAM()(WPARAM wparam) {
+    return cast(SHORT) HIWORD(wparam);
+}
+
+enum WHEEL_PAGESCROLL = uint.max;
+
+enum BM_CLICK = 245;
+enum BM_GETCHECK = 240;
+enum BM_GETIMAGE = 246;
+enum BM_GETSTATE = 242;
+enum BM_SETCHECK = 241;
+enum BM_SETIMAGE = 247;
+static if(_WIN32_WINNT >= 0x600) {
+    enum BM_SETDONTCLICK = 248;
+}
+enum BM_SETSTATE = 243;
+enum BM_SETSTYLE = 244;
+enum BN_CLICKED = 0;
+enum BN_DBLCLK = 5;
+enum BN_DISABLE = 4;
+enum BN_DOUBLECLICKED = 5;
+enum BN_HILITE = 2;
+enum BN_KILLFOCUS = 7;
+enum BN_PAINT = 1;
+enum BN_PUSHED = 2;
+enum BN_SETFOCUS = 6;
+enum BN_UNHILITE = 3;
+enum BN_UNPUSHED = 3;
+enum CB_ADDSTRING = 323;
+enum CB_DELETESTRING = 324;
+enum CB_DIR = 325;
+enum CB_FINDSTRING = 332;
+enum CB_FINDSTRINGEXACT = 344;
+enum CB_GETCOUNT = 326;
+enum CB_GETCURSEL = 327;
+enum CB_GETDROPPEDCONTROLRECT = 338;
+enum CB_GETDROPPEDSTATE = 343;
+enum CB_GETDROPPEDWIDTH = 351;
+enum CB_GETEDITSEL = 320;
+enum CB_GETEXTENDEDUI = 342;
+enum CB_GETHORIZONTALEXTENT = 349;
+enum CB_GETITEMDATA = 336;
+enum CB_GETITEMHEIGHT = 340;
+enum CB_GETLBTEXT = 328;
+enum CB_GETLBTEXTLEN = 329;
+enum CB_GETLOCALE = 346;
+enum CB_GETTOPINDEX = 347;
+enum CB_INITSTORAGE = 353;
+enum CB_INSERTSTRING = 330;
+enum CB_LIMITTEXT = 321;
+enum CB_RESETCONTENT = 331;
+enum CB_SELECTSTRING = 333;
+enum CB_SETCURSEL = 334;
+enum CB_SETDROPPEDWIDTH = 352;
+enum CB_SETEDITSEL = 322;
+enum CB_SETEXTENDEDUI = 341;
+enum CB_SETHORIZONTALEXTENT = 350;
+enum CB_SETITEMDATA = 337;
+enum CB_SETITEMHEIGHT = 339;
+enum CB_SETLOCALE = 345;
+enum CB_SETTOPINDEX = 348;
+enum CB_SHOWDROPDOWN = 335;
+
+static if(_WIN32_WINNT >= 0x501) {
+enum CB_GETCOMBOBOXINFO = 356;
+}
+
+enum CBN_CLOSEUP = 8;
+enum CBN_DBLCLK = 2;
+enum CBN_DROPDOWN = 7;
+enum CBN_EDITCHANGE = 5;
+enum CBN_EDITUPDATE = 6;
+enum CBN_ERRSPACE = (-1);
+enum CBN_KILLFOCUS = 4;
+enum CBN_SELCHANGE = 1;
+enum CBN_SELENDCANCEL = 10;
+enum CBN_SELENDOK = 9;
+enum CBN_SETFOCUS = 3;
+
+enum EM_CANUNDO = 198;
+enum EM_CHARFROMPOS = 215;
+enum EM_EMPTYUNDOBUFFER = 205;
+enum EM_FMTLINES = 200;
+enum EM_GETFIRSTVISIBLELINE = 206;
+enum EM_GETHANDLE = 189;
+enum EM_GETLIMITTEXT = 213;
+enum EM_GETLINE = 196;
+enum EM_GETLINECOUNT = 186;
+enum EM_GETMARGINS = 212;
+enum EM_GETMODIFY = 184;
+enum EM_GETPASSWORDCHAR = 210;
+enum EM_GETRECT = 178;
+enum EM_GETSEL = 176;
+enum EM_GETTHUMB = 190;
+enum EM_GETWORDBREAKPROC = 209;
+enum EM_LIMITTEXT = 197;
+enum EM_LINEFROMCHAR = 201;
+enum EM_LINEINDEX = 187;
+enum EM_LINELENGTH = 193;
+enum EM_LINESCROLL = 182;
+enum EM_POSFROMCHAR = 214;
+enum EM_REPLACESEL = 194;
+enum EM_SCROLL = 181;
+enum EM_SCROLLCARET = 183;
+enum EM_SETHANDLE = 188;
+enum EM_SETLIMITTEXT = 197;
+enum EM_SETMARGINS = 211;
+enum EM_SETMODIFY = 185;
+enum EM_SETPASSWORDCHAR = 204;
+enum EM_SETREADONLY = 207;
+enum EM_SETRECT = 179;
+enum EM_SETRECTNP = 180;
+enum EM_SETSEL = 177;
+enum EM_SETTABSTOPS = 203;
+enum EM_SETWORDBREAKPROC = 208;
+enum EM_UNDO = 199;
+
+enum EM_SETIMESTATUS = 216;
+enum EM_GETIMESTATUS = 217;
+
+enum EN_CHANGE = 768;
+enum EN_ERRSPACE = 1280;
+enum EN_HSCROLL = 1537;
+enum EN_KILLFOCUS = 512;
+enum EN_MAXTEXT = 1281;
+enum EN_SETFOCUS = 256;
+enum EN_UPDATE = 1024;
+enum EN_VSCROLL = 1538;
+
+enum LB_ADDFILE = 406;
+enum LB_ADDSTRING = 384;
+enum LB_DELETESTRING = 386;
+enum LB_DIR = 397;
+enum LB_FINDSTRING = 399;
+enum LB_FINDSTRINGEXACT = 418;
+enum LB_GETANCHORINDEX = 413;
+enum LB_GETCARETINDEX = 415;
+enum LB_GETCOUNT = 395;
+enum LB_GETCURSEL = 392;
+enum LB_GETHORIZONTALEXTENT = 403;
+enum LB_GETITEMDATA = 409;
+enum LB_GETITEMHEIGHT = 417;
+enum LB_GETITEMRECT = 408;
+enum LB_GETLOCALE = 422;
+enum LB_GETSEL = 391;
+enum LB_GETSELCOUNT = 400;
+enum LB_GETSELITEMS = 401;
+enum LB_GETTEXT = 393;
+enum LB_GETTEXTLEN = 394;
+enum LB_GETTOPINDEX = 398;
+enum LB_INITSTORAGE = 424;
+enum LB_INSERTSTRING = 385;
+enum LB_ITEMFROMPOINT = 425;
+enum LB_RESETCONTENT = 388;
+enum LB_SELECTSTRING = 396;
+enum LB_SELITEMRANGE = 411;
+enum LB_SELITEMRANGEEX = 387;
+enum LB_SETANCHORINDEX = 412;
+enum LB_SETCARETINDEX = 414;
+enum LB_SETCOLUMNWIDTH = 405;
+enum LB_SETCOUNT = 423;
+enum LB_SETCURSEL = 390;
+enum LB_SETHORIZONTALEXTENT = 404;
+enum LB_SETITEMDATA = 410;
+enum LB_SETITEMHEIGHT = 416;
+enum LB_SETLOCALE = 421;
+enum LB_SETSEL = 389;
+enum LB_SETTABSTOPS = 402;
+enum LB_SETTOPINDEX = 407;
+static if(_WIN32_WINNT >= 0x501) {
+enum LB_GETLISTBOXINFO = 434;
+}
+
+enum LBN_DBLCLK = 2;
+enum LBN_ERRSPACE = -2;
+enum LBN_KILLFOCUS = 5;
+enum LBN_SELCANCEL = 3;
+enum LBN_SELCHANGE = 1;
+enum LBN_SETFOCUS = 4;
+
+enum SBM_ENABLE_ARROWS = 228;
+enum SBM_GETPOS = 225;
+enum SBM_GETRANGE = 227;
+enum SBM_GETSCROLLINFO = 234;
+enum SBM_SETPOS = 224;
+enum SBM_SETRANGE = 226;
+enum SBM_SETRANGEREDRAW = 230;
+enum SBM_SETSCROLLINFO = 233;
+static if(_WIN32_WINNT >= 0x501) {
+enum SBM_GETSCROLLBARINFO = 235;
+}
+
+enum STM_GETICON = 369;
+enum STM_GETIMAGE = 371;
+enum STM_SETICON = 368;
+enum STM_SETIMAGE = 370;
+enum STN_CLICKED = 0;
+enum STN_DBLCLK = 1;
+enum STN_DISABLE = 3;
+enum STN_ENABLE = 2;
+enum STM_MSGMAX = 372;
+
+enum DM_GETDEFID   = WM_USER;
+enum DM_SETDEFID   = WM_USER+1;
+enum DM_REPOSITION = WM_USER+2;
+
+enum PSM_PAGEINFO  = WM_USER+100;
+enum PSM_SHEETINFO = WM_USER+101;
+
+enum PSI_SETACTIVE = 1;
+enum PSI_KILLACTIVE = 2;
+enum PSI_APPLY = 3;
+enum PSI_RESET = 4;
+enum PSI_HASHELP = 5;
+enum PSI_HELP = 6;
+enum PSI_CHANGED = 1;
+enum PSI_GUISTART = 2;
+enum PSI_REBOOT = 3;
+enum PSI_GETSIBLINGS = 4;
+
+enum DCX_WINDOW = 1;
+enum DCX_CACHE = 2;
+enum DCX_PARENTCLIP = 32;
+enum DCX_CLIPSIBLINGS = 16;
+enum DCX_CLIPCHILDREN = 8;
+enum DCX_NORESETATTRS = 4;
+enum DCX_INTERSECTUPDATE = 0x200;
+enum DCX_LOCKWINDOWUPDATE = 0x400;
+enum DCX_EXCLUDERGN = 64;
+enum DCX_INTERSECTRGN = 128;
+enum DCX_EXCLUDEUPDATE = 256;
+enum DCX_VALIDATE = 0x200000;
+
+enum GMDI_GOINTOPOPUPS = 2;
+enum GMDI_USEDISABLED = 1;
+enum FKF_AVAILABLE = 2;
+enum FKF_CLICKON = 64;
+enum FKF_FILTERKEYSON = 1;
+enum FKF_HOTKEYACTIVE = 4;
+enum FKF_HOTKEYSOUND = 16;
+enum FKF_CONFIRMHOTKEY = 8;
+enum FKF_INDICATOR = 32;
+enum HCF_HIGHCONTRASTON = 1;
+enum HCF_AVAILABLE = 2;
+enum HCF_HOTKEYACTIVE = 4;
+enum HCF_CONFIRMHOTKEY = 8;
+enum HCF_HOTKEYSOUND = 16;
+enum HCF_INDICATOR = 32;
+enum HCF_HOTKEYAVAILABLE = 64;
+enum MKF_AVAILABLE = 2;
+enum MKF_CONFIRMHOTKEY = 8;
+enum MKF_HOTKEYACTIVE = 4;
+enum MKF_HOTKEYSOUND = 16;
+enum MKF_INDICATOR = 32;
+enum MKF_MOUSEKEYSON = 1;
+enum MKF_MODIFIERS = 64;
+enum MKF_REPLACENUMBERS = 128;
+enum SERKF_ACTIVE = 8;  // May be obsolete. Not in recent MS docs.
+enum SERKF_AVAILABLE = 2;
+enum SERKF_INDICATOR = 4;
+enum SERKF_SERIALKEYSON = 1;
+enum SSF_AVAILABLE = 2;
+enum SSF_SOUNDSENTRYON = 1;
+enum SSTF_BORDER = 2;
+enum SSTF_CHARS = 1;
+enum SSTF_DISPLAY = 3;
+enum SSTF_NONE = 0;
+enum SSGF_DISPLAY = 3;
+enum SSGF_NONE = 0;
+enum SSWF_CUSTOM = 4;
+enum SSWF_DISPLAY = 3;
+enum SSWF_NONE = 0;
+enum SSWF_TITLE = 1;
+enum SSWF_WINDOW = 2;
+enum SKF_AUDIBLEFEEDBACK = 64;
+enum SKF_AVAILABLE = 2;
+enum SKF_CONFIRMHOTKEY = 8;
+enum SKF_HOTKEYACTIVE = 4;
+enum SKF_HOTKEYSOUND = 16;
+enum SKF_INDICATOR = 32;
+enum SKF_STICKYKEYSON = 1;
+enum SKF_TRISTATE = 128;
+enum SKF_TWOKEYSOFF = 256;
+enum TKF_AVAILABLE = 2;
+enum TKF_CONFIRMHOTKEY = 8;
+enum TKF_HOTKEYACTIVE = 4;
+enum TKF_HOTKEYSOUND = 16;
+enum TKF_TOGGLEKEYSON = 1;
+enum MDITILE_SKIPDISABLED = 2;
+enum MDITILE_HORIZONTAL = 1;
+enum MDITILE_VERTICAL = 0;
+
+enum {
+    VK_LBUTTON = 0x01,
+    VK_RBUTTON = 0x02,
+    VK_CANCEL = 0x03,
+    VK_MBUTTON = 0x04,
+    VK_XBUTTON1 = 0x05,
+    VK_XBUTTON2 = 0x06,
+    VK_BACK = 0x08,
+    VK_TAB = 0x09,
+    VK_CLEAR = 0x0C,
+    VK_RETURN = 0x0D,
+    VK_SHIFT = 0x10,
+    VK_CONTROL = 0x11,
+    VK_MENU = 0x12,
+    VK_PAUSE = 0x13,
+    VK_CAPITAL = 0x14,
+    VK_KANA = 0x15,
+    VK_HANGEUL = 0x15,
+    VK_HANGUL = 0x15,
+    VK_JUNJA = 0x17,
+    VK_FINAL = 0x18,
+    VK_HANJA = 0x19,
+    VK_KANJI = 0x19,
+    VK_ESCAPE = 0x1B,
+    VK_CONVERT = 0x1C,
+    VK_NONCONVERT = 0x1D,
+    VK_ACCEPT = 0x1E,
+    VK_MODECHANGE = 0x1F,
+    VK_SPACE = 0x20,
+    VK_PRIOR = 0x21,
+    VK_NEXT = 0x22,
+    VK_END = 0x23,
+    VK_HOME = 0x24,
+    VK_LEFT = 0x25,
+    VK_UP = 0x26,
+    VK_RIGHT = 0x27,
+    VK_DOWN = 0x28,
+    VK_SELECT = 0x29,
+    VK_PRINT = 0x2A,
+    VK_EXECUTE = 0x2B,
+    VK_SNAPSHOT = 0x2C,
+    VK_INSERT = 0x2D,
+    VK_DELETE = 0x2E,
+    VK_HELP = 0x2F,
+    VK_LWIN = 0x5B,
+    VK_RWIN = 0x5C,
+    VK_APPS = 0x5D,
+    VK_SLEEP = 0x5F,
+    VK_NUMPAD0 = 0x60,
+    VK_NUMPAD1 = 0x61,
+    VK_NUMPAD2 = 0x62,
+    VK_NUMPAD3 = 0x63,
+    VK_NUMPAD4 = 0x64,
+    VK_NUMPAD5 = 0x65,
+    VK_NUMPAD6 = 0x66,
+    VK_NUMPAD7 = 0x67,
+    VK_NUMPAD8 = 0x68,
+    VK_NUMPAD9 = 0x69,
+    VK_MULTIPLY = 0x6A,
+    VK_ADD = 0x6B,
+    VK_SEPARATOR = 0x6C,
+    VK_SUBTRACT = 0x6D,
+    VK_DECIMAL = 0x6E,
+    VK_DIVIDE = 0x6F,
+    VK_F1 = 0x70,
+    VK_F2 = 0x71,
+    VK_F3 = 0x72,
+    VK_F4 = 0x73,
+    VK_F5 = 0x74,
+    VK_F6 = 0x75,
+    VK_F7 = 0x76,
+    VK_F8 = 0x77,
+    VK_F9 = 0x78,
+    VK_F10 = 0x79,
+    VK_F11 = 0x7A,
+    VK_F12 = 0x7B,
+    VK_F13 = 0x7C,
+    VK_F14 = 0x7D,
+    VK_F15 = 0x7E,
+    VK_F16 = 0x7F,
+    VK_F17 = 0x80,
+    VK_F18 = 0x81,
+    VK_F19 = 0x82,
+    VK_F20 = 0x83,
+    VK_F21 = 0x84,
+    VK_F22 = 0x85,
+    VK_F23 = 0x86,
+    VK_F24 = 0x87,
+    VK_NUMLOCK = 0x90,
+    VK_SCROLL = 0x91,
+    VK_LSHIFT = 0xA0,
+    VK_RSHIFT = 0xA1,
+    VK_LCONTROL = 0xA2,
+    VK_RCONTROL = 0xA3,
+    VK_LMENU = 0xA4,
+    VK_RMENU = 0xA5,
+    VK_BROWSER_BACK = 0xA6,
+    VK_BROWSER_FORWARD = 0xA7,
+    VK_BROWSER_REFRESH = 0xA8,
+    VK_BROWSER_STOP = 0xA9,
+    VK_BROWSER_SEARCH = 0xAA,
+    VK_BROWSER_FAVORITES = 0xAB,
+    VK_BROWSER_HOME = 0xAC,
+    VK_VOLUME_MUTE = 0xAD,
+    VK_VOLUME_DOWN = 0xAE,
+    VK_VOLUME_UP = 0xAF,
+    VK_MEDIA_NEXT_TRACK = 0xB0,
+    VK_MEDIA_PREV_TRACK = 0xB1,
+    VK_MEDIA_STOP = 0xB2,
+    VK_MEDIA_PLAY_PAUSE = 0xB3,
+    VK_LAUNCH_MAIL = 0xB4,
+    VK_LAUNCH_MEDIA_SELECT = 0xB5,
+    VK_LAUNCH_APP1 = 0xB6,
+    VK_LAUNCH_APP2 = 0xB7,
+    VK_OEM_1 = 0xBA,
+    VK_OEM_PLUS = 0xBB,
+    VK_OEM_COMMA = 0xBC,
+    VK_OEM_MINUS = 0xBD,
+    VK_OEM_PERIOD = 0xBE,
+    VK_OEM_2 = 0xBF,
+    VK_OEM_3 = 0xC0,
+    VK_OEM_4 = 0xDB,
+    VK_OEM_5 = 0xDC,
+    VK_OEM_6 = 0xDD,
+    VK_OEM_7 = 0xDE,
+    VK_OEM_8 = 0xDF,
+    VK_OEM_102 = 0xE2,
+    VK_PROCESSKEY = 0xE5,
+    VK_PACKET = 0xE7,
+    VK_ATTN = 0xF6,
+    VK_CRSEL = 0xF7,
+    VK_EXSEL = 0xF8,
+    VK_EREOF = 0xF9,
+    VK_PLAY = 0xFA,
+    VK_ZOOM = 0xFB,
+    VK_NONAME = 0xFC,
+    VK_PA1 = 0xFD,
+    VK_OEM_CLEAR = 0xFE,
+}
+
+enum TME_HOVER = 1;
+enum TME_LEAVE = 2;
+enum TME_QUERY = 0x40000000;
+enum TME_CANCEL = 0x80000000;
+
+enum HOVER_DEFAULT = 0xFFFFFFFF;
+
+enum MK_LBUTTON = 1;
+enum MK_RBUTTON = 2;
+enum MK_SHIFT = 4;
+enum MK_CONTROL = 8;
+enum MK_MBUTTON = 16;
+enum MK_XBUTTON1 = 32;
+enum MK_XBUTTON2 = 64;
+
+enum {
+    TPM_RECURSE      = 0x0001,
+    TPM_LEFTBUTTON   = 0,
+    TPM_RIGHTBUTTON  = 0x0002,
+    TPM_LEFTALIGN    = 0,
+    TPM_CENTERALIGN  = 0x0004,
+    TPM_RIGHTALIGN   = 0x0008,
+    TPM_TOPALIGN     = 0,
+    TPM_VCENTERALIGN = 0x0010,
+    TPM_BOTTOMALIGN  = 0x0020,
+    TPM_HORIZONTAL   = 0,
+    TPM_VERTICAL     = 0x0040,
+    TPM_NONOTIFY     = 0x0080,
+    TPM_RETURNCMD    = 0x0100
+}
+
+enum HELP_COMMAND = 0x102;
+enum HELP_CONTENTS = 3;
+enum HELP_CONTEXT = 1;
+enum HELP_CONTEXTPOPUP = 8;
+enum HELP_FORCEFILE = 9;
+enum HELP_HELPONHELP = 4;
+enum HELP_INDEX = 3;
+enum HELP_KEY = 0x101;
+enum HELP_MULTIKEY = 0x201;
+enum HELP_PARTIALKEY = 0x105;
+enum HELP_QUIT = 2;
+enum HELP_SETCONTENTS = 5;
+enum HELP_SETINDEX = 5;
+enum HELP_SETWINPOS = 0x203;
+enum HELP_CONTEXTMENU = 0xa;
+enum HELP_FINDER = 0xb;
+enum HELP_WM_HELP = 0xc;
+enum HELP_TCARD = 0x8000;
+enum HELP_TCARD_DATA = 16;
+enum HELP_TCARD_OTHER_CALLER = 0x11;
+
+enum IDH_NO_HELP = 28440;
+enum IDH_MISSING_CONTEXT = 28441;
+enum IDH_GENERIC_HELP_BUTTON = 28442;
+enum IDH_OK = 28443;
+enum IDH_CANCEL = 28444;
+enum IDH_HELP = 28445;
+
+enum LB_CTLCODE = 0;
+enum LB_OKAY = 0;
+enum LB_ERR = -1;
+enum LB_ERRSPACE = -2;
+
+enum CB_OKAY = 0;
+enum CB_ERR = -1;
+enum CB_ERRSPACE = -2;
+
+enum HIDE_WINDOW = 0;
+
+enum SHOW_OPENWINDOW = 1;
+enum SHOW_ICONWINDOW = 2;
+enum SHOW_FULLSCREEN = 3;
+enum SHOW_OPENNOACTIVATE = 4;
+
+enum KF_EXTENDED = 256;
+enum KF_DLGMODE = 2048;
+enum KF_MENUMODE = 4096;
+enum KF_ALTDOWN = 8192;
+enum KF_REPEAT = 16384;
+enum KF_UP = 32768;
+
+enum WSF_VISIBLE = 1;
+
+enum PWR_OK = 1;
+enum PWR_FAIL = -1;
+enum PWR_SUSPENDREQUEST = 1;
+enum PWR_SUSPENDRESUME = 2;
+enum PWR_CRITICALRESUME = 3;
+
+enum NFR_ANSI = 1;
+enum NFR_UNICODE = 2;
+enum NF_QUERY = 3;
+enum NF_REQUERY = 4;
+
+enum MENULOOP_WINDOW = 0;
+enum MENULOOP_POPUP = 1;
+
+enum WMSZ_LEFT = 1;
+enum WMSZ_RIGHT = 2;
+enum WMSZ_TOP = 3;
+enum WMSZ_TOPLEFT = 4;
+enum WMSZ_TOPRIGHT = 5;
+enum WMSZ_BOTTOM = 6;
+enum WMSZ_BOTTOMLEFT = 7;
+enum WMSZ_BOTTOMRIGHT = 8;
+
+enum HTERROR = -2;
+enum HTTRANSPARENT = -1;
+enum HTNOWHERE = 0;
+enum HTCLIENT = 1;
+enum HTCAPTION = 2;
+enum HTSYSMENU = 3;
+enum HTGROWBOX = 4;
+enum HTSIZE = 4;
+enum HTMENU = 5;
+enum HTHSCROLL = 6;
+enum HTVSCROLL = 7;
+enum HTMINBUTTON = 8;
+enum HTMAXBUTTON = 9;
+enum HTREDUCE = 8;
+enum HTZOOM = 9;
+enum HTLEFT = 10;
+enum HTSIZEFIRST = 10;
+enum HTRIGHT = 11;
+enum HTTOP = 12;
+enum HTTOPLEFT = 13;
+enum HTTOPRIGHT = 14;
+enum HTBOTTOM = 15;
+enum HTBOTTOMLEFT = 16;
+enum HTBOTTOMRIGHT = 17;
+enum HTSIZELAST = 17;
+enum HTBORDER = 18;
+enum HTOBJECT = 19;
+enum HTCLOSE = 20;
+enum HTHELP = 21;
+
+enum MA_ACTIVATE = 1;
+enum MA_ACTIVATEANDEAT = 2;
+enum MA_NOACTIVATE = 3;
+enum MA_NOACTIVATEANDEAT = 4;
+
+enum SIZE_RESTORED = 0;
+enum SIZE_MINIMIZED = 1;
+enum SIZE_MAXIMIZED = 2;
+enum SIZE_MAXSHOW = 3;
+enum SIZE_MAXHIDE = 4;
+
+enum SIZENORMAL = 0;
+enum SIZEICONIC = 1;
+enum SIZEFULLSCREEN = 2;
+enum SIZEZOOMSHOW = 3;
+enum SIZEZOOMHIDE = 4;
+
+enum WVR_ALIGNTOP = 16;
+enum WVR_ALIGNLEFT = 32;
+enum WVR_ALIGNBOTTOM = 64;
+enum WVR_ALIGNRIGHT = 128;
+enum WVR_HREDRAW = 256;
+enum WVR_VREDRAW = 512;
+enum WVR_REDRAW = (WVR_HREDRAW|WVR_VREDRAW);
+enum WVR_VALIDRECTS = 1024;
+
+enum PRF_CHECKVISIBLE = 1;
+enum PRF_NONCLIENT = 2;
+enum PRF_CLIENT = 4;
+enum PRF_ERASEBKGND = 8;
+enum PRF_CHILDREN = 16;
+enum PRF_OWNED = 32;
+
+enum IDANI_OPEN = 1;
+enum IDANI_CLOSE = 2;
+enum IDANI_CAPTION = 3;
+
+enum WPF_RESTORETOMAXIMIZED = 2;
+enum WPF_SETMINPOSITION = 1;
+
+enum ODT_MENU = 1;
+enum ODT_LISTBOX = 2;
+enum ODT_COMBOBOX = 3;
+enum ODT_BUTTON = 4;
+enum ODT_STATIC = 5;
+enum ODA_DRAWENTIRE = 1;
+enum ODA_SELECT = 2;
+enum ODA_FOCUS = 4;
+enum ODS_SELECTED = 1;
+enum ODS_GRAYED = 2;
+enum ODS_DISABLED = 4;
+enum ODS_CHECKED = 8;
+enum ODS_FOCUS = 16;
+enum ODS_DEFAULT = 32;
+enum ODS_COMBOBOXEDIT = 4096;
+
+enum IDHOT_SNAPWINDOW = -1;
+enum IDHOT_SNAPDESKTOP = -2;
+
+enum DBWF_LPARAMPOINTER = 0x8000;
+enum DLGWINDOWEXTRA = 30;
+enum MNC_IGNORE = 0;
+enum MNC_CLOSE = 1;
+enum MNC_EXECUTE = 2;
+enum MNC_SELECT = 3;
+enum DOF_EXECUTABLE = 0x8001;
+enum DOF_DOCUMENT = 0x8002;
+enum DOF_DIRECTORY = 0x8003;
+enum DOF_MULTIPLE = 0x8004;
+enum DOF_PROGMAN = 1;
+enum DOF_SHELLDATA = 2;
+enum DO_DROPFILE = 0x454C4946;
+enum DO_PRINTFILE = 0x544E5250;
+
+enum SC_SIZE = 0xF000;
+enum SC_MOVE = 0xF010;
+enum SC_MINIMIZE = 0xF020;
+enum SC_ICON = 0xf020;
+enum SC_MAXIMIZE = 0xF030;
+enum SC_ZOOM = 0xF030;
+enum SC_NEXTWINDOW = 0xF040;
+enum SC_PREVWINDOW = 0xF050;
+enum SC_CLOSE = 0xF060;
+enum SC_VSCROLL = 0xF070;
+enum SC_HSCROLL = 0xF080;
+enum SC_MOUSEMENU = 0xF090;
+enum SC_KEYMENU = 0xF100;
+enum SC_ARRANGE = 0xF110;
+enum SC_RESTORE = 0xF120;
+enum SC_TASKLIST = 0xF130;
+enum SC_SCREENSAVE = 0xF140;
+enum SC_HOTKEY = 0xF150;
+enum SC_DEFAULT = 0xF160;
+enum SC_MONITORPOWER = 0xF170;
+enum SC_CONTEXTHELP = 0xF180;
+enum SC_SEPARATOR = 0xF00F;
+
+enum EC_LEFTMARGIN = 1;
+enum EC_RIGHTMARGIN = 2;
+enum EC_USEFONTINFO = 0xffff;
+
+enum DC_HASDEFID = 0x534B;
+
+enum DLGC_WANTARROWS = 1;
+enum DLGC_WANTTAB = 2;
+enum DLGC_WANTALLKEYS = 4;
+enum DLGC_WANTMESSAGE = 4;
+enum DLGC_HASSETSEL = 8;
+enum DLGC_DEFPUSHBUTTON = 16;
+enum DLGC_UNDEFPUSHBUTTON = 32;
+enum DLGC_RADIOBUTTON = 64;
+enum DLGC_WANTCHARS = 128;
+enum DLGC_STATIC = 256;
+enum DLGC_BUTTON = 0x2000;
+
+enum WA_INACTIVE = 0;
+enum WA_ACTIVE = 1;
+enum WA_CLICKACTIVE = 2;
+
+enum ICON_SMALL = 0;
+enum ICON_BIG = 1;
+static if (_WIN32_WINNT >= 0x501) {
+enum ICON_SMALL2 = 2;
+}
+
+enum HBITMAP
+    HBMMENU_CALLBACK = cast(HBITMAP)-1,
+    HBMMENU_SYSTEM = cast(HBITMAP)1,
+    HBMMENU_MBAR_RESTORE = cast(HBITMAP)2,
+    HBMMENU_MBAR_MINIMIZE = cast(HBITMAP)3,
+    HBMMENU_MBAR_CLOSE = cast(HBITMAP)5,
+    HBMMENU_MBAR_CLOSE_D = cast(HBITMAP)6,
+    HBMMENU_MBAR_MINIMIZE_D = cast(HBITMAP)7,
+    HBMMENU_POPUP_CLOSE = cast(HBITMAP)8,
+    HBMMENU_POPUP_RESTORE = cast(HBITMAP)9,
+    HBMMENU_POPUP_MAXIMIZE = cast(HBITMAP)10,
+    HBMMENU_POPUP_MINIMIZE = cast(HBITMAP)11;
+
+enum MOD_ALT = 1;
+enum MOD_CONTROL = 2;
+enum MOD_SHIFT = 4;
+enum MOD_WIN = 8;
+enum MOD_IGNORE_ALL_MODIFIER = 1024;
+enum MOD_ON_KEYUP = 2048;
+enum MOD_RIGHT = 16384;
+enum MOD_LEFT = 32768;
+
+enum LLKHF_EXTENDED = (KF_EXTENDED >> 8);
+enum LLKHF_INJECTED = 0x00000010;
+enum LLKHF_ALTDOWN = (KF_ALTDOWN >> 8);
+enum LLKHF_UP = (KF_UP >> 8);
+
+enum CURSOR_SHOWING = 0x00000001;
+enum WS_ACTIVECAPTION = 0x00000001;
+enum ENDSESSION_LOGOFF = 0x80000000;
+
+enum GA_PARENT    = 1;
+enum GA_ROOT      = 2;
+enum GA_ROOTOWNER = 3;
+
+enum {
+    MAPVK_VK_TO_VSC,
+    MAPVK_VSC_TO_VK,
+    MAPVK_VK_TO_CHAR,
+    MAPVK_VSC_TO_VK_EX,
+    MAPVK_VK_TO_VSC_EX // = 4
+}
+
+enum {
+    INPUT_MOUSE,
+    INPUT_KEYBOARD,
+    INPUT_HARDWARE // = 2
+}
+
+// Callbacks
+// ---------
+extern (Windows) nothrow {
+    alias INT_PTR function(HWND, UINT, WPARAM, LPARAM)   DLGPROC;
+    alias void function(HWND, UINT, UINT_PTR, DWORD)     TIMERPROC;
+    alias BOOL function(HDC, LPARAM, int)                GRAYSTRINGPROC;
+    alias LRESULT function(int, WPARAM, LPARAM)          HOOKPROC;
+    alias BOOL function(HWND, LPCSTR, HANDLE)            PROPENUMPROCA;
+    alias BOOL function(HWND, LPCWSTR, HANDLE)           PROPENUMPROCW;
+    alias BOOL function(HWND, LPSTR, HANDLE, ULONG_PTR)  PROPENUMPROCEXA;
+    alias BOOL function(HWND, LPWSTR, HANDLE, ULONG_PTR) PROPENUMPROCEXW;
+    alias int function(LPSTR, int, int, int)             EDITWORDBREAKPROCA;
+    alias int function(LPWSTR, int, int, int)            EDITWORDBREAKPROCW;
+    alias LRESULT function(HWND, UINT, WPARAM, LPARAM)   WNDPROC;
+    alias BOOL function(HDC, LPARAM, WPARAM, int, int)   DRAWSTATEPROC;
+    alias BOOL function(HWND, LPARAM)                    WNDENUMPROC;
+    alias BOOL function(HWND, LPARAM)                    ENUMWINDOWSPROC;
+    alias void function(LPHELPINFO)                      MSGBOXCALLBACK;
+
+    alias BOOL function(HMONITOR, HDC, LPRECT, LPARAM)   MONITORENUMPROC;
+    alias BOOL function(LPSTR, LPARAM)                   NAMEENUMPROCA;
+    alias BOOL function(LPWSTR, LPARAM)                  NAMEENUMPROCW;
+    alias void function(HWND, UINT, ULONG_PTR, LRESULT)  SENDASYNCPROC;
+
+    alias NAMEENUMPROCA DESKTOPENUMPROCA;
+    alias NAMEENUMPROCW DESKTOPENUMPROCW;
+    alias NAMEENUMPROCA WINSTAENUMPROCA;
+    alias NAMEENUMPROCW WINSTAENUMPROCW;
+}
+
+mixin DECLARE_HANDLE!("HDWP");
+mixin DECLARE_HANDLE!("HDEVNOTIFY");
+
+struct MENUGETOBJECTINFO {
+    DWORD dwFlags;
+    UINT  uPos;
+    HMENU hmenu;
+    PVOID riid;
+    PVOID pvObj;
+}
+alias MENUGETOBJECTINFO* PMENUGETOBJECTINFO;
+
+struct ACCEL {
+    BYTE fVirt;
+    WORD key;
+    WORD cmd;
+}
+alias ACCEL* LPACCEL;
+
+struct ACCESSTIMEOUT {
+    UINT  cbSize = ACCESSTIMEOUT.sizeof;
+    DWORD dwFlags;
+    DWORD iTimeOutMSec;
+}
+alias ACCESSTIMEOUT* LPACCESSTIMEOUT;
+
+struct ANIMATIONINFO {
+    UINT cbSize = ANIMATIONINFO.sizeof;
+    int  iMinAnimate;
+}
+alias ANIMATIONINFO* LPANIMATIONINFO;
+
+struct CREATESTRUCTA {
+    LPVOID    lpCreateParams;
+    HINSTANCE hInstance;
+    HMENU     hMenu;
+    HWND      hwndParent;
+    int       cy;
+    int       cx;
+    int       y;
+    int       x;
+    LONG      style;
+    LPCSTR    lpszName;
+    LPCSTR    lpszClass;
+    DWORD     dwExStyle;
+}
+alias CREATESTRUCTA* LPCREATESTRUCTA;
+
+struct CREATESTRUCTW {
+    LPVOID    lpCreateParams;
+    HINSTANCE hInstance;
+    HMENU     hMenu;
+    HWND      hwndParent;
+    int       cy;
+    int       cx;
+    int       y;
+    int       x;
+    LONG      style;
+    LPCWSTR   lpszName;
+    LPCWSTR   lpszClass;
+    DWORD     dwExStyle;
+}
+alias CREATESTRUCTW* LPCREATESTRUCTW;
+
+struct CBT_CREATEWNDA {
+    LPCREATESTRUCTA lpcs;
+    HWND            hwndInsertAfter;
+}
+alias CBT_CREATEWNDA* LPCBT_CREATEWNDA;
+
+struct CBT_CREATEWNDW {
+    LPCREATESTRUCTW lpcs;
+    HWND            hwndInsertAfter;
+}
+alias CBT_CREATEWNDW* LPCBT_CREATEWNDW;
+
+struct CBTACTIVATESTRUCT {
+    BOOL fMouse;
+    HWND hWndActive;
+}
+alias CBTACTIVATESTRUCT* LPCBTACTIVATESTRUCT;
+
+static if (_WIN32_WINNT >= 0x501) {
+
+struct WTSSESSION_NOTIFICATION
+{
+    DWORD cbSize;
+    DWORD dwSessionId;
+}
+alias WTSSESSION_NOTIFICATION* PWTSSESSION_NOTIFICATION;
+
+}
+
+struct CLIENTCREATESTRUCT {
+    HANDLE hWindowMenu;
+    UINT   idFirstChild;
+}
+alias CLIENTCREATESTRUCT* LPCLIENTCREATESTRUCT;
+
+struct COMPAREITEMSTRUCT {
+    UINT  CtlType;
+    UINT  CtlID;
+    HWND  hwndItem;
+    UINT  itemID1;
+    DWORD itemData1;
+    UINT  itemID2;
+    DWORD itemData2;
+    DWORD dwLocaleId;
+}
+alias COMPAREITEMSTRUCT* LPCOMPAREITEMSTRUCT;
+
+struct COPYDATASTRUCT {
+    DWORD dwData;
+    DWORD cbData;
+    PVOID lpData;
+}
+alias COPYDATASTRUCT* PCOPYDATASTRUCT;
+
+struct CURSORSHAPE {
+    int xHotSpot;
+    int yHotSpot;
+    int cx;
+    int cy;
+    int cbWidth;
+    BYTE Planes;
+    BYTE BitsPixel;
+}
+alias CURSORSHAPE* LPCURSORSHAPE;
+
+struct CWPRETSTRUCT {
+    LRESULT lResult;
+    LPARAM lParam;
+    WPARAM wParam;
+    DWORD message;
+    HWND hwnd;
+}
+
+struct CWPSTRUCT {
+    LPARAM lParam;
+    WPARAM wParam;
+    UINT message;
+    HWND hwnd;
+}
+alias CWPSTRUCT* PCWPSTRUCT;
+
+struct DEBUGHOOKINFO {
+    DWORD idThread;
+    DWORD idThreadInstaller;
+    LPARAM lParam;
+    WPARAM wParam;
+    int code;
+}
+alias DEBUGHOOKINFO* PDEBUGHOOKINFO, LPDEBUGHOOKINFO;
+
+struct DELETEITEMSTRUCT {
+    UINT CtlType;
+    UINT CtlID;
+    UINT itemID;
+    HWND hwndItem;
+    UINT itemData;
+}
+alias DELETEITEMSTRUCT* PDELETEITEMSTRUCT, LPDELETEITEMSTRUCT;
+
+align(2):
+struct DLGITEMTEMPLATE {
+    DWORD style;
+    DWORD dwExtendedStyle;
+    short x;
+    short y;
+    short cx;
+    short cy;
+    WORD id;
+}
+alias DLGITEMTEMPLATE* LPDLGITEMTEMPLATE;
+
+struct DLGTEMPLATE {
+    DWORD style;
+    DWORD dwExtendedStyle;
+    WORD  cdit;
+    short x;
+    short y;
+    short cx;
+    short cy;
+}
+alias DLGTEMPLATE*        LPDLGTEMPLATE, LPDLGTEMPLATEA, LPDLGTEMPLATEW;
+alias const(DLGTEMPLATE)* LPCDLGTEMPLATE, LPCDLGTEMPLATEA, LPCDLGTEMPLATEW;
+
+align:
+
+struct DRAWITEMSTRUCT {
+    UINT  CtlType;
+    UINT  CtlID;
+    UINT  itemID;
+    UINT  itemAction;
+    UINT  itemState;
+    HWND  hwndItem;
+    HDC   hDC;
+    RECT  rcItem;
+    DWORD itemData;
+}
+alias DRAWITEMSTRUCT* LPDRAWITEMSTRUCT, PDRAWITEMSTRUCT;
+
+struct DRAWTEXTPARAMS {
+    UINT cbSize = DRAWTEXTPARAMS.sizeof;
+    int  iTabLength;
+    int  iLeftMargin;
+    int  iRightMargin;
+    UINT uiLengthDrawn;
+}
+alias DRAWTEXTPARAMS* LPDRAWTEXTPARAMS;
+
+struct PAINTSTRUCT {
+    HDC      hdc;
+    BOOL     fErase;
+    RECT     rcPaint;
+    BOOL     fRestore;
+    BOOL     fIncUpdate;
+    BYTE[32] rgbReserved;
+}
+alias PAINTSTRUCT* PPAINTSTRUCT, NPPAINTSTRUCT, LPPAINTSTRUCT;
+
+struct MSG {
+    HWND   hwnd;
+    UINT   message;
+    WPARAM wParam;
+    LPARAM lParam;
+    DWORD  time;
+    POINT  pt;
+}
+alias MSG* NPMSG, LPMSG, PMSG;
+
+struct ICONINFO {
+    BOOL    fIcon;
+    DWORD   xHotspot;
+    DWORD   yHotspot;
+    HBITMAP hbmMask;
+    HBITMAP hbmColor;
+}
+alias ICONINFO* PICONINFO;
+
+struct NMHDR {
+    HWND hwndFrom;
+    UINT_PTR idFrom;
+    UINT code;
+}
+alias NMHDR* LPNMHDR;
+
+struct WNDCLASSA {
+    UINT      style;
+    WNDPROC   lpfnWndProc;
+    int       cbClsExtra;
+    int       cbWndExtra;
+    HINSTANCE hInstance;
+    HICON     hIcon;
+    HCURSOR   hCursor;
+    HBRUSH    hbrBackground;
+    LPCSTR    lpszMenuName;
+    LPCSTR    lpszClassName;
+}
+alias WNDCLASSA* NPWNDCLASSA, LPWNDCLASSA, PWNDCLASSA;
+
+struct WNDCLASSW {
+    UINT      style;
+    WNDPROC   lpfnWndProc;
+    int       cbClsExtra;
+    int       cbWndExtra;
+    HINSTANCE hInstance;
+    HICON     hIcon;
+    HCURSOR   hCursor;
+    HBRUSH    hbrBackground;
+    LPCWSTR   lpszMenuName;
+    LPCWSTR   lpszClassName;
+}
+alias WNDCLASSW* NPWNDCLASSW, LPWNDCLASSW, PWNDCLASSW;
+
+struct WNDCLASSEXA {
+    UINT      cbSize = WNDCLASSEXA.sizeof;
+    UINT      style;
+    WNDPROC   lpfnWndProc;
+    int       cbClsExtra;
+    int       cbWndExtra;
+    HINSTANCE hInstance;
+    HICON     hIcon;
+    HCURSOR   hCursor;
+    HBRUSH    hbrBackground;
+    LPCSTR    lpszMenuName;
+    LPCSTR    lpszClassName;
+    HICON     hIconSm;
+}
+alias WNDCLASSEXA* NPWNDCLASSEXA, LPWNDCLASSEXA, PWNDCLASSEXA;
+
+struct WNDCLASSEXW {
+    UINT      cbSize = WNDCLASSEXW.sizeof;
+    UINT      style;
+    WNDPROC   lpfnWndProc;
+    int       cbClsExtra;
+    int       cbWndExtra;
+    HINSTANCE hInstance;
+    HICON     hIcon;
+    HCURSOR   hCursor;
+    HBRUSH    hbrBackground;
+    LPCWSTR   lpszMenuName;
+    LPCWSTR   lpszClassName;
+    HICON     hIconSm;
+}
+alias WNDCLASSEXW* LPWNDCLASSEXW, PWNDCLASSEXW;
+
+struct MENUITEMINFOA {
+    UINT      cbSize = MENUITEMINFOA.sizeof;
+    UINT      fMask;
+    UINT      fType;
+    UINT      fState;
+    UINT      wID;
+    HMENU     hSubMenu;
+    HBITMAP   hbmpChecked;
+    HBITMAP   hbmpUnchecked;
+    ULONG_PTR dwItemData;
+    LPSTR     dwTypeData;
+    UINT      cch;
+    HBITMAP   hbmpItem;
+}
+alias MENUITEMINFOA*        LPMENUITEMINFOA;
+alias const(MENUITEMINFOA)* LPCMENUITEMINFOA;
+
+struct MENUITEMINFOW {
+    UINT      cbSize = MENUITEMINFOW.sizeof;
+    UINT      fMask;
+    UINT      fType;
+    UINT      fState;
+    UINT      wID;
+    HMENU     hSubMenu;
+    HBITMAP   hbmpChecked;
+    HBITMAP   hbmpUnchecked;
+    ULONG_PTR dwItemData;
+    LPWSTR    dwTypeData;
+    UINT      cch;
+    HBITMAP   hbmpItem;
+}
+alias MENUITEMINFOW*        LPMENUITEMINFOW;
+alias const(MENUITEMINFOW)* LPCMENUITEMINFOW;
+
+struct SCROLLINFO {
+    UINT cbSize = this.sizeof;
+    UINT fMask;
+    int nMin;
+    int nMax;
+    UINT nPage;
+    int nPos;
+    int nTrackPos;
+}
+alias SCROLLINFO*        LPSCROLLINFO;
+alias const(SCROLLINFO)* LPCSCROLLINFO;
+
+struct WINDOWPLACEMENT {
+    UINT length;
+    UINT flags;
+    UINT showCmd;
+    POINT ptMinPosition;
+    POINT ptMaxPosition;
+    RECT rcNormalPosition;
+}
+alias WINDOWPLACEMENT* LPWINDOWPLACEMENT, PWINDOWPLACEMENT;
+
+struct MENUITEMTEMPLATEHEADER {
+    WORD versionNumber;
+    WORD offset;
+}
+
+struct MENUITEMTEMPLATE {
+    WORD mtOption;
+    WORD mtID;
+    WCHAR[1] mtString;
+}
+
+alias void MENUTEMPLATE, MENUTEMPLATEA, MENUTEMPLATEW;
+
+alias MENUTEMPLATE* LPMENUTEMPLATEA, LPMENUTEMPLATEW, LPMENUTEMPLATE;
+
+struct HELPINFO {
+    UINT cbSize = this.sizeof;
+    int iContextType;
+    int iCtrlId;
+    HANDLE hItemHandle;
+    DWORD dwContextId;
+    POINT MousePos;
+}
+alias HELPINFO* LPHELPINFO;
+
+struct MSGBOXPARAMSA {
+    UINT cbSize = this.sizeof;
+    HWND hwndOwner;
+    HINSTANCE hInstance;
+    LPCSTR lpszText;
+    LPCSTR lpszCaption;
+    DWORD dwStyle;
+    LPCSTR lpszIcon;
+    DWORD dwContextHelpId;
+    MSGBOXCALLBACK lpfnMsgBoxCallback;
+    DWORD dwLanguageId;
+}
+alias MSGBOXPARAMSA* PMSGBOXPARAMSA, LPMSGBOXPARAMSA;
+
+struct MSGBOXPARAMSW {
+    UINT cbSize = this.sizeof;
+    HWND hwndOwner;
+    HINSTANCE hInstance;
+    LPCWSTR lpszText;
+    LPCWSTR lpszCaption;
+    DWORD dwStyle;
+    LPCWSTR lpszIcon;
+    DWORD dwContextHelpId;
+    MSGBOXCALLBACK lpfnMsgBoxCallback;
+    DWORD dwLanguageId;
+}
+alias MSGBOXPARAMSW* PMSGBOXPARAMSW, LPMSGBOXPARAMSW;
+
+struct USEROBJECTFLAGS {
+    BOOL fInherit;
+    BOOL fReserved;
+    DWORD dwFlags;
+}
+
+struct FILTERKEYS {
+    UINT cbSize = this.sizeof;
+    DWORD dwFlags;
+    DWORD iWaitMSec;
+    DWORD iDelayMSec;
+    DWORD iRepeatMSec;
+    DWORD iBounceMSec;
+}
+
+struct HIGHCONTRASTA {
+    UINT cbSize = this.sizeof;
+    DWORD dwFlags;
+    LPSTR lpszDefaultScheme;
+}
+alias HIGHCONTRASTA* LPHIGHCONTRASTA;
+
+struct HIGHCONTRASTW {
+    UINT cbSize = this.sizeof;
+    DWORD dwFlags;
+    LPWSTR lpszDefaultScheme;
+}
+alias HIGHCONTRASTW* LPHIGHCONTRASTW;
+
+struct ICONMETRICSA {
+    UINT cbSize = this.sizeof;
+    int iHorzSpacing;
+    int iVertSpacing;
+    int iTitleWrap;
+    LOGFONTA lfFont;
+}
+alias ICONMETRICSA* LPICONMETRICSA;
+
+struct ICONMETRICSW {
+    UINT cbSize = this.sizeof;
+    int iHorzSpacing;
+    int iVertSpacing;
+    int iTitleWrap;
+    LOGFONTW lfFont;
+}
+alias ICONMETRICSW* LPICONMETRICSW;
+
+struct MINIMIZEDMETRICS {
+    UINT cbSize = this.sizeof;
+    int iWidth;
+    int iHorzGap;
+    int iVertGap;
+    int iArrange;
+}
+alias MINIMIZEDMETRICS* LPMINIMIZEDMETRICS;
+
+struct MOUSEKEYS {
+    UINT cbSize = this.sizeof;
+    DWORD dwFlags;
+    DWORD iMaxSpeed;
+    DWORD iTimeToMaxSpeed;
+    DWORD iCtrlSpeed;
+    DWORD dwReserved1;
+    DWORD dwReserved2;
+}
+alias MOUSEKEYS* LPMOUSEKEYS;
+
+struct NONCLIENTMETRICSA {
+    UINT cbSize = this.sizeof;
+    int iBorderWidth;
+    int iScrollWidth;
+    int iScrollHeight;
+    int iCaptionWidth;
+    int iCaptionHeight;
+    LOGFONTA lfCaptionFont;
+    int iSmCaptionWidth;
+    int iSmCaptionHeight;
+    LOGFONTA lfSmCaptionFont;
+    int iMenuWidth;
+    int iMenuHeight;
+    LOGFONTA lfMenuFont;
+    LOGFONTA lfStatusFont;
+    LOGFONTA lfMessageFont;
+}
+alias NONCLIENTMETRICSA* LPNONCLIENTMETRICSA;
+
+struct NONCLIENTMETRICSW {
+    UINT cbSize = this.sizeof;
+    int iBorderWidth;
+    int iScrollWidth;
+    int iScrollHeight;
+    int iCaptionWidth;
+    int iCaptionHeight;
+    LOGFONTW lfCaptionFont;
+    int iSmCaptionWidth;
+    int iSmCaptionHeight;
+    LOGFONTW lfSmCaptionFont;
+    int iMenuWidth;
+    int iMenuHeight;
+    LOGFONTW lfMenuFont;
+    LOGFONTW lfStatusFont;
+    LOGFONTW lfMessageFont;
+}
+alias NONCLIENTMETRICSW* LPNONCLIENTMETRICSW;
+
+struct SERIALKEYSA {
+    UINT cbSize = this.sizeof;
+    DWORD dwFlags;
+    LPSTR lpszActivePort;
+    LPSTR lpszPort;
+    UINT iBaudRate;
+    UINT iPortState;
+    UINT iActive;
+}
+alias SERIALKEYSA* LPSERIALKEYSA;
+
+struct SERIALKEYSW {
+    UINT cbSize = this.sizeof;
+    DWORD dwFlags;
+    LPWSTR lpszActivePort;
+    LPWSTR lpszPort;
+    UINT iBaudRate;
+    UINT iPortState;
+    UINT iActive;
+}
+alias SERIALKEYSW* LPSERIALKEYSW;
+
+struct SOUNDSENTRYA {
+    UINT cbSize = this.sizeof;
+    DWORD dwFlags;
+    DWORD iFSTextEffect;
+    DWORD iFSTextEffectMSec;
+    DWORD iFSTextEffectColorBits;
+    DWORD iFSGrafEffect;
+    DWORD iFSGrafEffectMSec;
+    DWORD iFSGrafEffectColor;
+    DWORD iWindowsEffect;
+    DWORD iWindowsEffectMSec;
+    LPSTR lpszWindowsEffectDLL;
+    DWORD iWindowsEffectOrdinal;
+}
+alias SOUNDSENTRYA* LPSOUNDSENTRYA;
+
+struct SOUNDSENTRYW {
+    UINT cbSize = this.sizeof;
+    DWORD dwFlags;
+    DWORD iFSTextEffect;
+    DWORD iFSTextEffectMSec;
+    DWORD iFSTextEffectColorBits;
+    DWORD iFSGrafEffect;
+    DWORD iFSGrafEffectMSec;
+    DWORD iFSGrafEffectColor;
+    DWORD iWindowsEffect;
+    DWORD iWindowsEffectMSec;
+    LPWSTR lpszWindowsEffectDLL;
+    DWORD iWindowsEffectOrdinal;
+}
+alias SOUNDSENTRYW* LPSOUNDSENTRYW;
+
+struct STICKYKEYS {
+    DWORD cbSize = this.sizeof;
+    DWORD dwFlags;
+}
+alias STICKYKEYS* LPSTICKYKEYS;
+
+struct TOGGLEKEYS {
+    DWORD cbSize = this.sizeof;
+    DWORD dwFlags;
+}
+
+struct MOUSEHOOKSTRUCT {
+    POINT pt;
+    HWND hwnd;
+    UINT wHitTestCode;
+    DWORD dwExtraInfo;
+}
+alias MOUSEHOOKSTRUCT* LPMOUSEHOOKSTRUCT, PMOUSEHOOKSTRUCT;
+
+struct TRACKMOUSEEVENT {
+    DWORD cbSize = this.sizeof;
+    DWORD dwFlags;
+    HWND  hwndTrack;
+    DWORD dwHoverTime;
+}
+alias TRACKMOUSEEVENT* LPTRACKMOUSEEVENT;
+
+struct TPMPARAMS {
+    UINT cbSize = this.sizeof;
+    RECT rcExclude;
+}
+alias TPMPARAMS* LPTPMPARAMS;
+
+struct EVENTMSG {
+    UINT message;
+    UINT paramL;
+    UINT paramH;
+    DWORD time;
+    HWND hwnd;
+}
+alias EVENTMSG* PEVENTMSGMSG, LPEVENTMSGMSG, PEVENTMSG, LPEVENTMSG;
+
+struct WINDOWPOS {
+    HWND hwnd;
+    HWND hwndInsertAfter;
+    int x;
+    int y;
+    int cx;
+    int cy;
+    UINT flags;
+}
+alias WINDOWPOS* PWINDOWPOS, LPWINDOWPOS;
+
+struct NCCALCSIZE_PARAMS {
+    RECT[3] rgrc;
+    PWINDOWPOS lppos;
+}
+alias NCCALCSIZE_PARAMS* LPNCCALCSIZE_PARAMS;
+
+struct MDICREATESTRUCTA {
+    LPCSTR szClass;
+    LPCSTR szTitle;
+    HANDLE hOwner;
+    int x;
+    int y;
+    int cx;
+    int cy;
+    DWORD style;
+    LPARAM lParam;
+}
+alias MDICREATESTRUCTA* LPMDICREATESTRUCTA;
+
+struct MDICREATESTRUCTW {
+    LPCWSTR szClass;
+    LPCWSTR szTitle;
+    HANDLE hOwner;
+    int x;
+    int y;
+    int cx;
+    int cy;
+    DWORD style;
+    LPARAM lParam;
+}
+alias MDICREATESTRUCTW* LPMDICREATESTRUCTW;
+
+struct MINMAXINFO {
+    POINT ptReserved;
+    POINT ptMaxSize;
+    POINT ptMaxPosition;
+    POINT ptMinTrackSize;
+    POINT ptMaxTrackSize;
+}
+alias MINMAXINFO* PMINMAXINFO, LPMINMAXINFO;
+
+struct MDINEXTMENU {
+    HMENU hmenuIn;
+    HMENU hmenuNext;
+    HWND hwndNext;
+}
+alias MDINEXTMENU* PMDINEXTMENU, LPMDINEXTMENU;
+
+struct MEASUREITEMSTRUCT {
+    UINT CtlType;
+    UINT CtlID;
+    UINT itemID;
+    UINT itemWidth;
+    UINT itemHeight;
+    DWORD itemData;
+}
+alias MEASUREITEMSTRUCT* PMEASUREITEMSTRUCT, LPMEASUREITEMSTRUCT;
+
+struct DROPSTRUCT {
+    HWND hwndSource;
+    HWND hwndSink;
+    DWORD wFmt;
+    DWORD dwData;
+    POINT ptDrop;
+    DWORD dwControlData;
+}
+alias DROPSTRUCT* PDROPSTRUCT, LPDROPSTRUCT;
+
+alias DWORD HELPPOLY;
+
+struct MULTIKEYHELPA {
+    DWORD mkSize;
+    CHAR mkKeylist;
+    CHAR[1] szKeyphrase;
+}
+alias MULTIKEYHELPA* PMULTIKEYHELPA, LPMULTIKEYHELPA;
+
+struct MULTIKEYHELPW {
+    DWORD mkSize;
+    WCHAR mkKeylist;
+    WCHAR[1] szKeyphrase;
+}
+alias MULTIKEYHELPW* PMULTIKEYHELPW, LPMULTIKEYHELPW;
+
+struct HELPWININFOA {
+    int wStructSize;
+    int x;
+    int y;
+    int dx;
+    int dy;
+    int wMax;
+    CHAR[2] rgchMember;
+}
+alias HELPWININFOA* PHELPWININFOA, LPHELPWININFOA;
+
+struct HELPWININFOW {
+    int wStructSize;
+    int x;
+    int y;
+    int dx;
+    int dy;
+    int wMax;
+    WCHAR[2] rgchMember;
+}
+alias HELPWININFOW* PHELPWININFOW, LPHELPWININFOW;
+
+struct STYLESTRUCT {
+    DWORD styleOld;
+    DWORD styleNew;
+}
+alias STYLESTRUCT* LPSTYLESTRUCT;
+
+struct ALTTABINFO {
+    DWORD cbSize = this.sizeof;
+    int   cItems;
+    int   cColumns;
+    int   cRows;
+    int   iColFocus;
+    int   iRowFocus;
+    int   cxItem;
+    int   cyItem;
+    POINT ptStart;
+}
+alias ALTTABINFO* PALTTABINFO, LPALTTABINFO;
+
+struct COMBOBOXINFO {
+    DWORD cbSize = this.sizeof;
+    RECT rcItem;
+    RECT rcButton;
+    DWORD stateButton;
+    HWND hwndCombo;
+    HWND hwndItem;
+    HWND hwndList;
+}
+alias COMBOBOXINFO* PCOMBOBOXINFO, LPCOMBOBOXINFO;
+
+struct CURSORINFO {
+    DWORD cbSize = this.sizeof;
+    DWORD flags;
+    HCURSOR hCursor;
+    POINT ptScreenPos;
+}
+alias CURSORINFO* PCURSORINFO, LPCURSORINFO;
+
+struct MENUBARINFO {
+    DWORD cbSize = this.sizeof;
+    RECT  rcBar;
+    HMENU hMenu;
+    HWND  hwndMenu;
+    byte bf_; // Simulated bitfield
+//  BOOL  fBarFocused:1;
+//  BOOL  fFocused:1;
+    bool fBarFocused()       { return (bf_ & 1) == 1; }
+    bool fFocused()          { return (bf_ & 2) == 2; }
+    bool fBarFocused(bool b) { bf_ = cast(byte) ((bf_ & 0xFE) | b);           return b; }
+    bool fFocused(bool b)    { bf_ = cast(byte) (b ? (bf_ | 2) : bf_ & 0xFD); return b; }
+}
+alias MENUBARINFO* PMENUBARINFO;
+
+struct MENUINFO {
+    DWORD cbSize = this.sizeof;
+    DWORD fMask;
+    DWORD dwStyle;
+    UINT cyMax;
+    HBRUSH  hbrBack;
+    DWORD   dwContextHelpID;
+    ULONG_PTR dwMenuData;
+}
+alias MENUINFO*        LPMENUINFO;
+alias const(MENUINFO)* LPCMENUINFO;
+
+
+enum CCHILDREN_SCROLLBAR = 5;
+
+struct SCROLLBARINFO {
+    DWORD cbSize = this.sizeof;
+    RECT  rcScrollBar;
+    int   dxyLineButton;
+    int   xyThumbTop;
+    int   xyThumbBottom;
+    int   reserved;
+    DWORD[CCHILDREN_SCROLLBAR+1] rgstate;
+}
+alias SCROLLBARINFO* PSCROLLBARINFO, LPSCROLLBARINFO;
+
+enum CCHILDREN_TITLEBAR = 5;
+
+struct WINDOWINFO {
+    DWORD cbSize = WINDOWINFO.sizeof;
+    RECT  rcWindow;
+    RECT  rcClient;
+    DWORD dwStyle;
+    DWORD dwExStyle;
+    DWORD dwWindowStatus;
+    UINT  cxWindowBorders;
+    UINT  cyWindowBorders;
+    ATOM  atomWindowType;
+    WORD  wCreatorVersion;
+}
+alias WINDOWINFO* PWINDOWINFO, LPWINDOWINFO;
+
+struct LASTINPUTINFO {
+    UINT cbSize = this.sizeof;
+    DWORD dwTime;
+}
+alias LASTINPUTINFO* PLASTINPUTINFO;
+
+struct MONITORINFO {
+    DWORD cbSize = this.sizeof;
+    RECT rcMonitor;
+    RECT rcWork;
+    DWORD dwFlags;
+}
+alias MONITORINFO* LPMONITORINFO;
+
+enum CCHDEVICENAME = 32;
+
+struct MONITORINFOEXA {
+    DWORD cbSize = MONITORINFOEXA.sizeof;
+    RECT  rcMonitor;
+    RECT  rcWork;
+    DWORD dwFlags;
+    CHAR[CCHDEVICENAME] szDevice;
+}
+alias MONITORINFOEXA* LPMONITORINFOEXA;
+
+struct MONITORINFOEXW {
+    DWORD cbSize = MONITORINFOEXW.sizeof;
+    RECT  rcMonitor;
+    RECT  rcWork;
+    DWORD dwFlags;
+    WCHAR[CCHDEVICENAME] szDevice;
+}
+alias MONITORINFOEXW* LPMONITORINFOEXW;
+
+struct KBDLLHOOKSTRUCT {
+    DWORD vkCode;
+    DWORD scanCode;
+    DWORD flags;
+    DWORD time;
+    DWORD dwExtraInfo;
+}
+alias KBDLLHOOKSTRUCT* LPKBDLLHOOKSTRUCT, PKBDLLHOOKSTRUCT;
+
+struct MSLLHOOKSTRUCT {
+    POINT     pt;
+    DWORD     mouseData;
+    DWORD     flags;
+    DWORD     time;
+    ULONG_PTR dwExtraInfo;
+}
+alias MSLLHOOKSTRUCT* PMSLLHOOKSTRUCT;
+
+struct MOUSEINPUT {
+    LONG dx;
+    LONG dy;
+    DWORD mouseData;
+    DWORD dwFlags;
+    DWORD time;
+    ULONG_PTR dwExtraInfo;
+}
+alias MOUSEINPUT* PMOUSEINPUT;
+
+struct KEYBDINPUT {
+    WORD wVk;
+    WORD wScan;
+    DWORD dwFlags;
+    DWORD time;
+    ULONG_PTR dwExtraInfo;
+}
+alias KEYBDINPUT* PKEYBDINPUT;
+
+struct HARDWAREINPUT {
+    DWORD uMsg;
+    WORD wParamL;
+    WORD wParamH;
+}
+alias HARDWAREINPUT* PHARDWAREINPUT;
+
+struct INPUT {
+    DWORD type;
+    union {
+        MOUSEINPUT mi;
+        KEYBDINPUT ki;
+        HARDWAREINPUT hi;
+    }
+}
+alias INPUT* PINPUT, LPINPUT;
+
+static if (_WIN32_WINNT >= 0x501) {
+    struct BSMINFO {
+        UINT  cbSize = this.sizeof;
+        HDESK hdesk;
+        HWND  hwnd;
+        LUID  luid;
+    }
+    alias BSMINFO* PBSMINFO;
+
+    alias TypeDef!(HANDLE) HRAWINPUT;
+
+    struct RAWINPUTHEADER {
+        DWORD dwType;
+        DWORD dwSize;
+        HANDLE hDevice;
+        WPARAM wParam;
+    }
+    alias RAWINPUTHEADER* PRAWINPUTHEADER;
+
+    struct RAWMOUSE {
+        USHORT usFlags;
+        union {
+            ULONG ulButtons;
+            struct {
+                USHORT usButtonFlags;
+                USHORT usButtonData;
+            }
+        }
+        ULONG ulRawButtons;
+        LONG lLastX;
+        LONG lLastY;
+        ULONG ulExtraInformation;
+    }
+    alias RAWMOUSE* PRAWMOUSE, LPRAWMOUSE;
+
+    struct RAWKEYBOARD {
+        USHORT MakeCode;
+        USHORT Flags;
+        USHORT Reserved;
+        USHORT VKey;
+        UINT Message;
+        ULONG ExtraInformation;
+    }
+    alias RAWKEYBOARD* PRAWKEYBOARD, LPRAWKEYBOARD;
+
+    struct RAWHID {
+        DWORD dwSizeHid;
+        DWORD dwCount;
+        BYTE bRawData;
+    }
+    alias RAWHID* PRAWHID, LPRAWHID;
+
+    struct RAWINPUT {
+        RAWINPUTHEADER header;
+        union _data {
+            RAWMOUSE    mouse;
+            RAWKEYBOARD keyboard;
+            RAWHID      hid;
+        }
+        _data data;
+    }
+    alias RAWINPUT* PRAWINPUT, LPRAWINPUT;
+
+    struct RAWINPUTDEVICE {
+        USHORT usUsagePage;
+        USHORT usUsage;
+        DWORD dwFlags;
+        HWND hwndTarget;
+    }
+    alias RAWINPUTDEVICE*        PRAWINPUTDEVICE, LPRAWINPUTDEVICE;
+    alias const(RAWINPUTDEVICE)* PCRAWINPUTDEVICE;
+
+    struct RAWINPUTDEVICELIST {
+        HANDLE hDevice;
+        DWORD dwType;
+    }
+    alias RAWINPUTDEVICELIST* PRAWINPUTDEVICELIST;
+
+    struct RID_DEVICE_INFO_MOUSE {
+        DWORD dwId;
+        DWORD dwNumberOfButtons;
+        DWORD dwSampleRate;
+        BOOL  fHasHorizontalWheel;
+    }
+
+    struct RID_DEVICE_INFO_KEYBOARD {
+        DWORD dwType;
+        DWORD dwSubType;
+        DWORD dwKeyboardMode;
+        DWORD dwNumberOfFunctionKeys;
+        DWORD dwNumberOfIndicators;
+        DWORD dwNumberOfKeysTotal;
+    }
+
+    struct RID_DEVICE_INFO_HID {
+        DWORD dwVendorId;
+        DWORD dwProductId;
+        DWORD dwVersionNumber;
+        USHORT usUsagePage;
+        USHORT usUsage;
+    }
+
+    struct RID_DEVICE_INFO {
+        DWORD cbSize = this.sizeof;
+        DWORD dwType;
+        union {
+            RID_DEVICE_INFO_MOUSE mouse;
+            RID_DEVICE_INFO_KEYBOARD keyboard;
+            RID_DEVICE_INFO_HID hid;
+        }
+    }
+}// (_WIN32_WINNT >= 0x501)
+
+alias CharToOemA AnsiToOem;
+alias OemToCharA OemToAnsi;
+alias CharToOemBuffA AnsiToOemBuff;
+alias OemToCharBuffA OemToAnsiBuff;
+alias CharUpperA AnsiUpper;
+alias CharUpperBuffA AnsiUpperBuff;
+alias CharLowerA AnsiLower;
+alias CharLowerBuffA AnsiLowerBuff;
+alias CharNextA AnsiNext;
+alias CharPrevA AnsiPrev;
+
+alias MAKELONG MAKEWPARAM;
+alias MAKELONG MAKELPARAM;
+alias MAKELONG MAKELRESULT;
+
+void POINTSTOPOINT()(out POINT p, LONG ps) {
+    p.x = LOWORD(ps);
+    p.y = HIWORD(ps);
+}
+
+POINTS POINTTOPOINTS()(in POINT p) {
+    return MAKELONG(p.x, p.y);
+}
+
+extern (Windows) nothrow @nogc {
+    HKL ActivateKeyboardLayout(HKL, UINT);
+    BOOL AdjustWindowRect(LPRECT, DWORD, BOOL);
+    BOOL AdjustWindowRectEx(LPRECT, DWORD, BOOL, DWORD);
+    BOOL AnyPopup();
+    BOOL AppendMenuA(HMENU, UINT, UINT_PTR, LPCSTR);
+    BOOL AppendMenuW(HMENU, UINT, UINT_PTR, LPCWSTR);
+    UINT ArrangeIconicWindows(HWND);
+    BOOL AttachThreadInput(DWORD, DWORD, BOOL);
+    HDWP BeginDeferWindowPos(int);
+    HDC BeginPaint(HWND, LPPAINTSTRUCT);
+    BOOL BringWindowToTop(HWND);
+    BOOL CallMsgFilterA(LPMSG, INT);
+    BOOL CallMsgFilterW(LPMSG, INT);
+    LRESULT CallNextHookEx(HHOOK, int, WPARAM, LPARAM);
+    LRESULT CallWindowProcA(WNDPROC, HWND, UINT, WPARAM, LPARAM);
+    LRESULT CallWindowProcW(WNDPROC, HWND, UINT, WPARAM, LPARAM);
+    WORD CascadeWindows(HWND, UINT, LPCRECT, UINT, const(HWND)*);
+    BOOL ChangeClipboardChain(HWND, HWND);
+
+    LONG ChangeDisplaySettingsA(PDEVMODEA, DWORD);
+    LONG ChangeDisplaySettingsW(PDEVMODEW, DWORD);
+    LONG ChangeDisplaySettingsExA(LPCSTR, LPDEVMODEA, HWND, DWORD, LPVOID);
+    LONG ChangeDisplaySettingsExW(LPCWSTR, LPDEVMODEW, HWND, DWORD, LPVOID);
+
+    BOOL ChangeMenuA(HMENU, UINT, LPCSTR, UINT, UINT);
+    BOOL ChangeMenuW(HMENU, UINT, LPCWSTR, UINT, UINT);
+    LPSTR CharLowerA(LPSTR);
+    LPWSTR CharLowerW(LPWSTR);
+    DWORD CharLowerBuffA(LPSTR, DWORD);
+    DWORD CharLowerBuffW(LPWSTR, DWORD);
+    LPSTR CharNextA(LPCSTR);
+    LPWSTR CharNextW(LPCWSTR);
+    LPSTR CharNextExA(WORD, LPCSTR, DWORD);
+    LPWSTR CharNextExW(WORD, LPCWSTR, DWORD);
+    LPSTR CharPrevA(LPCSTR, LPCSTR);
+    LPWSTR CharPrevW(LPCWSTR, LPCWSTR);
+    LPSTR CharPrevExA(WORD, LPCSTR, LPCSTR, DWORD);
+    LPWSTR CharPrevExW(WORD, LPCWSTR, LPCWSTR, DWORD);
+    BOOL CharToOemA(LPCSTR, LPSTR);
+    BOOL CharToOemW(LPCWSTR, LPSTR);
+    BOOL CharToOemBuffA(LPCSTR, LPSTR, DWORD);
+    BOOL CharToOemBuffW(LPCWSTR, LPSTR, DWORD);
+    LPSTR CharUpperA(LPSTR);
+    LPWSTR CharUpperW(LPWSTR);
+    DWORD CharUpperBuffA(LPSTR, DWORD);
+    DWORD CharUpperBuffW(LPWSTR, DWORD);
+    BOOL CheckDlgButton(HWND, int, UINT);
+    DWORD CheckMenuItem(HMENU, UINT, UINT);
+    BOOL CheckMenuRadioItem(HMENU, UINT, UINT, UINT, UINT);
+    BOOL CheckRadioButton(HWND, int, int, int);
+    HWND ChildWindowFromPoint(HWND, POINT);
+    HWND ChildWindowFromPointEx(HWND, POINT, UINT);
+    BOOL ClientToScreen(HWND, LPPOINT);
+    BOOL ClipCursor(LPCRECT);
+    BOOL CloseClipboard();
+    BOOL CloseDesktop(HDESK);
+    BOOL CloseWindow(HWND);
+    BOOL CloseWindowStation(HWINSTA);
+    int CopyAcceleratorTableA(HACCEL, LPACCEL, int);
+    int CopyAcceleratorTableW(HACCEL, LPACCEL, int);
+
+    HICON CopyIcon(HICON);
+    HANDLE CopyImage(HANDLE, UINT, int, int, UINT);
+    BOOL CopyRect(LPRECT, LPCRECT);
+    int CountClipboardFormats();
+    HACCEL CreateAcceleratorTableA(LPACCEL, int);
+    HACCEL CreateAcceleratorTableW(LPACCEL, int);
+    BOOL CreateCaret(HWND, HBITMAP, int, int);
+    HCURSOR CreateCursor(HINSTANCE, int, int, int, int, PCVOID, PCVOID);
+
+    HDESK CreateDesktopA(LPCSTR, LPCSTR, LPDEVMODEA, DWORD, ACCESS_MASK, LPSECURITY_ATTRIBUTES);
+    HDESK CreateDesktopW(LPCWSTR, LPCWSTR, LPDEVMODEW, DWORD, ACCESS_MASK, LPSECURITY_ATTRIBUTES);
+
+    HWND CreateDialogParamA(HINSTANCE, LPCSTR, HWND, DLGPROC, LPARAM);
+    HWND CreateDialogParamW(HINSTANCE, LPCWSTR, HWND, DLGPROC, LPARAM);
+    HWND CreateDialogIndirectParamA(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC, LPARAM);
+    HWND CreateDialogIndirectParamW(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC, LPARAM);
+
+    HICON CreateIcon(HINSTANCE, int, int, BYTE, BYTE, const(BYTE)*, BYTE*);
+    HICON CreateIconFromResource(PBYTE, DWORD, BOOL, DWORD);
+    HICON CreateIconFromResourceEx(PBYTE, DWORD, BOOL, DWORD, int, int, UINT);
+    HICON CreateIconIndirect(PICONINFO);
+    HWND CreateMDIWindowA(LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HINSTANCE, LPARAM);
+    HWND CreateMDIWindowW(LPCWSTR, LPCWSTR, DWORD, int, int, int, int, HWND, HINSTANCE, LPARAM);
+    HMENU CreateMenu();
+    HMENU CreatePopupMenu();
+
+    HWND CreateWindowExA(DWORD, LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID);
+    HWND CreateWindowExW(DWORD, LPCWSTR, LPCWSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID);
+
+    HWINSTA CreateWindowStationA(LPSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
+    HWINSTA CreateWindowStationW(LPWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
+    LRESULT DefDlgProcA(HWND, UINT, WPARAM, LPARAM);
+    LRESULT DefDlgProcW(HWND, UINT, WPARAM, LPARAM);
+    HDWP DeferWindowPos(HDWP, HWND, HWND, int, int, int, int, UINT);
+    LRESULT DefFrameProcA(HWND, HWND, UINT, WPARAM, LPARAM);
+    LRESULT DefFrameProcW(HWND, HWND, UINT, WPARAM, LPARAM);
+
+    LRESULT DefMDIChildProcA(HWND, UINT, WPARAM, LPARAM);
+    LRESULT DefMDIChildProcW(HWND, UINT, WPARAM, LPARAM);
+    LRESULT DefWindowProcA(HWND, UINT, WPARAM, LPARAM);
+    LRESULT DefWindowProcW(HWND, UINT, WPARAM, LPARAM);
+    BOOL DeleteMenu(HMENU, UINT, UINT);
+    BOOL DeregisterShellHookWindow(HWND);
+    BOOL DestroyAcceleratorTable(HACCEL);
+    BOOL DestroyCaret();
+    BOOL DestroyCursor(HCURSOR);
+    BOOL DestroyIcon(HICON);
+    BOOL DestroyMenu(HMENU);
+    BOOL DestroyWindow(HWND);
+
+    INT_PTR DialogBoxParamA(HINSTANCE, LPCSTR, HWND, DLGPROC, LPARAM);
+    INT_PTR DialogBoxParamW(HINSTANCE, LPCWSTR, HWND, DLGPROC, LPARAM);
+    INT_PTR DialogBoxIndirectParamA(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC, LPARAM);
+    INT_PTR DialogBoxIndirectParamW(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC, LPARAM);
+
+} // extern (Windows)
+
+nothrow @nogc {
+    HCURSOR CopyCursor(HCURSOR c) {
+        return cast(HCURSOR)CopyIcon(cast(HICON)c);
+    }
+
+    HWND CreateDialogA(HINSTANCE h, LPCSTR n, HWND w, DLGPROC f) {
+        return CreateDialogParamA(h, n, w, f, 0);
+    }
+
+    HWND CreateDialogW(HINSTANCE h, LPCWSTR n, HWND w, DLGPROC f) {
+        return CreateDialogParamW(h, n, w, f, 0);
+    }
+
+    HWND CreateDialogIndirectA(HINSTANCE h, LPCDLGTEMPLATE t, HWND w, DLGPROC f) {
+        return CreateDialogIndirectParamA(h, t, w, f, 0);
+    }
+
+    HWND CreateDialogIndirectW(HINSTANCE h, LPCDLGTEMPLATE t, HWND w, DLGPROC f) {
+        return CreateDialogIndirectParamW(h, t, w, f, 0);
+    }
+
+    HWND CreateWindowA(LPCSTR a, LPCSTR b, DWORD c, int d, int e, int f, int g, HWND h, HMENU i, HINSTANCE j, LPVOID k) {
+        return CreateWindowExA(0, a, b, c, d, e, f, g, h, i, j, k);
+    }
+
+    HWND CreateWindowW(LPCWSTR a, LPCWSTR b, DWORD c, int d, int e, int f, int g, HWND h, HMENU i, HINSTANCE j, LPVOID k) {
+        return CreateWindowExW(0, a, b, c, d, e, f, g, h, i, j, k);
+    }
+
+    INT_PTR DialogBoxA(HINSTANCE i, LPCSTR t, HWND p, DLGPROC f) {
+        return DialogBoxParamA(i, t, p, f, 0);
+    }
+
+    INT_PTR DialogBoxW(HINSTANCE i, LPCWSTR t, HWND p, DLGPROC f) {
+        return DialogBoxParamW(i, t, p, f, 0);
+    }
+
+    INT_PTR DialogBoxIndirectA(HINSTANCE i, LPCDLGTEMPLATE t, HWND p, DLGPROC f) {
+        return DialogBoxIndirectParamA(i, t, p, f, 0);
+    }
+
+    INT_PTR DialogBoxIndirectW(HINSTANCE i, LPCDLGTEMPLATE t, HWND p, DLGPROC f) {
+        return DialogBoxIndirectParamW(i, t, p, f, 0);
+    }
+
+    BOOL ExitWindows(UINT r, DWORD c) {
+        return ExitWindowsEx(EWX_LOGOFF, 0);
+    }
+}
+alias GetWindow GetNextWindow;
+
+extern (Windows) nothrow @nogc:
+LONG DispatchMessageA(const(MSG)*);
+LONG DispatchMessageW(const(MSG)*);
+int DlgDirListA(HWND, LPSTR, int, int, UINT);
+int DlgDirListW(HWND, LPWSTR, int, int, UINT);
+int DlgDirListComboBoxA(HWND, LPSTR, int, int, UINT);
+int DlgDirListComboBoxW(HWND, LPWSTR, int, int, UINT);
+BOOL DlgDirSelectComboBoxExA(HWND, LPSTR, int, int);
+BOOL DlgDirSelectComboBoxExW(HWND, LPWSTR, int, int);
+BOOL DlgDirSelectExA(HWND, LPSTR, int, int);
+BOOL DlgDirSelectExW(HWND, LPWSTR, int, int);
+BOOL DragDetect(HWND, POINT);
+DWORD DragObject(HWND, HWND, UINT, DWORD, HCURSOR);
+BOOL DrawAnimatedRects(HWND, int, LPCRECT, LPCRECT);
+BOOL DrawCaption(HWND, HDC, LPCRECT, UINT);
+BOOL DrawEdge(HDC, LPRECT, UINT, UINT);
+BOOL DrawFocusRect(HDC, LPCRECT);
+BOOL DrawFrameControl(HDC, LPRECT, UINT, UINT);
+BOOL DrawIcon(HDC, int, int, HICON);
+BOOL DrawIconEx(HDC, int, int, HICON, int, int, UINT, HBRUSH, UINT);
+BOOL DrawMenuBar(HWND);
+BOOL DrawStateA(HDC, HBRUSH, DRAWSTATEPROC, LPARAM, WPARAM, int, int, int, int, UINT);
+BOOL DrawStateW(HDC, HBRUSH, DRAWSTATEPROC, LPARAM, WPARAM, int, int, int, int, UINT);
+int DrawTextA(HDC, LPCSTR, int, LPRECT, UINT);
+int DrawTextW(HDC, LPCWSTR, int, LPRECT, UINT);
+int DrawTextExA(HDC, LPSTR, int, LPRECT, UINT, LPDRAWTEXTPARAMS);
+int DrawTextExW(HDC, LPWSTR, int, LPRECT, UINT, LPDRAWTEXTPARAMS);
+BOOL EmptyClipboard();
+BOOL EnableMenuItem(HMENU, UINT, UINT);
+BOOL EnableScrollBar(HWND, UINT, UINT);
+BOOL EnableWindow(HWND, BOOL);
+BOOL EndDeferWindowPos(HDWP);
+BOOL EndDialog(HWND, INT_PTR);
+BOOL EndMenu();
+BOOL EndPaint(HWND, const(PAINTSTRUCT)*);
+BOOL EnumChildWindows(HWND, ENUMWINDOWSPROC, LPARAM);
+UINT EnumClipboardFormats(UINT);
+BOOL EnumDesktopsA(HWINSTA, DESKTOPENUMPROCA, LPARAM);
+BOOL EnumDesktopsW(HWINSTA, DESKTOPENUMPROCW, LPARAM);
+BOOL EnumDesktopWindows(HDESK, ENUMWINDOWSPROC, LPARAM);
+BOOL EnumDisplaySettingsA(LPCSTR, DWORD, PDEVMODEA);
+BOOL EnumDisplaySettingsW(LPCWSTR, DWORD, PDEVMODEW);
+
+BOOL EnumDisplayDevicesA(LPCSTR, DWORD, PDISPLAY_DEVICEA, DWORD);
+BOOL EnumDisplayDevicesW(LPCWSTR, DWORD, PDISPLAY_DEVICEW, DWORD);
+
+int EnumPropsA(HWND, PROPENUMPROCA);
+int EnumPropsW(HWND, PROPENUMPROCW);
+int EnumPropsExA(HWND, PROPENUMPROCEXA, LPARAM);
+int EnumPropsExW(HWND, PROPENUMPROCEXW, LPARAM);
+
+BOOL EnumThreadWindows(DWORD, WNDENUMPROC, LPARAM);
+BOOL EnumWindows(WNDENUMPROC, LPARAM);
+BOOL EnumWindowStationsA(WINSTAENUMPROCA, LPARAM);
+BOOL EnumWindowStationsW(WINSTAENUMPROCW, LPARAM);
+BOOL EqualRect(LPCRECT, LPCRECT);
+
+BOOL ExitWindowsEx(UINT, DWORD);
+HWND FindWindowA(LPCSTR, LPCSTR);
+HWND FindWindowExA(HWND, HWND, LPCSTR, LPCSTR);
+HWND FindWindowExW(HWND, HWND, LPCWSTR, LPCWSTR);
+HWND FindWindowW(LPCWSTR, LPCWSTR);
+BOOL FlashWindow(HWND, BOOL);
+
+int FrameRect(HDC, LPCRECT, HBRUSH);
+BOOL FrameRgn(HDC, HRGN, HBRUSH, int, int);
+HWND GetActiveWindow();
+HWND GetAncestor(HWND, UINT);
+SHORT GetAsyncKeyState(int);
+HWND GetCapture();
+UINT GetCaretBlinkTime();
+BOOL GetCaretPos(LPPOINT);
+BOOL GetClassInfoA(HINSTANCE, LPCSTR, LPWNDCLASSA);
+BOOL GetClassInfoExA(HINSTANCE, LPCSTR, LPWNDCLASSEXA);
+BOOL GetClassInfoW(HINSTANCE, LPCWSTR, LPWNDCLASSW);
+BOOL GetClassInfoExW(HINSTANCE, LPCWSTR, LPWNDCLASSEXW);
+DWORD GetClassLongA(HWND, int);
+DWORD GetClassLongW(HWND, int);
+int GetClassNameA(HWND, LPSTR, int);
+int GetClassNameW(HWND, LPWSTR, int);
+WORD GetClassWord(HWND, int);
+BOOL GetClientRect(HWND, LPRECT);
+HANDLE GetClipboardData(UINT);
+int GetClipboardFormatNameA(UINT, LPSTR, int);
+int GetClipboardFormatNameW(UINT, LPWSTR, int);
+HWND GetClipboardOwner();
+HWND GetClipboardViewer();
+BOOL GetClipCursor(LPRECT);
+BOOL GetCursorPos(LPPOINT);
+HDC GetDC(HWND);
+HDC GetDCEx(HWND, HRGN, DWORD);
+HWND GetDesktopWindow();
+int GetDialogBaseUnits();
+int GetDlgCtrlID(HWND);
+HWND GetDlgItem(HWND, int);
+UINT GetDlgItemInt(HWND, int, PBOOL, BOOL);
+UINT GetDlgItemTextA(HWND, int, LPSTR, int);
+UINT GetDlgItemTextW(HWND, int, LPWSTR, int);
+UINT GetDoubleClickTime();
+HWND GetFocus();
+HWND GetForegroundWindow();
+
+BOOL GetIconInfo(HICON, PICONINFO);
+BOOL GetInputState();
+UINT GetKBCodePage();
+HKL GetKeyboardLayout(DWORD);
+UINT GetKeyboardLayoutList(int, HKL*);
+BOOL GetKeyboardLayoutNameA(LPSTR);
+BOOL GetKeyboardLayoutNameW(LPWSTR);
+BOOL GetKeyboardState(PBYTE);
+int GetKeyboardType(int);
+int GetKeyNameTextA(LONG, LPSTR, int);
+int GetKeyNameTextW(LONG, LPWSTR, int);
+SHORT GetKeyState(int);
+HWND GetLastActivePopup(HWND);
+HMENU GetMenu(HWND);
+LONG GetMenuCheckMarkDimensions();
+DWORD GetMenuContextHelpId(HMENU);
+UINT GetMenuDefaultItem(HMENU, UINT, UINT);
+int GetMenuItemCount(HMENU);
+UINT GetMenuItemID(HMENU, int);
+BOOL GetMenuItemInfoA(HMENU, UINT, BOOL, LPMENUITEMINFOA);
+BOOL GetMenuItemInfoW(HMENU, UINT, BOOL, LPMENUITEMINFOW);
+BOOL GetMenuItemRect(HWND, HMENU, UINT, LPRECT);
+UINT GetMenuState(HMENU, UINT, UINT);
+int GetMenuStringA(HMENU, UINT, LPSTR, int, UINT);
+int GetMenuStringW(HMENU, UINT, LPWSTR, int, UINT);
+BOOL GetMessageA(LPMSG, HWND, UINT, UINT);
+BOOL GetMessageW(LPMSG, HWND, UINT, UINT);
+LONG GetMessageExtraInfo();
+DWORD GetMessagePos();
+LONG GetMessageTime();
+
+HWND GetNextDlgGroupItem(HWND, HWND, BOOL);
+HWND GetNextDlgTabItem(HWND, HWND, BOOL);
+
+HWND GetOpenClipboardWindow();
+HWND GetParent(HWND);
+int GetPriorityClipboardFormat(UINT*, int);
+HANDLE GetPropA(HWND, LPCSTR);
+HANDLE GetPropW(HWND, LPCWSTR);
+
+DWORD GetQueueStatus(UINT);
+BOOL GetScrollInfo(HWND, int, LPSCROLLINFO);
+int GetScrollPos(HWND, int);
+BOOL GetScrollRange(HWND, int, LPINT, LPINT);
+
+HMENU GetSubMenu(HMENU, int);
+DWORD GetSysColor(int);
+HBRUSH GetSysColorBrush(int);
+
+HMENU GetSystemMenu(HWND, BOOL);
+int GetSystemMetrics(int);
+DWORD GetTabbedTextExtentA(HDC, LPCSTR, int, int, LPINT);
+DWORD GetTabbedTextExtentW(HDC, LPCWSTR, int, int, LPINT);
+LONG GetWindowLongA(HWND, int);
+LONG GetWindowLongW(HWND, int);
+
+HDESK GetThreadDesktop(DWORD);
+HWND GetTopWindow(HWND);
+BOOL GetUpdateRect(HWND, LPRECT, BOOL);
+int GetUpdateRgn(HWND, HRGN, BOOL);
+BOOL GetUserObjectInformationA(HANDLE, int, PVOID, DWORD, PDWORD);
+BOOL GetUserObjectInformationW(HANDLE, int, PVOID, DWORD, PDWORD);
+BOOL GetUserObjectSecurity(HANDLE, PSECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, PDWORD);
+HWND GetWindow(HWND, UINT);
+DWORD GetWindowContextHelpId(HWND);
+HDC GetWindowDC(HWND);
+BOOL GetWindowPlacement(HWND, WINDOWPLACEMENT*);
+BOOL GetWindowRect(HWND, LPRECT);
+int GetWindowRgn(HWND, HRGN);
+int GetWindowTextA(HWND, LPSTR, int);
+int GetWindowTextLengthA(HWND);
+int GetWindowTextLengthW(HWND);
+int GetWindowTextW(HWND, LPWSTR, int);
+WORD GetWindowWord(HWND, int);
+BOOL GetAltTabInfoA(HWND, int, PALTTABINFO, LPSTR, UINT);
+BOOL GetAltTabInfoW(HWND, int, PALTTABINFO, LPWSTR, UINT);
+BOOL GetComboBoxInfo(HWND, PCOMBOBOXINFO);
+BOOL GetCursorInfo(PCURSORINFO);
+BOOL GetLastInputInfo(PLASTINPUTINFO);
+DWORD GetListBoxInfo(HWND);
+BOOL GetMenuBarInfo(HWND, LONG, LONG, PMENUBARINFO);
+BOOL GetMenuInfo(HMENU, LPMENUINFO);
+BOOL GetScrollBarInfo(HWND, LONG, PSCROLLBARINFO);
+BOOL GetTitleBarInfo(HWND, PTITLEBARINFO);
+BOOL GetWindowInfo(HWND, PWINDOWINFO);
+UINT GetWindowModuleFileNameA(HWND, LPSTR, UINT);
+UINT GetWindowModuleFileNameW(HWND, LPWSTR, UINT);
+BOOL GrayStringA(HDC, HBRUSH, GRAYSTRINGPROC, LPARAM, int, int, int, int, int);
+BOOL GrayStringW(HDC, HBRUSH, GRAYSTRINGPROC, LPARAM, int, int, int, int, int);
+BOOL HideCaret(HWND);
+BOOL HiliteMenuItem(HWND, HMENU, UINT, UINT);
+BOOL InflateRect(LPRECT, int, int);
+BOOL InSendMessage();
+BOOL InsertMenuA(HMENU, UINT, UINT, UINT_PTR, LPCSTR);
+BOOL InsertMenuW(HMENU, UINT, UINT, UINT_PTR, LPCWSTR);
+BOOL InsertMenuItemA(HMENU, UINT, BOOL, LPCMENUITEMINFOA);
+BOOL InsertMenuItemW(HMENU, UINT, BOOL, LPCMENUITEMINFOW);
+INT InternalGetWindowText(HWND, LPWSTR, INT);
+BOOL IntersectRect(LPRECT, LPCRECT, LPCRECT);
+BOOL InvalidateRect(HWND, LPCRECT, BOOL);
+BOOL InvalidateRgn(HWND, HRGN, BOOL);
+BOOL InvertRect(HDC, LPCRECT);
+BOOL IsCharAlphaA(CHAR ch);
+BOOL IsCharAlphaNumericA(CHAR);
+BOOL IsCharAlphaNumericW(WCHAR);
+BOOL IsCharAlphaW(WCHAR);
+BOOL IsCharLowerA(CHAR);
+BOOL IsCharLowerW(WCHAR);
+BOOL IsCharUpperA(CHAR);
+BOOL IsCharUpperW(WCHAR);
+BOOL IsChild(HWND, HWND);
+BOOL IsClipboardFormatAvailable(UINT);
+BOOL IsDialogMessageA(HWND, LPMSG);
+BOOL IsDialogMessageW(HWND, LPMSG);
+UINT IsDlgButtonChecked(HWND, int);
+BOOL IsIconic(HWND);
+BOOL IsMenu(HMENU);
+BOOL IsRectEmpty(LPCRECT);
+BOOL IsWindow(HWND);
+BOOL IsWindowEnabled(HWND);
+BOOL IsWindowUnicode(HWND);
+BOOL IsWindowVisible(HWND);
+BOOL IsZoomed(HWND);
+void keybd_event(BYTE, BYTE, DWORD, DWORD);
+BOOL KillTimer(HWND, UINT_PTR);
+HACCEL LoadAcceleratorsA(HINSTANCE, LPCSTR);
+HACCEL LoadAcceleratorsW(HINSTANCE, LPCWSTR);
+HBITMAP LoadBitmapA(HINSTANCE, LPCSTR);
+HBITMAP LoadBitmapW(HINSTANCE, LPCWSTR);
+HCURSOR LoadCursorA(HINSTANCE, LPCSTR);
+HCURSOR LoadCursorFromFileA(LPCSTR);
+HCURSOR LoadCursorFromFileW(LPCWSTR);
+HCURSOR LoadCursorW(HINSTANCE, LPCWSTR);
+HICON LoadIconA(HINSTANCE, LPCSTR);
+HICON LoadIconW(HINSTANCE, LPCWSTR);
+HANDLE LoadImageA(HINSTANCE, LPCSTR, UINT, int, int, UINT);
+HANDLE LoadImageW(HINSTANCE, LPCWSTR, UINT, int, int, UINT);
+HKL LoadKeyboardLayoutA(LPCSTR, UINT);
+HKL LoadKeyboardLayoutW(LPCWSTR, UINT);
+HMENU LoadMenuA(HINSTANCE, LPCSTR);
+HMENU LoadMenuIndirectA(const(MENUTEMPLATE)*);
+HMENU LoadMenuIndirectW(const(MENUTEMPLATE)*);
+HMENU LoadMenuW(HINSTANCE, LPCWSTR);
+int LoadStringA(HINSTANCE, UINT, LPSTR, int);
+int LoadStringW(HINSTANCE, UINT, LPWSTR, int);
+BOOL LockWindowUpdate(HWND);
+int LookupIconIdFromDirectory(PBYTE, BOOL);
+int LookupIconIdFromDirectoryEx(PBYTE, BOOL, int, int, UINT);
+BOOL MapDialogRect(HWND, LPRECT);
+UINT MapVirtualKeyA(UINT, UINT);
+UINT MapVirtualKeyExA(UINT, UINT, HKL);
+UINT MapVirtualKeyExW(UINT, UINT, HKL);
+UINT MapVirtualKeyW(UINT, UINT);
+int MapWindowPoints(HWND, HWND, LPPOINT, UINT);
+int MenuItemFromPoint(HWND, HMENU, POINT);
+BOOL MessageBeep(UINT);
+int MessageBoxA(HWND, LPCSTR, LPCSTR, UINT);
+int MessageBoxW(HWND, LPCWSTR, LPCWSTR, UINT);
+int MessageBoxExA(HWND, LPCSTR, LPCSTR, UINT, WORD);
+int MessageBoxExW(HWND, LPCWSTR, LPCWSTR, UINT, WORD);
+int MessageBoxIndirectA(const(MSGBOXPARAMSA)*);
+int MessageBoxIndirectW(const(MSGBOXPARAMSW)*);
+BOOL ModifyMenuA(HMENU, UINT, UINT, UINT_PTR, LPCSTR);
+BOOL ModifyMenuW(HMENU, UINT, UINT, UINT_PTR, LPCWSTR);
+void mouse_event(DWORD, DWORD, DWORD, DWORD, ULONG_PTR);
+BOOL MoveWindow(HWND, int, int, int, int, BOOL);
+DWORD MsgWaitForMultipleObjects(DWORD, const(HANDLE)*, BOOL, DWORD, DWORD);
+DWORD MsgWaitForMultipleObjectsEx(DWORD, const(HANDLE)*, DWORD, DWORD, DWORD);
+DWORD OemKeyScan(WORD);
+BOOL OemToCharA(LPCSTR, LPSTR);
+BOOL OemToCharBuffA(LPCSTR, LPSTR, DWORD);
+BOOL OemToCharBuffW(LPCSTR, LPWSTR, DWORD);
+BOOL OemToCharW(LPCSTR, LPWSTR);
+BOOL OffsetRect(LPRECT, int, int);
+BOOL OpenClipboard(HWND);
+HDESK OpenDesktopA(LPSTR, DWORD, BOOL, DWORD);
+HDESK OpenDesktopW(LPWSTR, DWORD, BOOL, DWORD);
+BOOL OpenIcon(HWND);
+HDESK OpenInputDesktop(DWORD, BOOL, DWORD);
+HWINSTA OpenWindowStationA(LPSTR, BOOL, DWORD);
+HWINSTA OpenWindowStationW(LPWSTR, BOOL, DWORD);
+BOOL PaintDesktop(HDC);
+BOOL PeekMessageA(LPMSG, HWND, UINT, UINT, UINT);
+BOOL PeekMessageW(LPMSG, HWND, UINT, UINT, UINT);
+BOOL PostMessageA(HWND, UINT, WPARAM, LPARAM);
+BOOL PostMessageW(HWND, UINT, WPARAM, LPARAM);
+void PostQuitMessage(int);
+BOOL PostThreadMessageA(DWORD, UINT, WPARAM, LPARAM);
+BOOL PostThreadMessageW(DWORD, UINT, WPARAM, LPARAM);
+BOOL PtInRect(LPCRECT, POINT);
+HWND RealChildWindowFromPoint(HWND, POINT);
+UINT RealGetWindowClassA(HWND, LPSTR, UINT);
+UINT RealGetWindowClassW(HWND, LPWSTR, UINT);
+BOOL RedrawWindow(HWND, LPCRECT, HRGN, UINT);
+ATOM RegisterClassA(const(WNDCLASSA)*);
+ATOM RegisterClassW(const(WNDCLASSW)*);
+ATOM RegisterClassExA(const(WNDCLASSEXA)*);
+ATOM RegisterClassExW(const(WNDCLASSEXW)*);
+UINT RegisterClipboardFormatA(LPCSTR);
+UINT RegisterClipboardFormatW(LPCWSTR);
+BOOL RegisterHotKey(HWND, int, UINT, UINT);
+UINT RegisterWindowMessageA(LPCSTR);
+UINT RegisterWindowMessageW(LPCWSTR);
+BOOL ReleaseCapture();
+int ReleaseDC(HWND, HDC);
+BOOL RemoveMenu(HMENU, UINT, UINT);
+HANDLE RemovePropA(HWND, LPCSTR);
+HANDLE RemovePropW(HWND, LPCWSTR);
+BOOL ReplyMessage(LRESULT);
+BOOL ScreenToClient(HWND, LPPOINT);
+BOOL ScrollDC(HDC, int, int, LPCRECT, LPCRECT, HRGN, LPRECT);
+BOOL ScrollWindow(HWND, int, int, LPCRECT, LPCRECT);
+int ScrollWindowEx(HWND, int, int, LPCRECT, LPCRECT, HRGN, LPRECT, UINT);
+LONG SendDlgItemMessageA(HWND, int, UINT, WPARAM, LPARAM);
+LONG SendDlgItemMessageW(HWND, int, UINT, WPARAM, LPARAM);
+LRESULT SendMessageA(HWND, UINT, WPARAM, LPARAM);
+BOOL SendMessageCallbackA(HWND, UINT, WPARAM, LPARAM, SENDASYNCPROC, DWORD);
+BOOL SendMessageCallbackW(HWND, UINT, WPARAM, LPARAM, SENDASYNCPROC, DWORD);
+LRESULT SendMessageTimeoutA(HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD);
+LRESULT SendMessageTimeoutW(HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD);
+LRESULT SendMessageW(HWND, UINT, WPARAM, LPARAM);
+BOOL SendNotifyMessageA(HWND, UINT, WPARAM, LPARAM);
+BOOL SendNotifyMessageW(HWND, UINT, WPARAM, LPARAM);
+HWND SetActiveWindow(HWND);
+HWND SetCapture(HWND hWnd);
+BOOL SetCaretBlinkTime(UINT);
+BOOL SetCaretPos(int, int);
+DWORD SetClassLongA(HWND, int, LONG);
+DWORD SetClassLongW(HWND, int, LONG);
+WORD SetClassWord(HWND, int, WORD);
+HANDLE SetClipboardData(UINT, HANDLE);
+HWND SetClipboardViewer(HWND);
+HCURSOR SetCursor(HCURSOR);
+BOOL SetCursorPos(int, int);
+void SetDebugErrorLevel(DWORD);
+BOOL SetDlgItemInt(HWND, int, UINT, BOOL);
+BOOL SetDlgItemTextA(HWND, int, LPCSTR);
+BOOL SetDlgItemTextW(HWND, int, LPCWSTR);
+BOOL SetDoubleClickTime(UINT);
+HWND SetFocus(HWND);
+BOOL SetForegroundWindow(HWND);
+BOOL SetKeyboardState(PBYTE);
+BOOL SetMenu(HWND, HMENU);
+BOOL SetMenuContextHelpId(HMENU, DWORD);
+BOOL SetMenuDefaultItem(HMENU, UINT, UINT);
+BOOL SetMenuInfo(HMENU, LPCMENUINFO);
+BOOL SetMenuItemBitmaps(HMENU, UINT, UINT, HBITMAP, HBITMAP);
+BOOL SetMenuItemInfoA(HMENU, UINT, BOOL, LPCMENUITEMINFOA);
+BOOL SetMenuItemInfoW(HMENU, UINT, BOOL, LPCMENUITEMINFOW);
+LPARAM SetMessageExtraInfo(LPARAM);
+BOOL SetMessageQueue(int);
+HWND SetParent(HWND, HWND);
+BOOL SetProcessWindowStation(HWINSTA);
+BOOL SetPropA(HWND, LPCSTR, HANDLE);
+BOOL SetPropW(HWND, LPCWSTR, HANDLE);
+BOOL SetRect(LPRECT, int, int, int, int);
+BOOL SetRectEmpty(LPRECT);
+int SetScrollInfo(HWND, int, LPCSCROLLINFO, BOOL);
+int SetScrollPos(HWND, int, int, BOOL);
+BOOL SetScrollRange(HWND, int, int, int, BOOL);
+BOOL SetSysColors(int, const(INT)*, const(COLORREF)*);
+BOOL SetSystemCursor(HCURSOR, DWORD);
+BOOL SetThreadDesktop(HDESK);
+UINT_PTR SetTimer(HWND, UINT_PTR, UINT, TIMERPROC);
+BOOL SetUserObjectInformationA(HANDLE, int, PVOID, DWORD);
+BOOL SetUserObjectInformationW(HANDLE, int, PVOID, DWORD);
+BOOL SetUserObjectSecurity(HANDLE, PSECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
+BOOL SetWindowContextHelpId(HWND, DWORD);
+LONG SetWindowLongA(HWND, int, LONG);
+LONG SetWindowLongW(HWND, int, LONG);
+BOOL SetWindowPlacement(HWND hWnd, const(WINDOWPLACEMENT)*);
+BOOL SetWindowPos(HWND, HWND, int, int, int, int, UINT);
+int SetWindowRgn(HWND, HRGN, BOOL);
+HHOOK SetWindowsHookA(int, HOOKPROC);
+HHOOK SetWindowsHookW(int, HOOKPROC);
+HHOOK SetWindowsHookExA(int, HOOKPROC, HINSTANCE, DWORD);
+HHOOK SetWindowsHookExW(int, HOOKPROC, HINSTANCE, DWORD);
+BOOL SetWindowTextA(HWND, LPCSTR);
+BOOL SetWindowTextW(HWND, LPCWSTR);
+WORD SetWindowWord(HWND, int, WORD);
+BOOL ShowCaret(HWND);
+int ShowCursor(BOOL);
+BOOL ShowOwnedPopups(HWND, BOOL);
+BOOL ShowScrollBar(HWND, int, BOOL);
+BOOL ShowWindow(HWND, int);
+BOOL ShowWindowAsync(HWND, int);
+BOOL SubtractRect(LPRECT, LPCRECT, LPCRECT);
+BOOL SwapMouseButton(BOOL);
+BOOL SwitchDesktop(HDESK);
+BOOL SystemParametersInfoA(UINT, UINT, PVOID, UINT);
+BOOL SystemParametersInfoW(UINT, UINT, PVOID, UINT);
+LONG TabbedTextOutA(HDC, int, int, LPCSTR, int, int, LPINT, int);
+LONG TabbedTextOutW(HDC, int, int, LPCWSTR, int, int, LPINT, int);
+WORD TileWindows(HWND, UINT, LPCRECT, UINT, const(HWND)*);
+int ToAscii(UINT, UINT, PBYTE, LPWORD, UINT);
+int ToAsciiEx(UINT, UINT, PBYTE, LPWORD, UINT, HKL);
+int ToUnicode(UINT, UINT, PBYTE, LPWSTR, int, UINT);
+int ToUnicodeEx(UINT, UINT, PBYTE, LPWSTR, int, UINT, HKL);
+BOOL TrackMouseEvent(LPTRACKMOUSEEVENT);
+BOOL TrackPopupMenu(HMENU, UINT, int, int, int, HWND, LPCRECT);
+BOOL TrackPopupMenuEx(HMENU, UINT, int, int, HWND, LPTPMPARAMS);
+int TranslateAcceleratorA(HWND, HACCEL, LPMSG);
+int TranslateAcceleratorW(HWND, HACCEL, LPMSG);
+BOOL TranslateMDISysAccel(HWND, LPMSG);
+BOOL TranslateMessage(const(MSG)*);
+BOOL UnhookWindowsHook(int, HOOKPROC);
+BOOL UnhookWindowsHookEx(HHOOK);
+BOOL UnionRect(LPRECT, LPCRECT, LPCRECT);
+BOOL UnloadKeyboardLayout(HKL);
+BOOL UnregisterClassA(LPCSTR, HINSTANCE);
+BOOL UnregisterClassW(LPCWSTR, HINSTANCE);
+BOOL UnregisterHotKey(HWND, int);
+BOOL UpdateWindow(HWND);
+BOOL ValidateRect(HWND, LPCRECT);
+BOOL ValidateRgn(HWND, HRGN);
+SHORT VkKeyScanA(CHAR);
+SHORT VkKeyScanExA(CHAR, HKL);
+SHORT VkKeyScanExW(WCHAR, HKL);
+SHORT VkKeyScanW(WCHAR);
+DWORD WaitForInputIdle(HANDLE, DWORD);
+BOOL WaitMessage();
+HWND WindowFromDC(HDC hDC);
+HWND WindowFromPoint(POINT);
+UINT WinExec(LPCSTR, UINT);
+BOOL WinHelpA(HWND, LPCSTR, UINT, DWORD);
+BOOL WinHelpW(HWND, LPCWSTR, UINT, DWORD);
+
+extern (C) {
+    int wsprintfA(LPSTR, LPCSTR, ...);
+    int wsprintfW(LPWSTR, LPCWSTR, ...);
+}
+
+
+// These shouldn't be necessary for D.
+alias TypeDef!(char*) va_list_;
+int wvsprintfA(LPSTR, LPCSTR, va_list_ arglist);
+int wvsprintfW(LPWSTR, LPCWSTR, va_list_ arglist);
+
+enum : DWORD {
+    MONITOR_DEFAULTTONULL,
+    MONITOR_DEFAULTTOPRIMARY,
+    MONITOR_DEFAULTTONEAREST // = 2
+}
+enum MONITORINFOF_PRIMARY = 1;
+
+enum EDS_RAWMODE = 0x00000002;
+
+enum {
+    ISMEX_NOSEND   = 0,
+    ISMEX_SEND     = 1,
+    ISMEX_NOTIFY   = 2,
+    ISMEX_CALLBACK = 4,
+    ISMEX_REPLIED  = 8
+}
+
+struct TITLEBARINFO {
+    DWORD cbSize = TITLEBARINFO.sizeof;
+    RECT  rcTitleBar;
+    DWORD[CCHILDREN_TITLEBAR+1] rgstate;
+}
+alias TITLEBARINFO* PTITLEBARINFO, LPTITLEBARINFO;
+
+static if (_WIN32_WINNT >= 0x501) { // *** correct?
+    struct FLASHWINFO {
+        UINT  cbSize = this.sizeof;
+        HWND  hwnd;
+        DWORD dwFlags;
+        UINT  uCount;
+        DWORD dwTimeout;
+    }
+    alias FLASHWINFO* PFLASHWINFO;
+}
+
+enum DWORD ASFW_ANY = -1;
+enum : UINT {
+    LSFW_LOCK = 1,
+    LSFW_UNLOCK
+}
+enum {
+    GMMP_USE_DISPLAY_POINTS = 1,
+    GMMP_USE_HIGH_RESOLUTION_POINTS
+}
+
+struct MOUSEMOVEPOINT {
+    int x;
+    int y;
+    DWORD time;
+    ULONG_PTR dwExtraInfo;
+}
+alias MOUSEMOVEPOINT* PMOUSEMOVEPOINT, LPMOUSEMOVEPOINT;
+
+enum {
+    MIM_MAXHEIGHT       =  1,
+    MIM_BACKGROUND      =  2,
+    MIM_HELPID          =  4,
+    MIM_MENUDATA        =  8,
+    MIM_STYLE           = 16,
+    MIM_APPLYTOSUBMENUS = 0x80000000L
+}
+
+enum {
+    MNS_NOCHECK     = 0x80000000,
+    MNS_MODELESS    = 0x40000000,
+    MNS_DRAGDROP    = 0x20000000,
+    MNS_AUTODISMISS = 0x10000000,
+    MNS_NOTIFYBYPOS = 0x08000000,
+    MNS_CHECKORBMP  = 0x04000000
+}
+
+enum {
+    PM_QS_INPUT       = (QS_INPUT << 16),
+    PM_QS_POSTMESSAGE = ((QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER) << 16),
+    PM_QS_PAINT       = (QS_PAINT << 16),
+    PM_QS_SENDMESSAGE = (QS_SENDMESSAGE << 16)
+}
+/*
+#define WM_GETOBJECT 0x003D
+#define WM_CHANGEUISTATE 0x0127
+#define WM_UPDATEUISTATE 0x0128
+#define WM_QUERYUISTATE 0x0129
+#define WM_UNINITMENUPOPUP 0x0125
+#define WM_MENURBUTTONUP 290
+#define WM_MENUCOMMAND 0x0126
+#define WM_MENUGETOBJECT 0x0124
+#define WM_MENUDRAG 0x0123
+#define WM_APPCOMMAND 0x0319
+#define WM_NCXBUTTONDOWN 171
+#define WM_NCXBUTTONUP 172
+#define WM_NCXBUTTONDBLCLK 173
+#define WM_NCMOUSEHOVER 0x02A0
+#define WM_NCMOUSELEAVE 0x02A2*/
+
+enum {
+    FLASHW_STOP      = 0,
+    FLASHW_CAPTION   = 0x01,
+    FLASHW_TRAY      = 0x02,
+    FLASHW_ALL       = 0x03,
+    FLASHW_TIMER     = 0x04,
+    FLASHW_TIMERNOFG = 0x0C
+}
+
+enum CHILDID_SELF = 0;
+
+enum {
+    OBJID_WINDOW   = 0x00000000,
+    OBJID_SOUND    = 0xFFFFFFF5,
+    OBJID_ALERT    = 0xFFFFFFF6,
+    OBJID_CURSOR   = 0xFFFFFFF7,
+    OBJID_CARET    = 0xFFFFFFF8,
+    OBJID_SIZEGRIP = 0xFFFFFFF9,
+    OBJID_HSCROLL  = 0xFFFFFFFA,
+    OBJID_VSCROLL  = 0xFFFFFFFB,
+    OBJID_CLIENT   = 0xFFFFFFFC,
+    OBJID_MENU     = 0xFFFFFFFD,
+    OBJID_TITLEBAR = 0xFFFFFFFE,
+    OBJID_SYSMENU  = 0xFFFFFFFF
+}
+
+enum {
+    GUI_CARETBLINKING  = 0x0001,
+    GUI_INMOVESIZE     = 0x0002,
+    GUI_INMENUMODE     = 0x0004,
+    GUI_SYSTEMMENUMODE = 0x0008,
+    GUI_POPUPMENUMODE  = 0x0010
+}
+static if (_WIN32_WINNT >= 0x501) {
+    enum GUI_16BITTASK = 0x0020;
+}
+
+enum {
+    WINEVENT_OUTOFCONTEXT   = 0x00,
+    WINEVENT_SKIPOWNTHREAD  = 0x01,
+    WINEVENT_SKIPOWNPROCESS = 0x02,
+    WINEVENT_INCONTEXT      = 0x04
+}
+
+enum {
+    AW_HOR_POSITIVE = 0x00000001,
+    AW_HOR_NEGATIVE = 0x00000002,
+    AW_VER_POSITIVE = 0x00000004,
+    AW_VER_NEGATIVE = 0x00000008,
+    AW_CENTER       = 0x00000010,
+    AW_HIDE         = 0x00010000,
+    AW_ACTIVATE     = 0x00020000,
+    AW_SLIDE        = 0x00040000,
+    AW_BLEND        = 0x00080000
+}
+
+enum {
+    DEVICE_NOTIFY_WINDOW_HANDLE  = 0x00000000,
+    DEVICE_NOTIFY_SERVICE_HANDLE = 0x00000001
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum DEVICE_NOTIFY_ALL_INTERFACE_CLASSES = 0x00000004;
+}
+
+enum : DWORD {
+    EVENT_MIN                          = 0x00000001,
+    EVENT_SYSTEM_SOUND                 = 0x00000001,
+    EVENT_SYSTEM_ALERT,
+    EVENT_SYSTEM_FOREGROUND,
+    EVENT_SYSTEM_MENUSTART,
+    EVENT_SYSTEM_MENUEND,
+    EVENT_SYSTEM_MENUPOPUPSTART,
+    EVENT_SYSTEM_MENUPOPUPEND,
+    EVENT_SYSTEM_CAPTURESTART,
+    EVENT_SYSTEM_CAPTUREEND,
+    EVENT_SYSTEM_MOVESIZESTART,
+    EVENT_SYSTEM_MOVESIZEEND,
+    EVENT_SYSTEM_CONTEXTHELPSTART,
+    EVENT_SYSTEM_CONTEXTHELPEND,
+    EVENT_SYSTEM_DRAGDROPSTART,
+    EVENT_SYSTEM_DRAGDROPEND,
+    EVENT_SYSTEM_DIALOGSTART,
+    EVENT_SYSTEM_DIALOGEND,
+    EVENT_SYSTEM_SCROLLINGSTART,
+    EVENT_SYSTEM_SCROLLINGEND,
+    EVENT_SYSTEM_SWITCHSTART,
+    EVENT_SYSTEM_SWITCHEND,
+    EVENT_SYSTEM_MINIMIZESTART,
+    EVENT_SYSTEM_MINIMIZEEND,       // = 0x00000017
+    EVENT_OBJECT_CREATE                = 0x00008000,
+    EVENT_OBJECT_DESTROY,
+    EVENT_OBJECT_SHOW,
+    EVENT_OBJECT_HIDE,
+    EVENT_OBJECT_REORDER,
+    EVENT_OBJECT_FOCUS,
+    EVENT_OBJECT_SELECTION,
+    EVENT_OBJECT_SELECTIONADD,
+    EVENT_OBJECT_SELECTIONREMOVE,
+    EVENT_OBJECT_SELECTIONWITHIN,
+    EVENT_OBJECT_STATECHANGE,
+    EVENT_OBJECT_LOCATIONCHANGE,
+    EVENT_OBJECT_NAMECHANGE,
+    EVENT_OBJECT_DESCRIPTIONCHANGE,
+    EVENT_OBJECT_VALUECHANGE,
+    EVENT_OBJECT_PARENTCHANGE,
+    EVENT_OBJECT_HELPCHANGE,
+    EVENT_OBJECT_DEFACTIONCHANGE,
+    EVENT_OBJECT_ACCELERATORCHANGE, // = 0x00008012
+    EVENT_MAX                          = 0x7FFFFFFF
+}
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum : DWORD {
+        EVENT_CONSOLE_CARET                = 0x00004000,
+        EVENT_CONSOLE_UPDATE_REGION,
+        EVENT_CONSOLE_UPDATE_SIMPLE,
+        EVENT_CONSOLE_UPDATE_SCROLL,
+        EVENT_CONSOLE_LAYOUT,
+        EVENT_CONSOLE_START_APPLICATION,
+        EVENT_CONSOLE_END_APPLICATION,  // = 0x00004007
+    }
+
+    enum : LONG {
+        CONSOLE_CARET_SELECTION  = 1,
+        CONSOLE_CARET_VISIBLE // = 2
+    }
+    enum LONG CONSOLE_APPLICATION_16BIT = 1;
+}
+
+enum {
+    LWA_COLORKEY = 1,
+    LWA_ALPHA
+}
+enum {
+    ULW_COLORKEY = 1,
+    ULW_ALPHA    = 2,
+    ULW_OPAQUE   = 4
+}
+enum {
+    GR_GDIOBJECTS,
+    GR_USEROBJECTS
+}
+
+enum {
+    XBUTTON1 = 1,
+    XBUTTON2
+}
+
+struct GUITHREADINFO {
+    DWORD cbSize = this.sizeof;
+    DWORD flags;
+    HWND  hwndActive;
+    HWND  hwndFocus;
+    HWND  hwndCapture;
+    HWND  hwndMenuOwner;
+    HWND  hwndMoveSize;
+    HWND  hwndCaret;
+    RECT  rcCaret;
+}
+alias GUITHREADINFO* PGUITHREADINFO, LPGUITHREADINFO;
+extern (Windows) {
+    alias void function(HWINEVENTHOOK, DWORD, HWND, LONG, LONG, DWORD, DWORD) WINEVENTPROC;
+}
+// *** line 4680 of MinGW 4.0
+int BroadcastSystemMessageA(DWORD, LPDWORD, UINT, WPARAM, LPARAM);
+int BroadcastSystemMessageW(DWORD, LPDWORD, UINT, WPARAM, LPARAM);
+
+UINT SendInput(UINT, LPINPUT, int);
+BOOL EnumDisplayMonitors(HDC, LPCRECT, MONITORENUMPROC, LPARAM);
+BOOL GetMonitorInfoA(HMONITOR, LPMONITORINFO);
+BOOL GetMonitorInfoA(HMONITOR, LPMONITORINFOEXA);
+BOOL GetMonitorInfoW(HMONITOR, LPMONITORINFO);
+BOOL GetMonitorInfoW(HMONITOR, LPMONITORINFOEXW);
+HMONITOR MonitorFromPoint(POINT, DWORD);
+HMONITOR MonitorFromRect(LPCRECT, DWORD);
+HMONITOR MonitorFromWindow(HWND, DWORD);
+BOOL AllowSetForegroundWindow(DWORD);
+BOOL AnimateWindow(HWND, DWORD, DWORD);
+BOOL EndTask(HWND, BOOL, BOOL);
+BOOL EnumDisplaySettingsExA(LPCSTR, DWORD, LPDEVMODEA, DWORD);
+BOOL EnumDisplaySettingsExW(LPCWSTR, DWORD, LPDEVMODEW, DWORD);
+DWORD GetClipboardSequenceNumber();
+DWORD GetGuiResources(HANDLE, DWORD);
+BOOL GetGUIThreadInfo(DWORD, LPGUITHREADINFO);
+
+int GetMouseMovePointsEx(UINT, LPMOUSEMOVEPOINT, LPMOUSEMOVEPOINT, int, DWORD);
+BOOL GetProcessDefaultLayout(DWORD*);
+HWND GetShellWindow();
+BOOL IsHungAppWindow(HWND);
+DWORD InSendMessageEx(LPVOID);
+BOOL LockSetForegroundWindow(UINT);
+BOOL LockWorkStation();
+void NotifyWinEvent(DWORD, HWND, LONG, LONG);
+HDEVNOTIFY RegisterDeviceNotificationA(HANDLE, LPVOID, DWORD);
+HDEVNOTIFY RegisterDeviceNotificationW(HANDLE, LPVOID, DWORD);
+BOOL SetProcessDefaultLayout(DWORD);
+HWINEVENTHOOK SetWinEventHook(UINT, UINT, HMODULE, WINEVENTPROC, DWORD, DWORD, UINT);
+void SwitchToThisWindow(HWND, BOOL);
+BOOL SetLayeredWindowAttributes(HWND, COLORREF, BYTE, DWORD);
+BOOL UpdateLayeredWindow(HWND, HDC, POINT*, SIZE*, HDC, POINT*, COLORREF, BLENDFUNCTION*, DWORD);
+BOOL UserHandleGrantAccess(HANDLE, HANDLE, BOOL);
+BOOL UnhookWinEvent(HWINEVENTHOOK);
+BOOL UnregisterDeviceNotification(HANDLE);
+
+static if (_WIN32_WINNT >= 0x501) {
+    int BroadcastSystemMessageExA(DWORD, LPDWORD, UINT, WPARAM, LPARAM, PBSMINFO);
+    int BroadcastSystemMessageExW(DWORD, LPDWORD, UINT, WPARAM, LPARAM, PBSMINFO);
+    LRESULT DefRawInputProc(PRAWINPUT*, INT, UINT);
+    BOOL FlashWindowEx(PFLASHWINFO);
+    BOOL GetLayeredWindowAttributes(HWND, COLORREF*, BYTE*, DWORD*);
+    UINT GetRawInputBuffer(PRAWINPUT, PUINT, UINT);
+    UINT GetRawInputData(HRAWINPUT, UINT, LPVOID, PUINT, UINT);
+    UINT GetRawInputDeviceInfoA(HANDLE, UINT, LPVOID, PUINT);
+    UINT GetRawInputDeviceInfoW(HANDLE, UINT, LPVOID, PUINT);
+    UINT GetRawInputDeviceList(PRAWINPUTDEVICELIST, PUINT, UINT);
+    UINT GetRegisteredRawInputDevices(PRAWINPUTDEVICE, PUINT, UINT);
+    BOOL IsGUIThread(BOOL);
+    BOOL IsWinEventHookInstalled(DWORD);
+    BOOL PrintWindow(HWND, HDC, UINT);
+    BOOL RegisterRawInputDevices(PCRAWINPUTDEVICE, UINT, UINT);
+}
+
+version (Win64) {
+    LONG_PTR GetWindowLongPtrA(HWND, int);
+    LONG_PTR GetWindowLongPtrW(HWND, int);
+    LONG_PTR SetWindowLongPtrA(HWND, int, LONG_PTR);
+    LONG_PTR SetWindowLongPtrW(HWND, int, LONG_PTR);
+} else {
+    alias GetWindowLongA GetWindowLongPtrA;
+    alias GetWindowLongW GetWindowLongPtrW;
+    alias SetWindowLongA SetWindowLongPtrA;
+    alias SetWindowLongW SetWindowLongPtrW;
+}
+
+
+// -----
+// Aliases for Unicode or Ansi
+version(Unicode) {
+    alias EDITWORDBREAKPROCW EDITWORDBREAKPROC;
+    alias PROPENUMPROCW PROPENUMPROC;
+    alias PROPENUMPROCEXW PROPENUMPROCEX;
+    alias DESKTOPENUMPROCW DESKTOPENUMPROC;
+    alias WINSTAENUMPROCW WINSTAENUMPROC;
+    alias MAKEINTRESOURCEW MAKEINTRESOURCE;
+
+    alias WNDCLASSW WNDCLASS;
+    alias WNDCLASSEXW WNDCLASSEX;
+    alias MENUITEMINFOW MENUITEMINFO;
+    alias LPCMENUITEMINFOW LPCMENUITEMINFO;
+    alias MSGBOXPARAMSW MSGBOXPARAMS;
+    alias HIGHCONTRASTW HIGHCONTRAST;
+    alias SERIALKEYSW SERIALKEYS;
+    alias SOUNDSENTRYW SOUNDSENTRY;
+    alias CREATESTRUCTW CREATESTRUCT;
+    alias CBT_CREATEWNDW CBT_CREATEWND;
+    alias MDICREATESTRUCTW MDICREATESTRUCT;
+    alias MULTIKEYHELPW MULTIKEYHELP;
+    alias MONITORINFOEXW MONITORINFOEX;
+    alias ICONMETRICSW ICONMETRICS;
+    alias NONCLIENTMETRICSW NONCLIENTMETRICS;
+
+    alias AppendMenuW AppendMenu;
+    alias BroadcastSystemMessageW BroadcastSystemMessage;
+    static if (_WIN32_WINNT >= 0x501) {
+        alias BroadcastSystemMessageExW BroadcastSystemMessageEx;
+    }
+    alias CallMsgFilterW CallMsgFilter;
+    alias CallWindowProcW CallWindowProc;
+    alias ChangeMenuW ChangeMenu;
+    alias CharLowerW CharLower;
+    alias CharLowerBuffW CharLowerBuff;
+    alias CharNextW CharNext;
+    alias CharNextExW CharNextEx;
+    alias CharPrevW CharPrev;
+    alias CharPrevExW CharPrevEx;
+    alias CharToOemW CharToOem;
+    alias CharToOemBuffW CharToOemBuff;
+    alias CharUpperW CharUpper;
+    alias CharUpperBuffW CharUpperBuff;
+    alias CopyAcceleratorTableW CopyAcceleratorTable;
+    alias CreateAcceleratorTableW CreateAcceleratorTable;
+    alias CreateDialogW CreateDialog;
+    alias CreateDialogIndirectW CreateDialogIndirect;
+    alias CreateDialogIndirectParamW CreateDialogIndirectParam;
+    alias CreateDialogParamW CreateDialogParam;
+    alias CreateMDIWindowW CreateMDIWindow;
+    alias CreateWindowW CreateWindow;
+    alias CreateWindowExW CreateWindowEx;
+    alias CreateWindowStationW CreateWindowStation;
+    alias DefDlgProcW DefDlgProc;
+    alias DefFrameProcW DefFrameProc;
+    alias DefMDIChildProcW DefMDIChildProc;
+    alias DefWindowProcW DefWindowProc;
+    alias DialogBoxW DialogBox;
+    alias DialogBoxIndirectW DialogBoxIndirect;
+    alias DialogBoxIndirectParamW DialogBoxIndirectParam;
+    alias DialogBoxParamW DialogBoxParam;
+    alias DispatchMessageW DispatchMessage;
+    alias DlgDirListW DlgDirList;
+    alias DlgDirListComboBoxW DlgDirListComboBox;
+    alias DlgDirSelectComboBoxExW DlgDirSelectComboBoxEx;
+    alias DlgDirSelectExW DlgDirSelectEx;
+    alias DrawStateW DrawState;
+    alias DrawTextW DrawText;
+    alias DrawTextExW DrawTextEx;
+    alias EnumDesktopsW EnumDesktops;
+    alias EnumPropsW EnumProps;
+    alias EnumPropsExW EnumPropsEx;
+    alias EnumWindowStationsW EnumWindowStations;
+    alias FindWindowW FindWindow;
+    alias FindWindowExW FindWindowEx;
+    alias GetClassInfoW GetClassInfo;
+    alias GetClassInfoExW GetClassInfoEx;
+    alias GetClassLongW GetClassLong;
+    alias GetClassNameW GetClassName;
+    alias GetClipboardFormatNameW GetClipboardFormatName;
+    alias GetDlgItemTextW GetDlgItemText;
+    alias GetKeyboardLayoutNameW GetKeyboardLayoutName;
+    alias GetKeyNameTextW GetKeyNameText;
+    alias GetMenuItemInfoW GetMenuItemInfo;
+    alias GetMenuStringW GetMenuString;
+    alias GetMessageW GetMessage;
+    alias GetMonitorInfoW GetMonitorInfo;
+    alias GetPropW GetProp;
+    static if (_WIN32_WINNT >= 0x501) {
+        alias GetRawInputDeviceInfoW GetRawInputDeviceInfo;
+    }
+    alias GetTabbedTextExtentW GetTabbedTextExtent;
+    alias GetUserObjectInformationW GetUserObjectInformation;
+    alias GetWindowLongW GetWindowLong;
+    alias GetWindowLongPtrW GetWindowLongPtr;
+    alias GetWindowTextW GetWindowText;
+    alias GetWindowTextLengthW GetWindowTextLength;
+    alias GetAltTabInfoW GetAltTabInfo;
+    alias GetWindowModuleFileNameW GetWindowModuleFileName;
+    alias GrayStringW GrayString;
+    alias InsertMenuW InsertMenu;
+    alias InsertMenuItemW InsertMenuItem;
+    alias IsCharAlphaW IsCharAlpha;
+    alias IsCharAlphaNumericW IsCharAlphaNumeric;
+    alias IsCharLowerW IsCharLower;
+    alias IsCharUpperW IsCharUpper;
+    alias IsDialogMessageW IsDialogMessage;
+    alias LoadAcceleratorsW LoadAccelerators;
+    alias LoadBitmapW LoadBitmap;
+    alias LoadCursorW LoadCursor;
+    alias LoadCursorFromFileW LoadCursorFromFile;
+    alias LoadIconW LoadIcon;
+    alias LoadImageW LoadImage;
+    alias LoadKeyboardLayoutW LoadKeyboardLayout;
+    alias LoadMenuW LoadMenu;
+    alias LoadMenuIndirectW LoadMenuIndirect;
+    alias LoadStringW LoadString;
+    alias MapVirtualKeyW MapVirtualKey;
+    alias MapVirtualKeyExW MapVirtualKeyEx;
+    alias MessageBoxW MessageBox;
+    alias MessageBoxExW MessageBoxEx;
+    alias MessageBoxIndirectW MessageBoxIndirect;
+    alias ModifyMenuW ModifyMenu;
+    alias OemToCharW OemToChar;
+    alias OemToCharBuffW OemToCharBuff;
+    alias OpenDesktopW OpenDesktop;
+    alias OpenWindowStationW OpenWindowStation;
+    alias PeekMessageW PeekMessage;
+    alias PostMessageW PostMessage;
+    alias PostThreadMessageW PostThreadMessage;
+    alias RealGetWindowClassW RealGetWindowClass;
+    alias RegisterClassW RegisterClass;
+    alias RegisterClassExW RegisterClassEx;
+    alias RegisterClipboardFormatW RegisterClipboardFormat;
+    alias RegisterDeviceNotificationW RegisterDeviceNotification;
+    alias RegisterWindowMessageW RegisterWindowMessage;
+    alias RemovePropW RemoveProp;
+    alias SendDlgItemMessageW SendDlgItemMessage;
+    alias SendMessageW SendMessage;
+    alias SendMessageCallbackW SendMessageCallback;
+    alias SendMessageTimeoutW SendMessageTimeout;
+    alias SendNotifyMessageW SendNotifyMessage;
+    alias SetClassLongW SetClassLong;
+    alias SetDlgItemTextW SetDlgItemText;
+    alias SetMenuItemInfoW SetMenuItemInfo;
+    alias SetPropW SetProp;
+    alias SetUserObjectInformationW SetUserObjectInformation;
+    alias SetWindowLongW SetWindowLong;
+    alias SetWindowLongPtrW SetWindowLongPtr;
+    alias SetWindowsHookW SetWindowsHook;
+    alias SetWindowsHookExW SetWindowsHookEx;
+    alias SetWindowTextW SetWindowText;
+    alias SystemParametersInfoW SystemParametersInfo;
+    alias TabbedTextOutW TabbedTextOut;
+    alias TranslateAcceleratorW TranslateAccelerator;
+    alias UnregisterClassW UnregisterClass;
+    alias VkKeyScanW VkKeyScan;
+    alias VkKeyScanExW VkKeyScanEx;
+    alias WinHelpW WinHelp;
+    alias wsprintfW wsprintf;
+    alias wvsprintfW wvsprintf;
+
+    alias ChangeDisplaySettingsW ChangeDisplaySettings;
+    alias ChangeDisplaySettingsExW ChangeDisplaySettingsEx;
+    alias CreateDesktopW CreateDesktop;
+    alias EnumDisplaySettingsW EnumDisplaySettings;
+    alias EnumDisplaySettingsExW EnumDisplaySettingsEx;
+    alias EnumDisplayDevicesW EnumDisplayDevices;
+
+} else { // ANSI
+
+    alias EDITWORDBREAKPROCA EDITWORDBREAKPROC;
+    alias PROPENUMPROCA PROPENUMPROC;
+    alias PROPENUMPROCEXA PROPENUMPROCEX;
+    alias DESKTOPENUMPROCA DESKTOPENUMPROC;
+    alias WINSTAENUMPROCA WINSTAENUMPROC;
+    alias MAKEINTRESOURCEA MAKEINTRESOURCE;
+
+    alias WNDCLASSA WNDCLASS;
+    alias WNDCLASSEXA WNDCLASSEX;
+    alias MENUITEMINFOA MENUITEMINFO;
+    alias LPCMENUITEMINFOA LPCMENUITEMINFO;
+    alias MSGBOXPARAMSA MSGBOXPARAMS;
+    alias HIGHCONTRASTA HIGHCONTRAST;
+    alias SERIALKEYSA SERIALKEYS;
+    alias SOUNDSENTRYA SOUNDSENTRY;
+    alias CREATESTRUCTA CREATESTRUCT;
+    alias CBT_CREATEWNDA CBT_CREATEWND;
+    alias MDICREATESTRUCTA MDICREATESTRUCT;
+    alias MULTIKEYHELPA MULTIKEYHELP;
+    alias MONITORINFOEXA MONITORINFOEX;
+    alias ICONMETRICSA ICONMETRICS;
+    alias NONCLIENTMETRICSA NONCLIENTMETRICS;
+
+    alias AppendMenuA AppendMenu;
+    alias BroadcastSystemMessageA BroadcastSystemMessage;
+    static if (_WIN32_WINNT >= 0x501) {
+        alias BroadcastSystemMessageExA BroadcastSystemMessageEx;
+    }
+    alias CallMsgFilterA CallMsgFilter;
+    alias CallWindowProcA CallWindowProc;
+    alias ChangeMenuA ChangeMenu;
+    alias CharLowerA CharLower;
+    alias CharLowerBuffA CharLowerBuff;
+    alias CharNextA CharNext;
+    alias CharNextExA CharNextEx;
+    alias CharPrevA CharPrev;
+    alias CharPrevExA CharPrevEx;
+    alias CharToOemA CharToOem;
+    alias CharToOemBuffA CharToOemBuff;
+    alias CharUpperA CharUpper;
+    alias CharUpperBuffA CharUpperBuff;
+    alias CopyAcceleratorTableA CopyAcceleratorTable;
+    alias CreateAcceleratorTableA CreateAcceleratorTable;
+    alias CreateDialogA CreateDialog;
+    alias CreateDialogIndirectA CreateDialogIndirect;
+    alias CreateDialogIndirectParamA CreateDialogIndirectParam;
+    alias CreateDialogParamA CreateDialogParam;
+    alias CreateMDIWindowA CreateMDIWindow;
+    alias CreateWindowA CreateWindow;
+    alias CreateWindowExA CreateWindowEx;
+    alias CreateWindowStationA CreateWindowStation;
+    alias DefDlgProcA DefDlgProc;
+    alias DefFrameProcA DefFrameProc;
+    alias DefMDIChildProcA DefMDIChildProc;
+    alias DefWindowProcA DefWindowProc;
+    alias DialogBoxA DialogBox;
+    alias DialogBoxIndirectA DialogBoxIndirect;
+    alias DialogBoxIndirectParamA DialogBoxIndirectParam;
+    alias DialogBoxParamA DialogBoxParam;
+    alias DispatchMessageA DispatchMessage;
+    alias DlgDirListA DlgDirList;
+    alias DlgDirListComboBoxA DlgDirListComboBox;
+    alias DlgDirSelectComboBoxExA DlgDirSelectComboBoxEx;
+    alias DlgDirSelectExA DlgDirSelectEx;
+    alias DrawStateA DrawState;
+    alias DrawTextA DrawText;
+    alias DrawTextExA DrawTextEx;
+    alias EnumDesktopsA EnumDesktops;
+    alias EnumPropsA EnumProps;
+    alias EnumPropsExA EnumPropsEx;
+    alias EnumWindowStationsA EnumWindowStations;
+    alias FindWindowA FindWindow;
+    alias FindWindowExA FindWindowEx;
+    alias GetClassInfoA GetClassInfo;
+    alias GetClassInfoExA GetClassInfoEx;
+    alias GetClassLongA GetClassLong;
+    alias GetClassNameA GetClassName;
+    alias GetClipboardFormatNameA GetClipboardFormatName;
+    alias GetDlgItemTextA GetDlgItemText;
+    alias GetKeyboardLayoutNameA GetKeyboardLayoutName;
+    alias GetKeyNameTextA GetKeyNameText;
+    alias GetMenuItemInfoA GetMenuItemInfo;
+    alias GetMenuStringA GetMenuString;
+    alias GetMessageA GetMessage;
+    alias GetMonitorInfoA GetMonitorInfo;
+    alias GetPropA GetProp;
+    static if (_WIN32_WINNT >= 0x501) {
+        alias GetRawInputDeviceInfoA GetRawInputDeviceInfo;
+    }
+    alias GetTabbedTextExtentA GetTabbedTextExtent;
+    alias GetUserObjectInformationA GetUserObjectInformation;
+    alias GetWindowLongA GetWindowLong;
+    alias GetWindowLongPtrA GetWindowLongPtr;
+    alias GetWindowTextA GetWindowText;
+    alias GetWindowTextLengthA GetWindowTextLength;
+    alias GetAltTabInfoA GetAltTabInfo;
+    alias GetWindowModuleFileNameA GetWindowModuleFileName;
+    alias GrayStringA GrayString;
+    alias InsertMenuA InsertMenu;
+    alias InsertMenuItemA InsertMenuItem;
+    alias IsCharAlphaA IsCharAlpha;
+    alias IsCharAlphaNumericA IsCharAlphaNumeric;
+    alias IsCharLowerA IsCharLower;
+    alias IsCharUpperA IsCharUpper;
+    alias IsDialogMessageA IsDialogMessage;
+    alias LoadAcceleratorsA LoadAccelerators;
+    alias LoadBitmapA LoadBitmap;
+    alias LoadCursorA LoadCursor;
+    alias LoadIconA LoadIcon;
+    alias LoadCursorFromFileA LoadCursorFromFile;
+    alias LoadImageA LoadImage;
+    alias LoadKeyboardLayoutA LoadKeyboardLayout;
+    alias LoadMenuA LoadMenu;
+    alias LoadMenuIndirectA LoadMenuIndirect;
+    alias LoadStringA LoadString;
+    alias MapVirtualKeyA MapVirtualKey;
+    alias MapVirtualKeyExA MapVirtualKeyEx;
+    alias MessageBoxA MessageBox;
+    alias MessageBoxExA MessageBoxEx;
+    alias MessageBoxIndirectA MessageBoxIndirect;
+    alias ModifyMenuA ModifyMenu;
+    alias OemToCharA OemToChar;
+    alias OemToCharBuffA OemToCharBuff;
+    alias OpenDesktopA OpenDesktop;
+    alias OpenWindowStationA OpenWindowStation;
+    alias PeekMessageA PeekMessage;
+    alias PostMessageA PostMessage;
+    alias PostThreadMessageA PostThreadMessage;
+    alias RealGetWindowClassA RealGetWindowClass;
+    alias RegisterClassA RegisterClass;
+    alias RegisterClassExA RegisterClassEx;
+    alias RegisterClipboardFormatA RegisterClipboardFormat;
+    alias RegisterDeviceNotificationA RegisterDeviceNotification;
+    alias RegisterWindowMessageA RegisterWindowMessage;
+    alias RemovePropA RemoveProp;
+    alias SendDlgItemMessageA SendDlgItemMessage;
+    alias SendMessageA SendMessage;
+    alias SendMessageCallbackA SendMessageCallback;
+    alias SendMessageTimeoutA SendMessageTimeout;
+    alias SendNotifyMessageA SendNotifyMessage;
+    alias SetClassLongA SetClassLong;
+    alias SetDlgItemTextA SetDlgItemText;
+    alias SetMenuItemInfoA SetMenuItemInfo;
+    alias SetPropA SetProp;
+    alias SetUserObjectInformationA SetUserObjectInformation;
+    alias SetWindowLongA SetWindowLong;
+    alias SetWindowLongPtrA SetWindowLongPtr;
+    alias SetWindowsHookA SetWindowsHook;
+    alias SetWindowsHookExA SetWindowsHookEx;
+    alias SetWindowTextA SetWindowText;
+    alias SystemParametersInfoA SystemParametersInfo;
+    alias TabbedTextOutA TabbedTextOut;
+    alias TranslateAcceleratorA TranslateAccelerator;
+    alias UnregisterClassA UnregisterClass;
+    alias VkKeyScanA VkKeyScan;
+    alias VkKeyScanExA VkKeyScanEx;
+    alias WinHelpA WinHelp;
+    alias wsprintfA wsprintf;
+    alias wvsprintfA wvsprintf;
+
+    alias ChangeDisplaySettingsA ChangeDisplaySettings;
+    alias ChangeDisplaySettingsExA ChangeDisplaySettingsEx;
+    alias CreateDesktopA CreateDesktop;
+    alias EnumDisplaySettingsA EnumDisplaySettings;
+    alias EnumDisplaySettingsExA EnumDisplaySettingsEx;
+    alias EnumDisplayDevicesA EnumDisplayDevices;
+}
+
+alias WNDCLASS* LPWNDCLASS, PWNDCLASS;
+alias WNDCLASSEX* LPWNDCLASSEX, PWNDCLASSEX;
+alias MENUITEMINFO* LPMENUITEMINFO;
+alias MSGBOXPARAMS* PMSGBOXPARAMS, LPMSGBOXPARAMS;
+alias HIGHCONTRAST* LPHIGHCONTRAST;
+alias SERIALKEYS* LPSERIALKEYS;
+alias SOUNDSENTRY* LPSOUNDSENTRY;
+alias CREATESTRUCT* LPCREATESTRUCT;
+alias CBT_CREATEWND* LPCBT_CREATEWND;
+alias MDICREATESTRUCT* LPMDICREATESTRUCT;
+alias MULTIKEYHELP* PMULTIKEYHELP, LPMULTIKEYHELP;
+alias MONITORINFOEX* LPMONITORINFOEX;
+alias ICONMETRICS* LPICONMETRICS;
+alias NONCLIENTMETRICS* LPNONCLIENTMETRICS;
+
+static if (_WIN32_WINNT >= 0x501) {
+    enum PW_CLIENTONLY               = 0x00000001;
+    enum RIM_INPUT                   = 0x00000000;
+    enum RIM_INPUTSINK               = 0x00000001;
+    enum RIM_TYPEMOUSE               = 0x00000000;
+    enum RIM_TYPEKEYBOARD            = 0x00000001;
+    enum RIM_TYPEHID                 = 0x00000002;
+    enum MOUSE_MOVE_RELATIVE         = 0x00000000;
+    enum MOUSE_MOVE_ABSOLUTE         = 0x00000001;
+    enum MOUSE_VIRTUAL_DESKTOP       = 0x00000002;
+    enum MOUSE_ATTRIBUTES_CHANGED    = 0x00000004;
+    enum RI_MOUSE_LEFT_BUTTON_DOWN   = 0x0001;
+    enum RI_MOUSE_LEFT_BUTTON_UP     = 0x0002;
+    enum RI_MOUSE_RIGHT_BUTTON_DOWN  = 0x0004;
+    enum RI_MOUSE_RIGHT_BUTTON_UP    = 0x0008;
+    enum RI_MOUSE_MIDDLE_BUTTON_DOWN = 0x0010;
+    enum RI_MOUSE_MIDDLE_BUTTON_UP   = 0x0020;
+    enum RI_MOUSE_BUTTON_1_DOWN = RI_MOUSE_LEFT_BUTTON_DOWN;
+    enum RI_MOUSE_BUTTON_1_UP   = RI_MOUSE_LEFT_BUTTON_UP;
+    enum RI_MOUSE_BUTTON_2_DOWN = RI_MOUSE_RIGHT_BUTTON_DOWN;
+    enum RI_MOUSE_BUTTON_2_UP   = RI_MOUSE_RIGHT_BUTTON_UP;
+    enum RI_MOUSE_BUTTON_3_DOWN = RI_MOUSE_MIDDLE_BUTTON_DOWN;
+    enum RI_MOUSE_BUTTON_3_UP   = RI_MOUSE_MIDDLE_BUTTON_UP;
+    enum RI_MOUSE_BUTTON_4_DOWN = 0x0040;
+    enum RI_MOUSE_BUTTON_4_UP   = 0x0080;
+    enum RI_MOUSE_BUTTON_5_DOWN = 0x0100;
+    enum RI_MOUSE_BUTTON_5_UP   = 0x0200;
+    enum RI_MOUSE_WHEEL         = 0x0400;
+    enum KEYBOARD_OVERRUN_MAKE_CODE = 0x00ff;
+    enum RI_KEY_MAKE            = 0x0000;
+    enum RI_KEY_BREAK           = 0x0001;
+    enum RI_KEY_E0              = 0x0002;
+    enum RI_KEY_E1              = 0x0004;
+    enum RI_KEY_TERMSRV_SET_LED = 0x0008;
+    enum RI_KEY_TERMSRV_SHADOW  = 0x0010;
+
+    enum RID_INPUT          = 0x10000003;
+    enum RID_HEADER         = 0x10000005;
+
+    enum RIDI_PREPARSEDDATA = 0x20000005;
+    enum RIDI_DEVICENAME    = 0x20000007;
+    enum RIDI_DEVICEINFO    = 0x2000000b;
+
+    enum RIDEV_REMOVE       = 0x00000001;
+    enum RIDEV_EXCLUDE      = 0x00000010;
+    enum RIDEV_PAGEONLY     = 0x00000020;
+    enum RIDEV_NOLEGACY     = 0x00000030;
+    enum RIDEV_INPUTSINK    = 0x00000100;
+    enum RIDEV_CAPTUREMOUSE = 0x00000200;
+    enum RIDEV_NOHOTKEYS    = 0x00000200;
+    enum RIDEV_APPKEYS      = 0x00000400;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/winver.d b/libphobos/libdruntime/core/sys/windows/winver.d
new file mode 100644
index 00000000000..e33ff4b498f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/winver.d
@@ -0,0 +1,174 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * Authors: Stewart Gordon
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_winver.d)
+ */
+module core.sys.windows.winver;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "version");
+
+private import core.sys.windows.windef;
+
+// FIXME: type weirdness
+enum {
+    VS_FILE_INFO    =  16,
+    VS_VERSION_INFO =   1,
+    VS_USER_DEFINED = 100
+}
+
+enum {
+    VS_FFI_SIGNATURE     = 0xFEEF04BD,
+    VS_FFI_STRUCVERSION  =    0x10000,
+    VS_FFI_FILEFLAGSMASK =       0x3F
+}
+
+enum {
+    VS_FF_DEBUG        =  1,
+    VS_FF_PRERELEASE   =  2,
+    VS_FF_PATCHED      =  4,
+    VS_FF_PRIVATEBUILD =  8,
+    VS_FF_INFOINFERRED = 16,
+    VS_FF_SPECIALBUILD = 32
+}
+
+enum {
+    VOS_UNKNOWN       =       0,
+    VOS_DOS           = 0x10000,
+    VOS_OS216         = 0x20000,
+    VOS_OS232         = 0x30000,
+    VOS_NT            = 0x40000,
+    VOS__BASE         =       0,
+    VOS__WINDOWS16    =       1,
+    VOS__PM16         =       2,
+    VOS__PM32         =       3,
+    VOS__WINDOWS32    =       4,
+    VOS_DOS_WINDOWS16 = 0x10001,
+    VOS_DOS_WINDOWS32 = 0x10004,
+    VOS_OS216_PM16    = 0x20002,
+    VOS_OS232_PM32    = 0x30003,
+    VOS_NT_WINDOWS32  = 0x40004
+}
+
+enum {
+    VFT_UNKNOWN    = 0,
+    VFT_APP        = 1,
+    VFT_DLL        = 2,
+    VFT_DRV        = 3,
+    VFT_FONT       = 4,
+    VFT_VXD        = 5,
+    VFT_STATIC_LIB = 7
+}
+
+enum {
+    VFT2_UNKNOWN         =  0,
+    VFT2_DRV_PRINTER     =  1,
+    VFT2_DRV_KEYBOARD    =  2,
+    VFT2_DRV_LANGUAGE    =  3,
+    VFT2_DRV_DISPLAY     =  4,
+    VFT2_DRV_MOUSE       =  5,
+    VFT2_DRV_NETWORK     =  6,
+    VFT2_DRV_SYSTEM      =  7,
+    VFT2_DRV_INSTALLABLE =  8,
+    VFT2_DRV_SOUND       =  9,
+    VFT2_DRV_COMM        = 10,
+    VFT2_DRV_INPUTMETHOD = 11,
+    VFT2_FONT_RASTER     =  1,
+    VFT2_FONT_VECTOR     =  2,
+    VFT2_FONT_TRUETYPE   =  3
+}
+
+enum : DWORD {
+    VFFF_ISSHAREDFILE = 1
+}
+
+enum : DWORD {
+    VFF_CURNEDEST    = 1,
+    VFF_FILEINUSE    = 2,
+    VFF_BUFFTOOSMALL = 4
+}
+
+enum : DWORD {
+    VIFF_FORCEINSTALL  = 1,
+    VIFF_DONTDELETEOLD
+}
+
+enum {
+    VIF_TEMPFILE         = 0x00001,
+    VIF_MISMATCH         = 0x00002,
+    VIF_SRCOLD           = 0x00004,
+    VIF_DIFFLANG         = 0x00008,
+    VIF_DIFFCODEPG       = 0x00010,
+    VIF_DIFFTYPE         = 0x00020,
+    VIF_WRITEPROT        = 0x00040,
+    VIF_FILEINUSE        = 0x00080,
+    VIF_OUTOFSPACE       = 0x00100,
+    VIF_ACCESSVIOLATION  = 0x00200,
+    VIF_SHARINGVIOLATION = 0x00400,
+    VIF_CANNOTCREATE     = 0x00800,
+    VIF_CANNOTDELETE     = 0x01000,
+    VIF_CANNOTRENAME     = 0x02000,
+    VIF_CANNOTDELETECUR  = 0x04000,
+    VIF_OUTOFMEMORY      = 0x08000,
+    VIF_CANNOTREADSRC    = 0x10000,
+    VIF_CANNOTREADDST    = 0x20000,
+    VIF_BUFFTOOSMALL     = 0x40000
+}
+
+struct VS_FIXEDFILEINFO {
+    DWORD dwSignature;
+    DWORD dwStrucVersion;
+    DWORD dwFileVersionMS;
+    DWORD dwFileVersionLS;
+    DWORD dwProductVersionMS;
+    DWORD dwProductVersionLS;
+    DWORD dwFileFlagsMask;
+    DWORD dwFileFlags;
+    DWORD dwFileOS;
+    DWORD dwFileType;
+    DWORD dwFileSubtype;
+    DWORD dwFileDateMS;
+    DWORD dwFileDateLS;
+}
+
+extern (Windows) {
+    DWORD VerFindFileA(DWORD, LPCSTR, LPCSTR, LPCSTR, LPSTR, PUINT, LPSTR,
+      PUINT);
+    DWORD VerFindFileW(DWORD, LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, PUINT, LPWSTR,
+      PUINT);
+    DWORD VerInstallFileA(DWORD, LPCSTR, LPCSTR, LPCSTR, LPCSTR, LPCSTR, LPSTR,
+      PUINT);
+    DWORD VerInstallFileW(DWORD, LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR,
+      LPWSTR, PUINT);
+    DWORD GetFileVersionInfoSizeA(LPCSTR, PDWORD);
+    DWORD GetFileVersionInfoSizeW(LPCWSTR, PDWORD);
+    BOOL GetFileVersionInfoA(LPCSTR, DWORD, DWORD, PVOID);
+    BOOL GetFileVersionInfoW(LPCWSTR, DWORD, DWORD, PVOID);
+    DWORD VerLanguageNameA(DWORD, LPSTR, DWORD);
+    DWORD VerLanguageNameW(DWORD, LPWSTR, DWORD);
+    BOOL VerQueryValueA(LPCVOID, LPCSTR, LPVOID*, PUINT);
+    BOOL VerQueryValueW(LPCVOID, LPCWSTR, LPVOID*, PUINT);
+}
+
+version (Unicode) {
+    alias VerFindFileW VerFindFile;
+    alias VerQueryValueW VerQueryValue;
+    alias VerInstallFileW VerInstallFile;
+    alias GetFileVersionInfoSizeW GetFileVersionInfoSize;
+    alias GetFileVersionInfoW GetFileVersionInfo;
+    alias VerLanguageNameW VerLanguageName;
+    alias VerQueryValueW VerQueryValue;
+} else {
+    alias VerQueryValueA VerQueryValue;
+    alias VerFindFileA VerFindFile;
+    alias VerInstallFileA VerInstallFile;
+    alias GetFileVersionInfoSizeA GetFileVersionInfoSize;
+    alias GetFileVersionInfoA GetFileVersionInfo;
+    alias VerLanguageNameA VerLanguageName;
+    alias VerQueryValueA VerQueryValue;
+}
diff --git a/libphobos/libdruntime/core/sys/windows/wtsapi32.d b/libphobos/libdruntime/core/sys/windows/wtsapi32.d
new file mode 100644
index 00000000000..0d502b941e4
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/wtsapi32.d
@@ -0,0 +1,431 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW-w64 API
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_wtsapi32.d)
+ */
+module core.sys.windows.wtsapi32;
+version (Windows):
+
+version (ANSI) {} else version = Unicode;
+pragma(lib, "wtsapi32");
+private import core.sys.windows.w32api;
+import core.sys.windows.windef;
+
+enum {
+    WTS_CURRENT_SERVER        = null,
+    WTS_CURRENT_SERVER_HANDLE = null,
+    WTS_CURRENT_SERVER_NAME   = null
+}
+
+enum DWORD WTS_CURRENT_SESSION = cast(DWORD) -1;
+
+enum {
+    IDTIMEOUT = 32000,
+    IDASYNC   = 32001
+}
+
+enum {
+    WTS_WSD_LOGOFF     = 0x01,
+    WTS_WSD_SHUTDOWN   = 0x02,
+    WTS_WSD_REBOOT     = 0x04,
+    WTS_WSD_POWEROFF   = 0x08,
+    WTS_WSD_FASTREBOOT = 0x10
+}
+
+enum WTS_CONNECTSTATE_CLASS {
+    WTSActive,
+    WTSConnected,
+    WTSConnectQuery,
+    WTSShadow,
+    WTSDisconnected,
+    WTSIdle,
+    WTSListen,
+    WTSReset,
+    WTSDown,
+    WTSInit
+}
+
+struct WTS_SERVER_INFOW {
+    LPWSTR pServerName;
+}
+alias WTS_SERVER_INFOW* PWTS_SERVER_INFOW;
+
+struct WTS_SERVER_INFOA {
+    LPSTR pServerName;
+}
+alias WTS_SERVER_INFOA* PWTS_SERVER_INFOA;
+
+version(Unicode) {
+    alias WTS_SERVER_INFOW  WTS_SERVER_INFO;
+    alias PWTS_SERVER_INFOW PWTS_SERVER_INFO;
+} else {
+    alias WTS_SERVER_INFOA  WTS_SERVER_INFO;
+    alias PWTS_SERVER_INFOA PWTS_SERVER_INFO;
+}
+
+struct WTS_SESSION_INFOW {
+    DWORD SessionId;
+    LPWSTR pWinStationName;
+    WTS_CONNECTSTATE_CLASS State;
+}
+alias WTS_SESSION_INFOW* PWTS_SESSION_INFOW;
+
+struct WTS_SESSION_INFOA {
+    DWORD SessionId;
+    LPSTR pWinStationName;
+    WTS_CONNECTSTATE_CLASS State;
+}
+alias WTS_SESSION_INFOA* PWTS_SESSION_INFOA;
+
+version(Unicode) {
+    alias WTS_SESSION_INFOW  WTS_SESSION_INFO;
+    alias PWTS_SESSION_INFOW PWTS_SESSION_INFO;
+} else {
+    alias WTS_SESSION_INFOA  WTS_SESSION_INFO;
+    alias PWTS_SESSION_INFOA PWTS_SESSION_INFO;
+}
+
+struct WTS_PROCESS_INFOW {
+    DWORD SessionId;
+    DWORD ProcessId;
+    LPWSTR pProcessName;
+    PSID pUserSid;
+}
+alias WTS_PROCESS_INFOW* PWTS_PROCESS_INFOW;
+
+struct WTS_PROCESS_INFOA {
+    DWORD SessionId;
+    DWORD ProcessId;
+    LPSTR pProcessName;
+    PSID pUserSid;
+}
+alias WTS_PROCESS_INFOA* PWTS_PROCESS_INFOA;
+
+version(Unicode) {
+    alias WTS_PROCESS_INFOW  WTS_PROCESS_INFO;
+    alias PWTS_PROCESS_INFOW PWTS_PROCESS_INFO;
+} else {
+    alias WTS_PROCESS_INFOA  WTS_PROCESS_INFO;
+    alias PWTS_PROCESS_INFOA PWTS_PROCESS_INFO;
+}
+
+enum {
+    WTS_PROTOCOL_TYPE_CONSOLE,
+    WTS_PROTOCOL_TYPE_ICA,
+    WTS_PROTOCOL_TYPE_RDP
+}
+
+enum WTS_INFO_CLASS {
+    WTSInitialProgram,
+    WTSApplicationName,
+    WTSWorkingDirectory,
+    WTSOEMId,
+    WTSSessionId,
+    WTSUserName,
+    WTSWinStationName,
+    WTSDomainName,
+    WTSConnectState,
+    WTSClientBuildNumber,
+    WTSClientName,
+    WTSClientDirectory,
+    WTSClientProductId,
+    WTSClientHardwareId,
+    WTSClientAddress,
+    WTSClientDisplay,
+    WTSClientProtocolType,
+    WTSIdleTime,
+    WTSLogonTime,
+    WTSIncomingBytes,
+    WTSOutgoingBytes,
+    WTSIncomingFrames,
+    WTSOutgoingFrames,
+    WTSClientInfo,
+    WTSSessionInfo, // = 24
+}
+
+struct WTS_CLIENT_ADDRESS {
+    DWORD    AddressFamily;
+    BYTE[20] Address;
+}
+alias WTS_CLIENT_ADDRESS* PWTS_CLIENT_ADDRESS;
+
+struct WTS_CLIENT_DISPLAY {
+    DWORD HorizontalResolution;
+    DWORD VerticalResolution;
+    DWORD ColorDepth;
+}
+alias WTS_CLIENT_DISPLAY* PWTS_CLIENT_DISPLAY;
+
+enum WTS_CONFIG_CLASS {
+    WTSUserConfigInitialProgram,
+    WTSUserConfigWorkingDirectory,
+    WTSUserConfigfInheritInitialProgram,
+    WTSUserConfigfAllowLogonTerminalServer,
+    WTSUserConfigTimeoutSettingsConnections,
+    WTSUserConfigTimeoutSettingsDisconnections,
+    WTSUserConfigTimeoutSettingsIdle,
+    WTSUserConfigfDeviceClientDrives,
+    WTSUserConfigfDeviceClientPrinters,
+    WTSUserConfigfDeviceClientDefaultPrinter,
+    WTSUserConfigBrokenTimeoutSettings,
+    WTSUserConfigReconnectSettings,
+    WTSUserConfigModemCallbackSettings,
+    WTSUserConfigModemCallbackPhoneNumber,
+    WTSUserConfigShadowingSettings,
+    WTSUserConfigTerminalServerProfilePath,
+    WTSUserConfigTerminalServerHomeDir,
+    WTSUserConfigTerminalServerHomeDirDrive,
+    WTSUserConfigfTerminalServerRemoteHomeDir
+}
+
+enum {
+    WTS_EVENT_NONE        = 0x0,
+    WTS_EVENT_CREATE      = 0x1,
+    WTS_EVENT_DELETE      = 0x2,
+    WTS_EVENT_RENAME      = 0x4,
+    WTS_EVENT_CONNECT     = 0x8,
+    WTS_EVENT_DISCONNECT  = 0x10,
+    WTS_EVENT_LOGON       = 0x20,
+    WTS_EVENT_LOGOFF      = 0x40,
+    WTS_EVENT_STATECHANGE = 0x80,
+    WTS_EVENT_LICENSE     = 0x100,
+    WTS_EVENT_ALL         = 0x7fffffff,
+    WTS_EVENT_FLUSH       = 0x80000000
+}
+
+enum WTS_VIRTUAL_CLASS {
+    WTSVirtualClientData,
+    WTSVirtualFileHandle
+}
+
+version(Unicode) {
+    alias WTSEnumerateServersW WTSEnumerateServers;
+    alias WTSOpenServerW WTSOpenServer;
+    alias WTSEnumerateSessionsW WTSEnumerateSessions;
+    alias WTSEnumerateProcessesW WTSEnumerateProcesses;
+    alias WTSQuerySessionInformationW WTSQuerySessionInformation;
+    alias WTSQueryUserConfigW WTSQueryUserConfig;
+    alias WTSSetUserConfigW WTSSetUserConfig;
+    alias WTSSendMessageW WTSSendMessage;
+} else {
+    alias WTSEnumerateServersA WTSEnumerateServers;
+    alias WTSOpenServerA WTSOpenServer;
+    alias WTSEnumerateSessionsA WTSEnumerateSessions;
+    alias WTSEnumerateProcessesA WTSEnumerateProcesses;
+    alias WTSQuerySessionInformationA WTSQuerySessionInformation;
+    alias WTSQueryUserConfigA WTSQueryUserConfig;
+    alias WTSSetUserConfigA WTSSetUserConfig;
+    alias WTSSendMessageA WTSSendMessage;
+}
+
+extern(Windows) {
+    WINBOOL WTSEnumerateServersW(LPWSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOW* ppServerInfo, DWORD* pCount);
+    WINBOOL WTSEnumerateServersA(LPSTR pDomainName, DWORD Reserved, DWORD Version, PWTS_SERVER_INFOA* ppServerInfo, DWORD* pCount);
+    HANDLE WTSOpenServerW(LPWSTR pServerName);
+    HANDLE WTSOpenServerA(LPSTR pServerName);
+    VOID WTSCloseServer(HANDLE hServer);
+    WINBOOL WTSEnumerateSessionsW(HANDLE hServer, DWORD Reserved, DWORD Version, PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount);
+    WINBOOL WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version, PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount);
+    WINBOOL WTSEnumerateProcessesW(HANDLE hServer, DWORD Reserved, DWORD Version, PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount);
+    WINBOOL WTSEnumerateProcessesA(HANDLE hServer, DWORD Reserved, DWORD Version, PWTS_PROCESS_INFOA* ppProcessInfo, DWORD* pCount);
+    WINBOOL WTSTerminateProcess(HANDLE hServer, DWORD ProcessId, DWORD ExitCode);
+    WINBOOL WTSQuerySessionInformationW(HANDLE hServer, DWORD SessionId, WTS_INFO_CLASS WTSInfoClass, LPWSTR* ppBuffer, DWORD* pBytesReturned);
+    WINBOOL WTSQuerySessionInformationA(HANDLE hServer, DWORD SessionId, WTS_INFO_CLASS WTSInfoClass, LPSTR* ppBuffer, DWORD* pBytesReturned);
+    WINBOOL WTSQueryUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer, DWORD* pBytesReturned);
+    WINBOOL WTSQueryUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR* ppBuffer, DWORD* pBytesReturned);
+    WINBOOL WTSSetUserConfigW(LPWSTR pServerName, LPWSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer, DWORD DataLength);
+    WINBOOL WTSSetUserConfigA(LPSTR pServerName, LPSTR pUserName, WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer, DWORD DataLength);
+    WINBOOL WTSSendMessageW(HANDLE hServer, DWORD SessionId, LPWSTR pTitle, DWORD TitleLength, LPWSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD* pResponse, WINBOOL bWait);
+    WINBOOL WTSSendMessageA(HANDLE hServer, DWORD SessionId, LPSTR pTitle, DWORD TitleLength, LPSTR pMessage, DWORD MessageLength, DWORD Style, DWORD Timeout, DWORD* pResponse, WINBOOL bWait);
+    WINBOOL WTSDisconnectSession(HANDLE hServer, DWORD SessionId, WINBOOL bWait);
+    WINBOOL WTSLogoffSession(HANDLE hServer, DWORD SessionId, WINBOOL bWait);
+    WINBOOL WTSShutdownSystem(HANDLE hServer, DWORD ShutdownFlag);
+    WINBOOL WTSWaitSystemEvent(HANDLE hServer, DWORD EventMask, DWORD* pEventFlags);
+    HANDLE WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPSTR pVirtualName);
+    WINBOOL WTSVirtualChannelClose(HANDLE hChannelHandle);
+    WINBOOL WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, ULONG BufferSize, PULONG pBytesRead);
+    WINBOOL WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, PULONG pBytesWritten);
+    WINBOOL WTSVirtualChannelPurgeInput(HANDLE hChannelHandle);
+    WINBOOL WTSVirtualChannelPurgeOutput(HANDLE hChannelHandle);
+    WINBOOL WTSVirtualChannelQuery(HANDLE hChannelHandle, WTS_VIRTUAL_CLASS, PVOID* ppBuffer, DWORD* pBytesReturned);
+    VOID WTSFreeMemory(PVOID pMemory);
+
+    WINBOOL WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags);
+    WINBOOL WTSUnRegisterSessionNotification(HWND hWnd);
+    WINBOOL WTSQueryUserToken(ULONG SessionId, PHANDLE phToken);
+}
+
+enum {
+    NOTIFY_FOR_ALL_SESSIONS = 1,
+    NOTIFY_FOR_THIS_SESSION = 0
+}
+
+enum {
+    USERNAME_LENGTH       = 20,
+    CLIENTNAME_LENGTH     = 20,
+    CLIENTADDRESS_LENGTH  = 30,
+    WINSTATIONNAME_LENGTH = 32,
+    DOMAIN_LENGTH         = 17
+}
+
+static if (_WIN32_WINNT >= 0x600) {
+    struct WTSCLIENTW {
+        WCHAR[CLIENTNAME_LENGTH + 1]      ClientName;
+        WCHAR[DOMAIN_LENGTH + 1]          Domain;
+        WCHAR[USERNAME_LENGTH + 1]        UserName;
+        WCHAR[MAX_PATH + 1]               WorkDirectory;
+        WCHAR[MAX_PATH + 1]               InitialProgram;
+        BYTE                              EncryptionLevel;
+        ULONG                             ClientAddressFamily;
+        USHORT[CLIENTADDRESS_LENGTH + 1]  ClientAddress;
+        USHORT                            HRes;
+        USHORT                            VRes;
+        USHORT                            ColorDepth;
+        WCHAR[MAX_PATH + 1]               ClientDirectory;
+        ULONG                             ClientBuildNumber;
+        ULONG                             ClientHardwareId;
+        USHORT                            ClientProductId;
+        USHORT                            OutBufCountHost;
+        USHORT                            OutBufCountClient;
+        USHORT                            OutBufLength;
+        WCHAR[MAX_PATH + 1]               DeviceId;
+    }
+    alias WTSCLIENTW* PWTSCLIENTW;
+
+    struct WTSCLIENTA {
+        CHAR[CLIENTNAME_LENGTH + 1]       ClientName;
+        CHAR[DOMAIN_LENGTH + 1 ]          Domain;
+        CHAR[USERNAME_LENGTH + 1]         UserName;
+        CHAR[MAX_PATH + 1]                WorkDirectory;
+        CHAR[MAX_PATH + 1]                InitialProgram;
+        BYTE                              EncryptionLevel;
+        ULONG                             ClientAddressFamily;
+        USHORT[CLIENTADDRESS_LENGTH + 1]  ClientAddress;
+        USHORT                            HRes;
+        USHORT                            VRes;
+        USHORT                            ColorDepth;
+        CHAR[MAX_PATH + 1]                ClientDirectory;
+        ULONG                             ClientBuildNumber;
+        ULONG                             ClientHardwareId;
+        USHORT                            ClientProductId;
+        USHORT                            OutBufCountHost;
+        USHORT                            OutBufCountClient;
+        USHORT                            OutBufLength;
+        CHAR[MAX_PATH + 1]                DeviceId;
+    }
+    alias WTSCLIENTA* PWTSCLIENTA;
+
+    version(Unicode) {
+        alias WTSCLIENTW  WTSCLIENT;
+        alias PWTSCLIENTW PWTSCLIENT;
+    } else {
+        alias WTSCLIENTA  WTSCLIENT;
+        alias PWTSCLIENTA PWTSCLIENT;
+    }
+
+    struct WTSINFOW {
+        WTS_CONNECTSTATE_CLASS       State;
+        DWORD                        SessionId;
+        DWORD                        IncomingBytes;
+        DWORD                        OutgoingBytes;
+        DWORD                        IncomingCompressedBytes;
+        DWORD                        OutgoingCompressedBytes;
+        WCHAR[WINSTATIONNAME_LENGTH] WinStationName;
+        WCHAR[DOMAIN_LENGTH]         Domain;
+        WCHAR[USERNAME_LENGTH+1]     UserName;
+        LARGE_INTEGER                ConnectTime;
+        LARGE_INTEGER                DisconnectTime;
+        LARGE_INTEGER                LastInputTime;
+        LARGE_INTEGER                LogonTime;
+        LARGE_INTEGER                CurrentTime;
+    }
+    alias WTSINFOW* PWTSINFOW;
+
+    struct WTSINFOA {
+        WTS_CONNECTSTATE_CLASS      State;
+        DWORD                       SessionId;
+        DWORD                       IncomingBytes;
+        DWORD                       OutgoingBytes;
+        DWORD                       IncomingCompressedBytes;
+        DWORD                       OutgoingCompressedBytes;
+        CHAR[WINSTATIONNAME_LENGTH] WinStationName;
+        CHAR[DOMAIN_LENGTH]         Domain;
+        CHAR[USERNAME_LENGTH+1]     UserName;
+        LARGE_INTEGER               ConnectTime;
+        LARGE_INTEGER               DisconnectTime;
+        LARGE_INTEGER               LastInputTime;
+        LARGE_INTEGER               LogonTime;
+        LARGE_INTEGER               CurrentTime;
+    }
+    alias WTSINFOA* PWTSINFOA;
+
+    version(Unicode) {
+        alias WTSINFOW  WTSINFO;
+        alias PWTSINFOW PWTSINFO;
+    } else {
+        alias WTSINFOA  WTSINFO;
+        alias PWTSINFOA PWTSINFO;
+    }
+
+    extern(Windows) {
+        WINBOOL WTSConnectSessionA(
+            ULONG LogonId,
+            ULONG TargetLogonId,
+            PSTR   pPassword,
+            WINBOOL bWait
+        );
+
+        WINBOOL WTSConnectSessionW(
+            ULONG LogonId,
+            ULONG TargetLogonId,
+            PWSTR  pPassword,
+            WINBOOL bWait
+        );
+
+        WINBOOL WTSRegisterSessionNotificationEx(
+            HANDLE hServer,
+            HWND hWnd,
+            DWORD dwFlags
+        );
+
+        WINBOOL WTSStartRemoteControlSessionA(
+            LPSTR pTargetServerName,
+            ULONG TargetLogonId,
+            BYTE HotkeyVk,
+            USHORT HotkeyModifiers
+        );
+
+        WINBOOL WTSStartRemoteControlSessionW(
+            LPWSTR pTargetServerName,
+            ULONG TargetLogonId,
+            BYTE HotkeyVk,
+            USHORT HotkeyModifiers
+        );
+
+        version(Unicode) {
+            alias WTSStartRemoteControlSessionW WTSStartRemoteControlSession;
+            alias WTSConnectSessionW WTSConnectSession;
+        } else {
+            alias WTSStartRemoteControlSessionA WTSStartRemoteControlSession;
+            alias WTSConnectSessionA WTSConnectSession;
+        }
+
+        WINBOOL WTSStopRemoteControlSession(
+            ULONG LogonId
+        );
+
+        WINBOOL WTSUnRegisterSessionNotificationEx(
+            HANDLE hServer,
+            HWND hWnd
+        );
+
+        HANDLE WTSVirtualChannelOpenEx(
+            DWORD SessionId,
+            LPSTR pVirtualName,
+            DWORD flags
+        );
+    } /* extern(Windows) */
+} /* static if (_WIN32_WINNT >= 0x600) */
diff --git a/libphobos/libdruntime/core/sys/windows/wtypes.d b/libphobos/libdruntime/core/sys/windows/wtypes.d
new file mode 100644
index 00000000000..b7a83cbce70
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/windows/wtypes.d
@@ -0,0 +1,235 @@
+/**
+ * Windows API header module
+ *
+ * Translated from MinGW Windows headers
+ *
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(DRUNTIMESRC src/core/sys/windows/_wtypes.d)
+ */
+module core.sys.windows.wtypes;
+version (Windows):
+
+import core.sys.windows.rpc, core.sys.windows.rpcndr;
+private import core.sys.windows.windef;
+private import core.sys.windows.uuid; // for GUID_NULL
+
+alias GUID_NULL IID_NULL, CLSID_NULL;
+
+enum ROTFLAGS_REGISTRATIONKEEPSALIVE = 0x01;
+enum ROTFLAGS_ALLOWANYCLIENT         = 0x02;
+
+// also in winsock2.h
+struct BLOB {
+    ULONG cbSize;
+    BYTE* pBlobData;
+}
+alias BLOB* PBLOB, LPBLOB;
+
+enum DVASPECT {
+    DVASPECT_CONTENT   = 1,
+    DVASPECT_THUMBNAIL = 2,
+    DVASPECT_ICON      = 4,
+    DVASPECT_DOCPRINT  = 8
+}
+
+enum DVASPECT2 {
+    DVASPECT_OPAQUE      = 16,
+    DVASPECT_TRANSPARENT = 32
+}
+
+enum STATFLAG {
+    STATFLAG_DEFAULT = 0,
+    STATFLAG_NONAME  = 1
+}
+
+enum MEMCTX {
+    MEMCTX_LOCAL = 0,
+    MEMCTX_TASK,
+    MEMCTX_SHARED,
+    MEMCTX_MACSYSTEM,
+    MEMCTX_UNKNOWN = -1,
+    MEMCTX_SAME = -2
+}
+
+enum MSHCTX {
+    MSHCTX_LOCAL = 0,
+    MSHCTX_NOSHAREDMEM,
+    MSHCTX_DIFFERENTMACHINE,
+    MSHCTX_INPROC,
+    MSHCTX_CROSSCTX
+}
+
+enum CLSCTX {
+    CLSCTX_INPROC_SERVER    = 0x1,
+    CLSCTX_INPROC_HANDLER   = 0x2,
+    CLSCTX_LOCAL_SERVER     = 0x4,
+    CLSCTX_INPROC_SERVER16  = 0x8,
+    CLSCTX_REMOTE_SERVER    = 0x10,
+    CLSCTX_INPROC_HANDLER16 = 0x20,
+    CLSCTX_INPROC_SERVERX86 = 0x40,
+    CLSCTX_INPROC_HANDLERX86 = 0x80,
+}
+
+enum MSHLFLAGS {
+    MSHLFLAGS_NORMAL,
+    MSHLFLAGS_TABLESTRONG,
+    MSHLFLAGS_TABLEWEAK
+}
+
+struct FLAGGED_WORD_BLOB {
+    uint fFlags;
+    uint clSize;
+    ushort[1] asData;
+}
+
+alias WCHAR OLECHAR;
+alias LPWSTR LPOLESTR;
+alias LPCWSTR LPCOLESTR;
+
+alias ushort VARTYPE;
+alias short VARIANT_BOOL;
+alias VARIANT_BOOL _VARIANT_BOOL;
+enum VARIANT_BOOL VARIANT_TRUE = -1; // 0xffff;
+enum VARIANT_BOOL VARIANT_FALSE = 0;
+
+alias OLECHAR* BSTR;
+alias FLAGGED_WORD_BLOB* wireBSTR;
+alias BSTR* LPBSTR;
+//alias LONG SCODE; // also in winerror
+mixin DECLARE_HANDLE!("HCONTEXT");
+mixin DECLARE_HANDLE!("HMETAFILEPICT");
+
+union CY {
+    struct {
+        uint Lo;
+        int Hi;
+    }
+    LONGLONG int64;
+}
+
+alias double DATE;
+struct  BSTRBLOB {
+    ULONG cbSize;
+    PBYTE pData;
+}
+alias BSTRBLOB* LPBSTRBLOB;
+
+// Used only in the PROPVARIANT structure
+// According to the 2003 SDK, this should be in propidl.h, not here.
+struct CLIPDATA {
+    ULONG cbSize;
+    int ulClipFmt;
+    PBYTE pClipData;
+}
+
+enum STGC {
+    STGC_DEFAULT,
+    STGC_OVERWRITE,
+    STGC_ONLYIFCURRENT,
+    STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE
+}
+
+enum STGMOVE {
+    STGMOVE_MOVE,
+    STGMOVE_COPY,
+    STGMOVE_SHALLOWCOPY
+}
+
+enum VARENUM {
+    VT_EMPTY,
+    VT_NULL,
+    VT_I2,
+    VT_I4,
+    VT_R4,
+    VT_R8,
+    VT_CY,
+    VT_DATE,
+    VT_BSTR,
+    VT_DISPATCH,
+    VT_ERROR,
+    VT_BOOL,
+    VT_VARIANT,
+    VT_UNKNOWN,
+    VT_DECIMAL,
+    VT_I1 = 16,
+    VT_UI1,
+    VT_UI2,
+    VT_UI4,
+    VT_I8,
+    VT_UI8,
+    VT_INT,
+    VT_UINT,
+    VT_VOID,
+    VT_HRESULT,
+    VT_PTR,
+    VT_SAFEARRAY,
+    VT_CARRAY,
+    VT_USERDEFINED,
+    VT_LPSTR,
+    VT_LPWSTR,
+    VT_RECORD   = 36,
+    VT_INT_PTR  = 37,
+    VT_UINT_PTR = 38,
+    VT_FILETIME = 64,
+    VT_BLOB,
+    VT_STREAM,
+    VT_STORAGE,
+    VT_STREAMED_OBJECT,
+    VT_STORED_OBJECT,
+    VT_BLOB_OBJECT,
+    VT_CF,
+    VT_CLSID,
+    VT_BSTR_BLOB     = 0xfff,
+    VT_VECTOR        = 0x1000,
+    VT_ARRAY         = 0x2000,
+    VT_BYREF         = 0x4000,
+    VT_RESERVED      = 0x8000,
+    VT_ILLEGAL       = 0xffff,
+    VT_ILLEGALMASKED = 0xfff,
+    VT_TYPEMASK      = 0xfff
+};
+
+struct BYTE_SIZEDARR {
+    uint clSize;
+    byte* pData;
+}
+
+struct WORD_SIZEDARR {
+    uint clSize;
+    ushort* pData;
+}
+
+struct DWORD_SIZEDARR {
+uint clSize;
+uint* pData;
+}
+
+struct HYPER_SIZEDARR {
+    uint clSize;
+    hyper* pData;
+}
+
+alias double DOUBLE;
+
+
+struct DECIMAL {
+    USHORT wReserved;
+    union {
+        struct {
+            ubyte scale; // valid values are 0 to 28
+            ubyte sign; // 0 for positive, DECIMAL_NEG for negatives.
+            enum ubyte DECIMAL_NEG = 0x80;
+        }
+        USHORT signscale;
+    }
+    ULONG Hi32;
+    union {
+        struct {
+            ULONG Lo32;
+            ULONG Mid32;
+        }
+        ULONGLONG Lo64;
+    }
+    // #define DECIMAL_SETZERO(d) {(d).Lo64=(d).Hi32=(d).signscale=0;}
+    void setZero() { Lo64 = 0; Hi32 = 0; signscale = 0; }
+}
diff --git a/libphobos/libdruntime/core/thread.d b/libphobos/libdruntime/core/thread.d
new file mode 100644
index 00000000000..225fb90df57
--- /dev/null
+++ b/libphobos/libdruntime/core/thread.d
@@ -0,0 +1,5453 @@
+﻿/**
+ * The thread module provides support for thread creation and management.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2012.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly, Walter Bright, Alex Rønne Petersen, Martin Nowak
+ * Source:    $(DRUNTIMESRC core/_thread.d)
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module core.thread;
+
+
+public import core.time; // for Duration
+import core.exception : onOutOfMemoryError;
+
+
+private
+{
+    // interface to rt.tlsgc
+    import core.internal.traits : externDFunc;
+
+    alias rt_tlsgc_init = externDFunc!("rt.tlsgc.init", void* function());
+    alias rt_tlsgc_destroy = externDFunc!("rt.tlsgc.destroy", void function(void*));
+
+    alias ScanDg = void delegate(void* pstart, void* pend) nothrow;
+    alias rt_tlsgc_scan =
+        externDFunc!("rt.tlsgc.scan", void function(void*, scope ScanDg) nothrow);
+
+    alias rt_tlsgc_processGCMarks =
+        externDFunc!("rt.tlsgc.processGCMarks", void function(void*, scope IsMarkedDg) nothrow);
+}
+
+version( Solaris )
+{
+    import core.sys.solaris.sys.priocntl;
+    import core.sys.solaris.sys.types;
+}
+
+// this should be true for most architectures
+version( GNU_StackGrowsDown )
+    version = StackGrowsDown;
+
+/**
+ * Returns the process ID of the calling process, which is guaranteed to be
+ * unique on the system. This call is always successful.
+ *
+ * Example:
+ * ---
+ * writefln("Current process id: %s", getpid());
+ * ---
+ */
+version(Posix)
+{
+    alias core.sys.posix.unistd.getpid getpid;
+}
+else version (Windows)
+{
+    alias core.sys.windows.windows.GetCurrentProcessId getpid;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Thread and Fiber Exceptions
+///////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * Base class for thread exceptions.
+ */
+class ThreadException : Exception
+{
+    @safe pure nothrow this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null)
+    {
+        super(msg, file, line, next);
+    }
+
+    @safe pure nothrow this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__)
+    {
+        super(msg, file, line, next);
+    }
+}
+
+
+/**
+* Base class for thread errors to be used for function inside GC when allocations are unavailable.
+*/
+class ThreadError : Error
+{
+    @safe pure nothrow this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null)
+    {
+        super(msg, file, line, next);
+    }
+
+    @safe pure nothrow this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__)
+    {
+        super(msg, file, line, next);
+    }
+}
+
+private
+{
+    import core.atomic, core.memory, core.sync.mutex;
+
+    //
+    // exposed by compiler runtime
+    //
+    extern (C) void  rt_moduleTlsCtor();
+    extern (C) void  rt_moduleTlsDtor();
+
+    /**
+     * Hook for whatever EH implementation is used to save/restore some data
+     * per stack.
+     *
+     * Params:
+     *     newContext = The return value of the prior call to this function
+     *         where the stack was last swapped out, or null when a fiber stack
+     *         is switched in for the first time.
+     */
+    extern(C) void* _d_eh_swapContext(void* newContext) nothrow;
+
+    version (DigitalMars)
+    {
+        version (Windows)
+            alias _d_eh_swapContext swapContext;
+        else
+        {
+            extern(C) void* _d_eh_swapContextDwarf(void* newContext) nothrow;
+
+            void* swapContext(void* newContext) nothrow
+            {
+                /* Detect at runtime which scheme is being used.
+                 * Eventually, determine it statically.
+                 */
+                static int which = 0;
+                final switch (which)
+                {
+                    case 0:
+                    {
+                        assert(newContext == null);
+                        auto p = _d_eh_swapContext(newContext);
+                        auto pdwarf = _d_eh_swapContextDwarf(newContext);
+                        if (p)
+                        {
+                            which = 1;
+                            return p;
+                        }
+                        else if (pdwarf)
+                        {
+                            which = 2;
+                            return pdwarf;
+                        }
+                        return null;
+                    }
+                    case 1:
+                        return _d_eh_swapContext(newContext);
+                    case 2:
+                        return _d_eh_swapContextDwarf(newContext);
+                }
+            }
+        }
+    }
+    else
+        alias _d_eh_swapContext swapContext;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Thread Entry Point and Signal Handlers
+///////////////////////////////////////////////////////////////////////////////
+
+
+version( Windows )
+{
+    private
+    {
+        import core.stdc.stdint : uintptr_t; // for _beginthreadex decl below
+        import core.stdc.stdlib;             // for malloc, atexit
+        import core.sys.windows.windows;
+        import core.sys.windows.threadaux;   // for OpenThreadHandle
+
+        extern (Windows) alias uint function(void*) btex_fptr;
+        extern (C) uintptr_t _beginthreadex(void*, uint, btex_fptr, void*, uint, uint*) nothrow;
+
+        //
+        // Entry point for Windows threads
+        //
+        extern (Windows) uint thread_entryPoint( void* arg )
+        {
+            Thread  obj = cast(Thread) arg;
+            assert( obj );
+
+            assert( obj.m_curr is &obj.m_main );
+            obj.m_main.bstack = getStackBottom();
+            obj.m_main.tstack = obj.m_main.bstack;
+            obj.m_tlsgcdata = rt_tlsgc_init();
+
+            Thread.setThis(obj);
+            Thread.add(obj);
+            scope (exit)
+            {
+                Thread.remove(obj);
+            }
+            Thread.add(&obj.m_main);
+
+            // NOTE: No GC allocations may occur until the stack pointers have
+            //       been set and Thread.getThis returns a valid reference to
+            //       this thread object (this latter condition is not strictly
+            //       necessary on Windows but it should be followed for the
+            //       sake of consistency).
+
+            // TODO: Consider putting an auto exception object here (using
+            //       alloca) forOutOfMemoryError plus something to track
+            //       whether an exception is in-flight?
+
+            void append( Throwable t )
+            {
+                if( obj.m_unhandled is null )
+                    obj.m_unhandled = t;
+                else
+                {
+                    Throwable last = obj.m_unhandled;
+                    while( last.next !is null )
+                        last = last.next;
+                    last.next = t;
+                }
+            }
+
+            version( D_InlineAsm_X86 )
+            {
+                asm nothrow @nogc { fninit; }
+            }
+
+            try
+            {
+                rt_moduleTlsCtor();
+                try
+                {
+                    obj.run();
+                }
+                catch( Throwable t )
+                {
+                    append( t );
+                }
+                rt_moduleTlsDtor();
+            }
+            catch( Throwable t )
+            {
+                append( t );
+            }
+            return 0;
+        }
+
+
+        HANDLE GetCurrentThreadHandle()
+        {
+            const uint DUPLICATE_SAME_ACCESS = 0x00000002;
+
+            HANDLE curr = GetCurrentThread(),
+                   proc = GetCurrentProcess(),
+                   hndl;
+
+            DuplicateHandle( proc, curr, proc, &hndl, 0, TRUE, DUPLICATE_SAME_ACCESS );
+            return hndl;
+        }
+    }
+}
+else version( Posix )
+{
+    private
+    {
+        import core.stdc.errno;
+        import core.sys.posix.semaphore;
+        import core.sys.posix.stdlib; // for malloc, valloc, free, atexit
+        import core.sys.posix.pthread;
+        import core.sys.posix.signal;
+        import core.sys.posix.time;
+
+        version( OSX )
+        {
+            import core.sys.osx.mach.thread_act;
+            import core.sys.osx.pthread : pthread_mach_thread_np;
+        }
+
+        version( GNU )
+        {
+            import gcc.builtins;
+        }
+
+        //
+        // Entry point for POSIX threads
+        //
+        extern (C) void* thread_entryPoint( void* arg )
+        {
+            version (Shared)
+            {
+                import rt.sections;
+                Thread obj = cast(Thread)(cast(void**)arg)[0];
+                auto loadedLibraries = (cast(void**)arg)[1];
+                .free(arg);
+            }
+            else
+            {
+                Thread obj = cast(Thread)arg;
+            }
+            assert( obj );
+
+            // loadedLibraries need to be inherited from parent thread
+            // before initilizing GC for TLS (rt_tlsgc_init)
+            version (Shared) inheritLoadedLibraries(loadedLibraries);
+
+            assert( obj.m_curr is &obj.m_main );
+            obj.m_main.bstack = getStackBottom();
+            obj.m_main.tstack = obj.m_main.bstack;
+            obj.m_tlsgcdata = rt_tlsgc_init();
+
+            atomicStore!(MemoryOrder.raw)(obj.m_isRunning, true);
+            Thread.setThis(obj); // allocates lazy TLS (see Issue 11981)
+            Thread.add(obj);     // can only receive signals from here on
+            scope (exit)
+            {
+                Thread.remove(obj);
+                atomicStore!(MemoryOrder.raw)(obj.m_isRunning, false);
+            }
+            Thread.add(&obj.m_main);
+
+            static extern (C) void thread_cleanupHandler( void* arg ) nothrow
+            {
+                Thread  obj = cast(Thread) arg;
+                assert( obj );
+
+                // NOTE: If the thread terminated abnormally, just set it as
+                //       not running and let thread_suspendAll remove it from
+                //       the thread list.  This is safer and is consistent
+                //       with the Windows thread code.
+                atomicStore!(MemoryOrder.raw)(obj.m_isRunning,false);
+            }
+
+            // NOTE: Using void to skip the initialization here relies on
+            //       knowledge of how pthread_cleanup is implemented.  It may
+            //       not be appropriate for all platforms.  However, it does
+            //       avoid the need to link the pthread module.  If any
+            //       implementation actually requires default initialization
+            //       then pthread_cleanup should be restructured to maintain
+            //       the current lack of a link dependency.
+            static if( __traits( compiles, pthread_cleanup ) )
+            {
+                pthread_cleanup cleanup = void;
+                cleanup.push( &thread_cleanupHandler, cast(void*) obj );
+            }
+            else static if( __traits( compiles, pthread_cleanup_push ) )
+            {
+                pthread_cleanup_push( &thread_cleanupHandler, cast(void*) obj );
+            }
+            else
+            {
+                static assert( false, "Platform not supported." );
+            }
+
+            // NOTE: No GC allocations may occur until the stack pointers have
+            //       been set and Thread.getThis returns a valid reference to
+            //       this thread object (this latter condition is not strictly
+            //       necessary on Windows but it should be followed for the
+            //       sake of consistency).
+
+            // TODO: Consider putting an auto exception object here (using
+            //       alloca) forOutOfMemoryError plus something to track
+            //       whether an exception is in-flight?
+
+            void append( Throwable t )
+            {
+                if( obj.m_unhandled is null )
+                    obj.m_unhandled = t;
+                else
+                {
+                    Throwable last = obj.m_unhandled;
+                    while( last.next !is null )
+                        last = last.next;
+                    last.next = t;
+                }
+            }
+
+            try
+            {
+                rt_moduleTlsCtor();
+                try
+                {
+                    obj.run();
+                }
+                catch( Throwable t )
+                {
+                    append( t );
+                }
+                rt_moduleTlsDtor();
+                version (Shared) cleanupLoadedLibraries();
+            }
+            catch( Throwable t )
+            {
+                append( t );
+            }
+
+            // NOTE: Normal cleanup is handled by scope(exit).
+
+            static if( __traits( compiles, pthread_cleanup ) )
+            {
+                cleanup.pop( 0 );
+            }
+            else static if( __traits( compiles, pthread_cleanup_push ) )
+            {
+                pthread_cleanup_pop( 0 );
+            }
+
+            return null;
+        }
+
+
+        //
+        // Used to track the number of suspended threads
+        //
+        __gshared sem_t suspendCount;
+
+
+        extern (C) void thread_suspendHandler( int sig ) nothrow
+        in
+        {
+            assert( sig == suspendSignalNumber );
+        }
+        body
+        {
+            void op(void* sp) nothrow
+            {
+                // NOTE: Since registers are being pushed and popped from the
+                //       stack, any other stack data used by this function should
+                //       be gone before the stack cleanup code is called below.
+                Thread obj = Thread.getThis();
+                assert(obj !is null);
+
+                if( !obj.m_lock )
+                {
+                    obj.m_curr.tstack = getStackTop();
+                }
+
+                sigset_t    sigres = void;
+                int         status;
+
+                status = sigfillset( &sigres );
+                assert( status == 0 );
+
+                status = sigdelset( &sigres, resumeSignalNumber );
+                assert( status == 0 );
+
+                version (FreeBSD) obj.m_suspendagain = false;
+                status = sem_post( &suspendCount );
+                assert( status == 0 );
+
+                sigsuspend( &sigres );
+
+                if( !obj.m_lock )
+                {
+                    obj.m_curr.tstack = obj.m_curr.bstack;
+                }
+            }
+
+            // avoid deadlocks on FreeBSD, see Issue 13416
+            version (FreeBSD)
+            {
+                auto obj = Thread.getThis();
+                if (THR_IN_CRITICAL(obj.m_addr))
+                {
+                    obj.m_suspendagain = true;
+                    if (sem_post(&suspendCount)) assert(0);
+                    return;
+                }
+            }
+
+            callWithStackShell(&op);
+        }
+
+
+        extern (C) void thread_resumeHandler( int sig ) nothrow
+        in
+        {
+            assert( sig == resumeSignalNumber );
+        }
+        body
+        {
+
+        }
+
+        // HACK libthr internal (thr_private.h) macro, used to
+        // avoid deadlocks in signal handler, see Issue 13416
+        version (FreeBSD) bool THR_IN_CRITICAL(pthread_t p) nothrow @nogc
+        {
+            import core.sys.posix.config : c_long;
+            import core.sys.posix.sys.types : lwpid_t;
+
+            // If the begin of pthread would be changed in libthr (unlikely)
+            // we'll run into undefined behavior, compare with thr_private.h.
+            static struct pthread
+            {
+                c_long tid;
+                static struct umutex { lwpid_t owner; uint flags; uint[2] ceilings; uint[4] spare; }
+                umutex lock;
+                uint cycle;
+                int locklevel;
+                int critical_count;
+                // ...
+            }
+            auto priv = cast(pthread*)p;
+            return priv.locklevel > 0 || priv.critical_count > 0;
+        }
+    }
+}
+else
+{
+    // NOTE: This is the only place threading versions are checked.  If a new
+    //       version is added, the module code will need to be searched for
+    //       places where version-specific code may be required.  This can be
+    //       easily accomlished by searching for 'Windows' or 'Posix'.
+    static assert( false, "Unknown threading implementation." );
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Thread
+///////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * This class encapsulates all threading functionality for the D
+ * programming language.  As thread manipulation is a required facility
+ * for garbage collection, all user threads should derive from this
+ * class, and instances of this class should never be explicitly deleted.
+ * A new thread may be created using either derivation or composition, as
+ * in the following example.
+ */
+class Thread
+{
+    ///////////////////////////////////////////////////////////////////////////
+    // Initialization
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Initializes a thread object which is associated with a static
+     * D function.
+     *
+     * Params:
+     *  fn = The thread function.
+     *  sz = The stack size for this thread.
+     *
+     * In:
+     *  fn must not be null.
+     */
+    this( void function() fn, size_t sz = 0 )
+    in
+    {
+        assert( fn );
+    }
+    body
+    {
+        this(sz);
+        m_fn   = fn;
+        m_call = Call.FN;
+        m_curr = &m_main;
+    }
+
+
+    /**
+     * Initializes a thread object which is associated with a dynamic
+     * D function.
+     *
+     * Params:
+     *  dg = The thread function.
+     *  sz = The stack size for this thread.
+     *
+     * In:
+     *  dg must not be null.
+     */
+    this( void delegate() dg, size_t sz = 0 )
+    in
+    {
+        assert( dg );
+    }
+    body
+    {
+        this(sz);
+        m_dg   = dg;
+        m_call = Call.DG;
+        m_curr = &m_main;
+    }
+
+
+    /**
+     * Cleans up any remaining resources used by this object.
+     */
+    ~this()
+    {
+        if( m_addr == m_addr.init )
+        {
+            return;
+        }
+
+        version( Windows )
+        {
+            m_addr = m_addr.init;
+            CloseHandle( m_hndl );
+            m_hndl = m_hndl.init;
+        }
+        else version( Posix )
+        {
+            pthread_detach( m_addr );
+            m_addr = m_addr.init;
+        }
+        version( OSX )
+        {
+            m_tmach = m_tmach.init;
+        }
+        rt_tlsgc_destroy( m_tlsgcdata );
+        m_tlsgcdata = null;
+    }
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // General Actions
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Starts the thread and invokes the function or delegate passed upon
+     * construction.
+     *
+     * In:
+     *  This routine may only be called once per thread instance.
+     *
+     * Throws:
+     *  ThreadException if the thread fails to start.
+     */
+    final Thread start() nothrow
+    in
+    {
+        assert( !next && !prev );
+    }
+    body
+    {
+        auto wasThreaded  = multiThreadedFlag;
+        multiThreadedFlag = true;
+        scope( failure )
+        {
+            if( !wasThreaded )
+                multiThreadedFlag = false;
+        }
+
+        version( Windows ) {} else
+        version( Posix )
+        {
+            pthread_attr_t  attr;
+
+            if( pthread_attr_init( &attr ) )
+                onThreadError( "Error initializing thread attributes" );
+            if( m_sz && pthread_attr_setstacksize( &attr, m_sz ) )
+                onThreadError( "Error initializing thread stack size" );
+        }
+
+        version( Windows )
+        {
+            // NOTE: If a thread is just executing DllMain()
+            //       while another thread is started here, it holds an OS internal
+            //       lock that serializes DllMain with CreateThread. As the code
+            //       might request a synchronization on slock (e.g. in thread_findByAddr()),
+            //       we cannot hold that lock while creating the thread without
+            //       creating a deadlock
+            //
+            // Solution: Create the thread in suspended state and then
+            //       add and resume it with slock acquired
+            assert(m_sz <= uint.max, "m_sz must be less than or equal to uint.max");
+            m_hndl = cast(HANDLE) _beginthreadex( null, cast(uint) m_sz, &thread_entryPoint, cast(void*) this, CREATE_SUSPENDED, &m_addr );
+            if( cast(size_t) m_hndl == 0 )
+                onThreadError( "Error creating thread" );
+        }
+
+        slock.lock_nothrow();
+        scope(exit) slock.unlock_nothrow();
+        {
+            ++nAboutToStart;
+            pAboutToStart = cast(Thread*)realloc(pAboutToStart, Thread.sizeof * nAboutToStart);
+            pAboutToStart[nAboutToStart - 1] = this;
+            version( Windows )
+            {
+                if( ResumeThread( m_hndl ) == -1 )
+                    onThreadError( "Error resuming thread" );
+            }
+            else version( Posix )
+            {
+                // NOTE: This is also set to true by thread_entryPoint, but set it
+                //       here as well so the calling thread will see the isRunning
+                //       state immediately.
+                atomicStore!(MemoryOrder.raw)(m_isRunning, true);
+                scope( failure ) atomicStore!(MemoryOrder.raw)(m_isRunning, false);
+
+                version (Shared)
+                {
+                    import rt.sections;
+                    auto libs = pinLoadedLibraries();
+                    auto ps = cast(void**).malloc(2 * size_t.sizeof);
+                    if (ps is null) onOutOfMemoryError();
+                    ps[0] = cast(void*)this;
+                    ps[1] = cast(void*)libs;
+                    if( pthread_create( &m_addr, &attr, &thread_entryPoint, ps ) != 0 )
+                    {
+                        unpinLoadedLibraries(libs);
+                        .free(ps);
+                        onThreadError( "Error creating thread" );
+                    }
+                }
+                else
+                {
+                    if( pthread_create( &m_addr, &attr, &thread_entryPoint, cast(void*) this ) != 0 )
+                        onThreadError( "Error creating thread" );
+                }
+            }
+            version( OSX )
+            {
+                m_tmach = pthread_mach_thread_np( m_addr );
+                if( m_tmach == m_tmach.init )
+                    onThreadError( "Error creating thread" );
+            }
+
+            return this;
+        }
+    }
+
+    /**
+     * Waits for this thread to complete.  If the thread terminated as the
+     * result of an unhandled exception, this exception will be rethrown.
+     *
+     * Params:
+     *  rethrow = Rethrow any unhandled exception which may have caused this
+     *            thread to terminate.
+     *
+     * Throws:
+     *  ThreadException if the operation fails.
+     *  Any exception not handled by the joined thread.
+     *
+     * Returns:
+     *  Any exception not handled by this thread if rethrow = false, null
+     *  otherwise.
+     */
+    final Throwable join( bool rethrow = true )
+    {
+        version( Windows )
+        {
+            if( WaitForSingleObject( m_hndl, INFINITE ) != WAIT_OBJECT_0 )
+                throw new ThreadException( "Unable to join thread" );
+            // NOTE: m_addr must be cleared before m_hndl is closed to avoid
+            //       a race condition with isRunning. The operation is done
+            //       with atomicStore to prevent compiler reordering.
+            atomicStore!(MemoryOrder.raw)(*cast(shared)&m_addr, m_addr.init);
+            CloseHandle( m_hndl );
+            m_hndl = m_hndl.init;
+        }
+        else version( Posix )
+        {
+            if( pthread_join( m_addr, null ) != 0 )
+                throw new ThreadException( "Unable to join thread" );
+            // NOTE: pthread_join acts as a substitute for pthread_detach,
+            //       which is normally called by the dtor.  Setting m_addr
+            //       to zero ensures that pthread_detach will not be called
+            //       on object destruction.
+            m_addr = m_addr.init;
+        }
+        if( m_unhandled )
+        {
+            if( rethrow )
+                throw m_unhandled;
+            return m_unhandled;
+        }
+        return null;
+    }
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // General Properties
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Gets the OS identifier for this thread.
+     *
+     * Returns:
+     *  If the thread hasn't been started yet, returns $(LREF ThreadID)$(D.init).
+     *  Otherwise, returns the result of $(D GetCurrentThreadId) on Windows,
+     *  and $(D pthread_self) on POSIX.
+     *
+     *  The value is unique for the current process.
+     */
+    final @property ThreadID id()
+    {
+        synchronized( this )
+        {
+            return m_addr;
+        }
+    }
+
+
+    /**
+     * Gets the user-readable label for this thread.
+     *
+     * Returns:
+     *  The name of this thread.
+     */
+    final @property string name()
+    {
+        synchronized( this )
+        {
+            return m_name;
+        }
+    }
+
+
+    /**
+     * Sets the user-readable label for this thread.
+     *
+     * Params:
+     *  val = The new name of this thread.
+     */
+    final @property void name( string val )
+    {
+        synchronized( this )
+        {
+            m_name = val;
+        }
+    }
+
+
+    /**
+     * Gets the daemon status for this thread.  While the runtime will wait for
+     * all normal threads to complete before tearing down the process, daemon
+     * threads are effectively ignored and thus will not prevent the process
+     * from terminating.  In effect, daemon threads will be terminated
+     * automatically by the OS when the process exits.
+     *
+     * Returns:
+     *  true if this is a daemon thread.
+     */
+    final @property bool isDaemon()
+    {
+        synchronized( this )
+        {
+            return m_isDaemon;
+        }
+    }
+
+
+    /**
+     * Sets the daemon status for this thread.  While the runtime will wait for
+     * all normal threads to complete before tearing down the process, daemon
+     * threads are effectively ignored and thus will not prevent the process
+     * from terminating.  In effect, daemon threads will be terminated
+     * automatically by the OS when the process exits.
+     *
+     * Params:
+     *  val = The new daemon status for this thread.
+     */
+    final @property void isDaemon( bool val )
+    {
+        synchronized( this )
+        {
+            m_isDaemon = val;
+        }
+    }
+
+
+    /**
+     * Tests whether this thread is running.
+     *
+     * Returns:
+     *  true if the thread is running, false if not.
+     */
+    final @property bool isRunning() nothrow
+    {
+        if( m_addr == m_addr.init )
+        {
+            return false;
+        }
+
+        version( Windows )
+        {
+            uint ecode = 0;
+            GetExitCodeThread( m_hndl, &ecode );
+            return ecode == STILL_ACTIVE;
+        }
+        else version( Posix )
+        {
+            return atomicLoad(m_isRunning);
+        }
+    }
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // Thread Priority Actions
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * The minimum scheduling priority that may be set for a thread.  On
+     * systems where multiple scheduling policies are defined, this value
+     * represents the minimum valid priority for the scheduling policy of
+     * the process.
+     */
+    __gshared const int PRIORITY_MIN;
+
+
+    /**
+     * The maximum scheduling priority that may be set for a thread.  On
+     * systems where multiple scheduling policies are defined, this value
+     * represents the maximum valid priority for the scheduling policy of
+     * the process.
+     */
+    __gshared const int PRIORITY_MAX;
+
+
+    /**
+     * The default scheduling priority that is set for a thread.  On
+     * systems where multiple scheduling policies are defined, this value
+     * represents the default priority for the scheduling policy of
+     * the process.
+     */
+    __gshared const int PRIORITY_DEFAULT;
+
+
+    /**
+     * Gets the scheduling priority for the associated thread.
+     *
+     * Note: Getting the priority of a thread that already terminated
+     * might return the default priority.
+     *
+     * Returns:
+     *  The scheduling priority of this thread.
+     */
+    final @property int priority()
+    {
+        version( Windows )
+        {
+            return GetThreadPriority( m_hndl );
+        }
+        else version( Posix )
+        {
+            int         policy;
+            sched_param param;
+
+            if (auto err = pthread_getschedparam(m_addr, &policy, &param))
+            {
+                // ignore error if thread is not running => Bugzilla 8960
+                if (!atomicLoad(m_isRunning)) return PRIORITY_DEFAULT;
+                throw new ThreadException("Unable to get thread priority");
+            }
+            return param.sched_priority;
+        }
+    }
+
+
+    /**
+     * Sets the scheduling priority for the associated thread.
+     *
+     * Note: Setting the priority of a thread that already terminated
+     * might have no effect.
+     *
+     * Params:
+     *  val = The new scheduling priority of this thread.
+     */
+    final @property void priority( int val )
+    in
+    {
+        assert(val >= PRIORITY_MIN);
+        assert(val <= PRIORITY_MAX);
+    }
+    body
+    {
+        version( Windows )
+        {
+            if( !SetThreadPriority( m_hndl, val ) )
+                throw new ThreadException( "Unable to set thread priority" );
+        }
+        else version( Solaris )
+        {
+            // the pthread_setschedprio(3c) and pthread_setschedparam functions
+            // are broken for the default (TS / time sharing) scheduling class.
+            // instead, we use priocntl(2) which gives us the desired behavior.
+
+            // We hardcode the min and max priorities to the current value
+            // so this is a no-op for RT threads.
+            if (m_isRTClass)
+                return;
+
+            pcparms_t   pcparm;
+
+            pcparm.pc_cid = PC_CLNULL;
+            if (priocntl(idtype_t.P_LWPID, P_MYID, PC_GETPARMS, &pcparm) == -1)
+                throw new ThreadException( "Unable to get scheduling class" );
+
+            pri_t* clparms = cast(pri_t*)&pcparm.pc_clparms;
+
+            // clparms is filled in by the PC_GETPARMS call, only necessary
+            // to adjust the element that contains the thread priority
+            clparms[1] = cast(pri_t) val;
+
+            if (priocntl(idtype_t.P_LWPID, P_MYID, PC_SETPARMS, &pcparm) == -1)
+                throw new ThreadException( "Unable to set scheduling class" );
+        }
+        else version( Posix )
+        {
+            static if(__traits(compiles, pthread_setschedprio))
+            {
+                if (auto err = pthread_setschedprio(m_addr, val))
+                {
+                    // ignore error if thread is not running => Bugzilla 8960
+                    if (!atomicLoad(m_isRunning)) return;
+                    throw new ThreadException("Unable to set thread priority");
+                }
+            }
+            else
+            {
+                // NOTE: pthread_setschedprio is not implemented on OSX or FreeBSD, so use
+                //       the more complicated get/set sequence below.
+                int         policy;
+                sched_param param;
+
+                if (auto err = pthread_getschedparam(m_addr, &policy, &param))
+                {
+                    // ignore error if thread is not running => Bugzilla 8960
+                    if (!atomicLoad(m_isRunning)) return;
+                    throw new ThreadException("Unable to set thread priority");
+                }
+                param.sched_priority = val;
+                if (auto err = pthread_setschedparam(m_addr, policy, &param))
+                {
+                    // ignore error if thread is not running => Bugzilla 8960
+                    if (!atomicLoad(m_isRunning)) return;
+                    throw new ThreadException("Unable to set thread priority");
+                }
+            }
+        }
+    }
+
+
+    unittest
+    {
+        auto thr = Thread.getThis();
+        immutable prio = thr.priority;
+        scope (exit) thr.priority = prio;
+
+        assert(prio == PRIORITY_DEFAULT);
+        assert(prio >= PRIORITY_MIN && prio <= PRIORITY_MAX);
+        thr.priority = PRIORITY_MIN;
+        assert(thr.priority == PRIORITY_MIN);
+        thr.priority = PRIORITY_MAX;
+        assert(thr.priority == PRIORITY_MAX);
+    }
+
+    unittest // Bugzilla 8960
+    {
+        import core.sync.semaphore;
+
+        auto thr = new Thread({});
+        thr.start();
+        Thread.sleep(1.msecs);       // wait a little so the thread likely has finished
+        thr.priority = PRIORITY_MAX; // setting priority doesn't cause error
+        auto prio = thr.priority;    // getting priority doesn't cause error
+        assert(prio >= PRIORITY_MIN && prio <= PRIORITY_MAX);
+    }
+
+    ///////////////////////////////////////////////////////////////////////////
+    // Actions on Calling Thread
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Suspends the calling thread for at least the supplied period.  This may
+     * result in multiple OS calls if period is greater than the maximum sleep
+     * duration supported by the operating system.
+     *
+     * Params:
+     *  val = The minimum duration the calling thread should be suspended.
+     *
+     * In:
+     *  period must be non-negative.
+     *
+     * Example:
+     * ------------------------------------------------------------------------
+     *
+     * Thread.sleep( dur!("msecs")( 50 ) );  // sleep for 50 milliseconds
+     * Thread.sleep( dur!("seconds")( 5 ) ); // sleep for 5 seconds
+     *
+     * ------------------------------------------------------------------------
+     */
+    static void sleep( Duration val ) @nogc nothrow
+    in
+    {
+        assert( !val.isNegative );
+    }
+    body
+    {
+        version( Windows )
+        {
+            auto maxSleepMillis = dur!("msecs")( uint.max - 1 );
+
+            // avoid a non-zero time to be round down to 0
+            if( val > dur!"msecs"( 0 ) && val < dur!"msecs"( 1 ) )
+                val = dur!"msecs"( 1 );
+
+            // NOTE: In instances where all other threads in the process have a
+            //       lower priority than the current thread, the current thread
+            //       will not yield with a sleep time of zero.  However, unlike
+            //       yield(), the user is not asking for a yield to occur but
+            //       only for execution to suspend for the requested interval.
+            //       Therefore, expected performance may not be met if a yield
+            //       is forced upon the user.
+            while( val > maxSleepMillis )
+            {
+                Sleep( cast(uint)
+                       maxSleepMillis.total!"msecs" );
+                val -= maxSleepMillis;
+            }
+            Sleep( cast(uint) val.total!"msecs" );
+        }
+        else version( Posix )
+        {
+            timespec tin  = void;
+            timespec tout = void;
+
+            val.split!("seconds", "nsecs")(tin.tv_sec, tin.tv_nsec);
+            if( val.total!"seconds" > tin.tv_sec.max )
+                tin.tv_sec  = tin.tv_sec.max;
+            while( true )
+            {
+                if( !nanosleep( &tin, &tout ) )
+                    return;
+                if( errno != EINTR )
+                    assert(0, "Unable to sleep for the specified duration");
+                tin = tout;
+            }
+        }
+    }
+
+
+    /**
+     * Forces a context switch to occur away from the calling thread.
+     */
+    static void yield() @nogc nothrow
+    {
+        version( Windows )
+            SwitchToThread();
+        else version( Posix )
+            sched_yield();
+    }
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // Thread Accessors
+    ///////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Provides a reference to the calling thread.
+     *
+     * Returns:
+     *  The thread object representing the calling thread.  The result of
+     *  deleting this object is undefined.  If the current thread is not
+     *  attached to the runtime, a null reference is returned.
+     */
+    static Thread getThis() nothrow
+    {
+        // NOTE: This function may not be called until thread_init has
+        //       completed.  See thread_suspendAll for more information
+        //       on why this might occur.
+        return sm_this;
+    }
+
+
+    /**
+     * Provides a list of all threads currently being tracked by the system.
+     * Note that threads in the returned array might no longer run (see
+     * $(D Thread.)$(LREF isRunning)).
+     *
+     * Returns:
+     *  An array containing references to all threads currently being
+     *  tracked by the system.  The result of deleting any contained
+     *  objects is undefined.
+     */
+    static Thread[] getAll()
+    {
+        static void resize(ref Thread[] buf, size_t nlen)
+        {
+            buf.length = nlen;
+        }
+        return getAllImpl!resize();
+    }
+
+
+    /**
+     * Operates on all threads currently being tracked by the system.  The
+     * result of deleting any Thread object is undefined.
+     * Note that threads passed to the callback might no longer run (see
+     * $(D Thread.)$(LREF isRunning)).
+     *
+     * Params:
+     *  dg = The supplied code as a delegate.
+     *
+     * Returns:
+     *  Zero if all elemented are visited, nonzero if not.
+     */
+    static int opApply(scope int delegate(ref Thread) dg)
+    {
+        import core.stdc.stdlib : free, realloc;
+
+        static void resize(ref Thread[] buf, size_t nlen)
+        {
+            buf = (cast(Thread*)realloc(buf.ptr, nlen * Thread.sizeof))[0 .. nlen];
+        }
+        auto buf = getAllImpl!resize;
+        scope(exit) if (buf.ptr) free(buf.ptr);
+
+        foreach (t; buf)
+        {
+            if (auto res = dg(t))
+                return res;
+        }
+        return 0;
+    }
+
+    unittest
+    {
+        auto t1 = new Thread({
+            foreach (_; 0 .. 20)
+                Thread.getAll;
+        }).start;
+        auto t2 = new Thread({
+            foreach (_; 0 .. 20)
+                GC.collect;
+        }).start;
+        t1.join();
+        t2.join();
+    }
+
+    private static Thread[] getAllImpl(alias resize)()
+    {
+        import core.atomic;
+
+        Thread[] buf;
+        while (true)
+        {
+            immutable len = atomicLoad!(MemoryOrder.raw)(*cast(shared)&sm_tlen);
+            resize(buf, len);
+            assert(buf.length == len);
+            synchronized (slock)
+            {
+                if (len == sm_tlen)
+                {
+                    size_t pos;
+                    for (Thread t = sm_tbeg; t; t = t.next)
+                        buf[pos++] = t;
+                    return buf;
+                }
+            }
+        }
+    }
+
+    ///////////////////////////////////////////////////////////////////////////
+    // Static Initalizer
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * This initializer is used to set thread constants.  All functional
+     * initialization occurs within thread_init().
+     */
+    shared static this()
+    {
+        version( Windows )
+        {
+            PRIORITY_MIN = THREAD_PRIORITY_IDLE;
+            PRIORITY_DEFAULT = THREAD_PRIORITY_NORMAL;
+            PRIORITY_MAX = THREAD_PRIORITY_TIME_CRITICAL;
+        }
+        else version( Solaris )
+        {
+            pcparms_t pcParms;
+            pcinfo_t pcInfo;
+
+            pcParms.pc_cid = PC_CLNULL;
+            if (priocntl(idtype_t.P_PID, P_MYID, PC_GETPARMS, &pcParms) == -1)
+                throw new ThreadException( "Unable to get scheduling class" );
+
+            pcInfo.pc_cid = pcParms.pc_cid;
+            // PC_GETCLINFO ignores the first two args, use dummy values
+            if (priocntl(idtype_t.P_PID, 0, PC_GETCLINFO, &pcInfo) == -1)
+                throw new ThreadException( "Unable to get scheduling class info" );
+
+            pri_t* clparms = cast(pri_t*)&pcParms.pc_clparms;
+            pri_t* clinfo = cast(pri_t*)&pcInfo.pc_clinfo;
+
+            if (pcInfo.pc_clname == "RT")
+            {
+                m_isRTClass = true;
+
+                // For RT class, just assume it can't be changed
+                PRIORITY_MAX = clparms[0];
+                PRIORITY_MIN = clparms[0];
+                PRIORITY_DEFAULT = clparms[0];
+            }
+            else
+            {
+                m_isRTClass = false;
+
+                // For all other scheduling classes, there are
+                // two key values -- uprilim and maxupri.
+                // maxupri is the maximum possible priority defined
+                // for the scheduling class, and valid priorities
+                // range are in [-maxupri, maxupri].
+                //
+                // However, uprilim is an upper limit that the
+                // current thread can set for the current scheduling
+                // class, which can be less than maxupri.  As such,
+                // use this value for PRIORITY_MAX since this is
+                // the effective maximum.
+
+                // uprilim
+                PRIORITY_MAX = clparms[0];
+
+                // maxupri
+                PRIORITY_MIN = -clinfo[0];
+
+                // by definition
+                PRIORITY_DEFAULT = 0;
+            }
+        }
+        else version( Posix )
+        {
+            int         policy;
+            sched_param param;
+            pthread_t   self = pthread_self();
+
+            int status = pthread_getschedparam( self, &policy, &param );
+            assert( status == 0 );
+
+            PRIORITY_MIN = sched_get_priority_min( policy );
+            assert( PRIORITY_MIN != -1 );
+
+            PRIORITY_DEFAULT = param.sched_priority;
+
+            PRIORITY_MAX = sched_get_priority_max( policy );
+            assert( PRIORITY_MAX != -1 );
+        }
+    }
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // Stuff That Should Go Away
+    ///////////////////////////////////////////////////////////////////////////
+
+
+private:
+    //
+    // Initializes a thread object which has no associated executable function.
+    // This is used for the main thread initialized in thread_init().
+    //
+    this(size_t sz = 0)
+    {
+        if (sz)
+        {
+            version (Posix)
+            {
+                // stack size must be a multiple of PAGESIZE
+                sz += PAGESIZE - 1;
+                sz -= sz % PAGESIZE;
+                // and at least PTHREAD_STACK_MIN
+                if (PTHREAD_STACK_MIN > sz)
+                    sz = PTHREAD_STACK_MIN;
+            }
+            m_sz = sz;
+        }
+        m_call = Call.NO;
+        m_curr = &m_main;
+    }
+
+
+    //
+    // Thread entry point.  Invokes the function or delegate passed on
+    // construction (if any).
+    //
+    final void run()
+    {
+        switch( m_call )
+        {
+        case Call.FN:
+            m_fn();
+            break;
+        case Call.DG:
+            m_dg();
+            break;
+        default:
+            break;
+        }
+    }
+
+
+private:
+    //
+    // The type of routine passed on thread construction.
+    //
+    enum Call
+    {
+        NO,
+        FN,
+        DG
+    }
+
+
+    //
+    // Standard types
+    //
+    version( Windows )
+    {
+        alias uint TLSKey;
+    }
+    else version( Posix )
+    {
+        alias pthread_key_t TLSKey;
+    }
+
+
+    //
+    // Local storage
+    //
+    static Thread       sm_this;
+
+
+    //
+    // Main process thread
+    //
+    __gshared Thread    sm_main;
+
+    version (FreeBSD)
+    {
+        // set when suspend failed and should be retried, see Issue 13416
+        shared bool m_suspendagain;
+    }
+
+
+    //
+    // Standard thread data
+    //
+    version( Windows )
+    {
+        HANDLE          m_hndl;
+    }
+    else version( OSX )
+    {
+        mach_port_t     m_tmach;
+    }
+    ThreadID            m_addr;
+    Call                m_call;
+    string              m_name;
+    union
+    {
+        void function() m_fn;
+        void delegate() m_dg;
+    }
+    size_t              m_sz;
+    version( Posix )
+    {
+        shared bool     m_isRunning;
+    }
+    bool                m_isDaemon;
+    bool                m_isInCriticalRegion;
+    Throwable           m_unhandled;
+
+    version( Solaris )
+    {
+        __gshared immutable bool m_isRTClass;
+    }
+
+private:
+    ///////////////////////////////////////////////////////////////////////////
+    // Storage of Active Thread
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    //
+    // Sets a thread-local reference to the current thread object.
+    //
+    static void setThis( Thread t )
+    {
+        sm_this = t;
+    }
+
+
+private:
+    ///////////////////////////////////////////////////////////////////////////
+    // Thread Context and GC Scanning Support
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    final void pushContext( Context* c ) nothrow
+    in
+    {
+        assert( !c.within );
+    }
+    body
+    {
+        m_curr.ehContext = swapContext(c.ehContext);
+        c.within = m_curr;
+        m_curr = c;
+    }
+
+
+    final void popContext() nothrow
+    in
+    {
+        assert( m_curr && m_curr.within );
+    }
+    body
+    {
+        Context* c = m_curr;
+        m_curr = c.within;
+        c.ehContext = swapContext(m_curr.ehContext);
+        c.within = null;
+    }
+
+
+    final Context* topContext() nothrow
+    in
+    {
+        assert( m_curr );
+    }
+    body
+    {
+        return m_curr;
+    }
+
+
+    static struct Context
+    {
+        void*           bstack,
+                        tstack;
+
+        /// Slot for the EH implementation to keep some state for each stack
+        /// (will be necessary for exception chaining, etc.). Opaque as far as
+        /// we are concerned here.
+        void*           ehContext;
+
+        Context*        within;
+        Context*        next,
+                        prev;
+    }
+
+
+    Context             m_main;
+    Context*            m_curr;
+    bool                m_lock;
+    void*               m_tlsgcdata;
+
+    version( Windows )
+    {
+      version( X86 )
+      {
+        uint[8]         m_reg; // edi,esi,ebp,esp,ebx,edx,ecx,eax
+      }
+      else version( X86_64 )
+      {
+        ulong[16]       m_reg; // rdi,rsi,rbp,rsp,rbx,rdx,rcx,rax
+                               // r8,r9,r10,r11,r12,r13,r14,r15
+      }
+      else
+      {
+        static assert(false, "Architecture not supported." );
+      }
+    }
+    else version( OSX )
+    {
+      version( X86 )
+      {
+        uint[8]         m_reg; // edi,esi,ebp,esp,ebx,edx,ecx,eax
+      }
+      else version( X86_64 )
+      {
+        ulong[16]       m_reg; // rdi,rsi,rbp,rsp,rbx,rdx,rcx,rax
+                               // r8,r9,r10,r11,r12,r13,r14,r15
+      }
+      else
+      {
+        static assert(false, "Architecture not supported." );
+      }
+    }
+
+
+private:
+    ///////////////////////////////////////////////////////////////////////////
+    // GC Scanning Support
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    // NOTE: The GC scanning process works like so:
+    //
+    //          1. Suspend all threads.
+    //          2. Scan the stacks of all suspended threads for roots.
+    //          3. Resume all threads.
+    //
+    //       Step 1 and 3 require a list of all threads in the system, while
+    //       step 2 requires a list of all thread stacks (each represented by
+    //       a Context struct).  Traditionally, there was one stack per thread
+    //       and the Context structs were not necessary.  However, Fibers have
+    //       changed things so that each thread has its own 'main' stack plus
+    //       an arbitrary number of nested stacks (normally referenced via
+    //       m_curr).  Also, there may be 'free-floating' stacks in the system,
+    //       which are Fibers that are not currently executing on any specific
+    //       thread but are still being processed and still contain valid
+    //       roots.
+    //
+    //       To support all of this, the Context struct has been created to
+    //       represent a stack range, and a global list of Context structs has
+    //       been added to enable scanning of these stack ranges.  The lifetime
+    //       (and presence in the Context list) of a thread's 'main' stack will
+    //       be equivalent to the thread's lifetime.  So the Ccontext will be
+    //       added to the list on thread entry, and removed from the list on
+    //       thread exit (which is essentially the same as the presence of a
+    //       Thread object in its own global list).  The lifetime of a Fiber's
+    //       context, however, will be tied to the lifetime of the Fiber object
+    //       itself, and Fibers are expected to add/remove their Context struct
+    //       on construction/deletion.
+
+
+    //
+    // All use of the global thread lists/array should synchronize on this lock.
+    //
+    // Careful as the GC acquires this lock after the GC lock to suspend all
+    // threads any GC usage with slock held can result in a deadlock through
+    // lock order inversion.
+    @property static Mutex slock() nothrow
+    {
+        return cast(Mutex)_locks[0].ptr;
+    }
+
+    @property static Mutex criticalRegionLock() nothrow
+    {
+        return cast(Mutex)_locks[1].ptr;
+    }
+
+    __gshared void[__traits(classInstanceSize, Mutex)][2] _locks;
+
+    static void initLocks()
+    {
+        foreach (ref lock; _locks)
+        {
+            lock[] = typeid(Mutex).initializer[];
+            (cast(Mutex)lock.ptr).__ctor();
+        }
+    }
+
+    static void termLocks()
+    {
+        foreach (ref lock; _locks)
+            (cast(Mutex)lock.ptr).__dtor();
+    }
+
+    __gshared Context*  sm_cbeg;
+
+    __gshared Thread    sm_tbeg;
+    __gshared size_t    sm_tlen;
+
+    // can't use rt.util.array in public code
+    __gshared Thread* pAboutToStart;
+    __gshared size_t nAboutToStart;
+
+    //
+    // Used for ordering threads in the global thread list.
+    //
+    Thread              prev;
+    Thread              next;
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // Global Context List Operations
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    //
+    // Add a context to the global context list.
+    //
+    static void add( Context* c ) nothrow
+    in
+    {
+        assert( c );
+        assert( !c.next && !c.prev );
+    }
+    body
+    {
+        slock.lock_nothrow();
+        scope(exit) slock.unlock_nothrow();
+        assert(!suspendDepth); // must be 0 b/c it's only set with slock held
+
+        if (sm_cbeg)
+        {
+            c.next = sm_cbeg;
+            sm_cbeg.prev = c;
+        }
+        sm_cbeg = c;
+    }
+
+
+    //
+    // Remove a context from the global context list.
+    //
+    // This assumes slock being acquired. This isn't done here to
+    // avoid double locking when called from remove(Thread)
+    static void remove( Context* c ) nothrow
+    in
+    {
+        assert( c );
+        assert( c.next || c.prev );
+    }
+    body
+    {
+        if( c.prev )
+            c.prev.next = c.next;
+        if( c.next )
+            c.next.prev = c.prev;
+        if( sm_cbeg == c )
+            sm_cbeg = c.next;
+        // NOTE: Don't null out c.next or c.prev because opApply currently
+        //       follows c.next after removing a node.  This could be easily
+        //       addressed by simply returning the next node from this
+        //       function, however, a context should never be re-added to the
+        //       list anyway and having next and prev be non-null is a good way
+        //       to ensure that.
+    }
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // Global Thread List Operations
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    //
+    // Add a thread to the global thread list.
+    //
+    static void add( Thread t, bool rmAboutToStart = true ) nothrow
+    in
+    {
+        assert( t );
+        assert( !t.next && !t.prev );
+    }
+    body
+    {
+        slock.lock_nothrow();
+        scope(exit) slock.unlock_nothrow();
+        assert(t.isRunning); // check this with slock to ensure pthread_create already returned
+        assert(!suspendDepth); // must be 0 b/c it's only set with slock held
+
+        if (rmAboutToStart)
+        {
+            size_t idx = -1;
+            foreach (i, thr; pAboutToStart[0 .. nAboutToStart])
+            {
+                if (thr is t)
+                {
+                    idx = i;
+                    break;
+                }
+            }
+            assert(idx != -1);
+            import core.stdc.string : memmove;
+            memmove(pAboutToStart + idx, pAboutToStart + idx + 1, Thread.sizeof * (nAboutToStart - idx - 1));
+            pAboutToStart =
+                cast(Thread*)realloc(pAboutToStart, Thread.sizeof * --nAboutToStart);
+        }
+
+        if (sm_tbeg)
+        {
+            t.next = sm_tbeg;
+            sm_tbeg.prev = t;
+        }
+        sm_tbeg = t;
+        ++sm_tlen;
+    }
+
+
+    //
+    // Remove a thread from the global thread list.
+    //
+    static void remove( Thread t ) nothrow
+    in
+    {
+        assert( t );
+    }
+    body
+    {
+        // Thread was already removed earlier, might happen b/c of thread_detachInstance
+        if (!t.next && !t.prev)
+            return;
+        slock.lock_nothrow();
+        {
+            // NOTE: When a thread is removed from the global thread list its
+            //       main context is invalid and should be removed as well.
+            //       It is possible that t.m_curr could reference more
+            //       than just the main context if the thread exited abnormally
+            //       (if it was terminated), but we must assume that the user
+            //       retains a reference to them and that they may be re-used
+            //       elsewhere.  Therefore, it is the responsibility of any
+            //       object that creates contexts to clean them up properly
+            //       when it is done with them.
+            remove( &t.m_main );
+
+            if( t.prev )
+                t.prev.next = t.next;
+            if( t.next )
+                t.next.prev = t.prev;
+            if( sm_tbeg is t )
+                sm_tbeg = t.next;
+            t.prev = t.next = null;
+            --sm_tlen;
+        }
+        // NOTE: Don't null out t.next or t.prev because opApply currently
+        //       follows t.next after removing a node.  This could be easily
+        //       addressed by simply returning the next node from this
+        //       function, however, a thread should never be re-added to the
+        //       list anyway and having next and prev be non-null is a good way
+        //       to ensure that.
+        slock.unlock_nothrow();
+    }
+}
+
+///
+unittest
+{
+    class DerivedThread : Thread
+    {
+        this()
+        {
+            super(&run);
+        }
+
+    private:
+        void run()
+        {
+            // Derived thread running.
+        }
+    }
+
+    void threadFunc()
+    {
+        // Composed thread running.
+    }
+
+    // create and start instances of each type
+    auto derived = new DerivedThread().start();
+    auto composed = new Thread(&threadFunc).start();
+    new Thread({
+        // Codes to run in the newly created thread.
+    }).start();
+}
+
+unittest
+{
+    int x = 0;
+
+    new Thread(
+    {
+        x++;
+    }).start().join();
+    assert( x == 1 );
+}
+
+
+unittest
+{
+    enum MSG = "Test message.";
+    string caughtMsg;
+
+    try
+    {
+        new Thread(
+        {
+            throw new Exception( MSG );
+        }).start().join();
+        assert( false, "Expected rethrown exception." );
+    }
+    catch( Throwable t )
+    {
+        assert( t.msg == MSG );
+    }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// GC Support Routines
+///////////////////////////////////////////////////////////////////////////////
+
+version( CoreDdoc )
+{
+    /**
+     * Instruct the thread module, when initialized, to use a different set of
+     * signals besides SIGUSR1 and SIGUSR2 for suspension and resumption of threads.
+     * This function should be called at most once, prior to thread_init().
+     * This function is Posix-only.
+     */
+    extern (C) void thread_setGCSignals(int suspendSignalNo, int resumeSignalNo)
+    {
+    }
+}
+else version( Posix )
+{
+    extern (C) void thread_setGCSignals(int suspendSignalNo, int resumeSignalNo)
+    in
+    {
+        assert(suspendSignalNumber == 0);
+        assert(resumeSignalNumber  == 0);
+        assert(suspendSignalNo != 0);
+        assert(resumeSignalNo  != 0);
+    }
+    out
+    {
+        assert(suspendSignalNumber != 0);
+        assert(resumeSignalNumber  != 0);
+    }
+    body
+    {
+        suspendSignalNumber = suspendSignalNo;
+        resumeSignalNumber  = resumeSignalNo;
+    }
+}
+
+version( Posix )
+{
+    __gshared int suspendSignalNumber;
+    __gshared int resumeSignalNumber;
+}
+
+/**
+ * Initializes the thread module.  This function must be called by the
+ * garbage collector on startup and before any other thread routines
+ * are called.
+ */
+extern (C) void thread_init()
+{
+    // NOTE: If thread_init itself performs any allocations then the thread
+    //       routines reserved for garbage collector use may be called while
+    //       thread_init is being processed.  However, since no memory should
+    //       exist to be scanned at this point, it is sufficient for these
+    //       functions to detect the condition and return immediately.
+
+    Thread.initLocks();
+
+    version( OSX )
+    {
+    }
+    else version( Posix )
+    {
+        if( suspendSignalNumber == 0 )
+        {
+            suspendSignalNumber = SIGUSR1;
+        }
+
+        if( resumeSignalNumber == 0 )
+        {
+            resumeSignalNumber = SIGUSR2;
+        }
+
+        int         status;
+        sigaction_t sigusr1 = void;
+        sigaction_t sigusr2 = void;
+
+        // This is a quick way to zero-initialize the structs without using
+        // memset or creating a link dependency on their static initializer.
+        (cast(byte*) &sigusr1)[0 .. sigaction_t.sizeof] = 0;
+        (cast(byte*) &sigusr2)[0 .. sigaction_t.sizeof] = 0;
+
+        // NOTE: SA_RESTART indicates that system calls should restart if they
+        //       are interrupted by a signal, but this is not available on all
+        //       Posix systems, even those that support multithreading.
+        static if( __traits( compiles, SA_RESTART ) )
+            sigusr1.sa_flags = SA_RESTART;
+        else
+            sigusr1.sa_flags   = 0;
+        sigusr1.sa_handler = &thread_suspendHandler;
+        // NOTE: We want to ignore all signals while in this handler, so fill
+        //       sa_mask to indicate this.
+        status = sigfillset( &sigusr1.sa_mask );
+        assert( status == 0 );
+
+        // NOTE: Since resumeSignalNumber should only be issued for threads within the
+        //       suspend handler, we don't want this signal to trigger a
+        //       restart.
+        sigusr2.sa_flags   = 0;
+        sigusr2.sa_handler = &thread_resumeHandler;
+        // NOTE: We want to ignore all signals while in this handler, so fill
+        //       sa_mask to indicate this.
+        status = sigfillset( &sigusr2.sa_mask );
+        assert( status == 0 );
+
+        status = sigaction( suspendSignalNumber, &sigusr1, null );
+        assert( status == 0 );
+
+        status = sigaction( resumeSignalNumber, &sigusr2, null );
+        assert( status == 0 );
+
+        status = sem_init( &suspendCount, 0, 0 );
+        assert( status == 0 );
+    }
+    Thread.sm_main = thread_attachThis();
+}
+
+
+/**
+ * Terminates the thread module. No other thread routine may be called
+ * afterwards.
+ */
+extern (C) void thread_term()
+{
+    assert(Thread.sm_tbeg && Thread.sm_tlen == 1);
+    assert(!Thread.nAboutToStart);
+    if (Thread.pAboutToStart) // in case realloc(p, 0) doesn't return null
+    {
+        free(Thread.pAboutToStart);
+        Thread.pAboutToStart = null;
+    }
+    Thread.termLocks();
+}
+
+
+/**
+ *
+ */
+extern (C) bool thread_isMainThread()
+{
+    return Thread.getThis() is Thread.sm_main;
+}
+
+
+/**
+ * Registers the calling thread for use with the D Runtime.  If this routine
+ * is called for a thread which is already registered, no action is performed.
+ *
+ * NOTE: This routine does not run thread-local static constructors when called.
+ *       If full functionality as a D thread is desired, the following function
+ *       must be called after thread_attachThis:
+ *
+ *       extern (C) void rt_moduleTlsCtor();
+ */
+extern (C) Thread thread_attachThis()
+{
+    GC.disable(); scope(exit) GC.enable();
+
+    if (auto t = Thread.getThis())
+        return t;
+
+    Thread          thisThread  = new Thread();
+    Thread.Context* thisContext = &thisThread.m_main;
+    assert( thisContext == thisThread.m_curr );
+
+    version( Windows )
+    {
+        thisThread.m_addr  = GetCurrentThreadId();
+        thisThread.m_hndl  = GetCurrentThreadHandle();
+        thisContext.bstack = getStackBottom();
+        thisContext.tstack = thisContext.bstack;
+    }
+    else version( Posix )
+    {
+        thisThread.m_addr  = pthread_self();
+        thisContext.bstack = getStackBottom();
+        thisContext.tstack = thisContext.bstack;
+
+        atomicStore!(MemoryOrder.raw)(thisThread.m_isRunning, true);
+    }
+    thisThread.m_isDaemon = true;
+    thisThread.m_tlsgcdata = rt_tlsgc_init();
+    Thread.setThis( thisThread );
+
+    version( OSX )
+    {
+        thisThread.m_tmach = pthread_mach_thread_np( thisThread.m_addr );
+        assert( thisThread.m_tmach != thisThread.m_tmach.init );
+    }
+
+    Thread.add( thisThread, false );
+    Thread.add( thisContext );
+    if( Thread.sm_main !is null )
+        multiThreadedFlag = true;
+    return thisThread;
+}
+
+
+version( Windows )
+{
+    // NOTE: These calls are not safe on Posix systems that use signals to
+    //       perform garbage collection.  The suspendHandler uses getThis()
+    //       to get the thread handle so getThis() must be a simple call.
+    //       Mutexes can't safely be acquired inside signal handlers, and
+    //       even if they could, the mutex needed (Thread.slock) is held by
+    //       thread_suspendAll().  So in short, these routines will remain
+    //       Windows-specific.  If they are truly needed elsewhere, the
+    //       suspendHandler will need a way to call a version of getThis()
+    //       that only does the TLS lookup without the fancy fallback stuff.
+
+    /// ditto
+    extern (C) Thread thread_attachByAddr( ThreadID addr )
+    {
+        return thread_attachByAddrB( addr, getThreadStackBottom( addr ) );
+    }
+
+
+    /// ditto
+    extern (C) Thread thread_attachByAddrB( ThreadID addr, void* bstack )
+    {
+        GC.disable(); scope(exit) GC.enable();
+
+        if (auto t = thread_findByAddr(addr))
+            return t;
+
+        Thread          thisThread  = new Thread();
+        Thread.Context* thisContext = &thisThread.m_main;
+        assert( thisContext == thisThread.m_curr );
+
+        thisThread.m_addr  = addr;
+        thisContext.bstack = bstack;
+        thisContext.tstack = thisContext.bstack;
+
+        thisThread.m_isDaemon = true;
+
+        if( addr == GetCurrentThreadId() )
+        {
+            thisThread.m_hndl = GetCurrentThreadHandle();
+            thisThread.m_tlsgcdata = rt_tlsgc_init();
+            Thread.setThis( thisThread );
+        }
+        else
+        {
+            thisThread.m_hndl = OpenThreadHandle( addr );
+            impersonate_thread(addr,
+            {
+                thisThread.m_tlsgcdata = rt_tlsgc_init();
+                Thread.setThis( thisThread );
+            });
+        }
+
+        Thread.add( thisThread, false );
+        Thread.add( thisContext );
+        if( Thread.sm_main !is null )
+            multiThreadedFlag = true;
+        return thisThread;
+    }
+}
+
+
+/**
+ * Deregisters the calling thread from use with the runtime.  If this routine
+ * is called for a thread which is not registered, the result is undefined.
+ *
+ * NOTE: This routine does not run thread-local static destructors when called.
+ *       If full functionality as a D thread is desired, the following function
+ *       must be called after thread_detachThis, particularly if the thread is
+ *       being detached at some indeterminate time before program termination:
+ *
+ *       $(D extern(C) void rt_moduleTlsDtor();)
+ */
+extern (C) void thread_detachThis() nothrow
+{
+    if (auto t = Thread.getThis())
+        Thread.remove(t);
+}
+
+
+/**
+ * Deregisters the given thread from use with the runtime.  If this routine
+ * is called for a thread which is not registered, the result is undefined.
+ *
+ * NOTE: This routine does not run thread-local static destructors when called.
+ *       If full functionality as a D thread is desired, the following function
+ *       must be called by the detached thread, particularly if the thread is
+ *       being detached at some indeterminate time before program termination:
+ *
+ *       $(D extern(C) void rt_moduleTlsDtor();)
+ */
+extern (C) void thread_detachByAddr( ThreadID addr )
+{
+    if( auto t = thread_findByAddr( addr ) )
+        Thread.remove( t );
+}
+
+
+/// ditto
+extern (C) void thread_detachInstance( Thread t )
+{
+    Thread.remove( t );
+}
+
+
+unittest
+{
+    import core.sync.semaphore;
+    auto sem = new Semaphore();
+
+    auto t = new Thread(
+    {
+        sem.notify();
+        Thread.sleep(100.msecs);
+    }).start();
+
+    sem.wait(); // thread cannot be detached while being started
+    thread_detachInstance(t);
+    foreach (t2; Thread)
+        assert(t !is t2);
+    t.join();
+}
+
+
+/**
+ * Search the list of all threads for a thread with the given thread identifier.
+ *
+ * Params:
+ *  addr = The thread identifier to search for.
+ * Returns:
+ *  The thread object associated with the thread identifier, null if not found.
+ */
+static Thread thread_findByAddr( ThreadID addr )
+{
+    Thread.slock.lock_nothrow();
+    scope(exit) Thread.slock.unlock_nothrow();
+
+    // also return just spawned thread so that
+    // DLL_THREAD_ATTACH knows it's a D thread
+    foreach (t; Thread.pAboutToStart[0 .. Thread.nAboutToStart])
+        if (t.m_addr == addr)
+            return t;
+
+    foreach (t; Thread)
+        if (t.m_addr == addr)
+            return t;
+
+    return null;
+}
+
+
+/**
+ * Sets the current thread to a specific reference. Only to be used
+ * when dealing with externally-created threads (in e.g. C code).
+ * The primary use of this function is when Thread.getThis() must
+ * return a sensible value in, for example, TLS destructors. In
+ * other words, don't touch this unless you know what you're doing.
+ *
+ * Params:
+ *  t = A reference to the current thread. May be null.
+ */
+extern (C) void thread_setThis(Thread t)
+{
+    Thread.setThis(t);
+}
+
+
+/**
+ * Joins all non-daemon threads that are currently running.  This is done by
+ * performing successive scans through the thread list until a scan consists
+ * of only daemon threads.
+ */
+extern (C) void thread_joinAll()
+{
+ Lagain:
+    Thread.slock.lock_nothrow();
+    // wait for just spawned threads
+    if (Thread.nAboutToStart)
+    {
+        Thread.slock.unlock_nothrow();
+        Thread.yield();
+        goto Lagain;
+    }
+
+    // join all non-daemon threads, the main thread is also a daemon
+    auto t = Thread.sm_tbeg;
+    while (t)
+    {
+        if (!t.isRunning)
+        {
+            auto tn = t.next;
+            Thread.remove(t);
+            t = tn;
+        }
+        else if (t.isDaemon)
+        {
+            t = t.next;
+        }
+        else
+        {
+            Thread.slock.unlock_nothrow();
+            t.join(); // might rethrow
+            goto Lagain; // must restart iteration b/c of unlock
+        }
+    }
+    Thread.slock.unlock_nothrow();
+}
+
+
+/**
+ * Performs intermediate shutdown of the thread module.
+ */
+shared static ~this()
+{
+    // NOTE: The functionality related to garbage collection must be minimally
+    //       operable after this dtor completes.  Therefore, only minimal
+    //       cleanup may occur.
+    auto t = Thread.sm_tbeg;
+    while (t)
+    {
+        auto tn = t.next;
+        if (!t.isRunning)
+            Thread.remove(t);
+        t = tn;
+    }
+}
+
+
+// Used for needLock below.
+private __gshared bool multiThreadedFlag = false;
+
+version (PPC64) version = ExternStackShell;
+
+version (ExternStackShell)
+{
+    extern(D) public void callWithStackShell(scope void delegate(void* sp) nothrow fn) nothrow;
+}
+else
+{
+    // Calls the given delegate, passing the current thread's stack pointer to it.
+    private void callWithStackShell(scope void delegate(void* sp) nothrow fn) nothrow
+    in
+    {
+        assert(fn);
+    }
+    body
+    {
+        // The purpose of the 'shell' is to ensure all the registers get
+        // put on the stack so they'll be scanned. We only need to push
+        // the callee-save registers.
+        void *sp = void;
+
+        version (GNU)
+        {
+            __builtin_unwind_init();
+            sp = &sp;
+        }
+        else version (AsmX86_Posix)
+        {
+            size_t[3] regs = void;
+            asm pure nothrow @nogc
+            {
+                mov [regs + 0 * 4], EBX;
+                mov [regs + 1 * 4], ESI;
+                mov [regs + 2 * 4], EDI;
+
+                mov sp[EBP], ESP;
+            }
+        }
+        else version (AsmX86_Windows)
+        {
+            size_t[3] regs = void;
+            asm pure nothrow @nogc
+            {
+                mov [regs + 0 * 4], EBX;
+                mov [regs + 1 * 4], ESI;
+                mov [regs + 2 * 4], EDI;
+
+                mov sp[EBP], ESP;
+            }
+        }
+        else version (AsmX86_64_Posix)
+        {
+            size_t[5] regs = void;
+            asm pure nothrow @nogc
+            {
+                mov [regs + 0 * 8], RBX;
+                mov [regs + 1 * 8], R12;
+                mov [regs + 2 * 8], R13;
+                mov [regs + 3 * 8], R14;
+                mov [regs + 4 * 8], R15;
+
+                mov sp[RBP], RSP;
+            }
+        }
+        else version (AsmX86_64_Windows)
+        {
+            size_t[7] regs = void;
+            asm pure nothrow @nogc
+            {
+                mov [regs + 0 * 8], RBX;
+                mov [regs + 1 * 8], RSI;
+                mov [regs + 2 * 8], RDI;
+                mov [regs + 3 * 8], R12;
+                mov [regs + 4 * 8], R13;
+                mov [regs + 5 * 8], R14;
+                mov [regs + 6 * 8], R15;
+
+                mov sp[RBP], RSP;
+            }
+        }
+        else
+        {
+            static assert(false, "Architecture not supported.");
+        }
+
+        fn(sp);
+    }
+}
+
+// Used for suspendAll/resumeAll below.
+private __gshared uint suspendDepth = 0;
+
+/**
+ * Suspend the specified thread and load stack and register information for
+ * use by thread_scanAll.  If the supplied thread is the calling thread,
+ * stack and register information will be loaded but the thread will not
+ * be suspended.  If the suspend operation fails and the thread is not
+ * running then it will be removed from the global thread list, otherwise
+ * an exception will be thrown.
+ *
+ * Params:
+ *  t = The thread to suspend.
+ *
+ * Throws:
+ *  ThreadError if the suspend operation fails for a running thread.
+ * Returns:
+ *  Whether the thread is now suspended (true) or terminated (false).
+ */
+private bool suspend( Thread t ) nothrow
+{
+    Duration waittime = dur!"usecs"(10);
+ Lagain:
+    if (!t.isRunning)
+    {
+        Thread.remove(t);
+        return false;
+    }
+    else if (t.m_isInCriticalRegion)
+    {
+        Thread.criticalRegionLock.unlock_nothrow();
+        Thread.sleep(waittime);
+        if (waittime < dur!"msecs"(10)) waittime *= 2;
+        Thread.criticalRegionLock.lock_nothrow();
+        goto Lagain;
+    }
+
+    version( Windows )
+    {
+        if( t.m_addr != GetCurrentThreadId() && SuspendThread( t.m_hndl ) == 0xFFFFFFFF )
+        {
+            if( !t.isRunning )
+            {
+                Thread.remove( t );
+                return false;
+            }
+            onThreadError( "Unable to suspend thread" );
+        }
+
+        CONTEXT context = void;
+        context.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL;
+
+        if( !GetThreadContext( t.m_hndl, &context ) )
+            onThreadError( "Unable to load thread context" );
+        version( X86 )
+        {
+            if( !t.m_lock )
+                t.m_curr.tstack = cast(void*) context.Esp;
+            // eax,ebx,ecx,edx,edi,esi,ebp,esp
+            t.m_reg[0] = context.Eax;
+            t.m_reg[1] = context.Ebx;
+            t.m_reg[2] = context.Ecx;
+            t.m_reg[3] = context.Edx;
+            t.m_reg[4] = context.Edi;
+            t.m_reg[5] = context.Esi;
+            t.m_reg[6] = context.Ebp;
+            t.m_reg[7] = context.Esp;
+        }
+        else version( X86_64 )
+        {
+            if( !t.m_lock )
+                t.m_curr.tstack = cast(void*) context.Rsp;
+            // rax,rbx,rcx,rdx,rdi,rsi,rbp,rsp
+            t.m_reg[0] = context.Rax;
+            t.m_reg[1] = context.Rbx;
+            t.m_reg[2] = context.Rcx;
+            t.m_reg[3] = context.Rdx;
+            t.m_reg[4] = context.Rdi;
+            t.m_reg[5] = context.Rsi;
+            t.m_reg[6] = context.Rbp;
+            t.m_reg[7] = context.Rsp;
+            // r8,r9,r10,r11,r12,r13,r14,r15
+            t.m_reg[8]  = context.R8;
+            t.m_reg[9]  = context.R9;
+            t.m_reg[10] = context.R10;
+            t.m_reg[11] = context.R11;
+            t.m_reg[12] = context.R12;
+            t.m_reg[13] = context.R13;
+            t.m_reg[14] = context.R14;
+            t.m_reg[15] = context.R15;
+        }
+        else
+        {
+            static assert(false, "Architecture not supported." );
+        }
+    }
+    else version( OSX )
+    {
+        if( t.m_addr != pthread_self() && thread_suspend( t.m_tmach ) != KERN_SUCCESS )
+        {
+            if( !t.isRunning )
+            {
+                Thread.remove( t );
+                return false;
+            }
+            onThreadError( "Unable to suspend thread" );
+        }
+
+        version( X86 )
+        {
+            x86_thread_state32_t    state = void;
+            mach_msg_type_number_t  count = x86_THREAD_STATE32_COUNT;
+
+            if( thread_get_state( t.m_tmach, x86_THREAD_STATE32, &state, &count ) != KERN_SUCCESS )
+                onThreadError( "Unable to load thread state" );
+            if( !t.m_lock )
+                t.m_curr.tstack = cast(void*) state.esp;
+            // eax,ebx,ecx,edx,edi,esi,ebp,esp
+            t.m_reg[0] = state.eax;
+            t.m_reg[1] = state.ebx;
+            t.m_reg[2] = state.ecx;
+            t.m_reg[3] = state.edx;
+            t.m_reg[4] = state.edi;
+            t.m_reg[5] = state.esi;
+            t.m_reg[6] = state.ebp;
+            t.m_reg[7] = state.esp;
+        }
+        else version( X86_64 )
+        {
+            x86_thread_state64_t    state = void;
+            mach_msg_type_number_t  count = x86_THREAD_STATE64_COUNT;
+
+            if( thread_get_state( t.m_tmach, x86_THREAD_STATE64, &state, &count ) != KERN_SUCCESS )
+                onThreadError( "Unable to load thread state" );
+            if( !t.m_lock )
+                t.m_curr.tstack = cast(void*) state.rsp;
+            // rax,rbx,rcx,rdx,rdi,rsi,rbp,rsp
+            t.m_reg[0] = state.rax;
+            t.m_reg[1] = state.rbx;
+            t.m_reg[2] = state.rcx;
+            t.m_reg[3] = state.rdx;
+            t.m_reg[4] = state.rdi;
+            t.m_reg[5] = state.rsi;
+            t.m_reg[6] = state.rbp;
+            t.m_reg[7] = state.rsp;
+            // r8,r9,r10,r11,r12,r13,r14,r15
+            t.m_reg[8]  = state.r8;
+            t.m_reg[9]  = state.r9;
+            t.m_reg[10] = state.r10;
+            t.m_reg[11] = state.r11;
+            t.m_reg[12] = state.r12;
+            t.m_reg[13] = state.r13;
+            t.m_reg[14] = state.r14;
+            t.m_reg[15] = state.r15;
+        }
+        else
+        {
+            static assert(false, "Architecture not supported." );
+        }
+    }
+    else version( Posix )
+    {
+        if( t.m_addr != pthread_self() )
+        {
+            if( pthread_kill( t.m_addr, suspendSignalNumber ) != 0 )
+            {
+                if( !t.isRunning )
+                {
+                    Thread.remove( t );
+                    return false;
+                }
+                onThreadError( "Unable to suspend thread" );
+            }
+        }
+        else if( !t.m_lock )
+        {
+            t.m_curr.tstack = getStackTop();
+        }
+    }
+    return true;
+}
+
+/**
+ * Suspend all threads but the calling thread for "stop the world" garbage
+ * collection runs.  This function may be called multiple times, and must
+ * be followed by a matching number of calls to thread_resumeAll before
+ * processing is resumed.
+ *
+ * Throws:
+ *  ThreadError if the suspend operation fails for a running thread.
+ */
+extern (C) void thread_suspendAll() nothrow
+{
+    // NOTE: We've got an odd chicken & egg problem here, because while the GC
+    //       is required to call thread_init before calling any other thread
+    //       routines, thread_init may allocate memory which could in turn
+    //       trigger a collection.  Thus, thread_suspendAll, thread_scanAll,
+    //       and thread_resumeAll must be callable before thread_init
+    //       completes, with the assumption that no other GC memory has yet
+    //       been allocated by the system, and thus there is no risk of losing
+    //       data if the global thread list is empty.  The check of
+    //       Thread.sm_tbeg below is done to ensure thread_init has completed,
+    //       and therefore that calling Thread.getThis will not result in an
+    //       error.  For the short time when Thread.sm_tbeg is null, there is
+    //       no reason not to simply call the multithreaded code below, with
+    //       the expectation that the foreach loop will never be entered.
+    if( !multiThreadedFlag && Thread.sm_tbeg )
+    {
+        if( ++suspendDepth == 1 )
+            suspend( Thread.getThis() );
+
+        return;
+    }
+
+    Thread.slock.lock_nothrow();
+    {
+        if( ++suspendDepth > 1 )
+            return;
+
+        Thread.criticalRegionLock.lock_nothrow();
+        scope (exit) Thread.criticalRegionLock.unlock_nothrow();
+        size_t cnt;
+        auto t = Thread.sm_tbeg;
+        while (t)
+        {
+            auto tn = t.next;
+            if (suspend(t))
+                ++cnt;
+            t = tn;
+        }
+
+        version (OSX)
+        {}
+        else version (Posix)
+        {
+            // subtract own thread
+            assert(cnt >= 1);
+            --cnt;
+        Lagain:
+            // wait for semaphore notifications
+            for (; cnt; --cnt)
+            {
+                while (sem_wait(&suspendCount) != 0)
+                {
+                    if (errno != EINTR)
+                        onThreadError("Unable to wait for semaphore");
+                    errno = 0;
+                }
+            }
+            version (FreeBSD)
+            {
+                // avoid deadlocks, see Issue 13416
+                t = Thread.sm_tbeg;
+                while (t)
+                {
+                    auto tn = t.next;
+                    if (t.m_suspendagain && suspend(t))
+                        ++cnt;
+                    t = tn;
+                }
+                if (cnt)
+                    goto Lagain;
+             }
+        }
+    }
+}
+
+/**
+ * Resume the specified thread and unload stack and register information.
+ * If the supplied thread is the calling thread, stack and register
+ * information will be unloaded but the thread will not be resumed.  If
+ * the resume operation fails and the thread is not running then it will
+ * be removed from the global thread list, otherwise an exception will be
+ * thrown.
+ *
+ * Params:
+ *  t = The thread to resume.
+ *
+ * Throws:
+ *  ThreadError if the resume fails for a running thread.
+ */
+private void resume( Thread t ) nothrow
+{
+    version( Windows )
+    {
+        if( t.m_addr != GetCurrentThreadId() && ResumeThread( t.m_hndl ) == 0xFFFFFFFF )
+        {
+            if( !t.isRunning )
+            {
+                Thread.remove( t );
+                return;
+            }
+            onThreadError( "Unable to resume thread" );
+        }
+
+        if( !t.m_lock )
+            t.m_curr.tstack = t.m_curr.bstack;
+        t.m_reg[0 .. $] = 0;
+    }
+    else version( OSX )
+    {
+        if( t.m_addr != pthread_self() && thread_resume( t.m_tmach ) != KERN_SUCCESS )
+        {
+            if( !t.isRunning )
+            {
+                Thread.remove( t );
+                return;
+            }
+            onThreadError( "Unable to resume thread" );
+        }
+
+        if( !t.m_lock )
+            t.m_curr.tstack = t.m_curr.bstack;
+        t.m_reg[0 .. $] = 0;
+    }
+    else version( Posix )
+    {
+        if( t.m_addr != pthread_self() )
+        {
+            if( pthread_kill( t.m_addr, resumeSignalNumber ) != 0 )
+            {
+                if( !t.isRunning )
+                {
+                    Thread.remove( t );
+                    return;
+                }
+                onThreadError( "Unable to resume thread" );
+            }
+        }
+        else if( !t.m_lock )
+        {
+            t.m_curr.tstack = t.m_curr.bstack;
+        }
+    }
+}
+
+/**
+ * Resume all threads but the calling thread for "stop the world" garbage
+ * collection runs.  This function must be called once for each preceding
+ * call to thread_suspendAll before the threads are actually resumed.
+ *
+ * In:
+ *  This routine must be preceded by a call to thread_suspendAll.
+ *
+ * Throws:
+ *  ThreadError if the resume operation fails for a running thread.
+ */
+extern (C) void thread_resumeAll() nothrow
+in
+{
+    assert( suspendDepth > 0 );
+}
+body
+{
+    // NOTE: See thread_suspendAll for the logic behind this.
+    if( !multiThreadedFlag && Thread.sm_tbeg )
+    {
+        if( --suspendDepth == 0 )
+            resume( Thread.getThis() );
+        return;
+    }
+
+    scope(exit) Thread.slock.unlock_nothrow();
+    {
+        if( --suspendDepth > 0 )
+            return;
+
+        for( Thread t = Thread.sm_tbeg; t; t = t.next )
+        {
+            // NOTE: We do not need to care about critical regions at all
+            //       here. thread_suspendAll takes care of everything.
+            resume( t );
+        }
+    }
+}
+
+/**
+ * Indicates the kind of scan being performed by $(D thread_scanAllType).
+ */
+enum ScanType
+{
+    stack, /// The stack and/or registers are being scanned.
+    tls, /// TLS data is being scanned.
+}
+
+alias void delegate(void*, void*) nothrow ScanAllThreadsFn; /// The scanning function.
+alias void delegate(ScanType, void*, void*) nothrow ScanAllThreadsTypeFn; /// ditto
+
+/**
+ * The main entry point for garbage collection.  The supplied delegate
+ * will be passed ranges representing both stack and register values.
+ *
+ * Params:
+ *  scan        = The scanner function.  It should scan from p1 through p2 - 1.
+ *
+ * In:
+ *  This routine must be preceded by a call to thread_suspendAll.
+ */
+extern (C) void thread_scanAllType( scope ScanAllThreadsTypeFn scan ) nothrow
+in
+{
+    assert( suspendDepth > 0 );
+}
+body
+{
+    callWithStackShell(sp => scanAllTypeImpl(scan, sp));
+}
+
+
+private void scanAllTypeImpl( scope ScanAllThreadsTypeFn scan, void* curStackTop ) nothrow
+{
+    Thread  thisThread  = null;
+    void*   oldStackTop = null;
+
+    if( Thread.sm_tbeg )
+    {
+        thisThread  = Thread.getThis();
+        if( !thisThread.m_lock )
+        {
+            oldStackTop = thisThread.m_curr.tstack;
+            thisThread.m_curr.tstack = curStackTop;
+        }
+    }
+
+    scope( exit )
+    {
+        if( Thread.sm_tbeg )
+        {
+            if( !thisThread.m_lock )
+            {
+                thisThread.m_curr.tstack = oldStackTop;
+            }
+        }
+    }
+
+    // NOTE: Synchronizing on Thread.slock is not needed because this
+    //       function may only be called after all other threads have
+    //       been suspended from within the same lock.
+    if (Thread.nAboutToStart)
+        scan(ScanType.stack, Thread.pAboutToStart, Thread.pAboutToStart + Thread.nAboutToStart);
+
+    for( Thread.Context* c = Thread.sm_cbeg; c; c = c.next )
+    {
+        version( StackGrowsDown )
+        {
+            // NOTE: We can't index past the bottom of the stack
+            //       so don't do the "+1" for StackGrowsDown.
+            if( c.tstack && c.tstack < c.bstack )
+                scan( ScanType.stack, c.tstack, c.bstack );
+        }
+        else
+        {
+            if( c.bstack && c.bstack < c.tstack )
+                scan( ScanType.stack, c.bstack, c.tstack + 1 );
+        }
+    }
+
+    for( Thread t = Thread.sm_tbeg; t; t = t.next )
+    {
+        version( Windows )
+        {
+            // Ideally, we'd pass ScanType.regs or something like that, but this
+            // would make portability annoying because it only makes sense on Windows.
+            scan( ScanType.stack, t.m_reg.ptr, t.m_reg.ptr + t.m_reg.length );
+        }
+
+        if (t.m_tlsgcdata !is null)
+            rt_tlsgc_scan(t.m_tlsgcdata, (p1, p2) => scan(ScanType.tls, p1, p2));
+    }
+}
+
+/**
+ * The main entry point for garbage collection.  The supplied delegate
+ * will be passed ranges representing both stack and register values.
+ *
+ * Params:
+ *  scan        = The scanner function.  It should scan from p1 through p2 - 1.
+ *
+ * In:
+ *  This routine must be preceded by a call to thread_suspendAll.
+ */
+extern (C) void thread_scanAll( scope ScanAllThreadsFn scan ) nothrow
+{
+    thread_scanAllType((type, p1, p2) => scan(p1, p2));
+}
+
+
+/**
+ * Signals that the code following this call is a critical region. Any code in
+ * this region must finish running before the calling thread can be suspended
+ * by a call to thread_suspendAll.
+ *
+ * This function is, in particular, meant to help maintain garbage collector
+ * invariants when a lock is not used.
+ *
+ * A critical region is exited with thread_exitCriticalRegion.
+ *
+ * $(RED Warning):
+ * Using critical regions is extremely error-prone. For instance, using locks
+ * inside a critical region can easily result in a deadlock when another thread
+ * holding the lock already got suspended.
+ *
+ * The term and concept of a 'critical region' comes from
+ * $(LINK2 https://github.com/mono/mono/blob/521f4a198e442573c400835ef19bbb36b60b0ebb/mono/metadata/sgen-gc.h#L925 Mono's SGen garbage collector).
+ *
+ * In:
+ *  The calling thread must be attached to the runtime.
+ */
+extern (C) void thread_enterCriticalRegion()
+in
+{
+    assert(Thread.getThis());
+}
+body
+{
+    synchronized (Thread.criticalRegionLock)
+        Thread.getThis().m_isInCriticalRegion = true;
+}
+
+
+/**
+ * Signals that the calling thread is no longer in a critical region. Following
+ * a call to this function, the thread can once again be suspended.
+ *
+ * In:
+ *  The calling thread must be attached to the runtime.
+ */
+extern (C) void thread_exitCriticalRegion()
+in
+{
+    assert(Thread.getThis());
+}
+body
+{
+    synchronized (Thread.criticalRegionLock)
+        Thread.getThis().m_isInCriticalRegion = false;
+}
+
+
+/**
+ * Returns true if the current thread is in a critical region; otherwise, false.
+ *
+ * In:
+ *  The calling thread must be attached to the runtime.
+ */
+extern (C) bool thread_inCriticalRegion()
+in
+{
+    assert(Thread.getThis());
+}
+body
+{
+    synchronized (Thread.criticalRegionLock)
+        return Thread.getThis().m_isInCriticalRegion;
+}
+
+
+/**
+* A callback for thread errors in D during collections. Since an allocation is not possible
+*  a preallocated ThreadError will be used as the Error instance
+*
+* Throws:
+*  ThreadError.
+*/
+private void onThreadError(string msg = null, Throwable next = null) nothrow
+{
+    __gshared ThreadError error = new ThreadError(null);
+    error.msg = msg;
+    error.next = next;
+    import core.exception : SuppressTraceInfo;
+    error.info = SuppressTraceInfo.instance;
+    throw error;
+}
+
+
+unittest
+{
+    assert(!thread_inCriticalRegion());
+
+    {
+        thread_enterCriticalRegion();
+
+        scope (exit)
+            thread_exitCriticalRegion();
+
+        assert(thread_inCriticalRegion());
+    }
+
+    assert(!thread_inCriticalRegion());
+}
+
+unittest
+{
+    // NOTE: This entire test is based on the assumption that no
+    //       memory is allocated after the child thread is
+    //       started. If an allocation happens, a collection could
+    //       trigger, which would cause the synchronization below
+    //       to cause a deadlock.
+    // NOTE: DO NOT USE LOCKS IN CRITICAL REGIONS IN NORMAL CODE.
+
+    import core.sync.semaphore;
+
+    auto sema = new Semaphore(),
+         semb = new Semaphore();
+
+    auto thr = new Thread(
+    {
+        thread_enterCriticalRegion();
+        assert(thread_inCriticalRegion());
+        sema.notify();
+
+        semb.wait();
+        assert(thread_inCriticalRegion());
+
+        thread_exitCriticalRegion();
+        assert(!thread_inCriticalRegion());
+        sema.notify();
+
+        semb.wait();
+        assert(!thread_inCriticalRegion());
+    });
+
+    thr.start();
+
+    sema.wait();
+    synchronized (Thread.criticalRegionLock)
+        assert(thr.m_isInCriticalRegion);
+    semb.notify();
+
+    sema.wait();
+    synchronized (Thread.criticalRegionLock)
+        assert(!thr.m_isInCriticalRegion);
+    semb.notify();
+
+    thr.join();
+}
+
+unittest
+{
+    import core.sync.semaphore;
+
+    shared bool inCriticalRegion;
+    auto sema = new Semaphore(),
+         semb = new Semaphore();
+
+    auto thr = new Thread(
+    {
+        thread_enterCriticalRegion();
+        inCriticalRegion = true;
+        sema.notify();
+        semb.wait();
+
+        Thread.sleep(dur!"msecs"(1));
+        inCriticalRegion = false;
+        thread_exitCriticalRegion();
+    });
+    thr.start();
+
+    sema.wait();
+    assert(inCriticalRegion);
+    semb.notify();
+
+    thread_suspendAll();
+    assert(!inCriticalRegion);
+    thread_resumeAll();
+}
+
+/**
+ * Indicates whether an address has been marked by the GC.
+ */
+enum IsMarked : int
+{
+         no, /// Address is not marked.
+        yes, /// Address is marked.
+    unknown, /// Address is not managed by the GC.
+}
+
+alias int delegate( void* addr ) nothrow IsMarkedDg; /// The isMarked callback function.
+
+/**
+ * This routine allows the runtime to process any special per-thread handling
+ * for the GC.  This is needed for taking into account any memory that is
+ * referenced by non-scanned pointers but is about to be freed.  That currently
+ * means the array append cache.
+ *
+ * Params:
+ *  isMarked = The function used to check if $(D addr) is marked.
+ *
+ * In:
+ *  This routine must be called just prior to resuming all threads.
+ */
+extern(C) void thread_processGCMarks( scope IsMarkedDg isMarked ) nothrow
+{
+    for( Thread t = Thread.sm_tbeg; t; t = t.next )
+    {
+        /* Can be null if collection was triggered between adding a
+         * thread and calling rt_tlsgc_init.
+         */
+        if (t.m_tlsgcdata !is null)
+            rt_tlsgc_processGCMarks(t.m_tlsgcdata, isMarked);
+    }
+}
+
+
+extern (C)
+{
+nothrow:
+    version (CRuntime_Glibc) int pthread_getattr_np(pthread_t thread, pthread_attr_t* attr);
+    version (FreeBSD) int pthread_attr_get_np(pthread_t thread, pthread_attr_t* attr);
+    version (Solaris) int thr_stksegment(stack_t* stk);
+    version (CRuntime_Bionic) int pthread_getattr_np(pthread_t thid, pthread_attr_t* attr);
+}
+
+
+private void* getStackTop() nothrow
+{
+    version (D_InlineAsm_X86)
+        asm pure nothrow @nogc { naked; mov EAX, ESP; ret; }
+    else version (D_InlineAsm_X86_64)
+        asm pure nothrow @nogc { naked; mov RAX, RSP; ret; }
+    else version (GNU)
+        return __builtin_frame_address(0);
+    else
+        static assert(false, "Architecture not supported.");
+}
+
+
+private void* getStackBottom() nothrow
+{
+    version (Windows)
+    {
+        version (D_InlineAsm_X86)
+            asm pure nothrow @nogc { naked; mov EAX, FS:4; ret; }
+        else version(D_InlineAsm_X86_64)
+            asm pure nothrow @nogc
+            {    naked;
+                 mov RAX, 8;
+                 mov RAX, GS:[RAX];
+                 ret;
+            }
+        else version (GNU_InlineAsm)
+        {
+            void *bottom;
+
+            version( X86 )
+                asm pure nothrow @nogc { "movl %%fs:4, %0;" : "=r" bottom; }
+            else version( X86_64 )
+                asm pure nothrow @nogc { "movq %%gs:8, %0;" : "=r" bottom; }
+            else
+                static assert(false, "Platform not supported.");
+
+            return bottom;
+        }
+        else
+            static assert(false, "Architecture not supported.");
+    }
+    else version (OSX)
+    {
+        import core.sys.osx.pthread;
+        return pthread_get_stackaddr_np(pthread_self());
+    }
+    else version (CRuntime_Glibc)
+    {
+        pthread_attr_t attr;
+        void* addr; size_t size;
+
+        pthread_getattr_np(pthread_self(), &attr);
+        pthread_attr_getstack(&attr, &addr, &size);
+        pthread_attr_destroy(&attr);
+        return addr + size;
+    }
+    else version (FreeBSD)
+    {
+        pthread_attr_t attr;
+        void* addr; size_t size;
+
+        pthread_attr_init(&attr);
+        pthread_attr_get_np(pthread_self(), &attr);
+        pthread_attr_getstack(&attr, &addr, &size);
+        pthread_attr_destroy(&attr);
+        return addr + size;
+    }
+    else version (Solaris)
+    {
+        stack_t stk;
+
+        thr_stksegment(&stk);
+        return stk.ss_sp;
+    }
+    else version (CRuntime_Bionic)
+    {
+        pthread_attr_t attr;
+        void* addr; size_t size;
+
+        pthread_getattr_np(pthread_self(), &attr);
+        pthread_attr_getstack(&attr, &addr, &size);
+        pthread_attr_destroy(&attr);
+        return addr + size;
+    }
+    else
+        static assert(false, "Platform not supported.");
+}
+
+
+/**
+ * Returns the stack top of the currently active stack within the calling
+ * thread.
+ *
+ * In:
+ *  The calling thread must be attached to the runtime.
+ *
+ * Returns:
+ *  The address of the stack top.
+ */
+extern (C) void* thread_stackTop() nothrow
+in
+{
+    // Not strictly required, but it gives us more flexibility.
+    assert(Thread.getThis());
+}
+body
+{
+    return getStackTop();
+}
+
+
+/**
+ * Returns the stack bottom of the currently active stack within the calling
+ * thread.
+ *
+ * In:
+ *  The calling thread must be attached to the runtime.
+ *
+ * Returns:
+ *  The address of the stack bottom.
+ */
+extern (C) void* thread_stackBottom() nothrow
+in
+{
+    assert(Thread.getThis());
+}
+body
+{
+    return Thread.getThis().topContext().bstack;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Thread Group
+///////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * This class is intended to simplify certain common programming techniques.
+ */
+class ThreadGroup
+{
+    /**
+     * Creates and starts a new Thread object that executes fn and adds it to
+     * the list of tracked threads.
+     *
+     * Params:
+     *  fn = The thread function.
+     *
+     * Returns:
+     *  A reference to the newly created thread.
+     */
+    final Thread create( void function() fn )
+    {
+        Thread t = new Thread( fn ).start();
+
+        synchronized( this )
+        {
+            m_all[t] = t;
+        }
+        return t;
+    }
+
+
+    /**
+     * Creates and starts a new Thread object that executes dg and adds it to
+     * the list of tracked threads.
+     *
+     * Params:
+     *  dg = The thread function.
+     *
+     * Returns:
+     *  A reference to the newly created thread.
+     */
+    final Thread create( void delegate() dg )
+    {
+        Thread t = new Thread( dg ).start();
+
+        synchronized( this )
+        {
+            m_all[t] = t;
+        }
+        return t;
+    }
+
+
+    /**
+     * Add t to the list of tracked threads if it is not already being tracked.
+     *
+     * Params:
+     *  t = The thread to add.
+     *
+     * In:
+     *  t must not be null.
+     */
+    final void add( Thread t )
+    in
+    {
+        assert( t );
+    }
+    body
+    {
+        synchronized( this )
+        {
+            m_all[t] = t;
+        }
+    }
+
+
+    /**
+     * Removes t from the list of tracked threads.  No operation will be
+     * performed if t is not currently being tracked by this object.
+     *
+     * Params:
+     *  t = The thread to remove.
+     *
+     * In:
+     *  t must not be null.
+     */
+    final void remove( Thread t )
+    in
+    {
+        assert( t );
+    }
+    body
+    {
+        synchronized( this )
+        {
+            m_all.remove( t );
+        }
+    }
+
+
+    /**
+     * Operates on all threads currently tracked by this object.
+     */
+    final int opApply( scope int delegate( ref Thread ) dg )
+    {
+        synchronized( this )
+        {
+            int ret = 0;
+
+            // NOTE: This loop relies on the knowledge that m_all uses the
+            //       Thread object for both the key and the mapped value.
+            foreach( Thread t; m_all.keys )
+            {
+                ret = dg( t );
+                if( ret )
+                    break;
+            }
+            return ret;
+        }
+    }
+
+
+    /**
+     * Iteratively joins all tracked threads.  This function will block add,
+     * remove, and opApply until it completes.
+     *
+     * Params:
+     *  rethrow = Rethrow any unhandled exception which may have caused the
+     *            current thread to terminate.
+     *
+     * Throws:
+     *  Any exception not handled by the joined threads.
+     */
+    final void joinAll( bool rethrow = true )
+    {
+        synchronized( this )
+        {
+            // NOTE: This loop relies on the knowledge that m_all uses the
+            //       Thread object for both the key and the mapped value.
+            foreach( Thread t; m_all.keys )
+            {
+                t.join( rethrow );
+            }
+        }
+    }
+
+
+private:
+    Thread[Thread]  m_all;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Fiber Platform Detection and Memory Allocation
+///////////////////////////////////////////////////////////////////////////////
+
+
+private
+{
+    version( D_InlineAsm_X86 )
+    {
+        version( Windows )
+            version = AsmX86_Windows;
+        else version( Posix )
+            version = AsmX86_Posix;
+
+        version( OSX )
+            version = AlignFiberStackTo16Byte;
+    }
+    else version( D_InlineAsm_X86_64 )
+    {
+        version( Windows )
+        {
+            version = AsmX86_64_Windows;
+            version = AlignFiberStackTo16Byte;
+        }
+        else version( Posix )
+        {
+            version = AsmX86_64_Posix;
+            version = AlignFiberStackTo16Byte;
+        }
+    }
+    else version( X86 )
+    {
+        version = AsmExternal;
+
+        version (MinGW)
+        {
+            version = GNU_AsmX86_Windows;
+            version = AlignFiberStackTo16Byte;
+        }
+        else version( Posix )
+        {
+            version = AsmX86_Posix;
+            version( OSX )
+                version = AlignFiberStackTo16Byte;
+        }
+    }
+    else version( X86_64 )
+    {
+        version( D_X32 )
+        {
+            // let X32 be handled by ucontext swapcontext
+        }
+        else
+        {
+            version = AsmExternal;
+            version = AlignFiberStackTo16Byte;
+
+            version ( MinGW )
+                version = GNU_AsmX86_64_Windows;
+            else version( Posix )
+                version = AsmX86_64_Posix;
+        }
+    }
+    else version( PPC )
+    {
+        version( Posix )
+        {
+            version = AsmPPC_Posix;
+            version = AsmExternal;
+        }
+    }
+    else version( PPC64 )
+    {
+        version( Posix )
+        {
+            version = AlignFiberStackTo16Byte;
+        }
+    }
+    else version( MIPS_O32 )
+    {
+        version( Posix )
+        {
+            version = AsmMIPS_O32_Posix;
+            version = AsmExternal;
+        }
+    }
+    else version( ARM )
+    {
+        version( Posix )
+        {
+            version = AsmARM_Posix;
+            version = AsmExternal;
+        }
+    }
+
+    version( Posix )
+    {
+        import core.sys.posix.unistd;   // for sysconf
+
+        version( AsmX86_Windows )    {} else
+        version( AsmX86_Posix )      {} else
+        version( AsmX86_64_Windows ) {} else
+        version( AsmX86_64_Posix )   {} else
+        version( AsmExternal )       {} else
+        {
+            // NOTE: The ucontext implementation requires architecture specific
+            //       data definitions to operate so testing for it must be done
+            //       by checking for the existence of ucontext_t rather than by
+            //       a version identifier.  Please note that this is considered
+            //       an obsolescent feature according to the POSIX spec, so a
+            //       custom solution is still preferred.
+            import core.sys.posix.ucontext;
+        }
+    }
+
+    static immutable size_t PAGESIZE;
+    version (Posix) static immutable size_t PTHREAD_STACK_MIN;
+}
+
+
+shared static this()
+{
+    version (Windows)
+    {
+        SYSTEM_INFO info;
+        GetSystemInfo(&info);
+
+        PAGESIZE = info.dwPageSize;
+        assert(PAGESIZE < int.max);
+    }
+    else version (Posix)
+    {
+        PAGESIZE = cast(size_t)sysconf(_SC_PAGESIZE);
+        PTHREAD_STACK_MIN = cast(size_t)sysconf(_SC_THREAD_STACK_MIN);
+    }
+    else
+    {
+        static assert(0, "unimplemented");
+    }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Fiber Entry Point and Context Switch
+///////////////////////////////////////////////////////////////////////////////
+
+
+private
+{
+    extern (C) void fiber_entryPoint()
+    {
+        Fiber   obj = Fiber.getThis();
+        assert( obj );
+
+        assert( Thread.getThis().m_curr is obj.m_ctxt );
+        atomicStore!(MemoryOrder.raw)(*cast(shared)&Thread.getThis().m_lock, false);
+        obj.m_ctxt.tstack = obj.m_ctxt.bstack;
+        obj.m_state = Fiber.State.EXEC;
+
+        try
+        {
+            obj.run();
+        }
+        catch( Throwable t )
+        {
+            obj.m_unhandled = t;
+        }
+
+        static if( __traits( compiles, ucontext_t ) )
+          obj.m_ucur = &obj.m_utxt;
+
+        obj.m_state = Fiber.State.TERM;
+        obj.switchOut();
+    }
+
+  // Look above the definition of 'class Fiber' for some information about the implementation of this routine
+  version( AsmExternal )
+    extern (C) void fiber_switchContext( void** oldp, void* newp ) nothrow;
+  else
+    extern (C) void fiber_switchContext( void** oldp, void* newp ) nothrow
+    {
+        // NOTE: The data pushed and popped in this routine must match the
+        //       default stack created by Fiber.initStack or the initial
+        //       switch into a new context will fail.
+
+        version( AsmX86_Windows )
+        {
+            asm pure nothrow @nogc
+            {
+                naked;
+
+                // save current stack state
+                push EBP;
+                mov  EBP, ESP;
+                push EDI;
+                push ESI;
+                push EBX;
+                push dword ptr FS:[0];
+                push dword ptr FS:[4];
+                push dword ptr FS:[8];
+                push EAX;
+
+                // store oldp again with more accurate address
+                mov EAX, dword ptr 8[EBP];
+                mov [EAX], ESP;
+                // load newp to begin context switch
+                mov ESP, dword ptr 12[EBP];
+
+                // load saved state from new stack
+                pop EAX;
+                pop dword ptr FS:[8];
+                pop dword ptr FS:[4];
+                pop dword ptr FS:[0];
+                pop EBX;
+                pop ESI;
+                pop EDI;
+                pop EBP;
+
+                // 'return' to complete switch
+                pop ECX;
+                jmp ECX;
+            }
+        }
+        else version( AsmX86_64_Windows )
+        {
+            asm pure nothrow @nogc
+            {
+                naked;
+
+                // save current stack state
+                // NOTE: When changing the layout of registers on the stack,
+                //       make sure that the XMM registers are still aligned.
+                //       On function entry, the stack is guaranteed to not
+                //       be aligned to 16 bytes because of the return address
+                //       on the stack.
+                push RBP;
+                mov  RBP, RSP;
+                push R12;
+                push R13;
+                push R14;
+                push R15;
+                push RDI;
+                push RSI;
+                // 7 registers = 56 bytes; stack is now aligned to 16 bytes
+                sub RSP, 160;
+                movdqa [RSP + 144], XMM6;
+                movdqa [RSP + 128], XMM7;
+                movdqa [RSP + 112], XMM8;
+                movdqa [RSP + 96], XMM9;
+                movdqa [RSP + 80], XMM10;
+                movdqa [RSP + 64], XMM11;
+                movdqa [RSP + 48], XMM12;
+                movdqa [RSP + 32], XMM13;
+                movdqa [RSP + 16], XMM14;
+                movdqa [RSP], XMM15;
+                push RBX;
+                xor  RAX,RAX;
+                push qword ptr GS:[RAX];
+                push qword ptr GS:8[RAX];
+                push qword ptr GS:16[RAX];
+
+                // store oldp
+                mov [RCX], RSP;
+                // load newp to begin context switch
+                mov RSP, RDX;
+
+                // load saved state from new stack
+                pop qword ptr GS:16[RAX];
+                pop qword ptr GS:8[RAX];
+                pop qword ptr GS:[RAX];
+                pop RBX;
+                movdqa XMM15, [RSP];
+                movdqa XMM14, [RSP + 16];
+                movdqa XMM13, [RSP + 32];
+                movdqa XMM12, [RSP + 48];
+                movdqa XMM11, [RSP + 64];
+                movdqa XMM10, [RSP + 80];
+                movdqa XMM9, [RSP + 96];
+                movdqa XMM8, [RSP + 112];
+                movdqa XMM7, [RSP + 128];
+                movdqa XMM6, [RSP + 144];
+                add RSP, 160;
+                pop RSI;
+                pop RDI;
+                pop R15;
+                pop R14;
+                pop R13;
+                pop R12;
+                pop RBP;
+
+                // 'return' to complete switch
+                pop RCX;
+                jmp RCX;
+            }
+        }
+        else version( AsmX86_Posix )
+        {
+            asm pure nothrow @nogc
+            {
+                naked;
+
+                // save current stack state
+                push EBP;
+                mov  EBP, ESP;
+                push EDI;
+                push ESI;
+                push EBX;
+                push EAX;
+
+                // store oldp again with more accurate address
+                mov EAX, dword ptr 8[EBP];
+                mov [EAX], ESP;
+                // load newp to begin context switch
+                mov ESP, dword ptr 12[EBP];
+
+                // load saved state from new stack
+                pop EAX;
+                pop EBX;
+                pop ESI;
+                pop EDI;
+                pop EBP;
+
+                // 'return' to complete switch
+                pop ECX;
+                jmp ECX;
+            }
+        }
+        else version( AsmX86_64_Posix )
+        {
+            asm pure nothrow @nogc
+            {
+                naked;
+
+                // save current stack state
+                push RBP;
+                mov  RBP, RSP;
+                push RBX;
+                push R12;
+                push R13;
+                push R14;
+                push R15;
+
+                // store oldp
+                mov [RDI], RSP;
+                // load newp to begin context switch
+                mov RSP, RSI;
+
+                // load saved state from new stack
+                pop R15;
+                pop R14;
+                pop R13;
+                pop R12;
+                pop RBX;
+                pop RBP;
+
+                // 'return' to complete switch
+                pop RCX;
+                jmp RCX;
+            }
+        }
+        else static if( __traits( compiles, ucontext_t ) )
+        {
+            Fiber   cfib = Fiber.getThis();
+            void*   ucur = cfib.m_ucur;
+
+            *oldp = &ucur;
+            swapcontext( **(cast(ucontext_t***) oldp),
+                          *(cast(ucontext_t**)  newp) );
+        }
+        else
+            static assert(0, "Not implemented");
+    }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Fiber
+///////////////////////////////////////////////////////////////////////////////
+/*
+ * Documentation of Fiber internals:
+ *
+ * The main routines to implement when porting Fibers to new architectures are
+ * fiber_switchContext and initStack. Some version constants have to be defined
+ * for the new platform as well, search for "Fiber Platform Detection and Memory Allocation".
+ *
+ * Fibers are based on a concept called 'Context'. A Context describes the execution
+ * state of a Fiber or main thread which is fully described by the stack, some
+ * registers and a return address at which the Fiber/Thread should continue executing.
+ * Please note that not only each Fiber has a Context, but each thread also has got a
+ * Context which describes the threads stack and state. If you call Fiber fib; fib.call
+ * the first time in a thread you switch from Threads Context into the Fibers Context.
+ * If you call fib.yield in that Fiber you switch out of the Fibers context and back
+ * into the Thread Context. (However, this is not always the case. You can call a Fiber
+ * from within another Fiber, then you switch Contexts between the Fibers and the Thread
+ * Context is not involved)
+ *
+ * In all current implementations the registers and the return address are actually
+ * saved on a Contexts stack.
+ *
+ * The fiber_switchContext routine has got two parameters:
+ * void** a:  This is the _location_ where we have to store the current stack pointer,
+ *            the stack pointer of the currently executing Context (Fiber or Thread).
+ * void*  b:  This is the pointer to the stack of the Context which we want to switch into.
+ *            Note that we get the same pointer here as the one we stored into the void** a
+ *            in a previous call to fiber_switchContext.
+ *
+ * In the simplest case, a fiber_switchContext rountine looks like this:
+ * fiber_switchContext:
+ *     push {return Address}
+ *     push {registers}
+ *     copy {stack pointer} into {location pointed to by a}
+ *     //We have now switch to the stack of a different Context!
+ *     copy {b} into {stack pointer}
+ *     pop {registers}
+ *     pop {return Address}
+ *     jump to {return Address}
+ *
+ * The GC uses the value returned in parameter a to scan the Fibers stack. It scans from
+ * the stack base to that value. As the GC dislikes false pointers we can actually optimize
+ * this a little: By storing registers which can not contain references to memory managed
+ * by the GC outside of the region marked by the stack base pointer and the stack pointer
+ * saved in fiber_switchContext we can prevent the GC from scanning them.
+ * Such registers are usually floating point registers and the return address. In order to
+ * implement this, we return a modified stack pointer from fiber_switchContext. However,
+ * we have to remember that when we restore the registers from the stack!
+ *
+ * --------------------------- <= Stack Base
+ * |          Frame          | <= Many other stack frames
+ * |          Frame          |
+ * |-------------------------| <= The last stack frame. This one is created by fiber_switchContext
+ * | registers with pointers |
+ * |                         | <= Stack pointer. GC stops scanning here
+ * |   return address        |
+ * |floating point registers |
+ * --------------------------- <= Real Stack End
+ *
+ * fiber_switchContext:
+ *     push {registers with pointers}
+ *     copy {stack pointer} into {location pointed to by a}
+ *     push {return Address}
+ *     push {Floating point registers}
+ *     //We have now switch to the stack of a different Context!
+ *     copy {b} into {stack pointer}
+ *     //We now have to adjust the stack pointer to point to 'Real Stack End' so we can pop
+ *     //the FP registers
+ *     //+ or - depends on if your stack grows downwards or upwards
+ *     {stack pointer} = {stack pointer} +- ({FPRegisters}.sizeof + {return address}.sizeof}
+ *     pop {Floating point registers}
+ *     pop {return Address}
+ *     pop {registers with pointers}
+ *     jump to {return Address}
+ *
+ * So the question now is which registers need to be saved? This depends on the specific
+ * architecture ABI of course, but here are some general guidelines:
+ * - If a register is callee-save (if the callee modifies the register it must saved and
+ *   restored by the callee) it needs to be saved/restored in switchContext
+ * - If a register is caller-save it needn't be saved/restored. (Calling fiber_switchContext
+ *   is a function call and the compiler therefore already must save these registers before
+ *   calling fiber_switchContext)
+ * - Argument registers used for passing parameters to functions needn't be saved/restored
+ * - The return register needn't be saved/restored (fiber_switchContext hasn't got a return type)
+ * - All scratch registers needn't be saved/restored
+ * - The link register usually needn't be saved/restored (but sometimes it must be cleared -
+ *   see below for details)
+ * - The frame pointer register - if it exists - is usually callee-save
+ * - All current implementations do not save control registers
+ *
+ * What happens on the first switch into a Fiber? We never saved a state for this fiber before,
+ * but the initial state is prepared in the initStack routine. (This routine will also be called
+ * when a Fiber is being resetted). initStack must produce exactly the same stack layout as the
+ * part of fiber_switchContext which saves the registers. Pay special attention to set the stack
+ * pointer correctly if you use the GC optimization mentioned before. the return Address saved in
+ * initStack must be the address of fiber_entrypoint.
+ *
+ * There's now a small but important difference between the first context switch into a fiber and
+ * further context switches. On the first switch, Fiber.call is used and the returnAddress in
+ * fiber_switchContext will point to fiber_entrypoint. The important thing here is that this jump
+ * is a _function call_, we call fiber_entrypoint by jumping before it's function prologue. On later
+ * calls, the user used yield() in a function, and therefore the return address points into a user
+ * function, after the yield call. So here the jump in fiber_switchContext is a _function return_,
+ * not a function call!
+ *
+ * The most important result of this is that on entering a function, i.e. fiber_entrypoint, we
+ * would have to provide a return address / set the link register once fiber_entrypoint
+ * returns. Now fiber_entrypoint does never return and therefore the actual value of the return
+ * address / link register is never read/used and therefore doesn't matter. When fiber_switchContext
+ * performs a _function return_ the value in the link register doesn't matter either.
+ * However, the link register will still be saved to the stack in fiber_entrypoint and some
+ * exception handling / stack unwinding code might read it from this stack location and crash.
+ * The exact solution depends on your architecture, but see the ARM implementation for a way
+ * to deal with this issue.
+ *
+ * The ARM implementation is meant to be used as a kind of documented example implementation.
+ * Look there for a concrete example.
+ *
+ * FIXME: fiber_entrypoint might benefit from a @noreturn attribute, but D doesn't have one.
+ */
+
+/**
+ * This class provides a cooperative concurrency mechanism integrated with the
+ * threading and garbage collection functionality.  Calling a fiber may be
+ * considered a blocking operation that returns when the fiber yields (via
+ * Fiber.yield()).  Execution occurs within the context of the calling thread
+ * so synchronization is not necessary to guarantee memory visibility so long
+ * as the same thread calls the fiber each time.  Please note that there is no
+ * requirement that a fiber be bound to one specific thread.  Rather, fibers
+ * may be freely passed between threads so long as they are not currently
+ * executing.  Like threads, a new fiber thread may be created using either
+ * derivation or composition, as in the following example.
+ *
+ * Warning:
+ * Status registers are not saved by the current implementations. This means
+ * floating point exception status bits (overflow, divide by 0), rounding mode
+ * and similar stuff is set per-thread, not per Fiber!
+ *
+ * Warning:
+ * On ARM FPU registers are not saved if druntime was compiled as ARM_SoftFloat.
+ * If such a build is used on a ARM_SoftFP system which actually has got a FPU
+ * and other libraries are using the FPU registers (other code is compiled
+ * as ARM_SoftFP) this can cause problems. Druntime must be compiled as
+ * ARM_SoftFP in this case.
+ *
+ * Example:
+ * ----------------------------------------------------------------------
+ *
+ * class DerivedFiber : Fiber
+ * {
+ *     this()
+ *     {
+ *         super( &run );
+ *     }
+ *
+ * private :
+ *     void run()
+ *     {
+ *         printf( "Derived fiber running.\n" );
+ *     }
+ * }
+ *
+ * void fiberFunc()
+ * {
+ *     printf( "Composed fiber running.\n" );
+ *     Fiber.yield();
+ *     printf( "Composed fiber running.\n" );
+ * }
+ *
+ * // create instances of each type
+ * Fiber derived = new DerivedFiber();
+ * Fiber composed = new Fiber( &fiberFunc );
+ *
+ * // call both fibers once
+ * derived.call();
+ * composed.call();
+ * printf( "Execution returned to calling context.\n" );
+ * composed.call();
+ *
+ * // since each fiber has run to completion, each should have state TERM
+ * assert( derived.state == Fiber.State.TERM );
+ * assert( composed.state == Fiber.State.TERM );
+ *
+ * ----------------------------------------------------------------------
+ *
+ * Authors: Based on a design by Mikola Lysenko.
+ */
+class Fiber
+{
+    ///////////////////////////////////////////////////////////////////////////
+    // Initialization
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Initializes a fiber object which is associated with a static
+     * D function.
+     *
+     * Params:
+     *  fn = The fiber function.
+     *  sz = The stack size for this fiber.
+     *
+     * In:
+     *  fn must not be null.
+     */
+    this( void function() fn, size_t sz = PAGESIZE*4 ) nothrow
+    in
+    {
+        assert( fn );
+    }
+    body
+    {
+        allocStack( sz );
+        reset( fn );
+    }
+
+
+    /**
+     * Initializes a fiber object which is associated with a dynamic
+     * D function.
+     *
+     * Params:
+     *  dg = The fiber function.
+     *  sz = The stack size for this fiber.
+     *
+     * In:
+     *  dg must not be null.
+     */
+    this( void delegate() dg, size_t sz = PAGESIZE*4 ) nothrow
+    in
+    {
+        assert( dg );
+    }
+    body
+    {
+        allocStack( sz );
+        reset( dg );
+    }
+
+
+    /**
+     * Cleans up any remaining resources used by this object.
+     */
+    ~this() nothrow
+    {
+        // NOTE: A live reference to this object will exist on its associated
+        //       stack from the first time its call() method has been called
+        //       until its execution completes with State.TERM.  Thus, the only
+        //       times this dtor should be called are either if the fiber has
+        //       terminated (and therefore has no active stack) or if the user
+        //       explicitly deletes this object.  The latter case is an error
+        //       but is not easily tested for, since State.HOLD may imply that
+        //       the fiber was just created but has never been run.  There is
+        //       not a compelling case to create a State.INIT just to offer a
+        //       means of ensuring the user isn't violating this object's
+        //       contract, so for now this requirement will be enforced by
+        //       documentation only.
+        freeStack();
+    }
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // General Actions
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Transfers execution to this fiber object.  The calling context will be
+     * suspended until the fiber calls Fiber.yield() or until it terminates
+     * via an unhandled exception.
+     *
+     * Params:
+     *  rethrow = Rethrow any unhandled exception which may have caused this
+     *            fiber to terminate.
+     *
+     * In:
+     *  This fiber must be in state HOLD.
+     *
+     * Throws:
+     *  Any exception not handled by the joined thread.
+     *
+     * Returns:
+     *  Any exception not handled by this fiber if rethrow = false, null
+     *  otherwise.
+     */
+    final Throwable call( Rethrow rethrow = Rethrow.yes )
+    {
+        return rethrow ? call!(Rethrow.yes)() : call!(Rethrow.no);
+    }
+
+    /// ditto
+    final Throwable call( Rethrow rethrow )()
+    {
+        callImpl();
+        if( m_unhandled )
+        {
+            Throwable t = m_unhandled;
+            m_unhandled = null;
+            static if( rethrow )
+                throw t;
+            else
+                return t;
+        }
+        return null;
+    }
+
+    /// ditto
+    deprecated("Please pass Fiber.Rethrow.yes or .no instead of a boolean.")
+    final Throwable call( bool rethrow )
+    {
+        return rethrow ? call!(Rethrow.yes)() : call!(Rethrow.no);
+    }
+
+    private void callImpl() nothrow
+    in
+    {
+        assert( m_state == State.HOLD );
+    }
+    body
+    {
+        Fiber   cur = getThis();
+
+        static if( __traits( compiles, ucontext_t ) )
+          m_ucur = cur ? &cur.m_utxt : &Fiber.sm_utxt;
+
+        setThis( this );
+        this.switchIn();
+        setThis( cur );
+
+        static if( __traits( compiles, ucontext_t ) )
+          m_ucur = null;
+
+        // NOTE: If the fiber has terminated then the stack pointers must be
+        //       reset.  This ensures that the stack for this fiber is not
+        //       scanned if the fiber has terminated.  This is necessary to
+        //       prevent any references lingering on the stack from delaying
+        //       the collection of otherwise dead objects.  The most notable
+        //       being the current object, which is referenced at the top of
+        //       fiber_entryPoint.
+        if( m_state == State.TERM )
+        {
+            m_ctxt.tstack = m_ctxt.bstack;
+        }
+    }
+
+    /// Flag to control rethrow behavior of $(D $(LREF call))
+    enum Rethrow : bool { no, yes }
+
+    /**
+     * Resets this fiber so that it may be re-used, optionally with a
+     * new function/delegate.  This routine should only be called for
+     * fibers that have terminated, as doing otherwise could result in
+     * scope-dependent functionality that is not executed.
+     * Stack-based classes, for example, may not be cleaned up
+     * properly if a fiber is reset before it has terminated.
+     *
+     * In:
+     *  This fiber must be in state TERM or HOLD.
+     */
+    final void reset() nothrow
+    in
+    {
+        assert( m_state == State.TERM || m_state == State.HOLD );
+    }
+    body
+    {
+        m_ctxt.tstack = m_ctxt.bstack;
+        m_state = State.HOLD;
+        initStack();
+        m_unhandled = null;
+    }
+
+    /// ditto
+    final void reset( void function() fn ) nothrow
+    {
+        reset();
+        m_fn    = fn;
+        m_call  = Call.FN;
+    }
+
+    /// ditto
+    final void reset( void delegate() dg ) nothrow
+    {
+        reset();
+        m_dg    = dg;
+        m_call  = Call.DG;
+    }
+
+    ///////////////////////////////////////////////////////////////////////////
+    // General Properties
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * A fiber may occupy one of three states: HOLD, EXEC, and TERM.  The HOLD
+     * state applies to any fiber that is suspended and ready to be called.
+     * The EXEC state will be set for any fiber that is currently executing.
+     * And the TERM state is set when a fiber terminates.  Once a fiber
+     * terminates, it must be reset before it may be called again.
+     */
+    enum State
+    {
+        HOLD,   ///
+        EXEC,   ///
+        TERM    ///
+    }
+
+
+    /**
+     * Gets the current state of this fiber.
+     *
+     * Returns:
+     *  The state of this fiber as an enumerated value.
+     */
+    final @property State state() const nothrow
+    {
+        return m_state;
+    }
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // Actions on Calling Fiber
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Forces a context switch to occur away from the calling fiber.
+     */
+    static void yield() nothrow
+    {
+        Fiber   cur = getThis();
+        assert( cur, "Fiber.yield() called with no active fiber" );
+        assert( cur.m_state == State.EXEC );
+
+        static if( __traits( compiles, ucontext_t ) )
+          cur.m_ucur = &cur.m_utxt;
+
+        cur.m_state = State.HOLD;
+        cur.switchOut();
+        cur.m_state = State.EXEC;
+    }
+
+
+    /**
+     * Forces a context switch to occur away from the calling fiber and then
+     * throws obj in the calling fiber.
+     *
+     * Params:
+     *  t = The object to throw.
+     *
+     * In:
+     *  t must not be null.
+     */
+    static void yieldAndThrow( Throwable t ) nothrow
+    in
+    {
+        assert( t );
+    }
+    body
+    {
+        Fiber   cur = getThis();
+        assert( cur, "Fiber.yield() called with no active fiber" );
+        assert( cur.m_state == State.EXEC );
+
+        static if( __traits( compiles, ucontext_t ) )
+          cur.m_ucur = &cur.m_utxt;
+
+        cur.m_unhandled = t;
+        cur.m_state = State.HOLD;
+        cur.switchOut();
+        cur.m_state = State.EXEC;
+    }
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // Fiber Accessors
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Provides a reference to the calling fiber or null if no fiber is
+     * currently active.
+     *
+     * Returns:
+     *  The fiber object representing the calling fiber or null if no fiber
+     *  is currently active within this thread. The result of deleting this object is undefined.
+     */
+    static Fiber getThis() nothrow
+    {
+        return sm_this;
+    }
+
+
+    ///////////////////////////////////////////////////////////////////////////
+    // Static Initialization
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    version( Posix )
+    {
+        static this()
+        {
+            static if( __traits( compiles, ucontext_t ) )
+            {
+              int status = getcontext( &sm_utxt );
+              assert( status == 0 );
+            }
+        }
+    }
+
+private:
+    //
+    // Initializes a fiber object which has no associated executable function.
+    //
+    this() nothrow
+    {
+        m_call = Call.NO;
+    }
+
+
+    //
+    // Fiber entry point.  Invokes the function or delegate passed on
+    // construction (if any).
+    //
+    final void run()
+    {
+        switch( m_call )
+        {
+        case Call.FN:
+            m_fn();
+            break;
+        case Call.DG:
+            m_dg();
+            break;
+        default:
+            break;
+        }
+    }
+
+
+private:
+    //
+    // The type of routine passed on fiber construction.
+    //
+    enum Call
+    {
+        NO,
+        FN,
+        DG
+    }
+
+
+    //
+    // Standard fiber data
+    //
+    Call                m_call;
+    union
+    {
+        void function() m_fn;
+        void delegate() m_dg;
+    }
+    bool                m_isRunning;
+    Throwable           m_unhandled;
+    State               m_state;
+
+
+private:
+    ///////////////////////////////////////////////////////////////////////////
+    // Stack Management
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    //
+    // Allocate a new stack for this fiber.
+    //
+    final void allocStack( size_t sz ) nothrow
+    in
+    {
+        assert( !m_pmem && !m_ctxt );
+    }
+    body
+    {
+        // adjust alloc size to a multiple of PAGESIZE
+        sz += PAGESIZE - 1;
+        sz -= sz % PAGESIZE;
+
+        // NOTE: This instance of Thread.Context is dynamic so Fiber objects
+        //       can be collected by the GC so long as no user level references
+        //       to the object exist.  If m_ctxt were not dynamic then its
+        //       presence in the global context list would be enough to keep
+        //       this object alive indefinitely.  An alternative to allocating
+        //       room for this struct explicitly would be to mash it into the
+        //       base of the stack being allocated below.  However, doing so
+        //       requires too much special logic to be worthwhile.
+        m_ctxt = new Thread.Context;
+
+        static if( __traits( compiles, VirtualAlloc ) )
+        {
+            // reserve memory for stack
+            m_pmem = VirtualAlloc( null,
+                                   sz + PAGESIZE,
+                                   MEM_RESERVE,
+                                   PAGE_NOACCESS );
+            if( !m_pmem )
+                onOutOfMemoryError();
+
+            version( StackGrowsDown )
+            {
+                void* stack = m_pmem + PAGESIZE;
+                void* guard = m_pmem;
+                void* pbase = stack + sz;
+            }
+            else
+            {
+                void* stack = m_pmem;
+                void* guard = m_pmem + sz;
+                void* pbase = stack;
+            }
+
+            // allocate reserved stack segment
+            stack = VirtualAlloc( stack,
+                                  sz,
+                                  MEM_COMMIT,
+                                  PAGE_READWRITE );
+            if( !stack )
+                onOutOfMemoryError();
+
+            // allocate reserved guard page
+            guard = VirtualAlloc( guard,
+                                  PAGESIZE,
+                                  MEM_COMMIT,
+                                  PAGE_READWRITE | PAGE_GUARD );
+            if( !guard )
+                onOutOfMemoryError();
+
+            m_ctxt.bstack = pbase;
+            m_ctxt.tstack = pbase;
+            m_size = sz;
+        }
+        else
+        {
+            version (Posix) import core.sys.posix.sys.mman; // mmap
+            version (FreeBSD) import core.sys.freebsd.sys.mman : MAP_ANON;
+            version (CRuntime_Glibc) import core.sys.linux.sys.mman : MAP_ANON;
+            version (OSX) import core.sys.osx.sys.mman : MAP_ANON;
+
+            static if( __traits( compiles, mmap ) )
+            {
+                m_pmem = mmap( null,
+                               sz,
+                               PROT_READ | PROT_WRITE,
+                               MAP_PRIVATE | MAP_ANON,
+                               -1,
+                               0 );
+                if( m_pmem == MAP_FAILED )
+                    m_pmem = null;
+            }
+            else static if( __traits( compiles, valloc ) )
+            {
+                m_pmem = valloc( sz );
+            }
+            else static if( __traits( compiles, malloc ) )
+            {
+                m_pmem = malloc( sz );
+            }
+            else
+            {
+                m_pmem = null;
+            }
+
+            if( !m_pmem )
+                onOutOfMemoryError();
+
+            version( StackGrowsDown )
+            {
+                m_ctxt.bstack = m_pmem + sz;
+                m_ctxt.tstack = m_pmem + sz;
+            }
+            else
+            {
+                m_ctxt.bstack = m_pmem;
+                m_ctxt.tstack = m_pmem;
+            }
+            m_size = sz;
+        }
+
+        Thread.add( m_ctxt );
+    }
+
+
+    //
+    // Free this fiber's stack.
+    //
+    final void freeStack() nothrow
+    in
+    {
+        assert( m_pmem && m_ctxt );
+    }
+    body
+    {
+        // NOTE: m_ctxt is guaranteed to be alive because it is held in the
+        //       global context list.
+        Thread.slock.lock_nothrow();
+        scope(exit) Thread.slock.unlock_nothrow();
+        Thread.remove( m_ctxt );
+
+        static if( __traits( compiles, VirtualAlloc ) )
+        {
+            VirtualFree( m_pmem, 0, MEM_RELEASE );
+        }
+        else
+        {
+            import core.sys.posix.sys.mman; // munmap
+
+            static if( __traits( compiles, mmap ) )
+            {
+                munmap( m_pmem, m_size );
+            }
+            else static if( __traits( compiles, valloc ) )
+            {
+                free( m_pmem );
+            }
+            else static if( __traits( compiles, malloc ) )
+            {
+                free( m_pmem );
+            }
+        }
+        m_pmem = null;
+        m_ctxt = null;
+    }
+
+
+    //
+    // Initialize the allocated stack.
+    // Look above the definition of 'class Fiber' for some information about the implementation of this routine
+    //
+    final void initStack() nothrow
+    in
+    {
+        assert( m_ctxt.tstack && m_ctxt.tstack == m_ctxt.bstack );
+        assert( cast(size_t) m_ctxt.bstack % (void*).sizeof == 0 );
+    }
+    body
+    {
+        void* pstack = m_ctxt.tstack;
+        scope( exit )  m_ctxt.tstack = pstack;
+
+        void push( size_t val ) nothrow
+        {
+            version( StackGrowsDown )
+            {
+                pstack -= size_t.sizeof;
+                *(cast(size_t*) pstack) = val;
+            }
+            else
+            {
+                pstack += size_t.sizeof;
+                *(cast(size_t*) pstack) = val;
+            }
+        }
+
+        // NOTE: On OS X the stack must be 16-byte aligned according
+        // to the IA-32 call spec. For x86_64 the stack also needs to
+        // be aligned to 16-byte according to SysV AMD64 ABI.
+        version( AlignFiberStackTo16Byte )
+        {
+            version( StackGrowsDown )
+            {
+                pstack = cast(void*)(cast(size_t)(pstack) - (cast(size_t)(pstack) & 0x0F));
+            }
+            else
+            {
+                pstack = cast(void*)(cast(size_t)(pstack) + (cast(size_t)(pstack) & 0x0F));
+            }
+        }
+
+        version( AsmX86_Windows )
+        {
+            version( StackGrowsDown ) {} else static assert( false );
+
+            // On Windows Server 2008 and 2008 R2, an exploit mitigation
+            // technique known as SEHOP is activated by default. To avoid
+            // hijacking of the exception handler chain, the presence of a
+            // Windows-internal handler (ntdll.dll!FinalExceptionHandler) at
+            // its end is tested by RaiseException. If it is not present, all
+            // handlers are disregarded, and the program is thus aborted
+            // (see http://blogs.technet.com/b/srd/archive/2009/02/02/
+            // preventing-the-exploitation-of-seh-overwrites-with-sehop.aspx).
+            // For new threads, this handler is installed by Windows immediately
+            // after creation. To make exception handling work in fibers, we
+            // have to insert it for our new stacks manually as well.
+            //
+            // To do this, we first determine the handler by traversing the SEH
+            // chain of the current thread until its end, and then construct a
+            // registration block for the last handler on the newly created
+            // thread. We then continue to push all the initial register values
+            // for the first context switch as for the other implementations.
+            //
+            // Note that this handler is never actually invoked, as we install
+            // our own one on top of it in the fiber entry point function.
+            // Thus, it should not have any effects on OSes not implementing
+            // exception chain verification.
+
+            alias void function() fp_t; // Actual signature not relevant.
+            static struct EXCEPTION_REGISTRATION
+            {
+                EXCEPTION_REGISTRATION* next; // sehChainEnd if last one.
+                fp_t handler;
+            }
+            enum sehChainEnd = cast(EXCEPTION_REGISTRATION*) 0xFFFFFFFF;
+
+            __gshared static fp_t finalHandler = null;
+            if ( finalHandler is null )
+            {
+                static EXCEPTION_REGISTRATION* fs0() nothrow
+                {
+                    asm pure nothrow @nogc
+                    {
+                        naked;
+                        mov EAX, FS:[0];
+                        ret;
+                    }
+                }
+                auto reg = fs0();
+                while ( reg.next != sehChainEnd ) reg = reg.next;
+
+                // Benign races are okay here, just to avoid re-lookup on every
+                // fiber creation.
+                finalHandler = reg.handler;
+            }
+
+            // When linking with /safeseh (supported by LDC, but not DMD)
+            // the exception chain must not extend to the very top
+            // of the stack, otherwise the exception chain is also considered
+            // invalid. Reserving additional 4 bytes at the top of the stack will
+            // keep the EXCEPTION_REGISTRATION below that limit
+            size_t reserve = EXCEPTION_REGISTRATION.sizeof + 4;
+            pstack -= reserve;
+            *(cast(EXCEPTION_REGISTRATION*)pstack) =
+                EXCEPTION_REGISTRATION( sehChainEnd, finalHandler );
+
+            push( cast(size_t) &fiber_entryPoint );                 // EIP
+            push( cast(size_t) m_ctxt.bstack - reserve );           // EBP
+            push( 0x00000000 );                                     // EDI
+            push( 0x00000000 );                                     // ESI
+            push( 0x00000000 );                                     // EBX
+            push( cast(size_t) m_ctxt.bstack - reserve );           // FS:[0]
+            push( cast(size_t) m_ctxt.bstack );                     // FS:[4]
+            push( cast(size_t) m_ctxt.bstack - m_size );            // FS:[8]
+            push( 0x00000000 );                                     // EAX
+        }
+        else version( AsmX86_64_Windows )
+        {
+            // Using this trampoline instead of the raw fiber_entryPoint
+            // ensures that during context switches, source and destination
+            // stacks have the same alignment. Otherwise, the stack would need
+            // to be shifted by 8 bytes for the first call, as fiber_entryPoint
+            // is an actual function expecting a stack which is not aligned
+            // to 16 bytes.
+            static void trampoline()
+            {
+                asm pure nothrow @nogc
+                {
+                    naked;
+                    sub RSP, 32; // Shadow space (Win64 calling convention)
+                    call fiber_entryPoint;
+                    xor RCX, RCX; // This should never be reached, as
+                    jmp RCX;      // fiber_entryPoint must never return.
+                }
+            }
+
+            push( cast(size_t) &trampoline );                       // RIP
+            push( 0x00000000_00000000 );                            // RBP
+            push( 0x00000000_00000000 );                            // R12
+            push( 0x00000000_00000000 );                            // R13
+            push( 0x00000000_00000000 );                            // R14
+            push( 0x00000000_00000000 );                            // R15
+            push( 0x00000000_00000000 );                            // RDI
+            push( 0x00000000_00000000 );                            // RSI
+            push( 0x00000000_00000000 );                            // XMM6 (high)
+            push( 0x00000000_00000000 );                            // XMM6 (low)
+            push( 0x00000000_00000000 );                            // XMM7 (high)
+            push( 0x00000000_00000000 );                            // XMM7 (low)
+            push( 0x00000000_00000000 );                            // XMM8 (high)
+            push( 0x00000000_00000000 );                            // XMM8 (low)
+            push( 0x00000000_00000000 );                            // XMM9 (high)
+            push( 0x00000000_00000000 );                            // XMM9 (low)
+            push( 0x00000000_00000000 );                            // XMM10 (high)
+            push( 0x00000000_00000000 );                            // XMM10 (low)
+            push( 0x00000000_00000000 );                            // XMM11 (high)
+            push( 0x00000000_00000000 );                            // XMM11 (low)
+            push( 0x00000000_00000000 );                            // XMM12 (high)
+            push( 0x00000000_00000000 );                            // XMM12 (low)
+            push( 0x00000000_00000000 );                            // XMM13 (high)
+            push( 0x00000000_00000000 );                            // XMM13 (low)
+            push( 0x00000000_00000000 );                            // XMM14 (high)
+            push( 0x00000000_00000000 );                            // XMM14 (low)
+            push( 0x00000000_00000000 );                            // XMM15 (high)
+            push( 0x00000000_00000000 );                            // XMM15 (low)
+            push( 0x00000000_00000000 );                            // RBX
+            push( 0xFFFFFFFF_FFFFFFFF );                            // GS:[0]
+            version( StackGrowsDown )
+            {
+                push( cast(size_t) m_ctxt.bstack );                 // GS:[8]
+                push( cast(size_t) m_ctxt.bstack - m_size );        // GS:[16]
+            }
+            else
+            {
+                push( cast(size_t) m_ctxt.bstack );                 // GS:[8]
+                push( cast(size_t) m_ctxt.bstack + m_size );        // GS:[16]
+            }
+        }
+        else version( AsmX86_Posix )
+        {
+            push( 0x00000000 );                                     // Return address of fiber_entryPoint call
+            push( cast(size_t) &fiber_entryPoint );                 // EIP
+            push( cast(size_t) m_ctxt.bstack );                     // EBP
+            push( 0x00000000 );                                     // EDI
+            push( 0x00000000 );                                     // ESI
+            push( 0x00000000 );                                     // EBX
+            push( 0x00000000 );                                     // EAX
+        }
+        else version( AsmX86_64_Posix )
+        {
+            push( 0x00000000_00000000 );                            // Return address of fiber_entryPoint call
+            push( cast(size_t) &fiber_entryPoint );                 // RIP
+            push( cast(size_t) m_ctxt.bstack );                     // RBP
+            push( 0x00000000_00000000 );                            // RBX
+            push( 0x00000000_00000000 );                            // R12
+            push( 0x00000000_00000000 );                            // R13
+            push( 0x00000000_00000000 );                            // R14
+            push( 0x00000000_00000000 );                            // R15
+        }
+        else version( AsmPPC_Posix )
+        {
+            version( StackGrowsDown )
+            {
+                pstack -= int.sizeof * 5;
+            }
+            else
+            {
+                pstack += int.sizeof * 5;
+            }
+
+            push( cast(size_t) &fiber_entryPoint );     // link register
+            push( 0x00000000 );                         // control register
+            push( 0x00000000 );                         // old stack pointer
+
+            // GPR values
+            version( StackGrowsDown )
+            {
+                pstack -= int.sizeof * 20;
+            }
+            else
+            {
+                pstack += int.sizeof * 20;
+            }
+
+            assert( (cast(size_t) pstack & 0x0f) == 0 );
+        }
+        else version( AsmMIPS_O32_Posix )
+        {
+            version (StackGrowsDown) {}
+            else static assert(0);
+
+            /* We keep the FP registers and the return address below
+             * the stack pointer, so they don't get scanned by the
+             * GC. The last frame before swapping the stack pointer is
+             * organized like the following.
+             *
+             *     |-----------|<= frame pointer
+             *     |    $gp    |
+             *     |   $s0-8   |
+             *     |-----------|<= stack pointer
+             *     |    $ra    |
+             *     |  align(8) |
+             *     |  $f20-30  |
+             *     |-----------|
+             *
+             */
+            enum SZ_GP = 10 * size_t.sizeof; // $gp + $s0-8
+            enum SZ_RA = size_t.sizeof;      // $ra
+            version (MIPS_HardFloat)
+            {
+                enum SZ_FP = 6 * 8;          // $f20-30
+                enum ALIGN = -(SZ_FP + SZ_RA) & (8 - 1);
+            }
+            else
+            {
+                enum SZ_FP = 0;
+                enum ALIGN = 0;
+            }
+
+            enum BELOW = SZ_FP + ALIGN + SZ_RA;
+            enum ABOVE = SZ_GP;
+            enum SZ = BELOW + ABOVE;
+
+            (cast(ubyte*)pstack - SZ)[0 .. SZ] = 0;
+            pstack -= ABOVE;
+            *cast(size_t*)(pstack - SZ_RA) = cast(size_t)&fiber_entryPoint;
+        }
+        else version( AsmARM_Posix )
+        {
+            /* We keep the FP registers and the return address below
+             * the stack pointer, so they don't get scanned by the
+             * GC. The last frame before swapping the stack pointer is
+             * organized like the following.
+             *
+             *   |  |-----------|<= 'frame starts here'
+             *   |  |     fp    | (the actual frame pointer, r11 isn't
+             *   |  |   r10-r4  |  updated and still points to the previous frame)
+             *   |  |-----------|<= stack pointer
+             *   |  |     lr    |
+             *   |  | 4byte pad |
+             *   |  |   d15-d8  |(if FP supported)
+             *   |  |-----------|
+             *   Y
+             *   stack grows down: The pointer value here is smaller than some lines above
+             */
+            // frame pointer can be zero, r10-r4 also zero initialized
+            version( StackGrowsDown )
+                pstack -= int.sizeof * 8;
+            else
+                static assert(false, "Only full descending stacks supported on ARM");
+
+            // link register
+            push( cast(size_t) &fiber_entryPoint );
+            /*
+             * We do not push padding and d15-d8 as those are zero initialized anyway
+             * Position the stack pointer above the lr register
+             */
+            pstack += int.sizeof * 1;
+        }
+        else version (GNU_AsmX86_Windows)
+        {
+            version( StackGrowsDown ) {} else static assert( false );
+
+            // Currently, MinGW doesn't utilize SEH exceptions.
+            // See DMD AsmX86_Windows If this code ever becomes fails and SEH is used.
+
+            push( 0x00000000 );                                     // Return address of fiber_entryPoint call
+            push( cast(size_t) &fiber_entryPoint );                 // EIP
+            push( 0x00000000 );                                     // EBP
+            push( 0x00000000 );                                     // EDI
+            push( 0x00000000 );                                     // ESI
+            push( 0x00000000 );                                     // EBX
+            push( 0xFFFFFFFF );                                     // FS:[0] - Current SEH frame
+            push( cast(size_t) m_ctxt.bstack );                     // FS:[4] - Top of stack
+            push( cast(size_t) m_ctxt.bstack - m_size );            // FS:[8] - Bottom of stack
+            push( 0x00000000 );                                     // EAX
+        }
+        else version (GNU_AsmX86_64_Windows)
+        {
+            push( 0x00000000_00000000 );                            // Return address of fiber_entryPoint call
+            push( cast(size_t) &fiber_entryPoint );                 // RIP
+            push( 0x00000000_00000000 );                            // RBP
+            push( 0x00000000_00000000 );                            // RBX
+            push( 0x00000000_00000000 );                            // R12
+            push( 0x00000000_00000000 );                            // R13
+            push( 0x00000000_00000000 );                            // R14
+            push( 0x00000000_00000000 );                            // R15
+            push( 0xFFFFFFFF_FFFFFFFF );                            // GS:[0] - Current SEH frame
+            version( StackGrowsDown )
+            {
+                push( cast(size_t) m_ctxt.bstack );                 // GS:[8]  - Top of stack
+                push( cast(size_t) m_ctxt.bstack - m_size );        // GS:[16] - Bottom of stack
+            }
+            else
+            {
+                push( cast(size_t) m_ctxt.bstack );                 // GS:[8]  - Top of stack
+                push( cast(size_t) m_ctxt.bstack + m_size );        // GS:[16] - Bottom of stack
+            }
+        }
+        else static if( __traits( compiles, ucontext_t ) )
+        {
+            getcontext( &m_utxt );
+            m_utxt.uc_stack.ss_sp   = m_pmem;
+            m_utxt.uc_stack.ss_size = m_size;
+            makecontext( &m_utxt, &fiber_entryPoint, 0 );
+            // NOTE: If ucontext is being used then the top of the stack will
+            //       be a pointer to the ucontext_t struct for that fiber.
+            push( cast(size_t) &m_utxt );
+        }
+        else
+            static assert(0, "Not implemented");
+    }
+
+
+    Thread.Context* m_ctxt;
+    size_t          m_size;
+    void*           m_pmem;
+
+    static if( __traits( compiles, ucontext_t ) )
+    {
+        // NOTE: The static ucontext instance is used to represent the context
+        //       of the executing thread.
+        static ucontext_t       sm_utxt = void;
+        ucontext_t              m_utxt  = void;
+        ucontext_t*             m_ucur  = null;
+    }
+
+
+private:
+    ///////////////////////////////////////////////////////////////////////////
+    // Storage of Active Fiber
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    //
+    // Sets a thread-local reference to the current fiber object.
+    //
+    static void setThis( Fiber f ) nothrow
+    {
+        sm_this = f;
+    }
+
+    static Fiber sm_this;
+
+
+private:
+    ///////////////////////////////////////////////////////////////////////////
+    // Context Switching
+    ///////////////////////////////////////////////////////////////////////////
+
+
+    //
+    // Switches into the stack held by this fiber.
+    //
+    final void switchIn() nothrow
+    {
+        Thread  tobj = Thread.getThis();
+        void**  oldp = &tobj.m_curr.tstack;
+        void*   newp = m_ctxt.tstack;
+
+        // NOTE: The order of operations here is very important.  The current
+        //       stack top must be stored before m_lock is set, and pushContext
+        //       must not be called until after m_lock is set.  This process
+        //       is intended to prevent a race condition with the suspend
+        //       mechanism used for garbage collection.  If it is not followed,
+        //       a badly timed collection could cause the GC to scan from the
+        //       bottom of one stack to the top of another, or to miss scanning
+        //       a stack that still contains valid data.  The old stack pointer
+        //       oldp will be set again before the context switch to guarantee
+        //       that it points to exactly the correct stack location so the
+        //       successive pop operations will succeed.
+        *oldp = getStackTop();
+        atomicStore!(MemoryOrder.raw)(*cast(shared)&tobj.m_lock, true);
+        tobj.pushContext( m_ctxt );
+
+        fiber_switchContext( oldp, newp );
+
+        // NOTE: As above, these operations must be performed in a strict order
+        //       to prevent Bad Things from happening.
+        tobj.popContext();
+        atomicStore!(MemoryOrder.raw)(*cast(shared)&tobj.m_lock, false);
+        tobj.m_curr.tstack = tobj.m_curr.bstack;
+    }
+
+
+    //
+    // Switches out of the current stack and into the enclosing stack.
+    //
+    final void switchOut() nothrow
+    {
+        Thread  tobj = Thread.getThis();
+        void**  oldp = &m_ctxt.tstack;
+        void*   newp = tobj.m_curr.within.tstack;
+
+        // NOTE: The order of operations here is very important.  The current
+        //       stack top must be stored before m_lock is set, and pushContext
+        //       must not be called until after m_lock is set.  This process
+        //       is intended to prevent a race condition with the suspend
+        //       mechanism used for garbage collection.  If it is not followed,
+        //       a badly timed collection could cause the GC to scan from the
+        //       bottom of one stack to the top of another, or to miss scanning
+        //       a stack that still contains valid data.  The old stack pointer
+        //       oldp will be set again before the context switch to guarantee
+        //       that it points to exactly the correct stack location so the
+        //       successive pop operations will succeed.
+        *oldp = getStackTop();
+        atomicStore!(MemoryOrder.raw)(*cast(shared)&tobj.m_lock, true);
+
+        fiber_switchContext( oldp, newp );
+
+        // NOTE: As above, these operations must be performed in a strict order
+        //       to prevent Bad Things from happening.
+        // NOTE: If use of this fiber is multiplexed across threads, the thread
+        //       executing here may be different from the one above, so get the
+        //       current thread handle before unlocking, etc.
+        tobj = Thread.getThis();
+        atomicStore!(MemoryOrder.raw)(*cast(shared)&tobj.m_lock, false);
+        tobj.m_curr.tstack = tobj.m_curr.bstack;
+    }
+}
+
+
+version( unittest )
+{
+    class TestFiber : Fiber
+    {
+        this()
+        {
+            super(&run);
+        }
+
+        void run()
+        {
+            foreach(i; 0 .. 1000)
+            {
+                sum += i;
+                Fiber.yield();
+            }
+        }
+
+        enum expSum = 1000 * 999 / 2;
+        size_t sum;
+    }
+
+    void runTen()
+    {
+        TestFiber[10] fibs;
+        foreach(ref fib; fibs)
+            fib = new TestFiber();
+
+        bool cont;
+        do {
+            cont = false;
+            foreach(fib; fibs) {
+                if (fib.state == Fiber.State.HOLD)
+                {
+                    fib.call();
+                    cont |= fib.state != Fiber.State.TERM;
+                }
+            }
+        } while (cont);
+
+        foreach(fib; fibs)
+        {
+            assert(fib.sum == TestFiber.expSum);
+        }
+    }
+}
+
+
+// Single thread running separate fibers
+unittest
+{
+    runTen();
+}
+
+
+// Multiple threads running separate fibers
+unittest
+{
+    auto group = new ThreadGroup();
+    foreach(_; 0 .. 4)
+    {
+        group.create(&runTen);
+    }
+    group.joinAll();
+}
+
+
+// Multiple threads running shared fibers
+unittest
+{
+    shared bool[10] locks;
+    TestFiber[10] fibs;
+
+    void runShared()
+    {
+        bool cont;
+        do {
+            cont = false;
+            foreach(idx; 0 .. 10)
+            {
+                if (cas(&locks[idx], false, true))
+                {
+                    if (fibs[idx].state == Fiber.State.HOLD)
+                    {
+                        fibs[idx].call();
+                        cont |= fibs[idx].state != Fiber.State.TERM;
+                    }
+                    locks[idx] = false;
+                }
+                else
+                {
+                    cont = true;
+                }
+            }
+        } while (cont);
+    }
+
+    foreach(ref fib; fibs)
+    {
+        fib = new TestFiber();
+    }
+
+    auto group = new ThreadGroup();
+    foreach(_; 0 .. 4)
+    {
+        group.create(&runShared);
+    }
+    group.joinAll();
+
+    foreach(fib; fibs)
+    {
+        assert(fib.sum == TestFiber.expSum);
+    }
+}
+
+
+// Test exception handling inside fibers.
+version (Win32) {
+    // broken on win32 under windows server 2012: bug 13821
+} else unittest {
+    enum MSG = "Test message.";
+    string caughtMsg;
+    (new Fiber({
+        try
+        {
+            throw new Exception(MSG);
+        }
+        catch (Exception e)
+        {
+            caughtMsg = e.msg;
+        }
+    })).call();
+    assert(caughtMsg == MSG);
+}
+
+
+unittest
+{
+    int x = 0;
+
+    (new Fiber({
+        x++;
+    })).call();
+    assert( x == 1 );
+}
+
+nothrow unittest
+{
+    new Fiber({}).call!(Fiber.Rethrow.no)();
+}
+
+unittest
+{
+    new Fiber({}).call(Fiber.Rethrow.yes);
+    new Fiber({}).call(Fiber.Rethrow.no);
+}
+
+deprecated unittest
+{
+    new Fiber({}).call(true);
+    new Fiber({}).call(false);
+}
+
+version (Win32) {
+    // broken on win32 under windows server 2012: bug 13821
+} else unittest {
+    enum MSG = "Test message.";
+
+    try
+    {
+        (new Fiber({
+            throw new Exception( MSG );
+        })).call();
+        assert( false, "Expected rethrown exception." );
+    }
+    catch( Throwable t )
+    {
+        assert( t.msg == MSG );
+    }
+}
+
+// Test exception chaining when switching contexts in finally blocks.
+unittest
+{
+    static void throwAndYield(string msg) {
+      try {
+        throw new Exception(msg);
+      } finally {
+        Fiber.yield();
+      }
+    }
+
+    static void fiber(string name) {
+      try {
+        try {
+          throwAndYield(name ~ ".1");
+        } finally {
+          throwAndYield(name ~ ".2");
+        }
+      } catch (Exception e) {
+        assert(e.msg == name ~ ".1");
+        assert(e.next);
+        assert(e.next.msg == name ~ ".2");
+        assert(!e.next.next);
+      }
+    }
+
+    auto first = new Fiber(() => fiber("first"));
+    auto second = new Fiber(() => fiber("second"));
+    first.call();
+    second.call();
+    first.call();
+    second.call();
+    first.call();
+    second.call();
+    assert(first.state == Fiber.State.TERM);
+    assert(second.state == Fiber.State.TERM);
+}
+
+// Test Fiber resetting
+unittest
+{
+    static string method;
+
+    static void foo()
+    {
+        method = "foo";
+    }
+
+    void bar()
+    {
+        method = "bar";
+    }
+
+    static void expect(Fiber fib, string s)
+    {
+        assert(fib.state == Fiber.State.HOLD);
+        fib.call();
+        assert(fib.state == Fiber.State.TERM);
+        assert(method == s); method = null;
+    }
+    auto fib = new Fiber(&foo);
+    expect(fib, "foo");
+
+    fib.reset();
+    expect(fib, "foo");
+
+    fib.reset(&foo);
+    expect(fib, "foo");
+
+    fib.reset(&bar);
+    expect(fib, "bar");
+
+    fib.reset(function void(){method = "function";});
+    expect(fib, "function");
+
+    fib.reset(delegate void(){method = "delegate";});
+    expect(fib, "delegate");
+}
+
+// Test unsafe reset in hold state
+unittest
+{
+    auto fib = new Fiber(function {ubyte[2048] buf = void; Fiber.yield();}, 4096);
+    foreach (_; 0 .. 10)
+    {
+        fib.call();
+        assert(fib.state == Fiber.State.HOLD);
+        fib.reset();
+    }
+}
+
+// stress testing GC stack scanning
+unittest
+{
+    import core.memory;
+
+    static void unreferencedThreadObject()
+    {
+        static void sleep() { Thread.sleep(dur!"msecs"(100)); }
+        auto thread = new Thread(&sleep).start();
+    }
+    unreferencedThreadObject();
+    GC.collect();
+
+    static class Foo
+    {
+        this(int value)
+        {
+            _value = value;
+        }
+
+        int bar()
+        {
+            return _value;
+        }
+
+        int _value;
+    }
+
+    static void collect()
+    {
+        auto foo = new Foo(2);
+        assert(foo.bar() == 2);
+        GC.collect();
+        Fiber.yield();
+        GC.collect();
+        assert(foo.bar() == 2);
+    }
+
+    auto fiber = new Fiber(&collect);
+
+    fiber.call();
+    GC.collect();
+    fiber.call();
+
+    // thread reference
+    auto foo = new Foo(2);
+
+    void collect2()
+    {
+        assert(foo.bar() == 2);
+        GC.collect();
+        Fiber.yield();
+        GC.collect();
+        assert(foo.bar() == 2);
+    }
+
+    fiber = new Fiber(&collect2);
+
+    fiber.call();
+    GC.collect();
+    fiber.call();
+
+    static void recurse(size_t cnt)
+    {
+        --cnt;
+        Fiber.yield();
+        if (cnt)
+        {
+            auto fib = new Fiber(() { recurse(cnt); });
+            fib.call();
+            GC.collect();
+            fib.call();
+        }
+    }
+    fiber = new Fiber(() { recurse(20); });
+    fiber.call();
+}
+
+
+version( AsmX86_64_Windows )
+{
+    // Test Windows x64 calling convention
+    unittest
+    {
+        void testNonvolatileRegister(alias REG)()
+        {
+            auto zeroRegister = new Fiber(() {
+                mixin("asm pure nothrow @nogc { naked; xor "~REG~", "~REG~"; ret; }");
+            });
+            long after;
+
+            mixin("asm pure nothrow @nogc { mov "~REG~", 0xFFFFFFFFFFFFFFFF; }");
+            zeroRegister.call();
+            mixin("asm pure nothrow @nogc { mov after, "~REG~"; }");
+
+            assert(after == -1);
+        }
+
+        void testNonvolatileRegisterSSE(alias REG)()
+        {
+            auto zeroRegister = new Fiber(() {
+                mixin("asm pure nothrow @nogc { naked; xorpd "~REG~", "~REG~"; ret; }");
+            });
+            long[2] before = [0xFFFFFFFF_FFFFFFFF, 0xFFFFFFFF_FFFFFFFF], after;
+
+            mixin("asm pure nothrow @nogc { movdqu "~REG~", before; }");
+            zeroRegister.call();
+            mixin("asm pure nothrow @nogc { movdqu after, "~REG~"; }");
+
+            assert(before == after);
+        }
+
+        testNonvolatileRegister!("R12")();
+        testNonvolatileRegister!("R13")();
+        testNonvolatileRegister!("R14")();
+        testNonvolatileRegister!("R15")();
+        testNonvolatileRegister!("RDI")();
+        testNonvolatileRegister!("RSI")();
+        testNonvolatileRegister!("RBX")();
+
+        testNonvolatileRegisterSSE!("XMM6")();
+        testNonvolatileRegisterSSE!("XMM7")();
+        testNonvolatileRegisterSSE!("XMM8")();
+        testNonvolatileRegisterSSE!("XMM9")();
+        testNonvolatileRegisterSSE!("XMM10")();
+        testNonvolatileRegisterSSE!("XMM11")();
+        testNonvolatileRegisterSSE!("XMM12")();
+        testNonvolatileRegisterSSE!("XMM13")();
+        testNonvolatileRegisterSSE!("XMM14")();
+        testNonvolatileRegisterSSE!("XMM15")();
+    }
+}
+
+
+version( D_InlineAsm_X86_64 )
+{
+    unittest
+    {
+        void testStackAlignment()
+        {
+            void* pRSP;
+            asm pure nothrow @nogc
+            {
+                mov pRSP, RSP;
+            }
+            assert((cast(size_t)pRSP & 0xF) == 0);
+        }
+
+        auto fib = new Fiber(&testStackAlignment);
+        fib.call();
+    }
+}
+
+// regression test for Issue 13416
+version (FreeBSD) unittest
+{
+    static void loop()
+    {
+        pthread_attr_t attr;
+        pthread_attr_init(&attr);
+        auto thr = pthread_self();
+        foreach (i; 0 .. 50)
+            pthread_attr_get_np(thr, &attr);
+        pthread_attr_destroy(&attr);
+    }
+
+    auto thr = new Thread(&loop).start();
+    foreach (i; 0 .. 50)
+    {
+        thread_suspendAll();
+        thread_resumeAll();
+    }
+    thr.join();
+}
+
+unittest
+{
+    // use >PAGESIZE to avoid stack overflow (e.g. in an syscall)
+    auto thr = new Thread(function{}, 4096 + 1).start();
+    thr.join();
+}
+
+/**
+ * Represents the ID of a thread, as returned by $(D Thread.)$(LREF id).
+ * The exact type varies from platform to platform.
+ */
+version (Windows)
+    alias ThreadID = uint;
+else
+version (Posix)
+    alias ThreadID = pthread_t;
diff --git a/libphobos/libdruntime/core/threadasm.S b/libphobos/libdruntime/core/threadasm.S
new file mode 100644
index 00000000000..1427b98fd9e
--- /dev/null
+++ b/libphobos/libdruntime/core/threadasm.S
@@ -0,0 +1,601 @@
+/**
+ * Support code for mutithreading.
+ *
+ * Copyright: Copyright Mikola Lysenko 2005 - 2012.
+ * License:   $(WEB http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Mikola Lysenko, Martin Nowak, Kai Nacke
+ */
+
+/*
+ *          Copyright Mikola Lysenko 2005 - 2012.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE_1_0.txt or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
+/*
+ * Mark the resulting object file as not requiring execution permissions on
+ * stack memory. The absence of this section would mark the whole resulting
+ * library as requiring an executable stack, making it impossible to
+ * dynamically load druntime on several Linux platforms where this is
+ * forbidden due to security policies.
+ * Use %progbits instead of @progbits to support ARM and X86.
+ */
+.section .note.GNU-stack,"",%progbits
+#endif
+
+/* Let preprocessor tell us if C symbols have a prefix: __USER_LABEL_PREFIX__ */
+#ifdef __USER_LABEL_PREFIX__
+#define GLUE2(a, b) a ## b
+#define GLUE(a, b) GLUE2(a, b)
+#define CSYM(name) GLUE(__USER_LABEL_PREFIX__, name)
+#else
+#define CSYM(name) name
+#endif
+
+/************************************************************************************
+ * POWER PC ASM BITS
+ ************************************************************************************/
+#if defined( __PPC64__ )
+
+#if defined(_CALL_ELF) && _CALL_ELF == 2
+#define USE_ABI_2
+#define LINKAGE_SZ   32
+#define LR_OFS       16
+#define TOC_OFS      24
+#define GPR_OFS      32
+#define STACK_SZ     (LINKAGE_SZ + 26*8)
+#define OFS_R3_R10   GPR_OFS
+#define OFS_R14_R31  (GPR_OFS+8*8)
+#else
+#define LINKAGE_SZ   48
+#define LR_OFS       16
+#define TOC_OFS      40
+#define GPR_OFS      112
+#define STACK_SZ     (LINKAGE_SZ + 8*8 + 18*8)
+#define OFS_R3_R10   (STACK_SZ+LINKAGE_SZ)
+#define OFS_R14_R31  GPR_OFS
+#endif
+
+    .text
+#if defined( USE_ABI_2 )
+    .abiversion 2
+#endif
+    .globl  _D4core6thread18callWithStackShellFNbMDFPvZvZv
+    .globl  _D4core6thread18callWithStackShellFNbMDFNbPvZvZv
+    .align  2
+    .type   _D4core6thread18callWithStackShellFNbMDFNbPvZvZv,@function
+#if defined( USE_ABI_2 )
+    .section .text._D4core6thread18callWithStackShellFNbMDFNbPvZvZv,"a",@progbits
+#else
+    .section .opd,"aw",@progbits
+#endif
+_D4core6thread18callWithStackShellFNbMDFNbPvZvZv:
+#if !defined( USE_ABI_2 )
+    .align  3
+    .quad .L._D4core6thread18callWithStackShellFNbMDFNbPvZvZv
+    .quad .TOC.@tocbase
+    .quad 0
+#endif
+    .text
+/*
+ * Called with:
+ * r3: pointer context
+ * r4: pointer to function
+ */
+.L._D4core6thread18callWithStackShellFNbMDFNbPvZvZv:
+    .cfi_startproc
+    stdu    1, -STACK_SZ(1)
+    mflr    0
+    std     0, LR_OFS(1)
+    .cfi_def_cfa_offset 256
+    .cfi_offset lr, 16
+
+    /* Save r14-r31 in general register save area */
+    std     14, (OFS_R14_R31 + 0 * 8)(1)
+    std     15, (OFS_R14_R31 + 1 * 8)(1)
+    std     16, (OFS_R14_R31 + 2 * 8)(1)
+    std     17, (OFS_R14_R31 + 3 * 8)(1)
+    std     18, (OFS_R14_R31 + 4 * 8)(1)
+    std     19, (OFS_R14_R31 + 5 * 8)(1)
+    std     20, (OFS_R14_R31 + 6 * 8)(1)
+    std     21, (OFS_R14_R31 + 7 * 8)(1)
+    std     22, (OFS_R14_R31 + 8 * 8)(1)
+    std     23, (OFS_R14_R31 + 9 * 8)(1)
+    std     24, (OFS_R14_R31 + 10 * 8)(1)
+    std     25, (OFS_R14_R31 + 11 * 8)(1)
+    std     26, (OFS_R14_R31 + 12 * 8)(1)
+    std     27, (OFS_R14_R31 + 13 * 8)(1)
+    std     28, (OFS_R14_R31 + 14 * 8)(1)
+    std     29, (OFS_R14_R31 + 15 * 8)(1)
+    std     30, (OFS_R14_R31 + 16 * 8)(1)
+    std     31, (OFS_R14_R31 + 17 * 8)(1)
+
+    /* Save r3-r10 in parameter save area of caller */
+    std     3, (OFS_R3_R10 + 0 * 8)(1)
+    std     4, (OFS_R3_R10 + 1 * 8)(1)
+    std     5, (OFS_R3_R10 + 2 * 8)(1)
+    std     6, (OFS_R3_R10 + 3 * 8)(1)
+    std     7, (OFS_R3_R10 + 4 * 8)(1)
+    std     8, (OFS_R3_R10 + 5 * 8)(1)
+    std     9, (OFS_R3_R10 + 6 * 8)(1)
+    std     10, (OFS_R3_R10 + 7 * 8)(1)
+
+    /* Save r2 in TOC save area */
+    std     2, TOC_OFS(1)
+
+    /* Do not save r11, r12 and r13. */
+
+    /* Call delegate:
+     * r3: pointer to context
+     * r4: pointer to stack
+     */
+    mr      5, 4
+    mr      4, 1
+    ld      6, 0(5)
+    ld      11, 16(5)
+    ld      2, 8(5)
+    mtctr   6
+    bctrl
+    nop
+
+    /* Restore r2 from TOC save area */
+    ld      2, TOC_OFS(1)
+
+    /* Restore r3-r10 from local variable space */
+    ld      3, (OFS_R3_R10 + 0 * 8)(1)
+    ld      4, (OFS_R3_R10 + 1 * 8)(1)
+    ld      5, (OFS_R3_R10 + 2 * 8)(1)
+    ld      6, (OFS_R3_R10 + 3 * 8)(1)
+    ld      7, (OFS_R3_R10 + 4 * 8)(1)
+    ld      8, (OFS_R3_R10 + 5 * 8)(1)
+    ld      9, (OFS_R3_R10 + 6 * 8)(1)
+    ld      10, (OFS_R3_R10 + 7 * 8)(1)
+
+    /* Restore r14-r31 from general register save area */
+    ld      14, (OFS_R14_R31 + 0 * 8)(1)
+    ld      15, (OFS_R14_R31 + 1 * 8)(1)
+    ld      16, (OFS_R14_R31 + 2 * 8)(1)
+    ld      17, (OFS_R14_R31 + 3 * 8)(1)
+    ld      18, (OFS_R14_R31 + 4 * 8)(1)
+    ld      19, (OFS_R14_R31 + 5 * 8)(1)
+    ld      20, (OFS_R14_R31 + 6 * 8)(1)
+    ld      21, (OFS_R14_R31 + 7 * 8)(1)
+    ld      22, (OFS_R14_R31 + 8 * 8)(1)
+    ld      23, (OFS_R14_R31 + 9 * 8)(1)
+    ld      24, (OFS_R14_R31 + 10 * 8)(1)
+    ld      25, (OFS_R14_R31 + 11 * 8)(1)
+    ld      26, (OFS_R14_R31 + 12 * 8)(1)
+    ld      27, (OFS_R14_R31 + 13 * 8)(1)
+    ld      28, (OFS_R14_R31 + 14 * 8)(1)
+    ld      29, (OFS_R14_R31 + 15 * 8)(1)
+    ld      30, (OFS_R14_R31 + 16 * 8)(1)
+    ld      31, (OFS_R14_R31 + 17 * 8)(1)
+
+    ld      0, LR_OFS(1)
+    mtlr    0
+    addi    1, 1, STACK_SZ
+    blr
+    .long 0
+    .quad 0
+.Lend:
+    .size _D4core6thread18callWithStackShellFNbMDFNbPvZvZv, .Lend-.L._D4core6thread18callWithStackShellFNbMDFNbPvZvZv
+    .cfi_endproc
+
+#elif defined( __ppc__ ) || defined( __PPC__ ) || defined( __powerpc__ )
+
+
+/**
+ * Performs a context switch.
+ *
+ * r3 - old context pointer
+ * r4 - new context pointer
+ *
+ */
+.text
+.align 2
+.globl _fiber_switchContext
+_fiber_switchContext:
+
+    /* Save linkage area */
+    mflr        0
+    mfcr        5
+    stw     0, 8(1)
+    stw     5, 4(1)
+
+    /* Save GPRs */
+    stw     11, (-1 * 4)(1)
+    stw     13, (-2 * 4)(1)
+    stw     14, (-3 * 4)(1)
+    stw     15, (-4 * 4)(1)
+    stw     16, (-5 * 4)(1)
+    stw     17, (-6 * 4)(1)
+    stw     18, (-7 * 4)(1)
+    stw     19, (-8 * 4)(1)
+    stw     20, (-9 * 4)(1)
+    stw     21, (-10 * 4)(1)
+    stw     22, (-11 * 4)(1)
+    stw     23, (-12 * 4)(1)
+    stw     24, (-13 * 4)(1)
+    stw     25, (-14 * 4)(1)
+    stw     26, (-15 * 4)(1)
+    stw     27, (-16 * 4)(1)
+    stw     28, (-17 * 4)(1)
+    stw     29, (-18 * 4)(1)
+    stw     30, (-19 * 4)(1)
+    stwu    31, (-20 * 4)(1)
+
+    /* We update the stack pointer here, since we do not want the GC to
+       scan the floating point registers. */
+
+    /* Save FPRs */
+    stfd    14, (-1 * 8)(1)
+    stfd    15, (-2 * 8)(1)
+    stfd    16, (-3 * 8)(1)
+    stfd    17, (-4 * 8)(1)
+    stfd    18, (-5 * 8)(1)
+    stfd    19, (-6 * 8)(1)
+    stfd    20, (-7 * 8)(1)
+    stfd    21, (-8 * 8)(1)
+    stfd    22, (-9 * 8)(1)
+    stfd    23, (-10 * 8)(1)
+    stfd    24, (-11 * 8)(1)
+    stfd    25, (-12 * 8)(1)
+    stfd    26, (-13 * 8)(1)
+    stfd    27, (-14 * 8)(1)
+    stfd    28, (-15 * 8)(1)
+    stfd    29, (-16 * 8)(1)
+    stfd    30, (-17 * 8)(1)
+    stfd    31, (-18 * 8)(1)
+
+    /* Update the old stack pointer */
+    stw     1, 0(3)
+
+    /* Set new stack pointer */
+    addi        1, 4, 20 * 4
+
+    /* Restore linkage area */
+    lwz     0, 8(1)
+    lwz     5, 4(1)
+
+    /* Restore GPRs */
+    lwz     11, (-1 * 4)(1)
+    lwz     13, (-2 * 4)(1)
+    lwz     14, (-3 * 4)(1)
+    lwz     15, (-4 * 4)(1)
+    lwz     16, (-5 * 4)(1)
+    lwz     17, (-6 * 4)(1)
+    lwz     18, (-7 * 4)(1)
+    lwz     19, (-8 * 4)(1)
+    lwz     20, (-9 * 4)(1)
+    lwz     21, (-10 * 4)(1)
+    lwz     22, (-11 * 4)(1)
+    lwz     23, (-12 * 4)(1)
+    lwz     24, (-13 * 4)(1)
+    lwz     25, (-14 * 4)(1)
+    lwz     26, (-15 * 4)(1)
+    lwz     27, (-16 * 4)(1)
+    lwz     28, (-17 * 4)(1)
+    lwz     29, (-18 * 4)(1)
+    lwz     30, (-19 * 4)(1)
+    lwz     31, (-20 * 4)(1)
+
+
+    /* Restore FPRs */
+    lfd     14, (-1 * 8)(4)
+    lfd     15, (-2 * 8)(4)
+    lfd     16, (-3 * 8)(4)
+    lfd     17, (-4 * 8)(4)
+    lfd     18, (-5 * 8)(4)
+    lfd     19, (-6 * 8)(4)
+    lfd     20, (-7 * 8)(4)
+    lfd     21, (-8 * 8)(4)
+    lfd     22, (-9 * 8)(4)
+    lfd     23, (-10 * 8)(4)
+    lfd     24, (-11 * 8)(4)
+    lfd     25, (-12 * 8)(4)
+    lfd     26, (-13 * 8)(4)
+    lfd     27, (-14 * 8)(4)
+    lfd     28, (-15 * 8)(4)
+    lfd     29, (-16 * 8)(4)
+    lfd     30, (-17 * 8)(4)
+    lfd     31, (-18 * 8)(4)
+
+    /* Set condition and link register */
+    mtcr        5
+    mtlr        0
+
+    /* Return and switch context */
+    blr
+
+#elif defined(__mips__) && _MIPS_SIM == _ABIO32
+/************************************************************************************
+ * MIPS ASM BITS
+ ************************************************************************************/
+
+/**
+ * Performs a context switch.
+ *
+ * $a0 - void** - ptr to old stack pointer
+ * $a1 - void*  - new stack pointer
+ *
+ */
+.text
+.globl fiber_switchContext
+fiber_switchContext:
+    addiu $sp, $sp, -(10 * 4)
+
+    // fp regs and return address are stored below the stack
+    // because we don't want the GC to scan them.
+
+#ifdef __mips_hard_float
+#define ALIGN8(val) (val + (-val & 7))
+#define BELOW (ALIGN8(6 * 8 + 4))
+    sdcl $f20, (0 * 8 - BELOW)($sp)
+    sdcl $f22, (1 * 8 - BELOW)($sp)
+    sdcl $f24, (2 * 8 - BELOW)($sp)
+    sdcl $f26, (3 * 8 - BELOW)($sp)
+    sdcl $f28, (4 * 8 - BELOW)($sp)
+    sdcl $f30, (5 * 8 - BELOW)($sp)
+#endif
+    sw $ra, -4($sp)
+
+    sw $s0, (0 * 4)($sp)
+    sw $s1, (1 * 4)($sp)
+    sw $s2, (2 * 4)($sp)
+    sw $s3, (3 * 4)($sp)
+    sw $s4, (4 * 4)($sp)
+    sw $s5, (5 * 4)($sp)
+    sw $s6, (6 * 4)($sp)
+    sw $s7, (7 * 4)($sp)
+    sw $s8, (8 * 4)($sp)
+    sw $gp, (9 * 4)($sp)
+
+    // swap stack pointer
+    sw $sp, 0($a0)
+    move $sp, $a1
+
+#ifdef __mips_hard_float
+    ldcl $f20, (0 * 8 - BELOW)($sp)
+    ldcl $f22, (1 * 8 - BELOW)($sp)
+    ldcl $f24, (2 * 8 - BELOW)($sp)
+    ldcl $f26, (3 * 8 - BELOW)($sp)
+    ldcl $f28, (4 * 8 - BELOW)($sp)
+    ldcl $f30, (5 * 8 - BELOW)($sp)
+#endif
+    lw $ra, -4($sp)
+
+    lw $s0, (0 * 4)($sp)
+    lw $s1, (1 * 4)($sp)
+    lw $s2, (2 * 4)($sp)
+    lw $s3, (3 * 4)($sp)
+    lw $s4, (4 * 4)($sp)
+    lw $s5, (5 * 4)($sp)
+    lw $s6, (6 * 4)($sp)
+    lw $s7, (7 * 4)($sp)
+    lw $s8, (8 * 4)($sp)
+    lw $gp, (9 * 4)($sp)
+
+    addiu $sp, $sp, (10 * 4)
+
+    jr $ra // return
+
+#elif defined(__arm__) && defined(__ARM_EABI__)
+/************************************************************************************
+ * ARM ASM BITS
+ ************************************************************************************/
+
+/**
+ * Performs a context switch.
+ *
+ * Parameters:
+ * r0 - void** - ptr to old stack pointer
+ * r1 - void*  - new stack pointer
+ *
+ * ARM EABI registers:
+ * r0-r3   : argument/scratch registers
+ * r4-r10  : callee-save registers
+ * r11     : frame pointer (or a callee save register if fp isn't needed)
+ * r12 =ip : inter procedure register. We can treat it like any other scratch register
+ * r13 =sp : stack pointer
+ * r14 =lr : link register, it contains the return address (belonging to the function which called us)
+ * r15 =pc : program counter
+ *
+ * For floating point registers:
+ * According to AAPCS (version 2.09, section 5.1.2) only the d8-d15 registers need to be preserved
+ * across method calls. This applies to all ARM FPU variants, whether they have 16 or 32 double registers
+ * NEON support or not, half-float support or not and so on does not matter.
+ *
+ * Note: If this file was compiled with -mfloat-abi=soft but the code runs on a softfp system with fpu the d8-d15
+ * registers won't be saved (we do not know that the system has got a fpu in that case) but the registers might actually
+ * be used by other code if it was compiled with -mfloat-abi=softfp.
+ *
+ * Interworking is only supported on ARMv5+, not on ARM v4T as ARM v4t requires special stubs when changing
+ * from thumb to arm mode or the other way round.
+ */
+
+.text
+.align  2
+.global fiber_switchContext
+#if defined(__ARM_PCS_VFP) || (defined(__ARM_PCS) && !defined(__SOFTFP__)) // ARM_HardFloat  || ARM_SoftFP
+  .fpu vfp
+#endif
+.type   fiber_switchContext, %function
+fiber_switchContext:
+    .fnstart
+    push {r4-r11}
+    // update the oldp pointer. Link register and floating point registers stored later to prevent the GC from
+    // scanning them.
+    str sp, [r0]
+    // push r0 (or any other register) as well to keep stack 8byte aligned
+    push {r0, lr}
+
+    #if defined(__ARM_PCS_VFP) || (defined(__ARM_PCS) && !defined(__SOFTFP__)) // ARM_HardFloat  || ARM_SoftFP
+      vpush {d8-d15}
+      // now switch over to the new stack. Need to subtract (8*8[d8-d15]+2*4[r0, lr]) to position stack pointer
+      // below the last saved register. Remember we saved the SP before pushing [r0, lr, d8-d15]
+      sub sp, r1, #72
+      vpop {d8-d15}
+    #else
+      sub sp, r1, #8
+    #endif
+
+    // we don't really care about r0, we only used that for padding.
+    // r1 is now what used to be in the link register when saving.
+    pop {r0, r1, r4-r11}
+    /**
+     * The link register for the initial jump to fiber_entryPoint must be zero: The jump actually
+     * looks like a normal method call as we jump to the start of the fiber_entryPoint function.
+     * Although fiber_entryPoint never returns and therefore never accesses lr, it saves lr to the stack.
+     * ARM unwinding will then look at the stack, find lr and think that fiber_entryPoint was called by
+     * the function in lr! So if we have some address in lr the unwinder will try to continue stack unwinding,
+     * although it's already at the stack base and crash.
+     * In all other cases the content of lr doesn't matter.
+     * Note: If we simply loaded into lr above and then moved lr into pc, the initial method call
+     * to fiber_entryPoint would look as if it was called from fiber_entryPoint itself, as the fiber_entryPoint
+     * address is in lr on the initial context switch.
+     */
+    mov lr, #0
+    // return by writing lr into pc
+    mov pc, r1
+    .fnend
+#endif
+/************************************************************************************
+ * GDC MinGW ASM BITS
+ ************************************************************************************/
+#if defined(__x86_64__) && defined(__MINGW32__)
+.global fiber_switchContext
+fiber_switchContext:
+    pushq %RBP;
+    movq %RSP, %RBP;
+    pushq %RBX;
+    pushq %R12;
+    pushq %R13;
+    pushq %R14;
+    pushq %R15;
+    pushq %GS:0;
+    pushq %GS:8;
+    pushq %GS:16;
+
+    // store oldp
+    movq %RSP, (%RCX);
+    // load newp to begin context switch
+    movq %RDX, %RSP;
+
+    // load saved state from new stack
+    popq %GS:16;
+    popq %GS:8;
+    popq %GS:0;
+    popq %R15;
+    popq %R14;
+    popq %R13;
+    popq %R12;
+    popq %RBX;
+    popq %RBP;
+
+    // 'return' to complete switch
+    popq %RCX;
+    jmp *%RCX;
+#endif
+#if defined(_X86_) && defined(__MINGW32__)
+.global _fiber_switchContext
+_fiber_switchContext:
+    // Save current stack state.save current stack state
+    // Standard CDECL prologue.
+    push %EBP;
+    mov  %ESP, %EBP;
+    push %EDI;
+    push %ESI;
+    push %EBX;
+    push %FS:0;
+    push %FS:4;
+    push %FS:8;
+    push %EAX;
+
+    // store oldp again with more accurate address
+    mov 8(%EBP), %EAX;
+    mov %ESP, (%EAX);
+    // load newp to begin context switch
+    mov 12(%EBP), %ESP;
+
+    // load saved state from new stack
+    pop %EAX;
+    pop %FS:8;
+    pop %FS:4;
+    pop %FS:0;
+    pop %EBX;
+    pop %ESI;
+    pop %EDI;
+    pop %EBP;
+
+    // 'return' to complete switch
+    ret;
+#endif
+/************************************************************************************
+ * i386- and x86_64-apple-darwin POSIX ASM BITS
+ ************************************************************************************/
+// if POSIX boils down to this (reference http://nadeausoftware.com)
+#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
+#if defined(__i386__)
+.text
+.p2align 4
+.globl CSYM(fiber_switchContext)
+CSYM(fiber_switchContext):
+    // save current stack state
+    push %ebp
+    mov  %esp, %ebp
+    push %edi
+    push %esi
+    push %ebx
+    push %eax
+
+    // store oldp again with more accurate address
+    mov 8(%ebp), %eax
+    mov %esp, (%eax)
+    // load newp to begin context switch
+    mov 12(%ebp), %esp
+
+    // load saved state from new stack
+    pop %eax
+    pop %ebx
+    pop %esi
+    pop %edi
+    pop %ebp
+
+    // 'return' to complete switch
+    ret
+#elif defined(__x86_64__) && !defined(__ILP32__)
+.text
+.p2align 4
+.globl CSYM(fiber_switchContext)
+CSYM(fiber_switchContext):
+    // Save current stack state.save current stack state
+    push %rbp
+    mov  %rsp, %rbp
+    push %rbx
+    push %r12
+    push %r13
+    push %r14
+    push %r15
+
+    // store oldp again with more accurate address
+    mov %rsp, (%rdi)
+    // load newp to begin context switch
+    mov %rsi, %rsp
+
+    // load saved state from new stack
+    pop %r15
+    pop %r14
+    pop %r13
+    pop %r12
+    pop %rbx
+    pop %rbp
+
+    // 'return' to complete switch
+    ret
+#endif	// __x86_64__ && !__ILP32__
+#endif	// posix
diff --git a/libphobos/libdruntime/core/time.d b/libphobos/libdruntime/core/time.d
new file mode 100644
index 00000000000..24943104016
--- /dev/null
+++ b/libphobos/libdruntime/core/time.d
@@ -0,0 +1,4891 @@
+//Written in the D programming language
+
+/++
+    Module containing core time functionality, such as $(LREF Duration) (which
+    represents a duration of time) or $(LREF MonoTime) (which represents a
+    timestamp of the system's monotonic clock).
+
+    Various functions take a string (or strings) to represent a unit of time
+    (e.g. $(D convert!("days", "hours")(numDays))). The valid strings to use
+    with such functions are "years", "months", "weeks", "days", "hours",
+    "minutes", "seconds", "msecs" (milliseconds), "usecs" (microseconds),
+    "hnsecs" (hecto-nanoseconds - i.e. 100 ns) or some subset thereof. There
+    are a few functions that also allow "nsecs", but very little actually
+    has precision greater than hnsecs.
+
+    $(BOOKTABLE Cheat Sheet,
+    $(TR $(TH Symbol) $(TH Description))
+    $(LEADINGROW Types)
+    $(TR $(TDNW $(LREF Duration)) $(TD Represents a duration of time of weeks
+    or less (kept internally as hnsecs). (e.g. 22 days or 700 seconds).))
+    $(TR $(TDNW $(LREF TickDuration)) $(TD Represents a duration of time in
+    system clock ticks, using the highest precision that the system provides.))
+    $(TR $(TDNW $(LREF MonoTime)) $(TD Represents a monotonic timestamp in
+    system clock ticks, using the highest precision that the system provides.))
+    $(TR $(TDNW $(LREF FracSec)) $(TD Represents fractional seconds
+    (portions of time smaller than a second).))
+    $(LEADINGROW Functions)
+    $(TR $(TDNW $(LREF convert)) $(TD Generic way of converting between two time
+    units.))
+    $(TR $(TDNW $(LREF dur)) $(TD Allows constructing a $(LREF Duration) from
+    the given time units with the given length.))
+    $(TR $(TDNW $(LREF weeks)$(NBSP)$(LREF days)$(NBSP)$(LREF hours)$(BR)
+    $(LREF minutes)$(NBSP)$(LREF seconds)$(NBSP)$(LREF msecs)$(BR)
+    $(LREF usecs)$(NBSP)$(LREF hnsecs)$(NBSP)$(LREF nsecs))
+    $(TD Convenience aliases for $(LREF dur).))
+    $(TR $(TDNW $(LREF abs)) $(TD Returns the absolute value of a duration.))
+    )
+
+    $(BOOKTABLE Conversions,
+    $(TR $(TH )
+     $(TH From $(LREF Duration))
+     $(TH From $(LREF TickDuration))
+     $(TH From $(LREF FracSec))
+     $(TH From units)
+    )
+    $(TR $(TD $(B To $(LREF Duration)))
+     $(TD -)
+     $(TD $(D tickDuration.)$(SXREF conv, to)$(D !Duration()))
+     $(TD -)
+     $(TD $(D dur!"msecs"(5)) or $(D 5.msecs()))
+    )
+    $(TR $(TD $(B To $(LREF TickDuration)))
+     $(TD $(D duration.)$(SXREF conv, to)$(D !TickDuration()))
+     $(TD -)
+     $(TD -)
+     $(TD $(D TickDuration.from!"msecs"(msecs)))
+    )
+    $(TR $(TD $(B To $(LREF FracSec)))
+     $(TD $(D duration.fracSec))
+     $(TD -)
+     $(TD -)
+     $(TD $(D FracSec.from!"msecs"(msecs)))
+    )
+    $(TR $(TD $(B To units))
+     $(TD $(D duration.total!"days"))
+     $(TD $(D tickDuration.msecs))
+     $(TD $(D fracSec.msecs))
+     $(TD $(D convert!("days", "msecs")(msecs)))
+    ))
+
+    Copyright: Copyright 2010 - 2012
+    License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+    Authors:   Jonathan M Davis and Kato Shoichi
+    Source:    $(DRUNTIMESRC core/_time.d)
+    Macros:
+    NBSP=&nbsp;
+    SXREF=<a href="std_$1.html#$2">$(D $2)</a>
+ +/
+module core.time;
+
+import core.exception;
+import core.stdc.time;
+import core.stdc.stdio;
+import core.internal.traits : _Unqual = Unqual;
+import core.internal.string;
+
+version(Windows)
+{
+import core.sys.windows.windows;
+}
+else version(Posix)
+{
+import core.sys.posix.time;
+import core.sys.posix.sys.time;
+}
+
+//This probably should be moved somewhere else in druntime which
+//is OSX-specific.
+version(OSX)
+{
+
+public import core.sys.osx.mach.kern_return;
+
+extern(C) nothrow @nogc
+{
+
+struct mach_timebase_info_data_t
+{
+    uint numer;
+    uint denom;
+}
+
+alias mach_timebase_info_data_t* mach_timebase_info_t;
+
+kern_return_t mach_timebase_info(mach_timebase_info_t);
+
+ulong mach_absolute_time();
+
+}
+
+}
+
+//To verify that an lvalue isn't required.
+version(unittest) T copy(T)(T t)
+{
+    return t;
+}
+
+
+/++
+    What type of clock to use with $(LREF MonoTime) / $(LREF MonoTimeImpl) or
+    $(D std.datetime.Clock.currTime). They default to $(D ClockType.normal),
+    and most programs do not need to ever deal with the others.
+
+    The other $(D ClockType)s are provided so that other clocks provided by the
+    underlying C, system calls can be used with $(LREF MonoTimeImpl) or
+    $(D std.datetime.Clock.currTime) without having to use the C API directly.
+
+    In the case of the monotonic time, $(LREF MonoTimeImpl) is templatized on
+    $(D ClockType), whereas with $(D std.datetime.Clock.currTime), its a runtime
+    argument, since in the case of the monotonic time, the type of the clock
+    affects the resolution of a $(LREF MonoTimeImpl) object, whereas with
+    $(XREF datetime, SysTime), its resolution is always hecto-nanoseconds
+    regardless of the source of the time.
+
+    $(D ClockType.normal), $(D ClockType.coarse), and $(D ClockType.precise)
+    work with both $(D Clock.currTime) and $(LREF MonoTimeImpl).
+    $(D ClockType.second) only works with $(D Clock.currTime). The others only
+    work with $(LREF MonoTimeImpl).
+  +/
+version(CoreDdoc) enum ClockType
+{
+    /++
+        Use the normal clock.
+      +/
+    normal = 0,
+
+    /++
+        $(BLUE Linux-Only)
+
+        Uses $(D CLOCK_BOOTTIME).
+      +/
+    bootTime = 1,
+
+    /++
+        Use the coarse clock, not the normal one (e.g. on Linux, that would be
+        $(D CLOCK_REALTIME_COARSE) instead of $(D CLOCK_REALTIME) for
+        $(D clock_gettime) if a function is using the realtime clock). It's
+        generally faster to get the time with the coarse clock than the normal
+        clock, but it's less precise (e.g. 1 msec instead of 1 usec or 1 nsec).
+        Howeover, it $(I is) guaranteed to still have sub-second precision
+        (just not as high as with $(D ClockType.normal)).
+
+        On systems which do not support a coarser clock,
+        $(D MonoTimeImpl!(ClockType.coarse)) will internally use the same clock
+        as $(D Monotime) does, and $(D Clock.currTime!(ClockType.coarse)) will
+        use the same clock as $(D Clock.currTime). This is because the coarse
+        clock is doing the same thing as the normal clock (just at lower
+        precision), whereas some of the other clock types
+        (e.g. $(D ClockType.processCPUTime)) mean something fundamentally
+        different. So, treating those as $(D ClockType.normal) on systems where
+        they weren't natively supported would give misleading results.
+
+        Most programs should not use the coarse clock, exactly because it's
+        less precise, and most programs don't need to get the time often
+        enough to care, but for those rare programs that need to get the time
+        extremely frequently (e.g. hundreds of thousands of times a second) but
+        don't care about high precision, the coarse clock might be appropriate.
+
+        Currently, only Linux and FreeBSD support a coarser clock, and on other
+        platforms, it's treated as $(D ClockType.normal).
+      +/
+    coarse = 2,
+
+    /++
+        Uses a more precise clock than the normal one (which is already very
+        precise), but it takes longer to get the time. Similarly to
+        $(D ClockType.coarse), if it's used on a system that does not support a
+        more precise clock than the normal one, it's treated as equivalent to
+        $(D ClockType.normal).
+
+        Currently, only FreeBSD supports a more precise clock, where it uses
+        $(D CLOCK_MONOTONIC_PRECISE) for the monotonic time and
+        $(D CLOCK_REALTIME_PRECISE) for the wall clock time.
+      +/
+    precise = 3,
+
+    /++
+        $(BLUE Linux,Solaris-Only)
+
+        Uses $(D CLOCK_PROCESS_CPUTIME_ID).
+      +/
+    processCPUTime = 4,
+
+    /++
+        $(BLUE Linux-Only)
+
+        Uses $(D CLOCK_MONOTONIC_RAW).
+      +/
+    raw = 5,
+
+    /++
+        Uses a clock that has a precision of one second (contrast to the coarse
+        clock, which has sub-second precision like the normal clock does).
+
+        FreeBSD is the only system which specifically has a clock set up for
+        this (it has $(D CLOCK_SECOND) to use with $(D clock_gettime) which
+        takes advantage of an in-kernel cached value), but on other systems, the
+        fastest function available will be used, and the resulting $(D SysTime)
+        will be rounded down to the second if the clock that was used gave the
+        time at a more precise resolution. So, it's guaranteed that the time
+        will be given at a precision of one second and it's likely the case that
+        will be faster than $(D ClockType.normal), since there tend to be
+        several options on a system to get the time at low resolutions, and they
+        tend to be faster than getting the time at high resolutions.
+
+        So, the primary difference between $(D ClockType.coarse) and
+        $(D ClockType.second) is that $(D ClockType.coarse) sacrifices some
+        precision in order to get speed but is still fairly precise, whereas
+        $(D ClockType.second) tries to be as fast as possible at the expense of
+        all sub-second precision.
+      +/
+    second = 6,
+
+    /++
+        $(BLUE Linux,Solaris-Only)
+
+        Uses $(D CLOCK_THREAD_CPUTIME_ID).
+      +/
+    threadCPUTime = 7,
+
+    /++
+        $(BLUE FreeBSD-Only)
+
+        Uses $(D CLOCK_UPTIME).
+      +/
+    uptime = 8,
+
+    /++
+        $(BLUE FreeBSD-Only)
+
+        Uses $(D CLOCK_UPTIME_FAST).
+      +/
+    uptimeCoarse = 9,
+
+    /++
+        $(BLUE FreeBSD-Only)
+
+        Uses $(D CLOCK_UPTIME_PRECISE).
+      +/
+    uptimePrecise = 10,
+}
+else version(Windows) enum ClockType
+{
+    normal = 0,
+    coarse = 2,
+    precise = 3,
+    second = 6,
+}
+else version(OSX) enum ClockType
+{
+    normal = 0,
+    coarse = 2,
+    precise = 3,
+    second = 6,
+}
+else version(linux) enum ClockType
+{
+    normal = 0,
+    bootTime = 1,
+    coarse = 2,
+    precise = 3,
+    processCPUTime = 4,
+    raw = 5,
+    second = 6,
+    threadCPUTime = 7,
+}
+else version(FreeBSD) enum ClockType
+{
+    normal = 0,
+    coarse = 2,
+    precise = 3,
+    second = 6,
+    uptime = 8,
+    uptimeCoarse = 9,
+    uptimePrecise = 10,
+}
+else version(Solaris) enum ClockType
+{
+    normal = 0,
+    coarse = 2,
+    precise = 3,
+    processCPUTime = 4,
+    second = 6,
+    threadCPUTime = 7,
+}
+else
+{
+    // It needs to be decided (and implemented in an appropriate version branch
+    // here) which clock types new platforms are going to support. At minimum,
+    // the ones _not_ marked with $(D Blue Foo-Only) should be supported.
+    static assert(0, "What are the clock types supported by this system?");
+}
+
+// private, used to translate clock type to proper argument to clock_xxx
+// functions on posix systems
+version(CoreDdoc)
+    private int _posixClock(ClockType clockType) { return 0; }
+else
+version(Posix)
+{
+    private auto _posixClock(ClockType clockType)
+    {
+        version(linux)
+        {
+            import core.sys.linux.time;
+            with(ClockType) final switch(clockType)
+            {
+            case bootTime: return CLOCK_BOOTTIME;
+            case coarse: return CLOCK_MONOTONIC_COARSE;
+            case normal: return CLOCK_MONOTONIC;
+            case precise: return CLOCK_MONOTONIC;
+            case processCPUTime: return CLOCK_PROCESS_CPUTIME_ID;
+            case raw: return CLOCK_MONOTONIC_RAW;
+            case threadCPUTime: return CLOCK_THREAD_CPUTIME_ID;
+            case second: assert(0);
+            }
+        }
+        else version(FreeBSD)
+        {
+            import core.sys.freebsd.time;
+            with(ClockType) final switch(clockType)
+            {
+            case coarse: return CLOCK_MONOTONIC_FAST;
+            case normal: return CLOCK_MONOTONIC;
+            case precise: return CLOCK_MONOTONIC_PRECISE;
+            case uptime: return CLOCK_UPTIME;
+            case uptimeCoarse: return CLOCK_UPTIME_FAST;
+            case uptimePrecise: return CLOCK_UPTIME_PRECISE;
+            case second: assert(0);
+            }
+        }
+        else version(Solaris)
+        {
+            import core.sys.solaris.time;
+            with(ClockType) final switch(clockType)
+            {
+            case coarse: return CLOCK_MONOTONIC;
+            case normal: return CLOCK_MONOTONIC;
+            case precise: return CLOCK_MONOTONIC;
+            case processCPUTime: return CLOCK_PROCESS_CPUTIME_ID;
+            case threadCPUTime: return CLOCK_THREAD_CPUTIME_ID;
+            case second: assert(0);
+            }
+        }
+        else
+            // It needs to be decided (and implemented in an appropriate
+            // version branch here) which clock types new platforms are going
+            // to support. Also, ClockType's documentation should be updated to
+            // mention it if a new platform uses anything that's not supported
+            // on all platforms..
+            assert(0, "What are the monotonic clock types supported by this system?");
+    }
+}
+
+unittest
+{
+    // Make sure that the values are the same across platforms.
+    static if(is(typeof(ClockType.normal)))         static assert(ClockType.normal == 0);
+    static if(is(typeof(ClockType.bootTime)))       static assert(ClockType.bootTime == 1);
+    static if(is(typeof(ClockType.coarse)))         static assert(ClockType.coarse == 2);
+    static if(is(typeof(ClockType.precise)))        static assert(ClockType.precise == 3);
+    static if(is(typeof(ClockType.processCPUTime))) static assert(ClockType.processCPUTime == 4);
+    static if(is(typeof(ClockType.raw)))            static assert(ClockType.raw == 5);
+    static if(is(typeof(ClockType.second)))         static assert(ClockType.second == 6);
+    static if(is(typeof(ClockType.threadCPUTime)))  static assert(ClockType.threadCPUTime == 7);
+    static if(is(typeof(ClockType.uptime)))         static assert(ClockType.uptime == 8);
+    static if(is(typeof(ClockType.uptimeCoarse)))   static assert(ClockType.uptimeCoarse == 9);
+    static if(is(typeof(ClockType.uptimePrecise)))  static assert(ClockType.uptimePrecise == 10);
+}
+
+
+/++
+    Represents a duration of time of weeks or less (kept internally as hnsecs).
+    (e.g. 22 days or 700 seconds).
+
+    It is used when representing a duration of time - such as how long to
+    sleep with $(CXREF thread, Thread.sleep).
+
+    In std.datetime, it is also used as the result of various arithmetic
+    operations on time points.
+
+    Use the $(LREF dur) function or one of its non-generic aliases to create
+    $(D Duration)s.
+
+    It's not possible to create a Duration of months or years, because the
+    variable number of days in a month or year makes it impossible to convert
+    between months or years and smaller units without a specific date. So,
+    nothing uses $(D Duration)s when dealing with months or years. Rather,
+    functions specific to months and years are defined. For instance,
+    $(XREF datetime, Date) has $(D add!"years") and $(D add!"months") for adding
+    years and months rather than creating a Duration of years or months and
+    adding that to a $(XREF datetime, Date). But Duration is used when dealing
+    with weeks or smaller.
+
+    Examples:
+--------------------
+assert(dur!"days"(12) == dur!"hnsecs"(10_368_000_000_000L));
+assert(dur!"hnsecs"(27) == dur!"hnsecs"(27));
+assert(std.datetime.Date(2010, 9, 7) + dur!"days"(5) ==
+       std.datetime.Date(2010, 9, 12));
+
+assert(days(-12) == dur!"hnsecs"(-10_368_000_000_000L));
+assert(hnsecs(-27) == dur!"hnsecs"(-27));
+assert(std.datetime.Date(2010, 9, 7) - std.datetime.Date(2010, 10, 3) ==
+       days(-26));
+--------------------
+ +/
+struct Duration
+{
+@safe pure:
+
+public:
+
+    /++
+        A $(D Duration) of $(D 0). It's shorter than doing something like
+        $(D dur!"seconds"(0)) and more explicit than $(D Duration.init).
+      +/
+    static @property nothrow @nogc Duration zero() { return Duration(0); }
+
+    /++
+        Largest $(D Duration) possible.
+      +/
+    static @property nothrow @nogc Duration max() { return Duration(long.max); }
+
+    /++
+        Most negative $(D Duration) possible.
+      +/
+    static @property nothrow @nogc Duration min() { return Duration(long.min); }
+
+    unittest
+    {
+        assert(zero == dur!"seconds"(0));
+        assert(Duration.max == Duration(long.max));
+        assert(Duration.min == Duration(long.min));
+        assert(Duration.min < Duration.zero);
+        assert(Duration.zero < Duration.max);
+        assert(Duration.min < Duration.max);
+        assert(Duration.min - dur!"hnsecs"(1) == Duration.max);
+        assert(Duration.max + dur!"hnsecs"(1) == Duration.min);
+    }
+
+
+    /++
+        Compares this $(D Duration) with the given $(D Duration).
+
+        Returns:
+            $(TABLE
+            $(TR $(TD this &lt; rhs) $(TD &lt; 0))
+            $(TR $(TD this == rhs) $(TD 0))
+            $(TR $(TD this &gt; rhs) $(TD &gt; 0))
+            )
+     +/
+    int opCmp(Duration rhs) const nothrow @nogc
+    {
+        if(_hnsecs < rhs._hnsecs)
+            return -1;
+        if(_hnsecs > rhs._hnsecs)
+            return 1;
+        return 0;
+    }
+
+    unittest
+    {
+        foreach(T; _TypeTuple!(Duration, const Duration, immutable Duration))
+        {
+            foreach(U; _TypeTuple!(Duration, const Duration, immutable Duration))
+            {
+                T t = 42;
+                U u = t;
+                assert(t == u);
+                assert(copy(t) == u);
+                assert(t == copy(u));
+            }
+        }
+
+        foreach(D; _TypeTuple!(Duration, const Duration, immutable Duration))
+        {
+            foreach(E; _TypeTuple!(Duration, const Duration, immutable Duration))
+            {
+                assert((cast(D)Duration(12)).opCmp(cast(E)Duration(12)) == 0);
+                assert((cast(D)Duration(-12)).opCmp(cast(E)Duration(-12)) == 0);
+
+                assert((cast(D)Duration(10)).opCmp(cast(E)Duration(12)) < 0);
+                assert((cast(D)Duration(-12)).opCmp(cast(E)Duration(12)) < 0);
+
+                assert((cast(D)Duration(12)).opCmp(cast(E)Duration(10)) > 0);
+                assert((cast(D)Duration(12)).opCmp(cast(E)Duration(-12)) > 0);
+
+                assert(copy(cast(D)Duration(12)).opCmp(cast(E)Duration(12)) == 0);
+                assert(copy(cast(D)Duration(-12)).opCmp(cast(E)Duration(-12)) == 0);
+
+                assert(copy(cast(D)Duration(10)).opCmp(cast(E)Duration(12)) < 0);
+                assert(copy(cast(D)Duration(-12)).opCmp(cast(E)Duration(12)) < 0);
+
+                assert(copy(cast(D)Duration(12)).opCmp(cast(E)Duration(10)) > 0);
+                assert(copy(cast(D)Duration(12)).opCmp(cast(E)Duration(-12)) > 0);
+
+                assert((cast(D)Duration(12)).opCmp(copy(cast(E)Duration(12))) == 0);
+                assert((cast(D)Duration(-12)).opCmp(copy(cast(E)Duration(-12))) == 0);
+
+                assert((cast(D)Duration(10)).opCmp(copy(cast(E)Duration(12))) < 0);
+                assert((cast(D)Duration(-12)).opCmp(copy(cast(E)Duration(12))) < 0);
+
+                assert((cast(D)Duration(12)).opCmp(copy(cast(E)Duration(10))) > 0);
+                assert((cast(D)Duration(12)).opCmp(copy(cast(E)Duration(-12))) > 0);
+            }
+        }
+    }
+
+
+    /++
+        Adds, subtracts or calculates the modulo of two durations.
+
+        The legal types of arithmetic for $(D Duration) using this operator are
+
+        $(TABLE
+        $(TR $(TD Duration) $(TD +) $(TD Duration) $(TD -->) $(TD Duration))
+        $(TR $(TD Duration) $(TD -) $(TD Duration) $(TD -->) $(TD Duration))
+        $(TR $(TD Duration) $(TD %) $(TD Duration) $(TD -->) $(TD Duration))
+        $(TR $(TD Duration) $(TD +) $(TD TickDuration) $(TD -->) $(TD Duration))
+        $(TR $(TD Duration) $(TD -) $(TD TickDuration) $(TD -->) $(TD Duration))
+        )
+
+        Params:
+            rhs = The duration to add to or subtract from this $(D Duration).
+      +/
+    Duration opBinary(string op, D)(D rhs) const nothrow @nogc
+        if(((op == "+" || op == "-" || op == "%") && is(_Unqual!D == Duration)) ||
+           ((op == "+" || op == "-") && is(_Unqual!D == TickDuration)))
+    {
+        static if(is(_Unqual!D == Duration))
+            return Duration(mixin("_hnsecs " ~ op ~ " rhs._hnsecs"));
+        else if(is(_Unqual!D == TickDuration))
+            return Duration(mixin("_hnsecs " ~ op ~ " rhs.hnsecs"));
+    }
+
+    unittest
+    {
+        foreach(D; _TypeTuple!(Duration, const Duration, immutable Duration))
+        {
+            foreach(E; _TypeTuple!(Duration, const Duration, immutable Duration))
+            {
+                assert((cast(D)Duration(5)) + (cast(E)Duration(7)) == Duration(12));
+                assert((cast(D)Duration(5)) - (cast(E)Duration(7)) == Duration(-2));
+                assert((cast(D)Duration(5)) % (cast(E)Duration(7)) == Duration(5));
+                assert((cast(D)Duration(7)) + (cast(E)Duration(5)) == Duration(12));
+                assert((cast(D)Duration(7)) - (cast(E)Duration(5)) == Duration(2));
+                assert((cast(D)Duration(7)) % (cast(E)Duration(5)) == Duration(2));
+
+                assert((cast(D)Duration(5)) + (cast(E)Duration(-7)) == Duration(-2));
+                assert((cast(D)Duration(5)) - (cast(E)Duration(-7)) == Duration(12));
+                assert((cast(D)Duration(5)) % (cast(E)Duration(-7)) == Duration(5));
+                assert((cast(D)Duration(7)) + (cast(E)Duration(-5)) == Duration(2));
+                assert((cast(D)Duration(7)) - (cast(E)Duration(-5)) == Duration(12));
+                assert((cast(D)Duration(7)) % (cast(E)Duration(-5)) == Duration(2));
+
+                assert((cast(D)Duration(-5)) + (cast(E)Duration(7)) == Duration(2));
+                assert((cast(D)Duration(-5)) - (cast(E)Duration(7)) == Duration(-12));
+                assert((cast(D)Duration(-5)) % (cast(E)Duration(7)) == Duration(-5));
+                assert((cast(D)Duration(-7)) + (cast(E)Duration(5)) == Duration(-2));
+                assert((cast(D)Duration(-7)) - (cast(E)Duration(5)) == Duration(-12));
+                assert((cast(D)Duration(-7)) % (cast(E)Duration(5)) == Duration(-2));
+
+                assert((cast(D)Duration(-5)) + (cast(E)Duration(-7)) == Duration(-12));
+                assert((cast(D)Duration(-5)) - (cast(E)Duration(-7)) == Duration(2));
+                assert((cast(D)Duration(-5)) % (cast(E)Duration(7)) == Duration(-5));
+                assert((cast(D)Duration(-7)) + (cast(E)Duration(-5)) == Duration(-12));
+                assert((cast(D)Duration(-7)) - (cast(E)Duration(-5)) == Duration(-2));
+                assert((cast(D)Duration(-7)) % (cast(E)Duration(5)) == Duration(-2));
+            }
+
+            foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+            {
+                assertApprox((cast(D)Duration(5)) + cast(T)TickDuration.from!"usecs"(7), Duration(70), Duration(80));
+                assertApprox((cast(D)Duration(5)) - cast(T)TickDuration.from!"usecs"(7), Duration(-70), Duration(-60));
+                assertApprox((cast(D)Duration(7)) + cast(T)TickDuration.from!"usecs"(5), Duration(52), Duration(62));
+                assertApprox((cast(D)Duration(7)) - cast(T)TickDuration.from!"usecs"(5), Duration(-48), Duration(-38));
+
+                assertApprox((cast(D)Duration(5)) + cast(T)TickDuration.from!"usecs"(-7), Duration(-70), Duration(-60));
+                assertApprox((cast(D)Duration(5)) - cast(T)TickDuration.from!"usecs"(-7), Duration(70), Duration(80));
+                assertApprox((cast(D)Duration(7)) + cast(T)TickDuration.from!"usecs"(-5), Duration(-48), Duration(-38));
+                assertApprox((cast(D)Duration(7)) - cast(T)TickDuration.from!"usecs"(-5), Duration(52), Duration(62));
+
+                assertApprox((cast(D)Duration(-5)) + cast(T)TickDuration.from!"usecs"(7), Duration(60), Duration(70));
+                assertApprox((cast(D)Duration(-5)) - cast(T)TickDuration.from!"usecs"(7), Duration(-80), Duration(-70));
+                assertApprox((cast(D)Duration(-7)) + cast(T)TickDuration.from!"usecs"(5), Duration(38), Duration(48));
+                assertApprox((cast(D)Duration(-7)) - cast(T)TickDuration.from!"usecs"(5), Duration(-62), Duration(-52));
+
+                assertApprox((cast(D)Duration(-5)) + cast(T)TickDuration.from!"usecs"(-7), Duration(-80), Duration(-70));
+                assertApprox((cast(D)Duration(-5)) - cast(T)TickDuration.from!"usecs"(-7), Duration(60), Duration(70));
+                assertApprox((cast(D)Duration(-7)) + cast(T)TickDuration.from!"usecs"(-5), Duration(-62), Duration(-52));
+                assertApprox((cast(D)Duration(-7)) - cast(T)TickDuration.from!"usecs"(-5), Duration(38), Duration(48));
+            }
+        }
+    }
+
+
+    /++
+        Adds or subtracts two durations.
+
+        The legal types of arithmetic for $(D Duration) using this operator are
+
+        $(TABLE
+        $(TR $(TD TickDuration) $(TD +) $(TD Duration) $(TD -->) $(TD Duration))
+        $(TR $(TD TickDuration) $(TD -) $(TD Duration) $(TD -->) $(TD Duration))
+        )
+
+        Params:
+            lhs = The $(D TickDuration) to add to this $(D Duration) or to
+                  subtract this $(D Duration) from.
+      +/
+    Duration opBinaryRight(string op, D)(D lhs) const nothrow @nogc
+        if((op == "+" || op == "-") &&
+            is(_Unqual!D == TickDuration))
+    {
+        return Duration(mixin("lhs.hnsecs " ~ op ~ " _hnsecs"));
+    }
+
+    unittest
+    {
+        foreach(D; _TypeTuple!(Duration, const Duration, immutable Duration))
+        {
+            foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+            {
+                assertApprox((cast(T)TickDuration.from!"usecs"(7)) + cast(D)Duration(5), Duration(70), Duration(80));
+                assertApprox((cast(T)TickDuration.from!"usecs"(7)) - cast(D)Duration(5), Duration(60), Duration(70));
+                assertApprox((cast(T)TickDuration.from!"usecs"(5)) + cast(D)Duration(7), Duration(52), Duration(62));
+                assertApprox((cast(T)TickDuration.from!"usecs"(5)) - cast(D)Duration(7), Duration(38), Duration(48));
+
+                assertApprox((cast(T)TickDuration.from!"usecs"(-7)) + cast(D)Duration(5), Duration(-70), Duration(-60));
+                assertApprox((cast(T)TickDuration.from!"usecs"(-7)) - cast(D)Duration(5), Duration(-80), Duration(-70));
+                assertApprox((cast(T)TickDuration.from!"usecs"(-5)) + cast(D)Duration(7), Duration(-48), Duration(-38));
+                assertApprox((cast(T)TickDuration.from!"usecs"(-5)) - cast(D)Duration(7), Duration(-62), Duration(-52));
+
+                assertApprox((cast(T)TickDuration.from!"usecs"(7)) + (cast(D)Duration(-5)), Duration(60), Duration(70));
+                assertApprox((cast(T)TickDuration.from!"usecs"(7)) - (cast(D)Duration(-5)), Duration(70), Duration(80));
+                assertApprox((cast(T)TickDuration.from!"usecs"(5)) + (cast(D)Duration(-7)), Duration(38), Duration(48));
+                assertApprox((cast(T)TickDuration.from!"usecs"(5)) - (cast(D)Duration(-7)), Duration(52), Duration(62));
+
+                assertApprox((cast(T)TickDuration.from!"usecs"(-7)) + cast(D)Duration(-5), Duration(-80), Duration(-70));
+                assertApprox((cast(T)TickDuration.from!"usecs"(-7)) - cast(D)Duration(-5), Duration(-70), Duration(-60));
+                assertApprox((cast(T)TickDuration.from!"usecs"(-5)) + cast(D)Duration(-7), Duration(-62), Duration(-52));
+                assertApprox((cast(T)TickDuration.from!"usecs"(-5)) - cast(D)Duration(-7), Duration(-48), Duration(-38));
+            }
+        }
+    }
+
+
+    /++
+        Adds, subtracts or calculates the modulo of two durations as well as
+        assigning the result to this $(D Duration).
+
+        The legal types of arithmetic for $(D Duration) using this operator are
+
+        $(TABLE
+        $(TR $(TD Duration) $(TD +) $(TD Duration) $(TD -->) $(TD Duration))
+        $(TR $(TD Duration) $(TD -) $(TD Duration) $(TD -->) $(TD Duration))
+        $(TR $(TD Duration) $(TD %) $(TD Duration) $(TD -->) $(TD Duration))
+        $(TR $(TD Duration) $(TD +) $(TD TickDuration) $(TD -->) $(TD Duration))
+        $(TR $(TD Duration) $(TD -) $(TD TickDuration) $(TD -->) $(TD Duration))
+        )
+
+        Params:
+            rhs = The duration to add to or subtract from this $(D Duration).
+      +/
+    ref Duration opOpAssign(string op, D)(in D rhs) nothrow @nogc
+        if(((op == "+" || op == "-" || op == "%") && is(_Unqual!D == Duration)) ||
+           ((op == "+" || op == "-") && is(_Unqual!D == TickDuration)))
+    {
+        static if(is(_Unqual!D == Duration))
+            mixin("_hnsecs " ~ op ~ "= rhs._hnsecs;");
+        else if(is(_Unqual!D == TickDuration))
+            mixin("_hnsecs " ~ op ~ "= rhs.hnsecs;");
+        return this;
+    }
+
+    unittest
+    {
+        static void test1(string op, E)(Duration actual, in E rhs, Duration expected, size_t line = __LINE__)
+        {
+            if(mixin("actual " ~ op ~ " rhs") != expected)
+                throw new AssertError("op failed", __FILE__, line);
+
+            if(actual != expected)
+                throw new AssertError("op assign failed", __FILE__, line);
+        }
+
+        static void test2(string op, E)
+                         (Duration actual, in E rhs, Duration lower, Duration upper, size_t line = __LINE__)
+        {
+            assertApprox(mixin("actual " ~ op ~ " rhs"), lower, upper, "op failed", line);
+            assertApprox(actual, lower, upper, "op assign failed", line);
+        }
+
+        foreach(E; _TypeTuple!(Duration, const Duration, immutable Duration))
+        {
+            test1!"+="(Duration(5), (cast(E)Duration(7)), Duration(12));
+            test1!"-="(Duration(5), (cast(E)Duration(7)), Duration(-2));
+            test1!"%="(Duration(5), (cast(E)Duration(7)), Duration(5));
+            test1!"+="(Duration(7), (cast(E)Duration(5)), Duration(12));
+            test1!"-="(Duration(7), (cast(E)Duration(5)), Duration(2));
+            test1!"%="(Duration(7), (cast(E)Duration(5)), Duration(2));
+
+            test1!"+="(Duration(5), (cast(E)Duration(-7)), Duration(-2));
+            test1!"-="(Duration(5), (cast(E)Duration(-7)), Duration(12));
+            test1!"%="(Duration(5), (cast(E)Duration(-7)), Duration(5));
+            test1!"+="(Duration(7), (cast(E)Duration(-5)), Duration(2));
+            test1!"-="(Duration(7), (cast(E)Duration(-5)), Duration(12));
+            test1!"%="(Duration(7), (cast(E)Duration(-5)), Duration(2));
+
+            test1!"+="(Duration(-5), (cast(E)Duration(7)), Duration(2));
+            test1!"-="(Duration(-5), (cast(E)Duration(7)), Duration(-12));
+            test1!"%="(Duration(-5), (cast(E)Duration(7)), Duration(-5));
+            test1!"+="(Duration(-7), (cast(E)Duration(5)), Duration(-2));
+            test1!"-="(Duration(-7), (cast(E)Duration(5)), Duration(-12));
+            test1!"%="(Duration(-7), (cast(E)Duration(5)), Duration(-2));
+
+            test1!"+="(Duration(-5), (cast(E)Duration(-7)), Duration(-12));
+            test1!"-="(Duration(-5), (cast(E)Duration(-7)), Duration(2));
+            test1!"%="(Duration(-5), (cast(E)Duration(-7)), Duration(-5));
+            test1!"+="(Duration(-7), (cast(E)Duration(-5)), Duration(-12));
+            test1!"-="(Duration(-7), (cast(E)Duration(-5)), Duration(-2));
+            test1!"%="(Duration(-7), (cast(E)Duration(-5)), Duration(-2));
+        }
+
+        foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+        {
+            test2!"+="(Duration(5), cast(T)TickDuration.from!"usecs"(7), Duration(70), Duration(80));
+            test2!"-="(Duration(5), cast(T)TickDuration.from!"usecs"(7), Duration(-70), Duration(-60));
+            test2!"+="(Duration(7), cast(T)TickDuration.from!"usecs"(5), Duration(52), Duration(62));
+            test2!"-="(Duration(7), cast(T)TickDuration.from!"usecs"(5), Duration(-48), Duration(-38));
+
+            test2!"+="(Duration(5), cast(T)TickDuration.from!"usecs"(-7), Duration(-70), Duration(-60));
+            test2!"-="(Duration(5), cast(T)TickDuration.from!"usecs"(-7), Duration(70), Duration(80));
+            test2!"+="(Duration(7), cast(T)TickDuration.from!"usecs"(-5), Duration(-48), Duration(-38));
+            test2!"-="(Duration(7), cast(T)TickDuration.from!"usecs"(-5), Duration(52), Duration(62));
+
+            test2!"+="(Duration(-5), cast(T)TickDuration.from!"usecs"(7), Duration(60), Duration(70));
+            test2!"-="(Duration(-5), cast(T)TickDuration.from!"usecs"(7), Duration(-80), Duration(-70));
+            test2!"+="(Duration(-7), cast(T)TickDuration.from!"usecs"(5), Duration(38), Duration(48));
+            test2!"-="(Duration(-7), cast(T)TickDuration.from!"usecs"(5), Duration(-62), Duration(-52));
+
+            test2!"+="(Duration(-5), cast(T)TickDuration.from!"usecs"(-7), Duration(-80), Duration(-70));
+            test2!"-="(Duration(-5), cast(T)TickDuration.from!"usecs"(-7), Duration(60), Duration(70));
+            test2!"+="(Duration(-7), cast(T)TickDuration.from!"usecs"(-5), Duration(-62), Duration(-52));
+            test2!"-="(Duration(-7), cast(T)TickDuration.from!"usecs"(-5), Duration(38), Duration(48));
+        }
+
+        foreach(D; _TypeTuple!(const Duration, immutable Duration))
+        {
+            foreach(E; _TypeTuple!(Duration, const Duration, immutable Duration,
+                                   TickDuration, const TickDuration, immutable TickDuration))
+            {
+                D lhs = D(120);
+                E rhs = E(120);
+                static assert(!__traits(compiles, lhs += rhs), D.stringof ~ " " ~ E.stringof);
+            }
+        }
+    }
+
+
+    /++
+        Multiplies or divides the duration by an integer value.
+
+        The legal types of arithmetic for $(D Duration) using this operator
+        overload are
+
+        $(TABLE
+        $(TR $(TD Duration) $(TD *) $(TD long) $(TD -->) $(TD Duration))
+        $(TR $(TD Duration) $(TD /) $(TD long) $(TD -->) $(TD Duration))
+        )
+
+        Params:
+            value = The value to multiply this $(D Duration) by.
+      +/
+    Duration opBinary(string op)(long value) const nothrow @nogc
+        if(op == "*" || op == "/")
+    {
+        mixin("return Duration(_hnsecs " ~ op ~ " value);");
+    }
+
+    unittest
+    {
+        foreach(D; _TypeTuple!(Duration, const Duration, immutable Duration))
+        {
+            assert((cast(D)Duration(5)) * 7 == Duration(35));
+            assert((cast(D)Duration(7)) * 5 == Duration(35));
+
+            assert((cast(D)Duration(5)) * -7 == Duration(-35));
+            assert((cast(D)Duration(7)) * -5 == Duration(-35));
+
+            assert((cast(D)Duration(-5)) * 7 == Duration(-35));
+            assert((cast(D)Duration(-7)) * 5 == Duration(-35));
+
+            assert((cast(D)Duration(-5)) * -7 == Duration(35));
+            assert((cast(D)Duration(-7)) * -5 == Duration(35));
+
+            assert((cast(D)Duration(5)) * 0 == Duration(0));
+            assert((cast(D)Duration(-5)) * 0 == Duration(0));
+        }
+    }
+
+    unittest
+    {
+        foreach(D; _TypeTuple!(Duration, const Duration, immutable Duration))
+        {
+            assert((cast(D)Duration(5)) / 7 == Duration(0));
+            assert((cast(D)Duration(7)) / 5 == Duration(1));
+
+            assert((cast(D)Duration(5)) / -7 == Duration(0));
+            assert((cast(D)Duration(7)) / -5 == Duration(-1));
+
+            assert((cast(D)Duration(-5)) / 7 == Duration(0));
+            assert((cast(D)Duration(-7)) / 5 == Duration(-1));
+
+            assert((cast(D)Duration(-5)) / -7 == Duration(0));
+            assert((cast(D)Duration(-7)) / -5 == Duration(1));
+        }
+    }
+
+
+    /++
+        Multiplies/Divides the duration by an integer value as well as
+        assigning the result to this $(D Duration).
+
+        The legal types of arithmetic for $(D Duration) using this operator
+        overload are
+
+        $(TABLE
+        $(TR $(TD Duration) $(TD *) $(TD long) $(TD -->) $(TD Duration))
+        $(TR $(TD Duration) $(TD /) $(TD long) $(TD -->) $(TD Duration))
+        )
+
+        Params:
+            value = The value to multiply/divide this $(D Duration) by.
+      +/
+    ref Duration opOpAssign(string op)(long value) nothrow @nogc
+        if(op == "*" || op == "/")
+    {
+        mixin("_hnsecs " ~ op ~ "= value;");
+        return this;
+    }
+
+    unittest
+    {
+        static void test(D)(D actual, long value, Duration expected, size_t line = __LINE__)
+        {
+            if((actual *= value) != expected)
+                throw new AssertError("op failed", __FILE__, line);
+
+            if(actual != expected)
+                throw new AssertError("op assign failed", __FILE__, line);
+        }
+
+        test(Duration(5), 7, Duration(35));
+        test(Duration(7), 5, Duration(35));
+
+        test(Duration(5), -7, Duration(-35));
+        test(Duration(7), -5, Duration(-35));
+
+        test(Duration(-5), 7, Duration(-35));
+        test(Duration(-7), 5, Duration(-35));
+
+        test(Duration(-5), -7, Duration(35));
+        test(Duration(-7), -5, Duration(35));
+
+        test(Duration(5), 0, Duration(0));
+        test(Duration(-5), 0, Duration(0));
+
+        const cdur = Duration(12);
+        immutable idur = Duration(12);
+        static assert(!__traits(compiles, cdur *= 12));
+        static assert(!__traits(compiles, idur *= 12));
+    }
+
+    unittest
+    {
+        static void test(Duration actual, long value, Duration expected, size_t line = __LINE__)
+        {
+            if((actual /= value) != expected)
+                throw new AssertError("op failed", __FILE__, line);
+
+            if(actual != expected)
+                throw new AssertError("op assign failed", __FILE__, line);
+        }
+
+        test(Duration(5), 7, Duration(0));
+        test(Duration(7), 5, Duration(1));
+
+        test(Duration(5), -7, Duration(0));
+        test(Duration(7), -5, Duration(-1));
+
+        test(Duration(-5), 7, Duration(0));
+        test(Duration(-7), 5, Duration(-1));
+
+        test(Duration(-5), -7, Duration(0));
+        test(Duration(-7), -5, Duration(1));
+
+        const cdur = Duration(12);
+        immutable idur = Duration(12);
+        static assert(!__traits(compiles, cdur /= 12));
+        static assert(!__traits(compiles, idur /= 12));
+    }
+
+
+    /++
+        Divides two durations.
+
+        The legal types of arithmetic for $(D Duration) using this operator are
+
+        $(TABLE
+        $(TR $(TD Duration) $(TD /) $(TD Duration) $(TD -->) $(TD long))
+        )
+
+        Params:
+            rhs = The duration to divide this $(D Duration) by.
+      +/
+    long opBinary(string op)(Duration rhs) const nothrow @nogc
+        if(op == "/")
+    {
+        return _hnsecs / rhs._hnsecs;
+    }
+
+    unittest
+    {
+        assert(Duration(5) / Duration(7) == 0);
+        assert(Duration(7) / Duration(5) == 1);
+        assert(Duration(8) / Duration(4) == 2);
+
+        assert(Duration(5) / Duration(-7) == 0);
+        assert(Duration(7) / Duration(-5) == -1);
+        assert(Duration(8) / Duration(-4) == -2);
+
+        assert(Duration(-5) / Duration(7) == 0);
+        assert(Duration(-7) / Duration(5) == -1);
+        assert(Duration(-8) / Duration(4) == -2);
+
+        assert(Duration(-5) / Duration(-7) == 0);
+        assert(Duration(-7) / Duration(-5) == 1);
+        assert(Duration(-8) / Duration(-4) == 2);
+    }
+
+
+    /++
+        Multiplies an integral value and a $(D Duration).
+
+        The legal types of arithmetic for $(D Duration) using this operator
+        overload are
+
+        $(TABLE
+        $(TR $(TD long) $(TD *) $(TD Duration) $(TD -->) $(TD Duration))
+        )
+
+        Params:
+            value = The number of units to multiply this $(D Duration) by.
+      +/
+    Duration opBinaryRight(string op)(long value) const nothrow @nogc
+        if(op == "*")
+    {
+        return opBinary!op(value);
+    }
+
+    unittest
+    {
+        foreach(D; _TypeTuple!(Duration, const Duration, immutable Duration))
+        {
+            assert(5 * cast(D)Duration(7) == Duration(35));
+            assert(7 * cast(D)Duration(5) == Duration(35));
+
+            assert(5 * cast(D)Duration(-7) == Duration(-35));
+            assert(7 * cast(D)Duration(-5) == Duration(-35));
+
+            assert(-5 * cast(D)Duration(7) == Duration(-35));
+            assert(-7 * cast(D)Duration(5) == Duration(-35));
+
+            assert(-5 * cast(D)Duration(-7) == Duration(35));
+            assert(-7 * cast(D)Duration(-5) == Duration(35));
+
+            assert(0 * cast(D)Duration(-5) == Duration(0));
+            assert(0 * cast(D)Duration(5) == Duration(0));
+        }
+    }
+
+
+    /++
+        Returns the negation of this $(D Duration).
+      +/
+    Duration opUnary(string op)() const nothrow @nogc
+        if(op == "-")
+    {
+        return Duration(-_hnsecs);
+    }
+
+    unittest
+    {
+        foreach(D; _TypeTuple!(Duration, const Duration, immutable Duration))
+        {
+            assert(-(cast(D)Duration(7)) == Duration(-7));
+            assert(-(cast(D)Duration(5)) == Duration(-5));
+            assert(-(cast(D)Duration(-7)) == Duration(7));
+            assert(-(cast(D)Duration(-5)) == Duration(5));
+            assert(-(cast(D)Duration(0)) == Duration(0));
+        }
+    }
+
+
+    /++
+        Returns a $(LREF TickDuration) with the same number of hnsecs as this
+        $(D Duration).
+        Note that the conventional way to convert between $(D Duration) and
+        $(D TickDuration) is using $(XREF conv, to), e.g.:
+        $(D duration.to!TickDuration())
+      +/
+    TickDuration opCast(T)() const nothrow @nogc
+        if(is(_Unqual!T == TickDuration))
+    {
+        return TickDuration.from!"hnsecs"(_hnsecs);
+    }
+
+    unittest
+    {
+        foreach(D; _TypeTuple!(Duration, const Duration, immutable Duration))
+        {
+            foreach(units; _TypeTuple!("seconds", "msecs", "usecs", "hnsecs"))
+            {
+                enum unitsPerSec = convert!("seconds", units)(1);
+
+                if(TickDuration.ticksPerSec >= unitsPerSec)
+                {
+                    foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+                    {
+                        auto t = TickDuration.from!units(1);
+                        assertApprox(cast(T)cast(D)dur!units(1), t - TickDuration(1), t + TickDuration(1), units);
+                        t = TickDuration.from!units(2);
+                        assertApprox(cast(T)cast(D)dur!units(2), t - TickDuration(1), t + TickDuration(1), units);
+                    }
+                }
+                else
+                {
+                    auto t = TickDuration.from!units(1);
+                    assert(t.to!(units, long)() == 0, units);
+                    t = TickDuration.from!units(1_000_000);
+                    assert(t.to!(units, long)() >= 900_000, units);
+                    assert(t.to!(units, long)() <= 1_100_000, units);
+                }
+            }
+        }
+    }
+
+
+    //Temporary hack until bug http://d.puremagic.com/issues/show_bug.cgi?id=5747 is fixed.
+    Duration opCast(T)() const nothrow @nogc
+        if(is(_Unqual!T == Duration))
+    {
+        return this;
+    }
+
+
+    /++
+        Splits out the Duration into the given units.
+
+        split takes the list of time units to split out as template arguments.
+        The time unit strings must be given in decreasing order. How it returns
+        the values for those units depends on the overload used.
+
+        The overload which accepts function arguments takes integral types in
+        the order that the time unit strings were given, and those integers are
+        passed by $(D ref). split assigns the values for the units to each
+        corresponding integer. Any integral type may be used, but no attempt is
+        made to prevent integer overflow, so don't use small integral types in
+        circumstances where the values for those units aren't likely to fit in
+        an integral type that small.
+
+        The overload with no arguments returns the values for the units in a
+        struct with members whose names are the same as the given time unit
+        strings. The members are all $(D long)s. This overload will also work
+        with no time strings being given, in which case $(I all) of the time
+        units from weeks through hnsecs will be provided (but no nsecs, since it
+        would always be $(D 0)).
+
+        For both overloads, the entire value of the Duration is split among the
+        units (rather than splitting the Duration across all units and then only
+        providing the values for the requested units), so if only one unit is
+        given, the result is equivalent to $(LREF total).
+
+        $(D "nsecs") is accepted by split, but $(D "years") and $(D "months")
+        are not.
+
+        For negative durations, all of the split values will be negative.
+      +/
+    template split(units...)
+        if(allAreAcceptedUnits!("weeks", "days", "hours", "minutes", "seconds",
+                                "msecs", "usecs", "hnsecs", "nsecs")(units) &&
+           unitsAreInDescendingOrder(units))
+    {
+        /++ Ditto +/
+        void split(Args...)(out Args args) const nothrow @nogc
+            if(units.length != 0 && args.length == units.length && allAreMutableIntegralTypes!Args)
+        {
+            long hnsecs = _hnsecs;
+            foreach(i, unit; units)
+            {
+                static if(unit == "nsecs")
+                    args[i] = cast(typeof(args[i]))convert!("hnsecs", "nsecs")(hnsecs);
+                else
+                    args[i] = cast(typeof(args[i]))splitUnitsFromHNSecs!unit(hnsecs);
+            }
+        }
+
+        /++ Ditto +/
+        auto split() const nothrow @nogc
+        {
+            static if(units.length == 0)
+                return split!("weeks", "days", "hours", "minutes", "seconds", "msecs", "usecs", "hnsecs")();
+            else
+            {
+                static string genMemberDecls()
+                {
+                    string retval;
+                    foreach(unit; units)
+                    {
+                        retval ~= "long ";
+                        retval ~= unit;
+                        retval ~= "; ";
+                    }
+                    return retval;
+                }
+
+                static struct SplitUnits
+                {
+                    mixin(genMemberDecls());
+                }
+
+                static string genSplitCall()
+                {
+                    auto retval = "split(";
+                    foreach(i, unit; units)
+                    {
+                        retval ~= "su.";
+                        retval ~= unit;
+                        if(i < units.length - 1)
+                            retval ~= ", ";
+                        else
+                            retval ~= ");";
+                    }
+                    return retval;
+                }
+
+                SplitUnits su = void;
+                mixin(genSplitCall());
+                return su;
+            }
+        }
+
+        /+
+            Whether all of the given arguments are integral types.
+          +/
+        private template allAreMutableIntegralTypes(Args...)
+        {
+            static if(Args.length == 0)
+                enum allAreMutableIntegralTypes = true;
+            else static if(!is(Args[0] == long) &&
+                           !is(Args[0] == int) &&
+                           !is(Args[0] == short) &&
+                           !is(Args[0] == byte) &&
+                           !is(Args[0] == ulong) &&
+                           !is(Args[0] == uint) &&
+                           !is(Args[0] == ushort) &&
+                           !is(Args[0] == ubyte))
+            {
+                enum allAreMutableIntegralTypes = false;
+            }
+            else
+                enum allAreMutableIntegralTypes = allAreMutableIntegralTypes!(Args[1 .. $]);
+        }
+
+        unittest
+        {
+            foreach(T; _TypeTuple!(long, int, short, byte, ulong, uint, ushort, ubyte))
+                static assert(allAreMutableIntegralTypes!T);
+            foreach(T; _TypeTuple!(long, int, short, byte, ulong, uint, ushort, ubyte))
+                static assert(!allAreMutableIntegralTypes!(const T));
+            foreach(T; _TypeTuple!(char, wchar, dchar, float, double, real, string))
+                static assert(!allAreMutableIntegralTypes!T);
+            static assert(allAreMutableIntegralTypes!(long, int, short, byte));
+            static assert(!allAreMutableIntegralTypes!(long, int, short, char, byte));
+            static assert(!allAreMutableIntegralTypes!(long, int*, short));
+        }
+    }
+
+    ///
+    unittest
+    {
+        {
+            auto d = dur!"days"(12) + dur!"minutes"(7) + dur!"usecs"(501223);
+            long days;
+            int seconds;
+            short msecs;
+            d.split!("days", "seconds", "msecs")(days, seconds, msecs);
+            assert(days == 12);
+            assert(seconds == 7 * 60);
+            assert(msecs == 501);
+
+            auto splitStruct = d.split!("days", "seconds", "msecs")();
+            assert(splitStruct.days == 12);
+            assert(splitStruct.seconds == 7 * 60);
+            assert(splitStruct.msecs == 501);
+
+            auto fullSplitStruct = d.split();
+            assert(fullSplitStruct.weeks == 1);
+            assert(fullSplitStruct.days == 5);
+            assert(fullSplitStruct.hours == 0);
+            assert(fullSplitStruct.minutes == 7);
+            assert(fullSplitStruct.seconds == 0);
+            assert(fullSplitStruct.msecs == 501);
+            assert(fullSplitStruct.usecs == 223);
+            assert(fullSplitStruct.hnsecs == 0);
+
+            assert(d.split!"minutes"().minutes == d.total!"minutes");
+        }
+
+        {
+            auto d = dur!"days"(12);
+            assert(d.split!"weeks"().weeks == 1);
+            assert(d.split!"days"().days == 12);
+
+            assert(d.split().weeks == 1);
+            assert(d.split().days == 5);
+        }
+
+        {
+            auto d = dur!"days"(7) + dur!"hnsecs"(42);
+            assert(d.split!("seconds", "nsecs")().nsecs == 4200);
+        }
+
+        {
+            auto d = dur!"days"(-7) + dur!"hours"(-9);
+            auto result = d.split!("days", "hours")();
+            assert(result.days == -7);
+            assert(result.hours == -9);
+        }
+    }
+
+    pure nothrow unittest
+    {
+        foreach(D; _TypeTuple!(const Duration, immutable Duration))
+        {
+            D d = dur!"weeks"(3) + dur!"days"(5) + dur!"hours"(19) + dur!"minutes"(7) +
+                  dur!"seconds"(2) + dur!"hnsecs"(1234567);
+            byte weeks;
+            ubyte days;
+            short hours;
+            ushort minutes;
+            int seconds;
+            uint msecs;
+            long usecs;
+            ulong hnsecs;
+            long nsecs;
+
+            d.split!("weeks", "days", "hours", "minutes", "seconds", "msecs", "usecs", "hnsecs", "nsecs")
+                    (weeks, days, hours, minutes, seconds, msecs, usecs, hnsecs, nsecs);
+            assert(weeks == 3);
+            assert(days == 5);
+            assert(hours == 19);
+            assert(minutes == 7);
+            assert(seconds == 2);
+            assert(msecs == 123);
+            assert(usecs == 456);
+            assert(hnsecs == 7);
+            assert(nsecs == 0);
+
+            d.split!("weeks", "days", "hours", "seconds", "usecs")(weeks, days, hours, seconds, usecs);
+            assert(weeks == 3);
+            assert(days == 5);
+            assert(hours == 19);
+            assert(seconds == 422);
+            assert(usecs == 123456);
+
+            d.split!("days", "minutes", "seconds", "nsecs")(days, minutes, seconds, nsecs);
+            assert(days == 26);
+            assert(minutes == 1147);
+            assert(seconds == 2);
+            assert(nsecs == 123456700);
+
+            d.split!("minutes", "msecs", "usecs", "hnsecs")(minutes, msecs, usecs, hnsecs);
+            assert(minutes == 38587);
+            assert(msecs == 2123);
+            assert(usecs == 456);
+            assert(hnsecs == 7);
+
+            {
+                auto result = d.split!("weeks", "days", "hours", "minutes", "seconds",
+                                       "msecs", "usecs", "hnsecs", "nsecs");
+                assert(result.weeks == 3);
+                assert(result.days == 5);
+                assert(result.hours == 19);
+                assert(result.minutes == 7);
+                assert(result.seconds == 2);
+                assert(result.msecs == 123);
+                assert(result.usecs == 456);
+                assert(result.hnsecs == 7);
+                assert(result.nsecs == 0);
+            }
+
+            {
+                auto result = d.split!("weeks", "days", "hours", "seconds", "usecs");
+                assert(result.weeks == 3);
+                assert(result.days == 5);
+                assert(result.hours == 19);
+                assert(result.seconds == 422);
+                assert(result.usecs == 123456);
+            }
+
+            {
+                auto result = d.split!("days", "minutes", "seconds", "nsecs")();
+                assert(result.days == 26);
+                assert(result.minutes == 1147);
+                assert(result.seconds == 2);
+                assert(result.nsecs == 123456700);
+            }
+
+            {
+                auto result = d.split!("minutes", "msecs", "usecs", "hnsecs")();
+                assert(result.minutes == 38587);
+                assert(result.msecs == 2123);
+                assert(result.usecs == 456);
+                assert(result.hnsecs == 7);
+            }
+
+            {
+                auto result = d.split();
+                assert(result.weeks == 3);
+                assert(result.days == 5);
+                assert(result.hours == 19);
+                assert(result.minutes == 7);
+                assert(result.seconds == 2);
+                assert(result.msecs == 123);
+                assert(result.usecs == 456);
+                assert(result.hnsecs == 7);
+                static assert(!is(typeof(result.nsecs)));
+            }
+
+            static assert(!is(typeof(d.split("seconds", "hnsecs")(seconds))));
+            static assert(!is(typeof(d.split("hnsecs", "seconds", "minutes")(hnsecs, seconds, minutes))));
+            static assert(!is(typeof(d.split("hnsecs", "seconds", "msecs")(hnsecs, seconds, msecs))));
+            static assert(!is(typeof(d.split("seconds", "hnecs", "msecs")(seconds, hnsecs, msecs))));
+            static assert(!is(typeof(d.split("seconds", "msecs", "msecs")(seconds, msecs, msecs))));
+            static assert(!is(typeof(d.split("hnsecs", "seconds", "minutes")())));
+            static assert(!is(typeof(d.split("hnsecs", "seconds", "msecs")())));
+            static assert(!is(typeof(d.split("seconds", "hnecs", "msecs")())));
+            static assert(!is(typeof(d.split("seconds", "msecs", "msecs")())));
+            alias _TypeTuple!("nsecs", "hnsecs", "usecs", "msecs", "seconds",
+                              "minutes", "hours", "days", "weeks") timeStrs;
+            foreach(i, str; timeStrs[1 .. $])
+                static assert(!is(typeof(d.split!(timeStrs[i - 1], str)())));
+
+            D nd = -d;
+
+            {
+                auto result = nd.split();
+                assert(result.weeks == -3);
+                assert(result.days == -5);
+                assert(result.hours == -19);
+                assert(result.minutes == -7);
+                assert(result.seconds == -2);
+                assert(result.msecs == -123);
+                assert(result.usecs == -456);
+                assert(result.hnsecs == -7);
+            }
+
+            {
+                auto result = nd.split!("weeks", "days", "hours", "minutes", "seconds", "nsecs")();
+                assert(result.weeks == -3);
+                assert(result.days == -5);
+                assert(result.hours == -19);
+                assert(result.minutes == -7);
+                assert(result.seconds == -2);
+                assert(result.nsecs == -123456700);
+            }
+        }
+    }
+
+
+    // Explicitly undocumented. It will be removed in August 2016. @@@DEPRECATED_2016-08@@@
+    deprecated("Please use split instead. get was too frequently confused for total.")
+    long get(string units)() const nothrow @nogc
+        if(units == "weeks" ||
+           units == "days" ||
+           units == "hours" ||
+           units == "minutes" ||
+           units == "seconds")
+    {
+        static if(units == "weeks")
+            return getUnitsFromHNSecs!"weeks"(_hnsecs);
+        else
+        {
+            immutable hnsecs = removeUnitsFromHNSecs!(nextLargerTimeUnits!units)(_hnsecs);
+            return getUnitsFromHNSecs!units(hnsecs);
+        }
+    }
+
+    ///
+    deprecated unittest
+    {
+        assert(dur!"weeks"(12).get!"weeks" == 12);
+        assert(dur!"weeks"(12).get!"days" == 0);
+
+        assert(dur!"days"(13).get!"weeks" == 1);
+        assert(dur!"days"(13).get!"days" == 6);
+
+        assert(dur!"hours"(49).get!"days" == 2);
+        assert(dur!"hours"(49).get!"hours" == 1);
+    }
+
+    deprecated unittest
+    {
+        foreach(D; _TypeTuple!(const Duration, immutable Duration))
+        {
+            assert((cast(D)dur!"weeks"(12)).get!"weeks" == 12);
+            assert((cast(D)dur!"weeks"(12)).get!"days" == 0);
+
+            assert((cast(D)dur!"days"(13)).get!"weeks" == 1);
+            assert((cast(D)dur!"days"(13)).get!"days" == 6);
+
+            assert((cast(D)dur!"hours"(49)).get!"days" == 2);
+            assert((cast(D)dur!"hours"(49)).get!"hours" == 1);
+        }
+    }
+
+
+    // Explicitly undocumented. It will be removed in August 2016. @@@DEPRECATED_2016-08@@@
+    deprecated(`Please use split instead. The functions which wrapped get were too frequently confused with total.`)
+    @property long weeks() const nothrow @nogc
+    {
+        return get!"weeks"();
+    }
+
+    ///
+    deprecated unittest
+    {
+        assert(dur!"weeks"(12).weeks == 12);
+        assert(dur!"days"(13).weeks == 1);
+    }
+
+    deprecated unittest
+    {
+        foreach(D; _TypeTuple!(const Duration, immutable Duration))
+        {
+            assert((cast(D)dur!"weeks"(12)).weeks == 12);
+            assert((cast(D)dur!"days"(13)).weeks == 1);
+        }
+    }
+
+
+    // Explicitly undocumented. It will be removed in August 2016. @@@DEPRECATED_2016-08@@@
+    deprecated(`Please use split instead. days was too frequently confused for total!"days".`)
+    @property long days() const nothrow @nogc
+    {
+        return get!"days"();
+    }
+
+    ///
+    deprecated unittest
+    {
+        assert(dur!"weeks"(12).days == 0);
+        assert(dur!"days"(13).days == 6);
+        assert(dur!"hours"(49).days == 2);
+    }
+
+    deprecated unittest
+    {
+        foreach(D; _TypeTuple!(const Duration, immutable Duration))
+        {
+            assert((cast(D)dur!"weeks"(12)).days == 0);
+            assert((cast(D)dur!"days"(13)).days == 6);
+            assert((cast(D)dur!"hours"(49)).days == 2);
+        }
+    }
+
+
+    // Explicitly undocumented. It will be removed in August 2016. @@@DEPRECATED_2016-08@@@
+    deprecated(`Please use split instead. hours was too frequently confused for total!"hours".`)
+    @property long hours() const nothrow @nogc
+    {
+        return get!"hours"();
+    }
+
+    ///
+    deprecated unittest
+    {
+        assert(dur!"days"(8).hours == 0);
+        assert(dur!"hours"(49).hours == 1);
+        assert(dur!"minutes"(121).hours == 2);
+    }
+
+    deprecated unittest
+    {
+        foreach(D; _TypeTuple!(const Duration, immutable Duration))
+        {
+            assert((cast(D)dur!"days"(8)).hours == 0);
+            assert((cast(D)dur!"hours"(49)).hours == 1);
+            assert((cast(D)dur!"minutes"(121)).hours == 2);
+        }
+    }
+
+
+    // Explicitly undocumented. It will be removed in August 2016. @@@DEPRECATED_2016-08@@@
+    deprecated(`Please use split instead. minutes was too frequently confused for total!"minutes".`)
+    @property long minutes() const nothrow @nogc
+    {
+        return get!"minutes"();
+    }
+
+    ///
+    deprecated unittest
+    {
+        assert(dur!"hours"(47).minutes == 0);
+        assert(dur!"minutes"(127).minutes == 7);
+        assert(dur!"seconds"(121).minutes == 2);
+    }
+
+    deprecated unittest
+    {
+        foreach(D; _TypeTuple!(const Duration, immutable Duration))
+        {
+            assert((cast(D)dur!"hours"(47)).minutes == 0);
+            assert((cast(D)dur!"minutes"(127)).minutes == 7);
+            assert((cast(D)dur!"seconds"(121)).minutes == 2);
+        }
+    }
+
+
+    // Explicitly undocumented. It will be removed in August 2016. @@@DEPRECATED_2016-08@@@
+    deprecated(`Please use split instead. seconds was too frequently confused for total!"seconds".`)
+    @property long seconds() const nothrow @nogc
+    {
+        return get!"seconds"();
+    }
+
+    ///
+    deprecated unittest
+    {
+        assert(dur!"minutes"(47).seconds == 0);
+        assert(dur!"seconds"(127).seconds == 7);
+        assert(dur!"msecs"(1217).seconds == 1);
+    }
+
+    deprecated unittest
+    {
+        foreach(D; _TypeTuple!(const Duration, immutable Duration))
+        {
+            assert((cast(D)dur!"minutes"(47)).seconds == 0);
+            assert((cast(D)dur!"seconds"(127)).seconds == 7);
+            assert((cast(D)dur!"msecs"(1217)).seconds == 1);
+        }
+    }
+
+
+    // Explicitly undocumented. It will be removed in August 2016. @@@DEPRECATED_2016-08@@@
+    deprecated(`Please use split instead.`)
+    @property FracSec fracSec() const nothrow
+    {
+        try
+        {
+            immutable hnsecs = removeUnitsFromHNSecs!("seconds")(_hnsecs);
+
+            return FracSec.from!"hnsecs"(hnsecs);
+        }
+        catch(Exception e)
+            assert(0, "FracSec.from!\"hnsecs\"() threw.");
+    }
+
+    ///
+    deprecated unittest
+    {
+        assert(dur!"msecs"(1000).fracSec == FracSec.from!"msecs"(0));
+        assert(dur!"msecs"(1217).fracSec == FracSec.from!"msecs"(217));
+        assert(dur!"usecs"(43).fracSec == FracSec.from!"usecs"(43));
+        assert(dur!"hnsecs"(50_007).fracSec == FracSec.from!"hnsecs"(50_007));
+        assert(dur!"nsecs"(62_127).fracSec == FracSec.from!"nsecs"(62_100));
+
+        assert(dur!"msecs"(-1000).fracSec == FracSec.from!"msecs"(-0));
+        assert(dur!"msecs"(-1217).fracSec == FracSec.from!"msecs"(-217));
+        assert(dur!"usecs"(-43).fracSec == FracSec.from!"usecs"(-43));
+        assert(dur!"hnsecs"(-50_007).fracSec == FracSec.from!"hnsecs"(-50_007));
+        assert(dur!"nsecs"(-62_127).fracSec == FracSec.from!"nsecs"(-62_100));
+    }
+
+    deprecated unittest
+    {
+        foreach(D; _TypeTuple!(const Duration, immutable Duration))
+        {
+            assert((cast(D)dur!"msecs"(1000)).fracSec == FracSec.from!"msecs"(0));
+            assert((cast(D)dur!"msecs"(1217)).fracSec == FracSec.from!"msecs"(217));
+            assert((cast(D)dur!"usecs"(43)).fracSec == FracSec.from!"usecs"(43));
+            assert((cast(D)dur!"hnsecs"(50_007)).fracSec == FracSec.from!"hnsecs"(50_007));
+            assert((cast(D)dur!"nsecs"(62_127)).fracSec == FracSec.from!"nsecs"(62_100));
+
+            assert((cast(D)dur!"msecs"(-1000)).fracSec == FracSec.from!"msecs"(-0));
+            assert((cast(D)dur!"msecs"(-1217)).fracSec == FracSec.from!"msecs"(-217));
+            assert((cast(D)dur!"usecs"(-43)).fracSec == FracSec.from!"usecs"(-43));
+            assert((cast(D)dur!"hnsecs"(-50_007)).fracSec == FracSec.from!"hnsecs"(-50_007));
+            assert((cast(D)dur!"nsecs"(-62_127)).fracSec == FracSec.from!"nsecs"(-62_100));
+        }
+    }
+
+
+    /++
+        Returns the total number of the given units in this $(D Duration).
+        So, unlike $(D split), it does not strip out the larger units.
+      +/
+    @property long total(string units)() const nothrow @nogc
+        if(units == "weeks" ||
+           units == "days" ||
+           units == "hours" ||
+           units == "minutes" ||
+           units == "seconds" ||
+           units == "msecs" ||
+           units == "usecs" ||
+           units == "hnsecs" ||
+           units == "nsecs")
+    {
+        static if(units == "nsecs")
+            return convert!("hnsecs", "nsecs")(_hnsecs);
+        else
+            return getUnitsFromHNSecs!units(_hnsecs);
+    }
+
+    ///
+    unittest
+    {
+        assert(dur!"weeks"(12).total!"weeks" == 12);
+        assert(dur!"weeks"(12).total!"days" == 84);
+
+        assert(dur!"days"(13).total!"weeks" == 1);
+        assert(dur!"days"(13).total!"days" == 13);
+
+        assert(dur!"hours"(49).total!"days" == 2);
+        assert(dur!"hours"(49).total!"hours" == 49);
+
+        assert(dur!"nsecs"(2007).total!"hnsecs" == 20);
+        assert(dur!"nsecs"(2007).total!"nsecs" == 2000);
+    }
+
+    unittest
+    {
+        foreach(D; _TypeTuple!(const Duration, immutable Duration))
+        {
+            assert((cast(D)dur!"weeks"(12)).total!"weeks" == 12);
+            assert((cast(D)dur!"weeks"(12)).total!"days" == 84);
+
+            assert((cast(D)dur!"days"(13)).total!"weeks" == 1);
+            assert((cast(D)dur!"days"(13)).total!"days" == 13);
+
+            assert((cast(D)dur!"hours"(49)).total!"days" == 2);
+            assert((cast(D)dur!"hours"(49)).total!"hours" == 49);
+
+            assert((cast(D)dur!"nsecs"(2007)).total!"hnsecs" == 20);
+            assert((cast(D)dur!"nsecs"(2007)).total!"nsecs" == 2000);
+        }
+    }
+
+
+    /+
+        Converts this $(D Duration) to a $(D string).
+      +/
+    //Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
+    //have versions of toString() with extra modifiers, so we define one version
+    //with modifiers and one without.
+    string toString()
+    {
+        return _toStringImpl();
+    }
+
+
+    /++
+        Converts this $(D Duration) to a $(D string).
+      +/
+    //Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
+    //have versions of toString() with extra modifiers, so we define one version
+    //with modifiers and one without.
+    string toString() const nothrow
+    {
+        return _toStringImpl();
+    }
+
+    unittest
+    {
+        foreach(D; _TypeTuple!(Duration, const Duration, immutable Duration))
+        {
+            assert((cast(D)Duration(0)).toString() == "0 hnsecs");
+            assert((cast(D)Duration(1)).toString() == "1 hnsec");
+            assert((cast(D)Duration(7)).toString() == "7 hnsecs");
+            assert((cast(D)Duration(10)).toString() == "1 μs");
+            assert((cast(D)Duration(20)).toString() == "2 μs");
+            assert((cast(D)Duration(10_000)).toString() == "1 ms");
+            assert((cast(D)Duration(20_000)).toString() == "2 ms");
+            assert((cast(D)Duration(10_000_000)).toString() == "1 sec");
+            assert((cast(D)Duration(20_000_000)).toString() == "2 secs");
+            assert((cast(D)Duration(600_000_000)).toString() == "1 minute");
+            assert((cast(D)Duration(1_200_000_000)).toString() == "2 minutes");
+            assert((cast(D)Duration(36_000_000_000)).toString() == "1 hour");
+            assert((cast(D)Duration(72_000_000_000)).toString() == "2 hours");
+            assert((cast(D)Duration(864_000_000_000)).toString() == "1 day");
+            assert((cast(D)Duration(1_728_000_000_000)).toString() == "2 days");
+            assert((cast(D)Duration(6_048_000_000_000)).toString() == "1 week");
+            assert((cast(D)Duration(12_096_000_000_000)).toString() == "2 weeks");
+
+            assert((cast(D)Duration(12)).toString() == "1 μs and 2 hnsecs");
+            assert((cast(D)Duration(120_795)).toString() == "12 ms, 79 μs, and 5 hnsecs");
+            assert((cast(D)Duration(12_096_020_900_003)).toString() == "2 weeks, 2 secs, 90 ms, and 3 hnsecs");
+
+            assert((cast(D)Duration(-1)).toString() == "-1 hnsecs");
+            assert((cast(D)Duration(-7)).toString() == "-7 hnsecs");
+            assert((cast(D)Duration(-10)).toString() == "-1 μs");
+            assert((cast(D)Duration(-20)).toString() == "-2 μs");
+            assert((cast(D)Duration(-10_000)).toString() == "-1 ms");
+            assert((cast(D)Duration(-20_000)).toString() == "-2 ms");
+            assert((cast(D)Duration(-10_000_000)).toString() == "-1 secs");
+            assert((cast(D)Duration(-20_000_000)).toString() == "-2 secs");
+            assert((cast(D)Duration(-600_000_000)).toString() == "-1 minutes");
+            assert((cast(D)Duration(-1_200_000_000)).toString() == "-2 minutes");
+            assert((cast(D)Duration(-36_000_000_000)).toString() == "-1 hours");
+            assert((cast(D)Duration(-72_000_000_000)).toString() == "-2 hours");
+            assert((cast(D)Duration(-864_000_000_000)).toString() == "-1 days");
+            assert((cast(D)Duration(-1_728_000_000_000)).toString() == "-2 days");
+            assert((cast(D)Duration(-6_048_000_000_000)).toString() == "-1 weeks");
+            assert((cast(D)Duration(-12_096_000_000_000)).toString() == "-2 weeks");
+
+            assert((cast(D)Duration(-12)).toString() == "-1 μs and -2 hnsecs");
+            assert((cast(D)Duration(-120_795)).toString() == "-12 ms, -79 μs, and -5 hnsecs");
+            assert((cast(D)Duration(-12_096_020_900_003)).toString() == "-2 weeks, -2 secs, -90 ms, and -3 hnsecs");
+        }
+    }
+
+
+    /++
+        Returns whether this $(D Duration) is negative.
+      +/
+    @property bool isNegative() const nothrow @nogc
+    {
+        return _hnsecs < 0;
+    }
+
+    unittest
+    {
+        foreach(D; _TypeTuple!(Duration, const Duration, immutable Duration))
+        {
+            assert(!(cast(D)Duration(100)).isNegative);
+            assert(!(cast(D)Duration(1)).isNegative);
+            assert(!(cast(D)Duration(0)).isNegative);
+            assert((cast(D)Duration(-1)).isNegative);
+            assert((cast(D)Duration(-100)).isNegative);
+        }
+    }
+
+
+private:
+
+    /+
+        Since we have two versions of toString, we have _toStringImpl
+        so that they can share implementations.
+      +/
+    string _toStringImpl() const nothrow
+    {
+        static void appListSep(ref string res, uint pos, bool last) nothrow
+        {
+            if (pos == 0)
+                return;
+            if (!last)
+                res ~= ", ";
+            else
+                res ~= pos == 1 ? " and " : ", and ";
+        }
+
+        static void appUnitVal(string units)(ref string res, long val) nothrow
+        {
+            immutable plural = val != 1;
+            string unit;
+            static if (units == "seconds")
+                unit = plural ? "secs" : "sec";
+            else static if (units == "msecs")
+                unit = "ms";
+            else static if (units == "usecs")
+                unit = "μs";
+            else
+                unit = plural ? units : units[0 .. $-1];
+            res ~= signedToTempString(val, 10);
+            res ~= " ";
+            res ~= unit;
+        }
+
+        if (_hnsecs == 0) return "0 hnsecs";
+
+        template TT(T...) { alias T TT; }
+        alias units = TT!("weeks", "days", "hours", "minutes", "seconds", "msecs", "usecs");
+
+        long hnsecs = _hnsecs; string res; uint pos;
+        foreach (unit; units)
+        {
+            if (auto val = splitUnitsFromHNSecs!unit(hnsecs))
+            {
+                appListSep(res, pos++, hnsecs == 0);
+                appUnitVal!unit(res, val);
+            }
+            if (hnsecs == 0) break;
+        }
+        if (hnsecs != 0)
+        {
+            appListSep(res, pos++, true);
+            appUnitVal!"hnsecs"(res, hnsecs);
+        }
+        return res;
+    }
+
+
+    /+
+        Params:
+            hnsecs = The total number of hecto-nanoseconds in this $(D Duration).
+      +/
+    this(long hnsecs) nothrow @nogc
+    {
+        _hnsecs = hnsecs;
+    }
+
+
+    long _hnsecs;
+}
+
+///
+unittest
+{
+    import core.time;
+
+    // using the dur template
+    auto numDays = dur!"days"(12);
+
+    // using the days function
+    numDays = days(12);
+
+    // alternatively using UFCS syntax
+    numDays = 12.days;
+
+    auto myTime = 100.msecs + 20_000.usecs + 30_000.hnsecs;
+    assert(myTime == 123.msecs);
+}
+
+/++
+    Converts a $(D TickDuration) to the given units as either an integral
+    value or a floating point value.
+
+    Params:
+        units = The units to convert to. Accepts $(D "seconds") and smaller
+                only.
+        T     = The type to convert to (either an integral type or a
+                floating point type).
+
+        td    = The TickDuration to convert
+  +/
+T to(string units, T, D)(D td) @safe pure nothrow @nogc
+    if(is(_Unqual!D == TickDuration) &&
+       (units == "seconds" ||
+        units == "msecs" ||
+        units == "usecs" ||
+        units == "hnsecs" ||
+        units == "nsecs"))
+{
+    static if(__traits(isIntegral, T) && T.sizeof >= 4)
+    {
+        enum unitsPerSec = convert!("seconds", units)(1);
+
+        return cast(T) (td.length / (TickDuration.ticksPerSec / cast(real) unitsPerSec));
+    }
+    else static if(__traits(isFloating, T))
+    {
+        static if(units == "seconds")
+            return td.length / cast(T)TickDuration.ticksPerSec;
+        else
+        {
+            enum unitsPerSec = convert!("seconds", units)(1);
+
+            return cast(T) (td.length /
+                (TickDuration.ticksPerSec / cast(real) unitsPerSec));
+        }
+    }
+    else
+        static assert(0, "Incorrect template constraint.");
+}
+
+///
+unittest
+{
+    auto t = TickDuration.from!"seconds"(1000);
+
+    long tl = to!("seconds",long)(t);
+    assert(tl == 1000);
+
+    double td = to!("seconds",double)(t);
+    assert(_abs(td - 1000) < 0.001);
+}
+
+unittest
+{
+    void testFun(string U)() {
+        auto t1v = 1000;
+        auto t2v = 333;
+
+        auto t1 = TickDuration.from!U(t1v);
+        auto t2 = TickDuration.from!U(t2v);
+
+        auto _str(F)(F val)
+        {
+            static if(is(F == int) || is(F == long))
+                return signedToTempString(val, 10);
+            else
+                return unsignedToTempString(val, 10);
+        }
+
+        foreach (F; _TypeTuple!(int,uint,long,ulong,float,double,real))
+        {
+            F t1f = to!(U,F)(t1);
+            F t2f = to!(U,F)(t2);
+            auto t12d = t1 / t2v;
+            auto t12m = t1 - t2;
+            F t3f = to!(U,F)(t12d);
+            F t4f = to!(U,F)(t12m);
+
+
+            static if(is(F == float) || is(F == double) || is(F == real))
+            {
+                assert((t1f - cast(F)t1v) <= 3.0,
+                    F.stringof ~ " " ~ U ~ " " ~ doubleToString(t1f) ~ " " ~
+                    doubleToString(cast(F)t1v)
+                );
+                assert((t2f - cast(F)t2v) <= 3.0,
+                    F.stringof ~ " " ~ U ~ " " ~ doubleToString(t2f) ~ " " ~
+                    doubleToString(cast(F)t2v)
+                );
+                assert(t3f - (cast(F)t1v) / (cast(F)t2v) <= 3.0,
+                    F.stringof ~ " " ~ U ~ " " ~ doubleToString(t3f) ~ " " ~
+                    doubleToString((cast(F)t1v)/(cast(F)t2v))
+                );
+                assert(t4f - (cast(F)(t1v - t2v)) <= 3.0,
+                    F.stringof ~ " " ~ U ~ " " ~ doubleToString(t4f) ~ " " ~
+                    doubleToString(cast(F)(t1v - t2v))
+                );
+            }
+            else
+            {
+                // even though this should be exact math it is not as internal
+                // in "to" floating point is used
+                assert(_abs(t1f) - _abs(cast(F)t1v) <= 3,
+                    F.stringof ~ " " ~ U ~ " " ~ _str(t1f) ~ " " ~
+                    _str(cast(F)t1v)
+                );
+                assert(_abs(t2f) - _abs(cast(F)t2v) <= 3,
+                    F.stringof ~ " " ~ U ~ " " ~ _str(t2f) ~ " " ~
+                    _str(cast(F)t2v)
+                );
+                assert(_abs(t3f) - _abs((cast(F)t1v) / (cast(F)t2v)) <= 3,
+                    F.stringof ~ " " ~ U ~ " " ~ _str(t3f) ~ " " ~
+                    _str((cast(F)t1v) / (cast(F)t2v))
+                );
+                assert(_abs(t4f) - _abs((cast(F)t1v) - (cast(F)t2v)) <= 3,
+                    F.stringof ~ " " ~ U ~ " " ~ _str(t4f) ~ " " ~
+                    _str((cast(F)t1v) - (cast(F)t2v))
+                );
+            }
+        }
+    }
+
+    testFun!"seconds"();
+    testFun!"msecs"();
+    testFun!"usecs"();
+}
+
+/++
+    These allow you to construct a $(D Duration) from the given time units
+    with the given length.
+
+    You can either use the generic function $(D dur) and give it the units as
+    a $(D string) or use the named aliases.
+
+    The possible values for units are $(D "weeks"), $(D "days"), $(D "hours"),
+    $(D "minutes"), $(D "seconds"), $(D "msecs") (milliseconds), $(D "usecs"),
+    (microseconds), $(D "hnsecs") (hecto-nanoseconds, i.e. 100 ns), and
+    $(D "nsecs").
+
+    Params:
+        units  = The time units of the $(D Duration) (e.g. $(D "days")).
+        length = The number of units in the $(D Duration).
+  +/
+Duration dur(string units)(long length) @safe pure nothrow @nogc
+    if(units == "weeks" ||
+       units == "days" ||
+       units == "hours" ||
+       units == "minutes" ||
+       units == "seconds" ||
+       units == "msecs" ||
+       units == "usecs" ||
+       units == "hnsecs" ||
+       units == "nsecs")
+{
+    return Duration(convert!(units, "hnsecs")(length));
+}
+
+alias weeks   = dur!"weeks";   /// Ditto
+alias days    = dur!"days";    /// Ditto
+alias hours   = dur!"hours";   /// Ditto
+alias minutes = dur!"minutes"; /// Ditto
+alias seconds = dur!"seconds"; /// Ditto
+alias msecs   = dur!"msecs";   /// Ditto
+alias usecs   = dur!"usecs";   /// Ditto
+alias hnsecs  = dur!"hnsecs";  /// Ditto
+alias nsecs   = dur!"nsecs";   /// Ditto
+
+///
+unittest
+{
+    // Generic
+    assert(dur!"weeks"(142).total!"weeks" == 142);
+    assert(dur!"days"(142).total!"days" == 142);
+    assert(dur!"hours"(142).total!"hours" == 142);
+    assert(dur!"minutes"(142).total!"minutes" == 142);
+    assert(dur!"seconds"(142).total!"seconds" == 142);
+    assert(dur!"msecs"(142).total!"msecs" == 142);
+    assert(dur!"usecs"(142).total!"usecs" == 142);
+    assert(dur!"hnsecs"(142).total!"hnsecs" == 142);
+    assert(dur!"nsecs"(142).total!"nsecs" == 100);
+
+    // Non-generic
+    assert(weeks(142).total!"weeks" == 142);
+    assert(days(142).total!"days" == 142);
+    assert(hours(142).total!"hours" == 142);
+    assert(minutes(142).total!"minutes" == 142);
+    assert(seconds(142).total!"seconds" == 142);
+    assert(msecs(142).total!"msecs" == 142);
+    assert(usecs(142).total!"usecs" == 142);
+    assert(hnsecs(142).total!"hnsecs" == 142);
+    assert(nsecs(142).total!"nsecs" == 100);
+}
+
+unittest
+{
+    foreach(D; _TypeTuple!(Duration, const Duration, immutable Duration))
+    {
+        assert(dur!"weeks"(7).total!"weeks" == 7);
+        assert(dur!"days"(7).total!"days" == 7);
+        assert(dur!"hours"(7).total!"hours" == 7);
+        assert(dur!"minutes"(7).total!"minutes" == 7);
+        assert(dur!"seconds"(7).total!"seconds" == 7);
+        assert(dur!"msecs"(7).total!"msecs" == 7);
+        assert(dur!"usecs"(7).total!"usecs" == 7);
+        assert(dur!"hnsecs"(7).total!"hnsecs" == 7);
+        assert(dur!"nsecs"(7).total!"nsecs" == 0);
+
+        assert(dur!"weeks"(1007) == weeks(1007));
+        assert(dur!"days"(1007) == days(1007));
+        assert(dur!"hours"(1007) == hours(1007));
+        assert(dur!"minutes"(1007) == minutes(1007));
+        assert(dur!"seconds"(1007) == seconds(1007));
+        assert(dur!"msecs"(1007) == msecs(1007));
+        assert(dur!"usecs"(1007) == usecs(1007));
+        assert(dur!"hnsecs"(1007) == hnsecs(1007));
+        assert(dur!"nsecs"(10) == nsecs(10));
+    }
+}
+
+// used in MonoTimeImpl
+private string _clockTypeName(ClockType clockType)
+{
+    final switch(clockType)
+    {
+        foreach(name; __traits(allMembers, ClockType))
+        {
+        case __traits(getMember, ClockType, name):
+            return name;
+        }
+    }
+    assert(0);
+}
+
+// used in MonoTimeImpl
+private size_t _clockTypeIdx(ClockType clockType)
+{
+    final switch(clockType)
+    {
+        foreach(i, name; __traits(allMembers, ClockType))
+        {
+        case __traits(getMember, ClockType, name):
+            return i;
+        }
+    }
+    assert(0);
+}
+
+
+/++
+    alias for $(D MonoTimeImpl) instantiated with $(D ClockType.normal). This is
+    what most programs should use. It's also what much of $(D MonoTimeImpl) uses
+    in its documentation (particularly in the examples), because that's what's
+    going to be used in most code.
+  +/
+alias MonoTime = MonoTimeImpl!(ClockType.normal);
+
+/++
+    Represents a timestamp of the system's monotonic clock.
+
+    A monotonic clock is one which always goes forward and never moves
+    backwards, unlike the system's wall clock time (as represented by
+    $(XREF datetime, SysTime)). The system's wall clock time can be adjusted
+    by the user or by the system itself via services such as NTP, so it is
+    unreliable to use the wall clock time for timing. Timers which use the wall
+    clock time could easily end up never going off due to changes made to the
+    wall clock time or otherwise waiting for a different period of time than
+    that specified by the programmer. However, because the monotonic clock
+    always increases at a fixed rate and is not affected by adjustments to the
+    wall clock time, it is ideal for use with timers or anything which requires
+    high precision timing.
+
+    So, MonoTime should be used for anything involving timers and timing,
+    whereas $(XREF datetime, SysTime) should be used when the wall clock time
+    is required.
+
+    The monotonic clock has no relation to wall clock time. Rather, it holds
+    its time as the number of ticks of the clock which have occurred since the
+    clock started (typically when the system booted up). So, to determine how
+    much time has passed between two points in time, one monotonic time is
+    subtracted from the other to determine the number of ticks which occurred
+    between the two points of time, and those ticks are divided by the number of
+    ticks that occur every second (as represented by MonoTime.ticksPerSecond)
+    to get a meaningful duration of time. Normally, MonoTime does these
+    calculations for the programmer, but the $(D ticks) and $(D ticksPerSecond)
+    properties are provided for those who require direct access to the system
+    ticks. The normal way that MonoTime would be used is
+
+--------------------
+    MonoTime before = MonoTime.currTime;
+    // do stuff...
+    MonoTime after = MonoTime.currTime;
+    Duration timeElapsed = after - before;
+--------------------
+
+    $(LREF MonoTime) is an alias to $(D MonoTimeImpl!(ClockType.normal)) and is
+    what most programs should use for the monotonic clock, so that's what is
+    used in most of $(D MonoTimeImpl)'s documentation. But $(D MonoTimeImpl)
+    can be instantiated with other clock types for those rare programs that need
+    it.
+
+    See_Also:
+        $(LREF ClockType)
+  +/
+struct MonoTimeImpl(ClockType clockType)
+{
+    private enum _clockIdx = _clockTypeIdx(clockType);
+    private enum _clockName = _clockTypeName(clockType);
+
+@safe:
+
+    version(Windows)
+    {
+        static if(clockType != ClockType.coarse &&
+                  clockType != ClockType.normal &&
+                  clockType != ClockType.precise)
+        {
+            static assert(0, "ClockType." ~ _clockName ~
+                             " is not supported by MonoTimeImpl on this system.");
+        }
+    }
+    else version(OSX)
+    {
+        static if(clockType != ClockType.coarse &&
+                  clockType != ClockType.normal &&
+                  clockType != ClockType.precise)
+        {
+            static assert(0, "ClockType." ~ _clockName ~
+                             " is not supported by MonoTimeImpl on this system.");
+        }
+    }
+    else version(Posix)
+    {
+        enum clockArg = _posixClock(clockType);
+    }
+    else
+        static assert(0, "Unsupported platform");
+
+    // POD value, test mutable/const/immutable conversion
+    unittest
+    {
+        MonoTimeImpl m;
+        const MonoTimeImpl cm = m;
+        immutable MonoTimeImpl im = m;
+        m = cm;
+        m = im;
+    }
+
+    /++
+        The current time of the system's monotonic clock. This has no relation
+        to the wall clock time, as the wall clock time can be adjusted (e.g.
+        by NTP), whereas the monotonic clock always moves forward. The source
+        of the monotonic time is system-specific.
+
+        On Windows, $(D QueryPerformanceCounter) is used. On Mac OS X,
+        $(D mach_absolute_time) is used, while on other POSIX systems,
+        $(D clock_gettime) is used.
+
+        $(RED Warning): On some systems, the monotonic clock may stop counting
+                        when the computer goes to sleep or hibernates. So, the
+                        monotonic clock may indicate less time than has actually
+                        passed if that occurs. This is known to happen on
+                        Mac OS X. It has not been tested whether it occurs on
+                        either Windows or Linux.
+      +/
+    static @property MonoTimeImpl currTime() @trusted nothrow @nogc
+    {
+        if(ticksPerSecond == 0)
+        {
+            import core.internal.abort : abort;
+            abort("MonoTimeImpl!(ClockType." ~ _clockName ~
+                      ") failed to get the frequency of the system's monotonic clock.");
+        }
+
+        version(Windows)
+        {
+            long ticks;
+            if(QueryPerformanceCounter(&ticks) == 0)
+            {
+                // This probably cannot happen on Windows 95 or later
+                import core.internal.abort : abort;
+                abort("Call to QueryPerformanceCounter failed.");
+            }
+            return MonoTimeImpl(ticks);
+        }
+        else version(OSX)
+            return MonoTimeImpl(mach_absolute_time());
+        else version(Posix)
+        {
+            timespec ts;
+            if(clock_gettime(clockArg, &ts) != 0)
+            {
+                import core.internal.abort : abort;
+                abort("Call to clock_gettime failed.");
+            }
+
+            return MonoTimeImpl(convClockFreq(ts.tv_sec * 1_000_000_000L + ts.tv_nsec,
+                                              1_000_000_000L,
+                                              ticksPerSecond));
+        }
+    }
+
+
+    static @property pure nothrow @nogc
+    {
+    /++
+        A $(D MonoTime) of $(D 0) ticks. It's provided to be consistent with
+        $(D Duration.zero), and it's more explicit than $(D MonoTime.init).
+      +/
+    MonoTimeImpl zero() { return MonoTimeImpl(0); }
+
+    /++
+        Largest $(D MonoTime) possible.
+      +/
+    MonoTimeImpl max() { return MonoTimeImpl(long.max); }
+
+    /++
+        Most negative $(D MonoTime) possible.
+      +/
+    MonoTimeImpl min() { return MonoTimeImpl(long.min); }
+    }
+
+    unittest
+    {
+        assert(MonoTimeImpl.zero == MonoTimeImpl(0));
+        assert(MonoTimeImpl.max == MonoTimeImpl(long.max));
+        assert(MonoTimeImpl.min == MonoTimeImpl(long.min));
+        assert(MonoTimeImpl.min < MonoTimeImpl.zero);
+        assert(MonoTimeImpl.zero < MonoTimeImpl.max);
+        assert(MonoTimeImpl.min < MonoTimeImpl.max);
+    }
+
+
+    /++
+        Compares this MonoTime with the given MonoTime.
+
+        Returns:
+            $(BOOKTABLE,
+                $(TR $(TD this &lt; rhs) $(TD &lt; 0))
+                $(TR $(TD this == rhs) $(TD 0))
+                $(TR $(TD this &gt; rhs) $(TD &gt; 0))
+            )
+     +/
+    int opCmp(MonoTimeImpl rhs) const pure nothrow @nogc
+    {
+        if(_ticks < rhs._ticks)
+            return -1;
+        return _ticks > rhs._ticks ? 1 : 0;
+    }
+
+    unittest
+    {
+        const t = MonoTimeImpl.currTime;
+        assert(t == copy(t));
+    }
+
+    unittest
+    {
+        const before = MonoTimeImpl.currTime;
+        auto after = MonoTimeImpl(before._ticks + 42);
+        assert(before < after);
+        assert(copy(before) <= before);
+        assert(copy(after) > before);
+        assert(after >= copy(after));
+    }
+
+    unittest
+    {
+        const currTime = MonoTimeImpl.currTime;
+        assert(MonoTimeImpl(long.max) > MonoTimeImpl(0));
+        assert(MonoTimeImpl(0) > MonoTimeImpl(long.min));
+        assert(MonoTimeImpl(long.max) > currTime);
+        assert(currTime > MonoTimeImpl(0));
+        assert(MonoTimeImpl(0) < currTime);
+        assert(MonoTimeImpl(0) < MonoTimeImpl(long.max));
+        assert(MonoTimeImpl(long.min) < MonoTimeImpl(0));
+    }
+
+
+    /++
+        Subtracting two MonoTimes results in a $(LREF Duration) representing
+        the amount of time which elapsed between them.
+
+        The primary way that programs should time how long something takes is to
+        do
+--------------------
+MonoTime before = MonoTime.currTime;
+// do stuff
+MonoTime after = MonoTime.currTime;
+
+// How long it took.
+Duration timeElapsed = after - before;
+--------------------
+        or to use a wrapper (such as a stop watch type) which does that.
+
+        $(RED Warning):
+            Because $(LREF Duration) is in hnsecs, whereas MonoTime is in system
+            ticks, it's usually the case that this assertion will fail
+--------------------
+auto before = MonoTime.currTime;
+// do stuff
+auto after = MonoTime.currTime;
+auto timeElapsed = after - before;
+assert(before + timeElapsed == after).
+--------------------
+
+            This is generally fine, and by its very nature, converting from
+            system ticks to any type of seconds (hnsecs, nsecs, etc.) will
+            introduce rounding errors, but if code needs to avoid any of the
+            small rounding errors introduced by conversion, then it needs to use
+            MonoTime's $(D ticks) property and keep all calculations in ticks
+            rather than using $(LREF Duration).
+      +/
+    Duration opBinary(string op)(MonoTimeImpl rhs) const pure nothrow @nogc
+        if(op == "-")
+    {
+        immutable diff = _ticks - rhs._ticks;
+        return Duration(convClockFreq(diff , ticksPerSecond, hnsecsPer!"seconds"));
+    }
+
+    unittest
+    {
+        const t = MonoTimeImpl.currTime;
+        assert(t - copy(t) == Duration.zero);
+        static assert(!__traits(compiles, t + t));
+    }
+
+    unittest
+    {
+        static void test(in MonoTimeImpl before, in MonoTimeImpl after, in Duration min)
+        {
+            immutable diff = after - before;
+            assert(diff >= min);
+            auto calcAfter = before + diff;
+            assertApprox(calcAfter, calcAfter - Duration(1), calcAfter + Duration(1));
+            assert(before - after == -diff);
+        }
+
+        const before = MonoTimeImpl.currTime;
+        test(before, MonoTimeImpl(before._ticks + 4202), Duration.zero);
+        test(before, MonoTimeImpl.currTime, Duration.zero);
+
+        const durLargerUnits = dur!"minutes"(7) + dur!"seconds"(22);
+        test(before, before + durLargerUnits + dur!"msecs"(33) + dur!"hnsecs"(571), durLargerUnits);
+    }
+
+
+    /++
+        Adding or subtracting a $(LREF Duration) to/from a MonoTime results in
+        a MonoTime which is adjusted by that amount.
+      +/
+    MonoTimeImpl opBinary(string op)(Duration rhs) const pure nothrow @nogc
+        if(op == "+" || op == "-")
+    {
+        immutable rhsConverted = convClockFreq(rhs._hnsecs, hnsecsPer!"seconds", ticksPerSecond);
+        mixin("return MonoTimeImpl(_ticks " ~ op ~ " rhsConverted);");
+    }
+
+    unittest
+    {
+        const t = MonoTimeImpl.currTime;
+        assert(t + Duration(0) == t);
+        assert(t - Duration(0) == t);
+    }
+
+    unittest
+    {
+        const t = MonoTimeImpl.currTime;
+
+        // We reassign ticks in order to get the same rounding errors
+        // that we should be getting with Duration (e.g. MonoTimeImpl may be
+        // at a higher precision than hnsecs, meaning that 7333 would be
+        // truncated when converting to hnsecs).
+        long ticks = 7333;
+        auto hnsecs = convClockFreq(ticks, ticksPerSecond, hnsecsPer!"seconds");
+        ticks = convClockFreq(hnsecs, hnsecsPer!"seconds", ticksPerSecond);
+
+        assert(t - Duration(hnsecs) == MonoTimeImpl(t._ticks - ticks));
+        assert(t + Duration(hnsecs) == MonoTimeImpl(t._ticks + ticks));
+    }
+
+
+    /++ Ditto +/
+    ref MonoTimeImpl opOpAssign(string op)(Duration rhs) pure nothrow @nogc
+        if(op == "+" || op == "-")
+    {
+        immutable rhsConverted = convClockFreq(rhs._hnsecs, hnsecsPer!"seconds", ticksPerSecond);
+        mixin("_ticks " ~ op ~ "= rhsConverted;");
+        return this;
+    }
+
+    unittest
+    {
+        auto mt = MonoTimeImpl.currTime;
+        const initial = mt;
+        mt += Duration(0);
+        assert(mt == initial);
+        mt -= Duration(0);
+        assert(mt == initial);
+
+        // We reassign ticks in order to get the same rounding errors
+        // that we should be getting with Duration (e.g. MonoTimeImpl may be
+        // at a higher precision than hnsecs, meaning that 7333 would be
+        // truncated when converting to hnsecs).
+        long ticks = 7333;
+        auto hnsecs = convClockFreq(ticks, ticksPerSecond, hnsecsPer!"seconds");
+        ticks = convClockFreq(hnsecs, hnsecsPer!"seconds", ticksPerSecond);
+        auto before = MonoTimeImpl(initial._ticks - ticks);
+
+        assert((mt -= Duration(hnsecs)) == before);
+        assert(mt  == before);
+        assert((mt += Duration(hnsecs)) == initial);
+        assert(mt  == initial);
+    }
+
+
+    /++
+        The number of ticks in the monotonic time.
+
+        Most programs should not use this directly, but it's exposed for those
+        few programs that need it.
+
+        The main reasons that a program might need to use ticks directly is if
+        the system clock has higher precision than hnsecs, and the program needs
+        that higher precision, or if the program needs to avoid the rounding
+        errors caused by converting to hnsecs.
+      +/
+    @property long ticks() const pure nothrow @nogc
+    {
+        return _ticks;
+    }
+
+    unittest
+    {
+        const mt = MonoTimeImpl.currTime;
+        assert(mt.ticks == mt._ticks);
+    }
+
+
+    /++
+        The number of ticks that MonoTime has per second - i.e. the resolution
+        or frequency of the system's monotonic clock.
+
+        e.g. if the system clock had a resolution of microseconds, then
+        ticksPerSecond would be $(D 1_000_000).
+      +/
+    static @property long ticksPerSecond() pure nothrow @nogc
+    {
+        return _ticksPerSecond[_clockIdx];
+    }
+
+    unittest
+    {
+        assert(MonoTimeImpl.ticksPerSecond == _ticksPerSecond[_clockIdx]);
+    }
+
+
+    ///
+    string toString() const pure nothrow
+    {
+        static if(clockType == ClockType.normal)
+            return "MonoTime(" ~ signedToTempString(_ticks, 10) ~ " ticks, " ~ signedToTempString(ticksPerSecond, 10) ~ " ticks per second)";
+        else
+            return "MonoTimeImpl!(ClockType." ~ _clockName ~ ")(" ~ signedToTempString(_ticks, 10) ~ " ticks, " ~
+                   signedToTempString(ticksPerSecond, 10) ~ " ticks per second)";
+    }
+
+    unittest
+    {
+        static min(T)(T a, T b) { return a < b ? a : b; }
+
+        static void eat(ref string s, const(char)[] exp)
+        {
+            assert(s[0 .. min($, exp.length)] == exp, s~" != "~exp);
+            s = s[exp.length .. $];
+        }
+
+        immutable mt = MonoTimeImpl.currTime;
+        auto str = mt.toString();
+        static if(is(typeof(this) == MonoTime))
+            eat(str, "MonoTime(");
+        else
+            eat(str, "MonoTimeImpl!(ClockType."~_clockName~")(");
+
+        eat(str, signedToTempString(mt._ticks, 10));
+        eat(str, " ticks, ");
+        eat(str, signedToTempString(ticksPerSecond, 10));
+        eat(str, " ticks per second)");
+    }
+
+private:
+
+    // static immutable long _ticksPerSecond;
+
+    unittest
+    {
+        assert(_ticksPerSecond[_clockIdx]);
+    }
+
+
+    long _ticks;
+}
+
+// This is supposed to be a static variable in MonoTimeImpl with the static
+// constructor being in there, but https://issues.dlang.org/show_bug.cgi?id=14517
+// prevents that from working. However, moving it back to a static ctor will
+// reraise issues with other systems using MonoTime, so we should leave this
+// here even when that bug is fixed.
+private immutable long[__traits(allMembers, ClockType).length] _ticksPerSecond;
+
+// This is called directly from the runtime initilization function (rt_init),
+// instead of using a static constructor. Other subsystems inside the runtime
+// (namely, the GC) may need time functionality, but cannot wait until the
+// static ctors have run. Therefore, we initialize these specially. Because
+// it's a normal function, we need to do some dangerous casting PLEASE take
+// care when modifying this function, and it should NOT be called except from
+// the runtime init.
+//
+// NOTE: the code below SPECIFICALLY does not assert when it cannot initialize
+// the ticks per second array. This allows cases where a clock is never used on
+// a system that doesn't support it. See bugzilla issue
+// https://issues.dlang.org/show_bug.cgi?id=14863
+// The assert will occur when someone attempts to use _ticksPerSecond for that
+// value.
+extern(C) void _d_initMonoTime()
+{
+    // We need a mutable pointer to the ticksPerSecond array. Although this
+    // would appear to break immutability, it is logically the same as a static
+    // ctor. So we should ONLY write these values once (we will check for 0
+    // values when setting to ensure this is truly only called once).
+    auto tps = cast(long[])_ticksPerSecond[];
+
+    // If we try to do anything with ClockType in the documentation build, it'll
+    // trigger the static assertions related to ClockType, since the
+    // documentation build defines all of the possible ClockTypes, which won't
+    // work when they're used in the static ifs, because no system supports them
+    // all.
+    version(CoreDdoc)
+    {}
+    else version(Windows)
+    {
+        long ticksPerSecond;
+        if(QueryPerformanceFrequency(&ticksPerSecond) != 0)
+        {
+            foreach(i, typeStr; __traits(allMembers, ClockType))
+            {
+                // ensure we are only writing immutable data once
+                if(tps[i] != 0)
+                    // should only be called once
+                    assert(0);
+                tps[i] = ticksPerSecond;
+            }
+        }
+    }
+    else version(OSX)
+    {
+        immutable long ticksPerSecond = machTicksPerSecond();
+        foreach(i, typeStr; __traits(allMembers, ClockType))
+        {
+            // ensure we are only writing immutable data once
+            if(tps[i] != 0)
+                // should only be called once
+                assert(0);
+            tps[i] = ticksPerSecond;
+        }
+    }
+    else version(Posix)
+    {
+        timespec ts;
+        foreach(i, typeStr; __traits(allMembers, ClockType))
+        {
+            static if(typeStr != "second")
+            {
+                enum clockArg = _posixClock(__traits(getMember, ClockType, typeStr));
+                if(clock_getres(clockArg, &ts) == 0)
+                {
+                    // ensure we are only writing immutable data once
+                    if(tps[i] != 0)
+                        // should only be called once
+                        assert(0);
+
+                    // For some reason, on some systems, clock_getres returns
+                    // a resolution which is clearly wrong (it's a millisecond
+                    // or worse, but the time is updated much more frequently
+                    // than that). In such cases, we'll just use nanosecond
+                    // resolution.
+                    tps[i] = ts.tv_nsec >= 1000 ? 1_000_000_000L
+                                                            : 1_000_000_000L / ts.tv_nsec;
+                }
+            }
+        }
+    }
+}
+
+
+// Tests for MonoTimeImpl.currTime. It has to be outside, because MonoTimeImpl
+// is a template. This unittest block also makes sure that MonoTimeImpl actually
+// is instantiated with all of the various ClockTypes so that those types and
+// their tests are compiled and run.
+unittest
+{
+    // This test is separate so that it can be tested with MonoTime and not just
+    // MonoTimeImpl.
+    auto norm1 = MonoTime.currTime;
+    auto norm2 = MonoTimeImpl!(ClockType.normal).currTime;
+    assert(norm1 <= norm2);
+
+    static bool clockSupported(ClockType c)
+    {
+        version (Linux_Pre_2639) // skip CLOCK_BOOTTIME on older linux kernels
+            return c != ClockType.second && c != ClockType.bootTime;
+        else
+            return c != ClockType.second; // second doesn't work with MonoTimeImpl
+
+    }
+
+    foreach(typeStr; __traits(allMembers, ClockType))
+    {
+        mixin("alias type = ClockType." ~ typeStr ~ ";");
+        static if (clockSupported(type))
+        {
+            auto v1 = MonoTimeImpl!type.currTime;
+            auto v2 = MonoTimeImpl!type.currTime;
+            scope(failure)
+            {
+                printf("%s: v1 %s, v2 %s, tps %s\n",
+                       (type.stringof ~ "\0").ptr,
+                       numToStringz(v1._ticks),
+                       numToStringz(v2._ticks),
+                       numToStringz(typeof(v1).ticksPerSecond));
+            }
+            assert(v1 <= v2);
+
+            foreach(otherStr; __traits(allMembers, ClockType))
+            {
+                mixin("alias other = ClockType." ~ otherStr ~ ";");
+                static if (clockSupported(other))
+                {
+                    static assert(is(typeof({auto o1 = MonTimeImpl!other.currTime; auto b = v1 <= o1;})) ==
+                                  is(type == other));
+                }
+            }
+        }
+    }
+}
+
+
+/++
+    Converts the given time from one clock frequency/resolution to another.
+
+    See_Also:
+        $(LREF ticksToNSecs)
+  +/
+long convClockFreq(long ticks, long srcTicksPerSecond, long dstTicksPerSecond) @safe pure nothrow @nogc
+{
+    // This would be more straightforward with floating point arithmetic,
+    // but we avoid it here in order to avoid the rounding errors that that
+    // introduces. Also, by splitting out the units in this way, we're able
+    // to deal with much larger values before running into problems with
+    // integer overflow.
+    return ticks / srcTicksPerSecond * dstTicksPerSecond +
+           ticks % srcTicksPerSecond * dstTicksPerSecond / srcTicksPerSecond;
+}
+
+///
+unittest
+{
+    // one tick is one second -> one tick is a hecto-nanosecond
+    assert(convClockFreq(45, 1, 10_000_000) == 450_000_000);
+
+    // one tick is one microsecond -> one tick is a millisecond
+    assert(convClockFreq(9029, 1_000_000, 1_000) == 9);
+
+    // one tick is 1/3_515_654 of a second -> 1/1_001_010 of a second
+    assert(convClockFreq(912_319, 3_515_654, 1_001_010) == 259_764);
+
+    // one tick is 1/MonoTime.ticksPerSecond -> one tick is a nanosecond
+    // Equivalent to ticksToNSecs
+    auto nsecs = convClockFreq(1982, MonoTime.ticksPerSecond, 1_000_000_000);
+}
+
+unittest
+{
+    assert(convClockFreq(99, 43, 57) == 131);
+    assert(convClockFreq(131, 57, 43) == 98);
+    assert(convClockFreq(1234567890, 10_000_000, 1_000_000_000) == 123456789000);
+    assert(convClockFreq(1234567890, 1_000_000_000, 10_000_000) == 12345678);
+    assert(convClockFreq(123456789000, 1_000_000_000, 10_000_000) == 1234567890);
+    assert(convClockFreq(12345678, 10_000_000, 1_000_000_000) == 1234567800);
+    assert(convClockFreq(13131, 3_515_654, 10_000_000) == 37350);
+    assert(convClockFreq(37350, 10_000_000, 3_515_654) == 13130);
+    assert(convClockFreq(37350, 3_515_654, 10_000_000) == 106239);
+    assert(convClockFreq(106239, 10_000_000, 3_515_654) == 37349);
+
+    // It would be too expensive to cover a large range of possible values for
+    // ticks, so we use random values in an attempt to get reasonable coverage.
+    import core.stdc.stdlib;
+    immutable seed = cast(int)time(null);
+    srand(seed);
+    scope(failure) printf("seed %d\n", seed);
+    enum freq1 = 5_527_551L;
+    enum freq2 = 10_000_000L;
+    enum freq3 = 1_000_000_000L;
+    enum freq4 = 98_123_320L;
+    immutable freq5 = MonoTime.ticksPerSecond;
+
+    // This makes it so that freq6 is the first multiple of 10 which is greater
+    // than or equal to freq5, which at one point was considered for MonoTime's
+    // ticksPerSecond rather than using the system's actual clock frequency, so
+    // it seemed like a good test case to have.
+    import core.stdc.math;
+    immutable numDigitsMinus1 = cast(int)floor(log10(freq5));
+    auto freq6 = cast(long)pow(10, numDigitsMinus1);
+    if(freq5 > freq6)
+        freq6 *= 10;
+
+    foreach(_; 0 .. 10_000)
+    {
+        long[2] values = [rand(), cast(long)rand() * (rand() % 16)];
+        foreach(i; values)
+        {
+            scope(failure) printf("i %s\n", numToStringz(i));
+            assertApprox(convClockFreq(convClockFreq(i, freq1, freq2), freq2, freq1), i - 10, i + 10);
+            assertApprox(convClockFreq(convClockFreq(i, freq2, freq1), freq1, freq2), i - 10, i + 10);
+
+            assertApprox(convClockFreq(convClockFreq(i, freq3, freq4), freq4, freq3), i - 100, i + 100);
+            assertApprox(convClockFreq(convClockFreq(i, freq4, freq3), freq3, freq4), i - 100, i + 100);
+
+            scope(failure) printf("sys %s mt %s\n", numToStringz(freq5), numToStringz(freq6));
+            assertApprox(convClockFreq(convClockFreq(i, freq5, freq6), freq6, freq5), i - 10, i + 10);
+            assertApprox(convClockFreq(convClockFreq(i, freq6, freq5), freq5, freq6), i - 10, i + 10);
+
+            // This is here rather than in a unittest block immediately after
+            // ticksToNSecs in order to avoid code duplication in the unit tests.
+            assert(convClockFreq(i, MonoTime.ticksPerSecond, 1_000_000_000) == ticksToNSecs(i));
+        }
+    }
+}
+
+
+/++
+    Convenience wrapper around $(LREF convClockFreq) which converts ticks at
+    a clock frequency of $(D MonoTime.ticksPerSecond) to nanoseconds.
+
+    It's primarily of use when $(D MonoTime.ticksPerSecond) is greater than
+    hecto-nanosecond resolution, and an application needs a higher precision
+    than hecto-nanoceconds.
+
+    See_Also:
+        $(LREF convClockFreq)
+  +/
+long ticksToNSecs(long ticks) @safe pure nothrow @nogc
+{
+    return convClockFreq(ticks, MonoTime.ticksPerSecond, 1_000_000_000);
+}
+
+///
+unittest
+{
+    auto before = MonoTime.currTime;
+    // do stuff
+    auto after = MonoTime.currTime;
+    auto diffInTicks = after.ticks - before.ticks;
+    auto diffInNSecs = ticksToNSecs(diffInTicks);
+    assert(diffInNSecs == convClockFreq(diffInTicks, MonoTime.ticksPerSecond, 1_000_000_000));
+}
+
+
+/++
+    The reverse of $(LREF ticksToNSecs).
+  +/
+long nsecsToTicks(long ticks) @safe pure nothrow @nogc
+{
+    return convClockFreq(ticks, 1_000_000_000, MonoTime.ticksPerSecond);
+}
+
+unittest
+{
+    long ticks = 123409832717333;
+    auto nsecs = convClockFreq(ticks, MonoTime.ticksPerSecond, 1_000_000_000);
+    ticks = convClockFreq(nsecs, 1_000_000_000, MonoTime.ticksPerSecond);
+    assert(nsecsToTicks(nsecs) == ticks);
+}
+
+
+
+/++
+    $(RED Warning: TickDuration will be deprecated in the near future (once all
+          uses of it in Phobos have been deprecated). Please use
+          $(LREF MonoTime) for the cases where a monotonic timestamp is needed
+          and $(LREF Duration) when a duration is needed, rather than using
+          TickDuration. It has been decided that TickDuration is too confusing
+          (e.g. it conflates a monotonic timestamp and a duration in monotonic
+           clock ticks) and that having multiple duration types is too awkward
+          and confusing.)
+
+   Represents a duration of time in system clock ticks.
+
+   The system clock ticks are the ticks of the system clock at the highest
+   precision that the system provides.
+  +/
+struct TickDuration
+{
+    /++
+       The number of ticks that the system clock has in one second.
+
+       If $(D ticksPerSec) is $(D 0), then then $(D TickDuration) failed to
+       get the value of $(D ticksPerSec) on the current system, and
+       $(D TickDuration) is not going to work. That would be highly abnormal
+       though.
+      +/
+    static immutable long ticksPerSec;
+
+
+    /++
+        The tick of the system clock (as a $(D TickDuration)) when the
+        application started.
+      +/
+    static immutable TickDuration appOrigin;
+
+
+    static @property @safe pure nothrow @nogc
+    {
+    /++
+        It's the same as $(D TickDuration(0)), but it's provided to be
+        consistent with $(D Duration) and $(D FracSec), which provide $(D zero)
+        properties.
+      +/
+    TickDuration zero() { return TickDuration(0); }
+
+    /++
+        Largest $(D TickDuration) possible.
+      +/
+    TickDuration max() { return TickDuration(long.max); }
+
+    /++
+        Most negative $(D TickDuration) possible.
+      +/
+    TickDuration min() { return TickDuration(long.min); }
+    }
+
+    unittest
+    {
+        assert(zero == TickDuration(0));
+        assert(TickDuration.max == TickDuration(long.max));
+        assert(TickDuration.min == TickDuration(long.min));
+        assert(TickDuration.min < TickDuration.zero);
+        assert(TickDuration.zero < TickDuration.max);
+        assert(TickDuration.min < TickDuration.max);
+        assert(TickDuration.min - TickDuration(1) == TickDuration.max);
+        assert(TickDuration.max + TickDuration(1) == TickDuration.min);
+    }
+
+
+    @trusted shared static this()
+    {
+        version(Windows)
+        {
+            if(QueryPerformanceFrequency(cast(long*)&ticksPerSec) == 0)
+                ticksPerSec = 0;
+        }
+        else version(OSX)
+        {
+            ticksPerSec = machTicksPerSecond();
+        }
+        else version(Posix)
+        {
+            static if(is(typeof(clock_gettime)))
+            {
+                timespec ts;
+
+                if(clock_getres(CLOCK_MONOTONIC, &ts) != 0)
+                    ticksPerSec = 0;
+                else
+                {
+                    //For some reason, on some systems, clock_getres returns
+                    //a resolution which is clearly wrong (it's a millisecond
+                    //or worse, but the time is updated much more frequently
+                    //than that). In such cases, we'll just use nanosecond
+                    //resolution.
+                    ticksPerSec = ts.tv_nsec >= 1000 ? 1_000_000_000
+                                                     : 1_000_000_000 / ts.tv_nsec;
+                }
+            }
+            else
+                ticksPerSec = 1_000_000;
+        }
+
+        if(ticksPerSec != 0)
+            appOrigin = TickDuration.currSystemTick;
+    }
+
+    unittest
+    {
+        assert(ticksPerSec);
+    }
+
+
+    /++
+       The number of system ticks in this $(D TickDuration).
+
+       You can convert this $(D length) into the number of seconds by dividing
+       it by $(D ticksPerSec) (or using one the appropriate property function
+       to do it).
+      +/
+    long length;
+
+    /++
+        Returns the total number of seconds in this $(D TickDuration).
+      +/
+    @property long seconds() @safe const pure nothrow @nogc
+    {
+        return this.to!("seconds", long)();
+    }
+
+    unittest
+    {
+        foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+        {
+            assert((cast(T)TickDuration(ticksPerSec)).seconds == 1);
+            assert((cast(T)TickDuration(ticksPerSec - 1)).seconds == 0);
+            assert((cast(T)TickDuration(ticksPerSec * 2)).seconds == 2);
+            assert((cast(T)TickDuration(ticksPerSec * 2 - 1)).seconds == 1);
+            assert((cast(T)TickDuration(-1)).seconds == 0);
+            assert((cast(T)TickDuration(-ticksPerSec - 1)).seconds == -1);
+            assert((cast(T)TickDuration(-ticksPerSec)).seconds == -1);
+        }
+    }
+
+
+    /++
+        Returns the total number of milliseconds in this $(D TickDuration).
+      +/
+    @property long msecs() @safe const pure nothrow @nogc
+    {
+        return this.to!("msecs", long)();
+    }
+
+
+    /++
+        Returns the total number of microseconds in this $(D TickDuration).
+      +/
+    @property long usecs() @safe const pure nothrow @nogc
+    {
+        return this.to!("usecs", long)();
+    }
+
+
+    /++
+        Returns the total number of hecto-nanoseconds in this $(D TickDuration).
+      +/
+    @property long hnsecs() @safe const pure nothrow @nogc
+    {
+        return this.to!("hnsecs", long)();
+    }
+
+
+    /++
+        Returns the total number of nanoseconds in this $(D TickDuration).
+      +/
+    @property long nsecs() @safe const pure nothrow @nogc
+    {
+        return this.to!("nsecs", long)();
+    }
+
+
+    /++
+        This allows you to construct a $(D TickDuration) from the given time
+        units with the given length.
+
+        Params:
+            units  = The time units of the $(D TickDuration) (e.g. $(D "msecs")).
+            length = The number of units in the $(D TickDuration).
+      +/
+    static TickDuration from(string units)(long length) @safe pure nothrow @nogc
+        if(units == "seconds" ||
+           units == "msecs" ||
+           units == "usecs" ||
+           units == "hnsecs" ||
+           units == "nsecs")
+    {
+        enum unitsPerSec = convert!("seconds", units)(1);
+
+        return TickDuration(cast(long)(length * (ticksPerSec / cast(real)unitsPerSec)));
+    }
+
+    unittest
+    {
+        foreach(units; _TypeTuple!("seconds", "msecs", "usecs", "nsecs"))
+        {
+            foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+            {
+                assertApprox((cast(T)TickDuration.from!units(1000)).to!(units, long)(),
+                             500, 1500, units);
+                assertApprox((cast(T)TickDuration.from!units(1_000_000)).to!(units, long)(),
+                             900_000, 1_100_000, units);
+                assertApprox((cast(T)TickDuration.from!units(2_000_000)).to!(units, long)(),
+                             1_900_000, 2_100_000, units);
+            }
+        }
+    }
+
+
+    /++
+        Returns a $(LREF Duration) with the same number of hnsecs as this
+        $(D TickDuration).
+        Note that the conventional way to convert between $(D TickDuration)
+        and $(D Duration) is using $(XREF conv, to), e.g.:
+        $(D tickDuration.to!Duration())
+      +/
+    Duration opCast(T)() @safe const pure nothrow @nogc
+        if(is(_Unqual!T == Duration))
+    {
+        return Duration(hnsecs);
+    }
+
+    unittest
+    {
+        foreach(D; _TypeTuple!(Duration, const Duration, immutable Duration))
+        {
+            foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+            {
+                auto expected = dur!"seconds"(1);
+                assert(cast(D)cast(T)TickDuration.from!"seconds"(1) == expected);
+
+                foreach(units; _TypeTuple!("msecs", "usecs", "hnsecs"))
+                {
+                    D actual = cast(D)cast(T)TickDuration.from!units(1_000_000);
+                    assertApprox(actual, dur!units(900_000), dur!units(1_100_000));
+                }
+            }
+        }
+    }
+
+
+    //Temporary hack until bug http://d.puremagic.com/issues/show_bug.cgi?id=5747 is fixed.
+    TickDuration opCast(T)() @safe const pure nothrow @nogc
+        if(is(_Unqual!T == TickDuration))
+    {
+        return this;
+    }
+
+
+    /++
+        Adds or subtracts two $(D TickDuration)s as well as assigning the result
+        to this $(D TickDuration).
+
+        The legal types of arithmetic for $(D TickDuration) using this operator
+        are
+
+        $(TABLE
+        $(TR $(TD TickDuration) $(TD +=) $(TD TickDuration) $(TD -->) $(TD TickDuration))
+        $(TR $(TD TickDuration) $(TD -=) $(TD TickDuration) $(TD -->) $(TD TickDuration))
+        )
+
+        Params:
+            rhs = The $(D TickDuration) to add to or subtract from this
+                  $(D $(D TickDuration)).
+      +/
+    ref TickDuration opOpAssign(string op)(TickDuration rhs) @safe pure nothrow @nogc
+        if(op == "+" || op == "-")
+    {
+        mixin("length " ~ op ~ "= rhs.length;");
+        return this;
+    }
+
+    unittest
+    {
+        foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+        {
+            auto a = TickDuration.currSystemTick;
+            auto result = a += cast(T)TickDuration.currSystemTick;
+            assert(a == result);
+            assert(a.to!("seconds", real)() >= 0);
+
+            auto b = TickDuration.currSystemTick;
+            result = b -= cast(T)TickDuration.currSystemTick;
+            assert(b == result);
+            assert(b.to!("seconds", real)() <= 0);
+
+            foreach(U; _TypeTuple!(const TickDuration, immutable TickDuration))
+            {
+                U u = TickDuration(12);
+                static assert(!__traits(compiles, u += cast(T)TickDuration.currSystemTick));
+                static assert(!__traits(compiles, u -= cast(T)TickDuration.currSystemTick));
+            }
+        }
+    }
+
+
+    /++
+        Adds or subtracts two $(D TickDuration)s.
+
+        The legal types of arithmetic for $(D TickDuration) using this operator
+        are
+
+        $(TABLE
+        $(TR $(TD TickDuration) $(TD +) $(TD TickDuration) $(TD -->) $(TD TickDuration))
+        $(TR $(TD TickDuration) $(TD -) $(TD TickDuration) $(TD -->) $(TD TickDuration))
+        )
+
+        Params:
+            rhs = The $(D TickDuration) to add to or subtract from this
+                  $(D TickDuration).
+      +/
+    TickDuration opBinary(string op)(TickDuration rhs) @safe const pure nothrow @nogc
+        if(op == "+" || op == "-")
+    {
+        return TickDuration(mixin("length " ~ op ~ " rhs.length"));
+    }
+
+    unittest
+    {
+        foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+        {
+            T a = TickDuration.currSystemTick;
+            T b = TickDuration.currSystemTick;
+            assert((a + b).seconds > 0);
+            assert((a - b).seconds <= 0);
+        }
+    }
+
+
+    /++
+        Returns the negation of this $(D TickDuration).
+      +/
+    TickDuration opUnary(string op)() @safe const pure nothrow @nogc
+        if(op == "-")
+    {
+        return TickDuration(-length);
+    }
+
+    unittest
+    {
+        foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+        {
+            assert(-(cast(T)TickDuration(7)) == TickDuration(-7));
+            assert(-(cast(T)TickDuration(5)) == TickDuration(-5));
+            assert(-(cast(T)TickDuration(-7)) == TickDuration(7));
+            assert(-(cast(T)TickDuration(-5)) == TickDuration(5));
+            assert(-(cast(T)TickDuration(0)) == TickDuration(0));
+        }
+    }
+
+
+    /++
+       operator overloading "<, >, <=, >="
+      +/
+    int opCmp(TickDuration rhs) @safe const pure nothrow @nogc
+    {
+        return length < rhs.length ? -1 : (length == rhs.length ? 0 : 1);
+    }
+
+    unittest
+    {
+        foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+        {
+            foreach(U; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+            {
+                T t = TickDuration.currSystemTick;
+                U u = t;
+                assert(t == u);
+                assert(copy(t) == u);
+                assert(t == copy(u));
+            }
+        }
+
+        foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+        {
+            foreach(U; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+            {
+                T t = TickDuration.currSystemTick;
+                U u = t + t;
+                assert(t < u);
+                assert(t <= t);
+                assert(u > t);
+                assert(u >= u);
+
+                assert(copy(t) < u);
+                assert(copy(t) <= t);
+                assert(copy(u) > t);
+                assert(copy(u) >= u);
+
+                assert(t < copy(u));
+                assert(t <= copy(t));
+                assert(u > copy(t));
+                assert(u >= copy(u));
+            }
+        }
+    }
+
+
+    /++
+        The legal types of arithmetic for $(D TickDuration) using this operator
+        overload are
+
+        $(TABLE
+        $(TR $(TD TickDuration) $(TD *) $(TD long) $(TD -->) $(TD TickDuration))
+        $(TR $(TD TickDuration) $(TD *) $(TD floating point) $(TD -->) $(TD TickDuration))
+        )
+
+        Params:
+            value = The value to divide from this duration.
+      +/
+    void opOpAssign(string op, T)(T value) @safe pure nothrow @nogc
+        if(op == "*" &&
+           (__traits(isIntegral, T) || __traits(isFloating, T)))
+    {
+        length = cast(long)(length * value);
+    }
+
+    unittest
+    {
+        immutable curr = TickDuration.currSystemTick;
+        TickDuration t1 = curr;
+        immutable t2 = curr + curr;
+        t1 *= 2;
+        assert(t1 == t2);
+
+        t1 = curr;
+        t1 *= 2.0;
+        immutable tol = TickDuration(cast(long)(_abs(t1.length) * double.epsilon * 2.0));
+        assertApprox(t1, t2 - tol, t2 + tol);
+
+        t1 = curr;
+        t1 *= 2.1;
+        assert(t1 > t2);
+
+        foreach(T; _TypeTuple!(const TickDuration, immutable TickDuration))
+        {
+            T t = TickDuration.currSystemTick;
+            assert(!__traits(compiles, t *= 12));
+            assert(!__traits(compiles, t *= 12.0));
+        }
+    }
+
+
+    /++
+        The legal types of arithmetic for $(D TickDuration) using this operator
+        overload are
+
+        $(TABLE
+        $(TR $(TD TickDuration) $(TD /) $(TD long) $(TD -->) $(TD TickDuration))
+        $(TR $(TD TickDuration) $(TD /) $(TD floating point) $(TD -->) $(TD TickDuration))
+        )
+
+        Params:
+            value = The value to divide from this $(D TickDuration).
+
+        Throws:
+            $(D TimeException) if an attempt to divide by $(D 0) is made.
+      +/
+    void opOpAssign(string op, T)(T value) @safe pure
+        if(op == "/" &&
+           (__traits(isIntegral, T) || __traits(isFloating, T)))
+    {
+        if(value == 0)
+            throw new TimeException("Attempted division by 0.");
+
+        length = cast(long)(length / value);
+    }
+
+    unittest
+    {
+        immutable curr = TickDuration.currSystemTick;
+        immutable t1 = curr;
+        TickDuration t2 = curr + curr;
+        t2 /= 2;
+        assert(t1 == t2);
+
+        t2 = curr + curr;
+        t2 /= 2.0;
+        immutable tol = TickDuration(cast(long)(_abs(t2.length) * double.epsilon / 2.0));
+        assertApprox(t1, t2 - tol, t2 + tol);
+
+        t2 = curr + curr;
+        t2 /= 2.1;
+        assert(t1 > t2);
+
+        _assertThrown!TimeException(t2 /= 0);
+
+        foreach(T; _TypeTuple!(const TickDuration, immutable TickDuration))
+        {
+            T t = TickDuration.currSystemTick;
+            assert(!__traits(compiles, t /= 12));
+            assert(!__traits(compiles, t /= 12.0));
+        }
+    }
+
+
+    /++
+        The legal types of arithmetic for $(D TickDuration) using this operator
+        overload are
+
+        $(TABLE
+        $(TR $(TD TickDuration) $(TD *) $(TD long) $(TD -->) $(TD TickDuration))
+        $(TR $(TD TickDuration) $(TD *) $(TD floating point) $(TD -->) $(TD TickDuration))
+        )
+
+        Params:
+            value = The value to divide from this $(D TickDuration).
+      +/
+    TickDuration opBinary(string op, T)(T value) @safe const pure nothrow @nogc
+        if(op == "*" &&
+           (__traits(isIntegral, T) || __traits(isFloating, T)))
+    {
+        return TickDuration(cast(long)(length * value));
+    }
+
+    unittest
+    {
+        foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+        {
+            T t1 = TickDuration.currSystemTick;
+            T t2 = t1 + t1;
+            assert(t1 * 2 == t2);
+            immutable tol = TickDuration(cast(long)(_abs(t1.length) * double.epsilon * 2.0));
+            assertApprox(t1 * 2.0, t2 - tol, t2 + tol);
+            assert(t1 * 2.1 > t2);
+        }
+    }
+
+
+    /++
+        The legal types of arithmetic for $(D TickDuration) using this operator
+        overload are
+
+        $(TABLE
+        $(TR $(TD TickDuration) $(TD /) $(TD long) $(TD -->) $(TD TickDuration))
+        $(TR $(TD TickDuration) $(TD /) $(TD floating point) $(TD -->) $(TD TickDuration))
+        )
+
+        Params:
+            value = The value to divide from this $(D TickDuration).
+
+        Throws:
+            $(D TimeException) if an attempt to divide by $(D 0) is made.
+      +/
+    TickDuration opBinary(string op, T)(T value) @safe const pure
+        if(op == "/" &&
+           (__traits(isIntegral, T) || __traits(isFloating, T)))
+    {
+        if(value == 0)
+            throw new TimeException("Attempted division by 0.");
+
+        return TickDuration(cast(long)(length / value));
+    }
+
+    unittest
+    {
+        foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
+        {
+            T t1 = TickDuration.currSystemTick;
+            T t2 = t1 + t1;
+            assert(t2 / 2 == t1);
+            immutable tol = TickDuration(cast(long)(_abs(t2.length) * double.epsilon / 2.0));
+            assertApprox(t2 / 2.0, t1 - tol, t1 + tol);
+            assert(t2 / 2.1 < t1);
+
+            _assertThrown!TimeException(t2 / 0);
+        }
+    }
+
+
+    /++
+        Params:
+            ticks = The number of ticks in the TickDuration.
+      +/
+    @safe pure nothrow @nogc this(long ticks)
+    {
+        this.length = ticks;
+    }
+
+    unittest
+    {
+        foreach(i; [-42, 0, 42])
+            assert(TickDuration(i).length == i);
+    }
+
+
+    /++
+        The current system tick. The number of ticks per second varies from
+        system to system. $(D currSystemTick) uses a monotonic clock, so it's
+        intended for precision timing by comparing relative time values, not for
+        getting the current system time.
+
+        On Windows, $(D QueryPerformanceCounter) is used. On Mac OS X,
+        $(D mach_absolute_time) is used, while on other Posix systems,
+        $(D clock_gettime) is used. If $(D mach_absolute_time) or
+        $(D clock_gettime) is unavailable, then Posix systems use
+        $(D gettimeofday) (the decision is made when $(D TickDuration) is
+        compiled), which unfortunately, is not monotonic, but if
+        $(D mach_absolute_time) and $(D clock_gettime) aren't available, then
+        $(D gettimeofday) is the the best that there is.
+
+        $(RED Warning):
+            On some systems, the monotonic clock may stop counting when
+            the computer goes to sleep or hibernates. So, the monotonic
+            clock could be off if that occurs. This is known to happen
+            on Mac OS X. It has not been tested whether it occurs on
+            either Windows or on Linux.
+
+        Throws:
+            $(D TimeException) if it fails to get the time.
+      +/
+    static @property TickDuration currSystemTick() @trusted nothrow @nogc
+    {
+        import core.internal.abort : abort;
+        version(Windows)
+        {
+            ulong ticks;
+            if(QueryPerformanceCounter(cast(long*)&ticks) == 0)
+                abort("Failed in QueryPerformanceCounter().");
+
+            return TickDuration(ticks);
+        }
+        else version(OSX)
+        {
+            static if(is(typeof(mach_absolute_time)))
+                return TickDuration(cast(long)mach_absolute_time());
+            else
+            {
+                timeval tv;
+                if(gettimeofday(&tv, null) != 0)
+                    abort("Failed in gettimeofday().");
+
+                return TickDuration(tv.tv_sec * TickDuration.ticksPerSec +
+                                    tv.tv_usec * TickDuration.ticksPerSec / 1000 / 1000);
+            }
+        }
+        else version(Posix)
+        {
+            static if(is(typeof(clock_gettime)))
+            {
+                timespec ts;
+                if(clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
+                    abort("Failed in clock_gettime().");
+
+                return TickDuration(ts.tv_sec * TickDuration.ticksPerSec +
+                                    ts.tv_nsec * TickDuration.ticksPerSec / 1000 / 1000 / 1000);
+            }
+            else
+            {
+                timeval tv;
+                if(gettimeofday(&tv, null) != 0)
+                    abort("Failed in gettimeofday().");
+
+                return TickDuration(tv.tv_sec * TickDuration.ticksPerSec +
+                                    tv.tv_usec * TickDuration.ticksPerSec / 1000 / 1000);
+            }
+        }
+    }
+
+    @safe nothrow unittest
+    {
+        assert(TickDuration.currSystemTick.length > 0);
+    }
+}
+
+
+/++
+    Generic way of converting between two time units. Conversions to smaller
+    units use truncating division. Years and months can be converted to each
+    other, small units can be converted to each other, but years and months
+    cannot be converted to or from smaller units (due to the varying number
+    of days in a month or year).
+
+    Params:
+        from  = The units of time to convert from.
+        to    = The units of time to convert to.
+        value = The value to convert.
+  +/
+long convert(string from, string to)(long value) @safe pure nothrow @nogc
+    if(((from == "weeks" ||
+         from == "days" ||
+         from == "hours" ||
+         from == "minutes" ||
+         from == "seconds" ||
+         from == "msecs" ||
+         from == "usecs" ||
+         from == "hnsecs" ||
+         from == "nsecs") &&
+        (to == "weeks" ||
+         to == "days" ||
+         to == "hours" ||
+         to == "minutes" ||
+         to == "seconds" ||
+         to == "msecs" ||
+         to == "usecs" ||
+         to == "hnsecs" ||
+         to == "nsecs")) ||
+       ((from == "years" || from == "months") && (to == "years" || to == "months")))
+{
+    static if(from == "years")
+    {
+        static if(to == "years")
+            return value;
+        else static if(to == "months")
+            return value * 12;
+        else
+            static assert(0, "A generic month or year cannot be converted to or from smaller units.");
+    }
+    else static if(from == "months")
+    {
+        static if(to == "years")
+            return value / 12;
+        else static if(to == "months")
+            return value;
+        else
+            static assert(0, "A generic month or year cannot be converted to or from smaller units.");
+    }
+    else static if(from == "nsecs" && to == "nsecs")
+        return value;
+    else static if(from == "nsecs")
+        return convert!("hnsecs", to)(value / 100);
+    else static if(to == "nsecs")
+        return convert!(from, "hnsecs")(value) * 100;
+    else
+        return (hnsecsPer!from * value) / hnsecsPer!to;
+}
+
+///
+unittest
+{
+    assert(convert!("years", "months")(1) == 12);
+    assert(convert!("months", "years")(12) == 1);
+
+    assert(convert!("weeks", "days")(1) == 7);
+    assert(convert!("hours", "seconds")(1) == 3600);
+    assert(convert!("seconds", "days")(1) == 0);
+    assert(convert!("seconds", "days")(86_400) == 1);
+
+    assert(convert!("nsecs", "nsecs")(1) == 1);
+    assert(convert!("nsecs", "hnsecs")(1) == 0);
+    assert(convert!("hnsecs", "nsecs")(1) == 100);
+    assert(convert!("nsecs", "seconds")(1) == 0);
+    assert(convert!("seconds", "nsecs")(1) == 1_000_000_000);
+}
+
+unittest
+{
+    foreach(units; _TypeTuple!("weeks", "days", "hours", "seconds", "msecs", "usecs", "hnsecs", "nsecs"))
+    {
+        static assert(!__traits(compiles, convert!("years", units)(12)), units);
+        static assert(!__traits(compiles, convert!(units, "years")(12)), units);
+    }
+
+    foreach(units; _TypeTuple!("years", "months", "weeks", "days",
+                               "hours", "seconds", "msecs", "usecs", "hnsecs", "nsecs"))
+    {
+        assert(convert!(units, units)(12) == 12);
+    }
+
+    assert(convert!("weeks", "hnsecs")(1) == 6_048_000_000_000L);
+    assert(convert!("days", "hnsecs")(1) == 864_000_000_000L);
+    assert(convert!("hours", "hnsecs")(1) == 36_000_000_000L);
+    assert(convert!("minutes", "hnsecs")(1) == 600_000_000L);
+    assert(convert!("seconds", "hnsecs")(1) == 10_000_000L);
+    assert(convert!("msecs", "hnsecs")(1) == 10_000);
+    assert(convert!("usecs", "hnsecs")(1) == 10);
+
+    assert(convert!("hnsecs", "weeks")(6_048_000_000_000L) == 1);
+    assert(convert!("hnsecs", "days")(864_000_000_000L) == 1);
+    assert(convert!("hnsecs", "hours")(36_000_000_000L) == 1);
+    assert(convert!("hnsecs", "minutes")(600_000_000L) == 1);
+    assert(convert!("hnsecs", "seconds")(10_000_000L) == 1);
+    assert(convert!("hnsecs", "msecs")(10_000) == 1);
+    assert(convert!("hnsecs", "usecs")(10) == 1);
+
+    assert(convert!("weeks", "days")(1) == 7);
+    assert(convert!("days", "weeks")(7) == 1);
+
+    assert(convert!("days", "hours")(1) == 24);
+    assert(convert!("hours", "days")(24) == 1);
+
+    assert(convert!("hours", "minutes")(1) == 60);
+    assert(convert!("minutes", "hours")(60) == 1);
+
+    assert(convert!("minutes", "seconds")(1) == 60);
+    assert(convert!("seconds", "minutes")(60) == 1);
+
+    assert(convert!("seconds", "msecs")(1) == 1000);
+    assert(convert!("msecs", "seconds")(1000) == 1);
+
+    assert(convert!("msecs", "usecs")(1) == 1000);
+    assert(convert!("usecs", "msecs")(1000) == 1);
+
+    assert(convert!("usecs", "hnsecs")(1) == 10);
+    assert(convert!("hnsecs", "usecs")(10) == 1);
+
+    assert(convert!("weeks", "nsecs")(1) == 604_800_000_000_000L);
+    assert(convert!("days", "nsecs")(1) == 86_400_000_000_000L);
+    assert(convert!("hours", "nsecs")(1) == 3_600_000_000_000L);
+    assert(convert!("minutes", "nsecs")(1) == 60_000_000_000L);
+    assert(convert!("seconds", "nsecs")(1) == 1_000_000_000L);
+    assert(convert!("msecs", "nsecs")(1) == 1_000_000);
+    assert(convert!("usecs", "nsecs")(1) == 1000);
+    assert(convert!("hnsecs", "nsecs")(1) == 100);
+
+    assert(convert!("nsecs", "weeks")(604_800_000_000_000L) == 1);
+    assert(convert!("nsecs", "days")(86_400_000_000_000L) == 1);
+    assert(convert!("nsecs", "hours")(3_600_000_000_000L) == 1);
+    assert(convert!("nsecs", "minutes")(60_000_000_000L) == 1);
+    assert(convert!("nsecs", "seconds")(1_000_000_000L) == 1);
+    assert(convert!("nsecs", "msecs")(1_000_000) == 1);
+    assert(convert!("nsecs", "usecs")(1000) == 1);
+    assert(convert!("nsecs", "hnsecs")(100) == 1);
+}
+
+
+/++
+    Represents fractional seconds.
+
+    This is the portion of the time which is smaller than a second and it cannot
+    hold values which would be greater than or equal to a second (or less than
+    or equal to a negative second).
+
+    It holds hnsecs internally, but you can create it using either milliseconds,
+    microseconds, or hnsecs. What it does is allow for a simple way to set or
+    adjust the fractional seconds portion of a $(D Duration) or a
+    $(XREF datetime, SysTime) without having to worry about whether you're
+    dealing with milliseconds, microseconds, or hnsecs.
+
+    $(D FracSec)'s functions which take time unit strings do accept
+    $(D "nsecs"), but because the resolution of $(D Duration) and
+    $(XREF datetime, SysTime) is hnsecs, you don't actually get precision higher
+    than hnsecs. $(D "nsecs") is accepted merely for convenience. Any values
+    given as nsecs will be converted to hnsecs using $(D convert) (which uses
+    truncating division when converting to smaller units).
+  +/
+struct FracSec
+{
+@safe pure:
+
+public:
+
+    /++
+        A $(D FracSec) of $(D 0). It's shorter than doing something like
+        $(D FracSec.from!"msecs"(0)) and more explicit than $(D FracSec.init).
+      +/
+    static @property nothrow @nogc FracSec zero() { return FracSec(0); }
+
+    unittest
+    {
+        assert(zero == FracSec.from!"msecs"(0));
+    }
+
+
+    /++
+        Create a $(D FracSec) from the given units ($(D "msecs"), $(D "usecs"),
+        or $(D "hnsecs")).
+
+        Params:
+            units = The units to create a FracSec from.
+            value = The number of the given units passed the second.
+
+        Throws:
+            $(D TimeException) if the given value would result in a $(D FracSec)
+            greater than or equal to $(D 1) second or less than or equal to
+            $(D -1) seconds.
+      +/
+    static FracSec from(string units)(long value)
+        if(units == "msecs" ||
+           units == "usecs" ||
+           units == "hnsecs" ||
+           units == "nsecs")
+    {
+        immutable hnsecs = cast(int)convert!(units, "hnsecs")(value);
+        _enforceValid(hnsecs);
+        return FracSec(hnsecs);
+    }
+
+    unittest
+    {
+        assert(FracSec.from!"msecs"(0) == FracSec(0));
+        assert(FracSec.from!"usecs"(0) == FracSec(0));
+        assert(FracSec.from!"hnsecs"(0) == FracSec(0));
+
+        foreach(sign; [1, -1])
+        {
+            _assertThrown!TimeException(from!"msecs"(1000 * sign));
+
+            assert(FracSec.from!"msecs"(1 * sign) == FracSec(10_000 * sign));
+            assert(FracSec.from!"msecs"(999 * sign) == FracSec(9_990_000 * sign));
+
+            _assertThrown!TimeException(from!"usecs"(1_000_000 * sign));
+
+            assert(FracSec.from!"usecs"(1 * sign) == FracSec(10 * sign));
+            assert(FracSec.from!"usecs"(999 * sign) == FracSec(9990 * sign));
+            assert(FracSec.from!"usecs"(999_999 * sign) == FracSec(9999_990 * sign));
+
+            _assertThrown!TimeException(from!"hnsecs"(10_000_000 * sign));
+
+            assert(FracSec.from!"hnsecs"(1 * sign) == FracSec(1 * sign));
+            assert(FracSec.from!"hnsecs"(999 * sign) == FracSec(999 * sign));
+            assert(FracSec.from!"hnsecs"(999_999 * sign) == FracSec(999_999 * sign));
+            assert(FracSec.from!"hnsecs"(9_999_999 * sign) == FracSec(9_999_999 * sign));
+
+            assert(FracSec.from!"nsecs"(1 * sign) == FracSec(0));
+            assert(FracSec.from!"nsecs"(10 * sign) == FracSec(0));
+            assert(FracSec.from!"nsecs"(99 * sign) == FracSec(0));
+            assert(FracSec.from!"nsecs"(100 * sign) == FracSec(1 * sign));
+            assert(FracSec.from!"nsecs"(99_999 * sign) == FracSec(999 * sign));
+            assert(FracSec.from!"nsecs"(99_999_999 * sign) == FracSec(999_999 * sign));
+            assert(FracSec.from!"nsecs"(999_999_999 * sign) == FracSec(9_999_999 * sign));
+        }
+    }
+
+
+    /++
+        Returns the negation of this $(D FracSec).
+      +/
+    FracSec opUnary(string op)() const nothrow @nogc
+        if(op == "-")
+    {
+        return FracSec(-_hnsecs);
+    }
+
+    unittest
+    {
+        foreach(val; [-7, -5, 0, 5, 7])
+        {
+            foreach(F; _TypeTuple!(FracSec, const FracSec, immutable FracSec))
+            {
+                F fs = FracSec(val);
+                assert(-fs == FracSec(-val));
+            }
+        }
+    }
+
+
+    /++
+        The value of this $(D FracSec) as milliseconds.
+      +/
+    @property int msecs() const nothrow @nogc
+    {
+        return cast(int)convert!("hnsecs", "msecs")(_hnsecs);
+    }
+
+    unittest
+    {
+        foreach(F; _TypeTuple!(FracSec, const FracSec, immutable FracSec))
+        {
+            assert(FracSec(0).msecs == 0);
+
+            foreach(sign; [1, -1])
+            {
+                assert((cast(F)FracSec(1 * sign)).msecs == 0);
+                assert((cast(F)FracSec(999 * sign)).msecs == 0);
+                assert((cast(F)FracSec(999_999 * sign)).msecs == 99 * sign);
+                assert((cast(F)FracSec(9_999_999 * sign)).msecs == 999 * sign);
+            }
+        }
+    }
+
+
+    /++
+        The value of this $(D FracSec) as milliseconds.
+
+        Params:
+            milliseconds = The number of milliseconds passed the second.
+
+        Throws:
+            $(D TimeException) if the given value is not less than $(D 1) second
+            and greater than a $(D -1) seconds.
+      +/
+    @property void msecs(int milliseconds)
+    {
+        immutable hnsecs = cast(int)convert!("msecs", "hnsecs")(milliseconds);
+        _enforceValid(hnsecs);
+        _hnsecs = hnsecs;
+    }
+
+    unittest
+    {
+        static void test(int msecs, FracSec expected = FracSec.init, size_t line = __LINE__)
+        {
+            FracSec fs;
+            fs.msecs = msecs;
+
+            if(fs != expected)
+                throw new AssertError("unittest failure", __FILE__, line);
+        }
+
+        _assertThrown!TimeException(test(-1000));
+        _assertThrown!TimeException(test(1000));
+
+        test(0, FracSec(0));
+
+        foreach(sign; [1, -1])
+        {
+            test(1 * sign, FracSec(10_000 * sign));
+            test(999 * sign, FracSec(9_990_000 * sign));
+        }
+
+        foreach(F; _TypeTuple!(const FracSec, immutable FracSec))
+        {
+            F fs = FracSec(1234567);
+            static assert(!__traits(compiles, fs.msecs = 12), F.stringof);
+        }
+    }
+
+
+    /++
+        The value of this $(D FracSec) as microseconds.
+      +/
+    @property int usecs() const nothrow @nogc
+    {
+        return cast(int)convert!("hnsecs", "usecs")(_hnsecs);
+    }
+
+    unittest
+    {
+        foreach(F; _TypeTuple!(FracSec, const FracSec, immutable FracSec))
+        {
+            assert(FracSec(0).usecs == 0);
+
+            foreach(sign; [1, -1])
+            {
+                assert((cast(F)FracSec(1 * sign)).usecs == 0);
+                assert((cast(F)FracSec(999 * sign)).usecs == 99 * sign);
+                assert((cast(F)FracSec(999_999 * sign)).usecs == 99_999 * sign);
+                assert((cast(F)FracSec(9_999_999 * sign)).usecs == 999_999 * sign);
+            }
+        }
+    }
+
+
+    /++
+        The value of this $(D FracSec) as microseconds.
+
+        Params:
+            microseconds = The number of microseconds passed the second.
+
+        Throws:
+            $(D TimeException) if the given value is not less than $(D 1) second
+            and greater than a $(D -1) seconds.
+      +/
+    @property void usecs(int microseconds)
+    {
+        immutable hnsecs = cast(int)convert!("usecs", "hnsecs")(microseconds);
+        _enforceValid(hnsecs);
+        _hnsecs = hnsecs;
+    }
+
+    unittest
+    {
+        static void test(int usecs, FracSec expected = FracSec.init, size_t line = __LINE__)
+        {
+            FracSec fs;
+            fs.usecs = usecs;
+
+            if(fs != expected)
+                throw new AssertError("unittest failure", __FILE__, line);
+        }
+
+        _assertThrown!TimeException(test(-1_000_000));
+        _assertThrown!TimeException(test(1_000_000));
+
+        test(0, FracSec(0));
+
+        foreach(sign; [1, -1])
+        {
+            test(1 * sign, FracSec(10 * sign));
+            test(999 * sign, FracSec(9990 * sign));
+            test(999_999 * sign, FracSec(9_999_990 * sign));
+        }
+
+        foreach(F; _TypeTuple!(const FracSec, immutable FracSec))
+        {
+            F fs = FracSec(1234567);
+            static assert(!__traits(compiles, fs.usecs = 12), F.stringof);
+        }
+    }
+
+
+    /++
+        The value of this $(D FracSec) as hnsecs.
+      +/
+    @property int hnsecs() const nothrow @nogc
+    {
+        return _hnsecs;
+    }
+
+    unittest
+    {
+        foreach(F; _TypeTuple!(FracSec, const FracSec, immutable FracSec))
+        {
+            assert(FracSec(0).hnsecs == 0);
+
+            foreach(sign; [1, -1])
+            {
+                assert((cast(F)FracSec(1 * sign)).hnsecs == 1 * sign);
+                assert((cast(F)FracSec(999 * sign)).hnsecs == 999 * sign);
+                assert((cast(F)FracSec(999_999 * sign)).hnsecs == 999_999 * sign);
+                assert((cast(F)FracSec(9_999_999 * sign)).hnsecs == 9_999_999 * sign);
+            }
+        }
+    }
+
+
+    /++
+        The value of this $(D FracSec) as hnsecs.
+
+        Params:
+            hnsecs = The number of hnsecs passed the second.
+
+        Throws:
+            $(D TimeException) if the given value is not less than $(D 1) second
+            and greater than a $(D -1) seconds.
+      +/
+    @property void hnsecs(int hnsecs)
+    {
+        _enforceValid(hnsecs);
+        _hnsecs = hnsecs;
+    }
+
+    unittest
+    {
+        static void test(int hnsecs, FracSec expected = FracSec.init, size_t line = __LINE__)
+        {
+            FracSec fs;
+            fs.hnsecs = hnsecs;
+
+            if(fs != expected)
+                throw new AssertError("unittest failure", __FILE__, line);
+        }
+
+        _assertThrown!TimeException(test(-10_000_000));
+        _assertThrown!TimeException(test(10_000_000));
+
+        test(0, FracSec(0));
+
+        foreach(sign; [1, -1])
+        {
+            test(1 * sign, FracSec(1 * sign));
+            test(999 * sign, FracSec(999 * sign));
+            test(999_999 * sign, FracSec(999_999 * sign));
+            test(9_999_999 * sign, FracSec(9_999_999 * sign));
+        }
+
+        foreach(F; _TypeTuple!(const FracSec, immutable FracSec))
+        {
+            F fs = FracSec(1234567);
+            static assert(!__traits(compiles, fs.hnsecs = 12), F.stringof);
+        }
+    }
+
+
+    /++
+        The value of this $(D FracSec) as nsecs.
+
+        Note that this does not give you any greater precision
+        than getting the value of this $(D FracSec) as hnsecs.
+      +/
+    @property int nsecs() const nothrow @nogc
+    {
+        return cast(int)convert!("hnsecs", "nsecs")(_hnsecs);
+    }
+
+    unittest
+    {
+        foreach(F; _TypeTuple!(FracSec, const FracSec, immutable FracSec))
+        {
+            assert(FracSec(0).nsecs == 0);
+
+            foreach(sign; [1, -1])
+            {
+                assert((cast(F)FracSec(1 * sign)).nsecs == 100 * sign);
+                assert((cast(F)FracSec(999 * sign)).nsecs == 99_900 * sign);
+                assert((cast(F)FracSec(999_999 * sign)).nsecs == 99_999_900 * sign);
+                assert((cast(F)FracSec(9_999_999 * sign)).nsecs == 999_999_900 * sign);
+            }
+        }
+    }
+
+
+    /++
+        The value of this $(D FracSec) as nsecs.
+
+        Note that this does not give you any greater precision
+        than setting the value of this $(D FracSec) as hnsecs.
+
+        Params:
+            nsecs = The number of nsecs passed the second.
+
+        Throws:
+            $(D TimeException) if the given value is not less than $(D 1) second
+            and greater than a $(D -1) seconds.
+      +/
+    @property void nsecs(long nsecs)
+    {
+        immutable hnsecs = cast(int)convert!("nsecs", "hnsecs")(nsecs);
+        _enforceValid(hnsecs);
+        _hnsecs = hnsecs;
+    }
+
+    unittest
+    {
+        static void test(int nsecs, FracSec expected = FracSec.init, size_t line = __LINE__)
+        {
+            FracSec fs;
+            fs.nsecs = nsecs;
+
+            if(fs != expected)
+                throw new AssertError("unittest failure", __FILE__, line);
+        }
+
+        _assertThrown!TimeException(test(-1_000_000_000));
+        _assertThrown!TimeException(test(1_000_000_000));
+
+        test(0, FracSec(0));
+
+        foreach(sign; [1, -1])
+        {
+            test(1 * sign, FracSec(0));
+            test(10 * sign, FracSec(0));
+            test(100 * sign, FracSec(1 * sign));
+            test(999 * sign, FracSec(9 * sign));
+            test(999_999 * sign, FracSec(9999 * sign));
+            test(9_999_999 * sign, FracSec(99_999 * sign));
+        }
+
+        foreach(F; _TypeTuple!(const FracSec, immutable FracSec))
+        {
+            F fs = FracSec(1234567);
+            static assert(!__traits(compiles, fs.nsecs = 12), F.stringof);
+        }
+    }
+
+
+    /+
+        Converts this $(D TickDuration) to a string.
+      +/
+    //Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
+    //have versions of toString() with extra modifiers, so we define one version
+    //with modifiers and one without.
+    string toString()
+    {
+        return _toStringImpl();
+    }
+
+
+    /++
+        Converts this $(D TickDuration) to a string.
+      +/
+    //Due to bug http://d.puremagic.com/issues/show_bug.cgi?id=3715 , we can't
+    //have versions of toString() with extra modifiers, so we define one version
+    //with modifiers and one without.
+    string toString() const nothrow
+    {
+        return _toStringImpl();
+    }
+
+    unittest
+    {
+        auto fs = FracSec(12);
+        const cfs = FracSec(12);
+        immutable ifs = FracSec(12);
+        assert(fs.toString() == "12 hnsecs");
+        assert(cfs.toString() == "12 hnsecs");
+        assert(ifs.toString() == "12 hnsecs");
+    }
+
+
+private:
+
+    /+
+        Since we have two versions of $(D toString), we have $(D _toStringImpl)
+        so that they can share implementations.
+      +/
+    string _toStringImpl() const nothrow
+    {
+        long hnsecs = _hnsecs;
+
+        immutable milliseconds = splitUnitsFromHNSecs!"msecs"(hnsecs);
+        immutable microseconds = splitUnitsFromHNSecs!"usecs"(hnsecs);
+
+        if(hnsecs == 0)
+        {
+            if(microseconds == 0)
+            {
+                if(milliseconds == 0)
+                    return "0 hnsecs";
+                else
+                {
+                    if(milliseconds == 1)
+                        return "1 ms";
+                    else
+                    {
+                        auto r = signedToTempString(milliseconds, 10).idup;
+                        r ~= " ms";
+                        return r;
+                    }
+                }
+            }
+            else
+            {
+                immutable fullMicroseconds = getUnitsFromHNSecs!"usecs"(_hnsecs);
+
+                if(fullMicroseconds == 1)
+                    return "1 μs";
+                else
+                {
+                    auto r = signedToTempString(fullMicroseconds, 10).idup;
+                    r ~= " μs";
+                    return r;
+                }
+            }
+        }
+        else
+        {
+            if(_hnsecs == 1)
+                return "1 hnsec";
+            else
+            {
+                auto r = signedToTempString(_hnsecs, 10).idup;
+                r ~= " hnsecs";
+                return r;
+            }
+        }
+    }
+
+    unittest
+    {
+        foreach(sign; [1 , -1])
+        {
+            immutable signStr = sign == 1 ? "" : "-";
+
+            assert(FracSec.from!"msecs"(0 * sign).toString() == "0 hnsecs");
+            assert(FracSec.from!"msecs"(1 * sign).toString() == signStr ~ "1 ms");
+            assert(FracSec.from!"msecs"(2 * sign).toString() == signStr ~ "2 ms");
+            assert(FracSec.from!"msecs"(100 * sign).toString() == signStr ~ "100 ms");
+            assert(FracSec.from!"msecs"(999 * sign).toString() == signStr ~ "999 ms");
+
+            assert(FracSec.from!"usecs"(0* sign).toString() == "0 hnsecs");
+            assert(FracSec.from!"usecs"(1* sign).toString() == signStr ~ "1 μs");
+            assert(FracSec.from!"usecs"(2* sign).toString() == signStr ~ "2 μs");
+            assert(FracSec.from!"usecs"(100* sign).toString() == signStr ~ "100 μs");
+            assert(FracSec.from!"usecs"(999* sign).toString() == signStr ~ "999 μs");
+            assert(FracSec.from!"usecs"(1000* sign).toString() == signStr ~ "1 ms");
+            assert(FracSec.from!"usecs"(2000* sign).toString() == signStr ~ "2 ms");
+            assert(FracSec.from!"usecs"(9999* sign).toString() == signStr ~ "9999 μs");
+            assert(FracSec.from!"usecs"(10_000* sign).toString() == signStr ~ "10 ms");
+            assert(FracSec.from!"usecs"(20_000* sign).toString() == signStr ~ "20 ms");
+            assert(FracSec.from!"usecs"(100_000* sign).toString() == signStr ~ "100 ms");
+            assert(FracSec.from!"usecs"(100_001* sign).toString() == signStr ~ "100001 μs");
+            assert(FracSec.from!"usecs"(999_999* sign).toString() == signStr ~ "999999 μs");
+
+            assert(FracSec.from!"hnsecs"(0* sign).toString() == "0 hnsecs");
+            assert(FracSec.from!"hnsecs"(1* sign).toString() == (sign == 1 ? "1 hnsec" : "-1 hnsecs"));
+            assert(FracSec.from!"hnsecs"(2* sign).toString() == signStr ~ "2 hnsecs");
+            assert(FracSec.from!"hnsecs"(100* sign).toString() == signStr ~ "10 μs");
+            assert(FracSec.from!"hnsecs"(999* sign).toString() == signStr ~ "999 hnsecs");
+            assert(FracSec.from!"hnsecs"(1000* sign).toString() == signStr ~ "100 μs");
+            assert(FracSec.from!"hnsecs"(2000* sign).toString() == signStr ~ "200 μs");
+            assert(FracSec.from!"hnsecs"(9999* sign).toString() == signStr ~ "9999 hnsecs");
+            assert(FracSec.from!"hnsecs"(10_000* sign).toString() == signStr ~ "1 ms");
+            assert(FracSec.from!"hnsecs"(20_000* sign).toString() == signStr ~ "2 ms");
+            assert(FracSec.from!"hnsecs"(100_000* sign).toString() == signStr ~ "10 ms");
+            assert(FracSec.from!"hnsecs"(100_001* sign).toString() == signStr ~ "100001 hnsecs");
+            assert(FracSec.from!"hnsecs"(200_000* sign).toString() == signStr ~ "20 ms");
+            assert(FracSec.from!"hnsecs"(999_999* sign).toString() == signStr ~ "999999 hnsecs");
+            assert(FracSec.from!"hnsecs"(1_000_001* sign).toString() == signStr ~ "1000001 hnsecs");
+            assert(FracSec.from!"hnsecs"(9_999_999* sign).toString() == signStr ~ "9999999 hnsecs");
+        }
+    }
+
+
+    /+
+        Returns whether the given number of hnsecs fits within the range of
+        $(D FracSec).
+
+        Params:
+            hnsecs = The number of hnsecs.
+      +/
+    static bool _valid(int hnsecs) nothrow @nogc
+    {
+        immutable second = convert!("seconds", "hnsecs")(1);
+        return hnsecs > -second && hnsecs < second;
+    }
+
+
+    /+
+        Throws:
+            $(D TimeException) if $(D valid(hnsecs)) is $(D false).
+      +/
+    static void _enforceValid(int hnsecs)
+    {
+        if(!_valid(hnsecs))
+            throw new TimeException("FracSec must be greater than equal to 0 and less than 1 second.");
+    }
+
+
+    /+
+        Params:
+            hnsecs = The number of hnsecs passed the second.
+      +/
+    this(int hnsecs) nothrow @nogc
+    {
+        _hnsecs = hnsecs;
+    }
+
+
+    invariant()
+    {
+        if(!_valid(_hnsecs))
+            throw new AssertError("Invariant Failure: hnsecs [" ~ signedToTempString(_hnsecs, 10).idup ~ "]", __FILE__, __LINE__);
+    }
+
+
+    int _hnsecs;
+}
+
+
+/++
+    Exception type used by core.time.
+  +/
+class TimeException : Exception
+{
+    /++
+        Params:
+            msg  = The message for the exception.
+            file = The file where the exception occurred.
+            line = The line number where the exception occurred.
+            next = The previous exception in the chain of exceptions, if any.
+      +/
+    this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) @safe pure nothrow
+    {
+        super(msg, file, line, next);
+    }
+
+    /++
+        Params:
+            msg  = The message for the exception.
+            next = The previous exception in the chain of exceptions.
+            file = The file where the exception occurred.
+            line = The line number where the exception occurred.
+      +/
+    this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__) @safe pure nothrow
+    {
+        super(msg, file, line, next);
+    }
+}
+
+unittest
+{
+    {
+        auto e = new TimeException("hello");
+        assert(e.msg == "hello");
+        assert(e.file == __FILE__);
+        assert(e.line == __LINE__ - 3);
+        assert(e.next is null);
+    }
+
+    {
+        auto next = new Exception("foo");
+        auto e = new TimeException("goodbye", next);
+        assert(e.msg == "goodbye");
+        assert(e.file == __FILE__);
+        assert(e.line == __LINE__ - 3);
+        assert(e.next is next);
+    }
+}
+
+
+
+/++
+    Returns the absolute value of a duration.
+  +/
+Duration abs(Duration duration) @safe pure nothrow @nogc
+{
+    return Duration(_abs(duration._hnsecs));
+}
+
+/++ Ditto +/
+TickDuration abs(TickDuration duration) @safe pure nothrow @nogc
+{
+    return TickDuration(_abs(duration.length));
+}
+
+unittest
+{
+    assert(abs(dur!"msecs"(5)) == dur!"msecs"(5));
+    assert(abs(dur!"msecs"(-5)) == dur!"msecs"(5));
+
+    assert(abs(TickDuration(17)) == TickDuration(17));
+    assert(abs(TickDuration(-17)) == TickDuration(17));
+}
+
+
+//==============================================================================
+// Private Section.
+//
+// Much of this is a copy or simplified copy of what's in std.datetime.
+//==============================================================================
+private:
+
+
+/+
+    Template to help with converting between time units.
+ +/
+template hnsecsPer(string units)
+    if(units == "weeks" ||
+       units == "days" ||
+       units == "hours" ||
+       units == "minutes" ||
+       units == "seconds" ||
+       units == "msecs" ||
+       units == "usecs" ||
+       units == "hnsecs")
+{
+    static if(units == "hnsecs")
+        enum hnsecsPer = 1L;
+    else static if(units == "usecs")
+        enum hnsecsPer = 10L;
+    else static if(units == "msecs")
+        enum hnsecsPer = 1000 * hnsecsPer!"usecs";
+    else static if(units == "seconds")
+        enum hnsecsPer = 1000 * hnsecsPer!"msecs";
+    else static if(units == "minutes")
+        enum hnsecsPer = 60 * hnsecsPer!"seconds";
+    else static if(units == "hours")
+        enum hnsecsPer = 60 * hnsecsPer!"minutes";
+    else static if(units == "days")
+        enum hnsecsPer = 24 * hnsecsPer!"hours";
+    else static if(units == "weeks")
+        enum hnsecsPer = 7 * hnsecsPer!"days";
+}
+
+/+
+    Splits out a particular unit from hnsecs and gives you the value for that
+    unit and the remaining hnsecs. It really shouldn't be used unless all units
+    larger than the given units have already been split out.
+
+    Params:
+        units  = The units to split out.
+        hnsecs = The current total hnsecs. Upon returning, it is the hnsecs left
+                 after splitting out the given units.
+
+    Returns:
+        The number of the given units from converting hnsecs to those units.
+  +/
+long splitUnitsFromHNSecs(string units)(ref long hnsecs) @safe pure nothrow @nogc
+    if(units == "weeks" ||
+       units == "days" ||
+       units == "hours" ||
+       units == "minutes" ||
+       units == "seconds" ||
+       units == "msecs" ||
+       units == "usecs" ||
+       units == "hnsecs")
+{
+    immutable value = convert!("hnsecs", units)(hnsecs);
+    hnsecs -= convert!(units, "hnsecs")(value);
+
+    return value;
+}
+
+///
+unittest
+{
+    auto hnsecs = 2595000000007L;
+    immutable days = splitUnitsFromHNSecs!"days"(hnsecs);
+    assert(days == 3);
+    assert(hnsecs == 3000000007);
+
+    immutable minutes = splitUnitsFromHNSecs!"minutes"(hnsecs);
+    assert(minutes == 5);
+    assert(hnsecs == 7);
+}
+
+
+/+
+    This function is used to split out the units without getting the remaining
+    hnsecs.
+
+    See_Also:
+        $(LREF splitUnitsFromHNSecs)
+
+    Params:
+        units  = The units to split out.
+        hnsecs = The current total hnsecs.
+
+    Returns:
+        The split out value.
+  +/
+long getUnitsFromHNSecs(string units)(long hnsecs) @safe pure nothrow @nogc
+    if(units == "weeks" ||
+       units == "days" ||
+       units == "hours" ||
+       units == "minutes" ||
+       units == "seconds" ||
+       units == "msecs" ||
+       units == "usecs" ||
+       units == "hnsecs")
+{
+    return convert!("hnsecs", units)(hnsecs);
+}
+
+///
+unittest
+{
+    auto hnsecs = 2595000000007L;
+    immutable days = getUnitsFromHNSecs!"days"(hnsecs);
+    assert(days == 3);
+    assert(hnsecs == 2595000000007L);
+}
+
+
+/+
+    This function is used to split out the units without getting the units but
+    just the remaining hnsecs.
+
+    See_Also:
+        $(LREF splitUnitsFromHNSecs)
+
+    Params:
+        units  = The units to split out.
+        hnsecs = The current total hnsecs.
+
+    Returns:
+        The remaining hnsecs.
+  +/
+long removeUnitsFromHNSecs(string units)(long hnsecs) @safe pure nothrow @nogc
+    if(units == "weeks" ||
+       units == "days" ||
+       units == "hours" ||
+       units == "minutes" ||
+       units == "seconds" ||
+       units == "msecs" ||
+       units == "usecs" ||
+       units == "hnsecs")
+{
+    immutable value = convert!("hnsecs", units)(hnsecs);
+
+    return hnsecs - convert!(units, "hnsecs")(value);
+}
+
+///
+unittest
+{
+    auto hnsecs = 2595000000007L;
+    auto returned = removeUnitsFromHNSecs!"days"(hnsecs);
+    assert(returned == 3000000007);
+    assert(hnsecs == 2595000000007L);
+}
+
+
+/+
+    Whether all of the given strings are among the accepted strings.
+  +/
+bool allAreAcceptedUnits(acceptedUnits...)(string[] units...)
+{
+    foreach(unit; units)
+    {
+        bool found = false;
+        foreach(acceptedUnit; acceptedUnits)
+        {
+            if(unit == acceptedUnit)
+            {
+                found = true;
+                break;
+            }
+        }
+        if(!found)
+            return false;
+    }
+    return true;
+}
+
+unittest
+{
+    assert(allAreAcceptedUnits!("hours", "seconds")("seconds", "hours"));
+    assert(!allAreAcceptedUnits!("hours", "seconds")("minutes", "hours"));
+    assert(!allAreAcceptedUnits!("hours", "seconds")("seconds", "minutes"));
+    assert(allAreAcceptedUnits!("days", "hours", "minutes", "seconds", "msecs")("minutes"));
+    assert(!allAreAcceptedUnits!("days", "hours", "minutes", "seconds", "msecs")("usecs"));
+    assert(!allAreAcceptedUnits!("days", "hours", "minutes", "seconds", "msecs")("secs"));
+}
+
+
+/+
+    Whether the given time unit strings are arranged in order from largest to
+    smallest.
+  +/
+bool unitsAreInDescendingOrder(string[] units...)
+{
+    if(units.length <= 1)
+        return true;
+
+    immutable string[] timeStrings = ["nsecs", "hnsecs", "usecs", "msecs", "seconds",
+                                      "minutes", "hours", "days", "weeks", "months", "years"];
+    size_t currIndex = 42;
+    foreach(i, timeStr; timeStrings)
+    {
+        if(units[0] == timeStr)
+        {
+            currIndex = i;
+            break;
+        }
+    }
+    assert(currIndex != 42);
+
+    foreach(unit; units[1 .. $])
+    {
+        size_t nextIndex = 42;
+        foreach(i, timeStr; timeStrings)
+        {
+            if(unit == timeStr)
+            {
+                nextIndex = i;
+                break;
+            }
+        }
+        assert(nextIndex != 42);
+
+        if(currIndex <= nextIndex)
+            return false;
+        currIndex = nextIndex;
+    }
+    return true;
+}
+
+unittest
+{
+    assert(unitsAreInDescendingOrder("years", "months", "weeks", "days", "hours", "minutes",
+                                     "seconds", "msecs", "usecs", "hnsecs", "nsecs"));
+    assert(unitsAreInDescendingOrder("weeks", "hours", "msecs"));
+    assert(unitsAreInDescendingOrder("days", "hours", "minutes"));
+    assert(unitsAreInDescendingOrder("hnsecs"));
+    assert(!unitsAreInDescendingOrder("days", "hours", "hours"));
+    assert(!unitsAreInDescendingOrder("days", "hours", "days"));
+}
+
+
+/+
+    The time units which are one step larger than the given units.
+  +/
+template nextLargerTimeUnits(string units)
+    if(units == "days" ||
+       units == "hours" ||
+       units == "minutes" ||
+       units == "seconds" ||
+       units == "msecs" ||
+       units == "usecs" ||
+       units == "hnsecs" ||
+       units == "nsecs")
+{
+    static if(units == "days")
+        enum nextLargerTimeUnits = "weeks";
+    else static if(units == "hours")
+        enum nextLargerTimeUnits = "days";
+    else static if(units == "minutes")
+        enum nextLargerTimeUnits = "hours";
+    else static if(units == "seconds")
+        enum nextLargerTimeUnits = "minutes";
+    else static if(units == "msecs")
+        enum nextLargerTimeUnits = "seconds";
+    else static if(units == "usecs")
+        enum nextLargerTimeUnits = "msecs";
+    else static if(units == "hnsecs")
+        enum nextLargerTimeUnits = "usecs";
+    else static if(units == "nsecs")
+        enum nextLargerTimeUnits = "hnsecs";
+    else
+        static assert(0, "Broken template constraint");
+}
+
+///
+unittest
+{
+    assert(nextLargerTimeUnits!"minutes" == "hours");
+    assert(nextLargerTimeUnits!"hnsecs" == "usecs");
+}
+
+unittest
+{
+    assert(nextLargerTimeUnits!"nsecs" == "hnsecs");
+    assert(nextLargerTimeUnits!"hnsecs" == "usecs");
+    assert(nextLargerTimeUnits!"usecs" == "msecs");
+    assert(nextLargerTimeUnits!"msecs" == "seconds");
+    assert(nextLargerTimeUnits!"seconds" == "minutes");
+    assert(nextLargerTimeUnits!"minutes" == "hours");
+    assert(nextLargerTimeUnits!"hours" == "days");
+    assert(nextLargerTimeUnits!"days" == "weeks");
+
+    static assert(!__traits(compiles, nextLargerTimeUnits!"weeks"));
+    static assert(!__traits(compiles, nextLargerTimeUnits!"months"));
+    static assert(!__traits(compiles, nextLargerTimeUnits!"years"));
+}
+
+version(OSX)
+long machTicksPerSecond()
+{
+    // Be optimistic that ticksPerSecond (1e9*denom/numer) is integral. So far
+    // so good on Darwin based platforms OS X, iOS.
+    import core.internal.abort : abort;
+    mach_timebase_info_data_t info;
+    if(mach_timebase_info(&info) != 0)
+        abort("Failed in mach_timebase_info().");
+
+    long scaledDenom = 1_000_000_000L * info.denom;
+    if(scaledDenom % info.numer != 0)
+        abort("Non integral ticksPerSecond from mach_timebase_info.");
+    return scaledDenom / info.numer;
+}
+
+/+
+    Local version of abs, since std.math.abs is in Phobos, not druntime.
+  +/
+long _abs(long val) @safe pure nothrow @nogc
+{
+    return val >= 0 ? val : -val;
+}
+
+double _abs(double val) @safe pure nothrow @nogc
+{
+    return val >= 0.0 ? val : -val;
+}
+
+
+version(unittest)
+string doubleToString(double value) @safe pure nothrow
+{
+    string result;
+    if(value < 0 && cast(long)value == 0)
+        result = "-0";
+    else
+        result = signedToTempString(cast(long)value, 10).idup;
+    result ~= '.';
+    result ~= unsignedToTempString(cast(ulong)(_abs((value - cast(long)value) * 1_000_000) + .5), 10);
+
+    while (result[$-1] == '0')
+        result = result[0 .. $-1];
+    return result;
+}
+
+unittest
+{
+    auto a = 1.337;
+    auto aStr = doubleToString(a);
+    assert(aStr == "1.337", aStr);
+
+    a = 0.337;
+    aStr = doubleToString(a);
+    assert(aStr == "0.337", aStr);
+
+    a = -0.337;
+    aStr = doubleToString(a);
+    assert(aStr == "-0.337", aStr);
+}
+
+version(unittest) const(char)* numToStringz()(long value) @safe pure nothrow
+{
+    return (signedToTempString(value, 10) ~ "\0").ptr;
+}
+
+
+/+ A copy of std.typecons.TypeTuple. +/
+template _TypeTuple(TList...)
+{
+    alias TList _TypeTuple;
+}
+
+
+/+ An adjusted copy of std.exception.assertThrown. +/
+version(unittest) void _assertThrown(T : Throwable = Exception, E)
+                                    (lazy E expression,
+                                     string msg = null,
+                                     string file = __FILE__,
+                                     size_t line = __LINE__)
+{
+    bool thrown = false;
+
+    try
+        expression();
+    catch(T t)
+        thrown = true;
+
+    if(!thrown)
+    {
+        immutable tail = msg.length == 0 ? "." : ": " ~ msg;
+
+        throw new AssertError("assertThrown() failed: No " ~ T.stringof ~ " was thrown" ~ tail, file, line);
+    }
+}
+
+unittest
+{
+
+    void throwEx(Throwable t)
+    {
+        throw t;
+    }
+
+    void nothrowEx()
+    {}
+
+    try
+        _assertThrown!Exception(throwEx(new Exception("It's an Exception")));
+    catch(AssertError)
+        assert(0);
+
+    try
+        _assertThrown!Exception(throwEx(new Exception("It's an Exception")), "It's a message");
+    catch(AssertError)
+        assert(0);
+
+    try
+        _assertThrown!AssertError(throwEx(new AssertError("It's an AssertError", __FILE__, __LINE__)));
+    catch(AssertError)
+        assert(0);
+
+    try
+        _assertThrown!AssertError(throwEx(new AssertError("It's an AssertError", __FILE__, __LINE__)), "It's a message");
+    catch(AssertError)
+        assert(0);
+
+
+    {
+        bool thrown = false;
+        try
+            _assertThrown!Exception(nothrowEx());
+        catch(AssertError)
+            thrown = true;
+
+        assert(thrown);
+    }
+
+    {
+        bool thrown = false;
+        try
+            _assertThrown!Exception(nothrowEx(), "It's a message");
+        catch(AssertError)
+            thrown = true;
+
+        assert(thrown);
+    }
+
+    {
+        bool thrown = false;
+        try
+            _assertThrown!AssertError(nothrowEx());
+        catch(AssertError)
+            thrown = true;
+
+        assert(thrown);
+    }
+
+    {
+        bool thrown = false;
+        try
+            _assertThrown!AssertError(nothrowEx(), "It's a message");
+        catch(AssertError)
+            thrown = true;
+
+        assert(thrown);
+    }
+}
+
+
+version(unittest) void assertApprox(D, E)(D actual,
+                                          E lower,
+                                          E upper,
+                                          string msg = "unittest failure",
+                                          size_t line = __LINE__)
+    if(is(D : const Duration) && is(E : const Duration))
+{
+    if(actual < lower)
+        throw new AssertError(msg ~ ": lower: " ~ actual.toString(), __FILE__, line);
+    if(actual > upper)
+        throw new AssertError(msg ~ ": upper: " ~ actual.toString(), __FILE__, line);
+}
+
+version(unittest) void assertApprox(D, E)(D actual,
+                                          E lower,
+                                          E upper,
+                                          string msg = "unittest failure",
+                                          size_t line = __LINE__)
+    if(is(D : const TickDuration) && is(E : const TickDuration))
+{
+    if(actual.length < lower.length || actual.length > upper.length)
+    {
+        throw new AssertError(msg ~ (": [" ~ signedToTempString(lower.length, 10) ~ "] [" ~
+                              signedToTempString(actual.length, 10) ~ "] [" ~
+                              signedToTempString(upper.length, 10) ~ "]").idup,
+                              __FILE__, line);
+    }
+}
+
+version(unittest) void assertApprox(MT)(MT actual,
+                                        MT lower,
+                                        MT upper,
+                                        string msg = "unittest failure",
+                                        size_t line = __LINE__)
+    if(is(MT == MonoTimeImpl!type, ClockType type))
+{
+    assertApprox(actual._ticks, lower._ticks, upper._ticks, msg, line);
+}
+
+version(unittest) void assertApprox()(long actual,
+                                      long lower,
+                                      long upper,
+                                      string msg = "unittest failure",
+                                      size_t line = __LINE__)
+{
+    if(actual < lower)
+        throw new AssertError(msg ~ ": lower: " ~ signedToTempString(actual, 10).idup, __FILE__, line);
+    if(actual > upper)
+        throw new AssertError(msg ~ ": upper: " ~ signedToTempString(actual, 10).idup, __FILE__, line);
+}
diff --git a/libphobos/libdruntime/core/vararg.d b/libphobos/libdruntime/core/vararg.d
new file mode 100644
index 00000000000..a02ffeaea23
--- /dev/null
+++ b/libphobos/libdruntime/core/vararg.d
@@ -0,0 +1,19 @@
+/**
+ * The vararg module is intended to facilitate vararg manipulation in D.
+ * It should be interface compatible with the C module "stdarg," and the
+ * two modules may share a common implementation if possible (as is done
+ * here).
+ * Copyright: Copyright Digital Mars 2000 - 2009.
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Walter Bright, Hauke Duden
+ * Source:    $(DRUNTIMESRC core/_vararg.d)
+ */
+
+/*          Copyright Digital Mars 2000 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module core.vararg;
+
+public import core.stdc.stdarg;
diff --git a/libphobos/libdruntime/etc/linux/memoryerror.d b/libphobos/libdruntime/etc/linux/memoryerror.d
new file mode 100644
index 00000000000..7b7b6ed0855
--- /dev/null
+++ b/libphobos/libdruntime/etc/linux/memoryerror.d
@@ -0,0 +1,331 @@
+/**
+ * Handle page protection errors using D errors (exceptions). $(D NullPointerError) is
+ * thrown when dereferencing null pointers. A system-dependent error is thrown in other
+ * cases.
+ *
+ * Note: Only x86 and x86_64 are supported for now.
+ *
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE_1_0.txt)
+ * Authors:   Amaury SECHET, FeepingCreature, Vladimir Panteleev
+ * Source: $(DRUNTIMESRC src/etc/linux/memory.d)
+ */
+
+module etc.linux.memoryerror;
+
+version (GNU)
+{}
+else version (CRuntime_Glibc)
+{
+    version (X86)
+        version = MemoryErrorSupported;
+    version (X86_64)
+        version = MemoryErrorSupported;
+}
+
+version (MemoryErrorSupported):
+@system:
+
+import core.sys.posix.signal;
+import core.sys.posix.ucontext;
+
+// Register and unregister memory error handler.
+
+bool registerMemoryErrorHandler()
+{
+    sigaction_t action;
+    action.sa_sigaction = &handleSignal;
+    action.sa_flags = SA_SIGINFO;
+
+    auto oldptr = &old_sigaction;
+
+    return !sigaction(SIGSEGV, &action, oldptr);
+}
+
+bool deregisterMemoryErrorHandler()
+{
+    auto oldptr = &old_sigaction;
+
+    return !sigaction(SIGSEGV, oldptr, null);
+}
+
+/**
+ * Thrown on POSIX systems when a SIGSEGV signal is received.
+ */
+class InvalidPointerError : Error
+{
+    this(string file = __FILE__, size_t line = __LINE__, Throwable next = null)
+    {
+        super("", file, line, next);
+    }
+
+    this(Throwable next, string file = __FILE__, size_t line = __LINE__)
+    {
+        super("", file, line, next);
+    }
+}
+
+/**
+ * Thrown on null pointer dereferences.
+ */
+class NullPointerError : InvalidPointerError
+{
+    this(string file = __FILE__, size_t line = __LINE__, Throwable next = null)
+    {
+        super(file, line, next);
+    }
+
+    this(Throwable next, string file = __FILE__, size_t line = __LINE__)
+    {
+        super(file, line, next);
+    }
+}
+
+version (unittest)
+{
+    int* getNull() { return null; }
+}
+
+unittest
+{
+    assert(registerMemoryErrorHandler());
+
+    bool b;
+
+    try
+    {
+        *getNull() = 42;
+    }
+    catch (NullPointerError)
+    {
+        b = true;
+    }
+
+    assert(b);
+
+    b = false;
+
+    try
+    {
+        *getNull() = 42;
+    }
+    catch (InvalidPointerError)
+    {
+        b = true;
+    }
+
+    assert(b);
+
+    assert(deregisterMemoryErrorHandler());
+}
+
+// Signal handler space.
+
+private:
+
+__gshared sigaction_t old_sigaction;
+
+alias typeof(ucontext_t.init.uc_mcontext.gregs[0]) RegType;
+
+version (X86_64)
+{
+    static RegType savedRDI, savedRSI;
+
+    extern(C)
+    void handleSignal(int signum, siginfo_t* info, void* contextPtr) nothrow
+    {
+        auto context = cast(ucontext_t*)contextPtr;
+
+        // Save registers into global thread local, to allow recovery.
+        savedRDI = context.uc_mcontext.gregs[REG_RDI];
+        savedRSI = context.uc_mcontext.gregs[REG_RSI];
+
+        // Hijack current context so we call our handler.
+        auto rip = context.uc_mcontext.gregs[REG_RIP];
+        auto addr = cast(RegType) info.si_addr;
+        context.uc_mcontext.gregs[REG_RDI] = addr;
+        context.uc_mcontext.gregs[REG_RSI] = rip;
+        context.uc_mcontext.gregs[REG_RIP] = cast(RegType) ((rip != addr)?&sigsegvDataHandler:&sigsegvCodeHandler);
+    }
+
+    // All handler functions must be called with faulting address in RDI and original RIP in RSI.
+
+    // This function is called when the segfault's cause is to call an invalid function pointer.
+    void sigsegvCodeHandler()
+    {
+        asm
+        {
+            naked;
+
+            // Handle the stack for an invalid function call (segfault at RIP).
+            // With the return pointer, the stack is now alligned.
+            push RBP;
+            mov RBP, RSP;
+
+            jmp sigsegvDataHandler;
+        }
+    }
+
+    void sigsegvDataHandler()
+    {
+        asm
+        {
+            naked;
+
+            push RSI;   // return address (original RIP).
+            push RBP;   // old RBP
+            mov RBP, RSP;
+
+            pushfq;     // Save flags.
+            push RAX;   // RAX, RCX, RDX, and R8 to R11 are trash registers and must be preserved as local variables.
+            push RCX;
+            push RDX;
+            push R8;
+            push R9;
+            push R10;
+            push R11;    // With 10 pushes, the stack is still aligned.
+
+            // Parameter address is already set as RAX.
+            call sigsegvUserspaceProcess;
+
+            // Restore RDI and RSI values.
+            call restoreRDI;
+            push RAX;   // RDI is in RAX. It is pushed and will be poped back to RDI.
+
+            call restoreRSI;
+            mov RSI, RAX;
+
+            pop RDI;
+
+            // Restore trash registers value.
+            pop R11;
+            pop R10;
+            pop R9;
+            pop R8;
+            pop RDX;
+            pop RCX;
+            pop RAX;
+            popfq;      // Restore flags.
+
+            // Return
+            pop RBP;
+            ret;
+        }
+    }
+
+    // The return value is stored in EAX and EDX, so this function restore the correct value for theses registers.
+    RegType restoreRDI()
+    {
+        return savedRDI;
+    }
+
+    RegType restoreRSI()
+    {
+        return savedRSI;
+    }
+}
+else version (X86)
+{
+    static RegType savedEAX, savedEDX;
+
+    extern(C)
+    void handleSignal(int signum, siginfo_t* info, void* contextPtr) nothrow
+    {
+        auto context = cast(ucontext_t*)contextPtr;
+
+        // Save registers into global thread local, to allow recovery.
+        savedEAX = context.uc_mcontext.gregs[REG_EAX];
+        savedEDX = context.uc_mcontext.gregs[REG_EDX];
+
+        // Hijack current context so we call our handler.
+        auto eip = context.uc_mcontext.gregs[REG_EIP];
+        auto addr = cast(RegType) info.si_addr;
+        context.uc_mcontext.gregs[REG_EAX] = addr;
+        context.uc_mcontext.gregs[REG_EDX] = eip;
+        context.uc_mcontext.gregs[REG_EIP] = cast(RegType) ((eip != addr)?&sigsegvDataHandler:&sigsegvCodeHandler);
+    }
+
+    // All handler functions must be called with faulting address in EAX and original EIP in EDX.
+
+    // This function is called when the segfault's cause is to call an invalid function pointer.
+    void sigsegvCodeHandler()
+    {
+        asm
+        {
+            naked;
+
+            // Handle the stack for an invalid function call (segfault at EIP).
+            // 4 bytes are used for function pointer; We need 12 byte to keep stack aligned.
+            sub ESP, 12;
+            mov 8[ESP], EBP;
+            mov EBP, ESP;
+
+            jmp sigsegvDataHandler;
+        }
+    }
+
+    void sigsegvDataHandler()
+    {
+        asm
+        {
+            naked;
+
+            // We jump directly here if we are in a valid function call case.
+            push EDX;   // return address (original EIP).
+            push EBP;   // old EBP
+            mov EBP, ESP;
+
+            pushfd;     // Save flags.
+            push ECX;   // ECX is a trash register and must be preserved as local variable.
+                        // 4 pushes have been done. The stack is aligned.
+
+            // Parameter address is already set as EAX.
+            call sigsegvUserspaceProcess;
+
+            // Restore register values and return.
+            call restoreRegisters;
+
+            pop ECX;
+            popfd;      // Restore flags.
+
+            // Return
+            pop EBP;
+            ret;
+        }
+    }
+
+    // The return value is stored in EAX and EDX, so this function restore the correct value for theses registers.
+    RegType[2] restoreRegisters()
+    {
+        RegType[2] restore;
+        restore[0] = savedEAX;
+        restore[1] = savedEDX;
+
+        return restore;
+    }
+}
+else
+{
+    static assert(false, "Unsupported architecture.");
+}
+
+// This should be calculated by druntime.
+// TODO: Add a core.memory function for this.
+enum PAGE_SIZE = 4096;
+
+// The first 64Kb are reserved for detecting null pointer dereferences.
+enum MEMORY_RESERVED_FOR_NULL_DEREFERENCE = 4096 * 16;
+
+// User space handler
+void sigsegvUserspaceProcess(void* address)
+{
+    // SEGV_MAPERR, SEGV_ACCERR.
+    // The first page is protected to detect null dereferences.
+    if((cast(size_t) address) < MEMORY_RESERVED_FOR_NULL_DEREFERENCE)
+    {
+        throw new NullPointerError();
+    }
+
+    throw new InvalidPointerError();
+}
diff --git a/libphobos/libdruntime/gc/bits.d b/libphobos/libdruntime/gc/bits.d
new file mode 100644
index 00000000000..60ba4f4eefd
--- /dev/null
+++ b/libphobos/libdruntime/gc/bits.d
@@ -0,0 +1,129 @@
+/**
+ * Contains a bitfield used by the GC.
+ *
+ * Copyright: Copyright Digital Mars 2005 - 2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, David Friedman, Sean Kelly
+ */
+
+/*          Copyright Digital Mars 2005 - 2013.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module gc.bits;
+
+
+import core.bitop;
+import core.stdc.string;
+import core.stdc.stdlib;
+import core.exception : onOutOfMemoryError;
+
+struct GCBits
+{
+    alias size_t wordtype;
+
+    enum BITS_PER_WORD = (wordtype.sizeof * 8);
+    enum BITS_SHIFT = (wordtype.sizeof == 8 ? 6 : 5);
+    enum BITS_MASK = (BITS_PER_WORD - 1);
+    enum BITS_1 = cast(wordtype)1;
+
+    wordtype* data;
+    size_t nbits;
+
+    void Dtor() nothrow
+    {
+        if (data)
+        {
+            free(data);
+            data = null;
+        }
+    }
+
+    void alloc(size_t nbits) nothrow
+    {
+        this.nbits = nbits;
+        data = cast(typeof(data[0])*)calloc(nwords, data[0].sizeof);
+        if (!data)
+            onOutOfMemoryError();
+    }
+
+    wordtype test(size_t i) const nothrow
+    in
+    {
+        assert(i < nbits);
+    }
+    body
+    {
+        return core.bitop.bt(data, i);
+    }
+
+    int set(size_t i) nothrow
+    in
+    {
+        assert(i < nbits);
+    }
+    body
+    {
+        return core.bitop.bts(data, i);
+    }
+
+    int clear(size_t i) nothrow
+    in
+    {
+        assert(i <= nbits);
+    }
+    body
+    {
+        return core.bitop.btr(data, i);
+    }
+
+    void zero() nothrow
+    {
+        memset(data, 0, nwords * wordtype.sizeof);
+    }
+
+    void copy(GCBits *f) nothrow
+    in
+    {
+        assert(nwords == f.nwords);
+    }
+    body
+    {
+        memcpy(data, f.data, nwords * wordtype.sizeof);
+    }
+
+    @property size_t nwords() const pure nothrow
+    {
+        return (nbits + (BITS_PER_WORD - 1)) >> BITS_SHIFT;
+    }
+}
+
+unittest
+{
+    GCBits b;
+
+    b.alloc(786);
+    assert(!b.test(123));
+    assert(!b.clear(123));
+    assert(!b.set(123));
+    assert(b.test(123));
+    assert(b.clear(123));
+    assert(!b.test(123));
+
+    b.set(785);
+    b.set(0);
+    assert(b.test(785));
+    assert(b.test(0));
+    b.zero();
+    assert(!b.test(785));
+    assert(!b.test(0));
+
+    GCBits b2;
+    b2.alloc(786);
+    b2.set(38);
+    b.copy(&b2);
+    assert(b.test(38));
+    b2.Dtor();
+    b.Dtor();
+}
diff --git a/libphobos/libdruntime/gc/config.d b/libphobos/libdruntime/gc/config.d
new file mode 100644
index 00000000000..95c6fb724f2
--- /dev/null
+++ b/libphobos/libdruntime/gc/config.d
@@ -0,0 +1,248 @@
+/**
+* Contains the garbage collector configuration.
+*
+* Copyright: Copyright Digital Mars 2014
+* License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+*/
+
+module gc.config;
+
+import core.stdc.stdlib;
+import core.stdc.stdio;
+import core.stdc.ctype;
+import core.stdc.string;
+import core.vararg;
+
+nothrow @nogc:
+extern extern(C) string[] rt_args();
+
+extern extern(C) __gshared bool rt_envvars_enabled;
+extern extern(C) __gshared bool rt_cmdline_enabled;
+extern extern(C) __gshared string[] rt_options;
+
+struct Config
+{
+    bool disable;            // start disabled
+    ubyte profile;           // enable profiling with summary when terminating program
+    bool precise;            // enable precise scanning
+    bool concurrent;         // enable concurrent collection
+
+    size_t initReserve;      // initial reserve (MB)
+    size_t minPoolSize = 1;  // initial and minimum pool size (MB)
+    size_t maxPoolSize = 64; // maximum pool size (MB)
+    size_t incPoolSize = 3;  // pool size increment (MB)
+    float heapSizeFactor = 2.0; // heap size to used memory ratio
+
+@nogc nothrow:
+
+    bool initialize()
+    {
+        import core.internal.traits : externDFunc;
+
+        alias rt_configCallBack = string delegate(string) @nogc nothrow;
+        alias fn_configOption = string function(string opt, scope rt_configCallBack dg, bool reverse) @nogc nothrow;
+
+        alias rt_configOption = externDFunc!("rt.config.rt_configOption", fn_configOption);
+
+        string parse(string opt) @nogc nothrow
+        {
+            if (!parseOptions(opt))
+                return "err";
+            return null; // continue processing
+        }
+        string s = rt_configOption("gcopt", &parse, true);
+        return s is null;
+    }
+
+    void help()
+    {
+        version (unittest) if (inUnittest) return;
+
+        string s = "GC options are specified as white space separated assignments:
+    disable:0|1    - start disabled (%d)
+    profile:0|1|2  - enable profiling with summary when terminating program (%d)
+    precise:0|1    - enable precise scanning (not implemented yet)
+    concurrent:0|1 - enable concurrent collection (not implemented yet)
+
+    initReserve:N  - initial memory to reserve in MB (%lld)
+    minPoolSize:N  - initial and minimum pool size in MB (%lld)
+    maxPoolSize:N  - maximum pool size in MB (%lld)
+    incPoolSize:N  - pool size increment MB (%lld)
+    heapSizeFactor:N - targeted heap size to used memory ratio (%g)
+";
+        printf(s.ptr, disable, profile, cast(long)initReserve, cast(long)minPoolSize,
+               cast(long)maxPoolSize, cast(long)incPoolSize, heapSizeFactor);
+    }
+
+    bool parseOptions(const(char)[] opt)
+    {
+        opt = skip!isspace(opt);
+        while (opt.length)
+        {
+            auto tail = find!(c => c == ':' || c == '=' || c == ' ')(opt);
+            auto name = opt[0 .. $ - tail.length];
+            if (name == "help")
+            {
+                help();
+                opt = skip!isspace(tail);
+                continue;
+            }
+            if (tail.length <= 1 || tail[0] == ' ')
+                return optError("Missing argument for", name);
+            tail = tail[1 .. $];
+
+            switch (name)
+            {
+            foreach (field; __traits(allMembers, Config))
+            {
+                static if (!is(typeof(__traits(getMember, this, field)) == function))
+                {
+                case field:
+                    if (!parse(name, tail, __traits(getMember, this, field)))
+                        return false;
+                    break;
+                }
+            }
+            break;
+
+            default:
+                return optError("Unknown", name);
+            }
+            opt = skip!isspace(tail);
+        }
+        return true;
+    }
+}
+
+private:
+
+bool optError(in char[] msg, in char[] name)
+{
+    version (unittest) if (inUnittest) return false;
+
+    fprintf(stderr, "%.*s GC option '%.*s'.\n",
+            cast(int)msg.length, msg.ptr,
+            cast(int)name.length, name.ptr);
+    return false;
+}
+
+inout(char)[] skip(alias pred)(inout(char)[] str)
+{
+    return find!(c => !pred(c))(str);
+}
+
+inout(char)[] find(alias pred)(inout(char)[] str)
+{
+    foreach (i; 0 .. str.length)
+        if (pred(str[i])) return str[i .. $];
+    return null;
+}
+
+bool parse(T:size_t)(const(char)[] optname, ref const(char)[] str, ref T res)
+in { assert(str.length); }
+body
+{
+    size_t i, v;
+    for (; i < str.length && isdigit(str[i]); ++i)
+        v = 10 * v + str[i] - '0';
+
+    if (!i)
+        return parseError("a number", optname, str);
+    if (v > res.max)
+        return parseError("a number " ~ T.max.stringof ~ " or below", optname, str[0 .. i]);
+    str = str[i .. $];
+    res = cast(T) v;
+    return true;
+}
+
+bool parse(T:bool)(const(char)[] optname, ref const(char)[] str, ref T res)
+in { assert(str.length); }
+body
+{
+    if (str[0] == '1' || str[0] == 'y' || str[0] == 'Y')
+        res = true;
+    else if (str[0] == '0' || str[0] == 'n' || str[0] == 'N')
+        res = false;
+    else
+        return parseError("'0/n/N' or '1/y/Y'", optname, str);
+    str = str[1 .. $];
+    return true;
+}
+
+bool parse(T:float)(const(char)[] optname, ref const(char)[] str, ref T res)
+in { assert(str.length); }
+body
+{
+    // % uint f %n \0
+    char[1 + 10 + 1 + 2 + 1] fmt=void;
+    // specify max-width
+    immutable n = snprintf(fmt.ptr, fmt.length, "%%%uf%%n", cast(uint)str.length);
+    assert(n > 4 && n < fmt.length);
+
+    int nscanned;
+    if (sscanf(str.ptr, fmt.ptr, &res, &nscanned) < 1)
+        return parseError("a float", optname, str);
+    str = str[nscanned .. $];
+    return true;
+}
+
+bool parseError(in char[] exp, in char[] opt, in char[] got)
+{
+    version (unittest) if (inUnittest) return false;
+
+    fprintf(stderr, "Expecting %.*s as argument for GC option '%.*s', got '%.*s' instead.\n",
+            cast(int)exp.length, exp.ptr,
+            cast(int)opt.length, opt.ptr,
+            cast(int)got.length, got.ptr);
+    return false;
+}
+
+size_t min(size_t a, size_t b) { return a <= b ? a : b; }
+
+version (unittest) __gshared bool inUnittest;
+
+unittest
+{
+    inUnittest = true;
+    scope (exit) inUnittest = false;
+
+    Config conf;
+    assert(!conf.parseOptions("disable"));
+    assert(!conf.parseOptions("disable:"));
+    assert(!conf.parseOptions("disable:5"));
+    assert(conf.parseOptions("disable:y") && conf.disable);
+    assert(conf.parseOptions("disable:n") && !conf.disable);
+    assert(conf.parseOptions("disable:Y") && conf.disable);
+    assert(conf.parseOptions("disable:N") && !conf.disable);
+    assert(conf.parseOptions("disable:1") && conf.disable);
+    assert(conf.parseOptions("disable:0") && !conf.disable);
+
+    assert(conf.parseOptions("disable=y") && conf.disable);
+    assert(conf.parseOptions("disable=n") && !conf.disable);
+
+    assert(conf.parseOptions("profile=0") && conf.profile == 0);
+    assert(conf.parseOptions("profile=1") && conf.profile == 1);
+    assert(conf.parseOptions("profile=2") && conf.profile == 2);
+    assert(!conf.parseOptions("profile=256"));
+
+    assert(conf.parseOptions("disable:1 minPoolSize:16"));
+    assert(conf.disable);
+    assert(conf.minPoolSize == 16);
+
+    assert(conf.parseOptions("heapSizeFactor:3.1"));
+    assert(conf.heapSizeFactor == 3.1f);
+    assert(conf.parseOptions("heapSizeFactor:3.1234567890 disable:0"));
+    assert(conf.heapSizeFactor > 3.123f);
+    assert(!conf.disable);
+    assert(!conf.parseOptions("heapSizeFactor:3.0.2.5"));
+    assert(conf.parseOptions("heapSizeFactor:2"));
+    assert(conf.heapSizeFactor == 2.0f);
+
+    assert(!conf.parseOptions("initReserve:foo"));
+    assert(!conf.parseOptions("initReserve:y"));
+    assert(!conf.parseOptions("initReserve:20.5"));
+
+    assert(conf.parseOptions("help"));
+    assert(conf.parseOptions("help profile:1"));
+    assert(conf.parseOptions("help profile:1 help"));
+}
diff --git a/libphobos/libdruntime/gc/gc.d b/libphobos/libdruntime/gc/gc.d
new file mode 100644
index 00000000000..deb999f5381
--- /dev/null
+++ b/libphobos/libdruntime/gc/gc.d
@@ -0,0 +1,3412 @@
+/**
+ * Contains the garbage collector implementation.
+ *
+ * Copyright: Copyright Digital Mars 2001 - 2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, David Friedman, Sean Kelly
+ */
+
+/*          Copyright Digital Mars 2005 - 2013.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module gc.gc;
+
+// D Programming Language Garbage Collector implementation
+
+/************** Debugging ***************************/
+
+//debug = PRINTF;               // turn on printf's
+//debug = COLLECT_PRINTF;       // turn on printf's
+//debug = PRINTF_TO_FILE;       // redirect printf's ouptut to file "gcx.log"
+//debug = LOGGING;              // log allocations / frees
+//debug = MEMSTOMP;             // stomp on memory
+//debug = SENTINEL;             // add underrun/overrrun protection
+                                // NOTE: this needs to be enabled globally in the makefiles
+                                // (-debug=SENTINEL) to pass druntime's unittests.
+//debug = PTRCHECK;             // more pointer checking
+//debug = PTRCHECK2;            // thorough but slow pointer checking
+//debug = INVARIANT;            // enable invariants
+//debug = PROFILE_API;          // profile API calls for config.profile > 1
+
+/*************** Configuration *********************/
+
+version = STACKGROWSDOWN;       // growing the stack means subtracting from the stack pointer
+                                // (use for Intel X86 CPUs)
+                                // else growing the stack means adding to the stack pointer
+
+/***************************************************/
+
+import gc.bits;
+import gc.stats;
+import gc.os;
+import gc.config;
+
+import rt.util.container.treap;
+
+import cstdlib = core.stdc.stdlib : calloc, free, malloc, realloc;
+import core.stdc.string : memcpy, memset, memmove;
+import core.bitop;
+import core.thread;
+static import core.memory;
+private alias BlkAttr = core.memory.GC.BlkAttr;
+private alias BlkInfo = core.memory.GC.BlkInfo;
+
+version (GNU) import gcc.builtins;
+
+debug (PRINTF_TO_FILE) import core.stdc.stdio : sprintf, fprintf, fopen, fflush, FILE;
+else                   import core.stdc.stdio : sprintf, printf; // needed to output profiling results
+
+import core.time;
+alias currTime = MonoTime.currTime;
+
+debug(PRINTF_TO_FILE)
+{
+    private __gshared MonoTime gcStartTick;
+    private __gshared FILE* gcx_fh;
+
+    private int printf(ARGS...)(const char* fmt, ARGS args) nothrow
+    {
+        if (!gcx_fh)
+            gcx_fh = fopen("gcx.log", "w");
+        if (!gcx_fh)
+            return 0;
+
+        int len;
+        if (MonoTime.ticksPerSecond == 0)
+        {
+            len = fprintf(gcx_fh, "before init: ");
+        }
+        else
+        {
+            if (gcStartTick == MonoTime.init)
+                gcStartTick = MonoTime.currTime;
+            immutable timeElapsed = MonoTime.currTime - gcStartTick;
+            immutable secondsAsDouble = timeElapsed.total!"hnsecs" / cast(double)convert!("seconds", "hnsecs")(1);
+            len = fprintf(gcx_fh, "%10.6lf: ", secondsAsDouble);
+        }
+        len += fprintf(gcx_fh, fmt, args);
+        fflush(gcx_fh);
+        return len;
+    }
+}
+
+debug(PRINTF) void printFreeInfo(Pool* pool) nothrow
+{
+    uint nReallyFree;
+    foreach(i; 0..pool.npages) {
+        if(pool.pagetable[i] >= B_FREE) nReallyFree++;
+    }
+
+    printf("Pool %p:  %d really free, %d supposedly free\n", pool, nReallyFree, pool.freepages);
+}
+
+// Track total time spent preparing for GC,
+// marking, sweeping and recovering pages.
+__gshared Duration prepTime;
+__gshared Duration markTime;
+__gshared Duration sweepTime;
+__gshared Duration recoverTime;
+__gshared Duration maxPauseTime;
+__gshared size_t numCollections;
+__gshared size_t maxPoolMemory;
+
+__gshared long numMallocs;
+__gshared long numFrees;
+__gshared long numReallocs;
+__gshared long numExtends;
+__gshared long numOthers;
+__gshared long mallocTime; // using ticks instead of MonoTime for better performance
+__gshared long freeTime;
+__gshared long reallocTime;
+__gshared long extendTime;
+__gshared long otherTime;
+__gshared long lockTime;
+
+private
+{
+    extern (C)
+    {
+        // to allow compilation of this module without access to the rt package,
+        //  make these functions available from rt.lifetime
+        void rt_finalizeFromGC(void* p, size_t size, uint attr) nothrow;
+        int rt_hasFinalizerInSegment(void* p, size_t size, uint attr, in void[] segment) nothrow;
+
+        // Declared as an extern instead of importing core.exception
+        // to avoid inlining - see issue 13725.
+        void onInvalidMemoryOperationError() @nogc nothrow;
+        void onOutOfMemoryErrorNoGC() @nogc nothrow;
+    }
+
+    enum
+    {
+        OPFAIL = ~cast(size_t)0
+    }
+}
+
+
+alias GC gc_t;
+
+
+/* ======================= Leak Detector =========================== */
+
+
+debug (LOGGING)
+{
+    struct Log
+    {
+        void*  p;
+        size_t size;
+        size_t line;
+        char*  file;
+        void*  parent;
+
+        void print() nothrow
+        {
+            printf("    p = %p, size = %zd, parent = %p ", p, size, parent);
+            if (file)
+            {
+                printf("%s(%u)", file, line);
+            }
+            printf("\n");
+        }
+    }
+
+
+    struct LogArray
+    {
+        size_t dim;
+        size_t allocdim;
+        Log *data;
+
+        void Dtor() nothrow
+        {
+            if (data)
+                cstdlib.free(data);
+            data = null;
+        }
+
+        void reserve(size_t nentries) nothrow
+        {
+            assert(dim <= allocdim);
+            if (allocdim - dim < nentries)
+            {
+                allocdim = (dim + nentries) * 2;
+                assert(dim + nentries <= allocdim);
+                if (!data)
+                {
+                    data = cast(Log*)cstdlib.malloc(allocdim * Log.sizeof);
+                    if (!data && allocdim)
+                        onOutOfMemoryErrorNoGC();
+                }
+                else
+                {   Log *newdata;
+
+                    newdata = cast(Log*)cstdlib.malloc(allocdim * Log.sizeof);
+                    if (!newdata && allocdim)
+                        onOutOfMemoryErrorNoGC();
+                    memcpy(newdata, data, dim * Log.sizeof);
+                    cstdlib.free(data);
+                    data = newdata;
+                }
+            }
+        }
+
+
+        void push(Log log) nothrow
+        {
+            reserve(1);
+            data[dim++] = log;
+        }
+
+        void remove(size_t i) nothrow
+        {
+            memmove(data + i, data + i + 1, (dim - i) * Log.sizeof);
+            dim--;
+        }
+
+
+        size_t find(void *p) nothrow
+        {
+            for (size_t i = 0; i < dim; i++)
+            {
+                if (data[i].p == p)
+                    return i;
+            }
+            return OPFAIL; // not found
+        }
+
+
+        void copy(LogArray *from) nothrow
+        {
+            reserve(from.dim - dim);
+            assert(from.dim <= allocdim);
+            memcpy(data, from.data, from.dim * Log.sizeof);
+            dim = from.dim;
+        }
+    }
+}
+
+
+/* ============================ GC =============================== */
+
+
+const uint GCVERSION = 1;       // increment every time we change interface
+                                // to GC.
+
+struct GC
+{
+    // For passing to debug code (not thread safe)
+    __gshared size_t line;
+    __gshared char*  file;
+
+    uint gcversion = GCVERSION;
+
+    Gcx *gcx;                   // implementation
+
+    import core.internal.spinlock;
+    static gcLock = shared(AlignedSpinLock)(SpinLock.Contention.lengthy);
+    static bool inFinalizer;
+
+    // lock GC, throw InvalidMemoryOperationError on recursive locking during finalization
+    static void lockNR() @nogc nothrow
+    {
+        if (inFinalizer)
+            onInvalidMemoryOperationError();
+        gcLock.lock();
+    }
+
+    __gshared Config config;
+
+    void initialize()
+    {
+        config.initialize();
+
+        gcx = cast(Gcx*)cstdlib.calloc(1, Gcx.sizeof);
+        if (!gcx)
+            onOutOfMemoryErrorNoGC();
+        gcx.initialize();
+
+        if (config.initReserve)
+            gcx.reserve(config.initReserve << 20);
+        if (config.disable)
+            gcx.disabled++;
+    }
+
+
+    void Dtor()
+    {
+        version (linux)
+        {
+            //debug(PRINTF) printf("Thread %x ", pthread_self());
+            //debug(PRINTF) printf("GC.Dtor()\n");
+        }
+
+        if (gcx)
+        {
+            gcx.Dtor();
+            cstdlib.free(gcx);
+            gcx = null;
+        }
+    }
+
+
+    /**
+     *
+     */
+    void enable()
+    {
+        static void go(Gcx* gcx) nothrow
+        {
+            assert(gcx.disabled > 0);
+            gcx.disabled--;
+        }
+        runLocked!(go, otherTime, numOthers)(gcx);
+    }
+
+
+    /**
+     *
+     */
+    void disable()
+    {
+        static void go(Gcx* gcx) nothrow
+        {
+            gcx.disabled++;
+        }
+        runLocked!(go, otherTime, numOthers)(gcx);
+    }
+
+    auto runLocked(alias func, Args...)(auto ref Args args)
+    {
+        debug(PROFILE_API) immutable tm = (GC.config.profile > 1 ? currTime.ticks : 0);
+        lockNR();
+        scope (failure) gcLock.unlock();
+        debug(PROFILE_API) immutable tm2 = (GC.config.profile > 1 ? currTime.ticks : 0);
+
+        static if (is(typeof(func(args)) == void))
+            func(args);
+        else
+            auto res = func(args);
+
+        debug(PROFILE_API) if (GC.config.profile > 1)
+            lockTime += tm2 - tm;
+        gcLock.unlock();
+
+        static if (!is(typeof(func(args)) == void))
+            return res;
+    }
+
+    auto runLocked(alias func, alias time, alias count, Args...)(auto ref Args args)
+    {
+        debug(PROFILE_API) immutable tm = (GC.config.profile > 1 ? currTime.ticks : 0);
+        lockNR();
+        scope (failure) gcLock.unlock();
+        debug(PROFILE_API) immutable tm2 = (GC.config.profile > 1 ? currTime.ticks : 0);
+
+        static if (is(typeof(func(args)) == void))
+            func(args);
+        else
+            auto res = func(args);
+
+        debug(PROFILE_API) if (GC.config.profile > 1)
+        {
+            count++;
+            immutable now = currTime.ticks;
+            lockTime += tm2 - tm;
+            time += now - tm2;
+        }
+        gcLock.unlock();
+
+        static if (!is(typeof(func(args)) == void))
+            return res;
+    }
+
+    /**
+     *
+     */
+    uint getAttr(void* p) nothrow
+    {
+        if (!p)
+        {
+            return 0;
+        }
+
+        static uint go(Gcx* gcx, void* p) nothrow
+        {
+            Pool* pool = gcx.findPool(p);
+            uint  oldb = 0;
+
+            if (pool)
+            {
+                p = sentinel_sub(p);
+                auto biti = cast(size_t)(p - pool.baseAddr) >> pool.shiftBy;
+
+                oldb = pool.getBits(biti);
+            }
+            return oldb;
+        }
+
+        return runLocked!(go, otherTime, numOthers)(gcx, p);
+    }
+
+
+    /**
+     *
+     */
+    uint setAttr(void* p, uint mask) nothrow
+    {
+        if (!p)
+        {
+            return 0;
+        }
+
+        static uint go(Gcx* gcx, void* p, uint mask) nothrow
+        {
+            Pool* pool = gcx.findPool(p);
+            uint  oldb = 0;
+
+            if (pool)
+            {
+                p = sentinel_sub(p);
+                auto biti = cast(size_t)(p - pool.baseAddr) >> pool.shiftBy;
+
+                oldb = pool.getBits(biti);
+                pool.setBits(biti, mask);
+            }
+            return oldb;
+        }
+
+        return runLocked!(go, otherTime, numOthers)(gcx, p, mask);
+    }
+
+
+    /**
+     *
+     */
+    uint clrAttr(void* p, uint mask) nothrow
+    {
+        if (!p)
+        {
+            return 0;
+        }
+
+        static uint go(Gcx* gcx, void* p, uint mask) nothrow
+        {
+            Pool* pool = gcx.findPool(p);
+            uint  oldb = 0;
+
+            if (pool)
+            {
+                p = sentinel_sub(p);
+                auto biti = cast(size_t)(p - pool.baseAddr) >> pool.shiftBy;
+
+                oldb = pool.getBits(biti);
+                pool.clrBits(biti, mask);
+            }
+            return oldb;
+        }
+
+        return runLocked!(go, otherTime, numOthers)(gcx, p, mask);
+    }
+
+    /**
+     *
+     */
+    void *malloc(size_t size, uint bits = 0, size_t *alloc_size = null, const TypeInfo ti = null) nothrow
+    {
+        if (!size)
+        {
+            if(alloc_size)
+                *alloc_size = 0;
+            return null;
+        }
+
+        size_t localAllocSize = void;
+        if(alloc_size is null) alloc_size = &localAllocSize;
+
+        auto p = runLocked!(mallocNoSync, mallocTime, numMallocs)(size, bits, *alloc_size, ti);
+
+        if (!(bits & BlkAttr.NO_SCAN))
+        {
+            memset(p + size, 0, *alloc_size - size);
+        }
+
+        return p;
+    }
+
+
+    //
+    //
+    //
+    private void *mallocNoSync(size_t size, uint bits, ref size_t alloc_size, const TypeInfo ti = null) nothrow
+    {
+        assert(size != 0);
+
+        //debug(PRINTF) printf("GC::malloc(size = %d, gcx = %p)\n", size, gcx);
+        assert(gcx);
+        //debug(PRINTF) printf("gcx.self = %x, pthread_self() = %x\n", gcx.self, pthread_self());
+
+        auto p = gcx.alloc(size + SENTINEL_EXTRA, alloc_size, bits);
+        if (!p)
+            onOutOfMemoryErrorNoGC();
+
+        debug (SENTINEL)
+        {
+            p = sentinel_add(p);
+            sentinel_init(p, size);
+            alloc_size = size;
+        }
+        gcx.log_malloc(p, size);
+
+        return p;
+    }
+
+
+    /**
+     *
+     */
+    void *calloc(size_t size, uint bits = 0, size_t *alloc_size = null, const TypeInfo ti = null) nothrow
+    {
+        if (!size)
+        {
+            if(alloc_size)
+                *alloc_size = 0;
+            return null;
+        }
+
+        size_t localAllocSize = void;
+        if(alloc_size is null) alloc_size = &localAllocSize;
+
+        auto p = runLocked!(mallocNoSync, mallocTime, numMallocs)(size, bits, *alloc_size, ti);
+
+        memset(p, 0, size);
+        if (!(bits & BlkAttr.NO_SCAN))
+        {
+            memset(p + size, 0, *alloc_size - size);
+        }
+
+        return p;
+    }
+
+    /**
+     *
+     */
+    void *realloc(void *p, size_t size, uint bits = 0, size_t *alloc_size = null, const TypeInfo ti = null) nothrow
+    {
+        size_t localAllocSize = void;
+        auto oldp = p;
+        if(alloc_size is null) alloc_size = &localAllocSize;
+
+        p = runLocked!(reallocNoSync, mallocTime, numMallocs)(p, size, bits, *alloc_size, ti);
+
+        if (p !is oldp && !(bits & BlkAttr.NO_SCAN))
+        {
+            memset(p + size, 0, *alloc_size - size);
+        }
+
+        return p;
+    }
+
+
+    //
+    // bits will be set to the resulting bits of the new block
+    //
+    private void *reallocNoSync(void *p, size_t size, ref uint bits, ref size_t alloc_size, const TypeInfo ti = null) nothrow
+    {
+        if (!size)
+        {   if (p)
+            {   freeNoSync(p);
+                p = null;
+            }
+            alloc_size = 0;
+        }
+        else if (!p)
+        {
+            p = mallocNoSync(size, bits, alloc_size, ti);
+        }
+        else
+        {   void *p2;
+            size_t psize;
+
+            //debug(PRINTF) printf("GC::realloc(p = %p, size = %zu)\n", p, size);
+            debug (SENTINEL)
+            {
+                sentinel_Invariant(p);
+                psize = *sentinel_size(p);
+                if (psize != size)
+                {
+                    if (psize)
+                    {
+                        Pool *pool = gcx.findPool(p);
+
+                        if (pool)
+                        {
+                            auto biti = cast(size_t)(sentinel_sub(p) - pool.baseAddr) >> pool.shiftBy;
+
+                            if (bits)
+                            {
+                                pool.clrBits(biti, ~BlkAttr.NONE);
+                                pool.setBits(biti, bits);
+                            }
+                            else
+                            {
+                                bits = pool.getBits(biti);
+                            }
+                        }
+                    }
+                    p2 = mallocNoSync(size, bits, alloc_size, ti);
+                    if (psize < size)
+                        size = psize;
+                    //debug(PRINTF) printf("\tcopying %d bytes\n",size);
+                    memcpy(p2, p, size);
+                    p = p2;
+                }
+            }
+            else
+            {
+                auto pool = gcx.findPool(p);
+                if (pool.isLargeObject)
+                {
+                    auto lpool = cast(LargeObjectPool*) pool;
+                    psize = lpool.getSize(p);     // get allocated size
+
+                    if (size <= PAGESIZE / 2)
+                        goto Lmalloc; // switching from large object pool to small object pool
+
+                    auto psz = psize / PAGESIZE;
+                    auto newsz = (size + PAGESIZE - 1) / PAGESIZE;
+                    if (newsz == psz)
+                    {
+                        alloc_size = psize;
+                        return p;
+                    }
+
+                    auto pagenum = lpool.pagenumOf(p);
+
+                    if (newsz < psz)
+                    {   // Shrink in place
+                        debug (MEMSTOMP) memset(p + size, 0xF2, psize - size);
+                        lpool.freePages(pagenum + newsz, psz - newsz);
+                    }
+                    else if (pagenum + newsz <= pool.npages)
+                    {   // Attempt to expand in place
+                        foreach (binsz; lpool.pagetable[pagenum + psz .. pagenum + newsz])
+                            if (binsz != B_FREE)
+                                goto Lmalloc;
+
+                        debug (MEMSTOMP) memset(p + psize, 0xF0, size - psize);
+                        debug(PRINTF) printFreeInfo(pool);
+                        memset(&lpool.pagetable[pagenum + psz], B_PAGEPLUS, newsz - psz);
+                        gcx.usedLargePages += newsz - psz;
+                        lpool.freepages -= (newsz - psz);
+                        debug(PRINTF) printFreeInfo(pool);
+                    }
+                    else
+                        goto Lmalloc; // does not fit into current pool
+
+                    lpool.updateOffsets(pagenum);
+                    if (bits)
+                    {
+                        immutable biti = cast(size_t)(p - pool.baseAddr) >> pool.shiftBy;
+                        pool.clrBits(biti, ~BlkAttr.NONE);
+                        pool.setBits(biti, bits);
+                    }
+                    alloc_size = newsz * PAGESIZE;
+                    return p;
+                }
+
+                psize = (cast(SmallObjectPool*) pool).getSize(p);   // get allocated size
+                if (psize < size ||             // if new size is bigger
+                    psize > size * 2)           // or less than half
+                {
+                Lmalloc:
+                    if (psize && pool)
+                    {
+                        auto biti = cast(size_t)(p - pool.baseAddr) >> pool.shiftBy;
+
+                        if (bits)
+                        {
+                            pool.clrBits(biti, ~BlkAttr.NONE);
+                            pool.setBits(biti, bits);
+                        }
+                        else
+                        {
+                            bits = pool.getBits(biti);
+                        }
+                    }
+                    p2 = mallocNoSync(size, bits, alloc_size, ti);
+                    if (psize < size)
+                        size = psize;
+                    //debug(PRINTF) printf("\tcopying %d bytes\n",size);
+                    memcpy(p2, p, size);
+                    p = p2;
+                }
+                else
+                    alloc_size = psize;
+            }
+        }
+        return p;
+    }
+
+
+    /**
+     * Attempt to in-place enlarge the memory block pointed to by p by at least
+     * minsize bytes, up to a maximum of maxsize additional bytes.
+     * This does not attempt to move the memory block (like realloc() does).
+     *
+     * Returns:
+     *  0 if could not extend p,
+     *  total size of entire memory block if successful.
+     */
+    size_t extend(void* p, size_t minsize, size_t maxsize, const TypeInfo ti = null) nothrow
+    {
+        return runLocked!(extendNoSync, extendTime, numExtends)(p, minsize, maxsize, ti);
+    }
+
+
+    //
+    //
+    //
+    private size_t extendNoSync(void* p, size_t minsize, size_t maxsize, const TypeInfo ti = null) nothrow
+    in
+    {
+        assert(minsize <= maxsize);
+    }
+    body
+    {
+        //debug(PRINTF) printf("GC::extend(p = %p, minsize = %zu, maxsize = %zu)\n", p, minsize, maxsize);
+        debug (SENTINEL)
+        {
+            return 0;
+        }
+        else
+        {
+            auto pool = gcx.findPool(p);
+            if (!pool || !pool.isLargeObject)
+                return 0;
+
+            auto lpool = cast(LargeObjectPool*) pool;
+            auto psize = lpool.getSize(p);   // get allocated size
+            if (psize < PAGESIZE)
+                return 0;                   // cannot extend buckets
+
+            auto psz = psize / PAGESIZE;
+            auto minsz = (minsize + PAGESIZE - 1) / PAGESIZE;
+            auto maxsz = (maxsize + PAGESIZE - 1) / PAGESIZE;
+
+            auto pagenum = lpool.pagenumOf(p);
+
+            size_t sz;
+            for (sz = 0; sz < maxsz; sz++)
+            {
+                auto i = pagenum + psz + sz;
+                if (i == lpool.npages)
+                    break;
+                if (lpool.pagetable[i] != B_FREE)
+                {   if (sz < minsz)
+                        return 0;
+                    break;
+                }
+            }
+            if (sz < minsz)
+                return 0;
+            debug (MEMSTOMP) memset(pool.baseAddr + (pagenum + psz) * PAGESIZE, 0xF0, sz * PAGESIZE);
+            memset(lpool.pagetable + pagenum + psz, B_PAGEPLUS, sz);
+            lpool.updateOffsets(pagenum);
+            lpool.freepages -= sz;
+            gcx.usedLargePages += sz;
+            return (psz + sz) * PAGESIZE;
+        }
+    }
+
+
+    /**
+     *
+     */
+    size_t reserve(size_t size) nothrow
+    {
+        if (!size)
+        {
+            return 0;
+        }
+
+        return runLocked!(reserveNoSync, otherTime, numOthers)(size);
+    }
+
+
+    //
+    //
+    //
+    private size_t reserveNoSync(size_t size) nothrow
+    {
+        assert(size != 0);
+        assert(gcx);
+
+        return gcx.reserve(size);
+    }
+
+
+    /**
+     *
+     */
+    void free(void *p) nothrow
+    {
+        if (!p || inFinalizer)
+        {
+            return;
+        }
+
+        return runLocked!(freeNoSync, freeTime, numFrees)(p);
+    }
+
+
+    //
+    //
+    //
+    private void freeNoSync(void *p) nothrow
+    {
+        debug(PRINTF) printf("Freeing %p\n", cast(size_t) p);
+        assert (p);
+
+        Pool*  pool;
+        size_t pagenum;
+        Bins   bin;
+        size_t biti;
+
+        // Find which page it is in
+        pool = gcx.findPool(p);
+        if (!pool)                              // if not one of ours
+            return;                             // ignore
+
+        pagenum = pool.pagenumOf(p);
+
+        debug(PRINTF) printf("pool base = %p, PAGENUM = %d of %d, bin = %d\n", pool.baseAddr, pagenum, pool.npages, pool.pagetable[pagenum]);
+        debug(PRINTF) if(pool.isLargeObject) printf("Block size = %d\n", pool.bPageOffsets[pagenum]);
+
+        bin = cast(Bins)pool.pagetable[pagenum];
+
+        // Verify that the pointer is at the beginning of a block,
+        //  no action should be taken if p is an interior pointer
+        if (bin > B_PAGE) // B_PAGEPLUS or B_FREE
+            return;
+        if ((sentinel_sub(p) - pool.baseAddr) & (binsize[bin] - 1))
+            return;
+
+        sentinel_Invariant(p);
+        p = sentinel_sub(p);
+        biti = cast(size_t)(p - pool.baseAddr) >> pool.shiftBy;
+
+        pool.clrBits(biti, ~BlkAttr.NONE);
+
+        if (pool.isLargeObject)              // if large alloc
+        {
+            assert(bin == B_PAGE);
+            auto lpool = cast(LargeObjectPool*) pool;
+
+            // Free pages
+            size_t npages = lpool.bPageOffsets[pagenum];
+            debug (MEMSTOMP) memset(p, 0xF2, npages * PAGESIZE);
+            lpool.freePages(pagenum, npages);
+        }
+        else
+        {   // Add to free list
+            List *list = cast(List*)p;
+
+            debug (MEMSTOMP) memset(p, 0xF2, binsize[bin]);
+
+            list.next = gcx.bucket[bin];
+            list.pool = pool;
+            gcx.bucket[bin] = list;
+        }
+
+        gcx.log_free(sentinel_add(p));
+    }
+
+
+    /**
+     * Determine the base address of the block containing p.  If p is not a gc
+     * allocated pointer, return null.
+     */
+    void* addrOf(void *p) nothrow
+    {
+        if (!p)
+        {
+            return null;
+        }
+
+        return runLocked!(addrOfNoSync, otherTime, numOthers)(p);
+    }
+
+
+    //
+    //
+    //
+    void* addrOfNoSync(void *p) nothrow
+    {
+        if (!p)
+        {
+            return null;
+        }
+
+        auto q = gcx.findBase(p);
+        if (q)
+            q = sentinel_add(q);
+        return q;
+    }
+
+
+    /**
+     * Determine the allocated size of pointer p.  If p is an interior pointer
+     * or not a gc allocated pointer, return 0.
+     */
+    size_t sizeOf(void *p) nothrow
+    {
+        if (!p)
+        {
+            return 0;
+        }
+
+        return runLocked!(sizeOfNoSync, otherTime, numOthers)(p);
+    }
+
+
+    //
+    //
+    //
+    private size_t sizeOfNoSync(void *p) nothrow
+    {
+        assert (p);
+
+        debug (SENTINEL)
+        {
+            p = sentinel_sub(p);
+            size_t size = gcx.findSize(p);
+
+            // Check for interior pointer
+            // This depends on:
+            // 1) size is a power of 2 for less than PAGESIZE values
+            // 2) base of memory pool is aligned on PAGESIZE boundary
+            if (cast(size_t)p & (size - 1) & (PAGESIZE - 1))
+                size = 0;
+            return size ? size - SENTINEL_EXTRA : 0;
+        }
+        else
+        {
+            size_t size = gcx.findSize(p);
+
+            // Check for interior pointer
+            // This depends on:
+            // 1) size is a power of 2 for less than PAGESIZE values
+            // 2) base of memory pool is aligned on PAGESIZE boundary
+            if (cast(size_t)p & (size - 1) & (PAGESIZE - 1))
+                return 0;
+            return size;
+        }
+    }
+
+
+    /**
+     * Determine the base address of the block containing p.  If p is not a gc
+     * allocated pointer, return null.
+     */
+    BlkInfo query(void *p) nothrow
+    {
+        if (!p)
+        {
+            BlkInfo i;
+            return  i;
+        }
+
+        return runLocked!(queryNoSync, otherTime, numOthers)(p);
+    }
+
+
+    //
+    //
+    //
+    BlkInfo queryNoSync(void *p) nothrow
+    {
+        assert(p);
+
+        BlkInfo info = gcx.getInfo(p);
+        debug(SENTINEL)
+        {
+            if (info.base)
+            {
+                info.base = sentinel_add(info.base);
+                info.size = *sentinel_size(info.base);
+            }
+        }
+        return info;
+    }
+
+
+    /**
+     * Verify that pointer p:
+     *  1) belongs to this memory pool
+     *  2) points to the start of an allocated piece of memory
+     *  3) is not on a free list
+     */
+    void check(void *p) nothrow
+    {
+        if (!p)
+        {
+            return;
+        }
+
+        return runLocked!(checkNoSync, otherTime, numOthers)(p);
+    }
+
+
+    //
+    //
+    //
+    private void checkNoSync(void *p) nothrow
+    {
+        assert(p);
+
+        sentinel_Invariant(p);
+        debug (PTRCHECK)
+        {
+            Pool*  pool;
+            size_t pagenum;
+            Bins   bin;
+            size_t size;
+
+            p = sentinel_sub(p);
+            pool = gcx.findPool(p);
+            assert(pool);
+            pagenum = pool.pagenumOf(p);
+            bin = cast(Bins)pool.pagetable[pagenum];
+            assert(bin <= B_PAGE);
+            size = binsize[bin];
+            assert((cast(size_t)p & (size - 1)) == 0);
+
+            debug (PTRCHECK2)
+            {
+                if (bin < B_PAGE)
+                {
+                    // Check that p is not on a free list
+                    List *list;
+
+                    for (list = gcx.bucket[bin]; list; list = list.next)
+                    {
+                        assert(cast(void*)list != p);
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * add p to list of roots
+     */
+    void addRoot(void *p) nothrow
+    {
+        if (!p)
+        {
+            return;
+        }
+
+        gcx.addRoot(p);
+    }
+
+
+    /**
+     * remove p from list of roots
+     */
+    void removeRoot(void *p) nothrow
+    {
+        if (!p)
+        {
+            return;
+        }
+
+        gcx.removeRoot(p);
+    }
+
+
+    /**
+     *
+     */
+    @property auto rootIter() @nogc
+    {
+        return &gcx.rootsApply;
+    }
+
+
+    /**
+     * add range to scan for roots
+     */
+    void addRange(void *p, size_t sz, const TypeInfo ti = null) nothrow @nogc
+    {
+        if (!p || !sz)
+        {
+            return;
+        }
+
+        gcx.addRange(p, p + sz, ti);
+    }
+
+
+    /**
+     * remove range
+     */
+    void removeRange(void *p) nothrow @nogc
+    {
+        if (!p)
+        {
+            return;
+        }
+
+        gcx.removeRange(p);
+    }
+
+
+    /**
+     *
+     */
+    @property auto rangeIter() @nogc
+    {
+        return &gcx.rangesApply;
+    }
+
+
+    /**
+     * run finalizers
+     */
+    void runFinalizers(in void[] segment) nothrow
+    {
+        static void go(Gcx* gcx, in void[] segment) nothrow
+        {
+            gcx.runFinalizers(segment);
+        }
+        return runLocked!(go, otherTime, numOthers)(gcx, segment);
+    }
+
+
+    /**
+     * Do full garbage collection.
+     * Return number of pages free'd.
+     */
+    size_t fullCollect() nothrow
+    {
+        debug(PRINTF) printf("GC.fullCollect()\n");
+
+        // Since a finalizer could launch a new thread, we always need to lock
+        // when collecting.
+        static size_t go(Gcx* gcx) nothrow
+        {
+            return gcx.fullcollect();
+        }
+        immutable result = runLocked!go(gcx);
+
+        version (none)
+        {
+            GCStats stats;
+
+            getStats(stats);
+            debug(PRINTF) printf("poolsize = %zx, usedsize = %zx, freelistsize = %zx\n",
+                    stats.poolsize, stats.usedsize, stats.freelistsize);
+        }
+
+        gcx.log_collect();
+        return result;
+    }
+
+
+    /**
+     * do full garbage collection ignoring roots
+     */
+    void fullCollectNoStack() nothrow
+    {
+        // Since a finalizer could launch a new thread, we always need to lock
+        // when collecting.
+        static size_t go(Gcx* gcx) nothrow
+        {
+            return gcx.fullcollect(true);
+        }
+        runLocked!go(gcx);
+    }
+
+
+    /**
+     * minimize free space usage
+     */
+    void minimize() nothrow
+    {
+        static void go(Gcx* gcx) nothrow
+        {
+            gcx.minimize();
+        }
+        runLocked!(go, otherTime, numOthers)(gcx);
+    }
+
+
+    /**
+     * Retrieve statistics about garbage collection.
+     * Useful for debugging and tuning.
+     */
+    void getStats(out GCStats stats) nothrow
+    {
+        return runLocked!(getStatsNoSync, otherTime, numOthers)(stats);
+    }
+
+
+    //
+    //
+    //
+    private void getStatsNoSync(out GCStats stats) nothrow
+    {
+        size_t psize = 0;
+        size_t usize = 0;
+        size_t flsize = 0;
+
+        size_t n;
+        size_t bsize = 0;
+
+        //debug(PRINTF) printf("getStats()\n");
+        memset(&stats, 0, GCStats.sizeof);
+
+        for (n = 0; n < gcx.npools; n++)
+        {   Pool *pool = gcx.pooltable[n];
+
+            psize += pool.npages * PAGESIZE;
+            for (size_t j = 0; j < pool.npages; j++)
+            {
+                Bins bin = cast(Bins)pool.pagetable[j];
+                if (bin == B_FREE)
+                    stats.freeblocks++;
+                else if (bin == B_PAGE)
+                    stats.pageblocks++;
+                else if (bin < B_PAGE)
+                    bsize += PAGESIZE;
+            }
+        }
+
+        for (n = 0; n < B_PAGE; n++)
+        {
+            //debug(PRINTF) printf("bin %d\n", n);
+            for (List *list = gcx.bucket[n]; list; list = list.next)
+            {
+                //debug(PRINTF) printf("\tlist %p\n", list);
+                flsize += binsize[n];
+            }
+        }
+
+        usize = bsize - flsize;
+
+        stats.poolsize = psize;
+        stats.usedsize = bsize - flsize;
+        stats.freelistsize = flsize;
+    }
+}
+
+
+/* ============================ Gcx =============================== */
+
+enum
+{   PAGESIZE =    4096,
+    POOLSIZE =   (4096*256),
+}
+
+
+enum
+{
+    B_16,
+    B_32,
+    B_64,
+    B_128,
+    B_256,
+    B_512,
+    B_1024,
+    B_2048,
+    B_PAGE,             // start of large alloc
+    B_PAGEPLUS,         // continuation of large alloc
+    B_FREE,             // free page
+    B_MAX
+}
+
+
+alias ubyte Bins;
+
+
+struct List
+{
+    List *next;
+    Pool *pool;
+}
+
+
+struct Range
+{
+    void *pbot;
+    void *ptop;
+    alias pbot this; // only consider pbot for relative ordering (opCmp)
+}
+
+struct Root
+{
+    void *proot;
+    alias proot this;
+}
+
+
+immutable uint[B_MAX] binsize = [ 16,32,64,128,256,512,1024,2048,4096 ];
+immutable size_t[B_MAX] notbinsize = [ ~(16-1),~(32-1),~(64-1),~(128-1),~(256-1),
+                                ~(512-1),~(1024-1),~(2048-1),~(4096-1) ];
+
+alias PageBits = GCBits.wordtype[PAGESIZE / 16 / GCBits.BITS_PER_WORD];
+static assert(PAGESIZE % (GCBits.BITS_PER_WORD * 16) == 0);
+
+private void set(ref PageBits bits, size_t i) @nogc pure nothrow
+{
+    assert(i < PageBits.sizeof * 8);
+    bts(bits.ptr, i);
+}
+
+/* ============================ Gcx =============================== */
+
+struct Gcx
+{
+    import core.internal.spinlock;
+    auto rootsLock = shared(AlignedSpinLock)(SpinLock.Contention.brief);
+    auto rangesLock = shared(AlignedSpinLock)(SpinLock.Contention.brief);
+    Treap!Root roots;
+    Treap!Range ranges;
+
+    bool log; // turn on logging
+    debug(INVARIANT) bool initialized;
+    uint disabled; // turn off collections if >0
+
+    import gc.pooltable;
+    @property size_t npools() pure const nothrow { return pooltable.length; }
+    PoolTable!Pool pooltable;
+
+    List*[B_PAGE] bucket; // free list for each small size
+
+    // run a collection when reaching those thresholds (number of used pages)
+    float smallCollectThreshold, largeCollectThreshold;
+    uint usedSmallPages, usedLargePages;
+    // total number of mapped pages
+    uint mappedPages;
+
+    void initialize()
+    {
+        (cast(byte*)&this)[0 .. Gcx.sizeof] = 0;
+        log_init();
+        roots.initialize();
+        ranges.initialize();
+        smallCollectThreshold = largeCollectThreshold = 0.0f;
+        usedSmallPages = usedLargePages = 0;
+        mappedPages = 0;
+        //printf("gcx = %p, self = %x\n", &this, self);
+        debug(INVARIANT) initialized = true;
+    }
+
+
+    void Dtor()
+    {
+        if (GC.config.profile)
+        {
+            printf("\tNumber of collections:  %llu\n", cast(ulong)numCollections);
+            printf("\tTotal GC prep time:  %lld milliseconds\n",
+                   prepTime.total!("msecs"));
+            printf("\tTotal mark time:  %lld milliseconds\n",
+                   markTime.total!("msecs"));
+            printf("\tTotal sweep time:  %lld milliseconds\n",
+                   sweepTime.total!("msecs"));
+            printf("\tTotal page recovery time:  %lld milliseconds\n",
+                   recoverTime.total!("msecs"));
+            long maxPause = maxPauseTime.total!("msecs");
+            printf("\tMax Pause Time:  %lld milliseconds\n", maxPause);
+            long gcTime = (recoverTime + sweepTime + markTime + prepTime).total!("msecs");
+            printf("\tGrand total GC time:  %lld milliseconds\n", gcTime);
+            long pauseTime = (markTime + prepTime).total!("msecs");
+
+            char[30] apitxt;
+            apitxt[0] = 0;
+            debug(PROFILE_API) if (GC.config.profile > 1)
+            {
+                static Duration toDuration(long dur)
+                {
+                    return MonoTime(dur) - MonoTime(0);
+                }
+
+                printf("\n");
+                printf("\tmalloc:  %llu calls, %lld ms\n", cast(ulong)numMallocs, toDuration(mallocTime).total!"msecs");
+                printf("\trealloc: %llu calls, %lld ms\n", cast(ulong)numReallocs, toDuration(reallocTime).total!"msecs");
+                printf("\tfree:    %llu calls, %lld ms\n", cast(ulong)numFrees, toDuration(freeTime).total!"msecs");
+                printf("\textend:  %llu calls, %lld ms\n", cast(ulong)numExtends, toDuration(extendTime).total!"msecs");
+                printf("\tother:   %llu calls, %lld ms\n", cast(ulong)numOthers, toDuration(otherTime).total!"msecs");
+                printf("\tlock time: %lld ms\n", toDuration(lockTime).total!"msecs");
+
+                long apiTime = mallocTime + reallocTime + freeTime + extendTime + otherTime + lockTime;
+                printf("\tGC API: %lld ms\n", toDuration(apiTime).total!"msecs");
+                sprintf(apitxt.ptr, " API%5ld ms", toDuration(apiTime).total!"msecs");
+            }
+
+            printf("GC summary:%5lld MB,%5lld GC%5lld ms, Pauses%5lld ms <%5lld ms%s\n",
+                   cast(long) maxPoolMemory >> 20, cast(ulong)numCollections, gcTime,
+                   pauseTime, maxPause, apitxt.ptr);
+        }
+
+        debug(INVARIANT) initialized = false;
+
+        for (size_t i = 0; i < npools; i++)
+        {
+            Pool *pool = pooltable[i];
+            mappedPages -= pool.npages;
+            pool.Dtor();
+            cstdlib.free(pool);
+        }
+        assert(!mappedPages);
+        pooltable.Dtor();
+
+        roots.removeAll();
+        ranges.removeAll();
+        toscan.reset();
+    }
+
+
+    void Invariant() const { }
+
+    debug(INVARIANT)
+    invariant()
+    {
+        if (initialized)
+        {
+            //printf("Gcx.invariant(): this = %p\n", &this);
+            pooltable.Invariant();
+
+            rangesLock.lock();
+            foreach (range; ranges)
+            {
+                assert(range.pbot);
+                assert(range.ptop);
+                assert(range.pbot <= range.ptop);
+            }
+            rangesLock.unlock();
+
+            for (size_t i = 0; i < B_PAGE; i++)
+            {
+                for (auto list = cast(List*)bucket[i]; list; list = list.next)
+                {
+                }
+            }
+        }
+    }
+
+
+    /**
+     *
+     */
+    void addRoot(void *p) nothrow
+    {
+        rootsLock.lock();
+        scope (failure) rootsLock.unlock();
+        roots.insert(Root(p));
+        rootsLock.unlock();
+    }
+
+
+    /**
+     *
+     */
+    void removeRoot(void *p) nothrow
+    {
+        rootsLock.lock();
+        scope (failure) rootsLock.unlock();
+        roots.remove(Root(p));
+        rootsLock.unlock();
+    }
+
+
+    /**
+     *
+     */
+    int rootsApply(scope int delegate(ref Root) nothrow dg) nothrow
+    {
+        rootsLock.lock();
+        scope (failure) rootsLock.unlock();
+        auto ret = roots.opApply(dg);
+        rootsLock.unlock();
+        return ret;
+    }
+
+
+    /**
+     *
+     */
+    void addRange(void *pbot, void *ptop, const TypeInfo ti) nothrow @nogc
+    {
+        //debug(PRINTF) printf("Thread %x ", pthread_self());
+        debug(PRINTF) printf("%p.Gcx::addRange(%p, %p)\n", &this, pbot, ptop);
+        rangesLock.lock();
+        scope (failure) rangesLock.unlock();
+        ranges.insert(Range(pbot, ptop));
+        rangesLock.unlock();
+    }
+
+
+    /**
+     *
+     */
+    void removeRange(void *pbot) nothrow @nogc
+    {
+        //debug(PRINTF) printf("Thread %x ", pthread_self());
+        debug(PRINTF) printf("Gcx.removeRange(%p)\n", pbot);
+        rangesLock.lock();
+        scope (failure) rangesLock.unlock();
+        ranges.remove(Range(pbot, pbot)); // only pbot is used, see Range.opCmp
+        rangesLock.unlock();
+
+        // debug(PRINTF) printf("Wrong thread\n");
+        // This is a fatal error, but ignore it.
+        // The problem is that we can get a Close() call on a thread
+        // other than the one the range was allocated on.
+        //assert(zero);
+    }
+
+    /**
+     *
+     */
+    int rangesApply(scope int delegate(ref Range) nothrow dg) nothrow
+    {
+        rangesLock.lock();
+        scope (failure) rangesLock.unlock();
+        auto ret = ranges.opApply(dg);
+        rangesLock.unlock();
+        return ret;
+    }
+
+
+    /**
+     *
+     */
+    void runFinalizers(in void[] segment) nothrow
+    {
+        GC.inFinalizer = true;
+        scope (failure) GC.inFinalizer = false;
+
+        foreach (pool; pooltable[0 .. npools])
+        {
+            if (!pool.finals.nbits) continue;
+
+            if (pool.isLargeObject)
+            {
+                auto lpool = cast(LargeObjectPool*) pool;
+                lpool.runFinalizers(segment);
+            }
+            else
+            {
+                auto spool = cast(SmallObjectPool*) pool;
+                spool.runFinalizers(segment);
+            }
+        }
+        GC.inFinalizer = false;
+    }
+
+    Pool* findPool(void* p) pure nothrow
+    {
+        return pooltable.findPool(p);
+    }
+
+    /**
+     * Find base address of block containing pointer p.
+     * Returns null if not a gc'd pointer
+     */
+    void* findBase(void *p) nothrow
+    {
+        Pool *pool;
+
+        pool = findPool(p);
+        if (pool)
+        {
+            size_t offset = cast(size_t)(p - pool.baseAddr);
+            size_t pn = offset / PAGESIZE;
+            Bins   bin = cast(Bins)pool.pagetable[pn];
+
+            // Adjust bit to be at start of allocated memory block
+            if (bin <= B_PAGE)
+            {
+                return pool.baseAddr + (offset & notbinsize[bin]);
+            }
+            else if (bin == B_PAGEPLUS)
+            {
+                auto pageOffset = pool.bPageOffsets[pn];
+                offset -= pageOffset * PAGESIZE;
+                pn -= pageOffset;
+
+                return pool.baseAddr + (offset & (offset.max ^ (PAGESIZE-1)));
+            }
+            else
+            {
+                // we are in a B_FREE page
+                assert(bin == B_FREE);
+                return null;
+            }
+        }
+        return null;
+    }
+
+
+    /**
+     * Find size of pointer p.
+     * Returns 0 if not a gc'd pointer
+     */
+    size_t findSize(void *p) nothrow
+    {
+        Pool* pool = findPool(p);
+        if (pool)
+            return pool.slGetSize(p);
+        return 0;
+    }
+
+    /**
+     *
+     */
+    BlkInfo getInfo(void* p) nothrow
+    {
+        Pool* pool = findPool(p);
+        if (pool)
+            return pool.slGetInfo(p);
+        return BlkInfo();
+    }
+
+    /**
+     * Computes the bin table using CTFE.
+     */
+    static byte[2049] ctfeBins() nothrow
+    {
+        byte[2049] ret;
+        size_t p = 0;
+        for (Bins b = B_16; b <= B_2048; b++)
+            for ( ; p <= binsize[b]; p++)
+                ret[p] = b;
+
+        return ret;
+    }
+
+    static const byte[2049] binTable = ctfeBins();
+
+    /**
+     * Allocate a new pool of at least size bytes.
+     * Sort it into pooltable[].
+     * Mark all memory in the pool as B_FREE.
+     * Return the actual number of bytes reserved or 0 on error.
+     */
+    size_t reserve(size_t size) nothrow
+    {
+        size_t npages = (size + PAGESIZE - 1) / PAGESIZE;
+
+        // Assume reserve() is for small objects.
+        Pool*  pool = newPool(npages, false);
+
+        if (!pool)
+            return 0;
+        return pool.npages * PAGESIZE;
+    }
+
+    /**
+     * Update the thresholds for when to collect the next time
+     */
+    void updateCollectThresholds() nothrow
+    {
+        static float max(float a, float b) nothrow
+        {
+            return a >= b ? a : b;
+        }
+
+        // instantly increases, slowly decreases
+        static float smoothDecay(float oldVal, float newVal) nothrow
+        {
+            // decay to 63.2% of newVal over 5 collections
+            // http://en.wikipedia.org/wiki/Low-pass_filter#Simple_infinite_impulse_response_filter
+            enum alpha = 1.0 / (5 + 1);
+            immutable decay = (newVal - oldVal) * alpha + oldVal;
+            return max(newVal, decay);
+        }
+
+        immutable smTarget = usedSmallPages * GC.config.heapSizeFactor;
+        smallCollectThreshold = smoothDecay(smallCollectThreshold, smTarget);
+        immutable lgTarget = usedLargePages * GC.config.heapSizeFactor;
+        largeCollectThreshold = smoothDecay(largeCollectThreshold, lgTarget);
+    }
+
+    /**
+     * Minimizes physical memory usage by returning free pools to the OS.
+     */
+    void minimize() nothrow
+    {
+        debug(PRINTF) printf("Minimizing.\n");
+
+        foreach (pool; pooltable.minimize())
+        {
+            debug(PRINTF) printFreeInfo(pool);
+            mappedPages -= pool.npages;
+            pool.Dtor();
+            cstdlib.free(pool);
+        }
+
+        debug(PRINTF) printf("Done minimizing.\n");
+    }
+
+    private @property bool lowMem() const nothrow
+    {
+        return isLowOnMem(mappedPages * PAGESIZE);
+    }
+
+    void* alloc(size_t size, ref size_t alloc_size, uint bits) nothrow
+    {
+        return size <= 2048 ? smallAlloc(binTable[size], alloc_size, bits)
+                            : bigAlloc(size, alloc_size, bits);
+    }
+
+    void* smallAlloc(Bins bin, ref size_t alloc_size, uint bits) nothrow
+    {
+        alloc_size = binsize[bin];
+
+        void* p;
+        bool tryAlloc() nothrow
+        {
+            if (!bucket[bin])
+            {
+                bucket[bin] = allocPage(bin);
+                if (!bucket[bin])
+                    return false;
+            }
+            p = bucket[bin];
+            return true;
+        }
+
+        if (!tryAlloc())
+        {
+            if (!lowMem && (disabled || usedSmallPages < smallCollectThreshold))
+            {
+                // disabled or threshold not reached => allocate a new pool instead of collecting
+                if (!newPool(1, false))
+                {
+                    // out of memory => try to free some memory
+                    fullcollect();
+                    if (lowMem) minimize();
+                }
+            }
+            else
+            {
+                fullcollect();
+                if (lowMem) minimize();
+            }
+            // tryAlloc will succeed if a new pool was allocated above, if it fails allocate a new pool now
+            if (!tryAlloc() && (!newPool(1, false) || !tryAlloc()))
+                // out of luck or memory
+                onOutOfMemoryErrorNoGC();
+        }
+        assert(p !is null);
+
+        // Return next item from free list
+        bucket[bin] = (cast(List*)p).next;
+        auto pool = (cast(List*)p).pool;
+        if (bits)
+            pool.setBits((p - pool.baseAddr) >> pool.shiftBy, bits);
+        //debug(PRINTF) printf("\tmalloc => %p\n", p);
+        debug (MEMSTOMP) memset(p, 0xF0, alloc_size);
+        return p;
+    }
+
+    /**
+     * Allocate a chunk of memory that is larger than a page.
+     * Return null if out of memory.
+     */
+    void* bigAlloc(size_t size, ref size_t alloc_size, uint bits, const TypeInfo ti = null) nothrow
+    {
+        debug(PRINTF) printf("In bigAlloc.  Size:  %d\n", size);
+
+        LargeObjectPool* pool;
+        size_t pn;
+        immutable npages = (size + PAGESIZE - 1) / PAGESIZE;
+
+        bool tryAlloc() nothrow
+        {
+            foreach (p; pooltable[0 .. npools])
+            {
+                if (!p.isLargeObject || p.freepages < npages)
+                    continue;
+                auto lpool = cast(LargeObjectPool*) p;
+                if ((pn = lpool.allocPages(npages)) == OPFAIL)
+                    continue;
+                pool = lpool;
+                return true;
+            }
+            return false;
+        }
+
+        bool tryAllocNewPool() nothrow
+        {
+            pool = cast(LargeObjectPool*) newPool(npages, true);
+            if (!pool) return false;
+            pn = pool.allocPages(npages);
+            assert(pn != OPFAIL);
+            return true;
+        }
+
+        if (!tryAlloc())
+        {
+            if (!lowMem && (disabled || usedLargePages < largeCollectThreshold))
+            {
+                // disabled or threshold not reached => allocate a new pool instead of collecting
+                if (!tryAllocNewPool())
+                {
+                    // disabled but out of memory => try to free some memory
+                    fullcollect();
+                    minimize();
+                }
+            }
+            else
+            {
+                fullcollect();
+                minimize();
+            }
+            // If alloc didn't yet succeed retry now that we collected/minimized
+            if (!pool && !tryAlloc() && !tryAllocNewPool())
+                // out of luck or memory
+                return null;
+        }
+        assert(pool);
+
+        debug(PRINTF) printFreeInfo(&pool.base);
+        pool.pagetable[pn] = B_PAGE;
+        if (npages > 1)
+            memset(&pool.pagetable[pn + 1], B_PAGEPLUS, npages - 1);
+        pool.updateOffsets(pn);
+        usedLargePages += npages;
+        pool.freepages -= npages;
+
+        debug(PRINTF) printFreeInfo(&pool.base);
+
+        auto p = pool.baseAddr + pn * PAGESIZE;
+        debug(PRINTF) printf("Got large alloc:  %p, pt = %d, np = %d\n", p, pool.pagetable[pn], npages);
+        debug (MEMSTOMP) memset(p, 0xF1, size);
+        alloc_size = npages * PAGESIZE;
+        //debug(PRINTF) printf("\tp = %p\n", p);
+
+        if (bits)
+            pool.setBits(pn, bits);
+        return p;
+    }
+
+
+    /**
+     * Allocate a new pool with at least npages in it.
+     * Sort it into pooltable[].
+     * Return null if failed.
+     */
+    Pool *newPool(size_t npages, bool isLargeObject) nothrow
+    {
+        //debug(PRINTF) printf("************Gcx::newPool(npages = %d)****************\n", npages);
+
+        // Minimum of POOLSIZE
+        size_t minPages = (GC.config.minPoolSize << 20) / PAGESIZE;
+        if (npages < minPages)
+            npages = minPages;
+        else if (npages > minPages)
+        {   // Give us 150% of requested size, so there's room to extend
+            auto n = npages + (npages >> 1);
+            if (n < size_t.max/PAGESIZE)
+                npages = n;
+        }
+
+        // Allocate successively larger pools up to 8 megs
+        if (npools)
+        {   size_t n;
+
+            n = GC.config.minPoolSize + GC.config.incPoolSize * npools;
+            if (n > GC.config.maxPoolSize)
+                n = GC.config.maxPoolSize;                 // cap pool size
+            n *= (1 << 20) / PAGESIZE;                     // convert MB to pages
+            if (npages < n)
+                npages = n;
+        }
+
+        //printf("npages = %d\n", npages);
+
+        auto pool = cast(Pool *)cstdlib.calloc(1, isLargeObject ? LargeObjectPool.sizeof : SmallObjectPool.sizeof);
+        if (pool)
+        {
+            pool.initialize(npages, isLargeObject);
+            if (!pool.baseAddr || !pooltable.insert(pool))
+            {
+                pool.Dtor();
+                cstdlib.free(pool);
+                return null;
+            }
+        }
+
+        mappedPages += npages;
+
+        if (GC.config.profile)
+        {
+            if (mappedPages * PAGESIZE > maxPoolMemory)
+                maxPoolMemory = mappedPages * PAGESIZE;
+        }
+        return pool;
+    }
+
+    /**
+    * Allocate a page of bin's.
+    * Returns:
+    *           head of a single linked list of new entries
+    */
+    List* allocPage(Bins bin) nothrow
+    {
+        //debug(PRINTF) printf("Gcx::allocPage(bin = %d)\n", bin);
+        for (size_t n = 0; n < npools; n++)
+        {
+            Pool* pool = pooltable[n];
+            if(pool.isLargeObject)
+                continue;
+            if (List* p = (cast(SmallObjectPool*)pool).allocPage(bin))
+            {
+                ++usedSmallPages;
+                return p;
+            }
+        }
+        return null;
+    }
+
+    static struct ToScanStack
+    {
+    nothrow:
+        @disable this(this);
+
+        void reset()
+        {
+            _length = 0;
+            os_mem_unmap(_p, _cap * Range.sizeof);
+            _p = null;
+            _cap = 0;
+        }
+
+        void push(Range rng)
+        {
+            if (_length == _cap) grow();
+            _p[_length++] = rng;
+        }
+
+        Range pop()
+        in { assert(!empty); }
+        body
+        {
+            return _p[--_length];
+        }
+
+        ref inout(Range) opIndex(size_t idx) inout
+        in { assert(idx < _length); }
+        body
+        {
+            return _p[idx];
+        }
+
+        @property size_t length() const { return _length; }
+        @property bool empty() const { return !length; }
+
+    private:
+        void grow()
+        {
+            enum initSize = 64 * 1024; // Windows VirtualAlloc granularity
+            immutable ncap = _cap ? 2 * _cap : initSize / Range.sizeof;
+            auto p = cast(Range*)os_mem_map(ncap * Range.sizeof);
+            if (p is null) onOutOfMemoryErrorNoGC();
+            if (_p !is null)
+            {
+                p[0 .. _length] = _p[0 .. _length];
+                os_mem_unmap(_p, _cap * Range.sizeof);
+            }
+            _p = p;
+            _cap = ncap;
+        }
+
+        size_t _length;
+        Range* _p;
+        size_t _cap;
+    }
+
+    ToScanStack toscan;
+
+    /**
+     * Search a range of memory values and mark any pointers into the GC pool.
+     */
+    void mark(void *pbot, void *ptop) nothrow
+    {
+        void **p1 = cast(void **)pbot;
+        void **p2 = cast(void **)ptop;
+
+        // limit the amount of ranges added to the toscan stack
+        enum FANOUT_LIMIT = 32;
+        size_t stackPos;
+        Range[FANOUT_LIMIT] stack = void;
+
+    Lagain:
+        size_t pcache = 0;
+
+        // let dmd allocate a register for this.pools
+        auto pools = pooltable.pools;
+        const highpool = pooltable.npools - 1;
+        const minAddr = pooltable.minAddr;
+        const maxAddr = pooltable.maxAddr;
+
+        //printf("marking range: [%p..%p] (%#zx)\n", p1, p2, cast(size_t)p2 - cast(size_t)p1);
+    Lnext: for (; p1 < p2; p1++)
+        {
+            auto p = cast(byte *)(*p1);
+
+            //if (log) debug(PRINTF) printf("\tmark %p\n", p);
+            if (p >= minAddr && p < maxAddr)
+            {
+                if ((cast(size_t)p & ~cast(size_t)(PAGESIZE-1)) == pcache)
+                    continue;
+
+                Pool* pool = void;
+                if (npools > 0)
+                {
+                    size_t low = 0;
+                    size_t high = highpool;
+                    while (true)
+                    {
+                        size_t mid = (low + high) >> 1;
+                        pool = pools[mid];
+                        if (p < pool.baseAddr)
+                            high = mid - 1;
+                        else if (p >= pool.topAddr)
+                            low = mid + 1;
+                        else break;
+
+                        if (low > high)
+                            continue Lnext;
+                    }
+                }
+                else
+                {
+                    pool = pools[0];
+                }
+
+                size_t offset = cast(size_t)(p - pool.baseAddr);
+                size_t biti = void;
+                size_t pn = offset / PAGESIZE;
+                Bins   bin = cast(Bins)pool.pagetable[pn];
+                void* base = void;
+
+                //debug(PRINTF) printf("\t\tfound pool %p, base=%p, pn = %zd, bin = %d, biti = x%x\n", pool, pool.baseAddr, pn, bin, biti);
+
+                // Adjust bit to be at start of allocated memory block
+                if (bin < B_PAGE)
+                {
+                    // We don't care abou setting pointsToBase correctly
+                    // because it's ignored for small object pools anyhow.
+                    auto offsetBase = offset & notbinsize[bin];
+                    biti = offsetBase >> pool.shiftBy;
+                    base = pool.baseAddr + offsetBase;
+                    //debug(PRINTF) printf("\t\tbiti = x%x\n", biti);
+
+                    if (!pool.mark.set(biti) && !pool.noscan.test(biti)) {
+                        stack[stackPos++] = Range(base, base + binsize[bin]);
+                        if (stackPos == stack.length)
+                            break;
+                    }
+                }
+                else if (bin == B_PAGE)
+                {
+                    auto offsetBase = offset & notbinsize[bin];
+                    base = pool.baseAddr + offsetBase;
+                    biti = offsetBase >> pool.shiftBy;
+                    //debug(PRINTF) printf("\t\tbiti = x%x\n", biti);
+
+                    pcache = cast(size_t)p & ~cast(size_t)(PAGESIZE-1);
+
+                    // For the NO_INTERIOR attribute.  This tracks whether
+                    // the pointer is an interior pointer or points to the
+                    // base address of a block.
+                    bool pointsToBase = (base == sentinel_sub(p));
+                    if(!pointsToBase && pool.nointerior.nbits && pool.nointerior.test(biti))
+                        continue;
+
+                    if (!pool.mark.set(biti) && !pool.noscan.test(biti)) {
+                        stack[stackPos++] = Range(base, base + pool.bPageOffsets[pn] * PAGESIZE);
+                        if (stackPos == stack.length)
+                            break;
+                    }
+                }
+                else if (bin == B_PAGEPLUS)
+                {
+                    pn -= pool.bPageOffsets[pn];
+                    base = pool.baseAddr + (pn * PAGESIZE);
+                    biti = pn * (PAGESIZE >> pool.shiftBy);
+
+                    pcache = cast(size_t)p & ~cast(size_t)(PAGESIZE-1);
+                    if(pool.nointerior.nbits && pool.nointerior.test(biti))
+                        continue;
+
+                    if (!pool.mark.set(biti) && !pool.noscan.test(biti)) {
+                        stack[stackPos++] = Range(base, base + pool.bPageOffsets[pn] * PAGESIZE);
+                        if (stackPos == stack.length)
+                            break;
+                    }
+                }
+                else
+                {
+                    // Don't mark bits in B_FREE pages
+                    assert(bin == B_FREE);
+                    continue;
+                }
+            }
+        }
+
+        Range next=void;
+        if (p1 < p2)
+        {
+            // local stack is full, push it to the global stack
+            assert(stackPos == stack.length);
+            toscan.push(Range(p1, p2));
+            // reverse order for depth-first-order traversal
+            foreach_reverse (ref rng; stack[0 .. $ - 1])
+                toscan.push(rng);
+            stackPos = 0;
+            next = stack[$-1];
+        }
+        else if (stackPos)
+        {
+            // pop range from local stack and recurse
+            next = stack[--stackPos];
+        }
+        else if (!toscan.empty)
+        {
+            // pop range from global stack and recurse
+            next = toscan.pop();
+        }
+        else
+        {
+            // nothing more to do
+            return;
+        }
+        p1 = cast(void**)next.pbot;
+        p2 = cast(void**)next.ptop;
+        // printf("  pop [%p..%p] (%#zx)\n", p1, p2, cast(size_t)p2 - cast(size_t)p1);
+        goto Lagain;
+    }
+
+    // collection step 1: prepare freebits and mark bits
+    void prepare() nothrow
+    {
+        size_t n;
+        Pool*  pool;
+
+        for (n = 0; n < npools; n++)
+        {
+            pool = pooltable[n];
+            pool.mark.zero();
+            if(!pool.isLargeObject) pool.freebits.zero();
+        }
+
+        debug(COLLECT_PRINTF) printf("Set bits\n");
+
+        // Mark each free entry, so it doesn't get scanned
+        for (n = 0; n < B_PAGE; n++)
+        {
+            for (List *list = bucket[n]; list; list = list.next)
+            {
+                pool = list.pool;
+                assert(pool);
+                pool.freebits.set(cast(size_t)(cast(byte*)list - pool.baseAddr) / 16);
+            }
+        }
+
+        debug(COLLECT_PRINTF) printf("Marked free entries.\n");
+
+        for (n = 0; n < npools; n++)
+        {
+            pool = pooltable[n];
+            if(!pool.isLargeObject)
+            {
+                pool.mark.copy(&pool.freebits);
+            }
+        }
+    }
+
+    // collection step 2: mark roots and heap
+    void markAll(bool nostack) nothrow
+    {
+        if (!nostack)
+        {
+            debug(COLLECT_PRINTF) printf("\tscan stacks.\n");
+            // Scan stacks and registers for each paused thread
+            thread_scanAll(&mark);
+        }
+
+        // Scan roots[]
+        debug(COLLECT_PRINTF) printf("\tscan roots[]\n");
+        foreach (root; roots)
+        {
+            mark(cast(void*)&root.proot, cast(void*)(&root.proot + 1));
+        }
+
+        // Scan ranges[]
+        debug(COLLECT_PRINTF) printf("\tscan ranges[]\n");
+        //log++;
+        foreach (range; ranges)
+        {
+            debug(COLLECT_PRINTF) printf("\t\t%p .. %p\n", range.pbot, range.ptop);
+            mark(range.pbot, range.ptop);
+        }
+        //log--;
+    }
+
+    // collection step 3: free all unreferenced objects
+    size_t sweep() nothrow
+    {
+        // Free up everything not marked
+        debug(COLLECT_PRINTF) printf("\tfree'ing\n");
+        size_t freedLargePages;
+        size_t freed;
+        for (size_t n = 0; n < npools; n++)
+        {
+            size_t pn;
+            Pool* pool = pooltable[n];
+
+            if(pool.isLargeObject)
+            {
+                for(pn = 0; pn < pool.npages; pn++)
+                {
+                    Bins bin = cast(Bins)pool.pagetable[pn];
+                    if(bin > B_PAGE) continue;
+                    size_t biti = pn;
+
+                    if (!pool.mark.test(biti))
+                    {
+                        byte *p = pool.baseAddr + pn * PAGESIZE;
+                        void* q = sentinel_add(p);
+                        sentinel_Invariant(q);
+
+                        if (pool.finals.nbits && pool.finals.clear(biti))
+                        {
+                            size_t size = pool.bPageOffsets[pn] * PAGESIZE - SENTINEL_EXTRA;
+                            uint attr = pool.getBits(biti);
+                            rt_finalizeFromGC(q, size, attr);
+                        }
+
+                        pool.clrBits(biti, ~BlkAttr.NONE ^ BlkAttr.FINALIZE);
+
+                        debug(COLLECT_PRINTF) printf("\tcollecting big %p\n", p);
+                        log_free(q);
+                        pool.pagetable[pn] = B_FREE;
+                        if(pn < pool.searchStart) pool.searchStart = pn;
+                        freedLargePages++;
+                        pool.freepages++;
+
+                        debug (MEMSTOMP) memset(p, 0xF3, PAGESIZE);
+                        while (pn + 1 < pool.npages && pool.pagetable[pn + 1] == B_PAGEPLUS)
+                        {
+                            pn++;
+                            pool.pagetable[pn] = B_FREE;
+
+                            // Don't need to update searchStart here because
+                            // pn is guaranteed to be greater than last time
+                            // we updated it.
+
+                            pool.freepages++;
+                            freedLargePages++;
+
+                            debug (MEMSTOMP)
+                            {   p += PAGESIZE;
+                                memset(p, 0xF3, PAGESIZE);
+                            }
+                        }
+                        pool.largestFree = pool.freepages; // invalidate
+                    }
+                }
+            }
+            else
+            {
+
+                for (pn = 0; pn < pool.npages; pn++)
+                {
+                    Bins bin = cast(Bins)pool.pagetable[pn];
+
+                    if (bin < B_PAGE)
+                    {
+                        immutable size = binsize[bin];
+                        byte *p = pool.baseAddr + pn * PAGESIZE;
+                        byte *ptop = p + PAGESIZE;
+                        immutable base = pn * (PAGESIZE/16);
+                        immutable bitstride = size / 16;
+
+                        bool freeBits;
+                        PageBits toFree;
+
+                        for (size_t i; p < ptop; p += size, i += bitstride)
+                        {
+                            immutable biti = base + i;
+
+                            if (!pool.mark.test(biti))
+                            {
+                                void* q = sentinel_add(p);
+                                sentinel_Invariant(q);
+
+                                if (pool.finals.nbits && pool.finals.test(biti))
+                                    rt_finalizeFromGC(q, size - SENTINEL_EXTRA, pool.getBits(biti));
+
+                                freeBits = true;
+                                toFree.set(i);
+
+                                debug(COLLECT_PRINTF) printf("\tcollecting %p\n", p);
+                                log_free(sentinel_add(p));
+
+                                debug (MEMSTOMP) memset(p, 0xF3, size);
+
+                                freed += size;
+                            }
+                        }
+
+                        if (freeBits)
+                            pool.freePageBits(pn, toFree);
+                    }
+                }
+            }
+        }
+
+        assert(freedLargePages <= usedLargePages);
+        usedLargePages -= freedLargePages;
+        debug(COLLECT_PRINTF) printf("\tfree'd %u bytes, %u pages from %u pools\n", freed, freedLargePages, npools);
+        return freedLargePages;
+    }
+
+    // collection step 4: recover pages with no live objects, rebuild free lists
+    size_t recover() nothrow
+    {
+        // init tail list
+        List**[B_PAGE] tail = void;
+        foreach (i, ref next; tail)
+            next = &bucket[i];
+
+        // Free complete pages, rebuild free list
+        debug(COLLECT_PRINTF) printf("\tfree complete pages\n");
+        size_t freedSmallPages;
+        for (size_t n = 0; n < npools; n++)
+        {
+            size_t pn;
+            Pool* pool = pooltable[n];
+
+            if(pool.isLargeObject)
+                continue;
+
+            for (pn = 0; pn < pool.npages; pn++)
+            {
+                Bins   bin = cast(Bins)pool.pagetable[pn];
+                size_t biti;
+                size_t u;
+
+                if (bin < B_PAGE)
+                {
+                    size_t size = binsize[bin];
+                    size_t bitstride = size / 16;
+                    size_t bitbase = pn * (PAGESIZE / 16);
+                    size_t bittop = bitbase + (PAGESIZE / 16);
+                    byte*  p;
+
+                    biti = bitbase;
+                    for (biti = bitbase; biti < bittop; biti += bitstride)
+                    {
+                        if (!pool.freebits.test(biti))
+                            goto Lnotfree;
+                    }
+                    pool.pagetable[pn] = B_FREE;
+                    if(pn < pool.searchStart) pool.searchStart = pn;
+                    pool.freepages++;
+                    freedSmallPages++;
+                    continue;
+
+                Lnotfree:
+                    p = pool.baseAddr + pn * PAGESIZE;
+                    for (u = 0; u < PAGESIZE; u += size)
+                    {
+                        biti = bitbase + u / 16;
+                        if (!pool.freebits.test(biti))
+                            continue;
+                        auto elem = cast(List *)(p + u);
+                        elem.pool = pool;
+                        *tail[bin] = elem;
+                        tail[bin] = &elem.next;
+                    }
+                }
+            }
+        }
+        // terminate tail list
+        foreach (ref next; tail)
+            *next = null;
+
+        assert(freedSmallPages <= usedSmallPages);
+        usedSmallPages -= freedSmallPages;
+        debug(COLLECT_PRINTF) printf("\trecovered pages = %d\n", freedSmallPages);
+        return freedSmallPages;
+    }
+
+    /**
+     * Return number of full pages free'd.
+     */
+    size_t fullcollect(bool nostack = false) nothrow
+    {
+        MonoTime start, stop, begin;
+
+        if (GC.config.profile)
+        {
+            begin = start = currTime;
+        }
+
+        debug(COLLECT_PRINTF) printf("Gcx.fullcollect()\n");
+        //printf("\tpool address range = %p .. %p\n", minAddr, maxAddr);
+
+        {
+            // lock roots and ranges around suspending threads b/c they're not reentrant safe
+            rangesLock.lock();
+            rootsLock.lock();
+            scope (exit)
+            {
+                rangesLock.unlock();
+                rootsLock.unlock();
+            }
+            thread_suspendAll();
+
+            prepare();
+
+            if (GC.config.profile)
+            {
+                stop = currTime;
+                prepTime += (stop - start);
+                start = stop;
+            }
+
+            markAll(nostack);
+
+            thread_processGCMarks(&isMarked);
+            thread_resumeAll();
+        }
+
+        if (GC.config.profile)
+        {
+            stop = currTime;
+            markTime += (stop - start);
+            Duration pause = stop - begin;
+            if (pause > maxPauseTime)
+                maxPauseTime = pause;
+            start = stop;
+        }
+
+        GC.inFinalizer = true;
+        size_t freedLargePages=void;
+        {
+            scope (failure) GC.inFinalizer = false;
+            freedLargePages = sweep();
+            GC.inFinalizer = false;
+        }
+
+        if (GC.config.profile)
+        {
+            stop = currTime;
+            sweepTime += (stop - start);
+            start = stop;
+        }
+
+        immutable freedSmallPages = recover();
+
+        if (GC.config.profile)
+        {
+            stop = currTime;
+            recoverTime += (stop - start);
+            ++numCollections;
+        }
+
+        updateCollectThresholds();
+
+        return freedLargePages + freedSmallPages;
+    }
+
+    /**
+     * Returns true if the addr lies within a marked block.
+     *
+     * Warning! This should only be called while the world is stopped inside
+     * the fullcollect function.
+     */
+    int isMarked(void *addr) nothrow
+    {
+        // first, we find the Pool this block is in, then check to see if the
+        // mark bit is clear.
+        auto pool = findPool(addr);
+        if(pool)
+        {
+            auto offset = cast(size_t)(addr - pool.baseAddr);
+            auto pn = offset / PAGESIZE;
+            auto bins = cast(Bins)pool.pagetable[pn];
+            size_t biti = void;
+            if(bins <= B_PAGE)
+            {
+                biti = (offset & notbinsize[bins]) >> pool.shiftBy;
+            }
+            else if(bins == B_PAGEPLUS)
+            {
+                pn -= pool.bPageOffsets[pn];
+                biti = pn * (PAGESIZE >> pool.shiftBy);
+            }
+            else // bins == B_FREE
+            {
+                assert(bins == B_FREE);
+                return IsMarked.no;
+            }
+            return pool.mark.test(biti) ? IsMarked.yes : IsMarked.no;
+        }
+        return IsMarked.unknown;
+    }
+
+
+    /***** Leak Detector ******/
+
+
+    debug (LOGGING)
+    {
+        LogArray current;
+        LogArray prev;
+
+
+        void log_init()
+        {
+            //debug(PRINTF) printf("+log_init()\n");
+            current.reserve(1000);
+            prev.reserve(1000);
+            //debug(PRINTF) printf("-log_init()\n");
+        }
+
+
+        void log_malloc(void *p, size_t size) nothrow
+        {
+            //debug(PRINTF) printf("+log_malloc(p = %p, size = %zd)\n", p, size);
+            Log log;
+
+            log.p = p;
+            log.size = size;
+            log.line = GC.line;
+            log.file = GC.file;
+            log.parent = null;
+
+            GC.line = 0;
+            GC.file = null;
+
+            current.push(log);
+            //debug(PRINTF) printf("-log_malloc()\n");
+        }
+
+
+        void log_free(void *p) nothrow
+        {
+            //debug(PRINTF) printf("+log_free(%p)\n", p);
+            auto i = current.find(p);
+            if (i == OPFAIL)
+            {
+                debug(PRINTF) printf("free'ing unallocated memory %p\n", p);
+            }
+            else
+                current.remove(i);
+            //debug(PRINTF) printf("-log_free()\n");
+        }
+
+
+        void log_collect() nothrow
+        {
+            //debug(PRINTF) printf("+log_collect()\n");
+            // Print everything in current that is not in prev
+
+            debug(PRINTF) printf("New pointers this cycle: --------------------------------\n");
+            size_t used = 0;
+            for (size_t i = 0; i < current.dim; i++)
+            {
+                auto j = prev.find(current.data[i].p);
+                if (j == OPFAIL)
+                    current.data[i].print();
+                else
+                    used++;
+            }
+
+            debug(PRINTF) printf("All roots this cycle: --------------------------------\n");
+            for (size_t i = 0; i < current.dim; i++)
+            {
+                void* p = current.data[i].p;
+                if (!findPool(current.data[i].parent))
+                {
+                    auto j = prev.find(current.data[i].p);
+                    debug(PRINTF) printf(j == OPFAIL ? "N" : " ");
+                    current.data[i].print();
+                }
+            }
+
+            debug(PRINTF) printf("Used = %d-------------------------------------------------\n", used);
+            prev.copy(&current);
+
+            debug(PRINTF) printf("-log_collect()\n");
+        }
+
+
+        void log_parent(void *p, void *parent) nothrow
+        {
+            //debug(PRINTF) printf("+log_parent()\n");
+            auto i = current.find(p);
+            if (i == OPFAIL)
+            {
+                debug(PRINTF) printf("parent'ing unallocated memory %p, parent = %p\n", p, parent);
+                Pool *pool;
+                pool = findPool(p);
+                assert(pool);
+                size_t offset = cast(size_t)(p - pool.baseAddr);
+                size_t biti;
+                size_t pn = offset / PAGESIZE;
+                Bins bin = cast(Bins)pool.pagetable[pn];
+                biti = (offset & notbinsize[bin]);
+                debug(PRINTF) printf("\tbin = %d, offset = x%x, biti = x%x\n", bin, offset, biti);
+            }
+            else
+            {
+                current.data[i].parent = parent;
+            }
+            //debug(PRINTF) printf("-log_parent()\n");
+        }
+
+    }
+    else
+    {
+        void log_init() nothrow { }
+        void log_malloc(void *p, size_t size) nothrow { }
+        void log_free(void *p) nothrow { }
+        void log_collect() nothrow { }
+        void log_parent(void *p, void *parent) nothrow { }
+    }
+}
+
+/* ============================ Pool  =============================== */
+
+struct Pool
+{
+    byte* baseAddr;
+    byte* topAddr;
+    GCBits mark;        // entries already scanned, or should not be scanned
+    GCBits freebits;    // entries that are on the free list
+    GCBits finals;      // entries that need finalizer run on them
+    GCBits structFinals;// struct entries that need a finalzier run on them
+    GCBits noscan;      // entries that should not be scanned
+    GCBits appendable;  // entries that are appendable
+    GCBits nointerior;  // interior pointers should be ignored.
+                        // Only implemented for large object pools.
+    size_t npages;
+    size_t freepages;     // The number of pages not in use.
+    ubyte* pagetable;
+
+    bool isLargeObject;
+
+    uint shiftBy;    // shift count for the divisor used for determining bit indices.
+
+    // This tracks how far back we have to go to find the nearest B_PAGE at
+    // a smaller address than a B_PAGEPLUS.  To save space, we use a uint.
+    // This limits individual allocations to 16 terabytes, assuming a 4k
+    // pagesize.
+    uint* bPageOffsets;
+
+    // This variable tracks a conservative estimate of where the first free
+    // page in this pool is, so that if a lot of pages towards the beginning
+    // are occupied, we can bypass them in O(1).
+    size_t searchStart;
+    size_t largestFree; // upper limit for largest free chunk in large object pool
+
+    void initialize(size_t npages, bool isLargeObject) nothrow
+    {
+        this.isLargeObject = isLargeObject;
+        size_t poolsize;
+
+        shiftBy = isLargeObject ? 12 : 4;
+
+        //debug(PRINTF) printf("Pool::Pool(%u)\n", npages);
+        poolsize = npages * PAGESIZE;
+        assert(poolsize >= POOLSIZE);
+        baseAddr = cast(byte *)os_mem_map(poolsize);
+
+        // Some of the code depends on page alignment of memory pools
+        assert((cast(size_t)baseAddr & (PAGESIZE - 1)) == 0);
+
+        if (!baseAddr)
+        {
+            //debug(PRINTF) printf("GC fail: poolsize = x%zx, errno = %d\n", poolsize, errno);
+            //debug(PRINTF) printf("message = '%s'\n", sys_errlist[errno]);
+
+            npages = 0;
+            poolsize = 0;
+        }
+        //assert(baseAddr);
+        topAddr = baseAddr + poolsize;
+        auto nbits = cast(size_t)poolsize >> shiftBy;
+
+        mark.alloc(nbits);
+
+        // pagetable already keeps track of what's free for the large object
+        // pool.
+        if(!isLargeObject)
+        {
+            freebits.alloc(nbits);
+        }
+
+        noscan.alloc(nbits);
+        appendable.alloc(nbits);
+
+        pagetable = cast(ubyte*)cstdlib.malloc(npages);
+        if (!pagetable)
+            onOutOfMemoryErrorNoGC();
+
+        if(isLargeObject)
+        {
+            bPageOffsets = cast(uint*)cstdlib.malloc(npages * uint.sizeof);
+            if (!bPageOffsets)
+                onOutOfMemoryErrorNoGC();
+        }
+
+        memset(pagetable, B_FREE, npages);
+
+        this.npages = npages;
+        this.freepages = npages;
+        this.searchStart = 0;
+        this.largestFree = npages;
+    }
+
+
+    void Dtor() nothrow
+    {
+        if (baseAddr)
+        {
+            int result;
+
+            if (npages)
+            {
+                result = os_mem_unmap(baseAddr, npages * PAGESIZE);
+                assert(result == 0);
+                npages = 0;
+            }
+
+            baseAddr = null;
+            topAddr = null;
+        }
+        if (pagetable)
+        {
+            cstdlib.free(pagetable);
+            pagetable = null;
+        }
+
+        if(bPageOffsets)
+            cstdlib.free(bPageOffsets);
+
+        mark.Dtor();
+        if(isLargeObject)
+        {
+            nointerior.Dtor();
+        }
+        else
+        {
+            freebits.Dtor();
+        }
+        finals.Dtor();
+        structFinals.Dtor();
+        noscan.Dtor();
+        appendable.Dtor();
+    }
+
+    /**
+    *
+    */
+    uint getBits(size_t biti) nothrow
+    {
+        uint bits;
+
+        if (finals.nbits && finals.test(biti))
+            bits |= BlkAttr.FINALIZE;
+        if (structFinals.nbits && structFinals.test(biti))
+            bits |= BlkAttr.STRUCTFINAL;
+        if (noscan.test(biti))
+            bits |= BlkAttr.NO_SCAN;
+        if (nointerior.nbits && nointerior.test(biti))
+            bits |= BlkAttr.NO_INTERIOR;
+        if (appendable.test(biti))
+            bits |= BlkAttr.APPENDABLE;
+        return bits;
+    }
+
+    /**
+     *
+     */
+    void clrBits(size_t biti, uint mask) nothrow
+    {
+        immutable dataIndex =  biti >> GCBits.BITS_SHIFT;
+        immutable bitOffset = biti & GCBits.BITS_MASK;
+        immutable keep = ~(GCBits.BITS_1 << bitOffset);
+
+        if (mask & BlkAttr.FINALIZE && finals.nbits)
+            finals.data[dataIndex] &= keep;
+
+        if (structFinals.nbits && (mask & BlkAttr.STRUCTFINAL))
+            structFinals.data[dataIndex] &= keep;
+
+        if (mask & BlkAttr.NO_SCAN)
+            noscan.data[dataIndex] &= keep;
+        if (mask & BlkAttr.APPENDABLE)
+            appendable.data[dataIndex] &= keep;
+        if (nointerior.nbits && (mask & BlkAttr.NO_INTERIOR))
+            nointerior.data[dataIndex] &= keep;
+    }
+
+    /**
+     *
+     */
+    void setBits(size_t biti, uint mask) nothrow
+    {
+        // Calculate the mask and bit offset once and then use it to
+        // set all of the bits we need to set.
+        immutable dataIndex = biti >> GCBits.BITS_SHIFT;
+        immutable bitOffset = biti & GCBits.BITS_MASK;
+        immutable orWith = GCBits.BITS_1 << bitOffset;
+
+        if (mask & BlkAttr.STRUCTFINAL)
+        {
+            if (!structFinals.nbits)
+                structFinals.alloc(mark.nbits);
+            structFinals.data[dataIndex] |= orWith;
+        }
+
+        if (mask & BlkAttr.FINALIZE)
+        {
+            if (!finals.nbits)
+                finals.alloc(mark.nbits);
+            finals.data[dataIndex] |= orWith;
+        }
+
+        if (mask & BlkAttr.NO_SCAN)
+        {
+            noscan.data[dataIndex] |= orWith;
+        }
+//        if (mask & BlkAttr.NO_MOVE)
+//        {
+//            if (!nomove.nbits)
+//                nomove.alloc(mark.nbits);
+//            nomove.data[dataIndex] |= orWith;
+//        }
+        if (mask & BlkAttr.APPENDABLE)
+        {
+            appendable.data[dataIndex] |= orWith;
+        }
+
+        if (isLargeObject && (mask & BlkAttr.NO_INTERIOR))
+        {
+            if(!nointerior.nbits)
+                nointerior.alloc(mark.nbits);
+            nointerior.data[dataIndex] |= orWith;
+        }
+    }
+
+    void freePageBits(size_t pagenum, in ref PageBits toFree) nothrow
+    {
+        assert(!isLargeObject);
+        assert(!nointerior.nbits); // only for large objects
+
+        import core.internal.traits : staticIota;
+        immutable beg = pagenum * (PAGESIZE / 16 / GCBits.BITS_PER_WORD);
+        foreach (i; staticIota!(0, PageBits.length))
+        {
+            immutable w = toFree[i];
+            if (!w) continue;
+
+            immutable wi = beg + i;
+            freebits.data[wi] |= w;
+            noscan.data[wi] &= ~w;
+            appendable.data[wi] &= ~w;
+        }
+
+        if (finals.nbits)
+        {
+            foreach (i; staticIota!(0, PageBits.length))
+                if (toFree[i])
+                    finals.data[beg + i] &= ~toFree[i];
+        }
+
+        if (structFinals.nbits)
+        {
+            foreach (i; staticIota!(0, PageBits.length))
+                if (toFree[i])
+                    structFinals.data[beg + i] &= ~toFree[i];
+        }
+    }
+
+    /**
+     * Given a pointer p in the p, return the pagenum.
+     */
+    size_t pagenumOf(void *p) const nothrow
+    in
+    {
+        assert(p >= baseAddr);
+        assert(p < topAddr);
+    }
+    body
+    {
+        return cast(size_t)(p - baseAddr) / PAGESIZE;
+    }
+
+    @property bool isFree() const pure nothrow
+    {
+        return npages == freepages;
+    }
+
+    size_t slGetSize(void* p) nothrow
+    {
+        if (isLargeObject)
+            return (cast(LargeObjectPool*)&this).getSize(p);
+        else
+            return (cast(SmallObjectPool*)&this).getSize(p);
+    }
+
+    BlkInfo slGetInfo(void* p) nothrow
+    {
+        if (isLargeObject)
+            return (cast(LargeObjectPool*)&this).getInfo(p);
+        else
+            return (cast(SmallObjectPool*)&this).getInfo(p);
+    }
+
+
+    void Invariant() const {}
+
+    debug(INVARIANT)
+    invariant()
+    {
+        //mark.Invariant();
+        //scan.Invariant();
+        //freebits.Invariant();
+        //finals.Invariant();
+        //structFinals.Invariant();
+        //noscan.Invariant();
+        //appendable.Invariant();
+        //nointerior.Invariant();
+
+        if (baseAddr)
+        {
+            //if (baseAddr + npages * PAGESIZE != topAddr)
+                //printf("baseAddr = %p, npages = %d, topAddr = %p\n", baseAddr, npages, topAddr);
+            assert(baseAddr + npages * PAGESIZE == topAddr);
+        }
+
+        if(pagetable !is null)
+        {
+            for (size_t i = 0; i < npages; i++)
+            {
+                Bins bin = cast(Bins)pagetable[i];
+                assert(bin < B_MAX);
+            }
+        }
+    }
+}
+
+struct LargeObjectPool
+{
+    Pool base;
+    alias base this;
+
+    void updateOffsets(size_t fromWhere) nothrow
+    {
+        assert(pagetable[fromWhere] == B_PAGE);
+        size_t pn = fromWhere + 1;
+        for(uint offset = 1; pn < npages; pn++, offset++)
+        {
+            if(pagetable[pn] != B_PAGEPLUS) break;
+            bPageOffsets[pn] = offset;
+        }
+
+        // Store the size of the block in bPageOffsets[fromWhere].
+        bPageOffsets[fromWhere] = cast(uint) (pn - fromWhere);
+    }
+
+    /**
+     * Allocate n pages from Pool.
+     * Returns OPFAIL on failure.
+     */
+    size_t allocPages(size_t n) nothrow
+    {
+        if(largestFree < n || searchStart + n > npages)
+            return OPFAIL;
+
+        //debug(PRINTF) printf("Pool::allocPages(n = %d)\n", n);
+        size_t largest = 0;
+        if (pagetable[searchStart] == B_PAGEPLUS)
+        {
+            searchStart -= bPageOffsets[searchStart]; // jump to B_PAGE
+            searchStart += bPageOffsets[searchStart];
+        }
+        while (searchStart < npages && pagetable[searchStart] == B_PAGE)
+            searchStart += bPageOffsets[searchStart];
+
+        for (size_t i = searchStart; i < npages; )
+        {
+            assert(pagetable[i] == B_FREE);
+            size_t p = 1;
+            while (p < n && i + p < npages && pagetable[i + p] == B_FREE)
+                p++;
+
+            if (p == n)
+                return i;
+
+            if (p > largest)
+                largest = p;
+
+            i += p;
+            while(i < npages && pagetable[i] == B_PAGE)
+            {
+                // we have the size information, so we skip a whole bunch of pages.
+                i += bPageOffsets[i];
+            }
+        }
+
+        // not enough free pages found, remember largest free chunk
+        largestFree = largest;
+        return OPFAIL;
+    }
+
+    /**
+     * Free npages pages starting with pagenum.
+     */
+    void freePages(size_t pagenum, size_t npages) nothrow
+    {
+        //memset(&pagetable[pagenum], B_FREE, npages);
+        if(pagenum < searchStart)
+            searchStart = pagenum;
+
+        for(size_t i = pagenum; i < npages + pagenum; i++)
+        {
+            if(pagetable[i] < B_FREE)
+            {
+                freepages++;
+            }
+
+            pagetable[i] = B_FREE;
+        }
+        largestFree = freepages; // invalidate
+    }
+
+    /**
+     * Get size of pointer p in pool.
+     */
+    size_t getSize(void *p) const nothrow
+    in
+    {
+        assert(p >= baseAddr);
+        assert(p < topAddr);
+    }
+    body
+    {
+        size_t pagenum = pagenumOf(p);
+        Bins bin = cast(Bins)pagetable[pagenum];
+        assert(bin == B_PAGE);
+        return bPageOffsets[pagenum] * PAGESIZE;
+    }
+
+    /**
+    *
+    */
+    BlkInfo getInfo(void* p) nothrow
+    {
+        BlkInfo info;
+
+        size_t offset = cast(size_t)(p - baseAddr);
+        size_t pn = offset / PAGESIZE;
+        Bins bin = cast(Bins)pagetable[pn];
+
+        if (bin == B_PAGEPLUS)
+            pn -= bPageOffsets[pn];
+        else if (bin != B_PAGE)
+            return info;           // no info for free pages
+
+        info.base = baseAddr + pn * PAGESIZE;
+        info.size = bPageOffsets[pn] * PAGESIZE;
+
+        info.attr = getBits(pn);
+        return info;
+    }
+
+    void runFinalizers(in void[] segment) nothrow
+    {
+        foreach (pn; 0 .. npages)
+        {
+            Bins bin = cast(Bins)pagetable[pn];
+            if (bin > B_PAGE)
+                continue;
+            size_t biti = pn;
+
+            if (!finals.test(biti))
+                continue;
+
+            auto p = sentinel_add(baseAddr + pn * PAGESIZE);
+            size_t size = bPageOffsets[pn] * PAGESIZE - SENTINEL_EXTRA;
+            uint attr = getBits(biti);
+
+            if(!rt_hasFinalizerInSegment(p, size, attr, segment))
+                continue;
+
+            rt_finalizeFromGC(p, size, attr);
+
+            clrBits(biti, ~BlkAttr.NONE);
+
+            if (pn < searchStart)
+                searchStart = pn;
+
+            debug(COLLECT_PRINTF) printf("\tcollecting big %p\n", p);
+            //log_free(sentinel_add(p));
+
+            size_t n = 1;
+            for (; pn + n < npages; ++n)
+                if (pagetable[pn + n] != B_PAGEPLUS)
+                    break;
+            debug (MEMSTOMP) memset(baseAddr + pn * PAGESIZE, 0xF3, n * PAGESIZE);
+            freePages(pn, n);
+        }
+    }
+}
+
+
+struct SmallObjectPool
+{
+    Pool base;
+    alias base this;
+
+    /**
+    * Get size of pointer p in pool.
+    */
+    size_t getSize(void *p) const nothrow
+    in
+    {
+        assert(p >= baseAddr);
+        assert(p < topAddr);
+    }
+    body
+    {
+        size_t pagenum = pagenumOf(p);
+        Bins bin = cast(Bins)pagetable[pagenum];
+        assert(bin < B_PAGE);
+        return binsize[bin];
+    }
+
+    BlkInfo getInfo(void* p) nothrow
+    {
+        BlkInfo info;
+        size_t offset = cast(size_t)(p - baseAddr);
+        size_t pn = offset / PAGESIZE;
+        Bins   bin = cast(Bins)pagetable[pn];
+
+        if (bin >= B_PAGE)
+            return info;
+
+        info.base = cast(void*)((cast(size_t)p) & notbinsize[bin]);
+        info.size = binsize[bin];
+        offset = info.base - baseAddr;
+        info.attr = getBits(cast(size_t)(offset >> shiftBy));
+
+        return info;
+    }
+
+    void runFinalizers(in void[] segment) nothrow
+    {
+        foreach (pn; 0 .. npages)
+        {
+            Bins bin = cast(Bins)pagetable[pn];
+            if (bin >= B_PAGE)
+                continue;
+
+            immutable size = binsize[bin];
+            auto p = baseAddr + pn * PAGESIZE;
+            const ptop = p + PAGESIZE;
+            immutable base = pn * (PAGESIZE/16);
+            immutable bitstride = size / 16;
+
+            bool freeBits;
+            PageBits toFree;
+
+            for (size_t i; p < ptop; p += size, i += bitstride)
+            {
+                immutable biti = base + i;
+
+                if (!finals.test(biti))
+                    continue;
+
+                auto q = sentinel_add(p);
+                uint attr = getBits(biti);
+
+                if(!rt_hasFinalizerInSegment(q, size, attr, segment))
+                    continue;
+
+                rt_finalizeFromGC(q, size, attr);
+
+                freeBits = true;
+                toFree.set(i);
+
+                debug(COLLECT_PRINTF) printf("\tcollecting %p\n", p);
+                //log_free(sentinel_add(p));
+
+                debug (MEMSTOMP) memset(p, 0xF3, size);
+            }
+
+            if (freeBits)
+                freePageBits(pn, toFree);
+        }
+    }
+
+    /**
+    * Allocate a page of bin's.
+    * Returns:
+    *           head of a single linked list of new entries
+    */
+    List* allocPage(Bins bin) nothrow
+    {
+        size_t pn;
+        for (pn = searchStart; pn < npages; pn++)
+            if (pagetable[pn] == B_FREE)
+                goto L1;
+
+        return null;
+
+    L1:
+        searchStart = pn + 1;
+        pagetable[pn] = cast(ubyte)bin;
+        freepages--;
+
+        // Convert page to free list
+        size_t size = binsize[bin];
+        void* p = baseAddr + pn * PAGESIZE;
+        void* ptop = p + PAGESIZE - size;
+        auto first = cast(List*) p;
+
+        for (; p < ptop; p += size)
+        {
+            (cast(List *)p).next = cast(List *)(p + size);
+            (cast(List *)p).pool = &base;
+        }
+        (cast(List *)p).next = null;
+        (cast(List *)p).pool = &base;
+        return first;
+    }
+}
+
+unittest // bugzilla 14467
+{
+    int[] arr = new int[10];
+    assert(arr.capacity);
+    arr = arr[$..$];
+    assert(arr.capacity);
+}
+
+unittest // bugzilla 15353
+{
+    import core.memory : GC;
+
+    static struct Foo
+    {
+        ~this()
+        {
+            GC.free(buf); // ignored in finalizer
+        }
+
+        void* buf;
+    }
+    new Foo(GC.malloc(10));
+    GC.collect();
+}
+
+unittest // bugzilla 15822
+{
+    import core.memory : GC;
+
+    ubyte[16] buf;
+    static struct Foo
+    {
+        ~this()
+        {
+            GC.removeRange(ptr);
+            GC.removeRoot(ptr);
+        }
+
+        ubyte* ptr;
+    }
+    GC.addRoot(buf.ptr);
+    GC.addRange(buf.ptr, buf.length);
+    new Foo(buf.ptr);
+    GC.collect();
+}
+
+/* ============================ SENTINEL =============================== */
+
+
+debug (SENTINEL)
+{
+    const size_t SENTINEL_PRE = cast(size_t) 0xF4F4F4F4F4F4F4F4UL; // 32 or 64 bits
+    const ubyte SENTINEL_POST = 0xF5;           // 8 bits
+    const uint SENTINEL_EXTRA = 2 * size_t.sizeof + 1;
+
+
+    inout(size_t*) sentinel_size(inout void *p) nothrow { return &(cast(inout size_t *)p)[-2]; }
+    inout(size_t*) sentinel_pre(inout void *p)  nothrow { return &(cast(inout size_t *)p)[-1]; }
+    inout(ubyte*) sentinel_post(inout void *p)  nothrow { return &(cast(inout ubyte *)p)[*sentinel_size(p)]; }
+
+
+    void sentinel_init(void *p, size_t size) nothrow
+    {
+        *sentinel_size(p) = size;
+        *sentinel_pre(p) = SENTINEL_PRE;
+        *sentinel_post(p) = SENTINEL_POST;
+    }
+
+
+    void sentinel_Invariant(const void *p) nothrow
+    {
+        debug
+        {
+            assert(*sentinel_pre(p) == SENTINEL_PRE);
+            assert(*sentinel_post(p) == SENTINEL_POST);
+        }
+        else if(*sentinel_pre(p) != SENTINEL_PRE || *sentinel_post(p) != SENTINEL_POST)
+            onInvalidMemoryOperationError(); // also trigger in release build
+    }
+
+
+    void *sentinel_add(void *p) nothrow
+    {
+        return p + 2 * size_t.sizeof;
+    }
+
+
+    void *sentinel_sub(void *p) nothrow
+    {
+        return p - 2 * size_t.sizeof;
+    }
+}
+else
+{
+    const uint SENTINEL_EXTRA = 0;
+
+
+    void sentinel_init(void *p, size_t size) nothrow
+    {
+    }
+
+
+    void sentinel_Invariant(const void *p) nothrow
+    {
+    }
+
+
+    void *sentinel_add(void *p) nothrow
+    {
+        return p;
+    }
+
+
+    void *sentinel_sub(void *p) nothrow
+    {
+        return p;
+    }
+}
+
+debug (MEMSTOMP)
+unittest
+{
+    import core.memory;
+    auto p = cast(uint*)GC.malloc(uint.sizeof*3);
+    assert(*p == 0xF0F0F0F0);
+    p[2] = 0; // First two will be used for free list
+    GC.free(p);
+    assert(p[2] == 0xF2F2F2F2);
+}
+
+debug (SENTINEL)
+unittest
+{
+    import core.memory;
+    auto p = cast(ubyte*)GC.malloc(1);
+    assert(p[-1] == 0xF4);
+    assert(p[ 1] == 0xF5);
+/*
+    p[1] = 0;
+    bool thrown;
+    try
+        GC.free(p);
+    catch (Error e)
+        thrown = true;
+    p[1] = 0xF5;
+    assert(thrown);
+*/
+}
diff --git a/libphobos/libdruntime/gc/os.d b/libphobos/libdruntime/gc/os.d
new file mode 100644
index 00000000000..a842f062456
--- /dev/null
+++ b/libphobos/libdruntime/gc/os.d
@@ -0,0 +1,200 @@
+/**
+ * Contains OS-level routines needed by the garbage collector.
+ *
+ * Copyright: Copyright Digital Mars 2005 - 2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, David Friedman, Sean Kelly, Leandro Lucarella
+ */
+
+/*          Copyright Digital Mars 2005 - 2013.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module gc.os;
+
+
+version (Windows)
+{
+    import core.sys.windows.windows;
+
+    alias int pthread_t;
+
+    pthread_t pthread_self() nothrow
+    {
+        return cast(pthread_t) GetCurrentThreadId();
+    }
+
+    //version = GC_Use_Alloc_Win32;
+}
+else version (Posix)
+{
+    import core.sys.posix.sys.mman;
+    version (FreeBSD) import core.sys.freebsd.sys.mman : MAP_ANON;
+    version (CRuntime_Glibc) import core.sys.linux.sys.mman : MAP_ANON;
+    version (OSX) import core.sys.osx.sys.mman : MAP_ANON;
+    import core.stdc.stdlib;
+
+    //version = GC_Use_Alloc_MMap;
+}
+else
+{
+    import core.stdc.stdlib;
+
+    //version = GC_Use_Alloc_Malloc;
+}
+
+/+
+static if(is(typeof(VirtualAlloc)))
+    version = GC_Use_Alloc_Win32;
+else static if (is(typeof(mmap)))
+    version = GC_Use_Alloc_MMap;
+else static if (is(typeof(valloc)))
+    version = GC_Use_Alloc_Valloc;
+else static if (is(typeof(malloc)))
+    version = GC_Use_Alloc_Malloc;
+else static assert(false, "No supported allocation methods available.");
++/
+
+static if (is(typeof(VirtualAlloc))) // version (GC_Use_Alloc_Win32)
+{
+    /**
+     * Map memory.
+     */
+    void *os_mem_map(size_t nbytes) nothrow
+    {
+        return VirtualAlloc(null, nbytes, MEM_RESERVE | MEM_COMMIT,
+                PAGE_READWRITE);
+    }
+
+
+    /**
+     * Unmap memory allocated with os_mem_map().
+     * Returns:
+     *      0       success
+     *      !=0     failure
+     */
+    int os_mem_unmap(void *base, size_t nbytes) nothrow
+    {
+        return cast(int)(VirtualFree(base, 0, MEM_RELEASE) == 0);
+    }
+}
+else static if (is(typeof(mmap)))  // else version (GC_Use_Alloc_MMap)
+{
+    void *os_mem_map(size_t nbytes) nothrow
+    {   void *p;
+
+        p = mmap(null, nbytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+        return (p == MAP_FAILED) ? null : p;
+    }
+
+
+    int os_mem_unmap(void *base, size_t nbytes) nothrow
+    {
+        return munmap(base, nbytes);
+    }
+}
+else static if (is(typeof(valloc))) // else version (GC_Use_Alloc_Valloc)
+{
+    void *os_mem_map(size_t nbytes) nothrow
+    {
+        return valloc(nbytes);
+    }
+
+
+    int os_mem_unmap(void *base, size_t nbytes) nothrow
+    {
+        free(base);
+        return 0;
+    }
+}
+else static if (is(typeof(malloc))) // else version (GC_Use_Alloc_Malloc)
+{
+    // NOTE: This assumes malloc granularity is at least (void*).sizeof.  If
+    //       (req_size + PAGESIZE) is allocated, and the pointer is rounded up
+    //       to PAGESIZE alignment, there will be space for a void* at the end
+    //       after PAGESIZE bytes used by the GC.
+
+
+    import gc.gc;
+
+
+    const size_t PAGE_MASK = PAGESIZE - 1;
+
+
+    void *os_mem_map(size_t nbytes) nothrow
+    {   byte *p, q;
+        p = cast(byte *) malloc(nbytes + PAGESIZE);
+        q = p + ((PAGESIZE - ((cast(size_t) p & PAGE_MASK))) & PAGE_MASK);
+        * cast(void**)(q + nbytes) = p;
+        return q;
+    }
+
+
+    int os_mem_unmap(void *base, size_t nbytes) nothrow
+    {
+        free( *cast(void**)( cast(byte*) base + nbytes ) );
+        return 0;
+    }
+}
+else
+{
+    static assert(false, "No supported allocation methods available.");
+}
+
+/**
+   Check for any kind of memory pressure.
+
+   Params:
+      mapped = the amount of memory mapped by the GC in bytes
+   Returns:
+       true if memory is scarce
+*/
+// TOOD: get virtual mem sizes and current usage from OS
+// TODO: compare current RSS and avail. physical memory
+version (Windows)
+{
+    bool isLowOnMem(size_t mapped) nothrow @nogc
+    {
+        version (D_LP64)
+            return false;
+        else
+        {
+            import core.sys.windows.windows;
+            MEMORYSTATUS stat;
+            GlobalMemoryStatus(&stat);
+            // Less than 5 % of virtual address space available
+            return stat.dwAvailVirtual < stat.dwTotalVirtual / 20;
+        }
+    }
+}
+else version (OSX)
+{
+    bool isLowOnMem(size_t mapped) nothrow @nogc
+    {
+        enum GB = 2 ^^ 30;
+        version (D_LP64)
+            return false;
+        else
+        {
+            // 80 % of available 4GB is used for GC (excluding malloc and mmap)
+            enum size_t limit = 4UL * GB * 8 / 10;
+            return mapped > limit;
+        }
+    }
+}
+else
+{
+    bool isLowOnMem(size_t mapped) nothrow @nogc
+    {
+        enum GB = 2 ^^ 30;
+        version (D_LP64)
+            return false;
+        else
+        {
+            // be conservative and assume 3GB
+            enum size_t limit = 3UL * GB * 8 / 10;
+            return mapped > limit;
+        }
+    }
+}
diff --git a/libphobos/libdruntime/gc/pooltable.d b/libphobos/libdruntime/gc/pooltable.d
new file mode 100644
index 00000000000..da2796dc981
--- /dev/null
+++ b/libphobos/libdruntime/gc/pooltable.d
@@ -0,0 +1,285 @@
+/**
+ * A sorted array to quickly lookup pools.
+ *
+ * Copyright: Copyright Digital Mars 2001 -.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, David Friedman, Sean Kelly, Martin Nowak
+ */
+module gc.pooltable;
+
+static import cstdlib=core.stdc.stdlib;
+
+struct PoolTable(Pool)
+{
+    import core.stdc.string : memmove;
+
+nothrow:
+    void Dtor()
+    {
+        cstdlib.free(pools);
+        pools = null;
+        npools = 0;
+    }
+
+    bool insert(Pool* pool)
+    {
+        auto newpools = cast(Pool **)cstdlib.realloc(pools, (npools + 1) * pools[0].sizeof);
+        if (!newpools)
+            return false;
+
+        pools = newpools;
+
+        // Sort pool into newpooltable[]
+        size_t i;
+        for (; i < npools; ++i)
+        {
+            if (pool.baseAddr < pools[i].baseAddr)
+                break;
+        }
+        if (i != npools)
+            memmove(pools + i + 1, pools + i, (npools - i) * pools[0].sizeof);
+        pools[i] = pool;
+
+        ++npools;
+
+        _minAddr = pools[0].baseAddr;
+        _maxAddr = pools[npools - 1].topAddr;
+
+        return true;
+    }
+
+    @property size_t length() pure const
+    {
+        return npools;
+    }
+
+    ref inout(Pool*) opIndex(size_t idx) inout pure
+    in { assert(idx < length); }
+    body
+    {
+        return pools[idx];
+    }
+
+    inout(Pool*)[] opSlice(size_t a, size_t b) inout pure
+    in { assert(a <= length && b <= length); }
+    body
+    {
+        return pools[a .. b];
+    }
+
+    alias opDollar = length;
+
+    /**
+     * Find Pool that pointer is in.
+     * Return null if not in a Pool.
+     * Assume pooltable[] is sorted.
+     */
+    Pool *findPool(void *p) nothrow
+    {
+        if (p >= minAddr && p < maxAddr)
+        {
+            assert(npools);
+
+            // let dmd allocate a register for this.pools
+            auto pools = this.pools;
+
+            if (npools == 1)
+                return pools[0];
+
+            /* The pooltable[] is sorted by address, so do a binary search
+             */
+            size_t low = 0;
+            size_t high = npools - 1;
+            while (low <= high)
+            {
+                size_t mid = (low + high) >> 1;
+                auto pool = pools[mid];
+                if (p < pool.baseAddr)
+                    high = mid - 1;
+                else if (p >= pool.topAddr)
+                    low = mid + 1;
+                else
+                    return pool;
+            }
+        }
+        return null;
+    }
+
+    // semi-stable partition, returns right half for which pred is false
+    Pool*[] minimize() pure
+    {
+        static void swap(ref Pool* a, ref Pool* b)
+        {
+            auto c = a; a = b; b = c;
+        }
+
+        size_t i;
+        // find first bad entry
+        for (; i < npools; ++i)
+            if (pools[i].isFree) break;
+
+        // move good in front of bad entries
+        size_t j = i + 1;
+        for (; j < npools; ++j)
+        {
+            if (!pools[j].isFree) // keep
+                swap(pools[i++], pools[j]);
+        }
+        // npooltable[0 .. i]      => used pools
+        // npooltable[i .. npools] => free pools
+
+        if (i)
+        {
+            _minAddr = pools[0].baseAddr;
+            _maxAddr = pools[i - 1].topAddr;
+        }
+        else
+        {
+            _minAddr = _maxAddr = null;
+        }
+
+        immutable len = npools;
+        npools = i;
+        // return freed pools to the caller
+        return pools[npools .. len];
+    }
+
+    void Invariant() const
+    {
+        if (!npools) return;
+
+        foreach (i, pool; pools[0 .. npools - 1])
+            assert(pool.baseAddr < pools[i + 1].baseAddr);
+
+        assert(_minAddr == pools[0].baseAddr);
+        assert(_maxAddr == pools[npools - 1].topAddr);
+    }
+
+    @property const(byte)* minAddr() pure const { return _minAddr; }
+    @property const(byte)* maxAddr() pure const { return _maxAddr; }
+
+package:
+    Pool** pools;
+    size_t npools;
+    byte* _minAddr, _maxAddr;
+}
+
+unittest
+{
+    enum NPOOLS = 6;
+    enum NPAGES = 10;
+    enum PAGESIZE = 4096;
+
+    static struct MockPool
+    {
+        byte* baseAddr, topAddr;
+        size_t freepages, npages;
+        @property bool isFree() const pure nothrow { return freepages == npages; }
+    }
+    PoolTable!MockPool pooltable;
+
+    void reset()
+    {
+        foreach(ref pool; pooltable[0 .. $])
+            pool.freepages = pool.npages;
+        pooltable.minimize();
+        assert(pooltable.length == 0);
+
+        foreach(i; 0 .. NPOOLS)
+        {
+            auto pool = cast(MockPool*)cstdlib.malloc(MockPool.sizeof);
+            *pool = MockPool.init;
+            assert(pooltable.insert(pool));
+        }
+    }
+
+    void usePools()
+    {
+        foreach(pool; pooltable[0 .. $])
+        {
+            pool.npages = NPAGES;
+            pool.freepages = NPAGES / 2;
+        }
+    }
+
+    // all pools are free
+    reset();
+    assert(pooltable.length == NPOOLS);
+    auto freed = pooltable.minimize();
+    assert(freed.length == NPOOLS);
+    assert(pooltable.length == 0);
+
+    // all pools used
+    reset();
+    usePools();
+    assert(pooltable.length == NPOOLS);
+    freed = pooltable.minimize();
+    assert(freed.length == 0);
+    assert(pooltable.length == NPOOLS);
+
+    // preserves order of used pools
+    reset();
+    usePools();
+
+    {
+        MockPool*[NPOOLS] opools = pooltable[0 .. NPOOLS];
+        // make the 2nd pool free
+        pooltable[2].freepages = NPAGES;
+
+        pooltable.minimize();
+        assert(pooltable.length == NPOOLS - 1);
+        assert(pooltable[0] == opools[0]);
+        assert(pooltable[1] == opools[1]);
+        assert(pooltable[2] == opools[3]);
+    }
+
+    // test that PoolTable reduces min/max address span
+    reset();
+    usePools();
+
+    byte* base, top;
+
+    {
+        // fill with fake addresses
+        size_t i;
+        foreach(pool; pooltable[0 .. NPOOLS])
+        {
+            pool.baseAddr = cast(byte*)(i++ * NPAGES * PAGESIZE);
+            pool.topAddr = pool.baseAddr + NPAGES * PAGESIZE;
+        }
+        base = pooltable[0].baseAddr;
+        top = pooltable[NPOOLS - 1].topAddr;
+    }
+
+    freed = pooltable.minimize();
+    assert(freed.length == 0);
+    assert(pooltable.length == NPOOLS);
+    assert(pooltable.minAddr == base);
+    assert(pooltable.maxAddr == top);
+
+    pooltable[NPOOLS - 1].freepages = NPAGES;
+    pooltable[NPOOLS - 2].freepages = NPAGES;
+
+    freed = pooltable.minimize();
+    assert(freed.length == 2);
+    assert(pooltable.length == NPOOLS - 2);
+    assert(pooltable.minAddr == base);
+    assert(pooltable.maxAddr == pooltable[NPOOLS - 3].topAddr);
+
+    pooltable[0].freepages = NPAGES;
+
+    freed = pooltable.minimize();
+    assert(freed.length == 1);
+    assert(pooltable.length == NPOOLS - 3);
+    assert(pooltable.minAddr != base);
+    assert(pooltable.minAddr == pooltable[0].baseAddr);
+    assert(pooltable.maxAddr == pooltable[NPOOLS - 4].topAddr);
+
+    // free all
+    foreach(pool; pooltable[0 .. $])
+        pool.freepages = NPAGES;
+    freed = pooltable.minimize();
+    assert(freed.length == NPOOLS - 3);
+    assert(pooltable.length == 0);
+    pooltable.Dtor();
+}
diff --git a/libphobos/libdruntime/gc/proxy.d b/libphobos/libdruntime/gc/proxy.d
new file mode 100644
index 00000000000..eb0f7ee275f
--- /dev/null
+++ b/libphobos/libdruntime/gc/proxy.d
@@ -0,0 +1,354 @@
+/**
+ * Contains the external GC interface.
+ *
+ * Copyright: Copyright Digital Mars 2005 - 2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Sean Kelly
+ */
+
+/*          Copyright Digital Mars 2005 - 2013.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module gc.proxy;
+
+import gc.gc;
+import gc.stats;
+import core.stdc.stdlib;
+
+private
+{
+    __gshared GC _gc;
+
+    static import core.memory;
+    alias BlkInfo = core.memory.GC.BlkInfo;
+
+    extern (C) void thread_init();
+    extern (C) void thread_term();
+
+    struct Proxy
+    {
+        extern (C)
+        {
+            void function() gc_enable;
+            void function() gc_disable;
+        nothrow:
+            void function() gc_collect;
+            void function() gc_minimize;
+
+            uint function(void*) gc_getAttr;
+            uint function(void*, uint) gc_setAttr;
+            uint function(void*, uint) gc_clrAttr;
+
+            void*   function(size_t, uint, const TypeInfo) gc_malloc;
+            BlkInfo function(size_t, uint, const TypeInfo) gc_qalloc;
+            void*   function(size_t, uint, const TypeInfo) gc_calloc;
+            void*   function(void*, size_t, uint ba, const TypeInfo) gc_realloc;
+            size_t  function(void*, size_t, size_t, const TypeInfo) gc_extend;
+            size_t  function(size_t) gc_reserve;
+            void    function(void*) gc_free;
+
+            void*   function(void*) gc_addrOf;
+            size_t  function(void*) gc_sizeOf;
+
+            BlkInfo function(void*) gc_query;
+
+            void function(void*) gc_addRoot;
+            void function(void*, size_t, const TypeInfo ti) gc_addRange;
+
+            void function(void*) gc_removeRoot;
+            void function(void*) gc_removeRange;
+            void function(in void[]) gc_runFinalizers;
+
+            bool function() gc_inFinalizer;
+        }
+    }
+
+    __gshared Proxy  pthis;
+    __gshared Proxy* proxy;
+
+    void initProxy()
+    {
+        pthis.gc_enable = &gc_enable;
+        pthis.gc_disable = &gc_disable;
+        pthis.gc_collect = &gc_collect;
+        pthis.gc_minimize = &gc_minimize;
+
+        pthis.gc_getAttr = &gc_getAttr;
+        pthis.gc_setAttr = &gc_setAttr;
+        pthis.gc_clrAttr = &gc_clrAttr;
+
+        pthis.gc_malloc = &gc_malloc;
+        pthis.gc_qalloc = &gc_qalloc;
+        pthis.gc_calloc = &gc_calloc;
+        pthis.gc_realloc = &gc_realloc;
+        pthis.gc_extend = &gc_extend;
+        pthis.gc_reserve = &gc_reserve;
+        pthis.gc_free = &gc_free;
+
+        pthis.gc_addrOf = &gc_addrOf;
+        pthis.gc_sizeOf = &gc_sizeOf;
+
+        pthis.gc_query = &gc_query;
+
+        pthis.gc_addRoot = &gc_addRoot;
+        pthis.gc_addRange = &gc_addRange;
+
+        pthis.gc_removeRoot = &gc_removeRoot;
+        pthis.gc_removeRange = &gc_removeRange;
+        pthis.gc_runFinalizers = &gc_runFinalizers;
+
+        pthis.gc_inFinalizer = &gc_inFinalizer;
+    }
+}
+
+extern (C)
+{
+
+    void gc_init()
+    {
+        _gc.initialize();
+        // NOTE: The GC must initialize the thread library
+        //       before its first collection.
+        thread_init();
+        initProxy();
+    }
+
+    void gc_term()
+    {
+        // NOTE: There may be daemons threads still running when this routine is
+        //       called.  If so, cleaning memory out from under then is a good
+        //       way to make them crash horribly.  This probably doesn't matter
+        //       much since the app is supposed to be shutting down anyway, but
+        //       I'm disabling cleanup for now until I can think about it some
+        //       more.
+        //
+        // NOTE: Due to popular demand, this has been re-enabled.  It still has
+        //       the problems mentioned above though, so I guess we'll see.
+        _gc.fullCollectNoStack(); // not really a 'collect all' -- still scans
+                                  // static data area, roots, and ranges.
+        thread_term();
+
+        _gc.Dtor();
+    }
+
+    void gc_enable()
+    {
+        if( proxy is null )
+            return _gc.enable();
+        return proxy.gc_enable();
+    }
+
+    void gc_disable()
+    {
+        if( proxy is null )
+            return _gc.disable();
+        return proxy.gc_disable();
+    }
+
+    void gc_collect() nothrow
+    {
+        if( proxy is null )
+        {
+            _gc.fullCollect();
+            return;
+        }
+        return proxy.gc_collect();
+    }
+
+    void gc_minimize() nothrow
+    {
+        if( proxy is null )
+            return _gc.minimize();
+        return proxy.gc_minimize();
+    }
+
+    uint gc_getAttr( void* p ) nothrow
+    {
+        if( proxy is null )
+            return _gc.getAttr( p );
+        return proxy.gc_getAttr( p );
+    }
+
+    uint gc_setAttr( void* p, uint a ) nothrow
+    {
+        if( proxy is null )
+            return _gc.setAttr( p, a );
+        return proxy.gc_setAttr( p, a );
+    }
+
+    uint gc_clrAttr( void* p, uint a ) nothrow
+    {
+        if( proxy is null )
+            return _gc.clrAttr( p, a );
+        return proxy.gc_clrAttr( p, a );
+    }
+
+    void* gc_malloc( size_t sz, uint ba = 0, const TypeInfo ti = null ) nothrow
+    {
+        if( proxy is null )
+            return _gc.malloc( sz, ba, null, ti );
+        return proxy.gc_malloc( sz, ba, ti );
+    }
+
+    BlkInfo gc_qalloc( size_t sz, uint ba = 0, const TypeInfo ti = null ) nothrow
+    {
+        if( proxy is null )
+        {
+            BlkInfo retval;
+            retval.base = _gc.malloc( sz, ba, &retval.size, ti );
+            retval.attr = ba;
+            return retval;
+        }
+        return proxy.gc_qalloc( sz, ba, ti );
+    }
+
+    void* gc_calloc( size_t sz, uint ba = 0, const TypeInfo ti = null ) nothrow
+    {
+        if( proxy is null )
+            return _gc.calloc( sz, ba, null, ti );
+        return proxy.gc_calloc( sz, ba, ti );
+    }
+
+    void* gc_realloc( void* p, size_t sz, uint ba = 0, const TypeInfo ti = null ) nothrow
+    {
+        if( proxy is null )
+            return _gc.realloc( p, sz, ba, null, ti );
+        return proxy.gc_realloc( p, sz, ba, ti );
+    }
+
+    size_t gc_extend( void* p, size_t mx, size_t sz, const TypeInfo ti = null ) nothrow
+    {
+        if( proxy is null )
+            return _gc.extend( p, mx, sz, ti );
+        return proxy.gc_extend( p, mx, sz,ti );
+    }
+
+    size_t gc_reserve( size_t sz ) nothrow
+    {
+        if( proxy is null )
+            return _gc.reserve( sz );
+        return proxy.gc_reserve( sz );
+    }
+
+    void gc_free( void* p ) nothrow
+    {
+        if( proxy is null )
+            return _gc.free( p );
+        return proxy.gc_free( p );
+    }
+
+    void* gc_addrOf( void* p ) nothrow
+    {
+        if( proxy is null )
+            return _gc.addrOf( p );
+        return proxy.gc_addrOf( p );
+    }
+
+    size_t gc_sizeOf( void* p ) nothrow
+    {
+        if( proxy is null )
+            return _gc.sizeOf( p );
+        return proxy.gc_sizeOf( p );
+    }
+
+    BlkInfo gc_query( void* p ) nothrow
+    {
+        if( proxy is null )
+            return _gc.query( p );
+        return proxy.gc_query( p );
+    }
+
+    // NOTE: This routine is experimental. The stats or function name may change
+    //       before it is made officially available.
+    GCStats gc_stats() nothrow
+    {
+        if( proxy is null )
+        {
+            GCStats stats = void;
+            _gc.getStats( stats );
+            return stats;
+        }
+        // TODO: Add proxy support for this once the layout of GCStats is
+        //       finalized.
+        //return proxy.gc_stats();
+        return GCStats.init;
+    }
+
+    void gc_addRoot( void* p ) nothrow
+    {
+        if( proxy is null )
+            return _gc.addRoot( p );
+        return proxy.gc_addRoot( p );
+    }
+
+    void gc_addRange( void* p, size_t sz, const TypeInfo ti = null ) nothrow
+    {
+        if( proxy is null )
+            return _gc.addRange( p, sz, ti );
+        return proxy.gc_addRange( p, sz, ti );
+    }
+
+    void gc_removeRoot( void* p ) nothrow
+    {
+        if( proxy is null )
+            return _gc.removeRoot( p );
+        return proxy.gc_removeRoot( p );
+    }
+
+    void gc_removeRange( void* p ) nothrow
+    {
+        if( proxy is null )
+            return _gc.removeRange( p );
+        return proxy.gc_removeRange( p );
+    }
+
+    void gc_runFinalizers( in void[] segment ) nothrow
+    {
+        if( proxy is null )
+            return _gc.runFinalizers( segment );
+        return proxy.gc_runFinalizers( segment );
+    }
+
+    bool gc_inFinalizer() nothrow
+    {
+        if( proxy is null )
+            return _gc.inFinalizer;
+        return proxy.gc_inFinalizer();
+    }
+
+    Proxy* gc_getProxy() nothrow
+    {
+        return &pthis;
+    }
+
+    export
+    {
+        void gc_setProxy( Proxy* p )
+        {
+            if( proxy !is null )
+            {
+                // TODO: Decide if this is an error condition.
+            }
+            proxy = p;
+            foreach (r; _gc.rootIter)
+                proxy.gc_addRoot( r );
+
+            foreach (r; _gc.rangeIter)
+                proxy.gc_addRange( r.pbot, r.ptop - r.pbot, null );
+        }
+
+        void gc_clrProxy()
+        {
+            foreach (r; _gc.rangeIter)
+                proxy.gc_removeRange( r.pbot );
+
+            foreach (r; _gc.rootIter)
+                proxy.gc_removeRoot( r );
+
+            proxy = null;
+        }
+    }
+
+}
diff --git a/libphobos/libdruntime/gc/stats.d b/libphobos/libdruntime/gc/stats.d
new file mode 100644
index 00000000000..2d6a01a350e
--- /dev/null
+++ b/libphobos/libdruntime/gc/stats.d
@@ -0,0 +1,27 @@
+/**
+ * Contains a struct for storing GC statistics.
+ *
+ * Copyright: Copyright Digital Mars 2005 - 2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Sean Kelly
+ */
+
+/*          Copyright Digital Mars 2005 - 2013.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module gc.stats;
+
+
+/**
+ *
+ */
+struct GCStats
+{
+    size_t poolsize;        // total size of pool
+    size_t usedsize;        // bytes allocated
+    size_t freeblocks;      // number of blocks marked FREE
+    size_t freelistsize;    // total of memory on free lists
+    size_t pageblocks;      // number of blocks marked PAGE
+}
diff --git a/libphobos/libdruntime/gcstub/gc.d b/libphobos/libdruntime/gcstub/gc.d
new file mode 100644
index 00000000000..b357a8074ea
--- /dev/null
+++ b/libphobos/libdruntime/gcstub/gc.d
@@ -0,0 +1,388 @@
+/**
+ * This module contains a minimal garbage collector implementation according to
+ * published requirements.  This library is mostly intended to serve as an
+ * example, but it is usable in applications which do not rely on a garbage
+ * collector to clean up memory (ie. when dynamic array resizing is not used,
+ * and all memory allocated with 'new' is freed deterministically with
+ * 'delete').
+ *
+ * Please note that block attribute data must be tracked, or at a minimum, the
+ * FINALIZE bit must be tracked for any allocated memory block because calling
+ * rt_finalize on a non-object block can result in an access violation.  In the
+ * allocator below, this tracking is done via a leading uint bitmask.  A real
+ * allocator may do better to store this data separately, similar to the basic
+ * GC.
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ */
+
+/*          Copyright Sean Kelly 2005 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module gc.gc;
+
+private
+{
+    import core.stdc.stdlib;
+    import core.stdc.stdio;
+
+    static import core.memory;
+    private alias BlkAttr = core.memory.GC.BlkAttr;
+    private alias BlkInfo = core.memory.GC.BlkInfo;
+
+    extern (C) void thread_init();
+    extern (C) void onOutOfMemoryError(void* pretend_sideffect = null) @trusted pure nothrow @nogc; /* dmd @@@BUG11461@@@ */
+
+    struct Proxy
+    {
+        extern (C) void function() gc_enable;
+        extern (C) void function() gc_disable;
+        extern (C) void function() gc_collect;
+        extern (C) void function() gc_minimize;
+
+        extern (C) uint function(void*) gc_getAttr;
+        extern (C) uint function(void*, uint) gc_setAttr;
+        extern (C) uint function(void*, uint) gc_clrAttr;
+
+        extern (C) void*   function(size_t, uint, const TypeInfo) gc_malloc;
+        extern (C) BlkInfo function(size_t, uint, const TypeInfo) gc_qalloc;
+        extern (C) void*   function(size_t, uint, const TypeInfo) gc_calloc;
+        extern (C) void*   function(void*, size_t, uint ba, const TypeInfo) gc_realloc;
+        extern (C) size_t  function(void*, size_t, size_t, const TypeInfo) gc_extend;
+        extern (C) size_t  function(size_t) gc_reserve;
+        extern (C) void    function(void*) gc_free;
+
+        extern (C) void*   function(void*) gc_addrOf;
+        extern (C) size_t  function(void*) gc_sizeOf;
+
+        extern (C) BlkInfo function(void*) gc_query;
+
+        extern (C) void function(void*) gc_addRoot;
+        extern (C) void function(void*, size_t, const TypeInfo ti) gc_addRange;
+
+        extern (C) void function(void*) gc_removeRoot;
+        extern (C) void function(void*) gc_removeRange;
+        extern (C) void function(in void[]) gc_runFinalizers;
+
+        extern (C) bool function() gc_inFinalizer;
+    }
+
+    __gshared Proxy  pthis;
+    __gshared Proxy* proxy;
+
+    void initProxy()
+    {
+        pthis.gc_enable = &gc_enable;
+        pthis.gc_disable = &gc_disable;
+        pthis.gc_collect = &gc_collect;
+        pthis.gc_minimize = &gc_minimize;
+
+        pthis.gc_getAttr = &gc_getAttr;
+        pthis.gc_setAttr = &gc_setAttr;
+        pthis.gc_clrAttr = &gc_clrAttr;
+
+        pthis.gc_malloc = &gc_malloc;
+        pthis.gc_qalloc = &gc_qalloc;
+        pthis.gc_calloc = &gc_calloc;
+        pthis.gc_realloc = &gc_realloc;
+        pthis.gc_extend = &gc_extend;
+        pthis.gc_reserve = &gc_reserve;
+        pthis.gc_free = &gc_free;
+
+        pthis.gc_addrOf = &gc_addrOf;
+        pthis.gc_sizeOf = &gc_sizeOf;
+
+        pthis.gc_query = &gc_query;
+
+        pthis.gc_addRoot = &gc_addRoot;
+        pthis.gc_addRange = &gc_addRange;
+
+        pthis.gc_removeRoot = &gc_removeRoot;
+        pthis.gc_removeRange = &gc_removeRange;
+        pthis.gc_runFinalizers = &gc_runFinalizers;
+
+        pthis.gc_inFinalizer = &gc_inFinalizer;
+    }
+
+    __gshared void** roots  = null;
+    __gshared size_t nroots = 0;
+
+    struct Range
+    {
+        void*  pos;
+        size_t len;
+        TypeInfo ti; // should be tail const, but doesn't exist for references
+    }
+
+    __gshared Range* ranges  = null;
+    __gshared size_t nranges = 0;
+}
+
+extern (C) void gc_init()
+{
+    // NOTE: The GC must initialize the thread library before its first
+    //       collection, and always before returning from gc_init().
+    thread_init();
+    initProxy();
+}
+
+extern (C) void gc_term()
+{
+    free( roots );
+    free( ranges );
+}
+
+extern (C) void gc_enable()
+{
+    if( proxy is null )
+        return;
+    return proxy.gc_enable();
+}
+
+extern (C) void gc_disable()
+{
+    if( proxy is null )
+        return;
+    return proxy.gc_disable();
+}
+
+extern (C) void gc_collect()
+{
+    if( proxy is null )
+        return;
+    return proxy.gc_collect();
+}
+
+extern (C) void gc_minimize()
+{
+    if( proxy is null )
+        return;
+    return proxy.gc_minimize();
+}
+
+extern (C) uint gc_getAttr( void* p )
+{
+    if( proxy is null )
+        return 0;
+    return proxy.gc_getAttr( p );
+}
+
+extern (C) uint gc_setAttr( void* p, uint a )
+{
+    if( proxy is null )
+        return 0;
+    return proxy.gc_setAttr( p, a );
+}
+
+extern (C) uint gc_clrAttr( void* p, uint a )
+{
+    if( proxy is null )
+        return 0;
+    return proxy.gc_clrAttr( p, a );
+}
+
+extern (C) void* gc_malloc( size_t sz, uint ba = 0, const TypeInfo ti = null )
+{
+    if( proxy is null )
+    {
+        void* p = malloc( sz );
+
+        if( sz && p is null )
+            onOutOfMemoryError();
+        return p;
+    }
+    return proxy.gc_malloc( sz, ba, ti );
+}
+
+extern (C) BlkInfo gc_qalloc( size_t sz, uint ba = 0, const TypeInfo ti = null )
+{
+    if( proxy is null )
+    {
+        BlkInfo retval;
+        retval.base = gc_malloc(sz, ba);
+        retval.size = sz;
+        retval.attr = ba;
+        return retval;
+    }
+    return proxy.gc_qalloc( sz, ba, ti );
+}
+
+extern (C) void* gc_calloc( size_t sz, uint ba = 0, const TypeInfo ti = null )
+{
+    if( proxy is null )
+    {
+        void* p = calloc( 1, sz );
+
+        if( sz && p is null )
+            onOutOfMemoryError();
+        return p;
+    }
+    return proxy.gc_calloc( sz, ba, ti );
+}
+
+extern (C) void* gc_realloc( void* p, size_t sz, uint ba = 0, const TypeInfo ti = null )
+{
+    if( proxy is null )
+    {
+        p = realloc( p, sz );
+
+        if( sz && p is null )
+            onOutOfMemoryError();
+        return p;
+    }
+    return proxy.gc_realloc( p, sz, ba, ti );
+}
+
+extern (C) size_t gc_extend( void* p, size_t mx, size_t sz, const TypeInfo ti = null )
+{
+    if( proxy is null )
+        return 0;
+    return proxy.gc_extend( p, mx, sz, ti );
+}
+
+extern (C) size_t gc_reserve( size_t sz )
+{
+    if( proxy is null )
+        return 0;
+    return proxy.gc_reserve( sz );
+}
+
+extern (C) void gc_free( void* p )
+{
+    if( proxy is null )
+        return free( p );
+    return proxy.gc_free( p );
+}
+
+extern (C) void* gc_addrOf( void* p )
+{
+    if( proxy is null )
+        return null;
+    return proxy.gc_addrOf( p );
+}
+
+extern (C) size_t gc_sizeOf( void* p )
+{
+    if( proxy is null )
+        return 0;
+    return proxy.gc_sizeOf( p );
+}
+
+extern (C) BlkInfo gc_query( void* p )
+{
+    if( proxy is null )
+        return BlkInfo.init;
+    return proxy.gc_query( p );
+}
+
+extern (C) void gc_addRoot( void* p )
+{
+    if( proxy is null )
+    {
+        void** r = cast(void**) realloc( roots,
+                                         (nroots+1) * roots[0].sizeof );
+        if( r is null )
+            onOutOfMemoryError();
+        r[nroots++] = p;
+        roots = r;
+        return;
+    }
+    return proxy.gc_addRoot( p );
+}
+
+extern (C) void gc_addRange( void* p, size_t sz, const TypeInfo ti = null )
+{
+    //printf("gcstub::gc_addRange() proxy = %p\n", proxy);
+    if( proxy is null )
+    {
+        Range* r = cast(Range*) realloc( ranges,
+                                         (nranges+1) * ranges[0].sizeof );
+        if( r is null )
+            onOutOfMemoryError();
+        r[nranges].pos = p;
+        r[nranges].len = sz;
+        r[nranges].ti = cast()ti;
+        ranges = r;
+        ++nranges;
+        return;
+    }
+    return proxy.gc_addRange( p, sz, ti );
+}
+
+extern (C) void gc_removeRoot( void *p )
+{
+    if( proxy is null )
+    {
+        for( size_t i = 0; i < nroots; ++i )
+        {
+            if( roots[i] is p )
+            {
+                roots[i] = roots[--nroots];
+                return;
+            }
+        }
+        assert( false );
+    }
+    return proxy.gc_removeRoot( p );
+}
+
+extern (C) void gc_removeRange( void *p )
+{
+    if( proxy is null )
+    {
+        for( size_t i = 0; i < nranges; ++i )
+        {
+            if( ranges[i].pos is p )
+            {
+                ranges[i] = ranges[--nranges];
+                return;
+            }
+        }
+        assert( false );
+    }
+    return proxy.gc_removeRange( p );
+}
+
+extern (C) void gc_runFinalizers( in void[] segment )
+{
+    if( proxy !is null )
+        proxy.gc_runFinalizers( segment );
+}
+
+extern (C) bool gc_inFinalizer()
+{
+    if( proxy !is null )
+        return proxy.gc_inFinalizer();
+    return false;
+}
+
+extern (C) Proxy* gc_getProxy()
+{
+    return &pthis;
+}
+
+export extern (C) void gc_setProxy( Proxy* p )
+{
+    if( proxy !is null )
+    {
+        // TODO: Decide if this is an error condition.
+    }
+    proxy = p;
+    foreach( r; roots[0 .. nroots] )
+        proxy.gc_addRoot( r );
+    foreach( r; ranges[0 .. nranges] )
+        proxy.gc_addRange( r.pos, r.len, r.ti );
+}
+
+export extern (C) void gc_clrProxy()
+{
+    foreach( r; ranges[0 .. nranges] )
+        proxy.gc_removeRange( r.pos );
+    foreach( r; roots[0 .. nroots] )
+        proxy.gc_removeRoot( r );
+    proxy = null;
+}
diff --git a/libphobos/libdruntime/object.d b/libphobos/libdruntime/object.d
new file mode 100644
index 00000000000..d5d4d81f5a9
--- /dev/null
+++ b/libphobos/libdruntime/object.d
@@ -0,0 +1,3558 @@
+/**
+ * Forms the symbols available to all D programs. Includes Object, which is
+ * the root of the class object hierarchy.  This module is implicitly
+ * imported.
+ * Macros:
+ *      WIKI = Object
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2011.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Sean Kelly
+ */
+
+/*          Copyright Digital Mars 2000 - 2011.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module object;
+
+private
+{
+    extern (C) Object _d_newclass(const TypeInfo_Class ci);
+    extern (C) void rt_finalize(void *data, bool det=true);
+}
+
+// NOTE: For some reason, this declaration method doesn't work
+//       in this particular file (and this file only).  It must
+//       be a DMD thing.
+//alias typeof(int.sizeof)                    size_t;
+//alias typeof(cast(void*)0 - cast(void*)0)   ptrdiff_t;
+
+version(D_LP64)
+{
+    alias ulong size_t;
+    alias long  ptrdiff_t;
+}
+else
+{
+    alias uint  size_t;
+    alias int   ptrdiff_t;
+}
+
+alias ptrdiff_t sizediff_t; //For backwards compatibility only.
+
+alias size_t hash_t; //For backwards compatibility only.
+alias bool equals_t; //For backwards compatibility only.
+
+alias immutable(char)[]  string;
+alias immutable(wchar)[] wstring;
+alias immutable(dchar)[] dstring;
+
+version (D_ObjectiveC) public import core.attribute : selector;
+
+/**
+ * All D class objects inherit from Object.
+ */
+class Object
+{
+    /**
+     * Convert Object to a human readable string.
+     */
+    string toString()
+    {
+        return typeid(this).name;
+    }
+
+    /**
+     * Compute hash function for Object.
+     */
+    size_t toHash() @trusted nothrow
+    {
+        // BUG: this prevents a compacting GC from working, needs to be fixed
+        return cast(size_t)cast(void*)this;
+    }
+
+    /**
+     * Compare with another Object obj.
+     * Returns:
+     *  $(TABLE
+     *  $(TR $(TD this &lt; obj) $(TD &lt; 0))
+     *  $(TR $(TD this == obj) $(TD 0))
+     *  $(TR $(TD this &gt; obj) $(TD &gt; 0))
+     *  )
+     */
+    int opCmp(Object o)
+    {
+        // BUG: this prevents a compacting GC from working, needs to be fixed
+        //return cast(int)cast(void*)this - cast(int)cast(void*)o;
+
+        throw new Exception("need opCmp for class " ~ typeid(this).name);
+        //return this !is o;
+    }
+
+    /**
+     * Returns !=0 if this object does have the same contents as obj.
+     */
+    bool opEquals(Object o)
+    {
+        return this is o;
+    }
+
+    interface Monitor
+    {
+        void lock();
+        void unlock();
+    }
+
+    /**
+     * Create instance of class specified by the fully qualified name
+     * classname.
+     * The class must either have no constructors or have
+     * a default constructor.
+     * Returns:
+     *   null if failed
+     * Example:
+     * ---
+     * module foo.bar;
+     *
+     * class C
+     * {
+     *     this() { x = 10; }
+     *     int x;
+     * }
+     *
+     * void main()
+     * {
+     *     auto c = cast(C)Object.factory("foo.bar.C");
+     *     assert(c !is null && c.x == 10);
+     * }
+     * ---
+     */
+    static Object factory(string classname)
+    {
+        auto ci = TypeInfo_Class.find(classname);
+        if (ci)
+        {
+            return ci.create();
+        }
+        return null;
+    }
+}
+
+auto opEquals(Object lhs, Object rhs)
+{
+    // If aliased to the same object or both null => equal
+    if (lhs is rhs) return true;
+
+    // If either is null => non-equal
+    if (lhs is null || rhs is null) return false;
+
+    // If same exact type => one call to method opEquals
+    if (typeid(lhs) is typeid(rhs) ||
+        !__ctfe && typeid(lhs).opEquals(typeid(rhs)))
+            /* CTFE doesn't like typeid much. 'is' works, but opEquals doesn't
+            (issue 7147). But CTFE also guarantees that equal TypeInfos are
+            always identical. So, no opEquals needed during CTFE. */
+    {
+        return lhs.opEquals(rhs);
+    }
+
+    // General case => symmetric calls to method opEquals
+    return lhs.opEquals(rhs) && rhs.opEquals(lhs);
+}
+
+/************************
+* Returns true if lhs and rhs are equal.
+*/
+auto opEquals(const Object lhs, const Object rhs)
+{
+    // A hack for the moment.
+    return opEquals(cast()lhs, cast()rhs);
+}
+
+private extern(C) void _d_setSameMutex(shared Object ownee, shared Object owner) nothrow;
+
+void setSameMutex(shared Object ownee, shared Object owner)
+{
+    _d_setSameMutex(ownee, owner);
+}
+
+/**
+ * Information about an interface.
+ * When an object is accessed via an interface, an Interface* appears as the
+ * first entry in its vtbl.
+ */
+struct Interface
+{
+    TypeInfo_Class   classinfo;  /// .classinfo for this interface (not for containing class)
+    void*[]     vtbl;
+    size_t      offset;     /// offset to Interface 'this' from Object 'this'
+}
+
+/**
+ * Array of pairs giving the offset and type information for each
+ * member in an aggregate.
+ */
+struct OffsetTypeInfo
+{
+    size_t   offset;    /// Offset of member from start of object
+    TypeInfo ti;        /// TypeInfo for this member
+}
+
+/**
+ * Runtime type information about a type.
+ * Can be retrieved for any type using a
+ * $(GLINK2 expression,TypeidExpression, TypeidExpression).
+ */
+class TypeInfo
+{
+    override string toString() const pure @safe nothrow
+    {
+        return typeid(this).name;
+    }
+
+    override size_t toHash() @trusted const
+    {
+        import core.internal.traits : externDFunc;
+        alias hashOf = externDFunc!("rt.util.hash.hashOf",
+                                    size_t function(const(void)*, size_t, size_t) @trusted pure nothrow);
+        try
+        {
+            auto data = this.toString();
+            return hashOf(data.ptr, data.length, 0);
+        }
+        catch (Throwable)
+        {
+            // This should never happen; remove when toString() is made nothrow
+
+            // BUG: this prevents a compacting GC from working, needs to be fixed
+            return cast(size_t)cast(void*)this;
+        }
+    }
+
+    override int opCmp(Object o)
+    {
+        import core.internal.traits : externDFunc;
+        alias dstrcmp = externDFunc!("core.internal.string.dstrcmp",
+                                     int function(in char[] s1, in char[] s2) @trusted pure nothrow @nogc);
+
+        if (this is o)
+            return 0;
+        TypeInfo ti = cast(TypeInfo)o;
+        if (ti is null)
+            return 1;
+        return dstrcmp(this.toString(), ti.toString());
+    }
+
+    override bool opEquals(Object o)
+    {
+        /* TypeInfo instances are singletons, but duplicates can exist
+         * across DLL's. Therefore, comparing for a name match is
+         * sufficient.
+         */
+        if (this is o)
+            return true;
+        auto ti = cast(const TypeInfo)o;
+        return ti && this.toString() == ti.toString();
+    }
+
+    /// Returns a hash of the instance of a type.
+    size_t getHash(in void* p) @trusted nothrow const { return cast(size_t)p; }
+
+    /// Compares two instances for equality.
+    bool equals(in void* p1, in void* p2) const { return p1 == p2; }
+
+    /// Compares two instances for &lt;, ==, or &gt;.
+    int compare(in void* p1, in void* p2) const { return _xopCmp(p1, p2); }
+
+    /// Returns size of the type.
+    @property size_t tsize() nothrow pure const @safe @nogc { return 0; }
+
+    /// Swaps two instances of the type.
+    void swap(void* p1, void* p2) const
+    {
+        size_t n = tsize;
+        for (size_t i = 0; i < n; i++)
+        {
+            byte t = (cast(byte *)p1)[i];
+            (cast(byte*)p1)[i] = (cast(byte*)p2)[i];
+            (cast(byte*)p2)[i] = t;
+        }
+    }
+
+    /// Get TypeInfo for 'next' type, as defined by what kind of type this is,
+    /// null if none.
+    @property inout(TypeInfo) next() nothrow pure inout @nogc { return null; }
+
+    /// Return default initializer.  If the type should be initialized to all zeros,
+    /// an array with a null ptr and a length equal to the type size will be returned.
+    abstract const(void)[] initializer() nothrow pure const @safe @nogc;
+
+    /// $(RED Scheduled for deprecation.) Please use `initializer` instead.
+    alias init = initializer; // added in 2.070, to stay in 2.071
+    version(none) deprecated alias init = initializer; // planned for 2.072
+    version(none) @disable static const(void)[] init(); // planned for 2.073
+    /* Planned for 2.074: Remove init, making way for the init type property,
+    fixing issue 12233. */
+
+    /// Get flags for type: 1 means GC should scan for pointers,
+    /// 2 means arg of this type is passed in XMM register
+    @property uint flags() nothrow pure const @safe @nogc { return 0; }
+
+    /// Get type information on the contents of the type; null if not available
+    const(OffsetTypeInfo)[] offTi() const { return null; }
+    /// Run the destructor on the object and all its sub-objects
+    void destroy(void* p) const {}
+    /// Run the postblit on the object and all its sub-objects
+    void postblit(void* p) const {}
+
+
+    /// Return alignment of type
+    @property size_t talign() nothrow pure const @safe @nogc { return tsize; }
+
+    /** Return internal info on arguments fitting into 8byte.
+     * See X86-64 ABI 3.2.3
+     */
+    version (X86_64) int argTypes(out TypeInfo arg1, out TypeInfo arg2) @safe nothrow
+    {
+        arg1 = this;
+        return 0;
+    }
+
+    /** Return info used by the garbage collector to do precise collection.
+     */
+    @property immutable(void)* rtInfo() nothrow pure const @safe @nogc { return null; }
+}
+
+class TypeInfo_Typedef : TypeInfo
+{
+    override string toString() const { return name; }
+
+    override bool opEquals(Object o)
+    {
+        if (this is o)
+            return true;
+        auto c = cast(const TypeInfo_Typedef)o;
+        return c && this.name == c.name &&
+                    this.base == c.base;
+    }
+
+    override size_t getHash(in void* p) const { return base.getHash(p); }
+    override bool equals(in void* p1, in void* p2) const { return base.equals(p1, p2); }
+    override int compare(in void* p1, in void* p2) const { return base.compare(p1, p2); }
+    override @property size_t tsize() nothrow pure const { return base.tsize; }
+    override void swap(void* p1, void* p2) const { return base.swap(p1, p2); }
+
+    override @property inout(TypeInfo) next() nothrow pure inout { return base.next; }
+    override @property uint flags() nothrow pure const { return base.flags; }
+
+    override const(void)[] initializer() const
+    {
+        return m_init.length ? m_init : base.initializer();
+    }
+
+    override @property size_t talign() nothrow pure const { return base.talign; }
+
+    version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
+    {
+        return base.argTypes(arg1, arg2);
+    }
+
+    override @property immutable(void)* rtInfo() const { return base.rtInfo; }
+
+    TypeInfo base;
+    string   name;
+    void[]   m_init;
+}
+
+class TypeInfo_Enum : TypeInfo_Typedef
+{
+
+}
+
+// Please make sure to keep this in sync with TypeInfo_P (src/rt/typeinfo/ti_ptr.d)
+class TypeInfo_Pointer : TypeInfo
+{
+    override string toString() const { return m_next.toString() ~ "*"; }
+
+    override bool opEquals(Object o)
+    {
+        if (this is o)
+            return true;
+        auto c = cast(const TypeInfo_Pointer)o;
+        return c && this.m_next == c.m_next;
+    }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        return cast(size_t)*cast(void**)p;
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        return *cast(void**)p1 == *cast(void**)p2;
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        if (*cast(void**)p1 < *cast(void**)p2)
+            return -1;
+        else if (*cast(void**)p1 > *cast(void**)p2)
+            return 1;
+        else
+            return 0;
+    }
+
+    override @property size_t tsize() nothrow pure const
+    {
+        return (void*).sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. (void*).sizeof];
+    }
+
+    override void swap(void* p1, void* p2) const
+    {
+        void* tmp = *cast(void**)p1;
+        *cast(void**)p1 = *cast(void**)p2;
+        *cast(void**)p2 = tmp;
+    }
+
+    override @property inout(TypeInfo) next() nothrow pure inout { return m_next; }
+    override @property uint flags() nothrow pure const { return 1; }
+
+    TypeInfo m_next;
+}
+
+class TypeInfo_Array : TypeInfo
+{
+    override string toString() const { return value.toString() ~ "[]"; }
+
+    override bool opEquals(Object o)
+    {
+        if (this is o)
+            return true;
+        auto c = cast(const TypeInfo_Array)o;
+        return c && this.value == c.value;
+    }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        void[] a = *cast(void[]*)p;
+        return getArrayHash(value, a.ptr, a.length);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        void[] a1 = *cast(void[]*)p1;
+        void[] a2 = *cast(void[]*)p2;
+        if (a1.length != a2.length)
+            return false;
+        size_t sz = value.tsize;
+        for (size_t i = 0; i < a1.length; i++)
+        {
+            if (!value.equals(a1.ptr + i * sz, a2.ptr + i * sz))
+                return false;
+        }
+        return true;
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        void[] a1 = *cast(void[]*)p1;
+        void[] a2 = *cast(void[]*)p2;
+        size_t sz = value.tsize;
+        size_t len = a1.length;
+
+        if (a2.length < len)
+            len = a2.length;
+        for (size_t u = 0; u < len; u++)
+        {
+            int result = value.compare(a1.ptr + u * sz, a2.ptr + u * sz);
+            if (result)
+                return result;
+        }
+        return cast(int)a1.length - cast(int)a2.length;
+    }
+
+    override @property size_t tsize() nothrow pure const
+    {
+        return (void[]).sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. (void[]).sizeof];
+    }
+
+    override void swap(void* p1, void* p2) const
+    {
+        void[] tmp = *cast(void[]*)p1;
+        *cast(void[]*)p1 = *cast(void[]*)p2;
+        *cast(void[]*)p2 = tmp;
+    }
+
+    TypeInfo value;
+
+    override @property inout(TypeInfo) next() nothrow pure inout
+    {
+        return value;
+    }
+
+    override @property uint flags() nothrow pure const { return 1; }
+
+    override @property size_t talign() nothrow pure const
+    {
+        return (void[]).alignof;
+    }
+
+    version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
+    {
+        arg1 = typeid(size_t);
+        arg2 = typeid(void*);
+        return 0;
+    }
+}
+
+class TypeInfo_StaticArray : TypeInfo
+{
+    override string toString() const
+    {
+        import core.internal.traits : externDFunc;
+        alias sizeToTempString = externDFunc!("core.internal.string.unsignedToTempString",
+                                              char[] function(ulong, char[], uint) @safe pure nothrow @nogc);
+
+        char[20] tmpBuff = void;
+        return value.toString() ~ "[" ~ sizeToTempString(len, tmpBuff, 10) ~ "]";
+    }
+
+    override bool opEquals(Object o)
+    {
+        if (this is o)
+            return true;
+        auto c = cast(const TypeInfo_StaticArray)o;
+        return c && this.len == c.len &&
+                    this.value == c.value;
+    }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        return getArrayHash(value, p, len);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        size_t sz = value.tsize;
+
+        for (size_t u = 0; u < len; u++)
+        {
+            if (!value.equals(p1 + u * sz, p2 + u * sz))
+                return false;
+        }
+        return true;
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        size_t sz = value.tsize;
+
+        for (size_t u = 0; u < len; u++)
+        {
+            int result = value.compare(p1 + u * sz, p2 + u * sz);
+            if (result)
+                return result;
+        }
+        return 0;
+    }
+
+    override @property size_t tsize() nothrow pure const
+    {
+        return len * value.tsize;
+    }
+
+    override void swap(void* p1, void* p2) const
+    {
+        import core.memory;
+        import core.stdc.string : memcpy;
+
+        void* tmp;
+        size_t sz = value.tsize;
+        ubyte[16] buffer;
+        void* pbuffer;
+
+        if (sz < buffer.sizeof)
+            tmp = buffer.ptr;
+        else
+            tmp = pbuffer = (new void[sz]).ptr;
+
+        for (size_t u = 0; u < len; u += sz)
+        {
+            size_t o = u * sz;
+            memcpy(tmp, p1 + o, sz);
+            memcpy(p1 + o, p2 + o, sz);
+            memcpy(p2 + o, tmp, sz);
+        }
+        if (pbuffer)
+            GC.free(pbuffer);
+    }
+
+    override const(void)[] initializer() nothrow pure const
+    {
+        return value.initializer();
+    }
+
+    override @property inout(TypeInfo) next() nothrow pure inout { return value; }
+    override @property uint flags() nothrow pure const { return value.flags; }
+
+    override void destroy(void* p) const
+    {
+        auto sz = value.tsize;
+        p += sz * len;
+        foreach (i; 0 .. len)
+        {
+            p -= sz;
+            value.destroy(p);
+        }
+    }
+
+    override void postblit(void* p) const
+    {
+        auto sz = value.tsize;
+        foreach (i; 0 .. len)
+        {
+            value.postblit(p);
+            p += sz;
+        }
+    }
+
+    TypeInfo value;
+    size_t   len;
+
+    override @property size_t talign() nothrow pure const
+    {
+        return value.talign;
+    }
+
+    version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
+    {
+        arg1 = typeid(void*);
+        return 0;
+    }
+}
+
+class TypeInfo_AssociativeArray : TypeInfo
+{
+    override string toString() const
+    {
+        return value.toString() ~ "[" ~ key.toString() ~ "]";
+    }
+
+    override bool opEquals(Object o)
+    {
+        if (this is o)
+            return true;
+        auto c = cast(const TypeInfo_AssociativeArray)o;
+        return c && this.key == c.key &&
+                    this.value == c.value;
+    }
+
+    override bool equals(in void* p1, in void* p2) @trusted const
+    {
+        return !!_aaEqual(this, *cast(const void**) p1, *cast(const void**) p2);
+    }
+
+    override hash_t getHash(in void* p) nothrow @trusted const
+    {
+        return _aaGetHash(cast(void*)p, this);
+    }
+
+    // BUG: need to add the rest of the functions
+
+    override @property size_t tsize() nothrow pure const
+    {
+        return (char[int]).sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. (char[int]).sizeof];
+    }
+
+    override @property inout(TypeInfo) next() nothrow pure inout { return value; }
+    override @property uint flags() nothrow pure const { return 1; }
+
+    TypeInfo value;
+    TypeInfo key;
+
+    override @property size_t talign() nothrow pure const
+    {
+        return (char[int]).alignof;
+    }
+
+    version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
+    {
+        arg1 = typeid(void*);
+        return 0;
+    }
+}
+
+class TypeInfo_Vector : TypeInfo
+{
+    override string toString() const { return "__vector(" ~ base.toString() ~ ")"; }
+
+    override bool opEquals(Object o)
+    {
+        if (this is o)
+            return true;
+        auto c = cast(const TypeInfo_Vector)o;
+        return c && this.base == c.base;
+    }
+
+    override size_t getHash(in void* p) const { return base.getHash(p); }
+    override bool equals(in void* p1, in void* p2) const { return base.equals(p1, p2); }
+    override int compare(in void* p1, in void* p2) const { return base.compare(p1, p2); }
+    override @property size_t tsize() nothrow pure const { return base.tsize; }
+    override void swap(void* p1, void* p2) const { return base.swap(p1, p2); }
+
+    override @property inout(TypeInfo) next() nothrow pure inout { return base.next; }
+    override @property uint flags() nothrow pure const { return base.flags; }
+
+    override const(void)[] initializer() nothrow pure const
+    {
+        return base.initializer();
+    }
+
+    override @property size_t talign() nothrow pure const { return 16; }
+
+    version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
+    {
+        return base.argTypes(arg1, arg2);
+    }
+
+    TypeInfo base;
+}
+
+class TypeInfo_Function : TypeInfo
+{
+    override string toString() const
+    {
+        return cast(string)(next.toString() ~ "()");
+    }
+
+    override bool opEquals(Object o)
+    {
+        if (this is o)
+            return true;
+        auto c = cast(const TypeInfo_Function)o;
+        return c && this.deco == c.deco;
+    }
+
+    // BUG: need to add the rest of the functions
+
+    override @property size_t tsize() nothrow pure const
+    {
+        return 0;       // no size for functions
+    }
+
+    override const(void)[] initializer() const @safe
+    {
+        return null;
+    }
+
+    TypeInfo next;
+    string deco;
+}
+
+class TypeInfo_Delegate : TypeInfo
+{
+    override string toString() const
+    {
+        return cast(string)(next.toString() ~ " delegate()");
+    }
+
+    override bool opEquals(Object o)
+    {
+        if (this is o)
+            return true;
+        auto c = cast(const TypeInfo_Delegate)o;
+        return c && this.deco == c.deco;
+    }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        return hashOf(*cast(void delegate()*)p);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        auto dg1 = *cast(void delegate()*)p1;
+        auto dg2 = *cast(void delegate()*)p2;
+        return dg1 == dg2;
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        auto dg1 = *cast(void delegate()*)p1;
+        auto dg2 = *cast(void delegate()*)p2;
+
+        if (dg1 < dg2)
+            return -1;
+        else if (dg1 > dg2)
+            return 1;
+        else
+            return 0;
+    }
+
+    override @property size_t tsize() nothrow pure const
+    {
+        alias int delegate() dg;
+        return dg.sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. (int delegate()).sizeof];
+    }
+
+    override @property uint flags() nothrow pure const { return 1; }
+
+    TypeInfo next;
+    string deco;
+
+    override @property size_t talign() nothrow pure const
+    {
+        alias int delegate() dg;
+        return dg.alignof;
+    }
+
+    version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
+    {
+        arg1 = typeid(void*);
+        arg2 = typeid(void*);
+        return 0;
+    }
+}
+
+unittest
+{
+    // Bugzilla 15367
+    void f1() {}
+    void f2() {}
+
+    // TypeInfo_Delegate.getHash
+    int[void delegate()] aa;
+    assert(aa.length == 0);
+    aa[&f1] = 1;
+    assert(aa.length == 1);
+    aa[&f1] = 1;
+    assert(aa.length == 1);
+
+    auto a1 = [&f2, &f1];
+    auto a2 = [&f2, &f1];
+
+    // TypeInfo_Delegate.equals
+    for (auto i = 0; i < 2; i++)
+        assert(a1[i] == a2[i]);
+    assert(a1 == a2);
+
+    // TypeInfo_Delegate.compare
+    for (auto i = 0; i < 2; i++)
+        assert(a1[i] <= a2[i]);
+    assert(a1 <= a2);
+}
+
+/**
+ * Runtime type information about a class.
+ * Can be retrieved from an object instance by using the
+ * $(DDSUBLINK spec/property,classinfo, .classinfo) property.
+ */
+class TypeInfo_Class : TypeInfo
+{
+    override string toString() const { return info.name; }
+
+    override bool opEquals(Object o)
+    {
+        if (this is o)
+            return true;
+        auto c = cast(const TypeInfo_Class)o;
+        return c && this.info.name == c.info.name;
+    }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        auto o = *cast(Object*)p;
+        return o ? o.toHash() : 0;
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        Object o1 = *cast(Object*)p1;
+        Object o2 = *cast(Object*)p2;
+
+        return (o1 is o2) || (o1 && o1.opEquals(o2));
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        Object o1 = *cast(Object*)p1;
+        Object o2 = *cast(Object*)p2;
+        int c = 0;
+
+        // Regard null references as always being "less than"
+        if (o1 !is o2)
+        {
+            if (o1)
+            {
+                if (!o2)
+                    c = 1;
+                else
+                    c = o1.opCmp(o2);
+            }
+            else
+                c = -1;
+        }
+        return c;
+    }
+
+    override @property size_t tsize() nothrow pure const
+    {
+        return Object.sizeof;
+    }
+
+    override const(void)[] initializer() nothrow pure const @safe
+    {
+        return m_init;
+    }
+
+    override @property uint flags() nothrow pure const { return 1; }
+
+    override @property const(OffsetTypeInfo)[] offTi() nothrow pure const
+    {
+        return m_offTi;
+    }
+
+    @property auto info() @safe nothrow pure const { return this; }
+    @property auto typeinfo() @safe nothrow pure const { return this; }
+
+    byte[]      m_init;         /** class static initializer
+                                 * (init.length gives size in bytes of class)
+                                 */
+    string      name;           /// class name
+    void*[]     vtbl;           /// virtual function pointer table
+    Interface[] interfaces;     /// interfaces this class implements
+    TypeInfo_Class   base;           /// base class
+    void*       destructor;
+    void function(Object) classInvariant;
+    enum ClassFlags : uint
+    {
+        isCOMclass = 0x1,
+        noPointers = 0x2,
+        hasOffTi = 0x4,
+        hasCtor = 0x8,
+        hasGetMembers = 0x10,
+        hasTypeInfo = 0x20,
+        isAbstract = 0x40,
+        isCPPclass = 0x80,
+        hasDtor = 0x100,
+    }
+    ClassFlags m_flags;
+    void*       deallocator;
+    OffsetTypeInfo[] m_offTi;
+    void function(Object) defaultConstructor;   // default Constructor
+
+    immutable(void)* m_RTInfo;        // data for precise GC
+    override @property immutable(void)* rtInfo() const { return m_RTInfo; }
+
+    /**
+     * Search all modules for TypeInfo_Class corresponding to classname.
+     * Returns: null if not found
+     */
+    static const(TypeInfo_Class) find(in char[] classname)
+    {
+        foreach (m; ModuleInfo)
+        {
+          if (m)
+            //writefln("module %s, %d", m.name, m.localClasses.length);
+            foreach (c; m.localClasses)
+            {
+                if (c is null) continue;
+                //writefln("\tclass %s", c.name);
+                if (c.name == classname)
+                    return c;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Create instance of Object represented by 'this'.
+     */
+    Object create() const
+    {
+        if (m_flags & 8 && !defaultConstructor)
+            return null;
+        if (m_flags & 64) // abstract
+            return null;
+        Object o = _d_newclass(this);
+        if (m_flags & 8 && defaultConstructor)
+        {
+            defaultConstructor(o);
+        }
+        return o;
+    }
+}
+
+alias TypeInfo_Class ClassInfo;
+
+unittest
+{
+    // Bugzilla 14401
+    static class X
+    {
+        int a;
+    }
+
+    assert(typeid(X).initializer is typeid(X).m_init);
+    assert(typeid(X).initializer.length == typeid(const(X)).initializer.length);
+    assert(typeid(X).initializer.length == typeid(shared(X)).initializer.length);
+    assert(typeid(X).initializer.length == typeid(immutable(X)).initializer.length);
+}
+
+class TypeInfo_Interface : TypeInfo
+{
+    override string toString() const { return info.name; }
+
+    override bool opEquals(Object o)
+    {
+        if (this is o)
+            return true;
+        auto c = cast(const TypeInfo_Interface)o;
+        return c && this.info.name == typeid(c).name;
+    }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        Interface* pi = **cast(Interface ***)*cast(void**)p;
+        Object o = cast(Object)(*cast(void**)p - pi.offset);
+        assert(o);
+        return o.toHash();
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        Interface* pi = **cast(Interface ***)*cast(void**)p1;
+        Object o1 = cast(Object)(*cast(void**)p1 - pi.offset);
+        pi = **cast(Interface ***)*cast(void**)p2;
+        Object o2 = cast(Object)(*cast(void**)p2 - pi.offset);
+
+        return o1 == o2 || (o1 && o1.opCmp(o2) == 0);
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        Interface* pi = **cast(Interface ***)*cast(void**)p1;
+        Object o1 = cast(Object)(*cast(void**)p1 - pi.offset);
+        pi = **cast(Interface ***)*cast(void**)p2;
+        Object o2 = cast(Object)(*cast(void**)p2 - pi.offset);
+        int c = 0;
+
+        // Regard null references as always being "less than"
+        if (o1 != o2)
+        {
+            if (o1)
+            {
+                if (!o2)
+                    c = 1;
+                else
+                    c = o1.opCmp(o2);
+            }
+            else
+                c = -1;
+        }
+        return c;
+    }
+
+    override @property size_t tsize() nothrow pure const
+    {
+        return Object.sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. Object.sizeof];
+    }
+
+    override @property uint flags() nothrow pure const { return 1; }
+
+    TypeInfo_Class info;
+}
+
+class TypeInfo_Struct : TypeInfo
+{
+    override string toString() const { return name; }
+
+    override bool opEquals(Object o)
+    {
+        if (this is o)
+            return true;
+        auto s = cast(const TypeInfo_Struct)o;
+        return s && this.name == s.name &&
+                    this.initializer().length == s.initializer().length;
+    }
+
+    override size_t getHash(in void* p) @safe pure nothrow const
+    {
+        assert(p);
+        if (xtoHash)
+        {
+            return (*xtoHash)(p);
+        }
+        else
+        {
+            import core.internal.traits : externDFunc;
+            alias hashOf = externDFunc!("rt.util.hash.hashOf",
+                                        size_t function(const(void)*, size_t, size_t) @trusted pure nothrow);
+            return hashOf(p, initializer().length, 0);
+        }
+    }
+
+    override bool equals(in void* p1, in void* p2) @trusted pure nothrow const
+    {
+        import core.stdc.string : memcmp;
+
+        if (!p1 || !p2)
+            return false;
+        else if (xopEquals)
+        {
+            version(GNU)
+            {   // BUG: GDC and DMD use different calling conventions
+                return (*xopEquals)(p2, p1);
+            }
+            else
+                return (*xopEquals)(p1, p2);
+        }
+        else if (p1 == p2)
+            return true;
+        else
+            // BUG: relies on the GC not moving objects
+            return memcmp(p1, p2, initializer().length) == 0;
+    }
+
+    override int compare(in void* p1, in void* p2) @trusted pure nothrow const
+    {
+        import core.stdc.string : memcmp;
+
+        // Regard null references as always being "less than"
+        if (p1 != p2)
+        {
+            if (p1)
+            {
+                if (!p2)
+                    return true;
+                else if (xopCmp)
+                {
+                    version(GNU)
+                    {   // BUG: GDC and DMD use different calling conventions
+                        return (*xopCmp)(p1, p2);
+                    }
+                    else
+                        return (*xopCmp)(p2, p1);
+                }
+                else
+                    // BUG: relies on the GC not moving objects
+                    return memcmp(p1, p2, initializer().length);
+            }
+            else
+                return -1;
+        }
+        return 0;
+    }
+
+    override @property size_t tsize() nothrow pure const
+    {
+        return initializer().length;
+    }
+
+    override const(void)[] initializer() nothrow pure const @safe
+    {
+        return m_init;
+    }
+
+    override @property uint flags() nothrow pure const { return m_flags; }
+
+    override @property size_t talign() nothrow pure const { return m_align; }
+
+    final override void destroy(void* p) const
+    {
+        if (xdtor)
+        {
+            if (m_flags & StructFlags.isDynamicType)
+                (*xdtorti)(p, this);
+            else
+                (*xdtor)(p);
+        }
+    }
+
+    override void postblit(void* p) const
+    {
+        if (xpostblit)
+            (*xpostblit)(p);
+    }
+
+    string name;
+    void[] m_init;      // initializer; m_init.ptr == null if 0 initialize
+
+  @safe pure nothrow
+  {
+    size_t   function(in void*)           xtoHash;
+    bool     function(in void*, in void*) xopEquals;
+    int      function(in void*, in void*) xopCmp;
+    string   function(in void*)           xtoString;
+
+    enum StructFlags : uint
+    {
+        hasPointers = 0x1,
+        isDynamicType = 0x2, // built at runtime, needs type info in xdtor
+    }
+    StructFlags m_flags;
+  }
+    union
+    {
+        void function(void*)                xdtor;
+        void function(void*, const TypeInfo_Struct ti) xdtorti;
+    }
+    void function(void*)                    xpostblit;
+
+    uint m_align;
+
+    override @property immutable(void)* rtInfo() const { return m_RTInfo; }
+
+    version (X86_64)
+    {
+        override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
+        {
+            arg1 = m_arg1;
+            arg2 = m_arg2;
+            return 0;
+        }
+        TypeInfo m_arg1;
+        TypeInfo m_arg2;
+    }
+    immutable(void)* m_RTInfo;                // data for precise GC
+}
+
+unittest
+{
+    struct S
+    {
+        bool opEquals(ref const S rhs) const
+        {
+            return false;
+        }
+    }
+    S s;
+    assert(!typeid(S).equals(&s, &s));
+}
+
+class TypeInfo_Tuple : TypeInfo
+{
+    TypeInfo[] elements;
+
+    override string toString() const
+    {
+        string s = "(";
+        foreach (i, element; elements)
+        {
+            if (i)
+                s ~= ',';
+            s ~= element.toString();
+        }
+        s ~= ")";
+        return s;
+    }
+
+    override bool opEquals(Object o)
+    {
+        if (this is o)
+            return true;
+
+        auto t = cast(const TypeInfo_Tuple)o;
+        if (t && elements.length == t.elements.length)
+        {
+            for (size_t i = 0; i < elements.length; i++)
+            {
+                if (elements[i] != t.elements[i])
+                    return false;
+            }
+            return true;
+        }
+        return false;
+    }
+
+    override size_t getHash(in void* p) const
+    {
+        assert(0);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        assert(0);
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        assert(0);
+    }
+
+    override @property size_t tsize() nothrow pure const
+    {
+        assert(0);
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        assert(0);
+    }
+
+    override void swap(void* p1, void* p2) const
+    {
+        assert(0);
+    }
+
+    override void destroy(void* p) const
+    {
+        assert(0);
+    }
+
+    override void postblit(void* p) const
+    {
+        assert(0);
+    }
+
+    override @property size_t talign() nothrow pure const
+    {
+        assert(0);
+    }
+
+    version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
+    {
+        assert(0);
+    }
+}
+
+class TypeInfo_Const : TypeInfo
+{
+    override string toString() const
+    {
+        return cast(string) ("const(" ~ base.toString() ~ ")");
+    }
+
+    //override bool opEquals(Object o) { return base.opEquals(o); }
+    override bool opEquals(Object o)
+    {
+        if (this is o)
+            return true;
+
+        if (typeid(this) != typeid(o))
+            return false;
+
+        auto t = cast(TypeInfo_Const)o;
+        return base.opEquals(t.base);
+    }
+
+    override size_t getHash(in void *p) const { return base.getHash(p); }
+    override bool equals(in void *p1, in void *p2) const { return base.equals(p1, p2); }
+    override int compare(in void *p1, in void *p2) const { return base.compare(p1, p2); }
+    override @property size_t tsize() nothrow pure const { return base.tsize; }
+    override void swap(void *p1, void *p2) const { return base.swap(p1, p2); }
+
+    override @property inout(TypeInfo) next() nothrow pure inout { return base.next; }
+    override @property uint flags() nothrow pure const { return base.flags; }
+
+    override const(void)[] initializer() nothrow pure const
+    {
+        return base.initializer();
+    }
+
+    override @property size_t talign() nothrow pure const { return base.talign; }
+
+    version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
+    {
+        return base.argTypes(arg1, arg2);
+    }
+
+    TypeInfo base;
+}
+
+class TypeInfo_Invariant : TypeInfo_Const
+{
+    override string toString() const
+    {
+        return cast(string) ("immutable(" ~ base.toString() ~ ")");
+    }
+}
+
+class TypeInfo_Shared : TypeInfo_Const
+{
+    override string toString() const
+    {
+        return cast(string) ("shared(" ~ base.toString() ~ ")");
+    }
+}
+
+class TypeInfo_Inout : TypeInfo_Const
+{
+    override string toString() const
+    {
+        return cast(string) ("inout(" ~ base.toString() ~ ")");
+    }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// ModuleInfo
+///////////////////////////////////////////////////////////////////////////////
+
+
+enum
+{
+    MIctorstart  = 0x1,   // we've started constructing it
+    MIctordone   = 0x2,   // finished construction
+    MIstandalone = 0x4,   // module ctor does not depend on other module
+                        // ctors being done first
+    MItlsctor    = 8,
+    MItlsdtor    = 0x10,
+    MIctor       = 0x20,
+    MIdtor       = 0x40,
+    MIxgetMembers = 0x80,
+    MIictor      = 0x100,
+    MIunitTest   = 0x200,
+    MIimportedModules = 0x400,
+    MIlocalClasses = 0x800,
+    MIname       = 0x1000,
+}
+
+
+struct ModuleInfo
+{
+    uint _flags;
+    uint _index; // index into _moduleinfo_array[]
+
+    version (all)
+    {
+        deprecated("ModuleInfo cannot be copy-assigned because it is a variable-sized struct.")
+        void opAssign(in ModuleInfo m) { _flags = m._flags; _index = m._index; }
+    }
+    else
+    {
+        @disable this();
+        @disable this(this) const;
+    }
+
+const:
+    private void* addrOf(int flag) nothrow pure
+    in
+    {
+        assert(flag >= MItlsctor && flag <= MIname);
+        assert(!(flag & (flag - 1)) && !(flag & ~(flag - 1) << 1));
+    }
+    body
+    {
+        import core.stdc.string : strlen;
+
+        void* p = cast(void*)&this + ModuleInfo.sizeof;
+
+        if (flags & MItlsctor)
+        {
+            if (flag == MItlsctor) return p;
+            p += typeof(tlsctor).sizeof;
+        }
+        if (flags & MItlsdtor)
+        {
+            if (flag == MItlsdtor) return p;
+            p += typeof(tlsdtor).sizeof;
+        }
+        if (flags & MIctor)
+        {
+            if (flag == MIctor) return p;
+            p += typeof(ctor).sizeof;
+        }
+        if (flags & MIdtor)
+        {
+            if (flag == MIdtor) return p;
+            p += typeof(dtor).sizeof;
+        }
+        if (flags & MIxgetMembers)
+        {
+            if (flag == MIxgetMembers) return p;
+            p += typeof(xgetMembers).sizeof;
+        }
+        if (flags & MIictor)
+        {
+            if (flag == MIictor) return p;
+            p += typeof(ictor).sizeof;
+        }
+        if (flags & MIunitTest)
+        {
+            if (flag == MIunitTest) return p;
+            p += typeof(unitTest).sizeof;
+        }
+        if (flags & MIimportedModules)
+        {
+            if (flag == MIimportedModules) return p;
+            p += size_t.sizeof + *cast(size_t*)p * typeof(importedModules[0]).sizeof;
+        }
+        if (flags & MIlocalClasses)
+        {
+            if (flag == MIlocalClasses) return p;
+            p += size_t.sizeof + *cast(size_t*)p * typeof(localClasses[0]).sizeof;
+        }
+        if (true || flags & MIname) // always available for now
+        {
+            if (flag == MIname) return p;
+            p += strlen(cast(immutable char*)p);
+        }
+        assert(0);
+    }
+
+    @property uint index() nothrow pure { return _index; }
+
+    @property uint flags() nothrow pure { return _flags; }
+
+    @property void function() tlsctor() nothrow pure
+    {
+        return flags & MItlsctor ? *cast(typeof(return)*)addrOf(MItlsctor) : null;
+    }
+
+    @property void function() tlsdtor() nothrow pure
+    {
+        return flags & MItlsdtor ? *cast(typeof(return)*)addrOf(MItlsdtor) : null;
+    }
+
+    @property void* xgetMembers() nothrow pure
+    {
+        return flags & MIxgetMembers ? *cast(typeof(return)*)addrOf(MIxgetMembers) : null;
+    }
+
+    @property void function() ctor() nothrow pure
+    {
+        return flags & MIctor ? *cast(typeof(return)*)addrOf(MIctor) : null;
+    }
+
+    @property void function() dtor() nothrow pure
+    {
+        return flags & MIdtor ? *cast(typeof(return)*)addrOf(MIdtor) : null;
+    }
+
+    @property void function() ictor() nothrow pure
+    {
+        return flags & MIictor ? *cast(typeof(return)*)addrOf(MIictor) : null;
+    }
+
+    @property void function() unitTest() nothrow pure
+    {
+        return flags & MIunitTest ? *cast(typeof(return)*)addrOf(MIunitTest) : null;
+    }
+
+    @property immutable(ModuleInfo*)[] importedModules() nothrow pure
+    {
+        if (flags & MIimportedModules)
+        {
+            auto p = cast(size_t*)addrOf(MIimportedModules);
+            return (cast(immutable(ModuleInfo*)*)(p + 1))[0 .. *p];
+        }
+        return null;
+    }
+
+    @property TypeInfo_Class[] localClasses() nothrow pure
+    {
+        if (flags & MIlocalClasses)
+        {
+            auto p = cast(size_t*)addrOf(MIlocalClasses);
+            return (cast(TypeInfo_Class*)(p + 1))[0 .. *p];
+        }
+        return null;
+    }
+
+    @property string name() nothrow pure
+    {
+        if (true || flags & MIname) // always available for now
+        {
+            import core.stdc.string : strlen;
+
+            auto p = cast(immutable char*)addrOf(MIname);
+            return p[0 .. strlen(p)];
+        }
+        // return null;
+    }
+
+    static int opApply(scope int delegate(ModuleInfo*) dg)
+    {
+        import core.internal.traits : externDFunc;
+        alias moduleinfos_apply = externDFunc!("rt.minfo.moduleinfos_apply",
+                                              int function(scope int delegate(immutable(ModuleInfo*))));
+        // Bugzilla 13084 - enforcing immutable ModuleInfo would break client code
+        return moduleinfos_apply(
+            (immutable(ModuleInfo*)m) => dg(cast(ModuleInfo*)m));
+    }
+}
+
+unittest
+{
+    ModuleInfo* m1;
+    foreach (m; ModuleInfo)
+    {
+        m1 = m;
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Throwable
+///////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * The base class of all thrown objects.
+ *
+ * All thrown objects must inherit from Throwable. Class $(D Exception), which
+ * derives from this class, represents the category of thrown objects that are
+ * safe to catch and handle. In principle, one should not catch Throwable
+ * objects that are not derived from $(D Exception), as they represent
+ * unrecoverable runtime errors. Certain runtime guarantees may fail to hold
+ * when these errors are thrown, making it unsafe to continue execution after
+ * catching them.
+ */
+class Throwable : Object
+{
+    interface TraceInfo
+    {
+        int opApply(scope int delegate(ref const(char[]))) const;
+        int opApply(scope int delegate(ref size_t, ref const(char[]))) const;
+        string toString() const;
+    }
+
+    string      msg;    /// A message describing the error.
+
+    /**
+     * The _file name and line number of the D source code corresponding with
+     * where the error was thrown from.
+     */
+    string      file;
+    size_t      line;   /// ditto
+
+    /**
+     * The stack trace of where the error happened. This is an opaque object
+     * that can either be converted to $(D string), or iterated over with $(D
+     * foreach) to extract the items in the stack trace (as strings).
+     */
+    TraceInfo   info;
+
+    /**
+     * A reference to the _next error in the list. This is used when a new
+     * $(D Throwable) is thrown from inside a $(D catch) block. The originally
+     * caught $(D Exception) will be chained to the new $(D Throwable) via this
+     * field.
+     */
+    Throwable   next;
+
+    @nogc @safe pure nothrow this(string msg, Throwable next = null)
+    {
+        this.msg = msg;
+        this.next = next;
+        //this.info = _d_traceContext();
+    }
+
+    @nogc @safe pure nothrow this(string msg, string file, size_t line, Throwable next = null)
+    {
+        this(msg, next);
+        this.file = file;
+        this.line = line;
+        //this.info = _d_traceContext();
+    }
+
+    /**
+     * Overrides $(D Object.toString) and returns the error message.
+     * Internally this forwards to the $(D toString) overload that
+     * takes a $(PARAM sink) delegate.
+     */
+    override string toString()
+    {
+        string s;
+        toString((buf) { s ~= buf; });
+        return s;
+    }
+
+    /**
+     * The Throwable hierarchy uses a toString overload that takes a
+     * $(PARAM sink) delegate to avoid GC allocations, which cannot be
+     * performed in certain error situations.  Override this $(D
+     * toString) method to customize the error message.
+     */
+    void toString(scope void delegate(in char[]) sink) const
+    {
+        import core.internal.traits : externDFunc;
+        alias sizeToTempString = externDFunc!("core.internal.string.unsignedToTempString",
+                                              char[] function(ulong, char[], uint) @safe pure nothrow @nogc);
+
+        char[20] tmpBuff = void;
+
+        sink(typeid(this).name);
+        sink("@"); sink(file);
+        sink("("); sink(sizeToTempString(line, tmpBuff, 10)); sink(")");
+
+        if (msg.length)
+        {
+            sink(": "); sink(msg);
+        }
+        if (info)
+        {
+            try
+            {
+                sink("\n----------------");
+                foreach (t; info)
+                {
+                    sink("\n"); sink(t);
+                }
+            }
+            catch (Throwable)
+            {
+                // ignore more errors
+            }
+        }
+    }
+}
+
+
+/**
+ * The base class of all errors that are safe to catch and handle.
+ *
+ * In principle, only thrown objects derived from this class are safe to catch
+ * inside a $(D catch) block. Thrown objects not derived from Exception
+ * represent runtime errors that should not be caught, as certain runtime
+ * guarantees may not hold, making it unsafe to continue program execution.
+ */
+class Exception : Throwable
+{
+
+    /**
+     * Creates a new instance of Exception. The next parameter is used
+     * internally and should always be $(D null) when passed by user code.
+     * This constructor does not automatically throw the newly-created
+     * Exception; the $(D throw) statement should be used for that purpose.
+     */
+    @nogc @safe pure nothrow this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null)
+    {
+        super(msg, file, line, next);
+    }
+
+    @nogc @safe pure nothrow this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__)
+    {
+        super(msg, file, line, next);
+    }
+}
+
+unittest
+{
+    {
+        auto e = new Exception("msg");
+        assert(e.file == __FILE__);
+        assert(e.line == __LINE__ - 2);
+        assert(e.next is null);
+        assert(e.msg == "msg");
+    }
+
+    {
+        auto e = new Exception("msg", new Exception("It's an Exception!"), "hello", 42);
+        assert(e.file == "hello");
+        assert(e.line == 42);
+        assert(e.next !is null);
+        assert(e.msg == "msg");
+    }
+
+    {
+        auto e = new Exception("msg", "hello", 42, new Exception("It's an Exception!"));
+        assert(e.file == "hello");
+        assert(e.line == 42);
+        assert(e.next !is null);
+        assert(e.msg == "msg");
+    }
+}
+
+
+/**
+ * The base class of all unrecoverable runtime errors.
+ *
+ * This represents the category of $(D Throwable) objects that are $(B not)
+ * safe to catch and handle. In principle, one should not catch Error
+ * objects, as they represent unrecoverable runtime errors.
+ * Certain runtime guarantees may fail to hold when these errors are
+ * thrown, making it unsafe to continue execution after catching them.
+ */
+class Error : Throwable
+{
+    /**
+     * Creates a new instance of Error. The next parameter is used
+     * internally and should always be $(D null) when passed by user code.
+     * This constructor does not automatically throw the newly-created
+     * Error; the $(D throw) statement should be used for that purpose.
+     */
+    @nogc @safe pure nothrow this(string msg, Throwable next = null)
+    {
+        super(msg, next);
+        bypassedException = null;
+    }
+
+    @nogc @safe pure nothrow this(string msg, string file, size_t line, Throwable next = null)
+    {
+        super(msg, file, line, next);
+        bypassedException = null;
+    }
+
+    /// The first $(D Exception) which was bypassed when this Error was thrown,
+    /// or $(D null) if no $(D Exception)s were pending.
+    Throwable   bypassedException;
+}
+
+unittest
+{
+    {
+        auto e = new Error("msg");
+        assert(e.file is null);
+        assert(e.line == 0);
+        assert(e.next is null);
+        assert(e.msg == "msg");
+        assert(e.bypassedException is null);
+    }
+
+    {
+        auto e = new Error("msg", new Exception("It's an Exception!"));
+        assert(e.file is null);
+        assert(e.line == 0);
+        assert(e.next !is null);
+        assert(e.msg == "msg");
+        assert(e.bypassedException is null);
+    }
+
+    {
+        auto e = new Error("msg", "hello", 42, new Exception("It's an Exception!"));
+        assert(e.file == "hello");
+        assert(e.line == 42);
+        assert(e.next !is null);
+        assert(e.msg == "msg");
+        assert(e.bypassedException is null);
+    }
+}
+
+/* Used in Exception Handling LSDA tables to 'wrap' C++ type info
+ * so it can be distinguished from D TypeInfo
+ */
+class __cpp_type_info_ptr
+{
+    void* ptr;          // opaque pointer to C++ RTTI type info
+}
+
+extern (C)
+{
+    // from druntime/src/rt/aaA.d
+
+    // size_t _aaLen(in void* p) pure nothrow @nogc;
+    private void* _aaGetY(void** paa, const TypeInfo_AssociativeArray ti, in size_t valuesize, in void* pkey) pure nothrow;
+    // inout(void)* _aaGetRvalueX(inout void* p, in TypeInfo keyti, in size_t valuesize, in void* pkey);
+    inout(void)[] _aaValues(inout void* p, in size_t keysize, in size_t valuesize, const TypeInfo tiValArray) pure nothrow;
+    inout(void)[] _aaKeys(inout void* p, in size_t keysize, const TypeInfo tiKeyArray) pure nothrow;
+    void* _aaRehash(void** pp, in TypeInfo keyti) pure nothrow;
+    void _aaClear(void* p) pure nothrow;
+
+    // alias _dg_t = extern(D) int delegate(void*);
+    // int _aaApply(void* aa, size_t keysize, _dg_t dg);
+
+    // alias _dg2_t = extern(D) int delegate(void*, void*);
+    // int _aaApply2(void* aa, size_t keysize, _dg2_t dg);
+
+    private struct AARange { void* impl; size_t idx; }
+    AARange _aaRange(void* aa) pure nothrow @nogc;
+    bool _aaRangeEmpty(AARange r) pure nothrow @nogc;
+    void* _aaRangeFrontKey(AARange r) pure nothrow @nogc;
+    void* _aaRangeFrontValue(AARange r) pure nothrow @nogc;
+    void _aaRangePopFront(ref AARange r) pure nothrow @nogc;
+
+    int _aaEqual(in TypeInfo tiRaw, in void* e1, in void* e2);
+    hash_t _aaGetHash(in void* aa, in TypeInfo tiRaw) nothrow;
+
+    /*
+        _d_assocarrayliteralTX marked as pure, because aaLiteral can be called from pure code.
+        This is a typesystem hole, however this is existing hole.
+        Early compiler didn't check purity of toHash or postblit functions, if key is a UDT thus
+        copiler allowed to create AA literal with keys, which have impure unsafe toHash methods.
+    */
+    void* _d_assocarrayliteralTX(const TypeInfo_AssociativeArray ti, void[] keys, void[] values) pure;
+}
+
+void* aaLiteral(Key, Value)(Key[] keys, Value[] values) @trusted pure
+{
+    return _d_assocarrayliteralTX(typeid(Value[Key]), *cast(void[]*)&keys, *cast(void[]*)&values);
+}
+
+alias AssociativeArray(Key, Value) = Value[Key];
+
+void clear(T : Value[Key], Value, Key)(T aa)
+{
+    _aaClear(*cast(void **) &aa);
+}
+
+void clear(T : Value[Key], Value, Key)(T* aa)
+{
+    _aaClear(*cast(void **) aa);
+}
+
+T rehash(T : Value[Key], Value, Key)(T aa)
+{
+    _aaRehash(cast(void**)&aa, typeid(Value[Key]));
+    return aa;
+}
+
+T rehash(T : Value[Key], Value, Key)(T* aa)
+{
+    _aaRehash(cast(void**)aa, typeid(Value[Key]));
+    return *aa;
+}
+
+T rehash(T : shared Value[Key], Value, Key)(T aa)
+{
+    _aaRehash(cast(void**)&aa, typeid(Value[Key]));
+    return aa;
+}
+
+T rehash(T : shared Value[Key], Value, Key)(T* aa)
+{
+    _aaRehash(cast(void**)aa, typeid(Value[Key]));
+    return *aa;
+}
+
+V[K] dup(T : V[K], K, V)(T aa)
+{
+    //pragma(msg, "K = ", K, ", V = ", V);
+
+    // Bug10720 - check whether V is copyable
+    static assert(is(typeof({ V v = aa[K.init]; })),
+        "cannot call " ~ T.stringof ~ ".dup because " ~ V.stringof ~ " is not copyable");
+
+    V[K] result;
+
+    //foreach (k, ref v; aa)
+    //    result[k] = v;  // Bug13701 - won't work if V is not mutable
+
+    ref V duplicateElem(ref K k, ref const V v) @trusted pure nothrow
+    {
+        import core.stdc.string : memcpy;
+
+        void* pv = _aaGetY(cast(void**)&result, typeid(V[K]), V.sizeof, &k);
+        memcpy(pv, &v, V.sizeof);
+        return *cast(V*)pv;
+    }
+
+    if (auto postblit = _getPostblit!V())
+    {
+        foreach (k, ref v; aa)
+            postblit(duplicateElem(k, v));
+    }
+    else
+    {
+        foreach (k, ref v; aa)
+            duplicateElem(k, v);
+    }
+
+    return result;
+}
+
+V[K] dup(T : V[K], K, V)(T* aa)
+{
+    return (*aa).dup;
+}
+
+auto byKey(T : V[K], K, V)(T aa) pure nothrow @nogc
+{
+    import core.internal.traits : substInout;
+
+    static struct Result
+    {
+        AARange r;
+
+    pure nothrow @nogc:
+        @property bool empty() { return _aaRangeEmpty(r); }
+        @property ref front() { return *cast(substInout!K*)_aaRangeFrontKey(r); }
+        void popFront() { _aaRangePopFront(r); }
+        @property Result save() { return this; }
+    }
+
+    return Result(_aaRange(cast(void*)aa));
+}
+
+auto byKey(T : V[K], K, V)(T* aa) pure nothrow @nogc
+{
+    return (*aa).byKey();
+}
+
+auto byValue(T : V[K], K, V)(T aa) pure nothrow @nogc
+{
+    import core.internal.traits : substInout;
+
+    static struct Result
+    {
+        AARange r;
+
+    pure nothrow @nogc:
+        @property bool empty() { return _aaRangeEmpty(r); }
+        @property ref front() { return *cast(substInout!V*)_aaRangeFrontValue(r); }
+        void popFront() { _aaRangePopFront(r); }
+        @property Result save() { return this; }
+    }
+
+    return Result(_aaRange(cast(void*)aa));
+}
+
+auto byValue(T : V[K], K, V)(T* aa) pure nothrow @nogc
+{
+    return (*aa).byValue();
+}
+
+auto byKeyValue(T : V[K], K, V)(T aa) pure nothrow @nogc
+{
+    import core.internal.traits : substInout;
+
+    static struct Result
+    {
+        AARange r;
+
+    pure nothrow @nogc:
+        @property bool empty() { return _aaRangeEmpty(r); }
+        @property auto front() @trusted
+        {
+            static struct Pair
+            {
+                // We save the pointers here so that the Pair we return
+                // won't mutate when Result.popFront is called afterwards.
+                private void* keyp;
+                private void* valp;
+
+                @property ref key() inout { return *cast(substInout!K*)keyp; }
+                @property ref value() inout { return *cast(substInout!V*)valp; }
+            }
+            return Pair(_aaRangeFrontKey(r),
+                        _aaRangeFrontValue(r));
+        }
+        void popFront() { _aaRangePopFront(r); }
+        @property Result save() { return this; }
+    }
+
+    return Result(_aaRange(cast(void*)aa));
+}
+
+auto byKeyValue(T : V[K], K, V)(T* aa) pure nothrow @nogc
+{
+    return (*aa).byKeyValue();
+}
+
+Key[] keys(T : Value[Key], Value, Key)(T aa) @property
+{
+    auto a = cast(void[])_aaKeys(cast(inout(void)*)aa, Key.sizeof, typeid(Key[]));
+    auto res = *cast(Key[]*)&a;
+    _doPostblit(res);
+    return res;
+}
+
+Key[] keys(T : Value[Key], Value, Key)(T *aa) @property
+{
+    return (*aa).keys;
+}
+
+Value[] values(T : Value[Key], Value, Key)(T aa) @property
+{
+    auto a = cast(void[])_aaValues(cast(inout(void)*)aa, Key.sizeof, Value.sizeof, typeid(Value[]));
+    auto res = *cast(Value[]*)&a;
+    _doPostblit(res);
+    return res;
+}
+
+Value[] values(T : Value[Key], Value, Key)(T *aa) @property
+{
+    return (*aa).values;
+}
+
+unittest
+{
+    static struct T
+    {
+        static size_t count;
+        this(this) { ++count; }
+    }
+    T[int] aa;
+    T t;
+    aa[0] = t;
+    aa[1] = t;
+    assert(T.count == 2);
+    auto vals = aa.values;
+    assert(vals.length == 2);
+    assert(T.count == 4);
+
+    T.count = 0;
+    int[T] aa2;
+    aa2[t] = 0;
+    assert(T.count == 1);
+    aa2[t] = 1;
+    assert(T.count == 1);
+    auto keys = aa2.keys;
+    assert(keys.length == 1);
+    assert(T.count == 2);
+}
+
+inout(V) get(K, V)(inout(V[K]) aa, K key, lazy inout(V) defaultValue)
+{
+    auto p = key in aa;
+    return p ? *p : defaultValue;
+}
+
+inout(V) get(K, V)(inout(V[K])* aa, K key, lazy inout(V) defaultValue)
+{
+    return (*aa).get(key, defaultValue);
+}
+
+pure nothrow unittest
+{
+    int[int] a;
+    foreach (i; a.byKey)
+    {
+        assert(false);
+    }
+    foreach (i; a.byValue)
+    {
+        assert(false);
+    }
+}
+
+pure /*nothrow @@@BUG5555@@@*/ unittest
+{
+    auto a = [ 1:"one", 2:"two", 3:"three" ];
+    auto b = a.dup;
+    assert(b == [ 1:"one", 2:"two", 3:"three" ]);
+
+    int[] c;
+    foreach (k; a.byKey)
+    {
+        c ~= k;
+    }
+
+    assert(c.length == 3);
+    assert(c[0] == 1 || c[1] == 1 || c[2] == 1);
+    assert(c[0] == 2 || c[1] == 2 || c[2] == 2);
+    assert(c[0] == 3 || c[1] == 3 || c[2] == 3);
+}
+
+pure nothrow unittest
+{
+    // test for bug 5925
+    const a = [4:0];
+    const b = [4:0];
+    assert(a == b);
+}
+
+pure nothrow unittest
+{
+    // test for bug 9052
+    static struct Json {
+        Json[string] aa;
+        void opAssign(Json) {}
+        size_t length() const { return aa.length; }
+        // This length() instantiates AssociativeArray!(string, const(Json)) to call AA.length(), and
+        // inside ref Slot opAssign(Slot p); (which is automatically generated by compiler in Slot),
+        // this.value = p.value would actually fail, because both side types of the assignment
+        // are const(Json).
+    }
+}
+
+pure nothrow unittest
+{
+    // test for bug 8583: ensure Slot and aaA are on the same page wrt value alignment
+    string[byte]    aa0 = [0: "zero"];
+    string[uint[3]] aa1 = [[1,2,3]: "onetwothree"];
+    ushort[uint[3]] aa2 = [[9,8,7]: 987];
+    ushort[uint[4]] aa3 = [[1,2,3,4]: 1234];
+    string[uint[5]] aa4 = [[1,2,3,4,5]: "onetwothreefourfive"];
+
+    assert(aa0.byValue.front == "zero");
+    assert(aa1.byValue.front == "onetwothree");
+    assert(aa2.byValue.front == 987);
+    assert(aa3.byValue.front == 1234);
+    assert(aa4.byValue.front == "onetwothreefourfive");
+}
+
+pure nothrow unittest
+{
+    // test for bug 10720
+    static struct NC
+    {
+        @disable this(this) { }
+    }
+
+    NC[string] aa;
+    static assert(!is(aa.nonExistingField));
+}
+
+pure nothrow unittest
+{
+    // bug 5842
+    string[string] test = null;
+    test["test1"] = "test1";
+    test.remove("test1");
+    test.rehash;
+    test["test3"] = "test3"; // causes divide by zero if rehash broke the AA
+}
+
+pure nothrow unittest
+{
+    string[] keys = ["a", "b", "c", "d", "e", "f"];
+
+    // Test forward range capabilities of byKey
+    {
+        int[string] aa;
+        foreach (key; keys)
+            aa[key] = 0;
+
+        auto keyRange = aa.byKey();
+        auto savedKeyRange = keyRange.save;
+
+        // Consume key range once
+        size_t keyCount = 0;
+        while (!keyRange.empty)
+        {
+            aa[keyRange.front]++;
+            keyCount++;
+            keyRange.popFront();
+        }
+
+        foreach (key; keys)
+        {
+            assert(aa[key] == 1);
+        }
+        assert(keyCount == keys.length);
+
+        // Verify it's possible to iterate the range the second time
+        keyCount = 0;
+        while (!savedKeyRange.empty)
+        {
+            aa[savedKeyRange.front]++;
+            keyCount++;
+            savedKeyRange.popFront();
+        }
+
+        foreach (key; keys)
+        {
+            assert(aa[key] == 2);
+        }
+        assert(keyCount == keys.length);
+    }
+
+    // Test forward range capabilities of byValue
+    {
+        size_t[string] aa;
+        foreach (i; 0 .. keys.length)
+        {
+            aa[keys[i]] = i;
+        }
+
+        auto valRange = aa.byValue();
+        auto savedValRange = valRange.save;
+
+        // Consume value range once
+        int[] hasSeen;
+        hasSeen.length = keys.length;
+        while (!valRange.empty)
+        {
+            assert(hasSeen[valRange.front] == 0);
+            hasSeen[valRange.front]++;
+            valRange.popFront();
+        }
+
+        foreach (sawValue; hasSeen) { assert(sawValue == 1); }
+
+        // Verify it's possible to iterate the range the second time
+        hasSeen = null;
+        hasSeen.length = keys.length;
+        while (!savedValRange.empty)
+        {
+            assert(!hasSeen[savedValRange.front]);
+            hasSeen[savedValRange.front] = true;
+            savedValRange.popFront();
+        }
+
+        foreach (sawValue; hasSeen) { assert(sawValue); }
+    }
+}
+
+pure nothrow unittest
+{
+    // expanded test for 5842: increase AA size past the point where the AA
+    // stops using binit, in order to test another code path in rehash.
+    int[int] aa;
+    foreach (int i; 0 .. 32)
+        aa[i] = i;
+    foreach (int i; 0 .. 32)
+        aa.remove(i);
+    aa.rehash;
+    aa[1] = 1;
+}
+
+pure nothrow unittest
+{
+    // bug 13078
+    shared string[][string] map;
+    map.rehash;
+}
+
+pure nothrow unittest
+{
+    // bug 11761: test forward range functionality
+    auto aa = ["a": 1];
+
+    void testFwdRange(R, T)(R fwdRange, T testValue)
+    {
+        assert(!fwdRange.empty);
+        assert(fwdRange.front == testValue);
+        static assert(is(typeof(fwdRange.save) == typeof(fwdRange)));
+
+        auto saved = fwdRange.save;
+        fwdRange.popFront();
+        assert(fwdRange.empty);
+
+        assert(!saved.empty);
+        assert(saved.front == testValue);
+        saved.popFront();
+        assert(saved.empty);
+    }
+
+    testFwdRange(aa.byKey, "a");
+    testFwdRange(aa.byValue, 1);
+    //testFwdRange(aa.byPair, tuple("a", 1));
+}
+
+unittest
+{
+    // Issue 9119
+    int[string] aa;
+    assert(aa.byKeyValue.empty);
+
+    aa["a"] = 1;
+    aa["b"] = 2;
+    aa["c"] = 3;
+
+    auto pairs = aa.byKeyValue;
+
+    auto savedPairs = pairs.save;
+    size_t count = 0;
+    while (!pairs.empty)
+    {
+        assert(pairs.front.key in aa);
+        assert(pairs.front.value == aa[pairs.front.key]);
+        count++;
+        pairs.popFront();
+    }
+    assert(count == aa.length);
+
+    // Verify that saved range can iterate over the AA again
+    count = 0;
+    while (!savedPairs.empty)
+    {
+        assert(savedPairs.front.key in aa);
+        assert(savedPairs.front.value == aa[savedPairs.front.key]);
+        count++;
+        savedPairs.popFront();
+    }
+    assert(count == aa.length);
+}
+
+unittest
+{
+    // Verify iteration with const.
+    auto aa = [1:2, 3:4];
+    foreach (const t; aa.byKeyValue)
+    {
+        auto k = t.key;
+        auto v = t.value;
+    }
+}
+
+unittest
+{
+    // test for bug 14626
+    static struct S
+    {
+        string[string] aa;
+        inout(string) key() inout { return aa.byKey().front; }
+        inout(string) val() inout { return aa.byValue().front; }
+        auto keyval() inout { return aa.byKeyValue().front; }
+    }
+
+    S s = S(["a":"b"]);
+    assert(s.key() == "a");
+    assert(s.val() == "b");
+    assert(s.keyval().key == "a");
+    assert(s.keyval().value == "b");
+
+    void testInoutKeyVal(inout(string) key)
+    {
+        inout(string)[typeof(key)] aa;
+
+        foreach (i; aa.byKey()) {}
+        foreach (i; aa.byValue()) {}
+        foreach (i; aa.byKeyValue()) {}
+    }
+
+    const int[int] caa;
+    static assert(is(typeof(caa.byValue().front) == const int));
+}
+
+private void _destructRecurse(S)(ref S s)
+    if (is(S == struct))
+{
+    static if (__traits(hasMember, S, "__xdtor") &&
+               // Bugzilla 14746: Check that it's the exact member of S.
+               __traits(isSame, S, __traits(parent, s.__xdtor)))
+        s.__xdtor();
+}
+
+private void _destructRecurse(E, size_t n)(ref E[n] arr)
+{
+    import core.internal.traits : hasElaborateDestructor;
+
+    static if (hasElaborateDestructor!E)
+    {
+        foreach_reverse (ref elem; arr)
+            _destructRecurse(elem);
+    }
+}
+
+// Public and explicitly undocumented
+void _postblitRecurse(S)(ref S s)
+    if (is(S == struct))
+{
+    static if (__traits(hasMember, S, "__xpostblit") &&
+               // Bugzilla 14746: Check that it's the exact member of S.
+               __traits(isSame, S, __traits(parent, s.__xpostblit)))
+        s.__xpostblit();
+}
+
+// Ditto
+void _postblitRecurse(E, size_t n)(ref E[n] arr)
+{
+    import core.internal.traits : hasElaborateCopyConstructor;
+
+    static if (hasElaborateCopyConstructor!E)
+    {
+        size_t i;
+        scope(failure)
+        {
+            for (; i != 0; --i)
+            {
+                _destructRecurse(arr[i - 1]); // What to do if this throws?
+            }
+        }
+
+        for (i = 0; i < arr.length; ++i)
+            _postblitRecurse(arr[i]);
+    }
+}
+
+// Test destruction/postblit order
+@safe nothrow pure unittest
+{
+    string[] order;
+
+    struct InnerTop
+    {
+        ~this() @safe nothrow pure
+        {
+            order ~= "destroy inner top";
+        }
+
+        this(this) @safe nothrow pure
+        {
+            order ~= "copy inner top";
+        }
+    }
+
+    struct InnerMiddle {}
+
+    version(none) // @@@BUG@@@ 14242
+    struct InnerElement
+    {
+        static char counter = '1';
+
+        ~this() @safe nothrow pure
+        {
+            order ~= "destroy inner element #" ~ counter++;
+        }
+
+        this(this) @safe nothrow pure
+        {
+            order ~= "copy inner element #" ~ counter++;
+        }
+    }
+
+    struct InnerBottom
+    {
+        ~this() @safe nothrow pure
+        {
+            order ~= "destroy inner bottom";
+        }
+
+        this(this) @safe nothrow pure
+        {
+            order ~= "copy inner bottom";
+        }
+    }
+
+    struct S
+    {
+        char[] s;
+        InnerTop top;
+        InnerMiddle middle;
+        version(none) InnerElement[3] array; // @@@BUG@@@ 14242
+        int a;
+        InnerBottom bottom;
+        ~this() @safe nothrow pure { order ~= "destroy outer"; }
+        this(this) @safe nothrow pure { order ~= "copy outer"; }
+    }
+
+    string[] destructRecurseOrder;
+    {
+        S s;
+        _destructRecurse(s);
+        destructRecurseOrder = order;
+        order = null;
+    }
+
+    assert(order.length);
+    assert(destructRecurseOrder == order);
+    order = null;
+
+    S s;
+    _postblitRecurse(s);
+    assert(order.length);
+    auto postblitRecurseOrder = order;
+    order = null;
+    S s2 = s;
+    assert(order.length);
+    assert(postblitRecurseOrder == order);
+}
+
+// Test static struct
+nothrow @safe @nogc unittest
+{
+    static int i = 0;
+    static struct S { ~this() nothrow @safe @nogc { i = 42; } }
+    S s;
+    _destructRecurse(s);
+    assert(i == 42);
+}
+
+unittest
+{
+    // Bugzilla 14746
+    static struct HasDtor
+    {
+        ~this() { assert(0); }
+    }
+    static struct Owner
+    {
+        HasDtor* ptr;
+        alias ptr this;
+    }
+
+    Owner o;
+    assert(o.ptr is null);
+    destroy(o);     // must not reach in HasDtor.__dtor()
+}
+
+unittest
+{
+    // Bugzilla 14746
+    static struct HasPostblit
+    {
+        this(this) { assert(0); }
+    }
+    static struct Owner
+    {
+        HasPostblit* ptr;
+        alias ptr this;
+    }
+
+    Owner o;
+    assert(o.ptr is null);
+    _postblitRecurse(o);     // must not reach in HasPostblit.__postblit()
+}
+
+// Test handling of fixed-length arrays
+// Separate from first test because of @@@BUG@@@ 14242
+unittest
+{
+    string[] order;
+
+    struct S
+    {
+        char id;
+
+        this(this)
+        {
+            order ~= "copy #" ~ id;
+        }
+
+        ~this()
+        {
+            order ~= "destroy #" ~ id;
+        }
+    }
+
+    string[] destructRecurseOrder;
+    {
+        S[3] arr = [S('1'), S('2'), S('3')];
+        _destructRecurse(arr);
+        destructRecurseOrder = order;
+        order = null;
+    }
+    assert(order.length);
+    assert(destructRecurseOrder == order);
+    order = null;
+
+    S[3] arr = [S('1'), S('2'), S('3')];
+    _postblitRecurse(arr);
+    assert(order.length);
+    auto postblitRecurseOrder = order;
+    order = null;
+
+    auto arrCopy = arr;
+    assert(order.length);
+    assert(postblitRecurseOrder == order);
+}
+
+// Test handling of failed postblit
+// Not nothrow or @safe because of @@@BUG@@@ 14242
+/+ nothrow @safe +/ unittest
+{
+    static class FailedPostblitException : Exception { this() nothrow @safe { super(null); } }
+    static string[] order;
+    static struct Inner
+    {
+        char id;
+
+        @safe:
+        this(this)
+        {
+            order ~= "copy inner #" ~ id;
+            if(id == '2')
+                throw new FailedPostblitException();
+        }
+
+        ~this() nothrow
+        {
+            order ~= "destroy inner #" ~ id;
+        }
+    }
+
+    static struct Outer
+    {
+        Inner inner1, inner2, inner3;
+
+        nothrow @safe:
+        this(char first, char second, char third)
+        {
+            inner1 = Inner(first);
+            inner2 = Inner(second);
+            inner3 = Inner(third);
+        }
+
+        this(this)
+        {
+            order ~= "copy outer";
+        }
+
+        ~this()
+        {
+            order ~= "destroy outer";
+        }
+    }
+
+    auto outer = Outer('1', '2', '3');
+
+    try _postblitRecurse(outer);
+    catch(FailedPostblitException) {}
+    catch(Exception) assert(false);
+
+    auto postblitRecurseOrder = order;
+    order = null;
+
+    try auto copy = outer;
+    catch(FailedPostblitException) {}
+    catch(Exception) assert(false);
+
+    assert(postblitRecurseOrder == order);
+    order = null;
+
+    Outer[3] arr = [Outer('1', '1', '1'), Outer('1', '2', '3'), Outer('3', '3', '3')];
+
+    try _postblitRecurse(arr);
+    catch(FailedPostblitException) {}
+    catch(Exception) assert(false);
+
+    postblitRecurseOrder = order;
+    order = null;
+
+    try auto arrCopy = arr;
+    catch(FailedPostblitException) {}
+    catch(Exception) assert(false);
+
+    assert(postblitRecurseOrder == order);
+}
+
+/++
+    Destroys the given object and puts it in an invalid state. It's used to
+    destroy an object so that any cleanup which its destructor or finalizer
+    does is done and so that it no longer references any other objects. It does
+    $(I not) initiate a GC cycle or free any GC memory.
+  +/
+void destroy(T)(T obj) if (is(T == class))
+{
+    rt_finalize(cast(void*)obj);
+}
+
+void destroy(T)(T obj) if (is(T == interface))
+{
+    destroy(cast(Object)obj);
+}
+
+version(unittest) unittest
+{
+   interface I { }
+   {
+       class A: I { string s = "A"; this() {} }
+       auto a = new A, b = new A;
+       a.s = b.s = "asd";
+       destroy(a);
+       assert(a.s == "A");
+
+       I i = b;
+       destroy(i);
+       assert(b.s == "A");
+   }
+   {
+       static bool destroyed = false;
+       class B: I
+       {
+           string s = "B";
+           this() {}
+           ~this()
+           {
+               destroyed = true;
+           }
+       }
+       auto a = new B, b = new B;
+       a.s = b.s = "asd";
+       destroy(a);
+       assert(destroyed);
+       assert(a.s == "B");
+
+       destroyed = false;
+       I i = b;
+       destroy(i);
+       assert(destroyed);
+       assert(b.s == "B");
+   }
+   // this test is invalid now that the default ctor is not run after clearing
+   version(none)
+   {
+       class C
+       {
+           string s;
+           this()
+           {
+               s = "C";
+           }
+       }
+       auto a = new C;
+       a.s = "asd";
+       destroy(a);
+       assert(a.s == "C");
+   }
+}
+
+void destroy(T)(ref T obj) if (is(T == struct))
+{
+    _destructRecurse(obj);
+    () @trusted {
+        auto buf = (cast(ubyte*) &obj)[0 .. T.sizeof];
+        auto init = cast(ubyte[])typeid(T).initializer();
+        if (init.ptr is null) // null ptr means initialize to 0s
+            buf[] = 0;
+        else
+            buf[] = init[];
+    } ();
+}
+
+version(unittest) nothrow @safe @nogc unittest
+{
+   {
+       struct A { string s = "A";  }
+       A a;
+       a.s = "asd";
+       destroy(a);
+       assert(a.s == "A");
+   }
+   {
+       static int destroyed = 0;
+       struct C
+       {
+           string s = "C";
+           ~this() nothrow @safe @nogc
+           {
+               destroyed ++;
+           }
+       }
+
+       struct B
+       {
+           C c;
+           string s = "B";
+           ~this() nothrow @safe @nogc
+           {
+               destroyed ++;
+           }
+       }
+       B a;
+       a.s = "asd";
+       a.c.s = "jkl";
+       destroy(a);
+       assert(destroyed == 2);
+       assert(a.s == "B");
+       assert(a.c.s == "C" );
+   }
+}
+
+void destroy(T : U[n], U, size_t n)(ref T obj) if (!is(T == struct))
+{
+    foreach_reverse (ref e; obj[])
+        destroy(e);
+}
+
+version(unittest) unittest
+{
+    int[2] a;
+    a[0] = 1;
+    a[1] = 2;
+    destroy(a);
+    assert(a == [ 0, 0 ]);
+}
+
+unittest
+{
+    static struct vec2f {
+        float[2] values;
+        alias values this;
+    }
+
+    vec2f v;
+    destroy!vec2f(v);
+}
+
+unittest
+{
+    // Bugzilla 15009
+    static string op;
+    static struct S
+    {
+        int x;
+        this(int x) { op ~= "C" ~ cast(char)('0'+x); this.x = x; }
+        this(this)  { op ~= "P" ~ cast(char)('0'+x); }
+        ~this()     { op ~= "D" ~ cast(char)('0'+x); }
+    }
+
+    {
+        S[2] a1 = [S(1), S(2)];
+        op = "";
+    }
+    assert(op == "D2D1");   // built-in scope destruction
+    {
+        S[2] a1 = [S(1), S(2)];
+        op = "";
+        destroy(a1);
+        assert(op == "D2D1");   // consistent with built-in behavior
+    }
+
+    {
+        S[2][2] a2 = [[S(1), S(2)], [S(3), S(4)]];
+        op = "";
+    }
+    assert(op == "D4D3D2D1");
+    {
+        S[2][2] a2 = [[S(1), S(2)], [S(3), S(4)]];
+        op = "";
+        destroy(a2);
+        assert(op == "D4D3D2D1", op);
+    }
+}
+
+void destroy(T)(ref T obj)
+    if (!is(T == struct) && !is(T == interface) && !is(T == class) && !_isStaticArray!T)
+{
+    obj = T.init;
+}
+
+template _isStaticArray(T : U[N], U, size_t N)
+{
+    enum bool _isStaticArray = true;
+}
+
+template _isStaticArray(T)
+{
+    enum bool _isStaticArray = false;
+}
+
+version(unittest) unittest
+{
+   {
+       int a = 42;
+       destroy(a);
+       assert(a == 0);
+   }
+   {
+       float a = 42;
+       destroy(a);
+       assert(isnan(a));
+   }
+}
+
+version (unittest)
+{
+    bool isnan(float x)
+    {
+        return x != x;
+    }
+}
+
+private
+{
+    extern (C) void _d_arrayshrinkfit(const TypeInfo ti, void[] arr) nothrow;
+    extern (C) size_t _d_arraysetcapacity(const TypeInfo ti, size_t newcapacity, void *arrptr) pure nothrow;
+}
+
+/**
+ * (Property) Get the current capacity of a slice. The capacity is the size
+ * that the slice can grow to before the underlying array must be
+ * reallocated or extended.
+ *
+ * If an append must reallocate a slice with no possibility of extension, then
+ * 0 is returned. This happens when the slice references a static array, or
+ * if another slice references elements past the end of the current slice.
+ *
+ * Note: The capacity of a slice may be impacted by operations on other slices.
+ */
+@property size_t capacity(T)(T[] arr) pure nothrow
+{
+    return _d_arraysetcapacity(typeid(T[]), 0, cast(void *)&arr);
+}
+///
+unittest
+{
+    //Static array slice: no capacity
+    int[4] sarray = [1, 2, 3, 4];
+    int[]  slice  = sarray[];
+    assert(sarray.capacity == 0);
+    //Appending to slice will reallocate to a new array
+    slice ~= 5;
+    assert(slice.capacity >= 5);
+
+    //Dynamic array slices
+    int[] a = [1, 2, 3, 4];
+    int[] b = a[1 .. $];
+    int[] c = a[1 .. $ - 1];
+    debug(SENTINEL) {} else // non-zero capacity very much depends on the array and GC implementation
+    {
+        assert(a.capacity != 0);
+        assert(a.capacity == b.capacity + 1); //both a and b share the same tail
+    }
+    assert(c.capacity == 0);              //an append to c must relocate c.
+}
+
+/**
+ * Reserves capacity for a slice. The capacity is the size
+ * that the slice can grow to before the underlying array must be
+ * reallocated or extended.
+ *
+ * The return value is the new capacity of the array (which may be larger than
+ * the requested capacity).
+ */
+size_t reserve(T)(ref T[] arr, size_t newcapacity) pure nothrow @trusted
+{
+    return _d_arraysetcapacity(typeid(T[]), newcapacity, cast(void *)&arr);
+}
+///
+unittest
+{
+    //Static array slice: no capacity. Reserve relocates.
+    int[4] sarray = [1, 2, 3, 4];
+    int[]  slice  = sarray[];
+    auto u = slice.reserve(8);
+    assert(u >= 8);
+    assert(sarray.ptr !is slice.ptr);
+    assert(slice.capacity == u);
+
+    //Dynamic array slices
+    int[] a = [1, 2, 3, 4];
+    a.reserve(8); //prepare a for appending 4 more items
+    auto p = a.ptr;
+    u = a.capacity;
+    a ~= [5, 6, 7, 8];
+    assert(p == a.ptr);      //a should not have been reallocated
+    assert(u == a.capacity); //a should not have been extended
+}
+
+// Issue 6646: should be possible to use array.reserve from SafeD.
+@safe unittest
+{
+    int[] a;
+    a.reserve(10);
+}
+
+/**
+ * Assume that it is safe to append to this array. Appends made to this array
+ * after calling this function may append in place, even if the array was a
+ * slice of a larger array to begin with.
+ *
+ * Use this only when it is certain there are no elements in use beyond the
+ * array in the memory block.  If there are, those elements will be
+ * overwritten by appending to this array.
+ *
+ * Calling this function, and then using references to data located after the
+ * given array results in undefined behavior.
+ *
+ * Returns:
+ *   The input is returned.
+ */
+auto ref inout(T[]) assumeSafeAppend(T)(auto ref inout(T[]) arr) nothrow
+{
+    _d_arrayshrinkfit(typeid(T[]), *(cast(void[]*)&arr));
+    return arr;
+}
+///
+unittest
+{
+    int[] a = [1, 2, 3, 4];
+
+    // Without assumeSafeAppend. Appending relocates.
+    int[] b = a [0 .. 3];
+    b ~= 5;
+    assert(a.ptr != b.ptr);
+
+    debug(SENTINEL) {} else
+    {
+        // With assumeSafeAppend. Appending overwrites.
+        int[] c = a [0 .. 3];
+        c.assumeSafeAppend() ~= 5;
+        assert(a.ptr == c.ptr);
+    }
+}
+
+unittest
+{
+    int[] arr;
+    auto newcap = arr.reserve(2000);
+    assert(newcap >= 2000);
+    assert(newcap == arr.capacity);
+    auto ptr = arr.ptr;
+    foreach(i; 0..2000)
+        arr ~= i;
+    assert(ptr == arr.ptr);
+    arr = arr[0..1];
+    arr.assumeSafeAppend();
+    arr ~= 5;
+    assert(ptr == arr.ptr);
+}
+
+unittest
+{
+    int[] arr = [1, 2, 3];
+    void foo(ref int[] i)
+    {
+        i ~= 5;
+    }
+    arr = arr[0 .. 2];
+    foo(assumeSafeAppend(arr)); //pass by ref
+    assert(arr[]==[1, 2, 5]);
+    arr = arr[0 .. 1].assumeSafeAppend(); //pass by value
+}
+
+//@@@10574@@@
+unittest
+{
+    int[] a;
+    immutable(int[]) b;
+    auto a2 = &assumeSafeAppend(a);
+    auto b2 = &assumeSafeAppend(b);
+    auto a3 = assumeSafeAppend(a[]);
+    auto b3 = assumeSafeAppend(b[]);
+    assert(is(typeof(*a2) == int[]));
+    assert(is(typeof(*b2) == immutable(int[])));
+    assert(is(typeof(a3) == int[]));
+    assert(is(typeof(b3) == immutable(int[])));
+}
+
+version (none)
+{
+    // enforce() copied from Phobos std.contracts for destroy(), left out until
+    // we decide whether to use it.
+
+
+    T _enforce(T, string file = __FILE__, int line = __LINE__)
+        (T value, lazy const(char)[] msg = null)
+    {
+        if (!value) bailOut(file, line, msg);
+        return value;
+    }
+
+    T _enforce(T, string file = __FILE__, int line = __LINE__)
+        (T value, scope void delegate() dg)
+    {
+        if (!value) dg();
+        return value;
+    }
+
+    T _enforce(T)(T value, lazy Exception ex)
+    {
+        if (!value) throw ex();
+        return value;
+    }
+
+    private void _bailOut(string file, int line, in char[] msg)
+    {
+        char[21] buf;
+        throw new Exception(cast(string)(file ~ "(" ~ ulongToString(buf[], line) ~ "): " ~ (msg ? msg : "Enforcement failed")));
+    }
+}
+
+
+/***************************************
+ * Helper function used to see if two containers of different
+ * types have the same contents in the same sequence.
+ */
+
+bool _ArrayEq(T1, T2)(T1[] a1, T2[] a2)
+{
+    if (a1.length != a2.length)
+        return false;
+    foreach(i, a; a1)
+    {
+        if (a != a2[i])
+            return false;
+    }
+    return true;
+}
+
+/**
+Calculates the hash value of $(D arg) with $(D seed) initial value.
+Result may be non-equals with `typeid(T).getHash(&arg)`
+The $(D seed) value may be used for hash chaining:
+----
+struct Test
+{
+    int a;
+    string b;
+    MyObject c;
+
+    size_t toHash() const @safe pure nothrow
+    {
+        size_t hash = a.hashOf();
+        hash = b.hashOf(hash);
+        size_t h1 = c.myMegaHash();
+        hash = h1.hashOf(hash); //Mix two hash values
+        return hash;
+    }
+}
+----
+*/
+size_t hashOf(T)(auto ref T arg, size_t seed = 0)
+{
+    import core.internal.hash;
+    return core.internal.hash.hashOf(arg, seed);
+}
+
+bool _xopEquals(in void*, in void*)
+{
+    throw new Error("TypeInfo.equals is not implemented");
+}
+
+bool _xopCmp(in void*, in void*)
+{
+    throw new Error("TypeInfo.compare is not implemented");
+}
+
+void __ctfeWrite(T...)(auto ref T) {}
+void __ctfeWriteln(T...)(auto ref T values) { __ctfeWrite(values, "\n"); }
+
+/******************************************
+ * Create RTInfo for type T
+ */
+
+template RTInfo(T)
+{
+    enum RTInfo = null;
+}
+
+
+// Helper functions
+
+private inout(TypeInfo) getElement(inout TypeInfo value) @trusted pure nothrow
+{
+    TypeInfo element = cast() value;
+    for(;;)
+    {
+        if(auto qualified = cast(TypeInfo_Const) element)
+            element = qualified.base;
+        else if(auto redefined = cast(TypeInfo_Typedef) element) // typedef & enum
+            element = redefined.base;
+        else if(auto staticArray = cast(TypeInfo_StaticArray) element)
+            element = staticArray.value;
+        else if(auto vector = cast(TypeInfo_Vector) element)
+            element = vector.base;
+        else
+            break;
+    }
+    return cast(inout) element;
+}
+
+private size_t getArrayHash(in TypeInfo element, in void* ptr, in size_t count) @trusted nothrow
+{
+    if(!count)
+        return 0;
+
+    const size_t elementSize = element.tsize;
+    if(!elementSize)
+        return 0;
+
+    static bool hasCustomToHash(in TypeInfo value) @trusted pure nothrow
+    {
+        const element = getElement(value);
+
+        if(const struct_ = cast(const TypeInfo_Struct) element)
+            return !!struct_.xtoHash;
+
+        return cast(const TypeInfo_Array) element
+            || cast(const TypeInfo_AssociativeArray) element
+            || cast(const ClassInfo) element
+            || cast(const TypeInfo_Interface) element;
+    }
+
+    import core.internal.traits : externDFunc;
+    alias hashOf = externDFunc!("rt.util.hash.hashOf",
+                                size_t function(const(void)*, size_t, size_t) @trusted pure nothrow);
+    if(!hasCustomToHash(element))
+        return hashOf(ptr, elementSize * count, 0);
+
+    size_t hash = 0;
+    foreach(size_t i; 0 .. count)
+        hash += element.getHash(ptr + i * elementSize);
+    return hash;
+}
+
+
+// @@@BUG5835@@@ tests:
+
+unittest
+{
+    class C
+    {
+        int i;
+        this(in int i) { this.i = i; }
+        override hash_t toHash() { return 0; }
+    }
+    C[] a1 = [new C(11)], a2 = [new C(12)];
+    assert(typeid(C[]).getHash(&a1) == typeid(C[]).getHash(&a2)); // fails
+}
+
+unittest
+{
+    struct S
+    {
+        int i;
+        hash_t toHash() const @safe nothrow { return 0; }
+    }
+    S[] a1 = [S(11)], a2 = [S(12)];
+    assert(typeid(S[]).getHash(&a1) == typeid(S[]).getHash(&a2)); // fails
+}
+
+@safe unittest
+{
+    struct S
+    {
+        int i;
+    const @safe nothrow:
+        hash_t toHash() { return 0; }
+        bool opEquals(const S) { return true; }
+        int opCmp(const S) { return 0; }
+    }
+
+    int[S[]] aa = [[S(11)] : 13];
+    assert(aa[[S(12)]] == 13); // fails
+}
+
+/// Provide the .dup array property.
+@property auto dup(T)(T[] a)
+    if (!is(const(T) : T))
+{
+    import core.internal.traits : Unconst;
+    static assert(is(T : Unconst!T), "Cannot implicitly convert type "~T.stringof~
+                  " to "~Unconst!T.stringof~" in dup.");
+
+    // wrap unsafe _dup in @trusted to preserve @safe postblit
+    static if (__traits(compiles, (T b) @safe { T a = b; }))
+        return _trustedDup!(T, Unconst!T)(a);
+    else
+        return _dup!(T, Unconst!T)(a);
+}
+
+/// ditto
+// const overload to support implicit conversion to immutable (unique result, see DIP29)
+@property T[] dup(T)(const(T)[] a)
+    if (is(const(T) : T))
+{
+    // wrap unsafe _dup in @trusted to preserve @safe postblit
+    static if (__traits(compiles, (T b) @safe { T a = b; }))
+        return _trustedDup!(const(T), T)(a);
+    else
+        return _dup!(const(T), T)(a);
+}
+
+/// ditto
+@property T[] dup(T:void)(const(T)[] a) @trusted
+{
+    if (__ctfe) assert(0, "Cannot dup a void[] array at compile time.");
+    return cast(T[])_rawDup(a);
+}
+
+/// Provide the .idup array property.
+@property immutable(T)[] idup(T)(T[] a)
+{
+    static assert(is(T : immutable(T)), "Cannot implicitly convert type "~T.stringof~
+                  " to immutable in idup.");
+
+    // wrap unsafe _dup in @trusted to preserve @safe postblit
+    static if (__traits(compiles, (T b) @safe { T a = b; }))
+        return _trustedDup!(T, immutable(T))(a);
+    else
+        return _dup!(T, immutable(T))(a);
+}
+
+/// ditto
+@property immutable(T)[] idup(T:void)(const(T)[] a)
+{
+    return a.dup;
+}
+
+private U[] _trustedDup(T, U)(T[] a) @trusted
+{
+    return _dup!(T, U)(a);
+}
+
+private U[] _dup(T, U)(T[] a) // pure nothrow depends on postblit
+{
+    if (__ctfe)
+    {
+        U[] res;
+        foreach (ref e; a)
+            res ~= e;
+        return res;
+    }
+
+    a = _rawDup(a);
+    auto res = *cast(typeof(return)*)&a;
+    _doPostblit(res);
+    return res;
+}
+
+private extern (C) void[] _d_newarrayU(const TypeInfo ti, size_t length) pure nothrow;
+
+private inout(T)[] _rawDup(T)(inout(T)[] a)
+{
+    import core.stdc.string : memcpy;
+
+    void[] arr = _d_newarrayU(typeid(T[]), a.length);
+    memcpy(arr.ptr, cast(void*)a.ptr, T.sizeof * a.length);
+    return *cast(inout(T)[]*)&arr;
+}
+
+private template _PostBlitType(T)
+{
+    // assume that ref T and void* are equivalent in abi level.
+    static if (is(T == struct))
+        alias _PostBlitType = typeof(function (ref T t){ T a = t; });
+    else
+        alias _PostBlitType = typeof(delegate (ref T t){ T a = t; });
+}
+
+// Returns null, or a delegate to call postblit of T
+private auto _getPostblit(T)() @trusted pure nothrow @nogc
+{
+    // infer static postblit type, run postblit if any
+    static if (is(T == struct))
+    {
+        import core.internal.traits : Unqual;
+        // use typeid(Unqual!T) here to skip TypeInfo_Const/Shared/...
+        return cast(_PostBlitType!T)typeid(Unqual!T).xpostblit;
+    }
+    else if ((&typeid(T).postblit).funcptr !is &TypeInfo.postblit)
+    {
+        return cast(_PostBlitType!T)&typeid(T).postblit;
+    }
+    else
+        return null;
+}
+
+private void _doPostblit(T)(T[] arr)
+{
+    // infer static postblit type, run postblit if any
+    if (auto postblit = _getPostblit!T())
+    {
+        foreach (ref elem; arr)
+            postblit(elem);
+    }
+}
+
+unittest
+{
+    static struct S1 { int* p; }
+    static struct S2 { @disable this(); }
+    static struct S3 { @disable this(this); }
+
+    int dg1() pure nothrow @safe
+    {
+        {
+           char[] m;
+           string i;
+           m = m.dup;
+           i = i.idup;
+           m = i.dup;
+           i = m.idup;
+        }
+        {
+           S1[] m;
+           immutable(S1)[] i;
+           m = m.dup;
+           i = i.idup;
+           static assert(!is(typeof(m.idup)));
+           static assert(!is(typeof(i.dup)));
+        }
+        {
+            S3[] m;
+            immutable(S3)[] i;
+            static assert(!is(typeof(m.dup)));
+            static assert(!is(typeof(i.idup)));
+        }
+        {
+            shared(S1)[] m;
+            m = m.dup;
+            static assert(!is(typeof(m.idup)));
+        }
+        {
+            int[] a = (inout(int)) { inout(const(int))[] a; return a.dup; }(0);
+        }
+        return 1;
+    }
+
+    int dg2() pure nothrow @safe
+    {
+        {
+           S2[] m = [S2.init, S2.init];
+           immutable(S2)[] i = [S2.init, S2.init];
+           m = m.dup;
+           m = i.dup;
+           i = m.idup;
+           i = i.idup;
+        }
+        return 2;
+    }
+
+    enum a = dg1();
+    enum b = dg2();
+    assert(dg1() == a);
+    assert(dg2() == b);
+}
+
+unittest
+{
+    static struct Sunpure { this(this) @safe nothrow {} }
+    static struct Sthrow { this(this) @safe pure {} }
+    static struct Sunsafe { this(this) @system pure nothrow {} }
+
+    static assert( __traits(compiles, ()         { [].dup!Sunpure; }));
+    static assert(!__traits(compiles, () pure    { [].dup!Sunpure; }));
+    static assert( __traits(compiles, ()         { [].dup!Sthrow; }));
+    static assert(!__traits(compiles, () nothrow { [].dup!Sthrow; }));
+    static assert( __traits(compiles, ()         { [].dup!Sunsafe; }));
+    static assert(!__traits(compiles, () @safe   { [].dup!Sunsafe; }));
+
+    static assert( __traits(compiles, ()         { [].idup!Sunpure; }));
+    static assert(!__traits(compiles, () pure    { [].idup!Sunpure; }));
+    static assert( __traits(compiles, ()         { [].idup!Sthrow; }));
+    static assert(!__traits(compiles, () nothrow { [].idup!Sthrow; }));
+    static assert( __traits(compiles, ()         { [].idup!Sunsafe; }));
+    static assert(!__traits(compiles, () @safe   { [].idup!Sunsafe; }));
+}
+
+unittest
+{
+    static int*[] pureFoo() pure { return null; }
+    { char[] s; immutable x = s.dup; }
+    { immutable x = (cast(int*[])null).dup; }
+    { immutable x = pureFoo(); }
+    { immutable x = pureFoo().dup; }
+}
+
+unittest
+{
+    auto a = [1, 2, 3];
+    auto b = a.dup;
+    debug(SENTINEL) {} else
+        assert(b.capacity >= 3);
+}
+
+unittest
+{
+    // Bugzilla 12580
+    void[] m = [0];
+    shared(void)[] s = [cast(shared)1];
+    immutable(void)[] i = [cast(immutable)2];
+
+    s = s.dup;
+    static assert(is(typeof(s.dup) == shared(void)[]));
+
+    m = i.dup;
+    i = m.dup;
+    i = i.idup;
+    i = m.idup;
+    i = s.idup;
+    i = s.dup;
+    static assert(!__traits(compiles, m = s.dup));
+}
+
+unittest
+{
+    // Bugzilla 13809
+    static struct S
+    {
+        this(this) {}
+        ~this() {}
+    }
+
+    S[] arr;
+    auto a = arr.dup;
+}
diff --git a/libphobos/libdruntime/rt/aApply.d b/libphobos/libdruntime/rt/aApply.d
new file mode 100644
index 00000000000..ef08fa91487
--- /dev/null
+++ b/libphobos/libdruntime/rt/aApply.d
@@ -0,0 +1,904 @@
+/**
+ * This code handles decoding UTF strings for foreach loops.  There are 6
+ * combinations of conversions between char, wchar, and dchar, and 2 of each
+ * of those.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ * Source: $(DRUNTIMESRC src/rt/_aApply.d)
+ */
+module rt.aApply;
+
+private import rt.util.utf : decode, toUTF8;
+
+/**********************************************/
+/* 1 argument versions */
+
+// dg is D, but _aApplycd() is C
+extern (D) alias int delegate(void *) dg_t;
+
+extern (C) int _aApplycd1(in char[] aa, dg_t dg)
+{
+    int result;
+    size_t len = aa.length;
+
+    debug(apply) printf("_aApplycd1(), len = %d\n", len);
+    for (size_t i = 0; i < len; )
+    {
+        dchar d = aa[i];
+        if (d & 0x80)
+            d = decode(aa, i);
+        else
+            ++i;
+        result = dg(cast(void *)&d);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplycd1.unittest\n");
+
+    auto s = "hello"c[];
+    int i;
+
+    foreach(dchar d; s)
+    {
+        switch (i)
+        {
+            case 0:     assert(d == 'h'); break;
+            case 1:     assert(d == 'e'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'l'); break;
+            case 4:     assert(d == 'o'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach(dchar d; s)
+    {
+        //printf("i = %d, d = %x\n", i, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'a'); break;
+            case 1:     assert(d == '\u1234'); break;
+            case 2:     assert(d == '\U000A0456'); break;
+            case 3:     assert(d == 'b'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 4);
+}
+
+/*****************************/
+
+extern (C) int _aApplywd1(in wchar[] aa, dg_t dg)
+{
+    int result;
+    size_t len = aa.length;
+
+    debug(apply) printf("_aApplywd1(), len = %d\n", len);
+    for (size_t i = 0; i < len; )
+    {
+        dchar d = aa[i];
+        if (d >= 0xD800)
+            d = decode(aa, i);
+        else
+            ++i;
+        result = dg(cast(void *)&d);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplywd1.unittest\n");
+
+    auto s = "hello"w[];
+    int i;
+
+    foreach(dchar d; s)
+    {
+        switch (i)
+        {
+            case 0:     assert(d == 'h'); break;
+            case 1:     assert(d == 'e'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'l'); break;
+            case 4:     assert(d == 'o'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach(dchar d; s)
+    {
+        //printf("i = %d, d = %x\n", i, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'a'); break;
+            case 1:     assert(d == '\u1234'); break;
+            case 2:     assert(d == '\U000A0456'); break;
+            case 3:     assert(d == 'b'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 4);
+}
+
+/*****************************/
+
+extern (C) int _aApplycw1(in char[] aa, dg_t dg)
+{
+    int result;
+    size_t len = aa.length;
+
+    debug(apply) printf("_aApplycw1(), len = %d\n", len);
+    for (size_t i = 0; i < len; )
+    {
+        wchar w = aa[i];
+        if (w & 0x80)
+        {
+            dchar d = decode(aa, i);
+            if (d <= 0xFFFF)
+                w = cast(wchar) d;
+            else
+            {
+                w = cast(wchar)((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
+                result = dg(cast(void *)&w);
+                if (result)
+                    break;
+                w = cast(wchar)(((d - 0x10000) & 0x3FF) + 0xDC00);
+            }
+        }
+        else
+            ++i;
+        result = dg(cast(void *)&w);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplycw1.unittest\n");
+
+    auto s = "hello"c[];
+    int i;
+
+    foreach(wchar d; s)
+    {
+        switch (i)
+        {
+            case 0:     assert(d == 'h'); break;
+            case 1:     assert(d == 'e'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'l'); break;
+            case 4:     assert(d == 'o'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach(wchar d; s)
+    {
+        //printf("i = %d, d = %x\n", i, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'a'); break;
+            case 1:     assert(d == 0x1234); break;
+            case 2:     assert(d == 0xDA41); break;
+            case 3:     assert(d == 0xDC56); break;
+            case 4:     assert(d == 'b'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+}
+
+/*****************************/
+
+extern (C) int _aApplywc1(in wchar[] aa, dg_t dg)
+{
+    int result;
+    size_t len = aa.length;
+
+    debug(apply) printf("_aApplywc1(), len = %d\n", len);
+    for (size_t i = 0; i < len; )
+    {
+        wchar w = aa[i];
+        if (w & ~0x7F)
+        {
+            char[4] buf = void;
+
+            dchar d = decode(aa, i);
+            auto b = toUTF8(buf, d);
+            foreach (char c2; b)
+            {
+                result = dg(cast(void *)&c2);
+                if (result)
+                    return result;
+            }
+        }
+        else
+        {
+            char c = cast(char)w;
+            ++i;
+            result = dg(cast(void *)&c);
+            if (result)
+                break;
+        }
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplywc1.unittest\n");
+
+    auto s = "hello"w[];
+    int i;
+
+    foreach(char d; s)
+    {
+        switch (i)
+        {
+            case 0:     assert(d == 'h'); break;
+            case 1:     assert(d == 'e'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'l'); break;
+            case 4:     assert(d == 'o'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach(char d; s)
+    {
+        //printf("i = %d, d = %x\n", i, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'a'); break;
+            case 1:     assert(d == 0xE1); break;
+            case 2:     assert(d == 0x88); break;
+            case 3:     assert(d == 0xB4); break;
+            case 4:     assert(d == 0xF2); break;
+            case 5:     assert(d == 0xA0); break;
+            case 6:     assert(d == 0x91); break;
+            case 7:     assert(d == 0x96); break;
+            case 8:     assert(d == 'b'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 9);
+}
+
+/*****************************/
+
+extern (C) int _aApplydc1(in dchar[] aa, dg_t dg)
+{
+    int result;
+
+    debug(apply) printf("_aApplydc1(), len = %d\n", aa.length);
+    foreach (dchar d; aa)
+    {
+        if (d & ~0x7F)
+        {
+            char[4] buf = void;
+
+            auto b = toUTF8(buf, d);
+            foreach (char c2; b)
+            {
+                result = dg(cast(void *)&c2);
+                if (result)
+                    return result;
+            }
+        }
+        else
+        {
+            char c = cast(char)d;
+            result = dg(cast(void *)&c);
+            if (result)
+                break;
+        }
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplyRdc1.unittest\n");
+
+    auto s = "hello"d[];
+    int i;
+
+    foreach(char d; s)
+    {
+        switch (i)
+        {
+            case 0:     assert(d == 'h'); break;
+            case 1:     assert(d == 'e'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'l'); break;
+            case 4:     assert(d == 'o'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach(char d; s)
+    {
+        //printf("i = %d, d = %x\n", i, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'a'); break;
+            case 1:     assert(d == 0xE1); break;
+            case 2:     assert(d == 0x88); break;
+            case 3:     assert(d == 0xB4); break;
+            case 4:     assert(d == 0xF2); break;
+            case 5:     assert(d == 0xA0); break;
+            case 6:     assert(d == 0x91); break;
+            case 7:     assert(d == 0x96); break;
+            case 8:     assert(d == 'b'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 9);
+}
+
+/*****************************/
+
+extern (C) int _aApplydw1(in dchar[] aa, dg_t dg)
+{
+    int result;
+
+    debug(apply) printf("_aApplydw1(), len = %d\n", aa.length);
+    foreach (dchar d; aa)
+    {
+        wchar w;
+
+        if (d <= 0xFFFF)
+            w = cast(wchar) d;
+        else
+        {
+            w = cast(wchar)((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
+            result = dg(cast(void *)&w);
+            if (result)
+                break;
+            w = cast(wchar)(((d - 0x10000) & 0x3FF) + 0xDC00);
+        }
+        result = dg(cast(void *)&w);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplydw1.unittest\n");
+
+    auto s = "hello"d[];
+    int i;
+
+    foreach(wchar d; s)
+    {
+        switch (i)
+        {
+            case 0:     assert(d == 'h'); break;
+            case 1:     assert(d == 'e'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'l'); break;
+            case 4:     assert(d == 'o'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach(wchar d; s)
+    {
+        //printf("i = %d, d = %x\n", i, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'a'); break;
+            case 1:     assert(d == 0x1234); break;
+            case 2:     assert(d == 0xDA41); break;
+            case 3:     assert(d == 0xDC56); break;
+            case 4:     assert(d == 'b'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+}
+
+
+/****************************************************************************/
+/* 2 argument versions */
+
+// dg is D, but _aApplycd2() is C
+extern (D) alias int delegate(void *, void *) dg2_t;
+
+extern (C) int _aApplycd2(in char[] aa, dg2_t dg)
+{
+    int result;
+    size_t len = aa.length;
+
+    debug(apply) printf("_aApplycd2(), len = %d\n", len);
+    size_t n;
+    for (size_t i = 0; i < len; i += n)
+    {
+        dchar d = aa[i];
+        if (d & 0x80)
+        {
+            n = i;
+            d = decode(aa, n);
+            n -= i;
+        }
+        else
+            n = 1;
+        result = dg(&i, cast(void *)&d);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplycd2.unittest\n");
+
+    auto s = "hello"c[];
+    int i;
+
+    foreach(k, dchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        assert(k == i);
+        switch (i)
+        {
+            case 0:     assert(d == 'h'); break;
+            case 1:     assert(d == 'e'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'l'); break;
+            case 4:     assert(d == 'o'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach(k, dchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'a'); assert(k == 0); break;
+            case 1:     assert(d == '\u1234'); assert(k == 1); break;
+            case 2:     assert(d == '\U000A0456'); assert(k == 4); break;
+            case 3:     assert(d == 'b'); assert(k == 8); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 4);
+}
+
+/*****************************/
+
+extern (C) int _aApplywd2(in wchar[] aa, dg2_t dg)
+{
+    int result;
+    size_t len = aa.length;
+
+    debug(apply) printf("_aApplywd2(), len = %d\n", len);
+    size_t n;
+    for (size_t i = 0; i < len; i += n)
+    {
+        dchar d = aa[i];
+        if (d & ~0x7F)
+        {
+            n = i;
+            d = decode(aa, n);
+            n -= i;
+        }
+        else
+            n = 1;
+        result = dg(&i, cast(void *)&d);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplywd2.unittest\n");
+
+    auto s = "hello"w[];
+    int i;
+
+    foreach(k, dchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        assert(k == i);
+        switch (i)
+        {
+            case 0:     assert(d == 'h'); break;
+            case 1:     assert(d == 'e'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'l'); break;
+            case 4:     assert(d == 'o'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach(k, dchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        switch (i)
+        {
+            case 0:     assert(k == 0); assert(d == 'a'); break;
+            case 1:     assert(k == 1); assert(d == '\u1234'); break;
+            case 2:     assert(k == 2); assert(d == '\U000A0456'); break;
+            case 3:     assert(k == 4); assert(d == 'b'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 4);
+}
+
+/*****************************/
+
+extern (C) int _aApplycw2(in char[] aa, dg2_t dg)
+{
+    int result;
+    size_t len = aa.length;
+
+    debug(apply) printf("_aApplycw2(), len = %d\n", len);
+    size_t n;
+    for (size_t i = 0; i < len; i += n)
+    {
+        wchar w = aa[i];
+        if (w & 0x80)
+        {
+            n = i;
+            dchar d = decode(aa, n);
+            n -= i;
+            if (d <= 0xFFFF)
+                w = cast(wchar) d;
+            else
+            {
+                w = cast(wchar) ((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
+                result = dg(&i, cast(void *)&w);
+                if (result)
+                    break;
+                w = cast(wchar) (((d - 0x10000) & 0x3FF) + 0xDC00);
+            }
+        }
+        else
+            n = 1;
+        result = dg(&i, cast(void *)&w);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplycw2.unittest\n");
+
+    auto s = "hello"c[];
+    int i;
+
+    foreach(k, wchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        assert(k == i);
+        switch (i)
+        {
+            case 0:     assert(d == 'h'); break;
+            case 1:     assert(d == 'e'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'l'); break;
+            case 4:     assert(d == 'o'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach(k, wchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        switch (i)
+        {
+            case 0:     assert(k == 0); assert(d == 'a'); break;
+            case 1:     assert(k == 1); assert(d == 0x1234); break;
+            case 2:     assert(k == 4); assert(d == 0xDA41); break;
+            case 3:     assert(k == 4); assert(d == 0xDC56); break;
+            case 4:     assert(k == 8); assert(d == 'b'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+}
+
+/*****************************/
+
+extern (C) int _aApplywc2(in wchar[] aa, dg2_t dg)
+{
+    int result;
+    size_t len = aa.length;
+
+    debug(apply) printf("_aApplywc2(), len = %d\n", len);
+    size_t n;
+    for (size_t i = 0; i < len; i += n)
+    {
+        wchar w = aa[i];
+        if (w & ~0x7F)
+        {
+            char[4] buf = void;
+
+            n = i;
+            dchar d = decode(aa, n);
+            n -= i;
+            auto b = toUTF8(buf, d);
+            foreach (char c2; b)
+            {
+                result = dg(&i, cast(void *)&c2);
+                if (result)
+                    return result;
+            }
+        }
+        else
+        {
+            char c = cast(char)w;
+            n = 1;
+            result = dg(&i, cast(void *)&c);
+            if (result)
+                break;
+        }
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplywc2.unittest\n");
+
+    auto s = "hello"w[];
+    int i;
+
+    foreach(k, char d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        assert(k == i);
+        switch (i)
+        {
+            case 0:     assert(d == 'h'); break;
+            case 1:     assert(d == 'e'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'l'); break;
+            case 4:     assert(d == 'o'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach(k, char d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        switch (i)
+        {
+            case 0:     assert(k == 0); assert(d == 'a'); break;
+            case 1:     assert(k == 1); assert(d == 0xE1); break;
+            case 2:     assert(k == 1); assert(d == 0x88); break;
+            case 3:     assert(k == 1); assert(d == 0xB4); break;
+            case 4:     assert(k == 2); assert(d == 0xF2); break;
+            case 5:     assert(k == 2); assert(d == 0xA0); break;
+            case 6:     assert(k == 2); assert(d == 0x91); break;
+            case 7:     assert(k == 2); assert(d == 0x96); break;
+            case 8:     assert(k == 4); assert(d == 'b'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 9);
+}
+
+/*****************************/
+
+extern (C) int _aApplydc2(in dchar[] aa, dg2_t dg)
+{
+    int result;
+    size_t len = aa.length;
+
+    debug(apply) printf("_aApplydc2(), len = %d\n", len);
+    for (size_t i = 0; i < len; i++)
+    {
+        dchar d = aa[i];
+        if (d & ~0x7F)
+        {
+            char[4] buf = void;
+
+            auto b = toUTF8(buf, d);
+            foreach (char c2; b)
+            {
+                result = dg(&i, cast(void *)&c2);
+                if (result)
+                    return result;
+            }
+        }
+        else
+        {
+            char c = cast(char)d;
+            result = dg(&i, cast(void *)&c);
+            if (result)
+                break;
+        }
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplydc2.unittest\n");
+
+    auto s = "hello"d[];
+    int i;
+
+    foreach(k, char d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        assert(k == i);
+        switch (i)
+        {
+            case 0:     assert(d == 'h'); break;
+            case 1:     assert(d == 'e'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'l'); break;
+            case 4:     assert(d == 'o'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach(k, char d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        switch (i)
+        {
+            case 0:     assert(k == 0); assert(d == 'a'); break;
+            case 1:     assert(k == 1); assert(d == 0xE1); break;
+            case 2:     assert(k == 1); assert(d == 0x88); break;
+            case 3:     assert(k == 1); assert(d == 0xB4); break;
+            case 4:     assert(k == 2); assert(d == 0xF2); break;
+            case 5:     assert(k == 2); assert(d == 0xA0); break;
+            case 6:     assert(k == 2); assert(d == 0x91); break;
+            case 7:     assert(k == 2); assert(d == 0x96); break;
+            case 8:     assert(k == 3); assert(d == 'b'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 9);
+}
+
+/*****************************/
+
+extern (C) int _aApplydw2(in dchar[] aa, dg2_t dg)
+{   int result;
+
+    debug(apply) printf("_aApplydw2(), len = %d\n", aa.length);
+    foreach (size_t i, dchar d; aa)
+    {
+        wchar w;
+        auto j = i;
+
+        if (d <= 0xFFFF)
+            w = cast(wchar) d;
+        else
+        {
+            w = cast(wchar) ((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
+            result = dg(&j, cast(void *)&w);
+            if (result)
+                break;
+            w = cast(wchar) (((d - 0x10000) & 0x3FF) + 0xDC00);
+        }
+        result = dg(&j, cast(void *)&w);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplydw2.unittest\n");
+
+    auto s = "hello"d[];
+    int i;
+
+    foreach(k, wchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        assert(k == i);
+        switch (i)
+        {
+            case 0:     assert(d == 'h'); break;
+            case 1:     assert(d == 'e'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'l'); break;
+            case 4:     assert(d == 'o'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach(k, wchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        switch (i)
+        {
+            case 0:     assert(k == 0); assert(d == 'a'); break;
+            case 1:     assert(k == 1); assert(d == 0x1234); break;
+            case 2:     assert(k == 2); assert(d == 0xDA41); break;
+            case 3:     assert(k == 2); assert(d == 0xDC56); break;
+            case 4:     assert(k == 3); assert(d == 'b'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+}
diff --git a/libphobos/libdruntime/rt/aApplyR.d b/libphobos/libdruntime/rt/aApplyR.d
new file mode 100644
index 00000000000..130fd2d5554
--- /dev/null
+++ b/libphobos/libdruntime/rt/aApplyR.d
@@ -0,0 +1,958 @@
+/**
+ * This code handles decoding UTF strings for foreach_reverse loops.  There are
+ * 6 combinations of conversions between char, wchar, and dchar, and 2 of each
+ * of those.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Sean Kelly
+ */
+
+/*          Copyright Digital Mars 2004 - 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.aApplyR;
+
+/* This code handles decoding UTF strings for foreach_reverse loops.
+ * There are 6 combinations of conversions between char, wchar,
+ * and dchar, and 2 of each of those.
+ */
+
+private import rt.util.utf;
+
+/**********************************************/
+/* 1 argument versions */
+
+// dg is D, but _aApplyRcd() is C
+extern (D) alias int delegate(void *) dg_t;
+
+extern (C) int _aApplyRcd1(in char[] aa, dg_t dg)
+{   int result;
+
+    debug(apply) printf("_aApplyRcd1(), len = %d\n", aa.length);
+    for (size_t i = aa.length; i != 0; )
+    {   dchar d;
+
+        i--;
+        d = aa[i];
+        if (d & 0x80)
+        {   char c = cast(char)d;
+            uint j;
+            uint m = 0x3F;
+            d = 0;
+            while ((c & 0xC0) != 0xC0)
+            {   if (i == 0)
+                    onUnicodeError("Invalid UTF-8 sequence", 0);
+                i--;
+                d |= (c & 0x3F) << j;
+                j += 6;
+                m >>= 1;
+                c = aa[i];
+            }
+            d |= (c & m) << j;
+        }
+        result = dg(cast(void *)&d);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplyRcd1.unittest\n");
+
+    auto s = "hello"c[];
+    int i;
+
+    foreach_reverse(dchar d; s)
+    {
+        switch (i)
+        {
+            case 0:     assert(d == 'o'); break;
+            case 1:     assert(d == 'l'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'e'); break;
+            case 4:     assert(d == 'h'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach_reverse(dchar d; s)
+    {
+        //printf("i = %d, d = %x\n", i, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'b'); break;
+            case 1:     assert(d == '\U000A0456'); break;
+            case 2:     assert(d == '\u1234'); break;
+            case 3:     assert(d == 'a'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 4);
+}
+
+/*****************************/
+
+extern (C) int _aApplyRwd1(in wchar[] aa, dg_t dg)
+{   int result;
+
+    debug(apply) printf("_aApplyRwd1(), len = %d\n", aa.length);
+    for (size_t i = aa.length; i != 0; )
+    {   dchar d;
+
+        i--;
+        d = aa[i];
+        if (d >= 0xDC00 && d <= 0xDFFF)
+        {   if (i == 0)
+                onUnicodeError("Invalid UTF-16 sequence", 0);
+            i--;
+            d = ((aa[i] - 0xD7C0) << 10) + (d - 0xDC00);
+        }
+        result = dg(cast(void *)&d);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplyRwd1.unittest\n");
+
+    auto s = "hello"w[];
+    int i;
+
+    foreach_reverse(dchar d; s)
+    {
+        switch (i)
+        {
+            case 0:     assert(d == 'o'); break;
+            case 1:     assert(d == 'l'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'e'); break;
+            case 4:     assert(d == 'h'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach_reverse(dchar d; s)
+    {
+        //printf("i = %d, d = %x\n", i, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'b'); break;
+            case 1:     assert(d == '\U000A0456'); break;
+            case 2:     assert(d == '\u1234'); break;
+            case 3:     assert(d == 'a'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 4);
+}
+
+/*****************************/
+
+extern (C) int _aApplyRcw1(in char[] aa, dg_t dg)
+{   int result;
+
+    debug(apply) printf("_aApplyRcw1(), len = %d\n", aa.length);
+    for (size_t i = aa.length; i != 0; )
+    {   dchar d;
+        wchar w;
+
+        i--;
+        w = aa[i];
+        if (w & 0x80)
+        {   char c = cast(char)w;
+            uint j;
+            uint m = 0x3F;
+            d = 0;
+            while ((c & 0xC0) != 0xC0)
+            {   if (i == 0)
+                    onUnicodeError("Invalid UTF-8 sequence", 0);
+                i--;
+                d |= (c & 0x3F) << j;
+                j += 6;
+                m >>= 1;
+                c = aa[i];
+            }
+            d |= (c & m) << j;
+
+            if (d <= 0xFFFF)
+                w = cast(wchar) d;
+            else
+            {
+                w = cast(wchar) ((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
+                result = dg(cast(void *)&w);
+                if (result)
+                    break;
+                w = cast(wchar) (((d - 0x10000) & 0x3FF) + 0xDC00);
+            }
+        }
+        result = dg(cast(void *)&w);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplyRcw1.unittest\n");
+
+    auto s = "hello"c[];
+    int i;
+
+    foreach_reverse(wchar d; s)
+    {
+        switch (i)
+        {
+            case 0:     assert(d == 'o'); break;
+            case 1:     assert(d == 'l'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'e'); break;
+            case 4:     assert(d == 'h'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach_reverse(wchar d; s)
+    {
+        //printf("i = %d, d = %x\n", i, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'b'); break;
+            case 1:     assert(d == 0xDA41); break;
+            case 2:     assert(d == 0xDC56); break;
+            case 3:     assert(d == 0x1234); break;
+            case 4:     assert(d == 'a'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+}
+
+/*****************************/
+
+extern (C) int _aApplyRwc1(in wchar[] aa, dg_t dg)
+{   int result;
+
+    debug(apply) printf("_aApplyRwc1(), len = %d\n", aa.length);
+    for (size_t i = aa.length; i != 0; )
+    {   dchar d;
+        char c;
+
+        i--;
+        d = aa[i];
+        if (d >= 0xDC00 && d <= 0xDFFF)
+        {   if (i == 0)
+                onUnicodeError("Invalid UTF-16 sequence", 0);
+            i--;
+            d = ((aa[i] - 0xD7C0) << 10) + (d - 0xDC00);
+        }
+
+        if (d & ~0x7F)
+        {
+            char[4] buf;
+
+            auto b = toUTF8(buf, d);
+            foreach (char c2; b)
+            {
+                result = dg(cast(void *)&c2);
+                if (result)
+                    return result;
+            }
+            continue;
+        }
+        c = cast(char)d;
+        result = dg(cast(void *)&c);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplyRwc1.unittest\n");
+
+    auto s = "hello"w[];
+    int i;
+
+    foreach_reverse(char d; s)
+    {
+        switch (i)
+        {
+            case 0:     assert(d == 'o'); break;
+            case 1:     assert(d == 'l'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'e'); break;
+            case 4:     assert(d == 'h'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach_reverse(char d; s)
+    {
+        //printf("i = %d, d = %x\n", i, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'b'); break;
+            case 1:     assert(d == 0xF2); break;
+            case 2:     assert(d == 0xA0); break;
+            case 3:     assert(d == 0x91); break;
+            case 4:     assert(d == 0x96); break;
+            case 5:     assert(d == 0xE1); break;
+            case 6:     assert(d == 0x88); break;
+            case 7:     assert(d == 0xB4); break;
+            case 8:     assert(d == 'a'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 9);
+}
+
+/*****************************/
+
+extern (C) int _aApplyRdc1(in dchar[] aa, dg_t dg)
+{   int result;
+
+    debug(apply) printf("_aApplyRdc1(), len = %d\n", aa.length);
+    for (size_t i = aa.length; i != 0;)
+    {   dchar d = aa[--i];
+        char c;
+
+        if (d & ~0x7F)
+        {
+            char[4] buf;
+
+            auto b = toUTF8(buf, d);
+            foreach (char c2; b)
+            {
+                result = dg(cast(void *)&c2);
+                if (result)
+                    return result;
+            }
+            continue;
+        }
+        else
+        {
+            c = cast(char)d;
+        }
+        result = dg(cast(void *)&c);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplyRdc1.unittest\n");
+
+    auto s = "hello"d[];
+    int i;
+
+    foreach_reverse(char d; s)
+    {
+        switch (i)
+        {
+            case 0:     assert(d == 'o'); break;
+            case 1:     assert(d == 'l'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'e'); break;
+            case 4:     assert(d == 'h'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach_reverse(char d; s)
+    {
+        //printf("i = %d, d = %x\n", i, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'b'); break;
+            case 1:     assert(d == 0xF2); break;
+            case 2:     assert(d == 0xA0); break;
+            case 3:     assert(d == 0x91); break;
+            case 4:     assert(d == 0x96); break;
+            case 5:     assert(d == 0xE1); break;
+            case 6:     assert(d == 0x88); break;
+            case 7:     assert(d == 0xB4); break;
+            case 8:     assert(d == 'a'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 9);
+}
+
+/*****************************/
+
+extern (C) int _aApplyRdw1(in dchar[] aa, dg_t dg)
+{   int result;
+
+    debug(apply) printf("_aApplyRdw1(), len = %d\n", aa.length);
+    for (size_t i = aa.length; i != 0; )
+    {   dchar d = aa[--i];
+        wchar w;
+
+        if (d <= 0xFFFF)
+            w = cast(wchar) d;
+        else
+        {
+            w = cast(wchar) ((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
+            result = dg(cast(void *)&w);
+            if (result)
+                break;
+            w = cast(wchar) (((d - 0x10000) & 0x3FF) + 0xDC00);
+        }
+        result = dg(cast(void *)&w);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplyRdw1.unittest\n");
+
+    auto s = "hello"d[];
+    int i;
+
+    foreach_reverse(wchar d; s)
+    {
+        switch (i)
+        {
+            case 0:     assert(d == 'o'); break;
+            case 1:     assert(d == 'l'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'e'); break;
+            case 4:     assert(d == 'h'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach_reverse(wchar d; s)
+    {
+        //printf("i = %d, d = %x\n", i, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'b'); break;
+            case 1:     assert(d == 0xDA41); break;
+            case 2:     assert(d == 0xDC56); break;
+            case 3:     assert(d == 0x1234); break;
+            case 4:     assert(d == 'a'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+}
+
+
+/****************************************************************************/
+/* 2 argument versions */
+
+// dg is D, but _aApplyRcd2() is C
+extern (D) alias int delegate(void *, void *) dg2_t;
+
+extern (C) int _aApplyRcd2(in char[] aa, dg2_t dg)
+{   int result;
+    size_t i;
+    size_t len = aa.length;
+
+    debug(apply) printf("_aApplyRcd2(), len = %d\n", len);
+    for (i = len; i != 0; )
+    {   dchar d;
+
+        i--;
+        d = aa[i];
+        if (d & 0x80)
+        {   char c = cast(char)d;
+            uint j;
+            uint m = 0x3F;
+            d = 0;
+            while ((c & 0xC0) != 0xC0)
+            {   if (i == 0)
+                    onUnicodeError("Invalid UTF-8 sequence", 0);
+                i--;
+                d |= (c & 0x3F) << j;
+                j += 6;
+                m >>= 1;
+                c = aa[i];
+            }
+            d |= (c & m) << j;
+        }
+        result = dg(&i, cast(void *)&d);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplyRcd2.unittest\n");
+
+    auto s = "hello"c[];
+    int i;
+
+    foreach_reverse(k, dchar d; s)
+    {
+        assert(k == 4 - i);
+        switch (i)
+        {
+            case 0:     assert(d == 'o'); break;
+            case 1:     assert(d == 'l'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'e'); break;
+            case 4:     assert(d == 'h'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach_reverse(k, dchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        switch (i)
+        {
+            case 0:     assert(d == 'b'); assert(k == 8); break;
+            case 1:     assert(d == '\U000A0456'); assert(k == 4); break;
+            case 2:     assert(d == '\u1234'); assert(k == 1); break;
+            case 3:     assert(d == 'a'); assert(k == 0); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 4);
+}
+
+/*****************************/
+
+extern (C) int _aApplyRwd2(in wchar[] aa, dg2_t dg)
+{   int result;
+
+    debug(apply) printf("_aApplyRwd2(), len = %d\n", aa.length);
+    for (size_t i = aa.length; i != 0; )
+    {   dchar d;
+
+        i--;
+        d = aa[i];
+        if (d >= 0xDC00 && d <= 0xDFFF)
+        {   if (i == 0)
+                onUnicodeError("Invalid UTF-16 sequence", 0);
+            i--;
+            d = ((aa[i] - 0xD7C0) << 10) + (d - 0xDC00);
+        }
+        result = dg(&i, cast(void *)&d);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplyRwd2.unittest\n");
+
+    auto s = "hello"w[];
+    int i;
+
+    foreach_reverse(k, dchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        assert(k == 4 - i);
+        switch (i)
+        {
+            case 0:     assert(d == 'o'); break;
+            case 1:     assert(d == 'l'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'e'); break;
+            case 4:     assert(d == 'h'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach_reverse(k, dchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        switch (i)
+        {
+            case 0:     assert(k == 4); assert(d == 'b'); break;
+            case 1:     assert(k == 2); assert(d == '\U000A0456'); break;
+            case 2:     assert(k == 1); assert(d == '\u1234'); break;
+            case 3:     assert(k == 0); assert(d == 'a'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 4);
+}
+
+/*****************************/
+
+extern (C) int _aApplyRcw2(in char[] aa, dg2_t dg)
+{   int result;
+
+    debug(apply) printf("_aApplyRcw2(), len = %d\n", aa.length);
+    for (size_t i = aa.length; i != 0; )
+    {   dchar d;
+        wchar w;
+
+        i--;
+        w = aa[i];
+        if (w & 0x80)
+        {   char c = cast(char)w;
+            uint j;
+            uint m = 0x3F;
+            d = 0;
+            while ((c & 0xC0) != 0xC0)
+            {   if (i == 0)
+                    onUnicodeError("Invalid UTF-8 sequence", 0);
+                i--;
+                d |= (c & 0x3F) << j;
+                j += 6;
+                m >>= 1;
+                c = aa[i];
+            }
+            d |= (c & m) << j;
+
+            if (d <= 0xFFFF)
+                w = cast(wchar) d;
+            else
+            {
+                w = cast(wchar) ((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
+                result = dg(&i, cast(void *)&w);
+                if (result)
+                    break;
+                w = cast(wchar) (((d - 0x10000) & 0x3FF) + 0xDC00);
+            }
+        }
+        result = dg(&i, cast(void *)&w);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplyRcw2.unittest\n");
+
+    auto s = "hello"c[];
+    int i;
+
+    foreach_reverse(k, wchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        assert(k == 4 - i);
+        switch (i)
+        {
+            case 0:     assert(d == 'o'); break;
+            case 1:     assert(d == 'l'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'e'); break;
+            case 4:     assert(d == 'h'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach_reverse(k, wchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        switch (i)
+        {
+            case 0:     assert(k == 8); assert(d == 'b'); break;
+            case 1:     assert(k == 4); assert(d == 0xDA41); break;
+            case 2:     assert(k == 4); assert(d == 0xDC56); break;
+            case 3:     assert(k == 1); assert(d == 0x1234); break;
+            case 4:     assert(k == 0); assert(d == 'a'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+}
+
+/*****************************/
+
+extern (C) int _aApplyRwc2(in wchar[] aa, dg2_t dg)
+{   int result;
+
+    debug(apply) printf("_aApplyRwc2(), len = %d\n", aa.length);
+    for (size_t i = aa.length; i != 0; )
+    {   dchar d;
+        char c;
+
+        i--;
+        d = aa[i];
+        if (d >= 0xDC00 && d <= 0xDFFF)
+        {   if (i == 0)
+                onUnicodeError("Invalid UTF-16 sequence", 0);
+            i--;
+            d = ((aa[i] - 0xD7C0) << 10) + (d - 0xDC00);
+        }
+
+        if (d & ~0x7F)
+        {
+            char[4] buf;
+
+            auto b = toUTF8(buf, d);
+            foreach (char c2; b)
+            {
+                result = dg(&i, cast(void *)&c2);
+                if (result)
+                    return result;
+            }
+            continue;
+        }
+        c = cast(char)d;
+        result = dg(&i, cast(void *)&c);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplyRwc2.unittest\n");
+
+    auto s = "hello"w[];
+    int i;
+
+    foreach_reverse(k, char d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        assert(k == 4 - i);
+        switch (i)
+        {
+            case 0:     assert(d == 'o'); break;
+            case 1:     assert(d == 'l'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'e'); break;
+            case 4:     assert(d == 'h'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach_reverse(k, char d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        switch (i)
+        {
+            case 0:     assert(k == 4); assert(d == 'b'); break;
+            case 1:     assert(k == 2); assert(d == 0xF2); break;
+            case 2:     assert(k == 2); assert(d == 0xA0); break;
+            case 3:     assert(k == 2); assert(d == 0x91); break;
+            case 4:     assert(k == 2); assert(d == 0x96); break;
+            case 5:     assert(k == 1); assert(d == 0xE1); break;
+            case 6:     assert(k == 1); assert(d == 0x88); break;
+            case 7:     assert(k == 1); assert(d == 0xB4); break;
+            case 8:     assert(k == 0); assert(d == 'a'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 9);
+}
+
+/*****************************/
+
+extern (C) int _aApplyRdc2(in dchar[] aa, dg2_t dg)
+{   int result;
+
+    debug(apply) printf("_aApplyRdc2(), len = %d\n", aa.length);
+    for (size_t i = aa.length; i != 0; )
+    {   dchar d = aa[--i];
+        char c;
+
+        if (d & ~0x7F)
+        {
+            char[4] buf;
+
+            auto b = toUTF8(buf, d);
+            foreach (char c2; b)
+            {
+                result = dg(&i, cast(void *)&c2);
+                if (result)
+                    return result;
+            }
+            continue;
+        }
+        else
+        {   c = cast(char)d;
+        }
+        result = dg(&i, cast(void *)&c);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplyRdc2.unittest\n");
+
+    auto s = "hello"d[];
+    int i;
+
+    foreach_reverse(k, char d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        assert(k == 4 - i);
+        switch (i)
+        {
+            case 0:     assert(d == 'o'); break;
+            case 1:     assert(d == 'l'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'e'); break;
+            case 4:     assert(d == 'h'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach_reverse(k, char d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        switch (i)
+        {
+            case 0:     assert(k == 3); assert(d == 'b'); break;
+            case 1:     assert(k == 2); assert(d == 0xF2); break;
+            case 2:     assert(k == 2); assert(d == 0xA0); break;
+            case 3:     assert(k == 2); assert(d == 0x91); break;
+            case 4:     assert(k == 2); assert(d == 0x96); break;
+            case 5:     assert(k == 1); assert(d == 0xE1); break;
+            case 6:     assert(k == 1); assert(d == 0x88); break;
+            case 7:     assert(k == 1); assert(d == 0xB4); break;
+            case 8:     assert(k == 0); assert(d == 'a'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 9);
+}
+
+/*****************************/
+
+extern (C) int _aApplyRdw2(in dchar[] aa, dg2_t dg)
+{   int result;
+
+    debug(apply) printf("_aApplyRdw2(), len = %d\n", aa.length);
+    for (size_t i = aa.length; i != 0; )
+    {   dchar d = aa[--i];
+        wchar w;
+
+        if (d <= 0xFFFF)
+            w = cast(wchar) d;
+        else
+        {
+            w = cast(wchar) ((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
+            result = dg(&i, cast(void *)&w);
+            if (result)
+                break;
+            w = cast(wchar) (((d - 0x10000) & 0x3FF) + 0xDC00);
+        }
+        result = dg(&i, cast(void *)&w);
+        if (result)
+            break;
+    }
+    return result;
+}
+
+unittest
+{
+    debug(apply) printf("_aApplyRdw2.unittest\n");
+
+    auto s = "hello"d[];
+    int i;
+
+    foreach_reverse(k, wchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        assert(k == 4 - i);
+        switch (i)
+        {
+            case 0:     assert(d == 'o'); break;
+            case 1:     assert(d == 'l'); break;
+            case 2:     assert(d == 'l'); break;
+            case 3:     assert(d == 'e'); break;
+            case 4:     assert(d == 'h'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+
+    s = "a\u1234\U000A0456b";
+    i = 0;
+    foreach_reverse(k, wchar d; s)
+    {
+        //printf("i = %d, k = %d, d = %x\n", i, k, d);
+        switch (i)
+        {
+            case 0:     assert(k == 3); assert(d == 'b'); break;
+            case 1:     assert(k == 2); assert(d == 0xDA41); break;
+            case 2:     assert(k == 2); assert(d == 0xDC56); break;
+            case 3:     assert(k == 1); assert(d == 0x1234); break;
+            case 4:     assert(k == 0); assert(d == 'a'); break;
+            default:    assert(0);
+        }
+        i++;
+    }
+    assert(i == 5);
+}
diff --git a/libphobos/libdruntime/rt/aaA.d b/libphobos/libdruntime/rt/aaA.d
new file mode 100644
index 00000000000..e9767c95c8f
--- /dev/null
+++ b/libphobos/libdruntime/rt/aaA.d
@@ -0,0 +1,990 @@
+/**
+ * Implementation of associative arrays.
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2015.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ */
+module rt.aaA;
+
+/// AA version for debuggers, bump whenever changing the layout
+extern (C) immutable int _aaVersion = 1;
+
+import core.memory : GC;
+
+// grow threshold
+private enum GROW_NUM = 4;
+private enum GROW_DEN = 5;
+// shrink threshold
+private enum SHRINK_NUM = 1;
+private enum SHRINK_DEN = 8;
+// grow factor
+private enum GROW_FAC = 4;
+// growing the AA doubles it's size, so the shrink threshold must be
+// smaller than half the grow threshold to have a hysteresis
+static assert(GROW_FAC * SHRINK_NUM * GROW_DEN < GROW_NUM * SHRINK_DEN);
+// initial load factor (for literals), mean of both thresholds
+private enum INIT_NUM = (GROW_DEN * SHRINK_NUM + GROW_NUM * SHRINK_DEN) / 2;
+private enum INIT_DEN = SHRINK_DEN * GROW_DEN;
+
+private enum INIT_NUM_BUCKETS = 8;
+// magic hash constants to distinguish empty, deleted, and filled buckets
+private enum HASH_EMPTY = 0;
+private enum HASH_DELETED = 0x1;
+private enum HASH_FILLED_MARK = size_t(1) << 8 * size_t.sizeof - 1;
+
+/// Opaque AA wrapper
+struct AA
+{
+    Impl* impl;
+    alias impl this;
+
+    private @property bool empty() const pure nothrow @nogc
+    {
+        return impl is null || !impl.length;
+    }
+}
+
+private struct Impl
+{
+private:
+    this(in TypeInfo_AssociativeArray ti, size_t sz = INIT_NUM_BUCKETS)
+    {
+        keysz = cast(uint) ti.key.tsize;
+        valsz = cast(uint) ti.value.tsize;
+        buckets = allocBuckets(sz);
+        firstUsed = cast(uint) buckets.length;
+        entryTI = fakeEntryTI(ti.key, ti.value);
+        valoff = cast(uint) talign(keysz, ti.value.talign);
+
+        import rt.lifetime : hasPostblit, unqualify;
+
+        if (hasPostblit(unqualify(ti.key)))
+            flags |= Flags.keyHasPostblit;
+        if ((ti.key.flags | ti.value.flags) & 1)
+            flags |= Flags.hasPointers;
+    }
+
+    Bucket[] buckets;
+    uint used;
+    uint deleted;
+    TypeInfo_Struct entryTI;
+    uint firstUsed;
+    immutable uint keysz;
+    immutable uint valsz;
+    immutable uint valoff;
+    Flags flags;
+
+    enum Flags : ubyte
+    {
+        none = 0x0,
+        keyHasPostblit = 0x1,
+        hasPointers = 0x2,
+    }
+
+    @property size_t length() const pure nothrow @nogc
+    {
+        assert(used >= deleted);
+        return used - deleted;
+    }
+
+    @property size_t dim() const pure nothrow @nogc
+    {
+        return buckets.length;
+    }
+
+    @property size_t mask() const pure nothrow @nogc
+    {
+        return dim - 1;
+    }
+
+    // find the first slot to insert a value with hash
+    inout(Bucket)* findSlotInsert(size_t hash) inout pure nothrow @nogc
+    {
+        for (size_t i = hash & mask, j = 1;; ++j)
+        {
+            if (!buckets[i].filled)
+                return &buckets[i];
+            i = (i + j) & mask;
+        }
+    }
+
+    // lookup a key
+    inout(Bucket)* findSlotLookup(size_t hash, in void* pkey, in TypeInfo keyti) inout
+    {
+        for (size_t i = hash & mask, j = 1;; ++j)
+        {
+            if (buckets[i].hash == hash && keyti.equals(pkey, buckets[i].entry))
+                return &buckets[i];
+            else if (buckets[i].empty)
+                return null;
+            i = (i + j) & mask;
+        }
+    }
+
+    void grow(in TypeInfo keyti)
+    {
+        // If there are so many deleted entries, that growing would push us
+        // below the shrink threshold, we just purge deleted entries instead.
+        if (length * SHRINK_DEN < GROW_FAC * dim * SHRINK_NUM)
+            resize(dim);
+        else
+            resize(GROW_FAC * dim);
+    }
+
+    void shrink(in TypeInfo keyti)
+    {
+        if (dim > INIT_NUM_BUCKETS)
+            resize(dim / GROW_FAC);
+    }
+
+    void resize(size_t ndim) pure nothrow
+    {
+        auto obuckets = buckets;
+        buckets = allocBuckets(ndim);
+
+        foreach (ref b; obuckets[firstUsed .. $])
+            if (b.filled)
+                *findSlotInsert(b.hash) = b;
+
+        firstUsed = 0;
+        used -= deleted;
+        deleted = 0;
+        GC.free(obuckets.ptr); // safe to free b/c impossible to reference
+    }
+
+    void clear() pure nothrow
+    {
+        import core.stdc.string : memset;
+        // clear all data, but don't change bucket array length
+        memset(&buckets[firstUsed], 0, (buckets.length - firstUsed) * Bucket.sizeof);
+        deleted = used = 0;
+        firstUsed = cast(uint) dim;
+    }
+}
+
+//==============================================================================
+// Bucket
+//------------------------------------------------------------------------------
+
+private struct Bucket
+{
+private pure nothrow @nogc:
+    size_t hash;
+    void* entry;
+
+    @property bool empty() const
+    {
+        return hash == HASH_EMPTY;
+    }
+
+    @property bool deleted() const
+    {
+        return hash == HASH_DELETED;
+    }
+
+    @property bool filled() const
+    {
+        return cast(ptrdiff_t) hash < 0;
+    }
+}
+
+Bucket[] allocBuckets(size_t dim) @trusted pure nothrow
+{
+    enum attr = GC.BlkAttr.NO_INTERIOR;
+    immutable sz = dim * Bucket.sizeof;
+    return (cast(Bucket*) GC.calloc(sz, attr))[0 .. dim];
+}
+
+//==============================================================================
+// Entry
+//------------------------------------------------------------------------------
+
+private void* allocEntry(in Impl* aa, in void* pkey)
+{
+    import rt.lifetime : _d_newitemU;
+    import core.stdc.string : memcpy, memset;
+
+    immutable akeysz = aa.valoff;
+    void* res = void;
+    if (aa.entryTI)
+        res = _d_newitemU(aa.entryTI);
+    else
+    {
+        auto flags = (aa.flags & Impl.Flags.hasPointers) ? 0 : GC.BlkAttr.NO_SCAN;
+        res = GC.malloc(akeysz + aa.valsz, flags);
+    }
+
+    memcpy(res, pkey, aa.keysz); // copy key
+    memset(res + akeysz, 0, aa.valsz); // zero value
+
+    return res;
+}
+
+package void entryDtor(void* p, const TypeInfo_Struct sti)
+{
+    // key and value type info stored after the TypeInfo_Struct by tiEntry()
+    auto sizeti = __traits(classInstanceSize, TypeInfo_Struct);
+    auto extra = cast(const(TypeInfo)*)(cast(void*) sti + sizeti);
+    extra[0].destroy(p);
+    extra[1].destroy(p + talign(extra[0].tsize, extra[1].talign));
+}
+
+private bool hasDtor(const TypeInfo ti)
+{
+    import rt.lifetime : unqualify;
+
+    if (typeid(ti) is typeid(TypeInfo_Struct))
+        if ((cast(TypeInfo_Struct) cast(void*) ti).xdtor)
+            return true;
+    if (typeid(ti) is typeid(TypeInfo_StaticArray))
+        return hasDtor(unqualify(ti.next));
+
+    return false;
+}
+
+// build type info for Entry with additional key and value fields
+TypeInfo_Struct fakeEntryTI(const TypeInfo keyti, const TypeInfo valti)
+{
+    import rt.lifetime : unqualify;
+
+    auto kti = unqualify(keyti);
+    auto vti = unqualify(valti);
+    if (!hasDtor(kti) && !hasDtor(vti))
+        return null;
+
+    // save kti and vti after type info for struct
+    enum sizeti = __traits(classInstanceSize, TypeInfo_Struct);
+    void* p = GC.malloc(sizeti + 2 * (void*).sizeof);
+    import core.stdc.string : memcpy;
+
+    memcpy(p, typeid(TypeInfo_Struct).initializer().ptr, sizeti);
+
+    auto ti = cast(TypeInfo_Struct) p;
+    auto extra = cast(TypeInfo*)(p + sizeti);
+    extra[0] = cast() kti;
+    extra[1] = cast() vti;
+
+    static immutable tiName = __MODULE__ ~ ".Entry!(...)";
+    ti.name = tiName;
+
+    // we don't expect the Entry objects to be used outside of this module, so we have control
+    // over the non-usage of the callback methods and other entries and can keep these null
+    // xtoHash, xopEquals, xopCmp, xtoString and xpostblit
+    ti.m_RTInfo = null;
+    immutable entrySize = talign(kti.tsize, vti.talign) + vti.tsize;
+    ti.m_init = (cast(ubyte*) null)[0 .. entrySize]; // init length, but not ptr
+
+    // xdtor needs to be built from the dtors of key and value for the GC
+    ti.xdtorti = &entryDtor;
+
+    ti.m_flags = TypeInfo_Struct.StructFlags.isDynamicType;
+    ti.m_flags |= (keyti.flags | valti.flags) & TypeInfo_Struct.StructFlags.hasPointers;
+    ti.m_align = cast(uint) max(kti.talign, vti.talign);
+
+    return ti;
+}
+
+//==============================================================================
+// Helper functions
+//------------------------------------------------------------------------------
+
+private size_t talign(size_t tsize, size_t algn) @safe pure nothrow @nogc
+{
+    immutable mask = algn - 1;
+    assert(!(mask & algn));
+    return (tsize + mask) & ~mask;
+}
+
+// mix hash to "fix" bad hash functions
+private size_t mix(size_t h) @safe pure nothrow @nogc
+{
+    // final mix function of MurmurHash2
+    enum m = 0x5bd1e995;
+    h ^= h >> 13;
+    h *= m;
+    h ^= h >> 15;
+    return h;
+}
+
+private size_t calcHash(in void* pkey, in TypeInfo keyti)
+{
+    immutable hash = keyti.getHash(pkey);
+    // highest bit is set to distinguish empty/deleted from filled buckets
+    return mix(hash) | HASH_FILLED_MARK;
+}
+
+private size_t nextpow2(in size_t n) pure nothrow @nogc
+{
+    import core.bitop : bsr;
+
+    if (!n)
+        return 1;
+
+    const isPowerOf2 = !((n - 1) & n);
+    return 1 << (bsr(n) + !isPowerOf2);
+}
+
+pure nothrow @nogc unittest
+{
+    //                            0, 1, 2, 3, 4, 5, 6, 7, 8,  9
+    foreach (const n, const pow2; [1, 1, 2, 4, 4, 8, 8, 8, 8, 16])
+        assert(nextpow2(n) == pow2);
+}
+
+private T min(T)(T a, T b) pure nothrow @nogc
+{
+    return a < b ? a : b;
+}
+
+private T max(T)(T a, T b) pure nothrow @nogc
+{
+    return b < a ? a : b;
+}
+
+//==============================================================================
+// API Implementation
+//------------------------------------------------------------------------------
+
+/// Determine number of entries in associative array.
+extern (C) size_t _aaLen(in AA aa) pure nothrow @nogc
+{
+    return aa ? aa.length : 0;
+}
+
+/// Get LValue for key
+extern (C) void* _aaGetY(AA* aa, const TypeInfo_AssociativeArray ti, in size_t valsz,
+    in void* pkey)
+{
+    // lazily alloc implementation
+    if (aa.impl is null)
+        aa.impl = new Impl(ti);
+
+    // get hash and bucket for key
+    immutable hash = calcHash(pkey, ti.key);
+
+    // found a value => return it
+    if (auto p = aa.findSlotLookup(hash, pkey, ti.key))
+        return p.entry + aa.valoff;
+
+    auto p = aa.findSlotInsert(hash);
+    if (p.deleted)
+        --aa.deleted;
+    // check load factor and possibly grow
+    else if (++aa.used * GROW_DEN > aa.dim * GROW_NUM)
+    {
+        aa.grow(ti.key);
+        p = aa.findSlotInsert(hash);
+        assert(p.empty);
+    }
+
+    // update search cache and allocate entry
+    aa.firstUsed = min(aa.firstUsed, cast(uint)(p - aa.buckets.ptr));
+    p.hash = hash;
+    p.entry = allocEntry(aa.impl, pkey);
+    // postblit for key
+    if (aa.flags & Impl.Flags.keyHasPostblit)
+    {
+        import rt.lifetime : __doPostblit, unqualify;
+
+        __doPostblit(p.entry, aa.keysz, unqualify(ti.key));
+    }
+    // return pointer to value
+    return p.entry + aa.valoff;
+}
+
+/// Get RValue for key, returns null if not present
+extern (C) inout(void)* _aaGetRvalueX(inout AA aa, in TypeInfo keyti, in size_t valsz,
+    in void* pkey)
+{
+    return _aaInX(aa, keyti, pkey);
+}
+
+/// Return pointer to value if present, null otherwise
+extern (C) inout(void)* _aaInX(inout AA aa, in TypeInfo keyti, in void* pkey)
+{
+    if (aa.empty)
+        return null;
+
+    immutable hash = calcHash(pkey, keyti);
+    if (auto p = aa.findSlotLookup(hash, pkey, keyti))
+        return p.entry + aa.valoff;
+    return null;
+}
+
+/// Delete entry in AA, return true if it was present
+extern (C) bool _aaDelX(AA aa, in TypeInfo keyti, in void* pkey)
+{
+    if (aa.empty)
+        return false;
+
+    immutable hash = calcHash(pkey, keyti);
+    if (auto p = aa.findSlotLookup(hash, pkey, keyti))
+    {
+        // clear entry
+        p.hash = HASH_DELETED;
+        p.entry = null;
+
+        ++aa.deleted;
+        if (aa.length * SHRINK_DEN < aa.dim * SHRINK_NUM)
+            aa.shrink(keyti);
+
+        return true;
+    }
+    return false;
+}
+
+/// Remove all elements from AA.
+extern (C) void _aaClear(AA aa) pure nothrow
+{
+    if (!aa.empty)
+    {
+        aa.impl.clear();
+    }
+}
+
+/// Rehash AA
+extern (C) void* _aaRehash(AA* paa, in TypeInfo keyti) pure nothrow
+{
+    if (!paa.empty)
+        paa.resize(nextpow2(INIT_DEN * paa.length / INIT_NUM));
+    return *paa;
+}
+
+/// Return a GC allocated array of all values
+extern (C) inout(void[]) _aaValues(inout AA aa, in size_t keysz, in size_t valsz,
+    const TypeInfo tiValueArray) pure nothrow
+{
+    if (aa.empty)
+        return null;
+
+    import rt.lifetime : _d_newarrayU;
+
+    auto res = _d_newarrayU(tiValueArray, aa.length).ptr;
+    auto pval = res;
+
+    immutable off = aa.valoff;
+    foreach (b; aa.buckets[aa.firstUsed .. $])
+    {
+        if (!b.filled)
+            continue;
+        pval[0 .. valsz] = b.entry[off .. valsz + off];
+        pval += valsz;
+    }
+    // postblit is done in object.values
+    return (cast(inout(void)*) res)[0 .. aa.length]; // fake length, return number of elements
+}
+
+/// Return a GC allocated array of all keys
+extern (C) inout(void[]) _aaKeys(inout AA aa, in size_t keysz, const TypeInfo tiKeyArray) pure nothrow
+{
+    if (aa.empty)
+        return null;
+
+    import rt.lifetime : _d_newarrayU;
+
+    auto res = _d_newarrayU(tiKeyArray, aa.length).ptr;
+    auto pkey = res;
+
+    foreach (b; aa.buckets[aa.firstUsed .. $])
+    {
+        if (!b.filled)
+            continue;
+        pkey[0 .. keysz] = b.entry[0 .. keysz];
+        pkey += keysz;
+    }
+    // postblit is done in object.keys
+    return (cast(inout(void)*) res)[0 .. aa.length]; // fake length, return number of elements
+}
+
+// opApply callbacks are extern(D)
+extern (D) alias dg_t = int delegate(void*);
+extern (D) alias dg2_t = int delegate(void*, void*);
+
+/// foreach opApply over all values
+extern (C) int _aaApply(AA aa, in size_t keysz, dg_t dg)
+{
+    if (aa.empty)
+        return 0;
+
+    immutable off = aa.valoff;
+    foreach (b; aa.buckets)
+    {
+        if (!b.filled)
+            continue;
+        if (auto res = dg(b.entry + off))
+            return res;
+    }
+    return 0;
+}
+
+/// foreach opApply over all key/value pairs
+extern (C) int _aaApply2(AA aa, in size_t keysz, dg2_t dg)
+{
+    if (aa.empty)
+        return 0;
+
+    immutable off = aa.valoff;
+    foreach (b; aa.buckets)
+    {
+        if (!b.filled)
+            continue;
+        if (auto res = dg(b.entry, b.entry + off))
+            return res;
+    }
+    return 0;
+}
+
+/// Construct an associative array of type ti from keys and value
+extern (C) Impl* _d_assocarrayliteralTX(const TypeInfo_AssociativeArray ti, void[] keys,
+    void[] vals)
+{
+    assert(keys.length == vals.length);
+
+    immutable keysz = ti.key.tsize;
+    immutable valsz = ti.value.tsize;
+    immutable length = keys.length;
+
+    if (!length)
+        return null;
+
+    auto aa = new Impl(ti, nextpow2(INIT_DEN * length / INIT_NUM));
+
+    void* pkey = keys.ptr;
+    void* pval = vals.ptr;
+    immutable off = aa.valoff;
+    foreach (_; 0 .. length)
+    {
+        immutable hash = calcHash(pkey, ti.key);
+
+        auto p = aa.findSlotLookup(hash, pkey, ti.key);
+        if (p is null)
+        {
+            p = aa.findSlotInsert(hash);
+            p.hash = hash;
+            p.entry = allocEntry(aa, pkey); // move key, no postblit
+            aa.firstUsed = min(aa.firstUsed, cast(uint)(p - aa.buckets.ptr));
+        }
+        else if (aa.entryTI && hasDtor(ti.value))
+        {
+            // destroy existing value before overwriting it
+            ti.value.destroy(p.entry + off);
+        }
+        // set hash and blit value
+        auto pdst = p.entry + off;
+        pdst[0 .. valsz] = pval[0 .. valsz]; // move value, no postblit
+
+        pkey += keysz;
+        pval += valsz;
+    }
+    aa.used = cast(uint) length;
+    return aa;
+}
+
+/// compares 2 AAs for equality
+extern (C) int _aaEqual(in TypeInfo tiRaw, in AA aa1, in AA aa2)
+{
+    if (aa1.impl is aa2.impl)
+        return true;
+
+    immutable len = _aaLen(aa1);
+    if (len != _aaLen(aa2))
+        return false;
+
+    if (!len) // both empty
+        return true;
+
+    import rt.lifetime : unqualify;
+
+    auto uti = unqualify(tiRaw);
+    auto ti = *cast(TypeInfo_AssociativeArray*)&uti;
+    // compare the entries
+    immutable off = aa1.valoff;
+    foreach (b1; aa1.buckets)
+    {
+        if (!b1.filled)
+            continue;
+        auto pb2 = aa2.findSlotLookup(b1.hash, b1.entry, ti.key);
+        if (pb2 is null || !ti.value.equals(b1.entry + off, pb2.entry + off))
+            return false;
+    }
+    return true;
+}
+
+/// compute a hash
+extern (C) hash_t _aaGetHash(in AA* aa, in TypeInfo tiRaw) nothrow
+{
+    if (aa.empty)
+        return 0;
+
+    import rt.lifetime : unqualify;
+
+    auto uti = unqualify(tiRaw);
+    auto ti = *cast(TypeInfo_AssociativeArray*)&uti;
+    immutable off = aa.valoff;
+    auto valHash = &ti.value.getHash;
+
+    size_t h;
+    foreach (b; aa.buckets)
+    {
+        if (!b.filled)
+            continue;
+        size_t[2] h2 = [b.hash, valHash(b.entry + off)];
+        // use XOR here, so that hash is independent of element order
+        h ^= hashOf(h2.ptr, h2.length * h2[0].sizeof);
+    }
+    return h;
+}
+
+/**
+ * _aaRange implements a ForwardRange
+ */
+struct Range
+{
+    Impl* impl;
+    size_t idx;
+    alias impl this;
+}
+
+extern (C) pure nothrow @nogc
+{
+    Range _aaRange(AA aa)
+    {
+        if (!aa)
+            return Range();
+
+        foreach (i; aa.firstUsed .. aa.dim)
+        {
+            if (aa.buckets[i].filled)
+                return Range(aa.impl, i);
+        }
+        return Range(aa, aa.dim);
+    }
+
+    bool _aaRangeEmpty(Range r)
+    {
+        return r.impl is null || r.idx == r.dim;
+    }
+
+    void* _aaRangeFrontKey(Range r)
+    {
+        return r.buckets[r.idx].entry;
+    }
+
+    void* _aaRangeFrontValue(Range r)
+    {
+        return r.buckets[r.idx].entry + r.valoff;
+    }
+
+    void _aaRangePopFront(ref Range r)
+    {
+        for (++r.idx; r.idx < r.dim; ++r.idx)
+        {
+            if (r.buckets[r.idx].filled)
+                break;
+        }
+    }
+}
+
+//==============================================================================
+// Unittests
+//------------------------------------------------------------------------------
+
+pure nothrow unittest
+{
+    int[string] aa;
+
+    assert(aa.keys.length == 0);
+    assert(aa.values.length == 0);
+
+    aa["hello"] = 3;
+    assert(aa["hello"] == 3);
+    aa["hello"]++;
+    assert(aa["hello"] == 4);
+
+    assert(aa.length == 1);
+
+    string[] keys = aa.keys;
+    assert(keys.length == 1);
+    assert(keys[0] == "hello");
+
+    int[] values = aa.values;
+    assert(values.length == 1);
+    assert(values[0] == 4);
+
+    aa.rehash;
+    assert(aa.length == 1);
+    assert(aa["hello"] == 4);
+
+    aa["foo"] = 1;
+    aa["bar"] = 2;
+    aa["batz"] = 3;
+
+    assert(aa.keys.length == 4);
+    assert(aa.values.length == 4);
+
+    foreach (a; aa.keys)
+    {
+        assert(a.length != 0);
+        assert(a.ptr != null);
+    }
+
+    foreach (v; aa.values)
+    {
+        assert(v != 0);
+    }
+}
+
+unittest  // Test for Issue 10381
+{
+    alias II = int[int];
+    II aa1 = [0 : 1];
+    II aa2 = [0 : 1];
+    II aa3 = [0 : 2];
+    assert(aa1 == aa2); // Passes
+    assert(typeid(II).equals(&aa1, &aa2));
+    assert(!typeid(II).equals(&aa1, &aa3));
+}
+
+pure nothrow unittest
+{
+    string[int] key1 = [1 : "true", 2 : "false"];
+    string[int] key2 = [1 : "false", 2 : "true"];
+    string[int] key3;
+
+    // AA lits create a larger hashtable
+    int[string[int]] aa1 = [key1 : 100, key2 : 200, key3 : 300];
+
+    // Ensure consistent hash values are computed for key1
+    assert((key1 in aa1) !is null);
+
+    // Manually assigning to an empty AA creates a smaller hashtable
+    int[string[int]] aa2;
+    aa2[key1] = 100;
+    aa2[key2] = 200;
+    aa2[key3] = 300;
+
+    assert(aa1 == aa2);
+
+    // Ensure binary-independence of equal hash keys
+    string[int] key2a;
+    key2a[1] = "false";
+    key2a[2] = "true";
+
+    assert(aa1[key2a] == 200);
+}
+
+// Issue 9852
+pure nothrow unittest
+{
+    // Original test case (revised, original assert was wrong)
+    int[string] a;
+    a["foo"] = 0;
+    a.remove("foo");
+    assert(a == null); // should not crash
+
+    int[string] b;
+    assert(b is null);
+    assert(a == b); // should not deref null
+    assert(b == a); // ditto
+
+    int[string] c;
+    c["a"] = 1;
+    assert(a != c); // comparison with empty non-null AA
+    assert(c != a);
+    assert(b != c); // comparison with null AA
+    assert(c != b);
+}
+
+// Bugzilla 14104
+unittest
+{
+    import core.stdc.stdio;
+
+    alias K = const(ubyte)*;
+    size_t[K] aa;
+    immutable key = cast(K)(cast(size_t) uint.max + 1);
+    aa[key] = 12;
+    assert(key in aa);
+}
+
+unittest
+{
+    int[int] aa;
+    foreach (k, v; aa)
+        assert(false);
+    foreach (v; aa)
+        assert(false);
+    assert(aa.byKey.empty);
+    assert(aa.byValue.empty);
+    assert(aa.byKeyValue.empty);
+
+    size_t n;
+    aa = [0 : 3, 1 : 4, 2 : 5];
+    foreach (k, v; aa)
+    {
+        n += k;
+        assert(k >= 0 && k < 3);
+        assert(v >= 3 && v < 6);
+    }
+    assert(n == 3);
+    n = 0;
+
+    foreach (v; aa)
+    {
+        n += v;
+        assert(v >= 3 && v < 6);
+    }
+    assert(n == 12);
+
+    n = 0;
+    foreach (k, v; aa)
+    {
+        ++n;
+        break;
+    }
+    assert(n == 1);
+
+    n = 0;
+    foreach (v; aa)
+    {
+        ++n;
+        break;
+    }
+    assert(n == 1);
+}
+
+unittest
+{
+    int[int] aa;
+    assert(!aa.remove(0));
+    aa = [0 : 1];
+    assert(aa.remove(0));
+    assert(!aa.remove(0));
+    aa[1] = 2;
+    assert(!aa.remove(0));
+    assert(aa.remove(1));
+
+    assert(aa.length == 0);
+    assert(aa.byKey.empty);
+}
+
+version (GNU)
+{
+// test zero sized value (hashset)
+unittest
+{
+    alias V = void[0];
+    auto aa = [0 : V.init];
+    assert(aa.length == 1);
+    assert(aa.byKey.front == 0);
+    assert(aa.byValue.front == V.init);
+    aa[1] = V.init;
+    assert(aa.length == 2);
+    aa[0] = V.init;
+    assert(aa.length == 2);
+    assert(aa.remove(0));
+    aa[0] = V.init;
+    assert(aa.length == 2);
+    assert(aa == [0 : V.init, 1 : V.init]);
+}
+}
+else
+{
+unittest
+{
+    alias E = void[0];
+    auto aa = [E.init : E.init];
+    assert(aa.length == 1);
+    assert(aa.byKey.front == E.init);
+    assert(aa.byValue.front == E.init);
+    aa[E.init] = E.init;
+    assert(aa.length == 1);
+    assert(aa.remove(E.init));
+    assert(aa.length == 0);
+}
+}
+
+// test tombstone purging
+unittest
+{
+    int[int] aa;
+    foreach (i; 0 .. 6)
+        aa[i] = i;
+    foreach (i; 0 .. 6)
+        assert(aa.remove(i));
+    foreach (i; 6 .. 10)
+        aa[i] = i;
+    assert(aa.length == 4);
+    foreach (i; 6 .. 10)
+        assert(i in aa);
+}
+
+// test postblit for AA literals
+unittest
+{
+    static struct T
+    {
+        ubyte field;
+        static size_t postblit, dtor;
+        this(this)
+        {
+            ++postblit;
+        }
+
+        ~this()
+        {
+            ++dtor;
+        }
+    }
+
+    T t;
+    auto aa1 = [0 : t, 1 : t];
+    assert(T.dtor == 0 && T.postblit == 2);
+    aa1[0] = t;
+    assert(T.dtor == 1 && T.postblit == 3);
+
+    T.dtor = 0;
+    T.postblit = 0;
+
+    auto aa2 = [0 : t, 1 : t, 0 : t]; // literal with duplicate key => value overwritten
+    assert(T.dtor == 1 && T.postblit == 3);
+
+    T.dtor = 0;
+    T.postblit = 0;
+
+    auto aa3 = [t : 0];
+    assert(T.dtor == 0 && T.postblit == 1);
+    aa3[t] = 1;
+    assert(T.dtor == 0 && T.postblit == 1);
+    aa3.remove(t);
+    assert(T.dtor == 0 && T.postblit == 1);
+    aa3[t] = 2;
+    assert(T.dtor == 0 && T.postblit == 2);
+
+    // dtor will be called by GC finalizers
+    aa1 = null;
+    aa2 = null;
+    aa3 = null;
+    GC.runFinalizers((cast(char*)(&entryDtor))[0 .. 1]);
+    assert(T.dtor == 6 && T.postblit == 2);
+}
+
+// for aa.clear
+pure nothrow unittest
+{
+    int[int] aa;
+    assert(aa.length == 0);
+    foreach (i; 0 .. 100)
+        aa[i] = i * 2;
+    assert(aa.length == 100);
+    auto aa2 = aa;
+    assert(aa2.length == 100);
+    aa.clear();
+    assert(aa.length == 0);
+    assert(aa2.length == 0);
+
+    aa2[5] = 6;
+    assert(aa.length == 1);
+    assert(aa[5] == 6);
+}
diff --git a/libphobos/libdruntime/rt/adi.d b/libphobos/libdruntime/rt/adi.d
new file mode 100644
index 00000000000..99b579b0732
--- /dev/null
+++ b/libphobos/libdruntime/rt/adi.d
@@ -0,0 +1,609 @@
+/**
+ * Implementation of dynamic array property support routines.
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2015.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Walter Bright
+ * Source: $(DRUNTIMESRC src/rt/_adi.d)
+ */
+
+module rt.adi;
+
+//debug=adi;            // uncomment to turn on debugging printf's
+
+private
+{
+    debug(adi) import core.stdc.stdio;
+    import core.stdc.string;
+    import core.stdc.stdlib;
+    import core.memory;
+    import rt.util.utf;
+
+    extern (C) void[] _adSort(void[] a, TypeInfo ti);
+}
+
+
+/**********************************************
+ * Reverse array of chars.
+ * Handled separately because embedded multibyte encodings should not be
+ * reversed.
+ */
+
+extern (C) char[] _adReverseChar(char[] a)
+{
+    if (a.length > 1)
+    {
+        char[6] tmp;
+        char[6] tmplo;
+        char* lo = a.ptr;
+        char* hi = &a[$ - 1];
+
+        while (lo < hi)
+        {   auto clo = *lo;
+            auto chi = *hi;
+
+            debug(adi) printf("lo = %d, hi = %d\n", lo, hi);
+            if (clo <= 0x7F && chi <= 0x7F)
+            {
+                debug(adi) printf("\tascii\n");
+                *lo = chi;
+                *hi = clo;
+                lo++;
+                hi--;
+                continue;
+            }
+
+            uint stridelo = UTF8stride[clo];
+
+            uint stridehi = 1;
+            while ((chi & 0xC0) == 0x80)
+            {
+                chi = *--hi;
+                stridehi++;
+                assert(hi >= lo);
+            }
+            if (lo == hi)
+                break;
+
+            debug(adi) printf("\tstridelo = %d, stridehi = %d\n", stridelo, stridehi);
+            if (stridelo == stridehi)
+            {
+
+                memcpy(tmp.ptr, lo, stridelo);
+                memcpy(lo, hi, stridelo);
+                memcpy(hi, tmp.ptr, stridelo);
+                lo += stridelo;
+                hi--;
+                continue;
+            }
+
+            /* Shift the whole array. This is woefully inefficient
+             */
+            memcpy(tmp.ptr, hi, stridehi);
+            memcpy(tmplo.ptr, lo, stridelo);
+            memmove(lo + stridehi, lo + stridelo , cast(size_t)((hi - lo) - stridelo));
+            memcpy(lo, tmp.ptr, stridehi);
+            memcpy(hi + stridehi - stridelo, tmplo.ptr, stridelo);
+
+            lo += stridehi;
+            hi = hi - 1 + cast(int)(stridehi - stridelo);
+        }
+    }
+    return a;
+}
+
+unittest
+{
+    auto a = "abcd"c[];
+
+    auto r = _adReverseChar(a.dup);
+    //writefln(r);
+    assert(r == "dcba");
+
+    a = "a\u1235\u1234c";
+    //writefln(a);
+    r = _adReverseChar(a.dup);
+    //writefln(r);
+    assert(r == "c\u1234\u1235a");
+
+    a = "ab\u1234c";
+    //writefln(a);
+    r = _adReverseChar(a.dup);
+    //writefln(r);
+    assert(r == "c\u1234ba");
+
+    a = "\u3026\u2021\u3061\n";
+    r = _adReverseChar(a.dup);
+    assert(r == "\n\u3061\u2021\u3026");
+}
+
+
+/**********************************************
+ * Reverse array of wchars.
+ * Handled separately because embedded multiword encodings should not be
+ * reversed.
+ */
+
+extern (C) wchar[] _adReverseWchar(wchar[] a)
+{
+    if (a.length > 1)
+    {
+        wchar[2] tmplo = void;
+        wchar[2] tmphi = void;
+        wchar* lo = a.ptr;
+        wchar* hi = &a[$ - 1];
+
+        while (lo < hi)
+        {   auto clo = *lo;
+            auto chi = *hi;
+
+            if ((clo < 0xD800 || clo > 0xDFFF) &&
+                (chi < 0xD800 || chi > 0xDFFF))
+            {
+                *lo = chi;
+                *hi = clo;
+                lo++;
+                hi--;
+                continue;
+            }
+
+            int stridelo = 1 + (clo >= 0xD800 && clo <= 0xDBFF);
+
+            int stridehi = 1;
+            if (chi >= 0xDC00 && chi <= 0xDFFF)
+            {
+                chi = *--hi;
+                stridehi++;
+                assert(hi >= lo);
+            }
+            if (lo == hi)
+                break;
+
+            if (stridelo == stridehi)
+            {
+                wchar[2] stmp;
+
+                assert(stridelo == 2);
+                stmp = lo[0 .. 2];
+                lo[0 .. 2] = hi[0 .. 2];
+                hi[0 .. 2] = stmp;
+                lo += stridelo;
+                hi--;
+                continue;
+            }
+
+            /* Shift the whole array. This is woefully inefficient
+             */
+            memcpy(tmplo.ptr, lo, stridelo * wchar.sizeof);
+            memcpy(tmphi.ptr, hi, stridehi * wchar.sizeof);
+            memmove(lo + stridehi, lo + stridelo , (hi - (lo + stridelo)) * wchar.sizeof);
+            memcpy(lo, tmphi.ptr, stridehi * wchar.sizeof);
+            memcpy(hi + (stridehi - stridelo), tmplo.ptr, stridelo * wchar.sizeof);
+
+            lo += stridehi;
+            hi = hi - 1 + (stridehi - stridelo);
+        }
+    }
+    return a;
+}
+
+unittest
+{
+  {
+    wstring a = "abcd";
+
+    auto r = _adReverseWchar(a.dup);
+    assert(r == "dcba");
+
+    a = "a\U00012356\U00012346c";
+    r = _adReverseWchar(a.dup);
+    assert(r == "c\U00012346\U00012356a");
+
+    a = "ab\U00012345c";
+    r = _adReverseWchar(a.dup);
+    assert(r == "c\U00012345ba");
+  }
+  {
+    wstring a = "a\U00000081b\U00002000c\U00010000";
+    wchar[] b = a.dup;
+
+    _adReverseWchar(b);
+    _adReverseWchar(b);
+    assert(b == "a\U00000081b\U00002000c\U00010000");
+  }
+}
+
+
+/**********************************************
+ * Support for array.reverse property.
+ */
+
+extern (C) void[] _adReverse(void[] a, size_t szelem)
+out (result)
+{
+    assert(result is a);
+}
+body
+{
+    if (a.length >= 2)
+    {
+        byte*    tmp;
+        byte[16] buffer;
+
+        void* lo = a.ptr;
+        void* hi = a.ptr + (a.length - 1) * szelem;
+
+        tmp = buffer.ptr;
+        if (szelem > 16)
+        {
+            //version (Windows)
+                tmp = cast(byte*) alloca(szelem);
+            //else
+                //tmp = GC.malloc(szelem);
+        }
+
+        for (; lo < hi; lo += szelem, hi -= szelem)
+        {
+            memcpy(tmp, lo,  szelem);
+            memcpy(lo,  hi,  szelem);
+            memcpy(hi,  tmp, szelem);
+        }
+
+        version (Windows)
+        {
+        }
+        else
+        {
+            //if (szelem > 16)
+                // BUG: bad code is generate for delete pointer, tries
+                // to call delclass.
+                //GC.free(tmp);
+        }
+    }
+    return a;
+}
+
+unittest
+{
+    debug(adi) printf("array.reverse.unittest\n");
+
+    int[] a = new int[5];
+    int[] b;
+
+    for (auto i = 0; i < 5; i++)
+        a[i] = i;
+    *(cast(void[]*)&b) = _adReverse(*cast(void[]*)&a, a[0].sizeof);
+    assert(b is a);
+    for (auto i = 0; i < 5; i++)
+        assert(a[i] == 4 - i);
+
+    struct X20
+    {   // More than 16 bytes in size
+        int a;
+        int b, c, d, e;
+    }
+
+    X20[] c = new X20[5];
+    X20[] d;
+
+    for (auto i = 0; i < 5; i++)
+    {   c[i].a = i;
+        c[i].e = 10;
+    }
+    *(cast(void[]*)&d) = _adReverse(*(cast(void[]*)&c), c[0].sizeof);
+    assert(d is c);
+    for (auto i = 0; i < 5; i++)
+    {
+        assert(c[i].a == 4 - i);
+        assert(c[i].e == 10);
+    }
+}
+
+private dchar[] mallocUTF32(C)(in C[] s)
+{
+    size_t j = 0;
+    auto p = cast(dchar*)malloc(dchar.sizeof * s.length);
+    auto r = p[0..s.length]; // r[] will never be longer than s[]
+    foreach (dchar c; s)
+        r[j++] = c;
+    return r[0 .. j];
+}
+
+/**********************************************
+ * Sort array of chars.
+ */
+
+extern (C) char[] _adSortChar(char[] a)
+{
+    if (a.length > 1)
+    {
+        auto da = mallocUTF32(a);
+        _adSort(*cast(void[]*)&da, typeid(da[0]));
+        size_t i = 0;
+        foreach (dchar d; da)
+        {   char[4] buf;
+            auto t = toUTF8(buf, d);
+            a[i .. i + t.length] = t[];
+            i += t.length;
+        }
+        free(da.ptr);
+    }
+    return a;
+}
+
+/**********************************************
+ * Sort array of wchars.
+ */
+
+extern (C) wchar[] _adSortWchar(wchar[] a)
+{
+    if (a.length > 1)
+    {
+        auto da = mallocUTF32(a);
+        _adSort(*cast(void[]*)&da, typeid(da[0]));
+        size_t i = 0;
+        foreach (dchar d; da)
+        {   wchar[2] buf;
+            auto t = toUTF16(buf, d);
+            a[i .. i + t.length] = t[];
+            i += t.length;
+        }
+        free(da.ptr);
+    }
+    return a;
+}
+
+/***************************************
+ * Support for array equality test.
+ * Returns:
+ *      1       equal
+ *      0       not equal
+ */
+
+extern (C) int _adEq(void[] a1, void[] a2, TypeInfo ti)
+{
+    debug(adi) printf("_adEq(a1.length = %d, a2.length = %d)\n", a1.length, a2.length);
+    if (a1.length != a2.length)
+        return 0; // not equal
+    auto sz = ti.tsize;
+    auto p1 = a1.ptr;
+    auto p2 = a2.ptr;
+
+    if (sz == 1)
+        // We should really have a ti.isPOD() check for this
+        return (memcmp(p1, p2, a1.length) == 0);
+
+    for (size_t i = 0; i < a1.length; i++)
+    {
+        if (!ti.equals(p1 + i * sz, p2 + i * sz))
+            return 0; // not equal
+    }
+    return 1; // equal
+}
+
+extern (C) int _adEq2(void[] a1, void[] a2, TypeInfo ti)
+{
+    debug(adi) printf("_adEq2(a1.length = %d, a2.length = %d)\n", a1.length, a2.length);
+    if (a1.length != a2.length)
+        return 0;               // not equal
+    if (!ti.equals(&a1, &a2))
+        return 0;
+    return 1;
+}
+unittest
+{
+    debug(adi) printf("array.Eq unittest\n");
+
+    auto a = "hello"c;
+
+    assert(a != "hel");
+    assert(a != "helloo");
+    assert(a != "betty");
+    assert(a == "hello");
+    assert(a != "hxxxx");
+
+    float[] fa = [float.nan];
+    assert(fa != fa);
+}
+
+/***************************************
+ * Support for array compare test.
+ */
+
+extern (C) int _adCmp(void[] a1, void[] a2, TypeInfo ti)
+{
+    debug(adi) printf("adCmp()\n");
+    auto len = a1.length;
+    if (a2.length < len)
+        len = a2.length;
+    auto sz = ti.tsize;
+    void *p1 = a1.ptr;
+    void *p2 = a2.ptr;
+
+    if (sz == 1)
+    {   // We should really have a ti.isPOD() check for this
+        auto c = memcmp(p1, p2, len);
+        if (c)
+            return c;
+    }
+    else
+    {
+        for (size_t i = 0; i < len; i++)
+        {
+            auto c = ti.compare(p1 + i * sz, p2 + i * sz);
+            if (c)
+                return c;
+        }
+    }
+    if (a1.length == a2.length)
+        return 0;
+    return (a1.length > a2.length) ? 1 : -1;
+}
+
+extern (C) int _adCmp2(void[] a1, void[] a2, TypeInfo ti)
+{
+    debug(adi) printf("_adCmp2(a1.length = %d, a2.length = %d)\n", a1.length, a2.length);
+    return ti.compare(&a1, &a2);
+}
+unittest
+{
+    debug(adi) printf("array.Cmp unittest\n");
+
+    auto a = "hello"c;
+
+    assert(a >  "hel");
+    assert(a >= "hel");
+    assert(a <  "helloo");
+    assert(a <= "helloo");
+    assert(a >  "betty");
+    assert(a >= "betty");
+    assert(a == "hello");
+    assert(a <= "hello");
+    assert(a >= "hello");
+    assert(a <  "я");
+}
+
+/***************************************
+ * Support for array compare test.
+ */
+
+extern (C) int _adCmpChar(void[] a1, void[] a2)
+{
+  version (D_InlineAsm_X86)
+  {
+    asm
+    {   naked                   ;
+
+        push    EDI             ;
+        push    ESI             ;
+
+        mov    ESI,a1+4[4+ESP]  ;
+        mov    EDI,a2+4[4+ESP]  ;
+
+        mov    ECX,a1[4+ESP]    ;
+        mov    EDX,a2[4+ESP]    ;
+
+        cmp     ECX,EDX         ;
+        jb      GotLength       ;
+
+        mov     ECX,EDX         ;
+
+GotLength:
+        cmp    ECX,4            ;
+        jb    DoBytes           ;
+
+        // Do alignment if neither is dword aligned
+        test    ESI,3           ;
+        jz    Aligned           ;
+
+        test    EDI,3           ;
+        jz    Aligned           ;
+DoAlign:
+        mov    AL,[ESI]         ; //align ESI to dword bounds
+        mov    DL,[EDI]         ;
+
+        cmp    AL,DL            ;
+        jnz    Unequal          ;
+
+        inc    ESI              ;
+        inc    EDI              ;
+
+        test    ESI,3           ;
+
+        lea    ECX,[ECX-1]      ;
+        jnz    DoAlign          ;
+Aligned:
+        mov    EAX,ECX          ;
+
+        // do multiple of 4 bytes at a time
+
+        shr    ECX,2            ;
+        jz    TryOdd            ;
+
+        repe                    ;
+        cmpsd                   ;
+
+        jnz    UnequalQuad      ;
+
+TryOdd:
+        mov    ECX,EAX          ;
+DoBytes:
+        // if still equal and not end of string, do up to 3 bytes slightly
+        // slower.
+
+        and    ECX,3            ;
+        jz    Equal             ;
+
+        repe                    ;
+        cmpsb                   ;
+
+        jnz    Unequal          ;
+Equal:
+        mov    EAX,a1[4+ESP]    ;
+        mov    EDX,a2[4+ESP]    ;
+
+        sub    EAX,EDX          ;
+        pop    ESI              ;
+
+        pop    EDI              ;
+        ret                     ;
+
+UnequalQuad:
+        mov    EDX,[EDI-4]      ;
+        mov    EAX,[ESI-4]      ;
+
+        cmp    AL,DL            ;
+        jnz    Unequal          ;
+
+        cmp    AH,DH            ;
+        jnz    Unequal          ;
+
+        shr    EAX,16           ;
+
+        shr    EDX,16           ;
+
+        cmp    AL,DL            ;
+        jnz    Unequal          ;
+
+        cmp    AH,DH            ;
+Unequal:
+        sbb    EAX,EAX          ;
+        pop    ESI              ;
+
+        or     EAX,1            ;
+        pop    EDI              ;
+
+        ret                     ;
+    }
+  }
+  else
+  {
+    debug(adi) printf("adCmpChar()\n");
+    auto len = a1.length;
+    if (a2.length < len)
+        len = a2.length;
+    auto c = memcmp(cast(char *)a1.ptr, cast(char *)a2.ptr, len);
+    if (!c)
+        c = cast(int)a1.length - cast(int)a2.length;
+    return c;
+  }
+}
+
+unittest
+{
+    debug(adi) printf("array.CmpChar unittest\n");
+
+    auto a = "hello"c;
+
+    assert(a >  "hel");
+    assert(a >= "hel");
+    assert(a <  "helloo");
+    assert(a <= "helloo");
+    assert(a >  "betty");
+    assert(a >= "betty");
+    assert(a == "hello");
+    assert(a <= "hello");
+    assert(a >= "hello");
+}
diff --git a/libphobos/libdruntime/rt/arrayassign.d b/libphobos/libdruntime/rt/arrayassign.d
new file mode 100644
index 00000000000..68305ef5f3e
--- /dev/null
+++ b/libphobos/libdruntime/rt/arrayassign.d
@@ -0,0 +1,263 @@
+/**
+ * Implementation of array assignment support routines.
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Kenji Hara
+ */
+
+/*          Copyright Digital Mars 2000 - 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.arrayassign;
+
+private
+{
+    import rt.util.array;
+    import core.stdc.string;
+    import core.stdc.stdlib;
+    debug(PRINTF) import core.stdc.stdio;
+}
+
+/**
+ * Keep for backward binary compatibility. This function can be removed in the future.
+ */
+extern (C) void[] _d_arrayassign(TypeInfo ti, void[] from, void[] to)
+{
+    debug(PRINTF) printf("_d_arrayassign(from = %p,%d, to = %p,%d) size = %d\n", from.ptr, from.length, to.ptr, to.length, ti.tsize);
+
+    immutable elementSize = ti.tsize;
+
+    // Need a temporary buffer tmp[] big enough to hold one element
+    void[16] buf = void;
+    void* ptmp = (elementSize > buf.sizeof) ? alloca(elementSize) : buf.ptr;
+    return _d_arrayassign_l(ti, from, to, ptmp);
+}
+
+/**
+ * Does array assignment (not construction) from another
+ * lvalue array of the same element type.
+ * Handles overlapping copies.
+ * Input:
+ *      ti      TypeInfo of the element type.
+ *      dst     Points target memory. Its .length is equal to the element count, not byte length.
+ *      src     Points source memory. Its .length is equal to the element count, not byte length.
+ *      ptmp    Temporary memory for element swapping.
+ */
+extern (C) void[] _d_arrayassign_l(TypeInfo ti, void[] src, void[] dst, void* ptmp)
+{
+    debug(PRINTF) printf("_d_arrayassign_l(src = %p,%d, dst = %p,%d) size = %d\n", src.ptr, src.length, dst.ptr, dst.length, ti.tsize);
+
+    immutable elementSize = ti.tsize;
+
+    enforceRawArraysConformable("copy", elementSize, src, dst, true);
+
+    if (src.ptr < dst.ptr && dst.ptr < src.ptr + elementSize * src.length)
+    {
+        // If dst is in the middle of src memory, use reverse order.
+        for (auto i = dst.length; i--; )
+        {
+            void* pdst = dst.ptr + i * elementSize;
+            void* psrc = src.ptr + i * elementSize;
+            memcpy(ptmp, pdst, elementSize);
+            memcpy(pdst, psrc, elementSize);
+            ti.postblit(pdst);
+            ti.destroy(ptmp);
+        }
+    }
+    else
+    {
+        // Otherwise, use normal order.
+        foreach (i; 0 .. dst.length)
+        {
+            void* pdst = dst.ptr + i * elementSize;
+            void* psrc = src.ptr + i * elementSize;
+            memcpy(ptmp, pdst, elementSize);
+            memcpy(pdst, psrc, elementSize);
+            ti.postblit(pdst);
+            ti.destroy(ptmp);
+        }
+    }
+    return dst;
+}
+
+unittest    // Bugzilla 14024
+{
+    string op;
+
+    struct S
+    {
+        char x = 'x';
+        this(this) { op ~= x-0x20; }    // upper case
+        ~this()    { op ~= x; }         // lower case
+    }
+
+    S[4] mem;
+    ref S[2] slice(int a, int b) { return mem[a .. b][0 .. 2]; }
+
+    op = null;
+    mem[0].x = 'a';
+    mem[1].x = 'b';
+    mem[2].x = 'x';
+    mem[3].x = 'y';
+    slice(0, 2) = slice(2, 4);  // [ab] = [xy]
+    assert(op == "XaYb", op);
+
+    op = null;
+    mem[0].x = 'x';
+    mem[1].x = 'y';
+    mem[2].x = 'a';
+    mem[3].x = 'b';
+    slice(2, 4) = slice(0, 2);  // [ab] = [xy]
+    assert(op == "XaYb", op);
+
+    op = null;
+    mem[0].x = 'a';
+    mem[1].x = 'b';
+    mem[2].x = 'c';
+    slice(0, 2) = slice(1, 3);  // [ab] = [bc]
+    assert(op == "BaCb", op);
+
+    op = null;
+    mem[0].x = 'x';
+    mem[1].x = 'y';
+    mem[2].x = 'z';
+    slice(1, 3) = slice(0, 2);  // [yz] = [xy]
+    assert(op == "YzXy", op);
+}
+
+/**
+ * Does array assignment (not construction) from another
+ * rvalue array of the same element type.
+ * Input:
+ *      ti      TypeInfo of the element type.
+ *      dst     Points target memory. Its .length is equal to the element count, not byte length.
+ *      src     Points source memory. Its .length is equal to the element count, not byte length.
+ *              It is always allocated on stack and never overlapping with dst.
+ *      ptmp    Temporary memory for element swapping.
+ */
+extern (C) void[] _d_arrayassign_r(TypeInfo ti, void[] src, void[] dst, void* ptmp)
+{
+    debug(PRINTF) printf("_d_arrayassign_r(src = %p,%d, dst = %p,%d) size = %d\n", src.ptr, src.length, dst.ptr, dst.length, ti.tsize);
+
+    immutable elementSize = ti.tsize;
+
+    enforceRawArraysConformable("copy", elementSize, src, dst, false);
+
+    // Always use normal order, because we can assume that
+    // the rvalue src has no overlapping with dst.
+    foreach (i; 0 .. dst.length)
+    {
+        void* pdst = dst.ptr + i * elementSize;
+        void* psrc = src.ptr + i * elementSize;
+        memcpy(ptmp, pdst, elementSize);
+        memcpy(pdst, psrc, elementSize);
+        ti.destroy(ptmp);
+    }
+    return dst;
+}
+
+/**
+ * Does array initialization (not assignment) from another
+ * array of the same element type.
+ * ti is the element type.
+ */
+extern (C) void[] _d_arrayctor(TypeInfo ti, void[] from, void[] to)
+{
+    debug(PRINTF) printf("_d_arrayctor(from = %p,%d, to = %p,%d) size = %d\n", from.ptr, from.length, to.ptr, to.length, ti.tsize);
+
+
+    auto element_size = ti.tsize;
+
+    enforceRawArraysConformable("initialization", element_size, from, to);
+
+    size_t i;
+    try
+    {
+        for (i = 0; i < to.length; i++)
+        {
+            // Copy construction is defined as bit copy followed by postblit.
+            memcpy(to.ptr + i * element_size, from.ptr + i * element_size, element_size);
+            ti.postblit(to.ptr + i * element_size);
+        }
+    }
+    catch (Throwable o)
+    {
+        /* Destroy, in reverse order, what we've constructed so far
+         */
+        while (i--)
+        {
+            ti.destroy(to.ptr + i * element_size);
+        }
+
+        throw o;
+    }
+    return to;
+}
+
+
+/**
+ * Do assignment to an array.
+ *      p[0 .. count] = value;
+ */
+extern (C) void* _d_arraysetassign(void* p, void* value, int count, TypeInfo ti)
+{
+    void* pstart = p;
+
+    auto element_size = ti.tsize;
+
+    //Need a temporary buffer tmp[] big enough to hold one element
+    void[16] buf = void;
+    void[] tmp;
+    if (element_size > buf.sizeof)
+    {
+        tmp = alloca(element_size)[0 .. element_size];
+    }
+    else
+        tmp = buf[];
+
+    foreach (i; 0 .. count)
+    {
+        memcpy(tmp.ptr, p, element_size);
+        memcpy(p, value, element_size);
+        ti.postblit(p);
+        ti.destroy(tmp.ptr);
+        p += element_size;
+    }
+    return pstart;
+}
+
+/**
+ * Do construction of an array.
+ *      ti[count] p = value;
+ */
+extern (C) void* _d_arraysetctor(void* p, void* value, int count, TypeInfo ti)
+{
+    void* pstart = p;
+    auto element_size = ti.tsize;
+
+    try
+    {
+        foreach (i; 0 .. count)
+        {
+            // Copy construction is defined as bit copy followed by postblit.
+            memcpy(p, value, element_size);
+            ti.postblit(p);
+            p += element_size;
+        }
+    }
+    catch (Throwable o)
+    {
+        // Destroy, in reverse order, what we've constructed so far
+        while (p > pstart)
+        {
+            p -= element_size;
+            ti.destroy(p);
+        }
+
+        throw o;
+    }
+    return pstart;
+}
diff --git a/libphobos/libdruntime/rt/arraycast.d b/libphobos/libdruntime/rt/arraycast.d
new file mode 100644
index 00000000000..52b135b5050
--- /dev/null
+++ b/libphobos/libdruntime/rt/arraycast.d
@@ -0,0 +1,97 @@
+/**
+ * Implementation of array cast support routines.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Sean Kelly
+ */
+
+/*          Copyright Digital Mars 2004 - 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.arraycast;
+
+/******************************************
+ * Runtime helper to convert dynamic array of one
+ * type to dynamic array of another.
+ * Adjusts the length of the array.
+ * Throws an error if new length is not aligned.
+ */
+
+extern (C)
+
+@trusted nothrow
+void[] _d_arraycast(size_t tsize, size_t fsize, void[] a)
+{
+    auto length = a.length;
+
+    auto nbytes = length * fsize;
+    if (nbytes % tsize != 0)
+    {
+        throw new Error("array cast misalignment");
+    }
+    length = nbytes / tsize;
+    *cast(size_t *)&a = length; // jam new length
+    return a;
+}
+
+unittest
+{
+    byte[int.sizeof * 3] b;
+    int[] i;
+    short[] s;
+
+    i = cast(int[])b;
+    assert(i.length == 3);
+
+    s = cast(short[])b;
+    assert(s.length == 6);
+
+    s = cast(short[])i;
+    assert(s.length == 6);
+}
+
+/******************************************
+ * Runtime helper to convert dynamic array of bits
+ * dynamic array of another.
+ * Adjusts the length of the array.
+ * Throws an error if new length is not aligned.
+ */
+
+version (none)
+{
+extern (C)
+
+@trusted nothrow
+void[] _d_arraycast_frombit(uint tsize, void[] a)
+{
+    uint length = a.length;
+
+    if (length & 7)
+    {
+       throw new Error("bit[] array cast misalignment");
+    }
+    length /= 8 * tsize;
+    *cast(size_t *)&a = length; // jam new length
+    return a;
+}
+
+unittest
+{
+    version (D_Bits)
+    {
+    bit[int.sizeof * 3 * 8] b;
+    int[] i;
+    short[] s;
+
+    i = cast(int[])b;
+    assert(i.length == 3);
+
+    s = cast(short[])b;
+    assert(s.length == 6);
+    }
+}
+
+}
diff --git a/libphobos/libdruntime/rt/arraycat.d b/libphobos/libdruntime/rt/arraycat.d
new file mode 100644
index 00000000000..c5542f22325
--- /dev/null
+++ b/libphobos/libdruntime/rt/arraycat.d
@@ -0,0 +1,33 @@
+/**
+ * Implementation of array copy support routines.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Sean Kelly
+ */
+
+/*          Copyright Digital Mars 2004 - 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.arraycat;
+
+private
+{
+    import core.stdc.string;
+    import rt.util.array;
+    debug(PRINTF) import core.stdc.stdio;
+}
+
+extern (C) @trusted nothrow:
+
+void[] _d_arraycopy(size_t size, void[] from, void[] to)
+{
+    debug(PRINTF) printf("f = %p,%d, t = %p,%d, size = %d\n",
+                 from.ptr, from.length, to.ptr, to.length, size);
+
+    enforceRawArraysConformable("copy", size, from, to);
+    memcpy(to.ptr, from.ptr, to.length * size);
+    return to;
+}
diff --git a/libphobos/libdruntime/rt/backtrace/dwarf.d b/libphobos/libdruntime/rt/backtrace/dwarf.d
new file mode 100644
index 00000000000..11074faeb63
--- /dev/null
+++ b/libphobos/libdruntime/rt/backtrace/dwarf.d
@@ -0,0 +1,525 @@
+/**
+ * This code handles backtrace generation using dwarf .debug_line section
+ * in ELF files for linux.
+ *
+ * Reference: http://www.dwarfstd.org/
+ *
+ * Copyright: Copyright Digital Mars 2015 - 2015.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Yazan Dabain, Sean Kelly
+ * Source: $(DRUNTIMESRC src/rt/backtrace/dwarf.d)
+ */
+
+module rt.backtrace.dwarf;
+
+version(CRuntime_Glibc) version = linux_or_freebsd;
+else version(FreeBSD) version = linux_or_freebsd;
+
+version(linux_or_freebsd):
+
+import rt.util.container.array;
+import rt.backtrace.elf;
+
+import core.stdc.string : strlen, memchr;
+
+//debug = DwarfDebugMachine;
+
+struct Location
+{
+    const(char)[] file = null; // file is missing directory, but DMD emits directory directly into file
+    int line = -1;
+    size_t address;
+}
+
+int traceHandlerOpApplyImpl(const void*[] callstack, scope int delegate(ref size_t, ref const(char[])) dg)
+{
+    import core.stdc.stdio : snprintf;
+    version(linux) import core.sys.linux.execinfo : backtrace_symbols;
+    else version(FreeBSD) import core.sys.freebsd.execinfo : backtrace_symbols;
+    import core.sys.posix.stdlib : free;
+
+    const char** frameList = backtrace_symbols(callstack.ptr, cast(int) callstack.length);
+    scope(exit) free(cast(void*) frameList);
+
+    // find address -> file, line mapping using dwarf debug_line
+    ElfFile file;
+    ElfSection dbgSection;
+    Array!Location locations;
+    if (ElfFile.openSelf(&file))
+    {
+        auto stringSectionHeader = ElfSectionHeader(&file, file.ehdr.e_shstrndx);
+        auto stringSection = ElfSection(&file, &stringSectionHeader);
+
+        auto dbgSectionIndex = findSectionByName(&file, &stringSection, ".debug_line");
+        if (dbgSectionIndex != -1)
+        {
+            auto dbgSectionHeader = ElfSectionHeader(&file, dbgSectionIndex);
+            dbgSection = ElfSection(&file, &dbgSectionHeader);
+            // debug_line section found and loaded
+
+            // resolve addresses
+            locations.length = callstack.length;
+            foreach(size_t i; 0 .. callstack.length)
+                locations[i].address = cast(size_t) callstack[i];
+
+            resolveAddresses(&dbgSection, locations[]);
+        }
+    }
+
+    int ret = 0;
+    foreach (size_t i; 0 .. callstack.length)
+    {
+        char[1536] buffer = void; buffer[0] = 0;
+        char[256] addressBuffer = void; addressBuffer[0] = 0;
+
+        if (locations.length > 0 && locations[i].line != -1)
+            snprintf(addressBuffer.ptr, addressBuffer.length, "%.*s:%d ", cast(int) locations[i].file.length, locations[i].file.ptr, locations[i].line);
+        else
+            addressBuffer[] = "??:? \0";
+
+        char[1024] symbolBuffer = void;
+        int bufferLength;
+        auto symbol = getDemangledSymbol(frameList[i][0 .. strlen(frameList[i])], symbolBuffer);
+        if (symbol.length > 0)
+            bufferLength = snprintf(buffer.ptr, buffer.length, "%s%.*s [0x%x]", addressBuffer.ptr, cast(int) symbol.length, symbol.ptr, callstack[i]);
+        else
+            bufferLength = snprintf(buffer.ptr, buffer.length, "%s[0x%x]", addressBuffer.ptr, callstack[i]);
+
+        assert(bufferLength >= 0);
+
+        auto output = buffer[0 .. bufferLength];
+        auto pos = i;
+        ret = dg(pos, output);
+        if (ret) break;
+    }
+    return ret;
+}
+
+private:
+
+// the lifetime of the Location data is the lifetime of the mmapped ElfSection
+void resolveAddresses(ElfSection* debugLineSection, Location[] locations) @nogc nothrow
+{
+    debug(DwarfDebugMachine) import core.stdc.stdio;
+
+    size_t numberOfLocationsFound = 0;
+
+    const(ubyte)[] dbg = debugLineSection.get();
+    while (dbg.length > 0)
+    {
+        debug(DwarfDebugMachine) printf("new debug program\n");
+        const(LPHeader)* lph = cast(const(LPHeader)*) dbg.ptr;
+
+        if (lph.unitLength == 0xffff_ffff) // is 64-bit dwarf?
+            return; // unable to read 64-bit dwarf
+
+        const(ubyte)[] program = dbg[
+            lph.headerLength + LPHeader.minimumInstructionLength.offsetof ..
+            lph.unitLength + LPHeader.dwarfVersion.offsetof
+        ];
+
+        const(ubyte)[] standardOpcodeLengths = dbg[
+            LPHeader.sizeof .. LPHeader.sizeof + lph.opcodeBase - 1
+        ];
+
+        const(ubyte)[] pathData = dbg[
+            LPHeader.sizeof + lph.opcodeBase - 1 .. $
+        ];
+
+        Array!(const(char)[]) directories;
+        directories.length = (const(ubyte)[] bytes) {
+            // count number of directories
+            int count = 0;
+            foreach (i; 0 .. bytes.length - 1)
+            {
+                if (bytes[i] == 0)
+                {
+                    count++;
+                    if (bytes[i + 1] == 0) return count;
+                }
+            }
+            return count;
+        }(pathData);
+
+        // fill directories array from dwarf section
+        int currentDirectoryIndex = 0;
+        while (pathData[0] != 0)
+        {
+            directories[currentDirectoryIndex] = cast(const(char)[]) pathData[0 .. strlen(cast(char*) (pathData.ptr))];
+            debug(DwarfDebugMachine) printf("dir: %s\n", pathData.ptr);
+            pathData = pathData[directories[currentDirectoryIndex].length + 1 .. $];
+            currentDirectoryIndex++;
+        }
+
+        pathData = pathData[1 .. $];
+
+        Array!(const(char)[]) filenames;
+        filenames.length = (const(ubyte)[] bytes)
+        {
+            // count number of files
+            int count = 0;
+            while (bytes[0] != 0)
+            {
+                auto filename = cast(const(char)[]) bytes[0 .. strlen(cast(char*) (bytes.ptr))];
+                bytes = bytes[filename.length + 1 .. $];
+                bytes.readULEB128(); // dir index
+                bytes.readULEB128(); // last mod
+                bytes.readULEB128(); // file len
+                count++;
+            }
+            return count;
+        }(pathData);
+
+        // fill filenames array from dwarf section
+        int currentFileIndex = 0;
+        while (pathData[0] != 0)
+        {
+            filenames[currentFileIndex] = cast(const(char)[]) pathData[0 .. strlen(cast(char*) (pathData.ptr))];
+            debug(DwarfDebugMachine) printf("file: %s\n", pathData.ptr);
+            pathData = pathData[filenames[currentFileIndex].length + 1 .. $];
+
+            auto dirIndex = pathData.readULEB128(); // unused
+            auto lastMod = pathData.readULEB128();  // unused
+            auto fileLen = pathData.readULEB128();  // unused
+
+            currentFileIndex++;
+        }
+
+        LocationInfo lastLoc = LocationInfo(-1, -1);
+        size_t lastAddress = 0x0;
+
+        debug(DwarfDebugMachine) printf("program:\n");
+        runStateMachine(lph, program, standardOpcodeLengths,
+            (size_t address, LocationInfo locInfo, bool isEndSequence)
+            {
+                // If loc.line != -1, then it has been set previously.
+                // Some implementations (eg. dmd) write an address to
+                // the debug data multiple times, but so far I have found
+                // that the first occurrence to be the correct one.
+                foreach (ref loc; locations) if (loc.line == -1)
+                {
+                    if (loc.address == address)
+                    {
+                        debug(DwarfDebugMachine) printf("-- found for [0x%x]:\n", loc.address);
+                        debug(DwarfDebugMachine) printf("--   file: %.*s\n", filenames[locInfo.file - 1].length, filenames[locInfo.file - 1].ptr);
+                        debug(DwarfDebugMachine) printf("--   line: %d\n", locInfo.line);
+                        loc.file = filenames[locInfo.file - 1];
+                        loc.line = locInfo.line;
+                        numberOfLocationsFound++;
+                    }
+                    else if (loc.address < address && lastAddress < loc.address && lastAddress != 0)
+                    {
+                        debug(DwarfDebugMachine) printf("-- found for [0x%x]:\n", loc.address);
+                        debug(DwarfDebugMachine) printf("--   file: %.*s\n", filenames[lastLoc.file - 1].length, filenames[lastLoc.file - 1].ptr);
+                        debug(DwarfDebugMachine) printf("--   line: %d\n", lastLoc.line);
+                        loc.file = filenames[lastLoc.file - 1];
+                        loc.line = lastLoc.line;
+                        numberOfLocationsFound++;
+                    }
+                }
+
+                if (isEndSequence)
+                {
+                    lastAddress = 0;
+                }
+                else
+                {
+                    lastAddress = address;
+                    lastLoc = locInfo;
+                }
+
+                return numberOfLocationsFound < locations.length;
+            }
+        );
+
+        if (numberOfLocationsFound == locations.length) return;
+        dbg = dbg[lph.unitLength + LPHeader.dwarfVersion.offsetof .. $];
+    }
+}
+
+alias RunStateMachineCallback = bool delegate(size_t, LocationInfo, bool) @nogc nothrow;
+bool runStateMachine(const(LPHeader)* lpHeader, const(ubyte)[] program, const(ubyte)[] standardOpcodeLengths, scope RunStateMachineCallback callback) @nogc nothrow
+{
+    debug(DwarfDebugMachine) import core.stdc.stdio;
+
+    StateMachine machine;
+    machine.isStatement = lpHeader.defaultIsStatement;
+
+    while (program.length > 0)
+    {
+        ubyte opcode = program.read!ubyte();
+        if (opcode < lpHeader.opcodeBase)
+        {
+            switch (opcode) with (StandardOpcode)
+            {
+                case extendedOp:
+                    size_t len = cast(size_t) program.readULEB128();
+                    ubyte eopcode = program.read!ubyte();
+
+                    switch (eopcode) with (ExtendedOpcode)
+                    {
+                        case endSequence:
+                            machine.isEndSequence = true;
+                            debug(DwarfDebugMachine) printf("endSequence 0x%x\n", machine.address);
+                            if (!callback(machine.address, LocationInfo(machine.fileIndex, machine.line), true)) return true;
+                            machine = StateMachine.init;
+                            machine.isStatement = lpHeader.defaultIsStatement;
+                            break;
+
+                        case setAddress:
+                            size_t address = program.read!size_t();
+                            debug(DwarfDebugMachine) printf("setAddress 0x%x\n", address);
+                            machine.address = address;
+                            break;
+
+                        case defineFile: // TODO: add proper implementation
+                            debug(DwarfDebugMachine) printf("defineFile\n");
+                            program = program[len - 1 .. $];
+                            break;
+
+                        default:
+                            // unknown opcode
+                            debug(DwarfDebugMachine) printf("unknown extended opcode %d\n", cast(int) eopcode);
+                            program = program[len - 1 .. $];
+                            break;
+                    }
+
+                    break;
+
+                case copy:
+                    debug(DwarfDebugMachine) printf("copy 0x%x\n", machine.address);
+                    if (!callback(machine.address, LocationInfo(machine.fileIndex, machine.line), false)) return true;
+                    machine.isBasicBlock = false;
+                    machine.isPrologueEnd = false;
+                    machine.isEpilogueBegin = false;
+                    break;
+
+                case advancePC:
+                    ulong op = readULEB128(program);
+                    machine.address += op * lpHeader.minimumInstructionLength;
+                    debug(DwarfDebugMachine) printf("advancePC %d to 0x%x\n", cast(int) (op * lpHeader.minimumInstructionLength), machine.address);
+                    break;
+
+                case advanceLine:
+                    long ad = readSLEB128(program);
+                    machine.line += ad;
+                    debug(DwarfDebugMachine) printf("advanceLine %d to %d\n", cast(int) ad, cast(int) machine.line);
+                    break;
+
+                case setFile:
+                    uint index = cast(uint) readULEB128(program);
+                    debug(DwarfDebugMachine) printf("setFile to %d\n", cast(int) index);
+                    machine.fileIndex = index;
+                    break;
+
+                case setColumn:
+                    uint col = cast(uint) readULEB128(program);
+                    debug(DwarfDebugMachine) printf("setColumn %d\n", cast(int) col);
+                    machine.column = col;
+                    break;
+
+                case negateStatement:
+                    debug(DwarfDebugMachine) printf("negateStatement\n");
+                    machine.isStatement = !machine.isStatement;
+                    break;
+
+                case setBasicBlock:
+                    debug(DwarfDebugMachine) printf("setBasicBlock\n");
+                    machine.isBasicBlock = true;
+                    break;
+
+                case constAddPC:
+                    machine.address += (255 - lpHeader.opcodeBase) / lpHeader.lineRange * lpHeader.minimumInstructionLength;
+                    debug(DwarfDebugMachine) printf("constAddPC 0x%x\n", machine.address);
+                    break;
+
+                case fixedAdvancePC:
+                    uint add = program.read!uint();
+                    machine.address += add;
+                    debug(DwarfDebugMachine) printf("fixedAdvancePC %d to 0x%x\n", cast(int) add, machine.address);
+                    break;
+
+                case setPrologueEnd:
+                    machine.isPrologueEnd = true;
+                    debug(DwarfDebugMachine) printf("setPrologueEnd\n");
+                    break;
+
+                case setEpilogueBegin:
+                    machine.isEpilogueBegin = true;
+                    debug(DwarfDebugMachine) printf("setEpilogueBegin\n");
+                    break;
+
+                case setISA:
+                    machine.isa = cast(uint) readULEB128(program);
+                    debug(DwarfDebugMachine) printf("setISA %d\n", cast(int) machine.isa);
+                    break;
+
+                default:
+                    // unimplemented/invalid opcode
+                    return false;
+            }
+        }
+        else
+        {
+            opcode -= lpHeader.opcodeBase;
+            auto ainc = (opcode / lpHeader.lineRange) * lpHeader.minimumInstructionLength;
+            machine.address += ainc;
+            auto linc = lpHeader.lineBase + (opcode % lpHeader.lineRange);
+            machine.line += linc;
+
+            debug(DwarfDebugMachine) printf("special %d %d to 0x%x line %d\n", cast(int) ainc, cast(int) linc, machine.address, cast(int) machine.line);
+            if (!callback(machine.address, LocationInfo(machine.fileIndex, machine.line), false)) return true;
+        }
+    }
+
+    return true;
+}
+
+const(char)[] getDemangledSymbol(const(char)[] btSymbol, ref char[1024] buffer)
+{
+    version(linux)
+    {
+        // format is:  module(_D6module4funcAFZv) [0x00000000]
+        // or:         module(_D6module4funcAFZv+0x78) [0x00000000]
+        auto bptr = cast(char*) memchr(btSymbol.ptr, '(', btSymbol.length);
+        auto eptr = cast(char*) memchr(btSymbol.ptr, ')', btSymbol.length);
+        auto pptr = cast(char*) memchr(btSymbol.ptr, '+', btSymbol.length);
+    }
+    else version(FreeBSD)
+    {
+        // format is: 0x00000000 <_D6module4funcAFZv+0x78> at module
+        auto bptr = cast(char*) memchr(btSymbol.ptr, '<', btSymbol.length);
+        auto eptr = cast(char*) memchr(btSymbol.ptr, '>', btSymbol.length);
+        auto pptr = cast(char*) memchr(btSymbol.ptr, '+', btSymbol.length);
+    }
+
+    if (pptr && pptr < eptr)
+        eptr = pptr;
+
+    size_t symBeg, symEnd;
+    if (bptr++ && eptr)
+    {
+        symBeg = bptr - btSymbol.ptr;
+        symEnd = eptr - btSymbol.ptr;
+    }
+
+    assert(symBeg <= symEnd);
+    assert(symEnd < btSymbol.length);
+
+    import core.demangle;
+    return demangle(btSymbol[symBeg .. symEnd], buffer[]);
+}
+
+T read(T)(ref const(ubyte)[] buffer) @nogc nothrow
+{
+    T result = *(cast(T*) buffer[0 .. T.sizeof].ptr);
+    buffer = buffer[T.sizeof .. $];
+    return result;
+}
+
+ulong readULEB128(ref const(ubyte)[] buffer) @nogc nothrow
+{
+    ulong val = 0;
+    uint shift = 0;
+
+    while (true)
+    {
+        ubyte b = buffer.read!ubyte();
+
+        val |= (b & 0x7f) << shift;
+        if ((b & 0x80) == 0) break;
+        shift += 7;
+    }
+
+    return val;
+}
+
+unittest
+{
+    const(ubyte)[] data = [0xe5, 0x8e, 0x26, 0xDE, 0xAD, 0xBE, 0xEF];
+    assert(readULEB128(data) == 624_485);
+    assert(data[] == [0xDE, 0xAD, 0xBE, 0xEF]);
+}
+
+long readSLEB128(ref const(ubyte)[] buffer) @nogc nothrow
+{
+    long val = 0;
+    uint shift = 0;
+    int size = 8 << 3;
+    ubyte b;
+
+    while (true)
+    {
+        b = buffer.read!ubyte();
+        val |= (b & 0x7f) << shift;
+        shift += 7;
+        if ((b & 0x80) == 0)
+            break;
+    }
+
+    if (shift < size && (b & 0x40) != 0)
+        val |= -(1 << shift);
+
+    return val;
+}
+
+enum StandardOpcode : ubyte
+{
+    extendedOp = 0,
+    copy = 1,
+    advancePC = 2,
+    advanceLine = 3,
+    setFile = 4,
+    setColumn = 5,
+    negateStatement = 6,
+    setBasicBlock = 7,
+    constAddPC = 8,
+    fixedAdvancePC = 9,
+    setPrologueEnd = 10,
+    setEpilogueBegin = 11,
+    setISA = 12,
+}
+
+enum ExtendedOpcode : ubyte
+{
+    endSequence = 1,
+    setAddress = 2,
+    defineFile = 3,
+}
+
+struct StateMachine
+{
+    size_t address = 0;
+    uint operationIndex = 0;
+    uint fileIndex = 1;
+    uint line = 1;
+    uint column = 0;
+    bool isStatement;
+    bool isBasicBlock = false;
+    bool isEndSequence = false;
+    bool isPrologueEnd = false;
+    bool isEpilogueBegin = false;
+    uint isa = 0;
+    uint discriminator = 0;
+}
+
+struct LocationInfo
+{
+    int file;
+    int line;
+}
+
+// 32-bit DWARF
+align(1)
+struct LPHeader
+{
+align(1):
+    uint unitLength;
+    ushort dwarfVersion;
+    uint headerLength;
+    ubyte minimumInstructionLength;
+    bool defaultIsStatement;
+    byte lineBase;
+    ubyte lineRange;
+    ubyte opcodeBase;
+}
diff --git a/libphobos/libdruntime/rt/backtrace/elf.d b/libphobos/libdruntime/rt/backtrace/elf.d
new file mode 100644
index 00000000000..2c75eb8c1b9
--- /dev/null
+++ b/libphobos/libdruntime/rt/backtrace/elf.d
@@ -0,0 +1,234 @@
+/**
+ * This code reads ELF files and sections using memory mapped IO.
+ *
+ * Reference: http://www.dwarfstd.org/
+ *
+ * Copyright: Copyright Digital Mars 2015 - 2015.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Yazan Dabain
+ * Source: $(DRUNTIMESRC src/rt/backtrace/elf.d)
+ */
+
+module rt.backtrace.elf;
+
+version(linux) version = linux_or_freebsd;
+else version(FreeBSD) version = linux_or_freebsd;
+
+version(linux_or_freebsd):
+
+import core.sys.posix.fcntl;
+import core.sys.posix.unistd;
+
+version(linux) public import core.sys.linux.elf;
+version(FreeBSD) public import core.sys.freebsd.sys.elf;
+
+struct ElfFile
+{
+    static bool openSelf(ElfFile* file) @nogc nothrow
+    {
+        version (linux)
+        {
+            auto selfPath = "/proc/self/exe".ptr;
+        }
+        else version (FreeBSD)
+        {
+            char[1024] selfPathBuffer = void;
+            auto selfPath = getFreeBSDExePath(selfPathBuffer[]);
+            if (selfPath is null) return false;
+        }
+
+        file.fd = open(selfPath, O_RDONLY);
+        if (file.fd >= 0)
+        {
+            // memory map header
+            file.ehdr = MMapRegion!Elf_Ehdr(file.fd, 0, Elf_Ehdr.sizeof);
+            if (file.ehdr.isValidElfHeader())
+                return true;
+            else
+                return false;
+        }
+        else
+            return false;
+    }
+
+    @disable this(this);
+
+    ~this() @nogc nothrow
+    {
+        if (fd != -1) close(fd);
+    }
+
+    int fd = -1;
+    MMapRegion!Elf_Ehdr ehdr;
+}
+
+struct ElfSectionHeader
+{
+    this(const(ElfFile)* file, size_t index) @nogc nothrow
+    {
+        assert(Elf_Shdr.sizeof == file.ehdr.e_shentsize);
+        shdr = MMapRegion!Elf_Shdr(
+            file.fd,
+            file.ehdr.e_shoff + index * file.ehdr.e_shentsize,
+            file.ehdr.e_shentsize
+        );
+    }
+
+    @disable this(this);
+
+    alias shdr this;
+    MMapRegion!Elf_Shdr shdr;
+}
+
+struct ElfSection
+{
+    this(ElfFile* file, ElfSectionHeader* shdr) @nogc nothrow
+    {
+        data = MMapRegion!ubyte(
+            file.fd,
+            shdr.sh_offset,
+            shdr.sh_size,
+        );
+
+        length = shdr.sh_size;
+    }
+
+    @disable this(this);
+
+    const(ubyte)[] get() @nogc nothrow
+    {
+        return data.get()[0 .. length];
+    }
+
+    alias get this;
+
+    MMapRegion!ubyte data;
+    size_t length;
+}
+
+const(char)[] getSectionName(const(ElfFile)* file, ElfSection* stringSection, size_t nameIndex) @nogc nothrow
+{
+    const(ubyte)[] data = stringSection.get();
+
+    foreach (i; nameIndex .. data.length)
+    {
+        if (data[i] == 0)
+            return cast(const(char)[])data[nameIndex .. i];
+    }
+
+    return null;
+}
+
+size_t findSectionByName(const(ElfFile)* file, ElfSection* stringSection, const(char)[] sectionName) @nogc nothrow
+{
+    foreach (s; 0 .. file.ehdr.e_shnum)
+    {
+        auto sectionHeader = ElfSectionHeader(file, s);
+        auto currentName = getSectionName(file, stringSection, sectionHeader.sh_name);
+        if (sectionName == currentName)
+            return s; // TODO: attempt to move ElfSectionHeader instead of returning index
+    }
+
+    // not found
+    return -1;
+}
+
+private:
+
+version (FreeBSD)
+{
+    extern (C) int sysctl(const int* name, uint namelen, void* oldp, size_t* oldlenp, const void* newp, size_t newlen) @nogc nothrow;
+    const(char)* getFreeBSDExePath(char[] buffer) @nogc nothrow
+    {
+        enum
+        {
+            CTL_KERN = 1,
+            KERN_PROC = 14,
+            KERN_PROC_PATHNAME = 12
+        }
+
+        int[4] mib = [CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1];
+        size_t len = buffer.length;
+
+        auto result = sysctl(mib.ptr, mib.length, buffer.ptr, &len, null, 0); // get the length of the path
+        if (result != 0) return null;
+        if (len + 1 > buffer.length) return null;
+        buffer[len] = 0;
+        return buffer.ptr;
+    }
+}
+
+bool isValidElfHeader(const(Elf_Ehdr)* ehdr) @nogc nothrow
+{
+    if (ehdr.e_ident[EI_MAG0] != ELFMAG0) return false;
+    if (ehdr.e_ident[EI_MAG1] != ELFMAG1) return false;
+    if (ehdr.e_ident[EI_MAG2] != ELFMAG2) return false;
+    if (ehdr.e_ident[EI_MAG3] != ELFMAG3) return false;
+
+    // elf class and data encoding should match target's config
+    if (ehdr.e_ident[EI_CLASS] != ELFCLASS) return false;
+    if (ehdr.e_ident[EI_DATA]  != ELFDATA ) return false;
+
+    return true;
+}
+
+struct MMapRegion(T)
+{
+    import core.sys.posix.sys.mman;
+    import core.sys.posix.unistd;
+
+    this(int fd, size_t offset, size_t length) @nogc nothrow
+    {
+        auto pagesize = sysconf(_SC_PAGESIZE);
+
+        auto realOffset = (offset / pagesize) * pagesize;
+        offsetDiff = offset - realOffset;
+        realLength = length + offsetDiff;
+
+        mptr = mmap(null, realLength, PROT_READ, MAP_PRIVATE, fd, realOffset);
+    }
+
+    @disable this(this);
+
+    ~this() @nogc nothrow
+    {
+        if (mptr) munmap(mptr, realLength);
+    }
+
+    const(T)* get() const @nogc nothrow
+    {
+        return cast(T*)(mptr + offsetDiff);
+    }
+
+    alias get this;
+
+    size_t realLength;
+    size_t offsetDiff;
+    void* mptr;
+}
+
+version(D_LP64)
+{
+    alias Elf_Ehdr = Elf64_Ehdr;
+    alias Elf_Shdr = Elf64_Shdr;
+    enum ELFCLASS = ELFCLASS64;
+}
+else
+{
+    alias Elf_Ehdr = Elf32_Ehdr;
+    alias Elf_Shdr = Elf32_Shdr;
+    enum ELFCLASS = ELFCLASS32;
+}
+
+version(LittleEndian)
+{
+    alias ELFDATA = ELFDATA2LSB;
+}
+else version(BigEndian)
+{
+    alias ELFDATA = ELFDATA2MSB;
+}
+else
+{
+    static assert(0, "unsupported byte order");
+}
diff --git a/libphobos/libdruntime/rt/bss_section.c b/libphobos/libdruntime/rt/bss_section.c
new file mode 100644
index 00000000000..939ecb27905
--- /dev/null
+++ b/libphobos/libdruntime/rt/bss_section.c
@@ -0,0 +1,21 @@
+/**
+ * This module is used to detect copy relocated ModuleInfos (located in .bss section).
+ *
+ * Copyright: Copyright Martin Nowak 2014-.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ * Source: $(DRUNTIMESRC src/rt/_bss_section.c)
+ */
+
+/* These symbols are defined in the linker script and bracket the
+ * .bss, .lbss, .lrodata and .ldata sections.
+ */
+#if defined(__linux__) || defined(__FreeBSD__)
+// Need to use weak linkage to workaround a bug in ld.bfd (Bugzilla 13025).
+extern int __attribute__((weak)) __bss_start, _end;
+
+__attribute__ ((visibility ("hidden"))) void* rt_get_bss_start();
+__attribute__ ((visibility ("hidden"))) void* rt_get_end();
+void* rt_get_bss_start() { return (void*)&__bss_start; }
+void* rt_get_end() { return (void*)&_end; }
+#endif
diff --git a/libphobos/libdruntime/rt/cast_.d b/libphobos/libdruntime/rt/cast_.d
new file mode 100644
index 00000000000..158c0453298
--- /dev/null
+++ b/libphobos/libdruntime/rt/cast_.d
@@ -0,0 +1,141 @@
+/**
+ * Implementation of array assignment support routines.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Sean Kelly
+ */
+
+/*          Copyright Digital Mars 2004 - 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.cast_;
+
+extern (C):
+
+/******************************************
+ * Given a pointer:
+ *      If it is an Object, return that Object.
+ *      If it is an interface, return the Object implementing the interface.
+ *      If it is null, return null.
+ *      Else, undefined crash
+ */
+Object _d_toObject(void* p)
+{
+    if (!p)
+        return null;
+
+    Object o = cast(Object) p;
+    ClassInfo oc = typeid(o);
+    Interface* pi = **cast(Interface***) p;
+
+    /* Interface.offset lines up with ClassInfo.name.ptr,
+     * so we rely on pointers never being less than 64K,
+     * and Objects never being greater.
+     */
+    if (pi.offset < 0x10000)
+    {
+        debug(cast_) printf("\tpi.offset = %d\n", pi.offset);
+        return cast(Object)(p - pi.offset);
+    }
+    return o;
+}
+
+/*************************************
+ * Attempts to cast Object o to class c.
+ * Returns o if successful, null if not.
+ */
+void* _d_interface_cast(void* p, ClassInfo c)
+{
+    debug(cast_) printf("_d_interface_cast(p = %p, c = '%.*s')\n", p, c.name);
+    if (!p)
+        return null;
+
+    Interface* pi = **cast(Interface***) p;
+
+    debug(cast_) printf("\tpi.offset = %d\n", pi.offset);
+    return _d_dynamic_cast(cast(Object)(p - pi.offset), c);
+}
+
+void* _d_dynamic_cast(Object o, ClassInfo c)
+{
+    debug(cast_) printf("_d_dynamic_cast(o = %p, c = '%.*s')\n", o, c.name);
+
+    void* res = null;
+    size_t offset = 0;
+    if (o && _d_isbaseof2(typeid(o), c, offset))
+    {
+        debug(cast_) printf("\toffset = %d\n", offset);
+        res = cast(void*) o + offset;
+    }
+    debug(cast_) printf("\tresult = %p\n", res);
+    return res;
+}
+
+int _d_isbaseof2(ClassInfo oc, ClassInfo c, ref size_t offset)
+{
+    if (oc is c)
+        return true;
+
+    do
+    {
+        if (oc.base is c)
+            return true;
+
+        // Bugzilla 2013: Use depth-first search to calculate offset
+        // from the derived (oc) to the base (c).
+        foreach (iface; oc.interfaces)
+        {
+            if (iface.classinfo is c || _d_isbaseof2(iface.classinfo, c, offset))
+            {
+                offset += iface.offset;
+                return true;
+            }
+        }
+
+        oc = oc.base;
+    } while(oc);
+
+    return false;
+}
+
+int _d_isbaseof(ClassInfo oc, ClassInfo c)
+{
+    if (oc is c)
+        return true;
+
+    do
+    {
+        if (oc.base is c)
+            return true;
+
+        foreach (iface; oc.interfaces)
+        {
+            if (iface.classinfo is c || _d_isbaseof(iface.classinfo, c))
+                return true;
+        }
+
+        oc = oc.base;
+    } while(oc);
+
+    return false;
+}
+
+/*********************************
+ * Find the vtbl[] associated with Interface ic.
+ */
+void* _d_interface_vtbl(ClassInfo ic, Object o)
+{
+    debug(cast_) printf("__d_interface_vtbl(o = %p, ic = %p)\n", o, ic);
+
+    assert(o);
+
+    foreach (iface; typeid(o).interfaces)
+    {
+        if (iface.classinfo is ic)
+            return cast(void*) iface.vtbl;
+    }
+    assert(0);
+}
diff --git a/libphobos/libdruntime/rt/config.d b/libphobos/libdruntime/rt/config.d
new file mode 100644
index 00000000000..acffb5708ad
--- /dev/null
+++ b/libphobos/libdruntime/rt/config.d
@@ -0,0 +1,147 @@
+/**
+* Configuration options for druntime
+*
+* Copyright: Copyright Digital Mars 2014.
+* License: Distributed under the
+*      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+*    (See accompanying file LICENSE)
+* Authors:   Rainer Schuetze
+* Source: $(DRUNTIMESRC src/rt/_config.d)
+*/
+
+module rt.config;
+
+// The default way to configure the runtime is by passing command line arguments
+// starting with "--DRT-" and followed by the option name, e.g. "--DRT-gcopt" to
+// configure the GC.
+// Command line options starting with "--DRT-" are filtered out before calling main,
+// so the program will not see them. They are still available via rt_args().
+//
+// Configuration via the command line can be disabled by declaring a variable for the
+// linker to pick up before using it's default from the runtime:
+//
+//   extern(C) __gshared bool rt_cmdline_enabled = false;
+//
+// Likewise, declare a boolean rt_envvars_enabled to enable configuration via the
+// environment variable "DRT_" followed by the option name, e.g. "DRT_GCOPT":
+//
+//   extern(C) __gshared bool rt_envvars_enabled = true;
+//
+// Setting default configuration properties in the executable can be done by specifying an
+// array of options named rt_options:
+//
+//   extern(C) __gshared string[] rt_options = [ "gcopt=precise:1 profile:1"];
+//
+// Evaluation order of options is rt_options, then environment variables, then command
+// line arguments, i.e. if command line arguments are not disabled, they can override
+// options specified through the environment or embedded in the executable.
+
+import core.demangle : cPrefix;
+
+// put each variable in its own COMDAT by making them template instances
+template rt_envvars_enabled()
+{
+    pragma(mangle, cPrefix ~ "rt_envvars_enabled") __gshared bool rt_envvars_enabled = false;
+}
+template rt_cmdline_enabled()
+{
+    pragma(mangle, cPrefix ~ "rt_cmdline_enabled") __gshared bool rt_cmdline_enabled = true;
+}
+template rt_options()
+{
+    pragma(mangle, cPrefix ~ "rt_options") __gshared string[] rt_options = [];
+}
+
+import core.stdc.ctype : toupper;
+import core.stdc.stdlib : getenv;
+import core.stdc.string : strlen;
+
+extern extern(C) string[] rt_args() @nogc nothrow;
+
+alias rt_configCallBack = string delegate(string) @nogc nothrow;
+
+/**
+* get a druntime config option using standard configuration options
+*      opt             name of the option to retreive
+*      dg              if non-null, passes the option through this
+*                      delegate and only returns its return value if non-null
+*      reverse         reverse the default processing order cmdline/envvar/rt_options
+*                      to allow overwriting settings in the delegate with values
+*                      from higher priority
+*
+* returns the options' value if
+*  - set on the command line as "--DRT-<opt>=value" (rt_cmdline_enabled enabled)
+*  - the environment variable "DRT_<OPT>" is set (rt_envvars_enabled enabled)
+*  - rt_options[] contains an entry "<opt>=value"
+*  - null otherwise
+*/
+string rt_configOption(string opt, scope rt_configCallBack dg = null, bool reverse = false) @nogc nothrow
+{
+    if (!dg)
+        dg = (string s) => s;
+
+    string s = (reverse ? rt_linkOption(opt, dg) : rt_cmdlineOption(opt, dg));
+    if (s != null)
+        return s;
+    s = rt_envvarsOption(opt, dg);
+    if (s != null)
+        return s;
+    s = (reverse ? rt_cmdlineOption(opt, dg) : rt_linkOption(opt, dg));
+    return s;
+}
+
+string rt_cmdlineOption(string opt, scope rt_configCallBack dg) @nogc nothrow
+{
+    if(rt_cmdline_enabled!())
+    {
+        foreach (a; rt_args)
+        {
+            if (a.length >= opt.length + 7 && a[0..6] == "--DRT-" &&
+                a[6 .. 6 + opt.length] == opt && a[6 + opt.length] == '=')
+            {
+                string s = dg(a[7 + opt.length .. $]);
+                if (s != null)
+                    return s;
+            }
+        }
+    }
+    return null;
+}
+
+string rt_envvarsOption(string opt, scope rt_configCallBack dg) @nogc nothrow
+{
+    if(rt_envvars_enabled!())
+    {
+        if (opt.length >= 32)
+            assert(0);
+
+        char[40] var;
+        var[0 .. 4] = "DRT_";
+        foreach (i, c; opt)
+            var[4 + i] = cast(char) toupper(c);
+        var[4 + opt.length] = 0;
+
+        auto p = getenv(var.ptr);
+        if (p)
+        {
+            string s = dg(cast(string) p[0 .. strlen(p)]);
+            if (s != null)
+                return s;
+        }
+    }
+    return null;
+}
+
+string rt_linkOption(string opt, scope rt_configCallBack dg) @nogc nothrow
+{
+    foreach (a; rt_options!())
+    {
+        if(a.length > opt.length && a[0..opt.length] == opt && a[opt.length] == '=')
+        {
+            string s = dg(a[opt.length + 1 .. $]);
+            if (s != null)
+                return s;
+        }
+    }
+    return null;
+}
diff --git a/libphobos/libdruntime/rt/critical_.d b/libphobos/libdruntime/rt/critical_.d
new file mode 100644
index 00000000000..c2ef8220901
--- /dev/null
+++ b/libphobos/libdruntime/rt/critical_.d
@@ -0,0 +1,68 @@
+/**
+ * Implementation of support routines for synchronized blocks.
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2011.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Sean Kelly
+ */
+
+/*          Copyright Digital Mars 2000 - 2011.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.critical_;
+
+nothrow:
+
+import rt.monitor_, core.atomic;
+
+extern (C) void _d_critical_init()
+{
+    initMutex(cast(Mutex*)&gcs.mtx);
+    head = &gcs;
+}
+
+extern (C) void _d_critical_term()
+{
+    for (auto p = head; p; p = p.next)
+        destroyMutex(cast(Mutex*)&p.mtx);
+}
+
+extern (C) void _d_criticalenter(D_CRITICAL_SECTION* cs)
+{
+    ensureMutex(cast(shared(D_CRITICAL_SECTION*)) cs);
+    lockMutex(&cs.mtx);
+}
+
+extern (C) void _d_criticalexit(D_CRITICAL_SECTION* cs)
+{
+    unlockMutex(&cs.mtx);
+}
+
+private:
+
+shared D_CRITICAL_SECTION* head;
+shared D_CRITICAL_SECTION gcs;
+
+struct D_CRITICAL_SECTION
+{
+    D_CRITICAL_SECTION* next;
+    Mutex mtx;
+}
+
+void ensureMutex(shared(D_CRITICAL_SECTION)* cs)
+{
+    if (atomicLoad!(MemoryOrder.acq)(cs.next) is null)
+    {
+        lockMutex(cast(Mutex*)&gcs.mtx);
+        if (atomicLoad!(MemoryOrder.raw)(cs.next) is null)
+        {
+            initMutex(cast(Mutex*)&cs.mtx);
+            auto ohead = head;
+            head = cs;
+            atomicStore!(MemoryOrder.rel)(cs.next, ohead);
+        }
+        unlockMutex(cast(Mutex*)&gcs.mtx);
+    }
+}
diff --git a/libphobos/libdruntime/rt/deh.d b/libphobos/libdruntime/rt/deh.d
new file mode 100644
index 00000000000..440e242c120
--- /dev/null
+++ b/libphobos/libdruntime/rt/deh.d
@@ -0,0 +1,42 @@
+/**
+ * Implementation of exception handling support routines.
+ *
+ * Copyright: Copyright Digital Mars 1999 - 2013.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Walter Bright
+ * Source: $(DRUNTIMESRC src/rt/deh.d)
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module rt.deh;
+
+extern (C)
+{
+    Throwable.TraceInfo _d_traceContext(void* ptr = null);
+    void _d_createTrace(Object o, void* context)
+    {
+        auto t = cast(Throwable) o;
+
+        if (t !is null && t.info is null &&
+            cast(byte*) t !is typeid(t).initializer.ptr)
+        {
+            t.info = _d_traceContext(context);
+        }
+    }
+}
+
+version (GNU)
+    public import gcc.deh;
+else version (Win32)
+    public import rt.deh_win32;
+else version (Win64)
+    public import rt.deh_win64_posix;
+else version (Posix)
+    public import rt.deh_win64_posix;
+else
+    static assert (0, "Unsupported architecture");
+
diff --git a/libphobos/libdruntime/rt/dmain2.d b/libphobos/libdruntime/rt/dmain2.d
new file mode 100644
index 00000000000..71688751289
--- /dev/null
+++ b/libphobos/libdruntime/rt/dmain2.d
@@ -0,0 +1,592 @@
+/**
+ * Contains druntime startup and shutdown routines.
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2013.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Walter Bright, Sean Kelly
+ * Source: $(DRUNTIMESRC src/rt/_dmain2.d)
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module rt.dmain2;
+
+private
+{
+    import rt.memory;
+    import rt.sections;
+    import core.atomic;
+    import core.stdc.stddef;
+    import core.stdc.stdlib;
+    import core.stdc.string;
+    import core.stdc.stdio;   // for printf()
+    import core.stdc.errno : errno;
+}
+
+version (Windows)
+{
+    private import core.stdc.wchar_;
+    private import core.sys.windows.windows;
+
+    version (GNU) {}
+    else pragma(lib, "shell32.lib"); // needed for CommandLineToArgvW
+}
+
+version (FreeBSD)
+{
+    import core.stdc.fenv;
+}
+
+extern (C) void _d_monitor_staticctor();
+extern (C) void _d_monitor_staticdtor();
+extern (C) void _d_critical_init();
+extern (C) void _d_critical_term();
+extern (C) void gc_init();
+extern (C) void gc_term();
+extern (C) void lifetime_init();
+extern (C) void rt_moduleCtor();
+extern (C) void rt_moduleTlsCtor();
+extern (C) void rt_moduleDtor();
+extern (C) void rt_moduleTlsDtor();
+extern (C) void thread_joinAll();
+extern (C) bool runModuleUnitTests();
+extern (C) void _d_initMonoTime();
+
+version (OSX)
+{
+    // The bottom of the stack
+    extern (C) __gshared void* __osx_stack_end = cast(void*)0xC0000000;
+}
+
+version(CRuntime_Microsoft)
+{
+    extern(C) void init_msvc();
+}
+
+/***********************************
+ * These are a temporary means of providing a GC hook for DLL use.  They may be
+ * replaced with some other similar functionality later.
+ */
+extern (C)
+{
+    void* gc_getProxy();
+    void  gc_setProxy(void* p);
+    void  gc_clrProxy();
+
+    alias void* function()      gcGetFn;
+    alias void  function(void*) gcSetFn;
+    alias void  function()      gcClrFn;
+}
+
+version (Windows)
+{
+    /*******************************************
+     * Loads a DLL written in D with the name 'name'.
+     * Returns:
+     *      opaque handle to the DLL if successfully loaded
+     *      null if failure
+     */
+    extern (C) void* rt_loadLibrary(const char* name)
+    {
+        return initLibrary(.LoadLibraryA(name));
+    }
+
+    extern (C) void* rt_loadLibraryW(const wchar_t* name)
+    {
+        return initLibrary(.LoadLibraryW(name));
+    }
+
+    void* initLibrary(void* mod)
+    {
+        // BUG: LoadLibrary() call calls rt_init(), which fails if proxy is not set!
+        // (What? LoadLibrary() is a Windows API call, it shouldn't call rt_init().)
+        if (mod is null)
+            return mod;
+        gcSetFn gcSet = cast(gcSetFn) GetProcAddress(mod, "gc_setProxy");
+        if (gcSet !is null)
+        {   // BUG: Set proxy, but too late
+            gcSet(gc_getProxy());
+        }
+        return mod;
+    }
+
+    /*************************************
+     * Unloads DLL that was previously loaded by rt_loadLibrary().
+     * Input:
+     *      ptr     the handle returned by rt_loadLibrary()
+     * Returns:
+     *      1   succeeded
+     *      0   some failure happened
+     */
+    extern (C) int rt_unloadLibrary(void* ptr)
+    {
+        gcClrFn gcClr  = cast(gcClrFn) GetProcAddress(ptr, "gc_clrProxy");
+        if (gcClr !is null)
+            gcClr();
+        return FreeLibrary(ptr) != 0;
+    }
+}
+
+/* To get out-of-band access to the args[] passed to main().
+ */
+
+__gshared string[] _d_args = null;
+
+extern (C) string[] rt_args()
+{
+    return _d_args;
+}
+
+// make arguments passed to main available for being filtered by runtime initializers
+extern(C) __gshared char[][] _d_main_args = null;
+
+// This variable is only ever set by a debugger on initialization so it should
+// be fine to leave it as __gshared.
+extern (C) __gshared bool rt_trapExceptions = true;
+
+alias void delegate(Throwable) ExceptionHandler;
+
+/**
+ * Keep track of how often rt_init/rt_term were called.
+ */
+shared size_t _initCount;
+
+/**********************************************
+ * Initialize druntime.
+ * If a C program wishes to call D code, and there's no D main(), then it
+ * must call rt_init() and rt_term().
+ */
+extern (C) int rt_init()
+{
+    /* @@BUG 11380 @@ Need to synchronize rt_init/rt_term calls for
+       version (Shared) druntime, because multiple C threads might
+       initialize different D libraries without knowing about the
+       shared druntime. Also we need to attach any thread that calls
+       rt_init. */
+    if (atomicOp!"+="(_initCount, 1) > 1) return 1;
+
+    version (CRuntime_Microsoft)
+        init_msvc();
+
+    _d_monitor_staticctor();
+    _d_critical_init();
+
+    try
+    {
+        initSections();
+        // this initializes mono time before anything else to allow usage
+        // in other druntime systems.
+        _d_initMonoTime();
+        gc_init();
+        initStaticDataGC();
+        lifetime_init();
+        rt_moduleCtor();
+        rt_moduleTlsCtor();
+        return 1;
+    }
+    catch (Throwable t)
+    {
+        _initCount = 0;
+        _d_print_throwable(t);
+    }
+    _d_critical_term();
+    _d_monitor_staticdtor();
+    return 0;
+}
+
+/**********************************************
+ * Terminate use of druntime.
+ */
+extern (C) int rt_term()
+{
+    if (!_initCount) return 0; // was never initialized
+    if (atomicOp!"-="(_initCount, 1)) return 1;
+
+    try
+    {
+        rt_moduleTlsDtor();
+        thread_joinAll();
+        rt_moduleDtor();
+        gc_term();
+        finiSections();
+        return 1;
+    }
+    catch (Throwable t)
+    {
+        _d_print_throwable(t);
+    }
+    finally
+    {
+        _d_critical_term();
+        _d_monitor_staticdtor();
+    }
+    return 0;
+}
+
+/**********************************************
+ * Trace handler
+ */
+alias Throwable.TraceInfo function(void* ptr) TraceHandler;
+private __gshared TraceHandler traceHandler = null;
+
+
+/**
+ * Overrides the default trace hander with a user-supplied version.
+ *
+ * Params:
+ *  h = The new trace handler.  Set to null to use the default handler.
+ */
+extern (C) void  rt_setTraceHandler(TraceHandler h)
+{
+    traceHandler = h;
+}
+
+/**
+ * Return the current trace handler
+ */
+extern (C) TraceHandler rt_getTraceHandler()
+{
+    return traceHandler;
+}
+
+/**
+ * This function will be called when an exception is constructed.  The
+ * user-supplied trace handler will be called if one has been supplied,
+ * otherwise no trace will be generated.
+ *
+ * Params:
+ *  ptr = A pointer to the location from which to generate the trace, or null
+ *        if the trace should be generated from within the trace handler
+ *        itself.
+ *
+ * Returns:
+ *  An object describing the current calling context or null if no handler is
+ *  supplied.
+ */
+extern (C) Throwable.TraceInfo _d_traceContext(void* ptr = null)
+{
+    if (traceHandler is null)
+        return null;
+    return traceHandler(ptr);
+}
+
+/***********************************
+ * Provide out-of-band access to the original C argc/argv
+ * passed to this program via main(argc,argv).
+ */
+
+struct CArgs
+{
+    int argc;
+    char** argv;
+}
+
+__gshared CArgs _cArgs;
+
+extern (C) CArgs rt_cArgs() @nogc
+{
+    return _cArgs;
+}
+
+/***********************************
+ * Run the given main function.
+ * Its purpose is to wrap the D main()
+ * function and catch any unhandled exceptions.
+ */
+private alias extern(C) int function(char[][] args) MainFunc;
+
+extern (C) int _d_run_main(int argc, char **argv, MainFunc mainFunc)
+{
+    // Remember the original C argc/argv
+    _cArgs.argc = argc;
+    _cArgs.argv = argv;
+
+    int result;
+
+    version (OSX)
+    {   /* OSX does not provide a way to get at the top of the
+         * stack, except for the magic value 0xC0000000.
+         * But as far as the gc is concerned, argv is at the top
+         * of the main thread's stack, so save the address of that.
+         */
+        __osx_stack_end = cast(void*)&argv;
+    }
+
+    version (FreeBSD) version (D_InlineAsm_X86)
+    {
+        /*
+         * FreeBSD/i386 sets the FPU precision mode to 53 bit double.
+         * Make it 64 bit extended.
+         */
+        ushort fpucw;
+        asm
+        {
+            fstsw   fpucw;
+            or      fpucw, 0b11_00_111111; // 11: use 64 bit extended-precision
+                                           // 111111: mask all FP exceptions
+            fldcw   fpucw;
+        }
+    }
+    version (CRuntime_Microsoft)
+    {
+        // enable full precision for reals
+        version(Win64)
+            asm
+            {
+                push    RAX;
+                fstcw   word ptr [RSP];
+                or      [RSP], 0b11_00_111111; // 11: use 64 bit extended-precision
+                                               // 111111: mask all FP exceptions
+                fldcw   word ptr [RSP];
+                pop     RAX;
+            }
+        else version(Win32)
+        {
+            asm
+            {
+                push    EAX;
+                fstcw   word ptr [ESP];
+                or      [ESP], 0b11_00_111111; // 11: use 64 bit extended-precision
+                // 111111: mask all FP exceptions
+                fldcw   word ptr [ESP];
+                pop     EAX;
+            }
+        }
+    }
+
+    version (Windows)
+    {
+        /* Because we want args[] to be UTF-8, and Windows doesn't guarantee that,
+         * we ignore argc/argv and go get the Windows command line again as UTF-16.
+         * Then, reparse into wargc/wargs, and then use Windows API to convert
+         * to UTF-8.
+         */
+        const wchar_t* wCommandLine = GetCommandLineW();
+        immutable size_t wCommandLineLength = wcslen(wCommandLine);
+        int wargc;
+        wchar_t** wargs = CommandLineToArgvW(wCommandLine, &wargc);
+        // assert(wargc == argc); /* argc can be broken by Unicode arguments */
+
+        // Allocate args[] on the stack - use wargc
+        char[][] args = (cast(char[]*) alloca(wargc * (char[]).sizeof))[0 .. wargc];
+
+        // This is required because WideCharToMultiByte requires int as input.
+        assert(wCommandLineLength <= cast(size_t) int.max, "Wide char command line length must not exceed int.max");
+
+        immutable size_t totalArgsLength = WideCharToMultiByte(CP_UTF8, 0, wCommandLine, cast(int)wCommandLineLength, null, 0, null, null);
+        {
+            char* totalArgsBuff = cast(char*) alloca(totalArgsLength);
+            size_t j = 0;
+            foreach (i; 0 .. wargc)
+            {
+                immutable size_t wlen = wcslen(wargs[i]);
+                assert(wlen <= cast(size_t) int.max, "wlen cannot exceed int.max");
+                immutable int len = WideCharToMultiByte(CP_UTF8, 0, &wargs[i][0], cast(int) wlen, null, 0, null, null);
+                args[i] = totalArgsBuff[j .. j + len];
+                if (len == 0)
+                    continue;
+                j += len;
+                assert(j <= totalArgsLength);
+                WideCharToMultiByte(CP_UTF8, 0, &wargs[i][0], cast(int) wlen, &args[i][0], len, null, null);
+            }
+        }
+        LocalFree(wargs);
+        wargs = null;
+        wargc = 0;
+    }
+    else version (Posix)
+    {
+        // Allocate args[] on the stack
+        char[][] args = (cast(char[]*) alloca(argc * (char[]).sizeof))[0 .. argc];
+
+        size_t totalArgsLength = 0;
+        foreach(i, ref arg; args)
+        {
+            arg = argv[i][0 .. strlen(argv[i])];
+            totalArgsLength += arg.length;
+        }
+    }
+    else
+        static assert(0);
+
+    /* Create a copy of args[] on the stack to be used for main, so that rt_args()
+     * cannot be modified by the user.
+     * Note that when this function returns, _d_args will refer to garbage.
+     */
+    {
+        _d_args = cast(string[]) args;
+        auto buff = cast(char[]*) alloca(args.length * (char[]).sizeof + totalArgsLength);
+
+        char[][] argsCopy = buff[0 .. args.length];
+        auto argBuff = cast(char*) (buff + args.length);
+        size_t j = 0;
+        foreach(arg; args)
+        {
+            if (arg.length < 6 || arg[0..6] != "--DRT-") // skip D runtime options
+            {
+                argsCopy[j++] = (argBuff[0 .. arg.length] = arg[]);
+                argBuff += arg.length;
+            }
+        }
+        args = argsCopy[0..j];
+    }
+
+    bool trapExceptions = rt_trapExceptions;
+
+    version (Windows)
+    {
+        if (IsDebuggerPresent())
+            trapExceptions = false;
+        version (GNU)
+        {
+            /* IsDebuggerPresent doesn't detect GDC.  Would be nice to have
+               some way of detecting valid console output */
+            trapExceptions = true;
+        }
+    }
+
+    void tryExec(scope void delegate() dg)
+    {
+        if (trapExceptions)
+        {
+            try
+            {
+                dg();
+            }
+            catch (Throwable t)
+            {
+                _d_print_throwable(t);
+                result = EXIT_FAILURE;
+            }
+        }
+        else
+        {
+            dg();
+        }
+    }
+
+    // NOTE: The lifetime of a process is much like the lifetime of an object:
+    //       it is initialized, then used, then destroyed.  If initialization
+    //       fails, the successive two steps are never reached.  However, if
+    //       initialization succeeds, then cleanup will occur even if the use
+    //       step fails in some way.  Here, the use phase consists of running
+    //       the user's main function.  If main terminates with an exception,
+    //       the exception is handled and then cleanup begins.  An exception
+    //       thrown during cleanup, however, will abort the cleanup process.
+    void runAll()
+    {
+        if (rt_init() && runModuleUnitTests())
+            tryExec({ result = mainFunc(args); });
+        else
+            result = EXIT_FAILURE;
+
+        if (!rt_term())
+            result = (result == EXIT_SUCCESS) ? EXIT_FAILURE : result;
+    }
+
+    tryExec(&runAll);
+
+    // Issue 10344: flush stdout and return nonzero on failure
+    if (.fflush(.stdout) != 0)
+    {
+        .fprintf(.stderr, "Failed to flush stdout: %s\n", .strerror(.errno));
+        if (result == 0)
+        {
+            result = EXIT_FAILURE;
+        }
+    }
+
+    return result;
+}
+
+private void formatThrowable(Throwable t, void delegate(in char[] s) nothrow sink)
+{
+    for (; t; t = t.next)
+    {
+        t.toString(sink); sink("\n");
+
+        auto e = cast(Error)t;
+        if (e is null || e.bypassedException is null) continue;
+
+        sink("=== Bypassed ===\n");
+        for (auto t2 = e.bypassedException; t2; t2 = t2.next)
+        {
+            t2.toString(sink); sink("\n");
+        }
+        sink("=== ~Bypassed ===\n");
+    }
+}
+
+extern (C) void _d_print_throwable(Throwable t)
+{
+    // On Windows, a console may not be present to print the output to.
+    // Show a message box instead.
+    version (Windows)
+    {
+        // ensure the exception is shown at the beginning of the line, while also
+        // checking whether stderr is a valid file
+        int written = fprintf(stderr, "\n");
+        if (written <= 0)
+        {
+            static struct WSink
+            {
+                wchar_t* ptr; size_t len;
+
+                void sink(in char[] s) nothrow
+                {
+                    if (!s.length) return;
+                    int swlen = MultiByteToWideChar(
+                        CP_UTF8, 0, s.ptr, cast(int)s.length, null, 0);
+                    if (!swlen) return;
+
+                    auto newPtr = cast(wchar_t*)realloc(ptr,
+                            (this.len + swlen + 1) * wchar_t.sizeof);
+                    if (!newPtr) return;
+                    ptr = newPtr;
+                    auto written = MultiByteToWideChar(
+                            CP_UTF8, 0, s.ptr, cast(int)s.length, ptr+len, swlen);
+                    len += written;
+                }
+
+                wchar_t* get() { if (ptr) ptr[len] = 0; return ptr; }
+
+                void free() { .free(ptr); }
+            }
+
+            WSink buf;
+            formatThrowable(t, &buf.sink);
+
+            if (buf.ptr)
+            {
+                WSink caption;
+                if (t)
+                    caption.sink(t.classinfo.name);
+
+                // Avoid static user32.dll dependency for console applications
+                // by loading it dynamically as needed
+                auto user32 = LoadLibraryW("user32.dll");
+                if (user32)
+                {
+                    alias typeof(&MessageBoxW) PMessageBoxW;
+                    auto pMessageBoxW = cast(PMessageBoxW)
+                        GetProcAddress(user32, "MessageBoxW");
+                    if (pMessageBoxW)
+                        pMessageBoxW(null, buf.get(), caption.get(), MB_ICONERROR);
+                }
+                FreeLibrary(user32);
+                caption.free();
+                buf.free();
+            }
+            return;
+        }
+    }
+
+    void sink(in char[] buf) nothrow
+    {
+        fprintf(stderr, "%.*s", cast(int)buf.length, buf.ptr);
+    }
+    formatThrowable(t, &sink);
+}
diff --git a/libphobos/libdruntime/rt/dylib_fixes.c b/libphobos/libdruntime/rt/dylib_fixes.c
new file mode 100644
index 00000000000..7bcf34b01c5
--- /dev/null
+++ b/libphobos/libdruntime/rt/dylib_fixes.c
@@ -0,0 +1,28 @@
+/**
+ * OS X support for dynamic libraries.
+ *
+ * Copyright: Copyright Digital Mars 2010 - 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2010 - 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+void* _Dmain __attribute__((weak));
+
+char rt_init ();
+char rt_term ();
+
+__attribute__((constructor)) static void initializer ()
+{
+    rt_init();
+}
+
+__attribute__((destructor)) static void finalizer ()
+{
+    rt_term();
+}
+
diff --git a/libphobos/libdruntime/rt/invariant.d b/libphobos/libdruntime/rt/invariant.d
new file mode 100644
index 00000000000..4dddfad38d2
--- /dev/null
+++ b/libphobos/libdruntime/rt/invariant.d
@@ -0,0 +1,36 @@
+/**
+ * Implementation of invariant support routines.
+ *
+ * Copyright: Copyright Digital Mars 2007 - 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2007 - 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+
+/**
+ *
+ */
+void _d_invariant(Object o)
+{   ClassInfo c;
+
+    //printf("__d_invariant(%p)\n", o);
+
+    // BUG: needs to be filename/line of caller, not library routine
+    assert(o !is null); // just do null check, not invariant check
+
+    c = typeid(o);
+    do
+    {
+        if (c.classInvariant)
+        {
+            (*c.classInvariant)(o);
+        }
+        c = c.base;
+    } while (c);
+}
diff --git a/libphobos/libdruntime/rt/lifetime.d b/libphobos/libdruntime/rt/lifetime.d
new file mode 100644
index 00000000000..d28edf8c584
--- /dev/null
+++ b/libphobos/libdruntime/rt/lifetime.d
@@ -0,0 +1,2653 @@
+/**
+ * This module contains all functions related to an object's lifetime:
+ * allocation, resizing, deallocation, and finalization.
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2012.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Walter Bright, Sean Kelly, Steven Schveighoffer
+ * Source: $(DRUNTIMESRC src/rt/_lifetime.d)
+ */
+
+module rt.lifetime;
+
+import core.stdc.stdlib;
+import core.stdc.string;
+import core.stdc.stdarg;
+import core.bitop;
+import core.memory;
+debug(PRINTF) import core.stdc.stdio;
+static import rt.tlsgc;
+
+alias BlkInfo = GC.BlkInfo;
+alias BlkAttr = GC.BlkAttr;
+import core.exception : onOutOfMemoryError, onFinalizeError, onInvalidMemoryOperationError;
+
+private
+{
+    alias bool function(Object) CollectHandler;
+    __gshared CollectHandler collectHandler = null;
+
+    extern (C) void _d_monitordelete(Object h, bool det);
+
+    enum : size_t
+    {
+        PAGESIZE = 4096,
+        BIGLENGTHMASK = ~(PAGESIZE - 1),
+        SMALLPAD = 1,
+        MEDPAD = ushort.sizeof,
+        LARGEPREFIX = 16, // 16 bytes padding at the front of the array
+        LARGEPAD = LARGEPREFIX + 1,
+        MAXSMALLSIZE = 256-SMALLPAD,
+        MAXMEDSIZE = (PAGESIZE / 2) - MEDPAD
+    }
+}
+
+private immutable bool callStructDtorsDuringGC;
+
+extern (C) void lifetime_init()
+{
+    // this is run before static ctors, so it is safe to modify immutables
+    import rt.config;
+    string s = rt_configOption("callStructDtorsDuringGC");
+    if (s != null)
+        cast() callStructDtorsDuringGC = s[0] == '1' || s[0] == 'y' || s[0] == 'Y';
+    else
+        cast() callStructDtorsDuringGC = true;
+}
+
+/**
+ *
+ */
+extern (C) void* _d_allocmemory(size_t sz)
+{
+    return GC.malloc(sz);
+}
+
+/**
+ *
+ */
+extern (C) Object _d_newclass(const ClassInfo ci)
+{
+    void* p;
+
+    debug(PRINTF) printf("_d_newclass(ci = %p, %s)\n", ci, cast(char *)ci.name);
+    if (ci.m_flags & TypeInfo_Class.ClassFlags.isCOMclass)
+    {   /* COM objects are not garbage collected, they are reference counted
+         * using AddRef() and Release().  They get free'd by C's free()
+         * function called by Release() when Release()'s reference count goes
+         * to zero.
+     */
+        p = malloc(ci.initializer.length);
+        if (!p)
+            onOutOfMemoryError();
+    }
+    else
+    {
+        // TODO: should this be + 1 to avoid having pointers to the next block?
+        BlkAttr attr = BlkAttr.NONE;
+        // extern(C++) classes don't have a classinfo pointer in their vtable so the GC can't finalize them
+        if (ci.m_flags & TypeInfo_Class.ClassFlags.hasDtor
+            && !(ci.m_flags & TypeInfo_Class.ClassFlags.isCPPclass))
+            attr |= BlkAttr.FINALIZE;
+        if (ci.m_flags & TypeInfo_Class.ClassFlags.noPointers)
+            attr |= BlkAttr.NO_SCAN;
+        p = GC.malloc(ci.initializer.length, attr, ci);
+        debug(PRINTF) printf(" p = %p\n", p);
+    }
+
+    debug(PRINTF)
+    {
+        printf("p = %p\n", p);
+        printf("ci = %p, ci.init.ptr = %p, len = %llu\n", ci, ci.initializer.ptr, cast(ulong)ci.initializer.length);
+        printf("vptr = %p\n", *cast(void**) ci.initializer);
+        printf("vtbl[0] = %p\n", (*cast(void***) ci.initializer)[0]);
+        printf("vtbl[1] = %p\n", (*cast(void***) ci.initializer)[1]);
+        printf("init[0] = %x\n", (cast(uint*) ci.initializer)[0]);
+        printf("init[1] = %x\n", (cast(uint*) ci.initializer)[1]);
+        printf("init[2] = %x\n", (cast(uint*) ci.initializer)[2]);
+        printf("init[3] = %x\n", (cast(uint*) ci.initializer)[3]);
+        printf("init[4] = %x\n", (cast(uint*) ci.initializer)[4]);
+    }
+
+    // initialize it
+    p[0 .. ci.initializer.length] = ci.initializer[];
+
+    debug(PRINTF) printf("initialization done\n");
+    return cast(Object) p;
+}
+
+
+/**
+ *
+ */
+extern (C) void _d_delinterface(void** p)
+{
+    if (*p)
+    {
+        Interface* pi = **cast(Interface ***)*p;
+        Object     o  = cast(Object)(*p - pi.offset);
+
+        _d_delclass(&o);
+        *p = null;
+    }
+}
+
+
+// used for deletion
+private extern (D) alias void function (Object) fp_t;
+
+
+/**
+ *
+ */
+extern (C) void _d_delclass(Object* p)
+{
+    if (*p)
+    {
+        debug(PRINTF) printf("_d_delclass(%p)\n", *p);
+
+        ClassInfo **pc = cast(ClassInfo **)*p;
+        if (*pc)
+        {
+            ClassInfo c = **pc;
+
+            rt_finalize(cast(void*) *p);
+
+            if (c.deallocator)
+            {
+                fp_t fp = cast(fp_t)c.deallocator;
+                (*fp)(*p); // call deallocator
+                *p = null;
+                return;
+            }
+        }
+        else
+        {
+            rt_finalize(cast(void*) *p);
+        }
+        GC.free(cast(void*) *p);
+        *p = null;
+    }
+}
+
+/**
+ * This is called for a delete statement where the value
+ * being deleted is a pointer to a struct with a destructor
+ * but doesn't have an overloaded delete operator.
+ */
+extern (C) void _d_delstruct(void** p, TypeInfo_Struct inf)
+{
+    if (*p)
+    {
+        debug(PRINTF) printf("_d_delstruct(%p, %p)\n", *p, cast(void*)inf);
+
+        inf.destroy(*p);
+        GC.free(*p);
+        *p = null;
+    }
+}
+
+// strip const/immutable/shared/inout from type info
+inout(TypeInfo) unqualify(inout(TypeInfo) cti) pure nothrow @nogc
+{
+    TypeInfo ti = cast() cti;
+    while (ti)
+    {
+        // avoid dynamic type casts
+        auto tti = typeid(ti);
+        if (tti is typeid(TypeInfo_Const))
+            ti = (cast(TypeInfo_Const)cast(void*)ti).base;
+        else if (tti is typeid(TypeInfo_Invariant))
+            ti = (cast(TypeInfo_Invariant)cast(void*)ti).base;
+        else if (tti is typeid(TypeInfo_Shared))
+            ti = (cast(TypeInfo_Shared)cast(void*)ti).base;
+        else if (tti is typeid(TypeInfo_Inout))
+            ti = (cast(TypeInfo_Inout)cast(void*)ti).base;
+        else
+            break;
+    }
+    return ti;
+}
+
+// size used to store the TypeInfo at the end of an allocation for structs that have a destructor
+size_t structTypeInfoSize(const TypeInfo ti) pure nothrow @nogc
+{
+    if (!callStructDtorsDuringGC)
+        return 0;
+
+    if (ti && typeid(ti) is typeid(TypeInfo_Struct)) // avoid a complete dynamic type cast
+    {
+        auto sti = cast(TypeInfo_Struct)cast(void*)ti;
+        if (sti.xdtor)
+            return size_t.sizeof;
+    }
+    return 0;
+}
+
+/** dummy class used to lock for shared array appending */
+private class ArrayAllocLengthLock
+{}
+
+
+/**
+  Set the allocated length of the array block.  This is called
+  any time an array is appended to or its length is set.
+
+  The allocated block looks like this for blocks < PAGESIZE:
+
+  |elem0|elem1|elem2|...|elemN-1|emptyspace|N*elemsize|
+
+
+  The size of the allocated length at the end depends on the block size:
+
+  a block of 16 to 256 bytes has an 8-bit length.
+
+  a block with 512 to pagesize/2 bytes has a 16-bit length.
+
+  For blocks >= pagesize, the length is a size_t and is at the beginning of the
+  block.  The reason we have to do this is because the block can extend into
+  more pages, so we cannot trust the block length if it sits at the end of the
+  block, because it might have just been extended.  If we can prove in the
+  future that the block is unshared, we may be able to change this, but I'm not
+  sure it's important.
+
+  In order to do put the length at the front, we have to provide 16 bytes
+  buffer space in case the block has to be aligned properly.  In x86, certain
+  SSE instructions will only work if the data is 16-byte aligned.  In addition,
+  we need the sentinel byte to prevent accidental pointers to the next block.
+  Because of the extra overhead, we only do this for page size and above, where
+  the overhead is minimal compared to the block size.
+
+  So for those blocks, it looks like:
+
+  |N*elemsize|padding|elem0|elem1|...|elemN-1|emptyspace|sentinelbyte|
+
+  where elem0 starts 16 bytes after the first byte.
+  */
+bool __setArrayAllocLength(ref BlkInfo info, size_t newlength, bool isshared, const TypeInfo tinext, size_t oldlength = ~0) pure nothrow
+{
+    import core.atomic;
+
+    size_t typeInfoSize = structTypeInfoSize(tinext);
+
+    if(info.size <= 256)
+    {
+        if(newlength + SMALLPAD + typeInfoSize > info.size)
+            // new size does not fit inside block
+            return false;
+        auto length = cast(ubyte *)(info.base + info.size - typeInfoSize - SMALLPAD);
+        if(oldlength != ~0)
+        {
+            if(isshared)
+            {
+                return cas(cast(shared)length, cast(ubyte)oldlength, cast(ubyte)newlength);
+            }
+            else
+            {
+                if(*length == cast(ubyte)oldlength)
+                    *length = cast(ubyte)newlength;
+                else
+                    return false;
+            }
+        }
+        else
+        {
+            // setting the initial length, no cas needed
+            *length = cast(ubyte)newlength;
+        }
+        if (typeInfoSize)
+        {
+            auto typeInfo = cast(TypeInfo*)(info.base + info.size - size_t.sizeof);
+            *typeInfo = cast() tinext;
+        }
+    }
+    else if(info.size < PAGESIZE)
+    {
+        if(newlength + MEDPAD + typeInfoSize > info.size)
+            // new size does not fit inside block
+            return false;
+        auto length = cast(ushort *)(info.base + info.size - typeInfoSize - MEDPAD);
+        if(oldlength != ~0)
+        {
+            if(isshared)
+            {
+                return cas(cast(shared)length, cast(ushort)oldlength, cast(ushort)newlength);
+            }
+            else
+            {
+                if(*length == oldlength)
+                    *length = cast(ushort)newlength;
+                else
+                    return false;
+            }
+        }
+        else
+        {
+            // setting the initial length, no cas needed
+            *length = cast(ushort)newlength;
+        }
+        if (typeInfoSize)
+        {
+            auto typeInfo = cast(TypeInfo*)(info.base + info.size - size_t.sizeof);
+            *typeInfo = cast() tinext;
+        }
+    }
+    else
+    {
+        if(newlength + LARGEPAD > info.size)
+            // new size does not fit inside block
+            return false;
+        auto length = cast(size_t *)(info.base);
+        if(oldlength != ~0)
+        {
+            if(isshared)
+            {
+                return cas(cast(shared)length, cast(size_t)oldlength, cast(size_t)newlength);
+            }
+            else
+            {
+                if(*length == oldlength)
+                    *length = newlength;
+                else
+                    return false;
+            }
+        }
+        else
+        {
+            // setting the initial length, no cas needed
+            *length = newlength;
+        }
+        if (typeInfoSize)
+        {
+            auto typeInfo = cast(TypeInfo*)(info.base + size_t.sizeof);
+            *typeInfo = cast()tinext;
+        }
+    }
+    return true; // resize succeeded
+}
+
+/**
+  get the allocation size of the array for the given block (without padding or type info)
+  */
+size_t __arrayAllocLength(ref BlkInfo info, const TypeInfo tinext) pure nothrow
+{
+    if(info.size <= 256)
+        return *cast(ubyte *)(info.base + info.size - structTypeInfoSize(tinext) - SMALLPAD);
+
+    if(info.size < PAGESIZE)
+        return *cast(ushort *)(info.base + info.size - structTypeInfoSize(tinext) - MEDPAD);
+
+    return *cast(size_t *)(info.base);
+}
+
+/**
+  get the start of the array for the given block
+  */
+void *__arrayStart(BlkInfo info) nothrow pure
+{
+    return info.base + ((info.size & BIGLENGTHMASK) ? LARGEPREFIX : 0);
+}
+
+/**
+  get the padding required to allocate size bytes.  Note that the padding is
+  NOT included in the passed in size.  Therefore, do NOT call this function
+  with the size of an allocated block.
+  */
+size_t __arrayPad(size_t size, const TypeInfo tinext) nothrow pure @trusted
+{
+    return size > MAXMEDSIZE ? LARGEPAD : ((size > MAXSMALLSIZE ? MEDPAD : SMALLPAD) + structTypeInfoSize(tinext));
+}
+
+/**
+  allocate an array memory block by applying the proper padding and
+  assigning block attributes if not inherited from the existing block
+  */
+BlkInfo __arrayAlloc(size_t arrsize, const TypeInfo ti, const TypeInfo tinext) nothrow pure
+{
+    size_t typeInfoSize = structTypeInfoSize(tinext);
+    size_t padsize = arrsize > MAXMEDSIZE ? LARGEPAD : ((arrsize > MAXSMALLSIZE ? MEDPAD : SMALLPAD) + typeInfoSize);
+
+    if (arrsize + padsize < arrsize)
+        return BlkInfo();
+
+    uint attr = (!(tinext.flags & 1) ? BlkAttr.NO_SCAN : 0) | BlkAttr.APPENDABLE;
+    if (typeInfoSize)
+        attr |= BlkAttr.STRUCTFINAL | BlkAttr.FINALIZE;
+    return GC.qalloc(arrsize + padsize, attr, ti);
+}
+
+BlkInfo __arrayAlloc(size_t arrsize, ref BlkInfo info, const TypeInfo ti, const TypeInfo tinext)
+{
+    if (!info.base)
+        return __arrayAlloc(arrsize, ti, tinext);
+
+    return GC.qalloc(arrsize + __arrayPad(arrsize, tinext), info.attr, ti);
+}
+
+/**
+  cache for the lookup of the block info
+  */
+enum N_CACHE_BLOCKS=8;
+
+// note this is TLS, so no need to sync.
+BlkInfo *__blkcache_storage;
+
+static if(N_CACHE_BLOCKS==1)
+{
+    version=single_cache;
+}
+else
+{
+    //version=simple_cache; // uncomment to test simple cache strategy
+    //version=random_cache; // uncomment to test random cache strategy
+
+    // ensure N_CACHE_BLOCKS is power of 2.
+    static assert(!((N_CACHE_BLOCKS - 1) & N_CACHE_BLOCKS));
+
+    version(random_cache)
+    {
+        int __nextRndNum = 0;
+    }
+    int __nextBlkIdx;
+}
+
+@property BlkInfo *__blkcache() nothrow
+{
+    if(!__blkcache_storage)
+    {
+        // allocate the block cache for the first time
+        immutable size = BlkInfo.sizeof * N_CACHE_BLOCKS;
+        __blkcache_storage = cast(BlkInfo *)malloc(size);
+        memset(__blkcache_storage, 0, size);
+    }
+    return __blkcache_storage;
+}
+
+// called when thread is exiting.
+static ~this()
+{
+    // free the blkcache
+    if(__blkcache_storage)
+    {
+        free(__blkcache_storage);
+        __blkcache_storage = null;
+    }
+}
+
+
+// we expect this to be called with the lock in place
+void processGCMarks(BlkInfo* cache, scope rt.tlsgc.IsMarkedDg isMarked) nothrow
+{
+    // called after the mark routine to eliminate block cache data when it
+    // might be ready to sweep
+
+    debug(PRINTF) printf("processing GC Marks, %x\n", cache);
+    if(cache)
+    {
+        debug(PRINTF) foreach(i; 0 .. N_CACHE_BLOCKS)
+        {
+            printf("cache entry %d has base ptr %x\tsize %d\tflags %x\n", i, cache[i].base, cache[i].size, cache[i].attr);
+        }
+        auto cache_end = cache + N_CACHE_BLOCKS;
+        for(;cache < cache_end; ++cache)
+        {
+            if(cache.base != null && !isMarked(cache.base))
+            {
+                debug(PRINTF) printf("clearing cache entry at %x\n", cache.base);
+                cache.base = null; // clear that data.
+            }
+        }
+    }
+}
+
+unittest
+{
+    // Bugzilla 10701 - segfault in GC
+    ubyte[] result; result.length = 4096;
+    GC.free(result.ptr);
+    GC.collect();
+}
+
+/**
+  Get the cached block info of an interior pointer.  Returns null if the
+  interior pointer's block is not cached.
+
+  NOTE: The base ptr in this struct can be cleared asynchronously by the GC,
+        so any use of the returned BlkInfo should copy it and then check the
+        base ptr of the copy before actually using it.
+
+  TODO: Change this function so the caller doesn't have to be aware of this
+        issue.  Either return by value and expect the caller to always check
+        the base ptr as an indication of whether the struct is valid, or set
+        the BlkInfo as a side-effect and return a bool to indicate success.
+  */
+BlkInfo *__getBlkInfo(void *interior) nothrow
+{
+    BlkInfo *ptr = __blkcache;
+    version(single_cache)
+    {
+        if(ptr.base && ptr.base <= interior && (interior - ptr.base) < ptr.size)
+            return ptr;
+        return null; // not in cache.
+    }
+    else version(simple_cache)
+    {
+        foreach(i; 0..N_CACHE_BLOCKS)
+        {
+            if(ptr.base && ptr.base <= interior && (interior - ptr.base) < ptr.size)
+                return ptr;
+            ptr++;
+        }
+    }
+    else
+    {
+        // try to do a smart lookup, using __nextBlkIdx as the "head"
+        auto curi = ptr + __nextBlkIdx;
+        for(auto i = curi; i >= ptr; --i)
+        {
+            if(i.base && i.base <= interior && cast(size_t)(interior - i.base) < i.size)
+                return i;
+        }
+
+        for(auto i = ptr + N_CACHE_BLOCKS - 1; i > curi; --i)
+        {
+            if(i.base && i.base <= interior && cast(size_t)(interior - i.base) < i.size)
+                return i;
+        }
+    }
+    return null; // not in cache.
+}
+
+void __insertBlkInfoCache(BlkInfo bi, BlkInfo *curpos) nothrow
+{
+    version(single_cache)
+    {
+        *__blkcache = bi;
+    }
+    else
+    {
+        version(simple_cache)
+        {
+            if(curpos)
+                *curpos = bi;
+            else
+            {
+                // note, this is a super-simple algorithm that does not care about
+                // most recently used.  It simply uses a round-robin technique to
+                // cache block info.  This means that the ordering of the cache
+                // doesn't mean anything.  Certain patterns of allocation may
+                // render the cache near-useless.
+                __blkcache[__nextBlkIdx] = bi;
+                __nextBlkIdx = (__nextBlkIdx+1) & (N_CACHE_BLOCKS - 1);
+            }
+        }
+        else version(random_cache)
+        {
+            // strategy: if the block currently is in the cache, move the
+            // current block index to the a random element and evict that
+            // element.
+            auto cache = __blkcache;
+            if(!curpos)
+            {
+                __nextBlkIdx = (__nextRndNum = 1664525 * __nextRndNum + 1013904223) & (N_CACHE_BLOCKS - 1);
+                curpos = cache + __nextBlkIdx;
+            }
+            else
+            {
+                __nextBlkIdx = curpos - cache;
+            }
+            *curpos = bi;
+        }
+        else
+        {
+            //
+            // strategy: If the block currently is in the cache, swap it with
+            // the head element.  Otherwise, move the head element up by one,
+            // and insert it there.
+            //
+            auto cache = __blkcache;
+            if(!curpos)
+            {
+                __nextBlkIdx = (__nextBlkIdx+1) & (N_CACHE_BLOCKS - 1);
+                curpos = cache + __nextBlkIdx;
+            }
+            else if(curpos !is cache + __nextBlkIdx)
+            {
+                *curpos = cache[__nextBlkIdx];
+                curpos = cache + __nextBlkIdx;
+            }
+            *curpos = bi;
+        }
+    }
+}
+
+/**
+ * Shrink the "allocated" length of an array to be the exact size of the array.
+ * It doesn't matter what the current allocated length of the array is, the
+ * user is telling the runtime that he knows what he is doing.
+ */
+extern(C) void _d_arrayshrinkfit(const TypeInfo ti, void[] arr) /+nothrow+/
+{
+    // note, we do not care about shared.  We are setting the length no matter
+    // what, so no lock is required.
+    debug(PRINTF) printf("_d_arrayshrinkfit, elemsize = %d, arr.ptr = x%x arr.length = %d\n", ti.next.tsize, arr.ptr, arr.length);
+    auto tinext = unqualify(ti.next);
+    auto size = tinext.tsize;                  // array element size
+    auto cursize = arr.length * size;
+    auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
+    auto bic = isshared ? null : __getBlkInfo(arr.ptr);
+    auto info = bic ? *bic : GC.query(arr.ptr);
+    if(info.base && (info.attr & BlkAttr.APPENDABLE))
+    {
+        auto newsize = (arr.ptr - __arrayStart(info)) + cursize;
+
+        debug(PRINTF) printf("setting allocated size to %d\n", (arr.ptr - info.base) + cursize);
+
+        // destroy structs that become unused memory when array size is shrinked
+        if (typeid(tinext) is typeid(TypeInfo_Struct)) // avoid a complete dynamic type cast
+        {
+            auto sti = cast(TypeInfo_Struct)cast(void*)tinext;
+            if (sti.xdtor)
+            {
+                auto oldsize = __arrayAllocLength(info, tinext);
+                if (oldsize > cursize)
+                    finalize_array(arr.ptr + cursize, oldsize - cursize, sti);
+            }
+        }
+        // Note: Since we "assume" the append is safe, it means it is not shared.
+        // Since it is not shared, we also know it won't throw (no lock).
+        if (!__setArrayAllocLength(info, newsize, false, tinext))
+            onInvalidMemoryOperationError();
+
+        // cache the block if not already done.
+        if (!isshared && !bic)
+            __insertBlkInfoCache(info, null);
+    }
+}
+
+package bool hasPostblit(in TypeInfo ti)
+{
+    return (&ti.postblit).funcptr !is &TypeInfo.postblit;
+}
+
+void __doPostblit(void *ptr, size_t len, const TypeInfo ti)
+{
+    if (!hasPostblit(ti))
+        return;
+
+    if(auto tis = cast(TypeInfo_Struct)ti)
+    {
+        // this is a struct, check the xpostblit member
+        auto pblit = tis.xpostblit;
+        if(!pblit)
+            // postblit not specified, no point in looping.
+            return;
+
+        // optimized for struct, call xpostblit directly for each element
+        immutable size = ti.tsize;
+        const eptr = ptr + len;
+        for(;ptr < eptr;ptr += size)
+            pblit(ptr);
+    }
+    else
+    {
+        // generic case, call the typeinfo's postblit function
+        immutable size = ti.tsize;
+        const eptr = ptr + len;
+        for(;ptr < eptr;ptr += size)
+            ti.postblit(ptr);
+    }
+}
+
+
+/**
+ * set the array capacity.  If the array capacity isn't currently large enough
+ * to hold the requested capacity (in number of elements), then the array is
+ * resized/reallocated to the appropriate size.  Pass in a requested capacity
+ * of 0 to get the current capacity.  Returns the number of elements that can
+ * actually be stored once the resizing is done.
+ */
+extern(C) size_t _d_arraysetcapacity(const TypeInfo ti, size_t newcapacity, void[]* p)
+in
+{
+    assert(ti);
+    assert(!(*p).length || (*p).ptr);
+}
+body
+{
+    // step 1, get the block
+    auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
+    auto bic = isshared ? null : __getBlkInfo((*p).ptr);
+    auto info = bic ? *bic : GC.query((*p).ptr);
+    auto tinext = unqualify(ti.next);
+    auto size = tinext.tsize;
+    version (D_InlineAsm_X86)
+    {
+        size_t reqsize = void;
+
+        asm
+        {
+            mov EAX, newcapacity;
+            mul EAX, size;
+            mov reqsize, EAX;
+            jnc  Lcontinue;
+        }
+    }
+    else version (D_InlineAsm_X86_64)
+    {
+        size_t reqsize = void;
+
+        asm
+        {
+            mov RAX, newcapacity;
+            mul RAX, size;
+            mov reqsize, RAX;
+            jnc  Lcontinue;
+        }
+    }
+    else
+    {
+        import core.checkedint : mulu;
+
+        bool overflow = false;
+        size_t reqsize = mulu(size, newcapacity, overflow);
+        if (!overflow)
+            goto Lcontinue;
+    }
+Loverflow:
+    onOutOfMemoryError();
+    assert(0);
+Lcontinue:
+
+    // step 2, get the actual "allocated" size.  If the allocated size does not
+    // match what we expect, then we will need to reallocate anyways.
+
+    // TODO: this probably isn't correct for shared arrays
+    size_t curallocsize = void;
+    size_t curcapacity = void;
+    size_t offset = void;
+    size_t arraypad = void;
+    if(info.base && (info.attr & BlkAttr.APPENDABLE))
+    {
+        if(info.size <= 256)
+        {
+            arraypad = SMALLPAD + structTypeInfoSize(tinext);
+            curallocsize = *(cast(ubyte *)(info.base + info.size - arraypad));
+        }
+        else if(info.size < PAGESIZE)
+        {
+            arraypad = MEDPAD + structTypeInfoSize(tinext);
+            curallocsize = *(cast(ushort *)(info.base + info.size - arraypad));
+        }
+        else
+        {
+            curallocsize = *(cast(size_t *)(info.base));
+            arraypad = LARGEPAD;
+        }
+
+
+        offset = (*p).ptr - __arrayStart(info);
+        if(offset + (*p).length * size != curallocsize)
+        {
+            curcapacity = 0;
+        }
+        else
+        {
+            // figure out the current capacity of the block from the point
+            // of view of the array.
+            curcapacity = info.size - offset - arraypad;
+        }
+    }
+    else
+    {
+        curallocsize = curcapacity = offset = 0;
+    }
+    debug(PRINTF) printf("_d_arraysetcapacity, p = x%d,%d, newcapacity=%d, info.size=%d, reqsize=%d, curallocsize=%d, curcapacity=%d, offset=%d\n", (*p).ptr, (*p).length, newcapacity, info.size, reqsize, curallocsize, curcapacity, offset);
+
+    if(curcapacity >= reqsize)
+    {
+        // no problems, the current allocated size is large enough.
+        return curcapacity / size;
+    }
+
+    // step 3, try to extend the array in place.
+    if(info.size >= PAGESIZE && curcapacity != 0)
+    {
+        auto extendsize = reqsize + offset + LARGEPAD - info.size;
+        auto u = GC.extend(info.base, extendsize, extendsize);
+        if(u)
+        {
+            // extend worked, save the new current allocated size
+            if(bic)
+                bic.size = u; // update cache
+            curcapacity = u - offset - LARGEPAD;
+            return curcapacity / size;
+        }
+    }
+
+    // step 4, if extending doesn't work, allocate a new array with at least the requested allocated size.
+    auto datasize = (*p).length * size;
+    // copy attributes from original block, or from the typeinfo if the
+    // original block doesn't exist.
+    info = __arrayAlloc(reqsize, info, ti, tinext);
+    if(info.base is null)
+        goto Loverflow;
+    // copy the data over.
+    // note that malloc will have initialized the data we did not request to 0.
+    auto tgt = __arrayStart(info);
+    memcpy(tgt, (*p).ptr, datasize);
+
+    // handle postblit
+    __doPostblit(tgt, datasize, tinext);
+
+    if(!(info.attr & BlkAttr.NO_SCAN))
+    {
+        // need to memset the newly requested data, except for the data that
+        // malloc returned that we didn't request.
+        void *endptr = tgt + reqsize;
+        void *begptr = tgt + datasize;
+
+        // sanity check
+        assert(endptr >= begptr);
+        memset(begptr, 0, endptr - begptr);
+    }
+
+    // set up the correct length
+    __setArrayAllocLength(info, datasize, isshared, tinext);
+    if(!isshared)
+        __insertBlkInfoCache(info, bic);
+
+    *p = (cast(void*)tgt)[0 .. (*p).length];
+
+    // determine the padding.  This has to be done manually because __arrayPad
+    // assumes you are not counting the pad size, and info.size does include
+    // the pad.
+    if(info.size <= 256)
+        arraypad = SMALLPAD + structTypeInfoSize(tinext);
+    else if(info.size < PAGESIZE)
+        arraypad = MEDPAD + structTypeInfoSize(tinext);
+    else
+        arraypad = LARGEPAD;
+
+    curcapacity = info.size - arraypad;
+    return curcapacity / size;
+}
+
+/**
+ * Allocate a new uninitialized array of length elements.
+ * ti is the type of the resulting array, or pointer to element.
+ */
+extern (C) void[] _d_newarrayU(const TypeInfo ti, size_t length) pure nothrow
+{
+    auto tinext = unqualify(ti.next);
+    auto size = tinext.tsize;
+
+    debug(PRINTF) printf("_d_newarrayU(length = x%x, size = %d)\n", length, size);
+    if (length == 0 || size == 0)
+        return null;
+
+    version (D_InlineAsm_X86)
+    {
+        asm pure nothrow @nogc
+        {
+            mov     EAX,size        ;
+            mul     EAX,length      ;
+            mov     size,EAX        ;
+            jnc     Lcontinue       ;
+        }
+    }
+    else version(D_InlineAsm_X86_64)
+    {
+        asm pure nothrow @nogc
+        {
+            mov     RAX,size        ;
+            mul     RAX,length      ;
+            mov     size,RAX        ;
+            jnc     Lcontinue       ;
+        }
+    }
+    else
+    {
+        import core.checkedint : mulu;
+
+        bool overflow = false;
+        size = mulu(size, length, overflow);
+        if (!overflow)
+            goto Lcontinue;
+    }
+Loverflow:
+    onOutOfMemoryError();
+    assert(0);
+Lcontinue:
+
+    auto info = __arrayAlloc(size, ti, tinext);
+    if (!info.base)
+        goto Loverflow;
+    debug(PRINTF) printf(" p = %p\n", info.base);
+    // update the length of the array
+    auto arrstart = __arrayStart(info);
+    auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
+    __setArrayAllocLength(info, size, isshared, tinext);
+    return arrstart[0..length];
+}
+
+/**
+ * Allocate a new array of length elements.
+ * ti is the type of the resulting array, or pointer to element.
+ * (For when the array is initialized to 0)
+ */
+extern (C) void[] _d_newarrayT(const TypeInfo ti, size_t length) pure nothrow
+{
+    void[] result = _d_newarrayU(ti, length);
+    auto tinext = unqualify(ti.next);
+    auto size = tinext.tsize;
+
+    memset(result.ptr, 0, size * length);
+    return result;
+}
+
+/**
+ * For when the array has a non-zero initializer.
+ */
+extern (C) void[] _d_newarrayiT(const TypeInfo ti, size_t length) pure nothrow
+{
+    import core.internal.traits : TypeTuple;
+
+    void[] result = _d_newarrayU(ti, length);
+    auto tinext = unqualify(ti.next);
+    auto size = tinext.tsize;
+
+    auto init = tinext.initializer();
+
+    switch (init.length)
+    {
+    foreach (T; TypeTuple!(ubyte, ushort, uint, ulong))
+    {
+    case T.sizeof:
+        (cast(T*)result.ptr)[0 .. size * length / T.sizeof] = *cast(T*)init.ptr;
+        return result;
+    }
+
+    default:
+    {
+        immutable sz = init.length;
+        for (size_t u = 0; u < size * length; u += sz)
+            memcpy(result.ptr + u, init.ptr, sz);
+        return result;
+    }
+    }
+}
+
+
+/**
+ *
+ */
+void[] _d_newarrayOpT(alias op)(const TypeInfo ti, size_t[] dims)
+{
+    debug(PRINTF) printf("_d_newarrayOpT(ndims = %d)\n", dims.length);
+    if (dims.length == 0)
+        return null;
+
+    void[] foo(const TypeInfo ti, size_t[] dims)
+    {
+        auto tinext = unqualify(ti.next);
+        auto dim = dims[0];
+
+        debug(PRINTF) printf("foo(ti = %p, ti.next = %p, dim = %d, ndims = %d\n", ti, ti.next, dim, dims.length);
+        if (dims.length == 1)
+        {
+            auto r = op(ti, dim);
+            return *cast(void[]*)(&r);
+        }
+
+        auto allocsize = (void[]).sizeof * dim;
+        auto info = __arrayAlloc(allocsize, ti, tinext);
+        auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
+        __setArrayAllocLength(info, allocsize, isshared, tinext);
+        auto p = __arrayStart(info)[0 .. dim];
+
+        foreach(i; 0..dim)
+        {
+            (cast(void[]*)p.ptr)[i] = foo(tinext, dims[1..$]);
+        }
+        return p;
+    }
+
+    auto result = foo(ti, dims);
+    debug(PRINTF) printf("result = %llx\n", result.ptr);
+
+    return result;
+}
+
+
+/**
+ *
+ */
+extern (C) void[] _d_newarraymTX(const TypeInfo ti, size_t[] dims)
+{
+    debug(PRINTF) printf("_d_newarraymT(dims.length = %d)\n", dims.length);
+
+    if (dims.length == 0)
+        return null;
+    else
+    {
+        return _d_newarrayOpT!(_d_newarrayT)(ti, dims);
+    }
+}
+
+
+/**
+ *
+ */
+extern (C) void[] _d_newarraymiTX(const TypeInfo ti, size_t[] dims)
+{
+    debug(PRINTF) printf("_d_newarraymiT(dims.length = %d)\n", dims.length);
+
+    if (dims.length == 0)
+        return null;
+    else
+    {
+        return _d_newarrayOpT!(_d_newarrayiT)(ti, dims);
+    }
+}
+
+/**
+ * Allocate an uninitialized non-array item.
+ * This is an optimization to avoid things needed for arrays like the __arrayPad(size).
+ */
+extern (C) void* _d_newitemU(in TypeInfo _ti)
+{
+    auto ti = unqualify(_ti);
+    auto flags = !(ti.flags & 1) ? BlkAttr.NO_SCAN : 0;
+    immutable tiSize = structTypeInfoSize(ti);
+    immutable size = ti.tsize + tiSize;
+    if (tiSize)
+        flags |= BlkAttr.STRUCTFINAL | BlkAttr.FINALIZE;
+
+    auto blkInf = GC.qalloc(size, flags, ti);
+    auto p = blkInf.base;
+
+    if (tiSize)
+        *cast(TypeInfo*)(p + blkInf.size - tiSize) = cast() ti;
+
+    return p;
+}
+
+/// Same as above, zero initializes the item.
+extern (C) void* _d_newitemT(in TypeInfo _ti)
+{
+    auto p = _d_newitemU(_ti);
+    memset(p, 0, _ti.tsize);
+    return p;
+}
+
+/// Same as above, for item with non-zero initializer.
+extern (C) void* _d_newitemiT(in TypeInfo _ti)
+{
+    auto p = _d_newitemU(_ti);
+    auto init = _ti.initializer();
+    assert(init.length <= _ti.tsize);
+    memcpy(p, init.ptr, init.length);
+    return p;
+}
+
+/**
+ *
+ */
+struct Array
+{
+    size_t length;
+    byte*  data;
+}
+
+
+/**
+ * This function has been replaced by _d_delarray_t
+ */
+extern (C) void _d_delarray(void[]* p)
+{
+    _d_delarray_t(p, null);
+}
+
+debug(PRINTF)
+{
+    extern(C) void printArrayCache()
+    {
+        auto ptr = __blkcache;
+        printf("CACHE: \n");
+        foreach(i; 0 .. N_CACHE_BLOCKS)
+        {
+            printf("  %d\taddr:% .8x\tsize:% .10d\tflags:% .8x\n", i, ptr[i].base, ptr[i].size, ptr[i].attr);
+        }
+    }
+}
+
+/**
+ *
+ */
+extern (C) void _d_delarray_t(void[]* p, const TypeInfo_Struct ti)
+{
+    if (p)
+    {
+        auto bic = __getBlkInfo(p.ptr);
+        auto info = bic ? *bic : GC.query(p.ptr);
+
+        if (info.base && (info.attr & BlkAttr.APPENDABLE))
+        {
+            if (ti) // ti non-null only if ti is a struct with dtor
+            {
+                void* start = __arrayStart(info);
+                size_t length = __arrayAllocLength(info, ti);
+                finalize_array(start, length, ti);
+            }
+
+            // if p is in the cache, clear it there as well
+            if(bic)
+                bic.base = null;
+
+            GC.free(info.base);
+            *p = null;
+        }
+    }
+}
+
+unittest
+{
+    __gshared size_t countDtor = 0;
+    struct S
+    {
+        int x;
+        ~this() { countDtor++; }
+    }
+    // destroy large array with x.ptr not base address of allocation
+    auto x = new S[10000];
+    void* p = x.ptr;
+    assert(GC.addrOf(p) != null);
+    delete x;
+    assert(GC.addrOf(p) == null);
+    assert(countDtor == 10000);
+
+    // destroy full array even if only slice passed
+    auto y = new S[400];
+    auto z = y[200 .. 300];
+    p = z.ptr;
+    assert(GC.addrOf(p) != null);
+    delete z;
+    assert(GC.addrOf(p) == null);
+    assert(countDtor == 10000 + 400);
+}
+
+/**
+ *
+ */
+extern (C) void _d_delmemory(void* *p)
+{
+    if (*p)
+    {
+        GC.free(*p);
+        *p = null;
+    }
+}
+
+
+/**
+ *
+ */
+extern (C) void _d_callinterfacefinalizer(void *p)
+{
+    if (p)
+    {
+        Interface *pi = **cast(Interface ***)p;
+        Object o = cast(Object)(p - pi.offset);
+        rt_finalize(cast(void*)o);
+    }
+}
+
+
+/**
+ *
+ */
+extern (C) void _d_callfinalizer(void* p)
+{
+    rt_finalize( p );
+}
+
+
+/**
+ *
+ */
+extern (C) void rt_setCollectHandler(CollectHandler h)
+{
+    collectHandler = h;
+}
+
+
+/**
+ *
+ */
+extern (C) CollectHandler rt_getCollectHandler()
+{
+    return collectHandler;
+}
+
+
+/**
+ *
+ */
+extern (C) int rt_hasFinalizerInSegment(void* p, size_t size, uint attr, in void[] segment) nothrow
+{
+    if (attr & BlkAttr.STRUCTFINAL)
+    {
+        if (attr & BlkAttr.APPENDABLE)
+            return hasArrayFinalizerInSegment(p, size, segment);
+        return hasStructFinalizerInSegment(p, size, segment);
+    }
+
+    // otherwise class
+    auto ppv = cast(void**) p;
+    if(!p || !*ppv)
+        return false;
+
+    auto c = *cast(ClassInfo*)*ppv;
+    do
+    {
+        auto pf = c.destructor;
+        if (cast(size_t)(pf - segment.ptr) < segment.length) return true;
+    }
+    while ((c = c.base) !is null);
+
+    return false;
+}
+
+int hasStructFinalizerInSegment(void* p, size_t size, in void[] segment) nothrow
+{
+    if(!p)
+        return false;
+
+    auto ti = *cast(TypeInfo_Struct*)(p + size - size_t.sizeof);
+    return cast(size_t)(cast(void*)ti.xdtor - segment.ptr) < segment.length;
+}
+
+int hasArrayFinalizerInSegment(void* p, size_t size, in void[] segment) nothrow
+{
+    if(!p)
+        return false;
+
+    TypeInfo_Struct si = void;
+    if (size < PAGESIZE)
+        si = *cast(TypeInfo_Struct*)(p + size - size_t.sizeof);
+    else
+        si = *cast(TypeInfo_Struct*)(p + size_t.sizeof);
+
+    return cast(size_t)(cast(void*)si.xdtor - segment.ptr) < segment.length;
+}
+
+// called by the GC
+void finalize_array2(void* p, size_t size) nothrow
+{
+    debug(PRINTF) printf("rt_finalize_array2(p = %p)\n", p);
+
+    TypeInfo_Struct si = void;
+    if(size <= 256)
+    {
+        si = *cast(TypeInfo_Struct*)(p + size - size_t.sizeof);
+        size = *cast(ubyte*)(p + size - size_t.sizeof - SMALLPAD);
+    }
+    else if (size < PAGESIZE)
+    {
+        si = *cast(TypeInfo_Struct*)(p + size - size_t.sizeof);
+        size = *cast(ushort*)(p + size - size_t.sizeof - MEDPAD);
+    }
+    else
+    {
+        si = *cast(TypeInfo_Struct*)(p + size_t.sizeof);
+        size = *cast(size_t*)p;
+        p += LARGEPREFIX;
+    }
+
+    try
+    {
+        finalize_array(p, size, si);
+    }
+    catch (Exception e)
+    {
+        onFinalizeError(si, e);
+    }
+}
+
+void finalize_array(void* p, size_t size, const TypeInfo_Struct si)
+{
+    // Due to the fact that the delete operator calls destructors
+    // for arrays from the last element to the first, we maintain
+    // compatibility here by doing the same.
+    auto tsize = si.tsize;
+    for (auto curP = p + size - tsize; curP >= p; curP -= tsize)
+    {
+        // call destructor
+        si.destroy(curP);
+    }
+}
+
+// called by the GC
+void finalize_struct(void* p, size_t size) nothrow
+{
+    debug(PRINTF) printf("finalize_struct(p = %p)\n", p);
+
+    auto ti = *cast(TypeInfo_Struct*)(p + size - size_t.sizeof);
+    try
+    {
+        ti.destroy(p); // call destructor
+    }
+    catch (Exception e)
+    {
+        onFinalizeError(ti, e);
+    }
+}
+
+/**
+ *
+ */
+extern (C) void rt_finalize2(void* p, bool det = true, bool resetMemory = true) nothrow
+{
+    debug(PRINTF) printf("rt_finalize2(p = %p)\n", p);
+
+    auto ppv = cast(void**) p;
+    if(!p || !*ppv)
+        return;
+
+    auto pc = cast(ClassInfo*) *ppv;
+    try
+    {
+        if (det || collectHandler is null || collectHandler(cast(Object) p))
+        {
+            auto c = *pc;
+            do
+            {
+                if (c.destructor)
+                    (cast(fp_t) c.destructor)(cast(Object) p); // call destructor
+            }
+            while ((c = c.base) !is null);
+        }
+
+        if (ppv[1]) // if monitor is not null
+            _d_monitordelete(cast(Object) p, det);
+
+        if (resetMemory)
+        {
+            auto w = (*pc).initializer;
+            p[0 .. w.length] = w[];
+        }
+    }
+    catch (Exception e)
+    {
+        onFinalizeError(*pc, e);
+    }
+    finally
+    {
+        *ppv = null; // zero vptr even if `resetMemory` is false
+    }
+}
+
+extern (C) void rt_finalize(void* p, bool det = true)
+{
+    rt_finalize2(p, det, true);
+}
+
+extern (C) void rt_finalizeFromGC(void* p, size_t size, uint attr)
+{
+    // to verify: reset memory necessary?
+    if (!(attr & BlkAttr.STRUCTFINAL))
+        rt_finalize2(p, false, false); // class
+    else if (attr & BlkAttr.APPENDABLE)
+        finalize_array2(p, size); // array of structs
+    else
+        finalize_struct(p, size); // struct
+}
+
+
+/**
+ * Resize dynamic arrays with 0 initializers.
+ */
+extern (C) void[] _d_arraysetlengthT(const TypeInfo ti, size_t newlength, void[]* p)
+in
+{
+    assert(ti);
+    assert(!(*p).length || (*p).ptr);
+}
+body
+{
+    debug(PRINTF)
+    {
+        //printf("_d_arraysetlengthT(p = %p, sizeelem = %d, newlength = %d)\n", p, sizeelem, newlength);
+        if (p)
+            printf("\tp.ptr = %p, p.length = %d\n", (*p).ptr, (*p).length);
+    }
+
+    void* newdata = void;
+    if (newlength)
+    {
+        if (newlength <= (*p).length)
+        {
+            *p = (*p)[0 .. newlength];
+            newdata = (*p).ptr;
+            return newdata[0 .. newlength];
+        }
+        auto tinext = unqualify(ti.next);
+        size_t sizeelem = tinext.tsize;
+        version (D_InlineAsm_X86)
+        {
+            size_t newsize = void;
+
+            asm pure nothrow @nogc
+            {
+                mov EAX, newlength;
+                mul EAX, sizeelem;
+                mov newsize, EAX;
+                jc  Loverflow;
+            }
+        }
+        else version (D_InlineAsm_X86_64)
+        {
+            size_t newsize = void;
+
+            asm pure nothrow @nogc
+            {
+                mov RAX, newlength;
+                mul RAX, sizeelem;
+                mov newsize, RAX;
+                jc  Loverflow;
+            }
+        }
+        else
+        {
+            import core.checkedint : mulu;
+
+            bool overflow = false;
+            size_t newsize = mulu(sizeelem, newlength, overflow);
+            if (overflow)
+                goto Loverflow;
+        }
+
+        debug(PRINTF) printf("newsize = %x, newlength = %x\n", newsize, newlength);
+
+        auto   isshared = typeid(ti) is typeid(TypeInfo_Shared);
+
+        if ((*p).ptr)
+        {
+            newdata = (*p).ptr;
+            if (newlength > (*p).length)
+            {
+                size_t size = (*p).length * sizeelem;
+                auto   bic = isshared ? null : __getBlkInfo((*p).ptr);
+                auto   info = bic ? *bic : GC.query((*p).ptr);
+                if(info.base && (info.attr & BlkAttr.APPENDABLE))
+                {
+                    // calculate the extent of the array given the base.
+                    size_t offset = (*p).ptr - __arrayStart(info);
+                    if(info.size >= PAGESIZE)
+                    {
+                        // size of array is at the front of the block
+                        if(!__setArrayAllocLength(info, newsize + offset, isshared, tinext, size + offset))
+                        {
+                            // check to see if it failed because there is not
+                            // enough space
+                            if(*(cast(size_t*)info.base) == size + offset)
+                            {
+                                // not enough space, try extending
+                                auto extendsize = newsize + offset + LARGEPAD - info.size;
+                                auto u = GC.extend(info.base, extendsize, extendsize);
+                                if(u)
+                                {
+                                    // extend worked, now try setting the length
+                                    // again.
+                                    info.size = u;
+                                    if(__setArrayAllocLength(info, newsize + offset, isshared, tinext, size + offset))
+                                    {
+                                        if(!isshared)
+                                            __insertBlkInfoCache(info, bic);
+                                        goto L1;
+                                    }
+                                }
+                            }
+
+                            // couldn't do it, reallocate
+                            goto L2;
+                        }
+                        else if(!isshared && !bic)
+                        {
+                            // add this to the cache, it wasn't present previously.
+                            __insertBlkInfoCache(info, null);
+                        }
+                    }
+                    else if(!__setArrayAllocLength(info, newsize + offset, isshared, tinext, size + offset))
+                    {
+                        // could not resize in place
+                        goto L2;
+                    }
+                    else if(!isshared && !bic)
+                    {
+                        // add this to the cache, it wasn't present previously.
+                        __insertBlkInfoCache(info, null);
+                    }
+                }
+                else
+                {
+                    if(info.base)
+                    {
+                L2:
+                        if(bic)
+                        {
+                            // a chance that flags have changed since this was cached, we should fetch the most recent flags
+                            info.attr = GC.getAttr(info.base) | BlkAttr.APPENDABLE;
+                        }
+                        info = __arrayAlloc(newsize, info, ti, tinext);
+                    }
+                    else
+                    {
+                        info = __arrayAlloc(newsize, ti, tinext);
+                    }
+                    __setArrayAllocLength(info, newsize, isshared, tinext);
+                    if(!isshared)
+                        __insertBlkInfoCache(info, bic);
+                    newdata = cast(byte *)__arrayStart(info);
+                    newdata[0 .. size] = (*p).ptr[0 .. size];
+
+                    // do postblit processing
+                    __doPostblit(newdata, size, tinext);
+                }
+             L1:
+                memset(newdata + size, 0, newsize - size);
+            }
+        }
+        else
+        {
+            // pointer was null, need to allocate
+            auto info = __arrayAlloc(newsize, ti, tinext);
+            __setArrayAllocLength(info, newsize, isshared, tinext);
+            if(!isshared)
+                __insertBlkInfoCache(info, null);
+            newdata = cast(byte *)__arrayStart(info);
+            memset(newdata, 0, newsize);
+        }
+    }
+    else
+    {
+        newdata = (*p).ptr;
+    }
+
+    *p = newdata[0 .. newlength];
+    return *p;
+
+Loverflow:
+    onOutOfMemoryError();
+    assert(0);
+}
+
+
+/**
+ * Resize arrays for non-zero initializers.
+ *      p               pointer to array lvalue to be updated
+ *      newlength       new .length property of array
+ *      sizeelem        size of each element of array
+ *      initsize        size of initializer
+ *      ...             initializer
+ */
+extern (C) void[] _d_arraysetlengthiT(const TypeInfo ti, size_t newlength, void[]* p)
+in
+{
+    assert(!(*p).length || (*p).ptr);
+}
+body
+{
+    void* newdata;
+    auto tinext = unqualify(ti.next);
+    auto sizeelem = tinext.tsize;
+    auto initializer = tinext.initializer();
+    auto initsize = initializer.length;
+
+    assert(sizeelem);
+    assert(initsize);
+    assert(initsize <= sizeelem);
+    assert((sizeelem / initsize) * initsize == sizeelem);
+
+    debug(PRINTF)
+    {
+        printf("_d_arraysetlengthiT(p = %p, sizeelem = %d, newlength = %d, initsize = %d)\n", p, sizeelem, newlength, initsize);
+        if (p)
+            printf("\tp.data = %p, p.length = %d\n", (*p).ptr, (*p).length);
+    }
+
+    if (newlength)
+    {
+        version (D_InlineAsm_X86)
+        {
+            size_t newsize = void;
+
+            asm
+            {
+                mov     EAX,newlength   ;
+                mul     EAX,sizeelem    ;
+                mov     newsize,EAX     ;
+                jc      Loverflow       ;
+            }
+        }
+        else version (D_InlineAsm_X86_64)
+        {
+            size_t newsize = void;
+
+            asm
+            {
+                mov     RAX,newlength   ;
+                mul     RAX,sizeelem    ;
+                mov     newsize,RAX     ;
+                jc      Loverflow       ;
+            }
+        }
+        else
+        {
+            import core.checkedint : mulu;
+
+            bool overflow = false;
+            size_t newsize = mulu(sizeelem, newlength, overflow);
+            if (overflow)
+                goto Loverflow;
+        }
+        debug(PRINTF) printf("newsize = %x, newlength = %x\n", newsize, newlength);
+
+
+        size_t size = (*p).length * sizeelem;
+        auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
+        if ((*p).ptr)
+        {
+            newdata = (*p).ptr;
+            if (newlength > (*p).length)
+            {
+                auto   bic = isshared ? null : __getBlkInfo((*p).ptr);
+                auto   info = bic ? *bic : GC.query((*p).ptr);
+
+                // calculate the extent of the array given the base.
+                size_t offset = (*p).ptr - __arrayStart(info);
+                if(info.base && (info.attr & BlkAttr.APPENDABLE))
+                {
+                    if(info.size >= PAGESIZE)
+                    {
+                        // size of array is at the front of the block
+                        if(!__setArrayAllocLength(info, newsize + offset, isshared, tinext, size + offset))
+                        {
+                            // check to see if it failed because there is not
+                            // enough space
+                            if(*(cast(size_t*)info.base) == size + offset)
+                            {
+                                // not enough space, try extending
+                                auto extendsize = newsize + offset + LARGEPAD - info.size;
+                                auto u = GC.extend(info.base, extendsize, extendsize);
+                                if(u)
+                                {
+                                    // extend worked, now try setting the length
+                                    // again.
+                                    info.size = u;
+                                    if(__setArrayAllocLength(info, newsize + offset, isshared, tinext, size + offset))
+                                    {
+                                        if(!isshared)
+                                            __insertBlkInfoCache(info, bic);
+                                        goto L1;
+                                    }
+                                }
+                            }
+
+                            // couldn't do it, reallocate
+                            goto L2;
+                        }
+                        else if(!isshared && !bic)
+                        {
+                            // add this to the cache, it wasn't present previously.
+                            __insertBlkInfoCache(info, null);
+                        }
+                    }
+                    else if(!__setArrayAllocLength(info, newsize + offset, isshared, tinext, size + offset))
+                    {
+                        // could not resize in place
+                        goto L2;
+                    }
+                    else if(!isshared && !bic)
+                    {
+                        // add this to the cache, it wasn't present previously.
+                        __insertBlkInfoCache(info, null);
+                    }
+                }
+                else
+                {
+                    // not appendable or not part of the heap yet.
+                    if(info.base)
+                    {
+                L2:
+                        if(bic)
+                        {
+                            // a chance that flags have changed since this was cached, we should fetch the most recent flags
+                            info.attr = GC.getAttr(info.base) | BlkAttr.APPENDABLE;
+                        }
+                        info = __arrayAlloc(newsize, info, ti, tinext);
+                    }
+                    else
+                    {
+                        info = __arrayAlloc(newsize, ti, tinext);
+                    }
+                    __setArrayAllocLength(info, newsize, isshared, tinext);
+                    if(!isshared)
+                        __insertBlkInfoCache(info, bic);
+                    newdata = cast(byte *)__arrayStart(info);
+                    newdata[0 .. size] = (*p).ptr[0 .. size];
+
+                    // do postblit processing
+                    __doPostblit(newdata, size, tinext);
+                }
+                L1: ;
+            }
+        }
+        else
+        {
+            // length was zero, need to allocate
+            auto info = __arrayAlloc(newsize, ti, tinext);
+            __setArrayAllocLength(info, newsize, isshared, tinext);
+            if(!isshared)
+                __insertBlkInfoCache(info, null);
+            newdata = cast(byte *)__arrayStart(info);
+        }
+
+        auto q = initializer.ptr; // pointer to initializer
+
+        if (newsize > size)
+        {
+            if (initsize == 1)
+            {
+                debug(PRINTF) printf("newdata = %p, size = %d, newsize = %d, *q = %d\n", newdata, size, newsize, *cast(byte*)q);
+                memset(newdata + size, *cast(byte*)q, newsize - size);
+            }
+            else
+            {
+                for (size_t u = size; u < newsize; u += initsize)
+                {
+                    memcpy(newdata + u, q, initsize);
+                }
+            }
+        }
+    }
+    else
+    {
+        newdata = (*p).ptr;
+    }
+
+    *p = newdata[0 .. newlength];
+    return *p;
+
+Loverflow:
+    onOutOfMemoryError();
+    assert(0);
+}
+
+
+/**
+ * Append y[] to array x[]
+ */
+extern (C) void[] _d_arrayappendT(const TypeInfo ti, ref byte[] x, byte[] y)
+{
+    auto length = x.length;
+    auto tinext = unqualify(ti.next);
+    auto sizeelem = tinext.tsize;              // array element size
+    _d_arrayappendcTX(ti, x, y.length);
+    memcpy(x.ptr + length * sizeelem, y.ptr, y.length * sizeelem);
+
+    // do postblit
+    __doPostblit(x.ptr + length * sizeelem, y.length * sizeelem, tinext);
+    return x;
+}
+
+
+/**
+ *
+ */
+size_t newCapacity(size_t newlength, size_t size)
+{
+    version(none)
+    {
+        size_t newcap = newlength * size;
+    }
+    else
+    {
+        /*
+         * Better version by Dave Fladebo:
+         * This uses an inverse logorithmic algorithm to pre-allocate a bit more
+         * space for larger arrays.
+         * - Arrays smaller than PAGESIZE bytes are left as-is, so for the most
+         * common cases, memory allocation is 1 to 1. The small overhead added
+         * doesn't affect small array perf. (it's virtually the same as
+         * current).
+         * - Larger arrays have some space pre-allocated.
+         * - As the arrays grow, the relative pre-allocated space shrinks.
+         * - The logorithmic algorithm allocates relatively more space for
+         * mid-size arrays, making it very fast for medium arrays (for
+         * mid-to-large arrays, this turns out to be quite a bit faster than the
+         * equivalent realloc() code in C, on Linux at least. Small arrays are
+         * just as fast as GCC).
+         * - Perhaps most importantly, overall memory usage and stress on the GC
+         * is decreased significantly for demanding environments.
+         */
+        size_t newcap = newlength * size;
+        size_t newext = 0;
+
+        if (newcap > PAGESIZE)
+        {
+            //double mult2 = 1.0 + (size / log10(pow(newcap * 2.0,2.0)));
+
+            // redo above line using only integer math
+
+            /*static int log2plus1(size_t c)
+            {   int i;
+
+                if (c == 0)
+                    i = -1;
+                else
+                    for (i = 1; c >>= 1; i++)
+                    {
+                    }
+                return i;
+            }*/
+
+            /* The following setting for mult sets how much bigger
+             * the new size will be over what is actually needed.
+             * 100 means the same size, more means proportionally more.
+             * More means faster but more memory consumption.
+             */
+            //long mult = 100 + (1000L * size) / (6 * log2plus1(newcap));
+            //long mult = 100 + (1000L * size) / log2plus1(newcap);
+            long mult = 100 + (1000L) / (bsr(newcap) + 1);
+
+            // testing shows 1.02 for large arrays is about the point of diminishing return
+            //
+            // Commented out because the multipler will never be < 102.  In order for it to be < 2,
+            // then 1000L / (bsr(x) + 1) must be > 2.  The highest bsr(x) + 1
+            // could be is 65 (64th bit set), and 1000L / 64 is much larger
+            // than 2.  We need 500 bit integers for 101 to be achieved :)
+            /*if (mult < 102)
+                mult = 102;*/
+            /*newext = cast(size_t)((newcap * mult) / 100);
+            newext -= newext % size;*/
+            // This version rounds up to the next element, and avoids using
+            // mod.
+            newext = cast(size_t)((newlength * mult + 99) / 100) * size;
+            debug(PRINTF) printf("mult: %2.2f, alloc: %2.2f\n",mult/100.0,newext / cast(double)size);
+        }
+        newcap = newext > newcap ? newext : newcap;
+        debug(PRINTF) printf("newcap = %d, newlength = %d, size = %d\n", newcap, newlength, size);
+    }
+    return newcap;
+}
+
+
+/**************************************
+ * Extend an array by n elements.
+ * Caller must initialize those elements.
+ */
+extern (C)
+byte[] _d_arrayappendcTX(const TypeInfo ti, ref byte[] px, size_t n)
+{
+    // This is a cut&paste job from _d_arrayappendT(). Should be refactored.
+
+    // only optimize array append where ti is not a shared type
+    auto tinext = unqualify(ti.next);
+    auto sizeelem = tinext.tsize;              // array element size
+    auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
+    auto bic = isshared ? null : __getBlkInfo(px.ptr);
+    auto info = bic ? *bic : GC.query(px.ptr);
+    auto length = px.length;
+    auto newlength = length + n;
+    auto newsize = newlength * sizeelem;
+    auto size = length * sizeelem;
+    size_t newcap = void; // for scratch space
+
+    // calculate the extent of the array given the base.
+    size_t offset = px.ptr - __arrayStart(info);
+    if(info.base && (info.attr & BlkAttr.APPENDABLE))
+    {
+        if(info.size >= PAGESIZE)
+        {
+            // size of array is at the front of the block
+            if(!__setArrayAllocLength(info, newsize + offset, isshared, tinext, size + offset))
+            {
+                // check to see if it failed because there is not
+                // enough space
+                newcap = newCapacity(newlength, sizeelem);
+                if(*(cast(size_t*)info.base) == size + offset)
+                {
+                    // not enough space, try extending
+                    auto extendoffset = offset + LARGEPAD - info.size;
+                    auto u = GC.extend(info.base, newsize + extendoffset, newcap + extendoffset);
+                    if(u)
+                    {
+                        // extend worked, now try setting the length
+                        // again.
+                        info.size = u;
+                        if(__setArrayAllocLength(info, newsize + offset, isshared, tinext, size + offset))
+                        {
+                            if(!isshared)
+                                __insertBlkInfoCache(info, bic);
+                            goto L1;
+                        }
+                    }
+                }
+
+                // couldn't do it, reallocate
+                goto L2;
+            }
+            else if(!isshared && !bic)
+            {
+                __insertBlkInfoCache(info, null);
+            }
+        }
+        else if(!__setArrayAllocLength(info, newsize + offset, isshared, tinext, size + offset))
+        {
+            // could not resize in place
+            newcap = newCapacity(newlength, sizeelem);
+            goto L2;
+        }
+        else if(!isshared && !bic)
+        {
+            __insertBlkInfoCache(info, null);
+        }
+    }
+    else
+    {
+        // not appendable or is null
+        newcap = newCapacity(newlength, sizeelem);
+        if(info.base)
+        {
+    L2:
+            if(bic)
+            {
+                // a chance that flags have changed since this was cached, we should fetch the most recent flags
+                info.attr = GC.getAttr(info.base) | BlkAttr.APPENDABLE;
+            }
+            info = __arrayAlloc(newcap, info, ti, tinext);
+        }
+        else
+        {
+            info = __arrayAlloc(newcap, ti, tinext);
+        }
+        __setArrayAllocLength(info, newsize, isshared, tinext);
+        if(!isshared)
+            __insertBlkInfoCache(info, bic);
+        auto newdata = cast(byte *)__arrayStart(info);
+        memcpy(newdata, px.ptr, length * sizeelem);
+        // do postblit processing
+        __doPostblit(newdata, length * sizeelem, tinext);
+        (cast(void **)(&px))[1] = newdata;
+    }
+
+  L1:
+    *cast(size_t *)&px = newlength;
+    return px;
+}
+
+
+/**
+ * Append dchar to char[]
+ */
+extern (C) void[] _d_arrayappendcd(ref byte[] x, dchar c)
+{
+    // c could encode into from 1 to 4 characters
+    char[4] buf = void;
+    byte[] appendthis; // passed to appendT
+    if (c <= 0x7F)
+    {
+        buf.ptr[0] = cast(char)c;
+        appendthis = (cast(byte *)buf.ptr)[0..1];
+    }
+    else if (c <= 0x7FF)
+    {
+        buf.ptr[0] = cast(char)(0xC0 | (c >> 6));
+        buf.ptr[1] = cast(char)(0x80 | (c & 0x3F));
+        appendthis = (cast(byte *)buf.ptr)[0..2];
+    }
+    else if (c <= 0xFFFF)
+    {
+        buf.ptr[0] = cast(char)(0xE0 | (c >> 12));
+        buf.ptr[1] = cast(char)(0x80 | ((c >> 6) & 0x3F));
+        buf.ptr[2] = cast(char)(0x80 | (c & 0x3F));
+        appendthis = (cast(byte *)buf.ptr)[0..3];
+    }
+    else if (c <= 0x10FFFF)
+    {
+        buf.ptr[0] = cast(char)(0xF0 | (c >> 18));
+        buf.ptr[1] = cast(char)(0x80 | ((c >> 12) & 0x3F));
+        buf.ptr[2] = cast(char)(0x80 | ((c >> 6) & 0x3F));
+        buf.ptr[3] = cast(char)(0x80 | (c & 0x3F));
+        appendthis = (cast(byte *)buf.ptr)[0..4];
+    }
+    else
+        assert(0);      // invalid utf character - should we throw an exception instead?
+
+    //
+    // TODO: This always assumes the array type is shared, because we do not
+    // get a typeinfo from the compiler.  Assuming shared is the safest option.
+    // Once the compiler is fixed, the proper typeinfo should be forwarded.
+    //
+    return _d_arrayappendT(typeid(shared char[]), x, appendthis);
+}
+
+
+/**
+ * Append dchar to wchar[]
+ */
+extern (C) void[] _d_arrayappendwd(ref byte[] x, dchar c)
+{
+    // c could encode into from 1 to 2 w characters
+    wchar[2] buf = void;
+    byte[] appendthis; // passed to appendT
+    if (c <= 0xFFFF)
+    {
+        buf.ptr[0] = cast(wchar) c;
+        // note that although we are passing only 1 byte here, appendT
+        // interprets this as being an array of wchar, making the necessary
+        // casts.
+        appendthis = (cast(byte *)buf.ptr)[0..1];
+    }
+    else
+    {
+        buf.ptr[0] = cast(wchar) ((((c - 0x10000) >> 10) & 0x3FF) + 0xD800);
+        buf.ptr[1] = cast(wchar) (((c - 0x10000) & 0x3FF) + 0xDC00);
+        // ditto from above.
+        appendthis = (cast(byte *)buf.ptr)[0..2];
+    }
+
+    //
+    // TODO: This always assumes the array type is shared, because we do not
+    // get a typeinfo from the compiler.  Assuming shared is the safest option.
+    // Once the compiler is fixed, the proper typeinfo should be forwarded.
+    //
+    return _d_arrayappendT(typeid(shared wchar[]), x, appendthis);
+}
+
+
+/**
+ *
+ */
+extern (C) byte[] _d_arraycatT(const TypeInfo ti, byte[] x, byte[] y)
+out (result)
+{
+    auto tinext = unqualify(ti.next);
+    auto sizeelem = tinext.tsize;              // array element size
+    debug(PRINTF) printf("_d_arraycatT(%d,%p ~ %d,%p sizeelem = %d => %d,%p)\n", x.length, x.ptr, y.length, y.ptr, sizeelem, result.length, result.ptr);
+    assert(result.length == x.length + y.length);
+
+    // If a postblit is involved, the contents of result might rightly differ
+    // from the bitwise concatenation of x and y.
+    if (!hasPostblit(tinext))
+    {
+        for (size_t i = 0; i < x.length * sizeelem; i++)
+            assert((cast(byte*)result)[i] == (cast(byte*)x)[i]);
+        for (size_t i = 0; i < y.length * sizeelem; i++)
+            assert((cast(byte*)result)[x.length * sizeelem + i] == (cast(byte*)y)[i]);
+    }
+
+    size_t cap = GC.sizeOf(result.ptr);
+    assert(!cap || cap > result.length * sizeelem);
+}
+body
+{
+    version (none)
+    {
+        /* Cannot use this optimization because:
+         *  char[] a, b;
+         *  char c = 'a';
+         *  b = a ~ c;
+         *  c = 'b';
+         * will change the contents of b.
+         */
+        if (!y.length)
+            return x;
+        if (!x.length)
+            return y;
+    }
+
+    auto tinext = unqualify(ti.next);
+    auto sizeelem = tinext.tsize;              // array element size
+    debug(PRINTF) printf("_d_arraycatT(%d,%p ~ %d,%p sizeelem = %d)\n", x.length, x.ptr, y.length, y.ptr, sizeelem);
+    size_t xlen = x.length * sizeelem;
+    size_t ylen = y.length * sizeelem;
+    size_t len  = xlen + ylen;
+
+    if (!len)
+        return null;
+
+    auto info = __arrayAlloc(len, ti, tinext);
+    byte* p = cast(byte*)__arrayStart(info);
+    p[len] = 0; // guessing this is to optimize for null-terminated arrays?
+    memcpy(p, x.ptr, xlen);
+    memcpy(p + xlen, y.ptr, ylen);
+    // do postblit processing
+    __doPostblit(p, xlen + ylen, tinext);
+
+    auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
+    __setArrayAllocLength(info, len, isshared, tinext);
+    return p[0 .. x.length + y.length];
+}
+
+
+/**
+ *
+ */
+extern (C) void[] _d_arraycatnTX(const TypeInfo ti, byte[][] arrs)
+{
+    size_t length;
+    auto tinext = unqualify(ti.next);
+    auto size = tinext.tsize;   // array element size
+
+    foreach(b; arrs)
+        length += b.length;
+
+    if (!length)
+        return null;
+
+    auto allocsize = length * size;
+    auto info = __arrayAlloc(allocsize, ti, tinext);
+    auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
+    __setArrayAllocLength(info, allocsize, isshared, tinext);
+    void *a = __arrayStart (info);
+
+    size_t j = 0;
+    foreach(b; arrs)
+    {
+        if (b.length)
+        {
+            memcpy(a + j, b.ptr, b.length * size);
+            j += b.length * size;
+        }
+    }
+
+    // do postblit processing
+    __doPostblit(a, j, tinext);
+
+    return a[0..length];
+}
+
+
+/**
+ * Allocate the array, rely on the caller to do the initialization of the array.
+ */
+extern (C)
+void* _d_arrayliteralTX(const TypeInfo ti, size_t length)
+{
+    auto tinext = unqualify(ti.next);
+    auto sizeelem = tinext.tsize;              // array element size
+    void* result;
+
+    debug(PRINTF) printf("_d_arrayliteralTX(sizeelem = %d, length = %d)\n", sizeelem, length);
+    if (length == 0 || sizeelem == 0)
+        result = null;
+    else
+    {
+        auto allocsize = length * sizeelem;
+        auto info = __arrayAlloc(allocsize, ti, tinext);
+        auto isshared = typeid(ti) is typeid(TypeInfo_Shared);
+        __setArrayAllocLength(info, allocsize, isshared, tinext);
+        result = __arrayStart(info);
+    }
+    return result;
+}
+
+
+unittest
+{
+    int[] a;
+    int[] b;
+    int i;
+
+    a = new int[3];
+    a[0] = 1; a[1] = 2; a[2] = 3;
+    b = a.dup;
+    assert(b.length == 3);
+    for (i = 0; i < 3; i++)
+        assert(b[i] == i + 1);
+
+    // test slice appending
+    b = a[0..1];
+    b ~= 4;
+    for(i = 0; i < 3; i++)
+        assert(a[i] == i + 1);
+
+    // test reserving
+    char[] arr = new char[4093];
+    for(i = 0; i < arr.length; i++)
+        arr[i] = cast(char)(i % 256);
+
+    // note that these two commands used to cause corruption, which may not be
+    // detected.
+    arr.reserve(4094);
+    auto arr2 = arr ~ "123";
+    assert(arr2[0..arr.length] == arr);
+    assert(arr2[arr.length..$] == "123");
+
+    // test postblit on array concat, append, length, etc.
+    static struct S
+    {
+        int x;
+        int pad;
+        this(this)
+        {
+            ++x;
+        }
+    }
+    void testPostBlit(T)()
+    {
+        auto sarr = new T[1];
+        debug(SENTINEL) {} else
+            assert(sarr.capacity == 1);
+
+        // length extend
+        auto sarr2 = sarr;
+        assert(sarr[0].x == 0);
+        sarr2.length += 1;
+        assert(sarr2[0].x == 1);
+        assert(sarr[0].x == 0);
+
+        // append
+        T s;
+        sarr2 = sarr;
+        sarr2 ~= s;
+        assert(sarr2[0].x == 1);
+        assert(sarr2[1].x == 1);
+        assert(sarr[0].x == 0);
+        assert(s.x == 0);
+
+        // concat
+        sarr2 = sarr ~ sarr;
+        assert(sarr2[0].x == 1);
+        assert(sarr2[1].x == 1);
+        assert(sarr[0].x == 0);
+
+        // concat multiple (calls different method)
+        sarr2 = sarr ~ sarr ~ sarr;
+        assert(sarr2[0].x == 1);
+        assert(sarr2[1].x == 1);
+        assert(sarr2[2].x == 1);
+        assert(sarr[0].x == 0);
+
+        // reserve capacity
+        sarr2 = sarr;
+        sarr2.reserve(2);
+        assert(sarr2[0].x == 1);
+        assert(sarr[0].x == 0);
+    }
+    testPostBlit!(S)();
+    testPostBlit!(const(S))();
+}
+
+// cannot define structs inside unit test block, or they become nested structs.
+version(unittest)
+{
+    struct S1
+    {
+        int x = 5;
+    }
+    struct S2
+    {
+        int x;
+        this(int x) {this.x = x;}
+    }
+    struct S3
+    {
+        int[4] x;
+        this(int x)
+        {this.x[] = x;}
+    }
+    struct S4
+    {
+        int *x;
+    }
+
+}
+
+unittest
+{
+    auto s1 = new S1;
+    assert(s1.x == 5);
+    assert(GC.getAttr(s1) == BlkAttr.NO_SCAN);
+
+    auto s2 = new S2(3);
+    assert(s2.x == 3);
+    assert(GC.getAttr(s2) == BlkAttr.NO_SCAN);
+
+    auto s3 = new S3(1);
+    assert(s3.x == [1,1,1,1]);
+    assert(GC.getAttr(s3) == BlkAttr.NO_SCAN);
+    debug(SENTINEL) {} else
+        assert(GC.sizeOf(s3) == 16);
+
+    auto s4 = new S4;
+    assert(s4.x == null);
+    assert(GC.getAttr(s4) == 0);
+}
+
+unittest
+{
+    // Bugzilla 3454 - Inconsistent flag setting in GC.realloc()
+    static void test(size_t multiplier)
+    {
+        auto p = GC.malloc(8 * multiplier, BlkAttr.NO_SCAN);
+        assert(GC.getAttr(p) == BlkAttr.NO_SCAN);
+        p = GC.realloc(p, 2 * multiplier, BlkAttr.NO_SCAN);
+        assert(GC.getAttr(p) == BlkAttr.NO_SCAN);
+    }
+    test(1);
+    test(1024 * 1024);
+}
+
+unittest
+{
+    import core.exception;
+    try
+    {
+        size_t x = size_t.max;
+        byte[] big_buf = new byte[x];
+    }
+    catch(OutOfMemoryError)
+    {
+    }
+}
+
+unittest
+{
+    // bugzilla 13854
+    auto arr = new ubyte[PAGESIZE]; // ensure page size
+    auto info1 = GC.query(arr.ptr);
+    assert(info1.base !is arr.ptr); // offset is required for page size or larger
+
+    auto arr2 = arr[0..1];
+    assert(arr2.capacity == 0); // cannot append
+    arr2 ~= 0; // add a byte
+    assert(arr2.ptr !is arr.ptr); // reallocated
+    auto info2 = GC.query(arr2.ptr);
+    assert(info2.base is arr2.ptr); // no offset, the capacity is small.
+
+    // do the same via setting length
+    arr2 = arr[0..1];
+    assert(arr2.capacity == 0);
+    arr2.length += 1;
+    assert(arr2.ptr !is arr.ptr); // reallocated
+    info2 = GC.query(arr2.ptr);
+    assert(info2.base is arr2.ptr); // no offset, the capacity is small.
+
+    // do the same for char[] since we need a type with an initializer to test certain runtime functions
+    auto carr = new char[PAGESIZE];
+    info1 = GC.query(carr.ptr);
+    assert(info1.base !is carr.ptr); // offset is required for page size or larger
+
+    auto carr2 = carr[0..1];
+    assert(carr2.capacity == 0); // cannot append
+    carr2 ~= 0; // add a byte
+    assert(carr2.ptr !is carr.ptr); // reallocated
+    info2 = GC.query(carr2.ptr);
+    assert(info2.base is carr2.ptr); // no offset, the capacity is small.
+
+    // do the same via setting length
+    carr2 = carr[0..1];
+    assert(carr2.capacity == 0);
+    carr2.length += 1;
+    assert(carr2.ptr !is carr.ptr); // reallocated
+    info2 = GC.query(carr2.ptr);
+    assert(info2.base is carr2.ptr); // no offset, the capacity is small.
+}
+
+unittest
+{
+    // bugzilla 13878
+    auto arr = new ubyte[1];
+    auto info = GC.query(arr.ptr);
+    assert(info.attr & BlkAttr.NO_SCAN); // should be NO_SCAN
+    arr ~= 0; // ensure array is inserted into cache
+    debug(SENTINEL) {} else
+        assert(arr.ptr is info.base);
+    GC.clrAttr(arr.ptr, BlkAttr.NO_SCAN); // remove the attribute
+    auto arr2 = arr[0..1];
+    assert(arr2.capacity == 0); // cannot append
+    arr2 ~= 0;
+    assert(arr2.ptr !is arr.ptr);
+    info = GC.query(arr2.ptr);
+    assert(!(info.attr & BlkAttr.NO_SCAN)); // ensure attribute sticks
+
+    // do the same via setting length
+    arr = new ubyte[1];
+    arr ~= 0; // ensure array is inserted into cache
+    GC.clrAttr(arr.ptr, BlkAttr.NO_SCAN); // remove the attribute
+    arr2 = arr[0..1];
+    assert(arr2.capacity == 0);
+    arr2.length += 1;
+    assert(arr2.ptr !is arr.ptr); // reallocated
+    info = GC.query(arr2.ptr);
+    assert(!(info.attr & BlkAttr.NO_SCAN)); // ensure attribute sticks
+
+    // do the same for char[] since we need a type with an initializer to test certain runtime functions
+    auto carr = new char[1];
+    info = GC.query(carr.ptr);
+    assert(info.attr & BlkAttr.NO_SCAN); // should be NO_SCAN
+    carr ~= 0; // ensure array is inserted into cache
+    debug(SENTINEL) {} else
+        assert(carr.ptr is info.base);
+    GC.clrAttr(carr.ptr, BlkAttr.NO_SCAN); // remove the attribute
+    auto carr2 = carr[0..1];
+    assert(carr2.capacity == 0); // cannot append
+    carr2 ~= 0;
+    assert(carr2.ptr !is carr.ptr);
+    info = GC.query(carr2.ptr);
+    assert(!(info.attr & BlkAttr.NO_SCAN)); // ensure attribute sticks
+
+    // do the same via setting length
+    carr = new char[1];
+    carr ~= 0; // ensure array is inserted into cache
+    GC.clrAttr(carr.ptr, BlkAttr.NO_SCAN); // remove the attribute
+    carr2 = carr[0..1];
+    assert(carr2.capacity == 0);
+    carr2.length += 1;
+    assert(carr2.ptr !is carr.ptr); // reallocated
+    info = GC.query(carr2.ptr);
+    assert(!(info.attr & BlkAttr.NO_SCAN)); // ensure attribute sticks
+}
+
+// test struct finalizers
+debug(SENTINEL) {} else
+unittest
+{
+    __gshared int dtorCount;
+    static struct S1
+    {
+        int x;
+
+        ~this()
+        {
+            dtorCount++;
+        }
+    }
+
+    dtorCount = 0;
+    S1* s1 = new S1;
+    delete s1;
+    assert(dtorCount == 1);
+
+    dtorCount = 0;
+    S1[] arr1 = new S1[7];
+    delete arr1;
+    assert(dtorCount == 7);
+
+    if (callStructDtorsDuringGC)
+    {
+        dtorCount = 0;
+        S1* s2 = new S1;
+        GC.runFinalizers((cast(char*)(typeid(S1).xdtor))[0..1]);
+        assert(dtorCount == 1);
+        GC.free(s2);
+
+        dtorCount = 0;
+        const(S1)* s3 = new const(S1);
+        GC.runFinalizers((cast(char*)(typeid(S1).xdtor))[0..1]);
+        assert(dtorCount == 1);
+        GC.free(cast(void*)s3);
+
+        dtorCount = 0;
+        shared(S1)* s4 = new shared(S1);
+        GC.runFinalizers((cast(char*)(typeid(S1).xdtor))[0..1]);
+        assert(dtorCount == 1);
+        GC.free(cast(void*)s4);
+
+        dtorCount = 0;
+        const(S1)[] carr1 = new const(S1)[5];
+        BlkInfo blkinf1 = GC.query(carr1.ptr);
+        GC.runFinalizers((cast(char*)(typeid(S1).xdtor))[0..1]);
+        assert(dtorCount == 5);
+        GC.free(blkinf1.base);
+    }
+
+    dtorCount = 0;
+    S1[] arr2 = new S1[10];
+    arr2.length = 6;
+    arr2.assumeSafeAppend;
+    assert(dtorCount == 4); // destructors run explicitely?
+
+    if (callStructDtorsDuringGC)
+    {
+        dtorCount = 0;
+        BlkInfo blkinf = GC.query(arr2.ptr);
+        GC.runFinalizers((cast(char*)(typeid(S1).xdtor))[0..1]);
+        assert(dtorCount == 6);
+        GC.free(blkinf.base);
+    }
+
+    // associative arrays
+    import rt.aaA : entryDtor;
+    // throw away all existing AA entries with dtor
+    GC.runFinalizers((cast(char*)(&entryDtor))[0..1]);
+
+    S1[int] aa1;
+    aa1[0] = S1(0);
+    aa1[1] = S1(1);
+    if (callStructDtorsDuringGC)
+    {
+        dtorCount = 0;
+        aa1 = null;
+        GC.runFinalizers((cast(char*)(&entryDtor))[0..1]);
+        assert(dtorCount == 2);
+    }
+
+    int[S1] aa2;
+    aa2[S1(0)] = 0;
+    aa2[S1(1)] = 1;
+    aa2[S1(2)] = 2;
+    if (callStructDtorsDuringGC)
+    {
+        dtorCount = 0;
+        aa2 = null;
+        GC.runFinalizers((cast(char*)(&entryDtor))[0..1]);
+        assert(dtorCount == 3);
+    }
+
+    S1[2][int] aa3;
+    aa3[0] = [S1(0),S1(2)];
+    aa3[1] = [S1(1),S1(3)];
+    if (callStructDtorsDuringGC)
+    {
+        dtorCount = 0;
+        aa3 = null;
+        GC.runFinalizers((cast(char*)(&entryDtor))[0..1]);
+        assert(dtorCount == 4);
+    }
+}
+
+// test class finalizers exception handling
+unittest
+{
+    bool test(E)()
+    {
+        import core.exception;
+        static class C1
+        {
+            E exc;
+            this(E exc) { this.exc = exc; }
+            ~this() { throw exc; }
+        }
+
+        bool caught = false;
+        C1 c = new C1(new E("test onFinalizeError"));
+        try
+        {
+            GC.runFinalizers((cast(uint*)&C1.__dtor)[0..1]);
+        }
+        catch(FinalizeError err)
+        {
+            caught = true;
+        }
+        catch(E)
+        {
+        }
+        GC.free(cast(void*)c);
+        return caught;
+    }
+
+    assert( test!Exception);
+    import core.exception : InvalidMemoryOperationError;
+    assert(!test!InvalidMemoryOperationError);
+}
+
+// test struct finalizers exception handling
+debug(SENTINEL) {} else
+unittest
+{
+    if (!callStructDtorsDuringGC)
+        return;
+
+    bool test(E)()
+    {
+        import core.exception;
+        static struct S1
+        {
+            E exc;
+            ~this() { throw exc; }
+        }
+
+        bool caught = false;
+        S1* s = new S1(new E("test onFinalizeError"));
+        try
+        {
+            GC.runFinalizers((cast(char*)(typeid(S1).xdtor))[0..1]);
+        }
+        catch(FinalizeError err)
+        {
+            caught = true;
+        }
+        catch(E)
+        {
+        }
+        GC.free(s);
+        return caught;
+    }
+
+    assert( test!Exception);
+    import core.exception : InvalidMemoryOperationError;
+    assert(!test!InvalidMemoryOperationError);
+}
+
+// test bug 14126
+unittest
+{
+    static struct S
+    {
+        S* thisptr;
+        ~this() { assert(&this == thisptr); thisptr = null;}
+    }
+
+    S[] test14126 = new S[2048]; // make sure we allocate at least a PAGE
+    foreach(ref s; test14126)
+    {
+        s.thisptr = &s;
+    }
+}
diff --git a/libphobos/libdruntime/rt/memory.d b/libphobos/libdruntime/rt/memory.d
new file mode 100644
index 00000000000..220b3d24e5a
--- /dev/null
+++ b/libphobos/libdruntime/rt/memory.d
@@ -0,0 +1,26 @@
+/**
+ * This module tells the garbage collector about the static data and bss segments,
+ * so the GC can scan them for roots. It does not deal with thread local static data.
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2012.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Walter Bright, Sean Kelly
+ * Source: $(DRUNTIMESRC src/rt/_memory.d)
+ */
+
+module rt.memory;
+
+
+import core.memory;
+import rt.sections;
+
+void initStaticDataGC()
+{
+    foreach (ref sg; SectionGroup)
+    {
+        foreach (rng; sg.gcRanges)
+            GC.addRange(rng.ptr, rng.length);
+    }
+}
diff --git a/libphobos/libdruntime/rt/minfo.d b/libphobos/libdruntime/rt/minfo.d
new file mode 100644
index 00000000000..94aa32a806b
--- /dev/null
+++ b/libphobos/libdruntime/rt/minfo.d
@@ -0,0 +1,585 @@
+/**
+ * Written in the D programming language.
+ * Module initialization routines.
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2013.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Walter Bright, Sean Kelly
+ * Source: $(DRUNTIMESRC src/rt/_minfo.d)
+ */
+
+module rt.minfo;
+
+import core.stdc.stdlib;  // alloca
+import core.stdc.string;  // memcpy
+import rt.sections;
+
+enum
+{
+    MIctorstart  = 0x1,   // we've started constructing it
+    MIctordone   = 0x2,   // finished construction
+    MIstandalone = 0x4,   // module ctor does not depend on other module
+                        // ctors being done first
+    MItlsctor    = 8,
+    MItlsdtor    = 0x10,
+    MIctor       = 0x20,
+    MIdtor       = 0x40,
+    MIxgetMembers = 0x80,
+    MIictor      = 0x100,
+    MIunitTest   = 0x200,
+    MIimportedModules = 0x400,
+    MIlocalClasses = 0x800,
+    MIname       = 0x1000,
+}
+
+/*****
+ * A ModuleGroup is an unordered collection of modules.
+ * There is exactly one for:
+ *  1. all statically linked in D modules, either directely or as shared libraries
+ *  2. each call to rt_loadLibrary()
+ */
+
+struct ModuleGroup
+{
+    this(immutable(ModuleInfo*)[] modules)
+    {
+        _modules = modules;
+    }
+
+    @property immutable(ModuleInfo*)[] modules() const
+    {
+        return _modules;
+    }
+
+    /******************************
+     * Allocate and fill in _ctors[] and _tlsctors[].
+     * Modules are inserted into the arrays in the order in which the constructors
+     * need to be run.
+     * Throws:
+     *  Exception if it fails.
+     */
+    void sortCtors()
+    {
+        immutable len = _modules.length;
+        if (!len)
+            return;
+
+        static struct StackRec
+        {
+            @property immutable(ModuleInfo)* mod()
+            {
+                return _mods[_idx];
+            }
+
+            immutable(ModuleInfo*)[] _mods;
+            size_t         _idx;
+        }
+
+        auto stack = (cast(StackRec*).calloc(len, StackRec.sizeof))[0 .. len];
+        // TODO: reuse GCBits by moving it to rt.util.container or core.internal
+        immutable nwords = (len + 8 * size_t.sizeof - 1) / (8 * size_t.sizeof);
+        auto ctorstart = cast(size_t*).malloc(nwords * size_t.sizeof);
+        auto ctordone = cast(size_t*).malloc(nwords * size_t.sizeof);
+        if (!stack.ptr || ctorstart is null || ctordone is null)
+            assert(0);
+        scope (exit) { .free(stack.ptr); .free(ctorstart); .free(ctordone); }
+
+        int findModule(in ModuleInfo* mi)
+        {
+            foreach (i, m; _modules)
+                if (m is mi) return cast(int)i;
+            return -1;
+        }
+
+        void sort(ref immutable(ModuleInfo)*[] ctors, uint mask)
+        {
+            import core.bitop;
+
+            ctors = (cast(immutable(ModuleInfo)**).malloc(len * size_t.sizeof))[0 .. len];
+            if (!ctors.ptr)
+                assert(0);
+
+            // clean flags
+            memset(ctorstart, 0, nwords * size_t.sizeof);
+            memset(ctordone, 0, nwords * size_t.sizeof);
+            size_t stackidx = 0;
+            size_t cidx;
+
+            immutable(ModuleInfo*)[] mods = _modules;
+            size_t idx;
+            while (true)
+            {
+                while (idx < mods.length)
+                {
+                    auto m = mods[idx];
+
+                    immutable bitnum = findModule(m);
+
+                    if (bitnum < 0 || bt(ctordone, bitnum))
+                    {
+                        /* If the module can't be found among the ones to be
+                         * sorted it's an imported module from another DSO.
+                         * Those don't need to be considered during sorting as
+                         * the OS is responsible for the DSO load order and
+                         * module construction is done during DSO loading.
+                         */
+                        ++idx;
+                        continue;
+                    }
+                    else if (bt(ctorstart, bitnum))
+                    {
+                        /* Trace back to the begin of the cycle.
+                         */
+                        bool ctorInCycle;
+                        size_t start = stackidx;
+                        while (start--)
+                        {
+                            auto sm = stack[start].mod;
+                            if (sm == m)
+                                break;
+                            immutable sbitnum = findModule(sm);
+                            assert(sbitnum >= 0);
+                            if (bt(ctorstart, sbitnum))
+                                ctorInCycle = true;
+                        }
+                        assert(stack[start].mod == m);
+                        if (ctorInCycle)
+                        {
+                            /* This is an illegal cycle, no partial order can be established
+                             * because the import chain have contradicting ctor/dtor
+                             * constraints.
+                             */
+                            string msg = "Aborting: Cycle detected between modules with ";
+                            if (mask & (MIctor | MIdtor))
+                                msg ~= "shared ";
+                            msg ~= "ctors/dtors:\n";
+                            foreach (e; stack[start .. stackidx])
+                            {
+                                msg ~= e.mod.name;
+                                if (e.mod.flags & mask)
+                                    msg ~= '*';
+                                msg ~= " ->\n";
+                            }
+                            msg ~= stack[start].mod.name;
+                            free();
+                            throw new Exception(msg);
+                        }
+                        else
+                        {
+                            /* This is also a cycle, but the import chain does not constrain
+                             * the order of initialization, either because the imported
+                             * modules have no ctors or the ctors are standalone.
+                             */
+                            ++idx;
+                        }
+                    }
+                    else
+                    {
+                        if (m.flags & mask)
+                        {
+                            if (m.flags & MIstandalone || !m.importedModules.length)
+                            {   // trivial ctor => sort in
+                                ctors[cidx++] = m;
+                                bts(ctordone, bitnum);
+                            }
+                            else
+                            {   // non-trivial ctor => defer
+                                bts(ctorstart, bitnum);
+                            }
+                        }
+                        else    // no ctor => mark as visited
+                        {
+                            bts(ctordone, bitnum);
+                        }
+
+                        if (m.importedModules.length)
+                        {
+                            /* Internal runtime error, recursion exceeds number of modules.
+                             */
+                            (stackidx < _modules.length) || assert(0);
+
+                            // recurse
+                            stack[stackidx++] = StackRec(mods, idx);
+                            idx  = 0;
+                            mods = m.importedModules;
+                        }
+                    }
+                }
+
+                if (stackidx)
+                {   // pop old value from stack
+                    --stackidx;
+                    mods    = stack[stackidx]._mods;
+                    idx     = stack[stackidx]._idx;
+                    auto m  = mods[idx++];
+                    immutable bitnum = findModule(m);
+                    assert(bitnum >= 0);
+                    if (m.flags & mask && !bts(ctordone, bitnum))
+                        ctors[cidx++] = m;
+                }
+                else // done
+                    break;
+            }
+            // store final number and shrink array
+            ctors = (cast(immutable(ModuleInfo)**).realloc(ctors.ptr, cidx * size_t.sizeof))[0 .. cidx];
+        }
+
+        /* Do two passes: ctor/dtor, tlsctor/tlsdtor
+         */
+        sort(_ctors, MIctor | MIdtor);
+        sort(_tlsctors, MItlsctor | MItlsdtor);
+    }
+
+    void runCtors()
+    {
+        // run independent ctors
+        runModuleFuncs!(m => m.ictor)(_modules);
+        // sorted module ctors
+        runModuleFuncs!(m => m.ctor)(_ctors);
+    }
+
+    void runTlsCtors()
+    {
+        runModuleFuncs!(m => m.tlsctor)(_tlsctors);
+    }
+
+    void runTlsDtors()
+    {
+        runModuleFuncsRev!(m => m.tlsdtor)(_tlsctors);
+    }
+
+    void runDtors()
+    {
+        runModuleFuncsRev!(m => m.dtor)(_ctors);
+    }
+
+    void free()
+    {
+        if (_ctors.ptr)
+            .free(_ctors.ptr);
+        _ctors = null;
+        if (_tlsctors.ptr)
+            .free(_tlsctors.ptr);
+        _tlsctors = null;
+        // _modules = null; // let the owner free it
+    }
+
+private:
+    immutable(ModuleInfo*)[]  _modules;
+    immutable(ModuleInfo)*[]    _ctors;
+    immutable(ModuleInfo)*[] _tlsctors;
+}
+
+
+/********************************************
+ * Iterate over all module infos.
+ */
+
+int moduleinfos_apply(scope int delegate(immutable(ModuleInfo*)) dg)
+{
+    foreach (ref sg; SectionGroup)
+    {
+        foreach (m; sg.modules)
+        {
+            // TODO: Should null ModuleInfo be allowed?
+            if (m !is null)
+            {
+                if (auto res = dg(m))
+                    return res;
+            }
+        }
+    }
+    return 0;
+}
+
+/********************************************
+ * Module constructor and destructor routines.
+ */
+
+extern (C)
+{
+void rt_moduleCtor()
+{
+    foreach (ref sg; SectionGroup)
+    {
+        sg.moduleGroup.sortCtors();
+        sg.moduleGroup.runCtors();
+    }
+}
+
+void rt_moduleTlsCtor()
+{
+    foreach (ref sg; SectionGroup)
+    {
+        sg.moduleGroup.runTlsCtors();
+    }
+}
+
+void rt_moduleTlsDtor()
+{
+    foreach_reverse (ref sg; SectionGroup)
+    {
+        sg.moduleGroup.runTlsDtors();
+    }
+}
+
+void rt_moduleDtor()
+{
+    foreach_reverse (ref sg; SectionGroup)
+    {
+        sg.moduleGroup.runDtors();
+        sg.moduleGroup.free();
+    }
+}
+
+version (Win32)
+{
+    // Alternate names for backwards compatibility with older DLL code
+    void _moduleCtor()
+    {
+        rt_moduleCtor();
+    }
+
+    void _moduleDtor()
+    {
+        rt_moduleDtor();
+    }
+
+    void _moduleTlsCtor()
+    {
+        rt_moduleTlsCtor();
+    }
+
+    void _moduleTlsDtor()
+    {
+        rt_moduleTlsDtor();
+    }
+}
+}
+
+/********************************************
+ */
+
+void runModuleFuncs(alias getfp)(const(immutable(ModuleInfo)*)[] modules)
+{
+    foreach (m; modules)
+    {
+        if (auto fp = getfp(m))
+            (*fp)();
+    }
+}
+
+void runModuleFuncsRev(alias getfp)(const(immutable(ModuleInfo)*)[] modules)
+{
+    foreach_reverse (m; modules)
+    {
+        if (auto fp = getfp(m))
+            (*fp)();
+    }
+}
+
+unittest
+{
+    static void assertThrown(T : Throwable, E)(lazy E expr)
+    {
+        try
+            expr;
+        catch (T)
+            return;
+        assert(0);
+    }
+
+    static void stub()
+    {
+    }
+
+    static struct UTModuleInfo
+    {
+        this(uint flags)
+        {
+            mi._flags = flags;
+        }
+
+        void setImports(immutable(ModuleInfo)*[] imports...)
+        {
+            import core.bitop;
+            assert(flags & MIimportedModules);
+
+            immutable nfuncs = popcnt(flags & (MItlsctor|MItlsdtor|MIctor|MIdtor|MIictor));
+            immutable size = nfuncs * (void function()).sizeof +
+                size_t.sizeof + imports.length * (ModuleInfo*).sizeof;
+            assert(size <= pad.sizeof);
+
+            pad[nfuncs] = imports.length;
+            .memcpy(&pad[nfuncs+1], imports.ptr, imports.length * imports[0].sizeof);
+        }
+
+        immutable ModuleInfo mi;
+        size_t[8] pad;
+        alias mi this;
+    }
+
+    static UTModuleInfo mockMI(uint flags)
+    {
+        auto mi = UTModuleInfo(flags | MIimportedModules);
+        auto p = cast(void function()*)&mi.pad;
+        if (flags & MItlsctor) *p++ = &stub;
+        if (flags & MItlsdtor) *p++ = &stub;
+        if (flags & MIctor) *p++ = &stub;
+        if (flags & MIdtor) *p++ = &stub;
+        if (flags & MIictor) *p++ = &stub;
+        *cast(size_t*)p++ = 0; // number of imported modules
+        assert(cast(void*)p <= &mi + 1);
+        return mi;
+    }
+
+    static void checkExp(
+        immutable(ModuleInfo*)[] modules,
+        immutable(ModuleInfo*)[] dtors=null,
+        immutable(ModuleInfo*)[] tlsdtors=null)
+    {
+        auto mgroup = ModuleGroup(modules);
+        mgroup.sortCtors();
+        foreach (m; mgroup._modules)
+            assert(!(m.flags & (MIctorstart | MIctordone)));
+        assert(mgroup._ctors    == dtors);
+        assert(mgroup._tlsctors == tlsdtors);
+    }
+
+    // no ctors
+    {
+        auto m0 = mockMI(0);
+        auto m1 = mockMI(0);
+        auto m2 = mockMI(0);
+        checkExp([&m0.mi, &m1.mi, &m2.mi]);
+    }
+
+    // independent ctors
+    {
+        auto m0 = mockMI(MIictor);
+        auto m1 = mockMI(0);
+        auto m2 = mockMI(MIictor);
+        auto mgroup = ModuleGroup([&m0.mi, &m1.mi, &m2.mi]);
+        checkExp([&m0.mi, &m1.mi, &m2.mi]);
+    }
+
+    // standalone ctor
+    {
+        auto m0 = mockMI(MIstandalone | MIctor);
+        auto m1 = mockMI(0);
+        auto m2 = mockMI(0);
+        auto mgroup = ModuleGroup([&m0.mi, &m1.mi, &m2.mi]);
+        checkExp([&m0.mi, &m1.mi, &m2.mi], [&m0.mi]);
+    }
+
+    // imported standalone => no dependency
+    {
+        auto m0 = mockMI(MIstandalone | MIctor);
+        auto m1 = mockMI(MIstandalone | MIctor);
+        auto m2 = mockMI(0);
+        m1.setImports(&m0.mi);
+        checkExp([&m0.mi, &m1.mi, &m2.mi], [&m0.mi, &m1.mi]);
+    }
+
+    {
+        auto m0 = mockMI(MIstandalone | MIctor);
+        auto m1 = mockMI(MIstandalone | MIctor);
+        auto m2 = mockMI(0);
+        m0.setImports(&m1.mi);
+        checkExp([&m0.mi, &m1.mi, &m2.mi], [&m0.mi, &m1.mi]);
+    }
+
+    // standalone may have cycle
+    {
+        auto m0 = mockMI(MIstandalone | MIctor);
+        auto m1 = mockMI(MIstandalone | MIctor);
+        auto m2 = mockMI(0);
+        m0.setImports(&m1.mi);
+        m1.setImports(&m0.mi);
+        checkExp([&m0.mi, &m1.mi, &m2.mi], [&m0.mi, &m1.mi]);
+    }
+
+    // imported ctor => ordered ctors
+    {
+        auto m0 = mockMI(MIctor);
+        auto m1 = mockMI(MIctor);
+        auto m2 = mockMI(0);
+        m1.setImports(&m0.mi);
+        checkExp([&m0.mi, &m1.mi, &m2.mi], [&m0.mi, &m1.mi], []);
+    }
+
+    {
+        auto m0 = mockMI(MIctor);
+        auto m1 = mockMI(MIctor);
+        auto m2 = mockMI(0);
+        m0.setImports(&m1.mi);
+        assert(m0.importedModules == [&m1.mi]);
+        checkExp([&m0.mi, &m1.mi, &m2.mi], [&m1.mi, &m0.mi], []);
+    }
+
+    // detects ctors cycles
+    {
+        auto m0 = mockMI(MIctor);
+        auto m1 = mockMI(MIctor);
+        auto m2 = mockMI(0);
+        m0.setImports(&m1.mi);
+        m1.setImports(&m0.mi);
+        assertThrown!Throwable(checkExp([&m0.mi, &m1.mi, &m2.mi]));
+    }
+
+    // imported ctor/tlsctor => ordered ctors/tlsctors
+    {
+        auto m0 = mockMI(MIctor);
+        auto m1 = mockMI(MIctor);
+        auto m2 = mockMI(MItlsctor);
+        m0.setImports(&m1.mi, &m2.mi);
+        checkExp([&m0.mi, &m1.mi, &m2.mi], [&m1.mi, &m0.mi], [&m2.mi]);
+    }
+
+    {
+        auto m0 = mockMI(MIctor | MItlsctor);
+        auto m1 = mockMI(MIctor);
+        auto m2 = mockMI(MItlsctor);
+        m0.setImports(&m1.mi, &m2.mi);
+        checkExp([&m0.mi, &m1.mi, &m2.mi], [&m1.mi, &m0.mi], [&m2.mi, &m0.mi]);
+    }
+
+    // no cycle between ctors/tlsctors
+    {
+        auto m0 = mockMI(MIctor);
+        auto m1 = mockMI(MIctor);
+        auto m2 = mockMI(MItlsctor);
+        m0.setImports(&m1.mi, &m2.mi);
+        m2.setImports(&m0.mi);
+        checkExp([&m0.mi, &m1.mi, &m2.mi], [&m1.mi, &m0.mi], [&m2.mi]);
+    }
+
+    // detects tlsctors cycle
+    {
+        auto m0 = mockMI(MItlsctor);
+        auto m1 = mockMI(MIctor);
+        auto m2 = mockMI(MItlsctor);
+        m0.setImports(&m2.mi);
+        m2.setImports(&m0.mi);
+        assertThrown!Throwable(checkExp([&m0.mi, &m1.mi, &m2.mi]));
+    }
+
+    // closed ctors cycle
+    {
+        auto m0 = mockMI(MIctor);
+        auto m1 = mockMI(MIstandalone | MIctor);
+        auto m2 = mockMI(MIstandalone | MIctor);
+        m0.setImports(&m1.mi);
+        m1.setImports(&m2.mi);
+        m2.setImports(&m0.mi);
+        checkExp([&m0.mi, &m1.mi, &m2.mi], [&m1.mi, &m2.mi, &m0.mi]);
+    }
+}
+
+version (CRuntime_Microsoft)
+{
+    // Dummy so Win32 code can still call it
+    extern(C) void _minit() { }
+}
diff --git a/libphobos/libdruntime/rt/monitor_.d b/libphobos/libdruntime/rt/monitor_.d
new file mode 100644
index 00000000000..2f8bdef46ac
--- /dev/null
+++ b/libphobos/libdruntime/rt/monitor_.d
@@ -0,0 +1,326 @@
+/**
+ * Contains the implementation for object monitors.
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2015.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Sean Kelly, Martin Nowak
+ */
+
+/* NOTE: This file has been patched from the original DMD distribution to
+ * work with the GDC compiler.
+ */
+module rt.monitor_;
+
+import core.atomic, core.stdc.stdlib, core.stdc.string;
+
+// NOTE: The dtor callback feature is only supported for monitors that are not
+//       supplied by the user.  The assumption is that any object with a user-
+//       supplied monitor may have special storage or lifetime requirements and
+//       that as a result, storing references to local objects within Monitor
+//       may not be safe or desirable.  Thus, devt is only valid if impl is
+//       null.
+
+extern (C) void _d_setSameMutex(shared Object ownee, shared Object owner) nothrow
+in
+{
+    assert(ownee.__monitor is null);
+}
+body
+{
+    auto m = ensureMonitor(cast(Object) owner);
+    auto i = m.impl;
+    if (i is null)
+    {
+        atomicOp!("+=")(m.refs, cast(size_t) 1);
+        ownee.__monitor = owner.__monitor;
+        return;
+    }
+    // If m.impl is set (ie. if this is a user-created monitor), assume
+    // the monitor is garbage collected and simply copy the reference.
+    ownee.__monitor = owner.__monitor;
+}
+
+extern (C) void _d_monitordelete(Object h, bool det)
+{
+    auto m = getMonitor(h);
+    if (m is null)
+        return;
+
+    if (m.impl)
+    {
+        // let the GC collect the monitor
+        setMonitor(h, null);
+    }
+    else if (!atomicOp!("-=")(m.refs, cast(size_t) 1))
+    {
+        // refcount == 0 means unshared => no synchronization required
+        disposeEvent(cast(Monitor*) m, h);
+        deleteMonitor(cast(Monitor*) m);
+        setMonitor(h, null);
+    }
+}
+
+extern (C) void _d_monitorenter(Object h)
+{
+    auto m = cast(Monitor*) ensureMonitor(h);
+    auto i = m.impl;
+    if (i is null)
+        lockMutex(&m.mtx);
+    else
+        i.lock();
+}
+
+extern (C) void _d_monitorexit(Object h)
+{
+    auto m = cast(Monitor*) getMonitor(h);
+    auto i = m.impl;
+    if (i is null)
+        unlockMutex(&m.mtx);
+    else
+        i.unlock();
+}
+
+extern (C) void rt_attachDisposeEvent(Object h, DEvent e)
+{
+    synchronized (h)
+    {
+        auto m = cast(Monitor*) getMonitor(h);
+        assert(m.impl is null);
+
+        foreach (ref v; m.devt)
+        {
+            if (v is null || v == e)
+            {
+                v = e;
+                return;
+            }
+        }
+
+        auto len = m.devt.length + 4; // grow by 4 elements
+        auto pos = m.devt.length; // insert position
+        auto p = realloc(m.devt.ptr, DEvent.sizeof * len);
+        import core.exception : onOutOfMemoryError;
+
+        if (!p)
+            onOutOfMemoryError();
+        m.devt = (cast(DEvent*) p)[0 .. len];
+        m.devt[pos + 1 .. len] = null;
+        m.devt[pos] = e;
+    }
+}
+
+extern (C) void rt_detachDisposeEvent(Object h, DEvent e)
+{
+    synchronized (h)
+    {
+        auto m = cast(Monitor*) getMonitor(h);
+        assert(m.impl is null);
+
+        foreach (p, v; m.devt)
+        {
+            if (v == e)
+            {
+                memmove(&m.devt[p], &m.devt[p + 1], (m.devt.length - p - 1) * DEvent.sizeof);
+                m.devt[$ - 1] = null;
+                return;
+            }
+        }
+    }
+}
+
+nothrow:
+
+extern (C) void _d_monitor_staticctor()
+{
+    version (Posix)
+    {
+        pthread_mutexattr_init(&gattr);
+        pthread_mutexattr_settype(&gattr, PTHREAD_MUTEX_RECURSIVE);
+    }
+    initMutex(&gmtx);
+}
+
+extern (C) void _d_monitor_staticdtor()
+{
+    destroyMutex(&gmtx);
+    version (Posix)
+        pthread_mutexattr_destroy(&gattr);
+}
+
+package:
+
+// This is what the monitor reference in Object points to
+alias IMonitor = Object.Monitor;
+alias DEvent = void delegate(Object);
+
+version (GNU)
+{
+    import gcc.config;
+    static if (GNU_Thread_Model == ThreadModel.Single)
+        version = SingleThreaded;
+    // Ignore ThreadModel, we don't want posix threads on windows and
+    // will always use native threading instead.
+}
+
+version (SingleThreaded)
+{
+    alias Mutex = int;
+
+    void initMutex(Mutex* mtx)
+    {
+    }
+
+    void destroyMutex(Mutex* mtx)
+    {
+    }
+
+    void lockMutex(Mutex* mtx)
+    {
+    }
+
+    void unlockMutex(Mutex* mtx)
+    {
+    }
+}
+else version (Windows)
+{
+    version (CRuntime_DigitalMars)
+    {
+        pragma(lib, "snn.lib");
+    }
+    else version (CRuntime_Microsoft)
+    {
+        pragma(lib, "libcmt.lib");
+        pragma(lib, "oldnames.lib");
+    }
+    import core.sys.windows.windows;
+
+    alias Mutex = CRITICAL_SECTION;
+
+    alias initMutex = InitializeCriticalSection;
+    alias destroyMutex = DeleteCriticalSection;
+    alias lockMutex = EnterCriticalSection;
+    alias unlockMutex = LeaveCriticalSection;
+}
+else version (Posix)
+{
+    import core.sys.posix.pthread;
+
+    alias Mutex = pthread_mutex_t;
+    __gshared pthread_mutexattr_t gattr;
+
+    void initMutex(pthread_mutex_t* mtx)
+    {
+        pthread_mutex_init(mtx, &gattr) && assert(0);
+    }
+
+    void destroyMutex(pthread_mutex_t* mtx)
+    {
+        pthread_mutex_destroy(mtx) && assert(0);
+    }
+
+    void lockMutex(pthread_mutex_t* mtx)
+    {
+        pthread_mutex_lock(mtx) && assert(0);
+    }
+
+    void unlockMutex(pthread_mutex_t* mtx)
+    {
+        pthread_mutex_unlock(mtx) && assert(0);
+    }
+}
+else
+{
+    static assert(0, "Unsupported platform");
+}
+
+struct Monitor
+{
+    IMonitor impl; // for user-level monitors
+    DEvent[] devt; // for internal monitors
+    size_t refs; // reference count
+    Mutex mtx;
+}
+
+private:
+
+@property ref shared(Monitor*) monitor(Object h) pure nothrow
+{
+    return *cast(shared Monitor**)&h.__monitor;
+}
+
+private shared(Monitor)* getMonitor(Object h) pure
+{
+    return atomicLoad!(MemoryOrder.acq)(h.monitor);
+}
+
+void setMonitor(Object h, shared(Monitor)* m) pure
+{
+    atomicStore!(MemoryOrder.rel)(h.monitor, m);
+}
+
+__gshared Mutex gmtx;
+
+shared(Monitor)* ensureMonitor(Object h)
+{
+    if (auto m = getMonitor(h))
+        return m;
+
+    auto m = cast(Monitor*) calloc(Monitor.sizeof, 1);
+    assert(m);
+    initMutex(&m.mtx);
+
+    bool success;
+    lockMutex(&gmtx);
+    if (getMonitor(h) is null)
+    {
+        m.refs = 1;
+        setMonitor(h, cast(shared) m);
+        success = true;
+    }
+    unlockMutex(&gmtx);
+
+    if (success)
+    {
+        // Set the finalize bit so that the monitor gets collected (Bugzilla 14573)
+        import core.memory : GC;
+
+        if (!(typeid(h).m_flags & TypeInfo_Class.ClassFlags.hasDtor))
+            GC.setAttr(cast(void*) h, GC.BlkAttr.FINALIZE);
+        return cast(shared(Monitor)*) m;
+    }
+    else // another thread succeeded instead
+    {
+        deleteMonitor(m);
+        return getMonitor(h);
+    }
+}
+
+void deleteMonitor(Monitor* m)
+{
+    destroyMutex(&m.mtx);
+    free(m);
+}
+
+void disposeEvent(Monitor* m, Object h)
+{
+    foreach (v; m.devt)
+    {
+        if (v)
+            v(h);
+    }
+    if (m.devt.ptr)
+        free(m.devt.ptr);
+}
+
+// Bugzilla 14573
+unittest
+{
+    import core.memory : GC;
+
+    auto obj = new Object;
+    assert(!(GC.getAttr(cast(void*) obj) & GC.BlkAttr.FINALIZE));
+    ensureMonitor(obj);
+    assert(getMonitor(obj) !is null);
+    assert(GC.getAttr(cast(void*) obj) & GC.BlkAttr.FINALIZE);
+}
diff --git a/libphobos/libdruntime/rt/obj.d b/libphobos/libdruntime/rt/obj.d
new file mode 100644
index 00000000000..97dfbb595b1
--- /dev/null
+++ b/libphobos/libdruntime/rt/obj.d
@@ -0,0 +1,35 @@
+/**
+ * Contains object comparator functions called by generated code.
+ *
+ * Copyright: Copyright Digital Mars 2002 - 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2000 - 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.obj;
+
+extern (C):
+
+/********************************
+ * Compiler helper for operator == for class objects.
+ */
+
+int _d_obj_eq(Object o1, Object o2)
+{
+    return o1 is o2 || (o1 && o1.opEquals(o2));
+}
+
+
+/********************************
+ * Compiler helper for operator <, <=, >, >= for class objects.
+ */
+
+int _d_obj_cmp(Object o1, Object o2)
+{
+    return o1.opCmp(o2);
+}
diff --git a/libphobos/libdruntime/rt/qsort.d b/libphobos/libdruntime/rt/qsort.d
new file mode 100644
index 00000000000..986e393f927
--- /dev/null
+++ b/libphobos/libdruntime/rt/qsort.d
@@ -0,0 +1,109 @@
+/**
+ * This is a public domain version of qsort.d.  All it does is call C's
+ * qsort().
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Martin Nowak
+ */
+
+/*          Copyright Digital Mars 2000 - 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE_1_0.txt or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.qsort;
+
+//debug=qsort;
+
+private import core.stdc.stdlib;
+
+version (CRuntime_Glibc)
+{
+    alias extern (C) int function(const void *, const void *, void *) Cmp;
+    extern (C) void qsort_r(void *base, size_t nmemb, size_t size, Cmp cmp, void *arg);
+
+    extern (C) void[] _adSort(void[] a, TypeInfo ti)
+    {
+        extern (C) int cmp(in void* p1, in void* p2, void* ti)
+        {
+            return (cast(TypeInfo)ti).compare(p1, p2);
+        }
+        qsort_r(a.ptr, a.length, ti.tsize, &cmp, cast(void*)ti);
+        return a;
+    }
+}
+else version (FreeBSD)
+{
+    alias extern (C) int function(void *, const void *, const void *) Cmp;
+    extern (C) void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, Cmp cmp);
+
+    extern (C) void[] _adSort(void[] a, TypeInfo ti)
+    {
+        extern (C) int cmp(void* ti, in void* p1, in void* p2)
+        {
+            return (cast(TypeInfo)ti).compare(p1, p2);
+        }
+        qsort_r(a.ptr, a.length, ti.tsize, cast(void*)ti, &cmp);
+        return a;
+    }
+}
+else version (OSX)
+{
+    alias extern (C) int function(void *, const void *, const void *) Cmp;
+    extern (C) void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, Cmp cmp);
+
+    extern (C) void[] _adSort(void[] a, TypeInfo ti)
+    {
+        extern (C) int cmp(void* ti, in void* p1, in void* p2)
+        {
+            return (cast(TypeInfo)ti).compare(p1, p2);
+        }
+        qsort_r(a.ptr, a.length, ti.tsize, cast(void*)ti, &cmp);
+        return a;
+    }
+}
+else
+{
+    private TypeInfo tiglobal;
+
+    extern (C) void[] _adSort(void[] a, TypeInfo ti)
+    {
+        extern (C) int cmp(in void* p1, in void* p2)
+        {
+            return tiglobal.compare(p1, p2);
+        }
+        tiglobal = ti;
+        qsort(a.ptr, a.length, ti.tsize, &cmp);
+        return a;
+    }
+}
+
+
+
+unittest
+{
+    debug(qsort) printf("array.sort.unittest()\n");
+
+    int[] a = new int[10];
+
+    a[0] = 23;
+    a[1] = 1;
+    a[2] = 64;
+    a[3] = 5;
+    a[4] = 6;
+    a[5] = 5;
+    a[6] = 17;
+    a[7] = 3;
+    a[8] = 0;
+    a[9] = -1;
+
+    _adSort(*cast(void[]*)&a, typeid(a[0]));
+
+    for (int i = 0; i < a.length - 1; i++)
+    {
+        //printf("i = %d", i);
+        //printf(" %d %d\n", a[i], a[i + 1]);
+        assert(a[i] <= a[i + 1]);
+    }
+}
diff --git a/libphobos/libdruntime/rt/sections.d b/libphobos/libdruntime/rt/sections.d
new file mode 100644
index 00000000000..af1bddbb443
--- /dev/null
+++ b/libphobos/libdruntime/rt/sections.d
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright: Copyright Digital Mars 2000 - 2012.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Walter Bright, Sean Kelly, Martin Nowak
+ * Source: $(DRUNTIMESRC src/rt/_sections.d)
+ */
+
+module rt.sections;
+
+version (CRuntime_Glibc)
+    public import rt.sections_elf_shared;
+else version (FreeBSD)
+    public import rt.sections_elf_shared;
+else version (Solaris)
+    public import rt.sections_solaris;
+else version (OSX)
+    public import rt.sections_osx;
+else version (CRuntime_DigitalMars)
+    public import rt.sections_win32;
+else version (CRuntime_Microsoft)
+    public import rt.sections_win64;
+else version (CRuntime_Bionic)
+    public import rt.sections_android;
+else
+    static assert(0, "unimplemented");
+
+import rt.deh, rt.minfo;
+
+template isSectionGroup(T)
+{
+    enum isSectionGroup =
+        is(typeof(T.init.modules) == immutable(ModuleInfo*)[]) &&
+        is(typeof(T.init.moduleGroup) == ModuleGroup) &&
+        (!is(typeof(T.init.ehTables)) || is(typeof(T.init.ehTables) == immutable(FuncTable)[])) &&
+        is(typeof(T.init.gcRanges) == void[][]) &&
+        is(typeof({ foreach (ref T; T) {}})) &&
+        is(typeof({ foreach_reverse (ref T; T) {}}));
+}
+static assert(isSectionGroup!(SectionGroup));
+static assert(is(typeof(&initSections) == void function()));
+static assert(is(typeof(&finiSections) == void function()));
+static assert(is(typeof(&initTLSRanges) RT == return) &&
+              is(typeof(&initTLSRanges) == RT function()) &&
+              is(typeof(&finiTLSRanges) == void function(RT)) &&
+              is(typeof(&scanTLSRanges) == void function(RT, scope void delegate(void*, void*) nothrow) nothrow));
+
+version (Shared)
+{
+    static assert(is(typeof(&pinLoadedLibraries) == void* function() nothrow));
+    static assert(is(typeof(&unpinLoadedLibraries) == void function(void*) nothrow));
+    static assert(is(typeof(&inheritLoadedLibraries) == void function(void*)));
+    static assert(is(typeof(&cleanupLoadedLibraries) == void function()));
+}
diff --git a/libphobos/libdruntime/rt/sections_android.d b/libphobos/libdruntime/rt/sections_android.d
new file mode 100644
index 00000000000..79e2a642e14
--- /dev/null
+++ b/libphobos/libdruntime/rt/sections_android.d
@@ -0,0 +1,187 @@
+/**
+ * Written in the D programming language.
+ * This module provides bionic-specific support for sections.
+ *
+ * Copyright: Copyright Martin Nowak 2012-2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ * Source: $(DRUNTIMESRC src/rt/_sections_android.d)
+ */
+
+module rt.sections_android;
+
+version (CRuntime_Bionic):
+
+// debug = PRINTF;
+debug(PRINTF) import core.stdc.stdio;
+import core.stdc.stdlib : malloc, free;
+import rt.deh, rt.minfo;
+import core.sys.posix.pthread;
+import core.stdc.stdlib : calloc;
+import core.stdc.string : memcpy;
+
+struct SectionGroup
+{
+    static int opApply(scope int delegate(ref SectionGroup) dg)
+    {
+        return dg(_sections);
+    }
+
+    static int opApplyReverse(scope int delegate(ref SectionGroup) dg)
+    {
+        return dg(_sections);
+    }
+
+    @property immutable(ModuleInfo*)[] modules() const
+    {
+        return _moduleGroup.modules;
+    }
+
+    @property ref inout(ModuleGroup) moduleGroup() inout
+    {
+        return _moduleGroup;
+    }
+
+    @property immutable(FuncTable)[] ehTables() const
+    {
+        auto pbeg = cast(immutable(FuncTable)*)&__start_deh;
+        auto pend = cast(immutable(FuncTable)*)&__stop_deh;
+        return pbeg[0 .. pend - pbeg];
+    }
+
+    @property inout(void[])[] gcRanges() inout
+    {
+        return _gcRanges[];
+    }
+
+private:
+    ModuleGroup _moduleGroup;
+    void[][1] _gcRanges;
+}
+
+void initSections()
+{
+    pthread_key_create(&_tlsKey, null);
+
+    auto mbeg = cast(immutable ModuleInfo**)&__start_minfo;
+    auto mend = cast(immutable ModuleInfo**)&__stop_minfo;
+    _sections.moduleGroup = ModuleGroup(mbeg[0 .. mend - mbeg]);
+
+    auto pbeg = cast(void*)&_tls_end;
+    auto pend = cast(void*)&__bss_end__;
+    _sections._gcRanges[0] = pbeg[0 .. pend - pbeg];
+}
+
+void finiSections()
+{
+    pthread_key_delete(_tlsKey);
+}
+
+void[]* initTLSRanges()
+{
+    return &getTLSBlock();
+}
+
+void finiTLSRanges(void[]* rng)
+{
+    .free(rng.ptr);
+    .free(rng);
+}
+
+void scanTLSRanges(void[]* rng, scope void delegate(void* pbeg, void* pend) nothrow dg) nothrow
+{
+    dg(rng.ptr, rng.ptr + rng.length);
+}
+
+/* NOTE: The Bionic C library does not allow storing thread-local data
+ *       in the normal .tbss/.tdata ELF sections. So instead we roll our
+ *       own by simply putting tls into the non-tls .data/.bss sections
+ *       and using the _tlsstart/_tlsend symbols as delimiters of the tls
+ *       data.
+ *
+ *       This function is called by the code emitted by the compiler.  It
+ *       is expected to translate an address in the TLS static data to
+ *       the corresponding address in the TLS dynamic per-thread data.
+ */
+
+version(X86)
+{
+    // NB: the compiler mangles this function as '___tls_get_addr'
+    // even though it is extern(D)
+    extern(D) void* ___tls_get_addr( void* p )
+    {
+        debug(PRINTF) printf("  ___tls_get_addr input - %p\n", p);
+        immutable offset = cast(size_t)(p - cast(void*)&_tlsstart);
+        auto tls = getTLSBlockAlloc();
+        assert(offset < tls.length);
+        return tls.ptr + offset;
+    }
+}
+else version(ARM)
+{
+    extern(C) void* __tls_get_addr( void** p )
+    {
+        debug(PRINTF) printf("  __tls_get_addr input - %p\n", *p);
+        immutable offset = cast(size_t)(*p - cast(void*)&_tlsstart);
+        auto tls = getTLSBlockAlloc();
+        assert(offset < tls.length);
+        return tls.ptr + offset;
+    }
+}
+else
+    static assert( false, "Android architecture not supported." );
+
+private:
+
+__gshared pthread_key_t _tlsKey;
+
+ref void[] getTLSBlock()
+{
+    auto pary = cast(void[]*)pthread_getspecific(_tlsKey);
+    if (pary is null)
+    {
+        pary = cast(void[]*).calloc(1, (void[]).sizeof);
+        if (pthread_setspecific(_tlsKey, pary) != 0)
+        {
+            import core.stdc.stdio;
+            perror("pthread_setspecific failed with");
+            assert(0);
+        }
+    }
+    return *pary;
+}
+
+ref void[] getTLSBlockAlloc()
+{
+    auto pary = &getTLSBlock();
+    if (!pary.length)
+    {
+        auto pbeg = cast(void*)&_tlsstart;
+        auto pend = cast(void*)&_tlsend;
+        auto p = .malloc(pend - pbeg);
+        memcpy(p, pbeg, pend - pbeg);
+        *pary = p[0 .. pend - pbeg];
+    }
+    return *pary;
+}
+
+__gshared SectionGroup _sections;
+
+extern(C)
+{
+    /* Symbols created by the compiler/linker and inserted into the
+     * object file that 'bracket' sections.
+     */
+    extern __gshared
+    {
+        void* __start_deh;
+        void* __stop_deh;
+        void* __start_minfo;
+        void* __stop_minfo;
+
+        size_t __bss_end__;
+
+        void* _tlsstart;
+        void* _tlsend;
+    }
+}
diff --git a/libphobos/libdruntime/rt/sections_elf_shared.d b/libphobos/libdruntime/rt/sections_elf_shared.d
new file mode 100644
index 00000000000..f33a016e9ee
--- /dev/null
+++ b/libphobos/libdruntime/rt/sections_elf_shared.d
@@ -0,0 +1,967 @@
+/**
+ * Written in the D programming language.
+ * This module provides ELF-specific support for sections with shared libraries.
+ *
+ * Copyright: Copyright Martin Nowak 2012-2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ * Source: $(DRUNTIMESRC src/rt/_sections_linux.d)
+ */
+
+module rt.sections_elf_shared;
+
+version (CRuntime_Glibc) enum SharedELF = true;
+else version (FreeBSD) enum SharedELF = true;
+else enum SharedELF = false;
+static if (SharedELF):
+
+// debug = PRINTF;
+import core.memory;
+import core.stdc.stdio;
+import core.stdc.stdlib : calloc, exit, free, malloc, EXIT_FAILURE;
+import core.stdc.string : strlen;
+version (linux)
+{
+    import core.sys.linux.dlfcn;
+    import core.sys.linux.elf;
+    import core.sys.linux.link;
+}
+else version (FreeBSD)
+{
+    import core.sys.freebsd.dlfcn;
+    import core.sys.freebsd.sys.elf;
+    import core.sys.freebsd.sys.link_elf;
+}
+else
+{
+    static assert(0, "unimplemented");
+}
+import core.sys.posix.pthread;
+import rt.deh;
+import rt.dmain2;
+import rt.minfo;
+import rt.util.container.array;
+import rt.util.container.hashtab;
+
+alias DSO SectionGroup;
+struct DSO
+{
+    static int opApply(scope int delegate(ref DSO) dg)
+    {
+        foreach (dso; _loadedDSOs)
+        {
+            if (auto res = dg(*dso))
+                return res;
+        }
+        return 0;
+    }
+
+    static int opApplyReverse(scope int delegate(ref DSO) dg)
+    {
+        foreach_reverse (dso; _loadedDSOs)
+        {
+            if (auto res = dg(*dso))
+                return res;
+        }
+        return 0;
+    }
+
+    @property immutable(ModuleInfo*)[] modules() const
+    {
+        return _moduleGroup.modules;
+    }
+
+    @property ref inout(ModuleGroup) moduleGroup() inout
+    {
+        return _moduleGroup;
+    }
+
+    @property immutable(FuncTable)[] ehTables() const
+    {
+        return _ehTables[];
+    }
+
+    @property inout(void[])[] gcRanges() inout
+    {
+        return _gcRanges[];
+    }
+
+private:
+
+    invariant()
+    {
+        assert(_moduleGroup.modules.length);
+        assert(_tlsMod || !_tlsSize);
+    }
+
+    immutable(FuncTable)[] _ehTables;
+    ModuleGroup _moduleGroup;
+    Array!(void[]) _gcRanges;
+    size_t _tlsMod;
+    size_t _tlsSize;
+
+    version (Shared)
+    {
+        Array!(void[]) _codeSegments; // array of code segments
+        Array!(DSO*) _deps; // D libraries needed by this DSO
+        void* _handle; // corresponding handle
+    }
+}
+
+/****
+ * Boolean flag set to true while the runtime is initialized.
+ */
+__gshared bool _isRuntimeInitialized;
+
+
+version (FreeBSD) private __gshared void* dummy_ref;
+
+/****
+ * Gets called on program startup just before GC is initialized.
+ */
+void initSections()
+{
+    _isRuntimeInitialized = true;
+    // reference symbol to support weak linkage
+    version (FreeBSD) dummy_ref = &_d_dso_registry;
+}
+
+
+/***
+ * Gets called on program shutdown just after GC is terminated.
+ */
+void finiSections()
+{
+    _isRuntimeInitialized = false;
+}
+
+alias ScanDG = void delegate(void* pbeg, void* pend) nothrow;
+
+version (Shared)
+{
+    /***
+     * Called once per thread; returns array of thread local storage ranges
+     */
+    Array!(ThreadDSO)* initTLSRanges()
+    {
+        return &_loadedDSOs;
+    }
+
+    void finiTLSRanges(Array!(ThreadDSO)* tdsos)
+    {
+        tdsos.reset();
+    }
+
+    void scanTLSRanges(Array!(ThreadDSO)* tdsos, scope ScanDG dg) nothrow
+    {
+        foreach (ref tdso; *tdsos)
+            dg(tdso._tlsRange.ptr, tdso._tlsRange.ptr + tdso._tlsRange.length);
+    }
+
+    // interface for core.thread to inherit loaded libraries
+    void* pinLoadedLibraries() nothrow
+    {
+        auto res = cast(Array!(ThreadDSO)*)calloc(1, Array!(ThreadDSO).sizeof);
+        res.length = _loadedDSOs.length;
+        foreach (i, ref tdso; _loadedDSOs)
+        {
+            (*res)[i] = tdso;
+            if (tdso._addCnt)
+            {
+                // Increment the dlopen ref for explicitly loaded libraries to pin them.
+                .dlopen(linkMapForHandle(tdso._pdso._handle).l_name, RTLD_LAZY) !is null || assert(0);
+                (*res)[i]._addCnt = 1; // new array takes over the additional ref count
+            }
+        }
+        return res;
+    }
+
+    void unpinLoadedLibraries(void* p) nothrow
+    {
+        auto pary = cast(Array!(ThreadDSO)*)p;
+        // In case something failed we need to undo the pinning.
+        foreach (ref tdso; *pary)
+        {
+            if (tdso._addCnt)
+            {
+                auto handle = tdso._pdso._handle;
+                handle !is null || assert(0);
+                .dlclose(handle);
+            }
+        }
+        pary.reset();
+        .free(pary);
+    }
+
+    // Called before TLS ctors are ran, copy over the loaded libraries
+    // of the parent thread.
+    void inheritLoadedLibraries(void* p)
+    {
+        assert(_loadedDSOs.empty);
+        _loadedDSOs.swap(*cast(Array!(ThreadDSO)*)p);
+        .free(p);
+        foreach (ref dso; _loadedDSOs)
+        {
+            // the copied _tlsRange corresponds to parent thread
+            dso.updateTLSRange();
+        }
+    }
+
+    // Called after all TLS dtors ran, decrements all remaining dlopen refs.
+    void cleanupLoadedLibraries()
+    {
+        foreach (ref tdso; _loadedDSOs)
+        {
+            if (tdso._addCnt == 0) continue;
+
+            auto handle = tdso._pdso._handle;
+            handle !is null || assert(0);
+            for (; tdso._addCnt > 0; --tdso._addCnt)
+                .dlclose(handle);
+        }
+        _loadedDSOs.reset();
+    }
+}
+else
+{
+    /***
+     * Called once per thread; returns array of thread local storage ranges
+     */
+    Array!(void[])* initTLSRanges()
+    {
+        return &_tlsRanges;
+    }
+
+    void finiTLSRanges(Array!(void[])* rngs)
+    {
+        rngs.reset();
+    }
+
+    void scanTLSRanges(Array!(void[])* rngs, scope ScanDG dg) nothrow
+    {
+        foreach (rng; *rngs)
+            dg(rng.ptr, rng.ptr + rng.length);
+    }
+}
+
+private:
+
+// start of linked list for ModuleInfo references
+version (FreeBSD) deprecated extern (C) __gshared void* _Dmodule_ref;
+
+version (Shared)
+{
+    /*
+     * Array of thread local DSO metadata for all libraries loaded and
+     * initialized in this thread.
+     *
+     * Note:
+     *     A newly spawned thread will inherit these libraries.
+     * Note:
+     *     We use an array here to preserve the order of
+     *     initialization.  If that became a performance issue, we
+     *     could use a hash table and enumerate the DSOs during
+     *     loading so that the hash table values could be sorted when
+     *     necessary.
+     */
+    struct ThreadDSO
+    {
+        DSO* _pdso;
+        static if (_pdso.sizeof == 8) uint _refCnt, _addCnt;
+        else static if (_pdso.sizeof == 4) ushort _refCnt, _addCnt;
+        else static assert(0, "unimplemented");
+        void[] _tlsRange;
+        alias _pdso this;
+        // update the _tlsRange for the executing thread
+        void updateTLSRange()
+        {
+            _tlsRange = getTLSRange(_pdso._tlsMod, _pdso._tlsSize);
+        }
+    }
+    Array!(ThreadDSO) _loadedDSOs;
+
+    /*
+     * Set to true during rt_loadLibrary/rt_unloadLibrary calls.
+     */
+    bool _rtLoading;
+
+    /*
+     * Hash table to map link_map* to corresponding DSO*.
+     * The hash table is protected by a Mutex.
+     */
+    __gshared pthread_mutex_t _handleToDSOMutex;
+    __gshared HashTab!(void*, DSO*) _handleToDSO;
+
+    /*
+     * Section in executable that contains copy relocations.
+     * Might be null when druntime is dynamically loaded by a C host.
+     */
+    __gshared const(void)[] _copyRelocSection;
+}
+else
+{
+    /*
+     * Static DSOs loaded by the runtime linker. This includes the
+     * executable. These can't be unloaded.
+     */
+    __gshared Array!(DSO*) _loadedDSOs;
+
+    /*
+     * Thread local array that contains TLS memory ranges for each
+     * library initialized in this thread.
+     */
+    Array!(void[]) _tlsRanges;
+
+    enum _rtLoading = false;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Compiler to runtime interface.
+///////////////////////////////////////////////////////////////////////////////
+
+import gcc.config;
+static assert(Minfo_Bracketing, "Can't use _d_dso_registry interface");
+
+/*
+ * This data structure is generated by the compiler, and then passed to
+ * _d_dso_registry().
+ */
+struct CompilerDSOData
+{
+    size_t _version;                                       // currently 1
+    void** _slot;                                          // can be used to store runtime data
+    immutable(object.ModuleInfo*)* _minfo_beg, _minfo_end; // array of modules in this object file
+    immutable(rt.deh.FuncTable)* _deh_beg, _deh_end;       // array of exception handling data
+}
+
+T[] toRange(T)(T* beg, T* end) { return beg[0 .. end - beg]; }
+
+/* For each shared library and executable, the compiler generates code that
+ * sets up CompilerDSOData and calls _d_dso_registry().
+ * A pointer to that code is inserted into both the .ctors and .dtors
+ * segment so it gets called by the loader on startup and shutdown.
+ */
+extern(C) void _d_dso_registry(CompilerDSOData* data)
+{
+    // only one supported currently
+    data._version >= 1 || assert(0, "corrupt DSO data version");
+
+    // no backlink => register
+    if (*data._slot is null)
+    {
+        immutable firstDSO = _loadedDSOs.empty;
+        if (firstDSO) initLocks();
+
+        DSO* pdso = cast(DSO*).calloc(1, DSO.sizeof);
+        assert(typeid(DSO).initializer().ptr is null);
+        *data._slot = pdso; // store backlink in library record
+
+        pdso._moduleGroup = ModuleGroup(toRange(data._minfo_beg, data._minfo_end));
+        pdso._ehTables = toRange(data._deh_beg, data._deh_end);
+
+        dl_phdr_info info = void;
+        findDSOInfoForAddr(data._slot, &info) || assert(0);
+
+        scanSegments(info, pdso);
+
+        version (Shared)
+        {
+            auto handle = handleForAddr(data._slot);
+
+            if (firstDSO)
+            {
+                /// Assert that the first loaded DSO is druntime itself. Use a
+                /// local druntime symbol (rt_get_bss_start) to get the handle.
+                assert(handleForAddr(data._slot) == handleForAddr(&rt_get_bss_start));
+                _copyRelocSection = getCopyRelocSection();
+            }
+            checkModuleCollisions(info, pdso._moduleGroup.modules, _copyRelocSection);
+
+            getDependencies(info, pdso._deps);
+            pdso._handle = handle;
+            setDSOForHandle(pdso, pdso._handle);
+
+            if (!_rtLoading)
+            {
+                /* This DSO was not loaded by rt_loadLibrary which
+                 * happens for all dependencies of an executable or
+                 * the first dlopen call from a C program.
+                 * In this case we add the DSO to the _loadedDSOs of this
+                 * thread with a refCnt of 1 and call the TlsCtors.
+                 */
+                immutable ushort refCnt = 1, addCnt = 0;
+                auto tlsRng = getTLSRange(pdso._tlsMod, pdso._tlsSize);
+                _loadedDSOs.insertBack(ThreadDSO(pdso, refCnt, addCnt, tlsRng));
+            }
+        }
+        else
+        {
+            foreach (p; _loadedDSOs) assert(p !is pdso);
+            _loadedDSOs.insertBack(pdso);
+            _tlsRanges.insertBack(getTLSRange(pdso._tlsMod, pdso._tlsSize));
+        }
+
+        // don't initialize modules before rt_init was called (see Bugzilla 11378)
+        if (_isRuntimeInitialized)
+        {
+            registerGCRanges(pdso);
+            // rt_loadLibrary will run tls ctors, so do this only for dlopen
+            immutable runTlsCtors = !_rtLoading;
+            runModuleConstructors(pdso, runTlsCtors);
+        }
+    }
+    // has backlink => unregister
+    else
+    {
+        DSO* pdso = cast(DSO*)*data._slot;
+        *data._slot = null;
+
+        // don't finalizes modules after rt_term was called (see Bugzilla 11378)
+        if (_isRuntimeInitialized)
+        {
+            // rt_unloadLibrary already ran tls dtors, so do this only for dlclose
+            immutable runTlsDtors = !_rtLoading;
+            runModuleDestructors(pdso, runTlsDtors);
+            unregisterGCRanges(pdso);
+            // run finalizers after module dtors (same order as in rt_term)
+            version (Shared) runFinalizers(pdso);
+        }
+
+        version (Shared)
+        {
+            if (!_rtLoading)
+            {
+                /* This DSO was not unloaded by rt_unloadLibrary so we
+                 * have to remove it from _loadedDSOs here.
+                 */
+                foreach (i, ref tdso; _loadedDSOs)
+                {
+                    if (tdso._pdso == pdso)
+                    {
+                        _loadedDSOs.remove(i);
+                        break;
+                    }
+                }
+            }
+
+            assert(pdso._handle == handleForAddr(data._slot));
+            unsetDSOForHandle(pdso, pdso._handle);
+            pdso._handle = null;
+        }
+        else
+        {
+            // static DSOs are unloaded in reverse order
+            assert(pdso._tlsSize == _tlsRanges.back.length);
+            _tlsRanges.popBack();
+            assert(pdso == _loadedDSOs.back);
+            _loadedDSOs.popBack();
+        }
+
+        freeDSO(pdso);
+
+        if (_loadedDSOs.empty) finiLocks(); // last DSO
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// dynamic loading
+///////////////////////////////////////////////////////////////////////////////
+
+// Shared D libraries are only supported when linking against a shared druntime library.
+
+version (Shared)
+{
+    ThreadDSO* findThreadDSO(DSO* pdso)
+    {
+        foreach (ref tdata; _loadedDSOs)
+            if (tdata._pdso == pdso) return &tdata;
+        return null;
+    }
+
+    void incThreadRef(DSO* pdso, bool incAdd)
+    {
+        if (auto tdata = findThreadDSO(pdso)) // already initialized
+        {
+            if (incAdd && ++tdata._addCnt > 1) return;
+            ++tdata._refCnt;
+        }
+        else
+        {
+            foreach (dep; pdso._deps)
+                incThreadRef(dep, false);
+            immutable ushort refCnt = 1, addCnt = incAdd ? 1 : 0;
+            auto tlsRng = getTLSRange(pdso._tlsMod, pdso._tlsSize);
+            _loadedDSOs.insertBack(ThreadDSO(pdso, refCnt, addCnt, tlsRng));
+            pdso._moduleGroup.runTlsCtors();
+        }
+    }
+
+    void decThreadRef(DSO* pdso, bool decAdd)
+    {
+        auto tdata = findThreadDSO(pdso);
+        tdata !is null || assert(0);
+        !decAdd || tdata._addCnt > 0 || assert(0, "Mismatching rt_unloadLibrary call.");
+
+        if (decAdd && --tdata._addCnt > 0) return;
+        if (--tdata._refCnt > 0) return;
+
+        pdso._moduleGroup.runTlsDtors();
+        foreach (i, ref td; _loadedDSOs)
+            if (td._pdso == pdso) _loadedDSOs.remove(i);
+        foreach (dep; pdso._deps)
+            decThreadRef(dep, false);
+    }
+
+    extern(C) void* rt_loadLibrary(const char* name)
+    {
+        immutable save = _rtLoading;
+        _rtLoading = true;
+        scope (exit) _rtLoading = save;
+
+        auto handle = .dlopen(name, RTLD_LAZY);
+        if (handle is null) return null;
+
+        // if it's a D library
+        if (auto pdso = dsoForHandle(handle))
+            incThreadRef(pdso, true);
+        return handle;
+    }
+
+    extern(C) int rt_unloadLibrary(void* handle)
+    {
+        if (handle is null) return false;
+
+        immutable save = _rtLoading;
+        _rtLoading = true;
+        scope (exit) _rtLoading = save;
+
+        // if it's a D library
+        if (auto pdso = dsoForHandle(handle))
+            decThreadRef(pdso, true);
+        return .dlclose(handle) == 0;
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// helper functions
+///////////////////////////////////////////////////////////////////////////////
+
+void initLocks()
+{
+    version (Shared)
+        !pthread_mutex_init(&_handleToDSOMutex, null) || assert(0);
+}
+
+void finiLocks()
+{
+    version (Shared)
+        !pthread_mutex_destroy(&_handleToDSOMutex) || assert(0);
+}
+
+void runModuleConstructors(DSO* pdso, bool runTlsCtors)
+{
+    pdso._moduleGroup.sortCtors();
+    pdso._moduleGroup.runCtors();
+    if (runTlsCtors) pdso._moduleGroup.runTlsCtors();
+}
+
+void runModuleDestructors(DSO* pdso, bool runTlsDtors)
+{
+    if (runTlsDtors) pdso._moduleGroup.runTlsDtors();
+    pdso._moduleGroup.runDtors();
+}
+
+void registerGCRanges(DSO* pdso)
+{
+    foreach (rng; pdso._gcRanges)
+        GC.addRange(rng.ptr, rng.length);
+}
+
+void unregisterGCRanges(DSO* pdso)
+{
+    foreach (rng; pdso._gcRanges)
+        GC.removeRange(rng.ptr);
+}
+
+version (Shared) void runFinalizers(DSO* pdso)
+{
+    foreach (seg; pdso._codeSegments)
+        GC.runFinalizers(seg);
+}
+
+void freeDSO(DSO* pdso)
+{
+    pdso._gcRanges.reset();
+    version (Shared) pdso._codeSegments.reset();
+    .free(pdso);
+}
+
+version (Shared)
+{
+nothrow:
+    link_map* linkMapForHandle(void* handle)
+    {
+        link_map* map;
+        dlinfo(handle, RTLD_DI_LINKMAP, &map) == 0 || assert(0);
+        return map;
+    }
+
+     link_map* exeLinkMap(link_map* map)
+     {
+         assert(map);
+         while (map.l_prev !is null)
+             map = map.l_prev;
+         return map;
+     }
+
+    DSO* dsoForHandle(void* handle)
+    {
+        DSO* pdso;
+        !pthread_mutex_lock(&_handleToDSOMutex) || assert(0);
+        if (auto ppdso = handle in _handleToDSO)
+            pdso = *ppdso;
+        !pthread_mutex_unlock(&_handleToDSOMutex) || assert(0);
+        return pdso;
+    }
+
+    void setDSOForHandle(DSO* pdso, void* handle)
+    {
+        !pthread_mutex_lock(&_handleToDSOMutex) || assert(0);
+        assert(handle !in _handleToDSO);
+        _handleToDSO[handle] = pdso;
+        !pthread_mutex_unlock(&_handleToDSOMutex) || assert(0);
+    }
+
+    void unsetDSOForHandle(DSO* pdso, void* handle)
+    {
+        !pthread_mutex_lock(&_handleToDSOMutex) || assert(0);
+        assert(_handleToDSO[handle] == pdso);
+        _handleToDSO.remove(handle);
+        !pthread_mutex_unlock(&_handleToDSOMutex) || assert(0);
+    }
+
+    void getDependencies(in ref dl_phdr_info info, ref Array!(DSO*) deps)
+    {
+        // get the entries of the .dynamic section
+        ElfW!"Dyn"[] dyns;
+        foreach (ref phdr; info.dlpi_phdr[0 .. info.dlpi_phnum])
+        {
+            if (phdr.p_type == PT_DYNAMIC)
+            {
+                auto p = cast(ElfW!"Dyn"*)(info.dlpi_addr + (phdr.p_vaddr & ~(size_t.sizeof - 1)));
+                dyns = p[0 .. phdr.p_memsz / ElfW!"Dyn".sizeof];
+                break;
+            }
+        }
+        // find the string table which contains the sonames
+        const(char)* strtab;
+        foreach (dyn; dyns)
+        {
+            if (dyn.d_tag == DT_STRTAB)
+            {
+                version (linux)
+                    strtab = cast(const(char)*)dyn.d_un.d_ptr;
+                else version (FreeBSD)
+                    strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate
+                else
+                    static assert(0, "unimplemented");
+                break;
+            }
+        }
+        foreach (dyn; dyns)
+        {
+            immutable tag = dyn.d_tag;
+            if (!(tag == DT_NEEDED || tag == DT_AUXILIARY || tag == DT_FILTER))
+                continue;
+
+            // soname of the dependency
+            auto name = strtab + dyn.d_un.d_val;
+            // get handle without loading the library
+            auto handle = handleForName(name);
+            // the runtime linker has already loaded all dependencies
+            if (handle is null) assert(0);
+            // if it's a D library
+            if (auto pdso = dsoForHandle(handle))
+                deps.insertBack(pdso); // append it to the dependencies
+        }
+    }
+
+    void* handleForName(const char* name)
+    {
+        auto handle = .dlopen(name, RTLD_NOLOAD | RTLD_LAZY);
+        if (handle !is null) .dlclose(handle); // drop reference count
+        return handle;
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Elf program header iteration
+///////////////////////////////////////////////////////////////////////////////
+
+/************
+ * Scan segments in Linux dl_phdr_info struct and store
+ * the TLS and writeable data segments in *pdso.
+ */
+void scanSegments(in ref dl_phdr_info info, DSO* pdso)
+{
+    foreach (ref phdr; info.dlpi_phdr[0 .. info.dlpi_phnum])
+    {
+        switch (phdr.p_type)
+        {
+        case PT_LOAD:
+            if (phdr.p_flags & PF_W) // writeable data segment
+            {
+                auto beg = cast(void*)(info.dlpi_addr + (phdr.p_vaddr & ~(size_t.sizeof - 1)));
+                pdso._gcRanges.insertBack(beg[0 .. phdr.p_memsz]);
+            }
+            version (Shared) if (phdr.p_flags & PF_X) // code segment
+            {
+                auto beg = cast(void*)(info.dlpi_addr + (phdr.p_vaddr & ~(size_t.sizeof - 1)));
+                pdso._codeSegments.insertBack(beg[0 .. phdr.p_memsz]);
+            }
+            break;
+
+        case PT_TLS: // TLS segment
+            assert(!pdso._tlsSize); // is unique per DSO
+            pdso._tlsMod = info.dlpi_tls_modid;
+            pdso._tlsSize = phdr.p_memsz;
+            break;
+
+        default:
+            break;
+        }
+    }
+}
+
+/**************************
+ * Input:
+ *      result  where the output is to be written; dl_phdr_info is a Linux struct
+ * Returns:
+ *      true if found, and *result is filled in
+ * References:
+ *      http://linux.die.net/man/3/dl_iterate_phdr
+ */
+version (linux) bool findDSOInfoForAddr(in void* addr, dl_phdr_info* result=null) nothrow @nogc
+{
+    static struct DG { const(void)* addr; dl_phdr_info* result; }
+
+    extern(C) int callback(dl_phdr_info* info, size_t sz, void* arg) nothrow @nogc
+    {
+        auto p = cast(DG*)arg;
+        if (findSegmentForAddr(*info, p.addr))
+        {
+            if (p.result !is null) *p.result = *info;
+            return 1; // break;
+        }
+        return 0; // continue iteration
+    }
+
+    auto dg = DG(addr, result);
+
+    /* Linux function that walks through the list of an application's shared objects and
+     * calls 'callback' once for each object, until either all shared objects
+     * have been processed or 'callback' returns a nonzero value.
+     */
+    return dl_iterate_phdr(&callback, &dg) != 0;
+}
+else version (FreeBSD) bool findDSOInfoForAddr(in void* addr, dl_phdr_info* result=null) nothrow @nogc
+{
+    return !!_rtld_addr_phdr(addr, result);
+}
+
+/*********************************
+ * Determine if 'addr' lies within shared object 'info'.
+ * If so, return true and fill in 'result' with the corresponding ELF program header.
+ */
+bool findSegmentForAddr(in ref dl_phdr_info info, in void* addr, ElfW!"Phdr"* result=null) nothrow @nogc
+{
+    if (addr < cast(void*)info.dlpi_addr) // less than base address of object means quick reject
+        return false;
+
+    foreach (ref phdr; info.dlpi_phdr[0 .. info.dlpi_phnum])
+    {
+        auto beg = cast(void*)(info.dlpi_addr + phdr.p_vaddr);
+        if (cast(size_t)(addr - beg) < phdr.p_memsz)
+        {
+            if (result !is null) *result = phdr;
+            return true;
+        }
+    }
+    return false;
+}
+
+version (linux) import core.sys.linux.errno : program_invocation_name;
+// should be in core.sys.freebsd.stdlib
+version (FreeBSD) extern(C) const(char)* getprogname() nothrow @nogc;
+
+@property const(char)* progname() nothrow @nogc
+{
+    version (linux) return program_invocation_name;
+    version (FreeBSD) return getprogname();
+}
+
+nothrow
+const(char)[] dsoName(const char* dlpi_name)
+{
+    // the main executable doesn't have a name in its dlpi_name field
+    const char* p = dlpi_name[0] != 0 ? dlpi_name : progname;
+    return p[0 .. strlen(p)];
+}
+
+extern(C)
+{
+    void* rt_get_bss_start() @nogc nothrow;
+    void* rt_get_end() @nogc nothrow;
+}
+
+/// get the BSS section of the executable to check for copy relocations
+const(void)[] getCopyRelocSection() nothrow
+{
+    auto bss_start = rt_get_bss_start();
+    auto bss_end = rt_get_end();
+    immutable bss_size = bss_end - bss_start;
+
+    /**
+       Check whether __bss_start/_end both lie within the executable DSO.same DSO.
+
+       When a C host program dynamically loads druntime, i.e. it isn't linked
+       against, __bss_start/_end might be defined in different DSOs, b/c the
+       linker creates those symbols only when they are used.
+       But as there are no copy relocations when dynamically loading a shared
+       library, we can simply return a null bss range in that case.
+    */
+    if (bss_size <= 0)
+        return null;
+
+    version (linux)
+        enum ElfW!"Addr" exeBaseAddr = 0;
+    else version (FreeBSD)
+        enum ElfW!"Addr" exeBaseAddr = 0;
+
+    dl_phdr_info info = void;
+    findDSOInfoForAddr(bss_start, &info) || assert(0);
+    if (info.dlpi_addr != exeBaseAddr)
+        return null;
+    findDSOInfoForAddr(bss_end - 1, &info) || assert(0);
+    if (info.dlpi_addr != exeBaseAddr)
+        return null;
+
+    return bss_start[0 .. bss_size];
+}
+
+/**
+ * Check for module collisions. A module in a shared library collides
+ * with an existing module if it's ModuleInfo is interposed (search
+ * symbol interposition) by another DSO.  Therefor two modules with the
+ * same name do not collide if their DSOs are in separate symbol resolution
+ * chains.
+ */
+void checkModuleCollisions(in ref dl_phdr_info info, in immutable(ModuleInfo)*[] modules,
+                           in void[] copyRelocSection) nothrow
+in { assert(modules.length); }
+body
+{
+    immutable(ModuleInfo)* conflicting;
+
+    foreach (m; modules)
+    {
+        auto addr = cast(const(void*))m;
+        if (cast(size_t)(addr - copyRelocSection.ptr) < copyRelocSection.length)
+        {
+            // Module is in .bss of the exe because it was copy relocated
+        }
+        else if (!findSegmentForAddr(info, addr))
+        {
+            // Module is in another DSO
+            conflicting = m;
+            break;
+        }
+    }
+
+    if (conflicting !is null)
+    {
+        dl_phdr_info other=void;
+        findDSOInfoForAddr(conflicting, &other) || assert(0);
+
+        auto modname = conflicting.name;
+        auto loading = dsoName(info.dlpi_name);
+        auto existing = dsoName(other.dlpi_name);
+        fprintf(stderr, "Fatal Error while loading '%.*s':\n\tThe module '%.*s' is already defined in '%.*s'.\n",
+                cast(int)loading.length, loading.ptr,
+                cast(int)modname.length, modname.ptr,
+                cast(int)existing.length, existing.ptr);
+        import core.stdc.stdlib : _Exit;
+        _Exit(1);
+    }
+}
+
+/**************************
+ * Input:
+ *      addr  an internal address of a DSO
+ * Returns:
+ *      the dlopen handle for that DSO or null if addr is not within a loaded DSO
+ */
+version (Shared) void* handleForAddr(void* addr)
+{
+    Dl_info info = void;
+    if (dladdr(addr, &info) != 0)
+        return handleForName(info.dli_fname);
+    return null;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// TLS module helper
+///////////////////////////////////////////////////////////////////////////////
+
+
+/*
+ * Returns: the TLS memory range for a given module and the calling
+ * thread or null if that module has no TLS.
+ *
+ * Note: This will cause the TLS memory to be eagerly allocated.
+ */
+struct tls_index
+{
+    size_t ti_module;
+    size_t ti_offset;
+}
+
+extern(C) void* __tls_get_addr(tls_index* ti);
+
+/* The dynamic thread vector (DTV) pointers may point 0x8000 past the start of
+ * each TLS block. This is at least true for PowerPC and Mips platforms.
+ * See: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/dl-tls.h;h=f7cf6f96ebfb505abfd2f02be0ad0e833107c0cd;hb=HEAD#l34
+ *      https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/mips/dl-tls.h;h=93a6dc050cb144b9f68b96fb3199c60f5b1fcd18;hb=HEAD#l32
+ */
+version(X86)
+    enum TLS_DTV_OFFSET = 0x;
+else version(X86_64)
+    enum TLS_DTV_OFFSET = 0x;
+else version(ARM)
+    enum TLS_DTV_OFFSET = 0x;
+else version(AArch64)
+    enum TLS_DTV_OFFSET = 0x;
+else version(SPARC)
+    enum TLS_DTV_OFFSET = 0x;
+else version(SPARC64)
+    enum TLS_DTV_OFFSET = 0x;
+else version(PPC)
+    enum TLS_DTV_OFFSET = 0x8000;
+else version(PPC64)
+    enum TLS_DTV_OFFSET = 0x8000;
+else version(MIPS)
+    enum TLS_DTV_OFFSET = 0x8000;
+else version(MIPS64)
+    enum TLS_DTV_OFFSET = 0x8000;
+else
+    static assert( false, "Platform not supported." );
+
+void[] getTLSRange(size_t mod, size_t sz)
+{
+    if (mod == 0)
+        return null;
+
+    // base offset
+    auto ti = tls_index(mod, 0);
+    return (__tls_get_addr(&ti)-TLS_DTV_OFFSET)[0 .. sz];
+}
diff --git a/libphobos/libdruntime/rt/sections_osx.d b/libphobos/libdruntime/rt/sections_osx.d
new file mode 100644
index 00000000000..b41f9982d16
--- /dev/null
+++ b/libphobos/libdruntime/rt/sections_osx.d
@@ -0,0 +1,277 @@
+/**
+ * Written in the D programming language.
+ * This module provides OSX-specific support for sections.
+ *
+ * Copyright: Copyright Digital Mars 2008 - 2012.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Walter Bright, Sean Kelly, Martin Nowak
+ * Source: $(DRUNTIMESRC src/rt/_sections_osx.d)
+ */
+
+module rt.sections_osx;
+
+version(OSX):
+
+// debug = PRINTF;
+import core.stdc.stdio;
+import core.stdc.string, core.stdc.stdlib;
+import core.sys.posix.pthread;
+import core.sys.osx.mach.dyld;
+import core.sys.osx.mach.getsect;
+import rt.deh, rt.minfo;
+import rt.util.container.array;
+
+struct SectionGroup
+{
+    static int opApply(scope int delegate(ref SectionGroup) dg)
+    {
+        return dg(_sections);
+    }
+
+    static int opApplyReverse(scope int delegate(ref SectionGroup) dg)
+    {
+        return dg(_sections);
+    }
+
+    @property immutable(ModuleInfo*)[] modules() const
+    {
+        return _moduleGroup.modules;
+    }
+
+    @property ref inout(ModuleGroup) moduleGroup() inout
+    {
+        return _moduleGroup;
+    }
+
+    @property inout(void[])[] gcRanges() inout
+    {
+        return _gcRanges[];
+    }
+
+    @property immutable(FuncTable)[] ehTables() const
+    {
+        return _ehTables[];
+    }
+
+private:
+    immutable(FuncTable)[] _ehTables;
+    ModuleGroup _moduleGroup;
+    Array!(void[]) _gcRanges;
+    immutable(void)[][2] _tlsImage;
+}
+
+/****
+ * Boolean flag set to true while the runtime is initialized.
+ */
+__gshared bool _isRuntimeInitialized;
+
+/****
+ * Gets called on program startup just before GC is initialized.
+ */
+void initSections()
+{
+    pthread_key_create(&_tlsKey, null);
+    _dyld_register_func_for_add_image(&sections_osx_onAddImage);
+    _isRuntimeInitialized = true;
+}
+
+/***
+ * Gets called on program shutdown just after GC is terminated.
+ */
+void finiSections()
+{
+    _sections._gcRanges.reset();
+    pthread_key_delete(_tlsKey);
+    _isRuntimeInitialized = false;
+}
+
+void[]* initTLSRanges()
+{
+    return &getTLSBlock();
+}
+
+void finiTLSRanges(void[]* rng)
+{
+    .free(rng.ptr);
+    .free(rng);
+}
+
+void scanTLSRanges(void[]* rng, scope void delegate(void* pbeg, void* pend) nothrow dg) nothrow
+{
+    dg(rng.ptr, rng.ptr + rng.length);
+}
+
+// NOTE: The Mach-O object file format does not allow for thread local
+//       storage declarations. So instead we roll our own by putting tls
+//       into the __tls_data and the __tlscoal_nt sections.
+//
+//       This function is called by the code emitted by the compiler.  It
+//       is expected to translate an address into the TLS static data to
+//       the corresponding address in the TLS dynamic per-thread data.
+
+// NB: the compiler mangles this function as '___tls_get_addr' even though it is extern(D)
+extern(D) void* ___tls_get_addr( void* p )
+{
+    immutable off = tlsOffset(p);
+    auto tls = getTLSBlockAlloc();
+    assert(off < tls.length);
+    return tls.ptr + off;
+}
+
+private:
+
+__gshared pthread_key_t _tlsKey;
+
+size_t tlsOffset(void* p)
+in
+{
+    assert(_sections._tlsImage[0].ptr !is null ||
+           _sections._tlsImage[1].ptr !is null);
+}
+body
+{
+    // NOTE: p is an address in the TLS static data emitted by the
+    //       compiler.  If it isn't, something is disastrously wrong.
+    immutable off0 = cast(size_t)(p - _sections._tlsImage[0].ptr);
+    if (off0 < _sections._tlsImage[0].length)
+    {
+        return off0;
+    }
+    immutable off1 = cast(size_t)(p - _sections._tlsImage[1].ptr);
+    if (off1 < _sections._tlsImage[1].length)
+    {
+        size_t sz = (_sections._tlsImage[0].length + 15) & ~cast(size_t)15;
+        return sz + off1;
+    }
+    assert(0);
+}
+
+ref void[] getTLSBlock()
+{
+    auto pary = cast(void[]*)pthread_getspecific(_tlsKey);
+    if (pary is null)
+    {
+        pary = cast(void[]*).calloc(1, (void[]).sizeof);
+        if (pthread_setspecific(_tlsKey, pary) != 0)
+        {
+            import core.stdc.stdio;
+            perror("pthread_setspecific failed with");
+            assert(0);
+        }
+    }
+    return *pary;
+}
+
+ref void[] getTLSBlockAlloc()
+{
+    auto pary = &getTLSBlock();
+    if (!pary.length)
+    {
+        auto imgs = _sections._tlsImage;
+        immutable sz0 = (imgs[0].length + 15) & ~cast(size_t)15;
+        immutable sz2 = sz0 + imgs[1].length;
+        auto p = .malloc(sz2);
+        memcpy(p, imgs[0].ptr, imgs[0].length);
+        memcpy(p + sz0, imgs[1].ptr, imgs[1].length);
+        *pary = p[0 .. sz2];
+    }
+    return *pary;
+}
+
+
+__gshared SectionGroup _sections;
+
+extern (C) void sections_osx_onAddImage(in mach_header* h, intptr_t slide)
+{
+    foreach (e; dataSegs)
+    {
+        auto sect = getSection(h, slide, e.seg.ptr, e.sect.ptr);
+        if (sect != null)
+            _sections._gcRanges.insertBack((cast(void*)sect.ptr)[0 .. sect.length]);
+    }
+
+    auto minfosect = getSection(h, slide, "__DATA", "__minfodata");
+    if (minfosect != null)
+    {
+        // no support for multiple images yet
+        // take the sections from the last static image which is the executable
+        if (_isRuntimeInitialized)
+        {
+            fprintf(stderr, "Loading shared libraries isn't yet supported on OSX.\n");
+            return;
+        }
+        else if (_sections.modules.ptr !is null)
+        {
+            fprintf(stderr, "Shared libraries are not yet supported on OSX.\n");
+        }
+
+        debug(PRINTF) printf("  minfodata\n");
+        auto p = cast(immutable(ModuleInfo*)*)minfosect.ptr;
+        immutable len = minfosect.length / (*p).sizeof;
+
+        _sections._moduleGroup = ModuleGroup(p[0 .. len]);
+    }
+
+    auto ehsect = getSection(h, slide, "__DATA", "__deh_eh");
+    if (ehsect != null)
+    {
+        debug(PRINTF) printf("  deh_eh\n");
+        auto p = cast(immutable(FuncTable)*)ehsect.ptr;
+        immutable len = ehsect.length / (*p).sizeof;
+
+        _sections._ehTables = p[0 .. len];
+    }
+
+    auto tlssect = getSection(h, slide, "__DATA", "__tls_data");
+    if (tlssect != null)
+    {
+        debug(PRINTF) printf("  tls_data %p %p\n", tlssect.ptr, tlssect.ptr + tlssect.length);
+        _sections._tlsImage[0] = (cast(immutable(void)*)tlssect.ptr)[0 .. tlssect.length];
+    }
+
+    auto tlssect2 = getSection(h, slide, "__DATA", "__tlscoal_nt");
+    if (tlssect2 != null)
+    {
+        debug(PRINTF) printf("  tlscoal_nt %p %p\n", tlssect2.ptr, tlssect2.ptr + tlssect2.length);
+        _sections._tlsImage[1] = (cast(immutable(void)*)tlssect2.ptr)[0 .. tlssect2.length];
+    }
+}
+
+struct SegRef
+{
+    string seg;
+    string sect;
+}
+
+
+static immutable SegRef[] dataSegs = [{SEG_DATA, SECT_DATA},
+                                      {SEG_DATA, SECT_BSS},
+                                      {SEG_DATA, SECT_COMMON}];
+
+
+ubyte[] getSection(in mach_header* header, intptr_t slide,
+                   in char* segmentName, in char* sectionName)
+{
+    version (X86)
+    {
+        assert(header.magic == MH_MAGIC);
+        auto sect = getsectbynamefromheader(header,
+                                            segmentName,
+                                            sectionName);
+    }
+    else version (X86_64)
+    {
+        assert(header.magic == MH_MAGIC_64);
+        auto sect = getsectbynamefromheader_64(cast(mach_header_64*)header,
+                                            segmentName,
+                                            sectionName);
+    }
+    else
+        static assert(0, "unimplemented");
+
+    if (sect !is null && sect.size > 0)
+        return (cast(ubyte*)sect.addr + slide)[0 .. cast(size_t)sect.size];
+    return null;
+}
diff --git a/libphobos/libdruntime/rt/sections_solaris.d b/libphobos/libdruntime/rt/sections_solaris.d
new file mode 100644
index 00000000000..bf7773de919
--- /dev/null
+++ b/libphobos/libdruntime/rt/sections_solaris.d
@@ -0,0 +1,114 @@
+/**
+ * Written in the D programming language.
+ * This module provides Solaris-specific support for sections.
+ *
+ * Copyright: Copyright Martin Nowak 2012-2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ * Source: $(DRUNTIMESRC src/rt/_sections_solaris.d)
+ */
+
+module rt.sections_solaris;
+
+version (Solaris):
+
+// debug = PRINTF;
+debug(PRINTF) import core.stdc.stdio;
+import core.stdc.stdlib : malloc, free;
+import rt.deh, rt.minfo;
+
+struct SectionGroup
+{
+    static int opApply(scope int delegate(ref SectionGroup) dg)
+    {
+        return dg(_sections);
+    }
+
+    static int opApplyReverse(scope int delegate(ref SectionGroup) dg)
+    {
+        return dg(_sections);
+    }
+
+    @property immutable(ModuleInfo*)[] modules() const
+    {
+        return _moduleGroup.modules;
+    }
+
+    @property ref inout(ModuleGroup) moduleGroup() inout
+    {
+        return _moduleGroup;
+    }
+
+    @property immutable(FuncTable)[] ehTables() const
+    {
+        auto pbeg = cast(immutable(FuncTable)*)&__start_deh;
+        auto pend = cast(immutable(FuncTable)*)&__stop_deh;
+        return pbeg[0 .. pend - pbeg];
+    }
+
+    @property inout(void[])[] gcRanges() inout
+    {
+        return _gcRanges[];
+    }
+
+private:
+    ModuleGroup _moduleGroup;
+    void[][1] _gcRanges;
+}
+
+void initSections()
+{
+    auto mbeg = cast(immutable ModuleInfo**)&__start_minfo;
+    auto mend = cast(immutable ModuleInfo**)&__stop_minfo;
+    _sections.moduleGroup = ModuleGroup(mbeg[0 .. mend - mbeg]);
+
+    auto pbeg = cast(void*)&__dso_handle;
+    auto pend = cast(void*)&_end;
+    _sections._gcRanges[0] = pbeg[0 .. pend - pbeg];
+}
+
+void finiSections()
+{
+}
+
+void[] initTLSRanges()
+{
+    auto pbeg = cast(void*)&_tlsstart;
+    auto pend = cast(void*)&_tlsend;
+    return pbeg[0 .. pend - pbeg];
+}
+
+void finiTLSRanges(void[] rng)
+{
+}
+
+void scanTLSRanges(void[] rng, scope void delegate(void* pbeg, void* pend) nothrow dg) nothrow
+{
+    dg(rng.ptr, rng.ptr + rng.length);
+}
+
+private:
+
+__gshared SectionGroup _sections;
+
+extern(C)
+{
+    /* Symbols created by the compiler/linker and inserted into the
+     * object file that 'bracket' sections.
+     */
+    extern __gshared
+    {
+        void* __start_deh;
+        void* __stop_deh;
+        void* __start_minfo;
+        void* __stop_minfo;
+        int __dso_handle;
+        int _end;
+    }
+
+    extern
+    {
+        void* _tlsstart;
+        void* _tlsend;
+    }
+}
diff --git a/libphobos/libdruntime/rt/sections_win32.d b/libphobos/libdruntime/rt/sections_win32.d
new file mode 100644
index 00000000000..526dc4d6500
--- /dev/null
+++ b/libphobos/libdruntime/rt/sections_win32.d
@@ -0,0 +1,122 @@
+/**
+ * Written in the D programming language.
+ * This module provides Win32-specific support for sections.
+ *
+ * Copyright: Copyright Digital Mars 2008 - 2012.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Walter Bright, Sean Kelly, Martin Nowak
+ * Source: $(DRUNTIMESRC src/rt/_sections_win32.d)
+ */
+
+module rt.sections_win32;
+
+version(CRuntime_DigitalMars):
+
+// debug = PRINTF;
+debug(PRINTF) import core.stdc.stdio;
+import rt.minfo;
+
+struct SectionGroup
+{
+    static int opApply(scope int delegate(ref SectionGroup) dg)
+    {
+        return dg(_sections);
+    }
+
+    static int opApplyReverse(scope int delegate(ref SectionGroup) dg)
+    {
+        return dg(_sections);
+    }
+
+    @property immutable(ModuleInfo*)[] modules() const
+    {
+        return _moduleGroup.modules;
+    }
+
+    @property ref inout(ModuleGroup) moduleGroup() inout
+    {
+        return _moduleGroup;
+    }
+
+    @property inout(void[])[] gcRanges() inout
+    {
+        return _gcRanges[];
+    }
+
+private:
+    ModuleGroup _moduleGroup;
+    void[][2] _gcRanges;
+}
+
+void initSections()
+{
+    _sections._moduleGroup = ModuleGroup(getModuleInfos());
+
+    auto databeg = cast(void*)&_xi_a;
+    auto dataend = cast(void*)_moduleinfo_array.ptr;
+    _sections._gcRanges[0] = databeg[0 .. dataend - databeg];
+
+    // skip module info and CONST segment
+    auto bssbeg = cast(void*)&_edata;
+    auto bssend = cast(void*)&_end;
+    _sections._gcRanges[1] = bssbeg[0 .. bssend - bssbeg];
+}
+
+void finiSections()
+{
+}
+
+void[] initTLSRanges()
+{
+    auto pbeg = cast(void*)&_tlsstart;
+    auto pend = cast(void*)&_tlsend;
+    return pbeg[0 .. pend - pbeg];
+}
+
+void finiTLSRanges(void[] rng)
+{
+}
+
+void scanTLSRanges(void[] rng, scope void delegate(void* pbeg, void* pend) nothrow dg) nothrow
+{
+    dg(rng.ptr, rng.ptr + rng.length);
+}
+
+private:
+
+__gshared SectionGroup _sections;
+
+// Windows: this gets initialized by minit.asm
+extern(C) __gshared immutable(ModuleInfo*)[] _moduleinfo_array;
+extern(C) void _minit();
+
+immutable(ModuleInfo*)[] getModuleInfos()
+out (result)
+{
+    foreach(m; result)
+        assert(m !is null);
+}
+body
+{
+    // _minit directly alters the global _moduleinfo_array
+    _minit();
+    return _moduleinfo_array;
+}
+
+extern(C)
+{
+    extern __gshared
+    {
+        int _xi_a;      // &_xi_a just happens to be start of data segment
+        int _edata;     // &_edata is start of BSS segment
+        int _end;       // &_end is past end of BSS
+    }
+
+    extern
+    {
+        int _tlsstart;
+        int _tlsend;
+    }
+}
diff --git a/libphobos/libdruntime/rt/sections_win64.d b/libphobos/libdruntime/rt/sections_win64.d
new file mode 100644
index 00000000000..86065813738
--- /dev/null
+++ b/libphobos/libdruntime/rt/sections_win64.d
@@ -0,0 +1,222 @@
+/**
+ * Written in the D programming language.
+ * This module provides Win32-specific support for sections.
+ *
+ * Copyright: Copyright Digital Mars 2008 - 2012.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Walter Bright, Sean Kelly, Martin Nowak
+ * Source: $(DRUNTIMESRC src/rt/_sections_win64.d)
+ */
+
+module rt.sections_win64;
+
+version(CRuntime_Microsoft):
+
+// debug = PRINTF;
+debug(PRINTF) import core.stdc.stdio;
+import core.stdc.stdlib : malloc, free;
+import rt.deh, rt.minfo;
+
+struct SectionGroup
+{
+    static int opApply(scope int delegate(ref SectionGroup) dg)
+    {
+        return dg(_sections);
+    }
+
+    static int opApplyReverse(scope int delegate(ref SectionGroup) dg)
+    {
+        return dg(_sections);
+    }
+
+    @property immutable(ModuleInfo*)[] modules() const
+    {
+        return _moduleGroup.modules;
+    }
+
+    @property ref inout(ModuleGroup) moduleGroup() inout
+    {
+        return _moduleGroup;
+    }
+
+    version(Win64)
+    @property immutable(FuncTable)[] ehTables() const
+    {
+        auto pbeg = cast(immutable(FuncTable)*)&_deh_beg;
+        auto pend = cast(immutable(FuncTable)*)&_deh_end;
+        return pbeg[0 .. pend - pbeg];
+    }
+
+    @property inout(void[])[] gcRanges() inout
+    {
+        return _gcRanges[];
+    }
+
+private:
+    ModuleGroup _moduleGroup;
+    void[][1] _gcRanges;
+}
+
+void initSections()
+{
+    _sections._moduleGroup = ModuleGroup(getModuleInfos());
+
+    // the ".data" image section includes both object file sections ".data" and ".bss"
+    _sections._gcRanges[0] = findImageSection(".data");
+    debug(PRINTF) printf("found .data section: [%p,+%llx]\n", _sections._gcRanges[0].ptr,
+                         cast(ulong)_sections._gcRanges[0].length);
+}
+
+void finiSections()
+{
+    .free(cast(void*)_sections.modules.ptr);
+}
+
+void[] initTLSRanges()
+{
+    auto pbeg = cast(void*)&_tls_start;
+    auto pend = cast(void*)&_tls_end;
+    return pbeg[0 .. pend - pbeg];
+}
+
+void finiTLSRanges(void[] rng)
+{
+}
+
+void scanTLSRanges(void[] rng, scope void delegate(void* pbeg, void* pend) nothrow dg) nothrow
+{
+    dg(rng.ptr, rng.ptr + rng.length);
+}
+
+private:
+__gshared SectionGroup _sections;
+
+extern(C)
+{
+    extern __gshared void* _minfo_beg;
+    extern __gshared void* _minfo_end;
+}
+
+immutable(ModuleInfo*)[] getModuleInfos()
+out (result)
+{
+    foreach(m; result)
+        assert(m !is null);
+}
+body
+{
+    auto m = (cast(immutable(ModuleInfo*)*)&_minfo_beg)[1 .. &_minfo_end - &_minfo_beg];
+    /* Because of alignment inserted by the linker, various null pointers
+     * are there. We need to filter them out.
+     */
+    auto p = m.ptr;
+    auto pend = m.ptr + m.length;
+
+    // count non-null pointers
+    size_t cnt;
+    for (; p < pend; ++p)
+    {
+        if (*p !is null) ++cnt;
+    }
+
+    auto result = (cast(immutable(ModuleInfo)**).malloc(cnt * size_t.sizeof))[0 .. cnt];
+
+    p = m.ptr;
+    cnt = 0;
+    for (; p < pend; ++p)
+        if (*p !is null) result[cnt++] = *p;
+
+    return cast(immutable)result;
+}
+
+extern(C)
+{
+    /* Symbols created by the compiler/linker and inserted into the
+     * object file that 'bracket' sections.
+     */
+    extern __gshared
+    {
+        void* __ImageBase;
+
+        void* _deh_beg;
+        void* _deh_end;
+    }
+
+    extern
+    {
+        int _tls_start;
+        int _tls_end;
+    }
+}
+
+/////////////////////////////////////////////////////////////////////
+
+enum IMAGE_DOS_SIGNATURE = 0x5A4D;      // MZ
+
+struct IMAGE_DOS_HEADER // DOS .EXE header
+{
+    ushort   e_magic;    // Magic number
+    ushort[29] e_res2;   // Reserved ushorts
+    int      e_lfanew;   // File address of new exe header
+}
+
+struct IMAGE_FILE_HEADER
+{
+    ushort Machine;
+    ushort NumberOfSections;
+    uint   TimeDateStamp;
+    uint   PointerToSymbolTable;
+    uint   NumberOfSymbols;
+    ushort SizeOfOptionalHeader;
+    ushort Characteristics;
+}
+
+struct IMAGE_NT_HEADERS
+{
+    uint Signature;
+    IMAGE_FILE_HEADER FileHeader;
+    // optional header follows
+}
+
+struct IMAGE_SECTION_HEADER
+{
+    char[8] Name;
+    union {
+        uint   PhysicalAddress;
+        uint   VirtualSize;
+    }
+    uint   VirtualAddress;
+    uint   SizeOfRawData;
+    uint   PointerToRawData;
+    uint   PointerToRelocations;
+    uint   PointerToLinenumbers;
+    ushort NumberOfRelocations;
+    ushort NumberOfLinenumbers;
+    uint   Characteristics;
+}
+
+bool compareSectionName(ref IMAGE_SECTION_HEADER section, string name) nothrow
+{
+    if (name[] != section.Name[0 .. name.length])
+        return false;
+    return name.length == 8 || section.Name[name.length] == 0;
+}
+
+void[] findImageSection(string name) nothrow
+{
+    if (name.length > 8) // section name from string table not supported
+        return null;
+    IMAGE_DOS_HEADER* doshdr = cast(IMAGE_DOS_HEADER*) &__ImageBase;
+    if (doshdr.e_magic != IMAGE_DOS_SIGNATURE)
+        return null;
+
+    auto nthdr = cast(IMAGE_NT_HEADERS*)(cast(void*)doshdr + doshdr.e_lfanew);
+    auto sections = cast(IMAGE_SECTION_HEADER*)(cast(void*)nthdr + IMAGE_NT_HEADERS.sizeof + nthdr.FileHeader.SizeOfOptionalHeader);
+    for(ushort i = 0; i < nthdr.FileHeader.NumberOfSections; i++)
+        if (compareSectionName (sections[i], name))
+            return (cast(void*)&__ImageBase + sections[i].VirtualAddress)[0 .. sections[i].VirtualSize];
+
+    return null;
+}
diff --git a/libphobos/libdruntime/rt/switch_.d b/libphobos/libdruntime/rt/switch_.d
new file mode 100644
index 00000000000..ec124e3f7bd
--- /dev/null
+++ b/libphobos/libdruntime/rt/switch_.d
@@ -0,0 +1,424 @@
+/**
+ * Contains support code for switch blocks using string constants.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2010.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Sean Kelly
+ */
+
+/*          Copyright Digital Mars 2004 - 2010.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.switch_;
+
+private import core.stdc.string;
+
+/******************************************************
+ * Support for switch statements switching on strings.
+ * Input:
+ *      table[]         sorted array of strings generated by compiler
+ *      ca              string to look up in table
+ * Output:
+ *      result          index of match in table[]
+ *                      -1 if not in table
+ */
+
+extern (C):
+
+int _d_switch_string(char[][] table, char[] ca)
+in
+{
+    //printf("in _d_switch_string()\n");
+    assert(table.length >= 0);
+    assert(ca.length >= 0);
+
+    // Make sure table[] is sorted correctly
+    for (size_t j = 1u; j < table.length; j++)
+    {
+        auto len1 = table[j - 1].length;
+        auto len2 = table[j].length;
+
+        assert(len1 <= len2);
+        if (len1 == len2)
+        {
+            int ci;
+
+            ci = memcmp(table[j - 1].ptr, table[j].ptr, len1);
+            assert(ci < 0); // ci==0 means a duplicate
+        }
+    }
+}
+out (result)
+{
+    int cj;
+
+    //printf("out _d_switch_string()\n");
+    if (result == -1)
+    {
+        // Not found
+        for (auto i = 0u; i < table.length; i++)
+        {
+            if (table[i].length == ca.length)
+            {   cj = memcmp(table[i].ptr, ca.ptr, ca.length);
+                assert(cj != 0);
+            }
+        }
+    }
+    else
+    {
+        assert(0 <= result && cast(size_t)result < table.length);
+        for (auto i = 0u; 1; i++)
+        {
+            assert(i < table.length);
+            if (table[i].length == ca.length)
+            {
+                cj = memcmp(table[i].ptr, ca.ptr, ca.length);
+                if (cj == 0)
+                {
+                    assert(i == result);
+                    break;
+                }
+            }
+        }
+    }
+}
+body
+{
+    //printf("body _d_switch_string(%.*s)\n", ca.length, ca.ptr);
+    size_t low  = 0;
+    size_t high = table.length;
+
+    version (none)
+    {
+        // Print table
+        printf("ca[] = '%s'\n", ca.length, ca.ptr);
+        for (auto i = 0; i < high; i++)
+        {
+            auto pca = table[i];
+            printf("table[%d] = %d, '%.*s'\n", i, pca.length, pca.length, pca.ptr);
+        }
+    }
+    if (high &&
+        ca.length >= table[0].length &&
+        ca.length <= table[high - 1].length)
+    {
+        // Looking for 0 length string, which would only be at the beginning
+        if (ca.length == 0)
+            return 0;
+
+        char c1 = ca[0];
+
+        // Do binary search
+        while (low < high)
+        {
+            auto mid = (low + high) >> 1;
+            auto pca = table[mid];
+            auto c   = cast(sizediff_t)(ca.length - pca.length);
+            if (c == 0)
+            {
+                c = cast(ubyte)c1 - cast(ubyte)pca[0];
+                if (c == 0)
+                {
+                    c = memcmp(ca.ptr, pca.ptr, ca.length);
+                    if (c == 0)
+                    {   //printf("found %d\n", mid);
+                        return cast(int)mid;
+                    }
+                }
+            }
+            if (c < 0)
+            {
+                high = mid;
+            }
+            else
+            {
+                low = mid + 1;
+            }
+        }
+    }
+
+    //printf("not found\n");
+    return -1; // not found
+}
+
+unittest
+{
+    switch (cast(char []) "c")
+    {
+         case "coo":
+         default:
+             break;
+    }
+
+    int bug5381(string s)
+    {
+        switch(s)
+        {
+            case "unittest":        return 1;
+            case "D_Version2":      return 2;
+            case "none":            return 3;
+            case "all":             return 4;
+            default:                return 5;
+        }
+    }
+    int rc = bug5381("none");
+    assert(rc == 3);
+}
+
+/**********************************
+ * Same thing, but for wide chars.
+ */
+
+int _d_switch_ustring(wchar[][] table, wchar[] ca)
+in
+{
+    //printf("in _d_switch_ustring()\n");
+    assert(table.length >= 0);
+    assert(ca.length >= 0);
+
+    // Make sure table[] is sorted correctly
+    for (size_t j = 1u; j < table.length; j++)
+    {
+        auto len1 = table[j - 1].length;
+        auto len2 = table[j].length;
+
+        assert(len1 <= len2);
+        if (len1 == len2)
+        {
+            int c;
+
+            c = memcmp(table[j - 1].ptr, table[j].ptr, len1 * wchar.sizeof);
+            assert(c < 0);  // c==0 means a duplicate
+        }
+    }
+}
+out (result)
+{
+    int c;
+
+    //printf("out _d_switch_ustring()\n");
+    if (result == -1)
+    {
+        // Not found
+        for (auto i = 0u; i < table.length; i++)
+        {
+            if (table[i].length == ca.length)
+            {   c = memcmp(table[i].ptr, ca.ptr, ca.length * wchar.sizeof);
+                assert(c != 0);
+            }
+        }
+    }
+    else
+    {
+        assert(0 <= result && cast(size_t)result < table.length);
+        for (auto i = 0u; 1; i++)
+        {
+            assert(i < table.length);
+            if (table[i].length == ca.length)
+            {
+                c = memcmp(table[i].ptr, ca.ptr, ca.length * wchar.sizeof);
+                if (c == 0)
+                {
+                    assert(i == result);
+                    break;
+                }
+            }
+        }
+    }
+}
+body
+{
+    //printf("body _d_switch_ustring()\n");
+    size_t low = 0;
+    auto high = table.length;
+
+    version(none)
+    {
+        // Print table
+        wprintf("ca[] = '%.*s'\n", ca.length, ca.ptr);
+        for (auto i = 0; i < high; i++)
+        {
+            auto pca = table[i];
+            wprintf("table[%d] = %d, '%.*s'\n", i, pca.length, pca.length, pca.ptr);
+        }
+    }
+
+    // Do binary search
+    while (low < high)
+    {
+        auto mid = (low + high) >> 1;
+        auto pca = table[mid];
+        auto c = cast(sizediff_t)(ca.length - pca.length);
+        if (c == 0)
+        {
+            c = memcmp(ca.ptr, pca.ptr, ca.length * wchar.sizeof);
+            if (c == 0)
+            {   //printf("found %d\n", mid);
+                return cast(int)mid;
+            }
+        }
+        if (c < 0)
+        {
+            high = mid;
+        }
+        else
+        {
+            low = mid + 1;
+        }
+    }
+    //printf("not found\n");
+    return -1;              // not found
+}
+
+
+unittest
+{
+    switch (cast(wchar []) "c")
+    {
+         case "coo":
+         default:
+             break;
+    }
+
+    int bug5381(wstring ws)
+    {
+        switch(ws)
+        {
+            case "unittest":        return 1;
+            case "D_Version2":      return 2;
+            case "none":            return 3;
+            case "all":             return 4;
+            default:                return 5;
+        }
+    }
+    int rc = bug5381("none"w);
+    assert(rc == 3);
+}
+
+/**********************************
+ * Same thing, but for wide chars.
+ */
+
+int _d_switch_dstring(dchar[][] table, dchar[] ca)
+in
+{
+    //printf("in _d_switch_dstring()\n");
+    assert(table.length >= 0);
+    assert(ca.length >= 0);
+
+    // Make sure table[] is sorted correctly
+    for (auto j = 1u; j < table.length; j++)
+    {
+        auto len1 = table[j - 1].length;
+        auto len2 = table[j].length;
+
+        assert(len1 <= len2);
+        if (len1 == len2)
+        {
+            auto c = memcmp(table[j - 1].ptr, table[j].ptr, len1 * dchar.sizeof);
+            assert(c < 0);  // c==0 means a duplicate
+        }
+    }
+}
+out (result)
+{
+    //printf("out _d_switch_dstring()\n");
+    if (result == -1)
+    {
+        // Not found
+        for (auto i = 0u; i < table.length; i++)
+        {
+            if (table[i].length == ca.length)
+            {   auto c = memcmp(table[i].ptr, ca.ptr, ca.length * dchar.sizeof);
+                assert(c != 0);
+            }
+        }
+    }
+    else
+    {
+        assert(0 <= result && cast(size_t)result < table.length);
+        for (auto i = 0u; 1; i++)
+        {
+            assert(i < table.length);
+            if (table[i].length == ca.length)
+            {
+                auto c = memcmp(table[i].ptr, ca.ptr, ca.length * dchar.sizeof);
+                if (c == 0)
+                {
+                    assert(i == result);
+                    break;
+                }
+            }
+        }
+    }
+}
+body
+{
+    //printf("body _d_switch_dstring()\n");
+    size_t low = 0;
+    auto high = table.length;
+
+    version(none)
+    {
+        // Print table
+        wprintf("ca[] = '%.*s'\n", ca.length, ca.ptr);
+        for (auto i = 0; i < high; i++)
+        {
+            auto pca = table[i];
+            wprintf("table[%d] = %d, '%.*s'\n", i, pca.length, pca.length, pca.ptr);
+        }
+    }
+
+    // Do binary search
+    while (low < high)
+    {
+        auto mid = (low + high) >> 1;
+        auto pca = table[mid];
+        auto c = cast(sizediff_t)(ca.length - pca.length);
+        if (c == 0)
+        {
+            c = memcmp(ca.ptr, pca.ptr, ca.length * dchar.sizeof);
+            if (c == 0)
+            {   //printf("found %d\n", mid);
+                return cast(int)mid;
+            }
+        }
+        if (c < 0)
+        {
+            high = mid;
+        }
+        else
+        {
+            low = mid + 1;
+        }
+    }
+    //printf("not found\n");
+    return -1; // not found
+}
+
+
+unittest
+{
+    switch (cast(dchar []) "c")
+    {
+         case "coo":
+         default:
+             break;
+    }
+
+    int bug5381(dstring ds)
+    {
+        switch(ds)
+        {
+            case "unittest":        return 1;
+            case "D_Version2":      return 2;
+            case "none":            return 3;
+            case "all":             return 4;
+            default:                return 5;
+        }
+    }
+    int rc = bug5381("none"d);
+    assert(rc == 3);
+}
diff --git a/libphobos/libdruntime/rt/tlsgc.d b/libphobos/libdruntime/rt/tlsgc.d
new file mode 100644
index 00000000000..e6da2e9a099
--- /dev/null
+++ b/libphobos/libdruntime/rt/tlsgc.d
@@ -0,0 +1,79 @@
+/**
+ *
+ * Copyright: Copyright Digital Mars 2011 - 2012.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ */
+
+/*          Copyright Digital Mars 2011.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.tlsgc;
+
+import core.stdc.stdlib;
+
+static import rt.lifetime, rt.sections;
+
+/**
+ * Per thread record to store thread associated data for garbage collection.
+ */
+struct Data
+{
+    typeof(rt.sections.initTLSRanges()) tlsRanges;
+    rt.lifetime.BlkInfo** blockInfoCache;
+}
+
+/**
+ * Initialization hook, called FROM each thread. No assumptions about
+ * module initialization state should be made.
+ */
+void* init()
+{
+    auto data = cast(Data*).malloc(Data.sizeof);
+    *data = Data.init;
+
+    // do module specific initialization
+    data.tlsRanges = rt.sections.initTLSRanges();
+    data.blockInfoCache = &rt.lifetime.__blkcache_storage;
+
+    return data;
+}
+
+/**
+ * Finalization hook, called FOR each thread. No assumptions about
+ * module initialization state should be made.
+ */
+void destroy(void* data)
+{
+    // do module specific finalization
+    rt.sections.finiTLSRanges((cast(Data*)data).tlsRanges);
+
+    .free(data);
+}
+
+alias void delegate(void* pstart, void* pend) nothrow ScanDg;
+
+/**
+ * GC scan hook, called FOR each thread. Can be used to scan
+ * additional thread local memory.
+ */
+void scan(void* data, scope ScanDg dg) nothrow
+{
+    // do module specific marking
+    rt.sections.scanTLSRanges((cast(Data*)data).tlsRanges, dg);
+}
+
+alias int delegate(void* addr) nothrow IsMarkedDg;
+
+/**
+ * GC sweep hook, called FOR each thread. Can be used to free
+ * additional thread local memory or associated data structures. Note
+ * that only memory allocated from the GC can have marks.
+ */
+void processGCMarks(void* data, scope IsMarkedDg dg) nothrow
+{
+    // do module specific sweeping
+    rt.lifetime.processGCMarks(*(cast(Data*)data).blockInfoCache, dg);
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_AC.d b/libphobos/libdruntime/rt/typeinfo/ti_AC.d
new file mode 100644
index 00000000000..cbfd5bd22c3
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_AC.d
@@ -0,0 +1,104 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_AC;
+
+// Object[]
+
+/*
+NOTE: It is sometimes used for arrays of
+classes or (incorrectly) interfaces.
+But naked `TypeInfo_Array` is mostly used.
+See @@@BUG12303@@@.
+*/
+class TypeInfo_AC : TypeInfo_Array
+{
+    override string toString() const { return TypeInfo.toString(); }
+
+    override bool opEquals(Object o) { return TypeInfo.opEquals(o); }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        Object[] s = *cast(Object[]*)p;
+        size_t hash = 0;
+
+        foreach (Object o; s)
+        {
+            if (o)
+                hash += o.toHash();
+        }
+        return hash;
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        Object[] s1 = *cast(Object[]*)p1;
+        Object[] s2 = *cast(Object[]*)p2;
+
+        if (s1.length == s2.length)
+        {
+            for (size_t u = 0; u < s1.length; u++)
+            {
+                Object o1 = s1[u];
+                Object o2 = s2[u];
+
+                // Do not pass null's to Object.opEquals()
+                if (o1 is o2 ||
+                    (!(o1 is null) && !(o2 is null) && o1.opEquals(o2)))
+                    continue;
+                return false;
+            }
+            return true;
+        }
+        return false;
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        Object[] s1 = *cast(Object[]*)p1;
+        Object[] s2 = *cast(Object[]*)p2;
+        auto     c  = cast(sizediff_t)(s1.length - s2.length);
+        if (c == 0)
+        {
+            for (size_t u = 0; u < s1.length; u++)
+            {
+                Object o1 = s1[u];
+                Object o2 = s2[u];
+
+                if (o1 is o2)
+                    continue;
+
+                // Regard null references as always being "less than"
+                if (o1)
+                {
+                    if (!o2)
+                        return 1;
+                    c = o1.opCmp(o2);
+                    if (c == 0)
+                        continue;
+                    break;
+                }
+                else
+                {
+                    return -1;
+                }
+            }
+        }
+        return c < 0 ? -1 : c > 0 ? 1 : 0;
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(Object);
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_Acdouble.d b/libphobos/libdruntime/rt/typeinfo/ti_Acdouble.d
new file mode 100644
index 00000000000..90020300bc1
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_Acdouble.d
@@ -0,0 +1,47 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_Acdouble;
+
+private import rt.util.typeinfo;
+
+// cdouble[]
+
+class TypeInfo_Ar : TypeInfo_Array
+{
+    alias F = cdouble;
+
+    override bool opEquals(Object o) { return TypeInfo.opEquals(o); }
+
+    override string toString() const { return (F[]).stringof; }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        return Array!F.hashOf(*cast(F[]*)p);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        return Array!F.equals(*cast(F[]*)p1, *cast(F[]*)p2);
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        return Array!F.compare(*cast(F[]*)p1, *cast(F[]*)p2);
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(F);
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_Acfloat.d b/libphobos/libdruntime/rt/typeinfo/ti_Acfloat.d
new file mode 100644
index 00000000000..0038fbc679e
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_Acfloat.d
@@ -0,0 +1,47 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_Acfloat;
+
+private import rt.util.typeinfo;
+
+// cfloat[]
+
+class TypeInfo_Aq : TypeInfo_Array
+{
+    alias F = cfloat;
+
+    override bool opEquals(Object o) { return TypeInfo.opEquals(o); }
+
+    override string toString() const { return (F[]).stringof; }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        return Array!F.hashOf(*cast(F[]*)p);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        return Array!F.equals(*cast(F[]*)p1, *cast(F[]*)p2);
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        return Array!F.compare(*cast(F[]*)p1, *cast(F[]*)p2);
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(F);
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_Acreal.d b/libphobos/libdruntime/rt/typeinfo/ti_Acreal.d
new file mode 100644
index 00000000000..f9346f42771
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_Acreal.d
@@ -0,0 +1,47 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_Acreal;
+
+private import rt.util.typeinfo;
+
+// creal[]
+
+class TypeInfo_Ac : TypeInfo_Array
+{
+    alias F = creal;
+
+    override bool opEquals(Object o) { return TypeInfo.opEquals(o); }
+
+    override string toString() const { return (F[]).stringof; }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        return Array!F.hashOf(*cast(F[]*)p);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        return Array!F.equals(*cast(F[]*)p1, *cast(F[]*)p2);
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        return Array!F.compare(*cast(F[]*)p1, *cast(F[]*)p2);
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(F);
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_Adouble.d b/libphobos/libdruntime/rt/typeinfo/ti_Adouble.d
new file mode 100644
index 00000000000..e161e09a7fe
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_Adouble.d
@@ -0,0 +1,61 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_Adouble;
+
+private import rt.util.typeinfo;
+
+// double[]
+
+class TypeInfo_Ad : TypeInfo_Array
+{
+    alias F = double;
+
+    override bool opEquals(Object o) { return TypeInfo.opEquals(o); }
+
+    override string toString() const { return (F[]).stringof; }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        return Array!F.hashOf(*cast(F[]*)p);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        return Array!F.equals(*cast(F[]*)p1, *cast(F[]*)p2);
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        return Array!F.compare(*cast(F[]*)p1, *cast(F[]*)p2);
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(F);
+    }
+}
+
+// idouble[]
+
+class TypeInfo_Ap : TypeInfo_Ad
+{
+    alias F = idouble;
+
+    override string toString() const { return (F[]).stringof; }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(F);
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_Afloat.d b/libphobos/libdruntime/rt/typeinfo/ti_Afloat.d
new file mode 100644
index 00000000000..a03faf40970
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_Afloat.d
@@ -0,0 +1,61 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_Afloat;
+
+private import rt.util.typeinfo;
+
+// float[]
+
+class TypeInfo_Af : TypeInfo_Array
+{
+    alias F = float;
+
+    override bool opEquals(Object o) { return TypeInfo.opEquals(o); }
+
+    override string toString() const { return (F[]).stringof; }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        return Array!F.hashOf(*cast(F[]*)p);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        return Array!F.equals(*cast(F[]*)p1, *cast(F[]*)p2);
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        return Array!F.compare(*cast(F[]*)p1, *cast(F[]*)p2);
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(F);
+    }
+}
+
+// ifloat[]
+
+class TypeInfo_Ao : TypeInfo_Af
+{
+    alias F = ifloat;
+
+    override string toString() const { return (F[]).stringof; }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(F);
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_Ag.d b/libphobos/libdruntime/rt/typeinfo/ti_Ag.d
new file mode 100644
index 00000000000..851c04356e0
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_Ag.d
@@ -0,0 +1,199 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_Ag;
+
+private import core.stdc.string;
+private import rt.util.hash;
+private import core.internal.string;
+
+// byte[]
+
+class TypeInfo_Ag : TypeInfo_Array
+{
+    override bool opEquals(Object o) { return TypeInfo.opEquals(o); }
+
+    override string toString() const { return "byte[]"; }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        byte[] s = *cast(byte[]*)p;
+        return rt.util.hash.hashOf(s.ptr, s.length * byte.sizeof);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        byte[] s1 = *cast(byte[]*)p1;
+        byte[] s2 = *cast(byte[]*)p2;
+
+        return s1.length == s2.length &&
+               memcmp(cast(byte *)s1, cast(byte *)s2, s1.length) == 0;
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        byte[] s1 = *cast(byte[]*)p1;
+        byte[] s2 = *cast(byte[]*)p2;
+        size_t len = s1.length;
+
+        if (s2.length < len)
+            len = s2.length;
+        for (size_t u = 0; u < len; u++)
+        {
+            int result = s1[u] - s2[u];
+            if (result)
+                return result;
+        }
+        if (s1.length < s2.length)
+            return -1;
+        else if (s1.length > s2.length)
+            return 1;
+        return 0;
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(byte);
+    }
+}
+
+
+// ubyte[]
+
+class TypeInfo_Ah : TypeInfo_Ag
+{
+    override string toString() const { return "ubyte[]"; }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        char[] s1 = *cast(char[]*)p1;
+        char[] s2 = *cast(char[]*)p2;
+
+        return dstrcmp(s1, s2);
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(ubyte);
+    }
+}
+
+// void[]
+
+class TypeInfo_Av : TypeInfo_Ah
+{
+    override string toString() const { return "void[]"; }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(void);
+    }
+}
+
+// bool[]
+
+class TypeInfo_Ab : TypeInfo_Ah
+{
+    override string toString() const { return "bool[]"; }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(bool);
+    }
+}
+
+// char[]
+
+class TypeInfo_Aa : TypeInfo_Ah
+{
+    override string toString() const { return "char[]"; }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        char[] s = *cast(char[]*)p;
+        size_t hash = 0;
+
+version (all)
+{
+        foreach (char c; s)
+            hash = hash * 11 + c;
+}
+else
+{
+        size_t len = s.length;
+        char *str = s;
+
+        while (1)
+        {
+            switch (len)
+            {
+                case 0:
+                    return hash;
+
+                case 1:
+                    hash *= 9;
+                    hash += *cast(ubyte *)str;
+                    return hash;
+
+                case 2:
+                    hash *= 9;
+                    hash += *cast(ushort *)str;
+                    return hash;
+
+                case 3:
+                    hash *= 9;
+                    hash += (*cast(ushort *)str << 8) +
+                            (cast(ubyte *)str)[2];
+                    return hash;
+
+                default:
+                    hash *= 9;
+                    hash += *cast(uint *)str;
+                    str += 4;
+                    len -= 4;
+                    break;
+            }
+        }
+}
+        return hash;
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(char);
+    }
+}
+
+// string
+
+class TypeInfo_Aya : TypeInfo_Aa
+{
+    override string toString() const { return "immutable(char)[]"; }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(immutable(char));
+    }
+}
+
+// const(char)[]
+
+class TypeInfo_Axa : TypeInfo_Aa
+{
+    override string toString() const { return "const(char)[]"; }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(const(char));
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_Aint.d b/libphobos/libdruntime/rt/typeinfo/ti_Aint.d
new file mode 100644
index 00000000000..0bd0341b6e2
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_Aint.d
@@ -0,0 +1,151 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_Aint;
+
+private import core.stdc.string;
+private import rt.util.hash;
+
+extern (C) void[] _adSort(void[] a, TypeInfo ti);
+
+// int[]
+
+class TypeInfo_Ai : TypeInfo_Array
+{
+    override bool opEquals(Object o) { return TypeInfo.opEquals(o); }
+
+    override string toString() const { return "int[]"; }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        int[] s = *cast(int[]*)p;
+        return rt.util.hash.hashOf(s.ptr, s.length * int.sizeof);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        int[] s1 = *cast(int[]*)p1;
+        int[] s2 = *cast(int[]*)p2;
+
+        return s1.length == s2.length &&
+               memcmp(cast(void *)s1, cast(void *)s2, s1.length * int.sizeof) == 0;
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        int[] s1 = *cast(int[]*)p1;
+        int[] s2 = *cast(int[]*)p2;
+        size_t len = s1.length;
+
+        if (s2.length < len)
+            len = s2.length;
+        for (size_t u = 0; u < len; u++)
+        {
+            if (s1[u] < s2[u])
+                return -1;
+            else if (s1[u] > s2[u])
+                return 1;
+        }
+        if (s1.length < s2.length)
+            return -1;
+        else if (s1.length > s2.length)
+            return 1;
+        return 0;
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(int);
+    }
+}
+
+unittest
+{
+    int[][] a = [[5,3,8,7], [2,5,3,8,7]];
+    _adSort(*cast(void[]*)&a, typeid(a[0]));
+    assert(a == [[2,5,3,8,7], [5,3,8,7]]);
+
+    a = [[5,3,8,7], [5,3,8]];
+    _adSort(*cast(void[]*)&a, typeid(a[0]));
+    assert(a == [[5,3,8], [5,3,8,7]]);
+}
+
+unittest
+{
+    // Issue 13073: original code uses int subtraction which is susceptible to
+    // integer overflow, causing the following case to fail.
+    int[] a = [int.max, int.max];
+    int[] b = [int.min, int.min];
+    assert(a > b);
+    assert(b < a);
+}
+
+// uint[]
+
+class TypeInfo_Ak : TypeInfo_Ai
+{
+    override string toString() const { return "uint[]"; }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        uint[] s1 = *cast(uint[]*)p1;
+        uint[] s2 = *cast(uint[]*)p2;
+        size_t len = s1.length;
+
+        if (s2.length < len)
+            len = s2.length;
+        for (size_t u = 0; u < len; u++)
+        {
+            if (s1[u] < s2[u])
+                return -1;
+            else if (s1[u] > s2[u])
+                return 1;
+        }
+        if (s1.length < s2.length)
+            return -1;
+        else if (s1.length > s2.length)
+            return 1;
+        return 0;
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(uint);
+    }
+}
+
+unittest
+{
+    // Original test case from issue 13073
+    uint x = 0x22_DF_FF_FF;
+    uint y = 0xA2_DF_FF_FF;
+    assert(!(x < y && y < x));
+    uint[] a = [x];
+    uint[] b = [y];
+    assert(!(a < b && b < a)); // Original failing case
+    uint[1] a1 = [x];
+    uint[1] b1 = [y];
+    assert(!(a1 < b1 && b1 < a1)); // Original failing case
+}
+
+// dchar[]
+
+class TypeInfo_Aw : TypeInfo_Ak
+{
+    override string toString() const { return "dchar[]"; }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(dchar);
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_Along.d b/libphobos/libdruntime/rt/typeinfo/ti_Along.d
new file mode 100644
index 00000000000..5439fee1afb
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_Along.d
@@ -0,0 +1,103 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_Along;
+
+private import core.stdc.string;
+private import rt.util.hash;
+
+// long[]
+
+class TypeInfo_Al : TypeInfo_Array
+{
+    override bool opEquals(Object o) { return TypeInfo.opEquals(o); }
+
+    override string toString() const { return "long[]"; }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        long[] s = *cast(long[]*)p;
+        return rt.util.hash.hashOf(s.ptr, s.length * long.sizeof);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        long[] s1 = *cast(long[]*)p1;
+        long[] s2 = *cast(long[]*)p2;
+
+        return s1.length == s2.length &&
+               memcmp(cast(void *)s1, cast(void *)s2, s1.length * long.sizeof) == 0;
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        long[] s1 = *cast(long[]*)p1;
+        long[] s2 = *cast(long[]*)p2;
+        size_t len = s1.length;
+
+        if (s2.length < len)
+            len = s2.length;
+        for (size_t u = 0; u < len; u++)
+        {
+            if (s1[u] < s2[u])
+                return -1;
+            else if (s1[u] > s2[u])
+                return 1;
+        }
+        if (s1.length < s2.length)
+            return -1;
+        else if (s1.length > s2.length)
+            return 1;
+        return 0;
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(long);
+    }
+}
+
+
+// ulong[]
+
+class TypeInfo_Am : TypeInfo_Al
+{
+    override string toString() const { return "ulong[]"; }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        ulong[] s1 = *cast(ulong[]*)p1;
+        ulong[] s2 = *cast(ulong[]*)p2;
+        size_t len = s1.length;
+
+        if (s2.length < len)
+            len = s2.length;
+        for (size_t u = 0; u < len; u++)
+        {
+            if (s1[u] < s2[u])
+                return -1;
+            else if (s1[u] > s2[u])
+                return 1;
+        }
+        if (s1.length < s2.length)
+            return -1;
+        else if (s1.length > s2.length)
+            return 1;
+        return 0;
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(ulong);
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_Areal.d b/libphobos/libdruntime/rt/typeinfo/ti_Areal.d
new file mode 100644
index 00000000000..b2b4d143f48
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_Areal.d
@@ -0,0 +1,61 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_Areal;
+
+private import rt.util.typeinfo;
+
+// real[]
+
+class TypeInfo_Ae : TypeInfo_Array
+{
+    alias F = real;
+
+    override bool opEquals(Object o) { return TypeInfo.opEquals(o); }
+
+    override string toString() const { return (F[]).stringof; }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        return Array!F.hashOf(*cast(F[]*)p);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        return Array!F.equals(*cast(F[]*)p1, *cast(F[]*)p2);
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        return Array!F.compare(*cast(F[]*)p1, *cast(F[]*)p2);
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(F);
+    }
+}
+
+// ireal[]
+
+class TypeInfo_Aj : TypeInfo_Ae
+{
+    alias F = ireal;
+
+    override string toString() const { return (F[]).stringof; }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(F);
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_Ashort.d b/libphobos/libdruntime/rt/typeinfo/ti_Ashort.d
new file mode 100644
index 00000000000..d270abbffdc
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_Ashort.d
@@ -0,0 +1,113 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_Ashort;
+
+private import core.stdc.string;
+private import rt.util.hash;
+
+// short[]
+
+class TypeInfo_As : TypeInfo_Array
+{
+    override bool opEquals(Object o) { return TypeInfo.opEquals(o); }
+
+    override string toString() const { return "short[]"; }
+
+    override size_t getHash(in void* p) @trusted const
+    {
+        short[] s = *cast(short[]*)p;
+        return rt.util.hash.hashOf(s.ptr, s.length * short.sizeof);
+    }
+
+    override bool equals(in void* p1, in void* p2) const
+    {
+        short[] s1 = *cast(short[]*)p1;
+        short[] s2 = *cast(short[]*)p2;
+
+        return s1.length == s2.length &&
+               memcmp(cast(void *)s1, cast(void *)s2, s1.length * short.sizeof) == 0;
+    }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        short[] s1 = *cast(short[]*)p1;
+        short[] s2 = *cast(short[]*)p2;
+        size_t len = s1.length;
+
+        if (s2.length < len)
+            len = s2.length;
+        for (size_t u = 0; u < len; u++)
+        {
+            int result = s1[u] - s2[u];
+            if (result)
+                return result;
+        }
+        if (s1.length < s2.length)
+            return -1;
+        else if (s1.length > s2.length)
+            return 1;
+        return 0;
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(short);
+    }
+}
+
+
+// ushort[]
+
+class TypeInfo_At : TypeInfo_As
+{
+    override string toString() const { return "ushort[]"; }
+
+    override int compare(in void* p1, in void* p2) const
+    {
+        ushort[] s1 = *cast(ushort[]*)p1;
+        ushort[] s2 = *cast(ushort[]*)p2;
+        size_t len = s1.length;
+
+        if (s2.length < len)
+            len = s2.length;
+        for (size_t u = 0; u < len; u++)
+        {
+            int result = s1[u] - s2[u];
+            if (result)
+                return result;
+        }
+        if (s1.length < s2.length)
+            return -1;
+        else if (s1.length > s2.length)
+            return 1;
+        return 0;
+    }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(ushort);
+    }
+}
+
+// wchar[]
+
+class TypeInfo_Au : TypeInfo_At
+{
+    override string toString() const { return "wchar[]"; }
+
+    override @property inout(TypeInfo) next() inout
+    {
+        return cast(inout)typeid(wchar);
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_C.d b/libphobos/libdruntime/rt/typeinfo/ti_C.d
new file mode 100644
index 00000000000..8bfae7901ea
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_C.d
@@ -0,0 +1,75 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_C;
+
+// Object
+
+class TypeInfo_C : TypeInfo
+{
+    @trusted:
+    const:
+    //pure:
+    //nothrow:
+
+    override size_t getHash(in void* p)
+    {
+        Object o = *cast(Object*)p;
+        return o ? o.toHash() : 0;
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        Object o1 = *cast(Object*)p1;
+        Object o2 = *cast(Object*)p2;
+
+        return o1 == o2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        Object o1 = *cast(Object*)p1;
+        Object o2 = *cast(Object*)p2;
+        int c = 0;
+
+        // Regard null references as always being "less than"
+        if (!(o1 is o2))
+        {
+            if (o1)
+            {
+                if (!o2)
+                    c = 1;
+                else
+                    c = o1.opCmp(o2);
+            }
+            else
+                c = -1;
+        }
+        return c;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return Object.sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. Object.sizeof];
+    }
+
+    override @property uint flags() nothrow pure
+    {
+        return 1;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_byte.d b/libphobos/libdruntime/rt/typeinfo/ti_byte.d
new file mode 100644
index 00000000000..6b0f3108516
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_byte.d
@@ -0,0 +1,60 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_byte;
+
+// byte
+
+class TypeInfo_g : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "byte"; }
+
+    override size_t getHash(in void* p)
+    {
+        return *cast(byte *)p;
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(byte *)p1 == *cast(byte *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        return *cast(byte *)p1 - *cast(byte *)p2;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return byte.sizeof;
+    }
+
+    override const(void)[] initializer() @trusted
+    {
+        return (cast(void *)null)[0 .. byte.sizeof];
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        byte t;
+
+        t = *cast(byte *)p1;
+        *cast(byte *)p1 = *cast(byte *)p2;
+        *cast(byte *)p2 = t;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_cdouble.d b/libphobos/libdruntime/rt/typeinfo/ti_cdouble.d
new file mode 100644
index 00000000000..15bec352518
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_cdouble.d
@@ -0,0 +1,74 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_cdouble;
+
+private import rt.util.typeinfo;
+
+// cdouble
+
+class TypeInfo_r : TypeInfo
+{
+  pure:
+  nothrow:
+  @safe:
+
+    alias F = cdouble;
+
+    override string toString() const { return F.stringof; }
+
+    override size_t getHash(in void* p) const @trusted
+    {
+        return Floating!F.hashOf(*cast(F*)p);
+    }
+
+    override bool equals(in void* p1, in void* p2) const @trusted
+    {
+        return Floating!F.equals(*cast(F*)p1, *cast(F*)p2);
+    }
+
+    override int compare(in void* p1, in void* p2) const @trusted
+    {
+        return Floating!F.compare(*cast(F*)p1, *cast(F*)p2);
+    }
+
+    override @property size_t tsize() const
+    {
+        return F.sizeof;
+    }
+
+    override void swap(void *p1, void *p2) const @trusted
+    {
+        F t = *cast(F*)p1;
+        *cast(F*)p1 = *cast(F*)p2;
+        *cast(F*)p2 = t;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        static immutable F r;
+        return (&r)[0 .. 1];
+    }
+
+    override @property size_t talign() const
+    {
+        return F.alignof;
+    }
+
+    version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
+    {
+        arg1 = typeid(double);
+        arg2 = typeid(double);
+        return 0;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_cent.d b/libphobos/libdruntime/rt/typeinfo/ti_cent.d
new file mode 100644
index 00000000000..d7e45da2989
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_cent.d
@@ -0,0 +1,73 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2015.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2015.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_cent;
+
+private import rt.util.hash;
+
+static if(is(cent)):
+
+// cent
+
+class TypeInfo_zi : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "cent"; }
+
+    override size_t getHash(in void* p)
+    {
+        return rt.util.hash.hashOf(p, cent.sizeof);
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(cent *)p1 == *cast(cent *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        if (*cast(cent *)p1 < *cast(cent *)p2)
+            return -1;
+        else if (*cast(cent *)p1 > *cast(cent *)p2)
+            return 1;
+        return 0;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return cent.sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. cent.sizeof];
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        cent t;
+
+        t = *cast(cent *)p1;
+        *cast(cent *)p1 = *cast(cent *)p2;
+        *cast(cent *)p2 = t;
+    }
+
+    override @property size_t talign() nothrow pure
+    {
+        return cent.alignof;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_cfloat.d b/libphobos/libdruntime/rt/typeinfo/ti_cfloat.d
new file mode 100644
index 00000000000..3b82f04d0d0
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_cfloat.d
@@ -0,0 +1,73 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_cfloat;
+
+private import rt.util.typeinfo;
+
+// cfloat
+
+class TypeInfo_q : TypeInfo
+{
+  pure:
+  nothrow:
+  @safe:
+
+    alias F = cfloat;
+
+    override string toString() const { return F.stringof; }
+
+    override size_t getHash(in void* p) const @trusted
+    {
+        return Floating!F.hashOf(*cast(F*)p);
+    }
+
+    override bool equals(in void* p1, in void* p2) const @trusted
+    {
+        return Floating!F.equals(*cast(F*)p1, *cast(F*)p2);
+    }
+
+    override int compare(in void* p1, in void* p2) const @trusted
+    {
+        return Floating!F.compare(*cast(F*)p1, *cast(F*)p2);
+    }
+
+    override @property size_t tsize() const
+    {
+        return F.sizeof;
+    }
+
+    override void swap(void *p1, void *p2) const @trusted
+    {
+        F t = *cast(F*)p1;
+        *cast(F*)p1 = *cast(F*)p2;
+        *cast(F*)p2 = t;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        static immutable F r;
+        return (&r)[0 .. 1];
+    }
+
+    override @property size_t talign() const
+    {
+        return F.alignof;
+    }
+
+    version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
+    {
+        arg1 = typeid(double);
+        return 0;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_char.d b/libphobos/libdruntime/rt/typeinfo/ti_char.d
new file mode 100644
index 00000000000..ba3841792c7
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_char.d
@@ -0,0 +1,62 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_char;
+
+// char
+
+class TypeInfo_a : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "char"; }
+
+    override size_t getHash(in void* p)
+    {
+        return *cast(char *)p;
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(char *)p1 == *cast(char *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        return *cast(char *)p1 - *cast(char *)p2;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return char.sizeof;
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        char t;
+
+        t = *cast(char *)p1;
+        *cast(char *)p1 = *cast(char *)p2;
+        *cast(char *)p2 = t;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        static immutable char c;
+
+        return (&c)[0 .. 1];
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_creal.d b/libphobos/libdruntime/rt/typeinfo/ti_creal.d
new file mode 100644
index 00000000000..b77429cf896
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_creal.d
@@ -0,0 +1,74 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_creal;
+
+private import rt.util.typeinfo;
+
+// creal
+
+class TypeInfo_c : TypeInfo
+{
+  pure:
+  nothrow:
+  @safe:
+
+    alias F = creal;
+
+    override string toString() const { return F.stringof; }
+
+    override size_t getHash(in void* p) const @trusted
+    {
+        return Floating!F.hashOf(*cast(F*)p);
+    }
+
+    override bool equals(in void* p1, in void* p2) const @trusted
+    {
+        return Floating!F.equals(*cast(F*)p1, *cast(F*)p2);
+    }
+
+    override int compare(in void* p1, in void* p2) const @trusted
+    {
+        return Floating!F.compare(*cast(F*)p1, *cast(F*)p2);
+    }
+
+    override @property size_t tsize() const
+    {
+        return F.sizeof;
+    }
+
+    override void swap(void *p1, void *p2) const @trusted
+    {
+        F t = *cast(F*)p1;
+        *cast(F*)p1 = *cast(F*)p2;
+        *cast(F*)p2 = t;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        static immutable F r;
+        return (&r)[0 .. 1];
+    }
+
+    override @property size_t talign() const
+    {
+        return F.alignof;
+    }
+
+    version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2)
+    {
+        arg1 = typeid(real);
+        arg2 = typeid(real);
+        return 0;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_dchar.d b/libphobos/libdruntime/rt/typeinfo/ti_dchar.d
new file mode 100644
index 00000000000..2d4354c18aa
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_dchar.d
@@ -0,0 +1,62 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_dchar;
+
+// dchar
+
+class TypeInfo_w : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "dchar"; }
+
+    override size_t getHash(in void* p)
+    {
+        return *cast(dchar *)p;
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(dchar *)p1 == *cast(dchar *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        return *cast(dchar *)p1 - *cast(dchar *)p2;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return dchar.sizeof;
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        dchar t;
+
+        t = *cast(dchar *)p1;
+        *cast(dchar *)p1 = *cast(dchar *)p2;
+        *cast(dchar *)p2 = t;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        static immutable dchar c;
+
+        return (&c)[0 .. 1];
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_delegate.d b/libphobos/libdruntime/rt/typeinfo/ti_delegate.d
new file mode 100644
index 00000000000..fa6b0a21e87
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_delegate.d
@@ -0,0 +1,64 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_delegate;
+
+private import rt.util.hash;
+
+// delegate
+
+alias void delegate(int) dg;
+
+class TypeInfo_D : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override size_t getHash(in void* p)
+    {
+        return rt.util.hash.hashOf(p, dg.sizeof);
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(dg *)p1 == *cast(dg *)p2;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return dg.sizeof;
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        dg t;
+
+        t = *cast(dg *)p1;
+        *cast(dg *)p1 = *cast(dg *)p2;
+        *cast(dg *)p2 = t;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        static immutable dg d;
+
+        return (cast(void *)null)[0 .. dg.sizeof];
+    }
+
+    override @property uint flags() nothrow pure
+    {
+        return 1;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_double.d b/libphobos/libdruntime/rt/typeinfo/ti_double.d
new file mode 100644
index 00000000000..8aa281f11b4
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_double.d
@@ -0,0 +1,76 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_double;
+
+private import rt.util.typeinfo;
+
+// double
+
+class TypeInfo_d : TypeInfo
+{
+  pure:
+  nothrow:
+  @safe:
+
+    alias F = double;
+
+    override string toString() const { return F.stringof; }
+
+    override size_t getHash(in void* p) const @trusted
+    {
+        return Floating!F.hashOf(*cast(F*)p);
+    }
+
+    override bool equals(in void* p1, in void* p2) const @trusted
+    {
+        return Floating!F.equals(*cast(F*)p1, *cast(F*)p2);
+    }
+
+    override int compare(in void* p1, in void* p2) const @trusted
+    {
+        return Floating!F.compare(*cast(F*)p1, *cast(F*)p2);
+    }
+
+    override @property size_t tsize() const
+    {
+        return F.sizeof;
+    }
+
+    override void swap(void *p1, void *p2) const @trusted
+    {
+        F t = *cast(F*)p1;
+        *cast(F*)p1 = *cast(F*)p2;
+        *cast(F*)p2 = t;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        static immutable F r;
+        return (&r)[0 .. 1];
+    }
+
+    override @property size_t talign() const
+    {
+        return F.alignof;
+    }
+
+    version (Windows)
+    {
+    }
+    else version (X86_64)
+    {
+        // 2 means arg to function is passed in XMM registers
+        override @property uint flags() const { return 2; }
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_float.d b/libphobos/libdruntime/rt/typeinfo/ti_float.d
new file mode 100644
index 00000000000..60837d1c967
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_float.d
@@ -0,0 +1,71 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_float;
+
+private import rt.util.typeinfo;
+
+// float
+
+class TypeInfo_f : TypeInfo
+{
+  pure:
+  nothrow:
+  @safe:
+
+    alias F = float;
+
+    override string toString() const { return F.stringof; }
+
+    override size_t getHash(in void* p) const @trusted
+    {
+        return Floating!F.hashOf(*cast(F*)p);
+    }
+
+    override bool equals(in void* p1, in void* p2) const @trusted
+    {
+        return Floating!F.equals(*cast(F*)p1, *cast(F*)p2);
+    }
+
+    override int compare(in void* p1, in void* p2) const @trusted
+    {
+        return Floating!F.compare(*cast(F*)p1, *cast(F*)p2);
+    }
+
+    override @property size_t tsize() const
+    {
+        return F.sizeof;
+    }
+
+    override void swap(void *p1, void *p2) const @trusted
+    {
+        F t = *cast(F*)p1;
+        *cast(F*)p1 = *cast(F*)p2;
+        *cast(F*)p2 = t;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        static immutable F r;
+        return (&r)[0 .. 1];
+    }
+
+    version (Windows)
+    {
+    }
+    else version (X86_64)
+    {
+        // 2 means arg to function is passed in XMM registers
+        override @property uint flags() const { return 2; }
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_idouble.d b/libphobos/libdruntime/rt/typeinfo/ti_idouble.d
new file mode 100644
index 00000000000..f06854917da
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_idouble.d
@@ -0,0 +1,27 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_idouble;
+
+private import rt.typeinfo.ti_double;
+
+// idouble
+
+class TypeInfo_p : TypeInfo_d
+{
+  pure:
+  nothrow:
+  @safe:
+
+    override string toString() const { return idouble.stringof; }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_ifloat.d b/libphobos/libdruntime/rt/typeinfo/ti_ifloat.d
new file mode 100644
index 00000000000..062b3f466bd
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_ifloat.d
@@ -0,0 +1,27 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_ifloat;
+
+private import rt.typeinfo.ti_float;
+
+// ifloat
+
+class TypeInfo_o : TypeInfo_f
+{
+  pure:
+  nothrow:
+  @safe:
+
+    override string toString() const { return ifloat.stringof; }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_int.d b/libphobos/libdruntime/rt/typeinfo/ti_int.d
new file mode 100644
index 00000000000..b0418c06fcf
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_int.d
@@ -0,0 +1,64 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_int;
+
+// int
+
+class TypeInfo_i : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "int"; }
+
+    override size_t getHash(in void* p)
+    {
+        return *cast(uint *)p;
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(uint *)p1 == *cast(uint *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        if (*cast(int*) p1 < *cast(int*) p2)
+            return -1;
+        else if (*cast(int*) p1 > *cast(int*) p2)
+            return 1;
+        return 0;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return int.sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. int.sizeof];
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        int t;
+
+        t = *cast(int *)p1;
+        *cast(int *)p1 = *cast(int *)p2;
+        *cast(int *)p2 = t;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_ireal.d b/libphobos/libdruntime/rt/typeinfo/ti_ireal.d
new file mode 100644
index 00000000000..c1334f7a7c2
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_ireal.d
@@ -0,0 +1,27 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_ireal;
+
+private import rt.typeinfo.ti_real;
+
+// ireal
+
+class TypeInfo_j : TypeInfo_e
+{
+  pure:
+  nothrow:
+  @safe:
+
+    override string toString() const { return ireal.stringof; }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_long.d b/libphobos/libdruntime/rt/typeinfo/ti_long.d
new file mode 100644
index 00000000000..d054022b263
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_long.d
@@ -0,0 +1,71 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_long;
+
+private import rt.util.hash;
+
+// long
+
+class TypeInfo_l : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "long"; }
+
+    override size_t getHash(in void* p)
+    {
+        return rt.util.hash.hashOf(p, long.sizeof);
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(long *)p1 == *cast(long *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        if (*cast(long *)p1 < *cast(long *)p2)
+            return -1;
+        else if (*cast(long *)p1 > *cast(long *)p2)
+            return 1;
+        return 0;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return long.sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. long.sizeof];
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        long t;
+
+        t = *cast(long *)p1;
+        *cast(long *)p1 = *cast(long *)p2;
+        *cast(long *)p2 = t;
+    }
+
+    override @property size_t talign() nothrow pure
+    {
+        return long.alignof;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_ptr.d b/libphobos/libdruntime/rt/typeinfo/ti_ptr.d
new file mode 100644
index 00000000000..a23511a6fdd
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_ptr.d
@@ -0,0 +1,64 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_ptr;
+
+// internal typeinfo for any pointer type
+// please keep in sync with TypeInfo_Pointer
+
+class TypeInfo_P : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override size_t getHash(in void* p)
+    {
+        return cast(size_t)*cast(void**)p;
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(void**)p1 == *cast(void**)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        if (*cast(void**)p1 < *cast(void**)p2)
+            return -1;
+        else if (*cast(void**)p1 > *cast(void**)p2)
+            return 1;
+        else
+            return 0;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return (void*).sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. (void*).sizeof];
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        void* tmp = *cast(void**)p1;
+        *cast(void**)p1 = *cast(void**)p2;
+        *cast(void**)p2 = tmp;
+    }
+
+    override @property uint flags() nothrow pure const { return 1; }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_real.d b/libphobos/libdruntime/rt/typeinfo/ti_real.d
new file mode 100644
index 00000000000..77ae1265112
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_real.d
@@ -0,0 +1,67 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_real;
+
+private import rt.util.typeinfo;
+
+// real
+
+class TypeInfo_e : TypeInfo
+{
+  pure:
+  nothrow:
+  @safe:
+
+    alias F = real;
+
+    override string toString() const { return F.stringof; }
+
+    override size_t getHash(in void* p) const @trusted
+    {
+        return Floating!F.hashOf(*cast(F*)p);
+    }
+
+    override bool equals(in void* p1, in void* p2) const @trusted
+    {
+        return Floating!F.equals(*cast(F*)p1, *cast(F*)p2);
+    }
+
+    override int compare(in void* p1, in void* p2) const @trusted
+    {
+        return Floating!F.compare(*cast(F*)p1, *cast(F*)p2);
+    }
+
+    override @property size_t tsize() const
+    {
+        return F.sizeof;
+    }
+
+    override void swap(void *p1, void *p2) const @trusted
+    {
+        F t = *cast(F*)p1;
+        *cast(F*)p1 = *cast(F*)p2;
+        *cast(F*)p2 = t;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        static immutable F r;
+        return (&r)[0 .. 1];
+    }
+
+    override @property size_t talign() const
+    {
+        return F.alignof;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_short.d b/libphobos/libdruntime/rt/typeinfo/ti_short.d
new file mode 100644
index 00000000000..f636fc3af3c
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_short.d
@@ -0,0 +1,60 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_short;
+
+// short
+
+class TypeInfo_s : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "short"; }
+
+    override size_t getHash(in void* p)
+    {
+        return *cast(short *)p;
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(short *)p1 == *cast(short *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        return *cast(short *)p1 - *cast(short *)p2;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return short.sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. short.sizeof];
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        short t;
+
+        t = *cast(short *)p1;
+        *cast(short *)p1 = *cast(short *)p2;
+        *cast(short *)p2 = t;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_ubyte.d b/libphobos/libdruntime/rt/typeinfo/ti_ubyte.d
new file mode 100644
index 00000000000..97b902ab079
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_ubyte.d
@@ -0,0 +1,70 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_ubyte;
+
+// ubyte
+
+class TypeInfo_h : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "ubyte"; }
+
+    override size_t getHash(in void* p)
+    {
+        return *cast(ubyte *)p;
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(ubyte *)p1 == *cast(ubyte *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        return *cast(ubyte *)p1 - *cast(ubyte *)p2;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return ubyte.sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. ubyte.sizeof];
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        ubyte t;
+
+        t = *cast(ubyte *)p1;
+        *cast(ubyte *)p1 = *cast(ubyte *)p2;
+        *cast(ubyte *)p2 = t;
+    }
+}
+
+class TypeInfo_b : TypeInfo_h
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "bool"; }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_ucent.d b/libphobos/libdruntime/rt/typeinfo/ti_ucent.d
new file mode 100644
index 00000000000..0f04253aafc
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_ucent.d
@@ -0,0 +1,73 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2015.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2015.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_ucent;
+
+private import rt.util.hash;
+
+static if (is(ucent)):
+
+// ucent
+
+class TypeInfo_zk : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "ucent"; }
+
+    override size_t getHash(in void* p)
+    {
+        return rt.util.hash.hashOf(p, ucent.sizeof);
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(ucent *)p1 == *cast(ucent *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        if (*cast(ucent *)p1 < *cast(ucent *)p2)
+            return -1;
+        else if (*cast(ucent *)p1 > *cast(ucent *)p2)
+            return 1;
+        return 0;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return ucent.sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. ucent.sizeof];
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        ucent t;
+
+        t = *cast(ucent *)p1;
+        *cast(ucent *)p1 = *cast(ucent *)p2;
+        *cast(ucent *)p2 = t;
+    }
+
+    override @property size_t talign() nothrow pure
+    {
+        return ucent.alignof;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_uint.d b/libphobos/libdruntime/rt/typeinfo/ti_uint.d
new file mode 100644
index 00000000000..6cd523ba2a6
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_uint.d
@@ -0,0 +1,64 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_uint;
+
+// uint
+
+class TypeInfo_k : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "uint"; }
+
+    override size_t getHash(in void* p)
+    {
+        return *cast(uint *)p;
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(uint *)p1 == *cast(uint *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        if (*cast(uint*) p1 < *cast(uint*) p2)
+            return -1;
+        else if (*cast(uint*) p1 > *cast(uint*) p2)
+            return 1;
+        return 0;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return uint.sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. uint.sizeof];
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        int t;
+
+        t = *cast(uint *)p1;
+        *cast(uint *)p1 = *cast(uint *)p2;
+        *cast(uint *)p2 = t;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_ulong.d b/libphobos/libdruntime/rt/typeinfo/ti_ulong.d
new file mode 100644
index 00000000000..af645a1a428
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_ulong.d
@@ -0,0 +1,71 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_ulong;
+
+private import rt.util.hash;
+
+// ulong
+
+class TypeInfo_m : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "ulong"; }
+
+    override size_t getHash(in void* p)
+    {
+        return rt.util.hash.hashOf(p, ulong.sizeof);
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(ulong *)p1 == *cast(ulong *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        if (*cast(ulong *)p1 < *cast(ulong *)p2)
+            return -1;
+        else if (*cast(ulong *)p1 > *cast(ulong *)p2)
+            return 1;
+        return 0;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return ulong.sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. ulong.sizeof];
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        ulong t;
+
+        t = *cast(ulong *)p1;
+        *cast(ulong *)p1 = *cast(ulong *)p2;
+        *cast(ulong *)p2 = t;
+    }
+
+    override @property size_t talign() nothrow pure
+    {
+        return ulong.alignof;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_ushort.d b/libphobos/libdruntime/rt/typeinfo/ti_ushort.d
new file mode 100644
index 00000000000..ae246564326
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_ushort.d
@@ -0,0 +1,60 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_ushort;
+
+// ushort
+
+class TypeInfo_t : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "ushort"; }
+
+    override size_t getHash(in void* p)
+    {
+        return *cast(ushort *)p;
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(ushort *)p1 == *cast(ushort *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        return *cast(ushort *)p1 - *cast(ushort *)p2;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return ushort.sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. ushort.sizeof];
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        ushort t;
+
+        t = *cast(ushort *)p1;
+        *cast(ushort *)p1 = *cast(ushort *)p2;
+        *cast(ushort *)p2 = t;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_void.d b/libphobos/libdruntime/rt/typeinfo/ti_void.d
new file mode 100644
index 00000000000..28e8c15a06c
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_void.d
@@ -0,0 +1,65 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_void;
+
+// void
+
+class TypeInfo_v : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() const pure nothrow @safe { return "void"; }
+
+    override size_t getHash(in void* p)
+    {
+        assert(0);
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(byte *)p1 == *cast(byte *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        return *cast(byte *)p1 - *cast(byte *)p2;
+    }
+
+    override @property size_t tsize() nothrow pure
+    {
+        return void.sizeof;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        return (cast(void *)null)[0 .. void.sizeof];
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        byte t;
+
+        t = *cast(byte *)p1;
+        *cast(byte *)p1 = *cast(byte *)p2;
+        *cast(byte *)p2 = t;
+    }
+
+    override @property uint flags() nothrow pure
+    {
+        return 1;
+    }
+}
diff --git a/libphobos/libdruntime/rt/typeinfo/ti_wchar.d b/libphobos/libdruntime/rt/typeinfo/ti_wchar.d
new file mode 100644
index 00000000000..3e2fba9b3b5
--- /dev/null
+++ b/libphobos/libdruntime/rt/typeinfo/ti_wchar.d
@@ -0,0 +1,62 @@
+/**
+ * TypeInfo support code.
+ *
+ * Copyright: Copyright Digital Mars 2004 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright
+ */
+
+/*          Copyright Digital Mars 2004 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.typeinfo.ti_wchar;
+
+// wchar
+
+class TypeInfo_u : TypeInfo
+{
+    @trusted:
+    const:
+    pure:
+    nothrow:
+
+    override string toString() { return "wchar"; }
+
+    override size_t getHash(in void* p)
+    {
+        return *cast(wchar *)p;
+    }
+
+    override bool equals(in void* p1, in void* p2)
+    {
+        return *cast(wchar *)p1 == *cast(wchar *)p2;
+    }
+
+    override int compare(in void* p1, in void* p2)
+    {
+        return *cast(wchar *)p1 - *cast(wchar *)p2;
+    }
+
+    override @property size_t tsize()
+    {
+        return wchar.sizeof;
+    }
+
+    override void swap(void *p1, void *p2)
+    {
+        wchar t;
+
+        t = *cast(wchar *)p1;
+        *cast(wchar *)p1 = *cast(wchar *)p2;
+        *cast(wchar *)p2 = t;
+    }
+
+    override const(void)[] initializer() const @trusted
+    {
+        static immutable wchar c;
+
+        return (&c)[0 .. 1];
+    }
+}
diff --git a/libphobos/libdruntime/rt/util/array.d b/libphobos/libdruntime/rt/util/array.d
new file mode 100644
index 00000000000..f2990524441
--- /dev/null
+++ b/libphobos/libdruntime/rt/util/array.d
@@ -0,0 +1,65 @@
+/**
+Array utilities.
+
+Copyright: Denis Shelomovskij 2013
+License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
+Authors: Denis Shelomovskij
+Source: $(DRUNTIMESRC src/rt/util/_array.d)
+*/
+module rt.util.array;
+
+
+import core.internal.string;
+
+
+@safe /* pure dmd @@@BUG11461@@@ */ nothrow:
+
+void enforceTypedArraysConformable(T)(in char[] action,
+    in T[] a1, in T[] a2, in bool allowOverlap = false)
+{
+    _enforceSameLength(action, a1.length, a2.length);
+    if(!allowOverlap)
+        _enforceNoOverlap(action, a1.ptr, a2.ptr, T.sizeof * a1.length);
+}
+
+void enforceRawArraysConformable(in char[] action, in size_t elementSize,
+    in void[] a1, in void[] a2, in bool allowOverlap = false)
+{
+    _enforceSameLength(action, a1.length, a2.length);
+    if(!allowOverlap)
+        _enforceNoOverlap(action, a1.ptr, a2.ptr, elementSize * a1.length);
+}
+
+private void _enforceSameLength(in char[] action,
+    in size_t length1, in size_t length2)
+{
+    if(length1 == length2)
+        return;
+
+    UnsignedStringBuf tmpBuff = void;
+    string msg = "Array lengths don't match for ";
+    msg ~= action;
+    msg ~= ": ";
+    msg ~= length1.unsignedToTempString(tmpBuff, 10);
+    msg ~= " != ";
+    msg ~= length2.unsignedToTempString(tmpBuff, 10);
+    throw new Error(msg);
+}
+
+private void _enforceNoOverlap(in char[] action,
+    in void* ptr1, in void* ptr2, in size_t bytes)
+{
+    const size_t d = ptr1 > ptr2 ? ptr1 - ptr2 : ptr2 - ptr1;
+    if(d >= bytes)
+        return;
+    const overlappedBytes = bytes - d;
+
+    UnsignedStringBuf tmpBuff = void;
+    string msg = "Overlapping arrays in ";
+    msg ~= action;
+    msg ~= ": ";
+    msg ~= overlappedBytes.unsignedToTempString(tmpBuff, 10);
+    msg ~= " byte(s) overlap of ";
+    msg ~= bytes.unsignedToTempString(tmpBuff, 10);
+    throw new Error(msg);
+}
diff --git a/libphobos/libdruntime/rt/util/container/array.d b/libphobos/libdruntime/rt/util/container/array.d
new file mode 100644
index 00000000000..9dcee943f8f
--- /dev/null
+++ b/libphobos/libdruntime/rt/util/container/array.d
@@ -0,0 +1,227 @@
+/**
+ * Array container for internal usage.
+ *
+ * Copyright: Copyright Martin Nowak 2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ */
+module rt.util.container.array;
+
+static import common = rt.util.container.common;
+
+import core.exception : onOutOfMemoryError;
+
+struct Array(T)
+{
+nothrow:
+    @disable this(this);
+
+    ~this()
+    {
+        reset();
+    }
+
+    void reset()
+    {
+        length = 0;
+    }
+
+    @property size_t length() const
+    {
+        return _length;
+    }
+
+    @property void length(size_t nlength)
+    {
+        import core.checkedint : mulu;
+
+        bool overflow = false;
+        size_t reqsize = mulu(T.sizeof, nlength, overflow);
+        if (!overflow)
+        {
+            if (nlength < length)
+                foreach (ref val; _ptr[nlength .. length]) common.destroy(val);
+            _ptr = cast(T*)common.xrealloc(_ptr, reqsize);
+            if (nlength > length)
+                foreach (ref val; _ptr[length .. nlength]) common.initialize(val);
+            _length = nlength;
+        }
+        else
+            onOutOfMemoryError();
+
+    }
+
+    @property bool empty() const
+    {
+        return !length;
+    }
+
+    @property ref inout(T) front() inout
+    in { assert(!empty); }
+    body
+    {
+        return _ptr[0];
+    }
+
+    @property ref inout(T) back() inout
+    in { assert(!empty); }
+    body
+    {
+        return _ptr[_length - 1];
+    }
+
+    ref inout(T) opIndex(size_t idx) inout
+    in { assert(idx < length); }
+    body
+    {
+        return _ptr[idx];
+    }
+
+    inout(T)[] opSlice() inout
+    {
+        return _ptr[0 .. _length];
+    }
+
+    inout(T)[] opSlice(size_t a, size_t b) inout
+    in { assert(a < b && b <= length); }
+    body
+    {
+        return _ptr[a .. b];
+    }
+
+    alias length opDollar;
+
+    void insertBack()(auto ref T val)
+    {
+        import core.checkedint : addu;
+
+        bool overflow = false;
+        size_t newlength = addu(length, 1, overflow);
+        if (!overflow)
+        {
+            length = newlength;
+            back = val;
+        }
+        else
+            onOutOfMemoryError();
+    }
+
+    void popBack()
+    {
+        length = length - 1;
+    }
+
+    void remove(size_t idx)
+    in { assert(idx < length); }
+    body
+    {
+        foreach (i; idx .. length - 1)
+            _ptr[i] = _ptr[i+1];
+        popBack();
+    }
+
+    void swap(ref Array other)
+    {
+        auto ptr = _ptr;
+        _ptr = other._ptr;
+        other._ptr = ptr;
+        immutable len = _length;
+        _length = other._length;
+        other._length = len;
+    }
+
+private:
+    T* _ptr;
+    size_t _length;
+}
+
+unittest
+{
+    Array!size_t ary;
+
+    assert(ary[] == []);
+    ary.insertBack(5);
+    assert(ary[] == [5]);
+    assert(ary[$-1] == 5);
+    ary.popBack();
+    assert(ary[] == []);
+    ary.insertBack(0);
+    ary.insertBack(1);
+    assert(ary[] == [0, 1]);
+    assert(ary[0 .. 1] == [0]);
+    assert(ary[1 .. 2] == [1]);
+    assert(ary[$ - 2 .. $] == [0, 1]);
+    size_t idx;
+    foreach (val; ary) assert(idx++ == val);
+    foreach_reverse (val; ary) assert(--idx == val);
+    foreach (i, val; ary) assert(i == val);
+    foreach_reverse (i, val; ary) assert(i == val);
+
+    ary.insertBack(2);
+    ary.remove(1);
+    assert(ary[] == [0, 2]);
+
+    assert(!ary.empty);
+    ary.reset();
+    assert(ary.empty);
+    ary.insertBack(0);
+    assert(!ary.empty);
+    destroy(ary);
+    assert(ary.empty);
+
+    // not copyable
+    static assert(!__traits(compiles, { Array!size_t ary2 = ary; }));
+    Array!size_t ary2;
+    static assert(!__traits(compiles, ary = ary2));
+    static void foo(Array!size_t copy) {}
+    static assert(!__traits(compiles, foo(ary)));
+
+    ary2.insertBack(0);
+    assert(ary.empty);
+    assert(ary2[] == [0]);
+    ary.swap(ary2);
+    assert(ary[] == [0]);
+    assert(ary2.empty);
+}
+
+unittest
+{
+    alias RC = common.RC;
+    Array!RC ary;
+
+    size_t cnt;
+    assert(cnt == 0);
+    ary.insertBack(RC(&cnt));
+    assert(cnt == 1);
+    ary.insertBack(RC(&cnt));
+    assert(cnt == 2);
+    ary.back = ary.front;
+    assert(cnt == 2);
+    ary.popBack();
+    assert(cnt == 1);
+    ary.popBack();
+    assert(cnt == 0);
+}
+
+unittest
+{
+    import core.exception;
+    try
+    {
+        // Overflow ary.length.
+        auto ary = Array!size_t(null, -1);
+        ary.insertBack(0);
+    }
+    catch(OutOfMemoryError)
+    {
+    }
+    try
+    {
+        // Overflow requested memory size for common.xrealloc().
+        auto ary = Array!size_t(null, -2);
+        ary.insertBack(0);
+    }
+    catch(OutOfMemoryError)
+    {
+    }
+}
diff --git a/libphobos/libdruntime/rt/util/container/common.d b/libphobos/libdruntime/rt/util/container/common.d
new file mode 100644
index 00000000000..29939a47e3a
--- /dev/null
+++ b/libphobos/libdruntime/rt/util/container/common.d
@@ -0,0 +1,66 @@
+/**
+ * Common code for writing containers.
+ *
+ * Copyright: Copyright Martin Nowak 2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ */
+module rt.util.container.common;
+
+import core.stdc.stdlib : malloc, realloc;
+public import core.stdc.stdlib : free;
+import core.internal.traits : dtorIsNothrow;
+nothrow:
+
+void* xrealloc(void* ptr, size_t sz) nothrow @nogc
+{
+    import core.exception;
+
+    if (!sz) { .free(ptr); return null; }
+    if (auto nptr = .realloc(ptr, sz)) return nptr;
+    .free(ptr); onOutOfMemoryError();
+    assert(0);
+}
+
+void* xmalloc(size_t sz) nothrow @nogc
+{
+    import core.exception;
+    if (auto nptr = .malloc(sz))
+        return nptr;
+    onOutOfMemoryError();
+    assert(0);
+}
+
+void destroy(T)(ref T t) if (is(T == struct) && dtorIsNothrow!T)
+{
+    scope (failure) assert(0); // nothrow hack
+    object.destroy(t);
+}
+
+void destroy(T)(ref T t) if (!is(T == struct))
+{
+    t = T.init;
+}
+
+void initialize(T)(ref T t) if (is(T == struct))
+{
+    import core.stdc.string;
+    if(auto p = typeid(T).initializer().ptr)
+        memcpy(&t, p, T.sizeof);
+    else
+        memset(&t, 0, T.sizeof);
+}
+
+void initialize(T)(ref T t) if (!is(T == struct))
+{
+    t = T.init;
+}
+
+version (unittest) struct RC
+{
+nothrow:
+    this(size_t* cnt) { ++*(_cnt = cnt); }
+    ~this() { if (_cnt) --*_cnt; }
+    this(this) { if (_cnt) ++*_cnt; }
+    size_t* _cnt;
+}
diff --git a/libphobos/libdruntime/rt/util/container/hashtab.d b/libphobos/libdruntime/rt/util/container/hashtab.d
new file mode 100644
index 00000000000..ef41b758113
--- /dev/null
+++ b/libphobos/libdruntime/rt/util/container/hashtab.d
@@ -0,0 +1,330 @@
+/**
+ * HashTab container for internal usage.
+ *
+ * Copyright: Copyright Martin Nowak 2013.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Martin Nowak
+ */
+module rt.util.container.hashtab;
+
+import rt.util.container.array;
+static import common = rt.util.container.common;
+
+struct HashTab(Key, Value)
+{
+    static struct Node
+    {
+        Key _key;
+        Value _value;
+        Node* _next;
+    }
+
+    @disable this(this);
+
+    ~this()
+    {
+        reset();
+    }
+
+    void reset()
+    {
+        foreach (p; _buckets)
+        {
+            while (p !is null)
+            {
+                auto pn = p._next;
+                common.destroy(*p);
+                common.free(p);
+                p = pn;
+            }
+        }
+        _buckets.reset();
+        _length = 0;
+    }
+
+    @property size_t length() const
+    {
+        return _length;
+    }
+
+    @property bool empty() const
+    {
+        return !_length;
+    }
+
+    void remove(in Key key)
+    in { assert(key in this); }
+    body
+    {
+        ensureNotInOpApply();
+
+        immutable hash = hashOf(key) & mask;
+        auto pp = &_buckets[hash];
+        while (*pp)
+        {
+            auto p = *pp;
+            if (p._key == key)
+            {
+                *pp = p._next;
+                common.destroy(*p);
+                common.free(p);
+                if (--_length < _buckets.length && _length >= 4)
+                    shrink();
+                return;
+            }
+            else
+            {
+                pp = &p._next;
+            }
+        }
+        assert(0);
+    }
+
+    ref inout(Value) opIndex(Key key) inout
+    {
+        return *opIn_r(key);
+    }
+
+    void opIndexAssign(Value value, Key key)
+    {
+        *get(key) = value;
+    }
+
+    inout(Value)* opIn_r(in Key key) inout
+    {
+        if (_buckets.length)
+        {
+            immutable hash = hashOf(key) & mask;
+            for (inout(Node)* p = _buckets[hash]; p !is null; p = p._next)
+            {
+                if (p._key == key)
+                    return &p._value;
+            }
+        }
+        return null;
+    }
+
+    int opApply(scope int delegate(ref Key, ref Value) dg)
+    {
+        immutable save = _inOpApply;
+        _inOpApply = true;
+        scope (exit) _inOpApply = save;
+        foreach (p; _buckets)
+        {
+            while (p !is null)
+            {
+                if (auto res = dg(p._key, p._value))
+                    return res;
+                p = p._next;
+            }
+        }
+        return 0;
+    }
+
+private:
+
+    Value* get(Key key)
+    {
+        if (auto p = opIn_r(key))
+            return p;
+
+        ensureNotInOpApply();
+
+        if (!_buckets.length)
+            _buckets.length = 4;
+
+        immutable hash = hashOf(key) & mask;
+        auto p = cast(Node*)common.xmalloc(Node.sizeof);
+        common.initialize(*p);
+        p._key = key;
+        p._next = _buckets[hash];
+        _buckets[hash] = p;
+        if (++_length >= 2 * _buckets.length)
+            grow();
+        return &p._value;
+    }
+
+    static hash_t hashOf(in ref Key key)
+    {
+        import rt.util.hash : hashOf;
+        static if (is(Key U : U[]))
+            return hashOf(cast(const ubyte*)key.ptr, key.length * key[0].sizeof);
+        else
+            return hashOf(cast(const ubyte*)&key, Key.sizeof);
+    }
+
+    @property hash_t mask() const
+    {
+        return _buckets.length - 1;
+    }
+
+    void grow()
+    in
+    {
+        assert(_buckets.length);
+    }
+    body
+    {
+        immutable ocnt = _buckets.length;
+        immutable nmask = 2 * ocnt - 1;
+        _buckets.length = 2 * ocnt;
+        for (size_t i = 0; i < ocnt; ++i)
+        {
+            auto pp = &_buckets[i];
+            while (*pp)
+            {
+                auto p = *pp;
+
+                immutable nidx = hashOf(p._key) & nmask;
+                if (nidx != i)
+                {
+                    *pp = p._next;
+                    p._next = _buckets[nidx];
+                    _buckets[nidx] = p;
+                }
+                else
+                {
+                    pp = &p._next;
+                }
+            }
+        }
+    }
+
+    void shrink()
+    in
+    {
+        assert(_buckets.length >= 2);
+    }
+    body
+    {
+        immutable ocnt = _buckets.length;
+        immutable ncnt = ocnt >> 1;
+        immutable nmask = ncnt - 1;
+
+        for (size_t i = ncnt; i < ocnt; ++i)
+        {
+            if (auto tail = _buckets[i])
+            {
+                immutable nidx = i & nmask;
+                auto pp = &_buckets[nidx];
+                while (*pp)
+                    pp = &(*pp)._next;
+                *pp = tail;
+                _buckets[i] = null;
+            }
+        }
+        _buckets.length = ncnt;
+    }
+
+    void ensureNotInOpApply()
+    {
+        if (_inOpApply)
+            assert(0, "Invalid HashTab manipulation during opApply iteration.");
+    }
+
+    Array!(Node*) _buckets;
+    size_t _length;
+    bool _inOpApply;
+}
+
+unittest
+{
+    HashTab!(int, int) tab;
+
+    foreach(i; 0 .. 100)
+        tab[i] = 100 - i;
+
+    foreach(i; 0 .. 100)
+        assert(tab[i] == 100 - i);
+
+    foreach (k, v; tab)
+        assert(v == 100 - k);
+
+    foreach(i; 0 .. 50)
+        tab.remove(2 * i);
+
+    assert(tab.length == 50);
+
+    foreach(i; 0 .. 50)
+        assert(tab[2 * i + 1] == 100 - 2 * i - 1);
+
+    assert(tab.length == 50);
+
+    tab.reset();
+    assert(tab.empty);
+    tab[0] = 0;
+    assert(!tab.empty);
+    destroy(tab);
+    assert(tab.empty);
+
+    // not copyable
+    static assert(!__traits(compiles, { HashTab!(int, int) tab2 = tab; }));
+    HashTab!(int, int) tab2;
+    static assert(!__traits(compiles, tab = tab2));
+    static void foo(HashTab!(int, int) copy) {}
+    static assert(!__traits(compiles, foo(tab)));
+}
+
+unittest
+{
+    HashTab!(string, size_t) tab;
+
+    tab["foo"] = 0;
+    assert(tab["foo"] == 0);
+    ++tab["foo"];
+    assert(tab["foo"] == 1);
+    tab["foo"]++;
+    assert(tab["foo"] == 2);
+
+    auto s = "fo";
+    s ~= "o";
+    assert(tab[s] == 2);
+    assert(tab.length == 1);
+    tab[s] -= 2;
+    assert(tab[s] == 0);
+    tab["foo"] = 12;
+    assert(tab[s] == 12);
+
+    tab.remove("foo");
+    assert(tab.empty);
+}
+
+unittest
+{
+    alias RC = common.RC;
+    HashTab!(size_t, RC) tab;
+
+    size_t cnt;
+    assert(cnt == 0);
+    tab[0] = RC(&cnt);
+    assert(cnt == 1);
+    tab[1] = tab[0];
+    assert(cnt == 2);
+    tab.remove(0);
+    assert(cnt == 1);
+    tab.remove(1);
+    assert(cnt == 0);
+}
+
+unittest
+{
+    import core.exception;
+
+    HashTab!(uint, uint) tab;
+    foreach (i; 0 .. 5)
+        tab[i] = i;
+    bool thrown;
+    foreach (k, v; tab)
+    {
+        try
+        {
+            if (k == 3) tab.remove(k);
+        }
+        catch (AssertError e)
+        {
+            thrown = true;
+        }
+    }
+    assert(thrown);
+    assert(tab[3] == 3);
+}
diff --git a/libphobos/libdruntime/rt/util/container/treap.d b/libphobos/libdruntime/rt/util/container/treap.d
new file mode 100644
index 00000000000..d252d364770
--- /dev/null
+++ b/libphobos/libdruntime/rt/util/container/treap.d
@@ -0,0 +1,338 @@
+/**
+ * Treap container for internal usage.
+ *
+ * Copyright: Copyright Digital Mars 2014 - 2014.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ */
+module rt.util.container.treap;
+
+static import common = rt.util.container.common;
+import rt.util.random;
+import rt.qsort;
+
+struct Treap(E)
+{
+nothrow:
+    static struct Node
+    {
+        Node* left, right;
+        E element;
+        uint priority;
+    }
+
+    @disable this(this);
+
+    ~this()
+    {
+        removeAll();
+    }
+
+    void initialize()
+    {
+        rand48.defaultSeed();
+    }
+
+    void insert(E element) @nogc
+    {
+        root = insert(root, element);
+    }
+
+    void remove(E element)
+    {
+        remove(&root, element);
+    }
+
+    int opApply(scope int delegate(ref E) nothrow dg)
+    {
+        return (cast(const)&this).opApply((ref const E e) => dg(*cast(E*)&e));
+    }
+
+    int opApply(scope int delegate(ref const E) nothrow dg) const
+    {
+        return opApplyHelper(root, dg);
+    }
+
+    version(unittest)
+    bool opEquals(E[] elements)
+    {
+        size_t i;
+        foreach (e; this)
+        {
+            if (i >= elements.length)
+                return false;
+            if (e != elements[i++])
+                return false;
+        }
+        return i == elements.length;
+    }
+
+    void removeAll()
+    {
+        removeAll(root);
+        root = null;
+    }
+
+    version(unittest)
+    bool valid()
+    {
+        return valid(root);
+    }
+
+
+    version(none)
+    uint height()
+    {
+        static uint height(Node* node)
+        {
+            if (!node)
+                return 0;
+            auto left = height(node.left);
+            auto right = height(node.right);
+            return 1 + (left > right ? left : right);
+        }
+        return height(root);
+    }
+
+    version(none)
+    size_t count()
+    {
+        static size_t count(Node* node)
+        {
+            if (!node)
+                return 0;
+            return count(node.left) + count(node.right) + 1;
+        }
+        return count(root);
+    }
+
+
+private:
+    Node* root;
+    Rand48 rand48;
+
+    Node* allocNode(E element) @nogc
+    {
+        Node* node = cast(Node*)common.xmalloc(Node.sizeof);
+        node.left = node.right = null;
+        node.priority = rand48();
+        node.element = element;
+        return node;
+    }
+
+    Node* insert(Node* node, E element) @nogc
+    {
+        if (!node)
+            return allocNode(element);
+        else if (element < node.element)
+        {
+            node.left = insert(node.left, element);
+            if (node.left.priority < node.priority)
+                node = rotateR(node);
+        }
+        else if (element > node.element)
+        {
+            node.right = insert(node.right, element);
+            if (node.right.priority < node.priority)
+                node = rotateL(node);
+        }
+        else
+        {} // ignore duplicate
+
+        return node;
+    }
+
+static:
+
+    void freeNode(Node* node)
+    {
+        common.free(node);
+    }
+
+    Node* rotateL(Node* root)
+    {
+        auto pivot = root.right;
+        root.right = pivot.left;
+        pivot.left = root;
+        return pivot;
+    }
+
+    Node* rotateR(Node* root)
+    {
+        auto pivot = root.left;
+        root.left = pivot.right;
+        pivot.right = root;
+        return pivot;
+    }
+
+    void remove(Node** ppnode, E element)
+    {
+        Node* node = *ppnode;
+        if (!node)
+            return; // element not in treap
+
+        if (element < node.element)
+        {
+            remove(&node.left, element);
+        }
+        else if (element > node.element)
+        {
+            remove(&node.right, element);
+        }
+        else
+        {
+            while (node.left && node.right)
+            {
+                if (node.left.priority < node.right.priority)
+                {
+                    *ppnode = rotateR(node);
+                    ppnode = &(*ppnode).right;
+                }
+                else
+                {
+                    *ppnode = rotateL(node);
+                    ppnode = &(*ppnode).left;
+                }
+            }
+            if (!node.left)
+                *ppnode = node.right;
+            else
+                *ppnode = node.left;
+            freeNode(node);
+        }
+    }
+
+    void removeAll(Node* node)
+    {
+        if (!node)
+            return;
+        removeAll(node.left);
+        removeAll(node.right);
+        freeNode(node);
+    }
+
+    int opApplyHelper(const Node* node, scope int delegate(ref const E) nothrow dg)
+    {
+        if (!node)
+            return 0;
+
+        int result = opApplyHelper(node.left, dg);
+        if (result)
+            return result;
+        result = dg(node.element);
+        if (result)
+            return result;
+        return opApplyHelper(node.right, dg);
+    }
+
+    version(unittest)
+    bool valid(Node* node)
+    {
+        if (!node)
+            return true;
+
+        if (node.left)
+        {
+            if (node.left.priority < node.priority)
+                return false;
+            if (node.left.element > node.element)
+                return false;
+        }
+        if (node.right)
+        {
+            if (node.right.priority < node.priority)
+                return false;
+            if (node.right.element < node.element)
+                return false;
+        }
+        return valid(node.left) && valid(node.right);
+    }
+}
+
+unittest
+{
+    // randomized unittest for randomized data structure
+    import /*cstdlib = */core.stdc.stdlib : rand, srand;
+    import /*ctime = */core.stdc.time : time;
+
+    enum OP { add, remove }
+    enum initialSize = 1000;
+    enum randOps = 1000;
+
+    Treap!uint treap;
+    OP[] ops;
+    uint[] opdata;
+
+    treap.initialize();
+    srand(cast(uint)time(null));
+
+    uint[] data;
+initialLoop:
+    foreach (i; 0 .. initialSize)
+    {
+        data ~= rand();
+        treap.insert(data[$-1]);
+        foreach (e; data[0..$-1])
+            if (e == data[$-1])
+            {
+                data = data[0..$-1];
+                continue initialLoop;
+            }
+    }
+    _adSort(*cast(void[]*)&data, typeid(data[0]));
+    assert(treap == data);
+    assert(treap.valid());
+
+    for (int i = randOps; i > 0; --i)
+    {
+        ops ~= cast(OP)(rand() < uint.max / 2 ? OP.add: OP.remove);
+        opdata ~= rand();
+    }
+
+    foreach (op; ops)
+    {
+        if (op == OP.add)
+        {
+            treap.insert(opdata[0]);
+
+            size_t i;
+            for (i = 0; i < data.length; ++i)
+                if (data[i] >= opdata[0])
+                    break;
+
+            if (i == data.length || data[i] != opdata[0])
+            {    // not a duplicate
+                data.length++;
+                uint tmp = opdata[0];
+                for (; i < data.length; ++i)
+                {
+                    uint tmp2 = data[i];
+                    data[i] = tmp;
+                    tmp = tmp2;
+                }
+            }
+        }
+        else if (!data.length)    // nothing to remove
+        {
+            opdata = opdata[1..$];
+            continue;
+        }
+        else
+        {
+            uint tmp = data[opdata[0]%data.length];
+            treap.remove(tmp);
+            size_t i;
+            for (i = 0; data[i] < tmp; ++i)
+            {}
+            for (; i < data.length-1; ++i)
+                data[i] = data[i+1];
+            data.length--;
+        }
+        assert(treap.valid());
+        assert(treap == data);
+        opdata = opdata[1..$];
+    }
+
+    treap.removeAll();
+    data.length = 0;
+    assert(treap == data);
+}
diff --git a/libphobos/libdruntime/rt/util/hash.d b/libphobos/libdruntime/rt/util/hash.d
new file mode 100644
index 00000000000..e5815a21349
--- /dev/null
+++ b/libphobos/libdruntime/rt/util/hash.d
@@ -0,0 +1,109 @@
+/**
+ * This module contains the default hash implementation.
+ *
+ * Copyright: Copyright Sean Kelly 2009 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Sean Kelly
+ */
+
+/*          Copyright Sean Kelly 2009 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.util.hash;
+
+
+version( X86 )
+    version = AnyX86;
+version( X86_64 )
+    version = AnyX86;
+version( AnyX86 )
+    version = HasUnalignedOps;
+
+
+@trusted pure nothrow
+size_t hashOf( const (void)* buf, size_t len, size_t seed = 0 )
+{
+    /*
+     * This is Paul Hsieh's SuperFastHash algorithm, described here:
+     *   http://www.azillionmonkeys.com/qed/hash.html
+     * It is protected by the following open source license:
+     *   http://www.azillionmonkeys.com/qed/weblicense.html
+     */
+    static uint get16bits( const (ubyte)* x ) pure nothrow
+    {
+        // CTFE doesn't support casting ubyte* -> ushort*, so revert to
+        // per-byte access when in CTFE.
+        version( HasUnalignedOps )
+        {
+            if (!__ctfe)
+                return *cast(ushort*) x;
+        }
+
+        return ((cast(uint) x[1]) << 8) + (cast(uint) x[0]);
+    }
+
+    // NOTE: SuperFastHash normally starts with a zero hash value.  The seed
+    //       value was incorporated to allow chaining.
+    auto data = cast(const (ubyte)*) buf;
+    auto hash = seed;
+    int  rem;
+
+    if( len <= 0 || data is null )
+        return 0;
+
+    rem = len & 3;
+    len >>= 2;
+
+    for( ; len > 0; len-- )
+    {
+        hash += get16bits( data );
+        auto tmp = (get16bits( data + 2 ) << 11) ^ hash;
+        hash  = (hash << 16) ^ tmp;
+        data += 2 * ushort.sizeof;
+        hash += hash >> 11;
+    }
+
+    switch( rem )
+    {
+    case 3: hash += get16bits( data );
+            hash ^= hash << 16;
+            hash ^= data[ushort.sizeof] << 18;
+            hash += hash >> 11;
+            break;
+    case 2: hash += get16bits( data );
+            hash ^= hash << 11;
+            hash += hash >> 17;
+            break;
+    case 1: hash += *data;
+            hash ^= hash << 10;
+            hash += hash >> 1;
+            break;
+     default:
+            break;
+    }
+
+    /* Force "avalanching" of final 127 bits */
+    hash ^= hash << 3;
+    hash += hash >> 5;
+    hash ^= hash << 4;
+    hash += hash >> 17;
+    hash ^= hash << 25;
+    hash += hash >> 6;
+
+    return hash;
+}
+
+// Check that hashOf works with CTFE
+unittest
+{
+    size_t ctfeHash(string x)
+    {
+        return hashOf(x.ptr, x.length);
+    }
+
+    enum test_str = "Sample string";
+    enum size_t hashVal = ctfeHash(test_str);
+    assert(hashVal == hashOf(test_str.ptr, test_str.length));
+}
diff --git a/libphobos/libdruntime/rt/util/random.d b/libphobos/libdruntime/rt/util/random.d
new file mode 100644
index 00000000000..bbe29ce0001
--- /dev/null
+++ b/libphobos/libdruntime/rt/util/random.d
@@ -0,0 +1,48 @@
+/**
+ * Random number generators for internal usage.
+ *
+ * Copyright: Copyright Digital Mars 2014.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ */
+module rt.util.random;
+
+struct Rand48
+{
+nothrow:
+    private ulong rng_state;
+
+    void defaultSeed()
+    {
+        import ctime = core.stdc.time : time;
+        seed(cast(uint)ctime.time(null));
+    }
+
+    void seed(uint seedval)
+    {
+        assert(seedval);
+        rng_state = cast(ulong)seedval << 16 | 0x330e;
+        popFront();
+    }
+
+    auto opCall() @nogc
+    {
+        auto result = front;
+        popFront();
+        return result;
+    }
+
+    @property uint front() @nogc
+    {
+        return cast(uint)(rng_state >> 16);
+    }
+
+    void popFront() @nogc
+    {
+        immutable ulong a = 25214903917;
+        immutable ulong c = 11;
+        immutable ulong m_mask = (1uL << 48uL) - 1;
+        rng_state = (a*rng_state+c) & m_mask;
+    }
+
+    enum empty = false;
+}
diff --git a/libphobos/libdruntime/rt/util/typeinfo.d b/libphobos/libdruntime/rt/util/typeinfo.d
new file mode 100644
index 00000000000..8c41e0a13b0
--- /dev/null
+++ b/libphobos/libdruntime/rt/util/typeinfo.d
@@ -0,0 +1,289 @@
+/**
+ * This module contains utilities for TypeInfo implementation.
+ *
+ * Copyright: Copyright Kenji Hara 2014-.
+ * License:   <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
+ * Authors:   Kenji Hara
+ */
+module rt.util.typeinfo;
+
+public import rt.util.hash;
+
+template Floating(T)
+if (is(T == float) || is(T == double) || is(T == real))
+{
+  pure nothrow @safe:
+
+    bool equals(T f1, T f2)
+    {
+        return f1 == f2;
+    }
+
+    int compare(T d1, T d2)
+    {
+        if (d1 != d1 || d2 != d2) // if either are NaN
+        {
+            if (d1 != d1)
+            {
+                if (d2 != d2)
+                    return 0;
+                return -1;
+            }
+            return 1;
+        }
+        return (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1);
+    }
+
+    size_t hashOf(T value) @trusted
+    {
+        if (value == 0) // +0.0 and -0.0
+            value = 0;
+
+        static if (is(T == float))  // special case?
+            return *cast(uint*)&value;
+        else
+            return rt.util.hash.hashOf(&value, T.sizeof);
+    }
+}
+template Floating(T)
+if (is(T == cfloat) || is(T == cdouble) || is(T == creal))
+{
+  pure nothrow @safe:
+
+    bool equals(T f1, T f2)
+    {
+        return f1 == f2;
+    }
+
+    int compare(T f1, T f2)
+    {
+        int result;
+
+        if (f1.re < f2.re)
+            result = -1;
+        else if (f1.re > f2.re)
+            result = 1;
+        else if (f1.im < f2.im)
+            result = -1;
+        else if (f1.im > f2.im)
+            result = 1;
+        else
+            result = 0;
+        return result;
+    }
+
+    size_t hashOf(T value) @trusted
+    {
+        if (value == 0 + 0i)
+            value = 0 + 0i;
+        return rt.util.hash.hashOf(&value, T.sizeof);
+    }
+}
+
+template Array(T)
+if (is(T ==  float) || is(T ==  double) || is(T ==  real) ||
+    is(T == cfloat) || is(T == cdouble) || is(T == creal))
+{
+  pure nothrow @safe:
+
+    bool equals(T[] s1, T[] s2)
+    {
+        size_t len = s1.length;
+        if (len != s2.length)
+            return false;
+        for (size_t u = 0; u < len; u++)
+        {
+            if (!Floating!T.equals(s1[u], s2[u]))
+                return false;
+        }
+        return true;
+    }
+
+    int compare(T[] s1, T[] s2)
+    {
+        size_t len = s1.length;
+        if (s2.length < len)
+            len = s2.length;
+        for (size_t u = 0; u < len; u++)
+        {
+            if (int c = Floating!T.compare(s1[u], s2[u]))
+                return c;
+        }
+        if (s1.length < s2.length)
+            return -1;
+        else if (s1.length > s2.length)
+            return 1;
+        return 0;
+    }
+
+    size_t hashOf(T[] value)
+    {
+        size_t h = 0;
+        foreach (e; value)
+            h += Floating!T.hashOf(e);
+        return h;
+    }
+}
+
+version(unittest)
+{
+    alias TypeTuple(T...) = T;
+}
+unittest
+{
+    // Bugzilla 13052
+
+    static struct SX(F) { F f; }
+    TypeInfo ti;
+
+    // real types
+    foreach (F; TypeTuple!(float, double, real))
+    (){ // workaround #2396
+        alias S = SX!F;
+        F f1 = +0.0,
+          f2 = -0.0;
+
+        assert(f1  == f2);
+        assert(f1 !is f2);
+        ti = typeid(F);
+        assert(ti.getHash(&f1) == ti.getHash(&f2));
+
+        F[] a1 = [f1, f1, f1];
+        F[] a2 = [f2, f2, f2];
+        assert(a1  == a2);
+        assert(a1 !is a2);
+        ti = typeid(F[]);
+        assert(ti.getHash(&a1) == ti.getHash(&a2));
+
+        F[][] aa1 = [a1, a1, a1];
+        F[][] aa2 = [a2, a2, a2];
+        assert(aa1  == aa2);
+        assert(aa1 !is aa2);
+        ti = typeid(F[][]);
+        assert(ti.getHash(&aa1) == ti.getHash(&aa2));
+
+        S s1 = {f1},
+          s2 = {f2};
+        assert(s1  == s2);
+        assert(s1 !is s2);
+        ti = typeid(S);
+        assert(ti.getHash(&s1) == ti.getHash(&s2));
+
+        S[] da1 = [S(f1), S(f1), S(f1)],
+            da2 = [S(f2), S(f2), S(f2)];
+        assert(da1  == da2);
+        assert(da1 !is da2);
+        ti = typeid(S[]);
+        assert(ti.getHash(&da1) == ti.getHash(&da2));
+
+        S[3] sa1 = {f1},
+             sa2 = {f2};
+        assert(sa1  == sa2);
+        assert(sa1 !is sa2);
+        ti = typeid(S[3]);
+        assert(ti.getHash(&sa1) == ti.getHash(&sa2));
+    }();
+
+    // imaginary types
+    foreach (F; TypeTuple!(ifloat, idouble, ireal))
+    (){ // workaround #2396
+        alias S = SX!F;
+        F f1 = +0.0i,
+          f2 = -0.0i;
+
+        assert(f1  == f2);
+        assert(f1 !is f2);
+        ti = typeid(F);
+        assert(ti.getHash(&f1) == ti.getHash(&f2));
+
+        F[] a1 = [f1, f1, f1];
+        F[] a2 = [f2, f2, f2];
+        assert(a1  == a2);
+        assert(a1 !is a2);
+        ti = typeid(F[]);
+        assert(ti.getHash(&a1) == ti.getHash(&a2));
+
+        F[][] aa1 = [a1, a1, a1];
+        F[][] aa2 = [a2, a2, a2];
+        assert(aa1  == aa2);
+        assert(aa1 !is aa2);
+        ti = typeid(F[][]);
+        assert(ti.getHash(&aa1) == ti.getHash(&aa2));
+
+        S s1 = {f1},
+          s2 = {f2};
+        assert(s1  == s2);
+        assert(s1 !is s2);
+        ti = typeid(S);
+        assert(ti.getHash(&s1) == ti.getHash(&s2));
+
+        S[] da1 = [S(f1), S(f1), S(f1)],
+            da2 = [S(f2), S(f2), S(f2)];
+        assert(da1  == da2);
+        assert(da1 !is da2);
+        ti = typeid(S[]);
+        assert(ti.getHash(&da1) == ti.getHash(&da2));
+
+        S[3] sa1 = {f1},
+             sa2 = {f2};
+        assert(sa1  == sa2);
+        assert(sa1 !is sa2);
+        ti = typeid(S[3]);
+        assert(ti.getHash(&sa1) == ti.getHash(&sa2));
+    }();
+
+    // complex types
+    foreach (F; TypeTuple!(cfloat, cdouble, creal))
+    (){ // workaround #2396
+        alias S = SX!F;
+        F[4] f = [+0.0 + 0.0i,
+                  +0.0 - 0.0i,
+                  -0.0 + 0.0i,
+                  -0.0 - 0.0i];
+
+        foreach (i, f1; f) foreach (j, f2; f) if (i != j)
+        {
+            assert(f1 == 0 + 0i);
+
+            assert(f1  == f2);
+            assert(f1 !is f2);
+            ti = typeid(F);
+            assert(ti.getHash(&f1) == ti.getHash(&f2));
+
+            F[] a1 = [f1, f1, f1];
+            F[] a2 = [f2, f2, f2];
+            assert(a1  == a2);
+            assert(a1 !is a2);
+            ti = typeid(F[]);
+            assert(ti.getHash(&a1) == ti.getHash(&a2));
+
+            F[][] aa1 = [a1, a1, a1];
+            F[][] aa2 = [a2, a2, a2];
+            assert(aa1  == aa2);
+            assert(aa1 !is aa2);
+            ti = typeid(F[][]);
+            assert(ti.getHash(&aa1) == ti.getHash(&aa2));
+
+            S s1 = {f1},
+              s2 = {f2};
+            assert(s1  == s2);
+            assert(s1 !is s2);
+            ti = typeid(S);
+            assert(ti.getHash(&s1) == ti.getHash(&s2));
+
+            S[] da1 = [S(f1), S(f1), S(f1)],
+                da2 = [S(f2), S(f2), S(f2)];
+            assert(da1  == da2);
+            assert(da1 !is da2);
+            ti = typeid(S[]);
+            assert(ti.getHash(&da1) == ti.getHash(&da2));
+
+            S[3] sa1 = {f1},
+                 sa2 = {f2};
+            assert(sa1  == sa2);
+            assert(sa1 !is sa2);
+            ti = typeid(S[3]);
+            assert(ti.getHash(&sa1) == ti.getHash(&sa2));
+        }
+    }();
+}
diff --git a/libphobos/libdruntime/rt/util/utf.d b/libphobos/libdruntime/rt/util/utf.d
new file mode 100644
index 00000000000..90579974ffc
--- /dev/null
+++ b/libphobos/libdruntime/rt/util/utf.d
@@ -0,0 +1,903 @@
+/********************************************
+ * Encode and decode UTF-8, UTF-16 and UTF-32 strings.
+ *
+ * For Win32 systems, the C wchar_t type is UTF-16 and corresponds to the D
+ * wchar type.
+ * For Posix systems, the C wchar_t type is UTF-32 and corresponds to
+ * the D utf.dchar type.
+ *
+ * UTF character support is restricted to (\u0000 &lt;= character &lt;= \U0010FFFF).
+ *
+ * See_Also:
+ *      $(LINK2 http://en.wikipedia.org/wiki/Unicode, Wikipedia)<br>
+ *      $(LINK http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8)<br>
+ *      $(LINK http://anubis.dkuug.dk/JTC1/SC2/WG2/docs/n1335)
+ * Macros:
+ *      WIKI = Phobos/StdUtf
+ *
+ * Copyright: Copyright Digital Mars 2003 - 2009.
+ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors:   Walter Bright, Sean Kelly
+ */
+
+/*          Copyright Digital Mars 2003 - 2009.
+ * Distributed under the Boost Software License, Version 1.0.
+ *    (See accompanying file LICENSE or copy at
+ *          http://www.boost.org/LICENSE_1_0.txt)
+ */
+module rt.util.utf;
+
+
+extern (C) void onUnicodeError( string msg, size_t idx, string file = __FILE__, size_t line = __LINE__ );
+
+/*******************************
+ * Test if c is a valid UTF-32 character.
+ *
+ * \uFFFE and \uFFFF are considered valid by this function,
+ * as they are permitted for internal use by an application,
+ * but they are not allowed for interchange by the Unicode standard.
+ *
+ * Returns: true if it is, false if not.
+ */
+
+bool isValidDchar(dchar c)
+{
+    /* Note: FFFE and FFFF are specifically permitted by the
+     * Unicode standard for application internal use, but are not
+     * allowed for interchange.
+     * (thanks to Arcane Jill)
+     */
+
+    return c < 0xD800 ||
+        (c > 0xDFFF && c <= 0x10FFFF /*&& c != 0xFFFE && c != 0xFFFF*/);
+}
+
+unittest
+{
+    debug(utf) printf("utf.isValidDchar.unittest\n");
+    assert(isValidDchar(cast(dchar)'a') == true);
+    assert(isValidDchar(cast(dchar)0x1FFFFF) == false);
+}
+
+
+
+static immutable UTF8stride =
+[
+    cast(ubyte)
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+    2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+    2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+    3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
+    4,4,4,4,4,4,4,4,5,5,5,5,6,6,0xFF,0xFF,
+];
+
+/**
+ * stride() returns the length of a UTF-8 sequence starting at index i
+ * in string s.
+ * Returns:
+ *      The number of bytes in the UTF-8 sequence or
+ *      0xFF meaning s[i] is not the start of of UTF-8 sequence.
+ */
+uint stride(in char[] s, size_t i)
+{
+    return UTF8stride[s[i]];
+}
+
+/**
+ * stride() returns the length of a UTF-16 sequence starting at index i
+ * in string s.
+ */
+uint stride(in wchar[] s, size_t i)
+{   uint u = s[i];
+    return 1 + (u >= 0xD800 && u <= 0xDBFF);
+}
+
+/**
+ * stride() returns the length of a UTF-32 sequence starting at index i
+ * in string s.
+ * Returns: The return value will always be 1.
+ */
+uint stride(in dchar[] s, size_t i)
+{
+    return 1;
+}
+
+/*******************************************
+ * Given an index i into an array of characters s[],
+ * and assuming that index i is at the start of a UTF character,
+ * determine the number of UCS characters up to that index i.
+ */
+
+size_t toUCSindex(in char[] s, size_t i)
+{
+    size_t n;
+    size_t j;
+
+    for (j = 0; j < i; )
+    {
+        j += stride(s, j);
+        n++;
+    }
+    if (j > i)
+    {
+        onUnicodeError("invalid UTF-8 sequence", j);
+    }
+    return n;
+}
+
+/** ditto */
+size_t toUCSindex(in wchar[] s, size_t i)
+{
+    size_t n;
+    size_t j;
+
+    for (j = 0; j < i; )
+    {
+        j += stride(s, j);
+        n++;
+    }
+    if (j > i)
+    {
+        onUnicodeError("invalid UTF-16 sequence", j);
+    }
+    return n;
+}
+
+/** ditto */
+size_t toUCSindex(in dchar[] s, size_t i)
+{
+    return i;
+}
+
+/******************************************
+ * Given a UCS index n into an array of characters s[], return the UTF index.
+ */
+
+size_t toUTFindex(in char[] s, size_t n)
+{
+    size_t i;
+
+    while (n--)
+    {
+        uint j = UTF8stride[s[i]];
+        if (j == 0xFF)
+            onUnicodeError("invalid UTF-8 sequence", i);
+        i += j;
+    }
+    return i;
+}
+
+/** ditto */
+size_t toUTFindex(in wchar[] s, size_t n)
+{
+    size_t i;
+
+    while (n--)
+    {   wchar u = s[i];
+
+        i += 1 + (u >= 0xD800 && u <= 0xDBFF);
+    }
+    return i;
+}
+
+/** ditto */
+size_t toUTFindex(in dchar[] s, size_t n)
+{
+    return n;
+}
+
+/* =================== Decode ======================= */
+
+/***************
+ * Decodes and returns character starting at s[idx]. idx is advanced past the
+ * decoded character. If the character is not well formed, a UtfException is
+ * thrown and idx remains unchanged.
+ */
+dchar decode(in char[] s, ref size_t idx)
+    in
+    {
+        assert(idx >= 0 && idx < s.length);
+    }
+    out (result)
+    {
+        assert(isValidDchar(result));
+    }
+    body
+    {
+        size_t len = s.length;
+        dchar V;
+        size_t i = idx;
+        char u = s[i];
+
+        if (u & 0x80)
+        {   uint n;
+            char u2;
+
+            /* The following encodings are valid, except for the 5 and 6 byte
+             * combinations:
+             *  0xxxxxxx
+             *  110xxxxx 10xxxxxx
+             *  1110xxxx 10xxxxxx 10xxxxxx
+             *  11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+             *  111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
+             *  1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
+             */
+            for (n = 1; ; n++)
+            {
+                if (n > 4)
+                    goto Lerr;          // only do the first 4 of 6 encodings
+                if (((u << n) & 0x80) == 0)
+                {
+                    if (n == 1)
+                        goto Lerr;
+                    break;
+                }
+            }
+
+            // Pick off (7 - n) significant bits of B from first byte of octet
+            V = cast(dchar)(u & ((1 << (7 - n)) - 1));
+
+            if (i + (n - 1) >= len)
+                goto Lerr;                      // off end of string
+
+            /* The following combinations are overlong, and illegal:
+             *  1100000x (10xxxxxx)
+             *  11100000 100xxxxx (10xxxxxx)
+             *  11110000 1000xxxx (10xxxxxx 10xxxxxx)
+             *  11111000 10000xxx (10xxxxxx 10xxxxxx 10xxxxxx)
+             *  11111100 100000xx (10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
+             */
+            u2 = s[i + 1];
+            if ((u & 0xFE) == 0xC0 ||
+                (u == 0xE0 && (u2 & 0xE0) == 0x80) ||
+                (u == 0xF0 && (u2 & 0xF0) == 0x80) ||
+                (u == 0xF8 && (u2 & 0xF8) == 0x80) ||
+                (u == 0xFC && (u2 & 0xFC) == 0x80))
+                goto Lerr;                      // overlong combination
+
+            for (uint j = 1; j != n; j++)
+            {
+                u = s[i + j];
+                if ((u & 0xC0) != 0x80)
+                    goto Lerr;                  // trailing bytes are 10xxxxxx
+                V = (V << 6) | (u & 0x3F);
+            }
+            if (!isValidDchar(V))
+                goto Lerr;
+            i += n;
+        }
+        else
+        {
+            V = cast(dchar) u;
+            i++;
+        }
+
+        idx = i;
+        return V;
+
+      Lerr:
+      onUnicodeError("invalid UTF-8 sequence", i);
+    return V; // dummy return
+    }
+
+unittest
+{   size_t i;
+    dchar c;
+
+    debug(utf) printf("utf.decode.unittest\n");
+
+    static s1 = "abcd"c;
+    i = 0;
+    c = decode(s1, i);
+    assert(c == cast(dchar)'a');
+    assert(i == 1);
+    c = decode(s1, i);
+    assert(c == cast(dchar)'b');
+    assert(i == 2);
+
+    static s2 = "\xC2\xA9"c;
+    i = 0;
+    c = decode(s2, i);
+    assert(c == cast(dchar)'\u00A9');
+    assert(i == 2);
+
+    static s3 = "\xE2\x89\xA0"c;
+    i = 0;
+    c = decode(s3, i);
+    assert(c == cast(dchar)'\u2260');
+    assert(i == 3);
+
+    static s4 =
+    [   "\xE2\x89"c[],          // too short
+        "\xC0\x8A",
+        "\xE0\x80\x8A",
+        "\xF0\x80\x80\x8A",
+        "\xF8\x80\x80\x80\x8A",
+        "\xFC\x80\x80\x80\x80\x8A",
+    ];
+
+    for (int j = 0; j < s4.length; j++)
+    {
+        try
+        {
+            i = 0;
+            c = decode(s4[j], i);
+            assert(0);
+        }
+        catch (Throwable o)
+        {
+            i = 23;
+        }
+        assert(i == 23);
+    }
+}
+
+/** ditto */
+
+dchar decode(in wchar[] s, ref size_t idx)
+    in
+    {
+        assert(idx >= 0 && idx < s.length);
+    }
+    out (result)
+    {
+        assert(isValidDchar(result));
+    }
+    body
+    {
+        string msg;
+        dchar V;
+        size_t i = idx;
+        uint u = s[i];
+
+        if (u & ~0x7F)
+        {   if (u >= 0xD800 && u <= 0xDBFF)
+            {   uint u2;
+
+                if (i + 1 == s.length)
+                {   msg = "surrogate UTF-16 high value past end of string";
+                    goto Lerr;
+                }
+                u2 = s[i + 1];
+                if (u2 < 0xDC00 || u2 > 0xDFFF)
+                {   msg = "surrogate UTF-16 low value out of range";
+                    goto Lerr;
+                }
+                u = ((u - 0xD7C0) << 10) + (u2 - 0xDC00);
+                i += 2;
+            }
+            else if (u >= 0xDC00 && u <= 0xDFFF)
+            {   msg = "unpaired surrogate UTF-16 value";
+                goto Lerr;
+            }
+            else if (u == 0xFFFE || u == 0xFFFF)
+            {   msg = "illegal UTF-16 value";
+                goto Lerr;
+            }
+            else
+                i++;
+        }
+        else
+        {
+            i++;
+        }
+
+        idx = i;
+        return cast(dchar)u;
+
+      Lerr:
+          onUnicodeError(msg, i);
+        return cast(dchar)u; // dummy return
+    }
+
+/** ditto */
+
+dchar decode(in dchar[] s, ref size_t idx)
+    in
+    {
+        assert(idx >= 0 && idx < s.length);
+    }
+    body
+    {
+        size_t i = idx;
+        dchar c = s[i];
+
+        if (!isValidDchar(c))
+            goto Lerr;
+        idx = i + 1;
+        return c;
+
+      Lerr:
+          onUnicodeError("invalid UTF-32 value", i);
+        return c; // dummy return
+    }
+
+
+/* =================== Encode ======================= */
+
+/*******************************
+ * Encodes character c and appends it to array s[].
+ */
+void encode(ref char[] s, dchar c)
+    in
+    {
+        assert(isValidDchar(c));
+    }
+    body
+    {
+        char[] r = s;
+
+        if (c <= 0x7F)
+        {
+            r ~= cast(char) c;
+        }
+        else
+        {
+            char[4] buf;
+            uint L;
+
+            if (c <= 0x7FF)
+            {
+                buf[0] = cast(char)(0xC0 | (c >> 6));
+                buf[1] = cast(char)(0x80 | (c & 0x3F));
+                L = 2;
+            }
+            else if (c <= 0xFFFF)
+            {
+                buf[0] = cast(char)(0xE0 | (c >> 12));
+                buf[1] = cast(char)(0x80 | ((c >> 6) & 0x3F));
+                buf[2] = cast(char)(0x80 | (c & 0x3F));
+                L = 3;
+            }
+            else if (c <= 0x10FFFF)
+            {
+                buf[0] = cast(char)(0xF0 | (c >> 18));
+                buf[1] = cast(char)(0x80 | ((c >> 12) & 0x3F));
+                buf[2] = cast(char)(0x80 | ((c >> 6) & 0x3F));
+                buf[3] = cast(char)(0x80 | (c & 0x3F));
+                L = 4;
+            }
+            else
+            {
+                assert(0);
+            }
+            r ~= buf[0 .. L];
+        }
+        s = r;
+    }
+
+unittest
+{
+    debug(utf) printf("utf.encode.unittest\n");
+
+    char[] s = "abcd".dup;
+    encode(s, cast(dchar)'a');
+    assert(s.length == 5);
+    assert(s == "abcda");
+
+    encode(s, cast(dchar)'\u00A9');
+    assert(s.length == 7);
+    assert(s == "abcda\xC2\xA9");
+    //assert(s == "abcda\u00A9");       // BUG: fix compiler
+
+    encode(s, cast(dchar)'\u2260');
+    assert(s.length == 10);
+    assert(s == "abcda\xC2\xA9\xE2\x89\xA0");
+}
+
+/** ditto */
+
+void encode(ref wchar[] s, dchar c)
+    in
+    {
+        assert(isValidDchar(c));
+    }
+    body
+    {
+        wchar[] r = s;
+
+        if (c <= 0xFFFF)
+        {
+            r ~= cast(wchar) c;
+        }
+        else
+        {
+            wchar[2] buf;
+
+            buf[0] = cast(wchar) ((((c - 0x10000) >> 10) & 0x3FF) + 0xD800);
+            buf[1] = cast(wchar) (((c - 0x10000) & 0x3FF) + 0xDC00);
+            r ~= buf;
+        }
+        s = r;
+    }
+
+/** ditto */
+void encode(ref dchar[] s, dchar c)
+    in
+    {
+        assert(isValidDchar(c));
+    }
+    body
+    {
+        s ~= c;
+    }
+
+/**
+Returns the code length of $(D c) in the encoding using $(D C) as a
+code point. The code is returned in character count, not in bytes.
+ */
+
+ubyte codeLength(C)(dchar c)
+{
+    static if (C.sizeof == 1)
+    {
+        if (c <= 0x7F) return 1;
+        if (c <= 0x7FF) return 2;
+        if (c <= 0xFFFF) return 3;
+        if (c <= 0x10FFFF) return 4;
+        assert(false);
+    }
+    else static if (C.sizeof == 2)
+    {
+        return c <= 0xFFFF ? 1 : 2;
+    }
+    else
+    {
+        static assert(C.sizeof == 4);
+        return 1;
+    }
+}
+
+/* =================== Validation ======================= */
+
+/***********************************
+Checks to see if string is well formed or not. $(D S) can be an array
+ of $(D char), $(D wchar), or $(D dchar). Throws a $(D UtfException)
+ if it is not. Use to check all untrusted input for correctness.
+ */
+void validate(S)(in S s)
+{
+    auto len = s.length;
+    for (size_t i = 0; i < len; )
+    {
+        decode(s, i);
+    }
+}
+
+/* =================== Conversion to UTF8 ======================= */
+
+char[] toUTF8(return out char[4] buf, dchar c)
+    in
+    {
+        assert(isValidDchar(c));
+    }
+    body
+    {
+        if (c <= 0x7F)
+        {
+            buf[0] = cast(char) c;
+            return buf[0 .. 1];
+        }
+        else if (c <= 0x7FF)
+        {
+            buf[0] = cast(char)(0xC0 | (c >> 6));
+            buf[1] = cast(char)(0x80 | (c & 0x3F));
+            return buf[0 .. 2];
+        }
+        else if (c <= 0xFFFF)
+        {
+            buf[0] = cast(char)(0xE0 | (c >> 12));
+            buf[1] = cast(char)(0x80 | ((c >> 6) & 0x3F));
+            buf[2] = cast(char)(0x80 | (c & 0x3F));
+            return buf[0 .. 3];
+        }
+        else if (c <= 0x10FFFF)
+        {
+            buf[0] = cast(char)(0xF0 | (c >> 18));
+            buf[1] = cast(char)(0x80 | ((c >> 12) & 0x3F));
+            buf[2] = cast(char)(0x80 | ((c >> 6) & 0x3F));
+            buf[3] = cast(char)(0x80 | (c & 0x3F));
+            return buf[0 .. 4];
+        }
+        assert(0);
+    }
+
+/*******************
+ * Encodes string s into UTF-8 and returns the encoded string.
+ */
+string toUTF8(string s)
+    in
+    {
+        validate(s);
+    }
+    body
+    {
+        return s;
+    }
+
+/** ditto */
+string toUTF8(in wchar[] s)
+{
+    char[] r;
+    size_t i;
+    size_t slen = s.length;
+
+    r.length = slen;
+
+    for (i = 0; i < slen; i++)
+    {   wchar c = s[i];
+
+        if (c <= 0x7F)
+            r[i] = cast(char)c;         // fast path for ascii
+        else
+        {
+            r.length = i;
+            foreach (dchar c; s[i .. slen])
+            {
+                encode(r, c);
+            }
+            break;
+        }
+    }
+    return cast(string)r;
+}
+
+/** ditto */
+string toUTF8(in dchar[] s)
+{
+    char[] r;
+    size_t i;
+    size_t slen = s.length;
+
+    r.length = slen;
+
+    for (i = 0; i < slen; i++)
+    {   dchar c = s[i];
+
+        if (c <= 0x7F)
+            r[i] = cast(char)c;         // fast path for ascii
+        else
+        {
+            r.length = i;
+            foreach (dchar d; s[i .. slen])
+            {
+                encode(r, d);
+            }
+            break;
+        }
+    }
+    return cast(string)r;
+}
+
+/* =================== Conversion to UTF16 ======================= */
+
+wchar[] toUTF16(return out wchar[2] buf, dchar c)
+    in
+    {
+        assert(isValidDchar(c));
+    }
+    body
+    {
+        if (c <= 0xFFFF)
+        {
+            buf[0] = cast(wchar) c;
+            return buf[0 .. 1];
+        }
+        else
+        {
+            buf[0] = cast(wchar) ((((c - 0x10000) >> 10) & 0x3FF) + 0xD800);
+            buf[1] = cast(wchar) (((c - 0x10000) & 0x3FF) + 0xDC00);
+            return buf[0 .. 2];
+        }
+    }
+
+/****************
+ * Encodes string s into UTF-16 and returns the encoded string.
+ * toUTF16z() is suitable for calling the 'W' functions in the Win32 API that take
+ * an LPWSTR or LPCWSTR argument.
+ */
+wstring toUTF16(in char[] s)
+{
+    wchar[] r;
+    size_t slen = s.length;
+
+    r.length = slen;
+    r.length = 0;
+    for (size_t i = 0; i < slen; )
+    {
+        dchar c = s[i];
+        if (c <= 0x7F)
+        {
+            i++;
+            r ~= cast(wchar)c;
+        }
+        else
+        {
+            c = decode(s, i);
+            encode(r, c);
+        }
+    }
+    return cast(wstring)r;
+}
+
+alias const(wchar)* wptr;
+/** ditto */
+wptr toUTF16z(in char[] s)
+{
+    wchar[] r;
+    size_t slen = s.length;
+
+    r.length = slen + 1;
+    r.length = 0;
+    for (size_t i = 0; i < slen; )
+    {
+        dchar c = s[i];
+        if (c <= 0x7F)
+        {
+            i++;
+            r ~= cast(wchar)c;
+        }
+        else
+        {
+            c = decode(s, i);
+            encode(r, c);
+        }
+    }
+    r ~= '\000';
+    return r.ptr;
+}
+
+/** ditto */
+wstring toUTF16(wstring s)
+    in
+    {
+        validate(s);
+    }
+    body
+    {
+        return s;
+    }
+
+/** ditto */
+wstring toUTF16(in dchar[] s)
+{
+    wchar[] r;
+    size_t slen = s.length;
+
+    r.length = slen;
+    r.length = 0;
+    for (size_t i = 0; i < slen; i++)
+    {
+        encode(r, s[i]);
+    }
+    return cast(wstring)r;
+}
+
+/* =================== Conversion to UTF32 ======================= */
+
+/*****
+ * Encodes string s into UTF-32 and returns the encoded string.
+ */
+dstring toUTF32(in char[] s)
+{
+    dchar[] r;
+    size_t slen = s.length;
+    size_t j = 0;
+
+    r.length = slen;            // r[] will never be longer than s[]
+    for (size_t i = 0; i < slen; )
+    {
+        dchar c = s[i];
+        if (c >= 0x80)
+            c = decode(s, i);
+        else
+            i++;                // c is ascii, no need for decode
+        r[j++] = c;
+    }
+    return cast(dstring)r[0 .. j];
+}
+
+/** ditto */
+dstring toUTF32(in wchar[] s)
+{
+    dchar[] r;
+    size_t slen = s.length;
+    size_t j = 0;
+
+    r.length = slen;            // r[] will never be longer than s[]
+    for (size_t i = 0; i < slen; )
+    {
+        dchar c = s[i];
+        if (c >= 0x80)
+            c = decode(s, i);
+        else
+            i++;                // c is ascii, no need for decode
+        r[j++] = c;
+    }
+    return cast(dstring)r[0 .. j];
+}
+
+/** ditto */
+dstring toUTF32(dstring s)
+    in
+    {
+        validate(s);
+    }
+    body
+    {
+        return s;
+    }
+
+/* ================================ tests ================================== */
+
+unittest
+{
+    debug(utf) printf("utf.toUTF.unittest\n");
+
+    auto c = "hello"c[];
+    auto w = toUTF16(c);
+    assert(w == "hello");
+    auto d = toUTF32(c);
+    assert(d == "hello");
+
+    c = toUTF8(w);
+    assert(c == "hello");
+    d = toUTF32(w);
+    assert(d == "hello");
+
+    c = toUTF8(d);
+    assert(c == "hello");
+    w = toUTF16(d);
+    assert(w == "hello");
+
+
+    c = "hel\u1234o";
+    w = toUTF16(c);
+    assert(w == "hel\u1234o");
+    d = toUTF32(c);
+    assert(d == "hel\u1234o");
+
+    c = toUTF8(w);
+    assert(c == "hel\u1234o");
+    d = toUTF32(w);
+    assert(d == "hel\u1234o");
+
+    c = toUTF8(d);
+    assert(c == "hel\u1234o");
+    w = toUTF16(d);
+    assert(w == "hel\u1234o");
+
+
+    c = "he\U000BAAAAllo";
+    w = toUTF16(c);
+    //foreach (wchar c; w) printf("c = x%x\n", c);
+    //foreach (wchar c; cast(wstring)"he\U000BAAAAllo") printf("c = x%x\n", c);
+    assert(w == "he\U000BAAAAllo");
+    d = toUTF32(c);
+    assert(d == "he\U000BAAAAllo");
+
+    c = toUTF8(w);
+    assert(c == "he\U000BAAAAllo");
+    d = toUTF32(w);
+    assert(d == "he\U000BAAAAllo");
+
+    c = toUTF8(d);
+    assert(c == "he\U000BAAAAllo");
+    w = toUTF16(d);
+    assert(w == "he\U000BAAAAllo");
+
+    wchar[2] buf;
+    auto ret = toUTF16(buf, '\U000BAAAA');
+    assert(ret == "\U000BAAAA");
+}
diff --git a/libphobos/libdruntime/test_runner.d b/libphobos/libdruntime/test_runner.d
new file mode 100644
index 00000000000..909620de399
--- /dev/null
+++ b/libphobos/libdruntime/test_runner.d
@@ -0,0 +1,78 @@
+import core.runtime, core.time : MonoTime;
+import core.stdc.stdio;
+
+ModuleInfo* getModuleInfo(string name)
+{
+    foreach (m; ModuleInfo)
+        if (m.name == name) return m;
+    assert(0, "module '"~name~"' not found");
+}
+
+// Call this program for every compiled in module
+bool testAll()
+{
+    import core.stdc.stdlib, core.stdc.inttypes, core.stdc.string;
+    bool success = true;
+    uint num;
+    foreach (m; ModuleInfo)
+    {
+        num++;
+        string command = Runtime.args[0] ~ " " ~ m.name ~ "\0";
+        if (system(command.ptr) != EXIT_SUCCESS)
+            success = false;
+    }
+    printf(("%" ~ PRIu32[0 .. strlen(PRIu32)] ~ " modules tested\n\0").ptr, num);
+    return success;
+}
+
+bool tester()
+{
+    assert(Runtime.args.length == 2);
+    auto name = Runtime.args[1];
+    immutable pkg = ".package";
+    immutable pkgLen = pkg.length;
+
+    debug string mode = "debug";
+    else string mode =  "release";
+    static if ((void*).sizeof == 4) mode ~= "32";
+    else static if ((void*).sizeof == 8) mode ~= "64";
+    else static assert(0, "You must be from the future!");
+
+    if (name.length > pkgLen && name[$ - pkgLen .. $] == pkg)
+        name = name[0 .. $ - pkgLen];
+
+    if (auto fp = getModuleInfo(name).unitTest)
+    {
+        try
+        {
+            immutable t0 = MonoTime.currTime;
+            fp();
+            printf("%.3fs PASS %.*s %.*s\n",
+                (MonoTime.currTime - t0).total!"msecs" / 1000.0,
+                cast(uint)mode.length, mode.ptr,
+                cast(uint)name.length, name.ptr);
+        }
+        catch (Throwable e)
+        {
+            auto msg = e.toString();
+            printf("****** FAIL %.*s %.*s\n%.*s\n",
+                cast(uint)mode.length, mode.ptr,
+                cast(uint)name.length, name.ptr,
+                cast(uint)msg.length, msg.ptr);
+            return false;
+        }
+    }
+    return true;
+}
+
+shared static this()
+{
+    if (Runtime.args.length == 1)
+        Runtime.moduleUnitTester = &testAll;
+    else
+        Runtime.moduleUnitTester = &tester;
+}
+
+void main()
+{
+}
