2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
5 * Copyright (C) Gerald (Jerry) Carter 2005.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #define DBGC_CLASS DBGC_RPC_SRV
27 /********************************************************************
28 ********************************************************************/
30 static char* get_device_path(TALLOC_CTX
*mem_ctx
, const char *device
)
32 return talloc_asprintf(mem_ctx
, "ROOT\\Legacy_%s\\0000", device
);
35 /********************************************************************
36 ********************************************************************/
38 WERROR
_ntsvcs_get_version( pipes_struct
*p
, NTSVCS_Q_GET_VERSION
*q_u
, NTSVCS_R_GET_VERSION
*r_u
)
40 r_u
->version
= 0x00000400; /* no idea what this means */
45 /********************************************************************
46 ********************************************************************/
48 WERROR
_ntsvcs_get_device_list_size( pipes_struct
*p
, NTSVCS_Q_GET_DEVICE_LIST_SIZE
*q_u
, NTSVCS_R_GET_DEVICE_LIST_SIZE
*r_u
)
53 if ( !q_u
->devicename
)
54 return WERR_ACCESS_DENIED
;
56 rpcstr_pull(device
, q_u
->devicename
->buffer
, sizeof(device
), q_u
->devicename
->uni_str_len
*2, 0);
58 if (!(devicepath
= get_device_path(p
->mem_ctx
, device
))) {
62 r_u
->size
= strlen(devicepath
) + 2;
64 TALLOC_FREE(devicepath
);
70 /********************************************************************
71 ********************************************************************/
73 WERROR
_ntsvcs_get_device_list( pipes_struct
*p
, NTSVCS_Q_GET_DEVICE_LIST
*q_u
, NTSVCS_R_GET_DEVICE_LIST
*r_u
)
78 if ( !q_u
->devicename
)
79 return WERR_ACCESS_DENIED
;
81 rpcstr_pull(device
, q_u
->devicename
->buffer
, sizeof(device
), q_u
->devicename
->uni_str_len
*2, 0);
83 if (!(devicepath
= get_device_path(p
->mem_ctx
, device
))) {
87 /* This has to be DOUBLE NULL terminated */
89 init_unistr2( &r_u
->devicepath
, devicepath
, UNI_STR_DBLTERMINATE
);
90 TALLOC_FREE(devicepath
);
91 r_u
->needed
= r_u
->devicepath
.uni_str_len
;
96 /********************************************************************
97 ********************************************************************/
99 WERROR
_ntsvcs_get_device_reg_property( pipes_struct
*p
, NTSVCS_Q_GET_DEVICE_REG_PROPERTY
*q_u
, NTSVCS_R_GET_DEVICE_REG_PROPERTY
*r_u
)
106 rpcstr_pull(devicepath
, q_u
->devicepath
.buffer
, sizeof(devicepath
), q_u
->devicepath
.uni_str_len
*2, 0);
108 switch( q_u
->property
) {
109 case DEV_REGPROP_DESC
:
110 /* just parse the service name from the device path and then
111 lookup the display name */
112 if ( !(ptr
= strrchr_m( devicepath
, '\\' )) )
113 return WERR_GENERAL_FAILURE
;
116 if ( !(ptr
= strrchr_m( devicepath
, '_' )) )
117 return WERR_GENERAL_FAILURE
;
120 if ( !(values
= svcctl_fetch_regvalues( ptr
, p
->pipe_user
.nt_user_token
)) )
121 return WERR_GENERAL_FAILURE
;
123 if ( !(val
= regval_ctr_getvalue( values
, "DisplayName" )) ) {
124 TALLOC_FREE( values
);
125 return WERR_GENERAL_FAILURE
;
128 r_u
->unknown1
= 0x1; /* always 1...tested using a remove device manager connection */
129 r_u
->size
= reg_init_regval_buffer( &r_u
->value
, val
);
130 r_u
->needed
= r_u
->size
;
137 r_u
->unknown1
= 0x00437c98;
138 return WERR_CM_NO_SUCH_VALUE
;
144 /********************************************************************
145 ********************************************************************/
147 WERROR
_ntsvcs_validate_device_instance( pipes_struct
*p
, NTSVCS_Q_VALIDATE_DEVICE_INSTANCE
*q_u
, NTSVCS_R_VALIDATE_DEVICE_INSTANCE
*r_u
)
153 /********************************************************************
154 ********************************************************************/
156 WERROR
_ntsvcs_get_hw_profile_info( pipes_struct
*p
, NTSVCS_Q_GET_HW_PROFILE_INFO
*q_u
, NTSVCS_R_GET_HW_PROFILE_INFO
*r_u
)
158 /* steal the incoming buffer */
160 r_u
->buffer_size
= q_u
->buffer_size
;
161 r_u
->buffer
= q_u
->buffer
;
163 /* Take the 5th Ammentment */
165 return WERR_CM_NO_MORE_HW_PROFILES
;
168 /********************************************************************
169 ********************************************************************/
171 WERROR
_ntsvcs_hw_profile_flags( pipes_struct
*p
, NTSVCS_Q_HW_PROFILE_FLAGS
*q_u
, NTSVCS_R_HW_PROFILE_FLAGS
*r_u
)
173 /* just nod your head */