I have a DLL that I need to call. It's written in Pascal and although I have the source, I don't have pascal so I'm stuck with using the compiled DLL. The problem I have is that when I call a function, it seems to be using the pointer and then changing MY memory - and not just the variable I passed it, other variables nearby. So when I am in the middle of doing something else (normally writing debug), my data is changing.
My question is, is there any way to prevent the DLL from doing this? I tried adding a buffer zone between the memory I pass it and the memory I use.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
void MyClass::myFunction(int myParameter)
{
int myVariable;
int myOtherVariable = myParameter * 2;
int ignore[10000];
ignore[0] = 0; //Just to stop compiler warning about unused variable!
int variableToPass = 40;
int otherVariableToPass;
for (myVariable = 0; myVariable < myOtherVariable; myVariable++)
{
otherVariableToPass = 0 + myVariable;
CallNaughtyDLL(variableToPass, otherVariableToPass);
qDebug("Print some nice debug %d", myVariable);
}
}
However this just results in a Segmentation Fault at the end of the function on the line with the last }. I guess because the naughty DLL is still using the memory?