aboutsummaryrefslogtreecommitdiff
path: root/src/libs/dutil/WixToolset.DUtil/guidutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/guidutil.cpp')
-rw-r--r--src/libs/dutil/WixToolset.DUtil/guidutil.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/guidutil.cpp b/src/libs/dutil/WixToolset.DUtil/guidutil.cpp
new file mode 100644
index 00000000..204c9af2
--- /dev/null
+++ b/src/libs/dutil/WixToolset.DUtil/guidutil.cpp
@@ -0,0 +1,54 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3#include "precomp.h"
4
5
6// Exit macros
7#define GuidExitOnLastError(x, s, ...) ExitOnLastErrorSource(DUTIL_SOURCE_GUIDUTIL, x, s, __VA_ARGS__)
8#define GuidExitOnLastErrorDebugTrace(x, s, ...) ExitOnLastErrorDebugTraceSource(DUTIL_SOURCE_GUIDUTIL, x, s, __VA_ARGS__)
9#define GuidExitWithLastError(x, s, ...) ExitWithLastErrorSource(DUTIL_SOURCE_GUIDUTIL, x, s, __VA_ARGS__)
10#define GuidExitOnFailure(x, s, ...) ExitOnFailureSource(DUTIL_SOURCE_GUIDUTIL, x, s, __VA_ARGS__)
11#define GuidExitOnRootFailure(x, s, ...) ExitOnRootFailureSource(DUTIL_SOURCE_GUIDUTIL, x, s, __VA_ARGS__)
12#define GuidExitOnFailureDebugTrace(x, s, ...) ExitOnFailureDebugTraceSource(DUTIL_SOURCE_GUIDUTIL, x, s, __VA_ARGS__)
13#define GuidExitOnNull(p, x, e, s, ...) ExitOnNullSource(DUTIL_SOURCE_GUIDUTIL, p, x, e, s, __VA_ARGS__)
14#define GuidExitOnNullWithLastError(p, x, s, ...) ExitOnNullWithLastErrorSource(DUTIL_SOURCE_GUIDUTIL, p, x, s, __VA_ARGS__)
15#define GuidExitOnNullDebugTrace(p, x, e, s, ...) ExitOnNullDebugTraceSource(DUTIL_SOURCE_GUIDUTIL, p, x, e, s, __VA_ARGS__)
16#define GuidExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_GUIDUTIL, p, x, s, __VA_ARGS__)
17#define GuidExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_GUIDUTIL, e, x, s, __VA_ARGS__)
18#define GuidExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_GUIDUTIL, g, x, s, __VA_ARGS__)
19
20extern "C" HRESULT DAPI GuidFixedCreate(
21 _Out_z_cap_c_(GUID_STRING_LENGTH) WCHAR* wzGuid
22 )
23{
24 HRESULT hr = S_OK;
25 UUID guid = { };
26
27 hr = HRESULT_FROM_RPC(::UuidCreate(&guid));
28 GuidExitOnFailure(hr, "UuidCreate failed.");
29
30 if (!::StringFromGUID2(guid, wzGuid, GUID_STRING_LENGTH))
31 {
32 hr = E_OUTOFMEMORY;
33 GuidExitOnRootFailure(hr, "Failed to convert guid into string.");
34 }
35
36LExit:
37 return hr;
38}
39
40extern "C" HRESULT DAPI GuidCreate(
41 __deref_out_z LPWSTR* psczGuid
42 )
43{
44 HRESULT hr = S_OK;
45
46 hr = StrAlloc(psczGuid, GUID_STRING_LENGTH);
47 GuidExitOnFailure(hr, "Failed to allocate space for guid");
48
49 hr = GuidFixedCreate(*psczGuid);
50 GuidExitOnFailure(hr, "Failed to create new guid.");
51
52LExit:
53 return hr;
54}