Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  Function 3DH (decimal 61) opens an existing file or device. You provide
  the pathname and filename in the form of an ASCIIZ string. As with all
  other file I/O functions, DS:DX points to this string. You also indicate
  how you want to use the file by placing a file-access code in register AL.
  The 8 bits of AL are divided into the four fields shown in Figure 17-7 on
  the following page.

        Bit
  7 6 5 4 3 2 1 0          Use
  --------------------------------------------------------------------------
  I . . . . . . .          Inheritance flag (DOS version 3 only)
  . S S S . . . .          Sharing mode (DOS version 3 only)
  . . . . R . . .          (Reserved)
  . . . . . A A A          Access code
  --------------------------------------------------------------------------

  Figure 17-7.  File-access and sharing codes for function 3DH.

  The file-access code for DOS version 2 is simple: Only the access bits
  (bits 0-2) are used; all other bits are set to 0. The three access-code
  settings are defined in Figure 17-8.

   Bit
  2 1 0                    Use
  --------------------------------------------------------------------------
  0 0 0                    Read (only) access
  0 0 1                    Write (only) access
  0 1 0                    Read or write access
  --------------------------------------------------------------------------

  Figure 17-8.  File-access modes for function 3DH.

  DOS version 3 uses the inheritance and sharing codes as well as the access
  code. The inheritance and sharing codes give you control over how
  different programs access the same file at the same time.

  Bit 7, the inheritance bit, indicates whether or not a child process can
  inherit the use of this file. (For more about parent and child processes,
  see the discussion of function 4BH later in this chapter.) When a child
  process inherits a handle, it inherits the file's access and sharing
  codes: If bit 7 = 0, a child process can use the same handle to access the
  file as the parent process; if bit 7 = 1, the child process must itself
  open the file to obtain a different handle.

  Bits 4 through 6, the sharing-mode bits (SSS in Figure 17-7), define what
  will happen when more than one program tries to open the same file. There
  are five sharing modes: compatibility mode (SSS = 000), deny read/write
  mode (SSS = 001), deny write mode (SSS = 010), deny read mode (SSS = 011),
  and deny none mode (SSS = 100). When a second attempt is made to open the
  file, DOS compares the file's sharing code with the access requested in
  the second open operation. DOS allows the second open operation to succeed
  only if the sharing mode and the requested access mode are compatible.

  --------------------------------------------------------------------------
  NOTE:
    DOS performs this file-sharing validation only if it is running on a
    network or if the SHARE utility is installed. See the DOS technical
    reference manual for more details on networking and the SHARE utility.
  --------------------------------------------------------------------------

  Bit 3, marked as "Reserved" in Figure 17-7, should be set to 0.

  Like function 3CH, function 3DH clears the carry flag and returns a handle
  in AX when it successfully opens a file or device. Otherwise, this
  function sets the carry flag and leaves an error code in AX. The possible
  return codes from function 3DH are 02H (file not found), 03H (path not
  found), 04H (no handles available), 05H (access denied), and 0CH (invalid
  access code).

  If SHARE or network file sharing is in force in DOS version 3, DOS signals
  a sharing violation by executing interrupt 24H.

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