Timeline for How can I properly execute and clean up after a DOS MZ executable loaded into memory with int21 function 4b01h?
Current License: CC BY-SA 4.0
18 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| S Dec 2, 2022 at 13:43 | history | suggested | Peter Mortensen | CC BY-SA 4.0 | Copy edited (e.g. ref. <https://en.wiktionary.org/wiki/cleanup#Noun>). Fixed the question formation - missing auxiliary (or helping) verb - see e.g. <https://www.youtube.com/watch?v=t4yWEt0OSpg&t=1m49s> (see also <https://www.youtube.com/watch?v=kS5NfSzXfrI> (QUASM)) - alternatively, drop the quest |
| Dec 2, 2022 at 1:02 | review | Suggested edits | |||
| S Dec 2, 2022 at 13:43 | |||||
| Dec 2, 2022 at 0:00 | history | became hot network question | |||
| Dec 1, 2022 at 23:09 | history | edited | TonyM | CC BY-SA 4.0 | Spelling and grammar. |
| Dec 1, 2022 at 21:25 | vote | accept | neuviemeporte | ||
| Dec 1, 2022 at 20:40 | comment | added | ecm | @StephenKitt I would in fact! I'm happy to be recognised =) But the "exit path" is actually the same as for plain 21.4B00. When the debugger regains control at the PRA it wrote to the child PSP's TPIV field then the child memory is already freed and possibly corrupted, except of course for 21.31 TSR returns. | |
| Dec 1, 2022 at 20:36 | answer | added | ecm | timeline score: 13 | |
| Dec 1, 2022 at 19:36 | comment | added | neuviemeporte | Well, the memory being released does not mean its contents go away. | |
| Dec 1, 2022 at 18:10 | comment | added | Stephen Kitt | @user3840170 I wonder whether the exit path isn’t different — this was intended for use by debuggers, so keeping the memory after execution would be useful too. I imagine ecm would know. | |
| Dec 1, 2022 at 18:00 | comment | added | user3840170 | Walk the MCB chain, I presume. However, I am not sure if this is actually necessary if you manage to jump to the entry point and let the child process run to completion. Everything should then get cleaned up when it exits. | |
| Dec 1, 2022 at 17:01 | comment | added | neuviemeporte | @user3840170, how do I identify other the other segments, if any? | |
| Dec 1, 2022 at 16:49 | comment | added | user3840170 | CS - PSP_SIZE is not a good way to determine the main segment of the loaded executable image; with MZ images, there is no guarantee that the entry point will be in the PSP’s segment. As noted in the RBIL, invoking the ‘exec’ syscall in this mode will switch the current PID (i.e. PSP segment) to the target process, so all you need to do is read the current PID and free that (and all other segments associated with that process). And of course, switch the current PID back to the parent’s. | |
| Dec 1, 2022 at 16:40 | comment | added | neuviemeporte | @StephenKitt I think you're right. I extracted the env segment from offset 0x2c in the loaded program's PSP, and after freeing it in addition to the PSP, I ended up with the exact same amount of memory as what I started with. Not sure about any other cleanups that are required though. | |
| Dec 1, 2022 at 16:31 | comment | added | Raffzahn | Also, from faint memory, wouldn't it be necessary to free all blocks assigned (Haven't done that kind of stuff since the mid 1990s). | |
| Dec 1, 2022 at 16:27 | history | edited | user3840170 | edited tags | |
| Dec 1, 2022 at 16:11 | comment | added | Stephen Kitt | 9 paragraphs, that wouldn’t happen to match the size of your environment, would it? | |
| Dec 1, 2022 at 16:09 | history | edited | Stephen Kitt | CC BY-SA 4.0 | Avoid subjecting people to porn ads. |
| Dec 1, 2022 at 15:59 | history | asked | neuviemeporte | CC BY-SA 4.0 |