diff --git a/Source/Process/AuProcessMap.NT.cpp b/Source/Process/AuProcessMap.NT.cpp index 22944d79..f3a19133 100644 --- a/Source/Process/AuProcessMap.NT.cpp +++ b/Source/Process/AuProcessMap.NT.cpp @@ -109,31 +109,33 @@ namespace Aurora::Process auto offset = static_cast(reinterpret_cast(nt) - reinterpret_cast(mod)); using Value_t = AuRemovePointer_t; Value_t value {}; + DWORD dwBytesRead {}; - auto handle = CreateFileW(Locale::ConvertFromUTF8(path).c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL); - if (handle == INVALID_HANDLE_VALUE) + auto hHandle = CreateFileW(Locale::ConvertFromUTF8(path).c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL); + if (hHandle == INVALID_HANDLE_VALUE) { return 0; } - DWORD bytesRead {}; - - if (!SetFilePointer(handle, offset, NULL, 0)) + if (!SetFilePointer(hHandle, offset, NULL, 0)) { + AuWin32CloseHandle(hHandle); return {}; } - if (!ReadFile(handle, &value, sizeof(Value_t), &bytesRead, NULL)) + if (!ReadFile(hHandle, &value, sizeof(Value_t), &dwBytesRead, NULL)) { + AuWin32CloseHandle(hHandle); return {}; } - if (bytesRead != sizeof(Value_t)) + if (dwBytesRead != sizeof(Value_t)) { + AuWin32CloseHandle(hHandle); return {}; } - CloseHandle(handle); + AuWin32CloseHandle(hHandle); return value; }