51w ago - As a follow-up to his
PS3 SCETool v0.2.7 update, today PlayStation 3 homebrew developer
Naehrwert has released the source code for a Quick PS3 CoreOS Image Tool via Twitter.
Files included below are the util.h, util.cpp, types.h and main.cpp released under the GPLv2.
Download:
Quick PS3 CoreOS Image Tool Code /
Quick PS3 CoreOS Image Tool (Compiled) /
Quick PS3 CoreOS Image Tool Code (Mirror) /
GIT
To quote: quick coreos image tool - http://pastie.org/4003488
## util.h
/*
* Copyright (c) 2012 by naehrwert
* This file is released under the GPLv2.
*/
#ifndef _UTIL_H_
#define _UTIL_H_
#include <stdio.h>
#include "types.h"
/*! Utility functions. */
u8 *_read_buffer(const s8 *file, u32 *length);
int _write_buffer(const s8 *file, u8 *buffer, u32 length);
#endif
## util.cpp
/*
* Copyright (c) 2012 by naehrwert
* This file is released under the GPLv2.
*/
#include <stdio.h>
#include <stdlib.h>
#include "types.h"
#include "util.h"
u8 *_read_buffer(const s8 *file, u32 *length)
{
FILE *fp;
u32 size;
if((fp = fopen(file, "rb")) == NULL)
return NULL;
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
u8 *buffer = (u8 *)malloc(sizeof(u8) * size);
fread(buffer, sizeof(u8), size, fp);
if(length != NULL)
*length = size;
fclose(fp);
return buffer;
}
int _write_buffer(const s8 *file, u8 *buffer, u32 length)
{
FILE *fp;
if((fp = fopen(file, "wb")) == NULL)
return 0;
/*while(length > 0)
{
u32 wrlen = 1024;
if(length < 1024)
wrlen = length;
fwrite(buffer, sizeof(u8), wrlen, fp);
length -= wrlen;
buffer += 1024;
}*/
fwrite(buffer, sizeof(u8), length, fp);
fclose(fp);
return 1;
} ## types.h
/*
* Copyright (c) 2012 by naehrwert
* This file is released under the GPLv2.
*/
#ifndef _TYPES_H_
#define _TYPES_H_
typedef char s8;
typedef unsigned char u8;
typedef short s16;
typedef unsigned short u16;
typedef int s32;
typedef unsigned int u32;
#ifdef _WIN32
typedef __int64 s64;
typedef unsigned __int64 u64;
#else
typedef long long int s64;
typedef unsigned long long int u64;
#endif
#define BOOL int
#define TRUE 1
#define FALSE 0
//Align.
#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
//Endian swap for u16.
#define _ES16(val) \
((u16)(((((u16)val) & 0xff00) >> 8) | \
((((u16)val) & 0x00ff) << 8)))
//Endian swap for u32.
#define _ES32(val) \
((u32)(((((u32)val) & 0xff000000) >> 24) | \
((((u32)val) & 0x00ff0000) >> 8 ) | \
((((u32)val) & 0x0000ff00) << 8 ) | \
((((u32)val) & 0x000000ff) << 24)))
//Endian swap for u64.
#define _ES64(val) \
((u64)(((((u64)val) & 0xff00000000000000ull) >> 56) | \
((((u64)val) & 0x00ff000000000000ull) >> 40) | \
((((u64)val) & 0x0000ff0000000000ull) >> 24) | \
((((u64)val) & 0x000000ff00000000ull) >> 8 ) | \
((((u64)val) & 0x00000000ff000000ull) << 8 ) | \
((((u64)val) & 0x0000000000ff0000ull) << 24) | \
((((u64)val) & 0x000000000000ff00ull) << 40) | \
((((u64)val) & 0x00000000000000ffull) << 56)))
#endif
## main.cpp
/*
* Copyright (c) 2012 by naehrwert
* This file is released under the GPLv2.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "types.h"
#include "util.h"
/*! Header. */
typedef struct _cos_header
{
/*! Version maybe. */
u32 version;
/*! Entry count. */
u32 entcnt;
/*! Image size. */
u64 imgsize;
} cos_header_t;
static void _es_cos_header_t(cos_header_t *ch)
{
ch->version = _ES32(ch->version);
ch->entcnt = _ES32(ch->entcnt);
ch->imgsize = _ES64(ch->imgsize);
}
static void _print_cos_header_t(FILE *fp, cos_header_t *ch)
{
fprintf(fp, "CoreOS Header:\n");
fprintf(fp, " Version 0x%08X\n", ch->version);
fprintf(fp, " Entry Count 0x%08X\n", ch->entcnt);
fprintf(fp, " Image Size 0x%016llX\n", ch->imgsize);
}
/*! Entry. */
typedef struct _cos_entry
{
/*! Offset. */
u64 offset;
/*! Size. */
u64 size;
/*! Name (zero padded). */
s8 name[0x20];
} cos_entry_t;
static void _es_cos_entry_t(cos_entry_t *ce)
{
ce->offset = _ES64(ce->offset);
ce->size = _ES64(ce->size);
}
static void _print_cos_entry_t(FILE *fp, cos_entry_t *ce, u32 idx)
{
fprintf(fp, "CoreOS Entry %02d:\n", idx);
fprintf(fp, " Offset 0x%016llX\n", ce->offset);
fprintf(fp, " Size 0x%016llX\n", ce->size);
fprintf(fp, " Name %s\n", ce->name);
}
/*! Context. */
typedef struct _cos_ctxt
{
/*! Buffer. */
u8 *buffer;
/*! Buffer length. */
u32 length;
/*! Pointer to header. */
cos_header_t *header;
/*! Pointer to entries. */
cos_entry_t *entries;
} cos_ctxt_t;
cos_ctxt_t *cos_load(const s8 *file)
{
u32 i;
cos_ctxt_t *res;
if((res = (cos_ctxt_t *)malloc(sizeof(cos_ctxt_t))) == NULL)
return NULL;
if((res->buffer = _read_buffer(file, &res->length)) == NULL)
{
free(res);
return NULL;
}
//Fix header and entries.
res->header = (cos_header_t *)res->buffer;
res->entries = (cos_entry_t *)(res->buffer + sizeof(cos_header_t));
_es_cos_header_t(res->header);
for(i = 0; i < res->header->entcnt; i++)
_es_cos_entry_t(&res->entries[i]);
return res;
}
void cos_free(cos_ctxt_t *ctxt)
{
free(ctxt->buffer);
free(ctxt);
}
void cos_print(cos_ctxt_t *ctxt)
{
u32 i;
_print_cos_header_t(stdout, ctxt->header);
for(i = 0; i < ctxt->header->entcnt; i++)
_print_cos_entry_t(stdout, &ctxt->entries[i], i);
}
void cos_unpack(cos_ctxt_t *ctxt, const s8 *base_path)
{
s8 path[256];
u32 i;
for(i = 0; i < ctxt->header->entcnt; i++)
{
sprintf(path, "%s/%s", base_path, ctxt->entries[i].name);
_write_buffer(path, ctxt->buffer + ctxt->entries[i].offset, ctxt->entries[i].size);
}
}
void _print_usage()
{
printf("costool (c) 2012 by naehrwert\n");
printf("Usage: costool [option] image\n");
printf("Options:\n");
printf(" -i ... Print infos.\n");
printf(" -u ... Unpack.\n");
exit(1);
}
int main(int argc, char **argv)
{
cos_ctxt_t *ctxt;
if(argc < 3)
_print_usage();
if(strcmp(argv[1], "-i") == 0) //Print infos.
{
ctxt = cos_load(argv[2]);
cos_print(ctxt);
cos_free(ctxt);
}
else if(strcmp(argv[1], "-u") == 0) //Unpack.
{
ctxt = cos_load(argv[2]);
cos_unpack(ctxt, ".");
cos_free(ctxt);
}
else
{
printf("Unknown option.\n");
return 1;
}
return 0;
}
a 3.55 asbestos_ldr would be awesome!
Anyways, waiting for the port of asbestos_ldr to 3.55. Although it may be more difficult that it would seem, assuming it's not the simple mater of resigning eboot, but finding an appropriate LV2 patching zones IIRC.
Steps:
1- Turn off your PS3.
2- Remove the current internal HDD from your PS3 and replace it with a new HDD.
3- Turn on your PS3, it will start in Recovery Mode and will ask you to format the HDD and plug an USB drive/pen drive with a 3.55 PUP.
4- Go to your PC and copy the OtherOS++ 22GB PUP in the USB/pen drive as /PS3/UPDATE/PS3UPDAT.PUP
5- Plug the USB/pen drive and install the OtherOS++ PUP. Follow the instructions.
6- Once the PS3 finish the installation, it will restart with System Factory settings and it will ask for the date/time and network settings.
7- Follow deank's tutorial carefully (you can continue from step 4).
Once you get your dump_eid0.bin, you can re-install your original 3.55 CFW (eg. kmeaw or Rebug), then shut down your PS3, remove the HDD and put back your original HDD. Turn on your PS3 and all your data (games, videos, music, trophies, save data, users, activations, etc) will be there