GoldLeaf v0.5 support added
Pay attention! All previous GoldLeaf versions are incompatible with this application
This commit is contained in:
Dmitry Isaenko 2019-03-28 00:05:50 +03:00
parent 4b2402f801
commit 20e4197e45
4 changed files with 73 additions and 48 deletions

View file

@ -8,7 +8,7 @@
<name>NS-USBloader</name> <name>NS-USBloader</name>
<artifactId>ns-usbloader</artifactId> <artifactId>ns-usbloader</artifactId>
<version>0.3.2-SNAPSHOT</version> <version>0.4-SNAPSHOT</version>
<url>https://github.com/developersu/ns-usbloader/</url> <url>https://github.com/developersu/ns-usbloader/</url>
<description> <description>

View file

@ -91,6 +91,7 @@ public class NSLMainController implements Initializable {
tableFilesListController.setNewProtocol(choiceProtocol.getSelectionModel().getSelectedItem()); tableFilesListController.setNewProtocol(choiceProtocol.getSelectionModel().getSelectedItem());
if (choiceProtocol.getSelectionModel().getSelectedItem().equals("GoldLeaf")) { if (choiceProtocol.getSelectionModel().getSelectedItem().equals("GoldLeaf")) {
choiceNetUsb.setDisable(true); choiceNetUsb.setDisable(true);
choiceNetUsb.getSelectionModel().select("USB");
nsIpLbl.setVisible(false); nsIpLbl.setVisible(false);
nsIpTextField.setVisible(false); nsIpTextField.setVisible(false);
} }
@ -109,6 +110,7 @@ public class NSLMainController implements Initializable {
choiceNetUsb.getSelectionModel().select(AppPreferences.getInstance().getNetUsb()); choiceNetUsb.getSelectionModel().select(AppPreferences.getInstance().getNetUsb());
if (choiceProtocol.getSelectionModel().getSelectedItem().equals("GoldLeaf")) { if (choiceProtocol.getSelectionModel().getSelectedItem().equals("GoldLeaf")) {
choiceNetUsb.setDisable(true); choiceNetUsb.setDisable(true);
choiceNetUsb.getSelectionModel().select("USB");
} }
choiceNetUsb.setOnAction(e->{ choiceNetUsb.setOnAction(e->{
if (choiceNetUsb.getSelectionModel().getSelectedItem().equals("NET")){ if (choiceNetUsb.getSelectionModel().getSelectedItem().equals("NET")){

View file

@ -12,7 +12,7 @@ import java.util.Locale;
import java.util.ResourceBundle; import java.util.ResourceBundle;
public class NSLMain extends Application { public class NSLMain extends Application {
public static final String appVersion = "v0.3.2"; public static final String appVersion = "v0.4";
@Override @Override
public void start(Stage primaryStage) throws Exception{ public void start(Stage primaryStage) throws Exception{

View file

@ -4,6 +4,7 @@ import javafx.concurrent.Task;
import nsusbloader.ModelControllers.LogPrinter; import nsusbloader.ModelControllers.LogPrinter;
import nsusbloader.NSLDataTypes.EFileStatus; import nsusbloader.NSLDataTypes.EFileStatus;
import nsusbloader.NSLDataTypes.EMsgType; import nsusbloader.NSLDataTypes.EMsgType;
import nsusbloader.RainbowHexDump;
import nsusbloader.USB.PFS.PFSProvider; import nsusbloader.USB.PFS.PFSProvider;
import org.usb4java.*; import org.usb4java.*;
@ -456,15 +457,16 @@ public class UsbCommunications extends Task<Void> {
* */ * */
private class GoldLeaf{ private class GoldLeaf{
// CMD G L U C ID 0 0 0 // CMD G L U C ID 0 0 0
private final byte[] CMD_ConnectionRequest = new byte[]{0x47, 0x4c, 0x55, 0x43, 0x00, 0x00, 0x00, 0x00}; // Write-only command private final byte[] CMD_GLUC = new byte[]{0x47, 0x4c, 0x55, 0x43};
private final byte[] CMD_NSPName = new byte[]{0x47, 0x4c, 0x55, 0x43, 0x02, 0x00, 0x00, 0x00}; // Write-only command private final byte[] CMD_ConnectionRequest = new byte[]{0x00, 0x00, 0x00, 0x00}; // Write-only command
private final byte[] CMD_NSPData = new byte[]{0x47, 0x4c, 0x55, 0x43, 0x04, 0x00, 0x00, 0x00}; // Write-only command private final byte[] CMD_NSPName = new byte[]{0x02, 0x00, 0x00, 0x00}; // Write-only command
private final byte[] CMD_NSPData = new byte[]{0x04, 0x00, 0x00, 0x00}; // Write-only command
private final byte[] CMD_ConnectionResponse = new byte[]{0x47, 0x4c, 0x55, 0x43, 0x01, 0x00, 0x00, 0x00}; private final byte[] CMD_ConnectionResponse = new byte[]{0x01, 0x00, 0x00, 0x00};
private final byte[] CMD_Start = new byte[]{0x47, 0x4c, 0x55, 0x43, 0x03, 0x00, 0x00, 0x00}; private final byte[] CMD_Start = new byte[]{0x03, 0x00, 0x00, 0x00};
private final byte[] CMD_NSPContent = new byte[]{0x47, 0x4c, 0x55, 0x43, 0x05, 0x00, 0x00, 0x00}; private final byte[] CMD_NSPContent = new byte[]{0x05, 0x00, 0x00, 0x00};
private final byte[] CMD_NSPTicket = new byte[]{0x47, 0x4c, 0x55, 0x43, 0x06, 0x00, 0x00, 0x00}; private final byte[] CMD_NSPTicket = new byte[]{0x06, 0x00, 0x00, 0x00};
private final byte[] CMD_Finish = new byte[]{0x47, 0x4c, 0x55, 0x43, 0x07, 0x00, 0x00, 0x00}; private final byte[] CMD_Finish = new byte[]{0x07, 0x00, 0x00, 0x00};
GoldLeaf(){ GoldLeaf(){
logPrinter.print("===========================================================================", EMsgType.INFO); logPrinter.print("===========================================================================", EMsgType.INFO);
@ -484,17 +486,26 @@ public class UsbCommunications extends Task<Void> {
byte[] readByte; byte[] readByte;
// Go connect to GoldLeaf // Go connect to GoldLeaf
if (writeToUsb(CMD_ConnectionRequest)) if (writeToUsb(CMD_GLUC))
logPrinter.print("GL Initiating GoldLeaf connection", EMsgType.PASS); logPrinter.print("GL Initiating GoldLeaf connection: 1/2", EMsgType.PASS);
else { else {
logPrinter.print("GL Initiating GoldLeaf connection", EMsgType.FAIL); logPrinter.print("GL Initiating GoldLeaf connection: 1/2", EMsgType.FAIL);
return false;
}
if (writeToUsb(CMD_ConnectionRequest))
logPrinter.print("GL Initiating GoldLeaf connection: 2/2", EMsgType.PASS);
else {
logPrinter.print("GL Initiating GoldLeaf connection: 2/2", EMsgType.FAIL);
return false; return false;
} }
while (true) { while (true) {
readByte = readFromUsb(); readByte = readFromUsb();
if (readByte == null) if (readByte == null)
return false; return false;
if (Arrays.equals(readByte, CMD_GLUC)) {
readByte = readFromUsb();
if (readByte == null)
return false;
if (Arrays.equals(readByte, CMD_ConnectionResponse)) { if (Arrays.equals(readByte, CMD_ConnectionResponse)) {
if (!handleConnectionResponse(pfsElement)) if (!handleConnectionResponse(pfsElement))
return false; return false;
@ -524,6 +535,7 @@ public class UsbCommunications extends Task<Void> {
break; break;
} }
} }
}
return true; return true;
} }
/** /**
@ -531,23 +543,28 @@ public class UsbCommunications extends Task<Void> {
* */ * */
private boolean handleConnectionResponse(PFSProvider pfsElement){ private boolean handleConnectionResponse(PFSProvider pfsElement){
logPrinter.print("GL 'ConnectionResponse' command:", EMsgType.INFO); logPrinter.print("GL 'ConnectionResponse' command:", EMsgType.INFO);
if (!writeToUsb(CMD_NSPName)) { if (!writeToUsb(CMD_GLUC)) {
logPrinter.print(" [1/3]", EMsgType.FAIL); logPrinter.print(" [1/4]", EMsgType.FAIL);
return false; return false;
} }
logPrinter.print(" [1/3]", EMsgType.PASS); logPrinter.print(" [1/4]", EMsgType.PASS);
if (!writeToUsb(CMD_NSPName)) {
logPrinter.print(" [2/4]", EMsgType.FAIL);
return false;
}
logPrinter.print(" [2/4]", EMsgType.PASS);
if (!writeToUsb(pfsElement.getBytesNspFileNameLength())) { if (!writeToUsb(pfsElement.getBytesNspFileNameLength())) {
logPrinter.print(" [2/3]", EMsgType.FAIL); logPrinter.print(" [3/4]", EMsgType.FAIL);
return false; return false;
} }
logPrinter.print(" [2/3]", EMsgType.PASS); logPrinter.print(" [3/4]", EMsgType.PASS);
if (!writeToUsb(pfsElement.getBytesNspFileName())) { if (!writeToUsb(pfsElement.getBytesNspFileName())) {
logPrinter.print(" [3/3]", EMsgType.FAIL); logPrinter.print(" [4/4]", EMsgType.FAIL);
return false; return false;
} }
logPrinter.print(" [3/3]", EMsgType.PASS); logPrinter.print(" [4/4]", EMsgType.PASS);
return true; return true;
} }
@ -556,6 +573,12 @@ public class UsbCommunications extends Task<Void> {
* */ * */
private boolean handleStart(PFSProvider pfsElement){ private boolean handleStart(PFSProvider pfsElement){
logPrinter.print("GL Handle 'Start' command:", EMsgType.INFO); logPrinter.print("GL Handle 'Start' command:", EMsgType.INFO);
if (!writeToUsb(CMD_GLUC)) {
logPrinter.print(" [Send command prepare]", EMsgType.FAIL);
return false;
}
logPrinter.print(" [Send command prepare]", EMsgType.PASS);
if (!writeToUsb(CMD_NSPData)) { if (!writeToUsb(CMD_NSPData)) {
logPrinter.print(" [Send command]", EMsgType.FAIL); logPrinter.print(" [Send command]", EMsgType.FAIL);
return false; return false;
@ -602,7 +625,7 @@ public class UsbCommunications extends Task<Void> {
* */ * */
private boolean handleNSPContent(PFSProvider pfsElement, boolean isItRawRequest){ private boolean handleNSPContent(PFSProvider pfsElement, boolean isItRawRequest){
int requestedNcaID; int requestedNcaID;
boolean isProgessBarInitiated = false;
if (isItRawRequest) { if (isItRawRequest) {
logPrinter.print("GL Handle 'Content' command", EMsgType.INFO); logPrinter.print("GL Handle 'Content' command", EMsgType.INFO);
byte[] readByte = readFromUsb(); byte[] readByte = readFromUsb();