[MPR]
[reactos.git] / reactos / dll / win32 / mpr / mpr_ros.diff
1 Index: mpr.spec
2 ===================================================================
3 --- mpr.spec (revision 49877)
4 +++ mpr.spec (working copy)
5 @@ -1,23 +1,23 @@
6 # ordinal exports
7 - 1 stub @
8 - 2 stub @
9 - 3 stub @
10 - 4 stub @
11 - 5 stub @
12 - 6 stub @
13 - 7 stub @
14 - 8 stub @
15 - 9 stub @
16 -12 stub @
17 -13 stub @
18 -14 stub @
19 -15 stub @
20 -16 stub @
21 -17 stub @
22 -18 stub @
23 -19 stub @
24 -20 stub @
25 -21 stub @
26 + 1 stub MPR_1
27 + 2 stub MPR_2
28 + 3 stub MPR_3
29 + 4 stub MPR_4
30 + 5 stub MPR_5
31 + 6 stub MPR_6
32 + 7 stub MPR_7
33 + 8 stub MPR_8
34 + 9 stub MPR_9
35 +12 stub MPR_12
36 +13 stub MPR_13
37 +14 stub MPR_14
38 +15 stub MPR_15
39 +16 stub MPR_16
40 +17 stub MPR_17
41 +18 stub MPR_18
42 +19 stub MPR_19
43 +20 stub MPR_20
44 +21 stub MPR_21
45 22 stdcall @(long) MPR_Alloc
46 23 stdcall @(ptr long) MPR_ReAlloc
47 24 stdcall @(ptr) MPR_Free
48 Index: wnet.c
49 ===================================================================
50 --- wnet.c (révision 70645)
51 +++ wnet.c (copie de travail)
52 @@ -750,7 +750,12 @@
53 providerTable->table[index].dwEnumScopes & WNNC_ENUM_GLOBAL)
54 {
55 HANDLE handle;
56 + PVOID RemoteName = lpNet->lpRemoteName;
57
58 + if ((lpNet->dwUsage & RESOURCEUSAGE_CONTAINER) &&
59 + RemoteName && !strcmpW(RemoteName, lpNet->lpProvider))
60 + lpNet->lpRemoteName = NULL;
61 +
62 ret = providerTable->table[index].openEnum(
63 dwScope, dwType, dwUsage, lpNet, &handle);
64 if (ret == WN_SUCCESS)
65 @@ -760,6 +765,8 @@
66 ret = *lphEnum ? WN_SUCCESS :
67 WN_OUT_OF_MEMORY;
68 }
69 +
70 + lpNet->lpRemoteName = RemoteName;
71 }
72 else
73 ret = WN_NOT_SUPPORTED;
74 @@ -1553,6 +1553,33 @@
75 dwFlags, NULL, 0, NULL);
76 }
77
78 +/* Convert an ANSI string to wide */
79 +static LPWSTR strdupAtoW( LPCSTR str )
80 +{
81 + LPWSTR ret;
82 + INT len;
83 +
84 + if (!str) return NULL;
85 + len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
86 + ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
87 + if (ret) MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
88 + return ret;
89 +}
90 +
91 +/* Convert ANSI NETRESOURCE struct to wide structure */
92 +static VOID convert_netresourcea_to_w( LPNETRESOURCEA lpNetResourceA,
93 + LPNETRESOURCEW lpNetResourceW )
94 +{
95 + lpNetResourceW->dwScope = lpNetResourceA->dwScope;
96 + lpNetResourceW->dwType = lpNetResourceA->dwType;
97 + lpNetResourceW->dwDisplayType = lpNetResourceA->dwDisplayType;
98 + lpNetResourceW->dwUsage = lpNetResourceA->dwUsage;
99 + lpNetResourceW->lpLocalName = strdupAtoW(lpNetResourceA->lpLocalName);
100 + lpNetResourceW->lpRemoteName = strdupAtoW(lpNetResourceA->lpRemoteName);
101 + lpNetResourceW->lpComment = strdupAtoW(lpNetResourceA->lpComment);
102 + lpNetResourceW->lpProvider = strdupAtoW(lpNetResourceA->lpProvider);
103 +}
104 +
105 /*****************************************************************
106 * WNetUseConnectionA [MPR.@]
107 */
108 @@ -1561,12 +1588,67 @@
109 LPSTR lpAccessName, LPDWORD lpBufferSize,
110 LPDWORD lpResult )
111 {
112 - FIXME( "(%p, %p, %p, %s, 0x%08X, %s, %p, %p), stub\n",
113 - hwndOwner, lpNetResource, lpPassword, debugstr_a(lpUserID), dwFlags,
114 - debugstr_a(lpAccessName), lpBufferSize, lpResult );
115 + NETRESOURCEW resourcesW, *pRes = NULL;
116 + PWSTR passW, userIDW, accessNameW = NULL;
117 + DWORD ret = WN_MORE_DATA;
118 + DWORD bufferSize = 1;
119 + int len;
120
121 - SetLastError(WN_NO_NETWORK);
122 - return WN_NO_NETWORK;
123 + if (lpNetResource)
124 + {
125 + convert_netresourcea_to_w(lpNetResource, &resourcesW);
126 + pRes = &resourcesW;
127 + }
128 +
129 + passW = strdupAtoW(lpPassword);
130 + userIDW = strdupAtoW(lpUserID);
131 +
132 + if (lpAccessName && lpBufferSize && *lpBufferSize)
133 + {
134 + WCHAR probe;
135 +
136 + ret = WNetUseConnectionW(hwndOwner, pRes, passW, userIDW, dwFlags,
137 + &probe, &bufferSize, lpResult);
138 + if (ret == WN_MORE_DATA)
139 + accessNameW = HeapAlloc(GetProcessHeap(), 0, bufferSize * sizeof(WCHAR));
140 + }
141 +
142 + if (ret == WN_MORE_DATA)
143 + {
144 + ret = WNetUseConnectionW(hwndOwner, pRes, passW, userIDW, dwFlags,
145 + accessNameW, &bufferSize, lpResult);
146 + if (ret == WN_SUCCESS)
147 + {
148 + if (lpAccessName && lpBufferSize && *lpBufferSize && accessNameW)
149 + {
150 + len = WideCharToMultiByte(CP_ACP, 0, accessNameW, -1, NULL, 0, NULL, NULL);
151 + if (len)
152 + {
153 + if (len <= *lpBufferSize)
154 + WideCharToMultiByte(CP_ACP, 0, accessNameW, -1, lpAccessName, len, NULL, NULL);
155 + else
156 + {
157 + WNetCancelConnectionW(accessNameW, TRUE);
158 + *lpBufferSize = len;
159 + ret = WN_MORE_DATA;
160 + }
161 + }
162 + }
163 + }
164 + }
165 +
166 + if (lpNetResource)
167 + {
168 + HeapFree(GetProcessHeap(), 0, resourcesW.lpLocalName);
169 + HeapFree(GetProcessHeap(), 0, resourcesW.lpRemoteName);
170 + HeapFree(GetProcessHeap(), 0, resourcesW.lpComment);
171 + HeapFree(GetProcessHeap(), 0, resourcesW.lpProvider);
172 + }
173 + HeapFree(GetProcessHeap(), 0, passW);
174 + HeapFree(GetProcessHeap(), 0, userIDW);
175 + HeapFree(GetProcessHeap(), 0, accessNameW);
176 +
177 + return ret;
178 }
179
180 /*****************************************************************