ReactOS  0.4.15-dev-3165-gdf6fff7
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 <pseh/pseh2.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 36 of file nfs41_np.c.

◆ TRACE_TAG

#define TRACE_TAG   L"[NFS41_NP]"

Definition at line 38 of file nfs41_np.c.

◆ WNNC_DRIVER

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

Definition at line 39 of file nfs41_np.c.

Function Documentation

◆ CloseSharedMemory()

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

Definition at line 143 of file nfs41_np.c.

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 }
#define CloseHandle
Definition: compat.h:598
FxMemoryObject * pMemory
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define FALSE
Definition: types.h:117
#define DbgP(_x_)
Definition: nfs41_np.c:36
HANDLE hMutex
Definition: mutex.c:11
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
WDFMEMORY hMemory
#define TEXT(s)
Definition: k32.h:26
#define NULL
Definition: types.h:112
#define UnmapViewOfFile
Definition: compat.h:605

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

◆ filter()

int filter ( unsigned int  code)

Definition at line 61 of file nfs41_np.c.

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

◆ NFS41DbgPrint()

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

Definition at line 42 of file nfs41_np.c.

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 }
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:38
#define OutputDebugString
Definition: winbase.h:3746
int marker
Definition: jpeglib.h:1030
char * va_list
Definition: acmsvcex.h:78
char TCHAR
Definition: xmlstorage.h:189
va_start(ap, x)
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 419 of file nfs41_np.c.

423 {
424  return NPAddConnection3( NULL, lpNetResource, lpPassword, lpUserName, 0 );
425 }
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 NULL
Definition: types.h:112

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 428 of file nfs41_np.c.

434 {
435  DWORD Status;
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 ) ) {
552  Status = GetLastError();
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 
566 out:
567  FreeConnectionInfo(&Connection);
568  DbgP(( L"[aglo] NPAddConnection3: status %08X\n", Status));
569  return Status;
570 out_undefine:
572  DDD_EXACT_MATCH_ON_REMOVE, LocalName, ConnectionName);
573 out_delconn:
574  SendTo_NFS41Driver(IOCTL_NFS41_DELCONN, ConnectionName,
575  Connection.Buffer->NameLength, NULL, &CopyBytes);
576  goto out;
577 }
#define QueryDosDevice
Definition: winbase.h:3748
#define WN_BAD_NETNAME
Definition: winnetwk.h:135
void FreeConnectionInfo(IN PCONNECTION_INFO Connection)
Definition: options.c:92
#define DefineDosDevice
Definition: winbase.h:3619
ULONG SendTo_NFS41Driver(IN ULONG IoctlCode, IN PVOID InputDataBuf, IN ULONG InputDataLen, IN PVOID OutputDataBuf, IN PULONG pOutputDataLen)
Definition: nfs41_np.c:268
#define DDD_REMOVE_DEFINITION
Definition: winbase.h:521
#define DDD_NO_BROADCAST_SYSTEM
Definition: winbase.h:523
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:1040
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
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define DbgP(_x_)
Definition: nfs41_np.c:36
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
Status
Definition: gdiplustypes.h:24
static DWORD StoreConnectionInfo(IN LPCWSTR LocalName, IN LPCWSTR ConnectionName, IN USHORT ConnectionNameLength, IN LPNETRESOURCE lpNetResource)
Definition: nfs41_np.c:187
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
static const WCHAR L[]
Definition: oid.c:1250
#define IOCTL_NFS41_ADDCONN
Definition: nfs41_driver.h:46
#define lstrlen
Definition: winbase.h:3732
#define DDD_RAW_TARGET_PATH
Definition: winbase.h:520
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
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
USHORT NameLength
Definition: options.h:45
#define DDD_EXACT_MATCH_ON_REMOVE
Definition: winbase.h:522
#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 580 of file nfs41_np.c.

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()));
639  Status = 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 }
#define DefineDosDevice
Definition: winbase.h:3619
ULONG SendTo_NFS41Driver(IN ULONG IoctlCode, IN PVOID InputDataBuf, IN ULONG InputDataLen, IN PVOID OutputDataBuf, IN PULONG pOutputDataLen)
Definition: nfs41_np.c:268
WCHAR ConnectionName[MAX_PATH]
Definition: nfs41_np.h:40
#define WN_SUCCESS
Definition: winnetwk.h:111
#define DDD_REMOVE_DEFINITION
Definition: winbase.h:521
_In_ LPCSTR lpName
Definition: winbase.h:2768
#define IOCTL_NFS41_DELCONN
Definition: nfs41_driver.h:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define WN_NOT_CONNECTED
Definition: winnetwk.h:132
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
#define DbgP(_x_)
Definition: nfs41_np.c:36
HANDLE hMutex
Definition: mutex.c:11
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ WDFCOLLECTION _In_ ULONG Index
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID CloseSharedMemory(PHANDLE hMutex, PHANDLE hMemory, PVOID *pMemory)
Definition: nfs41_np.c:143
WDFMEMORY hMemory
_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:520
NFS41NP_NETRESOURCE NetResources[NFS41NP_MAX_DEVICES]
Definition: nfs41_np.h:47
DWORD OpenSharedMemory(PHANDLE phMutex, PHANDLE phMemory, PVOID *pMemory)
Definition: nfs41_np.c:68
#define NULL
Definition: types.h:112
USHORT ConnectionNameLength
Definition: nfs41_np.h:33
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
unsigned int ULONG
Definition: retypes.h:1
USHORT LocalNameLength
Definition: nfs41_np.h:31
#define DDD_EXACT_MATCH_ON_REMOVE
Definition: winbase.h:522
WCHAR LocalName[MAX_PATH]
Definition: nfs41_np.h:38

Referenced by _tryLoadProvider().

◆ NPCloseEnum()

DWORD APIENTRY NPCloseEnum ( HANDLE  hEnum)

Definition at line 881 of file nfs41_np.c.

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

Referenced by _tryLoadProvider().

◆ NPEnumResource()

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

Definition at line 773 of file nfs41_np.c.

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 );
864  Status = WN_SUCCESS;
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 }
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:175
#define DbgP(_x_)
Definition: nfs41_np.c:36
HANDLE hMutex
Definition: mutex.c:11
NETRESOURCEA * LPNETRESOURCE
Definition: winnetwk.h:593
LPSTR lpProvider
Definition: winnetwk.h:174
DWORD dwScope
Definition: winnetwk.h:167
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ WDFCOLLECTION _In_ ULONG Index
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR lpComment
Definition: winnetwk.h:173
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:143
WDFMEMORY hMemory
NFS41NP_NETRESOURCE NetResources[NFS41NP_MAX_DEVICES]
Definition: nfs41_np.h:47
DWORD OpenSharedMemory(PHANDLE phMutex, PHANDLE phMemory, PVOID *pMemory)
Definition: nfs41_np.c:68
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 329 of file nfs41_np.c.

331 {
332  DWORD rc = 0;
333 
334 #ifndef __REACTOS__
335  DbgP(( L"[aglo] GetNetCaps %d\n", nIndex ));
336 #endif
337  switch ( nIndex )
338  {
339  case WNNC_SPEC_VERSION:
340  rc = WNNC_SPEC_VERSION51;
341  break;
342 
343  case WNNC_NET_TYPE:
344  rc = WNNC_NET_RDR2SAMPLE;
345  break;
346 
347  case WNNC_DRIVER_VERSION:
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 }
#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:36
#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:39
#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 674 of file nfs41_np.c.

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);
715  Status = WN_SUCCESS;
716  }
717  break;
718  }
719  }
720  }
721 
722  CloseSharedMemory( &hMutex, &hMemory, (PVOID)&pSharedMemory);
723  }
724 
725  return Status;
726 }
#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
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ WDFCOLLECTION _In_ ULONG Index
#define CopyMemory
Definition: winbase.h:1662
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID CloseSharedMemory(PHANDLE hMutex, PHANDLE hMemory, PVOID *pMemory)
Definition: nfs41_np.c:143
WDFMEMORY hMemory
_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:68
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define WN_MORE_DATA
Definition: winnetwk.h:117
WCHAR RemoteName[MAX_PATH]
Definition: nfs41_np.h:39
USHORT LocalNameLength
Definition: nfs41_np.h:31
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 900 of file nfs41_np.c.

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

Referenced by _tryLoadProvider().

◆ NPGetResourceParent()

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

Definition at line 890 of file nfs41_np.c.

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

◆ NPGetUniversalName()

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

Definition at line 911 of file nfs41_np.c.

916 {
917  DbgP(( L"[aglo] NPGetUniversalName: WN_NOT_SUPPORTED\n" ));
918  return WN_NOT_SUPPORTED;
919 }
#define WN_NOT_SUPPORTED
Definition: winnetwk.h:113
#define DbgP(_x_)
Definition: nfs41_np.c:36
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 378 of file nfs41_np.c.

387 {
388  *lpLogonScript = NULL;
389  DbgP(( L"[aglo] NPLogonNotify: returning WN_SUCCESS\n" ));
390  return WN_SUCCESS;
391 }
#define WN_SUCCESS
Definition: winnetwk.h:111
#define DbgP(_x_)
Definition: nfs41_np.c:36
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112

◆ NPOpenEnum()

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

Definition at line 729 of file nfs41_np.c.

735 {
736  DWORD Status;
737 
738  DbgP((L"[aglo] NPOpenEnum\n"));
739 
740  *lphEnum = NULL;
741 
742  switch ( dwScope )
743  {
744  case RESOURCE_CONNECTED:
745  {
746  *lphEnum = HeapAlloc( GetProcessHeap( ), HEAP_ZERO_MEMORY, sizeof( ULONG ) );
747 
748  if (*lphEnum )
749  {
750  Status = WN_SUCCESS;
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 }
#define WN_SUCCESS
Definition: winnetwk.h:111
#define WN_NOT_SUPPORTED
Definition: winnetwk.h:113
#define RESOURCE_CONNECTED
Definition: winnetwk.h:58
#define DbgP(_x_)
Definition: nfs41_np.c:36
Status
Definition: gdiplustypes.h:24
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RESOURCE_CONTEXT
Definition: winnetwk.h:62
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
#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 394 of file nfs41_np.c.

402 {
403  DbgP(( L"[aglo] NPPasswordChangeNotify: WN_NOT_SUPPORTED\n" ));
405  return WN_NOT_SUPPORTED;
406 }
#define WN_NOT_SUPPORTED
Definition: winnetwk.h:113
#define DbgP(_x_)
Definition: nfs41_np.c:36
#define SetLastError(x)
Definition: compat.h:611
static const WCHAR L[]
Definition: oid.c:1250

◆ OpenSharedMemory()

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

Definition at line 68 of file nfs41_np.c.

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 
108  *phMemory = OpenFileMapping(FILE_MAP_WRITE,
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 
128 OpenSharedMemoryAbort3:
129  CloseHandle(*phMemory);
130 
131 OpenSharedMemoryAbort2:
132  ReleaseMutex(*phMutex);
133  CloseHandle(*phMutex);
134  *phMutex = NULL;
135 
136 OpenSharedMemoryAbort1:
137  DbgP((TEXT("OpenSharedMemory: return dwStatus: %d\n"), dwStatus));
138 
139  return dwStatus;
140 }
#define NFS41NP_MUTEX_NAME
Definition: nfs41_np.h:25
#define CloseHandle
Definition: compat.h:598
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MapViewOfFile
Definition: compat.h:604
FxMemoryObject * pMemory
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
#define DbgP(_x_)
Definition: nfs41_np.c:36
#define CreateMutex
Definition: winbase.h:3612
#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 NULL
Definition: types.h:112
#define OpenFileMapping
Definition: winbase.h:3743
#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 268 of file nfs41_np.c.

274 {
275  HANDLE DeviceHandle; // The mini rdr device handle
276  BOOL rc = FALSE;
277  ULONG Status;
278 
279  Status = WN_SUCCESS;
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(
296  DeviceHandle,
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 }
#define CloseHandle
Definition: compat.h:598
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define WN_SUCCESS
Definition: winnetwk.h:111
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG IoctlCode
Definition: wdfiotarget.h:1039
#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
#define DbgP(_x_)
Definition: nfs41_np.c:36
#define NFS41_USER_DEVICE_NAME
Definition: nfs41_driver.h:27
#define OPEN_EXISTING
Definition: compat.h:634
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
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165

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 187 of file nfs41_np.c.

192 {
193  DWORD status;
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 
257 out_close:
258 #ifdef __REACTOS__
259  CloseSharedMemory(&hMutex, &hMemory, (PVOID *)&pSharedMemory);
260 #else
261  CloseSharedMemory(&hMutex, &hMemory, &(PVOID)pSharedMemory);
262 #endif
263 out:
264  return status;
265 }
#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:36
HANDLE hMutex
Definition: mutex.c:11
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ WDFCOLLECTION _In_ ULONG Index
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:143
WDFMEMORY hMemory
#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:68
USHORT ConnectionNameLength
Definition: nfs41_np.h:33
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
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
WCHAR LocalName[MAX_PATH]
Definition: nfs41_np.h:38
Definition: ps.c:97

Referenced by NPAddConnection3().