Mode: Real
OS: DOS
Comp: Borland C++ 5.02
Platform: DOS standard
EXE B Crashes if:
1. EXE A is set as TSR and loaded more then once. (this should not happen?)
2. EXE A is not a TSR,a and another program uses its (old) memory ( i understand this)
EXE A:
--------------------------------------------------------------------------------
#include <Iostream.h>
#include <Fstream.h>
#include <StdLib.h>
#include <DOS.h>
void huge (*HelloPtr)(void);
void Hello(void);
void main(void)
{
HelloPtr = &Hello;
(*HelloPtr)();
system("if exist C:\\TempPtr.dat del C:\\TempPtr.dat ");
ofstream Stream;
Stream.open("C:\\TempPtr.dat");
Stream<<HelloPtr;
Stream.close();
// _dos_keep(0, (_SS + (_SP+32/16) - _psp)); //Makes it TSR
}
void huge Hello(void)
{
cout<<"Hello World";
}
EXE B (the one that is run to test this external function calling)
-------------------------------------------------------------------------------
void huge (*HelloPtr)(void);
void main(void)
{
unsigned long Temp;
system("codesh~1.exe");
ifstream Stream;
Stream.open("C:\\TempPtr.dat");
Stream>>Temp;
Stream.close();
HelloPtr = (void huge(*)())Temp;
(*HelloPtr)();
getch(); //Also it crashes if this line is removed?!#$% wtf
}
Notes:
I have tried far, and _loadds also, no to avail.
Help Please!
Thanks
VoidLogic