Jump to content











Photo
- - - - -

Cannot start service ImDisk on computer '.'.


  • Please log in to reply
18 replies to this topic

#1 CrimsonGT

CrimsonGT

    Newbie

  • Members
  • 12 posts
  •  
    United States

Posted 13 August 2011 - 09:45 AM

I finished writing the basis for my RAMDisk in C# using ImDisk, and decided it was time to try it out. Unfortunately, I am getting the following error, and I am completely stumped. I did however just notice that there is no "ImDisk" service, only a "ImDisk Virtual Disk Drive Helper" service. Why would the "ImDisk" service not be created by the installer?


An unhandled exception of type 'System.InvalidOperationException' occured in System.ServiceProcess.dll

 

Additional Information: Cannot start service ImDisk on computer '.'.


My first assumption after getting this error was that it was not running with correct permissions. I disabled UAC, change the SC configuration as instructed on download website, ran the process as an Administrator, etc. Nothing has resolved this issue at all. Here is the exact code (stripped down to just relevant ImDisk code) as it crashes on the very first line of my RAMDisk Constructor.


    	public RAMDisk()

    	{

            	// Initalize the ImDisk Driver

            	ImDiskAPI.LoadDriver();

 

            	IVssImplementation vssImpl = VssUtils.LoadImplementation();

            	vssBkupCmp = vssImpl.CreateVssBackupComponents();

    	}

 

    	public bool CreateRAMDisk()

    	{

        	// Create Empty RAM Disk

        	char driveLetter = ImDiskAPI.FindFreeDriveLetter();

 

        	ImDiskAPI.CreateDevice(50000, 0, 0, 0, 0, ImDiskFlags.DeviceTypeHD | ImDiskFlags.TypeVM, null, false, driveLetter.ToString(), ref deviceID, IntPtr.Zero);

 

        	// Format the Drive for NTFS

        	if (FormatDrive(driveLetter.ToString(), "NTFS", true, 4096, "", false))

        	{

            	string workingDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

 

            	if (CreateSymLink(driveLetter + @":\World", workingDir + @"\World"))

            	{

                	CopyDirectory(workingDir + @"\World", workingDir + @"\World_Save");

                	CopyDirectory(workingDir + @"\World", driveLetter + @":\World");

 

                	return true;

            	}

 

        	return false;

    	}


Edited by CrimsonGT, 13 August 2011 - 09:52 AM.


#2 CrimsonGT

CrimsonGT

    Newbie

  • Members
  • 12 posts
  •  
    United States

Posted 13 August 2011 - 12:10 PM

It appears the service is running, so im at a loss why I am getting this error now.

#3 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 13 August 2011 - 05:15 PM

It appears the service is running, so im at a loss why I am getting this error now.

If it's already running, perhaps you do not need to start it. If you try to start it while it's already running, perhaps that'll yield an error. You can use sc query imdisk and sc qc imdisk to inspect the service. Note the "short" and "long" names for the same service, below.

SERVICE_NAME: imdisk

        TYPE               : 1  KERNEL_DRIVER

        STATE              : 4  RUNNING

                                (STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)

        WIN32_EXIT_CODE    : 0  (0x0)

        SERVICE_EXIT_CODE  : 0  (0x0)

        CHECKPOINT         : 0x0

        WAIT_HINT          : 0x0



[SC] GetServiceConfig SUCCESS



SERVICE_NAME: imdisk

        TYPE               : 1   KERNEL_DRIVER

        START_TYPE         : 3   DEMAND_START

        ERROR_CONTROL      : 0   IGNORE

        BINARY_PATH_NAME   : system32\DRIVERS\imdisk.sys

        LOAD_ORDER_GROUP   :

        TAG                : 0

        DISPLAY_NAME       : ImDisk Virtual Disk Driver

        DEPENDENCIES       :

        SERVICE_START_NAME :



#4 CrimsonGT

CrimsonGT

    Newbie

  • Members
  • 12 posts
  •  
    United States

Posted 13 August 2011 - 08:51 PM

Thank you for the assistance. That was actually what I was thinking, so I attempted to just comment out the ImDiskAPI.LoadDriver() line since it is already running. Unfortunately, on the next line, ImDiskAPI.FindFreeDriveLetter(), I get the error...


An unhandled exception of 'System.EntryPointNotFoundException' occured in ImDiskNet.dll

 

Additional Information: Unable to find an entry point named '_ImDiskFindFreeDriveLetter@0' in DLL 'imdisk.cpl'.


After searching that error, apparently it is caused from not initiating an object, but ImDiskAPI has no constructor, so I am not able to do...


ImDiskAPI imDisk = new ImDiskAPI();


Silly little things like this are when examples really come into play, as I am having a hard time trying to figure out exactly how I should be doing this now.

Edited by CrimsonGT, 13 August 2011 - 09:16 PM.


#5 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 14 August 2011 - 08:24 PM

The EntryPointNotFoundException error does not have anything to do with constructors, where did you find such information? That exception is caused when functions you are calling cannot be found in the underlying unmanaged DLL, which in this case is imdisk.cpl. Methods in ImDiskNet.dll call imdisk.cpl to get things done, pretty much.

In this case I think you might have found a problem that has not been found before. It might be caused by a incompatibility with 64 bit projects that I have failed to notice before. To verify that and if you are indeed running in a 64 bit environment, could you please try to set your project to x86 only and that way run it as a 32 bit application?

#6 CrimsonGT

CrimsonGT

    Newbie

  • Members
  • 12 posts
  •  
    United States

Posted 14 August 2011 - 08:41 PM

Well, that was indeed the issue. As soon as I switched it over to X86 it worked perfectly. I am not the greatest programmer so I generally assume the issue is with me and not the API I am working with, but I am glad to get it fixed. Thank you very much Olof!

#7 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 14 August 2011 - 08:44 PM

Thanks a lot, and especially thank you for finding this problem. I have sort of missed it so far. I will fix it for next release!

Happy coding!

:cheers:

#8 CrimsonGT

CrimsonGT

    Newbie

  • Members
  • 12 posts
  •  
    United States

Posted 14 August 2011 - 10:30 PM

No problem, definitely would have preferred not to bang my head on it for a couple of days, but always happy to help improve great libraries. :) Just to mention, I found a website with some Read/Write speed tests for various RAMDisk libraries, which ImDisk was listed at. The speeds listed were considerably low (compared to others), but I just ran some tests using CrystalDisk, and yours has drastically improved on speeds since that website ran the tests.

Also, I am pretty sure everything with my applications about ready to go, but how should the Mount Point be specified? I have been trying something along the lines of the following, but not having much luck.


    	public bool CreateRAMDisk()

    	{

        	// Create Empty RAM Disk

        	char driveLetter = ImDiskAPI.FindFreeDriveLetter();



        	ImDiskAPI.CreateDevice(52428800, 0, 0, 0, 0, ImDiskFlags.DeviceTypeHD | ImDiskFlags.TypeVM, null, false, driveLetter.ToString(), ref deviceID, IntPtr.Zero);



        	string mountPoint = driveLetter + @":\Device\ImDisk0";

        	ImDiskAPI.CreateMountPoint(mountPoint, deviceID);



        	// Format the Drive for NTFS

        	if (FormatDrive(driveLetter.ToString(), "NTFS", true, 4096, "", false))

        	{



#9 CrimsonGT

CrimsonGT

    Newbie

  • Members
  • 12 posts
  •  
    United States

Posted 15 August 2011 - 01:11 AM

Well I have tried both with and without CreateMountPoint (just providing something like C:\Device\ImDisk0) and while it doesn't error, and I get a proper DeviceID / Drive Letter, the drive never shows up in My Computer under Hard-Drives. I am running it as Administrator, which rules that out as an issue. Is there anything else that needs to be done to get it to show up as an actual Drive?

#10 CrimsonGT

CrimsonGT

    Newbie

  • Members
  • 12 posts
  •  
    United States

Posted 15 August 2011 - 05:07 AM

Got it all worked out. Went over every parameter and found some small bugs causing the issues. Thanks for the great library and the assistance!

Does anyone know if it is possible to suppress the message prompting the user to format the new drive? I need to automatically format the empty drive after I create it from my application, so suppressing that message is fairly necessary.

#11 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 15 August 2011 - 06:40 AM

Does anyone know if it is possible to suppress the message prompting the user to format the new drive?


Not as far as I know.


I need to automatically format the empty drive after I create it from my application, so suppressing that message is fairly necessary.


You can prepare an image file containing an empty NTFS filesystem and mount that image while also specifying ramdisk as device type. That way it will load your prepared, already formatted image file, into your new ramdisk. You can then call functions to extend this ramdisk to the size you wish.

There are also library tools for building filesystems in for example DiscUtils library. http://discutils.codeplex.com

#12 CrimsonGT

CrimsonGT

    Newbie

  • Members
  • 12 posts
  •  
    United States

Posted 23 August 2011 - 10:12 AM

Thanks a lot, and especially thank you for finding this problem. I have sort of missed it so far. I will fix it for next release!

Happy coding!

:cheers:


Is there currently an ETA on this release? I have been building in 32 bit to work around this, but apparently Volume Shadow Copy in Window's won't work with 32 bit applications, so that is causing my application not to function properly.

Basically until this is fixed, I have to build in 32bit for ImDisk to work, and 64bit for VSS to work, and both are badly needed.

Thank you!

Edited by CrimsonGT, 23 August 2011 - 10:15 AM.


#13 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 23 August 2011 - 10:25 AM


Is there currently an ETA on this release? I have been building in 32 bit to work around this, but apparently Volume Shadow Copy in Window's won't work with 32 bit applications, so that is causing my application not to function properly.

Basically until this is fixed, I have to build in 32bit for ImDisk to work, and 64bit for VSS to work, and both are badly needed.

Thank you!


I was was kind of hoping that I would get that fixed this or next week or so, but there have turned up a few "emergencies to do" in various projects so I think I need to put this on-hold for a few more weeks. Say, late September/early October or so. I think that would be reasonable.

#14 CrimsonGT

CrimsonGT

    Newbie

  • Members
  • 12 posts
  •  
    United States

Posted 23 August 2011 - 10:58 AM

Alright, thank you. Do you know of any alternatives to VSS I could use in the meantime for backing up the RAMDisk with files in use? You mentioned your "rawcopy" tool before, but I need something I can actually do from inside of my application.

#15 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 23 August 2011 - 11:14 AM

"rawcopy" does nothing special really, basically just open/read/write. If you use ImDisk API you could open the device and get a Stream object that you can read from, that is essentially the same thing as "rawcopy". Problem with this method is that to be safe you need to make sure that all files are closed and dismount the filesystem before saving this way. Otherwise filesystem structure on volume could be saved in an inconsistent state.

As far as I know there is no way to use VSS on ImDisk and similar kind of disk devices.

#16 cccec

cccec
  • Members
  • 2 posts
  •  
    Estonia

Posted 03 February 2012 - 01:31 PM

Seems I also have a similar issue like CrimsonGT described on 15/08/2011

My ultimate goal is to be able to create a ramdisk with an opensource C# API library, and it seems only ImDisk is the only one that applies.

After having tried to make it work in my machine by following any online information available, I must admit I'm stuck.
All the code compiles and completes when run, also the FindFreeDriveLetter() works and deviceID gets assinged by CreateDevice (value is 7)

However, the drive never appears. I have tried to create a mount point to an existing path on C:\ drive, to a new supposed drive, change the parameters of CreateDevice etc, but in vain.
Is there anything wrong with what I do? Are there any resources that describe in detail how to use this API, are there maybe some working examples?
CrimsonGT, what was the solution that fixed the issue in your case?


Big thanks in advance!

I am running Windows 7 (32-bit).
Here is my code:

		    ImDiskAPI.LoadDriver(); // Initalize the ImDisk Driver

		    uint deviceID = 0;

		    char driveLetter = ImDiskAPI.FindFreeDriveLetter();

		    ImDiskAPI.CreateDevice(52428800, 0, 0, 0, 0,

								    ImDiskFlags.DeviceTypeHD|ImDiskFlags.TypeVM,

								    null, //@"W:/test.iso",

								    false, driveLetter.ToString(), ref deviceID, IntPtr.Zero);

		    //ImDiskAPI.CreateMountPoint(driveLetter + @":\Device\ImDisk0", deviceID); // <== Exception: The system cannot find the path specified

		    //ImDiskAPI.CreateMountPoint(driveLetter, deviceID); // <== Exception: The system cannot find the path specified

		    ImDiskAPI.CreateMountPoint(@"C:\RAMDisk", deviceID);

		    FormatDrive(driveLetter.ToString(), "NTFS", true, 4096, "", false);



#17 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 03 February 2012 - 02:35 PM

@cccec
I would suggest that you read the documentation carefully to find out requirements for each parameter. I know that some of them are not very well documented, but you can avoid at least some catches if you read what is actually written about them.

(The documentation should be available along with IntelliSense once you put the ImDiskNet.xml file in same directory as ImDiskNet.dll, just like XML docs for any .NET assembly works.)

Quoted doc about DriveLetter parameter for ImDiskAPI.CreateDevice():

Mount point in the form of a drive letter and colon to create for newly created virtual disk. If this parameter is Nothing/null the virtual disk will be created without a drive letter.


In your particular case you don't send in a drive letter followed by a colon. You just send a letter, which will not work.

Once you have got this working, you would not need CreateMountPoint() because the drive letter is created in the CreateDevice() call.

Also, in this version you cannot use CreateMountPoint() for creating drive letter mount points because that particular function can only create subdirectory mount points. Drive letter mountpoints can only be created in the call to CreateDevice(). But in next version of the API, soon to be released, CreateMountPoint() will be able to create drive letter mount points as well.

Another thing I notice is that you pass in zero as device number. This will only work if device number zero is free, it will not allocate another device number otherwise but will instead fail.

From docs about DeviceNumber parameter:

In: Device number for device to create. Device number must not be in use by an existing virtual disk. For automatic allocation of device number, pass UInt32.MaxValue.

Out: Device number for created device.



#18 cccec

cccec
  • Members
  • 2 posts
  •  
    Estonia

Posted 06 February 2012 - 09:50 AM

Thanks loads for all your super-quick explanations, it was really helpful!
I initialize

uint deviceID = UInt32.MaxValue;

pass it to the CreateDevice (also, including the drive letter with a colon) and it works perfectly now!
What an amazing library!

#19 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 06 February 2012 - 12:53 PM

Thanks! Good that you find it useful!
:cheers:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users