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/ndr_ntsvcs_c.h"
25 static WERROR cmd_ntsvcs_get_version(struct rpc_pipe_client *cli,
30 struct dcerpc_binding_handle *b = cli->binding_handle;
35 status = dcerpc_PNP_GetVersion(b, mem_ctx,
37 if (!NT_STATUS_IS_OK(status)) {
38 return ntstatus_to_werror(status);
41 if (W_ERROR_IS_OK(werr)) {
42 printf("version: %d\n", version);
48 static WERROR cmd_ntsvcs_validate_dev_inst(struct rpc_pipe_client *cli,
53 struct dcerpc_binding_handle *b = cli->binding_handle;
56 const char *devicepath = NULL;
59 if (argc < 2 || argc > 3) {
60 printf("usage: %s [devicepath] <flags>\n", argv[0]);
67 flags = atoi(argv[2]);
70 status = dcerpc_PNP_ValidateDeviceInstance(b, mem_ctx,
74 if (!NT_STATUS_IS_OK(status)) {
75 return ntstatus_to_werror(status);
81 static WERROR cmd_ntsvcs_hw_prof_flags(struct rpc_pipe_client *cli,
86 struct dcerpc_binding_handle *b = cli->binding_handle;
89 const char *devicepath = NULL;
90 uint32_t profile_flags = 0;
91 uint16_t veto_type = 0;
92 const char *unk5 = NULL;
93 const char *unk5a = NULL;
96 printf("usage: %s [devicepath]\n", argv[0]);
100 devicepath = argv[1];
102 status = dcerpc_PNP_HwProfFlags(b, mem_ctx,
113 if (!NT_STATUS_IS_OK(status)) {
114 return ntstatus_to_werror(status);
120 static WERROR cmd_ntsvcs_get_hw_prof_info(struct rpc_pipe_client *cli,
125 struct dcerpc_binding_handle *b = cli->binding_handle;
129 struct PNP_HwProfInfo info;
130 uint32_t size = 0, flags = 0;
134 status = dcerpc_PNP_GetHwProfInfo(b, mem_ctx,
140 if (!NT_STATUS_IS_OK(status)) {
141 return ntstatus_to_werror(status);
147 static WERROR cmd_ntsvcs_get_dev_reg_prop(struct rpc_pipe_client *cli,
152 struct dcerpc_binding_handle *b = cli->binding_handle;
155 const char *devicepath = NULL;
156 uint32_t property = DEV_REGPROP_DESC;
157 uint32_t reg_data_type = REG_NONE;
159 uint32_t buffer_size = 0;
164 printf("usage: %s [devicepath] [buffersize]\n", argv[0]);
168 devicepath = argv[1];
171 buffer_size = atoi(argv[2]);
172 needed = buffer_size;
175 buffer = talloc_array(mem_ctx, uint8_t, buffer_size);
176 W_ERROR_HAVE_NO_MEMORY(buffer);
178 status = dcerpc_PNP_GetDeviceRegProp(b, mem_ctx,
187 if (!NT_STATUS_IS_OK(status)) {
188 return ntstatus_to_werror(status);
194 static WERROR cmd_ntsvcs_get_dev_list_size(struct rpc_pipe_client *cli,
199 struct dcerpc_binding_handle *b = cli->binding_handle;
204 const char *filter = NULL;
207 printf("usage: %s [filter] [flags]\n", argv[0]);
216 flags = atoi(argv[2]);
219 status = dcerpc_PNP_GetDeviceListSize(b, mem_ctx,
224 if (!NT_STATUS_IS_OK(status)) {
225 return ntstatus_to_werror(status);
228 printf("size: %d\n", size);
233 static WERROR cmd_ntsvcs_get_dev_list(struct rpc_pipe_client *cli,
238 struct dcerpc_binding_handle *b = cli->binding_handle;
241 const char *filter = NULL;
242 uint16_t *buffer = NULL;
247 printf("usage: %s [filter] [length] [flags]\n", argv[0]);
256 length = atoi(argv[2]);
260 flags = atoi(argv[3]);
263 buffer = talloc(mem_ctx, uint16_t);
265 return WERR_NOT_ENOUGH_MEMORY;
268 status = dcerpc_PNP_GetDeviceList(b, mem_ctx,
274 if (!NT_STATUS_IS_OK(status)) {
275 return ntstatus_to_werror(status);
278 printf("devlist needs size: %d\n", length);
283 struct cmd_set ntsvcs_commands[] = {
289 .name = "ntsvcs_getversion",
290 .returntype = RPC_RTYPE_WERROR,
292 .wfn = cmd_ntsvcs_get_version,
293 .table = &ndr_table_ntsvcs,
295 .description = "Query NTSVCS version",
299 .name = "ntsvcs_validatedevinst",
300 .returntype = RPC_RTYPE_WERROR,
302 .wfn = cmd_ntsvcs_validate_dev_inst,
303 .table = &ndr_table_ntsvcs,
305 .description = "Query NTSVCS device instance",
309 .name = "ntsvcs_hwprofflags",
310 .returntype = RPC_RTYPE_WERROR,
312 .wfn = cmd_ntsvcs_hw_prof_flags,
313 .table = &ndr_table_ntsvcs,
315 .description = "Query NTSVCS HW prof flags",
319 .name = "ntsvcs_hwprofinfo",
320 .returntype = RPC_RTYPE_WERROR,
322 .wfn = cmd_ntsvcs_get_hw_prof_info,
323 .table = &ndr_table_ntsvcs,
325 .description = "Query NTSVCS HW prof info",
329 .name = "ntsvcs_getdevregprop",
330 .returntype = RPC_RTYPE_WERROR,
332 .wfn = cmd_ntsvcs_get_dev_reg_prop,
333 .table = &ndr_table_ntsvcs,
335 .description = "Query NTSVCS device registry property",
339 .name = "ntsvcs_getdevlistsize",
340 .returntype = RPC_RTYPE_WERROR,
342 .wfn = cmd_ntsvcs_get_dev_list_size,
343 .table = &ndr_table_ntsvcs,
345 .description = "Query NTSVCS device list size",
349 .name = "ntsvcs_getdevlist",
350 .returntype = RPC_RTYPE_WERROR,
352 .wfn = cmd_ntsvcs_get_dev_list,
353 .table = &ndr_table_ntsvcs,
355 .description = "Query NTSVCS device list",