Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run static code analysis on IIS #58167

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions eng/scripts/vs.17.buildtools.intpreview.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"Microsoft.VisualStudio.Component.VC.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.Tools.ARM64",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ARM64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ARM64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ATL",
"Microsoft.VisualStudio.Component.Windows10SDK.19041",
"Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools",
"Microsoft.VisualStudio.Workload.MSBuildTools",
Expand Down
8 changes: 4 additions & 4 deletions eng/scripts/vs.17.buildtools.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"Microsoft.VisualStudio.Component.VC.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.Tools.ARM64",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ARM64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ARM64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ATL",
"Microsoft.VisualStudio.Component.Windows10SDK.19041",
"Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools",
"Microsoft.VisualStudio.Workload.MSBuildTools",
Expand Down
8 changes: 4 additions & 4 deletions eng/scripts/vs.17.buildtools.preview.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"Microsoft.VisualStudio.Component.VC.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.Tools.ARM64",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ARM64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ARM64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ATL",
"Microsoft.VisualStudio.Component.Windows10SDK.19041",
"Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools",
"Microsoft.VisualStudio.Workload.MSBuildTools",
Expand Down
8 changes: 4 additions & 4 deletions eng/scripts/vs.17.intpreview.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"Microsoft.VisualStudio.Component.VC.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.Tools.ARM64",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ARM64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ARM64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ATL",
"Microsoft.VisualStudio.Component.Windows10SDK.19041",
"Microsoft.VisualStudio.Workload.ManagedDesktop",
"Microsoft.VisualStudio.Workload.NativeDesktop",
Expand Down
8 changes: 4 additions & 4 deletions eng/scripts/vs.17.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"Microsoft.VisualStudio.Component.VC.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.Tools.ARM64",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ARM64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ARM64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ATL",
"Microsoft.VisualStudio.Component.Windows10SDK.19041",
"Microsoft.VisualStudio.Workload.ManagedDesktop",
"Microsoft.VisualStudio.Workload.NativeDesktop",
Expand Down
8 changes: 4 additions & 4 deletions eng/scripts/vs.17.preview.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"Microsoft.VisualStudio.Component.VC.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.Tools.ARM64",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ARM64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ARM64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ATL.ARM64",
"Microsoft.VisualStudio.Component.VC.14.41.17.11.ATL",
"Microsoft.VisualStudio.Component.Windows10SDK.19041",
"Microsoft.VisualStudio.Workload.ManagedDesktop",
"Microsoft.VisualStudio.Workload.NativeDesktop",
Expand Down
4 changes: 2 additions & 2 deletions eng/targets/Cpp.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<VCProjectVersion>15.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<Platform Condition="'$(Platform)' == ''">x64</Platform>
<PlatformToolsetVersion>v143</PlatformToolsetVersion>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
<PlatformToolsetVersion>143</PlatformToolsetVersion>
<PlatformToolset>v$(PlatformToolsetVersion)</PlatformToolset>
<!-- If the following line is updated ensure that the /eng/scripts/vs.17.*.json files are updated to include the same version component too. -->
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.19041.0</WindowsTargetPlatformVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup>
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<WholeProgramOptimization>false</WholeProgramOptimization>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
<PropertyGroup>
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ HRESULT AppOfflineApplication::CreateHandler(IHttpContext* pHttpContext, IREQUES
try
{
auto handler = std::make_unique<AppOfflineHandler>(*pHttpContext, m_strAppOfflineContent);
// 'Don't return a pointer that may be invalid'
// We use make_unique to prevent memory leaks in case of exception during ctor and then release it so we don't delete the pointer
#pragma warning(suppress: 26487)
*pRequestHandler = handler.release();
}
CATCH_RETURN();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
extern DWORD g_dwIISServerVersion;

static std::wstring GetIISVersion() {
int major = (int)(g_dwIISServerVersion >> 16);
int minor = (int)(g_dwIISServerVersion & 0xffff);
const int major = (int)(g_dwIISServerVersion >> 16);
const int minor = (int)(g_dwIISServerVersion & 0xffff);

std::wstringstream version;
version << major << "." << minor;
Expand Down Expand Up @@ -47,11 +47,11 @@ void SetApplicationEnvironmentVariables(_In_ IHttpServer &server, _In_ IHttpCont
SetEnvironmentVariable(L"ASPNETCORE_IIS_APP_POOL_CONFIG_FILE", server2->GetAppPoolConfigFile());
}

IHttpSite* site = pHttpContext.GetSite();
const IHttpSite* site = pHttpContext.GetSite();
SetEnvironmentVariable(L"ASPNETCORE_IIS_SITE_NAME", site->GetSiteName());
SetEnvironmentVariable(L"ASPNETCORE_IIS_SITE_ID", std::to_wstring(site->GetSiteId()).c_str());

IHttpApplication* app = pHttpContext.GetApplication();
const IHttpApplication* app = pHttpContext.GetApplication();
SetEnvironmentVariable(L"ASPNETCORE_IIS_APP_CONFIG_PATH", app->GetAppConfigPath());
SetEnvironmentVariable(L"ASPNETCORE_IIS_APPLICATION_ID", app->GetApplicationId());
SetEnvironmentVariable(L"ASPNETCORE_IIS_APPLICATION_VIRTUAL_PATH", ToVirtualPath(app->GetAppConfigPath()).c_str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ ShimOptions::ShimOptions(const ConfigurationSource &configurationSource) :
m_strArguments = Environment::GetEnvironmentVariableValue(CS_ANCM_LAUNCHER_ARGS)
.value_or(m_strArguments);

auto detailedErrorsEnabled = equals_ignore_case(L"1", detailedErrors) || equals_ignore_case(L"true", detailedErrors);
auto aspnetCoreEnvironmentEnabled = equals_ignore_case(L"Development", aspnetCoreEnvironment);
auto dotnetEnvironmentEnabled = equals_ignore_case(L"Development", dotnetEnvironment);
const auto detailedErrorsEnabled = equals_ignore_case(L"1", detailedErrors) || equals_ignore_case(L"true", detailedErrors);
const auto aspnetCoreEnvironmentEnabled = equals_ignore_case(L"Development", aspnetCoreEnvironment);
const auto dotnetEnvironmentEnabled = equals_ignore_case(L"Development", dotnetEnvironment);

m_fShowDetailedErrors = detailedErrorsEnabled || aspnetCoreEnvironmentEnabled || dotnetEnvironmentEnabled;

Expand Down Expand Up @@ -111,7 +111,7 @@ ShimOptions::ShimOptions(const ConfigurationSource &configurationSource) :

void ShimOptions::SetShutdownDelay(const std::wstring& shutdownDelay)
{
auto millsecondsValue = std::stoi(shutdownDelay);
const auto millsecondsValue = std::stoi(shutdownDelay);
if (millsecondsValue < 0)
{
throw ConfigurationLoadException(format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ APPLICATION_INFO::CreateApplication(IHttpContext& pHttpContext)
pHttpApplication.GetApplicationId(),
hr);

auto page = ANCM_ERROR_PAGE;
constexpr auto page = ANCM_ERROR_PAGE;
std::string responseContent;
if (options.QueryShowDetailedErrors())
{
Expand Down Expand Up @@ -301,7 +301,7 @@ APPLICATION_INFO::HandleShadowCopy(const ShimOptions& options, IHttpContext& pHt
auto shadowCopyBaseDirectory = std::filesystem::directory_entry(shadowCopyPath);
if (!shadowCopyBaseDirectory.exists())
{
CreateDirectory(shadowCopyBaseDirectory.path().wstring().c_str(), NULL);
CreateDirectory(shadowCopyBaseDirectory.path().wstring().c_str(), nullptr);
}

for (auto& entry : std::filesystem::directory_iterator(shadowCopyPath))
Expand All @@ -311,7 +311,7 @@ APPLICATION_INFO::HandleShadowCopy(const ShimOptions& options, IHttpContext& pHt
try
{
auto tempDirName = entry.path().filename().string();
int intFileName = std::stoi(tempDirName);
const int intFileName = std::stoi(tempDirName);
if (intFileName > directoryName)
{
directoryName = intFileName;
Expand All @@ -334,7 +334,7 @@ APPLICATION_INFO::HandleShadowCopy(const ShimOptions& options, IHttpContext& pHt
// Avoid using canonical for shadowCopyBaseDirectory
// It could expand to a network drive, or an expanded link folder path
// We already made it an absolute path relative to the physicalPath above
HRESULT hr = Environment::CopyToDirectory(physicalPath, shadowCopyPath, options.QueryCleanShadowCopyDirectory(), shadowCopyBaseDirectory.path(), copiedFileCount);
const HRESULT hr = Environment::CopyToDirectory(physicalPath, shadowCopyPath, options.QueryCleanShadowCopyDirectory(), shadowCopyBaseDirectory.path(), copiedFileCount);

LOG_INFOF(L"Finished copying %d files to shadow copy directory %ls.", copiedFileCount, shadowCopyBaseDirectory.path().c_str());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ BOOL WINAPI DllMain(HMODULE hModule,
// this is a bug in IIS. To try to avoid AVs, we will set a global flag
g_fInShutdown = TRUE;
StaticCleanup();
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ASPNET_CORE_GLOBAL_MODULE : NonCopyable, public CGlobalModule
// IIS will actually stop giving us new requests and queue them instead for processing by the new app process.
m_shutdown = std::thread([this]()
{
auto delay = m_pApplicationManager->GetShutdownDelay();
const auto delay = m_pApplicationManager->GetShutdownDelay();
LOG_INFOF(L"Shutdown starting in %d ms.", delay.count());
// Delay so that any incoming requests while we're returning from OnGlobalStopListening are allowed to be processed
std::this_thread::sleep_for(delay);
Expand Down
8 changes: 8 additions & 0 deletions src/Servers/IIS/AspNetCoreModuleV2/CommonLib/ErrorContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@

struct ErrorContext
{
ErrorContext() :
detailedErrorContent(),
generalErrorType(),
errorReason(),
statusCode(),
subStatusCode()
{}

// TODO consider adding HRESULT here
std::string detailedErrorContent;
USHORT statusCode;
Expand Down
5 changes: 4 additions & 1 deletion src/Servers/IIS/AspNetCoreModuleV2/CommonLib/HostFxr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ void HostFxr::Load(const std::wstring& location)
}
}

// No array to pointer decay
// This is in reference to main taking PCWSTR argv[] and the analyzer wanting us to use span instead
#pragma warning(suppress: 26485)
void HostFxr::SetMain(hostfxr_main_fn hostfxr_main_fn)
{
m_hostfxr_main_fn = hostfxr_main_fn;
Expand Down Expand Up @@ -114,7 +117,7 @@ HostFxrErrorRedirector HostFxr::RedirectOutput(RedirectionOutput* writer) const
return HostFxrErrorRedirector(m_corehost_set_error_writer_fn, writer);
}

int HostFxr::InitializeForApp(int argc, PCWSTR* argv, const std::wstring& dotnetExe) const noexcept
int HostFxr::InitializeForApp(int argc, PCWSTR* argv, const std::wstring& dotnetExe) const
{
if (m_hostfxr_initialize_for_dotnet_commandline_fn == nullptr || m_hostfxr_main_fn != nullptr)
{
Expand Down
14 changes: 11 additions & 3 deletions src/Servers/IIS/AspNetCoreModuleV2/CommonLib/HostFxr.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef int(*hostfxr_get_runtime_property_value_fn)(void* host_context_handle, P
typedef int(*hostfxr_run_app_fn)(void* host_context_handle);
typedef int(*hostfxr_close_fn)(void* hostfxr_context_handle);

const int AppArgNotRunnable = 0x80008094;
constexpr int AppArgNotRunnable = 0x80008094;

class HostFxrErrorRedirector: NonCopyable
{
Expand All @@ -53,14 +53,22 @@ class HostFxr: NonCopyable
{
}

// No array to pointer decay
// This is in reference to main taking PCWSTR argv[] and the analyzer wanting us to use span instead
#pragma warning(suppress: 26485)
HostFxr(
hostfxr_main_fn hostfxr_main_fn,
hostfxr_get_native_search_directories_fn hostfxr_get_native_search_directories_fn,
corehost_set_error_writer_fn corehost_set_error_writer_fn) noexcept
: m_hostfxr_main_fn(hostfxr_main_fn),
m_hostfxr_get_native_search_directories_fn(hostfxr_get_native_search_directories_fn),
m_corehost_set_error_writer_fn(corehost_set_error_writer_fn),
m_host_context_handle(nullptr)
m_host_context_handle(nullptr),
m_hostfxr_close_fn(nullptr),
m_hostfxr_get_runtime_property_value_fn(nullptr),
m_hostfxr_initialize_for_dotnet_commandline_fn(nullptr),
m_hostfxr_run_app_fn(nullptr),
m_hostfxr_set_runtime_property_value_fn(nullptr)
{
}

Expand All @@ -78,7 +86,7 @@ class HostFxr: NonCopyable
HostFxrErrorRedirector RedirectOutput(RedirectionOutput* writer) const noexcept;
int SetRuntimePropertyValue(PCWSTR name, PCWSTR value) const noexcept;
int GetRuntimePropertyValue(PCWSTR name, PWSTR* value) const noexcept;
int InitializeForApp(int argc, PCWSTR* argv, const std::wstring& m_dotnetExeKnownLocation) const noexcept;
int InitializeForApp(int argc, PCWSTR* argv, const std::wstring& m_dotnetExeKnownLocation) const;
void Close() const noexcept;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ std::optional<DWORD> RegistryKey::TryGetDWORD(HKEY section, const std::wstring&

std::optional<std::wstring> RegistryKey::TryGetString(HKEY section, const std::wstring& subSectionName, const std::wstring& valueName)
{
DWORD cbData;
DWORD cbData{};

if (!CheckReturnValue(RegGetValue(section, subSectionName.c_str(), valueName.c_str(), RRF_RT_REG_SZ, nullptr, nullptr, &cbData)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class ServerErrorApplication : public PollingAppOfflineApplication

HRESULT CreateHandler(IHttpContext *pHttpContext, IREQUEST_HANDLER ** pRequestHandler) override
{
// 'Don't return a pointer that may be invalid'
// We use make_unique to prevent memory leaks and then release it so we don't delete the pointer
#pragma warning(suppress: 26487)
*pRequestHandler = std::make_unique<ServerErrorHandler>(*pHttpContext, m_statusCode, m_subStatusCode, m_statusText, m_HR, m_disableStartupPage, m_responseContent).release();

return S_OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
class ServerErrorHandler : public REQUEST_HANDLER
{
public:
ServerErrorHandler(IHttpContext& pContext, USHORT statusCode, USHORT subStatusCode, const std::string& statusText, HRESULT hr, bool disableStartupPage, std::string& responseContent) noexcept
ServerErrorHandler(IHttpContext& pContext, USHORT statusCode, USHORT subStatusCode, const std::string& statusText, HRESULT hr, bool disableStartupPage, std::string& responseContent)
: REQUEST_HANDLER(pContext),
m_HR(hr),
m_disableStartupPage(disableStartupPage),
m_statusCode(statusCode),
m_subStatusCode(subStatusCode),
m_statusText(std::move(statusText)),
m_statusText(statusText),
m_ExceptionInfoContent(responseContent)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ void StandardStreamRedirection::Stop()
dwThreadStatus == STILL_ACTIVE)
{
LOG_WARN(L"Thread reading stdout/err hit timeout, forcibly closing thread.");
// Using TerminateThread does not allow proper thread clean up.
#pragma warning(suppress: 6258)
TerminateThread(m_hErrThread, STATUS_CONTROL_C_EXIT);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ConfigUtility
HRESULT
FindKeyValuePair(IAppHostElement* pElement, PCWSTR key, STRU& strHandlerVersionValue)
{
HRESULT hr;
HRESULT hr = S_OK;
CComPtr<IAppHostElement> pHandlerSettings = nullptr;
CComPtr<IAppHostElementCollection> pHandlerSettingsCollection = nullptr;
CComPtr<IAppHostElement> pHandlerVar = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ std::wstring
GetModuleName()
{
WCHAR path[MAX_PATH];
LOG_LAST_ERROR_IF(!GetModuleFileName(g_hModule, path, sizeof(path)));
LOG_LAST_ERROR_IF(!GetModuleFileName(g_hModule, path, sizeof(path) / sizeof(WCHAR)));
return path;
}

Expand Down
10 changes: 4 additions & 6 deletions src/Servers/IIS/AspNetCoreModuleV2/CommonLib/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@
#define RETURN_CAUGHT_EXCEPTION() return CaughtExceptionHResult(LOCATION_INFO);

#define _CHECK_FAILED(expr) __pragma(warning(push)) \
__pragma(warning(disable:4127)) /*disable condition is const warning*/ \
FAILED(expr) \
__pragma(warning(pop))
__pragma(warning(suppress:4127)) /*disable condition is const warning*/ \
FAILED(expr)

#define _HR_RET(hr) __pragma(warning(push)) \
__pragma(warning(disable:26498)) /*disable constexpr warning */ \
const HRESULT __hrRet = hr; \
__pragma(warning(pop))
__pragma(warning(suppress:26498 26814)) /*disable constexpr warning */ \
const HRESULT __hrRet = hr;

#define RETURN_HR(hr) do { _HR_RET(hr); if (_CHECK_FAILED(__hrRet)) { LogHResultFailed(LOCATION_INFO, __hrRet); } return __hrRet; } while (0, 0)
#define RETURN_LAST_ERROR() do { return LogLastError(LOCATION_INFO); } while (0, 0)
Expand Down
Loading
Loading