5252// #define STRICT_JITLOCK_ENTRY_LEAK_DETECTION
5353// #define STRICT_CLSINITLOCK_ENTRY_LEAK_DETECTION
5454
55+ LPCWSTR s_wszDiagnosticStartupHookPaths = nullptr ;
5556
5657#ifndef  DACCESS_COMPILE
5758
@@ -1122,7 +1123,47 @@ bool Assembly::IgnoresAccessChecksTo(Assembly *pAccessedAssembly)
11221123    return  GetFriendAssemblyInfo ()->IgnoresAccessChecksTo (pAccessedAssembly);
11231124}
11241125
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+     }
11251139
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+ }
11261167
11271168enum  CorEntryPointType
11281169{
@@ -1376,7 +1417,7 @@ static void RunMainPost()
13761417    }
13771418}
13781419
1379- static   void  RunManagedStartup ()
1420+ void  RunManagedStartup ()
13801421{
13811422    CONTRACTL
13821423    {
@@ -1388,7 +1429,11 @@ static void RunManagedStartup()
13881429    CONTRACTL_END;
13891430
13901431    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);
13921437}
13931438
13941439INT32 Assembly::ExecuteMainMethod (PTRARRAYREF *stringArgs, BOOL waitForOtherThreads)
0 commit comments