[cpp-log4shib] branch master updated: Fixes to NTEventLogAppender and message handling.
Scott Cantor
cantor.2 at osu.edu
Tue Apr 17 15:06:23 EDT 2018
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository cpp-log4shib.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-log4shib.git;a=commit;h=1afedd003dfb187bf44e3aed5878dbac5bc4a0f1
The following commit(s) were added to refs/heads/master by this push:
new 1afedd0 Fixes to NTEventLogAppender and message handling.
1afedd0 is described below
commit 1afedd003dfb187bf44e3aed5878dbac5bc4a0f1
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Apr 17 15:06:18 2018 -0400
Fixes to NTEventLogAppender and message handling.
---
msvc15/NTEventLogAppender/NTEventLogCategories.vcxproj | 8 ++++----
.../NTEventLogCategories.vcxproj.filters | 2 +-
src/NTEventLogAppender.cpp | 18 ++++++++++--------
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/msvc15/NTEventLogAppender/NTEventLogCategories.vcxproj b/msvc15/NTEventLogAppender/NTEventLogCategories.vcxproj
index 808841a..129541f 100644
--- a/msvc15/NTEventLogAppender/NTEventLogCategories.vcxproj
+++ b/msvc15/NTEventLogAppender/NTEventLogCategories.vcxproj
@@ -137,13 +137,13 @@
<CustomBuild Include="NTEventLogCategories.mc">
<FileType>Document</FileType>
<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>
diff --git a/msvc15/NTEventLogAppender/NTEventLogCategories.vcxproj.filters b/msvc15/NTEventLogAppender/NTEventLogCategories.vcxproj.filters
index 516df53..a8f6652 100644
--- a/msvc15/NTEventLogAppender/NTEventLogCategories.vcxproj.filters
+++ b/msvc15/NTEventLogAppender/NTEventLogCategories.vcxproj.filters
@@ -20,7 +20,7 @@
</CustomBuild>
</ItemGroup>
<ItemGroup>
- <ResourceCompile Include="\NTEventLogCategories.rc">
+ <ResourceCompile Include="$(IntDir)\NTEventLogCategories.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
diff --git a/src/NTEventLogAppender.cpp b/src/NTEventLogAppender.cpp
index 1e12456..12e5745 100644
--- a/src/NTEventLogAppender.cpp
+++ b/src/NTEventLogAppender.cpp
@@ -23,7 +23,9 @@ namespace log4shib {
void NTEventLogAppender::open()
{
- addRegistryInfo(_strSourceName.c_str());
+ // This has to be done as Admin and should really be app-specific and
+ // handled as part of installation or by a deployer.
+ //addRegistryInfo(_strSourceName.c_str());
_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),
getCategory(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");
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list