I am creating an object, for example a Waitable Timer, and I want to share my object with another process:
// In process 1:
HANDLE hTimerProcess1 = CreateWaitableTimer(NULL, FALSE, L"Time1");
// In process 2:
HANDLE hTimerProcess2 = CreateWaitableTimer(NULL, FALSE, L"Time1");
- As the third parameter, I am passing the same name
"Time1", does that mean that I am creating a new kernel objecthTimerProcess2but with the same descriptor table entry ashTimerProcess1, or ishTimerProcess2just a reference to the existing object (hTimerProcess1)? - How can I prove that
hTimerProcess1andhTimerProcess2are the same kernel object? I tried getting their address but they are different.
I'm reading M. Richter's "Advanced Win32 Programming"
From the docs to
CreateWaitableTimer:So the answer to your question #1 is no, you're not creating a new kernel object - if both calls succeed, they'll refer to the same timer.
How to prove they're the same? You could probably do this by calling
SetWaitableTimerin one process, and waiting on it in the other.If you want to make extra sure that you get the same timer object in the second process, call
OpenWaitableTimerinstead - since this only succeeds if the timer already exists.