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.

129 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. GetVolumeInformationLie.cpp
  5. Abstract:
  6. This DLL Hooks GetVolumeInformationA/W and strips out specified FILE_SUPPORTS_XXX flags
  7. Notes:
  8. This is a general purpose shim.
  9. History:
  10. 05/28/2002 yoda - the force wisely have I used, hmmmmm, yes!
  11. --*/
  12. #include "precomp.h"
  13. IMPLEMENT_SHIM_BEGIN(GetVolumeInformationLie)
  14. #include "ShimHookMacro.h"
  15. APIHOOK_ENUM_BEGIN
  16. APIHOOK_ENUM_ENTRY(GetVolumeInformationA)
  17. APIHOOK_ENUM_ENTRY(GetVolumeInformationW)
  18. APIHOOK_ENUM_END
  19. DWORD GetRestricedFSFlags()
  20. {
  21. static DWORD s_dwRet = (DWORD)-1;
  22. if (s_dwRet == (DWORD)-1)
  23. {
  24. char* pszCmdLine = COMMAND_LINE;
  25. if (pszCmdLine && *pszCmdLine)
  26. {
  27. while (*pszCmdLine == ' ')
  28. {
  29. pszCmdLine++;
  30. }
  31. s_dwRet = (DWORD)atol(pszCmdLine);
  32. }
  33. else
  34. {
  35. s_dwRet = 0;
  36. }
  37. }
  38. return s_dwRet;
  39. }
  40. BOOL APIHOOK(GetVolumeInformationA)(LPCSTR lpRootPathName, LPSTR lpVolumeNameBuffer, DWORD nVolumeNameSize, LPDWORD lpVolumeSerialNumber,
  41. LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, LPSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize)
  42. {
  43. BOOL bRet;
  44. bRet = ORIGINAL_API(GetVolumeInformationA)(lpRootPathName,
  45. lpVolumeNameBuffer,
  46. nVolumeNameSize,
  47. lpVolumeSerialNumber,
  48. lpMaximumComponentLength,
  49. lpFileSystemFlags,
  50. lpFileSystemNameBuffer,
  51. nFileSystemNameSize);
  52. if (lpFileSystemFlags)
  53. {
  54. // mask off whatever flags we don't want the app to see
  55. *lpFileSystemFlags = (*lpFileSystemFlags & (~GetRestricedFSFlags()));
  56. }
  57. return bRet;
  58. }
  59. BOOL APIHOOK(GetVolumeInformationW)
  60. (LPCWSTR lpRootPathName, // root directory
  61. LPWSTR lpVolumeNameBuffer, // volume name buffer
  62. DWORD nVolumeNameSize, // length of name buffer
  63. LPDWORD lpVolumeSerialNumber, // volume serial number
  64. LPDWORD lpMaximumComponentLength, // maximum file name length
  65. LPDWORD lpFileSystemFlags, // file system options
  66. LPWSTR lpFileSystemNameBuffer, // file system name buffer
  67. DWORD nFileSystemNameSize // length of file system name buffer
  68. )
  69. {
  70. BOOL bRet;
  71. bRet = ORIGINAL_API(GetVolumeInformationW)(lpRootPathName,
  72. lpVolumeNameBuffer,
  73. nVolumeNameSize,
  74. lpVolumeSerialNumber,
  75. lpMaximumComponentLength,
  76. lpFileSystemFlags,
  77. lpFileSystemNameBuffer,
  78. nFileSystemNameSize);
  79. if (lpFileSystemFlags)
  80. {
  81. // mask off whatever flags we don't want the app to see
  82. *lpFileSystemFlags = (*lpFileSystemFlags & (~GetRestricedFSFlags()));
  83. }
  84. return bRet;
  85. }
  86. /*++
  87. Register hooked functions
  88. --*/
  89. HOOK_BEGIN
  90. APIHOOK_ENTRY(KERNEL32.DLL, GetVolumeInformationA)
  91. APIHOOK_ENTRY(KERNEL32.DLL, GetVolumeInformationW)
  92. HOOK_END
  93. IMPLEMENT_SHIM_END