-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update HostingWithHostFxr to 3.1 (#3909)
* Update HostingWithHostFxr to 3.1 Also small changes to the readme * Fix the VS solution to build * Use compiler detection and don't rely on environment on Windows Copied the native build targets from core/interop/pinvoke/marshalling sample. * Fix build from VS - pick the bitness of the SDK being used * Update readme to match the latest requirements and behavior * Fix location of inc dir on Linux * PR feedback and cleanup
- Loading branch information
1 parent
067de6f
commit c232a34
Showing
7 changed files
with
202 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
core/hosting/HostWithHostFxr/src/NativeHost/inc.vs/nethost.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#ifndef __NETHOST_H__ | ||
#define __NETHOST_H__ | ||
|
||
#include <stddef.h> | ||
|
||
#ifdef _WIN32 | ||
#ifdef NETHOST_EXPORT | ||
#define NETHOST_API __declspec(dllexport) | ||
#else | ||
// Consuming the nethost as a static library | ||
// Shouldn't export attempt to dllimport. | ||
#ifdef NETHOST_USE_AS_STATIC | ||
#define NETHOST_API | ||
#else | ||
#define NETHOST_API __declspec(dllimport) | ||
#endif | ||
#endif | ||
|
||
#define NETHOST_CALLTYPE __stdcall | ||
#ifdef _WCHAR_T_DEFINED | ||
typedef wchar_t char_t; | ||
#else | ||
typedef unsigned short char_t; | ||
#endif | ||
#else | ||
#ifdef NETHOST_EXPORT | ||
#define NETHOST_API __attribute__((__visibility__("default"))) | ||
#else | ||
#define NETHOST_API | ||
#endif | ||
|
||
#define NETHOST_CALLTYPE | ||
typedef char char_t; | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
// Parameters for get_hostfxr_path | ||
// | ||
// Fields: | ||
// size | ||
// Size of the struct. This is used for versioning. | ||
// | ||
// assembly_path | ||
// Path to the compenent's assembly. | ||
// If specified, hostfxr is located as if the assembly_path is the apphost | ||
// | ||
// dotnet_root | ||
// Path to directory containing the dotnet executable. | ||
// If specified, hostfxr is located as if an application is started using | ||
// 'dotnet app.dll', which means it will be searched for under the dotnet_root | ||
// path and the assembly_path is ignored. | ||
// | ||
struct get_hostfxr_parameters { | ||
size_t size; | ||
const char_t *assembly_path; | ||
const char_t *dotnet_root; | ||
}; | ||
|
||
// | ||
// Get the path to the hostfxr library | ||
// | ||
// Parameters: | ||
// buffer | ||
// Buffer that will be populated with the hostfxr path, including a null terminator. | ||
// | ||
// buffer_size | ||
// [in] Size of buffer in char_t units. | ||
// [out] Size of buffer used in char_t units. If the input value is too small | ||
// or buffer is nullptr, this is populated with the minimum required size | ||
// in char_t units for a buffer to hold the hostfxr path | ||
// | ||
// get_hostfxr_parameters | ||
// Optional. Parameters that modify the behaviour for locating the hostfxr library. | ||
// If nullptr, hostfxr is located using the enviroment variable or global registration | ||
// | ||
// Return value: | ||
// 0 on success, otherwise failure | ||
// 0x80008098 - buffer is too small (HostApiBufferTooSmall) | ||
// | ||
// Remarks: | ||
// The full search for the hostfxr library is done on every call. To minimize the need | ||
// to call this function multiple times, pass a large buffer (e.g. PATH_MAX). | ||
// | ||
NETHOST_API int NETHOST_CALLTYPE get_hostfxr_path( | ||
char_t * buffer, | ||
size_t * buffer_size, | ||
const struct get_hostfxr_parameters *parameters); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif | ||
|
||
#endif // __NETHOST_H__ |
When
nativehost.exe
is copied, attempting to run it causes Windows Defender to detect it asTrojan:Script/Wacatac.B!ml
and delete it.May need to change the native output name to e.g.
dotnetlibhost
as it only loadsDotNetLib.runtimeconfig.json
.