Article View: comp.os.msdos.programmer
Article #7944Re: Writing A Pointer To Memory
From: 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*
Technical Details
Message-ID:
<314D966D.4020@wimbledon.bt.co.uk>Path:
arc1-ca.pugleaf.net!lade.news.pipex.net!pipex!bt!usenetReferences:
<4ijpev$ev8@canopus.cc.umanitoba.ca>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!lade.news.pipex.net!pipex!bt!usenet From: Phlash <paa@wimbledon.bt.co.uk> Newsgroups: comp.os.msdos.programmer,comp.lang.c Subject: Re: Writing A Pointer To Memory Date: Mon, 18 Mar 1996 16:59:25 +0000 Organization: BT Labs - but speaking only for myself Message-ID: <314D966D.4020@wimbledon.bt.co.uk> References: <4ijpev$ev8@canopus.cc.umanitoba.ca> NNTP-Posting-Host: 132.146.47.224 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 2.0 (Win95; I) To: "Nathan T. Wild" <natewild@mbnet.mb.ca>