2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
5 * Copyright (C) Gerald (Jerry) Carter 2005.
6 * Copyright (C) Guenther Deschner 2008,2009.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
24 #include "../librpc/gen_ndr/srv_ntsvcs.h"
25 #include "services/svc_winreg_glue.h"
26 #include "../libcli/registry/util_reg.h"
29 #define DBGC_CLASS DBGC_RPC_SRV
31 /********************************************************************
32 ********************************************************************/
34 static char* get_device_path(TALLOC_CTX
*mem_ctx
, const char *device
)
36 return talloc_asprintf(mem_ctx
, "ROOT\\Legacy_%s\\0000", device
);
39 /********************************************************************
40 ********************************************************************/
42 WERROR
_PNP_GetVersion(struct pipes_struct
*p
,
43 struct PNP_GetVersion
*r
)
45 *r
->out
.version
= 0x0400; /* no idea what this means */
50 /********************************************************************
51 ********************************************************************/
53 WERROR
_PNP_GetDeviceListSize(struct pipes_struct
*p
,
54 struct PNP_GetDeviceListSize
*r
)
58 if ((r
->in
.flags
& CM_GETIDLIST_FILTER_SERVICE
) &&
59 (!r
->in
.devicename
)) {
60 return WERR_CM_INVALID_POINTER
;
63 if (!(devicepath
= get_device_path(p
->mem_ctx
, r
->in
.devicename
))) {
67 *r
->out
.size
= strlen(devicepath
) + 2;
69 TALLOC_FREE(devicepath
);
74 /****************************************************************
76 ****************************************************************/
78 WERROR
_PNP_GetDeviceList(struct pipes_struct
*p
,
79 struct PNP_GetDeviceList
*r
)
83 const char **multi_sz
= NULL
;
86 if ((r
->in
.flags
& CM_GETIDLIST_FILTER_SERVICE
) &&
88 return WERR_CM_INVALID_POINTER
;
91 if (!(devicepath
= get_device_path(p
->mem_ctx
, r
->in
.filter
))) {
95 size
= strlen(devicepath
) + 2;
97 if (*r
->in
.length
< size
) {
98 return WERR_CM_BUFFER_SMALL
;
101 multi_sz
= talloc_zero_array(p
->mem_ctx
, const char *, 2);
106 multi_sz
[0] = devicepath
;
108 if (!push_reg_multi_sz(multi_sz
, &blob
, multi_sz
)) {
112 if (*r
->in
.length
< blob
.length
/2) {
113 return WERR_CM_BUFFER_SMALL
;
116 memcpy(r
->out
.buffer
, blob
.data
, blob
.length
);
121 /********************************************************************
122 _PNP_GetDeviceRegProp
123 ********************************************************************/
125 WERROR
_PNP_GetDeviceRegProp(struct pipes_struct
*p
,
126 struct PNP_GetDeviceRegProp
*r
)
131 TALLOC_CTX
*mem_ctx
= NULL
;
133 switch( r
->in
.property
) {
134 case DEV_REGPROP_DESC
:
136 /* just parse the service name from the device path and then
137 lookup the display name */
138 if ( !(ptr
= strrchr_m( r
->in
.devicepath
, '\\' )) )
139 return WERR_GENERAL_FAILURE
;
142 if ( !(ptr
= strrchr_m( r
->in
.devicepath
, '_' )) )
143 return WERR_GENERAL_FAILURE
;
146 mem_ctx
= talloc_stackframe();
148 result
= svcctl_lookup_dispname(mem_ctx
,
152 if (result
== NULL
) {
153 return WERR_GENERAL_FAILURE
;
156 if (!push_reg_sz(mem_ctx
, &blob
, result
)) {
157 talloc_free(mem_ctx
);
158 return WERR_GENERAL_FAILURE
;
161 if (*r
->in
.buffer_size
< blob
.length
) {
162 *r
->out
.needed
= blob
.length
;
163 *r
->out
.buffer_size
= 0;
164 talloc_free(mem_ctx
);
165 return WERR_CM_BUFFER_SMALL
;
168 r
->out
.buffer
= (uint8_t *)talloc_memdup(p
->mem_ctx
, blob
.data
, blob
.length
);
169 talloc_free(mem_ctx
);
170 if (!r
->out
.buffer
) {
174 *r
->out
.reg_data_type
= REG_SZ
; /* always 1...tested using a remove device manager connection */
175 *r
->out
.buffer_size
= blob
.length
;
176 *r
->out
.needed
= blob
.length
;
181 *r
->out
.reg_data_type
= 0x00437c98; /* ??? */
182 return WERR_CM_NO_SUCH_VALUE
;
188 /********************************************************************
189 ********************************************************************/
191 WERROR
_PNP_ValidateDeviceInstance(struct pipes_struct
*p
,
192 struct PNP_ValidateDeviceInstance
*r
)
198 /********************************************************************
199 ********************************************************************/
201 WERROR
_PNP_GetHwProfInfo(struct pipes_struct
*p
,
202 struct PNP_GetHwProfInfo
*r
)
204 /* steal the incoming buffer */
206 r
->out
.info
= r
->in
.info
;
208 /* Take the 5th Ammentment */
210 return WERR_CM_NO_MORE_HW_PROFILES
;
213 /********************************************************************
214 ********************************************************************/
216 WERROR
_PNP_HwProfFlags(struct pipes_struct
*p
,
217 struct PNP_HwProfFlags
*r
)
219 /* just nod your head */
224 /****************************************************************
225 ****************************************************************/
227 WERROR
_PNP_Disconnect(struct pipes_struct
*p
,
228 struct PNP_Disconnect
*r
)
230 p
->rng_fault_state
= true;
231 return WERR_NOT_SUPPORTED
;
234 /****************************************************************
235 ****************************************************************/
237 WERROR
_PNP_Connect(struct pipes_struct
*p
,
238 struct PNP_Connect
*r
)
240 p
->rng_fault_state
= true;
241 return WERR_NOT_SUPPORTED
;
244 /****************************************************************
245 ****************************************************************/
247 WERROR
_PNP_GetGlobalState(struct pipes_struct
*p
,
248 struct PNP_GetGlobalState
*r
)
250 p
->rng_fault_state
= true;
251 return WERR_NOT_SUPPORTED
;
254 /****************************************************************
255 ****************************************************************/
257 WERROR
_PNP_InitDetection(struct pipes_struct
*p
,
258 struct PNP_InitDetection
*r
)
260 p
->rng_fault_state
= true;
261 return WERR_NOT_SUPPORTED
;
264 /****************************************************************
265 ****************************************************************/
267 WERROR
_PNP_ReportLogOn(struct pipes_struct
*p
,
268 struct PNP_ReportLogOn
*r
)
270 p
->rng_fault_state
= true;
271 return WERR_NOT_SUPPORTED
;
274 /****************************************************************
275 ****************************************************************/
277 WERROR
_PNP_GetRootDeviceInstance(struct pipes_struct
*p
,
278 struct PNP_GetRootDeviceInstance
*r
)
280 p
->rng_fault_state
= true;
281 return WERR_NOT_SUPPORTED
;
284 /****************************************************************
285 ****************************************************************/
287 WERROR
_PNP_GetRelatedDeviceInstance(struct pipes_struct
*p
,
288 struct PNP_GetRelatedDeviceInstance
*r
)
290 p
->rng_fault_state
= true;
291 return WERR_NOT_SUPPORTED
;
294 /****************************************************************
295 ****************************************************************/
297 WERROR
_PNP_EnumerateSubKeys(struct pipes_struct
*p
,
298 struct PNP_EnumerateSubKeys
*r
)
300 p
->rng_fault_state
= true;
301 return WERR_NOT_SUPPORTED
;
304 /****************************************************************
305 ****************************************************************/
307 WERROR
_PNP_GetDepth(struct pipes_struct
*p
,
308 struct PNP_GetDepth
*r
)
310 p
->rng_fault_state
= true;
311 return WERR_NOT_SUPPORTED
;
314 /****************************************************************
315 ****************************************************************/
317 WERROR
_PNP_SetDeviceRegProp(struct pipes_struct
*p
,
318 struct PNP_SetDeviceRegProp
*r
)
320 p
->rng_fault_state
= true;
321 return WERR_NOT_SUPPORTED
;
324 /****************************************************************
325 ****************************************************************/
327 WERROR
_PNP_GetClassInstance(struct pipes_struct
*p
,
328 struct PNP_GetClassInstance
*r
)
330 p
->rng_fault_state
= true;
331 return WERR_NOT_SUPPORTED
;
334 /****************************************************************
335 ****************************************************************/
337 WERROR
_PNP_CreateKey(struct pipes_struct
*p
,
338 struct PNP_CreateKey
*r
)
340 p
->rng_fault_state
= true;
341 return WERR_NOT_SUPPORTED
;
344 /****************************************************************
345 ****************************************************************/
347 WERROR
_PNP_DeleteRegistryKey(struct pipes_struct
*p
,
348 struct PNP_DeleteRegistryKey
*r
)
350 p
->rng_fault_state
= true;
351 return WERR_NOT_SUPPORTED
;
354 /****************************************************************
355 ****************************************************************/
357 WERROR
_PNP_GetClassCount(struct pipes_struct
*p
,
358 struct PNP_GetClassCount
*r
)
360 p
->rng_fault_state
= true;
361 return WERR_NOT_SUPPORTED
;
364 /****************************************************************
365 ****************************************************************/
367 WERROR
_PNP_GetClassName(struct pipes_struct
*p
,
368 struct PNP_GetClassName
*r
)
370 p
->rng_fault_state
= true;
371 return WERR_NOT_SUPPORTED
;
374 /****************************************************************
375 ****************************************************************/
377 WERROR
_PNP_DeleteClassKey(struct pipes_struct
*p
,
378 struct PNP_DeleteClassKey
*r
)
380 p
->rng_fault_state
= true;
381 return WERR_NOT_SUPPORTED
;
384 /****************************************************************
385 ****************************************************************/
387 WERROR
_PNP_GetInterfaceDeviceAlias(struct pipes_struct
*p
,
388 struct PNP_GetInterfaceDeviceAlias
*r
)
390 p
->rng_fault_state
= true;
391 return WERR_NOT_SUPPORTED
;
394 /****************************************************************
395 ****************************************************************/
397 WERROR
_PNP_GetInterfaceDeviceList(struct pipes_struct
*p
,
398 struct PNP_GetInterfaceDeviceList
*r
)
400 p
->rng_fault_state
= true;
401 return WERR_NOT_SUPPORTED
;
404 /****************************************************************
405 ****************************************************************/
407 WERROR
_PNP_GetInterfaceDeviceListSize(struct pipes_struct
*p
,
408 struct PNP_GetInterfaceDeviceListSize
*r
)
410 p
->rng_fault_state
= true;
411 return WERR_NOT_SUPPORTED
;
414 /****************************************************************
415 ****************************************************************/
417 WERROR
_PNP_RegisterDeviceClassAssociation(struct pipes_struct
*p
,
418 struct PNP_RegisterDeviceClassAssociation
*r
)
420 p
->rng_fault_state
= true;
421 return WERR_NOT_SUPPORTED
;
424 /****************************************************************
425 ****************************************************************/
427 WERROR
_PNP_UnregisterDeviceClassAssociation(struct pipes_struct
*p
,
428 struct PNP_UnregisterDeviceClassAssociation
*r
)
430 p
->rng_fault_state
= true;
431 return WERR_NOT_SUPPORTED
;
434 /****************************************************************
435 ****************************************************************/
437 WERROR
_PNP_GetClassRegProp(struct pipes_struct
*p
,
438 struct PNP_GetClassRegProp
*r
)
440 p
->rng_fault_state
= true;
441 return WERR_NOT_SUPPORTED
;
444 /****************************************************************
445 ****************************************************************/
447 WERROR
_PNP_SetClassRegProp(struct pipes_struct
*p
,
448 struct PNP_SetClassRegProp
*r
)
450 p
->rng_fault_state
= true;
451 return WERR_NOT_SUPPORTED
;
454 /****************************************************************
455 ****************************************************************/
457 WERROR
_PNP_CreateDevInst(struct pipes_struct
*p
,
458 struct PNP_CreateDevInst
*r
)
460 p
->rng_fault_state
= true;
461 return WERR_NOT_SUPPORTED
;
464 /****************************************************************
465 ****************************************************************/
467 WERROR
_PNP_DeviceInstanceAction(struct pipes_struct
*p
,
468 struct PNP_DeviceInstanceAction
*r
)
470 p
->rng_fault_state
= true;
471 return WERR_NOT_SUPPORTED
;
474 /****************************************************************
475 ****************************************************************/
477 WERROR
_PNP_GetDeviceStatus(struct pipes_struct
*p
,
478 struct PNP_GetDeviceStatus
*r
)
480 p
->rng_fault_state
= true;
481 return WERR_NOT_SUPPORTED
;
484 /****************************************************************
485 ****************************************************************/
487 WERROR
_PNP_SetDeviceProblem(struct pipes_struct
*p
,
488 struct PNP_SetDeviceProblem
*r
)
490 p
->rng_fault_state
= true;
491 return WERR_NOT_SUPPORTED
;
494 /****************************************************************
495 ****************************************************************/
497 WERROR
_PNP_DisableDevInst(struct pipes_struct
*p
,
498 struct PNP_DisableDevInst
*r
)
500 p
->rng_fault_state
= true;
501 return WERR_NOT_SUPPORTED
;
504 /****************************************************************
505 ****************************************************************/
507 WERROR
_PNP_UninstallDevInst(struct pipes_struct
*p
,
508 struct PNP_UninstallDevInst
*r
)
510 p
->rng_fault_state
= true;
511 return WERR_NOT_SUPPORTED
;
514 /****************************************************************
515 ****************************************************************/
517 WERROR
_PNP_AddID(struct pipes_struct
*p
,
520 p
->rng_fault_state
= true;
521 return WERR_NOT_SUPPORTED
;
524 /****************************************************************
525 ****************************************************************/
527 WERROR
_PNP_RegisterDriver(struct pipes_struct
*p
,
528 struct PNP_RegisterDriver
*r
)
530 p
->rng_fault_state
= true;
531 return WERR_NOT_SUPPORTED
;
534 /****************************************************************
535 ****************************************************************/
537 WERROR
_PNP_QueryRemove(struct pipes_struct
*p
,
538 struct PNP_QueryRemove
*r
)
540 p
->rng_fault_state
= true;
541 return WERR_NOT_SUPPORTED
;
544 /****************************************************************
545 ****************************************************************/
547 WERROR
_PNP_RequestDeviceEject(struct pipes_struct
*p
,
548 struct PNP_RequestDeviceEject
*r
)
550 p
->rng_fault_state
= true;
551 return WERR_NOT_SUPPORTED
;
554 /****************************************************************
555 ****************************************************************/
557 WERROR
_PNP_IsDockStationPresent(struct pipes_struct
*p
,
558 struct PNP_IsDockStationPresent
*r
)
560 p
->rng_fault_state
= true;
561 return WERR_NOT_SUPPORTED
;
564 /****************************************************************
565 ****************************************************************/
567 WERROR
_PNP_RequestEjectPC(struct pipes_struct
*p
,
568 struct PNP_RequestEjectPC
*r
)
570 p
->rng_fault_state
= true;
571 return WERR_NOT_SUPPORTED
;
574 /****************************************************************
575 ****************************************************************/
577 WERROR
_PNP_AddEmptyLogConf(struct pipes_struct
*p
,
578 struct PNP_AddEmptyLogConf
*r
)
580 p
->rng_fault_state
= true;
581 return WERR_NOT_SUPPORTED
;
584 /****************************************************************
585 ****************************************************************/
587 WERROR
_PNP_FreeLogConf(struct pipes_struct
*p
,
588 struct PNP_FreeLogConf
*r
)
590 p
->rng_fault_state
= true;
591 return WERR_NOT_SUPPORTED
;
594 /****************************************************************
595 ****************************************************************/
597 WERROR
_PNP_GetFirstLogConf(struct pipes_struct
*p
,
598 struct PNP_GetFirstLogConf
*r
)
600 p
->rng_fault_state
= true;
601 return WERR_NOT_SUPPORTED
;
604 /****************************************************************
605 ****************************************************************/
607 WERROR
_PNP_GetNextLogConf(struct pipes_struct
*p
,
608 struct PNP_GetNextLogConf
*r
)
610 p
->rng_fault_state
= true;
611 return WERR_NOT_SUPPORTED
;
614 /****************************************************************
615 ****************************************************************/
617 WERROR
_PNP_GetLogConfPriority(struct pipes_struct
*p
,
618 struct PNP_GetLogConfPriority
*r
)
620 p
->rng_fault_state
= true;
621 return WERR_NOT_SUPPORTED
;
624 /****************************************************************
625 ****************************************************************/
627 WERROR
_PNP_AddResDes(struct pipes_struct
*p
,
628 struct PNP_AddResDes
*r
)
630 p
->rng_fault_state
= true;
631 return WERR_NOT_SUPPORTED
;
634 /****************************************************************
635 ****************************************************************/
637 WERROR
_PNP_FreeResDes(struct pipes_struct
*p
,
638 struct PNP_FreeResDes
*r
)
640 p
->rng_fault_state
= true;
641 return WERR_NOT_SUPPORTED
;
644 /****************************************************************
645 ****************************************************************/
647 WERROR
_PNP_GetNextResDes(struct pipes_struct
*p
,
648 struct PNP_GetNextResDes
*r
)
650 p
->rng_fault_state
= true;
651 return WERR_NOT_SUPPORTED
;
654 /****************************************************************
655 ****************************************************************/
657 WERROR
_PNP_GetResDesData(struct pipes_struct
*p
,
658 struct PNP_GetResDesData
*r
)
660 p
->rng_fault_state
= true;
661 return WERR_NOT_SUPPORTED
;
664 /****************************************************************
665 ****************************************************************/
667 WERROR
_PNP_GetResDesDataSize(struct pipes_struct
*p
,
668 struct PNP_GetResDesDataSize
*r
)
670 p
->rng_fault_state
= true;
671 return WERR_NOT_SUPPORTED
;
674 /****************************************************************
675 ****************************************************************/
677 WERROR
_PNP_ModifyResDes(struct pipes_struct
*p
,
678 struct PNP_ModifyResDes
*r
)
680 p
->rng_fault_state
= true;
681 return WERR_NOT_SUPPORTED
;
684 /****************************************************************
685 ****************************************************************/
687 WERROR
_PNP_DetectResourceLimit(struct pipes_struct
*p
,
688 struct PNP_DetectResourceLimit
*r
)
690 p
->rng_fault_state
= true;
691 return WERR_NOT_SUPPORTED
;
694 /****************************************************************
695 ****************************************************************/
697 WERROR
_PNP_QueryResConfList(struct pipes_struct
*p
,
698 struct PNP_QueryResConfList
*r
)
700 p
->rng_fault_state
= true;
701 return WERR_NOT_SUPPORTED
;
704 /****************************************************************
705 ****************************************************************/
707 WERROR
_PNP_SetHwProf(struct pipes_struct
*p
,
708 struct PNP_SetHwProf
*r
)
710 p
->rng_fault_state
= true;
711 return WERR_NOT_SUPPORTED
;
714 /****************************************************************
715 ****************************************************************/
717 WERROR
_PNP_QueryArbitratorFreeData(struct pipes_struct
*p
,
718 struct PNP_QueryArbitratorFreeData
*r
)
720 p
->rng_fault_state
= true;
721 return WERR_NOT_SUPPORTED
;
724 /****************************************************************
725 ****************************************************************/
727 WERROR
_PNP_QueryArbitratorFreeSize(struct pipes_struct
*p
,
728 struct PNP_QueryArbitratorFreeSize
*r
)
730 p
->rng_fault_state
= true;
731 return WERR_NOT_SUPPORTED
;
734 /****************************************************************
735 ****************************************************************/
737 WERROR
_PNP_RunDetection(struct pipes_struct
*p
,
738 struct PNP_RunDetection
*r
)
740 p
->rng_fault_state
= true;
741 return WERR_NOT_SUPPORTED
;
744 /****************************************************************
745 ****************************************************************/
747 WERROR
_PNP_RegisterNotification(struct pipes_struct
*p
,
748 struct PNP_RegisterNotification
*r
)
750 p
->rng_fault_state
= true;
751 return WERR_NOT_SUPPORTED
;
754 /****************************************************************
755 ****************************************************************/
757 WERROR
_PNP_UnregisterNotification(struct pipes_struct
*p
,
758 struct PNP_UnregisterNotification
*r
)
760 p
->rng_fault_state
= true;
761 return WERR_NOT_SUPPORTED
;
764 /****************************************************************
765 ****************************************************************/
767 WERROR
_PNP_GetCustomDevProp(struct pipes_struct
*p
,
768 struct PNP_GetCustomDevProp
*r
)
770 p
->rng_fault_state
= true;
771 return WERR_NOT_SUPPORTED
;
774 /****************************************************************
775 ****************************************************************/
777 WERROR
_PNP_GetVersionInternal(struct pipes_struct
*p
,
778 struct PNP_GetVersionInternal
*r
)
780 p
->rng_fault_state
= true;
781 return WERR_NOT_SUPPORTED
;
784 /****************************************************************
785 ****************************************************************/
787 WERROR
_PNP_GetBlockedDriverInfo(struct pipes_struct
*p
,
788 struct PNP_GetBlockedDriverInfo
*r
)
790 p
->rng_fault_state
= true;
791 return WERR_NOT_SUPPORTED
;
794 /****************************************************************
795 ****************************************************************/
797 WERROR
_PNP_GetServerSideDeviceInstallFlags(struct pipes_struct
*p
,
798 struct PNP_GetServerSideDeviceInstallFlags
*r
)
800 p
->rng_fault_state
= true;
801 return WERR_NOT_SUPPORTED
;