diff --git a/GUI/host/host.cpp b/GUI/host/host.cpp index 9c5f875..e0e1f9a 100644 --- a/GUI/host/host.cpp +++ b/GUI/host/host.cpp @@ -43,8 +43,7 @@ namespace static_assert(sizeof(data) < PIPE_BUFFER_SIZE); std::thread([=] { - DWORD DUMMY; - WriteFile(pipe, &data, sizeof(data), &DUMMY, nullptr); + WriteFile(pipe, &data, sizeof(data), DUMMY, nullptr); }).detach(); } diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index d5509aa..1d96bc6 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -92,9 +92,8 @@ MainWindow::MainWindow(QWidget *parent) : current = &Host::GetThread(Host::console); Host::AddConsoleOutput(ABOUT); - DWORD DUMMY; AttachConsole(ATTACH_PARENT_PROCESS); - WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), CL_OPTIONS, wcslen(CL_OPTIONS), &DUMMY, NULL); + WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), CL_OPTIONS, wcslen(CL_OPTIONS), DUMMY, NULL); std::vector processIds = Util::GetAllProcessIds(); std::vector processNames; for (auto processId : processIds) processNames.emplace_back(Util::GetModuleFilename(processId).value_or(L"")); @@ -116,10 +115,9 @@ MainWindow::MainWindow(QWidget *parent) : if (InternetHandle request = WinHttpOpenRequest(connection, L"GET", L"/repos/Artikash/Textractor/releases", NULL, NULL, NULL, WINHTTP_FLAG_SECURE)) if (WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, NULL)) { - DWORD bytesRead; - char buffer[2000] = {}; + char buffer[1000] = {}; WinHttpReceiveResponse(request, NULL); - WinHttpReadData(request, buffer, 1000, &bytesRead); + WinHttpReadData(request, buffer, 1000, DUMMY); if (abs(strstr(buffer, "/tag/") - strstr(buffer, VERSION)) > 10) MESSAGE(UPDATE_AVAILABLE); } }).detach(); diff --git a/extensions/replacer.cpp b/extensions/replacer.cpp index c2684ab..6ea53d3 100644 --- a/extensions/replacer.cpp +++ b/extensions/replacer.cpp @@ -1,7 +1,6 @@ #include "extension.h" #include #include -#include #include #include diff --git a/extensions/util.h b/extensions/util.h index fe9ced7..c362d71 100644 --- a/extensions/util.h +++ b/extensions/util.h @@ -6,11 +6,10 @@ class RateLimiter { public: RateLimiter(int requests, int delay) : requestsLeft(requests), delay(delay) {} - bool Request() { CreateTimerQueueTimer(&DUMMY, timerQueue, [](void* This, BOOLEAN) { ((RateLimiter*)This)->requestsLeft += 1; }, this, delay, 0, 0); return --requestsLeft > 0; } + bool Request() { CreateTimerQueueTimer(DUMMY, timerQueue, [](void* This, BOOLEAN) { ((RateLimiter*)This)->requestsLeft += 1; }, this, delay, 0, 0); return --requestsLeft > 0; } int delay; private: - inline static HANDLE DUMMY; std::atomic requestsLeft; AutoHandle> timerQueue = CreateTimerQueue(); }; diff --git a/include/common.h b/include/common.h index 3d497c4..bd5572f 100644 --- a/include/common.h +++ b/include/common.h @@ -72,6 +72,13 @@ private: std::unique_ptr h; }; +inline struct +{ + BYTE DUMMY[100]; + template + operator T*() { static_assert(sizeof(T) < sizeof(DUMMY)); return (T*)DUMMY; } +} DUMMY; + #pragma warning(push) #pragma warning(disable: 4996) template diff --git a/texthook/hookfinder.cc b/texthook/hookfinder.cc index 6bff29a..833846b 100644 --- a/texthook/hookfinder.cc +++ b/texthook/hookfinder.cc @@ -25,7 +25,6 @@ namespace uint64_t addressCharCache[CACHE_SIZE] = {}; long sumCache[CACHE_SIZE] = {}; - DWORD DUMMY; #ifndef _WIN64 BYTE trampoline[32] = { @@ -171,7 +170,7 @@ void SearchForHooks(SearchParam sp) }), addresses.end()); *(void**)(trampoline + send_offset) = Send; auto trampolines = (decltype(trampoline)*)VirtualAlloc(NULL, sizeof(trampoline) * addresses.size(), MEM_COMMIT, PAGE_READWRITE); - VirtualProtect(trampolines, addresses.size() * sizeof(trampoline), PAGE_EXECUTE_READWRITE, &DUMMY); + VirtualProtect(trampolines, addresses.size() * sizeof(trampoline), PAGE_EXECUTE_READWRITE, DUMMY); for (int i = 0; i < addresses.size(); ++i) { void* original; diff --git a/texthook/main.cc b/texthook/main.cc index 3718697..7f5c921 100644 --- a/texthook/main.cc +++ b/texthook/main.cc @@ -27,7 +27,6 @@ namespace TextHook (*hooks)[MAX_HOOK]; bool running; int currentHook = 0; - DWORD DUMMY; } DWORD WINAPI Pipe(LPVOID) @@ -91,7 +90,7 @@ void TextOutput(ThreadParam tp, BYTE* text, int len) BYTE buffer[PIPE_BUFFER_SIZE] = {}; *(ThreadParam*)buffer = tp; memcpy(buffer + sizeof(tp), text, len); - WriteFile(hookPipe, buffer, sizeof(tp) + len, &DUMMY, nullptr); + WriteFile(hookPipe, buffer, sizeof(tp) + len, DUMMY, nullptr); } void ConsoleOutput(LPCSTR text, ...) @@ -100,7 +99,7 @@ void ConsoleOutput(LPCSTR text, ...) va_list args; va_start(args, text); vsnprintf(buffer.message, MESSAGE_SIZE, text, args); - WriteFile(hookPipe, &buffer, sizeof(buffer), &DUMMY, nullptr); + WriteFile(hookPipe, &buffer, sizeof(buffer), DUMMY, nullptr); } void NotifyHookFound(uint64_t addr, int offset, wchar_t* text) @@ -110,14 +109,14 @@ void NotifyHookFound(uint64_t addr, int offset, wchar_t* text) hp.type = USING_UNICODE | USING_STRING; hp.address = addr; HookFoundNotif buffer(hp, text); - WriteFile(hookPipe, &buffer, sizeof(buffer), &DUMMY, nullptr); + WriteFile(hookPipe, &buffer, sizeof(buffer), DUMMY, nullptr); } void NotifyHookRemove(uint64_t addr, LPCSTR name) { if (name) ConsoleOutput(REMOVING_HOOK, name); HookRemovedNotif buffer(addr); - WriteFile(hookPipe, &buffer, sizeof(buffer), &DUMMY, nullptr); + WriteFile(hookPipe, &buffer, sizeof(buffer), DUMMY, nullptr); } BOOL WINAPI DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID)