所有,我试图使用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);
...
}
答案 0 :(得分:1)
PFLT_RELATED_OBJECTS copiedRelatedObj;
copiedRelatedObj 变量是指针。它没有初始化。为那种声明指针类型的可怕习惯,有点看不见的Microsoft C程序员。然后删除P.修复:
FLT_RELATED_OBJECTS copiedRelatedObj;
答案 1 :(得分:1)
RtlZeroMemory 需要指针作为其第一个参数的内存块。但你给它指针指针(因为PFLT_RELATED_OBJECTS已经是一个指针)。使用
FLT_RELATED_OBJECTS copiedRelatedObj;