印子:继续第八部分
https://chenghao.blog.csdn.net/article/details/146724782
第八部分:Npfs!NpFsdWrite函数到nt!IopfCompleteRequest函数
1: kd> kc 9
#
00 nt!IopfCompleteRequest
01 Npfs!NpFsdWrite
02 nt!IofCallDriver
03 nt!IopSynchronousServiceTail
04 nt!NtWriteFile
05 nt!_KiSystemService
06 SharedUserData!SystemCallStub
07 ntdll!ZwWriteFile
08 RPCRT4!UTIL_WriteFile
第一部分:
1: kd> kv 3
# ChildEBP RetAddr Args to Child
00 f794ab9c baaf50e5 e179e288 00000001 007b3990 Npfs!NpWriteDataQueue (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\base\fs\npfs\writesup.c @ 88]
01 f794ac14 baaf52f6 895824b8 007b3990 00000030 Npfs!NpCommonWrite+0x1b5 (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\base\fs\npfs\write.c @ 457]
02 f794ac54 80a2675c 895a5038 8979ef68 80a03598 Npfs!NpFsdWrite+0xcc (FPO: [Non-Fpo]) (CONV: stdcall) [d:\srv03rtm\base\fs\npfs\write.c @ 93]
第二部分:
NTSTATUS
NpFsdWrite (
IN PNPFS_DEVICE_OBJECT NpfsDeviceObject,
IN PIRP Irp
)
{
InitializeListHead (&DeferredList);
(VOID) NpCommonWrite( IrpSp->FileObject,
Irp->UserBuffer,
IrpSp->Parameters.Write.Length,
Irp->Tail.Overlay.Thread,
&Iosb,
Irp,
&DeferredList );
第三部分:
BOOLEAN
NpCommonWrite (
IN PFILE_OBJECT FileObject,
IN PVOID WriteBuffer,
IN ULONG WriteLength,
IN PETHREAD UserThread,
OUT PIO_STATUS_BLOCK Iosb,
IN PIRP Irp OPTIONAL,
IN PLIST_ENTRY DeferredList
)
{
。。。。。。
Iosb->Status = NpWriteDataQueue( WriteQueue,
ReadMode,
WriteBuffer,
WriteLength,
Ccb->Fcb->Specific.Fcb.NamedPipeType,
&WriteRemaining,
Ccb,
NamedPipeEnd,
UserThread,
DeferredList );
第四部分:
NTSTATUS
NpWriteDataQueue (
IN PDATA_QUEUE WriteQueue,
IN READ_MODE ReadMode,
IN PUCHAR WriteBuffer,
IN ULONG WriteLength,
IN NAMED_PIPE_TYPE PipeType,
OUT PULONG WriteRemaining,
IN PCCB Ccb,
IN NAMED_PIPE_END NamedPipeEnd,
IN PETHREAD UserThread,
IN PLIST_ENTRY DeferredList
)
{
。。。。。。
if (*WriteRemaining == 0) {
DebugTrace(0, Dbg, "Finished up the write remaining\n", 0);
//**** ASSERT( ReadIrp->IoStatus.Information != 0 );
NpDeferredCompleteRequest( ReadIrp, STATUS_SUCCESS, DeferredList );
#define NpDeferredCompleteRequest(IRP,STATUS,LIST) { \
(IRP)->IoStatus.Status = STATUS; \
InsertTailList ((LIST), &(IRP)->Tail.Overlay.ListEntry); \
}
第五部分:
(VOID) NpCommonWrite( IrpSp->FileObject,
Irp->UserBuffer,
IrpSp->Parameters.Write.Length,
Irp->Tail.Overlay.Thread,
&Iosb,
Irp,
&DeferredList );
NpReleaseVcb();
//
// Complete any deferred IRPs now we have dropped the locks
//
NpCompleteDeferredIrps (&DeferredList);
VOID
FORCEINLINE
NpCompleteDeferredIrps (
IN PLIST_ENTRY DeferredList
)
{
PIRP Irp;
PLIST_ENTRY Entry, NextEntry;
Entry = DeferredList->Flink;
while (Entry != DeferredList) {
Irp = CONTAINING_RECORD (Entry, IRP, Tail.Overlay.ListEntry);
NextEntry = Entry->Flink;
NpCompleteRequest (Irp, Irp->IoStatus.Status);
Entry = NextEntry;
}
}
#define NpCompleteRequest(IRP,STATUS) FsRtlCompleteRequest( (IRP), (STATUS) );
#define FsRtlCompleteRequest(IRP,STATUS) { \
(IRP)->IoStatus.Status = (STATUS); \
IoCompleteRequest( (IRP), IO_DISK_INCREMENT ); \
}
#define IO_DISK_INCREMENT 1