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.

273 lines
6.3 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. wow64reg.c
  5. Abstract:
  6. This module define some APIs a client can use to access the registry in the mix mode.
  7. The possible scenario is
  8. 1. 32 bit Apps need to access 64 bit registry key.
  9. 2. 64 bit Apps need to access 32-bit registry key.
  10. 3. The actual redirected path from a given path.
  11. Author:
  12. ATM Shafiqul Khalid (askhalid) 10-Nov-1999
  13. Revision History:
  14. --*/
  15. #ifndef __WOW64REG_H__
  16. #define __WOW64REG_H__
  17. //#define LOG_REGISTRY //define this to turn on logging for registry
  18. #define WOW64_REGISTRY_SETUP_KEY_NAME L"\\REGISTRY\\MACHINE\\SOFTWARE\\Microsoft\\WOW64\\ISN Nodes"
  19. #define WOW64_REGISTRY_SETUP_KEY_NAME_REL_PARENT L"SOFTWARE\\Microsoft\\WOW64"
  20. #define WOW64_REGISTRY_SETUP_KEY_NAME_REL L"SOFTWARE\\Microsoft\\WOW64\\ISN Nodes"
  21. #define MACHINE_CLASSES_ROOT L"\\REGISTRY\\MACHINE\\SOFTWARE\\Classes"
  22. #define WOW64_REGISTRY_ISN_NODE_NAME L"ISN Nodes"
  23. #define WOW64_RUNONCE_SUBSTR L"\\REGISTRY\\MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run"
  24. #define WOW64_32BIT_MACHINE_CLASSES_ROOT L"\\REGISTRY\\MACHINE\\SOFTWARE\\Classes\\Wow6432Node"
  25. #define WOW64_SYSTEM_DIRECTORY_NAME L"SysWow64"
  26. #define NODE_NAME_32BIT L"Wow6432Node"
  27. #define NODE_NAME_32BIT_LEN ((sizeof (NODE_NAME_32BIT)-sizeof(UNICODE_NULL))/sizeof (WCHAR))
  28. #define WOW6432_VALUE_KEY_NAME L"Wow6432KeyValue"
  29. #define ISN_NODE_MAX_LEN 256
  30. #define ISN_NODE_MAX_NUM 30
  31. #define EVENT_WOW64_RUNNING32BIT_APPLICATION 1108
  32. #define SHRED_MEMORY_NAME L"Wow64svc Shared Memory" // different process can open this for possible interaction
  33. #define WOW64_SVC_REFLECTOR_EVENT_NAME L"Wow64svc reflector Event" // different process can use this to ping wow64svc
  34. #define WOW64_SVC_REFLECTOR_MUTEX_NAME L"Wow64svc reflector Mutex" // different process can use this to synchronize
  35. #define TAG_KEY_ATTRIBUTE_32BIT_WRITE 0x00000001 //written by 32bit apps
  36. #define TAG_KEY_ATTRIBUTE_REFLECTOR_WRITE 0x00000002 //written by reflector
  37. #define WOW64_REFLECTOR_DISABLE 0x00000001
  38. #define WOW64_REFLECTOR_ENABLE 0x00000002
  39. typedef struct _IsnNode {
  40. WCHAR NodeName [ISN_NODE_MAX_LEN];
  41. WCHAR NodeValue [ISN_NODE_MAX_LEN];
  42. DWORD Flag;
  43. HKEY hKey;
  44. }ISN_NODE_TYPE;
  45. typedef enum _WOW6432VALUEKEY_TYPE {
  46. None=0,
  47. Copy, // it's a copy
  48. Reflected, // if it's not a cpoy then it has been reflected on the otherside
  49. NonMergeable // This key should not be merged.
  50. }WOW6432_VALUEKEY_TYPE;
  51. typedef struct _WOW6432VALUEKEY {
  52. WOW6432_VALUEKEY_TYPE ValueType; //define if it's a copy from the other side
  53. SIZE_T Reserve;
  54. ULONGLONG TimeStamp; // time() stamp to track time when it was copied etc.
  55. }WOW6432_VALUEKEY;
  56. typedef WCHAR NODETYPE[ISN_NODE_MAX_LEN];
  57. #define REG_OPTION_OPEN_32BITKEY KEY_WOW64_32KEY
  58. #define REG_OPTION_OPEN_64BITKEY KEY_WOW64_64KEY
  59. #define KEY_WOW64_OPEN KEY_WOW64_64KEY
  60. // This bit is set to make
  61. // special meaning to Wow64
  62. #ifndef KEY_WOW64_RES
  63. #define KEY_WOW64_RES (KEY_WOW64_64KEY | KEY_WOW64_32KEY)
  64. #endif
  65. #define WOW64_MAX_PATH 2048
  66. #ifdef __cplusplus
  67. extern "C" {
  68. #endif
  69. LONG
  70. Wow64RegOpenKeyEx(
  71. IN HKEY hKey, // handle to open key
  72. IN LPCWSTR lpSubKey, // address of name of subkey to open
  73. IN DWORD ulOptions, // reserved current implementation is zero means default.
  74. IN REGSAM samDesired, // security access mask
  75. OUT PHKEY phkResult // address of handle to open key
  76. );
  77. LONG
  78. Wow64RegCreateKeyEx(
  79. HKEY hKey, // handle to an open key
  80. LPCWSTR lpSubKey, // address of subkey name
  81. DWORD Reserved, // reserved
  82. LPWSTR lpClass, // address of class string
  83. DWORD dwOptions, // special options flag
  84. REGSAM samDesired, // desired security access
  85. LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  86. // address of key security structure
  87. PHKEY phkResult, // address of buffer for opened handle
  88. LPDWORD lpdwDisposition // address of disposition value buffer
  89. );
  90. BOOL
  91. HandleToKeyName (
  92. IN HANDLE Key,
  93. IN PWCHAR KeyName,
  94. IN OUT DWORD * dwSize
  95. );
  96. BOOL
  97. CreateNode (
  98. PWCHAR Path
  99. );
  100. HKEY
  101. OpenNode (
  102. IN PWCHAR NodeName
  103. );
  104. BOOL
  105. CheckAndCreateNode (
  106. IN PWCHAR Name
  107. );
  108. LONG
  109. RegReflectKey (
  110. HKEY hKey, // handle to open key
  111. LPCTSTR lpSubKey, // subkey name
  112. DWORD dwOption // option flag
  113. );
  114. BOOL
  115. Map64bitTo32bitKeyName (
  116. IN PWCHAR Name64Key,
  117. OUT PWCHAR Name32Key
  118. );
  119. BOOL
  120. Map32bitTo64bitKeyName (
  121. IN PWCHAR Name32Key,
  122. OUT PWCHAR Name64Key
  123. );
  124. // API called from wow64services
  125. BOOL
  126. InitReflector ();
  127. BOOL
  128. StartReflector ();
  129. BOOL
  130. StopReflector ();
  131. BOOL
  132. Wow64RegNotifyLoadHive (
  133. PWCHAR Name
  134. );
  135. BOOL
  136. Wow64RegNotifyUnloadHive (
  137. PWCHAR Name
  138. );
  139. BOOL
  140. Wow64RegNotifyLoadHiveByHandle (
  141. HKEY hKey
  142. );
  143. BOOL
  144. Wow64RegNotifyUnloadHiveByHandle (
  145. HKEY hKey
  146. );
  147. BOOL
  148. Wow64RegNotifyLoadHiveUserSid (
  149. PWCHAR lpwUserSid
  150. );
  151. BOOL
  152. Wow64RegNotifyUnloadHiveUserSid (
  153. PWCHAR lpwUserSid
  154. );
  155. //Called from advapi32 to set a key dirty or need cleanup.
  156. BOOL
  157. Wow64RegSetKeyDirty (
  158. HANDLE hKeyBase
  159. );
  160. //Called from advapi32 to sync a key in case that need synchronization.
  161. BOOL
  162. Wow64RegCloseKey (
  163. HANDLE hKeyBase
  164. );
  165. //Called from advapi32 to delete a key on the mirror side.
  166. BOOL
  167. Wow64RegDeleteKey (
  168. HKEY hBase,
  169. WCHAR *SubKey
  170. );
  171. //Called from advapi to get an handle to remapped key that is on reflection list.
  172. HKEY
  173. Wow64OpenRemappedKeyOnReflection (
  174. HKEY hKey
  175. );
  176. void
  177. InitializeWow64OnBoot(
  178. DWORD dwFlag
  179. );
  180. BOOL
  181. Wow64InitRegistry(
  182. DWORD dwFlag
  183. );
  184. BOOL
  185. Wow64CloseRegistry (
  186. DWORD dwFlag
  187. );
  188. BOOL
  189. QueryKeyTag (
  190. HKEY hBase,
  191. DWORD *dwAttribute
  192. );
  193. BOOL
  194. Wow64SyncCLSID();
  195. BOOL
  196. IsExemptRedirectedKey (
  197. IN PWCHAR SrcKey,
  198. OUT PWCHAR DestKey
  199. );
  200. BOOL
  201. IsOnReflectionByHandle (
  202. HKEY KeyHandle
  203. );
  204. #ifdef __cplusplus
  205. }
  206. #endif
  207. #endif //__WOW64REG_H__