Posted by member 80008 on 2003-11-06 20:39:17
Hallo ,
Recently I've coded a small module that checks a given (step.rc) set of drive letters for availability, type and label and hands back the info in form of evars for use in mzscript. Unfortunately I am not an experienced programmer and I may have no time to polish and improve it so I would like to offer the code here. It is really small and simple and I am not sure if it is worth a separate module. However, let me know what you think about it i.e if anybody is interested in it at all. Sorry for posting code here, structrure (and code ;)) may look ugly.
The checking function called OnTimer:
The exploit in mzscript looks like this (the script is called by !bang defined in LSToolCmd (I called it LSTool):
Best regards,
R.
Recently I've coded a small module that checks a given (step.rc) set of drive letters for availability, type and label and hands back the info in form of evars for use in mzscript. Unfortunately I am not an experienced programmer and I may have no time to polish and improve it so I would like to offer the code here. It is really small and simple and I am not sure if it is worth a separate module. However, let me know what you think about it i.e if anybody is interested in it at all. Sorry for posting code here, structrure (and code ;)) may look ugly.
The checking function called OnTimer:
for(ch = 'A'; ch DrivesToCheck), ch))
{
sprintf(root_path, "%c:", ch);
UINT drive_type = GetDriveType(root_path);
sprintf(temp,"DriveType%c",ch);
switch (drive_type)
{
case (DRIVE_FIXED) : result = GetVolumeInformation(root_path, volume_name_buffer, 1024, &volume_serial_number, &maximum_component_length, &file_system_flags, file_system_name, 1024);
if (result){ strcpy(temp2,volume_name_buffer); LSSetVariable(temp,temp2);
}
else
{ LSSetVariable(temp,"HardDrive");
}
break;
case (DRIVE_REMOTE) : LSSetVariable(temp,"NetDisc");
break;
case (DRIVE_REMOVABLE) : result = GetVolumeInformation(root_path, volume_name_buffer, 1024, &volume_serial_number, &maximum_component_length, &file_system_flags, file_system_name, 1024);
if (result){
strcpy(temp2,volume_name_buffer);
LSSetVariable(temp,temp2);
}
else
{ LSSetVariable(temp,"Removeable");
}
break;
case (DRIVE_CDROM) : result = GetVolumeInformation(root_path, volume_name_buffer, 1024, &volume_serial_number, &maximum_component_length, &file_system_flags, file_system_name, 1024);
if (result){ strcpy(temp2,volume_name_buffer); LSSetVariable(temp,temp2);
}
else
{ LSSetVariable(temp,"CD/DVD");
}
break;
case (DRIVE_NO_ROOT_DIR) : LSSetVariable(temp,"NoDrive");
break;
case (DRIVE_UNKNOWN) : LSSetVariable(temp,"unknown");
break;
case (DRIVE_RAMDISK) : LSSetVariable(temp,"RamDrive");
break;
default : {
if (tool->bLogSupport)
LSLog(LOG_DEBUG, szAppName, "Error checking drives!");
}
}
memset(temp,0,255);
memset(temp2,0,255);
}
}
return TRUE;
{
sprintf(root_path, "%c:", ch);
UINT drive_type = GetDriveType(root_path);
sprintf(temp,"DriveType%c",ch);
switch (drive_type)
{
case (DRIVE_FIXED) : result = GetVolumeInformation(root_path, volume_name_buffer, 1024, &volume_serial_number, &maximum_component_length, &file_system_flags, file_system_name, 1024);
if (result){ strcpy(temp2,volume_name_buffer); LSSetVariable(temp,temp2);
}
else
{ LSSetVariable(temp,"HardDrive");
}
break;
case (DRIVE_REMOTE) : LSSetVariable(temp,"NetDisc");
break;
case (DRIVE_REMOVABLE) : result = GetVolumeInformation(root_path, volume_name_buffer, 1024, &volume_serial_number, &maximum_component_length, &file_system_flags, file_system_name, 1024);
if (result){
strcpy(temp2,volume_name_buffer);
LSSetVariable(temp,temp2);
}
else
{ LSSetVariable(temp,"Removeable");
}
break;
case (DRIVE_CDROM) : result = GetVolumeInformation(root_path, volume_name_buffer, 1024, &volume_serial_number, &maximum_component_length, &file_system_flags, file_system_name, 1024);
if (result){ strcpy(temp2,volume_name_buffer); LSSetVariable(temp,temp2);
}
else
{ LSSetVariable(temp,"CD/DVD");
}
break;
case (DRIVE_NO_ROOT_DIR) : LSSetVariable(temp,"NoDrive");
break;
case (DRIVE_UNKNOWN) : LSSetVariable(temp,"unknown");
break;
case (DRIVE_RAMDISK) : LSSetVariable(temp,"RamDrive");
break;
default : {
if (tool->bLogSupport)
LSLog(LOG_DEBUG, szAppName, "Error checking drives!");
}
}
memset(temp,0,255);
memset(temp2,0,255);
}
}
return TRUE;
The exploit in mzscript looks like this (the script is called by !bang defined in LSToolCmd (I called it LSTool):
LSToolTimer 15
LSToolCmd !Update
LSToolCheckDrives ACDEFX
*Script bang !Update
*Script exec !varset label %#DriveTypeE%#
*Script exec |LabelSetText Label7 %[label]
*Script exec !ifEq label "NoDrive" '|LabelHide
label7' else '|LabelShow label7'
*Script exec !varset label %#DriveTypeA%#
*Script exec |LabelSetText Label8 %[label]
*Script exec !ifEq label "NoDrive" '|LabelHide
label8' else '|LabelShow label8'
*Script exec !varset label %#DriveTypeF%#
*Script exec |LabelSetText Label1 %[label]
*Script exec !ifEq label "NoDrive" '|LabelHide
label1' else '|LabelShow label1'
*Script ~bang
LSToolCmd !Update
LSToolCheckDrives ACDEFX
*Script bang !Update
*Script exec !varset label %#DriveTypeE%#
*Script exec |LabelSetText Label7 %[label]
*Script exec !ifEq label "NoDrive" '|LabelHide
label7' else '|LabelShow label7'
*Script exec !varset label %#DriveTypeA%#
*Script exec |LabelSetText Label8 %[label]
*Script exec !ifEq label "NoDrive" '|LabelHide
label8' else '|LabelShow label8'
*Script exec !varset label %#DriveTypeF%#
*Script exec |LabelSetText Label1 %[label]
*Script exec !ifEq label "NoDrive" '|LabelHide
label1' else '|LabelShow label1'
*Script ~bang
Best regards,
R.