20.06.2015, 15:37
|
#19
|
Antihero
Регистрация: 03.04.2010
Адрес: Virtual Reality
Сообщений: 2,455
Отблагодарили 1,098 раз(а)
|
Re: Gw2
Флаг файла -> расширение.
Свернуть ↑
Код:
wxFileName FileCategorizer::Categorize(const wxString& pOutPath, ANetFileType pFileType, uint pFileId, const byte* pData, uint pSize)
{
wxFileName fileName(pOutPath, wxT(""));
// Textures
if (pFileType > ANFT_TextureStart && pFileType < ANFT_TextureEnd) {
fileName.AppendDir(wxT("Textures"));
switch (pFileType) {
case ANFT_ATEX:
fileName.AppendDir(wxT("Generic textures"));
fileName.SetFullName(wxString::Format(wxT("%d.atex"), pFileId));
break;
case ANFT_ATTX:
fileName.AppendDir(wxT("Terrain textures"));
fileName.SetFullName(wxString::Format(wxT("%d.attx"), pFileId));
break;
case ANFT_ATEC:
fileName.AppendDir(wxT("ATEC"));
fileName.SetFullName(wxString::Format(wxT("%d.atec"), pFileId));
break;
case ANFT_ATEP:
fileName.AppendDir(wxT("Map textures"));
fileName.SetFullName(wxString::Format(wxT("%d.atep"), pFileId));
break;
case ANFT_ATEU:
fileName.AppendDir(wxT("UI textures"));
fileName.SetFullName(wxString::Format(wxT("%d.ateu"), pFileId));
break;
case ANFT_ATET:
fileName.AppendDir(wxT("ATET"));
fileName.SetFullName(wxString::Format(wxT("%d.atet"), pFileId));
break;
case ANFT_DDS:
fileName.AppendDir(wxT("DDS"));
fileName.SetFullName(wxString::Format(wxT("%d.dds"), pFileId));
break;
}
if (pFileType != ANFT_DDS && pSize >= 12) {
uint16 width = *(const uint16*)(pData + 0x8);
uint16 height = *(const uint16*)(pData + 0xa);
fileName.AppendDir(wxString::Format(wxT("%dx%d"), width, height));
} else if (pSize >= 20) {
uint32 width = *(const uint32*)(pData + 0x10);
uint32 height = *(const uint32*)(pData + 0x0c);
fileName.AppendDir(wxString::Format(wxT("%dx%d"), width, height));
}
}
// Sounds
else if (pFileType == ANFT_MP3 || pFileType == ANFT_OGG || pFileType == ANFT_Sound) {
fileName.AppendDir(wxT("Sounds"));
if (pFileType == ANFT_MP3) {
fileName.SetFullName(wxString::Format(wxT("%d.mp3"), pFileId));
} else if (pFileType == ANFT_OGG) {
fileName.SetFullName(wxString::Format(wxT("%d.ogg"), pFileId));
} else {
fileName.SetFullName(wxString::Format(wxT("%d.asnd"), pFileId));
}
}
// Binaries
else if (pFileType == ANFT_Binary || pFileType == ANFT_EXE || pFileType == ANFT_DLL) {
fileName.AppendDir(wxT("Binaries"));
if (pFileType == ANFT_EXE) {
fileName.SetFullName(wxString::Format(wxT("%d.exe"), pFileId));
} else if (pFileType == ANFT_DLL) {
fileName.SetFullName(wxString::Format(wxT("%d.dll"), pFileId));
} else {
fileName.SetFullName(wxString::Format(wxT("%d"), pFileId));
}
}
// Strings
else if (pFileType == ANFT_StringFile) {
fileName.AppendDir(wxT("Strings"));
if (pSize > 1) {
switch (pData[pSize-2]) {
case 0:
fileName.AppendDir(wxT("English"));
break;
case 1:
fileName.AppendDir(wxT("Korean"));
break;
case 2:
fileName.AppendDir(wxT("French"));
break;
case 3:
fileName.AppendDir(wxT("German"));
break;
case 4:
fileName.AppendDir(wxT("Spanish"));
break;
}
}
fileName.SetFullName(wxString::Format(wxT("%d.strs"), pFileId));
}
// Manifests
else if (pFileType == ANFT_Manifest) {
fileName.AppendDir(wxT("Manifests"));
fileName.SetFullName(wxString::Format(wxT("%d.armf"), pFileId));
}
// Bank files
else if (pFileType == ANFT_Bank) {
fileName.AppendDir(wxT("Banks"));
fileName.SetFullName(wxString::Format(wxT("%d.abnk"), pFileId));
}
// Model files
else if (pFileType == ANFT_Model) {
fileName.AppendDir(wxT("Models"));
fileName.SetFullName(wxString::Format(wxT("%d.modl"), pFileId));
}
// Dependency table
else if (pFileType == ANFT_DependencyTable) {
fileName.AppendDir(wxT("Dependency tables"));
fileName.SetFullName(wxString::Format(wxT("%d.deps"), pFileId));
}
// EULA
else if (pFileType == ANFT_EULA) {
fileName.AppendDir(wxT("EULA"));
fileName.SetFullName(wxString::Format(wxT("%d.eula"), pFileId));
}
// Cinematic
else if (pFileType == ANFT_Cinematic) {
fileName.AppendDir(wxT("Cinematics"));
fileName.SetFullName(wxString::Format(wxT("%d.cinp"), pFileId));
}
// Havok
else if (pFileType == ANFT_HavokCloth) {
fileName.AppendDir(wxT("Havok cloth"));
fileName.SetFullName(wxString::Format(wxT("%d.hvkc"), pFileId));
}
// Maps
else if (pFileType == ANFT_Map) {
fileName.AppendDir(wxT("Maps"));
fileName.SetFullName(wxString::Format(wxT("%d.mapc"), pFileId));
}
// Materials
else if (pFileType == ANFT_Material) {
fileName.AppendDir(wxT("Materials"));
fileName.SetFullName(wxString::Format(wxT("%d.amat"), pFileId));
}
// Random PF files
else if (pFileType == ANFT_PF) {
fileName.AppendDir(wxT("Misc"));
if (pSize >= 12) {
wxString type = wxString((const char*)(pData + 8), 4);
fileName.AppendDir(type);
fileName.SetFullName(wxString::Format(wxT("%d.%s"), pFileId, type.Lower()));
} else {
fileName.SetFullName(wxString::Format(wxT("%d"), pFileId));
}
}
// ABFF
else if (pFileType == ANFT_ABFF) {
fileName.AppendDir(wxT("Misc"));
fileName.AppendDir(wxT("ABFF"));
fileName.SetFullName(wxString::Format(wxT("%d.abff"), pFileId));
}
// unknown stuff
else {
fileName.AppendDir(wxT("Unknown"));
fileName.AppendDir(wxString::Format(wxT("%x"), *(const uint32*)pData));
fileName.SetFullName(wxString::Format(wxT("%d"), pFileId));
}
return fileName;
}
Свернуть ↑Развернуть ↓
Определение самого флага.
Свернуть ↑
Код:
ANetFileType Gw2Dat::IdentifyFileType(const byte* pBuffer, uint pSize) const
{
if (pSize < 4) { return ANFT_Unknown; }
// start with fourcc
uint32 fourcc = *(uint32*)pBuffer;
ANetFileType fileType = ANFT_Unknown;
// abff files need offsetting
if (fourcc == 0x66666261 && pSize >= 0x40) {
pBuffer += 0x40;
pSize -= 0x40;
fileType = ANFT_ABFF;
if (pSize >= 4) {
fourcc = *(uint32*)pBuffer;
}
}
switch (fourcc) {
case 0x58455441:
fileType = ANFT_ATEX;
break;
case 0x58545441:
fileType = ANFT_ATTX;
break;
case 0x43455441:
fileType = ANFT_ATEC;
break;
case 0x50455441:
fileType = ANFT_ATEP;
break;
case 0x55455441:
fileType = ANFT_ATEU;
break;
case 0x54455441:
fileType = ANFT_ATET;
break;
case 0x20534444:
fileType = ANFT_DDS;
break;
case 0x73727473:
fileType = ANFT_StringFile;
break;
case 0x646e7361:
fileType = ANFT_Sound;
break;
case 0x504e4943:
fileType = ANFT_Cinematic;
break;
}
// Identify binary files
if ((fourcc & 0xffff) == 0x5a4d) {
fileType = ANFT_Binary;
if (pSize >= 0x40) {
uint32 peOffset = *(uint32*)(pBuffer + 0x3c);
if (pSize >= (peOffset + 0x18)) {
uint16 flags = *(uint16*)(pBuffer + peOffset + 0x16);
fileType = (flags & 0x2000) ? ANFT_DLL : ANFT_EXE;
}
}
}
// Identify PF files
if ((fourcc & 0xffff) == 0x4650) {
fourcc = *(uint32*)(pBuffer + 8);
fileType = ANFT_PF;
switch (fourcc) {
case 0x464d5241:
fileType = ANFT_Manifest;
break;
case 0x444e5341:
fileType = ANFT_Sound;
break;
case 0x4b4e4241:
fileType = ANFT_Bank;
break;
case 0x4c444f4d:
fileType = ANFT_Model;
break;
case 0x53504544:
fileType = ANFT_DependencyTable;
break;
case 0x616c7565:
fileType = ANFT_EULA;
break;
case 0x436b7668:
fileType = ANFT_HavokCloth;
break;
case 0x6370616d:
fileType = ANFT_Map;
break;
case 0x54414d41:
fileType = ANFT_Material;
break;
}
}
// Identify sounds
if (fileType == ANFT_Sound || fileType == ANFT_Bank) {
const uint16 PF = 0x4650;
const uint32 asnd = 0x646e7361;
const uint32 ASND = 0x444e5341;
const uint32 ABNK = 0x4b4e4241;
const uint32 OggS = 0x5367674f;
if (pSize >= 12) {
if (*(uint32*)pBuffer == asnd && pSize >= 40) {
fileType = (*(uint32*)(pBuffer + 36) == OggS) ? ANFT_OGG : ANFT_MP3;
} else if (*(uint16*)pBuffer == PF && *(uint32*)(pBuffer + 8) == ASND && pSize >= 96) {
fileType = (*(uint32*)(pBuffer + 92) == OggS) ? ANFT_OGG : ANFT_MP3;
} else if (fileType == ANFT_Bank && pSize >= 592) {
fileType = (*(uint32*)(pBuffer + 588) == OggS) ? ANFT_OGG : ANFT_MP3;
}
}
}
return fileType;
}
Свернуть ↑Развернуть ↓
__________________
m0nster.art - clear client patches, linkz to utils & code.
Гадаю по капче.
|
|
|