diff --git a/src/chrome++.cpp b/src/chrome++.cpp index 1224f96..914f0e2 100644 --- a/src/chrome++.cpp +++ b/src/chrome++.cpp @@ -21,7 +21,7 @@ HMODULE hInstance; #include "green.h" typedef int (*Startup)(); -Startup ExeMain = NULL; +Startup ExeMain = nullptr; void ChromePlus() { // Shortcut. @@ -66,7 +66,7 @@ int Loader() { void InstallLoader() { // Get the address of the original entry point of the main module. MODULEINFO mi; - GetModuleInformation(GetCurrentProcess(), GetModuleHandle(NULL), &mi, + GetModuleInformation(GetCurrentProcess(), GetModuleHandle(nullptr), &mi, sizeof(MODULEINFO)); PBYTE entry = (PBYTE)mi.EntryPoint; diff --git a/src/fastsearch.h b/src/fastsearch.h index 7e973cb..6af3e30 100644 --- a/src/fastsearch.h +++ b/src/fastsearch.h @@ -5,13 +5,13 @@ static const uint8_t* ForceSearch(const uint8_t* s, int n, const uint8_t* p) { int i; - for (i = 0; i < n; i++) { + for (i = 0; i < n; ++i) { if (*(s + i) == *p) { return s + i; } } - return NULL; + return nullptr; } static const uint8_t* SundaySearch(const uint8_t* s, @@ -22,11 +22,11 @@ static const uint8_t* SundaySearch(const uint8_t* s, size_t skip[256]; - for (i = 0; i < 256; i++) { + for (i = 0; i < 256; ++i) { skip[i] = m + 1; } - for (i = 0; i < m; i++) { + for (i = 0; i < m; ++i) { skip[p[i]] = m - i; } @@ -34,7 +34,7 @@ static const uint8_t* SundaySearch(const uint8_t* s, while (i <= n - m) { j = 0; while (s[i + j] == p[j]) { - j++; + ++j; if (j >= m) { return s + i; } @@ -43,12 +43,12 @@ static const uint8_t* SundaySearch(const uint8_t* s, i += (int)skip[s[i + m]]; } - return NULL; + return nullptr; } const uint8_t* FastSearch(const uint8_t* s, int n, const uint8_t* p, int m) { if (!s || !p || n < m) - return NULL; + return nullptr; if (m == 0) { return s; diff --git a/src/green.h b/src/green.h index 9adedbb..10afff1 100644 --- a/src/green.h +++ b/src/green.h @@ -5,7 +5,7 @@ BOOL WINAPI FakeGetComputerName(_Out_ LPTSTR lpBuffer, _Inout_ LPDWORD lpnSize) { - return 0; + return false; } BOOL WINAPI FakeGetVolumeInformation(_In_opt_ LPCTSTR lpRootPathName, @@ -16,7 +16,7 @@ BOOL WINAPI FakeGetVolumeInformation(_In_opt_ LPCTSTR lpRootPathName, _Out_opt_ LPDWORD lpFileSystemFlags, _Out_opt_ LPTSTR lpFileSystemNameBuffer, _In_ DWORD nFileSystemNameSize) { - return 0; + return false; } BOOL WINAPI @@ -42,7 +42,7 @@ typedef BOOL(WINAPI* pCryptUnprotectData)( _In_ DWORD dwFlags, _Out_ DATA_BLOB* pDataOut); -pCryptUnprotectData RawCryptUnprotectData = NULL; +pCryptUnprotectData RawCryptUnprotectData = nullptr; BOOL WINAPI MyCryptUnprotectData(_In_ DATA_BLOB* pDataIn, @@ -70,7 +70,7 @@ typedef DWORD(WINAPI* pLogonUserW)(LPCWSTR lpszUsername, DWORD dwLogonProvider, PHANDLE phToken); -pLogonUserW RawLogonUserW = NULL; +pLogonUserW RawLogonUserW = nullptr; DWORD WINAPI MyLogonUserW(LPCWSTR lpszUsername, LPCWSTR lpszDomain, @@ -87,7 +87,7 @@ DWORD WINAPI MyLogonUserW(LPCWSTR lpszUsername, typedef BOOL(WINAPI* pIsOS)(DWORD dwOS); -pIsOS RawIsOS = NULL; +pIsOS RawIsOS = nullptr; BOOL WINAPI MyIsOS(DWORD dwOS) { DWORD ret = RawIsOS(dwOS); @@ -103,7 +103,7 @@ typedef NET_API_STATUS(WINAPI* pNetUserGetInfo)(LPCWSTR servername, DWORD level, LPBYTE* bufptr); -pNetUserGetInfo RawNetUserGetInfo = NULL; +pNetUserGetInfo RawNetUserGetInfo = nullptr; NET_API_STATUS WINAPI MyNetUserGetInfo(LPCWSTR servername, LPCWSTR username, @@ -170,14 +170,14 @@ void MakeGreen() { (PBYTE)GetProcAddress(kernel32, "GetVolumeInformationW"); MH_STATUS status = - MH_CreateHook(GetComputerNameW, FakeGetComputerName, NULL); + MH_CreateHook(GetComputerNameW, FakeGetComputerName, nullptr); if (status == MH_OK) { MH_EnableHook(GetComputerNameW); } else { DebugLog(L"MH_CreateHook GetComputerNameW failed:%d", status); } status = - MH_CreateHook(GetVolumeInformationW, FakeGetVolumeInformation, NULL); + MH_CreateHook(GetVolumeInformationW, FakeGetVolumeInformation, nullptr); if (status == MH_OK) { MH_EnableHook(GetVolumeInformationW); } else { @@ -193,7 +193,7 @@ void MakeGreen() { (PBYTE)GetProcAddress(Crypt32, "CryptUnprotectData"); MH_STATUS status = - MH_CreateHook(CryptProtectData, MyCryptProtectData, NULL); + MH_CreateHook(CryptProtectData, MyCryptProtectData, nullptr); if (status == MH_OK) { MH_EnableHook(CryptProtectData); } else { diff --git a/src/hijack.h b/src/hijack.h index 802f5bc..fb7cd21 100644 --- a/src/hijack.h +++ b/src/hijack.h @@ -109,7 +109,7 @@ bool WriteMemory(PBYTE BaseAddress, PBYTE Buffer, DWORD nSize) { // Restore the export function. void InstallJMP(PBYTE BaseAddress, uintptr_t Function) { if (*BaseAddress == 0xE9) { - BaseAddress++; + ++BaseAddress; BaseAddress = BaseAddress + *(uint32_t*)BaseAddress + 4; } #ifdef _WIN64 @@ -159,7 +159,7 @@ void LoadVersion(HINSTANCE hModule) { lstrcat(szDLLPath, TEXT("\\version.dll")); HINSTANCE module = LoadLibrary(szDLLPath); - for (size_t i = 0; i < pimExD->NumberOfNames; i++) { + for (size_t i = 0; i < pimExD->NumberOfNames; ++i) { uintptr_t Original = (uintptr_t)GetProcAddress(module, (char*)(pImageBase + pName[i])); if (Original) { diff --git a/src/hotkey.h b/src/hotkey.h index 2f41158..248e5f9 100644 --- a/src/hotkey.h +++ b/src/hotkey.h @@ -83,7 +83,7 @@ void HideAndShow() { EnumWindows(SearchChromeWindow, 0); } else { for (auto r_iter = hwnd_list.rbegin(); r_iter != hwnd_list.rend(); - r_iter++) { + ++r_iter) { ShowWindow(*r_iter, SW_SHOW); } hwnd_list.clear(); @@ -110,10 +110,10 @@ void Hotkey(const std::wstring& keys, HotkeyAction action) { UINT flag = ParseHotkeys(keys.c_str()); std::thread th([flag, action]() { - RegisterHotKey(NULL, 0, LOWORD(flag), HIWORD(flag)); + RegisterHotKey(nullptr, 0, LOWORD(flag), HIWORD(flag)); MSG msg; - while (GetMessage(&msg, NULL, 0, 0)) { + while (GetMessage(&msg, nullptr, 0, 0)) { if (msg.message == WM_HOTKEY) { OnHotkey(action); } diff --git a/src/iaccessible.h b/src/iaccessible.h index f4b0055..c40b96e 100644 --- a/src/iaccessible.h +++ b/src/iaccessible.h @@ -290,7 +290,7 @@ NodePtr FindChildElement(NodePtr parent, long role, int skipcount = 0) { if (i == skipcount) { element = child; } - i++; + ++i; } return element != nullptr; }); diff --git a/src/pakfile.h b/src/pakfile.h index 93f1d7b..cdaca64 100644 --- a/src/pakfile.h +++ b/src/pakfile.h @@ -75,8 +75,8 @@ bool CheckHeader(uint8_t* buffer, template void PakFind(uint8_t* buffer, uint8_t* pos, Function f) { - PAK_ENTRY* pak_entry = NULL; - PAK_ENTRY* end_entry = NULL; + PAK_ENTRY* pak_entry = nullptr; + PAK_ENTRY* end_entry = nullptr; // Check the file header. if (!CheckHeader(buffer, pak_entry, end_entry)) diff --git a/src/pakpatch.h b/src/pakpatch.h index 587796f..3e26d35 100644 --- a/src/pakpatch.h +++ b/src/pakpatch.h @@ -5,7 +5,7 @@ DWORD resources_pak_size = 0; -HANDLE resources_pak_map = NULL; +HANDLE resources_pak_map = nullptr; typedef HANDLE(WINAPI* pMapViewOfFile)(_In_ HANDLE hFileMappingObject, _In_ DWORD dwDesiredAccess, @@ -13,7 +13,7 @@ typedef HANDLE(WINAPI* pMapViewOfFile)(_In_ HANDLE hFileMappingObject, _In_ DWORD dwFileOffsetLow, _In_ SIZE_T dwNumberOfBytesToMap); -pMapViewOfFile RawMapViewOfFile = NULL; +pMapViewOfFile RawMapViewOfFile = nullptr; HANDLE WINAPI MyMapViewOfFile(_In_ HANDLE hFileMappingObject, _In_ DWORD dwDesiredAccess, @@ -27,7 +27,7 @@ HANDLE WINAPI MyMapViewOfFile(_In_ HANDLE hFileMappingObject, dwFileOffsetLow, dwNumberOfBytesToMap); // No more hook needed. - resources_pak_map = NULL; + resources_pak_map = nullptr; MH_DisableHook(MapViewOfFile); if (buffer) { @@ -79,7 +79,7 @@ HANDLE WINAPI MyMapViewOfFile(_In_ HANDLE hFileMappingObject, dwFileOffsetLow, dwNumberOfBytesToMap); } -HANDLE resources_pak_file = NULL; +HANDLE resources_pak_file = nullptr; typedef HANDLE(WINAPI* pCreateFileMapping)(_In_ HANDLE hFile, _In_opt_ LPSECURITY_ATTRIBUTES @@ -89,7 +89,7 @@ typedef HANDLE(WINAPI* pCreateFileMapping)(_In_ HANDLE hFile, _In_ DWORD dwMaximumSizeLow, _In_opt_ LPCTSTR lpName); -pCreateFileMapping RawCreateFileMapping = NULL; +pCreateFileMapping RawCreateFileMapping = nullptr; HANDLE WINAPI MyCreateFileMapping(_In_ HANDLE hFile, _In_opt_ LPSECURITY_ATTRIBUTES lpAttributes, @@ -104,7 +104,7 @@ HANDLE WINAPI MyCreateFileMapping(_In_ HANDLE hFile, dwMaximumSizeHigh, dwMaximumSizeLow, lpName); // No more hook needed. - resources_pak_file = NULL; + resources_pak_file = nullptr; MH_DisableHook(CreateFileMappingW); if (MH_CreateHook(MapViewOfFile, MyMapViewOfFile, @@ -127,7 +127,7 @@ typedef HANDLE(WINAPI* pCreateFile)(_In_ LPCTSTR lpFileName, _In_ DWORD dwFlagsAndAttributes, _In_opt_ HANDLE hTemplateFile); -pCreateFile RawCreateFile = NULL; +pCreateFile RawCreateFile = nullptr; HANDLE WINAPI MyCreateFile(_In_ LPCTSTR lpFileName, _In_ DWORD dwDesiredAccess, @@ -142,7 +142,7 @@ HANDLE WINAPI MyCreateFile(_In_ LPCTSTR lpFileName, if (isEndWith(lpFileName, L"resources.pak")) { resources_pak_file = file; - resources_pak_size = GetFileSize(resources_pak_file, NULL); + resources_pak_size = GetFileSize(resources_pak_file, nullptr); if (MH_CreateHook(CreateFileMappingW, MyCreateFileMapping, (LPVOID*)&RawCreateFileMapping) == MH_OK) { diff --git a/src/portable.h b/src/portable.h index 16b8110..8d605b7 100644 --- a/src/portable.h +++ b/src/portable.h @@ -37,7 +37,7 @@ std::wstring GetCommand(LPWSTR param) { LPWSTR* argv = CommandLineToArgvW(param, &argc); int insert_pos = 0; - for (int i = 0; i < argc; i++) { + for (int i = 0; i < argc; ++i) { if (std::wstring(argv[i]).find(L"--") != std::wstring::npos || std::wstring(argv[i]).find(L"--single-argument") != std::wstring::npos) { @@ -45,7 +45,7 @@ std::wstring GetCommand(LPWSTR param) { } insert_pos = i; } - for (int i = 0; i < argc; i++) { + for (int i = 0; i < argc; ++i) { // Preserve former arguments. if (i) args.push_back(argv[i]); @@ -97,7 +97,7 @@ std::wstring GetCommand(LPWSTR param) { void Portable(LPWSTR param) { wchar_t path[MAX_PATH]; - ::GetModuleFileName(NULL, path, MAX_PATH); + ::GetModuleFileName(nullptr, path, MAX_PATH); std::wstring args = GetCommand(param); diff --git a/src/utils.h b/src/utils.h index a726822..d985c21 100644 --- a/src/utils.h +++ b/src/utils.h @@ -184,7 +184,7 @@ uint8_t* SearchModuleRaw(HMODULE module, const uint8_t* sub, int m) { sizeof(IMAGE_FILE_HEADER) + nt_header->FileHeader.SizeOfOptionalHeader); - for (int i = 0; i < nt_header->FileHeader.NumberOfSections; i++) { + for (int i = 0; i < nt_header->FileHeader.NumberOfSections; ++i) { if (strcmp((const char*)section[i].Name, ".text") == 0) { return memmem(buffer + section[i].PointerToRawData, section[i].SizeOfRawData, sub, m); @@ -204,7 +204,7 @@ uint8_t* SearchModuleRaw2(HMODULE module, const uint8_t* sub, int m) { sizeof(IMAGE_FILE_HEADER) + nt_header->FileHeader.SizeOfOptionalHeader); - for (int i = 0; i < nt_header->FileHeader.NumberOfSections; i++) { + for (int i = 0; i < nt_header->FileHeader.NumberOfSections; ++i) { if (strcmp((const char*)section[i].Name, ".rdata") == 0) { return memmem(buffer + section[i].PointerToRawData, section[i].SizeOfRawData, sub, m);