Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logon, Logoff & Shutdown Sounds Restored - v1.0.1 #949

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions mods/logon-logoff-shutdown-sounds.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @id logon-logoff-shutdown-sounds
// @name Logon, Logoff & Shutdown Sounds Restored
// @description Restores the logon, logoff and shutdown sounds from earlier versions of Windows
// @version 1.0.0
// @version 1.0.1
// @author Toru the Red Fox
// @github https://github.com/TorutheRedFox
// @twitter https://twitter.com/TorutheRedFox
Expand All @@ -16,6 +16,8 @@
Restores the logon, logoff and shutdown sounds from earlier versions of Windows, simple as.

It is recommended to use [these reg files](https://www.howtogeek.com/wp-content/uploads/2016/09/Shutdown-Logoff-Logon-Sound-Hacks.zip) to restore the sound events to the Sound control panel applet.

Note: Likely redundant with explorer7 due to 7's explorer having this code in it already.
*/
// ==/WindhawkModReadme==

Expand All @@ -37,6 +39,7 @@ It is recommended to use [these reg files](https://www.howtogeek.com/wp-content/
#include <windhawk_utils.h>
#include <windows.h>
#include <shlwapi.h>
#include <winerror.h>
#include <winuser.h>

// settings
Expand Down Expand Up @@ -435,7 +438,7 @@ HRESULT WINAPI SHCreateSessionKey(REGSAM samDesired, PHKEY phKey)

if(SUCCEEDED(hr))
{
Error = RegCreateKeyExW(HKEY_LOCAL_MACHINE, wszSessionKey, 0, NULL,
Error = RegCreateKeyEx(HKEY_CURRENT_USER, wszSessionKey, 0, NULL,
REG_OPTION_VOLATILE, samDesired, NULL, phKey, NULL);
if (Error != ERROR_SUCCESS)
hr = HRESULT_FROM_WIN32(Error);
Expand All @@ -462,12 +465,12 @@ BOOL WINAPI HasPerLogonActionBeenDone(LPCWSTR lpSubKey, TRIBIT* out_tbDone)
HKEY phkResult;

*out_tbDone = TRIBIT_TRUE;
if ( (int)SHCreateSessionKey(131078, &hKey) >= 0 )
if ( SUCCEEDED(SHCreateSessionKey(KEY_WRITE, &hKey)) )
{
if ( !RegCreateKeyExW(hKey, lpSubKey, 0, 0, 1u, 0x20006u, 0, &phkResult, &dwDisposition) )
if ( RegCreateKeyExW(hKey, lpSubKey, NULL, NULL, REG_OPTION_VOLATILE, KEY_WRITE, NULL, &phkResult, &dwDisposition) == ERROR_SUCCESS )
{
RegCloseKey(phkResult);
if ( dwDisposition == 1 )
if ( dwDisposition == REG_CREATED_NEW_KEY )
*out_tbDone = TRIBIT_FALSE;
}
RegCloseKey(hKey);
Expand Down