Пример #1
0
        public void it_should_set_properties()
        {
            var  TEST_TRACE_NAME           = "krabs C++/CLI properties test";
            uint EVENT_TRACE_CONTROL_QUERY = 0;
            uint ERROR_SUCCESS             = 0;

            var trace      = new UserTrace(TEST_TRACE_NAME);
            var properties = new EventTraceProperties
            {
                BufferSize     = 1024,
                MinimumBuffers = (uint)Environment.ProcessorCount * 2 + 1,
                MaximumBuffers = (uint)Environment.ProcessorCount * 2 + 2,
                FlushTimer     = 2,
                LogFileMode    = (uint)LogFileModeFlags.FLAG_EVENT_TRACE_REAL_TIME_MODE
            };

            trace.SetTraceProperties(properties);
            trace.Open();

            var info = new TraceInfo
            {
                Wnode_BufferSize = 200,
                LoggerNameOffset = 120
            };
            var status = ControlTraceW(0, TEST_TRACE_NAME, ref info, EVENT_TRACE_CONTROL_QUERY);

            Assert.IsTrue(status == ERROR_SUCCESS);

            Assert.IsTrue(properties.BufferSize == info.BufferSize);
            Assert.IsTrue(properties.MinimumBuffers == info.MinimumBuffers);
            Assert.IsTrue(properties.MaximumBuffers == info.MaximumBuffers);
            Assert.IsTrue(properties.FlushTimer == info.FlushTimer);
            Assert.IsTrue((uint)LogFileModeFlags.FLAG_EVENT_TRACE_REAL_TIME_MODE == (info.LogFileMode & (uint)LogFileModeFlags.FLAG_EVENT_TRACE_REAL_TIME_MODE));
            Assert.IsTrue((uint)LogFileModeFlags.FLAG_EVENT_TRACE_NO_PER_PROCESSOR_BUFFERING != (info.LogFileMode & (uint)LogFileModeFlags.FLAG_EVENT_TRACE_NO_PER_PROCESSOR_BUFFERING));
        }
            protected override bool ReleaseHandle()
            {
                var properties = new EventTraceProperties(true /*initialize*/);

                return(NativeMethods.StopTrace(this.sessionHandle, this.loggerName, out properties /*as statistics*/)
                       != 0);
            }
Пример #3
0
 public static uint FlushTraceLogger(string sessionName, string sessionGuid, out string logfileName)
 {
     EventTraceProperties properties = new EventTraceProperties();
     properties.Wnode.BufferSize = (uint)Marshal.SizeOf(properties);
     properties.Wnode.Guid = new Guid(sessionGuid);
     properties.LoggerNameOffset = (uint)Marshal.OffsetOf(typeof(EventTraceProperties), "LoggerName");
     properties.LogFileNameOffset = (uint)Marshal.OffsetOf(typeof(EventTraceProperties), "LogFileName");
     uint result = ControlTrace(0, sessionName, ref properties, EVENT_TRACE_CONTROL_FLUSH);
     logfileName = properties.LogFileName;
     return result;
 }
Пример #4
0
        private bool LoadExistingEventTraceProperties()
        {
            const int ERROR_WMI_INSTANCE_NOT_FOUND = 4201;

            this.eventTraceProperties = new EventTraceProperties(true);
            int status = NativeMethods.QueryTrace(0, this.loggerName, ref this.eventTraceProperties);

            if (status == 0)
            {
                return(true);
            }
            else if (status == ERROR_WMI_INSTANCE_NOT_FOUND)
            {
                // The instance name passed was not recognized as valid by a WMI data provider.
                return(false);
            }
            throw new System.ComponentModel.Win32Exception(status);
        }
        /// <summary>
        /// The load existing event trace properties.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        /// <exception cref="Win32Exception">
        /// </exception>
        private bool LoadExistingEventTraceProperties()
        {
            const int ErrorWmiInstanceNotFound = 4201;

            this.eventTraceProperties = new EventTraceProperties(true);
            var status = NativeMethods.QueryTrace(0, this.loggerName, ref this.eventTraceProperties);

            if (status == 0)
            {
                return(true);
            }

            if (status == ErrorWmiInstanceNotFound)
            {
                // The instance name passed was not recognized as valid by a WMI data provider.
                return(false);
            }

            throw new Win32Exception(status);
        }
Пример #6
0
 private static extern uint ControlTrace(
     [In] ulong sessionHandle,
     [In] string sessionName,
     [In, Out] ref EventTraceProperties properties,
     [In] uint controlCode);
Пример #7
0
 public static extern uint FlushTrace(
     [In] Int64 sessionHandle,
     [In] string sessionName,
     [In, Out] ref EventTraceProperties properties);
Пример #8
0
 public static extern uint StopTrace(
     [In] Int64 sessionHandle,
     [In] string sessionName,
     [Out] out EventTraceProperties properties);
Пример #9
0
 public static extern uint StartTrace(
     [Out] out Int64 sessionHandle,
     [In] string sessionName,
     [In, Out] ref EventTraceProperties properties);
Пример #10
0
 public static extern uint StopTrace([In] ulong traceHandle, [In] string sessionName,
                                     [In, Out] ref EventTraceProperties properties);
Пример #11
0
 public static extern uint StartTrace([Out] out ulong traceHandle, [In] string sessionName,
                                      [In] ref EventTraceProperties properties);
Пример #12
0
 public static extern uint QueryTrace([In] ulong traceHandle, [In] string sessionName,
                                      ref EventTraceProperties properties);