Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

126 lines
2.9 KiB

/*++
Copyright (c) 2000 Microsoft Corporation
Module Name:
RemoveNoBufferingFlagFromCreateFile.cpp
Abstract:
This modified version of kernel32!CreateFile* prevents an app from using
the FILE_FLAG_NO_BUFFERING flag if the app doesn't handle it correctly.
Notes:
This is a general shim.
History:
02/16/2000 clupu Created
--*/
#include "precomp.h"
IMPLEMENT_SHIM_BEGIN(RemoveNoBufferingFlagFromCreateFile)
#include "ShimHookMacro.h"
APIHOOK_ENUM_BEGIN
APIHOOK_ENUM_ENTRY(CreateFileA)
APIHOOK_ENUM_ENTRY(CreateFileW)
APIHOOK_ENUM_END
/*++
Take out FILE_FLAG_NO_BUFFERING
--*/
HANDLE
APIHOOK(CreateFileA)(
LPSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
)
{
//
// Take out FILE_FLAG_NO_BUFFERING.
//
if (dwFlagsAndAttributes & FILE_FLAG_NO_BUFFERING) {
DPFN(
eDbgLevelInfo,
"[CreateFileA] called with FILE_FLAG_NO_BUFFERING set.\n");
}
dwFlagsAndAttributes &= ~FILE_FLAG_NO_BUFFERING;
return ORIGINAL_API(CreateFileA)(
lpFileName,
dwDesiredAccess,
dwShareMode,
lpSecurityAttributes,
dwCreationDisposition,
dwFlagsAndAttributes,
hTemplateFile);
}
/*++
Take out FILE_FLAG_NO_BUFFERING
--*/
HANDLE
APIHOOK(CreateFileW)(
LPWSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
)
{
//
// Take out FILE_FLAG_NO_BUFFERING.
//
if (dwFlagsAndAttributes & FILE_FLAG_NO_BUFFERING) {
DPFN(
eDbgLevelInfo,
"[CreateFileW] called with FILE_FLAG_NO_BUFFERING set.\n");
}
dwFlagsAndAttributes &= ~FILE_FLAG_NO_BUFFERING;
return ORIGINAL_API(CreateFileW)(
lpFileName,
dwDesiredAccess,
dwShareMode,
lpSecurityAttributes,
dwCreationDisposition,
dwFlagsAndAttributes,
hTemplateFile);
}
/*++
Register hooked functions
--*/
HOOK_BEGIN
APIHOOK_ENTRY(KERNEL32.DLL, CreateFileA)
APIHOOK_ENTRY(KERNEL32.DLL, CreateFileW)
HOOK_END
IMPLEMENT_SHIM_END