grab_it ROM dumper [source code]
May 29, 2008 in Software development, Windows Mobile by buzz_lightyear
Here’s the source code of grab_it tool.
I wrote it sometimes around may/june 2005 for some specific reason.
Maybe someone find this c++ source code useful.
// grab_it.cpp : Defines the entry point for the application.
// by buzz_lightyear
// sometime around may/june 2005
// http://buzzdev.net
#include "stdafx.h"
#include "windows.h"
// in this case, dump will be saved to MiniSD card
#define targetFile L"\Mini-SD\dump.bin"
int lineHeight=1; //progress bar height
int drawPoint=319;
int BarPosition=0;
int screenWidth = GetSystemMetrics(SM_CXSCREEN);
HDC hdc = ::GetDC(NULL);
HPEN lineProgress,lineBackground,po; // Pen Progress bar
wchar_t Buff[1024]; // buffer for Error messages
DWORD DumpStart=0x00000000; //start address
DWORD DumpSize=0x8000000; //Size
DWORD Step=0x80000;
extern "C" BOOL VirtualCopy(
LPVOID lpvDest,
LPVOID lpvSrc,
DWORD cbSize,
DWORD fdwProtect
);
int ShowProgress(int pos){
MoveToEx(hdc,0,drawPoint,NULL);
po = (HPEN)SelectObject(hdc,lineBackground);
LineTo(hdc,pos,drawPoint);
SelectObject(hdc,lineProgress);
LineTo(hdc,screenWidth,drawPoint);
SelectObject(hdc,lineBackground);
LineTo(hdc,screenWidth,drawPoint);
return 0;
}
int ShowError(wchar_t text[1024]){
MessageBox(NULL,text,L"ERROR",MB_OK | MB_TOPMOST | MB_SETFOREGROUND);
return 0;
}
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{/// 1st
lineProgress = CreatePen(PS_SOLID,lineHeight,RGB(255,0,0)); // Progress bar
lineBackground = CreatePen(PS_SOLID,lineHeight,RGB(100,100,100)); // Background bar
HANDLE H=CreateFile(targetFile,GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_FLAG_WRITE_THROUGH,0);
if(H==INVALID_HANDLE_VALUE)
{
MessageBox(NULL,L"Cannot create file!",L"Error",MB_OK);
return 1;
}
//for( i; i<(DumpStart+DumpSize); i+=Step)
{
LPVOID Ptr=VirtualAlloc(
0,
512*1024,
MEM_RESERVE,
PAGE_READONLY
);
if(Ptr==0)
{
wsprintf(Buff,L"Cannot allocate %08X",i);
ShowError(Buff);
return 1;
}
/// update progress bar ///
BarPosition=((i-DumpStart)/(DumpSize/screenWidth));
ShowProgress(BarPosition);
///////////////////////////
if(!VirtualCopy(Ptr,(void*)(i/256),512*1024,PAGE_EXECUTE_READWRITE|PAGE_PHYSICAL))
{
wsprintf(Buff,L"Cannot map %08X",i);
ShowError(Buff);
return 1;
}
DWORD W=0;
WriteFile(H,Ptr,512*1024,&W,0);
if(W!=512*1024)
{
wsprintf(Buff,L"Error on WriteFile. Card full?",i);
ShowError(Buff);
return 1;
}
VirtualFree(Ptr,0,MEM_RELEASE);
}
CloseHandle(H);
MessageBeep(MB_OK);
DeleteObject(lineBackground);
DeleteObject(lineProgress);
return 0;
}Related posts:
- grab_it – invisible ROM dumper- rename 'grab_it_xx.exe' to 'autorun.exe' - create folder '2577' on...
- The Best of Source Code CommentsWell.. do you write comments in your source code? I'm...
- How to post source code for highlitingHere’s little howto about posting source code in your posts,...
- Extended ROM unlocker for WindowsMobile 2005Here’s the source code of Extended ROM unlocker for: HTC...
WOW..thanks for sharing the code buzz.