summaryrefslogtreecommitdiff
path: root/source4/rpc_server/winreg/rpc_winreg.c
blob: a39a7d14831223e5d54fbc04983852daddf55a67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
/*
   Unix SMB/CIFS implementation.

   endpoint server for the winreg pipe

   Copyright (C) 2004 Jelmer Vernooij, jelmer@samba.org
   Copyright (C) 2008 Matthias Dieter Wallnöfer, mwallnoefer@yahoo.de

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "includes.h"
#include "rpc_server/dcerpc_server.h"
#include "lib/registry/registry.h"
#include "librpc/gen_ndr/ndr_winreg.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "libcli/security/security.h"

enum handle_types { HTYPE_REGVAL, HTYPE_REGKEY };

static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call,
				   const struct dcesrv_interface *iface)
{
	struct registry_context *ctx;
	WERROR err;

	err = reg_open_samba(dce_call->context,
			     &ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
			     dce_call->conn->auth_state.session_info,
			     NULL);

	if (!W_ERROR_IS_OK(err)) {
		DEBUG(0, ("Error opening registry: %s\n", win_errstr(err)));
		return NT_STATUS_UNSUCCESSFUL;
	}

	dce_call->context->private_data = ctx;

	return NT_STATUS_OK;
}

#define DCESRV_INTERFACE_WINREG_BIND dcerpc_winreg_bind

static WERROR dcesrv_winreg_openhive(struct dcesrv_call_state *dce_call,
				     TALLOC_CTX *mem_ctx, uint32_t hkey,
				     struct policy_handle **outh)
{
	struct registry_context *ctx = dce_call->context->private_data;
	struct dcesrv_handle *h;
	WERROR result;

	h = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY);
	W_ERROR_HAVE_NO_MEMORY(h);

	result = reg_get_predefined_key(ctx, hkey,
				       (struct registry_key **)&h->data);
	if (!W_ERROR_IS_OK(result)) {
		return result;
	}
	*outh = &h->wire_handle;

	return result;
}

#define func_winreg_OpenHive(k,n) static WERROR dcesrv_winreg_Open ## k (struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct winreg_Open ## k *r) \
{ \
	return dcesrv_winreg_openhive (dce_call, mem_ctx, n, &r->out.handle);\
}

func_winreg_OpenHive(HKCR,HKEY_CLASSES_ROOT)
func_winreg_OpenHive(HKCU,HKEY_CURRENT_USER)
func_winreg_OpenHive(HKLM,HKEY_LOCAL_MACHINE)
func_winreg_OpenHive(HKPD,HKEY_PERFORMANCE_DATA)
func_winreg_OpenHive(HKU,HKEY_USERS)
func_winreg_OpenHive(HKCC,HKEY_CURRENT_CONFIG)
func_winreg_OpenHive(HKDD,HKEY_DYN_DATA)
func_winreg_OpenHive(HKPT,HKEY_PERFORMANCE_TEXT)
func_winreg_OpenHive(HKPN,HKEY_PERFORMANCE_NLSTEXT)

/*
  winreg_CloseKey
*/
static WERROR dcesrv_winreg_CloseKey(struct dcesrv_call_state *dce_call,
				     TALLOC_CTX *mem_ctx,
				     struct winreg_CloseKey *r)
{
	struct dcesrv_handle *h;

	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);

	talloc_unlink(dce_call->context, h);

	ZERO_STRUCTP(r->out.handle);

	return WERR_OK;
}

/*
  winreg_CreateKey
*/
static WERROR dcesrv_winreg_CreateKey(struct dcesrv_call_state *dce_call,
				      TALLOC_CTX *mem_ctx,
				      struct winreg_CreateKey *r)
{
	struct dcesrv_handle *h, *newh;
	struct security_descriptor sd;
	struct registry_key *key;
	WERROR result;

	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
	key = h->data;

	newh = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY);

	switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
	{
	case SECURITY_SYSTEM:
	case SECURITY_ADMINISTRATOR:
		/* we support only non volatile keys */
		if (r->in.options != REG_OPTION_NON_VOLATILE) {
			return WERR_NOT_SUPPORTED;
		}

		/* the security descriptor is optional */
		if (r->in.secdesc != NULL) {
			DATA_BLOB sdblob;
			enum ndr_err_code ndr_err;
			sdblob.data = r->in.secdesc->sd.data;
			sdblob.length = r->in.secdesc->sd.len;
			if (sdblob.data == NULL) {
				return WERR_INVALID_PARAM;
			}
			ndr_err = ndr_pull_struct_blob_all(&sdblob, mem_ctx, &sd,
							   (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
			if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
				return WERR_INVALID_PARAM;
			}
		}
		
		result = reg_key_add_name(newh, key, r->in.name.name, NULL,
			r->in.secdesc?&sd:NULL, (struct registry_key **)&newh->data);

		r->out.action_taken = talloc(mem_ctx, enum winreg_CreateAction);
		if (r->out.action_taken == NULL) {
			talloc_free(newh);
			return WERR_NOMEM;
		}
		*r->out.action_taken = REG_ACTION_NONE;

		if (W_ERROR_IS_OK(result)) {
			r->out.new_handle = &newh->wire_handle;
			*r->out.action_taken = REG_CREATED_NEW_KEY;
		} else {
			talloc_free(newh);
		}

		return result;
	default:
		return WERR_ACCESS_DENIED;
	}
}


/*
  winreg_DeleteKey
*/
static WERROR dcesrv_winreg_DeleteKey(struct dcesrv_call_state *dce_call,
				      TALLOC_CTX *mem_ctx,
				      struct winreg_DeleteKey *r)
{
	struct dcesrv_handle *h;
	struct registry_key *key;
	WERROR result;

	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
	key = h->data;

	switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
	{
	case SECURITY_SYSTEM:
	case SECURITY_ADMINISTRATOR:
		result = reg_key_del(mem_ctx, key, r->in.key.name);
		talloc_unlink(dce_call->context, h);

		return result;
	default:
		return WERR_ACCESS_DENIED;
	}
}


/*
  winreg_DeleteValue
*/
static WERROR dcesrv_winreg_DeleteValue(struct dcesrv_call_state *dce_call,
					TALLOC_CTX *mem_ctx,
					struct winreg_DeleteValue *r)
{
	struct dcesrv_handle *h;
	struct registry_key *key;

	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
	key = h->data;

	switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
	{
	case SECURITY_SYSTEM:
	case SECURITY_ADMINISTRATOR:
		return reg_del_value(mem_ctx, key, r->in.value.name);
	default:
		return WERR_ACCESS_DENIED;
	}
}


/*
  winreg_EnumKey
*/
static WERROR dcesrv_winreg_EnumKey(struct dcesrv_call_state *dce_call,
				    TALLOC_CTX *mem_ctx,
				    struct winreg_EnumKey *r)
{
	struct dcesrv_handle *h;
	struct registry_key *key;
	const char *name, *classname;
	NTTIME last_mod;
	WERROR result;

	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
	key = h->data;

	result = reg_key_get_subkey_by_index(mem_ctx, 
		key, r->in.enum_index, &name, &classname, &last_mod);

	if (2*strlen_m_term(name) > r->in.name->size) {
		return WERR_MORE_DATA;
	}

	if (name != NULL) {
		r->out.name->name = name;
		r->out.name->length = 2*strlen_m_term(name);
	} else {
		r->out.name->name = r->in.name->name;
		r->out.name->length = r->in.name->length;
	}
	r->out.name->size = r->in.name->size;

	r->out.keyclass = r->in.keyclass;
	if (classname != NULL) {
		r->out.keyclass->name = classname;
		r->out.keyclass->length = 2*strlen_m_term(classname);
	} else {
		r->out.keyclass->name = r->in.keyclass->name;
		r->out.keyclass->length = r->in.keyclass->length;
	}
	r->out.keyclass->size = r->in.keyclass->size;

	if (r->in.last_changed_time != NULL)
		r->out.last_changed_time = &last_mod;

	return result;
}


/*
  winreg_EnumValue
*/
static WERROR dcesrv_winreg_EnumValue(struct dcesrv_call_state *dce_call,
				      TALLOC_CTX *mem_ctx,
				      struct winreg_EnumValue *r)
{
	struct dcesrv_handle *h;
	struct registry_key *key;
	const char *data_name;
	uint32_t data_type;
	DATA_BLOB data;
	WERROR result;

	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
	key = h->data;

	result = reg_key_get_value_by_index(mem_ctx, key,
		r->in.enum_index, &data_name, &data_type, &data);

	if (!W_ERROR_IS_OK(result)) {
		/* if the lookup wasn't successful, send client query back */
		data_name = r->in.name->name;
		data_type = *r->in.type;
		data.data = r->in.value;
		data.length = *r->in.length;
	}

	/* "data_name" is NULL when we query the default attribute */
	if (data_name != NULL) {
		r->out.name->name = data_name;
		r->out.name->length = 2*strlen_m_term(data_name);
	} else {
		r->out.name->name = r->in.name->name;
		r->out.name->length = r->in.name->length;
	}
	r->out.name->size = r->in.name->size;

	r->out.type = talloc(mem_ctx, enum winreg_Type);
	if (!r->out.type) {
		return WERR_NOMEM;
	}
	*r->out.type = (enum winreg_Type) data_type;

	/* check the client has enough room for the value */
	if (r->in.value != NULL &&
	    r->in.size != NULL &&
	    data.length > *r->in.size) {
		return WERR_MORE_DATA;
	}

	if (r->in.value != NULL) {
		r->out.value = data.data;
	}

	if (r->in.size != NULL) {
		r->out.size = talloc(mem_ctx, uint32_t);
		*r->out.size = data.length;
		r->out.length = r->out.size;
	}

	return result;
}


/*
  winreg_FlushKey
*/
static WERROR dcesrv_winreg_FlushKey(struct dcesrv_call_state *dce_call,
				     TALLOC_CTX *mem_ctx,
				     struct winreg_FlushKey *r)
{
	struct dcesrv_handle *h;
	struct registry_key *key;

	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
	key = h->data;

	switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
	{
	case SECURITY_SYSTEM:
	case SECURITY_ADMINISTRATOR:
		return reg_key_flush(key);
	default:
		return WERR_ACCESS_DENIED;
	}
}


/*
  winreg_GetKeySecurity
*/
static WERROR dcesrv_winreg_GetKeySecurity(struct dcesrv_call_state *dce_call,
					   TALLOC_CTX *mem_ctx,
					   struct winreg_GetKeySecurity *r)
{
	struct dcesrv_handle *h;

	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);

	return WERR_NOT_SUPPORTED;
}


/*
  winreg_LoadKey
*/
static WERROR dcesrv_winreg_LoadKey(struct dcesrv_call_state *dce_call,
				    TALLOC_CTX *mem_ctx,
				    struct winreg_LoadKey *r)
{
	return WERR_NOT_SUPPORTED;
}


/*
  winreg_NotifyChangeKeyValue
*/
static WERROR dcesrv_winreg_NotifyChangeKeyValue(struct dcesrv_call_state *dce_call,
						 TALLOC_CTX *mem_ctx,
						 struct winreg_NotifyChangeKeyValue *r)
{
	return WERR_NOT_SUPPORTED;
}


/*
  winreg_OpenKey
*/
static WERROR dcesrv_winreg_OpenKey(struct dcesrv_call_state *dce_call,
				    TALLOC_CTX *mem_ctx,
				    struct winreg_OpenKey *r)
{
	struct dcesrv_handle *h, *newh;
	struct registry_key *key;
	WERROR result;

	DCESRV_PULL_HANDLE_FAULT(h, r->in.parent_handle, HTYPE_REGKEY);
	key = h->data;

	switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
	{
	case SECURITY_SYSTEM:
	case SECURITY_ADMINISTRATOR:
	case SECURITY_USER:
		if (r->in.keyname.name && strcmp(r->in.keyname.name, "") == 0) {
			newh = talloc_reference(dce_call->context, h);
			result = WERR_OK;
		} else {
			newh = dcesrv_handle_new(dce_call->context, HTYPE_REGKEY);
			result = reg_open_key(newh, key, r->in.keyname.name,
				(struct registry_key **)&newh->data);
		}
		
		if (W_ERROR_IS_OK(result)) {
			r->out.handle = &newh->wire_handle;
		} else {
			talloc_free(newh);
		}
		return result;
	default:
		return WERR_ACCESS_DENIED;
	}
}


/*
  winreg_QueryInfoKey
*/
static WERROR dcesrv_winreg_QueryInfoKey(struct dcesrv_call_state *dce_call,
					 TALLOC_CTX *mem_ctx,
					 struct winreg_QueryInfoKey *r)
{
	struct dcesrv_handle *h;
	struct registry_key *key;
	const char *classname = NULL;
	WERROR result;

	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
	key = h->data;

	switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
	{
	case SECURITY_SYSTEM:
	case SECURITY_ADMINISTRATOR:
	case SECURITY_USER:
		result = reg_key_get_info(mem_ctx, key, &classname,
			r->out.num_subkeys, r->out.num_values,
			r->out.last_changed_time, r->out.max_subkeylen,
			r->out.max_valnamelen, r->out.max_valbufsize);

		if (r->out.max_subkeylen != NULL) {
			/* for UTF16 encoding */
			*r->out.max_subkeylen *= 2;
		}
		if (r->out.max_valnamelen != NULL) {
			/* for UTF16 encoding */
			*r->out.max_valnamelen *= 2;
		}

		if (classname != NULL) {
			r->out.classname->name = classname;
			r->out.classname->name_len = 2*strlen_m_term(classname);
		} else {
			r->out.classname->name = r->in.classname->name;
			r->out.classname->name_len = r->in.classname->name_len;
		}
		r->out.classname->name_size = r->in.classname->name_size;

		return result;
	default:
		return WERR_ACCESS_DENIED;
	}
}


/*
  winreg_QueryValue
*/
static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call,
				       TALLOC_CTX *mem_ctx,
				       struct winreg_QueryValue *r)
{
	struct dcesrv_handle *h;
	struct registry_key *key;
	uint32_t value_type;
	DATA_BLOB value_data;
	WERROR result;

	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
	key = h->data;

	switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
	{
	case SECURITY_SYSTEM:
	case SECURITY_ADMINISTRATOR:
	case SECURITY_USER:
		if ((r->in.type == NULL) || (r->in.data_length == NULL) ||
		    (r->in.data_size == NULL)) {
			return WERR_INVALID_PARAM;
		}

		result = reg_key_get_value_by_name(mem_ctx, key, 
			 r->in.value_name->name, &value_type, &value_data);
		
		if (!W_ERROR_IS_OK(result)) {
			/* if the lookup wasn't successful, send client query back */
			value_type = *r->in.type;
			value_data.data = r->in.data;
			value_data.length = *r->in.data_length;
		} else {
			if ((r->in.data != NULL)
			    && (*r->in.data_size < value_data.length)) {
				result = WERR_MORE_DATA;
			}
		}

		r->out.type = talloc(mem_ctx, enum winreg_Type);
		if (!r->out.type) {
			return WERR_NOMEM;
		}
		*r->out.type = (enum winreg_Type) value_type;
		r->out.data_length = talloc(mem_ctx, uint32_t);
		if (!r->out.data_length) {
			return WERR_NOMEM;
		}
		*r->out.data_length = value_data.length;
		r->out.data_size = talloc(mem_ctx, uint32_t);
		if (!r->out.data_size) {
			return WERR_NOMEM;
		}
		*r->out.data_size = value_data.length;
		r->out.data = value_data.data;

		return result;
	default:
		return WERR_ACCESS_DENIED;
	}
}


/*
  winreg_ReplaceKey
*/
static WERROR dcesrv_winreg_ReplaceKey(struct dcesrv_call_state *dce_call,
				       TALLOC_CTX *mem_ctx,
				       struct winreg_ReplaceKey *r)
{
	return WERR_NOT_SUPPORTED;
}


/*
  winreg_RestoreKey
*/
static WERROR dcesrv_winreg_RestoreKey(struct dcesrv_call_state *dce_call,
				       TALLOC_CTX *mem_ctx,
				       struct winreg_RestoreKey *r)
{
	return WERR_NOT_SUPPORTED;
}


/*
  winreg_SaveKey
*/
static WERROR dcesrv_winreg_SaveKey(struct dcesrv_call_state *dce_call,
				    TALLOC_CTX *mem_ctx,
				    struct winreg_SaveKey *r)
{
	return WERR_NOT_SUPPORTED;
}


/*
  winreg_SetKeySecurity
*/
static WERROR dcesrv_winreg_SetKeySecurity(struct dcesrv_call_state *dce_call,
					   TALLOC_CTX *mem_ctx,
					   struct winreg_SetKeySecurity *r)
{
	return WERR_NOT_SUPPORTED;
}


/*
  winreg_SetValue
*/
static WERROR dcesrv_winreg_SetValue(struct dcesrv_call_state *dce_call,
				     TALLOC_CTX *mem_ctx,
				     struct winreg_SetValue *r)
{
	struct dcesrv_handle *h;
	struct registry_key *key;
	DATA_BLOB data;
	WERROR result;

	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);
	key = h->data;

	switch (security_session_user_level(dce_call->conn->auth_state.session_info, NULL))
	{
	case SECURITY_SYSTEM:
	case SECURITY_ADMINISTRATOR:
		data.data = r->in.data;
		data.length = r->in.size;
		result = reg_val_set(key, r->in.name.name, r->in.type, data);
		return result;
	default:
		return WERR_ACCESS_DENIED;
	}
}


/*
  winreg_UnLoadKey
*/
static WERROR dcesrv_winreg_UnLoadKey(struct dcesrv_call_state *dce_call,
				      TALLOC_CTX *mem_ctx,
				      struct winreg_UnLoadKey *r)
{
	return WERR_NOT_SUPPORTED;
}


/*
  winreg_InitiateSystemShutdown
*/
static WERROR dcesrv_winreg_InitiateSystemShutdown(struct dcesrv_call_state *dce_call,
						   TALLOC_CTX *mem_ctx,
						   struct winreg_InitiateSystemShutdown *r)
{
	return WERR_NOT_SUPPORTED;
}


/*
  winreg_AbortSystemShutdown
*/
static WERROR dcesrv_winreg_AbortSystemShutdown(struct dcesrv_call_state *dce_call,
						TALLOC_CTX *mem_ctx,
						struct winreg_AbortSystemShutdown *r)
{
	return WERR_NOT_SUPPORTED;
}


/*
  winreg_GetVersion
*/
static WERROR dcesrv_winreg_GetVersion(struct dcesrv_call_state *dce_call,
				       TALLOC_CTX *mem_ctx,
				       struct winreg_GetVersion *r)
{
	struct dcesrv_handle *h;

	DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY);

	r->out.version = talloc(mem_ctx, uint32_t);
	W_ERROR_HAVE_NO_MEMORY(r->out.version);

	*r->out.version = 5;

	return WERR_OK;
}


/*
  winreg_QueryMultipleValues
*/
static WERROR dcesrv_winreg_QueryMultipleValues(struct dcesrv_call_state *dce_call,
						TALLOC_CTX *mem_ctx,
						struct winreg_QueryMultipleValues *r)
{
	return WERR_NOT_SUPPORTED;
}


/*
  winreg_InitiateSystemShutdownEx
*/
static WERROR dcesrv_winreg_InitiateSystemShutdownEx(struct dcesrv_call_state *dce_call,
						     TALLOC_CTX *mem_ctx,
						     struct winreg_InitiateSystemShutdownEx *r)
{
	return WERR_NOT_SUPPORTED;
}


/*
  winreg_SaveKeyEx
*/
static WERROR dcesrv_winreg_SaveKeyEx(struct dcesrv_call_state *dce_call,
				      TALLOC_CTX *mem_ctx,
				      struct winreg_SaveKeyEx *r)
{
	return WERR_NOT_SUPPORTED;
}


/*
  winreg_QueryMultipleValues2
*/
static WERROR dcesrv_winreg_QueryMultipleValues2(struct dcesrv_call_state *dce_call,
						 TALLOC_CTX *mem_ctx,
						 struct winreg_QueryMultipleValues2 *r)
{
	return WERR_NOT_SUPPORTED;
}

/*
  winreg_DeleteKeyEx
*/
static WERROR dcesrv_winreg_DeleteKeyEx(struct dcesrv_call_state *dce_call,
					TALLOC_CTX *mem_ctx,
					struct winreg_DeleteKeyEx *r)
{
	return WERR_NOT_SUPPORTED;
}

/* include the generated boilerplate */
#include "librpc/gen_ndr/ndr_winreg_s.c"