//a_head.h
#pragma once
#include<wdm.h>
#include <ntddk.h>
#include<stdio.h>
CHAR Password[50];
CHAR word[50];
BOOLEAN is_crypt;
BOOLEAN is_crypt_2=FALSE;
void cin_()
{
while (1)
{
scanf_s(word);
if (!strcmp(word, Password))
{
printf_s("密鑰正確,解密成功");
break;
}
else printf_s("密鑰錯誤");
}
}
//judge.c
#include<wdm.h>
#include<ntddk.h>
#include <stdio.h>
#include"a_head.h"
//過濾讀
NTSTATUS SfRead(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
{
PIO_STACK_LOCATION irp_stack;
NTSTATUS status;
PSFILTER_DEVICE_EXTENSION devExt;
PAGED_CODE();
ASSERT(!IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject));
ASSERT(IS_MY_DEVICE_OBJECT(DeviceObject));
devExt = (PSFILTER_DEVICE_EXTENSION)(DeviceObject->DeviceExtension);
if (Irp->Flags & (IRP_NOCACHE | IRP_PAGING_IO | IRP_SYNCHRONOUS_PAGING_IO))
{
irp_stack = IoGetCurrentIrpStackLocation(Irp);
is_crypt = IsMyCryptFile(irp_stack->FileObject);
if (is_crypt) //是我的加密檔案
{
//設定完成例程
IoCopyCurrentIrpStackLocationToNext(Irp);
cin_();
/*IoSetCompletionRoutine(Irp, SfReadCompletion, 0, TRUE, FALSE, FALSE);*/
//呼叫原來的驅動
return IoCallDriver(devExt->AttachedToDeviceObject, Irp);
}
}
//非加密檔案
IoSkipCurrentIrpStackLocation(Irp);
return IoCallDriver(devExt->AttachedToDeviceObject, Irp);
}
//encryption.c
#include<wdm.h>
#include <ntddk.h>
#include"a_head.h"
//加密
VOID jiami()
{
printf_s("請輸入密鑰");
scanf_s(Password);
is_crypt_2 = TRUE;
printf_s("加密成功");
}
//解密
VOID jiemi()
{
printf_s("請輸入密鑰");
while (1)
{
scanf_s(word);
if (!strcmp(word, Password))
{
printf_s("密鑰正確");
is_crypt_2 = FALSE;
printf_s("解密成功");
break;
}
else printf_s("密鑰錯誤");
}
}
為什么 PSFILTER_DEVICE_EXTENSION 是未定義識別符號?
怎么改這個才能跑?
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/101494.html
標籤:驅動開發/核心開發
上一篇:計算機考研作業系統
