The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Data corruption when calling external DLL
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Klaus.Schm1

Germany
4 Posts

Posted - 04/08/2005 :  09:37:38 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 75G SR3
Operating System: WinXP

I need to call C functions from an external DLL.
Everthing works fine except that for one function I get corrupted data except when I start Origin from the VS2003 debugger. If I step through the DLL'code from VS2003 when origin calls it everthing goes fine. If I run the DLL (both the Debug or Release build) stand allone in origin the data gets corrupted.

The function works fine btw. I called from a C test program and everything works OK. Only when calling it from Origin the memory gets corrupted.

Any suggestions ?

easwar

USA
1965 Posts

Posted - 04/08/2005 :  5:14:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:

Origin Version (Select Help-->About Origin): 75G SR3
Operating System: WinXP

I need to call C functions from an external DLL.
Everthing works fine except that for one function I get corrupted data except when I start Origin from the VS2003 debugger. If I step through the DLL'code from VS2003 when origin calls it everthing goes fine. If I run the DLL (both the Debug or Release build) stand allone in origin the data gets corrupted.

The function works fine btw. I called from a C test program and everything works OK. Only when calling it from Origin the memory gets corrupted.

Any suggestions ?





Hi,

Can you post here the prototypes of the functions exported from your DLL?

Thanks,

Easwar
OriginLab

Go to Top of Page

Klaus.Schm1

Germany
4 Posts

Posted - 04/11/2005 :  12:44:02 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here you go the header file I use in origin. If you want the entire project plus DLL's just let me know

// Header file for origin
// Load the external DLL
#pragma dll(C:\Dokumente und Einstellungen\skl.IPP\Eigene Dateien\Visual Studio Projects\Diffusion\OriginStub\Release\Diffusion.dll)
#pragma dll(C:\Dokumente und Einstellungen\skl.IPP\Eigene Dateien\Visual Studio Projects\Diffusion\OriginStub\Release\OriginStub.dll)
// Interface for origin
// Set the current diffuion profile
int SetDiffusionProfile(double* pX, double* pC, int NumLayers);
// Returns the number of layers in the current diffusion profile
int GetNumLayers(void);
// Gets the C(X) diffusion profile data
int GetDiffusionProfile(double* pX, double* pC, int* pNumLayers, int MaxLayers);
// Set the current D(C)
int SetDofC(double* pC, double* pD, int NumEntry);
// Get the number of entries in the current D(C)
int GetNumDofCEntries(void);
// Get D(C)
int GetDofC(double* pC, double* pD, int* pNumEntry, int MaxEntries);
// Runs the diffusion code
// Constant D
int DiffusionProfileDConst(double D, double dt, int NumSteps, double MinVal, double MaxVal);
// Uses the current D(C)
int DiffusionProfileDofC(double dt, int NumSteps, double MinVal, double MaxVal);
// Performs BM-Analysis
int BMAnalysis(double Time, int MaxSteps, double Acc);
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000