Вопрос

I have a error. The debugger says 0cx000000 or something like that access violation, which after reading online I found has to do with memory access violation or pointing t0 null memory location. Similar, but not same codes, examples, seem to be working. I do not understand the problem with this one. Or I do not understand how to solve this one.

Precise Error:

Unhandled exception at 0x00000000 in myfile.exe: 0xC0000005: Access violation reading location 0x00000000 on.

Main File:

MSG Msg;
HWND hWnd;

static void doSth(FIX32 propert[])
{
UINT wdev;
myFunction(WTI_DEFCONTEXT, CTX_DEVICE, &wdev);
.
.
.
}

WndProc()
{
switch(Msg){

case WM_CREATE:
    doSth(propert);
    return 0;
}

WINAPI WinMain(...)
{
hWnd=Create...

return Msg.wParam;
}

Source Code:

Bool LoadD(void)
{
libr=LoadLibrary(...);
GetProcessAddress(libr,myFunction);
return TRUE;
}

void UnloadD(void)
{
FreeLibrary(libr);
myFunc=NULL;
}

I had linking problem. Solved it. But this pointer problem is giving me trouble. The debugger points to the two lines in the code.

myFunction(WTI_DEFCONTEXT, CTX_DEVICE, &wdev);
doSth(propert);

I know this is vague, with this little information. Specially there are a lot of header files involved too. But, is the problem/solution apparent from this code? The problem is null reference(??). What is solution?

Это было полезно?

Решение 2

I had some problem loading library. Just explored little more and actually that fixed. Quoting hmjd:

Does LoadLibrary() succeed? Where is the result of GetProcAddress() stored and does it succeed?

Thanks

Другие советы

You should provide definition of "myFunction". I hope it can give us better understanding of problem. Check that you are passing address of wdev but value is uninitialized and also check that you are receiving a correct pointer.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top