summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joshua Hill2010-06-02 22:12:59 -0400
committerGravatar Joshua Hill2010-06-02 22:12:59 -0400
commitac4f614856a5751336fdb1b29b33060bd6c2eaf1 (patch)
tree097a3063556de5a73d16298868a4dd16ecccd4cf
parent30fd56859f50dea5712492807a1b9784da9fec11 (diff)
downloadlibirecovery-ac4f614856a5751336fdb1b29b33060bd6c2eaf1.tar.gz
libirecovery-ac4f614856a5751336fdb1b29b33060bd6c2eaf1.tar.bz2
Added some new helper functions to fetch chip id and board id and changed Makefile to automatically refresh linker cache after install
-rw-r--r--Makefile1
-rw-r--r--include/libirecovery.h4
-rw-r--r--src/libirecovery.c43
3 files changed, 46 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 2606226..cba35d0 100644
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,7 @@ install:
cp libirecovery.so /usr/local/lib/libirecovery.so
cp include/libirecovery.h /usr/local/include/libirecovery.h
cp irecovery /usr/local/bin/irecovery
+ ldconfig
uninstall:
rm -rf /usr/local/lib/libirecovery.so
diff --git a/include/libirecovery.h b/include/libirecovery.h
index a501c0f..20ecfc7 100644
--- a/include/libirecovery.h
+++ b/include/libirecovery.h
@@ -83,7 +83,9 @@ irecv_error_t irecv_receive(irecv_client_t client);
irecv_error_t irecv_send_exploit(irecv_client_t client);
irecv_error_t irecv_set_debug(irecv_client_t client, int level);
irecv_error_t irecv_getenv(irecv_client_t client, unsigned char** var);
-irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* pecid);
+irecv_error_t irecv_get_cpid(irecv_client_t client, unsigned int* cpid);
+irecv_error_t irecv_get_bdid(irecv_client_t client, unsigned int* bdid);
+irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* ecid);
irecv_error_t irecv_send(irecv_client_t client, unsigned char* command);
irecv_error_t irecv_send_file(irecv_client_t client, const char* filename);
irecv_error_t irecv_send_command(irecv_client_t client, unsigned char* command);
diff --git a/src/libirecovery.c b/src/libirecovery.c
index a641562..1303fc5 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -393,6 +393,48 @@ irecv_error_t irecv_getenv(irecv_client_t client, unsigned char** var) {
return IRECV_E_SUCCESS;
}
+irecv_error_t irecv_get_cpid(irecv_client_t client, unsigned int* cpid) {
+ char info[256];
+ memset(info, '\0', 256);
+
+ if (client == NULL || client->handle == NULL) {
+ return IRECV_E_NO_DEVICE;
+ }
+
+ libusb_get_string_descriptor_ascii(client->handle, 3, info, 255);
+ printf("%d: %s\n", strlen(info), info);
+
+ unsigned char* cpid_string = strstr(info, "CPID:");
+ if (cpid_string == NULL) {
+ *cpid = 0;
+ return IRECV_E_UNKNOWN_ERROR;
+ }
+ sscanf(cpid_string, "CPID:%d", cpid);
+
+ return IRECV_E_SUCCESS;
+}
+
+irecv_error_t irecv_get_bdid(irecv_client_t client, unsigned int* bdid) {
+ char info[256];
+ memset(info, '\0', 256);
+
+ if (client == NULL || client->handle == NULL) {
+ return IRECV_E_NO_DEVICE;
+ }
+
+ libusb_get_string_descriptor_ascii(client->handle, 3, info, 255);
+ printf("%d: %s\n", strlen(info), info);
+
+ unsigned char* bdid_string = strstr(info, "BDID:");
+ if (bdid_string == NULL) {
+ *bdid = 0;
+ return IRECV_E_UNKNOWN_ERROR;
+ }
+ sscanf(bdid_string, "BDID:%d", bdid);
+
+ return IRECV_E_SUCCESS;
+}
+
irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* ecid) {
char info[256];
memset(info, '\0', 256);
@@ -411,7 +453,6 @@ irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* ecid) {
}
sscanf(ecid_string, "ECID:%qX", ecid);
- irecv_reset(client);
return IRECV_E_SUCCESS;
}