Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions contrib/platform/src/com/sun/jna/platform/WindowUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1298,22 +1298,24 @@ public String getProcessFilePath(final HWND hwnd) {
pid.getValue());

if (process == null) {
if(Kernel32.INSTANCE.GetLastError() != WinNT.ERROR_ACCESS_DENIED) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
} else {
process = Kernel32.INSTANCE.OpenProcess(
WinNT.PROCESS_QUERY_LIMITED_INFORMATION,
false,
pid.getValue());

if (process == null) {
if (Kernel32.INSTANCE.GetLastError() != WinNT.ERROR_ACCESS_DENIED) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
} else {
// Ignore windows, that can't be accessed
return "";
switch (Kernel32.INSTANCE.GetLastError()) {
case WinNT.ERROR_ACCESS_DENIED:
case WinError.ERROR_INVALID_PARAMETER:
process = Kernel32.INSTANCE.OpenProcess(
WinNT.PROCESS_QUERY_LIMITED_INFORMATION,
false,
pid.getValue());
if (process != null) {
break;
}
}
switch (Kernel32.INSTANCE.GetLastError()) {
case WinNT.ERROR_ACCESS_DENIED:
case WinError.ERROR_INVALID_PARAMETER:
return "";
}
/* if above didn't already break or return, fall through to default */
default:
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}

Expand Down