EldoS | Feel safer!

Software components for data protection, secure storage and transfer

DLLs make life easy

Also by EldoS: SecureBlackbox
200+ components and classes for digital security, signing, encryption and secure networking.
#35859
Posted: 02/10/2016 05:53:07
by Stephen Pelc (Basic support level)
Joined: 02/10/2016
Posts: 7

In order to interface RawDisk to an unsupported language, surely it would make life easier if there were interface DLLs rather than static libraries. Since the vast majority of these languages can access functions in DLLs, all the questions about Lazarus, Free Pascal, Forth, Python and so on would all disappear.

All you need to do is define Exports of the methods such as
RawDisk_Open( ... )
with no name decoration or mangling. A C header file then completes it.

For my application, I would have had my code under test in under 20 minutes. Now I have to find a suitable C compiler that I only use once per year, read the documentation, remember how to make DLLs and link in static libraries and ... and ...

Stephen
#35865
Posted: 02/10/2016 11:19:32
by Eugene Mayevski (EldoS Corp.)

Thank you for your comment. It's possible that we'll implement such API in near future (but "near" is a month or two for us).


Sincerely yours
Eugene Mayevski
#35871
Posted: 02/11/2016 06:19:35
by Stephen Pelc (Basic support level)
Joined: 02/10/2016
Posts: 7

Thanks. We'll be happy to alpha test for you.

Regards, Stephen
#35917
Posted: 02/17/2016 07:39:42
by Stephen Pelc (Basic support level)
Joined: 02/10/2016
Posts: 7

Well, we finally have a DLL. Although we would have preferred to use gcc, at least with MinGW, the supplied library does not match the current gcc version. A VC2010 build does appear to work, but error reporting by exception is a real pain, especially since the error codes are undocumented. So we'll try putting a try block into the DLL interface. However, this means changing function returns which is not altogether desirable.

The current help file is not a help - it doesn't work properly under Windows 7 and above, and it conflicts with the rawdisk.h header file. A PDF is universal and searchable. For an example, compare the help file's version of InstallDriver and the header file's version. Which is the driver - elrawdsk.sys (help file) or rawdsk3.sys (exploration).

And I really, really need to get this done in the next ten working days "in my ample spare time".
#35918
Posted: 02/17/2016 08:19:57
by Eugene Mayevski (EldoS Corp.)

Thank you for your feedback. Please see my comments below.

Quote
spelc wrote:
Although we would have preferred to use gcc, at least with MinGW, the supplied library does not match the current gcc version


The licensed version includes API source code, which lets you build libraries for your particular compiler.

Quote
spelc wrote:
A VC2010 build does appear to work, but error reporting by exception is a real pain, especially since the error codes are undocumented.


The error codes are returned by Windows, these are not RawDisk error codes.

Quote
spelc wrote:
So we'll try putting a try block into the DLL interface. However, this means changing function returns which is not altogether desirable.


Overall, you are trying to use RawDisk in the environment for which it was not *designed*, hence your problems.

Quote
spelc wrote:
The current help file is not a help - it doesn't work properly under Windows 7 and above,


We provide plain HTML version of the help file, for these cases. Also, could you please tell me, what version of the help file did you try so that it didn't work? We would need to re-check it. CHM file works on Windows 7 and Windows 8.1 (I have just checked this).

Quote
spelc wrote:
For an example, compare the help file's version of InstallDriver and the header file's version. Which is the driver - elrawdsk.sys (help file) or rawdsk3.sys (exploration).


Some changes really don't get to the documentation because this information is scattered across the help file, and can be easily overlooked when updating. We rely on users' common sense with this - if you have rawdsk3.sys file, it's obvious, that this is the driver file. Still I am thankful to you for referencing the issue, we will update the help file in this regard.


Sincerely yours
Eugene Mayevski
#35923
Posted: 02/17/2016 09:22:45
by Stephen Pelc (Basic support level)
Joined: 02/10/2016
Posts: 7

Thanks for the feedback. The licensed version will be taken when we can prove that RawDisk works to a sceptical client! I have to prove that we can read/write sectors 0 and 1 of an SD card on a Windows 7 laptop set up by a paranoid IT department.

When you say we're out of the design environment, please tell me why. Should I give up with RawDisk as a DLL until Eldos produce one?

The status check call appears to work fine. So let's see what happens when we use InstallDriver. The code below is the DLL interface called from our Forth compiler.
Code
CRawDisk CRD;

extern "C" int __declspec(dllexport) RawDisk_InstallDriver(
  LPCWSTR DriverName, LPCSTR ProductName, LPBOOL RebootNeeded
){
   int ior=0;
   try{
      CRD.InstallDriver( DriverName, ProductName, RebootNeeded );
   }
   catch(int e){
    if( e==0) e=-1;
    ior=e;
   }
   catch(...){ ior=-2; }
   return ior;
}

We always get a code 2 return with a wide fully qualified driver name, an ANSI product name, and the address of a variable. If I take the try/catch out, I get a Windows exception (that is caught by VFX Forth).

What are the requirements for the two names?

I am not trying to be difficult, I'm just trying to get this working. If it makes life easier, you can Skype me as mpe_sfp or telephone on +44 (0)23 8063 1441.

Regards, Stephen
#35924
Posted: 02/17/2016 09:33:11
by Eugene Mayevski (EldoS Corp.)

Quote
spelc wrote:
When you say we're out of the design environment, please tell me why.


I was trying to say that we target and support the particular set of development tools and environments, and yours is not covered. So it's not our fault that we use exceptions (for example), even if this doesn't work well for you.

Quote
spelc wrote:
Should I give up with RawDisk as a DLL until Eldos produce one?


We normally don't do anything with limited benefits to our existing customer base. Making a DLL for your use is probably something we can do as a custom job (for a fee), but given that you are yet to prove something to the client, I understand that we are in a catch 22 situation.

Quote
spelc wrote:
We always get a code 2 return with a wide fully qualified driver name, an ANSI product name, and the address of a variable. If I take the try/catch out, I get a Windows exception (that is caught by VFX Forth).


It's hard to guess anything without seeing what you pass to the method and what your environment is. E.g. the 32-bit installer on 64-bit system would work with virtualized Program Files directory. Other similar surprises can come in effect.

BTW InstallDriver is a static method. Maybe the proper syntax would be CRawDisk::InstallDriver(... ).


Sincerely yours
Eugene Mayevski
#35925
Posted: 02/17/2016 10:07:26
by Stephen Pelc (Basic support level)
Joined: 02/10/2016
Posts: 7

Quote
It's hard to guess anything without seeing what you pass to the method and what your environment is. E.g. the 32-bit installer on 64-bit system would work with virtualized Program Files directory. Other similar surprises can come in effect.


The DLL is a 32 bit application built with VC++ 2010. The DLL is called from VFX Forth, a 32 bit interactive native code compiler. Think of it as a plain C application. The application is being tested on Windows 7 64 bit Professional.

Changing the InstallDriver call to
Code
CRawDisk::InstallDriver( DriverName, ProductName, RebootNeeded );

made no difference.

Regards, Stephen
#35927
Posted: 02/17/2016 10:44:17
by Eugene Mayevski (EldoS Corp.)

Can you please show me the exact values of DriverName and ProductName that you are passing and, especially, how they are received by the DLL. It looks like the path is incorrect. Windows error 2 means "file not found" which for InstallDriver can mean only that the path specified for the driver file was not correct.


Sincerely yours
Eugene Mayevski
#35928
Posted: 02/17/2016 11:25:01
by Stephen Pelc (Basic support level)
Joined: 02/10/2016
Posts: 7

This is the DLL function called by the Forth word InstallDriver below.
Code
extern "C" int __declspec(dllexport) RawDisk_InstallDriver(
  LPCWSTR DriverName, LPCSTR ProductName, LPBOOL RebootNeeded
){
   int ior=0;
   try{
      CRawDisk::InstallDriver( DriverName, ProductName, RebootNeeded );
   }
   catch(int e){
    if( e==0) e=-1;
    ior=e;
   }
   catch(...){ ior=-2; }
   return ior;
}



This is a run of the Forth word InstallDriver, which just passes data to the DLL.
Code
installdriver
DriverName
0046:2420  44 00 3A 00 5C 00 4D 00  79 00 41 00 70 00 70 00  D.:.\.M.y.A.p.p.
0046:2430  73 00 5C 00 45 00 6C 00  64 00 6F 00 73 00 5C 00  s.\.E.l.d.o.s.\.
0046:2440  52 00 61 00 77 00 44 00  69 00 73 00 6B 00 41 00  R.a.w.D.i.s.k.A.
0046:2450  70 00 70 00 5C 00 72 00  61 00 77 00 64 00 73 00  p.p.\.r.a.w.d.s.
0046:2460  6B 00 33 00 2E 00 73 00  79 00 73 00 00 00 00 00  k.3...s.y.s.....

Product Name
004C:BB00  56 66 78 46 6F 72 74 68  2E 65 78 65 00 00 00 00  VfxForth.exe....

RebootNeeded address 0046:2534 ok-2
.s
DATA STACK
     top
             -2 FFFF:FFFE
              0 0000:0000
ok-2


The -2 on top of the data stack is the -2 returned by the catch(...). The 0 is the initial value of RebootNeeded in the Forth when ior is non-zero.
How should I extract the Windows error code in a catch() clause?

Regards, Stephen
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 5886 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!