Kerem Gümrükcü
2009-11-03 21:07:41 UTC
Hi,
thats what the original looks like:
typedef struct _PROCESS_HEAP_ENTRY {
PVOID lpData;
DWORD cbData;
BYTE cbOverhead;
BYTE iRegionIndex;
WORD wFlags;
union {
struct {
HANDLE hMem;
DWORD dwReserved[3];
} Block;
struct {
DWORD dwCommittedSize;
DWORD dwUnCommittedSize;
LPVOID lpFirstBlock;
LPVOID lpLastBlock;
} Region;
} ;
}PROCESS_HEAP_ENTRY
Thats my signature translation:
[Flags]
public enum PROCESS_HEAP_ENTRY_WFLAGS : ushort
{
PROCESS_HEAP_ENTRY_BUSY = 0x0004,
PROCESS_HEAP_ENTRY_DDESHARE = 0x0020,
PROCESS_HEAP_ENTRY_MOVEABLE = 0x0010,
PROCESS_HEAP_REGION = 0x0001,
PROCESS_HEAP_UNCOMMITTED_RANGE = 0x0002,
}
[StructLayoutAttribute(LayoutKind.Explicit)]
public struct UNION_BLOCK
{
[FieldOffset(0)]
public STRUCT_BLOCK Block;
[FieldOffset(0)]
public STRUCT_REGION Region;
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct STRUCT_BLOCK
{
public IntPtr hMem;
[MarshalAsAttribute(UnmanagedType.ByValArray,SizeConst=3,
ArraySubType=UnmanagedType.U4)]
public uint[] dwReserved;
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct STRUCT_REGION
{
public uint dwCommittedSize;
public uint dwUnCommittedSize;
public IntPtr lpFirstBlock;
public IntPtr lpLastBlock;
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct PROCESS_HEAP_ENTRY
{
public IntPtr lpData;
public uint cbData;
public byte cbOverhead;
public byte iRegionIndex;
public PROCESS_HEAP_ENTRY_WFLAGS wFlags;
public UNION_BLOCK UnionBlock;
}
that is what i constructed, it compiles just fine, but throws a runtime
exception that either something is wrong with data alignement or
that the field has been overlapped by a non-object field. Thats pretty
unclear to me, why this happens,...can someone please give me the
right signature for this or at least tell me whats wrong on that
signature,...
Thanks in advance,...
Regards
Kerem
thats what the original looks like:
typedef struct _PROCESS_HEAP_ENTRY {
PVOID lpData;
DWORD cbData;
BYTE cbOverhead;
BYTE iRegionIndex;
WORD wFlags;
union {
struct {
HANDLE hMem;
DWORD dwReserved[3];
} Block;
struct {
DWORD dwCommittedSize;
DWORD dwUnCommittedSize;
LPVOID lpFirstBlock;
LPVOID lpLastBlock;
} Region;
} ;
}PROCESS_HEAP_ENTRY
Thats my signature translation:
[Flags]
public enum PROCESS_HEAP_ENTRY_WFLAGS : ushort
{
PROCESS_HEAP_ENTRY_BUSY = 0x0004,
PROCESS_HEAP_ENTRY_DDESHARE = 0x0020,
PROCESS_HEAP_ENTRY_MOVEABLE = 0x0010,
PROCESS_HEAP_REGION = 0x0001,
PROCESS_HEAP_UNCOMMITTED_RANGE = 0x0002,
}
[StructLayoutAttribute(LayoutKind.Explicit)]
public struct UNION_BLOCK
{
[FieldOffset(0)]
public STRUCT_BLOCK Block;
[FieldOffset(0)]
public STRUCT_REGION Region;
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct STRUCT_BLOCK
{
public IntPtr hMem;
[MarshalAsAttribute(UnmanagedType.ByValArray,SizeConst=3,
ArraySubType=UnmanagedType.U4)]
public uint[] dwReserved;
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct STRUCT_REGION
{
public uint dwCommittedSize;
public uint dwUnCommittedSize;
public IntPtr lpFirstBlock;
public IntPtr lpLastBlock;
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct PROCESS_HEAP_ENTRY
{
public IntPtr lpData;
public uint cbData;
public byte cbOverhead;
public byte iRegionIndex;
public PROCESS_HEAP_ENTRY_WFLAGS wFlags;
public UNION_BLOCK UnionBlock;
}
that is what i constructed, it compiles just fine, but throws a runtime
exception that either something is wrong with data alignement or
that the field has been overlapped by a non-object field. Thats pretty
unclear to me, why this happens,...can someone please give me the
right signature for this or at least tell me whats wrong on that
signature,...
Thanks in advance,...
Regards
Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------