Mail Archives: djgpp/2000/08/16/08:00:46
rui_paz AT my-deja DOT com wrote:
> Hi,
> Can sameone point me to info about making a program using DJGPP that can
> change the master enviroment to set a variable?
You're not supposed to be allowed doing such a thing, originally. The
master environment belongs to its owner (the root command.com), which
is supposed to be protected from other processes mingling with its
data structures. I.e. you shouldn't be doing that, usually.
That said: there *are* ways to do it. (There always are, on an OS as
badly protected against malicious software as DOS).
Two ways are well-known:
1) Use undocumented DOS methods to walk the chain of memory blocks
and find the one that stores the environment block for the master
copy of command.com. This is essentially the same thing 'mem /d'
does. You'll need at lowlevel system docs like Ralf Brown's Interrupt
List to be able to do that. Using DJGPP to do it will complicate
matters further.
2) Call your own C program from a .bat file, let it write another,
temporary .bat file, and have the first batch execute the second,
after termination of the C application:
@echo off
c:\some\where\yourprog.exe
if exist %TEMP%\yourprog.bat call %TEMP%\yourprog.bat
if exist %TEMP%\yourprog.bat del %TEMP%\yourprog.bat
In this setup, yourprog.exe can output 'set var=content' lines into
%TEMP%\yourprog.bat, and they'll be executed, and change the
master environment, after termination of yourprog.exe.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -