uLib  User mode C/C++ extended API library for Win32 programmers.
UNICODE_STRING Support

Module Description

Supplements for native UNICODE_STRINGs..

Classes

class  UString
 

Macros

#define INIT_PACKED_UNICODE_STRING(pu, bufsize)
 

Functions

PUNICODE_STRING mem_AllocUniStr (WORD ccStr, OPTOUT PULONG cbAlloc)
 
PUNICODE_STRING _InitUnicodeString (PUNICODE_STRING puStr, PCWSTR pwzSrc)
 
PSTRING _InitString (PSTRING pStr, LPCSTR pzSrc)
 
bool SetUnicodeString (PUNICODE_STRING puStr, WCSTR wzSrc)
 
PUNICODE_STRING InitPackedUnicodeString (PVOID Buffer, USHORT cbBuffer)
 

Macro Definition Documentation

◆ INIT_PACKED_UNICODE_STRING

#define INIT_PACKED_UNICODE_STRING (   pu,
  bufsize 
)
Value:
(pu)->Buffer = (PWSTR)( (PBYTE)(pu) + sizeof(UNICODE_STRING) ); \
(pu)->MaximumLength = bufsize - sizeof(UNICODE_STRING); \
(pu)->Length = 0
unsigned char * PBYTE
Definition: Common.h:412

Setup a UNICODE_STRING to point to the first WCHAR after itself.

Parameters
puPointer to the UNICODE_STRING at the head of the buffer.
bufsizeSize of the buffer, including the UNICODE_STRING struct.

See also SetUnicodeString()

Definition at line 607 of file StrFunc.h.

Function Documentation

◆ mem_AllocUniStr()

PUNICODE_STRING mem_AllocUniStr ( WORD  ccStr,
OPTOUT PULONG  cbAlloc 
)

Allocate and initialize a packed UNICODE_STRING buffer.
The allocated buffer iz zero-filled, and the struct initialized.

Parameters
ccStrCount of WCHAR to allocate to the UNICODE_STRING::Buffer.
cbAllocIf supplied, recieves the byte size of the whole allocation.

Dispose with mem_Free().

◆ _InitUnicodeString()

PUNICODE_STRING _InitUnicodeString ( PUNICODE_STRING  puStr,
PCWSTR  pwzSrc 
)

Alternative to RtlInitUnicodeString() / InitLsaUnicodeString().
The function returns puStr for easy chain-assignment.

Definition at line 1340 of file StrFunc.cpp.

◆ _InitString()

PSTRING _InitString ( PSTRING  pStr,
LPCSTR  pzSrc 
)

Alternative to RtlInitString(). The function returns pStr for easy chain-assignment.

Definition at line 1352 of file StrFunc.cpp.

◆ SetUnicodeString()

bool SetUnicodeString ( PUNICODE_STRING  puStr,
WCSTR  wzSrc 
)

Copy wzSrc (incl NUL) to puStr->Buffer if puStr->MaximumLength permits.
If MaximumLength is too small, do nothing and return false, else true.
Note: MaximumLength is never changed under any circumstance, only Length.

Definition at line 1370 of file StrFunc.cpp.

◆ InitPackedUnicodeString()

PUNICODE_STRING InitPackedUnicodeString ( PVOID  Buffer,
USHORT  cbBuffer 
)

Function version of INIT_PACKED_UNICODE_STRING.
Buffer points to your buffer, and cbBuffer is it's size, in bytes.
The return value is your Buffer, cast to a UNICODE_STRING pointer.

See also mem_AllocUnistr().

Definition at line 1364 of file StrFunc.cpp.