Skip to content

Commit

Permalink
style: reformat using Chromium style
Browse files Browse the repository at this point in the history
  • Loading branch information
Bush2021 committed May 9, 2024
1 parent 15bb95d commit d28fe91
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 175 deletions.
79 changes: 1 addition & 78 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,81 +3,4 @@
# Author: Kehan Xue, kehan.xue (at) gmail.com

Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: Align
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never # To avoid conflict, set this "Never" and each "if statement" should include brace when coding
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterStruct: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 80
CompactNamespaces: false
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false # Make sure the * or & align on the left
EmptyLineBeforeAccessModifier: LogicalBlock
FixNamespaceComments: true
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Left
ReflowComments: false
# SeparateDefinitionBlocks: Always # Only support since clang-format 14
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++11
TabWidth: 4
UseTab: Never
BasedOnStyle: Chromium
6 changes: 4 additions & 2 deletions src/appid.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
#include <shobjidl.h>

typedef HRESULT(WINAPI* pPSStringFromPropertyKey)(REFPROPERTYKEY pkey,
LPWSTR psz, UINT cch);
LPWSTR psz,
UINT cch);
pPSStringFromPropertyKey RawPSStringFromPropertyKey = nullptr;

HRESULT WINAPI MyPSStringFromPropertyKey(REFPROPERTYKEY pkey, LPWSTR psz,
HRESULT WINAPI MyPSStringFromPropertyKey(REFPROPERTYKEY pkey,
LPWSTR psz,
UINT cch) {
HRESULT result = RawPSStringFromPropertyKey(pkey, psz, cch);
if (SUCCEEDED(result)) {
Expand Down
3 changes: 2 additions & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ bool IsIniExist() {
return false;
}

std::wstring GetIniString(const std::wstring& section, const std::wstring& key,
std::wstring GetIniString(const std::wstring& section,
const std::wstring& key,
const std::wstring& default_value) {
std::vector<TCHAR> buffer(100);
DWORD bytesread = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/fastsearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ static const uint8_t* ForceSearch(const uint8_t* s, int n, const uint8_t* p) {
return NULL;
}

static const uint8_t* SundaySearch(const uint8_t* s, int n, const uint8_t* p,
static const uint8_t* SundaySearch(const uint8_t* s,
int n,
const uint8_t* p,
int m) {
int i, j;

Expand Down
79 changes: 52 additions & 27 deletions src/green.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,39 @@ BOOL WINAPI FakeGetVolumeInformation(_In_opt_ LPCTSTR lpRootPathName,
return 0;
}

BOOL WINAPI MyCryptProtectData(
_In_ DATA_BLOB* pDataIn, _In_opt_ LPCWSTR szDataDescr,
_In_opt_ DATA_BLOB* pOptionalEntropy, _Reserved_ PVOID pvReserved,
_In_opt_ CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct, _In_ DWORD dwFlags,
_Out_ DATA_BLOB* pDataOut) {
BOOL WINAPI
MyCryptProtectData(_In_ DATA_BLOB* pDataIn,
_In_opt_ LPCWSTR szDataDescr,
_In_opt_ DATA_BLOB* pOptionalEntropy,
_Reserved_ PVOID pvReserved,
_In_opt_ CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct,
_In_ DWORD dwFlags,
_Out_ DATA_BLOB* pDataOut) {
pDataOut->cbData = pDataIn->cbData;
pDataOut->pbData = (BYTE*)LocalAlloc(LMEM_FIXED, pDataOut->cbData);
memcpy(pDataOut->pbData, pDataIn->pbData, pDataOut->cbData);
return true;
}

typedef BOOL(WINAPI* pCryptUnprotectData)(
_In_ DATA_BLOB* pDataIn, _Out_opt_ LPWSTR* ppszDataDescr,
_In_opt_ DATA_BLOB* pOptionalEntropy, _Reserved_ PVOID pvReserved,
_In_opt_ CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct, _In_ DWORD dwFlags,
_In_ DATA_BLOB* pDataIn,
_Out_opt_ LPWSTR* ppszDataDescr,
_In_opt_ DATA_BLOB* pOptionalEntropy,
_Reserved_ PVOID pvReserved,
_In_opt_ CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct,
_In_ DWORD dwFlags,
_Out_ DATA_BLOB* pDataOut);

pCryptUnprotectData RawCryptUnprotectData = NULL;

BOOL WINAPI MyCryptUnprotectData(
_In_ DATA_BLOB* pDataIn, _Out_opt_ LPWSTR* ppszDataDescr,
_In_opt_ DATA_BLOB* pOptionalEntropy, _Reserved_ PVOID pvReserved,
_In_opt_ CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct, _In_ DWORD dwFlags,
_Out_ DATA_BLOB* pDataOut) {
BOOL WINAPI
MyCryptUnprotectData(_In_ DATA_BLOB* pDataIn,
_Out_opt_ LPWSTR* ppszDataDescr,
_In_opt_ DATA_BLOB* pOptionalEntropy,
_Reserved_ PVOID pvReserved,
_In_opt_ CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct,
_In_ DWORD dwFlags,
_Out_ DATA_BLOB* pDataOut) {
if (RawCryptUnprotectData(pDataIn, ppszDataDescr, pOptionalEntropy,
pvReserved, pPromptStruct, dwFlags, pDataOut)) {
return true;
Expand All @@ -54,15 +63,21 @@ BOOL WINAPI MyCryptUnprotectData(
return true;
}

typedef DWORD(WINAPI* pLogonUserW)(LPCWSTR lpszUsername, LPCWSTR lpszDomain,
LPCWSTR lpszPassword, DWORD dwLogonType,
DWORD dwLogonProvider, PHANDLE phToken);
typedef DWORD(WINAPI* pLogonUserW)(LPCWSTR lpszUsername,
LPCWSTR lpszDomain,
LPCWSTR lpszPassword,
DWORD dwLogonType,
DWORD dwLogonProvider,
PHANDLE phToken);

pLogonUserW RawLogonUserW = NULL;

DWORD WINAPI MyLogonUserW(LPCWSTR lpszUsername, LPCWSTR lpszDomain,
LPCWSTR lpszPassword, DWORD dwLogonType,
DWORD dwLogonProvider, PHANDLE phToken) {
DWORD WINAPI MyLogonUserW(LPCWSTR lpszUsername,
LPCWSTR lpszDomain,
LPCWSTR lpszPassword,
DWORD dwLogonType,
DWORD dwLogonProvider,
PHANDLE phToken) {
DWORD ret = RawLogonUserW(lpszUsername, lpszDomain, lpszPassword, dwLogonType,
dwLogonProvider, phToken);

Expand All @@ -84,13 +99,16 @@ BOOL WINAPI MyIsOS(DWORD dwOS) {
}

typedef NET_API_STATUS(WINAPI* pNetUserGetInfo)(LPCWSTR servername,
LPCWSTR username, DWORD level,
LPCWSTR username,
DWORD level,
LPBYTE* bufptr);

pNetUserGetInfo RawNetUserGetInfo = NULL;

NET_API_STATUS WINAPI MyNetUserGetInfo(LPCWSTR servername, LPCWSTR username,
DWORD level, LPBYTE* bufptr) {
NET_API_STATUS WINAPI MyNetUserGetInfo(LPCWSTR servername,
LPCWSTR username,
DWORD level,
LPBYTE* bufptr) {
NET_API_STATUS ret = RawNetUserGetInfo(servername, username, level, bufptr);
if (level == 1 && ret == 0) {
LPUSER_INFO_1 user_info = (LPUSER_INFO_1)*bufptr;
Expand All @@ -107,16 +125,23 @@ NET_API_STATUS WINAPI MyNetUserGetInfo(LPCWSTR servername, LPCWSTR username,
(0x00000001ui64 << 28)

typedef BOOL(WINAPI* pUpdateProcThreadAttribute)(
LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, DWORD dwFlags,
DWORD_PTR Attribute, PVOID lpValue, SIZE_T cbSize, PVOID lpPreviousValue,
LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList,
DWORD dwFlags,
DWORD_PTR Attribute,
PVOID lpValue,
SIZE_T cbSize,
PVOID lpPreviousValue,
PSIZE_T lpReturnSize);

pUpdateProcThreadAttribute RawUpdateProcThreadAttribute = nullptr;

BOOL WINAPI MyUpdateProcThreadAttribute(
__inout LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, __in DWORD dwFlags,
__in DWORD_PTR Attribute, __in_bcount_opt(cbSize) PVOID lpValue,
__in SIZE_T cbSize, __out_bcount_opt(cbSize) PVOID lpPreviousValue,
__inout LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList,
__in DWORD dwFlags,
__in DWORD_PTR Attribute,
__in_bcount_opt(cbSize) PVOID lpValue,
__in SIZE_T cbSize,
__out_bcount_opt(cbSize) PVOID lpPreviousValue,
__in_opt PSIZE_T lpReturnSize) {
if (Attribute == PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY &&
cbSize >= sizeof(DWORD64)) {
Expand Down
3 changes: 2 additions & 1 deletion src/hotkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ BOOL CALLBACK SearchChromeWindow(HWND hWnd, LPARAM lParam) {
wchar_t buff[256];
GetClassNameW(hWnd, buff, 255);
if (wcscmp(buff, L"Chrome_WidgetWin_1") ==
0) // || wcscmp(buff, L"Chrome_WidgetWin_2")==0 || wcscmp(buff, L"SysShadow")==0 )
0) // || wcscmp(buff, L"Chrome_WidgetWin_2")==0 || wcscmp(buff,
// L"SysShadow")==0 )
{
ShowWindow(hWnd, SW_HIDE);
hwnd_list.push_back(hWnd);
Expand Down
11 changes: 6 additions & 5 deletions src/iaccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ void TraversalAccessible(NodePtr node, Function f, bool raw_traversal = false) {
}

if (is_task_completed) {
arrChildren[j].pdispVal->Release(); // Release immediately to avoid memory leaks.
arrChildren[j]
.pdispVal->Release(); // Release immediately to avoid memory leaks.
continue;
}

Expand Down Expand Up @@ -356,7 +357,6 @@ bool IsOnTheTabBar(NodePtr top, POINT pt) {

// Determine whether it is a new tab page from the name of the current tab page.
bool IsNameNewTab(NodePtr top) {

bool flag = false;
std::unique_ptr<wchar_t, decltype(&free)> new_tab_name(nullptr, free);
NodePtr page_tab_list = FindElementWithRole(top, ROLE_SYSTEM_PAGETABLIST);
Expand All @@ -367,7 +367,8 @@ bool IsNameNewTab(NodePtr top) {
TraversalAccessible(page_tab_list, [&new_tab_name](NodePtr child) {
if (GetAccessibleRole(child) == ROLE_SYSTEM_PUSHBUTTON) {
GetAccessibleName(child, [&new_tab_name](BSTR bstr) {
new_tab_name.reset(_wcsdup(bstr)); // Save the name obtained from the new tab button.
new_tab_name.reset(
_wcsdup(bstr)); // Save the name obtained from the new tab button.
});
}
return false;
Expand Down Expand Up @@ -407,9 +408,9 @@ bool IsNameNewTab(NodePtr top) {
return flag;
}

// Determine whether it is a new tab page from the document value of the tab page.
// Determine whether it is a new tab page from the document value of the tab
// page.
bool IsDocNewTab() {

auto cr_command_line = GetCrCommandLine();
if (cr_command_line.find(L"--force-renderer-accessibility") ==
std::wstring::npos) {
Expand Down
3 changes: 2 additions & 1 deletion src/pakfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ struct PAK_ALIAS {
};
#pragma pack(pop)

bool CheckHeader(uint8_t* buffer, PAK_ENTRY*& pak_entry,
bool CheckHeader(uint8_t* buffer,
PAK_ENTRY*& pak_entry,
PAK_ENTRY*& end_entry) {
uint32_t version = *(uint32_t*)buffer;

Expand Down
28 changes: 17 additions & 11 deletions src/pakpatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ HANDLE WINAPI MyMapViewOfFile(_In_ HANDLE hFileMappingObject,
uint8_t* pos =
memmem(begin, size, search_start, sizeof(search_start) - 1);
if (pos) {

// Compress the HTML for writing patch information.
std::string html((char*)begin, size);
compression_html(html);
Expand Down Expand Up @@ -82,10 +81,13 @@ HANDLE WINAPI MyMapViewOfFile(_In_ HANDLE hFileMappingObject,

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);
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);

pCreateFileMapping RawCreateFileMapping = NULL;

Expand Down Expand Up @@ -116,15 +118,19 @@ HANDLE WINAPI MyCreateFileMapping(_In_ HANDLE hFile,
dwMaximumSizeLow, lpName);
}

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);
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);

pCreateFile RawCreateFile = NULL;

HANDLE WINAPI MyCreateFile(_In_ LPCTSTR lpFileName, _In_ DWORD dwDesiredAccess,
HANDLE WINAPI MyCreateFile(_In_ LPCTSTR lpFileName,
_In_ DWORD dwDesiredAccess,
_In_ DWORD dwShareMode,
_In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
_In_ DWORD dwCreationDisposition,
Expand Down
8 changes: 4 additions & 4 deletions src/patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ pLdrLoadDll RawLdrLoadDll = nullptr;
// void Outdated(HMODULE module) {
// // "OutdatedUpgradeBubble.Show"
// #ifdef _WIN64
// BYTE search[] = {0x48, 0x89, 0x8C, 0x24, 0xF0, 0x00, 0x00, 0x00, 0x80, 0x3D};
// uint8_t* match = SearchModuleRaw(module, search, sizeof(search));
// BYTE search[] = {0x48, 0x89, 0x8C, 0x24, 0xF0, 0x00, 0x00, 0x00, 0x80,
// 0x3D}; uint8_t* match = SearchModuleRaw(module, search, sizeof(search));
// #else
// BYTE search[] = {0x31, 0xE8, 0x89, 0x45, 0xF0, 0x88, 0x5D, 0xEF, 0x80, 0x3D};
// uint8_t* match = SearchModuleRaw(module, search, sizeof(search));
// BYTE search[] = {0x31, 0xE8, 0x89, 0x45, 0xF0, 0x88, 0x5D, 0xEF, 0x80,
// 0x3D}; uint8_t* match = SearchModuleRaw(module, search, sizeof(search));
// #endif
// if (match) {
// if (*(match + 0xF) == 0x74) {
Expand Down
3 changes: 2 additions & 1 deletion src/portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ std::wstring GetCommand(LPWSTR param) {
// Get the command line and append parameters
// Intercept and split the parameters starting with each --,
// and then args.push_back multiple times
// Repeat the above process until the -- sign no longer exists in the string
// Repeat the above process until the -- sign no longer exists in the
// string
{
auto cr_command_line = GetCrCommandLine();
std::wstring temp = cr_command_line;
Expand Down
1 change: 0 additions & 1 deletion src/tabbookmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
}

int HandleKeepTab(WPARAM wParam) {

if (!(wParam == 'W' && IsPressed(VK_CONTROL) && !IsPressed(VK_SHIFT)) &&
!(wParam == VK_F4 && IsPressed(VK_CONTROL))) {
return 0;
Expand Down
Loading

0 comments on commit d28fe91

Please sign in to comment.