smwikipedia
smwikipedia

Reputation: 64173

Question about process access privilege

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.

Upvotes: 1

Views: 210

Answers (1)

Jerry Coffin
Jerry Coffin

Reputation: 490018

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.

Upvotes: 2

Related Questions