Skip to content

Commit

Permalink
fixed an issue that will freeze process in certain cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
snowie2000 committed Aug 19, 2016
1 parent 493195f commit 893ba52
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
33 changes: 18 additions & 15 deletions directwrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -835,10 +835,20 @@ bool hookD2D1() {

}




#define FAILEXIT { /*CoUninitialize();*/ return false;}
bool hookFontCreation(CComPtr<IDWriteFactory>& pDWriteFactory) {
if (FAILED(pDWriteFactory->GetGdiInterop(&g_pGdiInterop))) FAILEXIT; //判断不正确
HOOK(pDWriteFactory, CreateTextFormat, 15);
CComPtr<IDWriteFont> dfont = NULL;
CComPtr<IDWriteFontCollection> fontcollection = NULL;
CComPtr<IDWriteFontFamily> 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);
Expand All @@ -851,6 +861,8 @@ bool hookDirectWrite(IUnknown ** factory) //此函数需要改进以判断是否
CComPtr<IDWriteFactory> pDWriteFactory;
HRESULT hr1 = (*factory)->QueryInterface(&pDWriteFactory);
if (FAILED(hr1)) FAILEXIT;
hookFontCreation(pDWriteFactory);

HOOK(pDWriteFactory, CreateGlyphRunAnalysis, 23);
HOOK(pDWriteFactory, GetGdiInterop, 17);
MyDebug(L"DW1 hooked");
Expand Down Expand Up @@ -906,7 +918,7 @@ bool hookDirectWrite(IUnknown ** factory) //此函数需要改进以判断是否
return true;*/
}


#undef FAILEXIT
#define FAILEXIT {return;}
void HookD2DDll()
{
Expand Down Expand Up @@ -947,15 +959,6 @@ void HookD2DDll()
__uuidof(IDWriteFactory),
reinterpret_cast<IUnknown**>(&pDWriteFactory));
MakeD2DParams(pDWriteFactory);
if (FAILED(pDWriteFactory->GetGdiInterop(&g_pGdiInterop))) FAILEXIT; //判断不正确
HOOK(pDWriteFactory, CreateTextFormat, 15);
CComPtr<IDWriteFont> dfont = NULL;
CComPtr<IDWriteFontCollection> fontcollection = NULL;
CComPtr<IDWriteFontFamily> 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);
}
}

Expand Down
3 changes: 3 additions & 0 deletions settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 893ba52

Please sign in to comment.