Sync to trunk r38250
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 1 Jan 2009 13:32:17 +0000 (13:32 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 1 Jan 2009 13:32:17 +0000 (13:32 +0000)
svn path=/branches/ros-amd64-bringup/; revision=38496

19 files changed:
1  2 
reactos/dll/cpl/desk/desk.rbuild
reactos/dll/cpl/intl/intl.rbuild
reactos/dll/cpl/main/main.rbuild
reactos/dll/cpl/usrmgr/usrmgr.rbuild
reactos/dll/directx/ddraw/ddraw.rbuild
reactos/dll/win32/advapi32/sec/misc.c
reactos/dll/win32/gdi32/gdi32.rbuild
reactos/dll/win32/glu32/glu32.rbuild
reactos/dll/win32/kernel32/kernel32.rbuild
reactos/dll/win32/msvcrt/msvcrt.rbuild
reactos/dll/win32/opengl32/opengl32.rbuild
reactos/dll/win32/user32/user32.rbuild
reactos/include/crt/mingw32/intrin_x86.h
reactos/include/psdk/winbase.h
reactos/include/psdk/winnt.h
reactos/include/reactos/libs/pseh/pseh2.h
reactos/ntoskrnl/io/iomgr/iofunc.c
reactos/tools/rbuild/module.cpp
reactos/tools/widl/typegen.c

@@@ -1,7 -1,7 +1,7 @@@
  <?xml version="1.0"?>
  <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
- <module name="desk" type="win32dll" extension=".cpl" baseaddress="${BASEADDRESS_DESK}" installbase="system32" installname="desk.cpl" unicode="yes">
+ <module name="desk" type="win32dll" extension=".cpl" baseaddress="${BASEADDRESS_DESK}" installbase="system32" installname="desk.cpl" unicode="yes" crt="msvcrt">
 -      <importlibrary definition="desk.def" />
 +      <importlibrary definition="desk.spec" />
        <include base="desk">.</include>
        <define name="_WIN32" />
        <library>kernel32</library>
@@@ -1,24 -1,24 +1,24 @@@
  <?xml version="1.0"?>
  <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
- <module name="intl" type="win32dll" extension=".cpl" baseaddress="${BASEADDRESS_INTL}" installbase="system32" installname="intl.cpl" unicode="yes">
+ <module name="intl" type="win32dll" extension=".cpl" baseaddress="${BASEADDRESS_INTL}" installbase="system32" installname="intl.cpl" unicode="yes" crt="msvcrt">
 -    <importlibrary definition="intl.def" />
 -    <include base="intl">.</include>
 -    <library>kernel32</library>
 -    <library>user32</library>
 -    <library>comctl32</library>
 -    <library>advapi32</library>
 -    <library>setupapi</library>
 -    <library>shell32</library>
 -    <file>currency.c</file>
 -    <file>date.c</file>
 -    <file>generalp.c</file>
 -    <file>intl.c</file>
 -    <file>inplocale.c</file>
 -    <file>numbers.c</file>
 -    <file>time.c</file>
 -    <file>misc.c</file>
 -    <file>languages.c</file>
 -    <file>advanced.c</file>
 -    <file>sort.c</file>
 -    <file>intl.rc</file>
 +      <importlibrary definition="intl.spec" />
 +      <include base="intl">.</include>
 +      <library>kernel32</library>
 +      <library>user32</library>
 +      <library>comctl32</library>
 +      <library>advapi32</library>
 +      <library>setupapi</library>
 +      <library>shell32</library>
 +      <file>currency.c</file>
 +      <file>date.c</file>
 +      <file>generalp.c</file>
 +      <file>intl.c</file>
 +      <file>inplocale.c</file>
 +      <file>numbers.c</file>
 +      <file>time.c</file>
 +      <file>misc.c</file>
 +      <file>languages.c</file>
 +      <file>advanced.c</file>
 +      <file>sort.c</file>
 +      <file>intl.rc</file>
  </module>
@@@ -1,7 -1,7 +1,7 @@@
  <?xml version="1.0"?>
  <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
- <module name="main" type="win32dll" extension=".cpl" baseaddress="${BASEADDRESS_MAIN}" installbase="system32" installname="main.cpl" unicode="yes">
+ <module name="main" type="win32dll" extension=".cpl" baseaddress="${BASEADDRESS_MAIN}" installbase="system32" installname="main.cpl" unicode="yes" crt="msvcrt">
 -      <importlibrary definition="main.def" />
 +      <importlibrary definition="main.spec" />
        <include base="main">.</include>
        <library>kernel32</library>
        <library>advapi32</library>
@@@ -1,7 -1,7 +1,7 @@@
  <?xml version="1.0"?>
  <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
- <module name="usrmgr" type="win32dll" extension=".cpl" baseaddress="${BASEADDRESS_USRMGR}" installbase="system32" installname="usrmgr.cpl" unicode="yes">
+ <module name="usrmgr" type="win32dll" extension=".cpl" baseaddress="${BASEADDRESS_USRMGR}" installbase="system32" installname="usrmgr.cpl" unicode="yes" crt="msvcrt">
 -      <importlibrary definition="usrmgr.def" />
 +      <importlibrary definition="usrmgr.spec" />
        <include base="usrmgr">.</include>
        <library>kernel32</library>
        <library>advapi32</library>
@@@ -1,7 -1,7 +1,7 @@@
  <?xml version="1.0"?>
  <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
- <module name="ddraw" type="win32dll" installbase="system32" installname="ddraw.dll" allowwarnings ="true" unicode="yes">
+ <module name="ddraw" type="win32dll" installbase="system32" installname="ddraw.dll" allowwarnings ="true" unicode="yes" crt="msvcrt">
 -      <importlibrary definition="ddraw.def" />
 +      <importlibrary definition="ddraw.spec" />
        <include base="ddraw">.</include>
        <library>kernel32</library>
        <library>user32</library>
@@@ -289,7 -289,7 +289,7 @@@ CheckNtMartaPresent(VOID
  {
      DWORD ErrorCode;
  
 -    if (InterlockedCompareExchangePointer(&NtMarta,
 +    if (InterlockedCompareExchangePointer((PVOID)&NtMarta,
                                            NULL,
                                            NULL) == NULL)
      {
          if (ErrorCode == ERROR_SUCCESS)
          {
              /* try change the NtMarta pointer */
 -            if (InterlockedCompareExchangePointer(&NtMarta,
 +            if (InterlockedCompareExchangePointer((PVOID)&NtMarta,
                                                    &NtMartaStatic,
                                                    NULL) != NULL)
              {
  VOID
  UnloadNtMarta(VOID)
  {
 -    if (InterlockedExchangePointer(&NtMarta,
 +    if (InterlockedExchangePointer((PVOID)&NtMarta,
                                     NULL) != NULL)
      {
          FreeLibrary(NtMartaStatic.hDllInstance);
@@@ -1461,7 -1461,7 +1461,7 @@@ LookupPrivilegeValueW(LPCWSTR SystemNam
  
    for (Priv = 0; Priv < sizeof(DefaultPrivNames) / sizeof(DefaultPrivNames[0]); Priv++)
      {
-       if (0 == wcsicmp(PrivName, DefaultPrivNames[Priv]))
+       if (0 == _wcsicmp(PrivName, DefaultPrivNames[Priv]))
          {
            Luid->LowPart = Priv + SE_MIN_WELL_KNOWN_PRIVILEGE;
            Luid->HighPart = 0;
@@@ -1,5 -1,5 +1,5 @@@
- <module name="gdi32" type="win32dll" baseaddress="${BASEADDRESS_GDI32}" installbase="system32" installname="gdi32.dll" unicode="yes" allowwarnings="true">
 -<module name="gdi32" type="win32dll" baseaddress="${BASEADDRESS_GDI32}" installbase="system32" installname="gdi32.dll" unicode="yes" crt="dll">
 -      <importlibrary definition="gdi32.def" />
++<module name="gdi32" type="win32dll" baseaddress="${BASEADDRESS_GDI32}" installbase="system32" installname="gdi32.dll" unicode="yes" crt="dll" allowwarnings="true">
 +      <importlibrary definition="gdi32.spec" />
        <include base="gdi32">include</include>
        <define name="_DISABLE_TIDENTS" />
        <define name="LANGPACK" />
@@@ -10,6 -10,7 +10,6 @@@
        <library>pseh</library>
        <library>dxguid</library>
        <library>ntdll</library>
 -
        <!-- See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38269
        <directory name="include">
                <pch>precomp.h</pch>
@@@ -1,5 -1,5 +1,5 @@@
- <module name="glu32" type="win32dll" entrypoint="0" baseaddress="${BASEADDRESS_GLU32}" installbase="system32" installname="glu32.dll" allowwarnings="true">
+ <module name="glu32" type="win32dll" entrypoint="0" baseaddress="${BASEADDRESS_GLU32}" installbase="system32" installname="glu32.dll" allowwarnings="true" crt="msvcrt">
 -      <importlibrary definition="glu32.def" />
 +      <importlibrary definition="glu32.spec" />
        <include base="glu32">include</include>
        <include base="glu32">libnurbs/internals</include>
        <include base="glu32">libnurbs/interface</include>
@@@ -1,7 -1,7 +1,7 @@@
  <?xml version="1.0"?>
  <!DOCTYPE group SYSTEM "../../../tools/rbuild/project.dtd">
  <group>
-       <module name="kernel32_base" type="objectlibrary" allowwarnings="true">
 -      <module name="kernel32_base" type="objectlibrary" crt="dll">
++      <module name="kernel32_base" type="objectlibrary" crt="dll" allowwarnings="true">
                <include base="kernel32_base">.</include>
                <include base="kernel32_base">include</include>
                <include base="ReactOS">include/reactos/subsys</include>
                                        <file>thread.S</file>
                                </directory>
                        </if>
 +                      <if property="ARCH" value="amd64">
 +                              <directory name="amd64">
 +                                      <file>fiber.S</file>
 +                                      <file>thread.S</file>
 +                              </directory>
 +                      </if>
                </directory>
  
                <compilerflag compiler="cpp">-fno-exceptions</compilerflag>
                </directory>
                <library>normalize</library>
        </module>
-       <module name="kernel32" type="win32dll" baseaddress="${BASEADDRESS_KERNEL32}" installbase="system32" installname="kernel32.dll">
+       <module name="kernel32" type="win32dll" baseaddress="${BASEADDRESS_KERNEL32}" installbase="system32" installname="kernel32.dll" crt="dll">
 -              <importlibrary definition="kernel32.def" />
 +              <importlibrary definition="kernel32.spec" />
                <include base="kernel32">.</include>
                <include base="kernel32" root="intermediate">.</include>
                <include base="kernel32">include</include>
@@@ -1,5 -1,5 +1,5 @@@
  <module name="msvcrt" type="win32dll" baseaddress="${BASEADDRESS_MSVCRT}" mangledsymbols="true" installbase="system32" installname="msvcrt.dll" iscrt="yes">
 -      <importlibrary definition="msvcrt.def" />
 +      <importlibrary definition="msvcrt-$(ARCH).def" />
        <include base="msvcrt">.</include>
        <include base="crt">include</include>
        <define name="_DISABLE_TIDENTS" />
@@@ -20,6 -20,7 +20,7 @@@
        <library>wine</library>
        <library>kernel32</library>
        <library>ntdll</library>
+       <library>pseh</library>
        <pch>precomp.h</pch>
        <file>dllmain.c</file>
        <file>msvcrt.rc</file>
@@@ -1,5 -1,5 +1,5 @@@
- <module name="opengl32" type="win32dll" baseaddress="${BASEADDRESS_OPENGL32}" installbase="system32" installname="opengl32.dll" unicode="yes">
+ <module name="opengl32" type="win32dll" baseaddress="${BASEADDRESS_OPENGL32}" installbase="system32" installname="opengl32.dll" unicode="yes" crt="msvcrt">
 -      <importlibrary definition="opengl32.def" />
 +      <importlibrary definition="opengl32.spec" />
        <define name="_DISABLE_TIDENTS" />
        <library>ntdll</library>
        <library>kernel32</library>
@@@ -1,5 -1,5 +1,5 @@@
- <module name="user32" type="win32dll" baseaddress="${BASEADDRESS_USER32}" installbase="system32" installname="user32.dll" unicode="yes" allowwarnings="true">
 -<module name="user32" type="win32dll" baseaddress="${BASEADDRESS_USER32}" installbase="system32" installname="user32.dll" unicode="yes" crt="dll">
 -      <importlibrary definition="user32.def" />
++<module name="user32" type="win32dll" baseaddress="${BASEADDRESS_USER32}" installbase="system32" installname="user32.dll" unicode="yes" crt="dll" allowwarnings="true">
 +      <importlibrary definition="user32.pspec" />
        <include base="user32">.</include>
        <include base="user32">include</include>
        <include base="ReactOS">include/reactos/subsys</include>
        would use in the same case
  */
  
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
  /*** Stack frame juggling ***/
  #define _ReturnAddress() (__builtin_return_address(0))
  #define _AddressOfReturnAddress() (&(((void **)(__builtin_frame_address(0)))[1]))
  /* TODO: __getcallerseflags but how??? */
  
 +/* Maybe the same for x86? */
 +#ifdef _x86_64
 +#define _alloca(s) __builtin_alloca(s)
 +#endif
  
  /*** Atomic operations ***/
  
@@@ -823,14 -823,14 +827,14 @@@ static __inline__ __attribute__((always
        return retval;
  }
  
- static __inline__ __attribute__((always_inline)) unsigned char _rotl8(const unsigned char value, const unsigned char shift)
+ static __inline__ __attribute__((always_inline)) unsigned char _rotl8(unsigned char value, unsigned char shift)
  {
        unsigned char retval;
        __asm__("rolb %b[shift], %b[retval]" : [retval] "=rm" (retval) : "[retval]" (value), [shift] "Nc" (shift));
        return retval;
  }
  
- static __inline__ __attribute__((always_inline)) unsigned short _rotl16(const unsigned short value, const unsigned char shift)
+ static __inline__ __attribute__((always_inline)) unsigned short _rotl16(unsigned short value, unsigned char shift)
  {
        unsigned short retval;
        __asm__("rolw %b[shift], %w[retval]" : [retval] "=rm" (retval) : "[retval]" (value), [shift] "Nc" (shift));
  }
  
  #ifndef __MSVCRT__
- static __inline__ __attribute__((always_inline)) unsigned int _rotl(const unsigned int value, const int shift)
+ static __inline__ __attribute__((always_inline)) unsigned int _rotl(unsigned int value, int shift)
  {
        unsigned long retval;
        __asm__("roll %b[shift], %k[retval]" : [retval] "=rm" (retval) : "[retval]" (value), [shift] "Nc" (shift));
        return retval;
  }
  
- static __inline__ __attribute__((always_inline)) unsigned long _rotr(const unsigned int value, const unsigned char shift)
+ static __inline__ __attribute__((always_inline)) unsigned int _rotr(unsigned int value, int shift)
  {
        unsigned long retval;
        __asm__("rorl %b[shift], %k[retval]" : [retval] "=rm" (retval) : "[retval]" (value), [shift] "Nc" (shift));
  }
  #endif
  
- static __inline__ __attribute__((always_inline)) unsigned char _rotr8(const unsigned char value, const unsigned char shift)
+ static __inline__ __attribute__((always_inline)) unsigned char _rotr8(unsigned char value, unsigned char shift)
  {
        unsigned char retval;
        __asm__("rorb %b[shift], %b[retval]" : [retval] "=rm" (retval) : "[retval]" (value), [shift] "Nc" (shift));
        return retval;
  }
  
- static __inline__ __attribute__((always_inline)) unsigned short _rotr16(const unsigned short value, const unsigned char shift)
+ static __inline__ __attribute__((always_inline)) unsigned short _rotr16(unsigned short value, unsigned char shift)
  {
        unsigned short retval;
        __asm__("rorw %b[shift], %w[retval]" : [retval] "=rm" (retval) : "[retval]" (value), [shift] "Nc" (shift));
@@@ -1296,6 -1296,10 +1300,10 @@@ static __inline__ __attribute__((always
        __asm__ __volatile__("sidt %0" : : "m"(*(short*)Destination) : "memory");
  }
  
+ #ifdef __cplusplus
+ }
+ #endif
  #endif /* KJK_INTRIN_X86_H_ */
  
  /* EOF */
@@@ -785,11 -785,7 +785,11 @@@ typedef struct _CRITICAL_SECTION_DEBUG 
        LIST_ENTRY ProcessLocksList;
        DWORD EntryCount;
        DWORD ContentionCount;
 -      DWORD Spare [2];
 +//#ifdef __WINESRC__ //not all wine code is marked so
 +      DWORD_PTR Spare[8/sizeof(DWORD_PTR)];/* in Wine they store a string here */
 +//#else
 +      //WORD SpareWORD;
 +//#endif
  } CRITICAL_SECTION_DEBUG,*PCRITICAL_SECTION_DEBUG;
  typedef struct _CRITICAL_SECTION {
        PCRITICAL_SECTION_DEBUG DebugInfo;
@@@ -911,7 -907,7 +911,7 @@@ typedef struct _SYSTEM_INFO 
        DWORD dwPageSize;
        PVOID lpMinimumApplicationAddress;
        PVOID lpMaximumApplicationAddress;
 -      DWORD dwActiveProcessorMask;
 +      DWORD_PTR dwActiveProcessorMask;
        DWORD dwNumberOfProcessors;
        DWORD dwProcessorType;
        DWORD dwAllocationGranularity;
@@@ -1050,6 -1046,11 +1050,11 @@@ typedef struct tagACTCTX_SECTION_KEYED_
        HANDLE ulAssemblyRosterIndex;
  } ACTCTX_SECTION_KEYED_DATA,*PACTCTX_SECTION_KEYED_DATA;
  typedef const ACTCTX_SECTION_KEYED_DATA *PCACTCTX_SECTION_KEYED_DATA;
+ typedef struct _ACTIVATION_CONTEXT_BASIC_INFORMATION {
+       HANDLE hActCtx;
+       DWORD  dwFlags;
+ } ACTIVATION_CONTEXT_BASIC_INFORMATION, *PACTIVATION_CONTEXT_BASIC_INFORMATION;
+ typedef const struct _ACTIVATION_CONTEXT_BASIC_INFORMATION *PCACTIVATION_CONTEXT_BASIC_INFORMATION;
  typedef enum {
        LowMemoryResourceNotification ,
        HighMemoryResourceNotification
@@@ -1528,7 -1529,7 +1533,7 @@@ DWORD WINAPI GetPrivateProfileStringW(L
  BOOL WINAPI GetPrivateProfileStructA(LPCSTR,LPCSTR,LPVOID,UINT,LPCSTR);
  BOOL WINAPI GetPrivateProfileStructW(LPCWSTR,LPCWSTR,LPVOID,UINT,LPCWSTR);
  FARPROC WINAPI GetProcAddress(HINSTANCE,LPCSTR);
 -BOOL WINAPI GetProcessAffinityMask(HANDLE,PDWORD,PDWORD);
 +BOOL WINAPI GetProcessAffinityMask(HANDLE,PDWORD_PTR,PDWORD_PTR);
  #if (_WIN32_WINNT >= 0x0502)
  BOOL WINAPI GetProcessHandleCount(HANDLE,PDWORD);
  #endif
@@@ -1659,7 -1660,7 +1664,7 @@@ BOOL WINAPI GlobalUnlock(HGLOBAL)
  BOOL WINAPI GlobalUnWire(HGLOBAL); /* Obsolete: Has no effect. */
  PVOID WINAPI GlobalWire(HGLOBAL); /* Obsolete: Has no effect. */
  #define HasOverlappedIoCompleted(lpOverlapped)  ((lpOverlapped)->Internal != STATUS_PENDING)
 -PVOID WINAPI HeapAlloc(HANDLE,DWORD,DWORD);
 +PVOID WINAPI HeapAlloc(HANDLE,DWORD,SIZE_T);
  SIZE_T WINAPI HeapCompact(HANDLE,DWORD);
  HANDLE WINAPI HeapCreate(DWORD,DWORD,DWORD);
  BOOL WINAPI HeapDestroy(HANDLE);
@@@ -1965,7 -1966,7 +1970,7 @@@ BOOL WINAPI ReadEventLogW(HANDLE,DWORD,
  BOOL WINAPI ReadFile(HANDLE,PVOID,DWORD,PDWORD,LPOVERLAPPED);
  BOOL WINAPI ReadFileEx(HANDLE,PVOID,DWORD,LPOVERLAPPED,LPOVERLAPPED_COMPLETION_ROUTINE);
  BOOL WINAPI ReadFileScatter(HANDLE,FILE_SEGMENT_ELEMENT*,DWORD,LPDWORD,LPOVERLAPPED);
 -BOOL WINAPI ReadProcessMemory(HANDLE,PCVOID,PVOID,DWORD,PDWORD);
 +BOOL WINAPI ReadProcessMemory(HANDLE,PCVOID,PVOID,SIZE_T,SIZE_T*);
  #if (_WIN32_WINNT >= 0x0600)
  VOID WINAPI RecoveryFinished(BOOL);
  HRESULT WINAPI RecoveryInProgress(OUT PBOOL);
@@@ -2069,7 -2070,7 +2074,7 @@@ BOOL WINAPI SetMailslotInfo(HANDLE,DWOR
  BOOL WINAPI SetNamedPipeHandleState(HANDLE,PDWORD,PDWORD,PDWORD);
  BOOL WINAPI SetPriorityClass(HANDLE,DWORD);
  BOOL WINAPI SetPrivateObjectSecurity(SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,PSECURITY_DESCRIPTOR *,PGENERIC_MAPPING,HANDLE);
 -BOOL WINAPI SetProcessAffinityMask(HANDLE,DWORD);
 +BOOL WINAPI SetProcessAffinityMask(HANDLE,DWORD_PTR);
  BOOL WINAPI SetProcessPriorityBoost(HANDLE,BOOL);
  BOOL WINAPI SetProcessShutdownParameters(DWORD,DWORD);
  BOOL WINAPI SetProcessWorkingSetSize(HANDLE,SIZE_T,SIZE_T);
@@@ -53,7 -53,6 +53,7 @@@ extern "C" 
  #ifdef _X86_
  #define UNALIGNED
  #else
 +#undef UNALIGNED
  #define UNALIGNED
  #endif
  
@@@ -181,7 -180,9 +181,9 @@@ typedef PDWORD PLCID
  typedef WORD LANGID;
  #ifdef __GNUC__
  #define _HAVE_INT64
- #define _INTEGRAL_MAX_BITS 64
+ #ifndef _INTEGRAL_MAX_BITS
+ # define _INTEGRAL_MAX_BITS 64
+ #endif
  #undef __int64
  #define __int64 long long
  #elif defined(__WATCOMC__) && (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 64 )
@@@ -1236,6 -1237,7 +1238,7 @@@ typedef enu
  #define SECTION_QUERY 1
  #define SECTION_MAP_EXECUTE 8
  #define SECTION_ALL_ACCESS 0xf001f
+ #define WRITE_WATCH_FLAG_RESET 0x01
  #ifndef __NTDDK_H
  #define MESSAGE_RESOURCE_UNICODE 1
  #endif
  #define IMAGE_REL_BASED_HIGHLOW 3
  #define IMAGE_REL_BASED_HIGHADJ 4
  #define IMAGE_REL_BASED_MIPS_JMPADDR 5
 +#define IMAGE_REL_BASED_MIPS_JMPADDR16 9
 +#define IMAGE_REL_BASED_IA64_IMM64 9
 +#define IMAGE_REL_BASED_DIR64 10
  #define IMAGE_ARCHIVE_START_SIZE 8
  #define IMAGE_ARCHIVE_START "!<arch>\n"
  #define IMAGE_ARCHIVE_END "`\n"
@@@ -2288,33 -2287,16 +2291,33 @@@ typedef struct _KNONVOLATILE_CONTEXT_PO
  
  #define RUNTIME_FUNCTION_INDIRECT 0x1
  
 -  typedef struct _RUNTIME_FUNCTION {
 +typedef struct _RUNTIME_FUNCTION {
      DWORD BeginAddress;
      DWORD EndAddress;
      DWORD UnwindData;
 -  } RUNTIME_FUNCTION,*PRUNTIME_FUNCTION;
 +} RUNTIME_FUNCTION,*PRUNTIME_FUNCTION;
  
 -  typedef PRUNTIME_FUNCTION (*PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD64 ControlPc,PVOID Context);
 -  typedef DWORD (*POUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK)(HANDLE Process,PVOID TableAddress,PDWORD Entries,PRUNTIME_FUNCTION *Functions);
 +#define UNWIND_HISTORY_TABLE_SIZE 12
  
 -  #define OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME "OutOfProcessFunctionTableCallback"
 +typedef struct _UNWIND_HISTORY_TABLE_ENTRY
 +{
 +    ULONG64 ImageBase;
 +    PRUNTIME_FUNCTION FunctionEntry;
 +} UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
 +
 +typedef struct _UNWIND_HISTORY_TABLE
 +{
 +    ULONG Count;
 +    UCHAR Search;
 +    ULONG64 LowAddress;
 +    ULONG64 HighAddress;
 +    UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
 +} UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
 +
 +typedef PRUNTIME_FUNCTION (*PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD64 ControlPc,PVOID Context);
 +typedef DWORD (*POUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK)(HANDLE Process,PVOID TableAddress,PDWORD Entries,PRUNTIME_FUNCTION *Functions);
 +
 +#define OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME "OutOfProcessFunctionTableCallback"
  
  NTSYSAPI
  VOID
@@@ -4660,11 -4642,7 +4663,11 @@@ static __inline__ PVOID GetCurrentFiber
  #elif defined (_M_AMD64)
  FORCEINLINE PVOID GetCurrentFiber(VOID)
  {
 +  #ifdef NONAMELESSUNION
 +    return (PVOID)__readgsqword(FIELD_OFFSET(NT_TIB, DUMMYUNIONNAME.FiberData));
 +  #else
      return (PVOID)__readgsqword(FIELD_OFFSET(NT_TIB, FiberData));
 +  #endif
  }
  #elif defined (_M_ARM)
      PVOID WINAPI GetCurrentFiber(VOID);
@@@ -4860,7 -4838,7 +4863,7 @@@ MemoryBarrier(VOID
  }
  #endif
  #elif defined (_M_AMD64)
 -#define MemoryBarrier()
 +#define MemoryBarrier __faststorefence
  #elif defined(_M_PPC)
  #define MemoryBarrier()
  #elif defined(_M_ARM)
@@@ -19,9 -19,6 +19,9 @@@
        FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
        DEALINGS IN THE SOFTWARE.
  */
 +#ifdef _M_AMD64
 +#include "pseh2_64.h"
 +#else
  
  #ifndef KJK_PSEH2_H_
  #define KJK_PSEH2_H_
@@@ -69,7 -66,7 +69,7 @@@ extern "C
  {
  #endif
  
- extern void __cdecl _SEH2EnterFrame(_SEH2Frame_t *);
+ extern __attribute__((returns_twice)) void __cdecl _SEH2EnterFrame(_SEH2Frame_t *);
  extern void __cdecl _SEH2LeaveFrame(void);
  extern void __cdecl _SEH2Return(void);
  
@@@ -134,23 -131,12 +134,12 @@@ void * _SEHClosureFromTrampoline(_SEHTr
  /* GCC doesn't know that this equals zero */
  #define __SEH_VOLATILE_ZERO ({ int zero = 0; __asm__ __volatile__("#" : "+g" (zero)); zero; })
  
- /* GCC believes this is setjmp */
- #define __SEH_PRETEND_SETJMP() (_SEH2PretendSetjmp(), 0)
  #define __SEH_VOLATILE_FALSE __builtin_expect(__SEH_VOLATILE_ZERO, 0)
  #define __SEH_VOLATILE_TRUE  __builtin_expect(!__SEH_VOLATILE_ZERO, 1)
  
  #define ___SEH_STRINGIFY(X_) # X_
  #define __SEH_STRINGIFY(X_) ___SEH_STRINGIFY(X_)
  
- static
- __inline__
- __attribute__((returns_twice))
- __attribute__((always_inline))
- void _SEH2PretendSetjmp(void)
- {
- }
  #define __SEH_FORCE_NEST \
        __asm__ __volatile__("#%0" : : "r" (&_SEHFrame))
  
  #define __SEH_RETURN_FINALLY() return
  
  #define __SEH_BEGIN_TRY \
-       if(!__SEH_PRETEND_SETJMP()) \
        { \
                __label__ _SEHEndTry; \
   \
@@@ -412,5 -397,4 +400,5 @@@ __SEH_END_SCOPE_CHAIN
  
  #endif
  
 +#endif
  /* EOF */
@@@ -428,7 -428,7 +428,7 @@@ IopDeviceFsIoControl(IN HANDLE DeviceHa
              _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
              {
                  /* Cleanup after exception */
-                 IopCleanupAfterException(FileObject, Irp, Event, NULL);
+                 IopCleanupAfterException(FileObject, Irp, EventObject, NULL);
                  Status = _SEH2_GetExceptionCode();
              }
              _SEH2_END;
              _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
              {
                  /* Cleanup after exception */
-                 IopCleanupAfterException(FileObject, Irp, Event, NULL);
+                 IopCleanupAfterException(FileObject, Irp, EventObject, NULL);
                  Status = _SEH2_GetExceptionCode();
              }
              _SEH2_END;
@@@ -2107,7 -2107,7 +2107,7 @@@ NtReadFile(IN HANDLE FileHandle
              _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
              {
                  /* Allocating failed, clean up */
-                 IopCleanupAfterException(FileObject, Irp, NULL, Event);
+                 IopCleanupAfterException(FileObject, Irp, EventObject, NULL);
                  Status = _SEH2_GetExceptionCode();
              }
              _SEH2_END;
              _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
              {
                  /* Allocating failed, clean up */
-                 IopCleanupAfterException(FileObject, Irp, Event, NULL);
+                 IopCleanupAfterException(FileObject, Irp, EventObject, NULL);
                  Status = _SEH2_GetExceptionCode();
                  _SEH2_YIELD(return Status);
              }
@@@ -2451,7 -2451,7 +2451,7 @@@ NtSetInformationFile(IN HANDLE FileHand
                      /* Set the Data */
                      Context->Key = CompletionInfo->Key;
                      Context->Port = Queue;
 -                    if (InterlockedCompareExchangePointer(&FileObject->
 +                    if (InterlockedCompareExchangePointer((PVOID*)&FileObject->
                                                            CompletionContext,
                                                            Context,
                                                            NULL))
@@@ -2971,7 -2971,7 +2971,7 @@@ NtWriteFile(IN HANDLE FileHandle
              _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
              {
                  /* Allocating failed, clean up */
-                 IopCleanupAfterException(FileObject, Irp, Event, NULL);
+                 IopCleanupAfterException(FileObject, Irp, EventObject, NULL);
                  Status = _SEH2_GetExceptionCode();
                  _SEH2_YIELD(return Status);
              }
              _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
              {
                  /* Allocating failed, clean up */
-                 IopCleanupAfterException(FileObject, Irp, Event, NULL);
+                 IopCleanupAfterException(FileObject, Irp, EventObject, NULL);
                  Status = _SEH2_GetExceptionCode();
                  _SEH2_YIELD(return Status);
              }
@@@ -1185,7 -1185,7 +1185,7 @@@ Module::GetDefaultModuleCRT () cons
                        return "static";
                case Win32DLL:
                case Win32OCX:
-                       return "msvcrt";
+                       return "ntdll";
                case NativeDLL:
                case NativeCUI:
                        return "ntdll";
@@@ -1323,14 -1323,6 +1323,14 @@@ Module::GetEntryPoint(bool leadingUnder
                result = "_";
  
        result += entrypoint;
 +
 +      if (Environment::GetArch() == "amd64")
 +      {
 +              size_t at_index = result.find_last_of( '@' );
 +              if ( at_index != result.npos )
 +                      return result.substr (0, at_index );
 +      }
 +
        return result;
  }
  
@@@ -823,7 -823,13 +823,13 @@@ size_t type_memsize(const type_t *t, un
      }
      else if (is_ptr(t) || is_conformant_array(t))
      {
-         size = sizeof(void *);
+ #if defined(TARGET_i386)
+         size = 4;
+ #elif defined(TARGET_amd64)
+         size = 8;
+ #else
+ #error Unsupported CPU
+ #endif
          if (size > *align) *align = size;
      }
      else switch (t->type)
@@@ -2728,8 -2734,8 +2734,8 @@@ void print_phase_basetype(FILE *file, i
      }
  
      if (phase == PHASE_MARSHAL)
 -        print_file(file, indent, "MIDL_memset(_StubMsg.Buffer, 0, (0x%x - (long)_StubMsg.Buffer) & 0x%x);\n", alignment, alignment - 1);
 -    print_file(file, indent, "_StubMsg.Buffer = (unsigned char *)(((long)_StubMsg.Buffer + %u) & ~0x%x);\n",
 +        print_file(file, indent, "MIDL_memset(_StubMsg.Buffer, 0, (0x%x - (size_t)_StubMsg.Buffer) & 0x%x);\n", alignment, alignment - 1);
 +    print_file(file, indent, "_StubMsg.Buffer = (unsigned char *)(((size_t)_StubMsg.Buffer + %u) & ~0x%x);\n",
                  alignment - 1, alignment - 1);
  
      if (phase == PHASE_MARSHAL)