@@ -97,7 +97,7 @@ static const MonoBundledSatelliteAssembly **satellite_bundles;
97
97
/* Class lazy loading functions */
98
98
static GENERATE_TRY_GET_CLASS_WITH_CACHE (internals_visible , "System.Runtime.CompilerServices" , "InternalsVisibleToAttribute" )
99
99
static MonoAssembly *
100
- mono_assembly_invoke_search_hook_internal (MonoAssemblyLoadContext * alc , MonoAssembly * requesting , MonoAssemblyName * aname , gboolean refonly , gboolean postload );
100
+ mono_assembly_invoke_search_hook_internal (MonoAssemblyLoadContext * alc , MonoAssembly * requesting , MonoAssemblyName * aname , gboolean postload );
101
101
102
102
static MonoAssembly *
103
103
invoke_assembly_preload_hook (MonoAssemblyLoadContext * alc , MonoAssemblyName * aname , gchar * * apath );
@@ -1015,10 +1015,10 @@ search_bundle_for_assembly (MonoAssemblyLoadContext *alc, MonoAssemblyName *anam
1015
1015
MonoImageOpenStatus status ;
1016
1016
MonoImage * image ;
1017
1017
MonoAssemblyLoadRequest req ;
1018
- image = mono_assembly_open_from_bundle (alc , aname -> name , & status , FALSE, aname -> culture );
1018
+ image = mono_assembly_open_from_bundle (alc , aname -> name , & status , aname -> culture );
1019
1019
if (!image && !g_str_has_suffix (aname -> name , ".dll" )) {
1020
1020
char * name = g_strdup_printf ("%s.dll" , aname -> name );
1021
- image = mono_assembly_open_from_bundle (alc , name , & status , FALSE, aname -> culture );
1021
+ image = mono_assembly_open_from_bundle (alc , name , & status , aname -> culture );
1022
1022
}
1023
1023
if (image ) {
1024
1024
mono_assembly_request_prepare_load (& req , MONO_ASMCTX_DEFAULT , alc );
@@ -1147,7 +1147,7 @@ netcore_load_reference (MonoAssemblyName *aname, MonoAssemblyLoadContext *alc, M
1147
1147
// Looking up corlib resources here can cause an infinite loop
1148
1148
// See: https://github.com/dotnet/coreclr/blob/0a762eb2f3a299489c459da1ddeb69e042008f07/src/vm/appdomain.cpp#L5178-L5239
1149
1149
if (!(strcmp (aname -> name , MONO_ASSEMBLY_CORLIB_RESOURCE_NAME ) == 0 && is_satellite ) && postload ) {
1150
- reference = mono_assembly_invoke_search_hook_internal (alc , requesting , aname , FALSE, TRUE);
1150
+ reference = mono_assembly_invoke_search_hook_internal (alc , requesting , aname , TRUE);
1151
1151
if (reference ) {
1152
1152
mono_trace (G_LOG_LEVEL_DEBUG , MONO_TRACE_ASSEMBLY , "Assembly found with AssemblyResolve event: '%s'." , aname -> name );
1153
1153
goto leave ;
@@ -1159,7 +1159,7 @@ netcore_load_reference (MonoAssemblyName *aname, MonoAssemblyLoadContext *alc, M
1159
1159
}
1160
1160
1161
1161
static MonoImage *
1162
- open_from_satellite_bundle (MonoAssemblyLoadContext * alc , const char * filename , MonoImageOpenStatus * status , gboolean refonly , const char * culture )
1162
+ open_from_satellite_bundle (MonoAssemblyLoadContext * alc , const char * filename , MonoImageOpenStatus * status , const char * culture )
1163
1163
{
1164
1164
if (!satellite_bundles )
1165
1165
return NULL ;
@@ -1168,7 +1168,7 @@ open_from_satellite_bundle (MonoAssemblyLoadContext *alc, const char *filename,
1168
1168
char * name = g_strdup (filename );
1169
1169
for (int i = 0 ; !image && satellite_bundles [i ]; ++ i ) {
1170
1170
if (strcmp (satellite_bundles [i ]-> name , name ) == 0 && strcmp (satellite_bundles [i ]-> culture , culture ) == 0 ) {
1171
- image = mono_image_open_from_data_internal (alc , (char * )satellite_bundles [i ]-> data , satellite_bundles [i ]-> size , FALSE, status , refonly , FALSE, name , NULL );
1171
+ image = mono_image_open_from_data_internal (alc , (char * )satellite_bundles [i ]-> data , satellite_bundles [i ]-> size , FALSE, status , FALSE, name , NULL );
1172
1172
break ;
1173
1173
}
1174
1174
}
@@ -1475,19 +1475,19 @@ struct AssemblySearchHook {
1475
1475
static AssemblySearchHook * assembly_search_hook = NULL ;
1476
1476
1477
1477
static MonoAssembly *
1478
- mono_assembly_invoke_search_hook_internal (MonoAssemblyLoadContext * alc , MonoAssembly * requesting , MonoAssemblyName * aname , gboolean refonly , gboolean postload )
1478
+ mono_assembly_invoke_search_hook_internal (MonoAssemblyLoadContext * alc , MonoAssembly * requesting , MonoAssemblyName * aname , gboolean postload )
1479
1479
{
1480
1480
AssemblySearchHook * hook ;
1481
1481
1482
1482
for (hook = assembly_search_hook ; hook ; hook = hook -> next ) {
1483
- if ((hook -> refonly == refonly ) && (hook -> postload == postload )) {
1483
+ if ((hook -> refonly == FALSE ) && (hook -> postload == postload )) {
1484
1484
MonoAssembly * ass ;
1485
1485
if (hook -> version == 1 ) {
1486
1486
ass = hook -> func .v1 (aname , hook -> user_data );
1487
1487
} else {
1488
1488
ERROR_DECL (hook_error );
1489
1489
g_assert (hook -> version == 2 );
1490
- ass = hook -> func .v2 (alc , requesting , aname , refonly , postload , hook -> user_data , hook_error );
1490
+ ass = hook -> func .v2 (alc , requesting , aname , FALSE , postload , hook -> user_data , hook_error );
1491
1491
mono_error_assert_ok (hook_error ); /* FIXME: proper error handling */
1492
1492
}
1493
1493
if (ass )
@@ -1504,7 +1504,7 @@ mono_assembly_invoke_search_hook_internal (MonoAssemblyLoadContext *alc, MonoAss
1504
1504
MonoAssembly *
1505
1505
mono_assembly_invoke_search_hook (MonoAssemblyName * aname )
1506
1506
{
1507
- return mono_assembly_invoke_search_hook_internal (NULL , NULL , aname , FALSE, FALSE );
1507
+ return mono_assembly_invoke_search_hook_internal (NULL , NULL , aname , FALSE);
1508
1508
}
1509
1509
1510
1510
static void
@@ -1870,7 +1870,7 @@ absolute_dir (const gchar *filename)
1870
1870
}
1871
1871
1872
1872
static MonoImage *
1873
- open_from_bundle_internal (MonoAssemblyLoadContext * alc , const char * filename , MonoImageOpenStatus * status , gboolean refonly , gboolean is_satellite )
1873
+ open_from_bundle_internal (MonoAssemblyLoadContext * alc , const char * filename , MonoImageOpenStatus * status , gboolean is_satellite )
1874
1874
{
1875
1875
if (!bundles )
1876
1876
return NULL ;
@@ -1880,7 +1880,7 @@ open_from_bundle_internal (MonoAssemblyLoadContext *alc, const char *filename, M
1880
1880
for (int i = 0 ; !image && bundles [i ]; ++ i ) {
1881
1881
if (strcmp (bundles [i ]-> name , name ) == 0 ) {
1882
1882
// Since bundled images don't exist on disk, don't give them a legit filename
1883
- image = mono_image_open_from_data_internal (alc , (char * )bundles [i ]-> data , bundles [i ]-> size , FALSE, status , refonly , FALSE, name , NULL );
1883
+ image = mono_image_open_from_data_internal (alc , (char * )bundles [i ]-> data , bundles [i ]-> size , FALSE, status , FALSE, name , NULL );
1884
1884
break ;
1885
1885
}
1886
1886
}
@@ -1899,7 +1899,7 @@ open_from_bundle_internal (MonoAssemblyLoadContext *alc, const char *filename, M
1899
1899
* returns NULL
1900
1900
*/
1901
1901
MonoImage *
1902
- mono_assembly_open_from_bundle (MonoAssemblyLoadContext * alc , const char * filename , MonoImageOpenStatus * status , gboolean refonly , const char * culture )
1902
+ mono_assembly_open_from_bundle (MonoAssemblyLoadContext * alc , const char * filename , MonoImageOpenStatus * status , const char * culture )
1903
1903
{
1904
1904
/*
1905
1905
* we do a very simple search for bundled assemblies: it's not a general
@@ -1909,9 +1909,9 @@ mono_assembly_open_from_bundle (MonoAssemblyLoadContext *alc, const char *filena
1909
1909
gboolean is_satellite = culture && culture [0 ] != 0 ;
1910
1910
1911
1911
if (is_satellite )
1912
- image = open_from_satellite_bundle (alc , filename , status , refonly , culture );
1912
+ image = open_from_satellite_bundle (alc , filename , status , culture );
1913
1913
else
1914
- image = open_from_bundle_internal (alc , filename , status , refonly , FALSE);
1914
+ image = open_from_bundle_internal (alc , filename , status , FALSE);
1915
1915
1916
1916
if (image ) {
1917
1917
mono_image_addref (image );
@@ -1948,11 +1948,16 @@ mono_assembly_open_from_bundle (MonoAssemblyLoadContext *alc, const char *filena
1948
1948
MonoAssembly *
1949
1949
mono_assembly_open_full (const char * filename , MonoImageOpenStatus * status , gboolean refonly )
1950
1950
{
1951
+ if (refonly ) {
1952
+ if (status )
1953
+ * status = MONO_IMAGE_IMAGE_INVALID ;
1954
+ return NULL ;
1955
+ }
1951
1956
MonoAssembly * res ;
1952
1957
MONO_ENTER_GC_UNSAFE ;
1953
1958
MonoAssemblyOpenRequest req ;
1954
1959
mono_assembly_request_prepare_open (& req ,
1955
- refonly ? MONO_ASMCTX_REFONLY : MONO_ASMCTX_DEFAULT ,
1960
+ MONO_ASMCTX_DEFAULT ,
1956
1961
mono_domain_default_alc (mono_domain_get ()));
1957
1962
res = mono_assembly_request_open (filename , & req , status );
1958
1963
MONO_EXIT_GC_UNSAFE ;
@@ -2038,7 +2043,7 @@ mono_assembly_request_open (const char *filename, const MonoAssemblyOpenRequest
2038
2043
return NULL ;
2039
2044
}
2040
2045
2041
- if ( load_req . asmctx != MONO_ASMCTX_REFONLY ) {
2046
+ {
2042
2047
MonoAssemblyContextKind out_asmctx ;
2043
2048
/* If the path belongs to the appdomain base dir or the
2044
2049
* base dir of the requesting assembly, load the
@@ -2048,10 +2053,8 @@ mono_assembly_request_open (const char *filename, const MonoAssemblyOpenRequest
2048
2053
load_req .asmctx = out_asmctx ;
2049
2054
}
2050
2055
} else {
2051
- if (load_req .asmctx != MONO_ASMCTX_REFONLY ) {
2052
- /* GAC assemblies always in default context or refonly context. */
2053
- load_req .asmctx = MONO_ASMCTX_DEFAULT ;
2054
- }
2056
+ /* GAC assemblies always in default context or refonly context. */
2057
+ load_req .asmctx = MONO_ASMCTX_DEFAULT ;
2055
2058
}
2056
2059
if (new_fname && new_fname != fname ) {
2057
2060
g_free (fname );
@@ -2062,24 +2065,23 @@ mono_assembly_request_open (const char *filename, const MonoAssemblyOpenRequest
2062
2065
2063
2066
image = NULL ;
2064
2067
2065
- const gboolean refonly = load_req .asmctx == MONO_ASMCTX_REFONLY ;
2066
2068
/* for LoadFrom(string), LoadFile(string) and Load(byte[]), allow them
2067
2069
* to load problematic images. Not sure if ReflectionOnlyLoad(string)
2068
2070
* and ReflectionOnlyLoadFrom(string) should also be allowed - let's
2069
2071
* say, yes.
2070
2072
*/
2071
- const gboolean load_from_context = load_req .asmctx == MONO_ASMCTX_LOADFROM || load_req .asmctx == MONO_ASMCTX_INDIVIDUAL || load_req . asmctx == MONO_ASMCTX_REFONLY ;
2073
+ const gboolean load_from_context = load_req .asmctx == MONO_ASMCTX_LOADFROM || load_req .asmctx == MONO_ASMCTX_INDIVIDUAL ;
2072
2074
2073
2075
// If VM built with mkbundle
2074
2076
loaded_from_bundle = FALSE;
2075
2077
if (bundles != NULL || satellite_bundles != NULL ) {
2076
2078
/* We don't know the culture of the filename we're loading here, so this call is not culture aware. */
2077
- image = mono_assembly_open_from_bundle (load_req .alc , fname , status , refonly , NULL );
2079
+ image = mono_assembly_open_from_bundle (load_req .alc , fname , status , NULL );
2078
2080
loaded_from_bundle = image != NULL ;
2079
2081
}
2080
2082
2081
2083
if (!image )
2082
- image = mono_image_open_a_lot (load_req .alc , fname , status , refonly , load_from_context );
2084
+ image = mono_image_open_a_lot (load_req .alc , fname , status , FALSE , load_from_context );
2083
2085
2084
2086
if (!image ){
2085
2087
if (* status == MONO_IMAGE_OK )
@@ -2326,13 +2328,18 @@ MonoAssembly *
2326
2328
mono_assembly_load_from_full (MonoImage * image , const char * fname ,
2327
2329
MonoImageOpenStatus * status , gboolean refonly )
2328
2330
{
2331
+ if (refonly ) {
2332
+ if (status )
2333
+ * status = MONO_IMAGE_IMAGE_INVALID ;
2334
+ return NULL ;
2335
+ }
2329
2336
MonoAssembly * res ;
2330
2337
MONO_ENTER_GC_UNSAFE ;
2331
2338
MonoAssemblyLoadRequest req ;
2332
2339
MonoImageOpenStatus def_status ;
2333
2340
if (!status )
2334
2341
status = & def_status ;
2335
- mono_assembly_request_prepare_load (& req , refonly ? MONO_ASMCTX_REFONLY : MONO_ASMCTX_DEFAULT , mono_domain_default_alc (mono_domain_get ()));
2342
+ mono_assembly_request_prepare_load (& req , MONO_ASMCTX_DEFAULT , mono_domain_default_alc (mono_domain_get ()));
2336
2343
res = mono_assembly_request_load_from (image , fname , & req , status );
2337
2344
MONO_EXIT_GC_UNSAFE ;
2338
2345
return res ;
@@ -2412,7 +2419,7 @@ mono_assembly_request_load_from (MonoImage *image, const char *fname,
2412
2419
*/
2413
2420
if (ass -> aname .name && asmctx != MONO_ASMCTX_INDIVIDUAL ) {
2414
2421
/* FIXME: I think individual context should probably also look for an existing MonoAssembly here, we just need to pass the asmctx to the search hook so that it does a filename match (I guess?) */
2415
- ass2 = mono_assembly_invoke_search_hook_internal (req -> alc , NULL , & ass -> aname , asmctx == MONO_ASMCTX_REFONLY , FALSE);
2422
+ ass2 = mono_assembly_invoke_search_hook_internal (req -> alc , NULL , & ass -> aname , FALSE);
2416
2423
if (ass2 ) {
2417
2424
mono_trace (G_LOG_LEVEL_DEBUG , MONO_TRACE_ASSEMBLY , "Image %s[%p] reusing existing assembly %s[%p]" , ass -> aname .name , ass , ass2 -> aname .name , ass2 );
2418
2425
g_free (ass );
@@ -2430,7 +2437,7 @@ mono_assembly_request_load_from (MonoImage *image, const char *fname,
2430
2437
* this image and we won't be able to look for a different
2431
2438
* candidate. */
2432
2439
2433
- if ( asmctx != MONO_ASMCTX_REFONLY ) {
2440
+ {
2434
2441
ERROR_DECL (refasm_error );
2435
2442
if (mono_assembly_has_reference_assembly_attribute (ass , refasm_error )) {
2436
2443
mono_trace (G_LOG_LEVEL_DEBUG , MONO_TRACE_ASSEMBLY , "Image for assembly '%s' (%s) has ReferenceAssemblyAttribute, skipping" , ass -> aname .name , image -> name );
@@ -3256,12 +3263,17 @@ mono_assembly_load_full_alc (MonoGCHandle alc_gchandle, MonoAssemblyName *aname,
3256
3263
MonoAssembly *
3257
3264
mono_assembly_load_full (MonoAssemblyName * aname , const char * basedir , MonoImageOpenStatus * status , gboolean refonly )
3258
3265
{
3266
+ if (refonly ) {
3267
+ if (status )
3268
+ * status = MONO_IMAGE_IMAGE_INVALID ;
3269
+ return NULL ;
3270
+ }
3259
3271
MonoAssembly * res ;
3260
3272
MONO_ENTER_GC_UNSAFE ;
3261
3273
MonoAssemblyByNameRequest req ;
3262
3274
mono_assembly_request_prepare_byname (& req ,
3263
- refonly ? MONO_ASMCTX_REFONLY : MONO_ASMCTX_DEFAULT ,
3264
- mono_domain_default_alc (mono_domain_get ()));
3275
+ MONO_ASMCTX_DEFAULT ,
3276
+ mono_domain_default_alc (mono_domain_get ()));
3265
3277
req .requesting_assembly = NULL ;
3266
3278
req .basedir = basedir ;
3267
3279
res = mono_assembly_request_byname (aname , & req , status );
@@ -3303,6 +3315,8 @@ mono_assembly_load (MonoAssemblyName *aname, const char *basedir, MonoImageOpenS
3303
3315
MonoAssembly *
3304
3316
mono_assembly_loaded_full (MonoAssemblyName * aname , gboolean refonly )
3305
3317
{
3318
+ if (refonly )
3319
+ return NULL ;
3306
3320
MonoAssemblyLoadContext * alc = mono_domain_default_alc (mono_domain_get ());
3307
3321
return mono_assembly_loaded_internal (alc , aname , refonly );
3308
3322
}
@@ -3313,9 +3327,11 @@ mono_assembly_loaded_internal (MonoAssemblyLoadContext *alc, MonoAssemblyName *a
3313
3327
MonoAssembly * res ;
3314
3328
MonoAssemblyName mapped_aname ;
3315
3329
3330
+ g_assert (!refonly );
3331
+
3316
3332
aname = mono_assembly_remap_version (aname , & mapped_aname );
3317
3333
3318
- res = mono_assembly_invoke_search_hook_internal (alc , NULL , aname , refonly , FALSE);
3334
+ res = mono_assembly_invoke_search_hook_internal (alc , NULL , aname , FALSE);
3319
3335
3320
3336
return res ;
3321
3337
}
@@ -3744,7 +3760,6 @@ mono_asmctx_get_name (const MonoAssemblyContext *asmctx)
3744
3760
{
3745
3761
static const char * names [] = {
3746
3762
"DEFAULT" ,
3747
- "REFONLY" ,
3748
3763
"LOADFROM" ,
3749
3764
"INDIVIDIUAL" ,
3750
3765
"INTERNAL"
0 commit comments