wslwinreg
Loading...
Searching...
No Matches
wslwinreg.common Namespace Reference

Windows constants and function common to both WSL and Cygwin implementaions. More...

Classes

class  FILETIME
 Structure to mimic the Windows FILETIME data type. More...

Functions

 winerror_to_errno (winerror)
 Convert a Windows error code into the matching errno code.
 convert_to_utf16 (input_string)
 Convert the input string into utf-16-le.
 to_registry_bytes (value, typ)
 Convert input data into appropriate Windows registry type.
 from_registry_bytes (input_data, input_size, typ)
 Convert raw Windows registry data into an appropriate Python object.

Variables

list __all__
 Items to import on "from .common import *".
 long = int
 Type long for Python 2 compatibility.
 basestring = str
 Type basestring for Python 2 compatibility.
int PY2 = 2
 True if the interpreter is Python 2.x.
 IS_LINUX = sys.platform.startswith("linux")
 Running on linux?
 IS_CYGWIN = sys.platform.startswith("cygwin")
 Running on Cygwin.
 IS_MSYS = sys.platform.startswith("msys")
 Running on MSYS.
str IS_WSL = IS_LINUX and "icrosoft" in platform.platform()
 Running on Windows Subsystem for Linux.
int ERROR_SUCCESS = 0x00000000
 The operation completed successfully.
int ERROR_FILE_NOT_FOUND = 0x00000002
 The system cannot find the file specified.
int ERROR_MORE_DATA = 0x000000ea
 More data is available.
int HKEY_CLASSES_ROOT = 0x80000000
 Registry entries subordinate to this key define types (or classes) of documents and the properties associated with those types.
int HKEY_CURRENT_USER = 0x80000001
 Registry entries subordinate to this key define the preferences of the current user.
int HKEY_LOCAL_MACHINE = 0x80000002
 Registry entries subordinate to this key define the physical state of the computer, including data about the bus type, system memory, and installed hardware and software.
int HKEY_USERS = 0x80000003
 Registry entries subordinate to this key define the default user configuration for new users on the local computer and the user configuration for the current user.
int HKEY_PERFORMANCE_DATA = 0x80000004
 Registry entries subordinate to this key reference the text strings that describe counters in US English.
int HKEY_CURRENT_CONFIG = 0x80000005
 Contains information about the current hardware profile of the local computer system.
int HKEY_DYN_DATA = 0x80000006
 Windows registry hive that contains information about hardware devices, including Plug and Play and network performance statistics.
int KEY_QUERY_VALUE = 0x00000001
 Required to query the values of a registry key.
int KEY_SET_VALUE = 0x00000002
 Required to create, delete, or set a registry value.
int KEY_CREATE_SUB_KEY = 0x00000004
 Required to create a subkey of a registry key.
int KEY_ENUMERATE_SUB_KEYS = 0x00000008
 Required to enumerate the subkeys of a registry key.
int KEY_NOTIFY = 0x00000010
 Required to request change notifications for a registry key or for subkeys of a registry key.
int KEY_CREATE_LINK = 0x00000020
 Reserved for system use.
int KEY_WOW64_32KEY = 0x00000200
 Indicates that an application on 64-bit Windows should operate on the 32-bit registry view.
int KEY_WOW64_64KEY = 0x00000100
 Indicates that an application on 64-bit Windows should operate on the 64-bit registry view.
int KEY_WOW64_RES = 0x00000300
 Mask for common.KEY_WOW64_32KEY or'd with common.KEY_WOW64_64KEY.
int KEY_WRITE = 0x00020006
 Combines the STANDARD_RIGHTS_WRITE, common.KEY_SET_VALUE, and common.KEY_CREATE_SUB_KEY access rights.
int KEY_EXECUTE = 0x00020019
 Equivalent to KEY_READ.
int KEY_READ = 0x00020019
 Combines the STANDARD_RIGHTS_READ, common.KEY_QUERY_VALUE, common.KEY_ENUMERATE_SUB_KEYS, and common.KEY_NOTIFY values.
int KEY_ALL_ACCESS = 0x000f003f
 Combines the STANDARD_RIGHTS_REQUIRED, common.KEY_QUERY_VALUE, common.KEY_SET_VALUE, common.KEY_CREATE_SUB_KEY, common.KEY_ENUMERATE_SUB_KEYS, common.KEY_NOTIFY, and common.KEY_CREATE_LINK access rights.
int REG_OPTION_RESERVED = 0x00000000
 Default key option, same as common.REG_OPTION_NON_VOLATILE.
int REG_OPTION_NON_VOLATILE = 0x00000000
 This key is not volatile; this is the default.
int REG_OPTION_VOLATILE = 0x00000001
 All keys created by the function are volatile.
int REG_OPTION_CREATE_LINK = 0x00000002
 This key is a symbolic link.
int REG_OPTION_BACKUP_RESTORE = 0x00000004
 If this flag is set, the function ignores the samDesired parameter and attempts to open the key with the access required to backup or restore the key.
int REG_OPTION_OPEN_LINK = 0x00000008
 The key to be opened is a symbolic link.
int REG_LEGAL_OPTION
 Mask for all registry key option flags.
int REG_CREATED_NEW_KEY = 0x00000001
 The key did not exist and was created.
int REG_OPENED_EXISTING_KEY = 0x00000002
 The key existed and was simply opened without being changed.
int REG_WHOLE_HIVE_VOLATILE = 0x00000001
 If specified, a new, volatile (memory only) set of registry information, or hive, is created.
int REG_REFRESH_HIVE = 0x00000002
 If set, the location of the subtree that the hKey parameter points to is restored to its state immediately following the last flush.
int REG_NO_LAZY_FLUSH = 0x00000004
 If set, disable lazy flushing.
int REG_NOTIFY_CHANGE_NAME = 0x00000001
 Notify the caller if a subkey is added or deleted.
int REG_NOTIFY_CHANGE_ATTRIBUTES = 0x00000002
 Notify the caller of changes to the attributes of the key, such as the security descriptor information.
int REG_NOTIFY_CHANGE_LAST_SET = 0x00000004
 Notify the caller of changes to a value of the key.
int REG_NOTIFY_CHANGE_SECURITY = 0x00000008
 Notify the caller of changes to the security descriptor of the key.
int REG_LEGAL_CHANGE_FILTER
 Mask for all REG_NOTIFY flags.
int REG_NONE = 0x000000000
 No defined value type.
int REG_SZ = 0x000000001
 A null-terminated string.
int REG_EXPAND_SZ = 0x000000002
 A null-terminated string that contains unexpanded references to environment variables (for example, "%PATH%")
int REG_BINARY = 0x000000003
 Binary data in any form.
int REG_DWORD = 0x000000004
 A 32-bit number.
int REG_DWORD_LITTLE_ENDIAN = 0x000000004
 A 32-bit number in little-endian format.
int REG_DWORD_BIG_ENDIAN = 0x000000005
 A 32-bit number in big-endian format.
int REG_LINK = 0x000000006
 A null-terminated Unicode string that contains the target path of a symbolic link that was created by calling the RegCreateKeyEx function with common.REG_OPTION_CREATE_LINK.
int REG_MULTI_SZ = 0x000000007
 A sequence of null-terminated strings, terminated by an empty string (\0).
int REG_RESOURCE_LIST = 0x000000008
 Device-driver resource list.
int REG_FULL_RESOURCE_DESCRIPTOR = 0x000000009
 A list of hardware resources that a physical device is using, detected and written into the \HardwareDescription tree by the system.
int REG_RESOURCE_REQUIREMENTS_LIST = 0x00000000a
 A device driver's list of possible hardware resources it or one of the physical devices it controls can use, from which the system writes a subset into the \ResourceMap tree.
int REG_QWORD = 0x0000000b
 A 64-bit number.
int REG_QWORD_LITTLE_ENDIAN = 0x0000000b
 A 64-bit number in little-endian format.
int FORMAT_MESSAGE_ALLOCATE_BUFFER = 256
 The function allocates a buffer large enough to hold the formatted message, and places a pointer to the allocated buffer at the address specified by lpBuffer.
int FORMAT_MESSAGE_IGNORE_INSERTS = 512
 Insert sequences in the message definition such as %1 are to be ignored and passed through to the output buffer unchanged.
int FORMAT_MESSAGE_FROM_STRING = 1024
 The lpSource parameter is a pointer to a null-terminated string that contains a message definition.
int FORMAT_MESSAGE_FROM_HMODULE = 2048
 The lpSource parameter is a module handle containing the message-table resource(s) to search.
int FORMAT_MESSAGE_FROM_SYSTEM = 4096
 The function should search the system message-table resource(s) for the requested message.
int FORMAT_MESSAGE_ARGUMENT_ARRAY = 8192
 The Arguments parameter is not a va_list structure, but is a pointer to an array of values that represent the arguments.
int FORMAT_MESSAGE_MAX_WIDTH_MASK = 255
 The function ignores regular line breaks in the message definition text.
int LANG_NEUTRAL = 0x00
 String has no associated language.
int SUBLANG_DEFAULT = 0x01
 User default sub language.
 LPCVOID = c_void_p
 const void * C void pointer
 LPVOID = c_void_p
 void * C void pointer
 BOOL = c_long
 BOOL 32 bit C integer type.
 WORD = c_ushort
 short int 16 bit C integer type
 DWORD = c_ulong
 unsigned int 32 bit C integer type
 PDWORD = POINTER(DWORD)
 unsigned int * 32 bit C integer pointer
 LPDWORD = PDWORD
 FAR unsigned int * 32 bit C pointer
 QWORD = c_ulonglong
 unsigned long long 64 bit C integer type
 PQWORD = POINTER(QWORD)
 unsigned long long * 64 bit C integer pointer
 LPQWORD = PQWORD
 FAR unsigned long long * 64 bit C integer pointer
 LONG = c_int
 signed int 32 bit signed C integer type
 PLONG = POINTER(LONG)
 signed int * 32 bit signed C integer pointer
 PBYTE = c_char_p
 signed char 8 bit signed C integer type
 LPBYTE = PBYTE
 unsigned char 8 bit unsigned C integer type
 LPSTR = c_char_p
 char * C string pointer
 LPWSTR = c_wchar_p
 wchar_t * C string pointer (16-bit)
 LPCWSTR = LPWSTR
 FAR wchar_t * C string pointer (16-bit)
 HANDLE = c_void_p
 HANDLE C data type from Windows (void *)
 HKEY = HANDLE
 HKEY C data type for Windows registry keys (void *)
 PHKEY = POINTER(HKEY)
 HKEY * C pointer to Windows HKEY (void **)
 HLOCAL = c_void_p
 HLOCAL Windows HLOCAL data type (void *)
 REGSAM = c_uint
 REGSAM Windows REGSAM C data type (unsigned int)
 PFILETIME = POINTER(FILETIME)
 FILETIME * pointer to Windows FILETIME structure
dict _winerror_to_errno
 Map for convert Windows error codes to errno codes.

Detailed Description

Windows constants and function common to both WSL and Cygwin implementaions.

This module contains numerous constants for Windows and functions common to both the WSL bridge and the Cygwin/MSYS2 cdll implementations of the wslwinreg module.

Function Documentation

◆ convert_to_utf16()

wslwinreg.common.convert_to_utf16 ( input_string)

Convert the input string into utf-16-le.

Parameters
input_stringstring encoded in locale.getpreferredencoding()
Returns
Byte array in little endian UTF-16

◆ from_registry_bytes()

wslwinreg.common.from_registry_bytes ( input_data,
input_size,
typ )

Convert raw Windows registry data into an appropriate Python object.

Parameters
input_dataRaw binary data
input_sizeSize in bytes of the input data
typWindows registry type to convert from (Example REG_DWORD)
Returns
Data converted to appropriate Python object, or None.

◆ to_registry_bytes()

wslwinreg.common.to_registry_bytes ( value,
typ )

Convert input data into appropriate Windows registry type.

Parameters
valueValue to convert
typWindows registry type to convert to (Example REG_DWORD)
Returns
A ctypes.c_char array.
Exception
ValueError for invalid input or TypeError for bad type.

◆ winerror_to_errno()

wslwinreg.common.winerror_to_errno ( winerror)

Convert a Windows error code into the matching errno code.

Parameters
winerrorInteger error code number returned by Windows
Returns
Corresponding errno error code or EINVAL if no match.

Variable Documentation

◆ REG_LEGAL_CHANGE_FILTER

int wslwinreg.common.REG_LEGAL_CHANGE_FILTER
Initial value:
1= REG_NOTIFY_CHANGE_NAME | \
2 REG_NOTIFY_CHANGE_ATTRIBUTES | \
3 REG_NOTIFY_CHANGE_LAST_SET | \
4 REG_NOTIFY_CHANGE_SECURITY

Mask for all REG_NOTIFY flags.

◆ REG_LEGAL_OPTION

int wslwinreg.common.REG_LEGAL_OPTION
Initial value:
1= REG_OPTION_RESERVED | \
2 REG_OPTION_NON_VOLATILE | \
3 REG_OPTION_VOLATILE | \
4 REG_OPTION_CREATE_LINK | \
5 REG_OPTION_BACKUP_RESTORE | \
6 REG_OPTION_OPEN_LINK

Mask for all registry key option flags.