mirror of
https://github.com/snowie2000/mactype.git
synced 2025-01-05 10:17:02 +08:00
fix file encoding in non-ambigous cases
This commit is contained in:
parent
98f62cb4b1
commit
412be722a4
@ -52,4 +52,4 @@ void EventLogging::LogIt(WORD CategoryID, DWORD EventID, LPCTSTR ArrayOfStrings[
|
||||
ReportEvent(m_hEventLinker,EVENTLOG_INFORMATION_TYPE,CategoryID,
|
||||
EventID,NULL,NumOfArrayStr,RawDataSize,ArrayOfStrings,RawData);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "override.h"
|
||||
|
||||
//CreateDIB计数,将在绘制下列次数后更新DIB区
|
||||
//CreateDIB计数,将在绘制下列次数后更新DIB区
|
||||
#define BITMAP_REDUCE_COUNTER 256//ĬÈÏ1024
|
||||
|
||||
|
||||
@ -157,7 +157,7 @@ L1:
|
||||
dec ebx
|
||||
jnz L1
|
||||
}
|
||||
#else*/ //对于64位系统,使用C语言
|
||||
#else*/ //对于64位系统,使用C语言
|
||||
for (int yy=Y1; yy<Y2; yy++) {
|
||||
for (int xx=X1; xx<X2; xx++) {
|
||||
*( (DWORD*)m_lpPixels + (yy * xSize + xx) ) = rgb;
|
||||
|
@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
//formula: (x+482)^2+(y+481)^2=880^2
|
||||
unsigned char InvertTable[260] = { 255,255,254,253,253,252,251,251,250,249,249,248,247,247,246,245,245,244,243,242,242,241,240,240,239,238,238,237,236,235,235,234,233,233,232,231,230,230,229,228,227,227,226,225,224,224,223,222,221,221,220,219,218,218,217,216,215,215,214,213,212,211,211,210,209,208,208,207,206,205,204,204,203,202,201,200,199,199,198,197,196,195,195,194,193,192,191,190,189,189,188,187,186,185,184,183,183,182,181,180,179,178,177,176,176,175,174,173,172,171,170,169,168,167,166,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,143,143,142,141,140,138,137,136,135,134,133,132,131,130,129,128,127,126,125,124,123,122,121,120,119,118,117,115,114,113,112,111,110,109,108,107,106,104,103,102,101,100,99,98,96,95,94,93,92,91,90,88,87,86,85,84,82,81,80,79,78,76,75,74,73,71,70,69,68,66,65,64,63,61,60,59,58,56,55,54,52,51,50,48,47,46,44,43,42,40,39,38,36,35,33,32,31,29,28,26,25,24,22,21,19,18,16,15,13,12,10,9,7,6,4,3,1,0,0,0,0,0};
|
||||
unsigned char InvertTable[260] = { 255,255,254,253,253,252,251,251,250,249,249,248,247,247,246,245,245,244,243,242,242,241,240,240,239,238,238,237,236,235,235,234,233,233,232,231,230,230,229,228,227,227,226,225,224,224,223,222,221,221,220,219,218,218,217,216,215,215,214,213,212,211,211,210,209,208,208,207,206,205,204,204,203,202,201,200,199,199,198,197,196,195,195,194,193,192,191,190,189,189,188,187,186,185,184,183,183,182,181,180,179,178,177,176,176,175,174,173,172,171,170,169,168,167,166,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,143,143,142,141,140,138,137,136,135,134,133,132,131,130,129,128,127,126,125,124,123,122,121,120,119,118,117,115,114,113,112,111,110,109,108,107,106,104,103,102,101,100,99,98,96,95,94,93,92,91,90,88,87,86,85,84,82,81,80,79,78,76,75,74,73,71,70,69,68,66,65,64,63,61,60,59,58,56,55,54,52,51,50,48,47,46,44,43,42,40,39,38,36,35,33,32,31,29,28,26,25,24,22,21,19,18,16,15,13,12,10,9,7,6,4,3,1,0,0,0,0,0};
|
||||
|
4
common.h
4
common.h
@ -497,7 +497,7 @@ public:
|
||||
#endif
|
||||
|
||||
|
||||
//String to int等系列函数的定义
|
||||
//String to int等系列函数的定义
|
||||
/*
|
||||
int _StrToInt(LPCTSTR pStr, int nDefault)
|
||||
{
|
||||
@ -628,4 +628,4 @@ bool HookD2D1();
|
||||
void HookGdiplus();
|
||||
void ChangeFileName(LPWSTR lpSrc, int nSize, LPCWSTR lpNewFileName);
|
||||
std::wstring MakeUniqueFontName(const std::wstring strFullName, const std::wstring strFamilyName, const std::wstring strStyleName);
|
||||
std::string WstringToString(const std::wstring str);
|
||||
std::string WstringToString(const std::wstring str);
|
||||
|
@ -2114,4 +2114,4 @@ void WINAPI IMPL_D2D1RenderTarget_DrawTextLayout(
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,4 +17,4 @@
|
||||
#define HOOK_DEFINE(rettype, name, argtype) ;
|
||||
#include "hooklist.h"
|
||||
#undef HOOK_DEFINE
|
||||
#undef HOOK_MANUALLY
|
||||
#undef HOOK_MANUALLY
|
||||
|
120
dll.cpp
120
dll.cpp
@ -19,10 +19,10 @@ CMemLoadDll::~CMemLoadDll()
|
||||
}
|
||||
}
|
||||
|
||||
//MemLoadLibrary函数从内存缓冲区数据中加载一个dll到当前进程的地址空间,缺省位置0x10000000
|
||||
//MemLoadLibrary函数从内存缓冲区数据中加载一个dll到当前进程的地址空间,缺省位置0x10000000
|
||||
//返回值: 成功返回TRUE , 失败返回FALSE
|
||||
//lpFileData: 存放dll文件数据的缓冲区
|
||||
//DataLength: 缓冲区中数据的总长度
|
||||
//lpFileData: 存放dll文件数据的缓冲区
|
||||
//DataLength: 缓冲区中数据的总长度
|
||||
BOOL CMemLoadDll::MemLoadLibrary(void* lpFileData, int DataLength, bool bInitDllMain, bool bFreeOnRavFail)
|
||||
{
|
||||
this->m_bInitDllMain = bInitDllMain;
|
||||
@ -30,40 +30,40 @@ BOOL CMemLoadDll::MemLoadLibrary(void* lpFileData, int DataLength, bool bInitDll
|
||||
{
|
||||
return FALSE; //已经加载一个dll,还没有释放,不能加载新的dll
|
||||
}
|
||||
//检查数据有效性,并初始化
|
||||
//检查数据有效性,并初始化
|
||||
if(!CheckDataValide(lpFileData, DataLength))return FALSE;
|
||||
//计算所需的加载空间
|
||||
//计算所需的加载空间
|
||||
int ImageSize = CalcTotalImageSize();
|
||||
if(ImageSize == 0) return FALSE;
|
||||
|
||||
// 分配虚拟内存
|
||||
// 分配虚拟内存
|
||||
void *pMemoryAddress = VirtualAlloc((LPVOID)0, ImageSize,
|
||||
MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||
if(pMemoryAddress == NULL) return FALSE;
|
||||
else
|
||||
{
|
||||
CopyDllDatas(pMemoryAddress, lpFileData); //复制dll数据,并对齐每个段
|
||||
CopyDllDatas(pMemoryAddress, lpFileData); //复制dll数据,并对齐每个段
|
||||
//重定位信息
|
||||
/*if(pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress >0
|
||||
&& pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].Size>0)
|
||||
{
|
||||
DoRelocation(pMemoryAddress);
|
||||
}
|
||||
//填充引入地址表
|
||||
if(!FillRavAddress(pMemoryAddress) && bFreeOnRavFail) //修正引入地址表失败
|
||||
//填充引入地址表
|
||||
if(!FillRavAddress(pMemoryAddress) && bFreeOnRavFail) //修正引入地址表失败
|
||||
{
|
||||
VirtualFree(pMemoryAddress,0,MEM_RELEASE);
|
||||
return FALSE;
|
||||
}*/
|
||||
//修改页属性。应该根据每个页的属性单独设置其对应内存页的属性。这里简化一下。
|
||||
//修改页属性。应该根据每个页的属性单独设置其对应内存页的属性。这里简化一下。
|
||||
//统一设置成一个属性PAGE_EXECUTE_READWRITE
|
||||
unsigned long old;
|
||||
VirtualProtect(pMemoryAddress, ImageSize, PAGE_EXECUTE_READWRITE,&old);
|
||||
}
|
||||
//修正基地址
|
||||
//修正基地址
|
||||
pNTHeader->OptionalHeader.ImageBase = (DWORD)pMemoryAddress;
|
||||
|
||||
//接下来要调用一下dll的入口函数,做初始化工作。
|
||||
//接下来要调用一下dll的入口函数,做初始化工作。
|
||||
pDllMain = (ProcDllMain)(pNTHeader->OptionalHeader.AddressOfEntryPoint +(DWORD_PTR) pMemoryAddress);
|
||||
BOOL InitResult = !bInitDllMain || pDllMain((HINSTANCE)pMemoryAddress,DLL_PROCESS_ATTACH,0);
|
||||
if(!InitResult) //初始化失败
|
||||
@ -79,9 +79,9 @@ BOOL CMemLoadDll::MemLoadLibrary(void* lpFileData, int DataLength, bool bInitDll
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//MemGetProcAddress函数从dll中获取指定函数的地址
|
||||
//返回值: 成功返回函数地址 , 失败返回NULL
|
||||
//lpProcName: 要查找函数的名字或者序号
|
||||
//MemGetProcAddress函数从dll中获取指定函数的地址
|
||||
//返回值: 成功返回函数地址 , 失败返回NULL
|
||||
//lpProcName: 要查找函数的名字或者序号
|
||||
FARPROC CMemLoadDll::MemGetProcAddress(LPCSTR lpProcName)
|
||||
{
|
||||
if(pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress == 0 ||
|
||||
@ -140,55 +140,55 @@ FARPROC CMemLoadDll::MemGetProcAddress(LPCSTR lpProcName)
|
||||
void CMemLoadDll::DoRelocation( void *NewBase)
|
||||
{
|
||||
/* 重定位表的结构:
|
||||
// DWORD sectionAddress, DWORD size (包括本节需要重定位的数据)
|
||||
// 例如 1000节需要修正5个重定位数据的话,重定位表的数据是
|
||||
// DWORD sectionAddress, DWORD size (包括本节需要重定位的数据)
|
||||
// 例如 1000节需要修正5个重定位数据的话,重定位表的数据是
|
||||
// 00 10 00 00 14 00 00 00 xxxx xxxx xxxx xxxx xxxx 0000
|
||||
// ----------- ----------- ----
|
||||
// 给出节的偏移 总尺寸=8+6*2 需要修正的地址 用于对齐4字节
|
||||
// 重定位表是若干个相连,如果address 和 size都是0 表示结束
|
||||
// 需要修正的地址是12位的,高4位是形态字,intel cpu下是3
|
||||
// 给出节的偏移 总尺寸=8+6*2 需要修正的地址 用于对齐4字节
|
||||
// 重定位表是若干个相连,如果address 和 size都是0 表示结束
|
||||
// 需要修正的地址是12位的,高4位是形态字,intel cpu下是3
|
||||
*/
|
||||
//假设NewBase是0x600000,而文件中设置的缺省ImageBase是0x400000,则修正偏移量就是0x200000
|
||||
//假设NewBase是0x600000,而文件中设置的缺省ImageBase是0x400000,则修正偏移量就是0x200000
|
||||
DWORD Delta = (DWORD)NewBase - pNTHeader->OptionalHeader.ImageBase;
|
||||
|
||||
//注意重定位表的位置可能和硬盘文件中的偏移地址不同,应该使用加载后的地址
|
||||
//注意重定位表的位置可能和硬盘文件中的偏移地址不同,应该使用加载后的地址
|
||||
PIMAGE_BASE_RELOCATION pLoc = (PIMAGE_BASE_RELOCATION)((DWORD_PTR)NewBase
|
||||
+ pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress);
|
||||
while((pLoc->VirtualAddress + pLoc->SizeOfBlock) != 0) //开始扫描重定位表
|
||||
while((pLoc->VirtualAddress + pLoc->SizeOfBlock) != 0) //开始扫描重定位表
|
||||
{
|
||||
WORD *pLocData = (WORD *)((DWORD_PTR)pLoc + sizeof(IMAGE_BASE_RELOCATION));
|
||||
//计算本节需要修正的重定位项(地址)的数目
|
||||
//计算本节需要修正的重定位项(地址)的数目
|
||||
int NumberOfReloc = (pLoc->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION))/sizeof(WORD);
|
||||
for( int i=0 ; i < NumberOfReloc; i++)
|
||||
{
|
||||
if( (DWORD)(pLocData[i] & 0xF000) == 0x00003000) //这是一个需要修正的地址
|
||||
if( (DWORD)(pLocData[i] & 0xF000) == 0x00003000) //这是一个需要修正的地址
|
||||
{
|
||||
// 举例:
|
||||
// 举例:
|
||||
// pLoc->VirtualAddress = 0x1000;
|
||||
// pLocData[i] = 0x313E; 表示本节偏移地址0x13E处需要修正
|
||||
// pLocData[i] = 0x313E; 表示本节偏移地址0x13E处需要修正
|
||||
// 因此 pAddress = 基地址 + 0x113E
|
||||
// 里面的内容是 A1 ( 0c d4 02 10) 汇编代码是: mov eax , [1002d40c]
|
||||
// 需要修正1002d40c这个地址
|
||||
// 里面的内容是 A1 ( 0c d4 02 10) 汇编代码是: mov eax , [1002d40c]
|
||||
// 需要修正1002d40c这个地址
|
||||
DWORD * pAddress = (DWORD *)((DWORD_PTR)NewBase + pLoc->VirtualAddress + (pLocData[i] & 0x0FFF));
|
||||
*pAddress += Delta;
|
||||
}
|
||||
}
|
||||
//转移到下一个节进行处理
|
||||
//转移到下一个节进行处理
|
||||
pLoc = (PIMAGE_BASE_RELOCATION)((DWORD)pLoc + pLoc->SizeOfBlock);
|
||||
}
|
||||
}
|
||||
|
||||
//填充引入地址表
|
||||
//填充引入地址表
|
||||
BOOL CMemLoadDll::FillRavAddress(void *pImageBase)
|
||||
{
|
||||
// 引入表实际上是一个 IMAGE_IMPORT_DESCRIPTOR 结构数组,全部是0表示结束
|
||||
// 数组定义如下:
|
||||
// 引入表实际上是一个 IMAGE_IMPORT_DESCRIPTOR 结构数组,全部是0表示结束
|
||||
// 数组定义如下:
|
||||
//
|
||||
// DWORD OriginalFirstThunk; // 0表示结束,否则指向未绑定的IAT结构数组
|
||||
// DWORD OriginalFirstThunk; // 0表示结束,否则指向未绑定的IAT结构数组
|
||||
// DWORD TimeDateStamp;
|
||||
// DWORD ForwarderChain; // -1 if no forwarders
|
||||
// DWORD Name; // 给出dll的名字
|
||||
// DWORD FirstThunk; // 指向IAT结构数组的地址(绑定后,这些IAT里面就是实际的函数地址)
|
||||
// DWORD FirstThunk; // 指向IAT结构数组的地址(绑定后,这些IAT里面就是实际的函数地址)
|
||||
unsigned long Offset = pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress ;
|
||||
if(Offset == 0) return TRUE; //No Import Table
|
||||
PIMAGE_IMPORT_DESCRIPTOR pID = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD_PTR) pImageBase + Offset);
|
||||
@ -209,25 +209,25 @@ BOOL CMemLoadDll::FillRavAddress(void *pImageBase)
|
||||
else buf[i] = 0;
|
||||
HMODULE hDll = GetModuleHandle(buf);
|
||||
if(hDll == NULL)return FALSE; //NOT FOUND DLL
|
||||
//获取DLL中每个导出函数的地址,填入IAT
|
||||
//获取DLL中每个导出函数的地址,填入IAT
|
||||
//每个IAT结构是 :
|
||||
// union { PBYTE ForwarderString;
|
||||
// PDWORD Function;
|
||||
// DWORD Ordinal;
|
||||
// PIMAGE_IMPORT_BY_NAME AddressOfData;
|
||||
// } u1;
|
||||
// 长度是一个DWORD ,正好容纳一个地址。
|
||||
// 长度是一个DWORD ,正好容纳一个地址。
|
||||
for(i=0; ;i++)
|
||||
{
|
||||
if(pOriginalIAT[i].u1.Function == 0)break;
|
||||
FARPROC lpFunction = NULL;
|
||||
if(pOriginalIAT[i].u1.Ordinal & IMAGE_ORDINAL_FLAG) //这里的值给出的是导出序号
|
||||
if(pOriginalIAT[i].u1.Ordinal & IMAGE_ORDINAL_FLAG) //这里的值给出的是导出序号
|
||||
{
|
||||
lpFunction = GetProcAddress(hDll, (LPCSTR)(pOriginalIAT[i].u1.Ordinal & 0x0000FFFF));
|
||||
}
|
||||
else //按照名字导入
|
||||
else //按照名字导入
|
||||
{
|
||||
//获取此IAT项所描述的函数名称
|
||||
//获取此IAT项所描述的函数名称
|
||||
PIMAGE_IMPORT_BY_NAME pByName = (PIMAGE_IMPORT_BY_NAME)
|
||||
((DWORD_PTR)pImageBase + (DWORD)(pOriginalIAT[i].u1.AddressOfData));
|
||||
// if(pByName->Hint !=0)
|
||||
@ -248,34 +248,34 @@ BOOL CMemLoadDll::FillRavAddress(void *pImageBase)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//CheckDataValide函数用于检查缓冲区中的数据是否有效的dll文件
|
||||
//CheckDataValide函数用于检查缓冲区中的数据是否有效的dll文件
|
||||
//返回值: 是一个可执行的dll则返回TRUE,否则返回FALSE。
|
||||
//lpFileData: 存放dll数据的内存缓冲区
|
||||
//DataLength: dll文件的长度
|
||||
//lpFileData: 存放dll数据的内存缓冲区
|
||||
//DataLength: dll文件的长度
|
||||
BOOL CMemLoadDll::CheckDataValide(void* lpFileData, int DataLength)
|
||||
{
|
||||
//检查长度
|
||||
//检查长度
|
||||
if(DataLength < sizeof(IMAGE_DOS_HEADER)) return FALSE;
|
||||
pDosHeader = (PIMAGE_DOS_HEADER)lpFileData; // DOS头
|
||||
//检查dos头的标记
|
||||
//检查dos头的标记
|
||||
if(pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) return FALSE; //0x5A4D : MZ
|
||||
|
||||
//检查长度
|
||||
//检查长度
|
||||
if((DWORD)DataLength < (pDosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS32)) ) return FALSE;
|
||||
//取得pe头
|
||||
pNTHeader = (PIMAGE_NT_HEADERS32)( (DWORD_PTR)lpFileData + (DWORD_PTR)pDosHeader->e_lfanew); // PE头
|
||||
//检查pe头的合法性
|
||||
//检查pe头的合法性
|
||||
if(pNTHeader->Signature != IMAGE_NT_SIGNATURE) return FALSE; //0x00004550 : PE00
|
||||
if((pNTHeader->FileHeader.Characteristics & IMAGE_FILE_DLL) == 0) //0x2000 : File is a DLL
|
||||
return FALSE;
|
||||
if((pNTHeader->FileHeader.Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE) == 0) //0x0002 : 指出文件可以运行
|
||||
if((pNTHeader->FileHeader.Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE) == 0) //0x0002 : 指出文件可以运行
|
||||
return FALSE;
|
||||
if(pNTHeader->FileHeader.SizeOfOptionalHeader != sizeof(IMAGE_OPTIONAL_HEADER32)) return FALSE;
|
||||
|
||||
|
||||
//取得节表(段表)
|
||||
pSectionHeader = (PIMAGE_SECTION_HEADER)((DWORD_PTR)pNTHeader + sizeof(IMAGE_NT_HEADERS32));
|
||||
//验证每个节表的空间
|
||||
//验证每个节表的空间
|
||||
for(int i=0; i< pNTHeader->FileHeader.NumberOfSections; i++)
|
||||
{
|
||||
if((pSectionHeader[i].PointerToRawData + pSectionHeader[i].SizeOfRawData) > (DWORD)DataLength)return FALSE;
|
||||
@ -283,19 +283,19 @@ BOOL CMemLoadDll::CheckDataValide(void* lpFileData, int DataLength)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//计算对齐边界
|
||||
//计算对齐边界
|
||||
int CMemLoadDll::GetAlignedSize(int Origin, int Alignment)
|
||||
{
|
||||
return (Origin + Alignment - 1) / Alignment * Alignment;
|
||||
}
|
||||
//计算整个dll映像文件的尺寸
|
||||
//计算整个dll映像文件的尺寸
|
||||
int CMemLoadDll::CalcTotalImageSize()
|
||||
{
|
||||
int Size;
|
||||
if(pNTHeader == NULL)return 0;
|
||||
int nAlign = pNTHeader->OptionalHeader.SectionAlignment; //段对齐字节数
|
||||
int nAlign = pNTHeader->OptionalHeader.SectionAlignment; //段对齐字节数
|
||||
|
||||
// 计算所有头的尺寸。包括dos, coff, pe头 和 段表的大小
|
||||
// 计算所有头的尺寸。包括dos, coff, pe头 和 段表的大小
|
||||
Size = GetAlignedSize(pNTHeader->OptionalHeader.SizeOfHeaders, nAlign);
|
||||
// 计算所有节的大小
|
||||
for(int i=0; i < pNTHeader->FileHeader.NumberOfSections; ++i)
|
||||
@ -311,12 +311,12 @@ int CMemLoadDll::CalcTotalImageSize()
|
||||
}
|
||||
return Size;
|
||||
}
|
||||
//CopyDllDatas函数将dll数据复制到指定内存区域,并对齐所有节
|
||||
//pSrc: 存放dll数据的原始缓冲区
|
||||
//pDest:目标内存地址
|
||||
//CopyDllDatas函数将dll数据复制到指定内存区域,并对齐所有节
|
||||
//pSrc: 存放dll数据的原始缓冲区
|
||||
//pDest:目标内存地址
|
||||
void CMemLoadDll::CopyDllDatas(void* pDest, void* pSrc)
|
||||
{
|
||||
// 计算需要复制的PE头+段表字节数
|
||||
// 计算需要复制的PE头+段表字节数
|
||||
int HeaderSize = pNTHeader->OptionalHeader.SizeOfHeaders;
|
||||
int SectionSize = pNTHeader->FileHeader.NumberOfSections * sizeof(IMAGE_SECTION_HEADER);
|
||||
int MoveSize = HeaderSize + SectionSize;
|
||||
@ -329,13 +329,13 @@ void CMemLoadDll::CopyDllDatas(void* pDest, void* pSrc)
|
||||
if(pSectionHeader[i].VirtualAddress == 0 || pSectionHeader[i].SizeOfRawData == 0)continue;
|
||||
// 定位该节在内存中的位置
|
||||
void *pSectionAddress = (void *)((DWORD_PTR)pDest + pSectionHeader[i].VirtualAddress);
|
||||
// 复制段数据到虚拟内存
|
||||
// 复制段数据到虚拟内存
|
||||
memmove((void *)pSectionAddress,
|
||||
(void *)((DWORD_PTR)pSrc + pSectionHeader[i].PointerToRawData),
|
||||
pSectionHeader[i].SizeOfRawData);
|
||||
}
|
||||
|
||||
//修正指针,指向新分配的内存
|
||||
//修正指针,指向新分配的内存
|
||||
//新的dos头
|
||||
pDosHeader = (PIMAGE_DOS_HEADER)pDest;
|
||||
//新的pe头地址
|
||||
@ -343,4 +343,4 @@ void CMemLoadDll::CopyDllDatas(void* pDest, void* pSrc)
|
||||
//新的节表地址
|
||||
pSectionHeader = (PIMAGE_SECTION_HEADER)((DWORD_PTR)pNTHeader + sizeof(IMAGE_NT_HEADERS32));
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
2
dll.h
2
dll.h
@ -28,4 +28,4 @@ private:
|
||||
PIMAGE_DOS_HEADER pDosHeader;
|
||||
PIMAGE_NT_HEADERS32 pNTHeader;
|
||||
PIMAGE_SECTION_HEADER pSectionHeader;
|
||||
};
|
||||
};
|
||||
|
@ -108,4 +108,4 @@ AutoEnableDynamicCodeGen::~AutoEnableDynamicCodeGen()
|
||||
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,4 +31,4 @@ private:
|
||||
static PGET_THREAD_INFORMATION_PROC GetThreadInformationProc;
|
||||
static PROCESS_MITIGATION_DYNAMIC_CODE_POLICY processPolicy;
|
||||
static volatile bool processPolicyObtained;
|
||||
};
|
||||
};
|
||||
|
@ -441,4 +441,4 @@ DRIVER_SHARED_API(NTSTATUS, LhBarrierCallStackTrace(
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
10
expfunc.cpp
10
expfunc.cpp
@ -142,7 +142,7 @@ EXTERN_C void SafeUnload()
|
||||
{
|
||||
static BOOL bInited = false;
|
||||
if (bInited)
|
||||
return; //防重入
|
||||
return; //防重入
|
||||
bInited = true;
|
||||
while (CThreadCounter::Count())
|
||||
Sleep(0);
|
||||
@ -252,7 +252,7 @@ FARPROC K32GetProcAddress(LPCSTR lpProcName)
|
||||
//kernel32のベースアドレス取得
|
||||
WCHAR sysdir[MAX_PATH];
|
||||
GetWindowsDirectory(sysdir, MAX_PATH);
|
||||
if (GetModuleHandle(_T("kernelbase.dll"))) //查看自己是否加载了Kernelbase.dll文件,存在则说明是win7系统
|
||||
if (GetModuleHandle(_T("kernelbase.dll"))) //查看自己是否加载了Kernelbase.dll文件,存在则说明是win7系统
|
||||
wcscat(sysdir, L"\\SysWow64\\kernelbase.dll");
|
||||
else
|
||||
wcscat(sysdir, L"\\SysWow64\\kernel32.dll"); //イサエ贇レセヘハヌvista
|
||||
@ -260,8 +260,8 @@ FARPROC K32GetProcAddress(LPCSTR lpProcName)
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
DWORD dwSize = GetFileSize(hFile, NULL);
|
||||
BYTE* pMem = new BYTE[dwSize]; //分配内存
|
||||
ReadFile(hFile, pMem, dwSize, &dwSize, NULL);//读取文件
|
||||
BYTE* pMem = new BYTE[dwSize]; //分配内存
|
||||
ReadFile(hFile, pMem, dwSize, &dwSize, NULL);//读取文件
|
||||
CloseHandle(hFile);
|
||||
|
||||
CMemLoadDll MemDll;
|
||||
@ -680,7 +680,7 @@ VOID SafeGetNativeSystemInfo(__out LPSYSTEM_INFO lpSystemInfo)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取操作系统位数
|
||||
// 获取操作系统位数
|
||||
int GetSystemBits()
|
||||
{
|
||||
SYSTEM_INFO si;
|
||||
|
@ -61,7 +61,7 @@ ControlIder CID;
|
||||
#endif
|
||||
|
||||
|
||||
//更新
|
||||
//更新
|
||||
#define RGBA(r,g,b,a) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)|(((DWORD)(BYTE)(a))<<24)))
|
||||
//!!Snowie
|
||||
|
||||
@ -147,7 +147,7 @@ static CAlphaBlend s_AlphaBlendTable;
|
||||
|
||||
void CAlphaBlend::gettunetbl(int paramalpha, BOOL lcd, BOOL dark, const int * &tblR, const int * &tblG, const int * &tblB) const
|
||||
{
|
||||
if (paramalpha == 1) { //获取文字混合表
|
||||
if (paramalpha == 1) { //获取文字混合表
|
||||
if (lcd) {
|
||||
tblR = tunetblR;
|
||||
tblG = tunetblG;
|
||||
@ -155,7 +155,7 @@ void CAlphaBlend::gettunetbl(int paramalpha, BOOL lcd, BOOL dark, const int * &t
|
||||
} else {
|
||||
tblR = tblG = tblB = tunetbl;
|
||||
}
|
||||
} else { //获取阴影混合表
|
||||
} else { //获取阴影混合表
|
||||
if (dark)
|
||||
{
|
||||
if (lcd) {
|
||||
@ -250,12 +250,12 @@ void CAlphaBlend::init()
|
||||
tunetblS[i] = Bound(0, alphatbl[Bound(table[i] * paramalpha /100, 0, 255)], CAlphaBlend::BASE);
|
||||
tunetblRS[i] = Bound(0, alphatbl[Bound(tableR[i] * paramalpha/100, 0, 255)], CAlphaBlend::BASE);
|
||||
tunetblGS[i] = Bound(0, alphatbl[Bound(tableG[i] * paramalpha/100, 0, 255)], CAlphaBlend::BASE);
|
||||
tunetblBS[i] =Bound(0, alphatbl[Bound(tableB[i] * paramalpha/100, 0, 255)], CAlphaBlend::BASE); //浅色混合表
|
||||
tunetblBS[i] =Bound(0, alphatbl[Bound(tableB[i] * paramalpha/100, 0, 255)], CAlphaBlend::BASE); //浅色混合表
|
||||
|
||||
tunetblLS[i] = Bound(0, alphatbl[Bound(table[i] * lightparamalpha/100, 0, 255)], CAlphaBlend::BASE);
|
||||
tunetblLRS[i] = Bound(0, alphatbl[Bound(tableR[i] * lightparamalpha/100, 0, 255)], CAlphaBlend::BASE);
|
||||
tunetblLGS[i] = Bound(0, alphatbl[Bound(tableG[i] * lightparamalpha/100, 0, 255)], CAlphaBlend::BASE);
|
||||
tunetblLBS[i] =Bound(0, alphatbl[Bound(tableB[i] * lightparamalpha/100, 0, 255)], CAlphaBlend::BASE); //深色混合表
|
||||
tunetblLBS[i] =Bound(0, alphatbl[Bound(tableB[i] * lightparamalpha/100, 0, 255)], CAlphaBlend::BASE); //深色混合表
|
||||
}
|
||||
}
|
||||
|
||||
@ -1177,7 +1177,7 @@ BOOL FreeTypePrepare(FreeTypeDrawInfo& FTInfo)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
FTInfo.params->lplf->lfWeight = FTInfo.params->otm->otmTextMetrics.tmWeight; //更新到标准weight
|
||||
FTInfo.params->lplf->lfWeight = FTInfo.params->otm->otmTextMetrics.tmWeight; //更新到标准weight
|
||||
pfs = &pfi->GetFontSettings();
|
||||
|
||||
cmap_index = -1;
|
||||
@ -1313,7 +1313,7 @@ BOOL FreeTypePrepare(FreeTypeDrawInfo& FTInfo)
|
||||
break;
|
||||
}
|
||||
|
||||
//如果含有内置hinting则启用default模式,否则使用autohint模式,以保证效果
|
||||
//如果含有内置hinting则启用default模式,否则使用autohint模式,以保证效果
|
||||
// アンチエイリアス
|
||||
if (FTInfo.IsMono()) {
|
||||
font_type.flags |= FT_LOAD_TARGET_MONO;
|
||||
@ -1348,7 +1348,7 @@ BOOL FreeTypePrepare(FreeTypeDrawInfo& FTInfo)
|
||||
if (pSettings->HintSmallFont() && font_type.flags & FT_LOAD_TARGET_LIGHT && font_type.height!=-1 && font_type.height<12) //ヘィモテノ靹テイサハケモテhinting」ャオォハヌエ<EFBE87>ェチヒミ。ラヨフ乕intingソェケリ
|
||||
{
|
||||
/*
|
||||
if (!(freetype_face->face_flags & FT_FACE_FLAG_TRICKY)) //如果不是tricky字体
|
||||
if (!(freetype_face->face_flags & FT_FACE_FLAG_TRICKY)) //如果不是tricky字体
|
||||
font_type.flags = font_type.flags & (~FT_LOAD_NO_HINTING) | (pfi->FontHasHinting() ? FT_LOAD_NO_AUTOHINT : FT_LOAD_FORCE_AUTOHINT);
|
||||
else*/
|
||||
|
||||
@ -1472,7 +1472,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
BOOL bWindowsLink = pSettings->FontLink()==2;
|
||||
//!!Snowie
|
||||
|
||||
/*const*/ FT_Face freetype_face = FTInfo.freetype_face; //去掉常量属性,下面要改他
|
||||
/*const*/ FT_Face freetype_face = FTInfo.freetype_face; //去掉常量属性,下面要改他
|
||||
const FT_Int cmap_index = FTInfo.cmap_index;
|
||||
const FT_Bool useKerning = FTInfo.useKerning;
|
||||
FT_Render_Mode render_mode = FTInfo.render_mode;
|
||||
@ -1520,13 +1520,13 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
ZeroMemory(lpfontlink[i], sizeof(WORD)*cbString); //ウ<>シサッホェボチエスモ
|
||||
}
|
||||
//
|
||||
hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //加载第一个字体
|
||||
hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //加载第一个字体
|
||||
}
|
||||
//fontlink
|
||||
|
||||
int* Dx= FTInfo.Dx;
|
||||
if (!bAllowDefaultLink && FTInfo.face_id_list_num > 1)
|
||||
FTInfo.face_id_list_num--; //如果是symbol页那就不链接到宋体
|
||||
FTInfo.face_id_list_num--; //如果是symbol页那就不链接到宋体
|
||||
|
||||
bool bUnicodePlane = false;
|
||||
for (int i=0 ; lpString < lpEnd; ++lpString, ++gi, ++GlyphArray, ++drState, ++AAList, /*ggdi32++,*/ i++){
|
||||
@ -1576,7 +1576,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
f_glyph = !!wch;
|
||||
glyph_index = wch;
|
||||
*AAList = AAMode;
|
||||
GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index的文字必须计算宽度
|
||||
GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index的文字必须计算宽度
|
||||
if (FTInfo.font_type.height<=pSettings->BitmapHeight() && pfi->EmbeddedBmpExist(FTInfo.font_type.height))
|
||||
{
|
||||
f_glyph=false; //ハケモテオ耻<EFBDB5>ャイササ賚シ
|
||||
@ -1586,11 +1586,11 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
if (wch && !CID.myiswcntrl(lpString[0])) {
|
||||
|
||||
for (int j = 0; j < FTInfo.face_id_list_num; ++j) {
|
||||
if (bWindowsLink) //使用Windows函数进行fontlink
|
||||
if (bWindowsLink) //使用Windows函数进行fontlink
|
||||
{
|
||||
if (!lpfontlink[j][i]) //サケテサウ<EFBDBB>シサックテラヨフ蠏トfontlink
|
||||
{
|
||||
SelectFont(FTInfo.hdc, FTInfo.ggo_font_list[j]); //加载ggo字体
|
||||
SelectFont(FTInfo.hdc, FTInfo.ggo_font_list[j]); //加载ggo字体
|
||||
GetGlyphIndices(FTInfo.hdc, lpString, cbString-i, &lpfontlink[j][i], GGI_MARK_NONEXISTING_GLYPHS); //ス<>ミfontlink
|
||||
SelectFont(FTInfo.hdc, hOldFont);
|
||||
}
|
||||
@ -1607,8 +1607,8 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
GetCharWidth32W(FTInfo.hdc, wch, wch, &gdi32x); //モミミァホトラヨ」ャシニヒ譱昮ネ
|
||||
f_glyph = true;
|
||||
FTInfo.font_type.face_id = FTInfo.face_id_list[j];
|
||||
freetype_face = FTInfo.GetFace(j); //同时更新对应faceid的实际face
|
||||
//接下来更新对应的fontsetting
|
||||
freetype_face = FTInfo.GetFace(j); //同时更新对应faceid的实际face
|
||||
//接下来更新对应的fontsetting
|
||||
FTInfo.font_type.flags = FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
|
||||
// ヒンティング
|
||||
//extern CFontSetCache g_fsetcache;
|
||||
@ -1617,7 +1617,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
{
|
||||
switch (FTInfo.font_type.height)
|
||||
{
|
||||
case 11:{FTInfo.font_type.height=12; FTInfo.font_type.width++; break;} //对宋体进行特殊处理
|
||||
case 11:{FTInfo.font_type.height=12; FTInfo.font_type.width++; break;} //对宋体进行特殊处理
|
||||
case 13:{FTInfo.font_type.height=15; FTInfo.font_type.width+=2; break;}
|
||||
}
|
||||
}
|
||||
@ -1672,7 +1672,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
AAMode = *AAList/*pfs->GetAntiAliasMode()*/;
|
||||
bLcdMode = render_mode == FT_RENDER_MODE_LCD;
|
||||
bLightLcdMode = (AAMode == 4) || (AAMode == 5);
|
||||
//更新完成
|
||||
//更新完成
|
||||
}
|
||||
if (FTInfo.font_type.height<=pSettings->BitmapHeight() && pfi->EmbeddedBmpExist(FTInfo.font_type.height))
|
||||
{
|
||||
@ -1686,7 +1686,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
|
||||
|
||||
|
||||
if (!f_glyph) { //glyphindex的文字上面已经计算过了
|
||||
if (!f_glyph) { //glyphindex的文字上面已经计算过了
|
||||
#ifdef _DEBUG
|
||||
GdiSetBatchLimit(0);
|
||||
#endif
|
||||
@ -1716,7 +1716,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
int dxWidth = clpdx.get(cx);
|
||||
if (isc == CNTRL_COMPLEX_TEXT) //ソリヨニラヨ
|
||||
{
|
||||
cx = dxWidth; //服从windows的宽度调度
|
||||
cx = dxWidth; //服从windows的宽度调度
|
||||
//if (!dxWidth)
|
||||
// CID.setcntrlAttribute(wch, CNTRL_ZERO_WIDTH);
|
||||
}
|
||||
@ -1731,7 +1731,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
GetCharABCWidthsI(FTInfo.hdc, wch, 1, NULL, &abc);
|
||||
else
|
||||
GetCharABCWidths(FTInfo.hdc, wch, wch, &abc);*/
|
||||
//FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //无效文字的情况下,绘图宽度=鼠标位置
|
||||
//FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //无效文字的情况下,绘图宽度=鼠标位置
|
||||
FTInfo.px = FTInfo.x + cx;
|
||||
FTInfo.x += dxWidth;//Max(clpdx.get(cx), cx);/*(int)abc.abcB+abc.abcC*///Max(clpdx.get(cx), abc.abcB? abc.abcA:0);
|
||||
//}
|
||||
@ -1774,7 +1774,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
}
|
||||
}else{
|
||||
if (bVertical)
|
||||
swap(FTInfo.font_type.height, FTInfo.font_type.width); //交换无法旋转的文字宽高
|
||||
swap(FTInfo.font_type.height, FTInfo.font_type.width); //交换无法旋转的文字宽高
|
||||
FTInfo.font_type.flags &=~FT_LOAD_VERTICAL_LAYOUT;
|
||||
if(bLcdMode){
|
||||
if(!bLightLcdMode){
|
||||
@ -1789,8 +1789,8 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
|
||||
bool bRequiredownsize;
|
||||
|
||||
bIsIndivBold = freetype_face->style_flags & FT_STYLE_FLAG_BOLD; //是独立粗体
|
||||
bIsBold = (IsFontBold(lf) && !bIsIndivBold); //是仿粗体
|
||||
bIsIndivBold = freetype_face->style_flags & FT_STYLE_FLAG_BOLD; //是独立粗体
|
||||
bIsBold = (IsFontBold(lf) && !bIsIndivBold); //是仿粗体
|
||||
bRequiredownsize = bIsBold && /*(pSettings->BolderMode()==2 || (*/pSettings->BolderMode()!=1 /*&& FTInfo.height>FT_BOLD_LOW))*/;
|
||||
if (bRequiredownsize)
|
||||
{
|
||||
@ -1877,7 +1877,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
int dx = clpdx.get(bWidthGDI32 ? gdi32x : cx); //サ<>テソ昮ネ
|
||||
int left = FT_BitmapGlyph((*glyph_bitmap))->left;
|
||||
if (FTInfo.x + left< FTInfo.xBase)
|
||||
FTInfo.xBase = FTInfo.x + left; //如果有字符是负数起始位置的(合成符号), 调整文字的起始位置
|
||||
FTInfo.xBase = FTInfo.x + left; //如果有字符是负数起始位置的(合成符号), 调整文字的起始位置
|
||||
|
||||
if (lpString < lpEnd - 1) {
|
||||
FTInfo.x += dx;
|
||||
@ -1885,7 +1885,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
int bx = FT_BitmapGlyph((*glyph_bitmap))->bitmap.width;
|
||||
if (render_mode == FT_RENDER_MODE_LCD) bx /= 3;
|
||||
bx += left;
|
||||
FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //有文字的情况下,绘图宽度=ft计算的宽度,鼠标位置=win宽度
|
||||
FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //有文字的情况下,绘图宽度=ft计算的宽度,鼠标位置=win宽度
|
||||
FTInfo.x += dx;//Max(dx, gdi32x);//Max(Max(dx, bx), cx);
|
||||
}
|
||||
|
||||
@ -1931,7 +1931,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
BOOL bWindowsLink = pSettings->FontLink()==2;
|
||||
//!!Snowie
|
||||
|
||||
/*const*/ FT_Face freetype_face = FTInfo.freetype_face; //去掉常量属性,下面要改他
|
||||
/*const*/ FT_Face freetype_face = FTInfo.freetype_face; //去掉常量属性,下面要改他
|
||||
const FT_Int cmap_index = FTInfo.cmap_index;
|
||||
const FT_Bool useKerning = FTInfo.useKerning;
|
||||
FT_Render_Mode render_mode = FTInfo.render_mode;
|
||||
@ -1988,7 +1988,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
ZeroMemory(lpfontlink[i], sizeof(WORD)*cbString); //ウ<>シサッホェボチエスモ
|
||||
}
|
||||
//
|
||||
hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //加载第一个字体
|
||||
hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //加载第一个字体
|
||||
}
|
||||
//fontlink
|
||||
|
||||
@ -2020,7 +2020,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!bGlyphIndex) //仅对win32情况进行优化,ft情况另议
|
||||
if (!bGlyphIndex) //仅对win32情况进行优化,ft情况另议
|
||||
if (GetGlyphIndices(FTInfo.hdc, lpString, cbString, gi, GGI_MARK_NONEXISTING_GLYPHS)!=cbString)
|
||||
{
|
||||
nRet = false;
|
||||
@ -2029,7 +2029,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
//!!Snowie
|
||||
int* Dx= FTInfo.Dx;
|
||||
if (!bAllowDefaultLink && FTInfo.face_id_list_num > 1)
|
||||
FTInfo.face_id_list_num--; //如果是symbol页那就不链接到宋体
|
||||
FTInfo.face_id_list_num--; //如果是symbol页那就不链接到宋体
|
||||
|
||||
for (int i=0 ; lpString < lpEnd; ++lpString, gi++, GlyphArray++, drState++, ++AAList,/*ggdi32++,*/ i++){
|
||||
WCHAR wch = *lpString;
|
||||
@ -2078,7 +2078,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
*AAList = AAMode;
|
||||
glyph_index = wch;
|
||||
ggoformat |= GGO_GLYPH_INDEX;
|
||||
GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index的文字必须计算宽度
|
||||
GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index的文字必须计算宽度
|
||||
} else
|
||||
{
|
||||
if (*(gi) != 0xffff) {
|
||||
@ -2104,7 +2104,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
}
|
||||
|
||||
|
||||
if (!f_glyph) { //glyphindex的文字上面已经计算过了
|
||||
if (!f_glyph) { //glyphindex的文字上面已经计算过了
|
||||
#ifdef _DEBUG
|
||||
GdiSetBatchLimit(0);
|
||||
#endif
|
||||
@ -2139,7 +2139,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
GetCharABCWidthsI(FTInfo.hdc, wch, 1, NULL, &abc);
|
||||
else
|
||||
GetCharABCWidths(FTInfo.hdc, wch, wch, &abc);*/
|
||||
//FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //无效文字的情况下,绘图宽度=鼠标位置
|
||||
//FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //无效文字的情况下,绘图宽度=鼠标位置
|
||||
FTInfo.px = FTInfo.x + cx;
|
||||
FTInfo.x += clpdx.get(cx);
|
||||
}
|
||||
@ -2171,7 +2171,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
}
|
||||
}else{
|
||||
if (bVertical)
|
||||
swap(FTInfo.font_type.height, FTInfo.font_type.width); //交换无法旋转的文字宽高
|
||||
swap(FTInfo.font_type.height, FTInfo.font_type.width); //交换无法旋转的文字宽高
|
||||
FTInfo.font_type.flags &=~FT_LOAD_VERTICAL_LAYOUT;
|
||||
if(bLcdMode){
|
||||
if(!bLightLcdMode){
|
||||
@ -2264,7 +2264,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
int dx = clpdx.get(bWidthGDI32 ? gdi32x : cx); //サ<>テソ昮ネ
|
||||
int left = FT_BitmapGlyph((*glyph_bitmap))->left;
|
||||
if (FTInfo.x + left< FTInfo.xBase)
|
||||
FTInfo.xBase = FTInfo.x + left; //如果有字符是负数起始位置的(合成符号), 调整文字的起始位置
|
||||
FTInfo.xBase = FTInfo.x + left; //如果有字符是负数起始位置的(合成符号), 调整文字的起始位置
|
||||
|
||||
if (lpString < lpEnd - 1) {
|
||||
FTInfo.x += dx;
|
||||
@ -2272,7 +2272,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
int bx = FT_BitmapGlyph((*glyph_bitmap))->bitmap.width;
|
||||
if (render_mode == FT_RENDER_MODE_LCD) bx /= 3;
|
||||
bx += left;
|
||||
FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //有文字的情况下,绘图宽度=ft计算的宽度,鼠标位置=win宽度
|
||||
FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //有文字的情况下,绘图宽度=ft计算的宽度,鼠标位置=win宽度
|
||||
FTInfo.x += dx;//Max(dx, gdi32x);//Max(Max(dx, bx), cx);
|
||||
}
|
||||
|
||||
@ -2340,7 +2340,7 @@ BOOL CALLBACK TextOutCallback(FreeTypeGlyphInfo& FTGInfo)
|
||||
|
||||
if (!FTGInfo.FTGlyph->bitmap.buffer) {
|
||||
//if (FTInfo->params->alpha == 1) {
|
||||
// if (!(FTInfo->GetETO() & ETO_GLYPH_INDEX) && wch==32) //空格
|
||||
// if (!(FTInfo->GetETO() & ETO_GLYPH_INDEX) && wch==32) //空格
|
||||
// ORIG_ExtTextOutW(FTInfo->hdc, FTInfo->x, FTInfo->yTop, FTInfo->GetETO() & ETO_IGNORELANGUAGE, NULL, &wch, 1, NULL);
|
||||
// else
|
||||
ORIG_ExtTextOutW(FTInfo->hdc, FTInfo->x, FTInfo->yTop, FTInfo->GetETO(), NULL, &FTGInfo.wch, 1, NULL);
|
||||
@ -2381,10 +2381,10 @@ int IsColorDark(DWORD Color, double Gamma)
|
||||
//return (GetRValue(Color)*0.299 + GetGValue(Color)*0.587 + GetBValue(Color)*0.114); //ヤュハシヒ羚ィ
|
||||
//===============================================================
|
||||
//イノモテPhotoshop sRGBオトRGB->Labヒ羚ィス<EFBDA8>ミササヒ罐ャLホェノォイハハモセ<EFBE93>チカネ
|
||||
//感谢 西安理工大学 贾婉丽 的分析
|
||||
//感谢 西安理工大学 贾婉丽 的分析
|
||||
//===============================================================
|
||||
static double s_multipler = 116/pow(100,(double)1.0/3.0); //预计算常数,强制使用double版本
|
||||
double* RGBTable = s_AlphaBlendTable.GetRGBTable(); //获得显示器转换表
|
||||
static double s_multipler = 116/pow(100,(double)1.0/3.0); //预计算常数,强制使用double版本
|
||||
double* RGBTable = s_AlphaBlendTable.GetRGBTable(); //获得显示器转换表
|
||||
double ret = pow(23.9746*RGBTable[GetRValue(Color)] + 73.0653*RGBTable[GetGValue(Color)] + 6.13799*RGBTable[GetBValue(Color)] , 1.0/3.0)*s_multipler-16;
|
||||
return max(int(ret + 0.499),0);
|
||||
|
||||
@ -2475,7 +2475,7 @@ BOOL FreeTypeTextOut(
|
||||
const TEXTMETRIC& tm = FTInfo.params->otm->otmTextMetrics;
|
||||
FTInfo.yBase = tm.tmAscent;
|
||||
|
||||
//===============计算颜色缓存======================
|
||||
//===============计算颜色缓存======================
|
||||
|
||||
const CGdippSettings* pSettings = CGdippSettings::GetInstance();
|
||||
int lightdiff, darkdiff, bDarkColor=0, ShadowColor=0;
|
||||
@ -2523,7 +2523,7 @@ BOOL FreeTypeTextOut(
|
||||
break;
|
||||
}
|
||||
|
||||
//===============计算完成==========================
|
||||
//===============计算完成==========================
|
||||
|
||||
FreeTypeGlyphInfo FTGInfo = {&FTInfo, 0, 0, 0, solid, shadow};
|
||||
for (int i=0; i<cbString; ++i, ++lpString)
|
||||
|
102
ft.cpp
102
ft.cpp
@ -4,19 +4,19 @@
|
||||
*/
|
||||
/* 2006-10-27(by 555)
|
||||
* http://hp.vector.co.jp/authors/VA028002/freetype.html (higambana(ンムメーモムシo))
|
||||
* を参考にしてやり直し
|
||||
* を参考にしてやり直し
|
||||
*/
|
||||
/* 2006-10-29(by 555)
|
||||
* 693氏(と呼ぶことにする)の精力的な活動によって出来上がったウハウハソースと
|
||||
* 上記サイトの変更点を元にみみっちい修正。(ベースgdi0164)
|
||||
* 693氏(と呼ぶことにする)の精力的な活動によって出来上がったウハウハソースと
|
||||
* 上記サイトの変更点を元にみみっちい修正。(ベースgdi0164)
|
||||
*/
|
||||
/* (by 555)
|
||||
* さらに線引きもウハウハにしてもらったgdi0168を元に
|
||||
* イタリックとボールドを追加。
|
||||
* さらに線引きもウハウハにしてもらったgdi0168を元に
|
||||
* イタリックとボールドを追加。
|
||||
*/
|
||||
/* (by sy567)
|
||||
* 太字のアルゴリズムを変更。
|
||||
* ガンマ補正を実装してみる。
|
||||
* 太字のアルゴリズムを変更。
|
||||
* ガンマ補正を実装してみる。
|
||||
*/
|
||||
#include "override.h"
|
||||
#include "ft.h"
|
||||
@ -64,7 +64,7 @@ ControlIder CID;
|
||||
#endif
|
||||
|
||||
|
||||
//更新
|
||||
//更新
|
||||
#define RGBA(r,g,b,a) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)|(((DWORD)(BYTE)(a))<<24)))
|
||||
//!!Snowie
|
||||
|
||||
@ -176,7 +176,7 @@ static CAlphaBlend s_AlphaBlendTable;
|
||||
|
||||
void CAlphaBlend::gettunetbl(int paramalpha, BOOL lcd, BOOL dark, const int * &tblR, const int * &tblG, const int * &tblB) const
|
||||
{
|
||||
if (paramalpha == 1) { //获取文字混合表
|
||||
if (paramalpha == 1) { //获取文字混合表
|
||||
if (lcd) {
|
||||
tblR = tunetblR.data();
|
||||
tblG = tunetblG.data();
|
||||
@ -186,7 +186,7 @@ void CAlphaBlend::gettunetbl(int paramalpha, BOOL lcd, BOOL dark, const int * &t
|
||||
tblR = tblG = tblB = tunetbl.data();
|
||||
}
|
||||
}
|
||||
else { //获取阴影混合表
|
||||
else { //获取阴影混合表
|
||||
if (dark)
|
||||
{
|
||||
if (lcd) {
|
||||
@ -289,12 +289,12 @@ void CAlphaBlend::init()
|
||||
tunetblS[i] = Bound(0, alphatbl[Bound(table[i] * paramalpha / 100, 0, 255)], CAlphaBlend::BASE);
|
||||
tunetblRS[i] = Bound(0, alphatbl[Bound(tableR[i] * paramalpha / 100, 0, 255)], CAlphaBlend::BASE);
|
||||
tunetblGS[i] = Bound(0, alphatbl[Bound(tableG[i] * paramalpha / 100, 0, 255)], CAlphaBlend::BASE);
|
||||
tunetblBS[i] = Bound(0, alphatbl[Bound(tableB[i] * paramalpha / 100, 0, 255)], CAlphaBlend::BASE); //浅色混合表
|
||||
tunetblBS[i] = Bound(0, alphatbl[Bound(tableB[i] * paramalpha / 100, 0, 255)], CAlphaBlend::BASE); //浅色混合表
|
||||
|
||||
tunetblLS[i] = Bound(0, alphatbl[Bound(table[i] * lightparamalpha / 100, 0, 255)], CAlphaBlend::BASE);
|
||||
tunetblLRS[i] = Bound(0, alphatbl[Bound(tableR[i] * lightparamalpha / 100, 0, 255)], CAlphaBlend::BASE);
|
||||
tunetblLGS[i] = Bound(0, alphatbl[Bound(tableG[i] * lightparamalpha / 100, 0, 255)], CAlphaBlend::BASE);
|
||||
tunetblLBS[i] = Bound(0, alphatbl[Bound(tableB[i] * lightparamalpha / 100, 0, 255)], CAlphaBlend::BASE); //深色混合表
|
||||
tunetblLBS[i] = Bound(0, alphatbl[Bound(tableB[i] * lightparamalpha / 100, 0, 255)], CAlphaBlend::BASE); //深色混合表
|
||||
}
|
||||
}
|
||||
|
||||
@ -1326,7 +1326,7 @@ BOOL FreeTypePrepare(FreeTypeDrawInfo& FTInfo)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
FTInfo.params->lplf->lfWeight = FTInfo.params->otm->otmTextMetrics.tmWeight; //更新到标准weight
|
||||
FTInfo.params->lplf->lfWeight = FTInfo.params->otm->otmTextMetrics.tmWeight; //更新到标准weight
|
||||
pfs = &pfi->GetFontSettings();
|
||||
|
||||
cmap_index = -1;
|
||||
@ -1464,7 +1464,7 @@ BOOL FreeTypePrepare(FreeTypeDrawInfo& FTInfo)
|
||||
break;
|
||||
}
|
||||
|
||||
//如果含有内置hinting则启用default模式,否则使用autohint模式,以保证效果
|
||||
//如果含有内置hinting则启用default模式,否则使用autohint模式,以保证效果
|
||||
// アンチエイリアス
|
||||
if (FTInfo.IsMono()) {
|
||||
font_type.flags |= FT_LOAD_TARGET_MONO;
|
||||
@ -1500,7 +1500,7 @@ BOOL FreeTypePrepare(FreeTypeDrawInfo& FTInfo)
|
||||
if (pSettings->HintSmallFont() /*&& font_type.flags & FT_LOAD_TARGET_LIGHT*/ && font_type.height != -1 && font_type.height<12) //ヘィモテノ靹テイサハケモテhinting」ャオォハヌエ<EFBE87>ェチヒミ。ラヨフ乕intingソェケリ
|
||||
{
|
||||
/*
|
||||
if (!(freetype_face->face_flags & FT_FACE_FLAG_TRICKY)) //如果不是tricky字体
|
||||
if (!(freetype_face->face_flags & FT_FACE_FLAG_TRICKY)) //如果不是tricky字体
|
||||
font_type.flags = font_type.flags & (~FT_LOAD_NO_HINTING) | (pfi->FontHasHinting() ? FT_LOAD_NO_AUTOHINT : FT_LOAD_FORCE_AUTOHINT);
|
||||
else*/
|
||||
|
||||
@ -1636,7 +1636,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
BOOL bWindowsLink = pSettings->FontLink() == 2;
|
||||
//!!Snowie
|
||||
|
||||
/*const*/ FT_Face freetype_face = FTInfo.freetype_face; //去掉常量属性,下面要改他
|
||||
/*const*/ FT_Face freetype_face = FTInfo.freetype_face; //去掉常量属性,下面要改他
|
||||
const FT_Int cmap_index = FTInfo.cmap_index;
|
||||
const FT_Bool useKerning = FTInfo.useKerning;
|
||||
FT_Render_Mode render_mode = FTInfo.render_mode;
|
||||
@ -1685,14 +1685,14 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
ZeroMemory(lpfontlink[i], sizeof(WORD)*cbString); //ウ<>シサッホェボチエスモ
|
||||
}
|
||||
//
|
||||
hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //加载第一个字体
|
||||
hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //加载第一个字体
|
||||
}
|
||||
//fontlink
|
||||
|
||||
int* Dx = FTInfo.Dx;
|
||||
int* Dy = FTInfo.Dy;
|
||||
if (!bAllowDefaultLink && FTInfo.face_id_list_num > 1)
|
||||
FTInfo.face_id_list_num--; //如果是symbol页那就不链接到宋体
|
||||
FTInfo.face_id_list_num--; //如果是symbol页那就不链接到宋体
|
||||
|
||||
bool bUnicodePlane = false;
|
||||
for (int i = 0; lpString < lpEnd; ++lpString, ++gi, ++GlyphArray, ++drState, ++AAList, /*ggdi32++,*/ i++) {
|
||||
@ -1752,7 +1752,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
f_glyph = !!wch;
|
||||
glyph_index = wch;
|
||||
*AAList = AAMode;
|
||||
GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index的文字必须计算宽度
|
||||
GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index的文字必须计算宽度
|
||||
if (FTInfo.font_type.height <= pSettings->BitmapHeight() && pfi->EmbeddedBmpExist(FTInfo.font_type.height))
|
||||
{
|
||||
f_glyph = false; //ハケモテオ耻<EFBDB5>ャイササ賚シ
|
||||
@ -1763,11 +1763,11 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
if (wch && !CID.myiswcntrl(lpString[0])) { // need to draw a non-control character
|
||||
for (int j = 0; j < FTInfo.face_id_list_num; ++j) {
|
||||
freetype_face = NULL; // reinitialize it in case no fontlinking is available.
|
||||
if (bWindowsLink) //使用Windows函数进行fontlink
|
||||
if (bWindowsLink) //使用Windows函数进行fontlink
|
||||
{
|
||||
if (!lpfontlink[j][i]) //サケテサウ<EFBDBB>シサックテラヨフ蠏トfontlink
|
||||
{
|
||||
SelectFont(FTInfo.hdc, FTInfo.ggo_font_list[j]); //加载ggo字体
|
||||
SelectFont(FTInfo.hdc, FTInfo.ggo_font_list[j]); //加载ggo字体
|
||||
GetGlyphIndices(FTInfo.hdc, lpString, cbString - i, &lpfontlink[j][i], GGI_MARK_NONEXISTING_GLYPHS); //ス<>ミfontlink
|
||||
SelectFont(FTInfo.hdc, hOldFont);
|
||||
}
|
||||
@ -1785,8 +1785,8 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
GetCharWidth32W(FTInfo.hdc, wch, wch, &gdi32x); //モミミァホトラヨ」ャシニヒ譱昮ネ
|
||||
f_glyph = true;
|
||||
FTInfo.font_type.face_id = FTInfo.face_id_list[j];
|
||||
freetype_face = FTInfo.GetFace(j); //同时更新对应faceid的实际face
|
||||
//接下来更新对应的fontsetting
|
||||
freetype_face = FTInfo.GetFace(j); //同时更新对应faceid的实际face
|
||||
//接下来更新对应的fontsetting
|
||||
FTInfo.font_type.flags = FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
|
||||
// ヒンティング
|
||||
//extern CFontSetCache g_fsetcache;
|
||||
@ -1795,7 +1795,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
{
|
||||
switch (FTInfo.font_type.height)
|
||||
{
|
||||
case 11: {FTInfo.font_type.height = 12; FTInfo.font_type.width++; break; } //对宋体进行特殊处理
|
||||
case 11: {FTInfo.font_type.height = 12; FTInfo.font_type.width++; break; } //对宋体进行特殊处理
|
||||
case 13: {FTInfo.font_type.height = 15; FTInfo.font_type.width += 2; break; }
|
||||
}
|
||||
}
|
||||
@ -1851,7 +1851,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
AAMode = *AAList/*pfs->GetAntiAliasMode()*/;
|
||||
bLcdMode = render_mode == FT_RENDER_MODE_LCD;
|
||||
bLightLcdMode = (AAMode == 4) || (AAMode == 5);
|
||||
//更新完成
|
||||
//更新完成
|
||||
}
|
||||
if (FTInfo.font_type.height <= pSettings->BitmapHeight() && pfi->EmbeddedBmpExist(FTInfo.font_type.height))
|
||||
{
|
||||
@ -1906,7 +1906,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
|
||||
if (isc == CNTRL_COMPLEX_TEXT) //ソリヨニラヨ
|
||||
{
|
||||
cx = dxWidth; //服从windows的宽度调度
|
||||
cx = dxWidth; //服从windows的宽度调度
|
||||
//if (!dxWidth)
|
||||
// CID.setcntrlAttribute(wch, CNTRL_ZERO_WIDTH);
|
||||
}
|
||||
@ -1923,7 +1923,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
GetCharABCWidthsI(FTInfo.hdc, wch, 1, NULL, &abc);
|
||||
else
|
||||
GetCharABCWidths(FTInfo.hdc, wch, wch, &abc);*/
|
||||
//FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //无效文字的情况下,绘图宽度=鼠标位置
|
||||
//FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //无效文字的情况下,绘图宽度=鼠标位置
|
||||
FTInfo.px = FTInfo.x + cx;
|
||||
FTInfo.x += dxWidth;//Max(clpdx.get(cx), cx);/*(int)abc.abcB+abc.abcC*///Max(clpdx.get(cx), abc.abcB? abc.abcA:0);
|
||||
//}
|
||||
@ -1954,7 +1954,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
}
|
||||
|
||||
|
||||
// 縦横
|
||||
// 縦横
|
||||
if (bVertical && IsVerticalChar(wch)) {
|
||||
FTInfo.font_type.flags |= FT_LOAD_VERTICAL_LAYOUT;
|
||||
if (bLcdMode) {
|
||||
@ -1967,7 +1967,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
}
|
||||
else {
|
||||
if (bVertical)
|
||||
swap(FTInfo.font_type.height, FTInfo.font_type.width); //交换无法旋转的文字宽高
|
||||
swap(FTInfo.font_type.height, FTInfo.font_type.width); //交换无法旋转的文字宽高
|
||||
FTInfo.font_type.flags &= ~FT_LOAD_VERTICAL_LAYOUT;
|
||||
if (bLcdMode) {
|
||||
if (FTInfo.font_type.flags&FT_LOAD_TARGET_LCD_V == FT_LOAD_TARGET_LCD_V) {
|
||||
@ -1982,8 +1982,8 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
|
||||
bool bRequiredownsize;
|
||||
|
||||
bIsIndivBold = freetype_face->style_flags & FT_STYLE_FLAG_BOLD; //是独立粗体
|
||||
bIsBold = (IsFontBold(lf) && !bIsIndivBold); //是仿粗体
|
||||
bIsIndivBold = freetype_face->style_flags & FT_STYLE_FLAG_BOLD; //是独立粗体
|
||||
bIsBold = (IsFontBold(lf) && !bIsIndivBold); //是仿粗体
|
||||
bRequiredownsize = bIsBold && /*(pSettings->BolderMode()==2 || (*/pSettings->BolderMode() != 1 /*&& FTInfo.height>FT_BOLD_LOW))*/;
|
||||
if (bRequiredownsize)
|
||||
{
|
||||
@ -2092,7 +2092,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
}
|
||||
else {
|
||||
if (FTInfo.x + left < FTInfo.xBase)
|
||||
FTInfo.xBase = FTInfo.x + left; //如果有字符是负数起始位置的(合成符号), 调整文字的起始位置
|
||||
FTInfo.xBase = FTInfo.x + left; //如果有字符是负数起始位置的(合成符号), 调整文字的起始位置
|
||||
}
|
||||
|
||||
if (lpString < lpEnd - 1) {
|
||||
@ -2103,7 +2103,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
int bx = FT_BitmapGlyph((*glyph_bitmap)->ft_glyph)->bitmap.width;
|
||||
if (render_mode == FT_RENDER_MODE_LCD && FT_BitmapGlyph((*glyph_bitmap)->ft_glyph)->bitmap.pixel_mode != FT_PIXEL_MODE_BGRA) bx /= 3;
|
||||
bx += left;
|
||||
FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //有文字的情况下,绘图宽度=ft计算的宽度,鼠标位置=win宽度
|
||||
FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //有文字的情况下,绘图宽度=ft计算的宽度,鼠标位置=win宽度
|
||||
FTInfo.x += dx;//Max(dx, gdi32x);//Max(Max(dx, bx), cx);
|
||||
}
|
||||
|
||||
@ -2124,7 +2124,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString,
|
||||
|
||||
cont:
|
||||
*Dx = FTInfo.x; //Dxオトホサヨテハヌマツメサク<EFBDBB>ヨキ釤ェハシオトサ<EFBE84>シホサヨテ」ャイ「イサハヌマツメサク<EFBDBB>ヨキ釤ェハシサュオトホサヨテ
|
||||
*Dy = FTInfo.y; //Dy的位置是下一个字符的y坐标
|
||||
*Dy = FTInfo.y; //Dy的位置是下一个字符的y坐标
|
||||
++Dx;
|
||||
++Dy;
|
||||
}
|
||||
@ -2152,7 +2152,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
BOOL bWindowsLink = pSettings->FontLink() == 2;
|
||||
//!!Snowie
|
||||
|
||||
/*const*/ FT_Face freetype_face = FTInfo.freetype_face; //去掉常量属性,下面要改他
|
||||
/*const*/ FT_Face freetype_face = FTInfo.freetype_face; //去掉常量属性,下面要改他
|
||||
const FT_Int cmap_index = FTInfo.cmap_index;
|
||||
const FT_Bool useKerning = FTInfo.useKerning;
|
||||
FT_Render_Mode render_mode = FTInfo.render_mode;
|
||||
@ -2209,7 +2209,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
ZeroMemory(lpfontlink[i], sizeof(WORD)*cbString); //ウ<>シサッホェボチエスモ
|
||||
}
|
||||
//
|
||||
hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //加载第一个字体
|
||||
hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //加载第一个字体
|
||||
}
|
||||
//fontlink
|
||||
|
||||
@ -2241,7 +2241,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!bGlyphIndex) //仅对win32情况进行优化,ft情况另议
|
||||
if (!bGlyphIndex) //仅对win32情况进行优化,ft情况另议
|
||||
if (GetGlyphIndices(FTInfo.hdc, lpString, cbString, gi, GGI_MARK_NONEXISTING_GLYPHS) != cbString)
|
||||
{
|
||||
nRet = false;
|
||||
@ -2251,7 +2251,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
int* Dx = FTInfo.Dx;
|
||||
int* Dy = FTInfo.Dy;
|
||||
if (!bAllowDefaultLink && FTInfo.face_id_list_num > 1)
|
||||
FTInfo.face_id_list_num--; //如果是symbol页那就不链接到宋体
|
||||
FTInfo.face_id_list_num--; //如果是symbol页那就不链接到宋体
|
||||
|
||||
for (int i = 0; lpString < lpEnd; ++lpString, gi++, GlyphArray++, drState++, ++AAList,/*ggdi32++,*/ i++) {
|
||||
WCHAR wch = *lpString;
|
||||
@ -2300,7 +2300,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
*AAList = AAMode;
|
||||
glyph_index = wch;
|
||||
ggoformat |= GGO_GLYPH_INDEX;
|
||||
GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index的文字必须计算宽度
|
||||
GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index的文字必须计算宽度
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2328,7 +2328,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
}
|
||||
|
||||
|
||||
if (!f_glyph) { //glyphindex的文字上面已经计算过了
|
||||
if (!f_glyph) { //glyphindex的文字上面已经计算过了
|
||||
#ifdef _DEBUG
|
||||
GdiSetBatchLimit(0);
|
||||
#endif
|
||||
@ -2365,7 +2365,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
GetCharABCWidthsI(FTInfo.hdc, wch, 1, NULL, &abc);
|
||||
else
|
||||
GetCharABCWidths(FTInfo.hdc, wch, wch, &abc);*/
|
||||
//FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //无效文字的情况下,绘图宽度=鼠标位置
|
||||
//FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //无效文字的情况下,绘图宽度=鼠标位置
|
||||
FTInfo.px = FTInfo.x + cx;
|
||||
FTInfo.x += clpdx.get(cx);
|
||||
}
|
||||
@ -2398,7 +2398,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
}
|
||||
else {
|
||||
if (bVertical)
|
||||
swap(FTInfo.font_type.height, FTInfo.font_type.width); //交换无法旋转的文字宽高
|
||||
swap(FTInfo.font_type.height, FTInfo.font_type.width); //交换无法旋转的文字宽高
|
||||
FTInfo.font_type.flags &= ~FT_LOAD_VERTICAL_LAYOUT;
|
||||
if (bLcdMode) {
|
||||
if (FTInfo.font_type.flags&FT_LOAD_TARGET_LCD_V == FT_LOAD_TARGET_LCD_V) {
|
||||
@ -2492,7 +2492,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
int dx = clpdx.get(bWidthGDI32 ? gdi32x : cx); //サ<>テソ昮ネ
|
||||
int left = FT_BitmapGlyph((*glyph_bitmap)->ft_glyph)->left;
|
||||
if (FTInfo.x + left< FTInfo.xBase)
|
||||
FTInfo.xBase = FTInfo.x + left; //如果有字符是负数起始位置的(合成符号), 调整文字的起始位置
|
||||
FTInfo.xBase = FTInfo.x + left; //如果有字符是负数起始位置的(合成符号), 调整文字的起始位置
|
||||
|
||||
if (lpString < lpEnd - 1) {
|
||||
FTInfo.x += dx;
|
||||
@ -2502,7 +2502,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString
|
||||
int bx = FT_BitmapGlyph((*glyph_bitmap)->ft_glyph)->bitmap.width;
|
||||
if (render_mode == FT_RENDER_MODE_LCD) bx /= 3;
|
||||
bx += left;
|
||||
FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //有文字的情况下,绘图宽度=ft计算的宽度,鼠标位置=win宽度
|
||||
FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //有文字的情况下,绘图宽度=ft计算的宽度,鼠标位置=win宽度
|
||||
FTInfo.x += dx;//Max(dx, gdi32x);//Max(Max(dx, bx), cx);
|
||||
}
|
||||
|
||||
@ -2573,7 +2573,7 @@ BOOL CALLBACK TextOutCallback(FreeTypeGlyphInfo& FTGInfo)
|
||||
|
||||
if (!FTGInfo.FTGlyph->bitmap.buffer) {
|
||||
//if (FTInfo->params->alpha == 1) {
|
||||
// if (!(FTInfo->GetETO() & ETO_GLYPH_INDEX) && wch==32) //空格
|
||||
// if (!(FTInfo->GetETO() & ETO_GLYPH_INDEX) && wch==32) //空格
|
||||
// ORIG_ExtTextOutW(FTInfo->hdc, FTInfo->x, FTInfo->yTop, FTInfo->GetETO() & ETO_IGNORELANGUAGE, NULL, &wch, 1, NULL);
|
||||
// else
|
||||
ORIG_ExtTextOutW(FTInfo->hdc, FTInfo->x, FTInfo->yTop, FTInfo->GetETO(), NULL, &FTGInfo.wch, 1, NULL);
|
||||
@ -2624,10 +2624,10 @@ int IsColorDark(DWORD Color, double Gamma)
|
||||
//return (GetRValue(Color)*0.299 + GetGValue(Color)*0.587 + GetBValue(Color)*0.114); //ヤュハシヒ羚ィ
|
||||
//===============================================================
|
||||
//イノモテPhotoshop sRGBオトRGB->Labヒ羚ィス<EFBDA8>ミササヒ罐ャLホェノォイハハモセ<EFBE93>チカネ
|
||||
//感谢 西安理工大学 贾婉丽 的分析
|
||||
//感谢 西安理工大学 贾婉丽 的分析
|
||||
//===============================================================
|
||||
static double s_multipler = 116 / pow(100, (double)1.0 / 3.0); //预计算常数,强制使用double版本
|
||||
double* RGBTable = s_AlphaBlendTable.GetRGBTable(); //获得显示器转换表
|
||||
static double s_multipler = 116 / pow(100, (double)1.0 / 3.0); //预计算常数,强制使用double版本
|
||||
double* RGBTable = s_AlphaBlendTable.GetRGBTable(); //获得显示器转换表
|
||||
double ret = pow(23.9746*RGBTable[GetRValue(Color)] + 73.0653*RGBTable[GetGValue(Color)] + 6.13799*RGBTable[GetBValue(Color)], 1.0 / 3.0)*s_multipler - 16;
|
||||
return max(int(ret + 0.499), 0);
|
||||
|
||||
@ -2718,7 +2718,7 @@ BOOL FreeTypeTextOut(
|
||||
const TEXTMETRIC& tm = FTInfo.params->otm->otmTextMetrics;
|
||||
FTInfo.yBase = tm.tmAscent;
|
||||
|
||||
//===============计算颜色缓存======================
|
||||
//===============计算颜色缓存======================
|
||||
|
||||
const CGdippSettings* pSettings = CGdippSettings::GetInstance();
|
||||
int lightdiff, darkdiff, bDarkColor = 0, ShadowColor = 0;
|
||||
@ -2766,7 +2766,7 @@ BOOL FreeTypeTextOut(
|
||||
break;
|
||||
}
|
||||
|
||||
//计算下划线或删除线的信息
|
||||
//计算下划线或删除线的信息
|
||||
int decorationInfo_height;
|
||||
int decorationInfo_thickness;
|
||||
OUTLINETEXTMETRIC &decorationInfo_otm = *FTInfo.params->otm;
|
||||
@ -2803,7 +2803,7 @@ BOOL FreeTypeTextOut(
|
||||
}
|
||||
}
|
||||
|
||||
//===============计算完成==========================
|
||||
//===============计算完成==========================
|
||||
|
||||
FreeTypeGlyphInfo FTGInfo = { &FTInfo, 0, 0, 0, solid, shadow, pSettings->InvertColor() };
|
||||
for (int i = 0; i<cbString; ++i, ++lpString)
|
||||
|
88
fteng.cpp
88
fteng.cpp
@ -13,9 +13,9 @@
|
||||
#define GC_TRACE TRACE
|
||||
#define FREETYPE_GC_COUNTER 128
|
||||
#else
|
||||
#define FREETYPE_REQCOUNTMAX 2048//默认4096,每缓存该数量的文字将刷新缓存降低内存占用
|
||||
#define FREETYPE_REQCOUNTMAX 2048//默认4096,每缓存该数量的文字将刷新缓存降低内存占用
|
||||
#define GC_TRACE NOP_FUNCTION
|
||||
#define FREETYPE_GC_COUNTER 1024//刷新缓存后保留文字数量
|
||||
#define FREETYPE_GC_COUNTER 1024//刷新缓存后保留文字数量
|
||||
#endif
|
||||
|
||||
FreeTypeFontEngine* g_pFTEngine;
|
||||
@ -56,7 +56,7 @@ bool GetFontLocalName(TCHAR* pszFontName, __out TCHAR* pszNameOut) //
|
||||
return lf.lfQuality == 0x2d;
|
||||
}
|
||||
|
||||
LOGFONTW* GetFontNameFromFile(LPCWSTR Filename) //获得一个字体文件内包含的所有字体名称s
|
||||
LOGFONTW* GetFontNameFromFile(LPCWSTR Filename) //获得一个字体文件内包含的所有字体名称s
|
||||
{
|
||||
LOGFONTW* logfonts = NULL;
|
||||
DWORD bufsize=0;
|
||||
@ -126,7 +126,7 @@ void CompactMap(T& pp, int count, int reduce)
|
||||
CCriticalSectionLock __lock(CCriticalSectionLock::CS_FONTCACHE);
|
||||
int reducecount = pp.size() - reduce;
|
||||
T::iterator it= pp.begin();
|
||||
for (int i=0;i<reducecount;i++) //删除超过FREETYPE_GC_COUNTER之后的缓存
|
||||
for (int i=0;i<reducecount;i++) //删除超过FREETYPE_GC_COUNTER之后的缓存
|
||||
{
|
||||
//it->second->Erase();
|
||||
delete it->second;
|
||||
@ -282,7 +282,7 @@ void FreeTypeFontCache::AddCharData(WCHAR wch, UINT glyphindex, int width, int g
|
||||
if (glyphindex & 0xffff0000 /*|| !g_ccbCache*/) {
|
||||
return;
|
||||
}
|
||||
if (AddIncrement() >= FREETYPE_REQCOUNTMAX) { //先压缩,避免压缩后丢失的问题
|
||||
if (AddIncrement() >= FREETYPE_REQCOUNTMAX) { //先压缩,避免压缩后丢失的问题
|
||||
Compact();
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ void FreeTypeFontCache::AddCharData(WCHAR wch, UINT glyphindex, int width, int g
|
||||
}
|
||||
#else
|
||||
GlyphCache::iterator it=m_GlyphCache.find(wch);
|
||||
if (it!=m_GlyphCache.end()) //找到了旧数据
|
||||
if (it!=m_GlyphCache.end()) //找到了旧数据
|
||||
{
|
||||
FreeTypeCharData* ppChar = it->second;
|
||||
if (ppChar) {
|
||||
@ -341,7 +341,7 @@ void FreeTypeFontCache::AddGlyphData(UINT glyphindex, int width, int gdiWidth, F
|
||||
}
|
||||
#else
|
||||
GlyphCache::iterator it=m_GlyphCache.find(-(int)glyphindex);
|
||||
if (it!=m_GlyphCache.end()) //找到了旧数据
|
||||
if (it!=m_GlyphCache.end()) //找到了旧数据
|
||||
{
|
||||
FreeTypeCharData* ppChar = it->second;
|
||||
if (ppChar) {
|
||||
@ -392,12 +392,12 @@ void FreeTypeFontInfo::Createlink()
|
||||
memset(&lf, 0, sizeof(LOGFONT));
|
||||
lf.lfCharSet=DEFAULT_CHARSET;
|
||||
const CGdippSettings* pSettings = CGdippSettings::GetInstance();
|
||||
for (fn.next() ; !fn.atend(); fn.next()) { //跳过第一个链接
|
||||
for (fn.next() ; !fn.atend(); fn.next()) { //跳过第一个链接
|
||||
//FreeTypeFontInfo* pfitemp = g_pFTEngine->FindFont(fn, m_weight, m_italic);
|
||||
//if (pfitemp && pfitemp->m_isSimSun)
|
||||
// IsSimSun = true;
|
||||
if (!m_SimSunID)
|
||||
IsSimSun = (_wcsicmp(fn,L"宋体")==0 || _wcsicmp(fn,L"SimSun")==0);
|
||||
IsSimSun = (_wcsicmp(fn,L"宋体")==0 || _wcsicmp(fn,L"SimSun")==0);
|
||||
StringCchCopy(lf.lfFaceName, LF_FACESIZE, fn);
|
||||
if (!_wcsicmp(fn, m_familyname.c_str())) // allow font link to itself
|
||||
pSettings->CopyForceFont(lf,lf);
|
||||
@ -419,19 +419,19 @@ bool FreeTypeFontInfo::EmbeddedBmpExist(int px)
|
||||
if (m_ebmps[px]!=-1)
|
||||
return !!m_ebmps[px];
|
||||
CCriticalSectionLock __lock(CCriticalSectionLock::CS_MANAGER);
|
||||
FTC_ImageTypeRec imgtype={(FTC_FaceID)m_id, px, px, FT_LOAD_DEFAULT}; //构造一个当前大小的imagetype
|
||||
FTC_ImageTypeRec imgtype={(FTC_FaceID)m_id, px, px, FT_LOAD_DEFAULT}; //构造一个当前大小的imagetype
|
||||
FT_Glyph temp_glyph=NULL;
|
||||
FT_UInt gindex = FTC_CMapCache_Lookup(cmap_cache, (FTC_FaceID)m_id, -1, FT_UInt32(L'0')); //获得0的索引值
|
||||
FT_UInt gindex = FTC_CMapCache_Lookup(cmap_cache, (FTC_FaceID)m_id, -1, FT_UInt32(L'0')); //获得0的索引值
|
||||
FTC_ImageCache_Lookup(image_cache, &imgtype, gindex, &temp_glyph, NULL);
|
||||
if (temp_glyph && temp_glyph->format==FT_GLYPH_FORMAT_BITMAP) //如果可以读到0的点阵
|
||||
m_ebmps[px]=1; //则该字号存在点阵
|
||||
if (temp_glyph && temp_glyph->format==FT_GLYPH_FORMAT_BITMAP) //如果可以读到0的点阵
|
||||
m_ebmps[px]=1; //则该字号存在点阵
|
||||
else
|
||||
{
|
||||
gindex = FTC_CMapCache_Lookup(cmap_cache, (FTC_FaceID)m_id, -1, FT_UInt32(L'的')); //获得"的"的索引值
|
||||
gindex = FTC_CMapCache_Lookup(cmap_cache, (FTC_FaceID)m_id, -1, FT_UInt32(L'的')); //获得"的"的索引值
|
||||
if (gindex)
|
||||
FTC_ImageCache_Lookup(image_cache, &imgtype, gindex, &temp_glyph, NULL); //读取“的”的点阵
|
||||
if (temp_glyph && temp_glyph->format==FT_GLYPH_FORMAT_BITMAP) //如果可以读到0的点阵
|
||||
m_ebmps[px]=1; //则该字号存在点阵
|
||||
FTC_ImageCache_Lookup(image_cache, &imgtype, gindex, &temp_glyph, NULL); //读取“的”的点阵
|
||||
if (temp_glyph && temp_glyph->format==FT_GLYPH_FORMAT_BITMAP) //如果可以读到0的点阵
|
||||
m_ebmps[px]=1; //则该字号存在点阵
|
||||
else
|
||||
m_ebmps[px]=0;
|
||||
}
|
||||
@ -442,7 +442,7 @@ FreeTypeFontCache* FreeTypeFontInfo::GetCache(FTC_ScalerRec& scaler, const LOGFO
|
||||
{
|
||||
CCriticalSectionLock __lock(CCriticalSectionLock::CS_FONTCACHE);
|
||||
|
||||
if (AddIncrement() > m_nMaxSizes) { //先压缩
|
||||
if (AddIncrement() > m_nMaxSizes) { //先压缩
|
||||
Compact();
|
||||
}
|
||||
int weight = lf.lfWeight;
|
||||
@ -472,7 +472,7 @@ FreeTypeFontCache* FreeTypeFontInfo::GetCache(FTC_ScalerRec& scaler, const LOGFO
|
||||
OK:
|
||||
Assert(p != NULL);
|
||||
if (p && p->Activate()) {
|
||||
DecIncrement(); //重复使用则减计数值
|
||||
DecIncrement(); //重复使用则减计数值
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@ -485,7 +485,7 @@ void FreeTypeFontEngine::Compact()
|
||||
|
||||
TRACE(_T("FreeTypeFontEngine::Compact: %d > %d\n"), m_mfontMap.size(), m_nMaxFaces);
|
||||
ResetGCCounter();
|
||||
//memset(m_arrFace, 0, sizeof(FT_Face)*m_nFaceCount); //超过最大face数了,老的face会被ft释放掉,所以需要全部重新获取
|
||||
//memset(m_arrFace, 0, sizeof(FT_Face)*m_nFaceCount); //超过最大face数了,老的face会被ft释放掉,所以需要全部重新获取
|
||||
//FontListArray& arr = m_arrFontList;
|
||||
//::Compact(arr.GetData(), arr.GetSize(), m_nMaxFaces);
|
||||
}
|
||||
@ -499,7 +499,7 @@ BOOL FreeTypeFontEngine::RemoveFont(FreeTypeFontInfo* fontinfo)
|
||||
{
|
||||
FreeTypeFontInfo* p = iter->second;
|
||||
if (p==fontinfo)
|
||||
m_mfontMap.erase(iter++); //删除引用
|
||||
m_mfontMap.erase(iter++); //删除引用
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
@ -510,7 +510,7 @@ BOOL FreeTypeFontEngine::RemoveFont(FreeTypeFontInfo* fontinfo)
|
||||
{
|
||||
FreeTypeFontInfo* p = iter->second;
|
||||
if (p==fontinfo)
|
||||
m_mfullMap.erase(iter++); //删除引用
|
||||
m_mfullMap.erase(iter++); //删除引用
|
||||
else
|
||||
{
|
||||
iter->second->UpdateFontSetting();
|
||||
@ -528,12 +528,12 @@ BOOL FreeTypeFontEngine::RemoveThisFont(FreeTypeFontInfo* fontinfo, LOGFONT* lg)
|
||||
{
|
||||
FontMap::const_iterator iter=m_mfontMap.find(myfont(lg->lfFaceName, CalcBoldWeight(lg->lfWeight), lg->lfItalic)); //遍历fontmap
|
||||
if (iter!=m_mfontMap.end())
|
||||
m_mfontMap.erase(iter); //删除引用
|
||||
m_mfontMap.erase(iter); //删除引用
|
||||
}
|
||||
{
|
||||
FullNameMap::const_iterator iter=m_mfullMap.find(fontinfo->GetFullName()); //遍历fullmap
|
||||
if (iter!=m_mfullMap.end())
|
||||
m_mfullMap.erase(iter); //删除引用
|
||||
m_mfullMap.erase(iter); //删除引用
|
||||
}
|
||||
delete fontinfo;
|
||||
return true;
|
||||
@ -543,11 +543,11 @@ BOOL FreeTypeFontEngine::RemoveFont(LPCWSTR FontName)
|
||||
{
|
||||
if (!FontName) return false;
|
||||
LOGFONTW* fontarray = GetFontNameFromFile(FontName);
|
||||
LOGFONTW* c_fontarray = fontarray; //记录原始指针
|
||||
LOGFONTW* c_fontarray = fontarray; //记录原始指针
|
||||
if (!fontarray) return false;
|
||||
FTC_FaceID fid = NULL;
|
||||
BOOL bIsFontLoaded, bIsFontFileLoaded = false;
|
||||
COwnedCriticalSectionLock __lock2(2, COwnedCriticalSectionLock::OCS_DC); //获取所有权,现在要处理DC,禁止所有绘图函数访问
|
||||
COwnedCriticalSectionLock __lock2(2, COwnedCriticalSectionLock::OCS_DC); //获取所有权,现在要处理DC,禁止所有绘图函数访问
|
||||
CCriticalSectionLock __lock(CCriticalSectionLock::CS_MANAGER);
|
||||
while (*(char*)fontarray)
|
||||
{
|
||||
@ -556,10 +556,10 @@ BOOL FreeTypeFontEngine::RemoveFont(LPCWSTR FontName)
|
||||
if (result)
|
||||
{
|
||||
fid = (FTC_FaceID)result->GetId();
|
||||
if (bIsFontLoaded) //该字体已经被使用过
|
||||
if (bIsFontLoaded) //该字体已经被使用过
|
||||
{
|
||||
RemoveFont(result); //枚举字体信息全部删除
|
||||
bIsFontFileLoaded = true; //设置字体文件也被使用过
|
||||
RemoveFont(result); //枚举字体信息全部删除
|
||||
bIsFontFileLoaded = true; //设置字体文件也被使用过
|
||||
}
|
||||
else
|
||||
RemoveThisFont(result, fontarray);
|
||||
@ -569,13 +569,13 @@ BOOL FreeTypeFontEngine::RemoveFont(LPCWSTR FontName)
|
||||
}
|
||||
fontarray++;
|
||||
}
|
||||
free(c_fontarray); //利用原始指针释放
|
||||
if (bIsFontFileLoaded) //若字体文件被使用过,则需要清楚所有DC
|
||||
free(c_fontarray); //利用原始指针释放
|
||||
if (bIsFontFileLoaded) //若字体文件被使用过,则需要清楚所有DC
|
||||
{
|
||||
CTLSDCArray::iterator iter = TLSDCArray.begin();
|
||||
while (iter!=TLSDCArray.end())
|
||||
{
|
||||
((CBitmapCache*)*iter)->~CBitmapCache(); //清除掉所有使用中的DC
|
||||
((CBitmapCache*)*iter)->~CBitmapCache(); //清除掉所有使用中的DC
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
@ -623,22 +623,22 @@ FreeTypeFontInfo* FreeTypeFontEngine::AddFont(void* lpparams)
|
||||
}*/
|
||||
|
||||
FullNameMap::const_iterator it = m_mfullMap.find(pfi->GetFullName());
|
||||
if (it!=m_mfullMap.end()) //是已经存在的字体了,原因是字体替换使两种名字指向一个字体
|
||||
if (it!=m_mfullMap.end()) //是已经存在的字体了,原因是字体替换使两种名字指向一个字体
|
||||
{
|
||||
delete pfi; //删除刚才创建的字体
|
||||
delete pfi; //删除刚才创建的字体
|
||||
ReleaseFaceID();
|
||||
pfi = it->second;//指向原字体
|
||||
pfi = it->second;//指向原字体
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mfullMap[pfi->GetFullName()]=pfi; //不存在,添加到map表
|
||||
m_mfullMap[pfi->GetFullName()]=pfi; //不存在,添加到map表
|
||||
m_mfontList.push_back(pfi);
|
||||
}
|
||||
|
||||
if (pfi->GetFullName()!=params->strFullName) //如果目标字体的真实名称和需要的名称不一样,说明是字体替换
|
||||
if (pfi->GetFullName()!=params->strFullName) //如果目标字体的真实名称和需要的名称不一样,说明是字体替换
|
||||
{
|
||||
pfi->AddRef(); //增加引用计数
|
||||
m_mfullMap[params->strFullName] = pfi; //双重引用,指向同一个字体
|
||||
pfi->AddRef(); //增加引用计数
|
||||
m_mfullMap[params->strFullName] = pfi; //双重引用,指向同一个字体
|
||||
}
|
||||
|
||||
//bool ret = !!arr.Add(pfi);
|
||||
@ -694,16 +694,16 @@ FreeTypeFontInfo* FreeTypeFontEngine::AddFont(LPCTSTR lpFaceName, int weight, bo
|
||||
FullNameMap::const_iterator it = m_mfullMap.find(pfi->GetFullName()); //是否在主map表中存在了
|
||||
if (it!=m_mfullMap.end()) //已经存在
|
||||
{
|
||||
delete pfi; //删除创建出来的字体
|
||||
delete pfi; //删除创建出来的字体
|
||||
ReleaseFaceID();
|
||||
pfi = it->second; //指向已经存在的字体
|
||||
pfi = it->second; //指向已经存在的字体
|
||||
if (bIsFontLoaded)
|
||||
*bIsFontLoaded = true;
|
||||
//pfi->AddRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mfullMap[pfi->GetFullName()]=pfi; //不存在,添加到map表
|
||||
m_mfullMap[pfi->GetFullName()]=pfi; //不存在,添加到map表
|
||||
m_mfontList.push_back(pfi);
|
||||
if (bIsFontLoaded)
|
||||
*bIsFontLoaded = false;
|
||||
@ -712,7 +712,7 @@ FreeTypeFontInfo* FreeTypeFontEngine::AddFont(LPCTSTR lpFaceName, int weight, bo
|
||||
//bool ret = !!arr.Add(pfi);
|
||||
//weight = weight < FW_BOLD ? 0: FW_BOLD;
|
||||
myfont font(lpFaceName, weight, italic);
|
||||
m_mfontMap[font]=pfi; //添加在次要map表
|
||||
m_mfontMap[font]=pfi; //添加在次要map表
|
||||
/*
|
||||
if (!ret) {
|
||||
delete pfi;
|
||||
@ -763,7 +763,7 @@ FreeTypeFontInfo* FreeTypeFontEngine::FindFont(void* lpparams)
|
||||
if (iter!=m_mfullMap.end())
|
||||
{
|
||||
FreeTypeFontInfo* p = iter->second;
|
||||
if (p->GetFullName()!=params->strFullName) //属于替换字体
|
||||
if (p->GetFullName()!=params->strFullName) //属于替换字体
|
||||
return FindFont(params->lplf->lfFaceName, params->lplf->lfWeight, !!params->lplf->lfItalic);
|
||||
p->SetMruCounter(this);
|
||||
return p;
|
||||
|
16
fteng.h
16
fteng.h
@ -314,7 +314,7 @@ private:
|
||||
wstring m_fullname, m_familyname;
|
||||
typedef map<UINT, FreeTypeFontCache*> CacheArray;
|
||||
CacheArray m_cache;
|
||||
//快速链接
|
||||
//快速链接
|
||||
FTC_FaceID face_id_link[CFontLinkInfo::FONTMAX * 2 + 1];
|
||||
HFONT ggo_link[CFontLinkInfo::FONTMAX * 2 + 1];
|
||||
bool m_linkinited;
|
||||
@ -397,7 +397,7 @@ public:
|
||||
if (nSize==0)
|
||||
m_fullname = L"";
|
||||
else
|
||||
//if (m_fullname.size()==0) //构造函数中不提供,自己获取
|
||||
//if (m_fullname.size()==0) //构造函数中不提供,自己获取
|
||||
{
|
||||
LPOUTLINETEXTMETRIC otm = (LPOUTLINETEXTMETRIC)malloc(nSize);
|
||||
memset(otm, 0, nSize);
|
||||
@ -410,7 +410,7 @@ public:
|
||||
|
||||
TCHAR buff[LF_FACESIZE+1];
|
||||
GetFontLocalName(localname, buff);
|
||||
m_nFontFamily = otm->otmTextMetrics.tmPitchAndFamily & 0xF0; //获取字体家族,家族对应使用什么默认链接字体
|
||||
m_nFontFamily = otm->otmTextMetrics.tmPitchAndFamily & 0xF0; //获取字体家族,家族对应使用什么默认链接字体
|
||||
m_familyname = (wstring)buff;
|
||||
m_set = pSettings->FindIndividual(m_familyname.c_str());
|
||||
m_ftWeight = CalcBoldWeight(/*weight*/700);
|
||||
@ -422,7 +422,7 @@ public:
|
||||
SelectFont(hdc, old);
|
||||
DeleteDC(hdc);
|
||||
|
||||
//完成
|
||||
//完成
|
||||
// g_EngineCreateFont = false;
|
||||
face_id_link[0]=(FTC_FaceID)NULL;
|
||||
ggo_link[0] = NULL;
|
||||
@ -472,7 +472,7 @@ public:
|
||||
void UpdateFontSetting()
|
||||
{
|
||||
m_ftWeight = CalcBoldWeight(700/*m_weight*/);
|
||||
//清除字体链接
|
||||
//清除字体链接
|
||||
face_id_link[0]=NULL;
|
||||
ggo_link[0]=NULL;
|
||||
m_linknum = 0;
|
||||
@ -617,7 +617,7 @@ public:
|
||||
}
|
||||
void ReloadAll()
|
||||
{
|
||||
//重新载入全部字体,即清空所有字体缓存
|
||||
//重新载入全部字体,即清空所有字体缓存
|
||||
COwnedCriticalSectionLock __olock(2);
|
||||
CCriticalSectionLock __lock;
|
||||
CGdippSettings* pSettings = CGdippSettings::GetInstance();
|
||||
@ -629,9 +629,9 @@ public:
|
||||
if (p)
|
||||
{
|
||||
/*
|
||||
if (p->GetFullName()!=iter->first) //是替换字体
|
||||
if (p->GetFullName()!=iter->first) //是替换字体
|
||||
{
|
||||
p->Release(); //释放掉多重引用
|
||||
p->Release(); //释放掉多重引用
|
||||
m_mfullMap.erase(iter++);
|
||||
continue;
|
||||
}*/
|
||||
|
2
ftref.h
2
ftref.h
@ -24,4 +24,4 @@ FT_Referenced_Glyph New_FT_Ref_Glyph();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -36,4 +36,4 @@ bool InitGdiplusFuncs(){
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ GdipDrawString)(
|
||||
GDIPCONST RectF *layoutRect,
|
||||
GDIPCONST GpStringFormat *stringFormat,
|
||||
GDIPCONST GpBrush *brush
|
||||
);//绘制文字的函数
|
||||
);//绘制文字的函数
|
||||
|
||||
typedef GpStatus (WINGDIPAPI*
|
||||
GdipGetLogFontW)(GpFont * font, GpGraphics *graphics, LOGFONTW * logfontW);//从GPFont获取Logfont
|
||||
@ -39,11 +39,11 @@ typedef GpStatus (WINGDIPAPI*
|
||||
GdipGetStringFormatTrimming)(
|
||||
GDIPCONST GpStringFormat *format,
|
||||
StringTrimming *trimming
|
||||
); //获取字符串的缩略方式。当字符串长度超过矩形长度时,将使用设置的方式删除中间的部分文字。
|
||||
); //获取字符串的缩略方式。当字符串长度超过矩形长度时,将使用设置的方式删除中间的部分文字。
|
||||
//转换成GDI后应使用DrawText来模拟。
|
||||
typedef GpStatus (WINGDIPAPI*
|
||||
GdipGetStringFormatHotkeyPrefix)(GDIPCONST GpStringFormat *format,
|
||||
INT *hotkeyPrefix); //获取&符号的显示方式,隐藏,显示下划线或者不处理&。由DrawText模拟。
|
||||
INT *hotkeyPrefix); //获取&符号的显示方式,隐藏,显示下划线或者不处理&。由DrawText模拟。
|
||||
|
||||
typedef GpStatus (WINGDIPAPI*
|
||||
GdipGetBrushType)(GpBrush *brush, GpBrushType *type);
|
||||
@ -63,4 +63,4 @@ extern GdipReleaseDC pfnGdipReleaseDC ;
|
||||
|
||||
bool InitGdiplusFuncs();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -694,4 +694,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@ -160,4 +160,4 @@
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@ -34,4 +34,4 @@ TCHAR * CHashedStringList::Find(TCHAR * String)
|
||||
return it->second;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -26,4 +26,4 @@ protected:
|
||||
private:
|
||||
strmap stringmap;
|
||||
BOOL m_bCaseSense;
|
||||
};
|
||||
};
|
||||
|
2
hook.cpp
2
hook.cpp
@ -567,7 +567,7 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID lpReserved)
|
||||
//delete AACacheFull;
|
||||
//delete AACache;
|
||||
// for (int i=0;i<CACHE_SIZE;i++)
|
||||
// delete g_AACache2[i]; //ヌ蟲<EFBFBD>サコエ・
|
||||
// delete g_AACache2[i]; //清除缓磥E
|
||||
//free(g_charmapCache);
|
||||
}
|
||||
#ifndef DEBUG
|
||||
|
2
misc.cpp
2
misc.cpp
@ -2,7 +2,7 @@
|
||||
#include "settings.h"
|
||||
CRITICAL_SECTION CCriticalSectionLock::m_cs[20];
|
||||
OWNED_CRITIAL_SECTION COwnedCriticalSectionLock::m_cs[2];
|
||||
LONG CThreadCounter::interlock; //snowie!! C++还需要额外申明,汗
|
||||
LONG CThreadCounter::interlock; //snowie!! C++还需要额外申明,汗
|
||||
TCHAR CGdippSettings::m_szexeName[MAX_PATH+1] = {0};
|
||||
|
||||
#ifdef _UNICODE
|
||||
|
38
override.cpp
38
override.cpp
@ -62,7 +62,7 @@ HFONT GetCurrentFont(HDC hdc)
|
||||
return hCurFont;
|
||||
}
|
||||
|
||||
//判断是否是有效普通显示DC,用于跳过字幕
|
||||
//判断是否是有效普通显示DC,用于跳过字幕
|
||||
BOOL IsValidDC(HDC hdc)
|
||||
{
|
||||
if (GetDeviceCaps(hdc, TECHNOLOGY) != DT_RASDISPLAY) {
|
||||
@ -136,7 +136,7 @@ int div_ceil(int a, int b)
|
||||
return a / b;
|
||||
}
|
||||
|
||||
template <typename _TCHAR> //修改这个函数,使它在失败的时候返回false,由调用者负责调用Windows原函数,实现线程安全。
|
||||
template <typename _TCHAR> //修改这个函数,使它在失败的时候返回false,由调用者负责调用Windows原函数,实现线程安全。
|
||||
BOOL _GetTextExtentPoint32AorW(HDC hdc, _TCHAR* lpString, int cbString, LPSIZE lpSize)
|
||||
{
|
||||
const CGdippSettings* pSettings = CGdippSettings::GetInstance();
|
||||
@ -230,8 +230,8 @@ LONG WINAPI IMPL_LdrLoadDll(IN PWCHAR PathToFile OPTIONAL, IN ULONG Flags OPTION
|
||||
wstring filename = wstring(ModuleFileName->Buffer);
|
||||
int last_slash=filename.find_last_of('\\');
|
||||
if (last_slash!=-1)
|
||||
filename.erase(0,last_slash+1); //删除路径
|
||||
if (_wcsicmp(filename.c_str(), L"d2d1.dll")==0) //正在载入d2d1.dll
|
||||
filename.erase(0,last_slash+1); //删除路径
|
||||
if (_wcsicmp(filename.c_str(), L"d2d1.dll")==0) //正在载入d2d1.dll
|
||||
{
|
||||
bD2D1Loaded = true;
|
||||
LONG result = ORIG_LdrLoadDll(PathToFile, Flags, ModuleFileName, ModuleHandle);
|
||||
@ -411,15 +411,15 @@ LPCWSTR GetCachedFontLocale(HFONT lFont)
|
||||
|
||||
void AddToCachedFont(HFONT lfont, LPWSTR lpFaceName, LPWSTR lpGDIName)
|
||||
{
|
||||
if (!lfont) return; //不可以添加空节点
|
||||
if (!lfont) return; //不可以添加空节点
|
||||
CCriticalSectionLock __lock(CCriticalSectionLock::CS_CACHEDFONT);
|
||||
if (GetCachedFont(lfont)) return; //已经存在的字体
|
||||
if (GetCachedFont(lfont)) return; //已经存在的字体
|
||||
FontCache[lfont] = new CFontSubResult(lpFaceName, lpGDIName);
|
||||
}
|
||||
|
||||
void DeleteCachedFont(HFONT lfont)
|
||||
{
|
||||
if (!lfont) return; //不可以删除头结点
|
||||
if (!lfont) return; //不可以删除头结点
|
||||
CCriticalSectionLock __lock(CCriticalSectionLock::CS_CACHEDFONT);
|
||||
CFontCache::iterator it= FontCache.find(lfont);
|
||||
if (it!=FontCache.end())
|
||||
@ -755,7 +755,7 @@ HFONT WINAPI IMPL_CreateFontIndirectExW(CONST ENUMLOGFONTEXDV *penumlfex)
|
||||
BOOL WINAPI IMPL_DeleteObject(HGDIOBJ hObject)
|
||||
{
|
||||
//CThreadCounter __counter;
|
||||
if (hObject == g_alterGUIFont) //我的系统字体,不可以释放掉
|
||||
if (hObject == g_alterGUIFont) //我的系统字体,不可以释放掉
|
||||
return true;
|
||||
BOOL bResult = ORIG_DeleteObject(hObject);
|
||||
if (bResult) DeleteCachedFont((HFONT)hObject);
|
||||
@ -763,7 +763,7 @@ BOOL WINAPI IMPL_DeleteObject(HGDIOBJ hObject)
|
||||
}
|
||||
|
||||
|
||||
HFONT WINAPI IMPL_CreateFontIndirectW(CONST LOGFONTW *lplf) //重新启用这个hook,只为兼容搜狗输入法
|
||||
HFONT WINAPI IMPL_CreateFontIndirectW(CONST LOGFONTW *lplf) //重新启用这个hook,只为兼容搜狗输入法
|
||||
{
|
||||
ENUMLOGFONTEXDVW envlf = {0};
|
||||
memcpy(&envlf.elfEnumLogfontEx.elfLogFont, lplf, sizeof(LOGFONTW));
|
||||
@ -1061,14 +1061,14 @@ extern ControlIder CID;
|
||||
// 取代Windows的ExtTextOutW
|
||||
BOOL WINAPI IMPL_ExtTextOutW(HDC hdc, int nXStart, int nYStart, UINT fuOptions, CONST RECT *lprc, LPCWSTR lpString, UINT cbString, CONST INT *SyslpDx)
|
||||
{
|
||||
//CThreadCounter __counter; //用于安全退出的计数器
|
||||
//CThreadCounter __counter; //用于安全退出的计数器
|
||||
INT* lpDx = const_cast<INT*>(SyslpDx);
|
||||
|
||||
if (!hdc || !lpString || !cbString || !g_ccbRender || cbString>8192) { //no valid param or rendering is disabled from control center.
|
||||
return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions, lprc, lpString, cbString, lpDx);
|
||||
}
|
||||
if (!(fuOptions & ETO_GLYPH_INDEX) && cbString==1 && *lpString==32) //空格
|
||||
return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions | ETO_IGNORELANGUAGE, lprc, lpString, cbString, lpDx); //空格就不用处理了。。。反正都一样
|
||||
if (!(fuOptions & ETO_GLYPH_INDEX) && cbString==1 && *lpString==32) //空格
|
||||
return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions | ETO_IGNORELANGUAGE, lprc, lpString, cbString, lpDx); //空格就不用处理了。。。反正都一样
|
||||
|
||||
CThreadLocalInfo* pTLInfo = g_TLInfo.GetPtr();
|
||||
if(!pTLInfo) {
|
||||
@ -1099,14 +1099,14 @@ BOOL WINAPI IMPL_ExtTextOutW(HDC hdc, int nXStart, int nYStart, UINT fuOptions,
|
||||
|
||||
if (!(fuOptions & ETO_GLYPH_INDEX) && !(fuOptions & ETO_IGNORELANGUAGE) && !lpDx && CID.myiscomplexscript(lpString,cbString)) //complex script
|
||||
return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions, lprc, lpString, cbString, lpDx);
|
||||
CGdippSettings* pSettings = CGdippSettings::GetInstance(); //获得一个配置文件实例
|
||||
CGdippSettings* pSettings = CGdippSettings::GetInstance(); //获得一个配置文件实例
|
||||
|
||||
/*
|
||||
|
||||
#ifndef _DEBUG //debug模式下此参数有问题
|
||||
#ifndef _DEBUG //debug模式下此参数有问题
|
||||
if (pSettings->FontLoader()==SETTING_FONTLOADER_WIN32)
|
||||
{
|
||||
if (!(fuOptions & ETO_GLYPH_INDEX) //复杂文件,不进行渲染
|
||||
if (!(fuOptions & ETO_GLYPH_INDEX) //复杂文件,不进行渲染
|
||||
&& !(fuOptions & ETO_IGNORELANGUAGE) && ScriptIsComplex(lpString, cbString, SIC_COMPLEX) == S_OK) {
|
||||
return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions, lprc, lpString, cbString, lpDx);
|
||||
}
|
||||
@ -1121,7 +1121,7 @@ BOOL WINAPI IMPL_ExtTextOutW(HDC hdc, int nXStart, int nYStart, UINT fuOptions,
|
||||
|
||||
|
||||
|
||||
if (pTLInfo->InExtTextOut()) { //是异常之后的自动还原执行
|
||||
if (pTLInfo->InExtTextOut()) { //是异常之后的自动还原执行
|
||||
return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions, lprc, lpString, cbString, lpDx);
|
||||
}
|
||||
|
||||
@ -1132,9 +1132,9 @@ BOOL WINAPI IMPL_ExtTextOutW(HDC hdc, int nXStart, int nYStart, UINT fuOptions,
|
||||
if (GetTransform)
|
||||
{
|
||||
GetTransform(hdc, GT_WORLD_TO_DEVICE, &xfm);
|
||||
if (memcmp(&xfm, &stdXfm, sizeof(XFORM)-sizeof(FLOAT)*2)) //(xfm.eM11!=1.0 || xfm.eM22!=1.0) //如果存在坐标转换
|
||||
if (memcmp(&xfm, &stdXfm, sizeof(XFORM)-sizeof(FLOAT)*2)) //(xfm.eM11!=1.0 || xfm.eM22!=1.0) //如果存在坐标转换
|
||||
{
|
||||
bool bZoomInOut = (xfm.eM12==0 && xfm.eM21==0 && xfm.eM11>0 && xfm.eM22>0); //只是缩放,且是正数缩放
|
||||
bool bZoomInOut = (xfm.eM12==0 && xfm.eM21==0 && xfm.eM11>0 && xfm.eM22>0); //只是缩放,且是正数缩放
|
||||
if (!bZoomInOut)
|
||||
return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions, lprc, lpString, cbString, lpDx); //放弃渲染
|
||||
else
|
||||
@ -1194,7 +1194,7 @@ BOOL WINAPI IMPL_ExtTextOutW(HDC hdc, int nXStart, int nYStart, UINT fuOptions,
|
||||
OUTLINETEXTMETRIC* otm = NULL;
|
||||
|
||||
ETO_TRY();
|
||||
//设置标志,
|
||||
//设置标志,
|
||||
pTLInfo->InExtTextOut(true);
|
||||
|
||||
POINT curPos = { nXStart, nYStart }; //记录开始的位置
|
||||
|
@ -31,15 +31,15 @@ void WINAPI EnterOwnedCritialSection(POWNED_CRITIAL_SECTION cs, WORD Owner)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (InterlockedIncrementInt(cs->nRequests)>0) //等待获取所有权
|
||||
if (InterlockedIncrementInt(cs->nRequests)>0) //等待获取所有权
|
||||
{
|
||||
LeaveCriticalSection(&cs->threadLock);
|
||||
WaitForSingleObject(cs->hEvent, INFINITE);
|
||||
}
|
||||
else
|
||||
LeaveCriticalSection(&cs->threadLock);
|
||||
InterlockedExchangeInt(cs->nOwner, Owner);//更改所有者
|
||||
InterlockedExchangeInt(cs->nRecursiveCount, 1);//增加占用计数
|
||||
InterlockedExchangeInt(cs->nOwner, Owner);//更改所有者
|
||||
InterlockedExchangeInt(cs->nRecursiveCount, 1);//增加占用计数
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,4 +58,4 @@ void WINAPI LeaveOwnedCritialSection(POWNED_CRITIAL_SECTION cs, WORD Owner)
|
||||
else
|
||||
InterlockedDecrementInt(cs->nRecursiveCount);
|
||||
LeaveCriticalSection(&cs->threadLock);
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,9 @@ typedef struct _OWNED_CRITIAL_SECTION
|
||||
HANDLE hEvent;
|
||||
CRITICAL_SECTION threadLock;
|
||||
}OWNED_CRITIAL_SECTION, *POWNED_CRITIAL_SECTION;
|
||||
//用于自定义临界区
|
||||
//用于自定义临界区
|
||||
|
||||
void WINAPI InitializeOwnedCritialSection(POWNED_CRITIAL_SECTION cs);
|
||||
void WINAPI DeleteOwnedCritialSection(POWNED_CRITIAL_SECTION cs);
|
||||
void WINAPI EnterOwnedCritialSection(POWNED_CRITIAL_SECTION cs, WORD Owner);
|
||||
void WINAPI LeaveOwnedCritialSection(POWNED_CRITIAL_SECTION cs, WORD Owner);
|
||||
void WINAPI LeaveOwnedCritialSection(POWNED_CRITIAL_SECTION cs, WORD Owner);
|
||||
|
14
settings.cpp
14
settings.cpp
@ -429,7 +429,7 @@ bool CGdippSettings::LoadAppSettings(LPCTSTR lpszFile)
|
||||
PathRemoveFileSpec(szDir);
|
||||
PathCombine(szAlternative, szDir, szAlternative);
|
||||
}
|
||||
StringCchCopy(szMainFile, MAX_PATH, lpszFile); //把原始文件名保存下来
|
||||
StringCchCopy(szMainFile, MAX_PATH, lpszFile); //把原始文件名保存下来
|
||||
StringCchCopy(m_szFileName, MAX_PATH, szAlternative);
|
||||
lpszFile = m_szFileName;
|
||||
m_Config.Clear();
|
||||
@ -642,7 +642,7 @@ SKIP:
|
||||
// [ExcludeSub]イサス<EFBDBB>ミラヨフ衫貊サオトト」ソ・
|
||||
AddListFromSection(L"ExcludeSub", lpszFile, m_arrUnFontSubModule);
|
||||
//AddListFromSection(L"ExcludeSub", szMainFile, m_arrUnFontSubModule);
|
||||
//如果是排除的模块,则关闭字体替换
|
||||
//如果是排除的模块,则关闭字体替换
|
||||
if (m_nFontSubstitutes)
|
||||
{
|
||||
ModuleHashMap::const_iterator it=m_arrUnFontSubModule.begin();
|
||||
@ -736,7 +736,7 @@ bool CGdippSettings::AddLcdFilterFromSection(LPCTSTR lpszKey, LPCTSTR lpszFile,
|
||||
for (int i = 0; i < 5; i++) {
|
||||
LPCTSTR arg = token.GetArgument(i);
|
||||
if (!arg)
|
||||
return false; //参数少于5个则视为不使用此参数
|
||||
return false; //参数少于5个则视为不使用此参数
|
||||
arr[i] = _StrToInt(arg, arr[i]);
|
||||
}
|
||||
|
||||
@ -998,7 +998,7 @@ bool CGdippSettings::IsExeUnload(LPCTSTR lpApp) const //
|
||||
return false;
|
||||
ModuleHashMap::const_iterator it = m_arrUnloadModule.begin();
|
||||
for(; it != m_arrUnloadModule.end(); ++it) {
|
||||
if (!lstrcmpi(lpApp, it->c_str())) { //匹配排除蟻E
|
||||
if (!lstrcmpi(lpApp, it->c_str())) { //匹配排除蟻E
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1015,7 +1015,7 @@ bool CGdippSettings::IsExeInclude(LPCTSTR lpApp) const //
|
||||
return false;
|
||||
ModuleHashMap::const_iterator it = m_arrIncludeModule.begin();
|
||||
for(; it != m_arrIncludeModule.end(); ++it) {
|
||||
if (!lstrcmpi(lpApp, it->c_str())) { //匹配排除蟻E
|
||||
if (!lstrcmpi(lpApp, it->c_str())) { //匹配排除蟻E
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1293,7 +1293,7 @@ void CFontLinkInfo::init()
|
||||
if (rc == ERROR_NO_MORE_ITEMS) break;
|
||||
if (rc != ERROR_SUCCESS) break;
|
||||
if (regtype != REG_SZ) continue;
|
||||
if (lstrcmpi(value2, linep) != 0) continue; //寻找字体链接中字体文件对应的字体脕E
|
||||
if (lstrcmpi(value2, linep) != 0) continue; //寻找字体链接中字体文件对应的字体脕E
|
||||
|
||||
StringCchCopyW(buf, sizeof(buf)/sizeof(buf[0]), name);
|
||||
if (buf[wcslen(buf) - 1] == L')') { //ネ・オ<EFBDA5>ィコナ
|
||||
@ -1330,7 +1330,7 @@ void CFontLinkInfo::init()
|
||||
{
|
||||
//カヤラヨフ蠱エスモア櫤<EFBDB1>賺<EFBFBD>ヲタ・
|
||||
LPWSTR swapbuff[32];
|
||||
memcpy(swapbuff, info[row], 32*sizeof(LPWSTR)); //整个柄源制过来
|
||||
memcpy(swapbuff, info[row], 32*sizeof(LPWSTR)); //整个柄源制过来
|
||||
for (int i=1; i<col; i++)
|
||||
info[row][i]=swapbuff[col-i]; //ト賻<EFBE84>ヨフ蠱エスモア・
|
||||
}*/
|
||||
|
32
settings.h
32
settings.h
@ -32,7 +32,7 @@
|
||||
extern rettype (WINAPI * ORIG_##name) argtype; \
|
||||
extern rettype WINAPI IMPL_##name argtype;
|
||||
#include "hooklist.h"
|
||||
#undef HOOK_DEFINE //为了确保此文件也能直接使用正确的函数,需要申明。
|
||||
#undef HOOK_DEFINE //为了确保此文件也能直接使用正确的函数,需要申明。
|
||||
#undef HOOK_MANUALLY
|
||||
|
||||
/*
|
||||
@ -151,7 +151,7 @@ class CFontLinkInfo
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
INFOMAX = 180, //源文件=15
|
||||
INFOMAX = 180, //源文件=15
|
||||
FONTMAX = 31,
|
||||
};
|
||||
private:
|
||||
@ -278,7 +278,7 @@ private:
|
||||
int m_nLcdFilter;
|
||||
int m_nShadow[4];
|
||||
int m_nFontSubstitutes;
|
||||
int m_bFontLink; //改为可以使用多种参数
|
||||
int m_bFontLink; //改为可以使用多种参数
|
||||
int m_nWidthMode;
|
||||
int m_nFontLoader;
|
||||
int m_nScreenDpi; // screen dpi
|
||||
@ -306,7 +306,7 @@ private:
|
||||
int m_dwOSMajorVer;
|
||||
int m_dwOSMinorVer;
|
||||
|
||||
// アンチエイリアス調整用テーブル
|
||||
// アンチエイリアス調整用テーブル
|
||||
int m_nTuneTable[256];
|
||||
// LCDÓÃ
|
||||
int m_nTuneTableR[256];
|
||||
@ -330,10 +330,10 @@ private:
|
||||
LOGFONT m_lfForceFont;
|
||||
TCHAR m_szForceChangeFont[LF_FACESIZE];
|
||||
|
||||
//INIファイル名
|
||||
//INIファイル名
|
||||
TCHAR m_szFileName[MAX_PATH];
|
||||
|
||||
//INIからの読み込み処理
|
||||
//INIからの読み込み処理
|
||||
bool LoadAppSettings(LPCTSTR lpszFile);
|
||||
void GetOSVersion();
|
||||
float FastGetProfileFloat(LPCTSTR lpszSection, LPCTSTR lpszKey, float fDefault);
|
||||
@ -468,7 +468,7 @@ public:
|
||||
// OS version comparsion for magic code
|
||||
bool IsWindows8() const { return m_dwOSMajorVer == 6 && m_dwOSMinorVer == 2; }
|
||||
bool IsWindows81() const { return m_dwOSMajorVer == 6 && m_dwOSMinorVer == 3; }
|
||||
// フォント名よみとり
|
||||
// フォント名よみとり
|
||||
LPCTSTR GetForceFontName() const
|
||||
{
|
||||
_ASSERTE(m_bDelayedInit);
|
||||
@ -478,7 +478,7 @@ public:
|
||||
|
||||
bool CopyForceFont(LOGFONT& lf, const LOGFONT& lfOrg) const;
|
||||
|
||||
//それ以外
|
||||
//それ以外
|
||||
bool IsWinXPorLater() const { return m_bIsWinXPorLater; }
|
||||
bool IsInclude() const { return m_bIsInclude; }
|
||||
// bool IsHDBench() const { return m_bIsHDBench; }
|
||||
@ -498,7 +498,7 @@ public:
|
||||
bool IsProcessUnload() const;
|
||||
bool IsExeUnload(LPCTSTR lpApp) const;
|
||||
bool IsExeInclude(LPCTSTR lpApp) const;
|
||||
void AddFontExclude(LPCWSTR lpFaceName); //点阵字体直接自动添加到此列表
|
||||
void AddFontExclude(LPCWSTR lpFaceName); //点阵字体直接自动添加到此列表
|
||||
bool IsProcessExcluded() const;
|
||||
bool IsProcessIncluded() const;
|
||||
const CFontSettings& FindIndividual(LPCTSTR lpFaceName) const;
|
||||
@ -673,14 +673,14 @@ public:
|
||||
break;
|
||||
case ATTR_LcdFilterWeight:
|
||||
if (!nValue)
|
||||
pSettings->m_bUseCustomLcdFilter = false; //传NULL过来就是关闭自定义过滤器
|
||||
pSettings->m_bUseCustomLcdFilter = false; //传NULL过来就是关闭自定义过滤器
|
||||
else
|
||||
{
|
||||
pSettings->m_bUseCustomLcdFilter = true; //否则打开过滤器
|
||||
if (!IsBadReadPtr((void*)nValue, sizeof(pSettings->m_arrLcdFilterWeights))) //如果指针有效
|
||||
memcpy(pSettings->m_arrLcdFilterWeights, (void*)nValue, sizeof(pSettings->m_arrLcdFilterWeights)); //复制数据
|
||||
pSettings->m_bUseCustomLcdFilter = true; //否则打开过滤器
|
||||
if (!IsBadReadPtr((void*)nValue, sizeof(pSettings->m_arrLcdFilterWeights))) //如果指针有效
|
||||
memcpy(pSettings->m_arrLcdFilterWeights, (void*)nValue, sizeof(pSettings->m_arrLcdFilterWeights)); //复制数据
|
||||
}
|
||||
UpdateLcdFilter(); //刷新过滤器
|
||||
UpdateLcdFilter(); //刷新过滤器
|
||||
break;
|
||||
case ATTR_HintSmallFont:
|
||||
pSettings->m_bHintSmallFont = !!nValue;
|
||||
@ -689,7 +689,7 @@ public:
|
||||
pSettings->m_nBitmapHeight = nValue;
|
||||
break;
|
||||
case ATTR_ShadowBuffer:
|
||||
if (nValue && !IsBadReadPtr((void*)nValue, sizeof(pSettings->m_nShadow))) //指针有效
|
||||
if (nValue && !IsBadReadPtr((void*)nValue, sizeof(pSettings->m_nShadow))) //指针有效
|
||||
{
|
||||
LPCTSTR szShadow = (LPCTSTR)nValue;
|
||||
CStringTokenizer token;
|
||||
@ -849,7 +849,7 @@ public:
|
||||
argc = token.Parse(value);
|
||||
}
|
||||
TCHAR buff[LF_FACESIZE+1];
|
||||
GetFontLocalName(p, buff); //转换字体名
|
||||
GetFontLocalName(p, buff); //转换字体名
|
||||
|
||||
CFontIndividual fi(buff);
|
||||
const CFontSettings& fsCommon = pSettings->m_FontSettings;
|
||||
|
12
supinfo.h
12
supinfo.h
@ -157,7 +157,7 @@ static wstring GetExeName(LPCTSTR lpApp, LPTSTR lpCmd)
|
||||
// DWORD aa=0;
|
||||
// if (GetFileSize(logfile, NULL)==0)
|
||||
// WriteFile(logfile, "\xff\xfe", 2, &aa, NULL);
|
||||
LPTSTR vlpApp = (LPTSTR)lpApp; //变成可以操作的参数
|
||||
LPTSTR vlpApp = (LPTSTR)lpApp; //变成可以操作的参数
|
||||
if (lpApp)
|
||||
{
|
||||
do
|
||||
@ -172,7 +172,7 @@ static wstring GetExeName(LPCTSTR lpApp, LPTSTR lpCmd)
|
||||
// WriteFile(logfile, ret.c_str(), ret.length()*2, &aa, NULL);
|
||||
// WriteFile(logfile, _T("\n"), 2, &aa, NULL);
|
||||
DWORD fa = GetFileAttributes(ret.c_str());
|
||||
if (fa!=INVALID_FILE_ATTRIBUTES && fa!=FILE_ATTRIBUTE_DIRECTORY) //文件是否存在
|
||||
if (fa!=INVALID_FILE_ATTRIBUTES && fa!=FILE_ATTRIBUTE_DIRECTORY) //文件是否存在
|
||||
{
|
||||
int p = ret.find_last_of(_T("\\"));
|
||||
if (p!=-1)
|
||||
@ -210,13 +210,13 @@ static wstring GetExeName(LPCTSTR lpApp, LPTSTR lpCmd)
|
||||
int p=0;
|
||||
if ((*lpCmd)==_T('\"'))
|
||||
{
|
||||
ret.erase(0,1); //删除第一个引号
|
||||
p=ret.find_first_of(_T("\"")); //查找下一个引号
|
||||
ret.erase(0,1); //删除第一个引号
|
||||
p=ret.find_first_of(_T("\"")); //查找下一个引号
|
||||
}
|
||||
else
|
||||
p=ret.find_first_of(_T(" "));
|
||||
if (p>0)
|
||||
ret.resize(p); //获得Cmd里面的文件名
|
||||
ret.resize(p); //获得Cmd里面的文件名
|
||||
// WriteFile(logfile, ret.c_str(), ret.length()*2, &aa, NULL);
|
||||
// WriteFile(logfile, _T("\n"), 2, &aa, NULL);
|
||||
p = ret.find_last_of(_T("\\"));
|
||||
@ -302,4 +302,4 @@ BOOL _CreateProcessInternalW(HANDLE hToken, LPCTSTR lpApp, LPTSTR lpCmd, LPSECUR
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -93,4 +93,4 @@ static TGetTextFA GetTextFaceAliasW= (TGetTextFA)GetProcAddress(LoadLibrary(_T("
|
||||
static PFNCreateProcessInternalW CreateProcessInternalW_KernelBase = (PFNCreateProcessInternalW)GetProcAddress(GetModuleHandle(_T("kernelbase.dll")),"CreateProcessInternalW");
|
||||
static PFNCreateProcessInternalW CreateProcessInternalW = CreateProcessInternalW_KernelBase ? CreateProcessInternalW_KernelBase:(PFNCreateProcessInternalW)GetProcAddress(GetModuleHandle(_T("kernel32.dll")),"CreateProcessInternalW");
|
||||
//static PFNIsWow64Process IsWow64Process=(PFNIsWow64Process)GetProcAddress(LoadLibrary(L"Kernel32.dll"), "IsWow64Process");
|
||||
static PFNGetFontResourceInfo GetFontResourceInfo=(PFNGetFontResourceInfo)GetProcAddress(LoadLibrary(L"gdi32.dll"), "GetFontResourceInfoW");
|
||||
static PFNGetFontResourceInfo GetFontResourceInfo=(PFNGetFontResourceInfo)GetProcAddress(LoadLibrary(L"gdi32.dll"), "GetFontResourceInfoW");
|
||||
|
@ -226,4 +226,4 @@ BOOL XP_GetThreadWow64Context(
|
||||
CloseHandle( Process );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user