at.spardat.xma.boot.natives
Class Pipes

java.lang.Object
  extended byat.spardat.xma.boot.natives.Pipes

public class Pipes
extends java.lang.Object

Since:
version_number Class with native static Methods wrapping JNI Calls to the WIN32-API (Pipe Functions).

Constructor Summary
Pipes()
           
 
Method Summary
static boolean CloseHandle(int hObject)
          The CloseHandle function closes an open object handle.
static boolean ConnectNamedPipe(int hNamedPipe, int lpOverlapped)
          The ConnectNamedPipe function enables a named pipe server process to wait for a client process to connect to an instance of a named pipe.
static int CreateFile(java.lang.String lpFileName, int dwDesiredAccess, int dwShareMode, int lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, int hTemplateFile)
          The CreateFile function creates or opens a file, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, or named pipe.
static int CreateNamedPipe(java.lang.String lpName, int dwOpenMode, int dwPipeMode, int nMaxInstances, int nOutBufferSize, int nInBufferSize, int nDefaultTimeOut, int lpSecurityAttributes)
          The CreateNamedPipe function creates an instance of a named pipe and returns a handle for subsequent pipe operations.
static boolean DisconnectNamedPipe(int hNamedPipe)
          The DisconnectNamedPipe function disconnects the server end of a named pipe instance from a client process.
static boolean FlushFileBuffers(int hFile)
          The FlushFileBuffers function flushes the buffers of the specified file and causes all buffered data to be written to the file.
static java.lang.String FormatMessage(int errorCode)
          returns Windows Error Message mapped to the errorCode.
static int GetLastError()
          The GetLastError function retrieves the calling thread's last-error code value.
static boolean ReadFile(int hFile, byte[] lpBuffer, int nNumberOfBytesToRead, int[] lpNumberOfBytesRead, int lpOverlapped)
          The ReadFile function reads data from a file, starting at the position indicated by the file pointer.
static boolean WaitNamedPipe(java.lang.String lpNamedPipeName, int nTimeOut)
          The WaitNamedPipe function waits until either a time-out interval elapses or an instance of the specified named pipe is available for connection (that is, the pipe's server process has a pending ConnectNamedPipe operation on the pipe).
static boolean WriteFile(int hFile, byte[] lpBuffer, int nNumberOfBytesToWrite, int[] lpNumberOfBytesWritten, int lpOverlapped)
          The WriteFile function writes data to a file at the position specified by the file pointer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pipes

public Pipes()
Method Detail

CreateNamedPipe

public static final int CreateNamedPipe(java.lang.String lpName,
                                        int dwOpenMode,
                                        int dwPipeMode,
                                        int nMaxInstances,
                                        int nOutBufferSize,
                                        int nInBufferSize,
                                        int nDefaultTimeOut,
                                        int lpSecurityAttributes)
The CreateNamedPipe function creates an instance of a named pipe and returns a handle for subsequent pipe operations. A named pipe server process uses this function either to create the first instance of a specific named pipe and establish its basic attributes or to create a new instance of an existing named pipe.

Parameters:
lpName -
dwOpenMode -
dwPipeMode -
nMaxInstances - Maximum number of instances that can be created for this pipe. range 1 through PIPE_UNLIMITED_INSTANCES (255).
nOutBufferSize - Number of bytes to reserve for the output buffer.
nInBufferSize - Number of bytes to reserve for the input buffer
nDefaultTimeOut - Default time-out value, in milliseconds. NMPWAIT_USE_DEFAULT_WAIT
lpSecurityAttributes - Pointer to a SECURITY_ATTRIBUTES structure.
Returns:
INVALID_HANDLE_VALUE if Method fails
Since:
version_number

ConnectNamedPipe

public static final boolean ConnectNamedPipe(int hNamedPipe,
                                             int lpOverlapped)
The ConnectNamedPipe function enables a named pipe server process to wait for a client process to connect to an instance of a named pipe. A client process connects by calling either the CreateFile or CallNamedPipe function.

Parameters:
hNamedPipe - Handle to the server end of a named pipe instance.
lpOverlapped - Pointer to an OVERLAPPED structure.
Returns:
true if connection to the pipe was successful, false otherwise
Since:
version_number

GetLastError

public static final int GetLastError()
The GetLastError function retrieves the calling thread's last-error code value. The last-error code is maintained on a per-thread basis. Multiple threads do not overwrite each other's last-error code.

Returns:
the last-error code value
Since:
version_number

CloseHandle

public static final boolean CloseHandle(int hObject)
The CloseHandle function closes an open object handle.

Parameters:
hObject - Handle to an open object. This parameter can be a pseudo handle or INVALID_HANDLE_VALUE
Returns:
If the function succeeds, the return value is nonzero.
Since:
version_number

ReadFile

public static final boolean ReadFile(int hFile,
                                     byte[] lpBuffer,
                                     int nNumberOfBytesToRead,
                                     int[] lpNumberOfBytesRead,
                                     int lpOverlapped)
The ReadFile function reads data from a file, starting at the position indicated by the file pointer. This function is designed for both synchronous and asynchronous operation.

Parameters:
hFile -
lpBuffer - Pointer to the buffer that receives the data read from the file.
nNumberOfBytesToRead -
lpNumberOfBytesRead -
lpOverlapped - Pointer to an OVERLAPPED structure. This structure is required if hFile was created with FILE_FLAG_OVERLAPPED.
Returns:
If the function succeeds, the return value is nonzero.
Since:
version_number

WriteFile

public static final boolean WriteFile(int hFile,
                                      byte[] lpBuffer,
                                      int nNumberOfBytesToWrite,
                                      int[] lpNumberOfBytesWritten,
                                      int lpOverlapped)
The WriteFile function writes data to a file at the position specified by the file pointer. This function is designed for both synchronous and asynchronous operation.

Parameters:
hFile -
lpBuffer - Pointer to the buffer containing the data to be written to the file.
nNumberOfBytesToWrite -
lpNumberOfBytesWritten -
lpOverlapped - Pointer to an OVERLAPPED structure. This structure is required if hFile was opened with FILE_FLAG_OVERLAPPED
Returns:
true if writing was ok otherwise false.
Since:
version_number

FlushFileBuffers

public static final boolean FlushFileBuffers(int hFile)
The FlushFileBuffers function flushes the buffers of the specified file and causes all buffered data to be written to the file.

Parameters:
hFile -
Returns:
true if ok otherwise false
Since:
version_number

DisconnectNamedPipe

public static final boolean DisconnectNamedPipe(int hNamedPipe)
The DisconnectNamedPipe function disconnects the server end of a named pipe instance from a client process.

Parameters:
hNamedPipe -
Returns:
true if pipe was succesfully closed, false otherwise
Since:
version_number

CreateFile

public static final int CreateFile(java.lang.String lpFileName,
                                   int dwDesiredAccess,
                                   int dwShareMode,
                                   int lpSecurityAttributes,
                                   int dwCreationDisposition,
                                   int dwFlagsAndAttributes,
                                   int hTemplateFile)
The CreateFile function creates or opens a file, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, or named pipe. The function returns a handle that can be used to access the object.

Parameters:
lpFileName -
dwDesiredAccess -
dwShareMode -
lpSecurityAttributes -
dwCreationDisposition -
dwFlagsAndAttributes -
hTemplateFile -
Returns:
returns a handle that can be used to access the object
Since:
version_number

WaitNamedPipe

public static final boolean WaitNamedPipe(java.lang.String lpNamedPipeName,
                                          int nTimeOut)
The WaitNamedPipe function waits until either a time-out interval elapses or an instance of the specified named pipe is available for connection (that is, the pipe's server process has a pending ConnectNamedPipe operation on the pipe). If an instance of the pipe is available before the time-out interval elapses, the return value is nonzero. If an instance of the pipe is not available before the time-out interval elapses, the return value is zero. To get extended error information, call GetLastError. Timeout: NMPWAIT_USE_DEFAULT_WAIT 0x00000000 NMPWAIT_WAIT_FOREVER 0xffffffff

Parameters:
lpNamedPipeName -
nTimeOut - Number of milliseconds that the function will wait for an instance of the named pipe to be available. You can used one of the following values instead of specifying a number of milliseconds.
Returns:
if instance of the pipe is available before the time-out interval the return value is nonzero otherwise zero.
Since:
version_number

FormatMessage

public static final java.lang.String FormatMessage(int errorCode)
returns Windows Error Message mapped to the errorCode.

Parameters:
errorCode -
Returns:
error message
Since:
version_number