Accessing a Delphi DLL function.

Accessing a Delphi DLL function.

Postby Jeff Barnes » Mon Oct 22, 2007 1:37 pm

Hi Everybody,

I have a Test DLL from a company that has a cost effective way of converting a standard USB Jump drive into a software protection device.
The software is called AntiDuplicate. It modifies a standard USB Jump drive so that it knows the difference between the original and a copy thus allowing you to use it as a hardware key (sells for $129.00 U.S.)

I need to know if it is possible to read data form this file.

The test dll can be downloaded from my site:

[url]
www.can-soft.net/dl/TestDLL.zip
[/url]

They also gave me this info:

If Fivewin can call functions with the array as argument and use the result from the same array, we can use AntiDuplicate DLL.

This package contains the DLL and an example of the test function call (on Delphi Pascal). If you prefer example on other program language, please let me know.
If you'll call function correctly, after the function call you'll get A[99] = 8300.



Does anyone know if Fivewin can work with this?
Can someone provide a sample of how to read it?

Thanks,
Jeff
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Antonio Linares » Mon Oct 22, 2007 1:39 pm

Jeff,

Please review samples\dlls\delphi32\*.prg to access a Delphi DLL from FW
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41356
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Jeff Barnes » Mon Oct 22, 2007 2:13 pm

Antonio,

I have looked at the sample but how do you return an array from a Delphi DLL?

The samples seem to work fine for text but I get NIL returned with the array.


Thanks,
Jeff
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Antonio Linares » Mon Oct 22, 2007 2:23 pm

Jeff,

> If you prefer example on other program language, please let me know

Could you please ask them for a C language sample ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41356
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Oct 22, 2007 2:33 pm

Jeff,

Please try this:
Code: Select all  Expand view
#include "FiveWin.ch"
#include "Struct.ch"

function Main()

   local oStruct, cBuffer

   STRUCT oStruct
      MEMBER n1 AS LONG
      MEMBER n2 AS LONG
      ... // please repeat it up to 128
      MEMBER n128 AS LONG
   ENDSTRUCT

    cBuffer = oStruct:cBuffer
   TestFunc1( cBuffer )
   oStruct:cBuffer = cBuffer

   MsgInfo( oStruct:n1 )

return nil

DLL FUNCTION TESTFUNC1( pValues as LPSTR ) AS BOOL PASCAL LIB "
TestLib12.dll'
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41356
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Jeff Barnes » Tue Oct 23, 2007 1:38 am

Antonio,

The code you gave me will only return a 0 (zero).

I asked for a C Language sample and this is what they sent me:

Code: Select all  Expand view

=======================

typedef VOID (CALLBACK* LPFNDLLACC1)(LONG[127]);

.....

HINSTANCE hDLL;              // Handle to DLL
LPFNDLLACC1 lpfnDllFunc1;    // Function pointer
LONG a[128];
INT i;

.....

hDLL = LoadLibrary("TestLib12.dll");
if (hDLL != NULL)
{
        for (i = 0; i < 128; i++)
                a[i] = i;
        lpfnDllFunc1 = (LPFNDLLACC1)GetProcAddress(hDLL, "TestFunc1");
        if (!lpfnDllFunc1)
        {
                printf("Function not found!\n");
        }
        else
        {
                // call the function
                lpfnDllFunc1(a);
                printf("Result = %u\n", a[99]);
        }
        FreeLibrary(hDLL);
}

=======================





Thanks,
Jeff
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Antonio Linares » Tue Oct 23, 2007 7:26 am

Jeff,

Please change this line:

DLL FUNCTION TESTFUNC1( pValues AS LPSTR ) AS BOOL PASCAL FROM "TestFunc1" LIB "TestLib12.dll"
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41356
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Jeff Barnes » Tue Oct 23, 2007 5:12 pm

Same thing ... Always shows 0 (zero)
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Antonio Linares » Tue Oct 23, 2007 7:07 pm

Jeff,

Could you please ask the developers to place a MessageBox( 0, "here", "inside the DLL", 0 ); inside that DLL function just to check if we properly access it ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41356
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Jeff Barnes » Thu Oct 25, 2007 2:46 pm

Hi Antonio,

Ok ... here is the latest DLL from the company:


http://www.antiduplicate.com/t/TestDLL.zip



Thanks,
Jeff
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Antonio Linares » Thu Oct 25, 2007 3:14 pm

Jeff,

The function is getting called as the MessageBox() is shown.

Could you provide me the PRG declaring the 128 members of the struct ? Thanks,
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41356
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Jeff Barnes » Thu Oct 25, 2007 3:40 pm

Antonio,

Please check your email.

Jeff
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Antonio Linares » Thu Oct 25, 2007 3:41 pm

Jeff,

I am testing it this way, so it can be simpler:
Code: Select all  Expand view
#include "FiveWin.ch"
#include "Struct.ch"

function Main()

   local oStruct, cBuffer, n

   STRUCT oStruct
      MEMBER cData AS STRING LEN 4 * 128
   ENDSTRUCT

   oStruct:cData = Replicate( " ", 4 * 128 )
   MsgInfo( Empty( oStruct:cData ) )

   cBuffer = oStruct:cBuffer
   TestFunc1( cBuffer )
   oStruct:cBuffer = cBuffer

   MsgInfo( Empty( oStruct:cData ) )
   
   for n = 1 to Len( oStruct:cData )
      if SubStr( oStruct:cData, n, 1 ) != " "
         MsgInfo( n )
      endif
   next     

return nil

DLL FUNCTION TESTFUNC1( pValues as LPSTR ) AS BOOL PASCAL ;
FROM "TestFunc1" LIB "TestLib12.dll"
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41356
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Oct 25, 2007 3:47 pm

Jeff,

There you have the MessageBox() shown value:
Code: Select all  Expand view
   for n = 1 to Len( oStruct:cData )
      if SubStr( oStruct:cData, n, 1 ) != " "
         MsgInfo( n )
      endif
   next
   
   MsgInfo( Bin2L( SubStr( oStruct:cData, 1, 4 ) ) ) // <=====

Don't know why they show [99], when they are placing it at zero :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41356
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Jeff Barnes » Thu Oct 25, 2007 4:50 pm

Antonio,

Are you sure this is right? They told me that the value should be 8300 at a[99].

With this code we get a value of 808464534.

It looks like the input and output values are the same?

Jeff
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 20 guests