diff --git a/configure b/configure index 2646b0b81a6..5f8b931335b 100755 --- a/configure +++ b/configure @@ -15288,6 +15288,7 @@ wine_fn_config_dll monodebg.vxd enable_win16 wine_fn_config_dll mountmgr.sys enable_mountmgr_sys wine_fn_config_dll mouse.drv16 enable_win16 wine_fn_config_dll mpr enable_mpr implib,po +wine_fn_config_test dlls/mpr/tests mpr_test wine_fn_config_dll mprapi enable_mprapi implib wine_fn_config_dll msacm.dll16 enable_win16 wine_fn_config_dll msacm32.drv enable_msacm32_drv diff --git a/configure.ac b/configure.ac index a85459d6611..67a0af687ec 100644 --- a/configure.ac +++ b/configure.ac @@ -2704,6 +2704,7 @@ WINE_CONFIG_DLL(monodebg.vxd,enable_win16) WINE_CONFIG_DLL(mountmgr.sys) WINE_CONFIG_DLL(mouse.drv16,enable_win16) WINE_CONFIG_DLL(mpr,,[implib,po]) +WINE_CONFIG_TEST(dlls/mpr/tests) WINE_CONFIG_DLL(mprapi,,[implib]) WINE_CONFIG_DLL(msacm.dll16,enable_win16) WINE_CONFIG_DLL(msacm32.drv) diff --git a/dlls/mpr/tests/Makefile.in b/dlls/mpr/tests/Makefile.in new file mode 100644 index 00000000000..655c49b8836 --- /dev/null +++ b/dlls/mpr/tests/Makefile.in @@ -0,0 +1,7 @@ +TESTDLL = mpr.dll +IMPORTS = mpr + +C_SRCS = \ + mpr.c + +@MAKE_TEST_RULES@ diff --git a/dlls/mpr/tests/mpr.c b/dlls/mpr/tests/mpr.c new file mode 100644 index 00000000000..d54d80dba42 --- /dev/null +++ b/dlls/mpr/tests/mpr.c @@ -0,0 +1,65 @@ +/* + * Copyright 2012 Andrew Eikum for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS + +#include + +#include "windows.h" +#include "winnetwk.h" +#include "wine/test.h" + +static void test_WNetGetUniversalName(void) +{ + DWORD ret; + char buffer[1024]; + DWORD drive_type, info_size; + char driveA[] = "A:\\"; + WCHAR driveW[] = {'A',':','\\',0}; + + for(; *driveA <= 'Z'; ++*driveA, ++*driveW){ + drive_type = GetDriveTypeW(driveW); + + info_size = sizeof(buffer); + ret = WNetGetUniversalNameA(driveA, UNIVERSAL_NAME_INFO_LEVEL, + buffer, &info_size); + + if(drive_type == DRIVE_REMOTE) + ok(ret == WN_NO_ERROR, "WNetGetUniversalNameA failed: %08x\n", ret); + else + ok(ret == ERROR_NOT_CONNECTED, "WNetGetUniversalNameA gave wrong error: %08x\n", ret); + + ok(info_size == sizeof(buffer), "Got wrong size: %u\n", info_size); + + info_size = sizeof(buffer); + ret = WNetGetUniversalNameW(driveW, UNIVERSAL_NAME_INFO_LEVEL, + buffer, &info_size); + + if(drive_type == DRIVE_REMOTE) + ok(ret == WN_NO_ERROR, "WNetGetUniversalNameW failed: %08x\n", ret); + else + ok(ret == ERROR_NOT_CONNECTED, "WNetGetUniversalNameW gave wrong error: %08x\n", ret); + + ok(info_size == sizeof(buffer), "Got wrong size: %u\n", info_size); + } +} + +START_TEST(mpr) +{ + test_WNetGetUniversalName(); +} diff --git a/dlls/mpr/wnet.c b/dlls/mpr/wnet.c index 946f47e74f2..bdc7ad08d72 100644 --- a/dlls/mpr/wnet.c +++ b/dlls/mpr/wnet.c @@ -1892,6 +1892,12 @@ DWORD WINAPI WNetGetUniversalNameA ( LPCSTR lpLocalPath, DWORD dwInfoLevel, { LPUNIVERSAL_NAME_INFOA info = lpBuffer; + if (GetDriveTypeA(lpLocalPath) != DRIVE_REMOTE) + { + err = ERROR_NOT_CONNECTED; + break; + } + size = sizeof(*info) + lstrlenA(lpLocalPath) + 1; if (*lpBufferSize < size) { @@ -1900,7 +1906,6 @@ DWORD WINAPI WNetGetUniversalNameA ( LPCSTR lpLocalPath, DWORD dwInfoLevel, } info->lpUniversalName = (char *)info + sizeof(*info); lstrcpyA(info->lpUniversalName, lpLocalPath); - *lpBufferSize = size; err = WN_NO_ERROR; break; } @@ -1934,6 +1939,12 @@ DWORD WINAPI WNetGetUniversalNameW ( LPCWSTR lpLocalPath, DWORD dwInfoLevel, { LPUNIVERSAL_NAME_INFOW info = lpBuffer; + if (GetDriveTypeW(lpLocalPath) != DRIVE_REMOTE) + { + err = ERROR_NOT_CONNECTED; + break; + } + size = sizeof(*info) + (lstrlenW(lpLocalPath) + 1) * sizeof(WCHAR); if (*lpBufferSize < size) { @@ -1942,7 +1953,6 @@ DWORD WINAPI WNetGetUniversalNameW ( LPCWSTR lpLocalPath, DWORD dwInfoLevel, } info->lpUniversalName = (LPWSTR)((char *)info + sizeof(*info)); lstrcpyW(info->lpUniversalName, lpLocalPath); - *lpBufferSize = size; err = WN_NO_ERROR; break; }