Fixes Lineage 2
-- v5: netapi32: Move some implementations to netutils.
From: Etaash Mathamsetty etaash.mathamsetty@gmail.com
--- dlls/netapi32/Makefile.in | 2 +- dlls/netapi32/netapi32.c | 68 ----------------------- dlls/netapi32/netapi32.spec | 10 ++-- dlls/netutils/Makefile.in | 3 ++ dlls/netutils/main.c | 104 ++++++++++++++++++++++++++++++++++++ dlls/netutils/netutils.spec | 10 ++-- 6 files changed, 118 insertions(+), 79 deletions(-) create mode 100644 dlls/netutils/main.c
diff --git a/dlls/netapi32/Makefile.in b/dlls/netapi32/Makefile.in index 055e8dd04d4..1ee1f8bfd8f 100644 --- a/dlls/netapi32/Makefile.in +++ b/dlls/netapi32/Makefile.in @@ -1,7 +1,7 @@ MODULE = netapi32.dll UNIXLIB = netapi32.so IMPORTLIB = netapi32 -IMPORTS = rpcrt4 iphlpapi ws2_32 advapi32 dnsapi +IMPORTS = rpcrt4 iphlpapi ws2_32 advapi32 dnsapi netutils
SOURCES = \ atsvc.idl \ diff --git a/dlls/netapi32/netapi32.c b/dlls/netapi32/netapi32.c index f7885f6e2c3..1a5af31b132 100644 --- a/dlls/netapi32/netapi32.c +++ b/dlls/netapi32/netapi32.c @@ -347,74 +347,6 @@ NET_API_STATUS WINAPI NetUseGetInfo(LMSTR server, LMSTR name, DWORD level, LPBYT
}
-/************************************************************ - * NetApiBufferAllocate (NETAPI32.@) - */ -NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID* Buffer) -{ - TRACE("(%ld, %p)\n", ByteCount, Buffer); - - if (Buffer == NULL) return ERROR_INVALID_PARAMETER; - *Buffer = HeapAlloc(GetProcessHeap(), 0, ByteCount); - if (*Buffer) - return NERR_Success; - else - return GetLastError(); -} - -/************************************************************ - * NetApiBufferFree (NETAPI32.@) - */ -NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer) -{ - TRACE("(%p)\n", Buffer); - MIDL_user_free(Buffer); - return NERR_Success; -} - -/************************************************************ - * NetApiBufferReallocate (NETAPI32.@) - */ -NET_API_STATUS WINAPI NetApiBufferReallocate(LPVOID OldBuffer, DWORD NewByteCount, - LPVOID* NewBuffer) -{ - TRACE("(%p, %ld, %p)\n", OldBuffer, NewByteCount, NewBuffer); - if (NewByteCount) - { - if (OldBuffer) - *NewBuffer = HeapReAlloc(GetProcessHeap(), 0, OldBuffer, NewByteCount); - else - *NewBuffer = HeapAlloc(GetProcessHeap(), 0, NewByteCount); - return *NewBuffer ? NERR_Success : GetLastError(); - } - else - { - if (!HeapFree(GetProcessHeap(), 0, OldBuffer)) return GetLastError(); - *NewBuffer = 0; - return NERR_Success; - } -} - -/************************************************************ - * NetApiBufferSize (NETAPI32.@) - */ -NET_API_STATUS WINAPI NetApiBufferSize(LPVOID Buffer, LPDWORD ByteCount) -{ - DWORD dw; - - TRACE("(%p, %p)\n", Buffer, ByteCount); - if (Buffer == NULL) - return ERROR_INVALID_PARAMETER; - dw = HeapSize(GetProcessHeap(), 0, Buffer); - TRACE("size: %ld\n", dw); - if (dw != 0xFFFFFFFF) - *ByteCount = dw; - else - *ByteCount = 0; - - return NERR_Success; -} - /************************************************************ * NetSessionEnum (NETAPI32.@) * diff --git a/dlls/netapi32/netapi32.spec b/dlls/netapi32/netapi32.spec index 19a03ad642a..f24aa4a490f 100644 --- a/dlls/netapi32/netapi32.spec +++ b/dlls/netapi32/netapi32.spec @@ -66,10 +66,10 @@ @ stub I_NetServerSetServiceBitsEx @ stub NetAlertRaise @ stub NetAlertRaiseEx -@ stdcall NetApiBufferAllocate(long ptr) -@ stdcall NetApiBufferFree(ptr) -@ stdcall NetApiBufferReallocate(ptr long ptr) -@ stdcall NetApiBufferSize(ptr ptr) +@ stdcall NetApiBufferAllocate(long ptr) netutils.NetApiBufferAllocate +@ stdcall NetApiBufferFree(ptr) netutils.NetApiBufferFree +@ stdcall NetApiBufferReallocate(ptr long ptr) netutils.NetApiBufferReallocate +@ stdcall NetApiBufferSize(ptr ptr) netutils.NetApiBufferSize @ stub NetAuditClear @ stub NetAuditRead @ stub NetAuditWrite @@ -224,7 +224,7 @@ @ stdcall NetWkstaUserEnum(wstr long ptr long ptr ptr ptr) @ stdcall NetWkstaUserGetInfo(wstr long ptr) @ stub NetWkstaUserSetInfo -@ stdcall NetapipBufferAllocate(long ptr) NetApiBufferAllocate +@ stdcall NetapipBufferAllocate(long ptr) netutils.NetapipBufferAllocate @ stdcall Netbios(ptr) @ stub NetpAccessCheck @ stub NetpAccessCheckAndAudit diff --git a/dlls/netutils/Makefile.in b/dlls/netutils/Makefile.in index 8b16b2eb178..0bce9d78776 100644 --- a/dlls/netutils/Makefile.in +++ b/dlls/netutils/Makefile.in @@ -1,3 +1,6 @@ MODULE = netutils.dll +IMPORTLIB = netutils
EXTRADLLFLAGS = -Wb,--prefer-native +SOURCES = \ + main.c diff --git a/dlls/netutils/main.c b/dlls/netutils/main.c new file mode 100644 index 00000000000..2dfbb098037 --- /dev/null +++ b/dlls/netutils/main.c @@ -0,0 +1,104 @@ +/* Copyright 2001 Mike McCormack + * Copyright 2002 Andriy Palamarchuk + * Copyright 2003 Juan Lang + * Copyright 2005,2006 Paul Vriens + * Copyright 2006 Robert Reif + * Copyright 2013 Hans Leidekker for CodeWeavers + * Copyright 2020 Dmitry Timoshkov + * + * 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 + */ + +#include <stdarg.h> + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winternl.h" +#include "lm.h" +#include "wine/debug.h" +#include "wine/list.h" +#include "initguid.h" + +WINE_DEFAULT_DEBUG_CHANNEL(netutils); + +/************************************************************ + * NetApiBufferAllocate (NETUTILS.@) + */ +NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID* Buffer) +{ + TRACE("(%ld, %p)\n", ByteCount, Buffer); + + if (Buffer == NULL) return ERROR_INVALID_PARAMETER; + *Buffer = HeapAlloc(GetProcessHeap(), 0, ByteCount); + if (*Buffer) + return NERR_Success; + else + return GetLastError(); +} + +/************************************************************ + * NetApiBufferFree (NETUTILS.@) + */ +NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer) +{ + TRACE("(%p)\n", Buffer); + HeapFree(GetProcessHeap(), 0, Buffer); + return NERR_Success; +} + +/************************************************************ + * NetApiBufferReallocate (NETUTILS.@) + */ +NET_API_STATUS WINAPI NetApiBufferReallocate(LPVOID OldBuffer, DWORD NewByteCount, + LPVOID* NewBuffer) +{ + TRACE("(%p, %ld, %p)\n", OldBuffer, NewByteCount, NewBuffer); + if (NewByteCount) + { + if (OldBuffer) + *NewBuffer = HeapReAlloc(GetProcessHeap(), 0, OldBuffer, NewByteCount); + else + *NewBuffer = HeapAlloc(GetProcessHeap(), 0, NewByteCount); + return *NewBuffer ? NERR_Success : GetLastError(); + } + else + { + if (!HeapFree(GetProcessHeap(), 0, OldBuffer)) return GetLastError(); + *NewBuffer = 0; + return NERR_Success; + } +} + +/************************************************************ + * NetApiBufferSize (NETUTILS.@) + */ +NET_API_STATUS WINAPI NetApiBufferSize(LPVOID Buffer, LPDWORD ByteCount) +{ + DWORD dw; + + TRACE("(%p, %p)\n", Buffer, ByteCount); + if (Buffer == NULL) + return ERROR_INVALID_PARAMETER; + dw = HeapSize(GetProcessHeap(), 0, Buffer); + TRACE("size: %ld\n", dw); + if (dw != 0xFFFFFFFF) + *ByteCount = dw; + else + *ByteCount = 0; + + return NERR_Success; +} diff --git a/dlls/netutils/netutils.spec b/dlls/netutils/netutils.spec index ff022af2c57..a6a43198007 100644 --- a/dlls/netutils/netutils.spec +++ b/dlls/netutils/netutils.spec @@ -1,9 +1,9 @@ -@ stub NetApiBufferAllocate -@ stub NetApiBufferFree -@ stub NetApiBufferReallocate -@ stub NetApiBufferSize +@ stdcall NetApiBufferAllocate(long ptr) +@ stdcall NetApiBufferFree(ptr) +@ stdcall NetApiBufferReallocate(ptr long ptr) +@ stdcall NetApiBufferSize(ptr ptr) @ stub NetRemoteComputerSupports -@ stub NetapipBufferAllocate +@ stdcall NetapipBufferAllocate(long ptr) NetApiBufferAllocate @ stub NetpIsComputerNameValid @ stub NetpIsDomainNameValid @ stub NetpIsGroupNameValid