Page 1 of 1
Two tools to deal with Diskimages
Posted: Thu Aug 29, 2013 12:42 am
by bluecard
This is my first post in this forum.
I start to write 2 tools,one of them to create empty diskimage in any size
kb,Mb,even Gb and second tool read/write data to diskimage from source/target file.
using DevC++ as IDE ,Console project
download here
mud_img.exe
mud_rw.exe
Re: Two tools to deal with Diskimages
Posted: Thu Aug 29, 2013 12:47 am
by zhiayang
First of all, hello.
Next, some issues:
1. Nobody with common sense will download a program without source code. Especially from someone with no prior reputation.
2. Not everyone on this forum uses w1nbl0ws. All the more reason to distribute source.
3. What exactly are the advantages between your software, as opposed to say FDisk?
- One can write directly to a flat disk with some hex-editor. Does your software support a multitude of filesystems?
- Failing that, someone can just mount the disk in their host OS and edit the files inside.
4. Not exactly the best sub forum to post this in.
Re: Two tools to deal with Diskimages
Posted: Thu Aug 29, 2013 2:08 am
by bluecard
second after all
from 0 to N
try to step in programming,
my small program is alfa version ,i wll put code here:
Code: Select all
#include <stdio.h>
#include <fcntl.h>
#include <windows.h>
#define DEBUG(x) {printf("\n[DBG]%s",x);}
#define MAX_ARG 5
#define F_KILO 1
#define F_MEGA 1024
#define F_GIGA 1024*F_MEGA
char buff[1024];
void prepare_buf(char f);
void fill_img(int file,int factor,int sn,int fl);
void help_info();
void GotoXY(int x, int y);
int main(int argc, char *argv[])
{
int i;
int input_file;
int n_sectors,size;
char bytefill=0x00;
int factor;
prepare_buf(0x00);
if (argc ==1)
{ help_info();
return 0;
}
if (argc <MAX_ARG )
{ printf("\n[Err] too more arg..");
return 1;
}
if (argv[1][0]=='-' && argv[1][1]=='f' )
{ input_file=open(argv[2],O_RDWR|O_CREAT);
if (input_file == -1 || input_file==0)
{ printf ("\n [Err] Could'n Open file");
return 1;
}
} else
{
printf("\n[Err] no -f");
return -1;
}
if(argv[3][0]=='-' && argv[3][1]=='s')
{
switch(argv[3][2])
{
case 'k':
case 'K':
factor = F_KILO;
break;
case 'm':
case 'M':
factor = F_MEGA;
break;
case 'g':
case 'G':
factor = F_GIGA;
break;
default:
printf("\n[Err] no Unit of size([k]ilo,[m]ega,[g]iga");
return -1;
};
size=atoi(argv[4]);
if (size>=1)
n_sectors=size;
fill_img(input_file,factor,n_sectors,bytefill);
} else
{ printf("\n[Err] no size ");
return -1;
}
close(input_file);
printf("\n\nSucce : created image with size= %d%c",size,argv[3][2]);
return 0;
}
void fill_img(int file,int factor,int sn,int fl)
{
int count=0,i,j;
float tmp;
prepare_buf(fl);
system("cls");
printf("MUD_IMG: Created by Mutaz Hussien 2013 Aug");
printf("\n Starting,please wait..\n");
for(i=0;i<factor;i++)
{
for(count = 0; count < sn; count ++)
{ write(file,buff,1024);
}
tmp=100.0*(float)i/factor;
// if(((int)tmp%15)==0)
// printf("%c",219);
GotoXY(7,5);
for(j=0;j<(int)tmp/2;j++)
printf("%c",219);
GotoXY(1,5);
printf("[%d%%]",(int)tmp);
}
GotoXY(1,5);
printf("[100%%]");
}
void prepare_buf(char f)
{
int i;
for(i=0;i<1024;i++)
buff[i]=f;
}
void help_info()
{
printf("MUD_IMG Created By Mutaz Hussien in 2013 Aug 26\n ");
printf("usage: mud_img -f <filename> -s[unit] <size> \n " );
printf(" <filename> : full path & name of image will created\n " );
printf(" -s : size of image followed by : \n " );
printf(" [unit] : (k) for kilobyte (m) megabyte (g)gigabyte) \n " );
printf(" size : size of image for ex 1,20, 50; \n\n " );
printf("ex: mud_img -f c:\\myimage.img -sm 100 \n " );
printf("will create an image with 100Mb in c drive .");
}
void GotoXY(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
Re: Two tools to deal with Diskimages
Posted: Sat Sep 07, 2013 12:19 pm
by Kortath
Just wanted to give you my thanks for the read image source code.
Any chance for the write image source ?
If not, no worries. Just wanted to say thank you.
Re: Two tools to deal with Diskimages
Posted: Sun Sep 08, 2013 8:56 am
by sortie
Kortath: The above source code is of low quality and isn't portable, which the tool easily could have been. It's also a really simple program that an experienced C programmer could write in a couple of minutes. I'm not sure what this program does what a simple Unix dd(1) call couldn't do.
Re: Two tools to deal with Diskimages
Posted: Sun Sep 08, 2013 9:19 am
by Kortath
sortie wrote:Kortath: The above source code is of low quality and isn't portable, which the tool easily could have been. It's also a really simple program that an experienced C programmer could write in a couple of minutes. I'm not sure what this program does what a simple Unix dd(1) call couldn't do.
Wasn't the point of my reply. I would like to see how
HE writes external bin files to the img file. Yes, dd can do it. But I would like to see how he does it.