Index: crt/crtdefs.h
===================================================================
--- crt/crtdefs.h	(revision 47065)
+++ crt/crtdefs.h	(working copy)
@@ -345,19 +345,17 @@
 #endif
 #endif
 
-  struct threadlocaleinfostruct;
-  typedef struct threadlocaleinfostruct *pthreadlocinfo;
+  typedef struct threadmbcinfostruct {
+    int refcount;
+    int mbcodepage;
+    int ismbcodepage;
+    int mblcid;
+    unsigned short mbulinfo[6];
+    char mbctype[257];
+    char mbcasemap[256];
+} threadmbcinfo, *pthreadmbcinfo;
 
-  struct threadmbcinfostruct;
-  typedef struct threadmbcinfostruct *pthreadmbcinfo;
 
-  struct __lc_time_data;
-
-  typedef struct localeinfo_struct {
-    pthreadlocinfo locinfo;
-    pthreadmbcinfo mbcinfo;
-  } _locale_tstruct,*_locale_t;
-
 #ifndef _TAGLC_ID_DEFINED
 #define _TAGLC_ID_DEFINED
   typedef struct tagLC_ID {
@@ -393,10 +391,16 @@
     const unsigned char *pclmap;
     const unsigned char *pcumap;
     struct __lc_time_data *lc_time_curr;
-  } threadlocinfo;
+  } threadlocinfo, *pthreadlocinfo;
 #endif
 
+struct __lc_time_data;
 
+typedef struct localeinfo_struct {
+    pthreadlocinfo locinfo;
+    pthreadmbcinfo mbcinfo;
+}_locale_tstruct,*_locale_t;
+
 #ifdef __cplusplus
 }
 #endif
Index: crt/stdlib.h
===================================================================
--- crt/stdlib.h	(revision 47065)
+++ crt/stdlib.h	(working copy)
@@ -136,6 +136,8 @@
   typedef void (__cdecl *_invalid_parameter_handler)(const wchar_t *,const wchar_t *,const wchar_t *,unsigned int,uintptr_t);
   _invalid_parameter_handler __cdecl _set_invalid_parameter_handler(_invalid_parameter_handler _Handler);
   _invalid_parameter_handler __cdecl _get_invalid_parameter_handler(void);
+  void __cdecl _invalid_parameter(const wchar_t *expr, const wchar_t *func, const wchar_t *file,
+                                 unsigned int line, uintptr_t arg);
 
 #ifndef _CRT_ERRNO_DEFINED
 #define _CRT_ERRNO_DEFINED
Index: crt/wchar.h
===================================================================
--- crt/wchar.h	(revision 47065)
+++ crt/wchar.h	(working copy)
@@ -812,5 +812,5 @@
 
 #pragma pack(pop)
 
-//#include <sec_api/wchar_s.h>
+#include <sec_api/wchar_s.h>
 #endif
Index: psdk/ntstatus.h
===================================================================
--- psdk/ntstatus.h	(revision 47065)
+++ psdk/ntstatus.h	(working copy)
@@ -938,6 +938,7 @@
 #define STATUS_AUTHENTICATION_FIREWALL_FAILED   ((NTSTATUS)0xC0000413)
 #define STATUS_VDM_DISALLOWED                   ((NTSTATUS)0xC0000414)
 #define STATUS_HUNG_DISPLAY_DRIVER_THREAD       ((NTSTATUS)0xC0000415)
+#define STATUS_INVALID_CRUNTIME_PARAMETER       ((NTSTATUS)0xC0000417)
 #define STATUS_ASSERTION_FAILURE                ((NTSTATUS)0xC0000420L)
 #define STATUS_CALLBACK_POP_STACK               ((NTSTATUS)0xC0000423)
 #define STATUS_WOW_ASSERTION                    ((NTSTATUS)0xC0009898)
Index: reactos/wine/config.h
===================================================================
--- reactos/wine/config.h	(revision 47065)
+++ reactos/wine/config.h	(working copy)
@@ -982,7 +982,11 @@
 #define __ASM_CFI(str) str
 
 /* Define to a macro to define an assembly function */
+#ifndef NO_UNDERSCORE_PREFIX
 #define __ASM_DEFINE_FUNC(name,suffix,code) asm(".text\n\t.align 4\n\t.globl _" #name suffix "\n\t.def _" #name suffix "; .scl 2; .type 32; .endef\n_" #name suffix ":\n\t.cfi_startproc\n\t" code "\n\t.cfi_endproc");
+#else
+#define __ASM_DEFINE_FUNC(name,suffix,code) asm(".text\n\t.align 4\n\t.globl " #name suffix "\n\t.def " #name suffix "; .scl 2; .type 32; .endef\n" #name suffix ":\n\t.cfi_startproc\n\t" code "\n\t.cfi_endproc");
+#endif
 
 /* Define to a macro to generate an assembly function directive */
 #define __ASM_FUNC(name) ".def " __ASM_NAME(name) "; .scl 2; .type 32; .endef"
@@ -992,7 +996,11 @@
 #define __ASM_GLOBAL_FUNC(name,code) __ASM_DEFINE_FUNC(name,"",code)
 
 /* Define to a macro to generate an assembly name from a C symbol */
+#ifndef NO_UNDERSCORE_PREFIX
 #define __ASM_NAME(name) "_" name
+#else
+#define __ASM_NAME(name) name
+#endif
 
 /* Define to a macro to generate an stdcall suffix */
 #define __ASM_STDCALL(args) "@" #args
Index: reactos/wine/exception.h
===================================================================
--- reactos/wine/exception.h	(revision 47065)
+++ reactos/wine/exception.h	(working copy)
@@ -9,6 +9,21 @@
 extern "C" {
 #endif
 
+/* Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD */
+#define EH_NONCONTINUABLE   0x01
+#define EH_UNWINDING        0x02
+#define EH_EXIT_UNWIND      0x04
+#define EH_STACK_INVALID    0x08
+#define EH_NESTED_CALL      0x10
+
+#define EXCEPTION_WINE_STUB       0x80000100
+#define EXCEPTION_WINE_ASSERTION  0x80000101
+
+#define EXCEPTION_VM86_INTx       0x80000110
+#define EXCEPTION_VM86_STI        0x80000111
+#define EXCEPTION_VM86_PICRETURN  0x80000112
+
+#ifndef _RTLTYPES_H
 typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER)
 		(struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
 
@@ -17,10 +32,22 @@
 
 struct _EXCEPTION_REGISTRATION_RECORD
 {
-    struct _EXCEPTION_REGISTRATION_RECORD * Prev;
+    struct _EXCEPTION_REGISTRATION_RECORD * Next;
     PEXCEPTION_HANDLER Handler;
 };
+#endif
 
+#ifdef USE_COMPILER_EXCEPTIONS
+
+#define __TRY __try
+#define __EXCEPT(func) __except((func)(GetExceptionInformation()))
+#define __FINALLY(func) __finally { (func)(!AbnormalTermination()); }
+#define __ENDTRY /*nothing*/
+#define __EXCEPT_PAGE_FAULT __except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
+#define __EXCEPT_ALL __except(EXCEPTION_EXECUTE_HANDLER)
+
+#else  /* USE_COMPILER_EXCEPTIONS */
+
 #define __TRY _SEH2_TRY
 #define __EXCEPT(func) _SEH2_EXCEPT(func(_SEH2_GetExceptionInformation()))
 #define __EXCEPT_PAGE_FAULT _SEH2_EXCEPT(_SEH2_GetExceptionCode() == STATUS_ACCESS_VIOLATION)
@@ -40,31 +67,33 @@
 #define AbnormalTermination() _SEH2_AbnormalTermination()
 #endif
 
-/* Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD */
-#define EH_NONCONTINUABLE   0x01
-#define EH_UNWINDING        0x02
-#define EH_EXIT_UNWIND      0x04
-#define EH_STACK_INVALID    0x08
-#define EH_NESTED_CALL      0x10
+#endif
 
-#define EXCEPTION_WINE_STUB       0x80000100
-#define EXCEPTION_WINE_ASSERTION  0x80000101
-
-#define EXCEPTION_VM86_INTx       0x80000110
-#define EXCEPTION_VM86_STI        0x80000111
-#define EXCEPTION_VM86_PICRETURN  0x80000112
-
 static inline EXCEPTION_REGISTRATION_RECORD *__wine_push_frame( EXCEPTION_REGISTRATION_RECORD *frame )
 {
-    frame->Prev = (struct _EXCEPTION_REGISTRATION_RECORD *)__readfsdword(0);
+#ifdef __i386__
+    frame->Next = (struct _EXCEPTION_REGISTRATION_RECORD *)__readfsdword(0);
 	__writefsdword(0, (unsigned long)frame);
-    return frame->Prev;
+    return frame->Next;
+#else
+    NT_TIB *teb = (NT_TIB *)NtCurrentTeb();
+    frame->Next = teb->ExceptionList;
+    teb->ExceptionList = frame;
+    return frame->Next;
+#endif
 }
 
 static inline EXCEPTION_REGISTRATION_RECORD *__wine_pop_frame( EXCEPTION_REGISTRATION_RECORD *frame )
 {
-	__writefsdword(0, (unsigned long)frame->Prev);
-    return frame->Prev;
+#ifdef __i386__
+	__writefsdword(0, (unsigned long)frame->Next);
+    return frame->Next;
+#else
+    NT_TIB *teb = (NT_TIB *)NtCurrentTeb();
+    frame->Next = teb->ExceptionList;
+    teb->ExceptionList = frame;
+    return frame->Next;
+#endif
 }
 
 extern void __wine_enter_vm86( CONTEXT *context );
