Click here to Skip to main content
15,905,967 members
Home / Discussions / C#
   

C#

 
GeneralRe: Renaming or deleting a displayed imgae Pin
Christian Graus9-Nov-08 10:04
protectorChristian Graus9-Nov-08 10:04 
GeneralRe: Renaming or deleting a displayed imgae Pin
electriac9-Nov-08 10:13
electriac9-Nov-08 10:13 
GeneralRe: Renaming or deleting a displayed imgae Pin
Pete O'Hanlon9-Nov-08 10:19
mvePete O'Hanlon9-Nov-08 10:19 
GeneralRe: Renaming or deleting a displayed imgae Pin
Guffa9-Nov-08 10:53
Guffa9-Nov-08 10:53 
GeneralRe: Renaming or deleting a displayed imgae Pin
electriac9-Nov-08 11:23
electriac9-Nov-08 11:23 
GeneralRe: Renaming or deleting a displayed imgae Pin
Pete O'Hanlon9-Nov-08 22:52
mvePete O'Hanlon9-Nov-08 22:52 
GeneralRe: Renaming or deleting a displayed imgae Pin
electriac10-Nov-08 0:24
electriac10-Nov-08 0:24 
GeneralRe: Renaming or deleting a displayed imgae Pin
Pete O'Hanlon10-Nov-08 9:18
mvePete O'Hanlon10-Nov-08 9:18 
GeneralRe: Renaming or deleting a displayed imgae Pin
Mark Churchill9-Nov-08 12:28
Mark Churchill9-Nov-08 12:28 
QuestionDownloading a file... Pin
EliottA9-Nov-08 9:40
EliottA9-Nov-08 9:40 
QuestionRe: Downloading a file... Pin
Mark Salsbery9-Nov-08 9:51
Mark Salsbery9-Nov-08 9:51 
AnswerRe: Downloading a file... Pin
EliottA9-Nov-08 9:55
EliottA9-Nov-08 9:55 
GeneralRe: Downloading a file... Pin
Mark Salsbery9-Nov-08 10:02
Mark Salsbery9-Nov-08 10:02 
GeneralRe: Downloading a file... Pin
Christian Graus9-Nov-08 10:06
protectorChristian Graus9-Nov-08 10:06 
GeneralRe: Downloading a file... Pin
EliottA9-Nov-08 10:24
EliottA9-Nov-08 10:24 
GeneralRe: Downloading a file... Pin
EliottA9-Nov-08 10:27
EliottA9-Nov-08 10:27 
QuestionWorld coordinates? Pin
seafaror9-Nov-08 7:31
seafaror9-Nov-08 7:31 
GeneralRe: World coordinates? Pin
Luc Pattyn9-Nov-08 7:59
sitebuilderLuc Pattyn9-Nov-08 7:59 
GeneralRe: World coordinates? Pin
seafaror9-Nov-08 9:43
seafaror9-Nov-08 9:43 
QuestionCannot change Graphics.PageScale on Graphics object created via Control.CreateGraphics() Pin
pulsar19609-Nov-08 7:12
pulsar19609-Nov-08 7:12 
AnswerRe: Cannot change Graphics.PageScale on Graphics object created via Control.CreateGraphics() Pin
Christian Graus9-Nov-08 7:32
protectorChristian Graus9-Nov-08 7:32 
QuestionDll Callback and shared memory [modified] Pin
Paolo Vernazza9-Nov-08 6:33
Paolo Vernazza9-Nov-08 6:33 
I've a third party DLL that exports this function:
typedef UCHAR (__cdecl *RESPONSE_FUNC)(UCHAR eventID);

__declspec(dllimport) void SetCallback(RESPONSE_FUNC pfResponse, UCHAR* responseBuffer);

I must allocate the buffer, call the SetCallback function, and read the modified data when the callback function is called.

I tried with this code:
static byte[] responseBuffer = new byte[10];

delegate bool RESPONSE_FUNC(byte eventID);

[DllImport("mydll.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern void ANT_SetCallback (RESPONSE_FUNC callback, byte[] responseBuffer);

public void test
{
          ANT_SetCallback (EventCallback, responseBuffer);
}


static bool EventCallback(byte eventID)
{
     return true;
}


When the dll doesn't try to modify the buffer then the Callback function is called without errors(the first event doesn't access the buffer).
But when the DLL tries to modify the data in the buffer, the program crashes with a 0xc0000409 exception.

I'm stuck on this, any suggestion ?

modified on Sunday, November 9, 2008 1:01 PM

AnswerRe: Dll Callback and shared memory Pin
Mark Salsbery9-Nov-08 7:17
Mark Salsbery9-Nov-08 7:17 
GeneralRe: Dll Callback and shared memory Pin
Paolo Vernazza9-Nov-08 8:25
Paolo Vernazza9-Nov-08 8:25 
GeneralRe: Dll Callback and shared memory Pin
Mark Salsbery9-Nov-08 8:34
Mark Salsbery9-Nov-08 8:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.