├── .clang-format ├── .editorconfig ├── .gitattributes ├── .github └── workflows │ ├── clang-format.yml │ └── compilation.yml ├── .gitignore ├── AUTHORS ├── CHANGELOG ├── COPYING ├── Makefile ├── README.md ├── aligned.c ├── aligned.h ├── apa.c ├── apa.h ├── aspi_hlio.c ├── aspi_hlio.h ├── byteseq.c ├── byteseq.h ├── common.c ├── common.h ├── config.h ├── dict.c ├── dict.h ├── execli ├── Makefile ├── execli.c ├── execli.def └── vb_test │ ├── execli_test.vbp │ └── startup.bas ├── gui ├── Makefile ├── gui_main.c ├── hdl_dump.conf ├── rsrc.h ├── rsrc.rc ├── rsrc │ ├── app.ico │ ├── folder-16x16.ico │ ├── gears-16x16.ico │ ├── manifest.bin │ ├── ps2_cd.bmp │ ├── ps2_cd.ico │ ├── ps2_dvd.bmp │ ├── ps2_dvd.ico │ ├── ps2_dvd9.bmp │ └── ps2_dvd9.ico └── wgdb ├── hdl.c ├── hdl.h ├── hdl_dump.c ├── hio.h ├── hio_dbg.c ├── hio_dbg.h ├── hio_probe.c ├── hio_trace.c ├── hio_trace.h ├── hio_udpnet.c ├── hio_udpnet.h ├── hio_udpnet2.c ├── hio_udpnet2.h ├── hio_win32.c ├── hio_win32.h ├── icon.h ├── iin.h ├── iin_aspi.c ├── iin_aspi.h ├── iin_cdrwin.c ├── iin_cdrwin.h ├── iin_gi.c ├── iin_gi.h ├── iin_hio.c ├── iin_hio.h ├── iin_img_base.c ├── iin_img_base.h ├── iin_iml.c ├── iin_iml.h ├── iin_iso.c ├── iin_iso.h ├── iin_nero.c ├── iin_nero.h ├── iin_optical.c ├── iin_optical.h ├── iin_probe.c ├── iin_spti.c ├── iin_spti.h ├── isofs.c ├── isofs.h ├── kelf.h ├── list.ico ├── mkrel.sh ├── mkrel_win.sh ├── mktestimg.sh ├── net_common.c ├── net_common.h ├── net_io.h ├── ntddscsi.h ├── osal.h ├── osal_unix.c ├── osal_win32.c ├── progress.c ├── progress.h ├── ps2_hdd.h ├── retcodes.h ├── rsrc.rc ├── scsidefs.h ├── sema.h ├── svr ├── Makefile ├── ipconfig.c ├── ipconfig.h ├── main.c ├── main.h └── pktdrv │ ├── Makefile │ ├── Rules.make │ ├── arp.c │ ├── arp.h │ ├── eth.c │ ├── eth.h │ ├── icmp.c │ ├── icmp.h │ ├── imports.lst │ ├── ip.c │ ├── ip.h │ ├── ipconfig.c │ ├── ipconfig.h │ ├── irx_imports.h │ ├── main.c │ ├── nettypes.h │ ├── nic.c │ ├── nic.h │ ├── svr.c │ ├── svr.h │ ├── udp.c │ └── udp.h ├── thd_iin.c ├── thd_iin.h └── wnaspi32.h /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | AccessModifierOffset: -4 4 | AlignAfterOpenBracket: Align 5 | AlignConsecutiveAssignments: false 6 | AlignConsecutiveBitFields: AcrossEmptyLinesAndComments 7 | AlignConsecutiveDeclarations: false 8 | AlignConsecutiveMacros: AcrossComments 9 | AlignEscapedNewlines: Left 10 | AlignOperands: Align 11 | AlignTrailingComments: true 12 | AllowAllArgumentsOnNextLine: false 13 | AllowAllConstructorInitializersOnNextLine: true 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AllowShortBlocksOnASingleLine: Empty 16 | AllowShortCaseLabelsOnASingleLine: false 17 | AllowShortEnumsOnASingleLine: true 18 | AllowShortFunctionsOnASingleLine: All 19 | AllowShortIfStatementsOnASingleLine: Never 20 | AllowShortLambdasOnASingleLine: Empty 21 | AllowShortLoopsOnASingleLine: false 22 | AlwaysBreakAfterReturnType: None 23 | AlwaysBreakBeforeMultilineStrings: false 24 | AlwaysBreakTemplateDeclarations: true 25 | BinPackArguments: true 26 | BinPackParameters: true 27 | BitFieldColonSpacing : Both 28 | BreakBeforeBraces: Custom 29 | BraceWrapping: 30 | AfterCaseLabel: false 31 | AfterClass: true 32 | AfterControlStatement: false 33 | AfterEnum: false 34 | AfterFunction: true 35 | AfterNamespace: true 36 | AfterObjCDeclaration: false 37 | AfterStruct: true 38 | AfterUnion: true 39 | AfterExternBlock: false 40 | BeforeCatch: false 41 | BeforeElse: false 42 | BeforeLambdaBody: false 43 | BeforeWhile: false 44 | IndentBraces: false 45 | SplitEmptyFunction: true 46 | SplitEmptyRecord: true 47 | SplitEmptyNamespace: true 48 | BreakBeforeBinaryOperators: None 49 | BreakBeforeConceptDeclarations: true 50 | BreakBeforeTernaryOperators: false 51 | BreakConstructorInitializers: BeforeComma 52 | BreakStringLiterals: true 53 | ColumnLimit: 0 54 | CommentPragmas: '^ (IWYU pragma:|NOLINT)' 55 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 56 | ConstructorInitializerIndentWidth: 4 57 | ContinuationIndentWidth: 4 58 | Cpp11BracedListStyle: true 59 | DeriveLineEnding: true 60 | DerivePointerAlignment: false 61 | DisableFormat: false 62 | EmptyLineBeforeAccessModifier: LogicalBlock 63 | FixNamespaceComments: true 64 | ForEachMacros: [] 65 | IncludeBlocks: Preserve 66 | IndentExternBlock: NoIndent 67 | IndentCaseBlocks: false 68 | IndentCaseLabels: true 69 | IndentGotoLabels: true 70 | IndentWidth: 4 71 | IndentWrappedFunctionNames: false 72 | KeepEmptyLinesAtTheStartOfBlocks: true 73 | MacroBlockBegin: '' 74 | MacroBlockEnd: '' 75 | MaxEmptyLinesToKeep: 3 76 | NamespaceIndentation: None 77 | ObjCBlockIndentWidth: 2 78 | ObjCSpaceAfterProperty: false 79 | ObjCSpaceBeforeProtocolList: true 80 | PenaltyBreakAssignment: 80 81 | PenaltyBreakBeforeFirstCallParameter: 19 82 | PenaltyBreakComment: 300 83 | PenaltyBreakFirstLessLess: 120 84 | PenaltyBreakString: 1000 85 | PenaltyBreakTemplateDeclaration: 80 86 | PenaltyExcessCharacter: 1000000 87 | PenaltyIndentedWhitespace: 80 88 | PenaltyReturnTypeOnItsOwnLine: 60 89 | PointerAlignment: Right 90 | # uncomment below when clang >13 will be out 91 | # IndentPPDirectives: AfterHash 92 | # PPIndentWidth: 1 93 | ReflowComments: true 94 | SortIncludes: false 95 | SpaceAfterCStyleCast: false 96 | SpaceAfterLogicalNot: false 97 | SpaceAroundPointerQualifiers: Default 98 | SpaceBeforeAssignmentOperators: true 99 | SpaceBeforeCaseColon: false 100 | SpaceBeforeCpp11BracedList: true 101 | SpaceBeforeInheritanceColon: false 102 | SpaceBeforeParens: ControlStatements 103 | SpaceBeforeRangeBasedForLoopColon: true 104 | SpaceBeforeSquareBrackets: false 105 | SpaceInEmptyBlock: false 106 | SpaceInEmptyParentheses: false 107 | SpacesBeforeTrailingComments: 1 108 | SpacesInAngles: false 109 | SpacesInConditionalStatement: false 110 | SpacesInContainerLiterals: true 111 | SpacesInCStyleCastParentheses: false 112 | SpacesInParentheses: false 113 | SpacesInSquareBrackets: false 114 | Standard: Cpp11 115 | TabWidth: 4 116 | UseTab: Never 117 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig: http://EditorConfig.org 2 | 3 | # Top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | charset = utf-8 12 | 13 | # 1 space indentation 14 | [*.{c,h,js,css,html}] 15 | indent_style = space 16 | indent_size = 4 17 | 18 | # Tab indentation 19 | [Makefile*] 20 | indent_style = tab 21 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.github/workflows/clang-format.yml: -------------------------------------------------------------------------------- 1 | name: Run clang-format Linter 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: DoozyX/clang-format-lint-action@v0.12 12 | with: 13 | source: '.' 14 | extensions: 'h,cpp,c' 15 | clangFormatVersion: 12 16 | inplace: False 17 | -------------------------------------------------------------------------------- /.github/workflows/compilation.yml: -------------------------------------------------------------------------------- 1 | name: CI-compile 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | jobs: 8 | build: 9 | runs-on: ${{ matrix.os }} 10 | strategy: 11 | matrix: 12 | os: [macos-latest, ubuntu-latest] 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: Install Ubuntu version 18 | if: ${{ matrix.os == 'ubuntu-latest' && always() }} 19 | run: make --trace RELEASE=yes 20 | 21 | - name: Install Mac version 22 | if: ${{ matrix.os == 'macos-latest' && always() }} 23 | run: make --debug USE_THREADED_IIN=no IIN_OPTICAL_MMAP=no RELEASE=yes 24 | 25 | - name: Get short SHA 26 | id: slug 27 | run: echo "SHA=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV 28 | 29 | - name: Create tar archive (keep executable bit) 30 | run: tar -zcvf hdl-dump-${{ env.SHA }}-${{matrix.os}}.tar.gz hdl_dump 31 | 32 | - uses: actions/upload-artifact@v3 33 | with: 34 | name: hdl-dump-${{ env.SHA }}-${{matrix.os}} 35 | path: | 36 | *tar.gz 37 | 38 | build-win: 39 | runs-on: ubuntu-latest 40 | container: dockcross/windows-static-x86:latest 41 | 42 | steps: 43 | - uses: actions/checkout@v3 44 | 45 | - name: Compile windows version with cross-compilator 46 | run: | 47 | make --trace XC=win RELEASE=yes 48 | mkdir -p rel 49 | mv hdl_dump.exe rel/ 50 | make clean 51 | make --trace -C gui XC=win RELEASE=yes 52 | mv gui/hdl_dumb.exe rel/ 53 | 54 | - name: Get short SHA 55 | id: slug 56 | run: echo "SHA=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV 57 | 58 | - name: Create tar archive 59 | run: tar -zcvf hdl-dump-${{ env.SHA }}-windows-latest.tar.gz rel 60 | 61 | - uses: actions/upload-artifact@v3 62 | with: 63 | name: hdl-dump-${{ env.SHA }}-windows-latest 64 | path: | 65 | *tar.gz 66 | 67 | release: 68 | needs: [build, build-win] 69 | runs-on: ubuntu-latest 70 | if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master' 71 | steps: 72 | - uses: actions/checkout@v3 73 | 74 | - name: Get short SHA 75 | id: slug 76 | run: echo "SHA=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV 77 | 78 | - name: Download artifacts 79 | uses: actions/download-artifact@v3 80 | 81 | - name: Create pre-release 82 | if: github.ref == 'refs/heads/master' 83 | uses: marvinpinto/action-automatic-releases@latest 84 | with: 85 | repo_token: "${{ secrets.GITHUB_TOKEN }}" 86 | prerelease: true 87 | automatic_release_tag: "latest" 88 | title: "Development build" 89 | files: | 90 | hdl-dump-${{ env.SHA }}-windows-latest/* 91 | hdl-dump-${{ env.SHA }}-ubuntu-latest/* 92 | hdl-dump-${{ env.SHA }}-macos-latest/* 93 | 94 | - name: Create Tagged Release Draft 95 | if: startsWith(github.ref, 'refs/tags/v') 96 | uses: marvinpinto/action-automatic-releases@latest 97 | with: 98 | repo_token: "${{ secrets.GITHUB_TOKEN }}" 99 | prerelease: false 100 | draft: true 101 | files: | 102 | hdl-dump-${{ env.SHA }}-windows-latest/* 103 | hdl-dump-${{ env.SHA }}-ubuntu-latest/* 104 | hdl-dump-${{ env.SHA }}-macos-latest/* 105 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE! Please use 'git ls-files -i --exclude-standard -c' 3 | # command after changing this file, to see if there are 4 | # any tracked files which get ignored after the change. 5 | # 6 | # Normal rules 7 | *.d 8 | .* 9 | *.o 10 | *.exe 11 | *_irx.c 12 | *.elf 13 | *.sys 14 | open-ps2-loader 15 | hdl_dump 16 | 17 | # 18 | # files that we don't want to ignore 19 | # 20 | !.gitignore 21 | !.gitattributes 22 | !.github 23 | !.editorconfig 24 | !.clang-format 25 | *.iso 26 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | hdl_dump authors list 2 | 3 | W1zard 0f 0z/Bobi B., w1zard0f07@yahoo.com 4 | portions by David Gauchard, deyv@free.fr 5 | copy_hdd command by JimmyZ 6 | Gambas frontend by Pietro Di Costanzo, piegeta@deejaymail.it 7 | elf injection by AKuHAK 8 | 9 | Big thanks to everybody. 10 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | 0.9.2prerelease 2 | + Add SP193's server (as elf file) 3 | + Add DVD-9 support in gui version. 4 | + clear some warnings 5 | 6 | 0.9.2prerelease 7 | + New function "modify_header", it will inject corresponding 8 | files into partition header. More info in README. 9 | + New version, by default al functions now are enabled. 10 | + More documentation. 11 | 12 | 0.9.1a 13 | + "initialize" function now injects OSD into __mbr partition. 14 | It needs MBR.KELF in the folder with working HDL Dumb. 15 | - removed playstation side server source code as it is 16 | separate project supported by SP193 17 | + cleared sources from old and obsolete files 18 | 19 | 0.9.1 20 | + Now it is possible to inject ELF's into partition 21 | ~ elf size must be less or equal than 417kb (427 456bytes) 22 | ~ elf name is PATINFO.ELF and elf must be placed into folder 23 | with working HDL executable 24 | 25 | 0.9.0a 26 | + KELF injection into source code 27 | ~ KELF can be 2.5Mb or less it will be injected at partition 28 | area header at offset 0x111000 29 | ~ elf name is PATINFO.KELF and elf must be placed into folder 30 | with working HDL Dumb 31 | 32 | 0.9.0 33 | + new networking server 34 | + copy_hdd command (doing what the name says), contributed by JimmyZ 35 | ~ fixed an inssue where APA might get broken on interrupted install 36 | (when main partition overwrites __empty one) 37 | ~ help has been revised 38 | 39 | 0.8.6 40 | + SPTI: dual-layer DVDs can finally be installed from the DVD-ROM drive 41 | ~ thanks to SPTI hdl_dumb works pretty well with both, wine and winelib 42 | + optional threaded I/O (faster networked installs from optical drive) 43 | ~ two fixes sent by Diego G. and few more by my self 44 | + dump command slighly modified to support all inputs 45 | (can even be used for BIN-to-ISO, IML-to-ISO, etc. conversion) 46 | + modify command 47 | ~ 'game@device' is now available as an input (to copy HDD-to-HDD) 48 | instead of 'hddX:game' and '192.168.0.10:game' 49 | 50 | 0.8.5 51 | + better differentiation between CD- and DVD-images/medias 52 | + server will look for IPCONFIG.DAT at mc0:/B?DATA-SYSTEM/, too 53 | + optional auto-tunning of throttling algorithm 54 | + partitioning type auto-detection 55 | + new command for hdl_dump: diag 56 | ~ minor fix of dual-layer support code 57 | ~ hdl_toc lists raw size now, not allocated size 58 | ~ extract can now be interrupted with Ctrl+C 59 | 60 | 0.8.4 61 | + a new (throttling) algorithm to control network install speeds 62 | + memory-mapped I/O when reading CDs/DVDs on Linux 63 | ~ improved 64-bit system/compiler compatibility 64 | ~ better FreeBSD (and maybe MacOS X) compatibility 65 | ~ major UDP server bug fixup 66 | ~ overall code cleanup 67 | 68 | 0.8.3 69 | + new server, better network transfer speeds 70 | + proper SIGINT handling 71 | 72 | 0.8.2 73 | + both - hdl_dump and hdl_dumb - are now configurable in run-time 74 | (as opposed to build-time) 75 | + GUI supports file-based compatibility list 76 | + GUI has been extended to allow up to 8 compatibility flags 77 | + GUI is partially compatible with wine and winelib 78 | (networked installations from an image file works fine) 79 | + new `install' command for hdl_dump that is "fire and forget" 80 | if the game is in the compatibility list 81 | + few minor usability fixes 82 | 83 | 0.8.1 84 | + quick-and-dirty prepare HDD for HD Loader (AKA format or initialize) 85 | works fine with HD Loader; not tested with homebrew 86 | + alternative partition naming scheme selectable via Makefile 87 | + startup file is optional when injecting a game 88 | + new optional argument to set compatibility flags from the commandline 89 | (+1/+2/+1+2/... or in hexidecimal - 0x01/0x02/0x03), up to 6 bits 90 | + dual-layer patch by CrazyC@ps2-scene 91 | ~ delete and extract now works by game name, too 92 | 93 | 0.8 94 | + should be compatible with MacOS X 95 | + build-time option (in the Makefile) to limit hdl_dump/b to 128GB 96 | to preserve compatibility with updated Sony browser 97 | ~ few hdl_dumb bugs fixed and few minor tweaks 98 | + GUI source code is now open 99 | 100 | 0.8-pre 101 | ~ endianess-neutral 102 | ~ fixed a bug with small cue-sheet files (move file ptr before file start) 103 | 104 | 0.7.3 105 | + poweroff and hdl_toc commands 106 | ~ transfer speed raised up to 30% (special thanks to dayv) 107 | ~ bug-fixes and minor changes 108 | 109 | 0.7-pre 110 | + RLE compression 111 | 112 | 0.6 113 | + cdvd_info command 114 | + networking installations 115 | 116 | 0.5 117 | + CDRWIN images support, Nero images support (mode1 plain & RAW and mode2 plain & RAW) 118 | + transparent support for HD Loader images in the same way as ISO files 119 | + support for IML files (Intermediate file format by Sony CD/DVD Generator) 120 | ~ fixed bug in ISOFS parsing (sometimes fails to locate SYSTEM.CNF) 121 | ~ system partitions could not be deleted any longer 122 | 123 | 0.4 124 | ~ dump fixed 125 | + automatic game name (from the media volume label) and signature 126 | 127 | 0.3 128 | - dump broken - DO NOT USE! forgot to erase some debug code, sorry 129 | ~ "__empty" partitions are now treated as an empty space 130 | + hdl_dumb GUI with install and delete games support 131 | 132 | 0.2a 133 | + inject_cd and inject_dvd are not limited anymore 134 | 135 | 0.2 136 | + inject_cd and inject_dvd support for a single game of up to 1GB 137 | + delete partition support 138 | 139 | 0.1 140 | + toc, map, extract support 141 | 142 | $Id: CHANGELOG,v 1.15 2007-05-12 20:12:35 bobi Exp $ 143 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ## 2 | ## Makefile 3 | ## $Id: Makefile,v 1.22 2007-05-12 20:13:04 bobi Exp $ 4 | ## 5 | ## Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | ## 7 | ## This file is part of hdl_dump. 8 | ## 9 | ## hdl_dump is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## hdl_dump is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with hdl_dump; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | ## 23 | 24 | # NOTE: this Makefile REQUIRES GNU make (gmake) 25 | 26 | ############################################################################### 27 | # configuration start 28 | # NOTE: don't forget, that changing some options REQUIRES `make clean' next! 29 | 30 | # `yes' - debug build; something else - release build 31 | # `RELEASE=yes make' makes a release build no matter what DEBUG flag is 32 | DEBUG ?= yes 33 | RELEASE ?= no 34 | 35 | # whether to use memory-mapped I/O when reading from optical drives 36 | # currently appears to work on Linux only 37 | IIN_OPTICAL_MMAP ?= no 38 | 39 | # whether to use iin (ISO inputs) tuned for "streaming" (obsoletes mmap) 40 | USE_THREADED_IIN ?= yes 41 | 42 | # hdl_dump current version/release 43 | VER_MAJOR = 0 44 | VER_MINOR = 9 45 | VER_PATCH = 2 46 | 47 | # https://mxe.cc/ 48 | MXE_TARGETS ?= i686-w64-mingw32.static 49 | 50 | # configuration end 51 | ############################################################################### 52 | 53 | CFLAGS = -Wall -ansi -pedantic -Wno-long-long 54 | 55 | LDFLAGS = 56 | 57 | # iin_hdloader.c iin_net.c 58 | SOURCES = hdl_dump.c \ 59 | apa.c common.c progress.c hdl.c isofs.c aligned.c \ 60 | iin_img_base.c iin_optical.c iin_iso.c iin_cdrwin.c \ 61 | iin_nero.c iin_gi.c iin_iml.c iin_probe.c iin_hio.c \ 62 | hio_probe.c hio_win32.c hio_dbg.c hio_trace.c \ 63 | net_common.c byteseq.c dict.c hio_udpnet2.c 64 | 65 | # "autodetect" Windows builds 66 | ifdef SYSTEMROOT 67 | WINDOWS = yes 68 | else 69 | WINDOWS = no 70 | endif 71 | 72 | # Windows cross-compilation with mingw32* on Debian 73 | # make XC=win ... 74 | WINDRES = windres 75 | ifeq ($(XC), win) 76 | WINDOWS = yes 77 | CC = $(MXE_TARGETS)-gcc 78 | WINDRES = $(MXE_TARGETS)-windres 79 | endif 80 | 81 | 82 | # Windows/Unix/Linux build 83 | ifeq ($(WINDOWS), yes) 84 | SOURCES += iin_spti.c iin_aspi.c aspi_hlio.c osal_win32.c 85 | OBJECTS += rsrc.o 86 | CFLAGS += -D_BUILD_WIN32 87 | CXXFLAGS += -D_BUILD_WIN32 88 | LDFLAGS += -lwsock32 -lwinmm 89 | EXESUF = .exe 90 | 91 | # make it compile with latest cygwin/mingw 92 | # however, that would probably not work under older versions of Windows...? 93 | CFLAGS += -D_WIN32_WINNT=0x0500 94 | 95 | # it looks like Windows doesn't support memory-mapping on optical drives 96 | IIN_OPTICAL_MMAP = no 97 | else 98 | SOURCES += osal_unix.c 99 | CFLAGS += -D_GNU_SOURCE -D_BUILD_UNIX 100 | CXXFLAGS += -D_GNU_SOURCE -D_BUILD_UNIX 101 | LDFLAGS += -lpthread 102 | EXESUF = 103 | endif 104 | 105 | 106 | # whether to make debug or release build 107 | ifeq ($(RELEASE), yes) 108 | DEBUG = no 109 | endif 110 | 111 | # Even on debug we need optimization for _FORTIFY_SOURCE 112 | ifeq ($(DEBUG), yes) 113 | CFLAGS += -O2 -g -D_DEBUG 114 | CXXFLAGS += -O2 -g -D_DEBUG 115 | else 116 | CFLAGS += -O2 -DNDEBUG 117 | CXXFLAGS += -O2 -DNDEBUG 118 | endif 119 | 120 | ifeq ($(USE_THREADED_IIN), yes) 121 | SOURCES += thd_iin.c 122 | CFLAGS += -DUSE_THREADED_IIN 123 | CXXFLAGS += -DUSE_THREADED_IIN 124 | endif 125 | 126 | 127 | # version number 128 | VERSION = -DVER_MAJOR=$(VER_MAJOR) \ 129 | -DVER_MINOR=$(VER_MINOR) \ 130 | -DVER_PATCH=$(VER_PATCH) 131 | VERSION += -DVERSION=\"$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)\" 132 | CFLAGS += $(VERSION) 133 | CXXFLAGS += $(VERSION) 134 | 135 | 136 | ifeq ($(IIN_OPTICAL_MMAP), yes) 137 | CFLAGS += -DIIN_OPTICAL_MMAP 138 | endif 139 | 140 | 141 | OBJECTS += $(SOURCES:.c=.o) 142 | DEPENDS += $(SOURCES:.c=.d) 143 | OBJECTS := $(OBJECTS:.cpp=.o) 144 | DEPENDS := $(DEPENDS:.cpp=.d) 145 | 146 | BINARY = hdl_dump$(EXESUF) 147 | 148 | 149 | ############################################################################### 150 | # make commands below... 151 | 152 | .PHONY: all clean rmdeps 153 | 154 | all: $(BINARY) 155 | 156 | 157 | clean: 158 | @rm -f $(BINARY) $(OBJECTS) 159 | @rm -f $(DEPENDS) 160 | @rm -f *.d *.o *.exe 161 | 162 | rmdeps: 163 | @rm -f $(DEPENDS) 164 | 165 | 166 | LINT_OFF = +posixlib +unixlib \ 167 | -fixedformalarray -exitarg -predboolint -boolops +boolint +partial \ 168 | +matchanyintegral 169 | lint: 170 | for src in $(SOURCES:osal_unix.c=); do \ 171 | @splint -D_LINT -D_BUILD_UNIX -DVERSION="" $(LINT_OFF) $$src; \ 172 | done 173 | 174 | lint2: 175 | @splint -D_LINT -D_BUILD_UNIX -DVERSION="" $(LINT_OFF) \ 176 | -weak -bufferoverflowhigh +longintegral +ignoresigns -ifempty \ 177 | -varuse -initallelements $(SOURCES:osal_unix.c=) 178 | 179 | format: 180 | find . -type f -a \( -iname \*.h -o -iname \*.c \) | xargs clang-format -i 181 | 182 | format-check: 183 | @! find . -type f -a \( -iname \*.h -o -iname \*.c \) | xargs clang-format -style=file -output-replacements-xml | grep " $@ 203 | 204 | GOALS := rmdeps format clean format-check lint lint2 205 | ifeq (,$(filter $(GOALS),$(MAKECMDGOALS))) 206 | -include $(DEPENDS) 207 | endif 208 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `hdl_dump` and `hdl_dumb` 2 | 3 | ## Contents 4 | 5 | - Intro 6 | - Networking server 7 | - Compilation 8 | - Configuration and list file location 9 | - Configuration 10 | - New features 11 | 12 | ## Intro 13 | 14 | The latest version, as well as documentation, can be found on the new official repository, 15 | 16 | _Me reads [w1zard0f07@yahoo.com](mailto:w1zard0f07@yahoo.com) and psx-scene forums every now and then.(c)_ 17 | 18 | Easy guide for installing games can be found here 19 | 20 | ## Networking server 21 | 22 | _Update:_ Currently, OPL built-in NBD server is the preferred option. 23 | 24 | _Deprecated:_ 25 | A UDP-based network server is available, based on the SMAP driver released by @sp193 . It is called `hdl_svr_093.elf` and is now part of the `hdl_dump` sources. 26 | 27 | _**Note**: You might need to punch a hole in your firewall for incoming UDP from port 12345._ 28 | 29 | ## Compilation 30 | 31 | First of all, you have to update your PS2SDK. 32 | 33 | Finally: You can run the shell script in the project folder: `mkrel.sh`. It will compile both GUI and CLI versions for Windows. 34 | 35 | - **Linux**: Build and copy executable into a directory of your choice. 36 | 37 | make RELEASE=yes 38 | 39 | Advanced Linux build commands: 40 | 41 | make XC=win # for Windows cross-compilation using mingw32 42 | make -C gui # for WineLib compilation (currently not working) 43 | make -C gui XC=win # for GUI cross-compilation using mingw32 44 | 45 | - **Mac OS X** or **FreeBSD**: You'll need to have GNU make installed, then 46 | 47 | gmake RELEASE=yes IIN_OPTICAL_MMAP=no 48 | 49 | or 50 | 51 | make RELEASE=yes IIN_OPTICAL_MMAP=no 52 | 53 | - **Windows**: You need to have MINGW32 installed; 54 | then use 55 | 56 | make RELEASE=yes 57 | make -C gui RELEASE=yes 58 | 59 | to compile command-line or GUI version. 60 | 61 | ## Configuration and list file location 62 | 63 | You can place these files in the folder where is installed hdl_dump for making it portable. 64 | 65 | - **Windows**: 66 | 67 | `%APPDATA%\hdl_dump.conf` 68 | `%APPDATA%\hdl_dump.list` 69 | 70 | - **Linux**, **Mac OS X** and **FreeBSD**: (`~` is your home dir) 71 | 72 | `~/.hdl_dump.conf` 73 | `~/.hdl_dump.list` 74 | 75 | ## Configuration 76 | 77 | - `disc_database_file` -- full path to your disc compatibility database file; 78 | 79 | ## New features 80 | 81 | All new stuff can be used from HDD OSD, BB Navigator, or XMB from PSX DVR. 82 | 83 | ### ZSO support 84 | 85 | hdl-dump supports zso compressed files. For using ZSO, you must keep original ISO (or cue/bin) files in the same folder and with the same name as ZSO compressed file. You should select original ISO (or cue/bin) and hdl-dump will check zso existence on installation. If ZSO file exists, it will install ZSO, if it does not exist it will install original ISO. Unfortunately, you need to keep original file for program to work. 86 | 87 | ### `inject_dvd`, `inject_cd`, `install` or `copy_hdd`. 88 | 89 | This command will install games onto the hard disk. 90 | 91 | _**Warning**: Be careful with `copy_hdd` - every HDLoader game will be given the same icon._ 92 | 93 | Optionally, you can place `boot.elf` (which is actually `miniopl.elf`) in the folder where `hdl_dump` is launched from. 94 | You can also optionally include `list.ico` (`*.ico` from memory card) and `icon.sys` (`*.sys` from memory card), or you can write your own `icon.sys` file. 95 | 96 | If you don't include an `*.ico`, the HDLoader logo is used. If you don't include `*.sys`, the default HDLoader icon settings are used.. 97 | 98 | Note: following options aren't supported by PSX1 (PSX DESR 1st generation). 99 | 100 | `boot.elf`, `boot.kelf` - PS2 executable file in signed or unsigned form. [OPL-Launcher](https://github.com/ps2homebrew/OPL-Launcher) is a preferable option. Injection address - `0x111000`. Size limit - 2,026,464 bytes (thanks to kHn) 101 | 102 | ### `inject_mbr` 103 | 104 | hdl_dump inject_mbr /dev/sdb MBR.KELF 105 | 106 | When you use this command and place the hard drive into your PlayStation 2 phat, it will launch the injected `MBR.KELF`. This option can be used as an entry point for PS2. 107 | 108 | All HDD data will remain intact. 109 | 110 | `MBR.KELF` injection address - `0x00404000` (for compatibility with PlayStation BB Navigator) 111 | 112 | `MBR.KELF` size should be a maximum of `883200` bytes and have a valid header. 113 | 114 | ### `modify_header` 115 | 116 | This command injects header attributes into an existing partition. 117 | 118 | hdl_dump.exe modify_header 192.168.0.10 PP.TEST 119 | 120 | It can inject these files: 121 | 122 | - `system.cnf` 123 | - `icon.sys` 124 | - `list.ico` 125 | - `del.ico` 126 | - `boot.kelf` 127 | - `boot.elf` 128 | - `boot.kirx` 129 | 130 | Any one can be skipped. It first tries to inject `boot.kelf`, then if not found it will try to inject `boot.elf`. 131 | 132 | Now `icon.sys` can be in any of 2 formats: Memory Card format or HDD format. 133 | 134 | `del.ico` injection address: `0x041000` (If `del.ico` is used `list.ico` maximum size 260,096 bytes) 135 | 136 | `boot.elf` (or `boot.kelf`) injection address - `0x111000` 137 | 138 | `boot.elf` size limit - 2,026,464 bytes (thanks to kHn) 139 | 140 | `boot.kelf` size limit - 3,076,096 bytes (if `boot.kirx` not used) 141 | 142 | `boot.kelf` size limit - 2,031,616 bytes (if `boot.kirx` is used) 143 | 144 | `boot.kirx` injection address - `0x301000` 145 | 146 | `boot.kirx` size limit - 1,044,480 bytes 147 | 148 | ### Hiding Games 149 | 150 | You can hide games so that they are not visible in the HDD Browser by using the `-hide` switch with the `install`, `inject_cd`, 151 | `inject_dvd`, or `modify` commands. A hidden game can be made visible again using the `-unhide` switch with the `modify` command. This is a necessary option for installing the games on PSX1 (1st DESR generation). 152 | 153 | ### Others 154 | 155 | If you want to know more about these files (and their restrictions), you have to study the official SONY ps2sdk document called `hdd_rule_3.0.2.pdf` 156 | 157 | There are also some undocumented features like this: 158 | 159 | - If you want to inject `boot.kelf` (or `boot.elf`), you have to change `BOOT2` in `system.cnf`. 160 | 161 | BOOT2 = PATINFO 162 | 163 | If you need to erase `boot.elf` from the PATINFO you have to place zero-sized `boot.kelf` or elf in program folder. 164 | \_**Note**: PSX1 (DESR 1st generation) doesn't support the PATINFO parameter. 165 | 166 | - If you want to launch KELF from the PFS partition you have to change `BOOT2` in `system.cnf` 167 | 168 | BOOT2 = pfs:/EXECUTE.KELF 169 | 170 | where `EXECUTE.KELF` - is the path to KELF that is placed into the partition. Changedable. 171 | 172 | - If you want to inject kirx into the partition you have to add a line into `system.cnf` 173 | 174 | IOPRP = PATINFO 175 | 176 | Don't ask about kirx - I don't know where that is used. 177 | \_**Note**: PSX1 (DESR 1st generation) doesn't support the IOPRP parameter. 178 | 179 | - If you don't want to boot from HDD OSD you have to add such a line into system.cnf 180 | 181 | BOOT2 = NOBOOT 182 | 183 | Happy gaming. 184 | -------------------------------------------------------------------------------- /aligned.c: -------------------------------------------------------------------------------- 1 | /* 2 | * aligned.c 3 | * $Id: aligned.c,v 1.8 2006/09/01 17:18:31 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "aligned.h" 29 | 30 | 31 | struct aligned_type 32 | { 33 | osal_handle_t in; 34 | char /*@owned@*/ *unaligned; 35 | char /*@dependent@*/ *buffer; 36 | u_int32_t sector_size, buffer_size, data_length; 37 | u_int64_t offset; 38 | }; 39 | 40 | 41 | /**************************************************************/ 42 | aligned_t * 43 | al_alloc(osal_handle_t in, 44 | u_int32_t sector_size, 45 | u_int32_t buffer_size_in_sectors) 46 | { 47 | aligned_t *al = osal_alloc(sizeof(aligned_t)); 48 | if (al != NULL) { 49 | memset(al, 0, sizeof(aligned_t)); 50 | al->buffer_size = sector_size * buffer_size_in_sectors; 51 | al->unaligned = osal_alloc(al->buffer_size + sector_size); 52 | if (al->unaligned != NULL) { 53 | al->in = in; 54 | /* FIX: 64-bit OS compatibility (not to trim ptr to 32-bit) */ 55 | al->buffer = (void *)(((unsigned long)al->unaligned + sector_size - 1) & ~((unsigned long)sector_size - 1)); 56 | assert(al->buffer >= al->unaligned); 57 | al->sector_size = sector_size; 58 | al->offset = (u_int64_t)-1; 59 | } else { 60 | osal_free(al); 61 | al = NULL; 62 | } 63 | } 64 | return (al); 65 | } 66 | 67 | 68 | /**************************************************************/ 69 | void al_free(aligned_t *al) 70 | { 71 | if (al != NULL) { 72 | osal_free(al->unaligned); 73 | osal_free(al); 74 | } 75 | } 76 | 77 | 78 | /**************************************************************/ 79 | int al_read(aligned_t *al, 80 | u_int64_t offset, 81 | const char **data, 82 | u_int32_t bytes, 83 | u_int32_t *data_length) 84 | { 85 | int result = OSAL_OK; 86 | 87 | /* check if buffer contains all requested data */ 88 | if (al->offset <= offset && offset + bytes <= al->offset + al->data_length) { /* return data from the buffer */ 89 | *data = al->buffer + (offset - al->offset); 90 | *data_length = bytes; 91 | } else { /* buffer does not contains all or any of the requested data */ 92 | u_int64_t aligned_offset = offset & ~((u_int64_t)al->sector_size - 1); 93 | u_int32_t correction = 0; 94 | assert(aligned_offset <= offset); 95 | 96 | /* check whether cache contains some usable data */ 97 | if (al->offset <= aligned_offset && 98 | aligned_offset < al->offset + al->data_length) { /* arrange data inside the cache and correct the offset */ 99 | u_int32_t usable_data_offs = (u_int32_t)(aligned_offset - al->offset); 100 | u_int32_t usable_data_len = (u_int32_t)(al->offset + al->data_length - aligned_offset); 101 | memmove(al->buffer, al->buffer + usable_data_offs, usable_data_len); 102 | correction = usable_data_len; 103 | } 104 | 105 | result = osal_seek(al->in, aligned_offset + correction); 106 | if (result == OSAL_OK) { 107 | result = osal_read(al->in, al->buffer + correction, 108 | al->buffer_size - correction, &al->data_length); 109 | al->data_length += correction; 110 | #if 0 111 | printf ("osal_read (%d, %luKB, %d, -> %d) = %d\n", 112 | al->in, (long) (aligned_offset / 1024), al->buffer_size, al->data_length, result); 113 | #endif 114 | } 115 | if (result == OSAL_OK) { /* success */ 116 | u_int32_t skip = (u_int32_t)(offset - aligned_offset); 117 | al->offset = aligned_offset; 118 | *data = al->buffer + skip; 119 | *data_length = bytes > al->data_length - skip ? al->data_length - skip : bytes; 120 | } 121 | } 122 | return (result); 123 | } 124 | -------------------------------------------------------------------------------- /aligned.h: -------------------------------------------------------------------------------- 1 | /* 2 | * aligned.h 3 | * $Id: aligned.h,v 1.4 2005/07/10 21:06:48 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_ALIGNED_H) 25 | #define _ALIGNED_H 26 | 27 | #include "config.h" 28 | #include "osal.h" 29 | 30 | C_START 31 | 32 | /* 33 | * Windowz: when caching is turned off, all file I/O should start on a multiple of sector size 34 | * (typically 512 bytes for HDD and 2048 bytes for an optical drive) 35 | * and the number of bytes involved should also be multiple of sector size; 36 | * aaahhh... and the buffer should be aligned to a multiple of sector size; 37 | * would read up to sector_size * buffer_size_in_sectors bytes at once 38 | */ 39 | typedef struct aligned_type aligned_t; 40 | 41 | aligned_t * 42 | al_alloc(osal_handle_t in, 43 | u_int32_t sector_size, /* device sector size - each file I/O should be aligned */ 44 | u_int32_t buffer_size_in_sectors); /* 32 is good enough */ 45 | 46 | int al_read(aligned_t *al, 47 | u_int64_t offset, 48 | const char **data, /* internal buffer, managed by aligned I/O */ 49 | u_int32_t dest_size, 50 | u_int32_t *length); 51 | 52 | void al_free(aligned_t *al); 53 | 54 | C_END 55 | 56 | #endif /* _ALIGNED_H defined? */ 57 | -------------------------------------------------------------------------------- /apa.h: -------------------------------------------------------------------------------- 1 | /* 2 | * apa.h 3 | * $Id: apa.h,v 1.11 2006/09/01 17:33:15 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_APA_H) 25 | #define _APA_H 26 | 27 | #include "config.h" 28 | #include "ps2_hdd.h" 29 | #include "osal.h" 30 | #include "hio.h" 31 | #include "dict.h" 32 | 33 | C_START 34 | 35 | #define MAX_MBR_KELF_SIZE 883200 36 | 37 | /* chunks_map */ 38 | static const char MAP_AVAIL = '.'; 39 | static const char MAP_MAIN = 'M'; 40 | static const char MAP_SUB = 's'; 41 | static const char MAP_COLL = 'x'; 42 | static const char MAP_ALLOC = '*'; 43 | 44 | 45 | typedef struct apa_partition_type 46 | { 47 | int existing; 48 | int modified; 49 | int linked; 50 | ps2_partition_header_t header; 51 | } apa_partition_t; 52 | 53 | 54 | typedef struct apa_slice_type 55 | { 56 | int slice_index; 57 | u_int32_t size_in_mb; 58 | 59 | u_int32_t total_chunks; 60 | u_int32_t allocated_chunks; 61 | u_int32_t free_chunks; 62 | /*@only@*/ char *chunks_map; 63 | 64 | /* existing partitions */ 65 | u_int32_t part_alloc_; 66 | u_int32_t part_count; 67 | /*@only@*/ apa_partition_t *parts; 68 | } apa_slice_t; 69 | 70 | typedef struct apa_toc_type 71 | { 72 | u_int32_t size_in_kb; 73 | 74 | int is_toxic, is_2_slice, got_2nd_slice; 75 | 76 | apa_slice_t slice[2]; 77 | } apa_toc_t; 78 | typedef /*@out@*/ /*@only@*/ /*@null@*/ apa_toc_t *apa_toc_p_t; 79 | 80 | #define PPAA_START 0x1000 81 | extern const char *PPAA_MAGIC; 82 | 83 | /* Parent Partition Attribute Area 84 | * The header size is fixed at 512 bytes. 85 | * 86 | */ 87 | typedef struct ppaa_partition_type 88 | { 89 | char magic[9]; /* PS2ICON3D */ 90 | char reserved0[3]; /* 0 */ 91 | int version; /* 0 */ 92 | struct 93 | { 94 | u_int32_t offset; /* must be a multiple of 512 */ 95 | u_int32_t size; 96 | } file[62]; /* could be up to 62 */ 97 | } ppaa_partition_t; 98 | 99 | u_int32_t apa_partition_checksum(const ps2_partition_header_t *part); 100 | 101 | int is_apa_partitioned(osal_handle_t handle); 102 | 103 | void apa_toc_free(/*@special@*/ /*@only@*/ apa_toc_t *toc) /*@releases toc@*/; 104 | 105 | int apa_toc_read(const dict_t *config, 106 | const char *device, 107 | /*@special@*/ apa_toc_p_t *toc) /*@allocates *toc@*/ /*@defines *toc@*/; 108 | 109 | int apa_toc_read_ex(hio_t *hio, 110 | /*@special@*/ apa_toc_p_t *toc) /*@allocates *toc@*/ /*@defines *toc@*/; 111 | 112 | int apa_find_partition(const apa_toc_t *toc, 113 | const char *partition_name, 114 | /*@out@*/ int *slice_index, 115 | /*@out@*/ u_int32_t *partition_index); 116 | 117 | /* slice_index is a hint for where to try first: slice 0 or 1 */ 118 | int apa_allocate_space(apa_toc_t *toc, 119 | const char *partition_name, 120 | u_int32_t size_in_mb, 121 | /*@in@*/ /*@out@*/ int *slice_index, 122 | /*@out@*/ u_int32_t *new_partition_start, 123 | int decreasing_size); 124 | 125 | int apa_delete_partition(apa_toc_t *toc, 126 | const char *partition_name); 127 | 128 | int apa_commit(const dict_t *config, 129 | const char *device_name, 130 | const apa_toc_t *toc); 131 | 132 | int apa_commit_ex(hio_t *hio, 133 | const apa_toc_t *toc); 134 | 135 | int apa_diag(const dict_t *config, 136 | const char *device, 137 | /*@out@*/ char *buffer, 138 | size_t buffer_size); 139 | 140 | int apa_diag_ex(hio_t *hio, 141 | /*@out@*/ char *buffer, 142 | size_t buffer_size); 143 | 144 | int apa_initialize(const dict_t *config, 145 | const char *device, 146 | const char *file_name); 147 | 148 | int apa_initialize_ex(hio_t *hio, const char *file_name); 149 | 150 | int apa_dump_mbr(const dict_t *config, 151 | const char *device, const char *file_name); 152 | 153 | int apa_dump_header(hio_t *hio, u_int32_t starting_partition_sector); 154 | 155 | C_END 156 | 157 | #endif /* _APA_H defined? */ 158 | -------------------------------------------------------------------------------- /aspi_hlio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * aspi_hlio.h - ASPI high-level I/O 3 | * $Id: aspi_hlio.h,v 1.7 2006/09/01 17:32:42 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_ASPI_HLIO_H) 25 | #define _ASPI_HLIO_H 26 | 27 | #include 28 | #include 29 | #include "config.h" 30 | #include "wnaspi32.h" 31 | 32 | C_START 33 | 34 | typedef struct scsi_device_type scsi_device_t; 35 | typedef struct scsi_devices_list_type scsi_devices_list_t; 36 | 37 | struct scsi_device_type 38 | { 39 | int host, scsi_id, lun; 40 | int type; /* 0: probably a HDD; 5: MMC device (CD- or DVD-drive) */ 41 | u_int32_t align; 42 | char name[28 + 1]; 43 | u_int32_t sector_size, size_in_sectors; 44 | unsigned long status; 45 | }; 46 | 47 | struct scsi_devices_list_type 48 | { 49 | u_int32_t used, alloc; 50 | scsi_device_t *device; 51 | }; 52 | 53 | 54 | int aspi_load(void); 55 | int aspi_unload(void); 56 | 57 | int aspi_scan_scsi_bus(scsi_devices_list_t **list); 58 | void aspi_dlist_free(scsi_devices_list_t *list); 59 | 60 | SRB_ExecSCSICmd *aspi_prepare_stat(int host, 61 | int scsi_id, 62 | int lun, 63 | /*@out@*/ u_int8_t buf[8], 64 | /*@returned@*/ /*@out@*/ SRB_ExecSCSICmd *cmd); 65 | 66 | int aspi_stat(int host, 67 | int scsi_id, 68 | int lun, 69 | u_int32_t *sector_size, 70 | u_int32_t *size_in_sectors); 71 | 72 | int aspi_mmc_read_cd(int host, 73 | int scsi_id, 74 | int lun, 75 | u_int32_t start_sector, 76 | u_int32_t num_sectors, 77 | u_int32_t sector_size, 78 | void *output); 79 | 80 | SRB_ExecSCSICmd *aspi_prepare_read_10(int host, 81 | int scsi_id, 82 | int lun, 83 | u_int32_t start_sector, 84 | u_int32_t num_sectors, 85 | /*@out@*/ void *output, 86 | /*@returned@*/ /*@out@*/ SRB_ExecSCSICmd *cmd); 87 | 88 | int aspi_read_10(int host, 89 | int scsi_id, 90 | int lun, 91 | u_int32_t start_sector, 92 | u_int32_t num_sectors, 93 | void *output); 94 | 95 | /* pointer should be passed to aspi_dispose_error_msg when no longer needed */ 96 | unsigned long aspi_get_last_error_code(void); 97 | const char *aspi_get_last_error_msg(void); 98 | const char *aspi_get_error_msg(unsigned long aspi_error_code); 99 | void aspi_dispose_error_msg(char *msg); 100 | 101 | C_END 102 | 103 | #endif /* _ASPI_HLIO_H defined? */ 104 | -------------------------------------------------------------------------------- /byteseq.c: -------------------------------------------------------------------------------- 1 | /* 2 | * byteseq.c 3 | * $Id: byteseq.c,v 1.2 2004/12/04 10:20:53 b081 Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "byteseq.h" 25 | 26 | 27 | /**************************************************************/ 28 | u_int32_t 29 | get_u32(const void *buffer) 30 | { 31 | const u_int8_t *p = buffer; 32 | return ((u_int32_t)p[3] << 24 | 33 | (u_int32_t)p[2] << 16 | 34 | (u_int32_t)p[1] << 8 | 35 | (u_int32_t)p[0] << 0); 36 | } 37 | 38 | 39 | /**************************************************************/ 40 | void set_u32(void *buffer, 41 | u_int32_t val) 42 | { 43 | u_int8_t *p = buffer; 44 | p[3] = (u_int8_t)(val >> 24); 45 | p[2] = (u_int8_t)(val >> 16); 46 | p[1] = (u_int8_t)(val >> 8); 47 | p[0] = (u_int8_t)(val >> 0); 48 | } 49 | 50 | 51 | /**************************************************************/ 52 | u_int16_t 53 | get_u16(const void *buffer) 54 | { 55 | const u_int8_t *p = buffer; 56 | return ((u_int16_t)p[1] << 8 | 57 | (u_int16_t)p[0] << 0); 58 | } 59 | 60 | 61 | /**************************************************************/ 62 | void set_u16(void *buffer, 63 | u_int16_t val) 64 | { 65 | u_int8_t *p = buffer; 66 | p[1] = (u_int8_t)(val >> 8); 67 | p[0] = (u_int8_t)(val >> 0); 68 | } 69 | 70 | /**************************************************************/ 71 | u_int8_t 72 | get_u8(const void *buffer) 73 | { 74 | const u_int8_t *p = buffer; 75 | return ((u_int8_t)p[0] << 0); 76 | } 77 | 78 | 79 | /**************************************************************/ 80 | void set_u8(void *buffer, 81 | u_int8_t val) 82 | { 83 | u_int8_t *p = buffer; 84 | p[0] = (u_int8_t)(val >> 0); 85 | } 86 | -------------------------------------------------------------------------------- /byteseq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * byteseq.h 3 | * $Id: byteseq.h,v 1.4 2006/09/01 17:32:03 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_BYTESEQ_H) 25 | #define _BYTESEQ_H 26 | 27 | #include "config.h" 28 | 29 | C_START 30 | 31 | u_int32_t get_u32(const void *buffer); 32 | void set_u32(/*@out@*/ void *buffer, u_int32_t val); 33 | 34 | u_int16_t get_u16(const void *buffer); 35 | void set_u16(/*@out@*/ void *buffer, u_int16_t val); 36 | 37 | u_int8_t get_u8(const void *buffer); 38 | void set_u8(/*@out@*/ void *buffer, u_int8_t val); 39 | 40 | C_END 41 | 42 | #endif /* _BYTESEQ_H defined? */ 43 | -------------------------------------------------------------------------------- /common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * common.h 3 | * $Id: common.h,v 1.15 2006/09/01 17:31:55 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_COMMON_H) 25 | #define _COMMON_H 26 | 27 | #include "config.h" 28 | #include "dict.h" 29 | #include "osal.h" 30 | #include "progress.h" 31 | #include "iin.h" 32 | #include "hio.h" 33 | #include "hdl.h" 34 | 35 | C_START 36 | 37 | #if !defined(MAX_PATH) 38 | /* This needs to be at least 256 bytes -- see iin_gi_probe_path */ 39 | #define MAX_PATH 1024 40 | #endif 41 | 42 | 43 | char *ltrim(/*@returned@*/ char *text); 44 | 45 | char *rtrim(/*@returned@*/ char *text); 46 | 47 | /* nonzero if same, zero if different */ 48 | int caseless_compare(const char *s1, 49 | const char *s2); 50 | 51 | /* would copy until EOF if bytes == 0 */ 52 | int copy_data(osal_handle_t in, 53 | osal_handle_t out, 54 | u_int64_t bytes, 55 | u_int32_t buff_size, 56 | progress_t *pgs); 57 | 58 | /* data buffer is zero-terminated */ 59 | int read_file(const char *file_name, 60 | /*@out@*/ char **data, 61 | /*@out@*/ u_int32_t *len); 62 | 63 | int write_file(const char *file_name, 64 | const void *data, 65 | u_int32_t len); 66 | 67 | int dump_device(const dict_t *config, 68 | const char *device_name, 69 | const char *output_file, 70 | u_int64_t max_size, 71 | progress_t *pgs); 72 | 73 | /* nonzero if file can be opened for reading, zero if none or on error */ 74 | int file_exists(const char *path); 75 | 76 | /* checks whether original_file exists; if not, checks for the same filename, 77 | in the directory of secondary file; returns RET_OK on success; 78 | modifies original_file if necessary */ 79 | int lookup_file(char original_file[MAX_PATH], 80 | const char *secondary_file); 81 | 82 | int iin_copy(iin_t *iin, 83 | osal_handle_t out, 84 | u_int32_t start_sector, 85 | u_int32_t num_sectors, 86 | progress_t *pgs); 87 | 88 | int iin_copy_ex(iin_t *iin, 89 | hio_t *hio, 90 | u_int32_t input_start_sector, 91 | u_int32_t output_start_sector, 92 | u_int32_t num_sectors, 93 | progress_t *pgs); 94 | 95 | /*@observer@*/ const char *get_config_file(void); 96 | void set_config_defaults(dict_t *config); 97 | 98 | compat_flags_t parse_compat_flags(const char *flags); 99 | unsigned short parse_dma(const char *flags); 100 | 101 | int ddb_lookup(const dict_t *config, 102 | const char *startup, 103 | /*@out@*/ char name[HDL_GAME_NAME_MAX + 1], 104 | /*@out@*/ compat_flags_t *flags); 105 | 106 | int ddb_update(const dict_t *config, 107 | const char *startup, 108 | const char *name, 109 | compat_flags_t flags); 110 | 111 | C_END 112 | 113 | #endif /* _COMMON_H defined? */ 114 | -------------------------------------------------------------------------------- /config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * config.h 3 | * $Id: config.h,v 1.15 2007-05-12 20:14:17 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_CONFIG_H) 25 | #define _CONFIG_H 26 | 27 | /* MacOS X support patch; there is more in osal_unix.c */ 28 | #if defined(__APPLE__) || defined(__FreeBSD__) 29 | #undef _BUILD_UNIX 30 | #define _BUILD_UNIX 31 | #define lseek64 lseek 32 | #define stat64 stat 33 | #define open64 open 34 | #define off64_t off_t 35 | #define fstat64 fstat 36 | #define mmap64 mmap 37 | #define O_LARGEFILE 0 38 | #endif 39 | /* end of MacOS X support patch */ 40 | 41 | #if !defined(_BUILD_WIN32) && !defined(_BUILD_UNIX) && !defined(_BUILD_PS2) 42 | #error One of _BUILD_WIN32, _BUILD_UNIX or _BUILD_PS2 should be defined 43 | #endif 44 | 45 | #if defined(_BUILD_WIN32) 46 | #if !defined(_BUILD_WINE) 47 | typedef unsigned char u_int8_t; 48 | typedef unsigned short u_int16_t; 49 | typedef unsigned long u_int32_t; 50 | #if defined(_MSC_VER) && defined(_WIN32) 51 | typedef unsigned __int64 u_int64_t; /* Microsoft Visual C/C++ compiler */ 52 | #else 53 | typedef unsigned long long u_int64_t; /* GNU C/C++ compiler */ 54 | /* typedef signed int ssize_t; => #include */ 55 | #endif 56 | #else 57 | #include 58 | #endif 59 | 60 | #elif defined(_BUILD_UNIX) 61 | #include 62 | #if defined(_LINT) 63 | typedef uint8_t u_int8_t; 64 | typedef uint16_t u_int16_t; 65 | typedef uint32_t u_int32_t; 66 | typedef uint64_t u_int64_t; 67 | #endif 68 | 69 | #elif defined(_BUILD_PS2) 70 | #if defined(_EE) 71 | #include /* EE */ 72 | #else 73 | #include /* IOP */ 74 | #endif 75 | typedef u8 u_int8_t; 76 | typedef u16 u_int16_t; 77 | typedef u32 u_int32_t; 78 | typedef u64 u_int64_t; 79 | #endif 80 | 81 | #if defined(_BUILD_UNIX) 82 | typedef int SOCKET; 83 | #define INVALID_SOCKET (-1) 84 | #endif 85 | 86 | /* maximum number of compatibility flags (in bits); 87 | should fit in the following type */ 88 | #define MAX_FLAGS 8 89 | typedef unsigned char compat_flags_t; 90 | static const compat_flags_t COMPAT_FLAGS_INVALID = (compat_flags_t)-1; 91 | 92 | /* control whether infrequently-used commands to be built */ 93 | #define INCLUDE_DUMP_CMD 94 | #define INCLUDE_COMPARE_IIN_CMD 95 | #define INCLUDE_MAP_CMD 96 | #define INCLUDE_INFO_CMD 97 | #define INCLUDE_ZERO_CMD 98 | #define INCLUDE_CUTOUT_CMD 99 | #define INCLUDE_INJECT_MBR_CMD 100 | #define INCLUDE_DUMP_MBR_CMD 101 | #define INCLUDE_DELETE_CMD 102 | #define INCLUDE_BACKUP_TOC_CMD 103 | #define INCLUDE_RESTORE_TOC_CMD 104 | #define INCLUDE_DIAG_CMD 105 | #define INCLUDE_MODIFY_CMD 106 | #define INCLUDE_COPY_HDD_CMD 107 | #undef INCLUDE_HIDE_CMD /*Hide function is malfunction*/ 108 | 109 | /* option names and values for the config file */ 110 | #define CONFIG_ENABLE_ASPI_FLAG "enable_aspi" 111 | #define CONFIG_DISC_DATABASE_FILE "disc_database_file" 112 | #define CONFIG_LAST_IP "last_ip" 113 | #define CONFIG_TARGET_KBPS "target_kbps" 114 | #define CONFIG_AUTO_THROTTLE "auto_throttle" 115 | #define CONFIG_DEFAULT_DMA "default_dma" 116 | 117 | #if defined(__cplusplus) 118 | #define C_START extern "C" { 119 | #define C_END } // extern "C" 120 | #else 121 | #define C_START 122 | #define C_END 123 | #endif 124 | 125 | #endif /* _CONFIG_H defined? */ 126 | -------------------------------------------------------------------------------- /dict.h: -------------------------------------------------------------------------------- 1 | /* 2 | * dict.h 3 | * $Id: dict.h,v 1.3 2006/09/01 17:31:33 bobi Exp $ 4 | * 5 | * Copyright 2005 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_DICT_H) 25 | #define _DICT_H 26 | 27 | #include "config.h" 28 | 29 | C_START 30 | 31 | typedef struct dict_type dict_t; 32 | 33 | /* returns NULL when out of memory */ 34 | /*@special@*/ /*@only@*/ dict_t * 35 | dict_alloc(void) /*@allocates result@*/ /*@defines result@*/; 36 | 37 | void dict_free(/*@special@*/ /*@only@*/ dict_t *dict) /*@releases dict@*/; 38 | 39 | /* set or replace; returns non-zero on success */ 40 | int dict_put(dict_t *dict, 41 | const char *key, 42 | const char *value); 43 | 44 | /* query; returns NULL if not found */ 45 | /*@observer@*/ const char *dict_lookup(const dict_t *dict, 46 | const char *key); 47 | 48 | int dict_put_flag(dict_t *dict, 49 | const char *key, 50 | int value); 51 | 52 | int dict_get_flag(const dict_t *dict, 53 | const char *key, 54 | int default_value); 55 | 56 | int dict_get_numeric(const dict_t *dict, 57 | const char *key, 58 | int default_value); 59 | 60 | int dict_store(const dict_t *dict, 61 | const char *filename); 62 | 63 | /* returns NULL on error or bad file format; src might be NULL */ 64 | /*@special@*/ /*@only@*/ dict_t * 65 | dict_restore(dict_t *src, 66 | const char *filename) /*@allocates result@*/ /*@defines result@*/; 67 | 68 | /* returns non-zero on success */ 69 | int dict_merge(dict_t *dst, 70 | const dict_t *src); 71 | 72 | #if defined(_DEBUG) 73 | void dict_dump(const dict_t *dict); 74 | #endif 75 | 76 | C_END 77 | 78 | #endif /* _DICT_H defined? */ 79 | -------------------------------------------------------------------------------- /execli/Makefile: -------------------------------------------------------------------------------- 1 | ## 2 | ## Makefile 3 | ## $Id: Makefile,v 1.1 2005/05/06 14:50:35 b081 Exp $ 4 | ## 5 | ## Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | ## 7 | ## This file is part of hdl_dump. 8 | ## 9 | ## hdl_dump is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## hdl_dump is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with hdl_dump; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | ## 23 | 24 | CFLAGS = -g -Wall -ansi -pedantic -mno-cygwin 25 | EXE = execli.exe 26 | DLL = libexecli.dll 27 | 28 | all: $(EXE) $(DLL) 29 | 30 | clean: 31 | rm -f execli_?.o $(EXE) $(DLL) 32 | 33 | $(EXE): execli.c 34 | $(CC) $(CFLAGS) -D_CONSOLE_TEST -c -o execli_e.o execli.c 35 | $(CC) $(CFLAGS) -o $@ execli_e.o 36 | 37 | $(DLL): execli.c execli.def 38 | $(CC) $(CFLAGS) -c -o execli_l.o execli.c 39 | $(CC) -shared $(CFLAGS) -o $@ execli_l.o execli.def 40 | -------------------------------------------------------------------------------- /execli/execli.c: -------------------------------------------------------------------------------- 1 | /* 2 | * execli.c 3 | * $Id: execli.c,v 1.2 2005/12/08 20:42:39 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | 28 | /* reads up to `bytes' from the `pipe' and returns the number of bytes get */ 29 | int non_blocking_pipe_read(HANDLE pipe, 30 | char *buffer, 31 | size_t bytes) 32 | { 33 | size_t bytes_orig = bytes; 34 | DWORD bytes_left; 35 | BOOL success; 36 | 37 | do { /* ask how much bytes could be get from the pipe */ 38 | bytes_left = 0; 39 | success = PeekNamedPipe(pipe, NULL, 0, NULL, &bytes_left, NULL); 40 | if (success && bytes_left > 0) { 41 | DWORD bytes_readen; 42 | if (bytes_left > bytes) 43 | bytes_left = bytes; 44 | success = ReadFile(pipe, buffer, bytes_left, &bytes_readen, NULL); 45 | if (success) { 46 | bytes -= bytes_readen; 47 | buffer += bytes_readen; 48 | } 49 | } 50 | } while (success && bytes_left > 0 && bytes > 0); 51 | return (bytes_orig - bytes); 52 | } 53 | 54 | 55 | /* executes a command-line interface program and passes all output 56 | via `message_callback'; upon complete returns exit code */ 57 | __stdcall int 58 | exec_cli(const char *file_path, 59 | const char *cmd_line, 60 | const char *current_dir, 61 | __stdcall int (*message_callback)(const char *output, 62 | size_t length)) 63 | { 64 | #define READ_BUFFER_SIZE 1024 65 | 66 | HANDLE out_read = NULL, out_write = NULL; 67 | SECURITY_ATTRIBUTES sa; 68 | BOOL success; 69 | char command_line[512]; 70 | DWORD exit_code = (DWORD)-1; 71 | 72 | memset(&sa, 0, sizeof(sa)); 73 | sa.nLength = sizeof(sa); 74 | sa.bInheritHandle = TRUE; 75 | success = CreatePipe(&out_read, &out_write, &sa, 0); 76 | if (success) { 77 | STARTUPINFOA si; 78 | PROCESS_INFORMATION pi; 79 | 80 | memset(&si, 0, sizeof(si)); 81 | si.cb = sizeof(si); 82 | si.hStdInput = INVALID_HANDLE_VALUE; 83 | si.hStdOutput = out_write; 84 | si.hStdError = out_write; 85 | si.dwFlags = STARTF_USESTDHANDLES; 86 | 87 | memset(&pi, 0, sizeof(pi)); 88 | 89 | sprintf(command_line, "\"%s\" %s", file_path, cmd_line); 90 | success = CreateProcess(file_path, command_line, NULL, NULL, 91 | TRUE, CREATE_NO_WINDOW, NULL, current_dir, &si, &pi); 92 | if (success) { /* wait 'till process is over and nothing left to read from stdout */ 93 | char buffer[READ_BUFFER_SIZE]; 94 | size_t bytes; 95 | BOOL process_alive; 96 | do { 97 | Sleep(10); /* fixes 100% CPU usage issue */ 98 | process_alive = (GetExitCodeProcess(pi.hProcess, &exit_code) && 99 | exit_code == STILL_ACTIVE); 100 | do { /* pipe all data to the caller */ 101 | bytes = non_blocking_pipe_read(out_read, buffer, 102 | sizeof(buffer) / 103 | sizeof(buffer[0])); 104 | if (bytes > 0) 105 | (*message_callback)(buffer, bytes); 106 | } while (bytes > 0); 107 | } while (process_alive || bytes > 0); 108 | } 109 | CloseHandle(out_read); 110 | CloseHandle(out_write); 111 | } 112 | return ((int)exit_code); 113 | } 114 | 115 | 116 | #if defined(_CONSOLE_TEST) 117 | 118 | __stdcall int 119 | callback(const char *output, 120 | size_t length) 121 | { 122 | printf("%d: [%.*s]", length, length, output); 123 | return (0); 124 | } 125 | 126 | 127 | int main(int argc, char *argv[]) 128 | { 129 | printf("exit code: %d", 130 | exec_cli("./hdl_dump.exe", 131 | "cdvd_info i:/KALIFORNIA.ISO", 132 | "t:/p/ps2/hdl_dump/", 133 | &callback)); 134 | return (0); 135 | } 136 | 137 | #endif /* _CONSOLE_TEST defined? */ 138 | -------------------------------------------------------------------------------- /execli/execli.def: -------------------------------------------------------------------------------- 1 | LIBRARY EXECLI 2 | 3 | DESCRIPTION 'Execute Command-Line Interface application DLL' 4 | 5 | EXPORTS 6 | exec_cli = exec_cli@16 7 | -------------------------------------------------------------------------------- /execli/vb_test/execli_test.vbp: -------------------------------------------------------------------------------- 1 | Type=Exe 2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\system32\stdole2.tlb#OLE Automation 3 | Module=startup; startup.bas 4 | Startup="Sub Main" 5 | HelpFile="" 6 | ExeName32="execli_test.exe" 7 | Command32="" 8 | Name="execli_test" 9 | HelpContextID="0" 10 | CompatibleMode="0" 11 | MajorVer=1 12 | MinorVer=0 13 | RevisionVer=0 14 | AutoIncrementVer=0 15 | ServerSupportFiles=0 16 | VersionCompanyName="-" 17 | CompilationType=0 18 | OptimizationType=0 19 | FavorPentiumPro(tm)=0 20 | CodeViewDebugInfo=0 21 | NoAliasing=0 22 | BoundsCheck=0 23 | OverflowCheck=0 24 | FlPointCheck=0 25 | FDIVCheck=0 26 | UnroundedFP=0 27 | StartMode=0 28 | Unattended=0 29 | Retained=0 30 | ThreadPerObject=0 31 | MaxNumberOfThreads=1 32 | 33 | [MS Transaction Server] 34 | AutoRefresh=1 35 | -------------------------------------------------------------------------------- /execli/vb_test/startup.bas: -------------------------------------------------------------------------------- 1 | Attribute VB_Name = "startup" 2 | Option Explicit 3 | 4 | 5 | Declare Function exec_cli Lib "libexecli" _ 6 | (ByVal exe_name As String, _ 7 | ByVal command_line As String, _ 8 | ByVal current_dir As String, _ 9 | ByVal callback As Long) As Long 10 | 11 | 12 | Dim all As String 13 | 14 | 15 | ' a workaround to convert C-style ANSI string to VB-string 16 | Type c_string 17 | text(1024) As Byte 18 | End Type 19 | Function callback(ByRef output As c_string, _ 20 | ByVal length As Long) As Long 21 | Dim i As Long, old_len As Long 22 | old_len = Len(all) 23 | all = all & Space$(length) 24 | For i = 0 To length - 1 25 | Mid$(all, old_len + i + 1, 1) = Chr$(output.text(i)) 26 | Next i 27 | End Function 28 | 29 | 30 | Sub Main() 31 | 32 | Dim exit_code As Long 33 | all = "" 34 | exit_code = exec_cli("c:\windows\system32\cmd.exe", _ 35 | "/c dir", _ 36 | "c:\", _ 37 | AddressOf callback) 38 | MsgBox ("exit code: " & exit_code & vbCrLf & all) 39 | 40 | End Sub 41 | -------------------------------------------------------------------------------- /gui/Makefile: -------------------------------------------------------------------------------- 1 | ## 2 | ## Makefile 3 | ## $Id: Makefile,v 1.10 2007-05-12 20:18:11 bobi Exp $ 4 | ## 5 | ## Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | ## 7 | ## This file is part of hdl_dumb. 8 | ## 9 | ## hdl_dumb is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## hdl_dumb is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with hdl_dumb; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | ## 23 | 24 | # NOTE: this Makefile REQUIRES GNU make (gmake) 25 | 26 | ############################################################################### 27 | # configuration start 28 | # NOTE: don't forget, that changing some options REQUIRES `make clean' next! 29 | 30 | # `yes' - debug build; something else - release build 31 | # `RELEASE=yes make' makes a release build no matter what DEBUG flag is 32 | DEBUG ?= yes 33 | RELEASE ?= no 34 | 35 | # whether to use memory-mapped I/O when reading from optical drives 36 | IIN_OPTICAL_MMAP ?= no 37 | 38 | # whether to use iin (ISO inputs) tuned for "streaming" (obsoletes mmap) 39 | USE_THREADED_IIN ?= yes 40 | 41 | # hdl_dump current version/release 42 | VER_MAJOR = 0 43 | VER_MINOR = 9 44 | VER_PATCH = 1 45 | 46 | # https://mxe.cc/ 47 | MXE_TARGETS ?= i686-w64-mingw32.static 48 | 49 | # configuration end 50 | ############################################################################### 51 | 52 | 53 | CFLAGS = -Wall -Wno-long-long 54 | 55 | LDFLAGS = 56 | 57 | VPATH = ./:../ 58 | 59 | # iin_hdloader.c iin_net.c 60 | SOURCES = gui_main.c \ 61 | apa.c common.c progress.c hdl.c isofs.c aligned.c \ 62 | iin_img_base.c iin_optical.c iin_iso.c iin_cdrwin.c \ 63 | iin_nero.c iin_gi.c iin_iml.c iin_spti.c iin_probe.c \ 64 | iin_hio.c thd_iin.c iin_aspi.c aspi_hlio.c \ 65 | hio_probe.c hio_win32.c hio_dbg.c hio_trace.c \ 66 | osal_win32.c net_common.c byteseq.c dict.c hio_udpnet2.c 67 | 68 | 69 | # "autodetect" Windows builds 70 | # since this is a _Windows_ GUI, there are two cases here: 71 | # either it is build with CYGWIN gcc or against winelib 72 | ifdef SYSTEMROOT 73 | WINDOWS = yes 74 | else 75 | WINDOWS = no 76 | endif 77 | 78 | # Windows cross-compilation with mingw32* on Debian 79 | # make XC=win ... 80 | WINDRES = windres 81 | ifeq ($(XC), win) 82 | WINDOWS = yes 83 | CC = $(MXE_TARGETS)-gcc 84 | WINDRES = $(MXE_TARGETS)-windres 85 | endif 86 | 87 | 88 | CFLAGS += -mwindows -D_BUILD_WIN32 89 | LDFLAGS += -lwsock32 -lcomctl32 -lwinmm 90 | 91 | # whether to include ASPI support or not 92 | ifeq ($(WINDOWS), yes) 93 | CFLAGS += -D_WITH_ASPI 94 | CFLAGS += -ansi -pedantic 95 | 96 | SOURCES += 97 | OBJECTS += rsrc.o 98 | EXESUF = .exe 99 | 100 | # it looks like Windows doesn't support memory-mapping on optical drives 101 | IIN_OPTICAL_MMAP = no 102 | else 103 | # assume it is winelib/wine build 104 | CFLAGS += -D_BUILD_WINE 105 | 106 | OBJECTS += rsrc.res 107 | EXESUF = 108 | 109 | CC = winegcc 110 | RC = wrc 111 | WINEBUILD = winebuild 112 | endif 113 | 114 | # make it compile with latest cygwin/mingw 115 | # however, that would probably not work under older versions of Windows 116 | CFLAGS += -D_WIN32_WINNT=0x0500 117 | 118 | 119 | # whether to make debug or release build 120 | ifeq ($(RELEASE), yes) 121 | DEBUG = no 122 | endif 123 | ifeq ($(DEBUG), yes) 124 | CFLAGS += -O0 -g -D_DEBUG 125 | else 126 | CFLAGS += -O2 -s -DNDEBUG 127 | endif 128 | 129 | ifeq ($(USE_THREADED_IIN), yes) 130 | SOURCES += thd_iin.c 131 | CFLAGS += -DUSE_THREADED_IIN 132 | CXXFLAGS += -DUSE_THREADED_IIN 133 | endif 134 | 135 | 136 | # version number 137 | VERSION = -DVER_MAJOR=$(VER_MAJOR) \ 138 | -DVER_MINOR=$(VER_MINOR) \ 139 | -DVER_PATCH=$(VER_PATCH) 140 | VERSION += -DVERSION=\"$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)\" 141 | CFLAGS += $(VERSION) 142 | 143 | 144 | ifeq ($(IIN_OPTICAL_MMAP), yes) 145 | CFLAGS += -DIIN_OPTICAL_MMAP 146 | endif 147 | 148 | 149 | OBJECTS += $(SOURCES:.c=.o) 150 | DEPENDS += $(SOURCES:.c=.d) 151 | 152 | BINARY = hdl_dumb$(EXESUF) 153 | 154 | 155 | ############################################################################### 156 | # make commands below... 157 | 158 | all: $(BINARY) 159 | 160 | 161 | clean: 162 | @rm -f $(BINARY) $(OBJECTS) 163 | ifeq ($(WINDOWS), no) 164 | @rm -f $(BINARY).exe.so 165 | endif 166 | rm -f *.d *.exe *.o afxres* 167 | 168 | rmdeps: 169 | @rm -f $(DEPENDS) 170 | 171 | 172 | rsrc.o: rsrc.rc rsrc.h rsrc/app.ico rsrc/manifest.bin \ 173 | rsrc/ps2_cd.bmp rsrc/ps2_dvd.bmp rsrc/ps2_dvd9.bmp 174 | @echo -e "\tRES $<" 175 | @echo '#include ' > afxres.h 176 | @echo '#define IDC_STATIC -1' >> afxres.h 177 | @$(WINDRES) $(VERSION) -o $@ -i $< 178 | 179 | 180 | $(BINARY): $(OBJECTS) 181 | @echo -e "\tLNK $@" 182 | @$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) 183 | 184 | 185 | .SUFFIXES: .o .exe .c 186 | 187 | 188 | %.o : %.c 189 | @echo -e "\tCC $<" 190 | @$(CC) -c $(CFLAGS) -o $@ $< 191 | 192 | 193 | %.d : %.c 194 | @echo -e "\tDEP $<" 195 | @$(CC) -MM $(CFLAGS) $< > $@ 196 | 197 | 198 | # for wine 199 | %.res : %.rc 200 | @echo -e "\tRC $<" 201 | @echo '#include ' > afxres.h 202 | @$(RC) $(RCFLAGS) $(RCEXTRA) $(DEFINCL) -fo$@ $< 203 | @rm -f afxres.h 204 | 205 | 206 | GOALS := rmdeps clean 207 | ifeq (,$(filter $(GOALS),$(MAKECMDGOALS))) 208 | -include $(DEPENDS) 209 | endif 210 | -------------------------------------------------------------------------------- /gui/hdl_dump.conf: -------------------------------------------------------------------------------- 1 | "auto_throttle" = "0" 2 | "disc_database_file" = "/home/bobi/.hdl_dump.list" 3 | "enable_aspi" = "no" 4 | "last_ip" = "192.168.0.10" 5 | "target_kbps" = "2300" 6 | -------------------------------------------------------------------------------- /gui/rsrc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rsrc.h 3 | * $Id: rsrc.h,v 1.5 2005/07/10 21:06:48 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dumb. 8 | * 9 | * hdl_dumb is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dumb is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dumb; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #define IDR_MANIFEST 1 25 | 26 | #define IDI_APPL 101 27 | 28 | #define IDS_DVD 1 29 | #define IDS_CD 2 30 | #define IDS_NAME_LBL 11 31 | #define IDS_FLAGS_LBL 12 32 | #define IDS_SIZE_LBL 13 33 | #define IDS_CREATED_LBL 14 34 | #define IDS_ESTIMATED_UNKNOWN 21 35 | #define IDS_DATA_RATE_UNKNOWN 22 36 | #define IDS_ERROR_TITLE 31 37 | #define IDS_INSTALL_LBL 41 38 | #define IDS_DELETE_LBL 42 39 | #define IDS_MDMA0 51 40 | #define IDS_MDMA1 52 41 | #define IDS_MDMA2 53 42 | #define IDS_UDMA0 54 43 | #define IDS_UDMA1 55 44 | #define IDS_UDMA2 56 45 | #define IDS_UDMA3 57 46 | #define IDS_UDMA4 58 47 | 48 | #define IDS_NO_PS2_HDD_ERR 101 49 | #define IDS_NOT_APA_ERR 102 50 | #define IDS_NOT_HDL_PART_ERR 103 51 | #define IDS_NOT_FOUND_ERR 104 52 | #define IDS_BAD_FORMAT_ERR 105 53 | #define IDS_BAD_DEVICE_ERR 106 54 | #define IDS_NO_SPACE_ERR 107 55 | #define IDS_BAD_APA_ERR 108 56 | #define IDS_NO_MEM_ERR 109 57 | #define IDS_INTERRUPTED_ERR 110 58 | #define IDS_PART_EXISTS_ERR 111 59 | #define IDS_UNKNOWN_ERR 112 60 | #define IDS_NOT_COMPAT_ERR 113 61 | #define IDS_NOT_ALLOWED_ERR 114 62 | #define IDS_DATA_CROSS_128GB 115 63 | 64 | #define IDS_CONFIRM_DELETE 25 65 | #define IDS_CONFIRM_DELETE_TITLE 26 66 | #define IDS_INCOMPATIBLE_GAME 27 67 | #define IDS_INCOMPATIBLE_GAME_TITLE 28 68 | 69 | #define IDD_MAIN_DLG 101 70 | #define IDD_PROGRESS_DLG 102 71 | 72 | #define IDC_PS2HDD 1001 73 | #define IDC_INSTALL_OPT 1002 74 | #define IDC_BROWSE_OPT 1003 75 | #define IDC_ISO_OPT 1004 76 | #define IDC_ISO_PATH 1005 77 | #define IDC_BROWSE_FOR_ISO 1006 78 | #define IDC_OPTICAL_OPT 1007 79 | #define IDC_SOURCE_DRIVE 1008 80 | #define IDC_GAMENAME 1010 81 | #define IDC_SOURCE_TYPE 1011 82 | #define IDC_PROGRESS 1012 83 | #define IDC_SIGNATURE 1013 84 | #define IDC_ACTION 1014 85 | #define IDC_PS2HDD_LBL 1015 86 | #define IDC_OPERATION_LBL 1016 87 | #define IDC_SOURCE_LBL 1017 88 | #define IDC_TYPE_LBL 1018 89 | #define IDC_GAME_LBL 1019 90 | #define IDC_GAMENAME_LBL 1020 91 | #define IDC_CONTENTS 1021 92 | #define IDC_PS2HDD_INFO 1022 93 | #define IDC_SIGNATURE_LBL 1023 94 | #define IDC_SOURCE_INFO 1024 95 | #define IDC_DMA_TYPE 1025 96 | #define IDC_MODE1 1101 97 | #define IDC_MODE2 1102 98 | #define IDC_MODE3 1103 99 | #define IDC_MODE4 1104 100 | #define IDC_MODE5 1105 101 | #define IDC_MODE6 1106 102 | #define IDC_MODE7 1107 103 | #define IDC_MODE8 1108 104 | #define IDC_PS2HDD_LOCAL 1028 105 | #define IDC_PS2HDD_NETWORK 1029 106 | #define IDC_PS2IP 1030 107 | #define IDC_FLAGS_LBL 1031 108 | #define IDC_NET_U2LINK 1032 109 | #define IDC_DMA_LBL 1033 110 | 111 | #define IDC_PROGRESS_LBL 2001 112 | #define IDC_ELAPSED_LBL 2002 113 | #define IDC_ELAPSED 2003 114 | #define IDC_ESTIMATED_LBL 2004 115 | #define IDC_ESTIMATED 2005 116 | #define IDC_AVGSPEED_LBL 2006 117 | #define IDC_AVGSPEED 2007 118 | #define IDC_CURRSPEED_LBL 2008 119 | #define IDC_CURRSPEED 2009 120 | 121 | #define IDB_PS2_CD 101 122 | #define IDB_PS2_DVD 102 123 | #define IDB_PS2_DVD9 103 124 | -------------------------------------------------------------------------------- /gui/rsrc.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israpps/hdl-dump/32c296c69cf9c263fcbe035004aa28c345b3b279/gui/rsrc.rc -------------------------------------------------------------------------------- /gui/rsrc/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israpps/hdl-dump/32c296c69cf9c263fcbe035004aa28c345b3b279/gui/rsrc/app.ico -------------------------------------------------------------------------------- /gui/rsrc/folder-16x16.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israpps/hdl-dump/32c296c69cf9c263fcbe035004aa28c345b3b279/gui/rsrc/folder-16x16.ico -------------------------------------------------------------------------------- /gui/rsrc/gears-16x16.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israpps/hdl-dump/32c296c69cf9c263fcbe035004aa28c345b3b279/gui/rsrc/gears-16x16.ico -------------------------------------------------------------------------------- /gui/rsrc/manifest.bin: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Generic 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /gui/rsrc/ps2_cd.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israpps/hdl-dump/32c296c69cf9c263fcbe035004aa28c345b3b279/gui/rsrc/ps2_cd.bmp -------------------------------------------------------------------------------- /gui/rsrc/ps2_cd.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israpps/hdl-dump/32c296c69cf9c263fcbe035004aa28c345b3b279/gui/rsrc/ps2_cd.ico -------------------------------------------------------------------------------- /gui/rsrc/ps2_dvd.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israpps/hdl-dump/32c296c69cf9c263fcbe035004aa28c345b3b279/gui/rsrc/ps2_dvd.bmp -------------------------------------------------------------------------------- /gui/rsrc/ps2_dvd.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israpps/hdl-dump/32c296c69cf9c263fcbe035004aa28c345b3b279/gui/rsrc/ps2_dvd.ico -------------------------------------------------------------------------------- /gui/rsrc/ps2_dvd9.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israpps/hdl-dump/32c296c69cf9c263fcbe035004aa28c345b3b279/gui/rsrc/ps2_dvd9.bmp -------------------------------------------------------------------------------- /gui/rsrc/ps2_dvd9.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israpps/hdl-dump/32c296c69cf9c263fcbe035004aa28c345b3b279/gui/rsrc/ps2_dvd9.ico -------------------------------------------------------------------------------- /gui/wgdb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # /usr/lib/wine/wine.bin winedbg.exe -cd /home/bobi/p/hdl_dump/gui/ -fullname --gdb /home/bobi/p/hdl_dump/gui/hdl_dumb.exe.so ... 4 | 5 | cd ~/p/hdl_dump/gui 6 | winedbg --gdb ./hdl_dumb.exe.so 7 | -------------------------------------------------------------------------------- /hdl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hdl.h 3 | * $Id: hdl.h,v 1.9 2006/09/01 17:29:13 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_HDL_H) 25 | #define _HDL_H 26 | 27 | #include "config.h" 28 | #include "progress.h" 29 | #include "hio.h" 30 | #include "iin.h" 31 | #include "apa.h" 32 | #include "ps2_hdd.h" 33 | 34 | C_START 35 | 36 | #define HDL_GAME_NAME_MAX 64 37 | #define VISIBLE_PART "PP." 38 | #define HIDDEN_PART "__." 39 | 40 | typedef struct hdl_game_type 41 | { 42 | char name[HDL_GAME_NAME_MAX + 1]; 43 | char partition_name[PS2_PART_IDMAX + 1]; 44 | char startup[8 + 1 + 3 + 1]; 45 | compat_flags_t compat_flags; 46 | unsigned short dma; 47 | int is_dvd; 48 | u_int32_t layer_break; 49 | } hdl_game_t; 50 | 51 | typedef struct hdl_game_info_type 52 | { 53 | char partition_name[PS2_PART_IDMAX + 1]; 54 | char name[HDL_GAME_NAME_MAX + 1]; 55 | char startup[8 + 1 + 3 + 1]; 56 | compat_flags_t compat_flags; 57 | unsigned short dma; 58 | int is_dvd; 59 | int slice_index; 60 | u_int32_t start_sector; 61 | u_int32_t raw_size_in_kb; 62 | u_int32_t alloc_size_in_kb; 63 | } hdl_game_info_t; 64 | 65 | typedef struct hdl_games_list_type 66 | { 67 | u_int32_t count; 68 | /*@only@*/ hdl_game_info_t *games; 69 | u_int32_t total_chunks; 70 | u_int32_t free_chunks; 71 | } hdl_games_list_t; 72 | typedef /*@only@*/ /*@null@*/ /*@out@*/ hdl_games_list_t *hdl_games_list_p_t; 73 | 74 | 75 | void hdl_pname(const char *startup_name, const char *name, const char part_prefix[3], 76 | /*@out@*/ char partition_name[PS2_PART_IDMAX + 1]); 77 | 78 | int hdl_extract_ex(hio_t *hio, 79 | const char *game_name, 80 | const char *output_file, 81 | progress_t *pgs); 82 | 83 | int hdl_extract(const dict_t *config, 84 | const char *device, 85 | const char *name, /* of the game */ 86 | const char *output, /* file */ 87 | progress_t *pgs); 88 | 89 | int hdl_inject(hio_t *hio, 90 | iin_t *iin, 91 | hdl_game_t *details, 92 | int slice_index, 93 | int is_hidden, /* is the game hidden? */ 94 | progress_t *pgs); 95 | 96 | 97 | int hdl_glist_read(hio_t *hio, 98 | /*@special@*/ hdl_games_list_p_t *glist) /*@allocates *glist@*/ /*@defines *glist@*/; 99 | 100 | void hdl_glist_free(/*@special@*/ /*@only@*/ hdl_games_list_t *glist) /*@releases glist@*/; 101 | 102 | int hdl_ginfo_read(hio_t *hio, 103 | int slice_index, 104 | const ps2_partition_header_t *part, 105 | hdl_game_info_t *ginfo); 106 | 107 | int hdl_lookup_partition_ex(hio_t *hio, 108 | const char *game_name, 109 | /*@out@*/ char partition_id[PS2_PART_IDMAX + 1]); 110 | 111 | int hdl_lookup_partition(const dict_t *config, 112 | const char *device_name, 113 | const char *game_name, 114 | /*@out@*/ char partition_id[PS2_PART_IDMAX + 1]); 115 | 116 | typedef struct hdl_game_alloc_table_type 117 | { 118 | u_int32_t count; 119 | u_int32_t size_in_kb; 120 | struct 121 | { /* those are in 512-byte long sectors */ 122 | u_int32_t start, len; 123 | } part[64]; 124 | } hdl_game_alloc_table_t; 125 | 126 | int hdl_read_game_alloc_table(hio_t *hio, 127 | const apa_toc_t *toc, 128 | int slice_index, 129 | u_int32_t partition_index, 130 | /*@out@*/ hdl_game_alloc_table_t *gat); 131 | 132 | int hdl_modify_game(hio_t *hio, 133 | apa_toc_t *toc, 134 | int slice_index, 135 | u_int32_t starting_partition_sector, 136 | const char *new_name, /* or NULL */ 137 | compat_flags_t new_compat_flags, /* or COMPAT_FLAGS_INVALID */ 138 | unsigned short new_dma, /* or 0 */ 139 | int is_hidden); /* is the game hidden? */ 140 | 141 | int hdd_inject_header(hio_t *hio, 142 | apa_toc_t *toc, 143 | int slice_index, 144 | u_int32_t starting_partition_sector); 145 | 146 | C_END 147 | 148 | #endif /* _HDL_H defined? */ 149 | -------------------------------------------------------------------------------- /hio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hio.h - PS2 HDD I/O 3 | * $Id: hio.h,v 1.9 2006/09/01 17:27:43 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_HIO_H) 25 | #define _HIO_H 26 | 27 | #include "config.h" 28 | #include 29 | #include "dict.h" 30 | 31 | C_START 32 | 33 | /* 34 | * HD Loader I/O interface below 35 | */ 36 | 37 | typedef struct hio_type hio_t; 38 | typedef /*@only@*/ /*@out@*/ /*@null@*/ hio_t *hio_p_t; 39 | 40 | 41 | typedef int (*hio_stat_t)(hio_t *hio, 42 | /*@out@*/ u_int32_t *size_in_kb); 43 | 44 | typedef int (*hio_read_t)(hio_t *hio, 45 | u_int32_t start_sector, 46 | u_int32_t num_sectors, 47 | /*@out@*/ void *output, 48 | /*@out@*/ u_int32_t *bytes); 49 | 50 | typedef int (*hio_write_t)(hio_t *hio, 51 | u_int32_t start_sector, 52 | u_int32_t num_sectors, 53 | const void *input, 54 | /*@out@*/ u_int32_t *bytes); 55 | 56 | typedef int (*hio_flush_t)(hio_t *hio); 57 | 58 | typedef int (*hio_poweroff_t)(hio_t *hio); 59 | 60 | typedef int (*hio_close_t)(/*@special@*/ /*@only@*/ hio_t *hio) /*@releases hio@*/; 61 | 62 | /* return last error text in a memory buffer, that would be freed by calling hio_dispose_error_t */ 63 | typedef /*@only@*/ char *(*hio_last_error_t)(hio_t *hio); 64 | typedef void (*hio_dispose_error_t)(hio_t *hio, 65 | /*@only@*/ char *error); 66 | 67 | 68 | struct hio_type 69 | { 70 | hio_stat_t stat; 71 | hio_read_t read; 72 | hio_write_t write; 73 | hio_flush_t flush; 74 | hio_close_t close; 75 | hio_poweroff_t poweroff; 76 | hio_last_error_t last_error; 77 | hio_dispose_error_t dispose_error; 78 | }; 79 | 80 | 81 | int hio_probe(const dict_t *config, 82 | const char *path, 83 | /*@special@*/ hio_p_t *hio) /*@allocates *hio@*/ /*@defines *hio@*/; 84 | 85 | C_END 86 | 87 | #endif /* _HIO_H defined? */ 88 | -------------------------------------------------------------------------------- /hio_dbg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hio_dbg.h - debug dumps access 3 | * $Id: hio_dbg.h,v 1.2 2006/09/01 17:27:24 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_HIO_DBG_H) 25 | #define _HIO_DBG_H 26 | 27 | #include "config.h" 28 | #include "hio.h" 29 | #include "dict.h" 30 | 31 | C_START 32 | 33 | /* accepts paths of the following form: 34 | "dbg:path-to-debug-dump-file" */ 35 | int hio_dbg_probe(const dict_t *config, 36 | const char *path, 37 | /*@special@*/ hio_p_t *hio) /*@allocates *hio@*/ /*@defines *hio@*/; 38 | 39 | C_END 40 | 41 | #endif /* _HIO_DBG_H defined? */ 42 | -------------------------------------------------------------------------------- /hio_probe.c: -------------------------------------------------------------------------------- 1 | /* 2 | * hio_probe.c 3 | * $Id: hio_probe.c,v 1.8 2007-05-12 20:16:14 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "hio_win32.h" 25 | #include "hio_udpnet2.h" 26 | #include "hio_dbg.h" 27 | #include "hio_trace.h" 28 | #include "retcodes.h" 29 | 30 | 31 | /**************************************************************/ 32 | int hio_probe(const dict_t *config, 33 | const char *path, 34 | hio_t **hio) 35 | { 36 | int result = RET_NOT_COMPAT; 37 | if (result == RET_NOT_COMPAT) 38 | result = hio_trace_probe(config, path, hio); 39 | if (result == RET_NOT_COMPAT) 40 | result = hio_dbg_probe(config, path, hio); 41 | if (result == RET_NOT_COMPAT) 42 | result = hio_udpnet2_probe(config, path, hio); 43 | if (result == RET_NOT_COMPAT) 44 | result = hio_win32_probe(config, path, hio); 45 | return (result); 46 | } 47 | -------------------------------------------------------------------------------- /hio_trace.c: -------------------------------------------------------------------------------- 1 | /* 2 | * hio_trace.c - decorator to trace HIO access 3 | * $Id: hio_trace.c,v 1.2 2006/09/01 17:27:18 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "hio_trace.h" 25 | #include "hio.h" 26 | #include "net_io.h" 27 | #include "osal.h" 28 | #include "retcodes.h" 29 | #include 30 | #include 31 | 32 | 33 | typedef struct hio_trace_type 34 | { 35 | hio_t hio; 36 | FILE *log; 37 | int close_log; 38 | hio_t *real; 39 | } hio_trace_t; 40 | 41 | 42 | /**************************************************************/ 43 | static int 44 | trace_stat(hio_t *hio, 45 | /*@out@*/ u_int32_t *size_in_kb) 46 | { 47 | hio_trace_t *trace = (hio_trace_t *)hio; 48 | int result; 49 | fprintf(trace->log, "hio->stat (%p, ", (void *)trace->real); 50 | result = trace->real->stat(trace->real, size_in_kb); 51 | fprintf(trace->log, "%lu) = %d\n", 52 | (unsigned long)*size_in_kb, result); 53 | return (result); 54 | } 55 | 56 | 57 | /**************************************************************/ 58 | static int 59 | trace_read(hio_t *hio, 60 | u_int32_t start_sector, 61 | u_int32_t num_sectors, 62 | /*@out@*/ void *output, 63 | /*@out@*/ u_int32_t *bytes) 64 | { 65 | hio_trace_t *trace = (hio_trace_t *)hio; 66 | int result; 67 | fprintf(trace->log, "hio->read (%p, 0x%08lx, %lu, %p, ", 68 | (void *)trace->real, (unsigned long)start_sector, 69 | (unsigned long)num_sectors, output); 70 | result = trace->real->read(trace->real, start_sector, num_sectors, 71 | output, bytes); 72 | fprintf(trace->log, "%lu) = %d\n", (unsigned long)*bytes, result); 73 | return (result); 74 | } 75 | 76 | 77 | /**************************************************************/ 78 | static int 79 | trace_write(hio_t *hio, 80 | u_int32_t start_sector, 81 | u_int32_t num_sectors, 82 | const void *input, 83 | /*@out@*/ u_int32_t *bytes) 84 | { 85 | hio_trace_t *trace = (hio_trace_t *)hio; 86 | int result; 87 | fprintf(trace->log, "hio->write (%p, 0x%08lx, %lu, %p, ", 88 | (void *)trace->real, (unsigned long)start_sector, 89 | (unsigned long)num_sectors, input); 90 | result = trace->real->write(trace->real, start_sector, num_sectors, 91 | input, bytes); 92 | fprintf(trace->log, "%lu) = %d\n", (unsigned long)*bytes, result); 93 | return (result); 94 | } 95 | 96 | 97 | /**************************************************************/ 98 | static int 99 | trace_poweroff(hio_t *hio) 100 | { 101 | hio_trace_t *trace = (hio_trace_t *)hio; 102 | int result; 103 | fprintf(trace->log, "hio->poweroff (%p", (void *)trace->real); 104 | result = trace->real->poweroff(trace->real); 105 | fprintf(trace->log, ") = %d\n", result); 106 | return (result); 107 | } 108 | 109 | 110 | /**************************************************************/ 111 | static int 112 | trace_flush(hio_t *hio) 113 | { 114 | hio_trace_t *trace = (hio_trace_t *)hio; 115 | int result; 116 | fprintf(trace->log, "hio->flush (%p", (void *)trace->real); 117 | result = trace->real->poweroff(trace->real); 118 | fprintf(trace->log, ") = %d\n", result); 119 | return (result); 120 | } 121 | 122 | 123 | /**************************************************************/ 124 | static int 125 | trace_close(/*@special@*/ /*@only@*/ hio_t *hio) /*@releases hio@*/ 126 | { 127 | hio_trace_t *trace = (hio_trace_t *)hio; 128 | int result; 129 | fprintf(trace->log, "hio->close (%p", (void *)trace->real); 130 | result = trace->real->close(trace->real); 131 | fprintf(trace->log, ") = %d\n", result); 132 | if (trace->close_log) 133 | fclose(trace->log); 134 | osal_free(trace); 135 | return (result); 136 | } 137 | 138 | 139 | /**************************************************************/ 140 | static char * 141 | trace_last_error(hio_t *hio) 142 | { 143 | hio_trace_t *trace = (hio_trace_t *)hio; 144 | char *err; 145 | fprintf(trace->log, "hio->last_error (%p", (void *)trace->real); 146 | err = trace->real->last_error(trace->real); 147 | fprintf(trace->log, ") = \"%s\"\n", err); 148 | return (err); 149 | } 150 | 151 | 152 | /**************************************************************/ 153 | static void 154 | trace_dispose_error(hio_t *hio, 155 | /*@only@*/ char *error) 156 | { 157 | hio_trace_t *trace = (hio_trace_t *)hio; 158 | fprintf(trace->log, "hio->dispose_error (%p, \"%s\")\n", 159 | (void *)trace->real, error); 160 | trace->real->dispose_error(trace->real, error); 161 | } 162 | 163 | 164 | /**************************************************************/ 165 | static hio_t * 166 | trace_alloc(hio_t *real) 167 | { 168 | hio_trace_t *trace = (hio_trace_t *)osal_alloc(sizeof(hio_trace_t)); 169 | if (trace != NULL) { 170 | memset(trace, 0, sizeof(hio_trace_t)); 171 | trace->hio.stat = &trace_stat; 172 | trace->hio.read = &trace_read; 173 | trace->hio.write = &trace_write; 174 | trace->hio.flush = &trace_flush; 175 | trace->hio.close = &trace_close; 176 | trace->hio.poweroff = &trace_poweroff; 177 | trace->hio.last_error = &trace_last_error; 178 | trace->hio.dispose_error = &trace_dispose_error; 179 | 180 | trace->log = stdout; 181 | trace->close_log = 0; 182 | trace->real = real; 183 | } 184 | return ((hio_t *)trace); 185 | } 186 | 187 | 188 | /**************************************************************/ 189 | int hio_trace_probe(const dict_t *config, 190 | const char *path, 191 | hio_t **hio) 192 | { 193 | static const char *MONIKER = "trace:"; 194 | int result = RET_NOT_COMPAT; 195 | if (memcmp(path, MONIKER, strlen(MONIKER)) == 0) { 196 | hio_t *real; 197 | result = hio_probe(config, path + strlen(MONIKER), &real); 198 | if (result == RET_OK) { 199 | *hio = trace_alloc(real); 200 | if (*hio == NULL) { 201 | real->close(real); 202 | result = RET_NO_MEM; 203 | } 204 | } 205 | } 206 | return (result); 207 | } 208 | -------------------------------------------------------------------------------- /hio_trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hio_trace.h - decorator to trace HIO access 3 | * $Id: hio_trace.h,v 1.2 2006/09/01 17:27:06 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_HIO_TRACE_H) 25 | #define _HIO_TRACE_H 26 | 27 | #include "config.h" 28 | #include "hio.h" 29 | #include "dict.h" 30 | 31 | C_START 32 | 33 | /* accepts paths of the following form: 34 | "trace:" */ 35 | int hio_trace_probe(const dict_t *config, 36 | const char *path, 37 | /*@special@*/ hio_p_t *hio) /*@allocates *hio@*/ /*@defines *hio@*/; 38 | 39 | C_END 40 | 41 | #endif /* _HIO_TRACE_H defined? */ 42 | -------------------------------------------------------------------------------- /hio_udpnet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hio_udpnet.h - TCP/IP+UDP networking access to PS2 HDD 3 | * $Id: hio_udpnet.h,v 1.3 2006/09/01 17:26:45 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_HIO_UDPNET_H) 25 | #define _HIO_UDPNET_H 26 | 27 | #include "config.h" 28 | #include "hio.h" 29 | #include "dict.h" 30 | 31 | C_START 32 | 33 | /* accepts paths of the following form: "udp:a.b.c.d", 34 | where a.b.c.d is a valid IP address */ 35 | int hio_udpnet_probe(const dict_t *config, 36 | const char *path, 37 | /*@special@*/ hio_p_t *hio) /*@allocates *hio@*/ /*@defines *hio@*/; 38 | 39 | C_END 40 | 41 | #endif /* _HIO_UDPNET_H defined? */ 42 | -------------------------------------------------------------------------------- /hio_udpnet2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hio_udpnet2.h - TCP/IP+UDP networking access to PS2 HDD 3 | * $Id: hio_udpnet2.h,v 1.1 2007-05-12 20:16:35 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_HIO_UDPNET2_H) 25 | #define _HIO_UDPNET2_H 26 | 27 | #include "config.h" 28 | #include "hio.h" 29 | #include "dict.h" 30 | 31 | C_START 32 | 33 | /* accepts paths of the following form: "udp2:a.b.c.d", 34 | where a.b.c.d is a valid IP address */ 35 | int hio_udpnet2_probe(const dict_t *config, 36 | const char *path, 37 | /*@special@*/ hio_p_t *hio) /*@allocates *hio@*/ /*@defines *hio@*/; 38 | 39 | C_END 40 | 41 | #endif /* _HIO_UDPNET2_H defined? */ 42 | -------------------------------------------------------------------------------- /hio_win32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * hio_win32.c - Win32 interface to locally connected PS2 HDD 3 | * $Id: hio_win32.c,v 1.8 2006/09/01 17:26:40 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "hio_win32.h" 25 | #include "osal.h" 26 | #include "retcodes.h" 27 | #include 28 | #include 29 | 30 | 31 | typedef struct hio_win32_type 32 | { 33 | hio_t hio; 34 | osal_handle_t device; 35 | unsigned long error_code; /* against osal_... */ 36 | } hio_win32_t; 37 | 38 | 39 | /**************************************************************/ 40 | static int 41 | win32_stat(hio_t *hio, 42 | /*@out@*/ u_int32_t *size_in_kb) 43 | { 44 | hio_win32_t *hw32 = (hio_win32_t *)hio; 45 | u_int64_t size_in_bytes; 46 | int result = osal_get_estimated_device_size(hw32->device, &size_in_bytes); 47 | if (result == OSAL_OK) { 48 | if (size_in_bytes / 1024 < (u_int32_t)0xffffffff) 49 | *size_in_kb = (u_int32_t)(size_in_bytes / 1024); 50 | else 51 | *size_in_kb = (u_int32_t)0xffffffff; 52 | } else 53 | hw32->error_code = osal_get_last_error_code(); 54 | return (result); 55 | } 56 | 57 | 58 | /**************************************************************/ 59 | static int 60 | win32_read(hio_t *hio, 61 | u_int32_t start_sector, 62 | u_int32_t num_sectors, 63 | /*@out@*/ void *output, 64 | /*@out@*/ u_int32_t *bytes) 65 | { 66 | hio_win32_t *hw32 = (hio_win32_t *)hio; 67 | int result = osal_seek(hw32->device, (u_int64_t)start_sector * 512); 68 | if (result == OSAL_OK) 69 | result = osal_read(hw32->device, output, num_sectors * 512, bytes); 70 | if (result == OSAL_OK) 71 | ; 72 | else 73 | hw32->error_code = osal_get_last_error_code(); 74 | return (result); 75 | } 76 | 77 | 78 | /**************************************************************/ 79 | static int 80 | win32_write(hio_t *hio, 81 | u_int32_t start_sector, 82 | u_int32_t num_sectors, 83 | const void *input, 84 | /*@out@*/ u_int32_t *bytes) 85 | { 86 | hio_win32_t *hw32 = (hio_win32_t *)hio; 87 | int result = osal_seek(hw32->device, (u_int64_t)start_sector * 512); 88 | if (result == OSAL_OK) 89 | result = osal_write(hw32->device, input, num_sectors * 512, bytes); 90 | if (result == OSAL_OK) 91 | ; 92 | else 93 | hw32->error_code = osal_get_last_error_code(); 94 | return (result); 95 | } 96 | 97 | 98 | /**************************************************************/ 99 | static int 100 | win32_flush(/*@unused@*/ hio_t *hio) 101 | { /* win32_flush is intentionately blank */ 102 | return (RET_OK); 103 | } 104 | 105 | 106 | /**************************************************************/ 107 | static int 108 | win32_poweroff(/*@unused@*/ hio_t *hio) 109 | { /* win32_poweroff is intentionately blank */ 110 | return (RET_OK); 111 | } 112 | 113 | 114 | /**************************************************************/ 115 | static int 116 | win32_close(/*@special@*/ /*@only@*/ hio_t *hio) /*@releases hio@*/ 117 | { 118 | hio_win32_t *hw32 = (hio_win32_t *)hio; 119 | int result = osal_close(&hw32->device); 120 | osal_free(hio); 121 | return (result); 122 | } 123 | 124 | 125 | /**************************************************************/ 126 | static char * 127 | win32_last_error(hio_t *hio) 128 | { 129 | hio_win32_t *hw32 = (hio_win32_t *)hio; 130 | return (osal_get_error_msg(hw32->error_code)); 131 | } 132 | 133 | 134 | /**************************************************************/ 135 | static void 136 | win32_dispose_error(/*@unused@*/ hio_t *hio, 137 | /*@only@*/ char *error) 138 | { 139 | osal_dispose_error_msg(error); 140 | } 141 | 142 | 143 | /**************************************************************/ 144 | /*@special@*/ static hio_t * 145 | win32_alloc(osal_handle_t device) /*@allocates result@*/ /*@defines result@*/ 146 | { 147 | hio_win32_t *hw32 = (hio_win32_t *)osal_alloc(sizeof(hio_win32_t)); 148 | if (hw32 != NULL) { 149 | memset(hw32, 0, sizeof(hio_win32_t)); 150 | hw32->hio.stat = &win32_stat; 151 | hw32->hio.read = &win32_read; 152 | hw32->hio.write = &win32_write; 153 | hw32->hio.flush = &win32_flush; 154 | hw32->hio.poweroff = &win32_poweroff; 155 | hw32->hio.close = &win32_close; 156 | hw32->hio.last_error = &win32_last_error; 157 | hw32->hio.dispose_error = &win32_dispose_error; 158 | hw32->device = device; 159 | } 160 | return ((hio_t *)hw32); 161 | } 162 | 163 | 164 | /**************************************************************/ 165 | int hio_win32_probe(const dict_t *config, 166 | const char *path, 167 | hio_t **hio) 168 | { 169 | int result; 170 | #if defined(_BUILD_WIN32) 171 | if (tolower(path[0]) == 'h' && 172 | tolower(path[1]) == 'd' && 173 | tolower(path[2]) == 'd' && 174 | isdigit(path[3]) && 175 | ((path[4] == ':' && 176 | path[5] == '\0') || 177 | (isdigit(path[4]) && 178 | path[5] == ':' && 179 | path[6] == '\0'))) 180 | result = RET_OK; 181 | else 182 | result = RET_NOT_COMPAT; 183 | #endif 184 | #if defined(_BUILD_UNIX) 185 | /* osal_map_device_name would check whether input is a device or not */ 186 | result = RET_OK; 187 | #endif 188 | 189 | if (result == RET_OK) { 190 | char device_name[MAX_PATH]; 191 | result = osal_map_device_name(path, device_name); 192 | #if defined(_BUILD_UNIX) 193 | if (result == RET_ERR || 194 | result == RET_BAD_DEVICE) 195 | result = RET_NOT_COMPAT; 196 | #endif 197 | if (result == OSAL_OK) { 198 | osal_handle_t device; 199 | result = osal_open_device_for_writing(device_name, &device); 200 | if (result == OSAL_OK) { 201 | *hio = win32_alloc(device); 202 | if (*hio != NULL) 203 | ; /* success */ 204 | else 205 | result = RET_NO_MEM; 206 | 207 | if (result != OSAL_OK) 208 | osal_close(&device); 209 | } 210 | } 211 | } 212 | return (result); 213 | } 214 | -------------------------------------------------------------------------------- /hio_win32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hio_win32.h - Win32 interface to locally connected PS2 HDD 3 | * $Id: hio_win32.h,v 1.6 2006/09/01 17:26:29 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_HIO_WIN32_H) 25 | #define _HIO_WIN32_H 26 | 27 | #include "config.h" 28 | #include "hio.h" 29 | #include "dict.h" 30 | 31 | C_START 32 | 33 | /* accepts paths in the following form: 34 | "hdd?:" or "hdd??:" where ? is 0-based device index */ 35 | int hio_win32_probe(const dict_t *config, 36 | const char *path, 37 | /*@special@*/ hio_p_t *hio) /*@allocates *hio@*/ /*@defines *hio@*/; 38 | 39 | C_END 40 | 41 | #endif /* _HIO_WIN32_H defined? */ 42 | -------------------------------------------------------------------------------- /iin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * iin.h 3 | * $Id: iin.h,v 1.10 2006/09/01 17:26:23 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_IIN_H) 25 | #define _IIN_H 26 | 27 | #include "config.h" 28 | #include 29 | #include "dict.h" 30 | 31 | C_START 32 | 33 | #define IIN_SECTOR_SIZE 2048u /* CD/DVD sector size */ 34 | #define IIN_NUM_SECTORS 512u /* number of sectors to read at once */ 35 | 36 | 37 | /* 38 | * ISO input interface below 39 | */ 40 | 41 | typedef struct iin_type iin_t; 42 | typedef /*@only@*/ /*@out@*/ /*@null@*/ iin_t *iin_p_t; 43 | 44 | 45 | typedef int (*iin_stat_t)(iin_t *iin, 46 | /*@out@*/ u_int32_t *sector_size, 47 | /*@out@*/ u_int32_t *num_sectors); 48 | 49 | /* read num_sectors starting from start_sector in an internal buffer; 50 | number of sectors read = *length / IIN_SECTOR_SIZE */ 51 | typedef int (*iin_read_t)(iin_t *iin, 52 | u_int32_t start_sector, 53 | u_int32_t num_sectors, 54 | /*@out@*/ const char **data, 55 | /*@out@*/ u_int32_t *length); 56 | 57 | /* return last error text in a memory buffer, that would be freed by calling iin_dispose_error_t */ 58 | typedef /*@only@*/ char *(*iin_last_error_t)(iin_t *iin); 59 | typedef void (*iin_dispose_error_t)(iin_t *iin, 60 | /*@only@*/ char *error); 61 | 62 | /* iin should not be used after close */ 63 | typedef int (*iin_close_t)(/*@special@*/ /*@only@*/ iin_t *iin) /*@releases iin@*/; 64 | 65 | struct iin_type 66 | { 67 | iin_stat_t stat; 68 | iin_read_t read; 69 | iin_close_t close; 70 | iin_last_error_t last_error; 71 | iin_dispose_error_t dispose_error; 72 | char source_type[36]; 73 | }; 74 | 75 | int iin_probe(const dict_t *dict, 76 | const char *path, 77 | /*@special@*/ iin_p_t *iin) /*@allocates *iin@*/ /*@defines *iin@*/; 78 | 79 | C_END 80 | 81 | #endif /* _IIN_H defined? */ 82 | -------------------------------------------------------------------------------- /iin_aspi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * iin_aspi.c 3 | * $Id: iin_aspi.c,v 1.9 2006/06/18 13:11:19 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include "wnaspi32.h" 29 | #include "iin_aspi.h" 30 | #include "osal.h" 31 | #include "retcodes.h" 32 | #include "iin.h" 33 | #include "aspi_hlio.h" 34 | 35 | 36 | /* that is for a preliminary check only; device is probed anyway */ 37 | #define MAX_HOSTS 15 38 | #define MAX_SCSI_ID 15 39 | #define MAX_LUN 7 40 | 41 | 42 | typedef struct iin_aspi_type 43 | { 44 | iin_t iin; 45 | int host, scsi_id, lun; 46 | u_int32_t size_in_sectors, sector_size; /* cached; can be obtained always, by calling aspi_stat */ 47 | char *unaligned, *buffer; 48 | unsigned long error_code; /* against aspi_... */ 49 | } iin_aspi_t; 50 | 51 | 52 | /**************************************************************/ 53 | static int 54 | aspicd_stat(iin_t *iin, 55 | u_int32_t *sector_size, 56 | u_int32_t *size_in_sectors) 57 | { 58 | const iin_aspi_t *aspi = (const iin_aspi_t *)iin; 59 | *sector_size = aspi->sector_size; 60 | *size_in_sectors = aspi->size_in_sectors; 61 | return (RET_OK); 62 | } 63 | 64 | 65 | /**************************************************************/ 66 | static int 67 | aspicd_read(iin_t *iin, 68 | u_int32_t start_sector, 69 | u_int32_t num_sectors, 70 | const char **data, 71 | u_int32_t *length) 72 | { 73 | iin_aspi_t *aspi = (iin_aspi_t *)iin; 74 | int result; 75 | 76 | /* TODO: divide requests on chunks, of up to 16KB data each */ 77 | result = aspi_read_10(aspi->host, aspi->scsi_id, aspi->lun, 78 | start_sector, (num_sectors * IIN_SECTOR_SIZE + aspi->sector_size - 1) / aspi->sector_size, 79 | aspi->buffer); 80 | if (result == RET_OK) { 81 | *data = aspi->buffer; 82 | *length = num_sectors * IIN_SECTOR_SIZE; 83 | } else { 84 | if (result == RET_ERR) 85 | result = RET_ASPI_ERROR; 86 | aspi->error_code = aspi_get_last_error_code(); 87 | } 88 | return (result); 89 | } 90 | 91 | 92 | /**************************************************************/ 93 | static int 94 | aspicd_close(iin_t *iin) 95 | { 96 | iin_aspi_t *aspi = (iin_aspi_t *)iin; 97 | osal_free(aspi->unaligned); 98 | osal_free(aspi); 99 | aspi_unload(); 100 | return (RET_OK); 101 | } 102 | 103 | 104 | /**************************************************************/ 105 | static char * 106 | aspicd_last_error(iin_t *iin) 107 | { 108 | iin_aspi_t *aspi = (iin_aspi_t *)iin; 109 | return ((char *)aspi_get_error_msg(aspi->error_code)); 110 | } 111 | 112 | 113 | /**************************************************************/ 114 | static void 115 | aspicd_dispose_error(iin_t *iin, 116 | char *error) 117 | { 118 | aspi_dispose_error_msg(error); 119 | } 120 | 121 | 122 | /**************************************************************/ 123 | static iin_t * 124 | aspicd_alloc(int host, int scsi_id, int lun, 125 | u_int32_t size_in_sectors, 126 | u_int32_t sector_size, 127 | u_int32_t reqd_alignment) 128 | { 129 | iin_aspi_t *aspi; 130 | 131 | /* make data buffer compatible with unbuffered file I/O (should be aligned @ sector size) */ 132 | if (reqd_alignment < 512) 133 | reqd_alignment = 512; 134 | 135 | aspi = (iin_aspi_t *)osal_alloc(sizeof(iin_aspi_t)); 136 | if (aspi != NULL) { 137 | char *tmp = osal_alloc(IIN_NUM_SECTORS * IIN_SECTOR_SIZE + reqd_alignment); 138 | if (tmp != NULL) { 139 | memset(aspi, 0, sizeof(iin_aspi_t)); 140 | aspi->iin.stat = &aspicd_stat; 141 | aspi->iin.read = &aspicd_read; 142 | aspi->iin.close = &aspicd_close; 143 | aspi->iin.last_error = &aspicd_last_error; 144 | aspi->iin.dispose_error = &aspicd_dispose_error; 145 | strcpy(aspi->iin.source_type, "Optical drive via ASPI"); 146 | aspi->host = host; 147 | aspi->scsi_id = scsi_id; 148 | aspi->lun = lun; 149 | aspi->size_in_sectors = size_in_sectors; 150 | aspi->sector_size = sector_size; 151 | aspi->unaligned = tmp; 152 | aspi->buffer = (void *)(((unsigned long)tmp + reqd_alignment - 1) & 153 | ~((unsigned long)reqd_alignment - 1)); 154 | } else { /* unable to allocate read buffer */ 155 | osal_free(aspi); 156 | aspi = NULL; 157 | } 158 | } 159 | return ((iin_t *)aspi); 160 | } 161 | 162 | 163 | /**************************************************************/ 164 | int iin_aspi_probe_path(const char *path, 165 | iin_t **iin) 166 | { 167 | int result = RET_NOT_COMPAT; 168 | int host, scsi_id, lun; 169 | int aspi_init = 0; 170 | 171 | #if 0 172 | if (!dict_get_flag (config, CONFIG_ENABLE_ASPI_FLAG, 0)) 173 | return (result); 174 | #endif 175 | 176 | /* expected pattern is "cd0:2:0" */ 177 | if (tolower(path[0]) == 'c' && 178 | tolower(path[1]) == 'd') { 179 | char *endp; 180 | host = strtol(path + 2, &endp, 10); 181 | if (host >= 0 && host <= MAX_HOSTS && *endp == ':') { 182 | scsi_id = strtol(endp + 1, &endp, 10); 183 | if (scsi_id >= 0 && scsi_id <= MAX_SCSI_ID && *endp == ':') { 184 | lun = strtol(endp + 1, &endp, 10); 185 | if (lun >= 0 && lun <= MAX_LUN && *endp == '\0') 186 | result = RET_OK; 187 | } 188 | } 189 | } 190 | 191 | if (result == RET_OK) { 192 | result = aspi_load(); 193 | aspi_init = result == RET_OK; 194 | } 195 | 196 | if (result == RET_OK) { /* pattern matched */ 197 | u_int32_t size_in_sectors, sector_size; 198 | result = aspi_stat(host, scsi_id, lun, §or_size, &size_in_sectors); 199 | if (result == RET_OK) { /* TODO: inquire SCSI host/device to ask the required alignment */ 200 | *iin = aspicd_alloc(host, scsi_id, lun, 201 | size_in_sectors, sector_size, 202 | 512); 203 | if (iin != NULL) 204 | ; 205 | else 206 | result = RET_NO_MEM; 207 | } else if (result == RET_ERR) 208 | result = RET_ASPI_ERROR; 209 | } 210 | 211 | if (result != RET_OK && aspi_init) 212 | aspi_unload(); 213 | 214 | return (result); 215 | } 216 | -------------------------------------------------------------------------------- /iin_aspi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * iin_aspi.h 3 | * $Id: iin_aspi.h,v 1.7 2006/09/01 17:26:12 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_IIN_ASPI_H) 25 | #define _IIN_ASPI_H 26 | 27 | #include "config.h" 28 | #include "iin.h" 29 | 30 | C_START 31 | 32 | /* would accept "cd0:2:0" */ 33 | int iin_aspi_probe_path(const char *path, 34 | /*@special@*/ iin_p_t *iin) /*@allocates *iin@*/ /*@defines *iin@*/; 35 | 36 | C_END 37 | 38 | #endif /* _IIN_ASPI_H defined? */ 39 | -------------------------------------------------------------------------------- /iin_cdrwin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * iin_cdrwin.h 3 | * $Id: iin_cdrwin.h,v 1.7 2006/09/01 17:25:53 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_IIN_CDRWIN_H) 25 | #define _IIN_CDRWIN_H 26 | 27 | #include "config.h" 28 | #include "iin.h" 29 | 30 | C_START 31 | 32 | /* would accept CDRWIN cuesheet file (.CUE) with a single track 33 | and a single binary data file */ 34 | int iin_cdrwin_probe_path(const char *path, 35 | /*@special@*/ iin_p_t *iin) /*@allocates *iin@*/ /*@defines *iin@*/; 36 | 37 | C_END 38 | 39 | #endif /* _IIN_CDRWIN_H defined? */ 40 | -------------------------------------------------------------------------------- /iin_gi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * iin_gi.h 3 | * $Id: iin_gi.h,v 1.7 2006/09/01 17:25:39 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_IIN_GI_H) 25 | #define _IIN_GI_H 26 | 27 | #include "config.h" 28 | #include "iin.h" 29 | 30 | C_START 31 | 32 | /* would accept GI (Global Image) file one or multiple parts, mode1 or mode2 */ 33 | int iin_gi_probe_path(const char *path, 34 | /*@special@*/ iin_p_t *iin) /*@allocates *iin@*/ /*@defines *iin@*/; 35 | 36 | C_END 37 | 38 | #endif /* _IIN_GI_H defined? */ 39 | -------------------------------------------------------------------------------- /iin_hio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * iin_hio.c, based on iin_net.c, v 1.7 3 | * $Id: iin_hio.h,v 1.1 2006/09/01 17:37:58 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_IIN_HIO_H) 25 | #define _IIN_HIO_H 26 | 27 | #include "config.h" 28 | #include "iin.h" 29 | 30 | C_START 31 | 32 | /* would accept "partition@device" */ 33 | int iin_hio_probe_path(const dict_t *config, 34 | const char *path, 35 | /*@special@*/ iin_p_t *iin) /*@allocates *iin@*/ /*@defines *iin@*/; 36 | 37 | C_END 38 | 39 | #endif /* _IIN_HIO_H defined? */ 40 | -------------------------------------------------------------------------------- /iin_img_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * iin_img_base.h 3 | * $Id: iin_img_base.h,v 1.6 2005/07/10 21:06:48 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_IIN_IMG_BASE_H) 25 | #define _IIN_IMG_BASE_H 26 | 27 | #include "config.h" 28 | #include "iin.h" 29 | #include "osal.h" 30 | 31 | C_START 32 | 33 | typedef struct iin_img_base_type iin_img_base_t; 34 | 35 | iin_img_base_t * 36 | img_base_alloc(u_int32_t raw_sector_size, 37 | u_int32_t raw_skip_offset); 38 | 39 | /* input is guaranteed to be upsized to one sector only (that is if input size is not 40 | aligned on sector size, the rest up to sector size would be zero-filled) */ 41 | int img_base_add_part(iin_img_base_t *img_base, 42 | const char *input_path, 43 | u_int32_t length_s, /* input length in sectors */ 44 | u_int64_t skip, /* bytes to skip in the begining of the input */ 45 | u_int32_t device_sector_size); /* to align reads on */ 46 | 47 | /* gap is only allowed IN THE BEGINING OR BETWEEN files and cannot exist behind the last file */ 48 | void img_base_add_gap(iin_img_base_t *img_base, 49 | u_int32_t length_s); 50 | 51 | C_END 52 | 53 | #endif /* _IIN_IMG_BASE_H defined? */ 54 | -------------------------------------------------------------------------------- /iin_iml.h: -------------------------------------------------------------------------------- 1 | /* 2 | * iin_iml.h 3 | * $Id: iin_iml.h,v 1.7 2006/09/01 17:25:04 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_IIN_IML_H) 25 | #define _IIN_IML_H 26 | 27 | #include "config.h" 28 | #include "iin.h" 29 | 30 | C_START 31 | 32 | /* would accept IML file */ 33 | int iin_iml_probe_path(const char *path, 34 | /*@special@*/ iin_p_t *iin) /*@allocates *iin@*/ /*@defines *iin@*/; 35 | 36 | C_END 37 | 38 | #endif /* _IIN_IML_H defined? */ 39 | -------------------------------------------------------------------------------- /iin_iso.c: -------------------------------------------------------------------------------- 1 | /* 2 | * iin_iso.c 3 | * $Id: iin_iso.c,v 1.11 2006/09/01 17:24:59 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include 25 | #include 26 | #include "iin_iso.h" 27 | #include "iin_img_base.h" 28 | #include "osal.h" 29 | #include "retcodes.h" 30 | 31 | 32 | /**************************************************************/ 33 | int iin_iso_probe_path(const char *path, 34 | iin_t **iin) 35 | { 36 | osal_handle_t file; 37 | u_int32_t size_in_sectors, volume_sector_size; 38 | int result = osal_open(path, &file, 0); /* open with caching enabled */ 39 | if (result == OSAL_OK) { 40 | u_int32_t bytes; 41 | unsigned char buffer[6]; 42 | result = osal_read(file, buffer, sizeof(buffer), &bytes); 43 | if (result == OSAL_OK) { 44 | if (memcmp(buffer, "ZISO", 4)) { /* probe zso, if zso header, skip iso probing */ 45 | /* at offset 0x00008000 there should be "\x01CD001" */ 46 | result = osal_seek(file, (u_int64_t)0x00008000); 47 | if (result == OSAL_OK) { 48 | result = osal_read(file, buffer, sizeof(buffer), &bytes); 49 | if (result == OSAL_OK) { 50 | if (bytes == 6 && 51 | memcmp(buffer, "\001CD001", 6) == 0) 52 | ; /* success */ 53 | else 54 | result = RET_NOT_COMPAT; 55 | } 56 | } 57 | } 58 | } 59 | 60 | size_in_sectors = 0; 61 | if (result == OSAL_OK) { 62 | u_int64_t size_in_bytes; 63 | result = osal_get_file_size(file, &size_in_bytes); 64 | if (result == OSAL_OK) 65 | size_in_sectors = (u_int32_t)(size_in_bytes / 2048); 66 | } 67 | 68 | if (result == OSAL_OK) 69 | result = osal_get_volume_sect_size(path, &volume_sector_size); 70 | 71 | osal_close(&file); 72 | } 73 | 74 | if (result == OSAL_OK) { 75 | iin_img_base_t *img_base = img_base_alloc(2048, 0); 76 | if (img_base != NULL) { 77 | result = img_base_add_part(img_base, path, size_in_sectors, 0, volume_sector_size); 78 | if (result == OSAL_OK) { 79 | *iin = (iin_t *)img_base; 80 | strcpy((*iin)->source_type, "Plain ISO/ZSO file"); 81 | } else 82 | ((iin_t *)img_base)->close((iin_t *)img_base); 83 | } else 84 | result = RET_NO_MEM; 85 | } 86 | return (result); 87 | } 88 | -------------------------------------------------------------------------------- /iin_iso.h: -------------------------------------------------------------------------------- 1 | /* 2 | * iin_iso.h 3 | * $Id: iin_iso.h,v 1.7 2006/09/01 17:24:53 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_IIN_ISO_H) 25 | #define _IIN_ISO_H 26 | 27 | #include "config.h" 28 | #include "iin.h" 29 | 30 | C_START 31 | 32 | /* would accept any plain ISO file */ 33 | int iin_iso_probe_path(const char *path, 34 | /*@special@*/ iin_p_t *iin) /*@allocates *iin@*/ /*@defines *iin@*/; 35 | 36 | C_END 37 | 38 | #endif /* _IIN_ISO_H defined? */ 39 | -------------------------------------------------------------------------------- /iin_nero.h: -------------------------------------------------------------------------------- 1 | /* 2 | * iin_nero.h 3 | * $Id: iin_nero.h,v 1.7 2006/09/01 17:24:38 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_IIN_NERO_H) 25 | #define _IIN_NERO_H 26 | 27 | #include "config.h" 28 | #include "iin.h" 29 | 30 | C_START 31 | 32 | /* would accept Nero image or Nero track; 33 | tested with mode1 plain & RAW and mode2 plain & RAW */ 34 | int iin_nero_probe_path(const char *path, 35 | /*@special@*/ iin_p_t *iin) /*@allocates *iin@*/ /*@defines *iin@*/; 36 | 37 | C_END 38 | 39 | #endif /* _IIN_NERO_H defined? */ 40 | -------------------------------------------------------------------------------- /iin_optical.h: -------------------------------------------------------------------------------- 1 | /* 2 | * iin_optical.h 3 | * $Id: iin_optical.h,v 1.7 2006/09/01 17:24:08 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_IIN_OPTICAL_H) 25 | #define _IIN_OPTICAL_H 26 | 27 | #include "config.h" 28 | #include "iin.h" 29 | 30 | C_START 31 | 32 | /* would accept "cd*:" */ 33 | int iin_optical_probe_path(const char *path, 34 | /*@special@*/ iin_p_t *iin) /*@allocates *iin@*/ /*@defines *iin@*/; 35 | 36 | C_END 37 | 38 | #endif /* _IIN_OPTICAL_H defined? */ 39 | -------------------------------------------------------------------------------- /iin_probe.c: -------------------------------------------------------------------------------- 1 | /* 2 | * iin_probe.c 3 | * $Id: iin_probe.c,v 1.9 2006/09/01 17:24:01 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "iin.h" 25 | #include "iin_optical.h" 26 | #include "iin_spti.h" 27 | #include "iin_aspi.h" 28 | #include "iin_nero.h" 29 | #include "iin_cdrwin.h" 30 | #include "iin_gi.h" 31 | #include "iin_iso.h" 32 | #include "iin_iml.h" 33 | #include "iin_hio.h" 34 | #include "dict.h" 35 | #include "config.h" 36 | #include "retcodes.h" 37 | #if defined(USE_THREADED_IIN) 38 | #include "thd_iin.h" 39 | #endif 40 | 41 | 42 | int iin_probe(const dict_t *config, 43 | const char *path, 44 | iin_t **iin) 45 | { 46 | int result = RET_NOT_COMPAT; 47 | 48 | /* prefix-driven inputs first */ 49 | if (result == RET_NOT_COMPAT) 50 | result = iin_hio_probe_path(config, path, iin); 51 | if (result == RET_NOT_COMPAT) 52 | result = iin_optical_probe_path(path, iin); 53 | #if defined(_BUILD_WIN32) 54 | if (result == RET_NOT_COMPAT) 55 | result = iin_spti_probe_path(path, iin); 56 | /* assume ASPI support enabled */ 57 | if (result == RET_NOT_COMPAT) 58 | result = iin_aspi_probe_path(path, iin); 59 | #endif 60 | 61 | /* file-driven inputs next, ordered by accuracy */ 62 | if (result == RET_NOT_COMPAT) 63 | result = iin_nero_probe_path(path, iin); 64 | if (result == RET_NOT_COMPAT) 65 | result = iin_cdrwin_probe_path(path, iin); 66 | if (result == RET_NOT_COMPAT) 67 | result = iin_gi_probe_path(path, iin); 68 | if (result == RET_NOT_COMPAT) 69 | result = iin_iml_probe_path(path, iin); 70 | if (result == RET_NOT_COMPAT) 71 | result = iin_iso_probe_path(path, iin); 72 | 73 | #if defined(USE_THREADED_IIN) 74 | if (result == RET_OK) { /* wrap in threaded delegate */ 75 | iin_t *tmp = thd_create(*iin); 76 | if (tmp != NULL) 77 | *iin = tmp; 78 | } 79 | #endif /* _BUILD_WIN32 defined? */ 80 | 81 | return (result); 82 | } 83 | -------------------------------------------------------------------------------- /iin_spti.h: -------------------------------------------------------------------------------- 1 | /* 2 | * iin_spti.h 3 | * $Id: iin_spti.h,v 1.1 2006/09/01 17:37:58 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_IIN_SPTI_H) 25 | #define _IIN_SPTI_H 26 | 27 | #include "config.h" 28 | #include "iin.h" 29 | 30 | C_START 31 | 32 | unsigned long spti_get_last_error_code(void); 33 | 34 | const char *spti_get_last_error_msg(void); 35 | 36 | const char *spti_get_error_msg(unsigned long spti_error_code); 37 | 38 | /* would accept a drive letter ("d:", "e:",...) of an optical drive */ 39 | int iin_spti_probe_path(const char *path, 40 | /*@special@*/ iin_p_t *iin) /*@allocates *iin@*/ /*@defines *iin@*/; 41 | 42 | C_END 43 | 44 | #endif /* _IIN_OPTICAL_H defined? */ 45 | -------------------------------------------------------------------------------- /isofs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * isofs.h 3 | * $Id: isofs.h,v 1.8 2006/09/01 17:22:31 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_ISOFS_H) 25 | #define _ISOFS_H 26 | 27 | #include "config.h" 28 | #include "iin.h" 29 | 30 | C_START 31 | 32 | typedef struct ps2_cdvd_info_type 33 | { 34 | enum { 35 | mt_unknown, 36 | mt_cd, 37 | mt_dvd 38 | } media_type; 39 | char volume_id[32 + 1]; 40 | char startup_elf[12 + 1]; 41 | u_int64_t layer_pvd; 42 | } ps2_cdvd_info_t; 43 | 44 | int isofs_get_ps2_cdvd_info(iin_t *iin, 45 | /*@out@*/ ps2_cdvd_info_t *info); 46 | 47 | C_END 48 | 49 | #endif /* _ISOFS_H defined? */ 50 | -------------------------------------------------------------------------------- /list.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israpps/hdl-dump/32c296c69cf9c263fcbe035004aa28c345b3b279/list.ico -------------------------------------------------------------------------------- /mkrel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | make clean 4 | make XC=win clean 5 | 6 | make XC=win RELEASE=yes 7 | 8 | rm -rf rel 9 | mkdir -p rel 10 | mv hdl_dump.exe rel/ 11 | 12 | make XC=win clean 13 | 14 | cd gui 15 | make clean 16 | make XC=win clean 17 | make XC=win RELEASE=yes 18 | mv hdl_dumb.exe ../rel/ 19 | make XC=win clean 20 | cd ../ 21 | 22 | cd rel/ 23 | zip -9 hdl_dumx.zip hdl_* boot.elf 24 | cd ../ 25 | -------------------------------------------------------------------------------- /mkrel_win.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | make clean 4 | 5 | make RELEASE=yes 6 | 7 | rm -rf rel 8 | mkdir -p rel 9 | mv hdl_dump.exe rel/ 10 | 11 | make clean 12 | 13 | cd gui 14 | make clean 15 | make RELEASE=yes 16 | mv hdl_dumb.exe ../rel/ 17 | make clean 18 | cd ../ 19 | 20 | cd rel/ 21 | zip -9 hdl_dumx.zip hdl_* boot.elf README.txt 22 | cd ../ 23 | -------------------------------------------------------------------------------- /mktestimg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $Id: mktestimg,v 1.1 2006-09-01 17:37:58 bobi Exp $ 3 | 4 | # well, maybe fs will need to support sparse files 5 | 6 | IMG_NAME=hdd.img 7 | BACKUP=../mine.toc 8 | 9 | [ -n "$1" ] && BACKUP="$1" 10 | 11 | SIZE=`ls -sk "$BACKUP" | cut "-d " -f1` 12 | SIZE=`echo "$SIZE * 64" | bc` 13 | 14 | rm -f $IMG_NAME 15 | dd if=/dev/zero of=$IMG_NAME bs=1048576 seek=$SIZE count=0 2> /dev/null 16 | ./hdl_dump restore_toc $IMG_NAME $BACKUP 17 | 18 | echo "$IMG_NAME" has been created of virtual size $SIZE KB 19 | -------------------------------------------------------------------------------- /net_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * net_common.c 3 | * $Id: net_common.c,v 1.3 2007-05-12 20:17:15 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if defined(_BUILD_WIN32) 25 | #if defined(_MSC_VER) && defined(_WIN32) 26 | #include /* Microsoft Visual C/C++ compiler */ 27 | #else 28 | #include /* GNU C/C++ compiler */ 29 | #endif 30 | #include 31 | #include 32 | #elif defined(_BUILD_UNIX) 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #endif 40 | #include 41 | #include "byteseq.h" 42 | #include "net_common.h" 43 | #include "retcodes.h" 44 | 45 | 46 | /**************************************************************/ 47 | int recv_exact(int s, 48 | void *buf, 49 | u_int32_t bytes, 50 | int flags) 51 | { 52 | ssize_t total = 0, result = 1; 53 | while (bytes > 0 && result > 0) { 54 | result = recv(s, buf, bytes, flags); 55 | if (result > 0) { 56 | buf = (char *)buf + result; 57 | total += result; 58 | bytes -= result; 59 | } 60 | } 61 | return ((int)(result >= 0 ? total : result)); 62 | } 63 | 64 | 65 | /**************************************************************/ 66 | int send_exact(int s, 67 | const void *buf, 68 | u_int32_t bytes, 69 | int flags) 70 | { 71 | ssize_t total = 0, result = 1; 72 | while (bytes > 0 && result > 0) { 73 | result = send(s, buf, bytes, flags); 74 | if (result > 0) { 75 | buf = (char *)buf + result; 76 | total += result; 77 | bytes -= result; 78 | } 79 | } 80 | return ((int)(result >= 0 ? total : result)); 81 | } 82 | -------------------------------------------------------------------------------- /net_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * net_common.h 3 | * $Id: net_common.h,v 1.1 2005/12/08 20:46:02 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_NET_COMMON_H) 25 | #define _NET_COMMON_H 26 | 27 | #include "config.h" 28 | 29 | int recv_exact(int s, 30 | void *outp, 31 | u_int32_t bytes, 32 | int flags); 33 | 34 | int send_exact(int s, 35 | const void *inp, 36 | u_int32_t bytes, 37 | int flags); 38 | 39 | #endif /* _NET_COMMON_H defined? */ 40 | -------------------------------------------------------------------------------- /net_io.h: -------------------------------------------------------------------------------- 1 | /* 2 | * net_io.h 3 | * $Id: net_io.h,v 1.9 2007-05-12 20:17:30 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_NET_IO_H) 25 | #define _NET_IO_H 26 | 27 | #include "config.h" 28 | #include 29 | 30 | C_START 31 | 32 | #define NET_HIO_SERVER_PORT 12345 /* port where server would listen */ 33 | 34 | /* commands */ 35 | #define CMD_HIO_STAT 0x73746174 /* 'stat'; get HDD size in sectors */ 36 | #define CMD_HIO_READ 0x72656164 /* 'read'; read sectors from HDD */ 37 | #define CMD_HIO_WRITE 0x77726974 /* 'writ'; write sectors to HDD */ 38 | #define CMD_HIO_WRITE_STAT 0x77726973 /* 'wris'; get last write status */ 39 | #define CMD_HIO_FLUSH 0x666c7368 /* 'flsh'; flush write buff */ 40 | #define CMD_HIO_POWEROFF 0x706f7778 /* 'powx'; poweroff system */ 41 | 42 | #define HDD_SECTOR_SIZE 512 /* HDD sector size in bytes */ 43 | #define HDD_NUM_SECTORS 32 /* number of sectors to write at once */ 44 | #define NET_NUM_SECTORS 2048 /* max # of sectors to move via network */ 45 | #define NET_IO_CMD_LEN 16 /* command length in bytes in networking I/O */ 46 | 47 | C_END 48 | 49 | #endif /* _NET_IO_H defined? */ 50 | -------------------------------------------------------------------------------- /ntddscsi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * borrowed from http://members.aol.com/plscsi/tools/gccscsi/ 3 | * 4 | * ntddscsi.h 5 | * 6 | * This source file for Win 2K/XP exists to make: 7 | * 8 | * #include "ntddscsi.h" 9 | * 10 | * work, with both Microsoft Visual C++, and 11 | * also in the gcc of: 12 | * 13 | * http://www.mingw.org/ 14 | * 15 | * Most of the names and the values equated here 16 | * match those you can find in the version of 17 | * Microsoft's "ntddk/inc/ntddscsi.h" that is tagged: 18 | * 19 | * BUILD Version: 0001 20 | * Copyright (c) 1990-1999 Microsoft Corporation 21 | * 22 | * That version in turn matches what you can view 23 | * in such places as: 24 | * 25 | * Windows DDK: System Support for Buses: DeviceIoControl struct SCSI_PASS_THROUGH 26 | * http://msdn.microsoft.com/library/en-us/buses/hh/buses/scsi_struct_34tu.asp 27 | * 28 | * Windows DDK: System Support for Buses: DeviceIoControl struct SCSI_PASS_THROUGH_DIRECT 29 | * http://msdn.microsoft.com/library/en-us/buses/hh/buses/scsi_struct_3qnm.asp 30 | * 31 | * Microsoft's ntddk/ version is more complete. This 32 | * version contains just enough names to make 33 | * DeviceIoControl work, and may be more closely 34 | * tied to the 32-bit versions of Windows. 35 | * 36 | * Microsoft's version also implicitly depends on: 37 | * 38 | * #include 39 | * 40 | * We did try the alternative: -I /ntddk/inc/ 41 | * but we saw an explosion of gcc -Wall complaints 42 | * in , in , etc. 43 | */ 44 | 45 | #ifndef NTDDSCSI_H 46 | #define NTDDSCSI_H NTDDSCSI_H 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | /* Define enough to talk IOCTL_SCSI_PASS_THROUGH. */ 53 | 54 | #define IOCTL_SCSI_PASS_THROUGH 0x4D004 55 | 56 | #define SCSI_IOCTL_DATA_OUT 0 57 | #define SCSI_IOCTL_DATA_IN 1 58 | #define SCSI_IOCTL_DATA_UNSPECIFIED 2 59 | 60 | typedef struct ScsiPassThrough 61 | { 62 | unsigned short Length; /* [x00] */ 63 | unsigned char ScsiStatus; /* [x01] */ 64 | unsigned char PathId; /* [x02] */ 65 | unsigned char TargetId; /* [x03] */ 66 | unsigned char Lun; /* [x04] */ 67 | unsigned char CdbLength; /* [x05] */ 68 | unsigned char SenseInfoLength; /* [x06] */ 69 | unsigned char DataIn; /* [x07] */ 70 | unsigned int DataTransferLength; /* [x0B:0A:09:08] */ 71 | unsigned int TimeOutValue; /* [x0F:0E:0D:0C] */ 72 | unsigned int DataBufferOffset; /* [x13:12:11:10] */ 73 | unsigned int SenseInfoOffset; /* [x17:16:15:14] */ 74 | unsigned char Cdb[16]; /* [x18...x27] */ 75 | } SCSI_PASS_THROUGH; 76 | 77 | /* Define enough more to talk IOCTL_SCSI_PASS_THROUGH_DIRECT. */ 78 | 79 | #define IOCTL_SCSI_PASS_THROUGH_DIRECT 0x4D014 80 | 81 | typedef struct ScsiPassThroughDirect 82 | { 83 | unsigned short Length; 84 | unsigned char ScsiStatus; 85 | unsigned char PathId; 86 | unsigned char TargetId; 87 | unsigned char Lun; 88 | unsigned char CdbLength; 89 | unsigned char SenseInfoLength; 90 | unsigned char DataIn; 91 | unsigned int DataTransferLength; 92 | unsigned int TimeOutValue; 93 | void *DataBuffer; /* [x13:12:11:10] */ 94 | unsigned int SenseInfoOffset; 95 | unsigned char Cdb[16]; 96 | } SCSI_PASS_THROUGH_DIRECT; 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* NTDDSCSI_H defined? */ 103 | -------------------------------------------------------------------------------- /osal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * osal.h 3 | * $Id: osal.h,v 1.13 2006/09/01 17:21:57 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_OSAL_H) 25 | #define _OSAL_H 26 | 27 | #include "config.h" 28 | 29 | C_START 30 | 31 | #if defined(_BUILD_WIN32) 32 | #include 33 | 34 | #elif defined(_BUILD_UNIX) 35 | /* NULL */ 36 | 37 | #else 38 | #error Unsupported platform; Please, modify Makefile 39 | #endif 40 | 41 | 42 | #include "retcodes.h" 43 | #define OSAL_OK RET_OK 44 | #define OSAL_ERR RET_ERR 45 | #define OSAL_NO_MEM RET_NO_MEM 46 | 47 | #define _MB *(1024 * 1024) /* really ugly :-) */ 48 | 49 | 50 | #if defined(_BUILD_WIN32) 51 | typedef HANDLE osal_handle_t; 52 | #define OSAL_HANDLE_INIT 0 53 | #define OSAL_IS_OPENED(x) ((x) != OSAL_HANDLE_INIT) 54 | 55 | #elif defined(_BUILD_UNIX) 56 | 57 | typedef struct 58 | { 59 | int desc; /* file descriptor */ 60 | } osal_handle_t; 61 | 62 | #define OSAL_HANDLE_INIT \ 63 | { \ 64 | -1 \ 65 | } /* file descriptor */ 66 | #define OSAL_IS_OPENED(x) ((x).desc != -1) 67 | 68 | /* This needs to be at least 256 bytes -- see iin_gi_probe_path */ 69 | #define MAX_PATH 1024 70 | 71 | #endif 72 | typedef /*@special@*/ /*@only@*/ /*@out@*/ osal_handle_t *osal_handle_p_t; 73 | 74 | 75 | /* pointer should be passed to osal_dispose_error_msg when no longer needed */ 76 | unsigned long osal_get_last_error_code(void); 77 | /*@special@*/ /*@only@*/ char *osal_get_last_error_msg(void) /*@allocates result@*/ /*@defines result@*/; 78 | /*@special@*/ /*@only@*/ char *osal_get_error_msg(unsigned long error) /*@allocates result@*/ /*@defines result@*/; 79 | void osal_dispose_error_msg(/*@special@*/ /*@only@*/ char *msg) /*@releases msg@*/; 80 | 81 | 82 | int osal_open(const char *name, 83 | /*@special@*/ osal_handle_p_t handle, 84 | int no_cache) /*@allocates handle@*/ /*@defines *handle@*/; 85 | 86 | int osal_open_device_for_writing(const char *device_name, 87 | /*@special@*/ osal_handle_p_t handle) /*@allocates handle@*/ /*@defines *handle@*/; 88 | 89 | int osal_create_file(const char *path, 90 | /*@special@*/ osal_handle_p_t handle, 91 | u_int64_t estimated_size) /*@allocates handle@*/ /*@defines *handle@*/; 92 | 93 | int osal_get_estimated_device_size(osal_handle_t handle, 94 | /*@out@*/ u_int64_t *size_in_bytes); 95 | 96 | int osal_get_device_size(osal_handle_t handle, 97 | /*@out@*/ u_int64_t *size_in_bytes); 98 | 99 | int osal_get_device_sect_size(osal_handle_t handle, 100 | /*@out@*/ u_int32_t *size_in_bytes); 101 | 102 | int osal_get_volume_sect_size(const char *volume_root, 103 | /*@out@*/ u_int32_t *size_in_bytes); 104 | 105 | int osal_get_file_size_ex(const char *path, 106 | /*@out@*/ u_int64_t *size_in_bytes); 107 | 108 | int osal_get_file_size(osal_handle_t handle, 109 | /*@out@*/ u_int64_t *size_in_bytes); 110 | 111 | int osal_seek(osal_handle_t handle, 112 | u_int64_t abs_pos); 113 | 114 | int osal_read(osal_handle_t handle, 115 | /*@out@*/ void *out, 116 | u_int32_t bytes, 117 | /*@out@*/ u_int32_t *stored); 118 | 119 | int osal_write(osal_handle_t handle, 120 | const void *in, 121 | u_int32_t bytes, 122 | /*@out@*/ u_int32_t *stored); 123 | 124 | int osal_close(/*@special@*/ /*@only@*/ osal_handle_t *handle) /*@releases handle@*/; 125 | 126 | 127 | /*@special@*/ /*@only@*/ /*@null@*/ void *osal_alloc(u_int32_t bytes) /*@allocates result@*/; 128 | void osal_free(/*@special@*/ /*@only@*/ void *ptr) /*@releases ptr@*/; 129 | 130 | 131 | /* support for memory-mapped files/devices */ 132 | typedef struct osal_mmap_type osal_mmap_t; 133 | typedef /*@only@*/ /*@out@*/ /*@null@*/ osal_mmap_t *osal_mmap_p_t; 134 | int osal_mmap(/*@special@*/ osal_mmap_p_t *mm, 135 | /*@out@*/ void **p, 136 | osal_handle_t handle, 137 | u_int64_t offset, 138 | u_int32_t length) /*@allocates *mm@*/ /*@defines *mm@*/; 139 | 140 | int osal_munmap(/*@special@*/ /*@only@*/ osal_mmap_t *mm) /*@releases *mm@*/; 141 | 142 | 143 | #define DEV_MAX_NAME_LEN 16 144 | 145 | typedef struct osal_dev_type /* device */ 146 | { 147 | char name[DEV_MAX_NAME_LEN]; 148 | u_int64_t capacity; /* -1 if not ready */ 149 | int is_ps2; 150 | unsigned long status; 151 | } osal_dev_t; 152 | 153 | typedef struct osal_dlist_type /* devices list */ 154 | { 155 | u_int32_t allocated, used; 156 | osal_dev_t *device; 157 | } osal_dlist_t; 158 | typedef /*@only@*/ /*@out@*/ /*@null@*/ osal_dlist_t *osal_dlist_p_t; 159 | 160 | 161 | int osal_query_hard_drives(/*@special@*/ osal_dlist_p_t *hard_drives) /*@allocates *hard_drives@*/ /*@defines *hard_drives@*/; 162 | int osal_query_optical_drives(/*@special@*/ osal_dlist_p_t *optical_drives) /*@allocates *optical_drives@*/ /*@defines *optical_drives@*/; 163 | int osal_query_devices(/*@special@*/ osal_dlist_p_t *hard_drives, 164 | /*@special@*/ osal_dlist_p_t *optical_drives) /*@allocates *hard_drives,*optical_drives@*/ /*@defines *hard_drives,*optical_drives@*/; 165 | void osal_dlist_free(/*@special@*/ /*@only@*/ osal_dlist_t *dlist) /*@releases dlist@*/; 166 | 167 | int /* RET_OK, RET_BAD_FORMAT, RET_BAD_DEVICE */ 168 | osal_map_device_name(const char *input, 169 | /*@out@*/ char output[MAX_PATH]); 170 | 171 | C_END 172 | 173 | #endif /* _OSAL_H defined? */ 174 | -------------------------------------------------------------------------------- /progress.h: -------------------------------------------------------------------------------- 1 | /* 2 | * progress.h 3 | * $Id: progress.h,v 1.11 2006/09/01 17:20:50 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_PROGRESS_H) 25 | #define _PROGRESS_H 26 | 27 | #include "config.h" 28 | #include 29 | 30 | C_START 31 | 32 | /* 33 | * the shorter that is, the faster it will respond to the changes, 34 | * however it will be more inacurate; 35 | * heavily depends on the distance between and height of measurements; 36 | * # measures of 1MB each => track last # megabytes 37 | */ 38 | #define PG_HIST_SIZE 10 39 | 40 | 41 | /* high-resolution timers support */ 42 | #define HIGHRES_TO_SEC 1000000 /* microseconds */ 43 | 44 | #if defined(_BUILD_WIN32) && !defined(_BUILD_WINE) 45 | #include 46 | typedef LARGE_INTEGER highres_time_t; 47 | #endif 48 | 49 | #if defined(_BUILD_UNIX) || defined(_BUILD_WINE) 50 | #include 51 | typedef struct timeval highres_time_t; 52 | #endif 53 | 54 | void highres_time(/*@out@*/ highres_time_t *cl); 55 | u_int64_t highres_time_val(const highres_time_t *cl); 56 | 57 | 58 | typedef struct progress_type progress_t; 59 | 60 | /* returns 0 to continue, other to interrupt */ 61 | typedef int (*progress_cb_t)(progress_t *, void *); 62 | 63 | /* TODO: check overflow with big files */ 64 | struct progress_type 65 | { /* "private" */ 66 | u_int64_t start_, elapsed_; /* highres_time_val */ 67 | u_int64_t offset_; /* of the current block, absolute */ 68 | progress_cb_t progress_cb_; 69 | /*@dependent@*/ void *progress_data_; 70 | int last_elapsed_; /* last time when the estimated has been calculated */ 71 | 72 | /* history/histogram to track current speed */ 73 | struct hist_t 74 | { 75 | u_int32_t how_much; 76 | u_int64_t when; /* highres_time_val */ 77 | } history_[PG_HIST_SIZE]; 78 | u_int32_t hist_pos_; 79 | u_int64_t hist_sum_; /* = select sum (how_much) from history_ */ 80 | 81 | /* last major values when callback has been called */ 82 | int call_pc_completed_, call_elapsed_, call_estimated_, call_remaining_; 83 | 84 | /* "public" */ 85 | u_int64_t total, curr; /* in bytes */ 86 | long avg_bps, curr_bps; /* avg and curr bps (since the begining) */ 87 | int pc_completed; /* in % */ 88 | int elapsed, estimated, remaining; /* in seconds or -1 */ 89 | char elapsed_text[20], estimated_text[20], remaining_text[20]; 90 | }; 91 | 92 | 93 | progress_t *pgs_alloc(progress_cb_t progress_cb, 94 | void *data); 95 | 96 | void pgs_free(progress_t *pgs); 97 | 98 | void pgs_prepare(progress_t *pgs, 99 | u_int64_t total); 100 | 101 | void pgs_chunk_complete(progress_t *pgs); 102 | 103 | int pgs_update(progress_t *pgs, 104 | u_int64_t curr); 105 | 106 | C_END 107 | 108 | #endif /* _PROGRESS_H defined? */ 109 | -------------------------------------------------------------------------------- /ps2_hdd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ps2_hdd.h 3 | * $Id: ps2_hdd.h,v 1.6 2006/06/18 13:12:57 bobi Exp $ 4 | * 5 | * borrowed from ps2fdisk 6 | */ 7 | 8 | #if !defined(_PS2_HDD_H) 9 | #define _PS2_HDD_H 10 | 11 | #include "config.h" 12 | 13 | C_START 14 | 15 | /* Various PS2 partition constants */ 16 | #define PS2_PARTITION_MAGIC "APA" /* "APA\0" */ 17 | #define PS2_PART_IDMAX 32 18 | #define PS2_PART_NAMEMAX 128 19 | #define PS2_PART_MAXSUB 64 /* Maximum # of sub-partitions */ 20 | #define PS2_PART_FLAG_SUB 0x0001 /* Is partition a sub-partition? */ 21 | #define PS2_MBR_VERSION 2 /* Current MBR version */ 22 | #define PS2_MBR_MAGIC "Sony Computer Entertainment Inc." 23 | 24 | /* Partition types */ 25 | #define PS2_MBR_PARTITION 0x0001 26 | #define PS2_SWAP_PARTITION 0x0082 27 | #define PS2_LINUX_PARTITION 0x0083 28 | #define PS2_GAME_PARTITION 0x0100 29 | #define PS2_HDL_PARTITION 0x1337 30 | 31 | /* Date/time descriptor used in on-disk partition header */ 32 | typedef struct ps2fs_datetime_type 33 | { 34 | u_int8_t unused; 35 | u_int8_t sec; 36 | u_int8_t min; 37 | u_int8_t hour; 38 | u_int8_t day; 39 | u_int8_t month; 40 | u_int16_t year; 41 | } ps2fs_datetime_t; 42 | 43 | /* On-disk partition header for a partition */ 44 | typedef struct ps2_partition_header_type 45 | { 46 | u_int32_t checksum; /* Sum of all 256 words, assuming checksum==0 */ 47 | u_int8_t magic[4]; /* PS2_PARTITION_MAGIC */ 48 | u_int32_t next; /* Sector address of next partition */ 49 | u_int32_t prev; /* Sector address of previous partition */ 50 | char id[PS2_PART_IDMAX]; 51 | char unknown1[16]; 52 | u_int32_t start; /* Sector address of this partition */ 53 | u_int32_t length; /* Sector count */ 54 | u_int16_t type; 55 | u_int16_t flags; /* PS2_PART_FLAG_* */ 56 | u_int32_t nsub; /* No. of sub-partitions (stored in main partition) */ 57 | ps2fs_datetime_t created; 58 | u_int32_t main; /* For sub-partitions, main partition sector address */ 59 | u_int32_t number; /* For sub-partitions, sub-partition number */ 60 | u_int32_t modver; 61 | u_int32_t pading1[7]; 62 | char name[PS2_PART_NAMEMAX]; 63 | struct 64 | { 65 | char magic[32]; /* Copyright message in MBR */ 66 | u_int32_t version; 67 | u_int32_t nsector; 68 | ps2fs_datetime_t created; /* Same as for the partition, it seems*/ 69 | u_int32_t data_start; /* Some sort of MBR data; position in sectors*/ 70 | u_int32_t data_len; /* Length also in sectors */ 71 | 72 | char unknown2[72]; 73 | 74 | /* DMS-/ToxicOS-specific */ 75 | char dms_boot_magic[32]; 76 | u_int32_t boot_elf_installed; 77 | u_int32_t boot_elf_lba; 78 | u_int32_t boot_elf_byte_size; 79 | u_int32_t boot_elf_checksum; 80 | u_int32_t boot_elf_virtual_addr; 81 | u_int32_t boot_elf_start_addr; 82 | char unknown3[72 - 12]; 83 | char toxic_magic[8]; 84 | u_int32_t toxic_flags; 85 | } mbr; 86 | struct 87 | { /* Sub-partition data */ 88 | u_int32_t start; /* Sector address */ 89 | u_int32_t length; /* Sector count */ 90 | } subs[PS2_PART_MAXSUB]; 91 | } ps2_partition_header_t; 92 | 93 | C_END 94 | 95 | #endif /* _PS2_HDD_H defined? */ 96 | -------------------------------------------------------------------------------- /retcodes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * retcodes.h 3 | * $Id: retcodes.h,v 1.13 2006/09/01 17:20:42 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_RETCODES_H) 25 | #define _RETCODES_H 26 | 27 | 28 | #define RET_ERR -1 /* error */ 29 | #define RET_NO_MEM -2 /* out-of-memory */ 30 | 31 | #define RET_OK 0 32 | 33 | #define RET_NOT_APA 1 /* not an APA device */ 34 | #define RET_NOT_HDL_PART 2 /* not a HD Loader partition */ 35 | #define RET_NOT_FOUND 3 /* partition is not found */ 36 | #define RET_BAD_FORMAT 4 /* bad device name format */ 37 | #define RET_BAD_DEVICE 5 /* unrecognized device */ 38 | #define RET_NO_SPACE 6 /* not enough free space */ 39 | #define RET_BAD_APA 7 /* something wrong with APA partition */ 40 | #define RET_DIFFERENT 8 /* files are different */ 41 | #define RET_INTERRUPTED 9 /* operation were interrupted */ 42 | #define RET_PART_EXISTS 10 /* partition with such name already exists */ 43 | #define RET_BAD_ISOFS 11 /* not an ISO file system */ 44 | #define RET_NOT_PS_CDVD 12 /* not a Playstation CD/DVD */ 45 | #define RET_BAD_SYSCNF 13 /* system.cnf is not in the expected format */ 46 | #define RET_NOT_COMPAT 14 /* iin probe returns "not compatible" */ 47 | #define RET_NOT_ALLOWED 15 /* operation is not allowed */ 48 | #define RET_BAD_COMPAT 16 /* iin probe is compatible, but the source is bad */ 49 | #define RET_SVR_ERR 17 /* server reported error */ 50 | #define RET_1ST_LONGER 18 /* compare_iin: first input is longer */ 51 | #define RET_2ND_LONGER 19 /* compare_iin: second input is longer */ 52 | #define RET_FILE_NOT_FOUND 20 /* pretty obvious */ 53 | #define RET_BROKEN_LINK 21 /* missing linked file (to an IML or CUE for example) */ 54 | #define RET_CROSS_128GB 22 /* data behind 128GB mark */ 55 | #define RET_ASPI_ERROR 23 /* ASPI error; they are far too many to list here */ 56 | #define RET_NO_DISC_DB 24 /* disc database file could not be found */ 57 | #define RET_NO_DDBENTRY 25 /* there is no entry for that game in the disc database */ 58 | #define RET_DDB_INCOMPATIBLE 26 /* game is incompatible according to disc database */ 59 | #define RET_TIMEOUT 27 /* communication timeout */ 60 | #define RET_PROTO_ERR 28 /* network communication protocol error */ 61 | #define RET_INVARIANT 29 /* invalid internal data state; probably a bug */ 62 | #define RET_SPTI_ERROR 30 /* SPTI error */ 63 | #define RET_MBR_KELF_SIZE 31 /* file size exceeds MAX_MBR_KELF_SIZE */ 64 | #define RET_INVALID_KELF 32 /* Invalid kelf header */ 65 | #define RET_MULTITRACK 33 /* Titles with audio tracks supported only if converted to one cue/bin */ 66 | 67 | #endif /* _RETCODES_H defined? */ 68 | -------------------------------------------------------------------------------- /rsrc.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/israpps/hdl-dump/32c296c69cf9c263fcbe035004aa28c345b3b279/rsrc.rc -------------------------------------------------------------------------------- /scsidefs.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * Name: SCSIDEFS.H 4 | * 5 | * Description: SCSI definitions ('C' Language) 6 | * 7 | * borrowed from PEOp.S. CDVD plug-in source code 8 | * http://sourceforge.net/projects/peops/ 9 | * 10 | ***************************************************************************/ 11 | 12 | #if !defined(_SCSIDEFS_H) 13 | #define _SCSIDEFS_H 14 | 15 | #include 16 | 17 | typedef struct 18 | { 19 | USHORT Length; 20 | UCHAR ScsiStatus; 21 | UCHAR PathId; 22 | UCHAR TargetId; 23 | UCHAR Lun; 24 | UCHAR CdbLength; 25 | UCHAR SenseInfoLength; 26 | UCHAR DataIn; 27 | ULONG DataTransferLength; 28 | ULONG TimeOutValue; 29 | ULONG DataBufferOffset; 30 | ULONG SenseInfoOffset; 31 | UCHAR Cdb[16]; 32 | } SCSI_PASS_THROUGH; 33 | 34 | typedef struct 35 | { 36 | USHORT Length; 37 | UCHAR ScsiStatus; 38 | UCHAR PathId; 39 | UCHAR TargetId; 40 | UCHAR Lun; 41 | UCHAR CdbLength; 42 | UCHAR SenseInfoLength; 43 | UCHAR DataIn; 44 | ULONG DataTransferLength; 45 | ULONG TimeOutValue; 46 | PVOID DataBuffer; 47 | ULONG SenseInfoOffset; 48 | UCHAR Cdb[16]; 49 | } SCSI_PASS_THROUGH_DIRECT; 50 | 51 | typedef struct 52 | { 53 | SCSI_PASS_THROUGH_DIRECT spt; 54 | ULONG Filler; 55 | UCHAR ucSenseBuf[32]; 56 | } SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER; 57 | 58 | typedef struct 59 | { 60 | ULONG Length; 61 | UCHAR PortNumber; 62 | UCHAR PathId; 63 | UCHAR TargetId; 64 | UCHAR Lun; 65 | } SCSI_ADDRESS; 66 | 67 | /* 68 | * constants for DataIn member of SCSI_PASS_THROUGH* structures 69 | */ 70 | #define SCSI_IOCTL_DATA_OUT 0 71 | #define SCSI_IOCTL_DATA_IN 1 72 | #define SCSI_IOCTL_DATA_UNSPECIFIED 2 73 | 74 | /* 75 | * Standard IOCTL define 76 | */ 77 | /*#define CTL_CODE( DevType, Function, Method, Access ) ( \ 78 | ((DevType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \ 79 | )*/ 80 | 81 | 82 | /* 83 | * method codes 84 | */ 85 | #define METHOD_BUFFERED 0 86 | #define METHOD_IN_DIRECT 1 87 | #define METHOD_OUT_DIRECT 2 88 | #define METHOD_NEITHER 3 89 | 90 | /* 91 | * file access values 92 | */ 93 | #define FILE_ANY_ACCESS 0 94 | #define FILE_READ_ACCESS (0x0001) 95 | #define FILE_WRITE_ACCESS (0x0002) 96 | 97 | #define IOCTL_SCSI_BASE 0x00000004 98 | 99 | #define IOCTL_SCSI_PASS_THROUGH_DIRECT \ 100 | CTL_CODE(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, \ 101 | FILE_READ_ACCESS | FILE_WRITE_ACCESS) 102 | 103 | #define IOCTL_SCSI_GET_ADDRESS \ 104 | CTL_CODE(IOCTL_SCSI_BASE, 0x0406, METHOD_BUFFERED, FILE_ANY_ACCESS) 105 | 106 | #endif /* _SCSIDEFS_H defined? */ 107 | -------------------------------------------------------------------------------- /sema.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sema.h 3 | * $Id: sema.h,v 1.1 2006/09/01 17:37:58 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_SEMA_H) 25 | #define _SEMA_H 26 | 27 | /* quick & dirty POSIX semaphores for Win32 */ 28 | #if defined(_BUILD_WIN32) 29 | #include 30 | 31 | typedef struct sema_type 32 | { 33 | HANDLE h; 34 | } sem_t; 35 | 36 | static int 37 | sem_init(sem_t *sem, 38 | int pshared, 39 | unsigned int value) 40 | { 41 | sem->h = CreateSemaphore(NULL, value, 1, NULL); 42 | return (sem->h != NULL ? 0 : -1); 43 | } 44 | 45 | static int 46 | sem_wait(sem_t *sem) 47 | { 48 | return (WaitForSingleObject(sem->h, INFINITE) == WAIT_OBJECT_0 ? 0 : -1); 49 | } 50 | 51 | #if 0 /* warning: `sem_trywait' defined but not used */ 52 | static int 53 | sem_trywait (sem_t *sem) 54 | { 55 | return (WaitForSingleObject (sem->h, 0) == WAIT_OBJECT_0 ? 0 : -1); 56 | } 57 | #endif 58 | 59 | static int 60 | sem_post(sem_t *sem) 61 | { 62 | return (ReleaseSemaphore(sem->h, 1, NULL) != 0 ? 0 : -1); 63 | } 64 | 65 | static int 66 | sem_destroy(sem_t *sem) 67 | { 68 | return (CloseHandle(sem->h) ? 0 : -1); 69 | } 70 | 71 | #elif defined(__MACH__) 72 | #include 73 | 74 | typedef struct sema_type 75 | { 76 | pthread_mutex_t mutex; 77 | pthread_cond_t cond; 78 | unsigned int counter; 79 | } sem_t; 80 | 81 | static int 82 | sem_init(sem_t *sem, 83 | int pshared, 84 | unsigned int value) 85 | { 86 | if (pthread_mutex_init(&sem->mutex, NULL) != 0) 87 | return -1; 88 | if (pthread_cond_init(&sem->cond, NULL) != 0) { 89 | (void)pthread_mutex_destroy(&sem->mutex); 90 | return -1; 91 | } 92 | sem->counter = value; 93 | return 0; 94 | } 95 | 96 | static int 97 | sem_wait(sem_t *sem) 98 | { 99 | if (pthread_mutex_lock(&sem->mutex)) 100 | return -1; 101 | while (sem->counter == 0) 102 | (void)pthread_cond_wait(&sem->cond, &sem->mutex); 103 | --sem->counter; 104 | (void)pthread_mutex_unlock(&sem->mutex); 105 | return 0; 106 | } 107 | 108 | static int 109 | sem_post(sem_t *sem) 110 | { 111 | if (pthread_mutex_lock(&sem->mutex)) 112 | return -1; 113 | ++sem->counter; 114 | (void)pthread_mutex_unlock(&sem->mutex); 115 | if (pthread_cond_signal(&sem->cond)) 116 | return -1; 117 | return 0; 118 | } 119 | 120 | static int 121 | sem_destroy(sem_t *sem) 122 | { 123 | (void)pthread_mutex_destroy(&sem->mutex); 124 | (void)pthread_cond_destroy(&sem->cond); 125 | } 126 | 127 | #endif 128 | 129 | #endif /* _SEMA_H defined? */ 130 | -------------------------------------------------------------------------------- /svr/Makefile: -------------------------------------------------------------------------------- 1 | EE_BIN = IOP_PKTDRV.elf 2 | 3 | IRX_PATH = $(PS2SDK)/iop/irx 4 | PKTDRV_PATH = ./pktdrv 5 | 6 | IOP_OBJS = IOMANX_irx.o FILEXIO_irx.o POWEROFF_irx.o DEV9_irx.o ATAD_irx.o HDD_irx.o SMAP_irx.o NETMAN_irx.o PKTDRV_irx.o 7 | EE_OBJS = main.o ipconfig.o $(IOP_OBJS) 8 | 9 | EE_INCS := -I$(PS2SDK)/sbv/include 10 | EE_LDFLAGS := -L$(PS2SDK)/sbv/lib -s 11 | EE_LIBS = -lpatches -ldebug -lfileXio -lnetman 12 | EE_CFLAGS += -mgpopt -G2 13 | 14 | all: 15 | $(MAKE) -C $(PKTDRV_PATH) 16 | $(MAKE) $(EE_BIN) 17 | 18 | clean: 19 | $(MAKE) -C $(PKTDRV_PATH) clean 20 | rm -f $(EE_BIN) $(EE_OBJS) *_irx.c 21 | 22 | IOMANX_irx.c: $(IRX_PATH)/iomanX.irx 23 | bin2c $(IRX_PATH)/iomanX.irx IOMANX_irx.c IOMANX_irx 24 | 25 | FILEXIO_irx.c: $(IRX_PATH)/fileXio.irx 26 | bin2c $(IRX_PATH)/fileXio.irx FILEXIO_irx.c FILEXIO_irx 27 | 28 | POWEROFF_irx.c: $(IRX_PATH)/poweroff.irx 29 | bin2c $(IRX_PATH)/poweroff.irx POWEROFF_irx.c POWEROFF_irx 30 | 31 | DEV9_irx.c: $(IRX_PATH)/ps2dev9.irx 32 | bin2c $(IRX_PATH)/ps2dev9.irx DEV9_irx.c DEV9_irx 33 | 34 | ATAD_irx.c: $(IRX_PATH)/ps2atad.irx 35 | bin2c $(IRX_PATH)/ps2atad.irx ATAD_irx.c ATAD_irx 36 | 37 | HDD_irx.c: $(IRX_PATH)/ps2hdd.irx 38 | bin2c $(IRX_PATH)/ps2hdd.irx HDD_irx.c HDD_irx 39 | 40 | SMAP_irx.c: $(IRX_PATH)/smap.irx 41 | bin2c $(IRX_PATH)/smap.irx SMAP_irx.c SMAP_irx 42 | 43 | NETMAN_irx.c: $(IRX_PATH)/netman.irx 44 | bin2c $(IRX_PATH)/netman.irx NETMAN_irx.c NETMAN_irx 45 | 46 | PKTDRV_irx.c: $(PKTDRV_PATH)/pktdrv.irx 47 | bin2c $(PKTDRV_PATH)/pktdrv.irx PKTDRV_irx.c PKTDRV_irx 48 | 49 | include $(PS2SDK)/samples/Makefile.pref 50 | include $(PS2SDK)/samples/Makefile.eeglobal 51 | -------------------------------------------------------------------------------- /svr/ipconfig.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "ipconfig.h" 8 | 9 | static char *GetNextToken(char *line, char delimiter) 10 | { 11 | char *field_end = '\0', *result; 12 | static char *current_line = NULL; 13 | 14 | if (line != NULL) { 15 | current_line = line; 16 | } 17 | 18 | while (*current_line == delimiter) 19 | current_line++; 20 | if (current_line[0] != '\0') { 21 | if ((field_end = strchr(current_line, delimiter)) == NULL) { 22 | field_end = ¤t_line[strlen(current_line)]; 23 | } 24 | 25 | *field_end = '\0'; 26 | } 27 | 28 | if (current_line[0] != '\0' && current_line[1] != '\0') { 29 | result = current_line; 30 | current_line = field_end + 1; 31 | } else { 32 | result = NULL; 33 | current_line = NULL; 34 | } 35 | 36 | return result; 37 | } 38 | 39 | int ParseNetAddr(const char *address, unsigned char *octlets) 40 | { 41 | int result; 42 | char address_copy[16], *octlet; 43 | unsigned char i; 44 | 45 | if (strlen(address) < 16) { 46 | strcpy(address_copy, address); 47 | 48 | if ((octlet = strtok(address_copy, ".")) != NULL) { 49 | result = 0; 50 | 51 | octlets[0] = strtoul(octlet, NULL, 10); 52 | for (i = 1; i < 4; i++) { 53 | if ((octlet = strtok(NULL, ".")) == NULL) { 54 | result = EINVAL; 55 | break; 56 | } else 57 | octlets[i] = strtoul(octlet, NULL, 10); 58 | } 59 | } else 60 | result = EINVAL; 61 | } else 62 | result = EINVAL; 63 | 64 | 65 | return result; 66 | } 67 | 68 | int ParseConfig(const char *path, char *ip_address, char *subnet_mask, char *gateway) 69 | { 70 | int fd, result, size; 71 | char *FileBuffer, *line, *field; 72 | unsigned int i; 73 | 74 | if ((fd = fioOpen(path, O_RDONLY)) >= 0) { 75 | size = fioLseek(fd, 0, SEEK_END); 76 | fioLseek(fd, 0, SEEK_SET); 77 | if ((FileBuffer = malloc(size)) != NULL) { 78 | if (fioRead(fd, FileBuffer, size) == size) { 79 | if ((line = strtok(FileBuffer, "\r\n")) != NULL) { 80 | result = EINVAL; 81 | do { 82 | i = 0; 83 | while (line[i] == ' ') 84 | i++; 85 | if (line[i] != '#' && line[i] != '\0') { 86 | if ((field = GetNextToken(line, ' ')) != NULL) { 87 | strncpy(ip_address, field, 15); 88 | ip_address[15] = '\0'; 89 | if ((field = GetNextToken(NULL, ' ')) != NULL) { 90 | strncpy(subnet_mask, field, 15); 91 | subnet_mask[15] = '\0'; 92 | if ((field = GetNextToken(NULL, ' ')) != NULL) { 93 | strncpy(gateway, field, 15); 94 | gateway[15] = '\0'; 95 | result = 0; 96 | break; 97 | } 98 | } 99 | } 100 | } 101 | } while ((line = strtok(NULL, "\r\n")) != NULL); 102 | } else 103 | result = EINVAL; 104 | } else 105 | result = EIO; 106 | 107 | free(FileBuffer); 108 | } else 109 | result = ENOMEM; 110 | 111 | fioClose(fd); 112 | } else 113 | result = fd; 114 | 115 | return result; 116 | } 117 | -------------------------------------------------------------------------------- /svr/ipconfig.h: -------------------------------------------------------------------------------- 1 | int ParseNetAddr(const char *address, unsigned char *octlets); 2 | int ParseConfig(const char *path, char *ip_address, char *subnet_mask, char *gateway); 3 | -------------------------------------------------------------------------------- /svr/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef USING_NETIF_RPC 16 | #include 17 | 18 | #ifdef USING_LWIP_STACK 19 | #include 20 | #endif 21 | 22 | #ifdef USING_LWIP_STACK 23 | #include "hdldsvr.h" 24 | #endif 25 | #endif 26 | 27 | #include "main.h" 28 | #include "ipconfig.h" 29 | 30 | extern unsigned char IOMANX_irx[]; 31 | extern unsigned int size_IOMANX_irx; 32 | 33 | extern unsigned char FILEXIO_irx[]; 34 | extern unsigned int size_FILEXIO_irx; 35 | 36 | extern unsigned char POWEROFF_irx[]; 37 | extern unsigned int size_POWEROFF_irx; 38 | 39 | extern unsigned char DEV9_irx[]; 40 | extern unsigned int size_DEV9_irx; 41 | 42 | extern unsigned char ATAD_irx[]; 43 | extern unsigned int size_ATAD_irx; 44 | 45 | extern unsigned char FILEXIO_irx[]; 46 | extern unsigned int size_FILEXIO_irx; 47 | 48 | extern unsigned char HDD_irx[]; 49 | extern unsigned int size_HDD_irx; 50 | 51 | extern unsigned char SMAP_irx[]; 52 | extern unsigned int size_SMAP_irx; 53 | 54 | extern unsigned char NETMAN_irx[]; 55 | extern unsigned int size_NETMAN_irx; 56 | 57 | #ifndef USING_NETIF_RPC 58 | #ifndef USING_LWIP_STACK 59 | #ifndef USING_SMSTCPIP_STACK 60 | extern unsigned char PKTDRV_irx[]; 61 | extern unsigned int size_PKTDRV_irx; 62 | #else 63 | extern unsigned char SMSTCPIP_irx[]; 64 | extern unsigned int size_SMSTCPIP_irx; 65 | 66 | extern unsigned char HDLDSVR_irx[]; 67 | extern unsigned int size_HDLDSVR_irx; 68 | #endif 69 | #else 70 | extern unsigned char PS2IP141_irx[]; 71 | extern unsigned int size_PS2IP141_irx; 72 | 73 | extern unsigned char HDLDSVR_irx[]; 74 | extern unsigned int size_HDLDSVR_irx; 75 | #endif 76 | #endif 77 | 78 | int main(int argc, char *argv[]) 79 | { 80 | #ifdef USING_LWIP_STACK 81 | #ifdef USING_NETIF_RPC 82 | struct ip_addr IP, NM, GW; 83 | #endif 84 | #endif 85 | char ip_address_str[16], subnet_mask_str[16], gateway_str[16]; 86 | unsigned char ip_address[4], subnet_mask[4], gateway[4]; 87 | 88 | SifInitRpc(0); 89 | 90 | while (!SifIopReset(NULL, 0)) { 91 | }; 92 | while (!SifIopSync()) { 93 | }; 94 | 95 | SifInitRpc(0); 96 | SifInitIopHeap(); 97 | SifLoadFileInit(); 98 | fioInit(); 99 | sbv_patch_enable_lmb(); 100 | 101 | init_scr(); 102 | 103 | scr_printf("\n\tSMAP TEST platform built on "__DATE__ 104 | " "__TIME__ 105 | "\n"); 106 | 107 | SifLoadStartModule("rom0:SIO2MAN", 0, NULL, NULL); 108 | SifLoadStartModule("rom0:MCMAN", 0, NULL, NULL); 109 | 110 | scr_printf("\t\t# Parsing IP configuration..."); 111 | 112 | if (ParseConfig("mc0:/SYS-CONF/IPCONFIG.DAT", ip_address_str, subnet_mask_str, gateway_str) != 0) { 113 | if (ParseConfig("mc1:/SYS-CONF/IPCONFIG.DAT", ip_address_str, subnet_mask_str, gateway_str) != 0) { 114 | strcpy(ip_address_str, "192.168.0.10"); 115 | strcpy(subnet_mask_str, "255.255.255.0"); 116 | strcpy(gateway_str, "192.168.0.1"); 117 | } 118 | } 119 | 120 | ParseNetAddr(ip_address_str, ip_address); 121 | ParseNetAddr(subnet_mask_str, subnet_mask); 122 | ParseNetAddr(gateway_str, gateway); 123 | 124 | scr_printf("\tdone!\n" 125 | "\t\tIP address:\t%u.%u.%u.%u\n" 126 | "\t\tSubnet mask:\t%u.%u.%u.%u\n" 127 | "\t\tGateway:\t\t%u.%u.%u.%u\n", 128 | ip_address[0], ip_address[1], ip_address[2], ip_address[3], subnet_mask[0], subnet_mask[1], subnet_mask[2], subnet_mask[3], gateway[0], gateway[1], gateway[2], gateway[3]); 129 | 130 | scr_printf("\t\t# Loading modules..."); 131 | 132 | SifExecModuleBuffer(IOMANX_irx, size_IOMANX_irx, 0, NULL, NULL); 133 | SifExecModuleBuffer(FILEXIO_irx, size_FILEXIO_irx, 0, NULL, NULL); 134 | SifExecModuleBuffer(POWEROFF_irx, size_POWEROFF_irx, 0, NULL, NULL); 135 | SifExecModuleBuffer(DEV9_irx, size_DEV9_irx, 0, NULL, NULL); 136 | SifExecModuleBuffer(NETMAN_irx, size_NETMAN_irx, 0, NULL, NULL); 137 | SifExecModuleBuffer(SMAP_irx, size_SMAP_irx, 0, NULL, NULL); 138 | SifExecModuleBuffer(ATAD_irx, size_ATAD_irx, 0, NULL, NULL); 139 | SifExecModuleBuffer(HDD_irx, size_HDD_irx, 0, NULL, NULL); 140 | #ifndef USING_NETIF_RPC 141 | char module_args[128]; 142 | unsigned int args_offset = 0; 143 | sprintf(module_args, "-ip=%s", ip_address_str); 144 | args_offset += strlen(&module_args[args_offset]) + 1; 145 | sprintf(&module_args[args_offset], "-netmask=%s", subnet_mask_str); 146 | args_offset += strlen(&module_args[args_offset]) + 1; 147 | sprintf(&module_args[args_offset], "-gateway=%s", gateway_str); 148 | args_offset += strlen(&module_args[args_offset]) + 1; 149 | module_args[args_offset + 1] = '\0'; 150 | #ifdef USING_LWIP_STACK 151 | SifExecModuleBuffer(PS2IP141_irx, size_PS2IP141_irx, args_offset, module_args, NULL); 152 | SifExecModuleBuffer(HDLDSVR_irx, size_HDLDSVR_irx, 0, NULL, NULL); 153 | #elif USING_SMSTCPIP_STACK 154 | SifExecModuleBuffer(SMSTCPIP_irx, size_SMSTCPIP_irx, args_offset, module_args, NULL); 155 | SifExecModuleBuffer(HDLDSVR_irx, size_HDLDSVR_irx, 0, NULL, NULL); 156 | #else 157 | SifExecModuleBuffer(PKTDRV_irx, size_PKTDRV_irx, args_offset, module_args, NULL); 158 | #endif 159 | #endif 160 | 161 | scr_printf("\tdone!\n"); 162 | 163 | SifLoadFileExit(); 164 | SifExitIopHeap(); 165 | fileXioInit(); 166 | 167 | scr_printf("\t\t# System initialized.\n" 168 | "\t\t# Initializing network protocol stack..."); 169 | 170 | #ifdef USING_NETIF_RPC 171 | #ifdef USING_LWIP_STACK 172 | IP4_ADDR(&IP, ip_address[0], ip_address[1], ip_address[2], ip_address[3]); 173 | IP4_ADDR(&NM, subnet_mask[0], subnet_mask[1], subnet_mask[2], subnet_mask[3]); 174 | IP4_ADDR(&GW, gateway[0], gateway[1], gateway[2], gateway[3]); 175 | 176 | InitPS2IP(&IP, &NM, &GW); 177 | 178 | StartServer(); 179 | #else 180 | InitPS2IP(ip_address, subnet_mask, gateway); 181 | #endif 182 | #endif 183 | scr_printf("\tdone!\n" 184 | "\t\t# Startup complete.\n"); 185 | 186 | SleepThread(); 187 | 188 | #ifdef USING_NETIF_RPC 189 | #ifdef USING_LWIP_STACK 190 | ShutdownServer(); 191 | #endif 192 | DeinitPS2IP(); 193 | #endif 194 | 195 | fioExit(); 196 | SifExitRpc(); 197 | return 0; 198 | } 199 | -------------------------------------------------------------------------------- /svr/main.h: -------------------------------------------------------------------------------- 1 | //#define DEBUG_TTY_FEEDBACK /* Comment out to disable debugging messages */ 2 | 3 | #ifdef DEBUG_TTY_FEEDBACK 4 | #define DEBUG_PRINTF(args...) printf(args) 5 | #else 6 | #define DEBUG_PRINTF(args...) 7 | #endif 8 | 9 | //From lwip/err.h and lwip/tcpip.h 10 | 11 | #define ERR_OK 0 //No error, everything OK 12 | #define ERR_CONN -6 //Not connected 13 | #define ERR_IF -11 //Low-level netif error 14 | -------------------------------------------------------------------------------- /svr/pktdrv/Makefile: -------------------------------------------------------------------------------- 1 | IOP_BIN = pktdrv.irx 2 | IOP_OBJS = main.o arp.o eth.o icmp.o ip.o nic.o udp.o svr.o ipconfig.o imports.o 3 | 4 | IOP_INCS += -I$(PS2SDK)/iop/include 5 | IOP_CFLAGS += -Wall -fno-builtin -D_IOP 6 | IOP_LDFLAGS += -s 7 | 8 | all: $(IOP_BIN) 9 | 10 | clean: 11 | rm -f $(IOP_OBJS) $(IOP_BIN) 12 | 13 | include $(PS2SDK)/Defs.make 14 | include Rules.make 15 | -------------------------------------------------------------------------------- /svr/pktdrv/Rules.make: -------------------------------------------------------------------------------- 1 | # _____ ___ ____ ___ ____ 2 | # ____| | ____| | | |____| 3 | # | ___| |____ ___| ____| | \ PS2DEV Open Source Project. 4 | #----------------------------------------------------------------------- 5 | # Copyright 2001-2004. 6 | # Licenced under Academic Free License version 2.0 7 | # Review ps2sdk README & LICENSE files for further details. 8 | 9 | 10 | IOP_CC_VERSION := $(shell $(IOP_CC) -v 2>&1 | sed -n 's/^.*version //p') 11 | 12 | ASFLAGS_TARGET = -mcpu=r3000 13 | 14 | ifeq ($(IOP_CC_VERSION),3.2.2) 15 | CFLAGS_TARGET = -miop 16 | ASFLAGS_TARGET = -march=r3000 17 | LDFLAGS_TARGET = -miop 18 | endif 19 | 20 | IOP_INCS := $(IOP_INCS) -I$(PS2SDK)/iop/include -I$(PS2SDK)/common/include -Iinclude 21 | 22 | IOP_CFLAGS := $(CFLAGS_TARGET) -O2 -G0 -c $(IOP_INCS) $(IOP_CFLAGS) 23 | IOP_ASFLAGS := $(ASFLAGS_TARGET) -EL -G0 $(IOP_ASFLAGS) 24 | IOP_LDFLAGS := $(LDFLAGS_TARGET) -nostdlib $(IOP_LDFLAGS) 25 | 26 | # Externally defined variables: IOP_BIN, IOP_OBJS, IOP_LIB 27 | 28 | %.o : %.c 29 | $(IOP_CC) $(IOP_CFLAGS) $< -o $@ 30 | 31 | %.o : %.s 32 | $(IOP_AS) $(IOP_ASFLAGS) $< -o $@ 33 | 34 | # A rule to build imports.lst. 35 | %.o : %.lst 36 | echo "#include \"irx_imports.h\"" > build-imports.c 37 | cat $< >> build-imports.c 38 | $(IOP_CC) $(IOP_CFLAGS) build-imports.c -o $@ 39 | -rm -f build-imports.c 40 | 41 | # A rule to build exports.tab. 42 | %.o : %.tab 43 | echo "#include \"irx.h\"" > build-exports.c 44 | cat $< >> build-exports.c 45 | $(IOP_CC) $(IOP_CFLAGS) build-exports.c -o $@ 46 | -rm -f build-exports.c 47 | 48 | 49 | $(IOP_BIN) : $(IOP_OBJS) 50 | $(IOP_CC) $(IOP_LDFLAGS) -o $(IOP_BIN) $(IOP_OBJS) $(IOP_LIBS) 51 | 52 | $(IOP_LIB) : $(IOP_OBJS) 53 | $(IOP_AR) cru $(IOP_LIB) $(IOP_OBJS) 54 | 55 | -------------------------------------------------------------------------------- /svr/pktdrv/arp.c: -------------------------------------------------------------------------------- 1 | #include "arp.h" 2 | #include 3 | #include "eth.h" 4 | #include "ip.h" 5 | #include "nic.h" 6 | 7 | static int 8 | arp_request(const arp_frame_t *af) 9 | { 10 | const nt_byte_t *my_ip = ip_address(); 11 | if (NT_IP_EQ(af->arp.dst_ip, my_ip)) { /* schedule ARP reply */ 12 | arp_frame_t tmp __attribute__((aligned(64))); 13 | 14 | arp_frame_t *reply = &tmp; 15 | memset(reply, 0, sizeof(arp_frame_t)); 16 | eth_header(&reply->eth, &af->eth, 0x0806); 17 | 18 | /* arp */ 19 | SET_NT_WORD(reply->arp.hardware_type, 0x0001); 20 | SET_NT_WORD(reply->arp.proto, 0x0800); 21 | reply->arp.hardware_len = 6; 22 | reply->arp.proto_len = 4; 23 | SET_NT_WORD(reply->arp.oper, 0x0002); /* ARP reply */ 24 | COPY_NT_MAC(reply->arp.src_mac, eth_mac()); 25 | COPY_NT_IP(reply->arp.src_ip, my_ip); 26 | COPY_NT_MAC(reply->arp.dst_mac, af->arp.src_mac); 27 | COPY_NT_IP(reply->arp.dst_ip, af->arp.src_ip); 28 | 29 | nic_send_wait(reply, sizeof(arp_frame_t)); 30 | return (0); 31 | } 32 | return (1); 33 | } 34 | 35 | int arp_probe(const void *frame, unsigned int frame_len) 36 | { 37 | int result; 38 | 39 | result = 0; 40 | if (frame_len >= sizeof(arp_frame_t)) { 41 | const arp_frame_t *af = (const arp_frame_t *)frame; 42 | if (IS_NT_WORD(af->eth.eth_type, 0x0806) && 43 | IS_NT_WORD(af->arp.hardware_type, 0x0001) && 44 | IS_NT_WORD(af->arp.proto, 0x0800) && 45 | af->arp.hardware_len == 6 && 46 | af->arp.proto_len == 4) { 47 | switch (GET_NT_WORD(af->arp.oper)) { 48 | case 0x0001: 49 | result = 1; 50 | } 51 | } 52 | } 53 | 54 | return result; 55 | } 56 | 57 | int arp_dispatch(const void *frame, size_t frame_len) 58 | { 59 | int result; 60 | 61 | if (arp_probe(frame, frame_len)) { 62 | result = arp_request((const arp_frame_t *)frame); 63 | } else 64 | result = 1; 65 | 66 | return result; 67 | } 68 | -------------------------------------------------------------------------------- /svr/pktdrv/arp.h: -------------------------------------------------------------------------------- 1 | #if !defined(_ARP_H) 2 | #define _ARP_H 3 | 4 | #include 5 | #include "nettypes.h" 6 | 7 | int arp_probe(const void *frame, unsigned int frame_len); 8 | int arp_dispatch(const void *frame, 9 | size_t frame_len); 10 | 11 | #endif /* _ARP_H defined? */ 12 | -------------------------------------------------------------------------------- /svr/pktdrv/eth.c: -------------------------------------------------------------------------------- 1 | #include "eth.h" 2 | #include 3 | 4 | static nt_mac_t my_mac = {0, 0, 0, 0, 0, 0}; 5 | 6 | 7 | void eth_setup(nt_mac_t mac) 8 | { 9 | memcpy(my_mac, mac, sizeof(nt_mac_t)); 10 | } 11 | 12 | 13 | void eth_header(eth_hdr_t *dst, 14 | const eth_hdr_t *in_reply_to, 15 | unsigned short eth_type) 16 | { 17 | COPY_NT_MAC(dst->dst_mac, in_reply_to->src_mac); 18 | COPY_NT_MAC(dst->src_mac, my_mac); 19 | SET_NT_WORD(dst->eth_type, eth_type); 20 | } 21 | 22 | 23 | const nt_byte_t * 24 | eth_mac(void) 25 | { 26 | return (my_mac); 27 | } 28 | -------------------------------------------------------------------------------- /svr/pktdrv/eth.h: -------------------------------------------------------------------------------- 1 | #if !defined(_ETH_H) 2 | #define _ETH_H 3 | 4 | #include "nettypes.h" 5 | 6 | void eth_setup(nt_mac_t mac); 7 | 8 | void eth_header(eth_hdr_t *dst, 9 | const eth_hdr_t *in_reply_to, 10 | unsigned short eth_type); 11 | 12 | const nt_byte_t *eth_mac(void); 13 | 14 | #endif /* _ETH_H defined? */ 15 | -------------------------------------------------------------------------------- /svr/pktdrv/icmp.c: -------------------------------------------------------------------------------- 1 | #include "icmp.h" 2 | #include 3 | #include "eth.h" 4 | #include "ip.h" 5 | #include "nic.h" 6 | 7 | 8 | static int 9 | icmp_echo_request(const ping_frame_t *pf) 10 | { 11 | const nt_byte_t *my_ip = ip_address(); 12 | if (NT_IP_EQ(pf->ip.dst_ip, my_ip)) { 13 | const size_t ip_tot_len = GET_NT_WORD(pf->ip.tot_len); 14 | const size_t payload_len = ip_tot_len - 20 - 8; /* ip & icmp headers */ 15 | unsigned char tmp[1536] __attribute__((aligned(64))); 16 | nt_word_t cs; 17 | 18 | pong_frame_t *pong = (pong_frame_t *)tmp; 19 | memset(pong, 0, sizeof(pong_frame_t)); 20 | eth_header(&pong->eth, &pf->eth, 0x0800); 21 | 22 | /* IPv4 */ 23 | ip_header(&pong->ip, &pf->ip, 0x01 /* ICMP */, 24 | GET_NT_WORD(pf->ip.tot_len)); 25 | 26 | /* ICMP */ 27 | pong->echo.type = 0x00; /* echo reply */ 28 | pong->echo.code = 0x00; 29 | SET_NT_WORD(pong->echo.hdr_checksum, 0); /* below */ 30 | COPY_NT_WORD(pong->echo.id, pf->echo.id); 31 | COPY_NT_WORD(pong->echo.seq_no, pf->echo.seq_no); 32 | memcpy(pong->echo.data, pf->echo.data, payload_len); 33 | SET_NT_WORD(cs, 0); 34 | COPY_NT_WORD(pong->echo.hdr_checksum, 35 | ip_checksum(&pong->echo, 8 + payload_len, cs)); 36 | 37 | nic_send_wait(pong, sizeof(eth_hdr_t) + ip_tot_len); 38 | 39 | return (0); 40 | } 41 | return (1); 42 | } 43 | 44 | int icmp_probe(const void *frame, unsigned int frame_len) 45 | { 46 | int result; 47 | 48 | result = 0; 49 | if (frame_len >= sizeof(ping_frame_t)) { 50 | const ping_frame_t *pf = (const ping_frame_t *)frame; 51 | if (IS_NT_WORD(pf->eth.eth_type, 0x0800) && 52 | pf->ip.version_and_hdr_len == ((4 << 4) | (5 << 0)) && 53 | pf->ip.diff_serv == 0 && 54 | pf->ip.proto == 0x01 /* ICMP */) { 55 | switch (pf->echo.type) { 56 | case 0x08: 57 | result = 1; 58 | } 59 | } 60 | } 61 | 62 | return result; 63 | } 64 | 65 | int icmp_dispatch(const void *frame, size_t frame_len) 66 | { 67 | int result; 68 | 69 | if (icmp_probe(frame, frame_len)) { 70 | result = icmp_echo_request((const ping_frame_t *)frame); 71 | } else 72 | result = 1; 73 | 74 | return result; 75 | } 76 | -------------------------------------------------------------------------------- /svr/pktdrv/icmp.h: -------------------------------------------------------------------------------- 1 | #if !defined(_ICMP_H) 2 | #define _ICMP_H 3 | 4 | #include 5 | #include "nettypes.h" 6 | 7 | int icmp_probe(const void *frame, unsigned int frame_len); 8 | int icmp_dispatch(const void *frame, 9 | size_t frame_len); 10 | 11 | #endif /* _ICMP_H defined? */ 12 | -------------------------------------------------------------------------------- /svr/pktdrv/imports.lst: -------------------------------------------------------------------------------- 1 | atad_IMPORTS_start 2 | I_ata_device_sector_io 3 | I_ata_get_devinfo 4 | atad_IMPORTS_end 5 | 6 | dev9_IMPORTS_start 7 | I_dev9IntrDisable 8 | I_dev9Shutdown 9 | dev9_IMPORTS_end 10 | 11 | stdio_IMPORTS_start 12 | I_printf 13 | stdio_IMPORTS_end 14 | 15 | sysclib_IMPORTS_start 16 | I_memset 17 | I_memcpy 18 | I_strncmp 19 | I_strlen 20 | I_strcpy 21 | I_strtok 22 | I_strtoul 23 | sysclib_IMPORTS_end 24 | 25 | netman_IMPORTS_start 26 | I_NetManRegisterNetworkStack 27 | I_NetManUnregisterNetworkStack 28 | I_NetManNetIFSendPacket 29 | I_NetManIoctl 30 | netman_IMPORTS_end 31 | -------------------------------------------------------------------------------- /svr/pktdrv/ip.c: -------------------------------------------------------------------------------- 1 | #include "ip.h" 2 | 3 | static nt_ip_t my_ip = {0, 0, 0, 0}; 4 | 5 | void ip_setup(nt_ip_t ip) 6 | { 7 | COPY_NT_IP(my_ip, ip); 8 | } 9 | 10 | 11 | nt_byte_t * 12 | ip_checksum(const void *p, size_t len, nt_word_t checksum) 13 | { 14 | unsigned long tot = 0; 15 | while (len >= 2) { 16 | tot += GET_NT_WORD((unsigned char *)p); 17 | p = (unsigned short *)p + 1; 18 | len -= 2; 19 | } 20 | if (len) 21 | tot += *(unsigned char *)p; 22 | while (tot > 0xffff) 23 | tot = (tot & 0xffff) + (tot >> 16); 24 | tot = ~tot; 25 | SET_NT_WORD(checksum, tot); 26 | return (checksum); 27 | } 28 | 29 | 30 | void ip_header(ip_hdr_t *ip, 31 | const ip_hdr_t *in_reply_to, 32 | nt_byte_t proto, 33 | size_t tot_len) 34 | { 35 | nt_word_t cs; 36 | ip->version_and_hdr_len = (4 << 4) | (5 << 0); 37 | ip->diff_serv = 0; 38 | SET_NT_WORD(ip->tot_len, tot_len); 39 | SET_NT_WORD(ip->id, 0); 40 | SET_NT_WORD(ip->flags_frag_offs, 0); 41 | ip->ttl = in_reply_to->ttl; 42 | ip->proto = proto; 43 | SET_NT_WORD(ip->hdr_checksum, 0); /* below */ 44 | COPY_NT_IP(ip->src_ip, in_reply_to->dst_ip); 45 | COPY_NT_IP(ip->dst_ip, in_reply_to->src_ip); 46 | SET_NT_WORD(cs, 0); 47 | COPY_NT_WORD(ip->hdr_checksum, 48 | ip_checksum(ip, sizeof(ip_hdr_t), cs)); 49 | } 50 | 51 | 52 | const nt_byte_t * 53 | ip_address(void) 54 | { 55 | return (my_ip); 56 | } 57 | -------------------------------------------------------------------------------- /svr/pktdrv/ip.h: -------------------------------------------------------------------------------- 1 | #if !defined(_IP_H) 2 | #define _IP_H 3 | 4 | #include 5 | #include "nettypes.h" 6 | 7 | void ip_setup(nt_ip_t ip); 8 | 9 | nt_byte_t *ip_checksum(const void *p, size_t len, nt_word_t checksum); 10 | 11 | /* set-up IP header */ 12 | void ip_header(ip_hdr_t *ip, 13 | const ip_hdr_t *in_reply_to, 14 | nt_byte_t proto, 15 | size_t tot_len); 16 | 17 | const nt_byte_t *ip_address(void); 18 | 19 | #endif /* _IP_H defined? */ 20 | -------------------------------------------------------------------------------- /svr/pktdrv/ipconfig.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "ipconfig.h" 5 | 6 | int ParseNetAddr(const char *address, unsigned char *octlets) 7 | { 8 | int result; 9 | char address_copy[16], *octlet; 10 | unsigned char i; 11 | 12 | if (strlen(address) < 16) { 13 | strcpy(address_copy, address); 14 | 15 | if ((octlet = strtok(address_copy, ".")) != NULL) { 16 | result = 0; 17 | 18 | octlets[0] = strtoul(octlet, NULL, 10); 19 | for (i = 1; i < 4; i++) { 20 | if ((octlet = strtok(NULL, ".")) == NULL) { 21 | result = EINVAL; 22 | break; 23 | } else 24 | octlets[i] = strtoul(octlet, NULL, 10); 25 | } 26 | } else 27 | result = EINVAL; 28 | } else 29 | result = EINVAL; 30 | 31 | 32 | return result; 33 | } 34 | -------------------------------------------------------------------------------- /svr/pktdrv/ipconfig.h: -------------------------------------------------------------------------------- 1 | int ParseNetAddr(const char *address, unsigned char *octlets); 2 | -------------------------------------------------------------------------------- /svr/pktdrv/irx_imports.h: -------------------------------------------------------------------------------- 1 | #ifndef IOP_IRX_IMPORTS_H 2 | #define IOP_IRX_IMPORTS_H 3 | 4 | #include 5 | 6 | /* Please keep these in alphabetical order! */ 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #endif /* IOP_IRX_IMPORTS_H */ 14 | -------------------------------------------------------------------------------- /svr/pktdrv/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "ipconfig.h" 10 | #include "nic.h" 11 | #include "eth.h" 12 | #include "arp.h" 13 | #include "ip.h" 14 | #include "udp.h" 15 | #include "icmp.h" 16 | #include "svr.h" 17 | 18 | IRX_ID("PKTDRV_stack", 0x00, 0x80); 19 | 20 | static unsigned char FrameBuffer[1600]; 21 | static struct NetManPacketBuffer RxPbuf; 22 | static unsigned int PacketAvailable = 1; 23 | 24 | static void LinkStateUp(void) 25 | { 26 | } 27 | 28 | static void LinkStateDown(void) 29 | { 30 | } 31 | 32 | static struct NetManPacketBuffer *AllocRxPacket(unsigned int size) 33 | { 34 | struct NetManPacketBuffer *result; 35 | 36 | if (PacketAvailable) { 37 | result = &RxPbuf; 38 | result->payload = FrameBuffer; 39 | result->length = size; 40 | PacketAvailable = 0; 41 | } else 42 | result = NULL; 43 | 44 | return result; 45 | } 46 | 47 | static void FreeRxPacket(struct NetManPacketBuffer *packet) 48 | { 49 | PacketAvailable = 1; 50 | } 51 | 52 | static int EnQRxPacket(struct NetManPacketBuffer *packet) 53 | { 54 | return 0; 55 | } 56 | 57 | static int FlushInputQueue(void) 58 | { 59 | if (RxPbuf.length > 0) { 60 | if (icmp_probe(FrameBuffer, RxPbuf.length)) 61 | icmp_dispatch(FrameBuffer, RxPbuf.length); 62 | else if (arp_probe(FrameBuffer, RxPbuf.length)) 63 | arp_dispatch(FrameBuffer, RxPbuf.length); 64 | else if (udp_probe(FrameBuffer, RxPbuf.length)) 65 | udp_dispatch(FrameBuffer, RxPbuf.length); 66 | 67 | RxPbuf.length = 0; 68 | } 69 | 70 | PacketAvailable = 1; 71 | 72 | return 0; 73 | } 74 | 75 | static inline int InitPktDrv(const char *ip_address, const char *subnet_mask, const char *gateway); 76 | 77 | int _start(int argc, char *argv[]) 78 | { 79 | unsigned int i; 80 | unsigned char ip_address[4], subnet_mask[4], gateway[4]; 81 | static struct NetManNetProtStack stack = { 82 | &LinkStateUp, 83 | &LinkStateDown, 84 | &AllocRxPacket, 85 | &FreeRxPacket, 86 | &EnQRxPacket, 87 | &FlushInputQueue}; 88 | 89 | for (i = 1; i < argc; i++) { 90 | // printf("%u: %s\n", i, argv[i]); 91 | if (strncmp("-ip=", argv[i], 4) == 0) { 92 | ParseNetAddr(&argv[i][4], ip_address); 93 | } else if (strncmp("-netmask=", argv[i], 9) == 0) { 94 | ParseNetAddr(&argv[i][9], subnet_mask); 95 | } else if (strncmp("-gateway=", argv[i], 9) == 0) { 96 | ParseNetAddr(&argv[i][9], gateway); 97 | } else 98 | break; 99 | } 100 | 101 | InitPktDrv((const char *)ip_address, (const char *)subnet_mask, (const char *)gateway); 102 | NetManRegisterNetworkStack(&stack); 103 | 104 | return MODULE_RESIDENT_END; 105 | } 106 | 107 | static inline int InitPktDrv(const char *ip_address, const char *subnet_mask, const char *gateway) 108 | { 109 | int retv; 110 | nt_ip_t my_ip; 111 | 112 | if (sizeof(eth_hdr_t) != 14) 113 | return (-1001); 114 | if (sizeof(arp_hdr_t) != 28) 115 | return (-1002); 116 | if (sizeof(ip_hdr_t) != 20) 117 | return (-1003); 118 | if (sizeof(icmp_echo_request_t) != 9) /* because of an extra char[1] */ 119 | return (-1004); 120 | if (sizeof(arp_frame_t) != 42) 121 | return (-1005); 122 | if (sizeof(ping_frame_t) != 43) /* because of icmp_echo_request extra byte */ 123 | return (-1006); 124 | if (sizeof(udp_hdr_t) != 9) /* extra char[1] */ 125 | return (-1007); 126 | if (sizeof(udp_frame_t) != 43) /* extra char[1] in udp_hdr */ 127 | return (-1008); 128 | 129 | eth_setup(nic_get_ethaddr()); 130 | 131 | my_ip[0] = ip_address[0]; 132 | my_ip[1] = ip_address[1]; 133 | my_ip[2] = ip_address[2]; 134 | my_ip[3] = ip_address[3]; 135 | 136 | printf("pktdrv: IP is %u.%u.%u.%u\n", 137 | (unsigned char)my_ip[0], (unsigned char)my_ip[1], (unsigned char)my_ip[2], (unsigned char)my_ip[3]); 138 | 139 | ip_setup(my_ip); 140 | 141 | retv = svr_startup(); 142 | if (retv != 0) { 143 | printf("svr_startup failed with %d.\n", retv); 144 | return (-2); 145 | } 146 | 147 | return (0); 148 | } 149 | -------------------------------------------------------------------------------- /svr/pktdrv/nettypes.h: -------------------------------------------------------------------------------- 1 | #if !defined(_NET_TYPES_H) 2 | #define _NET_TYPES_H 3 | 4 | #if defined(_IOP) || defined(_EE) 5 | #include 6 | #else 7 | #if defined(_WIN32) 8 | typedef unsigned long u32; 9 | typedef unsigned short u16; 10 | #else 11 | #include 12 | typedef uint32_t u32; 13 | typedef uint16_t u16; 14 | #endif 15 | #endif 16 | 17 | #if defined(__cplusplus) 18 | extern "C" { 19 | #endif 20 | 21 | typedef unsigned char nt_byte_t; 22 | typedef unsigned char nt_word_t[2]; 23 | typedef unsigned char nt_dword_t[4]; 24 | typedef unsigned char nt_ip_t[4]; 25 | typedef unsigned char nt_port_t[2]; 26 | typedef unsigned char nt_mac_t[6]; 27 | 28 | #define IS_NT_WORD(src, val) \ 29 | (((src)[0] == (((val) >> 8) & 0xff)) && \ 30 | ((src)[1] == (((val) >> 0) & 0xff))) 31 | 32 | #define NT_WORD_EQ(w1, w2) \ 33 | ((w1)[0] == (w2)[0] && \ 34 | (w1)[1] == (w2)[1]) 35 | 36 | #define GET_NT_WORD(src) \ 37 | ((((u16)(src)[0]) << 8) | \ 38 | (((u16)(src)[1]) << 0)) 39 | 40 | #define SET_NT_WORD(dst, val) \ 41 | (((dst)[0] = (((val) >> 8) & 0xff)), \ 42 | ((dst)[1] = (((val) >> 0) & 0xff))) 43 | 44 | #define COPY_NT_WORD(dst, src) \ 45 | (((dst)[0] = (src)[0]), \ 46 | ((dst)[1] = (src)[1])) 47 | 48 | 49 | #define IS_NT_DWORD(src, val) \ 50 | (((src)[0] == (((val) >> 24) & 0xff)) && \ 51 | ((src)[1] == (((val) >> 16) & 0xff)) && \ 52 | ((src)[2] == (((val) >> 8) & 0xff)) && \ 53 | ((src)[3] == (((val) >> 0) & 0xff))) 54 | 55 | #define NT_DWORD_EQ(dw1, dw2) \ 56 | ((dw1)[0] == (dw2)[0] && \ 57 | (dw1)[1] == (dw2)[1] && \ 58 | (dw1)[2] == (dw2)[2] && \ 59 | (dw1)[3] == (dw2)[3]) 60 | 61 | #define GET_NT_DWORD(src) \ 62 | ((((u32)(src)[0]) << 24) | \ 63 | (((u32)(src)[1]) << 16) | \ 64 | (((u32)(src)[2]) << 8) | \ 65 | (((u32)(src)[3]) << 0)) 66 | 67 | #define SET_NT_DWORD(dst, val) \ 68 | (((dst)[0] = (((val) >> 24) & 0xff)), \ 69 | ((dst)[1] = (((val) >> 16) & 0xff)), \ 70 | ((dst)[2] = (((val) >> 8) & 0xff)), \ 71 | ((dst)[3] = (((val) >> 0) & 0xff))) 72 | 73 | #define COPY_NT_DWORD(dst, src) \ 74 | (((dst)[0] = (src)[0]), \ 75 | ((dst)[1] = (src)[1]), \ 76 | ((dst)[2] = (src)[2]), \ 77 | ((dst)[3] = (src)[3])) 78 | 79 | 80 | #define COPY_NT_MAC(dst, src) \ 81 | do { \ 82 | size_t i; \ 83 | for (i = 0; i < 6; ++i) \ 84 | (dst)[i] = (src)[i]; \ 85 | } while (0) 86 | 87 | #define NT_IP_EQ(ip1, ip2) NT_DWORD_EQ(ip1, ip2) 88 | #define COPY_NT_IP(dst, src) COPY_NT_DWORD(dst, src) 89 | 90 | typedef struct eth_hdr_type 91 | { 92 | nt_mac_t dst_mac; 93 | nt_mac_t src_mac; 94 | nt_word_t eth_type; /* 0x08, 0x06 == ARP, 0x08, 0x00 == IP */ 95 | } __attribute__((packed)) eth_hdr_t; /* 14 bytes */ 96 | 97 | typedef struct arp_hdr_type 98 | { 99 | nt_word_t hardware_type; /* 0x00, 0x01 for Ethernet */ 100 | nt_word_t proto; /* 0x08, 0x00 */ 101 | nt_byte_t hardware_len; /* == 6 */ 102 | nt_byte_t proto_len; /* == 4 */ 103 | nt_word_t oper; 104 | nt_mac_t src_mac; 105 | nt_ip_t src_ip; 106 | nt_mac_t dst_mac; 107 | nt_ip_t dst_ip; 108 | } __attribute__((packed)) arp_hdr_t; /* 28 bytes */ 109 | 110 | typedef struct ip_hdr_type 111 | { 112 | /* header length is in 32-bit words; min 5 (20 bytes), max 15 (60 bytes) */ 113 | nt_byte_t version_and_hdr_len; /* (version << 4) | (len << 0) */ 114 | nt_byte_t diff_serv; 115 | nt_word_t tot_len; /* including header */ 116 | nt_word_t id; 117 | nt_word_t flags_frag_offs; /* flags: 3 bits; frag offs: 13 bits */ 118 | nt_byte_t ttl; 119 | nt_byte_t proto; /* 1: ICMP; 6: TCP; 17: UDP */ 120 | nt_word_t hdr_checksum; 121 | nt_ip_t src_ip; 122 | nt_ip_t dst_ip; 123 | /* optional options, depending on hdr_len */ 124 | } __attribute__((packed)) ip_hdr_t; /* 20 bytes */ 125 | 126 | typedef struct icmp_echo_rr_type 127 | { 128 | nt_byte_t type; /* == 8 for request, 0 for reply */ 129 | nt_byte_t code; /* == 0 */ 130 | nt_word_t hdr_checksum; 131 | nt_word_t id; 132 | nt_word_t seq_no; 133 | nt_byte_t data[1]; /* usually more than 1 byte */ 134 | } __attribute__((packed)) icmp_echo_request_t, icmp_echo_reply_t; /* 8 bytes+ */ 135 | 136 | typedef struct udp_hdr_type 137 | { 138 | nt_word_t src_port; 139 | nt_word_t dst_port; 140 | nt_word_t len; 141 | nt_word_t checksum; 142 | nt_byte_t data[1]; /* usually more than 1 byte */ 143 | } __attribute__((packed)) udp_hdr_t; /* 8 bytes+ */ 144 | 145 | typedef struct arp_frame_type 146 | { 147 | eth_hdr_t eth; 148 | arp_hdr_t arp; 149 | } __attribute__((packed)) arp_frame_t; 150 | 151 | typedef struct ping_frame_type 152 | { 153 | eth_hdr_t eth; 154 | ip_hdr_t ip; 155 | icmp_echo_request_t echo; 156 | } __attribute__((packed)) ping_frame_t, pong_frame_t; 157 | 158 | typedef struct udp_frame_type 159 | { 160 | eth_hdr_t eth; /* 14 bytes */ 161 | ip_hdr_t ip; /* 20 bytes */ 162 | udp_hdr_t udp; /* 8+1 bytes */ 163 | } __attribute__((packed)) udp_frame_t; /* 42 bytes */ 164 | 165 | #if defined(__cplusplus) 166 | } 167 | #endif 168 | 169 | #endif /* _NET_TYPES_H defined? */ 170 | -------------------------------------------------------------------------------- /svr/pktdrv/nic.c: -------------------------------------------------------------------------------- 1 | //PS2 built-in network interface card packet driver (under AFL license) 2 | #include "nic.h" 3 | //#include "storage.h" 4 | #include "stddef.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | struct s_descriptor 11 | { 12 | u16 flag; 13 | u16 zero; 14 | u16 size; 15 | u16 addr; 16 | }; 17 | 18 | struct s_nic 19 | { 20 | struct s_descriptor *rx_descriptors; /* [64] */ 21 | struct s_descriptor *tx_descriptors; /* [64] */ 22 | u8 ethaddr[6]; // keep it aligned on 4 bytes boundary 23 | u16 rx_next_addr; 24 | u16 tx_head_addr; 25 | u16 tx_tail_addr; 26 | u8 rx_next_index; 27 | 28 | /* when tx_head_index != tx_tail_index queued data for send exists */ 29 | u8 tx_head_index; /* [0,63] */ 30 | u8 tx_tail_index; /* [0,63] */ 31 | u8 running; 32 | }; 33 | 34 | static struct s_nic g_nic; 35 | 36 | size_t 37 | nic_get_state(void *buf) 38 | { 39 | memcpy(buf, &g_nic, sizeof(g_nic)); 40 | return (sizeof(g_nic)); 41 | } 42 | 43 | int nic_send(const void *pPacket, int size) 44 | { 45 | // return(SMAPSendPacket(pPacket, size)!=0?1:0); 46 | return (NetManNetIFSendPacket(pPacket, size) != 0 ? 1 : 0); 47 | } 48 | 49 | int nic_send_wait(const void *pPacket, int size) 50 | { 51 | while (nic_send(pPacket, size) == 0) { 52 | } //SMAPWaitTxEnd(); 53 | 54 | return 1; 55 | } 56 | 57 | unsigned char * 58 | nic_get_ethaddr(void) 59 | { 60 | // SMAPGetMACAddress(g_nic.ethaddr); 61 | 62 | NetManIoctl(NETMAN_NETIF_IOCTL_ETH_GET_MAC, NULL, 0, g_nic.ethaddr, sizeof(g_nic.ethaddr)); 63 | 64 | return g_nic.ethaddr; 65 | } 66 | -------------------------------------------------------------------------------- /svr/pktdrv/nic.h: -------------------------------------------------------------------------------- 1 | #ifndef __NIC_H__ 2 | #define __NIC_H__ 3 | 4 | int nic_init(void); 5 | 6 | void nic_quit(void); 7 | 8 | int nic_receive(unsigned char **ppPacket); 9 | 10 | int nic_receive_wait(unsigned char **ppPacket); 11 | 12 | int nic_send(const void *pPacket, int size); 13 | 14 | int nic_send_wait(const void *pPacket, int size); 15 | 16 | unsigned char *nic_get_ethaddr(void); 17 | 18 | /* same as nic_send 19 | * pros: can send out-of-order data (not consecutive bytes) 20 | * cons: each chunk must be multiple to 4 bytes */ 21 | struct schain 22 | { 23 | const struct schain *next; 24 | const void *data; 25 | unsigned short data_len; 26 | }; 27 | /* int nic_send_chain (const struct schain *head); */ 28 | 29 | #endif /* __NIC_H__ defined? */ 30 | -------------------------------------------------------------------------------- /svr/pktdrv/svr.h: -------------------------------------------------------------------------------- 1 | #if !defined(_SVR_H) 2 | #define _SVR_H 3 | 4 | #include "nettypes.h" 5 | 6 | /* sizes for write- and read buffers */ 7 | #define WR_BUF_SIZE 131072 8 | #define RD_BUF_SIZE 32768 9 | 10 | #if ((WR_BUF_SIZE % 512) != 0) || ((RD_BUF_SIZE % 512) != 0) 11 | #error Buffers should be multiple to HDD sector size (512 bytes). 12 | #endif 13 | #if WR_BUF_SIZE < 1024 || RD_BUF_SIZE < 1024 14 | #error Buffer sizes should be at least 1KB. 15 | #endif 16 | 17 | /* however, only the first 3 bytes are used; 4th is seq_no */ 18 | const nt_dword_t svr_magic; 19 | 20 | /* this one is 14 bytes so it will complement ethernet + ip + udp headers 21 | * to be multiple of 4 bytes */ 22 | typedef struct svr_packet 23 | { 24 | nt_byte_t magic[3]; 25 | nt_byte_t seq_no; 26 | nt_dword_t start; 27 | nt_dword_t result; 28 | nt_byte_t command; 29 | nt_byte_t count; 30 | unsigned char data[1]; 31 | } svr_packet; /* 14+ bytes */ 32 | 33 | #define SVR_TEST_MAGIC(p) (p[0] == svr_magic[0] && \ 34 | p[1] == svr_magic[1] && \ 35 | p[2] == svr_magic[2]) 36 | 37 | enum commands { 38 | cmd_stat = 1, 39 | cmd_read = 2, 40 | cmd_write = 3, 41 | cmd_sync = 4, 42 | cmd_shutdown = 5 43 | }; 44 | 45 | int svr_startup(void); 46 | int svr_request(const udp_frame_t *uf); 47 | 48 | #endif /* _SVR_H defined? */ 49 | -------------------------------------------------------------------------------- /svr/pktdrv/udp.c: -------------------------------------------------------------------------------- 1 | #include "udp.h" 2 | #include 3 | #include "eth.h" 4 | #include "ip.h" 5 | #include "nic.h" 6 | #include "svr.h" 7 | 8 | static int 9 | udp_packet(const udp_frame_t *uf) 10 | { 11 | static const size_t MAX_UDP_DATA_LEN = 1500 - sizeof(ip_hdr_t); 12 | const nt_byte_t *my_ip = ip_address(); 13 | if (NT_IP_EQ(uf->ip.dst_ip, my_ip) && 14 | GET_NT_WORD(uf->udp.len) <= MAX_UDP_DATA_LEN) { 15 | if (SVR_TEST_MAGIC(uf->udp.data)) 16 | return (svr_request(uf)); 17 | } 18 | return (1); 19 | } 20 | 21 | int udp_probe(const void *frame, unsigned int frame_len) 22 | { 23 | int result; 24 | 25 | result = 0; 26 | if (frame_len >= sizeof(udp_frame_t)) { 27 | const udp_frame_t *uf = (const udp_frame_t *)frame; 28 | if (IS_NT_WORD(uf->eth.eth_type, 0x0800) && 29 | uf->ip.version_and_hdr_len == ((4 << 4) | (5 << 0)) && 30 | uf->ip.diff_serv == 0 && 31 | uf->ip.proto == 17 /* UDP */ && 32 | (GET_NT_WORD(uf->ip.flags_frag_offs) == 0x0000 || 33 | GET_NT_WORD(uf->ip.flags_frag_offs) == 0x4000 /* don't fragment */)) { 34 | result = 1; 35 | } 36 | } 37 | 38 | return result; 39 | } 40 | 41 | int udp_dispatch(const void *frame, size_t frame_len) 42 | { 43 | int result; 44 | 45 | if (udp_probe(frame, frame_len)) { 46 | result = udp_packet((const udp_frame_t *)frame); 47 | } else 48 | result = 1; 49 | 50 | return result; 51 | } 52 | -------------------------------------------------------------------------------- /svr/pktdrv/udp.h: -------------------------------------------------------------------------------- 1 | #if !defined(_UDP_H) 2 | #define _UDP_H 3 | 4 | #include 5 | #include "nettypes.h" 6 | 7 | int udp_probe(const void *frame, unsigned int frame_len); 8 | int udp_dispatch(const void *frame, size_t frame_len); 9 | 10 | #endif /* _UDP_H defined? */ 11 | -------------------------------------------------------------------------------- /thd_iin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * thd_iin.h 3 | * $Id: thd_iin.h,v 1.1 2006/09/01 17:37:58 bobi Exp $ 4 | * 5 | * Copyright 2004 Bobi B., w1zard0f07@yahoo.com 6 | * 7 | * This file is part of hdl_dump. 8 | * 9 | * hdl_dump is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * hdl_dump is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with hdl_dump; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #if !defined(_THD_IIN_H) 25 | #define _THD_IIN_H 26 | 27 | /* returns a new iin which is tuned for "streaming" (sequential reading); 28 | * current implementation pre-reads sectors in a separate thread */ 29 | iin_t *thd_create(iin_t *worker); 30 | 31 | #endif /* _THD_IIN_H defined? */ 32 | --------------------------------------------------------------------------------