diff --git a/directwrite.cpp b/directwrite.cpp index 0e7d330..3e5fdbe 100644 --- a/directwrite.cpp +++ b/directwrite.cpp @@ -716,8 +716,8 @@ bool MakeD2DParams(IDWriteFactory* dw_factory) g_D2DParams.PixelGeometry = DWRITE_PIXEL_GEOMETRY_FLAT; } - g_D2DParams.AntialiasMode = (D2D1_TEXT_ANTIALIAS_MODE)D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE; - g_D2DParams.RenderingMode = (DWRITE_RENDERING_MODE)DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC; + g_D2DParams.AntialiasMode = (D2D1_TEXT_ANTIALIAS_MODE)D2D1_TEXT_ANTIALIAS_MODE_DEFAULT; + g_D2DParams.RenderingMode = (DWRITE_RENDERING_MODE)DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC; g_D2DParams.GrayscaleEnhancedContrast = 0.5f; g_D2DParams.GridFitMode = DWRITE_GRID_FIT_MODE_DISABLED; g_D2DParams.RenderingMode1 = DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC; @@ -835,10 +835,20 @@ bool hookD2D1() { } - - - #define FAILEXIT { /*CoUninitialize();*/ return false;} +bool hookFontCreation(CComPtr& pDWriteFactory) { + if (FAILED(pDWriteFactory->GetGdiInterop(&g_pGdiInterop))) FAILEXIT; //判断不正确 + HOOK(pDWriteFactory, CreateTextFormat, 15); + CComPtr dfont = NULL; + CComPtr fontcollection = NULL; + CComPtr ffamily = NULL; + if (FAILED(pDWriteFactory->GetSystemFontCollection(&fontcollection, false))) FAILEXIT; + if (FAILED(fontcollection->GetFontFamily(0, &ffamily))) FAILEXIT; + if (FAILED(ffamily->GetFont(0, &dfont))) FAILEXIT; + HOOK(dfont, CreateFontFace, 13); + return true; +} + bool hookDirectWrite(IUnknown ** factory) //此函数需要改进以判断是否成功hook { //CoInitialize(NULL); @@ -851,6 +861,8 @@ bool hookDirectWrite(IUnknown ** factory) //此函数需要改进以判断是否 CComPtr pDWriteFactory; HRESULT hr1 = (*factory)->QueryInterface(&pDWriteFactory); if (FAILED(hr1)) FAILEXIT; + hookFontCreation(pDWriteFactory); + HOOK(pDWriteFactory, CreateGlyphRunAnalysis, 23); HOOK(pDWriteFactory, GetGdiInterop, 17); MyDebug(L"DW1 hooked"); @@ -906,7 +918,7 @@ bool hookDirectWrite(IUnknown ** factory) //此函数需要改进以判断是否 return true;*/ } - +#undef FAILEXIT #define FAILEXIT {return;} void HookD2DDll() { @@ -947,15 +959,6 @@ void HookD2DDll() __uuidof(IDWriteFactory), reinterpret_cast(&pDWriteFactory)); MakeD2DParams(pDWriteFactory); - if (FAILED(pDWriteFactory->GetGdiInterop(&g_pGdiInterop))) FAILEXIT; //判断不正确 - HOOK(pDWriteFactory, CreateTextFormat, 15); - CComPtr dfont = NULL; - CComPtr fontcollection = NULL; - CComPtr ffamily = NULL; - if (FAILED(pDWriteFactory->GetSystemFontCollection(&fontcollection, false))) FAILEXIT; - if (FAILED(fontcollection->GetFontFamily(0, &ffamily))) FAILEXIT; - if (FAILED(ffamily->GetFont(0, &dfont))) FAILEXIT; - HOOK(dfont, CreateFontFace, 13); } } diff --git a/settings.cpp b/settings.cpp index 851b79d..52ebc3d 100644 --- a/settings.cpp +++ b/settings.cpp @@ -864,6 +864,9 @@ bool CGdippSettings::IsProcessExcluded() const if (m_bRunFromGdiExe) { return false; } + GetEnvironmentVariableW(L"MACTYPE_FORCE_EXCLUDE", NULL, 0); + if (GetLastError() != ERROR_ENVVAR_NOT_FOUND) + return true; GetEnvironmentVariableW(L"MACTYPE_FORCE_LOAD", NULL, 0); if (GetLastError()!=ERROR_ENVVAR_NOT_FOUND) return false;