需要在C#中使用CONTEXT struct P / Invoke声明

时间:2009-11-26 11:26:06

标签: pinvoke

是否有人在WinNT.h文件中定义了CONTEXT结构的P / Invoke声明?

感谢。

2 个答案:

答案 0 :(得分:2)

PInvoke.NET是一个免费的Visual Studio插件,可以自动插入P / Invoke签名。

另一个有用的工具是P/Invoke Interop Assistant

答案 1 :(得分:1)

    using System;
    using System.Runtime.InteropServices;

    [StructLayout(LayoutKind.Sequential)]
    public struct CONTEXT
    {
        public uint ContextFlags;
        public uint Dr0;
        public uint Dr1;
        public uint Dr2;
        public uint Dr3;
        public uint Dr6;
        public uint Dr7;
        public FLOATING_SAVE_AREA FloatSave;
        public uint SegGs;
        public uint SegFs;
        public uint SegEs;
        public uint SegDs;
        public uint Edi;
        public uint Esi;
        public uint Ebx;
        public uint Edx;
        public uint Ecx;
        public uint Eax;
        public uint Ebp;
        public uint Eip;
        public uint SegCs;
        public uint EFlags;
        public uint Esp;
        public uint SegSs;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst=0x200, ArraySubType=UnmanagedType.I1)]
        public byte[] ExtendedRegisters;
    }