From 87b41f7ff519038e6a3d4345dec53869d84fdcd2 Mon Sep 17 00:00:00 2001 From: shuax Date: Sun, 27 Dec 2015 22:53:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=B3=E4=BA=8E=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/GreenChrome.cpp | 5 ++ src/Patchs.h | 113 ++++++++++++++++++++++++++------------------ src/Util.h | 52 ++++++++++++++++++++ 3 files changed, 125 insertions(+), 45 deletions(-) diff --git a/src/GreenChrome.cpp b/src/GreenChrome.cpp index ef636aa..e772009 100644 --- a/src/GreenChrome.cpp +++ b/src/GreenChrome.cpp @@ -30,6 +30,11 @@ void GreenChrome() // 让新标签一片空白 BlankNewTab(iniPath); + // 生成关于,64位不好改,暂时不弄 + #ifndef _WIN64 + BuildAboutProduct(); + #endif + // 标签页,书签,地址栏增强 TabBookmark(iniPath); diff --git a/src/Patchs.h b/src/Patchs.h index 2c24a6f..3c4c808 100644 --- a/src/Patchs.h +++ b/src/Patchs.h @@ -1,7 +1,7 @@ HRESULT WINAPI FakeSHGetPropertyStoreForWindow( - _In_ HWND hwnd, - _In_ REFIID riid, - _Out_ void **ppv + _In_ HWND hwnd, + _In_ REFIID riid, + _Out_ void **ppv ) { return -1; @@ -29,9 +29,9 @@ void RepairDoubleIcon(const wchar_t *iniPath) BOOL WINAPI FakeVerifyVersionInfo( - _In_ LPOSVERSIONINFOEX lpVersionInfo, - _In_ DWORD dwTypeMask, - _In_ DWORDLONG dwlConditionMask + _In_ LPOSVERSIONINFOEX lpVersionInfo, + _In_ DWORD dwTypeMask, + _In_ DWORDLONG dwlConditionMask ) { return 0; @@ -59,8 +59,8 @@ void RepairDelegateExecute(const wchar_t *iniPath) BOOL WINAPI FakeGetComputerName( - _Out_ LPTSTR lpBuffer, - _Inout_ LPDWORD lpnSize + _Out_ LPTSTR lpBuffer, + _Inout_ LPDWORD lpnSize ) { return 0; @@ -150,21 +150,21 @@ void PatchResourcesPak(uint8_t *buffer) HANDLE resources_pak_map = NULL; typedef HANDLE (WINAPI *pMapViewOfFile)( - _In_ HANDLE hFileMappingObject, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwFileOffsetHigh, - _In_ DWORD dwFileOffsetLow, - _In_ SIZE_T dwNumberOfBytesToMap + _In_ HANDLE hFileMappingObject, + _In_ DWORD dwDesiredAccess, + _In_ DWORD dwFileOffsetHigh, + _In_ DWORD dwFileOffsetLow, + _In_ SIZE_T dwNumberOfBytesToMap ); pMapViewOfFile RawMapViewOfFile = NULL; HANDLE WINAPI MyMapViewOfFile( - _In_ HANDLE hFileMappingObject, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwFileOffsetHigh, - _In_ DWORD dwFileOffsetLow, - _In_ SIZE_T dwNumberOfBytesToMap + _In_ HANDLE hFileMappingObject, + _In_ DWORD dwDesiredAccess, + _In_ DWORD dwFileOffsetHigh, + _In_ DWORD dwFileOffsetLow, + _In_ SIZE_T dwNumberOfBytesToMap ) { if(hFileMappingObject == resources_pak_map) @@ -193,23 +193,23 @@ HANDLE WINAPI MyMapViewOfFile( HANDLE resources_pak_file = NULL; typedef HANDLE (WINAPI *pCreateFileMapping)( - _In_ HANDLE hFile, - _In_opt_ LPSECURITY_ATTRIBUTES lpAttributes, - _In_ DWORD flProtect, - _In_ DWORD dwMaximumSizeHigh, - _In_ DWORD dwMaximumSizeLow, - _In_opt_ LPCTSTR lpName + _In_ HANDLE hFile, + _In_opt_ LPSECURITY_ATTRIBUTES lpAttributes, + _In_ DWORD flProtect, + _In_ DWORD dwMaximumSizeHigh, + _In_ DWORD dwMaximumSizeLow, + _In_opt_ LPCTSTR lpName ); pCreateFileMapping RawCreateFileMapping = NULL; HANDLE WINAPI MyCreateFileMapping( - _In_ HANDLE hFile, - _In_opt_ LPSECURITY_ATTRIBUTES lpAttributes, - _In_ DWORD flProtect, - _In_ DWORD dwMaximumSizeHigh, - _In_ DWORD dwMaximumSizeLow, - _In_opt_ LPCTSTR lpName + _In_ HANDLE hFile, + _In_opt_ LPSECURITY_ATTRIBUTES lpAttributes, + _In_ DWORD flProtect, + _In_ DWORD dwMaximumSizeHigh, + _In_ DWORD dwMaximumSizeLow, + _In_opt_ LPCTSTR lpName ) { if(hFile == resources_pak_file) @@ -234,25 +234,25 @@ HANDLE WINAPI MyCreateFileMapping( } typedef HANDLE (WINAPI *pCreateFile)( - _In_ LPCTSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, - _In_opt_ HANDLE hTemplateFile + _In_ LPCTSTR lpFileName, + _In_ DWORD dwDesiredAccess, + _In_ DWORD dwShareMode, + _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + _In_ DWORD dwCreationDisposition, + _In_ DWORD dwFlagsAndAttributes, + _In_opt_ HANDLE hTemplateFile ); pCreateFile RawCreateFile = NULL; HANDLE WINAPI MyCreateFile( - _In_ LPCTSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, - _In_opt_ HANDLE hTemplateFile + _In_ LPCTSTR lpFileName, + _In_ DWORD dwDesiredAccess, + _In_ DWORD dwShareMode, + _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + _In_ DWORD dwCreationDisposition, + _In_ DWORD dwFlagsAndAttributes, + _In_opt_ HANDLE hTemplateFile ) { HANDLE file = RawCreateFile(lpFileName, dwDesiredAccess, dwShareMode, @@ -284,4 +284,27 @@ void BlankNewTab(const wchar_t *iniPath) MH_EnableHook(CreateFileW); } } -} \ No newline at end of file +} + + + +#ifndef _WIN64 +void BuildAboutProduct() +{ + BYTE search[] = "jsEngine"; + uint8_t *push_string = SearchModuleReference(L"chrome.dll", search, sizeof(search)); + + if(push_string && *(push_string - 0x0D) == 0x68) + { + BYTE address[] = {0x00, 0x00, 0x00, 0x00 }; + + static char aboutProductTitle[] = "aboutProductTitle"; + *(DWORD*)&address = (DWORD)&aboutProductTitle; + WriteMemory(push_string + 1, address, sizeof(address)); + + static char aboutProduct[] = "Google Chrome With GreenChrome"; + *(DWORD*)&address = (DWORD)&aboutProduct; + WriteMemory(push_string - 0x0C, address, sizeof(address)); + } +} +#endif diff --git a/src/Util.h b/src/Util.h index 99b2ff2..7147d4b 100644 --- a/src/Util.h +++ b/src/Util.h @@ -214,6 +214,58 @@ uint8_t* SearchModule(const wchar_t *path, const uint8_t* sub, int m) return NULL; } +#ifndef _WIN64 +uint8_t* SearchModuleReference(const wchar_t *path, const uint8_t* sub, int m) +{ + HMODULE module = LoadLibraryW(path); + + if(!module) + { + // dll存在于版本号文件夹中 + wchar_t version[MAX_PATH]; + GetVersion(version); + wcscat(version, L"/"); + wcscat(version, path); + + module = LoadLibraryW(version); + } + + if(module) + { + uint8_t* buffer = (uint8_t*)module; + + PIMAGE_NT_HEADERS nt_header = (PIMAGE_NT_HEADERS)(buffer + ((PIMAGE_DOS_HEADER)buffer)->e_lfanew); + PIMAGE_SECTION_HEADER section = (PIMAGE_SECTION_HEADER)((char*)nt_header + sizeof(DWORD) + + sizeof(IMAGE_FILE_HEADER) + nt_header->FileHeader.SizeOfOptionalHeader); + + uint8_t* find = NULL; + + for (int i = 0; iFileHeader.NumberOfSections; i++) + { + if (strcmp((const char*)section[i].Name, ".rdata") == 0) + { + find = memmem(buffer + section[i].PointerToRawData, section[i].SizeOfRawData, sub, m); + break; + } + } + + if(!find) return NULL; + + for(int i=0; iFileHeader.NumberOfSections; i++) + { + if(strcmp((const char*)section[i].Name,".text")==0) + { + BYTE search[] = { 0x68, 0x00, 0x00, 0x00, 0x00 }; + *(DWORD*)&search[1] = (DWORD)find; + return memmem(buffer + section[i].PointerToRawData, section[i].SizeOfRawData, search, sizeof(search)); + break; + } + } + } + return NULL; +} +#endif + template void StringSplit(String *str, Char delim, Function f) {