Fix null ref on ExeLocation not being set (#884)

This commit is contained in:
Justin Kotalik 2018-06-04 14:59:50 -07:00 committed by GitHub
parent ef071f605f
commit 1822992354
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 332 additions and 98 deletions

View File

@ -2,7 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
#include "stdafx.h"
#include "sttimer.h"
FileOutputManager::FileOutputManager()
: m_pStdOutFile(NULL)

View File

@ -3,6 +3,7 @@
#pragma once
#include "sttimer.h"
class FileOutputManager : public IOutputManager
{

View File

@ -16,19 +16,26 @@ LoggingHelpers::CreateLoggingProvider(
DBG_ASSERT(outputManager != NULL);
if (fIsLoggingEnabled)
try
{
FileOutputManager* manager = new FileOutputManager;
hr = manager->Initialize(pwzStdOutFileName, pwzApplicationPath);
*outputManager = manager;
if (fIsLoggingEnabled)
{
FileOutputManager* manager = new FileOutputManager;
hr = manager->Initialize(pwzStdOutFileName, pwzApplicationPath);
*outputManager = manager;
}
else if (fEnablePipe)
{
*outputManager = new PipeOutputManager;
}
else
{
*outputManager = new NullOutputManager;
}
}
else if (fEnablePipe)
catch (std::bad_alloc&)
{
*outputManager = new PipeOutputManager;
}
else
{
*outputManager = new NullOutputManager;
hr = E_OUTOFMEMORY;
}
return hr;

View File

@ -33,35 +33,42 @@ REQUESTHANDLER_CONFIG::CreateRequestHandlerConfig(
STRU struHostFxrDllLocation;
STRU struExeLocation;
if (ppAspNetCoreConfig == NULL)
try
{
hr = E_INVALIDARG;
goto Finished;
if (ppAspNetCoreConfig == NULL)
{
hr = E_INVALIDARG;
goto Finished;
}
*ppAspNetCoreConfig = NULL;
pRequestHandlerConfig = new REQUESTHANDLER_CONFIG;
hr = pRequestHandlerConfig->Populate(pHttpServer, pHttpApplication);
if (FAILED(hr))
{
goto Finished;
}
DebugPrintf(ASPNETCORE_DEBUG_FLAG_INFO,
"REQUESTHANDLER_CONFIG::GetConfig, set config to ModuleContext");
// set appliction info here instead of inside Populate()
// as the destructor will delete the backend process
hr = pRequestHandlerConfig->QueryApplicationPath()->Copy(pHttpApplication->GetApplicationId());
if (FAILED(hr))
{
goto Finished;
}
*ppAspNetCoreConfig = pRequestHandlerConfig;
pRequestHandlerConfig = NULL;
}
*ppAspNetCoreConfig = NULL;
pRequestHandlerConfig = new REQUESTHANDLER_CONFIG;
hr = pRequestHandlerConfig->Populate(pHttpServer, pHttpApplication);
if (FAILED(hr))
catch (std::bad_alloc&)
{
goto Finished;
hr = E_OUTOFMEMORY;
}
DebugPrintf(ASPNETCORE_DEBUG_FLAG_INFO,
"REQUESTHANDLER_CONFIG::GetConfig, set config to ModuleContext");
// set appliction info here instead of inside Populate()
// as the destructor will delete the backend process
hr = pRequestHandlerConfig->QueryApplicationPath()->Copy(pHttpApplication->GetApplicationId());
if (FAILED(hr))
{
goto Finished;
}
*ppAspNetCoreConfig = pRequestHandlerConfig;
pRequestHandlerConfig = NULL;
Finished:
if (pRequestHandlerConfig != NULL)

View File

@ -209,10 +209,10 @@ public:
return &m_struConfigPath;
}
private:
protected:
//
// private constructor
// protected constructor
//
REQUESTHANDLER_CONFIG() :
m_fStdoutLogEnabled(FALSE),

View File

@ -23,6 +23,7 @@
#include "dbgutil.h"
#include "ahutil.h"
#include "hashfn.h"
#include "sttimer.h"
#include "irequesthandler.h"
#include "sttimer.h"
#include "requesthandler.h"

View File

@ -3,6 +3,8 @@
#pragma once
#include "stdafx.h"
#ifndef _STTIMER_H
#define _STTIMER_H
@ -276,4 +278,4 @@ private:
BOOL _fUsingHighResolution;
};
#endif // _STTIMER_H
#endif // _STTIMER_H

View File

@ -211,16 +211,14 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="aspnetcore_event.h" />
<ClInclude Include="disconnectcontext.h" />
<ClInclude Include="environmentvariablehelpers.h" />
<ClInclude Include="inprocessapplication.h" />
<ClInclude Include="inprocesshandler.h" />
<ClInclude Include="precomp.hxx" />
<ClInclude Include=".\inprocess\inprocessapplication.h" />
<ClInclude Include=".\inprocess\inprocesshandler.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cxx" />
<ClCompile Include=".\inprocess\inprocessapplication.cpp" />
<ClCompile Include=".\inprocess\inprocesshandler.cpp" />
<ClCompile Include="inprocessapplication.cpp" />
<ClCompile Include="inprocesshandler.cpp" />
<ClCompile Include="managedexports.cxx" />
</ItemGroup>
<ItemGroup>

View File

@ -1,8 +1,16 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// dllmain.cpp : Defines the entry point for the DLL application.
#include "precomp.hxx"
#include <IPHlpApi.h>
#include <VersionHelpers.h>
#include "inprocessapplication.h"
#include "inprocesshandler.h"
#include "requesthandler_config.h"
BOOL g_fGlobalInitialize = FALSE;
BOOL g_fProcessDetach = FALSE;
DWORD g_dwAspNetCoreDebugFlags = 0;
@ -103,31 +111,56 @@ __stdcall
CreateApplication(
_In_ IHttpServer *pServer,
_In_ IHttpContext *pHttpContext,
_In_ PCWSTR pwzExeLocation,
_In_ PCWSTR pwzExeLocation,
_Out_ IAPPLICATION **ppApplication
)
{
HRESULT hr = S_OK;
IAPPLICATION *pApplication = NULL;
REQUESTHANDLER_CONFIG *pConfig;
HRESULT hr = S_OK;
IN_PROCESS_APPLICATION *pApplication = NULL;
REQUESTHANDLER_CONFIG *pConfig = NULL;
// Initialze some global variables here
InitializeGlobalConfiguration(pServer);
hr = REQUESTHANDLER_CONFIG::CreateRequestHandlerConfig(pServer, pHttpContext->GetApplication(), &pConfig);
if (FAILED(hr))
try
{
return hr;
}
hr = REQUESTHANDLER_CONFIG::CreateRequestHandlerConfig(pServer, pHttpContext->GetApplication(), &pConfig);
if (FAILED(hr))
{
goto Finished;
}
pApplication = new IN_PROCESS_APPLICATION(pServer, pConfig, pwzExeLocation);
if (pApplication == NULL)
pApplication = new IN_PROCESS_APPLICATION(pServer, pConfig);
pConfig = NULL;
hr = pApplication->Initialize(pwzExeLocation);
if (FAILED(hr))
{
goto Finished;
}
*ppApplication = pApplication;
}
catch (std::bad_alloc&)
{
hr = HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY);
goto Finished;
hr = E_OUTOFMEMORY;
}
*ppApplication = pApplication;
Finished:
if (FAILED(hr))
{
if (pApplication != NULL)
{
delete pApplication;
pApplication = NULL;
}
if (pConfig != NULL)
{
delete pConfig;
pConfig = NULL;
}
}
return hr;
}

View File

@ -1,21 +1,26 @@
#include "..\precomp.hxx"
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
#include "inprocessapplication.h"
#include "inprocesshandler.h"
#include "hostfxroptions.h"
#include "requesthandler_config.h"
#include "environmentvariablehelpers.h"
#include "aspnetcore_event.h"
IN_PROCESS_APPLICATION* IN_PROCESS_APPLICATION::s_Application = NULL;
hostfxr_main_fn IN_PROCESS_APPLICATION::s_fMainCallback = NULL;
IN_PROCESS_APPLICATION::IN_PROCESS_APPLICATION(
IHttpServer *pHttpServer,
REQUESTHANDLER_CONFIG *pConfig,
PCWSTR pDotnetExeLocation) :
REQUESTHANDLER_CONFIG *pConfig) :
m_pHttpServer(pHttpServer),
m_ProcessExitCode(0),
m_fBlockCallbacksIntoManaged(FALSE),
m_fInitialized(FALSE),
m_fShutdownCalledFromNative(FALSE),
m_fShutdownCalledFromManaged(FALSE),
m_srwLock(),
m_pstrDotnetExeLocation(pDotnetExeLocation)
m_srwLock()
{
// is it guaranteed that we have already checked app offline at this point?
// If so, I don't think there is much to do here.
@ -24,10 +29,18 @@ IN_PROCESS_APPLICATION::IN_PROCESS_APPLICATION(
InitializeSRWLock(&m_srwLock);
m_pConfig = pConfig;
// TODO we can probably initialized as I believe we are the only ones calling recycle.
m_status = APPLICATION_STATUS::STARTING;
}
HRESULT
IN_PROCESS_APPLICATION::Initialize(
PCWSTR pDotnetExeLocation
)
{
return m_struExeLocation.Copy(pDotnetExeLocation);
}
IN_PROCESS_APPLICATION::~IN_PROCESS_APPLICATION()
{
@ -573,7 +586,7 @@ IN_PROCESS_APPLICATION::ExecuteApplication(
}
if (FAILED(hr = HOSTFXR_OPTIONS::Create(
m_pstrDotnetExeLocation,
m_struExeLocation.QueryStr(),
m_pConfig->QueryProcessPath()->QueryStr(),
m_pConfig->QueryApplicationPhysicalPath()->QueryStr(),
m_pConfig->QueryArguments()->QueryStr(),

View File

@ -2,6 +2,11 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
#pragma once
#include "precomp.hxx"
#include "inprocesshandler.h"
#include "requesthandler_config.h"
typedef INT(*hostfxr_main_fn) (CONST DWORD argc, CONST PCWSTR argv[]); // TODO these may need to be BSTRs
typedef REQUEST_NOTIFICATION_STATUS(WINAPI * PFN_REQUEST_HANDLER) (IN_PROCESS_HANDLER* pInProcessHandler, void* pvRequestHandlerContext);
@ -13,14 +18,13 @@ class IN_PROCESS_APPLICATION : public APPLICATION
public:
IN_PROCESS_APPLICATION(
IHttpServer* pHttpServer,
REQUESTHANDLER_CONFIG *pConfig,
PCWSTR pDotnetExeLocation);
REQUESTHANDLER_CONFIG *pConfig);
~IN_PROCESS_APPLICATION();
HRESULT
Initialize(
VOID
PCWSTR pDotnetExeLocation
);
__override
@ -156,7 +160,6 @@ private:
HANDLE m_hErrThread;
CHAR m_pzFileContents[4096] = { 0 };
DWORD m_dwStdErrReadTotal;
PCWSTR m_pstrDotnetExeLocation;
static IN_PROCESS_APPLICATION* s_Application;
IOutputManager* m_pLoggerProvider;

View File

@ -1,4 +1,9 @@
#include "..\precomp.hxx"
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
#include "inprocesshandler.h"
#include "inprocessapplication.h"
#include "aspnetcore_event.h"
IN_PROCESS_HANDLER::IN_PROCESS_HANDLER(
_In_ IHttpContext *pW3Context,

View File

@ -1,12 +1,17 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
#pragma once
#include "precomp.hxx"
#include "requesthandler.h"
class IN_PROCESS_APPLICATION;
class IN_PROCESS_HANDLER : public REQUEST_HANDLER
{
public:
IN_PROCESS_HANDLER(
_In_ IHttpContext *pW3Context,
_In_ IN_PROCESS_APPLICATION *pApplication);

View File

@ -2,7 +2,9 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include "precomp.hxx"
#include "inprocessapplication.h"
#include "inprocesshandler.h"
#include "requesthandler_config.h"
//
// Initialization export
//

View File

@ -44,26 +44,6 @@
#define WINVER 0x0601
#define _WIN32_WINNT 0x0601
#include "..\IISLib\acache.h"
#include "..\IISLib\multisz.h"
#include "..\IISLib\multisza.h"
#include "..\IISLib\base64.h"
#include "..\IISLib\listentry.h"
#include "..\CommonLib\fx_ver.h"
#include "..\CommonLib\debugutil.h"
#include "..\CommonLib\requesthandler.h"
#include "..\CommonLib\requesthandler_config.h"
#include "..\CommonLib\utility.h"
#include "..\CommonLib\application.h"
#include "..\CommonLib\resources.h"
#include "aspnetcore_event.h"
#include "aspnetcore_msg.h"
#include "disconnectcontext.h"
#include "environmentvariablehelpers.h"
#include "sttimer.h"
#include ".\inprocess\InProcessHandler.h"
#include ".\inprocess\inprocessapplication.h"
#ifdef max
#undef max
template<typename T> inline T max(T a, T b)

View File

@ -46,12 +46,14 @@
</PropertyGroup>
<ItemGroup>
<ClInclude Include="Helpers.h" />
<ClInclude Include="fakeclasses.h" />
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="FileOutputManagerTests.cpp" />
<ClCompile Include="Helpers.cpp" />
<ClCompile Include="hostfxr_utility_tests.cpp" />
<ClCompile Include="inprocess_application_tests.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="PipeOutputManagerTests.cpp" />
<ClCompile Include="stdafx.cpp">
@ -75,6 +77,9 @@
<ProjectReference Include="..\gtest\gtest.vcxproj">
<Project>{cac1267b-8778-4257-aac6-caf481723b01}</Project>
</ProjectReference>
<ProjectReference Include="..\..\src\AspNetCoreModuleV2\InProcessRequestHandler\InProcessRequestHandler.vcxproj">
<Project>{d57ea297-6dc2-4bc0-8c91-334863327863}</Project>
</ProjectReference>
</ItemGroup>
<ItemDefinitionGroup />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
@ -88,13 +93,15 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories);..\..\src\AspNetCoreModuleV2\IISLib;..\..\src\AspNetCoreModuleV2\CommonLib;..\gtest\googletest\googletest\include;..\..\src\AspNetCoreModuleV2\AspNetCore\Inc;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories);..\..\src\AspNetCoreModuleV2\IISLib;..\..\src\AspNetCoreModuleV2\CommonLib;..\gtest\googletest\googletest\include;...\..\src\AspNetCoreModuleV2\AspNetCore\Inc;..\..\src\AspNetCoreModuleV2\InProcessRequestHandler\;</AdditionalIncludeDirectories>
<AdditionalOptions>/D "_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" </AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>..\..\src\AspNetCoreModuleV2\InProcessRequestHandler\$(Configuration)\;</AdditionalLibraryDirectories>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;inprocessapplication.obj;inprocesshandler.obj;ahadmin.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Lib>
<AdditionalDependencies>
@ -111,13 +118,15 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories);..\..\src\AspNetCoreModuleV2\IISLib;..\..\src\AspNetCoreModuleV2\CommonLib;..\gtest\googletest\googletest\include;..\..\src\AspNetCoreModuleV2\AspNetCore\Inc;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories);..\..\src\AspNetCoreModuleV2\IISLib;..\..\src\AspNetCoreModuleV2\CommonLib;..\gtest\googletest\googletest\include;...\..\src\AspNetCoreModuleV2\AspNetCore\Inc;..\..\src\AspNetCoreModuleV2\InProcessRequestHandler\;</AdditionalIncludeDirectories>
<AdditionalOptions>/D "_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" </AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>..\..\src\AspNetCoreModuleV2\InProcessRequestHandler\x64\$(Configuration)\;</AdditionalLibraryDirectories>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;inprocessapplication.obj;inprocesshandler.obj;ahadmin.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Lib>
<AdditionalDependencies>
@ -132,7 +141,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories);..\..\src\AspNetCoreModuleV2\IISLib;..\..\src\AspNetCoreModuleV2\CommonLib;..\gtest\googletest\googletest\include;..\..\src\AspNetCoreModuleV2\AspNetCore\Inc;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories);..\..\src\AspNetCoreModuleV2\IISLib;..\..\src\AspNetCoreModuleV2\CommonLib;..\gtest\googletest\googletest\include;...\..\src\AspNetCoreModuleV2\AspNetCore\Inc;..\..\src\AspNetCoreModuleV2\InProcessRequestHandler\;</AdditionalIncludeDirectories>
<AdditionalOptions>/D "_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" </AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
@ -141,6 +150,8 @@
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<AdditionalLibraryDirectories>..\..\src\AspNetCoreModuleV2\InProcessRequestHandler\$(Configuration)\;</AdditionalLibraryDirectories>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;inprocessapplication.obj;inprocesshandler.obj;ahadmin.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Lib>
<AdditionalDependencies>
@ -155,7 +166,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories);..\..\src\AspNetCoreModuleV2\IISLib;..\..\src\AspNetCoreModuleV2\CommonLib;..\gtest\googletest\googletest\include;..\..\src\AspNetCoreModuleV2\AspNetCore\Inc;</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories);..\..\src\AspNetCoreModuleV2\IISLib;..\..\src\AspNetCoreModuleV2\CommonLib;..\gtest\googletest\googletest\include;...\..\src\AspNetCoreModuleV2\AspNetCore\Inc;..\..\src\AspNetCoreModuleV2\InProcessRequestHandler\;</AdditionalIncludeDirectories>
<AdditionalOptions>/D "_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" </AdditionalOptions>
<LanguageStandard>stdcpp14</LanguageStandard>
</ClCompile>
@ -164,6 +175,8 @@
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<AdditionalLibraryDirectories>..\..\src\AspNetCoreModuleV2\InProcessRequestHandler\x64\$(Configuration)\;</AdditionalLibraryDirectories>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;inprocessapplication.obj;inprocesshandler.obj;ahadmin.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Lib>
<AdditionalDependencies>

View File

@ -0,0 +1,131 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#include "stdafx.h"
class MockHttpServer : public IHttpServer
{
// Inherited via IHttpServer
virtual BOOL IsCommandLineLaunch(VOID) const override
{
return 0;
}
virtual PCWSTR GetAppPoolName(VOID) const override
{
return PCWSTR();
}
virtual HRESULT AssociateWithThreadPool(HANDLE hHandle, LPOVERLAPPED_COMPLETION_ROUTINE completionRoutine) override
{
return E_NOTIMPL;
}
virtual VOID IncrementThreadCount(VOID) override
{
return VOID();
}
virtual VOID DecrementThreadCount(VOID) override
{
return VOID();
}
virtual VOID ReportUnhealthy(PCWSTR pszReasonString, HRESULT hrReason) override
{
return VOID();
}
virtual VOID RecycleProcess(PCWSTR pszReason) override
{
return VOID();
}
virtual IAppHostAdminManager * GetAdminManager(VOID) const override
{
return nullptr;
}
virtual HRESULT GetFileInfo(PCWSTR pszPhysicalPath, HANDLE hUserToken, PSID pSid, PCWSTR pszChangeNotificationPath, HANDLE hChangeNotificationToken, BOOL fCache, IHttpFileInfo ** ppFileInfo, IHttpTraceContext * pHttpTraceContext = NULL) override
{
return E_NOTIMPL;
}
virtual HRESULT FlushKernelCache(PCWSTR pszUrl) override
{
return E_NOTIMPL;
}
virtual HRESULT DoCacheOperation(CACHE_OPERATION cacheOperation, IHttpCacheKey * pCacheKey, IHttpCacheSpecificData ** ppCacheSpecificData, IHttpTraceContext * pHttpTraceContext = NULL) override
{
return E_NOTIMPL;
}
virtual GLOBAL_NOTIFICATION_STATUS NotifyCustomNotification(ICustomNotificationProvider * pCustomOutput) override
{
return GLOBAL_NOTIFICATION_STATUS();
}
virtual IHttpPerfCounterInfo * GetPerfCounterInfo(VOID) override
{
return nullptr;
}
virtual VOID RecycleApplication(PCWSTR pszAppConfigPath) override
{
return VOID();
}
virtual VOID NotifyConfigurationChange(PCWSTR pszPath) override
{
return VOID();
}
virtual VOID NotifyFileChange(PCWSTR pszFileName) override
{
return VOID();
}
virtual IDispensedHttpModuleContextContainer * DispenseContainer(VOID) override
{
return nullptr;
}
virtual HRESULT AddFragmentToCache(HTTP_DATA_CHUNK * pDataChunk, PCWSTR pszFragmentName) override
{
return E_NOTIMPL;
}
virtual HRESULT ReadFragmentFromCache(PCWSTR pszFragmentName, BYTE * pvBuffer, DWORD cbSize, DWORD * pcbCopied) override
{
return E_NOTIMPL;
}
virtual HRESULT RemoveFragmentFromCache(PCWSTR pszFragmentName) override
{
return E_NOTIMPL;
}
virtual HRESULT GetWorkerProcessSettings(IWpfSettings ** ppWorkerProcessSettings) override
{
return E_NOTIMPL;
}
virtual HRESULT GetProtocolManagerCustomInterface(PCWSTR pProtocolManagerDll, PCWSTR pProtocolManagerDllInitFunction, DWORD dwCustomInterfaceId, PVOID * ppCustomInterface) override
{
return E_NOTIMPL;
}
virtual BOOL SatisfiesPrecondition(PCWSTR pszPrecondition, BOOL * pfUnknownPrecondition = NULL) const override
{
return 0;
}
virtual IHttpTraceContext * GetTraceContext(VOID) const override
{
return nullptr;
}
virtual HRESULT RegisterFileChangeMonitor(PCWSTR pszPath, HANDLE hToken, IHttpFileMonitor ** ppFileMonitor) override
{
return E_NOTIMPL;
}
virtual HRESULT GetExtendedInterface(HTTP_SERVER_INTERFACE_VERSION version, PVOID * ppInterface) override
{
return E_NOTIMPL;
}
};
class MockRequestHandlerConfig : public REQUESTHANDLER_CONFIG
{
public:
static
MockRequestHandlerConfig*
CreateConfig()
{
return new MockRequestHandlerConfig;
}
private:
MockRequestHandlerConfig()
{
}
};

View File

@ -0,0 +1,23 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#include "stdafx.h"
#include "inprocessapplication.h"
#include "fakeclasses.h"
namespace InprocessTests
{
TEST(InProcessTest, NoNullRefForExePath)
{
auto server = new MockHttpServer();
auto requestHandlerConfig = MockRequestHandlerConfig::CreateConfig();
IN_PROCESS_APPLICATION *app = new IN_PROCESS_APPLICATION(server, requestHandlerConfig);
{
std::wstring exePath(L"hello");
app->Initialize(exePath.c_str());
}
ASSERT_STREQ(app->QueryExeLocation(), L"hello");
}
}

View File

@ -39,9 +39,9 @@
#include "stringa.h"
#include "multisz.h"
#include "dbgutil.h"
#include "ahutil.h"
#include "hashfn.h"
#include "requesthandler_config.h"
#include "hostfxr_utility.h"
#include "environmentvariablehash.h"
#include "iapplication.h"
@ -54,3 +54,11 @@
#undef assert // Macro redefinition in IISLib.
#include "gtest\gtest.h"
// Externals defined in inprocess
BOOL g_fProcessDetach;
HANDLE g_hEventLog;
DWORD g_dwAspNetCoreDebugFlags;
PCSTR g_szDebugLabel;
DWORD g_dwDebugFlags;

View File

@ -11,13 +11,14 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
public class StartupExceptionTests : IISFunctionalTestBase
{
// TODO FileNotFound here.
[Theory]
[InlineData("CheckLogFile")]
[InlineData("CheckErrLogFile")]
public async Task CheckStdoutWithRandomNumber(string path)
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters("StartupExceptionWebsite");
deploymentParameters.PublishApplicationBeforeDeployment = true;
deploymentParameters.EnvironmentVariables["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path;
var randomNumberString = new Random(Guid.NewGuid().GetHashCode()).Next(10000000).ToString();
deploymentParameters.EnvironmentVariables["ASPNETCORE_INPROCESS_RANDOM_VALUE"] = randomNumberString;
@ -39,6 +40,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task CheckStdoutWithLargeWrites(string path)
{
var deploymentParameters = Helpers.GetBaseDeploymentParameters("StartupExceptionWebsite");
deploymentParameters.PublishApplicationBeforeDeployment = true;
deploymentParameters.EnvironmentVariables["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path;
var deploymentResult = await DeployAsync(deploymentParameters);