Reputation: 442
I have problem with my application(s) - win32. I have client and server (nothing connected with net, just names). Client application isnt application, it's plugin working in Main Application. Server application is external application and it has closed source code and can callback functions from client. Client(plugin) is communicating with MainApplication via "Link"(pointer to structure with functions) and can send pointers to specifed defined structures(already filled), for example: structure with message, date and name. I can just modify plugin's source code. Now problem, server is calling function(for example, message received), is creating and filling there "message structure" and then using Link to send pointer to that structure MainApplication crashes because can't read that memory block.
Server calling function->creating and filling structure->sending pointer for that structure to MainApplication via Link->MainApplication tries to read memory addres and BAM crash.
If i'll do that manually, from plugin it's working.
How should I send that structure to Main Application? MainApplication can only receive address to structure. Maybe a little messed but you should understand problem.
Upvotes: 0
Views: 104
Reputation: 4328
Server calling function sending pointer for that structure to MainApplication may be local pointer for that server Function . You can allocate memory space to that pointer dynamically which will get allocated and hopefully can pass it to Main Application. This will not crash the code as you have not yet freed the memory from heap and then you can free it from heap after the Main Application is done with the pointer
Upvotes: 1