ReactOS 0.4.15-dev-7953-g1f49173
nfs41_np.c
Go to the documentation of this file.
1/* NFSv4.1 client for Windows
2 * Copyright © 2012 The Regents of the University of Michigan
3 *
4 * Olga Kornievskaia <aglo@umich.edu>
5 * Casey Bodley <cbodley@umich.edu>
6 *
7 * This library is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 of the License, or (at
10 * your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * without any warranty; without even the implied warranty of merchantability
14 * or fitness for a particular purpose. See the GNU Lesser General Public
15 * License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 */
21
22#include <windows.h>
23#include <npapi.h>
24#include <devioctl.h>
25#include <strsafe.h>
26
27#include "nfs41_driver.h"
28#include "nfs41_np.h"
29#include "options.h"
30
31#include <pseh/pseh2.h>
32
33#ifdef DBG
34#define DbgP(_x_) NFS41DbgPrint _x_
35#else
36#define DbgP(_x_)
37#endif
38#define TRACE_TAG L"[NFS41_NP]"
39#define WNNC_DRIVER( major, minor ) ( major * 0x00010000 + minor )
40
41
43{
44 ULONG rc = 0;
45 TCHAR szbuffer[256];
46
49 {
50
51 //StringCchVPrintfW( szbuffer, 127, Format, marker );
52 StringCchVPrintfW( szbuffer, 256, Format, marker );
53 szbuffer[255] = (TCHAR)0;
55 OutputDebugString( szbuffer );
56 }
57
58 return rc;
59}
60
61int filter(unsigned int code)
62{
63 DbgP((L"####Got exception %u\n", code));
65}
66
69 PHANDLE phMutex,
70 PHANDLE phMemory,
72/*++
73
74Routine Description:
75
76 This routine opens the shared memory for exclusive manipulation
77
78Arguments:
79
80 phMutex - the mutex handle
81
82 phMemory - the memory handle
83
84 pMemory - a ptr. to the shared memory which is set if successful
85
86Return Value:
87
88 WN_SUCCESS -- if successful
89
90--*/
91{
93
94 *phMutex = 0;
95 *phMemory = 0;
96 *pMemory = NULL;
97
99 if (*phMutex == NULL)
100 {
102 DbgP((TEXT("OpenSharedMemory: OpenMutex failed\n")));
103 goto OpenSharedMemoryAbort1;
104 }
105
106 WaitForSingleObject(*phMutex, INFINITE);
107
109 FALSE,
111 if (*phMemory == NULL)
112 {
114 DbgP((TEXT("OpenSharedMemory: OpenFileMapping failed\n")));
115 goto OpenSharedMemoryAbort2;
116 }
117
118 *pMemory = MapViewOfFile(*phMemory, FILE_MAP_WRITE, 0, 0, 0);
119 if (*pMemory == NULL)
120 {
122 DbgP((TEXT("OpenSharedMemory: MapViewOfFile failed\n")));
123 goto OpenSharedMemoryAbort3;
124 }
125
126 return ERROR_SUCCESS;
127
128OpenSharedMemoryAbort3:
129 CloseHandle(*phMemory);
130
131OpenSharedMemoryAbort2:
132 ReleaseMutex(*phMutex);
133 CloseHandle(*phMutex);
134 *phMutex = NULL;
135
136OpenSharedMemoryAbort1:
137 DbgP((TEXT("OpenSharedMemory: return dwStatus: %d\n"), dwStatus));
138
139 return dwStatus;
140}
141
142VOID
146 PVOID *pMemory)
147/*++
148
149Routine Description:
150
151 This routine relinquishes control of the shared memory after exclusive
152 manipulation
153
154Arguments:
155
156 hMutex - the mutex handle
157
158 hMemory - the memory handle
159
160 pMemory - a ptr. to the shared memory which is set if successful
161
162Return Value:
163
164--*/
165{
166 if (*pMemory)
167 {
169 *pMemory = NULL;
170 }
171 if (*hMemory)
172 {
174 *hMemory = 0;
175 }
176 if (*hMutex)
177 {
178 if (ReleaseMutex(*hMutex) == FALSE)
179 {
180 DbgP((TEXT("CloseSharedMemory: ReleaseMutex error: %d\n"), GetLastError()));
181 }
183 *hMutex = 0;
184 }
185}
186
188 IN LPCWSTR LocalName,
189 IN LPCWSTR ConnectionName,
190 IN USHORT ConnectionNameLength,
191 IN LPNETRESOURCE lpNetResource)
192{
195 PNFS41NP_SHARED_MEMORY pSharedMemory;
196 PNFS41NP_NETRESOURCE pNfs41NetResource;
197 INT Index;
198 BOOLEAN FreeEntryFound = FALSE;
199
200#ifdef __REACTOS__
201 status = OpenSharedMemory(&hMutex, &hMemory, (PVOID *)&pSharedMemory);
202#else
203 status = OpenSharedMemory(&hMutex, &hMemory, &(PVOID)pSharedMemory);
204#endif
205 if (status)
206 goto out;
207
208 DbgP((TEXT("StoreConnectionInfo: NextIndex %d, NumResources %d\n"),
209 pSharedMemory->NextAvailableIndex,
210 pSharedMemory->NumberOfResourcesInUse));
211
212 for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
213 {
214 if (!pSharedMemory->NetResources[Index].InUse)
215 {
216 FreeEntryFound = TRUE;
217 DbgP((TEXT("Reusing existing index %d\n"), Index));
218 break;
219 }
220 }
221
222 if (!FreeEntryFound)
223 {
224 if (pSharedMemory->NextAvailableIndex >= NFS41NP_MAX_DEVICES) {
226 goto out_close;
227 }
228 Index = pSharedMemory->NextAvailableIndex++;
229 DbgP((TEXT("Using new index %d\n"), Index));
230 }
231
232 pSharedMemory->NumberOfResourcesInUse += 1;
233
234 pNfs41NetResource = &pSharedMemory->NetResources[Index];
235
236 pNfs41NetResource->InUse = TRUE;
237 pNfs41NetResource->dwScope = lpNetResource->dwScope;
238 pNfs41NetResource->dwType = lpNetResource->dwType;
239 pNfs41NetResource->dwDisplayType = lpNetResource->dwDisplayType;
240 pNfs41NetResource->dwUsage = RESOURCEUSAGE_CONNECTABLE;
241 pNfs41NetResource->LocalNameLength = (USHORT)(wcslen(LocalName) + 1) * sizeof(WCHAR);
242 pNfs41NetResource->RemoteNameLength = (USHORT)(wcslen(lpNetResource->lpRemoteName) + 1) * sizeof(WCHAR);
243 pNfs41NetResource->ConnectionNameLength = ConnectionNameLength;
244
245 StringCchCopy(pNfs41NetResource->LocalName,
246 pNfs41NetResource->LocalNameLength,
247 LocalName);
248 StringCchCopy(pNfs41NetResource->RemoteName,
249 pNfs41NetResource->RemoteNameLength,
250 lpNetResource->lpRemoteName);
251 StringCchCopy(pNfs41NetResource->ConnectionName,
252 pNfs41NetResource->ConnectionNameLength,
253 ConnectionName);
254
255 // TODO: copy mount options -cbodley
256
257out_close:
258#ifdef __REACTOS__
259 CloseSharedMemory(&hMutex, &hMemory, (PVOID *)&pSharedMemory);
260#else
261 CloseSharedMemory(&hMutex, &hMemory, &(PVOID)pSharedMemory);
262#endif
263out:
264 return status;
265}
266
267ULONG
270 IN PVOID InputDataBuf,
271 IN ULONG InputDataLen,
272 IN PVOID OutputDataBuf,
273 IN PULONG pOutputDataLen)
274{
275 HANDLE DeviceHandle; // The mini rdr device handle
276 BOOL rc = FALSE;
278
280 DbgP((L"[aglo] calling CreateFile\n"));
287 0,
288 (HANDLE) NULL );
289
290 DbgP((L"[aglo] after CreateFile Device Handle\n"));
292 {
293 _SEH2_TRY {
294 DbgP((L"[aglo] calling DeviceIoControl\n"));
295 rc = DeviceIoControl(
297 IoctlCode,
298 InputDataBuf,
299 InputDataLen,
300 OutputDataBuf,
301 *pOutputDataLen,
302 pOutputDataLen,
303 NULL );
305 DbgP((L"#### In except\n"));
306 } _SEH2_END;
307 DbgP((L"[aglo] returned from DeviceIoControl %08lx\n", rc));
308 if ( !rc )
309 {
310 DbgP((L"[aglo] SendTo_NFS41Driver: returning error from DeviceIoctl\n"));
311 Status = GetLastError( );
312 }
313 else
314 {
315 DbgP((L"[aglo] SendTo_NFS41Driver: The DeviceIoctl call succeded\n"));
316 }
318 }
319 else
320 {
321 Status = GetLastError( );
322 DbgP((L"[aglo] SendTo_NFS41Driver: error %08lx opening device \n", Status));
323 }
324 DbgP((L"[aglo] returned from SendTo_NFS41Driver %08lx\n", Status));
325 return Status;
326}
327
330 DWORD nIndex )
331{
332 DWORD rc = 0;
333
334#ifndef __REACTOS__
335 DbgP(( L"[aglo] GetNetCaps %d\n", nIndex ));
336#endif
337 switch ( nIndex )
338 {
341 break;
342
343 case WNNC_NET_TYPE:
345 break;
346
348 rc = WNNC_DRIVER(1, 0);
349 break;
350
351 case WNNC_CONNECTION:
356 break;
357
358 case WNNC_ENUMERATION:
359 rc = WNNC_ENUM_LOCAL;
360 break;
361
362 case WNNC_START:
363 rc = 1;
364 break;
365
366 case WNNC_USER:
367 case WNNC_DIALOG:
368 case WNNC_ADMIN:
369 default:
370 rc = 0;
371 break;
372 }
373
374 return rc;
375}
376
379 __in PLUID lpLogonId,
380 __in PCWSTR lpAuthentInfoType,
381 __in PVOID lpAuthentInfo,
382 __in PCWSTR lpPreviousAuthentInfoType,
383 __in PVOID lpPreviousAuthentInfo,
384 __in PWSTR lpStationName,
385 __in PVOID StationHandle,
386 __out PWSTR *lpLogonScript)
387{
388 *lpLogonScript = NULL;
389 DbgP(( L"[aglo] NPLogonNotify: returning WN_SUCCESS\n" ));
390 return WN_SUCCESS;
391}
392
395 __in LPCWSTR lpAuthentInfoType,
396 __in LPVOID lpAuthentInfo,
397 __in LPCWSTR lpPreviousAuthentInfoType,
398 __in LPVOID lpPreviousAuthentInfo,
399 __in LPWSTR lpStationName,
400 LPVOID StationHandle,
401 DWORD dwChangeInfo )
402{
403 DbgP(( L"[aglo] NPPasswordChangeNotify: WN_NOT_SUPPORTED\n" ));
405 return WN_NOT_SUPPORTED;
406}
407
408#ifdef __REACTOS__
411 __in HWND hwndOwner,
412 __in LPNETRESOURCE lpNetResource,
413 __in_opt LPWSTR lpPassword,
414 __in_opt LPWSTR lpUserName,
416#endif
417
420 __in LPNETRESOURCE lpNetResource,
421 __in_opt LPWSTR lpPassword,
422 __in_opt LPWSTR lpUserName )
423{
424 return NPAddConnection3( NULL, lpNetResource, lpPassword, lpUserName, 0 );
425}
426
429 __in HWND hwndOwner,
430 __in LPNETRESOURCE lpNetResource,
431 __in_opt LPWSTR lpPassword,
432 __in_opt LPWSTR lpUserName,
434{
436 WCHAR wszScratch[128];
437 WCHAR LocalName[3];
438 DWORD CopyBytes = 0;
439 CONNECTION_INFO Connection;
440 LPWSTR ConnectionName;
441 WCHAR ServerName[MAX_PATH];
442 PWCHAR p;
443 DWORD i;
444
445 DbgP(( L"[aglo] NPAddConnection3('%s', '%s')\n",
446 lpNetResource->lpLocalName, lpNetResource->lpRemoteName ));
447 DbgP(( L"[aglo] username = '%s', passwd = '%s'\n", lpUserName, lpPassword));
448
449 Status = InitializeConnectionInfo(&Connection,
450 (PMOUNT_OPTION_BUFFER)lpNetResource->lpComment,
451 &ConnectionName);
452 if (Status) {
453 DbgP(( L"InitializeConnectionInfo failed with %d\n", Status ));
454 goto out;
455 }
456
457 // \device\miniredirector\;<DriveLetter>:\Server\Share
458
459 // local name, must start with "X:"
460 if (lstrlen(lpNetResource->lpLocalName) < 2 ||
461 lpNetResource->lpLocalName[1] != L':') {
463 goto out;
464 }
465
466 LocalName[0] = (WCHAR) toupper(lpNetResource->lpLocalName[0]);
467 LocalName[1] = L':';
468 LocalName[2] = L'\0';
469 StringCchCopyW( ConnectionName, MAX_PATH, NFS41_DEVICE_NAME );
470 StringCchCatW( ConnectionName, MAX_PATH, L"\\;" );
471 StringCchCatW( ConnectionName, MAX_PATH, LocalName );
472
473 // remote name, must start with "\\"
474 if (lpNetResource->lpRemoteName[0] == L'\0' ||
475 lpNetResource->lpRemoteName[0] != L'\\' ||
476 lpNetResource->lpRemoteName[1] != L'\\') {
478 goto out;
479 }
480
481 /* note: remotename comes as \\server but we need to add \server thus +1 pointer */
482 p = lpNetResource->lpRemoteName + 1;
483 ServerName[0] = L'\\';
484 i = 1;
485 for(;;) {
486 /* convert servername ending unix slash to windows slash */
487 if (p[i] == L'/')
488 p[i] = L'\\';
489 /* deal with servername ending with any slash */
490 if (p[i] == L'\0')
491 p[i] = L'\\';
492 ServerName[i] = p[i];
493 if (p[i] == L'\\') break;
494 i++;
495 }
496 ServerName[i] = L'\0';
497 StringCchCatW( ConnectionName, MAX_PATH, ServerName);
498 /* insert the "nfs4" in between the server name and the path,
499 * just to make sure all calls to our driver come thru this */
500 StringCchCatW( ConnectionName, MAX_PATH, L"\\nfs4" );
501
502#ifdef CONVERT_2_UNIX_SLASHES
503 /* convert all windows slashes to unix slashes */
504 {
505 PWCHAR q = p;
506 DWORD j = 0;
507 for(;;) {
508 if(q[j] == L'\0') break;
509 if (q[j] == L'\\') q[j] = L'/';
510 j++;
511 }
512 }
513#else
514 /* convert all unix slashes to windows slashes */
515 {
516 PWCHAR q = p;
517 DWORD j = 0;
518 for(;;) {
519 if(q[j] == L'\0') break;
520 if (q[j] == L'/') q[j] = L'\\';
521 j++;
522 }
523 }
524#endif
525 StringCchCatW( ConnectionName, MAX_PATH, &p[i]);
526 DbgP(( L"[aglo] Full Connect Name: %s\n", ConnectionName ));
527 DbgP(( L"[aglo] Full Connect Name Length: %d %d\n",
528 (wcslen(ConnectionName) + 1) * sizeof(WCHAR),
529 (lstrlen(ConnectionName) + 1) * sizeof(WCHAR)));
530
531 if ( QueryDosDevice( LocalName, wszScratch, 128 )
534 goto out;
535 }
536
537 MarshalConnectionInfo(&Connection);
538
540 Connection.Buffer, Connection.BufferSize,
541 NULL, &CopyBytes );
542 if (Status) {
543 DbgP(( L"[aglo] SendTo_NFS41Driver failed with %d\n", Status));
544 goto out;
545 }
546
547 DbgP(( L"[aglo] calling DefineDosDevice\n"));
550 lpNetResource->lpLocalName,
551 ConnectionName ) ) {
553 DbgP(( L"[aglo] DefineDosDevice failed with %d\n", Status));
554 goto out_delconn;
555 }
556
557 // The connection was established and the local device mapping
558 // added. Include this in the list of mapped devices.
559 Status = StoreConnectionInfo(LocalName, ConnectionName,
560 Connection.Buffer->NameLength, lpNetResource);
561 if (Status) {
562 DbgP(( L"[aglo] StoreConnectionInfo failed with %d\n", Status));
563 goto out_undefine;
564 }
565
566out:
567 FreeConnectionInfo(&Connection);
568 DbgP(( L"[aglo] NPAddConnection3: status %08X\n", Status));
569 return Status;
570out_undefine:
572 DDD_EXACT_MATCH_ON_REMOVE, LocalName, ConnectionName);
573out_delconn:
575 Connection.Buffer->NameLength, NULL, &CopyBytes);
576 goto out;
577}
578
582 __in BOOL fForce )
583{
584 DWORD Status = 0;
585
587 PNFS41NP_SHARED_MEMORY pSharedMemory;
588
589 DbgP((TEXT("NPCancelConnection\n")));
590 DbgP((TEXT("NPCancelConnection: ConnectionName: %S\n"), lpName));
591
593 &hMemory,
594 (PVOID)&pSharedMemory);
595
596 if (Status == WN_SUCCESS)
597 {
598 INT Index;
599 PNFS41NP_NETRESOURCE pNetResource;
601
602 DbgP((TEXT("NPCancelConnection: NextIndex %d, NumResources %d\n"),
603 pSharedMemory->NextAvailableIndex,
604 pSharedMemory->NumberOfResourcesInUse));
605
606 for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
607 {
608 pNetResource = &pSharedMemory->NetResources[Index];
609
610 if (pNetResource->InUse)
611 {
612 if ( ( (wcslen(lpName) + 1) * sizeof(WCHAR) ==
613 pNetResource->LocalNameLength)
614 && ( !wcscmp(lpName, pNetResource->LocalName) ))
615 {
616 ULONG CopyBytes;
617
618 DbgP((TEXT("NPCancelConnection: Connection Found:\n")));
619
620 CopyBytes = 0;
621
623 pNetResource->ConnectionName,
624 pNetResource->ConnectionNameLength,
625 NULL,
626 &CopyBytes );
627
628 if (Status != WN_SUCCESS)
629 {
630 DbgP((TEXT("NPCancelConnection: SendToMiniRdr returned Status %lx\n"),Status));
631 break;
632 }
633
635 lpName,
636 pNetResource->ConnectionName) == FALSE)
637 {
638 DbgP((TEXT("RemoveDosDevice: DefineDosDevice error: %d\n"), GetLastError()));
640 }
641 else
642 {
643 pNetResource->InUse = FALSE;
644 pSharedMemory->NumberOfResourcesInUse--;
645
646 if (Index+1 == pSharedMemory->NextAvailableIndex)
647 pSharedMemory->NextAvailableIndex--;
648 }
649 break;
650 }
651
652 DbgP((TEXT("NPCancelConnection: Name %S EntryName %S\n"),
653 lpName,pNetResource->LocalName));
654#ifndef __REACTOS__
655 DbgP((TEXT("NPCancelConnection: Name Length %d Entry Name Length %d\n"),
656 pNetResource->LocalNameLength,pNetResource->LocalName));
657#else
658 DbgP((TEXT("NPCancelConnection: Name Length %d Entry Name Length %d\n"),
659 (wcslen(lpName) + 1) * sizeof(WCHAR), pNetResource->LocalNameLength));
660#endif
661
662 }
663 }
664
666 &hMemory,
667 (PVOID)&pSharedMemory);
668 }
669
670 return Status;
671}
672
675 __in LPWSTR lpLocalName,
676 __out_bcount(*lpBufferSize) LPWSTR lpRemoteName,
677 __inout LPDWORD lpBufferSize )
678{
679 DWORD Status = 0;
680
682 PNFS41NP_SHARED_MEMORY pSharedMemory;
683
685 &hMemory,
686 (PVOID)&pSharedMemory);
687
688 if (Status == WN_SUCCESS)
689 {
690 INT Index;
691 PNFS41NP_NETRESOURCE pNetResource;
693
694 for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
695 {
696 pNetResource = &pSharedMemory->NetResources[Index];
697
698 if (pNetResource->InUse)
699 {
700 if ( ( (wcslen(lpLocalName) + 1) * sizeof(WCHAR) ==
701 pNetResource->LocalNameLength)
702 && ( !wcscmp(lpLocalName, pNetResource->LocalName) ))
703 {
704 if (*lpBufferSize < pNetResource->RemoteNameLength)
705 {
706 *lpBufferSize = pNetResource->RemoteNameLength;
708 }
709 else
710 {
711 *lpBufferSize = pNetResource->RemoteNameLength;
712 CopyMemory( lpRemoteName,
713 pNetResource->RemoteName,
714 pNetResource->RemoteNameLength);
716 }
717 break;
718 }
719 }
720 }
721
722 CloseSharedMemory( &hMutex, &hMemory, (PVOID)&pSharedMemory);
723 }
724
725 return Status;
726}
727
730 DWORD dwScope,
731 DWORD dwType,
732 DWORD dwUsage,
733 LPNETRESOURCE lpNetResource,
734 LPHANDLE lphEnum )
735{
737
738 DbgP((L"[aglo] NPOpenEnum\n"));
739
740 *lphEnum = NULL;
741
742 switch ( dwScope )
743 {
745 {
746 *lphEnum = HeapAlloc( GetProcessHeap( ), HEAP_ZERO_MEMORY, sizeof( ULONG ) );
747
748 if (*lphEnum )
749 {
751 }
752 else
753 {
755 }
756 break;
757 }
758 break;
759
760 case RESOURCE_CONTEXT:
761 default:
763 break;
764 }
765
766
767 DbgP((L"[aglo] NPOpenEnum returning Status %lx\n",Status));
768
769 return(Status);
770}
771
774 HANDLE hEnum,
775 LPDWORD lpcCount,
777 LPDWORD lpBufferSize)
778{
780 ULONG EntriesCopied;
781 LPNETRESOURCE pNetResource;
782 ULONG SpaceNeeded = 0;
783 ULONG SpaceAvailable;
784 PWCHAR StringZone;
786 PNFS41NP_SHARED_MEMORY pSharedMemory;
787 PNFS41NP_NETRESOURCE pNfsNetResource;
788 INT Index = *(PULONG)hEnum;
789
790
791 DbgP((L"[aglo] NPEnumResource\n"));
792
793 DbgP((L"[aglo] NPEnumResource Count Requested %d\n", *lpcCount));
794
795 pNetResource = (LPNETRESOURCE) lpBuffer;
796 SpaceAvailable = *lpBufferSize;
797 EntriesCopied = 0;
798 StringZone = (PWCHAR) ((PBYTE)lpBuffer + *lpBufferSize);
799
801 &hMemory,
802 (PVOID)&pSharedMemory);
803
804 if ( Status == WN_SUCCESS)
805 {
807 for (Index = *(PULONG)hEnum; EntriesCopied < *lpcCount &&
808 Index < pSharedMemory->NextAvailableIndex; Index++)
809 {
810 pNfsNetResource = &pSharedMemory->NetResources[Index];
811
812 if (pNfsNetResource->InUse)
813 {
814 SpaceNeeded = sizeof( NETRESOURCE );
815 SpaceNeeded += pNfsNetResource->LocalNameLength;
816 SpaceNeeded += pNfsNetResource->RemoteNameLength;
817 SpaceNeeded += 5 * sizeof(WCHAR); // comment
818 SpaceNeeded += sizeof(NFS41_PROVIDER_NAME_U); // provider name
819 if ( SpaceNeeded > SpaceAvailable )
820 {
822 DbgP((L"[aglo] NPEnumResource More Data Needed - %d\n", SpaceNeeded));
823 *lpBufferSize = SpaceNeeded;
824 break;
825 }
826 else
827 {
828 SpaceAvailable -= SpaceNeeded;
829
830 pNetResource->dwScope = pNfsNetResource->dwScope;
831 pNetResource->dwType = pNfsNetResource->dwType;
832 pNetResource->dwDisplayType = pNfsNetResource->dwDisplayType;
833 pNetResource->dwUsage = pNfsNetResource->dwUsage;
834
835 // setup string area at opposite end of buffer
836 SpaceNeeded -= sizeof( NETRESOURCE );
837 StringZone = (PWCHAR)( (PBYTE) StringZone - SpaceNeeded );
838 // copy local name
839 StringCchCopy( StringZone,
840 pNfsNetResource->LocalNameLength,
841 pNfsNetResource->LocalName );
842 pNetResource->lpLocalName = StringZone;
843 StringZone += pNfsNetResource->LocalNameLength/sizeof(WCHAR);
844 // copy remote name
845 StringCchCopy( StringZone,
846 pNfsNetResource->RemoteNameLength,
847 pNfsNetResource->RemoteName );
848 pNetResource->lpRemoteName = StringZone;
849 StringZone += pNfsNetResource->RemoteNameLength/sizeof(WCHAR);
850 // copy comment
851 pNetResource->lpComment = StringZone;
852 *StringZone++ = L'A';
853 *StringZone++ = L'_';
854 *StringZone++ = L'O';
855 *StringZone++ = L'K';
856 *StringZone++ = L'\0';
857 // copy provider name
858 pNetResource->lpProvider = StringZone;
860 StringZone += sizeof(NFS41_PROVIDER_NAME_U)/sizeof(WCHAR);
861 EntriesCopied++;
862 // set new bottom of string zone
863 StringZone = (PWCHAR)( (PBYTE) StringZone - SpaceNeeded );
865 }
866 pNetResource++;
867 }
868 }
869 CloseSharedMemory( &hMutex, &hMemory, (PVOID*)&pSharedMemory);
870 }
871
872 *lpcCount = EntriesCopied;
873 *(PULONG) hEnum = Index;
874
875 DbgP((L"[aglo] NPEnumResource entries returned: %d\n", EntriesCopied));
876
877 return Status;
878}
879
882 HANDLE hEnum )
883{
884 DbgP((L"[aglo] NPCloseEnum\n"));
885 HeapFree( GetProcessHeap( ), 0, (PVOID) hEnum );
886 return WN_SUCCESS;
887}
888
891 LPNETRESOURCE lpNetResource,
893 LPDWORD lpBufferSize )
894{
895 DbgP(( L"[aglo] NPGetResourceParent: WN_NOT_SUPPORTED\n" ));
896 return WN_NOT_SUPPORTED;
897}
898
901 __in LPNETRESOURCE lpNetResource,
902 __out_bcount(*lpBufferSize) LPVOID lpBuffer,
903 __inout LPDWORD lpBufferSize,
904 __deref_out LPWSTR *lplpSystem )
905{
906 DbgP(( L"[aglo] NPGetResourceInformation: WN_NOT_SUPPORTED\n" ));
907 return WN_NOT_SUPPORTED;
908}
909
912 LPCWSTR lpLocalPath,
915 LPDWORD lpBufferSize )
916{
917 DbgP(( L"[aglo] NPGetUniversalName: WN_NOT_SUPPORTED\n" ));
918 return WN_NOT_SUPPORTED;
919}
unsigned char BOOLEAN
int toupper(int c)
Definition: utclib.c:881
char * va_list
Definition: acmsvcex.h:78
#define va_start(ap, A)
Definition: acmsvcex.h:91
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define __in
Definition: dbghelp.h:35
#define __out_bcount(x)
Definition: dbghelp.h:68
#define __deref_out
Definition: dbghelp.h:26
#define __inout
Definition: dbghelp.h:50
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
void MarshalConnectionInfo(IN OUT PCONNECTION_INFO Connection)
Definition: options.c:68
DWORD InitializeConnectionInfo(IN OUT PCONNECTION_INFO Connection, IN PMOUNT_OPTION_BUFFER Options, OUT LPWSTR *ConnectionName)
Definition: options.c:26
void FreeConnectionInfo(IN PCONNECTION_INFO Connection)
Definition: options.c:92
#define APIENTRY
Definition: api.h:79
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define UnmapViewOfFile
Definition: compat.h:746
#define OPEN_EXISTING
Definition: compat.h:775
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MapViewOfFile
Definition: compat.h:745
#define FILE_SHARE_READ
Definition: compat.h:136
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define INFINITE
Definition: serial.h:102
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxMemoryObject * pMemory
WDFMEMORY hMemory
Status
Definition: gdiplustypes.h:25
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:86
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
int marker
Definition: jpeglib.h:1030
#define TEXT(s)
Definition: k32.h:26
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
HANDLE hMutex
Definition: mutex.c:11
#define NFS41_USER_DEVICE_NAME
Definition: nfs41_driver.h:27
#define NFS41_DEVICE_NAME
Definition: nfs41_driver.h:25
#define IOCTL_NFS41_ADDCONN
Definition: nfs41_driver.h:46
#define NFS41_USER_SHARED_MEMORY_NAME
Definition: nfs41_driver.h:37
#define NFS41_PROVIDER_NAME_U
Definition: nfs41_driver.h:30
#define IOCTL_NFS41_DELCONN
Definition: nfs41_driver.h:47
#define DbgP(_x_)
Definition: nfs41_np.c:36
DWORD APIENTRY NPEnumResource(HANDLE hEnum, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
Definition: nfs41_np.c:773
static DWORD StoreConnectionInfo(IN LPCWSTR LocalName, IN LPCWSTR ConnectionName, IN USHORT ConnectionNameLength, IN LPNETRESOURCE lpNetResource)
Definition: nfs41_np.c:187
DWORD APIENTRY NPGetCaps(DWORD nIndex)
Definition: nfs41_np.c:329
VOID CloseSharedMemory(PHANDLE hMutex, PHANDLE hMemory, PVOID *pMemory)
Definition: nfs41_np.c:143
DWORD APIENTRY NPPasswordChangeNotify(__in LPCWSTR lpAuthentInfoType, __in LPVOID lpAuthentInfo, __in LPCWSTR lpPreviousAuthentInfoType, __in LPVOID lpPreviousAuthentInfo, __in LPWSTR lpStationName, LPVOID StationHandle, DWORD dwChangeInfo)
Definition: nfs41_np.c:394
ULONG _cdecl NFS41DbgPrint(__in LPTSTR Format,...)
Definition: nfs41_np.c:42
#define TRACE_TAG
Definition: nfs41_np.c:38
ULONG SendTo_NFS41Driver(IN ULONG IoctlCode, IN PVOID InputDataBuf, IN ULONG InputDataLen, IN PVOID OutputDataBuf, IN PULONG pOutputDataLen)
Definition: nfs41_np.c:268
DWORD APIENTRY NPGetUniversalName(LPCWSTR lpLocalPath, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpBufferSize)
Definition: nfs41_np.c:911
DWORD APIENTRY NPCloseEnum(HANDLE hEnum)
Definition: nfs41_np.c:881
DWORD APIENTRY NPGetResourceParent(LPNETRESOURCE lpNetResource, LPVOID lpBuffer, LPDWORD lpBufferSize)
Definition: nfs41_np.c:890
DWORD APIENTRY NPGetResourceInformation(__in LPNETRESOURCE lpNetResource, __out_bcount(*lpBufferSize) LPVOID lpBuffer, __inout LPDWORD lpBufferSize, __deref_out LPWSTR *lplpSystem)
Definition: nfs41_np.c:900
DWORD APIENTRY NPAddConnection(__in LPNETRESOURCE lpNetResource, __in_opt LPWSTR lpPassword, __in_opt LPWSTR lpUserName)
Definition: nfs41_np.c:419
DWORD APIENTRY NPLogonNotify(__in PLUID lpLogonId, __in PCWSTR lpAuthentInfoType, __in PVOID lpAuthentInfo, __in PCWSTR lpPreviousAuthentInfoType, __in PVOID lpPreviousAuthentInfo, __in PWSTR lpStationName, __in PVOID StationHandle, __out PWSTR *lpLogonScript)
Definition: nfs41_np.c:378
DWORD APIENTRY NPOpenEnum(DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCE lpNetResource, LPHANDLE lphEnum)
Definition: nfs41_np.c:729
DWORD APIENTRY NPGetConnection(__in LPWSTR lpLocalName, __out_bcount(*lpBufferSize) LPWSTR lpRemoteName, __inout LPDWORD lpBufferSize)
Definition: nfs41_np.c:674
DWORD APIENTRY NPCancelConnection(__in LPWSTR lpName, __in BOOL fForce)
Definition: nfs41_np.c:580
DWORD APIENTRY NPAddConnection3(__in HWND hwndOwner, __in LPNETRESOURCE lpNetResource, __in_opt LPWSTR lpPassword, __in_opt LPWSTR lpUserName, __in DWORD dwFlags)
Definition: nfs41_np.c:428
#define WNNC_DRIVER(major, minor)
Definition: nfs41_np.c:39
DWORD OpenSharedMemory(PHANDLE phMutex, PHANDLE phMemory, PVOID *pMemory)
Definition: nfs41_np.c:68
#define NFS41NP_MUTEX_NAME
Definition: nfs41_np.h:25
#define NFS41NP_MAX_DEVICES
Definition: nfs41_np.h:27
#define WNNC_NET_TYPE
Definition: npapi.h:24
#define WNNC_START
Definition: npapi.h:56
#define WNNC_CON_GETCONNECTIONS
Definition: npapi.h:35
#define WNNC_USER
Definition: npapi.h:29
#define WNNC_SPEC_VERSION51
Definition: npapi.h:23
#define WNNC_DIALOG
Definition: npapi.h:38
#define WNNC_CON_CANCELCONNECTION
Definition: npapi.h:34
#define WNNC_CONNECTION
Definition: npapi.h:32
#define WNNC_ADMIN
Definition: npapi.h:47
#define WNNC_CON_ADDCONNECTION
Definition: npapi.h:33
#define WNNC_CON_ADDCONNECTION3
Definition: npapi.h:36
#define WNNC_SPEC_VERSION
Definition: npapi.h:22
#define WNNC_ENUM_LOCAL
Definition: npapi.h:53
#define WNNC_DRIVER_VERSION
Definition: npapi.h:27
#define WNNC_ENUMERATION
Definition: npapi.h:51
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define L(x)
Definition: ntvdm.h:50
BYTE * PBYTE
Definition: pedump.c:66
unsigned short USHORT
Definition: pedump.c:61
DWORD dwStatus
Definition: mediaobj.idl:95
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
static FILE * out
Definition: regtests2xml.c:44
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
#define StringCchCopy
Definition: strsafe.h:139
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
STRSAFEAPI StringCchVPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat, va_list argList)
Definition: strsafe.h:490
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
USHORT NameLength
Definition: options.h:45
ULONG BufferSize
Definition: options.h:57
PCONNECTION_BUFFER Buffer
Definition: options.h:58
LPSTR lpLocalName
Definition: winnetwk.h:171
DWORD dwDisplayType
Definition: winnetwk.h:169
LPSTR lpComment
Definition: winnetwk.h:173
DWORD dwScope
Definition: winnetwk.h:167
LPSTR lpProvider
Definition: winnetwk.h:174
LPSTR lpRemoteName
Definition: winnetwk.h:172
DWORD dwUsage
Definition: winnetwk.h:170
DWORD dwType
Definition: winnetwk.h:168
WCHAR LocalName[MAX_PATH]
Definition: nfs41_np.h:38
USHORT LocalNameLength
Definition: nfs41_np.h:31
WCHAR RemoteName[MAX_PATH]
Definition: nfs41_np.h:39
USHORT RemoteNameLength
Definition: nfs41_np.h:32
USHORT ConnectionNameLength
Definition: nfs41_np.h:33
WCHAR ConnectionName[MAX_PATH]
Definition: nfs41_np.h:40
NFS41NP_NETRESOURCE NetResources[NFS41NP_MAX_DEVICES]
Definition: nfs41_np.h:47
Definition: inflate.c:139
Definition: ps.c:97
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint32_t * LPDWORD
Definition: typedefs.h:59
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG IoctlCode
Definition: wdfiotarget.h:1043
#define DDD_NO_BROADCAST_SYSTEM
Definition: winbase.h:526
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define DDD_EXACT_MATCH_ON_REMOVE
Definition: winbase.h:525
#define FILE_MAP_WRITE
Definition: winbase.h:154
#define DDD_RAW_TARGET_PATH
Definition: winbase.h:523
_In_ LPCSTR lpName
Definition: winbase.h:2789
#define CreateMutex
Definition: winbase.h:3756
#define CopyMemory
Definition: winbase.h:1710
#define DDD_REMOVE_DEFINITION
Definition: winbase.h:524
#define OutputDebugString
Definition: winbase.h:3890
#define DefineDosDevice
Definition: winbase.h:3763
#define lstrlen
Definition: winbase.h:3876
#define OpenFileMapping
Definition: winbase.h:3887
#define CreateFile
Definition: winbase.h:3749
#define QueryDosDevice
Definition: winbase.h:3892
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define WN_NOT_SUPPORTED
Definition: winnetwk.h:113
#define WN_BAD_LOCALNAME
Definition: winnetwk.h:136
#define RESOURCE_CONNECTED
Definition: winnetwk.h:58
NETRESOURCEA NETRESOURCE
Definition: winnetwk.h:593
#define RESOURCEUSAGE_CONNECTABLE
Definition: winnetwk.h:68
#define WN_OUT_OF_MEMORY
Definition: winnetwk.h:125
#define WN_ALREADY_CONNECTED
Definition: winnetwk.h:137
#define RESOURCE_CONTEXT
Definition: winnetwk.h:62
#define WN_NOT_CONNECTED
Definition: winnetwk.h:132
#define WN_MORE_DATA
Definition: winnetwk.h:117
#define WN_SUCCESS
Definition: winnetwk.h:111
#define WN_NO_MORE_DEVICES
Definition: winnetwk.h:131
NETRESOURCEA * LPNETRESOURCE
Definition: winnetwk.h:593
#define WN_NO_MORE_ENTRIES
Definition: winnetwk.h:146
#define WN_BAD_NETNAME
Definition: winnetwk.h:135
#define WNNC_NET_RDR2SAMPLE
Definition: winnetwk.h:47
_In_ DWORD dwInfoLevel
Definition: winsvc.h:422
char TCHAR
Definition: xmlstorage.h:189
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
CHAR * LPTSTR
Definition: xmlstorage.h:192
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185