Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

OBJECT_ATTRIBUTES (Structures)
 
.
Summary
The OBJECT_ATTRIBUTES structure specifies attributes that can be applied to objects or object handles by routines that create objects and/or return handles to objects.

VB.NET Definition:

<StructLayout(LayoutKind.Sequential)> _
Public Structure OBJECT_ATTRIBUTES
    Implements IDisposable
    Public Length As Integer
    Public RootDirectory As IntPtr
    Private m_objectName As IntPtr
    Public Attributes As UInteger
    Public SecurityDescriptor As IntPtr
    Public SecurityQualityOfService As IntPtr

C# Definition:

[StructLayout(LayoutKind.Sequential)]
public struct OBJECT_ATTRIBUTES : IDisposable
{
   public int Length;
   public IntPtr RootDirectory;
   private IntPtr objectName;
   public uint Attributes;
   public IntPtr SecurityDescriptor;
   public IntPtr SecurityQualityOfService;

    Public Sub New(name As String, attrs As UInteger)
        Length = 0
        RootDirectory = IntPtr.Zero
        m_objectName = IntPtr.Zero
        Attributes = attrs
        SecurityDescriptor = IntPtr.Zero
        SecurityQualityOfService = IntPtr.Zero
   public OBJECT_ATTRIBUTES(string name, uint attrs)
   {
     Length = 0;
     RootDirectory = IntPtr.Zero;
     objectName = IntPtr.Zero;
     Attributes = attrs;
     SecurityDescriptor = IntPtr.Zero;
     SecurityQualityOfService = IntPtr.Zero;

        Length = Marshal.SizeOf(Me)
        ObjectName = New UNICODE_STRING(name)
    End Sub
     Length = Marshal.SizeOf(this);
     ObjectName = new UNICODE_STRING(name);
   }

    Public Property ObjectName As UNICODE_STRING
        Get
            Return DirectCast(Marshal.PtrToStructure(m_objectName, GetType(UNICODE_STRING)), UNICODE_STRING)
        End Get
   public UNICODE_STRING ObjectName
   {
     get
     {
      return (UNICODE_STRING)Marshal.PtrToStructure(
       objectName, typeof(UNICODE_STRING));
     }

        Set
            Dim fDeleteOld As Boolean = m_objectName <> IntPtr.Zero
            If Not fDeleteOld Then
                m_objectName = Marshal.AllocHGlobal(Marshal.SizeOf(value))
            End If
            Marshal.StructureToPtr(value, m_objectName, fDeleteOld)
        End Set
    End Property
     set
     {
      bool fDeleteOld = objectName != IntPtr.Zero;
      if (!fDeleteOld)
       objectName = Marshal.AllocHGlobal(Marshal.SizeOf(value));
      Marshal.StructureToPtr(value, objectName, fDeleteOld);
     }
   }

    Public Sub Dispose()
        If m_objectName <> IntPtr.Zero Then
            Marshal.DestroyStructure(m_objectName, GetType(UNICODE_STRING))
            Marshal.FreeHGlobal(m_objectName)
            m_objectName = IntPtr.Zero
        End If
    End Sub
End Structure

C# Definition:

[StructLayout(LayoutKind.Sequential)]
public struct OBJECT_ATTRIBUTES : IDisposable
{
   public int Length;
   public IntPtr RootDirectory;
   private IntPtr objectName;
   public uint Attributes;
   public IntPtr SecurityDescriptor;
   public IntPtr SecurityQualityOfService;

   public OBJECT_ATTRIBUTES(string name, uint attrs)
   public void Dispose()
   {
     Length = 0;
     RootDirectory = IntPtr.Zero;
     objectName = IntPtr.Zero;
     Attributes = attrs;
     SecurityDescriptor = IntPtr.Zero;
     SecurityQualityOfService = IntPtr.Zero;

     Length = Marshal.SizeOf(this);
     ObjectName = new UNICODE_STRING(name);
   }

   public UNICODE_STRING ObjectName
   {
     get
     {
      return (UNICODE_STRING)Marshal.PtrToStructure(
       objectName, typeof(UNICODE_STRING));
     }

     set
     {
      bool fDeleteOld = objectName != IntPtr.Zero;
      if (!fDeleteOld)
       objectName = Marshal.AllocHGlobal(Marshal.SizeOf(value));
      Marshal.StructureToPtr(value, objectName, fDeleteOld);
     }
   }

   public void Dispose()
   {
     if (objectName != IntPtr.Zero)
     {
       Marshal.DestroyStructure(objectName, typeof(UNICODE_STRING));
       Marshal.FreeHGlobal(objectName);
       objectName = IntPtr.Zero;
     }
   }
}

User-Defined Field Types:

UNICODE_STRING

Notes:

None.

Documentation

Please edit this page!

Do you have...

  • helpful tips?
  • corrections to the existing content?
  • alternate definitions?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions