Pointer array in C#

Discussion in 'Meetups & Events' started by siegelracing, Jan 15, 2009.

  1. siegelracing

    siegelracing Registered Vendor<br><b><font color="#666666">bion

    We're having a programming problem. Anybody know how you can have a pointer to an array that has a pointer in it?

    Siegel
     
  2. Kokopelli

    Kokopelli Active Member

    Your a tuner not a developer.

    I suggest you step away from the computer :rofl:
     
  3. nsvwrx

    nsvwrx Active Member

    i am a c# developer for a living, what do you need?
     
  4. nsvwrx

    nsvwrx Active Member

    FYI using unsafe code FTL.
     
  5. siegelracing

    siegelracing Registered Vendor<br><b><font color="#666666">bion

    We need to know how you can have a pointer to an array that has a pointer in it?
     
  6. siegelracing

    siegelracing Registered Vendor<br><b><font color="#666666">bion

    This is it in C+:

    SBYTE_ARRAY InputMsg;
    SBYTE_ARRAY OutputMsg;
    unsigned long status;

    unsigned char EcuAddr[1]; // ECU target address array
    unsigned char KeyWord[2]; // Keyword identifier array

    EcuAddr[0] = 0x33; // Initialization address used to activate all ECUs

    InputMsg.NumOfBytes = 1; // ECU target address array contains one address.
    InputMsg.BytePtr = &EcuAddr[0]; // Assign pointer to ECU target address array.
    OutputMsg.NumOfBytes = 2; // KeyWord array has 2 bytes allocated.
    OutputMsg.BytePtr = &KeyWord[0]; // Assign pointer to KeyWord array.

    status = PassThruIoctl(ChannelID, FIVE_BAUD_INIT, &InputMsg, &OutputMsg);
     
  7. nsvwrx

    nsvwrx Active Member

    Ah c++, sorry havent done that in years..
     
  8. EFI-Unlimited

    EFI-Unlimited New Member

    Well, we need that code translated into C#

    specifically, the line

    OutputMsg.BytePtr = &KeyWord[0]; // Assign pointer to KeyWord array.

    I think I have the rest of it figured out except for, I don't want the memory manager messing with the variables before I pass the pointers to the following function call, so I think a fixed statement needs to work its way in somewhere, but it is unclear how to have a fixed statement cover a block of code.

    Brian
     
    Last edited: Jan 16, 2009
  9. nsvwrx

    nsvwrx Active Member

    HMM you dont want the GC messing with the vars right?

    You could put that in a Unsafe block and tell the GC not the manage those vars..
     
  10. nsvwrx

    nsvwrx Active Member

  11. Cool_____

    Cool_____ Banned

    What software are you using Scott? IbOpenSource

    You can have pointers pointing to pointers that point to other pointers....yeah messy especially when the GC starts doing things.

    Too bad it's not in Java....I'd crack it in a heartbeat.
     
  12. XanRules

    XanRules Active Member


    [​IMG]
    I had to.
     

Share This Page