title: How to handle the content between unmanaged dll and C#
body: <p>Hi i got problems to handle information between an unmanaged dll and my C# code.</p>
  <p>The function in my C dll is:</p>
  <pre><code>int import_large_string(struct sha_struct *sha_s,
                     const char *large_string);
  </code></pre>
  <p>That import the large_string and transform into sha_s, the struct sha_struct is the following:</p>
  <pre><code>struct sha_struct 
  {
      struct information  *info;
      struct info_cfg cfg;
  };
  </code></pre>
  <p>And the information struct is something like</p>
  <pre><code>struct information 
  {
  int             version;
  char            serial_number[16];
  uint16_t        exp_date;
  };
  </code></pre>
  <p>In C# i imported the function import_large_string like this:</p>
  <pre><code>[DllImport(&quot;functionalDLL.dll&quot;, EntryPoint = &quot;import_large_string&quot;, CharSet = CharSet.Ansi)]
  public static int import_large_string(ref sha_struct sha_s, string large_string);
  </code></pre>
  <p>When i called the function, it suppose to store information in <code>sha_struct sha_s</code>, but i only have a random 8 digit number in <code>sha_s.information.version</code> not in the whole struct, what am I doing wrong?</p>
  <blockquote>
  <p><strong>Edited</strong></p>
  <p>My structs in C# are:</p>
  </blockquote>
  <pre><code>    [StructLayout(LayoutKind.Sequential)]
      public struct sha_struct
      {
          public information t;
          public info_cfg cfg;
      };
  
      [StructLayout(LayoutKind.Sequential)]
      public struct information
      {
          public int version;
          public string serial_number;
          public ushort exp_date;
      };
  
      [StructLayout(LayoutKind.Sequential)]
      public struct info_cfg
      {
          public string release_version;
          public string release_string;
          public string release_password;
      };
  </code></pre>