en:docs:mvm:api:0

SVC_DUPHANDLE

Duplicate a file handle. This call creates a new file handle that refers to the same open file, pipe, or device as an existing handle.

Brief

Duplicate file handle (INT 21h AH=45h)

Input

  • BX = existing file handle

Return

  • CF clear if successful
    • AX = new handle
  • CF set on error

Notes

  • Both handles refer to the same system file table entry. Moving the file pointer for one handle also moves it for the other.
  • Closing one handle does not affect the other until both are closed.
  • The new handle has the same access rights and sharing mode as the original.

Binding

MASM

include macrolib.inc
 
    mov bx, handle
    @SvcDupHandle
 
handle dw 1234h

C

#include <svc.h>
 
unsigned short newhandle;
unsigned short oldhandle = 0x1234;
 
newhandle = SvcDupHandle(oldhandle);

The underlying pragma is defined as:

extern unsigned short SvcDupHandle(unsigned short handle);
#pragma aux SvcDupHandle = \
    "hlt"           \
    "db  0"         \
    "db  NOT 0"     \
    parm [bx]       \
    value [ax]      \
    modify [ax bx cx dx];

See also

2024/11/07 03:44 · prokushev · 0 Comments