private static extern Win32Result CreateKey64( IntPtr hKey, string lpSubKey, string lpClass, RegOption dwOptions, /*ref SECURITY_DESCRIPTOR*/ IntPtr lpSecurityDescriptor, /*ref IntPtr*/ out IntPtr phkResult, out KeyDisposition lpdwDisposition);
static extern Int32 RegCreateKeyEx( UInt32 hKey, String lpSubKey, UInt32 Reserved, String lpClass, RegOption dwOptions, RegSAM samDesired, IntPtr lpSecurityAttributes, out UInt32 phkResult, out RegResult lpdwDisposition);
internal static extern IntPtr RegCreateKeyEx( IntPtr hKey, string subKey, IntPtr Reserved, string lpClass, RegOption dwOptions, RegSAM samDesired, ref SECURITY_ATTRIBUTES lpSecurityAttributes, out IntPtr hkResult, out RegResult lpdwDisposition);
public static extern int RegCreateKeyEx( [In] SafeRegistryHandle hKey, [In] string lpSubKey, [In, MarshalAs(UnmanagedType.U4)] int Reserved, [In] string lpClass, [In, MarshalAs(UnmanagedType.U4)] RegOption dwOptions, [In, MarshalAs(UnmanagedType.U4)] RegSAM samDesired, [In] IntPtr lpSecurityAttributes, [Out] out SafeRegistryHandle phkResult, [Out] out RegResult lpdwDisposition);
public static extern uint RegCreateKeyEx( uint hKey, string lpSubKey, int Reserved, string lpClass, RegOption dwOptions, RegSAM samDesired, SECURITY_ATTRIBUTES lpSecurityAttributes, out uint phkResult, IntPtr lpdwDisposition);
static extern int RegCreateKeyEx( IntPtr hKey, string lpSubKey, int Reserved, string lpClass, RegOption dwOptions, RegSAM samDesired, SecurityAttributes lpSecurityAttributes, out IntPtr phkResult, out RegResult lpdwDisposition);
static extern int RegCreateKeyEx( RegistryHive hKey, string lpSubKey, int Reserved, string lpClass, RegOption dwOptions, RegSAM samDesired, //UIntPtr lpSecurityAttributes, SECURITY_ATTRIBUTES lpSecurityAttributes, out UIntPtr phkResult, out RegResult lpdwDisposition);
/// <summary> /// Create a new subkey (or open an existing one) under another key. /// See http://msdn.microsoft.com/en-us/library/ee210761(v=vs.85).aspx /// </summary> /// <param name="hKey">Handle to an open key.</param> /// <param name="lpSubKey">Name of the new subkey.</param> /// <param name="lpClass">Name of the type of the new subkey.</param> /// <param name="dwOptions">Options for the creation.</param> /// <param name="lpSecurityDescriptor">Security descripter, may be NULL.</param> /// <param name="phkResult">The handle to the newly created key.</param> /// <param name="lpdwDisposition">The reuslting disposition.</param> /// <returns> /// <see cref="Win32Result" /> of the result. Win32Result.ERROR_SUCCESS indicates success. /// </returns> public static Win32Result CreateKey(IntPtr hKey, string lpSubKey, string lpClass, RegOption dwOptions, /*ref SECURITY_DESCRIPTOR*/ IntPtr lpSecurityDescriptor, /*ref IntPtr*/ out IntPtr phkResult, out KeyDisposition lpdwDisposition) { return(Is64BitProcess ? CreateKey64(hKey, lpSubKey, lpClass, dwOptions, lpSecurityDescriptor, out phkResult, out lpdwDisposition) : CreateKey32(hKey, lpSubKey, lpClass, dwOptions, lpSecurityDescriptor, out phkResult, out lpdwDisposition)); }
public static void RegistryCreateKey( IntPtr hKey, string lpSubKey, int reserved, string lpClass, RegOption dwOptions, RegSAM samDesired, SecurityAttributes lpSecurityAttributes, out IntPtr phkResult, out RegResult lpdwDisposition) { int error; if ((error = RegCreateKeyEx(hKey, lpSubKey, reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, out phkResult, out lpdwDisposition)) != 0) { throw new Win32Exception(error); } }
/// <summary> /// Creates a new subkey (or opens an existing one). /// </summary> /// <param name="name">The name of the subkey to create (or open).</param> /// <param name="options">Key creation options.</param> /// <returns>The newly created (or opened) key.</returns> public OffregKey CreateSubKey(string name, RegOption options = 0) { IntPtr newKeyPtr; KeyDisposition disposition; Win32Result result = OffregNative.CreateKey(_intPtr, name, null, options, IntPtr.Zero, out newKeyPtr, out disposition); if (result != Win32Result.ERROR_SUCCESS) { throw new Win32Exception((int)result); } // Return new key OffregKey newKey = new OffregKey(this, newKeyPtr, name); RefreshMetadata(); return(newKey); }
/// <summary> /// Open key will open a key from the VREG, or create it if not available. /// </summary> /// <param name="hKey"></param> /// <param name="subKey"></param> /// <param name="options"></param> /// <param name="sam"></param> /// <param name="phkResult"></param> /// <returns></returns> public NativeResultCode OpenKey(UIntPtr hKey, string subKey, RegOption options, RegAccessRights sam, out UIntPtr phkResult) { if (subKey == null) { phkResult = hKey; return NativeResultCode.Success; } uint handle; if (!TryParse(hKey, out handle)) { phkResult = UIntPtr.Zero; return NativeResultCode.InvalidHandle; } using (EngineCore.Engine.GetEngineProcessingSpace()) { uint hSubKey; var resultCode = _registry.OpenKey(handle, subKey, out hSubKey); EngineCore.Log.Debug(@"OpenKey({0}\\{1}) => {2}", hKey, subKey, resultCode == NativeResultCode.Success ? hSubKey.ToString() : resultCode.ToString()); phkResult = new UIntPtr(hSubKey); return resultCode; } }
/// <summary> /// Open key will open a key from the VREG, or create it if not available. /// </summary> /// <param name="hKey"></param> /// <param name="subKey"></param> /// <param name="options"></param> /// <param name="sam"></param> /// <param name="phkResult"></param> /// <returns></returns> public NativeResultCode OpenKey(UIntPtr hKey, string subKey, RegOption options, RegAccessRights sam, out UIntPtr phkResult) { if (subKey == null) { phkResult = hKey; return(NativeResultCode.Success); } uint handle; if (!TryParse(hKey, out handle)) { phkResult = UIntPtr.Zero; return(NativeResultCode.InvalidHandle); } using (EngineCore.Engine.GetEngineProcessingSpace()) { uint hSubKey; var resultCode = _registry.OpenKey(handle, subKey, out hSubKey); EngineCore.Log.Debug(@"OpenKey({0}\\{1}) => {2}", hKey, subKey, resultCode == NativeResultCode.Success ? hSubKey.ToString() : resultCode.ToString()); phkResult = new UIntPtr(hSubKey); return(resultCode); } }
//Read all options from internal data private List <RegOption[]> getOptions() { //Read unfiltered options from data List <RegOption> unfiltered = new List <RegOption>(); foreach (string[] data in InternalData.optionData) { RegOption opt = new RegOption(data); unfiltered.Add(opt); } //Read all the avalible types the options can be filtered to List <string> optionTypes = new List <string>(); foreach (RegOption opt in unfiltered) { string type = opt.optionType; //Check the option hasn't already been added if (!optionTypes.Contains(type)) { optionTypes.Add(type); } } //Sort the options into different arrays based on their type property List <RegOption[]> filtered = new List <RegOption[]>(); foreach (string str in optionTypes) { List <RegOption> filt = filterOptions(unfiltered, str); RegOption[] option = filt.ToArray(); filtered.Add(option); } return(filtered); }
//Set the selected option public void updateOption(string name) { RegOption opt = optionSearch(this.selectedLoc.options, name); selectedOpt = opt; }
/// <summary> /// Creates the specified registry key. If the key already exists, the function opens it. /// </summary> /// <param name="hKey">A handle to an open registry key.</param> /// <param name="lpSubKey"> /// The name of a subkey that this function opens or creates. The subkey specified must be /// a subkey of the key identified by the hKey parameter. The parameter cannot be NULL. /// </param> /// <param name="reserved">This parameter is reserved and must be zero.</param> /// <param name="lpClass">Ignored.</param> /// <param name="dwOptions">Ignored.</param> /// <param name="samDesired">Ignored.</param> /// <param name="lpSecurityAttributes">Ignored.</param> /// <param name="phkResult"> /// A pointer to a variable that receives a handle to the opened or created key. /// If the key is not one of the predefined registry keys, call the RegCloseKey function /// after you have finished using the handle. /// </param> /// <param name="lpdwDisposition"> /// A pointer to a variable that receives 0x00000001L if the key is created, /// or 0x00000002L if the key is opened. /// </param> /// <returns></returns> public NativeResultCode CreateKeyEx(UIntPtr hKey, string lpSubKey, int reserved, string lpClass, RegOption dwOptions, RegAccessRights samDesired, ref int lpSecurityAttributes, ref UIntPtr phkResult, ref RegCreationDisposition lpdwDisposition) { if (lpSubKey == null) { SafeWrite(RegCreationDisposition.NoKeyCreated, ref lpdwDisposition); return(NativeResultCode.RegBadKey); } uint handle; if (!TryParse(hKey, out handle)) { SafeWrite(RegCreationDisposition.NoKeyCreated, ref lpdwDisposition); return(NativeResultCode.InvalidHandle); } using (EngineCore.Engine.GetEngineProcessingSpace()) { uint phkResultHandle; RegCreationDisposition creationDisposition; var resultCode = _registry.CreateKey(handle, lpSubKey, out phkResultHandle, out creationDisposition); EngineCore.Log.Debug("CreateKey(HKey={0} NewSubKey={1}) => {2}", hKey, lpSubKey, resultCode == NativeResultCode.Success ? creationDisposition + " HKey=" + phkResultHandle : resultCode.ToString()); SafeWrite(creationDisposition, ref lpdwDisposition); phkResult = new UIntPtr(phkResultHandle); return(resultCode); } }
public static extern int RegCreateKeyEx( UIntPtr hKey, string lpSubKey, int Reserved, string lpClass, RegOption dwOptions, RegSAM samDesired, IntPtr lpSecurityAttributes, out IntPtr phkResult, out RegResult lpdwDisposition);
static extern int RegOpenKeyEx( RegistryHive hKey, [MarshalAs(UnmanagedType.VBByRefStr)] ref string subKey, RegOption dwOptions, RegSAM samDesired, out UIntPtr phkResult);
public static extern int RegOpenKeyEx( UIntPtr hKey, string subKey, RegOption ulOptions, RegSAM samDesired, out UIntPtr hkResult);
/// <summary> /// Creates a new subkey (or opens an existing one). /// </summary> /// <param name="name">The name of the subkey to create (or open).</param> /// <param name="options">Key creation options.</param> /// <returns>The newly created (or opened) key.</returns> public OffregKey CreateSubKey(string name, RegOption options = 0) { IntPtr newKeyPtr; KeyDisposition disposition; Win32Result result = OffregNative.CreateKey(_intPtr, name, null, options, IntPtr.Zero, out newKeyPtr, out disposition); if (result != Win32Result.ERROR_SUCCESS) throw new Win32Exception((int)result); // Return new key OffregKey newKey = new OffregKey(this, newKeyPtr, name); RefreshMetadata(); return newKey; }
/// <summary> /// Creates the specified registry key. If the key already exists, the function opens it. /// </summary> /// <param name="hKey">A handle to an open registry key.</param> /// <param name="lpSubKey"> /// The name of a subkey that this function opens or creates. The subkey specified must be /// a subkey of the key identified by the hKey parameter. The parameter cannot be NULL. /// </param> /// <param name="reserved">This parameter is reserved and must be zero.</param> /// <param name="lpClass">Ignored.</param> /// <param name="dwOptions">Ignored.</param> /// <param name="samDesired">Ignored.</param> /// <param name="lpSecurityAttributes">Ignored.</param> /// <param name="phkResult"> /// A pointer to a variable that receives a handle to the opened or created key. /// If the key is not one of the predefined registry keys, call the RegCloseKey function /// after you have finished using the handle. /// </param> /// <param name="lpdwDisposition"> /// A pointer to a variable that receives 0x00000001L if the key is created, /// or 0x00000002L if the key is opened. /// </param> /// <returns></returns> public NativeResultCode CreateKeyEx(UIntPtr hKey, string lpSubKey, int reserved, string lpClass, RegOption dwOptions, RegAccessRights samDesired, ref int lpSecurityAttributes, ref UIntPtr phkResult, ref RegCreationDisposition lpdwDisposition) { if (lpSubKey == null) { SafeWrite(RegCreationDisposition.NoKeyCreated, ref lpdwDisposition); return NativeResultCode.RegBadKey; } uint handle; if (!TryParse(hKey, out handle)) { SafeWrite(RegCreationDisposition.NoKeyCreated, ref lpdwDisposition); return NativeResultCode.InvalidHandle; } using (EngineCore.Engine.GetEngineProcessingSpace()) { uint phkResultHandle; RegCreationDisposition creationDisposition; var resultCode = _registry.CreateKey(handle, lpSubKey, out phkResultHandle, out creationDisposition); EngineCore.Log.Debug("CreateKey(HKey={0} NewSubKey={1}) => {2}", hKey, lpSubKey, resultCode == NativeResultCode.Success ? creationDisposition + " HKey=" + phkResultHandle : resultCode.ToString()); SafeWrite(creationDisposition, ref lpdwDisposition); phkResult = new UIntPtr(phkResultHandle); return resultCode; } }
/// <summary> /// Create a new subkey (or open an existing one) under another key. /// See http://msdn.microsoft.com/en-us/library/ee210761(v=vs.85).aspx /// </summary> /// <param name="hKey">Handle to an open key.</param> /// <param name="lpSubKey">Name of the new subkey.</param> /// <param name="lpClass">Name of the type of the new subkey.</param> /// <param name="dwOptions">Options for the creation.</param> /// <param name="lpSecurityDescriptor">Security descripter, may be NULL.</param> /// <param name="phkResult">The handle to the newly created key.</param> /// <param name="lpdwDisposition">The reuslting disposition.</param> /// <returns> /// <see cref="Win32Result" /> of the result. Win32Result.ERROR_SUCCESS indicates success. /// </returns> public static Win32Result CreateKey(IntPtr hKey, string lpSubKey, string lpClass, RegOption dwOptions, /*ref SECURITY_DESCRIPTOR*/ IntPtr lpSecurityDescriptor, /*ref IntPtr*/ out IntPtr phkResult, out KeyDisposition lpdwDisposition) { return Is64BitProcess ? CreateKey64(hKey, lpSubKey, lpClass, dwOptions, lpSecurityDescriptor, out phkResult, out lpdwDisposition) : CreateKey32(hKey, lpSubKey, lpClass, dwOptions, lpSecurityDescriptor, out phkResult, out lpdwDisposition); }