?? message.cxx
字號:
/*++
Copyright (c) 1992-1999 Microsoft Corporation
Module Name:
message.cxx
--*/
#include <pch.cxx>
#define _ULIB_MEMBER_
#include "ulib.hxx"
#include "message.hxx"
#include "hmem.hxx"
#if !defined( _EFICHECK_ )
extern "C" {
#include "stdio.h"
#if defined(_AUTOCHECK_)
#include "ntos.h"
#endif
}
#endif
DEFINE_EXPORTED_CONSTRUCTOR(MESSAGE, OBJECT, ULIB_EXPORT);
MESSAGE::~MESSAGE(
)
/*++
Routine Description:
Destructor for MESSAGE.
Arguments:
None.
Return Value:
None.
--*/
{
Destroy();
}
VOID
MESSAGE::Construct(
)
/*++
Routine Description:
This routine initializes the object to a default initial state.
Arguments:
None.
Return Value:
None.
--*/
{
_logged_chars = 0;
_next_message_offset = 0;
_logging_enabled = FALSE;
_msgid = 0;
_inuse = 0;
_timeout.QuadPart = 0;
}
VOID
MESSAGE::Destroy(
)
/*++
Routine Description:
This routine returns the object to a default initial state.
Arguments:
None.
Return Value:
None.
--*/
{
_logged_chars = 0;
_next_message_offset = 0;
_logging_enabled = FALSE;
_msgid = 0;
_inuse = 0;
_timeout.QuadPart = 0;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::Initialize(
)
/*++
Routine Description:
This routine initializes the class to a valid initial state.
Arguments:
DotsOnly - Autochk should produce only dots instead of messages.
Return Value:
FALSE - Failure.
TRUE - Success.
--*/
{
Destroy();
_timeout.QuadPart = -10000;
return _log_buffer.Initialize();
}
ULIB_EXPORT
BOOLEAN
MESSAGE::IsSuppressedMessage(
)
/*++
Routine Description:
This function determines whether the specified message ID
should be suppressed, i.e. not recorded in the message log.
Arguments:
MessageId -- Supplies the Message ID in question.
Return Value:
TRUE if this message ID is in the set which is not recorded
in the message log.
--*/
{
BOOLEAN result;
switch( _msgid ) {
case MSG_HIDDEN_STATUS:
case MSG_PERCENT_COMPLETE:
case MSG_PERCENT_COMPLETE2:
#if !defined( _EFICHECK_ )
case MSG_CHK_NTFS_CHECKING_FILES:
case MSG_CHK_NTFS_CHECKING_INDICES:
case MSG_CHK_NTFS_INDEX_VERIFICATION_COMPLETED:
case MSG_CHK_NTFS_FILE_VERIFICATION_COMPLETED:
case MSG_CHK_NTFS_CHECKING_SECURITY:
case MSG_CHK_NTFS_SECURITY_VERIFICATION_COMPLETED:
#endif
case MSG_CHK_VOLUME_CLEAN:
case MSG_CHK_CHECKING_FILES:
case MSG_CHK_DONE_CHECKING:
result = TRUE;
break;
default:
result = FALSE;
break;
}
return result;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::Display(
IN PCSTR Format ...
)
/*++
Routine Description:
This routine displays the message with the specified parameters.
Arguments:
Format ... - Supplies a printf style list of arguments.
Return Value:
FALSE - Failure.
TRUE - Success.
--*/
{
va_list ap;
BOOLEAN r;
// unreferenced parameters
(void)(this);
va_start(ap, Format);
r = DisplayV(Format, ap);
va_end(ap);
return r;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::DisplayMsg(
IN MSGID MsgId,
IN PCSTR Format ...
)
/*++
Routine Description:
This routine displays the message with the specified parameters.
It performs the operation atomically.
Arguments:
Format ... - Supplies a printf style list of arguments.
Return Value:
FALSE - Failure.
TRUE - Success.
--*/
{
va_list ap;
BOOLEAN r;
while (InterlockedCompareExchange(&_inuse, 1, 0)) {
NtDelayExecution(FALSE, &_timeout);
}
Set(MsgId);
va_start(ap, Format);
r = DisplayV(Format, ap);
va_end(ap);
InterlockedDecrement(&_inuse);
return r;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::DisplayMsg(
IN MSGID MsgId,
IN MESSAGE_TYPE MessageType,
IN ULONG MessageVisual,
IN PCSTR Format ...
)
/*++
Routine Description:
This routine displays the message with the specified parameters.
It performs the operation atomically.
Arguments:
Format ... - Supplies a printf style list of arguments.
Return Value:
FALSE - Failure.
TRUE - Success.
--*/
{
va_list ap;
BOOLEAN r;
while (InterlockedCompareExchange(&_inuse, 1, 0)) {
NtDelayExecution(FALSE, &_timeout);
}
Set(MsgId, MessageType, MessageVisual);
va_start(ap, Format);
r = DisplayV(Format, ap);
va_end(ap);
InterlockedDecrement(&_inuse);
return r;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::LogMsg(
IN MSGID MsgId,
IN PCSTR Format ...
)
/*++
Routine Description:
This routine logs the message with the specified parameters.
It performs the operation atomically.
Arguments:
Format ... - Supplies a printf style list of arguments.
Return Value:
FALSE - Failure.
TRUE - Success.
--*/
{
va_list ap;
BOOLEAN r;
while (InterlockedCompareExchange(&_inuse, 1, 0)) {
NtDelayExecution(FALSE, &_timeout);
}
Set(MsgId);
va_start(ap, Format);
r = LogV(Format, ap);
va_end(ap);
InterlockedDecrement(&_inuse);
return r;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::Log(
IN PCSTR Format ...
)
/*++
Routine Description:
This routine logs the message with the specified parameters.
Arguments:
Format ... - Supplies a printf style list of arguments.
Return Value:
FALSE - Failure.
TRUE - Success.
--*/
{
va_list ap;
BOOLEAN r;
// unreferenced parameters
(void)(this);
va_start(ap, Format);
r = LogV(Format, ap);
va_end(ap);
return r;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::DumpDataToLog(
IN PVOID Data,
IN ULONG Length
)
/*++
Routine Description:
This routine dumps the binary data to the log.
Arguments:
Data - Supplies a pointer to the data to be dumped
Length - Supplies the number of bytes to dump
Return Value:
FALSE - Failure.
TRUE - Success.
--*/
{
#if !defined( _EFICHECK_ )
PUCHAR pdata = (PUCHAR)Data;
ULONG block;
BOOLEAN rst = TRUE;
WCHAR buffer[50], buffer2[20];
USHORT i;
block = ((Length + 0xf) >> 4) + 1;
Set(MSG_CHKLOG_DUMP_DATA);
while (rst && block--) {
for (i=0; i<16; i++) {
__try {
swprintf(buffer+i*3, L"%02x ", pdata[i]);
if (isprint(pdata[i]))
swprintf(buffer2+i, L"%c", pdata[i]);
else
buffer2[i] = '.';
} __except (EXCEPTION_EXECUTE_HANDLER) {
buffer[i*3] = '?';
buffer[i*3+1] = '?';
buffer[i*3+2] = ' ';
buffer2[i] = '.';
}
}
buffer[48] = ' ';
buffer[49] = 0;
buffer2[16] = 0;
pdata += 0x10;
rst = rst && Log("%ws%ws", buffer, buffer2);
}
return rst;
#else
return FALSE;
#endif
}
BOOLEAN
MESSAGE::DisplayV(
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -