ReactOS 0.4.15-dev-5666-gc548b97
misc.c File Reference
#include "netapi32.h"
#include <rpc.h>
#include "srvsvc_c.h"
#include "wkssvc_c.h"
Include dependency graph for misc.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (netapi32)
 
NET_API_STATUS WINAPI NetRegisterDomainNameChangeNotification (_Out_ PHANDLE NotificationEventHandle)
 
NET_API_STATUS WINAPI NetStatisticsGet (_In_ LPWSTR server, _In_ LPWSTR service, _In_ DWORD level, _In_ DWORD options, _Out_ LPBYTE *bufptr)
 
NET_API_STATUS WINAPI NetUnregisterDomainNameChangeNotification (_In_ HANDLE NotificationEventHandle)
 
PSTR WINAPI NetpAllocAnsiStrFromWStr (_In_ PWSTR InString)
 
PSTR WINAPI NetpAllocStrFromWStr (_In_ PWSTR InString)
 
PWSTR WINAPI NetpAllocWStrFromAnsiStr (_In_ PSTR InString)
 
PWSTR WINAPI NetpAllocWStrFromStr (_In_ PSTR InString)
 
PWSTR WINAPI NetpAllocWStrFromWStr (_In_ PWSTR InString)
 
NET_API_STATUS WINAPI NetpNtStatusToApiStatus (_In_ NTSTATUS Status)
 

Function Documentation

◆ NetpAllocAnsiStrFromWStr()

PSTR WINAPI NetpAllocAnsiStrFromWStr ( _In_ PWSTR  InString)

Definition at line 140 of file misc.c.

142{
145 ULONG Size;
146 NET_API_STATUS NetStatus;
148
150
152 NetStatus = NetApiBufferAllocate(Size,
153 (PVOID*)&AnsiString.Buffer);
154 if (NetStatus != NERR_Success)
155 return NULL;
156
159 FALSE);
160 if (!NT_SUCCESS(Status))
161 {
163 return NULL;
164 }
165
166 return AnsiString.Buffer;
167}
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID *Buffer)
Definition: apibuf.c:28
@ AnsiString
Definition: dnslib.h:19
Status
Definition: gdiplustypes.h:25
#define NERR_Success
Definition: lmerr.h:5
unsigned int ULONG
Definition: retypes.h:1
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#define RtlUnicodeStringToAnsiSize(String)
Definition: rtlfuncs.h:1005

Referenced by DsGetSiteNameA().

◆ NetpAllocStrFromWStr()

PSTR WINAPI NetpAllocStrFromWStr ( _In_ PWSTR  InString)

Definition at line 172 of file misc.c.

174{
177 ULONG Size;
178 NET_API_STATUS NetStatus;
180
182
184 NetStatus = NetApiBufferAllocate(Size,
185 (PVOID*)&OemString.Buffer);
186 if (NetStatus != NERR_Success)
187 return NULL;
188
191 FALSE);
192 if (!NT_SUCCESS(Status))
193 {
195 return NULL;
196 }
197
198 return OemString.Buffer;
199}
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING DestinationString, PCUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
STRING OEM_STRING
Definition: umtypes.h:203
#define RtlUnicodeStringToOemSize(STRING)
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1560

◆ NetpAllocWStrFromAnsiStr()

PWSTR WINAPI NetpAllocWStrFromAnsiStr ( _In_ PSTR  InString)

Definition at line 204 of file misc.c.

206{
209 ULONG Size;
210 NET_API_STATUS NetStatus;
212
213 RtlInitAnsiString(&AnsiString, InString);
214
216 NetStatus = NetApiBufferAllocate(Size,
217 (PVOID*)&UnicodeString.Buffer);
218 if (NetStatus != NERR_Success)
219 return NULL;
220
222 &AnsiString,
223 FALSE);
224 if (!NT_SUCCESS(Status))
225 {
227 return NULL;
228 }
229
230 return UnicodeString.Buffer;
231}
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define RtlAnsiStringToUnicodeSize(STRING)
Definition: nt_native.h:404

Referenced by DsAddressToSiteNamesA(), DsAddressToSiteNamesExA(), DsDeregisterDnsHostRecordsA(), DsEnumerateDomainTrustsA(), DsGetDcNameWithAccountA(), DsGetDcSiteCoverageA(), and DsGetSiteNameA().

◆ NetpAllocWStrFromStr()

PWSTR WINAPI NetpAllocWStrFromStr ( _In_ PSTR  InString)

Definition at line 236 of file misc.c.

238{
241 ULONG Size;
242 NET_API_STATUS NetStatus;
244
246
248 NetStatus = NetApiBufferAllocate(Size,
249 (PVOID*)&UnicodeString.Buffer);
250 if (NetStatus != NERR_Success)
251 return NULL;
252
254 &OemString,
255 FALSE);
256 if (!NT_SUCCESS(Status))
257 {
259 return NULL;
260 }
261
262 return UnicodeString.Buffer;
263}
NTSYSAPI NTSTATUS NTAPI RtlOemStringToUnicodeString(PUNICODE_STRING DestinationString, PCOEM_STRING SourceString, BOOLEAN AllocateDestinationString)
#define RtlOemStringToUnicodeSize(STRING)

◆ NetpAllocWStrFromWStr()

PWSTR WINAPI NetpAllocWStrFromWStr ( _In_ PWSTR  InString)

Definition at line 268 of file misc.c.

270{
271 PWSTR OutString;
272 ULONG Size;
274
275 Size = (wcslen(InString) + 1) * sizeof(WCHAR);
277 (PVOID*)&OutString);
278 if (Status != NERR_Success)
279 return NULL;
280
281 wcscpy(OutString, InString);
282
283 return OutString;
284}
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
uint16_t * PWSTR
Definition: typedefs.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ NetpNtStatusToApiStatus()

NET_API_STATUS WINAPI NetpNtStatusToApiStatus ( _In_ NTSTATUS  Status)

Definition at line 289 of file misc.c.

291{
292 NET_API_STATUS ApiStatus;
293
294 switch (Status)
295 {
296 case STATUS_SUCCESS:
297 ApiStatus = NERR_Success;
298 break;
299
301 ApiStatus = NERR_BadUsername;
302 break;
303
305 ApiStatus = NERR_UserExists;
306 break;
307
309 ApiStatus = NERR_GroupExists;
310 break;
311
313 ApiStatus = NERR_PasswordTooShort;
314 break;
315
316 default:
317 ApiStatus = RtlNtStatusToDosError(Status);
318 break;
319 }
320
321 return ApiStatus;
322}
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define NERR_BadUsername
Definition: lmerr.h:72
#define NERR_PasswordTooShort
Definition: lmerr.h:112
#define NERR_GroupExists
Definition: lmerr.h:90
#define NERR_UserExists
Definition: lmerr.h:91
#define STATUS_INVALID_ACCOUNT_NAME
Definition: ntstatus.h:334
#define STATUS_PASSWORD_RESTRICTION
Definition: ntstatus.h:344
#define STATUS_USER_EXISTS
Definition: ntstatus.h:335
#define STATUS_GROUP_EXISTS
Definition: ntstatus.h:337
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by BuildSidListFromDomainAndName(), BuildUserInfoBuffer(), GetUserDacl(), GetUserPrivileges(), NetGetDisplayInformationIndex(), NetGroupAdd(), NetGroupAddUser(), NetGroupDel(), NetGroupDelUser(), NetGroupEnum(), NetGroupGetInfo(), NetGroupGetUsers(), NetGroupSetInfo(), NetGroupSetUsers(), NetLocalGroupAdd(), NetLocalGroupAddMembers(), NetLocalGroupDel(), NetLocalGroupDelMembers(), NetLocalGroupEnum(), NetLocalGroupGetInfo(), NetLocalGroupGetMembers(), NetLocalGroupSetInfo(), NetpBind(), NetpUnbind(), NetQueryDisplayInformation(), NetRegisterDomainNameChangeNotification(), NetUnregisterDomainNameChangeNotification(), NetUserAdd(), NetUserChangePassword(), NetUserDel(), NetUserEnum(), NetUserGetGroups(), NetUserGetInfo(), NetUserGetLocalGroups(), NetUserModalsGet(), NetUserSetInfo(), OpenAliasByName(), OpenGroupByName(), OpenUserByName(), and SetUserInfo().

◆ NetRegisterDomainNameChangeNotification()

NET_API_STATUS WINAPI NetRegisterDomainNameChangeNotification ( _Out_ PHANDLE  NotificationEventHandle)

Definition at line 23 of file misc.c.

25{
28
29 TRACE("NetRegisterDomainNameChangeNotification(%p)\n",
30 NotificationEventHandle);
31
32 if (NotificationEventHandle == NULL)
34
36 if (EventHandle == NULL)
37 return GetLastError();
38
40 NotificationEventHandle);
41 if (!NT_SUCCESS(Status))
42 {
45 }
46
47 *NotificationEventHandle = EventHandle;
48
49 return NERR_Success;
50}
#define CloseHandle
Definition: compat.h:739
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
NET_API_STATUS WINAPI NetpNtStatusToApiStatus(_In_ NTSTATUS Status)
Definition: misc.c:289
NTSTATUS NTAPI LsaRegisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass, HANDLE NotificationEventHandle)
Definition: lsalpc.c:331
@ PolicyNotifyDnsDomainInformation
Definition: ntsecapi.h:283
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:857

◆ NetStatisticsGet()

NET_API_STATUS WINAPI NetStatisticsGet ( _In_ LPWSTR  server,
_In_ LPWSTR  service,
_In_ DWORD  level,
_In_ DWORD  options,
_Out_ LPBYTE bufptr 
)

Definition at line 55 of file misc.c.

61{
63
64 TRACE("NetStatisticsGet(%s %s %lu %lu %p)\n",
66
67 *bufptr = NULL;
68
69 if (_wcsicmp(service, L"LanmanWorkstation") == 0)
70 {
71 if (level != 0)
73
74 if (options != 0)
76
78 {
80 L"LanmanWorkstation",
81 level,
82 options,
84 }
86 {
88 }
90 }
91 else if (_wcsicmp(service, L"LanmanServer") == 0)
92 {
93 if (level != 0)
95
96 if (options != 0)
98
100 {
102 L"LanmanServer",
103 level,
104 options,
106 }
108 {
110 }
112 }
113
114 return status;
115}
NET_API_STATUS __stdcall NetrServerStatisticsGet(SRVSVC_HANDLE ServerName, WCHAR *Service, DWORD Level, DWORD Options, LPSTAT_SERVER_0 *InfoStruct)
Definition: rpcserver.c:472
unsigned long __stdcall NetrWorkstationStatisticsGet(WKSSVC_IDENTIFY_HANDLE ServerName, wchar_t *ServiceName, unsigned long Level, unsigned long Options, LPSTAT_WORKSTATION_0 *Buffer)
Definition: rpcserver.c:397
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
GLint level
Definition: gl.h:1546
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define debugstr_w
Definition: kernel32.h:32
#define L(x)
Definition: ntvdm.h:50
LONG WINAPI I_RpcMapWin32Status(RPC_STATUS status)
Definition: rpcrt4_main.c:740
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define RpcEndExcept
Definition: rpc.h:128
#define RpcTryExcept
Definition: rpc.h:126
#define RpcExcept(expr)
Definition: rpc.h:127
#define RpcExceptionCode()
Definition: rpc.h:132
Definition: ps.c:97
static unsigned int bufptr
Definition: tncon.cpp:77
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196

Referenced by DisplayServerStatistics(), and DisplayWorkstationStatistics().

◆ NetUnregisterDomainNameChangeNotification()

NET_API_STATUS WINAPI NetUnregisterDomainNameChangeNotification ( _In_ HANDLE  NotificationEventHandle)

Definition at line 120 of file misc.c.

122{
124
125 TRACE("NetUnregisterDomainNameChangeNotification(%p)\n",
126 NotificationEventHandle);
127
128 if (NotificationEventHandle == NULL)
130
132 NotificationEventHandle);
133
135}
NTSTATUS NTAPI LsaUnregisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass, HANDLE NotificationEventHandle)
Definition: lsalpc.c:378

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( netapi32  )