Problems With Struct

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;
}
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top