mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Eric's beep driver and changes to support same
svn path=/trunk/; revision=285
This commit is contained in:
parent
2e61a84b9d
commit
3a2897ef52
13 changed files with 739 additions and 63 deletions
290
reactos/drivers/dd/beep/beep.c
Normal file
290
reactos/drivers/dd/beep/beep.c
Normal file
|
@ -0,0 +1,290 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: services/dd/beep/beep.c
|
||||||
|
* PURPOSE: BEEP device driver
|
||||||
|
* PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 30/01/99
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ****************************************************************/
|
||||||
|
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <ddk/ntddbeep.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* TYEPEDEFS ***************************************************************/
|
||||||
|
|
||||||
|
typedef struct _BEEP_DEVICE_EXTENSION
|
||||||
|
{
|
||||||
|
KDPC Dpc;
|
||||||
|
KTIMER Timer;
|
||||||
|
KEVENT Event;
|
||||||
|
DWORD BeepOn;
|
||||||
|
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
|
||||||
|
|
||||||
|
|
||||||
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
VOID BeepDPC(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
|
||||||
|
{
|
||||||
|
PDEVICE_EXTENSION pDeviceExtension = DeferredContext;
|
||||||
|
|
||||||
|
DPRINT("BeepDPC() called!\n");
|
||||||
|
HalMakeBeep (0);
|
||||||
|
InterlockedExchange (&(pDeviceExtension->BeepOn), 0);
|
||||||
|
KeSetEvent (&(pDeviceExtension->Event), 0, TRUE);
|
||||||
|
|
||||||
|
DPRINT("BeepDPC() finished!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS BeepCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Handles user mode requests
|
||||||
|
* ARGUMENTS:
|
||||||
|
* DeviceObject = Device for request
|
||||||
|
* Irp = I/O request packet describing request
|
||||||
|
* RETURNS: Success or failure
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
|
if (Stack->MajorFunction == IRP_MJ_CREATE)
|
||||||
|
{
|
||||||
|
DPRINT ("BeepCreate() called!\n");
|
||||||
|
Irp->IoStatus.Information = 0;
|
||||||
|
status = STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
Irp->IoStatus.Status = status;
|
||||||
|
IoCompleteRequest(Irp,IO_NO_INCREMENT);
|
||||||
|
return(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS BeepClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Handles user mode requests
|
||||||
|
* ARGUMENTS:
|
||||||
|
* DeviceObject = Device for request
|
||||||
|
* Irp = I/O request packet describing request
|
||||||
|
* RETURNS: Success or failure
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
|
switch (Stack->MajorFunction)
|
||||||
|
{
|
||||||
|
case IRP_MJ_CLOSE:
|
||||||
|
DPRINT ("BeepClose() called!\n");
|
||||||
|
Irp->IoStatus.Information = 0;
|
||||||
|
status = STATUS_SUCCESS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Irp->IoStatus.Status = status;
|
||||||
|
IoCompleteRequest(Irp,IO_NO_INCREMENT);
|
||||||
|
return(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS BeepCleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Handles user mode requests
|
||||||
|
* ARGUMENTS:
|
||||||
|
* DeviceObject = Device for request
|
||||||
|
* Irp = I/O request packet describing request
|
||||||
|
* RETURNS: Success or failure
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
|
if (Stack->MajorFunction == IRP_MJ_CLEANUP)
|
||||||
|
{
|
||||||
|
DPRINT ("BeepCleanup() called!\n");
|
||||||
|
Irp->IoStatus.Information = 0;
|
||||||
|
status = STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
Irp->IoStatus.Status = status;
|
||||||
|
IoCompleteRequest(Irp,IO_NO_INCREMENT);
|
||||||
|
return(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS BeepDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Handles user mode requests
|
||||||
|
* ARGUMENTS:
|
||||||
|
* DeviceObject = Device for request
|
||||||
|
* Irp = I/O request packet describing request
|
||||||
|
* RETURNS: Success or failure
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
PDEVICE_EXTENSION pDeviceExtension;
|
||||||
|
PBEEP_SET_PARAMETERS pbsp;
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
|
pDeviceExtension = DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
|
if (Stack->MajorFunction == IRP_MJ_DEVICE_CONTROL)
|
||||||
|
{
|
||||||
|
DPRINT("BeepDeviceControl() called!\n");
|
||||||
|
if (Stack->Parameters.DeviceIoControl.IoControlCode == IOCTL_BEEP_SET)
|
||||||
|
{
|
||||||
|
Irp->IoStatus.Information = 0;
|
||||||
|
if (Stack->Parameters.DeviceIoControl.InputBufferLength == sizeof(BEEP_SET_PARAMETERS))
|
||||||
|
{
|
||||||
|
pbsp = (PBEEP_SET_PARAMETERS)Irp->AssociatedIrp.SystemBuffer;
|
||||||
|
|
||||||
|
if (pbsp->Frequency >= BEEP_FREQUENCY_MINIMUM &&
|
||||||
|
pbsp->Frequency <= BEEP_FREQUENCY_MAXIMUM)
|
||||||
|
{
|
||||||
|
LARGE_INTEGER DueTime = 0;
|
||||||
|
|
||||||
|
/* do the beep!! */
|
||||||
|
DPRINT("Beep:\n Freq: %lu Hz\n Dur: %lu ms\n",
|
||||||
|
pbsp->Frequency, pbsp->Duration);
|
||||||
|
|
||||||
|
if (pbsp->Duration >= 0)
|
||||||
|
{
|
||||||
|
DueTime = (LARGE_INTEGER)pbsp->Duration * 10000;
|
||||||
|
|
||||||
|
KeSetTimer (&pDeviceExtension->Timer,
|
||||||
|
-DueTime,
|
||||||
|
&pDeviceExtension->Dpc);
|
||||||
|
|
||||||
|
HalMakeBeep (pbsp->Frequency);
|
||||||
|
InterlockedExchange(&(pDeviceExtension->BeepOn), TRUE);
|
||||||
|
KeWaitForSingleObject (&(pDeviceExtension->Event),
|
||||||
|
Executive,
|
||||||
|
KernelMode,
|
||||||
|
FALSE,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
else if (pbsp->Duration == (DWORD)-1)
|
||||||
|
{
|
||||||
|
if (pDeviceExtension->BeepOn)
|
||||||
|
{
|
||||||
|
HalMakeBeep(0);
|
||||||
|
InterlockedExchange(&(pDeviceExtension->BeepOn), FALSE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HalMakeBeep(pbsp->Frequency);
|
||||||
|
InterlockedExchange(&(pDeviceExtension->BeepOn), TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("Did the beep!\n");
|
||||||
|
|
||||||
|
status = STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
Irp->IoStatus.Status = status;
|
||||||
|
IoCompleteRequest(Irp,IO_NO_INCREMENT);
|
||||||
|
return(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS BeepUnload(PDRIVER_OBJECT DriverObject)
|
||||||
|
{
|
||||||
|
DPRINT("BeepUnload() called!\n");
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Called by the system to initalize the driver
|
||||||
|
* ARGUMENTS:
|
||||||
|
* DriverObject = object describing this driver
|
||||||
|
* RegistryPath = path to our configuration entries
|
||||||
|
* RETURNS: Success or failure
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PDEVICE_OBJECT pDeviceObject;
|
||||||
|
PDEVICE_EXTENSION pDeviceExtension;
|
||||||
|
NTSTATUS ret;
|
||||||
|
ANSI_STRING ansi_device_name;
|
||||||
|
UNICODE_STRING device_name;
|
||||||
|
ANSI_STRING asymlink_name;
|
||||||
|
UNICODE_STRING symlink_name;
|
||||||
|
|
||||||
|
DbgPrint("Beep Device Driver 0.0.1\n");
|
||||||
|
|
||||||
|
RtlInitAnsiString(&ansi_device_name,"\\Device\\Beep");
|
||||||
|
RtlAnsiStringToUnicodeString(&device_name,&ansi_device_name,TRUE);
|
||||||
|
ret = IoCreateDevice(DriverObject,
|
||||||
|
sizeof(DEVICE_EXTENSION),
|
||||||
|
&device_name,
|
||||||
|
FILE_DEVICE_BEEP,
|
||||||
|
0,
|
||||||
|
FALSE,
|
||||||
|
&pDeviceObject);
|
||||||
|
if (ret!=STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* prelininary */
|
||||||
|
RtlInitAnsiString(&asymlink_name,"\\??\\Beep");
|
||||||
|
RtlAnsiStringToUnicodeString(&symlink_name,&asymlink_name,TRUE);
|
||||||
|
IoCreateSymbolicLink(&symlink_name,&device_name);
|
||||||
|
|
||||||
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = BeepCreate;
|
||||||
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = BeepClose;
|
||||||
|
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = BeepCleanup;
|
||||||
|
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = BeepDeviceControl;
|
||||||
|
DriverObject->DriverUnload = BeepUnload;
|
||||||
|
|
||||||
|
/* set up device extension */
|
||||||
|
pDeviceObject->Flags |= DO_BUFFERED_IO;
|
||||||
|
pDeviceExtension = pDeviceObject->DeviceExtension;
|
||||||
|
pDeviceExtension->BeepOn = FALSE;
|
||||||
|
|
||||||
|
KeInitializeDpc (&(pDeviceExtension->Dpc),
|
||||||
|
BeepDPC,
|
||||||
|
pDeviceExtension);
|
||||||
|
KeInitializeTimer (&(pDeviceExtension->Timer));
|
||||||
|
KeInitializeEvent (&(pDeviceExtension->Event),
|
||||||
|
SynchronizationEvent,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
1
reactos/drivers/dd/beep/makefile
Normal file
1
reactos/drivers/dd/beep/makefile
Normal file
|
@ -0,0 +1 @@
|
||||||
|
all: beep.o
|
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
#define CTL_CODE(Dev, Func, Meth, Acc) ( ((Dev)<<16) | ((Acc)<<14) | ((Func)<<2) | (Meth))
|
#define CTL_CODE(Dev, Func, Meth, Acc) ( ((Dev)<<16) | ((Acc)<<14) | ((Func)<<2) | (Meth))
|
||||||
|
|
||||||
|
|
||||||
|
#define DEVICE_TYPE_FROM_CTL_CODE(ctlCode) (((ULONG)(ctlCode&0xffff0000))>>16)
|
||||||
|
#define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003)
|
||||||
|
|
||||||
|
|
||||||
// IOCTL Parameter buffering methods
|
// IOCTL Parameter buffering methods
|
||||||
#define METHOD_BUFFERED 0
|
#define METHOD_BUFFERED 0
|
||||||
#define METHOD_IN_DIRECT 1
|
#define METHOD_IN_DIRECT 1
|
||||||
|
|
|
@ -113,5 +113,6 @@ BOOLEAN HalTranslateBusAddress(INTERFACE_TYPE InterfaceType,
|
||||||
PHYSICAL_ADDRESS BusAddress,
|
PHYSICAL_ADDRESS BusAddress,
|
||||||
PULONG AddressSpace,
|
PULONG AddressSpace,
|
||||||
PPHYSICAL_ADDRESS TranslatedAddress);
|
PPHYSICAL_ADDRESS TranslatedAddress);
|
||||||
|
BOOLEAN HalMakeBeep(ULONG Frequency);
|
||||||
VOID HalQueryRealTimeClock(PTIME_FIELDS pTime);
|
VOID HalQueryRealTimeClock(PTIME_FIELDS pTime);
|
||||||
#endif /* __INCLUDE_INTERNAL_HAL_DDK_H */
|
#endif /* __INCLUDE_INTERNAL_HAL_DDK_H */
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <ddk/ntddbeep.h>
|
||||||
|
|
||||||
static DWORD LastError;
|
static DWORD LastError;
|
||||||
|
|
||||||
|
@ -33,3 +34,40 @@ PVOID __ErrorReturnNull(ULONG ErrorCode)
|
||||||
{
|
{
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WINBOOL
|
||||||
|
STDCALL
|
||||||
|
Beep (DWORD dwFreq, DWORD dwDuration)
|
||||||
|
{
|
||||||
|
HANDLE hBeep;
|
||||||
|
BEEP_SET_PARAMETERS BeepSetParameters;
|
||||||
|
DWORD dwReturned;
|
||||||
|
|
||||||
|
hBeep = CreateFile("\\Beep",
|
||||||
|
FILE_GENERIC_READ | FILE_GENERIC_WRITE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
if (!hBeep)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* Set beep data */
|
||||||
|
BeepSetParameters.Frequency = dwFreq;
|
||||||
|
BeepSetParameters.Duration = dwDuration;
|
||||||
|
|
||||||
|
DeviceIoControl(hBeep,
|
||||||
|
IOCTL_BEEP_SET,
|
||||||
|
&BeepSetParameters,
|
||||||
|
sizeof(BEEP_SET_PARAMETERS),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
&dwReturned,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
CloseHandle (hBeep);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,13 @@ char toupper(char c)
|
||||||
return(c);
|
return(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char tolower(char c)
|
||||||
|
{
|
||||||
|
if (c>='A' && c <= 'Z')
|
||||||
|
return (c - upalpha);
|
||||||
|
return(c);
|
||||||
|
}
|
||||||
|
|
||||||
int islower(char c)
|
int islower(char c)
|
||||||
{
|
{
|
||||||
if ((c>='a') && (c<='z')) return 1;
|
if ((c>='a') && (c<='z')) return 1;
|
||||||
|
@ -38,5 +45,11 @@ int isxdigit(char c)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int iscntrl(char c)
|
||||||
|
{
|
||||||
|
if ((c >=0x00 && c <= 0x1f) || c == 0x7f);
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -541,7 +541,6 @@ STUB(cos)
|
||||||
STUB(fabs)
|
STUB(fabs)
|
||||||
STUB(floor)
|
STUB(floor)
|
||||||
STUB(isalnum)
|
STUB(isalnum)
|
||||||
STUB(iscntrl)
|
|
||||||
STUB(isgraph)
|
STUB(isgraph)
|
||||||
STUB(isprint)
|
STUB(isprint)
|
||||||
STUB(ispunct)
|
STUB(ispunct)
|
||||||
|
@ -576,4 +575,3 @@ STUB(strtol)
|
||||||
STUB(strtoul)
|
STUB(strtoul)
|
||||||
STUB(swprintf)
|
STUB(swprintf)
|
||||||
STUB(tan)
|
STUB(tan)
|
||||||
STUB(towlower)
|
|
||||||
|
|
|
@ -97,6 +97,7 @@ HalGetBusData
|
||||||
HalGetBusDataByOffset
|
HalGetBusDataByOffset
|
||||||
HalGetDmaAlignmentRequirement
|
HalGetDmaAlignmentRequirement
|
||||||
HalGetInterruptVector
|
HalGetInterruptVector
|
||||||
|
HalMakeBeep
|
||||||
HalQuerySystemInformation
|
HalQuerySystemInformation
|
||||||
HalReadDmaCounter
|
HalReadDmaCounter
|
||||||
HalSetBusData
|
HalSetBusData
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
HAL_OBJECTS = hal/x86/head.o hal/x86/irq.o hal/x86/exp.o hal/x86/isa.o \
|
HAL_OBJECTS = hal/x86/head.o hal/x86/irq.o hal/x86/exp.o hal/x86/isa.o \
|
||||||
hal/x86/pci.o hal/x86/irqhand.o hal/x86/page.o hal/x86/halinit.o \
|
hal/x86/pci.o hal/x86/irqhand.o hal/x86/page.o hal/x86/halinit.o \
|
||||||
hal/x86/irql.o hal/x86/bios32.o hal/x86/thread.o hal/x86/spinlock.o \
|
hal/x86/irql.o hal/x86/bios32.o hal/x86/thread.o hal/x86/spinlock.o \
|
||||||
hal/x86/printk.o hal/x86/mp.o hal/x86/dma.o hal/x86/bus.o hal/x86/mbr.o \
|
hal/x86/printk.o hal/x86/mp.o hal/x86/dma.o hal/x86/bus.o hal/x86/mbr.o \
|
||||||
hal/x86/sysinfo.o hal/x86/usercall.o hal/x86/time.o
|
hal/x86/sysinfo.o hal/x86/time.o hal/x86/usercall.o hal/x86/beep.o
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
|
* Fixed IO method handling 04/03/99
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
@ -31,31 +32,31 @@ NTSTATUS IoPrepareIrpBuffer(PIRP Irp,
|
||||||
{
|
{
|
||||||
DPRINT("Doing buffer i/o\n");
|
DPRINT("Doing buffer i/o\n");
|
||||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||||
ExAllocatePool(NonPagedPool,Length);
|
ExAllocatePool(NonPagedPool,Length);
|
||||||
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||||
{
|
{
|
||||||
IoFreeIrp(Irp);
|
IoFreeIrp(Irp);
|
||||||
return(STATUS_NOT_IMPLEMENTED);
|
return(STATUS_NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
/* FIXME: should copy buffer in on other ops */
|
/* FIXME: should copy buffer in on other ops */
|
||||||
if (MajorFunction == IRP_MJ_WRITE)
|
if (MajorFunction == IRP_MJ_WRITE)
|
||||||
{
|
{
|
||||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, Buffer, Length);
|
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, Buffer, Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DeviceObject->Flags & DO_DIRECT_IO)
|
if (DeviceObject->Flags & DO_DIRECT_IO)
|
||||||
{
|
{
|
||||||
DPRINT("Doing direct i/o\n");
|
DPRINT("Doing direct i/o\n");
|
||||||
|
|
||||||
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
|
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
|
||||||
if (MajorFunction == IRP_MJ_READ)
|
if (MajorFunction == IRP_MJ_READ)
|
||||||
{
|
{
|
||||||
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
|
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoReadAccess);
|
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoReadAccess);
|
||||||
}
|
}
|
||||||
Irp->UserBuffer = NULL;
|
Irp->UserBuffer = NULL;
|
||||||
Irp->AssociatedIrp.SystemBuffer = NULL;
|
Irp->AssociatedIrp.SystemBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +76,7 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
|
||||||
* UserEvent = Event used to notify the caller of completion
|
* UserEvent = Event used to notify the caller of completion
|
||||||
* IoStatusBlock (OUT) = Used to return the status of the operation
|
* IoStatusBlock (OUT) = Used to return the status of the operation
|
||||||
* DeviceToMount = Device to mount (for the IRP_MN_MOUNT_DEVICE
|
* DeviceToMount = Device to mount (for the IRP_MN_MOUNT_DEVICE
|
||||||
* request)
|
* request)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
|
@ -209,8 +210,145 @@ PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode,
|
||||||
BOOLEAN InternalDeviceIoControl,
|
BOOLEAN InternalDeviceIoControl,
|
||||||
PKEVENT Event,
|
PKEVENT Event,
|
||||||
PIO_STATUS_BLOCK IoStatusBlock)
|
PIO_STATUS_BLOCK IoStatusBlock)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Allocates and sets up an IRP to be sent to drivers
|
||||||
|
* ARGUMENTS:
|
||||||
|
* IoControlCode = Device io control code
|
||||||
|
* DeviceObject = Device object to send the irp to
|
||||||
|
* InputBuffer = Buffer from which data will be read by the driver
|
||||||
|
* InputBufferLength = Length in bytes of the input buffer
|
||||||
|
* OutputBuffer = Buffer into which data will be written by the driver
|
||||||
|
* OutputBufferLength = Length in bytes of the output buffer
|
||||||
|
* InternalDeviceIoControl = Determines weather
|
||||||
|
* IRP_MJ_INTERNAL_DEVICE_CONTROL or
|
||||||
|
* IRP_MJ_DEVICE_CONTROL will be used
|
||||||
|
* Event = Event used to notify the caller of completion
|
||||||
|
* IoStatusBlock (OUT) = Storage for the result of the operation
|
||||||
|
* RETURNS: The IRP allocated on success, or
|
||||||
|
* NULL on failure
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
PIRP Irp;
|
||||||
|
PIO_STACK_LOCATION StackPtr;
|
||||||
|
|
||||||
|
DPRINT("IoBuildDeviceIoRequest(IoControlCode %x, DeviceObject %x, "
|
||||||
|
"InputBuffer %x, InputBufferLength %x, OutputBuffer %x, "
|
||||||
|
"OutputBufferLength %x, InternalDeviceIoControl %x "
|
||||||
|
"Event %x, IoStatusBlock %x\n",IoControlCode,DeviceObject,
|
||||||
|
InputBuffer,InputBufferLength,OutputBuffer,OutputBufferLength,
|
||||||
|
InternalDeviceIoControl,Event,IoStatusBlock);
|
||||||
|
|
||||||
|
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
|
||||||
|
if (Irp==NULL)
|
||||||
|
{
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
Irp->UserEvent = Event;
|
||||||
|
Irp->UserIosb = IoStatusBlock;
|
||||||
|
|
||||||
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
|
StackPtr->MajorFunction = InternalDeviceIoControl ? IRP_MJ_INTERNAL_DEVICE_CONTROL : IRP_MJ_DEVICE_CONTROL;
|
||||||
|
StackPtr->MinorFunction = 0;
|
||||||
|
StackPtr->Flags = 0;
|
||||||
|
StackPtr->Control = 0;
|
||||||
|
StackPtr->DeviceObject = DeviceObject;
|
||||||
|
StackPtr->FileObject = NULL;
|
||||||
|
StackPtr->CompletionRoutine = NULL;
|
||||||
|
StackPtr->Parameters.DeviceIoControl.IoControlCode = IoControlCode;
|
||||||
|
StackPtr->Parameters.DeviceIoControl.InputBufferLength = InputBufferLength;
|
||||||
|
StackPtr->Parameters.DeviceIoControl.OutputBufferLength = OutputBufferLength;
|
||||||
|
|
||||||
|
if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_BUFFERED)
|
||||||
|
{
|
||||||
|
ULONG BufferLength;
|
||||||
|
DPRINT("Using METHOD_BUFFERED!\n");
|
||||||
|
|
||||||
|
BufferLength = (InputBufferLength>OutputBufferLength)?InputBufferLength:OutputBufferLength;
|
||||||
|
if (BufferLength)
|
||||||
|
{
|
||||||
|
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||||
|
ExAllocatePool(NonPagedPool,BufferLength);
|
||||||
|
|
||||||
|
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||||
|
{
|
||||||
|
IoFreeIrp(Irp);
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (InputBuffer && InputBufferLength)
|
||||||
|
{
|
||||||
|
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||||
|
InputBuffer,
|
||||||
|
InputBufferLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_IN_DIRECT)
|
||||||
|
{
|
||||||
|
DPRINT("Using METHOD_IN_DIRECT!\n");
|
||||||
|
|
||||||
|
/* build input buffer (control buffer) */
|
||||||
|
if (InputBuffer && InputBufferLength)
|
||||||
|
{
|
||||||
|
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||||
|
ExAllocatePool(NonPagedPool,InputBufferLength);
|
||||||
|
|
||||||
|
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||||
|
{
|
||||||
|
IoFreeIrp(Irp);
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||||
|
InputBuffer,
|
||||||
|
InputBufferLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* build output buffer (data transfer buffer) */
|
||||||
|
if (OutputBuffer && OutputBufferLength)
|
||||||
|
{
|
||||||
|
PMDL Mdl = IoAllocateMdl (OutputBuffer,OutputBufferLength, FALSE, FALSE, Irp);
|
||||||
|
MmProbeAndLockPages (Mdl, UserMode,IoReadAccess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_OUT_DIRECT)
|
||||||
|
{
|
||||||
|
DPRINT("Using METHOD_OUT_DIRECT!\n");
|
||||||
|
|
||||||
|
/* build input buffer (control buffer) */
|
||||||
|
if (InputBuffer && InputBufferLength)
|
||||||
|
{
|
||||||
|
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||||
|
ExAllocatePool(NonPagedPool,InputBufferLength);
|
||||||
|
|
||||||
|
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||||
|
{
|
||||||
|
IoFreeIrp(Irp);
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||||
|
InputBuffer,
|
||||||
|
InputBufferLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* build output buffer (data transfer buffer) */
|
||||||
|
if (OutputBuffer && OutputBufferLength)
|
||||||
|
{
|
||||||
|
PMDL Mdl = IoAllocateMdl (OutputBuffer,OutputBufferLength, FALSE, FALSE, Irp);
|
||||||
|
MmProbeAndLockPages (Mdl, UserMode,IoWriteAccess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_NEITHER)
|
||||||
|
{
|
||||||
|
DPRINT("Using METHOD_NEITHER!\n");
|
||||||
|
|
||||||
|
Irp->UserBuffer = OutputBuffer;
|
||||||
|
StackPtr->Parameters.DeviceIoControl.Type3InputBuffer = InputBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(Irp);
|
||||||
}
|
}
|
||||||
|
|
||||||
PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
|
PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
|
||||||
|
@ -274,31 +412,31 @@ PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
|
||||||
if (MajorFunction == IRP_MJ_READ)
|
if (MajorFunction == IRP_MJ_READ)
|
||||||
{
|
{
|
||||||
if (StartingOffset != NULL)
|
if (StartingOffset != NULL)
|
||||||
{
|
{
|
||||||
StackPtr->Parameters.Read.ByteOffset = *StartingOffset;
|
StackPtr->Parameters.Read.ByteOffset = *StartingOffset;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SET_LARGE_INTEGER_LOW_PART(StackPtr->Parameters.Read.ByteOffset,
|
SET_LARGE_INTEGER_LOW_PART(StackPtr->Parameters.Read.ByteOffset,
|
||||||
0);
|
0);
|
||||||
SET_LARGE_INTEGER_HIGH_PART(StackPtr->Parameters.Read.ByteOffset,
|
SET_LARGE_INTEGER_HIGH_PART(StackPtr->Parameters.Read.ByteOffset,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
StackPtr->Parameters.Read.Length = Length;
|
StackPtr->Parameters.Read.Length = Length;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (StartingOffset!=NULL)
|
if (StartingOffset!=NULL)
|
||||||
{
|
{
|
||||||
StackPtr->Parameters.Write.ByteOffset = *StartingOffset;
|
StackPtr->Parameters.Write.ByteOffset = *StartingOffset;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SET_LARGE_INTEGER_LOW_PART(StackPtr->Parameters.Write.ByteOffset,
|
SET_LARGE_INTEGER_LOW_PART(StackPtr->Parameters.Write.ByteOffset,
|
||||||
0);
|
0);
|
||||||
SET_LARGE_INTEGER_HIGH_PART(StackPtr->Parameters.Write.ByteOffset,
|
SET_LARGE_INTEGER_HIGH_PART(StackPtr->Parameters.Write.ByteOffset,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
StackPtr->Parameters.Write.Length = Length;
|
StackPtr->Parameters.Write.Length = Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: kernel/base/bug.c
|
* FILE: ntoskrnl/io/ioctrl.c
|
||||||
* PURPOSE: Graceful system shutdown if a bug is detected
|
* PURPOSE: Device IO control
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
|
* Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
|
* Filled in ZwDeviceIoControlFile 22/02/99
|
||||||
|
* Fixed IO method handling 08/03/99
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
@ -24,33 +28,150 @@ ULONG IoGetFunctionCodeFromCtlCode(ULONG ControlCode)
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
NtDeviceIoControlFile(
|
NtDeviceIoControlFile(
|
||||||
IN HANDLE DeviceHandle,
|
IN HANDLE DeviceHandle,
|
||||||
IN HANDLE Event OPTIONAL,
|
IN HANDLE Event OPTIONAL,
|
||||||
IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
|
IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
|
||||||
IN PVOID UserApcContext OPTIONAL,
|
IN PVOID UserApcContext OPTIONAL,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
IN ULONG IoControlCode,
|
IN ULONG IoControlCode,
|
||||||
IN PVOID InputBuffer,
|
IN PVOID InputBuffer,
|
||||||
IN ULONG InputBufferSize,
|
IN ULONG InputBufferSize,
|
||||||
OUT PVOID OutputBuffer,
|
OUT PVOID OutputBuffer,
|
||||||
IN ULONG OutputBufferSize
|
IN ULONG OutputBufferSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
return(ZwDeviceIoControlFile(DeviceHandle,
|
||||||
|
Event,
|
||||||
|
UserApcRoutine,
|
||||||
|
UserApcContext,
|
||||||
|
IoStatusBlock,
|
||||||
|
IoControlCode,
|
||||||
|
InputBuffer,
|
||||||
|
InputBufferSize,
|
||||||
|
OutputBuffer,
|
||||||
|
OutputBufferSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTES: No apc support yet!
|
||||||
|
*/
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
ZwDeviceIoControlFile(
|
ZwDeviceIoControlFile(
|
||||||
IN HANDLE DeviceHandle,
|
IN HANDLE DeviceHandle,
|
||||||
IN HANDLE Event OPTIONAL,
|
IN HANDLE Event OPTIONAL,
|
||||||
IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
|
IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
|
||||||
IN PVOID UserApcContext OPTIONAL,
|
IN PVOID UserApcContext OPTIONAL,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
IN ULONG IoControlCode,
|
IN ULONG IoControlCode,
|
||||||
IN PVOID InputBuffer,
|
IN PVOID InputBuffer,
|
||||||
IN ULONG InputBufferSize,
|
IN ULONG InputBufferSize,
|
||||||
OUT PVOID OutputBuffer,
|
OUT PVOID OutputBuffer,
|
||||||
IN ULONG OutputBufferSize
|
IN ULONG OutputBufferSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
PFILE_OBJECT FileObject;
|
||||||
|
PDEVICE_OBJECT DeviceObject;
|
||||||
|
PIRP Irp;
|
||||||
|
PIO_STACK_LOCATION StackPtr;
|
||||||
|
KEVENT KEvent;
|
||||||
|
|
||||||
|
assert(KeGetCurrentIrql()==PASSIVE_LEVEL);
|
||||||
|
|
||||||
|
DPRINT("ZwDeviceIoControlFile(DeviceHandle %x Event %x UserApcRoutine %x "
|
||||||
|
"UserApcContext %x IoStatusBlock %x InputBuffer %x "
|
||||||
|
"InputBufferSize %x OutputBuffer %x OutputBufferSize %x)\n",
|
||||||
|
DeviceHandle,Event,UserApcRoutine,UserApcContext,IoStatusBlock,
|
||||||
|
InputBuffer,InputBufferSize,OutputBuffer,OutputBufferSize);
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(DeviceHandle,
|
||||||
|
FILE_READ_DATA | FILE_WRITE_DATA,
|
||||||
|
NULL,
|
||||||
|
KernelMode,
|
||||||
|
(PVOID *) &FileObject,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceObject = FileObject->DeviceObject;
|
||||||
|
assert(DeviceObject != NULL);
|
||||||
|
|
||||||
|
KeInitializeEvent(&KEvent,NotificationEvent,TRUE);
|
||||||
|
|
||||||
|
Irp = IoBuildDeviceIoControlRequest(IoControlCode,
|
||||||
|
DeviceObject,
|
||||||
|
InputBuffer,
|
||||||
|
InputBufferSize,
|
||||||
|
OutputBuffer,
|
||||||
|
OutputBufferSize,
|
||||||
|
FALSE,
|
||||||
|
&KEvent,
|
||||||
|
IoStatusBlock);
|
||||||
|
|
||||||
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
|
StackPtr->DeviceObject = DeviceObject;
|
||||||
|
StackPtr->Parameters.DeviceIoControl.InputBufferLength = InputBufferSize;
|
||||||
|
StackPtr->Parameters.DeviceIoControl.OutputBufferLength = OutputBufferSize;
|
||||||
|
|
||||||
|
Status = IoCallDriver(DeviceObject,Irp);
|
||||||
|
if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
|
||||||
|
{
|
||||||
|
KeWaitForSingleObject(&KEvent,Executive,KernelMode,FALSE,NULL);
|
||||||
|
return(IoStatusBlock->Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_BUFFERED)
|
||||||
|
{
|
||||||
|
DPRINT ("Using METHOD_BUFFERED!\n");
|
||||||
|
|
||||||
|
/* copy output buffer back and free it */
|
||||||
|
if (Irp->AssociatedIrp.SystemBuffer)
|
||||||
|
{
|
||||||
|
if (OutputBuffer && OutputBufferSize)
|
||||||
|
{
|
||||||
|
RtlCopyMemory(OutputBuffer,
|
||||||
|
Irp->AssociatedIrp.SystemBuffer,
|
||||||
|
OutputBufferSize);
|
||||||
|
}
|
||||||
|
ExFreePool (Irp->AssociatedIrp.SystemBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_IN_DIRECT)
|
||||||
|
{
|
||||||
|
DPRINT ("Using METHOD_IN_DIRECT!\n");
|
||||||
|
|
||||||
|
/* free input buffer (control buffer) */
|
||||||
|
if (Irp->AssociatedIrp.SystemBuffer)
|
||||||
|
ExFreePool (Irp->AssociatedIrp.SystemBuffer);
|
||||||
|
|
||||||
|
/* free output buffer (data transfer buffer) */
|
||||||
|
if (Irp->MdlAddress)
|
||||||
|
IoFreeMdl (Irp->MdlAddress);
|
||||||
|
}
|
||||||
|
else if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_OUT_DIRECT)
|
||||||
|
{
|
||||||
|
DPRINT ("Using METHOD_OUT_DIRECT!\n");
|
||||||
|
|
||||||
|
/* free input buffer (control buffer) */
|
||||||
|
if (Irp->AssociatedIrp.SystemBuffer)
|
||||||
|
ExFreePool (Irp->AssociatedIrp.SystemBuffer);
|
||||||
|
|
||||||
|
/* free output buffer (data transfer buffer) */
|
||||||
|
if (Irp->MdlAddress)
|
||||||
|
IoFreeMdl (Irp->MdlAddress);
|
||||||
|
}
|
||||||
|
else if (IO_METHOD_FROM_CTL_CODE(IoControlCode) == METHOD_NEITHER)
|
||||||
|
{
|
||||||
|
DPRINT ("Using METHOD_NEITHER!\n");
|
||||||
|
|
||||||
|
/* nothing to do */
|
||||||
|
}
|
||||||
|
|
||||||
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
static CONFIGURATION_INFORMATION SystemConfigurationInformation = {0,};
|
static CONFIGURATION_INFORMATION SystemConfigurationInformation =
|
||||||
|
{0, 0, 0, 0, 0, 0, 0, FALSE, FALSE};
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include <internal/i386/segment.h>
|
#include <internal/i386/segment.h>
|
||||||
#include <internal/ps.h>
|
#include <internal/ps.h>
|
||||||
|
|
||||||
|
#include <ddk/ntddbeep.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
@ -393,8 +395,75 @@ void TstIDERead(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TstBegin()
|
|
||||||
|
NTSTATUS TstBeepDriver(DWORD dwFreq, DWORD dwDuration)
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
HANDLE hBeep;
|
||||||
|
ANSI_STRING AnsiDeviceName;
|
||||||
|
UNICODE_STRING UnicodeDeviceName;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
BEEP_SET_PARAMETERS BeepSetParameters;
|
||||||
|
|
||||||
|
RtlInitAnsiString(&AnsiDeviceName, "\\Device\\Beep");
|
||||||
|
RtlAnsiStringToUnicodeString(&UnicodeDeviceName,
|
||||||
|
&AnsiDeviceName, TRUE);
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&UnicodeDeviceName,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
Status = ZwCreateFile(&hBeep,
|
||||||
|
FILE_GENERIC_WRITE,
|
||||||
|
&ObjectAttributes,
|
||||||
|
&IoStatusBlock,
|
||||||
|
0,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
0,
|
||||||
|
FILE_OPEN,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
0);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set beep data */
|
||||||
|
BeepSetParameters.Frequency = dwFreq;
|
||||||
|
BeepSetParameters.Duration = dwDuration;
|
||||||
|
|
||||||
|
Status = ZwDeviceIoControlFile(hBeep,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&IoStatusBlock,
|
||||||
|
IOCTL_BEEP_SET,
|
||||||
|
&BeepSetParameters,
|
||||||
|
sizeof(BEEP_SET_PARAMETERS),
|
||||||
|
NULL,
|
||||||
|
0);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ZwClose (hBeep);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZwClose(hBeep);
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TstBegin(void)
|
||||||
|
{
|
||||||
|
// TstBeepDriver(440, 100);
|
||||||
|
// TstBeepDriver(880, 200);
|
||||||
|
// TstBeepDriver(440, 100);
|
||||||
ExExecuteShell();
|
ExExecuteShell();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue