Bug 847468 - Poison NtWriteFileGather. r=BenWa.

--HG--
extra : rebase_source : 23ad1eec802f547504e08aa5dc8e7d90b2bf0708
This commit is contained in:
Rafael Ávila de Espíndola 2013-03-07 10:02:33 -05:00
parent ca0a572643
commit c8d22986fb
2 changed files with 21 additions and 0 deletions

View File

@ -117,6 +117,8 @@ int main()
#endif
TestHook("user32.dll", "TrackPopupMenu") &&
TestHook("ntdll.dll", "NtFlushBuffersFile") &&
TestHook("ntdll.dll", "NtWriteFile") &&
TestHook("ntdll.dll", "NtWriteFileGather") &&
TestHook("ntdll.dll", "LdrLoadDll")) {
printf("TEST-PASS | WindowsDllInterceptor | all checks passed\n");
return 0;

View File

@ -51,6 +51,24 @@ patched_WriteFile(HANDLE aFile, HANDLE aEvent, PIO_APC_ROUTINE aApc,
aBuffer, aLength, aOffset, aKey);
}
typedef NTSTATUS (WINAPI* WriteFileGather_fn)(HANDLE, HANDLE, PIO_APC_ROUTINE,
void*, PIO_STATUS_BLOCK,
FILE_SEGMENT_ELEMENT*,
ULONG, PLARGE_INTEGER, PULONG);
WriteFileGather_fn gOriginalWriteFileGather;
static NTSTATUS WINAPI
patched_WriteFileGather(HANDLE aFile, HANDLE aEvent, PIO_APC_ROUTINE aApc,
void* aApcUser, PIO_STATUS_BLOCK aIoStatus,
FILE_SEGMENT_ELEMENT* aSegments, ULONG aLength,
PLARGE_INTEGER aOffset, PULONG aKey)
{
AbortOnBadWrite(aFile);
return gOriginalWriteFileGather(aFile, aEvent, aApc, aApcUser, aIoStatus,
aSegments, aLength, aOffset, aKey);
}
void AbortOnBadWrite(HANDLE aFile)
{
if (!PoisonWriteEnabled())
@ -77,6 +95,7 @@ void PoisonWrite() {
sNtDllInterceptor.Init("ntdll.dll");
sNtDllInterceptor.AddHook("NtFlushBuffersFile", reinterpret_cast<intptr_t>(patched_FlushBuffersFile), reinterpret_cast<void**>(&gOriginalFlushBuffersFile));
sNtDllInterceptor.AddHook("NtWriteFile", reinterpret_cast<intptr_t>(patched_WriteFile), reinterpret_cast<void**>(&gOriginalWriteFile));
sNtDllInterceptor.AddHook("NtWriteFileGather", reinterpret_cast<intptr_t>(patched_WriteFileGather), reinterpret_cast<void**>(&gOriginalWriteFileGather));
}
}