-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix hooks project #18
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ Logger::~Logger() { | |
this->closeLog(); | ||
} | ||
|
||
void Logger::initLog(LPWSTR name, DWORD logLevel) { | ||
void Logger::initLog(LPCWSTR name, DWORD logLevel) { | ||
if (!m_hEventSrc) m_hEventSrc = RegisterEventSourceW(NULL, name); | ||
if (!m_reportLogBuf) m_reportLogBuf = (WCHAR*)malloc(REPORT_LOG_BUF_SIZE); | ||
m_logLevel = logLevel; | ||
|
@@ -27,7 +27,7 @@ void Logger::setLogLevel(DWORD logLevel) { | |
m_logLevel = logLevel; | ||
} | ||
|
||
void Logger::reportLogDebug(const LPWSTR message, ...) { | ||
void Logger::reportLogDebug(LPCWSTR message, ...) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This a minor mistake. |
||
va_list ap; | ||
va_start( ap, message ); | ||
if (m_logLevel <= PRISMATIK_LOG_SEVERITY_DEBUG) { | ||
|
@@ -36,7 +36,7 @@ void Logger::reportLogDebug(const LPWSTR message, ...) { | |
va_end( ap ); | ||
} | ||
|
||
void Logger::reportLogInfo(const LPWSTR message, ...) { | ||
void Logger::reportLogInfo(LPCWSTR message, ...) { | ||
va_list ap; | ||
va_start( ap, message ); | ||
if (m_logLevel <= PRISMATIK_LOG_SEVERITY_INFO) { | ||
|
@@ -45,7 +45,7 @@ void Logger::reportLogInfo(const LPWSTR message, ...) { | |
va_end( ap ); | ||
} | ||
|
||
void Logger::reportLogWarning(const LPWSTR message, ...) { | ||
void Logger::reportLogWarning(LPCWSTR message, ...) { | ||
va_list ap; | ||
va_start( ap, message ); | ||
if (m_logLevel <= PRISMATIK_LOG_SEVERITY_WARNING) { | ||
|
@@ -54,19 +54,19 @@ void Logger::reportLogWarning(const LPWSTR message, ...) { | |
va_end( ap ); | ||
} | ||
|
||
void Logger::reportLogError(const LPWSTR message, ...) { | ||
void Logger::reportLogError(LPCWSTR message, ...) { | ||
va_list ap; | ||
va_start( ap, message ); | ||
this->reportLog(EVENTLOG_ERROR_TYPE, PRISMATIK_LOG_MSG_ERROR, message, ap); | ||
va_end( ap ); | ||
} | ||
|
||
void Logger::reportLog(DWORD type, DWORD msgId, const LPWSTR message, va_list ap) { | ||
void Logger::reportLog(DWORD type, DWORD msgId, LPCWSTR message, va_list ap) { | ||
if (m_hEventSrc && m_reportLogBuf) { | ||
ZeroMemory(m_reportLogBuf, sizeof(m_reportLogBuf)); | ||
ZeroMemory(m_reportLogBuf, REPORT_LOG_BUF_SIZE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here only sizeof void* bytes will be set to zero instead of REPORTLOGBUFSIZE. |
||
int sprintfResult = wvsprintfW(m_reportLogBuf, message, ap); | ||
if (sprintfResult > -1) | ||
ReportEventW(m_hEventSrc, type, 0, msgId, NULL, 1, 0, const_cast<const WCHAR **>(&m_reportLogBuf), NULL); | ||
ReportEventW(m_hEventSrc, type & 0xFFFF, 0, msgId, NULL, 1, 0, const_cast<const WCHAR **>(&m_reportLogBuf), NULL); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
#ifndef HOOKSUTILS_H | ||
#define HOOKSUTILS_H | ||
#include<windows.h> | ||
|
||
#define NOMINMAX | ||
#define WIN32_LEAN_AND_MEAN | ||
#include <windows.h> | ||
//#include <stdarg.h> | ||
|
||
//void InitLog(const LPWSTR name, DWORD logLevel); | ||
|
@@ -13,4 +16,8 @@ | |
|
||
bool WriteToProtectedMem(void * mem, void * newVal, void * savedVal, size_t size); | ||
|
||
inline void * incPtr(void * ptr, UINT offset) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All compilers will give a warning when adding integer to a void *. |
||
return (void *)( (DWORD_PTR)ptr + offset ); | ||
} | ||
|
||
#endif // HOOKSUTILS_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a bug I think. In the next line we will overwrite m_liFreq value by uninitialized value of liFreq.