NT内核记录器会话日志未创建
NT Kernel Logger Session Log Not Being Created
我正在尝试编译我从Microsoft网站之一获得的以下代码(原始):
#include "stdafx.h"
#define INITGUID // Include this #define to use SystemTraceControlGuid in Evntrace.h.
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <strsafe.h>
#include <wmistr.h>
#include <evntrace.h>
#define LOGFILE_PATH L"C:Documents and SettingsAdministratorMy DocumentsMy DropboxLog.etl"
void wmain(void)
{
ULONG status = ERROR_SUCCESS;
TRACEHANDLE SessionHandle = 0;
EVENT_TRACE_PROPERTIES* pSessionProperties = NULL;
ULONG BufferSize = 0;
// Allocate memory for the session properties. The memory must
// be large enough to include the log file name and session name,
// which get appended to the end of the session properties structure.
BufferSize = sizeof(EVENT_TRACE_PROPERTIES) + sizeof(LOGFILE_PATH) + sizeof(KERNEL_LOGGER_NAME);
pSessionProperties = (EVENT_TRACE_PROPERTIES*) malloc(BufferSize);
if (NULL == pSessionProperties)
{
wprintf(L"Unable to allocate %d bytes for properties structure.n", BufferSize);
goto cleanup;
}
// Set the session properties. You only append the log file name
// to the properties structure; the StartTrace function appends
// the session name for you.
ZeroMemory(pSessionProperties, BufferSize);
pSessionProperties->Wnode.BufferSize = BufferSize;
pSessionProperties->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
pSessionProperties->Wnode.ClientContext = 1; //QPC clock resolution
pSessionProperties->Wnode.Guid = SystemTraceControlGuid;
pSessionProperties->EnableFlags = EVENT_TRACE_FLAG_NETWORK_TCPIP;
pSessionProperties->LogFileMode = EVENT_TRACE_FILE_MODE_CIRCULAR;
pSessionProperties->MaximumFileSize = 5; // 5 MB
pSessionProperties->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
pSessionProperties->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + sizeof(KERNEL_LOGGER_NAME);
StringCbCopy((LPWSTR)((char*)pSessionProperties + pSessionProperties->LogFileNameOffset), sizeof(LOGFILE_PATH), LOGFILE_PATH);
// Create the trace session.
status = StartTrace((PTRACEHANDLE)&SessionHandle, KERNEL_LOGGER_NAME, pSessionProperties);
if (ERROR_SUCCESS != status)
{
if (ERROR_ALREADY_EXISTS == status)
{
wprintf(L"The NT Kernel Logger session is already in use.n");
}
else
{
wprintf(L"EnableTrace() failed with %lun", status);
getchar();
}
goto cleanup;
}
wprintf(L"Press any key to end trace session ");
_getch();
cleanup:
if (SessionHandle)
{
status = ControlTrace(SessionHandle, KERNEL_LOGGER_NAME, pSessionProperties, EVENT_TRACE_CONTROL_STOP);
if (ERROR_SUCCESS != status)
{
wprintf(L"ControlTrace(stop) failed with %lun", status);
}
}
if (pSessionProperties)
free(pSessionProperties);
}
该程序似乎成功运行,但是日志文件从未创建。有人知道问题是什么吗?我正在使用Windows XP。
您应该用''替换logfile_path中的''。否则,它将被视为逃生序列
相关文章:
- 如何创建一个CMake变量,除非显式重写,否则使用默认值
- 未创建日志文件
- boost日志文件无法创建sample.log文件
- 使用 redis 进行日志缓存:是否可以创建逐出到 PostgreSQL 的逐出策略?
- Mac OS X:应用程序可以创建日志文件
- 如何使用 c++ 在 "Application and Services Logs" 部分创建事件日志
- 无法创建将包含日志文件的文件夹
- NT内核记录器会话日志未创建
- Pantheios:当太大时创建一个新的日志文件
- 尝试创建流的错误日志 - 获取"one or more multiply defined symbols found"
- 我们可以为 boost 库中的每个线程创建单独的日志文件吗?
- 正在创建故障日志
- 创建一个简单的窗口来输出用于调试的信息(日志样式)- wxWidgets
- 在扩展中创建字符串流的日志宏
- c#应用程序log4net日志文件在c++ /CLI中使用时未创建
- 在Android上创建可公开访问的日志文件的位置
- 创建一个没有时间字符串的Google日志文件
- 为数据密集型操作创建日志
- 如何创建一个宏来验证HR和日志
- 在分析器中创建日志的格式