🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.nativeapi
Article #14

SetSecurityInfo on Winstation Object - Invalid Access To Memory Location

#14
From: M
Date: Wed, 16 Mar 2005 16:13
84 lines
2755 bytes
Hi All,


I'm trying to set a new DACL (using D5 on either 2k, XP or 2k3) on both
the Winstation and Desktop objects during Winlogon using the following
code


<code>


procedure set_winstation_dacl(hToken : cardinal);
var s      : string;
    d      : string;
    dt     : hdesk;
    mydacl : pacl;
    sd     : psecurity_descriptor
    lo_sid : string;
begin
   .
   .
   .
   .
   d := 'D:(A;NP;LCWP;;;'+s+') blah blah blah';


   dt := openwindowstation('WinSta0',fa­lse,GENERIC_ALL);


   fillchar(mydacl,sizeof(pacl),0­);
   fillchar(sd.a,sizeof(psecurity­_descriptor),0);


convertstringsecuritydescripto­rtosecuritydescriptor(pchar(d)­,SDDL_REVISION_1,sd,nil);



   if
setsecurityinfo(dt,SE_WINDOW_O­BJECT,DACL_SECURITY_INFORMATIO­N,nil,nil,sd.dacl,nil)<>ERROR_­SUCCESS

then
      showmessage('Winstation - ' + syserrormessage(getlasterror))
   else
      showmessage('Winstation ok');


   .
   .
   .
   .
end;


</code>


but essentially always come up with the error - Invalid Access To
Memory Location.  I've previously read stuff about DWORD alignment
using the SetSecurityInfo API and have {$A+} set as a directive in the
code, however, makes no difference :-(


In the above hToken is obtained using the code


logonuser('a','b','c',LOGON32_­LOGON_INTERACTIVE,LOGON32_PROV­IDER_DEFAULT,th)



and passing th (declared as cardinal) to the above procedure.  Also the
convertstringsecuritydescripto­rtosecuritydescriptor API does generate
a correct DACL as I've used it and applied the same DACL to a newly
created directory...

Can anyone assist with this please ? 


TIA 


Mark
Technical Details
Message-ID: <1110989607.040030.95720@z14g2000cwz.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!z14g2000cwz.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f94dd,f4442fbedc3dcc56,start
X-Google-Attributes: gidf94dd,public
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!z14g2000cwz.googlegroups.com!not-for-mail
From: "M" <mark@wizbang.org.uk>
Newsgroups: borland.public.delphi.nativeapi
Subject: SetSecurityInfo on Winstation Object - Invalid Access To Memory Location
Date: 16 Mar 2005 08:13:27 -0800
Organization: http://groups.google.com
Lines: 85
Message-ID: <1110989607.040030.95720@z14g2000cwz.googlegroups.com>
NNTP-Posting-Host: 195.194.124.2
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1110989613 8662 127.0.0.1 (16 Mar 2005 16:13:33 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 16 Mar 2005 16:13:33 +0000 (UTC)
User-Agent: G2/0.2
Complaints-To: groups-abuse@google.com
Injection-Info: z14g2000cwz.googlegroups.com; posting-host=195.194.124.2;
   posting-account=uWIkvg0AAAA3AVRDiJH5XxxLhonx33NO