Maybe with an insight on C/C++ programming and on where/how to store exif data in a raw file
The CHDK "raw" is a byte for byte copy of the sensor frame buffer. There is no appropriate place to put other data. The tools that do understand non-format use file size as a hint for what camera it came from.
There is some argument to be made for creating a well specified CHDK specific raw format, but most of us would rather not proliferate even more ad-hoc file formats. If I did make this format, it would be an almost valid DNG (exactly the current CHDK DNG, without bytes reverse or badpixels removed) prefixed by a very small CHDK specific header.
I as I said before DNG contains exactly the same data, except for that known bad pixels are interpolated over, as required by the DNG spec. The byte order is also reversed. If you extract the raw data chunk from the DNG and reverse the bytes, you will have a valid CHDK raw.