Remove unused code getParentExe

This commit is contained in:
baldurk
2019-04-29 10:45:28 +01:00
parent 85215b9c44
commit 6dec2dad73
-51
View File
@@ -710,48 +710,6 @@ struct GlobalHookCommand : public Command
}
};
// from http://stackoverflow.com/q/29939893/4070143
// and http://stackoverflow.com/a/4570213/4070143
std::string getParentExe()
{
DWORD pid = GetCurrentProcessId();
HANDLE h = NULL;
PROCESSENTRY32 pe = {0};
DWORD ppid = 0;
pe.dwSize = sizeof(PROCESSENTRY32);
h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(Process32First(h, &pe))
{
do
{
if(pe.th32ProcessID == pid)
{
ppid = pe.th32ParentProcessID;
break;
}
} while(Process32Next(h, &pe));
}
CloseHandle(h);
if(ppid == 0)
return "";
h = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, ppid);
if(h)
{
char buf[MAX_PATH];
if(GetModuleFileNameExA(h, 0, buf, MAX_PATH))
{
CloseHandle(h);
return buf;
}
CloseHandle(h);
}
return "";
}
// ignore the argc/argv we get here, convert from wide to be sure we're unicode safe.
int main(int, char *)
{
@@ -771,15 +729,6 @@ int main(int, char *)
LocalFree(wargv);
// if launched from cmd.exe, be friendly and redirect output
std::string parent = getParentExe();
for(size_t i = 0; i < parent.length(); i++)
{
parent[i] = tolower(parent[i]);
if(parent[i] == '\\')
parent[i] = '/';
}
hInstance = GetModuleHandleA(NULL);
WNDCLASSEX wc;