Commit 1afedd00 authored by Scott Cantor's avatar Scott Cantor
Browse files

Fixes to NTEventLogAppender and message handling.

parent fab5488b
......@@ -137,13 +137,13 @@
<CustomBuild Include="">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">if not exist $(IntDir) md $(IntDir)
mc.exe -h $(IntDir) -r $(IntDir) $(ProjectDir)%(Filename).mc</Command>
mc.exe -c -h $(IntDir) -r $(IntDir) $(ProjectDir)%(Filename).mc</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">if not exist $(IntDir) md $(IntDir)
mc.exe -h $(IntDir) -r $(IntDir) $(ProjectDir)%(Filename).mc</Command>
mc.exe -c -h $(IntDir) -r $(IntDir) $(ProjectDir)%(Filename).mc</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">if not exist $(IntDir) md $(IntDir)
mc.exe -h $(IntDir) -r $(IntDir) $(ProjectDir)%(Filename).mc</Command>
mc.exe -c -h $(IntDir) -r $(IntDir) $(ProjectDir)%(Filename).mc</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">if not exist $(IntDir) md $(IntDir)
mc.exe -h $(IntDir) -r $(IntDir) $(ProjectDir)%(Filename).mc</Command>
mc.exe -c -h $(IntDir) -r $(IntDir) $(ProjectDir)%(Filename).mc</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)%(Filename).rc</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)%(Filename).rc</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)%(Filename).rc</Outputs>
......@@ -20,7 +20,7 @@
<ResourceCompile Include="\NTEventLogCategories.rc">
<ResourceCompile Include="$(IntDir)\NTEventLogCategories.rc">
<Filter>Resource Files</Filter>
......@@ -23,7 +23,9 @@ namespace log4shib {
void NTEventLogAppender::open()
// This has to be done as Admin and should really be app-specific and
// handled as part of installation or by a deployer.
_hEventSource = ::RegisterEventSource(NULL, _strSourceName.c_str());
......@@ -52,10 +54,9 @@ namespace log4shib {
const char* ps[1];
ps[0] = event.message.c_str();
const DWORD messageID = 0x1000;
::ReportEvent(_hEventSource, getType(event.priority),
messageID, NULL, 1, 0, ps, NULL);
0x20001000L, NULL, 1, 0, ps, NULL);
......@@ -119,14 +120,15 @@ namespace log4shib {
* Add this source with appropriate configuration keys to the registry.
void NTEventLogAppender::addRegistryInfo(const char *source) {
const TCHAR *prefix = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\";
DWORD disposition;
HKEY hkey = 0;
TCHAR subkey[256];
static const TCHAR *prefix = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\";
TCHAR* subkey = new TCHAR[lstrlen(prefix) + lstrlen(source) + 1];
lstrcpy(subkey, prefix);
lstrcat(subkey, source);
hkey = regGetKey(subkey, &disposition);
DWORD disposition;
HKEY hkey = regGetKey(subkey, &disposition);
delete[] subkey;
if (disposition == REG_CREATED_NEW_KEY) {
regSetString(hkey, "EventMessageFile", "NTEventLogAppender.dll");
regSetString(hkey, "CategoryMessageFile", "NTEventLogAppender.dll");
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment