title: Passing a pointer from c# to c++ ends with unexpected results
body: <p>im trying to pass a pointer from c# to c++, this ends with unexpected result in the c++ side when i always receive the same address even when i send a NULL pointer from the c#.</p>
  
  <p>some details.</p>
  
  <p>note: <strong>this is a different kind of question.</strong></p>
  
  <p>c++:</p>
  
  <pre><code>#pragma pack(push, 4)
          struct CEA708CONFIG 
          {
              BYTE                b608Service;            
              BYTE                bCompactStream;         
              BYTE                pActiveServices[63];    
              LONG                lActiveServiceCount;    //
              POINT               ptAlignmentPosition;    /
          };
          #pragma pack(pop)
  
          interface
          __declspec(uuid("{F1FAC4B6-5DAA-4875-B76B-8C10A0C0B22E}"))
          ICEA708Decoder : IUnknown {
              virtual HRESULT SetConfig(IN const CEA708CONFIG* pConfig) = 0;
              virtual HRESULT GetConfig(OUT CEA708CONFIG* pConfig) = 0;
          };
  </code></pre>
  
  <p>and the c# part:</p>
  
  <pre><code>[StructLayout(LayoutKind.Sequential, Pack = 4)]
      public unsafe struct CEA708CONFIG
      {
          public byte is608Service;
          public byte isCompactStream;
          public fixed byte activeServices[63];
          public int activeServiceCount;
          public Point alignmentPosition;
      };
  
      [ComVisible(true), ComImport, Guid("F1FAC4B6-5DAA-4875-B76B-8C10A0C0B22E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
      public interface ICEA708Decoder
      {
          [PreserveSig]
          int SetConfig([In] IntPtr config);
          [PreserveSig]
          int GetConfig([Out] out CEA708CONFIG config);
      }
  </code></pre>
  
  <p>and the code that actually does the work:</p>
  
  <pre><code> int     structSize = Marshal.SizeOf(cc708Config);
      IntPtr  structPtr  = Marshal.AllocHGlobal(structSize);
  
      Marshal.StructureToPtr(cc708Config, structPtr, false);
  
      if (0 != (hr = CC708DecoderConfig.SetConfig(/*structPtr*/IntPtr.Zero)))
      {
          throw new ApplicationException("Couldn't SetConfig() because: " + DirectShowLib.DsError.GetErrorText(hr));
      }
  </code></pre>
  
  <p>as you can see i even tried to send IntPtr.Zero, which ended with the following address in the c++ part: 0x0bb00058.</p>
  
  <p>my guess is that something is wrong with DS register, not sure though.</p>
  
  <p><strong>edit: whenever i step into to the c++ part of SetConfig()'s, i can see that 'this'' address is 0x0003, how is it possible?</strong></p>