Thread View: comp.os.msdos.programmer
2 messages
2 total messages
Started by Nathan T. Wild
Mon, 18 Mar 1996 13:46
Writing A Pointer To Memory
Author: Nathan T. Wild
Date: Mon, 18 Mar 1996 13:46
Date: Mon, 18 Mar 1996 13:46
26 lines
1194 bytes
1194 bytes
I know this is s fairly stupid question, but I am having a remarkable amount of confusion over it... I have a far * to a structure. I need to share this with a device driver, by writing the pointer to a location in memory. the location in RAM that I have to write to is 2xsizeof(far *) or 8 bytes back from a specific location in memory. I know where I need to write the pointer, and what I need to write, but for some strange reason I cannot get it to do what I want... take: void far *ptr = far pointer to a structure; desiredDestinationPtr = (locationPtr - sizeof(void far *)); All I want to do is copy the 4 byte seg/offset pointer that ptr points to into physical memory... Aargh... It shouldn't be this difficult... Too much coffee... Please respond via email asap... Thanks
Re: Writing A Pointer To Memory
Author: Phlash
Date: Mon, 18 Mar 1996 16:59
Date: Mon, 18 Mar 1996 16:59
41 lines
2099 bytes
2099 bytes
Nathan T. Wild wrote:
>
> I know this is s fairly stupid question, but I am having a remarkable
> amount of confusion over it...
Such is life :-)
> I have a far * to a structure. I need to share this with a device driver, by
> writing the pointer to a location in memory.
>
> the location in RAM that I have to write to is 2xsizeof(far *) or 8 bytes back
> from a specific location in memory.
assume declarations of this form:
char far *locationPtr = <specific location in memory>
struct far *structPtr = &myStructure;
then it should be possible to do this:
*((struct far * far *)(locationPtr - sizeof(struct far *) * 2)) = structPtr;
ie: Do the math on a char far *, then cast to a pointer to a pointer to struct,
then copy the pointer to struct into this memory location by de-referencing the
new location...
or for the less pointer-oriented:
_fmemcpy(locationPtr - sizeof(struct far *) * 2, (char far *)&structPtr,
sizeof(struct far *));
ie: calculate the memory location, give to _fmemcpy as destination address, give
address of pointer to copy, give size of pointer to copy...
PS: What wierd device driver needs this sort of thing?
--
!----- paa@wimbledon.bt.co.uk ------! GAT d?(d) H s:-- g?>+++ p?>! au--- a- w+
!Phil "Phlash" Ashby!+44-1473-293670! v*>! C++$ L+>+++ 3+ ULHS+++(++++)$ P- E-
!G10,153 Princes St.,Ipswich,England! N++ K- W++ M V->! -po+ Y+ t-@ 5+ !j R G?
!- http://www.mround.bt.co.uk/~paa -! tv>! b+ D+ B? e-- u+(-) h---- f* r+++ y*
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