mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
Porting pice. Added keyboard hook and some file functions.
svn path=/trunk/; revision=2420
This commit is contained in:
parent
8c3f4003e7
commit
ef93b48310
12 changed files with 902 additions and 741 deletions
|
@ -444,7 +444,7 @@ BOOLEAN ConsoleInitHercules(void)
|
|||
|
||||
attr.u.Asuchar = 0x07;
|
||||
|
||||
pScreenBufferHercules=ioremap(0xb0000,FRAMEBUFFER_SIZE);
|
||||
pScreenBufferHercules=MmMapIoSpace(0xb0000,FRAMEBUFFER_SIZE,MmWriteCombined);
|
||||
|
||||
DPRINT((0,"VGA memory phys. 0xb0000 mapped to virt. 0x%x\n",pScreenBufferHercules));
|
||||
|
||||
|
@ -483,7 +483,7 @@ void ConsoleShutdownHercules(void)
|
|||
outb_p(0,0x3bf);
|
||||
|
||||
if(pScreenBufferHercules)
|
||||
iounmap(pScreenBufferHercules);
|
||||
MmUnmapIoSpace(pScreenBufferHercules,FRAMEBUFFER_SIZE);
|
||||
|
||||
LEAVE_FUNC();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ Copyright notice:
|
|||
#include "precomp.h"
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/delay.h>
|
||||
|
@ -187,13 +186,12 @@ BOOLEAN InitPICE(void)
|
|||
}
|
||||
|
||||
DPRINT((0,"InitPICE(): trace step 12\n"));
|
||||
// need these two to hook the keyboard
|
||||
ScanExports("handle_scancode",&ulHandleScancode);
|
||||
ScanExports("handle_kbd_event",&ulHandleKbdEvent);
|
||||
|
||||
|
||||
DPRINT((0,"InitPICE(): trace step 13\n"));
|
||||
// patch the keyboard driver
|
||||
if(!(ulHandleScancode && ulHandleKbdEvent && PatchKeyboardDriver(ulHandleKbdEvent,ulHandleScancode)) )
|
||||
|
||||
if(PatchKeyboardDriver())
|
||||
{
|
||||
Print(OUTPUT_WINDOW,"pICE: ABORT (couldn't patch keyboard driver)\n");
|
||||
Print(OUTPUT_WINDOW,"pICE: press any key to continue...\n");
|
||||
|
|
|
@ -17,11 +17,13 @@ Environment:
|
|||
Author:
|
||||
|
||||
Klaus P. Gerlicher
|
||||
Reactos Port: Eugene Ingerman
|
||||
|
||||
Revision History:
|
||||
|
||||
10-Jul-1999: created
|
||||
15-Nov-2000: general cleanup of source files
|
||||
12/1/2001 reactos port
|
||||
|
||||
Copyright notice:
|
||||
|
||||
|
@ -37,6 +39,9 @@ Copyright notice:
|
|||
|
||||
#include <asm/system.h>
|
||||
|
||||
#include <ddk/ntddkbd.h>
|
||||
#include <ddk/ntdd8042.h>
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// GLOBALS
|
||||
////
|
||||
|
@ -44,7 +49,7 @@ Copyright notice:
|
|||
static PUCHAR pPatchAddress;
|
||||
static ULONG ulOldOffset = 0;
|
||||
static ULONG ulKeyPatchFlags;
|
||||
BOOLEAN bPatched = FALSE;
|
||||
|
||||
void (*old_handle_scancode)(UCHAR,int);
|
||||
char tempPatch[256];
|
||||
UCHAR ucBreakKey = 'D'; // key that will break into debugger in combination with CTRL
|
||||
|
@ -53,29 +58,44 @@ UCHAR ucBreakKey = 'D'; // key that will break into debugger in combination with
|
|||
// FUNCTIONS
|
||||
////
|
||||
|
||||
// the keyboard hook
|
||||
void pice_handle_scancode(UCHAR scancode,int bKeyPressed)
|
||||
//***********************************************************************************
|
||||
// PiceKbdIsr - keyboard isr hook routine.
|
||||
// IsrContext - context that we passed to keyboard driver in internal iocontrol
|
||||
// pCurrentInput, pCurrentOutput - not implemented yet
|
||||
// StatusByte - keyboard status register
|
||||
// pByte - pointer to the byte read from keyboard data port. can be changed.
|
||||
// pContinueProcessing - should keyboard driver continue processing this byte.
|
||||
//***********************************************************************************
|
||||
BOOLEAN PiceKbdIsr (
|
||||
PVOID IsrContext,
|
||||
PKEYBOARD_INPUT_DATA pCurrentInput,
|
||||
POUTPUT_PACKET pCurrentOutput,
|
||||
UCHAR StatusByte,
|
||||
PUCHAR pByte,
|
||||
PBOOLEAN pContinueProcessing,
|
||||
PKEYBOARD_SCAN_STATE pScanState
|
||||
)
|
||||
{
|
||||
UCHAR ucKey = scancode & 0x7f;
|
||||
static BOOLEAN bControl = FALSE;
|
||||
BOOLEAN bForward=TRUE;
|
||||
BOOLEAN bForward=TRUE; // should we let keyboard driver process this keystroke
|
||||
BOOLEAN isDown=!(*pByte & 0x80);
|
||||
UCHAR ucKey = *pByte & 0x7f;
|
||||
|
||||
ENTER_FUNC();
|
||||
// BUG!! should protect with spinlock since bControl is static.
|
||||
DPRINT((0,"PiceKbdIsr(%x,%u)\n",pByte,isDown));
|
||||
DPRINT((0,"PiceKbdIsr(1): bControl = %u bForward = %u bEnterNow = %u\n",bControl,bForward,bEnterNow));
|
||||
|
||||
DPRINT((0,"pice_handle_scancode(%x,%u)\n",scancode,bKeyPressed));
|
||||
DPRINT((0,"pice_handle_scancode(1): bControl = %u bForward = %u bEnterNow = %u\n",bControl,bForward,bEnterNow));
|
||||
if(bKeyPressed)
|
||||
if(isDown)
|
||||
{
|
||||
// CTRL pressed
|
||||
if(ucKey==0x1d)
|
||||
{
|
||||
bControl=TRUE;
|
||||
}
|
||||
else if(bControl==TRUE && ucKey==AsciiToScan(ucBreakKey)) // CTRL-F
|
||||
else if(bControl==TRUE && ucKey==AsciiToScan(ucBreakKey)) // CTRL-D
|
||||
{
|
||||
// fake a CTRL-F release call
|
||||
old_handle_scancode(0x1d|0x80,FALSE);
|
||||
old_handle_scancode(AsciiToScan(ucBreakKey)|0x80,FALSE);
|
||||
// fake a CTRL-D release call
|
||||
bForward=FALSE;
|
||||
bEnterNow=TRUE;
|
||||
bControl=FALSE;
|
||||
|
@ -98,80 +118,102 @@ void pice_handle_scancode(UCHAR scancode,int bKeyPressed)
|
|||
bForward=FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(bForward)
|
||||
{
|
||||
DPRINT((0,"pice_handle_scancode(): forwarding key stroke\n"));
|
||||
old_handle_scancode(scancode,bKeyPressed);
|
||||
}
|
||||
|
||||
*ContinueProcessing = bForward;
|
||||
LEAVE_FUNC();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN PatchKeyboardDriver(ULONG AddrOfKbdEvent,ULONG AddrOfScancode)
|
||||
//***********************************************************************************
|
||||
// PiceSendIoctl - send internal_io_control to the driver
|
||||
// Target - Device Object that receives control request
|
||||
// Ioctl - request
|
||||
// InputBuffer - Type3Buffer will be pointing here
|
||||
// InputBufferLength - length of inputbuffer
|
||||
//***********************************************************************************
|
||||
NTSTATUS PiceSendIoctl(PDEVICE_OBJECT Target, ULONG Ioctl,
|
||||
PVOID InputBuffer, ULONG InputBufferLength)
|
||||
{
|
||||
UCHAR ucPattern[5] = {0xE8,0x0,0x0,0x0,0x0};
|
||||
PULONG pOffset = (PULONG)&ucPattern[1];
|
||||
ULONG ulOffset,countBytes = 0;
|
||||
KEVENT event;
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
IO_STATUS_BLOCK iosb;
|
||||
PIRP irp;
|
||||
|
||||
KeInitializeEvent(&event,
|
||||
NotificationEvent,
|
||||
FALSE
|
||||
);
|
||||
|
||||
if (NULL == (irp = IoBuildDeviceIoControlRequest(Ioctl,
|
||||
Target,
|
||||
InputBuffer,
|
||||
InputBufferLength,
|
||||
0,
|
||||
0,
|
||||
TRUE,
|
||||
&event,
|
||||
&iosb))) {
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
status = IoCallDriver(Target, irp);
|
||||
|
||||
if (STATUS_PENDING == status) {
|
||||
|
||||
status = KeWaitForSingleObject(&event,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
|
||||
assert(STATUS_SUCCESS == status);
|
||||
status = iosb.Status;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
//**************************************************
|
||||
// PatchKeyboardDriver - set keyboard driver hook.
|
||||
// We use interface supported by standard keyboard drivers.
|
||||
//**************************************************
|
||||
BOOLEAN PatchKeyboardDriver(void)
|
||||
{
|
||||
PINTERNAL_I8042_HOOK_KEYBOARD phkData;
|
||||
UNICODE_STRING DevName;
|
||||
PDEVICE_OBJECT kbdDevice = NULL;
|
||||
PFILE_OBJECT FO = NULL;
|
||||
NTSTATUS status;
|
||||
|
||||
ENTER_FUNC();
|
||||
//When we have i8042 driver this should be changed!!!!!!!
|
||||
RtlInitUnicodeString(&DevName, L"\\Device\\Keyboard");
|
||||
|
||||
(void*)old_handle_scancode = AddrOfScancode;
|
||||
DPRINT((0,"handle_scancode = %X\n",AddrOfScancode));
|
||||
//Get pointer to keyboard device
|
||||
if( !NT_SUCCESS( IoGetDeviceObjectPointer( &DevName, FILE_READ_ACCESS, &FO, &kbdDevice ) ) )
|
||||
return FALSE;
|
||||
|
||||
pPatchAddress = (PUCHAR)AddrOfKbdEvent; // handle_kbd_event
|
||||
DPRINT((0,"initial patch address = %X\n",AddrOfKbdEvent));
|
||||
ulOffset = (ULONG)old_handle_scancode - ((ULONG)pPatchAddress+sizeof(ULONG)+1);
|
||||
DPRINT((0,"initial offset = %X\n",ulOffset));
|
||||
*pOffset = ulOffset;
|
||||
phkData = ExAllocatePool( PagedPool, sizeof( INTERNAL_I8042_HOOK_KEYBOARD ) );
|
||||
RtlZeroMemory( phkData, sizeof( INTERNAL_I8042_HOOK_KEYBOARD ) );
|
||||
|
||||
while((RtlCompareMemory(pPatchAddress,ucPattern,sizeof(ucPattern))!=0) &&
|
||||
(countBytes<0x1000))
|
||||
{
|
||||
/* DPRINT((0,"offset = %X\n",ulOffset));
|
||||
DPRINT((0,"patch address = %X\n",pPatchAddress));
|
||||
DPRINT((0,"pattern1 = %.2X %.2X %.2X %.2X %.2X\n",ucPattern[0],ucPattern[1],ucPattern[2],ucPattern[3],ucPattern[4]));
|
||||
DPRINT((0,"pattern2 = %.2X %.2X %.2X %.2X %.2X\n",pPatchAddress[0],pPatchAddress[1],pPatchAddress[2],pPatchAddress[3],pPatchAddress[4]));*/
|
||||
phkData->IsrRoutine = (PI8042_KEYBOARD_ISR) PiceKbdIsr;
|
||||
phkData->Context = (PVOID) NULL; //DeviceObject;
|
||||
|
||||
countBytes++;
|
||||
pPatchAddress++;
|
||||
//call keyboard device internal io control to hook keyboard input stream
|
||||
status = PiceSendIoctl( kbdDevice, IOCTL_INTERNAL_I8042_HOOK_KEYBOARD,
|
||||
phkData, sizeof( INTERNAL_I8042_HOOK_KEYBOARD ) );
|
||||
|
||||
ulOffset = (ULONG)old_handle_scancode - ((ULONG)pPatchAddress+sizeof(ULONG)+1);
|
||||
*pOffset = ulOffset;
|
||||
}
|
||||
|
||||
if(RtlCompareMemory(pPatchAddress,ucPattern,sizeof(ucPattern))==0)
|
||||
{
|
||||
DPRINT((0,"pattern found @ %x\n",pPatchAddress));
|
||||
|
||||
ulOffset = (ULONG)&pice_handle_scancode - ((ULONG)pPatchAddress+sizeof(ULONG)+1);
|
||||
ulOldOffset = *(PULONG)(pPatchAddress + 1);
|
||||
DPRINT((0,"old offset = %x new offset = %x\n",ulOldOffset,ulOffset));
|
||||
|
||||
save_flags(ulKeyPatchFlags);
|
||||
cli();
|
||||
*(PULONG)(pPatchAddress + 1) = ulOffset;
|
||||
|
||||
bPatched = TRUE;
|
||||
|
||||
restore_flags(ulKeyPatchFlags);
|
||||
DPRINT((0,"PatchKeyboardDriver(): SUCCESS!\n"));
|
||||
}
|
||||
ObDereferenceObject(FO);
|
||||
ExFreePool(phkData);
|
||||
|
||||
LEAVE_FUNC();
|
||||
|
||||
return bPatched;
|
||||
return NT_SUCCESS(status);
|
||||
}
|
||||
|
||||
void RestoreKeyboardDriver(void)
|
||||
{
|
||||
ENTER_FUNC();
|
||||
if(bPatched)
|
||||
{
|
||||
save_flags(ulKeyPatchFlags);
|
||||
cli();
|
||||
*(PULONG)(pPatchAddress + 1) = ulOldOffset;
|
||||
restore_flags(ulKeyPatchFlags);
|
||||
}
|
||||
DbgPrint("RestoreKeyboardDriver: Not Implemented yet!!!\n");
|
||||
LEAVE_FUNC();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ Copyright notice:
|
|||
#include <asm/page.h>
|
||||
#include <asm/pgtable.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/delay.h>
|
||||
#include <linux/interrupt.h>
|
||||
|
|
|
@ -97,6 +97,7 @@ NTSTATUS STDCALL pice_close(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
/* We're now ready for our next caller */
|
||||
bDeviceAlreadyOpen = FALSE;
|
||||
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -179,7 +180,7 @@ NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT DriverObject,
|
|||
|
||||
if(InitPICE()){
|
||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = pice_open;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = pice_close;
|
||||
//ei unimplemented DriverObject->MajorFunction[IRP_MJ_CLOSE] = pice_close;
|
||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = pice_ioctl;
|
||||
|
||||
RtlInitUnicodeString(&DeviceName, L"\\Device\\Pice");
|
||||
|
|
|
@ -609,7 +609,7 @@ BOOLEAN ConsoleInitSerial(void)
|
|||
GLOBAL_SCREEN_WIDTH = 80;
|
||||
GLOBAL_SCREEN_HEIGHT = 60;
|
||||
|
||||
pScreenBufferSerial = vmalloc(FRAMEBUFFER_SIZE);
|
||||
pScreenBufferSerial = PICE_malloc(FRAMEBUFFER_SIZE, NONPAGEDPOOL);
|
||||
|
||||
if(pScreenBufferSerial)
|
||||
{
|
||||
|
@ -648,7 +648,7 @@ void ConsoleShutdownSerial(void)
|
|||
FlushSerialBuffer();
|
||||
|
||||
if(pScreenBufferSerial)
|
||||
vfree(pScreenBufferSerial);
|
||||
PICE_free(pScreenBufferSerial);
|
||||
|
||||
LEAVE_FUNC();
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@ Copyright notice:
|
|||
This file may be distributed under the terms of the GNU Public License.
|
||||
|
||||
--*/
|
||||
void InstallKeyboardHook(void);
|
||||
void DeInstallKeyboardHook(void);
|
||||
//void InstallKeyboardHook(void);
|
||||
//void DeInstallKeyboardHook(void);
|
||||
void InstallGlobalKeyboardHook(void);
|
||||
void DeInstallGlobalKeyboardHook(void);
|
||||
|
||||
|
|
|
@ -35,12 +35,10 @@ Copyright notice:
|
|||
#include <linux/elf.h>
|
||||
#include "stab_gnu.h"
|
||||
|
||||
#include <linux/vmalloc.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/pgtable.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/delay.h>
|
||||
#include <linux/ctype.h>
|
||||
|
@ -1814,58 +1812,54 @@ BOOLEAN SanityCheckExports(void)
|
|||
//*************************************************************************
|
||||
BOOLEAN LoadExports(void)
|
||||
{
|
||||
struct file* pf;
|
||||
HANDLE hf;
|
||||
BOOLEAN bResult = TRUE;
|
||||
|
||||
ENTER_FUNC();
|
||||
|
||||
Print(OUTPUT_WINDOW,"pICE: loading exports...\n");
|
||||
pf = filp_open("/boot/System.map",O_RDONLY,S_IRUSR);
|
||||
|
||||
if(IS_ERR(pf))
|
||||
hf = PICE_open(L"\\SystemRoot\\symbols\\ntoskrnl.sym",OF_READ);
|
||||
/*
|
||||
if(hf)
|
||||
{
|
||||
Print(OUTPUT_WINDOW,"pICE: no System.map in /boot\n");
|
||||
pf = filp_open("/System.map",O_RDONLY,S_IRUSR);
|
||||
hf = PICE_open("/System.map",OF_READ);
|
||||
}
|
||||
*/
|
||||
|
||||
if(!IS_ERR(pf))
|
||||
if(hf)
|
||||
{
|
||||
mm_segment_t oldfs;
|
||||
size_t len;
|
||||
|
||||
if(pf->f_op)
|
||||
{
|
||||
DPRINT((0,"pf = %x pf->f_op->read @ %x\n",(ULONG)pf,(ULONG)pf->f_op->read));
|
||||
DPRINT((0,"pf->f_count = %x p->f_flags %x\n",pf->f_count,pf->f_flags));
|
||||
|
||||
len = pf->f_dentry->d_inode->i_size;
|
||||
len = PICE_len(hf);
|
||||
if(len)
|
||||
{
|
||||
DPRINT((0,"file len = %d\n",len));
|
||||
|
||||
pExports = vmalloc(len+1);
|
||||
pExports = PICE_malloc(len+1,NONPAGEDPOOL); // maybe make pool setting an option
|
||||
|
||||
DPRINT((0,"pExports = %x\n",pExports));
|
||||
|
||||
PICE_sprintf(tempSym,"pICE: exports loaded @ %x (size %x)\n",pExports,len);
|
||||
Print(OUTPUT_WINDOW,tempSym);
|
||||
|
||||
if(pExports)
|
||||
{
|
||||
oldfs = get_fs(); set_fs(KERNEL_DS);
|
||||
//oldfs = get_fs(); set_fs(KERNEL_DS);
|
||||
ulExportLen = len;
|
||||
((PUCHAR)pExports)[len]=0;
|
||||
if(len == pf->f_op->read(pf,pExports,len,&pf->f_pos))
|
||||
if(len == PICE_read(hf,pExports,len))
|
||||
{
|
||||
DPRINT((0,"success reading system map!\n"));
|
||||
PICE_sprintf(tempSym,"pICE: ntoskrnl.sym @ %x (size %x)\n",pExports,len);
|
||||
Print(OUTPUT_WINDOW,tempSym);
|
||||
}
|
||||
set_fs(oldfs);
|
||||
else
|
||||
DbgPrint("error reading ntoskrnl map!\n");
|
||||
//set_fs(oldfs);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
filp_close(pf,0);
|
||||
PICE_close(hf);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1889,7 +1883,7 @@ void UnloadExports(void)
|
|||
if(pExports)
|
||||
{
|
||||
DPRINT((0,"freeing %x\n",pExports));
|
||||
vfree(pExports);
|
||||
PICE_free(pExports);
|
||||
pExports = NULL;
|
||||
}
|
||||
LEAVE_FUNC();
|
||||
|
@ -1901,42 +1895,38 @@ void UnloadExports(void)
|
|||
//*************************************************************************
|
||||
PICE_SYMBOLFILE_HEADER* LoadSymbols(LPSTR filename)
|
||||
{
|
||||
struct file* pf;
|
||||
HANDLE hf;
|
||||
PICE_SYMBOLFILE_HEADER* pSymbols=NULL;
|
||||
|
||||
ENTER_FUNC();
|
||||
|
||||
if(ulNumSymbolsLoaded<DIM(apSymbols))
|
||||
{
|
||||
pf = filp_open(filename,O_RDONLY,S_IRUSR);
|
||||
if(!IS_ERR(pf))
|
||||
hf = PICE_open(filename,OF_READ);
|
||||
if(hf)
|
||||
{
|
||||
mm_segment_t oldfs;
|
||||
//mm_segment_t oldfs;
|
||||
size_t len;
|
||||
|
||||
DPRINT((0,"pf = %x\n",pf));
|
||||
if(pf->f_op)
|
||||
{
|
||||
DPRINT((0,"pf = %x pf->f_op->read @ %x\n",(ULONG)pf,(ULONG)pf->f_op->read));
|
||||
DPRINT((0,"pf->f_count = %x p->f_flags %x\n",pf->f_count,pf->f_flags));
|
||||
DPRINT((0,"hf = %x\n",hf));
|
||||
|
||||
len = pf->f_dentry->d_inode->i_size;
|
||||
len = PICE_len(hf);
|
||||
DPRINT((0,"file len = %d\n",len));
|
||||
|
||||
if(len)
|
||||
{
|
||||
pSymbols = vmalloc(len+1);
|
||||
pSymbols = PICE_malloc(len+1,NONPAGEDPOOL); // maybe make pool setting an option
|
||||
DPRINT((0,"pSymbols = %x\n",pSymbols));
|
||||
|
||||
if(pSymbols)
|
||||
{
|
||||
oldfs = get_fs(); set_fs(KERNEL_DS);
|
||||
if(len == pf->f_op->read(pf,(PVOID)pSymbols,len,&pf->f_pos))
|
||||
//oldfs = get_fs(); set_fs(KERNEL_DS);
|
||||
if(len == PICE_read(hf,(PVOID)pSymbols,len))
|
||||
{
|
||||
DPRINT((0,"LoadSymbols(): success reading symbols!\n"));
|
||||
DPRINT((0,"LoadSymbols(): pSymbols->magic = %X\n",pSymbols->magic));
|
||||
}
|
||||
set_fs(oldfs);
|
||||
//set_fs(oldfs);
|
||||
|
||||
|
||||
if(pSymbols->magic == PICE_MAGIC)
|
||||
|
@ -1956,14 +1946,14 @@ PICE_SYMBOLFILE_HEADER* LoadSymbols(LPSTR filename)
|
|||
{
|
||||
DPRINT((0,"LoadSymbols(): freeing %x\n",pSymbols));
|
||||
DPRINT((0,"pICE: symbols file \"%s\" corrupt\n",filename));
|
||||
vfree(pSymbols);
|
||||
PICE_free(pSymbols);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
filp_close(pf,0);
|
||||
|
||||
PICE_close(hf);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2010,7 +2000,7 @@ void UnloadSymbols()
|
|||
for(i=0;i<ulNumSymbolsLoaded;i++)
|
||||
{
|
||||
DPRINT((0,"freeing [%u] %x\n",i,apSymbols[i]));
|
||||
vfree(apSymbols[i]);
|
||||
PICE_free(apSymbols[i]);
|
||||
apSymbols[i] = NULL;
|
||||
}
|
||||
ulNumSymbolsLoaded = 0;
|
||||
|
@ -2024,7 +2014,7 @@ void UnloadSymbols()
|
|||
//*************************************************************************
|
||||
BOOLEAN LoadSymbolsFromConfig(BOOLEAN bIgnoreBootParams)
|
||||
{
|
||||
struct file* pf;
|
||||
HANDLE hf;
|
||||
LPSTR pConfig,pConfigEnd,pTemp;
|
||||
char temp[256];
|
||||
ULONG line = 1;
|
||||
|
@ -2032,29 +2022,26 @@ BOOLEAN LoadSymbolsFromConfig(BOOLEAN bIgnoreBootParams)
|
|||
|
||||
ENTER_FUNC();
|
||||
|
||||
pf = filp_open("/etc/pice.conf",O_RDONLY,0600);
|
||||
if(!IS_ERR(pf))
|
||||
hf = PICE_open("L"\\SystemRoot\\symbols\\pice.conf",OF_READ);
|
||||
if(hf)
|
||||
{
|
||||
mm_segment_t oldfs;
|
||||
//mm_segment_t oldfs;
|
||||
size_t len;
|
||||
|
||||
DPRINT((0,"pf = %x\n",pf));
|
||||
if(pf->f_op)
|
||||
{
|
||||
DPRINT((0,"pf = %x pf->f_op->read @ %x\n",(ULONG)pf,(ULONG)pf->f_op->read));
|
||||
DPRINT((0,"pf->f_count = %x p->f_flags %x\n",pf->f_count,pf->f_flags));
|
||||
DPRINT((0,"hf = %x\n",hf));
|
||||
|
||||
len = pf->f_dentry->d_inode->i_size;
|
||||
len = PICE_len(hf);
|
||||
DPRINT((0,"file len = %d\n",len));
|
||||
|
||||
if(len)
|
||||
{
|
||||
pConfig = vmalloc(len+1);
|
||||
pConfig = PICE_malloc(len+1,NONPAGEDPOOL); // maybe make pool setting an option
|
||||
DPRINT((0,"pConfig = %x\n",pConfig));
|
||||
oldfs = get_fs(); set_fs(KERNEL_DS);
|
||||
if(len == pf->f_op->read(pf,(PVOID)pConfig,len,&pf->f_pos))
|
||||
//oldfs = get_fs(); set_fs(KERNEL_DS);
|
||||
|
||||
if(len == PICE_read(pf,(PVOID)pConfig,len))
|
||||
{
|
||||
set_fs(oldfs);
|
||||
//set_fs(oldfs);
|
||||
|
||||
pConfigEnd = pConfig + len;
|
||||
|
||||
|
@ -2129,6 +2116,7 @@ BOOLEAN LoadSymbolsFromConfig(BOOLEAN bIgnoreBootParams)
|
|||
// symbol file name/path
|
||||
else
|
||||
{
|
||||
DPRINT((0,"Load symbols from file %s\n", temp));
|
||||
pSymbols = LoadSymbols(temp);
|
||||
if(pSymbols)
|
||||
{
|
||||
|
@ -2137,7 +2125,7 @@ BOOLEAN LoadSymbolsFromConfig(BOOLEAN bIgnoreBootParams)
|
|||
|
||||
pSrc = (PICE_SYMBOLFILE_SOURCE*)((ULONG)pSymbols + pSymbols->ulOffsetToSrcFiles);
|
||||
pCurrentSymbols = pSymbols;
|
||||
p = strrchr(pSrc->filename,'/');
|
||||
p = strrchr(pSrc->filename,'\\');
|
||||
if(p)
|
||||
{
|
||||
PICE_strcpy(szCurrentFile,p+1);
|
||||
|
@ -2158,17 +2146,17 @@ BOOLEAN LoadSymbolsFromConfig(BOOLEAN bIgnoreBootParams)
|
|||
}
|
||||
else
|
||||
{
|
||||
set_fs(oldfs);
|
||||
//set_fs(oldfs);
|
||||
}
|
||||
}
|
||||
}
|
||||
filp_close(pf,0);
|
||||
|
||||
PICE_close(hf);
|
||||
bResult = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT((0,"pICE: config file not found! No symbols loaded.\n"));
|
||||
DPRINT((0,"pICE: Please make sure to create a file /etc/pice.conf\n"));
|
||||
DPRINT((0,"pICE: Please make sure to create a file \\systemroot\\symbols\\pice.conf\n"));
|
||||
DPRINT((0,"pICE: if you want to have symbols for any module loaded.\n"));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,13 +36,14 @@ Copyright notice:
|
|||
#include <asm/page.h>
|
||||
#include <asm/pgtable.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/delay.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/ctype.h>
|
||||
|
||||
#include <defines.h>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// GLOBALS
|
||||
|
@ -2006,14 +2007,20 @@ UCHAR AsciiToScan(UCHAR s)
|
|||
//************************************************************************
|
||||
void outportb(USHORT port,UCHAR data)
|
||||
{
|
||||
WRITE_PORT_UCHAR(data,port);
|
||||
WRITE_PORT_UCHAR(port, data);
|
||||
}
|
||||
|
||||
void outb_p(UCHAR data, USHORT port)
|
||||
{
|
||||
WRITE_PORT_UCHAR(data,port);
|
||||
WRITE_PORT_UCHAR(port, data);
|
||||
}
|
||||
|
||||
VOID outl(ULONG data, PULONG port)
|
||||
{
|
||||
WRITE_PORT_ULONG(port, data);
|
||||
}
|
||||
|
||||
|
||||
//************************************************************************
|
||||
// inportb()
|
||||
//
|
||||
|
@ -2028,6 +2035,11 @@ UCHAR inb_p(USHORT port)
|
|||
return READ_PORT_UCHAR(port);
|
||||
}
|
||||
|
||||
ULONG inl(PULONG port)
|
||||
{
|
||||
return READ_PORT_ULONG(port);
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
// GetInitMm()
|
||||
|
@ -2079,3 +2091,109 @@ void EnablePassThrough(void)
|
|||
|
||||
restore_flags(flags);
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
// Pice_malloc - allocate memory from paged or non-paged pool
|
||||
//***********************************************************************************
|
||||
void * PICE_malloc( size_t numBytes, BOOLEAN fromPaged )
|
||||
{
|
||||
void* res = ExAllocatePool( (fromPaged)?PagedPool:NonPagedPool, numBytes );
|
||||
assert(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
// PICE_free - free memory allocated by PICE_malloc
|
||||
//***********************************************************************************
|
||||
void PICE_free( void* p )
|
||||
{
|
||||
assert( p );
|
||||
ExFreePool( p );
|
||||
}
|
||||
|
||||
long PICE_read(HANDLE hFile, LPVOID lpBuffer, long lBytes)
|
||||
{
|
||||
DWORD NumberOfBytesRead;
|
||||
IO_STATUS_BLOCK iosb;
|
||||
|
||||
assert( lpBuffer );
|
||||
|
||||
if (!NT_SUCCESS(NtReadFile(
|
||||
(HANDLE) hFile,
|
||||
NULL, NULL, NULL, &iosb,
|
||||
(LPVOID) lpBuffer,
|
||||
(DWORD) lBytes,
|
||||
NULL,
|
||||
NULL
|
||||
)))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
NumberOfBytesRead = iosb.Information;
|
||||
return NumberOfBytesRead;
|
||||
}
|
||||
|
||||
HANDLE PICE_open (LPCWSTR lpPathName, int iReadWrite)
|
||||
{
|
||||
DWORD dwAccessMask = 0;
|
||||
DWORD dwShareMode = 0;
|
||||
UNICODE_STRING TmpFileName;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
HANDLE hfile;
|
||||
NTSTATUS status;
|
||||
|
||||
if ( (iReadWrite & OF_READWRITE ) == OF_READWRITE )
|
||||
dwAccessMask = GENERIC_READ | GENERIC_WRITE;
|
||||
else if ( (iReadWrite & OF_READ ) == OF_READ )
|
||||
dwAccessMask = GENERIC_READ;
|
||||
else if ( (iReadWrite & OF_WRITE ) == OF_WRITE )
|
||||
dwAccessMask = GENERIC_WRITE;
|
||||
|
||||
if ((iReadWrite & OF_SHARE_COMPAT) == OF_SHARE_COMPAT )
|
||||
dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
|
||||
else if ((iReadWrite & OF_SHARE_DENY_NONE) == OF_SHARE_DENY_NONE)
|
||||
dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
|
||||
else if ((iReadWrite & OF_SHARE_DENY_READ) == OF_SHARE_DENY_READ)
|
||||
dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_DELETE;
|
||||
else if ((iReadWrite & OF_SHARE_DENY_WRITE) == OF_SHARE_DENY_WRITE )
|
||||
dwShareMode = FILE_SHARE_READ | FILE_SHARE_DELETE;
|
||||
else if ((iReadWrite & OF_SHARE_EXCLUSIVE) == OF_SHARE_EXCLUSIVE)
|
||||
dwShareMode = 0;
|
||||
|
||||
RtlInitUnicodeString (&TmpFileName, lpPathName);
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&TmpFileName,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
||||
status = NtOpenFile( &hfile,
|
||||
dwAccessMask,
|
||||
&ObjectAttributes,
|
||||
NULL, dwShareMode, 0);
|
||||
//BUG BUG check status!!!
|
||||
return hfile;
|
||||
}
|
||||
|
||||
int PICE_close (HANDLE hFile)
|
||||
{
|
||||
if (NT_SUCCESS( ZwClose((HANDLE)hFile)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
DbgPrint("ZwClose failed:\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t PICE_len( HANDLE hFile )
|
||||
{
|
||||
FILE_STANDARD_INFORMATION fs;
|
||||
IO_STATUS_BLOCK iosb;
|
||||
NTSTATUS status;
|
||||
|
||||
status = ZwQueryInformationFile( hFile, &iosb, &fs, sizeof fs, FileStandardInformation );
|
||||
assert(fs.EndOfFile.HighPart == 0);
|
||||
return (size_t)fs.EndOfFile.LowPart;
|
||||
}
|
||||
|
||||
|
|
|
@ -242,6 +242,10 @@ UCHAR inportb(USHORT port);
|
|||
void outb_p(UCHAR data, USHORT port);
|
||||
UCHAR inb_p(USHORT port);
|
||||
|
||||
VOID outl(ULONG l, PULONG port);
|
||||
ULONG inl(PULONG port);
|
||||
|
||||
|
||||
#define save_flags(x) __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */)
|
||||
#define restore_flags(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc")
|
||||
#define cli() __asm__ __volatile__("cli": : :"memory")
|
||||
|
@ -253,3 +257,14 @@ extern unsigned long sys_call_table[];
|
|||
struct mm_struct *GetInitMm(void);
|
||||
|
||||
void EnablePassThrough(void);
|
||||
|
||||
#define PAGEDPOOL (1)
|
||||
#define NONPAGEDPOOL (0)
|
||||
|
||||
void * PICE_malloc( size_t numBytes, BOOLEAN fromPaged );
|
||||
void PICE_free( void* p );
|
||||
|
||||
HANDLE PICE_open (LPCWSTR lpPathName, int iReadWrite);
|
||||
long PICE_read(HANDLE hFile, LPVOID lpBuffer, long lBytes);
|
||||
int PICE_close (HANDLE hFile);
|
||||
size_t PICE_len( HANDLE hFile );
|
||||
|
|
|
@ -393,11 +393,11 @@ BOOLEAN ConsoleInitVga(void)
|
|||
|
||||
#ifdef LOCAL_CONSOLE
|
||||
// the real framebuffer
|
||||
pScreenBufferHardwareVga = ioremap(0xB8000,FRAMEBUFFER_SIZE);
|
||||
pScreenBufferHardwareVga = MmMapIoSpace(0xB8000,FRAMEBUFFER_SIZE,MmWriteCombined);
|
||||
// the console
|
||||
pScreenBufferVga = vmalloc(FRAMEBUFFER_SIZE);
|
||||
pScreenBufferVga = PICE_malloc(FRAMEBUFFER_SIZE,NONPAGEDPOOL);
|
||||
// the save area
|
||||
pScreenBufferTempVga = vmalloc(FRAMEBUFFER_SIZE);
|
||||
pScreenBufferTempVga = PICE_malloc(FRAMEBUFFER_SIZE,NONPAGEDPOOL);
|
||||
#else
|
||||
outb_p(0,0x3b8);
|
||||
outb_p(0,0x3bf);
|
||||
|
@ -410,7 +410,7 @@ BOOLEAN ConsoleInitVga(void)
|
|||
}
|
||||
outb_p(0x08,0x3b8);
|
||||
|
||||
pScreenBufferVga=ioremap(0xB0000,FRAMEBUFFER_SIZE);
|
||||
pScreenBufferVga=MmMapIoSpace(0xB0000,FRAMEBUFFER_SIZE,MmWriteCombined);
|
||||
#endif
|
||||
if(pScreenBufferVga)
|
||||
{
|
||||
|
@ -446,9 +446,9 @@ void ConsoleShutdownVga(void)
|
|||
#ifdef LOCAL_CONSOLE
|
||||
if(pScreenBufferVga)
|
||||
{
|
||||
vfree(pScreenBufferVga);
|
||||
vfree(pScreenBufferTempVga);
|
||||
iounmap(pScreenBufferHardwareVga);
|
||||
PICE_free(pScreenBufferVga);
|
||||
PICE_free(pScreenBufferTempVga);
|
||||
MmUnmapIoSpace(pScreenBufferHardwareVga,FRAMEBUFFER_SIZE);
|
||||
}
|
||||
#else
|
||||
// HERC video off
|
||||
|
@ -456,7 +456,7 @@ void ConsoleShutdownVga(void)
|
|||
outb_p(0,0x3bf);
|
||||
|
||||
if(pScreenBufferVga)
|
||||
iounmap(pScreenBufferVga);
|
||||
MmUnmapIoSpace(pScreenBufferVga,FRAMEBUFFER_SIZE);
|
||||
#endif
|
||||
|
||||
LEAVE_FUNC();
|
||||
|
|
Loading…
Reference in a new issue