1

私はWindowsデバイスドライバーを書いています。ドライバーはとてもシンプルです。派手なことは何もしません。Windows ドライバーの開発に慣れようとしているだけです。

私のドライバーではNonPagedPool、からメモリを割り当てていますが、非常に奇妙なエラーがあります。

ここに私のコードセグメントがあります:

pMyNode = (PMY_NODE)ExAllocatePoolWithTag(NonPagedPool, sizeof(MY_NODE), 'TEST');
if (pMyNode == NULL){
    DbgPrint("Not Enough Memory\n");
}
else{
    // Do Some Stuffs and free memory
}

対応するアセンブリ コード (IDA Pro 逆アセンブラーから) は次のとおりです。

call ds:__imp__ExAllocatePoolWithTag
mov [ebp+pMyNode], eax
cmp [ebp+pMyNode], 0
jnz  SOME_OFFSET
call _DbgPrint

SOME_OFFSET:
.........
.........

このコード セグメントは、 のハンドラ関数に入りPsSetCreateProcessNotifyRoutineます。したがって、新しいプロセスが作成されるたびに、このコード セグメントが実行されます。ドライバーを長時間実行すると、BSoD突然エラーが発生します。そして、フォルト命令として命令をWinDbgトリガーします。mov [ebp+pMyNode], eaxこの行は、実際にの戻り値ExAllocatePoolWithTagpMyNodeポインターに代入します。これが誤った命令である可能性がある理由がわかりません。

BSoD画面のエラー メッセージは ですA Device Driver Has PoolWinDbg以下のログを確認してください。

DRIVER_CORRUPTED_EXPOOL (c5)
An attempt was made to access a pageable (or completely invalid) address at an
interrupt request level (IRQL) that is too high.  This is
caused by drivers that have corrupted the system pool.  Run the driver
verifier against any new (or suspect) drivers, and if that doesn't turn up
the culprit, then use gflags to enable special pool.
Arguments:
Arg1: e252a000, memory referenced
Arg2: 0000000d, IRQL
Arg3: 00000001, value 0 = read operation, 1 = write operation
Arg4: 8054baee, address which referenced memory

どんな助けもかなりのものです。

4

0 に答える 0