Solved

Free SECURITY_ATTRIBUTES and SECURITY_DESCRIPTOR

Posted on 2003-11-07
3
715 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 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now