Click here to Skip to main content
15,896,550 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Dll Callback and shared memory Pin
Paolo Vernazza10-Nov-08 5:21
Paolo Vernazza10-Nov-08 5:21 
Questionhow to send text to external program Pin
E_Gold9-Nov-08 2:36
E_Gold9-Nov-08 2:36 
AnswerRe: how to send text to external program Pin
Giorgi Dalakishvili9-Nov-08 3:09
mentorGiorgi Dalakishvili9-Nov-08 3:09 
GeneralRe: how to send text to external program Pin
E_Gold9-Nov-08 3:39
E_Gold9-Nov-08 3:39 
GeneralRe: how to send text to external program Pin
Giorgi Dalakishvili9-Nov-08 4:55
mentorGiorgi Dalakishvili9-Nov-08 4:55 
AnswerRe: how to send text to external program Pin
sph3rex9-Nov-08 6:31
sph3rex9-Nov-08 6:31 
GeneralRe: how to send text to external program Pin
jas0n2311-Nov-08 0:41
jas0n2311-Nov-08 0:41 
QuestionRun an application? Pin
dec829-Nov-08 1:49
dec829-Nov-08 1:49 
AnswerRe: Run an application? Pin
Guffa9-Nov-08 3:26
Guffa9-Nov-08 3:26 
GeneralRe: Run an application? Pin
dec829-Nov-08 5:21
dec829-Nov-08 5:21 
GeneralRe: Run an application? Pin
Guffa9-Nov-08 6:40
Guffa9-Nov-08 6:40 
QuestionHow to find parent's child in matrix (in maze)? Pin
sitnet9-Nov-08 1:25
sitnet9-Nov-08 1:25 
AnswerRe: How to find parent's child in matrix (in maze)? Pin
Christian Graus9-Nov-08 6:06
protectorChristian Graus9-Nov-08 6:06 
GeneralRe: How to find parent's child in matrix (in maze)? Pin
Luc Pattyn9-Nov-08 8:09
sitebuilderLuc Pattyn9-Nov-08 8:09 

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.