0

所有,我试图用来RtlCopyMemory复制一个结构实例,但似乎在回调返回之前它没有成功复制实例。我不知道我是否遗漏了什么,请帮助查看以下代码。谢谢。

#define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
#define RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))

typedef struct _FLT_RELATED_OBJECTS {

    USHORT CONST Size;
    USHORT CONST TransactionContext;            //TxF mini-version
    PFLT_FILTER CONST Filter;
    PFLT_VOLUME CONST Volume;
    PFLT_INSTANCE CONST Instance;
    PFILE_OBJECT CONST FileObject;
    PKTRANSACTION CONST Transaction;

} FLT_RELATED_OBJECTS, *PFLT_RELATED_OBJECTS;

FLT_POSTOP_CALLBACK_STATUS
CreateBackUpFile_WhenPostCreatedCallback (
    _Inout_ PFLT_CALLBACK_DATA Data,
    _In_ PCFLT_RELATED_OBJECTS FltObjects,
    _In_ PVOID CompletionContext,
    _In_ FLT_POST_OPERATION_FLAGS Flags
    )
{
   PFLT_RELATED_OBJECTS copiedRelatedObj;
   ...
   RtlZeroMemory(&copiedRelatedObj, FltObjects->Size);
   KdBreakPoint();
   RtlCopyMemory(&copiedRelatedObj,FltObjects,FltObjects->Size);
   DbgPrint("The file name in the FltObjects is : %s\n",FltObjects->FileObject->FileName);
   DbgPrint("The file name in the Duplicated FltObjects is : %s\n",copiedRelatedObj->FileObject->FileName);
   ...
}
4

2 回答 2

1

RtlZeroMemory需要指向内存块的指针作为其第一个参数。但是你给它一个指向指针的指针(因为 PFLT_RELATED_OBJECTS 已经是一个指针)。利用

FLT_RELATED_OBJECTS copiedRelatedObj;
于 2013-09-17T11:50:36.977 回答
1
   PFLT_RELATED_OBJECTS copiedRelatedObj;

CopyRelatedObj变量是一个指针。它没有被初始化。为那些声明指针类型的可怕习惯而大喊一些隐形的 Microsoft C 程序员。然后删除P。修复:

   FLT_RELATED_OBJECTS copiedRelatedObj;
于 2013-09-17T11:45:36.483 回答