I created a simple DLL with the following code:
#include "stdafx.h"
#include "winNT.h"
#include <stdio.h>
#include <windows.h>
UINT A_AddOne (UINT32 Base)
{
return Base + 1;
}
I created a .def file an from VB.net I can call this DLL without problems. Now I created a second DLL that calls the first:
#include "stdafx.h"
#include "winNT.h"
#include <stdio.h>
#include <windows.h>
typedef UINT (*A_ADDONE)(UINT32);
UINT B_AddOne (UINT32 uiBase)
{
HINSTANCE hinstLib;
A_ADDONE ProcAdd;
BOOL fFreeResult = FALSE;
UINT32 param;
int Result;
Result = 0;
param = uiBase;
hinstLib = LoadLibrary(TEXT("C:\Visual Studio Projects\ESD\debug\DLL_A.dll"));
if (hinstLib = NULL) return 101;
ProcAdd = (A_ADDONE) GetProcAddress(hinstLib, TEXT("A_AddOne"));
if (ProcAdd = NULL) return 102;
Result = ProcAdd (param);
fFreeResult = FreeLibrary(hinstLib);
return Result;
}
When I try to call this function an AccessViolationException is thrown as I reach the line Result = ProcAdd (param);
Can anyone explain me why?
Thanks
#include "stdafx.h"
#include "winNT.h"
#include <stdio.h>
#include <windows.h>
UINT A_AddOne (UINT32 Base)
{
return Base + 1;
}
I created a .def file an from VB.net I can call this DLL without problems. Now I created a second DLL that calls the first:
#include "stdafx.h"
#include "winNT.h"
#include <stdio.h>
#include <windows.h>
typedef UINT (*A_ADDONE)(UINT32);
UINT B_AddOne (UINT32 uiBase)
{
HINSTANCE hinstLib;
A_ADDONE ProcAdd;
BOOL fFreeResult = FALSE;
UINT32 param;
int Result;
Result = 0;
param = uiBase;
hinstLib = LoadLibrary(TEXT("C:\Visual Studio Projects\ESD\debug\DLL_A.dll"));
if (hinstLib = NULL) return 101;
ProcAdd = (A_ADDONE) GetProcAddress(hinstLib, TEXT("A_AddOne"));
if (ProcAdd = NULL) return 102;
Result = ProcAdd (param);
fFreeResult = FreeLibrary(hinstLib);
return Result;
}
When I try to call this function an AccessViolationException is thrown as I reach the line Result = ProcAdd (param);
Can anyone explain me why?
Thanks