/*
 * 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.
 */

#include "ndrtypes.ndl"

#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
#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

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 file_time {
	DWORD	low;
	DWORD	high;
};
typedef struct file_time file_time_t;

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;
};


OPERATION(WINREG_OPNUM_CreateKey)
struct winreg_CreateKey {
	IN winreg_handle_t	handle;
	IN winreg_string_t	subkey;
	/* IN	ignore the remaining input data */

	OUT DWORD		status;
};


OPERATION(WINREG_OPNUM_DeleteKey)
struct winreg_DeleteKey {
	IN winreg_handle_t	handle;
	IN winreg_string_t	subkey;
	/* IN	ignore the remaining input data */

	OUT DWORD		status;
};


OPERATION(WINREG_OPNUM_DeleteValue)
struct winreg_DeleteValue {
	IN winreg_handle_t	handle;
	IN winreg_string_t	name;
	/* IN	ignore the remaining input data */

	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_string_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 DWORD		*sd;
	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		unknown;
	IN  DWORD		access_mask;
	OUT winreg_handle_t	result_handle;
	OUT DWORD		status;
};


/*
 * 000000A0                    00 00 00 00 C1 F9 C0 86 18 B1       ..........
 * 000000B0  D5 11 99 C8 00 C0 F0 1F 42 26 00 00 10 04 CC ED ........B&......
 * 000000C0  12 00 08 02 00 00 00 00 00 00 00 00 00 00       ..............  
	DWORD unknown_0x04100000;
	DWORD unkown_ptr;
	DWORD unknown_0x00000208;
	DWORD unknown2;
	DWORD unknown3;
 */

OPERATION(WINREG_OPNUM_QueryKey)
struct winreg_QueryKey {
	IN  winreg_handle_t	handle;
	/*
	 * Ignore the remaining input data
	 * (2 * DWORD, possibly winreg_string_t).
	 */

	OUT winreg_string_t	name;
	OUT DWORD		unknown;
	OUT DWORD 		sub_keys;
	OUT DWORD 		max_subkey_len;
	OUT DWORD 		max_class_len;
	OUT DWORD 		values;
	OUT DWORD 		max_value_namelen;
	OUT DWORD 		max_value_len;
	OUT DWORD 		security_desc;
	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	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_GetVersion)
struct winreg_GetVersion {
	IN winreg_handle_t	handle;
	OUT DWORD		version;
	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_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_GetVersion)
		struct winreg_GetVersion	GetVersion;
};
typedef union winreg_interface	winreg_interface_t;
EXTERNTYPEINFO(winreg_interface)

#endif /* _MLSVC_WINREG_NDL_ */