A pointer to a variable that specifies the size of the buffer pointed to by the lpData parameter, in bytes. When the function returns, this variable contains the size of the data copied to lpData.
In other words, it's rewritten to be the actual length before it's incremented for null termination.
`RegQueryValueExW`'s last parameter is in and out, so that `length` is set to the actual written length after the call.
It might cause an OOB write though, with a data race on the registry key (if the key's value happens to grow in length by a char or two between the calls, time of check time of use yada yada).