• Home
  • Downloads
  • EBOOT Fixes
  • Forums
  • New Posts
  • Register
    • Welcome, Register Now! 
    • Premium VIP Membership
    • PS3 Sticky
      • PS3 CFW & MFW
      • PS3 Debug Firmware
      • PS3 Decrypted PSN Links for CFW
      • PS3 Downloads
      • PS3 EBOOT.BIN Original File Links
      • PS3 Firmware
      • PS3 Game Releases List
      • PS3 Guides & Tutorials
      • PS3 Hacking Guides and Tutorials
      • PS3 Hacks & JailBreak
      • PS3 Help & Support
      • PS3 JailBreak Game Compatibility List
      • PS3 JB2 / True Blue (TB) Game Links
      • PS3 multiMAN Updates
      • PS3 Resources
      • PS3 Reviews
      • PS3 Save Files Repository
      • PS3 Themes
      • PS3 Trophies List
      • PS3 Videos
      • PS Vita Trophies List
    • Quick Links
      • Affiliates
      • Contact Us
      • FAQ
      • Post News
      • Site Rules
      • Tag Cloud
 

Quick PS3 CoreOS Image Tool Code Released by Naehrwert

Category: PS3 Hacks & JailBreak  By: PS3 News - (twitter.com)
Tags: quick ps3 coreos image tool ps3 code ps3 coding naehrwert ps3 ps3 hackers ps3 hacks

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;
}




Stay tuned for more PS3 Hacks and PS3 CFW news, follow us on Twitter and be sure to drop by the PS3 Hacks and PS3 Custom Firmware Forums for the latest PlayStation 3 scene updates and homebrew releases!

Comments 14 Comments - Go to Forum Thread »

Errors

The following errors occurred with your submission

Okay

Quick Reply Quick Reply

  • Decrease Size
    Increase Size
  • Wrap [QUOTE] tags around selected text
Posting Quick Reply - Please Wait Posting Quick Reply - Please Wait
Luckystar's Avatar
#14 - Luckystar - 43w ago
Reply
yes... my ps3 has 3.50 as min firmware install

Brenza's Avatar
#13 - Brenza - 43w ago
Reply
i know qa downgrade won't lose data but my ps3 has 3.50 as min firmware install

a 3.55 asbestos_ldr would be awesome!

niwakun's Avatar
#12 - niwakun - 43w ago
Reply
the only main thing you need on linux is your PCK an IV keys. you can just go over downgrade your console to 3.41 and use naehwert's key dumping tool. Downgrading won't lose your data, as long as it's QA downgrade. And yes, I dont even see the difference installing a OtherOS CFW and a 3.41 Hermes CFW anyway.

Tidusnake666's Avatar
#11 - Tidusnake666 - 43w ago
Reply
Yeah, it's obvious, I thought of that, but do not have a spare 2.5" HDD. It's not the problem of wiping games, it's the problem of trophies, do not want run through their backup process once more.

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.

aldostools's Avatar
#10 - aldostools - 43w ago
Reply
Tidusnake666 if you have a 2nd HDD that fit internally in the PS3 (eg. your old PS3 HDD if you upgraded it), then you don't need to wipe all your data.

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

Page 1 of 3 123›LAST »

Related PS3 News and PS3 CFW Hacks or JailBreak Articles

• Guide to Install multiMAN PS3 Themes via USB from a PKG File
• Simple PS3Updates v1.6 Build 2 Final PS3 Homebrew App Updated
• Video: Super Pixel Jumper v1.2 PS3 Homebrew Game is Released
• Video: Pointman: The Akkadian Wars PS3 Homebrew Game Arrives
• PSPMinis / PS3Minis / Bite v1.5.1 Update for PS3 is Now Released
• PS3 Fan Control Utility v1.7 for PS3 CFW CEX 3.41 to 4.41 Arrives
Affiliates  NewsNow  Privacy  PS3 CFW & MFW  PS3 Hacks & JailBreak  PS3 Reviews  PS3 Videos  © 2013 PlayStation 3 News

PlayStation 3 Links

• Contact Us E-Mail
• PS3 Affiliates
• PS3 CFW & MFW
• PS3 Debug Firmware
• PS3 Decrypted PSN Links for CFW
• PS3 Downloads
• PS3 EBOOT.BIN Original File Links
• PS3 Firmware
• PS3 Game Releases List
• PS3 Guides & Tutorials
• PS3 Hacking Guides and Tutorials
• PS3 Hacks & JailBreak
• PS3 Help & Support
• PS3 JailBreak Game Compatibility List
• PS3 JB2 / True Blue (TB) Game Links
• PS3 multiMAN Updates
• PS3 News Forums
• PS3 News Site FAQ
• PS3 News Site Advertising FAQ
• PS3 News Site Posting FAQ
• PS3 News Site Privacy FAQ
• PS3 News Site Rules
• PS3 News Site Tag Cloud
• PS3 News Site Terms
• PS3 Resources
• PS3 Reviews
• PS3 Save Files Repository
• PS3 Themes
• PS3 Trophies List
• PS3 Videos
• PS Vita Trophies List

PlayStation 3 News Discussions
Latest and best CFW? - 25m ago

Liongooder's Avatar
Quote Hello everybody Rogero 4.40 is a good CFW to deal with,just spoof it to 4.41 to play online at your own risk. Rebug 4.41.2 if you wanna mess with trop...
By Liongooder with
 3 Comments »
Introductions: Hello Everyone, I'm New at PS3News.com! - 28m ago

kalius's Avatar
Quote I have much to thank everyone that has helped me. Thumbs up!...
By kalius with
 7045 Comments »
PS3 Slim 4.41 which custom firmware is best help? - 30m ago

Liongooder's Avatar
Quote First you need to check if its downgradable or not,how? check the model number if its CECH25XX or lower then you can downgrade it,if its CECH3000 or ...
By Liongooder with
 1 Comment »
Introductions: Hello Everyone, I'm New at PS3News.com! - 3h ago

agsr4ever's Avatar
Quote Hello Everyone, first time posting! been here for a while never posted till today Been here a while, first time posting. Everyone is very helpful....
By agsr4ever with
 7045 Comments »

Latest PlayStation 3 Trophies
Move Street Cricket II: Ace of all trades
Move Street Cricket II: Veteran
Move Street Cricket II: 5 Star
Move Street Cricket II: Velcro Hands

Latest PlayStation Vita Trophies
Men's Room Mayhem: Toilet Trouble
Men's Room Mayhem: Mayhem Master
Men's Room Mayhem: Hygiene Award
Men's Room Mayhem: Sand in the Face

Latest PlayStation 3 Releases
Kamen Rider Battride War Premium TV Sound Edition JPN PS3-HR - 05-24-2013
Tom Clancys H A W X EUR PS3-Googlecus - 05-23-2013
Terraria JPN PS3-HR - 05-23-2013
Kamen Rider Battlide War JPN PS3-Caravan - 05-21-2013

Latest PlayStation 3 Themes
Wolverine Origins PS3 Theme - 05-19-2013
Heavy Rain (Official) Dynamic PS3 Theme - 05-09-2013
Wipeout HD Fury Dynamic PS3 Theme - 05-06-2013
Batman Arkham City Dynamic PS3 Theme - 05-04-2013
  • Contact Us
  • -
  • PS3 News