This commit is contained in:
Akash Mozumdar 2019-06-03 17:58:30 -04:00
parent 494fcd24c3
commit 7cdbd93dcb
7 changed files with 17 additions and 17 deletions

View File

@ -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();
}

View File

@ -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<DWORD> processIds = Util::GetAllProcessIds();
std::vector<std::wstring> 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();

View File

@ -1,7 +1,6 @@
#include "extension.h"
#include <cwctype>
#include <fstream>
#include <atomic>
#include <filesystem>
#include <process.h>

View File

@ -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<int> requestsLeft;
AutoHandle<Functor<DeleteTimerQueue>> timerQueue = CreateTimerQueue();
};

View File

@ -72,6 +72,13 @@ private:
std::unique_ptr<void, HandleCleaner> h;
};
inline struct
{
BYTE DUMMY[100];
template <typename T>
operator T*() { static_assert(sizeof(T) < sizeof(DUMMY)); return (T*)DUMMY; }
} DUMMY;
#pragma warning(push)
#pragma warning(disable: 4996)
template <typename... Args>

View File

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

View File

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