@Test public void openOpensHandleCorrectly() throws Exception { int nativeHandle = 5192; openProcess = (flags, inherit, pid) -> nativeHandle; ProcessHandle handle = opener.open(111, ProcessAccessFlags.VIRTUAL_MEMORY_READ); assertEquals(nativeHandle, handle.getNativeHandle()); }
@Override public ProcessHandle open(int pid, int processAccessFlags) throws ProcessOpenException { int handle = openProcess.openProcess(processAccessFlags, false, pid); if (handle == WinApiConstants.NULL) { Integer lastError = Native.getLastError(); SystemErrorCode error = SystemErrorCode.fromId(lastError); String message = String.format( "Failed to open process %d for reading! System error: %s", pid, error == null ? lastError.toString() : error.toString() ); throw new ProcessOpenException(message); } return new WinApiProcessHandle(handle); }
WindowsProcessOpener implements ProcessOpener { @Override public ProcessHandle open(int pid, int processAccessFlags) throws ProcessOpenException { int handle = openProcess.openProcess(processAccessFlags, false, pid); if (handle == WinApiConstants.NULL) { Integer lastError = Native.getLastError(); SystemErrorCode error = SystemErrorCode.fromId(lastError); String message = String.format( "Failed to open process %d for reading! System error: %s", pid, error == null ? lastError.toString() : error.toString() ); throw new ProcessOpenException(message); } return new WinApiProcessHandle(handle); } }
WindowsProcessOpener implements ProcessOpener { @Override public ProcessHandle open(int pid, int processAccessFlags) throws ProcessOpenException { int handle = openProcess.openProcess(processAccessFlags, false, pid); if (handle == WinApiConstants.NULL) { Integer lastError = Native.getLastError(); SystemErrorCode error = SystemErrorCode.fromId(lastError); String message = String.format( "Failed to open process %d for reading! System error: %s", pid, error == null ? lastError.toString() : error.toString() ); throw new ProcessOpenException(message); } return new WinApiProcessHandle(handle); } <T extends OpenProcess & CloseHandle> WindowsProcessOpener(T processOpenerAndHandleCloser);   WindowsProcessOpener(OpenProcess openProcess, CloseHandle closeHandle); }
WindowsProcessOpener implements ProcessOpener { @Override public ProcessHandle open(int pid, int processAccessFlags) throws ProcessOpenException { int handle = openProcess.openProcess(processAccessFlags, false, pid); if (handle == WinApiConstants.NULL) { Integer lastError = Native.getLastError(); SystemErrorCode error = SystemErrorCode.fromId(lastError); String message = String.format( "Failed to open process %d for reading! System error: %s", pid, error == null ? lastError.toString() : error.toString() ); throw new ProcessOpenException(message); } return new WinApiProcessHandle(handle); } <T extends OpenProcess & CloseHandle> WindowsProcessOpener(T processOpenerAndHandleCloser);   WindowsProcessOpener(OpenProcess openProcess, CloseHandle closeHandle); @Override ProcessHandle open(int pid, int processAccessFlags); }
WindowsProcessOpener implements ProcessOpener { @Override public ProcessHandle open(int pid, int processAccessFlags) throws ProcessOpenException { int handle = openProcess.openProcess(processAccessFlags, false, pid); if (handle == WinApiConstants.NULL) { Integer lastError = Native.getLastError(); SystemErrorCode error = SystemErrorCode.fromId(lastError); String message = String.format( "Failed to open process %d for reading! System error: %s", pid, error == null ? lastError.toString() : error.toString() ); throw new ProcessOpenException(message); } return new WinApiProcessHandle(handle); } <T extends OpenProcess & CloseHandle> WindowsProcessOpener(T processOpenerAndHandleCloser);   WindowsProcessOpener(OpenProcess openProcess, CloseHandle closeHandle); @Override ProcessHandle open(int pid, int processAccessFlags);  }