EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Problems Getting Started

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#31822
Posted: 01/06/2015 09:39:54
by Steve Dorr (Basic support level)
Joined: 11/16/2014
Posts: 4

I am having problems getting started with coding and testing my evaluation for RawDisk. I am testing this on my Windows 8.1 system which I have Visual Studio 2012 installed on. I have turned off Device Driver Signing requirement. Below is my code which I have built which is incredibly simple and yet the Failed message comes up every time.
I have done a driver query and there is no Rawdisk or ELDOS driver installed after I run this code. I have added a reference in my project using Assemblies/Extensions to RawDisk which is pointing to the .Net 4.5 - 64bit version. I have also made sure I am only producing 64 bit compiled code.

Code:

Code
Imports Rawdisk

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        AccessDrive()
    End Sub

    Private Sub AccessDrive()
        Try
            CRawDisk.InstallDriver("C:\Program Files (x86)\EldoS\RawDisk\Drivers\debug\64bit\x64\rawdsk3.sys", "iTrustU - Disk Driver v1", True)
            MessageBox.Show("success installing driver")
        Catch ex As Exception
            MessageBox.Show("Failed")
        End Try
    End Sub
End Class
#31823
Posted: 01/06/2015 10:05:38
by Eugene Mayevski (EldoS Corp.)

Thank you for contacting us.

What does ex.Message property contain? I.e. what the actual exception is?

I guess it's Access Denied, which means that your application doesn't have enough rights to install the driver. What you can do in this case is right-click on application's EXE file in Explorer and choose Run As Administrator menu command. This will start the application with elevated rights which is enough for driver installation.


Sincerely yours
Eugene Mayevski
#31824
Posted: 01/06/2015 10:51:53
by Eugene Mayevski (EldoS Corp.)

On a side note please use CODE button to mark the beginning and the end of the code block in your messages.


Sincerely yours
Eugene Mayevski
#31836
Posted: 01/07/2015 07:56:32
by Steve Dorr (Basic support level)
Joined: 11/16/2014
Posts: 4

Thanks! That was exactly the issue. In the last 24 hours I have made significant progress. I can reference the drive, check # of sectors, sector size etc. However I am having problems reading a sector in VB.Net. I declared a "buffer" of one sector using:

Code
Dim sectordata(512) As Byte


But for the call to ReadSectors, I cannot figure out how to pass the pointer to the buffer rather than the buffer itself.

Here is my code:
Code
CRawDisk.ReadSectors(devicehandle, 1, 1, sectordata)


It appears that pointers to variables are not a strong point for VB.Net. I found a function that is suppose to return a pointer to a variable, but when I add that to my code and reference SectorData using this function, the program just terminates without any errors when it hits the ReadSectors line of code.

Code
    Public Function VarPtr(ByVal e As Object) As Integer
        Dim GC As GCHandle = GCHandle.Alloc(e, GCHandleType.Pinned)
        Dim GC2 As Integer = GC.AddrOfPinnedObject.ToInt32
        GC.Free()
        Return GC2
    End Function


I really appreciate the help you have provided.

Steve
#31839
Posted: 01/07/2015 09:50:20
by Eugene Mayevski (EldoS Corp.)

IntPtr is not a "pointer to variable" but rather "special pointer to locked memory block".

You need to use something like this (C# notation):

Code
GCHandle H = GCHandle.Alloc(sectordata, GCHandleType.Pinned);
CRawDisk.ReadSectors(devicehandle, 1, 1, H.AddrOfPinnedObject());
H.Free();
... read the data from sectordata here


Please try this and let us know the result.


Sincerely yours
Eugene Mayevski
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 5018 times

Number of guests: 1, 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!