win32-eventlog 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +7 -0
- data/README +2 -5
- data/install.rb +13 -0
- data/lib/win32/eventlog.rb +17 -9
- data/win32-eventlog.gemspec +24 -0
- metadata +9 -3
- data/lib/win32/test.rb +0 -8
data/CHANGES
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
= 0.4.3 - 18-Dec-2006
|
2
|
+
* Removed the FORMAT_MESSAGE_FROM_SYSTEM flag to the FormatMessage function
|
3
|
+
in the get_description private method because it could sometimes return
|
4
|
+
bogus information. Thanks go to Greg Holmes for the spot.
|
5
|
+
* Added the string_inserts member to the EventLogStruct. This contains an
|
6
|
+
array of only the raw string inserts, rather than the entire text message.
|
7
|
+
|
1
8
|
= 0.4.2 - 6-Aug-2006
|
2
9
|
* Fixed a bug in the EventLog.read method related to the
|
3
10
|
EVENTLOG_BACKWARDS_READ flag.
|
data/README
CHANGED
@@ -44,11 +44,8 @@ installed or they're not in your %PATH%. If you have MSVC++, you should have
|
|
44
44
|
them somewhere on your system.
|
45
45
|
|
46
46
|
= Known Issues
|
47
|
-
|
48
|
-
|
49
|
-
LINK : warning LNK4068: /MACHINE not specified; defaulting to X86
|
50
|
-
|
51
|
-
You may ignore this warning.
|
47
|
+
The code currently only checks the EventMessage file, it does not check the
|
48
|
+
CategoryMessage or ParameterMessage files.
|
52
49
|
|
53
50
|
= License
|
54
51
|
Ruby's
|
data/install.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# For those who don't like gems...
|
2
|
+
require 'rbconfig'
|
3
|
+
require 'ftools'
|
4
|
+
include Config
|
5
|
+
|
6
|
+
sitelibdir = CONFIG['sitelibdir']
|
7
|
+
installdir = sitelibdir + '/win32'
|
8
|
+
file1 = 'lib\win32\eventlog.rb'
|
9
|
+
file2 = 'lib\win32\mc.rb'
|
10
|
+
|
11
|
+
Dir.mkdir(installdir) unless File.exists?(installdir)
|
12
|
+
File.copy(file1, installdir, true)
|
13
|
+
File.copy(file2, installdir, true)
|
data/lib/win32/eventlog.rb
CHANGED
@@ -29,7 +29,7 @@ module Win32
|
|
29
29
|
extend Windows::Error
|
30
30
|
extend Windows::Registry
|
31
31
|
|
32
|
-
VERSION = '0.4.
|
32
|
+
VERSION = '0.4.3'
|
33
33
|
|
34
34
|
# Aliased read flags
|
35
35
|
FORWARDS_READ = EVENTLOG_FORWARDS_READ
|
@@ -53,7 +53,7 @@ module Win32
|
|
53
53
|
|
54
54
|
EventLogStruct = Struct.new('EventLogStruct', :record_number,
|
55
55
|
:time_generated, :time_written, :event_id, :event_type, :category,
|
56
|
-
:source, :computer, :user, :description
|
56
|
+
:source, :computer, :user, :string_inserts, :description
|
57
57
|
)
|
58
58
|
|
59
59
|
# The name of the event log source. This will typically be
|
@@ -430,6 +430,10 @@ module Win32
|
|
430
430
|
# ignored. If no flags are specified, then the default flags are:
|
431
431
|
#
|
432
432
|
# EventLog::SEQUENTIAL_READ | EventLog::FORWARDS_READ
|
433
|
+
#
|
434
|
+
# Note that, if you're performing a SEEK_READ, then the offset must
|
435
|
+
# refer to a record number that actually exists. The default of 0
|
436
|
+
# may or may not work for your particular event log.
|
433
437
|
#
|
434
438
|
# The EventLogStruct struct contains the following members:
|
435
439
|
#
|
@@ -443,6 +447,7 @@ module Win32
|
|
443
447
|
# computer # String
|
444
448
|
# user # String or nil
|
445
449
|
# description # String or nil
|
450
|
+
# string_inserts # An array of Strings or nil
|
446
451
|
#
|
447
452
|
# If no block is given the method returns an array of EventLogStruct's.
|
448
453
|
#
|
@@ -473,7 +478,7 @@ module Win32
|
|
473
478
|
computer = buf[56 + event_source.length + 1..-1].nstrip
|
474
479
|
|
475
480
|
user = get_user(buf)
|
476
|
-
desc = get_description(buf, event_source)
|
481
|
+
strings, desc = get_description(buf, event_source)
|
477
482
|
|
478
483
|
struct.source = event_source
|
479
484
|
struct.computer = computer
|
@@ -484,6 +489,7 @@ module Win32
|
|
484
489
|
struct.event_type = get_event_type(buf[24,2].unpack('S').first)
|
485
490
|
struct.user = user
|
486
491
|
struct.category = buf[28,2].unpack('S').first
|
492
|
+
struct.string_inserts = strings
|
487
493
|
struct.description = desc
|
488
494
|
|
489
495
|
if block_given?
|
@@ -646,15 +652,17 @@ module Win32
|
|
646
652
|
struct
|
647
653
|
end
|
648
654
|
|
649
|
-
# Private method that gets the
|
650
|
-
# from the EVENTLOGRECORD
|
655
|
+
# Private method that gets the string inserts (Array) and the full
|
656
|
+
# event description (String) based on data from the EVENTLOGRECORD
|
657
|
+
# buffer.
|
651
658
|
#
|
652
659
|
def get_description(rec, event_source)
|
653
|
-
str = rec[
|
660
|
+
str = rec[rec[36,4].unpack('L').first .. -1]
|
654
661
|
num = rec[26,2].unpack('S').first # NumStrings
|
655
662
|
hkey = [0].pack('L')
|
656
663
|
key = BASE_KEY + "#{@source}\\#{event_source}"
|
657
664
|
buf = 0.chr * 1024
|
665
|
+
va_list = nil
|
658
666
|
|
659
667
|
if num == 0
|
660
668
|
va_list_ptr = 0.chr * 4
|
@@ -684,7 +692,6 @@ module Win32
|
|
684
692
|
if hmodule != 0
|
685
693
|
FormatMessage(
|
686
694
|
FORMAT_MESSAGE_FROM_HMODULE |
|
687
|
-
FORMAT_MESSAGE_FROM_SYSTEM |
|
688
695
|
FORMAT_MESSAGE_ARGUMENT_ARRAY,
|
689
696
|
hmodule,
|
690
697
|
event_id,
|
@@ -693,6 +700,7 @@ module Win32
|
|
693
700
|
buf.size,
|
694
701
|
va_list_ptr
|
695
702
|
)
|
703
|
+
|
696
704
|
FreeLibrary(hmodule)
|
697
705
|
end
|
698
706
|
}
|
@@ -700,7 +708,7 @@ module Win32
|
|
700
708
|
|
701
709
|
RegCloseKey(hkey)
|
702
710
|
end
|
703
|
-
buf.strip
|
711
|
+
[va_list, buf.strip]
|
704
712
|
end
|
705
713
|
|
706
714
|
# Private method that retrieves the user name based on data in the
|
@@ -751,4 +759,4 @@ module Win32
|
|
751
759
|
end
|
752
760
|
end
|
753
761
|
end
|
754
|
-
end
|
762
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
|
3
|
+
spec = Gem::Specification.new do |gem|
|
4
|
+
gem.name = "win32-eventlog"
|
5
|
+
gem.version = "0.4.3"
|
6
|
+
gem.author = "Daniel J. Berger"
|
7
|
+
gem.email = "djberg96@gmail.com"
|
8
|
+
gem.homepage = "http://www.rubyforge.org/projects/win32utils"
|
9
|
+
gem.platform = Gem::Platform::RUBY
|
10
|
+
gem.summary = "Interface for the MS Windows Event Log."
|
11
|
+
gem.description = "Interface for the MS Windows Event Log."
|
12
|
+
gem.test_file = "test/ts_all.rb"
|
13
|
+
gem.has_rdoc = true
|
14
|
+
gem.files = Dir["lib/win32/*.rb"] + Dir["test/*"] + Dir["[A-Z]*"]
|
15
|
+
gem.files.reject! { |fn| fn.include? "CVS" }
|
16
|
+
gem.require_path = "lib"
|
17
|
+
gem.extra_rdoc_files = ["README", "CHANGES", "doc/tutorial.txt"]
|
18
|
+
gem.add_dependency("windows-pr", ">= 0.5.0")
|
19
|
+
end
|
20
|
+
|
21
|
+
if $0 == __FILE__
|
22
|
+
Gem.manage_gems
|
23
|
+
Gem::Builder.new(spec).build
|
24
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: win32-eventlog
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.4.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.4.3
|
7
|
+
date: 2006-12-18 00:00:00 -07:00
|
8
8
|
summary: Interface for the MS Windows Event Log.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -31,7 +31,6 @@ authors:
|
|
31
31
|
files:
|
32
32
|
- lib/win32/eventlog.rb
|
33
33
|
- lib/win32/mc.rb
|
34
|
-
- lib/win32/test.rb
|
35
34
|
- test/CVS
|
36
35
|
- test/foo.mc
|
37
36
|
- test/tc_eventlog.rb
|
@@ -39,8 +38,15 @@ files:
|
|
39
38
|
- test/ts_all.rb
|
40
39
|
- CHANGES
|
41
40
|
- CVS
|
41
|
+
- doc
|
42
|
+
- examples
|
43
|
+
- install.rb
|
44
|
+
- lib
|
42
45
|
- MANIFEST
|
46
|
+
- misc
|
43
47
|
- README
|
48
|
+
- test
|
49
|
+
- win32-eventlog.gemspec
|
44
50
|
- doc/tutorial.txt
|
45
51
|
test_files:
|
46
52
|
- test/ts_all.rb
|