EventLogMsgs.mc - Building a resource file (DLL)

1.2k views Asked by At

Currently I have a resource file that I use for my custom created event log. Everything seems to work perfectly when I write an event to the log with intentions of informational/success purposes. But when I write one of an Error intent I get...

The description for Event ID 301 from source X cannot be found...

I was wondering... Does it have to do with the fact that all my categories are Severity=Success? Do I also need a category for Service that has Severity=Error?


Example of successful log entry:

Event ID: 101, Level: Information, Task Category: (8) Service

Example of NON successful log entry:

Event ID: 301, Level: Error, Task Category: (8) Service


The following is my current text message file that I convert into a resource file for categories, and messages...

; // EventLogMsgs.mc
; // ********************************************************
; // Use the following commands to build this file:
; //   mc -s EventLogMsgs.mc
; //   rc EventLogMsgs.rc
; //   link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res 

; // ********************************************************
; // - Event categories -
; // Categories must be numbered consecutively starting at 1.
; // ********************************************************

MessageId=0x1
Severity=Success
SymbolicName=GENERAL_CATEGORY
Language=English
General
.

MessageId=0x2
Severity=Success
SymbolicName=DATABASE_CATEGORY
Language=English
Database Query
.

MessageId=0x3
Severity=Success
SymbolicName=LOGON_CATEGORY
Language=English
Logon
.

MessageId=0x4
Severity=Success
SymbolicName=LOGOFF_CATEGORY
Language=English
Logoff
.

MessageId=0x5
Severity=Success
SymbolicName=EMAIL_CATEGORY
Language=English
Email
.

MessageId=0x6
Severity=Success
SymbolicName=PRINTER_CATEGORY
Language=English
Printer
.

MessageId=0x7
Severity=Success
SymbolicName=IO_CATEGORY
Language=English
IO
.

MessageId=0x8
Severity=Success
SymbolicName=SERVICE_CATEGORY
Language=English
Service
.

MessageId=0x9
Severity=Success
SymbolicName=DEBUG_CATEGORY
Language=English
Debug
.

; // - Event messages -
; // *********************************

MessageId = 100
Severity = Success
Facility = Application
SymbolicName = SMESSAGE_ID100
Language=English
%1
.

MessageId = 101
Severity = Success
Facility = Application
SymbolicName = SMESSAGE_ID101
Language=English
%1
.

MessageId = 102
Severity = Success
Facility = Application
SymbolicName = SMESSAGE_ID102
Language=English
%1
.

MessageId = 103
Severity = Success
Facility = Application
SymbolicName = SMESSAGE_ID103
Language=English
%1
.

MessageId = 104
Severity = Success
Facility = Application
SymbolicName = SMESSAGE_ID104
Language=English
%1
.

MessageId = 105
Severity = Success
Facility = Application
SymbolicName = SMESSAGE_ID105
Language=English
%1
.

MessageId = 200
Severity = Warning
Facility = Application
SymbolicName = WMESSAGE_ID200
Language=English
%1
.

MessageId = 201
Severity = Warning
Facility = Application
SymbolicName = WMESSAGE_ID201
Language=English
%1
.

MessageId = 202
Severity = Warning
Facility = Application
SymbolicName = WMESSAGE_ID202
Language=English
%1
.

MessageId = 203
Severity = Warning
Facility = Application
SymbolicName = WMESSAGE_ID203
Language=English
%1
.

MessageId = 204
Severity = Warning
Facility = Application
SymbolicName = WMESSAGE_ID204
Language=English
%1
.

MessageId = 205
Severity = Warning
Facility = Application
SymbolicName = WMESSAGE_ID205
Language=English
%1
.

MessageId = 300
Severity = Error
Facility = Application
SymbolicName = EMESSAGE_ID300
Language=English
%1
.

MessageId = 301
Severity = Error
Facility = Application
SymbolicName = EMESSAGE_ID301
Language=English
%1
.

MessageId = 302
Severity = Error
Facility = Application
SymbolicName = EMESSAGE_ID302
Language=English
%1
.

MessageId = 303
Severity = Error
Facility = Application
SymbolicName = EMESSAGE_ID303
Language=English
%1
.

MessageId = 304
Severity = Error
Facility = Application
SymbolicName = EMESSAGE_ID304
Language=English
%1
.

MessageId = 305
Severity = Error
Facility = Application
SymbolicName = EMESSAGE_ID305
Language=English
%1
.
1

There are 1 answers

0
Arvo Bowen On BEST ANSWER

Actual Problem: I was creating the file wrong and the event numbers I thought I was creating we infact different number. I found out what was going on after digging into the myfile.c file produced when running the mc.exe and rc.exe commands. When looking at that file I realized that the DWORD values (HEX) did not add up to the integer I expected.

My Issue: The bottom line was my issue was simply because I used "Severity = Warning" on #200 rather than "Severity = Success". When I changed that I finally got the event numbers I was looking for being created. There were a few other enhancements I made to my file (as seen below) but that was the main reason I had my issue.

Corrected Eventlog Message File: Below, you will find my correct eventlog message file. I also decided to break it up into two files keeping the Categories and Events separate. (You don't have to)

categories.mc

; // EventLogMsgs.mc
; // ********************************************************
; // Use the following commands to build this file:
; //   mc -s EventLogMsgs.mc
; //   rc EventLogMsgs.rc
; //   link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res 

; // ********************************************************
; // - Event categories -
; // Categories must be numbered consecutively starting at 1.
; // ********************************************************

MessageIdTypedef = WORD

LanguageNames = (English=0x409:MSG00409)

MessageId = 0x1
SymbolicName=GENERAL_CATEGORY
Language=English
General
.

MessageId = 0x2
SymbolicName=DATABASE_CATEGORY
Language=English
Database
.

MessageId = 0x3
SymbolicName=LOGON_CATEGORY
Language=English
Logon
.

MessageId = 0x4
SymbolicName=LOGOFF_CATEGORY
Language=English
Logoff
.

MessageId = 0x5
SymbolicName=EMAIL_CATEGORY
Language=English
Email
.

MessageId = 0x6
SymbolicName=PRINTER_CATEGORY
Language=English
Printer
.

MessageId = 0x7
SymbolicName=IO_CATEGORY
Language=English
IO
.

MessageId = 0x8
SymbolicName=SERVICE_CATEGORY
Language=English
Service
.

MessageId = 0x9
SymbolicName=DEBUG_CATEGORY
Language=English
Debug
.

events.mc

; // EventLogMsgs.mc
; // ********************************************************
; // Use the following commands to build this file:
; //   mc -s EventLogMsgs.mc
; //   rc EventLogMsgs.rc
; //   link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res 

; // ********************************************************
; // - Event categories -
; // Categories must be numbered consecutively starting at 1.
; // ********************************************************

; // - Event messages -
; // *********************************

MessageIdTypedef = DWORD

LanguageNames = (English=0x409:MSG00409)

MessageId = 100
SymbolicName = SMESSAGE_ID100
Language=English
%1
.

MessageId = 101
SymbolicName = SMESSAGE_ID101
Language=English
%1
.

MessageId = 102
SymbolicName = SMESSAGE_ID102
Language=English
%1
.

MessageId = 103
SymbolicName = SMESSAGE_ID103
Language=English
%1
.

MessageId = 104
SymbolicName = SMESSAGE_ID104
Language=English
%1
.

MessageId = 105
SymbolicName = SMESSAGE_ID105
Language=English
%1
.

MessageId = 200
SymbolicName = WMESSAGE_ID200
Language=English
%1
.

MessageId = 201
SymbolicName = WMESSAGE_ID201
Language=English
%1
.

MessageId = 202
SymbolicName = WMESSAGE_ID202
Language=English
%1
.

MessageId = 203
SymbolicName = WMESSAGE_ID203
Language=English
%1
.

MessageId = 204
SymbolicName = WMESSAGE_ID204
Language=English
%1
.

MessageId = 205
SymbolicName = WMESSAGE_ID205
Language=English
%1
.

MessageId = 300
SymbolicName = EMESSAGE_ID300
Language=English
%1
.

MessageId = 301
SymbolicName = EMESSAGE_ID301
Language=English
%1
.

MessageId = 302
SymbolicName = EMESSAGE_ID302
Language=English
%1
.

MessageId = 303
SymbolicName = EMESSAGE_ID303
Language=English
%1
.

MessageId = 304
SymbolicName = EMESSAGE_ID304
Language=English
%1
.

MessageId = 305
SymbolicName = EMESSAGE_ID305
Language=English
%1
.