Example #1
0
Int32 WINAPI MylstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
{
    Int32  ret, bOgg;
    UInt32 Length, tag;
    Char   szFileName[MAX_PATH];

    ret = StrICompareA(lpString1, lpString2);
    if (!ret)
        return ret;

    Length = StrLengthA(lpString2);
    if (Length < 4 && Length != StrLengthA(lpString1))
        return ret;

    bOgg = False;
    Length -= 3;
    switch ((*(PUInt32)&lpString2[Length] & 0xDFDFDF))
    {
        case TAG3('EPA'):
            tag = TAG3('uci');
            break;

        case TAG3('OGG'):
            bOgg = True;
            tag = TAG3('m4a');
            break;

        case TAG3('WAV'):
            tag = TAG3('ogg');
            break;

        default:
            return ret;
    }

    MYAPI(lstrcpyA)(szFileName, lpString2);
    *(PUInt32)&szFileName[Length] = tag;

    ret = StrICompareA(lpString1, szFileName);
    if (ret && bOgg)
    {
        *(PUInt32)&szFileName[Length] = TAG3('uca');
        ret = StrICompareA(lpString1, szFileName);
    }

    return ret;
}
Example #2
0
BOOL FASTCALL GetIniString(ALICE_INI_INFO *pIniInfo, PVOID, STL_STRINGA *pString)
{
    BOOL Result;
    LONG Type;
    WCHAR szPath[MAX_PATH];
    bool (FASTCALL *pfGetIniString)(PVOID pIniInfo, PVOID, STL_STRINGA *pString);
    enum { INI_TYPE_FACE, INI_TYPE_FONT };

    static CHAR szFaceName[] = "FaceName";
    static CHAR szFontName[] = "FontName";

    *(PVOID *)&pfGetIniString = (PVOID)0x42CA40;

    LOOP_ALWAYS
    {
        Result = pfGetIniString(pIniInfo, 0, pString);
        if (!Result)
            return Result;

        if (pString->Length == sizeof(szFaceName) - 1 &&
            !StrICompareA(pString->GetBuffer(), szFaceName))
        {
            Type = INI_TYPE_FACE;
        }
        else if (pString->Length == sizeof(szFontName) - 1 &&
            !StrICompareA(pString->GetBuffer(), szFontName))
        {
            Type = INI_TYPE_FONT;
        }
        else
        {
            return TRUE;
        }

        LOOP_ONCE
        {
            if (!pfGetIniString(pIniInfo, 0, pString) || *pString->GetBuffer() != '=')
                break;

            if (!pfGetIniString(pIniInfo, 0, pString) || pString->Length == 0)
                break;

            switch (Type)
            {
                case INI_TYPE_FACE:
                    MultiByteToWideChar(
                        CP_ACP,
                        0,
                        pString->GetBuffer(),
                        -1,
                        g_szFaceName,
                        countof(g_szFaceName));
                    break;

                case INI_TYPE_FONT:
                    MultiByteToWideChar(
                        CP_ACP,
                        0,
                        pString->GetBuffer(),
                        -1,
                        szPath,
                        countof(szPath));

                    if (AddFontResourceExW(szPath, FR_PRIVATE, NULL) == 0)
                        break;

                    GetFontNameFromFile(szPath, g_szFaceName, countof(g_szFaceName));
                    break;
            }
        }
    }
}
Example #3
0
PByte CDECL DecodeImage(PByte pbImage, PUInt32 puWidth, PUInt32 puHeight, PUInt32 puBitPerPixel)
{
    Int32  uWidth, uHeight, uBpp, uStride, uStrideRaw, Size;
    PByte  pbDecode, pbDest, pbSrc;

#if defined(USE_CACHE)
    Char   szFullPath[MAX_PATH];
    PChar  name, fmt, path, dir;
    SCacheIndex *pCache;

    __asm
    {
        mov name, ebx;
    }
#endif

    do
    {
        if ((*(PUInt32)pbImage & 0xFFFFFF) != TAG3('UCI'))
            break;

#if defined(USE_CACHE)

        __asm
        {
            mov fmt, 0x45B6D8;
            mov path, 0x4EF150;
            mov eax, 0x46335C;
            mov eax, [eax];
            mov dir, eax;
        }

        ++g_UCIReadCount;
        MYAPI(wsprintfA)(szFullPath, fmt, path, dir, name);
        pCache = g_ImageCache.Find(szFullPath);
        if (pCache->pbBuffer && !StrICompareA(pCache->FileName, szFullPath))
        {
            ++g_CacheHitCount;
            pbImage = (PByte)MYAPI(GlobalAlloc)(GPTR, pCache->Size);
            if (pbImage == NULL)
            {
                goto DEFAULT_PROC;
            }

            CopyMemory(pbImage, pCache->pbBuffer, pCache->Size);
            if (puWidth       != NULL) *puWidth = pCache->Width;
            if (puHeight      != NULL) *puHeight = pCache->Height;
            if (puBitPerPixel != NULL) *puBitPerPixel = pCache->BitPerPixel;

            return pbImage;
        }

#endif

        if (MYAPI(UCIDecode)(pbImage, INT_MAX, (LPVoid *)&pbDecode, &uStrideRaw, &uWidth, &uHeight, &uBpp) < 0)
            break;

        Size = uHeight * uWidth * 4;
        pbImage = (PByte)MYAPI(GlobalAlloc)(GPTR, Size);
        if (pbImage == NULL)
        {
        	MYAPI(UCIFree)(pbDecode);
            break;
        }

//        uStride = (uWidth * uBpp / 8 + 3) & ~3;
        pbSrc  = pbDecode;
        pbDest = pbImage;

        if (puWidth)       *puWidth = uWidth;
        if (puHeight)      *puHeight = uHeight;
        if (puBitPerPixel) *puBitPerPixel = uBpp;

        if (uBpp == 32)
        {
            ULONG Stride = uWidth * 4;
            for (ULONG Height = uHeight; Height; --Height)
            {
                CopyMemory(pbDest, pbSrc, Stride);
                pbDest += Stride;
                pbSrc  += uStrideRaw;
            }
        }
        else
        {
            for (Int32 h = uHeight; h--; )
            {
                PByte src = pbSrc;
                for (Int32 w = 0; w != uWidth; ++w)
                {
                    *(PUInt32)pbDest = *(PUInt32)src | 0xFF000000;
                    pbDest += 4;
                    src += 3;
                }
                pbSrc += uStrideRaw;
            }
        }

        MYAPI(UCIFree)(pbDecode);

#if defined(USE_CACHE)
        if (pCache->pbBuffer == NULL)
            ++g_CacheCount;
        g_ImageCache.Add(pCache, pbImage, Size, uWidth, uHeight, uBpp, szFullPath);
#endif

        return pbImage;

    } while (0);

DEFAULT_PROC:

    F_DecodeImage OldDecodeImage = (F_DecodeImage)0x42E120;
    return OldDecodeImage(pbImage, puWidth, puHeight, puBitPerPixel);
}
Example #4
0
Bool CSharu::Open(PCWChar pszFileName)
{
    ReleaseAll();

    if (file.Open(pszFileName) == False)
        return False;

    Bool ret;
    UInt32 Version, Key;
    SPackHeader header;
    SPackHashTableHeader *pHashTable;
    static Char Seed[] = "8hr48uky,8ugi8ewra4g8d5vbf5hb5s6";

    UNREFERENCED_PARAMETER(pHashTable);

    if (file.Seek(file.FILE_SEEK_END, -(Long)sizeof(header)) == False)
        return False;

    if (file.Read(&header, sizeof(header)) == False)
        return False;

    Version = *(PUInt32)&header.tag[11];
    if (Version > TAG3('3.0') || Version < TAG3('1.0'))
        return False;

    header.tag[11] = 0;
    if (StrICompareA(header.tag, "FilePackVer"))
        return False;

    Key = Hash(header.Data, sizeof(header.Data)) & 0x0FFFFFFF;
    Decrypt(header.Seed, sizeof(header.Seed), Key);

    if (Version == TAG3('3.0') && memcmp(header.Seed, Seed, sizeof(header.Seed)))
        return False;

    // what the f**k is it

#if 0
    pHashTable = (SPackHashTableHeader *)Alloc(header.HashTableSize);
    if (pHashTable == NULL)
        return False;

    if (file.Seek(file.FILE_SEEK_END, -(Long)(sizeof(header) + header.HashTableSize)) == False)
        return False;

    if (file.Read(pHashTable, header.HashTableSize) == False)
        return False;

    Version = *(PUInt32)&pHashTable->HashVer[7];

    do
    {
        ret = False;
        if (Version < TAG3('1.2') || Version > TAG3('1.3'))
            break;

        pHashTable->HashVer[7] = 0;
        if (lstrcmpiA(pHashTable->HashVer, "HashVer") || pHashTable->SubTableNum != 0x100)
            break;

        Decrypt(&pHashTable->Data, pHashTable->CompressedSize, 0x428);

        UInt32 DecompressSize;
        LPVoid lpDecrypted = Alloc(pHashTable->Data.DecompressSize);
        if (lpDecrypted == NULL)
            break;

        DecompressSize = Uncompress(&pHashTable->Data, pHashTable->CompressedSize, lpDecrypted);

        CFileDisk f;
        if (f.Open(L"K:\\galgame\\¥×¥ê¥ó¥»¥¹¥é¥Ð©`!\\GameData\\test.bin", f.W, f.N))
        {
            f.Write(pHashTable, sizeof(*pHashTable) - sizeof(pHashTable->Data));
            f.Write(lpDecrypted, DecompressSize);
        }

        Free(lpDecrypted);

    } while (0);

    Free(pHashTable);
    return False;
#endif

    if (Version == TAG3('1.0'))
        Key = 0xC4;

    ret = InitIndex(&header, Key);

    return ret;
}