Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Access to DirectDraw Objects

Hi,

I am using DirectX 7 (DirectDraw only) on Win2000 in a DLL. A service which
uses the DLL is started automatically using the 'Local System account' on
startup. One or more instances of an application using the same DLL may be
started later. When an application is started later, it fails to initialize
and it fails with a 0xC0000142 error. If I comment out the DirectDraw object
(DirectDrawCreateEx (NULL, (void **) &ddObj, IID_IDirectDraw7, NULL)) creation,
everything works fine. I assume the problem is because of differing Security
Contexts. I am logged in as an Administrator. When I change the 'Log On'
account of the service from a 'Local System account' to an 'Administrator'
account, everything works fine.

Given that DirectDraw object are COM objects, I thought I would try and use
CoInitializeSecurity () to allow access to everybody (similar to creating
a
NULL DACL for other objects) in both the service application and my application.
I found out that I couldn't use this in a DLL. However, that didn't help.
Following is the code snippet that I used.

SECURITY_ATTRIBUTES sa;
SECURITY_DESCRIPTOR sd;

sa.nLength = sizeof (SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = &sd; // NULL Dacl, initialized before this
// assignment
sa.bInheritHandle = TRUE; // Child process can inherit

CoInitialize ();
ret = CoInitializeSecurity (
&sa,
-1,
NULL,
NULL,
RPC_C_AUTHN_LEVEL_NONE,
RPC_C_IMP_LEVEL_DEFAULT,
NULL,
EOAC_ANY_AUTHORITY,
NULL);

I also tried using dcomcnfg, but that didn't help. Since I am new to COM
and to Security in general, I am not sure if I am doing the right thing.
Also,I am not sure if I am correct in my assuming that I can use COM security
functions as DirectDraw objects are COM objects. I hope there is some solution
to this problem. Any help is greatly appreciated.

Thanks,
Sheela.
[2073 byte] By [Sheela] at [2007-11-9 23:50:01]
# 1 Re: Access to DirectDraw Objects
hhhmmm - audit for object access - and see what transpires in the audit event
logs. also, can you send the code for building the SD?

"Sheela" <Sheela_Kashyap@yahoo.com> wrote:
>
>Hi,
>
>I am using DirectX 7 (DirectDraw only) on Win2000 in a DLL. A service which
>uses the DLL is started automatically using the 'Local System account' on
>startup. One or more instances of an application using the same DLL may
be
>started later. When an application is started later, it fails to initialize
>and it fails with a 0xC0000142 error. If I comment out the DirectDraw object
>(DirectDrawCreateEx (NULL, (void **) &ddObj, IID_IDirectDraw7, NULL)) creation,
>everything works fine. I assume the problem is because of differing Security
>Contexts. I am logged in as an Administrator. When I change the 'Log On'
>account of the service from a 'Local System account' to an 'Administrator'
>account, everything works fine.
>
>Given that DirectDraw object are COM objects, I thought I would try and
use
>CoInitializeSecurity () to allow access to everybody (similar to creating
>a
>NULL DACL for other objects) in both the service application and my application.
>I found out that I couldn't use this in a DLL. However, that didn't help.
>Following is the code snippet that I used.
>
>SECURITY_ATTRIBUTES sa;
>SECURITY_DESCRIPTOR sd;
>
>sa.nLength = sizeof (SECURITY_ATTRIBUTES);
>sa.lpSecurityDescriptor = &sd; // NULL Dacl, initialized before this
> // assignment
>sa.bInheritHandle = TRUE; // Child process can inherit
>
>CoInitialize ();
>ret = CoInitializeSecurity (
> &sa,
> -1,
> NULL,
> NULL,
> RPC_C_AUTHN_LEVEL_NONE,
> RPC_C_IMP_LEVEL_DEFAULT,
> NULL,
> EOAC_ANY_AUTHORITY,
> NULL);
>
>I also tried using dcomcnfg, but that didn't help. Since I am new to COM
>and to Security in general, I am not sure if I am doing the right thing.
>Also,I am not sure if I am correct in my assuming that I can use COM security
>functions as DirectDraw objects are COM objects. I hope there is some solution
>to this problem. Any help is greatly appreciated.
>
>Thanks,
>Sheela.
>
Michael Howard at 2007-11-12 0:14:46 >