summaryrefslogtreecommitdiff
path: root/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.cpp
diff options
context:
space:
mode:
authorAdonais Romero González <[email protected]>2024-05-06 16:21:31 -0700
committerGitHub <[email protected]>2024-05-06 16:21:31 -0700
commita74a241c664c4e1d7c0838287b34076c19d9858a (patch)
tree6ff7562612967b122acf8acf8a69c4dcfd5905db /general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.cpp
parentdef8e8e34ed2b7b1deb2fc9112ac4255f1a0f2ba (diff)
parent15477ce52bbb6b42ca591ecdfb484cac089f89ab (diff)
Merge develop changes prior to upcoming WDK release (May 2024)
Diffstat (limited to 'general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.cpp')
-rw-r--r--general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.cpp177
1 files changed, 0 insertions, 177 deletions
diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.cpp b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.cpp
deleted file mode 100644
index 870d6306..00000000
--- a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-//*********************************************************
-//
-// Copyright (c) Microsoft. All rights reserved.
-// This code is licensed under the MIT License (MIT).
-// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
-// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
-// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
-// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
-//
-//*********************************************************
-
-// There is an error in the system header files that incorrectly
-// places RpcStringBindingCompose in the app partition.
-// Work around it by changing the WINAPI_FAMILY to desktop temporarily.
-#pragma push_macro("WINAPI_FAMILY")
-#undef WINAPI_FAMILY
-#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
-#include "RpcClient.h"
-#pragma pop_macro("WINAPI_FAMILY")
-
-using namespace SDKTemplate;
-
-__int64 RpcClient::Initialize()
-{
- RPC_STATUS status;
- RPC_WSTR pszStringBinding = nullptr;
-
- status = RpcStringBindingCompose(
- NULL,
- reinterpret_cast<RPC_WSTR>(L"ncalrpc"),
- NULL,
- reinterpret_cast<RPC_WSTR>(RPC_STATIC_ENDPOINT),
- NULL,
- &pszStringBinding);
-
- if (status)
- {
- goto error_status;
- }
-
- status = RpcBindingFromStringBinding(
- pszStringBinding,
- &hRpcBinding);
-
- if (status)
- {
- goto error_status;
- }
-
- status = RpcStringFree(&pszStringBinding);
-
- if (status)
- {
- goto error_status;
- }
-
- RpcTryExcept
- {
- ::RemoteOpen(hRpcBinding, &phContext);
- }
- RpcExcept(1)
- {
- status = RpcExceptionCode();
- }
- RpcEndExcept
-
-error_status:
-
- return status;
-}
-
-//
-// Make RPC call to start metering. This is a blocking call and
-// will return only after StopMetering is called.
-//
-__int64 RpcClient::StartMeteringAndWaitForStop(__int64 samplePeriod)
-{
- __int64 ulCode = 0;
- CallbackCount = 0;
- MeteringData = 0;
-
- RpcTryExcept
- {
- ::StartMetering(phContext, samplePeriod, (__int64)this);
- }
- RpcExcept(1)
- {
- ulCode = RpcExceptionCode();
- }
- RpcEndExcept
-
- return ulCode;
-}
-
-
-//
-// Make rpc call SetSampleRate
-//
-__int64 RpcClient::SetSampleRate(int rate)
-{
- __int64 ulCode = 0;
- RpcTryExcept
- {
- ::SetSamplePeriod(phContext, rate);
- }
- RpcExcept(1)
- {
- ulCode = RpcExceptionCode();
- }
- RpcEndExcept
- return ulCode;
-}
-
-//
-// Make rpc call StopMetering
-//
-__int64 RpcClient::StopMetering()
-{
- __int64 ulCode = 0;
- RpcTryExcept
- {
- ::StopMetering(phContext);
- }
- RpcExcept(1)
- {
- ulCode = RpcExceptionCode();
- }
- RpcEndExcept
- return ulCode;
-}
-
-RpcClient::~RpcClient()
-{
- RPC_STATUS status;
-
- if (hRpcBinding != NULL)
- {
- RpcTryExcept
- {
- ::RemoteClose(&phContext);
- }
- RpcExcept(1)
- {
- // Ignoring the result of RemoteClose as nothing can be
- // done on the client side with this return code
- status = RpcExceptionCode();
- }
- RpcEndExcept
-
- status = RpcBindingFree(&hRpcBinding);
- hRpcBinding = NULL;
- }
-}
-
-//
-// Metering rpc callback
-//
-void MeteringDataEvent(__int64 data, __int64 context)
-{
- RpcClient* client = static_cast<RpcClient*>((PVOID)context);
- client->MeteringData = data;
- ++client->CallbackCount;
-}
-
-///******************************************************/
-///* MIDL allocate and free */
-///******************************************************/
-
-void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
-{
- return(malloc(len));
-}
-
-void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
-{
- free(ptr);
-} \ No newline at end of file