troubleshooting Question

return a value

Avatar of zeurx
zeurxFlag for United States of America asked on
System ProgrammingC++
6 Comments2 Solutions420 ViewsLast Modified:
OK guys, get this and get all my points i currently have...

A program runs fine in an IDE under debug, but when you execute it from exporer the just in time debugger kicks in but does not break in ASM.  Also it only has a problem when loading a dll.


[Edit Code Snips following]
I have found that when i return an LPCTSTR is when it crashes, still do not understand why it will work when ran from the IDE

Plugin.DLL
LPCTSTR *Initialize()
{
      // Initialize plugin
      args = new LPCTSTR;
      args[BCONNECT] = "Connect"; //Connect button text
      args[BDISCONNECT] = "Disconnect"; //Disconnect button text
      args[MAP] = "MapDrive";
      args[UNMAP] = "UnMapDrive";
      args[DOMAIN] = "DOMAIN";
      // Drive letter and server, 2 slots per network drive
      int NumOfDrives = 1; //The number of network drives
      Drives = new LPCTSTR;
      Drives[0] = "Z:"; //Drive letter to use
      Drives[1] = "localhost"; //Server to use
      Drives[2] = "127.0.0.1"; //Fallback IP
      // Add drives and servers to main array
      for(int i = 0; i <= NumOfDrives*3-1; i++)
      {
            args[DRIVES+i] = Drives[i];
            args[DRIVES+i+1] = NULL;
      }
      
      return args;
}

Program.exe
typedef LPCTSTR *(*Initialize)(void);
Initialize Init = (Initialize)::GetProcAddress(PlugDll,"Initialize");
if(!Init)
{
      MessageBox("Failed to initialize",0, MB_ICONERROR);
      break;
}
// Setup local vars
DriveArgs = NULL;
DriveArgs = new LPCTSTR;
// Call initialize function
break;
DriveArgs = Init();

Now if i break before i call the dll function my program wont crash so i know it is that function on the dll. could it be the returning of the LPCTSTR *args?
ASKER CERTIFIED SOLUTION
itsmeandnobodyelse

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 2 Answers and 6 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 2 Answers and 6 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004