[comp.sys.ibm.pc] Dumping Expanded Memory

yung@contact.uucp (11/27/90)

Hello, any expert in expanded memory out there???
 
I am writing a TSR software which requires dumping the expanded memory to
the hard disk. So far I have done everything I know about the expanded
memory but the damn thing is still not working. Here is the alogithm that
I used:
 
1) Check to make sure EMM is present.
2) Find out the total EMS pages exist.
3) Find out the page frame address for the first physical page.
4) Save the current page map to a buffer.
5) Allocate one page and get a handle.
6) Open a storage file on hard disk
7) Map the first logical page to the first physical page.
8) Save the physical page to the storage file.
9) Unmap the logical page.
10) Advance to the next logical page and repeat the process until all logical
    page has been saved.
11) Close the storage file.
12) Deallocate the handle.
13) Restore the page map from the buffer.
 
What did I miss? I have examined the file (created while we were running
Desqview and have used up almost all the expanded memory) and found out
that the file was almost entirely made up of 00 and FF's, which should
be source code or data instead.
 
I have worked on it from scratch for almost a month and is now totally
at lost of what goes wrong. I would REALLY appreciate any input.
 
Thanks in advance. Happy computing.
 
-Amos Yung.

yung@contact.uucp (12/05/90)

 
Thanks James! Your response sure helped clearing up a lot of confusions!
 
 
In article <4303@amc-gw.amc.com> jwbirdsa@europa.amc.com (James Birdsall)
writes:
>In article <1990Nov26.164506.24237@contact.uucp> yung@contact.uucp () writes:
>>I am writing a TSR software which requires dumping the expanded memory to
>>the hard disk.
>
>   As a side issue, I assume you are taking appropriate precautions for
>writing to disk from within a TSR? Since you mention being able to look at
>the file, you probably are (or you're lucky).
 
Yes. They have all been taken care of.
 
 
 
>>5) Allocate one page and get a handle.
>
>   THIS is the problem. When you get a handle/allocate pages, you are
>getting pages not used by any other handle. Hence, you wind up dumping the
>contents of unused memory to disk, and of course these contents are random.
>   What you should be doing is:
> 5) Get information on all handles presently in use (there is a call
>    to do this) which tells you what the handles are and how many pages
>    are allocated for each.
> 6) For each of those handles, dump each logical page to the disk by
>    mapping it to the first physical page and doing a disk write.
>    This is possible because EMM handles are global; the EMM does not
>    care whether the program using the handle is the same program that
>    the handle was allocated to.
 
You are probably right. Almost all the response that I've got so far
points to this problem. I am trying to fix it and hopefully get it done
by the weekend.
 
 
>  If you need more information, feel free to contact me.
Don't mind if I do    :^)
Aside from saving the memory to disk, I would also like to restore in
at some latter point as well. Can you suggest a feasible strategy for
me? Before I get into this EMM mess, I really didn't expect it would
be so difficult. Afterall, all I wanted to do was simple memory
dump and restoration. Is there any good book out there about programming
expanded memory? I have been looking but there seems to be pitifully
little out there.
 
Thanks again for your response. Happy Computing.
 
-Amos Yung