Skip to content

Commit

Permalink
change: limit right when querying process info
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhas committed Oct 12, 2018
1 parent f059d01 commit 0c49c0d
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions AppVolume/AppVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ BOOL ParentMeasure::InitializeCOM()
}

if (pEnumerator == nullptr
&& FAILED(CoCreateInstance(
&& FAILED(CoCreateInstance(
CLSID_MMDeviceEnumerator,
0,
CLSCTX_ALL,
Expand Down Expand Up @@ -178,28 +178,26 @@ BOOL ParentMeasure::UpdateList()
}
else
{
HANDLE checkProc = OpenProcess(PROCESS_ALL_ACCESS, false, procID);
HANDLE checkProc = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, procID);
WCHAR procPath[400];
procPath[0] = 0;
DWORD copied = (DWORD)0;
if (checkProc != NULL)
{
GetModuleFileNameEx(checkProc, NULL, procPath, 400);
copied = GetModuleFileNameEx(checkProc, NULL, procPath, 400);
}
CloseHandle(checkProc);

//Windows 7 doesn't kill session when process is closed.
//And it leaves various "ghost" processID that can't be get path.
//Use that to skip these kind of sessions.
if (procPath[0] == 0)
if (copied == (DWORD)0)
{
SAFE_RELEASE(sessControl2);
continue;
}
else
{
newAppSession.appPath = procPath;
newAppSession.appName = PathFindFileName(newAppSession.appPath.c_str());
}

newAppSession.appPath = procPath;
newAppSession.appName = PathFindFileName(newAppSession.appPath.c_str());

BOOL found = FALSE;
for (auto app : excludeList)
Expand Down Expand Up @@ -990,4 +988,4 @@ PLUGIN_EXPORT void Finalize(void* data)
}

delete child;
}
}

0 comments on commit 0c49c0d

Please sign in to comment.