React to hostfxr api changes (#577)

This commit is contained in:
Justin Kotalik 2018-02-02 16:07:51 -08:00 committed by GitHub
parent 2ed691a960
commit 5465216be9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -369,7 +369,8 @@ APPLICATION_INFO::FindNativeAssemblyFromHostfxr(
INT intIndex = -1; INT intIndex = -1;
INT intPrevIndex = 0; INT intPrevIndex = 0;
BOOL fFound = FALSE; BOOL fFound = FALSE;
DWORD dwBufferSize = 1024 * 10; DWORD dwBufferSize = 1024;
DWORD dwRequiredBufferSize = 0;
DBG_ASSERT(struFileName != NULL); DBG_ASSERT(struFileName != NULL);
@ -404,16 +405,17 @@ APPLICATION_INFO::FindNativeAssemblyFromHostfxr(
m_pConfiguration->QueryHostFxrArgCount(), m_pConfiguration->QueryHostFxrArgCount(),
m_pConfiguration->QueryHostFxrArguments(), m_pConfiguration->QueryHostFxrArguments(),
struNativeSearchPaths.QueryStr(), struNativeSearchPaths.QueryStr(),
dwBufferSize dwBufferSize,
&dwRequiredBufferSize
); );
if (intHostFxrExitCode == 0) if (intHostFxrExitCode == 0)
{ {
break; break;
} }
else if (intHostFxrExitCode == API_BUFFER_TOO_SMALL) else if (dwRequiredBufferSize >= dwBufferSize)
{ {
dwBufferSize *= 2; // smaller buffer. increase the buffer and retry dwBufferSize = dwRequiredBufferSize + 1; // for null terminator
if (FAILED(hr = struNativeSearchPaths.Resize(dwBufferSize))) if (FAILED(hr = struNativeSearchPaths.Resize(dwBufferSize)))
{ {
goto Finished; goto Finished;

View File

@ -3,7 +3,7 @@
#pragma once #pragma once
typedef INT(*hostfxr_get_native_search_directories_fn) (const int argc, const PCWSTR argv[], PCWSTR dest, size_t dest_size); typedef INT(*hostfxr_get_native_search_directories_fn) (CONST INT argc, CONST PCWSTR* argv, PWSTR buffer, DWORD buffer_size, DWORD* required_buffer_size);
typedef INT(*hostfxr_main_fn) (CONST DWORD argc, CONST PCWSTR argv[]); typedef INT(*hostfxr_main_fn) (CONST DWORD argc, CONST PCWSTR argv[]);
#define READ_BUFFER_SIZE 4096 #define READ_BUFFER_SIZE 4096

View File

@ -143,4 +143,4 @@ IN_PROCESS_HANDLER::SetManangedHttpContext(
) )
{ {
m_pManagedHttpContext = pManagedHttpContext; m_pManagedHttpContext = pManagedHttpContext;
} }