-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Am 2014-10-29 19:56, schrieb Jonathan Vollebregt:
There will always be errors that are specific to reg.exe though. E.g. it's not possible to pass a negative DWORD to RegSetValue.
How would I add reg.exe specific errors? Just make them ints over the 16k used by system error codes?
That depends. Printing error messages from the top level reg_add, reg_query, etc is fine. What I don't like is printing them from functions at many different levels.
In some cases (e.g. invalid root key) you may be able to reuse some of the existing error values.
In any case implementing this would require a big rewrite of most of the patches in the series, so I'll probably make a patch for the end of this series.
Works for me.
This checks for backslashes at the end of the key not the start - tests show more than one should produce an error.
Ooops, I should have read this more carefully :-\ .
reg_type = get_regtype(type);
if (!type)
reg_type = REG_SZ;
else
reg_type = wchar_get_type(type);
Why not keep the !type check inside get_regtype?
It's possible for something calling this to want a different default, so I decided to let the caller handle it.
I'd say keep it in get_regtype until you find a specific case that needs it.
Since you know the length, you can use memcpy. You could also think about a strdupW_heap() helper function if you need this in multiple places, but then reusing the length is more difficult.
Does this mean I'm allowed to use malloc too?
No, what I meant is write your own strdup-like function that uses HeapAlloc.
The idea is presumably only to prompt for overwrite if the value already exists. That's what the RegQueryValue is for. Presumably a y/n prompt should go here but I have my hands full with the rest of it.
Sure, I'm not saying that you should add a prompt now. I'm saying a /* FIXME: Check if the value exists and prompt for overwrite */ works just as well as calling RegQueryValue for (currently) no reason.
If the subkey does not exist, and invalid data is passed, you're creating the subkey without adding the value and returning an error. This is likely not the correct behavior.
Should it prompt for new key creation as well as overwriting? I'm not sure what the native behavior is
What I meant is that you are doing some error checks *after* you already modified the registry. Leaving modifications behind (or creating them in the first place) if invalid operands are specified is most likely wrong.