pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnf41client: nfs41_np fixes&cleanup, docs update+misc, 2024-06-06
Posted by Anonymous on Thu 6th Jun 2024 15:15
raw | new post

  1. From 466cac711f321214eb71d15eeba68f224c669d4f Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Thu, 6 Jun 2024 11:32:45 +0200
  4. Subject: [PATCH 1/6] dll: Add thread ID to nfs41_np debug output
  5.  
  6. Add thread ID to nfs41_np debug output
  7.  
  8. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  9. ---
  10. dll/nfs41_np.c | 15 +++++----------
  11.  1 file changed, 5 insertions(+), 10 deletions(-)
  12.  
  13. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  14. index dfd7b88..1b23eb3 100644
  15. --- a/dll/nfs41_np.c
  16. +++ b/dll/nfs41_np.c
  17. @@ -41,7 +41,7 @@
  18.  #else
  19.  #define DbgP(_x_)
  20.  #endif
  21. -#define TRACE_TAG   L"[NFS41_NP] "
  22. +#define TRACE_TAG   L"[NFS41_NP]"
  23.  #define WNNC_DRIVER(major, minor) ((major * 0x00010000) + (minor))
  24.  
  25.  
  26. @@ -55,17 +55,12 @@ ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  27.      va_list marker;
  28.      va_start(marker, fmt);
  29.  
  30. -#pragma warning( push )
  31. -    /*
  32. -     * Disable "'wcscpy': This function or variable may be unsafe",
  33. -     * in this context it is safe to use
  34. -     */
  35. -#pragma warning (disable : 4996)
  36. -    (void)wcscpy(szbp, TRACE_TAG);
  37. -#pragma warning( pop )
  38. +    (void)StringCchPrintfW(szbp, SZBUFFER_SIZE-(szbp - szbuffer),
  39. +        TRACE_TAG TEXT("[thr=%04x] "), (int)GetCurrentThreadId());
  40.      szbp += wcslen(szbp);
  41.  
  42. -    StringCchVPrintfW(szbp, SZBUFFER_SIZE-(szbp - szbuffer), fmt, marker);
  43. +    (void)StringCchVPrintfW(szbp, SZBUFFER_SIZE-(szbp - szbuffer),
  44. +        fmt, marker);
  45.      szbuffer[SZBUFFER_SIZE-1] = L'\0';
  46.  
  47.      OutputDebugString(szbuffer);
  48. --
  49. 2.45.1
  50.  
  51. From 961cb19c0814ac2dfac901ab5e08f2cefbd49a8e Mon Sep 17 00:00:00 2001
  52. From: Roland Mainz <roland.mainz@nrubsig.org>
  53. Date: Thu, 6 Jun 2024 13:39:20 +0200
  54. Subject: [PATCH 2/6] dll: Minor nfs41_np cleanup
  55.  
  56. Minor nfs41_np cleanup
  57.  
  58. Reviewed-by: Dan Shelton <dan.f.shelton@gmail.com>
  59. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  60. ---
  61. dll/nfs41_np.c | 1340 ++++++++++++++++++++++++------------------------
  62.  1 file changed, 683 insertions(+), 657 deletions(-)
  63.  
  64. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  65. index 1b23eb3..9a4d7cd 100644
  66. --- a/dll/nfs41_np.c
  67. +++ b/dll/nfs41_np.c
  68. @@ -1,5 +1,5 @@
  69. -/* NFSv4.1 client for Windows
  70. - * Copyright (C) 2012 The Regents of the University of Michigan
  71. +/* NFSv4.1 client for Windows
  72. + * Copyright (C) 2012 The Regents of the University of Michigan
  73.   *
  74.   * Olga Kornievskaia <aglo@umich.edu>
  75.   * Casey Bodley <cbodley@umich.edu>
  76. @@ -7,16 +7,16 @@
  77.   *
  78.   * This library is free software; you can redistribute it and/or modify it
  79.   * under the terms of the GNU Lesser General Public License as published by
  80. - * the Free Software Foundation; either version 2.1 of the License, or (at
  81. - * your option) any later version.
  82. - *
  83. - * This library is distributed in the hope that it will be useful, but
  84. - * without any warranty; without even the implied warranty of merchantability
  85. - * or fitness for a particular purpose.  See the GNU Lesser General Public
  86. - * License for more details.
  87. - *
  88. - * You should have received a copy of the GNU Lesser General Public License
  89. - * along with this library; if not, write to the Free Software Foundation,
  90. + * the Free Software Foundation; either version 2.1 of the License, or (at
  91. + * your option) any later version.
  92. + *
  93. + * This library is distributed in the hope that it will be useful, but
  94. + * without any warranty; without even the implied warranty of merchantability
  95. + * or fitness for a particular purpose.  See the GNU Lesser General Public
  96. + * License for more details.
  97. + *
  98. + * You should have received a copy of the GNU Lesser General Public License
  99. + * along with this library; if not, write to the Free Software Foundation,
  100.   * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  101.   */
  102.  
  103. @@ -28,6 +28,7 @@
  104.  #include <npapi.h>
  105.  #include <devioctl.h>
  106.  #include <strsafe.h>
  107. +#include <stdbool.h>
  108.  
  109.  #include "nfs41_build_features.h"
  110.  #include "nfs41_driver.h"
  111. @@ -42,8 +43,10 @@
  112.  #define DbgP(_x_)
  113.  #endif
  114.  #define TRACE_TAG   L"[NFS41_NP]"
  115. -#define WNNC_DRIVER(major, minor) ((major * 0x00010000) + (minor))
  116. +#define WNNC_DRIVER(major, minor) (((major) * 0x00010000) + (minor))
  117.  
  118. +#define PTR2PTRDIFF_T(p) (((char *)(p))-((char *)0))
  119. +#define HANDLE2INT(h) ((int)PTR2PTRDIFF_T(h))
  120.  
  121.  ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  122.  {
  123. @@ -56,7 +59,7 @@ ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  124.      va_start(marker, fmt);
  125.  
  126.      (void)StringCchPrintfW(szbp, SZBUFFER_SIZE-(szbp - szbuffer),
  127. -        TRACE_TAG TEXT("[thr=%04x] "), (int)GetCurrentThreadId());
  128. +        TRACE_TAG L"[thr=%04x] ", (int)GetCurrentThreadId());
  129.      szbp += wcslen(szbp);
  130.  
  131.      (void)StringCchVPrintfW(szbp, SZBUFFER_SIZE-(szbp - szbuffer),
  132. @@ -69,149 +72,142 @@ ULONG _cdecl NFS41DbgPrint(__in LPTSTR fmt, ...)
  133.  
  134.      return rc;
  135.  }
  136. -
  137. -int filter(unsigned int code)
  138. -{
  139. -    DbgP((L"####Got exception %u\n", code));
  140. -    return EXCEPTION_CONTINUE_SEARCH;
  141. -}
  142. -
  143. -DWORD
  144. -OpenSharedMemory(
  145. -    PHANDLE phMutex,
  146. -    PHANDLE phMemory,
  147. -    PVOID   *pMemory)
  148. -/*++
  149. -
  150. -Routine Description:
  151. -
  152. -    This routine opens the shared memory for exclusive manipulation
  153. -
  154. -Arguments:
  155. -
  156. -    phMutex - the mutex handle
  157. -
  158. -    phMemory - the memory handle
  159. -
  160. -    pMemory - a ptr. to the shared memory which is set if successful
  161. -
  162. -Return Value:
  163. -
  164. -    WN_SUCCESS -- if successful
  165. -
  166. ---*/
  167. -{
  168. -    DWORD dwStatus;
  169. -
  170. -    *phMutex = 0;
  171. -    *phMemory = 0;
  172. -    *pMemory = NULL;
  173. -
  174. -    *phMutex = CreateMutex(NULL, FALSE, TEXT(NFS41NP_MUTEX_NAME));
  175. -    if (*phMutex == NULL)
  176. -    {
  177. -        dwStatus = GetLastError();
  178. -        DbgP((TEXT("OpenSharedMemory:  OpenMutex failed\n")));
  179. -        goto OpenSharedMemoryAbort1;
  180. -    }
  181. -
  182. -    WaitForSingleObject(*phMutex, INFINITE);
  183. -
  184. -    *phMemory = OpenFileMapping(FILE_MAP_WRITE,
  185. -                                FALSE,
  186. -                                TEXT(NFS41_USER_SHARED_MEMORY_NAME));
  187. -    if (*phMemory == NULL)
  188. -    {
  189. -        dwStatus = GetLastError();
  190. -        DbgP((TEXT("OpenSharedMemory:  OpenFileMapping failed\n")));
  191. -        goto OpenSharedMemoryAbort2;
  192. -    }
  193. -
  194. -    *pMemory = MapViewOfFile(*phMemory, FILE_MAP_WRITE, 0, 0, 0);
  195. -    if (*pMemory == NULL)
  196. -    {
  197. -        dwStatus = GetLastError();
  198. -        DbgP((TEXT("OpenSharedMemory:  MapViewOfFile failed\n")));
  199. -        goto OpenSharedMemoryAbort3;
  200. -    }
  201. -
  202. -    return ERROR_SUCCESS;
  203. -
  204. -OpenSharedMemoryAbort3:
  205. -    CloseHandle(*phMemory);
  206. -
  207. -OpenSharedMemoryAbort2:
  208. -    ReleaseMutex(*phMutex);
  209. -    CloseHandle(*phMutex);
  210. -    *phMutex = NULL;
  211. -
  212. -OpenSharedMemoryAbort1:
  213. -    DbgP((TEXT("OpenSharedMemory: return dwStatus: %d\n"), dwStatus));
  214. -
  215. -    return dwStatus;
  216. -}
  217. -
  218. -VOID
  219. -CloseSharedMemory(
  220. -    PHANDLE hMutex,
  221. -    PHANDLE hMemory,
  222. -    PVOID   *pMemory)
  223. -/*++
  224. -
  225. -Routine Description:
  226. -
  227. -    This routine relinquishes control of the shared memory after exclusive
  228. -    manipulation
  229. -
  230. -Arguments:
  231. -
  232. -    hMutex - the mutex handle
  233. -
  234. -    hMemory  - the memory handle
  235. -
  236. -    pMemory - a ptr. to the shared memory which is set if successful
  237. -
  238. -Return Value:
  239. -
  240. ---*/
  241. -{
  242. -    if (*pMemory)
  243. -    {
  244. -        UnmapViewOfFile(*pMemory);
  245. -        *pMemory = NULL;
  246. -    }
  247. -    if (*hMemory)
  248. -    {
  249. -        CloseHandle(*hMemory);
  250. -        *hMemory = 0;
  251. -    }
  252. -    if (*hMutex)
  253. -    {
  254. -        if (ReleaseMutex(*hMutex) == FALSE)
  255. -        {
  256. -            DbgP((TEXT("CloseSharedMemory: ReleaseMutex error: %d\n"), GetLastError()));
  257. -        }
  258. -        CloseHandle(*hMutex);
  259. -        *hMutex = 0;
  260. -    }
  261. -}
  262. -
  263. -static DWORD StoreConnectionInfo(
  264. -    IN LPCWSTR LocalName,
  265. -    IN LPCWSTR ConnectionName,
  266. -    IN USHORT ConnectionNameLength,
  267. -    IN LPNETRESOURCE lpNetResource)
  268. -{
  269. -    DWORD status;
  270. -    HANDLE hMutex, hMemory;
  271. -    PNFS41NP_SHARED_MEMORY pSharedMemory;
  272. -    PNFS41NP_NETRESOURCE pNfs41NetResource;
  273. -    INT Index;
  274. -    BOOLEAN FreeEntryFound = FALSE;
  275. +
  276. +int filter(unsigned int code)
  277. +{
  278. +    DbgP((L"####Got exception %u\n", code));
  279. +    return EXCEPTION_CONTINUE_SEARCH;
  280. +}
  281. +
  282. +static
  283. +DWORD OpenSharedMemory(
  284. +    PHANDLE phMutex,
  285. +    PHANDLE phMemory,
  286. +    PVOID   *pMemory)
  287. +/*++
  288. +
  289. +Routine Description:
  290. +
  291. +    This routine opens the shared memory for exclusive manipulation
  292. +
  293. +Arguments:
  294. +    phMutex - the mutex handle
  295. +    phMemory - the memory handle
  296. +    pMemory - a ptr. to the shared memory which is set if successful
  297. +
  298. +Return Value:
  299. +    WN_SUCCESS -- if successful
  300. +
  301. +--*/
  302. +{
  303. +    DWORD dwStatus;
  304. +
  305. +    *phMutex = 0;
  306. +    *phMemory = 0;
  307. +    *pMemory = NULL;
  308. +
  309. +    DbgP((L"--> OpenSharedMemory()\n"));
  310. +
  311. +    *phMutex = CreateMutexA(NULL, FALSE, NFS41NP_MUTEX_NAME);
  312. +    if (*phMutex == NULL) {
  313. +        dwStatus = GetLastError();
  314. +        DbgP((L"OpenSharedMemory: "
  315. +            "CreateMutexA() failed, lasterr=%d\n",
  316. +            dwStatus));
  317. +        goto OpenSharedMemoryAbort1;
  318. +    }
  319. +
  320. +    (void)WaitForSingleObject(*phMutex, INFINITE);
  321. +
  322. +    *phMemory = OpenFileMappingA(FILE_MAP_WRITE,
  323. +                                FALSE,
  324. +                                NFS41_USER_SHARED_MEMORY_NAME);
  325. +    if (*phMemory == NULL) {
  326. +        dwStatus = GetLastError();
  327. +        DbgP((L"OpenFileMappingA() failed, lasterr=%d\n", dwStatus));
  328. +        goto OpenSharedMemoryAbort2;
  329. +    }
  330. +
  331. +    *pMemory = MapViewOfFile(*phMemory, FILE_MAP_WRITE, 0, 0, 0);
  332. +    if (*pMemory == NULL) {
  333. +        dwStatus = GetLastError();
  334. +        DbgP((L"MapViewOfFile failed, lasterr=%d\n", dwStatus));
  335. +        goto OpenSharedMemoryAbort3;
  336. +    }
  337. +
  338. +    DbgP((L"<-- OpenSharedMemory() returns ERROR_SUCCESS\n"));
  339. +    return ERROR_SUCCESS;
  340. +
  341. +OpenSharedMemoryAbort3:
  342. +    (void)CloseHandle(*phMemory);
  343. +
  344. +OpenSharedMemoryAbort2:
  345. +    (void)ReleaseMutex(*phMutex);
  346. +    (void)CloseHandle(*phMutex);
  347. +    *phMutex = NULL;
  348. +
  349. +OpenSharedMemoryAbort1:
  350. +    DbgP((L"<-- OpenSharedMemory: return dwStatus: %d\n", dwStatus));
  351. +
  352. +    return dwStatus;
  353. +}
  354. +
  355. +static
  356. +VOID CloseSharedMemory(
  357. +    PHANDLE hMutex,
  358. +    PHANDLE hMemory,
  359. +    PVOID   *pMemory)
  360. +/*++
  361. +
  362. +Routine Description:
  363. +    This routine relinquishes control of the shared memory after
  364. +    exclusive manipulation
  365. +
  366. +Arguments:
  367. +    hMutex - the mutex handle
  368. +    hMemory  - the memory handle
  369. +    pMemory - a ptr. to the shared memory which is set if successful
  370. +
  371. +Return Value:
  372. +
  373. +--*/
  374. +{
  375. +    DbgP((L"--> CloseSharedMemory\n"));
  376. +    if (*pMemory) {
  377. +        (void)UnmapViewOfFile(*pMemory);
  378. +        *pMemory = NULL;
  379. +    }
  380. +    if (*hMemory) {
  381. +        (void)CloseHandle(*hMemory);
  382. +        *hMemory = 0;
  383. +    }
  384. +    if (*hMutex) {
  385. +        if (ReleaseMutex(*hMutex) == FALSE) {
  386. +            DbgP((L"ReleaseMutex error: %d\n", (int)GetLastError()));
  387. +        }
  388. +        (void)CloseHandle(*hMutex);
  389. +        *hMutex = 0;
  390. +    }
  391. +    DbgP((L"<-- CloseSharedMemory\n"));
  392. +}
  393. +
  394. +static DWORD StoreConnectionInfo(
  395. +    IN LPCWSTR LocalName,
  396. +    IN LPCWSTR ConnectionName,
  397. +    IN USHORT ConnectionNameLength,
  398. +    IN LPNETRESOURCE lpNetResource)
  399. +{
  400. +    DWORD status;
  401. +    HANDLE hMutex, hMemory;
  402. +    PNFS41NP_SHARED_MEMORY pSharedMemory;
  403. +    PNFS41NP_NETRESOURCE pNfs41NetResource;
  404. +    INT i;
  405. +    bool FreeEntryFound = false;
  406.  
  407.      DbgP((L"--> StoreConnectionInfo\n"));
  408.  
  409. -    status = OpenSharedMemory(&hMutex, &hMemory, &(PVOID)pSharedMemory);
  410. +    status = OpenSharedMemory(&hMutex, &hMemory,
  411. +        &(PVOID)pSharedMemory);
  412.      if (status)
  413.          goto out;
  414.  
  415. @@ -219,215 +215,232 @@ static DWORD StoreConnectionInfo(
  416.          pSharedMemory->NextAvailableIndex,
  417.          pSharedMemory->NumberOfResourcesInUse));
  418.  
  419. -    for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
  420. -    {
  421. -        if (!pSharedMemory->NetResources[Index].InUse)
  422. -        {
  423. -            FreeEntryFound = TRUE;
  424. -            DbgP((TEXT("Reusing existing index %d\n"), Index));
  425. -            break;
  426. -        }
  427. -    }
  428. -
  429. -    if (!FreeEntryFound)
  430. -    {
  431. -        if (pSharedMemory->NextAvailableIndex >= NFS41NP_MAX_DEVICES) {
  432. -            status = WN_NO_MORE_DEVICES;
  433. -            goto out_close;
  434. -        }
  435. -        Index = pSharedMemory->NextAvailableIndex++;
  436. -        DbgP((TEXT("Using new index %d\n"), Index));
  437. -    }
  438. -
  439. -    pSharedMemory->NumberOfResourcesInUse += 1;
  440. -
  441. -    pNfs41NetResource = &pSharedMemory->NetResources[Index];
  442. -
  443. -    pNfs41NetResource->InUse                = TRUE;
  444. -    pNfs41NetResource->dwScope              = lpNetResource->dwScope;
  445. -    pNfs41NetResource->dwType               = lpNetResource->dwType;
  446. -    pNfs41NetResource->dwDisplayType        = lpNetResource->dwDisplayType;
  447. -    pNfs41NetResource->dwUsage              = RESOURCEUSAGE_CONNECTABLE;
  448. -    pNfs41NetResource->LocalNameLength      = (USHORT)(wcslen(LocalName) + 1) * sizeof(WCHAR);
  449. -    pNfs41NetResource->RemoteNameLength     = (USHORT)(wcslen(lpNetResource->lpRemoteName) + 1) * sizeof(WCHAR);
  450. -    pNfs41NetResource->ConnectionNameLength = ConnectionNameLength;
  451. -
  452. -    StringCchCopy(pNfs41NetResource->LocalName,
  453. -        pNfs41NetResource->LocalNameLength,
  454. -        LocalName);
  455. -    StringCchCopy(pNfs41NetResource->RemoteName,
  456. -        pNfs41NetResource->RemoteNameLength,
  457. -        lpNetResource->lpRemoteName);
  458. -    StringCchCopy(pNfs41NetResource->ConnectionName,
  459. -        pNfs41NetResource->ConnectionNameLength,
  460. -        ConnectionName);
  461. -
  462. -    // TODO: copy mount options -cbodley
  463. -
  464. +    for (i = 0; i < pSharedMemory->NextAvailableIndex; i++)
  465. +    {
  466. +        if (!pSharedMemory->NetResources[i].InUse) {
  467. +            FreeEntryFound = true;
  468. +            DbgP((L"Reusing existing index %d\n", i));
  469. +            break;
  470. +        }
  471. +    }
  472. +
  473. +    if (!FreeEntryFound) {
  474. +        if (pSharedMemory->NextAvailableIndex >= NFS41NP_MAX_DEVICES) {
  475. +            status = WN_NO_MORE_DEVICES;
  476. +            goto out_close;
  477. +        }
  478. +        i = pSharedMemory->NextAvailableIndex++;
  479. +        DbgP((L"Using new index %d\n", i));
  480. +    }
  481. +
  482. +    pSharedMemory->NumberOfResourcesInUse += 1;
  483. +
  484. +    pNfs41NetResource = &pSharedMemory->NetResources[i];
  485. +
  486. +    pNfs41NetResource->InUse            = TRUE;
  487. +    pNfs41NetResource->dwScope          = lpNetResource->dwScope;
  488. +    pNfs41NetResource->dwType           = lpNetResource->dwType;
  489. +    pNfs41NetResource->dwDisplayType    =
  490. +        lpNetResource->dwDisplayType;
  491. +    pNfs41NetResource->dwUsage          = RESOURCEUSAGE_CONNECTABLE;
  492. +    pNfs41NetResource->LocalNameLength  =
  493. +        (USHORT)(wcslen(LocalName) + 1) * sizeof(WCHAR);
  494. +    pNfs41NetResource->RemoteNameLength =
  495. +        (USHORT)(wcslen(lpNetResource->lpRemoteName)+1)*sizeof(WCHAR);
  496. +    pNfs41NetResource->ConnectionNameLength = ConnectionNameLength;
  497. +
  498. +    (void)StringCchCopy(pNfs41NetResource->LocalName,
  499. +        pNfs41NetResource->LocalNameLength,
  500. +        LocalName);
  501. +    (void)StringCchCopy(pNfs41NetResource->RemoteName,
  502. +        pNfs41NetResource->RemoteNameLength,
  503. +        lpNetResource->lpRemoteName);
  504. +    (void)StringCchCopy(pNfs41NetResource->ConnectionName,
  505. +        pNfs41NetResource->ConnectionNameLength,
  506. +        ConnectionName);
  507. +
  508. +    // TODO: copy mount options -cbodley
  509. +
  510.  out_close:
  511.      CloseSharedMemory(&hMutex, &hMemory, &(PVOID)pSharedMemory);
  512.  out:
  513. -    DbgP((TEXT("<-- StoreConnectionInfo returns %d\n"), (int)status));
  514. +    DbgP((L"<-- StoreConnectionInfo returns %d\n", (int)status));
  515.  
  516.      return status;
  517.  }
  518.  
  519. -ULONG
  520. -SendTo_NFS41Driver(
  521. -    IN ULONG            IoctlCode,
  522. -    IN PVOID            InputDataBuf,
  523. -    IN ULONG            InputDataLen,
  524. -    IN PVOID            OutputDataBuf,
  525. -    IN PULONG           pOutputDataLen)
  526. -{
  527. -    HANDLE  DeviceHandle;       // The mini rdr device handle
  528. +static
  529. +ULONG SendTo_NFS41Driver(
  530. +    IN ULONG            IoctlCode,
  531. +    IN PVOID            InputDataBuf,
  532. +    IN ULONG            InputDataLen,
  533. +    IN PVOID            OutputDataBuf,
  534. +    IN PULONG           pOutputDataLen)
  535. +{
  536. +    HANDLE  DeviceHandle;       // The mini rdr device handle
  537.      BOOL    rc = FALSE;
  538.      ULONG   Status;
  539.  
  540. -    DbgP((TEXT("--> SendTo_NFS41Driver\n")));
  541. +    DbgP((L"--> SendTo_NFS41Driver\n"));
  542.  
  543.      Status = WN_SUCCESS;
  544. -    DbgP((L"calling CreateFile\n"));
  545. -    DeviceHandle = CreateFile(
  546. +    DbgP((L"calling CreateFileW\n"));
  547. +    DeviceHandle = CreateFileW(
  548.          NFS41_USER_DEVICE_NAME,
  549.          GENERIC_READ | GENERIC_WRITE,
  550. -        FILE_SHARE_READ | FILE_SHARE_WRITE,
  551. -        (LPSECURITY_ATTRIBUTES)NULL,
  552. -        OPEN_EXISTING,
  553. +        FILE_SHARE_READ | FILE_SHARE_WRITE,
  554. +        (LPSECURITY_ATTRIBUTES)NULL,
  555. +        OPEN_EXISTING,
  556.          0,
  557. -        (HANDLE) NULL );
  558. +        (HANDLE)NULL);
  559. +    DbgP((L"after CreateFileW() Device Handle\n"));
  560.  
  561. -    DbgP((L"after CreateFile Device Handle\n"));
  562. -    if ( INVALID_HANDLE_VALUE != DeviceHandle )
  563. -    {
  564. -        __try {
  565. +    if (DeviceHandle == INVALID_HANDLE_VALUE) {
  566. +        Status = GetLastError();
  567. +        DbgP((L"SendTo_NFS41Driver: error %08lx opening device\n",
  568. +            Status));
  569. +        goto out;
  570. +    }
  571. +
  572. +    __try {
  573.          DbgP((L"calling DeviceIoControl\n"));
  574.          rc = DeviceIoControl(
  575.              DeviceHandle,
  576.              IoctlCode,
  577. -            InputDataBuf,
  578. -            InputDataLen,
  579. -            OutputDataBuf,
  580. -            *pOutputDataLen,
  581. -            pOutputDataLen,
  582. -            NULL );
  583. -        } __except(filter(GetExceptionCode())) {
  584. -            DbgP((L"#### In except\n"));
  585. -        }
  586. -        DbgP((L"returned from DeviceIoControl %08lx\n", rc));
  587. -            if ( !rc )
  588. -            {
  589. -                DbgP((L"SendTo_NFS41Driver: returning error from DeviceIoctl\n"));
  590. -                Status = GetLastError( );
  591. -            }
  592. -            else
  593. -            {
  594. -                DbgP((L"SendTo_NFS41Driver: The DeviceIoctl call succeded\n"));
  595. -            }
  596. -            CloseHandle(DeviceHandle);
  597. +            InputDataBuf,
  598. +            InputDataLen,
  599. +            OutputDataBuf,
  600. +            *pOutputDataLen,
  601. +            pOutputDataLen,
  602. +            NULL);
  603. +    } __except(filter(GetExceptionCode())) {
  604. +        DbgP((L"#### DeviceIoControl() exception\n"));
  605.      }
  606. -    else
  607. -    {
  608. -        Status = GetLastError( );
  609. -        DbgP((L"SendTo_NFS41Driver: error %08lx opening device \n", Status));
  610. +    Status = GetLastError();
  611. +    DbgP((L"DeviceIoControl returned rc=%08lx\n", rc));
  612. +    if (!rc) {
  613. +        DbgP((L"SendTo_NFS41Driver: "
  614. +            "returning error from DeviceIoctl\n"));
  615.      }
  616. -    DbgP((TEXT("<-- SendTo_NFS41Driver returns %d\n"), Status));
  617. +    else {
  618. +        DbgP((L"SendTo_NFS41Driver: DeviceIoctl() success\n"));
  619. +        Status = WN_SUCCESS;
  620. +    }
  621. +    (void)CloseHandle(DeviceHandle);
  622. +out:
  623. +    DbgP((L"<-- SendTo_NFS41Driver returns %d\n", Status));
  624.      return Status;
  625.  }
  626.  
  627. -DWORD APIENTRY
  628. -NPGetCaps(
  629. -    DWORD nIndex )
  630. +static
  631. +const char *netcaps2string(DWORD idx)
  632.  {
  633. -   DWORD rc = 0;
  634. +#define NETCAPS_TO_STRLITERAL(e) case e: return #e
  635. +    switch(idx) {
  636. +        NETCAPS_TO_STRLITERAL(WNNC_SPEC_VERSION);
  637. +        NETCAPS_TO_STRLITERAL(WNNC_NET_TYPE);
  638. +        NETCAPS_TO_STRLITERAL(WNNC_DRIVER_VERSION);
  639. +        NETCAPS_TO_STRLITERAL(WNNC_CONNECTION);
  640. +        NETCAPS_TO_STRLITERAL(WNNC_ENUMERATION);
  641. +        NETCAPS_TO_STRLITERAL(WNNC_START);
  642. +        NETCAPS_TO_STRLITERAL(WNNC_USER);
  643. +        NETCAPS_TO_STRLITERAL(WNNC_DIALOG);
  644. +        NETCAPS_TO_STRLITERAL(WNNC_ADMIN);
  645. +        NETCAPS_TO_STRLITERAL(WNNC_CONNECTION_FLAGS);
  646. +    }
  647. +    return "<unknown WNNC_* index>";
  648. +}
  649.  
  650. -    DbgP(( L"GetNetCaps %d\n", nIndex ));
  651. -    switch ( nIndex )
  652. -    {
  653. +DWORD APIENTRY
  654. +NPGetCaps(
  655. +    DWORD nIndex )
  656. +{
  657. +    DWORD rc = 0;
  658. +
  659. +    DbgP((L"--> GetNetCaps(nIndex='%S'(=%d)\n",
  660. +        netcaps2string(nIndex), nIndex));
  661. +    switch(nIndex) {
  662.          case WNNC_SPEC_VERSION:
  663. -            rc = WNNC_SPEC_VERSION51;
  664. -            break;
  665. -
  666. -        case WNNC_NET_TYPE:
  667. -            rc = WNNC_NET_RDR2SAMPLE;
  668. -            break;
  669. -
  670. -        case WNNC_DRIVER_VERSION:
  671. -            rc = WNNC_DRIVER(1, 0);
  672. -            break;
  673. -
  674. -        case WNNC_CONNECTION:
  675. -            rc = WNNC_CON_GETCONNECTIONS |
  676. -                 WNNC_CON_CANCELCONNECTION |
  677. -                 WNNC_CON_ADDCONNECTION |
  678. -                 WNNC_CON_ADDCONNECTION3;
  679. -            break;
  680. -
  681. -        case WNNC_ENUMERATION:
  682. -            rc = WNNC_ENUM_LOCAL;
  683. -            break;
  684. -
  685. -        case WNNC_START:
  686. -            rc = 1;
  687. -            break;
  688. -
  689. -        case WNNC_USER:
  690. -        case WNNC_DIALOG:
  691. -        case WNNC_ADMIN:
  692. -        default:
  693. +            rc = WNNC_SPEC_VERSION51;
  694. +            break;
  695. +        case WNNC_NET_TYPE:
  696. +            rc = WNNC_NET_RDR2SAMPLE;
  697. +            break;
  698. +        case WNNC_DRIVER_VERSION:
  699. +            rc = WNNC_DRIVER(1, 0);
  700. +            break;
  701. +        case WNNC_CONNECTION:
  702. +            rc = WNNC_CON_GETCONNECTIONS |
  703. +                 WNNC_CON_CANCELCONNECTION |
  704. +                 WNNC_CON_ADDCONNECTION |
  705. +                 WNNC_CON_ADDCONNECTION3;
  706. +            break;
  707. +        case WNNC_ENUMERATION:
  708. +            rc = WNNC_ENUM_LOCAL;
  709. +            break;
  710. +        case WNNC_START:
  711. +            rc = 1;
  712. +            break;
  713. +        case WNNC_USER:
  714. +        case WNNC_DIALOG:
  715. +        case WNNC_ADMIN:
  716. +        case WNNC_CONNECTION_FLAGS:
  717. +        default:
  718.              rc = 0;
  719.              break;
  720.      }
  721.  
  722. +    DbgP((L"<-- GetNetCaps returns %d\n", (int)rc));
  723.      return rc;
  724.  }
  725.  
  726. -DWORD APIENTRY
  727. -NPLogonNotify(
  728. -    __in PLUID   lpLogonId,
  729. -    __in PCWSTR lpAuthentInfoType,
  730. -    __in PVOID  lpAuthentInfo,
  731. -    __in PCWSTR lpPreviousAuthentInfoType,
  732. -    __in PVOID  lpPreviousAuthentInfo,
  733. -    __in PWSTR  lpStationName,
  734. -    __in PVOID  StationHandle,
  735. +DWORD APIENTRY
  736. +NPLogonNotify(
  737. +    __in PLUID   lpLogonId,
  738. +    __in PCWSTR lpAuthentInfoType,
  739. +    __in PVOID  lpAuthentInfo,
  740. +    __in PCWSTR lpPreviousAuthentInfoType,
  741. +    __in PVOID  lpPreviousAuthentInfo,
  742. +    __in PWSTR  lpStationName,
  743. +    __in PVOID  StationHandle,
  744.      __out PWSTR  *lpLogonScript)
  745.  {
  746.      *lpLogonScript = NULL;
  747. -    DbgP(( L"NPLogonNotify: returning WN_SUCCESS\n" ));
  748. +    DbgP((L"NPLogonNotify: returning WN_SUCCESS\n"));
  749.      return WN_SUCCESS;
  750.  }
  751.  
  752. -DWORD APIENTRY
  753. -NPPasswordChangeNotify (
  754. -    __in LPCWSTR lpAuthentInfoType,
  755. -    __in LPVOID  lpAuthentInfo,
  756. -    __in LPCWSTR lpPreviousAuthentInfoType,
  757. -    __in LPVOID  lpPreviousAuthentInfo,
  758. -    __in LPWSTR  lpStationName,
  759. +DWORD APIENTRY
  760. +NPPasswordChangeNotify (
  761. +    __in LPCWSTR lpAuthentInfoType,
  762. +    __in LPVOID  lpAuthentInfo,
  763. +    __in LPCWSTR lpPreviousAuthentInfoType,
  764. +    __in LPVOID  lpPreviousAuthentInfo,
  765. +    __in LPWSTR  lpStationName,
  766.      LPVOID  StationHandle,
  767.      DWORD   dwChangeInfo )
  768.  {
  769. -    DbgP(( L"NPPasswordChangeNotify: WN_NOT_SUPPORTED\n" ));
  770. -    SetLastError( WN_NOT_SUPPORTED );
  771. +    DbgP(( L"NPPasswordChangeNotify: WN_NOT_SUPPORTED\n"));
  772. +    SetLastError(WN_NOT_SUPPORTED);
  773.      return WN_NOT_SUPPORTED;
  774.  }
  775. -
  776. -DWORD APIENTRY
  777. -NPAddConnection(
  778. -    __in LPNETRESOURCE   lpNetResource,
  779. -    __in_opt LPWSTR      lpPassword,
  780. -    __in_opt LPWSTR      lpUserName )
  781. -{
  782. -    return NPAddConnection3( NULL, lpNetResource, lpPassword, lpUserName, 0 );
  783. -}
  784. -
  785. -DWORD APIENTRY
  786. -NPAddConnection3(
  787. -    __in HWND           hwndOwner,
  788. -    __in LPNETRESOURCE  lpNetResource,
  789. -    __in_opt LPWSTR     lpPassword,
  790. -    __in_opt LPWSTR     lpUserName,
  791. +
  792. +DWORD APIENTRY
  793. +NPAddConnection(
  794. +    __in LPNETRESOURCE   lpNetResource,
  795. +    __in_opt LPWSTR      lpPassword,
  796. +    __in_opt LPWSTR      lpUserName )
  797. +{
  798. +    return NPAddConnection3(NULL, lpNetResource, lpPassword,
  799. +        lpUserName, 0);
  800. +}
  801. +
  802. +DWORD APIENTRY
  803. +NPAddConnection3(
  804. +    __in HWND           hwndOwner,
  805. +    __in LPNETRESOURCE  lpNetResource,
  806. +    __in_opt LPWSTR     lpPassword,
  807. +    __in_opt LPWSTR     lpUserName,
  808.      __in DWORD          dwFlags)
  809.  {
  810.      DWORD   Status;
  811. @@ -443,7 +456,9 @@ NPAddConnection3(
  812.      DbgP((L"-->  NPAddConnection3(lpNetResource->lpLocalName='%s', "
  813.          L"lpNetResource->lpRemoteName='%s', "
  814.          L"username='%s', passwd='%s')\n",
  815. -        lpNetResource->lpLocalName, lpNetResource->lpRemoteName, lpUserName, lpPassword));
  816. +        lpNetResource->lpLocalName,
  817. +        lpNetResource->lpRemoteName,lpUserName,
  818. +        lpPassword));
  819.  
  820.      Status = InitializeConnectionInfo(&Connection,
  821.          (PMOUNT_OPTION_BUFFER)lpNetResource->lpComment,
  822. @@ -453,12 +468,13 @@ NPAddConnection3(
  823.          goto out;
  824.      }
  825.  
  826. -    //  \device\miniredirector\;<DriveLetter>:\Server\Share
  827. -
  828. +    //  \device\miniredirector\;<DriveLetter>:\Server\Share
  829. +
  830.      // local name, must start with "X:"
  831.      if (lstrlen(lpNetResource->lpLocalName) < 2 ||
  832.          lpNetResource->lpLocalName[1] != L':') {
  833. -        DbgP((L"lpNetResource->lpLocalName(='%s') is not a device letter\n",
  834. +        DbgP((L"lpNetResource->lpLocalName(='%s') "
  835. +            "is not a device letter\n",
  836.              lpNetResource->lpLocalName));
  837.          Status = WN_BAD_LOCALNAME;
  838.          goto out;
  839. @@ -467,65 +483,73 @@ NPAddConnection3(
  840.      LocalName[0] = towupper(lpNetResource->lpLocalName[0]);
  841.      LocalName[1] = L':';
  842.      LocalName[2] = L'\0';
  843. -    StringCchCopyW( ConnectionName, NFS41_SYS_MAX_PATH_LEN, NFS41_DEVICE_NAME );
  844. -    StringCchCatW( ConnectionName, NFS41_SYS_MAX_PATH_LEN, L"\\;" );
  845. -    StringCchCatW( ConnectionName, NFS41_SYS_MAX_PATH_LEN, LocalName );
  846. +    (void)StringCchCopyW(ConnectionName,
  847. +        NFS41_SYS_MAX_PATH_LEN, NFS41_DEVICE_NAME);
  848. +    (void)StringCchCatW(ConnectionName,
  849. +        NFS41_SYS_MAX_PATH_LEN, L"\\;");
  850. +    (void)StringCchCatW(ConnectionName,
  851. +        NFS41_SYS_MAX_PATH_LEN, LocalName);
  852.  
  853.      // remote name, must start with "\\"
  854. -    if (lpNetResource->lpRemoteName[0] == L'\0' ||
  855. -        lpNetResource->lpRemoteName[0] != L'\\' ||
  856. -        lpNetResource->lpRemoteName[1] != L'\\') {
  857. -        Status = WN_BAD_NETNAME;
  858. -        goto out;
  859. -    }
  860. -
  861. -    /* note: remotename comes as \\server but we need to add \server thus +1 pointer */
  862. -    p = lpNetResource->lpRemoteName + 1;
  863. -    ServerName[0] = L'\\';
  864. -    i = 1;
  865. -    for(;;) {
  866. -        /* convert servername ending unix slash to windows slash */
  867. -        if (p[i] == L'/')
  868. -            p[i] = L'\\';
  869. -        /* deal with servername ending with any slash */
  870. -        if (p[i] == L'\0')
  871. -            p[i] = L'\\';
  872. -        ServerName[i] = p[i];
  873. -        if (p[i] == L'\\') break;
  874. +    if ((lpNetResource->lpRemoteName[0] == L'\0') ||
  875. +        (lpNetResource->lpRemoteName[0] != L'\\') ||
  876. +        (lpNetResource->lpRemoteName[1] != L'\\')) {
  877. +        Status = WN_BAD_NETNAME;
  878. +        goto out;
  879. +    }
  880. +
  881. +    /*
  882. +     * Note: remotename comes as \\server but we need to
  883. +     * add \server thus +1 pointer
  884. +     */
  885. +    p = lpNetResource->lpRemoteName + 1;
  886. +    ServerName[0] = L'\\';
  887. +    i = 1;
  888. +    for(;;) {
  889. +        /* convert servername ending unix slash to windows slash */
  890. +        if (p[i] == L'/')
  891. +            p[i] = L'\\';
  892. +        /* deal with servername ending with any slash */
  893. +        if (p[i] == L'\0')
  894. +            p[i] = L'\\';
  895. +        ServerName[i] = p[i];
  896. +        if (p[i] == L'\\') break;
  897.          i++;
  898.      }
  899.      ServerName[i] = L'\0';
  900.  
  901. -    StringCchCatW( ConnectionName, NFS41_SYS_MAX_PATH_LEN, ServerName);
  902. +    (void)StringCchCatW(ConnectionName,
  903. +        NFS41_SYS_MAX_PATH_LEN, ServerName);
  904.  #ifndef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
  905.      /* insert the "nfs4" in between the server name and the path,
  906.       * just to make sure all calls to our driver come thru this */
  907. -    StringCchCatW( ConnectionName, NFS41_SYS_MAX_PATH_LEN, L"\\nfs4" );
  908. +    (void)StringCchCatW(ConnectionName,
  909. +        NFS41_SYS_MAX_PATH_LEN, L"\\nfs4");
  910.  #endif /* NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX */
  911.  
  912.  #ifdef CONVERT_2_UNIX_SLASHES
  913.      /* convert all windows slashes to unix slashes */
  914. -    {
  915. -        PWCHAR q = p;
  916. -        DWORD j = 0;
  917. -        for(;;) {
  918. -            if(q[j] == L'\0') break;
  919. -            if (q[j] == L'\\') q[j] = L'/';
  920. -            j++;
  921. -        }
  922. -    }
  923. -#else
  924. -    /* convert all unix slashes to windows slashes */
  925. -    {
  926. -        PWCHAR q = p;
  927. -        DWORD j = 0;
  928. -        for(;;) {
  929. -            if(q[j] == L'\0') break;
  930. -            if (q[j] == L'/') q[j] = L'\\';
  931. -            j++;
  932. +    {
  933. +        PWCHAR q = p;
  934. +        DWORD j = 0;
  935. +        for(;;) {
  936. +            if(q[j] == L'\0') break;
  937. +            if (q[j] == L'\\') q[j] = L'/';
  938. +            j++;
  939.          }
  940.      }
  941. -#endif
  942. +#else
  943. +    /* convert all unix slashes to windows slashes */
  944. +    {
  945. +        PWCHAR q = p;
  946. +        DWORD j = 0;
  947. +        for(;;) {
  948. +            if(q[j] == L'\0') break;
  949. +            if (q[j] == L'/') q[j] = L'\\';
  950. +            j++;
  951. +        }
  952. +    }
  953. +#endif /* CONVERT_2_UNIX_SLASHES */
  954.  
  955.  #if 1
  956.      /*
  957. @@ -554,15 +578,17 @@ NPAddConnection3(
  958.  
  959.  #ifdef NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX
  960.      if (wcsncmp(&p[i], L"\\nfs4", 5) != 0) {
  961. -        DbgP(( L"Connection name '%s' not prefixed with '\\nfs41'\n", &p[i]));
  962. +        DbgP((L"Connection name '%s' not prefixed with '\\nfs41'\n",
  963. +            &p[i]));
  964.          Status = WN_BAD_NETNAME;
  965.          goto out;
  966.      }
  967.  #endif /* NFS41_DRIVER_MOUNT_DOES_NFS4_PREFIX */
  968.  
  969. -    StringCchCatW( ConnectionName, NFS41_SYS_MAX_PATH_LEN, &p[i]);
  970. -    DbgP(( L"Full Connect Name: '%s'\n", ConnectionName ));
  971. -    DbgP(( L"Full Connect Name Length: %d %d\n",
  972. +    (void)StringCchCatW(ConnectionName,
  973. +        NFS41_SYS_MAX_PATH_LEN, &p[i]);
  974. +    DbgP((L"Full Connect Name: '%s'\n", ConnectionName));
  975. +    DbgP((L"Full Connect Name Length: %d %d\n",
  976.          (wcslen(ConnectionName) + 1) * sizeof(WCHAR),
  977.          (lstrlen(ConnectionName) + 1) * sizeof(WCHAR)));
  978.  
  979. @@ -577,341 +603,340 @@ NPAddConnection3(
  980.          goto out;
  981.      }
  982.  
  983. -    MarshalConnectionInfo(&Connection);
  984. -
  985. -    Status = SendTo_NFS41Driver( IOCTL_NFS41_ADDCONN,
  986. +    MarshalConnectionInfo(&Connection);
  987. +
  988. +    Status = SendTo_NFS41Driver(IOCTL_NFS41_ADDCONN,
  989.          Connection.Buffer, Connection.BufferSize,
  990. -        NULL, &CopyBytes );
  991. +        NULL, &CopyBytes);
  992.      DbgP(( L"SendTo_NFS41Driver() returned %d\n", Status));
  993.      if (Status) {
  994.          goto out;
  995.      }
  996.  
  997. -    DbgP((L"DefineDosDevice(lpNetResource->lpLocalName='%s',ConnectionName='%s')\n", lpNetResource->lpLocalName, ConnectionName));
  998. -    if ( !DefineDosDevice( DDD_RAW_TARGET_PATH |
  999. -                           DDD_NO_BROADCAST_SYSTEM,
  1000. -                           lpNetResource->lpLocalName,
  1001. -                           ConnectionName ) ) {
  1002. +    DbgP((L"DefineDosDevice(lpNetResource->lpLocalName='%s', "
  1003. +        L"ConnectionName='%s')\n",
  1004. +        lpNetResource->lpLocalName, ConnectionName));
  1005. +    if (!DefineDosDevice(DDD_RAW_TARGET_PATH |
  1006. +        DDD_NO_BROADCAST_SYSTEM,
  1007. +        lpNetResource->lpLocalName,
  1008. +        ConnectionName)) {
  1009.          Status = GetLastError();
  1010. -        DbgP(( L"DefineDosDevice(lpNetResource->lpLocalName='%s',"
  1011. +        DbgP((L"DefineDosDevice(lpNetResource->lpLocalName='%s',"
  1012.              L"ConnectionName='%s') failed with %d\n",
  1013.              lpNetResource->lpLocalName, ConnectionName, Status));
  1014.          goto out_delconn;
  1015.      }
  1016.  
  1017. -    // The connection was established and the local device mapping
  1018. -    // added. Include this in the list of mapped devices.
  1019. +    // The connection was established and the local device mapping
  1020. +    // added. Include this in the list of mapped devices.
  1021.      Status = StoreConnectionInfo(LocalName, ConnectionName,
  1022.          Connection.Buffer->NameLength, lpNetResource);
  1023.      if (Status) {
  1024. -        DbgP(( L"StoreConnectionInfo failed with %d\n", Status));
  1025. +        DbgP((L"StoreConnectionInfo failed with %d\n", Status));
  1026.          goto out_undefine;
  1027.      }
  1028.  
  1029.  out:
  1030.      FreeConnectionInfo(&Connection);
  1031. -    DbgP((TEXT("<-- NPAddConnection3 returns %d\n"), (int)Status));
  1032. +    DbgP((L"<-- NPAddConnection3 returns %d\n", (int)Status));
  1033.      return Status;
  1034.  out_undefine:
  1035. -    DefineDosDevice(DDD_REMOVE_DEFINITION | DDD_RAW_TARGET_PATH |
  1036. -        DDD_EXACT_MATCH_ON_REMOVE, LocalName, ConnectionName);
  1037. -out_delconn:
  1038. -    SendTo_NFS41Driver(IOCTL_NFS41_DELCONN, ConnectionName,
  1039. -        Connection.Buffer->NameLength, NULL, &CopyBytes);
  1040. -    goto out;
  1041. -}
  1042. -
  1043. -DWORD APIENTRY
  1044. -NPCancelConnection(
  1045. -    __in LPWSTR  lpName,
  1046. -    __in BOOL    fForce )
  1047. -{
  1048. -    DWORD   Status = 0;
  1049. -
  1050. +    (void)DefineDosDevice(DDD_REMOVE_DEFINITION |
  1051. +        DDD_RAW_TARGET_PATH |
  1052. +        DDD_EXACT_MATCH_ON_REMOVE,
  1053. +        LocalName, ConnectionName);
  1054. +out_delconn:
  1055. +    SendTo_NFS41Driver(IOCTL_NFS41_DELCONN, ConnectionName,
  1056. +        Connection.Buffer->NameLength, NULL, &CopyBytes);
  1057. +    goto out;
  1058. +}
  1059. +
  1060. +DWORD APIENTRY
  1061. +NPCancelConnection(
  1062. +    __in LPWSTR  lpName,
  1063. +    __in BOOL    fForce )
  1064. +{
  1065. +    DWORD   Status = 0;
  1066. +
  1067.      HANDLE  hMutex, hMemory;
  1068.      PNFS41NP_SHARED_MEMORY  pSharedMemory;
  1069.  
  1070. -    DbgP((TEXT("--> NPCancelConnection(lpName='%s', fForce=%d)\n"),
  1071. +    DbgP((L"--> NPCancelConnection(lpName='%s', fForce=%d)\n",
  1072.          lpName, (int)fForce));
  1073.  
  1074. -    Status = OpenSharedMemory( &hMutex,
  1075. -                               &hMemory,
  1076. -                               (PVOID)&pSharedMemory);
  1077. -
  1078. -    if (Status == WN_SUCCESS)
  1079. -    {
  1080. -        INT  Index;
  1081. -        PNFS41NP_NETRESOURCE pNetResource;
  1082. -        Status = WN_NOT_CONNECTED;
  1083. -
  1084. -        DbgP((TEXT("NPCancelConnection: NextIndex %d, NumResources %d\n"),
  1085. -                    pSharedMemory->NextAvailableIndex,
  1086. -                    pSharedMemory->NumberOfResourcesInUse));
  1087. -
  1088. -        for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
  1089. -        {
  1090. -            pNetResource = &pSharedMemory->NetResources[Index];
  1091. -
  1092. -            if (pNetResource->InUse)
  1093. -            {
  1094. -                if ( ( (wcslen(lpName) + 1) * sizeof(WCHAR) ==
  1095. -                        pNetResource->LocalNameLength)
  1096. -                        && ( !wcscmp(lpName, pNetResource->LocalName) ))
  1097. -                {
  1098. -                    ULONG CopyBytes;
  1099. -
  1100. -                    DbgP((TEXT("NPCancelConnection: Connection Found:\n")));
  1101. -
  1102. -                    CopyBytes = 0;
  1103. -
  1104. -                    Status = SendTo_NFS41Driver( IOCTL_NFS41_DELCONN,
  1105. -                                pNetResource->ConnectionName,
  1106. -                                pNetResource->ConnectionNameLength,
  1107. -                                NULL,
  1108. -                                &CopyBytes );
  1109. -
  1110. -                    if (Status != WN_SUCCESS)
  1111. -                    {
  1112. -                        DbgP((TEXT("NPCancelConnection: SendToMiniRdr returned Status %lx\n"),Status));
  1113. -                        break;
  1114. -                    }
  1115. -
  1116. -                    if (DefineDosDevice(DDD_REMOVE_DEFINITION | DDD_RAW_TARGET_PATH | DDD_EXACT_MATCH_ON_REMOVE,
  1117. -                            lpName,
  1118. -                            pNetResource->ConnectionName) == FALSE)
  1119. -                    {
  1120. -                        DbgP((TEXT("RemoveDosDevice:  DefineDosDevice error: %d\n"), GetLastError()));
  1121. -                        Status = GetLastError();
  1122. -                    }
  1123. -                    else
  1124. -                    {
  1125. -                        pNetResource->InUse = FALSE;
  1126. -                        pSharedMemory->NumberOfResourcesInUse--;
  1127. -
  1128. -                        if (Index+1 == pSharedMemory->NextAvailableIndex)
  1129. -                            pSharedMemory->NextAvailableIndex--;
  1130. -                    }
  1131. +    Status = OpenSharedMemory(&hMutex,
  1132. +        &hMemory,
  1133. +        (PVOID)&pSharedMemory);
  1134. +
  1135. +    if (Status != WN_SUCCESS)
  1136. +        goto out;
  1137. +
  1138. +    INT  Index;
  1139. +    PNFS41NP_NETRESOURCE pNetResource;
  1140. +    Status = WN_NOT_CONNECTED;
  1141. +
  1142. +    DbgP((L"NPCancelConnection: NextIndex %d, NumResources %d\n",
  1143. +                pSharedMemory->NextAvailableIndex,
  1144. +                pSharedMemory->NumberOfResourcesInUse));
  1145. +
  1146. +    for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
  1147. +    {
  1148. +        pNetResource = &pSharedMemory->NetResources[Index];
  1149. +
  1150. +        if (pNetResource->InUse) {
  1151. +            if ((((wcslen(lpName)+1) * sizeof(WCHAR)) ==
  1152. +                pNetResource->LocalNameLength) &&
  1153. +                (!wcscmp(lpName, pNetResource->LocalName))) {
  1154. +                ULONG CopyBytes;
  1155. +
  1156. +                DbgP((L"NPCancelConnection: Connection Found:\n"));
  1157. +
  1158. +                CopyBytes = 0;
  1159. +
  1160. +                Status = SendTo_NFS41Driver( IOCTL_NFS41_DELCONN,
  1161. +                            pNetResource->ConnectionName,
  1162. +                            pNetResource->ConnectionNameLength,
  1163. +                            NULL,
  1164. +                            &CopyBytes);
  1165. +
  1166. +                if (Status != WN_SUCCESS) {
  1167. +                    DbgP((L"SendToMiniRdr returned Status %lx\n",
  1168. +                        Status));
  1169.                      break;
  1170.                  }
  1171.  
  1172. -                DbgP((TEXT("NPCancelConnection: Name '%s' EntryName '%s'\n"),
  1173. -                            lpName,pNetResource->LocalName));
  1174. -                DbgP((TEXT("NPCancelConnection: Name Length %d Entry Name Length %d\n"),
  1175. -                           pNetResource->LocalNameLength,pNetResource->LocalName));
  1176. -
  1177. -            }
  1178. -        }
  1179. -
  1180. -        CloseSharedMemory( &hMutex,
  1181. -                           &hMemory,
  1182. -                          (PVOID)&pSharedMemory);
  1183. +                if (DefineDosDevice(DDD_REMOVE_DEFINITION |
  1184. +                    DDD_RAW_TARGET_PATH | DDD_EXACT_MATCH_ON_REMOVE,
  1185. +                    lpName,
  1186. +                    pNetResource->ConnectionName) == FALSE) {
  1187. +                    DbgP((L"DefineDosDevice error: %d\n",
  1188. +                        GetLastError()));
  1189. +                    Status = GetLastError();
  1190. +                }
  1191. +                else {
  1192. +                    pNetResource->InUse = FALSE;
  1193. +                    pSharedMemory->NumberOfResourcesInUse--;
  1194. +
  1195. +                    if (Index+1 == pSharedMemory->NextAvailableIndex)
  1196. +                        pSharedMemory->NextAvailableIndex--;
  1197. +                }
  1198. +                break;
  1199. +            }
  1200. +
  1201. +            DbgP((L"Name '%s' EntryName '%s'\n",
  1202. +                lpName,pNetResource->LocalName));
  1203. +            DbgP((L"Name Length %d Entry Name Length %d\n",
  1204. +                pNetResource->LocalNameLength,
  1205. +                pNetResource->LocalName));
  1206. +        }
  1207.      }
  1208.  
  1209. -    DbgP((TEXT("<-- NPCancelConnection returns %d\n"), (int)Status));
  1210. +    CloseSharedMemory(&hMutex,
  1211. +        &hMemory,
  1212. +        (PVOID)&pSharedMemory);
  1213. +out:
  1214. +    DbgP((L"<-- NPCancelConnection returns %d\n", (int)Status));
  1215.      return Status;
  1216.  }
  1217.  
  1218. -DWORD APIENTRY
  1219. -NPGetConnection(
  1220. -    __in LPWSTR  lpLocalName,
  1221. -    __out_bcount(*lpBufferSize) LPWSTR  lpRemoteName,
  1222. -    __inout LPDWORD lpBufferSize )
  1223. -{
  1224. -    DWORD   Status = 0;
  1225. -
  1226. +DWORD APIENTRY
  1227. +NPGetConnection(
  1228. +    __in LPWSTR  lpLocalName,
  1229. +    __out_bcount(*lpBufferSize) LPWSTR  lpRemoteName,
  1230. +    __inout LPDWORD lpBufferSize )
  1231. +{
  1232. +    DWORD   Status = 0;
  1233. +
  1234.      HANDLE  hMutex, hMemory;
  1235.      PNFS41NP_SHARED_MEMORY  pSharedMemory;
  1236.  
  1237. -    DbgP((TEXT("--> NPGetConnection(lpLocalName='%s')\n"), lpLocalName));
  1238. -
  1239. -    Status = OpenSharedMemory( &hMutex,
  1240. -                               &hMemory,
  1241. -                               (PVOID)&pSharedMemory);
  1242. -
  1243. -    if (Status == WN_SUCCESS)
  1244. -    {
  1245. -        INT  Index;
  1246. -        PNFS41NP_NETRESOURCE pNetResource;
  1247. -        Status = WN_NOT_CONNECTED;
  1248. -
  1249. -        for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
  1250. -        {
  1251. -            pNetResource = &pSharedMemory->NetResources[Index];
  1252. -
  1253. -            if (pNetResource->InUse)
  1254. -            {
  1255. -                if ( ( (wcslen(lpLocalName) + 1) * sizeof(WCHAR) ==
  1256. -                        pNetResource->LocalNameLength)
  1257. -                        && ( !wcscmp(lpLocalName, pNetResource->LocalName) ))
  1258. -                {
  1259. -                    if (*lpBufferSize < pNetResource->RemoteNameLength)
  1260. -                    {
  1261. -                        *lpBufferSize = pNetResource->RemoteNameLength;
  1262. -                        Status = WN_MORE_DATA;
  1263. -                    }
  1264. -                    else
  1265. -                    {
  1266. -                        *lpBufferSize = pNetResource->RemoteNameLength;
  1267. -                        CopyMemory( lpRemoteName,
  1268. -                                    pNetResource->RemoteName,
  1269. -                                    pNetResource->RemoteNameLength);
  1270. -                        Status = WN_SUCCESS;
  1271. -                    }
  1272. -                    break;
  1273. -                }
  1274. -            }
  1275. -        }
  1276. -
  1277. -        CloseSharedMemory( &hMutex, &hMemory, (PVOID)&pSharedMemory);
  1278. +    DbgP((L"--> NPGetConnection(lpLocalName='%s')\n", lpLocalName));
  1279. +
  1280. +    Status = OpenSharedMemory(&hMutex,
  1281. +        &hMemory,
  1282. +        (PVOID)&pSharedMemory);
  1283. +    if (Status != WN_SUCCESS)
  1284. +        goto out;
  1285. +
  1286. +    INT  Index;
  1287. +    PNFS41NP_NETRESOURCE pNetResource;
  1288. +    Status = WN_NOT_CONNECTED;
  1289. +
  1290. +    for (Index = 0; Index < pSharedMemory->NextAvailableIndex; Index++)
  1291. +    {
  1292. +        pNetResource = &pSharedMemory->NetResources[Index];
  1293. +
  1294. +        if (pNetResource->InUse) {
  1295. +            if ((((wcslen(lpLocalName)+1)*sizeof(WCHAR)) ==
  1296. +                    pNetResource->LocalNameLength) &&
  1297. +                    (!wcscmp(lpLocalName, pNetResource->LocalName))) {
  1298. +                if (*lpBufferSize < pNetResource->RemoteNameLength) {
  1299. +                    *lpBufferSize = pNetResource->RemoteNameLength;
  1300. +                    Status = WN_MORE_DATA;
  1301. +                }
  1302. +                else {
  1303. +                    *lpBufferSize = pNetResource->RemoteNameLength;
  1304. +                    CopyMemory(lpRemoteName,
  1305. +                        pNetResource->RemoteName,
  1306. +                        pNetResource->RemoteNameLength);
  1307. +                    Status = WN_SUCCESS;
  1308. +                }
  1309. +                break;
  1310. +            }
  1311. +        }
  1312.      }
  1313.  
  1314. -    DbgP((TEXT("<-- NPGetConnection returns %d\n"), (int)Status));
  1315. +    CloseSharedMemory( &hMutex, &hMemory, (PVOID)&pSharedMemory);
  1316. +out:
  1317. +    DbgP((L"<-- NPGetConnection returns %d\n", (int)Status));
  1318.  
  1319.      return Status;
  1320.  }
  1321.  
  1322. -DWORD APIENTRY
  1323. -NPOpenEnum(
  1324. -    DWORD          dwScope,
  1325. -    DWORD          dwType,
  1326. -    DWORD          dwUsage,
  1327. -    LPNETRESOURCE  lpNetResource,
  1328. -    LPHANDLE       lphEnum )
  1329. +DWORD APIENTRY
  1330. +NPOpenEnum(
  1331. +    DWORD           dwScope,
  1332. +    DWORD           dwType,
  1333. +    DWORD           dwUsage,
  1334. +    LPNETRESOURCE   lpNetResource,
  1335. +    LPHANDLE        lphEnum)
  1336.  {
  1337. -    DWORD   Status;
  1338. +    DWORD Status;
  1339.  
  1340.      DbgP((L" --> NPOpenEnum(dwScope=%d, dwType=%d, dwUsage=%d)\n",
  1341.          (int)dwScope, (int)dwType, (int)dwUsage));
  1342.  
  1343.      *lphEnum = NULL;
  1344.  
  1345. -    switch ( dwScope )
  1346. -    {
  1347. -        case RESOURCE_CONNECTED:
  1348. -        {
  1349. -            *lphEnum = HeapAlloc( GetProcessHeap( ), HEAP_ZERO_MEMORY, sizeof( ULONG ) );
  1350. -
  1351. -            if (*lphEnum )
  1352. -            {
  1353. -                Status = WN_SUCCESS;
  1354. -            }
  1355. -            else
  1356. -            {
  1357. -                Status = WN_OUT_OF_MEMORY;
  1358. -            }
  1359. -            break;
  1360. -        }
  1361. -        break;
  1362. -
  1363. -        case RESOURCE_CONTEXT:
  1364. -        default:
  1365. -            Status  = WN_NOT_SUPPORTED;
  1366. -            break;
  1367. -    }
  1368. +    switch(dwScope)
  1369. +    {
  1370. +        case RESOURCE_CONNECTED:
  1371. +        {
  1372. +            *lphEnum = HeapAlloc(GetProcessHeap(),
  1373. +                HEAP_ZERO_MEMORY, sizeof(ULONG));
  1374.  
  1375. +            if (*lphEnum ) {
  1376. +                Status = WN_SUCCESS;
  1377. +            }
  1378. +            else {
  1379. +                Status = WN_OUT_OF_MEMORY;
  1380. +            }
  1381. +            break;
  1382. +        }
  1383. +        break;
  1384. +
  1385. +        case RESOURCE_CONTEXT:
  1386. +        default:
  1387. +            Status  = WN_NOT_SUPPORTED;
  1388. +            break;
  1389. +    }
  1390.  
  1391. -    DbgP((L"<-- NPOpenEnum returns %d\n", (int)Status));
  1392. +    DbgP((L"<-- NPOpenEnum returns %d, *lphEnum=0x%x\n",
  1393. +        (int)Status, HANDLE2INT(*lphEnum)));
  1394.  
  1395.      return(Status);
  1396.  }
  1397. -
  1398. -DWORD APIENTRY
  1399. -NPEnumResource(
  1400. -    HANDLE  hEnum,
  1401. -    LPDWORD lpcCount,
  1402. -    LPVOID  lpBuffer,
  1403. -    LPDWORD lpBufferSize)
  1404. -{
  1405. -    DWORD           Status = WN_SUCCESS;
  1406. -    ULONG           EntriesCopied;
  1407. -    LPNETRESOURCE   pNetResource;
  1408. -    ULONG           SpaceNeeded = 0;
  1409. -    ULONG           SpaceAvailable;
  1410. -    PWCHAR          StringZone;
  1411. -    HANDLE  hMutex, hMemory;
  1412. -    PNFS41NP_SHARED_MEMORY  pSharedMemory;
  1413. +
  1414. +DWORD APIENTRY
  1415. +NPEnumResource(
  1416. +    HANDLE  hEnum,
  1417. +    LPDWORD lpcCount,
  1418. +    LPVOID  lpBuffer,
  1419. +    LPDWORD lpBufferSize)
  1420. +{
  1421. +    DWORD           Status = WN_SUCCESS;
  1422. +    ULONG           EntriesCopied;
  1423. +    LPNETRESOURCE   pNetResource;
  1424. +    ULONG           SpaceNeeded = 0;
  1425. +    ULONG           SpaceAvailable;
  1426. +    PWCHAR          StringZone;
  1427. +    HANDLE  hMutex, hMemory;
  1428. +    PNFS41NP_SHARED_MEMORY  pSharedMemory;
  1429.      PNFS41NP_NETRESOURCE pNfsNetResource;
  1430.      INT  Index = *(PULONG)hEnum;
  1431.  
  1432. -    DbgP((L"--> NPEnumResource(*lpcCount=%d)\n", (int)*lpcCount));
  1433. +    DbgP((L"--> NPEnumResource(hEnum=0x%x, *lpcCount=%d)\n",
  1434. +        HANDLE2INT(hEnum), (int)*lpcCount));
  1435.  
  1436.      pNetResource = (LPNETRESOURCE) lpBuffer;
  1437.      SpaceAvailable = *lpBufferSize;
  1438.      EntriesCopied = 0;
  1439.      StringZone = (PWCHAR) ((PBYTE)lpBuffer + *lpBufferSize);
  1440.  
  1441. -    Status = OpenSharedMemory( &hMutex,
  1442. -                               &hMemory,
  1443. -                               (PVOID)&pSharedMemory);
  1444. -
  1445. -    if ( Status == WN_SUCCESS)
  1446. +    Status = OpenSharedMemory(&hMutex,
  1447. +        &hMemory,
  1448. +        (PVOID)&pSharedMemory);
  1449. +    if (Status != WN_SUCCESS)
  1450. +        goto out;
  1451. +
  1452. +    Status = WN_NO_MORE_ENTRIES;
  1453. +    for (Index = *(PULONG)hEnum; EntriesCopied < *lpcCount &&
  1454. +            Index < pSharedMemory->NextAvailableIndex; Index++)
  1455.      {
  1456. -        Status = WN_NO_MORE_ENTRIES;
  1457. -        for (Index = *(PULONG)hEnum; EntriesCopied < *lpcCount &&
  1458. -                Index < pSharedMemory->NextAvailableIndex; Index++)
  1459. +        pNfsNetResource = &pSharedMemory->NetResources[Index];
  1460. +
  1461. +        if (pNfsNetResource->InUse)
  1462.          {
  1463. -            pNfsNetResource = &pSharedMemory->NetResources[Index];
  1464. -
  1465. -            if (pNfsNetResource->InUse)
  1466. -            {
  1467. -                SpaceNeeded  = sizeof( NETRESOURCE );
  1468. -                SpaceNeeded += pNfsNetResource->LocalNameLength;
  1469. -                SpaceNeeded += pNfsNetResource->RemoteNameLength;
  1470. -                SpaceNeeded += 5 * sizeof(WCHAR);               // comment
  1471. -                SpaceNeeded += sizeof(NFS41_PROVIDER_NAME_U);  // provider name
  1472. -                if ( SpaceNeeded > SpaceAvailable )
  1473. -                {
  1474. -                    Status = WN_MORE_DATA;
  1475. -                    DbgP((L"NPEnumResource More Data Needed - %d\n", SpaceNeeded));
  1476. -                    *lpBufferSize = SpaceNeeded;
  1477. -                    break;
  1478. -                }
  1479. -                else
  1480. -                {
  1481. -                    SpaceAvailable -= SpaceNeeded;
  1482. -
  1483. -                    pNetResource->dwScope       = pNfsNetResource->dwScope;
  1484. -                    pNetResource->dwType        = pNfsNetResource->dwType;
  1485. -                    pNetResource->dwDisplayType = pNfsNetResource->dwDisplayType;
  1486. -                    pNetResource->dwUsage       = pNfsNetResource->dwUsage;
  1487. -
  1488. -                    // setup string area at opposite end of buffer
  1489. -                    SpaceNeeded -= sizeof( NETRESOURCE );
  1490. -                    StringZone = (PWCHAR)( (PBYTE) StringZone - SpaceNeeded );
  1491. -                    // copy local name
  1492. -                    StringCchCopy( StringZone,
  1493. -                        pNfsNetResource->LocalNameLength,
  1494. -                        pNfsNetResource->LocalName );
  1495. -                    pNetResource->lpLocalName = StringZone;
  1496. -                    StringZone += pNfsNetResource->LocalNameLength/sizeof(WCHAR);
  1497. -                    // copy remote name
  1498. -                    StringCchCopy( StringZone,
  1499. -                        pNfsNetResource->RemoteNameLength,
  1500. -                        pNfsNetResource->RemoteName );
  1501. -                    pNetResource->lpRemoteName = StringZone;
  1502. -                    StringZone += pNfsNetResource->RemoteNameLength/sizeof(WCHAR);
  1503. -                    // copy comment
  1504. -                    pNetResource->lpComment = StringZone;
  1505. -                    *StringZone++ = L'A';
  1506. -                    *StringZone++ = L'_';
  1507. -                    *StringZone++ = L'O';
  1508. -                    *StringZone++ = L'K';
  1509. -                    *StringZone++ = L'\0';
  1510. -                    // copy provider name
  1511. -                    pNetResource->lpProvider = StringZone;
  1512. -                    StringCbCopyW( StringZone, sizeof(NFS41_PROVIDER_NAME_U), NFS41_PROVIDER_NAME_U );
  1513. -                    StringZone += sizeof(NFS41_PROVIDER_NAME_U)/sizeof(WCHAR);
  1514. -                    EntriesCopied++;
  1515. -                    // set new bottom of string zone
  1516. -                    StringZone = (PWCHAR)( (PBYTE) StringZone - SpaceNeeded );
  1517. -                    Status = WN_SUCCESS;
  1518. -                }
  1519. -                pNetResource++;
  1520. -            }
  1521. -        }
  1522. -        CloseSharedMemory( &hMutex, &hMemory, (PVOID*)&pSharedMemory);
  1523. -    }
  1524. -
  1525. +            SpaceNeeded  = sizeof(NETRESOURCE);
  1526. +            SpaceNeeded += pNfsNetResource->LocalNameLength;
  1527. +            SpaceNeeded += pNfsNetResource->RemoteNameLength;
  1528. +            // comment
  1529. +            SpaceNeeded += 5 * sizeof(WCHAR);
  1530. +            // provider name
  1531. +            SpaceNeeded += sizeof(NFS41_PROVIDER_NAME_U);
  1532. +            if (SpaceNeeded > SpaceAvailable) {
  1533. +                Status = WN_MORE_DATA;
  1534. +                DbgP((L"NPEnumResource: "
  1535. +                    "More Data Needed, SpaceNeeded=%d\n", SpaceNeeded));
  1536. +                *lpBufferSize = SpaceNeeded;
  1537. +                break;
  1538. +            }
  1539. +            else {
  1540. +                SpaceAvailable -= SpaceNeeded;
  1541. +
  1542. +                pNetResource->dwScope       = pNfsNetResource->dwScope;
  1543. +                pNetResource->dwType        = pNfsNetResource->dwType;
  1544. +                pNetResource->dwDisplayType = pNfsNetResource->dwDisplayType;
  1545. +                pNetResource->dwUsage       = pNfsNetResource->dwUsage;
  1546. +
  1547. +                // setup string area at opposite end of buffer
  1548. +                SpaceNeeded -= sizeof(NETRESOURCE);
  1549. +                StringZone = (PWCHAR)( (PBYTE) StringZone - SpaceNeeded);
  1550. +                // copy local name
  1551. +                (void)StringCchCopy(StringZone,
  1552. +                    pNfsNetResource->LocalNameLength,
  1553. +                    pNfsNetResource->LocalName);
  1554. +                pNetResource->lpLocalName = StringZone;
  1555. +                StringZone += pNfsNetResource->LocalNameLength/sizeof(WCHAR);
  1556. +                // copy remote name
  1557. +                (void)StringCchCopy(StringZone,
  1558. +                    pNfsNetResource->RemoteNameLength,
  1559. +                    pNfsNetResource->RemoteName);
  1560. +                pNetResource->lpRemoteName = StringZone;
  1561. +                StringZone += pNfsNetResource->RemoteNameLength/sizeof(WCHAR);
  1562. +                // copy comment
  1563. +                pNetResource->lpComment = StringZone;
  1564. +                *StringZone++ = L'A';
  1565. +                *StringZone++ = L'_';
  1566. +                *StringZone++ = L'O';
  1567. +                *StringZone++ = L'K';
  1568. +                *StringZone++ = L'\0';
  1569. +                // copy provider name
  1570. +                pNetResource->lpProvider = StringZone;
  1571. +                (void)StringCbCopyW(StringZone,
  1572. +                    sizeof(NFS41_PROVIDER_NAME_U), NFS41_PROVIDER_NAME_U);
  1573. +                StringZone += sizeof(NFS41_PROVIDER_NAME_U)/sizeof(WCHAR);
  1574. +                EntriesCopied++;
  1575. +                // set new bottom of string zone
  1576. +                StringZone = (PWCHAR)((PBYTE)StringZone - SpaceNeeded);
  1577. +                Status = WN_SUCCESS;
  1578. +            }
  1579. +            pNetResource++;
  1580. +        }
  1581. +    }
  1582. +
  1583. +    CloseSharedMemory(&hMutex, &hMemory, (PVOID*)&pSharedMemory);
  1584. +out:
  1585.      *lpcCount = EntriesCopied;
  1586.      *(PULONG) hEnum = Index;
  1587.  
  1588. @@ -919,45 +944,46 @@ NPEnumResource(
  1589.  
  1590.      return Status;
  1591.  }
  1592. -
  1593. -DWORD APIENTRY
  1594. +
  1595. +DWORD APIENTRY
  1596.  NPCloseEnum(
  1597. -    HANDLE hEnum )
  1598. +    HANDLE hEnum)
  1599.  {
  1600. -    DbgP((L"NPCloseEnum\n"));
  1601. -    HeapFree( GetProcessHeap( ), 0, (PVOID) hEnum );
  1602. +    DbgP((L"NPCloseEnum(handle=0x%x)\n", HANDLE2INT(hEnum)));
  1603. +    HeapFree(GetProcessHeap(), 0, (PVOID)hEnum);
  1604.      return WN_SUCCESS;
  1605.  }
  1606. -
  1607. -DWORD APIENTRY
  1608. -NPGetResourceParent(
  1609. -    LPNETRESOURCE   lpNetResource,
  1610. +
  1611. +DWORD APIENTRY
  1612. +NPGetResourceParent(
  1613. +    LPNETRESOURCE   lpNetResource,
  1614.      LPVOID  lpBuffer,
  1615.      LPDWORD lpBufferSize )
  1616.  {
  1617. -    DbgP(( L"NPGetResourceParent: WN_NOT_SUPPORTED\n" ));
  1618. +    DbgP((L"NPGetResourceParent: WN_NOT_SUPPORTED\n"));
  1619.      return WN_NOT_SUPPORTED;
  1620.  }
  1621.  
  1622. -DWORD APIENTRY
  1623. -NPGetResourceInformation(
  1624. -    __in LPNETRESOURCE   lpNetResource,
  1625. -    __out_bcount(*lpBufferSize) LPVOID  lpBuffer,
  1626. +DWORD APIENTRY
  1627. +NPGetResourceInformation(
  1628. +    __in LPNETRESOURCE   lpNetResource,
  1629. +    __out_bcount(*lpBufferSize) LPVOID  lpBuffer,
  1630.      __inout LPDWORD lpBufferSize,
  1631.      __deref_out LPWSTR *lplpSystem )
  1632.  {
  1633. -    DbgP(( L"NPGetResourceInformation: WN_NOT_SUPPORTED\n" ));
  1634. +    DbgP((L"NPGetResourceInformation: WN_NOT_SUPPORTED\n"));
  1635.      return WN_NOT_SUPPORTED;
  1636.  }
  1637.  
  1638. -DWORD APIENTRY
  1639. -NPGetUniversalName(
  1640. -    LPCWSTR lpLocalPath,
  1641. -    DWORD   dwInfoLevel,
  1642. +DWORD APIENTRY
  1643. +NPGetUniversalName(
  1644. +    LPCWSTR lpLocalPath,
  1645. +    DWORD   dwInfoLevel,
  1646.      LPVOID  lpBuffer,
  1647.      LPDWORD lpBufferSize )
  1648.  {
  1649. -    DbgP(( L"NPGetUniversalName(lpLocalPath='%s', dwInfoLevel=%d): WN_NOT_SUPPORTED\n",
  1650. +    DbgP((L"NPGetUniversalName(lpLocalPath='%s', dwInfoLevel=%d): "
  1651. +        "WN_NOT_SUPPORTED\n",
  1652.          lpLocalPath, (int)dwInfoLevel));
  1653.      return WN_NOT_SUPPORTED;
  1654.  }
  1655. --
  1656. 2.45.1
  1657.  
  1658. From c3980b4603028b08837dfc4c3ad78d76032a78e6 Mon Sep 17 00:00:00 2001
  1659. From: Roland Mainz <roland.mainz@nrubsig.org>
  1660. Date: Thu, 6 Jun 2024 13:50:43 +0200
  1661. Subject: [PATCH 3/6] tests/winfsinfo1: Fix build warnings
  1662.  
  1663. Fix build warnings
  1664.  
  1665. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  1666. ---
  1667. tests/winfsinfo1/winfsinfo.c | 16 ++++++++--------
  1668.  1 file changed, 8 insertions(+), 8 deletions(-)
  1669.  
  1670. diff --git a/tests/winfsinfo1/winfsinfo.c b/tests/winfsinfo1/winfsinfo.c
  1671. index 9066056..986ebb5 100644
  1672. --- a/tests/winfsinfo1/winfsinfo.c
  1673. +++ b/tests/winfsinfo1/winfsinfo.c
  1674. @@ -51,7 +51,7 @@ bool getvolumeinfo(const char *progname, const char *filename)
  1675.              "%s: Error opening file '%s'. Last error was %d.\n",
  1676.              progname,
  1677.              filename,
  1678. -            GetLastError());
  1679. +            (int)GetLastError());
  1680.          return EXIT_FAILURE;
  1681.      }
  1682.  
  1683. @@ -63,7 +63,7 @@ bool getvolumeinfo(const char *progname, const char *filename)
  1684.          (void)fprintf(stderr, "%s: GetVolumeInformationByHandleW() "
  1685.              "error. GetLastError()==%d.\n",
  1686.              progname,
  1687. -            GetLastError());
  1688. +            (int)GetLastError());
  1689.          res = EXIT_FAILURE;
  1690.          goto done;
  1691.      }
  1692. @@ -148,7 +148,7 @@ bool get_file_basic_info(const char *progname, const char *filename)
  1693.              "%s: Error opening file '%s'. Last error was %d.\n",
  1694.              progname,
  1695.              filename,
  1696. -            GetLastError());
  1697. +            (int)GetLastError());
  1698.          return EXIT_FAILURE;
  1699.      }
  1700.  
  1701. @@ -159,7 +159,7 @@ bool get_file_basic_info(const char *progname, const char *filename)
  1702.          (void)fprintf(stderr, "%s: GetFileInformationByHandleEx() "
  1703.              "error. GetLastError()==%d.\n",
  1704.              progname,
  1705. -            GetLastError());
  1706. +            (int)GetLastError());
  1707.          res = EXIT_FAILURE;
  1708.          goto done;
  1709.      }
  1710. @@ -237,7 +237,7 @@ bool get_file_standard_info(const char *progname, const char *filename)
  1711.              "%s: Error opening file '%s'. Last error was %d.\n",
  1712.              progname,
  1713.              filename,
  1714. -            GetLastError());
  1715. +            (int)GetLastError());
  1716.          return EXIT_FAILURE;
  1717.      }
  1718.  
  1719. @@ -248,7 +248,7 @@ bool get_file_standard_info(const char *progname, const char *filename)
  1720.          (void)fprintf(stderr, "%s: GetFileInformationByHandleEx() "
  1721.              "error. GetLastError()==%d.\n",
  1722.              progname,
  1723. -            GetLastError());
  1724. +            (int)GetLastError());
  1725.          res = EXIT_FAILURE;
  1726.          goto done;
  1727.      }
  1728. @@ -295,7 +295,7 @@ bool get_filenormalizednameinfo(const char *progname, const char *filename)
  1729.              "%s: Error opening file '%s'. Last error was %d.\n",
  1730.              progname,
  1731.              filename,
  1732. -            GetLastError());
  1733. +            (int)GetLastError());
  1734.          return EXIT_FAILURE;
  1735.      }
  1736.  
  1737. @@ -315,7 +315,7 @@ bool get_filenormalizednameinfo(const char *progname, const char *filename)
  1738.          (void)fprintf(stderr, "%s: GetFileInformationByHandleEx() "
  1739.              "error. GetLastError()==%d.\n",
  1740.              progname,
  1741. -            GetLastError());
  1742. +            (int)GetLastError());
  1743.          res = EXIT_FAILURE;
  1744.          goto done;
  1745.      }
  1746. --
  1747. 2.45.1
  1748.  
  1749. From c97e3264e38ee0e66e033f9570e697c76db73fe7 Mon Sep 17 00:00:00 2001
  1750. From: Roland Mainz <roland.mainz@nrubsig.org>
  1751. Date: Thu, 6 Jun 2024 13:55:20 +0200
  1752. Subject: [PATCH 4/6] tests/winfsinfo1: Fix comment about Cygwin-vs-MinGW bug
  1753.  
  1754. Fix comment about Cygwin-vs-MinGW bug, the issue is in the
  1755. MinGW headers, not in Cygwin itself
  1756.  
  1757. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  1758. ---
  1759. tests/winfsinfo1/winfsinfo.c | 11 +++++++----
  1760.  1 file changed, 7 insertions(+), 4 deletions(-)
  1761.  
  1762. diff --git a/tests/winfsinfo1/winfsinfo.c b/tests/winfsinfo1/winfsinfo.c
  1763. index 986ebb5..99bcc2f 100644
  1764. --- a/tests/winfsinfo1/winfsinfo.c
  1765. +++ b/tests/winfsinfo1/winfsinfo.c
  1766. @@ -300,12 +300,15 @@ bool get_filenormalizednameinfo(const char *progname, const char *filename)
  1767.      }
  1768.  
  1769.      /*
  1770. -     * |FileNormalizedNameInfo| value:
  1771. +     * MinGW header bug: Wrong |FileNormalizedNameInfo| value
  1772.       * Per
  1773.       * https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ne-minwinbase-file_info_by_handle_class
  1774. -     * |FileNormalizedNameInfo| should be |24|, but on Cygwin 3.6 we
  1775. -     * get the value |48|. Since |24| works and |48| returns an
  1776. -     * "Invalid Parameter" error we assume this is a Cygwin bug.
  1777. +     * |FileNormalizedNameInfo| should be |24|, but with older MinGW
  1778. +     * headers we get the value |48|.
  1779. +     * This has been reported as
  1780. +     * https://github.com/mingw-w64/mingw-w64/issues/48 ("Integer
  1781. +     * value of |FileNormalizedNameInfo| shifts with Windows
  1782. +     * version")
  1783.       */
  1784.      ok = GetFileInformationByHandleEx(fileHandle,
  1785.          24/*FileNormalizedNameInfo*/,
  1786. --
  1787. 2.45.1
  1788.  
  1789. From 73dd9921ef3c96b10ce1b8141bc9f98acf34c313 Mon Sep 17 00:00:00 2001
  1790. From: Roland Mainz <roland.mainz@nrubsig.org>
  1791. Date: Thu, 6 Jun 2024 14:24:41 +0200
  1792. Subject: [PATCH 5/6] cygwin: Install instructions in README.bintarball.txt do
  1793.  not work from cmd.exe
  1794.  
  1795. Fix install instructions in README.bintarball.txt, Windows
  1796. cmd.exe will pass 'foo' as 'foo' to curl instead of foo,
  1797. and the mirrors.kernel.org URL is wrong.
  1798.  
  1799. Reported-by: Martin Wege <martin.l.wege@gmail.com>
  1800. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  1801. ---
  1802. cygwin/README.bintarball.txt | 8 ++++----
  1803.  1 file changed, 4 insertions(+), 4 deletions(-)
  1804.  
  1805. diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
  1806. index 9865131..8599d8f 100644
  1807. --- a/cygwin/README.bintarball.txt
  1808. +++ b/cygwin/README.bintarball.txt
  1809. @@ -135,9 +135,9 @@ echo %PROCESSOR_ARCHITECTURE%
  1810.  # Install Cygwin 64bit on Windows 64bit with packages required by "ms-nfs41-client"
  1811.  # (Windows NFSv4.1 client):
  1812.  # 1. Get installer from https://cygwin.com/setup-x86_64.exe
  1813. -curl --remote-name 'https://www.cygwin.com/setup-x86_64.exe'
  1814. +curl --remote-name "https://www.cygwin.com/setup-x86_64.exe"
  1815.  # 2. Run installer with these arguments:
  1816. -setup-x86_64.exe -q --site https://mirrors.kernel.org -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs,make,git,dos2unix,unzip
  1817. +setup-x86_64.exe -q --site "https://mirrors.kernel.org/sourceware/cygwin" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs,make,git,dos2unix,unzip
  1818.  
  1819.  
  1820.  - Cygwin 32bit can be installed like this:
  1821. @@ -145,9 +145,9 @@ setup-x86_64.exe -q --site https://mirrors.kernel.org -P cygwin,cygwin-devel,cyg
  1822.  # Install Cygwin 32bit on Windows 32bit with packages required by "ms-nfs41-client"
  1823.  # (Windows NFSv4.1 client):
  1824.  # 1. Get installer from https://www.cygwin.com/setup-x86.exe
  1825. -curl --remote-name 'https://www.cygwin.com/setup-x86.exe'
  1826. +curl --remote-name "https://www.cygwin.com/setup-x86.exe"
  1827.  # 2. Run installer with these arguments:
  1828. -setup-x86.exe --allow-unsupported-windows -q --no-verify --site http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457 -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs,make,git,dos2unix,unzip
  1829. +setup-x86.exe --allow-unsupported-windows -q --no-verify --site "http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs,make,git,dos2unix,unzip
  1830.  ---- snip ----
  1831.  
  1832.  
  1833. --
  1834. 2.45.1
  1835.  
  1836. From e2d81bd2682e52e4859129bac213826181ba974c Mon Sep 17 00:00:00 2001
  1837. From: Roland Mainz <roland.mainz@nrubsig.org>
  1838. Date: Thu, 6 Jun 2024 14:29:44 +0200
  1839. Subject: [PATCH 6/6] cygwin: Fix libnfs-utils package name
  1840.  README.bintarball.txt
  1841.  
  1842. Fix libnfs-utils package name README.bintarball.txt,
  1843. s/libnfs/libnfs-utils/
  1844.  
  1845. Reported-by: Martin Wege <martin.l.wege@gmail.com>
  1846. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  1847. ---
  1848. cygwin/README.bintarball.txt | 6 +++---
  1849.  1 file changed, 3 insertions(+), 3 deletions(-)
  1850.  
  1851. diff --git a/cygwin/README.bintarball.txt b/cygwin/README.bintarball.txt
  1852. index 8599d8f..81e8ab3 100644
  1853. --- a/cygwin/README.bintarball.txt
  1854. +++ b/cygwin/README.bintarball.txt
  1855. @@ -107,7 +107,7 @@ NFSv4.1 client and filesystem driver for Windows 10/11
  1856.          util-linux
  1857.          wget
  1858.      - Packages (recommended):
  1859. -        libnfs (for /usr/bin/nfs-ls)
  1860. +        libnfs-utils (for /usr/bin/nfs-ls)
  1861.          make
  1862.          git
  1863.          gcc-core
  1864. @@ -137,7 +137,7 @@ echo %PROCESSOR_ARCHITECTURE%
  1865.  # 1. Get installer from https://cygwin.com/setup-x86_64.exe
  1866.  curl --remote-name "https://www.cygwin.com/setup-x86_64.exe"
  1867.  # 2. Run installer with these arguments:
  1868. -setup-x86_64.exe -q --site "https://mirrors.kernel.org/sourceware/cygwin" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs,make,git,dos2unix,unzip
  1869. +setup-x86_64.exe -q --site "https://mirrors.kernel.org/sourceware/cygwin" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs-utils,make,git,dos2unix,unzip
  1870.  
  1871.  
  1872.  - Cygwin 32bit can be installed like this:
  1873. @@ -147,7 +147,7 @@ setup-x86_64.exe -q --site "https://mirrors.kernel.org/sourceware/cygwin" -P cyg
  1874.  # 1. Get installer from https://www.cygwin.com/setup-x86.exe
  1875.  curl --remote-name "https://www.cygwin.com/setup-x86.exe"
  1876.  # 2. Run installer with these arguments:
  1877. -setup-x86.exe --allow-unsupported-windows -q --no-verify --site "http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs,make,git,dos2unix,unzip
  1878. +setup-x86.exe --allow-unsupported-windows -q --no-verify --site "http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs-utils,make,git,dos2unix,unzip
  1879.  ---- snip ----
  1880.  
  1881.  
  1882. --
  1883. 2.45.1

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at