mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Adding more ETW logs to wsman plugin (#12798)
This commit is contained in:
@@ -187,6 +187,15 @@ namespace System.Management.Automation.Remoting
|
||||
WSManNativeApi.WSManShellStartupInfo_UnToMan startupInfo,
|
||||
WSManNativeApi.WSManData_UnToMan inboundShellInformation)
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerCreateRemoteSession,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
"null",
|
||||
"CreateShell: Create a new shell in the plugin context",
|
||||
string.Empty);
|
||||
|
||||
if (requestDetails == null)
|
||||
{
|
||||
// Nothing can be done because requestDetails are required to report operation complete
|
||||
@@ -228,6 +237,15 @@ namespace System.Management.Automation.Remoting
|
||||
return;
|
||||
}
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerCreateRemoteSession,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
requestDetails.ToString(),
|
||||
"CreateShell: NULL checks being performed",
|
||||
string.Empty);
|
||||
|
||||
if ((0 == startupInfo.inputStreamSet.streamIDsCount) || (0 == startupInfo.outputStreamSet.streamIDsCount))
|
||||
{
|
||||
ReportOperationComplete(
|
||||
@@ -282,11 +300,12 @@ namespace System.Management.Automation.Remoting
|
||||
serverTransportMgr = new WSManPluginServerTransportManager(BaseTransportManager.DefaultFragmentSize, null);
|
||||
}
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.ServerCreateRemoteSession,
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerCreateRemoteSession,
|
||||
PSOpcode.Connect, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
requestDetails.ToString(), senderInfo.UserInfo.Identity.Name, requestDetails.resourceUri);
|
||||
ServerRemoteSession remoteShellSession = ServerRemoteSession.CreateServerRemoteSession(senderInfo,
|
||||
ServerRemoteSession remoteShellSession = ServerRemoteSession.CreateServerRemoteSession(senderInfo,
|
||||
requestDetails.resourceUri,
|
||||
extraInfo,
|
||||
serverTransportMgr);
|
||||
@@ -334,7 +353,8 @@ namespace System.Management.Automation.Remoting
|
||||
}
|
||||
|
||||
// now report the shell context to WSMan.
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.ReportContext,
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ReportContext,
|
||||
PSOpcode.Connect, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
requestDetails.ToString(), requestDetails.ToString());
|
||||
@@ -445,6 +465,15 @@ namespace System.Management.Automation.Remoting
|
||||
return;
|
||||
}
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerCreateRemoteSession,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
requestDetails.ToString(),
|
||||
"CreateShell: Completed",
|
||||
string.Empty);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -455,9 +484,11 @@ namespace System.Management.Automation.Remoting
|
||||
internal void CloseShellOperation(
|
||||
WSManPluginOperationShutdownContext context)
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.ServerCloseOperation,
|
||||
PSOpcode.Disconnect, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerCloseOperation,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
((IntPtr)context.shellContext).ToString(),
|
||||
((IntPtr)context.commandContext).ToString(),
|
||||
context.isReceiveOperation.ToString());
|
||||
@@ -478,13 +509,23 @@ namespace System.Management.Automation.Remoting
|
||||
|
||||
System.Exception reasonForClose = new System.Exception(RemotingErrorIdStrings.WSManPluginOperationClose);
|
||||
mgdShellSession.CloseOperation(context, reasonForClose);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerCloseOperation,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
"CloseShellOperation: Completed",
|
||||
string.Empty);
|
||||
}
|
||||
|
||||
internal void CloseCommandOperation(
|
||||
WSManPluginOperationShutdownContext context)
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.ServerCloseOperation,
|
||||
PSOpcode.Disconnect, PSTask.None,
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerCloseOperation,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
context.shellContext.ToString(),
|
||||
context.commandContext.ToString(),
|
||||
@@ -499,6 +540,14 @@ namespace System.Management.Automation.Remoting
|
||||
}
|
||||
|
||||
mgdShellSession.CloseCommandOperation(context);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerCloseOperation,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
"CloseCommandOperation: Completed",
|
||||
string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -598,7 +647,8 @@ namespace System.Management.Automation.Remoting
|
||||
if (requestDetails == null)
|
||||
{
|
||||
// Nothing can be done because requestDetails are required to report operation complete
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.ReportOperationComplete,
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ReportOperationComplete,
|
||||
PSOpcode.Close, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
"null",
|
||||
@@ -643,6 +693,15 @@ namespace System.Management.Automation.Remoting
|
||||
string commandLine,
|
||||
WSManNativeApi.WSManCommandArgSet arguments)
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerCreateCommandSession,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"CreateCommand: Create a new command in the shell context",
|
||||
string.Empty);
|
||||
|
||||
if (!validateIncomingContexts(requestDetails, shellContext, "WSManRunShellCommandEx"))
|
||||
{
|
||||
return;
|
||||
@@ -650,9 +709,10 @@ namespace System.Management.Automation.Remoting
|
||||
|
||||
SetThreadProperties(requestDetails);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.ServerCreateCommandSession,
|
||||
PSOpcode.Connect, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerCreateCommandSession,
|
||||
PSOpcode.Connect, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
((IntPtr)shellContext).ToString(), requestDetails.ToString());
|
||||
|
||||
WSManPluginShellSession mgdShellSession = GetFromActiveShellSessions(shellContext);
|
||||
@@ -667,6 +727,15 @@ namespace System.Management.Automation.Remoting
|
||||
}
|
||||
|
||||
mgdShellSession.CreateCommand(pluginContext, requestDetails, flags, commandLine, arguments);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerCreateCommandSession,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"CreateCommand: Create a new command in the shell context completed",
|
||||
string.Empty);
|
||||
}
|
||||
|
||||
internal void StopCommand(
|
||||
@@ -677,7 +746,8 @@ namespace System.Management.Automation.Remoting
|
||||
if (requestDetails == null)
|
||||
{
|
||||
// Nothing can be done because requestDetails are required to report operation complete
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.ReportOperationComplete,
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ReportOperationComplete,
|
||||
PSOpcode.Close, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
"null",
|
||||
@@ -692,12 +762,14 @@ namespace System.Management.Automation.Remoting
|
||||
|
||||
SetThreadProperties(requestDetails);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.ServerStopCommand,
|
||||
PSOpcode.Disconnect, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
((IntPtr)shellContext).ToString(),
|
||||
((IntPtr)commandContext).ToString(),
|
||||
requestDetails.ToString());
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerStopCommand,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
((IntPtr)shellContext).ToString(),
|
||||
((IntPtr)commandContext).ToString(),
|
||||
requestDetails.ToString());
|
||||
|
||||
WSManPluginShellSession mgdShellSession = GetFromActiveShellSessions(shellContext);
|
||||
if (mgdShellSession == null)
|
||||
@@ -722,13 +794,22 @@ namespace System.Management.Automation.Remoting
|
||||
}
|
||||
|
||||
mgdCommandSession.Stop(requestDetails);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerStopCommand,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
"StopCommand: completed",
|
||||
string.Empty);
|
||||
}
|
||||
|
||||
internal void Shutdown()
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManPluginShutdown,
|
||||
PSOpcode.ShuttingDown, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic);
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManPluginShutdown,
|
||||
PSOpcode.ShuttingDown, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic);
|
||||
|
||||
// all active shells should be closed at this point
|
||||
Dbg.Assert(_activeShellSessions.Count == 0, "All active shells should be closed");
|
||||
@@ -752,6 +833,15 @@ namespace System.Management.Automation.Remoting
|
||||
IntPtr commandContext,
|
||||
WSManNativeApi.WSManData_UnToMan inboundConnectInformation)
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"ConnectShellOrCommand: Connect",
|
||||
string.Empty);
|
||||
|
||||
if (!validateIncomingContexts(requestDetails, shellContext, "ConnectShellOrCommand"))
|
||||
{
|
||||
return;
|
||||
@@ -759,10 +849,15 @@ namespace System.Management.Automation.Remoting
|
||||
|
||||
// TODO... What does this mean from a new client that has specified diff locale from original client?
|
||||
SetThreadProperties(requestDetails);
|
||||
// TODO.. Add new ETW events and log
|
||||
/*etwTracer.AnalyticChannel.WriteInformation(PSEventId.ServerReceivedData,
|
||||
PSOpcode.Open, PSTask.None,
|
||||
((IntPtr)shellContext).ToString(), ((IntPtr)commandContext).ToString(), ((IntPtr)requestDetails).ToString());*/
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
((IntPtr)shellContext).ToString(),
|
||||
((IntPtr)commandContext).ToString(),
|
||||
requestDetails.ToString());
|
||||
|
||||
WSManPluginShellSession mgdShellSession = GetFromActiveShellSessions(shellContext);
|
||||
if (mgdShellSession == null)
|
||||
@@ -793,7 +888,25 @@ namespace System.Management.Automation.Remoting
|
||||
return;
|
||||
}
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
((IntPtr)shellContext).ToString(),
|
||||
((IntPtr)commandContext).ToString(),
|
||||
requestDetails.ToString());
|
||||
|
||||
mgdCmdSession.ExecuteConnect(requestDetails, flags, inboundConnectInformation);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"ConnectShellOrCommand: ExecuteConnect invoked",
|
||||
string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -813,6 +926,15 @@ namespace System.Management.Automation.Remoting
|
||||
string stream,
|
||||
WSManNativeApi.WSManData_UnToMan inboundData)
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"SendOneItemToShellOrCommand: Send data to the shell / command specified",
|
||||
string.Empty);
|
||||
|
||||
if (!validateIncomingContexts(requestDetails, shellContext, "SendOneItemToShellOrCommand"))
|
||||
{
|
||||
return;
|
||||
@@ -820,10 +942,14 @@ namespace System.Management.Automation.Remoting
|
||||
|
||||
SetThreadProperties(requestDetails);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.ServerReceivedData,
|
||||
PSOpcode.Open, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
((IntPtr)shellContext).ToString(), ((IntPtr)commandContext).ToString(), requestDetails.ToString());
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
((IntPtr)shellContext).ToString(),
|
||||
((IntPtr)commandContext).ToString(),
|
||||
requestDetails.ToString());
|
||||
|
||||
WSManPluginShellSession mgdShellSession = GetFromActiveShellSessions(shellContext);
|
||||
if (mgdShellSession == null)
|
||||
@@ -856,7 +982,25 @@ namespace System.Management.Automation.Remoting
|
||||
return;
|
||||
}
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
((IntPtr)shellContext).ToString(),
|
||||
((IntPtr)commandContext).ToString(),
|
||||
requestDetails.ToString());
|
||||
|
||||
mgdCmdSession.SendOneItemToSession(requestDetails, flags, stream, inboundData);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"SendOneItemToShellOrCommand: SendOneItemToSession invoked",
|
||||
string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -877,6 +1021,15 @@ namespace System.Management.Automation.Remoting
|
||||
IntPtr commandContext,
|
||||
WSManNativeApi.WSManStreamIDSet_UnToMan streamSet)
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerClientReceiveRequest,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"EnableShellOrCommandToSendDataToClient: unlock the shell / command specified so that the shell / command starts sending data to the client.",
|
||||
string.Empty);
|
||||
|
||||
if (!validateIncomingContexts(requestDetails, shellContext, "EnableShellOrCommandToSendDataToClient"))
|
||||
{
|
||||
return;
|
||||
@@ -884,12 +1037,14 @@ namespace System.Management.Automation.Remoting
|
||||
|
||||
SetThreadProperties(requestDetails);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.ServerClientReceiveRequest,
|
||||
PSOpcode.Open, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
((IntPtr)shellContext).ToString(),
|
||||
((IntPtr)commandContext).ToString(),
|
||||
requestDetails.ToString());
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerClientReceiveRequest,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
((IntPtr)shellContext).ToString(),
|
||||
((IntPtr)commandContext).ToString(),
|
||||
requestDetails.ToString());
|
||||
|
||||
WSManPluginShellSession mgdShellSession = GetFromActiveShellSessions(shellContext);
|
||||
if (mgdShellSession == null)
|
||||
@@ -910,6 +1065,15 @@ namespace System.Management.Automation.Remoting
|
||||
return;
|
||||
}
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerClientReceiveRequest,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"EnableShellOrCommandToSendDataToClient: Instruction destined to shell or for command",
|
||||
string.Empty);
|
||||
|
||||
if (IntPtr.Zero == commandContext)
|
||||
{
|
||||
// the instruction is destined for shell (runspace) session. so let shell handle it
|
||||
@@ -1135,6 +1299,15 @@ namespace System.Management.Automation.Remoting
|
||||
IntPtr startupInfo, // WSMAN_SHELL_STARTUP_INFO*
|
||||
IntPtr inboundShellInformation) // WSMAN_DATA*
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateShell,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"PerformWSManPluginShell: static func to take care of unmanaged to managed transitions.",
|
||||
string.Empty);
|
||||
|
||||
WSManPluginInstance pluginToUse = GetFromActivePlugins(pluginContext);
|
||||
|
||||
if (pluginToUse == null)
|
||||
@@ -1157,7 +1330,24 @@ namespace System.Management.Automation.Remoting
|
||||
WSManNativeApi.WSManShellStartupInfo_UnToMan startupInfoInstance = WSManNativeApi.WSManShellStartupInfo_UnToMan.UnMarshal(startupInfo);
|
||||
WSManNativeApi.WSManData_UnToMan inboundShellInfo = WSManNativeApi.WSManData_UnToMan.UnMarshal(inboundShellInformation);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateShell,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
requestDetailsInstance.ToString(),
|
||||
requestDetailsInstance.resourceUri);
|
||||
|
||||
pluginToUse.CreateShell(pluginContext, requestDetailsInstance, flags, extraInfo, startupInfoInstance, inboundShellInfo);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateShell,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"PerformWSManPluginShell: Completed",
|
||||
string.Empty);
|
||||
}
|
||||
|
||||
internal static void PerformWSManPluginCommand(
|
||||
@@ -1168,6 +1358,15 @@ namespace System.Management.Automation.Remoting
|
||||
[MarshalAs(UnmanagedType.LPWStr)] string commandLine,
|
||||
IntPtr arguments) // WSMAN_COMMAND_ARG_SET*
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateShell,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"PerformWSManPluginCommand: static func to take care of unmanaged to managed transitions.",
|
||||
string.Empty);
|
||||
|
||||
WSManPluginInstance pluginToUse = GetFromActivePlugins(pluginContext);
|
||||
|
||||
if (pluginToUse == null)
|
||||
@@ -1184,7 +1383,24 @@ namespace System.Management.Automation.Remoting
|
||||
WSManNativeApi.WSManPluginRequest request = WSManNativeApi.WSManPluginRequest.UnMarshal(requestDetails);
|
||||
WSManNativeApi.WSManCommandArgSet argSet = WSManNativeApi.WSManCommandArgSet.UnMarshal(arguments);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateShell,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
request.ToString(),
|
||||
request.resourceUri);
|
||||
|
||||
pluginToUse.CreateCommand(pluginContext, request, flags, shellContext, commandLine, argSet);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateShell,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"PerformWSManPluginCommand: Completed",
|
||||
string.Empty);
|
||||
}
|
||||
|
||||
internal static void PerformWSManPluginConnect(
|
||||
@@ -1195,6 +1411,15 @@ namespace System.Management.Automation.Remoting
|
||||
IntPtr commandContext,
|
||||
IntPtr inboundConnectInformation)
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateShell,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"PerformWSManPluginConnect: static func to take care of unmanaged to managed transitions.",
|
||||
string.Empty);
|
||||
|
||||
WSManPluginInstance pluginToUse = GetFromActivePlugins(pluginContext);
|
||||
|
||||
if (pluginToUse == null)
|
||||
@@ -1211,7 +1436,24 @@ namespace System.Management.Automation.Remoting
|
||||
WSManNativeApi.WSManPluginRequest request = WSManNativeApi.WSManPluginRequest.UnMarshal(requestDetails);
|
||||
WSManNativeApi.WSManData_UnToMan connectInformation = WSManNativeApi.WSManData_UnToMan.UnMarshal(inboundConnectInformation);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateShell,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
request.ToString(),
|
||||
request.resourceUri);
|
||||
|
||||
pluginToUse.ConnectShellOrCommand(request, flags, shellContext, commandContext, connectInformation);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateShell,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"PerformWSManPluginConnect: Completed",
|
||||
string.Empty);
|
||||
}
|
||||
|
||||
internal static void PerformWSManPluginSend(
|
||||
@@ -1223,6 +1465,15 @@ namespace System.Management.Automation.Remoting
|
||||
string stream,
|
||||
IntPtr inboundData) // WSMAN_DATA*
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"PerformWSManPluginSend: Invoked",
|
||||
string.Empty);
|
||||
|
||||
WSManPluginInstance pluginToUse = GetFromActivePlugins(pluginContext);
|
||||
|
||||
if (pluginToUse == null)
|
||||
@@ -1240,6 +1491,15 @@ namespace System.Management.Automation.Remoting
|
||||
WSManNativeApi.WSManData_UnToMan data = WSManNativeApi.WSManData_UnToMan.UnMarshal(inboundData);
|
||||
|
||||
pluginToUse.SendOneItemToShellOrCommand(request, flags, shellContext, commandContext, stream, data);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"PerformWSManPluginSend: Completed",
|
||||
string.Empty);
|
||||
}
|
||||
|
||||
internal static void PerformWSManPluginReceive(
|
||||
@@ -1250,6 +1510,15 @@ namespace System.Management.Automation.Remoting
|
||||
IntPtr commandContext,
|
||||
IntPtr streamSet) // WSMAN_STREAM_ID_SET*
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"PerformWSManPluginReceive: Invoked",
|
||||
string.Empty);
|
||||
|
||||
WSManPluginInstance pluginToUse = GetFromActivePlugins(pluginContext);
|
||||
|
||||
if (pluginToUse == null)
|
||||
@@ -1266,7 +1535,24 @@ namespace System.Management.Automation.Remoting
|
||||
WSManNativeApi.WSManPluginRequest request = WSManNativeApi.WSManPluginRequest.UnMarshal(requestDetails);
|
||||
WSManNativeApi.WSManStreamIDSet_UnToMan streamIdSet = WSManNativeApi.WSManStreamIDSet_UnToMan.UnMarshal(streamSet);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
request.ToString(),
|
||||
request.resourceUri);
|
||||
|
||||
pluginToUse.EnableShellOrCommandToSendDataToClient(pluginContext, request, flags, shellContext, commandContext, streamIdSet);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"PerformWSManPluginReceive: Completed",
|
||||
string.Empty);
|
||||
}
|
||||
|
||||
internal static void PerformWSManPluginSignal(
|
||||
@@ -1277,6 +1563,15 @@ namespace System.Management.Automation.Remoting
|
||||
IntPtr commandContext, // PVOID
|
||||
string code)
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"PerformWSManPluginSignal: Invoked",
|
||||
string.Empty);
|
||||
|
||||
WSManNativeApi.WSManPluginRequest request = WSManNativeApi.WSManPluginRequest.UnMarshal(requestDetails);
|
||||
|
||||
// Close Command
|
||||
@@ -1328,6 +1623,15 @@ namespace System.Management.Automation.Remoting
|
||||
internal static void PerformCloseOperation(
|
||||
WSManPluginOperationShutdownContext context)
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ServerReceivedData,
|
||||
PSOpcode.Open,
|
||||
PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
string.Empty,
|
||||
"PerformCloseOperation: Invoked",
|
||||
string.Empty);
|
||||
|
||||
WSManPluginInstance pluginToUse = GetFromActivePlugins(context.pluginContext);
|
||||
|
||||
if (pluginToUse == null)
|
||||
@@ -1399,7 +1703,8 @@ namespace System.Management.Automation.Remoting
|
||||
{
|
||||
Dbg.Assert(requestDetails != null, "requestDetails cannot be null in operation complete.");
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.ReportOperationComplete,
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ReportOperationComplete,
|
||||
PSOpcode.Close, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
(requestDetails.unmanagedHandle).ToString(),
|
||||
@@ -1432,7 +1737,8 @@ namespace System.Management.Automation.Remoting
|
||||
stackTrace = reasonForClose.StackTrace;
|
||||
}
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.ReportOperationComplete,
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.ReportOperationComplete,
|
||||
PSOpcode.Close, PSTask.None,
|
||||
PSKeyword.ManagedPlugin | PSKeyword.UseAlwaysAnalytic,
|
||||
requestDetails.ToString(),
|
||||
|
||||
@@ -1005,7 +1005,8 @@ namespace System.Management.Automation.Remoting.Client
|
||||
|
||||
receiveDataInitiated = true;
|
||||
tracer.WriteLine("Client Session TM: Placing Receive request using WSManReceiveShellOutputEx");
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManReceiveShellOutputEx,
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManReceiveShellOutputEx,
|
||||
PSOpcode.Receive, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString(), Guid.Empty.ToString());
|
||||
|
||||
@@ -1109,7 +1110,9 @@ namespace System.Management.Automation.Remoting.Client
|
||||
_createSessionCallbackGCHandle = GCHandle.Alloc(_createSessionCallback);
|
||||
}
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManCreateShell, PSOpcode.Connect,
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateShell,
|
||||
PSOpcode.Connect,
|
||||
PSTask.CreateRunspace, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString());
|
||||
|
||||
@@ -1227,7 +1230,8 @@ namespace System.Management.Automation.Remoting.Client
|
||||
}
|
||||
|
||||
// TODO - On unexpected failures on a reconstructed session... we dont want to close server session
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManCloseShell,
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCloseShell,
|
||||
PSOpcode.Disconnect, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString());
|
||||
_closeSessionCompleted = new WSManNativeApi.WSManShellAsync(new IntPtr(_sessionContextID), s_sessionCloseCallback);
|
||||
@@ -1306,9 +1310,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
{
|
||||
CloseSessionAndClearResources();
|
||||
tracer.WriteLine("Redirecting to URI: {0}", newUri);
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.URIRedirection,
|
||||
PSOpcode.Connect, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString(), newUri.ToString());
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.URIRedirection,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString(),
|
||||
newUri.ToString());
|
||||
Initialize(newUri, (WSManConnectionInfo)connectionInfo);
|
||||
// reset startmode
|
||||
_startMode = WSManTransportManagerUtils.tmStartModes.None;
|
||||
@@ -1638,14 +1646,16 @@ namespace System.Management.Automation.Remoting.Client
|
||||
}
|
||||
|
||||
// Write errors into both Operational and Analytical channels
|
||||
PSEtwLog.LogOperationalError(PSEventId.TransportError, PSOpcode.Open, PSTask.None, PSKeyword.UseAlwaysOperational,
|
||||
PSEtwLog.LogOperationalError(
|
||||
PSEventId.TransportError, PSOpcode.Open, PSTask.None, PSKeyword.UseAlwaysOperational,
|
||||
RunspacePoolInstanceId.ToString(),
|
||||
Guid.Empty.ToString(),
|
||||
eventArgs.Exception.ErrorCode.ToString(CultureInfo.InvariantCulture),
|
||||
eventArgs.Exception.Message,
|
||||
stackTrace);
|
||||
|
||||
PSEtwLog.LogAnalyticError(PSEventId.TransportError_Analytic,
|
||||
PSEtwLog.LogAnalyticError(
|
||||
PSEventId.TransportError_Analytic,
|
||||
PSOpcode.Open, PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString(),
|
||||
@@ -1852,8 +1862,11 @@ namespace System.Management.Automation.Remoting.Client
|
||||
return;
|
||||
}
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManCreateShellCallbackReceived,
|
||||
PSOpcode.Connect, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateShellCallbackReceived,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
sessionTM.RunspacePoolInstanceId.ToString());
|
||||
|
||||
// TODO: 188098 wsManShellOperationHandle should be populated by WSManCreateShellEx,
|
||||
@@ -1965,9 +1978,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
return;
|
||||
}
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManCloseShellCallbackReceived,
|
||||
PSOpcode.Disconnect, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
sessionTM.RunspacePoolInstanceId.ToString());
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCloseShellCallbackReceived,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
sessionTM.RunspacePoolInstanceId.ToString(),
|
||||
"OnCloseSessionCompleted");
|
||||
|
||||
if (IntPtr.Zero != error)
|
||||
{
|
||||
@@ -2013,6 +2030,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
}
|
||||
|
||||
// LOG ETW EVENTS
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCloseShellCallbackReceived,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
sessionTM.RunspacePoolInstanceId.ToString(),
|
||||
"OnRemoteSessionDisconnectCompleted");
|
||||
|
||||
// Dispose the OnDisconnect callback as it is not needed anymore
|
||||
if (sessionTM._disconnectSessionCompleted != null)
|
||||
@@ -2055,7 +2079,14 @@ namespace System.Management.Automation.Remoting.Client
|
||||
sessionTM.EnqueueAndStartProcessingThread(null, null,
|
||||
new CompletionEventArgs(CompletionNotification.DisconnectCompleted));
|
||||
|
||||
// Log ETW traces
|
||||
// Log ETW traces
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCloseShellCallbackReceived,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
sessionTM.RunspacePoolInstanceId.ToString(),
|
||||
"OnRemoteSessionReconnectCompleted: DisconnectCompleted");
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -2081,6 +2112,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
}
|
||||
|
||||
// Add ETW events
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCloseShellCallbackReceived,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
sessionTM.RunspacePoolInstanceId.ToString(),
|
||||
"OnRemoteSessionReconnectCompleted");
|
||||
|
||||
// Dispose the OnCreate callback as it is not needed anymore
|
||||
if (sessionTM._reconnectSessionCompleted != null)
|
||||
@@ -2176,6 +2214,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
{
|
||||
tracer.WriteLine("Client Session TM: Connect callback received");
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManSendShellInputExCallbackReceived,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
"OnRemoteSessionConnectCallback:Client Session TM: Connect callback received");
|
||||
|
||||
long sessionTMHandle = 0;
|
||||
WSManClientSessionTransportManager sessionTM = null;
|
||||
if (!TryGetSessionTransportManager(operationContext, out sessionTM, out sessionTMHandle))
|
||||
@@ -2269,9 +2314,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
}
|
||||
|
||||
// do the logging for this send
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManSendShellInputExCallbackReceived,
|
||||
PSOpcode.Connect, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
sessionTM.RunspacePoolInstanceId.ToString(), Guid.Empty.ToString());
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManSendShellInputExCallbackReceived,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
sessionTM.RunspacePoolInstanceId.ToString(),
|
||||
Guid.Empty.ToString());
|
||||
|
||||
if (!shellOperationHandle.Equals(sessionTM._wsManShellOperationHandle))
|
||||
{
|
||||
@@ -2981,9 +3030,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
_cmdContextId = GetNextCmdTMHandleId();
|
||||
AddCmdTransportManager(_cmdContextId, this);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManCreateCommand, PSOpcode.Connect,
|
||||
PSTask.CreateRunspace, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString(), powershellInstanceId.ToString());
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateCommand,
|
||||
PSOpcode.Connect,
|
||||
PSTask.CreateRunspace,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString(),
|
||||
powershellInstanceId.ToString());
|
||||
|
||||
_createCmdCompleted = new WSManNativeApi.WSManShellAsync(new IntPtr(_cmdContextId), s_cmdCreateCallback);
|
||||
_createCmdCompletedGCHandle = GCHandle.Alloc(_createCmdCompleted);
|
||||
@@ -3061,9 +3114,14 @@ namespace System.Management.Automation.Remoting.Client
|
||||
_isStopSignalPending = false;
|
||||
|
||||
tracer.WriteLine("Sending stop signal with command context: {0} Operation Context {1}", _cmdContextId, _wsManCmdOperationHandle);
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManSignal,
|
||||
PSOpcode.Disconnect, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString(), powershellInstanceId.ToString(), StopSignal);
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManSignal,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString(),
|
||||
powershellInstanceId.ToString(),
|
||||
StopSignal);
|
||||
|
||||
_signalCmdCompleted = new WSManNativeApi.WSManShellAsync(new IntPtr(_cmdContextId), s_cmdSignalCallback);
|
||||
WSManNativeApi.WSManSignalShellEx(_wsManShellOperationHandle, _wsManCmdOperationHandle, 0,
|
||||
@@ -3115,9 +3173,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
return;
|
||||
}
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManCloseCommand,
|
||||
PSOpcode.Disconnect, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString(), powershellInstanceId.ToString());
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCloseCommand,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString(),
|
||||
powershellInstanceId.ToString());
|
||||
_closeCmdCompleted = new WSManNativeApi.WSManShellAsync(new IntPtr(_cmdContextId), s_cmdCloseCallback);
|
||||
Dbg.Assert((IntPtr)_closeCmdCompleted != IntPtr.Zero, "closeCmdCompleted callback is null in cmdTM.CloseAsync()");
|
||||
WSManNativeApi.WSManCloseCommand(_wsManCmdOperationHandle, 0, _closeCmdCompleted);
|
||||
@@ -3292,9 +3354,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
return;
|
||||
}
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManCreateCommandCallbackReceived,
|
||||
PSOpcode.Connect, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
cmdTM.RunspacePoolInstanceId.ToString(), cmdTM.powershellInstanceId.ToString());
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateCommandCallbackReceived,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
cmdTM.RunspacePoolInstanceId.ToString(),
|
||||
cmdTM.powershellInstanceId.ToString());
|
||||
|
||||
// dispose the cmdCompleted callback as it is not needed any more
|
||||
if (cmdTM._createCmdCompleted != null)
|
||||
@@ -3384,6 +3450,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
{
|
||||
tracer.WriteLine("OnConnectCmdCompleted callback received");
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCreateCommandCallbackReceived,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
"OnConnectCmdCompleted: OnConnectCmdCompleted callback received");
|
||||
|
||||
long cmdContextId = 0;
|
||||
WSManClientCommandTransportManager cmdTM = null;
|
||||
if (!TryGetCmdTransportManager(operationContext, out cmdTM, out cmdContextId))
|
||||
@@ -3473,6 +3546,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
{
|
||||
tracer.WriteLine("OnCloseCmdCompleted callback received for operation context {0}", commandOperationHandle);
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCloseCommandCallbackReceived,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
"OnCloseCmdCompleted: OnCloseCmdCompleted callback received");
|
||||
|
||||
long cmdContextId = 0;
|
||||
WSManClientCommandTransportManager cmdTM = null;
|
||||
if (!TryGetCmdTransportManager(operationContext, out cmdTM, out cmdContextId))
|
||||
@@ -3483,9 +3563,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
}
|
||||
|
||||
tracer.WriteLine("Close completed callback received for command: {0}", cmdTM._cmdContextId);
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManCloseCommandCallbackReceived,
|
||||
PSOpcode.Disconnect, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
cmdTM.RunspacePoolInstanceId.ToString(), cmdTM.powershellInstanceId.ToString());
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManCloseCommandCallbackReceived,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
cmdTM.RunspacePoolInstanceId.ToString(),
|
||||
cmdTM.powershellInstanceId.ToString());
|
||||
|
||||
if (cmdTM._isDisconnectPending)
|
||||
{
|
||||
@@ -3505,6 +3589,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
{
|
||||
tracer.WriteLine("SendComplete callback received");
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManSendShellInputExCallbackReceived,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
"OnRemoteCmdSendCompleted: SendComplete callback received");
|
||||
|
||||
long cmdContextId = 0;
|
||||
WSManClientCommandTransportManager cmdTM = null;
|
||||
if (!TryGetCmdTransportManager(operationContext, out cmdTM, out cmdContextId))
|
||||
@@ -3517,9 +3608,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
cmdTM._isSendingInput = false;
|
||||
|
||||
// do the logging for this send
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManSendShellInputExCallbackReceived,
|
||||
PSOpcode.Connect, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
cmdTM.RunspacePoolInstanceId.ToString(), cmdTM.powershellInstanceId.ToString());
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManSendShellInputExCallbackReceived,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
cmdTM.RunspacePoolInstanceId.ToString(),
|
||||
cmdTM.powershellInstanceId.ToString());
|
||||
|
||||
if ((!shellOperationHandle.Equals(cmdTM._wsManShellOperationHandle)) ||
|
||||
(!commandOperationHandle.Equals(cmdTM._wsManCmdOperationHandle)))
|
||||
@@ -3588,6 +3683,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
{
|
||||
tracer.WriteLine("Remote Command DataReceived callback.");
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManReceiveShellOutputExCallbackReceived,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
"OnRemoteCmdDataReceived: Remote Command DataReceived callback");
|
||||
|
||||
long cmdContextId = 0;
|
||||
WSManClientCommandTransportManager cmdTM = null;
|
||||
if (!TryGetCmdTransportManager(operationContext, out cmdTM, out cmdContextId))
|
||||
@@ -3672,6 +3774,14 @@ namespace System.Management.Automation.Remoting.Client
|
||||
{
|
||||
long cmdContextId = 0;
|
||||
WSManClientCommandTransportManager cmdTM = null;
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManReceiveShellOutputExCallbackReceived,
|
||||
PSOpcode.Connect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
"OnReconnectCmdCompleted");
|
||||
|
||||
if (!TryGetCmdTransportManager(operationContext, out cmdTM, out cmdContextId))
|
||||
{
|
||||
// We dont have the command TM handle..just return.
|
||||
@@ -3731,6 +3841,8 @@ namespace System.Management.Automation.Remoting.Client
|
||||
{
|
||||
tracer.WriteLine("Signal Completed callback received.");
|
||||
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManSignalCallbackReceived, PSOpcode.Disconnect, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic, "OnRemoteCmdSignalCompleted");
|
||||
|
||||
long cmdContextId = 0;
|
||||
WSManClientCommandTransportManager cmdTM = null;
|
||||
if (!TryGetCmdTransportManager(operationContext, out cmdTM, out cmdContextId))
|
||||
@@ -3741,9 +3853,13 @@ namespace System.Management.Automation.Remoting.Client
|
||||
}
|
||||
|
||||
// log the callback received event.
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManSignalCallbackReceived,
|
||||
PSOpcode.Disconnect, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
cmdTM.RunspacePoolInstanceId.ToString(), cmdTM.powershellInstanceId.ToString());
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManSignalCallbackReceived,
|
||||
PSOpcode.Disconnect,
|
||||
PSTask.None,
|
||||
PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
cmdTM.RunspacePoolInstanceId.ToString(),
|
||||
cmdTM.powershellInstanceId.ToString());
|
||||
|
||||
if ((!shellOperationHandle.Equals(cmdTM._wsManShellOperationHandle)) ||
|
||||
(!commandOperationHandle.Equals(cmdTM._wsManCmdOperationHandle)))
|
||||
@@ -3920,9 +4036,11 @@ namespace System.Management.Automation.Remoting.Client
|
||||
|
||||
internal override void StartReceivingData()
|
||||
{
|
||||
PSEtwLog.LogAnalyticInformational(PSEventId.WSManReceiveShellOutputEx,
|
||||
PSOpcode.Receive, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString(), powershellInstanceId.ToString());
|
||||
PSEtwLog.LogAnalyticInformational(
|
||||
PSEventId.WSManReceiveShellOutputEx,
|
||||
PSOpcode.Receive, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic,
|
||||
RunspacePoolInstanceId.ToString(), powershellInstanceId.ToString());
|
||||
|
||||
// We should call Receive only once.. WSMan will call the callback multiple times.
|
||||
_shouldStartReceivingData = false;
|
||||
lock (syncObject)
|
||||
|
||||
Reference in New Issue
Block a user