Skip to content

Commit

Permalink
chore: minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Bush2021 committed May 11, 2024
1 parent ca4a491 commit 090959e
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions src/chrome++.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ HMODULE hInstance;
#include "green.h"

typedef int (*Startup)();
Startup ExeMain = NULL;
Startup ExeMain = nullptr;

void ChromePlus() {
// Shortcut.
Expand Down Expand Up @@ -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;

Expand Down
14 changes: 7 additions & 7 deletions src/fastsearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -22,19 +22,19 @@ 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;
}

i = 0;
while (i <= n - m) {
j = 0;
while (s[i + j] == p[j]) {
j++;
++j;
if (j >= m) {
return s + i;
}
Expand All @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions src/green.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

BOOL WINAPI FakeGetComputerName(_Out_ LPTSTR lpBuffer,
_Inout_ LPDWORD lpnSize) {
return 0;
return false;
}

BOOL WINAPI FakeGetVolumeInformation(_In_opt_ LPCTSTR lpRootPathName,
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/hijack.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/hotkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/iaccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ NodePtr FindChildElement(NodePtr parent, long role, int skipcount = 0) {
if (i == skipcount) {
element = child;
}
i++;
++i;
}
return element != nullptr;
});
Expand Down
4 changes: 2 additions & 2 deletions src/pakfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ bool CheckHeader(uint8_t* buffer,

template <typename Function>
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))
Expand Down
16 changes: 8 additions & 8 deletions src/pakpatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

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,
_In_ DWORD dwFileOffsetHigh,
_In_ DWORD dwFileOffsetLow,
_In_ SIZE_T dwNumberOfBytesToMap);

pMapViewOfFile RawMapViewOfFile = NULL;
pMapViewOfFile RawMapViewOfFile = nullptr;

HANDLE WINAPI MyMapViewOfFile(_In_ HANDLE hFileMappingObject,
_In_ DWORD dwDesiredAccess,
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ 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) {
break;
}
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]);
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 090959e

Please sign in to comment.