Git Product home page Git Product logo

nx2elf's People

Contributors

shuffle2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nx2elf's Issues

"please report this" triggered on Fire emblem: three houses

Filing in response to

error: raw MOD failed to find .data in .dynsym. please report this.

I am trying to look into the code for fire emblem three houses using your tool.
Here is the process I went through:

First applying nx2elf to main directly I get the following failure and no output.

../hfk10miiu03lobmh/main:
gnu_build_id: cecf500cea4c214c46abd94d133939c400000000000000000000000000000000
         file off file len mem off  mem len  bss/algn
0 [r-x]:      101   623532        0   a917c0      100
1 [r--]:   623633   3273c4   a92000   e14840        1
2 [rw-]:   94a9f7     9b10  18a7000    cc0e0   72cf20
.rodata-relative:
  .dynstr:   1a41f8     5e56
  .dynsym:   1a0be0     3618
segment digests:
0 [r-x]: 4aecae5756a817df37200b8c249a28a24f30acd3e920ec27b667e69cd1a4a771
1 [r--]: 075456fdfd6b5c68d81d1a844314d5a07072a4c2e425d8a41c9f08eb4c00c377
2 [rw-]: 05c8119381258163d3ac052d1dccc82ffdc63daca8c7625630050f73b80cc8ff
failed to make shdr for st_shndx 22

I had success getting an output using nso.py from SciresM however (https://gist.github.com/SciresM/62715cfb5d06648ee46bc4622d2725e5)

python2 nso.py main output

so I tried running nx2elf on the output.
Triggering:

error: raw MOD failed to find .data in .dynsym. please report this.

As you have requested, here is the report.

Can't open main from Wolfenstein 2

I'm trying to modify main from Wolfenstein 2: The New Colossus - with patch 1.2 and without patch.
And i got errors

warning: failed to meet ordering for sh_addr              160
warning: failed to meet ordering for sh_addr          202d5c0
warning: failed to meet ordering for sh_addr          5469b68
warning: failed to meet ordering for sh_addr          5468e88
warning: failed to meet ordering for sh_addr          54c3e98

And this file cannot be opened with IDA Pro
image
When with SwitchIDAProLoader it can be opened directly.

make on raspberry fails (my only linux machine)

pi@raspberrypi:~/nx2elf $ make
g++ -o nx2elf .cpp .c -lstdc++fs -std=c++14
nx2elf.cpp: In member function ‘bool NsoFile::WriteElf(const std::experimental:: filesystem::v1::__cxx11::path&)’:
nx2elf.cpp:723:117: error: no matching function for call to ‘ElfEHInfo::MeasureF rame(eh_frame_hdr
, uintptr_t
, u64*)’
_frame_hdr >(&image[eh_info.hdr_addr]), &eh_frame_ptr, &eh_info.frame_size)) {
^
In file included from nx2elf.cpp:12:0:
elf_eh.h:37:7: note: candidate: bool ElfEHInfo::MeasureFrame(const eh_frame_hdr
, uintptr_t*, size_t*)
bool MeasureFrame(const eh_frame_hdr hdr, uintptr_t eh_frame_ptr, size_t eh _frame_len);
^~~~~~~~~~~~
elf_eh.h:37:7: note: no known conversion for argument 3 from ‘u64
{aka long l ong unsigned int
}’ to ‘size_t
{aka unsigned int*}’
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 1

is it related to the arm architecture or?

Issue with Mario Kart 8 Deluxe

There seems to be an issue with MK8D binaries, inside the exefs folder I can find the following files:
main main.npdm rtld sdk subsdk0 subsdk1 subsdk2 subsdk3 subsdk4

Running the tool gives the following output:
https://filetrip.net/dl?i1QvmxjyDR
(Had to upload the file somewhere because the output was too big)

There are errors for each of the binaries. The elfs are generated, however the symbols are reported as corrupted. Ask me if you need more info. :)

LZ4_decompress_safe: -7555422 (expected bf1838)

This Error gets thrown at me when I try to convert the main/sdk/subsdk0 executables to elf for any game.
It works with some rtld executables.

[fruityloops@soda-lake SUPER MARIO ODYSSEY v0 (0100000000010000) (BASE)]$ nx2elf main
LZ4_decompress_safe: -7555422 (expected   bf1838)

Executables this happens on:

  • Super Mario Odyssey (1.0, 1.3)
  • Super Mario 3D World + Bowser's Fury (1.0, 1.1)
  • New Super Mario Bros. U Deluxe (1.0)

Built on commit eb40107 with gcc c++20

Maybe you can see this.

F:\NSP\nx2elf2nso\main:
gnu_build_id: 427cc70591c65847a433ff59d0dd70dc00000000000000000000000000000000
file off file len mem off mem len bss/algn
0 [r-x]: 101 f0d5d5 0 1c31918 100
1 [r--]: f0d6d6 57211e 1c32000 e7993e 1
2 [rw-]: 147f7f4 1381c8 2aac000 2c54b0 235b50
.rodata-relative:
.dynstr: 69ad70 7514
.dynsym: 6967b0 45c0
segment digests:
0 [r-x]: 7d1222526935809b3b69250f2316337225fffcbc4a07db8dc034c5357d54d5f1
1 [r--]: f832fdd03bcc6d029c55688aba1b0daa6730137d9bd1bc9e83036b71de0d1ba2
2 [rw-]: b9bc50b3587d572bf210dd223ea40684f1e8951b5d4db43963462e45b0247b8b
unexpected enc base ff
unexpected enc type ff

Building fails on Linux

$ make
g++ -o nx2elf *.cpp *.c -lstdc++fs -std=c++14
elf_eh.cpp: In lambda function:
elf_eh.cpp:49:33: error: ‘stderr’ was not declared in this scope
   49 |                         fprintf(stderr, "unexpected enc base %02x\n", enc);
      |                                 ^~~~~~
elf_eh.cpp:2:1: note: ‘stderr’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
    1 | #include "elf_eh.h"
  +++ |+#include <cstdio>
    2 | #include "types.h"
elf_eh.cpp:49:25: error: ‘fprintf’ was not declared in this scope; did you mean ‘wprintf’?
   49 |                         fprintf(stderr, "unexpected enc base %02x\n", enc);
      |                         ^~~~~~~
      |                         wprintf
elf_eh.cpp:63:33: error: ‘stderr’ was not declared in this scope
   63 |                         fprintf(stderr, "unexpected enc type %02x\n", enc);
      |                                 ^~~~~~
elf_eh.cpp:63:33: note: ‘stderr’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
elf_eh.cpp:63:25: error: ‘fprintf’ was not declared in this scope; did you mean ‘wprintf’?
   63 |                         fprintf(stderr, "unexpected enc type %02x\n", enc);
      |                         ^~~~~~~
      |                         wprintf
elf_eh.cpp: In member function ‘bool ElfEHInfo::MeasureFrame(const eh_frame_hdr*, uintptr_t*, size_t*)’:
elf_eh.cpp:92:33: error: ‘stderr’ was not declared in this scope
   92 |                         fprintf(stderr, "reading fde %zi failed\n", i);
      |                                 ^~~~~~
elf_eh.cpp:92:33: note: ‘stderr’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
elf_eh.cpp:92:25: error: ‘fprintf’ was not declared in this scope; did you mean ‘wprintf’?
   92 |                         fprintf(stderr, "reading fde %zi failed\n", i);
      |                         ^~~~~~~
      |                         wprintf
nx2elf.cpp:16:21: error: ‘filesystem’ is not a namespace-name; did you mean ‘system’?
   16 | namespace fs = std::filesystem;
      |                     ^~~~~~~~~~
      |                     system
nx2elf.cpp:28:30: error: ‘fs’ does not name a type
   28 | static void iter_files(const fs::path& directory, std::function<void(const fs::path&)> func) {
      |                              ^~
nx2elf.cpp:28:38: error: expected unqualified-id before ‘&’ token
   28 | static void iter_files(const fs::path& directory, std::function<void(const fs::path&)> func) {
      |                                      ^
nx2elf.cpp:28:38: error: expected ‘)’ before ‘&’ token
   28 | static void iter_files(const fs::path& directory, std::function<void(const fs::path&)> func) {
      |                       ~              ^
      |                                      )
nx2elf.cpp:28:40: error: expected initializer before ‘directory’
   28 | static void iter_files(const fs::path& directory, std::function<void(const fs::path&)> func) {
      |                                        ^~~~~~~~~
nx2elf.cpp:37:30: error: ‘fs’ does not name a type
   37 | static UniqueFile Open(const fs::path& path, const char *mode) {
      |                              ^~
nx2elf.cpp:37:38: error: expected unqualified-id before ‘&’ token
   37 | static UniqueFile Open(const fs::path& path, const char *mode) {
      |                                      ^
nx2elf.cpp:37:38: error: expected ‘)’ before ‘&’ token
   37 | static UniqueFile Open(const fs::path& path, const char *mode) {
      |                       ~              ^
      |                                      )
nx2elf.cpp:37:40: error: expected initializer before ‘path’
   37 | static UniqueFile Open(const fs::path& path, const char *mode) {
      |                                        ^~~~
nx2elf.cpp:41:13: error: ‘vector’ in namespace ‘std’ does not name a template type
   41 | static std::vector<u8> Read(const fs::path& path) {
      |             ^~~~~~
nx2elf.cpp:14:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
   13 | #include "lz4.h"
  +++ |+#include <vector>
   14 | #include "types.h"
nx2elf.cpp:55:25: error: ‘fs’ does not name a type
   55 | static bool Write(const fs::path& path, const std::vector<u8>& buffer) {
      |                         ^~
nx2elf.cpp:55:33: error: expected unqualified-id before ‘&’ token
   55 | static bool Write(const fs::path& path, const std::vector<u8>& buffer) {
      |                                 ^
nx2elf.cpp:55:33: error: expected ‘)’ before ‘&’ token
   55 | static bool Write(const fs::path& path, const std::vector<u8>& buffer) {
      |                  ~              ^
      |                                 )
nx2elf.cpp:55:35: error: expected initializer before ‘path’
   55 | static bool Write(const fs::path& path, const std::vector<u8>& buffer) {
      |                                   ^~~~
nx2elf.cpp:80:14: error: ‘vector’ in namespace ‘std’ does not name a template type
   80 |         std::vector<char> GetBuffer() {
      |              ^~~~~~
nx2elf.cpp:80:9: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
   80 |         std::vector<char> GetBuffer() {
      |         ^~~
nx2elf.cpp:95:14: error: ‘vector’ in namespace ‘std’ does not name a template type
   95 |         std::vector<char> buffer;
      |              ^~~~~~
nx2elf.cpp:95:9: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
   95 |         std::vector<char> buffer;
      |         ^~~
nx2elf.cpp: In member function ‘void StringTable::Finalize()’:
nx2elf.cpp:88:17: error: ‘buffer’ was not declared in this scope; did you mean ‘setbuffer’?
   88 |                 buffer = GetBuffer();
      |                 ^~~~~~
      |                 setbuffer
nx2elf.cpp:88:26: error: ‘GetBuffer’ was not declared in this scope; did you mean ‘setbuffer’?
   88 |                 buffer = GetBuffer();
      |                          ^~~~~~~~~
      |                          setbuffer
nx2elf.cpp: At global scope:
nx2elf.cpp:255:25: error: ‘fs’ does not name a type
  255 |         bool Load(const fs::path& path) {
      |                         ^~
nx2elf.cpp:255:33: error: expected unqualified-id before ‘&’ token
  255 |         bool Load(const fs::path& path) {
      |                                 ^
nx2elf.cpp:255:33: error: expected ‘)’ before ‘&’ token
  255 |         bool Load(const fs::path& path) {
      |                  ~              ^
      |                                 )
nx2elf.cpp:255:33: error: expected ‘;’ at end of member declaration
  255 |         bool Load(const fs::path& path) {
      |                                 ^
      |                                  ;
nx2elf.cpp:255:35: error: ‘path’ does not name a type
  255 |         bool Load(const fs::path& path) {
      |                                   ^~~~
nx2elf.cpp:534:29: error: ‘fs’ does not name a type
  534 |         bool WriteElf(const fs::path& path) {
      |                             ^~
nx2elf.cpp:534:37: error: expected unqualified-id before ‘&’ token
  534 |         bool WriteElf(const fs::path& path) {
      |                                     ^
nx2elf.cpp:534:37: error: expected ‘)’ before ‘&’ token
  534 |         bool WriteElf(const fs::path& path) {
      |                      ~              ^
      |                                     )
nx2elf.cpp:534:37: error: expected ‘;’ at end of member declaration
  534 |         bool WriteElf(const fs::path& path) {
      |                                     ^
      |                                      ;
nx2elf.cpp:534:39: error: ‘path’ does not name a type
  534 |         bool WriteElf(const fs::path& path) {
      |                                       ^~~~
nx2elf.cpp:1196:14: error: ‘vector’ in namespace ‘std’ does not name a template type
 1196 |         std::vector<u8> image;
      |              ^~~~~~
nx2elf.cpp:1196:9: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
 1196 |         std::vector<u8> image;
      |         ^~~
nx2elf.cpp: In member function ‘bool NsoFile::ResolvePlt(void*, size_t)’:
nx2elf.cpp:245:58: error: ‘image’ was not declared in this scope
  245 |                                 plt_info.addr = found - &image[0];
      |                                                          ^~~~~
nx2elf.cpp: In member function ‘void NsoFile::DumpElfInfo()’:
nx2elf.cpp:497:55: error: ‘image’ was not declared in this scope
  497 |                         DT_ASSIGN_PTR(DT_RELA, rela, &image[dyn->d_un]);
      |                                                       ^~~~~
nx2elf.cpp:492:93: note: in definition of macro ‘DT_ASSIGN_PTR’
  492 |                         case dt: rela_info.var = reinterpret_cast<decltype(rela_info.var)>((x)); break;
      |                                                                                             ^
nx2elf.cpp:518:32: error: ‘image’ was not declared in this scope
  518 |                 auto rodata = &image[header.segments[kRodata].mem_offset];
      |                                ^~~~~
nx2elf.cpp: In member function ‘void NsoFile::iter_dynsym(std::function<void(const Elf64_Sym&, unsigned int)>)’:
nx2elf.cpp:529:59: error: ‘image’ was not declared in this scope
  529 |                 auto sym = reinterpret_cast<Elf64_Sym *>(&image[dyn_info.symtab]);
      |                                                           ^~~~~
nx2elf.cpp: At global scope:
nx2elf.cpp:1235:28: error: ‘fs’ does not name a type
 1235 | static bool NsoToElf(const fs::path& path, bool verbose = false) {
      |                            ^~
nx2elf.cpp:1235:36: error: expected unqualified-id before ‘&’ token
 1235 | static bool NsoToElf(const fs::path& path, bool verbose = false) {
      |                                    ^
nx2elf.cpp:1235:36: error: expected ‘)’ before ‘&’ token
 1235 | static bool NsoToElf(const fs::path& path, bool verbose = false) {
      |                     ~              ^
      |                                    )
nx2elf.cpp:1235:38: error: expected initializer before ‘path’
 1235 | static bool NsoToElf(const fs::path& path, bool verbose = false) {
      |                                      ^~~~
nx2elf.cpp: In function ‘int main(int, char**)’:
nx2elf.cpp:1253:26: error: ‘fs’ has not been declared
 1253 |         if (argc < 2 || !fs::exists(argv[1])) {
      |                          ^~
nx2elf.cpp:1258:9: error: ‘fs’ has not been declared
 1258 |         fs::path path(argv[1]);
      |         ^~
nx2elf.cpp:1259:13: error: ‘fs’ has not been declared
 1259 |         if (fs::is_directory(path)) {
      |             ^~
nx2elf.cpp:1259:30: error: ‘path’ was not declared in this scope
 1259 |         if (fs::is_directory(path)) {
      |                              ^~~~
nx2elf.cpp:1260:23: error: ‘iter_files’ is not a member of ‘File’
 1260 |                 File::iter_files(path, [](const fs::path& nx_path) {
      |                       ^~~~~~~~~~
nx2elf.cpp:1260:49: error: ‘fs’ does not name a type
 1260 |                 File::iter_files(path, [](const fs::path& nx_path) {
      |                                                 ^~
nx2elf.cpp: In lambda function:
nx2elf.cpp:1262:19: error: expected ‘{’ before ‘;’ token
 1262 |                 });
      |                   ^
nx2elf.cpp: In function ‘int main(int, char**)’:
nx2elf.cpp:1262:19: error: expected ‘)’ before ‘;’ token
 1262 |                 });
      |                   ^
      |                   )
nx2elf.cpp:1260:33: note: to match this ‘(’
 1260 |                 File::iter_files(path, [](const fs::path& nx_path) {
      |                                 ^
nx2elf.cpp:1265:17: error: ‘NsoToElf’ was not declared in this scope
 1265 |                 NsoToElf(path);
      |                 ^~~~~~~~
make: *** [Makefile:2: all] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.