winapiini

How is the WritePrivateProfileStruct/GetPrivateProfileStruct checksum calculated?


Windows provides a WritePrivateProfileStruct API which can be used to write binary data to an INI file, and a GetPrivateProfileStruct API which can be used to read that binary data back from the INI file.

The binary data is serialised in hex format, followed by a single additional byte which is a checksum. For example:

[ultravnc]
passwd=2AE0C448372D3C1CD2

in that case, the binary data is 2AE0C448372D3C1C and the checksum byte is D2.

How is that checksum calculated?


Solution

  • The checksum is calculated simply by adding up each byte, and using the result (mod 256) as the checksum. It is not using anything more sophisticated than that.