@@ -373,11 +373,14 @@ DkmStackWalkFrame[] IDkmCallStackFilter.FilterNextFrame(DkmStackContext stackCon
373373 return new DkmStackWalkFrame [ 1 ] { input } ;
374374 }
375375
376- if ( processData . scratchMemory == 0 )
377- processData . scratchMemory = process . AllocateVirtualMemory ( 0 , 4096 , 0x3000 , 0x04 ) ;
376+ if ( process . LivePart != null )
377+ {
378+ if ( processData . scratchMemory == 0 )
379+ processData . scratchMemory = process . AllocateVirtualMemory ( 0 , 4096 , 0x3000 , 0x04 ) ;
378380
379- if ( processData . scratchMemory == 0 )
380- return new DkmStackWalkFrame [ 1 ] { input } ;
381+ if ( processData . scratchMemory == 0 )
382+ return new DkmStackWalkFrame [ 1 ] { input } ;
383+ }
381384
382385 // Find out the current process working directory (Lua script files will be resolved from that location)
383386 if ( processData . workingDirectory == null && ! processData . workingDirectoryRequested )
@@ -397,7 +400,7 @@ DkmStackWalkFrame[] IDkmCallStackFilter.FilterNextFrame(DkmStackContext stackCon
397400 // Jumping through hoops, kernel32.dll should be loaded
398401 ulong callAddress = DebugHelpers . FindFunctionAddress ( process . GetNativeRuntimeInstance ( ) , "GetCurrentDirectoryA" ) ;
399402
400- if ( callAddress != 0 )
403+ if ( callAddress != 0 && processData . scratchMemory != 0 )
401404 {
402405 long ? length = EvaluationHelpers . TryEvaluateNumberExpression ( $ "((int(*)(int, char*))0x{ callAddress : x} )(4095, (char*){ processData . scratchMemory } )", stackContext . InspectionSession , stackContext . Thread , input , DkmEvaluationFlags . None ) ;
403406
@@ -453,6 +456,9 @@ DkmStackWalkFrame[] IDkmCallStackFilter.FilterNextFrame(DkmStackContext stackCon
453456
454457 string GetLuaFunctionName ( ulong currCallInfoAddress , ulong prevCallInfoAddress , ulong closureAddress )
455458 {
459+ if ( processData . scratchMemory == 0 )
460+ return null ;
461+
456462 string functionNameType = null ;
457463
458464 DkmCustomMessage . Create ( process . Connection , process , MessageToRemote . guid , MessageToRemote . pauseBreakpoints , null , null ) . SendLower ( ) ;
@@ -2270,12 +2276,6 @@ void IDkmModuleInstanceLoadNotification.OnModuleInstanceLoad(DkmModuleInstance m
22702276 }
22712277#endif
22722278
2273- if ( process . LivePart == null )
2274- {
2275- log . Debug ( $ "Process is not live, do not attach to Lua") ;
2276- return ;
2277- }
2278-
22792279 var processData = DebugHelpers . GetOrCreateDataItem < LuaLocalProcessData > ( process ) ;
22802280
22812281 var moduleName = nativeModuleInstance . FullName ;
@@ -2286,6 +2286,13 @@ void IDkmModuleInstanceLoadNotification.OnModuleInstanceLoad(DkmModuleInstance m
22862286 // Request the RemoteComponent to create the runtime and a module
22872287 DkmCustomMessage . Create ( process . Connection , process , MessageToRemote . guid , MessageToRemote . createRuntime , null , null ) . SendLower ( ) ;
22882288
2289+ if ( process . LivePart == null )
2290+ {
2291+ log . Debug ( $ "Process is not live, do not attach to Lua") ;
2292+
2293+ return ;
2294+ }
2295+
22892296 if ( ! attachOnLaunch )
22902297 {
22912298 log . Warning ( "Lua attach on launch is disabled, skip search for Lua" ) ;
0 commit comments