diff options
author | Takamichi Horikawa <myon@myon98.net> | 2021-12-05 13:20:53 +0900 |
---|---|---|
committer | Takamichi Horikawa <myon@myon98.net> | 2021-12-05 13:24:22 +0900 |
commit | b43099221e2af2dfca8100b3fdf59d89c122f9d9 (patch) | |
tree | 66c8bc20d57663a9915fd1afaa3224369bfb353b |
-rw-r--r-- | Makefile | 17 | ||||
-rw-r--r-- | README.md | 30 | ||||
-rw-r--r-- | SHA256SUM | 2 | ||||
-rw-r--r-- | main.c | 91 |
4 files changed, 140 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..26debf0 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +OBJS=main.obj +CEVersion=400 +CePlatform= +CECrtMT=C +CePlatform=WIN32_PLATFORM_UNKNOWN +CESubsystem=windowsce,4.0 +CENoDefaultLib=libc.lib /nodefaultlib:libcd.lib /nodefaultlib:libcmt.lib /nodefaultlib:libcmtd.lib /nodefaultlib:msvcrt.lib /nodefaultlib:msvcrtd.lib +LINK=link +LINKFLAGS=commctrl.lib coredll.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"mainWCRTStartup" /incremental:no /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /MACHINE:THUMB +CFLAGS=/nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "ARM" /D "_ARM_" /D "$(CePlatform)" /D "THUMB" /D "_THUMB_" /D "ARMV4T" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /QRarch4T /QRinterwork-return /O2 /M$(CECrtMT) /c + +sig3romdump.exe: $(OBJS) + $(LINK) /out:$@ $(LINKFLAGS) $(OBJS) + +clean: + -erase main.obj + -erase sig3romdump.exe
\ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9cb8157 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# Sigmarion III ROM dumper +This is a simple program that dumps the rom and flash data from Sigmarion III. + +See [https://www.myon98.net/softwares/](https://www.myon98.net/softwares/) for pre-built binary. + +Checksums for the extracted roms are attached for reference. + +## Details +* rom.dat: 0x0000\_0000 - 0x01ff\_ffff (32MB) +* flash.dat: 0x0c00\_0000 - 0x0c3f\_ffff ( 4MB) + +It will dump these files into the same directory as the executable. Because of the size of the output files, it is not recommended to run this in the internal RAM filesystem. + +This is a console application, but can be double tap executed from Explorer and it will wait for an enter key at the end before closing. (WinCE does not have the concept of current directory anyways) + +There are absolutely no check whether the running machine is actually Sigmarion III. + +## Building +eMbedded Visual C++ 4.0 is used, load the environment variables from wcearmv4t.bat and run nmake. + +## Extracting files +### ROM +1. Remove first 256KiB from rom.dat and save as romdata.dat +2. dumprom -3 -d romdata romdata.dat + +### Flash +TODO + +## References +* [Inside Sigmarion III](https://z.apps.atjp.jp/sig3/) diff --git a/SHA256SUM b/SHA256SUM new file mode 100644 index 0000000..e06d625 --- /dev/null +++ b/SHA256SUM @@ -0,0 +1,2 @@ +SHA256 (flash.dat) = b3f8dc81b546fe7524f302e5fa2c8809a1404e85dbec6dc9d3ea2a4d57f7c28f +SHA256 (rom.dat) = 58afdc4badef46d46a5365d4d73f301e388c9eac370095d461ab8846ba67073c @@ -0,0 +1,91 @@ +#include <windows.h> +#include <stdio.h> + +BOOL WINAPI VirtualCopy(LPVOID lpvDest, LPVOID lpvSrc, DWORD cbSize, DWORD fdwProtect); + +enum { + PAGESIZE = 0x10000, +}; + +static BOOL writefile(const void *p, unsigned size, const wchar_t *fname) +{ + FILE *f = 0; + const char *pb = p; + BOOL ret = FALSE; + + f = _wfopen(fname, L"wb"); + if (!f) { + wprintf(L"\nError: fopen failed! Aborting.\n"); + goto cleanup; + } + while (size) { + const unsigned wsize = (size < PAGESIZE) ? size : PAGESIZE; + if (fwrite(pb, 1, wsize, f) != wsize) { + wprintf(L"\nError: fwrite failed! Aborting.\n"); + goto cleanup; + } + wprintf(L"."); + fflush(stdout); + pb += wsize; + size -= wsize; + } + ret = TRUE; +cleanup: + if (f) fclose(f); + return ret; +} + + +struct data { + unsigned addr; + unsigned size; + const wchar_t *name; +}; + +const struct data roms[] = { + {0x00000000, 0x02000000, L"rom.dat"}, // 0x0000_0000 - 0x01ff_ffff + {0x0c000000, 0x00400000, L"flash.dat"}, // 0x0c00_0000 - 0x0c3f_ffff + {0, 0, 0}, +}; + +int wmain(int argc, wchar_t **argv) +{ + wchar_t fname[MAX_PATH]; + wchar_t *pathend; + const struct data *i; + + if (!GetModuleFileName(0, fname, MAX_PATH)) { + wprintf(L"Error: Cannot get executable file path! Aborting.\n"); + goto end; + } + pathend = wcsrchr(fname, L'\\'); + if (!pathend) { + wprintf(L"Error: Cannot get directory to write rom files! Aborting\n"); + goto end; + } + for (i = roms; i->name; i++) { + void *p; + + /* too lazy to check string length */ + pathend[1] = 0; + wcscat(fname, i->name); + wprintf(L"Dumping %ls", fname); + fflush(stdout); + p = VirtualAlloc(0, i->size, MEM_RESERVE, PAGE_NOACCESS); + if (!p) { + wprintf(L"\nError: VirtualAlloc failed! Aborting.\n"); + goto end; + } + if (!VirtualCopy(p, (void *)(i->addr >> 8), i->size, PAGE_READONLY | PAGE_PHYSICAL)) { + wprintf(L"\nError: VirtualCopy failed! Aborting.\n"); + goto end; + } + if (!writefile(p, i->size, fname)) return 1; + wprintf(L"OK!\n"); + } +end: + wprintf(L"Press enter to continue...\n"); + getwchar(); + return 0; +} + |