'// Search_Value - search for a value under the key
'** Conversion Routines **
'// Make_LEndian16 - convert integer to 16bit little_endian
'// Make_LEndian32 - convert long to 32bit little_endian
'// Make_BEndian32 - convert long to big endian format
'** Error Logging **
'// Get_Error - interprets errors passed from dll
'// Log_Error - sends errors to a log file
'** Security Functions **
'// Test_Access - test users level of access permissions
'// Set_Key_Permissions - change access permissions to a key
'** Backup and Restore **
'// Save_Key - save a binary image of a registry key
'// Restore_Key - restore key from binary image
'//root keys
Public Enum HKEY_Type
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
HKEY_PERFORMANCE_DATA = &H80000004
HKEY_CURRENT_CONFIG = &H80000005
HKEY_DYN_DATA = &H80000006
End Enum
'//Generic Access Rights
Private Const GENERIC_ALL As Long = &H10000000
Private Const GENERIC_READ As Long = &H80000000
Private Const GENERIC_EXECUTE As Long = &H20000000
Private Const GENERIC_WRITE As Long = &H40000000
'//Standard Access Rights
Private Const DELETE As Long = &H10000
Private Const READ_CONTROL As Long = &H20000
Private Const WRITE_DAC As Long = &H40000
Private Const WRITE_OWNER As Long = &H80000
Private Const SYNCHRONIZE As Long = &H100000
Private Const STANDARD_RIGHTS_REQUIRED As Long = &HF0000
Private Const STANDARD_RIGHTS_READ As Long = READ_CONTROL
Private Const STANDARD_RIGHTS_WRITE As Long = READ_CONTROL
Private Const STANDARD_RIGHTS_EXECUTE As Long = READ_CONTROL
Private Const STANDARD_RIGHTS_ALL As Long = &H1F0000
Private Const SPECIFIC_RIGHTS_ALL As Long = &HFFFF
Private Const ACCESS_SYSTEM_SECURITY As Long = &H1000000
Private Const MAXIMUM_ALLOWED As Long = &H2000000
'//inherit flags of an Ace header.
Private Const OBJECT_INHERIT_ACE As Long = &H1
Private Const CONTAINER_INHERIT_ACE As Long = &H2
Private Const NO_PROPAGATE_INHERIT_ACE As Long = &H4
Private Const INHERIT_ONLY_ACE As Long = &H8
Private Const INHERITED_ACE As Long = &H10
Private Const VALID_INHERIT_FLAGS As Long = &H1F
'//security descriptor flags.
Private Const SE_DACL_AUTO_INHERIT_REQ As Long = &H100
Private Const SE_SACL_AUTO_INHERIT_REQ As Long = &H200
Private Const SE_DACL_AUTO_INHERITED As Long = &H400
Private Const SE_SACL_AUTO_INHERITED As Long = &H800
Private Const SE_DACL_PROTECTED As Long = &H1000
Private Const SE_SACL_PROTECTED As Long = &H2000
'//ACE being added.
Private Const ACCESS_ALLOWED_ACE_TYPE As Integer = 0
Private Const ACCESS_DENIED_ACE_TYPE As Integer = 1
'//well-known SIDs, users and groups
Private Const SECURITY_WORLD_SID_AUTHORITY As Long = &H1
Private Const SECURITY_NT_AUTHORITY As Long = &H5
Private Const SECURITY_BUILTIN_DOMAIN_RID As Long = &H20
Private Const DOMAIN_ALIAS_RID_ADMINS As Long = &H220
Private Const DOMAIN_ALIAS_RID_USERS As Long = &H221
Private Const SECURITY_LOCAL_SYSTEM_RID As Long = &H12
Private Const SECURITY_WORLD_RID As Long = &H0
Private Const DOMAIN_USER_RID_ADMIN As Long = &H1F4
Private Const DOMAIN_USER_RID_GUEST As Long = &H1F5
Private Const DOMAIN_GROUP_RID_ADMINS As Long = &H200
Private Const INVALID_HANDLE_VALUE As Integer = -1
Private Const OPEN_EXISTING As Integer = 3
Private Const FILE_FLAG_BACKUP_SEMANTICS As Long = &H2000000
'//API Constants
Private Const DACL_SECURITY_INFORMATION As Long = &H4
Private Const SECURITY_DESCRIPTOR_REVISION As Integer = 1
Private Const SECURITY_DESCRIPTOR_MIN_LENGTH As Integer = 20
Private Const SD_SIZE As Double = (65536 + SECURITY_DESCRIPTOR_MIN_LENGTH)
Private Const ACL_REVISION2 As Integer = 2
Private Const ACL_REVISION As Integer = 2
Private Const MAXDWORD As Long = &HFFFFFFFF
Private Const SidTypeUser As Integer = 1
Private Const AclSizeInformation As Integer = 2
'//Registry access masks
Private Const KEY_QUERY_VALUE As Long = &H1
Private Const KEY_SET_VALUE As Long = &H2
Private Const KEY_CREATE_SUB_KEY As Long = &H4
Private Const KEY_ENUMERATE_SUB_KEYS As Long = &H8
Private Const KEY_NOTIFY As Long = &H10
Private Const KEY_CREATE_LINK As Long = &H20
Private Const KEY_WOW64_32KEY As Long = &H200
Private Const KEY_WOW64_64KEY As Long = &H100
Private Const KEY_READ As Double = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
Private Const KEY_WRITE As Double = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))
Private Const KEY_EXECUTE As Double = ((KEY_READ) And (Not SYNCHRONIZE))
Private Const KEY_ALL_ACCESS As Double = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Public Enum REGISTRY_ACCESS
'//unique rights
Registry_Read = KEY_READ
Registry_Write = KEY_WRITE
Registry_Execute = KEY_EXECUTE
Registry_Full_Control = KEY_ALL_ACCESS
'//compound rights
Registry_Read_Write = KEY_READ Or KEY_WRITE
Registry_Read_Execute = KEY_READ Or KEY_EXECUTE
Registry_Read_Write_Execute = KEY_READ Or KEY_WRITE Or KEY_EXECUTE
End Enum
Public Enum ACCESS_TYPE
'//permissive DACL
Access_Allowed
'//deny DACL
Access_Denied
End Enum
'<<<inheritence properties>>>
Public Enum INHERITENCE_FLAGS
Container_Inherit = CONTAINER_INHERIT_ACE
Object_Inherit = OBJECT_INHERIT_ACE
Non_Propogate = NO_PROPAGATE_INHERIT_ACE
Inherit_Only = INHERIT_ONLY_ACE
Inherit_Ace = INHERITED_ACE
Object_Container_Inherit = OBJECT_INHERIT_ACE Or CONTAINER_INHERIT_ACE
Child_Inherit_Level = OBJECT_INHERIT_ACE Or CONTAINER_INHERIT_ACE Or NO_PROPAGATE_INHERIT_ACE
Child_Container_Inherit = OBJECT_INHERIT_ACE Or CONTAINER_INHERIT_ACE Or INHERIT_ONLY_ACE
Family_Container_Inherit = OBJECT_INHERIT_ACE Or CONTAINER_INHERIT_ACE Or INHERITED_ACE