16 #pragma alloc_text (INIT, DriverEntry) 17 #pragma alloc_text (PAGE, Bus_AddDevice) 49 DPRINT(
"#################### Bus_CreateClose Creating FDO Device ####################\n");
59 DPRINT1(
"IoCreateDevice() failed with status 0x%X\n",
status);
129 if (
NULL == deviceName) {
130 DPRINT1(
"AddDevice: no memory to alloc for deviceName(0x%x)\n", nameLength);
147 DPRINT(
"AddDevice: %p to %p->%p (%ws) \n",
184 Irp->IoStatus.Information = 0;
216 RtlCopyMemory(
Irp->AssociatedIrp.SystemBuffer, &ButtonEvent,
sizeof(ButtonEvent));
218 Irp->IoStatus.Information =
sizeof(
ULONG);
244 Irp->IoStatus.Information = 0;
248 switch (irpStack->
Parameters.DeviceIoControl.IoControlCode)
256 if (irpStack->
Parameters.DeviceIoControl.OutputBufferLength <
sizeof(
ULONG))
264 DPRINT1(
"Lid button reported to power manager\n");
275 DPRINT(
"Fixed power button reported to power manager\n");
280 DPRINT(
"Fixed sleep button reported to power manager\n");
286 DPRINT(
"Control method power button reported to power manager\n");
291 DPRINT(
"Control method sleep reported to power manager\n");
296 DPRINT1(
"IOCTL_GET_SYS_BUTTON_CAPS sent to a non-button device\n");
303 Irp->IoStatus.Information =
sizeof(Caps);
316 DPRINT(
"IOCTL_BATTERY_QUERY_TAG is not supported!\n");
320 DPRINT1(
"Unsupported IOCTL: %x\n", irpStack->
Parameters.DeviceIoControl.IoControlCode);
325 DPRINT1(
"IOCTL sent to the ACPI FDO! Kill the caller!\n");
386 if (ValueInfo ==
NULL)
408 if (ValueInfo ==
NULL)
443 if (ValueInfo !=
NULL)
459 ULONG Length = 0, Level1Length = 0, Level2Length = 0, Level3Length = 0;
460 SIZE_T HardwareIdsLength = 0;
461 SIZE_T VendorIdentifierLength;
466 DPRINT(
"GetProcessorInformation()\n");
470 L"\\Registry\\Machine\\Hardware\\Description\\System\\CentralProcessor\\0",
475 DPRINT1(
"Failed to open CentralProcessor registry key: 0x%lx\n",
Status);
487 DPRINT1(
"Failed to query Identifier value: 0x%lx\n",
Status);
492 Level1Length = Level2Length = Level3Length =
Length;
497 if (ProcessorIdentifier ==
NULL)
512 DPRINT1(
"Failed to query Identifier value: 0x%lx\n",
Status);
519 L"ProcessorNameString",
525 DPRINT1(
"Failed to query ProcessorNameString value: 0x%lx\n",
Status);
541 L"ProcessorNameString",
547 DPRINT1(
"Failed to query ProcessorNameString value: 0x%lx\n",
Status);
560 DPRINT1(
"Failed to query VendorIdentifier value: 0x%lx\n",
Status);
567 if (ProcessorVendorIdentifier ==
NULL)
578 ProcessorVendorIdentifier,
582 DPRINT1(
"Failed to query VendorIdentifier value: 0x%lx\n",
Status);
587 for (
i = 0;
i <
wcslen(ProcessorIdentifier);
i++)
589 if (ProcessorIdentifier[
i] ==
L' ')
590 ProcessorIdentifier[
i] =
L'_';
593 Ptr =
wcsstr(ProcessorIdentifier,
L"Stepping");
597 Level1Length = (
ULONG)(
Ptr - ProcessorIdentifier);
604 Level2Length = (
ULONG)(
Ptr - ProcessorIdentifier);
611 Level3Length = (
ULONG)(
Ptr - ProcessorIdentifier);
614 VendorIdentifierLength = (
USHORT)
wcslen(ProcessorVendorIdentifier);
617 HardwareIdsLength = (5 + VendorIdentifierLength + 3 + Level1Length + 1 +
618 1 + VendorIdentifierLength + 3 + Level1Length + 1 +
619 5 + VendorIdentifierLength + 3 + Level2Length + 1 +
620 1 + VendorIdentifierLength + 3 + Level2Length + 1 +
621 5 + VendorIdentifierLength + 3 + Level3Length + 1 +
622 1 + VendorIdentifierLength + 3 + Level3Length + 1 +
627 if (HardwareIdsBuffer ==
NULL)
634 Length +=
swprintf(&HardwareIdsBuffer[
Length],
L"ACPI\\%s_-_%.*s", ProcessorVendorIdentifier, Level1Length, ProcessorIdentifier);
637 Length +=
swprintf(&HardwareIdsBuffer[
Length],
L"*%s_-_%.*s", ProcessorVendorIdentifier, Level1Length, ProcessorIdentifier);
640 Length +=
swprintf(&HardwareIdsBuffer[
Length],
L"ACPI\\%s_-_%.*s", ProcessorVendorIdentifier, Level2Length, ProcessorIdentifier);
643 Length +=
swprintf(&HardwareIdsBuffer[
Length],
L"*%s_-_%.*s", ProcessorVendorIdentifier, Level2Length, ProcessorIdentifier);
646 Length +=
swprintf(&HardwareIdsBuffer[
Length],
L"ACPI\\%s_-_%.*s", ProcessorVendorIdentifier, Level3Length, ProcessorIdentifier);
649 Length +=
swprintf(&HardwareIdsBuffer[
Length],
L"*%s_-_%.*s", ProcessorVendorIdentifier, Level3Length, ProcessorIdentifier);
660 Length = (5 + VendorIdentifierLength + 3 + Level1Length + 1) *
sizeof(
WCHAR);
670 if (ProcessorHandle !=
NULL)
673 if (ProcessorIdentifier !=
NULL)
676 if (ProcessorVendorIdentifier !=
NULL)
681 if (HardwareIdsBuffer !=
NULL)
696 DPRINT(
"Driver Entry \n");
NTSTATUS NTAPI ACPIDispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define DO_DEVICE_INITIALIZING
#define IOCTL_GET_SYS_BUTTON_CAPS
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
DEVICE_POWER_STATE DevicePowerState
#define THREAD_ALL_ACCESS
static NTSTATUS AcpiRegQueryValue(IN HANDLE KeyHandle, IN LPWSTR ValueName, OUT PULONG Type OPTIONAL, OUT PVOID Data OPTIONAL, IN OUT PULONG DataLength OPTIONAL)
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
UNICODE_STRING ProcessorHardwareIds
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
#define STATUS_INVALID_PARAMETER
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
char * strstr(char *String1, char *String2)
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
NTSTATUS NTAPI Bus_Power(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS NTAPI Bus_PDO_EvalMethod(PPDO_DEVICE_DATA DeviceData, PIRP Irp)
PDEVICE_OBJECT PhysicalDeviceObject
struct acpi_device * power_button
PDEVICE_OBJECT UnderlyingPDO
#define RtlMoveMemory(Destination, Source, Length)
static NTSTATUS GetProcessorInformation(VOID)
#define STATUS_BUFFER_TOO_SMALL
_In_ PUNICODE_STRING ValueName
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
struct _COMMON_DEVICE_DATA * PCOMMON_DEVICE_DATA
SYSTEM_POWER_STATE SystemPowerState
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
PDRIVER_EXTENSION DriverExtension
LPWSTR ProcessorNameString
static PDRIVER_OBJECT DriverObject
#define IoCompleteRequest
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
#define ACPI_BUTTON_NOTIFY_STATUS
#define IOCTL_GET_SYS_BUTTON_EVENT
static NTSTATUS AcpiRegOpenKey(IN HANDLE ParentKeyHandle, IN LPCWSTR KeyName, IN ACCESS_MASK DesiredAccess, OUT HANDLE KeyHandle)
#define NT_SUCCESS(StatCode)
static PSecPkgInfoA *static SEC_CHAR ULONG
#define STATUS_NO_SUCH_DEVICE
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
#define swprintf(buf, format,...)
NTSTATUS NTAPI Bus_AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT PhysicalDeviceObject)
#define IOCTL_BATTERY_QUERY_TAG
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define OBJ_CASE_INSENSITIVE
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
#define ExAllocatePoolWithTag(hernya, size, tag)
COMMON_DEVICE_DATA Common
#define IOCTL_ACPI_EVAL_METHOD
struct _FDO_DEVICE_DATA * PFDO_DEVICE_DATA
IN PDEVICE_OBJECT DeviceObject
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
PDRIVER_ADD_DEVICE AddDevice
struct acpi_device * sleep_button
VOID NTAPI ButtonWaitThread(PVOID Context)
#define STATUS_BUFFER_OVERFLOW
NTSTATUS NTAPI DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
#define InitializeListHead(ListHead)
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
#define FIELD_OFFSET(t, f)
NTSTATUS NTAPI Bus_PnP(PDEVICE_OBJECT DeviceObject, PIRP Irp)
#define INITIALIZE_PNP_STATE(_Data_)
PDEVICE_OBJECT NextLowerDriver
int acpi_bus_receive_event(struct acpi_bus_event *event)
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
struct tagContext Context
#define STATUS_NOT_SUPPORTED
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
#define InitializeObjectAttributes(p, n, a, r, s)
_In_ PUNICODE_STRING RegistryPath
NTSTATUS NTAPI ACPIDispatchCreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define FILE_DEVICE_SECURE_OPEN
#define ExFreePoolWithTag(_P, _T)
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG DataLength
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
static SERVICE_STATUS status
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define IRP_MJ_DEVICE_CONTROL
PULONG MinorVersion OPTIONAL