From 8adca7cd8986f6d984d0b2c514fba33ac02b4cfa Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 16 Nov 2026 01:12:04 +0100 Subject: Move device database to data/devices.txt with user-extensible device files The device table is now maintained in data/devices.txt (one device per line, "#!format 1" header) and the built-in table src/devices.c is generated from it at build time by data/gen-devices.sh. At runtime the built-in table is merged with, in order, /devices.txt and ~/.libirecovery/devices.txt (%APPDATA%\libirecovery on Windows, or $LIBIRECOVERY_DEVICE_DB). Entries are matched by hardware_model; later files override earlier ones. User files must be owned by the user (or root) and not world-writable. Add irecv_devices_add() which appends an entry to the user device file so applications can register new models without rebuilding the library. If no display name is given, an existing entry keeps its name and a new one is named " ()". Adding is refused if another hardware_model already uses the same chip and board ID. --- src/Makefile.am | 11 +- src/devicedb.c | 661 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/devicedb.h | 36 +++ src/libirecovery.c | 396 ++------------------------------ 4 files changed, 723 insertions(+), 381 deletions(-) create mode 100644 src/devicedb.c create mode 100644 src/devicedb.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index f80ffa7..f65607e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include -DIRECV_DATADIR=\"$(pkgdatadir)\" AM_CFLAGS = \ $(GLOBAL_CFLAGS) \ @@ -14,7 +14,14 @@ AM_LDFLAGS = \ lib_LTLIBRARIES = libirecovery-1.0.la libirecovery_1_0_la_CFLAGS = $(AM_CFLAGS) libirecovery_1_0_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBIRECOVERY_SO_VERSION) -no-undefined -libirecovery_1_0_la_SOURCES = libirecovery.c +libirecovery_1_0_la_SOURCES = libirecovery.c devicedb.c devicedb.h devices.c + +# The built-in device table is generated from data/devices.txt +BUILT_SOURCES = devices.c +CLEANFILES = devices.c + +devices.c: $(top_srcdir)/data/devices.txt $(top_srcdir)/data/gen-devices.sh + $(AM_V_GEN)$(SHELL) $(top_srcdir)/data/gen-devices.sh $(top_srcdir)/data/devices.txt > $@.tmp && mv $@.tmp $@ if WIN32 libirecovery_1_0_la_LDFLAGS += -avoid-version diff --git a/src/devicedb.c b/src/devicedb.c new file mode 100644 index 0000000..9ca0cc8 --- /dev/null +++ b/src/devicedb.c @@ -0,0 +1,661 @@ +/* + * devicedb.c + * Device database: built-in table merged with optional device files + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser General Public License + * (LGPL) version 2.1 which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-2.1.html + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * Device files start with an optional "#!format N" line (N = DEVICES_FORMAT_VERSION); + * a file without it is format 1. Files declaring a newer format are ignored. + * + * The table is assembled from, in order (later entries override earlier + * ones with the same hardware_model): + * 1. the built-in table generated from data/devices.txt + * 2. /devices.txt (not on Windows) + * 3. ~/.libirecovery/devices.txt (%APPDATA%\libirecovery\devices.txt on Windows) + * or the file named by $LIBIRECOVERY_DEVICE_DB + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#ifdef _WIN32 +#include +#include +#define strcasecmp _stricmp +#define PATH_SEP "\\" +#else +#include +#include +#include +#define PATH_SEP "/" +#endif + +#include + +#ifdef IRECV_STATIC + #define IRECV_API +#elif defined(_WIN32) + #define IRECV_API __declspec( dllexport ) +#else + #if __GNUC__ >= 4 + #define IRECV_API __attribute__((visibility("default"))) + #else + #define IRECV_API + #endif +#endif + +#include "libirecovery.h" +#include "devicedb.h" + +#define DEVICES_FILE_NAME "devices.txt" +#define USER_DIR_NAME "libirecovery" +#define ENV_DEVICE_DB "LIBIRECOVERY_DEVICE_DB" +#define DEVICES_FORMAT_VERSION 1 +#define MAX_LINE_LENGTH 512 +#define MAX_ENTRIES 16384 + +#define debug(...) if (db_debug) fprintf(stderr, __VA_ARGS__) + +struct db_generation { + struct irecv_device* table; + void** blocks; + size_t block_count; + struct db_generation* prev; +}; + +struct db_builder { + struct irecv_device* table; + size_t count; + size_t capacity; + void** blocks; + size_t block_count; + size_t block_capacity; +}; + +static mutex_t db_mutex; +static int db_debug = 0; +static int db_loaded = 0; +static struct db_generation* db_current = NULL; + +static char* join_path(const char* dir, const char* name) +{ + size_t len = strlen(dir) + strlen(PATH_SEP) + strlen(name) + 1; + char* path = malloc(len); + if (path) { + snprintf(path, len, "%s%s%s", dir, PATH_SEP, name); + } + return path; +} + +static char* get_user_dir(void) +{ +#ifdef _WIN32 + const char* base = getenv("APPDATA"); + if (!base || !*base) { + return NULL; + } + return join_path(base, USER_DIR_NAME); +#else + const char* home = getenv("HOME"); + if (!home || !*home) { + struct passwd* pw = getpwuid(getuid()); + home = pw ? pw->pw_dir : NULL; + } + if (!home || !*home) { + return NULL; + } + return join_path(home, "." USER_DIR_NAME); +#endif +} + +static char* get_user_file(int* is_default) +{ + const char* env = getenv(ENV_DEVICE_DB); + char* dir; + char* path; + + if (env && *env) { + *is_default = 0; + return strdup(env); + } + *is_default = 1; + dir = get_user_dir(); + if (!dir) { + return NULL; + } + path = join_path(dir, DEVICES_FILE_NAME); + free(dir); + return path; +} + +/* A user-controlled file must belong to us (or root) and not be world-writable. */ +static int file_is_trusted(FILE* f) +{ +#ifdef _WIN32 + (void)f; + return 1; +#else + struct stat st; + if (fstat(fileno(f), &st) != 0 || !S_ISREG(st.st_mode)) { + return 0; + } + if (st.st_uid != geteuid() && st.st_uid != 0) { + return 0; + } + return (st.st_mode & S_IWOTH) == 0; +#endif +} + +static int has_control_chars(const char* s) +{ + for (; *s; s++) { + if ((unsigned char)*s < 0x20 || *s == 0x7f) { + return 1; + } + } + return 0; +} + +static int parse_u32(const char* s, unsigned int* out) +{ + char* end = NULL; + unsigned long v; + + if (!isdigit((unsigned char)s[0])) { + return -1; + } + errno = 0; + v = strtoul(s, &end, 0); + if (errno != 0 || *end != '\0' || v > 0xFFFFFFFFUL) { + return -1; + } + *out = (unsigned int)v; + return 0; +} + +/* Parses one line in place. Returns 1 for an entry, 0 for a blank or comment line, -1 if malformed. + * The strings in 'dev' point into 'line'. */ +static int parse_line(char* line, struct irecv_device* dev) +{ + char* tok[4]; + char* p = line; + size_t len; + int i; + + while (isspace((unsigned char)*p)) p++; + if (*p == '\0' || *p == '#') { + return 0; + } + for (i = 0; i < 4; i++) { + tok[i] = p; + while (*p && !isspace((unsigned char)*p)) p++; + if (*p == '\0') { + return -1; + } + *p++ = '\0'; + while (isspace((unsigned char)*p)) p++; + } + len = strlen(p); + while (len > 0 && isspace((unsigned char)p[len-1])) { + p[--len] = '\0'; + } + if (len == 0 || has_control_chars(p)) { + return -1; + } + if (parse_u32(tok[2], &dev->board_id) != 0 || parse_u32(tok[3], &dev->chip_id) != 0) { + return -1; + } + dev->product_type = tok[0]; + dev->hardware_model = tok[1]; + dev->display_name = p; + return 1; +} + +static int builder_add_block(struct db_builder* b, void* block) +{ + if (b->block_count == b->block_capacity) { + size_t ncap = b->block_capacity ? b->block_capacity * 2 : 16; + void** nb = realloc(b->blocks, ncap * sizeof(void*)); + if (!nb) { + return -1; + } + b->blocks = nb; + b->block_capacity = ncap; + } + b->blocks[b->block_count++] = block; + return 0; +} + +/* Adds or replaces an entry (matched by hardware_model); copies the strings. */ +static int builder_apply(struct db_builder* b, const struct irecv_device* dev) +{ + size_t l1 = strlen(dev->product_type) + 1; + size_t l2 = strlen(dev->hardware_model) + 1; + size_t l3 = strlen(dev->display_name) + 1; + struct irecv_device* slot = NULL; + char* block; + size_t i; + + for (i = 0; i < b->count; i++) { + if (!strcasecmp(b->table[i].hardware_model, dev->hardware_model)) { + slot = &b->table[i]; + break; + } + } + if (!slot && b->count >= MAX_ENTRIES) { + return -1; + } + if (!slot && b->count + 2 > b->capacity) { + size_t ncap = b->capacity * 2; + struct irecv_device* nt = realloc(b->table, ncap * sizeof(struct irecv_device)); + if (!nt) { + return -1; + } + b->table = nt; + b->capacity = ncap; + } + block = malloc(l1 + l2 + l3); + if (!block) { + return -1; + } + if (builder_add_block(b, block) != 0) { + free(block); + return -1; + } + memcpy(block, dev->product_type, l1); + memcpy(block + l1, dev->hardware_model, l2); + memcpy(block + l1 + l2, dev->display_name, l3); + + if (!slot) { + slot = &b->table[b->count++]; + } + slot->product_type = block; + slot->hardware_model = block + l1; + slot->display_name = block + l1 + l2; + slot->board_id = dev->board_id; + slot->chip_id = dev->chip_id; + return 0; +} + +/* Returns the declared format version (1 if none), or -1 if it is invalid. + * Only the directive lines before the first entry count. Leaves the file position undefined. */ +static int scan_format(FILE* f) +{ + char line[MAX_LINE_LENGTH]; + int version = 1; + + rewind(f); + while (fgets(line, sizeof(line), f)) { + char* p = line; + char* end = NULL; + long v; + + while (isspace((unsigned char)*p)) p++; + if (*p == '\0') continue; + if (*p != '#') break; + if (strncmp(p, "#!format", 8) != 0 || !isspace((unsigned char)p[8])) continue; + p += 8; + while (isspace((unsigned char)*p)) p++; + errno = 0; + v = strtol(p, &end, 10); + if (end == p || errno != 0 || v < 1 || v > 0x7fff) { + return -1; + } + while (isspace((unsigned char)*end)) end++; + if (*end != '\0') { + return -1; + } + version = (int)v; + break; + } + return version; +} + +static int format_supported(FILE* f, const char* path) +{ + int version = scan_format(f); + if (version < 1 || version > DEVICES_FORMAT_VERSION) { + debug("%s: %s: unsupported or invalid device file format, ignored\n", __func__, path); + return 0; + } + rewind(f); + return 1; +} + +/* Returns the number of entries applied, or -1 if the file could not be used. */ +static int load_file(struct db_builder* b, const char* path, int check_trust) +{ + char line[MAX_LINE_LENGTH]; + int lineno = 0; + int applied = 0; + FILE* f = fopen(path, "r"); + + if (!f) { + return -1; + } + if (check_trust && !file_is_trusted(f)) { + debug("%s: ignoring device file with unsafe ownership or permissions: %s\n", __func__, path); + fclose(f); + return -1; + } + if (!format_supported(f, path)) { + fclose(f); + return -1; + } + while (fgets(line, sizeof(line), f)) { + struct irecv_device dev; + size_t len = strlen(line); + int r; + + lineno++; + if (len == sizeof(line) - 1 && line[len-1] != '\n') { + int c; + while ((c = fgetc(f)) != EOF && c != '\n') {} + debug("%s: %s:%d: line too long, skipped\n", __func__, path, lineno); + continue; + } + r = parse_line(line, &dev); + if (r < 0) { + debug("%s: %s:%d: malformed entry, skipped\n", __func__, path, lineno); + } else if (r > 0) { + if (builder_apply(b, &dev) != 0) { + debug("%s: %s:%d: unable to add entry\n", __func__, path, lineno); + break; + } + applied++; + } + } + fclose(f); + return applied; +} + +/* Returns NULL if no device file contributed anything, i.e. the built-in table is to be used as is. */ +static struct db_generation* build_generation(void) +{ + struct db_builder b; + struct db_generation* gen = NULL; + size_t builtin_count = 0; + int total = 0; + int is_default = 0; + char* user_file; + int r; + + while (irecv_devices_builtin[builtin_count].product_type != NULL) { + builtin_count++; + } + memset(&b, 0, sizeof(b)); + b.capacity = builtin_count + 32; + b.table = malloc(b.capacity * sizeof(struct irecv_device)); + if (!b.table) { + return NULL; + } + memcpy(b.table, irecv_devices_builtin, builtin_count * sizeof(struct irecv_device)); + b.count = builtin_count; + +#if defined(IRECV_DATADIR) && !defined(_WIN32) + { + char* sys_file = join_path(IRECV_DATADIR, DEVICES_FILE_NAME); + if (sys_file) { + r = load_file(&b, sys_file, 0); + if (r > 0) total += r; + free(sys_file); + } + } +#endif + user_file = get_user_file(&is_default); + if (user_file) { + r = load_file(&b, user_file, 1); + if (r > 0) total += r; + free(user_file); + } + + if (total > 0) { + gen = calloc(1, sizeof(*gen)); + } + if (!gen) { + size_t i; + for (i = 0; i < b.block_count; i++) free(b.blocks[i]); + free(b.blocks); + free(b.table); + return NULL; + } + memset(&b.table[b.count], 0, sizeof(struct irecv_device)); + b.table[b.count].board_id = (unsigned int)-1; + b.table[b.count].chip_id = (unsigned int)-1; + gen->table = b.table; + gen->blocks = b.blocks; + gen->block_count = b.block_count; + return gen; +} + +static void free_generation(struct db_generation* gen) +{ + size_t i; + for (i = 0; i < gen->block_count; i++) free(gen->blocks[i]); + free(gen->blocks); + free(gen->table); + free(gen); +} + +void irecv_devicedb_init(void) +{ + mutex_init(&db_mutex); +} + +void irecv_devicedb_cleanup(void) +{ + mutex_lock(&db_mutex); + while (db_current) { + struct db_generation* prev = db_current->prev; + free_generation(db_current); + db_current = prev; + } + db_loaded = 0; + mutex_unlock(&db_mutex); + mutex_destroy(&db_mutex); +} + +void irecv_devicedb_set_debug(int level) +{ + db_debug = level; +} + +struct irecv_device* irecv_devicedb_get(void) +{ + struct irecv_device* table; + + mutex_lock(&db_mutex); + if (!db_loaded) { + db_current = build_generation(); + db_loaded = 1; + } + table = db_current ? db_current->table : irecv_devices_builtin; + mutex_unlock(&db_mutex); + return table; +} + +/* Re-reads all device files. Tables handed out earlier remain valid. */ +static void reload(void) +{ + struct db_generation* gen; + + mutex_lock(&db_mutex); + gen = build_generation(); + if (gen) { + gen->prev = db_current; + db_current = gen; + } + db_loaded = 1; + mutex_unlock(&db_mutex); +} + +static int token_valid(const char* s) +{ + if (!s || !*s) { + return 0; + } + for (; *s; s++) { + if (isspace((unsigned char)*s) || (unsigned char)*s < 0x20 || *s == 0x7f) { + return 0; + } + } + return 1; +} + +static int name_valid(const char* s) +{ + size_t len; + if (!s || !*s || has_control_chars(s)) { + return 0; + } + len = strlen(s); + return !isspace((unsigned char)s[0]) && !isspace((unsigned char)s[len-1]); +} + +static irecv_error_t add_entry(const char* product_type, const char* hardware_model, unsigned int board_id, unsigned int chip_id, const char* display_name) +{ + struct irecv_device* table; + char* path; + int is_default = 0; + FILE* f; + long size; + int ok; + size_t i; + + /* the whole line, including separators and the IDs, must fit what the loader accepts */ + if (!name_valid(display_name) || + strlen(product_type) + strlen(hardware_model) + strlen(display_name) + 32 > MAX_LINE_LENGTH) { + return IRECV_E_INVALID_INPUT; + } + + table = irecv_devicedb_get(); + for (i = 0; table[i].product_type != NULL; i++) { + if (!strcasecmp(table[i].hardware_model, hardware_model)) { + if (!strcmp(table[i].product_type, product_type) && + table[i].board_id == board_id && table[i].chip_id == chip_id && + !strcmp(table[i].display_name, display_name)) { + return IRECV_E_SUCCESS; + } + break; + } + } + + path = get_user_file(&is_default); + if (!path) { + return IRECV_E_UNKNOWN_ERROR; + } + if (is_default) { + char* dir = get_user_dir(); + if (dir) { +#ifdef _WIN32 + _mkdir(dir); +#else + mkdir(dir, 0700); +#endif + free(dir); + } + } + + f = fopen(path, "a+"); + free(path); + if (!f) { + return IRECV_E_UNKNOWN_ERROR; + } + if (!file_is_trusted(f)) { + fclose(f); + return IRECV_E_UNKNOWN_ERROR; + } + + if (!format_supported(f, "user device file")) { + fclose(f); + return IRECV_E_UNSUPPORTED; + } + + /* a missing final newline must not glue our line onto the previous entry */ + ok = (fseek(f, 0, SEEK_END) == 0); + size = ok ? ftell(f) : -1; + if (size == 0) { + ok = fputs("#!format 1\n" + "# libirecovery user device database\n" + "# \n" + "# Entries override built-in ones with the same hardware_model.\n", f) >= 0; + } else if (size > 0) { + if (fseek(f, -1, SEEK_END) != 0) { + ok = 0; + } else if (fgetc(f) != '\n') { + ok = (fseek(f, 0, SEEK_END) == 0) && fputc('\n', f) != EOF; + } + } else { + ok = 0; + } + if (ok) { + ok = fprintf(f, "%s %s 0x%02x 0x%04x %s\n", product_type, hardware_model, board_id, chip_id, display_name) > 0; + } + if (fclose(f) != 0) { + ok = 0; + } + if (!ok) { + return IRECV_E_UNKNOWN_ERROR; + } + + reload(); + return IRECV_E_SUCCESS; +} + +IRECV_API irecv_error_t irecv_devices_add(const char* product_type, const char* hardware_model, unsigned int board_id, unsigned int chip_id, const char* display_name) +{ + struct irecv_device* table; + const struct irecv_device* existing = NULL; + const char* name = display_name; + char* generated = NULL; + irecv_error_t err; + size_t i; + + if (!token_valid(product_type) || !token_valid(hardware_model)) { + return IRECV_E_INVALID_INPUT; + } + + table = irecv_devicedb_get(); + for (i = 0; table[i].product_type != NULL; i++) { + if (!strcasecmp(table[i].hardware_model, hardware_model)) { + existing = &table[i]; + } else if (table[i].chip_id == chip_id && table[i].board_id == board_id) { + /* the existing entry would shadow the new one in lookups by chip/board ID */ + return IRECV_E_INVALID_INPUT; + } + } + + if (!name || !*name) { + if (existing) { + name = existing->display_name; + } else { + size_t len = strlen(product_type) + strlen(hardware_model) + 4; + generated = malloc(len); + if (!generated) { + return IRECV_E_OUT_OF_MEMORY; + } + snprintf(generated, len, "%s (%s)", product_type, hardware_model); + name = generated; + } + } + + err = add_entry(product_type, hardware_model, board_id, chip_id, name); + free(generated); + return err; +} diff --git a/src/devicedb.h b/src/devicedb.h new file mode 100644 index 0000000..5a96ca7 --- /dev/null +++ b/src/devicedb.h @@ -0,0 +1,36 @@ +/* + * devicedb.h + * Internal device database interface (not installed) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef IRECV_DEVICEDB_H +#define IRECV_DEVICEDB_H + +#include "libirecovery.h" + +/* built-in table generated from data/devices.txt; terminated by a NULL entry */ +extern struct irecv_device irecv_devices_builtin[]; + +void irecv_devicedb_init(void); +void irecv_devicedb_cleanup(void); +void irecv_devicedb_set_debug(int level); + +/* NULL-terminated table (built-in data merged with the device files). + * Never NULL, and the returned table stays valid until library unload. */ +struct irecv_device* irecv_devicedb_get(void); + +#endif diff --git a/src/libirecovery.c b/src/libirecovery.c index 4654eb5..48d6b0b 100644 --- a/src/libirecovery.c +++ b/src/libirecovery.c @@ -71,6 +71,7 @@ #endif #include "libirecovery.h" +#include "devicedb.h" // Reference: https://stackoverflow.com/a/2390626/1806760 // Initializer/finalizer sample for MSVC and GCC/Clang. @@ -172,375 +173,6 @@ static libusb_context* libirecovery_context = NULL; #endif #endif -static struct irecv_device irecv_devices[] = { - /* iPhone */ - { "iPhone1,1", "m68ap", 0x00, 0x8900, "iPhone 2G" }, - { "iPhone1,2", "n82ap", 0x04, 0x8900, "iPhone 3G" }, - { "iPhone2,1", "n88ap", 0x00, 0x8920, "iPhone 3Gs" }, - { "iPhone3,1", "n90ap", 0x00, 0x8930, "iPhone 4 (GSM)" }, - { "iPhone3,2", "n90bap", 0x04, 0x8930, "iPhone 4 (GSM) R2 2012" }, - { "iPhone3,3", "n92ap", 0x06, 0x8930, "iPhone 4 (CDMA)" }, - { "iPhone4,1", "n94ap", 0x08, 0x8940, "iPhone 4s" }, - { "iPhone5,1", "n41ap", 0x00, 0x8950, "iPhone 5 (GSM)" }, - { "iPhone5,2", "n42ap", 0x02, 0x8950, "iPhone 5 (Global)" }, - { "iPhone5,3", "n48ap", 0x0a, 0x8950, "iPhone 5c (GSM)" }, - { "iPhone5,4", "n49ap", 0x0e, 0x8950, "iPhone 5c (Global)" }, - { "iPhone6,1", "n51ap", 0x00, 0x8960, "iPhone 5s (GSM)" }, - { "iPhone6,2", "n53ap", 0x02, 0x8960, "iPhone 5s (Global)" }, - { "iPhone7,1", "n56ap", 0x04, 0x7000, "iPhone 6 Plus" }, - { "iPhone7,2", "n61ap", 0x06, 0x7000, "iPhone 6" }, - { "iPhone8,1", "n71ap", 0x04, 0x8000, "iPhone 6s" }, - { "iPhone8,1", "n71map", 0x04, 0x8003, "iPhone 6s" }, - { "iPhone8,2", "n66ap", 0x06, 0x8000, "iPhone 6s Plus" }, - { "iPhone8,2", "n66map", 0x06, 0x8003, "iPhone 6s Plus" }, - { "iPhone8,4", "n69ap", 0x02, 0x8003, "iPhone SE (1st gen)" }, - { "iPhone8,4", "n69uap", 0x02, 0x8000, "iPhone SE (1st gen)" }, - { "iPhone9,1", "d10ap", 0x08, 0x8010, "iPhone 7 (Global)" }, - { "iPhone9,2", "d11ap", 0x0a, 0x8010, "iPhone 7 Plus (Global)" }, - { "iPhone9,3", "d101ap", 0x0c, 0x8010, "iPhone 7 (GSM)" }, - { "iPhone9,4", "d111ap", 0x0e, 0x8010, "iPhone 7 Plus (GSM)" }, - { "iPhone10,1", "d20ap", 0x02, 0x8015, "iPhone 8 (Global)" }, - { "iPhone10,2", "d21ap", 0x04, 0x8015, "iPhone 8 Plus (Global)" }, - { "iPhone10,3", "d22ap", 0x06, 0x8015, "iPhone X (Global)" }, - { "iPhone10,4", "d201ap", 0x0a, 0x8015, "iPhone 8 (GSM)" }, - { "iPhone10,5", "d211ap", 0x0c, 0x8015, "iPhone 8 Plus (GSM)" }, - { "iPhone10,6", "d221ap", 0x0e, 0x8015, "iPhone X (GSM)" }, - { "iPhone11,2", "d321ap", 0x0e, 0x8020, "iPhone XS" }, - { "iPhone11,4", "d331ap", 0x0a, 0x8020, "iPhone XS Max (China)" }, - { "iPhone11,6", "d331pap", 0x1a, 0x8020, "iPhone XS Max" }, - { "iPhone11,8", "n841ap", 0x0c, 0x8020, "iPhone XR" }, - { "iPhone12,1", "n104ap", 0x04, 0x8030, "iPhone 11" }, - { "iPhone12,3", "d421ap", 0x06, 0x8030, "iPhone 11 Pro" }, - { "iPhone12,5", "d431ap", 0x02, 0x8030, "iPhone 11 Pro Max" }, - { "iPhone12,8", "d79ap", 0x10, 0x8030, "iPhone SE (2nd gen)" }, - { "iPhone13,1", "d52gap", 0x0A, 0x8101, "iPhone 12 mini" }, - { "iPhone13,2", "d53gap", 0x0C, 0x8101, "iPhone 12" }, - { "iPhone13,3", "d53pap", 0x0E, 0x8101, "iPhone 12 Pro" }, - { "iPhone13,4", "d54pap", 0x08, 0x8101, "iPhone 12 Pro Max" }, - { "iPhone14,2", "d63ap", 0x0C, 0x8110, "iPhone 13 Pro" }, - { "iPhone14,3", "d64ap", 0x0E, 0x8110, "iPhone 13 Pro Max" }, - { "iPhone14,4", "d16ap", 0x08, 0x8110, "iPhone 13 mini" }, - { "iPhone14,5", "d17ap", 0x0A, 0x8110, "iPhone 13" }, - { "iPhone14,6", "d49ap", 0x10, 0x8110, "iPhone SE (3rd gen)" }, - { "iPhone14,7", "d27ap", 0x18, 0x8110, "iPhone 14" }, - { "iPhone14,8", "d28ap", 0x1A, 0x8110, "iPhone 14 Plus" }, - { "iPhone15,2", "d73ap", 0x0C, 0x8120, "iPhone 14 Pro" }, - { "iPhone15,3", "d74ap", 0x0E, 0x8120, "iPhone 14 Pro Max" }, - { "iPhone15,4", "d37ap", 0x08, 0x8120, "iPhone 15" }, - { "iPhone15,5", "d38ap", 0x0A, 0x8120, "iPhone 15 Plus" }, - { "iPhone16,1", "d83ap", 0x04, 0x8130, "iPhone 15 Pro" }, - { "iPhone16,2", "d84ap", 0x06, 0x8130, "iPhone 15 Pro Max" }, - { "iPhone17,1", "d93ap", 0x0C, 0x8140, "iPhone 16 Pro" }, - { "iPhone17,2", "d94ap", 0x0E, 0x8140, "iPhone 16 Pro Max" }, - { "iPhone17,3", "d47ap", 0x08, 0x8140, "iPhone 16" }, - { "iPhone17,4", "d48ap", 0x0A, 0x8140, "iPhone 16 Plus" }, - { "iPhone17,5", "v59ap", 0x04, 0x8140, "iPhone 16e" }, - { "iPhone18,1", "v53ap", 0x0C, 0x8150, "iPhone 17 Pro" }, - { "iPhone18,2", "v54ap", 0x0E, 0x8150, "iPhone 17 Pro Max" }, - { "iPhone18,3", "v57ap", 0x08, 0x8150, "iPhone 17" }, - { "iPhone18,4", "d23ap", 0x0A, 0x8150, "iPhone Air" }, - { "iPhone18,5", "v159ap", 0x16, 0x8150, "iPhone 17e" }, - { "iPhone19,2", "v63ap", 0x0A, 0x8160, "iPhone 18 Pro" }, - { "iPhone19,3", "v64ap", 0x0C, 0x8160, "iPhone 18 Pro Max (US)" }, - { "iPhone19,7", "v64sap", 0x12, 0x8160, "iPhone 18 Pro Max (Global)" }, - { "iPhone19,4", "v68ap", 0x0E, 0x8160, "iPhone Duo" }, - /* iPod */ - { "iPod1,1", "n45ap", 0x02, 0x8900, "iPod Touch (1st gen)" }, - { "iPod2,1", "n72ap", 0x00, 0x8720, "iPod Touch (2nd gen)" }, - { "iPod3,1", "n18ap", 0x02, 0x8922, "iPod Touch (3rd gen)" }, - { "iPod4,1", "n81ap", 0x08, 0x8930, "iPod Touch (4th gen)" }, - { "iPod5,1", "n78ap", 0x00, 0x8942, "iPod Touch (5th gen)" }, - { "iPod7,1", "n102ap", 0x10, 0x7000, "iPod Touch (6th gen)" }, - { "iPod9,1", "n112ap", 0x16, 0x8010, "iPod Touch (7th gen)" }, - /* iPad */ - { "iPad1,1", "k48ap", 0x02, 0x8930, "iPad" }, - { "iPad2,1", "k93ap", 0x04, 0x8940, "iPad 2 (WiFi)" }, - { "iPad2,2", "k94ap", 0x06, 0x8940, "iPad 2 (GSM)" }, - { "iPad2,3", "k95ap", 0x02, 0x8940, "iPad 2 (CDMA)" }, - { "iPad2,4", "k93aap", 0x06, 0x8942, "iPad 2 (WiFi) R2 2012" }, - { "iPad2,5", "p105ap", 0x0a, 0x8942, "iPad mini (WiFi)" }, - { "iPad2,6", "p106ap", 0x0c, 0x8942, "iPad mini (GSM)" }, - { "iPad2,7", "p107ap", 0x0e, 0x8942, "iPad mini (Global)" }, - { "iPad3,1", "j1ap", 0x00, 0x8945, "iPad (3rd gen, WiFi)" }, - { "iPad3,2", "j2ap", 0x02, 0x8945, "iPad (3rd gen, CDMA)" }, - { "iPad3,3", "j2aap", 0x04, 0x8945, "iPad (3rd gen, GSM)" }, - { "iPad3,4", "p101ap", 0x00, 0x8955, "iPad (4th gen, WiFi)" }, - { "iPad3,5", "p102ap", 0x02, 0x8955, "iPad (4th gen, GSM)" }, - { "iPad3,6", "p103ap", 0x04, 0x8955, "iPad (4th gen, Global)" }, - { "iPad4,1", "j71ap", 0x10, 0x8960, "iPad Air (WiFi)" }, - { "iPad4,2", "j72ap", 0x12, 0x8960, "iPad Air (Cellular)" }, - { "iPad4,3", "j73ap", 0x14, 0x8960, "iPad Air (China)" }, - { "iPad4,4", "j85ap", 0x0a, 0x8960, "iPad mini 2 (WiFi)" }, - { "iPad4,5", "j86ap", 0x0c, 0x8960, "iPad mini 2 (Cellular)" }, - { "iPad4,6", "j87ap", 0x0e, 0x8960, "iPad mini 2 (China)" }, - { "iPad4,7", "j85map", 0x32, 0x8960, "iPad mini 3 (WiFi)" }, - { "iPad4,8", "j86map", 0x34, 0x8960, "iPad mini 3 (Cellular)" }, - { "iPad4,9", "j87map", 0x36, 0x8960, "iPad mini 3 (China)" }, - { "iPad5,1", "j96ap", 0x08, 0x7000, "iPad mini 4 (WiFi)" }, - { "iPad5,2", "j97ap", 0x0A, 0x7000, "iPad mini 4 (Cellular)" }, - { "iPad5,3", "j81ap", 0x06, 0x7001, "iPad Air 2 (WiFi)" }, - { "iPad5,4", "j82ap", 0x02, 0x7001, "iPad Air 2 (Cellular)" }, - { "iPad6,3", "j127ap", 0x08, 0x8001, "iPad Pro 9.7-inch (WiFi)" }, - { "iPad6,4", "j128ap", 0x0a, 0x8001, "iPad Pro 9.7-inch (Cellular)" }, - { "iPad6,7", "j98aap", 0x10, 0x8001, "iPad Pro 12.9-inch (1st gen, WiFi)" }, - { "iPad6,8", "j99aap", 0x12, 0x8001, "iPad Pro 12.9-inch (1st gen, Cellular)" }, - { "iPad6,11", "j71sap", 0x10, 0x8000, "iPad (5th gen, WiFi)" }, - { "iPad6,11", "j71tap", 0x10, 0x8003, "iPad (5th gen, WiFi)" }, - { "iPad6,12", "j72sap", 0x12, 0x8000, "iPad (5th gen, Cellular)" }, - { "iPad6,12", "j72tap", 0x12, 0x8003, "iPad (5th gen, Cellular)" }, - { "iPad7,1", "j120ap", 0x0C, 0x8011, "iPad Pro 12.9-inch (2nd gen, WiFi)" }, - { "iPad7,2", "j121ap", 0x0E, 0x8011, "iPad Pro 12.9-inch (2nd gen, Cellular)" }, - { "iPad7,3", "j207ap", 0x04, 0x8011, "iPad Pro 10.5-inch (WiFi)" }, - { "iPad7,4", "j208ap", 0x06, 0x8011, "iPad Pro 10.5-inch (Cellular)" }, - { "iPad7,5", "j71bap", 0x18, 0x8010, "iPad (6th gen, WiFi)" }, - { "iPad7,6", "j72bap", 0x1A, 0x8010, "iPad (6th gen, Cellular)" }, - { "iPad7,11", "j171ap", 0x1C, 0x8010, "iPad (7th gen, WiFi)" }, - { "iPad7,12", "j172ap", 0x1E, 0x8010, "iPad (7th gen, Cellular)" }, - { "iPad8,1", "j317ap", 0x0C, 0x8027, "iPad Pro 11-inch (1st gen, WiFi)" }, - { "iPad8,2", "j317xap", 0x1C, 0x8027, "iPad Pro 11-inch (1st gen, WiFi, 1TB)" }, - { "iPad8,3", "j318ap", 0x0E, 0x8027, "iPad Pro 11-inch (1st gen, Cellular)" }, - { "iPad8,4", "j318xap", 0x1E, 0x8027, "iPad Pro 11-inch (1st gen, Cellular, 1TB)" }, - { "iPad8,5", "j320ap", 0x08, 0x8027, "iPad Pro 12.9-inch (3rd gen, WiFi)" }, - { "iPad8,6", "j320xap", 0x18, 0x8027, "iPad Pro 12.9-inch (3rd gen, WiFi, 1TB)" }, - { "iPad8,7", "j321ap", 0x0A, 0x8027, "iPad Pro 12.9-inch (3rd gen, Cellular)" }, - { "iPad8,8", "j321xap", 0x1A, 0x8027, "iPad Pro 12.9-inch (3rd gen, Cellular, 1TB)" }, - { "iPad8,9", "j417ap", 0x3C, 0x8027, "iPad Pro 11-inch (2nd gen, WiFi)" }, - { "iPad8,10", "j418ap", 0x3E, 0x8027, "iPad Pro 11-inch (2nd gen, Cellular)" }, - { "iPad8,11", "j420ap", 0x38, 0x8027, "iPad Pro 12.9-inch (4th gen, WiFi)" }, - { "iPad8,12", "j421ap", 0x3A, 0x8027, "iPad Pro 12.9-inch (4th gen, Cellular)" }, - { "iPad11,1", "j210ap", 0x14, 0x8020, "iPad mini (5th gen, WiFi)" }, - { "iPad11,2", "j211ap", 0x16, 0x8020, "iPad mini (5th gen, Cellular)" }, - { "iPad11,3", "j217ap", 0x1C, 0x8020, "iPad Air (3rd gen, WiFi)" }, - { "iPad11,4", "j218ap", 0x1E, 0x8020, "iPad Air (3rd gen, Cellular)" }, - { "iPad11,6", "j171aap", 0x24, 0x8020, "iPad (8th gen, WiFi)" }, - { "iPad11,7", "j172aap", 0x26, 0x8020, "iPad (8th gen, Cellular)" }, - { "iPad12,1", "j181ap", 0x18, 0x8030, "iPad (9th gen, WiFi)" }, - { "iPad12,2", "j182ap", 0x1A, 0x8030, "iPad (9th gen, Cellular)" }, - { "iPad13,1", "j307ap", 0x04, 0x8101, "iPad Air (4th gen, WiFi)" }, - { "iPad13,2", "j308ap", 0x06, 0x8101, "iPad Air (4th gen, Cellular)" }, - { "iPad13,4", "j517ap", 0x08, 0x8103, "iPad Pro 11-inch (3rd gen, WiFi)" }, - { "iPad13,5", "j517xap", 0x0A, 0x8103, "iPad Pro 11-inch (3rd gen, WiFi, 2TB)" }, - { "iPad13,6", "j518ap", 0x0C, 0x8103, "iPad Pro 11-inch (3rd gen, Cellular)" }, - { "iPad13,7", "j518xap", 0x0E, 0x8103, "iPad Pro 11-inch (3rd gen, Cellular, 2TB)" }, - { "iPad13,8", "j522ap", 0x18, 0x8103, "iPad Pro 12.9-inch (5th gen, WiFi)" }, - { "iPad13,9", "j522xap", 0x1A, 0x8103, "iPad Pro 12.9-inch (5th gen, WiFi, 2TB)" }, - { "iPad13,10", "j523ap", 0x1C, 0x8103, "iPad Pro 12.9-inch (5th gen, Cellular)" }, - { "iPad13,11", "j523xap", 0x1E, 0x8103, "iPad Pro 12.9-inch (5th gen, Cellular, 2TB)" }, - { "iPad13,16", "j407ap", 0x10, 0x8103, "iPad Air (5th gen, WiFi)" }, - { "iPad13,17", "j408ap", 0x12, 0x8103, "iPad Air (5th gen, Cellular)" }, - { "iPad13,18", "j271ap", 0x14, 0x8101, "iPad (10th gen, WiFi)" }, - { "iPad13,19", "j272ap", 0x16, 0x8101, "iPad (10th gen, Cellular)" }, - { "iPad14,1", "j310ap", 0x04, 0x8110, "iPad mini (6th gen, WiFi)" }, - { "iPad14,2", "j311ap", 0x06, 0x8110, "iPad mini (6th gen, Cellular)" }, - { "iPad14,3", "j617ap", 0x08, 0x8112, "iPad Pro 11-inch (4th gen, WiFi)" }, - { "iPad14,4", "j618ap", 0x0A, 0x8112, "iPad Pro 11-inch (4th gen, Cellular)" }, - { "iPad14,5", "j620ap", 0x0C, 0x8112, "iPad Pro 12.9-inch (6th gen, WiFi)" }, - { "iPad14,6", "j621ap", 0x0E, 0x8112, "iPad Pro 12.9-inch (6th gen, Cellular)" }, - { "iPad14,8", "j507ap", 0x10, 0x8112, "iPad Air 11-inch (M2, WiFi)" }, - { "iPad14,9", "j508ap", 0x12, 0x8112, "iPad Air 11-inch (M2, Cellular)" }, - { "iPad14,10", "j537ap", 0x14, 0x8112, "iPad Air 13-inch (M2, WiFi)" }, - { "iPad14,11", "j538ap", 0x16, 0x8112, "iPad Air 13-inch (M2, Cellular)" }, - { "iPad15,3", "j607ap", 0x08, 0x8122, "iPad Air 11-inch (M3, WiFi)" }, - { "iPad15,4", "j608ap", 0x0A, 0x8122, "iPad Air 11-inch (M3, Cellular)" }, - { "iPad15,5", "j637ap", 0x0C, 0x8122, "iPad Air 13-inch (M3, WiFi)" }, - { "iPad15,6", "j638ap", 0x0E, 0x8122, "iPad Air 13-inch (M3, Cellular)" }, - { "iPad15,7", "j481ap", 0x10, 0x8120, "iPad (A16, WiFi)" }, - { "iPad15,8", "j482ap", 0x12, 0x8120, "iPad (A16, Cellular)" }, - { "iPad16,1", "j410ap", 0x08, 0x8130, "iPad mini (A17 Pro, WiFi)" }, - { "iPad16,2", "j411ap", 0x0A, 0x8130, "iPad mini (A17 Pro, Cellular)" }, - { "iPad16,3", "j717ap", 0x08, 0x8132, "iPad Pro 11-inch (M4, WiFi)" }, - { "iPad16,4", "j718ap", 0x0A, 0x8132, "iPad Pro 11-inch (M4, Cellular)" }, - { "iPad16,5", "j720ap", 0x0C, 0x8132, "iPad Pro 13-inch (M4, WiFi)" }, - { "iPad16,6", "j721ap", 0x0E, 0x8132, "iPad Pro 13-inch (M4, Cellular)" }, - { "iPad16,8", "j707ap", 0x10, 0x8132, "iPad Air 11-inch (M4, WiFi)" }, - { "iPad16,9", "j708ap", 0x12, 0x8132, "iPad Air 11-inch (M4, Cellular)" }, - { "iPad16,10", "j737ap", 0x14, 0x8132, "iPad Air 13-inch (M4, WiFi)" }, - { "iPad16,11", "j738ap", 0x16, 0x8132, "iPad Air 13-inch (M4, Cellular)" }, - { "iPad17,1", "j817ap", 0x08, 0x8142, "iPad Pro 11-inch (M5, WiFi)" }, - { "iPad17,2", "j818ap", 0x0A, 0x8142, "iPad Pro 11-inch (M5, Cellular)" }, - { "iPad17,3", "j820ap", 0x0C, 0x8142, "iPad Pro 13-inch (M5, WiFi)" }, - { "iPad17,4", "j821ap", 0x0E, 0x8142, "iPad Pro 13-inch (M5, Cellular)" }, - { "iPad19,1", "j510ap", 0x04, 0x8160, "iPad mini (A20 Pro, WiFi)" }, - { "iPad19,2", "j511ap", 0x06, 0x8160, "iPad mini (A20 Pro, Cellular)" }, - /* Apple TV */ - { "AppleTV2,1", "k66ap", 0x10, 0x8930, "Apple TV 2" }, - { "AppleTV3,1", "j33ap", 0x08, 0x8942, "Apple TV 3" }, - { "AppleTV3,2", "j33iap", 0x00, 0x8947, "Apple TV 3 (2013)" }, - { "AppleTV5,3", "j42dap", 0x34, 0x7000, "Apple TV 4" }, - { "AppleTV6,2", "j105aap", 0x02, 0x8011, "Apple TV 4K" }, - { "AppleTV11,1", "j305ap", 0x08, 0x8020, "Apple TV 4K (2nd gen)" }, - { "AppleTV14,1", "j255ap", 0x02, 0x8110, "Apple TV 4K (3rd gen)" }, - /* HomePod */ - { "AudioAccessory1,1", "b238aap", 0x38, 0x7000, "HomePod (1st gen)" }, - { "AudioAccessory1,2", "b238ap", 0x1A, 0x7000, "HomePod (1st gen)" }, - { "AudioAccessory5,1", "b520ap", 0x22, 0x8006, "HomePod mini" }, - { "AudioAccessory6,1", "b620ap", 0x18, 0x8301, "HomePod (2nd gen)" }, - /* Apple Watch */ - { "Watch1,1", "n27aap", 0x02, 0x7002, "Apple Watch 38mm (1st gen)" }, - { "Watch1,2", "n28aap", 0x04, 0x7002, "Apple Watch 42mm (1st gen)" }, - { "Watch2,6", "n27dap", 0x02, 0x8002, "Apple Watch Series 1 (38mm)" }, - { "Watch2,7", "n28dap", 0x04, 0x8002, "Apple Watch Series 1 (42mm)" }, - { "Watch2,3", "n74ap", 0x0C, 0x8002, "Apple Watch Series 2 (38mm)" }, - { "Watch2,4", "n75ap", 0x0E, 0x8002, "Apple Watch Series 2 (42mm)" }, - { "Watch3,1", "n111sap", 0x1C, 0x8004, "Apple Watch Series 3 (38mm Cellular)" }, - { "Watch3,2", "n111bap", 0x1E, 0x8004, "Apple Watch Series 3 (42mm Cellular)" }, - { "Watch3,3", "n121sap", 0x18, 0x8004, "Apple Watch Series 3 (38mm)" }, - { "Watch3,4", "n121bap", 0x1A, 0x8004, "Apple Watch Series 3 (42mm)" }, - { "Watch4,1", "n131sap", 0x08, 0x8006, "Apple Watch Series 4 (40mm)" }, - { "Watch4,2", "n131bap", 0x0A, 0x8006, "Apple Watch Series 4 (44mm)" }, - { "Watch4,3", "n141sap", 0x0C, 0x8006, "Apple Watch Series 4 (40mm Cellular)" }, - { "Watch4,4", "n141bap", 0x0E, 0x8006, "Apple Watch Series 4 (44mm Cellular)" }, - { "Watch5,1", "n144sap", 0x10, 0x8006, "Apple Watch Series 5 (40mm)" }, - { "Watch5,2", "n144bap", 0x12, 0x8006, "Apple Watch Series 5 (44mm)" }, - { "Watch5,3", "n146sap", 0x14, 0x8006, "Apple Watch Series 5 (40mm Cellular)" }, - { "Watch5,4", "n146bap", 0x16, 0x8006, "Apple Watch Series 5 (44mm Cellular)" }, - { "Watch5,9", "n140sap", 0x28, 0x8006, "Apple Watch SE (40mm)" }, - { "Watch5,10", "n140bap", 0x2A, 0x8006, "Apple Watch SE (44mm)" }, - { "Watch5,11", "n142sap", 0x2C, 0x8006, "Apple Watch SE (40mm Cellular)" }, - { "Watch5,12", "n142bap", 0x2E, 0x8006, "Apple Watch SE (44mm Cellular)" }, - { "Watch6,1", "n157sap", 0x08, 0x8301, "Apple Watch Series 6 (40mm)" }, - { "Watch6,2", "n157bap", 0x0A, 0x8301, "Apple Watch Series 6 (44mm)" }, - { "Watch6,3", "n158sap", 0x0C, 0x8301, "Apple Watch Series 6 (40mm Cellular)" }, - { "Watch6,4", "n158bap", 0x0E, 0x8301, "Apple Watch Series 6 (44mm Cellular)" }, - { "Watch6,6", "n187sap", 0x10, 0x8301, "Apple Watch Series 7 (41mm)" }, - { "Watch6,7", "n187bap", 0x12, 0x8301, "Apple Watch Series 7 (45mm)" }, - { "Watch6,8", "n188sap", 0x14, 0x8301, "Apple Watch Series 7 (41mm Cellular)" }, - { "Watch6,9", "n188bap", 0x16, 0x8301, "Apple Watch Series 7 (45mm Cellular)" }, - { "Watch6,10", "n143sap", 0x28, 0x8301, "Apple Watch SE 2 (40mm)" }, - { "Watch6,11", "n143bap", 0x2A, 0x8301, "Apple Watch SE 2 (44mm)" }, - { "Watch6,12", "n149sap", 0x2C, 0x8301, "Apple Watch SE 2 (40mm Cellular)" }, - { "Watch6,13", "n149bap", 0x2E, 0x8301, "Apple Watch SE 2 (44mm Cellular)" }, - { "Watch6,14", "n197sap", 0x30, 0x8301, "Apple Watch Series 8 (41mm)" }, - { "Watch6,15", "n197bap", 0x32, 0x8301, "Apple Watch Series 8 (45mm)" }, - { "Watch6,16", "n198sap", 0x34, 0x8301, "Apple Watch Series 8 (41mm Cellular)" }, - { "Watch6,17", "n198bap", 0x36, 0x8301, "Apple Watch Series 8 (45mm Cellular)" }, - { "Watch6,18", "n199ap", 0x26, 0x8301, "Apple Watch Ultra" }, - { "Watch7,1", "n207sap", 0x08, 0x8310, "Apple Watch Series 9 (41mm)" }, - { "Watch7,2", "n207bap", 0x0A, 0x8310, "Apple Watch Series 9 (45mm)" }, - { "Watch7,3", "n208sap", 0x0C, 0x8310, "Apple Watch Series 9 (41mm Cellular)" }, - { "Watch7,4", "n208bap", 0x0E, 0x8310, "Apple Watch Series 9 (45mm Cellular)" }, - { "Watch7,5", "n210ap", 0x02, 0x8310, "Apple Watch Ultra 2" }, - { "Watch7,8", "n217sap", 0x10, 0x8310, "Apple Watch Series 10 (42mm)" }, - { "Watch7,9", "n217bap", 0x12, 0x8310, "Apple Watch Series 10 (46mm)" }, - { "Watch7,10", "n218sap", 0x14, 0x8310, "Apple Watch Series 10 (42mm Cellular)" }, - { "Watch7,11", "n218bap", 0x16, 0x8310, "Apple Watch Series 10 (46mm Cellular)" }, - { "Watch7,12", "n230ap", 0x22, 0x8310, "Apple Watch Ultra 3" }, - { "Watch7,13", "n243sap", 0x28, 0x8310, "Apple Watch SE 3 (40mm)" }, - { "Watch7,14", "n243bap", 0x2A, 0x8310, "Apple Watch SE 3 (44mm)" }, - { "Watch7,15", "n244sap", 0x2C, 0x8310, "Apple Watch SE 3 (40mm Cellular)" }, - { "Watch7,16", "n244bap", 0x2E, 0x8310, "Apple Watch SE 3 (44mm Cellular)" }, - { "Watch7,17", "n227sap", 0x18, 0x8310, "Apple Watch Series 11 (42mm)" }, - { "Watch7,18", "n227bap", 0x1A, 0x8310, "Apple Watch Series 11 (46mm)" }, - { "Watch7,19", "n228sap", 0x1C, 0x8310, "Apple Watch Series 11 (42mm Cellular)" }, - { "Watch7,20", "n228bap", 0x1E, 0x8310, "Apple Watch Series 11 (46mm Cellular)" }, - { "Watch8,1", "n240ap", 0x02, 0x8320, "Apple Watch Ultra 4" }, - { "Watch8,2", "n237sap", 0x08, 0x8320, "Apple Watch Series 12 (42mm)" }, - { "Watch8,3", "n237bap", 0x0A, 0x8320, "Apple Watch Series 12 (46mm)" }, - { "Watch8,4", "n238sap", 0x0C, 0x8320, "Apple Watch Series 12 (42mm Cellular)" }, - { "Watch8,5", "n238bap", 0x0E, 0x8320, "Apple Watch Series 12 (46mm Cellular)" }, - /* Apple Silicon Macs */ - { "ADP3,2", "j273aap", 0x42, 0x8027, "Developer Transition Kit (2020)" }, - { "Macmini9,1", "j274ap", 0x22, 0x8103, "Mac mini (M1, 2020)" }, - { "MacBookPro17,1", "j293ap", 0x24, 0x8103, "MacBook Pro (M1, 13-inch, 2020)" }, - { "MacBookPro18,1", "j316sap", 0x0A, 0x6000, "MacBook Pro (M1 Pro, 16-inch, 2021)" }, - { "MacBookPro18,2", "j316cap", 0x0A, 0x6001, "MacBook Pro (M1 Max, 16-inch, 2021)" }, - { "MacBookPro18,3", "j314sap", 0x08, 0x6000, "MacBook Pro (M1 Pro, 14-inch, 2021)" }, - { "MacBookPro18,4", "j314cap", 0x08, 0x6001, "MacBook Pro (M1 Max, 14-inch, 2021)" }, - { "MacBookAir10,1", "j313ap", 0x26, 0x8103, "MacBook Air (M1, 2020)" }, - { "iMac21,1", "j456ap", 0x28, 0x8103, "iMac 24-inch (M1, Two Ports, 2021)" }, - { "iMac21,2", "j457ap", 0x2A, 0x8103, "iMac 24-inch (M1, Four Ports, 2021)" }, - { "Mac13,1", "j375cap", 0x04, 0x6001, "Mac Studio (M1 Max, 2022)" }, - { "Mac13,2", "j375dap", 0x0C, 0x6002, "Mac Studio (M1 Ultra, 2022)" }, - { "Mac14,2", "j413ap", 0x28, 0x8112, "MacBook Air (M2, 2022)" }, - { "Mac14,7", "j493ap", 0x2A, 0x8112, "MacBook Pro (M2, 13-inch, 2022)" }, - { "Mac14,3", "j473ap", 0x24, 0x8112, "Mac mini (M2, 2023)" }, - { "Mac14,5", "j414cap", 0x04, 0x6021, "MacBook Pro (14-inch, M2 Max, 2023)" }, - { "Mac14,6", "j416cap", 0x06, 0x6021, "MacBook Pro (16-inch, M2 Max, 2023)" }, - { "Mac14,8", "j180dap", 0x08, 0x6022, "Mac Pro (2023)" }, - { "Mac14,9", "j414sap", 0x04, 0x6020, "MacBook Pro (14-inch, M2 Pro, 2023)" }, - { "Mac14,10", "j416sap", 0x06, 0x6020, "MacBook Pro (16-inch, M2 Pro, 2023)" }, - { "Mac14,12", "j474sap", 0x02, 0x6020, "Mac mini (M2 Pro, 2023)" }, - { "Mac14,13", "j475cap", 0x0A, 0x6021, "Mac Studio (M2 Max, 2023)" }, - { "Mac14,14", "j475dap", 0x0A, 0x6022, "Mac Studio (M2 Ultra, 2023)" }, - { "Mac14,15", "j415ap", 0x2E, 0x8112, "MacBook Air (M2, 15-inch, 2023)" }, - { "Mac15,3", "j504ap", 0x22, 0x8122, "MacBook Pro (14-inch, M3, Nov 2023)" }, - { "Mac15,4", "j433ap", 0x28, 0x8122, "iMac 24-inch (M3, Two Ports, 2023)" }, - { "Mac15,5", "j434ap", 0x2A, 0x8122, "iMac 24-inch (M3, Four Ports, 2023)" }, - { "Mac15,6", "j514sap", 0x04, 0x6030, "MacBook Pro (14-inch, M3 Pro, Nov 2023)" }, - { "Mac15,7", "j516sap", 0x06, 0x6030, "MacBook Pro (16-inch, M3 Pro, Nov 2023)" }, - { "Mac15,8", "j514cap", 0x44, 0x6031, "MacBook Pro (14-inch, M3 Max, Nov 2023)" }, - { "Mac15,9", "j516cap", 0x46, 0x6031, "MacBook Pro (16-inch, M3 Max, Nov 2023)" }, - { "Mac15,10", "j514map", 0x44, 0x6034, "MacBook Pro (14-inch, M3 Max, Nov 2023)" }, - { "Mac15,11", "j516map", 0x46, 0x6034, "MacBook Pro (16-inch, M3 Max, Nov 2023)" }, - { "Mac15,12", "j613ap", 0x30, 0x8122, "MacBook Air (13-inch, M3, 2024)" }, - { "Mac15,13", "j615ap", 0x32, 0x8122, "MacBook Air (15-inch, M3, 2024)" }, - { "Mac15,14", "j575dap", 0x44, 0x6032, "Mac Studio (M3 Ultra, 2025)" }, - { "Mac16,1", "j604ap", 0x22, 0x8132, "MacBook Pro (14-inch, M4, Nov 2024)" }, - { "Mac16,2", "j623ap", 0x24, 0x8132, "iMac 24-inch (M4, Two Ports, 2024)" }, - { "Mac16,3", "j624ap", 0x26, 0x8132, "iMac 24-inch (M4, Four Ports, 2024)" }, - { "Mac16,5", "j616cap", 0x06, 0x6041, "MacBook Pro (16-inch, M4 Max, Nov 2024)" }, - { "Mac16,6", "j614cap", 0x04, 0x6041, "MacBook Pro (14-inch, M4 Max, Nov 2024)" }, - { "Mac16,7", "j616sap", 0x06, 0x6040, "MacBook Pro (16-inch, M4 Pro, Nov 2024)" }, - { "Mac16,8", "j614sap", 0x04, 0x6040, "MacBook Pro (14-inch, M4 Pro, Nov 2024)" }, - { "Mac16,9", "j575cap", 0x02, 0x6041, "Mac Studio (M4 Max, 2025)" }, - { "Mac16,10", "j773gap", 0x2A, 0x8132, "Mac mini (M4, 2024)" }, - { "Mac16,11", "j773sap", 0x02, 0x6040, "Mac mini (M4 Pro, 2024)" }, - { "Mac16,12", "j713ap", 0x2C, 0x8132, "MacBook Air (13-inch, M4, 2025)" }, - { "Mac16,13", "j715ap", 0x2E, 0x8132, "MacBook Air (15-inch, M4, 2025)" }, - { "Mac17,2", "j704ap", 0x22, 0x8142, "MacBook Pro (14-inch, M5, 2025)" }, - { "Mac17,3", "j813ap", 0x24, 0x8142, "MacBook Air (13-inch, M5, 2026)" }, - { "Mac17,4", "j815ap", 0x26, 0x8142, "MacBook Air (15-inch, M5, 2026)" }, - { "Mac17,5", "j700ap", 0x64, 0x8140, "MacBook Neo" }, - { "Mac17,6", "j716cap", 0x0E, 0x6050, "MacBook Pro (16-inch, M5 Max, 2026)" }, - { "Mac17,7", "j714cap", 0x0A, 0x6050, "MacBook Pro (14-inch, M5 Max, 2026)" }, - { "Mac17,8", "j716sap", 0x0C, 0x6050, "MacBook Pro (16-inch, M5 Pro, 2026)" }, - { "Mac17,9", "j714sap", 0x08, 0x6050, "MacBook Pro (14-inch, M5 Pro, 2026)" }, - { "Mac17,10", "k116cap", 0x06, 0x6050, "MacBook Pro (16-inch PROLED, M5 Max, 2026)" }, - { "Mac17,11", "k114cap", 0x04, 0x6050, "MacBook Pro (14-inch PROLED, M5 Max, 2026)" }, - { "Mac17,12", "k116sap", 0x16, 0x6050, "MacBook Pro (16-inch PROLED, M5 Pro, 2026)" }, - { "Mac17,13", "k114sap", 0x14, 0x6050, "MacBook Pro (14-inch PROLED, M5 Pro, 2026)" }, - { "Mac17,14", "j775cap", 0x10, 0x6050, "Mac Studio (M5 Max, 2026)" }, - { "Mac17,15", "j775dap", 0x12, 0x6050, "Mac Studio (M5 Ultra, 2026)" }, - { "Mac17,16", "j873sap", 0x02, 0x6050, "Mac mini (M5 Pro, 2026)" }, - { "Mac18,1", "j804ap", 0x22, 0x8152, "MacBook Pro (14-inch, M6, 2026)" }, - { "Mac18,2", "j833ctap",0x26, 0x8152, "iMac (24-inch, M6, 2026)" }, - { "Mac18,5", "j873gap", 0x24, 0x8152, "Mac mini (M6, 2026)" }, - /* Apple Silicon VMs (supported by Virtualization.framework on macOS 12) */ - { "VirtualMac2,1", "vma2macosap", 0x20, 0xFE00, "Apple Virtual Machine 1" }, - /* Apple T1 Coprocessor (iBridge1,1) - all four Touch Bar Macs share one identity */ - { "iBridge1,1", "x619ap", 0x12, 0x8002, "Apple T1 iBridge (x619)" }, - /* Apple T2 Coprocessor */ - { "iBridge2,1", "j137ap", 0x0A, 0x8012, "Apple T2 iMacPro1,1 (j137)" }, - { "iBridge2,3", "j680ap", 0x0B, 0x8012, "Apple T2 MacBookPro15,1 (j680)" }, - { "iBridge2,4", "j132ap", 0x0C, 0x8012, "Apple T2 MacBookPro15,2 (j132)" }, - { "iBridge2,5", "j174ap", 0x0E, 0x8012, "Apple T2 Macmini8,1 (j174)" }, - { "iBridge2,6", "j160ap", 0x0F, 0x8012, "Apple T2 MacPro7,1 (j160)" }, - { "iBridge2,7", "j780ap", 0x07, 0x8012, "Apple T2 MacBookPro15,3 (j780)" }, - { "iBridge2,8", "j140kap", 0x17, 0x8012, "Apple T2 MacBookAir8,1 (j140k)" }, - { "iBridge2,10", "j213ap", 0x18, 0x8012, "Apple T2 MacBookPro15,4 (j213)" }, - { "iBridge2,12", "j140aap", 0x37, 0x8012, "Apple T2 MacBookAir8,2 (j140a)" }, - { "iBridge2,14", "j152fap", 0x3A, 0x8012, "Apple T2 MacBookPro16,1 (j152f)" }, - { "iBridge2,15", "j230kap", 0x3F, 0x8012, "Apple T2 MacBookAir9,1 (j230k)" }, - { "iBridge2,16", "j214kap", 0x3E, 0x8012, "Apple T2 MacBookPro16,2 (j214k)" }, - { "iBridge2,19", "j185ap", 0x22, 0x8012, "Apple T2 iMac20,1 (j185)" }, - { "iBridge2,20", "j185fap", 0x23, 0x8012, "Apple T2 iMac20,2 (j185f)" }, - { "iBridge2,21", "j223ap", 0x3B, 0x8012, "Apple T2 MacBookPro16,3 (j223)" }, - { "iBridge2,22", "j215ap", 0x38, 0x8012, "Apple T2 MacBookPro16,4 (j215)" }, - /* Lightning Video Adapters */ - { "iAccy1,1", "b137ap", 0x00, 0x8747, "Lightning Digital AV Adapter" }, - { "iAccy1,2", "b165ap", 0x02, 0x8747, "Lightning to VGA Adapter" }, - /* Apple Displays */ - { "AppleDisplay2,1", "j327ap", 0x22, 0x8030, "Studio Display" }, - { "AppleDisplay18,1", "j427ap", 0x02, 0x8150, "Studio Display XDR" }, - { "AppleDisplay18,2", "j527ap", 0x04, 0x8150, "Studio Display (2026)" }, - /* Apple Vision Pro */ - { "RealityDevice14,1", "n301ap", 0x42, 0x8112, "Apple Vision Pro" }, - { "RealityDevice17,1", "n301aap", 0x42, 0x8142, "Apple Vision Pro (M5)" }, - /* Private Cloud Compute Research Environment */ - { "iPhone99,11", "vresearch101ap", 0x90, 0xFE01, "iPhone 99,11" }, - { NULL, NULL, -1, -1, NULL } -}; - #ifndef USE_DUMMY static unsigned int crc32_lookup_t1[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, @@ -738,6 +370,7 @@ static libusb_context* irecv_hotplug_ctx = NULL; static void _irecv_deinit(void) { + irecv_devicedb_cleanup(); #ifndef USE_DUMMY #ifndef _WIN32 #ifndef HAVE_IOKIT @@ -754,6 +387,7 @@ static void _irecv_deinit(void) INITIALIZER(_irecv_init) { + irecv_devicedb_init(); char* dbglvl = getenv("LIBIRECOVERY_DEBUG_LEVEL"); if (dbglvl) { libirecovery_debug = strtol(dbglvl, NULL, 0); @@ -3713,6 +3347,7 @@ irecv_error_t irecv_close(irecv_client_t client) void irecv_set_debug_level(int level) { libirecovery_debug = level; + irecv_devicedb_set_debug(level); #ifndef USE_DUMMY #ifndef _WIN32 #ifndef HAVE_IOKIT @@ -4761,7 +4396,7 @@ irecv_error_t irecv_finish_transfer(irecv_client_t client) irecv_device_t irecv_devices_get_all(void) { - return irecv_devices; + return irecv_devicedb_get(); } irecv_error_t irecv_devices_get_device_by_client(irecv_client_t client, irecv_device_t* device) @@ -4770,6 +4405,7 @@ irecv_error_t irecv_devices_get_device_by_client(irecv_client_t client, irecv_de return IRECV_E_UNSUPPORTED; #else int i = 0; + irecv_device_t table = irecv_devicedb_get(); if (!client || !device) return IRECV_E_INVALID_INPUT; @@ -4787,9 +4423,9 @@ irecv_error_t irecv_devices_get_device_by_client(irecv_client_t client, irecv_de bdid_match = (client->device_info.bdid >> 24) & 0xFF; } - for (i = 0; irecv_devices[i].hardware_model != NULL; i++) { - if (irecv_devices[i].chip_id == cpid_match && irecv_devices[i].board_id == bdid_match) { - *device = &irecv_devices[i]; + for (i = 0; table[i].hardware_model != NULL; i++) { + if (table[i].chip_id == cpid_match && table[i].board_id == bdid_match) { + *device = &table[i]; return IRECV_E_SUCCESS; } } @@ -4801,15 +4437,16 @@ irecv_error_t irecv_devices_get_device_by_client(irecv_client_t client, irecv_de irecv_error_t irecv_devices_get_device_by_product_type(const char* product_type, irecv_device_t* device) { int i = 0; + irecv_device_t table = irecv_devicedb_get(); if (!product_type || !device) return IRECV_E_INVALID_INPUT; *device = NULL; - for (i = 0; irecv_devices[i].product_type != NULL; i++) { - if (!strcmp(product_type, irecv_devices[i].product_type)) { - *device = &irecv_devices[i]; + for (i = 0; table[i].product_type != NULL; i++) { + if (!strcmp(product_type, table[i].product_type)) { + *device = &table[i]; return IRECV_E_SUCCESS; } } @@ -4820,15 +4457,16 @@ irecv_error_t irecv_devices_get_device_by_product_type(const char* product_type, irecv_error_t irecv_devices_get_device_by_hardware_model(const char* hardware_model, irecv_device_t* device) { int i = 0; + irecv_device_t table = irecv_devicedb_get(); if (!hardware_model || !device) return IRECV_E_INVALID_INPUT; *device = NULL; - for (i = 0; irecv_devices[i].hardware_model != NULL; i++) { - if (!strcasecmp(hardware_model, irecv_devices[i].hardware_model)) { - *device = &irecv_devices[i]; + for (i = 0; table[i].hardware_model != NULL; i++) { + if (!strcasecmp(hardware_model, table[i].hardware_model)) { + *device = &table[i]; return IRECV_E_SUCCESS; } } -- cgit v1.1-32-gdbae