2012-11-26 19:26:15 +04:00
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
2015-02-27 04:44:22 +03:00
|
|
|
|
///////////////////////// Console ////////////////////
|
2012-11-26 19:26:15 +04:00
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2013-08-10 21:47:40 +04:00
|
|
|
|
#ifdef LANG_RUS
|
2013-10-05 02:02:44 +04:00
|
|
|
|
?define ADD_DISK_TEXT "<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㠫<EFBFBD><E3A0AB><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>"
|
|
|
|
|
?define DELETE_DISK_TEXT "<EFBFBD><EFBFBD><EFBFBD> 㤠<><E3A4A0><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㠫<EFBFBD><E3A0AB><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>"
|
2016-02-22 00:57:22 +03:00
|
|
|
|
?define DONT_KNOW_DISK_SIZE_TEXT "<EFBFBD><EFBFBD><EFBFBD> ࠧ<><E0A0A7><EFBFBD> <20><> 㪠<><E3AAA0><EFBFBD>, 20% <><E1A2AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20>㤥<EFBFBD> <20>ᯮ<EFBFBD>짮<EFBFBD><ECA7AE><EFBFBD><EFBFBD>"
|
2013-10-05 02:02:44 +04:00
|
|
|
|
?define NEW_DISK_TEXT "ࠧ<EFBFBD><EFBFBD><EFBFBD> <20><>᪠ <20>㤥<EFBFBD>: "
|
2012-11-26 19:26:15 +04:00
|
|
|
|
char *rezult_text[]={
|
2013-08-10 21:47:40 +04:00
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ᯥ譮 <20><><EFBFBD><EFBFBD><EFBFBD>襭<EFBFBD>",
|
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IOCTL, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ࠧ<><E0A0A7><EFBFBD> <20>।<EFBFBD><E0A5A4>⠢<EFBFBD>塞<EFBFBD><EFA5AC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...",
|
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>᪠ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> 0 <20><> 9",
|
|
|
|
|
"ࠧ<EFBFBD><EFBFBD><EFBFBD> ᮧ<><E1AEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>᪠ 誮<E1ABA8> <20><><EFBFBD><EFBFBD><EFBFBD>",
|
|
|
|
|
"ࠧ<EFBFBD><EFBFBD><EFBFBD> ᮧ<><E1AEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>᪠ 誮<E1ABA8> <20><><EFBFBD>",
|
|
|
|
|
"<EFBFBD>訡<EFBFBD><EFBFBD> <20>뤥<EFBFBD><EBA4A5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⭠<EFBFBD> <20>訡<EFBFBD><E8A8A1> O_o",
|
2012-11-26 19:26:15 +04:00
|
|
|
|
0};
|
2013-08-10 21:47:40 +04:00
|
|
|
|
#else
|
2013-10-05 02:02:44 +04:00
|
|
|
|
?define ADD_DISK_TEXT "trying to add disk"
|
|
|
|
|
?define DELETE_DISK_TEXT "trying to delete virtual disk"
|
2016-02-22 00:57:22 +03:00
|
|
|
|
?define DONT_KNOW_DISK_SIZE_TEXT "its size is not specified, 20% from free RAM will be used"
|
2013-10-05 02:02:44 +04:00
|
|
|
|
?define NEW_DISK_TEXT "new DiskSize: "
|
2012-11-26 19:26:15 +04:00
|
|
|
|
char *rezult_text[]={
|
2013-03-05 22:50:47 +04:00
|
|
|
|
"operation completed successfully",
|
2012-11-26 19:26:15 +04:00
|
|
|
|
"unknown IOCTL code, wrong input/output size...",
|
|
|
|
|
"DiskId must be from 0 to 9",
|
|
|
|
|
"DiskSize is too large",
|
2013-03-05 22:50:47 +04:00
|
|
|
|
"DiskSize is too small, might be too little free RAM",
|
2012-11-26 19:26:15 +04:00
|
|
|
|
"memory allocation failed",
|
|
|
|
|
"unknown error O_o",
|
|
|
|
|
0};
|
2013-08-10 21:47:40 +04:00
|
|
|
|
#endif
|
2012-11-26 19:26:15 +04:00
|
|
|
|
|
2013-03-01 17:00:21 +04:00
|
|
|
|
char Console_Work()
|
2012-11-26 19:26:15 +04:00
|
|
|
|
{
|
|
|
|
|
unsigned int disk_size, driver_rezult;
|
|
|
|
|
char size_t[256];
|
|
|
|
|
|
|
|
|
|
strlwr(#param);
|
|
|
|
|
|
|
|
|
|
switch (param[0])
|
|
|
|
|
{
|
2015-07-29 20:44:24 +03:00
|
|
|
|
case '?':
|
2012-11-26 19:26:15 +04:00
|
|
|
|
case 'h':
|
2014-03-14 23:06:48 +04:00
|
|
|
|
debugln("tmpdisk command line parameters:");
|
|
|
|
|
debugln("a[number]s[size in MB] - add RAM disk");
|
|
|
|
|
debugln("d[number] - delete RAM disk");
|
2012-11-26 19:26:15 +04:00
|
|
|
|
ExitProcess();
|
|
|
|
|
break;
|
2015-07-29 20:44:24 +03:00
|
|
|
|
case 'd':
|
2014-03-14 23:06:48 +04:00
|
|
|
|
debugln(DELETE_DISK_TEXT);
|
2012-11-26 19:26:15 +04:00
|
|
|
|
del_disk.DiskId = param[1]-'0';
|
|
|
|
|
ioctl.handle = driver_handle;
|
|
|
|
|
ioctl.io_code = DEV_DEL_DISK;
|
|
|
|
|
ioctl.input = #del_disk;
|
|
|
|
|
ioctl.inp_size = sizeof(del_disk);
|
|
|
|
|
ioctl.output = 0;
|
|
|
|
|
ioctl.out_size = 0;
|
2015-02-27 04:44:22 +03:00
|
|
|
|
disk_sizes[del_disk.DiskId] = 0;
|
2012-11-26 19:26:15 +04:00
|
|
|
|
break;
|
2015-07-29 20:44:24 +03:00
|
|
|
|
case 'a':
|
2014-03-14 23:06:48 +04:00
|
|
|
|
debugln(ADD_DISK_TEXT);
|
2012-11-26 19:26:15 +04:00
|
|
|
|
disk_size= strchr(#param, 's');
|
|
|
|
|
if (!disk_size)
|
|
|
|
|
{
|
2016-02-22 00:57:22 +03:00
|
|
|
|
add_disk.DiskSize = GetFreeRAM() / 5 * 2;
|
2014-03-14 23:06:48 +04:00
|
|
|
|
debugln(DONT_KNOW_DISK_SIZE_TEXT);
|
2012-11-26 19:26:15 +04:00
|
|
|
|
}
|
|
|
|
|
else
|
2015-07-29 20:44:24 +03:00
|
|
|
|
{
|
|
|
|
|
add_disk.DiskSize = atoi(disk_size+1)*2048;
|
|
|
|
|
}
|
2013-10-05 02:02:44 +04:00
|
|
|
|
strcpy(#size_t, NEW_DISK_TEXT);
|
2014-03-13 04:37:35 +04:00
|
|
|
|
strcat(#size_t, itoa(add_disk.DiskSize/2048));
|
2013-10-05 02:02:44 +04:00
|
|
|
|
strcat(#size_t, " MB");
|
2014-03-14 23:06:48 +04:00
|
|
|
|
debugln(#size_t);
|
2012-11-26 19:26:15 +04:00
|
|
|
|
add_disk.DiskId = param[1]-'0';
|
|
|
|
|
ioctl.handle = driver_handle;
|
|
|
|
|
ioctl.io_code = DEV_ADD_DISK;
|
|
|
|
|
ioctl.input = #add_disk;
|
|
|
|
|
ioctl.inp_size = sizeof(add_disk);
|
|
|
|
|
ioctl.output = 0;
|
|
|
|
|
ioctl.out_size = 0;
|
2015-02-27 04:44:22 +03:00
|
|
|
|
disk_sizes[add_disk.DiskId] = add_disk.DiskSize * 512;
|
2012-11-26 19:26:15 +04:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2014-03-14 23:06:48 +04:00
|
|
|
|
debugln("unknown command line parameters");
|
|
|
|
|
debugln("use 'h' or '?' for help");
|
2012-11-26 19:26:15 +04:00
|
|
|
|
ExitProcess();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
driver_rezult = RuleDriver(#ioctl);
|
2014-03-14 23:06:48 +04:00
|
|
|
|
if (driver_rezult<7) debugln(rezult_text[driver_rezult]);
|
2013-03-01 17:00:21 +04:00
|
|
|
|
return driver_rezult;
|
2012-11-26 19:26:15 +04:00
|
|
|
|
}
|
|
|
|
|
|