📄 message.cxx
字号:
IN PCSTR Format,
IN va_list VarPointer
)
/*++
Routine Description:
This routine displays the message with the specified parameters.
Arguments:
Format - Supplies a printf style list of arguments.
VarPointer - Supplies a varargs pointer to the arguments.
Return Value:
FALSE - Failure.
TRUE - Success.
--*/
{
// unreferenced parameters
(void)(this);
(void)(Format);
(void)(VarPointer);
return TRUE;
}
BOOLEAN
MESSAGE::LogV(
IN PCSTR Format,
IN va_list VarPointer
)
/*++
Routine Description:
This routine logs the message with the specified parameters.
Arguments:
Format - Supplies a printf style list of arguments.
VarPointer - Supplies a varargs pointer to the arguments.
Return Value:
FALSE - Failure.
TRUE - Success.
--*/
{
DSTRING display_string;
CHAR buffer[512];
if (IsLoggingEnabled()) {
if (!BASE_SYSTEM::QueryResourceStringV(&display_string, _msgid, Format,
VarPointer)) {
return FALSE;
}
if (display_string.QuerySTR(0, TO_END, buffer, 512, TRUE)) {
DebugPrintTrace(("%s", buffer));
}
return LogMessage(&display_string);
}
return TRUE;
}
PMESSAGE
MESSAGE::Dup(
)
/*++
Routine Description:
This routine returns a new MESSAGE of the same type.
Arguments:
None.
Return Value:
A pointer to a new MESSAGE object.
--*/
{
// unreferenced parameters
(void)(this);
return NEW MESSAGE;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::IsYesResponse(
IN BOOLEAN Default
)
/*++
Routine Description:
This routine queries to see if the response to a message is either
yes or no.
Arguments:
Default - Supplies a default answer to the question.
Return Value:
FALSE - A "no" response.
TRUE - A "yes" response.
--*/
{
// unreferenced parameters
(void)(this);
return Default;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::QueryStringInput(
OUT PWSTRING String
)
/*++
Routine Description:
This routine queries a string from the user.
Arguments:
String - Supplies a buffer to return the string into.
Return Value:
FALSE - Failure.
TRUE - Success.
--*/
{
// unreferenced parameters
(void)(this);
return String->Initialize("");
}
ULIB_EXPORT
MSGID
MESSAGE::SelectResponse(
IN ULONG NumberOfSelections ...
)
/*++
Routine Descriptions:
This routine queries a response from the user. It returns the
message id of the response inputted.
Arguments:
NumberOfSelections - Supplies the number of possible message
responses.
... - Supplies 'NumberOfSelections' message identifiers.
Return Value:
The first message id on the list.
--*/
{
va_list ap;
MSGID msg;
// unreferenced parameters
(void)(this);
va_start(ap, NumberOfSelections);
msg = va_arg(ap, MSGID);
va_end(ap);
return msg;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::IsInAutoChk(
)
/*++
Routine Description:
This routine simply returns FALSE to indicate it is not
in regular autochk.
Arguments:
None.
Return Value:
FALSE - Not in autochk
--*/
{
return FALSE;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::IsInSetup(
)
/*++
Routine Description:
This routine simply returns FALSE to indicate it is not
in setup.
Arguments:
None.
Return Value:
FALSE - Not in setup
--*/
{
return FALSE;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::IsKeyPressed(
MSGID MsgId,
ULONG TimeOutInSeconds
)
/*++
Routine Description:
This routine simply returns FALSE to indicate no
key has been pressed.
Arguments:
None.
Return Value:
FALSE - No key is pressed within the time out period.
--*/
{
// unreferenced parameters
(void)(this);
UNREFERENCED_PARAMETER( MsgId );
UNREFERENCED_PARAMETER( TimeOutInSeconds );
return FALSE;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::WaitForUserSignal(
)
/*++
Routine Description:
This routine waits for a signal from the user.
Arguments:
None.
Return Value:
FALSE - Failure.
TRUE - Success.
--*/
{
// unreferenced parameters
(void)(this);
return TRUE;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::SetDotsOnly(
IN BOOLEAN DotsState
)
{
// unreferenced parameters
(void)this;
(void)DotsState;
return FALSE;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::QueryPackedLog(
IN OUT PHMEM Mem,
OUT PULONG PackedDataLength
)
/*++
Routine Description:
Arguments:
Mem -- Supplies a container for the packed log.
PackedDataLength -- Receives the number of bytes written to Mem.
Return Value:
TRUE upon successful completion.
--*/
{
FSTRING CurrentString;
PWCHAR Buffer;
ULONG NewBufferSize, CurrentOffset;
if( !IsLoggingEnabled() ) {
return FALSE;
}
ResetLoggingIterator();
CurrentOffset = 0;
while( QueryNextLoggedMessage( &CurrentString ) ) {
NewBufferSize = (CurrentOffset + CurrentString.QueryChCount()) * sizeof(WCHAR);
if( NewBufferSize > Mem->QuerySize() &&
!Mem->Resize( (NewBufferSize + 1023)/1024 * 1024, 0x1 ) ) {
return FALSE;
}
Buffer = (PWCHAR)Mem->GetBuf();
memcpy( Buffer + CurrentOffset,
CurrentString.GetWSTR(),
CurrentString.QueryChCount() * sizeof(WCHAR) );
CurrentOffset += CurrentString.QueryChCount();
}
*PackedDataLength = CurrentOffset * sizeof(WCHAR);
return TRUE;
}
BOOLEAN
MESSAGE::QueryNextLoggedMessage(
OUT PFSTRING MessageText
)
{
PWCHAR Buffer = (PWCHAR)_log_buffer.GetBuf();
BOOLEAN Result;
if( _next_message_offset >= _logged_chars ) {
// No more logged messages.
//
return FALSE;
}
Result = (MessageText->Initialize( Buffer + _next_message_offset ) != NULL) ?
TRUE : FALSE;
// Push _next_message_offset to the next message. Note
// that _next_message_offset is also incremented if this
// loop terminates because a zero was found, so that it
// will be one character past the next NULL character.
//
while( _next_message_offset < _logged_chars &&
Buffer[_next_message_offset++] );
return Result;
}
ULIB_EXPORT
BOOLEAN
MESSAGE::LogMessage(
PCWSTRING Message
)
{
ULONG NewBufferSize;
PWCHAR Buffer;
// The buffer must be large enough to accept this message plus
// a trailing null. To cut down the number of memory allocation
// calls, grow the buffer by 1K chunks.
//
NewBufferSize = (_logged_chars + Message->QueryChCount() + 1) * sizeof(WCHAR);
// Don't allow the buffer to grow more than 0.5MB
// otherwise we may use up all the pages.
if (NewBufferSize > 512000)
return FALSE;
if( _log_buffer.QuerySize() < NewBufferSize &&
!_log_buffer.Resize( (NewBufferSize + 1023)/1024 * 1024, 0x1 ) ) {
return FALSE;
}
Buffer = (PWCHAR)_log_buffer.GetBuf();
// QueryWSTR will append a trailing NULL.
//
Message->QueryWSTR( 0, TO_END,
Buffer + _logged_chars,
_log_buffer.QuerySize()/sizeof(WCHAR) - _logged_chars );
_logged_chars += Message->QueryChCount() + 1;
return TRUE;
}
ULIB_EXPORT
VOID
MESSAGE::Lock(
)
{
while (InterlockedCompareExchange(&_inuse, 1, 0)) {
NtDelayExecution(FALSE, &_timeout);
}
}
ULIB_EXPORT
VOID
MESSAGE::Unlock(
)
{
InterlockedDecrement(&_inuse);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -