Skip to content

Commit

Permalink
修改关于界面
Browse files Browse the repository at this point in the history
  • Loading branch information
shuax committed Dec 27, 2015
1 parent 56f8268 commit 87b41f7
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 45 deletions.
5 changes: 5 additions & 0 deletions src/GreenChrome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ void GreenChrome()
// 让新标签一片空白
BlankNewTab(iniPath);

// 生成关于,64位不好改,暂时不弄
#ifndef _WIN64
BuildAboutProduct();
#endif

// 标签页,书签,地址栏增强
TabBookmark(iniPath);

Expand Down
113 changes: 68 additions & 45 deletions src/Patchs.h
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -284,4 +284,27 @@ void BlankNewTab(const wchar_t *iniPath)
MH_EnableHook(CreateFileW);
}
}
}
}



#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
52 changes: 52 additions & 0 deletions src/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; i<nt_header->FileHeader.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; i<nt_header->FileHeader.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<typename String, typename Char, typename Function>
void StringSplit(String *str, Char delim, Function f)
{
Expand Down

0 comments on commit 87b41f7

Please sign in to comment.