F
Fishman1175
Guest
Hello,
I'm guessing a developer or higher up might need to comment on this. I'm trying to pass the pointer of a buffer I create in GM to my C++ DLL. Now, the help docs say that this can be passed to be used in extensions. Here is the gml code:
buffer_new_map=buffer_create(2097152,buffer_fixed,8)
buffer_pointer=buffer_get_address(buffer_new_map)
simplex_set_buffer_address(real(buffer_pointer))
show_message(string(buffer_pointer))
simplex_set_buffer_address is an external call to my DLL.
Now, in C++ I have:
export double set_buffer_address(double hex_addr)
{
int ptr = (int) hex_addr;
buffer_pointer = reinterpret_cast<double *>(ptr);
ofstream myfile;
myfile.open ("C:\\output.txt");
myfile << buffer_pointer;
myfile.close();
return 1.0;
}
The error that appears in Game Maker's console is:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at calc_map()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
The output from the c++ file and the show_message are identical, so I know the memory addresses are the same. Am I just screwed? I don't see why the help doc says I can use the pointer in my extensions if I can't read or write to the data. What else can I try?
I'm guessing a developer or higher up might need to comment on this. I'm trying to pass the pointer of a buffer I create in GM to my C++ DLL. Now, the help docs say that this can be passed to be used in extensions. Here is the gml code:
buffer_new_map=buffer_create(2097152,buffer_fixed,8)
buffer_pointer=buffer_get_address(buffer_new_map)
simplex_set_buffer_address(real(buffer_pointer))
show_message(string(buffer_pointer))
simplex_set_buffer_address is an external call to my DLL.
Now, in C++ I have:
export double set_buffer_address(double hex_addr)
{
int ptr = (int) hex_addr;
buffer_pointer = reinterpret_cast<double *>(ptr);
ofstream myfile;
myfile.open ("C:\\output.txt");
myfile << buffer_pointer;
myfile.close();
return 1.0;
}
The error that appears in Game Maker's console is:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at calc_map()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
The output from the c++ file and the show_message are identical, so I know the memory addresses are the same. Am I just screwed? I don't see why the help doc says I can use the pointer in my extensions if I can't read or write to the data. What else can I try?