Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with converting .npdm to .json #128

Open
canplx opened this issue Oct 8, 2024 · 14 comments
Open

Issue with converting .npdm to .json #128

canplx opened this issue Oct 8, 2024 · 14 comments

Comments

@canplx
Copy link

canplx commented Oct 8, 2024

Currently have a main.nmpd from a game and have placed the file into the same folder as hactool.exe, and only using a PC with no switch directory. I downloaded last hactool.exe release and used this command:

C:\Users\ [Name] \OneDrive\Desktop\hactool\hactool.exe -k C:\Users\ [Name] \AppData\Roaming\keys\prod.keys -t npdm --json=file C:\Users\ [Name] \OneDrive\Desktop\ [Output Folder]

And recieve the following error:

[WARN] prod.keys does not exist.
[WARN]: Failed to match key "bis_kek_source", (value "34c1a0c48258f8b4fa9e5e6adafc7e4f")
[WARN]: Failed to match key "bis_key_00", (value "bc9375d3e3b77cfaf1def8e6998bdcbc9b3915820ccf82435a3057aa07723a94")
[WARN]: Failed to match key "bis_key_01", (value "d2ce2c4aae2c7478dfcd19307032c2f6eb70f597d4e1e8174c4bc1e78da93c12")
[WARN]: Failed to match key "bis_key_02", (value "36e8d790debcdd659c9c0ba8f145630e70d9a3a33ec583a2b8bb7de9a33f69b4")
[WARN]: Failed to match key "bis_key_03", (value "36e8d790debcdd659c9c0ba8f145630e70d9a3a33ec583a2b8bb7de9a33f69b4")
[WARN]: Failed to match key "bis_key_source_00", (value "f83f386e2cd2ca32a89ab9aa29bfc7487d92b03aa8bfdee1a74c3b6e35cb7106")
[WARN]: Failed to match key "bis_key_source_01", (value "41003049ddccc065647a7eb41eed9c5f44424edab49dfcd98777249adc9f7ca4")
[WARN]: Failed to match key "bis_key_source_02", (value "52c2e9eb09e3ee2932a10c1fb6a0926c4d12e14b2a474c1c09cb0359f015f4e4")
[WARN]: Failed to match key "device_key", (value "c324c5de972571a329a434dc8c774cbf")
[WARN]: Failed to match key "device_key_4x", (value "581578e3fe27ca7776c1b14d825d163f")
[WARN]: Failed to match key "eticket_rsa_kek", (value "19c8b441d318802bad63a5beda283a84")
[WARN]: Failed to match key "eticket_rsa_kek_source", (value "dba451124ca0a9836814f5ed95e3125b")
[WARN]: Failed to match key "eticket_rsa_kekek_source", (value "466e57b74a447f02f321cde58f2f5535")
[WARN]: Failed to match key "eticket_rsa_keypair", (value "5a6c5e407ad418d3eccb09b970660922846c2aed94babe56c79895fe5395b233a2ed3201572fd7c7bce2e53f5c2a2e47c4d90a68fd5bebc70060e71894bdff523d87570ba56747ec62b5cecd0f3eb6b0f835fd01bd0202c85190b1fc27ea6c63889515a6a1a85d004fbed1d54f62a97118f8165d4b2622b0326e01ed3157792061bcb133aa38e6c3a80c10b27885aff4e3692eec2f8fe63cf1cbf98441cf0cba9c268f7236c800205ee584566dd1ca623a9723627faa66dbdd0279a65542d307c10ab66741b20af90f4bbe7ef01e55dd570da9135d3e03c9bb1a7324ab17725ffc70a6a1dd0ee05db48909665cc08befd28ad165dd74289c5983591ae5b7f745aa69701dbfb53ba2f60fc1f5b95e6c8767fcdfb7ad511893b02a80bf1e78498214a22393435869a6973dd88b2c9d86ea75fbae3dff6eb83946440fc3c7e4e15af942d3582899474b742ccc95e5bf301b15282e67d408dca140536b2003d14cd8f7f18ee8aa7ccc82b05568035da95c24bcca342cae6fbf80012a25d8f69e6ce22ec61607d5a9167ed3e22c1bbd01288f03a96fb124de9f48dd35ddb54579a50ac2a65b13f91f55a693c5ce22b75ece94b8b9e3018cea77a8e2b2ffa4bc40c2bcffb05ca844fb1d8b7f697993c09814119ab9010ef6e8c6bb96928297baa8cc9345c1756c1f421e0e0852b3216b80c1219212a8cb5")
[WARN]: Failed to match key "mariko_master_kek_source_05", (value "77605ad2ee6ef83c3f72e2599dac5e56")
[WARN]: Failed to match key "retail_specific_aes_key_source", (value "e2d6b87a119cb880e822888a46fba195")
[WARN]: Failed to match key "save_mac_key", (value "f523d5bb503152b56d052f2b2e1d24ab")
[WARN]: Failed to match key "save_mac_sd_card_kek_source", (value "0489ef5d326e1a59c4b7ab8c367aab17")
[WARN]: Failed to match key "save_mac_sd_card_key_source", (value "6f645947c56146f9ffa045d595332918")
[WARN]: Failed to match key "sd_card_custom_storage_key_source", (value "370c345e12e4cefe21b58e64db52af354f2ca5a3fc999a47c03ee004485b2fd0")
[WARN]: Failed to match key "sd_seed", (value "3a0dbab8bc543aff8d7c3f1f73276eed")
[WARN]: Failed to match key "ssl_rsa_kek", (value "b011100660d1dccbad1b1b733afa9f95")
[WARN]: Failed to match key "ssl_rsa_kek_source", (value "9a383bf431d0bd8132534ba964397de3")
[WARN]: Failed to match key "ssl_rsa_kekek_source", (value "7f5bb0847b25aa67fac84be23d7b6903")
[WARN]: Failed to match key "ssl_rsa_key", (value "019bc1b8983ce4035edbf6e82711afa204a842e30748fe8af219ea43c79020373c10fdafac6507882d6bf22bb86adb127448fb44e59916ce99790cdbf54b113b7d19ced895dd0540b2884bac67f392b3c79f370c0ff89c95cbc3e2d313f87d027a5ecb495ff618cb3f82211a83cc4239408deda646cef1f199299845b9fa2bec6fee19ac91377ca3f862b8339989f7f70d852d2025e2e5c736b05bb7b7cb483a3a4ab739ce3971d07bef25ecf0ecc5cb2b1562b7be68151351d74bab1631955c744dc5fae113301bc092bd82d7c3117d64bef79feaff6783da3021f3ac515686c48bce683c991ba0f52eebd569218f277a79bd96b725e9554cd16ea92295ebb1")
unable to open C:\Users\ [Name] \OneDrive\Desktop\ [Output Folder] : Permission denied

I wouldn't be surprised if I made an error somewhere, or if this isn't a option with my current setup.

@enriicsolaa
Copy link

Same here. And later I can't recompile it with npdmtool of switch-tools.

@masagrator
Copy link

masagrator commented Oct 16, 2024

Same here.

Their error comes from the fact that they mindlessly copy pasted stuff from readme without understanding that they are supposed to replace those brackets with proper names. [Name] and [Output Folder] are placeholders. So either you too don't understand what you are doing, or this error is not the same.

And later I can't recompile it with npdmtool of switch-tools.

It doesn't extract all informations.

@canplx
Copy link
Author

canplx commented Oct 16, 2024

Same here.

Their error comes from the fact that they mindlessly copy pasted stuff from readme without understanding that they are supposed to replace those brackets with proper names. [Name] and [Output Folder] are placeholders. So either you too don't understand what you are doing, or this error is not the same.

if your referring the the [Name] and [Output Folder] what I typed out isn't literally that, I just put that there so I wouldn't have to type the entire full names of my folders and user profile.

Also showing an example of how to properly type out the command would be nice.

@masagrator
Copy link

Same here.

Their error comes from the fact that they mindlessly copy pasted stuff from readme without understanding that they are supposed to replace those brackets with proper names. [Name] and [Output Folder] are placeholders. So either you too don't understand what you are doing, or this error is not the same.

if your referring the the [Name] and [Output Folder] what I typed out isn't literally that, I just put that there so I wouldn't have to type the entire full names of my folders and user profile.

Also showing an example of how to properly type out the command would be nice.

hactool -t npdm --json=output.json main.npdm

@enriicsolaa
Copy link

any other option to decompress, edit and compress npdm? Concretly I need to modify a main.npdm and I haven't found anything on the internet. I'm really desperate, and editing with HxD is not an option.

@masagrator
Copy link

Dunno what you want to achieve, but you can basically use my template I am using and it should work as long as you properly fill name, title_id, main_thread_stack_size and system_resource_size. The last one is not extracted by hactool, it's stored at 0x14 offset (in some games it's 0)

https://github.com/masagrator/SleepLoggerEx/blob/main/config.json

@borntohonk
Copy link

borntohonk commented Oct 17, 2024

another "issue" related to npdm functionality, it cannot properly read the .npdm of compiled binaries with the latest version of switch-tools.

It'll read the following with hactool -t npdm --json=output.json hbl.npdm

		}, {
			"type":	"debug_flags",
			"value":	{
				"allow_debug":	false,
				"force_debug":	false
			}
		}]

instead of

        {
            "type": "debug_flags",
            "value": {
                "allow_debug": false,
                "force_debug_prod": false,
                "force_debug": true
            }
        },

when compiling https://github.com/borntohonk/nx-hbloader/blob/master/hbl.json#L245-L252

side note: if https://github.com/Atmosphere-NX/hac2l was ready to compile / had binaries that'd probably(?) solve this? (It didn't compile when i tried recently)

@borntohonk
Copy link

@borntohonk that's actually wrong output anyway, retail game will always have allow_debug set to true, while everything else set to false

HBL is not a game.
Atmosphere-NX/Atmosphere@0c4ae55#diff-8f4f075aef2c24447ccda4c26924401ac8ee494eb948d971e1116e8df73bda07R433

/* 19.0.0+ disallows more than one flag set; we are always DebugMode for kernel, so ForceDebug is the most powerful/flexible flag to set. */
kac[i] = CapabilityDebugFlags::Encode(false, false, true);

@borntohonk
Copy link

borntohonk commented Oct 17, 2024

as for hac2l, which is supposed to be a replacement to this version of hactool;

Building nx_release
make[1]: Entering directory '/build/Atmosphere-NX/Atmosphere/tools/hac2l'
make[3]: '/build/Atmosphere-NX/Atmosphere/libraries/libstratosphere/lib/nintendo_nx_arm64_armv8a/release/libstratosphere.a' is up to date.
Checked library.
make[2]: *** No rule to make target '/build/Atmosphere-NX/Atmosphere/tools/hac2l/out/nintendo_nx_arm64_armv8a/release/hac2l.kip', needed by 'all'.  Stop.
make[1]: *** [/build/Atmosphere-NX/Atmosphere/tools/hac2l/tool.mk:80: all] Error 2
make[1]: Leaving directory '/build/Atmosphere-NX/Atmosphere/tools/hac2l'
make: *** [Makefile:39: nx_release] Error 2

changing Atmosphere-NX/Atmosphere/tools/hac2l/tool.mk
from:
%.kip : %.elf
to:
#%.kip : %.elf

instead progresses it to another error, which by changing Atmosphere-NX/Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_nca_file_system_driver.hpp class NcaFileSystemDriver private/public if condition to:

        public:
            struct StorageContext {

will make it compile further, but ultimately error

@borntohonk
Copy link

another "issue" related to npdm functionality, it cannot properly read the .npdm of compiled binaries with the latest version of switch-tools.

fix for that: https://github.com/borntohonk/hactuah/commit/54ba34e94b09a5043a60f24c5880a2a69a1fe272

@mrdude2478
Copy link

hactool -t npdm --json=output.json main.npdm

as for hac2l, which is supposed to be a replacement to this version of hactool;

Building nx_release
make[1]: Entering directory '/build/Atmosphere-NX/Atmosphere/tools/hac2l'
make[3]: '/build/Atmosphere-NX/Atmosphere/libraries/libstratosphere/lib/nintendo_nx_arm64_armv8a/release/libstratosphere.a' is up to date.
Checked library.
make[2]: *** No rule to make target '/build/Atmosphere-NX/Atmosphere/tools/hac2l/out/nintendo_nx_arm64_armv8a/release/hac2l.kip', needed by 'all'.  Stop.
make[1]: *** [/build/Atmosphere-NX/Atmosphere/tools/hac2l/tool.mk:80: all] Error 2
make[1]: Leaving directory '/build/Atmosphere-NX/Atmosphere/tools/hac2l'
make: *** [Makefile:39: nx_release] Error 2

changing Atmosphere-NX/Atmosphere/tools/hac2l/tool.mk from: %.kip : %.elf to: #%.kip : %.elf

instead progresses it to another error, which by changing Atmosphere-NX/Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_nca_file_system_driver.hpp class NcaFileSystemDriver private/public if condition to:

        public:
            struct StorageContext {

will make it compile further, but ultimately error

I can compile it fine on windows, I cloned the git into Atmosphere tests folder.

Don't edit tool.mk, go to the makefile and change the second line from:
all: nx_release
to
all: win_x64_release

Then you can compile with mingw64.exe

The built exe ends up at around about 40mb so I used upx packer to compress it down to about 10mb.

I've uploaded the built exe here - https://github.com/mrdude2478/New-Binaries

@SciresM
Copy link
Owner

SciresM commented Nov 2, 2024

Why pack it and not strip it? A stripped hac2l is like 600kb.

@borntohonk
Copy link

all: nx_release
to
all: win_x64_release

Similarly it does compile on linux_x64 with dependencies (such as libjpeg-dev, binutils-dev) on debian unstable, which also when stripped is ~600kb

@mrdude2478
Copy link

mrdude2478 commented Nov 4, 2024

Why pack it and not strip it? A stripped hac2l is like 600kb.

I stripped it and it makes it small. I forgot to do that when I compiled it :-), I'm an idiot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants