[RESOLVED] api_closehandle peculiar crashing

Blitz3D Forums/Blitz3D Programming/[RESOLVED] api_closehandle peculiar crashing

Mikorians(Posted 2014) [#1]
It's very strange behavior!

EDIT: AHA! Please advise on using global memory instead of banks. The API function's being greedy and won't let me free my bank without a MAV!
Show me the pointer(s) to use with an API and poke/peek loop example please.
It's for api_read/writefile and file mapping Never mind. I found it.

EDIT#2: DOUBLE AHA! That wasn't it. I think it was my API decls file.
MoveMemory is REALLY touchy!
For future reference folks, use this method:
Kernel32.decls:
api_RtlCopyMemory(Destination*,Source%,Length%):"RtlMoveMemory"
api_RtlCopyMemory2(Destination%,Source*,Length%):"RtlMoveMemory"
Your program:
api_RtlCopyMemory(MemBank,lApiMapFilePointer%,mSize%)
api_RtlCopyMemory2(lApiMapFilePointer%,MemBank,mSize%)
This seemed to solve my crashing issue.

[Original Plea for help]
Has anybody figured out why my working application
Would crash when it hits api_closehandle(hObj)?
My hObj is global and contains the right value or I couldn't write/read
to my created file handle.


videz(Posted 2014) [#2]
Hi Mikorians. By any chance what is the difference of this function with the standard file and read for B3D? looks interesting to me.

thanks.


Floyd(Posted 2015) [#3]
This sounds like C programming from the good old days. You are allocating blocks of memory then effectively using memcpy to move data into them. When some sort of cleanup causes the memory to be freed the program crashes. That suggests you wrote past the end of a block and corrupted the administrative data the OS needs to manage memory.


Mikorians(Posted 2015) [#4]
The use I had was for IPC, but can also be used to write to a disk file as well.
The reason for its deployment is that the windows API runs concurrently with blitz, and unlike the built-in file handling functions does NOT cause a noticable frame-rate stutter on a polygon-heavy 3D scene.

I have a Visual Basic 6 force-feedback client application for my many different devices BY name and control type. I use blitz to read the controls because its simpler, but VB for triggering FFB because the sample BB app was insufficient to my rather drastic needs.

I have BB samples of both API uses.


Mikorians(Posted 2015) [#5]
@Floyd: Actually, I had just called the function with incorrect parameters (gotta keep a weather eye on those decls). And I now understand C FAR MORE than I EVER wanted to.