Solved

Free SECURITY_ATTRIBUTES and SECURITY_DESCRIPTOR

Posted on 2003-11-07
3
728 Views
Last Modified: 2013-12-03
Hi Experts,

If i use security attributes and security descriptors with e.g. CreateProcess, CreateNamedPipe or CreateFile - who is responsible for freeing the SECURITY_ATTRIBUTES and the SECURITY_DESCRIPTOR after use ??

Kind Regards
Peter
0
Comment
Question by:PeterLarsen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 9704470
What do you mean by "freeing" them - they are usually allocated on the stack and will be cleaned up when the calling function terminates. In other words: This is to be performed (and is done automatically) by the application that calls the APIs you mentioned.
0
 
LVL 2

Author Comment

by:PeterLarsen
ID: 9707132
Hi jkr and thanks for your comment,

I dont get it.
If program "A" starts program "B" by calling CreateProcess, program "A" must create an instance of PSecurityAttributes and PSecurityDescriptor, and the information are used by windows to set the security in the called process, right ?
But if program "A" terminates before program "B", the information are no longer available in memory - what then, are the information copied to the called process on creation or .. ??

PSecurityAttributes and PSecurityDescriptor are pointers to record structures and are created by e.g. New(pointer). Normally it's up to the programmer to keep track of allocated memory, and to make sure that they are freed - by call to Dispose or similar - before the program terminates. But in this case (CreateProcess) the helpfile dont say anything about it.

Kind Regards
Peter
0
 
LVL 86

Accepted Solution

by:
jkr earned 50 total points
ID: 9707754
>>But if program "A" terminates before program "B", the information are no longer
>>available in memory

Yes, but the security information is applied to the newly created process, it is no longer necessary to keep them. In fact, they are obsolete as soon as e.g. 'CreateProcess()' returns.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question