I'm using Visual Studio 2005
I have a function named "CallBIOWDLL" that calls a third party dll. When I compile and run the program at this point, it works fine. However, When I call CallBIOWDLL from my main function, it compiles, but when I run the program it freezes. I'm working with a simple win32 console program. Below is the code and debugging information. I've been struggling with this for a long time so any help is greatly appreciated:
Debugging info:
I have a function named "CallBIOWDLL" that calls a third party dll. When I compile and run the program at this point, it works fine. However, When I call CallBIOWDLL from my main function, it compiles, but when I run the program it freezes. I'm working with a simple win32 console program. Below is the code and debugging information. I've been struggling with this for a long time so any help is greatly appreciated:
Code:
// test5.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#define MAXLEN 360
char Details[12000];
char ErrMess[1200];
char numLines[12];
char EstLin[15];
char EstNon[15];
char EstUlt[15];
char EstPrim[15];
char EstMitiLin[15];
char EstMitiNon[15];
char UltTime[30];
char PrimTime[30];
char szString[MAXLEN] ;
int CallBIOWDLL(void)
{
strcpy(szString,"O=C");
/* get handle to dll */
HINSTANCE hGetProcIDDLL = LoadLibrary("C:\\WINDOWS\\system32\\BIOWDLL.dll");
/* get pointer to the function in the dll*/
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE(hGetProcIDDLL), "GetSrcBIOWIN");
/* Define the Function in the DLL for reuse. This is just prototyping
the dll's function. A mock of it. Use "stdcall" for maximum compatibility.
*/
typedef int (__stdcall * pICFUNC)(char*,char*,char*);
pICFUNC MyFunction;
MyFunction = pICFUNC(lpfnGetProcessID);
/* The actual call to the function contained in the dll */
int intMyReturnVal = MyFunction(szString,"test2",EstLin);
/* Release the Dll */
FreeLibrary(hGetProcIDDLL);
/* The return val from the dll */
return intMyReturnVal;
}
int _tmain(int argc, _TCHAR* argv[])
{
CallBIOWDLL();
return 0;
}
Debugging info:
Code:
'test5.exe': Loaded 'C:\Documents and Settings\epajn\My Documents\Visual Studio 2005\Projects\test5\Debug\test5.exe', Symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_f75eb16c\msvcr80d.dll', Symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\system32\BIOWDLL.dll', Binary was not built with debug information.
'test5.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', No symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\system32\lpk.dll', No symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\system32\usp10.dll', No symbols loaded.
'test5.exe': Loaded 'C:\WINDOWS\system32\apphelp.dll', No symbols loaded.
The thread 'Win32 Thread' (0xd24) has exited with code 0 (0x0).
Unhandled exception at 0x00000000 in test5.exe: 0xC0000005: Access violation reading location 0x00000000.
First-chance exception at 0x00000000 in test5.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x00000000 in test5.exe: 0xC0000005: Access violation reading location 0x00000000.
First-chance exception at 0x00000000 in test5.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x00000000 in test5.exe: 0xC0000005: Access violation reading location 0x00000000.
First-chance exception at 0x00000000 in test5.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x00000000 in test5.exe: 0xC0000005: Access violation reading location 0x00000000.
First-chance exception at 0x00000000 in test5.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x00000000 in test5.exe: 0xC0000005: Access violation reading location 0x00000000.
First-chance exception at 0x00000000 in test5.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x00000000 in test5.exe: 0xC0000005: Access violation reading location 0x00000000.
The program '[3852] test5.exe: Native' has exited with code 0 (0x0).