From 643293e48d176ff78282670512f45b4cf889b0a5 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 17 Nov 2020 14:11:30 -0600 Subject: Allow E_IMPL from BA/bext and check all cbSizes from BA/bext. --- src/engine/externalengine.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/engine/externalengine.cpp (limited to 'src/engine/externalengine.cpp') diff --git a/src/engine/externalengine.cpp b/src/engine/externalengine.cpp new file mode 100644 index 00000000..ef4f931d --- /dev/null +++ b/src/engine/externalengine.cpp @@ -0,0 +1,30 @@ +// 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" + + +// function definitions + +// TODO: callers need to provide the original size (at the time of first public release) of the struct instead of the current size. +HRESULT WINAPI ExternalEngineValidateMessageParameter( + __in_opt const LPVOID pv, + __in SIZE_T cbSizeOffset, + __in DWORD dwMinimumSize + ) +{ + HRESULT hr = S_OK; + + if (!pv) + { + ExitFunction1(hr = E_INVALIDARG); + } + + DWORD cbSize = *(DWORD*)((BYTE*)pv + cbSizeOffset); + if (dwMinimumSize < cbSize) + { + ExitFunction1(hr = E_INVALIDARG); + } + +LExit: + return hr; +} -- cgit v1.2.3-55-g6feb