| OLD | NEW |
| (Empty) |
| 1 // Copyright 2004-2009 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 // | |
| 16 // Other persons' registry hive manipulations. | |
| 17 // | |
| 18 #ifndef OMAHA_COMMON_REGISTRY_HIVE_H_ | |
| 19 #define OMAHA_COMMON_REGISTRY_HIVE_H_ | |
| 20 | |
| 21 #include <windows.h> | |
| 22 #include <atlstr.h> | |
| 23 | |
| 24 namespace omaha { | |
| 25 | |
| 26 #define kProfileKeyFormat \ | |
| 27 _T("HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\%s") | |
| 28 #define kProfilePathValue _T("ProfileImagePath") | |
| 29 #define kHiveName _T("Ntuser.dat") | |
| 30 | |
| 31 // !!! Warning !!! | |
| 32 // You MUST unload hive, or this hive becomes unavailable until PC is restarted | |
| 33 // This means the person cannot login. | |
| 34 class RegistryHive { | |
| 35 public: | |
| 36 RegistryHive(); | |
| 37 ~RegistryHive(); | |
| 38 | |
| 39 // Loads hive for requested SID. SID should be in format "S-X-X....." | |
| 40 // name is a name under which the hive will be added to the HKEY_USERS, | |
| 41 // you could use persons name here. This parameter should not have '\\' | |
| 42 // characters! | |
| 43 // It is not recommended to load more than one hive at once - LoadHive, | |
| 44 // manipulate hive, UnloadHive, and then work on the next one. | |
| 45 HRESULT LoadHive(TCHAR const * sid, TCHAR const *name); | |
| 46 // Loads hive for requested SID, but only if the SID is another user | |
| 47 // (since we don't need to do anything if the sid is ours) | |
| 48 HRESULT LoadHive(TCHAR const * sid); | |
| 49 // Unloads and saves loaded hive | |
| 50 HRESULT UnloadHive(); | |
| 51 // Does it recursively. The name should be relative to HKEY_CURRENT_USER. | |
| 52 HRESULT DeleteUserKey(TCHAR const * key_name); | |
| 53 // Expands key name for hive: | |
| 54 // "Software\Google" => "HKEY_USERS\[hive_name_]\Software\Google" | |
| 55 void ExpandKeyName(CString * str); | |
| 56 | |
| 57 private: | |
| 58 CString hive_name_; | |
| 59 HKEY hive_holding_key_; | |
| 60 }; | |
| 61 | |
| 62 // Function pointer | |
| 63 // Return non-zero to abort the enumeration | |
| 64 typedef int ProcessUserRegistryFunc(const TCHAR* user_sid, | |
| 65 const TCHAR* user_reg_key, | |
| 66 LONG_PTR param); | |
| 67 | |
| 68 // Enumerate all user registries | |
| 69 void EnumerateAllUserRegistries(ProcessUserRegistryFunc* handler, | |
| 70 LONG_PTR param); | |
| 71 | |
| 72 } // namespace omaha | |
| 73 | |
| 74 #endif // OMAHA_COMMON_REGISTRY_HIVE_H_ | |
| OLD | NEW |