diff --git a/Build/Release/x64/repacls.exe b/Build/Release/x64/repacls.exe index 3cd4474..3d16ddd 100644 Binary files a/Build/Release/x64/repacls.exe and b/Build/Release/x64/repacls.exe differ diff --git a/Build/Release/x86/repacls.exe b/Build/Release/x86/repacls.exe index 0aaeb3f..9481283 100644 Binary files a/Build/Release/x86/repacls.exe and b/Build/Release/x86/repacls.exe differ diff --git a/Build/Repacls.zip b/Build/Repacls.zip index 509a4ff..5683f9a 100644 Binary files a/Build/Repacls.zip and b/Build/Repacls.zip differ diff --git a/Main.cpp b/Main.cpp index a047250..1693f26 100644 --- a/Main.cpp +++ b/Main.cpp @@ -18,7 +18,8 @@ #include "ConcurrentQueue.h" #include "DriverKitPartial.h" #include "Functions.h" -#include "Version.h" + +#pragma comment(lib,"version.lib") constexpr ULONG MAX_DIRECTORY_BUFFER = 65536; @@ -447,9 +448,30 @@ int wmain(int iArgs, WCHAR * aArgs[]) _setmode(_fileno(stderr), _O_U16TEXT); _setmode(_fileno(stdout), _O_U16TEXT); + // fetch currently running executable name + std::wstring sVersion; + LPWSTR sCurrentExe = nullptr; + if (_get_wpgmptr(&sCurrentExe) != 0 || sCurrentExe == nullptr) + { + wprintf(L"%s\n", L"ERROR: Cannot get currently running executable name."); + exit(-1); + } + + // fetch the version string + const DWORD iVersionSize = GetFileVersionInfoSize(sCurrentExe, nullptr); + UINT iQueriedSize = 0; + std::vector tVersionInfo = std::vector(iVersionSize); + VS_FIXEDFILEINFO* pVersion = nullptr; + if (GetFileVersionInfo(sCurrentExe, 0, iVersionSize, tVersionInfo.data()) != 0 && + VerQueryValue(tVersionInfo.data(), L"\\", reinterpret_cast(&pVersion), &iQueriedSize) != 0) + { + sVersion = std::to_wstring(HIWORD(pVersion->dwFileVersionMS)) + L"." + std::to_wstring(LOWORD(pVersion->dwFileVersionMS)) + + L"." + std::to_wstring(HIWORD(pVersion->dwFileVersionLS)) + L"." + std::to_wstring(LOWORD(pVersion->dwFileVersionLS)); + } + // print standard header wprintf(L"===============================================================================\n"); - wprintf(L"= Repacls Version %hs by Bryan Berns\n", VERSION_STRING); + wprintf(L"= Repacls Version %s by Bryan Berns\n", sVersion.c_str()); wprintf(L"===============================================================================\n"); // translate diff --git a/OperationRemoveStreams.cpp b/OperationRemoveStreams.cpp index 14f724c..bfed995 100644 --- a/OperationRemoveStreams.cpp +++ b/OperationRemoveStreams.cpp @@ -31,19 +31,19 @@ void OperationRemoveStreams::ProcessObjectAction(ObjectEntry& tObjectEntry) } // loop until we can fill the stream into a buffer + IO_STATUS_BLOCK tIOStatus = {}; NTSTATUS iStatus; thread_local std::vector sInfoBuffer(16 * 1024, 0); for (iStatus = STATUS_BUFFER_OVERFLOW; iStatus == STATUS_BUFFER_OVERFLOW; sInfoBuffer.resize(sInfoBuffer.size() * 2, 0)) { - IO_STATUS_BLOCK tIOStatus = {}; iStatus = NtQueryInformationFile(hFile, &tIOStatus, sInfoBuffer.data(), (ULONG) sInfoBuffer.size(), FileStreamInformation); if (iStatus == STATUS_SUCCESS) break; } // cleanup and verify we got the data we needed CloseHandle(hFile); - if (iStatus != STATUS_SUCCESS) return; + if (iStatus != STATUS_SUCCESS || tIOStatus.Information == 0) return; // Loop for all streams for (PFILE_STREAM_INFORMATION pStreamInfo = (PFILE_STREAM_INFORMATION)sInfoBuffer.data(); pStreamInfo->StreamNameLength != 0; @@ -67,7 +67,7 @@ void OperationRemoveStreams::ProcessObjectAction(ObjectEntry& tObjectEntry) } else { - InputOutput::AddError(L"Unable delete stream: " + sStream); + InputOutput::AddError(L"Unable delete stream: " + sStream + L" (" + std::to_wstring(GetLastError()) + L")"); } // break if no next stream diff --git a/Resource.rc b/Resource.rc index faacd93..8c02e15 100644 Binary files a/Resource.rc and b/Resource.rc differ diff --git a/Version.h b/Version.h deleted file mode 100644 index cd764c6..0000000 --- a/Version.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -#define VERSION_STRING "1.14.0.0" -#define VERSION_COMMA 1,14,0,0 diff --git a/repacls.vcxproj b/repacls.vcxproj index 4692b3b..cc7aa31 100644 --- a/repacls.vcxproj +++ b/repacls.vcxproj @@ -281,7 +281,6 @@ - diff --git a/repacls.vcxproj.filters b/repacls.vcxproj.filters index f36780f..5ee1849 100644 --- a/repacls.vcxproj.filters +++ b/repacls.vcxproj.filters @@ -213,9 +213,6 @@ Includes\Operations - - Includes - Includes\Operations