Hi,
i’m get in a troubl when i want to get the full path of the current process in the dispatch routine of IRP_MJ_WRITE. the code is :
NTSTATUS
MyWrite(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
PUNICODE_STRING processName = NULL;
ULONG offset = 0;
PEPROCESS CurrentProcess = NULL;
PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation( Irp );
if(!(irpSp->FileObject->FileName).Buffer)
return SfPassThrough(DeviceObject,Irp);
if((irpSp->FileObject->FileName).Length<6)
return SfPassThrough(DeviceObject,Irp);
CurrentProcess = PsGetCurrentProcess();
KeAttachProcess(CurrentProcess);
offset = *(PULONG)((ULONG)CurrentProcess + 0x1B0); //to get the peb address
offset = *(PULONG)((ULONG)offset + 0x10); //here is a wrong pointed out by wdb
processName = (PUNICODE_STRING)(offset + 0x38); //imagefile
DbgPrint(“Current Process Full Path Name: %wZ\n”,processName);
KeDetachProcess();
return SfPassThrough(DeviceObject,Irp);
}
When i run these code in ,the system got a blue_screen…
who can tell me what’ why???
Thanks!