qishi1997
驱动牛犊
驱动牛犊
  • 注册日期2003-03-20
  • 最后登录2007-09-09
  • 粉丝0
  • 关注0
  • 积分40分
  • 威望4点
  • 贡献值0点
  • 好评度4点
  • 原创分0分
  • 专家分0分
阅读:1452回复:0

贴出代码高分求答案(filespy 加密)

楼主#
更多 发布于:2004-04-07 11:36
下面是我的代码,现在只是处理txt文件,在文件小于64K的时候结果正常单大于64k就checkbug希望各位大虾给点意见
例程前面我已经加了控制只处理某一个文件
******************write**********************************
if(( Irp->Flags & IRP_PAGING_IO || Irp->Flags & IRP_SYNCHRONOUS_PAGING_IO )&&(des!=NULL))// Irp->Flags & IRP_NOCACHE ||
{
PDEVICE_EXTENSION DeviceExtention = DeviceObject ->DeviceExtension;
PIO_STACK_LOCATION IrpCurStack = IoGetCurrentIrpStackLocation(Irp);
PIO_STACK_LOCATION IrpNextStack = IoGetNextIrpStackLocation(Irp);
char * buffer;    
char * pInData;  
PMDL myMdl;
ULONG i;
ULONG Length;
PREAD_CONTEXT newContext = ExAllocatePool( NonPagedPool , sizeof(READ_CONTEXT) );
newContext->orgMdlAddress = Irp->MdlAddress;
newContext->UserBuffer = Irp->UserBuffer;
RtlCopyMemory( IrpNextStack , IrpCurStack , sizeof( IO_STACK_LOCATION ) );
if( Irp ->MdlAddress )
pInData = (char *) MmGetSystemAddressForMdl( Irp->MdlAddress);
else
pInData = (char *) Irp->UserBuffer;
                Length = strlen( pInData );
                buffer = (char*)ExAllocatePool( NonPagedPool , IrpCurStack->Parameters.Write.Length );
                memset( buffer , 0 , IrpCurStack->Parameters.Write.Length );
RtlCopyMemory( buffer , pInData , Length );
encry(pInData ) ;//使用的单字节异或
if( Irp->MdlAddress )
{
myMdl = IoAllocateMdl( buffer , strlen(pInData) , FALSE , FALSE , Irp );
MmProbeAndLockPages( myMdl , Irp->RequestorMode , IoModifyAccess );
}
else
Irp->UserBuffer = (PVOID)buffer;
IoSetCompletionRoutine( Irp,SpyWriteCompleteRoutine,newContext,TRUE,TRUE,TRUE);
return IoCallDriver( DeviceExtention->NextDriverDeviceObject , Irp );
}
else
return SpyPassThrough( DeviceObject , Irp );

************writecomplete******************
PMDL tmp = Irp->MdlAddress;
char * buffer;
PREAD_CONTEXT newContext = (PREAD_CONTEXT)Context;
Irp->MdlAddress = newContext->orgMdlAddress;
if( tmp )
{
MmUnlockPages( tmp );
IoFreeMdl( tmp );
}
else
{
buffer = Irp->UserBuffer;
Irp->UserBuffer = newContext->UserBuffer;
ExFreePool( buffer );
}
ExFreePool( newContext );
if( Irp ->PendingReturned )
{
IoMarkIrpPending( Irp );
}
return Irp->IoStatus.Status;
游客

返回顶部