├── Sharpii
├── libWiiSharp.dll
├── WadInstaller.dll
├── Exit Codes.txt
├── Program.cs
├── BNS.cs
├── U8.cs
├── TPL.cs
├── IOS.cs
├── HBC.cs
├── EXT.cs
└── NUSD.cs
├── Sharpii.csproj.user
├── .gitignore
├── .vscode
├── launch.json
└── tasks.json
├── Sharpii.sln
├── Sharpii.csproj
├── README.md
├── .github
└── workflows
│ └── dotnet.yml
└── LICENSE
/Sharpii/libWiiSharp.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheShadowEevee/Sharpii-NetCore/HEAD/Sharpii/libWiiSharp.dll
--------------------------------------------------------------------------------
/Sharpii/WadInstaller.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TheShadowEevee/Sharpii-NetCore/HEAD/Sharpii/WadInstaller.dll
--------------------------------------------------------------------------------
/Sharpii.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3 | ################################################################################
4 |
5 | /.vs
6 | /bin
7 | /obj
8 | /Releases
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | // Use IntelliSense to find out which attributes exist for C# debugging
6 | // Use hover for the description of the existing attributes
7 | // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md
8 | "name": ".NET Core Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceFolder}/bin/Debug/net7.0/win-x64/Sharpii.dll",
14 | "args": [],
15 | "cwd": "${workspaceFolder}",
16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17 | "console": "internalConsole",
18 | "stopAtEntry": false
19 | },
20 | {
21 | "name": ".NET Core Attach",
22 | "type": "coreclr",
23 | "request": "attach"
24 | }
25 | ]
26 | }
--------------------------------------------------------------------------------
/Sharpii.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29709.97
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sharpii", "Sharpii.csproj", "{A5ABD4DA-DBAB-4304-BEB1-A52BC9D6516D}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {A5ABD4DA-DBAB-4304-BEB1-A52BC9D6516D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {A5ABD4DA-DBAB-4304-BEB1-A52BC9D6516D}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {A5ABD4DA-DBAB-4304-BEB1-A52BC9D6516D}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {A5ABD4DA-DBAB-4304-BEB1-A52BC9D6516D}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {D7A37F7C-1238-497F-8B97-F238108BBB4B}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Sharpii.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | true
7 | true
8 | true
9 | link
10 | true
11 | README.md
12 | https://github.com/TheShadowEevee/Sharpii-NetCore
13 | git
14 | Copyright (C) 2013 Person66, Copyright (C) 2020-2025 TheShadowEevee and Sharpii-NetCore Contributors
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | Sharpii\libWiiSharp.dll
24 |
25 |
26 | Sharpii\WadInstaller.dll
27 |
28 |
29 |
30 |
31 |
32 | True
33 | \
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Sharpii .Net Core Port - A command line libWiiSharp tool ported for all OS's
2 |
3 | ## Repo info
4 |
5 | Sharpii is a command line app for windows that person66 made and was ported to .Net by TheShadowEevee, which uses leathl's libWiiSharp to perform tasks such as:
6 |
7 | - Pack, unpack, or edit .wad files
8 | - Pack, and unpack U8 archives
9 | - Patch IOS .wad files with various patches
10 | - Download files from NUS
11 | - Convert a .wav file to .bns, and vice versa
12 | - Convert an image file to a .tpl, and vice versa
13 | - Send a .dol or .wad to the Homebrew Channel over Wi-Fi
14 |
15 | .Net was renamed from .Net Core awhile back but Sharpii .Net doesn't sound as good and much more would be pointless "rebranding" so the name will stay.
16 |
17 | ## Download
18 |
19 | You can download the latest version of Sharpii on the project's releases page:
20 | Releases will have certain executables pre-made. If an executable you need isn't there, you can follow the compilation instructions in the wiki. I will compile this myself for certain people if asked via Discord (Usually for projects such as RC24's Linux patcher.)
21 |
22 | > [!IMPORTANT]
23 | > MacOS users may need to run the following command in the directory Sharpii is downloaded to. See [this issue](https://github.com/TheShadowEevee/Sharpii-NetCore/issues/11) for more information.
24 | > `codesign --sign - --force --preserve-metadata=entitlements,requirements,flags,runtime ./Sharpii`
25 | > Please ensure you replace `./Sharpii` with the full name of the downloaded binary.
26 |
27 | ## Compiling
28 |
29 | To compile, do the following:
30 |
31 | 1. Ensure you have the [.Net SDK](https://github.com/dotnet/core) installed. Sharpii-NetCore is compiled normally with .Net v7.
32 | 2. Run `git clone https://github.com/TheShadowEevee/Sharpii-NetCore`
33 | 3. Move into the new directory and run `dotnet publish -c {type} -r {RID}` replacing `{type}` with Debug or Release and `{RID}` with a valid RID from [here](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog) or [here](https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json).
34 | 4. Binaries are shipped as .7z files on ultra compression.
35 |
36 | ## Issues/Pull Requests
37 |
38 | All issues with this version of Sharpii should go in this fork's issue tracker. I will look into any issue whether it's caused by the port or a remnant from the original iteration of Sharpii. Pull requests are appreciated if they fix an issue, but it may take a bit to review.
39 |
40 | ## Giving Credit
41 |
42 | No credit is needed to use this program! If you do give credit, make sure to put the original creator(s) names first! (person66 for Sharpii, and leathl for libWiiSharp)
43 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "Publish Windows x64",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "publish",
10 | "${workspaceFolder}/Sharpii.csproj",
11 | "-c",
12 | "Release",
13 | "-r",
14 | "win-x64",
15 | "-o",
16 | "${workspaceFolder}/Releases/Sharpii-Windows-x64"
17 | ],
18 | "problemMatcher": "$msCompile"
19 | },
20 | {
21 | "label": "Publish Linux x64",
22 | "command": "dotnet",
23 | "type": "process",
24 | "args": [
25 | "publish",
26 | "${workspaceFolder}/Sharpii.csproj",
27 | "-c",
28 | "Release",
29 | "-r",
30 | "linux-x64",
31 | "-o",
32 | "${workspaceFolder}/Releases/Sharpii-Linux-x64"
33 | ],
34 | "problemMatcher": "$msCompile"
35 | },
36 | {
37 | "label": "Publish Linux ARM",
38 | "command": "dotnet",
39 | "type": "process",
40 | "args": [
41 | "publish",
42 | "${workspaceFolder}/Sharpii.csproj",
43 | "-c",
44 | "Release",
45 | "-r",
46 | "linux-arm",
47 | "-o",
48 | "${workspaceFolder}/Releases/Sharpii-Linux-ARM"
49 | ],
50 | "problemMatcher": "$msCompile"
51 | },
52 | {
53 | "label": "Publish Linux ARM64",
54 | "command": "dotnet",
55 | "type": "process",
56 | "args": [
57 | "publish",
58 | "${workspaceFolder}/Sharpii.csproj",
59 | "-c",
60 | "Release",
61 | "-r",
62 | "linux-arm64",
63 | "-o",
64 | "${workspaceFolder}/Releases/Sharpii-Linux-ARM64"
65 | ],
66 | "problemMatcher": "$msCompile"
67 | },
68 | {
69 | "label": "Publish MacOSX x64",
70 | "command": "dotnet",
71 | "type": "process",
72 | "args": [
73 | "publish",
74 | "${workspaceFolder}/Sharpii.csproj",
75 | "-c",
76 | "Release",
77 | "-r",
78 | "osx-x64",
79 | "-o",
80 | "${workspaceFolder}/Releases/Sharpii-OSX-x64"
81 | ],
82 | "problemMatcher": "$msCompile"
83 | },
84 | {
85 | "label": "Publish MacOSX ARM64",
86 | "command": "dotnet",
87 | "type": "process",
88 | "args": [
89 | "publish",
90 | "${workspaceFolder}/Sharpii.csproj",
91 | "-c",
92 | "Release",
93 | "-r",
94 | "osx-arm64",
95 | "-o",
96 | "${workspaceFolder}/Releases/Sharpii-OSX-ARM64"
97 | ],
98 | "problemMatcher": "$msCompile"
99 | },
100 | {
101 | "label": "build",
102 | "command": "dotnet",
103 | "type": "process",
104 | "args": [
105 | "build",
106 | "${workspaceFolder}/Sharpii.sln",
107 | "/property:GenerateFullPaths=true",
108 | "/consoleloggerparameters:NoSummary"
109 | ],
110 | "problemMatcher": "$msCompile"
111 | },
112 | {
113 | "label": "publish",
114 | "command": "dotnet",
115 | "type": "process",
116 | "args": [
117 | "publish",
118 | "${workspaceFolder}/Sharpii.sln",
119 | "/property:GenerateFullPaths=true",
120 | "/consoleloggerparameters:NoSummary"
121 | ],
122 | "problemMatcher": "$msCompile"
123 | },
124 | {
125 | "label": "watch",
126 | "command": "dotnet",
127 | "type": "process",
128 | "args": [
129 | "watch",
130 | "run",
131 | "--project",
132 | "${workspaceFolder}/Sharpii.sln"
133 | ],
134 | "problemMatcher": "$msCompile"
135 | }
136 | ]
137 | }
--------------------------------------------------------------------------------
/.github/workflows/dotnet.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a .NET project
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3 |
4 | name: Publish Builds
5 |
6 | on:
7 | push:
8 | tags:
9 | - "v*.*.*"
10 |
11 | jobs:
12 | build:
13 |
14 | runs-on: ubuntu-latest
15 |
16 | steps:
17 |
18 | # Setup Build Environment
19 | - uses: actions/checkout@v3
20 | - name: Setup .NET
21 | uses: actions/setup-dotnet@v3
22 | with:
23 | dotnet-version: 7.0.x
24 |
25 | # Create Builds
26 | - name: Publish Windows x64 Build
27 | run: dotnet publish -c Release -r win-x64 -o win-x64
28 | - name: Publish Windows ARM Build
29 | run: dotnet publish -c Release -r win-arm -o win-arm
30 | - name: Publish Windows ARM64 Build
31 | run: dotnet publish -c Release -r win-arm64 -o win-arm64
32 | - name: Publish Linux x64 Build
33 | run: dotnet publish -c Release -r linux-x64 -o linux-x64
34 | - name: Publish Linux ARM Build
35 | run: dotnet publish -c Release -r linux-arm -o linux-arm
36 | - name: Publish Linux ARM64 Build
37 | run: dotnet publish -c Release -r linux-arm64 -o linux-arm64
38 | - name: Publish MacOSX x64 Build
39 | run: dotnet publish -c Release -r osx-x64 -o osx-x64
40 | - name: Publish MacOSX ARM64 Build
41 | run: dotnet publish -c Release -r osx-arm64 -o osx-arm64
42 |
43 | # Package Binaries Into 7zip Archives
44 | - name: Archive Windows x64 Build
45 | run: 7z a -t7z -mx=9 Sharpii-Net-Core-${{ github.ref_name }}-Windows.7z /home/runner/work/Sharpii-NetCore/Sharpii-NetCore/win-x64/Sharpii.exe
46 | - name: Archive Windows ARM Build
47 | run: 7z a -t7z -mx=9 Sharpii-Net-Core-${{ github.ref_name }}-Windows-arm.7z /home/runner/work/Sharpii-NetCore/Sharpii-NetCore/win-arm/Sharpii.exe
48 | - name: Archive Windows ARM64 Build
49 | run: 7z a -t7z -mx=9 Sharpii-Net-Core-${{ github.ref_name }}-Windows-arm64.7z /home/runner/work/Sharpii-NetCore/Sharpii-NetCore/win-arm64/Sharpii.exe
50 | - name: Archive Linux x64 Build
51 | run: 7z a -t7z -mx=9 Sharpii-Net-Core-${{ github.ref_name }}-Linux-x64.7z /home/runner/work/Sharpii-NetCore/Sharpii-NetCore/linux-x64/Sharpii
52 | - name: Archive Linux ARM Build
53 | run: 7z a -t7z -mx=9 Sharpii-Net-Core-${{ github.ref_name }}-Linux-arm.7z /home/runner/work/Sharpii-NetCore/Sharpii-NetCore/linux-arm/Sharpii
54 | - name: Archive Linux ARM64 Build
55 | run: 7z a -t7z -mx=9 Sharpii-Net-Core-${{ github.ref_name }}-Linux-arm64.7z /home/runner/work/Sharpii-NetCore/Sharpii-NetCore/linux-arm64/Sharpii
56 | - name: Archive MacOSX x64 Build
57 | run: 7z a -t7z -mx=9 Sharpii-Net-Core-${{ github.ref_name }}-MacOSX-x64.7z /home/runner/work/Sharpii-NetCore/Sharpii-NetCore/osx-x64/Sharpii
58 | - name: Archive MacOSX ARM64 Build
59 | run: 7z a -t7z -mx=9 Sharpii-Net-Core-${{ github.ref_name }}-MacOSX-arm64.7z /home/runner/work/Sharpii-NetCore/Sharpii-NetCore/osx-arm64/Sharpii
60 |
61 |
62 | # Preform Release Actions
63 | - name: GH Release
64 | uses: softprops/action-gh-release@v0.1.15
65 | with:
66 | fail_on_unmatched_files: true
67 | name: Sharpii .Net Core ${{ github.ref_name }}
68 | body: |
69 | ***A port for the program Sharpii that maintains it and allows it to run on multiple OS's***
70 |
71 | If you can't open the 7z archive, Use 7-zip on Windows. Most unix-like distros should be able to unpack this with `zip`
72 |
73 | > [!IMPORTANT]
74 | > MacOS users may need to run the following command in the directory Sharpii is downloaded to. See [this issue](https://github.com/TheShadowEevee/Sharpii-NetCore/issues/11) for more information.
75 | > `codesign --sign - --force --preserve-metadata=entitlements,requirements,flags,runtime ./Sharpii`
76 | > Please ensure you replace `./Sharpii` with the full name of the downloaded binary.
77 |
78 |
79 | Platform Support and Contribution Info
80 |
81 | **OS Support:**
82 | Windows 7 and up
83 | Mac/OSX 10.12 and up (Sierra [2016] and up) including M1 Silicon Computers
84 | Most up-to-date x64, arm, and arm64 Linux distros
85 |
86 | **Issues and Pull requests:**
87 | When using Sharpii, you may run into errors. If you can't fix the error or can't find a fix, open an issue and I will get to it as soon as possible! If you think an issue is with the original Sharpii, I recommend opening it here anyway as I *might* be able to fix it, and I don't think the original Sharpii will be updated in any way at this point. Pull requests are also accepted and appreciated, as long as they actually fix something.
88 |
89 | Most issues are likely with libWiiSharp instead of Sharpii. If you can tell the difference, feel free to open an issue/PR over at https://github.com/TheShadowEevee/libWiiSharp
90 |
91 |
92 | generate_release_notes: true
93 | token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
94 | draft: true
95 | files: |
96 | Sharpii-Net-Core-${{ github.ref_name }}-Windows.7z
97 | Sharpii-Net-Core-${{ github.ref_name }}-Windows-arm.7z
98 | Sharpii-Net-Core-${{ github.ref_name }}-Windows-arm64.7z
99 | Sharpii-Net-Core-${{ github.ref_name }}-Linux-x64.7z
100 | Sharpii-Net-Core-${{ github.ref_name }}-Linux-arm.7z
101 | Sharpii-Net-Core-${{ github.ref_name }}-Linux-arm64.7z
102 | Sharpii-Net-Core-${{ github.ref_name }}-MacOSX-x64.7z
103 | Sharpii-Net-Core-${{ github.ref_name }}-MacOSX-arm64.7z
104 |
--------------------------------------------------------------------------------
/Sharpii/Exit Codes.txt:
--------------------------------------------------------------------------------
1 | Format of this list:
2 | Exit Code: [Windows Exit Code]/[GNU/Linux and Mac Exit Code]
3 | [Basic Description (Error Code)]
4 | [Description]
5 | [Solution]
6 |
7 | Exit Code: 0
8 | No errors reported/Likely successful exit
9 |
10 | Exit Code: 16001/3
11 | File Access Issue/Missing File. (SHARPII_NET_CORE_xxx_FILE_ERR)
12 | Either the file doesn't exist, or Sharpii doesn't have permission to open it.
13 | Check the file's permissions and that it's in the right place.
14 |
15 | Exit Code: 16002/4
16 | Unknown Error/Untracked Error. (SHARPII_NET_CORE_xxx_UNKNOWN)
17 | An untracked error has occurred.
18 | Use the error text to self-diagnose.
19 |
20 | Exit Code: 16003/5
21 | No IP was provided for remote Wii access. (SHARPII_NET_CORE_HBC_NO_IP)
22 | No IP address was listed for the Wii.
23 | Furthermore, no IP address is saved from previous uses.
24 | If this doesn't help, open an issue on GitHub!
25 |
26 | Exit Code: 16004/6
27 | DOL Flag was used, but no file provided. (SHARPII_NET_CORE_xxx_NO_DOL)
28 | You used the -DOL flag, but no DOL file was provided.
29 | Provide the proper DOL file.
30 |
31 | Exit Code: 16005/7
32 | A Critical DLL (WadInstaller.dll) couldn't be found. (SHARPII_NET_CORE_HBC_MISSING_DLL_WADINSTALLER)
33 | The WadInstaller.dll couldn't be found.
34 | This error SHOULD NOT APPEAR in this Sharpii port.
35 | Open an issue on GitHub!
36 |
37 | Exit Code: 16006/8
38 | IOS Flag was used, but no IOS provided. (SHARPII_NET_CORE_xxx_NO_IOS)
39 | You used the -IOS flag, but no IOS was provided.
40 | Provide a proper IOS.
41 |
42 | Exit Code: 16007/9
43 | IOS Flag was used, but an invalid IOS provided. (SHARPII_NET_CORE_xxx_INVALID_IOS)
44 | You used the -IOS flag, but an invalid IOS was provided.
45 | Provide a proper IOS.
46 |
47 | Exit Code: 16008/10
48 | WAD Flag was used, but no wad provided. (SHARPII_NET_CORE_HBC_NO_WAD)
49 | You used the -WAD flag, but no WAD was provided.
50 | Provide a proper WAD.
51 |
52 | Exit Code: 16009/11
53 | Slot Flag was used, but no slot provided. (SHARPII_NET_CORE_IOS_NO_SLOT)
54 | You used the -SLOT flag, but no slot was provided.
55 | Provide a proper slot.
56 |
57 | Exit Code: 16010/12
58 | Slot Flag was used, but an invalid slot provided. (SHARPII_NET_CORE_xxx_INVALID_SLOT)
59 | You used the -SLOT flag, but an invalid slot was provided.
60 | Provide a proper slot.
61 |
62 | Exit Code: 16011/13
63 | V Flag was used, but no version provided. (SHARPII_NET_CORE_xxx_NO_VERSION)
64 | You used the -V flag, but no version was provided.
65 | Provide a proper version.
66 |
67 | Exit Code: 16012/14
68 | V Flag was used, but an invalid version provided. (SHARPII_NET_CORE_xxx_INVALID_VERSION)
69 | You used the -V flag, but no version was provided.
70 | Provide a proper version.
71 |
72 | Exit Code: 16013/15
73 | O Flag was used, but no output provided. (SHARPII_NET_CORE_xxx_NO_OUTPUT)
74 | You used the -O flag, but no output was provided.
75 | Provide a proper output.
76 |
77 | Exit Code: 16014/16
78 | ID Flag was used, but no id provided. (SHARPII_NET_CORE_xxx_NO_ID)
79 | You used the -ID flag, but no id was provided.
80 | Provide a proper id.
81 |
82 | Exit Code: 16015/17
83 | A Critical DLL (libWiiSharp.dll) couldn't be found. (SHARPII_NET_CORE_MAIN_MISSING_DLL_LIBWIISHARP)
84 | The libWiiSharp.dll couldn't be found.
85 | This error SHOULD NOT APPEAR in this Sharpii port.
86 | Open an issue on GitHub!
87 |
88 | Exit Code: 16016/18
89 | An invalid argument was passed when starting Sharpii. (SHARPII_NET_CORE_xxx_INVALID_ARG)
90 | An invalid argument was provided.
91 | Check the options you are using to start Sharpii.
92 |
93 | Exit Code: 16017/19
94 | FORMAT Flag was used, but no format provided. (SHARPII_NET_CORE_TPL_NO_FORMAT)
95 | You used the -FORMAT flag, but no format was provided.
96 | Provide a proper format.
97 |
98 | Exit Code: 16018/20
99 | FORMAT Flag was used, but invalid format provided. (SHARPII_NET_CORE_TPL_INVALID_FORMAT)
100 | You used the -FORMAT flag, but an invalid format was provided.
101 | Provide a proper format.
102 |
103 | Exit Code: 16019/21
104 | A non U8 archive file was provided. (SHARPII_NET_CORE_U8_NON_U8)
105 | The provided file is not a U8 archive.
106 | Provide a U8 archive.
107 |
108 | Exit Code: 16020/22
109 | Folder Access Issue/Missing Folder. (SHARPII_NET_CORE_xxx_FOLDER_ERR)
110 | Either the folder doesn't exist, or Sharpii doesn't have permission to open it.
111 | Check the folders's permissions and that it's in the right place.
112 |
113 | Exit Code: 16021/23
114 | IMET Flag was used, but no title provided. (SHARPII_NET_CORE_xxx_NO_TITLE
115 | You used the -IMET flag, but no title was provided.
116 | Provide a proper title.
117 |
118 | Exit Code: 16022/24
119 | IMET and IMD5 Flags were used, but only one can be used. (SHARPII_NET_CORE_U8_TWO_HEADERS)
120 | You used the -IMET and -IMD5 flags, but you can't use two headers.
121 | Provide only one flag.
122 |
123 | Exit Code: 16023/25
124 | ID Flag was used, but short ID provided. (SHARPII_NET_CORE_WAD_SHORT_ID)
125 | You used the -ID flag, but the provided id was too short to be correct.
126 | Provide a proper id.
127 |
128 | Exit Code: 16024/26
129 | TYPE or IOS Flag used, but no type provided. (SHARPII_NET_CORE_WAD_NO_TYPE)
130 | You used the -TYPE or -IOS flag, but no type was provided.
131 | Provide a proper type.
132 |
133 | Exit Code: 16025/27
134 | TYPE or IOS Flag used, but provided type unknown. (SHARPII_NET_CORE_WAD_UNKNOWN_TYPE)
135 | You used the -TYPE flag, but an unknown type was provided.
136 | Provide a proper type.
137 |
138 | Exit Code: 16026/28
139 | SOUND Flag used, but no wad provided. (SHARPII_NET_CORE_WAD_NO_SOUND)
140 | You used the -SOUND flag, but no wad file to provide sound was provided.
141 | Provide a proper wad.
142 |
143 | Exit Code: 16027/29
144 | BANNER Flag used, but no wad provided. (SHARPII_NET_CORE_WAD_NO_BANNER)
145 | You used the BANNER flag, but no wad file to provide a banner was provided.
146 | Provide a proper wad.
147 |
148 | Exit Code: 16028/30
149 | ID Flag was used, but invalid id provided. (SHARPII_NET_CORE_xxx_BAD_ID)
150 | You used the -ID flag, but an invalid id was provided.
151 | Provide a proper id.
152 |
153 | Exit Code: 16029/31
154 | Not all files needed to pack a wad are present. (SHARPII_NET_CORE_NUSD_MISSING_FILES)
155 | You need to have all the required .app files, a tmd file, a tik file, and a cert file to pack a wad.
156 | Ensure all files are present.
157 |
158 | Exit Code: 16030/32
159 | Invalid ID or Missing CETK (SHARPII_NET_CORE_NUSD_SERVER_ERROR)
160 | The remote server returned an HTTP error. Check your Title ID.
161 | If you have a CETK file, please place it in the same directory as Sharpii saves the NUS Files to.
162 | The server may also actually be having issues.
163 |
164 | Exit Code: 16031/33
165 | A WebRequest Error has occurred and stopped a NUS download. (SHARPII_NET_CORE_NUSD_WEBREQUEST_FAIL)
166 | A WebRequest Error occurred. This usually means that Sharpii can not properly download and save the file.
167 | Please ensure you have the proper permissions to use the current folder or files.
--------------------------------------------------------------------------------
/Sharpii/Program.cs:
--------------------------------------------------------------------------------
1 | /* This file is part of Sharpii.
2 | * Copyright (C) 2013 Person66
3 | * Copyright (C) 2020-2025 Sharpii-NetCore Contributors
4 | *
5 | * Sharpii is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * Sharpii is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with Sharpii. If not, see .
17 | */
18 |
19 | using System;
20 | using System.IO;
21 | using System.Runtime.InteropServices;
22 |
23 | namespace Sharpii
24 | {
25 | class MainApp
26 | {
27 | static void Main(string[] args)
28 | {
29 | if (args.Length < 1)
30 | {
31 | Help();
32 | Environment.Exit(0);
33 | }
34 |
35 | for (int i = 1; i < args.Length; i++)
36 | {
37 | switch (args[i].ToUpper())
38 | {
39 | case "-QUIET":
40 | BeQuiet.quiet = 1;
41 | break;
42 | case "-Q":
43 | BeQuiet.quiet = 1;
44 | break;
45 | case "-LOTS":
46 | BeQuiet.quiet = 3;
47 | break;
48 | }
49 | }
50 |
51 | string Function = args[0].ToUpper();
52 | bool gotSomewhere = false;
53 |
54 | if (Function == "-H" || Function == "-HELP" || Function == "H" || Function == "HELP")
55 | {
56 | Help();
57 | gotSomewhere = true;
58 | }
59 |
60 | if (Function == "BNS")
61 | {
62 | BNS_Stuff.BNS(args);
63 | gotSomewhere = true;
64 | }
65 |
66 | if (Function == "WAD")
67 | {
68 | WAD_Stuff.WAD(args);
69 | gotSomewhere = true;
70 | }
71 |
72 | if (Function == "TPL")
73 | {
74 | TPL_Stuff.TPL(args);
75 | gotSomewhere = true;
76 | }
77 |
78 | if (Function == "U8")
79 | {
80 | U8_Stuff.U8(args);
81 | gotSomewhere = true;
82 | }
83 |
84 | if (Function == "IOS")
85 | {
86 | IOS_Stuff.IOS(args);
87 | gotSomewhere = true;
88 | }
89 |
90 | if (Function == "NUS" || Function == "NUSD")
91 | {
92 | NUS_Stuff.NUS(args);
93 | gotSomewhere = true;
94 | }
95 |
96 | if (Function == "SENDDOL" || Function == "SENDOL")
97 | {
98 | HBC_Stuff.SendDol(args);
99 | gotSomewhere = true;
100 | }
101 |
102 | if (Function == "SENDWAD")
103 | {
104 | bool cont = HBC_Stuff.SendWad_Check(args);
105 | if (cont == true) HBC_Stuff.SendWad(args);
106 | gotSomewhere = true;
107 | }
108 |
109 | if (Function == "ERRORS")
110 | {
111 | ERROR_Stuff.ERROR(args);
112 | gotSomewhere = true;
113 | }
114 |
115 | if (Function == "EXITCODES")
116 | {
117 | ERRORCODE_Stuff.ERRORCODE(args);
118 | gotSomewhere = true;
119 | }
120 |
121 | if (gotSomewhere == false)
122 | {
123 | //If the user gets here, they entered something wrong
124 | Console.WriteLine("ERROR: The argument {0} is invalid", args[0]);
125 | Console.WriteLine("Error: SHARPII_NET_CORE_MAIN_INVALID_ARG");
126 | if (OperatingSystem.Windows())
127 | {
128 | Environment.Exit(0x00003E90);
129 | }
130 | else
131 | {
132 | Environment.Exit(0x00000012);
133 | }
134 | return;
135 | }
136 |
137 | string temp = Path.GetTempPath() + "Sharpii.tmp";
138 | if (Directory.Exists(temp) == true)
139 | DeleteADir.DeleteDirectory(temp);
140 |
141 | Environment.Exit(0);
142 | }
143 |
144 | private static void Help()
145 | {
146 | Console.WriteLine("");
147 | Console.WriteLine("Sharpii .Net Core v{0} - Updated and Maintained by TheShadowEevee, originally by person66", ProgramVersion.version);
148 | Console.WriteLine("Using a modified version of libWiiSharp, originally made by leathl");
149 | Console.WriteLine("");
150 | Console.WriteLine("");
151 | Console.WriteLine(" Usage:");
152 | Console.WriteLine("");
153 | Console.WriteLine(" ./Sharpii [function] [parameters] [-quiet | -q | -lots]");
154 | Console.WriteLine("");
155 | Console.WriteLine("");
156 | Console.WriteLine(" Functions:");
157 | Console.WriteLine("");
158 | Console.WriteLine(" BNS Convert a wav to bns, or vice versa");
159 | Console.WriteLine(" WAD Pack/Unpack/Edit a wad file");
160 | Console.WriteLine(" TPL Convert a image to a tpl, or vice versa");
161 | Console.WriteLine(" U8 Pack/Unpack a U8 archive");
162 | Console.WriteLine(" IOS Apply various patches to an IOS");
163 | Console.WriteLine(" NUSD Download files from NUS");
164 | Console.WriteLine(" SendDol Send a dol to the HBC over wifi");
165 | Console.WriteLine(" SendWad Send a wad to the HBC over wifi");
166 | Console.WriteLine(" Errors Get a Sharpii error's description");
167 | Console.WriteLine(" ExitCodes List of all Sharpii exit codes");
168 | Console.WriteLine("");
169 | Console.WriteLine(" NOTE: To see more detailed descriptions of any of the above,");
170 | Console.WriteLine(" use 'Sharpii [function] -h'");
171 | Console.WriteLine("");
172 | Console.WriteLine("");
173 | Console.WriteLine(" Global Arguments:");
174 | Console.WriteLine("");
175 | Console.WriteLine(" -quiet | -q Try not to display any output");
176 | Console.WriteLine(" -lots Display lots of output");
177 | Console.WriteLine("");
178 | }
179 | }
180 | }
181 | public class DeleteADir
182 | {
183 | public static bool DeleteDirectory(string target_dir)
184 | {
185 | bool result = false;
186 |
187 | string[] files = Directory.GetFiles(target_dir);
188 | string[] dirs = Directory.GetDirectories(target_dir);
189 |
190 | foreach (string file in files)
191 | {
192 | File.SetAttributes(file, FileAttributes.Normal);
193 | File.Delete(file);
194 | }
195 |
196 | foreach (string dir in dirs)
197 | {
198 | DeleteDirectory(dir);
199 | }
200 |
201 | Directory.Delete(target_dir, false);
202 |
203 | return result;
204 | }
205 | }
206 | public class BeQuiet
207 | {
208 | //Little output = 1;
209 | //Normal output = 2;
210 | //Lots of output = 3;
211 | public static int quiet = 2;
212 | }
213 | public class ProgramVersion
214 | {
215 | public static string version = "1.1.9";
216 | }
217 |
218 | public static class OperatingSystem
219 | {
220 | //To check the running OS for Exit Code use.
221 | public static bool Windows() =>
222 | RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
223 |
224 | public static bool Mac() =>
225 | RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
226 |
227 | public static bool GNULinux() =>
228 | RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
229 | }
--------------------------------------------------------------------------------
/Sharpii/BNS.cs:
--------------------------------------------------------------------------------
1 | /* This file is part of Sharpii.
2 | * Copyright (C) 2013 Person66
3 | * Copyright (C) 2020-2025 Sharpii-NetCore Contributors
4 | *
5 | * Sharpii is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * Sharpii is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with Sharpii. If not, see .
17 | */
18 |
19 | using libWiiSharp;
20 | using System;
21 | using System.IO;
22 |
23 | namespace Sharpii
24 | {
25 | partial class BNS_Stuff
26 | {
27 | public static void BNS(string[] args)
28 | {
29 | if (args.Length < 4)
30 | {
31 | Wav2BNS_help();
32 | return;
33 | }
34 |
35 | //********************* To BNS *********************
36 | if (args[1] == "-to")
37 | {
38 | To(args);
39 | return;
40 | }
41 |
42 | if (args[1] == "-from")
43 | {
44 | From(args);
45 | return;
46 | }
47 |
48 | return;
49 | }
50 |
51 | private static void From(string[] args)
52 | {
53 | string input = args[2];
54 | string output = args[3];
55 |
56 | //Check if file exists
57 | if (File.Exists(input) == false)
58 | {
59 | Console.WriteLine("ERROR: Unable to open file: {0}", input);
60 | Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it.");
61 | Console.WriteLine("Error: SHARPII_NET_CORE_BNS_FILE_ERR");
62 | if (OperatingSystem.Windows())
63 | {
64 | Environment.Exit(0x00003E81);
65 | }
66 | else
67 | {
68 | Environment.Exit(0x00000003);
69 | }
70 | return;
71 | }
72 |
73 | //Run main part, and check for exceptions
74 | try
75 | {
76 | //Now convert it
77 | if (BeQuiet.quiet > 2)
78 | Console.Write("Loading file...");
79 |
80 | Wave WavFile = libWiiSharp.BNS.BnsToWave(input);
81 |
82 | if (BeQuiet.quiet > 2)
83 | Console.Write("Done!\n");
84 |
85 | if (BeQuiet.quiet > 2)
86 | Console.Write("Saving wav...");
87 |
88 | if (!output.EndsWith(".wav", StringComparison.OrdinalIgnoreCase))
89 | output += ".wav";
90 |
91 | WavFile.Save(output);
92 |
93 | if (BeQuiet.quiet > 2)
94 | Console.Write("Done!\n");
95 |
96 | if (BeQuiet.quiet > 1)
97 | Console.WriteLine("Operation completed successfully!");
98 | }
99 | catch (Exception ex)
100 | {
101 | Console.WriteLine("An unknown error occurred, please try again");
102 | Console.WriteLine("");
103 | Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
104 | Console.WriteLine("Error: SHARPII_NET_CORE_BNS_UNKNOWN");
105 | if (OperatingSystem.Windows())
106 | {
107 | Environment.Exit(0x00003E82);
108 | }
109 | else
110 | {
111 | Environment.Exit(0x00000004);
112 | }
113 | return;
114 | }
115 | }
116 |
117 | private static void To(string[] args)
118 | {
119 | string input = args[2];
120 | string output = args[3];
121 | bool loop = false;
122 | bool mono = false;
123 |
124 | //Check if file exists
125 | if (File.Exists(input) == false)
126 | {
127 | Console.WriteLine("ERROR: Unable to open file: {0}", input);
128 | Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it.");
129 | Console.WriteLine("Error: SHARPII_NET_CORE_BNS_FILE_ERR");
130 | if (OperatingSystem.Windows())
131 | {
132 | Environment.Exit(0x00003E81);
133 | }
134 | else
135 | {
136 | Environment.Exit(0x00000003);
137 | }
138 | return;
139 | }
140 |
141 | for (int i = 1; i < args.Length; i++)
142 | {
143 | switch (args[i].ToUpper())
144 | {
145 | case "-L":
146 | loop = true;
147 | break;
148 | case "-LOOP":
149 | loop = true;
150 | break;
151 | case "-M":
152 | mono = true;
153 | break;
154 | case "-MONO":
155 | mono = true;
156 | break;
157 | }
158 | }
159 |
160 | //Run main part, and check for exceptions
161 | try
162 | {
163 | if (BeQuiet.quiet > 2)
164 | Console.Write("Loading file...");
165 |
166 | BNS WavFile = new BNS(input);
167 |
168 | if (BeQuiet.quiet > 2)
169 | Console.Write("Done!\n");
170 |
171 | if (loop == true)
172 | {
173 | if (BeQuiet.quiet > 2)
174 | Console.WriteLine("Applying loop");
175 | WavFile.SetLoop(1);
176 | }
177 | if (mono == true)
178 | {
179 | if (BeQuiet.quiet > 2)
180 | Console.WriteLine("Converting to mono");
181 | WavFile.StereoToMono = true;
182 | }
183 |
184 | if (BeQuiet.quiet > 2)
185 | Console.Write("Saving BNS...");
186 |
187 | WavFile.Convert();
188 |
189 | if (!output.EndsWith(".bns", StringComparison.OrdinalIgnoreCase))
190 | output += ".bns";
191 |
192 | WavFile.Save(output);
193 |
194 | if (BeQuiet.quiet > 2)
195 | Console.Write("Done!\n");
196 |
197 | if (BeQuiet.quiet > 1)
198 | Console.WriteLine("Operation completed successfully!");
199 | }
200 | catch (Exception ex)
201 | {
202 | Console.WriteLine("An unknown error occurred, please try again");
203 | Console.WriteLine("");
204 | Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
205 | Console.WriteLine("Error: SHARPII_NET_CORE_BNS_UNKNOWN");
206 | if (OperatingSystem.Windows())
207 | {
208 | Environment.Exit(0x00003E82);
209 | }
210 | else
211 | {
212 | Environment.Exit(0x00000004);
213 | }
214 | return;
215 | }
216 | }
217 |
218 | public static void Wav2BNS_help()
219 | {
220 | Console.WriteLine("");
221 | Console.WriteLine("Sharpii .Net Core v{0} - Ported and Maintained by TheShadowEevee, originally by person66", ProgramVersion.version);
222 | Console.WriteLine("Using a modified version of libWiiSharp, originally made by leathl");
223 | Console.WriteLine("");
224 | Console.WriteLine("");
225 | Console.WriteLine(" Usage:");
226 | Console.WriteLine("");
227 | Console.WriteLine(" ./Sharpii BNS [-to | -from] input.wav output.bns [-l/-loop] [-m/-mono]");
228 | Console.WriteLine("");
229 | Console.WriteLine("");
230 | Console.WriteLine(" Arguments:");
231 | Console.WriteLine("");
232 | Console.WriteLine(" -to Convert wav to bns");
233 | Console.WriteLine(" -from Create wav from bns");
234 | Console.WriteLine(" input.wav The input wave sound file");
235 | Console.WriteLine(" output.bns The output BNS sound file");
236 | Console.WriteLine("");
237 | Console.WriteLine(" Arguments for converting to BNS:");
238 | Console.WriteLine("");
239 | Console.WriteLine(" -l | -loop Creates a looping BNS");
240 | Console.WriteLine(" -m | -mono Convert stereo sound to mono BNS");
241 | }
242 | }
243 | }
244 |
--------------------------------------------------------------------------------
/Sharpii/U8.cs:
--------------------------------------------------------------------------------
1 | /* This file is part of Sharpii.
2 | * Copyright (C) 2013 Person66
3 | * Copyright (C) 2020-2025 Sharpii-NetCore Contributors
4 | *
5 | * Sharpii is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * Sharpii is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with Sharpii. If not, see .
17 | */
18 |
19 | using libWiiSharp;
20 | using System;
21 | using System.IO;
22 |
23 | namespace Sharpii
24 | {
25 | partial class U8_Stuff
26 | {
27 | public static void U8(string[] args)
28 | {
29 | if (args.Length < 4)
30 | {
31 | U8_help();
32 | return;
33 | }
34 |
35 | //********************* Pack *********************
36 | if (args[1] == "-p")
37 | {
38 | Pack(args);
39 | return;
40 | }
41 |
42 | //********************* Unpack *********************
43 | if (args[1] == "-u")
44 | {
45 | Unpack(args);
46 | return;
47 | }
48 |
49 | //If the user gets here, they entered something wrong
50 | Console.WriteLine("ERROR: The argument {0} is invalid", args[1]);
51 | Console.WriteLine("Error: SHARPII_NET_CORE_U8_INVALID_ARG");
52 | if (OperatingSystem.Windows())
53 | {
54 | Environment.Exit(0x00003E90);
55 | }
56 | else
57 | {
58 | Environment.Exit(0x00000012);
59 | }
60 | return;
61 | }
62 |
63 | private static void Unpack(string[] args)
64 | {
65 | string input = args[2];
66 | string output = args[3];
67 |
68 | //Check if file exists
69 | if (File.Exists(input) == false)
70 | {
71 | Console.WriteLine("ERROR: Unable to open file: {0}", input);
72 | Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it.");
73 | Console.WriteLine("Error: SHARPII_NET_CORE_U8_FILE_ERR");
74 | return;
75 | }
76 | //Check if file is U8
77 | if (libWiiSharp.U8.IsU8(input) != true)
78 | {
79 | Console.WriteLine("ERROR: File {0} is not a U8 archive", input);
80 | Console.WriteLine("Error: SHARPII_NET_CORE_U8_NON_U8");
81 | if (OperatingSystem.Windows())
82 | {
83 | Environment.Exit(0x00003E93);
84 | }
85 | else
86 | {
87 | Environment.Exit(0x00000015);
88 | }
89 | return;
90 | }
91 |
92 | //Run main part, and check for exceptions
93 | try
94 | {
95 | //Load U8
96 | U8 U8file = new U8();
97 |
98 | if (BeQuiet.quiet > 2)
99 | Console.Write("Loading file...");
100 |
101 | U8file.LoadFile(input);
102 |
103 | if (BeQuiet.quiet > 2)
104 | Console.Write("Done!\n");
105 |
106 | if (BeQuiet.quiet > 2)
107 | Console.Write("Extracting file...");
108 |
109 | U8file.Extract(output);
110 |
111 | if (BeQuiet.quiet > 2)
112 | Console.Write("Done!\n");
113 |
114 | if (BeQuiet.quiet > 1)
115 | Console.WriteLine("Operation completed successfully!");
116 | }
117 | catch (Exception ex)
118 | {
119 | Console.WriteLine("An unknown error occurred, please try again");
120 | Console.WriteLine("");
121 | Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
122 | Console.WriteLine("Error: SHARPII_NET_CORE_U8_UNKNOWN");
123 | if (OperatingSystem.Windows())
124 | {
125 | Environment.Exit(0x00003E82);
126 | }
127 | else
128 | {
129 | Environment.Exit(0x00000004);
130 | }
131 | return;
132 | }
133 | }
134 |
135 | private static void Pack(string[] args)
136 | {
137 | //Setting up variables
138 | string input = args[2];
139 | string output = args[3];
140 | bool lz77 = false;
141 | bool imd5 = false;
142 | string imet = "";
143 |
144 | //Check if folder exists
145 | if (Directory.Exists(input) == false)
146 | {
147 | Console.WriteLine("ERROR: Unable to open Folder: {0}", input);
148 | Console.WriteLine("Either the folder doesn't exist, or Sharpii doesn't have permission to open it.");
149 | Console.WriteLine("Error: SHARPII_NET_CORE_U8_FOLDER_ERR");
150 | if (OperatingSystem.Windows())
151 | {
152 | Environment.Exit(0x00003E94);
153 | }
154 | else
155 | {
156 | Environment.Exit(0x00000016);
157 | }
158 | return;
159 | }
160 |
161 | for (int i = 1; i < args.Length; i++)
162 | {
163 | switch (args[i].ToUpper())
164 | {
165 | case "-LZ77":
166 | lz77 = true;
167 | break;
168 | case "-IMD5":
169 | imd5 = true;
170 | break;
171 | case "-IMET":
172 | if (i + 1 >= args.Length)
173 | {
174 | Console.WriteLine("ERROR: No title set");
175 | Console.WriteLine("Error: SHARPII_NET_CORE_U8_NO_TITLE");
176 | if (OperatingSystem.Windows())
177 | {
178 | Environment.Exit(0x00003E95);
179 | }
180 | else
181 | {
182 | Environment.Exit(0x00000017);
183 | }
184 | return;
185 | }
186 | imet = args[i + 1];
187 | break;
188 | }
189 | }
190 |
191 | if (imd5 == true && imet != "")
192 | {
193 | Console.WriteLine("ERROR: Cannot use IMET and IMD5 at the same time.");
194 | Console.WriteLine("Error: SHARPII_NET_CORE_U8_TWO_HEADERS");
195 | if (OperatingSystem.Windows())
196 | {
197 | Environment.Exit(0x00003E96);
198 | }
199 | else
200 | {
201 | Environment.Exit(0x00000018);
202 | }
203 | return;
204 | }
205 |
206 | //Run main part, and check for exceptions
207 | try
208 | {
209 | U8 U8folder = new U8();
210 |
211 | if (BeQuiet.quiet > 2)
212 | Console.Write("Loading folder...");
213 |
214 | U8folder.CreateFromDirectory(input);
215 |
216 | if (BeQuiet.quiet > 2)
217 | Console.Write("Done!\n");
218 |
219 | if (imd5 == true)
220 | {
221 | if (BeQuiet.quiet > 2)
222 | Console.WriteLine("Adding IMD5 Header");
223 | U8folder.AddHeaderImd5();
224 | }
225 |
226 | if (imet != "")
227 | {
228 | if (BeQuiet.quiet > 2)
229 | Console.WriteLine("Adding IMET header with title: {0}", imet);
230 | U8folder.AddHeaderImet(false, imet);
231 | }
232 |
233 | if (lz77 == true)
234 | {
235 | //Yeah, I know this isn't where it actually compresses it
236 | if (BeQuiet.quiet > 2)
237 | Console.WriteLine("Compressing U8 archive");
238 | U8folder.Lz77Compress = true;
239 | }
240 |
241 | if (BeQuiet.quiet > 2)
242 | Console.WriteLine("Saving file");
243 |
244 | U8folder.Save(output);
245 |
246 | if (BeQuiet.quiet > 1)
247 | Console.WriteLine("Operation completed successfully!");
248 | }
249 | catch (Exception ex)
250 | {
251 | Console.WriteLine("An unknown error occurred, please try again");
252 | Console.WriteLine("");
253 | Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
254 | Console.WriteLine("Error: SHARPII_NET_CORE_U8_UNKNOWN");
255 | if (OperatingSystem.Windows())
256 | {
257 | Environment.Exit(0x00003E82);
258 | }
259 | else
260 | {
261 | Environment.Exit(0x00000004);
262 | }
263 | return;
264 | }
265 | }
266 |
267 | public static void U8_help()
268 | {
269 | Console.WriteLine("");
270 | Console.WriteLine("Sharpii .Net Core v{0} - Ported and Maintained by TheShadowEevee, originally by person66", ProgramVersion.version);
271 | Console.WriteLine("Using a modified version of libWiiSharp, originally made by leathl");
272 | Console.WriteLine("");
273 | Console.WriteLine("");
274 | Console.WriteLine(" Usage:");
275 | Console.WriteLine("");
276 | Console.WriteLine(" ./Sharpii U8 [-p | -u] input output [arguments]");
277 | Console.WriteLine("");
278 | Console.WriteLine("");
279 | Console.WriteLine(" Arguments:");
280 | Console.WriteLine("");
281 | Console.WriteLine(" input The input file/folder");
282 | Console.WriteLine(" output The output file/folder");
283 | Console.WriteLine(" -p Pack");
284 | Console.WriteLine(" -u Unpack");
285 | Console.WriteLine("");
286 | Console.WriteLine(" Arguments for Packing:");
287 | Console.WriteLine("");
288 | Console.WriteLine(" -imet [title] Pack with an IMET header (for 00000000.app)");
289 | Console.WriteLine(" You MUST enter a channel title");
290 | Console.WriteLine(" -imd5 Pack with an IMD5 header (for Banner/Icon.bin)");
291 | Console.WriteLine(" -lz77 Compress with lz77");
292 | }
293 | }
294 | }
--------------------------------------------------------------------------------
/Sharpii/TPL.cs:
--------------------------------------------------------------------------------
1 | /* This file is part of Sharpii.
2 | * Copyright (C) 2013 Person66
3 | * Copyright (C) 2020-2025 Sharpii-NetCore Contributors
4 | *
5 | * Sharpii is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * Sharpii is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with Sharpii. If not, see .
17 | */
18 |
19 | using libWiiSharp;
20 | using System;
21 | using System.IO;
22 |
23 | namespace Sharpii
24 | {
25 | partial class TPL_Stuff
26 | {
27 | public static void TPL(string[] args)
28 | {
29 | if (args.Length < 4)
30 | {
31 | TPL_help();
32 | return;
33 | }
34 |
35 | //********************* To TPL *********************
36 | if (args[1] == "-to")
37 | {
38 | To(args);
39 | return;
40 | }
41 |
42 | //********************* From TPL *********************
43 | if (args[1] == "-from")
44 | {
45 | From(args);
46 | return;
47 | }
48 |
49 | //If the user gets here, they entered something wrong
50 | Console.WriteLine("ERROR: The argument {0} is invalid", args[1]);
51 | Console.WriteLine("Error: SHARPII_NET_CORE_TPL_INVALID_ARG");
52 | if (OperatingSystem.Windows())
53 | {
54 | Environment.Exit(0x00003E90);
55 | }
56 | else
57 | {
58 | Environment.Exit(0x00000012);
59 | }
60 | return;
61 | }
62 |
63 | private static void From(string[] args)
64 | {
65 | string input = args[2];
66 | string output = args[3];
67 |
68 | //Check if file exists
69 | if (File.Exists(input) == false)
70 | {
71 | Console.WriteLine("ERROR: Unable to open file: {0}", input);
72 | Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it.");
73 | Console.WriteLine("Error: SHARPII_NET_CORE_TPL_FILE_ERR");
74 | if (OperatingSystem.Windows())
75 | {
76 | Environment.Exit(0x00003E81);
77 | }
78 | else
79 | {
80 | Environment.Exit(0x00000003);
81 | }
82 | return;
83 | }
84 |
85 | //Run main part, and check for exceptions
86 | try
87 | {
88 | //Load tpl
89 | if (BeQuiet.quiet > 2)
90 | Console.Write("Loading file...");
91 |
92 | TPL tplfile = libWiiSharp.TPL.Load(input);
93 |
94 | if (BeQuiet.quiet > 2)
95 | Console.Write("Done!\n");
96 |
97 | //save image
98 | if (BeQuiet.quiet > 2)
99 | Console.Write("Extracting texture...");
100 |
101 | tplfile.ExtractTexture(output);
102 |
103 | if (BeQuiet.quiet > 2)
104 | Console.Write("Done!\n");
105 |
106 | if (BeQuiet.quiet > 1)
107 | Console.WriteLine("Operation completed successfully!");
108 | }
109 | catch (Exception ex)
110 | {
111 | Console.WriteLine("An unknown error occurred, please try again");
112 | Console.WriteLine("");
113 | Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
114 | Console.WriteLine("Error: SHARPII_NET_CORE_TPL_UNKNOWN");
115 | if (OperatingSystem.Windows())
116 | {
117 | Environment.Exit(0x00003E81);
118 | }
119 | else
120 | {
121 | Environment.Exit(0x00000003);
122 | }
123 | return;
124 | }
125 | }
126 |
127 | private static void To(string[] args)
128 | {
129 | //Setting up variables
130 | string input = args[2];
131 | string output = args[3];
132 | string tplFormat = "RGB565";
133 |
134 | //Check if file exists
135 | if (File.Exists(input) == false)
136 | {
137 | Console.WriteLine("ERROR: Unable to open file: {0}", input);
138 | Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it.");
139 | Console.WriteLine("Error: SHARPII_NET_CORE_TPL_FILE_ERR");
140 | if (OperatingSystem.Windows())
141 | {
142 | Environment.Exit(0x00003E81);
143 | }
144 | else
145 | {
146 | Environment.Exit(0x00000003);
147 | }
148 | return;
149 | }
150 |
151 | //Check for arguments
152 | for (int i = 1; i < args.Length; i++)
153 | {
154 | switch (args[i].ToUpper())
155 | {
156 | case "-FORMAT":
157 | if (i + 1 >= args.Length)
158 | {
159 | Console.WriteLine("ERROR: No format set");
160 | Console.WriteLine("Error: SHARPII_NET_CORE_TPL_NO_FORMAT");
161 | if (OperatingSystem.Windows())
162 | {
163 | Environment.Exit(0x00003E91);
164 | }
165 | else
166 | {
167 | Environment.Exit(0x00000013);
168 | }
169 | return;
170 | }
171 | tplFormat = args[i + 1];
172 | break;
173 | case "-F":
174 | if (i + 1 >= args.Length)
175 | {
176 | Console.WriteLine("ERROR: No format set");
177 | Console.WriteLine("Error: SHARPII_NET_CORE_TPL_NO_FORMAT");
178 | if (OperatingSystem.Windows())
179 | {
180 | Environment.Exit(0x00003E91);
181 | }
182 | else
183 | {
184 | Environment.Exit(0x00000013);
185 | }
186 | return;
187 | }
188 | tplFormat = args[i + 1];
189 | break;
190 | }
191 | }
192 |
193 | //Check if valid format was entered
194 | if (tplFormat != "I4" & tplFormat != "I8" & tplFormat != "IA4" & tplFormat != "IA8" & tplFormat != "RGB565" & tplFormat != "RGB5A3" & tplFormat != "RGBA8")
195 | {
196 | Console.WriteLine("ERROR: Unknown format type: {0}", tplFormat);
197 | Console.WriteLine("Error: SHARPII_NET_CORE_TPL_UNKNOWN_FORMAT");
198 | Environment.Exit(0x00003E92);
199 | return;
200 | }
201 |
202 |
203 | //Run main part, and check for exceptions
204 | try
205 | {
206 | //Set format
207 | TPL_TextureFormat format = TPL_TextureFormat.RGB565;
208 | if (tplFormat == "I4")
209 | format = TPL_TextureFormat.I4;
210 | if (tplFormat == "I8")
211 | format = TPL_TextureFormat.I8;
212 | if (tplFormat == "IA4")
213 | format = TPL_TextureFormat.IA4;
214 | if (tplFormat == "IA8")
215 | format = TPL_TextureFormat.IA8;
216 | if (tplFormat == "RGB565")
217 | format = TPL_TextureFormat.RGB565;
218 | if (tplFormat == "RGB5A3")
219 | format = TPL_TextureFormat.RGB5A3;
220 | if (tplFormat == "RGBA8")
221 | format = TPL_TextureFormat.RGBA8;
222 |
223 | if (BeQuiet.quiet > 2)
224 | Console.WriteLine("Format set to: {0}", tplFormat);
225 |
226 | //Make tpl
227 | if (BeQuiet.quiet > 2)
228 | Console.Write("Creating tpl file...");
229 |
230 | TPL tplfile = libWiiSharp.TPL.FromImage(input, format);
231 |
232 | if (BeQuiet.quiet > 2)
233 | Console.Write("Done!\n");
234 |
235 | //save
236 | if (BeQuiet.quiet > 2)
237 | Console.Write("Saving tpl file...");
238 |
239 | if (!output.EndsWith(".tpl", StringComparison.OrdinalIgnoreCase))
240 | output += ".tpl";
241 |
242 | tplfile.Save(output);
243 |
244 | if (BeQuiet.quiet > 2)
245 | Console.Write("Done!\n");
246 |
247 | if (BeQuiet.quiet > 1)
248 | Console.WriteLine("Operation completed successfully!");
249 | }
250 | catch (Exception ex)
251 | {
252 | Console.WriteLine("An unknown error occurred, please try again");
253 | Console.WriteLine("");
254 | Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
255 | Console.WriteLine("Error: SHARPII_NET_CORE_TPL_UNKNOWN");
256 | if (OperatingSystem.Windows())
257 | {
258 | Environment.Exit(0x00003E82);
259 | }
260 | else
261 | {
262 | Environment.Exit(0x00000004);
263 | }
264 | return;
265 | }
266 | }
267 |
268 | public static void TPL_help()
269 | {
270 | Console.WriteLine("");
271 | Console.WriteLine("Sharpii .Net Core v{0} - Ported and Maintained by TheShadowEevee, originally by person66", ProgramVersion.version);
272 | Console.WriteLine("Using a modified version of libWiiSharp, originally made by leathl");
273 | Console.WriteLine("");
274 | Console.WriteLine("");
275 | Console.WriteLine(" Usage:");
276 | Console.WriteLine("");
277 | Console.WriteLine(" ./Sharpii TPL [-to | -from] input output [arguments]");
278 | Console.WriteLine("");
279 | Console.WriteLine("");
280 | Console.WriteLine(" Arguments:");
281 | Console.WriteLine("");
282 | Console.WriteLine(" -to Convert image to tpl");
283 | Console.WriteLine(" -from Create image from tpl");
284 | Console.WriteLine(" input The input file/folder");
285 | Console.WriteLine(" output The output file/folder");
286 | Console.WriteLine("");
287 | Console.WriteLine(" Arguments for Converting to TPL:");
288 | Console.WriteLine("");
289 | Console.WriteLine(" -format | -f The format of the tpl. Possible values are:");
290 | Console.WriteLine(" RGBA8 (High Quality with Alpha)");
291 | Console.WriteLine(" RGB565 (Medium Quality without Alpha)");
292 | Console.WriteLine(" RGB5A3 (Low Quality with Alpha)");
293 | Console.WriteLine(" IA8 (High quality B/W with Alpha)");
294 | Console.WriteLine(" IA4 (Low Quality B/W with Alpha)");
295 | Console.WriteLine(" I8 (High Quality B/W without Alpha)");
296 | Console.WriteLine(" I4 (Low Quality B/W without Alpha)");
297 | Console.WriteLine("");
298 | Console.WriteLine(" Notes:");
299 | Console.WriteLine("");
300 | Console.WriteLine(" If no format is specified when converting to TPL, RGB565 is used.");
301 | Console.WriteLine(" When converting to an image, the image format is chosen based on the extension");
302 | }
303 | }
304 | }
--------------------------------------------------------------------------------
/Sharpii/IOS.cs:
--------------------------------------------------------------------------------
1 | /* This file is part of Sharpii.
2 | * Copyright (C) 2013 Person66
3 | * Copyright (C) 2020-2025 Sharpii-NetCore Contributors
4 | *
5 | * Sharpii is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * Sharpii is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with Sharpii. If not, see .
17 | */
18 |
19 | using libWiiSharp;
20 | using System;
21 | using System.IO;
22 |
23 | namespace Sharpii
24 | {
25 | partial class IOS_Stuff
26 | {
27 | public static void IOS(string[] args)
28 | {
29 | if (args.Length < 3)
30 | {
31 | IOS_help();
32 | return;
33 | }
34 | string input = args[1];
35 | string output = "";
36 | bool fs = false;
37 | bool es = false;
38 | bool np = false;
39 | bool vp = false;
40 | int slot = -1;
41 | int version = -1;
42 |
43 | //Check if file exists
44 | if (File.Exists(input) == false)
45 | {
46 | Console.WriteLine("ERROR: Unable to open file: {0}", input);
47 | Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it.");
48 | Console.WriteLine("Error: SHARPII_NET_CORE_IOS_FILE_ERR");
49 | if (OperatingSystem.Windows())
50 | {
51 | Environment.Exit(0x00003E81);
52 | }
53 | else
54 | {
55 | Environment.Exit(0x00000003);
56 | }
57 | return;
58 | }
59 |
60 | //Get parameters
61 | for (int i = 1; i < args.Length; i++)
62 | {
63 | switch (args[i].ToUpper())
64 | {
65 | case "-FS":
66 | fs = true;
67 | break;
68 | case "-ES":
69 | es = true;
70 | break;
71 | case "-NP":
72 | np = true;
73 | break;
74 | case "-VP":
75 | vp = true;
76 | break;
77 | case "-SLOT":
78 | if (i + 1 >= args.Length)
79 | {
80 | Console.WriteLine("ERROR: No slot set");
81 | Console.WriteLine("Error: SHARPII_NET_CORE_IOS_NO_SLOT");
82 | if (OperatingSystem.Windows())
83 | {
84 | Environment.Exit(0x00003E89);
85 | }
86 | else
87 | {
88 | Environment.Exit(0x0000000B);
89 | }
90 | return;
91 | }
92 | if (!int.TryParse(args[i + 1], out slot))
93 | {
94 | Console.WriteLine("Invalid slot {0}...", args[i + 1]);
95 | Console.WriteLine("Error: SHARPII_NET_CORE_IOS_INVALID_SLOT");
96 | if (OperatingSystem.Windows())
97 | {
98 | Environment.Exit(0x00003E8A);
99 | }
100 | else
101 | {
102 | Environment.Exit(0x0000000C);
103 | }
104 | return;
105 | }
106 | if (slot < 3 || slot > 255)
107 | {
108 | Console.WriteLine("Invalid slot {0}...", slot);
109 | Console.WriteLine("Error: SHARPII_NET_CORE_IOS_INVALID_SLOT");
110 | if (OperatingSystem.Windows())
111 | {
112 | Environment.Exit(0x00003E8A);
113 | }
114 | else
115 | {
116 | Environment.Exit(0x0000000C);
117 | }
118 | return;
119 | }
120 | break;
121 | case "-S":
122 | if (i + 1 >= args.Length)
123 | {
124 | Console.WriteLine("ERROR: No slot set");
125 | Console.WriteLine("Error: SHARPII_NET_CORE_IOS_NO_SLOT");
126 | if (OperatingSystem.Windows())
127 | {
128 | Environment.Exit(0x00003E89);
129 | }
130 | else
131 | {
132 | Environment.Exit(0x0000000B);
133 | }
134 | return;
135 | }
136 | if (!int.TryParse(args[i + 1], out slot))
137 | {
138 | Console.WriteLine("Invalid slot {0}...", args[i + 1]);
139 | Console.WriteLine("Error: SHARPII_NET_CORE_IOS_INVALID_SLOT");
140 | if (OperatingSystem.Windows())
141 | {
142 | Environment.Exit(0x00003E8A);
143 | }
144 | else
145 | {
146 | Environment.Exit(0x0000000C);
147 | }
148 | return;
149 | }
150 | if (slot < 3 || slot > 255)
151 | {
152 | Console.WriteLine("Invalid slot {0}...", slot);
153 | Console.WriteLine("Error: SHARPII_NET_CORE_IOS_INVALID_SLOT");
154 | if (OperatingSystem.Windows())
155 | {
156 | Environment.Exit(0x00003E8A);
157 | }
158 | else
159 | {
160 | Environment.Exit(0x0000000C);
161 | }
162 | return;
163 | }
164 | break;
165 | case "-V":
166 | if (i + 1 >= args.Length)
167 | {
168 | Console.WriteLine("ERROR: No version set");
169 | Console.WriteLine("Error: SHARPII_NET_CORE_IOS_NO_VERSION");
170 | if (OperatingSystem.Windows())
171 | {
172 | Environment.Exit(0x00003E8B);
173 | }
174 | else
175 | {
176 | Environment.Exit(0x0000000D);
177 | }
178 | return;
179 | }
180 | if (!int.TryParse(args[i + 1], out version))
181 | {
182 | Console.WriteLine("Invalid version {0}...", args[i + 1]);
183 | Console.WriteLine("Error: SHARPII_NET_CORE_IOS_INVALID_VERSION");
184 | if (OperatingSystem.Windows())
185 | {
186 | Environment.Exit(0x00003E8C);
187 | }
188 | else
189 | {
190 | Environment.Exit(0x0000000E);
191 | }
192 | return;
193 | }
194 | if (version < 0 || version > 65535)
195 | {
196 | Console.WriteLine("Invalid version {0}...", version);
197 | Console.WriteLine("Error: SHARPII_NET_CORE_IOS_INVALID_VERSION");
198 | if (OperatingSystem.Windows())
199 | {
200 | Environment.Exit(0x00003E8C);
201 | }
202 | else
203 | {
204 | Environment.Exit(0x0000000E);
205 | }
206 | return;
207 | }
208 | break;
209 | case "-O":
210 | if (i + 1 >= args.Length)
211 | {
212 | Console.WriteLine("ERROR: No output set");
213 | Console.WriteLine("Error: SHARPII_NET_CORE_IOS_NO_OUTPUT");
214 | if (OperatingSystem.Windows())
215 | {
216 | Environment.Exit(0x00003E8D);
217 | }
218 | else
219 | {
220 | Environment.Exit(0x0000000F);
221 | }
222 | return;
223 | }
224 | output = args[i + 1];
225 | break;
226 | }
227 | }
228 |
229 | //Main part (most of it was borrowed from PatchIOS)
230 | try
231 | {
232 | WAD ios = new WAD
233 | {
234 | KeepOriginalFooter = true
235 | };
236 |
237 | if (BeQuiet.quiet > 2)
238 | Console.Write("Loading File...");
239 |
240 | ios.LoadFile(input);
241 |
242 | if (BeQuiet.quiet > 2)
243 | Console.Write("Done!\n");
244 |
245 | //Check if WAD is an IOS
246 | if ((ios.TitleID >> 32) != 1 || (ios.TitleID & 0xffffffff) > 255 || (ios.TitleID & 0xffffffff) < 3)
247 | {
248 | Console.WriteLine("Only IOS WADs can be patched...");
249 | return;
250 | }
251 |
252 | IosPatcher patcher = new IosPatcher();
253 |
254 | patcher.LoadIOS(ref ios);
255 |
256 | //apply patches
257 | if (fs == true)
258 | {
259 | if (BeQuiet.quiet > 2)
260 | Console.WriteLine("Applying Fakesigning patch");
261 | patcher.PatchFakeSigning();
262 | }
263 |
264 | if (es == true)
265 | {
266 | if (BeQuiet.quiet > 2)
267 | Console.WriteLine("Applying ES_Identify patch");
268 | patcher.PatchEsIdentify();
269 | }
270 |
271 | if (np == true)
272 | {
273 | if (BeQuiet.quiet > 2)
274 | Console.WriteLine("Applying NAND permissions patch");
275 | patcher.PatchNandPermissions();
276 | }
277 |
278 | if (vp == true)
279 | {
280 | if (BeQuiet.quiet > 2)
281 | Console.WriteLine("Applying Version patch");
282 | patcher.PatchVP();
283 | }
284 |
285 | if (slot > -1 || version > -1)
286 | ios.FakeSign = true;
287 |
288 | if (slot > -1)
289 | {
290 | if (BeQuiet.quiet > 2)
291 | Console.WriteLine("Changing IOS slot to: {0}", slot);
292 | ios.TitleID = (ulong)((1UL << 32) | (uint)slot);
293 | }
294 |
295 | if (version > -1)
296 | {
297 | if (BeQuiet.quiet > 2)
298 | Console.WriteLine("Changing title version to: {0}", version);
299 | ios.TitleVersion = (ushort)version;
300 | }
301 |
302 | //check if output was set
303 | if (output != "")
304 | {
305 | if (BeQuiet.quiet > 2)
306 | Console.WriteLine("Saving to file: {0}", output);
307 | ios.Save(output);
308 | }
309 | else
310 | {
311 | if (BeQuiet.quiet > 2)
312 | Console.Write("Saving file...");
313 |
314 | if (output != "")
315 | {
316 | if (!output.EndsWith(".wad", StringComparison.OrdinalIgnoreCase))
317 | output += ".wad";
318 | }
319 |
320 | ios.Save(input);
321 |
322 | if (BeQuiet.quiet > 2)
323 | Console.Write("Done!\n");
324 | }
325 | if (BeQuiet.quiet > 1)
326 | Console.WriteLine("Operation completed successfully!");
327 | }
328 | catch (Exception ex)
329 | {
330 | Console.WriteLine("An unknown error occurred, please try again");
331 | Console.WriteLine("");
332 | Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
333 | Console.WriteLine("Error: SHARPII_NET_CORE_IOS_UNKNOWN");
334 | if (OperatingSystem.Windows())
335 | {
336 | Environment.Exit(0x00003E82);
337 | }
338 | else
339 | {
340 | Environment.Exit(0x00000004);
341 | }
342 | return;
343 | }
344 |
345 | return;
346 | }
347 |
348 | public static void IOS_help()
349 | {
350 | Console.WriteLine("");
351 | Console.WriteLine("Sharpii .Net Core v{0} - Ported and Maintained by TheShadowEevee, originally by person66", ProgramVersion.version);
352 | Console.WriteLine(" Code based off PatchIOS by leathl");
353 | Console.WriteLine("Using a modified version of libWiiSharp, originally made by leathl");
354 | Console.WriteLine("");
355 | Console.WriteLine(" Usage:");
356 | Console.WriteLine("");
357 | Console.WriteLine(" ./Sharpii IOS input [-o output] [-fs] [-es] [-np] [-vp] [-s slot]");
358 | Console.WriteLine(" [-v version]");
359 | Console.WriteLine("");
360 | Console.WriteLine("");
361 | Console.WriteLine(" Arguments:");
362 | Console.WriteLine("");
363 | Console.WriteLine(" input The input file");
364 | Console.WriteLine(" -o output The output file");
365 | Console.WriteLine(" -fs Patch Fakesigning");
366 | Console.WriteLine(" -es Patch ES_Identify");
367 | Console.WriteLine(" -np Patch NAND Permissions");
368 | Console.WriteLine(" -vp Add version patch");
369 | Console.WriteLine(" -s # Change IOS slot to #");
370 | Console.WriteLine(" -v # Change IOS version to #");
371 | }
372 | }
373 | }
--------------------------------------------------------------------------------
/Sharpii/HBC.cs:
--------------------------------------------------------------------------------
1 | /* This file is part of Sharpii.
2 | * Copyright (C) 2013 Person66
3 | * Copyright (C) 2020-2025 Sharpii-NetCore Contributors
4 | *
5 | * Sharpii is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * Sharpii is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with Sharpii. If not, see .
17 | */
18 |
19 | using libWiiSharp;
20 | using System;
21 | using System.IO;
22 |
23 | namespace Sharpii
24 | {
25 | partial class HBC_Stuff
26 | {
27 | public static void SendDol(string[] args)
28 | {
29 | if (args.Length < 2)
30 | {
31 | SendDol_help();
32 | return;
33 | }
34 | if (args[1].ToUpper() == "-H" || args[1].ToUpper() == "-HELP")
35 | {
36 | SendDol_help();
37 | return;
38 | }
39 | string input = "";
40 | string ip = "";
41 | string protocol = "JODI";
42 | string arguments = "";
43 | bool compress = true;
44 | bool saveip = false;
45 | bool noip = true;
46 |
47 | //Get parameters
48 | for (int i = 1; i < args.Length; i++)
49 | {
50 | switch (args[i].ToUpper())
51 | {
52 | case "-IP":
53 | if (i + 1 >= args.Length)
54 | {
55 | Console.WriteLine("ERROR: No ip set");
56 | Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_IP");
57 | if (OperatingSystem.Windows())
58 | {
59 | Environment.Exit(0x00003E83);
60 | }
61 | else
62 | {
63 | Environment.Exit(0x00000005);
64 | }
65 | return;
66 | }
67 | ip = args[i + 1];
68 | noip = false;
69 | break;
70 | case "-SAVEIP":
71 | saveip = true;
72 | break;
73 | case "-DOL":
74 | if (i + 1 >= args.Length)
75 | {
76 | Console.WriteLine("ERROR: No dol set");
77 | Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_DOL");
78 | if (OperatingSystem.Windows())
79 | {
80 | Environment.Exit(0x00003E84);
81 | }
82 | else
83 | {
84 | Environment.Exit(0x00000006);
85 | }
86 | return;
87 | }
88 | input = args[i + 1];
89 | //Check if file exists
90 | if (File.Exists(input) == false)
91 | {
92 | Console.WriteLine("ERROR: Unable to open file: {0}", input);
93 | Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it.");
94 | Console.WriteLine("Error: SHARPII_NET_CORE_HBC_FILE_ERR");
95 | if (OperatingSystem.Windows())
96 | {
97 | Environment.Exit(0x00003E81);
98 | }
99 | else
100 | {
101 | Environment.Exit(0x00000003);
102 | }
103 | return;
104 | }
105 |
106 | if (i + 1 < args.Length)
107 | {
108 | for (int n = i + 2; n < args.Length; n++)
109 | {
110 | arguments += "\x0000";
111 | arguments += args[n];
112 | }
113 | }
114 | break;
115 | case "-NOCOMP":
116 | compress = false;
117 | break;
118 | case "-OLD":
119 | protocol = "HAXX";
120 | break;
121 | }
122 | }
123 |
124 | //Run main part, and check for exceptions
125 | try
126 | {
127 | if (ip != "" && saveip == true)
128 | {
129 | if (BeQuiet.quiet > 2)
130 | Console.WriteLine("Saving IP");
131 | Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.Machine);
132 | }
133 |
134 | if (String.IsNullOrEmpty(ip))
135 | ip = Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.User);
136 | if (String.IsNullOrEmpty(ip))
137 | ip = Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.Machine);
138 | if (String.IsNullOrEmpty(ip))
139 | {
140 | Console.WriteLine("ERROR: No IP set");
141 | Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_IP");
142 | if (OperatingSystem.Windows())
143 | {
144 | Environment.Exit(0x00003E82);
145 | }
146 | else
147 | {
148 | Environment.Exit(0x00000005);
149 | }
150 | return;
151 | }
152 | if (noip == true && BeQuiet.quiet > 2)
153 | Console.WriteLine("No IP set, using {0}", ip);
154 |
155 | libWiiSharp.Protocol proto = Protocol.JODI;
156 |
157 | if (BeQuiet.quiet > 2 && protocol == "HAXX")
158 | Console.WriteLine("Using old protocol");
159 |
160 | if (protocol == "HAXX")
161 | proto = Protocol.HAXX;
162 |
163 | if (BeQuiet.quiet > 2)
164 | Console.Write("Loading File...");
165 |
166 | HbcTransmitter file = new HbcTransmitter(proto, ip);
167 |
168 | if (BeQuiet.quiet > 2)
169 | Console.Write("Done!\n");
170 |
171 |
172 | if (BeQuiet.quiet > 2 && compress == true)
173 | Console.Write("Compressing File...");
174 |
175 | file.Compress = compress;
176 |
177 | if (BeQuiet.quiet > 2 && compress == true)
178 | Console.Write("Done!\n");
179 |
180 | if (BeQuiet.quiet > 1)
181 | Console.Write("Sending file...");
182 |
183 | file.TransmitFile(Path.GetFileName(input) + arguments, File.ReadAllBytes(input));
184 |
185 | if (BeQuiet.quiet > 1)
186 | Console.Write("Done!\n");
187 | }
188 | catch (Exception ex)
189 | {
190 | Console.WriteLine("An unknown error occurred, please try again");
191 | Console.WriteLine("");
192 | Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
193 | Console.WriteLine("Error: SHARPII_NET_CORE_HBC_UNKNOWN");
194 | if (OperatingSystem.Windows())
195 | {
196 | Environment.Exit(0x00003E81);
197 | }
198 | else
199 | {
200 | Environment.Exit(0x00000004);
201 | }
202 | return;
203 | }
204 |
205 | return;
206 | }
207 |
208 | public static bool SendWad_Check(string[] args)
209 | {
210 | if (args.Length < 2)
211 | {
212 | SendWad_help();
213 | return false;
214 | }
215 | if (args[1].ToUpper() == "-H" || args[1].ToUpper() == "-HELP")
216 | {
217 | SendWad_help();
218 | return false;
219 | }
220 |
221 | return true;
222 | }
223 |
224 | public static void SendWad(string[] args)
225 | {
226 | string input = "";
227 | string ip = "";
228 | string ios = "";
229 | string protocol = "JODI";
230 | bool ahb = false;
231 | bool saveip = false;
232 | bool noip = true;
233 |
234 | //Get parameters
235 | for (int i = 1; i < args.Length; i++)
236 | {
237 | switch (args[i].ToUpper())
238 | {
239 | case "-IOS":
240 | if (i + 1 >= args.Length)
241 | {
242 | Console.WriteLine("ERROR: No ios set");
243 | Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_IOS");
244 | if (OperatingSystem.Windows())
245 | {
246 | Environment.Exit(0x00003E86);
247 | }
248 | else
249 | {
250 | Environment.Exit(0x00000008);
251 | }
252 | return;
253 | }
254 | ios = args[i + 1];
255 | if (!(Convert.ToInt32(ios) >= 3 && Convert.ToInt32(ios) <= 255))
256 | {
257 | Console.WriteLine("ERROR: Invalid IOS number");
258 | Console.WriteLine("Error: SHARPII_NET_CORE_HBC_INVALID_IOS");
259 | if (OperatingSystem.Windows())
260 | {
261 | Environment.Exit(0x00003E87);
262 | }
263 | else
264 | {
265 | Environment.Exit(0x00000009);
266 | }
267 | return;
268 | }
269 | break;
270 | case "-AHB":
271 | ahb = true;
272 | break;
273 | case "-IP":
274 | if (i + 1 >= args.Length)
275 | {
276 | Console.WriteLine("ERROR: No ip set");
277 | Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_IP");
278 | if (OperatingSystem.Windows())
279 | {
280 | Environment.Exit(0x00003E83);
281 | }
282 | else
283 | {
284 | Environment.Exit(0x00000005);
285 | }
286 | return;
287 | }
288 | ip = args[i + 1];
289 | noip = false;
290 | break;
291 | case "-SAVEIP":
292 | saveip = true;
293 | break;
294 | case "-WAD":
295 | if (i + 1 >= args.Length)
296 | {
297 | Console.WriteLine("ERROR: No WAD set");
298 | Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_WAD");
299 | if (OperatingSystem.Windows())
300 | {
301 | Environment.Exit(0x00003E88);
302 | }
303 | else
304 | {
305 | Environment.Exit(0x0000000A);
306 | }
307 | return;
308 | }
309 | input = args[i + 1];
310 | //Check if file exists
311 | if (File.Exists(input) == false)
312 | {
313 | Console.WriteLine("ERROR: Unable to open file: {0}", input);
314 | Console.WriteLine("Error: SHARPII_NET_CORE_BNS_FILE_ERR");
315 | if (OperatingSystem.Windows())
316 | {
317 | Environment.Exit(0x00003E81);
318 | }
319 | else
320 | {
321 | Environment.Exit(0x00000003);
322 | }
323 | return;
324 | }
325 | break;
326 | case "-OLD":
327 | protocol = "HAXX";
328 | break;
329 | }
330 | }
331 |
332 | //Run main part, and check for exceptions
333 | try
334 | {
335 | if (ip != "" && saveip == true)
336 | {
337 | if (BeQuiet.quiet > 2)
338 | Console.WriteLine("Saving IP");
339 | Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.Machine);
340 | }
341 |
342 | if (ahb == true || ios == "")
343 | {
344 | if (BeQuiet.quiet > 2)
345 | Console.WriteLine("Using AHBPROT");
346 | ios = "0";
347 | }
348 |
349 | if (String.IsNullOrEmpty(ip))
350 | ip = Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.User);
351 | if (String.IsNullOrEmpty(ip))
352 | ip = Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.Machine);
353 | if (String.IsNullOrEmpty(ip))
354 | {
355 | Console.WriteLine("ERROR: No IP set");
356 | Console.WriteLine("Error: SHARPII_NET_CORE_HBC_NO_IP");
357 | if (OperatingSystem.Windows())
358 | {
359 | Environment.Exit(0x00003E83);
360 | }
361 | else
362 | {
363 | Environment.Exit(0x00000005);
364 | }
365 | return;
366 | }
367 | if (noip == true && BeQuiet.quiet > 2)
368 | Console.WriteLine("No IP set, using {0}", ip);
369 |
370 | libWiiSharp.Protocol proto = Protocol.JODI;
371 |
372 | if (BeQuiet.quiet > 2 && protocol == "HAXX")
373 | Console.WriteLine("Using old protocol");
374 |
375 | if (protocol == "HAXX")
376 | proto = Protocol.HAXX;
377 |
378 | if (BeQuiet.quiet > 2)
379 | Console.Write("Loading File...");
380 |
381 | HbcTransmitter file = new HbcTransmitter(proto, ip);
382 | byte[] Installer = WadInstaller.InstallerHelper.CreateInstaller(input, (byte)Convert.ToInt32(ios)).ToArray();
383 |
384 | if (BeQuiet.quiet > 2)
385 | Console.Write("Done!\n");
386 |
387 | if (BeQuiet.quiet > 1)
388 | Console.Write("Sending file...");
389 |
390 | file.TransmitFile("WadInstaller.dol", Installer);
391 |
392 | if (BeQuiet.quiet > 1)
393 | Console.Write("Done!\n");
394 | }
395 | catch (Exception ex)
396 | {
397 | Console.WriteLine("An unknown error occurred, please try again");
398 | Console.WriteLine("");
399 | Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
400 | Console.WriteLine("Error: SHARPII_NET_CORE_HBC_UNKNOWN");
401 | if (OperatingSystem.Windows())
402 | {
403 | Environment.Exit(0x00003E82);
404 | }
405 | else
406 | {
407 | Environment.Exit(0x00000004);
408 | }
409 | return;
410 | }
411 |
412 | return;
413 | }
414 |
415 | private static void SendDol_help()
416 | {
417 | Console.WriteLine("");
418 | Console.WriteLine("Sharpii {0} - Ported and Maintained by TheShadowEevee, originally by person66", ProgramVersion.version);
419 | Console.WriteLine("Using a modified version of libWiiSharp, originally made by leathl");
420 | Console.WriteLine("");
421 | Console.WriteLine("");
422 | Console.WriteLine(" Usage:");
423 | Console.WriteLine("");
424 | Console.WriteLine(" Sharpii.exe SendDol -ip ip_address [-old] [-nocomp] [-saveip]");
425 | Console.WriteLine(" [-dol/-wad] file [args]");
426 | Console.WriteLine("");
427 | Console.WriteLine("");
428 | Console.WriteLine(" Arguments:");
429 | Console.WriteLine("");
430 | Console.WriteLine(" -dol file The dol file to send");
431 | Console.WriteLine(" -wad file The wad file to send");
432 | Console.WriteLine(" -ip ip_address The IP address of your wii");
433 | Console.WriteLine(" -saveip Save entered IP address for future use");
434 | Console.WriteLine(" -old Use for the old (1.0.4 and below) HBC");
435 | Console.WriteLine(" -nocomp Disable compression");
436 | Console.WriteLine(" args Dol arguments");
437 | Console.WriteLine("");
438 | Console.WriteLine(" NOTE: Any arguments after '-dol file' will be sent as dol");
439 | Console.WriteLine(" arguments");
440 | }
441 |
442 | public static void SendWad_help()
443 | {
444 | Console.WriteLine("");
445 | Console.WriteLine("Sharpii .Net Core v{0} - Ported and Maintained by TheShadowEevee, originally by person66", ProgramVersion.version);
446 | Console.WriteLine(" and CRAP's installer by WiiCrazy/I.R.on");
447 | Console.WriteLine("Using a modified version of libWiiSharp, originally made by leathl");
448 | Console.WriteLine("");
449 | Console.WriteLine(" Usage:");
450 | Console.WriteLine("");
451 | Console.WriteLine(" ./Sharpii SendWad -ip ip_address -wad file [-ios IOS | -ahb] [-old]");
452 | Console.WriteLine(" [-nocomp] [-saveip]");
453 | Console.WriteLine("");
454 | Console.WriteLine("");
455 | Console.WriteLine(" Arguments:");
456 | Console.WriteLine("");
457 | Console.WriteLine(" -dol file The dol file to send");
458 | Console.WriteLine(" -ip ip_address The IP address of your wii");
459 | Console.WriteLine(" -ios ios The ios to use to install the wad");
460 | Console.WriteLine(" -ahb Use HW_AHBPROT to install the wad");
461 | Console.WriteLine(" -saveip Save entered IP address for future use");
462 | Console.WriteLine(" -old Use for the old (1.0.4 and below) HBC");
463 | Console.WriteLine(" -nocomp Disable compression");
464 | Console.WriteLine("");
465 | Console.WriteLine(" NOTE: WAD files must be less than 8MB in size.");
466 | }
467 | }
468 | }
--------------------------------------------------------------------------------
/Sharpii/EXT.cs:
--------------------------------------------------------------------------------
1 | /* This file is part of Sharpii.
2 | * Copyright (C) 2013 Person66
3 | * Copyright (C) 2020-2025 Sharpii-NetCore Contributors
4 | *
5 | * Sharpii is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * Sharpii is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with Sharpii. If not, see .
17 | */
18 |
19 | using System;
20 |
21 | namespace Sharpii
22 | {
23 | partial class ERRORCODE_Stuff
24 | {
25 | public static int ErrCodeFound = 0;
26 | public static void ERRORCODE(string[] args)
27 | {
28 | try
29 | {
30 | if (args[1] == "0")
31 | {
32 | Console.WriteLine("");
33 | Console.WriteLine("No errors reported/Likely successful exit");
34 | Console.WriteLine("");
35 | }
36 | if (args[1] == "16001")
37 | {
38 | Console.WriteLine("");
39 | Console.WriteLine("File Access Issue/Missing File. (SHARPII_NET_CORE_xxx_FILE_ERR)");
40 | Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it.");
41 | Console.WriteLine("Check the file's permissions and that it's in the right place.");
42 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
43 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
44 | Console.WriteLine("");
45 | ErrCodeFound = 1;
46 | }
47 |
48 | if (args[1] == "16002")
49 | {
50 | Console.WriteLine("");
51 | Console.WriteLine("Unknown Error/Untracked Error. (SHARPII_NET_CORE_xxx_UNKNOWN)");
52 | Console.WriteLine("An untracked error has occurred.");
53 | Console.WriteLine("Use the error text to self-diagnose.");
54 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
55 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
56 | Console.WriteLine("");
57 | ErrCodeFound = 1;
58 | }
59 |
60 | if (args[1] == "16003")
61 | {
62 | Console.WriteLine("");
63 | Console.WriteLine("No IP was provided for remote Wii access. (SHARPII_NET_CORE_HBC_NO_IP)");
64 | Console.WriteLine("No IP address was listed for the Wii.");
65 | Console.WriteLine("Furthermore, no IP address is saved from previous uses.");
66 | Console.WriteLine("If this doesn't help, open an issue on GitHub!");
67 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
68 | Console.WriteLine("");
69 | ErrCodeFound = 1;
70 | }
71 | if (args[1] == "16004")
72 | {
73 | Console.WriteLine("DOL Flag was used, but no file provided. (SHARPII_NET_CORE_xxx_NO_DOL)");
74 | Console.WriteLine("You used the -DOL flag, but no DOL file was provided.");
75 | Console.WriteLine("Provide the proper DOL file.");
76 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
77 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
78 | Console.WriteLine("");
79 | ErrCodeFound = 1;
80 | }
81 | if (args[1] == "16005")
82 | {
83 | Console.WriteLine("");
84 | Console.WriteLine("A Critical DLL (WadInstaller.dll) couldn't be found. (SHARPII_NET_CORE_HBC_MISSING_DLL_WADINSTALLER)");
85 | Console.WriteLine("The WadInstaller.dll couldn't be found.");
86 | Console.WriteLine("This error SHOULD NOT APPEAR in this Sharpii port.");
87 | Console.WriteLine("Open an issue on GitHub!");
88 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
89 | Console.WriteLine("");
90 | ErrCodeFound = 1;
91 | }
92 | if (args[1] == "16006")
93 | {
94 | Console.WriteLine("");
95 | Console.WriteLine("IOS Flag was used, but no IOS provided. (SHARPII_NET_CORE_xxx_NO_IOS)");
96 | Console.WriteLine("You used the -IOS flag, but no IOS was provided.");
97 | Console.WriteLine("Provide a proper IOS.");
98 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
99 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
100 | Console.WriteLine("");
101 | ErrCodeFound = 1;
102 | }
103 | if (args[1] == "16007")
104 | {
105 | Console.WriteLine("");
106 | Console.WriteLine("IOS Flag was used, but an invalid IOS provided. (SHARPII_NET_CORE_xxx_INVALID_IOS)");
107 | Console.WriteLine("You used the -IOS flag, but an invalid IOS was provided.");
108 | Console.WriteLine("Provide a proper IOS.");
109 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
110 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
111 | Console.WriteLine("");
112 | ErrCodeFound = 1;
113 | }
114 | if (args[1] == "16008")
115 | {
116 | Console.WriteLine("");
117 | Console.WriteLine("WAD Flag was used, but no wad provided. (SHARPII_NET_CORE_HBC_NO_WAD)");
118 | Console.WriteLine("You used the -WAD flag, but no WAD was provided.");
119 | Console.WriteLine("Provide a proper WAD.");
120 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
121 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
122 | Console.WriteLine("");
123 | ErrCodeFound = 1;
124 | }
125 | if (args[1] == "16009")
126 | {
127 | Console.WriteLine("");
128 | Console.WriteLine("Slot Flag was used, but no slot provided. (SHARPII_NET_CORE_IOS_NO_SLOT)");
129 | Console.WriteLine("You used the -SLOT flag, but no slot was provided.");
130 | Console.WriteLine("Provide a proper slot.");
131 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
132 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
133 | Console.WriteLine("");
134 | ErrCodeFound = 1;
135 | }
136 | if (args[1] == "16010")
137 | {
138 | Console.WriteLine("");
139 | Console.WriteLine("Slot Flag was used, but an invalid slot provided. (SHARPII_NET_CORE_xxx_INVALID_SLOT)");
140 | Console.WriteLine("You used the -SLOT flag, but an invalid slot was provided.");
141 | Console.WriteLine("Provide a proper slot.");
142 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
143 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
144 | Console.WriteLine("");
145 | ErrCodeFound = 1;
146 | }
147 | if (args[1] == "16011")
148 | {
149 | Console.WriteLine("");
150 | Console.WriteLine("V Flag was used, but no version provided. (SHARPII_NET_CORE_xxx_NO_VERSION)");
151 | Console.WriteLine("You used the -V flag, but no version was provided.");
152 | Console.WriteLine("Provide a proper version.");
153 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
154 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
155 | Console.WriteLine("");
156 | ErrCodeFound = 1;
157 | }
158 | if (args[1] == "16012")
159 | {
160 | Console.WriteLine("");
161 | Console.WriteLine("V Flag was used, but an invalid version provided. (SHARPII_NET_CORE_xxx_INVALID_VERSION)");
162 | Console.WriteLine("You used the -V flag, but no version was provided.");
163 | Console.WriteLine("Provide a proper version.");
164 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
165 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
166 | Console.WriteLine("");
167 | ErrCodeFound = 1;
168 | }
169 | if (args[1] == "16013")
170 | {
171 | Console.WriteLine("");
172 | Console.WriteLine("O Flag was used, but no output provided. (SHARPII_NET_CORE_xxx_NO_OUTPUT)");
173 | Console.WriteLine("You used the -O flag, but no output was provided.");
174 | Console.WriteLine("Provide a proper output.");
175 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
176 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
177 | Console.WriteLine("");
178 | ErrCodeFound = 1;
179 | }
180 | if (args[1] == "16014")
181 | {
182 | Console.WriteLine("");
183 | Console.WriteLine("ID Flag was used, but no id provided. (SHARPII_NET_CORE_xxx_NO_ID)");
184 | Console.WriteLine("You used the -ID flag, but no id was provided.");
185 | Console.WriteLine("Provide a proper id.");
186 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
187 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
188 | Console.WriteLine("");
189 | ErrCodeFound = 1;
190 | }
191 | if (args[1] == "16015")
192 | {
193 | Console.WriteLine("");
194 | Console.WriteLine("A Critical DLL (libWiiSharp.dll) couldn't be found. (SHARPII_NET_CORE_MAIN_MISSING_DLL_LIBWIISHARP)");
195 | Console.WriteLine("The libWiiSharp.dll couldn't be found.");
196 | Console.WriteLine("This error SHOULD NOT APPEAR in this Sharpii port.");
197 | Console.WriteLine("Open an issue on GitHub!");
198 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
199 | Console.WriteLine("");
200 | ErrCodeFound = 1;
201 | }
202 | if (args[1] == "16016")
203 | {
204 | Console.WriteLine("");
205 | Console.WriteLine("An invalid argument was passed when starting Sharpii. (SHARPII_NET_CORE_xxx_INVALID_ARG)");
206 | Console.WriteLine("An invalid argument was provided.");
207 | Console.WriteLine("Check the options you are using to start Sharpii.");
208 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
209 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
210 | Console.WriteLine("");
211 | ErrCodeFound = 1;
212 | }
213 | if (args[1] == "16017")
214 | {
215 | Console.WriteLine("");
216 | Console.WriteLine("FORMAT Flag was used, but no format provided. (SHARPII_NET_CORE_TPL_NO_FORMAT)");
217 | Console.WriteLine("You used the -FORMAT flag, but no format was provided.");
218 | Console.WriteLine("Provide a proper format.");
219 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
220 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
221 | Console.WriteLine("");
222 | ErrCodeFound = 1;
223 | }
224 | if (args[1] == "16018")
225 | {
226 | Console.WriteLine("");
227 | Console.WriteLine("FORMAT Flag was used, but invalid format provided. (SHARPII_NET_CORE_TPL_INVALID_FORMAT)");
228 | Console.WriteLine("You used the -FORMAT flag, but an invalid format was provided.");
229 | Console.WriteLine("Provide a proper format.");
230 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
231 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
232 | Console.WriteLine("");
233 | ErrCodeFound = 1;
234 | }
235 | if (args[1] == "16019")
236 | {
237 | Console.WriteLine("");
238 | Console.WriteLine("A non U8 archive file was provided. (SHARPII_NET_CORE_U8_NON_U8)");
239 | Console.WriteLine("The provided file is not a U8 archive.");
240 | Console.WriteLine("Provide a U8 archive.");
241 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
242 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
243 | Console.WriteLine("");
244 | ErrCodeFound = 1;
245 | }
246 | if (args[1] == "16020")
247 | {
248 | Console.WriteLine("");
249 | Console.WriteLine("Folder Access Issue/Missing Folder. (SHARPII_NET_CORE_xxx_FOLDER_ERR)");
250 | Console.WriteLine("Either the folder doesn't exist, or Sharpii doesn't have permission to open it.");
251 | Console.WriteLine("Check the folders's permissions and that it's in the right place.");
252 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
253 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
254 | Console.WriteLine("");
255 | ErrCodeFound = 1;
256 | }
257 | if (args[1] == "16021")
258 | {
259 | Console.WriteLine("");
260 | Console.WriteLine("IMET Flag was used, but no title provided. (SHARPII_NET_CORE_xxx_NO_TITLE");
261 | Console.WriteLine("You used the -IMET flag, but no title was provided.");
262 | Console.WriteLine("Provide a proper title.");
263 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
264 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
265 | Console.WriteLine("");
266 | ErrCodeFound = 1;
267 | }
268 | if (args[1] == "16022")
269 | {
270 | Console.WriteLine("");
271 | Console.WriteLine("IMET and IMD5 Flags were used, but only one can be used. (SHARPII_NET_CORE_U8_TWO_HEADERS");
272 | Console.WriteLine("You used the -IMET and -IMD5 flags, but you can't use two headers.");
273 | Console.WriteLine("Provide only one flag.");
274 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
275 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
276 | Console.WriteLine("");
277 | ErrCodeFound = 1;
278 | }
279 | if (args[1] == "16023")
280 | {
281 | Console.WriteLine("");
282 | Console.WriteLine("ID Flag was used, but short ID provided. (SHARPII_NET_CORE_WAD_SHORT_ID)");
283 | Console.WriteLine("You used the -ID flag, but the provided id was too short to be correct.");
284 | Console.WriteLine("Provide a proper id.");
285 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
286 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
287 | Console.WriteLine("");
288 | ErrCodeFound = 1;
289 | }
290 | if (args[1] == "16024")
291 | {
292 | Console.WriteLine("");
293 | Console.WriteLine("TYPE or IOS Flag used, but no type provided. (SHARPII_NET_CORE_WAD_NO_TYPE)");
294 | Console.WriteLine("You used the -TYPE or -IOS flag, but no type was provided.");
295 | Console.WriteLine("Provide a proper type.");
296 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
297 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
298 | Console.WriteLine("");
299 | ErrCodeFound = 1;
300 | }
301 | if (args[1] == "16025")
302 | {
303 | Console.WriteLine("");
304 | Console.WriteLine("TYPE or IOS Flag used, but provided type unknown. (SHARPII_NET_CORE_WAD_UNKNOWN_TYPE)");
305 | Console.WriteLine("You used the -TYPE flag, but an unknown type was provided.");
306 | Console.WriteLine("Provide a proper type.");
307 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
308 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
309 | Console.WriteLine("");
310 | ErrCodeFound = 1;
311 | }
312 | if (args[1] == "16026")
313 | {
314 | Console.WriteLine("");
315 | Console.WriteLine("SOUND Flag used, but no wad provided. (SHARPII_NET_CORE_WAD_NO_SOUND)");
316 | Console.WriteLine("You used the -SOUND flag, but no wad file to provide sound was provided.");
317 | Console.WriteLine("Provide a proper wad.");
318 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
319 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
320 | Console.WriteLine("");
321 | ErrCodeFound = 1;
322 | }
323 | if (args[1] == "16027")
324 | {
325 | Console.WriteLine("");
326 | Console.WriteLine("BANNER Flag used, but no wad provided. (SHARPII_NET_CORE_WAD_NO_BANNER)");
327 | Console.WriteLine("You used the BANNER flag, but no wad file to provide a banner was provided.");
328 | Console.WriteLine("Provide a proper wad.");
329 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
330 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
331 | Console.WriteLine("");
332 | ErrCodeFound = 1;
333 | }
334 | if (args[1] == "16028")
335 | {
336 | Console.WriteLine("");
337 | Console.WriteLine("ID Flag was used, but invalid id provided. (SHARPII_NET_CORE_xxx_BAD_ID)");
338 | Console.WriteLine("You used the -ID flag, but an invalid id was provided.");
339 | Console.WriteLine("Provide a proper id.");
340 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
341 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
342 | Console.WriteLine("");
343 | ErrCodeFound = 1;
344 | }
345 | if (args[1] == "16029")
346 | {
347 | Console.WriteLine("");
348 | Console.WriteLine("Not all files needed to pack a wad are present. (SHARPII_NET_CORE_NUSD_MISSING_FILES)");
349 | Console.WriteLine("You need to have all the required .app files, a tmd file, a tik file, and a cert file to pack a wad.");
350 | Console.WriteLine("Ensure all files are present");
351 | Console.WriteLine("If that doesn't help, open an issue on GitHub!");
352 | Console.WriteLine("https://github.com/TheShadowEevee/Sharpii-NetCore/issues");
353 | Console.WriteLine("");
354 | ErrCodeFound = 1;
355 | }
356 | if (ErrCodeFound != 1)
357 | {
358 | ExitCode_help();
359 | }
360 | }
361 | catch (Exception)
362 | {
363 | ExitCode_help();
364 | }
365 | }
366 | public static void ExitCode_help()
367 | {
368 | Console.WriteLine("");
369 | Console.WriteLine("Sharpii .Net Core v{0} - Ported and Maintained by TheShadowEevee, originally by person66", ProgramVersion.version);
370 | Console.WriteLine("Using a modified version of libWiiSharp, originally made by leathl");
371 | Console.WriteLine("");
372 | Console.WriteLine("");
373 | Console.WriteLine(" Usage:");
374 | Console.WriteLine("");
375 | Console.WriteLine(" ./Sharpii EXITCODES [Exit]");
376 | Console.WriteLine("");
377 | Console.WriteLine(" Ex. \"Sharpii EXITCODES 16001\"");
378 | Console.WriteLine("");
379 | }
380 | }
381 | }
382 |
--------------------------------------------------------------------------------
/Sharpii/NUSD.cs:
--------------------------------------------------------------------------------
1 | /* This file is part of Sharpii.
2 | * Copyright (C) 2013 Person66
3 | * Copyright (C) 2020-2025 Sharpii-NetCore Contributors
4 | *
5 | * Sharpii is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * Sharpii is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with Sharpii. If not, see .
17 | */
18 |
19 | using libWiiSharp;
20 | using System;
21 | using System.Collections.Generic;
22 | using System.IO;
23 |
24 | namespace Sharpii
25 | {
26 | partial class NUS_Stuff
27 | {
28 | public static int ExceptionListRan = 0;
29 | public static void NUS(string[] args)
30 | {
31 | if (args.Length < 2)
32 | {
33 | NUS_help();
34 | return;
35 | }
36 | if (args[1].ToUpper() == "-H" || args[1].ToUpper() == "-HELP")
37 | {
38 | NUS_help();
39 | return;
40 | }
41 |
42 | //Set up variables
43 | string id = "";
44 | string url = "";
45 | string content = "";
46 | string version = "";
47 | int intver = -1;
48 | string output = "";
49 | bool local = false;
50 | List store = new List();
51 | bool entered = false;
52 | bool wad = false;
53 | bool NoOut = false;
54 | string ios = "";
55 | string temp = Path.GetTempPath() + "Sharpii.tmp";
56 | bool ContinueWithoutTicket = false;
57 |
58 | //Get arguments
59 | for (int i = 1; i < args.Length; i++)
60 | {
61 | switch (args[i].ToUpper())
62 | {
63 | case "-ALL":
64 | store.Add(StoreType.All);
65 | entered = true;
66 | break;
67 | case "-WAD":
68 | store.Add(StoreType.WAD);
69 | entered = true;
70 | break;
71 | case "-ENCRYPT":
72 | store.Add(StoreType.EncryptedContent);
73 | entered = true;
74 | break;
75 | case "-ENCRYPTED":
76 | store.Add(StoreType.EncryptedContent);
77 | entered = true;
78 | break;
79 | case "-DECRYPT":
80 | store.Add(StoreType.DecryptedContent);
81 | entered = true;
82 | break;
83 | case "-DECRYPTED":
84 | store.Add(StoreType.DecryptedContent);
85 | entered = true;
86 | break;
87 | case "-LOCAL":
88 | local = true;
89 | break;
90 | case "-V":
91 | if (i + 1 >= args.Length)
92 | {
93 | Console.WriteLine("ERROR: No version set");
94 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_NO_VERSION");
95 | if (OperatingSystem.Windows())
96 | {
97 | Environment.Exit(0x00003E8B);
98 | }
99 | else
100 | {
101 | Environment.Exit(0x0000000D);
102 | }
103 | return;
104 | }
105 | version = args[i + 1];
106 | if (version.ToUpper() == "LATEST")
107 | break;
108 | if (!int.TryParse(version, out intver))
109 | {
110 | Console.WriteLine("Invalid version {0}...", args[i + 1]);
111 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_INVALID_VERSION");
112 | if (OperatingSystem.Windows())
113 | {
114 | Environment.Exit(0x00003E8C);
115 | }
116 | else
117 | {
118 | Environment.Exit(0x0000000E);
119 | }
120 | return;
121 | }
122 | if (intver < 0 || intver > 65535)
123 | {
124 | Console.WriteLine("Invalid version {0}...", version);
125 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_INVALID_VERSION");
126 | if (OperatingSystem.Windows())
127 | {
128 | Environment.Exit(0x00003E8C);
129 | }
130 | else
131 | {
132 | Environment.Exit(0x0000000E);
133 | }
134 | return;
135 | }
136 | break;
137 | case "-VERSION":
138 | if (i + 1 >= args.Length)
139 | {
140 | Console.WriteLine("ERROR: No version set");
141 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_NO_VERSION");
142 | if (OperatingSystem.Windows())
143 | {
144 | Environment.Exit(0x00003E8B);
145 | }
146 | else
147 | {
148 | Environment.Exit(0x0000000D);
149 | }
150 | return;
151 | }
152 | version = args[i + 1];
153 | if (version.ToUpper() == "LATEST")
154 | break;
155 | if (!int.TryParse(version, out intver))
156 | {
157 | Console.WriteLine("Invalid version {0}...", args[i + 1]);
158 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_INVALID_VERSION");
159 | if (OperatingSystem.Windows())
160 | {
161 | Environment.Exit(0x00003E8C);
162 | }
163 | else
164 | {
165 | Environment.Exit(0x0000000E);
166 | }
167 | return;
168 | }
169 | if (intver < 0 || intver > 65535)
170 | {
171 | Console.WriteLine("Invalid version {0}...", version);
172 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_INVALID_VERSION");
173 | if (OperatingSystem.Windows())
174 | {
175 | Environment.Exit(0x00003E8C);
176 | }
177 | else
178 | {
179 | Environment.Exit(0x0000000E);
180 | }
181 | return;
182 | }
183 | break;
184 | case "-O":
185 | if (i + 1 >= args.Length)
186 | {
187 | Console.WriteLine("ERROR: No output set");
188 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_NO_OUTPUT");
189 | if (OperatingSystem.Windows())
190 | {
191 | Environment.Exit(0x00003E8D);
192 | }
193 | else
194 | {
195 | Environment.Exit(0x0000000F);
196 | }
197 | return;
198 | }
199 | output = args[i + 1];
200 | break;
201 | case "-ID":
202 | if (i + 1 >= args.Length)
203 | {
204 | Console.WriteLine("ERROR: No ID specified");
205 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_NO_ID");
206 | if (OperatingSystem.Windows())
207 | {
208 | Environment.Exit(0x00003E8E);
209 | }
210 | else
211 | {
212 | Environment.Exit(0x00000010);
213 | }
214 | return;
215 | }
216 | id = args[i + 1];
217 | id = id.ToUpper();
218 | break;
219 | case "-URL":
220 | if (i + 1 >= args.Length)
221 | {
222 | Console.WriteLine("ERROR: No URL specified");
223 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_NO_URL");
224 | if (OperatingSystem.Windows())
225 | {
226 | Environment.Exit(0x00003E8E);
227 | }
228 | else
229 | {
230 | Environment.Exit(0x00000010);
231 | }
232 | return;
233 | }
234 | url = args[i + 1];
235 | break;
236 | case "-IOS":
237 | if (i + 1 >= args.Length)
238 | {
239 | Console.WriteLine("ERROR: No IOS specified");
240 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_NO_IOS");
241 | if (OperatingSystem.Windows())
242 | {
243 | Environment.Exit(0x00003E86);
244 | }
245 | else
246 | {
247 | Environment.Exit(0x00000008);
248 | }
249 | return;
250 | }
251 | id = "00000001000000" + Convert.ToInt32(args[i + 1]).ToString("X2");
252 | break;
253 | case "-SINGLE":
254 | if (i + 1 >= args.Length)
255 | {
256 | Console.WriteLine("ERROR: No ID specified");
257 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_NO_ID");
258 | if (OperatingSystem.Windows())
259 | {
260 | Environment.Exit(0x00003E8E);
261 | }
262 | else
263 | {
264 | Environment.Exit(0x00000010);
265 | }
266 | return;
267 | }
268 | content = args[i + 1];
269 | break;
270 | case "-S":
271 | if (i + 1 >= args.Length)
272 | {
273 | Console.WriteLine("ERROR: No ID specified");
274 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_NO_ID");
275 | if (OperatingSystem.Windows())
276 | {
277 | Environment.Exit(0x00003E8E);
278 | }
279 | else
280 | {
281 | Environment.Exit(0x00000010);
282 | }
283 | return;
284 | }
285 | content = args[i + 1];
286 | break;
287 | }
288 | }
289 |
290 | //Error checking & stuff
291 | if (id == "")
292 | {
293 | Console.WriteLine("ERROR: No ID specified");
294 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_NO_ID");
295 | if (OperatingSystem.Windows())
296 | {
297 | Environment.Exit(0x00003E8E);
298 | }
299 | else
300 | {
301 | Environment.Exit(0x00000010);
302 | }
303 | return;
304 | }
305 |
306 | if (version == "")
307 | {
308 | if (BeQuiet.quiet > 2)
309 | Console.WriteLine("No version specified, using latest", version);
310 | version = "LATEST";
311 | }
312 |
313 | try
314 | {
315 | if (version.ToUpper() == "LATEST")
316 | {
317 | //Grab the TMD and get the latest version
318 | NusClient grabtmd = new NusClient();
319 | TMD tmd = grabtmd.DownloadTMD(id, "");
320 | version = tmd.TitleVersion.ToString();
321 | }
322 | }
323 | catch (Exception ex)
324 | {
325 | if (ex.Message == "Title ID must be 16 characters long!")
326 | {
327 | Console.WriteLine("");
328 | Console.WriteLine("The ID needs to be 16 Characters.");
329 | Console.WriteLine("");
330 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_BAD_ID");
331 | Console.WriteLine("");
332 | if (OperatingSystem.Windows())
333 | {
334 | Environment.Exit(0x00003E9C);
335 | }
336 | else
337 | {
338 | Environment.Exit(0x0000001E);
339 | }
340 | return;
341 | }
342 | if (ex.Message.Contains("The remote server returned an error:"))
343 | {
344 | Console.WriteLine("The remote server returned an HTTP error. Check your Title ID.");
345 | Console.WriteLine("");
346 | Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
347 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_SERVER_ERROR");
348 | if (OperatingSystem.Windows())
349 | {
350 | Environment.Exit(0x00003E9E);
351 | }
352 | else
353 | {
354 | Environment.Exit(0x00000020);
355 | }
356 | return;
357 | }
358 | if (ExceptionListRan == 0)
359 | {
360 | Console.WriteLine("An unknown error occurred, please try again");
361 | Console.WriteLine("");
362 | Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
363 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_UNKNOWN");
364 | if (OperatingSystem.Windows())
365 | {
366 | Environment.Exit(0x00003E82);
367 | }
368 | else
369 | {
370 | Environment.Exit(0x00000004);
371 | }
372 | return;
373 | }
374 | }
375 | if (BeQuiet.quiet > 2)
376 | Console.WriteLine("Found latest version: v{0}", version);
377 |
378 | if (entered == false) //Will only be false if no store type argument was given
379 | {
380 | store.Add(StoreType.All);
381 | if (BeQuiet.quiet > 2)
382 | Console.WriteLine("No store type specified, using all");
383 | }
384 |
385 | if (id.Length == 16 && Convert.ToInt32(id.Substring(14, 2), 16) >= 3 && Convert.ToInt32(id.Substring(14, 2), 16) <= 255 && id.Substring(0, 14) == "00000001000000")
386 | ios = "IOS" + Convert.ToInt32(id.Substring(14, 2), 16) + "-64-" + version + ".wad";
387 |
388 | bool isWadOutput = output.EndsWith(".wad", StringComparison.OrdinalIgnoreCase);
389 | bool isOutputEmpty = string.IsNullOrEmpty(output);
390 | bool hasOnlyWadStore = store.Count == 1 && store.Contains(StoreType.WAD);
391 | bool hasIos = !string.IsNullOrEmpty(ios);
392 |
393 | if (((isWadOutput || isOutputEmpty) && hasOnlyWadStore) || (isOutputEmpty && hasIos && hasOnlyWadStore))
394 | {
395 | wad = true;
396 | if (Directory.Exists(temp) == true)
397 | DeleteADir.DeleteDirectory(temp);
398 |
399 | Directory.CreateDirectory(temp);
400 | }
401 |
402 | if (output == "")
403 | {
404 | NoOut = true;
405 | output = ios == "" ? id + "v" + version : ios[0..^4];
406 | if (BeQuiet.quiet > 2)
407 | Console.WriteLine("No output specified, using {0}", output);
408 | }
409 |
410 | //Main part, catches random/unexpected exceptions
411 | try
412 | {
413 | NusClient nus = new NusClient();
414 |
415 | if (local == true)
416 | {
417 | if (BeQuiet.quiet > 2)
418 | Console.WriteLine("Using local files if present...");
419 | nus.UseLocalFiles = true;
420 | }
421 |
422 | if (ContinueWithoutTicket == true)
423 | {
424 | if (BeQuiet.quiet > 2)
425 | Console.WriteLine("Attempting Download without ticket");
426 | nus.ContinueWithoutTicket = true;
427 | }
428 |
429 | if (content != "")
430 | {
431 | if (BeQuiet.quiet > 1)
432 | Console.Write("Downloading content...");
433 |
434 | if (url != "")
435 | {
436 | nus.DownloadSingleContent(id, version, content, output, url);
437 | }
438 | else
439 | {
440 | nus.DownloadSingleContent(id, version, content, output);
441 | }
442 |
443 | if (BeQuiet.quiet > 1)
444 | Console.Write("Done!\n");
445 | }
446 | else
447 | {
448 | if (BeQuiet.quiet > 1)
449 | Console.Write("Downloading title...\n");
450 |
451 | string realout = output;
452 | if (wad == true)
453 | {
454 | output = temp;
455 | }
456 |
457 | if (url != "")
458 | {
459 | nus.DownloadTitle(id, version, output, url, store.ToArray());
460 | }
461 | else
462 | {
463 | nus.DownloadTitle(id, version, output, store.ToArray());
464 | }
465 |
466 |
467 | WadIosNamingStuff(wad, temp, id, version, ios, NoOut, output, realout);
468 |
469 | if (BeQuiet.quiet > 1)
470 | Console.Write("Done!\n");
471 | }
472 |
473 | if (BeQuiet.quiet > 1)
474 | Console.WriteLine("Operation completed successfully!\n");
475 | }
476 | catch (Exception ex)
477 | {
478 | if (ex.Message == "CETK Doesn't Exist and Downloading Ticket Failed:\nThe remote server returned an error: (404) Not Found.")
479 | {
480 | Console.WriteLine("The remote server returned a 404 error. Check your Title ID.");
481 | Console.WriteLine("If you have a CETK file, please place it in the same directory as Sharpii saves the NUS Files to.");
482 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_REMOTE_404");
483 | Console.WriteLine("");
484 |
485 | if (OperatingSystem.Windows())
486 | {
487 | Environment.Exit(0x00003E9E);
488 | }
489 | else
490 | {
491 | Environment.Exit(0x00000020);
492 | }
493 | return;
494 | }
495 | if (ex.Message == "Title ID must be 16 characters long!")
496 | {
497 | Console.WriteLine("");
498 | Console.WriteLine("The ID needs to be 16 Characters.");
499 | Console.WriteLine("");
500 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_BAD_ID");
501 | Console.WriteLine("");
502 | if (OperatingSystem.Windows())
503 | {
504 | Environment.Exit(0x00003E9C);
505 | }
506 | else
507 | {
508 | Environment.Exit(0x0000001E);
509 | }
510 | return;
511 | }
512 | if (ex.Message == "ERROR DETAILS: Downloading Content Failed:\nAn exception occurred during a WebClient request.")
513 | {
514 | Console.WriteLine("A WebClient Request Error occurred. This usually means that Sharpii can not properly download the file.");
515 | Console.WriteLine("Please ensure you have the proper permissions.");
516 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_WEBREQUEST_FAIL");
517 | ExceptionListRan = 1;
518 | if (OperatingSystem.Windows())
519 | {
520 | Environment.Exit(0x00003E9F);
521 | }
522 | else
523 | {
524 | Environment.Exit(0x00000021);
525 | }
526 | }
527 | if (ExceptionListRan == 0)
528 | {
529 | Console.WriteLine("An unknown error occurred, please try again");
530 | Console.WriteLine("");
531 | Console.WriteLine("ERROR DETAILS: {0}", ex.Message);
532 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_UNKNOWN");
533 | if (OperatingSystem.Windows())
534 | {
535 | Environment.Exit(0x00003E82);
536 | }
537 | else
538 | {
539 | Environment.Exit(0x00000004);
540 | }
541 | return;
542 | }
543 | }
544 |
545 | return;
546 | }
547 |
548 | private static void WadIosNamingStuff(bool wad, string temp, string id, string version, string ios, bool NoOut, string output, string realout)
549 | {
550 | bool LowercaseWad = false;
551 | bool OperationDone = false;
552 | if (wad == true)
553 | {
554 | try
555 | {
556 | if (!File.Exists(Path.Combine(temp, id + "v" + version + ".wad")))
557 | {
558 | LowercaseWad = true;
559 | try
560 | {
561 | if (!File.Exists(Path.Combine(temp, id.ToLower() + "v" + version + ".wad")))
562 | {
563 | Console.WriteLine("ERROR: Can't find WAD {0}", id.ToLower());
564 | Console.WriteLine("Try running without the -WAD or -ALL tag. If it still doesn't work, open an issue on Github.");
565 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_FILE_ERR");
566 | if (OperatingSystem.Windows())
567 | {
568 | Environment.Exit(0x00003E81);
569 | }
570 | else
571 | {
572 | Environment.Exit(0x00000003);
573 | }
574 | return;
575 | }
576 | }
577 | catch (Exception ex2)
578 | {
579 | Console.WriteLine("ERROR: Can't find WAD {0}", id.ToLower());
580 | Console.WriteLine("Try running without the -WAD or -ALL tag. If it still doesn't work, open an issue on Github.");
581 | Console.WriteLine("Exact Error: {0}", ex2.Message);
582 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_FILE_ERR");
583 | if (OperatingSystem.Windows())
584 | {
585 | Environment.Exit(0x00003E81);
586 | }
587 | else
588 | {
589 | Environment.Exit(0x00000003);
590 | }
591 | return;
592 | }
593 | }
594 | }
595 | catch (Exception ex)
596 | {
597 | Console.WriteLine("ERROR: Can't find WAD");
598 | Console.WriteLine("Try running with out the -WAD or -ALL tag. If it still doesn't work, open an issue on Github.");
599 | Console.WriteLine("Exact Error: {0}", ex.Message);
600 | Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_FILE_ERR");
601 | if (OperatingSystem.Windows())
602 | {
603 | Environment.Exit(0x00003E81);
604 | }
605 | else
606 | {
607 | Environment.Exit(0x00000003);
608 | }
609 | return;
610 | }
611 | if (ios != "" && NoOut == true && LowercaseWad == false)
612 | {
613 | int index = realout.LastIndexOf("\\") > realout.LastIndexOf("/") ? realout.LastIndexOf("\\") : realout.LastIndexOf("/");
614 | if (File.Exists(realout.Substring(0, index + 1) + ios))
615 | File.Delete(realout.Substring(0, index + 1) + ios);
616 | File.Move(Path.Combine(temp, id.ToUpper() + "v" + version + ".wad"), realout.Substring(0, index + 1) + ios);
617 | }
618 | else if (ios == "" && NoOut == true && LowercaseWad == false)
619 | {
620 | if (File.Exists(realout + ".wad"))
621 | File.Delete(realout + ".wad");
622 | File.Move(Path.Combine(temp, id.ToUpper() + "v" + version + ".wad"), realout + ".wad");
623 | }
624 | else if (LowercaseWad == false && OperationDone == false)
625 | {
626 | if (File.Exists(realout))
627 | File.Delete(realout);
628 | File.Move(Path.Combine(temp, id.ToUpper() + "v" + version + ".wad"), realout);
629 | }
630 | else if (ios != "" && NoOut == true && LowercaseWad == true)
631 | {
632 | int index = realout.LastIndexOf("\\") > realout.LastIndexOf("/") ? realout.LastIndexOf("\\") : realout.LastIndexOf("/");
633 | if (File.Exists(realout.Substring(0, index + 1) + ios))
634 | File.Delete(realout.Substring(0, index + 1) + ios);
635 | File.Move(Path.Combine(temp, id.ToLower() + "v" + version + ".wad"), realout.Substring(0, index + 1) + ios);
636 | }
637 | else if (ios == "" && NoOut == true && LowercaseWad == true)
638 | {
639 | if (File.Exists(realout + ".wad"))
640 | File.Delete(realout + ".wad");
641 | File.Move(Path.Combine(temp, id.ToLower() + "v" + version + ".wad"), realout + ".wad");
642 | }
643 | else if (LowercaseWad == true && OperationDone == false)
644 | {
645 | if (File.Exists(realout))
646 | File.Delete(realout);
647 | File.Move(Path.Combine(temp, id.ToLower() + "v" + version + ".wad"), realout);
648 | }
649 | DeleteADir.DeleteDirectory(temp);
650 | }
651 | else if (ios != "" && LowercaseWad == false)
652 | {
653 | if (output.Substring(output.Length - 1, 1) == "\\" || output.Substring(output.Length - 1, 1) == "/")
654 | output = output.Substring(output.Length - 1, 1);
655 | if (File.Exists(Path.Combine(output, id.ToUpper() + "v" + version + ".wad")))
656 | {
657 | if (File.Exists(Path.Combine(output, ios)))
658 | File.Delete(Path.Combine(output, ios));
659 | File.Move(Path.Combine(output, id.ToUpper() + "v" + version + ".wad"), Path.Combine(output, ios));
660 | }
661 | }
662 | else if (ios != "" && LowercaseWad == true)
663 | {
664 | if (output.Substring(output.Length - 1, 1) == "\\" || output.Substring(output.Length - 1, 1) == "/")
665 | output = output.Substring(output.Length - 1, 1);
666 | if (File.Exists(Path.Combine(output, id.ToLower() + "v" + version + ".wad")))
667 | {
668 | if (File.Exists(Path.Combine(output, ios)))
669 | File.Delete(Path.Combine(output, ios));
670 | File.Move(Path.Combine(output, id.ToLower() + "v" + version + ".wad"), Path.Combine(output, ios));
671 | }
672 | }
673 | }
674 | public static void NUS_help()
675 | {
676 | Console.WriteLine("");
677 | Console.WriteLine("Sharpii .Net Core v{0} - Ported and Maintained by TheShadowEevee, originally by person66", ProgramVersion.version);
678 | Console.WriteLine("Using a modified version of libWiiSharp, originally made by leathl");
679 | Console.WriteLine("");
680 | Console.WriteLine("");
681 | Console.WriteLine(" Usage:");
682 | Console.WriteLine("");
683 | Console.WriteLine(" ./Sharpii NUSD [-id titleID | -ios IOS] [-v version] [-o output] [-all]");
684 | Console.WriteLine(" [-wad] [-decrypt] [-encrypt] [-local] [-s content]");
685 | Console.WriteLine("");
686 | Console.WriteLine("");
687 | Console.WriteLine(" Arguments:");
688 | Console.WriteLine("");
689 | Console.WriteLine(" -id titleID [required] The Title ID of the file you wish to download");
690 | Console.WriteLine(" -v version [required] The version of the file you wish to download");
691 | Console.WriteLine(" NOTE: Use 'latest' to get the latest version");
692 | Console.WriteLine(" -ios IOS The IOS you wish to download. This is an alternative to");
693 | Console.WriteLine(" '-id', use one or the other, but not both.");
694 | Console.WriteLine(" -o output Folder to output the files to");
695 | Console.WriteLine(" -local Use local files if present");
696 | Console.WriteLine(" -s content Download a single content from the file");
697 | Console.WriteLine(" NOTE: When using this, output MUST have a path and a");
698 | Console.WriteLine(" filename. For current directory use '.\\[filename]'");
699 | Console.WriteLine(" -all Create and keep encrypted, decrypted, and WAD versions");
700 | Console.WriteLine(" of the file you wish to download");
701 | Console.WriteLine(" -wad Keep only the WAD version of the file you wish to");
702 | Console.WriteLine(" download");
703 | Console.WriteLine(" -decrypt Keep only the decrypted contents of the file you wish to");
704 | Console.WriteLine(" download");
705 | Console.WriteLine(" -encrypt Keep only the encrypted contents of the file you wish to");
706 | Console.WriteLine(" download");
707 | }
708 | }
709 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------