Monday, July 11, 2016

Policy Plus - Save CMTX files

I had previously created a CmtxFile class for Policy Plus that can load CMTX files and present their comments in an easy-to-use dictionary. Since comment files are designed to be updated, I also need a way to write CMTX files.

So that's what I did today. CmtxFile can now create an instance of itself from a simple dictionary and then save itself to disk. It turns out that the Group Policy Editor is very particular about all the attributes being there. It also doesn't like periods in resource IDs or prefixes. I had to do a little extra legwork to deal with those, but it is working very well now. I intentionally didn't follow the incremental ns convention because I want it to be relatively easy to see what policy namespace a comment refers to, even when viewing the CMTX in a hex or text editor.

Oh, and I figured out the meaning of the three-byte header. It's just the UTF-8 byte order mark, and XmlDocument can handle it automatically. (I knew about byte-order marks, I just didn't recognize the UTF-8 one.)

No comments:

Post a Comment