TSP and CreateSemaphore/CreateFileMapping

From: Trent Glascock (Glascock_at_discussions.microsoft.com)
Date: 10/11/04


Date: Mon, 11 Oct 2004 13:25:07 -0700

I am working on a TSP that needs to communicate with another process via
shared memory & a semephore.

The code in the TSP creates a semaphore and the shared memory, passing in
security attributes and a security descriptor so that the other process can
"attach" to them. The other process creates the semaphore and the shared
memory, checking the value of GetLastError to make sure that the objects
weren't created, to verify that it is attaching to them, not re-creating them.

Now when I run each of these, all return values from the Win32 APIs indicate
that everything is working correctly, but when I release the semaphore in the
other process the semaphore in the TSP doesn't get signalled. Also, when I
modify shared memory in the other process, the TSP's fileMapping doesn't
reflect this.

Now, if I move the code from the TSP to a Win32 service of my own creation,
the code works. Releasing the semaphore causes the semaphore in the service
to be signalled, and it sees the shared memory. This is of course my desire.

The question is why when the code is run under SvcHost.exe it doesn't work?
The service I created is set to log on as "Local Service", same as the TAPI
service.

It is almost as if when the other process calls
CreateSemaphore/CreateFileMapping it is creating it's own semaphore & shared
memory. Although after checking for the success of the calls, when I call
GetLastError, it returns ERROR_ALREADY_EXISTS.

Any ideas anyone???

--
Trent Glas***