* RPC Pipe client / server routines
*
* Copyright (C) Gerald (Jerry) Carter 2005.
+ * Copyright (C) Guenther Deschner 2008,2009.
*
* 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
*/
#include "includes.h"
+#include "../librpc/gen_ndr/srv_ntsvcs.h"
+#include "registry.h"
+#include "registry/reg_objects.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
{
char *devicepath;
- if (!r->in.devicename) {
- return WERR_ACCESS_DENIED;
+ if ((r->in.flags & CM_GETIDLIST_FILTER_SERVICE) &&
+ (!r->in.devicename)) {
+ return WERR_CM_INVALID_POINTER;
}
if (!(devicepath = get_device_path(p->mem_ctx, r->in.devicename))) {
return WERR_OK;
}
+/****************************************************************
+ _PNP_GetDeviceList
+****************************************************************/
-/********************************************************************
-********************************************************************/
-
-WERROR _ntsvcs_get_device_list( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST *q_u, NTSVCS_R_GET_DEVICE_LIST *r_u )
+WERROR _PNP_GetDeviceList(pipes_struct *p,
+ struct PNP_GetDeviceList *r)
{
- fstring device;
char *devicepath;
+ uint32_t size = 0;
+ const char **multi_sz = NULL;
+ DATA_BLOB blob;
- if ( !q_u->devicename )
- return WERR_ACCESS_DENIED;
+ if ((r->in.flags & CM_GETIDLIST_FILTER_SERVICE) &&
+ (!r->in.filter)) {
+ return WERR_CM_INVALID_POINTER;
+ }
- rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0);
+ if (!(devicepath = get_device_path(p->mem_ctx, r->in.filter))) {
+ return WERR_NOMEM;
+ }
- if (!(devicepath = get_device_path(p->mem_ctx, device))) {
+ size = strlen(devicepath) + 2;
+
+ if (*r->in.length < size) {
+ return WERR_CM_BUFFER_SMALL;
+ }
+
+ multi_sz = talloc_zero_array(p->mem_ctx, const char *, 2);
+ if (!multi_sz) {
return WERR_NOMEM;
}
- /* This has to be DOUBLE NULL terminated */
+ multi_sz[0] = devicepath;
- init_unistr2( &r_u->devicepath, devicepath, UNI_STR_DBLTERMINATE );
- TALLOC_FREE(devicepath);
- r_u->needed = r_u->devicepath.uni_str_len;
+ if (!push_reg_multi_sz(multi_sz, &blob, multi_sz)) {
+ return WERR_NOMEM;
+ }
+
+ if (*r->in.length < blob.length/2) {
+ return WERR_CM_BUFFER_SMALL;
+ }
+
+ memcpy(r->out.buffer, blob.data, blob.length);
return WERR_OK;
}
struct PNP_GetDeviceRegProp *r)
{
char *ptr;
- REGVAL_CTR *values;
- REGISTRY_VALUE *val;
+ struct regval_ctr *values;
+ struct regval_blob *val;
switch( r->in.property ) {
case DEV_REGPROP_DESC:
return WERR_GENERAL_FAILURE;
}
- if (*r->in.buffer_size < val->size) {
- *r->out.needed = val->size;
+ if (*r->in.buffer_size < regval_size(val)) {
+ *r->out.needed = regval_size(val);
*r->out.buffer_size = 0;
TALLOC_FREE( values );
return WERR_CM_BUFFER_SMALL;
}
- r->out.buffer = (uint8_t *)talloc_memdup(p->mem_ctx, val->data_p, val->size);
+ r->out.buffer = (uint8_t *)talloc_memdup(p->mem_ctx, regval_data_p(val), regval_size(val));
TALLOC_FREE(values);
if (!r->out.buffer) {
return WERR_NOMEM;
}
*r->out.reg_data_type = REG_SZ; /* always 1...tested using a remove device manager connection */
- *r->out.buffer_size = val->size;
- *r->out.needed = val->size;
+ *r->out.buffer_size = regval_size(val);
+ *r->out.needed = regval_size(val);
break;
/****************************************************************
****************************************************************/
-WERROR _PNP_GetDeviceList(pipes_struct *p,
- struct PNP_GetDeviceList *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
-****************************************************************/
-
WERROR _PNP_GetDepth(pipes_struct *p,
struct PNP_GetDepth *r)
{