Added the source code of the WinRing0 device driver.
authormoel.mich
Sun, 27 May 2012 16:50:01 +0000
changeset 347d043dac9f34e
parent 346 f652ab1e06e2
child 348 d8fa1e55acfa
Added the source code of the WinRing0 device driver.
External/WinRing0/COPYRIGHT.txt
External/WinRing0/MAKEFILE
External/WinRing0/OlsIoctl.h
External/WinRing0/OpenLibSys.c
External/WinRing0/OpenLibSys.h
External/WinRing0/OpenLibSys.rc
External/WinRing0/SOURCES
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/External/WinRing0/COPYRIGHT.txt	Sun May 27 16:50:01 2012 +0000
     1.3 @@ -0,0 +1,21 @@
     1.4 +Copyright (c) 2007-2009 OpenLibSys.org. All rights reserved.
     1.5 +
     1.6 +Redistribution and use in source and binary forms, with or without
     1.7 +modification, are permitted provided that the following conditions
     1.8 +are met:
     1.9 +1. Redistributions of source code must retain the above copyright
    1.10 +   notice, this list of conditions and the following disclaimer.
    1.11 +2. Redistributions in binary form must reproduce the above copyright
    1.12 +   notice, this list of conditions and the following disclaimer in the
    1.13 +   documentation and/or other materials provided with the distribution.
    1.14 +
    1.15 +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    1.16 +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    1.17 +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    1.18 +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    1.19 +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    1.20 +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.21 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    1.22 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    1.23 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    1.24 +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/External/WinRing0/MAKEFILE	Sun May 27 16:50:01 2012 +0000
     2.3 @@ -0,0 +1,7 @@
     2.4 +#
     2.5 +# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source
     2.6 +# file to this component.  This file merely indirects to the real make file
     2.7 +# that is shared by all the driver components of the Windows NT DDK
     2.8 +#
     2.9 +
    2.10 +!INCLUDE $(NTMAKEENV)\makefile.def
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/External/WinRing0/OlsIoctl.h	Sun May 27 16:50:01 2012 +0000
     3.3 @@ -0,0 +1,170 @@
     3.4 +//-----------------------------------------------------------------------------
     3.5 +//     Author : hiyohiyo
     3.6 +//       Mail : hiyohiyo@crystalmark.info
     3.7 +//        Web : http://openlibsys.org/
     3.8 +//    License : The modified BSD license
     3.9 +//
    3.10 +//                     Copyright 2007-2008 OpenLibSys.org. All rights reserved.
    3.11 +//-----------------------------------------------------------------------------
    3.12 +
    3.13 +#pragma once
    3.14 +
    3.15 +//-----------------------------------------------------------------------------
    3.16 +//
    3.17 +// The Device type codes form 32768 to 65535 are for customer use.
    3.18 +//
    3.19 +//-----------------------------------------------------------------------------
    3.20 +
    3.21 +#define OLS_TYPE 40000
    3.22 +
    3.23 +//-----------------------------------------------------------------------------
    3.24 +//
    3.25 +// Version Information
    3.26 +//
    3.27 +//-----------------------------------------------------------------------------
    3.28 +
    3.29 +#define OLS_DRIVER_ID							_T("WinRing0_1_2_0")
    3.30 +
    3.31 +#define OLS_DRIVER_MAJOR_VERSION				1
    3.32 +#define OLS_DRIVER_MINOR_VERSION				2
    3.33 +#define OLS_DRIVER_REVISION						0
    3.34 +#define OLS_DRIVER_RELESE						5
    3.35 +
    3.36 +#define OLS_DRIVER_VERSION \
    3.37 +	((OLS_DRIVER_MAJOR_VERSION << 24) | (OLS_DRIVER_MINOR_VERSION << 16) \
    3.38 +	| (OLS_DRIVER_REVISION << 8) | OLS_DRIVER_RELESE) 
    3.39 +
    3.40 +//-----------------------------------------------------------------------------
    3.41 +//
    3.42 +// The IOCTL function codes from 0x800 to 0xFFF are for customer use.
    3.43 +//
    3.44 +//-----------------------------------------------------------------------------
    3.45 +#define IOCTL_OLS_GET_DRIVER_VERSION \
    3.46 +	CTL_CODE(OLS_TYPE, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
    3.47 +
    3.48 +#define IOCTL_OLS_GET_REFCOUNT \
    3.49 +	CTL_CODE(OLS_TYPE, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
    3.50 +
    3.51 +#define IOCTL_OLS_READ_MSR \
    3.52 +	CTL_CODE(OLS_TYPE, 0x821, METHOD_BUFFERED, FILE_ANY_ACCESS)
    3.53 +
    3.54 +#define IOCTL_OLS_WRITE_MSR \
    3.55 +	CTL_CODE(OLS_TYPE, 0x822, METHOD_BUFFERED, FILE_ANY_ACCESS)
    3.56 +
    3.57 +#define IOCTL_OLS_READ_PMC \
    3.58 +	CTL_CODE(OLS_TYPE, 0x823, METHOD_BUFFERED, FILE_ANY_ACCESS)
    3.59 +
    3.60 +#define IOCTL_OLS_HALT \
    3.61 +	CTL_CODE(OLS_TYPE, 0x824, METHOD_BUFFERED, FILE_ANY_ACCESS)
    3.62 +
    3.63 +#define IOCTL_OLS_READ_IO_PORT \
    3.64 +	CTL_CODE(OLS_TYPE, 0x831, METHOD_BUFFERED, FILE_READ_ACCESS)
    3.65 +
    3.66 +#define IOCTL_OLS_WRITE_IO_PORT \
    3.67 +	CTL_CODE(OLS_TYPE, 0x832, METHOD_BUFFERED, FILE_WRITE_ACCESS)
    3.68 +
    3.69 +#define IOCTL_OLS_READ_IO_PORT_BYTE \
    3.70 +	CTL_CODE(OLS_TYPE, 0x833, METHOD_BUFFERED, FILE_READ_ACCESS)
    3.71 +
    3.72 +#define IOCTL_OLS_READ_IO_PORT_WORD \
    3.73 +	CTL_CODE(OLS_TYPE, 0x834, METHOD_BUFFERED, FILE_READ_ACCESS)
    3.74 +
    3.75 +#define IOCTL_OLS_READ_IO_PORT_DWORD \
    3.76 +	CTL_CODE(OLS_TYPE, 0x835, METHOD_BUFFERED, FILE_READ_ACCESS)
    3.77 +
    3.78 +#define IOCTL_OLS_WRITE_IO_PORT_BYTE \
    3.79 +	CTL_CODE(OLS_TYPE, 0x836, METHOD_BUFFERED, FILE_WRITE_ACCESS)
    3.80 +
    3.81 +#define IOCTL_OLS_WRITE_IO_PORT_WORD \
    3.82 +	CTL_CODE(OLS_TYPE, 0x837, METHOD_BUFFERED, FILE_WRITE_ACCESS)
    3.83 +
    3.84 +#define IOCTL_OLS_WRITE_IO_PORT_DWORD \
    3.85 +	CTL_CODE(OLS_TYPE, 0x838, METHOD_BUFFERED, FILE_WRITE_ACCESS)
    3.86 +
    3.87 +#define IOCTL_OLS_READ_MEMORY \
    3.88 +	CTL_CODE(OLS_TYPE, 0x841, METHOD_BUFFERED, FILE_READ_ACCESS)
    3.89 +
    3.90 +#define IOCTL_OLS_WRITE_MEMORY \
    3.91 +	CTL_CODE(OLS_TYPE, 0x842, METHOD_BUFFERED, FILE_WRITE_ACCESS)
    3.92 +
    3.93 +#define IOCTL_OLS_READ_PCI_CONFIG \
    3.94 +	CTL_CODE(OLS_TYPE, 0x851, METHOD_BUFFERED, FILE_READ_ACCESS)
    3.95 +
    3.96 +#define IOCTL_OLS_WRITE_PCI_CONFIG \
    3.97 +	CTL_CODE(OLS_TYPE, 0x852, METHOD_BUFFERED, FILE_WRITE_ACCESS)
    3.98 +
    3.99 +//-----------------------------------------------------------------------------
   3.100 +//
   3.101 +// PCI Error Code
   3.102 +//
   3.103 +//-----------------------------------------------------------------------------
   3.104 +
   3.105 +#define OLS_ERROR_PCI_BUS_NOT_EXIST		(0xE0000001L)
   3.106 +#define OLS_ERROR_PCI_NO_DEVICE			(0xE0000002L)
   3.107 +#define OLS_ERROR_PCI_WRITE_CONFIG		(0xE0000003L)
   3.108 +#define OLS_ERROR_PCI_READ_CONFIG		(0xE0000004L)
   3.109 +
   3.110 +//-----------------------------------------------------------------------------
   3.111 +//
   3.112 +// Support Macros
   3.113 +//
   3.114 +//-----------------------------------------------------------------------------
   3.115 +
   3.116 +// Bus Number, Device Number and Function Number to PCI Device Address
   3.117 +#define PciBusDevFunc(Bus, Dev, Func)	((Bus&0xFF)<<8) | ((Dev&0x1F)<<3) | (Func&7)
   3.118 +// PCI Device Address to Bus Number
   3.119 +#define PciGetBus(address)				((address>>8) & 0xFF)
   3.120 +// PCI Device Address to Device Number
   3.121 +#define PciGetDev(address)				((address>>3) & 0x1F)
   3.122 +// PCI Device Address to Function Number
   3.123 +#define PciGetFunc(address)				(address&7)
   3.124 +
   3.125 +//-----------------------------------------------------------------------------
   3.126 +//
   3.127 +// Typedef Struct
   3.128 +//
   3.129 +//-----------------------------------------------------------------------------
   3.130 +
   3.131 +#pragma pack(push,4)
   3.132 +
   3.133 +typedef struct  _OLS_WRITE_MSR_INPUT {
   3.134 +	ULONG		Register;
   3.135 +	ULARGE_INTEGER	Value;
   3.136 +}   OLS_WRITE_MSR_INPUT;
   3.137 +
   3.138 +typedef struct  _OLS_WRITE_IO_PORT_INPUT {
   3.139 +	ULONG	PortNumber; 
   3.140 +	union {
   3.141 +		ULONG   LongData;
   3.142 +		USHORT  ShortData;
   3.143 +		UCHAR   CharData;
   3.144 +	};
   3.145 +}   OLS_WRITE_IO_PORT_INPUT;
   3.146 +
   3.147 +typedef struct  _OLS_READ_PCI_CONFIG_INPUT {
   3.148 +	ULONG PciAddress;
   3.149 +	ULONG PciOffset;
   3.150 +}   OLS_READ_PCI_CONFIG_INPUT;
   3.151 +
   3.152 +typedef struct  _OLS_WRITE_PCI_CONFIG_INPUT {
   3.153 +	ULONG PciAddress;
   3.154 +	ULONG PciOffset;
   3.155 +	UCHAR Data[1];
   3.156 +}   OLS_WRITE_PCI_CONFIG_INPUT;
   3.157 +
   3.158 +typedef LARGE_INTEGER PHYSICAL_ADDRESS;
   3.159 +
   3.160 +typedef struct  _OLS_READ_MEMORY_INPUT {
   3.161 +	PHYSICAL_ADDRESS Address;
   3.162 +	ULONG UnitSize;
   3.163 +	ULONG Count;
   3.164 +}   OLS_READ_MEMORY_INPUT;
   3.165 +
   3.166 +typedef struct  _OLS_WRITE_MEMORY_INPUT {
   3.167 +	PHYSICAL_ADDRESS Address;	 
   3.168 +	ULONG UnitSize;
   3.169 +	ULONG Count;
   3.170 +	UCHAR Data[1];
   3.171 +}   OLS_WRITE_MEMORY_INPUT;
   3.172 +
   3.173 +#pragma pack(pop)
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/External/WinRing0/OpenLibSys.c	Sun May 27 16:50:01 2012 +0000
     4.3 @@ -0,0 +1,714 @@
     4.4 +//-----------------------------------------------------------------------------
     4.5 +//     Author : hiyohiyo
     4.6 +//       Mail : hiyohiyo@crystalmark.info
     4.7 +//        Web : http://openlibsys.org/
     4.8 +//    License : The modified BSD license
     4.9 +//
    4.10 +//                     Copyright 2007-2008 OpenLibSys.org. All rights reserved.
    4.11 +//-----------------------------------------------------------------------------
    4.12 +
    4.13 +#include <ntddk.h>
    4.14 +#include <stddef.h>
    4.15 +#include "OpenLibSys.h"
    4.16 +
    4.17 +//-----------------------------------------------------------------------------
    4.18 +//
    4.19 +// Global
    4.20 +//
    4.21 +//-----------------------------------------------------------------------------
    4.22 +
    4.23 +static ULONG refCount;
    4.24 +
    4.25 +//-----------------------------------------------------------------------------
    4.26 +//
    4.27 +// Classic NT driver
    4.28 +// DriverEntry / OlsDispatch / Unload
    4.29 +//
    4.30 +//-----------------------------------------------------------------------------
    4.31 +
    4.32 +NTSTATUS
    4.33 +DriverEntry(
    4.34 +	IN PDRIVER_OBJECT  DriverObject,
    4.35 +	IN PUNICODE_STRING RegistryPath
    4.36 +	)
    4.37 +
    4.38 +/*
    4.39 +
    4.40 +Return Value:
    4.41 +
    4.42 +	STATUS_SUCCESS if the driver initialized correctly, otherwise an erroror
    4.43 +	indicating the reason for failure.
    4.44 +*/
    4.45 +
    4.46 +{
    4.47 +	NTSTATUS		status;
    4.48 +	UNICODE_STRING  ntDeviceName;
    4.49 +	UNICODE_STRING  win32DeviceName;
    4.50 +	PDEVICE_OBJECT  deviceObject = NULL;
    4.51 +
    4.52 +	RtlInitUnicodeString(&ntDeviceName, NT_DEVICE_NAME);
    4.53 +
    4.54 +	status = IoCreateDevice(
    4.55 +		DriverObject,					// Our Driver Object
    4.56 +		0,								// We don't use a device extension
    4.57 +		&ntDeviceName,					// Device name 
    4.58 +		OLS_TYPE,						// Device type
    4.59 +		FILE_DEVICE_SECURE_OPEN,		// Device characteristics
    4.60 +		FALSE,							// Not an exclusive device
    4.61 +		&deviceObject );				// Returned ptr to Device Object
    4.62 +
    4.63 +	if(!NT_SUCCESS(status))
    4.64 +	{
    4.65 +		refCount = (ULONG)-1;
    4.66 +		return status;
    4.67 +	}
    4.68 +	else
    4.69 +	{
    4.70 +		refCount = 0;
    4.71 +	}
    4.72 +
    4.73 +	// Initialize the driver object with this driver's entry points.
    4.74 +	DriverObject->MajorFunction[IRP_MJ_CREATE] = OlsDispatch;
    4.75 +	DriverObject->MajorFunction[IRP_MJ_CLOSE] = OlsDispatch;
    4.76 +	DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = OlsDispatch;
    4.77 +	DriverObject->DriverUnload = Unload;
    4.78 +
    4.79 +	// Initialize a Unicode String containing the Win32 name for our device.
    4.80 +	RtlInitUnicodeString(&win32DeviceName, DOS_DEVICE_NAME);
    4.81 +
    4.82 +	// Create a symbolic link between our device name  and the Win32 name
    4.83 +	status = IoCreateSymbolicLink(&win32DeviceName, &ntDeviceName);
    4.84 +
    4.85 +	if (!NT_SUCCESS(status))
    4.86 +	{
    4.87 +		// Delete everything that this routine has allocated.
    4.88 +		IoDeleteDevice( deviceObject );
    4.89 +	}
    4.90 +
    4.91 +	return status;
    4.92 +}
    4.93 +
    4.94 +NTSTATUS
    4.95 +OlsDispatch(
    4.96 +	IN	PDEVICE_OBJECT pDO,
    4.97 +	IN	PIRP pIrp
    4.98 +	)
    4.99 +
   4.100 +/*++
   4.101 +
   4.102 +Routine Description:
   4.103 +	This routine is the dispatch handler for the driver.  It is responsible
   4.104 +	for processing the IRPs.
   4.105 +
   4.106 +Arguments:
   4.107 +	
   4.108 +	pDO - Pointer to device object.
   4.109 +
   4.110 +	pIrp - Pointer to the current IRP.
   4.111 +
   4.112 +Return Value:
   4.113 +
   4.114 +	STATUS_SUCCESS if the IRP was processed successfully, otherwise an erroror
   4.115 +	indicating the reason for failure.
   4.116 +
   4.117 +--*/
   4.118 +
   4.119 +{
   4.120 +	PIO_STACK_LOCATION pIrpStack;
   4.121 +	NTSTATUS status;
   4.122 +	int index;
   4.123 +
   4.124 +	//  Initialize the irp info field.
   4.125 +	//	  This is used to return the number of bytes transfered.
   4.126 +	pIrp->IoStatus.Information = 0;
   4.127 +	pIrpStack = IoGetCurrentIrpStackLocation(pIrp);
   4.128 +
   4.129 +	//  Set default return status
   4.130 +	status = STATUS_NOT_IMPLEMENTED;
   4.131 +
   4.132 +	// Dispatch based on major fcn code.
   4.133 +	switch(pIrpStack->MajorFunction)
   4.134 +	{
   4.135 +		case IRP_MJ_CREATE:
   4.136 +			if(refCount != (ULONG)-1){refCount++;}
   4.137 +			status = STATUS_SUCCESS;
   4.138 +			break;
   4.139 +		case IRP_MJ_CLOSE:
   4.140 +			if(refCount != (ULONG)-1){refCount--;}
   4.141 +			status = STATUS_SUCCESS;
   4.142 +			break;
   4.143 +
   4.144 +		case IRP_MJ_DEVICE_CONTROL:
   4.145 +			//  Dispatch on IOCTL
   4.146 +			switch(pIrpStack->Parameters.DeviceIoControl.IoControlCode)
   4.147 +			{
   4.148 +			case IOCTL_OLS_GET_DRIVER_VERSION:
   4.149 +				*(PULONG)pIrp->AssociatedIrp.SystemBuffer = OLS_DRIVER_VERSION;
   4.150 +				pIrp->IoStatus.Information = 4;
   4.151 +				status = STATUS_SUCCESS;
   4.152 +				break;
   4.153 +
   4.154 +			case IOCTL_OLS_GET_REFCOUNT:
   4.155 +				*(PULONG)pIrp->AssociatedIrp.SystemBuffer = refCount;
   4.156 +				pIrp->IoStatus.Information = sizeof(refCount);
   4.157 +				status = STATUS_SUCCESS;
   4.158 +				break;
   4.159 +
   4.160 +			case IOCTL_OLS_READ_MSR:
   4.161 +				status = ReadMsr(
   4.162 +					pIrp->AssociatedIrp.SystemBuffer,
   4.163 +					pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
   4.164 +					pIrp->AssociatedIrp.SystemBuffer,
   4.165 +					pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
   4.166 +					(ULONG*)&pIrp->IoStatus.Information
   4.167 +					);
   4.168 +				break;
   4.169 +			case IOCTL_OLS_WRITE_MSR:
   4.170 +				status = WriteMsr(
   4.171 +					pIrp->AssociatedIrp.SystemBuffer,
   4.172 +					pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
   4.173 +					pIrp->AssociatedIrp.SystemBuffer,
   4.174 +					pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
   4.175 +					(ULONG*)&pIrp->IoStatus.Information
   4.176 +					);
   4.177 +				break;
   4.178 +			case IOCTL_OLS_READ_PMC:
   4.179 +				status = ReadPmc(
   4.180 +					pIrp->AssociatedIrp.SystemBuffer,
   4.181 +					pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
   4.182 +					pIrp->AssociatedIrp.SystemBuffer,
   4.183 +					pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
   4.184 +					(ULONG*)&pIrp->IoStatus.Information
   4.185 +					);
   4.186 +				break;
   4.187 +			case IOCTL_OLS_HALT:
   4.188 +				__halt();
   4.189 +				status = STATUS_SUCCESS;
   4.190 +				break;
   4.191 +
   4.192 +			case IOCTL_OLS_READ_IO_PORT:
   4.193 +			case IOCTL_OLS_READ_IO_PORT_BYTE:
   4.194 +			case IOCTL_OLS_READ_IO_PORT_WORD:
   4.195 +			case IOCTL_OLS_READ_IO_PORT_DWORD:
   4.196 +				status = ReadIoPort(
   4.197 +					pIrpStack->Parameters.DeviceIoControl.IoControlCode,
   4.198 +					pIrp->AssociatedIrp.SystemBuffer,
   4.199 +					pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
   4.200 +					pIrp->AssociatedIrp.SystemBuffer,
   4.201 +					pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
   4.202 +					(ULONG*)&pIrp->IoStatus.Information
   4.203 +					);
   4.204 +				break;
   4.205 +			case IOCTL_OLS_WRITE_IO_PORT:
   4.206 +			case IOCTL_OLS_WRITE_IO_PORT_BYTE:
   4.207 +			case IOCTL_OLS_WRITE_IO_PORT_WORD:
   4.208 +			case IOCTL_OLS_WRITE_IO_PORT_DWORD:
   4.209 +				status = WriteIoPort(
   4.210 +					pIrpStack->Parameters.DeviceIoControl.IoControlCode,
   4.211 +					pIrp->AssociatedIrp.SystemBuffer,
   4.212 +					pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
   4.213 +					pIrp->AssociatedIrp.SystemBuffer,
   4.214 +					pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
   4.215 +					(ULONG*)&pIrp->IoStatus.Information
   4.216 +					);
   4.217 +				break;
   4.218 +
   4.219 +			case IOCTL_OLS_READ_PCI_CONFIG:
   4.220 +				status = ReadPciConfig(
   4.221 +					pIrp->AssociatedIrp.SystemBuffer,
   4.222 +					pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
   4.223 +					pIrp->AssociatedIrp.SystemBuffer,
   4.224 +					pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
   4.225 +					(ULONG*)&pIrp->IoStatus.Information
   4.226 +					);
   4.227 +				break;
   4.228 +			case IOCTL_OLS_WRITE_PCI_CONFIG:
   4.229 +				status = WritePciConfig(
   4.230 +					pIrp->AssociatedIrp.SystemBuffer,
   4.231 +					pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
   4.232 +					pIrp->AssociatedIrp.SystemBuffer,
   4.233 +					pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
   4.234 +					(ULONG*)&pIrp->IoStatus.Information
   4.235 +					);
   4.236 +				break;
   4.237 +
   4.238 +			case IOCTL_OLS_READ_MEMORY:
   4.239 +				status = ReadMemory(
   4.240 +					pIrp->AssociatedIrp.SystemBuffer,
   4.241 +					pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
   4.242 +					pIrp->AssociatedIrp.SystemBuffer,
   4.243 +					pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
   4.244 +					(ULONG*)&pIrp->IoStatus.Information
   4.245 +					);
   4.246 +				break;
   4.247 +			case IOCTL_OLS_WRITE_MEMORY:
   4.248 +				status = WriteMemory(
   4.249 +					pIrp->AssociatedIrp.SystemBuffer,
   4.250 +					pIrpStack->Parameters.DeviceIoControl.InputBufferLength,
   4.251 +					pIrp->AssociatedIrp.SystemBuffer,
   4.252 +					pIrpStack->Parameters.DeviceIoControl.OutputBufferLength,
   4.253 +					(ULONG*)&pIrp->IoStatus.Information
   4.254 +					);
   4.255 +				break;
   4.256 +
   4.257 +
   4.258 +			}
   4.259 +			break;
   4.260 +	}
   4.261 +
   4.262 +	// We're done with I/O request.  Record the status of the I/O action.
   4.263 +	pIrp->IoStatus.Status = status;
   4.264 +
   4.265 +	// Don't boost priority when returning since this took little time.
   4.266 +	IoCompleteRequest(pIrp, IO_NO_INCREMENT);
   4.267 +
   4.268 +	return status;
   4.269 +}
   4.270 +
   4.271 +VOID
   4.272 +Unload(
   4.273 +	PDRIVER_OBJECT DriverObject
   4.274 +	)
   4.275 +/*++
   4.276 +
   4.277 +Routine Description:
   4.278 +
   4.279 +	This routine is called by the I/O system to unload the driver.
   4.280 +
   4.281 +	Any resources previously allocated must be freed.
   4.282 +
   4.283 +Arguments:
   4.284 +
   4.285 +	DriverObject - a pointer to the object that represents our driver.
   4.286 +
   4.287 +Return Value:
   4.288 +
   4.289 +	None
   4.290 +--*/
   4.291 +
   4.292 +{
   4.293 +	PDEVICE_OBJECT deviceObject = DriverObject->DeviceObject;
   4.294 +	UNICODE_STRING win32NameString;
   4.295 +
   4.296 +	PAGED_CODE();
   4.297 +
   4.298 +	// Create counted string version of our Win32 device name.
   4.299 +	RtlInitUnicodeString(&win32NameString, DOS_DEVICE_NAME);
   4.300 +
   4.301 +	// Delete the link from our device name to a name in the Win32 namespace.
   4.302 +	IoDeleteSymbolicLink(&win32NameString);
   4.303 +
   4.304 +	if(deviceObject != NULL)
   4.305 +	{
   4.306 +		IoDeleteDevice(deviceObject);
   4.307 +	}
   4.308 +}
   4.309 +
   4.310 +//-----------------------------------------------------------------------------
   4.311 +//
   4.312 +// CPU
   4.313 +//
   4.314 +//-----------------------------------------------------------------------------
   4.315 +
   4.316 +NTSTATUS
   4.317 +ReadMsr(	void	*lpInBuffer, 
   4.318 +			ULONG	nInBufferSize, 
   4.319 +			void	*lpOutBuffer, 
   4.320 +			ULONG	nOutBufferSize, 
   4.321 +			ULONG	*lpBytesReturned)
   4.322 +{
   4.323 +	__try
   4.324 +	{
   4.325 +		ULONGLONG data = __readmsr(*(ULONG*)lpInBuffer);
   4.326 +		memcpy((PULONG)lpOutBuffer, &data, 8);
   4.327 +		*lpBytesReturned = 8;
   4.328 +		return STATUS_SUCCESS;
   4.329 +	}
   4.330 +	__except(EXCEPTION_EXECUTE_HANDLER)
   4.331 +	{
   4.332 +		*lpBytesReturned = 0;
   4.333 +		return STATUS_UNSUCCESSFUL;
   4.334 +	}
   4.335 +}
   4.336 +
   4.337 +NTSTATUS
   4.338 +WriteMsr(	void	*lpInBuffer, 
   4.339 +			ULONG	nInBufferSize, 
   4.340 +			void	*lpOutBuffer, 
   4.341 +			ULONG	nOutBufferSize, 
   4.342 +			ULONG	*lpBytesReturned)
   4.343 +{
   4.344 +	__try
   4.345 +	{
   4.346 +		OLS_WRITE_MSR_INPUT* param;
   4.347 +		param = (OLS_WRITE_MSR_INPUT*)lpInBuffer;
   4.348 +
   4.349 +		__writemsr(param->Register, param->Value.QuadPart);
   4.350 +		*lpBytesReturned = 0;
   4.351 +		return STATUS_SUCCESS;
   4.352 +	}
   4.353 +	__except(EXCEPTION_EXECUTE_HANDLER)
   4.354 +	{
   4.355 +		*lpBytesReturned = 0;
   4.356 +		return STATUS_UNSUCCESSFUL;
   4.357 +	}
   4.358 +}
   4.359 +
   4.360 +NTSTATUS
   4.361 +ReadPmc(	void	*lpInBuffer, 
   4.362 +			ULONG	nInBufferSize, 
   4.363 +			void	*lpOutBuffer, 
   4.364 +			ULONG	nOutBufferSize, 
   4.365 +			ULONG	*lpBytesReturned)
   4.366 +{
   4.367 +	__try
   4.368 +	{
   4.369 +		ULONGLONG data = __readpmc(*(ULONG*)lpInBuffer);
   4.370 +		memcpy((PULONG)lpOutBuffer, &data, 8);
   4.371 +		*lpBytesReturned = 8;
   4.372 +		return STATUS_SUCCESS;
   4.373 +	}
   4.374 +	__except(EXCEPTION_EXECUTE_HANDLER)
   4.375 +	{
   4.376 +		*lpBytesReturned = 0;
   4.377 +		return STATUS_UNSUCCESSFUL;
   4.378 +	}
   4.379 +}
   4.380 +
   4.381 +//-----------------------------------------------------------------------------
   4.382 +//
   4.383 +// IO Port
   4.384 +//
   4.385 +//-----------------------------------------------------------------------------
   4.386 +
   4.387 +NTSTATUS
   4.388 +ReadIoPort( ULONG	ioControlCode,
   4.389 +			void	*lpInBuffer, 
   4.390 +			ULONG	nInBufferSize, 
   4.391 +			void	*lpOutBuffer, 
   4.392 +			ULONG	nOutBufferSize, 
   4.393 +			ULONG	*lpBytesReturned)
   4.394 +{
   4.395 +	ULONG nPort = *(ULONG*)lpInBuffer;
   4.396 +
   4.397 +	switch(ioControlCode)
   4.398 +	{
   4.399 +		case IOCTL_OLS_READ_IO_PORT_BYTE:
   4.400 +			*(PUCHAR)lpOutBuffer = READ_PORT_UCHAR((PUCHAR)(ULONG_PTR)nPort);
   4.401 +			break;
   4.402 +		case IOCTL_OLS_READ_IO_PORT_WORD:
   4.403 +			*(PUSHORT)lpOutBuffer = READ_PORT_USHORT((PUSHORT)(ULONG_PTR)nPort);
   4.404 +			break;
   4.405 +		case IOCTL_OLS_READ_IO_PORT_DWORD:
   4.406 +			*(PULONG)lpOutBuffer = READ_PORT_ULONG((PULONG)(ULONG_PTR)nPort);
   4.407 +			break;
   4.408 +		default:
   4.409 +			*lpBytesReturned = 0;
   4.410 +			return STATUS_INVALID_PARAMETER;
   4.411 +			break;
   4.412 +	}
   4.413 +	
   4.414 +	*lpBytesReturned = nInBufferSize;
   4.415 +	return STATUS_SUCCESS;
   4.416 +}
   4.417 +
   4.418 +NTSTATUS
   4.419 +WriteIoPort(ULONG	ioControlCode,
   4.420 +			void	*lpInBuffer, 
   4.421 +			ULONG	nInBufferSize, 
   4.422 +			void	*lpOutBuffer, 
   4.423 +			ULONG	nOutBufferSize, 
   4.424 +			ULONG	*lpBytesReturned)
   4.425 +{
   4.426 +	ULONG nPort;
   4.427 +	OLS_WRITE_IO_PORT_INPUT* param;
   4.428 +	
   4.429 +	param = (OLS_WRITE_IO_PORT_INPUT*)lpInBuffer;
   4.430 +	nPort = param->PortNumber;
   4.431 +
   4.432 +	switch(ioControlCode)
   4.433 +	{
   4.434 +
   4.435 +		case IOCTL_OLS_WRITE_IO_PORT_BYTE:
   4.436 +			WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)nPort, param->CharData);
   4.437 +			break;
   4.438 +		case IOCTL_OLS_WRITE_IO_PORT_WORD:
   4.439 +			WRITE_PORT_USHORT((PUSHORT)(ULONG_PTR)nPort, param->ShortData);
   4.440 +			break;
   4.441 +		case IOCTL_OLS_WRITE_IO_PORT_DWORD:
   4.442 +			WRITE_PORT_ULONG((PULONG)(ULONG_PTR)nPort, param->LongData);
   4.443 +			break;
   4.444 +		default:
   4.445 +			return STATUS_INVALID_PARAMETER;
   4.446 +			break;
   4.447 +	}
   4.448 +
   4.449 +	return STATUS_SUCCESS;
   4.450 +}
   4.451 +
   4.452 +//-----------------------------------------------------------------------------
   4.453 +//
   4.454 +// PCI
   4.455 +//
   4.456 +//-----------------------------------------------------------------------------
   4.457 +
   4.458 +NTSTATUS
   4.459 +ReadPciConfig(	void	*lpInBuffer, 
   4.460 +				ULONG	nInBufferSize, 
   4.461 +				void	*lpOutBuffer, 
   4.462 +				ULONG	nOutBufferSize, 
   4.463 +				ULONG	*lpBytesReturned)
   4.464 +{
   4.465 +	OLS_READ_PCI_CONFIG_INPUT *param;
   4.466 +	NTSTATUS status;
   4.467 +
   4.468 +	if(nInBufferSize != sizeof(OLS_READ_PCI_CONFIG_INPUT))
   4.469 +	{
   4.470 +		return STATUS_INVALID_PARAMETER;
   4.471 +	}
   4.472 +	param = (OLS_READ_PCI_CONFIG_INPUT *)lpInBuffer;
   4.473 +
   4.474 +	status = pciConfigRead(param->PciAddress, param->PciOffset,
   4.475 +						lpOutBuffer, nOutBufferSize);
   4.476 +
   4.477 +	if(status == STATUS_SUCCESS)
   4.478 +	{
   4.479 +		*lpBytesReturned = nOutBufferSize;
   4.480 +	}
   4.481 +	else
   4.482 +	{
   4.483 +		*lpBytesReturned = 0;
   4.484 +	}
   4.485 +
   4.486 +	return status;
   4.487 +}
   4.488 +
   4.489 +NTSTATUS
   4.490 +WritePciConfig(	void *lpInBuffer, 
   4.491 +				ULONG nInBufferSize, 
   4.492 +				void *lpOutBuffer, 
   4.493 +				ULONG nOutBufferSize, 
   4.494 +				ULONG *lpBytesReturned)
   4.495 +
   4.496 +{
   4.497 +	OLS_WRITE_PCI_CONFIG_INPUT *param;
   4.498 +	ULONG writeSize;
   4.499 +	NTSTATUS status;
   4.500 +
   4.501 +	if(nInBufferSize < offsetof(OLS_WRITE_PCI_CONFIG_INPUT, Data))
   4.502 +	{
   4.503 +		return STATUS_INVALID_PARAMETER;
   4.504 +	}
   4.505 +
   4.506 +	param = (OLS_WRITE_PCI_CONFIG_INPUT *)lpInBuffer;
   4.507 +	writeSize = nInBufferSize - offsetof(OLS_WRITE_PCI_CONFIG_INPUT, Data);
   4.508 +	
   4.509 +	*lpBytesReturned = 0;
   4.510 +
   4.511 +	return pciConfigWrite(param->PciAddress, param->PciOffset,
   4.512 +							&param->Data, writeSize);
   4.513 +
   4.514 +}
   4.515 +
   4.516 +//-----------------------------------------------------------------------------
   4.517 +//
   4.518 +// Support Function
   4.519 +//
   4.520 +//-----------------------------------------------------------------------------
   4.521 +
   4.522 +NTSTATUS pciConfigRead(ULONG pciAddress, ULONG offset, void *data, int length)
   4.523 +{
   4.524 +	PCI_SLOT_NUMBER slot;
   4.525 +	int error;
   4.526 +	ULONG busNumber;
   4.527 +
   4.528 +	busNumber = PciGetBus(pciAddress);
   4.529 +	slot.u.AsULONG = 0;
   4.530 +	slot.u.bits.DeviceNumber = PciGetDev(pciAddress);
   4.531 +	slot.u.bits.FunctionNumber = PciGetFunc(pciAddress);
   4.532 +	error =	HalGetBusDataByOffset(PCIConfiguration, busNumber, slot.u.AsULONG,
   4.533 +									data, offset, length);
   4.534 +
   4.535 +	if(error == 0)
   4.536 +	{
   4.537 +		return OLS_ERROR_PCI_BUS_NOT_EXIST;
   4.538 +	}
   4.539 +	else if(length != 2 && error == 2)
   4.540 +	{
   4.541 +		return OLS_ERROR_PCI_NO_DEVICE;
   4.542 +	}
   4.543 +	else if(length != error)
   4.544 +	{
   4.545 +		return OLS_ERROR_PCI_READ_CONFIG;
   4.546 +	}
   4.547 +
   4.548 +	return STATUS_SUCCESS;
   4.549 +}
   4.550 +
   4.551 +NTSTATUS pciConfigWrite(ULONG pciAddress, ULONG offset, void *data, int length)
   4.552 +{
   4.553 +	PCI_SLOT_NUMBER slot;
   4.554 +	int error;
   4.555 +	ULONG busNumber;
   4.556 +
   4.557 +	busNumber = PciGetBus(pciAddress);
   4.558 +
   4.559 +	slot.u.AsULONG = 0;
   4.560 +	slot.u.bits.DeviceNumber = PciGetDev(pciAddress);
   4.561 +	slot.u.bits.FunctionNumber = PciGetFunc(pciAddress);
   4.562 +	error = HalSetBusDataByOffset(PCIConfiguration, busNumber, slot.u.AsULONG,
   4.563 +									data, offset, length);
   4.564 +
   4.565 +	if(error != length)
   4.566 +	{
   4.567 +		return OLS_ERROR_PCI_WRITE_CONFIG;
   4.568 +	}
   4.569 +
   4.570 +	return STATUS_SUCCESS;
   4.571 +}
   4.572 +
   4.573 +
   4.574 +//-----------------------------------------------------------------------------
   4.575 +//
   4.576 +// Physical Memory
   4.577 +//
   4.578 +//-----------------------------------------------------------------------------
   4.579 +
   4.580 +NTSTATUS
   4.581 +ReadMemory(	void	*lpInBuffer, 
   4.582 +			ULONG	nInBufferSize, 
   4.583 +			void	*lpOutBuffer, 
   4.584 +			ULONG	nOutBufferSize, 
   4.585 +			ULONG	*lpBytesReturned)
   4.586 +{
   4.587 +	OLS_READ_MEMORY_INPUT *param;
   4.588 +	ULONG	size;
   4.589 +	PHYSICAL_ADDRESS address;
   4.590 +	PVOID	maped;
   4.591 +	BOOLEAN	error;
   4.592 +
   4.593 +	if(nInBufferSize != sizeof(OLS_READ_MEMORY_INPUT))
   4.594 +	{
   4.595 +		return STATUS_INVALID_PARAMETER;
   4.596 +	}
   4.597 +
   4.598 +	param = (OLS_READ_MEMORY_INPUT *)lpInBuffer;
   4.599 +	size = param->UnitSize * param->Count;
   4.600 +
   4.601 +	if(nOutBufferSize < size)
   4.602 +	{
   4.603 +		return STATUS_INVALID_PARAMETER;
   4.604 +	}
   4.605 +
   4.606 +	address.QuadPart = param->Address.QuadPart;
   4.607 +
   4.608 +#ifndef _PHYSICAL_MEMORY_SUPPORT
   4.609 +
   4.610 +	if(0x000C0000 > address.QuadPart 
   4.611 +	|| (address.QuadPart + size - 1) > 0x000FFFFF)
   4.612 +	{
   4.613 +		return STATUS_INVALID_PARAMETER;
   4.614 +	}
   4.615 +
   4.616 +#endif
   4.617 +
   4.618 +	maped = MmMapIoSpace(address, size, FALSE);
   4.619 +
   4.620 +	error = FALSE;
   4.621 +	switch(param->UnitSize){
   4.622 +		case 1:
   4.623 +			READ_REGISTER_BUFFER_UCHAR(maped, lpOutBuffer, param->Count);
   4.624 +			break;
   4.625 +		case 2:
   4.626 +			READ_REGISTER_BUFFER_USHORT(maped, lpOutBuffer, param->Count);
   4.627 +			break;
   4.628 +		case 4:
   4.629 +			READ_REGISTER_BUFFER_ULONG(maped, lpOutBuffer, param->Count);
   4.630 +			break;
   4.631 +		default:
   4.632 +			error = TRUE;
   4.633 +			break;
   4.634 +	}
   4.635 +
   4.636 +	MmUnmapIoSpace(maped, size);
   4.637 +
   4.638 +	if(error)
   4.639 +	{
   4.640 +		return STATUS_INVALID_PARAMETER;
   4.641 +	}
   4.642 +
   4.643 +	*lpBytesReturned = nOutBufferSize;
   4.644 +
   4.645 +	return STATUS_SUCCESS;
   4.646 +}
   4.647 +
   4.648 +NTSTATUS
   4.649 +WriteMemory(void	*lpInBuffer, 
   4.650 +			ULONG	nInBufferSize, 
   4.651 +			void	*lpOutBuffer, 
   4.652 +			ULONG	nOutBufferSize, 
   4.653 +			ULONG	*lpBytesReturned)
   4.654 +{
   4.655 +#ifdef _PHYSICAL_MEMORY_SUPPORT
   4.656 +
   4.657 +	OLS_WRITE_MEMORY_INPUT *param;
   4.658 +	ULONG size;
   4.659 +	PHYSICAL_ADDRESS address;
   4.660 +	PVOID	maped;
   4.661 +	BOOLEAN	error;
   4.662 +
   4.663 +	if(nInBufferSize < offsetof(OLS_WRITE_MEMORY_INPUT, Data))
   4.664 +	{
   4.665 +		return STATUS_INVALID_PARAMETER;
   4.666 +	}
   4.667 +
   4.668 +	param = (OLS_WRITE_MEMORY_INPUT *)lpInBuffer;
   4.669 +
   4.670 +	size = param->UnitSize * param->Count;
   4.671 +	if (nInBufferSize < size + offsetof(OLS_WRITE_MEMORY_INPUT, Data))
   4.672 +	{
   4.673 +		return STATUS_INVALID_PARAMETER;
   4.674 +	}
   4.675 +
   4.676 +	address.QuadPart = param->Address.QuadPart;
   4.677 +
   4.678 +	maped = MmMapIoSpace(address, size, FALSE);
   4.679 +
   4.680 +	error = FALSE;
   4.681 +	switch(param->UnitSize){
   4.682 +		case 1:
   4.683 +			WRITE_REGISTER_BUFFER_UCHAR(maped, 
   4.684 +										(UCHAR*)&param->Data, param->Count);
   4.685 +			break;
   4.686 +		case 2:
   4.687 +			WRITE_REGISTER_BUFFER_USHORT(maped,
   4.688 +										(USHORT*)&param->Data, param->Count);
   4.689 +			break;
   4.690 +		case 4:
   4.691 +			WRITE_REGISTER_BUFFER_ULONG(maped,
   4.692 +										(ULONG*)&param->Data, param->Count);
   4.693 +			break;
   4.694 +		default:
   4.695 +			error = TRUE;
   4.696 +			break;
   4.697 +	}
   4.698 +
   4.699 +	MmUnmapIoSpace(maped, size);
   4.700 +
   4.701 +	if(error)
   4.702 +	{
   4.703 +		return STATUS_INVALID_PARAMETER;
   4.704 +	}
   4.705 +
   4.706 +	*lpBytesReturned = 0;
   4.707 +
   4.708 +	return STATUS_SUCCESS;
   4.709 +
   4.710 +#else
   4.711 +
   4.712 +	*lpBytesReturned = 0;
   4.713 +	
   4.714 +	return STATUS_INVALID_PARAMETER;
   4.715 +
   4.716 +#endif
   4.717 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/External/WinRing0/OpenLibSys.h	Sun May 27 16:50:01 2012 +0000
     5.3 @@ -0,0 +1,131 @@
     5.4 +//-----------------------------------------------------------------------------
     5.5 +//     Author : hiyohiyo
     5.6 +//       Mail : hiyohiyo@crystalmark.info
     5.7 +//        Web : http://openlibsys.org/
     5.8 +//    License : The modified BSD license
     5.9 +//
    5.10 +//                     Copyright 2007-2008 OpenLibSys.org. All rights reserved.
    5.11 +//-----------------------------------------------------------------------------
    5.12 +
    5.13 +#include <ntddk.h>
    5.14 +#include <devioctl.h>
    5.15 +#include "OlsIoctl.h"
    5.16 +
    5.17 +//-----------------------------------------------------------------------------
    5.18 +//
    5.19 +// Device Name
    5.20 +//
    5.21 +//-----------------------------------------------------------------------------
    5.22 +
    5.23 +#define NT_DEVICE_NAME	L"\\Device\\WinRing0_1_2_0"
    5.24 +#define DOS_DEVICE_NAME	L"\\DosDevices\\WinRing0_1_2_0"
    5.25 +
    5.26 +//-----------------------------------------------------------------------------
    5.27 +//
    5.28 +// Function Prototypes
    5.29 +//
    5.30 +//-----------------------------------------------------------------------------
    5.31 +
    5.32 +NTSTATUS	DriverEntry(
    5.33 +				IN PDRIVER_OBJECT DriverObject,
    5.34 +				IN PUNICODE_STRING RegistryPath
    5.35 +			);
    5.36 +
    5.37 +NTSTATUS	OlsDispatch(
    5.38 +				IN PDEVICE_OBJECT pDO,
    5.39 +				IN PIRP pIrp
    5.40 +			);
    5.41 +
    5.42 +VOID		Unload(
    5.43 +				IN PDRIVER_OBJECT DriverObject
    5.44 +			);
    5.45 +
    5.46 +//-----------------------------------------------------------------------------
    5.47 +//
    5.48 +// Function Prototypes for Control Code
    5.49 +//
    5.50 +//-----------------------------------------------------------------------------
    5.51 +
    5.52 +NTSTATUS	ReadMsr(
    5.53 +				void *lpInBuffer, 
    5.54 +				ULONG nInBufferSize, 
    5.55 +				void *lpOutBuffer, 
    5.56 +				ULONG nOutBufferSize, 
    5.57 +				ULONG *lpBytesReturned
    5.58 +			);
    5.59 +
    5.60 +NTSTATUS	WriteMsr(
    5.61 +				void *lpInBuffer, 
    5.62 +				ULONG nInBufferSize, 
    5.63 +				void *lpOutBuffer, 
    5.64 +				ULONG nOutBufferSize, 
    5.65 +				ULONG *lpBytesReturned
    5.66 +			);
    5.67 +			
    5.68 +NTSTATUS	ReadPmc(
    5.69 +				void *lpInBuffer, 
    5.70 +				ULONG nInBufferSize, 
    5.71 +				void *lpOutBuffer, 
    5.72 +				ULONG nOutBufferSize, 
    5.73 +				ULONG *lpBytesReturned
    5.74 +			);
    5.75 +
    5.76 +NTSTATUS	ReadIoPort(
    5.77 +				ULONG ioControlCode,
    5.78 +				void *lpInBuffer, 
    5.79 +				ULONG nInBufferSize, 
    5.80 +				void *lpOutBuffer, 
    5.81 +				ULONG nOutBufferSize, 
    5.82 +				ULONG *lpBytesReturned
    5.83 +			);
    5.84 +
    5.85 +NTSTATUS	WriteIoPort(
    5.86 +				ULONG ioControlCode,
    5.87 +				void *lpInBuffer, 
    5.88 +				ULONG nInBufferSize, 
    5.89 +				void *lpOutBuffer, 
    5.90 +				ULONG nOutBufferSize, 
    5.91 +				ULONG *lpBytesReturned
    5.92 +			);
    5.93 +
    5.94 +NTSTATUS	ReadPciConfig(
    5.95 +				void *lpInBuffer, 
    5.96 +				ULONG nInBufferSize, 
    5.97 +				void *lpOutBuffer, 
    5.98 +				ULONG nOutBufferSize, 
    5.99 +				ULONG *lpBytesReturned
   5.100 +			);
   5.101 +
   5.102 +NTSTATUS	WritePciConfig(
   5.103 +				void *lpInBuffer, 
   5.104 +				ULONG nInBufferSize, 
   5.105 +				void *lpOutBuffer, 
   5.106 +				ULONG nOutBufferSize, 
   5.107 +				ULONG *lpBytesReturned
   5.108 +			);
   5.109 +			
   5.110 +NTSTATUS	ReadMemory(
   5.111 +				void *lpInBuffer, 
   5.112 +				ULONG nInBufferSize, 
   5.113 +				void *lpOutBuffer, 
   5.114 +				ULONG nOutBufferSize, 
   5.115 +				ULONG *lpBytesReturned
   5.116 +			);
   5.117 +
   5.118 +NTSTATUS	WriteMemory(
   5.119 +				void *lpInBuffer, 
   5.120 +				ULONG nInBufferSize, 
   5.121 +				void *lpOutBuffer, 
   5.122 +				ULONG nOutBufferSize, 
   5.123 +				ULONG *lpBytesReturned
   5.124 +			);
   5.125 +
   5.126 +
   5.127 +//-----------------------------------------------------------------------------
   5.128 +//
   5.129 +// Support Function Prototypes
   5.130 +//
   5.131 +//-----------------------------------------------------------------------------
   5.132 +
   5.133 +NTSTATUS pciConfigRead(ULONG pciAddress, ULONG offset, void *data, int length);
   5.134 +NTSTATUS pciConfigWrite(ULONG pciAddress, ULONG offset, void *data, int length);
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/External/WinRing0/OpenLibSys.rc	Sun May 27 16:50:01 2012 +0000
     6.3 @@ -0,0 +1,43 @@
     6.4 +#include <windows.h>
     6.5 +#include <ntverp.h>
     6.6 +
     6.7 +#define VER_FILETYPE                VFT_DRV
     6.8 +#define VER_FILESUBTYPE             VFT2_DRV_SYSTEM
     6.9 +
    6.10 +#define VER_FILEDESCRIPTION_STR     "WinRing0"
    6.11 +#define VER_INTERNALNAME_STR        "WinRing0.sys"
    6.12 +
    6.13 +/////////////////////////////////////////////////////////////////////////////
    6.14 +//
    6.15 +// Version
    6.16 +//
    6.17 +
    6.18 +VS_VERSION_INFO VERSIONINFO
    6.19 + FILEVERSION 1, 2, 0, 5
    6.20 + PRODUCTVERSION 1, 2, 0, 5
    6.21 + FILEFLAGSMASK 0x3fL
    6.22 + FILEFLAGS 0x0L
    6.23 + FILEOS 0x40004L
    6.24 + FILETYPE 0x2L
    6.25 + FILESUBTYPE 0x0L
    6.26 +BEGIN
    6.27 +    BLOCK "StringFileInfo"
    6.28 +    BEGIN
    6.29 +        BLOCK "041104b0"
    6.30 +        BEGIN
    6.31 +            VALUE "Comments", "The modified BSD license\0"
    6.32 +            VALUE "CompanyName", "OpenLibSys.org\0"
    6.33 +            VALUE "FileDescription", "WinRing0\0"
    6.34 +            VALUE "FileVersion", "1.2.0.5\0"
    6.35 +            VALUE "InternalName", "WinRing0.sys\0"
    6.36 +            VALUE "LegalCopyright", "Copyright (C) 2007-2008 OpenLibSys.org. All rights reserved.\0"
    6.37 +            VALUE "OriginalFilename", "WinRing0.sys\0"
    6.38 +            VALUE "ProductName", "WinRing0\0"
    6.39 +            VALUE "ProductVersion", "1.2.0.5\0"
    6.40 +        END
    6.41 +    END
    6.42 +    BLOCK "VarFileInfo"
    6.43 +    BEGIN
    6.44 +        VALUE "Translation", 0x411, 1200
    6.45 +    END
    6.46 +END
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/External/WinRing0/SOURCES	Sun May 27 16:50:01 2012 +0000
     7.3 @@ -0,0 +1,7 @@
     7.4 +TARGETNAME=WinRing0
     7.5 +TARGETPATH=lib
     7.6 +TARGETTYPE=DRIVER
     7.7 +
     7.8 +INCLUDES=..\
     7.9 +
    7.10 +SOURCES=OpenLibSys.c OpenLibSys.rc