Class Fileapi


  • @Include("fileapi.h")
    public final class Fileapi
    extends Object
    Wrapper around the fileapi.h header.
    Author:
    aploese
    • Constructor Detail

      • Fileapi

        public Fileapi()
    • Method Detail

      • CreateFileW

        public static final Winnt.HANDLE CreateFileW​(File file,
                                                     int dwDesiredAccess,
                                                     int dwShareMode,
                                                     Minwinbase.SECURITY_ATTRIBUTES lpSecurityAttributes,
                                                     int dwCreationDisposition,
                                                     int dwFlagsAndAttributes,
                                                     Winnt.HANDLE hTemplateFile)
                                              throws NativeErrorException
        CreateFileW Creates or opens a file or I/O device.
        Parameters:
        file - The File of the file or device to be created or opened.
        dwDesiredAccess - The requested access to the file or device, which can be summarized as read, write, both or neither zero.
        dwShareMode - The requested sharing mode of the file or device, which can be read, write, both, delete, all of these, or none.
        lpSecurityAttributes - A pointer to a Minwinbase.SECURITY_ATTRIBUTES structure that contains two separate but related data members: an optional security descriptor, and a Boolean value that determines whether the returned handle can be inherited by child processes.
        dwCreationDisposition - An action to take on a file or device that exists or does not exist.
        dwFlagsAndAttributes - The file or device attributes and flags, FILE_ATTRIBUTE_NORMAL being the most common default value for files.
        hTemplateFile - A valid handle to a template file with the GENERIC_READ access right. The template file supplies file attributes and extended attributes for the file that is being created.
        Returns:
        If the function succeeds, the return value is an open handle to the specified file, device, named pipe, or mail slot.
        Throws:
        NullPointerException - if file is null.
        NativeErrorException - if the return value of the native function indicates an error.
      • CreateFileW

        public static final Winnt.HANDLE CreateFileW​(String lpFileName,
                                                     int dwDesiredAccess,
                                                     int dwShareMode,
                                                     Minwinbase.SECURITY_ATTRIBUTES lpSecurityAttributes,
                                                     int dwCreationDisposition,
                                                     int dwFlagsAndAttributes,
                                                     Winnt.HANDLE hTemplateFile)
                                              throws NativeErrorException
        CreateFileW Creates or opens a file or I/O device.
        Parameters:
        lpFileName - The name of the file or device to be created or opened.
        dwDesiredAccess - The requested access to the file or device, which can be summarized as read, write, both or neither zero.
        dwShareMode - The requested sharing mode of the file or device, which can be read, write, both, delete, all of these, or none.
        lpSecurityAttributes - A pointer to a Minwinbase.SECURITY_ATTRIBUTES structure that contains two separate but related data members: an optional security descriptor, and a Boolean value that determines whether the returned handle can be inherited by child processes.
        dwCreationDisposition - An action to take on a file or device that exists or does not exist.
        dwFlagsAndAttributes - The file or device attributes and flags, FILE_ATTRIBUTE_NORMAL being the most common default value for files.
        hTemplateFile - A valid handle to a template file with the GENERIC_READ access right. The template file supplies file attributes and extended attributes for the file that is being created.
        Returns:
        If the function succeeds, the return value is an open handle to the specified file, device, named pipe, or mail slot.
        Throws:
        NullPointerException - if lpFileName is null.
        NativeErrorException - if the return value of the native function indicates an error.
      • ReadFile

        public static int ReadFile​(Winnt.HANDLE hFile,
                                   byte[] lpBuffer)
                            throws NativeErrorException
        ReadFile Reads data from the specified file or input/output (I/O) device. Reads occur at the position specified by the file pointer if supported by the device. This is the synchronous read - for byte[] there is no asynchronous read.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - the byte array that receives the data read from a file or device.
        Returns:
        lpNumberOfBytesRead the number of bytes read.
        Throws:
        NullPointerException - if hFile or lpBuffer is null.
        ArrayIndexOutOfBoundsException - if off and nNumberOfBytesToRead are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.
      • ReadFile

        public static final int ReadFile​(Winnt.HANDLE hFile,
                                         byte[] lpBuffer,
                                         int off,
                                         int nNumberOfBytesToRead)
                                  throws NativeErrorException
        ReadFile Reads data from the specified file or input/output (I/O) device. Reads occur at the position specified by the file pointer if supported by the device. This is the synchronous read - for byte[] there is no asynchronous read.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - the byte array that receives the data read from a file or device.
        off - the start offset in lpBuffer to which the data is transferred.
        nNumberOfBytesToRead - the maximum number of bytes to read.
        Returns:
        lpNumberOfBytesRead the number of bytes read.
        Throws:
        NullPointerException - if hFile or lpBuffer is null.
        ArrayIndexOutOfBoundsException - if off and nNumberOfBytesToRead are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.
      • ReadFile

        public static final void ReadFile​(Winnt.HANDLE hFile,
                                          ByteBuffer lpBuffer)
                                   throws NativeErrorException
        ReadFile Reads data from the specified file or input/output (I/O) device. Reads occur at the position specified by the file pointer if supported by the device. This is the synchronous read for direct ByteBuffer. the position of lpBuffer is updated after successful read.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - a pointer to an direct ByteBuffer that receives the data read from a file or device.
        Throws:
        NullPointerException - if hFile or lpBuffer is null.
        NativeErrorException - if the return value of the native function indicates an error.
      • ReadFile

        public static final void ReadFile​(Winnt.HANDLE hFile,
                                          ByteBuffer lpBuffer,
                                          Minwinbase.OVERLAPPED lpOverlapped)
                                   throws NativeErrorException
        ReadFile Reads data from the specified file or input/output (I/O) device. Reads occur at the position specified by the file pointer if supported by the device. This is the asynchronous read for direct ByteBuffer. Use Ioapiset.GetOverlappedResult(HANDLE, OVERLAPPED, ByteBuffer, boolean) to get the result and update the ByteBuffers position. ReadFile(hFile, lpBuffer, lpOverlapped); final long waitResult = WaitForSingleObject(lpOverlapped.hEvent(), INFINITE()); if (waitResult == WAIT_OBJECT_0()) { //success int bytesRead = GetOverlappedResult(hFile, readOverlapped, lpBuffer, false); } else { //error }
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - a pointer to an direct ByteBuffer that receives the data read from a file or device.
        lpOverlapped - a pointer to an Minwinbase.OVERLAPPED structure.
        Throws:
        NullPointerException - if hFile or lpBuffer or lpOverlapped is null.
        NativeErrorException - if the return value of the native function indicates an error.
      • ReadFile

        public static final int ReadFile​(Winnt.HANDLE hFile,
                                         Int8_t b)
                                  throws NativeErrorException
        ReadFile Reads a single byte from the specified file or input/output (I/O) device.Reads occur at the position specified by the file pointer if supported by the device. This is the synchronous read.
        Parameters:
        hFile - a handle to the file or I/O device.
        b - a pointer to the ByteRef that receives the single byte read from a file or device.
        Returns:
        lpNumberOfBytesRead the number of bytes read.
        Throws:
        NullPointerException - if hFile or b is null.
        NativeErrorException - if the return value of the native function indicates an error.
      • ReadFile

        public static final int ReadFile​(Winnt.HANDLE hFile,
                                         OpaqueMemory32 lpBuffer,
                                         int off,
                                         int nNumberOfBytesToRead)
                                  throws NativeErrorException
        ReadFile Reads data from the specified file or input/output (I/O) device.Reads occur at the position specified by the file pointer if supported by the device. This is the synchronous read for OpaqueMemory32.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - a pointer to the OpaqueMemory32 that receives the data read from a file or device.
        off - the start offset in buf to which the data is transferred.
        nNumberOfBytesToRead - the maximum number of bytes to read.
        Returns:
        lpNumberOfBytesRead the number of bytes read.
        Throws:
        NullPointerException - if hFile or lpBuffer is null.
        ArrayIndexOutOfBoundsException - if pos and nNumberOfBytesToRead are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.
      • ReadFile

        public static final void ReadFile​(Winnt.HANDLE hFile,
                                          OpaqueMemory32 lpBuffer,
                                          int off,
                                          int nNumberOfBytesToRead,
                                          Minwinbase.OVERLAPPED lpOverlapped)
                                   throws NativeErrorException
        ReadFile Reads data from the specified file or input/output (I/O) device. Reads occur at the position specified by the file pointer if supported by the device. This is the asynchronous read for OpaqueMemory32.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - a pointer to the OpaqueMemory32 that receives the data read from a file or device.
        off - the start offset in buf to which the data is transferred.
        nNumberOfBytesToRead - the maximum number of bytes to read.
        lpOverlapped - A pointer to an Minwinbase.OVERLAPPED structure.
        Throws:
        NullPointerException - if hFile or lpBuffer or lpOverlapped is null.
        ArrayIndexOutOfBoundsException - if pos and len are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.
      • ReadFile

        public static final int ReadFile​(Winnt.HANDLE hFile,
                                         OpaqueMemory64 lpBuffer,
                                         long off,
                                         int nNumberOfBytesToRead)
                                  throws NativeErrorException
        ReadFile Reads data from the specified file or input/output (I/O) device.Reads occur at the position specified by the file pointer if supported by the device. This is the synchronous read for OpaqueMemory32.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - a pointer to the OpaqueMemory32 that receives the data read from a file or device.
        off - the start offset in buf to which the data is transferred.
        nNumberOfBytesToRead - the maximum number of bytes to read.
        Returns:
        lpNumberOfBytesRead the number of bytes read.
        Throws:
        NullPointerException - if hFile or lpBuffer is null.
        IndexOutOfBoundsException - if pos and nNumberOfBytesToRead are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.
      • ReadFile

        public static void ReadFile​(Winnt.HANDLE hFile,
                                    OpaqueMemory64 lpBuffer,
                                    long off,
                                    int nNumberOfBytesToRead,
                                    Minwinbase.OVERLAPPED lpOverlapped)
                             throws NativeErrorException
        ReadFile Reads data from the specified file or input/output (I/O) device. Reads occur at the position specified by the file pointer if supported by the device. This is the asynchronous read for OpaqueMemory32.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - a pointer to the OpaqueMemory32 that receives the data read from a file or device.
        off - the start offset in buf to which the data is transferred.
        nNumberOfBytesToRead - the maximum number of bytes to read.
        lpOverlapped - A pointer to an Minwinbase.OVERLAPPED structure.
        Throws:
        NullPointerException - if hFile or lpBuffer or lpOverlapped is null.
        ArrayIndexOutOfBoundsException - if pos and len are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.
      • ReadFileEx

        public static final void ReadFileEx​(Winnt.HANDLE hFile,
                                            ByteBuffer lpBuffer,
                                            Minwinbase.OVERLAPPED lpOverlapped,
                                            Minwinbase.LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
                                     throws NativeErrorException
        ReadFile Reads data from the specified file or input/output (I/O) device. Reads occur at the position specified by the file pointer if supported by the device. This is the asynchronous read for direct ByteBuffer. Use Ioapiset.GetOverlappedResult(HANDLE, OVERLAPPED, ByteBuffer, boolean) to get the result and update the ByteBuffers position. ReadFile(hFile, lpBuffer, lpOverlapped); final long waitResult = WaitForSingleObject(lpOverlapped.hEvent(), INFINITE()); if (waitResult == WAIT_OBJECT_0()) { //success int bytesRead = GetOverlappedResult(hFile, readOverlapped, lpBuffer, false); } else { //error }
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - a pointer to an direct ByteBuffer that receives the data read from a file or device.
        lpOverlapped - a pointer to an Minwinbase.OVERLAPPED structure.
        lpCompletionRoutine - A pointer to a completion routine to be called when the read operation has been completed and the calling thread is in an alertable wait state.
        Throws:
        NullPointerException - if hFile or lpBuffer or lpOverlapped is null.
        NativeErrorException - if the return value of the native function indicates an error.
      • ReadFileEx

        public static final void ReadFileEx​(Winnt.HANDLE hFile,
                                            OpaqueMemory32 lpBuffer,
                                            int off,
                                            int nNumberOfBytesToRead,
                                            Minwinbase.OVERLAPPED lpOverlapped,
                                            Minwinbase.LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
                                     throws NativeErrorException
        ReadFile Reads data from the specified file or input/output (I/O) device. Reads occur at the position specified by the file pointer if supported by the device. This is the asynchronous read for OpaqueMemory32.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - a pointer to the OpaqueMemory32 that receives the data read from a file or device.
        off - the start offset in buf to which the data is transferred.
        nNumberOfBytesToRead - the maximum number of bytes to read.
        lpOverlapped - A pointer to an Minwinbase.OVERLAPPED structure.
        lpCompletionRoutine - A pointer to a completion routine to be called when the read operation has been completed and the calling thread is in an alertable wait state.
        Throws:
        NullPointerException - if hFile or lpBuffer or lpOverlapped is null.
        ArrayIndexOutOfBoundsException - if pos and len are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.
      • ReadFileEx

        public static final void ReadFileEx​(Winnt.HANDLE hFile,
                                            OpaqueMemory64 lpBuffer,
                                            long off,
                                            int nNumberOfBytesToRead,
                                            Minwinbase.OVERLAPPED lpOverlapped,
                                            Minwinbase.LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
                                     throws NativeErrorException
        ReadFile Reads data from the specified file or input/output (I/O) device. Reads occur at the position specified by the file pointer if supported by the device. This is the asynchronous read for OpaqueMemory32.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - a pointer to the OpaqueMemory32 that receives the data read from a file or device.
        off - the start offset in buf to which the data is transferred.
        nNumberOfBytesToRead - the maximum number of bytes to read.
        lpOverlapped - A pointer to an Minwinbase.OVERLAPPED structure.
        lpCompletionRoutine - A pointer to a completion routine to be called when the read operation has been completed and the calling thread is in an alertable wait state.
        Throws:
        NullPointerException - if hFile or lpBuffer or lpOverlapped is null.
        ArrayIndexOutOfBoundsException - if pos and len are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.
      • WriteFile

        public static final int WriteFile​(Winnt.HANDLE hFile,
                                          byte b)
                                   throws NativeErrorException
        WriteFile Writes data to the specified file or input/output (I/O) device. Writing starts at the position specified by the file pointer if supported by the device. This is the synchronous write for a single byte .
        Parameters:
        hFile - a handle to the file or I/O device.
        b - the byte to write.
        Returns:
        lpNumberOfBytesWritten the number of bytes written.
        Throws:
        NativeErrorException - if the return value of the native function indicates an error.
      • WriteFile

        public static int WriteFile​(Winnt.HANDLE hFile,
                                    byte[] lpBuffer)
                             throws NativeErrorException
        WriteFile Writes data to the specified file or input/output (I/O) device.Writing starts at the position specified by the file pointer if supported by the device. This is the synchronous write for a byte array.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - the byte array lpBuffer containing the data to be written to the file or device.
        Returns:
        lpNumberOfBytesWritten the number of bytes written.
        Throws:
        NullPointerException - if hFile or lpBuffer is null.
        ArrayIndexOutOfBoundsException - if pos and len are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.
      • WriteFile

        public static final int WriteFile​(Winnt.HANDLE hFile,
                                          byte[] lpBuffer,
                                          int off,
                                          int nNumberOfBytesToWrite)
                                   throws NativeErrorException
        WriteFile Writes data to the specified file or input/output (I/O) device.Writing starts at the position specified by the file pointer if supported by the device. This is the synchronous write for a byte array.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - the byte array lpBuffer containing the data to be written to the file or device.
        off - the start offset in lpBuffer.
        nNumberOfBytesToWrite - the number of bytes to write.
        Returns:
        lpNumberOfBytesWritten the number of bytes written.
        Throws:
        NullPointerException - if hFile or lpBuffer is null.
        ArrayIndexOutOfBoundsException - if pos and len are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.
      • WriteFile

        public static final void WriteFile​(Winnt.HANDLE hFile,
                                           ByteBuffer lpBuffer)
                                    throws NativeErrorException
        WriteFile Writes data to the specified file or input/output (I/O) device. Writing starts at the position specified by the file pointer if supported by the device. This is the synchronous write for ByteBuffer.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - the ByteBuffer lpBuffer containing the data to be written to the file or device.
        Throws:
        NullPointerException - if hFile or lpBuffer is null.
        NativeErrorException - if the return value of the native function indicates an error.
      • WriteFile

        public static final void WriteFile​(Winnt.HANDLE hFile,
                                           ByteBuffer lpBuffer,
                                           Minwinbase.OVERLAPPED lpOverlapped)
                                    throws NativeErrorException
        WriteFile Writes data to the specified file or input/output (I/O) device. Writing starts at the position specified by the file pointer if supported by the device. This is the asynchronous write for ByteBuffer. Use Ioapiset.GetOverlappedResult(HANDLE, OVERLAPPED, ByteBuffer, boolean) to get the result and update the ByteBuffers position. WriteFile(hFile, lpBuffer, lpOverlapped); final long waitResult = WaitForSingleObject(lpOverlapped.hEvent(), INFINITE()); if (waitResult == WAIT_OBJECT_0()) { //success int bytesWritten = GetOverlappedResult(hFile, readOverlapped, lpBuffer, false); } else { //error }
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - the ByteBuffer lpBuffer containing the data to be written to the file or device.
        lpOverlapped - a pointer to an Minwinbase.OVERLAPPED structure.
        Throws:
        NullPointerException - if hFile or lpBuffer or lpOverlapped is null.
        NativeErrorException - if the return value of the native function indicates an error.
      • WriteFile

        public static final int WriteFile​(Winnt.HANDLE hFile,
                                          OpaqueMemory32 lpBuffer,
                                          int off,
                                          int nNumberOfBytesToWrite)
                                   throws NativeErrorException
        WriteFile Writes data to the specified file or input/output (I/O) device.Writing starts at the position specified by the file pointer if supported by the device. This is the synchronous write for OpaqueMemory32.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - the OpaqueMemory32 lpBuffer containing the data to be written to the file or device.
        off - the start offset in lpBuffer.
        nNumberOfBytesToWrite - the number of bytes to write.
        Returns:
        lpNumberOfBytesWritten the number of bytes written.
        Throws:
        NullPointerException - if hFile or lpBuffer is null.
        ArrayIndexOutOfBoundsException - if pos and len are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.
      • WriteFile

        public static final int WriteFile​(Winnt.HANDLE hFile,
                                          OpaqueMemory64 lpBuffer,
                                          long off,
                                          int nNumberOfBytesToWrite)
                                   throws NativeErrorException
        WriteFile Writes data to the specified file or input/output (I/O) device.Writing starts at the position specified by the file pointer if supported by the device. This is the synchronous write for OpaqueMemory32.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - the OpaqueMemory32 lpBuffer containing the data to be written to the file or device.
        off - the start offset in lpBuffer.
        nNumberOfBytesToWrite - the number of bytes to write.
        Returns:
        lpNumberOfBytesWritten the number of bytes written.
        Throws:
        NullPointerException - if hFile or lpBuffer is null.
        ArrayIndexOutOfBoundsException - if pos and len are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.
      • WriteFileEx

        public static final void WriteFileEx​(Winnt.HANDLE hFile,
                                             ByteBuffer lpBuffer,
                                             Minwinbase.OVERLAPPED lpOverlapped,
                                             Minwinbase.LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
                                      throws NativeErrorException
        WriteFile Writes data to the specified file or input/output (I/O) device. Writing starts at the position specified by the file pointer if supported by the device. This is the asynchronous write for ByteBuffer. Use Ioapiset.GetOverlappedResult(HANDLE, OVERLAPPED, ByteBuffer, boolean) to get the result and update the ByteBuffers position. WriteFile(hFile, lpBuffer, lpOverlapped); final long waitResult = WaitForSingleObject(lpOverlapped.hEvent(), INFINITE()); if (waitResult == WAIT_OBJECT_0()) { //success int bytesWritten = GetOverlappedResult(hFile, readOverlapped, lpBuffer, false); } else { //error }
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - the ByteBuffer lpBuffer containing the data to be written to the file or device.
        lpOverlapped - a pointer to an Minwinbase.OVERLAPPED structure.
        lpCompletionRoutine - A pointer to a completion routine to be called when the write operation has been completed and the calling thread is in an alertable wait state.
        Throws:
        NullPointerException - if hFile or lpBuffer or lpOverlapped is null.
        NativeErrorException - if the return value of the native function indicates an error.
      • WriteFileEx

        public static final void WriteFileEx​(Winnt.HANDLE hFile,
                                             OpaqueMemory32 lpBuffer,
                                             int off,
                                             int nNumberOfBytesToWrite,
                                             Minwinbase.OVERLAPPED lpOverlapped,
                                             Minwinbase.LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
                                      throws NativeErrorException
        WriteFile Writes data to the specified file or input/output (I/O) device.Writing starts at the position specified by the file pointer if supported by the device. This is the asynchronous write for OpaqueMemory32.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - the OpaqueMemory32 lpBuffer containing the data to be written to the file or device.
        off - the start offset in lpBuffer.
        nNumberOfBytesToWrite - the number of bytes to write.
        lpOverlapped - a pointer to an Minwinbase.OVERLAPPED structure.
        lpCompletionRoutine - A pointer to a completion routine to be called when the write operation has been completed and the calling thread is in an alertable wait state.
        Throws:
        NullPointerException - if hFile or lpBuffer or lpOverlapped is null.
        ArrayIndexOutOfBoundsException - if pos and len are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.
      • WriteFileEx

        public static final void WriteFileEx​(Winnt.HANDLE hFile,
                                             OpaqueMemory64 lpBuffer,
                                             long off,
                                             int nNumberOfBytesToWrite,
                                             Minwinbase.OVERLAPPED lpOverlapped,
                                             Minwinbase.LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
                                      throws NativeErrorException
        WriteFile Writes data to the specified file or input/output (I/O) device.Writing starts at the position specified by the file pointer if supported by the device. This is the asynchronous write for OpaqueMemory32.
        Parameters:
        hFile - a handle to the file or I/O device.
        lpBuffer - the OpaqueMemory32 lpBuffer containing the data to be written to the file or device.
        off - the start offset in lpBuffer.
        nNumberOfBytesToWrite - the number of bytes to write.
        lpOverlapped - a pointer to an Minwinbase.OVERLAPPED structure.
        lpCompletionRoutine - A pointer to a completion routine to be called when the write operation has been completed and the calling thread is in an alertable wait state.
        Throws:
        NullPointerException - if hFile or lpBuffer or lpOverlapped is null.
        ArrayIndexOutOfBoundsException - if pos and len are outside of lpBuffer.
        NativeErrorException - if the return value of the native function indicates an error.