Using FILE* as paramter to DLL-function fails
-
Hi, i want to call a function defined in an DLL with a FILE * as parameter, but trying to access the file via this fileponter i get an access violation. Isn't it possible to pass a filepointer to a dll function, or is there anything else to do before passing this pointer? TIA, Chris
-
Hi, i want to call a function defined in an DLL with a FILE * as parameter, but trying to access the file via this fileponter i get an access violation. Isn't it possible to pass a filepointer to a dll function, or is there anything else to do before passing this pointer? TIA, Chris
-
Hi, i want to call a function defined in an DLL with a FILE * as parameter, but trying to access the file via this fileponter i get an access violation. Isn't it possible to pass a filepointer to a dll function, or is there anything else to do before passing this pointer? TIA, Chris
I'm not sure if this is the answer but from experience I do know that the standard library allocates memeory out of a heap. This heap is maintained by the standard library and your application and it's DLL would each maintain separate heaps. A problem will occur if a heap allocation/deallocation occurs when this FILE * pointer is used. Basically you cannot allocate from the heap in the application then attempt to deallocate from the DLL since the DLL assumes that the memory is in its own heap. I would suggest if possible to use file handles and work with the Win32 API instead of the standard library.
-
I'm not sure if this is the answer but from experience I do know that the standard library allocates memeory out of a heap. This heap is maintained by the standard library and your application and it's DLL would each maintain separate heaps. A problem will occur if a heap allocation/deallocation occurs when this FILE * pointer is used. Basically you cannot allocate from the heap in the application then attempt to deallocate from the DLL since the DLL assumes that the memory is in its own heap. I would suggest if possible to use file handles and work with the Win32 API instead of the standard library.
-
Hi, i want to call a function defined in an DLL with a FILE * as parameter, but trying to access the file via this fileponter i get an access violation. Isn't it possible to pass a filepointer to a dll function, or is there anything else to do before passing this pointer? TIA, Chris