Process Hacker
Main Page
Namespaces
Data Structures
Files
File List
Globals
filelog.c
Go to the documentation of this file.
1
/*
2
* Process Hacker Extended Notifications -
3
* file logging
4
*
5
* Copyright (C) 2010 wj32
6
*
7
* This file is part of Process Hacker.
8
*
9
* Process Hacker is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation, either version 3 of the License, or
12
* (at your option) any later version.
13
*
14
* Process Hacker is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
18
*
19
* You should have received a copy of the GNU General Public License
20
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
21
*/
22
23
#include <
phdk.h
>
24
#include "
extnoti.h
"
25
26
VOID
NTAPI
LoggedCallback
(
27
_In_opt_ PVOID Parameter,
28
_In_opt_ PVOID Context
29
);
30
31
PPH_FILE_STREAM
LogFileStream
= NULL;
32
PH_CALLBACK_REGISTRATION
LoggedCallbackRegistration
;
33
34
VOID
FileLogInitialization
(
35
VOID
36
)
37
{
38
NTSTATUS status;
39
PPH_STRING
fileName;
40
41
fileName =
PhGetStringSetting
(
SETTING_NAME_LOG_FILENAME
);
42
43
if
(fileName->
Length
!= 0)
44
{
45
status =
PhCreateFileStream
(
46
&LogFileStream,
47
fileName->
Buffer
,
48
FILE_GENERIC_WRITE,
49
FILE_SHARE_READ,
50
FILE_OPEN_IF
,
51
PH_FILE_STREAM_APPEND
|
PH_FILE_STREAM_UNBUFFERED
52
);
53
54
if
(
NT_SUCCESS
(status))
55
{
56
PhRegisterCallback
(
57
&
PhLoggedCallback
,
58
LoggedCallback
,
59
NULL,
60
&LoggedCallbackRegistration
61
);
62
}
63
}
64
65
PhDereferenceObject
(fileName);
66
}
67
68
VOID
NTAPI
LoggedCallback
(
69
_In_opt_ PVOID Parameter,
70
_In_opt_ PVOID Context
71
)
72
{
73
PPH_LOG_ENTRY
logEntry = Parameter;
74
PPH_STRING
formattedTime;
75
PPH_STRING
formatted;
76
77
formattedTime =
PhFormatDateTime
(NULL);
78
formatted =
PhFormatLogEntry
(logEntry);
79
80
PhWriteStringFormatAsUtf8FileStream
(LogFileStream, L
"%s: %s\r\n"
, formattedTime->
Buffer
, formatted->
Buffer
);
81
82
PhDereferenceObject
(formatted);
83
PhDereferenceObject
(formattedTime);
84
}
plugins
ExtendedNotifications
filelog.c
Generated by
1.8.2