diff --git a/ctypes_generation/definitions/defines/cfgmgr32.txt b/ctypes_generation/definitions/defines/cfgmgr32.txt new file mode 100644 index 0000000..e8daba6 --- /dev/null +++ b/ctypes_generation/definitions/defines/cfgmgr32.txt @@ -0,0 +1,145 @@ +#define MAX_DEVICE_ID_LEN 200 +#define MAX_DEVNODE_ID_LEN MAX_DEVICE_ID_LEN + +#define MAX_GUID_STRING_LEN 39 // 38 chars + terminator null +#define MAX_CLASS_NAME_LEN 32 +#define MAX_PROFILE_LEN 80 + +#define MAX_CONFIG_VALUE 9999 +#define MAX_INSTANCE_VALUE 9999 + +#define MAX_MEM_REGISTERS 9 // Win95 compatibility--not applicable to 32-bit ConfigMgr +#define MAX_IO_PORTS 20 // Win95 compatibility--not applicable to 32-bit ConfigMgr +#define MAX_IRQS 7 // Win95 compatibility--not applicable to 32-bit ConfigMgr +#define MAX_DMA_CHANNELS 7 // Win95 compatibility--not applicable to 32-bit ConfigMgr + +#define DWORD_MAX 0xffffffff +#define DWORDLONG_MAX 0xffffffffffffffff + + + +#define CM_DEVCAP_LOCKSUPPORTED (0x00000001) +#define CM_DEVCAP_EJECTSUPPORTED (0x00000002) +#define CM_DEVCAP_REMOVABLE (0x00000004) +#define CM_DEVCAP_DOCKDEVICE (0x00000008) +#define CM_DEVCAP_UNIQUEID (0x00000010) +#define CM_DEVCAP_SILENTINSTALL (0x00000020) +#define CM_DEVCAP_RAWDEVICEOK (0x00000040) +#define CM_DEVCAP_SURPRISEREMOVALOK (0x00000080) +#define CM_DEVCAP_HARDWAREDISABLED (0x00000100) +#define CM_DEVCAP_NONDYNAMIC (0x00000200) + + +// +// Resource types +// +#define ResType_All (0x00000000) // Return all resource types +#define ResType_None (0x00000000) // Arbitration always succeeded +#define ResType_Mem (0x00000001) // Physical address resource +#define ResType_IO (0x00000002) // Physical I/O address resource +#define ResType_DMA (0x00000003) // DMA channels resource +#define ResType_IRQ (0x00000004) // IRQ resource +#define ResType_DoNotUse (0x00000005) // Used as spacer to sync subsequent ResTypes w/NT +#define ResType_BusNumber (0x00000006) // bus number resource +#define ResType_MemLarge (0x00000007) // Memory resources >= 4GB +#define ResType_MAX (0x00000007) // Maximum known (arbitrated) ResType + +#define ResType_Ignored_Bit (0x00008000) // Ignore this resource +#define ResType_ClassSpecific (0x0000FFFF) // class-specific resource +#define ResType_Reserved (0x00008000) // reserved for internal use +#define ResType_DevicePrivate (0x00008001) // device private data +#define ResType_PcCardConfig (0x00008002) // PC Card configuration data +#define ResType_MfCardConfig (0x00008003) // MF Card configuration data +#define ResType_Connection (0x00008004) // Connection (Resource Hub) resource + + +// +// Logical Config Flags (specified in call to CM_Get_First_Log_Conf +// +#define BASIC_LOG_CONF 0x00000000 // Specifies the req list. +#define FILTERED_LOG_CONF 0x00000001 // Specifies the filtered req list. +#define ALLOC_LOG_CONF 0x00000002 // Specifies the Alloc Element. +#define BOOT_LOG_CONF 0x00000003 // Specifies the RM Alloc Element. +#define FORCED_LOG_CONF 0x00000004 // Specifies the Forced Log Conf +#define OVERRIDE_LOG_CONF 0x00000005 // Specifies the Override req list. +#define NUM_LOG_CONF 0x00000006 // Number of Log Conf type +#define LOG_CONF_BITS 0x00000007 // The bits of the log conf type. + +#define PRIORITY_EQUAL_FIRST (0x00000008) // Same priority, new one first +#define PRIORITY_EQUAL_LAST (0x00000000) // Same priority, new one last +#define PRIORITY_BIT (0x00000008) + + +// +// Configuration Manager CONFIGRET return status codes +// + +#define CR_SUCCESS (0x00000000) +#define CR_DEFAULT (0x00000001) +#define CR_OUT_OF_MEMORY (0x00000002) +#define CR_INVALID_POINTER (0x00000003) +#define CR_INVALID_FLAG (0x00000004) +#define CR_INVALID_DEVNODE (0x00000005) +#define CR_INVALID_DEVINST CR_INVALID_DEVNODE +#define CR_INVALID_RES_DES (0x00000006) +#define CR_INVALID_LOG_CONF (0x00000007) +#define CR_INVALID_ARBITRATOR (0x00000008) +#define CR_INVALID_NODELIST (0x00000009) +#define CR_DEVNODE_HAS_REQS (0x0000000A) +#define CR_DEVINST_HAS_REQS CR_DEVNODE_HAS_REQS +#define CR_INVALID_RESOURCEID (0x0000000B) +#define CR_DLVXD_NOT_FOUND (0x0000000C) // WIN 95 ONLY +#define CR_NO_SUCH_DEVNODE (0x0000000D) +#define CR_NO_SUCH_DEVINST CR_NO_SUCH_DEVNODE +#define CR_NO_MORE_LOG_CONF (0x0000000E) +#define CR_NO_MORE_RES_DES (0x0000000F) +#define CR_ALREADY_SUCH_DEVNODE (0x00000010) +#define CR_ALREADY_SUCH_DEVINST CR_ALREADY_SUCH_DEVNODE +#define CR_INVALID_RANGE_LIST (0x00000011) +#define CR_INVALID_RANGE (0x00000012) +#define CR_FAILURE (0x00000013) +#define CR_NO_SUCH_LOGICAL_DEV (0x00000014) +#define CR_CREATE_BLOCKED (0x00000015) +#define CR_NOT_SYSTEM_VM (0x00000016) // WIN 95 ONLY +#define CR_REMOVE_VETOED (0x00000017) +#define CR_APM_VETOED (0x00000018) +#define CR_INVALID_LOAD_TYPE (0x00000019) +#define CR_BUFFER_SMALL (0x0000001A) +#define CR_NO_ARBITRATOR (0x0000001B) +#define CR_NO_REGISTRY_HANDLE (0x0000001C) +#define CR_REGISTRY_ERROR (0x0000001D) +#define CR_INVALID_DEVICE_ID (0x0000001E) +#define CR_INVALID_DATA (0x0000001F) +#define CR_INVALID_API (0x00000020) +#define CR_DEVLOADER_NOT_READY (0x00000021) +#define CR_NEED_RESTART (0x00000022) +#define CR_NO_MORE_HW_PROFILES (0x00000023) +#define CR_DEVICE_NOT_THERE (0x00000024) +#define CR_NO_SUCH_VALUE (0x00000025) +#define CR_WRONG_TYPE (0x00000026) +#define CR_INVALID_PRIORITY (0x00000027) +#define CR_NOT_DISABLEABLE (0x00000028) +#define CR_FREE_RESOURCES (0x00000029) +#define CR_QUERY_VETOED (0x0000002A) +#define CR_CANT_SHARE_IRQ (0x0000002B) +#define CR_NO_DEPENDENT (0x0000002C) +#define CR_SAME_RESOURCES (0x0000002D) +#define CR_NO_SUCH_REGISTRY_KEY (0x0000002E) +#define CR_INVALID_MACHINENAME (0x0000002F) // NT ONLY +#define CR_REMOTE_COMM_FAILURE (0x00000030) // NT ONLY +#define CR_MACHINE_UNAVAILABLE (0x00000031) // NT ONLY +#define CR_NO_CM_SERVICES (0x00000032) // NT ONLY +#define CR_ACCESS_DENIED (0x00000033) // NT ONLY +#define CR_CALL_NOT_IMPLEMENTED (0x00000034) +#define CR_INVALID_PROPERTY (0x00000035) +#define CR_DEVICE_INTERFACE_ACTIVE (0x00000036) +#define CR_NO_SUCH_DEVICE_INTERFACE (0x00000037) +#define CR_INVALID_REFERENCE_STRING (0x00000038) +#define CR_INVALID_CONFLICT_LIST (0x00000039) +#define CR_INVALID_INDEX (0x0000003A) +#define CR_INVALID_STRUCTURE_SIZE (0x0000003B) +#define NUM_CR_RESULTS (0x0000003C) + + +#define PCD_MAX_MEMORY 2 +#define PCD_MAX_IO 2 \ No newline at end of file diff --git a/ctypes_generation/definitions/defines/device_types.txt b/ctypes_generation/definitions/defines/device_types.txt new file mode 100644 index 0000000..93350a2 --- /dev/null +++ b/ctypes_generation/definitions/defines/device_types.txt @@ -0,0 +1,58 @@ +#define FILE_DEVICE_8042_PORT 0x00000027 +#define FILE_DEVICE_ACPI 0x00000032 +#define FILE_DEVICE_BATTERY 0x00000029 +#define FILE_DEVICE_BEEP 0x00000001 +#define FILE_DEVICE_BUS_EXTENDER 0x0000002a +#define FILE_DEVICE_CD_ROM 0x00000002 +#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 +#define FILE_DEVICE_CHANGER 0x00000030 +#define FILE_DEVICE_CONTROLLER 0x00000004 +#define FILE_DEVICE_DATALINK 0x00000005 +#define FILE_DEVICE_DFS 0x00000006 +#define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035 +#define FILE_DEVICE_DFS_VOLUME 0x00000036 +#define FILE_DEVICE_DISK 0x00000007 +#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 +#define FILE_DEVICE_DVD 0x00000033 +#define FILE_DEVICE_FILE_SYSTEM 0x00000009 +#define FILE_DEVICE_FIPS 0x0000003a +#define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034 +#define FILE_DEVICE_INPORT_PORT 0x0000000a +#define FILE_DEVICE_KEYBOARD 0x0000000b +#define FILE_DEVICE_KS 0x0000002f +#define FILE_DEVICE_KSEC 0x00000039 +#define FILE_DEVICE_MAILSLOT 0x0000000c +#define FILE_DEVICE_MASS_STORAGE 0x0000002d +#define FILE_DEVICE_MIDI_IN 0x0000000d +#define FILE_DEVICE_MIDI_OUT 0x0000000e +#define FILE_DEVICE_MODEM 0x0000002b +#define FILE_DEVICE_MOUSE 0x0000000f +#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010 +#define FILE_DEVICE_NAMED_PIPE 0x00000011 +#define FILE_DEVICE_NETWORK 0x00000012 +#define FILE_DEVICE_NETWORK_BROWSER 0x00000013 +#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 +#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 +#define FILE_DEVICE_NULL 0x00000015 +#define FILE_DEVICE_PARALLEL_PORT 0x00000016 +#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017 +#define FILE_DEVICE_PRINTER 0x00000018 +#define FILE_DEVICE_SCANNER 0x00000019 +#define FILE_DEVICE_SCREEN 0x0000001c +#define FILE_DEVICE_SERENUM 0x00000037 +#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a +#define FILE_DEVICE_SERIAL_PORT 0x0000001b +#define FILE_DEVICE_SMARTCARD 0x00000031 +#define FILE_DEVICE_SMB 0x0000002e +#define FILE_DEVICE_SOUND 0x0000001d +#define FILE_DEVICE_STREAMS 0x0000001e +#define FILE_DEVICE_TAPE 0x0000001f +#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 +#define FILE_DEVICE_TERMSRV 0x00000038 +#define FILE_DEVICE_TRANSPORT 0x00000021 +#define FILE_DEVICE_UNKNOWN 0x00000022 +#define FILE_DEVICE_VDM 0x0000002c +#define FILE_DEVICE_VIDEO 0x00000023 +#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 +#define FILE_DEVICE_WAVE_IN 0x00000025 +#define FILE_DEVICE_WAVE_OUT 0x00000026 \ No newline at end of file diff --git a/ctypes_generation/definitions/defines/error_helper.txt b/ctypes_generation/definitions/defines/error_helper.txt new file mode 100644 index 0000000..99a693e --- /dev/null +++ b/ctypes_generation/definitions/defines/error_helper.txt @@ -0,0 +1,5 @@ +#define APPLICATION_ERROR_MASK 0x20000000 +#define ERROR_SEVERITY_SUCCESS 0x00000000 +#define ERROR_SEVERITY_INFORMATIONAL 0x40000000 +#define ERROR_SEVERITY_WARNING 0x80000000 +#define ERROR_SEVERITY_ERROR 0xC0000000 \ No newline at end of file diff --git a/ctypes_generation/definitions/defines/setupapi.txt b/ctypes_generation/definitions/defines/setupapi.txt new file mode 100644 index 0000000..f63cac1 --- /dev/null +++ b/ctypes_generation/definitions/defines/setupapi.txt @@ -0,0 +1,168 @@ +// +// Device registry property codes +// (Codes marked as read-only (R) may only be used for +// SetupDiGetDeviceRegistryProperty) +// +// These values should cover the same set of registry properties +// as defined by the CM_DRP codes in cfgmgr32.h. +// +// Note that SPDRP codes are zero based while CM_DRP codes are one based! +// +#define SPDRP_DEVICEDESC (0x00000000) // DeviceDesc (R/W) +#define SPDRP_HARDWAREID (0x00000001) // HardwareID (R/W) +#define SPDRP_COMPATIBLEIDS (0x00000002) // CompatibleIDs (R/W) +#define SPDRP_UNUSED0 (0x00000003) // unused +#define SPDRP_SERVICE (0x00000004) // Service (R/W) +#define SPDRP_UNUSED1 (0x00000005) // unused +#define SPDRP_UNUSED2 (0x00000006) // unused +#define SPDRP_CLASS (0x00000007) // Class (R--tied to ClassGUID) +#define SPDRP_CLASSGUID (0x00000008) // ClassGUID (R/W) +#define SPDRP_DRIVER (0x00000009) // Driver (R/W) +#define SPDRP_CONFIGFLAGS (0x0000000A) // ConfigFlags (R/W) +#define SPDRP_MFG (0x0000000B) // Mfg (R/W) +#define SPDRP_FRIENDLYNAME (0x0000000C) // FriendlyName (R/W) +#define SPDRP_LOCATION_INFORMATION (0x0000000D) // LocationInformation (R/W) +#define SPDRP_PHYSICAL_DEVICE_OBJECT_NAME (0x0000000E) // PhysicalDeviceObjectName (R) +#define SPDRP_CAPABILITIES (0x0000000F) // Capabilities (R) +#define SPDRP_UI_NUMBER (0x00000010) // UiNumber (R) +#define SPDRP_UPPERFILTERS (0x00000011) // UpperFilters (R/W) +#define SPDRP_LOWERFILTERS (0x00000012) // LowerFilters (R/W) +#define SPDRP_BUSTYPEGUID (0x00000013) // BusTypeGUID (R) +#define SPDRP_LEGACYBUSTYPE (0x00000014) // LegacyBusType (R) +#define SPDRP_BUSNUMBER (0x00000015) // BusNumber (R) +#define SPDRP_ENUMERATOR_NAME (0x00000016) // Enumerator Name (R) +#define SPDRP_SECURITY (0x00000017) // Security (R/W, binary form) +#define SPDRP_SECURITY_SDS (0x00000018) // Security (W, SDS form) +#define SPDRP_DEVTYPE (0x00000019) // Device Type (R/W) +#define SPDRP_EXCLUSIVE (0x0000001A) // Device is exclusive-access (R/W) +#define SPDRP_CHARACTERISTICS (0x0000001B) // Device Characteristics (R/W) +#define SPDRP_ADDRESS (0x0000001C) // Device Address (R) +#define SPDRP_UI_NUMBER_DESC_FORMAT (0X0000001D) // UiNumberDescFormat (R/W) +#define SPDRP_DEVICE_POWER_DATA (0x0000001E) // Device Power Data (R) +#define SPDRP_REMOVAL_POLICY (0x0000001F) // Removal Policy (R) +#define SPDRP_REMOVAL_POLICY_HW_DEFAULT (0x00000020) // Hardware Removal Policy (R) +#define SPDRP_REMOVAL_POLICY_OVERRIDE (0x00000021) // Removal Policy Override (RW) +#define SPDRP_INSTALL_STATE (0x00000022) // Device Install State (R) +#define SPDRP_LOCATION_PATHS (0x00000023) // Device Location Paths (R) +#define SPDRP_BASE_CONTAINERID (0x00000024) // Base ContainerID (R) + +#define SPDRP_MAXIMUM_PROPERTY (0x00000025) // Upper bound on ordinals + + +// +// Inf parse outcomes +// +#define ERROR_EXPECTED_SECTION_NAME (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0) +#define ERROR_BAD_SECTION_NAME_LINE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|1) +#define ERROR_SECTION_NAME_TOO_LONG (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|2) +#define ERROR_GENERAL_SYNTAX (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|3) +// +// Inf runtime errors +// +#define ERROR_WRONG_INF_STYLE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x100) +#define ERROR_SECTION_NOT_FOUND (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x101) +#define ERROR_LINE_NOT_FOUND (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x102) +#define ERROR_NO_BACKUP (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x103) + + + +// +// Device Installer/other errors +// +#define ERROR_NO_ASSOCIATED_CLASS (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x200) +#define ERROR_CLASS_MISMATCH (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x201) +#define ERROR_DUPLICATE_FOUND (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x202) +#define ERROR_NO_DRIVER_SELECTED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x203) +#define ERROR_KEY_DOES_NOT_EXIST (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x204) +#define ERROR_INVALID_DEVINST_NAME (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x205) +#define ERROR_INVALID_CLASS (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x206) +#define ERROR_DEVINST_ALREADY_EXISTS (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x207) +#define ERROR_DEVINFO_NOT_REGISTERED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x208) +#define ERROR_INVALID_REG_PROPERTY (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x209) +#define ERROR_NO_INF (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x20A) +#define ERROR_NO_SUCH_DEVINST (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x20B) +#define ERROR_CANT_LOAD_CLASS_ICON (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x20C) +#define ERROR_INVALID_CLASS_INSTALLER (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x20D) +#define ERROR_DI_DO_DEFAULT (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x20E) +#define ERROR_DI_NOFILECOPY (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x20F) +#define ERROR_INVALID_HWPROFILE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x210) +#define ERROR_NO_DEVICE_SELECTED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x211) +#define ERROR_DEVINFO_LIST_LOCKED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x212) +#define ERROR_DEVINFO_DATA_LOCKED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x213) +#define ERROR_DI_BAD_PATH (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x214) +#define ERROR_NO_CLASSINSTALL_PARAMS (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x215) +#define ERROR_FILEQUEUE_LOCKED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x216) +#define ERROR_BAD_SERVICE_INSTALLSECT (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x217) +#define ERROR_NO_CLASS_DRIVER_LIST (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x218) +#define ERROR_NO_ASSOCIATED_SERVICE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x219) +#define ERROR_NO_DEFAULT_DEVICE_INTERFACE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x21A) +#define ERROR_DEVICE_INTERFACE_ACTIVE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x21B) +#define ERROR_DEVICE_INTERFACE_REMOVED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x21C) +#define ERROR_BAD_INTERFACE_INSTALLSECT (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x21D) +#define ERROR_NO_SUCH_INTERFACE_CLASS (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x21E) +#define ERROR_INVALID_REFERENCE_STRING (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x21F) +#define ERROR_INVALID_MACHINENAME (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x220) +#define ERROR_REMOTE_COMM_FAILURE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x221) +#define ERROR_MACHINE_UNAVAILABLE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x222) +#define ERROR_NO_CONFIGMGR_SERVICES (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x223) +#define ERROR_INVALID_PROPPAGE_PROVIDER (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x224) +#define ERROR_NO_SUCH_DEVICE_INTERFACE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x225) +#define ERROR_DI_POSTPROCESSING_REQUIRED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x226) +#define ERROR_INVALID_COINSTALLER (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x227) +#define ERROR_NO_COMPAT_DRIVERS (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x228) +#define ERROR_NO_DEVICE_ICON (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x229) +#define ERROR_INVALID_INF_LOGCONFIG (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x22A) +#define ERROR_DI_DONT_INSTALL (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x22B) +#define ERROR_INVALID_FILTER_DRIVER (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x22C) +#define ERROR_NON_WINDOWS_NT_DRIVER (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x22D) +#define ERROR_NON_WINDOWS_DRIVER (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x22E) +#define ERROR_NO_CATALOG_FOR_OEM_INF (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x22F) +#define ERROR_DEVINSTALL_QUEUE_NONNATIVE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x230) +#define ERROR_NOT_DISABLEABLE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x231) +#define ERROR_CANT_REMOVE_DEVINST (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x232) +#define ERROR_INVALID_TARGET (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x233) +#define ERROR_DRIVER_NONNATIVE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x234) +#define ERROR_IN_WOW64 (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x235) +#define ERROR_SET_SYSTEM_RESTORE_POINT (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x236) + +#define ERROR_SCE_DISABLED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x238) +#define ERROR_UNKNOWN_EXCEPTION (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x239) +#define ERROR_PNP_REGISTRY_ERROR (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x23A) +#define ERROR_REMOTE_REQUEST_UNSUPPORTED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x23B) +#define ERROR_NOT_AN_INSTALLED_OEM_INF (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x23C) +#define ERROR_INF_IN_USE_BY_DEVICES (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x23D) +#define ERROR_DI_FUNCTION_OBSOLETE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x23E) +#define ERROR_NO_AUTHENTICODE_CATALOG (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x23F) +#define ERROR_AUTHENTICODE_DISALLOWED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x240) +#define ERROR_AUTHENTICODE_TRUSTED_PUBLISHER (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x241) +#define ERROR_AUTHENTICODE_TRUST_NOT_ESTABLISHED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x242) +#define ERROR_AUTHENTICODE_PUBLISHER_NOT_TRUSTED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x243) +#define ERROR_SIGNATURE_OSATTRIBUTE_MISMATCH (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x244) +#define ERROR_ONLY_VALIDATE_VIA_AUTHENTICODE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x245) +#define ERROR_DEVICE_INSTALLER_NOT_READY (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x246) +#define ERROR_DRIVER_STORE_ADD_FAILED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x247) +#define ERROR_DEVICE_INSTALL_BLOCKED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x248) +#define ERROR_DRIVER_INSTALL_BLOCKED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x249) +#define ERROR_WRONG_INF_TYPE (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x24A) +#define ERROR_FILE_HASH_NOT_IN_CATALOG (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x24B) +#define ERROR_DRIVER_STORE_DELETE_FAILED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x24C) + +// +// Setupapi exception codes +// +#define ERROR_UNRECOVERABLE_STACK_OVERFLOW (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x300) +#define EXCEPTION_SPAPI_UNRECOVERABLE_STACK_OVERFLOW ERROR_UNRECOVERABLE_STACK_OVERFLOW + +// +// Backward compatibility--do not use. +// +#define ERROR_NO_DEFAULT_INTERFACE_DEVICE ERROR_NO_DEFAULT_DEVICE_INTERFACE +#define ERROR_INTERFACE_DEVICE_ACTIVE ERROR_DEVICE_INTERFACE_ACTIVE +#define ERROR_INTERFACE_DEVICE_REMOVED ERROR_DEVICE_INTERFACE_REMOVED +#define ERROR_NO_SUCH_INTERFACE_DEVICE ERROR_NO_SUCH_DEVICE_INTERFACE + + +// +// Win9x migration DLL error code +// +#define ERROR_NOT_INSTALLED (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x1000) diff --git a/ctypes_generation/definitions/functions/cfgmgr32.txt b/ctypes_generation/definitions/functions/cfgmgr32.txt new file mode 100644 index 0000000..a4eff3f --- /dev/null +++ b/ctypes_generation/definitions/functions/cfgmgr32.txt @@ -0,0 +1,163 @@ +CONFIGRET WINAPI CM_Enumerate_Classes( + _In_ ULONG ulClassIndex, + _Out_ LPGUID ClassGuid, + _In_ ULONG ulFlags + ); + +CONFIGRET WINAPI CM_Enumerate_Classes_Ex( + _In_ ULONG ulClassIndex, + _Out_ LPGUID ClassGuid, + _In_ ULONG ulFlags, + _In_opt_ HMACHINE hMachine + ); + +CONFIGRET WINAPI CM_Get_First_Log_Conf( + _Out_opt_ PLOG_CONF plcLogConf, + _In_ DEVINST dnDevInst, + _In_ ULONG ulFlags + ); + +CONFIGRET WINAPI CM_Get_First_Log_Conf_Ex( + _Out_opt_ PLOG_CONF plcLogConf, + _In_ DEVINST dnDevInst, + _In_ ULONG ulFlags, + _In_opt_ HMACHINE hMachine + ); + +CONFIGRET WINAPI CM_Get_Log_Conf_Priority( + _In_ LOG_CONF lcLogConf, + _Out_ PPRIORITY pPriority, + _In_ ULONG ulFlags + ); + +CONFIGRET WINAPI CM_Get_Log_Conf_Priority_Ex( + _In_ LOG_CONF lcLogConf, + _Out_ PPRIORITY pPriority, + _In_ ULONG ulFlags, + _In_opt_ HMACHINE hMachine + ); + +CONFIGRET WINAPI CM_Get_Next_Log_Conf( + _Out_opt_ PLOG_CONF plcLogConf, + _In_ LOG_CONF lcLogConf, + _In_ ULONG ulFlags + ); + +CONFIGRET WINAPI CM_Get_Next_Log_Conf_Ex( + _Out_opt_ PLOG_CONF plcLogConf, + _In_ LOG_CONF lcLogConf, + _In_ ULONG ulFlags, + _In_opt_ HMACHINE hMachine + ); + +CONFIGRET WINAPI CM_Free_Res_Des_Handle( + _In_ RES_DES rdResDes + ); + +CONFIGRET WINAPI CM_Get_Child( + _Out_ PDEVINST pdnDevInst, + _In_ DEVINST dnDevInst, + _In_ ULONG ulFlags + ); + +CONFIGRET WINAPI CM_Get_Child_Ex( + _Out_ PDEVINST pdnDevInst, + _In_ DEVINST dnDevInst, + _In_ ULONG ulFlags, + _In_opt_ HMACHINE hMachine + ); + +CONFIGRET WINAPI CM_Get_Next_Res_Des( + _Out_ PRES_DES prdResDes, + _In_ RES_DES rdResDes, + _In_ RESOURCEID ForResource, + _Out_opt_ PRESOURCEID pResourceID, + _In_ ULONG ulFlags + ); + +CONFIGRET WINAPI CM_Get_Parent( + _Out_ PDEVINST pdnDevInst, + _In_ DEVINST dnDevInst, + _In_ ULONG ulFlags + ); + +CONFIGRET WINAPI CM_Get_Parent_Ex( + _Out_ PDEVINST pdnDevInst, + _In_ DEVINST dnDevInst, + _In_ ULONG ulFlags, + _In_opt_ HMACHINE hMachine + ); + +CONFIGRET WINAPI CM_Get_Res_Des_Data( + _In_ RES_DES rdResDes, + _Out_writes_bytes_(BufferLen) PVOID Buffer, + _In_ ULONG BufferLen, + _In_ ULONG ulFlags + ); + +CONFIGRET WINAPI CM_Get_Next_Res_Des_Ex( + _Out_ PRES_DES prdResDes, + _In_ RES_DES rdResDes, + _In_ RESOURCEID ForResource, + _Out_opt_ PRESOURCEID pResourceID, + _In_ ULONG ulFlags, + _In_opt_ HMACHINE hMachine + ); + +CONFIGRET WINAPI CM_Get_Res_Des_Data_Size( + _Out_ PULONG pulSize, + _In_ RES_DES rdResDes, + _In_ ULONG ulFlags + ); + +CONFIGRET WINAPI CM_Get_Res_Des_Data_Size_Ex( + _Out_ PULONG pulSize, + _In_ RES_DES rdResDes, + _In_ ULONG ulFlags, + _In_opt_ HMACHINE hMachine + ); + +CONFIGRET WINAPI CM_Get_Sibling( + _Out_ PDEVINST pdnDevInst, + _In_ DEVINST dnDevInst, + _In_ ULONG ulFlags + ); + +CONFIGRET WINAPI CM_Get_Sibling_Ex( + _Out_ PDEVINST pdnDevInst, + _In_ DEVINST dnDevInst, + _In_ ULONG ulFlags, + _In_opt_ HMACHINE hMachine + ); + +WORD WINAPI CM_Get_Version(); + +WORD WINAPI CM_Get_Version_Ex( + _In_opt_ HMACHINE hMachine + ); + +CONFIGRET WINAPI CM_Locate_DevNodeA( + _Out_ PDEVINST pdnDevInst, + _In_opt_ DEVINSTID_A pDeviceID, + _In_ ULONG ulFlags + ); + +CONFIGRET WINAPI CM_Locate_DevNodeW( + _Out_ PDEVINST pdnDevInst, + _In_opt_ DEVINSTID_W pDeviceID, + _In_ ULONG ulFlags + ); + +CONFIGRET WINAPI CM_Locate_DevNode_ExA( + _Out_ PDEVINST pdnDevInst, + _In_opt_ DEVINSTID_A pDeviceID, + _In_ ULONG ulFlags, + _In_opt_ HMACHINE hMachine + ); + +CONFIGRET WINAPI CM_Locate_DevNode_ExW( + _Out_ PDEVINST pdnDevInst, + _In_opt_ DEVINSTID_W pDeviceID, + _In_ ULONG ulFlags, + _In_opt_ HMACHINE hMachine + ); \ No newline at end of file diff --git a/ctypes_generation/definitions/functions/setupapi.txt b/ctypes_generation/definitions/functions/setupapi.txt new file mode 100644 index 0000000..2923383 --- /dev/null +++ b/ctypes_generation/definitions/functions/setupapi.txt @@ -0,0 +1,91 @@ +BOOL WINAPI SetupDiClassNameFromGuidA( + _In_ CONST GUID *ClassGuid, + _Out_writes_(ClassNameSize) PSTR ClassName, + _In_ DWORD ClassNameSize, + _Out_opt_ PDWORD RequiredSize + ); + +BOOL WINAPI SetupDiClassNameFromGuidW( + _In_ CONST GUID *ClassGuid, + _Out_writes_(ClassNameSize) PWSTR ClassName, + _In_ DWORD ClassNameSize, + _Out_opt_ PDWORD RequiredSize + ); + + +BOOL WINAPI SetupDiClassNameFromGuidExA( + _In_ CONST GUID *ClassGuid, + _Out_writes_(ClassNameSize) PSTR ClassName, + _In_ DWORD ClassNameSize, + _Out_opt_ PDWORD RequiredSize, + _In_opt_ PCSTR MachineName, + _Reserved_ PVOID Reserved + ); + + +BOOL WINAPI SetupDiClassNameFromGuidExW( + _In_ CONST GUID *ClassGuid, + _Out_writes_(ClassNameSize) PWSTR ClassName, + _In_ DWORD ClassNameSize, + _Out_opt_ PDWORD RequiredSize, + _In_opt_ PCWSTR MachineName, + _Reserved_ PVOID Reserved + ); + +HDEVINFO WINAPI SetupDiGetClassDevsA( + _In_opt_ CONST GUID *ClassGuid, + _In_opt_ PCSTR Enumerator, + _In_opt_ HWND hwndParent, + _In_ DWORD Flags + ); + +HDEVINFO WINAPI SetupDiGetClassDevsW( + _In_opt_ CONST GUID *ClassGuid, + _In_opt_ PCWSTR Enumerator, + _In_opt_ HWND hwndParent, + _In_ DWORD Flags + ); + +BOOL WINAPI SetupDiDeleteDeviceInfo( + _In_ HDEVINFO DeviceInfoSet, + _In_ PSP_DEVINFO_DATA DeviceInfoData + ); + +BOOL WINAPI SetupDiEnumDeviceInfo( + _In_ HDEVINFO DeviceInfoSet, + _In_ DWORD MemberIndex, + _Out_ PSP_DEVINFO_DATA DeviceInfoData + ); + +BOOL WINAPI SetupDiDestroyDeviceInfoList( + _In_ HDEVINFO DeviceInfoSet + ); + +BOOL WINAPI SetupDiEnumDeviceInterfaces( + _In_ HDEVINFO DeviceInfoSet, + _In_opt_ PSP_DEVINFO_DATA DeviceInfoData, + _In_ CONST GUID *InterfaceClassGuid, + _In_ DWORD MemberIndex, + _Out_ PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData + ); + + +BOOL WINAPI SetupDiGetDeviceRegistryPropertyA( + _In_ HDEVINFO DeviceInfoSet, + _In_ PSP_DEVINFO_DATA DeviceInfoData, + _In_ DWORD Property, + _Out_opt_ PDWORD PropertyRegDataType, + _Out_writes_bytes_to_opt_(PropertyBufferSize, *RequiredSize) PBYTE PropertyBuffer, + _In_ DWORD PropertyBufferSize, + _Out_opt_ PDWORD RequiredSize + ); + +BOOL WINAPI SetupDiGetDeviceRegistryPropertyW( + _In_ HDEVINFO DeviceInfoSet, + _In_ PSP_DEVINFO_DATA DeviceInfoData, + _In_ DWORD Property, + _Out_opt_ PDWORD PropertyRegDataType, + _Out_writes_bytes_to_opt_(PropertyBufferSize, *RequiredSize) PBYTE PropertyBuffer, + _In_ DWORD PropertyBufferSize, + _Out_opt_ PDWORD RequiredSize + ); diff --git a/ctypes_generation/definitions/simple_types.txt b/ctypes_generation/definitions/simple_types.txt index 933536c..45e093b 100644 --- a/ctypes_generation/definitions/simple_types.txt +++ b/ctypes_generation/definitions/simple_types.txt @@ -20,6 +20,7 @@ LONG_PTR = PVOID DWORD_PTR = ULONG_PTR KAFFINITY = ULONG_PTR KPRIORITY = LONG + CHAR = c_char PCHAR = POINTER(CHAR) UCHAR = c_char @@ -48,6 +49,8 @@ LONG64 = c_longlong PLARGE_INTEGER = POINTER(LARGE_INTEGER) DWORD64 = ULONG64 PDWORD64 = POINTER(DWORD64) +// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/c575fb47-166c-48cd-a37c-e44cac05c3d6 +DWORDLONG = ULONGLONG SCODE = LONG CIMTYPE = LONG NET_IFINDEX = ULONG @@ -87,6 +90,8 @@ NCRYPT_SECRET_HANDLE = ULONG_PTR TRACEHANDLE = ULONG64 PTRACEHANDLE = POINTER(TRACEHANDLE) + + /* Symbols stuff */ /* https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-symsetcontext @@ -108,6 +113,10 @@ UINT16 = USHORT UINT32 = UINT UINT64 = ULONGLONG +/* LONG sized (lol..) */ +ULONG32 = UINT32 +LONG32 = INT32 + /* HANDLES */ PHANDLE = POINTER(HANDLE) @@ -122,6 +131,10 @@ HBRUSH = HANDLE HCRYPTPROV_OR_NCRYPT_KEY_HANDLE = PULONG EVT_HANDLE = HANDLE EVT_OBJECT_ARRAY_PROPERTY_HANDLE = HANDLE +// Define type for setup disk space list +HDSKSPC = HANDLE +// Define type for reference to device information set +HDEVINFO = HANDLE /* Network */ @@ -145,6 +158,37 @@ PSID_HASH_ENTRY = POINTER(SID_HASH_ENTRY) PSID = PVOID +/* cfgmgr32 types */ + +// Return value +CONFIGRET = DWORD + +DEVNODE = DWORD +DEVINST = DWORD +PDEVNODE = POINTER(DEVNODE) +PDEVINST = POINTER(DEVINST) + + +PRIORITY = ULONG +PPRIORITY = POINTER(PRIORITY) +RES_DES = DWORD_PTR +PRES_DES = POINTER(RES_DES) +HMACHINE = HANDLE +PHMACHINE = POINTER(HMACHINE) +LOG_CONF = DWORD_PTR +PLOG_CONF = POINTER(LOG_CONF) +RESOURCEID = ULONG +PRESOURCEID = POINTER(RESOURCEID) + +DEVNODEID_A = PCSTR +DEVINSTID_A = PCSTR +DEVNODEID_W = LPWSTR +DEVINSTID_W = LPWSTR + + + + + /* COM STUFF */ RPCOLEDATAREP = ULONG diff --git a/ctypes_generation/definitions/structures/cfgmgr32.txt b/ctypes_generation/definitions/structures/cfgmgr32.txt new file mode 100644 index 0000000..6e4c9e6 --- /dev/null +++ b/ctypes_generation/definitions/structures/cfgmgr32.txt @@ -0,0 +1,300 @@ + +/* + The IO_DES structure is used for specifying either a resource list or a resource requirements list that describes I/O port usage for a device instance. + Source : https://docs.microsoft.com/en-gb/windows/win32/api/cfgmgr32/ns-cfgmgr32-io_des +*/ +typedef struct IO_Des_s { + DWORD IOD_Count; + DWORD IOD_Type; + DWORDLONG IOD_Alloc_Base; + DWORDLONG IOD_Alloc_End; + DWORD IOD_DesFlags; +} IO_DES, *PIO_DES; + + +/* + The IO_RANGE structure specifies a resource requirements list that describes I/O port usage for a device instance. + Source : https://docs.microsoft.com/en-gb/windows/win32/api/cfgmgr32/ns-cfgmgr32-io_range +*/ + +typedef struct IO_Range_s { + DWORDLONG IOR_Align; + DWORD IOR_nPorts; + DWORDLONG IOR_Min; + DWORDLONG IOR_Max; + DWORD IOR_RangeFlags; + DWORDLONG IOR_Alias; +} IO_RANGE, *PIO_RANGE; + + +/* + The MEM_DES structure is used for specifying either a resource list or a resource requirements list that describes memory usage for a device instance. + Source : https://docs.microsoft.com/en-gb/windows/win32/api/cfgmgr32/ns-cfgmgr32-mem_des +*/ +typedef struct Mem_Des_s { + DWORD MD_Count; + DWORD MD_Type; + DWORDLONG MD_Alloc_Base; + DWORDLONG MD_Alloc_End; + DWORD MD_Flags; + DWORD MD_Reserved; +} MEM_DES, *PMEM_DES; + + +/* + The MEM_RANGE structure specifies a resource requirements list that describes memory usage for a device instance. + Source : https://docs.microsoft.com/en-gb/windows/win32/api/cfgmgr32/ns-cfgmgr32-mem_range +*/ + +typedef struct Mem_Range_s { + DWORDLONG MR_Align; + ULONG MR_nBytes; + DWORDLONG MR_Min; + DWORDLONG MR_Max; + DWORD MR_Flags; + DWORD MR_Reserved; +} MEM_RANGE, *PMEM_RANGE; + + +/* + The DMA_DES structure is used for specifying either a resource list or a resource requirements list that describes direct memory access (DMA) channel usage for a device instance. + Source : https://docs.microsoft.com/en-gb/windows/win32/api/cfgmgr32/ns-cfgmgr32-dma_des +*/ + +typedef struct DMA_Des_s { + DWORD DD_Count; + DWORD DD_Type; + DWORD DD_Flags; + ULONG DD_Alloc_Chan; +} DMA_DES, *PDMA_DES; + +/* + The DMA_RANGE structure specifies a resource requirements list that describes DMA channel usage for a device instance + Source : https://docs.microsoft.com/en-gb/windows/win32/api/cfgmgr32/ns-cfgmgr32-dma_range +*/ + +typedef struct DMA_Range_s { + ULONG DR_Min; + ULONG DR_Max; + ULONG DR_Flags; +} DMA_RANGE, *PDMA_RANGE; + + +/* + The IRQ_DES structure is used for specifying either a resource list or a resource requirements list that describes IRQ line usage for a device instance. + Source : https://docs.microsoft.com/en-gb/windows/win32/api/cfgmgr32/ns-cfgmgr32-irq_des_64 + +The structure from the header looks like: + +#if defined(NT_PROCESSOR_GROUPS) + USHORT IRQD_Flags; + USHORT IRQD_Group; +#else + DWORD IRQD_Flags; +#endif + +Let's ignore IRQD_Group it and only have a flag for now. +*/ + + +typedef struct IRQ_Des_64_s { + DWORD IRQD_Count; + DWORD IRQD_Type; + DWORD IRQD_Flags; + ULONG IRQD_Alloc_Num; + ULONG64 IRQD_Affinity; +} IRQ_DES_64, *PIRQ_DES_64; + +/* + The IRQ_DES structure is used for specifying either a resource list or a resource requirements list that describes IRQ line usage for a device instance. + Source : https://docs.microsoft.com/en-gb/windows/win32/api/cfgmgr32/ns-cfgmgr32-irq_des_32 + +The structure from the header looks like: + +#if defined(NT_PROCESSOR_GROUPS) + USHORT IRQD_Flags; + USHORT IRQD_Group; +#else + DWORD IRQD_Flags; +#endif + +Let's ignore IRQD_Group it and only have a flag for now. +*/ + +typedef struct IRQ_Des_32_s { + DWORD IRQD_Count; + DWORD IRQD_Type; + DWORD IRQD_Flags; + ULONG IRQD_Alloc_Num; + ULONG32 IRQD_Affinity; +} IRQ_DES_32, *PIRQ_DES_32; + + +/* + The IRQ_RANGE structure specifies a resource requirements list that describes IRQ line usage for a device instance. + Source : https://docs.microsoft.com/en-gb/windows/win32/api/cfgmgr32/ns-cfgmgr32-irq_range + +The definition from the header is: + +typedef struct IRQ_Range_s { + ULONG IRQR_Min; // minimum IRQ in the range + ULONG IRQR_Max; // maximum IRQ in the range +#if defined(NT_PROCESSOR_GROUPS) + USHORT IRQR_Flags; // flags describing the range (fIRQD flags) + USHORT IRQR_Rsvdz; // Reserved, must be zero. +#else + ULONG IRQR_Flags; // flags describing the range (fIRQD flags) +#endif +} IRQ_RANGE, *PIRQ_RANGE; + +Let's ignore IRQR_Rsvdz for now +*/ + +typedef struct IRQ_Range_s { + ULONG IRQR_Min; // minimum IRQ in the range + ULONG IRQR_Max; // maximum IRQ in the range + ULONG IRQR_Flags; // flags describing the range (fIRQD flags) +} IRQ_RANGE, *PIRQ_RANGE; + + +// Ressources + +// BUSNUMBER_DES structure +typedef struct BusNumber_Des_s { + DWORD BUSD_Count; // number of BUSNUMBER_RANGE structs in BUSNUMBER_RESOURCE + DWORD BUSD_Type; // size (in bytes) of BUSNUMBER_RANGE (BusNumberType_Range) + DWORD BUSD_Flags; // flags describing the range (currently unused) + ULONG BUSD_Alloc_Base; // specifies the first Bus that was allocated + ULONG BUSD_Alloc_End; // specifies the last Bus number that was allocated +} BUSNUMBER_DES, *PBUSNUMBER_DES; + +typedef struct BusNumber_Range_s { + ULONG BUSR_Min; + ULONG BUSR_Max; + ULONG BUSR_nBusNumbers; + ULONG BUSR_Flags; +} BUSNUMBER_RANGE, *PBUSNUMBER_RANGE; + +typedef struct BusNumber_Resource_s { + BUSNUMBER_DES BusNumber_Header; + BUSNUMBER_RANGE BusNumber_Data[ANYSIZE_ARRAY]; +} BUSNUMBER_RESOURCE, *PBUSNUMBER_RESOURCE; + +typedef struct CS_Des_s { + DWORD CSD_SignatureLength; + DWORD CSD_LegacyDataOffset; + DWORD CSD_LegacyDataSize; + DWORD CSD_Flags; + GUID CSD_ClassGuid; + BYTE CSD_Signature[ANYSIZE_ARRAY]; +} CS_DES, *PCS_DES; + +typedef struct CS_Resource_s { + CS_DES CS_Header; +} CS_RESOURCE, *PCS_RESOURCE; + +typedef struct DMA_Des_s { + DWORD DD_Count; + DWORD DD_Type; + DWORD DD_Flags; + ULONG DD_Alloc_Chan; +} DMA_DES, *PDMA_DES; + +typedef struct DMA_Resource_s { + DMA_DES DMA_Header; + DMA_RANGE DMA_Data[ANYSIZE_ARRAY]; +} DMA_RESOURCE, *PDMA_RESOURCE; + +typedef struct IO_Des_s { + DWORD IOD_Count; + DWORD IOD_Type; + DWORDLONG IOD_Alloc_Base; + DWORDLONG IOD_Alloc_End; + DWORD IOD_DesFlags; +} IO_DES, *PIO_DES; + +typedef struct IO_Resource_s { + IO_DES IO_Header; + IO_RANGE IO_Data[ANYSIZE_ARRAY]; +} IO_RESOURCE, *PIO_RESOURCE; + + +typedef struct IRQ_Resource_32_s { + IRQ_DES_32 IRQ_Header; + IRQ_RANGE IRQ_Data[ANYSIZE_ARRAY]; +} IRQ_RESOURCE_32, *PIRQ_RESOURCE_32; + + +typedef struct IRQ_Resource_64_s { + IRQ_DES_64 IRQ_Header; // info about IRQ range list + IRQ_RANGE IRQ_Data[ANYSIZE_ARRAY]; // list of IRQ ranges +} IRQ_RESOURCE_64, *PIRQ_RESOURCE_64; + +typedef struct Mem_Resource_s { + MEM_DES MEM_Header; + MEM_RANGE MEM_Data[ANYSIZE_ARRAY]; +} MEM_RESOURCE, *PMEM_RESOURCE; + +typedef struct MfCard_Des_s { + DWORD PMF_Count; + DWORD PMF_Type; + DWORD PMF_Flags; + BYTE PMF_ConfigOptions; + BYTE PMF_IoResourceIndex; + BYTE PMF_Reserved[2]; + DWORD PMF_ConfigRegisterBase; +} MFCARD_DES, *PMFCARD_DES; + +typedef struct MfCard_Resource_s { + MFCARD_DES MfCard_Header; +} MFCARD_RESOURCE, *PMFCARD_RESOURCE; + +typedef struct PcCard_Des_s { + DWORD PCD_Count; + DWORD PCD_Type; + DWORD PCD_Flags; + BYTE PCD_ConfigIndex; + BYTE PCD_Reserved[3]; + DWORD PCD_MemoryCardBase1; + DWORD PCD_MemoryCardBase2; + DWORD PCD_MemoryCardBase[PCD_MAX_MEMORY]; + WORD PCD_MemoryFlags[PCD_MAX_MEMORY]; + BYTE PCD_IoFlags[PCD_MAX_IO]; +} PCCARD_DES, *PPCCARD_DES; + +typedef struct PcCard_Resource_s { + PCCARD_DES PcCard_Header; +} PCCARD_RESOURCE, *PPCCARD_RESOURCE; + + +// +// MEM_LARGE_RANGE Structure +// +typedef struct Mem_Large_Range_s { + DWORDLONG MLR_Align; // specifies mask for base alignment + ULONGLONG MLR_nBytes; // specifies number of bytes required + DWORDLONG MLR_Min; // specifies minimum address of the range + DWORDLONG MLR_Max; // specifies maximum address of the range + DWORD MLR_Flags; // specifies flags describing range (fMD flags) + DWORD MLR_Reserved; +} MEM_LARGE_RANGE, *PMEM_LARGE_RANGE; + +// +// MEM_LARGE_DES structure +// +typedef struct Mem_Large_Des_s { + DWORD MLD_Count; // number of LARGE_MEM_RANGE structs in LARGE_MEM_RESOURCE + DWORD MLD_Type; // size (in bytes) of MEM_RANGE (MType_Range) + DWORDLONG MLD_Alloc_Base; // base memory address of range allocated + DWORDLONG MLD_Alloc_End; // end of allocated range + DWORD MLD_Flags; // flags describing allocated range (fMD flags) + DWORD MLD_Reserved; +} MEM_LARGE_DES, *PMEM_LARGE_DES; + +// +// MEM_LARGE_RESOURCE structure +// +typedef struct Mem_Large_Resource_s { + MEM_LARGE_DES MEM_LARGE_Header; // info about memory range list + MEM_LARGE_RANGE MEM_LARGE_Data[ANYSIZE_ARRAY]; // list of memory ranges +} MEM_LARGE_RESOURCE, *PMEM_LARGE_RESOURCE; \ No newline at end of file diff --git a/ctypes_generation/definitions/structures/setupapi.txt b/ctypes_generation/definitions/structures/setupapi.txt new file mode 100644 index 0000000..0578dd1 --- /dev/null +++ b/ctypes_generation/definitions/structures/setupapi.txt @@ -0,0 +1,23 @@ +// +// Device interface information structure (references a device +// interface that is associated with the device information +// element that owns it). +// +typedef struct _SP_DEVICE_INTERFACE_DATA { + DWORD cbSize; + GUID InterfaceClassGuid; + DWORD Flags; + ULONG_PTR Reserved; +} SP_DEVICE_INTERFACE_DATA, *PSP_DEVICE_INTERFACE_DATA; + + +// +// Device information structure (references a device instance +// that is a member of a device information set) +// +typedef struct _SP_DEVINFO_DATA { + DWORD cbSize; + GUID ClassGuid; + DWORD DevInst; // DEVINST handle + ULONG_PTR Reserved; +} SP_DEVINFO_DATA, *PSP_DEVINFO_DATA; \ No newline at end of file diff --git a/ctypes_generation/func_parser.py b/ctypes_generation/func_parser.py index c937f30..d13dcfe 100644 --- a/ctypes_generation/func_parser.py +++ b/ctypes_generation/func_parser.py @@ -45,7 +45,7 @@ class WinFunc(object): class WinFuncParser(Parser): known_io_info_type = ["__in", "__in_opt", "_In_", "_In_opt_", "_Inout_", "_Out_opt_", "_Out_", "_Reserved_", "_Inout_opt_", "__inout_opt", "__out", "__inout", "__deref_out", "_Outptr_"] - known_io_info_with_param = ["_Out_writes_bytes_", "_In_reads_bytes_opt_", "_In_reads_bytes_"] + known_io_info_with_param = ["_Out_writes_bytes_", "_In_reads_bytes_opt_", "_In_reads_bytes_", "_Out_writes_", "_Out_writes_bytes_to_opt_"] known_declarations = { "WINAPI" : "WINFUNCTYPE", "LDAPAPI" : "CFUNCTYPE" @@ -57,10 +57,10 @@ class WinFuncParser(Parser): if io_info.value not in self.known_io_info_type: if io_info.value not in self.known_io_info_with_param: raise ParsingError("Was expection IO_INFO got {0} instead".format(io_info)) - # Ignore IO infor params. - # Only 1 param accepted for now + # Ignore IO infos params. self.assert_token_type(OpenParenthesisToken) - self.assert_token_type(NameToken) + while type(self.peek()) is not CloseParenthesisToken: + self.next_token() self.assert_token_type(CloseParenthesisToken) return io_info