Program 6-1, later in the chapter, uses inheritable handles. Handles and are represented in the reference count. Inherited and duplicate handles are both distinct from the original Handle is closed and the reference count becomes zero. An object cannot be destroyed until the last This count is not available to the application program, however. The Windows kernel maintains a reference count for all objects this count represents the number of distinct handles referring If dwDesiredAccess is not overridden by DUPLICATE_SAME_ACCESS in dwOptions, it has many possible values (see the MSDN library on-line help).ĭwOptions is any combination of two flags.ĭUPLICATE_CLOSE_SOURCE causes the source handle to be closed.ĭUPLICATE_SAME_ACCESS causes dwDesiredAccess to be ignored. The other process of the new handle's identity.ĭuplicateHandle can be used for any handle type. Also notice that it is possible to create a handle in another process if you do this, you then need a mechanism for informing The calling process, and the handle is obtained from GetCurrentProcess. Frequently, these target and source processes are Note that three processes are involved, including the calling process. The new handle, which is pointed to by lphTargetHandle, is valid in the target process, hTargetProcessHandle. hSourceHandle is a handle in the process indicated by hSourceProcessHandle and must have PROCESS_DUP_HANDLE access DuplicateHandle will fail if the source handle does not exist in the source process. Upon completion, lphTargetHandle points to a copy of the original handle, hSourceHandle. Here is the function to duplicate handles: To address this issue, the parent process can create a duplicate handle with the desired accessĪnd inheritability. Process may also need a real, inheritable process handlerather than the pseudohandle produced by GetCurrentProcessfor use by a child process. The parent and child processes may require different access to an object identified by a handle that the child inherits.
0 Comments
Leave a Reply. |