Mail Archives: djgpp/1997/03/18/06:36:57
On Sun, 16 Mar 1997, enigma wrote:
> i'm trying to copy memory from a real pointer to a protected mode
> pointer.  well, i got the copying of bytes to work, but my func for
> copying unsigned words isn't working.  i could use a little help here
> folks
Not enough information.  The only thing that I can find wrong with
your code is that you rely on the FFFFh word to appear before `count'
hits 256; if that doesn't happen, you begin to overwrite your memory.
However, you didn't tell:
	1) How exactly is that code ``not working''.
	2) How do you compute the RMptr thing (real-mode pointers are
seg:off pairs, so how did you get them into a single UWORD?).  Without
this info it is hard to know whether your RM_TO_LINEAR macro is
correct.
Some more notes:
>    addr = RM_TO_LINEAR((ULONG)RMptr);
                         ^^^^^^^^^^^^
That should be (ULONG)*RMptr I think, no?
>    _farsetsel(_dos_ds);
>    while (_farnspeekw(addr) != 0xFFFF) {
>       buffer[count++] = _farnspeekw(addr++);
>       addr++;
>    }
Why do you call `_farnspeekw' twice for the same address?  Save the
value from the first call, then use it inside `while'.
>    buffer[count] = 0xFFFF;
>    p = (UWORD *)malloc(count);
>    memcpy(p,buffer,count);
Why do you need to use a local buffer, then move it into another one?
Allocate an initial buffer, move directly into it, then grow it or
make smaller by calling `realloc'.  This is cleaner and doesn't have
any artificial limits like 256.
- Raw text -