ReactOS  0.4.13-dev-242-g611e6d7
srvsvc.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: NetAPI DLL
4  * FILE: reactos/dll/win32/netapi32/srvsvc.c
5  * PURPOSE: Server service interface code
6  * PROGRAMMERS: Eric Kohl <eric.kohl@reactos.org>
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include "netapi32.h"
12 #include "srvsvc_c.h"
13 
15 
16 /* FUNCTIONS *****************************************************************/
17 
20 {
22  LPWSTR pszStringBinding;
24 
25  TRACE("SRVSVC_HANDLE_bind() called\n");
26 
28  L"ncacn_np",
29  (RPC_WSTR)pszSystemName,
30  L"\\pipe\\srvsvc",
31  NULL,
32  &pszStringBinding);
33  if (status)
34  {
35  TRACE("RpcStringBindingCompose returned 0x%x\n", status);
36  return NULL;
37  }
38 
39  /* Set the binding handle that will be used to bind to the server. */
40  status = RpcBindingFromStringBindingW(pszStringBinding,
41  &hBinding);
42  if (status)
43  {
44  TRACE("RpcBindingFromStringBinding returned 0x%x\n", status);
45  }
46 
47  status = RpcStringFreeW(&pszStringBinding);
48  if (status)
49  {
50 // TRACE("RpcStringFree returned 0x%x\n", status);
51  }
52 
53  return hBinding;
54 }
55 
56 
57 void __RPC_USER
60 {
62 
63  TRACE("SRVSVC_HANDLE_unbind() called\n");
64 
66  if (status)
67  {
68  TRACE("RpcBindingFree returned 0x%x\n", status);
69  }
70 }
71 
72 
74 WINAPI
76  _In_ LMSTR servername,
80  _In_ DWORD prefmaxlen,
81  _Out_ LPDWORD entriesread,
82  _Out_ LPDWORD totalentries,
83  _Inout_ LPDWORD resume_handle)
84 {
85  CONNECT_ENUM_STRUCT EnumStruct;
86  CONNECT_INFO_0_CONTAINER Level0Container = {0, NULL};
87  CONNECT_INFO_1_CONTAINER Level1Container = {0, NULL};
89 
90  TRACE("NetConnectionEnum(%s %s %s %lu %p %lu %p %p %p)\n",
91  debugstr_w(servername), debugstr_w(qualifier), level, bufptr,
92  prefmaxlen, entriesread, totalentries, resume_handle);
93 
94  if (level > 1)
95  return ERROR_INVALID_LEVEL;
96 
97  EnumStruct.Level = level;
98  switch (level)
99  {
100  case 0:
101  EnumStruct.ConnectInfo.Level0 = &Level0Container;
102  break;
103 
104  case 1:
105  EnumStruct.ConnectInfo.Level1 = &Level1Container;
106  break;
107  }
108 
110  {
111  status = NetrConnectionEnum(servername,
112  qualifier,
113  &EnumStruct,
114  prefmaxlen,
115  totalentries,
116  resume_handle);
117 
118  switch (level)
119  {
120  case 0:
121  if (EnumStruct.ConnectInfo.Level0->Buffer != NULL)
122  {
123  *bufptr = (LPBYTE)EnumStruct.ConnectInfo.Level0->Buffer;
124  *entriesread = EnumStruct.ConnectInfo.Level0->EntriesRead;
125  }
126  break;
127 
128  case 1:
129  if (EnumStruct.ConnectInfo.Level1->Buffer != NULL)
130  {
131  *bufptr = (LPBYTE)EnumStruct.ConnectInfo.Level1->Buffer;
132  *entriesread = EnumStruct.ConnectInfo.Level1->EntriesRead;
133  }
134  break;
135  }
136  }
138  {
140  }
141  RpcEndExcept;
142 
143  return status;
144 }
145 
146 
148 WINAPI
150  _In_ LMSTR servername,
151  _In_ DWORD fileid)
152 {
154 
155  TRACE("NetFileClose(%s %lu)\n",
156  debugstr_w(servername), fileid);
157 
159  {
160  status = NetrFileClose(servername,
161  fileid);
162  }
164  {
166  }
167  RpcEndExcept;
168 
169  return status;
170 }
171 
172 
174 WINAPI
176  _In_ LMSTR servername,
177  _In_ LMSTR basepath,
179  _In_ DWORD level,
181  _In_ DWORD prefmaxlen,
182  _Out_ LPDWORD entriesread,
183  _Out_ LPDWORD totalentries,
184  _Inout_ PDWORD_PTR resume_handle)
185 {
186  FILE_ENUM_STRUCT EnumStruct;
187  FILE_INFO_2_CONTAINER Level2Container = {0, NULL};
188  FILE_INFO_3_CONTAINER Level3Container = {0, NULL};
190 
191  TRACE("NetFileEnum(%s %s %s %lu %p %lu %p %p %p)\n",
192  debugstr_w(servername), debugstr_w(basepath), debugstr_w(username),
193  level, bufptr, prefmaxlen, entriesread, totalentries, resume_handle);
194 
195  if (level != 2 && level != 3)
196  return ERROR_INVALID_LEVEL;
197 
198  EnumStruct.Level = level;
199  switch (level)
200  {
201  case 2:
202  EnumStruct.FileInfo.Level2 = &Level2Container;
203  break;
204 
205  case 3:
206  EnumStruct.FileInfo.Level3 = &Level3Container;
207  break;
208  }
209 
211  {
212  status = NetrFileEnum(servername,
213  basepath,
214  username,
215  &EnumStruct,
216  prefmaxlen,
217  totalentries,
218  (PDWORD)resume_handle);
219 
220  switch (level)
221  {
222  case 2:
223  if (EnumStruct.FileInfo.Level2->Buffer != NULL)
224  {
225  *bufptr = (LPBYTE)EnumStruct.FileInfo.Level2->Buffer;
226  *entriesread = EnumStruct.FileInfo.Level2->EntriesRead;
227  }
228  break;
229 
230  case 3:
231  if (EnumStruct.FileInfo.Level3->Buffer != NULL)
232  {
233  *bufptr = (LPBYTE)EnumStruct.FileInfo.Level3->Buffer;
234  *entriesread = EnumStruct.FileInfo.Level3->EntriesRead;
235  }
236  break;
237  }
238  }
240  {
242  }
243  RpcEndExcept;
244 
245  return status;
246 }
247 
248 
250 WINAPI
252  _In_ LMSTR servername,
253  _In_ DWORD fileid,
254  _In_ DWORD level,
256 {
258 
259  TRACE("NetFileGetInfo(%s %lu %lu %p)\n",
260  debugstr_w(servername), fileid, level, bufptr);
261 
262  *bufptr = NULL;
263 
265  {
266  status = NetrFileGetInfo(servername,
267  fileid,
268  level,
270  }
272  {
274  }
275  RpcEndExcept;
276 
277  return status;
278 }
279 
280 
282 WINAPI
284  _In_ LPCWSTR UncServerName,
285  _Out_ LPBYTE *BufferPtr)
286 {
288 
289  TRACE("NetRemoteTOD(%s %p)\n",
290  debugstr_w(UncServerName), BufferPtr);
291 
292  *BufferPtr = NULL;
293 
295  {
296  status = NetrRemoteTOD((SRVSVC_HANDLE)UncServerName,
297  (LPTIME_OF_DAY_INFO *)BufferPtr);
298  }
300  {
302  }
303  RpcEndExcept;
304 
305  return status;
306 }
307 
308 
310 WINAPI
312  _In_ LMSTR servername,
313  _In_ DWORD level,
315  _In_ DWORD prefmaxlen,
316  _Out_ LPDWORD entriesread,
317  _Out_ LPDWORD totalentries,
318  _Inout_ LPDWORD resume_handle)
319 {
320  DISK_ENUM_CONTAINER EnumContainer;
322 
323  TRACE("NetServerDiskEnum(%s %lu %p %lu %p %p %p)\n",
324  debugstr_w(servername), level, bufptr, prefmaxlen,
325  entriesread, totalentries, resume_handle);
326 
327  EnumContainer.EntriesRead = 0;
328  EnumContainer.Buffer = NULL;
329 
331  {
332  status = NetrServerDiskEnum(servername,
333  level,
334  &EnumContainer,
335  prefmaxlen,
336  totalentries,
337  resume_handle);
338 
339  if (EnumContainer.Buffer != NULL)
340  {
341  *bufptr = (LPBYTE)EnumContainer.Buffer;
342  }
343  else
344  {
345  *bufptr = NULL;
346  }
347 
348  if (EnumContainer.EntriesRead > 0)
349  {
350  *entriesread = EnumContainer.EntriesRead - 1;
351  }
352  else
353  {
354  *entriesread = 0;
355  }
356  }
358  {
360  }
361  RpcEndExcept;
362 
363  return status;
364 }
365 
366 
368 WINAPI
370  LMSTR servername,
371  DWORD level,
372  LPBYTE *bufptr)
373 {
375 
376  TRACE("NetServerGetInfo(%s %lu %p)\n",
377  debugstr_w(servername), level, bufptr);
378 
379  *bufptr = NULL;
380 
382  {
383  status = NetrServerGetInfo(servername,
384  level,
385  (LPSERVER_INFO *)bufptr);
386  }
388  {
390  }
391  RpcEndExcept;
392 
393  return status;
394 }
395 
396 
398 WINAPI
400  _In_ LPWSTR servername,
401  _In_ DWORD level,
402  _In_ LPBYTE buf,
403  _Out_ LPDWORD parm_err)
404 {
406 
407  TRACE("NetServerSetInfo(%s %lu %p %p)\n",
408  debugstr_w(servername), level, buf, parm_err);
409 
411  {
412  status = NetrServerSetInfo(servername,
413  level,
414  (LPSERVER_INFO)&buf,
415  parm_err);
416  }
418  {
420  }
421  RpcEndExcept;
422 
423  return status;
424 }
425 
426 
428 WINAPI
430  _In_ LPWSTR servername,
431  _In_ LPWSTR transport,
432  _In_ DWORD servicebits,
433  _In_ DWORD updateimmediately)
434 {
436 
437  TRACE("I_NetServerSetServiceBits(%s %s 0x%lx %lu)\n",
438  debugstr_w(servername), debugstr_w(transport), servicebits, updateimmediately);
439 
441  {
442  status = NetrServerSetServiceBits(servername,
443  transport,
444  servicebits,
445  updateimmediately);
446  }
448  {
450  }
451  RpcEndExcept;
452 
453  return status;
454 }
455 
456 
458 WINAPI
460  _In_ LPWSTR servername,
461  _In_ DWORD level,
463 {
465 
466  TRACE("NetServerTransportAdd(%s %lu %p)\n",
467  debugstr_w(servername), level, bufptr);
468 
470  {
471  status = NetrServerTransportAdd(servername,
472  level,
474  }
476  {
478  }
479  RpcEndExcept;
480 
481  return status;
482 }
483 
484 
486 WINAPI
488  _In_ LPWSTR servername,
489  _In_ DWORD level,
491 {
493 
494  TRACE("NetServerTransportAddEx(%s %lu %p)\n",
495  debugstr_w(servername), level, bufptr);
496 
498  {
499  status = NetrServerTransportAddEx(servername,
500  level,
502  }
504  {
506  }
507  RpcEndExcept;
508 
509  return status;
510 }
511 
512 
514 WINAPI
516  _In_ LPWSTR servername,
517  _In_ DWORD level,
519 {
521 
522  TRACE("NetServerTransportDel(%s %lu %p)\n",
523  debugstr_w(servername), level, bufptr);
524 
526  {
527  status = NetrServerTransportDel(servername,
528  level,
530  }
532  {
534  }
535  RpcEndExcept;
536 
537  return status;
538 }
539 
540 
542 WINAPI
544  _In_ LPWSTR servername,
545  _In_ DWORD level,
547  _In_ DWORD prefmaxlen,
548  _Out_ LPDWORD entriesread,
549  _Out_ LPDWORD totalentries,
550  _Inout_ LPDWORD resume_handle)
551 {
552  SERVER_XPORT_ENUM_STRUCT EnumStruct;
553  SERVER_XPORT_INFO_0_CONTAINER Level0Container = {0, NULL};
554  SERVER_XPORT_INFO_1_CONTAINER Level1Container = {0, NULL};
556 
557  TRACE("NetServerTransportEnum(%s %lu %p %lu %p %p %p)\n",
558  debugstr_w(servername), level, bufptr, prefmaxlen,
559  entriesread, totalentries, resume_handle);
560 
561  EnumStruct.Level = level;
562  switch (level)
563  {
564  case 0:
565  EnumStruct.XportInfo.Level0 = &Level0Container;
566  break;
567 
568  case 1:
569  EnumStruct.XportInfo.Level1 = &Level1Container;
570  break;
571  }
572 
574  {
575  status = NetrServerTransportEnum(servername,
576  &EnumStruct,
577  prefmaxlen,
578  totalentries,
579  resume_handle);
580 
581  switch (level)
582  {
583  case 0:
584  if (EnumStruct.XportInfo.Level0->Buffer != NULL)
585  {
586  *bufptr = (LPBYTE)EnumStruct.XportInfo.Level0->Buffer;
587  *entriesread = EnumStruct.XportInfo.Level0->EntriesRead;
588  }
589  break;
590 
591  case 1:
592  if (EnumStruct.XportInfo.Level1->Buffer != NULL)
593  {
594  *bufptr = (LPBYTE)EnumStruct.XportInfo.Level1->Buffer;
595  *entriesread = EnumStruct.XportInfo.Level1->EntriesRead;
596  }
597  break;
598  }
599  }
601  {
603  }
604  RpcEndExcept;
605 
606  return status;
607 }
608 
609 
611 WINAPI
613  _In_ LMSTR servername,
614  _In_ LMSTR UncClientName,
616 {
618 
619  TRACE("NetSessionDel(%s %s %s)\n",
620  debugstr_w(servername), debugstr_w(UncClientName), debugstr_w(username));
621 
623  {
624  status = NetrSessionDel(servername,
625  UncClientName,
626  username);
627  }
629  {
631  }
632  RpcEndExcept;
633 
634  return status;
635 }
636 
637 
639 WINAPI
641  _In_ LMSTR servername,
642  _In_ LMSTR UncClientName,
644  _In_ DWORD level,
646  _In_ DWORD prefmaxlen,
647  _Out_ LPDWORD entriesread,
648  _Out_ LPDWORD totalentries,
649  _Inout_ LPDWORD resume_handle)
650 {
651  SESSION_ENUM_STRUCT EnumStruct;
652  SESSION_INFO_0_CONTAINER Level0Container = {0, NULL};
653  SESSION_INFO_1_CONTAINER Level1Container = {0, NULL};
654  SESSION_INFO_2_CONTAINER Level2Container = {0, NULL};
655  SESSION_INFO_10_CONTAINER Level10Container = {0, NULL};
656  SESSION_INFO_502_CONTAINER Level502Container = {0, NULL};
658 
659  TRACE("NetSessionEnum(%s %s %s %lu %p %lu %p %p %p)\n",
660  debugstr_w(servername), debugstr_w(UncClientName), debugstr_w(username),
661  level, bufptr, prefmaxlen, entriesread, totalentries, resume_handle);
662 
663  if (level > 2 && level != 10 && level != 502)
664  return ERROR_INVALID_LEVEL;
665 
666  if (UncClientName == NULL || username == NULL)
668 
669  *bufptr = NULL;
670  *entriesread = 0;
671 
672  EnumStruct.Level = level;
673  switch (level)
674  {
675  case 0:
676  EnumStruct.SessionInfo.Level0 = &Level0Container;
677  break;
678 
679  case 1:
680  EnumStruct.SessionInfo.Level1 = &Level1Container;
681  break;
682 
683  case 2:
684  EnumStruct.SessionInfo.Level2 = &Level2Container;
685  break;
686 
687  case 10:
688  EnumStruct.SessionInfo.Level10 = &Level10Container;
689  break;
690 
691  case 502:
692  EnumStruct.SessionInfo.Level502 = &Level502Container;
693  break;
694  }
695 
697  {
698  status = NetrSessionEnum(servername,
699  UncClientName,
700  username,
701  &EnumStruct,
702  prefmaxlen,
703  totalentries,
704  resume_handle);
705 
706  switch (level)
707  {
708  case 0:
709  if (EnumStruct.SessionInfo.Level0->Buffer != NULL)
710  {
711  *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level0->Buffer;
712  *entriesread = EnumStruct.SessionInfo.Level0->EntriesRead;
713  }
714  break;
715 
716  case 1:
717  if (EnumStruct.SessionInfo.Level1->Buffer != NULL)
718  {
719  *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level1->Buffer;
720  *entriesread = EnumStruct.SessionInfo.Level1->EntriesRead;
721  }
722  break;
723 
724  case 2:
725  if (EnumStruct.SessionInfo.Level2->Buffer != NULL)
726  {
727  *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level2->Buffer;
728  *entriesread = EnumStruct.SessionInfo.Level2->EntriesRead;
729  }
730  break;
731 
732  case 10:
733  if (EnumStruct.SessionInfo.Level10->Buffer != NULL)
734  {
735  *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level10->Buffer;
736  *entriesread = EnumStruct.SessionInfo.Level10->EntriesRead;
737  }
738  break;
739 
740  case 502:
741  if (EnumStruct.SessionInfo.Level502->Buffer != NULL)
742  {
743  *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level502->Buffer;
744  *entriesread = EnumStruct.SessionInfo.Level502->EntriesRead;
745  }
746  break;
747  }
748  }
750  {
752  }
753  RpcEndExcept;
754 
755  return status;
756 }
757 
758 
760 WINAPI
762  _In_ LMSTR servername,
763  _In_ LMSTR UncClientName,
765  _In_ DWORD level,
767 {
768  SESSION_ENUM_STRUCT EnumStruct;
769  SESSION_INFO_0_CONTAINER Level0Container = {0, NULL};
770  SESSION_INFO_1_CONTAINER Level1Container = {0, NULL};
771  SESSION_INFO_2_CONTAINER Level2Container = {0, NULL};
772  SESSION_INFO_10_CONTAINER Level10Container = {0, NULL};
773  DWORD dwTotalEntries;
775 
776  TRACE("NetSessionGetInfo(%s %s %s %lu %p)\n",
777  debugstr_w(servername), debugstr_w(UncClientName),
779 
780  if (level > 2 && level != 10)
781  return ERROR_INVALID_LEVEL;
782 
783  if (UncClientName == NULL || username == NULL)
785 
786  *bufptr = NULL;
787 
788  EnumStruct.Level = level;
789  switch (level)
790  {
791  case 0:
792  EnumStruct.SessionInfo.Level0 = &Level0Container;
793  break;
794 
795  case 1:
796  EnumStruct.SessionInfo.Level1 = &Level1Container;
797  break;
798 
799  case 2:
800  EnumStruct.SessionInfo.Level2 = &Level2Container;
801  break;
802 
803  case 10:
804  EnumStruct.SessionInfo.Level10 = &Level10Container;
805  break;
806  }
807 
809  {
810  status = NetrSessionEnum(servername,
811  UncClientName,
812  username,
813  &EnumStruct,
814  MAX_PREFERRED_LENGTH, //(DWORD)-1,
815  &dwTotalEntries,
816  NULL);
817 
818  switch (level)
819  {
820  case 0:
821  if (EnumStruct.SessionInfo.Level0->Buffer != NULL)
822  *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level0->Buffer;
823  break;
824 
825  case 1:
826  if (EnumStruct.SessionInfo.Level1->Buffer != NULL)
827  *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level1->Buffer;
828  break;
829 
830  case 2:
831  if (EnumStruct.SessionInfo.Level2->Buffer != NULL)
832  *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level2->Buffer;
833  break;
834 
835  case 10:
836  if (EnumStruct.SessionInfo.Level10->Buffer != NULL)
837  *bufptr = (LPBYTE)EnumStruct.SessionInfo.Level10->Buffer;
838  break;
839  }
840  }
842  {
844  }
845  RpcEndExcept;
846 
847  return status;
848 }
849 
850 
852 WINAPI
854  _In_ LMSTR servername,
855  _In_ DWORD level,
856  _In_ LPBYTE buf,
857  _Out_ LPDWORD parm_err)
858 {
860 
861  TRACE("NetShareAdd(%s %lu %p %p)\n",
862  debugstr_w(servername), level, buf, parm_err);
863 
864  if (level != 2 && level != 502 && level != 503)
865  return ERROR_INVALID_LEVEL;
866 
868  {
869  status = NetrShareAdd(servername,
870  level,
871  (LPSHARE_INFO)&buf,
872  parm_err);
873  }
875  {
877  }
878  RpcEndExcept;
879 
880  return status;
881 }
882 
883 
885 WINAPI
887  _In_ LMSTR servername,
888  _In_ LMSTR device,
890 {
892 
893  TRACE("NetShareCheck(%s %s %p)\n",
894  debugstr_w(servername), debugstr_w(device), type);
895 
897  {
898  status = NetrShareCheck(servername,
899  device,
900  type);
901  }
903  {
905  }
906  RpcEndExcept;
907 
908  return status;
909 }
910 
911 
913 WINAPI
915  _In_ LMSTR servername,
916  _In_ LMSTR netname,
918 {
920 
921  TRACE("NetShareDel(%s %s %lu)\n",
922  debugstr_w(servername), debugstr_w(netname), reserved);
923 
924  if (netname == NULL || (*netname == 0) || reserved != 0)
926 
928  {
929  status = NetrShareDel(servername,
930  netname,
931  reserved);
932  }
934  {
936  }
937  RpcEndExcept;
938 
939  return status;
940 }
941 
942 
944 WINAPI
946  _In_ LMSTR servername,
947  _In_ LMSTR netname,
949 {
951 
952  TRACE("NetShareDelSticky(%s %s %lu)\n",
953  debugstr_w(servername), debugstr_w(netname), reserved);
954 
955  if (netname == NULL || (*netname == 0) || reserved != 0)
957 
959  {
960  status = NetrShareDelSticky(servername,
961  netname,
962  reserved);
963  }
965  {
967  }
968  RpcEndExcept;
969 
970  return status;
971 }
972 
973 
975 WINAPI
977  _In_ LMSTR servername,
978  _In_ DWORD level,
980  _In_ DWORD prefmaxlen,
981  _Out_ LPDWORD entriesread,
982  _Out_ LPDWORD totalentries,
983  _Inout_ LPDWORD resume_handle)
984 {
985  SHARE_ENUM_STRUCT EnumStruct;
986  SHARE_INFO_0_CONTAINER Level0Container = {0, NULL};
987  SHARE_INFO_1_CONTAINER Level1Container = {0, NULL};
988  SHARE_INFO_2_CONTAINER Level2Container = {0, NULL};
989  SHARE_INFO_502_CONTAINER Level502Container = {0, NULL};
991 
992  TRACE("NetShareEnum(%s %lu %p %lu %p %p %p)\n",
993  debugstr_w(servername), level, bufptr, prefmaxlen,
994  entriesread, totalentries, resume_handle);
995 
996  if (level > 2 && level != 502)
997  return ERROR_INVALID_LEVEL;
998 
999  *bufptr = NULL;
1000  *entriesread = 0;
1001  *totalentries = 0;
1002 
1003  EnumStruct.Level = level;
1004  switch (level)
1005  {
1006  case 0:
1007  EnumStruct.ShareInfo.Level0 = &Level0Container;
1008  break;
1009 
1010  case 1:
1011  EnumStruct.ShareInfo.Level1 = &Level1Container;
1012  break;
1013 
1014  case 2:
1015  EnumStruct.ShareInfo.Level2 = &Level2Container;
1016  break;
1017 
1018  case 502:
1019  EnumStruct.ShareInfo.Level502 = &Level502Container;
1020  break;
1021  }
1022 
1023  RpcTryExcept
1024  {
1025  status = NetrShareEnum(servername,
1026  &EnumStruct,
1027  prefmaxlen,
1028  totalentries,
1029  resume_handle);
1030 
1031  switch (level)
1032  {
1033  case 0:
1034  if (EnumStruct.ShareInfo.Level0->Buffer != NULL)
1035  {
1036  *bufptr = (LPBYTE)EnumStruct.ShareInfo.Level0->Buffer;
1037  *entriesread = EnumStruct.ShareInfo.Level0->EntriesRead;
1038  }
1039  break;
1040 
1041  case 1:
1042  if (EnumStruct.ShareInfo.Level1->Buffer != NULL)
1043  {
1044  *bufptr = (LPBYTE)EnumStruct.ShareInfo.Level1->Buffer;
1045  *entriesread = EnumStruct.ShareInfo.Level1->EntriesRead;
1046  }
1047  break;
1048 
1049  case 2:
1050  if (EnumStruct.ShareInfo.Level2->Buffer != NULL)
1051  {
1052  *bufptr = (LPBYTE)EnumStruct.ShareInfo.Level2->Buffer;
1053  *entriesread = EnumStruct.ShareInfo.Level2->EntriesRead;
1054  }
1055  break;
1056 
1057  case 502:
1058  if (EnumStruct.ShareInfo.Level502->Buffer != NULL)
1059  {
1060  *bufptr = (LPBYTE)EnumStruct.ShareInfo.Level502->Buffer;
1061  *entriesread = EnumStruct.ShareInfo.Level502->EntriesRead;
1062  }
1063  break;
1064  }
1065  }
1067  {
1069  }
1070  RpcEndExcept;
1071 
1072  return status;
1073 }
1074 
1075 
1077 WINAPI
1079  _In_ LMSTR servername,
1080  _In_ DWORD level,
1081  _Out_ LPBYTE *bufptr,
1082  _In_ DWORD prefmaxlen,
1083  _Out_ LPDWORD entriesread,
1084  _Out_ LPDWORD totalentries,
1085  _Inout_ LPDWORD resume_handle)
1086 {
1087  SHARE_ENUM_STRUCT EnumStruct;
1088  SHARE_INFO_0_CONTAINER Level0Container = {0, NULL};
1089  SHARE_INFO_1_CONTAINER Level1Container = {0, NULL};
1090  SHARE_INFO_2_CONTAINER Level2Container = {0, NULL};
1091  SHARE_INFO_502_CONTAINER Level502Container = {0, NULL};
1093 
1094  TRACE("NetShareEnumSticky(%s %lu %p %lu %p %p %p)\n",
1095  debugstr_w(servername), level, bufptr, prefmaxlen,
1096  entriesread, totalentries, resume_handle);
1097 
1098  if (level > 2 && level != 502)
1099  return ERROR_INVALID_LEVEL;
1100 
1101  *bufptr = NULL;
1102  *entriesread = 0;
1103  *totalentries = 0;
1104 
1105  EnumStruct.Level = level;
1106  switch (level)
1107  {
1108  case 0:
1109  EnumStruct.ShareInfo.Level0 = &Level0Container;
1110  break;
1111 
1112  case 1:
1113  EnumStruct.ShareInfo.Level1 = &Level1Container;
1114  break;
1115 
1116  case 2:
1117  EnumStruct.ShareInfo.Level2 = &Level2Container;
1118  break;
1119 
1120  case 502:
1121  EnumStruct.ShareInfo.Level502 = &Level502Container;
1122  break;
1123  }
1124 
1125  RpcTryExcept
1126  {
1127  status = NetrShareEnum(servername,
1128  (LPSHARE_ENUM_STRUCT)&EnumStruct,
1129  prefmaxlen,
1130  totalentries,
1131  resume_handle);
1132 
1133  switch (level)
1134  {
1135  case 0:
1136  if (EnumStruct.ShareInfo.Level0->Buffer != NULL)
1137  {
1138  *bufptr = (LPBYTE)EnumStruct.ShareInfo.Level0->Buffer;
1139  *entriesread = EnumStruct.ShareInfo.Level0->EntriesRead;
1140  }
1141  break;
1142 
1143  case 1:
1144  if (EnumStruct.ShareInfo.Level1->Buffer != NULL)
1145  {
1146  *bufptr = (LPBYTE)EnumStruct.ShareInfo.Level1->Buffer;
1147  *entriesread = EnumStruct.ShareInfo.Level1->EntriesRead;
1148  }
1149  break;
1150 
1151  case 2:
1152  if (EnumStruct.ShareInfo.Level2->Buffer != NULL)
1153  {
1154  *bufptr = (LPBYTE)EnumStruct.ShareInfo.Level2->Buffer;
1155  *entriesread = EnumStruct.ShareInfo.Level2->EntriesRead;
1156  }
1157  break;
1158 
1159  case 502:
1160  if (EnumStruct.ShareInfo.Level502->Buffer != NULL)
1161  {
1162  *bufptr = (LPBYTE)EnumStruct.ShareInfo.Level502->Buffer;
1163  *entriesread = EnumStruct.ShareInfo.Level502->EntriesRead;
1164  }
1165  break;
1166  }
1167  }
1169  {
1171  }
1172  RpcEndExcept;
1173 
1174  return status;
1175 }
1176 
1177 
1179 WINAPI
1181  _In_ LMSTR servername,
1182  _In_ LMSTR netname,
1183  _In_ DWORD level,
1184  _Out_ LPBYTE *bufptr)
1185 {
1187 
1188  TRACE("NetShareGetInfo(%s %s %lu %p)\n",
1189  debugstr_w(servername), debugstr_w(netname), level, bufptr);
1190 
1191  if (level > 2 && level != 502 && level != 1005)
1192  return ERROR_INVALID_LEVEL;
1193 
1194  if (netname == NULL || *netname == 0)
1195  return ERROR_INVALID_PARAMETER;
1196 
1197  *bufptr = NULL;
1198 
1199  RpcTryExcept
1200  {
1201  status = NetrShareGetInfo(servername,
1202  netname,
1203  level,
1204  (LPSHARE_INFO)bufptr);
1205  }
1207  {
1209  }
1210  RpcEndExcept;
1211 
1212  return status;
1213 }
1214 
1215 
1217 WINAPI
1219  _In_ LPWSTR servername,
1220  _In_ LPWSTR netname,
1221  _In_ DWORD level,
1222  _In_ LPBYTE buf,
1223  _Out_ LPDWORD parm_err)
1224 {
1226 
1227  TRACE("NetShareSetInfo(%s %s %lu %p %p)\n",
1228  debugstr_w(servername), debugstr_w(netname), level, buf, parm_err);
1229 
1230  if (level != 2 && level != 502 && level != 503 && level != 1004 &&
1231  level != 1005 && level != 1006 && level != 1501)
1232  return ERROR_INVALID_LEVEL;
1233 
1234  RpcTryExcept
1235  {
1236  status = NetrShareSetInfo(servername,
1237  netname,
1238  level,
1239  (LPSHARE_INFO)&buf,
1240  parm_err);
1241  }
1243  {
1245  }
1246  RpcEndExcept;
1247 
1248  return status;
1249 }
1250 
1251 /* EOF */
LPSESSION_INFO_1 Buffer
Definition: srvsvc.idl:117
NET_API_STATUS __stdcall NetrServerTransportAdd(SRVSVC_HANDLE ServerName, DWORD Level, LPSERVER_TRANSPORT_INFO_0 Buffer)
Definition: rpcserver.c:507
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
RPC_STATUS WINAPI RpcBindingFromStringBindingW(RPC_WSTR StringBinding, RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:877
#define MAX_PREFERRED_LENGTH
Definition: lmcons.h:48
GLint level
Definition: gl.h:1546
#define RpcEndExcept
Definition: rpc.h:128
WCHAR * LMSTR
Definition: ms-dtyp.idl:119
RPC_STATUS WINAPI RpcBindingFree(RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:784
NET_API_STATUS WINAPI NetServerSetInfo(_In_ LPWSTR servername, _In_ DWORD level, _In_ LPBYTE buf, _Out_ LPDWORD parm_err)
Definition: srvsvc.c:399
PSERVER_XPORT_INFO_1_CONTAINER Level1
Definition: srvsvc.idl:945
NET_API_STATUS __stdcall NetrRemoteTOD(SRVSVC_HANDLE ServerName, LPTIME_OF_DAY_INFO *BufferPtr)
Definition: rpcserver.c:548
NET_API_STATUS __stdcall NetrServerTransportEnum(SRVSVC_HANDLE ServerName, LPSERVER_XPORT_ENUM_STRUCT InfoStruct, DWORD PreferedMaximumLength, DWORD *TotalEntries, DWORD *ResumeHandle)
Definition: rpcserver.c:520
NET_API_STATUS __stdcall NetrSessionEnum(SRVSVC_HANDLE ServerName, WCHAR *ClientName, WCHAR *UserName, PSESSION_ENUM_STRUCT InfoStruct, DWORD PreferedMaximumLength, DWORD *TotalEntries, DWORD *ResumeHandle)
Definition: rpcserver.c:221
NET_API_STATUS __stdcall NetrServerSetServiceBits(SRVSVC_HANDLE ServerName, WCHAR *Transport, DWORD ServiceBits, DWORD UpdateImmediately)
Definition: rpcserver.c:616
NET_API_STATUS __stdcall NetrShareEnum(SRVSVC_HANDLE ServerName, LPSHARE_ENUM_STRUCT InfoStruct, DWORD PreferedMaximumLength, DWORD *TotalEntries, DWORD *ResumeHandle)
Definition: rpcserver.c:265
static unsigned int bufptr
Definition: tncon.cpp:77
LPSERVER_TRANSPORT_INFO_0 Buffer
Definition: srvsvc.idl:873
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
handle_t hBinding
Definition: ctx_c.c:54
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:177
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
NET_API_STATUS __stdcall NetrServerDiskEnum(SRVSVC_HANDLE ServerName, DWORD Level, DISK_ENUM_CONTAINER *DiskInfoStruct, DWORD PreferedMaximumLength, DWORD *TotalEntries, DWORD *ResumeHandle)
Definition: rpcserver.c:456
NET_API_STATUS __stdcall NetrShareSetInfo(SRVSVC_HANDLE ServerName, WCHAR *NetName, DWORD Level, LPSHARE_INFO ShareInfo, DWORD *ParmErr)
Definition: rpcserver.c:294
NET_API_STATUS WINAPI NetRemoteTOD(_In_ LPCWSTR UncServerName, _Out_ LPBYTE *BufferPtr)
Definition: srvsvc.c:283
LPFILE_INFO_2 Buffer
Definition: srvsvc.idl:57
SESSION_INFO_10_CONTAINER * Level10
Definition: srvsvc.idl:174
NET_API_STATUS __stdcall NetrFileClose(SRVSVC_HANDLE ServerName, DWORD FileId)
Definition: rpcserver.c:209
SHARE_INFO_502_CONTAINER * Level502
Definition: srvsvc.idl:291
NET_API_STATUS WINAPI NetConnectionEnum(_In_ LMSTR servername, _In_ LMSTR qualifier, _In_ DWORD level, _Out_ LPBYTE *bufptr, _In_ DWORD prefmaxlen, _Out_ LPDWORD entriesread, _Out_ LPDWORD totalentries, _Inout_ LPDWORD resume_handle)
Definition: srvsvc.c:75
NET_API_STATUS __stdcall NetrFileEnum(SRVSVC_HANDLE ServerName, WCHAR *BasePath, WCHAR *UserName, PFILE_ENUM_STRUCT InfoStruct, DWORD PreferedMaximumLength, DWORD *TotalEntries, DWORD *ResumeHandle)
Definition: rpcserver.c:178
LPCONNECTION_INFO_1 Buffer
Definition: srvsvc.idl:34
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
NET_API_STATUS __stdcall NetrFileGetInfo(SRVSVC_HANDLE ServerName, DWORD FileId, DWORD Level, LPFILE_INFO InfoStruct)
Definition: rpcserver.c:195
SESSION_ENUM_UNION SessionInfo
Definition: srvsvc.idl:180
NET_API_STATUS __stdcall NetrServerTransportAddEx(SRVSVC_HANDLE ServerName, DWORD Level, LPTRANSPORT_INFO Buffer)
Definition: rpcserver.c:798
PSERVER_XPORT_INFO_0_CONTAINER Level0
Definition: srvsvc.idl:944
SHARE_INFO_1_CONTAINER * Level1
Definition: srvsvc.idl:288
SHARE_INFO_0_CONTAINER * Level0
Definition: srvsvc.idl:287
unsigned short * RPC_WSTR
Definition: rpcdce.h:46
NET_API_STATUS WINAPI NetShareDel(_In_ LMSTR servername, _In_ LMSTR netname, _In_ DWORD reserved)
Definition: srvsvc.c:914
RPC_STATUS WINAPI RpcStringBindingComposeW(RPC_WSTR ObjUuid, RPC_WSTR Protseq, RPC_WSTR NetworkAddr, RPC_WSTR Endpoint, RPC_WSTR Options, RPC_WSTR *StringBinding)
Definition: rpc_binding.c:511
NET_API_STATUS __stdcall NetrShareCheck(SRVSVC_HANDLE ServerName, WCHAR *Device, DWORD *Type)
Definition: rpcserver.c:335
CONNECT_ENUM_UNION ConnectInfo
Definition: srvsvc.idl:46
FILE_ENUM_UNION FileInfo
Definition: srvsvc.idl:84
LPSESSION_INFO_0 Buffer
Definition: srvsvc.idl:101
long RPC_STATUS
Definition: rpc.h:52
CONNECT_INFO_0_CONTAINER * Level0
Definition: srvsvc.idl:39
unsigned char * LPBYTE
Definition: typedefs.h:52
NET_API_STATUS WINAPI NetServerTransportDel(_In_ LPWSTR servername, _In_ DWORD level, _In_ LPBYTE bufptr)
Definition: srvsvc.c:515
NET_API_STATUS WINAPI NetShareGetInfo(_In_ LMSTR servername, _In_ LMSTR netname, _In_ DWORD level, _Out_ LPBYTE *bufptr)
Definition: srvsvc.c:1180
SHARE_ENUM_UNION ShareInfo
Definition: srvsvc.idl:298
LPCONNECTION_INFO_0 Buffer
Definition: srvsvc.idl:17
Definition: devices.h:37
NET_API_STATUS WINAPI NetSessionEnum(_In_ LMSTR servername, _In_ LMSTR UncClientName, _In_ LMSTR username, _In_ DWORD level, _Out_ LPBYTE *bufptr, _In_ DWORD prefmaxlen, _Out_ LPDWORD entriesread, _Out_ LPDWORD totalentries, _Inout_ LPDWORD resume_handle)
Definition: srvsvc.c:640
#define debugstr_w
Definition: kernel32.h:32
SESSION_INFO_1_CONTAINER * Level1
Definition: srvsvc.idl:172
#define RpcTryExcept
Definition: rpc.h:126
r reserved
Definition: btrfs.c:2673
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
LPSESSION_INFO_10 Buffer
Definition: srvsvc.idl:148
NET_API_STATUS __stdcall NetrShareAdd(SRVSVC_HANDLE ServerName, DWORD Level, LPSHARE_INFO InfoStruct, DWORD *ParmErr)
Definition: rpcserver.c:251
smooth NULL
Definition: ftsmooth.c:416
static APTTYPEQUALIFIER * qualifier
Definition: compobj.c:74
NET_API_STATUS WINAPI NetSessionGetInfo(_In_ LMSTR servername, _In_ LMSTR UncClientName, _In_ LMSTR username, _In_ DWORD level, _Out_ LPBYTE *bufptr)
Definition: srvsvc.c:761
#define _Out_
Definition: no_sal2.h:323
LPSHARE_INFO_2 Buffer
Definition: srvsvc.idl:262
void __RPC_USER SRVSVC_HANDLE_unbind(SRVSVC_HANDLE pszSystemName, handle_t hBinding)
Definition: srvsvc.c:58
LPSHARE_INFO_1 Buffer
Definition: srvsvc.idl:244
#define __RPC_USER
Definition: rpc.h:65
SESSION_INFO_502_CONTAINER * Level502
Definition: srvsvc.idl:175
NET_API_STATUS WINAPI NetShareAdd(_In_ LMSTR servername, _In_ DWORD level, _In_ LPBYTE buf, _Out_ LPDWORD parm_err)
Definition: srvsvc.c:853
handle_t __RPC_USER SRVSVC_HANDLE_bind(SRVSVC_HANDLE pszSystemName)
Definition: srvsvc.c:19
static WCHAR username[]
Definition: url.c:32
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
NET_API_STATUS WINAPI NetShareCheck(_In_ LMSTR servername, _In_ LMSTR device, _Out_ LPDWORD type)
Definition: srvsvc.c:886
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
NET_API_STATUS WINAPI NetShareEnumSticky(_In_ LMSTR servername, _In_ DWORD level, _Out_ LPBYTE *bufptr, _In_ DWORD prefmaxlen, _Out_ LPDWORD entriesread, _Out_ LPDWORD totalentries, _Inout_ LPDWORD resume_handle)
Definition: srvsvc.c:1078
if(!(yy_init))
Definition: macro.lex.yy.c:714
NET_API_STATUS __stdcall NetrShareDelSticky(SRVSVC_HANDLE ServerName, WCHAR *NetName, DWORD Reserved)
Definition: rpcserver.c:322
NET_API_STATUS __stdcall NetrServerGetInfo(SRVSVC_HANDLE ServerName, DWORD Level, LPSERVER_INFO *InfoStruct)
Definition: rpcserver.c:348
FILE_INFO_3_CONTAINER * Level3
Definition: srvsvc.idl:78
NET_API_STATUS WINAPI NetShareDelSticky(_In_ LMSTR servername, _In_ LMSTR netname, _In_ DWORD reserved)
Definition: srvsvc.c:945
#define WINAPI
Definition: msvc.h:8
LPDISK_INFO Buffer
Definition: srvsvc.idl:856
NET_API_STATUS __stdcall NetrSessionDel(SRVSVC_HANDLE ServerName, WCHAR *ClientName, WCHAR *UserName)
Definition: rpcserver.c:238
unsigned long DWORD
Definition: ntddk_ex.h:95
NET_API_STATUS WINAPI NetServerTransportAdd(_In_ LPWSTR servername, _In_ DWORD level, _In_ LPBYTE bufptr)
Definition: srvsvc.c:459
ULONG_PTR * PDWORD_PTR
Definition: basetsd.h:184
#define _Inout_
Definition: no_sal2.h:244
FILE_INFO_2_CONTAINER * Level2
Definition: srvsvc.idl:77
NET_API_STATUS WINAPI NetShareSetInfo(_In_ LPWSTR servername, _In_ LPWSTR netname, _In_ DWORD level, _In_ LPBYTE buf, _Out_ LPDWORD parm_err)
Definition: srvsvc.c:1218
NET_API_STATUS __stdcall NetrServerTransportDel(SRVSVC_HANDLE ServerName, DWORD Level, LPSERVER_TRANSPORT_INFO_0 Buffer)
Definition: rpcserver.c:535
static const WCHAR L[]
Definition: oid.c:1250
NET_API_STATUS __stdcall NetrServerSetInfo(SRVSVC_HANDLE ServerName, DWORD Level, LPSERVER_INFO ServerInfo, DWORD *ParmErr)
Definition: rpcserver.c:442
NET_API_STATUS WINAPI NetFileEnum(_In_ LMSTR servername, _In_ LMSTR basepath, _In_ LMSTR username, _In_ DWORD level, _Out_ LPBYTE *bufptr, _In_ DWORD prefmaxlen, _Out_ LPDWORD entriesread, _Out_ LPDWORD totalentries, _Inout_ PDWORD_PTR resume_handle)
Definition: srvsvc.c:175
NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE *bufptr)
Definition: srvsvc.c:369
LPSHARE_INFO_502_I Buffer
Definition: srvsvc.idl:282
SESSION_INFO_2_CONTAINER * Level2
Definition: srvsvc.idl:173
#define _In_
Definition: no_sal2.h:204
SHARE_INFO_2_CONTAINER * Level2
Definition: srvsvc.idl:289
SERVER_XPORT_ENUM_UNION XportInfo
Definition: srvsvc.idl:953
LPSHARE_INFO_0 Buffer
Definition: srvsvc.idl:231
LPSERVER_TRANSPORT_INFO_1 Buffer
Definition: srvsvc.idl:891
NET_API_STATUS WINAPI NetFileGetInfo(_In_ LMSTR servername, _In_ DWORD fileid, _In_ DWORD level, _Out_ LPBYTE *bufptr)
Definition: srvsvc.c:251
wchar_t * SRVSVC_HANDLE
Definition: srvsvc.idl:7
DWORD * PDWORD
Definition: pedump.c:68
NET_API_STATUS WINAPI NetServerTransportEnum(_In_ LPWSTR servername, _In_ DWORD level, _Out_ LPBYTE *bufptr, _In_ DWORD prefmaxlen, _Out_ LPDWORD entriesread, _Out_ LPDWORD totalentries, _Inout_ LPDWORD resume_handle)
Definition: srvsvc.c:543
CONNECT_INFO_1_CONTAINER * Level1
Definition: srvsvc.idl:40
WINE_DEFAULT_DEBUG_CHANNEL(srvsvc)
NET_API_STATUS WINAPI NetServerDiskEnum(_In_ LMSTR servername, _In_ DWORD level, _Out_ LPBYTE *bufptr, _In_ DWORD prefmaxlen, _Out_ LPDWORD entriesread, _Out_ LPDWORD totalentries, _Inout_ LPDWORD resume_handle)
Definition: srvsvc.c:311
NET_API_STATUS WINAPI NetShareEnum(_In_ LMSTR servername, _In_ DWORD level, _Out_ LPBYTE *bufptr, _In_ DWORD prefmaxlen, _Out_ LPDWORD entriesread, _Out_ LPDWORD totalentries, _Inout_ LPDWORD resume_handle)
Definition: srvsvc.c:976
uint32_t * LPDWORD
Definition: typedefs.h:57
LPFILE_INFO_3 Buffer
Definition: srvsvc.idl:72
NET_API_STATUS WINAPI NetSessionDel(_In_ LMSTR servername, _In_ LMSTR UncClientName, _In_ LMSTR username)
Definition: srvsvc.c:612
LPSESSION_INFO_502 Buffer
Definition: srvsvc.idl:166
NET_API_STATUS __stdcall NetrShareGetInfo(SRVSVC_HANDLE ServerName, WCHAR *NetName, DWORD Level, LPSHARE_INFO InfoStruct)
Definition: rpcserver.c:280
SESSION_INFO_0_CONTAINER * Level0
Definition: srvsvc.idl:171
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
NET_API_STATUS WINAPI I_NetServerSetServiceBits(_In_ LPWSTR servername, _In_ LPWSTR transport, _In_ DWORD servicebits, _In_ DWORD updateimmediately)
Definition: srvsvc.c:429
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static SERVICE_STATUS status
Definition: service.c:31
NET_API_STATUS WINAPI NetServerTransportAddEx(_In_ LPWSTR servername, _In_ DWORD level, _In_ LPBYTE bufptr)
Definition: srvsvc.c:487
NET_API_STATUS __stdcall NetrConnectionEnum(SRVSVC_HANDLE ServerName, WCHAR *Qualifier, LPCONNECT_ENUM_STRUCT InfoStruct, DWORD PreferedMaximumLength, DWORD *TotalEntries, DWORD *ResumeHandle)
Definition: rpcserver.c:162
LPSESSION_INFO_2 Buffer
Definition: srvsvc.idl:134
#define RpcExcept(expr)
Definition: rpc.h:127
NET_API_STATUS __stdcall NetrShareDel(SRVSVC_HANDLE ServerName, WCHAR *NetName, DWORD Reserved)
Definition: rpcserver.c:309
NET_API_STATUS WINAPI NetFileClose(_In_ LMSTR servername, _In_ DWORD fileid)
Definition: srvsvc.c:149
LONG WINAPI I_RpcMapWin32Status(RPC_STATUS status)
Definition: rpcrt4_main.c:741
Definition: ps.c:97