/* (C) 2003 XDA Developers itsme@xs4all.nl * * $Header$ */ #include int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { TCHAR filename[1024]; if (!GetModuleFileName(NULL, filename, 1024)) { MessageBox(0,L"error getting module name",0,0); return 1; } int i; for (i=wcslen(filename)-1 ; i>=0 ; --i) if (filename[i]=='\\' || filename[i]=='/') { filename[i]= 0; break; } SYSTEMTIME t; GetSystemTime(&t); _sntprintf(filename+i, 1024-i, L"\\romfile-%04d%02d%02d-%02d%02d%02d.nb", t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond); HANDLE hFile= CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { MessageBox(0, L"Error creating romfile", 0, 0); return 1; } for (BYTE *p= (BYTE*)0x80000000 ; p<(BYTE*)0x82000000 ; p+=0x40000) { DWORD dwWrote; if (!WriteFile(hFile, p, 0x40000, &dwWrote, NULL)) { MessageBox(0, L"Error writing", 0, 0); break; } if (dwWrote!=0x40000) { MessageBox(0, L"Error writing", 0, 0); break; } } CloseHandle(hFile); MessageBox(0, L"rom saved", 0, MB_OK); return 0; }