Skip to content

Commit

Permalink
#571 Restore the original windows getProcessCode() because Microsoft'…
Browse files Browse the repository at this point in the history
…s GetModuleFileName isn't effective!
  • Loading branch information
clanmills authored and piponazo committed Nov 29, 2018
1 parent 948c48d commit 8980eac
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/futils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,14 @@ namespace Exiv2 {
{
std::string ret("unknown");
#if defined(WIN32)
TCHAR filename[MAX_PATH];
if ( GetModuleFileName( (HMODULE)"", filename, MAX_PATH ) != 0 ) {
ret = filename;
HANDLE processHandle = NULL;
processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, GetCurrentProcessId());
if (processHandle != NULL) {
TCHAR filename[MAX_PATH];
if (GetModuleFileNameEx(processHandle, NULL, filename, MAX_PATH) != 0) {
ret = filename;
}
CloseHandle(processHandle);
}
#elif defined(__APPLE__)
const int pid = getpid();
Expand Down

0 comments on commit 8980eac

Please sign in to comment.