static bool test_PNP_GetDeviceListSize(struct torture_context *tctx, struct dcerpc_pipe *p) { struct PNP_GetDeviceListSize r; uint32_t size = 0; r.in.devicename = NULL; r.in.flags = CM_GETIDLIST_FILTER_SERVICE; r.out.size = &size; torture_assert_ntstatus_ok(tctx, dcerpc_PNP_GetDeviceListSize(p, tctx, &r), "PNP_GetDeviceListSize"); torture_assert_werr_equal(tctx, r.out.result, WERR_CM_INVALID_POINTER, "PNP_GetDeviceListSize"); r.in.devicename = "Spooler"; torture_assert_ntstatus_ok(tctx, dcerpc_PNP_GetDeviceListSize(p, tctx, &r), "PNP_GetDeviceListSize"); torture_assert_werr_ok(tctx, r.out.result, "PNP_GetDeviceListSize"); return true; }
static bool test_PNP_GetDeviceList(struct torture_context *tctx, struct dcerpc_pipe *p) { struct PNP_GetDeviceList r; uint16_t *buffer = NULL; uint32_t length = 0; buffer = talloc_array(tctx, uint16_t, 0); r.in.filter = NULL; r.in.flags = CM_GETIDLIST_FILTER_SERVICE; r.in.length = &length; r.out.length = &length; r.out.buffer = buffer; torture_assert_ntstatus_ok(tctx, dcerpc_PNP_GetDeviceList(p, tctx, &r), "PNP_GetDeviceList failed"); torture_assert_werr_equal(tctx, r.out.result, WERR_CM_INVALID_POINTER, "PNP_GetDeviceList failed"); r.in.filter = "Spooler"; torture_assert_ntstatus_ok(tctx, dcerpc_PNP_GetDeviceList(p, tctx, &r), "PNP_GetDeviceList failed"); if (W_ERROR_EQUAL(r.out.result, WERR_CM_BUFFER_SMALL)) { struct PNP_GetDeviceListSize s; s.in.devicename = "Spooler"; s.in.flags = CM_GETIDLIST_FILTER_SERVICE; s.out.size = &length; torture_assert_ntstatus_ok(tctx, dcerpc_PNP_GetDeviceListSize(p, tctx, &s), "PNP_GetDeviceListSize failed"); torture_assert_werr_ok(tctx, s.out.result, "PNP_GetDeviceListSize failed"); } buffer = talloc_array(tctx, uint16_t, length); r.in.length = &length; r.out.length = &length; r.out.buffer = buffer; torture_assert_ntstatus_ok(tctx, dcerpc_PNP_GetDeviceList(p, tctx, &r), "PNP_GetDeviceList failed"); torture_assert_werr_ok(tctx, r.out.result, "PNP_GetDeviceList failed"); return true; }
static WERROR cmd_ntsvcs_get_dev_list_size(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { struct dcerpc_binding_handle *b = cli->binding_handle; NTSTATUS status; WERROR werr; uint32_t size = 0; uint32_t flags = 0; const char *filter = NULL; if (argc > 3) { printf("usage: %s [filter] [flags]\n", argv[0]); return WERR_OK; } if (argc >= 2) { filter = argv[1]; } if (argc >= 3) { flags = atoi(argv[2]); } status = dcerpc_PNP_GetDeviceListSize(b, mem_ctx, filter, &size, flags, &werr); if (!NT_STATUS_IS_OK(status)) { return ntstatus_to_werror(status); } printf("size: %d\n", size); return werr; }