LCOV - code coverage report
Current view: top level - source3/rpcclient - cmd_ntsvcs.c (source / functions) Hit Total Coverage
Test: coverage report for master 2b515b7d Lines: 0 107 0.0 %
Date: 2024-02-28 12:06:22 Functions: 0 7 0.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    RPC pipe client
       4             : 
       5             :    Copyright (C) Günther Deschner 2008
       6             : 
       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.
      11             : 
      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.
      16             : 
      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/>.
      19             : */
      20             : 
      21             : #include "includes.h"
      22             : #include "rpcclient.h"
      23             : #include "../librpc/gen_ndr/ndr_ntsvcs_c.h"
      24             : 
      25           0 : static WERROR cmd_ntsvcs_get_version(struct rpc_pipe_client *cli,
      26             :                                      TALLOC_CTX *mem_ctx,
      27             :                                      int argc,
      28             :                                      const char **argv)
      29             : {
      30           0 :         struct dcerpc_binding_handle *b = cli->binding_handle;
      31             :         NTSTATUS status;
      32             :         WERROR werr;
      33             :         uint16_t version;
      34             : 
      35           0 :         status = dcerpc_PNP_GetVersion(b, mem_ctx,
      36             :                                        &version, &werr);
      37           0 :         if (!NT_STATUS_IS_OK(status)) {
      38           0 :                 return ntstatus_to_werror(status);
      39             :         }
      40             : 
      41           0 :         if (W_ERROR_IS_OK(werr)) {
      42           0 :                 printf("version: %d\n", version);
      43             :         }
      44             : 
      45           0 :         return werr;
      46             : }
      47             : 
      48           0 : static WERROR cmd_ntsvcs_validate_dev_inst(struct rpc_pipe_client *cli,
      49             :                                            TALLOC_CTX *mem_ctx,
      50             :                                            int argc,
      51             :                                            const char **argv)
      52             : {
      53           0 :         struct dcerpc_binding_handle *b = cli->binding_handle;
      54             :         NTSTATUS status;
      55             :         WERROR werr;
      56           0 :         const char *devicepath = NULL;
      57           0 :         uint32_t flags = 0;
      58             : 
      59           0 :         if (argc < 2 || argc > 3) {
      60           0 :                 printf("usage: %s [devicepath] <flags>\n", argv[0]);
      61           0 :                 return WERR_OK;
      62             :         }
      63             : 
      64           0 :         devicepath = argv[1];
      65             : 
      66           0 :         if (argc >= 3) {
      67           0 :                 flags = atoi(argv[2]);
      68             :         }
      69             : 
      70           0 :         status = dcerpc_PNP_ValidateDeviceInstance(b, mem_ctx,
      71             :                                                    devicepath,
      72             :                                                    flags,
      73             :                                                    &werr);
      74           0 :         if (!NT_STATUS_IS_OK(status)) {
      75           0 :                 return ntstatus_to_werror(status);
      76             :         }
      77             : 
      78           0 :         return werr;
      79             : }
      80             : 
      81           0 : static WERROR cmd_ntsvcs_hw_prof_flags(struct rpc_pipe_client *cli,
      82             :                                        TALLOC_CTX *mem_ctx,
      83             :                                        int argc,
      84             :                                        const char **argv)
      85             : {
      86           0 :         struct dcerpc_binding_handle *b = cli->binding_handle;
      87             :         NTSTATUS status;
      88             :         WERROR werr;
      89           0 :         const char *devicepath = NULL;
      90           0 :         uint32_t profile_flags = 0;
      91           0 :         uint16_t veto_type = 0;
      92           0 :         const char *unk5 = NULL;
      93           0 :         const char *unk5a = NULL;
      94             : 
      95           0 :         if (argc < 2) {
      96           0 :                 printf("usage: %s [devicepath]\n", argv[0]);
      97           0 :                 return WERR_OK;
      98             :         }
      99             : 
     100           0 :         devicepath = argv[1];
     101             : 
     102           0 :         status = dcerpc_PNP_HwProfFlags(b, mem_ctx,
     103             :                                         0,
     104             :                                         devicepath,
     105             :                                         0,
     106             :                                         &profile_flags,
     107             :                                         &veto_type,
     108             :                                         unk5,
     109             :                                         &unk5a,
     110             :                                         0,
     111             :                                         0,
     112             :                                         &werr);
     113           0 :         if (!NT_STATUS_IS_OK(status)) {
     114           0 :                 return ntstatus_to_werror(status);
     115             :         }
     116             : 
     117           0 :         return werr;
     118             : }
     119             : 
     120           0 : static WERROR cmd_ntsvcs_get_hw_prof_info(struct rpc_pipe_client *cli,
     121             :                                           TALLOC_CTX *mem_ctx,
     122             :                                           int argc,
     123             :                                           const char **argv)
     124             : {
     125           0 :         struct dcerpc_binding_handle *b = cli->binding_handle;
     126             :         NTSTATUS status;
     127             :         WERROR werr;
     128           0 :         uint32_t idx = 0;
     129             :         struct PNP_HwProfInfo info;
     130           0 :         uint32_t size = 0, flags = 0;
     131             : 
     132           0 :         ZERO_STRUCT(info);
     133             : 
     134           0 :         status = dcerpc_PNP_GetHwProfInfo(b, mem_ctx,
     135             :                                           idx,
     136             :                                           &info,
     137             :                                           size,
     138             :                                           flags,
     139             :                                           &werr);
     140           0 :         if (!NT_STATUS_IS_OK(status)) {
     141           0 :                 return ntstatus_to_werror(status);
     142             :         }
     143             : 
     144           0 :         return werr;
     145             : }
     146             : 
     147           0 : static WERROR cmd_ntsvcs_get_dev_reg_prop(struct rpc_pipe_client *cli,
     148             :                                           TALLOC_CTX *mem_ctx,
     149             :                                           int argc,
     150             :                                           const char **argv)
     151             : {
     152           0 :         struct dcerpc_binding_handle *b = cli->binding_handle;
     153             :         NTSTATUS status;
     154             :         WERROR werr;
     155           0 :         const char *devicepath = NULL;
     156           0 :         uint32_t property = DEV_REGPROP_DESC;
     157           0 :         uint32_t reg_data_type = REG_NONE;
     158             :         uint8_t *buffer;
     159           0 :         uint32_t buffer_size = 0;
     160           0 :         uint32_t needed = 0;
     161           0 :         uint32_t flags = 0;
     162             : 
     163           0 :         if (argc < 2) {
     164           0 :                 printf("usage: %s [devicepath] [buffersize]\n", argv[0]);
     165           0 :                 return WERR_OK;
     166             :         }
     167             : 
     168           0 :         devicepath = argv[1];
     169             : 
     170           0 :         if (argc >= 3) {
     171           0 :                 buffer_size = atoi(argv[2]);
     172           0 :                 needed = buffer_size;
     173             :         }
     174             : 
     175           0 :         buffer = talloc_array(mem_ctx, uint8_t, buffer_size);
     176           0 :         W_ERROR_HAVE_NO_MEMORY(buffer);
     177             : 
     178           0 :         status = dcerpc_PNP_GetDeviceRegProp(b, mem_ctx,
     179             :                                              devicepath,
     180             :                                              property,
     181             :                                              &reg_data_type,
     182             :                                              buffer,
     183             :                                              &buffer_size,
     184             :                                              &needed,
     185             :                                              flags,
     186             :                                              &werr);
     187           0 :         if (!NT_STATUS_IS_OK(status)) {
     188           0 :                 return ntstatus_to_werror(status);
     189             :         }
     190             : 
     191           0 :         return werr;
     192             : }
     193             : 
     194           0 : static WERROR cmd_ntsvcs_get_dev_list_size(struct rpc_pipe_client *cli,
     195             :                                            TALLOC_CTX *mem_ctx,
     196             :                                            int argc,
     197             :                                            const char **argv)
     198             : {
     199           0 :         struct dcerpc_binding_handle *b = cli->binding_handle;
     200             :         NTSTATUS status;
     201             :         WERROR werr;
     202           0 :         uint32_t size = 0;
     203           0 :         uint32_t flags = 0;
     204           0 :         const char *filter = NULL;
     205             : 
     206           0 :         if (argc > 3) {
     207           0 :                 printf("usage: %s [filter] [flags]\n", argv[0]);
     208           0 :                 return WERR_OK;
     209             :         }
     210             : 
     211           0 :         if (argc >= 2) {
     212           0 :                 filter = argv[1];
     213             :         }
     214             : 
     215           0 :         if (argc >= 3) {
     216           0 :                 flags = atoi(argv[2]);
     217             :         }
     218             : 
     219           0 :         status = dcerpc_PNP_GetDeviceListSize(b, mem_ctx,
     220             :                                               filter,
     221             :                                               &size,
     222             :                                               flags,
     223             :                                               &werr);
     224           0 :         if (!NT_STATUS_IS_OK(status)) {
     225           0 :                 return ntstatus_to_werror(status);
     226             :         }
     227             : 
     228           0 :         printf("size: %d\n", size);
     229             : 
     230           0 :         return werr;
     231             : }
     232             : 
     233           0 : static WERROR cmd_ntsvcs_get_dev_list(struct rpc_pipe_client *cli,
     234             :                                       TALLOC_CTX *mem_ctx,
     235             :                                       int argc,
     236             :                                       const char **argv)
     237             : {
     238           0 :         struct dcerpc_binding_handle *b = cli->binding_handle;
     239             :         NTSTATUS status;
     240             :         WERROR werr;
     241           0 :         const char *filter = NULL;
     242           0 :         uint16_t *buffer = NULL;
     243           0 :         uint32_t length = 0;
     244           0 :         uint32_t flags = 0;
     245             : 
     246           0 :         if (argc > 4) {
     247           0 :                 printf("usage: %s [filter] [length] [flags]\n", argv[0]);
     248           0 :                 return WERR_OK;
     249             :         }
     250             : 
     251           0 :         if (argc >= 2) {
     252           0 :                 filter = argv[1];
     253             :         }
     254             : 
     255           0 :         if (argc >= 3) {
     256           0 :                 length = atoi(argv[2]);
     257             :         }
     258             : 
     259           0 :         if (argc >= 4) {
     260           0 :                 flags = atoi(argv[3]);
     261             :         }
     262             : 
     263           0 :         buffer = talloc(mem_ctx, uint16_t);
     264           0 :         if (!buffer) {
     265           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     266             :         }
     267             : 
     268           0 :         status = dcerpc_PNP_GetDeviceList(b, mem_ctx,
     269             :                                           filter,
     270             :                                           buffer,
     271             :                                           &length,
     272             :                                           flags,
     273             :                                           &werr);
     274           0 :         if (!NT_STATUS_IS_OK(status)) {
     275           0 :                 return ntstatus_to_werror(status);
     276             :         }
     277             : 
     278           0 :         printf("devlist needs size: %d\n", length);
     279             : 
     280           0 :         return werr;
     281             : }
     282             : 
     283             : struct cmd_set ntsvcs_commands[] = {
     284             : 
     285             :         {
     286             :                 .name = "NTSVCS",
     287             :         },
     288             :         {
     289             :                 .name               = "ntsvcs_getversion",
     290             :                 .returntype         = RPC_RTYPE_WERROR,
     291             :                 .ntfn               = NULL,
     292             :                 .wfn                = cmd_ntsvcs_get_version,
     293             :                 .table              = &ndr_table_ntsvcs,
     294             :                 .rpc_pipe           = NULL,
     295             :                 .description        = "Query NTSVCS version",
     296             :                 .usage              = "",
     297             :         },
     298             :         {
     299             :                 .name               = "ntsvcs_validatedevinst",
     300             :                 .returntype         = RPC_RTYPE_WERROR,
     301             :                 .ntfn               = NULL,
     302             :                 .wfn                = cmd_ntsvcs_validate_dev_inst,
     303             :                 .table              = &ndr_table_ntsvcs,
     304             :                 .rpc_pipe           = NULL,
     305             :                 .description        = "Query NTSVCS device instance",
     306             :                 .usage              = "",
     307             :         },
     308             :         {
     309             :                 .name               = "ntsvcs_hwprofflags",
     310             :                 .returntype         = RPC_RTYPE_WERROR,
     311             :                 .ntfn               = NULL,
     312             :                 .wfn                = cmd_ntsvcs_hw_prof_flags,
     313             :                 .table              = &ndr_table_ntsvcs,
     314             :                 .rpc_pipe           = NULL,
     315             :                 .description        = "Query NTSVCS HW prof flags",
     316             :                 .usage              = "",
     317             :         },
     318             :         {
     319             :                 .name               = "ntsvcs_hwprofinfo",
     320             :                 .returntype         = RPC_RTYPE_WERROR,
     321             :                 .ntfn               = NULL,
     322             :                 .wfn                = cmd_ntsvcs_get_hw_prof_info,
     323             :                 .table              = &ndr_table_ntsvcs,
     324             :                 .rpc_pipe           = NULL,
     325             :                 .description        = "Query NTSVCS HW prof info",
     326             :                 .usage              = "",
     327             :         },
     328             :         {
     329             :                 .name               = "ntsvcs_getdevregprop",
     330             :                 .returntype         = RPC_RTYPE_WERROR,
     331             :                 .ntfn               = NULL,
     332             :                 .wfn                = cmd_ntsvcs_get_dev_reg_prop,
     333             :                 .table              = &ndr_table_ntsvcs,
     334             :                 .rpc_pipe           = NULL,
     335             :                 .description        = "Query NTSVCS device registry property",
     336             :                 .usage              = "",
     337             :         },
     338             :         {
     339             :                 .name               = "ntsvcs_getdevlistsize",
     340             :                 .returntype         = RPC_RTYPE_WERROR,
     341             :                 .ntfn               = NULL,
     342             :                 .wfn                = cmd_ntsvcs_get_dev_list_size,
     343             :                 .table              = &ndr_table_ntsvcs,
     344             :                 .rpc_pipe           = NULL,
     345             :                 .description        = "Query NTSVCS device list size",
     346             :                 .usage              = "",
     347             :         },
     348             :         {
     349             :                 .name               = "ntsvcs_getdevlist",
     350             :                 .returntype         = RPC_RTYPE_WERROR,
     351             :                 .ntfn               = NULL,
     352             :                 .wfn                = cmd_ntsvcs_get_dev_list,
     353             :                 .table              = &ndr_table_ntsvcs,
     354             :                 .rpc_pipe           = NULL,
     355             :                 .description        = "Query NTSVCS device list",
     356             :                 .usage              = "",
     357             :         },
     358             :         {
     359             :                 .name = NULL,
     360             :         },
     361             : };

Generated by: LCOV version 1.14