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.

67 lines
1.5 KiB

  1. /*
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. BeyondAtlantis.cpp
  5. Abstract:
  6. Fix disk space error caused by bad string passed to
  7. GetDiskFreeSpace. This root path is also bad on Win9x. No idea
  8. why that doesn't affect it.
  9. History:
  10. 05/31/2002 linstev Created
  11. */
  12. #include "precomp.h"
  13. IMPLEMENT_SHIM_BEGIN(BeyondAtlantis)
  14. #include "ShimHookMacro.h"
  15. APIHOOK_ENUM_BEGIN
  16. APIHOOK_ENUM_ENTRY(GetDiskFreeSpaceA)
  17. APIHOOK_ENUM_END
  18. BOOL
  19. APIHOOK(GetDiskFreeSpaceA)(
  20. LPCSTR lpRootPathName,
  21. LPDWORD lpSectorsPerCluster,
  22. LPDWORD lpBytesPerSector,
  23. LPDWORD lpNumberOfFreeClusters,
  24. LPDWORD lpTotalNumberOfClusters
  25. )
  26. {
  27. if (lpRootPathName && (strncmp(lpRootPathName, "tla", 3) == 0)) {
  28. CSTRING_TRY
  29. {
  30. CString csPath;
  31. csPath.GetCurrentDirectoryW();
  32. CString csDrive;
  33. csPath.SplitPath(&csDrive, NULL, NULL, NULL);
  34. return ORIGINAL_API(GetDiskFreeSpaceA)(csDrive.GetAnsi(), lpSectorsPerCluster,
  35. lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters);
  36. }
  37. CSTRING_CATCH
  38. {
  39. }
  40. }
  41. return ORIGINAL_API(GetDiskFreeSpaceA)(lpRootPathName, lpSectorsPerCluster,
  42. lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters);
  43. }
  44. HOOK_BEGIN
  45. APIHOOK_ENTRY(KERNEL32.DLL, GetDiskFreeSpaceA)
  46. HOOK_END
  47. IMPLEMENT_SHIM_END