diff --git a/reactos/lib/sdk/crt/crt.cmake b/reactos/lib/sdk/crt/crt.cmake
index f65347db341..6af16da7909 100644
--- a/reactos/lib/sdk/crt/crt.cmake
+++ b/reactos/lib/sdk/crt/crt.cmake
@@ -377,6 +377,7 @@ if(ARCH MATCHES i386)
elseif(ARCH MATCHES amd64)
list(APPEND CRT_SOURCE
except/amd64/seh.s
+ except/amd64/ehandler.c
float/amd64/clearfp.S
float/i386/cntrlfp.c
float/amd64/fpreset.S
@@ -401,6 +402,10 @@ elseif(ARCH MATCHES amd64)
math/amd64/sqrtf.S
math/amd64/tan.S
setjmp/amd64/setjmp.s)
+ if(MSVC)
+ list(APPEND CRT_SOURCE
+ except/amd64/cpp.s)
+ endif()
endif()
if(NOT ARCH MATCHES i386)
diff --git a/reactos/lib/sdk/crt/crt.rbuild b/reactos/lib/sdk/crt/crt.rbuild
index a7f49cecac4..99d3e2a4137 100644
--- a/reactos/lib/sdk/crt/crt.rbuild
+++ b/reactos/lib/sdk/crt/crt.rbuild
@@ -98,6 +98,7 @@
seh.s
chkstk_asm.s
+ ehandler.c
xcptfil.c
@@ -157,7 +158,7 @@
sinh.c
tanh.c
powl.c
-
+
j0_y0.c
j1_y1.c
diff --git a/reactos/lib/sdk/crt/except/amd64/cpp.s b/reactos/lib/sdk/crt/except/amd64/cpp.s
new file mode 100644
index 00000000000..fef42e875d2
--- /dev/null
+++ b/reactos/lib/sdk/crt/except/amd64/cpp.s
@@ -0,0 +1,53 @@
+
+
+#include
+
+.code64
+.align 4
+
+MACRO(START_VTABLE, shortname, cxxname)
+EXTERN shortname&_rtti:PROC
+EXTERN MSVCRT_&shortname&_vector_dtor:PROC
+ .double shortname&_rtti
+PUBLIC MSVCRT_&shortname&_vtable
+MSVCRT_&shortname&_vtable:
+PUBLIC &cxxname
+&cxxname:
+ .double MSVCRT_&shortname&_vector_dtor
+ENDM
+
+MACRO(DEFINE_EXCEPTION_VTABLE, shortname, cxxname)
+ START_VTABLE shortname, cxxname
+ EXTERN MSVCRT_what_exception:PROC
+ .double MSVCRT_what_exception
+ENDM
+
+START_VTABLE type_info, __dummyname_type_info
+DEFINE_EXCEPTION_VTABLE exception, ??_7exception@@6B@
+DEFINE_EXCEPTION_VTABLE bad_typeid, ??_7bad_typeid@@6B@
+DEFINE_EXCEPTION_VTABLE bad_cast, ??_7bad_cast@@6B@
+DEFINE_EXCEPTION_VTABLE __non_rtti_object, ??_7__non_rtti_object@@6B@
+
+
+MACRO(DEFINE_ALIAS, alias, orig)
+EXTERN &orig:ABS
+ALIAS <&alias> = <&orig>
+ENDM
+
+DEFINE_ALIAS ??3@YAXPAX@Z, MSVCRT_operator_delete
+DEFINE_ALIAS ??_U@YAPAXI@Z, MSVCRT_operator_new
+DEFINE_ALIAS ??_V@YAXPAX@Z, MSVCRT_operator_delete
+DEFINE_ALIAS ??2@YAPAXI@Z, MSVCRT_operator_new
+DEFINE_ALIAS ?_query_new_handler@@YAP6AHI@ZXZ, MSVCRT__query_new_handler
+DEFINE_ALIAS ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z, MSVCRT__set_new_handler
+DEFINE_ALIAS ?set_new_handler@@YAP6AXXZP6AXXZ@Z, MSVCRT_set_new_handler
+DEFINE_ALIAS ?_query_new_mode@@YAHXZ, MSVCRT__query_new_mode
+DEFINE_ALIAS ?_set_new_mode@@YAHH@Z, MSVCRT__set_new_mode
+DEFINE_ALIAS ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z, MSVCRT__set_se_translator
+DEFINE_ALIAS ?set_terminate@@YAP6AXXZP6AXXZ@Z, MSVCRT_set_terminate
+DEFINE_ALIAS ?set_unexpected@@YAP6AXXZP6AXXZ@Z, MSVCRT_set_unexpected
+DEFINE_ALIAS ?terminate@@YAXXZ, MSVCRT_terminate
+DEFINE_ALIAS ?unexpected@@YAXXZ, MSVCRT_unexpected
+
+END
+
diff --git a/reactos/lib/sdk/crt/except/amd64/ehandler.c b/reactos/lib/sdk/crt/except/amd64/ehandler.c
new file mode 100644
index 00000000000..06bbd6883c3
--- /dev/null
+++ b/reactos/lib/sdk/crt/except/amd64/ehandler.c
@@ -0,0 +1,17 @@
+
+#include
+
+
+_CRTIMP
+EXCEPTION_DISPOSITION
+__cdecl
+__C_specific_handler(
+ struct _EXCEPTION_RECORD *_ExceptionRecord,
+ void *_EstablisherFrame,
+ struct _CONTEXT *_ContextRecord,
+ struct _DISPATCHER_CONTEXT *_DispatcherContext)
+{
+ UNIMPLEMENTED;
+ return 0;
+}
+
diff --git a/reactos/lib/sdk/crt/math/amd64/fmod.S b/reactos/lib/sdk/crt/math/amd64/fmod.S
index 5117d8bc358..738d3604e2d 100644
--- a/reactos/lib/sdk/crt/math/amd64/fmod.S
+++ b/reactos/lib/sdk/crt/math/amd64/fmod.S
@@ -13,8 +13,8 @@
/* CODE **********************************************************************/
.code64
-PUBLIC _fmod
-_fmod:
+PUBLIC fmod
+fmod:
UNIMPLEMENTED fmod
ret
diff --git a/reactos/lib/sdk/crt/startup/cinitexe.c b/reactos/lib/sdk/crt/startup/cinitexe.c
index ee441ed77f9..2befe7c94d3 100644
--- a/reactos/lib/sdk/crt/startup/cinitexe.c
+++ b/reactos/lib/sdk/crt/startup/cinitexe.c
@@ -2,8 +2,12 @@
#include
#ifdef _MSC_VER
+#ifdef _M_AMD64
+#pragma comment(linker, "/merge:.CRT=.data")
+#else
#pragma comment(linker, "/merge:.CRT=.rdata")
#endif
+#endif
typedef void (__cdecl *_PVFV)(void);
diff --git a/reactos/lib/sdk/crt/startup/mscmain.c b/reactos/lib/sdk/crt/startup/mscmain.c
index 361d04a7691..8917fd46b08 100644
--- a/reactos/lib/sdk/crt/startup/mscmain.c
+++ b/reactos/lib/sdk/crt/startup/mscmain.c
@@ -9,6 +9,12 @@
int _fltused;
+int __mingw_init_ehandler (void)
+{
+ /* Nothing to do */
+ return 1;
+}
+
void
__do_global_dtors (void)
{
diff --git a/reactos/lib/sdk/crt/startup/tlsmcrt.c b/reactos/lib/sdk/crt/startup/tlsmcrt.c
index c5c01d9b8a6..1110b3b81d0 100644
--- a/reactos/lib/sdk/crt/startup/tlsmcrt.c
+++ b/reactos/lib/sdk/crt/startup/tlsmcrt.c
@@ -10,35 +10,3 @@
otherwise
we do tls cleanup in runtime and _CRT_MT has value 2. */
int _CRT_MT = 2;
-
-// HACK around broken imports from libmingwex, until RosBE64 is updated
-#ifdef _M_AMD64
-
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#include
-#include
-
-int __mingwthr_key_dtor (DWORD key, void (*dtor)(void *));
-int __mingwthr_remove_key_dtor (DWORD key);
-
-extern int ___w64_mingwthr_remove_key_dtor (DWORD key);
-extern int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *));
-
-int
-__mingwthr_remove_key_dtor (DWORD key)
-{
- return ___w64_mingwthr_remove_key_dtor (key);
-}
-
-int
-__mingwthr_key_dtor (DWORD key, void (*dtor)(void *))
-{
- if (dtor)
- return ___w64_mingwthr_add_key_dtor (key, dtor);
-
- return 0;
-}
-#endif
-