Skip to content

Commit

Permalink
Fixed Issue With Using /Report Multiple Times
Browse files Browse the repository at this point in the history
  • Loading branch information
NoMoreFood committed Jan 27, 2017
1 parent 8b7c482 commit 08e9526
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
24 changes: 19 additions & 5 deletions Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,19 @@ HANDLE RegisterFileHandle(HANDLE hFile, std::wstring sOperation)
// do a reverse lookup on the file name
DWORD iSize = GetFinalPathNameByHandle(hFile, NULL, 0, VOLUME_NAME_NT);

// create a string that can accommodate that size
// create a string that can accommodate that size (plus null terminating character)
std::wstring sPath;
sPath.reserve(iSize);
sPath.resize(iSize + 1);

// get the full name
GetFinalPathNameByHandle(hFile, (LPWSTR) sPath.data(), (DWORD) sPath.capacity(), VOLUME_NAME_NT);
if (GetFinalPathNameByHandle(hFile, (LPWSTR)sPath.data(), (DWORD)sPath.capacity(), VOLUME_NAME_NT) == 0)
{
wprintf(L"ERROR: The true path to the specified file could not be determined.\n");
exit(-1);
}

// resize string back to actual size to remove null terminating character from string data
sPath.resize(iSize);

// if the handle already exists, then use that one if the parameters match
std::map<std::wstring, std::pair<HANDLE,std::wstring>>::iterator oFile = oFileLookup.find(sPath);
Expand All @@ -384,14 +391,21 @@ HANDLE RegisterFileHandle(HANDLE hFile, std::wstring sOperation)
}
else
{
oFileLookup[sPath] = std::pair<HANDLE, std::wstring>(hFile, sOperation);
oFileLookup[std::wstring(sPath)] = std::pair<HANDLE, std::wstring>(hFile, sOperation);
return hFile;
}
}

bool CheckIfAntivirusIsActive()
{
CoInitializeEx(0, COINIT_APARTMENTTHREADED);
// initialize COM for checking the antivirus status
HRESULT hResult = CoInitializeEx(0, COINIT_APARTMENTTHREADED);
if (hResult != S_OK && hResult != S_FALSE)
{
return false;
}

// assume not installed by default
bool bIsInstalled = false;

// query the product list
Expand Down
2 changes: 1 addition & 1 deletion Operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ std::vector<std::wstring> Operation::SplitArgs(std::wstring sInput, std::wstring
bool Operation::ProcessSidAction(WCHAR * const sSdPart, ObjectEntry & tObjectEntry, PSID & tCurrentSid, bool & bSidReplacement)
{
PSID tResultantSid;
SidActionResult tResult = DetermineSid(sSdPart, tObjectEntry, tCurrentSid, tResultantSid);
const SidActionResult tResult = DetermineSid(sSdPart, tObjectEntry, tCurrentSid, tResultantSid);
bool bMadeChange = false;

if (tResult == SidActionResult::Remove)
Expand Down
2 changes: 1 addition & 1 deletion Version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once

#define VERSION_STRING "1.7.0.2"
#define VERSION_STRING "1.7.0.3"
14 changes: 9 additions & 5 deletions repacls.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
Expand All @@ -140,21 +139,23 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DisableSpecificWarnings>4100</DisableSpecificWarnings>
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<DebugInformationFormat>None</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>false</GenerateDebugInformation>
<Profile>true</Profile>
<Profile>false</Profile>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<SetChecksum>true</SetChecksum>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
Expand All @@ -165,6 +166,8 @@
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<DisableSpecificWarnings>4100</DisableSpecificWarnings>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<DebugInformationFormat>None</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -173,6 +176,7 @@
<GenerateDebugInformation>false</GenerateDebugInformation>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<Profile>true</Profile>
<SetChecksum>true</SetChecksum>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down

0 comments on commit 08e9526

Please sign in to comment.