ReactOS 0.4.15-dev-8434-g155a7c7
wnet.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winioctl.h"
#include "winnetwk.h"
#include "npapi.h"
#include "winreg.h"
#include "winuser.h"
#include "ddk/mountmgr.h"
#include "wine/debug.h"
#include "mprres.h"
#include "wnetpriv.h"
Include dependency graph for wnet.c:

Go to the source code of this file.

Classes

struct  _WNetProvider
 
struct  _WNetProviderTable
 
struct  _WNetEnumerator
 
struct  use_connection_context
 

Macros

#define WINE_MOUNTMGR_EXTENSIONS
 
#define WNET_ENUMERATOR_TYPE_GLOBAL   0
 
#define WNET_ENUMERATOR_TYPE_PROVIDER   1
 
#define WNET_ENUMERATOR_TYPE_CONTEXT   2
 
#define WNET_ENUMERATOR_TYPE_CONNECTED   3
 
#define WNET_ENUMERATOR_TYPE_REMEMBERED   4
 
#define BAD_PROVIDER_INDEX   (DWORD)0xffffffff
 
#define MPR_GETPROC(proc)   ((PF_##proc)GetProcAddress(hLib, #proc))
 

Typedefs

typedef struct _WNetProvider WNetProvider
 
typedef struct _WNetProviderPWNetProvider
 
typedef struct _WNetProviderTable WNetProviderTable
 
typedef struct _WNetProviderTablePWNetProviderTable
 
typedef struct _WNetEnumerator WNetEnumerator
 
typedef struct _WNetEnumeratorPWNetEnumerator
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (mpr)
 
static DWORD _findProviderIndexW (LPCWSTR lpProvider)
 
static void _tryLoadProvider (PCWSTR provider)
 
void wnetInit (HINSTANCE hInstDll)
 
void wnetFree (void)
 
static LPNETRESOURCEW _copyNetResourceForEnumW (LPNETRESOURCEW lpNet)
 
static void _freeEnumNetResource (LPNETRESOURCEW lpNet)
 
static PWNetEnumerator _createGlobalEnumeratorW (DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCEW lpNet)
 
static PWNetEnumerator _createProviderEnumerator (DWORD dwScope, DWORD dwType, DWORD dwUsage, DWORD index, HANDLE handle)
 
static PWNetEnumerator _createContextEnumerator (DWORD dwScope, DWORD dwType, DWORD dwUsage)
 
static PWNetEnumerator _createConnectedEnumerator (DWORD dwScope, DWORD dwType, DWORD dwUsage)
 
static PWNetEnumerator _createRememberedEnumerator (DWORD dwScope, DWORD dwType, HKEY remembered)
 
static DWORD _thunkNetResourceArrayWToA (const NETRESOURCEW *lpNetArrayIn, const DWORD *lpcCount, LPVOID lpBuffer, const DWORD *lpBufferSize)
 
static DWORD _thunkNetResourceArrayAToW (const NETRESOURCEA *lpNetArrayIn, const DWORD *lpcCount, LPVOID lpBuffer, const DWORD *lpBufferSize)
 
DWORD WINAPI WNetOpenEnumA (DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCEA lpNet, LPHANDLE lphEnum)
 
DWORD WINAPI WNetOpenEnumW (DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCEW lpNet, LPHANDLE lphEnum)
 
DWORD WINAPI WNetEnumResourceA (HANDLE hEnum, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
 
static DWORD _countProviderBytesW (PWNetProvider provider)
 
static DWORD _enumerateProvidersW (PWNetEnumerator enumerator, LPDWORD lpcCount, LPVOID lpBuffer, const DWORD *lpBufferSize)
 
static DWORD _globalEnumeratorAdvance (PWNetEnumerator enumerator)
 
static DWORD _enumerateGlobalPassthroughW (PWNetEnumerator enumerator, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
 
static DWORD _enumerateGlobalW (PWNetEnumerator enumerator, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
 
static DWORD _enumerateProviderW (PWNetEnumerator enumerator, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
 
static DWORD _enumerateContextW (PWNetEnumerator enumerator, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
 
static DWORD _copyStringToEnumW (const WCHAR *source, DWORD *left, void **end)
 
static DWORD _enumerateConnectedW (PWNetEnumerator enumerator, DWORD *user_count, void *user_buffer, DWORD *user_size)
 
static WCHARget_reg_str (HKEY hkey, const WCHAR *value, DWORD *len)
 
static DWORD _enumeratorRememberedW (PWNetEnumerator enumerator, DWORD *user_count, void *user_buffer, DWORD *user_size)
 
DWORD WINAPI WNetEnumResourceW (HANDLE hEnum, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
 
DWORD WINAPI WNetCloseEnum (HANDLE hEnum)
 
DWORD WINAPI WNetGetResourceInformationA (LPNETRESOURCEA lpNetResource, LPVOID lpBuffer, LPDWORD cbBuffer, LPSTR *lplpSystem)
 
DWORD WINAPI WNetGetResourceInformationW (LPNETRESOURCEW lpNetResource, LPVOID lpBuffer, LPDWORD cbBuffer, LPWSTR *lplpSystem)
 
DWORD WINAPI WNetGetResourceParentA (LPNETRESOURCEA lpNetResource, LPVOID lpBuffer, LPDWORD lpBufferSize)
 
DWORD WINAPI WNetGetResourceParentW (LPNETRESOURCEW lpNetResource, LPVOID lpBuffer, LPDWORD lpBufferSize)
 
DWORD WINAPI WNetAddConnectionA (LPCSTR lpRemoteName, LPCSTR lpPassword, LPCSTR lpLocalName)
 
DWORD WINAPI WNetAddConnectionW (LPCWSTR lpRemoteName, LPCWSTR lpPassword, LPCWSTR lpLocalName)
 
DWORD WINAPI WNetAddConnection2A (LPNETRESOURCEA lpNetResource, LPCSTR lpPassword, LPCSTR lpUserID, DWORD dwFlags)
 
DWORD WINAPI WNetAddConnection2W (LPNETRESOURCEW lpNetResource, LPCWSTR lpPassword, LPCWSTR lpUserID, DWORD dwFlags)
 
DWORD WINAPI WNetAddConnection3A (HWND hwndOwner, LPNETRESOURCEA lpNetResource, LPCSTR lpPassword, LPCSTR lpUserID, DWORD dwFlags)
 
DWORD WINAPI WNetAddConnection3W (HWND hwndOwner, LPNETRESOURCEW lpNetResource, LPCWSTR lpPassword, LPCWSTR lpUserID, DWORD dwFlags)
 
static DWORD use_connection_pre_set_accessnameW (struct use_connection_context *ctxt, WCHAR *local_name)
 
static void use_connection_set_accessnameW (struct use_connection_context *ctxt, WCHAR *local_name)
 
static DWORD wnet_use_provider (struct use_connection_context *ctxt, NETRESOURCEW *netres, WNetProvider *provider, BOOLEAN redirect)
 
static DWORD wnet_use_connection (struct use_connection_context *ctxt)
 
DWORD WINAPI WNetUseConnectionW (HWND hwndOwner, NETRESOURCEW *resource, LPCWSTR password, LPCWSTR userid, DWORD flags, LPWSTR accessname, DWORD *buffer_size, DWORD *result)
 
static DWORD use_connection_pre_set_accessnameA (struct use_connection_context *ctxt, WCHAR *local_name)
 
static void use_connection_set_accessnameA (struct use_connection_context *ctxt, WCHAR *local_name)
 
static LPWSTR strdupAtoW (LPCSTR str)
 
static void netresource_a_to_w (NETRESOURCEA *resourceA, NETRESOURCEW *resourceW)
 
static void free_netresourceW (NETRESOURCEW *resource)
 
DWORD WINAPI WNetUseConnectionA (HWND hwndOwner, NETRESOURCEA *resource, LPCSTR password, LPCSTR userid, DWORD flags, LPSTR accessname, DWORD *buffer_size, DWORD *result)
 
DWORD WINAPI WNetCancelConnectionA (LPCSTR lpName, BOOL fForce)
 
DWORD WINAPI WNetCancelConnectionW (LPCWSTR lpName, BOOL fForce)
 
DWORD WINAPI WNetCancelConnection2A (LPCSTR lpName, DWORD dwFlags, BOOL fForce)
 
DWORD WINAPI WNetCancelConnection2W (LPCWSTR lpName, DWORD dwFlags, BOOL fForce)
 
DWORD WINAPI WNetRestoreConnectionA (HWND hwndOwner, LPCSTR lpszDevice)
 
DWORD WINAPI WNetRestoreConnectionW (HWND hwndOwner, LPCWSTR lpszDevice)
 
DWORD WINAPI WNetGetConnectionA (LPCSTR lpLocalName, LPSTR lpRemoteName, LPDWORD lpBufferSize)
 
static DWORD get_drive_connection (WCHAR letter, LPWSTR remote, LPDWORD size)
 
DWORD WINAPI WNetGetConnectionW (LPCWSTR lpLocalName, LPWSTR lpRemoteName, LPDWORD lpBufferSize)
 
DWORD WINAPI WNetSetConnectionA (LPCSTR lpName, DWORD dwProperty, LPVOID pvValue)
 
DWORD WINAPI WNetSetConnectionW (LPCWSTR lpName, DWORD dwProperty, LPVOID pvValue)
 
DWORD WINAPI WNetGetUniversalNameA (LPCSTR lpLocalPath, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpBufferSize)
 
DWORD WINAPI WNetGetUniversalNameW (LPCWSTR lpLocalPath, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpBufferSize)
 
DWORD WINAPI WNetClearConnections (HWND owner)
 
DWORD WINAPI WNetGetUserA (LPCSTR lpName, LPSTR lpUserID, LPDWORD lpBufferSize)
 
DWORD WINAPI WNetGetUserW (LPCWSTR lpName, LPWSTR lpUserID, LPDWORD lpBufferSize)
 
DWORD WINAPI WNetConnectionDialog (HWND hwnd, DWORD dwType)
 
DWORD WINAPI WNetConnectionDialog1A (LPCONNECTDLGSTRUCTA lpConnDlgStruct)
 
DWORD WINAPI WNetConnectionDialog1W (LPCONNECTDLGSTRUCTW lpConnDlgStruct)
 
DWORD WINAPI WNetDisconnectDialog (HWND hwnd, DWORD dwType)
 
DWORD WINAPI WNetDisconnectDialog1A (LPDISCDLGSTRUCTA lpConnDlgStruct)
 
DWORD WINAPI WNetDisconnectDialog1W (LPDISCDLGSTRUCTW lpConnDlgStruct)
 
DWORD WINAPI WNetGetLastErrorA (LPDWORD lpError, LPSTR lpErrorBuf, DWORD nErrorBufSize, LPSTR lpNameBuf, DWORD nNameBufSize)
 
DWORD WINAPI WNetGetLastErrorW (LPDWORD lpError, LPWSTR lpErrorBuf, DWORD nErrorBufSize, LPWSTR lpNameBuf, DWORD nNameBufSize)
 
DWORD WINAPI WNetGetNetworkInformationA (LPCSTR lpProvider, LPNETINFOSTRUCT lpNetInfoStruct)
 
DWORD WINAPI WNetGetNetworkInformationW (LPCWSTR lpProvider, LPNETINFOSTRUCT lpNetInfoStruct)
 
DWORD WINAPI WNetGetProviderNameA (DWORD dwNetType, LPSTR lpProvider, LPDWORD lpBufferSize)
 
DWORD WINAPI WNetGetProviderNameW (DWORD dwNetType, LPWSTR lpProvider, LPDWORD lpBufferSize)
 

Variables

static PWNetProviderTable providerTable
 
static const WCHAR connectionType [] = { 'C','o','n','n','e','c','t','i','o','n','T','y','p','e',0 }
 
static const WCHAR providerName [] = { 'P','r','o','v','i','d','e','r','N','a','m','e',0 }
 
static const WCHAR remotePath [] = { 'R','e','m','o','t','e','P','a','t','h',0 }
 
static const WCHAR providerType [] = { 'P','r','o','v','i','d','e','r','T','y','p','e',0 }
 
static const WCHAR userName [] = { 'U','s','e','r','N','a','m','e',0 }
 

Macro Definition Documentation

◆ BAD_PROVIDER_INDEX

#define BAD_PROVIDER_INDEX   (DWORD)0xffffffff

Definition at line 122 of file wnet.c.

◆ MPR_GETPROC

#define MPR_GETPROC (   proc)    ((PF_##proc)GetProcAddress(hLib, #proc))

◆ WINE_MOUNTMGR_EXTENSIONS

#define WINE_MOUNTMGR_EXTENSIONS

Definition at line 34 of file wnet.c.

◆ WNET_ENUMERATOR_TYPE_CONNECTED

#define WNET_ENUMERATOR_TYPE_CONNECTED   3

Definition at line 83 of file wnet.c.

◆ WNET_ENUMERATOR_TYPE_CONTEXT

#define WNET_ENUMERATOR_TYPE_CONTEXT   2

Definition at line 82 of file wnet.c.

◆ WNET_ENUMERATOR_TYPE_GLOBAL

#define WNET_ENUMERATOR_TYPE_GLOBAL   0

Definition at line 80 of file wnet.c.

◆ WNET_ENUMERATOR_TYPE_PROVIDER

#define WNET_ENUMERATOR_TYPE_PROVIDER   1

Definition at line 81 of file wnet.c.

◆ WNET_ENUMERATOR_TYPE_REMEMBERED

#define WNET_ENUMERATOR_TYPE_REMEMBERED   4

Definition at line 84 of file wnet.c.

Typedef Documentation

◆ PWNetEnumerator

◆ PWNetProvider

◆ PWNetProviderTable

◆ WNetEnumerator

◆ WNetProvider

◆ WNetProviderTable

Function Documentation

◆ _copyNetResourceForEnumW()

static LPNETRESOURCEW _copyNetResourceForEnumW ( LPNETRESOURCEW  lpNet)
static

Definition at line 529 of file wnet.c.

530{
532
533 if (lpNet)
534 {
535 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(NETRESOURCEW));
536 if (ret)
537 {
538 size_t len;
539
540 *ret = *lpNet;
541 ret->lpLocalName = ret->lpComment = ret->lpProvider = NULL;
542 if (lpNet->lpRemoteName)
543 {
544 len = lstrlenW(lpNet->lpRemoteName) + 1;
545 ret->lpRemoteName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
546 if (ret->lpRemoteName)
547 lstrcpyW(ret->lpRemoteName, lpNet->lpRemoteName);
548 }
549 }
550 }
551 else
552 ret = NULL;
553 return ret;
554}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
GLenum GLsizei len
Definition: glext.h:6722
LPWSTR lpRemoteName
Definition: winnetwk.h:182
int ret
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by _createGlobalEnumeratorW().

◆ _copyStringToEnumW()

static DWORD _copyStringToEnumW ( const WCHAR source,
DWORD left,
void **  end 
)
static

Definition at line 1420 of file wnet.c.

1421{
1422 DWORD len;
1423 WCHAR* local = *end;
1424
1425 len = lstrlenW(source) + 1;
1426 len *= sizeof(WCHAR);
1427 if (*left < len)
1428 return WN_MORE_DATA;
1429
1430 local -= (len / sizeof(WCHAR));
1432 *left -= len;
1433 *end = local;
1434
1435 return WN_SUCCESS;
1436}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define local
Definition: zutil.h:30
GLuint GLuint end
Definition: gl.h:1545
GLint left
Definition: glext.h:7726
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define WN_MORE_DATA
Definition: winnetwk.h:117
#define WN_SUCCESS
Definition: winnetwk.h:111

Referenced by _enumerateConnectedW().

◆ _countProviderBytesW()

static DWORD _countProviderBytesW ( PWNetProvider  provider)
static

Definition at line 1104 of file wnet.c.

1105{
1106 DWORD ret;
1107
1108 if (provider)
1109 {
1110 ret = sizeof(NETRESOURCEW);
1111 ret += 2 * (lstrlenW(provider->name) + 1) * sizeof(WCHAR);
1112 }
1113 else
1114 ret = 0;
1115 return ret;
1116}
PWSTR name
Definition: wnet.c:55
struct _NETRESOURCEW NETRESOURCEW

Referenced by _enumerateProvidersW().

◆ _createConnectedEnumerator()

static PWNetEnumerator _createConnectedEnumerator ( DWORD  dwScope,
DWORD  dwType,
DWORD  dwUsage 
)
static

Definition at line 621 of file wnet.c.

623{
625 if (ret)
626 {
628 ret->dwScope = dwScope;
629 ret->dwType = dwType;
630 ret->dwUsage = dwUsage;
632 if (!ret->specific.handles)
633 {
635 ret = NULL;
636 }
637 }
638 return ret;
639}
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
DWORD numProviders
Definition: wnet.c:76
#define WNET_ENUMERATOR_TYPE_CONNECTED
Definition: wnet.c:83
static PWNetProviderTable providerTable
Definition: wnet.c:129

Referenced by WNetOpenEnumW().

◆ _createContextEnumerator()

static PWNetEnumerator _createContextEnumerator ( DWORD  dwScope,
DWORD  dwType,
DWORD  dwUsage 
)
static

Definition at line 605 of file wnet.c.

607{
610
611 if (ret)
612 {
614 ret->dwScope = dwScope;
615 ret->dwType = dwType;
616 ret->dwUsage = dwUsage;
617 }
618 return ret;
619}
#define WNET_ENUMERATOR_TYPE_CONTEXT
Definition: wnet.c:82

Referenced by WNetOpenEnumW().

◆ _createGlobalEnumeratorW()

static PWNetEnumerator _createGlobalEnumeratorW ( DWORD  dwScope,
DWORD  dwType,
DWORD  dwUsage,
LPNETRESOURCEW  lpNet 
)
static

Definition at line 565 of file wnet.c.

567{
570
571 if (ret)
572 {
574 ret->dwScope = dwScope;
575 ret->dwType = dwType;
576 ret->dwUsage = dwUsage;
577 ret->specific.net = _copyNetResourceForEnumW(lpNet);
578 }
579 return ret;
580}
static LPNETRESOURCEW _copyNetResourceForEnumW(LPNETRESOURCEW lpNet)
Definition: wnet.c:529
#define WNET_ENUMERATOR_TYPE_GLOBAL
Definition: wnet.c:80

Referenced by WNetOpenEnumW().

◆ _createProviderEnumerator()

static PWNetEnumerator _createProviderEnumerator ( DWORD  dwScope,
DWORD  dwType,
DWORD  dwUsage,
DWORD  index,
HANDLE  handle 
)
static

Definition at line 582 of file wnet.c.

584{
586
588 ret = NULL;
589 else
590 {
592 if (ret)
593 {
595 ret->providerIndex = index;
596 ret->dwScope = dwScope;
597 ret->dwType = dwType;
598 ret->dwUsage = dwUsage;
599 ret->handle = handle;
600 }
601 }
602 return ret;
603}
#define index(s, c)
Definition: various.h:29
GLuint index
Definition: glext.h:6031
#define WNET_ENUMERATOR_TYPE_PROVIDER
Definition: wnet.c:81

Referenced by WNetOpenEnumW().

◆ _createRememberedEnumerator()

static PWNetEnumerator _createRememberedEnumerator ( DWORD  dwScope,
DWORD  dwType,
HKEY  remembered 
)
static

Definition at line 641 of file wnet.c.

643{
645 if (ret)
646 {
648 ret->dwScope = dwScope;
649 ret->dwType = dwType;
650 ret->specific.remembered.registry = remembered;
651 }
652 return ret;
653}
#define WNET_ENUMERATOR_TYPE_REMEMBERED
Definition: wnet.c:84

Referenced by WNetOpenEnumW().

◆ _enumerateConnectedW()

static DWORD _enumerateConnectedW ( PWNetEnumerator  enumerator,
DWORD user_count,
void user_buffer,
DWORD user_size 
)
static

Definition at line 1438 of file wnet.c.

1440{
1441 DWORD ret, index, count, total_count, size, i, left;
1442 void* end;
1443 NETRESOURCEW* curr, * buffer;
1444 HANDLE* handles;
1445
1446 if (!enumerator)
1447 return WN_BAD_POINTER;
1448 if (enumerator->enumType != WNET_ENUMERATOR_TYPE_CONNECTED)
1449 return WN_BAD_VALUE;
1450 if (!user_count || !user_buffer || !user_size)
1451 return WN_BAD_POINTER;
1452 if (!providerTable)
1453 return WN_NO_NETWORK;
1454
1455 handles = enumerator->specific.handles;
1456 left = *user_size;
1457 size = *user_size;
1458 buffer = HeapAlloc(GetProcessHeap(), 0, *user_size);
1459 if (!buffer)
1460 return WN_NO_NETWORK;
1461
1462 curr = user_buffer;
1463 end = (char *)user_buffer + size;
1464 count = *user_count;
1465 total_count = 0;
1466
1468 for (index = 0; index < providerTable->numProviders; index++)
1469 {
1471 {
1472 if (handles[index] == 0)
1473 {
1474 ret = providerTable->table[index].openEnum(enumerator->dwScope,
1475 enumerator->dwType,
1476 enumerator->dwUsage,
1477 NULL, &handles[index]);
1478 if (ret != WN_SUCCESS)
1479 continue;
1480 }
1481
1483 &count, buffer,
1484 &size);
1485 total_count += count;
1486 if (ret == WN_MORE_DATA)
1487 break;
1488
1489 if (ret == WN_SUCCESS)
1490 {
1491 for (i = 0; i < count; ++i)
1492 {
1493 if (left < sizeof(NETRESOURCEW))
1494 {
1495 ret = WN_MORE_DATA;
1496 break;
1497 }
1498
1499 memcpy(curr, &buffer[i], sizeof(NETRESOURCEW));
1500 left -= sizeof(NETRESOURCEW);
1501
1502 ret = _copyStringToEnumW(buffer[i].lpLocalName, &left, &end);
1503 if (ret == WN_MORE_DATA)
1504 break;
1505 curr->lpLocalName = end;
1506
1507 ret = _copyStringToEnumW(buffer[i].lpRemoteName, &left, &end);
1508 if (ret == WN_MORE_DATA)
1509 break;
1510 curr->lpRemoteName = end;
1511
1512 ret = _copyStringToEnumW(buffer[i].lpProvider, &left, &end);
1513 if (ret == WN_MORE_DATA)
1514 break;
1515 curr->lpProvider = end;
1516
1517 ++curr;
1518 }
1519
1520 size = left;
1521 }
1522
1523 if (*user_count != -1)
1524 count = *user_count - total_count;
1525 else
1526 count = *user_count;
1527 }
1528 }
1529
1530 if (total_count == 0)
1532
1533 *user_count = total_count;
1535 ret = WN_SUCCESS;
1536
1538
1539 TRACE("Returning %d\n", ret);
1540 return ret;
1541}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
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 TRACE(s)
Definition: solgame.cpp:4
LPWSTR lpLocalName
Definition: winnetwk.h:181
LPWSTR lpProvider
Definition: winnetwk.h:184
DWORD dwUsage
Definition: wnet.c:109
DWORD dwType
Definition: wnet.c:108
DWORD dwScope
Definition: wnet.c:107
union _WNetEnumerator::@473 specific
DWORD enumType
Definition: wnet.c:103
HANDLE * handles
Definition: wnet.c:113
WNetProvider table[1]
Definition: wnet.c:77
PF_NPOpenEnum openEnum
Definition: wnet.c:60
DWORD dwEnumScopes
Definition: wnet.c:59
PF_NPEnumResource enumResource
Definition: wnet.c:61
static EFI_HANDLE * handles
Definition: uefidisk.c:62
#define WN_BAD_POINTER
Definition: winnetwk.h:118
#define WN_NO_NETWORK
Definition: winnetwk.h:126
#define WN_NO_MORE_ENTRIES
Definition: winnetwk.h:146
#define WN_BAD_VALUE
Definition: winnetwk.h:119
static DWORD _copyStringToEnumW(const WCHAR *source, DWORD *left, void **end)
Definition: wnet.c:1420

Referenced by WNetEnumResourceW().

◆ _enumerateContextW()

static DWORD _enumerateContextW ( PWNetEnumerator  enumerator,
LPDWORD  lpcCount,
LPVOID  lpBuffer,
LPDWORD  lpBufferSize 
)
static

Definition at line 1343 of file wnet.c.

1345{
1346 DWORD ret;
1347 size_t cchEntireNetworkLen, bytesNeeded;
1348
1349 if (!enumerator)
1350 return WN_BAD_POINTER;
1351 if (enumerator->enumType != WNET_ENUMERATOR_TYPE_CONTEXT)
1352 return WN_BAD_VALUE;
1353 if (!lpcCount)
1354 return WN_BAD_POINTER;
1355 if (!lpBuffer)
1356 return WN_BAD_POINTER;
1357 if (!lpBufferSize)
1358 return WN_BAD_POINTER;
1359 if (!providerTable)
1360 return WN_NO_NETWORK;
1361
1362 cchEntireNetworkLen = lstrlenW(providerTable->entireNetwork) + 1;
1363 bytesNeeded = sizeof(NETRESOURCEW) + cchEntireNetworkLen * sizeof(WCHAR);
1364 if (*lpBufferSize < bytesNeeded)
1365 {
1366 *lpBufferSize = bytesNeeded;
1367 ret = WN_MORE_DATA;
1368 }
1369 else
1370 {
1371 LPNETRESOURCEW lpNet = lpBuffer;
1372
1373 lpNet->dwScope = RESOURCE_GLOBALNET;
1374 lpNet->dwType = enumerator->dwType;
1377 lpNet->lpLocalName = NULL;
1378 lpNet->lpRemoteName = NULL;
1379 lpNet->lpProvider = NULL;
1380 /* odd, but correct: put comment at end of buffer, so it won't get
1381 * overwritten by subsequent calls to a provider's enumResource
1382 */
1383 lpNet->lpComment = (LPWSTR)((LPBYTE)lpBuffer + *lpBufferSize -
1384 (cchEntireNetworkLen * sizeof(WCHAR)));
1386 ret = WN_SUCCESS;
1387 }
1388 if (ret == WN_SUCCESS)
1389 {
1390 DWORD bufferSize = *lpBufferSize - bytesNeeded;
1391
1392 /* "Entire Network" entry enumerated--morph this into a global
1393 * enumerator. enumerator->lpNet continues to be NULL, since it has
1394 * no meaning when the scope isn't RESOURCE_GLOBALNET.
1395 */
1397 ret = _enumerateGlobalW(enumerator, lpcCount,
1398 (LPBYTE)lpBuffer + bytesNeeded, &bufferSize);
1399 if (ret == WN_SUCCESS)
1400 {
1401 /* reflect the fact that we already enumerated "Entire Network" */
1402 (*lpcCount)++;
1403 *lpBufferSize = bufferSize + bytesNeeded;
1404 }
1405 else
1406 {
1407 /* the provider enumeration failed, but we already succeeded in
1408 * enumerating "Entire Network"--leave type as global to allow a
1409 * retry, but indicate success with a count of one.
1410 */
1411 ret = WN_SUCCESS;
1412 *lpcCount = 1;
1413 *lpBufferSize = bytesNeeded;
1414 }
1415 }
1416 TRACE("Returning %d\n", ret);
1417 return ret;
1418}
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
size_t bufferSize
DWORD dwType
Definition: winnetwk.h:178
DWORD dwDisplayType
Definition: winnetwk.h:179
LPWSTR lpComment
Definition: winnetwk.h:183
DWORD dwUsage
Definition: winnetwk.h:180
DWORD dwScope
Definition: winnetwk.h:177
LPWSTR entireNetwork
Definition: wnet.c:74
unsigned char * LPBYTE
Definition: typedefs.h:53
#define RESOURCEDISPLAYTYPE_ROOT
Definition: winnetwk.h:82
#define RESOURCEUSAGE_CONTAINER
Definition: winnetwk.h:69
#define RESOURCE_GLOBALNET
Definition: winnetwk.h:59
static DWORD _enumerateGlobalW(PWNetEnumerator enumerator, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
Definition: wnet.c:1276
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by WNetEnumResourceW().

◆ _enumerateGlobalPassthroughW()

static DWORD _enumerateGlobalPassthroughW ( PWNetEnumerator  enumerator,
LPDWORD  lpcCount,
LPVOID  lpBuffer,
LPDWORD  lpBufferSize 
)
static

Definition at line 1238 of file wnet.c.

1240{
1241 DWORD ret;
1242
1243 if (!enumerator)
1244 return WN_BAD_POINTER;
1245 if (enumerator->enumType != WNET_ENUMERATOR_TYPE_GLOBAL)
1246 return WN_BAD_VALUE;
1247 if (!lpcCount)
1248 return WN_BAD_POINTER;
1249 if (!lpBuffer)
1250 return WN_BAD_POINTER;
1251 if (!lpBufferSize)
1252 return WN_BAD_POINTER;
1253 if (*lpBufferSize < sizeof(NETRESOURCEW))
1254 return WN_MORE_DATA;
1255
1256 ret = _globalEnumeratorAdvance(enumerator);
1257 if (ret == WN_SUCCESS)
1258 {
1259 ret = providerTable->table[enumerator->providerIndex].
1260 openEnum(enumerator->dwScope, enumerator->dwType,
1261 enumerator->dwUsage, enumerator->specific.net,
1262 &enumerator->handle);
1263 if (ret == WN_SUCCESS)
1264 {
1265 ret = providerTable->table[enumerator->providerIndex].
1266 enumResource(enumerator->handle, lpcCount, lpBuffer,
1267 lpBufferSize);
1268 if (ret != WN_MORE_DATA)
1269 enumerator->providerDone = TRUE;
1270 }
1271 }
1272 TRACE("Returning %d\n", ret);
1273 return ret;
1274}
#define TRUE
Definition: types.h:120
NETRESOURCEW * net
Definition: wnet.c:112
DWORD providerIndex
Definition: wnet.c:104
BOOL providerDone
Definition: wnet.c:106
HANDLE handle
Definition: wnet.c:105
static DWORD _globalEnumeratorAdvance(PWNetEnumerator enumerator)
Definition: wnet.c:1194

Referenced by _enumerateGlobalW().

◆ _enumerateGlobalW()

static DWORD _enumerateGlobalW ( PWNetEnumerator  enumerator,
LPDWORD  lpcCount,
LPVOID  lpBuffer,
LPDWORD  lpBufferSize 
)
static

Definition at line 1276 of file wnet.c.

1278{
1279 DWORD ret;
1280
1281 if (!enumerator)
1282 return WN_BAD_POINTER;
1283 if (enumerator->enumType != WNET_ENUMERATOR_TYPE_GLOBAL)
1284 return WN_BAD_VALUE;
1285 if (!lpcCount)
1286 return WN_BAD_POINTER;
1287 if (!lpBuffer)
1288 return WN_BAD_POINTER;
1289 if (!lpBufferSize)
1290 return WN_BAD_POINTER;
1291 if (*lpBufferSize < sizeof(NETRESOURCEW))
1292 return WN_MORE_DATA;
1293 if (!providerTable)
1294 return WN_NO_NETWORK;
1295
1296 switch (enumerator->dwScope)
1297 {
1298 case RESOURCE_GLOBALNET:
1299 if (enumerator->specific.net)
1300 ret = _enumerateGlobalPassthroughW(enumerator, lpcCount,
1301 lpBuffer, lpBufferSize);
1302 else
1303 ret = _enumerateProvidersW(enumerator, lpcCount, lpBuffer,
1304 lpBufferSize);
1305 break;
1306 case RESOURCE_CONTEXT:
1307 ret = _enumerateGlobalPassthroughW(enumerator, lpcCount, lpBuffer,
1308 lpBufferSize);
1309 break;
1310 default:
1311 WARN("unexpected scope 0x%08x\n", enumerator->dwScope);
1313 }
1314 TRACE("Returning %d\n", ret);
1315 return ret;
1316}
#define WARN(fmt,...)
Definition: precomp.h:61
#define RESOURCE_CONTEXT
Definition: winnetwk.h:62
static DWORD _enumerateProvidersW(PWNetEnumerator enumerator, LPDWORD lpcCount, LPVOID lpBuffer, const DWORD *lpBufferSize)
Definition: wnet.c:1118
static DWORD _enumerateGlobalPassthroughW(PWNetEnumerator enumerator, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
Definition: wnet.c:1238

Referenced by _enumerateContextW(), and WNetEnumResourceW().

◆ _enumerateProvidersW()

static DWORD _enumerateProvidersW ( PWNetEnumerator  enumerator,
LPDWORD  lpcCount,
LPVOID  lpBuffer,
const DWORD lpBufferSize 
)
static

Definition at line 1118 of file wnet.c.

1120{
1121 DWORD ret;
1122
1123 if (!enumerator)
1124 return WN_BAD_POINTER;
1125 if (enumerator->enumType != WNET_ENUMERATOR_TYPE_GLOBAL)
1126 return WN_BAD_VALUE;
1127 if (!lpcCount)
1128 return WN_BAD_POINTER;
1129 if (!lpBuffer)
1130 return WN_BAD_POINTER;
1131 if (!lpBufferSize)
1132 return WN_BAD_POINTER;
1133 if (*lpBufferSize < sizeof(NETRESOURCEA))
1134 return WN_MORE_DATA;
1135
1136 if (!providerTable || enumerator->providerIndex >=
1139 else
1140 {
1141 DWORD bytes = 0, count = 0, countLimit, i;
1143 LPWSTR strNext;
1144
1145 countLimit = *lpcCount == -1 ?
1146 providerTable->numProviders - enumerator->providerIndex : *lpcCount;
1147 while (count < countLimit && bytes < *lpBufferSize)
1148 {
1149 DWORD bytesNext = _countProviderBytesW(
1150 &providerTable->table[count + enumerator->providerIndex]);
1151
1152 if (bytes + bytesNext < *lpBufferSize)
1153 {
1154 bytes += bytesNext;
1155 count++;
1156 }
1157 }
1158 strNext = (LPWSTR)((LPBYTE)lpBuffer + count * sizeof(NETRESOURCEW));
1159 for (i = 0, resource = lpBuffer; i < count; i++, resource++)
1160 {
1161 resource->dwScope = RESOURCE_GLOBALNET;
1162 resource->dwType = RESOURCETYPE_ANY;
1163 resource->dwDisplayType = RESOURCEDISPLAYTYPE_NETWORK;
1166 resource->lpLocalName = NULL;
1167 resource->lpRemoteName = strNext;
1168 lstrcpyW(resource->lpRemoteName,
1169 providerTable->table[i + enumerator->providerIndex].name);
1170 strNext += lstrlenW(resource->lpRemoteName) + 1;
1171 resource->lpComment = NULL;
1172 resource->lpProvider = strNext;
1173 lstrcpyW(resource->lpProvider,
1174 providerTable->table[i + enumerator->providerIndex].name);
1175 strNext += lstrlenW(resource->lpProvider) + 1;
1176 }
1177 enumerator->providerIndex += count;
1178 *lpcCount = count;
1179 ret = count > 0 ? WN_SUCCESS : WN_MORE_DATA;
1180 }
1181 TRACE("Returning %d\n", ret);
1182 return ret;
1183}
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define resource
Definition: kernel32.h:9
#define RESOURCEDISPLAYTYPE_NETWORK
Definition: winnetwk.h:81
#define RESOURCEUSAGE_RESERVED
Definition: winnetwk.h:74
#define RESOURCETYPE_ANY
Definition: winnetwk.h:63
static DWORD _countProviderBytesW(PWNetProvider provider)
Definition: wnet.c:1104

Referenced by _enumerateGlobalW().

◆ _enumerateProviderW()

static DWORD _enumerateProviderW ( PWNetEnumerator  enumerator,
LPDWORD  lpcCount,
LPVOID  lpBuffer,
LPDWORD  lpBufferSize 
)
static

Definition at line 1318 of file wnet.c.

1320{
1321 if (!enumerator)
1322 return WN_BAD_POINTER;
1323 if (enumerator->enumType != WNET_ENUMERATOR_TYPE_PROVIDER)
1324 return WN_BAD_VALUE;
1325 if (!enumerator->handle)
1326 return WN_BAD_VALUE;
1327 if (!lpcCount)
1328 return WN_BAD_POINTER;
1329 if (!lpBuffer)
1330 return WN_BAD_POINTER;
1331 if (!lpBufferSize)
1332 return WN_BAD_POINTER;
1333 if (!providerTable)
1334 return WN_NO_NETWORK;
1335 if (enumerator->providerIndex >= providerTable->numProviders)
1336 return WN_NO_MORE_ENTRIES;
1337 if (!providerTable->table[enumerator->providerIndex].enumResource)
1338 return WN_BAD_VALUE;
1339 return providerTable->table[enumerator->providerIndex].enumResource(
1340 enumerator->handle, lpcCount, lpBuffer, lpBufferSize);
1341}

Referenced by WNetEnumResourceW().

◆ _enumeratorRememberedW()

static DWORD _enumeratorRememberedW ( PWNetEnumerator  enumerator,
DWORD user_count,
void user_buffer,
DWORD user_size 
)
static

Definition at line 1561 of file wnet.c.

1563{
1564 HKEY registry, connection;
1565 WCHAR buffer[255];
1566 LONG size_left;
1567 DWORD index, ret, type, len, size, registry_size, full_size = 0, total_count;
1568 NETRESOURCEW * net_buffer = user_buffer;
1569 WCHAR * str, * registry_string;
1570
1571 /* we will do the work in a single loop, so here is some things:
1572 * we write netresource at the begin of the user buffer
1573 * we write strings at the end of the user buffer
1574 */
1575 size_left = *user_size;
1576 total_count = 0;
1577 type = enumerator->dwType;
1578 registry = enumerator->specific.remembered.registry;
1579 str = (WCHAR *)((ULONG_PTR)user_buffer + *user_size - sizeof(WCHAR));
1580 for (index = enumerator->specific.remembered.index; ; ++index)
1581 {
1582 enumerator->specific.remembered.index = index;
1583
1584 if (*user_count != -1 && total_count == *user_count)
1585 {
1586 ret = WN_SUCCESS;
1587 break;
1588 }
1589
1592 if (ret != ERROR_SUCCESS)
1593 {
1595 break;
1596 }
1597
1598 if (RegOpenKeyExW(registry, buffer, 0, KEY_READ, &connection) != ERROR_SUCCESS)
1599 {
1600 continue;
1601 }
1602
1603 full_size = sizeof(NETRESOURCEW);
1604 size_left -= sizeof(NETRESOURCEW);
1605
1606 if (size_left > 0)
1607 {
1608 size = sizeof(DWORD);
1609 RegQueryValueExW(connection, connectionType, NULL, NULL, (BYTE *)&net_buffer->dwType, &size);
1610 if (type != RESOURCETYPE_ANY && net_buffer->dwType != type)
1611 {
1612 size_left += sizeof(NETRESOURCEW);
1613 RegCloseKey(connection);
1614 continue;
1615 }
1616
1617 net_buffer->dwScope = RESOURCE_REMEMBERED;
1619 net_buffer->dwUsage = RESOURCEUSAGE_CONNECTABLE;
1620 }
1621 else
1622 ret = WN_MORE_DATA;
1623
1624 /* FIXME: this only supports drive letters */
1625 full_size += 3 * sizeof(WCHAR);
1626 size_left -= 3 * sizeof(WCHAR);
1627 if (size_left > 0)
1628 {
1629 str -= 3;
1630 str[0] = buffer[0];
1631 str[1] = ':';
1632 str[2] = 0;
1633 net_buffer->lpLocalName = str;
1634 }
1635
1636 registry_size = 0;
1637 registry_string = get_reg_str(connection, providerName, &registry_size);
1638 if (registry_string)
1639 {
1640 full_size += registry_size;
1641 size_left -= registry_size;
1642
1643 if (size_left > 0)
1644 {
1645 str -= (registry_size / sizeof(WCHAR));
1646 lstrcpyW(str, registry_string);
1647 net_buffer->lpProvider = str;
1648 }
1649 else
1650 ret = WN_MORE_DATA;
1651
1652 HeapFree(GetProcessHeap(), 0, registry_string);
1653 }
1654
1655 registry_size = 0;
1656 registry_string = get_reg_str(connection, remotePath, &registry_size);
1657 if (registry_string)
1658 {
1659 full_size += registry_size;
1660 size_left -= registry_size;
1661
1662 if (size_left > 0)
1663 {
1664 str -= (registry_size / sizeof(WCHAR));
1665 lstrcpyW(str, registry_string);
1666 net_buffer->lpRemoteName = str;
1667 }
1668 else
1669 ret = WN_MORE_DATA;
1670
1671 HeapFree(GetProcessHeap(), 0, registry_string);
1672 }
1673
1674 RegCloseKey(connection);
1675
1676 net_buffer->lpComment = NULL;
1677
1678 if (size_left < 0)
1679 break;
1680
1681 ++total_count;
1682 ++net_buffer;
1683 }
1684
1685 if (total_count == 0)
1687
1688 *user_count = total_count;
1689
1691 ret = WN_SUCCESS;
1692
1693 if (ret == WN_MORE_DATA)
1694 *user_size = *user_size + full_size;
1695
1696 return ret;
1697}
#define ARRAY_SIZE(A)
Definition: main.h:33
#define RegCloseKey(hKey)
Definition: registry.h:49
const char ** registry
Definition: cffdrivr.c:690
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define KEY_READ
Definition: nt_native.h:1023
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
const WCHAR * str
struct _WNetEnumerator::@473::@474 remembered
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define RESOURCEUSAGE_CONNECTABLE
Definition: winnetwk.h:68
#define RESOURCEDISPLAYTYPE_GENERIC
Definition: winnetwk.h:75
#define RESOURCE_REMEMBERED
Definition: winnetwk.h:60
static const WCHAR remotePath[]
Definition: wnet.c:1545
static WCHAR * get_reg_str(HKEY hkey, const WCHAR *value, DWORD *len)
Definition: wnet.c:1547
static const WCHAR providerName[]
Definition: wnet.c:1544
static const WCHAR connectionType[]
Definition: wnet.c:1543
unsigned char BYTE
Definition: xxhash.c:193

Referenced by WNetEnumResourceW().

◆ _findProviderIndexW()

static DWORD _findProviderIndexW ( LPCWSTR  lpProvider)
static

Definition at line 509 of file wnet.c.

510{
512
514 {
515 DWORD i;
516
517 for (i = 0; i < providerTable->numProviders &&
519 if (!lstrcmpW(lpProvider, providerTable->table[i].name))
520 ret = i;
521 }
522 return ret;
523}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
#define BAD_PROVIDER_INDEX
Definition: wnet.c:122

Referenced by wnet_use_connection(), WNetGetNetworkInformationW(), and WNetOpenEnumW().

◆ _freeEnumNetResource()

static void _freeEnumNetResource ( LPNETRESOURCEW  lpNet)
static

Definition at line 556 of file wnet.c.

557{
558 if (lpNet)
559 {
561 HeapFree(GetProcessHeap(), 0, lpNet);
562 }
563}

Referenced by WNetCloseEnum().

◆ _globalEnumeratorAdvance()

static DWORD _globalEnumeratorAdvance ( PWNetEnumerator  enumerator)
static

Definition at line 1194 of file wnet.c.

1195{
1196 if (!enumerator)
1197 return WN_BAD_POINTER;
1198 if (enumerator->enumType != WNET_ENUMERATOR_TYPE_GLOBAL)
1199 return WN_BAD_VALUE;
1200 if (!providerTable || enumerator->providerIndex >=
1202 return WN_NO_MORE_ENTRIES;
1203
1204 if (enumerator->providerDone)
1205 {
1206 DWORD dwEnum = 0;
1207 enumerator->providerDone = FALSE;
1208 if (enumerator->handle)
1209 {
1211 enumerator->handle);
1212 enumerator->handle = NULL;
1213 enumerator->providerIndex++;
1214 }
1215 if (enumerator->dwScope == RESOURCE_CONNECTED)
1216 dwEnum = WNNC_ENUM_LOCAL;
1217 else if (enumerator->dwScope == RESOURCE_GLOBALNET)
1218 dwEnum = WNNC_ENUM_GLOBAL;
1219 else if (enumerator->dwScope == RESOURCE_CONTEXT)
1220 dwEnum = WNNC_ENUM_CONTEXT;
1221 for (; enumerator->providerIndex < providerTable->numProviders &&
1223 & dwEnum); enumerator->providerIndex++)
1224 ;
1225 }
1226 return enumerator->providerIndex < providerTable->numProviders ?
1228}
#define FALSE
Definition: types.h:117
#define WNNC_ENUM_CONTEXT
Definition: npapi.h:54
#define WNNC_ENUM_GLOBAL
Definition: npapi.h:52
#define WNNC_ENUM_LOCAL
Definition: npapi.h:53
PF_NPCloseEnum closeEnum
Definition: wnet.c:62
#define RESOURCE_CONNECTED
Definition: winnetwk.h:58

Referenced by _enumerateGlobalPassthroughW().

◆ _thunkNetResourceArrayAToW()

static DWORD _thunkNetResourceArrayAToW ( const NETRESOURCEA lpNetArrayIn,
const DWORD lpcCount,
LPVOID  lpBuffer,
const DWORD lpBufferSize 
)
static

Definition at line 747 of file wnet.c.

749{
750 DWORD i, numToThunk, totalBytes, ret;
751 LPWSTR strNext;
752
753 if (!lpNetArrayIn)
754 return WN_BAD_POINTER;
755 if (!lpcCount)
756 return WN_BAD_POINTER;
757 if (*lpcCount == -1)
758 return WN_BAD_VALUE;
759 if (!lpBuffer)
760 return WN_BAD_POINTER;
761 if (!lpBufferSize)
762 return WN_BAD_POINTER;
763
764 for (i = 0, numToThunk = 0, totalBytes = 0; i < *lpcCount; i++)
765 {
766 const NETRESOURCEA *lpNet = lpNetArrayIn + i;
767
768 totalBytes += sizeof(NETRESOURCEW);
769 if (lpNet->lpLocalName)
770 totalBytes += MultiByteToWideChar(CP_ACP, 0, lpNet->lpLocalName,
771 -1, NULL, 0) * sizeof(WCHAR);
772 if (lpNet->lpRemoteName)
773 totalBytes += MultiByteToWideChar(CP_ACP, 0, lpNet->lpRemoteName,
774 -1, NULL, 0) * sizeof(WCHAR);
775 if (lpNet->lpComment)
776 totalBytes += MultiByteToWideChar(CP_ACP, 0, lpNet->lpComment,
777 -1, NULL, 0) * sizeof(WCHAR);
778 if (lpNet->lpProvider)
779 totalBytes += MultiByteToWideChar(CP_ACP, 0, lpNet->lpProvider,
780 -1, NULL, 0) * sizeof(WCHAR);
781 if (totalBytes < *lpBufferSize)
782 numToThunk = i + 1;
783 }
784 strNext = (LPWSTR)((LPBYTE)lpBuffer + numToThunk * sizeof(NETRESOURCEW));
785 for (i = 0; i < numToThunk; i++)
786 {
788 const NETRESOURCEA *lpNetIn = lpNetArrayIn + i;
789
790 memcpy(lpNetOut, lpNetIn, sizeof(NETRESOURCEW));
791 /* lie about string lengths, we already verified how many
792 * we have space for above
793 */
794 if (lpNetIn->lpLocalName)
795 {
796 lpNetOut->lpLocalName = strNext;
797 strNext += MultiByteToWideChar(CP_ACP, 0, lpNetIn->lpLocalName,
798 -1, lpNetOut->lpLocalName, *lpBufferSize);
799 }
800 if (lpNetIn->lpRemoteName)
801 {
802 lpNetOut->lpRemoteName = strNext;
803 strNext += MultiByteToWideChar(CP_ACP, 0, lpNetIn->lpRemoteName,
804 -1, lpNetOut->lpRemoteName, *lpBufferSize);
805 }
806 if (lpNetIn->lpComment)
807 {
808 lpNetOut->lpComment = strNext;
809 strNext += MultiByteToWideChar(CP_ACP, 0, lpNetIn->lpComment,
810 -1, lpNetOut->lpComment, *lpBufferSize);
811 }
812 if (lpNetIn->lpProvider)
813 {
814 lpNetOut->lpProvider = strNext;
815 strNext += MultiByteToWideChar(CP_ACP, 0, lpNetIn->lpProvider,
816 -1, lpNetOut->lpProvider, *lpBufferSize);
817 }
818 }
819 ret = numToThunk < *lpcCount ? WN_MORE_DATA : WN_SUCCESS;
820 TRACE("numToThunk is %d, *lpcCount is %d, returning %d\n", numToThunk,
821 *lpcCount, ret);
822 return ret;
823}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
LPSTR lpLocalName
Definition: winnetwk.h:171
LPSTR lpComment
Definition: winnetwk.h:173
LPSTR lpProvider
Definition: winnetwk.h:174
LPSTR lpRemoteName
Definition: winnetwk.h:172
struct _NETRESOURCEW * LPNETRESOURCEW

Referenced by WNetGetResourceInformationA(), and WNetOpenEnumA().

◆ _thunkNetResourceArrayWToA()

static DWORD _thunkNetResourceArrayWToA ( const NETRESOURCEW lpNetArrayIn,
const DWORD lpcCount,
LPVOID  lpBuffer,
const DWORD lpBufferSize 
)
static

Definition at line 662 of file wnet.c.

664{
665 DWORD i, numToThunk, totalBytes, ret;
666 LPSTR strNext;
667
668 if (!lpNetArrayIn)
669 return WN_BAD_POINTER;
670 if (!lpcCount)
671 return WN_BAD_POINTER;
672 if (*lpcCount == -1)
673 return WN_BAD_VALUE;
674 if (!lpBuffer)
675 return WN_BAD_POINTER;
676 if (!lpBufferSize)
677 return WN_BAD_POINTER;
678
679 for (i = 0, numToThunk = 0, totalBytes = 0; i < *lpcCount; i++)
680 {
681 const NETRESOURCEW *lpNet = lpNetArrayIn + i;
682
683 totalBytes += sizeof(NETRESOURCEA);
684 if (lpNet->lpLocalName)
685 totalBytes += WideCharToMultiByte(CP_ACP, 0, lpNet->lpLocalName,
686 -1, NULL, 0, NULL, NULL);
687 if (lpNet->lpRemoteName)
688 totalBytes += WideCharToMultiByte(CP_ACP, 0, lpNet->lpRemoteName,
689 -1, NULL, 0, NULL, NULL);
690 if (lpNet->lpComment)
691 totalBytes += WideCharToMultiByte(CP_ACP, 0, lpNet->lpComment,
692 -1, NULL, 0, NULL, NULL);
693 if (lpNet->lpProvider)
694 totalBytes += WideCharToMultiByte(CP_ACP, 0, lpNet->lpProvider,
695 -1, NULL, 0, NULL, NULL);
696 if (totalBytes < *lpBufferSize)
697 numToThunk = i + 1;
698 }
699 strNext = (LPSTR)((LPBYTE)lpBuffer + numToThunk * sizeof(NETRESOURCEA));
700 for (i = 0; i < numToThunk; i++)
701 {
703 const NETRESOURCEW *lpNetIn = lpNetArrayIn + i;
704
705 memcpy(lpNetOut, lpNetIn, sizeof(NETRESOURCEA));
706 /* lie about string lengths, we already verified how many
707 * we have space for above
708 */
709 if (lpNetIn->lpLocalName)
710 {
711 lpNetOut->lpLocalName = strNext;
712 strNext += WideCharToMultiByte(CP_ACP, 0, lpNetIn->lpLocalName, -1,
713 lpNetOut->lpLocalName, *lpBufferSize, NULL, NULL);
714 }
715 if (lpNetIn->lpRemoteName)
716 {
717 lpNetOut->lpRemoteName = strNext;
718 strNext += WideCharToMultiByte(CP_ACP, 0, lpNetIn->lpRemoteName, -1,
719 lpNetOut->lpRemoteName, *lpBufferSize, NULL, NULL);
720 }
721 if (lpNetIn->lpComment)
722 {
723 lpNetOut->lpComment = strNext;
724 strNext += WideCharToMultiByte(CP_ACP, 0, lpNetIn->lpComment, -1,
725 lpNetOut->lpComment, *lpBufferSize, NULL, NULL);
726 }
727 if (lpNetIn->lpProvider)
728 {
729 lpNetOut->lpProvider = strNext;
730 strNext += WideCharToMultiByte(CP_ACP, 0, lpNetIn->lpProvider, -1,
731 lpNetOut->lpProvider, *lpBufferSize, NULL, NULL);
732 }
733 }
734 ret = numToThunk < *lpcCount ? WN_MORE_DATA : WN_SUCCESS;
735 TRACE("numToThunk is %d, *lpcCount is %d, returning %d\n", numToThunk,
736 *lpcCount, ret);
737 return ret;
738}
#define WideCharToMultiByte
Definition: compat.h:111
struct _NETRESOURCEA * LPNETRESOURCEA
struct _NETRESOURCEA NETRESOURCEA
char * LPSTR
Definition: xmlstorage.h:182

Referenced by WNetEnumResourceA(), and WNetGetResourceInformationA().

◆ _tryLoadProvider()

static void _tryLoadProvider ( PCWSTR  provider)
static

Definition at line 135 of file wnet.c.

136{
137 static const WCHAR servicePrefix[] = { 'S','y','s','t','e','m','\\',
138 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
139 'S','e','r','v','i','c','e','s','\\',0 };
140 static const WCHAR serviceFmt[] = { '%','s','%','s','\\',
141 'N','e','t','w','o','r','k','P','r','o','v','i','d','e','r',0 };
143 HKEY hKey;
144
145 TRACE("%s\n", debugstr_w(provider));
146 swprintf(serviceName, serviceFmt, servicePrefix, provider);
150 {
151 static const WCHAR szProviderPath[] = { 'P','r','o','v','i','d','e','r',
152 'P','a','t','h',0 };
153 WCHAR providerPath[MAX_PATH];
154 DWORD type, size = sizeof(providerPath);
155
156 if (RegQueryValueExW(hKey, szProviderPath, NULL, &type,
157 (LPBYTE)providerPath, &size) == ERROR_SUCCESS && (type == REG_SZ || type == REG_EXPAND_SZ))
158 {
159 static const WCHAR szProviderName[] = { 'N','a','m','e',0 };
160 PWSTR name = NULL;
161
162 if (type == REG_EXPAND_SZ)
163 {
165 if (ExpandEnvironmentStringsW(providerPath, path, MAX_PATH)) lstrcpyW( providerPath, path );
166 }
167
168 size = 0;
169 RegQueryValueExW(hKey, szProviderName, NULL, NULL, NULL, &size);
170 if (size)
171 {
173 if (RegQueryValueExW(hKey, szProviderName, NULL, &type,
175 {
177 name = NULL;
178 }
179 }
180 if (name)
181 {
182 HMODULE hLib = LoadLibraryW(providerPath);
183
184 if (hLib)
185 {
186#define MPR_GETPROC(proc) ((PF_##proc)GetProcAddress(hLib, #proc))
187
189
190 TRACE("loaded lib %p\n", hLib);
191 if (getCaps)
192 {
193 DWORD connectCap;
194 PWNetProvider provider =
196
197 provider->hLib = hLib;
198 provider->name = name;
199 TRACE("name is %s\n", debugstr_w(name));
200 provider->getCaps = getCaps;
201 provider->dwSpecVersion = getCaps(WNNC_SPEC_VERSION);
202 provider->dwNetType = getCaps(WNNC_NET_TYPE);
203 TRACE("net type is 0x%08x\n", provider->dwNetType);
204 provider->dwEnumScopes = getCaps(WNNC_ENUMERATION);
205 if (provider->dwEnumScopes)
206 {
207 TRACE("supports enumeration\n");
208 provider->openEnum = MPR_GETPROC(NPOpenEnum);
209 TRACE("NPOpenEnum %p\n", provider->openEnum);
211 TRACE("NPEnumResource %p\n", provider->enumResource);
212 provider->closeEnum = MPR_GETPROC(NPCloseEnum);
213 TRACE("NPCloseEnum %p\n", provider->closeEnum);
215 TRACE("NPGetResourceInformation %p\n", provider->getResourceInformation);
216 if (!provider->openEnum ||
217 !provider->enumResource ||
218 !provider->closeEnum)
219 {
220 provider->openEnum = NULL;
221 provider->enumResource = NULL;
222 provider->closeEnum = NULL;
223 provider->dwEnumScopes = 0;
224 WARN("Couldn't load enumeration functions\n");
225 }
226 }
227 connectCap = getCaps(WNNC_CONNECTION);
228 if (connectCap & WNNC_CON_ADDCONNECTION)
230 if (connectCap & WNNC_CON_ADDCONNECTION3)
232 if (connectCap & WNNC_CON_CANCELCONNECTION)
234#ifdef __REACTOS__
235 if (connectCap & WNNC_CON_GETCONNECTIONS)
236 provider->getConnection = MPR_GETPROC(NPGetConnection);
237#endif
238 TRACE("NPAddConnection %p\n", provider->addConnection);
239 TRACE("NPAddConnection3 %p\n", provider->addConnection3);
240 TRACE("NPCancelConnection %p\n", provider->cancelConnection);
242 }
243 else
244 {
245 WARN("Provider %s didn't export NPGetCaps\n",
246 debugstr_w(provider));
248 FreeLibrary(hLib);
249 }
250
251#undef MPR_GETPROC
252 }
253 else
254 {
255 WARN("Couldn't load library %s for provider %s\n",
256 debugstr_w(providerPath), debugstr_w(provider));
258 }
259 }
260 else
261 {
262 WARN("Couldn't get provider name for provider %s\n",
263 debugstr_w(provider));
264 }
265 }
266 else
267 WARN("Couldn't open value %s\n", debugstr_w(szProviderPath));
269 }
270 else
271 WARN("Couldn't open service key for provider %s\n",
272 debugstr_w(provider));
273}
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
#define LoadLibraryW(x)
Definition: compat.h:747
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
#define swprintf
Definition: precomp.h:40
FxAutoRegKey hKey
#define debugstr_w
Definition: kernel32.h:32
#define REG_SZ
Definition: layer.c:22
DWORD APIENTRY NPEnumResource(HANDLE hEnum, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
Definition: nfs41_np.c:773
DWORD APIENTRY NPGetCaps(DWORD nIndex)
Definition: nfs41_np.c:329
DWORD APIENTRY NPCloseEnum(HANDLE hEnum)
Definition: nfs41_np.c:881
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 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_NET_TYPE
Definition: npapi.h:24
#define WNNC_CON_GETCONNECTIONS
Definition: npapi.h:35
DWORD(APIENTRY * PF_NPGetCaps)(DWORD ndex)
Definition: npapi.h:59
#define WNNC_CON_CANCELCONNECTION
Definition: npapi.h:34
#define WNNC_CONNECTION
Definition: npapi.h:32
#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_ENUMERATION
Definition: npapi.h:51
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
PF_NPAddConnection3 addConnection3
Definition: wnet.c:65
PF_NPCancelConnection cancelConnection
Definition: wnet.c:66
DWORD dwNetType
Definition: wnet.c:58
PF_NPGetResourceInformation getResourceInformation
Definition: wnet.c:63
PF_NPAddConnection addConnection
Definition: wnet.c:64
DWORD dwSpecVersion
Definition: wnet.c:57
HMODULE hLib
Definition: wnet.c:54
PF_NPGetCaps getCaps
Definition: wnet.c:56
Definition: name.c:39
char serviceName[]
Definition: tftpd.cpp:34
uint16_t * PWSTR
Definition: typedefs.h:56
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define MPR_GETPROC(proc)

Referenced by wnetInit().

◆ free_netresourceW()

static void free_netresourceW ( NETRESOURCEW resource)
static

Definition at line 2340 of file wnet.c.

2341{
2342 HeapFree(GetProcessHeap(), 0, resource->lpLocalName);
2343 HeapFree(GetProcessHeap(), 0, resource->lpRemoteName);
2344 HeapFree(GetProcessHeap(), 0, resource->lpComment);
2345 HeapFree(GetProcessHeap(), 0, resource->lpProvider);
2346}

Referenced by WNetUseConnectionA().

◆ get_drive_connection()

static DWORD get_drive_connection ( WCHAR  letter,
LPWSTR  remote,
LPDWORD  size 
)
static

Definition at line 2583 of file wnet.c.

2584{
2585#ifndef __REACTOS__
2586 char buffer[1024];
2587 struct mountmgr_unix_drive *data = (struct mountmgr_unix_drive *)buffer;
2588 HANDLE mgr;
2590 DWORD bytes_returned;
2591
2594 0, 0 )) == INVALID_HANDLE_VALUE)
2595 {
2596 ERR( "failed to open mount manager err %u\n", GetLastError() );
2597 return ret;
2598 }
2599 memset( data, 0, sizeof(*data) );
2600 data->letter = letter;
2601 if (DeviceIoControl( mgr, IOCTL_MOUNTMGR_QUERY_UNIX_DRIVE, data, sizeof(*data),
2602 data, sizeof(buffer), &bytes_returned, NULL ))
2603 {
2604 char *p, *mount_point = buffer + data->mount_point_offset;
2605 DWORD len;
2606
2607 if (data->mount_point_offset && !strncmp( mount_point, "unc/", 4 ))
2608 {
2609 mount_point += 2;
2610 mount_point[0] = '\\';
2611 for (p = mount_point; *p; p++) if (*p == '/') *p = '\\';
2612
2613 len = MultiByteToWideChar( CP_UNIXCP, 0, mount_point, -1, NULL, 0 );
2614 if (len > *size)
2615 {
2616 *size = len;
2617 ret = WN_MORE_DATA;
2618 }
2619 else
2620 {
2621 *size = MultiByteToWideChar( CP_UNIXCP, 0, mount_point, -1, remote, *size);
2622 ret = WN_SUCCESS;
2623 }
2624 }
2625 }
2626 CloseHandle( mgr );
2627 return ret;
2628#else
2630 DWORD index;
2631 WCHAR local[3] = {letter, ':', 0};
2632
2633 if (providerTable != NULL)
2634 {
2635 for (index = 0; index < providerTable->numProviders; index++)
2636 {
2639 {
2640 if (providerTable->table[index].getConnection)
2641 ret = providerTable->table[index].getConnection(
2642 local, remote, size);
2643 else
2645 if (ret == WN_SUCCESS || ret == WN_MORE_DATA)
2646 break;
2647 }
2648 }
2649 }
2650 if (ret)
2652 return ret;
2653#endif
2654}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define ERR(fmt,...)
Definition: precomp.h:57
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 CloseHandle
Definition: compat.h:739
#define CP_UNIXCP
Definition: compat.h:79
#define OPEN_EXISTING
Definition: compat.h:775
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLfloat GLfloat p
Definition: glext.h:8902
#define MOUNTMGR_DOS_DEVICE_NAME
Definition: mountmgr.h:37
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
#define memset(x, y, z)
Definition: compat.h:39
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WN_NOT_CONNECTED
Definition: winnetwk.h:132

Referenced by WNetGetConnectionW().

◆ get_reg_str()

static WCHAR * get_reg_str ( HKEY  hkey,
const WCHAR value,
DWORD len 
)
static

Definition at line 1547 of file wnet.c.

1548{
1549 DWORD type;
1550 WCHAR *ret = NULL;
1551
1552 if (!RegQueryValueExW(hkey, value, NULL, &type, NULL, len) && type == REG_SZ)
1553 {
1554 if (!(ret = HeapAlloc(GetProcessHeap(), 0, *len))) return NULL;
1555 RegQueryValueExW(hkey, value, 0, 0, (BYTE *)ret, len);
1556 }
1557
1558 return ret;
1559}
Definition: pdh_main.c:94

Referenced by _enumeratorRememberedW().

◆ netresource_a_to_w()

static void netresource_a_to_w ( NETRESOURCEA resourceA,
NETRESOURCEW resourceW 
)
static

Definition at line 2328 of file wnet.c.

2329{
2330 resourceW->dwScope = resourceA->dwScope;
2331 resourceW->dwType = resourceA->dwType;
2332 resourceW->dwDisplayType = resourceA->dwDisplayType;
2333 resourceW->dwUsage = resourceA->dwUsage;
2334 resourceW->lpLocalName = strdupAtoW(resourceA->lpLocalName);
2335 resourceW->lpRemoteName = strdupAtoW(resourceA->lpRemoteName);
2336 resourceW->lpComment = strdupAtoW(resourceA->lpComment);
2337 resourceW->lpProvider = strdupAtoW(resourceA->lpProvider);
2338}
DWORD dwDisplayType
Definition: winnetwk.h:169
DWORD dwScope
Definition: winnetwk.h:167
DWORD dwUsage
Definition: winnetwk.h:170
DWORD dwType
Definition: winnetwk.h:168
static LPWSTR strdupAtoW(LPCSTR str)
Definition: wnet.c:2316

Referenced by WNetUseConnectionA().

◆ strdupAtoW()

static LPWSTR strdupAtoW ( LPCSTR  str)
static

Definition at line 2316 of file wnet.c.

2317{
2318 LPWSTR ret;
2319 INT len;
2320
2321 if (!str) return NULL;
2322 len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
2323 ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
2324 if (ret) MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
2325 return ret;
2326}
int32_t INT
Definition: typedefs.h:58

Referenced by netresource_a_to_w(), WNetCancelConnection2A(), and WNetUseConnectionA().

◆ use_connection_pre_set_accessnameA()

static DWORD use_connection_pre_set_accessnameA ( struct use_connection_context ctxt,
WCHAR local_name 
)
static

Definition at line 2280 of file wnet.c.

2281{
2282 if (ctxt->accessname && ctxt->buffer_size && *ctxt->buffer_size)
2283 {
2284 DWORD len;
2285
2286 if (local_name)
2287 len = WideCharToMultiByte(CP_ACP, 0, local_name, -1, NULL, 0, NULL, NULL) - 1;
2288 else
2289 len = strlen(ctxt->resourceA->lpRemoteName);
2290
2291 if (++len > *ctxt->buffer_size)
2292 {
2293 *ctxt->buffer_size = len;
2294 return ERROR_MORE_DATA;
2295 }
2296 }
2297 else
2298 ctxt->accessname = NULL;
2299
2300 return ERROR_SUCCESS;
2301}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ERROR_MORE_DATA
Definition: dderror.h:13
static BSTR local_name(call_frame_t *frame, int ref)
Definition: engine.c:187
DWORD * buffer_size
Definition: wnet.c:2087
NETRESOURCEA * resourceA
Definition: wnet.c:2082

Referenced by WNetUseConnectionA().

◆ use_connection_pre_set_accessnameW()

static DWORD use_connection_pre_set_accessnameW ( struct use_connection_context ctxt,
WCHAR local_name 
)
static

Definition at line 2093 of file wnet.c.

2094{
2095 if (ctxt->accessname && ctxt->buffer_size && *ctxt->buffer_size)
2096 {
2097 DWORD len;
2098
2099 if (local_name)
2101 else
2103
2104 if (++len > *ctxt->buffer_size)
2105 {
2106 *ctxt->buffer_size = len;
2107 return ERROR_MORE_DATA;
2108 }
2109 }
2110 else
2111 ctxt->accessname = NULL;
2112
2113 return ERROR_SUCCESS;
2114}
NETRESOURCEW * resource
Definition: wnet.c:2081

Referenced by WNetUseConnectionW().

◆ use_connection_set_accessnameA()

static void use_connection_set_accessnameA ( struct use_connection_context ctxt,
WCHAR local_name 
)
static

Definition at line 2303 of file wnet.c.

2304{
2305 char *accessname = ctxt->accessname;
2306 if (local_name)
2307 {
2308 WideCharToMultiByte(CP_ACP, 0, local_name, -1, accessname, *ctxt->buffer_size, NULL, NULL);
2309 if (ctxt->result)
2310 *ctxt->result = CONNECT_LOCALDRIVE;
2311 }
2312 else
2313 strcpy(accessname, ctxt->resourceA->lpRemoteName);
2314}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define CONNECT_LOCALDRIVE
Definition: winnetwk.h:95

Referenced by WNetUseConnectionA().

◆ use_connection_set_accessnameW()

static void use_connection_set_accessnameW ( struct use_connection_context ctxt,
WCHAR local_name 
)
static

Definition at line 2116 of file wnet.c.

2117{
2118 WCHAR *accessname = ctxt->accessname;
2119 if (local_name)
2120 {
2121 lstrcpyW(accessname, local_name);
2122 if (ctxt->result)
2123 *ctxt->result = CONNECT_LOCALDRIVE;
2124 }
2125 else
2126 lstrcpyW(accessname, ctxt->resource->lpRemoteName);
2127}

Referenced by WNetUseConnectionW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( mpr  )

◆ wnet_use_connection()

static DWORD wnet_use_connection ( struct use_connection_context ctxt)
static

Definition at line 2158 of file wnet.c.

2159{
2160 WNetProvider *provider = NULL;
2162 BOOL redirect = FALSE;
2163 WCHAR letter[3] = {'Z', ':', 0};
2164 NETRESOURCEW netres;
2165
2167 return WN_NO_NETWORK;
2168
2169 if (!ctxt->resource)
2171 netres = *ctxt->resource;
2172
2173 if (!netres.lpLocalName && (ctxt->flags & CONNECT_REDIRECT))
2174 {
2175 if (netres.dwType != RESOURCETYPE_DISK && netres.dwType != RESOURCETYPE_PRINT)
2176 return ERROR_BAD_DEV_TYPE;
2177
2178 if (netres.dwType == RESOURCETYPE_PRINT)
2179 {
2180 FIXME("Local device selection is not implemented for printers.\n");
2181 return WN_NO_NETWORK;
2182 }
2183
2184 redirect = TRUE;
2185 netres.lpLocalName = letter;
2186 }
2187
2188 if (ctxt->flags & CONNECT_INTERACTIVE)
2189 return ERROR_BAD_NET_NAME;
2190
2191 if ((ret = ctxt->pre_set_accessname(ctxt, netres.lpLocalName)))
2192 return ret;
2193
2194 if (netres.lpProvider)
2195 {
2198 return ERROR_BAD_PROVIDER;
2199
2200 provider = &providerTable->table[index];
2201 ret = wnet_use_provider(ctxt, &netres, provider, redirect);
2202 }
2203 else
2204 {
2205 for (index = 0; index < providerTable->numProviders; index++)
2206 {
2207 provider = &providerTable->table[index];
2208 ret = wnet_use_provider(ctxt, &netres, provider, redirect);
2210 break;
2211 }
2212 }
2213
2214 if (ret == WN_SUCCESS && ctxt->flags & CONNECT_UPDATE_PROFILE)
2215 {
2216 HKEY user_profile;
2217
2218 if (netres.dwType == RESOURCETYPE_PRINT)
2219 {
2220 FIXME("Persistent connection are not supported for printers\n");
2221 return ret;
2222 }
2223
2224 if (RegOpenCurrentUser(KEY_ALL_ACCESS, &user_profile) == ERROR_SUCCESS)
2225 {
2226 HKEY network;
2227 WCHAR subkey[10] = {'N', 'e', 't', 'w', 'o', 'r', 'k', '\\', netres.lpLocalName[0], 0};
2228
2229 if (RegCreateKeyExW(user_profile, subkey, 0, NULL, REG_OPTION_NON_VOLATILE,
2231 {
2232 DWORD dword_arg = RESOURCETYPE_DISK;
2233 DWORD len = (lstrlenW(provider->name) + 1) * sizeof(WCHAR);
2234 static const WCHAR empty[1] = {0};
2235
2236 RegSetValueExW(network, connectionType, 0, REG_DWORD, (const BYTE *)&dword_arg, sizeof(DWORD));
2237 RegSetValueExW(network, providerName, 0, REG_SZ, (const BYTE *)provider->name, len);
2238 RegSetValueExW(network, providerType, 0, REG_DWORD, (const BYTE *)&provider->dwNetType, sizeof(DWORD));
2239 len = (lstrlenW(netres.lpRemoteName) + 1) * sizeof(WCHAR);
2241 len = sizeof(empty);
2244 }
2245
2246 RegCloseKey(user_profile);
2247 }
2248 }
2249
2250 return ret;
2251}
#define FIXME(fmt,...)
Definition: precomp.h:53
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
Definition: reg.c:3209
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
static const WCHAR empty[]
Definition: main.c:47
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
unsigned int BOOL
Definition: ntddk_ex.h:94
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define REG_DWORD
Definition: sdbapi.c:596
DWORD(* pre_set_accessname)(struct use_connection_context *, WCHAR *)
Definition: wnet.c:2089
data1 network
Definition: tftpd.cpp:49
#define ERROR_BAD_DEV_TYPE
Definition: winerror.h:158
#define ERROR_BAD_PROVIDER
Definition: winerror.h:707
#define ERROR_BAD_NET_NAME
Definition: winerror.h:159
#define CONNECT_INTERACTIVE
Definition: winnetwk.h:90
#define CONNECT_REDIRECT
Definition: winnetwk.h:94
#define WN_ALREADY_CONNECTED
Definition: winnetwk.h:137
#define CONNECT_UPDATE_PROFILE
Definition: winnetwk.h:87
#define RESOURCETYPE_DISK
Definition: winnetwk.h:64
#define RESOURCETYPE_PRINT
Definition: winnetwk.h:65
static DWORD wnet_use_provider(struct use_connection_context *ctxt, NETRESOURCEW *netres, WNetProvider *provider, BOOLEAN redirect)
Definition: wnet.c:2129
static const WCHAR userName[]
Definition: wnet.c:2156
static const WCHAR providerType[]
Definition: wnet.c:2155
static DWORD _findProviderIndexW(LPCWSTR lpProvider)
Definition: wnet.c:509

Referenced by WNetUseConnectionA(), and WNetUseConnectionW().

◆ wnet_use_provider()

static DWORD wnet_use_provider ( struct use_connection_context ctxt,
NETRESOURCEW netres,
WNetProvider provider,
BOOLEAN  redirect 
)
static

Definition at line 2129 of file wnet.c.

2130{
2131 DWORD caps, ret;
2132
2133 caps = provider->getCaps(WNNC_CONNECTION);
2135 return ERROR_BAD_PROVIDER;
2136
2138 do
2139 {
2140 if ((caps & WNNC_CON_ADDCONNECTION3) && provider->addConnection3)
2141 ret = provider->addConnection3(ctxt->hwndOwner, netres, ctxt->password, ctxt->userid, ctxt->flags);
2142 else if ((caps & WNNC_CON_ADDCONNECTION) && provider->addConnection)
2143 ret = provider->addConnection(netres, ctxt->password, ctxt->userid);
2144
2145 if (ret == WN_ALREADY_CONNECTED && redirect)
2146 netres->lpLocalName[0] -= 1;
2147 } while (redirect && ret == WN_ALREADY_CONNECTED && netres->lpLocalName[0] >= 'C');
2148
2149 if (ret == WN_SUCCESS && ctxt->accessname)
2150 ctxt->set_accessname(ctxt, netres->lpLocalName);
2151
2152 return ret;
2153}
void(* set_accessname)(struct use_connection_context *, WCHAR *)
Definition: wnet.c:2090
#define WN_ACCESS_DENIED
Definition: winnetwk.h:122

Referenced by wnet_use_connection().

◆ WNetAddConnection2A()

DWORD WINAPI WNetAddConnection2A ( LPNETRESOURCEA  lpNetResource,
LPCSTR  lpPassword,
LPCSTR  lpUserID,
DWORD  dwFlags 
)

Definition at line 2037 of file wnet.c.

2040{
2041 return WNetUseConnectionA(NULL, lpNetResource, lpPassword, lpUserID, dwFlags,
2042 NULL, 0, NULL);
2043}
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
DWORD WINAPI WNetUseConnectionA(HWND hwndOwner, NETRESOURCEA *resource, LPCSTR password, LPCSTR userid, DWORD flags, LPSTR accessname, DWORD *buffer_size, DWORD *result)
Definition: wnet.c:2351

◆ WNetAddConnection2W()

DWORD WINAPI WNetAddConnection2W ( LPNETRESOURCEW  lpNetResource,
LPCWSTR  lpPassword,
LPCWSTR  lpUserID,
DWORD  dwFlags 
)

Definition at line 2048 of file wnet.c.

2051{
2052 return WNetUseConnectionW(NULL, lpNetResource, lpPassword, lpUserID, dwFlags,
2053 NULL, 0, NULL);
2054}
DWORD WINAPI WNetUseConnectionW(HWND hwndOwner, NETRESOURCEW *resource, LPCWSTR password, LPCWSTR userid, DWORD flags, LPWSTR accessname, DWORD *buffer_size, DWORD *result)
Definition: wnet.c:2256

◆ WNetAddConnection3A()

DWORD WINAPI WNetAddConnection3A ( HWND  hwndOwner,
LPNETRESOURCEA  lpNetResource,
LPCSTR  lpPassword,
LPCSTR  lpUserID,
DWORD  dwFlags 
)

Definition at line 2059 of file wnet.c.

2062{
2063 return WNetUseConnectionA(hwndOwner, lpNetResource, lpPassword, lpUserID,
2064 dwFlags, NULL, 0, NULL);
2065}

◆ WNetAddConnection3W()

DWORD WINAPI WNetAddConnection3W ( HWND  hwndOwner,
LPNETRESOURCEW  lpNetResource,
LPCWSTR  lpPassword,
LPCWSTR  lpUserID,
DWORD  dwFlags 
)

Definition at line 2070 of file wnet.c.

2073{
2074 return WNetUseConnectionW(hwndOwner, lpNetResource, lpPassword, lpUserID,
2075 dwFlags, NULL, 0, NULL);
2076}

◆ WNetAddConnectionA()

DWORD WINAPI WNetAddConnectionA ( LPCSTR  lpRemoteName,
LPCSTR  lpPassword,
LPCSTR  lpLocalName 
)

Definition at line 2009 of file wnet.c.

2011{
2012 NETRESOURCEA resourcesA;
2013
2014 memset(&resourcesA, 0, sizeof(resourcesA));
2015 resourcesA.lpRemoteName = (LPSTR)lpRemoteName;
2016 resourcesA.lpLocalName = (LPSTR)lpLocalName;
2017 return WNetUseConnectionA(NULL, &resourcesA, lpPassword, NULL, 0, NULL, 0, NULL);
2018}

◆ WNetAddConnectionW()

DWORD WINAPI WNetAddConnectionW ( LPCWSTR  lpRemoteName,
LPCWSTR  lpPassword,
LPCWSTR  lpLocalName 
)

Definition at line 2023 of file wnet.c.

2025{
2026 NETRESOURCEW resourcesW;
2027
2028 memset(&resourcesW, 0, sizeof(resourcesW));
2029 resourcesW.lpRemoteName = (LPWSTR)lpRemoteName;
2030 resourcesW.lpLocalName = (LPWSTR)lpLocalName;
2031 return WNetUseConnectionW(NULL, &resourcesW, lpPassword, NULL, 0, NULL, 0, NULL);
2032}

◆ WNetCancelConnection2A()

DWORD WINAPI WNetCancelConnection2A ( LPCSTR  lpName,
DWORD  dwFlags,
BOOL  fForce 
)

Definition at line 2404 of file wnet.c.

2405{
2406 DWORD ret;
2408 if (!name)
2409 return ERROR_NOT_CONNECTED;
2410
2413
2414 return ret;
2415}
_In_ LPCSTR lpName
Definition: winbase.h:2789
#define ERROR_NOT_CONNECTED
Definition: winerror.h:1201
DWORD WINAPI WNetCancelConnection2W(LPCWSTR lpName, DWORD dwFlags, BOOL fForce)
Definition: wnet.c:2420

Referenced by WNetCancelConnectionA().

◆ WNetCancelConnection2W()

DWORD WINAPI WNetCancelConnection2W ( LPCWSTR  lpName,
DWORD  dwFlags,
BOOL  fForce 
)

Definition at line 2420 of file wnet.c.

2421{
2423 DWORD index;
2424
2425 if (providerTable != NULL)
2426 {
2427 for (index = 0; index < providerTable->numProviders; index++)
2428 {
2431 {
2434 else
2436 if (ret == WN_SUCCESS || ret == WN_OPEN_FILES)
2437 break;
2438 }
2439 }
2440 }
2441
2443 {
2444 HKEY user_profile;
2445
2446 /* FIXME: Only remove it if that's a drive letter */
2447 if (iswalpha(lpName[0]) && lpName[1] == ':' &&
2449 {
2450 WCHAR subkey[10] = {'N', 'e', 't', 'w', 'o', 'r', 'k', '\\', lpName[0], 0};
2451
2452 RegDeleteKeyW(user_profile, subkey);
2453
2454 RegCloseKey(user_profile);
2455 }
2456 }
2457
2458 return ret;
2459}
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
#define iswalpha(_c)
Definition: ctype.h:664
#define WN_OPEN_FILES
Definition: winnetwk.h:133

Referenced by DrivesContextMenuCallback(), WNetCancelConnection2A(), WNetCancelConnectionW(), and WNetClearConnections().

◆ WNetCancelConnectionA()

DWORD WINAPI WNetCancelConnectionA ( LPCSTR  lpName,
BOOL  fForce 
)

Definition at line 2388 of file wnet.c.

2389{
2390 return WNetCancelConnection2A(lpName, 0, fForce);
2391}
DWORD WINAPI WNetCancelConnection2A(LPCSTR lpName, DWORD dwFlags, BOOL fForce)
Definition: wnet.c:2404

Referenced by test_WNetUseConnection().

◆ WNetCancelConnectionW()

DWORD WINAPI WNetCancelConnectionW ( LPCWSTR  lpName,
BOOL  fForce 
)

Definition at line 2396 of file wnet.c.

2397{
2398 return WNetCancelConnection2W(lpName, 0, fForce);
2399}

◆ WNetClearConnections()

DWORD WINAPI WNetClearConnections ( HWND  owner)

Definition at line 2827 of file wnet.c.

2828{
2830 PWSTR connection;
2831 DWORD ret, size, count;
2832 NETRESOURCEW * resources, * iter;
2833
2835 if (ret != WN_SUCCESS)
2836 {
2837 if (ret != WN_NO_NETWORK)
2838 {
2839 return ret;
2840 }
2841
2842 /* Means no provider, then, clearing is OK */
2843 return WN_SUCCESS;
2844 }
2845
2846 size = 0x1000;
2848 if (!resources)
2849 {
2851 return WN_OUT_OF_MEMORY;
2852 }
2853
2854 for (;;)
2855 {
2856 size = 0x1000;
2857 count = -1;
2858
2859 memset(resources, 0, size);
2861 if (ret == WN_SUCCESS || ret == WN_MORE_DATA)
2862 {
2863 for (iter = resources; count; count--, iter++)
2864 {
2865 if (iter->lpLocalName && iter->lpLocalName[0])
2866 connection = iter->lpLocalName;
2867 else
2868 connection = iter->lpRemoteName;
2869
2870 WNetCancelConnection2W(connection, 0, TRUE);
2871 }
2872 }
2873 else
2874 break;
2875 }
2876
2879
2880 return ret;
2881}
int connected
Definition: main.c:61
FxCmResList * resources
#define WN_OUT_OF_MEMORY
Definition: winnetwk.h:125
DWORD WINAPI WNetEnumResourceW(HANDLE hEnum, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
Definition: wnet.c:1702
DWORD WINAPI WNetCloseEnum(HANDLE hEnum)
Definition: wnet.c:1762
DWORD WINAPI WNetOpenEnumW(DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCEW lpNet, LPHANDLE lphEnum)
Definition: wnet.c:922

Referenced by LogoffShutdownThread().

◆ WNetCloseEnum()

DWORD WINAPI WNetCloseEnum ( HANDLE  hEnum)

Definition at line 1762 of file wnet.c.

1763{
1764 DWORD ret, index;
1765 HANDLE *handles;
1766
1767 TRACE( "(%p)\n", hEnum );
1768
1769 if (hEnum)
1770 {
1771 PWNetEnumerator enumerator = (PWNetEnumerator)hEnum;
1772
1773 switch (enumerator->enumType)
1774 {
1776 if (enumerator->specific.net)
1777 _freeEnumNetResource(enumerator->specific.net);
1778 if (enumerator->handle)
1779 providerTable->table[enumerator->providerIndex].
1780 closeEnum(enumerator->handle);
1781 ret = WN_SUCCESS;
1782 break;
1784 if (enumerator->handle)
1785 providerTable->table[enumerator->providerIndex].
1786 closeEnum(enumerator->handle);
1787 ret = WN_SUCCESS;
1788 break;
1790 handles = enumerator->specific.handles;
1791 for (index = 0; index < providerTable->numProviders; index++)
1792 {
1795 }
1797 ret = WN_SUCCESS;
1798 break;
1800 RegCloseKey(enumerator->specific.remembered.registry);
1801 ret = WN_SUCCESS;
1802 break;
1803 default:
1804 WARN("bogus enumerator type!\n");
1806 }
1807 HeapFree(GetProcessHeap(), 0, hEnum);
1808 }
1809 else
1811 if (ret)
1813 TRACE("Returning %d\n", ret);
1814 return ret;
1815}
#define WN_BAD_HANDLE
Definition: winnetwk.h:129
static void _freeEnumNetResource(LPNETRESOURCEW lpNet)
Definition: wnet.c:556
struct _WNetEnumerator * PWNetEnumerator

Referenced by EnumerateConnectedDrives(), EnumerateConnections(), CNetFolderEnum::EnumerateRec(), np_enum(), RestoreAllConnections(), and WNetClearConnections().

◆ WNetConnectionDialog()

DWORD WINAPI WNetConnectionDialog ( HWND  hwnd,
DWORD  dwType 
)

Definition at line 2913 of file wnet.c.

2914{
2915 CONNECTDLGSTRUCTW conn_dlg;
2916 NETRESOURCEW net_res;
2917
2918 ZeroMemory(&conn_dlg, sizeof(conn_dlg));
2919 ZeroMemory(&net_res, sizeof(net_res));
2920
2921 conn_dlg.cbStructure = sizeof(conn_dlg);
2922 conn_dlg.lpConnRes = &net_res;
2923 conn_dlg.hwndOwner = hwnd;
2924 net_res.dwType = dwType;
2925
2926 return WNetConnectionDialog1W(&conn_dlg);
2927}
LPNETRESOURCEW lpConnRes
Definition: winnetwk.h:196
#define ZeroMemory
Definition: winbase.h:1712
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD WINAPI WNetConnectionDialog1W(LPCONNECTDLGSTRUCTW lpConnDlgStruct)
Definition: wnet.c:2943

Referenced by CShellBrowser::OnMapNetworkDrive().

◆ WNetConnectionDialog1A()

DWORD WINAPI WNetConnectionDialog1A ( LPCONNECTDLGSTRUCTA  lpConnDlgStruct)

Definition at line 2932 of file wnet.c.

2933{
2934 FIXME( "(%p): stub\n", lpConnDlgStruct );
2935
2937 return WN_NO_NETWORK;
2938}

◆ WNetConnectionDialog1W()

DWORD WINAPI WNetConnectionDialog1W ( LPCONNECTDLGSTRUCTW  lpConnDlgStruct)

Definition at line 2943 of file wnet.c.

2944{
2945 FIXME( "(%p): stub\n", lpConnDlgStruct );
2946
2948 return WN_NO_NETWORK;
2949}

Referenced by WNetConnectionDialog().

◆ WNetDisconnectDialog()

DWORD WINAPI WNetDisconnectDialog ( HWND  hwnd,
DWORD  dwType 
)

Definition at line 2954 of file wnet.c.

2955{
2956#ifdef __REACTOS__
2957 DWORD dwRet;
2958 HMODULE hDll = LoadLibraryW(L"netplwiz.dll");
2959 static BOOL (WINAPI *pSHDisconnectNetDrives)(PVOID);
2960 pSHDisconnectNetDrives = (VOID *) GetProcAddress(hDll, "SHDisconnectNetDrives");
2961
2962 dwRet = pSHDisconnectNetDrives(NULL);
2963
2964 FreeLibrary(hDll);
2965 return dwRet;
2966#else
2967 FIXME( "(%p, %08X): stub\n", hwnd, dwType );
2968
2970 return WN_NO_NETWORK;
2971#endif
2972}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define BOOL
Definition: nt_native.h:43
#define L(x)
Definition: ntvdm.h:50
void * PVOID
Definition: typedefs.h:50
#define WINAPI
Definition: msvc.h:6

Referenced by CShellBrowser::OnDisconnectNetworkDrive().

◆ WNetDisconnectDialog1A()

DWORD WINAPI WNetDisconnectDialog1A ( LPDISCDLGSTRUCTA  lpConnDlgStruct)

Definition at line 2977 of file wnet.c.

2978{
2979 FIXME( "(%p): stub\n", lpConnDlgStruct );
2980
2982 return WN_NO_NETWORK;
2983}

◆ WNetDisconnectDialog1W()

DWORD WINAPI WNetDisconnectDialog1W ( LPDISCDLGSTRUCTW  lpConnDlgStruct)

Definition at line 2988 of file wnet.c.

2989{
2990 FIXME( "(%p): stub\n", lpConnDlgStruct );
2991
2993 return WN_NO_NETWORK;
2994}

◆ WNetEnumResourceA()

DWORD WINAPI WNetEnumResourceA ( HANDLE  hEnum,
LPDWORD  lpcCount,
LPVOID  lpBuffer,
LPDWORD  lpBufferSize 
)

Definition at line 1052 of file wnet.c.

1054{
1055 DWORD ret;
1056
1057 TRACE( "(%p, %p, %p, %p)\n", hEnum, lpcCount, lpBuffer, lpBufferSize );
1058
1059 if (!hEnum)
1061 else if (!lpcCount)
1063 else if (!lpBuffer)
1065 else if (!lpBufferSize)
1067 else if (*lpBufferSize < sizeof(NETRESOURCEA))
1068 {
1069 *lpBufferSize = sizeof(NETRESOURCEA);
1070 ret = WN_MORE_DATA;
1071 }
1072 else
1073 {
1074 DWORD localCount = *lpcCount, localSize = *lpBufferSize;
1075 LPVOID localBuffer = HeapAlloc(GetProcessHeap(), 0, localSize);
1076
1077 if (localBuffer)
1078 {
1079 ret = WNetEnumResourceW(hEnum, &localCount, localBuffer,
1080 &localSize);
1081 if (ret == WN_SUCCESS || (ret == WN_MORE_DATA && localCount != -1))
1082 {
1083 /* FIXME: this isn't necessarily going to work in the case of
1084 * WN_MORE_DATA, because our enumerator may have moved on to
1085 * the next provider. MSDN states that a large (16KB) buffer
1086 * size is the appropriate usage of this function, so
1087 * hopefully it won't be an issue.
1088 */
1089 ret = _thunkNetResourceArrayWToA(localBuffer, &localCount,
1090 lpBuffer, lpBufferSize);
1091 *lpcCount = localCount;
1092 }
1093 HeapFree(GetProcessHeap(), 0, localBuffer);
1094 }
1095 else
1097 }
1098 if (ret)
1100 TRACE("Returning %d\n", ret);
1101 return ret;
1102}
static DWORD _thunkNetResourceArrayWToA(const NETRESOURCEW *lpNetArrayIn, const DWORD *lpcCount, LPVOID lpBuffer, const DWORD *lpBufferSize)
Definition: wnet.c:662

◆ WNetEnumResourceW()

DWORD WINAPI WNetEnumResourceW ( HANDLE  hEnum,
LPDWORD  lpcCount,
LPVOID  lpBuffer,
LPDWORD  lpBufferSize 
)

Definition at line 1702 of file wnet.c.

1704{
1705 DWORD ret;
1706
1707 TRACE( "(%p, %p, %p, %p)\n", hEnum, lpcCount, lpBuffer, lpBufferSize );
1708
1709 if (!hEnum)
1711 else if (!lpcCount)
1713 else if (!lpBuffer)
1715 else if (!lpBufferSize)
1717 else if (*lpBufferSize < sizeof(NETRESOURCEW))
1718 {
1719 *lpBufferSize = sizeof(NETRESOURCEW);
1720 ret = WN_MORE_DATA;
1721 }
1722 else
1723 {
1724 PWNetEnumerator enumerator = (PWNetEnumerator)hEnum;
1725
1726 switch (enumerator->enumType)
1727 {
1729 ret = _enumerateGlobalW(enumerator, lpcCount, lpBuffer,
1730 lpBufferSize);
1731 break;
1733 ret = _enumerateProviderW(enumerator, lpcCount, lpBuffer,
1734 lpBufferSize);
1735 break;
1737 ret = _enumerateContextW(enumerator, lpcCount, lpBuffer,
1738 lpBufferSize);
1739 break;
1741 ret = _enumerateConnectedW(enumerator, lpcCount, lpBuffer,
1742 lpBufferSize);
1743 break;
1745 ret = _enumeratorRememberedW(enumerator, lpcCount, lpBuffer,
1746 lpBufferSize);
1747 break;
1748 default:
1749 WARN("bogus enumerator type!\n");
1751 }
1752 }
1753 if (ret)
1755 TRACE("Returning %d\n", ret);
1756 return ret;
1757}
static DWORD _enumerateConnectedW(PWNetEnumerator enumerator, DWORD *user_count, void *user_buffer, DWORD *user_size)
Definition: wnet.c:1438
static DWORD _enumeratorRememberedW(PWNetEnumerator enumerator, DWORD *user_count, void *user_buffer, DWORD *user_size)
Definition: wnet.c:1561
static DWORD _enumerateProviderW(PWNetEnumerator enumerator, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
Definition: wnet.c:1318
static DWORD _enumerateContextW(PWNetEnumerator enumerator, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize)
Definition: wnet.c:1343

Referenced by WNetClearConnections(), and WNetEnumResourceA().

◆ wnetFree()

void wnetFree ( void  )

Definition at line 492 of file wnet.c.

493{
494 if (providerTable)
495 {
496 DWORD i;
497
498 for (i = 0; i < providerTable->numProviders; i++)
499 {
502 }
506 }
507}
#define FreeModule(m)
Definition: winbase.h:2033

Referenced by DllMain().

◆ WNetGetConnectionA()

DWORD WINAPI WNetGetConnectionA ( LPCSTR  lpLocalName,
LPSTR  lpRemoteName,
LPDWORD  lpBufferSize 
)

Definition at line 2494 of file wnet.c.

2496{
2497 DWORD ret;
2498
2499 if (!lpLocalName)
2501 else if (!lpBufferSize)
2503 else if (!lpRemoteName && *lpBufferSize)
2505 else
2506 {
2507 int len = MultiByteToWideChar(CP_ACP, 0, lpLocalName, -1, NULL, 0);
2508
2509 if (len)
2510 {
2511 PWSTR wideLocalName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
2512
2513 if (wideLocalName)
2514 {
2515 WCHAR wideRemoteStatic[MAX_PATH];
2516 DWORD wideRemoteSize = ARRAY_SIZE(wideRemoteStatic);
2517
2518 MultiByteToWideChar(CP_ACP, 0, lpLocalName, -1, wideLocalName, len);
2519
2520 /* try once without memory allocation */
2521 ret = WNetGetConnectionW(wideLocalName, wideRemoteStatic,
2522 &wideRemoteSize);
2523 if (ret == WN_SUCCESS)
2524 {
2525 int len = WideCharToMultiByte(CP_ACP, 0, wideRemoteStatic,
2526 -1, NULL, 0, NULL, NULL);
2527
2528 if (len <= *lpBufferSize)
2529 {
2530 WideCharToMultiByte(CP_ACP, 0, wideRemoteStatic, -1,
2531 lpRemoteName, *lpBufferSize, NULL, NULL);
2532 ret = WN_SUCCESS;
2533 }
2534 else
2535 {
2536 *lpBufferSize = len;
2537 ret = WN_MORE_DATA;
2538 }
2539 }
2540 else if (ret == WN_MORE_DATA)
2541 {
2542 PWSTR wideRemote = HeapAlloc(GetProcessHeap(), 0,
2543 wideRemoteSize * sizeof(WCHAR));
2544
2545 if (wideRemote)
2546 {
2547 ret = WNetGetConnectionW(wideLocalName, wideRemote,
2548 &wideRemoteSize);
2549 if (ret == WN_SUCCESS)
2550 {
2551 if (len <= *lpBufferSize)
2552 {
2553 WideCharToMultiByte(CP_ACP, 0, wideRemoteStatic,
2554 -1, lpRemoteName, *lpBufferSize, NULL, NULL);
2555 ret = WN_SUCCESS;
2556 }
2557 else
2558 {
2559 *lpBufferSize = len;
2560 ret = WN_MORE_DATA;
2561 }
2562 }
2563 HeapFree(GetProcessHeap(), 0, wideRemote);
2564 }
2565 else
2567 }
2568 HeapFree(GetProcessHeap(), 0, wideLocalName);
2569 }
2570 else
2572 }
2573 else
2575 }
2576 if (ret)
2578 TRACE("Returning %d\n", ret);
2579 return ret;
2580}
#define WN_BAD_LOCALNAME
Definition: winnetwk.h:136
DWORD WINAPI WNetGetConnectionW(LPCWSTR lpLocalName, LPWSTR lpRemoteName, LPDWORD lpBufferSize)
Definition: wnet.c:2661

◆ WNetGetConnectionW()

DWORD WINAPI WNetGetConnectionW ( LPCWSTR  lpLocalName,
LPWSTR  lpRemoteName,
LPDWORD  lpBufferSize 
)

Definition at line 2661 of file wnet.c.

2663{
2664 DWORD ret;
2665
2666 TRACE("(%s, %p, %p)\n", debugstr_w(lpLocalName), lpRemoteName,
2667 lpBufferSize);
2668
2669 if (!lpLocalName)
2671 else if (!lpBufferSize)
2673 else if (!lpRemoteName && *lpBufferSize)
2675 else if (!lpLocalName[0])
2677 else
2678 {
2679 if (lpLocalName[1] == ':')
2680 {
2681 switch(GetDriveTypeW(lpLocalName))
2682 {
2683 case DRIVE_REMOTE:
2684 ret = get_drive_connection( lpLocalName[0], lpRemoteName, lpBufferSize );
2685 break;
2686 case DRIVE_REMOVABLE:
2687 case DRIVE_FIXED:
2688 case DRIVE_CDROM:
2689 TRACE("file is local\n");
2691 break;
2692 default:
2694 }
2695 }
2696 else
2698 }
2699 if (ret)
2701 TRACE("Returning %d\n", ret);
2702 return ret;
2703}
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
#define DRIVE_CDROM
Definition: machpc98.h:119
#define DRIVE_REMOTE
Definition: winbase.h:253
#define DRIVE_FIXED
Definition: winbase.h:252
#define DRIVE_REMOVABLE
Definition: winbase.h:251
static DWORD get_drive_connection(WCHAR letter, LPWSTR remote, LPDWORD size)
Definition: wnet.c:2583

Referenced by WNetGetConnectionA().

◆ WNetGetLastErrorA()

DWORD WINAPI WNetGetLastErrorA ( LPDWORD  lpError,
LPSTR  lpErrorBuf,
DWORD  nErrorBufSize,
LPSTR  lpNameBuf,
DWORD  nNameBufSize 
)

Definition at line 2999 of file wnet.c.

3002{
3003 FIXME( "(%p, %p, %d, %p, %d): stub\n",
3004 lpError, lpErrorBuf, nErrorBufSize, lpNameBuf, nNameBufSize );
3005
3007 return WN_NO_NETWORK;
3008}

◆ WNetGetLastErrorW()

DWORD WINAPI WNetGetLastErrorW ( LPDWORD  lpError,
LPWSTR  lpErrorBuf,
DWORD  nErrorBufSize,
LPWSTR  lpNameBuf,
DWORD  nNameBufSize 
)

Definition at line 3013 of file wnet.c.

3016{
3017 FIXME( "(%p, %p, %d, %p, %d): stub\n",
3018 lpError, lpErrorBuf, nErrorBufSize, lpNameBuf, nNameBufSize );
3019
3021 return WN_NO_NETWORK;
3022}

Referenced by WNetGetLastErrorWrapW().

◆ WNetGetNetworkInformationA()

DWORD WINAPI WNetGetNetworkInformationA ( LPCSTR  lpProvider,
LPNETINFOSTRUCT  lpNetInfoStruct 
)

Definition at line 3027 of file wnet.c.

3029{
3030 DWORD ret;
3031
3032 TRACE( "(%s, %p)\n", debugstr_a(lpProvider), lpNetInfoStruct );
3033
3034 if (!lpProvider)
3036 else
3037 {
3038 int len;
3039
3040 len = MultiByteToWideChar(CP_ACP, 0, lpProvider, -1, NULL, 0);
3041 if (len)
3042 {
3043 LPWSTR wideProvider = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3044
3045 if (wideProvider)
3046 {
3047 MultiByteToWideChar(CP_ACP, 0, lpProvider, -1, wideProvider,
3048 len);
3049 ret = WNetGetNetworkInformationW(wideProvider, lpNetInfoStruct);
3050 HeapFree(GetProcessHeap(), 0, wideProvider);
3051 }
3052 else
3054 }
3055 else
3056 ret = GetLastError();
3057 }
3058 if (ret)
3060 TRACE("Returning %d\n", ret);
3061 return ret;
3062}
#define debugstr_a
Definition: kernel32.h:31
DWORD WINAPI WNetGetNetworkInformationW(LPCWSTR lpProvider, LPNETINFOSTRUCT lpNetInfoStruct)
Definition: wnet.c:3067

◆ WNetGetNetworkInformationW()

DWORD WINAPI WNetGetNetworkInformationW ( LPCWSTR  lpProvider,
LPNETINFOSTRUCT  lpNetInfoStruct 
)

Definition at line 3067 of file wnet.c.

3069{
3070 DWORD ret;
3071
3072 TRACE( "(%s, %p)\n", debugstr_w(lpProvider), lpNetInfoStruct );
3073
3074 if (!lpProvider)
3076 else if (!lpNetInfoStruct)
3078 else if (lpNetInfoStruct->cbStructure < sizeof(NETINFOSTRUCT))
3079 ret = WN_BAD_VALUE;
3080 else
3081 {
3083 {
3084 DWORD providerIndex = _findProviderIndexW(lpProvider);
3085
3086 if (providerIndex != BAD_PROVIDER_INDEX)
3087 {
3088 lpNetInfoStruct->cbStructure = sizeof(NETINFOSTRUCT);
3089 lpNetInfoStruct->dwProviderVersion =
3090 providerTable->table[providerIndex].dwSpecVersion;
3091 lpNetInfoStruct->dwStatus = NO_ERROR;
3092 lpNetInfoStruct->dwCharacteristics = 0;
3093 lpNetInfoStruct->dwHandle = 0;
3094 lpNetInfoStruct->wNetType =
3095 HIWORD(providerTable->table[providerIndex].dwNetType);
3096 lpNetInfoStruct->dwPrinters = -1;
3097 lpNetInfoStruct->dwDrives = -1;
3098 ret = WN_SUCCESS;
3099 }
3100 else
3102 }
3103 else
3105 }
3106 if (ret)
3108 TRACE("Returning %d\n", ret);
3109 return ret;
3110}
#define NO_ERROR
Definition: dderror.h:5
DWORD cbStructure
Definition: winnetwk.h:227
DWORD dwProviderVersion
Definition: winnetwk.h:228
DWORD dwPrinters
Definition: winnetwk.h:233
DWORD dwDrives
Definition: winnetwk.h:234
DWORD dwCharacteristics
Definition: winnetwk.h:230
ULONG_PTR dwHandle
Definition: winnetwk.h:231
DWORD dwStatus
Definition: winnetwk.h:229
#define HIWORD(l)
Definition: typedefs.h:247
#define WN_BAD_PROVIDER
Definition: winnetwk.h:141
struct _NETINFOSTRUCT NETINFOSTRUCT

Referenced by WNetGetNetworkInformationA().

◆ WNetGetProviderNameA()

DWORD WINAPI WNetGetProviderNameA ( DWORD  dwNetType,
LPSTR  lpProvider,
LPDWORD  lpBufferSize 
)

Definition at line 3115 of file wnet.c.

3117{
3118 DWORD ret;
3119
3120 TRACE("(0x%08x, %s, %p)\n", dwNetType, debugstr_a(lpProvider),
3121 lpBufferSize);
3122
3123 if (!lpProvider)
3125 else if (!lpBufferSize)
3127 else
3128 {
3129 if (providerTable)
3130 {
3131 DWORD i;
3132
3134 for (i = 0; i < providerTable->numProviders &&
3135 HIWORD(providerTable->table[i].dwNetType) != HIWORD(dwNetType);
3136 i++)
3137 ;
3138 if (i < providerTable->numProviders)
3139 {
3140 DWORD sizeNeeded = WideCharToMultiByte(CP_ACP, 0,
3141 providerTable->table[i].name, -1, NULL, 0, NULL, NULL);
3142
3143 if (*lpBufferSize < sizeNeeded)
3144 {
3145 *lpBufferSize = sizeNeeded;
3146 ret = WN_MORE_DATA;
3147 }
3148 else
3149 {
3151 -1, lpProvider, *lpBufferSize, NULL, NULL);
3152 ret = WN_SUCCESS;
3153 /* FIXME: is *lpBufferSize set to the number of characters
3154 * copied? */
3155 }
3156 }
3157 }
3158 else
3160 }
3161 if (ret)
3163 TRACE("Returning %d\n", ret);
3164 return ret;
3165}

◆ WNetGetProviderNameW()

DWORD WINAPI WNetGetProviderNameW ( DWORD  dwNetType,
LPWSTR  lpProvider,
LPDWORD  lpBufferSize 
)

Definition at line 3170 of file wnet.c.

3172{
3173 DWORD ret;
3174
3175 TRACE("(0x%08x, %s, %p)\n", dwNetType, debugstr_w(lpProvider),
3176 lpBufferSize);
3177
3178 if (!lpProvider)
3180 else if (!lpBufferSize)
3182 else
3183 {
3184 if (providerTable)
3185 {
3186 DWORD i;
3187
3189 for (i = 0; i < providerTable->numProviders &&
3190 HIWORD(providerTable->table[i].dwNetType) != HIWORD(dwNetType);
3191 i++)
3192 ;
3193 if (i < providerTable->numProviders)
3194 {
3195 DWORD sizeNeeded = lstrlenW(providerTable->table[i].name) + 1;
3196
3197 if (*lpBufferSize < sizeNeeded)
3198 {
3199 *lpBufferSize = sizeNeeded;
3200 ret = WN_MORE_DATA;
3201 }
3202 else
3203 {
3204 lstrcpyW(lpProvider, providerTable->table[i].name);
3205 ret = WN_SUCCESS;
3206 /* FIXME: is *lpBufferSize set to the number of characters
3207 * copied? */
3208 }
3209 }
3210 }
3211 else
3213 }
3214 if (ret)
3216 TRACE("Returning %d\n", ret);
3217 return ret;
3218}

◆ WNetGetResourceInformationA()

DWORD WINAPI WNetGetResourceInformationA ( LPNETRESOURCEA  lpNetResource,
LPVOID  lpBuffer,
LPDWORD  cbBuffer,
LPSTR lplpSystem 
)

Definition at line 1822 of file wnet.c.

1825{
1826 DWORD ret;
1827
1828 TRACE( "(%p, %p, %p, %p)\n",
1829 lpNetResource, lpBuffer, cbBuffer, lplpSystem );
1830
1833 else if (lpNetResource)
1834 {
1835 LPNETRESOURCEW lpNetResourceW = NULL;
1836 DWORD size = 1024, count = 1;
1837 DWORD len;
1838
1839 lpNetResourceW = HeapAlloc(GetProcessHeap(), 0, size);
1840 ret = _thunkNetResourceArrayAToW(lpNetResource, &count, lpNetResourceW, &size);
1841 if (ret == WN_MORE_DATA)
1842 {
1843 HeapFree(GetProcessHeap(), 0, lpNetResourceW);
1844 lpNetResourceW = HeapAlloc(GetProcessHeap(), 0, size);
1845 if (lpNetResourceW)
1846 ret = _thunkNetResourceArrayAToW(lpNetResource,
1847 &count, lpNetResourceW, &size);
1848 else
1850 }
1851 if (ret == WN_SUCCESS)
1852 {
1853 LPWSTR lpSystemW = NULL;
1854 LPVOID lpBufferW;
1855 size = 1024;
1856 lpBufferW = HeapAlloc(GetProcessHeap(), 0, size);
1857 if (lpBufferW)
1858 {
1859 ret = WNetGetResourceInformationW(lpNetResourceW,
1860 lpBufferW, &size, &lpSystemW);
1861 if (ret == WN_MORE_DATA)
1862 {
1863 HeapFree(GetProcessHeap(), 0, lpBufferW);
1864 lpBufferW = HeapAlloc(GetProcessHeap(), 0, size);
1865 if (lpBufferW)
1866 ret = WNetGetResourceInformationW(lpNetResourceW,
1867 lpBufferW, &size, &lpSystemW);
1868 else
1870 }
1871 if (ret == WN_SUCCESS)
1872 {
1873 ret = _thunkNetResourceArrayWToA(lpBufferW,
1874 &count, lpBuffer, cbBuffer);
1875 HeapFree(GetProcessHeap(), 0, lpNetResourceW);
1876 lpNetResourceW = lpBufferW;
1877 size = sizeof(NETRESOURCEA);
1878 size += WideCharToMultiByte(CP_ACP, 0, lpNetResourceW->lpRemoteName,
1879 -1, NULL, 0, NULL, NULL);
1880 size += WideCharToMultiByte(CP_ACP, 0, lpNetResourceW->lpProvider,
1881 -1, NULL, 0, NULL, NULL);
1882
1883 len = WideCharToMultiByte(CP_ACP, 0, lpSystemW,
1884 -1, NULL, 0, NULL, NULL);
1885 if ((len) && ( size + len < *cbBuffer))
1886 {
1887 *lplpSystem = (char*)lpBuffer + *cbBuffer - len;
1888 WideCharToMultiByte(CP_ACP, 0, lpSystemW, -1,
1889 *lplpSystem, len, NULL, NULL);
1890 ret = WN_SUCCESS;
1891 }
1892 else
1893 ret = WN_MORE_DATA;
1894 }
1895 else
1897 HeapFree(GetProcessHeap(), 0, lpBufferW);
1898 }
1899 else
1901 HeapFree(GetProcessHeap(), 0, lpSystemW);
1902 }
1903 HeapFree(GetProcessHeap(), 0, lpNetResourceW);
1904 }
1905 else
1907
1908 if (ret)
1910 TRACE("Returning %d\n", ret);
1911 return ret;
1912}
static DWORD _thunkNetResourceArrayAToW(const NETRESOURCEA *lpNetArrayIn, const DWORD *lpcCount, LPVOID lpBuffer, const DWORD *lpBufferSize)
Definition: wnet.c:747
DWORD WINAPI WNetGetResourceInformationW(LPNETRESOURCEW lpNetResource, LPVOID lpBuffer, LPDWORD cbBuffer, LPWSTR *lplpSystem)
Definition: wnet.c:1937

◆ WNetGetResourceInformationW()

DWORD WINAPI WNetGetResourceInformationW ( LPNETRESOURCEW  lpNetResource,
LPVOID  lpBuffer,
LPDWORD  cbBuffer,
LPWSTR lplpSystem 
)

Definition at line 1937 of file wnet.c.

1940{
1942 DWORD index;
1943
1944 TRACE( "(%p, %p, %p, %p)\n",
1945 lpNetResource, lpBuffer, cbBuffer, lplpSystem);
1946
1947 if (!(lpBuffer))
1949 else if (providerTable != NULL)
1950 {
1951 /* FIXME: For function value of a variable is indifferent, it does
1952 * search of all providers in a network.
1953 */
1954 for (index = 0; index < providerTable->numProviders; index++)
1955 {
1958 {
1961 lpNetResource, lpBuffer, cbBuffer, lplpSystem);
1962 else
1964 if (ret == WN_SUCCESS)
1965 break;
1966 }
1967 }
1968 }
1969 if (ret)
1971 return ret;
1972}
#define WNNC_DLG_GETRESOURCEINFORMATION
Definition: npapi.h:45
#define WNNC_DIALOG
Definition: npapi.h:38

Referenced by WNetGetResourceInformationA().

◆ WNetGetResourceParentA()

DWORD WINAPI WNetGetResourceParentA ( LPNETRESOURCEA  lpNetResource,
LPVOID  lpBuffer,
LPDWORD  lpBufferSize 
)

Definition at line 1977 of file wnet.c.

1979{
1980 FIXME( "(%p, %p, %p): stub\n",
1981 lpNetResource, lpBuffer, lpBufferSize );
1982
1984 return WN_NO_NETWORK;
1985}

◆ WNetGetResourceParentW()

DWORD WINAPI WNetGetResourceParentW ( LPNETRESOURCEW  lpNetResource,
LPVOID  lpBuffer,
LPDWORD  lpBufferSize 
)

Definition at line 1990 of file wnet.c.

1992{
1993 FIXME( "(%p, %p, %p): stub\n",
1994 lpNetResource, lpBuffer, lpBufferSize );
1995
1997 return WN_NO_NETWORK;
1998}

◆ WNetGetUniversalNameA()

DWORD WINAPI WNetGetUniversalNameA ( LPCSTR  lpLocalPath,
DWORD  dwInfoLevel,
LPVOID  lpBuffer,
LPDWORD  lpBufferSize 
)

Definition at line 2732 of file wnet.c.

2734{
2735 DWORD err, size;
2736
2737 FIXME( "(%s, 0x%08X, %p, %p): stub\n",
2738 debugstr_a(lpLocalPath), dwInfoLevel, lpBuffer, lpBufferSize);
2739
2740 switch (dwInfoLevel)
2741 {
2743 {
2745
2746 if (GetDriveTypeA(lpLocalPath) != DRIVE_REMOTE)
2747 {
2749 break;
2750 }
2751
2752 size = sizeof(*info) + lstrlenA(lpLocalPath) + 1;
2753 if (*lpBufferSize < size)
2754 {
2755 err = WN_MORE_DATA;
2756 break;
2757 }
2758 info->lpUniversalName = (char *)info + sizeof(*info);
2759 lstrcpyA(info->lpUniversalName, lpLocalPath);
2760 err = WN_NO_ERROR;
2761 break;
2762 }
2765 break;
2766
2767 default:
2768 err = WN_BAD_VALUE;
2769 break;
2770 }
2771
2773 return err;
2774}
UINT WINAPI GetDriveTypeA(IN LPCSTR lpRootPathName)
Definition: disk.c:468
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define err(...)
#define WN_NO_ERROR
Definition: winnetwk.h:112
#define REMOTE_NAME_INFO_LEVEL
Definition: winnetwk.h:152
#define UNIVERSAL_NAME_INFO_LEVEL
Definition: winnetwk.h:151
_In_ DWORD dwInfoLevel
Definition: winsvc.h:422

Referenced by test_WNetGetRemoteName(), and test_WNetGetUniversalName().

◆ WNetGetUniversalNameW()

DWORD WINAPI WNetGetUniversalNameW ( LPCWSTR  lpLocalPath,
DWORD  dwInfoLevel,
LPVOID  lpBuffer,
LPDWORD  lpBufferSize 
)

Definition at line 2779 of file wnet.c.

2781{
2782 DWORD err, size;
2783
2784 FIXME( "(%s, 0x%08X, %p, %p): stub\n",
2785 debugstr_w(lpLocalPath), dwInfoLevel, lpBuffer, lpBufferSize);
2786
2787 switch (dwInfoLevel)
2788 {
2790 {
2792
2793 if (GetDriveTypeW(lpLocalPath) != DRIVE_REMOTE)
2794 {
2796 break;
2797 }
2798
2799 size = sizeof(*info) + (lstrlenW(lpLocalPath) + 1) * sizeof(WCHAR);
2800 if (*lpBufferSize < size)
2801 {
2802 *lpBufferSize = size;
2803 err = WN_MORE_DATA;
2804 break;
2805 }
2806 info->lpUniversalName = (LPWSTR)((char *)info + sizeof(*info));
2807 lstrcpyW(info->lpUniversalName, lpLocalPath);
2808 err = WN_NO_ERROR;
2809 break;
2810 }
2813 break;
2814
2815 default:
2816 err = WN_BAD_VALUE;
2817 break;
2818 }
2819
2821 return err;
2822}

Referenced by fw_app_put_ProcessImageFileName(), test_NetFwAuthorizedApplication(), test_WNetGetRemoteName(), and test_WNetGetUniversalName().

◆ WNetGetUserA()

DWORD WINAPI WNetGetUserA ( LPCSTR  lpName,
LPSTR  lpUserID,
LPDWORD  lpBufferSize 
)

Definition at line 2893 of file wnet.c.

2894{
2895 if (GetUserNameA( lpUserID, lpBufferSize )) return WN_SUCCESS;
2896 return GetLastError();
2897}
BOOL WINAPI GetUserNameA(LPSTR lpszName, LPDWORD lpSize)
Definition: misc.c:246

◆ WNetGetUserW()

DWORD WINAPI WNetGetUserW ( LPCWSTR  lpName,
LPWSTR  lpUserID,
LPDWORD  lpBufferSize 
)

Definition at line 2904 of file wnet.c.

2905{
2906 if (GetUserNameW( lpUserID, lpBufferSize )) return WN_SUCCESS;
2907 return GetLastError();
2908}
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291

◆ wnetInit()

void wnetInit ( HINSTANCE  hInstDll)

Definition at line 354 of file wnet.c.

355{
356 static const WCHAR providerOrderKey[] = { 'S','y','s','t','e','m','\\',
357 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
358 'C','o','n','t','r','o','l','\\',
359 'N','e','t','w','o','r','k','P','r','o','v','i','d','e','r','\\',
360 'O','r','d','e','r',0 };
361 static const WCHAR providerOrder[] = { 'P','r','o','v','i','d','e','r',
362 'O','r','d','e','r',0 };
363 HKEY hKey;
364
365 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, providerOrderKey, 0, KEY_READ, &hKey)
366 == ERROR_SUCCESS)
367 {
368 DWORD size = 0;
369
370 RegQueryValueExW(hKey, providerOrder, NULL, NULL, NULL, &size);
371 if (size)
372 {
374
375 if (providers)
376 {
377 DWORD type;
378
379 if (RegQueryValueExW(hKey, providerOrder, NULL, &type,
381 {
382 PWSTR ptr;
383 DWORD numToAllocate;
384
385 TRACE("provider order is %s\n", debugstr_w(providers));
386 /* first count commas as a heuristic for how many to
387 * allocate space for */
388 for (ptr = providers, numToAllocate = 1; ptr; )
389 {
390 ptr = wcschr(ptr, ',');
391 if (ptr) {
392 numToAllocate++;
393 ptr++;
394 }
395 }
398 sizeof(WNetProviderTable)
399 + (numToAllocate - 1) * sizeof(WNetProvider));
400 if (providerTable)
401 {
402 PWSTR ptrPrev;
403 int entireNetworkLen;
404 LPCWSTR stringresource;
405
406 entireNetworkLen = LoadStringW(hInstDll,
407 IDS_ENTIRENETWORK, (LPWSTR)&stringresource, 0);
409 GetProcessHeap(), 0, (entireNetworkLen + 1) *
410 sizeof(WCHAR));
412 {
413 memcpy(providerTable->entireNetwork, stringresource, entireNetworkLen*sizeof(WCHAR));
414 providerTable->entireNetwork[entireNetworkLen] = 0;
415 }
416 providerTable->numAllocated = numToAllocate;
417 for (ptr = providers; ptr; )
418 {
419 ptrPrev = ptr;
420 ptr = wcschr(ptr, ',');
421 if (ptr)
422 *ptr++ = '\0';
423 _tryLoadProvider(ptrPrev);
424 }
425 }
426 }
428 }
429 }
431 }
432
433#ifdef __REACTOS__
434 if (providerTable)
435 {
436 HKEY user_profile;
437
438 if (RegOpenCurrentUser(KEY_ALL_ACCESS, &user_profile) == ERROR_SUCCESS)
439 {
441 WCHAR subkey[8] = {'N', 'e', 't', 'w', 'o', 'r', 'k', 0};
442
443 if (RegOpenKeyExW(user_profile, subkey, 0, KEY_READ, &network) == ERROR_SUCCESS)
444 {
445 DWORD size, max;
446
447 TRACE("Enumerating remembered connections\n");
448
450 {
451 WCHAR *local;
452
453 TRACE("There are %lu connections\n", max);
454
455 local = HeapAlloc(GetProcessHeap(), 0, (size + 1) * sizeof(WCHAR));
456 if (local)
457 {
458 DWORD index;
459
460 for (index = 0; index < max; ++index)
461 {
462 DWORD len = size + 1;
463 HKEY connection;
464
465 TRACE("Trying connection %lu\n", index);
466
468 continue;
469
470 TRACE("It is %S\n", local);
471
472 if (RegOpenKeyExW(network, local, 0, KEY_READ, &connection) != ERROR_SUCCESS)
473 continue;
474
475 _restoreSavedConnection(connection, local);
476 RegCloseKey(connection);
477 }
478
480 }
481 }
482
484 }
485
486 RegCloseKey(user_profile);
487 }
488 }
489#endif
490}
static struct list providers
Definition: sip.c:564
#define wcschr
Definition: compat.h:17
static PVOID ptr
Definition: dispmode.c:27
#define IDS_ENTIRENETWORK
Definition: mprres.h:24
DWORD numAllocated
Definition: wnet.c:75
#define max(a, b)
Definition: svc.c:63
#define RegQueryInfoKey
Definition: winreg.h:521
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
static void _tryLoadProvider(PCWSTR provider)
Definition: wnet.c:135
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by DllMain().

◆ WNetOpenEnumA()

DWORD WINAPI WNetOpenEnumA ( DWORD  dwScope,
DWORD  dwType,
DWORD  dwUsage,
LPNETRESOURCEA  lpNet,
LPHANDLE  lphEnum 
)

Definition at line 830 of file wnet.c.

832{
833 DWORD ret;
834
835 TRACE( "(%08X, %08X, %08X, %p, %p)\n",
836 dwScope, dwType, dwUsage, lpNet, lphEnum );
837
838 if (!lphEnum)
840 else if (!providerTable || providerTable->numProviders == 0)
841 {
842 *lphEnum = NULL;
844 }
845 else
846 {
847 if (lpNet)
848 {
849 LPNETRESOURCEW lpNetWide = NULL;
850 BYTE buf[1024];
851 DWORD size = sizeof(buf), count = 1;
852 BOOL allocated = FALSE;
853
855 if (ret == WN_MORE_DATA)
856 {
857 lpNetWide = HeapAlloc(GetProcessHeap(), 0,
858 size);
859 if (lpNetWide)
860 {
861 ret = _thunkNetResourceArrayAToW(lpNet, &count, lpNetWide,
862 &size);
863 allocated = TRUE;
864 }
865 else
867 }
868 else if (ret == WN_SUCCESS)
869 lpNetWide = (LPNETRESOURCEW)buf;
870 if (ret == WN_SUCCESS)
871 ret = WNetOpenEnumW(dwScope, dwType, dwUsage, lpNetWide,
872 lphEnum);
873 if (allocated)
874 HeapFree(GetProcessHeap(), 0, lpNetWide);
875 }
876 else
877 ret = WNetOpenEnumW(dwScope, dwType, dwUsage, NULL, lphEnum);
878 }
879 if (ret)
881 TRACE("Returning %d\n", ret);
882 return ret;
883}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751

◆ WNetOpenEnumW()

DWORD WINAPI WNetOpenEnumW ( DWORD  dwScope,
DWORD  dwType,
DWORD  dwUsage,
LPNETRESOURCEW  lpNet,
LPHANDLE  lphEnum 
)

Definition at line 922 of file wnet.c.

924{
925 DWORD ret;
926
927 TRACE( "(%08X, %08X, %08X, %p, %p)\n",
928 dwScope, dwType, dwUsage, lpNet, lphEnum );
929
930 if (!lphEnum)
932 else if (!providerTable || providerTable->numProviders == 0)
933 {
934 *lphEnum = NULL;
936 }
937 else
938 {
939 switch (dwScope)
940 {
942 if (lpNet)
943 {
944 if (lpNet->lpProvider)
945 {
947
949 {
952 {
954 PWSTR RemoteName = lpNet->lpRemoteName;
955
956 if ((lpNet->dwUsage & RESOURCEUSAGE_CONTAINER) &&
957 RemoteName && !lstrcmpW(RemoteName, lpNet->lpProvider))
958 lpNet->lpRemoteName = NULL;
959
961 dwScope, dwType, dwUsage, lpNet, &handle);
962 if (ret == WN_SUCCESS)
963 {
964 *lphEnum = _createProviderEnumerator(
965 dwScope, dwType, dwUsage, index, handle);
966 ret = *lphEnum ? WN_SUCCESS :
968 }
969
970 lpNet->lpRemoteName = RemoteName;
971 }
972 else
974 }
975 else
977 }
978 else if (lpNet->lpRemoteName)
979 {
980 *lphEnum = _createGlobalEnumeratorW(dwScope,
981 dwType, dwUsage, lpNet);
982 ret = *lphEnum ? WN_SUCCESS : WN_OUT_OF_MEMORY;
983 }
984 else
985 {
986 if (lpNet->lpComment && !lstrcmpW(lpNet->lpComment,
988 {
989 /* comment matches the "Entire Network", enumerate
990 * global scope of every provider
991 */
992 *lphEnum = _createGlobalEnumeratorW(dwScope,
993 dwType, dwUsage, lpNet);
994 }
995 else
996 {
997 /* this is the same as not having passed lpNet */
998 *lphEnum = _createGlobalEnumeratorW(dwScope,
999 dwType, dwUsage, NULL);
1000 }
1001 ret = *lphEnum ? WN_SUCCESS : WN_OUT_OF_MEMORY;
1002 }
1003 }
1004 else
1005 {
1006 *lphEnum = _createGlobalEnumeratorW(dwScope, dwType,
1007 dwUsage, lpNet);
1008 ret = *lphEnum ? WN_SUCCESS : WN_OUT_OF_MEMORY;
1009 }
1010 break;
1011 case RESOURCE_CONTEXT:
1012 *lphEnum = _createContextEnumerator(dwScope, dwType, dwUsage);
1013 ret = *lphEnum ? WN_SUCCESS : WN_OUT_OF_MEMORY;
1014 break;
1015 case RESOURCE_CONNECTED:
1016 *lphEnum = _createConnectedEnumerator(dwScope, dwType, dwUsage);
1017 ret = *lphEnum ? WN_SUCCESS : WN_OUT_OF_MEMORY;
1018 break;
1020 {
1021 HKEY remembered, user_profile;
1022
1024 if (RegOpenCurrentUser(KEY_READ, &user_profile) == ERROR_SUCCESS)
1025 {
1026 WCHAR subkey[8] = {'N', 'e', 't', 'w', 'o', 'r', 'k', 0};
1027
1028 if (RegOpenKeyExW(user_profile, subkey, 0, KEY_READ, &remembered) == ERROR_SUCCESS)
1029 {
1030 *lphEnum = _createRememberedEnumerator(dwScope, dwType, remembered);
1031 ret = *lphEnum ? WN_SUCCESS : WN_OUT_OF_MEMORY;
1032 }
1033
1034 RegCloseKey(user_profile);
1035 }
1036 }
1037 break;
1038 default:
1039 WARN("unknown scope 0x%08x\n", dwScope);
1040 ret = WN_BAD_VALUE;
1041 }
1042 }
1043 if (ret)
1045 TRACE("Returning %d\n", ret);
1046 return ret;
1047}
#define WN_NOT_SUPPORTED
Definition: winnetwk.h:113
static PWNetEnumerator _createConnectedEnumerator(DWORD dwScope, DWORD dwType, DWORD dwUsage)
Definition: wnet.c:621
static PWNetEnumerator _createRememberedEnumerator(DWORD dwScope, DWORD dwType, HKEY remembered)
Definition: wnet.c:641
static PWNetEnumerator _createProviderEnumerator(DWORD dwScope, DWORD dwType, DWORD dwUsage, DWORD index, HANDLE handle)
Definition: wnet.c:582
static PWNetEnumerator _createGlobalEnumeratorW(DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCEW lpNet)
Definition: wnet.c:565
static PWNetEnumerator _createContextEnumerator(DWORD dwScope, DWORD dwType, DWORD dwUsage)
Definition: wnet.c:605

Referenced by WNetClearConnections(), and WNetOpenEnumA().

◆ WNetRestoreConnectionA()

DWORD WINAPI WNetRestoreConnectionA ( HWND  hwndOwner,
LPCSTR  lpszDevice 
)

Definition at line 2464 of file wnet.c.

2465{
2466 FIXME( "(%p, %s), stub\n", hwndOwner, debugstr_a(lpszDevice) );
2467
2469 return WN_NO_NETWORK;
2470}

◆ WNetRestoreConnectionW()

DWORD WINAPI WNetRestoreConnectionW ( HWND  hwndOwner,
LPCWSTR  lpszDevice 
)

Definition at line 2475 of file wnet.c.

2476{
2477 FIXME( "(%p, %s), stub\n", hwndOwner, debugstr_w(lpszDevice) );
2478
2480 return WN_NO_NETWORK;
2481}

Referenced by WNetRestoreConnectionWrapW().

◆ WNetSetConnectionA()

DWORD WINAPI WNetSetConnectionA ( LPCSTR  lpName,
DWORD  dwProperty,
LPVOID  pvValue 
)

Definition at line 2708 of file wnet.c.

2710{
2711 FIXME( "(%s, %08X, %p): stub\n", debugstr_a(lpName), dwProperty, pvValue );
2712
2714 return WN_NO_NETWORK;
2715}

◆ WNetSetConnectionW()

DWORD WINAPI WNetSetConnectionW ( LPCWSTR  lpName,
DWORD  dwProperty,
LPVOID  pvValue 
)

Definition at line 2720 of file wnet.c.

2722{
2723 FIXME( "(%s, %08X, %p): stub\n", debugstr_w(lpName), dwProperty, pvValue );
2724
2726 return WN_NO_NETWORK;
2727}

◆ WNetUseConnectionA()

DWORD WINAPI WNetUseConnectionA ( HWND  hwndOwner,
NETRESOURCEA resource,
LPCSTR  password,
LPCSTR  userid,
DWORD  flags,
LPSTR  accessname,
DWORD buffer_size,
DWORD result 
)

Definition at line 2351 of file wnet.c.

2354{
2355 struct use_connection_context ctxt;
2356 NETRESOURCEW resourceW;
2357 DWORD ret;
2358
2359 TRACE( "(%p, %p, %p, %s, 0x%08X, %p, %p, %p)\n", hwndOwner, resource, password, debugstr_a(userid), flags,
2361
2362 netresource_a_to_w(resource, &resourceW);
2363
2364 ctxt.hwndOwner = hwndOwner;
2365 ctxt.resource = &resourceW;
2366 ctxt.resourceA = resource;
2367 ctxt.password = strdupAtoW(password);
2368 ctxt.userid = strdupAtoW(userid);
2369 ctxt.flags = flags;
2370 ctxt.accessname = accessname;
2371 ctxt.buffer_size = buffer_size;
2372 ctxt.result = result;
2373 ctxt.pre_set_accessname = use_connection_pre_set_accessnameA;
2374 ctxt.set_accessname = use_connection_set_accessnameA;
2375
2376 ret = wnet_use_connection(&ctxt);
2377
2378 free_netresourceW(&resourceW);
2379 HeapFree(GetProcessHeap(), 0, ctxt.password);
2380 HeapFree(GetProcessHeap(), 0, ctxt.userid);
2381
2382 return ret;
2383}
GLbitfield flags
Definition: glext.h:7161
GLuint64EXT * result
Definition: glext.h:11304
static WCHAR password[]
Definition: url.c:33
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888
static void free_netresourceW(NETRESOURCEW *resource)
Definition: wnet.c:2340
static void netresource_a_to_w(NETRESOURCEA *resourceA, NETRESOURCEW *resourceW)
Definition: wnet.c:2328
static DWORD use_connection_pre_set_accessnameA(struct use_connection_context *ctxt, WCHAR *local_name)
Definition: wnet.c:2280
static void use_connection_set_accessnameA(struct use_connection_context *ctxt, WCHAR *local_name)
Definition: wnet.c:2303
static DWORD wnet_use_connection(struct use_connection_context *ctxt)
Definition: wnet.c:2158

Referenced by InitFunctionPtrs(), WNetAddConnection2A(), WNetAddConnection3A(), and WNetAddConnectionA().

◆ WNetUseConnectionW()

DWORD WINAPI WNetUseConnectionW ( HWND  hwndOwner,
NETRESOURCEW resource,
LPCWSTR  password,
LPCWSTR  userid,
DWORD  flags,
LPWSTR  accessname,
DWORD buffer_size,
DWORD result 
)

Definition at line 2256 of file wnet.c.

2258{
2259 struct use_connection_context ctxt;
2260
2261 TRACE( "(%p, %p, %p, %s, 0x%08X, %p, %p, %p)\n",
2264
2265 ctxt.hwndOwner = hwndOwner;
2266 ctxt.resource = resource;
2267 ctxt.resourceA = NULL;
2268 ctxt.password = (WCHAR*)password;
2269 ctxt.userid = (WCHAR*)userid;
2270 ctxt.flags = flags;
2271 ctxt.accessname = accessname;
2272 ctxt.buffer_size = buffer_size;
2273 ctxt.result = result;
2274 ctxt.pre_set_accessname = use_connection_pre_set_accessnameW;
2275 ctxt.set_accessname = use_connection_set_accessnameW;
2276
2277 return wnet_use_connection(&ctxt);
2278}
static DWORD use_connection_pre_set_accessnameW(struct use_connection_context *ctxt, WCHAR *local_name)
Definition: wnet.c:2093
static void use_connection_set_accessnameW(struct use_connection_context *ctxt, WCHAR *local_name)
Definition: wnet.c:2116

Referenced by WNetAddConnection2W(), WNetAddConnection3W(), and WNetAddConnectionW().

Variable Documentation

◆ connectionType

const WCHAR connectionType[] = { 'C','o','n','n','e','c','t','i','o','n','T','y','p','e',0 }
static

Definition at line 1543 of file wnet.c.

Referenced by _enumeratorRememberedW(), and wnet_use_connection().

◆ providerName

const WCHAR providerName[] = { 'P','r','o','v','i','d','e','r','N','a','m','e',0 }
static

Definition at line 1544 of file wnet.c.

Referenced by _enumeratorRememberedW(), and wnet_use_connection().

◆ providerTable

◆ providerType

const WCHAR providerType[] = { 'P','r','o','v','i','d','e','r','T','y','p','e',0 }
static

Definition at line 2155 of file wnet.c.

Referenced by wnet_use_connection().

◆ remotePath

const WCHAR remotePath[] = { 'R','e','m','o','t','e','P','a','t','h',0 }
static

Definition at line 1545 of file wnet.c.

Referenced by _enumeratorRememberedW(), and wnet_use_connection().

◆ userName

const WCHAR userName[] = { 'U','s','e','r','N','a','m','e',0 }
static