The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Danesh on July 13, 2005, 12:06:26 AM

Title: Duplicate Handle
Post by: Danesh on July 13, 2005, 12:06:26 AM
Hi all,

I want to know is duplicating a file handle a costly task ? I mean would it have any negative effect on performance if each write operation be done by one handle duplicating ? I am working on a program and the source file which is shared may change so I can can not get a handle to ir once and should get handle each time I want to write to it, would it kill the performance ? Besides, I thought DuplicateHandle may work for duplicating file handles but it seems it doesn't. It just works for process handles not files. Does anybody know how a file handle can be duplicated ?

Thanks,

Danesh

Title: Re: Duplicate Handle
Post by: Danesh on July 13, 2005, 09:31:22 PM
Hi again,

Well it is solved. Thanks for your helps  :lol
I found out that DuplicateHandle can be used to duplicate an object handle and therefor files too.
I used it like this:

Invoke GetCurrentProcess
Mov ProcessHdl, eax

Invoke DuplicateHandle, ProcessHdl, OrigHandle, ProcessHdl, Addr DupHandle, DUPLICATE_SAME_ACCESS, FALSE, DUPLICATE_SAME_ACCESS


and it works.