4kux / winsvc

Automatically exported from code.google.com/p/winsvc
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Event ID limit too strict #1

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The eventlog package only accepts event IDs between 1 and 100. This is too 
narrow when not using the EventCreate executable, because the base ID in any 
message file is ORed with the severity and facility numbers to make the final 
ID used with ReportEvent. See, for instance, Microsoft's example here:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa363680(v=vs.85).aspx

Their message file defines MSG_INVALID_COMMAND with Id 0x100, but the Id passed 
to ReportEvent (as seen in the header file) is 0xC0020100.

I suggest just deleting the check in (*Log).report as follows:

diff -r 187091ca1db6 eventlog/log.go
--- a/eventlog/log.go   Sat Jul 21 20:41:30 2012 +1000
+++ b/eventlog/log.go   Wed Oct 02 13:41:25 2013 -0700
@@ -44,10 +44,6 @@
 }

 func (l *Log) report(etype uint16, eid uint32, msg string) error {
-   if eid < 1 || eid > 100 {
-       // EventCreate executable has messages for these only.
-       return errors.New("event id must be between 1 and 1000")
-   }
    ss := []*uint16{syscall.StringToUTF16Ptr(msg)}
    return winapi.ReportEvent(l.Handle, etype, 0, eid, 0, 1, 0, &ss[0], nil)
 }

Original issue reported on code.google.com by mi...@classroomsystems.com on 2 Oct 2013 at 8:58

GoogleCodeExporter commented 8 years ago
Sounds good. Here https://codereview.appspot.com/14247044/ is the change. 
Please, review it. Thank you.

Alex

Original comment by alex.bra...@gmail.com on 3 Oct 2013 at 7:29

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 19f1ceca3538.

Original comment by alex.bra...@gmail.com on 3 Oct 2013 at 11:15