/// <summary> /// Create global events necessary for handshaking with the parent /// </summary> /// <param name="nodeNumber"></param> /// <returns>True if events created successfully and false otherwise</returns> private static bool CreateGlobalEvents(int nodeNumber) { bool createdNew = false; if (NativeMethods.IsUserAdministrator()) { EventWaitHandleSecurity mSec = new EventWaitHandleSecurity(); // Add a rule that grants the access only to admins and systems mSec.SetSecurityDescriptorSddlForm(NativeMethods.ADMINONLYSDDL); // Create an initiation event to allow the parent side to prove to the child that we have the same level of privilege as it does. // this is done by having the parent set this event which means it needs to have administrative permissions to do so. globalInitiateActivationEvent = new EventWaitHandle(false, EventResetMode.ManualReset, LocalNodeProviderGlobalNames.NodeInitiateActivationEventName(nodeNumber), out createdNew, mSec); } else { // Create an initiation event to allow the parent side to prove to the child that we have the same level of privilege as it does. // this is done by having the parent set this event which means it has atleast the same permissions as the child process globalInitiateActivationEvent = new EventWaitHandle(false, EventResetMode.ManualReset, LocalNodeProviderGlobalNames.NodeInitiateActivationEventName(nodeNumber), out createdNew); } // This process must be the creator of the event to prevent squating by a lower privilaged attacker if (!createdNew) { return false; } // Informs the parent process that the child process has been created. globalNodeActive = new EventWaitHandle(false, EventResetMode.ManualReset, LocalNodeProviderGlobalNames.NodeActiveEventName(nodeNumber)); globalNodeActive.Set(); // Indicate to the parent process, this node is currently is ready to start to recieve requests globalNodeInUse = new EventWaitHandle(false, EventResetMode.ManualReset, LocalNodeProviderGlobalNames.NodeInUseEventName(nodeNumber)); // Used by the parent process to inform the child process to shutdown due to the child process // not recieving the initialization command. globalNodeErrorShutdown = new EventWaitHandle(false, EventResetMode.ManualReset, LocalNodeProviderGlobalNames.NodeErrorShutdownEventName(nodeNumber)); // Inform the parent process the node has started its communication threads. globalNodeActivate = new EventWaitHandle(false, EventResetMode.ManualReset, LocalNodeProviderGlobalNames.NodeActivedEventName(nodeNumber)); return true; }