Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

guid.c File Reference

#include "nt.h"
#include "ntrtlp.h"

Go to the source code of this file.

Defines

#define GUID_STRING_SIZE   38

Functions

NTSYSAPI NTSTATUS NTAPI RtlStringFromGUID (IN REFGUID Guid, OUT PUNICODE_STRING GuidString)
int __cdecl ScanHexFormat (IN const WCHAR *Buffer, IN ULONG MaximumLength, IN const WCHAR *Format,...)
NTSYSAPI NTSTATUS NTAPI RtlGUIDFromString (IN PUNICODE_STRING GuidString, OUT GUID *Guid)

Variables

const WCHAR GuidFormat []


Define Documentation

#define GUID_STRING_SIZE   38
 

Definition at line 45 of file guid.c.


Function Documentation

NTSYSAPI NTSTATUS NTAPI RtlGUIDFromString IN PUNICODE_STRING  GuidString,
OUT GUID *  Guid
 

Definition at line 191 of file guid.c.

References Count, GuidFormat, RTL_PAGED_CODE, ScanHexFormat(), and USHORT.

Referenced by IopParseSymbolicLinkName(), and IopRemoveDeviceInterfaces().

00197 : 00198 00199 Retrieves a the binary format of a textual GUID presented in the standard 00200 string version of a GUID: "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}". 00201 00202 Arguments: 00203 00204 GuidString - 00205 Place from which to retrieve the textual form of the GUID. 00206 00207 Guid - 00208 Place in which to put the binary form of the GUID. 00209 00210 Return Value: 00211 00212 Returns STATUS_SUCCESS if the buffer contained a valid GUID, else 00213 STATUS_INVALID_PARAMETER if the string was invalid. 00214 00215 --*/ 00216 { 00217 USHORT Data4[8]; 00218 int Count; 00219 00220 RTL_PAGED_CODE(); 00221 if (ScanHexFormat(GuidString->Buffer, GuidString->Length / sizeof(WCHAR), GuidFormat, &Guid->Data1, &Guid->Data2, &Guid->Data3, &Data4[0], &Data4[1], &Data4[2], &Data4[3], &Data4[4], &Data4[5], &Data4[6], &Data4[7]) == -1) { 00222 return STATUS_INVALID_PARAMETER; 00223 } 00224 for (Count = 0; Count < sizeof(Data4)/sizeof(Data4[0]); Count++) { 00225 Guid->Data4[Count] = (UCHAR)Data4[Count]; 00226 } 00227 return STATUS_SUCCESS; 00228 } }

NTSYSAPI NTSTATUS NTAPI RtlStringFromGUID IN REFGUID  Guid,
OUT PUNICODE_STRING  GuidString
 

Definition at line 51 of file guid.c.

References GUID_STRING_SIZE, GuidFormat, RTL_PAGED_CODE, and RtlAllocateStringRoutine.

Referenced by CmpCloneHwProfile(), IoGetDeviceInterfaceAlias(), IopGetDeviceInterfaces(), and IopRegisterDeviceInterface().

00057 : 00058 00059 Constructs the standard string version of a GUID, in the form: 00060 "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}". 00061 00062 Arguments: 00063 00064 Guid - 00065 Contains the GUID to translate. 00066 00067 GuidString - 00068 Returns a string that represents the textual format of the GUID. 00069 Caller must call RtlFreeUnicodeString to free the buffer when done with 00070 it. 00071 00072 Return Value: 00073 00074 NTSTATUS - Returns STATUS_SUCCESS if the user string was succesfully 00075 initialized. 00076 00077 --*/ 00078 { 00079 RTL_PAGED_CODE(); 00080 GuidString->Length = GUID_STRING_SIZE * sizeof(WCHAR); 00081 GuidString->MaximumLength = GuidString->Length + sizeof(UNICODE_NULL); 00082 if (!(GuidString->Buffer = RtlAllocateStringRoutine(GuidString->MaximumLength))) { 00083 return STATUS_NO_MEMORY; 00084 } 00085 swprintf(GuidString->Buffer, GuidFormat, Guid->Data1, Guid->Data2, Guid->Data3, Guid->Data4[0], Guid->Data4[1], Guid->Data4[2], Guid->Data4[3], Guid->Data4[4], Guid->Data4[5], Guid->Data4[6], Guid->Data4[7]); 00086 return STATUS_SUCCESS; 00087 }

int __cdecl ScanHexFormat IN const WCHAR *  Buffer,
IN ULONG  MaximumLength,
IN const WCHAR *  Format,
  ...
[static]
 

Definition at line 93 of file guid.c.

References Buffer, PUSHORT, and USHORT.

Referenced by RtlGUIDFromString().

00100 : 00101 00102 Scans a source Buffer and places values from that buffer into the parameters 00103 as specified by Format. 00104 00105 Arguments: 00106 00107 Buffer - 00108 Contains the source buffer which is to be scanned. 00109 00110 MaximumLength - 00111 Contains the maximum length in characters for which Buffer is searched. 00112 This implies that Buffer need not be UNICODE_NULL terminated. 00113 00114 Format - 00115 Contains the format string which defines both the acceptable string format 00116 contained in Buffer, and the variable parameters which follow. 00117 00118 Return Value: 00119 00120 Returns the number of parameters filled if the end of the Buffer is reached, 00121 else -1 on an error. 00122 00123 --*/ 00124 { 00125 va_list ArgList; 00126 int FormatItems; 00127 00128 va_start(ArgList, Format); 00129 for (FormatItems = 0;;) { 00130 switch (*Format) { 00131 case 0: 00132 return (MaximumLength && *Buffer) ? -1 : FormatItems; 00133 case '%': 00134 Format++; 00135 if (*Format != '%') { 00136 ULONG Number; 00137 int Width; 00138 int Long; 00139 PVOID Pointer; 00140 00141 for (Long = 0, Width = 0;; Format++) { 00142 if ((*Format >= '0') && (*Format <= '9')) { 00143 Width = Width * 10 + *Format - '0'; 00144 } else if (*Format == 'l') { 00145 Long++; 00146 } else if ((*Format == 'X') || (*Format == 'x')) { 00147 break; 00148 } 00149 } 00150 Format++; 00151 for (Number = 0; Width--; Buffer++, MaximumLength--) { 00152 if (!MaximumLength) 00153 return -1; 00154 Number *= 16; 00155 if ((*Buffer >= '0') && (*Buffer <= '9')) { 00156 Number += (*Buffer - '0'); 00157 } else if ((*Buffer >= 'a') && (*Buffer <= 'f')) { 00158 Number += (*Buffer - 'a' + 10); 00159 } else if ((*Buffer >= 'A') && (*Buffer <= 'F')) { 00160 Number += (*Buffer - 'A' + 10); 00161 } else { 00162 return -1; 00163 } 00164 } 00165 Pointer = va_arg(ArgList, PVOID); 00166 if (Long) { 00167 *(PULONG)Pointer = Number; 00168 } else { 00169 *(PUSHORT)Pointer = (USHORT)Number; 00170 } 00171 FormatItems++; 00172 break; 00173 } 00174 /* no break */ 00175 default: 00176 if (!MaximumLength || (*Buffer != *Format)) { 00177 return -1; 00178 } 00179 Buffer++; 00180 MaximumLength--; 00181 Format++; 00182 break; 00183 } 00184 } 00185 }


Variable Documentation

const WCHAR GuidFormat[]
 

Definition at line 43 of file guid.c.

Referenced by RtlGUIDFromString(), and RtlStringFromGUID().


Generated on Sat May 15 19:43:54 2004 for test by doxygen 1.3.7