| 1 | // Licensed to the .NET Foundation under one or more agreements. | 
| 2 | // The .NET Foundation licenses this file to you under the MIT license. | 
| 3 | // See the LICENSE file in the project root for more information. | 
| 4 | // | 
| 5 |  | 
| 6 | // | 
| 7 | // =========================================================================== | 
| 8 | // File: guid.cpp | 
| 9 | //  | 
| 10 | // PALRT guids | 
| 11 | // =========================================================================== | 
| 12 |  | 
| 13 | #define INITGUID | 
| 14 | #include <guiddef.h> | 
| 15 |  | 
| 16 | // These are GUIDs and IIDs that would normally be provided by the system via uuid.lib, | 
| 17 | // and that the PALRT exposes through headers. | 
| 18 |  | 
| 19 | DEFINE_GUID(GUID_NULL, 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); | 
| 20 | DEFINE_GUID(IID_IUnknown, 0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); | 
| 21 | DEFINE_GUID(IID_IClassFactory, 0x00000001, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); | 
| 22 |  | 
| 23 |  | 
| 24 | // objidl.idl | 
| 25 | DEFINE_GUID(IID_ISequentialStream, 0x0c733a30, 0x2a1c, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d); | 
| 26 | DEFINE_GUID(IID_IStream, 0x0000000c, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); | 
| 27 |  | 
| 28 | // Create a random guid based on the https://www.ietf.org/rfc/rfc4122.txt | 
| 29 | STDAPI | 
| 30 | CoCreateGuid(OUT GUID * pguid) | 
| 31 | { | 
| 32 |     PAL_Random(pguid, sizeof(GUID)); | 
| 33 |  | 
| 34 |     static const USHORT VersionMask = 0xF000; | 
| 35 |     static const USHORT RandomGuidVersion = 0x4000; | 
| 36 |  | 
| 37 |     static const BYTE ClockSeqHiAndReservedMask = 0xC0; | 
| 38 |     static const BYTE ClockSeqHiAndReservedValue = 0x80; | 
| 39 |  | 
| 40 |     // Modify bits indicating the type of the GUID | 
| 41 |  | 
| 42 |     // time_hi_and_version | 
| 43 |     pguid->Data3 = (pguid->Data3 & ~VersionMask) | RandomGuidVersion; | 
| 44 |     // clock_seq_hi_and_reserved | 
| 45 |     pguid->Data4[0] = (pguid->Data4[0] & ~ClockSeqHiAndReservedMask) | ClockSeqHiAndReservedValue; | 
| 46 |  | 
| 47 |     return S_OK; | 
| 48 | } | 
| 49 |  |