title: Passing private member pointer to Unmanaged Function C++/CLI
body: <p>I am having trouble passing an unmanaged pointer (stored as a member in a managed wrapper) to an unmanaged function that requires a double pointer (pointer to the stored unmanaged pointer).  This problem is illustrated below:</p>
  
  <p>I have a wrapper for an unmanaged C structure declared below: </p>
  
  <pre><code>   public ref class MyStructWrapper
      {
      private:
      myStruct *_rto;
      public:
  
      MyStructWrapper()
      {
          _rto = new myStruct();
      }
  
      // read-only property
      public property RTO{
         myStruct * get(){return _rto;}
      }
      }
  </code></pre>
  
  <p>I need to call a function from a C Dll:</p>
  
  <pre><code>// alters data based on data in "SomeotherStructWrapper"(which consequently holds a 
  // SomeOtherStruct* ).
  
  int SomeOtherStructWrapper::AlterMyStruct(myStructWrapper^ myObj)
  {
  
      // unmanaged function in C DLL
      pin_ptr&lt;myStruct&gt; ptr = myObj-&gt;RTO;
      AlterMyStructUnmanaged(&amp;ptr,&amp;someOtherStructStoredMemberPtr);
  
  
  }
  </code></pre>
  
  <p>The goal is to alter the data that myObj->RTO points to...  Unfortunately, this compiles and runs and alters the data behind ptr, but the actual data I need to be altered in myObj is not.  </p>
  
  <p>EDIT: </p>
  
  <p>This is the implementation of SomeOtherStructWrapper:</p>
  
  <pre><code>public ref class SomeOtherStructWrapper
      {
      private:
      otherStruct *_ots;
      public:
  
      MyStructWrapper()
      {
          _ots = new otherStruct();
      }
  
      int AlterMyStruct(MyStructWrapper ^rto);
   }
  }
  </code></pre>
  
  <p>Declaration of  AlterMyStructUnmanaged:</p>
  
  <pre><code>__declspec(dllexport) int AlterMyStructUnmanaged
  (
      MyStruct **Object,
      otherStruct struct
  );
  </code></pre>
  
  <p>Thanks in advance for the help!  </p>