Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- TASM 2.x / MASM 6.x Assembly Language - <b>function 40h (64) write to file or device, using a handle</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Function 40h (64)        Write to File or Device, Using a Handle

    Write bytes from a buffer to a file or device.

       On entry:      AH         40h
                      BX         File handle
                      CX         Number of bytes to write
                      DS:DX      Address of buffer

       Returns:       AX         Number of bytes written, or
                                 Error code, if CF is set

       Error codes:   5          Access denied
                      6          Invalid handle

                      Call function 59h for extended error code information
                      (DOS 3.0 and above).

       Network:       Requires Write access rights

  --------------------------------------------------------------------------

    This function writes data to the file or device whose handle is in BX.
    Data is written starting at the current file pointer. The file pointer
    is then incremented by the number of bytes written.

       Notes:         If a disk full condition is encountered, no error
                      code will be returned (i.e., CF will not be set);
                      however, fewer bytes than requested will have been
                      written. You should check for this condition by
                      testing for AX less than CX after returning from the
                      function.

                      A file can be truncated my moving the file pointer
                      to the new end of file (with function 42h) and
                      calling this function with CX = 0.

                      You can write bytes to anywhere in the file by
                      calling function 42h to move to file poniter before
                      writing data.

                      Writing to a file marked "read-only" will generate
                      an error code of 5, "access denied."

See Also: 15h 22h 28h 42h 59h

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson