Problems With Struct

  • Thread starter Thread starter David White
  • Start date Start date
D

David White

I have the following structure. I need to create a pointer to it for calling
the Windows API. When I try, I get an error. I have found that the String is
the culprit. In the C declaration for this structure, the String is shown as
UNICODE_STRING. Can someone tell me the correct datatype to use for the String
which will allow me to both call the Win API and declare a pointer to this
structure? Thanks.

[StructLayout(LayoutKind.Sequential)]
struct OBJECT_TYPE_INFORMATION
{
public String TypeName;
public uint TotalNumberOfObjects;
public uint TotalNumberOfHandles;
public uint TotalPagedPoolUsage;
public uint TotalNonPagedPoolUsage;
public uint TotalNamePoolUsage;
public uint TotalHandleTableUsage;
public uint HighWaterNumberOfObjects;
public uint HighWaterNumberOfHandles;
public uint HighWaterPagedPoolUsage;
public uint HighWaterNonPagedPoolUsage;
public uint HighWaterNamePoolUsage;
public uint HighWaterHandleTableUsage;
public uint InvalidAttributes;
public GENERIC_MAPPING GenericMapping;
public uint ValidAccessMask;
public bool SecurityRequired;
public bool MaintainHandleCount;
public uint PoolType;
public uint DefaultPagedPoolCharge;
public uint DefaultNonPagedPoolCharge;
}
 
David,
I have found that the String is
the culprit. In the C declaration for this structure, the String is shown as
UNICODE_STRING.

Exactly, UNICODE_STRING is defined as

typedef struct _LSA_UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
} LSA_UNICODE_STRING,

so that's what you have to match.


Mattias
 
Back
Top