mirror of
https://github.com/siemens-mobile-hacks/libffshit.git
synced 2026-11-25 23:57:31 +00:00
SGOLD keeps a name in the 8-bit codepage of the phone's language when the codepage has all of its characters, and else as 0x1F followed by the name in UTF-8, which is what the emulated CX70 v56 stored for names sent over OBEX. Filesystem::Base::set_codepage() picks the codepage, CP1252 by default: CP1251 for Cyrillic languages, CP1250 for Central European ones. The SGOLD reader decodes names with it instead of returning the bytes, and the writer encodes them the way the firmware does, so names beyond ASCII can be written. The firmware folds the case of ASCII letters only and hashes the stored bytes, 0x1F included. A name in another codepage than the phone's is listed by the phone, but it cannot open it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MhNPkhMCs197RC4AQ3Nfgs
59 lines
3 KiB
C++
59 lines
3 KiB
C++
#include <ffshit/filesystem/hash.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
using FULLFLASH::Filesystem::name_hash_utf16;
|
|
using FULLFLASH::Filesystem::name_hash_8bit;
|
|
|
|
// The hashes the phones keep next to these names in their directories: of the S75 v40 and the
|
|
// EL71 v41 for UTF-16 names, of the CX70 v56 and the SL65 v49 for 8-bit names. The uploads are
|
|
// what the emulated phones stored for files sent to them over OBEX.
|
|
|
|
TEST(NameHashTest, HashesUtf16NamesLikeTheNewSgoldFirmware) {
|
|
EXPECT_EQ(name_hash_utf16(u"Misc"), 0xCA77);
|
|
EXPECT_EQ(name_hash_utf16(u"Pictures"), 0x805A);
|
|
EXPECT_EQ(name_hash_utf16(u"00"), 0xBF4C);
|
|
EXPECT_EQ(name_hash_utf16(u"09"), 0x3F55);
|
|
EXPECT_EQ(name_hash_utf16(u"Marble Madness.jad"), 0xC26A);
|
|
EXPECT_EQ(name_hash_utf16(u"Siemens wallpaper.jpg"), 0x107F);
|
|
EXPECT_EQ(name_hash_utf16(u"small.bin"), 0xBB37);
|
|
EXPECT_EQ(name_hash_utf16(u"big.bin"), 0x3D00);
|
|
EXPECT_EQ(name_hash_utf16(u"newdir"), 0x6273);
|
|
}
|
|
|
|
TEST(NameHashTest, FoldsTheCaseOfUtf16Names) {
|
|
EXPECT_EQ(name_hash_utf16(u"tmp"), 0x8445);
|
|
EXPECT_EQ(name_hash_utf16(u"Tmp"), 0x8445);
|
|
EXPECT_EQ(name_hash_utf16(u"Аркады"), 0xAEE9);
|
|
EXPECT_EQ(name_hash_utf16(u"аркады"), 0xAEE9);
|
|
EXPECT_EQ(name_hash_utf16(u"Логические"), 0xD999);
|
|
EXPECT_EQ(name_hash_utf16(u"призрак.mid"), 0x693A);
|
|
EXPECT_EQ(name_hash_utf16(u"будильник.mp3"), 0xAF7F);
|
|
}
|
|
|
|
TEST(NameHashTest, HashesEightBitNamesLikeTheSgoldFirmware) {
|
|
EXPECT_EQ(name_hash_8bit("Misc"), 0x14B8);
|
|
EXPECT_EQ(name_hash_8bit("Voice memo"), 0xE07B);
|
|
EXPECT_EQ(name_hash_8bit("main"), 0x9E63);
|
|
EXPECT_EQ(name_hash_8bit("Cfg"), 0x52A9);
|
|
EXPECT_EQ(name_hash_8bit("default.cfg"), 0xB2BA);
|
|
EXPECT_EQ(name_hash_8bit("s100.bin"), 0x6C06);
|
|
EXPECT_EQ(name_hash_8bit("s2200.bin"), 0xABDE);
|
|
}
|
|
|
|
// As the emulated CX70 v56 stored names made over OBEX: in its codepage, CP1252, and else as 0x1F
|
|
// and the name in UTF-8. The hash is of the stored bytes.
|
|
TEST(NameHashTest, HashesEightBitNamesAsTheyAreStored) {
|
|
EXPECT_EQ(name_hash_8bit("\xC4rger"), 0x98DC);
|
|
EXPECT_EQ(name_hash_8bit("\xE4rger"), 0xA456);
|
|
EXPECT_EQ(name_hash_8bit("a\xE9\x80"), 0x9462);
|
|
EXPECT_EQ(name_hash_8bit("\x1F" "Файл"), 0x3152);
|
|
EXPECT_EQ(name_hash_8bit("\x1F" "файл"), 0x92E3);
|
|
EXPECT_EQ(name_hash_8bit("\x1F" "Ωμέγα"), 0x6F37);
|
|
EXPECT_EQ(name_hash_8bit("\x1F" "中文"), 0x35D3);
|
|
}
|
|
|
|
TEST(NameHashTest, FoldsTheCaseOfEightBitNames) {
|
|
EXPECT_EQ(name_hash_8bit("MISC"), name_hash_8bit("misc"));
|
|
EXPECT_EQ(name_hash_8bit("Misc"), name_hash_8bit("mIsC"));
|
|
}
|