├── .gitattributes ├── .gitignore ├── CMakeLists.txt ├── README.md ├── cmake_modules └── FindIDASDK.cmake ├── loader └── nds.ldw ├── nds.cpp ├── nds.h ├── nds.sln └── nds.vcxproj /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # Build results 11 | [Dd]ebug/ 12 | [Dd]ebugPublic/ 13 | [Rr]elease/ 14 | [Rr]eleases/ 15 | x64/ 16 | x86/ 17 | build/ 18 | bld/ 19 | [Bb]in/ 20 | [Oo]bj/ 21 | 22 | # Roslyn cache directories 23 | *.ide/ 24 | 25 | # MSTest test Results 26 | [Tt]est[Rr]esult*/ 27 | [Bb]uild[Ll]og.* 28 | 29 | #NUNIT 30 | *.VisualState.xml 31 | TestResult.xml 32 | 33 | # Build Results of an ATL Project 34 | [Dd]ebugPS/ 35 | [Rr]eleasePS/ 36 | dlldata.c 37 | 38 | *_i.c 39 | *_p.c 40 | *_i.h 41 | *.ilk 42 | *.meta 43 | *.obj 44 | *.pch 45 | *.pdb 46 | *.pgc 47 | *.pgd 48 | *.rsp 49 | *.sbr 50 | *.tlb 51 | *.tli 52 | *.tlh 53 | *.tmp 54 | *.tmp_proj 55 | *.log 56 | *.vspscc 57 | *.vssscc 58 | .builds 59 | *.pidb 60 | *.svclog 61 | *.scc 62 | 63 | # Chutzpah Test files 64 | _Chutzpah* 65 | 66 | # Visual C++ cache files 67 | ipch/ 68 | *.aps 69 | *.ncb 70 | *.opensdf 71 | *.sdf 72 | *.cachefile 73 | 74 | # Visual Studio profiler 75 | *.psess 76 | *.vsp 77 | *.vspx 78 | 79 | # TFS 2012 Local Workspace 80 | $tf/ 81 | 82 | # Guidance Automation Toolkit 83 | *.gpState 84 | 85 | # ReSharper is a .NET coding add-in 86 | _ReSharper*/ 87 | *.[Rr]e[Ss]harper 88 | *.DotSettings.user 89 | 90 | # JustCode is a .NET coding addin-in 91 | .JustCode 92 | 93 | # TeamCity is a build add-in 94 | _TeamCity* 95 | 96 | # DotCover is a Code Coverage Tool 97 | *.dotCover 98 | 99 | # NCrunch 100 | _NCrunch_* 101 | .*crunch*.local.xml 102 | 103 | # MightyMoose 104 | *.mm.* 105 | AutoTest.Net/ 106 | 107 | # Web workbench (sass) 108 | .sass-cache/ 109 | 110 | # Installshield output folder 111 | [Ee]xpress/ 112 | 113 | # DocProject is a documentation generator add-in 114 | DocProject/buildhelp/ 115 | DocProject/Help/*.HxT 116 | DocProject/Help/*.HxC 117 | DocProject/Help/*.hhc 118 | DocProject/Help/*.hhk 119 | DocProject/Help/*.hhp 120 | DocProject/Help/Html2 121 | DocProject/Help/html 122 | 123 | # Click-Once directory 124 | publish/ 125 | 126 | # Publish Web Output 127 | *.[Pp]ublish.xml 128 | *.azurePubxml 129 | # TODO: Comment the next line if you want to checkin your web deploy settings 130 | # but database connection strings (with potential passwords) will be unencrypted 131 | *.pubxml 132 | *.publishproj 133 | 134 | # NuGet Packages 135 | *.nupkg 136 | # The packages folder can be ignored because of Package Restore 137 | **/packages/* 138 | # except build/, which is used as an MSBuild target. 139 | !**/packages/build/ 140 | # If using the old MSBuild-Integrated Package Restore, uncomment this: 141 | #!**/packages/repositories.config 142 | 143 | # Windows Azure Build Output 144 | csx/ 145 | *.build.csdef 146 | 147 | # Windows Store app package directory 148 | AppPackages/ 149 | 150 | # Others 151 | sql/ 152 | *.Cache 153 | ClientBin/ 154 | [Ss]tyle[Cc]op.* 155 | ~$* 156 | *~ 157 | *.dbmdl 158 | *.dbproj.schemaview 159 | *.pfx 160 | *.publishsettings 161 | node_modules/ 162 | 163 | # RIA/Silverlight projects 164 | Generated_Code/ 165 | 166 | # Backup & report files from converting an old project file 167 | # to a newer Visual Studio version. Backup files are not needed, 168 | # because we have git ;-) 169 | _UpgradeReport_Files/ 170 | Backup*/ 171 | UpgradeLog*.XML 172 | UpgradeLog*.htm 173 | 174 | # SQL Server files 175 | *.mdf 176 | *.ldf 177 | 178 | # Business Intelligence projects 179 | *.rdl.data 180 | *.bim.layout 181 | *.bim_*.settings 182 | 183 | # Microsoft Fakes 184 | FakesAssemblies/ 185 | 186 | # ========================= 187 | # Operating System Files 188 | # ========================= 189 | 190 | # OSX 191 | # ========================= 192 | 193 | .DS_Store 194 | .AppleDouble 195 | .LSOverride 196 | 197 | # Thumbnails 198 | ._* 199 | 200 | # Files that might appear on external disk 201 | .Spotlight-V100 202 | .Trashes 203 | 204 | # Directories potentially created on remote AFP share 205 | .AppleDB 206 | .AppleDesktop 207 | Network Trash Folder 208 | Temporary Items 209 | .apdisk 210 | 211 | # Windows 212 | # ========================= 213 | 214 | # Windows image file caches 215 | Thumbs.db 216 | ehthumbs.db 217 | 218 | # Folder config file 219 | Desktop.ini 220 | 221 | # Recycle Bin used on file shares 222 | $RECYCLE.BIN/ 223 | 224 | # Windows Installer files 225 | *.cab 226 | *.msi 227 | *.msm 228 | *.msp 229 | 230 | # Windows shortcuts 231 | *.lnk 232 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.3.2) 2 | project(ndsloader CXX) 3 | 4 | # build type 5 | if (NOT CMAKE_BUILD_TYPE) 6 | set(CMAKE_BUILD_TYPE Release) 7 | endif () 8 | 9 | if (CMAKE_BUILD_TYPE MATCHES Debug) 10 | set(PROJECT_CXXFLAGS "${PROJECT_CXXFLAGS} -O0") 11 | set(CMAKE_VERBOSE_MAKEFILE TRUE) 12 | else () 13 | set(PROJECT_CXXFLAGS "${PROJECT_CXXFLAGS} -O3") 14 | endif () 15 | 16 | message("Build type: ${CMAKE_BUILD_TYPE}") 17 | 18 | # project files 19 | set(PROJECT_SOURCEFILES 20 | 21 | nds.h 22 | nds.cpp 23 | ) 24 | 25 | # external cmake modules 26 | set(CMAKE_MODULE_PATH 27 | 28 | ${CMAKE_MODULE_PATH} 29 | ${CMAKE_SOURCE_DIR}/cmake_modules 30 | ) 31 | 32 | # ida sdk 33 | find_package(IDASDK REQUIRED) 34 | 35 | set(PROJECT_INCLUDEDIRECTORIES 36 | 37 | ${PROJECT_INCLUDEDIRECTORIES} 38 | ${IDASDK_INCLUDEDIRECTORIES} 39 | ) 40 | 41 | set(PROJECT_DEFINITIONS ${PROJECT_DEFINITIONS} ${IDASDK_DEFINITIONS}) 42 | set(PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${IDASDK_LIBRARIES}) 43 | 44 | # output directories 45 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 46 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 47 | 48 | # static files 49 | file(COPY ${CMAKE_SOURCE_DIR}/README.md DESTINATION ${CMAKE_BINARY_DIR}/lib) 50 | 51 | # project settings 52 | set(PROJECT_OUTPUTFILENAME "nds") 53 | 54 | set(CMAKE_CXX_FLAGS ${PROJECT_CXXFLAGS}) 55 | add_definitions(${PROJECT_DEFINITIONS}) 56 | 57 | include_directories(${PROJECT_INCLUDEDIRECTORIES}) 58 | link_directories(${PROJECT_LIBRARYFOLDERPATHLIST}) 59 | 60 | add_library(${PROJECT_OUTPUTFILENAME} SHARED ${PROJECT_SOURCEFILES}) 61 | target_link_libraries(${PROJECT_OUTPUTFILENAME} ${PROJECT_LIBRARIES}) 62 | 63 | set_target_properties(${PROJECT_OUTPUTFILENAME} PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") 64 | set_target_properties(${PROJECT_OUTPUTFILENAME} PROPERTIES PREFIX "") 65 | set_target_properties(${PROJECT_OUTPUTFILENAME} PROPERTIES SUFFIX ".llx") 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # About 2 | Nintendo DS loader module for IDA Pro 6.1 3 | 4 | # Windows Installation 5 | Copy ***nds.ldw*** to your ***loaders*** folder. 6 | 7 | # Linux Installation 8 | - Install the IDA SDK 9 | - Create a build folder 10 | - Generate the makefile using CMake: cmake -DIDASDK=/path/to/ida/sdk /path/to/source 11 | - Compile the plugin using make 12 | - Copy the nds.llx file inside your IDA directory 13 | 14 | # Credits 15 | - Dennis Elser: original loader. 16 | - Franck Charlet: other fixes. 17 | -------------------------------------------------------------------------------- /cmake_modules/FindIDASDK.cmake: -------------------------------------------------------------------------------- 1 | find_path(IDASDK_FOLDER include/ida.hpp HINTS $ENV{HOME}/ida-6.7/sdk $ENV{HOME}/ida-6.8/sdk $ENV{HOME}/ida-6.9/sdk $ENV{HOME}/ida/sdk $ENV{HOME}/IDA/sdk /opt/IDA/sdk NO_DEFAULT_PATH) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(IDASDK DEFAULT_MSG IDASDK_FOLDER) 5 | 6 | if (IDASDK_FOUND) 7 | set(IDASDK_INCLUDEDIRECTORIES ${IDASDK_FOLDER}/include ${IDASDK_FOLDER}/ldr) 8 | set(IDASDK_LIBRARIES ${IDASDK_FOLDER}/bin/libida.so) 9 | set(IDASDK_DEFINITIONS -D__LINUX__=1) 10 | endif () 11 | 12 | mark_as_advanced(IDASDK_INCLUDEDIRECTORIES IDASDK_DEFINITIONS) 13 | -------------------------------------------------------------------------------- /loader/nds.ldw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RigleGit/nds_loader/92f861539b8feb0375277d9746783aaed462b2e3/loader/nds.ldw -------------------------------------------------------------------------------- /nds.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | IDA Loader module for Nintendo DS (NDS) ROM files. 3 | Written by Dennis Elser. 4 | Fixed / Updated by Franck Charlet (hitchhikr@australia.edu). 5 | Reupdated to 6.1 by Rodrigo Iglesias (@Areidz). 6 | 7 | Comments: 8 | --------- 9 | This is the first loader module for IDA 10 | I have written so far. It might therefore 11 | give inaccurate results. 12 | Feedback, bugreports and donations are welcome =) 13 | 14 | dennis[at]backtrace[dot]de / www[dot]backtrace[dot]de 15 | 16 | 17 | Credits: 18 | -------- 19 | - Rafael Vuijk for the CRC16 Code and the 20 | NDS ROM Header layout 21 | - DataRescue for providing loader sourcecode 22 | with the IDA SDK 23 | 24 | History: 25 | -------- 26 | 27 | 2004/12/29 initial version 28 | 29 | - can disassemble arm7 or arm9 code 30 | - can add additional information about 31 | the ROM to database 32 | 33 | 2005/01/01 version 1.1 34 | 35 | - creates a section for the whole RAM area 36 | and maps the cartridge's code into it 37 | - adds more additional information about 38 | the ROM to database 39 | 40 | 2006/01/17 version 1.11 41 | 42 | - updated sourcecode to be compatible with IDA4.8 SDK 43 | 44 | 2007/10/29 version 1.12 45 | 46 | - updated sourcecode to be compatible with IDA5.x SDK 47 | - added more infos in header structure 48 | - fixed the allowed memory ranges 49 | - added more infos in disassembled header 50 | 51 | 2008/07/17 version 1.13 52 | 53 | - correctly positioned at program's entry point 54 | - corrected the selection of processors 55 | 56 | 2015/11/11 version 1.14 57 | - updated sourcecode to be compatible with IDA6.1 SDK 58 | 59 | */ 60 | 61 | #include 62 | #include "nds.h" 63 | 64 | //defines 65 | #define version "v1.14" 66 | 67 | //global data 68 | nds_hdr hdr; 69 | 70 | //-------------------------------------------------------------------------- 71 | // 72 | // the code of CalcCRC16() has been taken from Rafael Vuijk's "ndstool" 73 | // and slightly been modified by me 74 | // 75 | unsigned short CalcCRC16(nds_hdr *ndshdr) 76 | { 77 | unsigned short crc16 = 0xFFFF; 78 | for(int i = 0; i < 350; i++) 79 | { 80 | unsigned char data = *((unsigned char *) ndshdr + i); 81 | crc16 = (crc16 >> 8) ^ crc16tab[(crc16 ^ data) & 0xFF]; 82 | } 83 | return crc16; 84 | } 85 | 86 | //-------------------------------------------------------------------------- 87 | // 88 | // check input file format. if recognized, then return 1 89 | // and fill 'fileformatname'. 90 | // otherwise return 0 91 | // 92 | int idaapi accept_file(linput_t *li, char fileformatname[MAX_FILE_FORMAT_NAME], int n) 93 | { 94 | 95 | ulong filelen; 96 | 97 | if( n!= 0 ) 98 | return 0; 99 | 100 | // get filesize 101 | filelen = qlsize(li); 102 | 103 | // quit, if file is smaller than size of NDS header 104 | if (filelen < sizeof(nds_hdr)) 105 | return 0; 106 | 107 | // set filepos to offset 0 108 | qlseek(li, 0, SEEK_SET); 109 | 110 | // read whole NDS header 111 | if(qlread(li, &hdr, sizeof(nds_hdr)) != sizeof(nds_hdr)) 112 | return 0; 113 | 114 | // check validity of CRC16 value of header 115 | // this is used to determine if this file is an NDS file 116 | if (CalcCRC16(&hdr) != hdr.headerCRC16) 117 | return 0; 118 | 119 | // this is the name of the file format which will be 120 | // displayed in IDA's dialog 121 | qstrncpy(fileformatname, "Nintendo DS ROM", MAX_FILE_FORMAT_NAME); 122 | 123 | // Default processor 124 | set_processor_type("ARM", SETPROC_ALL); 125 | 126 | return (1 | ACCEPT_FIRST); 127 | } 128 | 129 | //-------------------------------------------------------------------------- 130 | // 131 | // load file into the database. 132 | // 133 | void load_file(linput_t *li, ushort /*neflag*/, const char * /*fileformatname*/) 134 | { 135 | 136 | int i; 137 | ea_t startEA; 138 | ea_t endEA; 139 | long offset; 140 | int ARM9; 141 | int found_mem_block; 142 | ea_t entry_point; 143 | 144 | // go to file-offset 0 145 | qlseek(li, 0, SEEK_SET); 146 | 147 | // and read the whole header 148 | qlread(li, &hdr, sizeof(nds_hdr)); 149 | 150 | // display a messagebox asking the user for details 151 | // 1 - Yes 152 | // 0 - No 153 | // -1 - Cancel 154 | int answer = askyn_cv(1, 155 | "NDS Loader by Dennis Elser.\n\n" 156 | "This file possibly contains ARM7 *and* ARM9 code.\n" 157 | "Choose \"Yes\" to load the ARM9 executable,\n" 158 | "\"No\" to load the ARM7 executable\n\n" 159 | "Please note that this loader has not been thoroughly tested!\n" 160 | "If you discover a bug, please let me know: dennis@backtrace.de\n" 161 | "\nDo you want to load the ARM9 code?\n\n" 162 | ,NULL 163 | ); 164 | 165 | // user chose "cancel" ? 166 | if(answer==BADADDR) 167 | { 168 | qexit(1); 169 | } 170 | 171 | // user chose "yes" = arm9 172 | if(answer) 173 | { 174 | set_processor_type("ARM", SETPROC_ALL); 175 | // init 176 | inf.startIP = inf.beginEA = hdr.arm9_entry_address; 177 | startEA = hdr.arm9_ram_address; 178 | endEA = hdr.arm9_ram_address + hdr.arm9_size; 179 | offset = hdr.arm9_rom_offset; 180 | ARM9 = true; 181 | // sanitycheck 182 | if (qlsize(li) < offset+hdr.arm9_size) 183 | { 184 | qexit(1); 185 | } 186 | } 187 | // user chose "no" = arm7 188 | else 189 | { 190 | set_processor_type("ARM710A", SETPROC_ALL); 191 | // init 192 | inf.startIP = inf.beginEA = hdr.arm7_entry_address; 193 | startEA = hdr.arm7_ram_address; 194 | endEA = hdr.arm7_ram_address + hdr.arm7_size; 195 | offset = hdr.arm7_rom_offset; 196 | ARM9 = false; 197 | // sanitycheck 198 | if(qlsize(li) < offset+hdr.arm7_size) 199 | { 200 | qexit(1); 201 | } 202 | } 203 | 204 | // check if segment lies within legal RAM blocks 205 | found_mem_block = false; 206 | for(i = 0; i < sizeof(memory) / sizeof(MEMARRAY); i++) { 207 | if(startEA >= memory[i].start || endEA <= memory[i].end) 208 | { 209 | found_mem_block = true; 210 | break; 211 | } 212 | } 213 | if(!found_mem_block) 214 | { 215 | qexit(1); 216 | } 217 | 218 | // map selector 219 | set_selector(1, 0); 220 | inf.start_cs = 1; 221 | 222 | // create a segment for the legal RAM blocks 223 | for(i = 0; i < sizeof(memory) / sizeof(MEMARRAY); i++) { 224 | if (!add_segm(1, memory[i].start, memory[i].end, "RAM", CLASS_CODE)) 225 | { 226 | qexit(1); 227 | } 228 | } 229 | 230 | // enable 32bit addressing 231 | set_segm_addressing(getseg( startEA ), 1); 232 | 233 | // load file into RAM area 234 | file2base(li, offset, startEA, endEA, FILEREG_PATCHABLE); 235 | 236 | entry_point = ARM9 == true ? hdr.arm9_entry_address : hdr.arm7_entry_address; 237 | 238 | // add additional information about the ROM to the database 239 | describe(startEA, true, "; Created with NDS Loader %s.\n", version); 240 | describe(startEA, true, "; Author 1: dennis@backtrace.de"); 241 | describe(startEA, true, "; Author 2: hitchhikr@australia.edu\n"); 242 | describe(startEA, true, "; Game Title: %s\n", hdr.title); 243 | describe(startEA, true, "; Processor: ARM%c", ARM9 == true ? '9' : '7'); 244 | describe(startEA, true, "; ROM Header size: 0x%08X", hdr.headerSize); 245 | describe(startEA, true, "; Header CRC: 0x%04X\n", hdr.headerCRC16); 246 | describe(startEA, true, "; Offset in ROM: 0x%08X", ARM9 == true ? hdr.arm9_rom_offset : hdr.arm7_rom_offset); 247 | describe(startEA, true, "; Array: 0x%08X - 0x%08X (%d bytes)", startEA, endEA, ARM9 == true ? hdr.arm9_size : hdr.arm7_size); 248 | describe(startEA, true, "; Entry point: 0x%08X\n", entry_point); 249 | 250 | describe(startEA, true, "; --- Beginning of ROM content ---", NULL); 251 | if(entry_point != startEA) 252 | { 253 | describe(entry_point, true, "; --- Entry point ---", NULL); 254 | } 255 | describe(endEA, true, "; --- End of ROM content ---", NULL); 256 | if(entry_point != BADADDR) 257 | { 258 | inf.start_cs = 0; 259 | inf.startIP = entry_point; 260 | } 261 | } 262 | 263 | //---------------------------------------------------------------------- 264 | // 265 | // LOADER DESCRIPTION BLOCK 266 | // 267 | //---------------------------------------------------------------------- 268 | loader_t LDSC = 269 | { 270 | IDP_INTERFACE_VERSION, 271 | 0, // loader flags 272 | // 273 | // check input file format. if recognized, then return 1 274 | // and fill 'fileformatname'. 275 | // otherwise return 0 276 | // 277 | accept_file, 278 | // 279 | // load file into the database. 280 | // 281 | load_file, 282 | // 283 | // create output file from the database. 284 | // this function may be absent. 285 | // 286 | NULL, 287 | NULL, 288 | NULL, 289 | }; 290 | -------------------------------------------------------------------------------- /nds.h: -------------------------------------------------------------------------------- 1 | typedef struct { 2 | unsigned int start; 3 | unsigned int end; 4 | } MEMARRAY, *LPMEMARRAY; 5 | 6 | MEMARRAY memory[] = { 7 | { 0x02000000, 0x02800000 }, 8 | { 0x037F8000, 0x037FFFFF }, 9 | { 0x03800000, 0x0380FFFF }, 10 | }; 11 | 12 | typedef struct { 13 | 14 | char title[0xC]; 15 | char gamecode[0x4]; 16 | 17 | unsigned char makercode[2]; 18 | unsigned char unitcode; 19 | unsigned char devicetype; // type of device in the game card 20 | unsigned char deviceSize; // capacity 21 | unsigned char reserved1[0x9]; 22 | unsigned char romversion; 23 | unsigned char flags; 24 | 25 | unsigned int arm9_rom_offset; 26 | unsigned int arm9_entry_address; 27 | unsigned int arm9_ram_address; 28 | unsigned int arm9_size; 29 | 30 | unsigned int arm7_rom_offset; 31 | unsigned int arm7_entry_address; 32 | unsigned int arm7_ram_address; 33 | unsigned int arm7_size; 34 | 35 | unsigned int filenameSource; 36 | unsigned int filenameSize; 37 | unsigned int fatSource; 38 | unsigned int fatSize; 39 | 40 | unsigned int arm9overlaySource; 41 | unsigned int arm9overlaySize; 42 | unsigned int arm7overlaySource; 43 | unsigned int arm7overlaySize; 44 | 45 | unsigned int cardControl13; // 0x60 used in modes 1 and 3 46 | unsigned int cardControlBF; // 0x64 used in mode 2 47 | unsigned int bannerOffset; // 0x68 48 | 49 | unsigned short secureCRC16; // 0x6c 50 | 51 | unsigned short readTimeout; // 0x6e 52 | 53 | unsigned int unknownRAM1; // 0x70 54 | unsigned int unknownRAM2; // 0x74 55 | 56 | unsigned int bfPrime1; // 0x78 57 | unsigned int bfPrime2; // 0x7c 58 | unsigned int romSize; // 0x80 59 | 60 | unsigned int headerSize; // 0x84 61 | unsigned int zeros88[14]; // 0x88 62 | unsigned char gbaLogo[156]; // 0xc0 63 | unsigned short logoCRC16; // 0x15c 64 | unsigned short headerCRC16; // 0x15e 65 | 66 | unsigned int debugRomSource; // 0x160 67 | unsigned int debugRomSize; // 0x164 68 | unsigned int debugRomDestination; // 0x168 69 | unsigned int offset_0x16C; // 0x16c 70 | 71 | unsigned char zero[0x90]; // 0x170 72 | } nds_hdr; 73 | 74 | const unsigned short crc16tab[] = 75 | { 76 | 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 77 | 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, 78 | 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, 79 | 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, 80 | 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, 81 | 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41, 82 | 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, 83 | 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040, 84 | 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, 85 | 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441, 86 | 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, 87 | 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, 88 | 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, 89 | 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40, 90 | 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, 91 | 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041, 92 | 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, 93 | 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441, 94 | 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, 95 | 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840, 96 | 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, 97 | 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, 98 | 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, 99 | 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041, 100 | 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, 101 | 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440, 102 | 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, 103 | 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841, 104 | 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, 105 | 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, 106 | 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, 107 | 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040 108 | }; -------------------------------------------------------------------------------- /nds.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2013 for Windows Desktop 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nds", "nds.vcxproj", "{6B2BB5E8-6F2F-4A95-95E4-7F3BF15EAB9C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {6B2BB5E8-6F2F-4A95-95E4-7F3BF15EAB9C}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {6B2BB5E8-6F2F-4A95-95E4-7F3BF15EAB9C}.Debug|Win32.Build.0 = Debug|Win32 16 | {6B2BB5E8-6F2F-4A95-95E4-7F3BF15EAB9C}.Release|Win32.ActiveCfg = Release|Win32 17 | {6B2BB5E8-6F2F-4A95-95E4-7F3BF15EAB9C}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /nds.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | 15 | 16 | {6B2BB5E8-6F2F-4A95-95E4-7F3BF15EAB9C} 17 | 18 | 19 | 20 | DynamicLibrary 21 | v120 22 | false 23 | MultiByte 24 | 25 | 26 | DynamicLibrary 27 | v120 28 | false 29 | MultiByte 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | .\Release\ 45 | .\Release\ 46 | false 47 | 48 | 49 | .\Debug\ 50 | .\Debug\ 51 | false 52 | $(VC_ReferencesPath_x86); 53 | $(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86); 54 | .ldw 55 | 56 | 57 | 58 | MultiThreaded 59 | Default 60 | true 61 | true 62 | MaxSpeed 63 | true 64 | Level3 65 | ..\..\include;%(AdditionalIncludeDirectories) 66 | WIN32;NDEBUG;_WINDOWS;_USRDLL;NDS_EXPORTS;__IDP__;__NT__;%(PreprocessorDefinitions) 67 | .\Release\ 68 | .\Release\nds.pch 69 | .\Release\ 70 | .\Release\ 71 | StdCall 72 | 73 | 74 | true 75 | NDEBUG;%(PreprocessorDefinitions) 76 | .\Release\nds.tlb 77 | true 78 | Win32 79 | 80 | 81 | 0x0419 82 | NDEBUG;%(PreprocessorDefinitions) 83 | 84 | 85 | true 86 | .\Release\nds.bsc 87 | 88 | 89 | true 90 | true 91 | Console 92 | ..\..\loaders\nds.ldw 93 | .\Release\nds.lib 94 | ../../libvc.w32;%(AdditionalLibraryDirectories) 95 | odbc32.lib;odbccp32.lib;ida.lib;%(AdditionalDependencies) 96 | /export:LDSC 97 | 98 | 99 | 100 | 101 | MultiThreadedDebug 102 | Default 103 | false 104 | Disabled 105 | true 106 | Level3 107 | true 108 | EditAndContinue 109 | C:\IDASDK\include;C:\IDASDK\ldr;%(AdditionalIncludeDirectories) 110 | WIN32;_DEBUG;_WINDOWS;_USRDLL;NDS_EXPORTS;__IDP__;__NT__;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS; 111 | 112 | 113 | .\Debug\nds.pch 114 | 115 | 116 | 117 | 118 | StdCall 119 | EnableFastChecks 120 | 121 | 122 | true 123 | _DEBUG;%(PreprocessorDefinitions) 124 | .\Debug\nds.tlb 125 | true 126 | Win32 127 | 128 | 129 | 0x0419 130 | _DEBUG;%(PreprocessorDefinitions) 131 | 132 | 133 | true 134 | .\Debug\nds.bsc 135 | 136 | 137 | true 138 | true 139 | true 140 | Console 141 | nds.ldw 142 | .\Debug\nds.lib 143 | C:\IDASDK\lib\x86_win_vc_32;%(AdditionalLibraryDirectories) 144 | odbc32.lib;odbccp32.lib;ida.lib;%(AdditionalDependencies) 145 | /export:LDSC 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | --------------------------------------------------------------------------------