🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.msdos.programmer
2 messages
2 total messages Started by Nathan T. Wild Tue, 06 Feb 1996 03:33
Pointer Stew...
#7903
Author: Nathan T. Wild
Date: Tue, 06 Feb 1996 03:33
53 lines
2498 bytes
I am implimenting a system, but which executable code modules are loaded
from disk files into allocated blocks.

This is working very well.  I allocated a big enough block, load the
"driver" in and aim a function pointer ar it.  

What I would like to do is have the code that I load in contain near
pointers to it's own groups of functions.  I have placed a header on the
driver module I wish to load that contains the offset from the current
segment for two functions contained within the driver block.

This time I want to calculate the segment and read in the offset and set
both function pointers accordingly.

I am having difficulty dereferencing things???



Say, for example that my code block is allocated at XXXX:0004.  The first 2
bytes are the pointer (within the block) to the first function and the next
2 bytes are the pointer to the second function.

I want to set my function pointer to the segment XXXX and the offset stored
at XXXX:0004 & 0005.  No matter how I reference this, I get my function
pointing to XXXX:0004!


I have tried (where driverPtr == XXXX:0004 and is a void far *):
	func1ptr = (void far **)driverPtr
	func2ptr = (void far **)(driverPtr+2)
	
But I get XXXX:0004 every time?  I can set the function pointers to what I
want if I use MK_FP(), FP_SEG() and peek(), but there has got to be a
better way than this?




In short, how, given the address of a stored pointer, set a function to
point to the address stored, no to the location it is stored in???

This is driving me nuts as I am sure it is fairly simple...

Please respond via Email, I cannot access this group "live"...

Thanks in advance...

|--------------------------------------------------------------------|
| ooooO (``)   (``) Ooooo | Nathan T. Wild                           | 
| (   ) )  (   )  ( (   ) | natewild@mbnet.mb.ca                     |
| )  (  (   ) (   ) )  (  | ftp://ftp.mbnet.mb.ca/pub/natewild       |
| (__)  ooooO Ooooo (__)  | http://www.mbnet.mb.ca/~natewild         |
|--------------------------------------------------------------------|
Re: Pointer Stew...
#7905
Author: George C. Lindauer
Date: Tue, 06 Feb 1996 20:00
68 lines
3180 bytes
natewild@mbnet.mb.ca (Nathan T. Wild) writes:

>I am implimenting a system, but which executable code modules are loaded
>from disk files into allocated blocks.

>This is working very well.  I allocated a big enough block, load the
>"driver" in and aim a function pointer ar it.  

>What I would like to do is have the code that I load in contain near
>pointers to it's own groups of functions.  I have placed a header on the
>driver module I wish to load that contains the offset from the current
>segment for two functions contained within the driver block.

>This time I want to calculate the segment and read in the offset and set
>both function pointers accordingly.

>I am having difficulty dereferencing things???



>Say, for example that my code block is allocated at XXXX:0004.  The first 2
>bytes are the pointer (within the block) to the first function and the next
>2 bytes are the pointer to the second function.

>I want to set my function pointer to the segment XXXX and the offset stored
>at XXXX:0004 & 0005.  No matter how I reference this, I get my function
>pointing to XXXX:0004!


>I have tried (where driverPtr == XXXX:0004 and is a void far *):
>	func1ptr = (void far **)driverPtr
>	func2ptr = (void far **)(driverPtr+2)
>	
>But I get XXXX:0004 every time?  I can set the function pointers to what I
>want if I use MK_FP(), FP_SEG() and peek(), but there has got to be a
>better way than this?

I would use MK_FP (it uses compiler primitives that manage segments and offsets)
, but you might get away with:

func1ptr = (void far *)(*(short *)driverPtr);
func2ptr = (void far *)(*(short *)(driverPtr+2));

Of course that last +2 may not work because driverPtr is void far *,
so you may have to do something like:

func2ptr = (void far *)(*(((short *)driverPtr)+1));

And maybe unsigned shorts would be smarter, I don't know.
And this still doesn't handle segments appropriately.  Oh well...



>In short, how, given the address of a stored pointer, set a function to
>point to the address stored, no to the location it is stored in???

>This is driving me nuts as I am sure it is fairly simple...

>Please respond via Email, I cannot access this group "live"...

>Thanks in advance...

>|--------------------------------------------------------------------|
>| ooooO (``)   (``) Ooooo | Nathan T. Wild                           | 
>| (   ) )  (   )  ( (   ) | natewild@mbnet.mb.ca                     |
>| )  (  (   ) (   ) )  (  | ftp://ftp.mbnet.mb.ca/pub/natewild       |
>| (__)  ooooO Ooooo (__)  | http://www.mbnet.mb.ca/~natewild         |
>|--------------------------------------------------------------------|
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads