2 Unix SMB/CIFS implementation.
5 Copyright (C) Günther Deschner 2008
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 3 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, see <http://www.gnu.org/licenses/>.
22 #include "rpcclient.h"
23 #include "../librpc/gen_ndr/cli_ntsvcs.h"
25 static WERROR
cmd_ntsvcs_get_version(struct rpc_pipe_client
*cli
,
34 status
= rpccli_PNP_GetVersion(cli
, mem_ctx
,
36 if (!NT_STATUS_IS_OK(status
)) {
37 return ntstatus_to_werror(status
);
40 if (W_ERROR_IS_OK(werr
)) {
41 printf("version: %d\n", version
);
47 static WERROR
cmd_ntsvcs_validate_dev_inst(struct rpc_pipe_client
*cli
,
54 const char *devicepath
= NULL
;
57 if (argc
< 2 || argc
> 3) {
58 printf("usage: %s [devicepath] <flags>\n", argv
[0]);
65 flags
= atoi(argv
[2]);
68 status
= rpccli_PNP_ValidateDeviceInstance(cli
, mem_ctx
,
72 if (!NT_STATUS_IS_OK(status
)) {
73 return ntstatus_to_werror(status
);
79 static WERROR
cmd_ntsvcs_hw_prof_flags(struct rpc_pipe_client
*cli
,
86 const char *devicepath
= NULL
;
87 uint32_t profile_flags
= 0;
88 uint16_t veto_type
= 0;
89 const char *unk5
= NULL
;
90 const char *unk5a
= NULL
;
93 printf("usage: %s [devicepath]\n", argv
[0]);
99 status
= rpccli_PNP_HwProfFlags(cli
, mem_ctx
,
110 if (!NT_STATUS_IS_OK(status
)) {
111 return ntstatus_to_werror(status
);
117 static WERROR
cmd_ntsvcs_get_hw_prof_info(struct rpc_pipe_client
*cli
,
125 struct PNP_HwProfInfo info
;
126 uint32_t size
= 0, flags
= 0;
130 status
= rpccli_PNP_GetHwProfInfo(cli
, mem_ctx
,
136 if (!NT_STATUS_IS_OK(status
)) {
137 return ntstatus_to_werror(status
);
143 static WERROR
cmd_ntsvcs_get_dev_reg_prop(struct rpc_pipe_client
*cli
,
150 const char *devicepath
= NULL
;
151 uint32_t property
= DEV_REGPROP_DESC
;
152 uint32_t reg_data_type
= REG_NONE
;
154 uint32_t buffer_size
= 0;
159 printf("usage: %s [devicepath] [buffersize]\n", argv
[0]);
163 devicepath
= argv
[1];
166 buffer_size
= atoi(argv
[2]);
167 needed
= buffer_size
;
170 buffer
= talloc_array(mem_ctx
, uint8_t, buffer_size
);
171 W_ERROR_HAVE_NO_MEMORY(buffer
);
173 status
= rpccli_PNP_GetDeviceRegProp(cli
, mem_ctx
,
182 if (!NT_STATUS_IS_OK(status
)) {
183 return ntstatus_to_werror(status
);
189 static WERROR
cmd_ntsvcs_get_dev_list_size(struct rpc_pipe_client
*cli
,
198 const char *filter
= NULL
;
201 printf("usage: %s [filter] [flags]\n", argv
[0]);
210 flags
= atoi(argv
[2]);
213 status
= rpccli_PNP_GetDeviceListSize(cli
, mem_ctx
,
218 if (!NT_STATUS_IS_OK(status
)) {
219 return ntstatus_to_werror(status
);
222 printf("size: %d\n", size
);
227 static WERROR
cmd_ntsvcs_get_dev_list(struct rpc_pipe_client
*cli
,
234 const char *filter
= NULL
;
235 uint16_t *buffer
= NULL
;
240 printf("usage: %s [filter] [length] [flags]\n", argv
[0]);
249 length
= atoi(argv
[2]);
253 flags
= atoi(argv
[3]);
256 buffer
= talloc(mem_ctx
, uint16_t);
261 status
= rpccli_PNP_GetDeviceList(cli
, mem_ctx
,
267 if (!NT_STATUS_IS_OK(status
)) {
268 return ntstatus_to_werror(status
);
271 printf("devlist needs size: %d\n", length
);
276 struct cmd_set ntsvcs_commands
[] = {
279 { "ntsvcs_getversion", RPC_RTYPE_WERROR
, NULL
, cmd_ntsvcs_get_version
, &ndr_table_ntsvcs
.syntax_id
, NULL
, "Query NTSVCS version", "" },
280 { "ntsvcs_validatedevinst", RPC_RTYPE_WERROR
, NULL
, cmd_ntsvcs_validate_dev_inst
, &ndr_table_ntsvcs
.syntax_id
, NULL
, "Query NTSVCS device instance", "" },
281 { "ntsvcs_hwprofflags", RPC_RTYPE_WERROR
, NULL
, cmd_ntsvcs_hw_prof_flags
, &ndr_table_ntsvcs
.syntax_id
, NULL
, "Query NTSVCS HW prof flags", "" },
282 { "ntsvcs_hwprofinfo", RPC_RTYPE_WERROR
, NULL
, cmd_ntsvcs_get_hw_prof_info
, &ndr_table_ntsvcs
.syntax_id
, NULL
, "Query NTSVCS HW prof info", "" },
283 { "ntsvcs_getdevregprop", RPC_RTYPE_WERROR
, NULL
, cmd_ntsvcs_get_dev_reg_prop
, &ndr_table_ntsvcs
.syntax_id
, NULL
, "Query NTSVCS device registry property", "" },
284 { "ntsvcs_getdevlistsize", RPC_RTYPE_WERROR
, NULL
, cmd_ntsvcs_get_dev_list_size
, &ndr_table_ntsvcs
.syntax_id
, NULL
, "Query NTSVCS device list size", "" },
285 { "ntsvcs_getdevlist", RPC_RTYPE_WERROR
, NULL
, cmd_ntsvcs_get_dev_list
, &ndr_table_ntsvcs
.syntax_id
, NULL
, "Query NTSVCS device list", "" },