{"id":19527849,"url":"https://github.com/valinet/acpifiltr","last_synced_at":"2025-08-03T00:42:49.776Z","repository":{"id":245747498,"uuid":"819110681","full_name":"valinet/acpifiltr","owner":"valinet","description":"WDF-based kernel-mode filter driver based on the sample from Microsoft that signals a user space named event when the ACPI power button is pressed.","archived":false,"fork":false,"pushed_at":"2024-06-23T20:42:34.000Z","size":14,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-19T22:08:34.266Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/valinet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-23T20:06:37.000Z","updated_at":"2025-06-13T13:36:42.000Z","dependencies_parsed_at":"2024-06-23T21:43:32.881Z","dependency_job_id":null,"html_url":"https://github.com/valinet/acpifiltr","commit_stats":null,"previous_names":["valinet/acpifiltr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/valinet/acpifiltr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valinet%2Facpifiltr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valinet%2Facpifiltr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valinet%2Facpifiltr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valinet%2Facpifiltr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/valinet","download_url":"https://codeload.github.com/valinet/acpifiltr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valinet%2Facpifiltr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268479902,"owners_count":24256887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T01:16:36.389Z","updated_at":"2025-08-03T00:42:49.715Z","avatar_url":"https://github.com/valinet.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# acpifiltr\nWDF-based kernel-mode filter driver based on the [sample from Microsoft](https://github.com/microsoft/Windows-driver-samples/tree/main/general/toaster/toastDrv/kmdf/filter/generic) that signals a user space named event when the ACPI power button is pressed. Basically, this allows mapping the power button to any custom action, besides the limited options that Windows is offering.\n\nTheoretically, this can be used as a filter driver over any device that supports the `IOCTL_GET_SYS_BUTTON_EVENT` ioctls (for example, a PS/2 or USB keyboard that contains a power button); it only happens that I have tested it over the `ACPI Fixed Feature Button` on my setup, which coresponds to the power button on my laptop's keyboard and on the docking station. Adapt the steps below to your own setup. In the light of this, indeed `acpifiltr` is not necessarily the best name, but I kept it this way because, for some reason, I can remember it easily.\n\n## How to?\n\nFirst of all, obviously, compile the driver on your machine (I have tested it solely on `x64` architecture). You need to have installed the [WDK](https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk) for this.\n\nTo run in a secure manner, I recommend [this](https://github.com/valinet/ssde), which is implied in the installation procedure below. So, to start, ensure ssde runs with Secure Boot on (`Confirm-SecureBootUEFI` in PowerShell); no need to enable test signing or Test Mode.\n\nFor best results, adjust Windows so that pressing the power button does nothing. Open Control Panel (`control.exe`), go to `System and Security\\Power Options\\Change what the power buttons do` and set `When I press the power button:` to `Do nothing` for both `On battery`, and `Plugged in`.\n\nRemove the test signature from the driver:\n\n```\nsigntool remove /s acpifiltr.sys\n```\n\nSign the driver with the certificate created for ssde. Replace `password` with your certificate's password, and `17cf4521f162442bf61d3a09ec8c4455456eaf54` with the SHA1 of your `localhost-km.der` file.\n\n```\nsigntool sign /fd sha256 /ac .\\localhost-root-ca.der /f .\\localhost-km.pfx /p password /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /td SHA256 /sha1 17cf4521f162442bf61d3a09ec8c4455456eaf54 acpifiltr.sys\n```\n\nCopy driver to `C:\\Windows\\System32\\drivers`.\n\n```\ndel C:\\Windows\\System32\\drivers\\acpifiltr.sysO\nren C:\\Windows\\System32\\drivers\\acpifiltr.sys acpifiltr.sysO\nxcopy /Y acpifiltr.sys C:\\Windows\\System32\\drivers\n```\n\nInstall driver in the system.\n\n```\nsc create acpifiltr binpath=%windir%\\system32\\drivers\\acpifiltr.sys type=kernel start=demand error=normal\n```\n\nRegister driver as filter for the `ACPI Fixed Feature Button` device. In the Windows Registry, go to `HKLM\\SYSTEM\\CurrentControlSet\\Enum\\ACPI\\FixedButton`. In there, you probably have got a subfolder - mine is called `2\u0026daba3ff\u00260`. Open that; it should contain various 'things', like entries for `HardwareID`, `Driver` etc. Create a new `REG_MULTI_SZ` and call it `UpperFilters`, if not already there. Edit `UpperFilters` and add `acpifiltr` at the top of the list.\n\n```\nWindows Registry Editor Version 5.00\n\n[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\ACPI\\FixedButton\\2\u0026daba3ff\u00260]\n\"UpperFilters\"=hex(7):61,00,63,00,70,00,69,00,66,00,69,00,6c,00,74,00,72,00,00,\\\n  00,00,00\n```\n\nNow, restart the system; and after reboot the driver should be up and running. You can confirm using `sc query` which should report the status as `RUNNING`:\n\n```\nsc query acpifiltr\n```\n\nWhen the driver is functioning and the user presses the power button, it will signal the `Global\\{29DFB10F-5CFF-4A9D-B9D1-31B053A1AE95}` named event. This event should be created by a user land application which should wait on it, and then perform whatever action the user desires when the event gets signaled.\n\nFor example, [here](https://github.com/valinet/wh-mods/blob/master/mods/valinet-power-button-action.wh.cpp) is a Windhawk module that opens `calc.exe` when the driver is installed and the user presses the power button.\n\nEnjoy.\n\n## References\n\n* https://github.com/microsoft/Windows-driver-samples/tree/main/general/toaster/toastDrv/kmdf/filter/generic\n* https://web.archive.org/web/20130313055404/http://support.microsoft.com/kb/302092\n* https://learn.microsoft.com/en-us/archive/blogs/doronh/how-are-power-buttons-reported-in-windows\n* https://learn.microsoft.com/en-us/archive/blogs/doronh/how-ps2-and-hid-keyboads-report-power-button-events\n* https://www.techtalkz.com/threads/acpi-intercepting-power-button-and-lid-switch-questions-xp.259038/\n* https://community.osr.com/t/how-to-track-the-power-button-press-event-in-kernel/44660\n* https://community.osr.com/t/capturing-physical-power-button-event-in-windows-xp-embedded/48075/18\n* https://stackoverflow.com/questions/5769786/installing-filter-drivers-to-an-existing-device\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalinet%2Facpifiltr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvalinet%2Facpifiltr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalinet%2Facpifiltr/lists"}