43 DPRINT(
"#################### Bus_CreateClose Creating FDO Device ####################\n");
53 DPRINT1(
"IoCreateDevice() failed with status 0x%X\n",
status);
123 if (
NULL == deviceName) {
124 DPRINT1(
"AddDevice: no memory to alloc for deviceName(0x%x)\n", nameLength);
141 DPRINT(
"AddDevice: %p to %p->%p (%ws) \n",
178 Irp->IoStatus.Information = 0;
210 RtlCopyMemory(
Irp->AssociatedIrp.SystemBuffer, &ButtonEvent,
sizeof(ButtonEvent));
212 Irp->IoStatus.Information =
sizeof(
ULONG);
236 Irp->IoStatus.Information = 0;
251 sizeof(*workItemData),
287 DPRINT1(
"Lid button reported to power manager\n");
298 DPRINT(
"Fixed power button reported to power manager\n");
303 DPRINT(
"Fixed sleep button reported to power manager\n");
309 DPRINT(
"Control method power button reported to power manager\n");
314 DPRINT(
"Control method sleep reported to power manager\n");
319 DPRINT1(
"IOCTL_GET_SYS_BUTTON_CAPS sent to a non-button device\n");
326 Irp->IoStatus.Information =
sizeof(Caps);
339 DPRINT(
"IOCTL_BATTERY_QUERY_TAG is not supported!\n");
348 DPRINT1(
"IOCTL sent to the ACPI FDO! Kill the caller!\n");
411 if (ValueInfo ==
NULL)
433 if (ValueInfo ==
NULL)
468 if (ValueInfo !=
NULL)
485 ULONG Length = 0, Level1Length = 0, Level2Length = 0, Level3Length = 0;
486 SIZE_T HardwareIdsLength = 0;
487 SIZE_T VendorIdentifierLength;
492 DPRINT(
"GetProcessorInformation()\n");
496 L"\\Registry\\Machine\\Hardware\\Description\\System\\CentralProcessor\\0",
501 DPRINT1(
"Failed to open CentralProcessor registry key: 0x%lx\n",
Status);
513 DPRINT1(
"Failed to query Identifier value: 0x%lx\n",
Status);
518 Level1Length = Level2Length = Level3Length =
Length;
523 if (ProcessorIdentifier ==
NULL)
538 DPRINT1(
"Failed to query Identifier value: 0x%lx\n",
Status);
545 L"ProcessorNameString",
563 L"ProcessorNameString",
569 DPRINT1(
"Failed to query ProcessorNameString value: 0x%lx\n",
Status);
583 DPRINT1(
"Failed to query VendorIdentifier value: 0x%lx\n",
Status);
590 if (ProcessorVendorIdentifier ==
NULL)
601 ProcessorVendorIdentifier,
605 DPRINT1(
"Failed to query VendorIdentifier value: 0x%lx\n",
Status);
610 for (
i = 0;
i <
wcslen(ProcessorIdentifier);
i++)
612 if (ProcessorIdentifier[
i] ==
L' ')
613 ProcessorIdentifier[
i] =
L'_';
616 Ptr =
wcsstr(ProcessorIdentifier,
L"Stepping");
620 Level1Length = (
ULONG)(
Ptr - ProcessorIdentifier);
627 Level2Length = (
ULONG)(
Ptr - ProcessorIdentifier);
634 Level3Length = (
ULONG)(
Ptr - ProcessorIdentifier);
637 VendorIdentifierLength = (
USHORT)
wcslen(ProcessorVendorIdentifier);
640 HardwareIdsLength = (5 + VendorIdentifierLength + 3 + Level1Length + 1 +
641 1 + VendorIdentifierLength + 3 + Level1Length + 1 +
642 5 + VendorIdentifierLength + 3 + Level2Length + 1 +
643 1 + VendorIdentifierLength + 3 + Level2Length + 1 +
644 5 + VendorIdentifierLength + 3 + Level3Length + 1 +
645 1 + VendorIdentifierLength + 3 + Level3Length + 1 +
650 if (HardwareIdsBuffer ==
NULL)
657 Length +=
swprintf(&HardwareIdsBuffer[
Length],
L"ACPI\\%s_-_%.*s", ProcessorVendorIdentifier, Level1Length, ProcessorIdentifier);
660 Length +=
swprintf(&HardwareIdsBuffer[
Length],
L"*%s_-_%.*s", ProcessorVendorIdentifier, Level1Length, ProcessorIdentifier);
663 Length +=
swprintf(&HardwareIdsBuffer[
Length],
L"ACPI\\%s_-_%.*s", ProcessorVendorIdentifier, Level2Length, ProcessorIdentifier);
666 Length +=
swprintf(&HardwareIdsBuffer[
Length],
L"*%s_-_%.*s", ProcessorVendorIdentifier, Level2Length, ProcessorIdentifier);
669 Length +=
swprintf(&HardwareIdsBuffer[
Length],
L"ACPI\\%s_-_%.*s", ProcessorVendorIdentifier, Level3Length, ProcessorIdentifier);
672 Length +=
swprintf(&HardwareIdsBuffer[
Length],
L"*%s_-_%.*s", ProcessorVendorIdentifier, Level3Length, ProcessorIdentifier);
683 Length = (5 + VendorIdentifierLength + 3 + Level1Length + 1) *
sizeof(
WCHAR);
693 if (ProcessorHandle !=
NULL)
696 if (ProcessorIdentifier !=
NULL)
699 if (ProcessorVendorIdentifier !=
NULL)
704 if (HardwareIdsBuffer !=
NULL)
720 DPRINT(
"Driver Entry \n");
#define ExAllocatePoolUninitialized
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
char * strstr(char *String1, char *String2)
#define ACPI_BUTTON_NOTIFY_STATUS
#define IOCTL_ACPI_ASYNC_EVAL_METHOD
#define IOCTL_ACPI_EVAL_METHOD
struct _COMMON_DEVICE_DATA * PCOMMON_DEVICE_DATA
struct _FDO_DEVICE_DATA * PFDO_DEVICE_DATA
WORKER_THREAD_ROUTINE Bus_PDO_EvalMethodWorker
NTSTATUS NTAPI Bus_Power(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS NTAPI Bus_PnP(PDEVICE_OBJECT DeviceObject, PIRP Irp)
struct _PDO_DEVICE_DATA * PPDO_DEVICE_DATA
#define IOCTL_BATTERY_QUERY_TAG
PDEVICE_OBJECT PhysicalDeviceObject
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
#define FILE_DEVICE_SECURE_OPEN
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define STATUS_NOT_SUPPORTED
#define NT_SUCCESS(StatCode)
int acpi_bus_receive_event(struct acpi_bus_event *event)
NTSTATUS NTAPI Bus_PDO_EvalMethod(_In_ PPDO_DEVICE_DATA DeviceData, _Inout_ PIRP Irp)
struct acpi_device * sleep_button
struct acpi_device * power_button
static NTSTATUS AcpiRegQueryValue(IN HANDLE KeyHandle, IN LPWSTR ValueName, OUT PULONG Type OPTIONAL, OUT PVOID Data OPTIONAL, IN OUT PULONG DataLength OPTIONAL)
DRIVER_INITIALIZE DriverEntry
static NTSTATUS GetProcessorInformation(VOID)
NTSTATUS NTAPI ACPIDispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
DRIVER_ADD_DEVICE Bus_AddDevice
static NTSTATUS AcpiRegOpenKey(IN HANDLE ParentKeyHandle, IN LPCWSTR KeyName, IN ACCESS_MASK DesiredAccess, OUT HANDLE KeyHandle)
UNICODE_STRING ProcessorHardwareIds
LPWSTR ProcessorNameString
NTSTATUS NTAPI ACPIDispatchCreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
VOID NTAPI ButtonWaitThread(PVOID Context)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define KeGetCurrentIrql()
#define InitializeListHead(ListHead)
#define INITIALIZE_PNP_STATE(_Data_)
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
MxDeviceObject deviceObject
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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define OBJ_KERNEL_HANDLE
#define OBJ_CASE_INSENSITIVE
#define ExFreePoolWithTag(_P, _T)
#define InitializeObjectAttributes(p, n, a, r, s)
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define THREAD_ALL_ACCESS
@ KeyValuePartialInformation
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
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)
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
#define IoCompleteRequest
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)
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
#define IOCTL_GET_SYS_BUTTON_CAPS
#define IOCTL_GET_SYS_BUTTON_EVENT
#define IRP_MJ_DEVICE_CONTROL
#define STATUS_BUFFER_TOO_SMALL
#define STATUS_BUFFER_OVERFLOW
PULONG MinorVersion OPTIONAL
SYSTEM_POWER_STATE SystemPowerState
DEVICE_POWER_STATE DevicePowerState
WORK_QUEUE_ITEM WorkQueueItem
PPDO_DEVICE_DATA DeviceData
COMMON_DEVICE_DATA Common
PDEVICE_OBJECT NextLowerDriver
PDEVICE_OBJECT UnderlyingPDO
union _IO_STACK_LOCATION::@1581 Parameters
struct _IO_STACK_LOCATION::@1581::@1582 DeviceIoControl
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define RtlMoveMemory(Destination, Source, Length)
#define STATUS_INVALID_PARAMETER
#define STATUS_NO_SUCH_DEVICE
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
#define ExInitializeWorkItem(Item, Routine, Context)
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
@ DevicePropertyPhysicalDeviceObjectName