From 5d61a4a79a1e96dc5d9af1e5e712c84507307544 Mon Sep 17 00:00:00 2001 From: J M Rossy Date: Wed, 29 Jul 2015 15:40:09 -0700 Subject: Samples update for public Windows 10 release Fix #2 Enabling WPP Recorder in Sensors Samples causes errors Fix #4 Add back fixed KMDOD sample Add new BarcodeScanner sample in pos folder Add new MagneticStripeReader sample in pos folder Add new SynpaticsTouch sample in input folder Add new Power Engine Plugin sample in pofx folder Add new DeviceMft sample in avstream folder Add new AvsCamera sample in root Add new SimBatt sample in root Add other pre-existing samples not yet released for Win10 --- .../trans/WFPSampler/lib/HelperFunctions_GUID.cpp | 318 +++++++++++++++++++++ 1 file changed, 318 insertions(+) create mode 100644 network/trans/WFPSampler/lib/HelperFunctions_GUID.cpp (limited to 'network/trans/WFPSampler/lib/HelperFunctions_GUID.cpp') diff --git a/network/trans/WFPSampler/lib/HelperFunctions_GUID.cpp b/network/trans/WFPSampler/lib/HelperFunctions_GUID.cpp new file mode 100644 index 00000000..eda8106e --- /dev/null +++ b/network/trans/WFPSampler/lib/HelperFunctions_GUID.cpp @@ -0,0 +1,318 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2012 Microsoft Corporation. All Rights Reserved. +// +// Module Name: +// HelperFunctions_GUID.cpp +// +// Abstract: +// This module contains functions which assist in actions pertaining to GUIDs. +// +// Naming Convention: +// +// +// +// i.e. +// +// +// { +// - Function is likely visible to other modules +// } +// +// { +// Hlpr - Function is from HelperFunctions_* Modules. +// } +// +// { +// GUID - Function pertains to GUID objects. +// } +// +// { +// Are - Function compares values. +// Create - Function allocates and fills memory. +// Destroy - Function cleans up and frees memory. +// Is - Function compares values. +// Populate - Function fills memory with values. +// Purge - Function cleans up values. +// } +// +// { +// Equal - Function determines equality between values. +// Null - Function determines if value is Null or empty. +// String - Function acts on a null terminated wide character string. +// } +// +// Private Functions: +// +// Public Functions: +// HlprGUIDsAreEqual(), +// HlprGUIDCreate(), +// HlprGUIDCreateString(), +// HlprGUIDDestroy(), +// HlprGUIDDestroyString(), +// HlprGUIDIsNull() +// HlprGUIDPopulate(), +// HlprGUIDPurge(), +// +// Author: +// Dusty Harper (DHarper) +// +// Revision History: +// +// [ Month ][Day] [Year] - [Revision]-[ Comments ] +// May 01, 2010 - 1.0 - Creation +// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "HelperFunctions_Include.h" /// . + +static const GUID NULL_GUID = {0}; + +/** + @helper_function="HlprGUIDPurge" + + Purpose: Cleanup a GUID.
+
+ Notes:
+
+ MSDN_Ref:
+*/ +VOID HlprGUIDPurge(_Inout_ GUID* pGUID) +{ + if(pGUID) + ZeroMemory(pGUID, + sizeof(GUID)); + + return; +} + +/** + @helper_function="HlprGUIDDestroy" + + Purpose: Cleanup and free a GUID.
+
+ Notes:
+
+ MSDN_Ref:
+*/ +_At_(*ppGUID, _Post_ _Null_) +VOID HlprGUIDDestroy(_Inout_ GUID** ppGUID) +{ + if(ppGUID) + { + if(*ppGUID) + HlprGUIDPurge(*ppGUID); + + HLPR_DELETE(*ppGUID); + } + + return; +} + +/** + @helper_function="HlprGUIDPopulate" + + Purpose: Populate a GUID with a random value.
+
+ Notes:
+
+ MSDN_Ref: HTTP://MSDN.Microsoft.com/En-US/Library/AA379205.aspx
+*/ +_Success_(return == NO_ERROR) +UINT32 HlprGUIDPopulate(_Inout_ GUID* pGUID) +{ + UINT32 status = NO_ERROR; + + if(pGUID) + { + status = UuidCreate(pGUID); + + if(status != RPC_S_OK && // 0 + status != RPC_S_UUID_LOCAL_ONLY) // 1824 + { + // RPC_S_UUID_NO_ADDRESS // 1739 + HlprLogError(L"HlprGUIDPopulate : UuidCreate() [status: %#x]", + status); + } + else + status = NO_ERROR; + } + else + { + status = ERROR_INVALID_PARAMETER; + + HlprLogError(L"HlprGUIDPopulate() [status: %#x][pGUID: %#p]", + status, + pGUID); + } + + return status; +} + +/** + @helper_function="HlprGUIDCreate" + + Purpose: Allocate and populate a GUID with a random value.
+
+ Notes: The caller is responsible for freeing the allocated memory using + HlprGUIDDestroy().
+
+ MSDN_Ref: HTTP://MSDN.Microsoft.com/En-US/Library/AA379205.aspx
+*/ +_At_(*ppGUID, _Pre_ _Null_) +_When_(return != NO_ERROR, _At_(*ppGUID, _Post_ _Null_)) +_When_(return == NO_ERROR, _At_(*ppGUID, _Post_ _Notnull_)) +_Success_(return == NO_ERROR) +UINT32 HlprGUIDCreate(_Outptr_ GUID** ppGUID) +{ + UINT32 status = NO_ERROR; + + if(ppGUID) + { + HLPR_NEW(*ppGUID, + GUID); + HLPR_BAIL_ON_ALLOC_FAILURE(*ppGUID, + status); + + status = HlprGUIDPopulate(*ppGUID); + + HLPR_BAIL_LABEL: + + if(status != NO_ERROR) + { + HLPR_DELETE(*ppGUID); + } + } + else + { + status = ERROR_INVALID_PARAMETER; + + HlprLogError(L"HlprGUIDCreate() [status: %#x][ppGUID: %#p]", + status, + ppGUID); + } + + return status; +} + +/** + @helper_function="HlprGUIDDestroyString" + + Purpose: Cleanup and free a string representing a GUID.
+
+ Notes: Use if string was allocated by HlprGUIDCreateString().
+
+ MSDN_Ref: HTTP://MSDN.Microsoft.com/En-US/Library/AA378483.aspx
+*/ +_When_(return != NO_ERROR, _At_(*ppGUIDString, _Post_ _Notnull_)) +_When_(return == NO_ERROR, _At_(*ppGUIDString, _Post_ _Null_)) +_Success_(return == NO_ERROR) +UINT32 HlprGUIDDestroyString(_Inout_ PWSTR* ppGUIDString) +{ + UINT32 status = NO_ERROR; + + if(ppGUIDString && + *ppGUIDString) + { + status = RpcStringFree(ppGUIDString); + if(status != RPC_S_OK) + HlprLogError(L"HlprGUIDDestroyString : RpcStringFree() [status: %#x]", + status); + else + *ppGUIDString = 0; + } + + return status; +} + +/** + @helper_function="HlprGUIDCreateString" + + Purpose: Allocate and populate a string representing the provided GUID.
+
+ Notes: The caller is responsible for freeing the allocated memory using + HlprGUIDDestroyString().
+
+ MSDN_Ref: HTTP://MSDN.Microsoft.com/En-US/Library/AA379352.aspx
+*/ +_Success_(return != 0) +PWSTR HlprGUIDCreateString(_In_ const GUID* pGUID) +{ + PWSTR pGUIDString = 0; + + if(pGUID) + { + UINT32 status = NO_ERROR; + + status = UuidToString(pGUID, + &pGUIDString); + if(status != NO_ERROR) + { + HlprLogError(L"HlprGUIDCreateString : UuidToString() [status: %#x]", + status); + } + } + + return pGUIDString; +} + +/** + @helper_function="HlprGUIDsAreEqual" + + Purpose: Determine if two GUIDs are identical.
+
+ Notes:
+
+ MSDN_Ref: HTTP://MSDN.Microsoft.com/En-US/Library/AA379329.aspx
+*/ +BOOLEAN HlprGUIDsAreEqual(_In_ const GUID* pGUIDAlpha, + _In_ const GUID* pGUIDOmega) +{ + RPC_STATUS status = RPC_S_OK; + UINT32 areEqual = FALSE; + + if(pGUIDAlpha == 0 || + pGUIDOmega == 0) + { + if((pGUIDAlpha == 0 && + pGUIDOmega) || + (pGUIDAlpha && + pGUIDOmega == 0)) + + HLPR_BAIL; + } + + if(pGUIDAlpha == 0 && + pGUIDOmega == 0) + { + areEqual = TRUE; + + HLPR_BAIL; + } + + areEqual = UuidEqual((UUID*)pGUIDAlpha, + (UUID*)pGUIDOmega, + &status); + if(status != RPC_S_OK) + HlprLogError(L"HlprGUIDsAreEqual : UuidEqual() [status %#x]", + status); + + HLPR_BAIL_LABEL: + + return (BOOLEAN)areEqual; +} + +/** + @helper_function="HlprGUIDIsNull" + + Purpose: Determine if a GUID is a NULL GUID.
+
+ Notes:
+
+ MSDN_Ref:
+*/ +BOOLEAN HlprGUIDIsNull(_In_ const GUID* pGUID) +{ + return HlprGUIDsAreEqual(pGUID, + (GUID*)&NULL_GUID);; +} -- cgit v1.3.1