/*
  winreg interface definition
*/

/* import "lsa.idl", "initshutdown.idl", "security.idl";*/

[ 
  uuid("338cd001-2244-31f1-aaaa-900038001003"),
  version(1.0),
  endpoint("ncacn_np:[\\pipe\\winreg]","ncacn_ip_tcp:","ncalrpc:"),
  pointer_default(unique),
  pointer_default_top(unique),
  helpstring("Remote Registry Service")
] interface winreg
{
	declare bitmap security_secinfo;

	typedef [bitmap32bit] bitmap {
		KEY_QUERY_VALUE 		= 0x00001,
		KEY_SET_VALUE 			= 0x00002,
		KEY_CREATE_SUB_KEY 		= 0x00004,
		KEY_ENUMERATE_SUB_KEYS 	= 0x00008,
		KEY_NOTIFY 				= 0x00010,
		KEY_CREATE_LINK 		= 0x00020,
		KEY_WOW64_64KEY 		= 0x00100,
		KEY_WOW64_32KEY 		= 0x00200
	} winreg_AccessMask;

	typedef [public,v1_enum] enum {
		REG_NONE                       = 0,
		REG_SZ                         = 1,
		REG_EXPAND_SZ                  = 2,
		REG_BINARY                     = 3,
		REG_DWORD                      = 4,
		REG_DWORD_BIG_ENDIAN           = 5,
		REG_LINK                       = 6,
		REG_MULTI_SZ                   = 7,
		REG_RESOURCE_LIST              = 8,
		REG_FULL_RESOURCE_DESCRIPTOR   = 9,
		REG_RESOURCE_REQUIREMENTS_LIST = 10,
		REG_QWORD                      = 11
	} winreg_Type;

	typedef [public,noejs] struct {
		[value(strlen_m_term(name)*2)] uint16 name_len;
		[value(strlen_m_term(name)*2)] uint16 name_size;
		[string,charset(UTF16)] uint16 *name;
	} winreg_String;

	/******************/
	/* Function: 0x00 */
	WERROR winreg_OpenHKCR(
		[in]      uint16 *system_name,
		[in]      winreg_AccessMask access_mask,
		[out,ref] policy_handle *handle
	);

	/******************/
	/* Function: 0x01 */
	WERROR winreg_OpenHKCU(
	        [in]      uint16 *system_name,
		[in]      winreg_AccessMask access_mask,
		[out,ref] policy_handle *handle
	);

	/******************/
	/* Function: 0x02 */
	[public] WERROR winreg_OpenHKLM(
		[in]      uint16 *system_name,
		[in]      winreg_AccessMask access_mask,
		[out,ref] policy_handle *handle
	);

	/******************/
	/* Function: 0x03 */
	WERROR winreg_OpenHKPD(
		[in]      uint16 *system_name,
		[in]      winreg_AccessMask access_mask,
		[out,ref] policy_handle *handle
	);

	/******************/
	/* Function: 0x04 */
	WERROR winreg_OpenHKU(
		[in]      uint16 *system_name,
		[in]      winreg_AccessMask access_mask,
		[out,ref] policy_handle *handle
	);

	/******************/
	/* Function: 0x05 */
	[public] WERROR winreg_CloseKey(
		[in,out,ref] policy_handle *handle
	);

	/******************/
	/* Function: 0x06 */

	typedef struct {
		[size_is(size),length_is(len)] uint8 *data;
		uint32 size;
		uint32 len;
	} KeySecurityData;

	typedef struct {
		uint32 length;
		KeySecurityData sd;
		boolean8  inherit;
	} winreg_SecBuf;

	typedef [v1_enum] enum {
		REG_ACTION_NONE         = 0, /* used by caller */
		REG_CREATED_NEW_KEY     = 1,
		REG_OPENED_EXISTING_KEY = 2
	} winreg_CreateAction;

	[public] WERROR winreg_CreateKey(
		[in,ref] policy_handle *handle,
		[in] winreg_String name,
		[in] winreg_String keyclass,
		[in] uint32 options,
		[in] winreg_AccessMask access_mask,
		[in,unique] winreg_SecBuf *secdesc,
		[out,ref] policy_handle *new_handle,
		[in,out,unique] winreg_CreateAction *action_taken
	);

	/******************/
	/* Function: 0x07 */
	[public] WERROR winreg_DeleteKey(
		[in,ref] policy_handle *handle,
		[in]	 winreg_String key
	);

	/******************/
	/* Function: 0x08 */
	WERROR winreg_DeleteValue(
		[in,ref] policy_handle *handle,
		[in]	 winreg_String value
	);

	typedef struct {
		[value(strlen_m_term(name)*2)] uint16 length; 
		/* size cannot be auto-set by value() as it is the
		   amount of space the server is allowed to use for this
		   string in the reply, not its current size */
		uint16 size;
		[size_is(size/2),length_is(length/2),charset(UTF16)] uint16 *name;
	} winreg_StringBuf;

	/******************/
	/* Function: 0x09 */
	[public] WERROR winreg_EnumKey(
		[in,ref]        policy_handle    *handle,
		[in]            uint32           enum_index,
		[in,out,ref]    winreg_StringBuf *name,
		[in,out,unique] winreg_StringBuf *keyclass,
		[in,out,unique] NTTIME           *last_changed_time
	);

	/******************/
	/* Function: 0x0a */

	[public] WERROR winreg_EnumValue(
		[in,ref]        policy_handle *handle,
		[in]            uint32 enum_index,
		[in,out,ref]    winreg_StringBuf *name,
		[in,out,unique] winreg_Type *type,
		[in,out,unique,size_is(*size),length_is(*length)] uint8 *value,
		[in,out,unique] uint32 *size,
		[in,out,unique] uint32 *length
	);

	/******************/
	/* Function: 0x0b */
	[public] WERROR winreg_FlushKey(
		[in,ref] policy_handle *handle
	);

	/******************/
	/* Function: 0x0c */
	[public] WERROR winreg_GetKeySecurity(
		[in,ref] policy_handle *handle,
		[in] security_secinfo sec_info,
		[in,out,ref] KeySecurityData *sd
	);

	/******************/
	/* Function: 0x0d */
	WERROR winreg_LoadKey(
		[in,ref] policy_handle *handle,
		[in] winreg_String *keyname,
		[in] winreg_String *filename
	);

	/******************/
	/* Function: 0x0e */
	[public] WERROR winreg_NotifyChangeKeyValue(
		[in,ref] policy_handle *handle,
		[in] uint8 watch_subtree,
		[in] uint32 notify_filter,
		[in] uint32 unknown,
		[in] winreg_String string1,
		[in] winreg_String string2, 
		[in] uint32 unknown2
	);

	/******************/
	/* Function: 0x0f */
	[public] WERROR winreg_OpenKey(
		[in,ref] policy_handle *parent_handle,
		[in] winreg_String keyname,
		[in] uint32 unknown,
		[in] winreg_AccessMask access_mask,
		[out,ref] policy_handle *handle
	);

	/******************/
	/* Function: 0x10 */
	[public] WERROR winreg_QueryInfoKey(
		[in,ref] policy_handle *handle,
		[in,out,ref] winreg_String *classname,
		[out,ref] uint32 *num_subkeys,
		[out,ref] uint32 *max_subkeylen,
		[out,ref] uint32 *max_subkeysize,
		[out,ref] uint32 *num_values,
		[out,ref] uint32 *max_valnamelen,
		[out,ref] uint32 *max_valbufsize,
		[out,ref] uint32 *secdescsize,
		[out,ref] NTTIME *last_changed_time
	);

	/******************/
	/* Function: 0x11 */
	[public] WERROR winreg_QueryValue(
		[in,ref] policy_handle *handle,
		[in] winreg_String value_name,
		[in,out] winreg_Type *type,
		[in,out,size_is(*size),length_is(*length)] uint8 *data,
		[in,out] uint32 *size,
		[in,out] uint32 *length
	);

	/******************/
	/* Function: 0x12 */
	WERROR winreg_ReplaceKey(
	);

	/******************/
	/* Function: 0x13 */
	WERROR winreg_RestoreKey(
		[in,ref] policy_handle *handle,
		[in,ref] winreg_String *filename,
		[in]     uint32 flags 
	);

	/******************/
	/* Function: 0x14 */

	typedef struct {
		uint32 data_size;
		KeySecurityData sec_data;
		uint8 inherit;
	} KeySecurityAttribute;

	WERROR winreg_SaveKey(
		[in,ref] policy_handle *handle,
		[in,ref] winreg_String *filename,
		[in,unique] KeySecurityAttribute *sec_attrib
	);

	/******************/
	/* Function: 0x15 */
	WERROR winreg_SetKeySecurity(
		[in,ref] policy_handle *handle,
		[in] winreg_AccessMask access_mask,
		[in,ref] KeySecurityData *sd
	);

	/******************/
	/* Function: 0x16 */
	WERROR winreg_SetValue(
		[in,ref]           policy_handle *handle,
		[in]               winreg_String name,
		[in]               winreg_Type type,
		[in,size_is(size),ref] uint8  *data,
		[in]               uint32 size
	);

	/******************/
	/* Function: 0x17 */
	WERROR winreg_UnLoadKey(
	);

	/******************/
	/* Function: 0x18 */
	WERROR winreg_InitiateSystemShutdown(
		[in]	uint16 *hostname,
		[in]	initshutdown_String *message,
		[in]	uint32 timeout,
		[in]	uint8 force_apps,
		[in]	uint8 reboot
	);

	/******************/
	/* Function: 0x19 */
	WERROR winreg_AbortSystemShutdown(
		[in]	uint16 *server
	);

	/******************/
	/* Function: 0x1a */
	[public] WERROR winreg_GetVersion(
		[in,ref]     policy_handle *handle,
		[out,ref]    uint32 *version
	);

	/******************/
	/* Function: 0x1b */
	WERROR winreg_OpenHKCC(
		[in]      uint16 *system_name,
		[in]      winreg_AccessMask access_mask,
		[out,ref] policy_handle *handle
	);

	/******************/
	/* Function: 0x1c */
	WERROR winreg_OpenHKDD(
		[in]      uint16 *system_name,
		[in]      winreg_AccessMask access_mask,
		[out,ref] policy_handle *handle
	);

	typedef struct {
		winreg_String *name;
		winreg_Type type;
		uint32 offset;
		uint32 length;
	} QueryMultipleValue;
	
	/******************/
	/* Function: 0x1d */
	[public] WERROR winreg_QueryMultipleValues(
		[in,ref] policy_handle *key_handle, 
		[in,out,ref,size_is(num_values),length_is(num_values)] QueryMultipleValue *values,
		[in] uint32 num_values,
		[in,out,size_is(*buffer_size),length_is(*buffer_size)] uint8 *buffer,
		[in,out,ref] uint32 *buffer_size
	);

	/******************/
	/* Function: 0x1e */
	WERROR winreg_InitiateSystemShutdownEx(
		[in] uint16 *hostname,
		[in] initshutdown_String *message,
		[in] uint32 timeout,
		[in] uint8 force_apps,
		[in] uint8 reboot,
		[in] uint32 reason
	);

	/******************/
	/* Function: 0x1f */
	WERROR winreg_SaveKeyEx(
	);

	/******************/
	/* Function: 0x20 */
	WERROR winreg_OpenHKPT(
		[in]      uint16 *system_name,
		[in]      winreg_AccessMask access_mask,
		[out,ref] policy_handle *handle
	);

	/******************/
	/* Function: 0x21 */
	WERROR winreg_OpenHKPN(
		[in]      uint16 *system_name,
		[in]      winreg_AccessMask access_mask,
		[out,ref] policy_handle *handle
	);

	/******************/
	/* Function: 0x22 */
	WERROR winreg_QueryMultipleValues2(
	);
}
