52
52
// #define STRICT_JITLOCK_ENTRY_LEAK_DETECTION
53
53
// #define STRICT_CLSINITLOCK_ENTRY_LEAK_DETECTION
54
54
55
+ LPCWSTR s_wszDiagnosticStartupHookPaths = nullptr ;
55
56
56
57
#ifndef DACCESS_COMPILE
57
58
@@ -1122,7 +1123,47 @@ bool Assembly::IgnoresAccessChecksTo(Assembly *pAccessedAssembly)
1122
1123
return GetFriendAssemblyInfo ()->IgnoresAccessChecksTo (pAccessedAssembly);
1123
1124
}
1124
1125
1126
+ void Assembly::AddDiagnosticStartupHookPath (LPCWSTR wszPath)
1127
+ {
1128
+ LPCWSTR wszDiagnosticStartupHookPathsLocal = s_wszDiagnosticStartupHookPaths;
1129
+
1130
+ size_t cchPath = u16_strlen (wszPath);
1131
+ size_t cchDiagnosticStartupHookPathsNew = cchPath;
1132
+ size_t cchDiagnosticStartupHookPathsLocal = 0 ;
1133
+ if (nullptr != wszDiagnosticStartupHookPathsLocal)
1134
+ {
1135
+ cchDiagnosticStartupHookPathsLocal = u16_strlen (wszDiagnosticStartupHookPathsLocal);
1136
+ // Add 1 for the path separator
1137
+ cchDiagnosticStartupHookPathsNew += cchDiagnosticStartupHookPathsLocal + 1 ;
1138
+ }
1125
1139
1140
+ size_t currentSize = cchDiagnosticStartupHookPathsNew + 1 ;
1141
+ LPWSTR wszDiagnosticStartupHookPathsNew = new WCHAR[currentSize];
1142
+ LPWSTR wszCurrent = wszDiagnosticStartupHookPathsNew;
1143
+
1144
+ u16_strcpy_s (wszCurrent, currentSize, wszPath);
1145
+ wszCurrent += cchPath;
1146
+ currentSize -= cchPath;
1147
+
1148
+ if (cchDiagnosticStartupHookPathsLocal > 0 )
1149
+ {
1150
+ u16_strcpy_s (wszCurrent, currentSize, PATH_SEPARATOR_STR_W);
1151
+ wszCurrent += 1 ;
1152
+ currentSize -= 1 ;
1153
+
1154
+ u16_strcpy_s (wszCurrent, currentSize, wszDiagnosticStartupHookPathsLocal);
1155
+ wszCurrent += cchDiagnosticStartupHookPathsLocal;
1156
+ currentSize -= cchDiagnosticStartupHookPathsLocal;
1157
+ }
1158
+
1159
+ // Expect null terminating character
1160
+ _ASSERTE (currentSize == 1 );
1161
+ _ASSERTE (wszCurrent[0 ] == W (' \0 ' ));
1162
+
1163
+ s_wszDiagnosticStartupHookPaths = wszDiagnosticStartupHookPathsNew;
1164
+
1165
+ delete [] wszDiagnosticStartupHookPathsLocal;
1166
+ }
1126
1167
1127
1168
enum CorEntryPointType
1128
1169
{
@@ -1376,7 +1417,7 @@ static void RunMainPost()
1376
1417
}
1377
1418
}
1378
1419
1379
- static void RunManagedStartup ()
1420
+ void RunManagedStartup ()
1380
1421
{
1381
1422
CONTRACTL
1382
1423
{
@@ -1388,7 +1429,11 @@ static void RunManagedStartup()
1388
1429
CONTRACTL_END;
1389
1430
1390
1431
MethodDescCallSite managedStartup (METHOD__STARTUP_HOOK_PROVIDER__MANAGED_STARTUP);
1391
- managedStartup.Call (NULL );
1432
+
1433
+ ARG_SLOT args[1 ];
1434
+ args[0 ] = PtrToArgSlot (s_wszDiagnosticStartupHookPaths);
1435
+
1436
+ managedStartup.Call (args);
1392
1437
}
1393
1438
1394
1439
INT32 Assembly::ExecuteMainMethod (PTRARRAYREF *stringArgs, BOOL waitForOtherThreads)
0 commit comments