亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? hdl_dump.cpp

?? PS2游戲硬盤直灌(HDL)的Windows下VC的源代碼
?? CPP
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
/*
 * hdl_dump.c
 * $Id: hdl_dump.c,v 1.14 2005/02/17 17:50:25 b081 Exp $
 *
 * Copyright 2004 Bobi B., w1zard0f07@yahoo.com
 *
 * This file is part of hdl_dump.
 *
 * hdl_dump is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * hdl_dump is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with hdl_dump; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#if defined (_BUILD_WIN32)
#  include <windows.h>
#  include <stdlib.h>
#  include <stdio.h>
#  include <conio.h>
#endif
#include <assert.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include "byteseq.h"
#include "retcodes.h"
#include "osal.h"
#include "apa.h"
#include "common.h"
#include "progress.h"
#include "hdl.h"
#include "isofs.h"
#include "iin.h"
#include "aligned.h"
#include "hio_probe.h"
#include "net_io.h"
#if defined (_WITH_ASPI)
#  include "aspi_hlio.h"
#endif

#define INCLUDE_DUMP_CMD
#define INCLUDE_COMPARE_CMD
#define INCLUDE_COMPARE_IIN_CMD
#define INCLUDE_MAP_CMD
#define INCLUDE_ZERO_CMD
#define INCLUDE_CUTOUT_CMD
#define INCLUDE_INFO_CMD
#define INCLUDE_READ_TEST_CMD

/* command names */
#define CMD_QUERY "query"
#if defined (INCLUDE_DUMP_CMD)
#  define CMD_DUMP "dump"
#endif
#if defined (INCLUDE_COMPARE_CMD)
#  define CMD_COMPARE "compare"
#endif
#if defined (INCLUDE_COMPARE_IIN_CMD)
#  define CMD_COMPARE_IIN "compare_iin"
#endif
#define CMD_TOC "toc"
#define CMD_HDL_TOC "hdl_toc"
#if defined (INCLUDE_MAP_CMD)
#  define CMD_MAP "map"
#endif
#define CMD_DELETE "delete"
#if defined (INCLUDE_ZERO_CMD)
#  define CMD_ZERO "zero"
#endif
#if defined (INCLUDE_CUTOUT_CMD)
#  define CMD_CUTOUT "cutout"
#endif
#if defined (INCLUDE_INFO_CMD)
#  define CMD_HDL_INFO "info"
#endif
#define CMD_HDL_EXTRACT "extract"
#define CMD_HDL_INJECT_CD "inject_cd"
#define CMD_HDL_INJECT_DVD "inject_dvd"
#define CMD_CDVD_INFO "cdvd_info"
#if defined (INCLUDE_READ_TEST_CMD)
#  define CMD_READ_TEST "read_test"
#endif
#define CMD_POWER_OFF "poweroff"
#if defined (INCLUDE_CHECK_CMD)
#  define CMD_CHECK "check"
#endif


/**************************************************************/
static void
show_apa_toc (const apa_partition_table_t *table)
{
  u_int32_t i;

  for (i=0; i<table->part_count; ++i)
    {
      const ps2_partition_header_t *part = &table->parts [i].header;
	  
      fprintf (stdout, "%06lx00%c%c %5luMB ",
	       (unsigned long) (get_u32 (&part->start) >> 8),
	       table->parts [i].existing ? '.' : '*',
	       table->parts [i].modified ? '*' : ':',
	       (unsigned long) (get_u32 (&part->length) / 2048));
      if (get_u32 (&part->main) == 0)
	fprintf (stdout, "%4x [%-*s]\n",
		 get_u16 (&part->type), PS2_PART_IDMAX, part->id);
      else
	fprintf (stdout, "      part # %2lu in %06lx00\n",
		 (unsigned long) (get_u32 (&part->number)),
		 (unsigned long) (get_u32 (&part->main) >> 8));
    }

  fprintf (stdout, "Total device size: %uMB, used: %uMB, available: %uMB\n",
	   (unsigned int) table->device_size_in_mb,
	   (unsigned int) (table->allocated_chunks * 128),
	   (unsigned int) (table->free_chunks * 128));
}


/**************************************************************/
#if defined (INCLUDE_MAP_CMD)
static void
show_apa_map (const apa_partition_table_t *table)
{
  /* show device map */
  const char *map = table->chunks_map;
  const u_int32_t GIGS_PER_ROW = 8;
  u_int32_t i, count = 0;

  for (i=0; i<table->total_chunks; ++i)
    {
      if (count == 0)
	fprintf (stdout, "%3uGB: ",
		 (unsigned int) ((i / ((GIGS_PER_ROW * 1024) / 128)) *
				 GIGS_PER_ROW));

      fputc (map [i], stdout);
      if ((count & 0x07) == 0x07)
	fputc (' ', stdout);

      if (++count == ((GIGS_PER_ROW * 1024) / 128)) /* 8G on each row */
	{
	  fputc ('\n', stdout);
	  count = 0;
	}
    }

  fprintf (stdout, "\nTotal device size: %uMB, used: %uMB, available: %uMB\n",
	   (unsigned int) table->device_size_in_mb,
	   (unsigned int) (table->allocated_chunks * 128),
	   (unsigned int) (table->free_chunks * 128));
}
#endif /* INCLUDE_MAP_CMD defined? */


/**************************************************************/
static int
show_toc (const char *device_name)
{
  apa_partition_table_t *table;
  int result = apa_ptable_read (device_name, &table);
  if (result == RET_OK)
    {
      show_apa_toc (table);
      apa_ptable_free (table);
    }
  return (result);
}


/**************************************************************/
static int
show_hdl_toc (const char *device_name)
{
  hio_t *hio;
  int result = hio_probe (device_name, &hio);
  if (result == RET_OK)
    {
      hdl_games_list_t *glist;
      result = hdl_glist_read (hio, &glist);
      if (result == RET_OK)
	{
	  u_int32_t i;
	  printf ("%-4s%9s %-5s %-12s %s\n",
		  "type", "size", "flags", "startup", "name");
	  for (i=0; i<glist->count; ++i)
	    {
	      const hdl_game_info_t *game = glist->games + i;
	      char compat_flags [6 + 1] = { "\0\0\0\0\0\0" };
	      if (game->compat_flags & 0x01)
		strcat (compat_flags, "+1");
	      if (game->compat_flags & 0x02)
		strcat (compat_flags, "+2");
	      if (game->compat_flags & 0x04)
		strcat (compat_flags, "+3");
	      printf ("%3s %7luKB %5s %-12s %s\n",
		      game->is_dvd ? "DVD" : "CD ",
		      game->total_size_in_kb,
		      compat_flags + 1, /* trim leading + */
		      game->startup,
		      game->name);
	    }
	  printf ("total %uMB, used %uMB, available %uMB\n",
		  (unsigned int) (glist->total_chunks * 128),
		  (unsigned int) ((glist->total_chunks -
				   glist->free_chunks) * 128),
		  (unsigned int) (glist->free_chunks * 128));
	  hdl_glist_free (glist);
	}
      hio->close (hio);
    }
  return (result);
}

/**************************************************************/
#if defined (INCLUDE_MAP_CMD)
static int
show_map (const char *device_name)
{
  apa_partition_table_t *table;
  int result = apa_ptable_read (device_name, &table);
  if (result == RET_OK)
    {
      show_apa_map (table);
      apa_ptable_free (table);
    }
  return (result);
}
#endif /* INCLUDE_MAP_CMD defined? */


/**************************************************************/
#if defined (INCLUDE_INFO_CMD)
static int
show_hdl_game_info (const char *device_name,
		    const char *game_name)
{
  hio_t *hio;
  int result = hio_probe (device_name, &hio);
  if (result == RET_OK)
    {
      apa_partition_table_t *table;
      result = apa_ptable_read_ex (hio, &table);
      if (result == RET_OK)
	{
	  u_int32_t partition_index;
	  result = apa_find_partition (table, game_name, &partition_index);
	  if (result == RET_NOT_FOUND)
	    { /* use heuristics - look among the HD Loader partitions */
	      char tmp [100];
	      strcpy (tmp, "PP.HDL.");
	      strcat (tmp, game_name);
	      result = apa_find_partition (table, tmp, &partition_index);
	    }

	  if (result == RET_OK)
	    { /* partition found */
	      const u_int32_t PART_SYSDATA_SIZE = 4 * 1024 * 1024;
	      unsigned char *buffer = (unsigned char *)osal_alloc (PART_SYSDATA_SIZE);
	      if (buffer != NULL)
		{
		  u_int32_t len;
		  result = hio->read (hio,
				      get_u32 (&table->parts [partition_index].header.start),
				      (4 _MB) / HDD_SECTOR_SIZE, buffer, &len);
		  if (result == OSAL_OK)
		    {
		      const char *signature = (char*) buffer + 0x001010ac;
		      const char *hdl_name = (char*) buffer + 0x00101008;
		      u_int32_t type = buffer [0x001010ec];
		      u_int32_t num_parts = buffer [0x001010f0];
		      const u_int32_t *data = (u_int32_t*) (buffer + 0x001010f5);
		      u_int32_t i;

		      if (buffer [0x00101000] == 0xed &&
			  buffer [0x00101001] == 0xfe &&
			  buffer [0x00101002] == 0xad &&
			  buffer [0x00101003] == 0xde)
			{ /* 0xdeadfeed magic found */
			  u_int64_t total_size = 0;

#if 0
			  /* save main partition incomplete header or debug purposes */
			  write_file (signature, buffer, 0x00101200);
#endif

			  fprintf (stdout, "%s: [%s], %s\n",
				   signature, hdl_name, (type == 0x14 ? "DVD" : "CD"));
			  if (buffer [0x1010a8] != 0)
			    {
			      char compat_flags [6 + 1] = { "" };
			      if (buffer [0x1010a8] & 0x01)
				strcat (compat_flags, "+1");
			      if (buffer [0x1010a8] & 0x02)
				strcat (compat_flags, "+2");
			      if (buffer [0x1010a8] & 0x04)
				strcat (compat_flags, "+3");
			      fprintf (stdout, "compatibility flags: %s\n",
				       compat_flags + 1);
			    }
			  for (i=0; i<num_parts; ++i)
			    {
			      unsigned long start = get_u32 (data + (i * 3 + 1));
			      unsigned long length = get_u32 (data + (i * 3 + 2));
			      total_size += ((u_int64_t) length) << 8;
			      fprintf (stdout,
				       "\tpart %2u is from sector 0x%06lx00, "
				       "%7luKB long\n",
				       (unsigned int) (i + 1),
				       start, length / 4);
			    }
			  fprintf (stdout,
				   "Total size: %luKB (%luMB approx.)\n",
				   (unsigned long) (total_size / 1024),
				   (unsigned long) (total_size / (1024 * 1024)));
			}
		      else
			result = RET_NOT_HDL_PART;
		    }
		  osal_free (buffer);
		}
	      else
		result = RET_NO_MEM;
	    }
	  apa_ptable_free (table);
	}
      hio->close (hio);
    }
  return (result);
}
#endif /* INCLUDE_INFO_CMD defined? */


/**************************************************************/
#if defined (INCLUDE_CUTOUT_CMD)
static int
show_apa_cut_out_for_inject (const char *device_name,
			     u_int32_t size_in_mb)
{
  apa_partition_table_t *table;
  int result = apa_ptable_read (device_name, &table);
  if (result == RET_OK)
    {
      u_int32_t new_partition_index;
      result = apa_allocate_space (table,
				   "<new partition>",
				   size_in_mb,
				   &new_partition_index,
				   0);
      if (result == RET_OK)
	{
	  show_apa_toc (table);
	  show_apa_map (table);
	}

      apa_ptable_free (table);
    }
  return (result);
}
#endif /* INCLUDE_CUTOUT_CMD defined? */


/**************************************************************/
static int
delete_partition (const char *device_name,
		  const char *name)
{
  apa_partition_table_t *table;
  int result = apa_ptable_read (device_name, &table);
  if (result == RET_OK)
    {
      result = apa_delete_partition (table, name);

      if (result == RET_OK)
	result = apa_commit (device_name, table);

      apa_ptable_free (table);
    }
  return (result);
}


/**************************************************************/
#if defined (INCLUDE_COMPARE_CMD)
static int
compare (const char *file_name_1,
	 int file_name_1_is_device,
	 const char *file_name_2,
	 int file_name_2_is_device)
{
  osal_handle_t file1 = OSAL_HANDLE_INIT, file2 = OSAL_HANDLE_INIT;
  int different = 0;
  int result = osal_open (file_name_1, &file1, 1);
  if (result == OSAL_OK)
    {
      result = osal_open (file_name_2, &file2, 1);
      if (result == OSAL_OK)
	{
	  const u_int32_t BUFF_SIZE = 4 * 1024 * 1024;
	  char *buffer = (char *)osal_alloc (BUFF_SIZE);
	  if (buffer != NULL)
	    {
	      u_int32_t read1 = 0, read2 = 0;
	      do
		{
		  result = osal_read (file1, buffer + 0 * BUFF_SIZE / 2,
				      BUFF_SIZE / 2, &read1);
		  if (result == OSAL_OK)
		    {
		      result = osal_read (file2, buffer + 1 * BUFF_SIZE / 2,
					  BUFF_SIZE / 2, &read2);
		      if (result == OSAL_OK)
			{
			  different = read1 != read2;
			  if (!different)
			    {
			      u_int32_t i;
			      const char *p1 = buffer + 0 * BUFF_SIZE / 2;
			      const char *p2 = buffer + 1 * BUFF_SIZE / 2;
			      for (i=0; !different && i<read1; ++i)
				different = *p1++ != *p2++;
			    }
			}
		    }
		}
	      while (result == OSAL_OK && read1 > 0 && read2 > 0 && !different);
	    }
	  else
	    result = RET_NO_MEM;
	  osal_close (file2);
	}
      osal_close (file1);
    }
  return (result == RET_OK ? (!different ? RET_OK : RET_DIFFERENT) : result);
}
#endif /* INCLUDE_COMPARE_CMD defined? */


/**************************************************************/
#if defined (INCLUDE_ZERO_CMD)
static int
zero_device (const char *device_name)
{
  osal_handle_t device;
  int result = osal_open_device_for_writing (device_name, &device);
  if (result == OSAL_OK)
    {
      void *buffer = osal_alloc (1 _MB);
      if (buffer != NULL)
	{
	  u_int32_t bytes;
	  memset (buffer, 0, 1 _MB);
	  do
	    {
	      result = osal_write (device, buffer, 1 _MB, &bytes);
	    }
	  while (result == OSAL_OK && bytes > 0);
	}
      else
	result = RET_NO_MEM;
      osal_close (device);
    }
  return (result);
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
另类小说欧美激情| 91在线观看一区二区| 欧美激情在线看| 欧美日韩精品一区二区三区| 国产一区日韩二区欧美三区| 亚洲一区二区三区视频在线播放| 精品福利av导航| 欧美日韩国产高清一区二区| 国产91精品入口| 另类人妖一区二区av| 亚洲国产精品一区二区www | 久久久国产综合精品女国产盗摄| 色88888久久久久久影院按摩| 国产一二精品视频| 麻豆成人av在线| 亚洲r级在线视频| 亚洲欧美激情插 | 亚洲一级二级三级在线免费观看| 欧美国产激情一区二区三区蜜月| 欧美电影影音先锋| 欧美性色欧美a在线播放| 99在线精品视频| 成人av在线网站| 成人免费高清在线观看| 国产精品一线二线三线| 精品一区二区av| 久草精品在线观看| 久久99热这里只有精品| 视频在线在亚洲| 亚洲一区二区三区四区五区中文 | 欧美蜜桃一区二区三区| 一本色道久久综合精品竹菊| 不卡电影一区二区三区| 99视频一区二区| 91色九色蝌蚪| 91蜜桃网址入口| 91黄色免费观看| 欧美色图12p| 欧美女孩性生活视频| 8v天堂国产在线一区二区| 欧美年轻男男videosbes| 91.com视频| 精品日韩欧美在线| 国产女人18毛片水真多成人如厕| 国产日韩欧美精品在线| 国产精品丝袜91| 亚洲免费三区一区二区| 亚洲一区在线观看网站| 日本在线不卡一区| 精品午夜久久福利影院| 国产成人精品午夜视频免费| 成人性色生活片| 在线观看不卡视频| 91精品一区二区三区久久久久久 | 亚洲午夜精品在线| 日本成人在线不卡视频| 国产在线精品免费av| 粗大黑人巨茎大战欧美成人| 91免费看`日韩一区二区| 91福利在线播放| 欧美一区二区日韩一区二区| 久久在线观看免费| 国产精品久久三区| 亚洲线精品一区二区三区八戒| 日本美女一区二区三区视频| 韩国女主播成人在线| gogo大胆日本视频一区| 777欧美精品| 国产日韩欧美综合在线| 亚洲一卡二卡三卡四卡无卡久久| 免费的国产精品| av高清久久久| 欧美一区二区三区喷汁尤物| 国产视频911| 一区二区免费看| 久久99精品久久久久久久久久久久| 国产91丝袜在线18| 欧美日韩aaa| 国产欧美精品一区二区三区四区| 亚洲综合一二三区| 国产一区高清在线| 91黄色免费版| 国产亚洲精品资源在线26u| 亚洲尤物在线视频观看| 激情文学综合丁香| 欧美伊人久久大香线蕉综合69| 欧美哺乳videos| 一区二区久久久| 国产成人免费视频一区| 91麻豆精品国产自产在线观看一区| 精品av久久707| 亚洲风情在线资源站| 成人午夜视频免费看| 日韩三级.com| 一区二区国产视频| www.成人网.com| 久久久久久97三级| 日本vs亚洲vs韩国一区三区二区 | 五月激情六月综合| 成人污污视频在线观看| 日韩欧美国产麻豆| 一区二区三区.www| 成人免费va视频| 欧美mv日韩mv国产| 日韩中文字幕一区二区三区| 91在线观看污| 中文字幕精品一区| 国产又黄又大久久| 欧美一级片在线看| 亚洲国产乱码最新视频 | 男女男精品网站| 色哟哟在线观看一区二区三区| 久久青草欧美一区二区三区| 蜜臀91精品一区二区三区| 在线观看日韩av先锋影音电影院| 日本一区二区三区高清不卡 | 成人激情文学综合网| 欧美不卡一区二区三区| 欧美aaa在线| 欧美美女视频在线观看| 亚洲激情六月丁香| 色哦色哦哦色天天综合| 日韩一区在线看| eeuss影院一区二区三区| 国产亚洲欧洲997久久综合| 狠狠色狠狠色合久久伊人| 日韩精品一区二区三区老鸭窝| 奇米精品一区二区三区四区| 91麻豆精品国产91久久久久久久久| 一区二区免费在线| 欧美午夜精品理论片a级按摩| 日韩毛片一二三区| 色噜噜狠狠色综合中国| 亚洲精品欧美激情| 在线欧美日韩精品| 亚洲午夜激情网站| 欧美精品久久久久久久多人混战 | 一本一道综合狠狠老| 亚洲人成网站在线| 色呦呦日韩精品| 亚洲国产成人va在线观看天堂| 欧美午夜精品一区二区三区| 性欧美大战久久久久久久久| 精品视频在线免费| 五月天丁香久久| 精品国产一区二区三区av性色| 日韩国产欧美三级| 欧美精品一区二区三区蜜桃视频| 国产麻豆午夜三级精品| 国产精品传媒在线| 在线视频观看一区| 热久久一区二区| 久久久一区二区| 99在线视频精品| 三级欧美韩日大片在线看| 日韩三级视频在线看| 粉嫩av一区二区三区在线播放| 国产精品美女久久久久高潮| 97久久精品人人澡人人爽| 午夜精品123| 亚洲精品一区二区在线观看| 成人一区二区视频| 亚洲午夜国产一区99re久久| 精品日韩在线一区| av日韩在线网站| 丝袜亚洲精品中文字幕一区| 亚洲精品一区二区三区四区高清| 99久久精品费精品国产一区二区| 亚洲国产乱码最新视频| 国产日韩亚洲欧美综合| 欧美日韩综合在线免费观看| 狠狠色丁香婷综合久久| 一区二区三区在线观看视频| 欧美一区二区三区播放老司机| 岛国精品在线观看| 亚洲成人动漫在线观看| 欧美国产精品专区| 欧美精品高清视频| 成人高清av在线| 日本成人超碰在线观看| 亚洲日本免费电影| 精品欧美一区二区三区精品久久| aaa国产一区| 寂寞少妇一区二区三区| 亚洲精品高清在线观看| 国产视频911| 日韩一级二级三级| 91黄视频在线观看| 国产乱码精品一区二区三区av | 国产精品亚洲一区二区三区妖精| 一区二区三区精品久久久| 在线免费亚洲电影| 国产女人aaa级久久久级 | 国产一区二三区好的| 亚洲色图第一区| 精品国产污网站| 欧美日韩一级片在线观看| 成人美女在线观看| 国产精品一区二区视频| 日韩av午夜在线观看|