aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-04-26 20:57:04 -0700
committerFuwn <[email protected]>2022-04-26 20:57:04 -0700
commit98f4b7c5b3c38a78b200efe84bbb5c3f9f627f11 (patch)
tree6bd04b62c191536c2942e8b347c1a583dad4112d
parentrefactor(cc): remove unused implementation unit (diff)
downloadsoyuz-98f4b7c5b3c38a78b200efe84bbb5c3f9f627f11.tar.xz
soyuz-98f4b7c5b3c38a78b200efe84bbb5c3f9f627f11.zip
refactor(include): global formatting
-rw-r--r--include/soyuz/library.hh22
-rw-r--r--include/soyuz/resource.hh10
-rw-r--r--include/soyuz/soyuz.hh2
-rw-r--r--include/soyuz/tray.hh4
-rw-r--r--include/soyuz/windows.hh32
-rw-r--r--soyuz/library.cc24
-rw-r--r--soyuz/soyuz.cc18
-rw-r--r--soyuz/tray.cc4
8 files changed, 60 insertions, 56 deletions
diff --git a/include/soyuz/library.hh b/include/soyuz/library.hh
index f96bbf2..8ada0bf 100644
--- a/include/soyuz/library.hh
+++ b/include/soyuz/library.hh
@@ -29,23 +29,27 @@ const std::string numbers_as_string[] = {
};
enum log_level {
- trace,
- debug,
- info,
- warn,
- error,
+ LOG_LEVEL_TRACE,
+ LOG_LEVEL_DEBUG,
+ LOG_LEVEL_INFO,
+ LOG_LEVEL_WARN,
+ LOG_LEVEL_ERROR,
};
struct log_t {
log_level level;
std::string value;
- log_t(log_level level, std::string value) : level(level), value(std::move(value)) {}
+ log_t(
+ log_level level,
+ std::string value
+ ) : level(level), value(std::move(value))
+ {}
- auto to_coloref() -> COLORREF;
+ auto to_colorref() -> COLORREF;
};
-static BOOL CALLBACK enum_windows_proc(HWND, LPARAM);
+static auto CALLBACK enum_windows_proc(HWND, LPARAM) -> BOOL;
auto find_lunar() -> DWORD;
auto delete_handle(DWORD) -> int;
auto write_log_file(const std::string &) -> void;
@@ -57,4 +61,4 @@ auto current_date_time() -> std::string;
}
-#endif //SOYUZ_LIBRARY_HH
+#endif // SOYUZ_LIBRARY_HH
diff --git a/include/soyuz/resource.hh b/include/soyuz/resource.hh
index 28cb4b3..4caebbf 100644
--- a/include/soyuz/resource.hh
+++ b/include/soyuz/resource.hh
@@ -14,9 +14,9 @@
#include <shellapi.h>
#include <Windows.h>
-#define ICO1 101
-#define ID_TRAY_APP_ICON 1001
-#define ID_TRAY_EXIT 1002
-#define WM_SYSICON (WM_USER + 1)
+#define ICO1 101
+#define ID_TRAY_APP_ICON 1001
+#define ID_TRAY_EXIT 1002
+#define WM_SYSICON (WM_USER + 1)
-#endif //SOYUZ_RESOURCE_HH
+#endif // SOYUZ_RESOURCE_HH
diff --git a/include/soyuz/soyuz.hh b/include/soyuz/soyuz.hh
index c831080..3e63e3b 100644
--- a/include/soyuz/soyuz.hh
+++ b/include/soyuz/soyuz.hh
@@ -15,4 +15,4 @@
#define DISCORD_IPC_NAMED_PIPE_NAME L"\\Device\\NamedPipe\\discord-ipc-0"
#define WINDOW_TRAY_NAME "Soyuz - 1.1.2 | Copyright (C) 2021-2022 Fuwn"
-#endif //SOYUZ_SOYUZ_HH
+#endif // SOYUZ_SOYUZ_HH
diff --git a/include/soyuz/tray.hh b/include/soyuz/tray.hh
index a6bdb89..c4adc30 100644
--- a/include/soyuz/tray.hh
+++ b/include/soyuz/tray.hh
@@ -17,7 +17,7 @@
#include <soyuz/library.hh>
-LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
+auto CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM) -> LRESULT;
auto minimize() -> void;
auto restore() -> void;
auto InitNotifyIconData() -> void;
@@ -29,4 +29,4 @@ auto log(log_level, const std::string &) -> void;
}
-#endif //SOYUZ_TRAY_HH
+#endif // SOYUZ_TRAY_HH
diff --git a/include/soyuz/windows.hh b/include/soyuz/windows.hh
index 00ab5d1..1acfaac 100644
--- a/include/soyuz/windows.hh
+++ b/include/soyuz/windows.hh
@@ -18,27 +18,27 @@ enum PROCESSINFOCLASS {
};
typedef struct _PROCESS_HANDLE_TABLE_ENTRY_INFO {
- HANDLE HandleValue;
+ HANDLE HandleValue;
ULONG_PTR HandleCount;
ULONG_PTR PointerCount;
- ULONG GrantedAccess;
- ULONG ObjectTypeIndex;
- ULONG HandleAttributes;
- ULONG Reserved;
+ ULONG GrantedAccess;
+ ULONG ObjectTypeIndex;
+ ULONG HandleAttributes;
+ ULONG Reserved;
} PROCESS_HANDLE_TABLE_ENTRY_INFO, * PPROCESS_HANDLE_TABLE_ENTRY_INFO;
typedef struct _PROCESS_HANDLE_SNAPSHOT_INFORMATION {
- ULONG_PTR NumberOfHandles;
- ULONG_PTR Reserved;
+ ULONG_PTR NumberOfHandles;
+ ULONG_PTR Reserved;
PROCESS_HANDLE_TABLE_ENTRY_INFO Handles[1];
} PROCESS_HANDLE_SNAPSHOT_INFORMATION, * PPROCESS_HANDLE_SNAPSHOT_INFORMATION;
extern "C" NTSTATUS NTAPI NtQueryInformationProcess(
- _In_ HANDLE ProcessHandle,
- _In_ PROCESSINFOCLASS ProcessInformationClass,
+ _In_ HANDLE ProcessHandle,
+ _In_ PROCESSINFOCLASS ProcessInformationClass,
_Out_writes_bytes_(ProcessInformationLength) PVOID ProcessInformation,
- _In_ ULONG ProcessInformationLength,
- _Out_opt_ PULONG ReturnLength
+ _In_ ULONG ProcessInformationLength,
+ _Out_opt_ PULONG ReturnLength
);
typedef enum _OBJECT_INFORMATION_CLASS {
@@ -56,11 +56,11 @@ typedef struct _OBJECT_NAME_INFORMATION {
} OBJECT_NAME_INFORMATION, * POBJECT_NAME_INFORMATION;
extern "C" NTSTATUS NTAPI NtQueryObject(
- _In_opt_ HANDLE Handle,
- _In_ OBJECT_INFORMATION_CLASS ObjectInformationClass,
+ _In_opt_ HANDLE Handle,
+ _In_ OBJECT_INFORMATION_CLASS ObjectInformationClass,
_Out_writes_bytes_opt_(ObjectInformationLength) PVOID ObjectInformation,
- _In_ ULONG ObjectInformationLength,
- _Out_opt_ PULONG ReturnLength
+ _In_ ULONG ObjectInformationLength,
+ _Out_opt_ PULONG ReturnLength
);
-#endif //SOYUZ_WINDOWS_HH
+#endif // SOYUZ_WINDOWS_HH
diff --git a/soyuz/library.cc b/soyuz/library.cc
index 691aaf3..8b9ea8b 100644
--- a/soyuz/library.cc
+++ b/soyuz/library.cc
@@ -62,7 +62,7 @@ auto delete_handle(DWORD pid) -> int {
pid
);
if (!lunar) {
- soyuz::log(soyuz::log_level::warn, fmt::format("could not open handle to lunar client: {}", GetLastError()));
+ soyuz::log(soyuz::log_level::LOG_LEVEL_WARN, fmt::format("could not open handle to lunar client: {}", GetLastError()));
return 1;
}
@@ -83,7 +83,7 @@ auto delete_handle(DWORD pid) -> int {
if (NT_SUCCESS(status)) { break; }
if (status == STATUS_INFO_LENGTH_MISMATCH) { size += 1 << 10; continue; }
- soyuz::log(soyuz::log_level::debug, "could not enumerate handle, skipping");
+ soyuz::log(soyuz::log_level::LOG_LEVEL_DEBUG, "could not enumerate handle, skipping");
return 1;
}
@@ -121,7 +121,7 @@ auto delete_handle(DWORD pid) -> int {
auto *name = reinterpret_cast<UNICODE_STRING *>(name_buffer);
if (name->Buffer && _wcsnicmp(name->Buffer, target_name, length) == 0) {
- soyuz::log(soyuz::log_level::info, "found lunar client's discord ipc named pipe");
+ soyuz::log(soyuz::log_level::LOG_LEVEL_INFO, "found lunar client's discord ipc named pipe");
DuplicateHandle(
lunar,
@@ -134,7 +134,7 @@ auto delete_handle(DWORD pid) -> int {
);
CloseHandle(target);
- soyuz::log(soyuz::log_level::info, "closed lunar client's discord ipc named pipe");
+ soyuz::log(soyuz::log_level::LOG_LEVEL_INFO, "closed lunar client's discord ipc named pipe");
return 0;
}
@@ -155,11 +155,11 @@ auto init_log_file() -> void {
// return;
// }
- soyuz::log(soyuz::log_level::debug, "opened 'soyuz.log'");
+ soyuz::log(soyuz::log_level::LOG_LEVEL_DEBUG, "opened 'soyuz.log'");
}
auto close_log_file() -> void {
- soyuz::log(soyuz::log_level::debug, "closing 'soyuz.log'"); log_file.close();
+ soyuz::log(soyuz::log_level::LOG_LEVEL_DEBUG, "closing 'soyuz.log'"); log_file.close();
}
auto exit(int exit_code) -> void {
@@ -178,13 +178,13 @@ auto current_date_time() -> std::string {
return buffer;
}
-auto log_t::to_coloref() -> COLORREF {
+auto log_t::to_colorref() -> COLORREF {
switch (this->level) {
- case trace: { return 0x00FF0000; } // blue
- case debug: { return 0x0000FF00; } // green
- case info: { return 0x00000000; } // black
- case warn: { return 0x000080FF; } // orange
- case error: { return 0x000000FF; } // red
+ case LOG_LEVEL_TRACE: { return 0x00FF0000; } // blue
+ case LOG_LEVEL_DEBUG: { return 0x0000FF00; } // green
+ case LOG_LEVEL_INFO: { return 0x00000000; } // black
+ case LOG_LEVEL_WARN: { return 0x000080FF; } // orange
+ case LOG_LEVEL_ERROR: { return 0x000000FF; } // red
default: { return 0x00000000; } // black
}
}
diff --git a/soyuz/soyuz.cc b/soyuz/soyuz.cc
index 9e1d8a9..db88b8a 100644
--- a/soyuz/soyuz.cc
+++ b/soyuz/soyuz.cc
@@ -75,17 +75,17 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int show) {
// Check if Lunar Client is open, if not; close Soyuz
DWORD pid = soyuz::find_lunar();
if (pid == 0 || pid == 3435973836) {
- soyuz::log(soyuz::log_level::error, "could not locate lunar client");
- soyuz::log(soyuz::log_level::warn, "this window will close in five seconds");
+ soyuz::log(soyuz::log_level::LOG_LEVEL_ERROR, "could not locate lunar client");
+ soyuz::log(soyuz::log_level::LOG_LEVEL_WARN, "this window will close in five seconds");
for (int i = 4; i > -1; --i) {
std::this_thread::sleep_for(std::chrono::seconds(1));
- soyuz::log(soyuz::log_level::warn, fmt::format("> {} second{}", soyuz::numbers_as_string[i], i != 1 ? "s" : ""));
+ soyuz::log(soyuz::log_level::LOG_LEVEL_WARN, fmt::format("> {} second{}", soyuz::numbers_as_string[i], i != 1 ? "s" : ""));
}
soyuz::exit(1);
}
- soyuz::log(soyuz::log_level::info, fmt::format("located lunar client: pid {}", pid)); // GetLastError()
- soyuz::log(soyuz::log_level::info, "hooked lunar client"); soyuz::log(soyuz::log_level::info, "you may now close this window");
+ soyuz::log(soyuz::log_level::LOG_LEVEL_INFO, fmt::format("located lunar client: pid {}", pid)); // GetLastError()
+ soyuz::log(soyuz::log_level::LOG_LEVEL_INFO, "hooked lunar client"); soyuz::log(soyuz::log_level::LOG_LEVEL_INFO, "you may now close this window");
while (!stop.stop_requested()) {
/**
@@ -95,13 +95,13 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int show) {
*/
pid = soyuz::find_lunar();
if (pid == 0 || pid == 3435973836) {
- soyuz::log(soyuz::log_level::warn, "could not locate lunar client, waiting 10 seconds");
+ soyuz::log(soyuz::log_level::LOG_LEVEL_WARN, "could not locate lunar client, waiting 10 seconds");
std::this_thread::sleep_for(std::chrono::seconds(10));
}
// If Lunar Client **is** open, close it's Discord IPC Named Pipe
if (soyuz::delete_handle(pid) == 1) {
- soyuz::log(soyuz::log_level::warn, "unable to close lunar client's discord ipc named pipe");
+ soyuz::log(soyuz::log_level::LOG_LEVEL_WARN, "unable to close lunar client's discord ipc named pipe");
}
}
}};
@@ -111,10 +111,10 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int show) {
DispatchMessage(&messages);
}
- soyuz::log(soyuz::log_level::info, "requesting exit");
+ soyuz::log(soyuz::log_level::LOG_LEVEL_INFO, "requesting exit");
soyuz.request_stop(); soyuz.detach();
- soyuz::log(soyuz::log_level::info, "exiting");
+ soyuz::log(soyuz::log_level::LOG_LEVEL_INFO, "exiting");
soyuz::close_log_file();
return (int)messages.wParam;
diff --git a/soyuz/tray.cc b/soyuz/tray.cc
index 85ea3f8..a1e914e 100644
--- a/soyuz/tray.cc
+++ b/soyuz/tray.cc
@@ -43,7 +43,7 @@ LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM
int height = 5;
for (soyuz::log_t &i : logs) {
- SetTextColor(hdc, i.to_coloref());
+ SetTextColor(hdc, i.to_colorref());
TextOut(hdc, 5, height, i.value.c_str(), (int)strlen(i.value.c_str()));
height += 20;
}
@@ -142,7 +142,7 @@ auto log(const std::string &message) -> void {
std::string to_log = fmt::format("[{}] {}", current_date_time(), message);
- logs.emplace_back(log_t(log_level::info, to_log)); write_log_file(to_log);
+ logs.emplace_back(log_t(log_level::LOG_LEVEL_INFO, to_log)); write_log_file(to_log);
RedrawWindow(window, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
}