Hello.. I got a problem I'm hoping someone here can help me with.
I am writing an application in c#, and wish to use a c++ library. In this library, I am calling the following method
Code:
    HANDLE WINAPI SFileFindFirstFile(
      HANDLE hMpq,                      // Archive handle
      const char * szMask,              // Search mask
      SFILE_FIND_DATA * lpFindFileData, // Pointer to the search result
      const char * szListFile           // Name of additional listfile
    );
Where SFILE_FIND_DATA is defined as
Code:
    struct SFILE_FIND_DATA
    {
      char   cFileName[MAX_PATH];              // Name of the found file
      char * szPlainName;                      // Plain name of the found file
      DWORD  dwHashIndex;                      // Hash table index for the file
      DWORD  dwBlockIndex;                     // Block table index for the file
      DWORD  dwFileSize;                       // Uncompressed size of the file, in bytes
      DWORD  dwFileFlags;                      // MPQ file flags
      DWORD  dwCompSize;                       // Compressed file size
      DWORD  dwFileTimeLo;                     // Low 32-bits of the file time (0 if not present)
      DWORD  dwFileTimeHi;                     // High 32-bits of the file time (0 if not present)
      LCID   lcLocale;                         // Locale version
    };
I'm having some trouble getting cFileName as a string in c#.. Anyone got an idea about how to do this?
What I'm doing now in c# is this
Code:
    [DllImport("StormLib.dll")]
    private static extern UInt32 SFileFindFirstFile(
          UInt32 hMpq,                      // Archive handle
          byte[] szMask,              // Search mask
          ref SFILE_FIND_DATA lpFindFileData, // Pointer to the search result
          UInt32 szListFile           // Name of additional listfile
    );

    struct SFILE_FIND_DATA
    {
            public byte[] cFileName;              // Name of the found file
            public IntPtr szPlainName;                      // Plain name of the found file
            public UInt32 dwHashIndex;                      // Hash table index for the file
            public UInt32 dwBlockIndex;                     // Block table index for the file
            public UInt32 dwFileSize;                       // Uncompressed size of the file, in bytes
            public UInt32 dwFileFlags;                      // MPQ file flags
            public UInt32 dwCompSize;                       // Compressed file size
            public UInt32 dwFileTimeLo;                     // Low 32-bits of the file time (0 if not present)
            public UInt32 dwFileTimeHi;                     // High 32-bits of the file time (0 if not present)
            public UInt32 lcLocale;                         // Locale version
    };
Like this, I get an exception about an attempt to write protected memory.

The dll is open source, so if you need more info, I can find it for you, or you can download the code at
http://www.zezula.net/en/mpq/stormlib.html