Service Access Control implemented to NPDM -> ACID
This commit is contained in:
parent
c3c89f2659
commit
4a803c7b08
8 changed files with 1422 additions and 1301 deletions
|
@ -78,6 +78,9 @@ public class NPDMController implements ITabController {
|
|||
@FXML
|
||||
private FSAccessControlController FSAccessControlTableController;
|
||||
|
||||
@FXML
|
||||
private ServiceAccessControlController ServiceAccessControlTableController;
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) { }
|
||||
|
||||
|
@ -163,6 +166,8 @@ public class NPDMController implements ITabController {
|
|||
acidReserved2Lbl.setText("-");
|
||||
|
||||
FSAccessControlTableController.resetTab();
|
||||
|
||||
ServiceAccessControlTableController.resetTab();
|
||||
}
|
||||
private void setData(NPDMProvider npdmProvider, File file) {
|
||||
if (npdmProvider == null)
|
||||
|
@ -223,6 +228,8 @@ public class NPDMController implements ITabController {
|
|||
acidKernelAccessControlSizeLbl.setText(Integer.toString(acid.getKernelAccessControlSize()));
|
||||
acidReserved2Lbl.setText(byteArrToHexString(acid.getReserved2()));
|
||||
|
||||
FSAccessControlTableController.populateFields(acid.getFSAccessControlProvider());
|
||||
FSAccessControlTableController.populateFields(acid.getFsAccessControlProvider());
|
||||
ServiceAccessControlTableController.populateFields(acid.getServiceAccessControlProvider().getCollection());
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package konogonka.Controllers.NPDM;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import konogonka.LoperConverter;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ServiceAccessControlController implements Initializable {
|
||||
|
||||
@FXML
|
||||
private VBox SACPane;
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
|
||||
}
|
||||
public void resetTab(){
|
||||
SACPane.getChildren().clear();
|
||||
}
|
||||
|
||||
public void populateFields(LinkedHashMap<Byte, String> collection){
|
||||
resetTab();
|
||||
|
||||
for (Object object : collection.entrySet()) {
|
||||
Map.Entry<Byte, String> entry = (Map.Entry) object;
|
||||
|
||||
Label control = new Label(String.format("0x%02x", entry.getKey()));
|
||||
Label serviceName = new Label(entry.getValue());
|
||||
|
||||
control.setPadding(new Insets(5.0, 5.0, 5.0, 5.0));
|
||||
serviceName.setPadding(new Insets(5.0, 5.0, 5.0, 5.0));
|
||||
|
||||
SACPane.getChildren().add(new HBox(control, serviceName));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ public class ACIDProvider {
|
|||
private byte[] reserved2;
|
||||
|
||||
private FSAccessControlProvider fsAccessControlProvider;
|
||||
|
||||
private ServiceAccessControlProvider serviceAccessControlProvider;
|
||||
|
||||
public ACIDProvider(byte[] acidBytes) throws Exception{
|
||||
if (acidBytes.length < 0x240)
|
||||
|
@ -53,6 +53,7 @@ public class ACIDProvider {
|
|||
if (fsAccessControlOffset > serviceAccessControlOffset || serviceAccessControlOffset > kernelAccessControlOffset )
|
||||
throw new Exception("ACIDProvider -> blocks inside the ACID are not sorted in ascending order. Only ascending order supported.");
|
||||
fsAccessControlProvider = new FSAccessControlProvider(Arrays.copyOfRange(acidBytes, fsAccessControlOffset, fsAccessControlOffset+fsAccessControlSize));
|
||||
serviceAccessControlProvider = new ServiceAccessControlProvider(Arrays.copyOfRange(acidBytes, serviceAccessControlOffset, serviceAccessControlOffset+serviceAccessControlSize));
|
||||
}
|
||||
|
||||
public byte[] getRsa2048signature() { return rsa2048signature; }
|
||||
|
@ -74,6 +75,6 @@ public class ACIDProvider {
|
|||
public int getKernelAccessControlSize() { return kernelAccessControlSize; }
|
||||
public byte[] getReserved2() { return reserved2; }
|
||||
|
||||
public FSAccessControlProvider getFSAccessControlProvider() { return fsAccessControlProvider; }
|
||||
|
||||
public FSAccessControlProvider getFsAccessControlProvider() { return fsAccessControlProvider; }
|
||||
public ServiceAccessControlProvider getServiceAccessControlProvider() { return serviceAccessControlProvider; }
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package konogonka.Tools.NPDM;
|
||||
|
||||
import konogonka.RainbowHexDump;
|
||||
import konogonka.Tools.ASuperInFileProvider;
|
||||
|
||||
import java.io.*;
|
||||
|
@ -109,13 +110,13 @@ public class NPDMProvider extends ASuperInFileProvider {
|
|||
acidSize = getLEint(metaBuf, 0x7C);
|
||||
// Get ACI0
|
||||
raf.seek(aci0offset);
|
||||
metaBuf = new byte[aci0size]; // TODO: NOTE: we read all size but need only header
|
||||
metaBuf = new byte[aci0size]; // TODO: NOTE: we read all size but it's memory consuming
|
||||
if (raf.read(metaBuf) != aci0size)
|
||||
throw new Exception("NPDMProvider: Failed to read 'ACI0'");
|
||||
aci0 = new ACI0Provider(metaBuf);
|
||||
// Get ACID
|
||||
raf.seek(acidOffset);
|
||||
metaBuf = new byte[acidSize]; // TODO: NOTE: we read all size but need only header
|
||||
metaBuf = new byte[acidSize]; // TODO: NOTE: we read all size but it's memory consuming
|
||||
if (raf.read(metaBuf) != acidSize)
|
||||
throw new Exception("NPDMProvider: Failed to read 'ACID'");
|
||||
acid = new ACIDProvider(metaBuf);
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package konogonka.Tools.NPDM;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class ServiceAccessControlProvider {
|
||||
|
||||
private LinkedHashMap<Byte, String> collection;
|
||||
|
||||
public ServiceAccessControlProvider(byte[] bytes){
|
||||
collection = new LinkedHashMap<>();
|
||||
byte key;
|
||||
String value;
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (i < bytes.length){
|
||||
key = bytes[i];
|
||||
value = new String(bytes, i+1, getSize(key), StandardCharsets.UTF_8);
|
||||
collection.put(key, value);
|
||||
i += getSize(key)+1;
|
||||
}
|
||||
}
|
||||
|
||||
private int getSize(byte control) {
|
||||
return ((byte) 0x7 & control) + 1;
|
||||
}
|
||||
|
||||
public LinkedHashMap<Byte, String> getCollection() { return collection; }
|
||||
}
|
|
@ -14,14 +14,11 @@
|
|||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<VBox xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="konogonka.Controllers.NPDM.FSAccessControlController">
|
||||
<Label text="FS Access Control">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
<TitledPane text="FS Access Control">
|
||||
<VBox.margin>
|
||||
<Insets bottom="5.0" />
|
||||
</VBox.margin>
|
||||
</Label>
|
||||
<content>
|
||||
|
||||
<GridPane>
|
||||
<columnConstraints>
|
||||
|
@ -226,7 +223,7 @@
|
|||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
<TitledPane text="Details">
|
||||
<TitledPane expanded="false" text="Details">
|
||||
<content>
|
||||
<GridPane gridLinesVisible="true">
|
||||
<columnConstraints>
|
||||
|
@ -1310,8 +1307,7 @@
|
|||
</content>
|
||||
</ScrollPane>
|
||||
</children>
|
||||
<VBox.margin>
|
||||
<Insets bottom="5.0" />
|
||||
</VBox.margin>
|
||||
</GridPane>
|
||||
</content>
|
||||
</TitledPane>
|
||||
</VBox>
|
||||
|
|
|
@ -1174,6 +1174,7 @@
|
|||
<Label text="** [5.0.0+] bit2-3: PoolPartition? For applets set to 0b01, for sysmodules set to 0b10. Exceptions: "starter" is set to 0, "nvservices" is set to 3" />
|
||||
<Label text="*** Inside of ACID block" />
|
||||
<fx:include fx:id="FSAccessControlTable" source="FSAccessControlTable.fxml" />
|
||||
<fx:include fx:id="ServiceAccessControlTable" source="ServiceAccessControlTable.fxml" />
|
||||
</children>
|
||||
</VBox>
|
||||
</content>
|
||||
|
|
41
src/main/resources/FXML/NPDM/ServiceAccessControlTable.fxml
Normal file
41
src/main/resources/FXML/NPDM/ServiceAccessControlTable.fxml
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.TitledPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<VBox xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="konogonka.Controllers.NPDM.ServiceAccessControlController">
|
||||
<TitledPane text="Service Access Control">
|
||||
<content>
|
||||
<VBox>
|
||||
<children>
|
||||
<HBox VBox.vgrow="ALWAYS">
|
||||
<children>
|
||||
<Label text="CTRL">
|
||||
<padding>
|
||||
<Insets left="5.0" right="5.0" />
|
||||
</padding>
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label text="Service name">
|
||||
<padding>
|
||||
<Insets left="5.0" right="5.0" />
|
||||
</padding>
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
<VBox fx:id="SACPane" />
|
||||
</children>
|
||||
</VBox>
|
||||
</content>
|
||||
</TitledPane>
|
||||
|
||||
</VBox>
|
Loading…
Reference in a new issue