Skip to content

Commit

Permalink
mostly fix NFC Patch (NTR CFW)
Browse files Browse the repository at this point in the history
also switched text in the UI to say "NFC Patch" instead of "NTR Patch"
  • Loading branch information
ChainSwordCS committed Sep 1, 2023
1 parent 0ea4d1d commit 5ac6e58
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 19 deletions.
47 changes: 38 additions & 9 deletions src/main/java/chokistream/NTRClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,47 @@ public Frame getFrame() throws InterruptedException {
return f;
}

// Probably doesn't work right now. Need to look at other implementations.
public static void sendNFCPatch(String host, int port, byte[] addr, ConsoleModel model) throws UnknownHostException, IOException {
byte[] binaryPacketPatch = new byte[11 + addr.length];
binaryPacketPatch[0] = (byte) 0x81;
binaryPacketPatch[1] = 0x0A;
binaryPacketPatch[4] = (byte) ((model == ConsoleModel.N3DS) ? 0x1A : 0x19);
binaryPacketPatch[binaryPacketPatch.length - 2] = 0x70;
binaryPacketPatch[binaryPacketPatch.length - 1] = 0x47;
public static void sendNFCPatch(String host, int port, byte[] addr) throws UnknownHostException, IOException {
byte[] pak = new byte[84+2];

// magic number / secret code (dumb)
pak[3] = 0x12;
pak[2] = 0x34;
pak[1] = 0x56;
pak[0] = 0x78;

// currentSeq (?)
pak[4] = (byte) 0xc0;
pak[5] = 0x5d;

// type
pak[8] = 0x01;

// command
pak[12] = 0x0a;

// "args" section

// pid
pak[16] = 0x1a;

// address
pak[20] = addr[0];
pak[21] = addr[1];
pak[22] = addr[2];
pak[23] = addr[3];

// length of data section (written in two places, for some reason)
pak[24] = 0x02;
pak[80] = 0x02;

// data section
pak[84] = 0x70;
pak[85] = 0x47;

Socket patchClient = new Socket(host, port);
OutputStream patchOut = patchClient.getOutputStream();
patchOut.write(binaryPacketPatch);
patchOut.write(pak);
patchOut.close();
patchClient.close();
}
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/chokistream/SwingGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class SwingGUI extends SettingsUI {
private JTextField priFac;
private JTextField qos;

// NTR patch screen
// NFC Patch screen
private JFrame ntrPatch;

private static final Logger logger = Logger.INSTANCE;
Expand Down Expand Up @@ -635,36 +635,35 @@ public void createNTRPatch() {
JPanel p = new JPanel();
GridBagConstraints c = new GridBagConstraints();
frameSetup(ntrPatch, p, c);
ntrPatch.setTitle("NTR Patch");
ntrPatch.setTitle("NFC Patch");

JLabel header = new JLabel("NTR Patch");
JLabel header = new JLabel("NFC Patch");
header.setFont(new Font("System", Font.PLAIN, 20));
add(header, p, c, 0, 0, 2, 1);

JButton n3ds = new JButton("New 3DS");
JButton n3ds = new JButton(">= 11.4");
add(n3ds, p, c, 0, 1);
n3ds.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
ntrPatch.setVisible(false);
JOptionPane.showMessageDialog(f, "NTR patch isn't implemented yet, check back soon!", "Error", JOptionPane.ERROR_MESSAGE);
//NTRClient.sendNFCPatch(getPropString(Prop.IP), getPropInt(Prop.PORT), null, ConsoleModel.N3DS);
} catch (RuntimeException ex) {
NTRClient.sendNFCPatch(getPropString(Prop.IP), getPropInt(Prop.PORT), new byte[]{0x00, 0x5b, 0x10, 0x00});
} catch (IOException | RuntimeException ex) {
displayError(ex);
}
}
});

JButton o3ds = new JButton("Old 3DS");
JButton o3ds = new JButton("<= 11.3");
add(o3ds, p, c, 1, 1);
o3ds.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
ntrPatch.setVisible(false);
JOptionPane.showMessageDialog(f, "NTR patch isn't implemented yet, check back soon!", "Error", JOptionPane.ERROR_MESSAGE);
} catch (RuntimeException ex) {
NTRClient.sendNFCPatch(getPropString(Prop.IP), getPropInt(Prop.PORT), new byte[]{(byte)0xe4, 0x5a, 0x10, 0x00});
} catch (IOException | RuntimeException ex) {
displayError(ex);
}
}
Expand Down

0 comments on commit 5ac6e58

Please sign in to comment.