EldoS | Feel safer!

Software components for data protection, secure storage and transfer

I can't open SD card with Rawdisk

Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.
#24013
Posted: 03/11/2013 04:51:55
by rafenx bnz (Basic support level)
Joined: 03/08/2013
Posts: 3

Hi! I am trying to write on SD Card with trial version of Rawdisk and I have a runtime error in Open()/OpenEx function.

I am using C# on Visual Studio 2010. My test code is the following:

------------
Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using RawDisk;


namespace P_SD
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

            bool unmount = false;

            //IntPtr Disco = CRawDisk.Open("\\??\\PhysicalDrive5", 0x40000000, "key");
            //IntPtr Disco = CRawDisk.Open(@"\\.\PhysicalDrive5", 0x40000000, "key");
            //IntPtr Disco = CRawDisk.OpenEx("\\\\.\\H:", 0x40000000, "key", true, ref unmount);
            //IntPtr Disco = CRawDisk.OpenEx("\\\\.\\H:", GENERIC_WRITE, "key", true, ref unmount);
             IntPtr Disco = CRawDisk.OpenEx("\\??\\PhysicalDrive5", 0x40000000, "key", true, ref unmount);


            int[] buffer_write = new int[512];
            for (int i = 0; i < 512; i++)
                buffer_write[i] = 255;
            IntPtr puntero = new IntPtr(buffer_write[0]);
            CRawDisk.WriteSectors(Disco, 1000, 1, puntero);  //I want to write "buffer_write in 1000 sector"

        }
    }
}

---------

My queries:

1. I can't open SD Card, I have a runtime error (SD Card is Drive H: on Windows XP and WinHex software calls it "Removable medium 5".

2. String DeviceName in Open/OpenEx() functions would be "\\??\\PhysicalDrive5" or \\??\\RemovalDrive5" ???

3. GENERIC_WRITE variable is not recognized in my code. I am using its value 0x0x40000000, I do not know if I'm missing something in "using" directives.


I'm sorry my ignorance on this topic.

Thanks in advance!
#24014
Posted: 03/11/2013 05:49:45
by Volodymyr Zinin (EldoS Corp.)

Hello,

Quote
1. I can't open SD Card, I have a runtime error (SD Card is Drive H: on Windows XP and WinHex software calls it "Removable medium 5".

Check the error code that the Open/OpenEx() function is thrown.

Quote
2. String DeviceName in Open/OpenEx() functions would be "\\??\\PhysicalDrive5" or \\??\\RemovalDrive5" ???

Actually RawDisk operates with names in the system object manager namespace. If you want to open a volume (like "C:", "D:") then use "\\??\\C:". In the case of a disk at whole use "\\??\\PhysicalDrive2". The object manager namespace can be seen by the use of WinObj from sysinternals.com (run it elevated in the case of Win Vista and later). For example look the attached screenshot.

Quote
rafenx bnz wrote:
3. GENERIC_WRITE variable is not recognized in my code. I am using its value 0x0x40000000, I do not know if I'm missing something in "using" directives.

It's ok to use it in a such way.


#24058
Posted: 03/13/2013 06:57:21
by rafenx bnz (Basic support level)
Joined: 03/08/2013
Posts: 3

Hi again!!
Thanks a lot for your answer!

Finally, my code is working on Windows XP (32bits)...but no on Windows 7 (64 bits). Driver on Windows 7 is succesfully installed (I can see it in windows registry) but it fails when I am running the program (as Administrator).. in "Open()" fuction, exactly.

In RawDisk documentation in your website says that I have to sign the driver on 64-bits systems but I don't know how to do it. I downloaded "sdk suite" for Windows 7 (include "signtool.exe") and I am testing.

I tried:

>signtool sign /t http://timestamp.globalsign.com/scripts/timstamp.dll /ac "GlobalSign Root CA.crt" /s GlobalSignTest /n "GlobalSign" elrawdsk.sys

....with the next error:

">SignTool Error: No certificates were found that met all the given criteria."

Note:"elrawdsk.sys" and "GlobalSign Root CA.crt" are in the same folder -->"C:\windows\system32\drivers

What is wrong?

Thanks in advance!
#24065
Posted: 03/13/2013 09:39:08
by Volodymyr Zinin (EldoS Corp.)

In order to execute the unsigned driver on a 64 bit Windows reboot the machine and when the boot is starting press F8 and choose the option "Disable driver signature enforcement".

About the driver signing. You need to buy a certificate to sign the kernel mode drivers. For details see the documentation on the Microsoft website. Here is one of it:
http://msdn.microsoft.com/en-us/libra...87332.aspx
#24127
Posted: 03/15/2013 07:57:38
by rafenx bnz (Basic support level)
Joined: 03/08/2013
Posts: 3

Hi again! Thanks a lot for your fast response.

My 64-bit driver for Windows 7 is already signed by a trusted AC (you can see it in the picture below ) and when I install it, Windows 7 doesn't fail with an non-signed driver error. Perfect.

..but when I am running the program (it has to write FF on a sector ), I have a runtime error in the "Open()" fuction, it doesn't match the path and doesn't open. I don't know what is wrong!

The code is the following:

namespace P_SD
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();




}

private void Form1_Load(object sender, EventArgs e)
{

}

private unsafe void button1_Click(object sender, EventArgs e)
{


IntPtr Disco = new IntPtr();
byte* buffer_write = stackalloc byte[512];



Disco = CRawDisk.Open("\\??\\PhysicalDrive1", 0x40000000, "...key..."); // I'm sure that unit G: is PhysicalDrive1. Checked.

for (int i = 0; i < 512; i++)
buffer_write[i]= 255;

CRawDisk.WriteSectors(Disco, 2000, 1, (IntPtr)buffer_write);


}

private void button2_Click(object sender, EventArgs e)
{
bool success = false;
int error = -10;
string path;
string drvpath32, drvpath64, appname;

path = Application.StartupPath;

appname = "installer";


if (drv32.Checked)
{
drvpath32 = path + "\\Driver32\\elrawdsk.sys";
MessageBox.Show("El path para 32 es " + drvpath32);
CRawDisk.InstallDriver(drvpath32, appname, ref success);
error = Marshal.GetLastWin32Error();

}
else
{
if (drv64.Checked)
{
drvpath64 = path + "\\Driver64\\elrawdsk.sys";
MessageBox.Show("El path es 64 es" + drvpath64);
CRawDisk.InstallDriver(drvpath64, appname, ref success);
error = Marshal.GetLastWin32Error();


}
}

-----------------------------

Thanks in advance!
#24128
Posted: 03/15/2013 09:13:34
by Volodymyr Zinin (EldoS Corp.)

Check what does the function GetDriverStatus return after the installation? I.e. is it finished successfuly and what is the contents of its DriverInstalled and ServiceStatus.dwCurrentState parameters?

Quote
rafenx bnz wrote:
I have a runtime error in the "Open()" fuction

Does this function throw an exception? If so then it should be an instance of the ERDError class (it's defined in RawDisk). Please check the ErrorCode value there.

Thanks.
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

Topic viewed 6588 times

Number of guests: 2, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!