iduniq iduniq wrote: > Hi, > Good day! I have a problem opening a shared mem, the error code > of which is 2 (Object does not exist). This is my setup, a Windows > service calls a process A, process A creates successfully shared > mem. Then I have another app which runs on DOS prompt which tries to > open the shared mem but encounters error 2. The OS is Windows Server > 2003 for Small Business Server (ServicePack 1). Since process A > calls another process (process B), i tested using OpenFilemapping > (same open code with DOS app) in process B and it successfully opened > the shared mem. Any ides? > > TIA, > Roy > > // Shared mem creation (NotQuiteNullDacl clss came from codeguru.com)
CodeGuru has legacy stuff that isn't updated. I don't trust much of anything from there. > int maxlen = 256; > SECURITY_ATTRIBUTES MutexAttributes; > NotQuiteNullDacl Dacl; > > bool bDaclOk = Dacl.Create(); > ZeroMemory( &MutexAttributes, sizeof(MutexAttributes) ); > MutexAttributes.nLength = sizeof( MutexAttributes ); > MutexAttributes.bInheritHandle = FALSE; > SECURITY_DESCRIPTOR SD; > BOOL bInitOk = InitializeSecurityDescriptor( &SD, > SECURITY_DESCRIPTOR_REVISION ); > BOOL bSetOk = SetSecurityDescriptorDacl( &SD, > TRUE, > Dacl.GetPDACL(), > FALSE ); > MutexAttributes.lpSecurityDescriptor = &SD; Why is a default security descriptor not good enough for you? And you aren't testing for errors. Any of these functions might be failing. > hmmf=CreateFileMapping((HANDLE) 0xFFFFFFFF, > &MutexAttributes,PAGE_READWRITE,0,maxlen,"MYSVCNAME"); > > // Open shared mem > HANDLE hdltest = OpenFileMapping(FILE_MAP_READ, TRUE,"MYSVCNAME"); NT Services operate under a different set of rules than a command prompt. Quick search turned up this link that you might find useful: http://msdn2.microsoft.com/en-us/library/aa366551.aspx -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* VerifyMyPC 2.2 Change tracking and management tool. Reduce tech. support times from 2 hours to 5 minutes. Free for personal use, $10 otherwise. http://www.CubicleSoft.com/VerifyMyPC/
