#include "os.h" static unsigned addr_addrs[] = {0x107C1DDC, 0x10801E3C, 0x107A2DC8, 0x107FF0D0}; #define addr ((char **)nl_osvalue((int*)addr_addrs, 4)) static unsigned build_addrs[] = {0x10825114, 0x10865174, 0x10806100, 0x10862408}; #define build ((char *)nl_osvalue((int*)build_addrs, 4)) static unsigned version_addrs[] = {0x100A9CD8, 0x100A9F98, 0x100A93D4, 0x100A96BC}; #define version ((unsigned *)nl_osvalue((int*)version_addrs, 4)) #define CONFIG_FILE "/documents/ndless/verpatch.cfg.tns" int char2int(char c) { return c-'0'; } int main() { int major = 3; int minor = 1; int revision = 0; int b = 392; int ok = 0; if(nl_isstartup()) { FILE* h = fopen(CONFIG_FILE,"rb"); printf("startup-vpatch...\n"); if(h) { if(fread(&major,1,sizeof(int),h)==sizeof(int)) { if(fread(&minor,1,sizeof(int),h)==sizeof(int)) { if(fread(&revision,1,sizeof(int),h)==sizeof(int)) { if(fread(&b,1,sizeof(int),h)==sizeof(int)) { ok=1; } } } } fclose(h); } } else { if(show_2numeric_input("Change version", "model : [3.1].0.392", "3.", &major, -2, 0xF, "1.", &minor, -2, 0xFF)) if(show_2numeric_input("Change version", "model : 3.1.[0.392]", "0.", &revision, -2, 0xF, "392", &b, -2, 0xFFF)) ok=1; } if(ok) { char v[] = {major, minor, revision}; /* patch inside infos */ char * lol = malloc(sizeof(char)*15); sprintf(lol, " %d.%d.%d.%03d", v[0], v[1], v[2], b); printf("set version to %s\n",lol); *(addr) = lol; /* patch outide infos */ sprintf(build, "%03d", b); *(version-3) = 0xE3A02800 | (v[1]*10+v[2]); // MOV R2, #A, LSR16 *(version-2) = 0xE3A01400 | (v[0]); // MOV R1, #3, LSR24 *(version-1) = 0xE0800001; // ADD R0, R0, R1 *(version) = 0xE0800002; // ADD R0, R0, R2 FILE* h = fopen(CONFIG_FILE,"w+b"); if(h) { fwrite(&major,sizeof(int),1,h); fwrite(&minor,sizeof(int),1,h); fwrite(&revision,sizeof(int),1,h); fwrite(&b,sizeof(int),1,h); fclose(h); } } if(!nl_isstartup() && ok) show_msgbox("vPatch", "OS version patched until the next reboot. To make this permanent, move the patching program to the Ndless startup folder."); return 0; }