BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SetSecurityInfo on Winstation Object - Invalid Access To Mem

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Native API
View previous topic :: View next topic  
Author Message
M
Guest





PostPosted: Wed Mar 16, 2005 9:13 pm    Post subject: SetSecurityInfo on Winstation Object - Invalid Access To Mem Reply with quote



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 := 'DSadA;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
Back to top
M
Guest





PostPosted: Thu Mar 17, 2005 5:29 pm    Post subject: Re: SetSecurityInfo on Winstation Object - Invalid Access To Reply with quote



The api call convertstringsecuritydescripto­­rtosecuritydescriptor
generates a relative security descriptor, however, SetSecurityInfo
requires an absolute one, therefore, simply call makeabsolutesd on the
returned security descriptor before passing it to the SetSecurityInfo
api !
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Native API All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.