I have a program which queries the 'Counter' value of the 'Perflib' subkey in
the Windows registry using RegQueryValueEx. It used to work fine but now the
debug build of my program is broken on Windows 2008 Server R2.
The 'Counter' value is a REG_MULTI_SZ type data and is terminated with two
NULL characters. However, I found out for Windows 2008 Server R2, the value
returned from RegQueryValueEx has an extra character(0xcdcd) after the two
NULL characters, which ends the 'Counter' string value. And that extra
character causes my program to fail because my code tries to read it.
Looking at the 'Counter' value of the 'Perflib' subkey in the Windows
registry (opened by regedt32), I do see there are two blank lines at the end.
While for other Windows OS (I checked Windows XP x86, Windows 2003 Server R2
x86 and Windows 2003 Server R2 x64), all of them have only one blank line at
the end. Hence it seems the problem is not with RegQueryValueEx , the value
itself contains the extra character after the two null characters. Note that
this problem only happens in DEBUG binary. I guess it is because the memory
is initialized by DEBUG configuration as 0xCDCD. For release build 0x00 is
used hence no problem.
Having said that, does anyone know why the 'Counter' value of the 'Perflib'
subkey in the Windows 2008 Server R2 registry ends with an extra character
after the two nulls, which is different from previous Windows versions?
|