Я попытался модифицировать официальную демонстрацию драйвера Microsoft SYSVAD и добавить приведенный ниже код для создания таймера ядра Windows. Но когда драйвер установлен, генерируется ошибка страницы.
Код между двумя // ... by tomxue ...
добавлен мной.
#pragma code_seg("PAGE")
NTSTATUS
CreateMiniportWaveRTSYSVAD
(
_Out_ PUNKNOWN * Unknown,
_In_ REFCLSID,
_In_opt_ PUNKNOWN UnknownOuter,
_When_((PoolType & NonPagedPoolMustSucceed) != 0,
__drv_reportError("Must succeed pool allocations are forbidden. "
"Allocation failures cause a system crash"))
_In_ POOL_TYPE PoolType,
_In_ PUNKNOWN UnknownAdapter,
_In_opt_ PVOID DeviceContext,
_In_ PENDPOINT_MINIPAIR MiniportPair
)
{
UNREFERENCED_PARAMETER(UnknownOuter);
PAGED_CODE();
ASSERT(Unknown);
ASSERT(MiniportPair);
// ... by tomxue ...
KDPC stTimerDPC = { 0 };
KTIMER stTimerObj = { 0 };
LARGE_INTEGER stTimeCnt;
stTimeCnt.QuadPart = -10000000;
readPCMFileOnce = true;
if (readPCMFileOnce)
{
readPCMFileOnce = false;
DPF(D_TERSE, ("tomxue: PropertyHandlerProposedFormat2, (code 11.....................)"));
PCMBuffer = (BYTE*)ExAllocatePoolWithTag(NonPagedPoolNx, PCM_FILE_SIZE, PCM_TAG);
ReadVoiceFileToBuffer(PCMBuffer, PCM_FILE_SIZE);
KeInitializeTimer(&stTimerObj);
KeInitializeDpc(&stTimerDPC, OnTimer, NULL);
KeSetTimerEx(&stTimerObj, stTimeCnt, 1000, &stTimerDPC);
}
// ... by tomxue ...
CMiniportWaveRT *obj = new (PoolType, MINWAVERT_POOLTAG) CMiniportWaveRT
(
UnknownAdapter,
MiniportPair,
DeviceContext
);
Информация об ошибке, предоставленная Windbg.exe, является ниже. Не понимаю, почему так происходит. Функция CreateMiniportWaveRTSYSVAD () помечена как код для страницы через #pragma code_seg("PAGE")
, внутри нее я добавляю код для чтения файла и создания таймера. Почему при создании таймера выдается сообщение об ошибке страницы?
IRQL_NOT_LESS_OR_EQUAL (a)
An attempt was made to access a pageable (or completely invalid) address at an
interrupt request level (IRQL) that is too high. This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 0000000000000008, memory referenced
Arg2: 0000000000000002, IRQL
Arg3: 0000000000000000, bitfield :
bit 0 : value 0 = read operation, 1 = write operation
bit 3 : value 0 = not an execute operation, 1 = execute operation (only on chips which support this level of status)
Arg4: fffff8047a8a5a37, address which referenced memory
0: kd> kb
# RetAddr : Args to Child : Call Site
00 fffff804`7aaa9942 : 00000000`00000008 00000000`00000003 fffff181`ec9e19d0 fffff804`7a911b50 : nt!DbgBreakPointWithStatus
01 fffff804`7aaa9037 : 00000000`00000003 fffff181`ec9e19d0 fffff804`7a9d6a60 00000000`0000000a : nt!KiBugCheckDebugBreak+0x12
02 fffff804`7a9c24a7 : 00000000`00000001 ffffcb86`f0ec2da0 00000000`00000000 00000000`00004984 : nt!KeBugCheck2+0x947
03 fffff804`7a9d41e9 : 00000000`0000000a 00000000`00000008 00000000`00000002 00000000`00000000 : nt!KeBugCheckEx+0x107
04 fffff804`7a9d0529 : ffffcb86`f00b6040 fffff804`7a9d3c15 ffffcb86`f1000120 00000000`00000010 : nt!KiBugCheckDispatch+0x69
05 fffff804`7a8a5a37 : fffff181`ec9e22f8 ffffffff`ffffffff 00000000`00000000 fffff804`77049ed3 : nt!KiPageFault+0x469
06 fffff804`7a8f53d5 : ffffffff`ff676980 fffff804`00000000 00000000`00000000 00000000`00000300 : nt!KiInsertTimerTable+0xd7
07 fffff804`7708c60f : 00000000`00000001 ffffcb86`f90ebc70 ffffcb86`00000025 ffffcb86`f90ebdc0 : nt!KeSetTimerEx+0xb5
08 fffff804`7707a161 : fffff181`ec9e2500 fffff804`7704e890 00000000`00000000 ffffcb86`00000200 : tabletaudiosample!CreateMiniportWaveRTSYSVAD+0x1af [D:\workspace\4\Windows-driver-samples\audio\sysvad\EndpointsCommon\minwavert.cpp @ 122]
09 fffff804`77079b35 : ffffcb87`000809a0 ffffcb86`fb624720 fffff804`7704f8c0 00000000`00000000 : tabletaudiosample!CAdapterCommon::InstallSubdevice+0x201 [D:\workspace\4\Windows-driver-samples\audio\sysvad\common.cpp @ 1765]
0a fffff804`7706e682 : ffffcb87`000809a0 ffffcb86`fb624720 fffff804`7705ab80 00000000`00000000 : tabletaudiosample!CAdapterCommon::InstallEndpointFilters+0x405 [D:\workspace\4\Windows-driver-samples\audio\sysvad\common.cpp @ 2512]
0b fffff804`7706e4bb : ffffcb86`f90ebc70 ffffcb86`fb624720 ffffcb87`000809a0 fffff804`7705ab80 : tabletaudiosample!InstallEndpointRenderFilters+0xf2 [D:\workspace\4\Windows-driver-samples\audio\sysvad\adapter.cpp @ 722]
0c fffff804`7706f0e2 : ffffcb86`f90ebc70 ffffcb86`fb624720 ffffcb87`000809a0 00000000`00000200 : tabletaudiosample!InstallAllRenderFilters+0x8b [D:\workspace\4\Windows-driver-samples\audio\sysvad\adapter.cpp @ 853]
0d fffff804`92c4cb56 : ffffcb86`f90ebc70 ffffcb86`fb624720 ffffdb8f`7978c8b0 fffff804`7d951fd0 : tabletaudiosample!StartDevice+0x232 [D:\workspace\4\Windows-driver-samples\audio\sysvad\adapter.cpp @ 1074]
0e fffff804`92c49a5d : ffffdb8f`7978c8b0 ffffdb8f`6c95a190 00000000`00000000 ffffcb86`f007bc80 : portcls!PnpStartDevice+0x136
0f fffff804`7a89208f : 00000000`00000000 ffffcb86`fb635370 ffffcb86`f90ebc70 fffff804`7d951fd0 : portcls!EnqueuedIoWorkItemCallback+0x2d
10 fffff804`7a883945 : ffffcb86`f007bc80 ffffcb86`f00b6040 fffff804`7a891f90 00000000`0000000c : nt!IopProcessWorkItem+0xff
11 fffff804`7a91e135 : ffffcb86`f00b6040 00000000`00000080 ffffcb86`f00b50c0 000025ef`b59bbfff : nt!ExpWorkerThread+0x105
12 fffff804`7a9c99a8 : ffffbb80`847a0180 ffffcb86`f00b6040 fffff804`7a91e0e0 00000000`00000000 : nt!PspSystemThreadStartup+0x55
13 00000000`00000000 : fffff181`ec9e3000 fffff181`ec9dc000 00000000`00000000 00000000`00000000 : nt!KiStartSystemThread+0x28
Демо-код SYSVAD находится здесь: https://github.com/microsoft/Windows-driver-samples/tree/master/audio/sysvad
Исходный файл, который я изменил (содержит функцию CreateMiniportWaveRTSYSVAD) - minwavert. cpp: https://github.com/microsoft/Windows-driver-samples/blob/master/audio/sysvad/EndpointsCommon/minwavert.cpp