piclist 2003\11\23\092741a >
Thread: How do you do a callback in a Windows DLL?
face picon face BY : Byron A Jeff email (remove spam text)

I started this message the other day, but I don't think that I actually posted
it. So apologies if this is a repost.

One of my students is doing a port of picprg to Windows for a semester
project. picprg is Brian Lane's Linux software for programming PICs using
Tait style programmers hanging from the parallel port, such as my Trivial
Programmer. Our alpha version is working and we're planning on releasing an
interim version just as soon as the code to save the config settings is done.

The next stage is updating the programming algorithms so that all of the chips
that folks really want to use (18F, 16F819, 16F88, 16F648A, 16F87XA) can be
programmed. Our game plan is to separate each of the program/read/verify
routines into a DLL. That way a new programming algorithm can be included by
downloading a new DLL.

In order to maintain dual system compatibility, we are compiling with the
MingW GCC compiler which has a compatibility layer for translating Unix
specific calls into Windows equivalents. The DLL builder works fine BTW.

So here's the problem. The programming software is divided into a set of low
level routines that twiddle the parallel port (vpp_on, bit_on, bit_off and the
like), and the high level routines that read/program the chip using the low
level routines. Since the low level routines are used by every programming
algorithm, and are used for auto chip detection, we are trying to keep these
in the main executable, only moving the high level routines to the DLLs.

The problem is how do you make callbacks into the main application's low level
routines from the high level routines in the DLL? Quick example:

--------- main.c ------------------

void vpp_on()
  // Code to turn the vpp bit on

  // Load the DLL
  read_pic(); // A routine in the DLL

int read_pic()
  // Read the chip. Calls vpp_on
  // ....

Under Linux it's possible to tell the linker to export symbols from the main
executable so that they are visible from loaded shared libraries. So the
routine set above works fine. main calls read_pic int testdll and testdll does
a callback to vpp_on in the main executable.

The documentation I've read on DLLs talks about import/export tables that
defines what the DLL uses or provides. But I can't find anything that talks
about an export table for an executable, only DLLs.

I have my backup solution if I can't figure out how to do this: take the low
level routines and put them in a separate DLL that's linked to the application.
Since the DLL can have a export table, when the high level DLL is loaded, the
exported symbols from the low level DLL should be visible to it, so that
these routines can be called.

Any suggestions on this would be appreciated. It's one of those situations
where I know what I want to do, I figure it can be done, but I just don't
program in Windows enough to figure out how to do it.



http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


See also: www.piclist.com/techref/index.htm?key=how+you+callback
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) How do you do a callback in a Windows DLL?

month overview.

new search...