/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _MLSVC_WINREG_NDL_
#define _MLSVC_WINREG_NDL_

#pragma ident	"%Z%%M%	%I%	%E% SMI"

/*
 * Windows Registry (WINREG) RPC interface definition.
 *
 * The Windows registry is split into a number of hives, which are divided
 * by function.  The hive names are abbreviated and prefixed by HKEY or HK.
 *
 * HKEY_CLASSES_ROOT     (HKCR)	Information about registered applications
 * HKEY_CURRENT_USER     (HKCU)	Settings for the current logged in user.
 * HKEY_LOCAL_MACHINE    (HKLM)	Settings for all users on the computer.
 * HKEY_USERS            (HKU)	HKEY_CURRENT_USER subkeys for user accounts.
 * HKEY_CURRENT_CONFIG   (HKCC)	Runtime configuration information.
 * HKEY_PERFORMANCE_DATA (HKPD)	Runtime performance data.
 * HKEY_DYN_DATA         (HKDD)	Runtime data for Windows 9x applications.
 * HKEY_PERFORMANCE_TEXT (HKPT)	Runtime performance information.
 * HKEY_PERFORMANCE_NLS  (HKPN)	Runtime performance information.
 */

#include "ndrtypes.ndl"

/* Windows NT */
#define WINREG_OPNUM_OpenHKCR		0x00
#define WINREG_OPNUM_OpenHKCU		0x01
#define WINREG_OPNUM_OpenHKLM		0x02
#define WINREG_OPNUM_OpenHKPD		0x03
#define WINREG_OPNUM_OpenHKUsers	0x04
#define WINREG_OPNUM_Close		0x05
#define WINREG_OPNUM_CreateKey		0x06
#define WINREG_OPNUM_DeleteKey		0x07
#define WINREG_OPNUM_DeleteValue	0x08
#define WINREG_OPNUM_EnumKey		0x09
#define WINREG_OPNUM_EnumValue		0x0a
#define WINREG_OPNUM_FlushKey		0x0b
#define WINREG_OPNUM_GetKeySec		0x0c
#define WINREG_OPNUM_LoadKey		0x0d
#define WINREG_OPNUM_NotifyChange	0x0e
#define WINREG_OPNUM_OpenKey		0x0f
#define WINREG_OPNUM_QueryKey		0x10
#define WINREG_OPNUM_QueryValue		0x11
#define WINREG_OPNUM_ReplaceKey		0x12
#define WINREG_OPNUM_RestoreKey		0x13
#define WINREG_OPNUM_SaveKey		0x14
#define WINREG_OPNUM_SetKeySec		0x15

/* Windows 2000 */
#define WINREG_OPNUM_CreateValue	0x16
#define WINREG_OPNUM_UnloadKey		0x17
#define WINREG_OPNUM_Shutdown		0x18
#define WINREG_OPNUM_AbortShutdown	0x19
#define WINREG_OPNUM_GetVersion		0x1a
#define WINREG_OPNUM_OpenHKCC		0x1b
#define WINREG_OPNUM_OpenHKDD		0x1c
#define WINREG_OPNUM_QueryMultiValues	0x1d
#define WINREG_OPNUM_ShutdownEx		0x1e

/* Windows XP and Windows Server 2003 */
#define WINREG_OPNUM_SavekeyEx		0x1f
#define WINREG_OPNUM_OpenHKPT		0x20
#define WINREG_OPNUM_OpenHKPN		0x21

/* Windows 2003 SP1 */
#define WINREG_OPNUM_QueryMultiValues2	0x22
#define WINREG_OPNUM_DeleteKeyEx	0x23

#define	WINREG_TYPE_NONE		0
#define WINREG_SZ			1
#define WINREG_EXPAND_SZ		2
#define WINREG_BINARY			3
#define WINREG_DWORD			4
#define WINREG_DWORD_BIG_ENDIAN		5
#define WINREG_LINK			6
#define WINREG_MULTI_SZ			7
#define WINREG_RESOURCE_LIST		8
#define WINREG_RESOURCE_DESC		9
#define WINREG_RESOURCE_REQ_LIST	10
#define WINREG_QWORD			11

#define	WINREG_ACCESS_QUERY_VALUE	0x00000001
#define WINREG_ACCESS_SET_VALUE		0x00000002
#define WINREG_ACCESS_CREATE_KEY	0x00000004
#define WINREG_ACCESS_ENUMERATE		0x00000008
#define WINREG_ACCESS_NOTIFY		0x00000010
#define WINREG_ACCESS_CREATE_LINK	0x00000020
#define WINREG_ACCESS_KEY64		0x00000100
#define WINREG_ACCESS_KEY32		0x00000200

struct winreg_handle {
	DWORD hand1;
	DWORD hand2;
	WORD  hand3[2];
	BYTE  hand4[8];
};
typedef struct winreg_handle winreg_handle_t;

struct winreg_string_desc {
	WORD	length;
	WORD	allosize;
	LPTSTR	str;
};
typedef struct winreg_string_desc winreg_string_t;

/*
 * Fake Varying/Conformant with a funny conformant.
 */
struct winreg_value {
	DWORD	vc_first_is;	/* 0 */
	DWORD	vc_length_is;
  SIZE_IS(vc_length_is)
	BYTE	value[ANY_SIZE_ARRAY];
};

struct winreg_vcbuf {
	WORD wclen;
	WORD wcsize;
	struct winreg_value *buf;
};
typedef struct winreg_vcbuf winreg_vcbuf_t;

struct file_time {
	DWORD	low;
	DWORD	high;
};
typedef struct file_time file_time_t;

struct winreg_secdesc {
	DWORD	sd_length_is;
  SIZE_IS(sd_length_is)
	BYTE	value[ANY_SIZE_ARRAY];
};

OPERATION(WINREG_OPNUM_OpenHKCR)
struct winreg_OpenHKCR {
	IN  DWORD		*server;
	IN  DWORD		access_mask;
	OUT winreg_handle_t	handle;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_OpenHKCU)
struct winreg_OpenHKCU {
	IN  DWORD		*server;
	IN  DWORD		access_mask;
	OUT winreg_handle_t	handle;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_OpenHKLM)
struct winreg_OpenHKLM {
	IN  DWORD		*server;
	IN  DWORD		access_mask;
	OUT winreg_handle_t	handle;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_OpenHKPD)
struct winreg_OpenHKPD {
	IN  DWORD		*server;
	IN  DWORD		access_mask;
	OUT winreg_handle_t	handle;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_OpenHKUsers)
struct winreg_OpenHKUsers {
	IN  DWORD		*server;
	IN  DWORD		access_mask;
	OUT winreg_handle_t	handle;
	OUT DWORD		status;
};


OPERATION(WINREG_OPNUM_Close)
struct winreg_Close {
	IN  winreg_handle_t	handle;
	OUT winreg_handle_t	result_handle;
	OUT DWORD		status;
};

#define	WINREG_ACTION_NONE		0
#define	WINREG_ACTION_NEW_KEY		1
#define	WINREG_ACTION_EXISTING_KEY	2

OPERATION(WINREG_OPNUM_CreateKey)
struct winreg_CreateKey {
	IN winreg_handle_t	handle;
	IN winreg_string_t	subkey;
	IN winreg_string_t	keyclass;
	IN DWORD		options;
	IN DWORD		access_mask;
	IN DWORD		*sd;
	OUT winreg_handle_t	result_handle;
	OUT DWORD		*action;
	OUT DWORD		status;
};


OPERATION(WINREG_OPNUM_DeleteKey)
struct winreg_DeleteKey {
	IN winreg_handle_t	handle;
	IN winreg_string_t	subkey;
	OUT DWORD		status;
};


OPERATION(WINREG_OPNUM_DeleteValue)
struct winreg_DeleteValue {
	IN winreg_handle_t	handle;
	IN winreg_string_t	name;
	OUT DWORD		status;
};

/*
 * Some of the OUT parameters are also supplied
 * as IN parameters but we can ignore them.
 */
OPERATION(WINREG_OPNUM_EnumKey)
struct winreg_EnumKey {
	IN	winreg_handle_t	handle;
	IN	DWORD		index;
	/* IN	ignore the remaining input data */
/*
	INOUT	winreg_vcbuf_t	name;
	INOUT	winreg_vcbuf_t	*class;
	INOUT	file_time_t	*change_time;
*/
	OUT	winreg_vcbuf_t	name;
	OUT	winreg_vcbuf_t	*class;
	OUT	file_time_t	*change_time;
	OUT	DWORD		status;
};

/*
 * Some of the OUT parameters are also supplied
 * as IN parameters but we can ignore them.
 */
OPERATION(WINREG_OPNUM_EnumValue)
struct winreg_EnumValue {
	IN winreg_handle_t	handle;
	IN DWORD		index;
	/* IN	ignore the remaining input data */

	OUT winreg_vcbuf_t	name;
	OUT DWORD		*type;
	OUT struct winreg_value *value;
	OUT DWORD		*value_size;
	OUT DWORD		*value_size_total;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_FlushKey)
struct winreg_FlushKey {
	IN winreg_handle_t	handle;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_GetKeySec)
struct winreg_GetKeySec {
	IN winreg_handle_t	handle;
	IN DWORD		sec_info;
/*
	OUT struct winreg_secdesc	sd;
*/
	OUT DWORD		sd_length_is;
	OUT DWORD		sd_size_is;
	OUT DWORD		sd_array;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_NotifyChange)
struct winreg_NotifyChange {
	IN  winreg_handle_t	handle;
	IN  DWORD		watch_subtree;
	IN  DWORD		notify_filter;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_OpenKey)
struct winreg_OpenKey {
	IN  winreg_handle_t	handle;
	IN  winreg_string_t	name;
	IN  DWORD		options;
	IN  DWORD		access_mask;
	OUT winreg_handle_t	result_handle;
	OUT DWORD		status;
};


OPERATION(WINREG_OPNUM_QueryKey)
struct winreg_QueryKey {
	IN  winreg_handle_t	handle;
	INOUT winreg_string_t	name;
	OUT DWORD 		num_subkeys;
	OUT DWORD 		max_subkey_len;
	OUT DWORD 		max_class_len;
	OUT DWORD 		num_values;
	OUT DWORD 		max_value_namelen;
	OUT DWORD 		max_value_len;
	OUT DWORD 		secdesc_size;
	OUT file_time_t 	last_write_time;
	OUT DWORD		status;
};


/*
 * Some of the OUT parameters are also supplied
 * as IN parameters but we can ignore them.
 */
OPERATION(WINREG_OPNUM_QueryValue)
struct winreg_QueryValue {
	IN  winreg_handle_t	handle;
	IN  winreg_string_t	value_name;
	/* IN	ignore the remaining input data */

	OUT DWORD		*type;
	OUT struct winreg_value	*value;
	OUT DWORD		*value_size;
	OUT DWORD		*value_size_total;
	OUT DWORD		status;
};


OPERATION(WINREG_OPNUM_SetKeySec)
struct winreg_SetKeySec {
	IN winreg_handle_t	handle;
	IN DWORD		access_mask;
	IN DWORD		sd;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_CreateValue)
struct winreg_CreateValue {
	IN winreg_handle_t	handle;
	IN winreg_string_t	name;
	IN winreg_string_t	class;
	IN DWORD		options;
	/* IN	ignore the remaining input data */

	OUT DWORD		status;
};


/*
 * The real structure of shutdown passes some strings, a timeout
 * and reboot/shutdown flags but this allows us to accept the call,
 * without anything appearing in the log, and return access denied.
 */
OPERATION(WINREG_OPNUM_Shutdown)
struct winreg_Shutdown {
	IN DWORD		ignored;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_AbortShutdown)
struct winreg_AbortShutdown {
	IN DWORD		ignored;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_GetVersion)
struct winreg_GetVersion {
	IN winreg_handle_t	handle;
	OUT DWORD		version;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_OpenHKCC)
struct winreg_OpenHKCC {
	IN  DWORD		*server;
	IN  DWORD		access_mask;
	OUT winreg_handle_t	handle;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_OpenHKDD)
struct winreg_OpenHKDD {
	IN  DWORD		*server;
	IN  DWORD		access_mask;
	OUT winreg_handle_t	handle;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_OpenHKPT)
struct winreg_OpenHKPT {
	IN  DWORD		*server;
	IN  DWORD		access_mask;
	OUT winreg_handle_t	handle;
	OUT DWORD		status;
};

OPERATION(WINREG_OPNUM_OpenHKPN)
struct winreg_OpenHKPN {
	IN  DWORD		*server;
	IN  DWORD		access_mask;
	OUT winreg_handle_t	handle;
	OUT DWORD		status;
};

/*
 * The WINREG interface.
 */
INTERFACE(0)
union winreg_interface {
	CASE(WINREG_OPNUM_OpenHKCR)
		struct winreg_OpenHKCR		OpenHKCR;
	CASE(WINREG_OPNUM_OpenHKCU)
		struct winreg_OpenHKCU		OpenHKCU;
	CASE(WINREG_OPNUM_OpenHKLM)
		struct winreg_OpenHKLM		OpenHKLM;
	CASE(WINREG_OPNUM_OpenHKPD)
		struct winreg_OpenHKPD		OpenHKPD;
	CASE(WINREG_OPNUM_OpenHKUsers)
		struct winreg_OpenHKUsers	OpenHKUsers;
	CASE(WINREG_OPNUM_Close)
		struct winreg_Close		Close;
	CASE(WINREG_OPNUM_CreateKey)
		struct winreg_CreateKey		CreateKey;
	CASE(WINREG_OPNUM_DeleteKey)
		struct winreg_DeleteKey		DeleteKey;
	CASE(WINREG_OPNUM_DeleteValue)
		struct winreg_DeleteValue	DeleteValue;
	CASE(WINREG_OPNUM_EnumKey)
		struct winreg_EnumKey		EnumKey;
	CASE(WINREG_OPNUM_EnumValue)
		struct winreg_EnumValue		EnumValue;
	CASE(WINREG_OPNUM_FlushKey)
		struct winreg_FlushKey		FlushKey;
	CASE(WINREG_OPNUM_GetKeySec)
		struct winreg_GetKeySec		GetKeySec;
	CASE(WINREG_OPNUM_NotifyChange)
		struct winreg_NotifyChange	NotifyChange;
	CASE(WINREG_OPNUM_OpenKey)
		struct winreg_OpenKey		OpenKey;
	CASE(WINREG_OPNUM_QueryKey)
		struct winreg_QueryKey		QueryKey;
	CASE(WINREG_OPNUM_QueryValue)
		struct winreg_QueryValue	QueryValue;
	CASE(WINREG_OPNUM_SetKeySec)
		struct winreg_SetKeySec		SetKeySec;
	CASE(WINREG_OPNUM_CreateValue)
		struct winreg_CreateValue	CreateValue;
	CASE(WINREG_OPNUM_Shutdown)
		struct winreg_Shutdown		Shutdown;
	CASE(WINREG_OPNUM_AbortShutdown)
		struct winreg_AbortShutdown	AbortShutdown;
	CASE(WINREG_OPNUM_GetVersion)
		struct winreg_GetVersion	GetVersion;
	CASE(WINREG_OPNUM_OpenHKCC)
		struct winreg_OpenHKCC		OpenHKCC;
	CASE(WINREG_OPNUM_OpenHKDD)
		struct winreg_OpenHKDD		OpenHKDD;
	CASE(WINREG_OPNUM_OpenHKPT)
		struct winreg_OpenHKPT		OpenHKPT;
	CASE(WINREG_OPNUM_OpenHKPN)
		struct winreg_OpenHKPN		OpenHKPN;
};
typedef union winreg_interface	winreg_interface_t;
EXTERNTYPEINFO(winreg_interface)

#endif /* _MLSVC_WINREG_NDL_ */