diff --git a/common.h b/common.h index 94f586d..81b303a 100644 --- a/common.h +++ b/common.h @@ -2,12 +2,13 @@ #define _CRT_SECURE_NO_DEPRECATE 1 #ifdef _WIN64 -#define _WIN32_WINNT _WIN32_WINNT_VISTA +#define _WIN32_WINNT _WIN32_WINNT_WIN10 #define WINVER _WIN32_WINNT_VISTA #else -#define _WIN32_WINNT _WIN32_WINNT_WINXP -#define WINVER _WIN32_WINNT_WINXP +#define _WIN32_WINNT _WIN32_WINNT_WIN10 +#define WINVER _WIN32_WINNT_WIN10 #endif +#define NTDDI_VERSION NTDDI_WIN10_RS1 #define WIN32_LEAN_AND_MEAN 1 #define UNICODE 1 #define _UNICODE 1 diff --git a/directwrite.cpp b/directwrite.cpp index 3e5fdbe..ca8367c 100644 --- a/directwrite.cpp +++ b/directwrite.cpp @@ -71,6 +71,20 @@ void HookFactory(ID2D1Factory* pD2D1Factory) { HOOK(ptr, CreateDevice3, 28); } } + {//factory4 + CComPtr ptr; + HRESULT hr = pD2D1Factory->QueryInterface(&ptr); + if (SUCCEEDED(hr)){ + HOOK(ptr, CreateDevice4, 29); + } + } + {//factory5 + CComPtr ptr; + HRESULT hr = pD2D1Factory->QueryInterface(&ptr); + if (SUCCEEDED(hr)){ + HOOK(ptr, CreateDevice5, 30); + } + } } void HookRenderTarget(ID2D1RenderTarget* pD2D1RenderTarget) { @@ -80,12 +94,14 @@ void HookRenderTarget(ID2D1RenderTarget* pD2D1RenderTarget) { CComQIPtr ptr = pD2D1RenderTarget; HOOK(ptr, CreateCompatibleRenderTarget, 12); + //HOOK(ptr, DrawGlyphRun2, 29); HOOK(ptr, SetTextAntialiasMode, 34); HOOK(ptr, SetTextRenderingParams, 36); ID2D1Factory* pD2D1Factory; pD2D1RenderTarget->GetFactory(&pD2D1Factory); - HookFactory(pD2D1Factory); + if (pD2D1Factory) + HookFactory(pD2D1Factory); } pD2D1RenderTarget->SetTextAntialiasMode(D2D1_TEXT_ANTIALIAS_MODE_DEFAULT); pD2D1RenderTarget->SetTextRenderingParams(g_D2DParams.RenderingParams); @@ -103,7 +119,17 @@ void HookDevice(ID2D1Device* d2dDevice){ CComPtr ptr3; hr = (d2dDevice)->QueryInterface(&ptr3); if SUCCEEDED(hr) { - HOOK(ptr2, CreateDeviceContext3, 12); + HOOK(ptr3, CreateDeviceContext3, 12); + } + CComPtr ptr4; + hr = (d2dDevice)->QueryInterface(&ptr4); + if SUCCEEDED(hr) { + HOOK(ptr4, CreateDeviceContext4, 15); + } + CComPtr ptr5; + hr = (d2dDevice)->QueryInterface(&ptr5); + if SUCCEEDED(hr) { + HOOK(ptr5, CreateDeviceContext5, 16); } } @@ -629,6 +655,38 @@ HRESULT WINAPI IMPL_CreateDeviceContext3( return hr; } +HRESULT WINAPI IMPL_CreateDeviceContext4( + ID2D1Device3* This, + D2D1_DEVICE_CONTEXT_OPTIONS options, + ID2D1DeviceContext3** deviceContext2 + ) { + HRESULT hr = ORIG_CreateDeviceContext4( + This, + options, + deviceContext2 + ); + if (SUCCEEDED(hr)) { + HookRenderTarget(*deviceContext2); + } + return hr; +} + +HRESULT WINAPI IMPL_CreateDeviceContext5( + ID2D1Device4* This, + D2D1_DEVICE_CONTEXT_OPTIONS options, + ID2D1DeviceContext4** deviceContext + ) { + HRESULT hr = ORIG_CreateDeviceContext5( + This, + options, + deviceContext + ); + if (SUCCEEDED(hr)) { + HookRenderTarget(*deviceContext); + } + return hr; +} + HRESULT WINAPI IMPL_CreateDevice1( ID2D1Factory1* This, IDXGIDevice* dxgiDevice, @@ -689,6 +747,46 @@ HRESULT WINAPI IMPL_CreateDevice3( return hr; } +HRESULT WINAPI IMPL_CreateDevice4( + ID2D1Factory4* This, + IDXGIDevice* dxgiDevice, + ID2D1Device3** d2dDevice3 + ){ + HRESULT hr = ORIG_CreateDevice4( + This, + dxgiDevice, + d2dDevice3 + ); + if (SUCCEEDED(hr)) { + static bool loaded = false; + if (!loaded) { + loaded = true; + HookDevice(*d2dDevice3); + } + } + return hr; +} + +HRESULT WINAPI IMPL_CreateDevice5( + ID2D1Factory5* This, + IDXGIDevice* dxgiDevice, + ID2D1Device4** d2dDevice4 + ){ + HRESULT hr = ORIG_CreateDevice5( + This, + dxgiDevice, + d2dDevice4 + ); + if (SUCCEEDED(hr)) { + static bool loaded = false; + if (!loaded) { + loaded = true; + HookDevice(*d2dDevice4); + } + } + return hr; +} + bool MakeD2DParams(IDWriteFactory* dw_factory) { @@ -853,7 +951,7 @@ bool hookDirectWrite(IUnknown ** factory) //此函数需要改进以判断是否 { //CoInitialize(NULL); #ifdef DEBUG - MessageBox(NULL, L"HookDW", NULL, MB_OK); + //MessageBox(NULL, L"HookDW", NULL, MB_OK); #endif if (InterlockedExchange((LONG*)&bDWLoaded, true)) return false; @@ -928,7 +1026,7 @@ void HookD2DDll() _COM_Outptr_ IUnknown **factory ); #ifdef DEBUG - MessageBox(0, L"HookD2DDll", NULL, MB_OK); + //MessageBox(0, L"HookD2DDll", NULL, MB_OK); #endif HMODULE d2d1 = LoadLibrary(_T("d2d1.dll")); HMODULE dw = LoadLibrary(_T("dwrite.dll")); @@ -1111,4 +1209,14 @@ HRESULT WINAPI IMPL_DrawGlyphRun( } MyDebug(L"DrawGlyphRun hooked"); return hr; -} \ No newline at end of file +} + +/* +void WINAPI IMPL_DrawGlyphRun2( + D2D1_POINT_2F baselineOrigin, + _In_ CONST DWRITE_GLYPH_RUN *glyphRun, + _In_ ID2D1Brush *foregroundBrush, + DWRITE_MEASURING_MODE measuringMode = DWRITE_MEASURING_MODE_NATURAL) +{ + return ORIG_DrawGlyphRun2(baselineOrigin, glyphRun, foregroundBrush, measuringMode); +}*/ diff --git a/directwrite.h b/directwrite.h index 863fed7..613012f 100644 --- a/directwrite.h +++ b/directwrite.h @@ -3,6 +3,7 @@ #include "easyhook.h" #pragma once + #define HOOK_MANUALLY HOOK_DEFINE #define HOOK_DEFINE(rettype, name, argtype) \ extern rettype(WINAPI * ORIG_##name) argtype; \ diff --git a/doc/HOWTOBUILD.md b/doc/HOWTOBUILD.md index 477411b..2682720 100644 --- a/doc/HOWTOBUILD.md +++ b/doc/HOWTOBUILD.md @@ -14,7 +14,7 @@ Here I will show you the steps I do to make the compilation. - Freetype ([link](https://www.freetype.org/download.html)) - EasyHook ([link](http://easyhook.github.io/)) - or Detours(obsolete, better not use) - - Windows sdk ([link](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk)) + - Windows sdk 10.0.14393.0 or later([link](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk)) 3. **Building dependencies** - FreeType @@ -42,7 +42,7 @@ Here I will show you the steps I do to make the compilation. 4. **Build** - Last but simplest step. Put all files you builds in the above steps, set up VC++ folders and hit F7. + Last but simplest step. Put all files you builds in the above steps to MacType folder, set up VC++ folders and hit F7. Enjoy. FAQ diff --git a/gdidll.rc b/gdidll.rc index 03b77d2..993d2aa 100644 --- a/gdidll.rc +++ b/gdidll.rc @@ -24,8 +24,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,2016,216,0 - PRODUCTVERSION 1,2016,216,0 + FILEVERSION 1,2016,830,0 + PRODUCTVERSION 1,2016,830,0 FILEFLAGSMASK 0x8L #ifdef _DEBUG FILEFLAGS 0x9L @@ -43,13 +43,13 @@ BEGIN VALUE "Comments", "Portions of this software are copyright (c) 2005-2012 The FreeType Project (www.freetype.org). All rights reserved." VALUE "CompanyName", "2ch & THEMEX" VALUE "FileDescription", "The Ultimate Font Rasterizer" - VALUE "FileVersion", "1.2016.0216.0" + VALUE "FileVersion", "1.2016.830.0" VALUE "InternalName", "MacType" VALUE "LegalCopyright", "(C) 460, 168, Higambana, 555 and sy567. All rights reserved. FlyingSnow republished" VALUE "OriginalFilename", "MacType.dll" VALUE "PrivateBuild", "False" VALUE "ProductName", "The Ultimate Font Rasterizer" - VALUE "ProductVersion", "1.2016.0216.0" + VALUE "ProductVersion", "1.2016.830.0" VALUE "URL", "http://mactype.themex.net http://drwatson.nobody.jp/gdi++/" END END diff --git a/gdipp.vcxproj b/gdipp.vcxproj index f336304..0bde5a6 100644 --- a/gdipp.vcxproj +++ b/gdipp.vcxproj @@ -72,7 +72,7 @@ $(Configuration)\ true false - D:\Archives\Documents\Visual Studio 2008\Projects\freetype-2.6.5\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\shared;$(IncludePath) + D:\Archives\Documents\Visual Studio 2008\Projects\freetype-2.6.5\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;$(IncludePath) D:\Program Files\Microsoft Research\Detours Express 2.1\lib;$(ReferencePath) @@ -80,7 +80,7 @@ $(Platform)\$(Configuration)\ true false - D:\Archives\Documents\Visual Studio 2008\Projects\freetype-2.6.5\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\shared;$(IncludePath) + D:\Archives\Documents\Visual Studio 2008\Projects\freetype-2.6.5\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;$(IncludePath) D:\Program Files\Microsoft Research\Detours Express 2.1\lib;$(ReferencePath) @@ -88,7 +88,7 @@ $(Configuration)\ false false - D:\Archives\Documents\Visual Studio 2008\Projects\freetype-2.6.5\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\shared;$(IncludePath) + D:\Archives\Documents\Visual Studio 2008\Projects\freetype-2.6.5\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;$(IncludePath) C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0\um\x86;$(LibraryPath) @@ -97,7 +97,7 @@ $(Platform)\$(Configuration)\ false false - D:\Archives\Documents\Visual Studio 2008\Projects\freetype-2.6.5\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\shared;$(IncludePath) + D:\Archives\Documents\Visual Studio 2008\Projects\freetype-2.6.5\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;$(IncludePath) diff --git a/hook.cpp b/hook.cpp index b61f561..b7a6082 100644 --- a/hook.cpp +++ b/hook.cpp @@ -276,7 +276,7 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID lpReserved) switch(reason) { case DLL_PROCESS_ATTACH: #ifdef DEBUG - MessageBox(0, L"Load", NULL, MB_OK); + //MessageBox(0, L"Load", NULL, MB_OK); #endif g_dllInstance = instance; // diff --git a/hooklist.h b/hooklist.h index a0e12e5..4fd097b 100644 --- a/hooklist.h +++ b/hooklist.h @@ -209,6 +209,18 @@ HOOK_MANUALLY(HRESULT, CreateDeviceContext3, ( ID2D1DeviceContext2** deviceContext )) +HOOK_MANUALLY(HRESULT, CreateDeviceContext4, ( + ID2D1Device3* This, + D2D1_DEVICE_CONTEXT_OPTIONS options, + ID2D1DeviceContext3** deviceContext + )) + +HOOK_MANUALLY(HRESULT, CreateDeviceContext5, ( + ID2D1Device4* This, + D2D1_DEVICE_CONTEXT_OPTIONS options, + ID2D1DeviceContext4** deviceContext + )) + HOOK_MANUALLY(HRESULT, CreateTextFormat, ( IDWriteFactory* self, __in_z WCHAR const* fontFamilyName, @@ -300,4 +312,25 @@ HOOK_MANUALLY(HRESULT, CreateDevice3, ( IDXGIDevice* dxgiDevice, ID2D1Device2** d2dDevice2 )); + +HOOK_MANUALLY(HRESULT, CreateDevice4, ( + ID2D1Factory4* This, + IDXGIDevice* dxgiDevice, + ID2D1Device3** d2dDevice3 + )); + +HOOK_MANUALLY(HRESULT, CreateDevice5, ( + ID2D1Factory5* This, + IDXGIDevice* dxgiDevice, + ID2D1Device4** d2dDevice4 + )); + +/* +HOOK_MANUALLY(void, DrawGlyphRun2, ( + D2D1_POINT_2F baselineOrigin, + _In_ CONST DWRITE_GLYPH_RUN *glyphRun, + _In_ ID2D1Brush *foregroundBrush, + DWRITE_MEASURING_MODE measuringMode + ));*/ + //EOF diff --git a/settings.h b/settings.h index 5ab1fe3..181bfc7 100644 --- a/settings.h +++ b/settings.h @@ -5,7 +5,7 @@ #include "cache.h" #include "hash_list.h" -#define MACTYPE_VERSION 20120404 +#define MACTYPE_VERSION 20160830 #define MAX_FONT_SETTINGS 16 #define DEFINE_FS_MEMBER(name, param) \ int Get##name() const { return GetParam(param); } \