RegisterPowerSettingNotification is unnecessary.
authorIain Patterson <me@iain.cx>
Wed, 31 Dec 2014 15:11:05 +0000 (15:11 +0000)
committerIain Patterson <me@iain.cx>
Wed, 31 Dec 2014 15:12:19 +0000 (15:12 +0000)
We were importing RegisterPowerSettingNotification but not actually
calling it.  This didn't matter because including
SERVICE_ACCEPT_POWEREVENT in the accepted controls list is sufficient to
receive power notifications.

imports.cpp
imports.h

index 064ba27..6257131 100644 (file)
@@ -82,15 +82,6 @@ int get_imports() {
   }
   else if (error != ERROR_MOD_NOT_FOUND) return 5;
 
-  imports.user32 = get_dll(_T("user32.dll"), &error);
-  if (imports.user32) {
-    imports.RegisterPowerSettingNotification = (RegisterPowerSettingNotification_ptr) get_import(imports.user32, "RegisterPowerSettingNotification", &error);
-    if (! imports.RegisterPowerSettingNotification) {
-      if (error != ERROR_PROC_NOT_FOUND) return 9;
-    }
-  }
-  else if (error != ERROR_MOD_NOT_FOUND) return 8;
-
   return 0;
 }
 
index 249eb05..03e2df1 100644 (file)
--- a/imports.h
+++ b/imports.h
@@ -6,18 +6,15 @@ typedef BOOL (WINAPI *SleepConditionVariableCS_ptr)(PCONDITION_VARIABLE, PCRITIC
 typedef void (WINAPI *WakeConditionVariable_ptr)(PCONDITION_VARIABLE);
 typedef BOOL (WINAPI *CreateWellKnownSid_ptr)(WELL_KNOWN_SID_TYPE, SID *, SID *, unsigned long *);
 typedef BOOL (WINAPI *IsWellKnownSid_ptr)(SID *, WELL_KNOWN_SID_TYPE);
-typedef HANDLE (WINAPI *RegisterPowerSettingNotification_ptr)(HANDLE, LPCGUID, DWORD);
 
 typedef struct {
   HMODULE kernel32;
   HMODULE advapi32;
-  HMODULE user32;
   AttachConsole_ptr AttachConsole;
   SleepConditionVariableCS_ptr SleepConditionVariableCS;
   WakeConditionVariable_ptr WakeConditionVariable;
   CreateWellKnownSid_ptr CreateWellKnownSid;
   IsWellKnownSid_ptr IsWellKnownSid;
-  RegisterPowerSettingNotification_ptr RegisterPowerSettingNotification;
 } imports_t;
 
 HMODULE get_dll(const TCHAR *, unsigned long *);