internal EventLogRecord(EventLogHandle handle, EventLogSession session, ProviderMetadataCachedInformation cachedMetadataInfo) {
     this.cachedMetadataInformation = cachedMetadataInfo;
     this.handle = handle;
     this.session = session;
     systemProperties = new NativeWrapper.SystemProperties();
     syncObject = new object();
 }
        public EventLogWatcher(EventLogQuery eventQuery, EventBookmark bookmark, bool readExistingEvents)
        {
            if (eventQuery == null)
            {
                throw new ArgumentNullException(nameof(eventQuery));
            }

            if (bookmark != null)
            {
                readExistingEvents = false;
            }

            // Explicit data
            _eventQuery         = eventQuery;
            _readExistingEvents = readExistingEvents;

            if (_eventQuery.ReverseDirection)
            {
                throw new InvalidOperationException();
            }

            _eventsBuffer             = new IntPtr[64];
            cachedMetadataInformation = new ProviderMetadataCachedInformation(eventQuery.Session, null, 50);
            _bookmark = bookmark;
        }
Example #3
0
 internal EventLogRecord(EventLogHandle handle, EventLogSession session, ProviderMetadataCachedInformation cachedMetadataInfo)
 {
     _cachedMetadataInformation = cachedMetadataInfo;
     Handle            = handle;
     _session          = session;
     _systemProperties = new NativeWrapper.SystemProperties();
     _syncObject       = new object();
 }
Example #4
0
        public EventLogReader(EventLogQuery eventQuery, EventBookmark bookmark)
        {
            ArgumentNullException.ThrowIfNull(eventQuery);

            string logfile = null;

            if (eventQuery.ThePathType == PathType.FilePath)
            {
                logfile = eventQuery.Path;
            }

            _cachedMetadataInformation = new ProviderMetadataCachedInformation(eventQuery.Session, logfile, 50);

            // Explicit data
            _eventQuery = eventQuery;

            // Implicit
            _batchSize    = 64;
            _eventsBuffer = new IntPtr[_batchSize];

            //
            // compute the flag.
            //
            int flag = 0;

            if (_eventQuery.ThePathType == PathType.LogName)
            {
                flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryChannelPath;
            }
            else
            {
                flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryFilePath;
            }

            if (_eventQuery.ReverseDirection)
            {
                flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryReverseDirection;
            }

            if (_eventQuery.TolerateQueryErrors)
            {
                flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryTolerateQueryErrors;
            }

            _handle = NativeWrapper.EvtQuery(_eventQuery.Session.Handle,
                                             _eventQuery.Path, _eventQuery.Query,
                                             flag);

            EventLogHandle bookmarkHandle = EventLogRecord.GetBookmarkHandleFromBookmark(bookmark);

            if (!bookmarkHandle.IsInvalid)
            {
                using (bookmarkHandle)
                {
                    NativeWrapper.EvtSeek(_handle, 1, bookmarkHandle, 0, UnsafeNativeMethods.EvtSeekFlags.EvtSeekRelativeToBookmark);
                }
            }
        }
Example #5
0
        public EventLogReader(EventLogQuery eventQuery, EventBookmark bookmark)
        {
            if (eventQuery == null)
                throw new ArgumentNullException("eventQuery");

            string logfile = null;
            if (eventQuery.ThePathType == PathType.FilePath)
                logfile = eventQuery.Path;

            _cachedMetadataInformation = new ProviderMetadataCachedInformation(eventQuery.Session, logfile, 50);

            //explicit data
            _eventQuery = eventQuery;

            //implicit
            _batchSize = 64;
            _eventsBuffer = new IntPtr[_batchSize];

            //
            // compute the flag.
            //
            int flag = 0;

            if (_eventQuery.ThePathType == PathType.LogName)
                flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryChannelPath;
            else
                flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryFilePath;

            if (_eventQuery.ReverseDirection)
                flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryReverseDirection;

            if (_eventQuery.TolerateQueryErrors)
                flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryTolerateQueryErrors;

            _handle = NativeWrapper.EvtQuery(_eventQuery.Session.Handle,
                _eventQuery.Path, _eventQuery.Query,
                flag);

            EventLogHandle bookmarkHandle = EventLogRecord.GetBookmarkHandleFromBookmark(bookmark);

            if (!bookmarkHandle.IsInvalid)
            {
                using (bookmarkHandle)
                {
                    NativeWrapper.EvtSeek(_handle, 1, bookmarkHandle, 0, UnsafeNativeMethods.EvtSeekFlags.EvtSeekRelativeToBookmark);
                }
            }
        }
        public EventLogReader(EventLogQuery eventQuery, EventBookmark bookmark)
        {
            if (eventQuery == null)
            {
                throw new ArgumentNullException("eventQuery");
            }
            string logfile = null;

            if (eventQuery.ThePathType == PathType.FilePath)
            {
                logfile = eventQuery.Path;
            }
            this.cachedMetadataInformation = new ProviderMetadataCachedInformation(eventQuery.Session, logfile, 50);
            this.eventQuery   = eventQuery;
            this.batchSize    = 0x40;
            this.eventsBuffer = new IntPtr[this.batchSize];
            int flags = 0;

            if (this.eventQuery.ThePathType == PathType.LogName)
            {
                flags |= 1;
            }
            else
            {
                flags |= 2;
            }
            if (this.eventQuery.ReverseDirection)
            {
                flags |= 0x200;
            }
            if (this.eventQuery.TolerateQueryErrors)
            {
                flags |= 0x1000;
            }
            EventLogPermissionHolder.GetEventLogPermission().Demand();
            this.handle = NativeWrapper.EvtQuery(this.eventQuery.Session.Handle, this.eventQuery.Path, this.eventQuery.Query, flags);
            EventLogHandle bookmarkHandleFromBookmark = EventLogRecord.GetBookmarkHandleFromBookmark(bookmark);

            if (!bookmarkHandleFromBookmark.IsInvalid)
            {
                using (bookmarkHandleFromBookmark)
                {
                    NativeWrapper.EvtSeek(this.handle, 1L, bookmarkHandleFromBookmark, 0, Microsoft.Win32.UnsafeNativeMethods.EvtSeekFlags.EvtSeekRelativeToBookmark);
                }
            }
        }
        public EventLogWatcher(EventLogQuery eventQuery, EventBookmark bookmark, bool readExistingEvents) {

            if (eventQuery == null)
                throw new ArgumentNullException("eventQuery");

            if (bookmark != null)
                readExistingEvents = false;

            //explicit data
            this.eventQuery = eventQuery;
            this.readExistingEvents = readExistingEvents;

            if (this.eventQuery.ReverseDirection)
                throw new InvalidOperationException();

            this.eventsBuffer = new IntPtr[64];
            this.cachedMetadataInformation = new ProviderMetadataCachedInformation(eventQuery.Session, null, 50);
            this.bookmark = bookmark;
        }
Example #8
0
 public EventLogReader(EventLogQuery eventQuery, EventBookmark bookmark)
 {
     if (eventQuery == null)
     {
         throw new ArgumentNullException("eventQuery");
     }
     string logfile = null;
     if (eventQuery.ThePathType == PathType.FilePath)
     {
         logfile = eventQuery.Path;
     }
     this.cachedMetadataInformation = new ProviderMetadataCachedInformation(eventQuery.Session, logfile, 50);
     this.eventQuery = eventQuery;
     this.batchSize = 0x40;
     this.eventsBuffer = new IntPtr[this.batchSize];
     int flags = 0;
     if (this.eventQuery.ThePathType == PathType.LogName)
     {
         flags |= 1;
     }
     else
     {
         flags |= 2;
     }
     if (this.eventQuery.ReverseDirection)
     {
         flags |= 0x200;
     }
     if (this.eventQuery.TolerateQueryErrors)
     {
         flags |= 0x1000;
     }
     EventLogPermissionHolder.GetEventLogPermission().Demand();
     this.handle = NativeWrapper.EvtQuery(this.eventQuery.Session.Handle, this.eventQuery.Path, this.eventQuery.Query, flags);
     EventLogHandle bookmarkHandleFromBookmark = EventLogRecord.GetBookmarkHandleFromBookmark(bookmark);
     if (!bookmarkHandleFromBookmark.IsInvalid)
     {
         using (bookmarkHandleFromBookmark)
         {
             NativeWrapper.EvtSeek(this.handle, 1L, bookmarkHandleFromBookmark, 0, Microsoft.Win32.UnsafeNativeMethods.EvtSeekFlags.EvtSeekRelativeToBookmark);
         }
     }
 }
Example #9
0
 public EventLogWatcher(EventLogQuery eventQuery, EventBookmark bookmark, bool readExistingEvents)
 {
     if (eventQuery == null)
     {
         throw new ArgumentNullException("eventQuery");
     }
     if (bookmark != null)
     {
         readExistingEvents = false;
     }
     this.eventQuery         = eventQuery;
     this.readExistingEvents = readExistingEvents;
     if (this.eventQuery.ReverseDirection)
     {
         throw new InvalidOperationException();
     }
     this.eventsBuffer = new IntPtr[0x40];
     this.cachedMetadataInformation = new ProviderMetadataCachedInformation(eventQuery.Session, null, 50);
     this.bookmark = bookmark;
 }
Example #10
0
        public EventLogReader(EventLogQuery eventQuery, EventBookmark bookmark)
        {
            if (eventQuery == null)
            {
                throw new ArgumentNullException("eventQuery");
            }

            string logfile = null;

            if (eventQuery.ThePathType == PathType.FilePath)
            {
                logfile = eventQuery.Path;
            }

            this.cachedMetadataInformation = new ProviderMetadataCachedInformation(eventQuery.Session, logfile, 50);

            //explicit data
            this.eventQuery = eventQuery;

            //implicit
            this.batchSize    = 64;
            this.eventsBuffer = new IntPtr[batchSize];

            //
            // compute the flag.
            //
            int flag = 0;

            if (this.eventQuery.ThePathType == PathType.LogName)
            {
                flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryChannelPath;
            }
            else
            {
                flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryFilePath;
            }

            if (this.eventQuery.ReverseDirection)
            {
                flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryReverseDirection;
            }

            if (this.eventQuery.TolerateQueryErrors)
            {
                flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryTolerateQueryErrors;
            }

            EventLogPermissionHolder.GetEventLogPermission().Demand();

            handle = NativeWrapper.EvtQuery(this.eventQuery.Session.Handle,
                                            this.eventQuery.Path, this.eventQuery.Query,
                                            flag);

            EventLogHandle bookmarkHandle = EventLogRecord.GetBookmarkHandleFromBookmark(bookmark);

            if (!bookmarkHandle.IsInvalid)
            {
                using (bookmarkHandle) {
                    NativeWrapper.EvtSeek(handle, 1, bookmarkHandle, 0, UnsafeNativeMethods.EvtSeekFlags.EvtSeekRelativeToBookmark);
                }
            }
        }
 internal EventLogRecord(EventLogHandle handle, EventLogSession session, ProviderMetadataCachedInformation cachedMetadataInfo)
     : base(handle, session, cachedMetadataInfo)
 {
 }