create a pcode dll

create a pcode dll

Postby don lowenstein » Mon Jan 05, 2009 7:21 pm

I am using the samples from FiveWin testdllp.prg and pcodedll.prg
when I execute the exe made using the testdllp.prg the following message appears

"An exception (C00000FD) occurred during DllEntryPoint or DLLMain in module:
...\pcodedll.dll


any help is greatly appreciated.
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: create a pcode dll

Postby ukoenig » Mon Jan 05, 2009 8:28 pm

Hello Don,

I compiled and tested the samples < TESTDLLP.prg (13.12.2007) > and < PCODEDLL.prg (13.12.2007)
It works fine here, no error ( I using xHARBOUR ).
The Dll is inside the same path of the exe-file ?

Regards
Uwe :lol:
Last edited by ukoenig on Mon Jan 05, 2009 10:21 pm, edited 4 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: create a pcode dll

Postby Antonio Linares » Mon Jan 05, 2009 9:08 pm

Don,

Are you using Harbour or xHarbour ?

Borland C ?
regards, saludos

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

Re: create a pcode dll

Postby don lowenstein » Mon Jan 05, 2009 11:29 pm

borland c with xharbour10 with fwh 7.1
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: create a pcode dll

Postby Antonio Linares » Tue Jan 06, 2009 6:29 pm

Don,

We provide several examples with FWH:

FWH\samples\TestDLLP.prg shows how to use a pcode DLL

FWH\samples\pcodedll.prg shows how to build a pcode DLL using buildhdp.bat

But I am afraid that you may experience compatibility problems.

We recommend you to upgrade to FWH 8.12 and current xHarbour provided by FiveTech, in order to be able to build and test our same examples, so we can provide you the proper tech support.
regards, saludos

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

Re: create a pcode dll

Postby csincuir » Tue Jan 06, 2009 10:04 pm

Antonio, estos ejemplos solo funcionan con Harbour?
Estoy tratando de probarlos con xHarbour, y Borland C++ 5.5, pero me hace falta "MAINDLLP.OBJ"

Saludos cordiales.

Carlos Sincuir.
csincuir
 
Posts: 407
Joined: Sat Feb 03, 2007 6:36 am
Location: Guatemala

Re: create a pcode dll

Postby Antonio Linares » Tue Jan 06, 2009 11:26 pm

Carlos,

Those examples work with both Harbour and xHarbour.

maindllp.obj is not automatically created by Harbour/xHarbour makefiles, so you have to create it manually from Harbour/xHarbour source\vm\maindllp.c

Here you have maindllp.obj already created for Harbour:
http://www.mediafire.com/?sharekey=de51 ... b23c8c3964

and maindllp.obj for xHarbour:
http://www.mediafire.com/?sharekey=de51 ... 052f1d41f7
regards, saludos

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

Re: create a pcode dll

Postby don lowenstein » Wed Jan 07, 2009 12:31 am

Thank you for your help - we have successfully passed a char value to DLL
Is it possible to pass an array ?
If not can you provide samples for Int, Logical(bool).
We have a Need to pass various parameters to a dll, and are not C programmers.
We are having difficulties with more than 1 parm.

Thank you for your help.

p.s.
Is the debugger fixed in the Latest version of xHarbour1.0?
We have NOT upgraded do to the lack of a debugger.
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: create a pcode dll

Postby Antonio Linares » Wed Jan 07, 2009 12:54 am

Don,

Based on your comments it seems to me that you are talking about a C DLL instead of a pcode DLL.

A pcode DLL is created using PRG code and it uses the EXE "virtual machine". They are small DLLs that just contain "pcode" and need the "virtual machine" from the EXE, to execute the pcode.

A C DLL is created using C code (usually) and its C code is called from the EXE. It does not need the EXE "virtual machine" at all.

I recommend you this document reading as it explains the different kind of DLLs that can be managed with Harbour/xHarbour:
/*
* $Id: windll.txt 5836 2002-12-28 00:32:44Z brianhays $
*/

Windows 32-bit DLLs with Harbour code
=====================================

Programs created with Clipper or Harbour are traditionally a
monolithic EXE containing all executable code. This includes
the Virtual Machine (VM) and the RunTime Library (RTL) as well as
your own code. Running under Windows (Win32) with Harbour, you
can now also create and use Windows DLLs that contain PRG code.

Harbour supports Win32 DLLs in 3 ways.

1) Self-contained DLLs containing functions from any platform.
(These are not what we call a "Harbour.dll", although they may
be named that. The DLL entry points are different.)
These have the VM/RTL inside them and can be used by any other
Windows program. You can create a .lib for static linking,
or use GetProcAddress as in any standard Win32 DLL.
Calling Harbour/Prg functions directly is limited to
those that take no parameters unless you include C functions
in the DLL that take parameters and then call the PRG-level
code.

To do static linking, do this to create the .lib:
implib harbour.lib harbour.dll
For the Borland C platform, use that library and import32.lib
and cw32.lib from Borland, and you are ready to go.

See contrib\delphi\hbdll for an example of a Delphi program that can
use all of Harbour's functionality by accessing a self-contained DLL.
BLD_SDLL.BAT is used there to create the DLL.


2) PCode EXEs using a Harbour.dll

A Harbour.dll is designed to be called from a Harbour app.
A pcode EXE is a small Harbour executable that does not contain the
VM/RTL. To execute its functions, it must load and access a
Harbour.dll.
If you want dynamic linking, then use this to execute a Harbour
dynamically loaded pcode DLL function or procedure:
HB_DllDo( <cFuncName> [,<params...>] ) --> [<uResult>]

This lets you have all your common code in a DLL, and have lots
of small EXEs that use it. Realize however that, even though this
may be a nice way to manage your code, each EXE may
load its own image of the Harbour.dll into memory at runtime.
In terms of Windows memory, there may not be a benefit to using pcode
EXEs over monolithic EXEs. But it may be a worthwhile maintenance
benefit to have lots of replaceable small exes.

3) PCode DLLs used from traditional EXEs
A pcode DLL does not contain the VM/RTL.
It is a library of Harbour-compiled PRG code that uses the VM/RTL
of the EXE that calls it. This has the benefit of having
replaceable modules in DLLs that don't necessarily require updating
your EXE.


The following is clipped from a msg by Antonio Linares to the Harbour
developer list explaining some of the details:

Please notice that there are three different Windows DLL entry points:
+ source/vm/
* maindll.c Windows self-contained DLL entry point
* maindllh.c Windows Harbour DLL entry point (harbour.dll)
* maindllp.c Windows pcode DLL entry point and VM/RTL routing functions

> * maindll.c Windows self-contained DLL entry point
To produce Harbour code, as DLLs, that may be used
from other programming languages applications (as VB,
Delphi, C++, etc...)

> * maindllh.c Windows Harbour DLL entry point (harbour.dll)
To produce Harbour.dll, to be just used from small pcode Harbour EXEs

> * maindllp.c Windows pcode DLL entry point and VM/RTL routing
To produce small pcode DLLs, to be used just from Harbour EXE apps.
maindllp.c is the entry point for the Harbour pcode DLLs. pcode DLLs
are quite small DLLs, that just contain pcode and/or C (using extend
api) functions.

mainwin.c is the entry point for Windows EXEs, not for DLLs.

You may use maindll.c, maindllh.c or maindllp.c based on
your needs.

If you are looking to build a Harbour.dll, then you must use
maindllh.c
regards, saludos

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

Re: create a pcode dll

Postby Antonio Linares » Wed Jan 07, 2009 1:03 am

Don,

The question is:

Are you using a third party DLL that can be used from any programming language ? This uses to be a C DLL.
If this is the case, then keep in mind that the C language knows "nothing" about the Harbour/xHarbour items structure. You can just supply C types to the DLL, so you have to convert the Harbour/xHarbour items values to C types, in order to manage them from the DLL.

Have you created the DLL youself using C language ?

Or, have you used harbour.exe to create the DLL ?
regards, saludos

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

Re: create a pcode dll

Postby Antonio Linares » Wed Jan 07, 2009 1:11 am

Don,

>
Is the debugger fixed in the Latest version of xHarbour1.0?
We have NOT upgraded do to the lack of a debugger.
>

The xHarbour debugger is properly working with FWH 8.12 and the xHarbour build that FiveTech provides:

Image
regards, saludos

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

Re: create a pcode dll

Postby don lowenstein » Wed Jan 07, 2009 3:15 pm

Antoio,

Thank you for your feedback.

We are wanting to create an executable dll using prg code. We do not have much C coding experience.
Sounds like the pcode dll is the way to go. We are currently looking at our options to determine the best way to implement custom coding without having to make a new exe.
I am assuming since you did not answer the "pass array question" - it is not possible.

Please advise.

Once again your assistance is greatly appreciated.
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: create a pcode dll

Postby Antonio Linares » Wed Jan 07, 2009 4:10 pm

Don,

> I am assuming since you did not answer the "pass array question" - it is not possible.

It is perfectly possible :-)

Being a pcode DLL you can supply Harbour/xHarbour items to it. No limitations.

Please show how you are coding your DLL or an example, so we can point you in the right way. thanks
regards, saludos

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

Re: create a pcode dll

Postby don lowenstein » Thu Jan 08, 2009 12:23 am

Antonio,

Below is a sample calling prg:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()
   local cString := "Hello world!"
   local cString2 := "ABC or 123?"
   local LPARM := .T., retarr := {}, passparm := {}
   local NPARM := 998877
   local DPARM := DATE()

   DOPROC( "MAIN" )

   aadd(passparm, {cstring, cstring2, nparm, lparm, dparm } )

   retarr := DOPROC( "ONEPARAM", @passparm )

   MsgInfo( "mydll returned OK to myEXE" )
   
return nil

DLL FUNCTION DOPROC( cProc AS LPSTR, aparm AS ???? ) AS LONG PASCAL LIB "MYDLL.dll"


What we would like to do is call the dll with an array of parameters. This array may contain various data types.
We would like to get back an array contining various data items as needed. Also, is it possible to change the contents of the original passed array and see the results in the calling prg?

Once again your assistance is greatly appreciated.
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: create a pcode dll

Postby Antonio Linares » Fri Jan 09, 2009 11:25 pm

Don,

Are you building your DLL as described here ?
viewtopic.php?f=3&t=11626&start=0&hilit=oneparam

If yes, then you are calling a C function and you can not supply a Harbour item to it.

Please review the use of HBDLLENTRY...() in that same post. You can supply a Harbour item to those functions, even if they are arrays :-)
regards, saludos

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

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