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.

80 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. FireFighters.cpp
  5. Abstract:
  6. This game stores the filenames it calls CreateFile on in a block of memory and
  7. occasionally it gets the offsets wrong and it's always off by 9 bytes.
  8. History:
  9. 09/03/2000 maonis Created
  10. --*/
  11. #include "precomp.h"
  12. IMPLEMENT_SHIM_BEGIN(FireFighters)
  13. #include "ShimHookMacro.h"
  14. APIHOOK_ENUM_BEGIN
  15. APIHOOK_ENUM_ENTRY(CreateFileA)
  16. APIHOOK_ENUM_END
  17. /*++
  18. Remove write attributes for read-only devices.
  19. --*/
  20. HANDLE
  21. APIHOOK(CreateFileA)(
  22. LPSTR lpFileName,
  23. DWORD dwDesiredAccess,
  24. DWORD dwShareMode,
  25. LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  26. DWORD dwCreationDisposition,
  27. DWORD dwFlagsAndAttributes,
  28. HANDLE hTemplateFile
  29. )
  30. {
  31. // if the 1st char is not '.' or an alphabetical char, we add 9 bytes to the filename pointer.
  32. char chFirst = *lpFileName;
  33. if (!isalpha(chFirst) && chFirst != '.')
  34. {
  35. lpFileName += 9;
  36. DPFN(
  37. eDbgLevelError,
  38. "[CreateFileA] filename is now %s", lpFileName);
  39. }
  40. HANDLE hRet = ORIGINAL_API(CreateFileA)(
  41. lpFileName,
  42. dwDesiredAccess,
  43. dwShareMode,
  44. lpSecurityAttributes,
  45. dwCreationDisposition,
  46. dwFlagsAndAttributes,
  47. hTemplateFile);
  48. return hRet;
  49. }
  50. /*++
  51. Register hooked functions
  52. --*/
  53. HOOK_BEGIN
  54. APIHOOK_ENTRY(KERNEL32.DLL, CreateFileA)
  55. HOOK_END
  56. IMPLEMENT_SHIM_END