From 9c5d38a78635085eed2b5ed57696deb4d5a0cc99 Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Wed, 25 Oct 2017 12:35:47 -0700 Subject: [PATCH] Expose VirtualDirectory to In Process mode (#210) --- src/AspNetCore/Inc/aspnetcoreconfig.h | 9 ++++++++ src/AspNetCore/Src/aspnetcoreconfig.cxx | 30 +++++++++++++++++++++++++ src/AspNetCore/Src/managedexports.cxx | 18 ++++++++++----- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/src/AspNetCore/Inc/aspnetcoreconfig.h b/src/AspNetCore/Inc/aspnetcoreconfig.h index 5a4fbf398a..b3fa4d7d8e 100644 --- a/src/AspNetCore/Inc/aspnetcoreconfig.h +++ b/src/AspNetCore/Inc/aspnetcoreconfig.h @@ -139,6 +139,14 @@ public: return &m_struApplicationFullPath; } + STRU* + QueryApplicationVirtualPath( + VOID + ) + { + return &m_struApplicationVirtualPath; + } + STRU* QueryProcessPath( VOID @@ -233,6 +241,7 @@ private: STRU m_struStdoutLogFile; STRU m_struApplicationFullPath; STRU m_strHostingModel; + STRU m_struApplicationVirtualPath; BOOL m_fStdoutLogEnabled; BOOL m_fForwardWindowsAuthToken; BOOL m_fDisableStartUpErrorPage; diff --git a/src/AspNetCore/Src/aspnetcoreconfig.cxx b/src/AspNetCore/Src/aspnetcoreconfig.cxx index 090c4e3f23..99ccac1c3e 100644 --- a/src/AspNetCore/Src/aspnetcoreconfig.cxx +++ b/src/AspNetCore/Src/aspnetcoreconfig.cxx @@ -157,6 +157,9 @@ ASPNETCORE_CONFIG::Populate( ULONGLONG ullRawTimeSpan = 0; ENUM_INDEX index; ENVIRONMENT_VAR_ENTRY* pEntry = NULL; + DWORD dwCounter = 0; + DWORD dwPosition = 0; + WCHAR* pszPath = NULL; m_pEnvironmentVariables = new ENVIRONMENT_VAR_HASH(); if (m_pEnvironmentVariables == NULL) @@ -184,6 +187,33 @@ ASPNETCORE_CONFIG::Populate( goto Finished; } + pszPath = strSiteConfigPath.QueryStr(); + while (pszPath[dwPosition] != NULL) + { + if (pszPath[dwPosition] == '/') + { + dwCounter++; + if (dwCounter == 4) + break; + } + dwPosition++; + } + + if (dwCounter == 4) + { + hr = m_struApplicationVirtualPath.Copy(pszPath + dwPosition); + } + else + { + hr = m_struApplicationVirtualPath.Copy(L"/"); + } + + // Will setup the application virtual path. + if (FAILED(hr)) + { + goto Finished; + } + hr = pAdminManager->GetAdminSection(CS_WINDOWS_AUTHENTICATION_SECTION, strSiteConfigPath.QueryStr(), &pWindowsAuthenticationElement); diff --git a/src/AspNetCore/Src/managedexports.cxx b/src/AspNetCore/Src/managedexports.cxx index f9dd492fcc..b0a31daa5f 100644 --- a/src/AspNetCore/Src/managedexports.cxx +++ b/src/AspNetCore/Src/managedexports.cxx @@ -136,16 +136,22 @@ http_get_completion_info( // the signature should be changed. application's based address should be passed in // EXTERN_C __MIDL_DECLSPEC_DLLEXPORT -BSTR // TODO probably should make this a wide string -http_get_application_full_path() +HRESULT // TODO probably should make this a wide string +http_get_application_paths( + _Out_ BSTR* pwzFullPath, + _Out_ BSTR* pwzVirtualPath +) { - LPWSTR pwzPath = NULL; IN_PROCESS_APPLICATION* pApplication = IN_PROCESS_APPLICATION::GetInstance(); - if (pApplication != NULL) + + if (pApplication == NULL) { - pwzPath = pApplication->QueryConfig()->QueryApplicationFullPath()->QueryStr(); + return E_FAIL; } - return SysAllocString(pwzPath); + // These should be provided to the in process application as arguments? + *pwzFullPath = SysAllocString(pApplication->QueryConfig()->QueryApplicationFullPath()->QueryStr()); + *pwzVirtualPath = SysAllocString(pApplication->QueryConfig()->QueryApplicationVirtualPath()->QueryStr()); + return S_OK; } EXTERN_C __MIDL_DECLSPEC_DLLEXPORT