Switch to using wide strings in the injector

This commit is contained in:
mkrsym1
2023-07-03 14:04:04 +03:00
parent 8c900f93fc
commit b860834be1
8 changed files with 70 additions and 69 deletions

View File

@ -10,11 +10,11 @@ static inline void write_protected_process_memory(HANDLE process, void *address,
VirtualProtectEx(process, address, size, oldProtect, &oldProtect);
}
void inject(HANDLE process, const void *payload, size_t payloadSize, const char *dllPath) {
void inject(HANDLE process, const void *payload, size_t payloadSize, const wchar_t *dllPath) {
size_t _; // Contrary to the docs, {Write,Read}ProcessMemory likes to crash if the last arg is NULL
// Inject the loader into the module
size_t dllPathLen = strlen(dllPath) + 1;
size_t dllPathLen = (wcslen(dllPath) + 1) * sizeof(wchar_t);
char *remoteAlloc = VirtualAllocEx(process, NULL, payloadSize + dllPathLen, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
WriteProcessMemory(process, remoteAlloc, payload, payloadSize, &_);