未记录的结构定义和转发

时间:2016-01-02 15:34:02

标签: c visual-studio-2012 reverse-engineering

我有两个未定义的结构,我从ntoskrnl x64:

构建
 /* RegistrationHandle (_OB_HANDLE)  */
 typedef struct _OB_HANDLE {
    WORD Version;
    WORD OperationRegistrationCount;
    POB_OPERATION_REGISTRATION RegistrationContext;  // Struct defined inside wdm.h
    UNICODE_STRING Altitude;                         // UNICODE_STRING inside ntdef.h
    CALLBACK_ENTRY Entries[MAXENTRIES]; 
 } OB_HANDLE,  *POB_HANDLE;


 typedef struct _CALLBACK_ENTRY {
    LIST_ENTRY CallbackList;                    // LIST_ENTRY inside ntdef.h
    OB_OPERATION Operations;                    // typedef ULONG inside wdmh.h
    ULONG Active;                               // Set to 1 after all the callbacks have been successfully inserted.
    POB_HANDLE ObHandle; 
    POBJECT_TYPE ObjectType;                    // Hidden Structure (NOT EXPORTED) inside wdm.h
    POB_PRE_OPERATION_CALLBACK  PreOperation;   // Function Pointer inside wdm.h
    POB_POST_OPERATION_CALLBACK PostOperation;  // Function Pointer inside wdm.h
    ULONG unknown;
} CALLBACK_ENTRY, *PCALLBACK_ENTRY;

虽然我为他们创建了一个头文件。我收到错误:

error C2143: syntax error : missing ';' before '*'

对于行CALLBACK_ENTRY条目[MAXENTRIES];

当我切换周围的结构时:

 typedef struct _CALLBACK_ENTRY {
    LIST_ENTRY CallbackList;                    // LIST_ENTRY inside ntdef.h
    OB_OPERATION Operations;                    // typedef ULONG inside wdmh.h
    ULONG Active;                               // Set to 1 after all the callbacks have been successfully inserted.
    POB_HANDLE ObHandle; 
    POBJECT_TYPE ObjectType;                    // Hidden Structure (NOT EXPORTED) inside wdm.h
    POB_PRE_OPERATION_CALLBACK  PreOperation;   // Function Pointer inside wdm.h
    POB_POST_OPERATION_CALLBACK PostOperation;  // Function Pointer inside wdm.h
    ULONG unknown;
} CALLBACK_ENTRY, *PCALLBACK_ENTRY;


 /* RegistrationHandle (_OB_HANDLE)  */
 typedef struct _OB_HANDLE {
    WORD Version;
    WORD OperationRegistrationCount;
    POB_OPERATION_REGISTRATION RegistrationContext;  // Struct defined inside wdm.h
    UNICODE_STRING Altitude;                         // UNICODE_STRING inside ntdef.h
    CALLBACK_ENTRY Entries[MAXENTRIES]; 
 } OB_HANDLE,  *POB_HANDLE;

我现在收到一行错误:POB_HANDLE ObHandle;

 error C2143: syntax error : missing ';' before '*'

我知道我做错了,因为没有向前声明某些东西,或者它可能与结构内部的数组有关。

我一直在网上搜索。关于在相同的两个定义结构中嵌套两个结构的信息不多。

任何帮助都可以帮助您正确编译。感谢。

2 个答案:

答案 0 :(得分:0)

将第二个typedef(您的第二个代码段)拆分为:

typedef struct _OB_HANDLE * POB_HANDLE;

typedef struct _CALLBACK_ENTRY {
  LIST_ENTRY CallbackList;                    // LIST_ENTRY inside ntdef.h
  OB_OPERATION Operations;                    // typedef ULONG inside wdmh.h
  ULONG Active;                               // Set to 1 after all the   callbacks have been successfully inserted.
  POB_HANDLE ObHandle; 
  POBJECT_TYPE ObjectType;                    // Hidden Structure (NOT EXPORTED) inside wdm.h
  POB_PRE_OPERATION_CALLBACK  PreOperation;   // Function Pointer inside wdm.h
  POB_POST_OPERATION_CALLBACK PostOperation;  // Function Pointer inside wdm.h
  ULONG unknown;
} CALLBACK_ENTRY, *PCALLBACK_ENTRY;


/* RegistrationHandle (_OB_HANDLE)  */
typedef struct _OB_HANDLE {
  WORD Version;
  WORD OperationRegistrationCount;
  POB_OPERATION_REGISTRATION RegistrationContext;  // Struct defined inside wdm.h
  UNICODE_STRING Altitude;                         // UNICODE_STRING inside ntdef.h
  CALLBACK_ENTRY Entries[MAXENTRIES]; 
} OB_HANDLE;

答案 1 :(得分:0)

POB_HANDLE ObHandle;需要采用不同的方式。

 /* pre-declare structure _OB_HANDLE */
 struct _OB_HANDLE;
 typedef struct _CALLBACK_ENTRY {
     LIST_ENTRY CallbackList;                    // LIST_ENTRY inside      ntdef.h
     OB_OPERATION Operations;                    // typedef ULONG inside wdmh.h
     ULONG Active;                               // Set to 1 after all the callbacks have been successfully inserted.
     struct _OB_HANDLE * ObHandle;               // <<<use struct not typedef
     POBJECT_TYPE ObjectType;                    // Hidden Structure (NOT EXPORTED) inside wdm.h
     POB_PRE_OPERATION_CALLBACK  PreOperation;   // Function Pointer inside wdm.h
     POB_POST_OPERATION_CALLBACK PostOperation;  // Function Pointer inside wdm.h
     ULONG unknown;
 } CALLBACK_ENTRY, *PCALLBACK_ENTRY;


  /* RegistrationHandle (_OB_HANDLE)  */
  typedef struct _OB_HANDLE {
     WORD Version;
     WORD OperationRegistrationCount;
     POB_OPERATION_REGISTRATION RegistrationContext;  // Struct defined inside wdm.h
     UNICODE_STRING Altitude;                         // UNICODE_STRING inside ntdef.h
     CALLBACK_ENTRY Entries[MAXENTRIES]; 
  } OB_HANDLE,  *POB_HANDLE;