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.

145 lines
5.9 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. Localreg.h
  5. Abstract:
  6. This file is used to make small changes to the Winreg Base entry
  7. points so that they compile as local or remote functions.
  8. Author:
  9. David J. Gilman (davegi) 26-Aug-1992
  10. Notes:
  11. The mapping from BaseRegNotifyChangeKeyValue to
  12. LocalBaseRegNotifyChangeKeyValue is missing because in the
  13. local case the call to NJt is made by the client.
  14. --*/
  15. #if defined( LOCAL )
  16. //
  17. // Change the 'server' enrty point names for the local functions.
  18. //
  19. //
  20. // Base functions.
  21. //
  22. #define BaseRegDeleteKey LocalBaseRegDeleteKey
  23. #define BaseRegDeleteValue LocalBaseRegDeleteValue
  24. #define BaseRegEnumKey LocalBaseRegEnumKey
  25. #define BaseRegEnumValue LocalBaseRegEnumValue
  26. #define BaseRegCloseKey LocalBaseRegCloseKey
  27. #define BaseRegCreateKey LocalBaseRegCreateKey
  28. #define BaseRegFlushKey LocalBaseRegFlushKey
  29. #define BaseRegOpenKey LocalBaseRegOpenKey
  30. #define BaseRegLoadKey LocalBaseRegLoadKey
  31. #define BaseRegUnLoadKey LocalBaseRegUnLoadKey
  32. #define BaseRegReplaceKey LocalBaseRegReplaceKey
  33. #define BaseRegQueryInfoKey LocalBaseRegQueryInfoKey
  34. #define BaseRegQueryValue LocalBaseRegQueryValue
  35. #define BaseRegGetKeySecurity LocalBaseRegGetKeySecurity
  36. #define BaseRegSetKeySecurity LocalBaseRegSetKeySecurity
  37. #define BaseRegRestoreKey LocalBaseRegRestoreKey
  38. #define BaseRegSaveKey LocalBaseRegSaveKey
  39. #define BaseRegSaveKeyEx LocalBaseRegSaveKeyEx
  40. #define BaseRegSetValue LocalBaseRegSetValue
  41. #define BaseRegQueryMultipleValues LocalBaseRegQueryMultipleValues
  42. #define BaseRegQueryMultipleValues2 LocalBaseRegQueryMultipleValues2
  43. #define BaseRegGetVersion LocalBaseRegGetVersion
  44. //
  45. // Predefined handle functions.
  46. //
  47. #define OpenClassesRoot LocalOpenClassesRoot
  48. #define OpenCurrentUser LocalOpenCurrentUser
  49. #define OpenLocalMachine LocalOpenLocalMachine
  50. #define OpenUsers LocalOpenUsers
  51. #define OpenPerformanceData LocalOpenPerformanceData
  52. #define OpenPerformanceText LocalOpenPerformanceText
  53. #define OpenPerformanceNlsText LocalOpenPerformanceNlsText
  54. #define OpenCurrentConfig LocalOpenCurrentConfig
  55. #define OpenDynData LocalOpenDynData
  56. //
  57. // Initialization and cleanup functions.
  58. //
  59. #define InitializeRegCreateKey LocalInitializeRegCreateKey
  60. #define CleanupRegCreateKey LocalCleanupRegCreateKey
  61. //
  62. // No RPC Impersonation needed in the local case.
  63. //
  64. #define RPC_IMPERSONATE_CLIENT( Handle )
  65. #define RPC_REVERT_TO_SELF()
  66. #define REGSEC_CHECK_HANDLE( Handle ) ( 0 )
  67. #define REGSEC_FLAG_HANDLE( Handle, Flag ) ( Handle )
  68. #define REGSEC_TEST_HANDLE( Handle, Flag ) ( Handle )
  69. #define REGSEC_CLEAR_HANDLE( Handle ) ( Handle )
  70. #define REGSEC_CHECK_REMOTE( Key ) ( 1 )
  71. #define REGSEC_CHECK_PATH( Key, Path ) ( 1 )
  72. #define REGSEC_CHECK_PERF( Key ) ( 1 )
  73. #else
  74. #include <Rpcasync.h>
  75. //
  76. // Impersonate the client.
  77. //
  78. #define RPC_IMPERSONATE_CLIENT( Handle ) \
  79. { \
  80. RPC_STATUS _rpcstatus; \
  81. RPC_CALL_ATTRIBUTES CallAttributes; \
  82. memset(&CallAttributes, 0, sizeof(CallAttributes)); \
  83. CallAttributes.Version = RPC_CALL_ATTRIBUTES_VERSION; \
  84. _rpcstatus = RpcServerInqCallAttributesW(0, &CallAttributes); \
  85. if(_rpcstatus == RPC_S_BINDING_HAS_NO_AUTH ) { \
  86. } else if (_rpcstatus == RPC_S_OK) { \
  87. if( CallAttributes.AuthenticationLevel < RPC_C_AUTHN_LEVEL_PKT_PRIVACY ) { \
  88. RpcRaiseException(RPC_S_ACCESS_DENIED); \
  89. } \
  90. } else { \
  91. RpcRaiseException(_rpcstatus); \
  92. } \
  93. _rpcstatus = RpcImpersonateClient( NULL ); \
  94. if (_rpcstatus != ERROR_SUCCESS) { \
  95. RpcRaiseException(_rpcstatus); \
  96. } \
  97. }
  98. #define RPC_REVERT_TO_SELF() { RPC_STATUS _rpcstatus = RpcRevertToSelf(); }
  99. #define CHECK_MACHINE_PATHS 0x00000001
  100. #define REGSEC_CHECK_HANDLE( Handle ) ((LONG)(ULONG_PTR) (Handle) & CHECK_MACHINE_PATHS)
  101. #define REGSEC_FLAG_HANDLE( Handle, Flag ) LongToHandle(HandleToLong(Handle) | Flag)
  102. #define REGSEC_TEST_HANDLE( Handle, Flag ) ((LONG)(ULONG_PTR) (Handle) & Flag )
  103. #define REGSEC_CLEAR_HANDLE( Handle ) LongToHandle(HandleToLong(Handle) & ~(CHECK_MACHINE_PATHS))
  104. #define REGSEC_CHECK_REMOTE( Key ) ( RegSecCheckRemoteAccess( Key ) )
  105. #define REGSEC_CHECK_PATH( Key, Path ) ( RegSecCheckPath( Key, Path ) )
  106. #define REGSEC_CHECK_PERF( Key ) ( RegSecCheckRemotePerfAccess( Key ) )
  107. #endif // LOCAL
  108. NTSTATUS RelinkMachineKey(
  109. LPWSTR lpSubDirName,
  110. PUNICODE_STRING lpSubKey,
  111. HKEY hKey );