r6218: * fix a segv in EnumPrinters():rpc_buffer_alloc when the caller does not provi...
[tprouty/samba.git] / source / include / rpc_reg.h
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB parameters and setup
4    Copyright (C) Andrew Tridgell                 1992-1997.
5    Copyright (C) Luke Kenneth Casson Leighton    1996-1997.
6    Copyright (C) Paul Ashton                          1997.
7    Copyright (C) Jeremy Cooper                        2004.
8    Copyright (C) Gerald Carter                   2002-2005.
9    
10    This program is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 2 of the License, or
13    (at your option) any later version.
14    
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19    
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25 #ifndef _RPC_REG_H /* _RPC_REG_H */
26 #define _RPC_REG_H 
27
28 /* RPC opnum */
29
30 #define REG_OPEN_HKCR           0x00
31 #define REG_OPEN_HKLM           0x02
32 #define REG_OPEN_HKPD           0x03
33 #define REG_OPEN_HKU            0x04
34 #define REG_CLOSE               0x05
35 #define REG_CREATE_KEY          0x06
36 #define REG_DELETE_KEY          0x07
37 #define REG_DELETE_VALUE        0x08
38 #define REG_ENUM_KEY            0x09
39 #define REG_ENUM_VALUE          0x0a
40 #define REG_FLUSH_KEY           0x0b
41 #define REG_GET_KEY_SEC         0x0c
42 #define REG_OPEN_ENTRY          0x0f
43 #define REG_QUERY_KEY           0x10
44 #define REG_INFO                0x11
45 #define REG_RESTORE_KEY         0x13
46 #define REG_SAVE_KEY            0x14
47 #define REG_SET_KEY_SEC         0x15
48 #define REG_CREATE_VALUE        0x16
49 #define REG_SHUTDOWN            0x18
50 #define REG_ABORT_SHUTDOWN      0x19
51 #define REG_GETVERSION          0x1a
52 #define REG_SHUTDOWN_EX         0x1e
53
54
55 #define HKEY_CLASSES_ROOT       0x80000000
56 #define HKEY_CURRENT_USER       0x80000001
57 #define HKEY_LOCAL_MACHINE      0x80000002
58 #define HKEY_USERS              0x80000003
59 #define HKEY_PERFORMANCE_DATA   0x80000004
60
61 #define KEY_HKLM        "HKLM"
62 #define KEY_HKU         "HKU"
63 #define KEY_HKCR        "HKCR"
64 #define KEY_PRINTING    "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print"
65 #define KEY_EVENTLOG    "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Eventlog"
66 #define KEY_TREE_ROOT   ""
67
68 /* Registry data types */
69
70 #define REG_NONE                       0
71 #define REG_SZ                         1
72 #define REG_EXPAND_SZ                  2
73 #define REG_BINARY                     3
74 #define REG_DWORD                      4
75 #define REG_DWORD_LE                   4        /* DWORD, little endian */
76 #define REG_DWORD_BE                   5        /* DWORD, big endian */
77 #define REG_LINK                       6
78 #define REG_MULTI_SZ                   7
79 #define REG_RESOURCE_LIST              8
80 #define REG_FULL_RESOURCE_DESCRIPTOR   9
81 #define REG_RESOURCE_REQUIREMENTS_LIST 10
82
83 /*
84  * INTERNAL REGISTRY STRUCTURES 
85  */
86
87 /* structure to contain registry values */
88
89 typedef struct {
90         fstring         valuename;
91         uint16          type;
92         uint32          size;   /* in bytes */
93         uint8           *data_p;
94 } REGISTRY_VALUE;
95
96 /* container for registry values */
97
98 typedef struct {
99         TALLOC_CTX      *ctx;
100         uint32          num_values;
101         REGISTRY_VALUE  **values;
102 } REGVAL_CTR;
103
104 /* container for registry subkey names */
105
106 typedef struct {
107         TALLOC_CTX      *ctx;
108         uint32          num_subkeys;
109         char            **subkeys;
110 } REGSUBKEY_CTR;
111
112
113 /* 
114  * container for function pointers to enumeration routines
115  * for vitural registry view 
116  */ 
117  
118 typedef struct {
119         /* functions for enumerating subkeys and values */      
120         int     (*subkey_fn)( char *key, REGSUBKEY_CTR *subkeys);
121         int     (*value_fn) ( char *key, REGVAL_CTR *val );
122         BOOL    (*store_subkeys_fn)( char *key, REGSUBKEY_CTR *subkeys );
123         BOOL    (*store_values_fn)( char *key, REGVAL_CTR *val );
124 } REGISTRY_OPS;
125
126 typedef struct {
127         const char      *keyname;       /* full path to name of key */
128         REGISTRY_OPS    *ops;           /* registry function hooks */
129 } REGISTRY_HOOK;
130
131
132
133 /* structure to store the registry handles */
134
135 typedef struct _RegistryKey {
136
137         struct _RegistryKey *prev, *next;
138
139         POLICY_HND      hnd;
140         pstring         name;   /* full name of registry key */
141         REGISTRY_HOOK   *hook;
142         
143 } REGISTRY_KEY;
144
145 /*
146  * RPC REGISTRY STRUCTURES
147  */
148
149 /***********************************************/
150
151 typedef struct {
152         uint16 *server;
153         uint32 access;     
154 } REG_Q_OPEN_HIVE;
155
156 typedef struct {
157         POLICY_HND pol;
158         WERROR status; 
159 } REG_R_OPEN_HIVE;
160
161
162 /***********************************************/
163
164 typedef struct {
165         POLICY_HND pol;
166 } REG_Q_FLUSH_KEY;
167
168 typedef struct {
169         WERROR status; 
170 } REG_R_FLUSH_KEY;
171
172
173 /***********************************************/
174
175 typedef struct {
176         POLICY_HND pol;
177         uint32 sec_info;
178         uint32 ptr; 
179         BUFHDR hdr_sec;
180         SEC_DESC_BUF *data;
181 } REG_Q_SET_KEY_SEC;
182
183 typedef struct {
184         WERROR status;
185 } REG_R_SET_KEY_SEC;
186
187
188 /***********************************************/
189
190 typedef struct {
191         POLICY_HND pol;
192         uint32 sec_info;
193         uint32 ptr; 
194         BUFHDR hdr_sec; 
195         SEC_DESC_BUF *data; 
196 } REG_Q_GET_KEY_SEC;
197
198 typedef struct {
199         uint32 sec_info; 
200         uint32 ptr; 
201         BUFHDR hdr_sec; 
202         SEC_DESC_BUF *data;
203         WERROR status;
204 } REG_R_GET_KEY_SEC;
205
206 /***********************************************/
207
208 typedef struct {
209         POLICY_HND pol;   
210         UNISTR4 name;           
211         uint32 type;  
212         BUFFER3 *value; 
213 } REG_Q_CREATE_VALUE;
214
215 typedef struct { 
216         WERROR status;
217 } REG_R_CREATE_VALUE;
218
219 /***********************************************/
220
221 typedef struct {
222         POLICY_HND pol;
223         uint32 val_index;
224         UNISTR4 name;
225         uint32 *type;  
226         REGVAL_BUFFER *value; /* value, in byte buffer */
227         uint32 *len_value1; 
228         uint32 *len_value2; 
229 } REG_Q_ENUM_VALUE;
230
231 typedef struct { 
232         UNISTR4 name;
233         uint32 *type;
234         REGVAL_BUFFER *value;
235         uint32 *len_value1;
236         uint32 *len_value2;
237         WERROR status;
238 } REG_R_ENUM_VALUE;
239
240 /***********************************************/
241
242 typedef struct {
243         POLICY_HND pnt_pol;
244         UNISTR4 name;
245         UNISTR4 class;
246         uint32 reserved;
247         uint32 access;
248         uint32 *sec_info;
249         uint32 ptr2;
250         BUFHDR hdr_sec;
251         uint32 ptr3;
252         SEC_DESC_BUF *data;
253         uint32 unknown_2; /* 0x0000 0000 */
254 } REG_Q_CREATE_KEY;
255
256 typedef struct {
257         POLICY_HND key_pol;
258         uint32 unknown;
259         WERROR status; 
260 } REG_R_CREATE_KEY;
261
262 /***********************************************/
263
264 typedef struct {
265         POLICY_HND pnt_pol;
266         UNISTR4 name;
267 } REG_Q_DELETE_KEY;
268
269 typedef struct {
270         POLICY_HND key_pol;
271         WERROR status; 
272 } REG_R_DELETE_KEY;
273
274 /***********************************************/
275
276 typedef struct {
277         POLICY_HND pnt_pol;
278         UNISTR4 name;
279 } REG_Q_DELETE_VALUE;
280
281 typedef struct {
282         POLICY_HND key_pol;
283         WERROR status;
284 } REG_R_DELETE_VALUE;
285
286 /***********************************************/
287
288 typedef struct {
289         POLICY_HND pol;
290         UNISTR4 class;
291 } REG_Q_QUERY_KEY;
292
293 typedef struct {
294         UNISTR4 class;
295         uint32 num_subkeys;
296         uint32 max_subkeylen;
297         uint32 reserved;        /* 0x0000 0000 - according to MSDN (max_subkeysize?) */
298         uint32 num_values;
299         uint32 max_valnamelen;
300         uint32 max_valbufsize; 
301         uint32 sec_desc;        /* 0x0000 0078 */
302         NTTIME mod_time;        /* modified time */
303         WERROR status;         
304 } REG_R_QUERY_KEY;
305
306
307 /***********************************************/
308
309 typedef struct {
310         POLICY_HND pol;       /* policy handle */
311 } REG_Q_GETVERSION;
312
313 typedef struct {
314         uint32 unknown;         /* 0x0500 0000 */
315         WERROR status;         /* return status */
316 } REG_R_GETVERSION;
317
318
319 /***********************************************/
320
321 typedef struct {
322         POLICY_HND pol; 
323         UNISTR4 filename;
324         uint32 flags;
325 } REG_Q_RESTORE_KEY;
326
327 typedef struct {
328         WERROR status;         /* return status */
329 } REG_R_RESTORE_KEY;
330
331
332 /***********************************************/
333
334 typedef struct {
335         POLICY_HND pol; 
336         UNISTR4 filename;
337         uint32 unknown;         /* I'm pretty sure this is a pointer to a SEC_DESC as per MSDN */
338 } REG_Q_SAVE_KEY;
339
340
341 typedef struct {
342         WERROR status;         /* return status */
343 } REG_R_SAVE_KEY;
344
345
346 /***********************************************/
347
348 typedef struct {
349         POLICY_HND pol; /* policy handle */
350 } REG_Q_CLOSE;
351
352 typedef struct {
353         POLICY_HND pol; 
354         WERROR status; 
355 } REG_R_CLOSE;
356
357
358 /***********************************************/
359
360 typedef struct {
361         POLICY_HND pol; 
362         uint32 key_index;       
363         uint16 key_name_len;    /* 0x0000 */
364         uint16 unknown_1;       /* 0x0414 */
365         uint32 ptr1;            /* pointer */
366         uint32 unknown_2;       /* 0x0000 020A */
367         uint8  pad1[8];         /* padding - zeros */
368         uint32 ptr2;            /* pointer */
369         uint8  pad2[8];         /* padding - zeros */
370         uint32 ptr3;            /* pointer */
371         NTTIME time;            /* current time? */
372 } REG_Q_ENUM_KEY;
373
374 typedef struct { 
375         uint16 key_name_len;    /* number of bytes in key name */
376         uint16 unknown_1;       /* 0x0414 - matches with query unknown_1 */
377
378         uint32 ptr1;            /* pointer */
379         uint32 unknown_2;       /* 0x0000 020A */
380         uint32 unknown_3;       /* 0x0000 0000 */
381
382         UNISTR3 key_name;
383
384         uint32 ptr2;            /* pointer */
385         uint8  pad2[8];         /* padding - zeros */
386
387         uint32 ptr3;            /* pointer */
388         NTTIME time;            /* current time? */
389
390         WERROR status;         /* return status */
391 } REG_R_ENUM_KEY;
392
393
394 /***********************************************/
395
396 typedef struct {
397         POLICY_HND pol;         /* policy handle */
398         UNISTR4  name;
399
400         uint32 ptr_reserved;    /* pointer */
401   
402         uint32 ptr_buf;         /* the next three fields follow if ptr_buf != 0 */
403         uint32 ptr_bufsize;
404         uint32 bufsize;
405         uint32 buf_unk;
406
407         uint32 unk1;
408         uint32 ptr_buflen;
409         uint32 buflen;
410   
411         uint32 ptr_buflen2;
412         uint32 buflen2;
413
414 } REG_Q_INFO;
415
416 typedef struct { 
417         uint32 *type;
418         REGVAL_BUFFER *value;   /* key value */
419         uint32 *buf_max_len;
420         uint32 *buf_len;
421         WERROR status;  /* return status */
422 } REG_R_INFO;
423
424
425 /***********************************************/
426
427 typedef struct {
428         POLICY_HND pol;
429         UNISTR4 name; 
430         uint32 unknown_0;       /* 32 bit unknown - 0x0000 0000 */
431         uint32 access; 
432 } REG_Q_OPEN_ENTRY;
433
434 typedef struct {
435         POLICY_HND pol;
436         WERROR status;
437 } REG_R_OPEN_ENTRY;
438
439 /***********************************************/
440  
441 typedef struct {
442         uint16 *server;
443         UNISTR4 *message;       
444         uint32 timeout;         /* in seconds */
445         uint8 force;            /* boolean: force shutdown */
446         uint8 reboot;           /* boolean: reboot on shutdown */               
447 } REG_Q_SHUTDOWN;
448
449 typedef struct {
450         WERROR status;          /* return status */
451 } REG_R_SHUTDOWN;
452
453 /***********************************************/
454  
455 typedef struct {
456         uint16 *server;
457         UNISTR4 *message;       
458         uint32 timeout;         /* in seconds */
459         uint8 force;            /* boolean: force shutdown */
460         uint8 reboot;           /* boolean: reboot on shutdown */
461         uint32 reason;          /* reason - must be defined code */
462 } REG_Q_SHUTDOWN_EX;
463
464 typedef struct {
465         WERROR status;
466 } REG_R_SHUTDOWN_EX;
467
468 /***********************************************/
469
470 typedef struct {
471         uint16 *server;
472 } REG_Q_ABORT_SHUTDOWN;
473
474 typedef struct { 
475         WERROR status; 
476 } REG_R_ABORT_SHUTDOWN;
477
478
479 #endif /* _RPC_REG_H */
480