From 8810aa8908ed7887616d86dd5fb821fcfa92f444 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 3 Jun 2022 17:50:22 -0500 Subject: Update Burn algorithm for picking elevated temp path to use SystemTemp. --- src/libs/dutil/test/DUtilUnitTest/ProcUtilTest.cpp | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/libs/dutil/test/DUtilUnitTest/ProcUtilTest.cpp (limited to 'src/libs/dutil/test/DUtilUnitTest/ProcUtilTest.cpp') diff --git a/src/libs/dutil/test/DUtilUnitTest/ProcUtilTest.cpp b/src/libs/dutil/test/DUtilUnitTest/ProcUtilTest.cpp new file mode 100644 index 00000000..297d90f4 --- /dev/null +++ b/src/libs/dutil/test/DUtilUnitTest/ProcUtilTest.cpp @@ -0,0 +1,42 @@ +// 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. + +#include "precomp.h" + +using namespace System; +using namespace System::Security::Principal; +using namespace Xunit; +using namespace WixBuildTools::TestSupport; + +namespace DutilTests +{ + public ref class ProcUtil + { + public: + [Fact] + void ProcTokenUserTest() + { + HRESULT hr = S_OK; + TOKEN_USER* pTokenUser = NULL; + LPWSTR sczSid = NULL; + + try + { + hr = ProcTokenUser(::GetCurrentProcess(), &pTokenUser); + NativeAssert::Succeeded(hr, "Failed to get TokenUser for current process."); + + if (!::ConvertSidToStringSidW(pTokenUser->User.Sid, &sczSid)) + { + hr = HRESULT_FROM_WIN32(::GetLastError()); + NativeAssert::Succeeded(hr, "Failed to get string SID from TokenUser SID."); + } + + Assert::Equal(WindowsIdentity::GetCurrent()->User->Value, gcnew String(sczSid)); + } + finally + { + ReleaseMem(pTokenUser); + ReleaseStr(sczSid); + } + } + }; +} -- cgit v1.2.3-55-g6feb