Jump-start your project by learning from devs who
write Windows drivers and file systems every day.
Take an OSR seminar!

Upcoming OSR Seminars:
WDM Lab, Seattle, WA 16 August 2010
WDF Lab, Santa Clara, CA 27 September 2010
Debug Lab, Portland, OR 18 October 2010
Windows Internals & Software Drivers Lab, Santa Clara, CA 15 November 2010


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 2  
13 Mar 01 08:07
ntdev member 4578
xxxxxx@infosec.ru
Join Date:
Posts To This List: 4
Output to screen at boot time

Hello! I wonder - how Softice & friends put text to screen and receive keys during the Windows NT boot? Is it kind of "dirty trick" or there is some "right" way to do it? Vladimir --- You are currently subscribed to ntdev as: $subst('Recip.EmailAddr') To unsubscribe send a blank email to leave-ntdev-$subst('Recip.MemberIDChar')@lists.osr.com
  Message 2 of 2  
13 Mar 01 12:06
ntdev member 730
xxxxxx@ontrack.com
Join Date:
Posts To This List: 15
Re: Output to screen at boot time

You would use NtDisplayString() to write strings to the console: void OutputString(PWCHAR pwszText) { UNICODE_STRING usText; usText.Buffer = pwszText; usText.Length = wcslen(pwszText) * sizeof(WCHAR); usText.MaximumLength = usText.Length + sizeof(WCHAR); NtDisplayString(&usText); } To receive keyboard input you must open and read the keyboard device directly: HANDLE g_hKeyboardAsync = NULL; NTSTATUS CreateKeyboard() { UNICODE_STRING ustrFileName; HANDLE hKeyboard = NULL; OBJECT_ATTRIBUTES oa; IO_STATUS_BLOCK iosb; NTSTATUS status; PWCHAR pszFileName = L"\\Device\\KeyboardClass0"; RtlInitUnicodeString( &ustrFileName, pszFileName ); InitializeObjectAttributes ( &oa, &ustrFileName, OBJ_CASE_INSENSITIVE, NULL, NULL ); memset( &iosb, 0, sizeof( iosb ) ); status = ZwCreateFile( &g_hKeyboardAsync, GENERIC_READ | SYNCHRONIZE | FILE_READ_ATTRIBUTES, &oa, &iosb, 0, FILE_ATTRIBUTE_NORMAL, 0, FILE_OPEN, FILE_DIRECTORY_FILE, NULL, 0 ); return status; } Once you have a handle to the keyboard device, NtWaitForSingleObject() on it and if it returns STATUS_SUCCESS (as opposed to STATUS_PENDING) then ZwReadFile() the handle to retrieve the make/break code and the scan code value. You must translate the scan codes to ASCII codes yourself. For the read, declare an array of type: CHAR g_KeyBuf[ 0xf0 ]; The make/break code will be at g_KeyBuf[ 4 ], and the scan code will be at g_KeyBuf[ 2 ]: PWORD pwScanCode; PWORD pwMakeBreak; pwMakeBreak = ( PWORD ) &g_KeyBuf[ 4 ]; pwScanCode = ( PWORD ) &g_KeyBuf[ 2 ]; Hope this helps. Rick Howard Principal Engineer Ontrack Data International, Inc. Boulder,CO --- You are currently subscribed to ntdev as: $subst('Recip.EmailAddr') To unsubscribe send a blank email to leave-ntdev-$subst('Recip.MemberIDChar')@lists.osr.com
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 13:59.


Copyright ©2005, OSR Open Systems Resourcs, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license