Skip to content

Commit ec7f233

Browse files
committed
Revert "Load ANCM out of process via global versioning (#895)"
This reverts commit 9d97ff3.
1 parent 9d97ff3 commit ec7f233

24 files changed

+69
-863
lines changed

build/testsite.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030
</PropertyGroup>
3131
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
32-
<None Include="$(MSBuildThisFileDirectory)..\src\AspNetCoreModuleV2\OutOfProcessRequestHandler\bin\$(Configuration)\$(NativeFolder)\aspnetcorev2_outofprocess.dll" CopyToOutputDirectory="PreserveNewest" Visible="true" Link="$(BasePathForRequestHandler)\$(AspNetCoreModuleOutOfProcessVersion)\%(FileName)%(Extension)" />
33-
<None Include="$(MSBuildThisFileDirectory)..\src\AspNetCoreModuleV2\OutOfProcessRequestHandler\bin\$(Configuration)\$(NativeFolder)\aspnetcorev2_outofprocess.pdb" CopyToOutputDirectory="PreserveNewest" Visible="true" Link="$(BasePathForRequestHandler)\$(AspNetCoreModuleOutOfProcessVersion)\%(FileName)%(Extension)" />
32+
<None Include="$(MSBuildThisFileDirectory)..\src\AspNetCoreModuleV2\OutOfProcessRequestHandler\bin\$(Configuration)\$(NativeFolder)\aspnetcorev2_outofprocess.dll" CopyToOutputDirectory="PreserveNewest" Visible="true" Link="$(BasePathForRequestHandler)%(FileName)%(Extension)" />
33+
<None Include="$(MSBuildThisFileDirectory)..\src\AspNetCoreModuleV2\OutOfProcessRequestHandler\bin\$(Configuration)\$(NativeFolder)\aspnetcorev2_outofprocess.pdb" CopyToOutputDirectory="PreserveNewest" Visible="true" Link="$(BasePathForRequestHandler)%(FileName)%(Extension)" />
3434
<None Include="$(MSBuildThisFileDirectory)..\src\AspNetCoreModuleV2\InProcessRequestHandler\bin\$(Configuration)\$(NativeFolder)\aspnetcorev2_inprocess.dll" CopyToOutputDirectory="PreserveNewest" Visible="true" Link="$(BasePathForRequestHandler)%(FileName)%(Extension)" />
3535
<None Include="$(MSBuildThisFileDirectory)..\src\AspNetCoreModuleV2\InProcessRequestHandler\bin\$(Configuration)\$(NativeFolder)\aspnetcorev2_inprocess.pdb" CopyToOutputDirectory="PreserveNewest" Visible="true" Link="$(BasePathForRequestHandler)%(FileName)%(Extension)" />
3636
<None Include="$(MSBuildThisFileDirectory)..\src\AspNetCoreModuleV2\AspNetCore\bin\$(Configuration)\$(NativeFolder)\aspnetcorev2.dll" CopyToOutputDirectory="PreserveNewest" Visible="true" Link="$(BasePathForRequestHandler)%(FileName)%(Extension)" />

nuget/AspNetCoreV2.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<files>
2222
<file src="src\AspNetCoreModuleV2\AspNetCore\bin\$Configuration$\Win32\aspnetcorev2.dll" target="contentFiles\any\any\x86\aspnetcorev2.dll" />
2323
<file src="src\AspNetCoreModuleV2\AspNetCore\bin\$Configuration$\x64\aspnetcorev2.dll" target="contentFiles\any\any\x64\aspnetcorev2.dll" />
24-
<file src="src\AspNetCoreModuleV2\OutOfProcessRequestHandler\bin\$Configuration$\Win32\aspnetcorev2_outofprocess.dll" target="contentFiles\any\any\x86\$(AspNetCoreModuleOutOfProcessVersion)\aspnetcorev2_outofprocess.dll" />
25-
<file src="src\AspNetCoreModuleV2\OutOfProcessRequestHandler\bin\$Configuration$\x64\aspnetcorev2_outofprocess.dll" target="contentFiles\any\any\x64\$(AspNetCoreModuleOutOfProcessVersion)\aspnetcorev2_outofprocess.dll" />
24+
<file src="src\AspNetCoreModuleV2\OutOfProcessRequestHandler\bin\$Configuration$\Win32\aspnetcorev2_outofprocess.dll" target="contentFiles\any\any\x86\aspnetcorev2_outofprocess.dll" />
25+
<file src="src\AspNetCoreModuleV2\OutOfProcessRequestHandler\bin\$Configuration$\x64\aspnetcorev2_outofprocess.dll" target="contentFiles\any\any\x64\aspnetcorev2_outofprocess.dll" />
2626
<file src="src\AspNetCoreModuleV2\InProcessRequestHandler\bin\$Configuration$\Win32\aspnetcorev2_inprocess.dll" target="contentFiles\any\any\x86\aspnetcorev2_inprocess.dll" />
2727
<file src="src\AspNetCoreModuleV2\InProcessRequestHandler\bin\$Configuration$\x64\aspnetcorev2_inprocess.dll" target="contentFiles\any\any\x64\aspnetcorev2_inprocess.dll" />
2828
<file src="src\AspNetCoreModuleV2\AspNetCore\bin\$Configuration$\x64\*.xml"/>

nuget/Microsoft.AspNetCore.AspNetCoreModule.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<AspNetCoreModuleX86Location>$(MSBuildThisFileDirectory)..\contentFiles\any\any\x86\aspnetcore.dll</AspNetCoreModuleX86Location>
66
<InProcessRequestHandlerX64Location>$(MSBuildThisFileDirectory)..\contentFiles\any\any\x64\aspnetcorev2_inprocess.dll</InProcessRequestHandlerX64Location>
77
<InProcessRequestHandlerX86Location>$(MSBuildThisFileDirectory)..\contentFiles\any\any\x86\aspnetcorev2_inprocess.dll</InProcessRequestHandlerX86Location>
8-
<OutOfProcessRequestHandlerX64Location>$(MSBuildThisFileDirectory)..\contentFiles\any\any\x64\$(AspNetCoreModuleOutOfProcessVersion)\aspnetcorev2_outofprocess.dll</OutOfProcessRequestHandlerX64Location>
9-
<OutOfProcessRequestHandlerX86Location>$(MSBuildThisFileDirectory)..\contentFiles\any\any\x86\$(AspNetCoreModuleOutOfProcessVersion)\aspnetcorev2_outofprocess.dll</OutOfProcessRequestHandlerX86Location>
8+
<OutOfProcessRequestHandlerX64Location>$(MSBuildThisFileDirectory)..\contentFiles\any\any\x64\aspnetcorev2_outofprocess.dll</OutOfProcessRequestHandlerX64Location>
9+
<OutOfProcessRequestHandlerX86Location>$(MSBuildThisFileDirectory)..\contentFiles\any\any\x86\aspnetcorev2_outofprocess.dll</OutOfProcessRequestHandlerX86Location>
1010
</PropertyGroup>
1111

1212
</Project>

src/AspNetCoreModuleV2/AspNetCore/Inc/aspnetcore_shim_config.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#pragma once
55

66
#include "precomp.hxx"
7-
#include <map>
87

98
#define CS_ASPNETCORE_SECTION L"system.webServer/aspNetCore"
109
#define CS_ASPNETCORE_PROCESS_EXE_PATH L"processPath"
@@ -106,14 +105,6 @@ class ASPNETCORE_SHIM_CONFIG : IHttpStoredContext
106105
return m_hostingModel;
107106
}
108107

109-
STRU*
110-
QueryHandlerVersion(
111-
VOID
112-
)
113-
{
114-
return &m_struHandlerVersion;
115-
}
116-
117108
private:
118109
ASPNETCORE_SHIM_CONFIG() :
119110
m_cRefs(1),
@@ -129,6 +120,5 @@ class ASPNETCORE_SHIM_CONFIG : IHttpStoredContext
129120
STRU m_struConfigPath;
130121
APP_HOSTING_MODEL m_hostingModel;
131122
STRU m_struHostFxrLocation;
132-
STRU m_struHandlerVersion;
133123
};
134124

src/AspNetCoreModuleV2/AspNetCore/src/applicationinfo.cpp

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -358,47 +358,60 @@ APPLICATION_INFO::FindRequestHandlerAssembly(STRU& location)
358358

359359
HRESULT
360360
APPLICATION_INFO::FindNativeAssemblyFromGlobalLocation(
361-
PCWSTR pstrHandlerDllName,
362-
STRU* struFilename
363-
)
361+
PCWSTR libraryName,
362+
STRU* struFilename)
364363
{
365364
HRESULT hr = S_OK;
366-
367-
try
365+
DWORD dwSize = MAX_PATH;
366+
BOOL fDone = FALSE;
367+
DWORD dwPosition = 0;
368+
369+
// Though we could call LoadLibrary(L"aspnetcorerh.dll") relying the OS to solve
370+
// the path (the targeted dll is the same folder of w3wp.exe/iisexpress)
371+
// let's still load with full path to avoid security issue
372+
if (FAILED(hr = struFilename->Resize(dwSize + 20)))
368373
{
369-
std::wstring modulePath = GlobalVersionUtility::GetModuleName(g_hModule);
370-
371-
modulePath = GlobalVersionUtility::RemoveFileNameFromFolderPath(modulePath);
372-
373-
std::wstring retval = GlobalVersionUtility::GetGlobalRequestHandlerPath(modulePath.c_str(),
374-
m_pConfiguration->QueryHandlerVersion()->QueryStr(),
375-
pstrHandlerDllName
376-
);
374+
goto Finished;
375+
}
377376

378-
if (FAILED(hr = struFilename->Copy(retval.c_str())))
377+
while (!fDone)
378+
{
379+
DWORD dwReturnedSize = GetModuleFileNameW(g_hModule, struFilename->QueryStr(), dwSize);
380+
if (dwReturnedSize == 0)
379381
{
380-
return hr;
382+
hr = HRESULT_FROM_WIN32(GetLastError());
383+
fDone = TRUE;
384+
goto Finished;
381385
}
382-
}
383-
catch (std::exception& e)
384-
{
385-
STRU struEvent;
386-
if (SUCCEEDED(struEvent.Copy(ASPNETCORE_EVENT_OUT_OF_PROCESS_RH_MISSING_MSG))
387-
&& SUCCEEDED(struEvent.AppendA(e.what())))
386+
else if ((dwReturnedSize == dwSize) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER))
388387
{
389-
UTILITY::LogEvent(g_hEventLog,
390-
EVENTLOG_INFORMATION_TYPE,
391-
ASPNETCORE_EVENT_OUT_OF_PROCESS_RH_MISSING,
392-
struEvent.QueryStr());
388+
dwSize *= 2; // smaller buffer. increase the buffer and retry
389+
if (FAILED(hr = struFilename->Resize(dwSize + 40))) // + 40 for aspnetcorerh.dll
390+
{
391+
goto Finished;
392+
}
393+
}
394+
else
395+
{
396+
fDone = TRUE;
393397
}
394-
395-
hr = E_FAIL;
396398
}
397-
catch (...)
399+
400+
if (FAILED(hr = struFilename->SyncWithBuffer()))
398401
{
399-
hr = E_FAIL;
402+
goto Finished;
400403
}
404+
dwPosition = struFilename->LastIndexOf(L'\\', 0);
405+
struFilename->QueryStr()[dwPosition] = L'\0';
401406

407+
if (FAILED(hr = struFilename->SyncWithBuffer()) ||
408+
FAILED(hr = struFilename->Append(L"\\")) ||
409+
FAILED(hr = struFilename->Append(libraryName)))
410+
{
411+
goto Finished;
412+
}
413+
414+
Finished:
402415
return hr;
403416
}
404417

src/AspNetCoreModuleV2/AspNetCore/src/aspnetcore_shim_config.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "aspnetcore_shim_config.h"
55

6-
#include "config_utility.h"
76
#include "hostfxr_utility.h"
87
#include "debugutil.h"
98
#include "ahutil.h"
@@ -193,8 +192,6 @@ ASPNETCORE_SHIM_CONFIG::Populate(
193192
goto Finished;
194193
}
195194

196-
hr = ConfigUtility::FindHandlerVersion(pAspNetCoreElement, &m_struHandlerVersion);
197-
198195
Finished:
199196

200197
if (pAspNetCoreElement != NULL)

src/AspNetCoreModuleV2/CommonLib/CommonLib.vcxproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,6 @@
181181
</ItemDefinitionGroup>
182182
<ItemGroup>
183183
<ClInclude Include="application.h" />
184-
<ClInclude Include="config_utility.h" />
185-
<ClInclude Include="GlobalVersionUtility.h" />
186184
<ClInclude Include="NullOutputManager.h" />
187185
<ClInclude Include="FileOutputManager.h" />
188186
<ClInclude Include="fx_ver.h" />
@@ -207,7 +205,6 @@
207205
<ItemGroup>
208206
<ClCompile Include="FileOutputManager.cpp" />
209207
<ClCompile Include="fx_ver.cxx" />
210-
<ClCompile Include="GlobalVersionUtility.cpp" />
211208
<ClCompile Include="hostfxr_utility.cpp" />
212209
<ClCompile Include="hostfxroptions.cpp" />
213210
<ClCompile Include="requesthandler_config.cpp" />

src/AspNetCoreModuleV2/CommonLib/GlobalVersionUtility.cpp

Lines changed: 0 additions & 131 deletions
This file was deleted.

src/AspNetCoreModuleV2/CommonLib/GlobalVersionUtility.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)