Example #1
0
int main(int argc, char** argv){

	if(argc != 2){
		printf("Invalid Arguments. Usage: raw_image_reader <path_to_file>\n");
		return -1;
	} 
	struct stat fstats;	
	int file = open(argv[1], O_RDONLY);
	MBR mbr;
	VBR vbr[NUM_OF_PARTITIONS];
	if(file<0){
		printf("Unable to open file");
		return -1;
	}
	printDivider();
	fstat(file, &fstats);
	calcMD5(file, fstats.st_size, argv[1]);
	calcSHA1(file, fstats.st_size, argv[1]);
	readMBR(file, (char*)&mbr);
	readVBR(file, &mbr, vbr);
	printDivider();
	printPartitions(&mbr);
	printDivider();
	printVBR(&mbr,vbr);
	close(file);
	return 1;
}
Example #2
0
INT_PTR CALLBACK Dialog1(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(lParam);
	switch (message)
	{
	case WM_INITDIALOG:
		return (INT_PTR)TRUE;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
		{
			EndDialog(hDlg, LOWORD(wParam));
			PostQuitMessage(0);
			return (INT_PTR)TRUE;
		}
		switch (LOWORD(wParam))
		{
		case IDC_VOLUME_INFO:
		{
			mBootSector mbs;
			//HWND val = GetDlgItem(hDlg, IDC_EDIT_VOLUME);
			//TCHAR temp[1024];
			//char ctemp[1024];
			/*GetDlgItemText(hDlg, IDC_EDIT_VOLUME, temp, 1024);

			for (int i = 0; i < lstrlen(temp); ++i)
				ctemp[i] = temp[i];
			ctemp[lstrlen(temp)] = 0;*/
			char vol[1024];
			getVolumeName(hDlg, vol);
			if (readBootSector(vol, mbs))
			{
				writeBootSectorToLog(mbs);
				CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)showLog, 0, 0, NULL);
			}
			
			else MessageBox(hDlg, L"Cannot open volume", L"Error", MB_OK);
			//system("notepad log.txt");
			break;
		}
		case IDC_DRIVE_INFO:
		{
			mMBR mbr;
			//HWND val = GetDlgItem(hDlg, IDC_EDIT_PHYSICAL_DRIVE);
			int driveNumber;// = GetDlgItemInt(hDlg, IDC_EDIT_PHYSICAL_DRIVE, 0, false);//get
			getPhysicalNumber(hDlg, driveNumber);

			if (readMBR(driveNumber, mbr))
			{
				writeMBRtoLog(mbr);
				CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)showLog, 0, 0, NULL);
			}
			else
				MessageBox(hDlg, L"Cannot open drive", L"Error", MB_OK);
			//system("notepad log.txt");

			break;
		}

		case IDC_IMAGE_PHYDRIVE:
		{
			int num;
			char path[1024], dest[1024];
			getPhysicalNumber(hDlg, num);
			getPathPhysicalDrive(num, path);
			srcdest* temp = new srcdest;
			temp->src = std::string(path);
			saveFile(hDlg, dest);
			temp->dest = std::string(dest);

			CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)makeImage, temp, 0, NULL);
			//CreateImage(path, "temp.img", NULL);
			break;
		}
		case IDC_IMAGE_VOLUME:
		{
			char vol[1024];
			char path[1024], dest[1024];
			getVolumeName(hDlg, vol);
			getPathVolume(vol, path);
			srcdest* temp = new srcdest;
			temp->src = std::string(path);
			saveFile(hDlg, dest);
			temp->dest = std::string(dest);

			CreateThread(NULL, 1024, (LPTHREAD_START_ROUTINE)makeImage, temp, 0, NULL);

			//CreateImage(path, "temp.img", NULL);
			break;
		}
		default: 
			return (INT_PTR)TRUE;
		}
		break;
	}

	return (INT_PTR)FALSE;
}