diff --git a/dlls/wlanapi/main.c b/dlls/wlanapi/main.c index 5eeb515f7c9..9b71330bc5d 100644 --- a/dlls/wlanapi/main.c +++ b/dlls/wlanapi/main.c @@ -28,6 +28,29 @@ WINE_DEFAULT_DEBUG_CHANNEL(wlanapi); +#define WLAN_MAGIC 0x574c414e /* WLAN */ + +static struct wine_wlan +{ + DWORD magic, cli_version; +} handle_table[16]; + +static HANDLE handle_new(struct wine_wlan **entry) +{ + ULONG_PTR i; + + for (i = 0; i < sizeof(handle_table) / sizeof(handle_table[0]); i++) + { + if (handle_table[i].magic == 0) + { + *entry = &handle_table[i]; + return (HANDLE)(i + 1); + } + } + + return NULL; +} + DWORD WINAPI WlanEnumInterfaces(HANDLE handle, void *reserved, WLAN_INTERFACE_INFO_LIST **interface_list) { FIXME("(%p, %p, %p) stub\n", handle, reserved, interface_list); @@ -42,8 +65,26 @@ DWORD WINAPI WlanCloseHandle(HANDLE handle, void *reserved) DWORD WINAPI WlanOpenHandle(DWORD client_version, void *reserved, DWORD *negotiated_version, HANDLE *handle) { - FIXME("(%u, %p, %p, %p) stub\n", client_version, reserved, negotiated_version, handle); - return ERROR_CALL_NOT_IMPLEMENTED; + struct wine_wlan *wlan; + HANDLE ret_handle; + + TRACE("(%u, %p, %p, %p)\n", client_version, reserved, negotiated_version, handle); + + if (reserved || !negotiated_version || !handle) + return ERROR_INVALID_PARAMETER; + + if (client_version != 1 && client_version != 2) + return ERROR_NOT_SUPPORTED; + + ret_handle = handle_new(&wlan); + if (!ret_handle) + return ERROR_REMOTE_SESSION_LIMIT_EXCEEDED; + + wlan->magic = WLAN_MAGIC; + wlan->cli_version = *negotiated_version = client_version; + *handle = ret_handle; + + return ERROR_SUCCESS; } void WINAPI WlanFreeMemory(void *ptr) diff --git a/dlls/wlanapi/tests/wlanapi.c b/dlls/wlanapi/tests/wlanapi.c index 09fcb58ca12..7f8b83cbc7f 100644 --- a/dlls/wlanapi/tests/wlanapi.c +++ b/dlls/wlanapi/tests/wlanapi.c @@ -26,7 +26,7 @@ static void test_WlanOpenHandle(void) { - HANDLE bad_handle = (HANDLE) 0xdeadcafe, handle = bad_handle; + HANDLE bad_handle = (HANDLE) 0xdeadcafe, handle = bad_handle, handle2; DWORD ret, neg_version = 0xdeadbeef, reserved = 0xdead; BOOL is_xp; @@ -35,30 +35,25 @@ static void test_WlanOpenHandle(void) is_xp = ret == ERROR_SUCCESS; if (!is_xp) /* the results in XP differ completely from all other versions */ { -todo_wine ok(ret == ERROR_NOT_SUPPORTED, "Expected 50, got %d\n", ret); ok(neg_version == 0xdeadbeef, "neg_vesion changed\n"); ok(handle == bad_handle, "handle changed\n"); ret = WlanOpenHandle(10, NULL, &neg_version, &handle); -todo_wine ok(ret == ERROR_NOT_SUPPORTED, "Expected 50, got %d\n", ret); ok(neg_version == 0xdeadbeef, "neg_vesion changed\n"); ok(handle == bad_handle, "handle changed\n"); /* reserved parameter must not be used */ ret = WlanOpenHandle(1, &reserved, &neg_version, &handle); -todo_wine ok(ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret); ok(neg_version == 0xdeadbeef, "neg_vesion changed\n"); ok(handle == bad_handle, "handle changed\n"); /* invalid parameters */ ret = WlanOpenHandle(1, NULL, NULL, &handle); -todo_wine ok(ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret); ok(handle == bad_handle, "bad handle\n"); ret = WlanOpenHandle(1, NULL, &neg_version, NULL); -todo_wine ok(ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret); ok(neg_version == 0xdeadbeef, "neg_vesion changed\n"); } @@ -71,12 +66,12 @@ todo_wine } /* good tests */ -todo_wine { ret = WlanOpenHandle(1, NULL, &neg_version, &handle); ok(ret == ERROR_SUCCESS, "Expected 0, got %d\n", ret); ok(neg_version == 1, "Expected 1, got %d\n", neg_version); ok(handle != bad_handle && handle, "handle changed\n"); ret = WlanCloseHandle(handle, NULL); +todo_wine ok(ret == 0, "Expected 0, got %d\n", ret); ret = WlanOpenHandle(2, NULL, &neg_version, &handle); @@ -87,8 +82,21 @@ todo_wine { ok(neg_version == 1, "Expected 1, got %d\n", neg_version); ok(handle != bad_handle && handle, "bad handle\n"); ret = WlanCloseHandle(handle, NULL); +todo_wine ok(ret == 0, "Expected 0, got %d\n", ret); + /* open twice */ + ret = WlanOpenHandle(1, NULL, &neg_version, &handle); + ok(ret == ERROR_SUCCESS, "Expected 0, got %d\n", ret); + ret = WlanOpenHandle(1, NULL, &neg_version, &handle2); + ok(ret == ERROR_SUCCESS, "Expected 0, got %d\n", ret); + +todo_wine { + ret = WlanCloseHandle(handle, NULL); + ok(ret == ERROR_SUCCESS, "Expected 0, got %d\n", ret); + ret = WlanCloseHandle(handle2, NULL); + ok(ret == ERROR_SUCCESS, "Expected 0, got %d\n", ret); + ret = WlanCloseHandle(NULL, NULL); ok(ret == ERROR_INVALID_PARAMETER, "Expected 0, got %d\n", ret); } @@ -120,7 +128,6 @@ static void test_WlanEnumInterfaces(void) WLAN_INTERFACE_INFO *info; ret = WlanOpenHandle(1, NULL, &neg_version, &handle); -todo_wine ok(ret == 0, "Expected 0, got %d\n", ret); /* invalid parameters */