Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Lots of miscellaneous fixes merged from private branch

  • Loading branch information...
commit 345ea539bc305a072f2ba92a6dccca5fb7403cde 1 parent a0b9ad4
planetbeing planetbeing authored

Showing 57 changed files with 1,454 additions and 510 deletions. Show diff stats Hide diff stats

  1. +1 1  CMakeLists.txt
  2. +16 14 dfu-util/CMakeLists.txt
  3. +463 455 hfs/rawfile.c
  4. +3 0  includes/common.h
  5. +3 0  includes/hfs/hfsplus.h
  6. +6 0 includes/xpwn/pwnutil.h
  7. +38 12 ipsw-patch/CMakeLists.txt
  8. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/018-4108-7-nowipe.patch
  9. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/018-4108-7.patch
  10. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/018-4118-1.patch
  11. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/DeviceTree.m68ap.patch
  12. +254 0 ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/Info.plist
  13. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/LLB.m68ap.RELEASE.patch
  14. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/Services.patch
  15. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/WTF.m68ap.RELEASE.patch
  16. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/WTF.s5l8900xall.RELEASE.patch
  17. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/bbupdater.patch
  18. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/fstab.patch
  19. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/iBEC.m68ap.RELEASE.patch
  20. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/iBSS.m68ap.RELEASE.patch
  21. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/iBoot.m68ap.RELEASE.patch
  22. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/kernelcache.release.patch
  23. BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/lockdownd.patch
  24. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/018-4118-1.patch
  25. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/018-4122-1-nowipe.patch
  26. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/018-4122-1.patch
  27. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/DeviceTree.n82ap.patch
  28. +218 0 ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/Info.plist
  29. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/LLB.n82ap.RELEASE.patch
  30. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/Services.patch
  31. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/WTF.n82ap.RELEASE.patch
  32. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/WTF.s5l8900xall.RELEASE.patch
  33. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/fstab.patch
  34. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/iBEC.n82ap.RELEASE.patch
  35. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/iBSS.n82ap.RELEASE.patch
  36. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/iBoot.n82ap.RELEASE.patch
  37. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/kernelcache.release.patch
  38. BIN  ipsw-patch/FirmwareBundles/iPhone1,2_2.1_5F136.bundle/lockdownd.patch
  39. BIN  ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/018-4146-1.patch
  40. BIN  ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/018-4149-1-nowipe.patch
  41. BIN  ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/018-4149-1.patch
  42. BIN  ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/DeviceTree.n45ap.patch
  43. +203 0 ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/Info.plist
  44. BIN  ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/LLB.n45ap.RELEASE.patch
  45. BIN  ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/Services.patch
  46. BIN  ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/WTF.n45ap.RELEASE.patch
  47. BIN  ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/WTF.s5l8900xall.RELEASE.patch
  48. BIN  ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/fstab.patch
  49. BIN  ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/iBEC.n45ap.RELEASE.patch
  50. BIN  ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/iBSS.n45ap.RELEASE.patch
  51. BIN  ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/iBoot.n45ap.RELEASE.patch
  52. BIN  ipsw-patch/FirmwareBundles/iPod1,1_2.1_5F137.bundle/kernelcache.release.patch
  53. +92 0 ipsw-patch/img3.c
  54. +7 0 ipsw-patch/libxpwn.c
  55. +5 3 ipsw-patch/outputstate.c
  56. +126 8 ipsw-patch/pwnutil.c
  57. +19 17 xpwn/CMakeLists.txt
2  CMakeLists.txt
@@ -41,7 +41,7 @@ SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.markdown")
41 41 SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
42 42 SET(CPACK_PACKAGE_VERSION_MAJOR "0")
43 43 SET(CPACK_PACKAGE_VERSION_MINOR "5")
44   -SET(CPACK_PACKAGE_VERSION_PATCH "2")
  44 +SET(CPACK_PACKAGE_VERSION_PATCH "3")
45 45 SET(CPACK_PACKAGE_EXECUTABLES "xpwn" "XPwn Pwner")
46 46 SET(CPACK_PACKAGE_EXECUTABLES "ipsw" "IPSW Tool")
47 47 SET(CPACK_PACKAGE_EXECUTABLES "hdutil" "Apple disk image utility")
30 dfu-util/CMakeLists.txt
... ... @@ -1,21 +1,23 @@
1 1 INCLUDE(${PROJECT_SOURCE_DIR}/FindUSB.cmake)
2 2
3   -IF(NOT USB_FOUND)
4   - message(STATUS "libusb is required for dfu-util!")
5   -ELSE(NOT USB_FOUND)
6   - include_directories(${USB_INCLUDE_DIR})
7   - link_directories(${USB_LIBRARIES})
  3 +IF(NOT APPLE OR NOT BUILD_STATIC)
  4 + IF(NOT USB_FOUND)
  5 + message(STATUS "libusb is required for dfu-util!")
  6 + ELSE(NOT USB_FOUND)
  7 + include_directories(${USB_INCLUDE_DIR})
  8 + link_directories(${USB_LIBRARIES})
8 9
9   - add_executable(dfu-util dfu.c sam7dfu.c main.c)
  10 + add_executable(dfu-util dfu.c sam7dfu.c main.c)
10 11
11   - link_directories(${PROJECT_BINARY_DIR}/common ${PROJECT_BINARY_DIR}/hfs ${PROJECT_BINARY_DIR}/ipsw-patch)
  12 + link_directories(${PROJECT_BINARY_DIR}/common ${PROJECT_BINARY_DIR}/hfs ${PROJECT_BINARY_DIR}/ipsw-patch)
12 13
13   - IF(APPLE)
14   - SET_TARGET_PROPERTIES(dfu-util PROPERTIES LINK_FLAGS "-framework CoreFoundation -framework IOKit")
15   - ENDIF(APPLE)
  14 + IF(APPLE)
  15 + SET_TARGET_PROPERTIES(dfu-util PROPERTIES LINK_FLAGS "-framework CoreFoundation -framework IOKit")
  16 + ENDIF(APPLE)
16 17
17   - target_link_libraries(dfu-util xpwn)
18   - target_link_libraries(dfu-util ${USB_LIBRARIES})
  18 + target_link_libraries(dfu-util xpwn)
  19 + target_link_libraries(dfu-util ${USB_LIBRARIES})
19 20
20   - install(TARGETS dfu-util DESTINATION .)
21   -ENDIF(NOT USB_FOUND)
  21 + install(TARGETS dfu-util DESTINATION .)
  22 + ENDIF(NOT USB_FOUND)
  23 +ENDIF(NOT APPLE OR NOT BUILD_STATIC)
918 hfs/rawfile.c
@@ -6,486 +6,494 @@ int writeExtents(RawFile* rawFile);
6 6
7 7 int isBlockUsed(Volume* volume, uint32_t block)
8 8 {
9   - unsigned char byte;
10   -
11   - READ(volume->allocationFile, block / 8, 1, &byte);
12   - return (byte & (1 << (7 - (block % 8)))) != 0;
  9 + unsigned char byte;
  10 +
  11 + READ(volume->allocationFile, block / 8, 1, &byte);
  12 + return (byte & (1 << (7 - (block % 8)))) != 0;
13 13 }
14 14
15 15 int setBlockUsed(Volume* volume, uint32_t block, int used) {
16   - unsigned char byte;
17   -
18   - READ(volume->allocationFile, block / 8, 1, &byte);
19   - if(used) {
20   - byte |= (1 << (7 - (block % 8)));
21   - } else {
22   - byte &= ~(1 << (7 - (block % 8)));
23   - }
24   - ASSERT(WRITE(volume->allocationFile, block / 8, 1, &byte), "WRITE");
25   -
26   - return TRUE;
  16 + unsigned char byte;
  17 +
  18 + READ(volume->allocationFile, block / 8, 1, &byte);
  19 + if(used) {
  20 + byte |= (1 << (7 - (block % 8)));
  21 + } else {
  22 + byte &= ~(1 << (7 - (block % 8)));
  23 + }
  24 + ASSERT(WRITE(volume->allocationFile, block / 8, 1, &byte), "WRITE");
  25 +
  26 + return TRUE;
27 27 }
28 28
29 29 int allocate(RawFile* rawFile, off_t size) {
30   - unsigned char* zeros;
31   - Volume* volume;
32   - HFSPlusForkData* forkData;
33   - uint32_t blocksNeeded;
34   - uint32_t blocksToAllocate;
35   - Extent* extent;
36   - Extent* lastExtent;
37   -
38   - uint32_t curBlock;
39   -
40   - volume = rawFile->volume;
41   - forkData = rawFile->forkData;
42   - extent = rawFile->extents;
43   -
44   - blocksNeeded = ((uint64_t)size / (uint64_t)volume->volumeHeader->blockSize) + (((size % volume->volumeHeader->blockSize) == 0) ? 0 : 1);
45   -
46   - if(blocksNeeded > forkData->totalBlocks) {
47   - zeros = (unsigned char*) malloc(volume->volumeHeader->blockSize);
48   - memset(zeros, 0, volume->volumeHeader->blockSize);
49   -
50   - blocksToAllocate = blocksNeeded - forkData->totalBlocks;
51   -
52   - if(blocksToAllocate > volume->volumeHeader->freeBlocks) {
53   - return FALSE;
54   - }
55   -
56   - lastExtent = NULL;
57   - while(extent != NULL) {
58   - lastExtent = extent;
59   - extent = extent->next;
60   - }
61   -
62   - if(lastExtent == NULL) {
63   - rawFile->extents = (Extent*) malloc(sizeof(Extent));
64   - lastExtent = rawFile->extents;
65   - lastExtent->blockCount = 0;
66   - lastExtent->next = NULL;
67   - curBlock = volume->volumeHeader->nextAllocation;
68   - } else {
69   - curBlock = lastExtent->startBlock + lastExtent->blockCount;
70   - }
71   -
72   - while(blocksToAllocate > 0) {
73   - if(isBlockUsed(volume, curBlock)) {
74   - if(lastExtent->blockCount > 0) {
75   - lastExtent->next = (Extent*) malloc(sizeof(Extent));
76   - lastExtent = lastExtent->next;
77   - lastExtent->blockCount = 0;
78   - lastExtent->next = NULL;
79   - }
80   - curBlock = volume->volumeHeader->nextAllocation;
81   - volume->volumeHeader->nextAllocation++;
82   - if(volume->volumeHeader->nextAllocation >= volume->volumeHeader->totalBlocks) {
83   - volume->volumeHeader->nextAllocation = 0;
84   - }
85   - } else {
86   - if(lastExtent->blockCount == 0) {
87   - lastExtent->startBlock = curBlock;
88   - }
89   -
90   - /* zero out allocated block */
91   - ASSERT(WRITE(volume->image, curBlock * volume->volumeHeader->blockSize, volume->volumeHeader->blockSize, zeros), "WRITE");
92   -
93   - setBlockUsed(volume, curBlock, TRUE);
94   - volume->volumeHeader->freeBlocks--;
95   - blocksToAllocate--;
96   - curBlock++;
97   - lastExtent->blockCount++;
98   -
99   - if(curBlock >= volume->volumeHeader->totalBlocks) {
100   - curBlock = volume->volumeHeader->nextAllocation;
101   - }
102   - }
103   - }
104   -
105   - free(zeros);
106   - } else if(blocksNeeded < forkData->totalBlocks) {
107   - blocksToAllocate = blocksNeeded;
108   -
109   - lastExtent = NULL;
110   -
111   - while(blocksToAllocate > 0) {
112   - if(blocksToAllocate > extent->blockCount) {
113   - blocksToAllocate -= extent->blockCount;
114   - lastExtent = extent;
115   - extent = extent->next;
116   - } else {
117   - break;
118   - }
119   - }
120   -
121   -
122   - if(blocksToAllocate == 0 && lastExtent != NULL) {
123   - lastExtent->next = NULL;
124   - } else {
125   - rawFile->extents = NULL;
126   - }
127   -
128   - do {
129   - for(curBlock = (extent->startBlock + blocksToAllocate); curBlock < (extent->startBlock + extent->blockCount); curBlock++) {
130   - setBlockUsed(volume, curBlock, FALSE);
131   - volume->volumeHeader->freeBlocks++;
132   - }
133   - blocksToAllocate = 0;
134   - lastExtent = extent;
135   - extent = extent->next;
136   - free(lastExtent);
137   -
138   - } while(extent != NULL);
139   - }
140   -
141   - writeExtents(rawFile);
142   -
143   - forkData->logicalSize = size;
144   - forkData->totalBlocks = blocksNeeded;
145   -
146   - updateVolume(rawFile->volume);
147   -
148   - if(rawFile->catalogRecord != NULL) {
149   - updateCatalog(rawFile->volume, rawFile->catalogRecord);
150   - }
151   -
152   - return TRUE;
  30 + unsigned char* zeros;
  31 + Volume* volume;
  32 + HFSPlusForkData* forkData;
  33 + uint32_t blocksNeeded;
  34 + uint32_t blocksToAllocate;
  35 + Extent* extent;
  36 + Extent* lastExtent;
  37 +
  38 + uint32_t curBlock;
  39 +
  40 + volume = rawFile->volume;
  41 + forkData = rawFile->forkData;
  42 + extent = rawFile->extents;
  43 +
  44 + blocksNeeded = ((uint64_t)size / (uint64_t)volume->volumeHeader->blockSize) + (((size % volume->volumeHeader->blockSize) == 0) ? 0 : 1);
  45 +
  46 + if(blocksNeeded > forkData->totalBlocks) {
  47 + zeros = (unsigned char*) malloc(volume->volumeHeader->blockSize);
  48 + memset(zeros, 0, volume->volumeHeader->blockSize);
  49 +
  50 + blocksToAllocate = blocksNeeded - forkData->totalBlocks;
  51 +
  52 + if(blocksToAllocate > volume->volumeHeader->freeBlocks) {
  53 + return FALSE;
  54 + }
  55 +
  56 + lastExtent = NULL;
  57 + while(extent != NULL) {
  58 + lastExtent = extent;
  59 + extent = extent->next;
  60 + }
  61 +
  62 + if(lastExtent == NULL) {
  63 + rawFile->extents = (Extent*) malloc(sizeof(Extent));
  64 + lastExtent = rawFile->extents;
  65 + lastExtent->blockCount = 0;
  66 + lastExtent->next = NULL;
  67 + curBlock = volume->volumeHeader->nextAllocation;
  68 + } else {
  69 + curBlock = lastExtent->startBlock + lastExtent->blockCount;
  70 + }
  71 +
  72 + while(blocksToAllocate > 0) {
  73 + if(isBlockUsed(volume, curBlock)) {
  74 + if(lastExtent->blockCount > 0) {
  75 + lastExtent->next = (Extent*) malloc(sizeof(Extent));
  76 + lastExtent = lastExtent->next;
  77 + lastExtent->blockCount = 0;
  78 + lastExtent->next = NULL;
  79 + }
  80 + curBlock = volume->volumeHeader->nextAllocation;
  81 + volume->volumeHeader->nextAllocation++;
  82 + if(volume->volumeHeader->nextAllocation >= volume->volumeHeader->totalBlocks) {
  83 + volume->volumeHeader->nextAllocation = 0;
  84 + }
  85 + } else {
  86 + if(lastExtent->blockCount == 0) {
  87 + lastExtent->startBlock = curBlock;
  88 + }
  89 +
  90 + /* zero out allocated block */
  91 + ASSERT(WRITE(volume->image, curBlock * volume->volumeHeader->blockSize, volume->volumeHeader->blockSize, zeros), "WRITE");
  92 +
  93 + setBlockUsed(volume, curBlock, TRUE);
  94 + volume->volumeHeader->freeBlocks--;
  95 + blocksToAllocate--;
  96 + curBlock++;
  97 + lastExtent->blockCount++;
  98 +
  99 + if(curBlock >= volume->volumeHeader->totalBlocks) {
  100 + curBlock = volume->volumeHeader->nextAllocation;
  101 + }
  102 + }
  103 + }
  104 +
  105 + free(zeros);
  106 + } else if(blocksNeeded < forkData->totalBlocks) {
  107 + blocksToAllocate = blocksNeeded;
  108 +
  109 + lastExtent = NULL;
  110 +
  111 + while(blocksToAllocate > 0) {
  112 + if(blocksToAllocate > extent->blockCount) {
  113 + blocksToAllocate -= extent->blockCount;
  114 + lastExtent = extent;
  115 + extent = extent->next;
  116 + } else {
  117 + break;
  118 + }
  119 + }
  120 +
  121 +
  122 + if(blocksToAllocate == 0 && lastExtent != NULL) {
  123 + // snip the extent list here, since we don't need the rest
  124 + lastExtent->next = NULL;
  125 + } else if(blocksNeeded == 0) {
  126 + rawFile->extents = NULL;
  127 + }
  128 +
  129 + do {
  130 + for(curBlock = (extent->startBlock + blocksToAllocate); curBlock < (extent->startBlock + extent->blockCount); curBlock++) {
  131 + setBlockUsed(volume, curBlock, FALSE);
  132 + volume->volumeHeader->freeBlocks++;
  133 + }
  134 + lastExtent = extent;
  135 + extent = extent->next;
  136 +
  137 + if(blocksToAllocate == 0)
  138 + {
  139 + free(lastExtent);
  140 + } else {
  141 + lastExtent->next = NULL;
  142 + lastExtent->blockCount = blocksToAllocate;
  143 + }
  144 +
  145 + blocksToAllocate = 0;
  146 + } while(extent != NULL);
  147 + }
  148 +
  149 + writeExtents(rawFile);
  150 +
  151 + forkData->logicalSize = size;
  152 + forkData->totalBlocks = blocksNeeded;
  153 +
  154 + updateVolume(rawFile->volume);
  155 +
  156 + if(rawFile->catalogRecord != NULL) {
  157 + updateCatalog(rawFile->volume, rawFile->catalogRecord);
  158 + }
  159 +
  160 + return TRUE;
153 161 }
154 162
155 163 static int rawFileRead(io_func* io,off_t location, size_t size, void *buffer) {
156   - RawFile* rawFile;
157   - Volume* volume;
158   - Extent* extent;
159   -
160   - size_t blockSize;
161   - off_t fileLoc;
162   - off_t locationInBlock;
163   - size_t possible;
164   -
165   - rawFile = (RawFile*) io->data;
166   - volume = rawFile->volume;
167   - blockSize = volume->volumeHeader->blockSize;
168   -
169   - extent = rawFile->extents;
170   - fileLoc = 0;
171   -
172   - locationInBlock = location;
173   - while(TRUE) {
174   - fileLoc += extent->blockCount * blockSize;
175   - if(fileLoc <= location) {
176   - locationInBlock -= extent->blockCount * blockSize;
177   - extent = extent->next;
178   - if(extent == NULL)
179   - break;
180   - } else {
181   - break;
182   - }
183   - }
184   -
185   - while(size > 0) {
186   - if(extent == NULL)
187   - return FALSE;
188   -
189   - possible = extent->blockCount * blockSize - locationInBlock;
190   -
191   - if(size > possible) {
192   - ASSERT(READ(volume->image, extent->startBlock * blockSize + locationInBlock, possible, buffer), "READ");
193   - size -= possible;
194   - buffer = (void*)(((size_t)buffer) + possible);
195   - extent = extent->next;
196   - } else {
197   - ASSERT(READ(volume->image, extent->startBlock * blockSize + locationInBlock, size, buffer), "READ");
198   - break;
199   - }
200   -
201   - locationInBlock = 0;
202   - }
203   -
204   - return TRUE;
  164 + RawFile* rawFile;
  165 + Volume* volume;
  166 + Extent* extent;
  167 +
  168 + size_t blockSize;
  169 + off_t fileLoc;
  170 + off_t locationInBlock;
  171 + size_t possible;
  172 +
  173 + rawFile = (RawFile*) io->data;
  174 + volume = rawFile->volume;
  175 + blockSize = volume->volumeHeader->blockSize;
  176 +
  177 + extent = rawFile->extents;
  178 + fileLoc = 0;
  179 +
  180 + locationInBlock = location;
  181 + while(TRUE) {
  182 + fileLoc += extent->blockCount * blockSize;
  183 + if(fileLoc <= location) {
  184 + locationInBlock -= extent->blockCount * blockSize;
  185 + extent = extent->next;
  186 + if(extent == NULL)
  187 + break;
  188 + } else {
  189 + break;
  190 + }
  191 + }
  192 +
  193 + while(size > 0) {
  194 + if(extent == NULL)
  195 + return FALSE;
  196 +
  197 + possible = extent->blockCount * blockSize - locationInBlock;
  198 +
  199 + if(size > possible) {
  200 + ASSERT(READ(volume->image, extent->startBlock * blockSize + locationInBlock, possible, buffer), "READ");
  201 + size -= possible;
  202 + buffer = (void*)(((size_t)buffer) + possible);
  203 + extent = extent->next;
  204 + } else {
  205 + ASSERT(READ(volume->image, extent->startBlock * blockSize + locationInBlock, size, buffer), "READ");
  206 + break;
  207 + }
  208 +
  209 + locationInBlock = 0;
  210 + }
  211 +
  212 + return TRUE;
205 213 }
206 214
207 215 static int rawFileWrite(io_func* io,off_t location, size_t size, void *buffer) {
208   - RawFile* rawFile;
209   - Volume* volume;
210   - Extent* extent;
211   -
212   - size_t blockSize;
213   - off_t fileLoc;
214   - off_t locationInBlock;
215   - size_t possible;
216   -
217   - rawFile = (RawFile*) io->data;
218   - volume = rawFile->volume;
219   - blockSize = volume->volumeHeader->blockSize;
220   -
221   - if(rawFile->forkData->logicalSize < (location + size)) {
222   - ASSERT(allocate(rawFile, location + size), "allocate");
223   - }
224   -
225   - extent = rawFile->extents;
226   - fileLoc = 0;
227   -
228   - locationInBlock = location;
229   - while(TRUE) {
230   - fileLoc += extent->blockCount * blockSize;
231   - if(fileLoc <= location) {
232   - locationInBlock -= extent->blockCount * blockSize;
233   - extent = extent->next;
234   - if(extent == NULL)
235   - break;
236   - } else {
237   - break;
238   - }
239   - }
240   -
241   - while(size > 0) {
242   - if(extent == NULL)
243   - return FALSE;
244   -
245   - possible = extent->blockCount * blockSize - locationInBlock;
246   -
247   - if(size > possible) {
248   - ASSERT(WRITE(volume->image, extent->startBlock * blockSize + locationInBlock, possible, buffer), "WRITE");
249   - size -= possible;
250   - buffer = (void*)(((size_t)buffer) + possible);
251   - extent = extent->next;
252   - } else {
253   - ASSERT(WRITE(volume->image, extent->startBlock * blockSize + locationInBlock, size, buffer), "WRITE");
254   - break;
255   - }
256   -
257   - locationInBlock = 0;
258   - }
259   -
260   - return TRUE;
  216 + RawFile* rawFile;
  217 + Volume* volume;
  218 + Extent* extent;
  219 +
  220 + size_t blockSize;
  221 + off_t fileLoc;
  222 + off_t locationInBlock;
  223 + size_t possible;
  224 +
  225 + rawFile = (RawFile*) io->data;
  226 + volume = rawFile->volume;
  227 + blockSize = volume->volumeHeader->blockSize;
  228 +
  229 + if(rawFile->forkData->logicalSize < (location + size)) {
  230 + ASSERT(allocate(rawFile, location + size), "allocate");
  231 + }
  232 +
  233 + extent = rawFile->extents;
  234 + fileLoc = 0;
  235 +
  236 + locationInBlock = location;
  237 + while(TRUE) {
  238 + fileLoc += extent->blockCount * blockSize;
  239 + if(fileLoc <= location) {
  240 + locationInBlock -= extent->blockCount * blockSize;
  241 + extent = extent->next;
  242 + if(extent == NULL)
  243 + break;
  244 + } else {
  245 + break;
  246 + }
  247 + }
  248 +
  249 + while(size > 0) {
  250 + if(extent == NULL)
  251 + return FALSE;
  252 +
  253 + possible = extent->blockCount * blockSize - locationInBlock;
  254 +
  255 + if(size > possible) {
  256 + ASSERT(WRITE(volume->image, extent->startBlock * blockSize + locationInBlock, possible, buffer), "WRITE");
  257 + size -= possible;
  258 + buffer = (void*)(((size_t)buffer) + possible);
  259 + extent = extent->next;
  260 + } else {
  261 + ASSERT(WRITE(volume->image, extent->startBlock * blockSize + locationInBlock, size, buffer), "WRITE");
  262 + break;
  263 + }
  264 +
  265 + locationInBlock = 0;
  266 + }
  267 +
  268 + return TRUE;
261 269 }
262 270
263 271 static void closeRawFile(io_func* io) {
264   - RawFile* rawFile;
265   - Extent* extent;
266   - Extent* toRemove;
267   -
268   - rawFile = (RawFile*) io->data;
269   - extent = rawFile->extents;
270   -
271   - while(extent != NULL) {
272   - toRemove = extent;
273   - extent = extent->next;
274   - free(toRemove);
275   - }
276   -
277   - free(rawFile);
278   - free(io);
  272 + RawFile* rawFile;
  273 + Extent* extent;
  274 + Extent* toRemove;
  275 +
  276 + rawFile = (RawFile*) io->data;
  277 + extent = rawFile->extents;
  278 +
  279 + while(extent != NULL) {
  280 + toRemove = extent;
  281 + extent = extent->next;
  282 + free(toRemove);
  283 + }
  284 +
  285 + free(rawFile);
  286 + free(io);
279 287 }
280 288
281 289 int removeExtents(RawFile* rawFile) {
282   - uint32_t blocksLeft;
283   - HFSPlusForkData* forkData;
284   - uint32_t currentBlock;
285   -
286   - uint32_t startBlock;
287   - uint32_t blockCount;
288   -
289   - HFSPlusExtentDescriptor* descriptor;
290   - int currentExtent;
291   - HFSPlusExtentKey extentKey;
292   - int exact;
293   -
294   - extentKey.keyLength = sizeof(HFSPlusExtentKey) - sizeof(extentKey.keyLength);
295   - extentKey.forkType = 0;
296   - extentKey.fileID = rawFile->id;
297   -
298   - forkData = rawFile->forkData;
299   - blocksLeft = forkData->totalBlocks;
300   - currentExtent = 0;
301   - currentBlock = 0;
302   - descriptor = (HFSPlusExtentDescriptor*) forkData->extents;
303   -
304   - while(blocksLeft > 0) {
305   - if(currentExtent == 8) {
306   - if(rawFile->volume->extentsTree == NULL) {
307   - hfs_panic("no extents overflow file loaded yet!");
308   - return FALSE;
309   - }
310   -
311   - if(descriptor != ((HFSPlusExtentDescriptor*) forkData->extents)) {
312   - free(descriptor);
313   - }
314   -
315   - extentKey.startBlock = currentBlock;
316   - descriptor = (HFSPlusExtentDescriptor*) search(rawFile->volume->extentsTree, (BTKey*)(&extentKey), &exact, NULL, NULL);
317   - if(descriptor == NULL || exact == FALSE) {
318   - hfs_panic("inconsistent extents information!");
319   - return FALSE;
320   - } else {
321   - removeFromBTree(rawFile->volume->extentsTree, (BTKey*)(&extentKey));
322   - currentExtent = 0;
323   - continue;
324   - }
325   - }
326   -
327   - startBlock = descriptor[currentExtent].startBlock;
328   - blockCount = descriptor[currentExtent].blockCount;
329   -
330   - currentBlock += blockCount;
331   - blocksLeft -= blockCount;
332   - currentExtent++;
333   - }
334   -
335   - if(descriptor != ((HFSPlusExtentDescriptor*) forkData->extents)) {
336   - free(descriptor);
337   - }
338   -
339   - return TRUE;
  290 + uint32_t blocksLeft;
  291 + HFSPlusForkData* forkData;
  292 + uint32_t currentBlock;
  293 +
  294 + uint32_t startBlock;
  295 + uint32_t blockCount;
  296 +
  297 + HFSPlusExtentDescriptor* descriptor;
  298 + int currentExtent;
  299 + HFSPlusExtentKey extentKey;
  300 + int exact;
  301 +
  302 + extentKey.keyLength = sizeof(HFSPlusExtentKey) - sizeof(extentKey.keyLength);
  303 + extentKey.forkType = 0;
  304 + extentKey.fileID = rawFile->id;
  305 +
  306 + forkData = rawFile->forkData;
  307 + blocksLeft = forkData->totalBlocks;
  308 + currentExtent = 0;
  309 + currentBlock = 0;
  310 + descriptor = (HFSPlusExtentDescriptor*) forkData->extents;
  311 +
  312 + while(blocksLeft > 0) {
  313 + if(currentExtent == 8) {
  314 + if(rawFile->volume->extentsTree == NULL) {
  315 + hfs_panic("no extents overflow file loaded yet!");
  316 + return FALSE;
  317 + }
  318 +
  319 + if(descriptor != ((HFSPlusExtentDescriptor*) forkData->extents)) {
  320 + free(descriptor);
  321 + }
  322 +
  323 + extentKey.startBlock = currentBlock;
  324 + descriptor = (HFSPlusExtentDescriptor*) search(rawFile->volume->extentsTree, (BTKey*)(&extentKey), &exact, NULL, NULL);
  325 + if(descriptor == NULL || exact == FALSE) {
  326 + hfs_panic("inconsistent extents information!");
  327 + return FALSE;
  328 + } else {
  329 + removeFromBTree(rawFile->volume->extentsTree, (BTKey*)(&extentKey));
  330 + currentExtent = 0;
  331 + continue;
  332 + }
  333 + }
  334 +
  335 + startBlock = descriptor[currentExtent].startBlock;
  336 + blockCount = descriptor[currentExtent].blockCount;
  337 +
  338 + currentBlock += blockCount;
  339 + blocksLeft -= blockCount;
  340 + currentExtent++;
  341 + }
  342 +
  343 + if(descriptor != ((HFSPlusExtentDescriptor*) forkData->extents)) {
  344 + free(descriptor);
  345 + }
  346 +
  347 + return TRUE;
340 348 }
341 349
342 350 int writeExtents(RawFile* rawFile) {
343   - Extent* extent;
344   - int currentExtent;
345   - HFSPlusExtentKey extentKey;
346   - HFSPlusExtentDescriptor descriptor[8];
347   - HFSPlusForkData* forkData;
348   -
349   - removeExtents(rawFile);
350   -
351   - forkData = rawFile->forkData;
352   - currentExtent = 0;
353   - extent = rawFile->extents;
354   -
355   - memset(forkData->extents, 0, sizeof(HFSPlusExtentRecord));
356   - while(extent != NULL && currentExtent < 8) {
357   - ((HFSPlusExtentDescriptor*)forkData->extents)[currentExtent].startBlock = extent->startBlock;
358   - ((HFSPlusExtentDescriptor*)forkData->extents)[currentExtent].blockCount = extent->blockCount;
359   - extent = extent->next;
360   - currentExtent++;
361   - }
362   -
363   - if(extent != NULL) {
364   - extentKey.keyLength = sizeof(HFSPlusExtentKey) - sizeof(extentKey.keyLength);
365   - extentKey.forkType = 0;
366   - extentKey.fileID = rawFile->id;
367   -
368   - currentExtent = 0;
369   -
370   - while(extent != NULL) {
371   - if(currentExtent == 0) {
372   - memset(descriptor, 0, sizeof(HFSPlusExtentRecord));
373   - }
374   -
375   - if(currentExtent == 8) {
376   - extentKey.startBlock = descriptor[0].startBlock;
377   - addToBTree(rawFile->volume->extentsTree, (BTKey*)(&extentKey), sizeof(HFSPlusExtentRecord), (unsigned char *)(&(descriptor[0])));
378   - currentExtent = 0;
379   - }
380   -
381   - descriptor[currentExtent].startBlock = extent->startBlock;
382   - descriptor[currentExtent].blockCount = extent->blockCount;
383   -
384   - currentExtent++;
385   - extent = extent->next;
386   - }
387   -
388   - extentKey.startBlock = descriptor[0].startBlock;
389   - addToBTree(rawFile->volume->extentsTree, (BTKey*)(&extentKey), sizeof(HFSPlusExtentRecord), (unsigned char *)(&(descriptor[0])));
390   - }
391   -
392   - return TRUE;
  351 + Extent* extent;
  352 + int currentExtent;
  353 + HFSPlusExtentKey extentKey;
  354 + HFSPlusExtentDescriptor descriptor[8];
  355 + HFSPlusForkData* forkData;
  356 +
  357 + removeExtents(rawFile);
  358 +
  359 + forkData = rawFile->forkData;
  360 + currentExtent = 0;
  361 + extent = rawFile->extents;
  362 +
  363 + memset(forkData->extents, 0, sizeof(HFSPlusExtentRecord));
  364 + while(extent != NULL && currentExtent < 8) {
  365 + ((HFSPlusExtentDescriptor*)forkData->extents)[currentExtent].startBlock = extent->startBlock;
  366 + ((HFSPlusExtentDescriptor*)forkData->extents)[currentExtent].blockCount = extent->blockCount;
  367 + extent = extent->next;
  368 + currentExtent++;
  369 + }
  370 +
  371 + if(extent != NULL) {
  372 + extentKey.keyLength = sizeof(HFSPlusExtentKey) - sizeof(extentKey.keyLength);
  373 + extentKey.forkType = 0;
  374 + extentKey.fileID = rawFile->id;
  375 +
  376 + currentExtent = 0;
  377 +
  378 + while(extent != NULL) {
  379 + if(currentExtent == 0) {
  380 + memset(descriptor, 0, sizeof(HFSPlusExtentRecord));
  381 + }
  382 +
  383 + if(currentExtent == 8) {
  384 + extentKey.startBlock = descriptor[0].startBlock;
  385 + addToBTree(rawFile->volume->extentsTree, (BTKey*)(&extentKey), sizeof(HFSPlusExtentRecord), (unsigned char *)(&(descriptor[0])));
  386 + currentExtent = 0;
  387 + }
  388 +
  389 + descriptor[currentExtent].startBlock = extent->startBlock;
  390 + descriptor[currentExtent].blockCount = extent->blockCount;
  391 +
  392 + currentExtent++;
  393 + extent = extent->next;
  394 + }
  395 +
  396 + extentKey.startBlock = descriptor[0].startBlock;
  397 + addToBTree(rawFile->volume->extentsTree, (BTKey*)(&extentKey), sizeof(HFSPlusExtentRecord), (unsigned char *)(&(descriptor[0])));
  398 + }
  399 +
  400 + return TRUE;
393 401 }
394 402
395 403 int readExtents(RawFile* rawFile) {
396   - uint32_t blocksLeft;
397   - HFSPlusForkData* forkData;
398   - uint32_t currentBlock;
399   -
400   - Extent* extent;
401   - Extent* lastExtent;
402   -
403   - HFSPlusExtentDescriptor* descriptor;
404   - int currentExtent;
405   - HFSPlusExtentKey extentKey;
406   - int exact;
407   -
408   - extentKey.keyLength = sizeof(HFSPlusExtentKey) - sizeof(extentKey.keyLength);
409   - extentKey.forkType = 0;
410   - extentKey.fileID = rawFile->id;
411   -
412   - forkData = rawFile->forkData;
413   - blocksLeft = forkData->totalBlocks;
414   - currentExtent = 0;
415   - currentBlock = 0;
416   - descriptor = (HFSPlusExtentDescriptor*) forkData->extents;
417   -
418   - lastExtent = NULL;
419   -
420   - while(blocksLeft > 0) {
421   - extent = (Extent*) malloc(sizeof(Extent));
422   -
423   - if(currentExtent == 8) {
424   - if(rawFile->volume->extentsTree == NULL) {
425   - hfs_panic("no extents overflow file loaded yet!");
426   - return FALSE;
427   - }
428   -
429   - if(descriptor != ((HFSPlusExtentDescriptor*) forkData->extents)) {
430   - free(descriptor);
431   - }
432   -
433   - extentKey.startBlock = currentBlock;
434   - descriptor = (HFSPlusExtentDescriptor*) search(rawFile->volume->extentsTree, (BTKey*)(&extentKey), &exact, NULL, NULL);
435   - if(descriptor == NULL || exact == FALSE) {
436   - hfs_panic("inconsistent extents information!");
437   - return FALSE;
438   - } else {
439   - currentExtent = 0;
440   - continue;
441   - }
442   - }
443   -
444   - extent->startBlock = descriptor[currentExtent].startBlock;
445   - extent->blockCount = descriptor[currentExtent].blockCount;
446   - extent->next = NULL;
447   -
448   - currentBlock += extent->blockCount;
449   - blocksLeft -= extent->blockCount;
450   - currentExtent++;
451   -
452   - if(lastExtent == NULL) {
453   - rawFile->extents = extent;
454   - } else {
455   - lastExtent->next = extent;
456   - }
457   -
458   - lastExtent = extent;
459   - }
460   -
461   - if(descriptor != ((HFSPlusExtentDescriptor*) forkData->extents)) {
462   - free(descriptor);
463   - }
464   -
465   - return TRUE;
  404 + uint32_t blocksLeft;
  405 + HFSPlusForkData* forkData;
  406 + uint32_t currentBlock;
  407 +
  408 + Extent* extent;
  409 + Extent* lastExtent;
  410 +
  411 + HFSPlusExtentDescriptor* descriptor;
  412 + int currentExtent;
  413 + HFSPlusExtentKey extentKey;
  414 + int exact;
  415 +
  416 + extentKey.keyLength = sizeof(HFSPlusExtentKey) - sizeof(extentKey.keyLength);
  417 + extentKey.forkType = 0;
  418 + extentKey.fileID = rawFile->id;
  419 +
  420 + forkData = rawFile->forkData;
  421 + blocksLeft = forkData->totalBlocks;
  422 + currentExtent = 0;
  423 + currentBlock = 0;
  424 + descriptor = (HFSPlusExtentDescriptor*) forkData->extents;
  425 +
  426 + lastExtent = NULL;
  427 +
  428 + while(blocksLeft > 0) {
  429 + extent = (Extent*) malloc(sizeof(Extent));
  430 +
  431 + if(currentExtent == 8) {
  432 + if(rawFile->volume->extentsTree == NULL) {
  433 + hfs_panic("no extents overflow file loaded yet!");
  434 + return FALSE;
  435 + }
  436 +
  437 + if(descriptor != ((HFSPlusExtentDescriptor*) forkData->extents)) {
  438 + free(descriptor);
  439 + }
  440 +
  441 + extentKey.startBlock = currentBlock;
  442 + descriptor = (HFSPlusExtentDescriptor*) search(rawFile->volume->extentsTree, (BTKey*)(&extentKey), &exact, NULL, NULL);
  443 + if(descriptor == NULL || exact == FALSE) {
  444 + hfs_panic("inconsistent extents information!");
  445 + return FALSE;
  446 + } else {
  447 + currentExtent = 0;
  448 + continue;
  449 + }
  450 + }
  451 +
  452 + extent->startBlock = descriptor[currentExtent].startBlock;
  453 + extent->blockCount = descriptor[currentExtent].blockCount;
  454 + extent->next = NULL;
  455 +
  456 + currentBlock += extent->blockCount;
  457 + blocksLeft -= extent->blockCount;
  458 + currentExtent++;
  459 +
  460 + if(lastExtent == NULL) {
  461 + rawFile->extents = extent;
  462 + } else {
  463 + lastExtent->next = extent;
  464 + }
  465 +
  466 + lastExtent = extent;
  467 + }
  468 +
  469 + if(descriptor != ((HFSPlusExtentDescriptor*) forkData->extents)) {
  470 + free(descriptor);
  471 + }
  472 +
  473 + return TRUE;
466 474 }
467 475
468 476 io_func* openRawFile(HFSCatalogNodeID id, HFSPlusForkData* forkData, HFSPlusCatalogRecord* catalogRecord, Volume* volume) {
469   - io_func* io;
470   - RawFile* rawFile;
471   -
472   - io = (io_func*) malloc(sizeof(io_func));
473   - rawFile = (RawFile*) malloc(sizeof(RawFile));
474   -
475   - rawFile->id = id;
476   - rawFile->volume = volume;
477   - rawFile->forkData = forkData;
478   - rawFile->catalogRecord = catalogRecord;
479   - rawFile->extents = NULL;
480   -
481   - io->data = rawFile;
482   - io->read = &rawFileRead;
483   - io->write = &rawFileWrite;
484   - io->close = &closeRawFile;
485   -
486   - if(!readExtents(rawFile)) {
487   - return NULL;
488   - }
489   -
490   - return io;
  477 + io_func* io;
  478 + RawFile* rawFile;
  479 +
  480 + io = (io_func*) malloc(sizeof(io_func));
  481 + rawFile = (RawFile*) malloc(sizeof(RawFile));
  482 +
  483 + rawFile->id = id;
  484 + rawFile->volume = volume;
  485 + rawFile->forkData = forkData;
  486 + rawFile->catalogRecord = catalogRecord;
  487 + rawFile->extents = NULL;
  488 +
  489 + io->data = rawFile;
  490 + io->read = &rawFileRead;
  491 + io->write = &rawFileWrite;
  492 + io->close = &closeRawFile;
  493 +
  494 + if(!readExtents(rawFile)) {
  495 + return NULL;
  496 + }
  497 +
  498 + return io;
491 499 }
3  includes/common.h
@@ -12,6 +12,9 @@
12 12 #define ftello ftello64
13 13 #define off_t off64_t
14 14 #define mkdir(x, y) mkdir(x)
  15 +#define PATH_SEPARATOR "\\"
  16 +#else
  17 +#define PATH_SEPARATOR "/"
15 18 #endif
16 19
17 20 #define TRUE 1
3  includes/hfs/hfsplus.h
@@ -161,6 +161,7 @@ struct HFSPlusCatalogKey {
161 161 } __attribute__((__packed__));
162 162 typedef struct HFSPlusCatalogKey HFSPlusCatalogKey;
163 163
  164 +#ifndef __MACTYPES__
164 165 struct Point {
165 166 int16_t v;
166 167 int16_t h;
@@ -180,6 +181,8 @@ typedef struct Rect Rect;
180 181 typedef uint32_t FourCharCode;
181 182 typedef FourCharCode OSType;
182 183
  184 +#endif
  185 +
183 186 /* Finder flags (finderFlags, fdFlags and frFlags) */
184 187 enum {
185 188 kIsOnDesk = 0x0001, /* Files and folders (System 6) */
6 includes/xpwn/pwnutil.h
@@ -5,6 +5,8 @@
5 5 #include <xpwn/outputstate.h>
6 6 #include <hfs/hfsplus.h>
7 7
  8 +typedef int (*PatchFunction)(AbstractFile* file);
  9 +
8 10 #ifdef __cplusplus
9 11 extern "C" {
10 12 #endif
@@ -15,6 +17,10 @@ extern "C" {
15 17 void doPatchInPlace(Volume* volume, const char* filePath, const char* patchPath);
16 18 void fixupBootNeuterArgs(Volume* volume, char unlockBaseband, char selfDestruct, char use39, char use46);
17 19 void createRestoreOptions(Volume* volume, int SystemPartitionSize, int UpdateBaseband);
  20 +
  21 + int patchSigCheck(AbstractFile* file);
  22 + int patchKernel(AbstractFile* file);
  23 + int patchDeviceTree(AbstractFile* file);
18 24 #ifdef __cplusplus
19 25 }
20 26 #endif
50 ipsw-patch/CMakeLists.txt
@@ -27,7 +27,11 @@ IF(NOT PNG_FOUND)
27 27 ENDIF(NOT PNG_FOUND)
28 28
29 29 include_directories(${ZLIB_INCLUDE_DIR})
  30 +
  31 +IF(NOT APPLE)
30 32 link_directories(${ZLIB_LIBRARIES})
  33 +ENDIF(NOT APPLE)
  34 +
31 35 include_directories(${BZIP2_INCLUDE_DIR})
32 36 link_directories(${BZIP2_LIBRARIES})
33 37 include_directories(${PNG_INCLUDE_DIR})
@@ -38,20 +42,42 @@ link_directories(${PROJECT_BINARY_DIR}/minizip)
38 42
39 43 link_directories(${PROJECT_BINARY_DIR}/common ${PROJECT_BINARY_DIR}/hfs ${PROJECT_BINARY_DIR}/dmg)
40 44
  45 +IF(HAVE_HW_CRYPTO)
  46 + add_definitions(-DHAVE_HW_CRYPTO)
  47 +ENDIF(HAVE_HW_CRYPTO)
  48 +
41 49 add_library(xpwn 8900.c bspatch.c ibootim.c img2.c img3.c libxpwn.c lzss.c lzssfile.c nor_files.c outputstate.c plist.c pwnutil.c)
42 50
43   -target_link_libraries(xpwn dmg hfs common minizip ${CRYPTO_LIBRARIES} ${BZIP2_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} m)
44   -
45   -ADD_CUSTOM_TARGET(libXPwn.a
46   - COMMAND ${CMAKE_C_COMPILER}
47   - -L${PROJECT_BINARY_DIR}/ipsw-patch -L${PROJECT_BINARY_DIR}/dmg -L${PROJECT_BINARY_DIR}/hfs
48   - -L${PROJECT_BINARY_DIR}/hfs -L${PROJECT_BINARY_DIR}/minizip -L${PROJECT_BINARY_DIR}/common
49   - -Xlinker --whole-archive -lxpwn -ldmg -lhfs -lcommon -lminizip
50   - ${CRYPTO_LIBRARIES} ${BZIP2_LIBRARIES} ${PNG_LIBRARIES}
51   - -Xlinker --unresolved-symbols=ignore-all -Xlinker -r -nostdlib -o libXPwn.o
52   - COMMAND ${CMAKE_AR} cr libXPwn.a libXPwn.o
53   - COMMAND ${CMAKE_RANLIB} libXPwn.a
54   - DEPENDS xpwn dmg hfs common minizip)
  51 +IF(HAVE_HW_CRYPTO)
  52 + target_link_libraries(xpwn IOKit)
  53 +ENDIF(HAVE_HW_CRYPTO)
  54 +
  55 +target_link_libraries(xpwn dmg hfs common minizip ${CRYPTO_LIBRARIES} ${BZIP2_LIBRARIES} ${PNG_LIBRARIES} m)
  56 +
  57 +IF(NOT APPLE)
  58 + target_link_libraries(xpwn ${ZLIB_LIBRARIES})
  59 +ENDIF(NOT APPLE)
  60 +
  61 +IF(APPLE)
  62 + ADD_CUSTOM_TARGET(libXPwn.a
  63 + COMMAND powerpc-apple-darwin8-libtool -static -o libXPwn.a
  64 + ${PROJECT_BINARY_DIR}/ipsw-patch/libxpwn.a ${PROJECT_BINARY_DIR}/minizip/libminizip.a
  65 + ${PROJECT_BINARY_DIR}/common/libcommon.a ${PROJECT_BINARY_DIR}/hfs/libhfs.a
  66 + ${PROJECT_BINARY_DIR}/dmg/libdmg.a ${PNG_LIBRARIES} ${BZIP2_LIBRARIES}
  67 + ${CRYPTO_LIBRARIES}
  68 + DEPENDS xpwn dmg hfs common minizip)
  69 +ELSE(APPLE)
  70 + ADD_CUSTOM_TARGET(libXPwn.a
  71 + COMMAND ${CMAKE_C_COMPILER}
  72 + -L${PROJECT_BINARY_DIR}/ipsw-patch -L${PROJECT_BINARY_DIR}/dmg -L${PROJECT_BINARY_DIR}/hfs
  73 + -L${PROJECT_BINARY_DIR}/hfs -L${PROJECT_BINARY_DIR}/minizip -L${PROJECT_BINARY_DIR}/common
  74 + -Xlinker --whole-archive -lxpwn -ldmg -lhfs -lcommon -lminizip
  75 + ${CRYPTO_LIBRARIES} ${BZIP2_LIBRARIES} ${PNG_LIBRARIES}
  76 + -Xlinker --unresolved-symbols=ignore-all -Xlinker -r -nostdlib -o libXPwn.o
  77 + COMMAND ${CMAKE_AR} cr libXPwn.a libXPwn.o
  78 + COMMAND ${CMAKE_RANLIB} libXPwn.a
  79 + DEPENDS xpwn dmg hfs common minizip)
  80 +ENDIF(APPLE)
55 81
56 82 IF(WIN32)
57 83 TARGET_LINK_LIBRARIES(xpwn gdi32)
BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/018-4108-7-nowipe.patch
Binary file not shown
BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/018-4108-7.patch
Binary file not shown
BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/018-4118-1.patch
Binary file not shown
BIN  ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/DeviceTree.m68ap.patch
Binary file not shown
254 ipsw-patch/FirmwareBundles/iPhone1,1_2.1_5F136.bundle/Info.plist
... ... @@ -0,0 +1,254 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<dict>
  5 + <key>BasebandPatches</key>
  6 + <dict>
  7 + <key>BBUpdater</key>
  8 + <dict>
  9 + <key>File</key>
  10 + <string>usr/local/bin/bbupdater</string>
  11 + <key>Patch</key>
  12 + <string>bbupdater.patch</string>
  13 + <key>Path</key>
  14 + <string>Applications/BootNeuter.app/bin/bbupdater</string>
  15 + </dict>
  16 + <key>Baseband EEP</key>
  17 + <dict>
  18 + <key>File</key>
  19 + <string>usr/local/standalone/firmware/ICE04.05.04_G.eep</string>
  20 + <key>Path</key>
  21 + <string>Applications/BootNeuter.app/firmware/ICE04.05.04_G.eep</string>
  22 + </dict>
  23 + <key>Baseband FLS</key>
  24 + <dict>
  25 + <key>File</key>
  26 + <string>usr/local/standalone/firmware/ICE04.05.04_G.fls</string>
  27 + <key>Path</key>
  28 + <string>Applications/BootNeuter.app/firmware/ICE04.05.04_G.fls</string>
  29 + </dict>
  30 + <key>Bootloader 3.9</key>
  31 + <dict>
  32 + <key>Path</key>
  33 + <string>Applications/BootNeuter.app/firmware/bl39.bin</string>
  34 + </dict>
  35 + <key>Bootloader 4.6</key>
  36 + <dict>
  37 + <key>Path</key>
  38 + <string>Applications/BootNeuter.app/firmware/bl46.bin</string>
  39 + </dict>
  40 + </dict>
  41 + <key>FilesystemPatches</key>
  42 + <dict>
  43 + <key>Core Files Installation</key>
  44 + <array>
  45 + <dict>
  46 + <key>Action</key>
  47 + <string>ReplaceKernel</string>
  48 + <key>File</key>
  49 + <string>kernelcache.release.s5l8900x</string>
  50 + <key>Name</key>
  51 + <string>KernelCache</string>
  52 + <key>Path</key>
  53 + <string>System/Library/Caches/com.apple.kernelcaches/kernelcache.s5l8900x</string>
  54 + </dict>
  55 + </array>
  56 + <key>Filesystem Jailbreak</key>
  57 + <array>
  58 + <dict>
  59 + <key>Action</key>
  60 + <string>Patch</string>
  61 + <key>File</key>
  62 + <string>etc/fstab</string>
  63 + <key>Name</key>
  64 + <string>Filesystem Write Access</string>
  65 + <key>Patch</key>
  66 + <string>fstab.patch</string>
  67 + </dict>
  68 + <dict>
  69 + <key>Action</key>
  70 + <string>Patch</string>
  71 + <key>File</key>
  72 + <string>System/Library/Lockdown/Services.plist</string>
  73 + <key>Name</key>
  74 + <string>Apple File Connection v2</string>
  75 + <key>Patch</key>
  76 + <string>Services.patch</string>