IonicWind Software

IWBasic => General Questions => Topic started by: Andy on August 09, 2017, 03:08:25 AM

Title: Marking a function as a success or a failure
Post by: Andy on August 09, 2017, 03:08:25 AM
I've managed to successfully copy a Major registry key - with the exception of a few open keys.

The question is should I mark this down as a success or a failure?

I could return 3 possible states:

1. Success
2. Success with some Errors
3. Failure.

What's your thoughts on this please?
Title: Re: Marking a function as a success or a failure
Post by: LarryMc on August 09, 2017, 06:01:30 AM
The way I look at it is,
Did the function successfully complete its intended purpose, yes or no?
Your title for this post says it all "success or a failure".

Is the purpose of the function to copy the key and ALL of it's sub keys or
is its purpose to copy the key and all of the sub keys that it can?
Title: Re: Marking a function as a success or a failure
Post by: Andy on August 09, 2017, 10:31:06 PM
A good question Larry,

The intention of the function is to copy a sub key of HKEY_CURRENT_USER\Software.

For that purpose it is successful - with the exception of HKEY_CURRENT_USER\Software\Microsoft.

I was just seeing if the function could copy the whole of the \Software key out of curiosity as it contains many (thousands) sub keys and values.

When trying to copy HKEY_CURRENT_USER\Software to say HKEY_CURRENT_USER\Software2 the program would at some point crash out.  I found the first key that made it crash - it was because the sub key had only READ access - not full.

So for the Registry lib file i'm writing I've changed the open key command from:

   if RegOpenKeyExA(GetRoot(Key),ky,0,@KEY_ALL_ACCESS,ret) = 0

   to

   if RegOpenKeyExA(GetRoot(Key),ky,0,@KEY_READ,ret) = 0

@KEY_ALL_ACCESS will cause the RegOpenKeyExA to fail on read only keys, and after all if we are just copying a key we only need to read that key not have full access to it.

RegCopyKey function will copy all sub keys and values, the values it can copy are:

Strings
Expandable strings
Multi strings
Dwords
Qwords
Binary
Null entries (REG_NONE).

Now I've jumped that one, I'm writing a RegExport function to export keys and values to a .reg file
this new function will export all the above values with the exception of Qwords as these are UINT64 decimal values and at the moment I cannot convert them to hex.

Andy.