Thursday, June 22, 2017

Policy Plus - Starting POL editing

Today I made some progress on allowing users to edit POL files directly with the Edit Raw POL window in Policy Plus. There are now a handful of buttons across the top to do the editing: Add Key, Add Value, Delete Value(s), Forget, and Edit. Currently only Add Key, Add Value, and Edit do anything.

When a key is selected, Add Key creates a new key under the current one. Add Value creates a new value of the selected key, prompting the user for a kind (e.g. string) and then for the data. Delete Value(s) will do one of two things. If a key is selected, it will allow the user to clear the key or to delete a value with a given name. If a value is selected, it will convert that value to a "delete this value" marker. Forget will remove the selected item and its descendants, making them no longer tracked by the POL file, which is distinct from explicit deletion. Finally, when a value is selected, Edit allows the data to be changed.

Now with actual editing controls
I ran into a bit of a surprise while making the form that edits numeric values (DWord and QWord). Apparently NumericUpDown, despite being designed to work with Decimal numbers (which can get huge, markedly larger than a quad-word), glitches out in hexadecimal mode when its value is greater than the largest signed integer (DWord). Since Policy Plus is supposed to be able to work with unsigned QWords (UInt64), that's a problem. People had run into it before, though, so I was able to adapt some code there into a subclass of NumericUpDown that doesn't bug out.


Since raw POL editing can cause some seriously strange stuff if done poorly, I added a warning message before launching Edit Raw POL for the first time.

No comments:

Post a Comment