Source code of Windows XP (NT5)
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.8 KiB

  1. //
  2. // REGFKEY.C
  3. //
  4. // Copyright (C) Microsoft Corporation, 1995
  5. //
  6. // Implementation of RegFlushKey and supporting functions.
  7. //
  8. #include "pch.h"
  9. // Magic HKEY used by Setup to disable disk I/O for the duration of this
  10. // Windows session (you must restart to re-enable disk I/O). This is done
  11. // just before the new SYSTEM.DAT and USER.DAT are copied to their final
  12. // destination.
  13. #define HKEY_DISABLE_REG (HKEY) 0x484A574D
  14. // Magic HKEY used by CONFIGMG to force a flush of the registry before we've
  15. // received our normal post-critical init call.
  16. #define HKEY_CRITICAL_FLUSH (HKEY) 0x5350574D
  17. //
  18. // VMMRegFlushKey
  19. //
  20. LONG
  21. REGAPI
  22. VMMRegFlushKey(
  23. HKEY hKey
  24. )
  25. {
  26. int ErrorCode;
  27. if (!RgLockRegistry())
  28. return ERROR_LOCK_FAILED;
  29. #ifdef VXD
  30. // Set the g_RgFileAccessDisabled flag so that all create or open file
  31. // calls will be failed. The backing stores for our files are about to
  32. // be changed, so there's no file for us to go to.
  33. if (hKey == HKEY_DISABLE_REG) {
  34. g_RgFileAccessDisabled = TRUE;
  35. ErrorCode = ERROR_SUCCESS;
  36. goto ReturnErrorCode;
  37. }
  38. // Set the g_RgPostCriticalInit flag so that all I/O calls will go to disk
  39. // instead of the XMS cache. The XMS cache will be freed when/if the
  40. // normal post critical init routine is called, but we should only be
  41. // getting this call when we're about to die, so it doesn't really matter.
  42. if (hKey == HKEY_CRITICAL_FLUSH) {
  43. g_RgPostCriticalInit = TRUE;
  44. hKey = HKEY_LOCAL_MACHINE;
  45. }
  46. #endif
  47. if ((ErrorCode = RgValidateAndConvertKeyHandle(&hKey)) == ERROR_SUCCESS)
  48. ErrorCode = RgFlushFileInfo(hKey-> lpFileInfo);
  49. #ifdef VXD
  50. ReturnErrorCode:
  51. #endif
  52. RgUnlockRegistry();
  53. return ErrorCode;
  54. }