com.sun.jna.platform.win32.WinBase Java Examples

The following examples show how to use com.sun.jna.platform.win32.WinBase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WindowsPktDumpService.java    From trex-stateless-gui with Apache License 2.0 5 votes vote down vote up
private void createPipe() {
    pipeHandler = Kernel32.INSTANCE.CreateNamedPipe(pipeName,
            WinBase.PIPE_ACCESS_OUTBOUND,        // dwOpenMode
            PIPE_TYPE_MESSAGE | PIPE_WAIT | PIPE_READMODE_MESSAGE,    // dwPipeMode
            1,    // nMaxInstances,
            65536,    // nOutBufferSize,
            65536,    // nInBufferSize,
            1000,    // nDefaultTimeOut,
            null);
}
 
Example #2
Source File: JKernel32.java    From Flashtool with GNU General Public License v3.0 5 votes vote down vote up
public static boolean openDevice() throws IOException {
       /* Kernel32RW.GENERIC_READ | Kernel32RW.GENERIC_WRITE not used in dwDesiredAccess field for system devices such a keyboard or mouse */
       int shareMode = WinNT.FILE_SHARE_READ | WinNT.FILE_SHARE_WRITE;
       int Access = WinNT.GENERIC_WRITE | WinNT.GENERIC_READ;
	HandleToDevice = Kernel32.INSTANCE.CreateFile(
               Devices.getConnectedDeviceWin32().getDevPath(), 
               Access, 
               shareMode, 
               null, 
               WinNT.OPEN_EXISTING, 
               0,//WinNT.FILE_FLAG_OVERLAPPED, 
               (WinNT.HANDLE)null);
	if (HandleToDevice == WinBase.INVALID_HANDLE_VALUE) throw new IOException(getLastError());
	return true;
}
 
Example #3
Source File: JKernel32.java    From Flashtool with GNU General Public License v3.0 5 votes vote down vote up
public static boolean openDeviceAsync() throws IOException {
       /* Kernel32RW.GENERIC_READ | Kernel32RW.GENERIC_WRITE not used in dwDesiredAccess field for system devices such a keyboard or mouse */
       int shareMode = WinNT.FILE_SHARE_READ | WinNT.FILE_SHARE_WRITE;
       int Access = WinNT.GENERIC_WRITE | WinNT.GENERIC_READ;
	HandleToDevice = Kernel32.INSTANCE.CreateFile(
               Devices.getConnectedDeviceWin32().getDevPath(), 
               Access, 
               shareMode, 
               null, 
               WinNT.OPEN_EXISTING, 
               WinNT.FILE_FLAG_OVERLAPPED, 
               (WinNT.HANDLE)null);
	if (HandleToDevice == WinBase.INVALID_HANDLE_VALUE) throw new IOException(getLastError());
	return true;
}
 
Example #4
Source File: JKernel32.java    From Flashtool with GNU General Public License v3.0 5 votes vote down vote up
public static WinNT.HANDLE createEvent() throws IOException {
	WinNT.HANDLE hevent = kernel32.CreateEvent(null, false, false, null);
	int res = kernel32.GetLastError();
	if (hevent == WinBase.INVALID_HANDLE_VALUE || res!=0)
			throw new IOException(JKernel32.getLastError());
	return hevent;
}
 
Example #5
Source File: JKernel32.java    From Flashtool with GNU General Public License v3.0 5 votes vote down vote up
public static boolean closeDevice() {
	boolean result = true;
	
	if (HandleToDevice != WinBase.INVALID_HANDLE_VALUE) {
		result = kernel32.CloseHandle(HandleToDevice);
	}
	HandleToDevice = WinBase.INVALID_HANDLE_VALUE;
	return result;
}
 
Example #6
Source File: WindowsNamedPipeLibrary.java    From buck with Apache License 2.0 5 votes vote down vote up
WinNT.HANDLE CreateFile(
String lpFileName,
int dwDesiredAccess,
int dwShareMode,
WinBase.SECURITY_ATTRIBUTES lpSecurityAttributes,
int dwCreationDisposition,
int dwFlagsAndAttributes,
WinNT.HANDLE hTemplateFile);
 
Example #7
Source File: SetupApi.java    From Flashtool with GNU General Public License v3.0 4 votes vote down vote up
public SP_DRVINFO_DATA() {
	DriverDate = new WinBase.FILETIME();
}
 
Example #8
Source File: WindowsNamedPipeLibrary.java    From buck with Apache License 2.0 4 votes vote down vote up
WinNT.HANDLE CreateEvent(
WinBase.SECURITY_ATTRIBUTES lpEventAttributes,
boolean bManualReset,
boolean bInitialState,
String lpName);
 
Example #9
Source File: WindowsNamedPipe.java    From buck with Apache License 2.0 4 votes vote down vote up
private static WinBase.OVERLAPPED createOverlapped(WinNT.HANDLE event) {
  WinBase.OVERLAPPED olap = new WinBase.OVERLAPPED();
  olap.hEvent = event;
  olap.write();
  return olap;
}