From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: How Do I catch a "printf interrupt" ? Date: 27 Jan 2000 14:09:04 GMT Organization: Aachen University of Technology (RWTH) Lines: 32 Message-ID: <86pji0$g3g$1@nets3.rz.RWTH-Aachen.DE> References: <86n3vr$dll$1 AT nnrp1 DOT deja DOT com> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 948982144 16496 137.226.32.75 (27 Jan 2000 14:09:04 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 27 Jan 2000 14:09:04 GMT User-Agent: tin/1.4-19991113 ("No Labels") (UNIX) (Linux/2.0.0 (i586)) Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com arcadepreserv AT hotmail DOT com wrote: > I think it is possible to trap a interrupt that accurs when a call to > printf is made, and then read the string a pointer is pointing to. You cannot trap that particular interrupt, just like so, because it is not an interrup of its own. To begin with, printf() is not implemented by any interrupt at all. It's a library function built into the program's code. At the very heart of its operation, there will of course be a DOS interrupt call (the 'write something to file' one), but even that you cannot easily trap from the parent process --- it occurs in the *child*, so if at all, the child would have to trap it. But that'd mean you'ld no longer be building a frontend for the other code, but instead modify that existing code iteself. Probably not what you wanted. If it's really plain printf() output you want to grab, you can spare yourself the work and use DJGPP's library function 'popen()', instead of 'system()' or similar, to call that child. It can automatically catch all its standard output (asynchronously, i.e. you'll get it after child process termination) and present it to you as a pseudo file. If that other program is a more 'typical' DOS full-screen application, though, the whole method won't work at all: all of them usually use direct screen writes, which you cannot catch at all, unless your frontend program 'owns' the whole system, like Windows does for its DOS boxes. Technically, you have to be at protection 'ring 0', to do that, and it's quite hard to get done, even then. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.