MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / read_part_xbox

Function read_part_xbox

src/partxbox.c:156–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156static list_part_t *read_part_xbox(disk_t *disk_car, const int verbose, const int saveheader)
157{
158 unsigned char buffer[0x800];
159 list_part_t *new_list_part=NULL;
160 /*@ assert valid_list_part(new_list_part); */
161 screen_buffer_reset();
162 if(disk_car->pread(disk_car, &buffer, sizeof(buffer), 0) != sizeof(buffer))
163 return new_list_part;
164 {
165 uint64_t offsets[]={ 0x00080000, 0x2ee80000, 0x5dc80000, 0x8ca80000, 0xabe80000 };
166 unsigned int i;
167 struct xbox_partition *xboxlabel=(struct xbox_partition*)&buffer;
168 if (memcmp(xboxlabel->magic,"BRFR",4))
169 {
170 screen_buffer_add("\nBad XBOX partition, invalid signature\n");
171 return NULL;
172 }
173 /*@
174 @ loop invariant valid_list_part(new_list_part);
175 @*/
176 for(i=0;i<sizeof(offsets)/sizeof(uint64_t);i++)
177 {
178 if(offsets[i]<disk_car->disk_size)
179 {
180 int insert_error=0;
181 partition_t *partition=partition_new(&arch_xbox);
182 partition->part_type_xbox=PXBOX_FATX;
183 partition->part_offset=offsets[i];
184 partition->order=1+i;
185 if(i==sizeof(offsets)/sizeof(uint64_t)-1 || disk_car->disk_size<=offsets[i+1])
186 partition->part_size=disk_car->disk_size-offsets[i];
187 else
188 partition->part_size=offsets[i+1]-offsets[i];
189 partition->status=STATUS_PRIM;
190 check_part_xbox(disk_car,verbose,partition,saveheader);
191 aff_part_buffer(AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
192 new_list_part=insert_new_partition(new_list_part, partition, 0, &insert_error);
193 if(insert_error>0)
194 free(partition);
195 }
196 }
197 }
198 /*@ assert valid_list_part(new_list_part); */
199 return new_list_part;
200}
201
202static int write_part_xbox(disk_t *disk_car, const list_part_t *list_part, const int ro, const int verbose)
203{

Callers

nothing calls this directly

Calls 6

screen_buffer_resetFunction · 0.85
screen_buffer_addFunction · 0.85
partition_newFunction · 0.85
check_part_xboxFunction · 0.85
aff_part_bufferFunction · 0.85
insert_new_partitionFunction · 0.85

Tested by

no test coverage detected