Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Free SECURITY_ATTRIBUTES and SECURITY_DESCRIPTOR

Posted on 2003-11-07
3
Medium Priority
?
736 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
  • 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 200 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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

783 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