1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 //! This module defines the API function prototypes and data structures
7 use shared::basetsd::PDWORD_PTR;
8 use shared::guiddef::GUID;
9 use shared::lmcons::{LMSTR, NET_API_STATUS, PARMNUM_BASE_INFOLEVEL};
10 use shared::minwindef::{DWORD, LPBYTE, LPDWORD, ULONG};
11 use um::winnt::{BOOLEAN, PSECURITY_DESCRIPTOR};
12 extern "system" {
NetShareAdd( servername: LMSTR, level: DWORD, buf: LPBYTE, parm_err: LPDWORD, ) -> NET_API_STATUS13     pub fn NetShareAdd(
14         servername: LMSTR,
15         level: DWORD,
16         buf: LPBYTE,
17         parm_err: LPDWORD,
18     ) -> NET_API_STATUS;
NetShareEnum( servername: LMSTR, level: DWORD, bufptr: *mut LPBYTE, prefmaxlen: DWORD, entriesread: LPDWORD, totalentries: LPDWORD, resumehandle: LPDWORD, ) -> NET_API_STATUS19     pub fn NetShareEnum(
20         servername: LMSTR,
21         level: DWORD,
22         bufptr: *mut LPBYTE,
23         prefmaxlen: DWORD,
24         entriesread: LPDWORD,
25         totalentries: LPDWORD,
26         resumehandle: LPDWORD,
27     ) -> NET_API_STATUS;
NetShareEnumSticky( servername: LMSTR, level: DWORD, bufptr: *mut LPBYTE, prefmaxlen: DWORD, entriesread: LPDWORD, totalentries: LPDWORD, resumehandle: LPDWORD, ) -> NET_API_STATUS28     pub fn NetShareEnumSticky(
29         servername: LMSTR,
30         level: DWORD,
31         bufptr: *mut LPBYTE,
32         prefmaxlen: DWORD,
33         entriesread: LPDWORD,
34         totalentries: LPDWORD,
35         resumehandle: LPDWORD,
36     ) -> NET_API_STATUS;
NetShareGetInfo( servername: LMSTR, netname: LMSTR, level: DWORD, bufptr: *mut LPBYTE, ) -> NET_API_STATUS37     pub fn NetShareGetInfo(
38         servername: LMSTR,
39         netname: LMSTR,
40         level: DWORD,
41         bufptr: *mut LPBYTE,
42     ) -> NET_API_STATUS;
NetShareSetInfo( servername: LMSTR, netname: LMSTR, level: DWORD, buf: LPBYTE, parm_err: LPDWORD, ) -> NET_API_STATUS43     pub fn NetShareSetInfo(
44         servername: LMSTR,
45         netname: LMSTR,
46         level: DWORD,
47         buf: LPBYTE,
48         parm_err: LPDWORD,
49     ) -> NET_API_STATUS;
NetShareDel( servername: LMSTR, netname: LMSTR, reserved: DWORD, ) -> NET_API_STATUS50     pub fn NetShareDel(
51         servername: LMSTR,
52         netname: LMSTR,
53         reserved: DWORD,
54     ) -> NET_API_STATUS;
NetShareDelSticky( servername: LMSTR, netname: LMSTR, reserved: DWORD, ) -> NET_API_STATUS55     pub fn NetShareDelSticky(
56         servername: LMSTR,
57         netname: LMSTR,
58         reserved: DWORD,
59     ) -> NET_API_STATUS;
NetShareCheck( servername: LMSTR, device: LMSTR, _type: LPDWORD, ) -> NET_API_STATUS60     pub fn NetShareCheck(
61         servername: LMSTR,
62         device: LMSTR,
63         _type: LPDWORD,
64     ) -> NET_API_STATUS;
NetShareDelEx( servername: LMSTR, level: DWORD, buf: LPBYTE, ) -> NET_API_STATUS65     pub fn NetShareDelEx(
66         servername: LMSTR,
67         level: DWORD,
68         buf: LPBYTE,
69     ) -> NET_API_STATUS;
70 }
71 STRUCT!{struct SHARE_INFO_0 {
72     shi0_netname: LMSTR,
73 }}
74 pub type PSHARE_INFO_0 = *mut SHARE_INFO_0;
75 pub type LPSHARE_INFO_0 = *mut SHARE_INFO_0;
76 STRUCT!{struct SHARE_INFO_1 {
77     shi1_netname: LMSTR,
78     shi1_type: DWORD,
79     shi1_remark: LMSTR,
80 }}
81 pub type PSHARE_INFO_1 = *mut SHARE_INFO_1;
82 pub type LPSHARE_INFO_1 = *mut SHARE_INFO_1;
83 STRUCT!{struct SHARE_INFO_2 {
84     shi2_netname: LMSTR,
85     shi2_type: DWORD,
86     shi2_remark: LMSTR,
87     shi2_permissions: DWORD,
88     shi2_max_uses: DWORD,
89     shi2_current_uses: DWORD,
90     shi2_path: LMSTR,
91     shi2_passwd: LMSTR,
92 }}
93 pub type PSHARE_INFO_2 = *mut SHARE_INFO_2;
94 pub type LPSHARE_INFO_2 = *mut SHARE_INFO_2;
95 STRUCT!{struct SHARE_INFO_501 {
96     shi501_netname: LMSTR,
97     shi501_type: DWORD,
98     shi501_remark: LMSTR,
99     shi501_flags: DWORD,
100 }}
101 pub type PSHARE_INFO_501 = *mut SHARE_INFO_501;
102 pub type LPSHARE_INFO_501 = *mut SHARE_INFO_501;
103 STRUCT!{struct SHARE_INFO_502 {
104     shi502_netname: LMSTR,
105     shi502_type: DWORD,
106     shi502_remark: LMSTR,
107     shi502_permissions: DWORD,
108     shi502_max_uses: DWORD,
109     shi502_current_uses: DWORD,
110     shi502_path: LMSTR,
111     shi502_passwd: LMSTR,
112     shi502_reserved: DWORD,
113     shi502_security_descriptor: PSECURITY_DESCRIPTOR,
114 }}
115 pub type PSHARE_INFO_502 = *mut SHARE_INFO_502;
116 pub type LPSHARE_INFO_502 = *mut SHARE_INFO_502;
117 STRUCT!{struct SHARE_INFO_503 {
118     shi503_netname: LMSTR,
119     shi503_type: DWORD,
120     shi503_remark: LMSTR,
121     shi503_permissions: DWORD,
122     shi503_max_uses: DWORD,
123     shi503_current_uses: DWORD,
124     shi503_path: LMSTR,
125     shi503_passwd: LMSTR,
126     shi503_servername: LMSTR,
127     shi503_reserved: DWORD,
128     shi503_security_descriptor: PSECURITY_DESCRIPTOR,
129 }}
130 pub type PSHARE_INFO_503 = *mut SHARE_INFO_503;
131 pub type LPSHARE_INFO_503 = *mut SHARE_INFO_503;
132 STRUCT!{struct SHARE_INFO_1004 {
133     shi1004_remark: LMSTR,
134 }}
135 pub type PSHARE_INFO_1004 = *mut SHARE_INFO_1004;
136 pub type LPSHARE_INFO_1004 = *mut SHARE_INFO_1004;
137 STRUCT!{struct SHARE_INFO_1005 {
138     shi1005_flags: DWORD,
139 }}
140 pub type PSHARE_INFO_1005 = *mut SHARE_INFO_1005;
141 pub type LPSHARE_INFO_1005 = *mut SHARE_INFO_1005;
142 STRUCT!{struct SHARE_INFO_1006 {
143     shi1006_max_uses: DWORD,
144 }}
145 pub type PSHARE_INFO_1006 = *mut SHARE_INFO_1006;
146 pub type LPSHARE_INFO_1006 = *mut SHARE_INFO_1006;
147 STRUCT!{struct SHARE_INFO_1501 {
148     shi1501_reserved: DWORD,
149     shi1501_security_descriptor: PSECURITY_DESCRIPTOR,
150 }}
151 pub type PSHARE_INFO_1501 = *mut SHARE_INFO_1501;
152 pub type LPSHARE_INFO_1501 = *mut SHARE_INFO_1501;
153 STRUCT!{struct SHARE_INFO_1503 {
154     shi1503_sharefilter: GUID,
155 }}
156 pub type PSHARE_INFO_1503 = *mut SHARE_INFO_1503;
157 pub type LPSHARE_INFO_1503 = *mut SHARE_INFO_1503;
158 extern "system" {
NetServerAliasAdd( servername: LMSTR, level: DWORD, buf: LPBYTE, ) -> NET_API_STATUS159     pub fn NetServerAliasAdd(
160         servername: LMSTR,
161         level: DWORD,
162         buf: LPBYTE,
163     ) -> NET_API_STATUS;
NetServerAliasDel( servername: LMSTR, level: DWORD, buf: LPBYTE, ) -> NET_API_STATUS164     pub fn NetServerAliasDel(
165         servername: LMSTR,
166         level: DWORD,
167         buf: LPBYTE,
168     ) -> NET_API_STATUS;
NetServerAliasEnum( servername: LMSTR, level: DWORD, bufptr: *mut LPBYTE, prefmaxlen: DWORD, entriesread: LPDWORD, totalentries: LPDWORD, resumehandle: LPDWORD, ) -> NET_API_STATUS169     pub fn NetServerAliasEnum(
170         servername: LMSTR,
171         level: DWORD,
172         bufptr: *mut LPBYTE,
173         prefmaxlen: DWORD,
174         entriesread: LPDWORD,
175         totalentries: LPDWORD,
176         resumehandle: LPDWORD,
177     ) -> NET_API_STATUS;
178 }
179 STRUCT!{struct SERVER_ALIAS_INFO_0 {
180     srvai0_alias: LMSTR,
181     srvai0_target: LMSTR,
182     srvai0_default: BOOLEAN,
183     srvai0_reserved: ULONG,
184 }}
185 pub type PSERVER_ALIAS_INFO_0 = *mut SERVER_ALIAS_INFO_0;
186 pub type LPSERVER_ALIAS_INFO_0 = *mut SERVER_ALIAS_INFO_0;
187 pub const SHARE_NETNAME_PARMNUM: DWORD = 1;
188 pub const SHARE_TYPE_PARMNUM: DWORD = 3;
189 pub const SHARE_REMARK_PARMNUM: DWORD = 4;
190 pub const SHARE_PERMISSIONS_PARMNUM: DWORD = 5;
191 pub const SHARE_MAX_USES_PARMNUM: DWORD = 6;
192 pub const SHARE_CURRENT_USES_PARMNUM: DWORD = 7;
193 pub const SHARE_PATH_PARMNUM: DWORD = 8;
194 pub const SHARE_PASSWD_PARMNUM: DWORD = 9;
195 pub const SHARE_FILE_SD_PARMNUM: DWORD = 501;
196 pub const SHARE_SERVER_PARMNUM: DWORD = 503;
197 pub const SHARE_REMARK_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SHARE_REMARK_PARMNUM;
198 pub const SHARE_MAX_USES_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SHARE_MAX_USES_PARMNUM;
199 pub const SHARE_FILE_SD_INFOLEVEL: DWORD = PARMNUM_BASE_INFOLEVEL + SHARE_FILE_SD_PARMNUM;
200 pub const SHI1_NUM_ELEMENTS: DWORD = 4;
201 pub const SHI2_NUM_ELEMENTS: DWORD = 10;
202 pub const STYPE_DISKTREE: DWORD = 0;
203 pub const STYPE_PRINTQ: DWORD = 1;
204 pub const STYPE_DEVICE: DWORD = 2;
205 pub const STYPE_IPC: DWORD = 3;
206 pub const STYPE_MASK: DWORD = 0x000000FF;
207 pub const STYPE_RESERVED1: DWORD = 0x01000000;
208 pub const STYPE_RESERVED2: DWORD = 0x02000000;
209 pub const STYPE_RESERVED3: DWORD = 0x04000000;
210 pub const STYPE_RESERVED4: DWORD = 0x08000000;
211 pub const STYPE_RESERVED_ALL: DWORD = 0x3FFFFF00;
212 pub const STYPE_TEMPORARY: DWORD = 0x40000000;
213 pub const STYPE_SPECIAL: DWORD = 0x80000000;
214 pub const SHI_USES_UNLIMITED: DWORD = -1i32 as u32;
215 pub const SHI1005_FLAGS_DFS: DWORD = 0x0001;
216 pub const SHI1005_FLAGS_DFS_ROOT: DWORD = 0x0002;
217 pub const CSC_MASK_EXT: DWORD = 0x2030;
218 pub const CSC_MASK: DWORD = 0x0030;
219 pub const CSC_CACHE_MANUAL_REINT: DWORD = 0x0000;
220 pub const CSC_CACHE_AUTO_REINT: DWORD = 0x0010;
221 pub const CSC_CACHE_VDO: DWORD = 0x0020;
222 pub const CSC_CACHE_NONE: DWORD = 0x0030;
223 pub const SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS: DWORD = 0x00100;
224 pub const SHI1005_FLAGS_FORCE_SHARED_DELETE: DWORD = 0x00200;
225 pub const SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING: DWORD = 0x00400;
226 pub const SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM: DWORD = 0x00800;
227 pub const SHI1005_FLAGS_FORCE_LEVELII_OPLOCK: DWORD = 0x01000;
228 pub const SHI1005_FLAGS_ENABLE_HASH: DWORD = 0x02000;
229 pub const SHI1005_FLAGS_ENABLE_CA: DWORD = 0x04000;
230 pub const SHI1005_FLAGS_ENCRYPT_DATA: DWORD = 0x08000;
231 pub const SHI1005_FLAGS_RESERVED: DWORD = 0x10000;
232 pub const SHI1005_VALID_FLAGS_SET: DWORD = CSC_MASK | SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS
233     | SHI1005_FLAGS_FORCE_SHARED_DELETE | SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING
234     | SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM | SHI1005_FLAGS_FORCE_LEVELII_OPLOCK
235     | SHI1005_FLAGS_ENABLE_HASH | SHI1005_FLAGS_ENABLE_CA | SHI1005_FLAGS_ENCRYPT_DATA
236     | SHI1005_FLAGS_RESERVED;
237 extern "system" {
NetSessionEnum( servername: LMSTR, UncClientName: LMSTR, username: LMSTR, level: DWORD, bufptr: *mut LPBYTE, prefmaxlen: DWORD, entriesread: LPDWORD, totalentries: LPDWORD, resumehandle: LPDWORD, ) -> NET_API_STATUS238     pub fn NetSessionEnum(
239         servername: LMSTR,
240         UncClientName: LMSTR,
241         username: LMSTR,
242         level: DWORD,
243         bufptr: *mut LPBYTE,
244         prefmaxlen: DWORD,
245         entriesread: LPDWORD,
246         totalentries: LPDWORD,
247         resumehandle: LPDWORD,
248     ) -> NET_API_STATUS;
NetSessionDel( servername: LMSTR, UncClientName: LMSTR, username: LMSTR, ) -> NET_API_STATUS249     pub fn NetSessionDel(
250         servername: LMSTR,
251         UncClientName: LMSTR,
252         username: LMSTR,
253     ) -> NET_API_STATUS;
NetSessionGetInfo( servername: LMSTR, UncClientName: LMSTR, username: LMSTR, level: DWORD, bufptr: *mut LPBYTE, ) -> NET_API_STATUS254     pub fn NetSessionGetInfo(
255         servername: LMSTR,
256         UncClientName: LMSTR,
257         username: LMSTR,
258         level: DWORD,
259         bufptr: *mut LPBYTE,
260     ) -> NET_API_STATUS;
261 }
262 STRUCT!{struct SESSION_INFO_0 {
263     sesi0_cname: LMSTR,
264 }}
265 pub type PSESSION_INFO_0 = *mut SESSION_INFO_0;
266 pub type LPSESSION_INFO_0 = *mut SESSION_INFO_0;
267 STRUCT!{struct SESSION_INFO_1 {
268     sesi1_cname: LMSTR,
269     sesi1_username: LMSTR,
270     sesi1_num_opens: DWORD,
271     sesi1_time: DWORD,
272     sesi1_idle_time: DWORD,
273     sesi1_user_flags: DWORD,
274 }}
275 pub type PSESSION_INFO_1 = *mut SESSION_INFO_1;
276 pub type LPSESSION_INFO_1 = *mut SESSION_INFO_1;
277 STRUCT!{struct SESSION_INFO_2 {
278     sesi2_cname: LMSTR,
279     sesi2_username: LMSTR,
280     sesi2_num_opens: DWORD,
281     sesi2_time: DWORD,
282     sesi2_idle_time: DWORD,
283     sesi2_user_flags: DWORD,
284     sesi2_cltype_name: LMSTR,
285 }}
286 pub type PSESSION_INFO_2 = *mut SESSION_INFO_2;
287 pub type LPSESSION_INFO_2 = *mut SESSION_INFO_2;
288 STRUCT!{struct SESSION_INFO_10 {
289     sesi10_cname: LMSTR,
290     sesi10_username: LMSTR,
291     sesi10_time: DWORD,
292     sesi10_idle_time: DWORD,
293 }}
294 pub type PSESSION_INFO_10 = *mut SESSION_INFO_10;
295 pub type LPSESSION_INFO_10 = *mut SESSION_INFO_10;
296 STRUCT!{struct SESSION_INFO_502 {
297     sesi502_cname: LMSTR,
298     sesi502_username: LMSTR,
299     sesi502_num_opens: DWORD,
300     sesi502_time: DWORD,
301     sesi502_idle_time: DWORD,
302     sesi502_user_flags: DWORD,
303     sesi502_cltype_name: LMSTR,
304     sesi502_transport: LMSTR,
305 }}
306 pub type PSESSION_INFO_502 = *mut SESSION_INFO_502;
307 pub type LPSESSION_INFO_502 = *mut SESSION_INFO_502;
308 pub const SESS_GUEST: DWORD = 0x00000001;
309 pub const SESS_NOENCRYPTION: DWORD = 0x00000002;
310 pub const SESI1_NUM_ELEMENTS: DWORD = 8;
311 pub const SESI2_NUM_ELEMENTS: DWORD = 9;
312 extern "system" {
NetConnectionEnum( servername: LMSTR, qualifier: LMSTR, level: DWORD, bufptr: *mut LPBYTE, prefmaxlen: DWORD, entriesread: LPDWORD, totalentries: LPDWORD, resume_handle: LPDWORD, ) -> NET_API_STATUS313     pub fn NetConnectionEnum(
314         servername: LMSTR,
315         qualifier: LMSTR,
316         level: DWORD,
317         bufptr: *mut LPBYTE,
318         prefmaxlen: DWORD,
319         entriesread: LPDWORD,
320         totalentries: LPDWORD,
321         resume_handle: LPDWORD,
322     ) -> NET_API_STATUS;
323 }
324 STRUCT!{struct CONNECTION_INFO_0 {
325     coni0_id: DWORD,
326 }}
327 pub type PCONNECTION_INFO_0 = *mut CONNECTION_INFO_0;
328 pub type LPCONNECTION_INFO_0 = *mut CONNECTION_INFO_0;
329 STRUCT!{struct CONNECTION_INFO_1 {
330     coni1_id: DWORD,
331     coni1_type: DWORD,
332     coni1_num_opens: DWORD,
333     coni1_num_users: DWORD,
334     coni1_time: DWORD,
335     coni1_username: LMSTR,
336     coni1_netname: LMSTR,
337 }}
338 pub type PCONNECTION_INFO_1 = *mut CONNECTION_INFO_1;
339 pub type LPCONNECTION_INFO_1 = *mut CONNECTION_INFO_1;
340 extern "system" {
NetFileClose( servername: LMSTR, fileid: DWORD, ) -> NET_API_STATUS341     pub fn NetFileClose(
342         servername: LMSTR,
343         fileid: DWORD,
344     ) -> NET_API_STATUS;
NetFileEnum( servername: LMSTR, basepath: LMSTR, username: LMSTR, level: DWORD, bufptr: *mut LPBYTE, prefmaxlen: DWORD, entriesread: LPDWORD, totalentries: LPDWORD, resume_handle: PDWORD_PTR, ) -> NET_API_STATUS345     pub fn NetFileEnum(
346         servername: LMSTR,
347         basepath: LMSTR,
348         username: LMSTR,
349         level: DWORD,
350         bufptr: *mut LPBYTE,
351         prefmaxlen: DWORD,
352         entriesread: LPDWORD,
353         totalentries: LPDWORD,
354         resume_handle: PDWORD_PTR,
355     ) -> NET_API_STATUS;
NetFileGetInfo( servername: LMSTR, fileid: DWORD, level: DWORD, bufptr: *mut LPBYTE, ) -> NET_API_STATUS356     pub fn NetFileGetInfo(
357         servername: LMSTR,
358         fileid: DWORD,
359         level: DWORD,
360         bufptr: *mut LPBYTE,
361     ) -> NET_API_STATUS;
362 }
363 STRUCT!{struct FILE_INFO_2 {
364     fi2_id: DWORD,
365 }}
366 pub type PFILE_INFO_2 = *mut FILE_INFO_2;
367 pub type LPFILE_INFO_2 = *mut FILE_INFO_2;
368 STRUCT!{struct FILE_INFO_3 {
369     fi3_id: DWORD,
370     fi3_permissions: DWORD,
371     fi3_num_locks: DWORD,
372     fi3_pathname: LMSTR,
373     fi3_username: LMSTR,
374 }}
375 pub type PFILE_INFO_3 = *mut FILE_INFO_3;
376 pub type LPFILE_INFO_3 = *mut FILE_INFO_3;
377 pub const PERM_FILE_READ: DWORD = 0x1;
378 pub const PERM_FILE_WRITE: DWORD = 0x2;
379 pub const PERM_FILE_CREATE: DWORD = 0x4;
380