ReactOS  0.4.15-dev-1070-ge1a01de
nfs41_np.c File Reference
#include <windows.h>
#include <npapi.h>
#include <devioctl.h>
#include <strsafe.h>
#include "nfs41_driver.h"
#include "nfs41_np.h"
#include "options.h"
Include dependency graph for nfs41_np.c:

Go to the source code of this file.

Macros

#define DbgP(_x_)
 
#define TRACE_TAG   L"[NFS41_NP]"
 
#define WNNC_DRIVER(major, minor)   ( major * 0x00010000 + minor )
 

Functions

ULONG _cdecl NFS41DbgPrint (__in LPTSTR Format,...)
 
int filter (unsigned int code)
 
DWORD OpenSharedMemory (PHANDLE phMutex, PHANDLE phMemory, PVOID *pMemory)
 
VOID CloseSharedMemory (PHANDLE hMutex, PHANDLE hMemory, PVOID *pMemory)
 
static DWORD StoreConnectionInfo (IN LPCWSTR LocalName, IN LPCWSTR ConnectionName, IN USHORT ConnectionNameLength, IN LPNETRESOURCE lpNetResource)
 
ULONG SendTo_NFS41Driver (IN ULONG IoctlCode, IN PVOID InputDataBuf, IN ULONG InputDataLen, IN PVOID OutputDataBuf, IN PULONG pOutputDataLen)
 
DWORD APIENTRY NPGetCaps (DWORD nIndex)
 
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)
 
DWORD APIENTRY NPPasswordChangeNotify (__in LPCWSTR lpAuthentInfoType, __in LPVOID lpAuthentInfo, __in LPCWSTR lpPreviousAuthentInfoType, __in LPVOID lpPreviousAuthentInfo, __in LPWSTR lpStationName, LPVOID StationHandle, DWORD dwChangeInfo)
 
DWORD APIENTRY NPAddConnection (__in LPNETRESOURCE lpNetResource, __in_opt LPWSTR lpPassword, __in_opt LPWSTR lpUserName)
 
DWORD APIENTRY NPAddConnection3 (__in HWND hwndOwner, __in LPNETRESOURCE lpNetResource, __in_opt LPWSTR lpPassword, __in_opt LPWSTR lpUserName, __in DWORD dwFlags)
 
DWORD APIENTRY NPCancelConnection (__in LPWSTR lpName, __in BOOL fForce)
 
DWORD APIENTRY NPGetConnection (__in LPWSTR lpLocalName, __out_bcount(*lpBufferSize) LPWSTR lpRemoteName, __inout LPDWORD lpBufferSize)
 
DWORD APIENTRY NPOpenEnum (DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCE lpNetResource, LPHANDLE lphEnum)
 
DWORD APIENTRY NPEnumResource (HANDLE hEnum, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
 
DWORD APIENTRY NPCloseEnum (HANDLE hEnum)
 
DWORD APIENTRY NPGetResourceParent (LPNETRESOURCE lpNetResource, LPVOID lpBuffer, LPDWORD lpBufferSize)
 
DWORD APIENTRY NPGetResourceInformation (__in LPNETRESOURCE lpNetResource, __out_bcount(*lpBufferSize) LPVOID lpBuffer, __inout LPDWORD lpBufferSize, __deref_out LPWSTR *lplpSystem)
 
DWORD APIENTRY NPGetUniversalName (LPCWSTR lpLocalPath, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpBufferSize)
 

Macro Definition Documentation

◆ DbgP

#define DbgP (   _x_)

Definition at line 34 of file nfs41_np.c.

◆ TRACE_TAG

#define TRACE_TAG   L"[NFS41_NP]"

Definition at line 36 of file nfs41_np.c.

◆ WNNC_DRIVER

#define WNNC_DRIVER (   major,
  minor 
)    ( major * 0x00010000 + minor )

Definition at line 37 of file nfs41_np.c.

Function Documentation

◆ CloseSharedMemory()

VOID CloseSharedMemory ( PHANDLE  hMutex,
PHANDLE  hMemory,
PVOID pMemory 
)

Definition at line 141 of file nfs41_np.c.

163 {
164  if (*pMemory)
165  {
166  UnmapViewOfFile(*pMemory);
167  *pMemory = NULL;
168  }
169  if (*hMemory)
170  {
171  CloseHandle(*hMemory);
172  *hMemory = 0;
173  }
174  if (*hMutex)
175  {
176  if (ReleaseMutex(*hMutex) == FALSE)
177  {
178  DbgP((TEXT("CloseSharedMemory: ReleaseMutex error: %d\n"), GetLastError()));
179  }
181  *hMutex = 0;
182  }
183 }
#define CloseHandle
Definition: compat.h:487
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define DbgP(_x_)
Definition: nfs41_np.c:34
HANDLE hMutex
Definition: mutex.c:11
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
#define TEXT(s)
Definition: k32.h:26
#define UnmapViewOfFile
Definition: compat.h:494

Referenced by NPCancelConnection(), NPEnumResource(), NPGetConnection(), and StoreConnectionInfo().

◆ filter()

int filter ( unsigned int  code)

Definition at line 59 of file nfs41_np.c.

60 {
61  DbgP((L"####Got exception %u\n", code));
63 }
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:86
#define DbgP(_x_)
Definition: nfs41_np.c:34
static const WCHAR L[]
Definition: oid.c:1250
Definition: inflate.c:139

◆ NFS41DbgPrint()

ULONG _cdecl NFS41DbgPrint ( __in LPTSTR  Format,
  ... 
)

Definition at line 40 of file nfs41_np.c.

41 {
42  ULONG rc = 0;
43  TCHAR szbuffer[256];
44 
47  {
48 
49  //StringCchVPrintfW( szbuffer, 127, Format, marker );
50  StringCchVPrintfW( szbuffer, 256, Format, marker );
51  szbuffer[255] = (TCHAR)0;
53  OutputDebugString( szbuffer );
54  }
55 
56  return rc;
57 }
STRSAFEAPI StringCchVPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat, va_list argList)
Definition: strsafe.h:490
#define TRACE_TAG
Definition: nfs41_np.c:36
#define OutputDebugString
Definition: winbase.h:3730
int marker
Definition: jpeglib.h:1030
char * va_list
Definition: acmsvcex.h:78
char TCHAR
Definition: xmlstorage.h:189
#define va_start(ap, A)
Definition: acmsvcex.h:91
unsigned int ULONG
Definition: retypes.h:1

◆ NPAddConnection()

DWORD APIENTRY NPAddConnection ( __in LPNETRESOURCE  lpNetResource,
__in_opt LPWSTR  lpPassword,
__in_opt LPWSTR  lpUserName 
)

Definition at line 417 of file nfs41_np.c.

421 {
422  return NPAddConnection3( NULL, lpNetResource, lpPassword, lpUserName, 0 );
423 }
smooth NULL
Definition: ftsmooth.c:416
DWORD APIENTRY NPAddConnection3(__in HWND hwndOwner, __in LPNETRESOURCE lpNetResource, __in_opt LPWSTR lpPassword, __in_opt LPWSTR lpUserName, __in DWORD dwFlags)
Definition: nfs41_np.c:426

Referenced by _tryLoadProvider().

◆ NPAddConnection3()

DWORD APIENTRY NPAddConnection3 ( __in HWND  hwndOwner,
__in LPNETRESOURCE  lpNetResource,
__in_opt LPWSTR  lpPassword,
__in_opt LPWSTR  lpUserName,
__in DWORD  dwFlags 
)

Definition at line 426 of file nfs41_np.c.

432 {
433  DWORD Status;
434  WCHAR wszScratch[128];
435  WCHAR LocalName[3];
436  DWORD CopyBytes = 0;
437  CONNECTION_INFO Connection;
438  LPWSTR ConnectionName;
439  WCHAR ServerName[MAX_PATH];
440  PWCHAR p;
441  DWORD i;
442 
443  DbgP(( L"[aglo] NPAddConnection3('%s', '%s')\n",
444  lpNetResource->lpLocalName, lpNetResource->lpRemoteName ));
445  DbgP(( L"[aglo] username = '%s', passwd = '%s'\n", lpUserName, lpPassword));
446 
447  Status = InitializeConnectionInfo(&Connection,
448  (PMOUNT_OPTION_BUFFER)lpNetResource->lpComment,
449  &ConnectionName);
450  if (Status) {
451  DbgP(( L"InitializeConnectionInfo failed with %d\n", Status ));
452  goto out;
453  }
454 
455  // \device\miniredirector\;<DriveLetter>:\Server\Share
456 
457  // local name, must start with "X:"
458  if (lstrlen(lpNetResource->lpLocalName) < 2 ||
459  lpNetResource->lpLocalName[1] != L':') {
461  goto out;
462  }
463 
464  LocalName[0] = (WCHAR) toupper(lpNetResource->lpLocalName[0]);
465  LocalName[1] = L':';
466  LocalName[2] = L'\0';
467  StringCchCopyW( ConnectionName, MAX_PATH, NFS41_DEVICE_NAME );
468  StringCchCatW( ConnectionName, MAX_PATH, L"\\;" );
469  StringCchCatW( ConnectionName, MAX_PATH, LocalName );
470 
471  // remote name, must start with "\\"
472  if (lpNetResource->lpRemoteName[0] == L'\0' ||
473  lpNetResource->lpRemoteName[0] != L'\\' ||
474  lpNetResource->lpRemoteName[1] != L'\\') {
476  goto out;
477  }
478 
479  /* note: remotename comes as \\server but we need to add \server thus +1 pointer */
480  p = lpNetResource->lpRemoteName + 1;
481  ServerName[0] = L'\\';
482  i = 1;
483  for(;;) {
484  /* convert servername ending unix slash to windows slash */
485  if (p[i] == L'/')
486  p[i] = L'\\';
487  /* deal with servername ending with any slash */
488  if (p[i] == L'\0')
489  p[i] = L'\\';
490  ServerName[i] = p[i];
491  if (p[i] == L'\\') break;
492  i++;
493  }
494  ServerName[i] = L'\0';
495  StringCchCatW( ConnectionName, MAX_PATH, ServerName);
496  /* insert the "nfs4" in between the server name and the path,
497  * just to make sure all calls to our driver come thru this */
498  StringCchCatW( ConnectionName, MAX_PATH, L"\\nfs4" );
499 
500 #ifdef CONVERT_2_UNIX_SLASHES
501  /* convert all windows slashes to unix slashes */
502  {
503  PWCHAR q = p;
504  DWORD j = 0;
505  for(;;) {
506  if(q[j] == L'\0') break;
507  if (q[j] == L'\\') q[j] = L'/';
508  j++;
509  }
510  }
511 #else
512  /* convert all unix slashes to windows slashes */
513  {
514  PWCHAR q = p;
515  DWORD j = 0;
516  for(;;) {
517  if(q[j] == L'\0') break;
518  if (q[j] == L'/') q[j] = L'\\';
519  j++;
520  }
521  }
522 #endif
523  StringCchCatW( ConnectionName, MAX_PATH, &p[i]);
524  DbgP(( L"[aglo] Full Connect Name: %s\n", ConnectionName ));
525  DbgP(( L"[aglo] Full Connect Name Length: %d %d\n",
526  (wcslen(ConnectionName) + 1) * sizeof(WCHAR),
527  (lstrlen(ConnectionName) + 1) * sizeof(WCHAR)));
528 
529  if ( QueryDosDevice( LocalName, wszScratch, 128 )
532  goto out;
533  }
534 
535  MarshalConnectionInfo(&Connection);
536 
538  Connection.Buffer, Connection.BufferSize,
539  NULL, &CopyBytes );
540  if (Status) {
541  DbgP(( L"[aglo] SendTo_NFS41Driver failed with %d\n", Status));
542  goto out;
543  }
544 
545  DbgP(( L"[aglo] calling DefineDosDevice\n"));
548  lpNetResource->lpLocalName,
549  ConnectionName ) ) {
550  Status = GetLastError();
551  DbgP(( L"[aglo] DefineDosDevice failed with %d\n", Status));
552  goto out_delconn;
553  }
554 
555  // The connection was established and the local device mapping
556  // added. Include this in the list of mapped devices.
557  Status = StoreConnectionInfo(LocalName, ConnectionName,
558  Connection.Buffer->NameLength, lpNetResource);
559  if (Status) {
560  DbgP(( L"[aglo] StoreConnectionInfo failed with %d\n", Status));
561  goto out_undefine;
562  }
563 
564 out:
565  FreeConnectionInfo(&Connection);
566  DbgP(( L"[aglo] NPAddConnection3: status %08X\n", Status));
567  return Status;
568 out_undefine:
570  DDD_EXACT_MATCH_ON_REMOVE, LocalName, ConnectionName);
571 out_delconn:
572  SendTo_NFS41Driver(IOCTL_NFS41_DELCONN, ConnectionName,
573  Connection.Buffer->NameLength, NULL, &CopyBytes);
574  goto out;
575 }
#define QueryDosDevice
Definition: winbase.h:3732
#define WN_BAD_NETNAME
Definition: winnetwk.h:135
void FreeConnectionInfo(IN PCONNECTION_INFO Connection)
Definition: options.c:92
#define DefineDosDevice
Definition: winbase.h:3603
ULONG SendTo_NFS41Driver(IN ULONG IoctlCode, IN PVOID InputDataBuf, IN ULONG InputDataLen, IN PVOID OutputDataBuf, IN PULONG pOutputDataLen)
Definition: nfs41_np.c:266
#define DDD_REMOVE_DEFINITION
Definition: winbase.h:505
#define DDD_NO_BROADCAST_SYSTEM
Definition: winbase.h:507
void MarshalConnectionInfo(IN OUT PCONNECTION_INFO Connection)
Definition: options.c:68
#define IOCTL_NFS41_DELCONN
Definition: nfs41_driver.h:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
DWORD InitializeConnectionInfo(IN OUT PCONNECTION_INFO Connection, IN PMOUNT_OPTION_BUFFER Options, OUT LPWSTR *ConnectionName)
Definition: options.c:26
uint16_t * PWCHAR
Definition: typedefs.h:56
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
ULONG BufferSize
Definition: options.h:57
#define WN_ALREADY_CONNECTED
Definition: winnetwk.h:137
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
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
smooth NULL
Definition: ftsmooth.c:416
#define DbgP(_x_)
Definition: nfs41_np.c:34
PCONNECTION_BUFFER Buffer
Definition: options.h:58
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
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
static DWORD StoreConnectionInfo(IN LPCWSTR LocalName, IN LPCWSTR ConnectionName, IN USHORT ConnectionNameLength, IN LPNETRESOURCE lpNetResource)
Definition: nfs41_np.c:185
int toupper(int c)
Definition: utclib.c:881
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NFS41_DEVICE_NAME
Definition: nfs41_driver.h:25
#define MAX_PATH
Definition: compat.h:34
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
Status
Definition: gdiplustypes.h:24
static const WCHAR L[]
Definition: oid.c:1250
#define IOCTL_NFS41_ADDCONN
Definition: nfs41_driver.h:46
#define lstrlen
Definition: winbase.h:3716
#define DDD_RAW_TARGET_PATH
Definition: winbase.h:504
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
USHORT NameLength
Definition: options.h:45
#define DDD_EXACT_MATCH_ON_REMOVE
Definition: winbase.h:506
#define WN_BAD_LOCALNAME
Definition: winnetwk.h:136

Referenced by _tryLoadProvider(), and NPAddConnection().

◆ NPCancelConnection()

DWORD APIENTRY NPCancelConnection ( __in LPWSTR  lpName,
__in BOOL  fForce 
)

Definition at line 578 of file nfs41_np.c.

581 {
582  DWORD Status = 0;
583 
584  HANDLE hMutex, hMemory;
585  PNFS41NP_SHARED_MEMORY pSharedMemory;
586 
587  DbgP((TEXT("NPCancelConnection\n")));
588  DbgP((TEXT("NPCancelConnection: ConnectionName: %S\n"), lpName));
589 
591  &hMemory,
592  (PVOID)&pSharedMemory);
593 
594  if (Status == WN_SUCCESS)
595  {
596  INT Index;
597  PNFS41NP_NETRESOURCE pNetResource;
599 
600  DbgP((TEXT("NPCancelConnection: NextIndex %d, NumResources %d\n"),
601  pSharedMemory->NextAvailableIndex,
602  pSharedMemory->NumberOfResourcesInUse));
603 
604  for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
605  {
606  pNetResource = &pSharedMemory->NetResources[Index];
607 
608  if (pNetResource->InUse)
609  {
610  if ( ( (wcslen(lpName) + 1) * sizeof(WCHAR) ==
611  pNetResource->LocalNameLength)
612  && ( !wcscmp(lpName, pNetResource->LocalName) ))
613  {
614  ULONG CopyBytes;
615 
616  DbgP((TEXT("NPCancelConnection: Connection Found:\n")));
617 
618  CopyBytes = 0;
619 
621  pNetResource->ConnectionName,
622  pNetResource->ConnectionNameLength,
623  NULL,
624  &CopyBytes );
625 
626  if (Status != WN_SUCCESS)
627  {
628  DbgP((TEXT("NPCancelConnection: SendToMiniRdr returned Status %lx\n"),Status));
629  break;
630  }
631 
633  lpName,
634  pNetResource->ConnectionName) == FALSE)
635  {
636  DbgP((TEXT("RemoveDosDevice: DefineDosDevice error: %d\n"), GetLastError()));
637  Status = GetLastError();
638  }
639  else
640  {
641  pNetResource->InUse = FALSE;
642  pSharedMemory->NumberOfResourcesInUse--;
643 
644  if (Index+1 == pSharedMemory->NextAvailableIndex)
645  pSharedMemory->NextAvailableIndex--;
646  }
647  break;
648  }
649 
650  DbgP((TEXT("NPCancelConnection: Name %S EntryName %S\n"),
651  lpName,pNetResource->LocalName));
652 #ifndef __REACTOS__
653  DbgP((TEXT("NPCancelConnection: Name Length %d Entry Name Length %d\n"),
654  pNetResource->LocalNameLength,pNetResource->LocalName));
655 #else
656  DbgP((TEXT("NPCancelConnection: Name Length %d Entry Name Length %d\n"),
657  (wcslen(lpName) + 1) * sizeof(WCHAR), pNetResource->LocalNameLength));
658 #endif
659 
660  }
661  }
662 
664  &hMemory,
665  (PVOID)&pSharedMemory);
666  }
667 
668  return Status;
669 }
#define DefineDosDevice
Definition: winbase.h:3603
ULONG SendTo_NFS41Driver(IN ULONG IoctlCode, IN PVOID InputDataBuf, IN ULONG InputDataLen, IN PVOID OutputDataBuf, IN PULONG pOutputDataLen)
Definition: nfs41_np.c:266
WCHAR ConnectionName[MAX_PATH]
Definition: nfs41_np.h:40
#define WN_SUCCESS
Definition: winnetwk.h:111
#define DDD_REMOVE_DEFINITION
Definition: winbase.h:505
_In_ LPCSTR lpName
Definition: winbase.h:2752
#define IOCTL_NFS41_DELCONN
Definition: nfs41_driver.h:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define WN_NOT_CONNECTED
Definition: winnetwk.h:132
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define DbgP(_x_)
Definition: nfs41_np.c:34
HANDLE hMutex
Definition: mutex.c:11
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:24
VOID CloseSharedMemory(PHANDLE hMutex, PHANDLE hMemory, PVOID *pMemory)
Definition: nfs41_np.c:141
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define TEXT(s)
Definition: k32.h:26
#define DDD_RAW_TARGET_PATH
Definition: winbase.h:504
NFS41NP_NETRESOURCE NetResources[NFS41NP_MAX_DEVICES]
Definition: nfs41_np.h:47
DWORD OpenSharedMemory(PHANDLE phMutex, PHANDLE phMemory, PVOID *pMemory)
Definition: nfs41_np.c:66
USHORT ConnectionNameLength
Definition: nfs41_np.h:33
unsigned int ULONG
Definition: retypes.h:1
USHORT LocalNameLength
Definition: nfs41_np.h:31
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DDD_EXACT_MATCH_ON_REMOVE
Definition: winbase.h:506
WCHAR LocalName[MAX_PATH]
Definition: nfs41_np.h:38

Referenced by _tryLoadProvider().

◆ NPCloseEnum()

DWORD APIENTRY NPCloseEnum ( HANDLE  hEnum)

Definition at line 879 of file nfs41_np.c.

881 {
882  DbgP((L"[aglo] NPCloseEnum\n"));
883  HeapFree( GetProcessHeap( ), 0, (PVOID) hEnum );
884  return WN_SUCCESS;
885 }
#define WN_SUCCESS
Definition: winnetwk.h:111
#define DbgP(_x_)
Definition: nfs41_np.c:34
#define GetProcessHeap()
Definition: compat.h:484
static const WCHAR L[]
Definition: oid.c:1250
#define HeapFree(x, y, z)
Definition: compat.h:483

Referenced by _tryLoadProvider().

◆ NPEnumResource()

DWORD APIENTRY NPEnumResource ( HANDLE  hEnum,
LPDWORD  lpcCount,
LPVOID  lpBuffer,
LPDWORD  lpBufferSize 
)

Definition at line 771 of file nfs41_np.c.

776 {
778  ULONG EntriesCopied;
779  LPNETRESOURCE pNetResource;
780  ULONG SpaceNeeded = 0;
781  ULONG SpaceAvailable;
782  PWCHAR StringZone;
783  HANDLE hMutex, hMemory;
784  PNFS41NP_SHARED_MEMORY pSharedMemory;
785  PNFS41NP_NETRESOURCE pNfsNetResource;
786  INT Index = *(PULONG)hEnum;
787 
788 
789  DbgP((L"[aglo] NPEnumResource\n"));
790 
791  DbgP((L"[aglo] NPEnumResource Count Requested %d\n", *lpcCount));
792 
793  pNetResource = (LPNETRESOURCE) lpBuffer;
794  SpaceAvailable = *lpBufferSize;
795  EntriesCopied = 0;
796  StringZone = (PWCHAR) ((PBYTE)lpBuffer + *lpBufferSize);
797 
799  &hMemory,
800  (PVOID)&pSharedMemory);
801 
802  if ( Status == WN_SUCCESS)
803  {
805  for (Index = *(PULONG)hEnum; EntriesCopied < *lpcCount &&
806  Index < pSharedMemory->NextAvailableIndex; Index++)
807  {
808  pNfsNetResource = &pSharedMemory->NetResources[Index];
809 
810  if (pNfsNetResource->InUse)
811  {
812  SpaceNeeded = sizeof( NETRESOURCE );
813  SpaceNeeded += pNfsNetResource->LocalNameLength;
814  SpaceNeeded += pNfsNetResource->RemoteNameLength;
815  SpaceNeeded += 5 * sizeof(WCHAR); // comment
816  SpaceNeeded += sizeof(NFS41_PROVIDER_NAME_U); // provider name
817  if ( SpaceNeeded > SpaceAvailable )
818  {
820  DbgP((L"[aglo] NPEnumResource More Data Needed - %d\n", SpaceNeeded));
821  *lpBufferSize = SpaceNeeded;
822  break;
823  }
824  else
825  {
826  SpaceAvailable -= SpaceNeeded;
827 
828  pNetResource->dwScope = pNfsNetResource->dwScope;
829  pNetResource->dwType = pNfsNetResource->dwType;
830  pNetResource->dwDisplayType = pNfsNetResource->dwDisplayType;
831  pNetResource->dwUsage = pNfsNetResource->dwUsage;
832 
833  // setup string area at opposite end of buffer
834  SpaceNeeded -= sizeof( NETRESOURCE );
835  StringZone = (PWCHAR)( (PBYTE) StringZone - SpaceNeeded );
836  // copy local name
837  StringCchCopy( StringZone,
838  pNfsNetResource->LocalNameLength,
839  pNfsNetResource->LocalName );
840  pNetResource->lpLocalName = StringZone;
841  StringZone += pNfsNetResource->LocalNameLength/sizeof(WCHAR);
842  // copy remote name
843  StringCchCopy( StringZone,
844  pNfsNetResource->RemoteNameLength,
845  pNfsNetResource->RemoteName );
846  pNetResource->lpRemoteName = StringZone;
847  StringZone += pNfsNetResource->RemoteNameLength/sizeof(WCHAR);
848  // copy comment
849  pNetResource->lpComment = StringZone;
850  *StringZone++ = L'A';
851  *StringZone++ = L'_';
852  *StringZone++ = L'O';
853  *StringZone++ = L'K';
854  *StringZone++ = L'\0';
855  // copy provider name
856  pNetResource->lpProvider = StringZone;
858  StringZone += sizeof(NFS41_PROVIDER_NAME_U)/sizeof(WCHAR);
859  EntriesCopied++;
860  // set new bottom of string zone
861  StringZone = (PWCHAR)( (PBYTE) StringZone - SpaceNeeded );
862  Status = WN_SUCCESS;
863  }
864  pNetResource++;
865  }
866  }
867  CloseSharedMemory( &hMutex, &hMemory, (PVOID*)&pSharedMemory);
868  }
869 
870  *lpcCount = EntriesCopied;
871  *(PULONG) hEnum = Index;
872 
873  DbgP((L"[aglo] NPEnumResource entries returned: %d\n", EntriesCopied));
874 
875  return Status;
876 }
DWORD dwType
Definition: winnetwk.h:168
#define WN_SUCCESS
Definition: winnetwk.h:111
USHORT RemoteNameLength
Definition: nfs41_np.h:32
LPSTR lpLocalName
Definition: winnetwk.h:171
uint16_t * PWCHAR
Definition: typedefs.h:56
DWORD dwDisplayType
Definition: winnetwk.h:169
int32_t INT
Definition: typedefs.h:58
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
#define DbgP(_x_)
Definition: nfs41_np.c:34
HANDLE hMutex
Definition: mutex.c:11
NETRESOURCEA * LPNETRESOURCE
Definition: winnetwk.h:593
LPSTR lpProvider
Definition: winnetwk.h:174
DWORD dwScope
Definition: winnetwk.h:167
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR lpComment
Definition: winnetwk.h:173
Status
Definition: gdiplustypes.h:24
DWORD dwUsage
Definition: winnetwk.h:170
static const WCHAR L[]
Definition: oid.c:1250
#define StringCchCopy
Definition: strsafe.h:139
VOID CloseSharedMemory(PHANDLE hMutex, PHANDLE hMemory, PVOID *pMemory)
Definition: nfs41_np.c:141
NFS41NP_NETRESOURCE NetResources[NFS41NP_MAX_DEVICES]
Definition: nfs41_np.h:47
DWORD OpenSharedMemory(PHANDLE phMutex, PHANDLE phMemory, PVOID *pMemory)
Definition: nfs41_np.c:66
unsigned int * PULONG
Definition: retypes.h:1
#define WN_NO_MORE_ENTRIES
Definition: winnetwk.h:146
LPSTR lpRemoteName
Definition: winnetwk.h:172
#define NFS41_PROVIDER_NAME_U
Definition: nfs41_driver.h:30
NETRESOURCEA NETRESOURCE
Definition: winnetwk.h:593
#define WN_MORE_DATA
Definition: winnetwk.h:117
unsigned int ULONG
Definition: retypes.h:1
WCHAR RemoteName[MAX_PATH]
Definition: nfs41_np.h:39
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
USHORT LocalNameLength
Definition: nfs41_np.h:31
BYTE * PBYTE
Definition: pedump.c:66
WCHAR LocalName[MAX_PATH]
Definition: nfs41_np.h:38

Referenced by _tryLoadProvider().

◆ NPGetCaps()

DWORD APIENTRY NPGetCaps ( DWORD  nIndex)

Definition at line 327 of file nfs41_np.c.

329 {
330  DWORD rc = 0;
331 
332 #ifndef __REACTOS__
333  DbgP(( L"[aglo] GetNetCaps %d\n", nIndex ));
334 #endif
335  switch ( nIndex )
336  {
337  case WNNC_SPEC_VERSION:
338  rc = WNNC_SPEC_VERSION51;
339  break;
340 
341  case WNNC_NET_TYPE:
342  rc = WNNC_NET_RDR2SAMPLE;
343  break;
344 
345  case WNNC_DRIVER_VERSION:
346  rc = WNNC_DRIVER(1, 0);
347  break;
348 
349  case WNNC_CONNECTION:
354  break;
355 
356  case WNNC_ENUMERATION:
357  rc = WNNC_ENUM_LOCAL;
358  break;
359 
360  case WNNC_START:
361  rc = 1;
362  break;
363 
364  case WNNC_USER:
365  case WNNC_DIALOG:
366  case WNNC_ADMIN:
367  default:
368  rc = 0;
369  break;
370  }
371 
372  return rc;
373 }
#define WNNC_CON_ADDCONNECTION3
Definition: npapi.h:36
#define WNNC_SPEC_VERSION
Definition: npapi.h:22
#define WNNC_ENUMERATION
Definition: npapi.h:51
#define WNNC_CON_ADDCONNECTION
Definition: npapi.h:33
#define WNNC_NET_TYPE
Definition: npapi.h:24
#define DbgP(_x_)
Definition: nfs41_np.c:34
#define WNNC_USER
Definition: npapi.h:29
#define WNNC_DIALOG
Definition: npapi.h:38
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WNNC_ENUM_LOCAL
Definition: npapi.h:53
#define WNNC_CONNECTION
Definition: npapi.h:32
#define WNNC_NET_RDR2SAMPLE
Definition: winnetwk.h:47
static const WCHAR L[]
Definition: oid.c:1250
#define WNNC_START
Definition: npapi.h:56
#define WNNC_ADMIN
Definition: npapi.h:47
#define WNNC_CON_CANCELCONNECTION
Definition: npapi.h:34
#define WNNC_DRIVER_VERSION
Definition: npapi.h:27
#define WNNC_DRIVER(major, minor)
Definition: nfs41_np.c:37
#define WNNC_SPEC_VERSION51
Definition: npapi.h:23
#define WNNC_CON_GETCONNECTIONS
Definition: npapi.h:35

Referenced by _tryLoadProvider().

◆ NPGetConnection()

DWORD APIENTRY NPGetConnection ( __in LPWSTR  lpLocalName,
__out_bcount *lpBufferSize LPWSTR  lpRemoteName,
__inout LPDWORD  lpBufferSize 
)

Definition at line 672 of file nfs41_np.c.

676 {
677  DWORD Status = 0;
678 
679  HANDLE hMutex, hMemory;
680  PNFS41NP_SHARED_MEMORY pSharedMemory;
681 
683  &hMemory,
684  (PVOID)&pSharedMemory);
685 
686  if (Status == WN_SUCCESS)
687  {
688  INT Index;
689  PNFS41NP_NETRESOURCE pNetResource;
691 
692  for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
693  {
694  pNetResource = &pSharedMemory->NetResources[Index];
695 
696  if (pNetResource->InUse)
697  {
698  if ( ( (wcslen(lpLocalName) + 1) * sizeof(WCHAR) ==
699  pNetResource->LocalNameLength)
700  && ( !wcscmp(lpLocalName, pNetResource->LocalName) ))
701  {
702  if (*lpBufferSize < pNetResource->RemoteNameLength)
703  {
704  *lpBufferSize = pNetResource->RemoteNameLength;
706  }
707  else
708  {
709  *lpBufferSize = pNetResource->RemoteNameLength;
710  CopyMemory( lpRemoteName,
711  pNetResource->RemoteName,
712  pNetResource->RemoteNameLength);
713  Status = WN_SUCCESS;
714  }
715  break;
716  }
717  }
718  }
719 
720  CloseSharedMemory( &hMutex, &hMemory, (PVOID)&pSharedMemory);
721  }
722 
723  return Status;
724 }
#define WN_SUCCESS
Definition: winnetwk.h:111
USHORT RemoteNameLength
Definition: nfs41_np.h:32
#define WN_NOT_CONNECTED
Definition: winnetwk.h:132
int32_t INT
Definition: typedefs.h:58
HANDLE hMutex
Definition: mutex.c:11
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CopyMemory
Definition: winbase.h:1646
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:24
VOID CloseSharedMemory(PHANDLE hMutex, PHANDLE hMemory, PVOID *pMemory)
Definition: nfs41_np.c:141
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
NFS41NP_NETRESOURCE NetResources[NFS41NP_MAX_DEVICES]
Definition: nfs41_np.h:47
DWORD OpenSharedMemory(PHANDLE phMutex, PHANDLE phMemory, PVOID *pMemory)
Definition: nfs41_np.c:66
#define WN_MORE_DATA
Definition: winnetwk.h:117
WCHAR RemoteName[MAX_PATH]
Definition: nfs41_np.h:39
USHORT LocalNameLength
Definition: nfs41_np.h:31
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
WCHAR LocalName[MAX_PATH]
Definition: nfs41_np.h:38

Referenced by _tryLoadProvider().

◆ NPGetResourceInformation()

DWORD APIENTRY NPGetResourceInformation ( __in LPNETRESOURCE  lpNetResource,
__out_bcount *lpBufferSize LPVOID  lpBuffer,
__inout LPDWORD  lpBufferSize,
__deref_out LPWSTR lplpSystem 
)

Definition at line 898 of file nfs41_np.c.

903 {
904  DbgP(( L"[aglo] NPGetResourceInformation: WN_NOT_SUPPORTED\n" ));
905  return WN_NOT_SUPPORTED;
906 }
#define WN_NOT_SUPPORTED
Definition: winnetwk.h:113
#define DbgP(_x_)
Definition: nfs41_np.c:34
static const WCHAR L[]
Definition: oid.c:1250

Referenced by _tryLoadProvider().

◆ NPGetResourceParent()

DWORD APIENTRY NPGetResourceParent ( LPNETRESOURCE  lpNetResource,
LPVOID  lpBuffer,
LPDWORD  lpBufferSize 
)

Definition at line 888 of file nfs41_np.c.

892 {
893  DbgP(( L"[aglo] NPGetResourceParent: WN_NOT_SUPPORTED\n" ));
894  return WN_NOT_SUPPORTED;
895 }
#define WN_NOT_SUPPORTED
Definition: winnetwk.h:113
#define DbgP(_x_)
Definition: nfs41_np.c:34
static const WCHAR L[]
Definition: oid.c:1250

◆ NPGetUniversalName()

DWORD APIENTRY NPGetUniversalName ( LPCWSTR  lpLocalPath,
DWORD  dwInfoLevel,
LPVOID  lpBuffer,
LPDWORD  lpBufferSize 
)

Definition at line 909 of file nfs41_np.c.

914 {
915  DbgP(( L"[aglo] NPGetUniversalName: WN_NOT_SUPPORTED\n" ));
916  return WN_NOT_SUPPORTED;
917 }
#define WN_NOT_SUPPORTED
Definition: winnetwk.h:113
#define DbgP(_x_)
Definition: nfs41_np.c:34
static const WCHAR L[]
Definition: oid.c:1250

◆ NPLogonNotify()

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 at line 376 of file nfs41_np.c.

385 {
386  *lpLogonScript = NULL;
387  DbgP(( L"[aglo] NPLogonNotify: returning WN_SUCCESS\n" ));
388  return WN_SUCCESS;
389 }
#define WN_SUCCESS
Definition: winnetwk.h:111
smooth NULL
Definition: ftsmooth.c:416
#define DbgP(_x_)
Definition: nfs41_np.c:34
static const WCHAR L[]
Definition: oid.c:1250

◆ NPOpenEnum()

DWORD APIENTRY NPOpenEnum ( DWORD  dwScope,
DWORD  dwType,
DWORD  dwUsage,
LPNETRESOURCE  lpNetResource,
LPHANDLE  lphEnum 
)

Definition at line 727 of file nfs41_np.c.

733 {
734  DWORD Status;
735 
736  DbgP((L"[aglo] NPOpenEnum\n"));
737 
738  *lphEnum = NULL;
739 
740  switch ( dwScope )
741  {
742  case RESOURCE_CONNECTED:
743  {
744  *lphEnum = HeapAlloc( GetProcessHeap( ), HEAP_ZERO_MEMORY, sizeof( ULONG ) );
745 
746  if (*lphEnum )
747  {
748  Status = WN_SUCCESS;
749  }
750  else
751  {
753  }
754  break;
755  }
756  break;
757 
758  case RESOURCE_CONTEXT:
759  default:
761  break;
762  }
763 
764 
765  DbgP((L"[aglo] NPOpenEnum returning Status %lx\n",Status));
766 
767  return(Status);
768 }
#define WN_SUCCESS
Definition: winnetwk.h:111
#define WN_NOT_SUPPORTED
Definition: winnetwk.h:113
#define RESOURCE_CONNECTED
Definition: winnetwk.h:58
smooth NULL
Definition: ftsmooth.c:416
#define DbgP(_x_)
Definition: nfs41_np.c:34
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RESOURCE_CONTEXT
Definition: winnetwk.h:62
Status
Definition: gdiplustypes.h:24
static const WCHAR L[]
Definition: oid.c:1250
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define WN_OUT_OF_MEMORY
Definition: winnetwk.h:125
unsigned int ULONG
Definition: retypes.h:1

Referenced by _tryLoadProvider().

◆ NPPasswordChangeNotify()

DWORD APIENTRY NPPasswordChangeNotify ( __in LPCWSTR  lpAuthentInfoType,
__in LPVOID  lpAuthentInfo,
__in LPCWSTR  lpPreviousAuthentInfoType,
__in LPVOID  lpPreviousAuthentInfo,
__in LPWSTR  lpStationName,
LPVOID  StationHandle,
DWORD  dwChangeInfo 
)

Definition at line 392 of file nfs41_np.c.

400 {
401  DbgP(( L"[aglo] NPPasswordChangeNotify: WN_NOT_SUPPORTED\n" ));
403  return WN_NOT_SUPPORTED;
404 }
#define WN_NOT_SUPPORTED
Definition: winnetwk.h:113
#define DbgP(_x_)
Definition: nfs41_np.c:34
#define SetLastError(x)
Definition: compat.h:500
static const WCHAR L[]
Definition: oid.c:1250

◆ OpenSharedMemory()

DWORD OpenSharedMemory ( PHANDLE  phMutex,
PHANDLE  phMemory,
PVOID pMemory 
)

Definition at line 66 of file nfs41_np.c.

89 {
91 
92  *phMutex = 0;
93  *phMemory = 0;
94  *pMemory = NULL;
95 
97  if (*phMutex == NULL)
98  {
100  DbgP((TEXT("OpenSharedMemory: OpenMutex failed\n")));
101  goto OpenSharedMemoryAbort1;
102  }
103 
104  WaitForSingleObject(*phMutex, INFINITE);
105 
106  *phMemory = OpenFileMapping(FILE_MAP_WRITE,
107  FALSE,
109  if (*phMemory == NULL)
110  {
112  DbgP((TEXT("OpenSharedMemory: OpenFileMapping failed\n")));
113  goto OpenSharedMemoryAbort2;
114  }
115 
116  *pMemory = MapViewOfFile(*phMemory, FILE_MAP_WRITE, 0, 0, 0);
117  if (*pMemory == NULL)
118  {
120  DbgP((TEXT("OpenSharedMemory: MapViewOfFile failed\n")));
121  goto OpenSharedMemoryAbort3;
122  }
123 
124  return ERROR_SUCCESS;
125 
126 OpenSharedMemoryAbort3:
127  CloseHandle(*phMemory);
128 
129 OpenSharedMemoryAbort2:
130  ReleaseMutex(*phMutex);
131  CloseHandle(*phMutex);
132  *phMutex = NULL;
133 
134 OpenSharedMemoryAbort1:
135  DbgP((TEXT("OpenSharedMemory: return dwStatus: %d\n"), dwStatus));
136 
137  return dwStatus;
138 }
#define NFS41NP_MUTEX_NAME
Definition: nfs41_np.h:25
#define CloseHandle
Definition: compat.h:487
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MapViewOfFile
Definition: compat.h:493
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define DbgP(_x_)
Definition: nfs41_np.c:34
#define CreateMutex
Definition: winbase.h:3596
#define FILE_MAP_WRITE
Definition: winbase.h:154
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
#define NFS41_USER_SHARED_MEMORY_NAME
Definition: nfs41_driver.h:37
#define TEXT(s)
Definition: k32.h:26
DWORD dwStatus
Definition: mediaobj.idl:95
#define OpenFileMapping
Definition: winbase.h:3727
#define INFINITE
Definition: serial.h:102

Referenced by NPCancelConnection(), NPEnumResource(), NPGetConnection(), and StoreConnectionInfo().

◆ SendTo_NFS41Driver()

ULONG SendTo_NFS41Driver ( IN ULONG  IoctlCode,
IN PVOID  InputDataBuf,
IN ULONG  InputDataLen,
IN PVOID  OutputDataBuf,
IN PULONG  pOutputDataLen 
)

Definition at line 266 of file nfs41_np.c.

272 {
273  HANDLE DeviceHandle; // The mini rdr device handle
274  BOOL rc = FALSE;
275  ULONG Status;
276 
277  Status = WN_SUCCESS;
278  DbgP((L"[aglo] calling CreateFile\n"));
285  0,
286  (HANDLE) NULL );
287 
288  DbgP((L"[aglo] after CreateFile Device Handle\n"));
290  {
291  _SEH2_TRY {
292  DbgP((L"[aglo] calling DeviceIoControl\n"));
293  rc = DeviceIoControl(
294  DeviceHandle,
295  IoctlCode,
296  InputDataBuf,
297  InputDataLen,
298  OutputDataBuf,
299  *pOutputDataLen,
300  pOutputDataLen,
301  NULL );
303  DbgP((L"#### In except\n"));
304  } _SEH2_END;
305  DbgP((L"[aglo] returned from DeviceIoControl %08lx\n", rc));
306  if ( !rc )
307  {
308  DbgP((L"[aglo] SendTo_NFS41Driver: returning error from DeviceIoctl\n"));
309  Status = GetLastError( );
310  }
311  else
312  {
313  DbgP((L"[aglo] SendTo_NFS41Driver: The DeviceIoctl call succeded\n"));
314  }
316  }
317  else
318  {
319  Status = GetLastError( );
320  DbgP((L"[aglo] SendTo_NFS41Driver: error %08lx opening device \n", Status));
321  }
322  DbgP((L"[aglo] returned from SendTo_NFS41Driver %08lx\n", Status));
323  return Status;
324 }
#define CloseHandle
Definition: compat.h:487
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define WN_SUCCESS
Definition: winnetwk.h:111
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:136
_SEH2_TRY
Definition: create.c:4226
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define DbgP(_x_)
Definition: nfs41_np.c:34
#define NFS41_USER_DEVICE_NAME
Definition: nfs41_driver.h:27
#define OPEN_EXISTING
Definition: compat.h:523
Status
Definition: gdiplustypes.h:24
static const WCHAR L[]
Definition: oid.c:1250
#define GENERIC_READ
Definition: compat.h:135
_SEH2_END
Definition: create.c:4400
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
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12

Referenced by NPAddConnection3(), and NPCancelConnection().

◆ StoreConnectionInfo()

static DWORD StoreConnectionInfo ( IN LPCWSTR  LocalName,
IN LPCWSTR  ConnectionName,
IN USHORT  ConnectionNameLength,
IN LPNETRESOURCE  lpNetResource 
)
static

Definition at line 185 of file nfs41_np.c.

190 {
191  DWORD status;
192  HANDLE hMutex, hMemory;
193  PNFS41NP_SHARED_MEMORY pSharedMemory;
194  PNFS41NP_NETRESOURCE pNfs41NetResource;
195  INT Index;
196  BOOLEAN FreeEntryFound = FALSE;
197 
198 #ifdef __REACTOS__
199  status = OpenSharedMemory(&hMutex, &hMemory, (PVOID *)&pSharedMemory);
200 #else
201  status = OpenSharedMemory(&hMutex, &hMemory, &(PVOID)pSharedMemory);
202 #endif
203  if (status)
204  goto out;
205 
206  DbgP((TEXT("StoreConnectionInfo: NextIndex %d, NumResources %d\n"),
207  pSharedMemory->NextAvailableIndex,
208  pSharedMemory->NumberOfResourcesInUse));
209 
210  for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
211  {
212  if (!pSharedMemory->NetResources[Index].InUse)
213  {
214  FreeEntryFound = TRUE;
215  DbgP((TEXT("Reusing existing index %d\n"), Index));
216  break;
217  }
218  }
219 
220  if (!FreeEntryFound)
221  {
222  if (pSharedMemory->NextAvailableIndex >= NFS41NP_MAX_DEVICES) {
224  goto out_close;
225  }
226  Index = pSharedMemory->NextAvailableIndex++;
227  DbgP((TEXT("Using new index %d\n"), Index));
228  }
229 
230  pSharedMemory->NumberOfResourcesInUse += 1;
231 
232  pNfs41NetResource = &pSharedMemory->NetResources[Index];
233 
234  pNfs41NetResource->InUse = TRUE;
235  pNfs41NetResource->dwScope = lpNetResource->dwScope;
236  pNfs41NetResource->dwType = lpNetResource->dwType;
237  pNfs41NetResource->dwDisplayType = lpNetResource->dwDisplayType;
238  pNfs41NetResource->dwUsage = RESOURCEUSAGE_CONNECTABLE;
239  pNfs41NetResource->LocalNameLength = (USHORT)(wcslen(LocalName) + 1) * sizeof(WCHAR);
240  pNfs41NetResource->RemoteNameLength = (USHORT)(wcslen(lpNetResource->lpRemoteName) + 1) * sizeof(WCHAR);
241  pNfs41NetResource->ConnectionNameLength = ConnectionNameLength;
242 
243  StringCchCopy(pNfs41NetResource->LocalName,
244  pNfs41NetResource->LocalNameLength,
245  LocalName);
246  StringCchCopy(pNfs41NetResource->RemoteName,
247  pNfs41NetResource->RemoteNameLength,
248  lpNetResource->lpRemoteName);
249  StringCchCopy(pNfs41NetResource->ConnectionName,
250  pNfs41NetResource->ConnectionNameLength,
251  ConnectionName);
252 
253  // TODO: copy mount options -cbodley
254 
255 out_close:
256 #ifdef __REACTOS__
257  CloseSharedMemory(&hMutex, &hMemory, (PVOID *)&pSharedMemory);
258 #else
259  CloseSharedMemory(&hMutex, &hMemory, &(PVOID)pSharedMemory);
260 #endif
261 out:
262  return status;
263 }
#define WN_NO_MORE_DEVICES
Definition: winnetwk.h:131
#define RESOURCEUSAGE_CONNECTABLE
Definition: winnetwk.h:68
WCHAR ConnectionName[MAX_PATH]
Definition: nfs41_np.h:40
#define TRUE
Definition: types.h:120
USHORT RemoteNameLength
Definition: nfs41_np.h:32
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
#define DbgP(_x_)
Definition: nfs41_np.c:34
HANDLE hMutex
Definition: mutex.c:11
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const UCHAR Index[8]
Definition: usbohci.c:18
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
#define StringCchCopy
Definition: strsafe.h:139
VOID CloseSharedMemory(PHANDLE hMutex, PHANDLE hMemory, PVOID *pMemory)
Definition: nfs41_np.c:141
#define TEXT(s)
Definition: k32.h:26
NFS41NP_NETRESOURCE NetResources[NFS41NP_MAX_DEVICES]
Definition: nfs41_np.h:47
unsigned short USHORT
Definition: pedump.c:61
DWORD OpenSharedMemory(PHANDLE phMutex, PHANDLE phMemory, PVOID *pMemory)
Definition: nfs41_np.c:66
USHORT ConnectionNameLength
Definition: nfs41_np.h:33
WCHAR RemoteName[MAX_PATH]
Definition: nfs41_np.h:39
#define NFS41NP_MAX_DEVICES
Definition: nfs41_np.h:27
static SERVICE_STATUS status
Definition: service.c:31
USHORT LocalNameLength
Definition: nfs41_np.h:31
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
WCHAR LocalName[MAX_PATH]
Definition: nfs41_np.h:38
Definition: ps.c:97

Referenced by NPAddConnection3().