mirror of
https://github.com/snowie2000/mactype.git
synced 2025-01-05 10:17:02 +08:00
update to conform changes made by freetype
This commit is contained in:
parent
c3a52fc534
commit
ebb860e993
@ -1519,9 +1519,10 @@ void HookD2DDll()
|
||||
MessageBox(0, L"HookD2DDll", NULL, MB_OK);
|
||||
#endif
|
||||
HMODULE d2d1 = GetModuleHandle(_T("d2d1.dll"));
|
||||
HMODULE dw = GetModuleHandle(_T("dwrite.dll"));
|
||||
|
||||
if (!d2d1)
|
||||
d2d1 = LoadLibrary(_T("d2d1.dll"));
|
||||
HMODULE dw = GetModuleHandle(_T("dwrite.dll"));
|
||||
if (!dw)
|
||||
dw = LoadLibrary(_T("dwrite.dll"));
|
||||
void* D2D1Factory = GetProcAddress(d2d1, "D2D1CreateFactory");
|
||||
|
6
ft.cpp
6
ft.cpp
@ -1175,14 +1175,14 @@ CGGOOutlineGlyph::init(DWORD bufsize, PVOID bufp, const GLYPHMETRICS& gm)
|
||||
return false;
|
||||
}
|
||||
outline.points = (FT_Vector *)calloc(outline.n_points, sizeof *outline.points);
|
||||
outline.tags = (char *)calloc(outline.n_points, sizeof *outline.tags);
|
||||
outline.contours = (short *)calloc(outline.n_contours, sizeof *outline.contours);
|
||||
outline.tags = (unsigned char *)calloc(outline.n_points, sizeof *outline.tags);
|
||||
outline.contours = (unsigned short *)calloc(outline.n_contours, sizeof *outline.contours);
|
||||
if (!outline.points || !outline.tags || !outline.contours) {
|
||||
done();
|
||||
return false;
|
||||
}
|
||||
|
||||
short *cp = outline.contours;
|
||||
unsigned short *cp = outline.contours;
|
||||
short ppos = 0;
|
||||
|
||||
ttphp = (LPTTPOLYGONHEADER)bufp;
|
||||
|
@ -25,8 +25,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,2023,823,1
|
||||
PRODUCTVERSION 1,2023,823,1
|
||||
FILEVERSION 1,2024,815,1
|
||||
PRODUCTVERSION 1,2024,815,1
|
||||
FILEFLAGSMASK 0x8L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0xbL
|
||||
@ -44,12 +44,12 @@ BEGIN
|
||||
VALUE "Comments", "Portions of this software are copyright (c) 2005-2021 The FreeType Project (www.freetype.org). All rights reserved."
|
||||
VALUE "CompanyName", "2ch & THEMEX & everyone"
|
||||
VALUE "FileDescription", "The Ultimate Font Rasterizer"
|
||||
VALUE "FileVersion", "1.2023.823.1"
|
||||
VALUE "FileVersion", "1.2024.815.1"
|
||||
VALUE "InternalName", "MacType"
|
||||
VALUE "LegalCopyright", "(C) 460, 168, Higambana, 555 and sy567. All rights reserved. FlyingSnow republished"
|
||||
VALUE "OriginalFilename", "MacType.dll"
|
||||
VALUE "ProductName", "The Ultimate Font Rasterizer"
|
||||
VALUE "ProductVersion", "1.2023.823.1"
|
||||
VALUE "ProductVersion", "1.2024.815.1"
|
||||
VALUE "URL", "http://www.mactype.net http://drwatson.nobody.jp/gdi++/"
|
||||
END
|
||||
END
|
||||
|
355
hook.cpp
355
hook.cpp
@ -451,205 +451,208 @@ extern COLORCACHE* g_AACache2[MAX_CACHE_SIZE];
|
||||
HANDLE hDelayHook = 0;
|
||||
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID lpReserved)
|
||||
{
|
||||
static bool bDllInited = false;
|
||||
BOOL IsUnload = false, bEnableDW = true, bUseFontSubstitute = false;
|
||||
switch(reason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
try {
|
||||
static bool bDllInited = false;
|
||||
BOOL IsUnload = false, bEnableDW = true, bUseFontSubstitute = false;
|
||||
switch (reason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
#ifdef DEBUG
|
||||
MessageBox(0, L"Load", NULL, MB_OK);
|
||||
MessageBox(0, L"Load", NULL, MB_OK);
|
||||
#endif
|
||||
DebugOut(L"Begin core loading stage, pid %d", ::GetCurrentProcessId());
|
||||
if (bDllInited)
|
||||
return true;
|
||||
g_dllInstance = instance;
|
||||
DebugOut(L"Begin core loading stage, pid %d", ::GetCurrentProcessId());
|
||||
if (bDllInited)
|
||||
return true;
|
||||
g_dllInstance = instance;
|
||||
|
||||
#ifdef EASYHOOK
|
||||
#ifdef STATIC_LIB
|
||||
EasyHookDllMain(instance, reason, lpReserved);
|
||||
EasyHookDllMain(instance, reason, lpReserved);
|
||||
#else
|
||||
{
|
||||
LPWSTR dllPath = new WCHAR[MAX_PATH + 1];
|
||||
int nSize = GetModuleFileName(g_dllInstance, dllPath, MAX_PATH + 1);
|
||||
WCHAR* p = &dllPath[nSize];
|
||||
while (*--p != L'\\');
|
||||
*p = L'\0';
|
||||
{
|
||||
LPWSTR dllPath = new WCHAR[MAX_PATH + 1];
|
||||
int nSize = GetModuleFileName(g_dllInstance, dllPath, MAX_PATH + 1);
|
||||
WCHAR* p = &dllPath[nSize];
|
||||
while (*--p != L'\\');
|
||||
*p = L'\0';
|
||||
#ifdef _WIN64
|
||||
wcscat(dllPath, L"\\easyhk64.dll");
|
||||
wcscat(dllPath, L"\\easyhk64.dll");
|
||||
#else
|
||||
wcscat(dllPath, L"\\easyhk32.dll");
|
||||
wcscat(dllPath, L"\\easyhk32.dll");
|
||||
#endif
|
||||
HMODULE hEasyhk = LoadLibrary(dllPath);
|
||||
delete[]dllPath;
|
||||
if (!hEasyhk) {
|
||||
DebugOut(L"Failed to load Easyhook, exiting");
|
||||
return false;
|
||||
HMODULE hEasyhk = LoadLibrary(dllPath);
|
||||
delete[]dllPath;
|
||||
if (!hEasyhk) {
|
||||
DebugOut(L"Failed to load Easyhook, exiting");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
//初期化順序
|
||||
//DLL_PROCESS_DETACHではこれの逆順にする
|
||||
//1. CRT関数の初期化
|
||||
//2. クリティカルセクションの初期化
|
||||
//3. TLSの準備
|
||||
//4. CGdippSettingsのインスタンス生成、INI読み込み
|
||||
//5. ExcludeModuleチェック
|
||||
// 6. FreeTypeライブラリの初期化
|
||||
// 7. FreeTypeFontEngineのインスタンス生成
|
||||
// 8. APIをフック
|
||||
// 9. ManagerのGetProcAddressをフック
|
||||
//初期化順序
|
||||
//DLL_PROCESS_DETACHではこれの逆順にする
|
||||
//1. CRT関数の初期化
|
||||
//2. クリティカルセクションの初期化
|
||||
//3. TLSの準備
|
||||
//4. CGdippSettingsのインスタンス生成、INI読み込み
|
||||
//5. ExcludeModuleチェック
|
||||
// 6. FreeTypeライブラリの初期化
|
||||
// 7. FreeTypeFontEngineのインスタンス生成
|
||||
// 8. APIをフック
|
||||
// 9. ManagerのGetProcAddressをフック
|
||||
|
||||
//1
|
||||
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
|
||||
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_WNDW);
|
||||
//_CrtSetBreakAlloc(100);
|
||||
//1
|
||||
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
|
||||
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_WNDW);
|
||||
//_CrtSetBreakAlloc(100);
|
||||
|
||||
//Operaよ止まれ~
|
||||
//Assert(GetModuleHandleA("opera.exe") == NULL);
|
||||
|
||||
//setlocale(LC_ALL, "");
|
||||
g_hinstDLL = instance;
|
||||
|
||||
//Operaよ止まれ~
|
||||
//Assert(GetModuleHandleA("opera.exe") == NULL);
|
||||
|
||||
//APITracer::Start(instance, APITracer::OutputFile);
|
||||
//setlocale(LC_ALL, "");
|
||||
g_hinstDLL = instance;
|
||||
|
||||
//2, 3
|
||||
CCriticalSectionLock::Init();
|
||||
COwnedCriticalSectionLock::Init();
|
||||
CThreadCounter::Init();
|
||||
if (!g_TLInfo.ProcessInit()) {
|
||||
DebugOut(L"Can't initialize process, exiting");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Above classes are heavily referenced and must be initialized as early as possible.
|
||||
// Unload dll is not safe until their initialization is complete.
|
||||
bDllInited = true;
|
||||
//APITracer::Start(instance, APITracer::OutputFile);
|
||||
|
||||
//2, 3
|
||||
CCriticalSectionLock::Init();
|
||||
COwnedCriticalSectionLock::Init();
|
||||
CThreadCounter::Init();
|
||||
if (!g_TLInfo.ProcessInit()) {
|
||||
DebugOut(L"Can't initialize process, exiting");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Above classes are heavily referenced and must be initialized as early as possible.
|
||||
// Unload dll is not safe until their initialization is complete.
|
||||
bDllInited = true;
|
||||
|
||||
//4
|
||||
{
|
||||
#ifdef INFINALITY
|
||||
// enable infinality exclusive features
|
||||
FT_initEnv();
|
||||
#endif
|
||||
CGdippSettings* pSettings = CGdippSettings::CreateInstance();
|
||||
if (!pSettings || !pSettings->LoadSettings(instance)) {
|
||||
CGdippSettings::DestroyInstance();
|
||||
return FALSE;
|
||||
}
|
||||
IsUnload = IsProcessUnload();
|
||||
bEnableDW = pSettings->DirectWrite();
|
||||
bUseFontSubstitute = !!pSettings->FontSubstitutes();
|
||||
}
|
||||
if (!IsUnload) hook_initinternal(); //不加载的模块就不做任何事莵E
|
||||
//5
|
||||
if (!IsProcessExcluded() && !IsUnload) {
|
||||
#ifndef _WIN64
|
||||
InitWow64ext();
|
||||
#endif
|
||||
if (!FontLInit()) {
|
||||
DebugOut(L"FreeType failed to initialize, exiting");
|
||||
return FALSE;
|
||||
}
|
||||
g_pFTEngine = new FreeTypeFontEngine;
|
||||
if (!g_pFTEngine) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//if (!AddEasyHookEnv()) return FALSE; //fail to load easyhook
|
||||
InterlockedExchange(&g_bHookEnabled, TRUE);
|
||||
if (hook_init() != NOERROR) {
|
||||
DebugOut(L"Can't do hooking, exiting");
|
||||
return FALSE;
|
||||
}
|
||||
//hook d2d if already loaded
|
||||
/*
|
||||
DWORD dwSessionID = 0;
|
||||
if (ProcessIdToSessionIdProc)
|
||||
ProcessIdToSessionIdProc(GetCurrentThreadId(), &dwSessionID);
|
||||
else
|
||||
dwSessionID = 1;*/
|
||||
if (IsRunAsUser() && bEnableDW && IsWindowsVistaOrGreater()) //vista or later
|
||||
{
|
||||
HookD2DDll();
|
||||
//hook_demand_LdrLoadDll();
|
||||
}
|
||||
// only hook font creation funcs if font substition is set.
|
||||
if (bUseFontSubstitute) {
|
||||
HookFontCreation();
|
||||
}
|
||||
}
|
||||
//获得当前加载模式
|
||||
|
||||
if (IsUnload)
|
||||
{
|
||||
HANDLE mutex_offical = OpenMutex(MUTEX_ALL_ACCESS, false, _T("{46AD3688-30D0-411e-B2AA-CB177818F428}"));
|
||||
HANDLE mutex_gditray2 = OpenMutex(MUTEX_ALL_ACCESS, false, _T("Global\\MacType"));
|
||||
if (!mutex_gditray2)
|
||||
mutex_gditray2 = OpenMutex(MUTEX_ALL_ACCESS, false, _T("MacType"));
|
||||
HANDLE mutex_CompMode = OpenMutex(MUTEX_ALL_ACCESS, false, _T("Global\\MacTypeCompMode"));
|
||||
if (!mutex_CompMode)
|
||||
mutex_CompMode = OpenMutex(MUTEX_ALL_ACCESS, false, _T("MacTypeCompMode"));
|
||||
BOOL HookMode = (mutex_offical || (mutex_gditray2 && mutex_CompMode)) || (!mutex_offical && !mutex_gditray2); //是否在兼容模式下
|
||||
CloseHandle(mutex_CompMode);
|
||||
CloseHandle(mutex_gditray2);
|
||||
CloseHandle(mutex_offical);
|
||||
if (!HookMode) { //非兼容模式下,拒绝加载
|
||||
DebugOut(L"Process is in unloaddll list, exiting");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//APITracer::Finish();
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
break;
|
||||
case DLL_THREAD_DETACH:
|
||||
g_TLInfo.ThreadTerm();
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
// RemoveManagerHook();
|
||||
if (!bDllInited)
|
||||
return true;
|
||||
bDllInited = false;
|
||||
if (InterlockedExchange(&g_bHookEnabled, FALSE) && lpReserved == NULL) { //如果是进程终止,则不需要释放
|
||||
hook_term();
|
||||
//delete AACacheFull;
|
||||
//delete AACache;
|
||||
// for (int i=0;i<CACHE_SIZE;i++)
|
||||
// delete g_AACache2[i]; //清除缓磥E
|
||||
//free(g_charmapCache);
|
||||
}
|
||||
#ifndef DEBUG
|
||||
if (lpReserved != NULL) return true;
|
||||
#endif
|
||||
|
||||
if (g_pFTEngine) {
|
||||
delete g_pFTEngine;
|
||||
}
|
||||
|
||||
//4
|
||||
{
|
||||
#ifdef INFINALITY
|
||||
// enable infinality exclusive features
|
||||
FT_initEnv();
|
||||
FT_freeEnv();
|
||||
#endif
|
||||
CGdippSettings* pSettings = CGdippSettings::CreateInstance();
|
||||
if (!pSettings || !pSettings->LoadSettings(instance)) {
|
||||
CGdippSettings::DestroyInstance();
|
||||
return FALSE;
|
||||
}
|
||||
IsUnload = IsProcessUnload();
|
||||
bEnableDW = pSettings->DirectWrite();
|
||||
bUseFontSubstitute = !!pSettings->FontSubstitutes();
|
||||
}
|
||||
if (!IsUnload) hook_initinternal(); //不加载的模块就不做任何事莵E
|
||||
//5
|
||||
if (!IsProcessExcluded() && !IsUnload) {
|
||||
#ifndef _WIN64
|
||||
InitWow64ext();
|
||||
#endif
|
||||
if (!FontLInit()) {
|
||||
DebugOut(L"FreeType failed to initialize, exiting");
|
||||
return FALSE;
|
||||
}
|
||||
g_pFTEngine = new FreeTypeFontEngine;
|
||||
if (!g_pFTEngine) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//if (!AddEasyHookEnv()) return FALSE; //fail to load easyhook
|
||||
InterlockedExchange(&g_bHookEnabled, TRUE);
|
||||
if (hook_init() != NOERROR) {
|
||||
DebugOut(L"Can't do hooking, exiting");
|
||||
return FALSE;
|
||||
}
|
||||
//hook d2d if already loaded
|
||||
/*
|
||||
DWORD dwSessionID = 0;
|
||||
if (ProcessIdToSessionIdProc)
|
||||
ProcessIdToSessionIdProc(GetCurrentThreadId(), &dwSessionID);
|
||||
else
|
||||
dwSessionID = 1;*/
|
||||
if (IsRunAsUser() && bEnableDW && IsWindowsVistaOrGreater()) //vista or later
|
||||
{
|
||||
//ORIG_LdrLoadDll = LdrLoadDll;
|
||||
//MessageBox(0, L"Test", NULL, MB_OK);
|
||||
HookD2DDll();
|
||||
//hook_demand_LdrLoadDll();
|
||||
}
|
||||
// only hook font creation funcs if font substition is set.
|
||||
if (bUseFontSubstitute) {
|
||||
HookFontCreation();
|
||||
}
|
||||
}
|
||||
//获得当前加载模式
|
||||
//if (g_alterGUIFont)
|
||||
// DeleteObject(g_alterGUIFont);
|
||||
FontLFree();
|
||||
/*
|
||||
#ifndef _WIN64
|
||||
__FUnloadDelayLoadedDLL2("easyhook32.dll");
|
||||
#else
|
||||
__FUnloadDelayLoadedDLL2("easyhook64.dll");
|
||||
#endif*/
|
||||
|
||||
if (IsUnload)
|
||||
{
|
||||
HANDLE mutex_offical = OpenMutex(MUTEX_ALL_ACCESS, false, _T("{46AD3688-30D0-411e-B2AA-CB177818F428}"));
|
||||
HANDLE mutex_gditray2 = OpenMutex(MUTEX_ALL_ACCESS, false, _T("Global\\MacType"));
|
||||
if (!mutex_gditray2)
|
||||
mutex_gditray2 = OpenMutex(MUTEX_ALL_ACCESS, false, _T("MacType"));
|
||||
HANDLE mutex_CompMode = OpenMutex(MUTEX_ALL_ACCESS, false, _T("Global\\MacTypeCompMode"));
|
||||
if (!mutex_CompMode)
|
||||
mutex_CompMode = OpenMutex(MUTEX_ALL_ACCESS, false, _T("MacTypeCompMode"));
|
||||
BOOL HookMode = (mutex_offical || (mutex_gditray2 && mutex_CompMode)) || (!mutex_offical && !mutex_gditray2); //是否在兼容模式下
|
||||
CloseHandle(mutex_CompMode);
|
||||
CloseHandle(mutex_gditray2);
|
||||
CloseHandle(mutex_offical);
|
||||
if (!HookMode) { //非兼容模式下,拒绝加载
|
||||
DebugOut(L"Process is in unloaddll list, exiting");
|
||||
return false;
|
||||
}
|
||||
CGdippSettings::DestroyInstance();
|
||||
g_TLInfo.ProcessTerm();
|
||||
CCriticalSectionLock::Term();
|
||||
COwnedCriticalSectionLock::Term();
|
||||
break;
|
||||
}
|
||||
|
||||
//APITracer::Finish();
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
break;
|
||||
case DLL_THREAD_DETACH:
|
||||
g_TLInfo.ThreadTerm();
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
// RemoveManagerHook();
|
||||
if (!bDllInited)
|
||||
return true;
|
||||
bDllInited = false;
|
||||
if (InterlockedExchange(&g_bHookEnabled, FALSE) && lpReserved == NULL) { //如果是进程终止,则不需要释放
|
||||
hook_term();
|
||||
//delete AACacheFull;
|
||||
//delete AACache;
|
||||
// for (int i=0;i<CACHE_SIZE;i++)
|
||||
// delete g_AACache2[i]; //清除缓磥E
|
||||
//free(g_charmapCache);
|
||||
}
|
||||
#ifndef DEBUG
|
||||
if (lpReserved != NULL) return true;
|
||||
#endif
|
||||
|
||||
if (g_pFTEngine) {
|
||||
delete g_pFTEngine;
|
||||
}
|
||||
|
||||
#ifdef INFINALITY
|
||||
// enable infinality exclusive features
|
||||
FT_freeEnv();
|
||||
#endif
|
||||
//if (g_alterGUIFont)
|
||||
// DeleteObject(g_alterGUIFont);
|
||||
FontLFree();
|
||||
/*
|
||||
#ifndef _WIN64
|
||||
__FUnloadDelayLoadedDLL2("easyhook32.dll");
|
||||
#else
|
||||
__FUnloadDelayLoadedDLL2("easyhook64.dll");
|
||||
#endif*/
|
||||
|
||||
CGdippSettings::DestroyInstance();
|
||||
g_TLInfo.ProcessTerm();
|
||||
CCriticalSectionLock::Term();
|
||||
COwnedCriticalSectionLock::Term();
|
||||
break;
|
||||
return TRUE;
|
||||
}
|
||||
catch(...) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
//EOF
|
||||
|
Loading…
Reference in New Issue
Block a user