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