1

I got the following scenario:

Process A create process B, and then B try to get a handle of A with OpenProcess(). I want B to have PROCESS_ALL_ACCESS rights to A.

How should I achieve this?

Thanks.

skaffman
  • 398,947
  • 96
  • 818
  • 769
smwikipedia
  • 61,609
  • 92
  • 309
  • 482

1 Answers1

2

Probably the easiest way is for the parent to avoid the child having to call OpenProcess at all. Instead, have the parent retrieve a handle to itself (which will automatically have all access) and then call DuplicateHandle with bInheritHandle = true. Then when it creates process B, that handle (with full access to process A) will already be open in the child. Process A simply has to pass the handle to process B, and process B can use it.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111