2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
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) Marc Jacobsen 2000,
8 * Copyright (C) Jeremy Allison 2001,
9 * Copyright (C) Gerald Carter 2002,
10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 /* This is the interface for the registry functions. */
32 #define DBGC_CLASS DBGC_RPC_SRV
34 /*******************************************************************
36 ********************************************************************/
38 static BOOL
api_reg_close(pipes_struct
*p
)
42 prs_struct
*data
= &p
->in_data
.data
;
43 prs_struct
*rdata
= &p
->out_data
.rdata
;
48 /* grab the reg unknown 1 */
49 if(!reg_io_q_close("", &q_u
, data
, 0))
52 r_u
.status
= _reg_close(p
, &q_u
, &r_u
);
54 if(!reg_io_r_close("", &r_u
, rdata
, 0))
60 /*******************************************************************
62 ********************************************************************/
64 static BOOL
api_reg_open_hklm(pipes_struct
*p
)
68 prs_struct
*data
= &p
->in_data
.data
;
69 prs_struct
*rdata
= &p
->out_data
.rdata
;
74 /* grab the reg open */
75 if(!reg_io_q_open_hive("", &q_u
, data
, 0))
78 r_u
.status
= _reg_open_hklm(p
, &q_u
, &r_u
);
80 if(!reg_io_r_open_hive("", &r_u
, rdata
, 0))
86 /*******************************************************************
88 ********************************************************************/
90 static BOOL
api_reg_open_hku(pipes_struct
*p
)
94 prs_struct
*data
= &p
->in_data
.data
;
95 prs_struct
*rdata
= &p
->out_data
.rdata
;
100 /* grab the reg open */
101 if(!reg_io_q_open_hive("", &q_u
, data
, 0))
104 r_u
.status
= _reg_open_hku(p
, &q_u
, &r_u
);
106 if(!reg_io_r_open_hive("", &r_u
, rdata
, 0))
112 /*******************************************************************
114 ********************************************************************/
116 static BOOL
api_reg_open_hkcr(pipes_struct
*p
)
120 prs_struct
*data
= &p
->in_data
.data
;
121 prs_struct
*rdata
= &p
->out_data
.rdata
;
126 /* grab the reg open */
127 if(!reg_io_q_open_hive("", &q_u
, data
, 0))
130 r_u
.status
= _reg_open_hkcr(p
, &q_u
, &r_u
);
132 if(!reg_io_r_open_hive("", &r_u
, rdata
, 0))
139 /*******************************************************************
141 ********************************************************************/
143 static BOOL
api_reg_open_entry(pipes_struct
*p
)
145 REG_Q_OPEN_ENTRY q_u
;
146 REG_R_OPEN_ENTRY r_u
;
147 prs_struct
*data
= &p
->in_data
.data
;
148 prs_struct
*rdata
= &p
->out_data
.rdata
;
153 /* grab the reg open entry */
154 if(!reg_io_q_open_entry("", &q_u
, data
, 0))
157 /* construct reply. */
158 r_u
.status
= _reg_open_entry(p
, &q_u
, &r_u
);
160 if(!reg_io_r_open_entry("", &r_u
, rdata
, 0))
166 /*******************************************************************
168 ********************************************************************/
170 static BOOL
api_reg_query_value(pipes_struct
*p
)
172 REG_Q_QUERY_VALUE q_u
;
173 REG_R_QUERY_VALUE r_u
;
174 prs_struct
*data
= &p
->in_data
.data
;
175 prs_struct
*rdata
= &p
->out_data
.rdata
;
180 /* grab the reg unknown 0x11*/
181 if(!reg_io_q_query_value("", &q_u
, data
, 0))
184 r_u
.status
= _reg_query_value(p
, &q_u
, &r_u
);
186 if(!reg_io_r_query_value("", &r_u
, rdata
, 0))
192 /*******************************************************************
194 ********************************************************************/
196 static BOOL
api_reg_shutdown(pipes_struct
*p
)
200 prs_struct
*data
= &p
->in_data
.data
;
201 prs_struct
*rdata
= &p
->out_data
.rdata
;
206 /* grab the reg shutdown */
207 if(!reg_io_q_shutdown("", &q_u
, data
, 0))
210 r_u
.status
= _reg_shutdown(p
, &q_u
, &r_u
);
212 if(!reg_io_r_shutdown("", &r_u
, rdata
, 0))
218 /*******************************************************************
220 ********************************************************************/
222 static BOOL
api_reg_shutdown_ex(pipes_struct
*p
)
224 REG_Q_SHUTDOWN_EX q_u
;
225 REG_R_SHUTDOWN_EX r_u
;
226 prs_struct
*data
= &p
->in_data
.data
;
227 prs_struct
*rdata
= &p
->out_data
.rdata
;
232 /* grab the reg shutdown ex */
233 if(!reg_io_q_shutdown_ex("", &q_u
, data
, 0))
236 r_u
.status
= _reg_shutdown_ex(p
, &q_u
, &r_u
);
238 if(!reg_io_r_shutdown_ex("", &r_u
, rdata
, 0))
244 /*******************************************************************
245 api_reg_abort_shutdown
246 ********************************************************************/
248 static BOOL
api_reg_abort_shutdown(pipes_struct
*p
)
250 REG_Q_ABORT_SHUTDOWN q_u
;
251 REG_R_ABORT_SHUTDOWN r_u
;
252 prs_struct
*data
= &p
->in_data
.data
;
253 prs_struct
*rdata
= &p
->out_data
.rdata
;
258 /* grab the reg shutdown */
259 if(!reg_io_q_abort_shutdown("", &q_u
, data
, 0))
262 r_u
.status
= _reg_abort_shutdown(p
, &q_u
, &r_u
);
264 if(!reg_io_r_abort_shutdown("", &r_u
, rdata
, 0))
271 /*******************************************************************
273 ********************************************************************/
275 static BOOL
api_reg_query_key(pipes_struct
*p
)
279 prs_struct
*data
= &p
->in_data
.data
;
280 prs_struct
*rdata
= &p
->out_data
.rdata
;
285 if(!reg_io_q_query_key("", &q_u
, data
, 0))
288 r_u
.status
= _reg_query_key(p
, &q_u
, &r_u
);
290 if(!reg_io_r_query_key("", &r_u
, rdata
, 0))
296 /*******************************************************************
298 ********************************************************************/
300 static BOOL
api_reg_getversion(pipes_struct
*p
)
302 REG_Q_GETVERSION q_u
;
303 REG_R_GETVERSION r_u
;
304 prs_struct
*data
= &p
->in_data
.data
;
305 prs_struct
*rdata
= &p
->out_data
.rdata
;
310 if(!reg_io_q_getversion("", &q_u
, data
, 0))
313 r_u
.status
= _reg_getversion(p
, &q_u
, &r_u
);
315 if(!reg_io_r_getversion("", &r_u
, rdata
, 0))
321 /*******************************************************************
323 ********************************************************************/
325 static BOOL
api_reg_enum_key(pipes_struct
*p
)
329 prs_struct
*data
= &p
->in_data
.data
;
330 prs_struct
*rdata
= &p
->out_data
.rdata
;
335 if(!reg_io_q_enum_key("", &q_u
, data
, 0))
338 r_u
.status
= _reg_enum_key(p
, &q_u
, &r_u
);
340 if(!reg_io_r_enum_key("", &r_u
, rdata
, 0))
346 /*******************************************************************
348 ********************************************************************/
350 static BOOL
api_reg_enum_value(pipes_struct
*p
)
352 REG_Q_ENUM_VALUE q_u
;
353 REG_R_ENUM_VALUE r_u
;
354 prs_struct
*data
= &p
->in_data
.data
;
355 prs_struct
*rdata
= &p
->out_data
.rdata
;
360 if(!reg_io_q_enum_val("", &q_u
, data
, 0))
363 r_u
.status
= _reg_enum_value(p
, &q_u
, &r_u
);
365 if(!reg_io_r_enum_val("", &r_u
, rdata
, 0))
371 /*******************************************************************
372 ******************************************************************/
374 static BOOL
api_reg_restore_key(pipes_struct
*p
)
376 REG_Q_RESTORE_KEY q_u
;
377 REG_R_RESTORE_KEY r_u
;
378 prs_struct
*data
= &p
->in_data
.data
;
379 prs_struct
*rdata
= &p
->out_data
.rdata
;
384 if(!reg_io_q_restore_key("", &q_u
, data
, 0))
387 r_u
.status
= _reg_restore_key(p
, &q_u
, &r_u
);
389 if(!reg_io_r_restore_key("", &r_u
, rdata
, 0))
395 /*******************************************************************
396 ******************************************************************/
398 static BOOL
api_reg_save_key(pipes_struct
*p
)
402 prs_struct
*data
= &p
->in_data
.data
;
403 prs_struct
*rdata
= &p
->out_data
.rdata
;
408 if(!reg_io_q_save_key("", &q_u
, data
, 0))
411 r_u
.status
= _reg_save_key(p
, &q_u
, &r_u
);
413 if(!reg_io_r_save_key("", &r_u
, rdata
, 0))
419 /*******************************************************************
420 ******************************************************************/
422 static BOOL
api_reg_create_key(pipes_struct
*p
)
424 REG_Q_CREATE_KEY q_u
;
425 REG_R_CREATE_KEY r_u
;
426 prs_struct
*data
= &p
->in_data
.data
;
427 prs_struct
*rdata
= &p
->out_data
.rdata
;
432 if(!reg_io_q_create_key("", &q_u
, data
, 0))
435 r_u
.status
= _reg_create_key(p
, &q_u
, &r_u
);
437 if(!reg_io_r_create_key("", &r_u
, rdata
, 0))
443 /*******************************************************************
444 ******************************************************************/
446 static BOOL
api_reg_set_value(pipes_struct
*p
)
450 prs_struct
*data
= &p
->in_data
.data
;
451 prs_struct
*rdata
= &p
->out_data
.rdata
;
456 if(!reg_io_q_set_value("", &q_u
, data
, 0))
459 r_u
.status
= _reg_set_value(p
, &q_u
, &r_u
);
461 if(!reg_io_r_set_value("", &r_u
, rdata
, 0))
467 /*******************************************************************
468 ******************************************************************/
470 static BOOL
api_reg_delete_key(pipes_struct
*p
)
472 REG_Q_DELETE_KEY q_u
;
473 REG_R_DELETE_KEY r_u
;
474 prs_struct
*data
= &p
->in_data
.data
;
475 prs_struct
*rdata
= &p
->out_data
.rdata
;
480 if(!reg_io_q_delete_key("", &q_u
, data
, 0))
483 r_u
.status
= _reg_delete_key(p
, &q_u
, &r_u
);
485 if(!reg_io_r_delete_key("", &r_u
, rdata
, 0))
491 /*******************************************************************
492 ******************************************************************/
494 static BOOL
api_reg_delete_value(pipes_struct
*p
)
496 REG_Q_DELETE_VALUE q_u
;
497 REG_R_DELETE_VALUE r_u
;
498 prs_struct
*data
= &p
->in_data
.data
;
499 prs_struct
*rdata
= &p
->out_data
.rdata
;
504 if(!reg_io_q_delete_value("", &q_u
, data
, 0))
507 r_u
.status
= _reg_delete_value(p
, &q_u
, &r_u
);
509 if(!reg_io_r_delete_value("", &r_u
, rdata
, 0))
516 /*******************************************************************
517 ******************************************************************/
519 static BOOL
api_reg_get_key_sec(pipes_struct
*p
)
521 REG_Q_GET_KEY_SEC q_u
;
522 REG_R_GET_KEY_SEC r_u
;
523 prs_struct
*data
= &p
->in_data
.data
;
524 prs_struct
*rdata
= &p
->out_data
.rdata
;
529 if(!reg_io_q_get_key_sec("", &q_u
, data
, 0))
532 r_u
.status
= _reg_get_key_sec(p
, &q_u
, &r_u
);
534 if(!reg_io_r_get_key_sec("", &r_u
, rdata
, 0))
541 /*******************************************************************
542 ******************************************************************/
544 static BOOL
api_reg_set_key_sec(pipes_struct
*p
)
546 REG_Q_SET_KEY_SEC q_u
;
547 REG_R_SET_KEY_SEC r_u
;
548 prs_struct
*data
= &p
->in_data
.data
;
549 prs_struct
*rdata
= &p
->out_data
.rdata
;
554 if(!reg_io_q_set_key_sec("", &q_u
, data
, 0))
557 r_u
.status
= _reg_set_key_sec(p
, &q_u
, &r_u
);
559 if(!reg_io_r_set_key_sec("", &r_u
, rdata
, 0))
566 /*******************************************************************
567 array of \PIPE\reg operations
568 ********************************************************************/
570 static struct api_struct api_reg_cmds
[] =
572 { "REG_CLOSE" , REG_CLOSE
, api_reg_close
},
573 { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY
, api_reg_open_entry
},
574 { "REG_OPEN_HKCR" , REG_OPEN_HKCR
, api_reg_open_hkcr
},
575 { "REG_OPEN_HKLM" , REG_OPEN_HKLM
, api_reg_open_hklm
},
576 { "REG_OPEN_HKU" , REG_OPEN_HKU
, api_reg_open_hku
},
577 { "REG_ENUM_KEY" , REG_ENUM_KEY
, api_reg_enum_key
},
578 { "REG_ENUM_VALUE" , REG_ENUM_VALUE
, api_reg_enum_value
},
579 { "REG_QUERY_KEY" , REG_QUERY_KEY
, api_reg_query_key
},
580 { "REG_QUERY_VALUE" , REG_QUERY_VALUE
, api_reg_query_value
},
581 { "REG_SHUTDOWN" , REG_SHUTDOWN
, api_reg_shutdown
},
582 { "REG_SHUTDOWN_EX" , REG_SHUTDOWN_EX
, api_reg_shutdown_ex
},
583 { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN
, api_reg_abort_shutdown
},
584 { "REG_GETVERSION" , REG_GETVERSION
, api_reg_getversion
},
585 { "REG_SAVE_KEY" , REG_SAVE_KEY
, api_reg_save_key
},
586 { "REG_RESTORE_KEY" , REG_RESTORE_KEY
, api_reg_restore_key
},
587 { "REG_CREATE_KEY" , REG_CREATE_KEY
, api_reg_create_key
},
588 { "REG_SET_VALUE" , REG_SET_VALUE
, api_reg_set_value
},
589 { "REG_DELETE_KEY" , REG_DELETE_KEY
, api_reg_delete_key
},
590 { "REG_DELETE_VALUE" , REG_DELETE_VALUE
, api_reg_delete_value
},
591 { "REG_GET_KEY_SEC" , REG_GET_KEY_SEC
, api_reg_get_key_sec
},
592 { "REG_SET_KEY_SEC" , REG_SET_KEY_SEC
, api_reg_set_key_sec
}
595 void reg_get_pipe_fns( struct api_struct
**fns
, int *n_fns
)
598 *n_fns
= sizeof(api_reg_cmds
) / sizeof(struct api_struct
);
601 NTSTATUS
rpc_reg_init(void)
604 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION
, "winreg", "winreg", api_reg_cmds
,
605 sizeof(api_reg_cmds
) / sizeof(struct api_struct
));