Byte Array Question for Anyone!


dacrone

Well-known member
Pro User
VIP
Local time
5:49 PM
Posts
3,037
OS
Windows 11 Pro
so in the following python script, we have:

Code:
def process_data(byte_array):
    process_is_on = False
    ch = byte_array[18]
    size = len(byte_array)

    if ch == 0x15:
        process_is_on = True
        for i in range(10, 15):
            ch = byte_array[i]
            if ch != 0xff:
                byte_array[i] += 1
                break
        byte_array[18] = 0x13
        for i in range(24, 22, -1):
            for j in range(i, size - 2):
                byte_array[j] = byte_array[j + 1]
    elif ch == 0x13:
        process_is_on = False
        for i in range(10, 15):
            ch = byte_array[i]
            if ch != 0xff:
                byte_array[i] += 1
                break
        byte_array[18] = 0x15
        n = 0
        while n < 2:
            for j in range(size - 1, 23, -1):
                byte_array[j] = byte_array[j - 1]
            n += 1
        byte_array[23] = 0x10
        byte_array[24] = 0x00
        # extend array
        ba = bytearray(1)
        ba[0] = 0x00
        byte_array.extend(ba)
        byte_array.extend(ba)
    return process_is_on


def write_data_to_registry(byte_array, process_state):
    size = len(byte_array)
    retval = False
    try:
        hKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, STATUS_PATH, 0, winreg.KEY_SET_VALUE)
        winreg.SetValueEx(hKey, STATE_VALUE_NAME, 0, winreg.REG_BINARY, byte_array[:size])
        winreg.CloseKey(hKey)
        retval = True
    except:
        pass
    return retval


The above numbers are corresponding to these REG_BINARY Keys (which obviously change ever time the toggle is flipped, but the mathematics work despite the changes as they are absolute)

Code:
"Data"=hex:43 42 01 00 0a 02 01 00 2a 06 ff ff e6 be 06 2a 2b 0e 13 43 42 01 00 d0 0a 02 c6 14 f7 a8 eb 97 db f6 e5 ed 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
and in bytes:
Code:
34 33 20 34 32 20 30 31 20 30 30 20 30 61 20 30 32 20 30 31 20 30 30 20 32 61 20 30 36 20 66 66 20 66 66 20 65 36 20 62 65 20 30 36 20 32 61 20 32 62 20 30 65 20 31 33 20 34 33 20 34 32 20 30 31 20 30 30 20 64 30 20 30 61 20 30 32 20 63 36 20 31 34 20 66 37 20 61 38 20 65 62 20 39 37 20 64 62 20 66 36 20 65 35 20 65 64 20 30 31 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30

and that toggles to:
Code:
"Data"=hex:43 42 01 00 0a 02 01 00 2a 06 ff ff e7 be 06 2a 2b 0e 15 43 42 01 00 10 00 d0 0a 02 c6 14 f7 a8 eb 97 db f6 e5 ed 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
and in bytes:
Code:
34 33 20 34 32 20 30 31 20 30 30 20 30 61 20 30 32 20 30 31 20 30 30 20 32 61 20 30 36 20 66 66 20 66 66 20 65 37 20 62 65 20 30 36 20 32 61 20 32 62 20 30 65 20 31 35 20 34 33 20 34 32 20 30 31 20 30 30 20 31 30 20 30 30 20 64 30 20 30 61 20 30 32 20 63 36 20 31 34 20 66 37 20 61 38 20 65 62 20 39 37 20 64 62 20 66 36 20 65 35 20 65 64 20 30 31 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30 20 30 30


SO.. given this template and seeing how it got the byte_array numbers, what are the correct numbers to plug in for the following keys?:

Code:
"Data"=hex:02,00,00,00,90,4c,66,1a,5f,9c,db,01,00,00,00,00,43,42,01,00,c2,0a,\
  01,d2,14,28,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,2e,00,51,\
  00,75,00,69,00,65,00,74,00,48,00,6f,00,75,00,72,00,73,00,50,00,72,00,6f,00,\
  66,00,69,00,6c,00,65,00,2e,00,55,00,6e,00,72,00,65,00,73,00,74,00,72,00,69,\
  00,63,00,74,00,65,00,64,00,ca,28,00,00
and in bytes:
Code:
 30 32 20 30 30 20 30 30 20 30 30 20 39 30 20 34 63 20 36 36 20 31 61 20 35 66 20 39 63 20 64 62 20 30 31 20 30 30 20 30 30 20 30 30 20 30 30 20 34 33 20 34 32 20 30 31 20 30 30 20 63 32 20 30 61 20 20 30 31 20 64 32 20 31 34 20 32 38 20 34 64 20 30 30 20 36 39 20 30 30 20 36 33 20 30 30 20 37 32 20 30 30 20 36 66 20 30 30 20 37 33 20 30 30 20 36 66 20 30 30 20 36 36 20 30 30 20 37 34 20 30 30 20 32 65 20 30 30 20 35 31 20 0a 30 30 20 37 35 20 30 30 20 36 39 20 30 30 20 36 35 20 30 30 20 37 34 20 30 30 20 34 38 20 30 30 20 36 66 20 30 30 20 37 35 20 30 30 20 37 32 20 30 30 20 37 33 20 30 30 20 35 30 20 30 30 20 37 32 20 30 30 20 36 66 20 30 30 20 36 36 20 30 30 20 36 39 20 30 30 20 36 63 20 30 30 20 36 35 20 30 30 20 32 65 20 30 30 20 35 35 20 30 30 20 36 65 20 30 30 20 37 32 20 30 30 20 36 35 20 30 30 20 37 33 20 30 30 20 37 34 20 30 30 20 37 32 20 30 30 20 36 39 20 30 30 20 36 33 20 30 30 20 37 34 20 30 30 20 36 35 20 30 30 20 36 34 20 30 30 20 63 61 20 32 38 20 30 30 20 30 30

and that toggles to:
Code:
"Data"=hex:02,00,00,00,c1,ca,60,27,5f,9c,db,01,00,00,00,00,43,42,01,00,c2,0a,\
  01,d2,14,28,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,2e,00,51,\
  00,75,00,69,00,65,00,74,00,48,00,6f,00,75,00,72,00,73,00,50,00,72,00,6f,00,\
  66,00,69,00,6c,00,65,00,2e,00,50,00,72,00,69,00,6f,00,72,00,69,00,74,00,79,\
  00,4f,00,6e,00,6c,00,79,00,ca,28,00,00
and in bytes:
Code:
 30 32 20 30 30 20 30 30 20 30 30 20 63 31 20 63 61 20 36 30 20 32 37 20 35 66 20 39 63 20 64 62 20 30 31 20 30 30 20 30 30 20 30 30 20 30 30 20 34 33 20 34 32 20 30 31 20 30 30 20 63 32 20 30 61 20 30 31 20 64 32 20 31 34 20 32 38 20 34 64 20 30 30 20 36 39 20 30 30 20 36 33 20 30 30 20 37 32 20 30 30 20 36 66 20 30 30 20 37 33 20 30 30 20 36 66 20 30 30 20 36 36 20 30 30 20 37 34 20 30 30 20 32 65 20 30 30 20 35 31 20 30 30 20 37 35 20 30 30 20 36 39 20 30 30 20 36 35 20 30 30 20 37 34 20 30 30 20 34 38 20 30 30 20 36 66 20 30 30 20 37 35 20 30 30 20 37 32 20 30 30 20 37 33 20 30 30 20 35 30 20 30 30 20 37 32 20 30 30 20 36 66 20 30 30 20 36 36 20 30 30 20 36 39 20 30 30 20 36 63 20 30 30 20 36 35 20 30 30 20 32 65 20 30 30 20 35 30 20 30 30 20 37 32 20 30 30 20 36 39 20 30 30 20 36 66 20 30 30 20 37 32 20 30 30 20 36 39 20 30 30 20 37 34 20 30 30 20 37 39 20 30 30 20 34 66 20 30 30 20 36 65 20 30 30 20 36 63 20 30 30 20 37 39 20 30 30 20 63 61 20 32 38 20 30 30 20 30 30 0a 0a
 

My Computer

System One

  • OS
    Windows 11 Pro
[Epoch filetime in UTC... 82,03,63,78,79,9c,db,01]... null separated bytes... terminated by double null's.

Rule #1 of reverse engineering:

Collect as many data samples from different PC's and users. Compare and contrast. Just because you know a set of bytes changed, doesn't mean you understand what the rest of the bytes actually do. "...,9c,db,01" is always a sequence that strongly implies its a stored UTC timestamp.
 

My Computer

System One

  • OS
    Windows 7
[Epoch filetime in UTC... 82,03,63,78,79,9c,db,01]... null separated bytes... terminated by double null's.

Rule #1 of reverse engineering:

Collect as many data samples from different PC's and users. Compare and contrast. Just because you know a set of bytes changed, doesn't mean you understand what the rest of the bytes actually do. "...,9c,db,01" is always a sequence that strongly implies its a stored UTC timestamp.
had a hunch you'd be the first to respond lol. so i can get data from 3 PCs in the morning to add to this. just so you know, this is in reference to the Do Not Disturb toggle in settings.

Turn it on, refresh the below reg entry. then off and refresh reg again:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\$$windows.data.notifications.quiethourssettings\Current\Data
 

My Computer

System One

  • OS
    Windows 11 Pro
Those hex bytes were strangely familiar...
I stopped working on this script a year ago. Except for the "wtf does this unexplained byte sequence do?", this code kinda makes the recipe's ingredients more obvious.

Code:
function QuietMoment {
    param (
        [ValidateSet('Presentation','Game','Fullscreen')]
        [string]$Rule,
        [ValidateSet('Priority','Alarms')]
        [string]$Focus,
        [ValidateSet('on','off')]
        [string]$Enabled
    )

    $DateValues = ([System.BitConverter]::GetBytes((Get-Date).ToFileTimeUtc()) | foreach { ('{0:x2}' -f $_).ToUpper() }) -join ','

    if ($Enabled -eq 'on' ) {
        $EnabledValues = ',01,C2,14'
    }
    else {
        $EnabledValues = ''
    }

    $UnknownByte = switch ($Rule)
    {
        game { '28' }
        default { '26' }
    }

    if ($Focus -eq 'priority' ) {
        $PriorityOnly = (('Microsoft.QuietHoursProfile.PriorityOnly' | Format-Hex).Bytes | foreach { ('{0:x},' -f $_).ToUpper() }) -join '00,'
        $FocusValues = $PriorityOnly
    }
    else {
        $AlarmsOnly = (('Microsoft.QuietHoursProfile.AlarmsOnly' | Format-Hex).Bytes | foreach { ('{0:x},' -f $_).ToUpper() }) -join '00,'
        $FocusValues = $AlarmsOnly
    }

    '[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\$quietmoment{0}$windows.data.notifications.quietmoment\Current]' -f $Rule

    $DataValues = '02,00,00,00,{0},00,00,00,00,43,42,01,00,C2,0A{1},01,D2,1E,{2},{3}00,C2,28,01,CA,50,00,00' -f $DateValues, $EnabledValues, $UnknownByte, $FocusValues
    '"Data"=hex(3):{0},\' -f (($DataValues -split ',')[0..19] -join ',')

    $ByteCount = ($DataValues -split ',').Count

    for ($i = 20; $i -le ($ByteCount - 24); $i += 25) {
        '{0},\' -f (($DataValues -split ',')[($i)..($i + 24)] -join ',')
    }
    '{0}' -f (($DataValues -split ',')[($i)..$ByteCount] -join ',')

    ''
}

# CREATE RULES HERE
#
# Rule:    'Presentation', 'Game', 'Fullscreen'
# Focus:   'Priority', 'Alarms'
# Enabled: 'on','off'

@'
Windows Registry Editor Version 5.00

'@
QuietMoment -Rule 'presentation' -Focus 'alarms' -Enabled 'off'
QuietMoment -Rule 'game' -Focus 'priority' -Enabled 'off'
QuietMoment -Rule 'fullscreen' -Focus 'alarms' -Enabled 'off'

Code:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\$quietmomentpresentation$windows.data.notifications.quietmoment\Current]
"Data"=hex(3):02,00,00,00,40,99,4E,AE,79,9C,DB,01,00,00,00,00,43,42,01,00,\
C2,0A,01,D2,1E,26,4D,00,69,00,63,00,72,00,6F,00,73,00,6F,00,66,00,74,00,2E,\
00,51,00,75,00,69,00,65,00,74,00,48,00,6F,00,75,00,72,00,73,00,50,00,72,00,\
6F,00,66,00,69,00,6C,00,65,00,2E,00,41,00,6C,00,61,00,72,00,6D,00,73,00,4F,\
00,6E,00,6C,00,79,00,C2,28,01,CA,50,00,00

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\$quietmomentgame$windows.data.notifications.quietmoment\Current]
"Data"=hex(3):02,00,00,00,28,BC,50,AE,79,9C,DB,01,00,00,00,00,43,42,01,00,\
C2,0A,01,D2,1E,28,4D,00,69,00,63,00,72,00,6F,00,73,00,6F,00,66,00,74,00,2E,\
00,51,00,75,00,69,00,65,00,74,00,48,00,6F,00,75,00,72,00,73,00,50,00,72,00,\
6F,00,66,00,69,00,6C,00,65,00,2E,00,50,00,72,00,69,00,6F,00,72,00,69,00,74,\
00,79,00,4F,00,6E,00,6C,00,79,00,C2,28,01,CA,50,00,00

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\$quietmomentfullscreen$windows.data.notifications.quietmoment\Current]
"Data"=hex(3):02,00,00,00,59,31,51,AE,79,9C,DB,01,00,00,00,00,43,42,01,00,\
C2,0A,01,D2,1E,26,4D,00,69,00,63,00,72,00,6F,00,73,00,6F,00,66,00,74,00,2E,\
00,51,00,75,00,69,00,65,00,74,00,48,00,6F,00,75,00,72,00,73,00,50,00,72,00,\
6F,00,66,00,69,00,6C,00,65,00,2E,00,41,00,6C,00,61,00,72,00,6D,00,73,00,4F,\
00,6E,00,6C,00,79,00,C2,28,01,CA,50,00,00
 

My Computer

System One

  • OS
    Windows 7
Sorry. Refresh the page, I had to shuffle two string constructs inside the function instead of existing outside of it. My bad.
 

My Computer

System One

  • OS
    Windows 7
Those hex bytes were strangely familiar...
I stopped working on this script a year ago. Except for the "wtf does this unexplained byte sequence do?", this code kinda makes the recipe's ingredients more obvious.
haha way more than i was trying to do. i was literally only trying to get this toggle to trip on and off:
1742795133841.webp

the python script used in the Night Light toggle uses the same styled script (hence my snippet in the first post). once the math is figured out, it literally flips the toggle in real time (live view when .py is ran)

*finally found the original source. it was a github cli. i added the url to the nightlight thread (had a stackoverflow link where someone shared it but wasnt the original source).
 
Last edited:

My Computer

System One

  • OS
    Windows 11 Pro
Sorry. Refresh the page, I had to shuffle two string constructs inside the function instead of existing outside of it. My bad.
not sure if you're interested in this topic or not. if not i can quit tagging you lol.

update - played with it for an hour or so today. figured out how to toggle Notifications on/off with powershell.
also how to add/remove apps from the Priority list of allowed & calls/reminders via powershell.

1742876580793.webp

what else i've found is that when the binary data changes (in my original post), it is changing the default profile, which i knew but didnt know the reg naming for it offhand:

1742876663176.webp

OFF = Microsoft.QuietHoursProfile.Unrestricted

1742877076936.webp

so instead of messing with the binary, as it will take me forever to figure that out, i'm going to shift focus to figuring out how to change the profile via Data name instead. any ideas?
 

My Computer

System One

  • OS
    Windows 11 Pro
When I was playing around a year ago, 23H2(?) only had two profiles:
Microsoft.QuietHoursProfile.PriorityOnly​
Microsoft.QuietHoursProfile.AlarmsOnly​

I imagine you do a switch() and pick one of the three strings to inject into the byte array.
 

My Computer

System One

  • OS
    Windows 7
When I was playing around a year ago, 23H2(?) only had two profiles:
Microsoft.QuietHoursProfile.PriorityOnly​
Microsoft.QuietHoursProfile.AlarmsOnly​

I imagine you do a switch() and pick one of the three strings to inject into the byte array.
I tried that (unless i did it incorrectly... possibility). i'll keep playing with it

also - just compared the data for the 2 on a different machine. may help me try to figure out the python attempt, but i'm just leaving these here for completion's sake

1742879864200.webp1742879872169.webp
 

My Computer

System One

  • OS
    Windows 11 Pro
Isnt it easier to just disable toasts for "DnD" behavior?

(interesting topic nonetheless)
 

My Computer

System One

  • OS
    PE
The first block is the UTC timestamp, written in big-endian bytes. 9D,DB,01 never changes as the preface (right to left). Think of it as an anchor.

I just finished watching "The Imitation Game" last night on streaming. Break out your ASCII table...

U-n-r-e-s-t-r-i-c-t-e-d
P-r-i-o-r-i-t-y

Dude, it's a data structure flattened into a byte array. Some items are just number value bytes, some are strings. What's not obvious is how the function reads back the data stream and delimits the different struct fields. And since it's supposed to be a data struct, the size (length) of each field can widely vary so you have this shifting of relative positions. The numerical fields are probably fixed in byte length, representing a specific word size (uint, uint16, etc.)
 

My Computer

System One

  • OS
    Windows 7
Isnt it easier to just disable toasts for "DnD" behavior?

(interesting topic nonetheless)
yeah i figured out how to do that one already. just a 2 line ps script. i want to figure the dnd out just because.

What's not obvious is how the function reads back the data stream and delimits the different struct fields.
time for me to do some more homework. there is a method to the madness and it will be found! if not for any other reason than to control what Microsoft doesnt want us to control :lmao:
 

My Computer

System One

  • OS
    Windows 11 Pro
If you guys are itnterested I have a good Greek recipe you can try. It's right up your alley. It written in GREEK, kinda like your speak. :boom::ROFLMAO:
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2 26100.3194
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell Optiplex 7080
    CPU
    i9-10900 10 core 20 threads
    Motherboard
    DELL 0J37VM
    Memory
    32 gb
    Graphics Card(s)
    none-Intel UHD Graphics 630
    Sound Card
    Integrated Realtek
    Monitor(s) Displays
    Benq 27
    Screen Resolution
    2560x1440
    Hard Drives
    1tb Solidigm m.2 nvme+256gb SKHynix m.2 nvme /External drives 512gb Samsung m.2 sata+1tb Kingston m2.nvme+ 4gb Solidigm nvme
    PSU
    500w
    Case
    MT
    Cooling
    Dell Premium
    Keyboard
    Logitech wired
    Mouse
    Logitech wireless
    Internet Speed
    so slow I'm too embarrassed to tell
    Browser
    #1 Edge #2 Firefox
    Antivirus
    Defender+MWB Premium
  • Operating System
    Windows 10 Pro 22H2 19045.3930
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell Optiplex 9020
    CPU
    i7-4770
    Memory
    24 gb
    Monitor(s) Displays
    Benq 27
    Screen Resolution
    2560x1440
    Hard Drives
    256 gb Toshiba BG4 M.2 NVE SSB and 1 tb hdd
    PSU
    500w
    Case
    MT
    Cooling
    Dell factory
    Mouse
    Logitech wireless
    Keyboard
    Logitech wired
    Internet Speed
    still not telling
    Browser
    Firefox
    Antivirus
    Defender+MWB Premium
What's not obvious is how the function reads back the data stream and delimits the different struct fields
also - check the breakdown the OG for the nightlight posted on his git. great insight, and i cant imagine the toggle for
Code:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\$$windows.data.notifications.quiethourssettings\Current
would be TOO different (obv the factors invovled with light effect, etc - but similar layout)

.https://github.com/Enyium/sem-reg-rs/blob/master/src/cloud_store/night_light/docs.md
 

My Computer

System One

  • OS
    Windows 11 Pro
If you guys are itnterested I have a good Greek recipe you can try. It's right up your alley. It written in GREEK, kinda like your speak. :boom::ROFLMAO:
It's really simple. When someone asks "What's the time?" You reply "well it's 35,82,76,c9,4a,9d,db,01".
 

My Computer

System One

  • OS
    Windows 7
It's really simple. When someone asks "What's the time?" You reply "well it's 35,82,76,c9,4a,9d,db,01".
progress! little google (brave), tons of stackoverflow & reddit and lack of sleep lmao. got the python to TURN OFF Do Not Disturb when it is on. works live, no reboot or explorer restarts necessary (it restarts the WpnUserService to force the change). i CANNOT for the life of me get it to toggle DND ON when it is off...

Code:
import winreg
import ctypes
import sys
import subprocess

# Registry key and value definitions
REGISTRY_PATH = r"Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\$$windows.data.notifications.quiethourssettings\Current"
DATA_NAME = "Data"

# Partial bytes for matching static portions of ON and OFF states
STATIC_BYTES_ON = bytes.fromhex("02 00 00 00")  # Example pattern for "ON"
STATIC_BYTES_OFF = bytes.fromhex("02 00 00 00")  # Example pattern for "OFF"

# Function to check if the script is running as administrator
def is_admin():
    try:
        return ctypes.windll.shell32.IsUserAnAdmin()
    except:
        return False

# Function to restart the WpnUserService
def restart_notification_service():
    try:
        print("Restarting Windows Push Notifications User Service...")
        subprocess.run(["powershell", "-Command", "Restart-Service -Name WpnUserService* -Force"], check=True)
        print("Windows Push Notifications User Service restarted successfully.")
    except subprocess.CalledProcessError as e:
        print(f"Failed to restart WpnUserService: {e}")
    except Exception as e:
        print(f"An unexpected error occurred while restarting the service: {e}")

# Function to read and inspect the current state
def inspect_current_state(current_data):
    # Check for static matching patterns
    if STATIC_BYTES_ON in current_data:
        return "ON"
    elif STATIC_BYTES_OFF in current_data:
        return "OFF"
    else:
        return "UNKNOWN"

# Function to toggle the Quiet Hours data
def toggle_quiet_hours():
    try:
        # Open the registry key
        key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, REGISTRY_PATH, 0, winreg.KEY_READ | winreg.KEY_WRITE)

        # Read the current value of the Data field
        current_data, _ = winreg.QueryValueEx(key, DATA_NAME)

        # Inspect the current state
        current_state = inspect_current_state(current_data)

        # Toggle based on current state
        if current_state == "ON":
            print("Switching to OFF state...")
            # Modify the necessary bytes for the OFF state (update as needed)
            new_data = bytearray(current_data)
            new_data[0] = 0x00  # Example modification
            winreg.SetValueEx(key, DATA_NAME, 0, winreg.REG_BINARY, bytes(new_data))
        elif current_state == "OFF":
            print("Switching to ON state...")
            # Modify the necessary bytes for the ON state (update as needed)
            new_data = bytearray(current_data)
            new_data[0] = 0x01  # Example modification
            winreg.SetValueEx(key, DATA_NAME, 0, winreg.REG_BINARY, bytes(new_data))
        else:
            print("Unknown current state. No changes made.")
            print(f"Current Data: {current_data.hex()}")  # Debugging output
       
        # Close the registry key
        winreg.CloseKey(key)

        print("Operation completed successfully.")
        # Restart the WpnUserService
        restart_notification_service()
    except FileNotFoundError:
        print(f"Registry path not found: {REGISTRY_PATH}. Ensure Quiet Hours is configured on your system.")
    except PermissionError:
        print("Permission denied. Please run the script as Administrator.")
    except Exception as e:
        print(f"An error occurred: {e}")

# Main execution
if __name__ == "__main__":
    if not is_admin():
        print("Relaunching script with administrator privileges...")
        ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
        sys.exit()
    toggle_quiet_hours()
 

My Computer

System One

  • OS
    Windows 11 Pro
Back
Top Bottom