diff --git a/Source/Core/Common/Common.vcxproj b/Source/Core/Common/Common.vcxproj
index ec67edf..590c5d7 100644
--- a/Source/Core/Common/Common.vcxproj
+++ b/Source/Core/Common/Common.vcxproj
@@ -120,13 +120,13 @@
+
-
@@ -148,4 +148,4 @@
-
+
\ No newline at end of file
diff --git a/Source/Core/Common/Common.vcxproj.filters b/Source/Core/Common/Common.vcxproj.filters
index 64c29fb..5547036 100644
--- a/Source/Core/Common/Common.vcxproj.filters
+++ b/Source/Core/Common/Common.vcxproj.filters
@@ -115,15 +115,15 @@
Logging
- Logging
+
-
+
\ No newline at end of file
diff --git a/Source/Core/Common/XSaveWorkaround.cpp b/Source/Core/Common/XSaveWorkaround.cpp
deleted file mode 100644
index a91af47..0000000
--- a/Source/Core/Common/XSaveWorkaround.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2014 Dolphin Emulator Project
-// Licensed under GPLv2+
-// Refer to the license.txt file included.
-
-#if defined(_WIN32)
-
-#include
-#include
-
-typedef decltype(&GetEnabledXStateFeatures) GetEnabledXStateFeatures_t;
-
-int __cdecl EnableXSaveWorkaround()
-{
- // Some Windows environments may have hardware support for AVX/FMA,
- // but the OS does not support it. The CRT math library does not support
- // this scenario, so we have to manually tell it not to use FMA3
- // instructions.
-
- // The API name is somewhat misleading - we're testing for OS support
- // here.
- if (!IsProcessorFeaturePresent(PF_XSAVE_ENABLED))
- {
- _set_FMA3_enable(0);
- return 0;
- }
-
- // Even if XSAVE feature is enabled, we have to see if
- // GetEnabledXStateFeatures function is present, and see what it says about
- // AVX state.
- auto kernel32Handle = GetModuleHandle(TEXT("kernel32.dll"));
- if (kernel32Handle == nullptr)
- {
- std::abort();
- }
-
- auto pGetEnabledXStateFeatures = (GetEnabledXStateFeatures_t)GetProcAddress(
- kernel32Handle, "GetEnabledXStateFeatures");
- if (pGetEnabledXStateFeatures == nullptr ||
- (pGetEnabledXStateFeatures() & XSTATE_MASK_AVX) == 0)
- {
- _set_FMA3_enable(0);
- }
-
- return 0;
-}
-
-// Create a segment which is recognized by the linker to be part of the CRT
-// initialization. XI* = C startup, XC* = C++ startup. "A" placement is reserved
-// for system use. Thus, the earliest we can get is XIB (C startup is before
-// C++).
-#pragma section(".CRT$XIB", read)
-
-// Place a symbol in the special segment, make it have C linkage so that
-// referencing it doesn't require ugly decorated names.
-// Use /include:XSaveWorkaround linker flag to enable this.
-extern "C" {
- __declspec(allocate(".CRT$XIB"))
- decltype(&EnableXSaveWorkaround) XSaveWorkaround = EnableXSaveWorkaround;
-};
-
-#endif
diff --git a/Source/Core/Common/ucrtFreadWorkaround.cpp b/Source/Core/Common/ucrtFreadWorkaround.cpp
new file mode 100644
index 0000000..9cd1804
--- /dev/null
+++ b/Source/Core/Common/ucrtFreadWorkaround.cpp
@@ -0,0 +1,53 @@
+// Copyright 2014 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#if defined(_WIN32)
+
+#include
+
+int __cdecl EnableucrtFreadWorkaround()
+{
+ // This patches ucrtbase such that fseek will alway
+ // synchronize the file object's internal buffer.
+
+ auto ucrtbase = GetModuleHandle(TEXT("ucrtbase.dll"));
+ auto ucrtbase_pe = (PIMAGE_NT_HEADERS)((uintptr_t)ucrtbase + ((PIMAGE_DOS_HEADER)ucrtbase)->e_lfanew);
+ if (ucrtbase == nullptr || ucrtbase_pe->OptionalHeader.CheckSum != 0xF61ED)
+ {
+ std::abort();
+ }
+
+ void *patch_addr = (void *)((uintptr_t)ucrtbase + 0x6AE7B);
+ size_t patch_size = 5;
+
+ DWORD old_protect;
+ if (!VirtualProtect(patch_addr, patch_size, PAGE_EXECUTE_READWRITE, &old_protect))
+ {
+ std::abort();
+ }
+
+ memset(patch_addr, 0x90, patch_size);
+
+ VirtualProtect(patch_addr, patch_size, old_protect, &old_protect);
+
+ FlushInstructionCache(GetCurrentProcess(), patch_addr, patch_size);
+
+ return 0;
+}
+
+// Create a segment which is recognized by the linker to be part of the CRT
+// initialization. XI* = C startup, XC* = C++ startup. "A" placement is reserved
+// for system use. Thus, the earliest we can get is XIB (C startup is before
+// C++).
+#pragma section(".CRT$XIB", read)
+
+// Place a symbol in the special segment, make it have C linkage so that
+// referencing it doesn't require ugly decorated names.
+// Use /include:EnableucrtFreadWorkaround linker flag to enable this.
+extern "C" {
+ __declspec(allocate(".CRT$XIB"))
+ decltype(&EnableucrtFreadWorkaround) ucrtFreadWorkaround = EnableucrtFreadWorkaround;
+};
+
+#endif
diff --git a/Source/VSProps/Base.props b/Source/VSProps/Base.props
index 4730347..b3f24fb 100644
--- a/Source/VSProps/Base.props
+++ b/Source/VSProps/Base.props
@@ -122,8 +122,8 @@
-
- XSaveWorkaround
+
+ ucrtFreadWorkaroundtrue