From e71c25046ecea9d2908c02f15f65d490c36d1d14 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 23 Feb 2015 22:55:43 +0000 Subject: [PATCH] [NETAPI32] CORE-9248 Comment out NetGetJoinInformation and NetWkstaGetInfo in wksta.c and reimplement them as RPC client functions to the workstation service in wksta_new.c. svn path=/trunk/; revision=66436 --- reactos/dll/win32/netapi32/CMakeLists.txt | 15 +- reactos/dll/win32/netapi32/wksta.c | 3 +- reactos/dll/win32/netapi32/wksta_new.c | 197 ++++++++++++++++++++++ 3 files changed, 209 insertions(+), 6 deletions(-) create mode 100644 reactos/dll/win32/netapi32/wksta_new.c diff --git a/reactos/dll/win32/netapi32/CMakeLists.txt b/reactos/dll/win32/netapi32/CMakeLists.txt index c5eb75cf69e..350aee9ede4 100644 --- a/reactos/dll/win32/netapi32/CMakeLists.txt +++ b/reactos/dll/win32/netapi32/CMakeLists.txt @@ -1,8 +1,11 @@ -include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) +include_directories( + ${REACTOS_SOURCE_DIR}/include/reactos/idl + ${REACTOS_SOURCE_DIR}/include/reactos/wine) + add_definitions(-D__WINESRC__) - spec2def(netapi32.dll netapi32.spec ADD_IMPORTLIB) +add_rpc_files(client ${REACTOS_SOURCE_DIR}/include/reactos/idl/wkssvc.idl) list(APPEND SOURCE access.c @@ -20,7 +23,9 @@ list(APPEND SOURCE share.c user.c wksta.c - netapi32.h) + wksta_new.c + netapi32.h + ${CMAKE_CURRENT_BINARY_DIR}/wkssvc_c.c) add_library(netapi32 SHARED ${SOURCE} @@ -28,8 +33,8 @@ add_library(netapi32 SHARED ${CMAKE_CURRENT_BINARY_DIR}/netapi32.def) set_module_type(netapi32 win32dll) -target_link_libraries(netapi32 wine) -add_importlibs(netapi32 iphlpapi ws2_32 advapi32 msvcrt kernel32 ntdll) +target_link_libraries(netapi32 wine ${PSEH_LIB}) +add_importlibs(netapi32 iphlpapi ws2_32 advapi32 rpcrt4 msvcrt kernel32 ntdll) add_delay_importlibs(netapi32 samlib secur32) add_pch(netapi32 netapi32.h SOURCE) add_cd_file(TARGET netapi32 DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/win32/netapi32/wksta.c b/reactos/dll/win32/netapi32/wksta.c index 4e5d8d6e128..fca7e4095b1 100644 --- a/reactos/dll/win32/netapi32/wksta.c +++ b/reactos/dll/win32/netapi32/wksta.c @@ -464,6 +464,7 @@ NET_API_STATUS WINAPI I_NetNameValidate(LPVOID p1, LPWSTR wkgrp, LPVOID p3, return ERROR_INVALID_PARAMETER; } +#if 0 NET_API_STATUS WINAPI NetWkstaGetInfo( LMSTR servername, DWORD level, LPBYTE* bufptr) { @@ -566,4 +567,4 @@ NET_API_STATUS NET_API_FUNCTION NetGetJoinInformation( return NERR_Success; } - +#endif diff --git a/reactos/dll/win32/netapi32/wksta_new.c b/reactos/dll/win32/netapi32/wksta_new.c new file mode 100644 index 00000000000..2500b193860 --- /dev/null +++ b/reactos/dll/win32/netapi32/wksta_new.c @@ -0,0 +1,197 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: NetAPI DLL + * FILE: reactos/dll/win32/netapi32/wksta_new.c + * PURPOSE: Workstation service interface code + * + * PROGRAMMERS: Eric Kohl + */ + +/* INCLUDES ******************************************************************/ + +#include "netapi32.h" +#include "wkssvc_c.h" + +WINE_DEFAULT_DEBUG_CHANNEL(netapi32); + +/* FUNCTIONS *****************************************************************/ + +void __RPC_FAR * __RPC_USER midl_user_allocate(SIZE_T len) +{ + return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len); +} + + +void __RPC_USER midl_user_free(void __RPC_FAR * ptr) +{ + HeapFree(GetProcessHeap(), 0, ptr); +} + + +handle_t __RPC_USER +WKSSVC_IDENTIFY_HANDLE_bind(WKSSVC_IDENTIFY_HANDLE pszSystemName) +{ + handle_t hBinding = NULL; + LPWSTR pszStringBinding; + RPC_STATUS status; + + TRACE("WKSSVC_IDENTIFY_HANDLE_bind() called\n"); + + status = RpcStringBindingComposeW(NULL, + L"ncacn_np", + pszSystemName, + L"\\pipe\\wkssvc", + NULL, + &pszStringBinding); + if (status) + { + TRACE("RpcStringBindingCompose returned 0x%x\n", status); + return NULL; + } + + /* Set the binding handle that will be used to bind to the server. */ + status = RpcBindingFromStringBindingW(pszStringBinding, + &hBinding); + if (status) + { + TRACE("RpcBindingFromStringBinding returned 0x%x\n", status); + } + + status = RpcStringFreeW(&pszStringBinding); + if (status) + { +// TRACE("RpcStringFree returned 0x%x\n", status); + } + + return hBinding; +} + + +void __RPC_USER +WKSSVC_IDENTIFY_HANDLE_unbind(WKSSVC_IDENTIFY_HANDLE pszSystemName, + handle_t hBinding) +{ + RPC_STATUS status; + + TRACE("WKSSVC_IDENTIFY_HANDLE_unbind() called\n"); + + status = RpcBindingFree(&hBinding); + if (status) + { + TRACE("RpcBindingFree returned 0x%x\n", status); + } +} + + +handle_t __RPC_USER +WKSSVC_IMPERSONATE_HANDLE_bind(WKSSVC_IMPERSONATE_HANDLE pszSystemName) +{ + handle_t hBinding = NULL; + LPWSTR pszStringBinding; + RPC_STATUS status; + + TRACE("WKSSVC_IMPERSONATE_HANDLE_bind() called\n"); + + status = RpcStringBindingComposeW(NULL, + L"ncacn_np", + pszSystemName, + L"\\pipe\\wkssvc", + NULL, + &pszStringBinding); + if (status) + { + TRACE("RpcStringBindingCompose returned 0x%x\n", status); + return NULL; + } + + /* Set the binding handle that will be used to bind to the server. */ + status = RpcBindingFromStringBindingW(pszStringBinding, + &hBinding); + if (status) + { + TRACE("RpcBindingFromStringBinding returned 0x%x\n", status); + } + + status = RpcStringFreeW(&pszStringBinding); + if (status) + { +// TRACE("RpcStringFree returned 0x%x\n", status); + } + + return hBinding; +} + + +void __RPC_USER +WKSSVC_IMPERSONATE_HANDLE_unbind(WKSSVC_IMPERSONATE_HANDLE pszSystemName, + handle_t hBinding) +{ + RPC_STATUS status; + + TRACE("WKSSVC_IMPERSONATE_HANDLE_unbind() called\n"); + + status = RpcBindingFree(&hBinding); + if (status) + { + TRACE("RpcBindingFree returned 0x%x\n", status); + } +} + + +NET_API_STATUS +NET_API_FUNCTION +NetGetJoinInformation( + LPCWSTR Server, + LPWSTR *Name, + PNETSETUP_JOIN_STATUS type) +{ + NET_API_STATUS status; + + FIXME("Stub %s %p %p\n", wine_dbgstr_w(Server), Name, type); + + if (Name == NULL || type == NULL) + return ERROR_INVALID_PARAMETER; + + RpcTryExcept + { + status = NetrGetJoinInformation((LPWSTR)Server, + Name, + type); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return status; +} + + +NET_API_STATUS +WINAPI +NetWkstaGetInfo( + LMSTR servername, + DWORD level, + LPBYTE *bufptr) +{ + NET_API_STATUS status; + + *bufptr = NULL; + + RpcTryExcept + { + status = NetrWkstaGetInfo(servername, + level, + (LPWKSTA_INFO)bufptr); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return status; +} + +/* EOF */