ReactOS  0.4.15-dev-4874-g57c84dd
util.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _NTLM_CLIENT_BUFFER
 

Typedefs

typedef struct _NTLM_CLIENT_BUFFER NTLM_CLIENT_BUFFER
 
typedef struct _NTLM_CLIENT_BUFFERPNTLM_CLIENT_BUFFER
 

Functions

bool NtlmUStrAlloc (_Out_ PUNICODE_STRING Dst, _In_ UINT16 SizeInBytes, _In_ UINT16 InitLength)
 
VOID NtlmUStrFree (_In_ PUNICODE_STRING String)
 
bool NtlmUStrWriteToStruct (_In_ PVOID DataStart, _In_ ULONG DataSize, _Out_ PUNICODE_STRING DstData, _In_ const PUNICODE_STRING SrcData, _In_ OUT PBYTE *AbsoluteOffsetPtr, _In_ bool TerminateWith0)
 
bool NtlmFixupAndValidateUStr (_Inout_ PUNICODE_STRING String, _In_ ULONG_PTR FixupOffset)
 
bool NtlmFixupAStr (_Inout_ PSTRING String, _In_ ULONG_PTR FixupOffset)
 
NTSTATUS NtlmAllocateClientBuffer (_In_ PLSA_CLIENT_REQUEST ClientRequest, _In_ ULONG BufferLength, _Inout_ PNTLM_CLIENT_BUFFER Buffer)
 
NTSTATUS NtlmCopyToClientBuffer (_In_ PLSA_CLIENT_REQUEST ClientRequest, _In_ ULONG BufferLength, _In_ OUT PNTLM_CLIENT_BUFFER Buffer)
 
VOID NtlmFreeClientBuffer (_In_ PLSA_CLIENT_REQUEST ClientRequest, _In_ bool FreeClientBuffer, _Inout_ PNTLM_CLIENT_BUFFER Buffer)
 

Typedef Documentation

◆ NTLM_CLIENT_BUFFER

◆ PNTLM_CLIENT_BUFFER

Function Documentation

◆ NtlmAllocateClientBuffer()

NTSTATUS NtlmAllocateClientBuffer ( _In_ PLSA_CLIENT_REQUEST  ClientRequest,
_In_ ULONG  BufferLength,
_Inout_ PNTLM_CLIENT_BUFFER  Buffer 
)

Definition at line 264 of file util.c.

268 {
270 
271  if (!Buffer)
272  return STATUS_NO_MEMORY;
273 
274  Buffer->LocalBuffer = NtlmAllocate(BufferLength, false);
275  if (!Buffer->LocalBuffer)
276  return STATUS_NO_MEMORY;
277 
278  if ((HANDLE)ClientRequest == INVALID_HANDLE_VALUE)
279  {
280  Buffer->ClientBaseAddress = Buffer->LocalBuffer;
281  //if (!ClientBaseAddress)
282  // return STATUS_INSUFFICIENT_RESOURCES;
283  }
284  else
285  {
286  Status = DispatchTable.AllocateClientBuffer(ClientRequest,
287  BufferLength,
288  &Buffer->ClientBaseAddress);
289  if (!NT_SUCCESS(Status))
290  {
291  NtlmFree(Buffer->LocalBuffer, false);
292  Buffer->LocalBuffer = NULL;
293  }
294  //FIXME: Maybe we have to free ClientBaseAddress if something
295  // goes wrong ...? I'm not sure about that ...
296  }
297  return Status;
298 }
VOID NtlmFree(_In_ PVOID Buffer, _In_ bool FromPrivateLsaHeap)
Definition: util.c:64
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
LONG NTSTATUS
Definition: precomp.h:26
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
Definition: bufpool.h:45
Status
Definition: gdiplustypes.h:24
PVOID NtlmAllocate(_In_ size_t Size, _In_ bool UsePrivateLsaHeap)
Definition: util.c:18
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245

Referenced by BuildLm20LogonProfileBuffer().

◆ NtlmCopyToClientBuffer()

NTSTATUS NtlmCopyToClientBuffer ( _In_ PLSA_CLIENT_REQUEST  ClientRequest,
_In_ ULONG  BufferLength,
_In_ OUT PNTLM_CLIENT_BUFFER  Buffer 
)

◆ NtlmFixupAndValidateUStr()

bool NtlmFixupAndValidateUStr ( _Inout_ PUNICODE_STRING  String,
_In_ ULONG_PTR  FixupOffset 
)

Definition at line 223 of file util.c.

226 {
228 
229  if (String->Length)
230  {
231  String->Buffer = FIXUP_POINTER(String->Buffer, FixupOffset);
232  String->MaximumLength = String->Length;
233  }
234  else
235  {
236  String->Buffer = NULL;
237  String->MaximumLength = 0;
238  }
239 
241  return NT_SUCCESS(Status);
242 }
LONG NTSTATUS
Definition: precomp.h:26
#define FIXUP_POINTER(Pointer, Offset)
Definition: msv1_0.h:9
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
NTSYSAPI NTSTATUS NTAPI RtlValidateUnicodeString(_In_ ULONG Flags, _In_ PCUNICODE_STRING String)
Definition: unicode.c:2559
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NULL
Definition: types.h:112

Referenced by LsaApLogonUserEx2_Network().

◆ NtlmFixupAStr()

bool NtlmFixupAStr ( _Inout_ PSTRING  String,
_In_ ULONG_PTR  FixupOffset 
)

Definition at line 245 of file util.c.

248 {
249  if (String->Length)
250  {
251  String->Buffer = (PCHAR)FIXUP_POINTER(String->Buffer, FixupOffset);
252  String->MaximumLength = String->Length;
253  }
254  else
255  {
256  String->Buffer = NULL;
257  String->MaximumLength = 0;
258  }
259 
260  return true;
261 }
#define FIXUP_POINTER(Pointer, Offset)
Definition: msv1_0.h:9
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
#define PCHAR
Definition: match.c:90
#define NULL
Definition: types.h:112

Referenced by LsaApLogonUserEx2_Network().

◆ NtlmFreeClientBuffer()

VOID NtlmFreeClientBuffer ( _In_ PLSA_CLIENT_REQUEST  ClientRequest,
_In_ bool  FreeClientBuffer,
_Inout_ PNTLM_CLIENT_BUFFER  Buffer 
)

Definition at line 335 of file util.c.

339 {
340  if (!Buffer->ClientBaseAddress)
341  return;
342 
343  if ((HANDLE)ClientRequest == INVALID_HANDLE_VALUE)
344  {
345  if (Buffer->ClientBaseAddress != Buffer->LocalBuffer)
346  {
347  ERR("Buffer->ClientBaseAddress != Buffer->LocalBuffer (something must be wrong!)\n");
348  return;
349  }
350  // LocalBuffer and ClientBaseAddress is the same
351  // so we have only to free it if FreeClientBuffer is TRUE.
352  Buffer->LocalBuffer = NULL;
353  if (FreeClientBuffer)
354  {
355  NtlmFree(Buffer->ClientBaseAddress, false);
356  Buffer->ClientBaseAddress = NULL;
357  }
358  }
359  else
360  {
361  NtlmFree(Buffer->LocalBuffer, false);
362  Buffer->LocalBuffer = NULL;
363  if (FreeClientBuffer)
364  DispatchTable.FreeClientBuffer(ClientRequest, Buffer->ClientBaseAddress);
365  Buffer->ClientBaseAddress = NULL;
366  }
367 }
VOID NtlmFree(_In_ PVOID Buffer, _In_ bool FromPrivateLsaHeap)
Definition: util.c:64
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
Definition: bufpool.h:45
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245

Referenced by BuildLm20LogonProfileBuffer().

◆ NtlmUStrAlloc()

bool NtlmUStrAlloc ( _Out_ PUNICODE_STRING  Dst,
_In_ UINT16  SizeInBytes,
_In_ UINT16  InitLength 
)

◆ NtlmUStrFree()

VOID NtlmUStrFree ( _In_ PUNICODE_STRING  String)

Definition at line 115 of file util.c.

117 {
118  if (String == NULL || String->Buffer == NULL || String->MaximumLength == 0)
119  return;
120 
121  NtlmFree(String->Buffer, false);
122  String->Buffer = NULL;
123  String->MaximumLength = 0;
124 }
VOID NtlmFree(_In_ PVOID Buffer, _In_ bool FromPrivateLsaHeap)
Definition: util.c:64
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
#define NULL
Definition: types.h:112

Referenced by BuildLm20LogonProfileBuffer().

◆ NtlmUStrWriteToStruct()

bool NtlmUStrWriteToStruct ( _In_ PVOID  DataStart,
_In_ ULONG  DataSize,
_Out_ PUNICODE_STRING  DstData,
_In_ const PUNICODE_STRING  SrcData,
_In_ OUT PBYTE AbsoluteOffsetPtr,
_In_ bool  TerminateWith0 
)