LocHelper.cs
/// <summary>
/// Places the string with the given hashid into the stringbuilder passed in.
/// String ids can be present multiple times. This will return the last occurance
/// of the string. 
/// </summary>
/// <param name="hashId"></param>
/// <param name="sb">string will be added to the builder</param>
/// <returns>The location of the string id, -1 if not found </returns>
Places the string with the given hashid into the stringbuilder passed in.
String ids can be present multiple times. This will return the last occurance
of the string.
Places the string with the given hashid into the stringbuilder passed in . String ids can be present multiple times . This will return the last occurance of the string .
public int GetString(UInt32 hashId, StringBuilder sb)
        {
            int stringLoc = (int)BodyStart;
            int occurance = 0;
            int target_occurance = 1;
            if (mStringSet2 != null && mStringSet2.ContainsKey(hashId))
                target_occurance++;
            UInt32 currentHash = 0;
            while (true)
            {
                currentHash = BinUtils.GetNumberAtLocation(stringLoc, mData);
                if (currentHash == hashId)
                {
                    occurance++;
                    if( occurance == target_occurance)
                        break;
                }
                stringLoc = NextStringLoc(stringLoc);
                if (stringLoc + 10 > mData.Count)
                    return -1;
            }
            UInt16 sz = BinUtils.Get2ByteNumberAtLocation(stringLoc + 4, mData);
            int byteStart = stringLoc + 6;
            int byteEnd = stringLoc + sz -1;
            char current = '\0';
            for (int i = byteStart; i < byteEnd; i += 2)
            {
                current = (char)BinUtils.Get2ByteNumberAtLocation(i, mData);
                if (current != '\0')
                    sb.Append(current);
            }
            return stringLoc;
        }
public int GetString ( UInt32 hashId , StringBuilder sb ) { int stringLoc = ( int ) BodyStart ; int occurance = 0 ; int target_occurance = 1 ; if ( mStringSet2 != null && mStringSet2 . ContainsKey ( hashId ) ) target_occurance ++ ; UInt32 currentHash = 0 ; while ( true ) { currentHash = BinUtils . GetNumberAtLocation ( stringLoc , mData ) ; if ( currentHash == hashId ) { occurance ++ ; if ( occurance == target_occurance ) break ; } stringLoc = NextStringLoc ( stringLoc ) ; if ( stringLoc + 10 > mData . Count ) return - 1 ; } UInt16 sz = BinUtils . Get2ByteNumberAtLocation ( stringLoc + 4 , mData ) ; int byteStart = stringLoc + 6 ; int byteEnd = stringLoc + sz - 1 ; char current = ' \0 ' ; for ( int i = byteStart ; i < byteEnd ; i += 2 ) { current = ( char ) BinUtils . Get2ByteNumberAtLocation ( i , mData ) ; if ( current != ' \0 ' ) sb . Append ( current ) ; } return stringLoc ; }
Places the string with the given hashid into the stringbuilder passed in.
Places the string with the given hashid into the stringbuilder passed in .
The location of the string id, -1 if not found
The location of the string id - 1 if not found
hashId
UInt32
None
sb
StringBuilder
string will be added to the builder
string will be added to the builder