setupldr!BlOutputLoadMessage函数和setupldr!SlWriteStatusText函数分析

setupldr!BlOutputLoadMessage函数和setupldr!SlWriteStatusText函数分析

kd> p

Breakpoint 10 hit

eax=003828fc ebx=00000000 ecx=00382414 edx=003828f8 esi=00348198 edi=00002335

eip=00323246 esp=00060bb0 ebp=00060df4 iopl=0 nv up di pl zr na pe nc

cs=0008 ss=0010 ds=0010 es=0010 fs=0030 gs=0000 efl=00000046

setupldr!BlOutputLoadMessage:

00323246 55 push ebp

kd> dv

DeviceName = 0x8021cb28 "multi(0)disk(0)cdrom(159)"

FileName = 0x00348198 "\I386\ntkrnlmp.exe"

FileDescription = 0x003828fc "Windows Executive.."

OutputBuffer = char [256] "???"

dots = 0n0

kd> kc 6

00 setupldr!BlOutputLoadMessage

01 setupldr!SlInit

02 setupldr!BlStartup

03 setupldr!NtProcessStartup

WARNING: Frame IP not in any known module. Following frames may be wrong.

04 0x0

05 0x0

kd> gu

Breakpoint 9 hit

eax=00060aac ebx=00000000 ecx=00060a78 edx=00060adc esi=00348198 edi=00002335

eip=00329dfa esp=00060aa4 ebp=00060bac iopl=0 nv up di pl nz na pe nc

cs=0008 ss=0010 ds=0010 es=0010 fs=0030 gs=0000 efl=00000006

setupldr!SlWriteStatusText:

00329dfa 55 push ebp

kd> kc 6

00 setupldr!SlWriteStatusText

01 setupldr!BlOutputLoadMessage

02 setupldr!SlInit

03 setupldr!BlStartup

04 setupldr!NtProcessStartup

WARNING: Frame IP not in any known module. Following frames may be wrong.

05 0x0

kd> dv

Text = 0x00060aac "Setup is loading files (Windows Executive..)....."

AttributeSave = 0xfa ''

Count = 8

VOID

BlOutputLoadMessage (

IN PCHAR DeviceName,

IN PCHAR FileName,

IN PTCHAR FileDescription OPTIONAL

)

{

static int dots = 0;

TCHAR OutputBuffer[256];

PTCHAR FormatString;

UNREFERENCED_PARAMETER( FileName );

UNREFERENCED_PARAMETER( DeviceName );

//

// Construct and output loading file message.

//

if (!UseRegularBackground) {

FormatString = BlFindMessage(SL_FILE_LOAD_MESSAGE);

if (FileDescription) {

_stprintf(OutputBuffer,FormatString,FileDescription);

SlWriteStatusText(OutputBuffer);

}

}

return;

}

D:\srv03rtm\base\boot\setup\daytona\obj\i386\msgs.h

//

// MessageId: SL_FILE_LOAD_MESSAGE

//

// MessageText:

//

// Setup is loading files (%s)...

//

#define SL_FILE_LOAD_MESSAGE 0x0000232CL

VOID

SlWriteStatusText(

IN PTCHAR Text

)

{

UCHAR AttributeSave = CurAttribute;

PTCHAR p;

ULONG Count;

#ifdef EFI

ULONG MaxWidth = ScreenWidth - 3;

#else

ULONG MaxWidth = ScreenWidth - 2;

#endif

//

// Nop, if status bar is disabled

//

if (!StatusBarEnabled) {

return;

}

//

// if we're writing to a terminal, we don't want to write into the lower

// right corner as this would make us scroll.

//

if (BlTerminalConnected) {

MaxWidth -= 1;

}

if (MaxWidth > MAX_STATUS) {

MaxWidth = MAX_STATUS;

}

#ifdef UNICODE

for (Count = 0 ; Count < sizeof(StatusText)/sizeof(TCHAR);Count++) {

StatusText[Count] = TEXT(' ');

}

#else

RtlFillMemory(StatusText,sizeof(StatusText),' ');

#endif

//

// Strip cr/lf as we copy the status text into the status text buffer.

//

p = StatusText;

Count = 0;

while((Count < MaxWidth) && *Text) {

if((*Text != TEXT('\r')) && (*Text != TEXT('\n'))) {

*p++ = *Text;

Count++;

}

Text++;

}

SlSetCurrentAttribute(StatusAttribute);

SlPositionCursor(0,ScreenHeight-1);最后一行

ArcWrite(ARC_CONSOLE_OUTPUT,TEXT(" "),2*sizeof(TCHAR),&Count);2个空格

SlPositionCursor(2,ScreenHeight-1);

ArcWrite(ARC_CONSOLE_OUTPUT,StatusText,MaxWidth*sizeof(TCHAR),&Count);

SlSetCurrentAttribute(AttributeSave);

SlPositionCursor(0,5);

}