[NP_ENUM]

Add a test application that allows checking that currently network places enumeration is broken in ReactOS

svn path=/trunk/; revision=70759
This commit is contained in:
Pierre Schweitzer 2016-02-20 15:56:49 +00:00
parent 58ef33073d
commit cf7b88e22f
2 changed files with 80 additions and 0 deletions

View file

@ -0,0 +1,4 @@
add_executable(np_enum np_enum.c)
set_module_type(np_enum win32cui UNICODE)
add_importlibs(np_enum msvcrt kernel32 mpr)
add_cd_file(TARGET np_enum DESTINATION reactos/bin FOR all)

View file

@ -0,0 +1,76 @@
#include <windows.h>
#include <stdio.h>
DWORD debug_shift = 0;
#define INC_SHIFT ++debug_shift;
#define DEC_SHIFT --debug_shift;
#define PRT_SHIFT do { DWORD cur = 0; for (; cur < debug_shift; ++cur) printf("\t"); } while (0);
void np_enum(NETRESOURCEW * resource)
{
DWORD ret;
HANDLE handle;
DWORD size = 0x1000;
NETRESOURCEW * out;
BOOL check = FALSE;
if (resource && resource->lpRemoteName)
check = TRUE;
ret = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_DISK, 0, resource, &handle);
if (ret != WN_SUCCESS)
return;
out = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (!out)
{
WNetCloseEnum(handle);
return;
}
INC_SHIFT
if (check)
{
printf("Called with lpRemoteName not null, current value: %S\n", resource->lpRemoteName);
}
do
{
DWORD count = -1;
ret = WNetEnumResource(handle, &count, out, &size);
if (ret == WN_SUCCESS || ret == WN_MORE_DATA)
{
NETRESOURCEW * current;
current = out;
for (; count; count--)
{
PRT_SHIFT;
printf("lpRemoteName: %S\n", current->lpRemoteName);
if ((current->dwUsage & RESOURCEUSAGE_CONTAINER) == RESOURCEUSAGE_CONTAINER)
{
PRT_SHIFT;
printf("Found provider: %S\n", current->lpProvider);
np_enum(current);
}
current++;
}
}
} while (ret != WN_NO_MORE_ENTRIES);
DEC_SHIFT;
HeapFree(GetProcessHeap(), 0, out);
WNetCloseEnum(handle);
}
int wmain(int argc, const WCHAR *argv[])
{
np_enum(NULL);
return 0;
}