Example #1
0
int dc_unmount_all()
{
	vol_inf info;
	
	if (dc_first_volume(&info) == ST_OK)
	{
		do
		{
			if (info.status.flags & F_ENABLED) {
				dc_unmount_volume(info.device, MF_FORCE);
			}
		} while (dc_next_volume(&info) == ST_OK);
	}
	
	return ST_OK;
}
Example #2
0
int dc_first_volume(vol_inf *info)
{
	wchar_t name[MAX_PATH];
	
	info->find = FindFirstVolume(name, sizeof_w(name));

	if (info->find != INVALID_HANDLE_VALUE) 
	{
		if (dc_get_vol_info(name, info) != ST_OK) {
			return dc_next_volume(info);
		} else {
			return ST_OK;
		}
	} 

	return ST_ERROR;
}
Example #3
0
int _list_volumes(
		list_entry *volumes
	)
{
	DWORD drives = 0;

	u32 k     = 2;
	int count = 0;

	vol_inf   volinfo;
	drive_inf drvinfo;

	if ( dc_first_volume( &volinfo ) == ST_OK )
	{
		do 
		{
			_dnode *mnt = _scan_vols_tree( &volinfo, NULL );
			if (! mnt )
			{
				if ( volinfo.status.flags & F_CDROM )
				{
					_add_drive_node( NULL, &drvinfo, &volinfo, 0 );
					continue;
				}
				if ( dc_get_drive_info( volinfo.w32_device, &drvinfo ) != ST_OK ) 
				{
					continue;
				}
				for ( k = 0; k < drvinfo.dsk_num; k++ ) 
				{
					_add_drive_node( NULL, &drvinfo, &volinfo, drvinfo.disks[k].number );
				}
			} else 
			{
				do {
					_add_drive_node( mnt, NULL, &volinfo, 0 );
				} while ( (mnt = _scan_vols_tree(&volinfo, NULL)) != NULL );
			}

		} while ( dc_next_volume(&volinfo) == ST_OK );
	}
	_scan_vols_tree(NULL, &count);
	return count;

}
Example #4
0
int dc_next_volume(vol_inf *info)
{
	wchar_t name[MAX_PATH];

	FindNextVolume(
		info->find, name, sizeof_w(name));

	if (GetLastError() != ERROR_NO_MORE_FILES) 
	{
		if (dc_get_vol_info(name, info) != ST_OK) {
			return dc_next_volume(info);
		} else {
			return ST_OK;
		}
	} else {
		FindVolumeClose(info->find);		
	}

	return ST_ERROR;
}
Example #5
0
int WINAPI wWinMain(
		HINSTANCE hinst,
		HINSTANCE hprev,
		LPWSTR    cmd_line,
		int       cmd_show
		)
{
	int d_st;
	int resl;

	if (dc_is_old_runned() != 0) {
		return ST_INCOMPATIBLE;
	}

	/* open DC driver device */
	dc_open_device();
	/* get DC sriver status */
	d_st = dc_driver_status();
	resl = ST_ERROR;

	do
	{
		if (wcscmp(cmd_line, L"-setup") == 0)
		{
			if (d_st == ST_ERROR) {
				resl = dc_install_driver(NULL);
			} else
			{
				resl = dc_update_boot(-1);

				if ( (resl != ST_OK) && (resl != ST_BLDR_NOTINST) ) {
					break;
				}
				resl = dc_update_driver();
			}
			break;
		}

		if (wcscmp(cmd_line, L"-unins") == 0)
		{
			if (d_st == ST_ERROR) {
				resl = ST_ERROR; break;
			}
			resl = dc_remove_driver(); 
			break;
		}

		if (wcscmp(cmd_line, L"-unldr") == 0) {
			resl = dc_unset_mbr(-1);
			break;
		}

		if (wcscmp(cmd_line, L"-isboot") == 0) {
			ldr_config conf;
			resl = dc_get_mbr_config(-1, NULL, &conf);
			break;
		}		

		if (wcscmp(cmd_line, L"-isenc") == 0)
		{
			vol_inf info;
			u32     flags;
			wchar_t boot_dev[MAX_PATH];
			int     is_enc = 0;

			if (dc_open_device() != ST_OK) {
				resl = ST_ERROR; break;
			}

			if (dc_get_boot_device(boot_dev) != ST_OK) {
				boot_dev[0] = 0;
			}
	
			if (dc_first_volume(&info) == ST_OK)
			{
				do
				{
					flags = info.status.flags;

					if ( ((flags & F_SYSTEM) || 
						  (wcscmp(info.device, boot_dev) == 0)) && (flags & F_ENABLED) )
					{
						is_enc = 1;
					}
				} while (dc_next_volume(&info) == ST_OK);
			}

			dc_close_device();
			resl = is_enc != 0 ? ST_ENCRYPTED : ST_OK; break;
		}
	} while (0);

	return resl;
}