en:docs:mvm:api:0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:docs:mvm:api:0 [2024/05/08 02:59] – created prokusheven:docs:mvm:api:0 [2026/03/20 03:14] (current) prokushev
Line 1: Line 1:
-====== ======+====== 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 ===== ===== Brief =====
 +
 +Duplicate file handle (INT 21h AH=45h)
  
 ===== Input ===== ===== Input =====
  
 +  * BX = existing file handle
  
 ===== Return ===== ===== Return =====
  
 +  * CF clear if successful
 +    * AX = new handle
 +  * CF set on error
 +    * AX = [[en:docs:mvm:api:errors|error code]] (04h, 06h)
  
 ===== Notes ===== ===== 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.
  
-===== See also =====+===== Binding =====
  
 +==== MASM ====
 +
 +<code asm>
 +include macrolib.inc
 +
 +    mov bx, handle
 +    @SvcDupHandle
 +
 +handle dw 1234h
 +</code>
 +
 +==== C ====
 +
 +<code c>
 +#include <svc.h>
 +
 +unsigned short newhandle;
 +unsigned short oldhandle = 0x1234;
 +
 +newhandle = SvcDupHandle(oldhandle);
 +</code>
 +
 +The underlying pragma is defined as:
 +
 +<code c>
 +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];
 +</code>
 +
 +===== See also =====
  
 +  * [[en:docs:dos:api:int21:45|INT 21h AH=45h]] – DOS duplicate handle
  
 +{{page>en:templates:svcapi}}