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. // Licensed under the MIT License. See License.txt in the project root for license information.
#include "stdafx.h" #include "stdafx.h"
#include "sttimer.h"
FileOutputManager::FileOutputManager() FileOutputManager::FileOutputManager()
: m_pStdOutFile(NULL) : m_pStdOutFile(NULL)

View File

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

View File

@ -16,19 +16,26 @@ LoggingHelpers::CreateLoggingProvider(
DBG_ASSERT(outputManager != NULL); DBG_ASSERT(outputManager != NULL);
if (fIsLoggingEnabled) try
{ {
FileOutputManager* manager = new FileOutputManager; if (fIsLoggingEnabled)
hr = manager->Initialize(pwzStdOutFileName, pwzApplicationPath); {
*outputManager = manager; 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; hr = E_OUTOFMEMORY;
}
else
{
*outputManager = new NullOutputManager;
} }
return hr; return hr;

View File

@ -33,35 +33,42 @@ REQUESTHANDLER_CONFIG::CreateRequestHandlerConfig(
STRU struHostFxrDllLocation; STRU struHostFxrDllLocation;
STRU struExeLocation; STRU struExeLocation;
if (ppAspNetCoreConfig == NULL) try
{ {
hr = E_INVALIDARG; if (ppAspNetCoreConfig == NULL)
goto Finished; {
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;
} }
catch (std::bad_alloc&)
*ppAspNetCoreConfig = NULL;
pRequestHandlerConfig = new REQUESTHANDLER_CONFIG;
hr = pRequestHandlerConfig->Populate(pHttpServer, pHttpApplication);
if (FAILED(hr))
{ {
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: Finished:
if (pRequestHandlerConfig != NULL) if (pRequestHandlerConfig != NULL)

View File

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

View File

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

View File

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

View File

@ -211,16 +211,14 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="aspnetcore_event.h" /> <ClInclude Include="aspnetcore_event.h" />
<ClInclude Include="disconnectcontext.h" /> <ClInclude Include="inprocessapplication.h" />
<ClInclude Include="environmentvariablehelpers.h" /> <ClInclude Include="inprocesshandler.h" />
<ClInclude Include="precomp.hxx" /> <ClInclude Include="precomp.hxx" />
<ClInclude Include=".\inprocess\inprocessapplication.h" />
<ClInclude Include=".\inprocess\inprocesshandler.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="dllmain.cxx" /> <ClCompile Include="dllmain.cxx" />
<ClCompile Include=".\inprocess\inprocessapplication.cpp" /> <ClCompile Include="inprocessapplication.cpp" />
<ClCompile Include=".\inprocess\inprocesshandler.cpp" /> <ClCompile Include="inprocesshandler.cpp" />
<ClCompile Include="managedexports.cxx" /> <ClCompile Include="managedexports.cxx" />
</ItemGroup> </ItemGroup>
<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. // dllmain.cpp : Defines the entry point for the DLL application.
#include "precomp.hxx" #include "precomp.hxx"
#include <IPHlpApi.h> #include <IPHlpApi.h>
#include <VersionHelpers.h> #include <VersionHelpers.h>
#include "inprocessapplication.h"
#include "inprocesshandler.h"
#include "requesthandler_config.h"
BOOL g_fGlobalInitialize = FALSE; BOOL g_fGlobalInitialize = FALSE;
BOOL g_fProcessDetach = FALSE; BOOL g_fProcessDetach = FALSE;
DWORD g_dwAspNetCoreDebugFlags = 0; DWORD g_dwAspNetCoreDebugFlags = 0;
@ -103,31 +111,56 @@ __stdcall
CreateApplication( CreateApplication(
_In_ IHttpServer *pServer, _In_ IHttpServer *pServer,
_In_ IHttpContext *pHttpContext, _In_ IHttpContext *pHttpContext,
_In_ PCWSTR pwzExeLocation, _In_ PCWSTR pwzExeLocation,
_Out_ IAPPLICATION **ppApplication _Out_ IAPPLICATION **ppApplication
) )
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
IAPPLICATION *pApplication = NULL; IN_PROCESS_APPLICATION *pApplication = NULL;
REQUESTHANDLER_CONFIG *pConfig; REQUESTHANDLER_CONFIG *pConfig = NULL;
// Initialze some global variables here // Initialze some global variables here
InitializeGlobalConfiguration(pServer); InitializeGlobalConfiguration(pServer);
hr = REQUESTHANDLER_CONFIG::CreateRequestHandlerConfig(pServer, pHttpContext->GetApplication(), &pConfig); try
if (FAILED(hr))
{ {
return hr; hr = REQUESTHANDLER_CONFIG::CreateRequestHandlerConfig(pServer, pHttpContext->GetApplication(), &pConfig);
} if (FAILED(hr))
{
goto Finished;
}
pApplication = new IN_PROCESS_APPLICATION(pServer, pConfig, pwzExeLocation); pApplication = new IN_PROCESS_APPLICATION(pServer, pConfig);
if (pApplication == NULL)
pConfig = NULL;
hr = pApplication->Initialize(pwzExeLocation);
if (FAILED(hr))
{
goto Finished;
}
*ppApplication = pApplication;
}
catch (std::bad_alloc&)
{ {
hr = HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY); hr = E_OUTOFMEMORY;
goto Finished;
} }
*ppApplication = pApplication;
Finished: Finished:
if (FAILED(hr))
{
if (pApplication != NULL)
{
delete pApplication;
pApplication = NULL;
}
if (pConfig != NULL)
{
delete pConfig;
pConfig = NULL;
}
}
return hr; 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 "hostfxroptions.h"
#include "requesthandler_config.h"
#include "environmentvariablehelpers.h"
#include "aspnetcore_event.h"
IN_PROCESS_APPLICATION* IN_PROCESS_APPLICATION::s_Application = NULL; IN_PROCESS_APPLICATION* IN_PROCESS_APPLICATION::s_Application = NULL;
hostfxr_main_fn IN_PROCESS_APPLICATION::s_fMainCallback = NULL; hostfxr_main_fn IN_PROCESS_APPLICATION::s_fMainCallback = NULL;
IN_PROCESS_APPLICATION::IN_PROCESS_APPLICATION( IN_PROCESS_APPLICATION::IN_PROCESS_APPLICATION(
IHttpServer *pHttpServer, IHttpServer *pHttpServer,
REQUESTHANDLER_CONFIG *pConfig, REQUESTHANDLER_CONFIG *pConfig) :
PCWSTR pDotnetExeLocation) :
m_pHttpServer(pHttpServer), m_pHttpServer(pHttpServer),
m_ProcessExitCode(0), m_ProcessExitCode(0),
m_fBlockCallbacksIntoManaged(FALSE), m_fBlockCallbacksIntoManaged(FALSE),
m_fInitialized(FALSE), m_fInitialized(FALSE),
m_fShutdownCalledFromNative(FALSE), m_fShutdownCalledFromNative(FALSE),
m_fShutdownCalledFromManaged(FALSE), m_fShutdownCalledFromManaged(FALSE),
m_srwLock(), m_srwLock()
m_pstrDotnetExeLocation(pDotnetExeLocation)
{ {
// is it guaranteed that we have already checked app offline at this point? // 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. // 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); InitializeSRWLock(&m_srwLock);
m_pConfig = pConfig; m_pConfig = pConfig;
// TODO we can probably initialized as I believe we are the only ones calling recycle.
m_status = APPLICATION_STATUS::STARTING; m_status = APPLICATION_STATUS::STARTING;
} }
HRESULT
IN_PROCESS_APPLICATION::Initialize(
PCWSTR pDotnetExeLocation
)
{
return m_struExeLocation.Copy(pDotnetExeLocation);
}
IN_PROCESS_APPLICATION::~IN_PROCESS_APPLICATION() IN_PROCESS_APPLICATION::~IN_PROCESS_APPLICATION()
{ {
@ -573,7 +586,7 @@ IN_PROCESS_APPLICATION::ExecuteApplication(
} }
if (FAILED(hr = HOSTFXR_OPTIONS::Create( if (FAILED(hr = HOSTFXR_OPTIONS::Create(
m_pstrDotnetExeLocation, m_struExeLocation.QueryStr(),
m_pConfig->QueryProcessPath()->QueryStr(), m_pConfig->QueryProcessPath()->QueryStr(),
m_pConfig->QueryApplicationPhysicalPath()->QueryStr(), m_pConfig->QueryApplicationPhysicalPath()->QueryStr(),
m_pConfig->QueryArguments()->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. // Licensed under the MIT License. See License.txt in the project root for license information.
#pragma once #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 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); 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: public:
IN_PROCESS_APPLICATION( IN_PROCESS_APPLICATION(
IHttpServer* pHttpServer, IHttpServer* pHttpServer,
REQUESTHANDLER_CONFIG *pConfig, REQUESTHANDLER_CONFIG *pConfig);
PCWSTR pDotnetExeLocation);
~IN_PROCESS_APPLICATION(); ~IN_PROCESS_APPLICATION();
HRESULT HRESULT
Initialize( Initialize(
VOID PCWSTR pDotnetExeLocation
); );
__override __override
@ -156,7 +160,6 @@ private:
HANDLE m_hErrThread; HANDLE m_hErrThread;
CHAR m_pzFileContents[4096] = { 0 }; CHAR m_pzFileContents[4096] = { 0 };
DWORD m_dwStdErrReadTotal; DWORD m_dwStdErrReadTotal;
PCWSTR m_pstrDotnetExeLocation;
static IN_PROCESS_APPLICATION* s_Application; static IN_PROCESS_APPLICATION* s_Application;
IOutputManager* m_pLoggerProvider; 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_PROCESS_HANDLER::IN_PROCESS_HANDLER(
_In_ IHttpContext *pW3Context, _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 #pragma once
#include "precomp.hxx"
#include "requesthandler.h"
class IN_PROCESS_APPLICATION; class IN_PROCESS_APPLICATION;
class IN_PROCESS_HANDLER : public REQUEST_HANDLER class IN_PROCESS_HANDLER : public REQUEST_HANDLER
{ {
public: public:
IN_PROCESS_HANDLER( IN_PROCESS_HANDLER(
_In_ IHttpContext *pW3Context, _In_ IHttpContext *pW3Context,
_In_ IN_PROCESS_APPLICATION *pApplication); _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. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include "precomp.hxx" #include "precomp.hxx"
#include "inprocessapplication.h"
#include "inprocesshandler.h"
#include "requesthandler_config.h"
// //
// Initialization export // Initialization export
// //

View File

@ -44,26 +44,6 @@
#define WINVER 0x0601 #define WINVER 0x0601
#define _WIN32_WINNT 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 #ifdef max
#undef max #undef max
template<typename T> inline T max(T a, T b) template<typename T> inline T max(T a, T b)

View File

@ -46,12 +46,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Helpers.h" /> <ClInclude Include="Helpers.h" />
<ClInclude Include="fakeclasses.h" />
<ClInclude Include="stdafx.h" /> <ClInclude Include="stdafx.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="FileOutputManagerTests.cpp" /> <ClCompile Include="FileOutputManagerTests.cpp" />
<ClCompile Include="Helpers.cpp" /> <ClCompile Include="Helpers.cpp" />
<ClCompile Include="hostfxr_utility_tests.cpp" /> <ClCompile Include="hostfxr_utility_tests.cpp" />
<ClCompile Include="inprocess_application_tests.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="PipeOutputManagerTests.cpp" /> <ClCompile Include="PipeOutputManagerTests.cpp" />
<ClCompile Include="stdafx.cpp"> <ClCompile Include="stdafx.cpp">
@ -75,6 +77,9 @@
<ProjectReference Include="..\gtest\gtest.vcxproj"> <ProjectReference Include="..\gtest\gtest.vcxproj">
<Project>{cac1267b-8778-4257-aac6-caf481723b01}</Project> <Project>{cac1267b-8778-4257-aac6-caf481723b01}</Project>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\src\AspNetCoreModuleV2\InProcessRequestHandler\InProcessRequestHandler.vcxproj">
<Project>{d57ea297-6dc2-4bc0-8c91-334863327863}</Project>
</ProjectReference>
</ItemGroup> </ItemGroup>
<ItemDefinitionGroup /> <ItemDefinitionGroup />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
@ -88,13 +93,15 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel> <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> <AdditionalOptions>/D "_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" </AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem> <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> </Link>
<Lib> <Lib>
<AdditionalDependencies> <AdditionalDependencies>
@ -111,13 +118,15 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel> <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> <AdditionalOptions>/D "_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" </AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem> <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> </Link>
<Lib> <Lib>
<AdditionalDependencies> <AdditionalDependencies>
@ -132,7 +141,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <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> <AdditionalOptions>/D "_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" </AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile> </ClCompile>
@ -141,6 +150,8 @@
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <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> </Link>
<Lib> <Lib>
<AdditionalDependencies> <AdditionalDependencies>
@ -155,7 +166,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <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> <AdditionalOptions>/D "_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" </AdditionalOptions>
<LanguageStandard>stdcpp14</LanguageStandard> <LanguageStandard>stdcpp14</LanguageStandard>
</ClCompile> </ClCompile>
@ -164,6 +175,8 @@
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <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> </Link>
<Lib> <Lib>
<AdditionalDependencies> <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 "stringa.h"
#include "multisz.h" #include "multisz.h"
#include "dbgutil.h" #include "dbgutil.h"
#include "ahutil.h"
#include "hashfn.h" #include "hashfn.h"
#include "requesthandler_config.h"
#include "hostfxr_utility.h" #include "hostfxr_utility.h"
#include "environmentvariablehash.h" #include "environmentvariablehash.h"
#include "iapplication.h" #include "iapplication.h"
@ -54,3 +54,11 @@
#undef assert // Macro redefinition in IISLib. #undef assert // Macro redefinition in IISLib.
#include "gtest\gtest.h" #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 public class StartupExceptionTests : IISFunctionalTestBase
{ {
// TODO FileNotFound here.
[Theory] [Theory]
[InlineData("CheckLogFile")] [InlineData("CheckLogFile")]
[InlineData("CheckErrLogFile")] [InlineData("CheckErrLogFile")]
public async Task CheckStdoutWithRandomNumber(string path) public async Task CheckStdoutWithRandomNumber(string path)
{ {
var deploymentParameters = Helpers.GetBaseDeploymentParameters("StartupExceptionWebsite"); var deploymentParameters = Helpers.GetBaseDeploymentParameters("StartupExceptionWebsite");
deploymentParameters.PublishApplicationBeforeDeployment = true;
deploymentParameters.EnvironmentVariables["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path; deploymentParameters.EnvironmentVariables["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path;
var randomNumberString = new Random(Guid.NewGuid().GetHashCode()).Next(10000000).ToString(); var randomNumberString = new Random(Guid.NewGuid().GetHashCode()).Next(10000000).ToString();
deploymentParameters.EnvironmentVariables["ASPNETCORE_INPROCESS_RANDOM_VALUE"] = randomNumberString; deploymentParameters.EnvironmentVariables["ASPNETCORE_INPROCESS_RANDOM_VALUE"] = randomNumberString;
@ -39,6 +40,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task CheckStdoutWithLargeWrites(string path) public async Task CheckStdoutWithLargeWrites(string path)
{ {
var deploymentParameters = Helpers.GetBaseDeploymentParameters("StartupExceptionWebsite"); var deploymentParameters = Helpers.GetBaseDeploymentParameters("StartupExceptionWebsite");
deploymentParameters.PublishApplicationBeforeDeployment = true;
deploymentParameters.EnvironmentVariables["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path; deploymentParameters.EnvironmentVariables["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path;
var deploymentResult = await DeployAsync(deploymentParameters); var deploymentResult = await DeployAsync(deploymentParameters);