├── .gitignore ├── LICENSE.txt ├── README.md ├── brightmoon ├── Makefile ├── arctmp.hpp ├── bitreader.hpp ├── brightmoon.vcxproj ├── brightmoon.vcxproj.filters ├── frandre.cpp ├── frandre.hpp ├── hinanawi.cpp ├── hinanawi.hpp ├── kaguya.cpp ├── kaguya.hpp ├── kanako.cpp ├── kanako.hpp ├── limit.hpp ├── mainwnd.cpp ├── mima.cpp ├── mima.hpp ├── mt.hpp ├── pathext.cpp ├── pathext.hpp ├── pbgarc.hpp ├── pbgmgr.cpp ├── pbgmgr.rc ├── pbgmgr.xml ├── resource.h ├── stdint.h ├── suica.cpp ├── suica.hpp ├── thcrypter.cpp ├── unerle.cpp ├── unlzss.cpp ├── vivit.cpp ├── vivit.hpp ├── xor.hpp ├── yumemi.cpp ├── yumemi.hpp ├── yumemicrypt.hpp ├── yuyuko.cpp └── yuyuko.hpp ├── convcv0 ├── ReadMe.txt ├── convcv0.cpp ├── convcv0.vcxproj ├── convcv0.vcxproj.filters ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── convcv1 ├── ReadMe.txt ├── convcv1.cpp ├── convcv1.vcxproj ├── convcv1.vcxproj.filters ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── convcv2 ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── convcv2.csproj ├── cv0conv ├── ReadMe.txt ├── cv0conv.cpp ├── cv0conv.vcxproj ├── cv0conv.vcxproj.filters ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── cv1conv ├── ReadMe.txt ├── cv1conv.cpp ├── cv1conv.vcxproj ├── cv1conv.vcxproj.filters ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── cv2conv ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── cv2conv.csproj ├── darkmoon ├── darkmoon.cpp ├── darkmoon.vcxproj ├── darkmoon.vcxproj.filters ├── mt.hpp ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── istring ├── ReadMe.txt ├── istring.cpp ├── istring.vcxproj ├── istring.vcxproj.filters ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── strings ├── ReadMe.txt ├── stdafx.cpp ├── stdafx.h ├── strings.cpp ├── strings.vcxproj ├── strings.vcxproj.filters └── targetver.h └── th123_toolkit.sln /.gitignore: -------------------------------------------------------------------------------- 1 | #ignore thumbnails created by windows 2 | Thumbs.db 3 | #Ignore files build by Visual Studio 4 | *.obj 5 | *.exe 6 | *.pdb 7 | *.user 8 | *.aps 9 | *.pch 10 | *.vspscc 11 | *_i.c 12 | *_p.c 13 | *.ncb 14 | *.suo 15 | *.tlb 16 | *.tlh 17 | *.bak 18 | *.cache 19 | *.ilk 20 | *.log 21 | [Bb]in 22 | [Dd]ebug*/ 23 | *.lib 24 | *.sbr 25 | obj/ 26 | [Rr]elease*/ 27 | _ReSharper*/ 28 | [Tt]est[Rr]esult* 29 | /ipch 30 | *.swp 31 | *.sdf 32 | *.opensdf 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | I wrote these tools to help in translating th123 into Chinese, some of these tools (brightmoon/cv2conv/convcv2) are borrowed from the internet. 2 | 3 | brightmoon 4 | ========== 5 | 6 | Extract file(cv0/1/2) from dat pack 7 | 8 | darkmoon 9 | ======== 10 | 11 | Pack data files (cv0/1/2) back to dat pack 12 | 13 | cv0conv 14 | ======= 15 | 16 | Convert cv0 to readable txt 17 | 18 | convcv0 19 | ======= 20 | 21 | Convert txt back to cv0 22 | 23 | cv1conv 24 | ======= 25 | 26 | Convert cv1 to readable txt 27 | 28 | convcv1 29 | ======= 30 | 31 | Convert txt back to cv1 32 | 33 | cv2conv 34 | ======= 35 | 36 | Convert cv2 to picture 37 | 38 | convcv2 39 | ======= 40 | 41 | Convert picture to cv2 42 | 43 | strings 44 | ======= 45 | 46 | Find/Extract shift_jis string inside exe 47 | 48 | istring 49 | ======= 50 | 51 | Replace strings inside exe 52 | 53 | -------------------------------------------------------------------------------- /brightmoon/Makefile: -------------------------------------------------------------------------------- 1 | SRCS := frandre.cpp kaguya.cpp kanako.cpp mainwnd.cpp pbgmgr.cpp \ 2 | thcrypter.cpp unlzss.cpp yuyuko.cpp vivit.cpp hinanawi.cpp \ 3 | suica.cpp mima.cpp yumemi.cpp unerle.cpp pathext.cpp 4 | RESRCS := pbgmgr.rc 5 | 6 | OBJS := $(SRCS:%.cpp=%.o) $(RESRCS:%.rc=%.res) 7 | LIBS := -lcomctl32 -lcomdlg32 -lshlwapi -lole32 -limagehlp -lboost_filesystem-gcc-mt-s-1_33_1 8 | 9 | CXX := g++ 10 | RM := rm 11 | DRES := windres 12 | 13 | CXXFLAGS := -O3 -Os -s -mno-cygwin -Wno-deprecated -D_WIN32_IE=0x600 14 | LDFLAGS := -O3 -Os -s -mno-cygwin 15 | # CXXFLAGS := -g -mno-cygwin -Wno-deprecated -D_WIN32_IE=0x600 16 | # LDFLAGS := -g -mno-cygwin -Wl,-Map,brightmoon.map 17 | 18 | all: brightmoon.exe 19 | 20 | brightmoon.exe: ${OBJS} 21 | ${CXX} -o $@ ${OBJS} -mwindows ${LDFLAGS} ${LIBS} 22 | 23 | %.res: %.rc 24 | ${DRES} -O coff $< $@ 25 | 26 | %.o: %.cpp 27 | ${CXX} -c -o $@ $< ${CXXFLAGS} 28 | 29 | dep: 30 | ${CXX} -MM -MG ${SRCS} > Makefile.dep 31 | ${CXX} -MM -MG ${RESRCS} >> Makefile.dep 32 | 33 | clean: 34 | ${RM} ${OBJS} 35 | 36 | -include Makefile.dep 37 | -------------------------------------------------------------------------------- /brightmoon/arctmp.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ARCTMP_HPP 2 | #define ARCTMP_HPP 3 | 4 | #include 5 | #include "pbgarc.hpp" 6 | 7 | template 8 | class PBGArchiveTemplate : public PBGArchive, public Impl 9 | { 10 | //friend class PBGArchiveTemplate::Entry; 11 | private: 12 | typedef std::list EntryList; 13 | typedef typename EntryList::iterator EntryIterator; 14 | 15 | public: 16 | class Entry : public PBGArchiveEntry 17 | { 18 | friend class PBGArchiveTemplate; 19 | private: 20 | typedef PBGArchiveTemplate _Parent; 21 | typedef typename _Parent::EntryIterator _EntryIterator; 22 | 23 | private: 24 | _EntryIterator it; 25 | _Parent *parent; 26 | 27 | private: 28 | Entry(_Parent *p, _EntryIterator &vi) { 29 | parent = p; 30 | it = vi; 31 | } 32 | 33 | public: 34 | Entry() : parent(NULL), it() {} 35 | Entry(const Entry &orig) { 36 | parent = orig.parent; 37 | it = orig.it; 38 | } 39 | 40 | public: 41 | uint32_t GetOriginalSize() { 42 | return it->GetOriginalSize(); 43 | } 44 | 45 | uint32_t GetCompressedSize() { 46 | return it->GetCompressedSize(); 47 | } 48 | 49 | const char * GetEntryName() { 50 | return it->GetEntryName(); 51 | } 52 | 53 | bool Extract(std::ostream &os, bool (*callback)(const char *, void *), void * user) { 54 | return parent->Extract(it, os, callback, user); 55 | } 56 | }; 57 | 58 | public: 59 | PBGArchiveTemplate() : Impl() {} 60 | virtual ~PBGArchiveTemplate() {} 61 | 62 | public: 63 | virtual bool Open(const char * filename) { 64 | return Impl::Open(filename, m_entries); 65 | } 66 | 67 | virtual bool EnumFirst() { 68 | m_entry = m_entries.begin(); 69 | return m_entry != m_entries.end(); 70 | } 71 | 72 | virtual bool EnumNext() { 73 | return m_entry != m_entries.end() && 74 | ++m_entry != m_entries.end(); 75 | } 76 | virtual const char * GetEntryName() { 77 | return m_entry->GetEntryName(); 78 | } 79 | 80 | virtual uint32_t GetOriginalSize() { 81 | return m_entry->GetOriginalSize(); 82 | } 83 | 84 | virtual uint32_t GetCompressedSize() { 85 | return m_entry->GetCompressedSize(); 86 | } 87 | 88 | virtual struct PBGArchiveEntry * GetEntry() { 89 | return new Entry(this, m_entry); 90 | } 91 | 92 | virtual bool Extract(std::ostream &os, bool (*callback)(const char *, void *), void * user) { 93 | return Extract(m_entry, os, callback, user); 94 | } 95 | 96 | virtual bool ExtractAll(bool (*callback)(const char *, void *), void * user) { 97 | return false; 98 | } 99 | 100 | private: 101 | bool Extract(EntryIterator &entry, std::ostream &os, bool (*callback)(const char *, void *), void * user) { 102 | return Impl::Extract(entry, os, callback, user); 103 | } 104 | 105 | private: 106 | EntryList m_entries; 107 | EntryIterator m_entry; 108 | }; 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /brightmoon/bitreader.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BITREADER_HPP 2 | #define BITREADER_HPP 3 | 4 | #ifndef min 5 | #define min(x, y) ((x) < (y) ? (x) : (y)) 6 | #endif 7 | 8 | class BitReader 9 | { 10 | private: 11 | unsigned char m_cbuf; 12 | unsigned char m_mask; 13 | std::istream *m_stream; 14 | 15 | public: 16 | BitReader(std::istream &stream) : 17 | m_stream(&stream), m_cbuf(0), m_mask(0x80) {} 18 | 19 | void Attach(std::istream &stream) 20 | { 21 | this->m_stream = &stream; 22 | this->m_cbuf = 0; 23 | this->m_mask = 0x80; 24 | } 25 | 26 | int Read(int nBits) 27 | { 28 | int nResult = 0; 29 | for(unsigned int nDestBit = 1 << (nBits - 1); nDestBit; nDestBit >>= 1) { 30 | if(this->m_mask == 0x80) { 31 | m_stream->read((char *)&this->m_cbuf, 1); 32 | if(m_stream->eof()) this->m_cbuf = 0; 33 | } 34 | if(this->m_cbuf & this->m_mask) nResult |= nDestBit; 35 | this->m_mask >>= 1; 36 | if(!this->m_mask) this->m_mask = 0x80; 37 | } 38 | return nResult; 39 | } 40 | 41 | int ReadL(int nBits) { 42 | int nResult = 0; 43 | for(int i = 0; nBits > 0; ++i, nBits -= 8) { 44 | nResult |= Read(min(8, nBits)) << (i * 8); 45 | } 46 | return nResult; 47 | } 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /brightmoon/brightmoon.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {424D04A8-7059-4F80-8167-8894FFB0FB77} 15 | brightmoon 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | NotSet 22 | true 23 | 24 | 25 | Application 26 | NotSet 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | <_ProjectFileVersion>10.0.30128.1 40 | $(SolutionDir)$(Configuration)\ 41 | $(Configuration)\ 42 | true 43 | $(SolutionDir)$(Configuration)\ 44 | $(Configuration)\ 45 | false 46 | 47 | 48 | 49 | Disabled 50 | E:\boost_1_38_0;%(AdditionalIncludeDirectories) 51 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 52 | true 53 | EnableFastChecks 54 | MultiThreadedDebugDLL 55 | 56 | 57 | Level3 58 | EditAndContinue 59 | 60 | 61 | shlwapi.lib;Dbghelp.lib;comctl32.lib;%(AdditionalDependencies) 62 | true 63 | Windows 64 | MachineX86 65 | 66 | 67 | 68 | 69 | MaxSpeed 70 | true 71 | D:\boost_1_38_0;%(AdditionalIncludeDirectories) 72 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 73 | MultiThreadedDLL 74 | true 75 | 76 | 77 | Level3 78 | ProgramDatabase 79 | 80 | 81 | shlwapi.lib;Dbghelp.lib;comctl32.lib;%(AdditionalDependencies) 82 | true 83 | Windows 84 | true 85 | true 86 | MachineX86 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /brightmoon/brightmoon.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | Source Files 59 | 60 | 61 | Source Files 62 | 63 | 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | Header Files 100 | 101 | 102 | Header Files 103 | 104 | 105 | Header Files 106 | 107 | 108 | Header Files 109 | 110 | 111 | Header Files 112 | 113 | 114 | Header Files 115 | 116 | 117 | Header Files 118 | 119 | 120 | Header Files 121 | 122 | 123 | 124 | 125 | Resource Files 126 | 127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /brightmoon/frandre.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "frandre.hpp" 4 | 5 | extern void unlzss(std::istream &in, std::ostream &out); 6 | 7 | FrandreArchive_Base::FrandreArchive_Base() 8 | { 9 | } 10 | 11 | FrandreArchive_Base::~FrandreArchive_Base() 12 | { 13 | } 14 | 15 | bool FrandreArchive_Base::Open(const char *filename, EntryList &list) 16 | { 17 | m_file.open(filename, std::ios_base::binary); 18 | if(m_file.fail()) return false; 19 | 20 | std::ifstream::pos_type begpos = m_file.tellg(); 21 | m_file.seekg(0, std::ios_base::end); 22 | std::ifstream::pos_type endpos = m_file.tellg(); 23 | m_file.seekg(0, std::ios_base::beg); 24 | std::ifstream::pos_type filesize = endpos - begpos; 25 | BitReader reader(m_file); 26 | int signature = reader.Read(32); 27 | if(signature != 'PBG3') return false; 28 | 29 | uint32_t filecount = ReadPackValue(reader); 30 | uint32_t listoffset = ReadPackValue(reader); 31 | if(listoffset >= filesize) return false; 32 | if(filecount == 0) return false; 33 | 34 | m_file.seekg(listoffset, std::ios_base::beg); 35 | reader.Attach(m_file); 36 | list.clear(); 37 | for(int i = 0; i < filecount; ++i) 38 | { 39 | Entry entry; 40 | ReadPackValue(reader); // ? 41 | ReadPackValue(reader); // ?? 42 | entry.checksum = ReadPackValue(reader); 43 | entry.offset = ReadPackValue(reader); 44 | entry.origsize = ReadPackValue(reader); 45 | ReadCString(reader, entry.name, 0x100); 46 | list.push_back(entry); 47 | } 48 | EntryList::iterator it = list.begin(); 49 | EntryList::iterator next = list.begin(); 50 | for(++next; next != list.end(); ++it, ++next) 51 | { 52 | it->compsize = next->offset - it->offset; 53 | } 54 | it->compsize = listoffset - it->offset; 55 | return true; 56 | } 57 | 58 | bool FrandreArchive_Base::Extract(EntryList::iterator &entry, std::ostream &os, bool (*callback)(const char *, void *), void * user) 59 | { 60 | if(callback) { 61 | if(!callback(entry->GetEntryName(), user)) return false; 62 | if(!callback(" extracting...", user)) return false; 63 | } 64 | m_file.seekg(entry->offset, std::ios_base::beg); 65 | unlzss(m_file, os); 66 | if(m_file.bad()) { 67 | if(callback) { 68 | if(!callback("unexpected error occured.\r\nplease restart.\r\n", user)) return false; 69 | } 70 | return false; 71 | } 72 | if(callback) { 73 | if(!callback("finished.\r\n", user)) return false; 74 | } 75 | return true; 76 | } 77 | 78 | uint32_t FrandreArchive_Base::ReadPackValue(BitReader &reader) 79 | { 80 | int type = reader.Read(2); 81 | return reader.Read((type + 1) * 8); 82 | } 83 | 84 | void FrandreArchive_Base::ReadCString(BitReader &reader, char *str, int max) 85 | { 86 | while(max-- && (*str++ = reader.Read(8))); 87 | } 88 | -------------------------------------------------------------------------------- /brightmoon/frandre.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FRANDRE_HPP 2 | #define FRANDRE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include "stdint.h" 8 | 9 | #include "arctmp.hpp" 10 | #include "bitreader.hpp" 11 | 12 | class FrandreArchive_Base 13 | { 14 | protected: 15 | struct Entry { 16 | uint32_t offset; 17 | uint32_t compsize; 18 | uint32_t origsize; 19 | uint32_t checksum; 20 | char name[0x100]; 21 | 22 | inline uint32_t GetOriginalSize() { return origsize; } 23 | inline uint32_t GetCompressedSize() { return compsize; } 24 | inline const char * GetEntryName() { return name; } 25 | 26 | bool operator==(const char *rhs) { 27 | return std::strcmp(name, rhs) == 0; 28 | } 29 | }; 30 | 31 | typedef std::list EntryList; 32 | 33 | protected: 34 | FrandreArchive_Base(); 35 | virtual ~FrandreArchive_Base(); 36 | 37 | protected: 38 | bool Open(const char *filename, EntryList &list); 39 | bool Extract(EntryList::iterator &it, std::ostream &os, bool (*callback)(const char *, void *), void * user); 40 | 41 | private: 42 | uint32_t ReadPackValue(BitReader &); 43 | void ReadCString(BitReader &, char *string, int max); 44 | 45 | private: 46 | std::ifstream m_file; 47 | }; 48 | 49 | typedef PBGArchiveTemplate FrandreArchive; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /brightmoon/hinanawi.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "hinanawi.hpp" 10 | #include "mt.hpp" 11 | 12 | HinanawiArchive_Base::HinanawiArchive_Base() 13 | { 14 | } 15 | 16 | HinanawiArchive_Base::~HinanawiArchive_Base() 17 | { 18 | } 19 | 20 | bool HinanawiArchive_Base::Open(const char *filename, EntryList &list) 21 | { 22 | m_file.open(filename, std::ios_base::binary); 23 | if(m_file.fail()) return false; 24 | 25 | std::ifstream::pos_type begpos = m_file.tellg(); 26 | m_file.seekg(0, std::ios_base::end); 27 | std::ifstream::pos_type endpos = m_file.tellg(); 28 | m_file.seekg(0, std::ios_base::beg); 29 | std::ifstream::pos_type filesize = endpos - begpos; 30 | if(filesize < 6) return false; 31 | 32 | uint16_t list_count; 33 | m_file.read(reinterpret_cast(&list_count), sizeof(list_count)); 34 | if(m_file.eof() || m_file.fail()) return false; 35 | uint32_t list_size; 36 | m_file.read(reinterpret_cast(&list_size), sizeof(list_size)); 37 | if(m_file.eof() || m_file.fail()) return false; 38 | if(list_count == 0 || list_size == 0) return false; 39 | if(filesize < 6 + list_size) return false; 40 | 41 | boost::scoped_array list_buf(new (std::nothrow) char[list_size]); 42 | if(!list_buf) return false; 43 | 44 | m_file.read(list_buf.get(), list_size); 45 | if(m_file.eof() || m_file.fail()) return false; 46 | 47 | RNG_MT mt(list_size + 6); 48 | for(uint32_t i = 0; i < list_size; ++i) 49 | list_buf[i] ^= mt.next_int32() & 0xFF; 50 | 51 | if(!DeserializeList(list_buf.get(), list_count, list_size, filesize, list)) { 52 | list.clear(); 53 | uint8_t k = 0xC5, t = 0x83; 54 | for(uint32_t i = 0; i < list_size; ++i) { 55 | list_buf[i] ^= k; k += t; t +=0x53; 56 | } 57 | if(!DeserializeList(list_buf.get(), list_count, list_size, filesize, list)) 58 | return false; 59 | } 60 | return true; 61 | } 62 | 63 | bool HinanawiArchive_Base::DeserializeList(char *list_buf, uint32_t list_count, uint32_t list_size, uint32_t filesize, EntryList &list) 64 | { 65 | const char *p = list_buf; 66 | uint32_t offset = 0; 67 | for(uint16_t i = 0; i < list_count; ++i) { 68 | if(offset + 9 > filesize) return false; 69 | uint8_t name_len = *reinterpret_cast(p + 8); 70 | if(offset + 9 + name_len > filesize) return false; 71 | Entry entry = { 72 | *reinterpret_cast(p), 73 | *reinterpret_cast(p + 4), 74 | std::string(p + 9, p + 9 + name_len) 75 | }; 76 | if(entry.offset < list_size + 6 || entry.offset > filesize) return false; 77 | if(entry.size > static_cast(filesize) - entry.offset) return false; 78 | if(entry.name == "") return false; 79 | int wlen = MultiByteToWideChar(932, MB_PRECOMPOSED, entry.name.c_str(), entry.name.size(), NULL, 0); 80 | std::vector ws(wlen); 81 | MultiByteToWideChar(932, MB_PRECOMPOSED, entry.name.c_str(), entry.name.size(), &ws[0], ws.size()); 82 | wlen = WideCharToMultiByte(CP_ACP, 0, &ws[0], ws.size(), NULL, 0, NULL, NULL); 83 | std::vector s(wlen); 84 | WideCharToMultiByte(CP_ACP, 0, &ws[0], ws.size(), &s[0], s.size(), NULL, NULL); 85 | entry.name = std::string(s.begin(), s.end()); 86 | list.push_back(entry); 87 | p += 9 + name_len; 88 | offset += 9 + name_len; 89 | } 90 | return true; 91 | } 92 | 93 | bool HinanawiArchive_Base::Extract(EntryList::iterator &entry, std::ostream &os, bool (*callback)(const char *, void *), void * user) 94 | { 95 | if(callback) { 96 | if(!callback(entry->GetEntryName(), user)) return false; 97 | if(!callback(" extracting...", user)) return false; 98 | } 99 | 100 | boost::scoped_array data(new (std::nothrow) char[entry->size]); 101 | if(!data) { 102 | callback(" out of memory\r\n", user); 103 | return false; 104 | } 105 | 106 | m_file.seekg(entry->offset, std::ios::beg); 107 | m_file.read(reinterpret_cast(data.get()), entry->size); 108 | if(m_file.eof() || m_file.fail()) return false; 109 | 110 | uint8_t k = (entry->offset >> 1) | 0x23; 111 | for(uint32_t i = 0; i < entry->size; ++i) 112 | data[i] ^= k; 113 | 114 | os.write(data.get(), entry->size); 115 | 116 | if(callback) { 117 | if(!callback("finished.\r\n", user)) return false; 118 | } 119 | return true; 120 | } 121 | -------------------------------------------------------------------------------- /brightmoon/hinanawi.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HINANAWI_HPP 2 | #define HINANAWI_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "stdint.h" 9 | #include "arctmp.hpp" 10 | 11 | class HinanawiArchive_Base 12 | { 13 | protected: 14 | struct Entry { 15 | uint32_t offset; 16 | uint32_t size; 17 | std::string name; 18 | 19 | inline uint32_t GetOriginalSize() { return size; } 20 | inline uint32_t GetCompressedSize() { return size; } 21 | inline const char * GetEntryName() { return name.c_str(); } 22 | 23 | bool operator==(const char *rhs) { 24 | return std::strcmp(name.c_str(), rhs) == 0; 25 | } 26 | }; 27 | 28 | typedef std::list EntryList; 29 | 30 | protected: 31 | HinanawiArchive_Base(); 32 | virtual ~HinanawiArchive_Base(); 33 | 34 | protected: 35 | bool Open(const char *filename, EntryList &list); 36 | bool Extract(EntryList::iterator &entry, std::ostream &os, bool (*callback)(const char *, void *), void * user); 37 | 38 | private: 39 | bool DeserializeList(char *list_buf, uint32_t list_count, uint32_t list_size, uint32_t filesize, EntryList &list); 40 | 41 | private: 42 | std::ifstream m_file; 43 | }; 44 | 45 | typedef PBGArchiveTemplate HinanawiArchive; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /brightmoon/kaguya.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "kaguya.hpp" 4 | 5 | #define ARRAYSIZE(x) (sizeof(x) / sizeof(x)[0]) 6 | 7 | extern void unlzss(std::istream &in, std::ostream &out); 8 | extern bool thcrypter(std::istream &in, std::ostream &out, int size, unsigned char key, unsigned char step, int block, int limit); 9 | 10 | const KaguyaArchive_Base::CryptParam 11 | KaguyaArchive_Base::m_cryprm1[] = 12 | { 13 | { 0x4d, 0x1b, 0x37, 0x40, 0x2000 }, 14 | { 0x54, 0x51, 0xe9, 0x40, 0x3000 }, 15 | { 0x41, 0xc1, 0x51, 0x1400, 0x2000 }, 16 | { 0x4a, 0x03, 0x19, 0x1400, 0x7800 }, 17 | { 0x45, 0xab, 0xcd, 0x200, 0x1000 }, 18 | { 0x57, 0x12, 0x34, 0x400, 0x2800 }, 19 | { 0x2d, 0x35, 0x97, 0x80, 0x2800 }, 20 | { 0x2a, 0x99, 0x37, 0x400, 0x1000 } 21 | }; 22 | 23 | const KaguyaArchive_Base::CryptParam 24 | KaguyaArchive_Base::m_cryprm2[] = 25 | { 26 | { 0x4d, 0x1b, 0x37, 0x40, 0x2800 }, 27 | { 0x54, 0x51, 0xe9, 0x40, 0x3000 }, 28 | { 0x41, 0xc1, 0x51, 0x400, 0x400 }, 29 | { 0x4a, 0x03, 0x19, 0x400, 0x400 }, 30 | { 0x45, 0xab, 0xcd, 0x200, 0x1000 }, 31 | { 0x57, 0x12, 0x34, 0x400, 0x400 }, 32 | { 0x2d, 0x35, 0x97, 0x80, 0x2800 }, 33 | { 0x2a, 0x99, 0x37, 0x400, 0x1000 } 34 | }; 35 | 36 | KaguyaArchive_Base::KaguyaArchive_Base() 37 | : m_cryprm(m_cryprm1) 38 | { 39 | } 40 | 41 | KaguyaArchive_Base::~KaguyaArchive_Base() 42 | { 43 | } 44 | 45 | bool KaguyaArchive_Base::Open(const char *filename, EntryList &list) 46 | { 47 | m_file.open(filename, std::ios_base::binary); 48 | if(m_file.fail()) return false; 49 | 50 | std::ifstream::pos_type begpos = m_file.tellg(); 51 | m_file.seekg(0, std::ios_base::end); 52 | std::ifstream::pos_type endpos = m_file.tellg(); 53 | m_file.seekg(0, std::ios_base::beg); 54 | std::ifstream::pos_type filesize = endpos - begpos; 55 | 56 | uint32_t magic; 57 | m_file.read((char *)&magic, 4); 58 | if(magic != 'ZGBP') return false; 59 | 60 | std::strstream headbuf; 61 | if(!thcrypter(m_file, headbuf, 12, 0x1b, 0x37, 0x0c, 0x400)) 62 | return false; 63 | 64 | uint32_t filecount; 65 | uint32_t listoffset; 66 | uint32_t listsize; 67 | headbuf.read((char *)&filecount, 4); 68 | headbuf.read((char *)&listoffset, 4); 69 | headbuf.read((char *)&listsize, 4); 70 | filecount -= 123456; 71 | listoffset -= 345678; 72 | listsize -= 567891; 73 | if(listoffset >= filesize) return false; 74 | 75 | std::strstream compbuf; 76 | m_file.seekg(listoffset, std::ios_base::beg); 77 | if(!thcrypter(m_file, compbuf, static_cast(filesize) - listoffset, 78 | 62, 155, 0x80, 0x400)) 79 | return false; 80 | 81 | std::strstream listbuf; 82 | unlzss(compbuf, listbuf); 83 | 84 | for(int i = 0; i < filecount; ++i) { 85 | Entry entry; 86 | for(;;) { 87 | char c; 88 | listbuf.read(&c, 1); 89 | if(listbuf.fail()) return false; 90 | if(!c) break; 91 | entry.name.push_back(c); 92 | } 93 | listbuf.read((char *)&entry.offset, 4); 94 | if(listbuf.fail()) return false; 95 | listbuf.read((char *)&entry.origsize, 4); 96 | if(listbuf.fail()) return false; 97 | entry.origsize -= 4; 98 | if(entry.offset >= filesize) return false; 99 | char dummy[4]; 100 | listbuf.read(dummy, 4); 101 | if(listbuf.fail()) return false; 102 | list.push_back(entry); 103 | } 104 | EntryList::iterator it = list.begin(); 105 | EntryList::iterator next = list.begin(); 106 | for(++next; next != list.end(); ++it, ++next) 107 | { 108 | it->compsize = next->offset - it->offset; 109 | } 110 | it->compsize = listoffset - it->offset; 111 | return true; 112 | } 113 | 114 | bool KaguyaArchive_Base::Extract(EntryList::iterator &entry, std::ostream &os, bool (*callback)(const char *, void *), void *user) 115 | { 116 | if(callback) { 117 | if(!callback(entry->GetEntryName(), user)) return false; 118 | if(!callback(" extracting...", user)) return false; 119 | } 120 | m_file.clear(); 121 | m_file.seekg(entry->offset, std::ios_base::beg); 122 | std::strstream crypbuf; 123 | unlzss(m_file, crypbuf); 124 | if(m_file.bad()) { 125 | if(callback) { 126 | if(!callback("unexpected error occured!\r\nplease restart.\r\n", user)) return false; 127 | } 128 | return false; 129 | } 130 | char magic[4]; 131 | crypbuf.read(magic, 4); 132 | int prmidx; 133 | for(prmidx = 0; prmidx < 8; ++prmidx) 134 | if(m_cryprm[prmidx].type == magic[3]) break; 135 | if(memcmp(magic, "edz", 3) != 0 || prmidx == 8) { 136 | if(callback) { 137 | if(!callback("data may be corrupted!\r\n", user)) return false; 138 | } 139 | return false; 140 | } 141 | if(!thcrypter(crypbuf, os, entry->origsize, 142 | m_cryprm[prmidx].key, m_cryprm[prmidx].step, m_cryprm[prmidx].block, m_cryprm[prmidx].limit)) { 143 | if(callback) { 144 | if(!callback("failed to decryption.\r\n", user)) return false; 145 | } 146 | return false; 147 | } 148 | if(callback) { 149 | if(!callback("finished.\r\n", user)) return false; 150 | } 151 | return true; 152 | } 153 | 154 | void KaguyaArchive_Base::SetArchiveType(int type) 155 | { 156 | if(type == 0) { 157 | m_cryprm = m_cryprm1; 158 | } else { 159 | m_cryprm = m_cryprm2; 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /brightmoon/kaguya.hpp: -------------------------------------------------------------------------------- 1 | #ifndef KAGUYA_HPP 2 | #define KAGUYA_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include "stdint.h" 8 | #include "arctmp.hpp" 9 | 10 | class KaguyaArchive_Base 11 | { 12 | protected: 13 | struct Entry { 14 | uint32_t offset; 15 | uint32_t compsize; 16 | uint32_t origsize; 17 | std::string name; 18 | 19 | inline uint32_t GetOriginalSize() { return origsize; } 20 | inline uint32_t GetCompressedSize() { return compsize; } 21 | inline const char * GetEntryName() { return name.c_str(); } 22 | 23 | bool operator==(const char *rhs) { 24 | return std::strcmp(name.c_str(), rhs) == 0; 25 | } 26 | }; 27 | 28 | typedef std::list EntryList; 29 | 30 | struct CryptParam { 31 | unsigned char type; 32 | unsigned char key; 33 | unsigned char step; 34 | int block; 35 | int limit; 36 | }; 37 | 38 | protected: 39 | KaguyaArchive_Base(); 40 | virtual ~KaguyaArchive_Base(); 41 | 42 | protected: 43 | bool Open(const char *filename, EntryList &list); 44 | bool Extract(EntryList::iterator &it, std::ostream &os, bool (*callback)(const char *, void *), void * user); 45 | 46 | public: 47 | void SetArchiveType(int type); 48 | 49 | private: 50 | static const CryptParam m_cryprm1[]; 51 | static const CryptParam m_cryprm2[]; 52 | 53 | private: 54 | std::ifstream m_file; 55 | const CryptParam *m_cryprm; 56 | }; 57 | 58 | typedef PBGArchiveTemplate KaguyaArchive; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /brightmoon/kanako.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "kanako.hpp" 5 | 6 | extern void unlzss(std::istream &in, std::ostream &out); 7 | extern bool thcrypter(std::istream &in, std::ostream &out, int size, unsigned char key, unsigned char step, int block, int limit); 8 | 9 | const KanakoArchive_Base::CryptParam 10 | KanakoArchive_Base::m_cryprm[] = 11 | { 12 | { 0x1b, 0x37, 0x40, 0x2800 }, 13 | { 0x51, 0xe9, 0x40, 0x3000 }, 14 | { 0xc1, 0x51, 0x80, 0x3200 }, 15 | { 0x03, 0x19, 0x400, 0x7800 }, 16 | { 0xab, 0xcd, 0x200, 0x2800 }, 17 | { 0x12, 0x34, 0x80, 0x3200 }, 18 | { 0x35, 0x97, 0x80, 0x2800 }, 19 | { 0x99, 0x37, 0x400, 0x2000 } 20 | }; 21 | 22 | KanakoArchive_Base::KanakoArchive_Base() 23 | { 24 | } 25 | 26 | KanakoArchive_Base::~KanakoArchive_Base() 27 | { 28 | } 29 | 30 | bool KanakoArchive_Base::Open(const char *filename, EntryList &list) 31 | { 32 | m_file.open(filename, std::ios_base::binary); 33 | if(m_file.fail()) return false; 34 | 35 | std::ifstream::pos_type begpos = m_file.tellg(); 36 | m_file.seekg(0, std::ios_base::end); 37 | std::ifstream::pos_type endpos = m_file.tellg(); 38 | m_file.seekg(0, std::ios_base::beg); 39 | std::ifstream::pos_type filesize = endpos - begpos; 40 | 41 | std::strstream headbuf; 42 | if(!thcrypter(m_file, headbuf, 0x10, 0x1B, 0x37, 0x10, 0x10)) 43 | return false; 44 | 45 | uint32_t magic; 46 | headbuf.read((char *)&magic, 4); 47 | if(magic != '1AHT') return false; 48 | 49 | uint32_t listsize; 50 | uint32_t listcompsize; 51 | uint32_t filecount; 52 | headbuf.read((char *)&listsize, 4); 53 | headbuf.read((char *)&listcompsize, 4); 54 | headbuf.read((char *)&filecount, 4); 55 | listsize -= 123456789UL; 56 | listcompsize -= 987654321UL; 57 | filecount -= 135792468UL; 58 | if(listcompsize > filesize) return false; 59 | 60 | uint32_t listoffset = static_cast(filesize) - listcompsize; 61 | m_file.seekg(listoffset, std::ios_base::beg); 62 | 63 | std::strstream compbuf; 64 | if(!thcrypter(m_file, compbuf, listcompsize, 0x3e, 0x9b, 0x80, listcompsize)) 65 | return false; 66 | 67 | std::strstream listbuf; 68 | unlzss(compbuf, listbuf); 69 | 70 | for(int i = 0; i < filecount; ++i) { 71 | Entry entry; 72 | char buff[4]; 73 | do { 74 | listbuf.read(buff, 4); 75 | if(listbuf.fail()) return false; 76 | for(int j = 0; j < 4 && buff[j]; ++j) 77 | entry.name.push_back(buff[j]); 78 | } while(buff[3]); 79 | listbuf.read((char *)&entry.offset, 4); 80 | if(listbuf.fail()) return false; 81 | listbuf.read((char *)&entry.origsize, 4); 82 | if(listbuf.fail()) return false; 83 | listbuf.read(buff, 4); // zero padding 84 | if(listbuf.fail()) return false; 85 | list.push_back(entry); 86 | } 87 | EntryList::iterator it = list.begin(); 88 | EntryList::iterator next = list.begin(); 89 | for(++next; next != list.end(); ++it, ++next) 90 | { 91 | it->compsize = next->offset - it->offset; 92 | } 93 | it->compsize = listoffset - it->offset; 94 | return true; 95 | } 96 | 97 | bool KanakoArchive_Base::Extract(EntryList::iterator &entry, std::ostream &os, bool (*callback)(const char *, void *), void * user) 98 | { 99 | if(callback) { 100 | if(!callback(entry->GetEntryName(), user)) return false; 101 | if(!callback(" extracting...", user)) return false; 102 | } 103 | m_file.clear(); 104 | m_file.seekg(entry->offset, std::ios_base::beg); 105 | int cryidx = GetCryptParamIndex(entry->GetEntryName()); 106 | std::strstream compbuf; 107 | if(!thcrypter(m_file, compbuf, entry->GetCompressedSize(), 108 | m_cryprm[cryidx].key, m_cryprm[cryidx].step, m_cryprm[cryidx].block, m_cryprm[cryidx].limit)) 109 | { 110 | if(callback) { 111 | if(!callback("failed to decryption.\r\n", user)) return false; 112 | } 113 | return false; 114 | } 115 | if(entry->GetCompressedSize() == entry->GetOriginalSize()) { 116 | boost::iostreams::copy(compbuf, os); 117 | } else { 118 | unlzss(compbuf, os); 119 | } 120 | if(callback) { 121 | if(!callback("finished.\r\n", user)) return false; 122 | } 123 | return true; 124 | } 125 | 126 | int KanakoArchive_Base::GetCryptParamIndex(const char *entryname) 127 | { 128 | char index = 0; 129 | while(*entryname) index += *entryname++; 130 | return index & 7; 131 | } 132 | -------------------------------------------------------------------------------- /brightmoon/kanako.hpp: -------------------------------------------------------------------------------- 1 | #ifndef KANAKO_HPP 2 | #define KANAKO_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include "stdint.h" 8 | #include "arctmp.hpp" 9 | 10 | class KanakoArchive_Base 11 | { 12 | protected: 13 | struct Entry { 14 | uint32_t offset; 15 | uint32_t compsize; 16 | uint32_t origsize; 17 | std::string name; 18 | 19 | inline uint32_t GetOriginalSize() { return origsize; } 20 | inline uint32_t GetCompressedSize() { return compsize; } 21 | inline const char * GetEntryName() { return name.c_str(); } 22 | 23 | bool operator==(const char *rhs) { 24 | return std::strcmp(name.c_str(), rhs) == 0; 25 | } 26 | }; 27 | 28 | typedef std::list EntryList; 29 | 30 | struct CryptParam { 31 | unsigned char key; 32 | unsigned char step; 33 | int block; 34 | int limit; 35 | }; 36 | 37 | protected: 38 | KanakoArchive_Base(); 39 | virtual ~KanakoArchive_Base(); 40 | 41 | protected: 42 | bool Open(const char *filename, EntryList &list); 43 | bool Extract(EntryList::iterator &itearotr, std::ostream &os, bool (*callback)(const char *, void *), void * user); 44 | 45 | private: 46 | int GetCryptParamIndex(const char *entryname); 47 | 48 | private: 49 | static const CryptParam m_cryprm[]; 50 | 51 | private: 52 | std::ifstream m_file; 53 | }; 54 | 55 | typedef PBGArchiveTemplate KanakoArchive; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /brightmoon/limit.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LIMIT_HPP 2 | #define LIMIT_HPP 3 | 4 | #include // EOF, WOULD_BLOCK 5 | #include // input_filter_tag 6 | #include // get 7 | 8 | struct limit_input_filter { 9 | typedef char char_type; 10 | typedef boost::iostreams::input_filter_tag category; 11 | 12 | limit_input_filter(int limit) : limit_(limit), count(0) {} 13 | 14 | template 15 | int get(Source& src) 16 | { 17 | if(count > limit_) return EOF; 18 | ++count; 19 | return boost::iostreams::get(src); 20 | } 21 | 22 | int limit_; 23 | int count; 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /brightmoon/mainwnd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "mima.hpp" 12 | #include "yumemi.hpp" 13 | #include "vivit.hpp" 14 | #include "frandre.hpp" 15 | #include "yuyuko.hpp" 16 | #include "kaguya.hpp" 17 | #include "kanako.hpp" 18 | #include "hinanawi.hpp" 19 | #include "suica.hpp" 20 | #include "pathext.hpp" 21 | #include "resource.h" 22 | 23 | #ifndef ARRAYSIZE 24 | #define ARRAYSIZE(x) (sizeof(x)/ sizeof(x)[0]) 25 | #endif 26 | 27 | #ifndef HANDLE_WM_SIZING 28 | #define HANDLE_WM_SIZING(hwnd, wParam, lParam, fn) \ 29 | (fn)((hwnd), (UINT)(wParam), (LPRECT)(lParam)) 30 | #endif 31 | 32 | #define WC_MYMAINWND "pbgmgr_MainWindow" 33 | #define WT_MYMAINWND "Brightmoon" 34 | 35 | enum LV_SORTTYPE { 36 | LVSORT_STRING, 37 | LVSORT_NUMBER 38 | }; 39 | 40 | static struct { 41 | PSTR pszText; 42 | int nWidth; 43 | LV_SORTTYPE nSortType; 44 | } g_ColumnSet[] = { 45 | { "Name", 100, LVSORT_STRING }, 46 | { "Path", 150, LVSORT_STRING }, 47 | { "Type", 100, LVSORT_STRING }, 48 | { "Size", 100, LVSORT_NUMBER }, 49 | { "Comp. Ratio", 80, LVSORT_NUMBER } 50 | }; 51 | 52 | struct MYLISTITEM { 53 | std::string column[ARRAYSIZE(g_ColumnSet)]; 54 | boost::shared_ptr entry; 55 | } ; 56 | 57 | HINSTANCE g_hInstance; 58 | HACCEL g_hAccel; 59 | HMENU g_hMenu; 60 | HWND g_hMainWnd; 61 | HWND g_hListWnd; 62 | 63 | std::vector g_listItems; 64 | int g_sortColumn; 65 | bool g_sortAscend; 66 | 67 | std::auto_ptr g_archive; 68 | 69 | 70 | bool g_statuscancel; 71 | 72 | BOOL CALLBACK StatusDialog_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 73 | { 74 | switch(uMsg) { 75 | case WM_INITDIALOG: return TRUE; 76 | case WM_COMMAND: 77 | if(LOWORD(wParam) == IDCANCEL) 78 | g_statuscancel = true; 79 | break; 80 | } 81 | return FALSE; 82 | } 83 | 84 | bool ListView_Show(HWND hParentWnd, HINSTANCE hInstance) 85 | { 86 | g_hListWnd = CreateWindowEx( 87 | WS_EX_CLIENTEDGE, 88 | WC_LISTVIEW, NULL, 89 | WS_CHILDWINDOW | WS_OVERLAPPED | WS_VISIBLE | WS_HSCROLL | LVS_REPORT | LVS_SHOWSELALWAYS | LVS_OWNERDATA, 90 | 0, 0, 91 | CW_USEDEFAULT, CW_USEDEFAULT, 92 | hParentWnd, NULL, hInstance, NULL); 93 | if(!g_hListWnd) return false; 94 | 95 | ListView_SetItemCountEx(g_hListWnd, 0, LVSICF_NOINVALIDATEALL); 96 | //ListView_SetExtendedListViewStyle(g_hListWnd, LVS_EX_FULLROWSELECT); 97 | 98 | LVCOLUMN lvCol; 99 | lvCol.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; 100 | lvCol.fmt = LVCFMT_LEFT; 101 | for(int i = 0; i < ARRAYSIZE(g_ColumnSet); i++) { 102 | lvCol.cchTextMax = strlen(g_ColumnSet[i].pszText); 103 | lvCol.pszText = g_ColumnSet[i].pszText; 104 | lvCol.cx = g_ColumnSet[i].nWidth; 105 | ListView_InsertColumn(g_hListWnd, i, &lvCol); 106 | } 107 | 108 | RECT rect; 109 | GetClientRect(hParentWnd, &rect); 110 | MoveWindow(g_hListWnd, 0, 0, rect.right - rect.left, rect.bottom - rect.top, TRUE); 111 | 112 | return true; 113 | } 114 | 115 | bool ListView_StringDescendSortProc(const MYLISTITEM &item1, const MYLISTITEM &item2) 116 | { 117 | const std::string &itemText1 = item1.column[g_sortColumn]; 118 | const std::string &itemText2 = item2.column[g_sortColumn]; 119 | return itemText1 < itemText2; 120 | } 121 | 122 | bool ListView_StringAscendSortProc(const MYLISTITEM &item1, const MYLISTITEM &item2) 123 | { 124 | const std::string &itemText1 = item1.column[g_sortColumn]; 125 | const std::string &itemText2 = item2.column[g_sortColumn]; 126 | return itemText1 > itemText2; 127 | } 128 | 129 | bool ListView_NumberDescendSortProc(const MYLISTITEM &item1, const MYLISTITEM &item2) 130 | { 131 | int itemNumber1 = boost::lexical_cast(item1.column[g_sortColumn]); 132 | int itemNumber2 = boost::lexical_cast(item2.column[g_sortColumn]); 133 | return itemNumber1 < itemNumber2; 134 | } 135 | 136 | bool ListView_NumberAscendSortProc(const MYLISTITEM &item1, const MYLISTITEM &item2) 137 | { 138 | int itemNumber1 = boost::lexical_cast(item1.column[g_sortColumn]); 139 | int itemNumber2 = boost::lexical_cast(item2.column[g_sortColumn]); 140 | return itemNumber1 > itemNumber2; 141 | } 142 | 143 | void ListView_OnColumnClick(NM_LISTVIEW *pNMLV) 144 | { 145 | if(pNMLV->iSubItem != g_sortColumn) 146 | g_sortAscend = false; 147 | g_sortColumn = pNMLV->iSubItem; 148 | 149 | switch(g_ColumnSet[g_sortColumn].nSortType) { 150 | case LVSORT_STRING: 151 | std::stable_sort(g_listItems.begin(), g_listItems.end(), 152 | g_sortAscend ? ListView_StringAscendSortProc : ListView_StringDescendSortProc); 153 | break; 154 | case LVSORT_NUMBER: 155 | std::stable_sort(g_listItems.begin(), g_listItems.end(), 156 | g_sortAscend ? ListView_NumberAscendSortProc : ListView_NumberDescendSortProc); 157 | break; 158 | } 159 | g_sortAscend = !g_sortAscend; 160 | 161 | InvalidateRect(g_hListWnd, NULL, TRUE); 162 | UpdateWindow(g_hListWnd); 163 | } 164 | 165 | void ListView_OnGetDispInfo(LV_DISPINFO * pLVDI) 166 | { 167 | if(pLVDI->item.mask & LVIF_TEXT) { 168 | lstrcpy(pLVDI->item.pszText, 169 | g_listItems[pLVDI->item.iItem].column[pLVDI->item.iSubItem].c_str()); 170 | } 171 | } 172 | 173 | BOOL MainWindow_OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct) 174 | { 175 | InitCommonControls(); 176 | 177 | if(!ListView_Show(hwnd, g_hInstance)) return FALSE; 178 | return TRUE; 179 | } 180 | 181 | void MainWindow_OnDestroy(HWND hwnd) 182 | { 183 | PostQuitMessage(0); 184 | } 185 | 186 | BOOL MainWindow_OnSizing(HWND hwnd, UINT fwSide, LPRECT lprc) 187 | { 188 | RECT rect; 189 | GetClientRect(hwnd, &rect); 190 | MoveWindow(g_hListWnd, 0, 0, rect.right - rect.left, rect.bottom - rect.top, TRUE); 191 | return TRUE; 192 | } 193 | 194 | void MainWindow_OnSize(HWND hwnd, UINT state, int cx, int cy) 195 | { 196 | RECT rect; 197 | GetClientRect(hwnd, &rect); 198 | MoveWindow(g_hListWnd, 0, 0, rect.right - rect.left, rect.bottom - rect.top, TRUE); 199 | return; 200 | } 201 | 202 | template 203 | bool OpenArchive(LPCSTR filename) 204 | { 205 | g_archive.reset(new(std::nothrow) T); 206 | if(!g_archive.get()) return false; 207 | 208 | if(!g_archive.get()->Open(filename) || 209 | !g_archive.get()->EnumFirst()) { 210 | g_archive.reset(NULL); 211 | return false; 212 | } 213 | return true; 214 | } 215 | 216 | bool TryToOpenArchive(HWND hwnd, const char *filename) 217 | { 218 | if(OpenArchive(filename)) return true; 219 | if(OpenArchive(filename)) return true; 220 | if(OpenArchive(filename)) return true; 221 | if(OpenArchive(filename)) return true; 222 | if(OpenArchive(filename)) return true; 223 | if(OpenArchive(filename)) { 224 | int result = MessageBox(hwnd, 225 | "press 'Yes' to treat as Touhou Eiyashou Archive. Otherwise, press 'No.'", 226 | WT_MYMAINWND, MB_YESNO | MB_ICONINFORMATION); 227 | static_cast(g_archive.get()) 228 | ->SetArchiveType(result != IDYES); 229 | return true; 230 | } 231 | if(OpenArchive(filename)) return true; 232 | if(OpenArchive(filename)) return true; 233 | if(OpenArchive(filename)) return true; 234 | return false; 235 | } 236 | 237 | 238 | void MainMenu_OnFileOpen(HWND hwnd) 239 | { 240 | OPENFILENAME ofn; 241 | char filename[1024]; 242 | ZeroMemory(&ofn, sizeof(OPENFILENAME)); 243 | ZeroMemory(filename, sizeof(filename)); 244 | ofn.lStructSize = sizeof(OPENFILENAME); 245 | ofn.hwndOwner = hwnd; 246 | ofn.lpstrFilter = "Brightmoon Archive (*.dat)\0*.dat\0"; 247 | ofn.lpstrFile = filename; 248 | ofn.nMaxFile = sizeof filename; 249 | ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST; 250 | if(!GetOpenFileName(&ofn)) return; 251 | 252 | ListView_SetItemCountEx(g_hListWnd, 0, LVSICF_NOINVALIDATEALL); 253 | g_listItems.clear(); 254 | 255 | if(!TryToOpenArchive(hwnd, filename)) { 256 | MessageBox(hwnd, "failed to open archive.", "error", MB_OK | MB_ICONSTOP); 257 | return; 258 | } 259 | 260 | do { 261 | MYLISTITEM item; 262 | PBGArchiveEntry *entry = g_archive.get()->GetEntry(); 263 | item.entry.reset(entry); 264 | 265 | std::string entryname(entry->GetEntryName()); 266 | std::vector filename(entryname.begin(), entryname.end()); 267 | filename.push_back(0); 268 | PathStripPath(&filename[0]); 269 | item.column[0] = std::string(&filename[0]); 270 | 271 | std::vector filepath(entryname.begin(), entryname.end()); 272 | filepath.push_back(0); 273 | PathRemoveFileSpecEx(&filepath[0]); 274 | item.column[1] = std::string(&filepath[0]); 275 | 276 | SHFILEINFO sfi; 277 | SHGetFileInfo(&filename[0], 0, &sfi, sizeof sfi, 278 | SHGFI_TYPENAME | SHGFI_USEFILEATTRIBUTES); 279 | item.column[2] = std::string(sfi.szTypeName); 280 | 281 | char buffer[64]; 282 | wsprintf(buffer, "%d", entry->GetOriginalSize()); 283 | item.column[3] = std::string(buffer); 284 | 285 | long comp_ratio = MulDiv(entry->GetCompressedSize(), 100, entry->GetOriginalSize()); 286 | wsprintf(buffer, "%d", comp_ratio); 287 | item.column[4] = std::string(buffer); 288 | 289 | g_listItems.push_back(item); 290 | } while(g_archive.get()->EnumNext()); 291 | ListView_SetItemCountEx(g_hListWnd, g_listItems.size(), LVSICF_NOINVALIDATEALL); 292 | 293 | EnableMenuItem(g_hMenu, ID_FILE_CLOSE , MF_ENABLED); 294 | EnableMenuItem(g_hMenu, ID_FILE_EXTRACT, MF_ENABLED); 295 | EnableMenuItem(g_hMenu, 1, MF_BYPOSITION | MF_ENABLED); 296 | DrawMenuBar(hwnd); 297 | } 298 | 299 | bool ExtractCallback(const char *message, void *user) 300 | { 301 | MSG msg; 302 | while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) > 0) { 303 | TranslateMessage(&msg); 304 | DispatchMessage(&msg); 305 | } 306 | 307 | HWND hStatusDlg = (HWND)user; 308 | SendDlgItemMessage(hStatusDlg, IDC_EDIT_STATUS, EM_REPLACESEL, 1, (LPARAM)message); 309 | UpdateWindow(hStatusDlg); 310 | 311 | return !g_statuscancel; 312 | } 313 | 314 | void MainMenu_OnExtract(HWND hwnd) 315 | { 316 | BROWSEINFO bi; 317 | ZeroMemory(&bi, sizeof(BROWSEINFO)); 318 | bi.hwndOwner = hwnd; 319 | bi.lpszTitle = "Please choose a folder for extracted files."; 320 | bi.pidlRoot = CSIDL_DESKTOP; 321 | bi.ulFlags = BIF_RETURNONLYFSDIRS; 322 | LPITEMIDLIST lpidl = SHBrowseForFolder(&bi); 323 | if(!lpidl) return; 324 | 325 | char extractpath[1024]; 326 | SHGetPathFromIDList(lpidl, extractpath); 327 | CoTaskMemFree(lpidl); 328 | 329 | SetCurrentDirectory(extractpath); 330 | 331 | HWND hStatusDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_STATUS), hwnd, StatusDialog_WindowProc); 332 | SendDlgItemMessage(hStatusDlg, IDC_EDIT_STATUS, EM_SETSEL, 0, 0); 333 | ShowWindow(hStatusDlg, SW_SHOW); 334 | 335 | g_statuscancel = false; 336 | int index = -1; 337 | while((index = ListView_GetNextItem(g_hListWnd, index, LVNI_SELECTED)) != -1 && 338 | !g_statuscancel) 339 | { 340 | PBGArchiveEntry *entry = g_listItems[index].entry.get(); 341 | try { 342 | std::string entryname(entry->GetEntryName()); 343 | std::vector outname(entryname.begin(), entryname.end()); 344 | outname.push_back(0); 345 | PathSlashToBackSlash(&outname[0]); 346 | 347 | std::vector filepath(outname); 348 | PathRemoveFileSpecEx(&filepath[0]); 349 | if(filepath[0]) 350 | MakeSureDirectoryPathExists(&filepath[0]); 351 | int wlen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, &outname[0], outname.size(), NULL, 0); 352 | std::vector ws(wlen); 353 | MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, &outname[0], outname.size(), &ws[0], ws.size()); 354 | ws.push_back(0); 355 | std::ofstream os(&ws[0], std::ios_base::binary); 356 | if(os.fail()) { 357 | throw std::exception(); 358 | } else { 359 | entry->Extract(os, ExtractCallback, (void *)hStatusDlg); 360 | } 361 | } catch(std::exception &e) { 362 | ExtractCallback("failed to create", (void *)hStatusDlg); 363 | ExtractCallback(entry->GetEntryName(), (void *)hStatusDlg); 364 | ExtractCallback("\r\n", (void *)hStatusDlg); 365 | } 366 | } 367 | DestroyWindow(hStatusDlg); 368 | } 369 | 370 | void MainMenu_OnFileClose(HWND hwnd) 371 | { 372 | ListView_SetItemCountEx(g_hListWnd, 0, LVSICF_NOINVALIDATEALL); 373 | g_listItems.clear(); 374 | g_archive.reset(NULL); 375 | EnableMenuItem(g_hMenu, ID_FILE_CLOSE , MF_GRAYED); 376 | EnableMenuItem(g_hMenu, ID_FILE_EXTRACT, MF_GRAYED); 377 | EnableMenuItem(g_hMenu, 1, MF_BYPOSITION | MF_GRAYED); 378 | DrawMenuBar(hwnd); 379 | } 380 | 381 | void MainMenu_OnQuit(HWND hwnd) 382 | { 383 | PostMessage(hwnd, WM_CLOSE, 0, 0); 384 | } 385 | 386 | void MainMenu_OnSelectAll(HWND hwnd) 387 | { 388 | ListView_SetItemState(g_hListWnd, (UINT)-1, LVIS_SELECTED, LVIS_SELECTED); 389 | SetFocus(g_hListWnd); 390 | } 391 | 392 | void MainMenu_OnSelectInv(HWND hwnd) 393 | { 394 | for(int i = 0; i < ListView_GetItemCount(g_hListWnd); ++i) { 395 | int oldstate = ListView_GetItemState(g_hListWnd, i, LVIS_SELECTED); 396 | int newstate = (oldstate == LVIS_SELECTED ? 0 : LVIS_SELECTED); 397 | ListView_SetItemState(g_hListWnd, i, newstate, LVIS_SELECTED); 398 | } 399 | SetFocus(g_hListWnd); 400 | } 401 | 402 | void MainWindow_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) 403 | { 404 | switch(id) { 405 | case ID_FILE_OPEN: MainMenu_OnFileOpen(hwnd); break; 406 | case ID_FILE_EXTRACT: MainMenu_OnExtract(hwnd); break; 407 | case ID_FILE_CLOSE: MainMenu_OnFileClose(hwnd); break; 408 | case ID_FILE_QUIT: MainMenu_OnQuit(hwnd); break; 409 | case ID_LIST_SELALL: MainMenu_OnSelectAll(hwnd); break; 410 | case ID_LIST_SELINV: MainMenu_OnSelectInv(hwnd); break; 411 | } 412 | return; 413 | } 414 | 415 | LRESULT MainWindow_OnNotify(HWND hwnd, int idCtrl, LPNMHDR pNMHdr) 416 | { 417 | if(pNMHdr->hwndFrom != g_hListWnd) return FALSE; 418 | switch(pNMHdr->code) { 419 | case LVN_COLUMNCLICK: ListView_OnColumnClick(reinterpret_cast(pNMHdr)); break; 420 | case LVN_GETDISPINFO: ListView_OnGetDispInfo(reinterpret_cast(pNMHdr)); break; 421 | } 422 | return TRUE; 423 | } 424 | 425 | LRESULT CALLBACK MainWindow_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 426 | { 427 | switch(uMsg) { 428 | HANDLE_MSG(hwnd, WM_CREATE, MainWindow_OnCreate); 429 | HANDLE_MSG(hwnd, WM_DESTROY, MainWindow_OnDestroy); 430 | HANDLE_MSG(hwnd, WM_SIZING, MainWindow_OnSizing); 431 | HANDLE_MSG(hwnd, WM_SIZE, MainWindow_OnSize); 432 | HANDLE_MSG(hwnd, WM_COMMAND, MainWindow_OnCommand); 433 | HANDLE_MSG(hwnd, WM_NOTIFY, MainWindow_OnNotify); 434 | } 435 | return DefWindowProc(hwnd, uMsg, wParam, lParam); 436 | } 437 | 438 | bool MainWindow_RegisterClass(HINSTANCE hInstance) 439 | { 440 | WNDCLASSEX wcex; 441 | wcex.cbSize = sizeof(WNDCLASSEX); 442 | wcex.cbClsExtra = 0; 443 | wcex.cbWndExtra = 0; 444 | wcex.hbrBackground = reinterpret_cast(COLOR_WINDOW); 445 | wcex.hCursor = LoadCursor(NULL, IDC_ARROW); 446 | wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION); 447 | wcex.hIconSm = NULL; 448 | wcex.hInstance = hInstance; 449 | wcex.lpfnWndProc = MainWindow_WndProc; 450 | wcex.lpszClassName = WC_MYMAINWND; 451 | wcex.lpszMenuName = NULL; 452 | wcex.style = CS_VREDRAW | CS_HREDRAW; 453 | 454 | return RegisterClassEx(&wcex) != 0; 455 | } 456 | 457 | bool MainWindow_Show(HINSTANCE hInstance) 458 | { 459 | g_hInstance = hInstance; 460 | g_hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDM_MENU)); 461 | if(!g_hMenu) return false; 462 | g_hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCEL)); 463 | if(!g_hAccel) return false; 464 | 465 | g_hMainWnd = CreateWindowEx( 466 | 0, 467 | WC_MYMAINWND, WT_MYMAINWND, 468 | WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS, 469 | CW_USEDEFAULT, CW_USEDEFAULT, 470 | 640, 480, 471 | NULL, g_hMenu, hInstance, NULL); 472 | if(!g_hMainWnd) return false; 473 | 474 | ShowWindow(g_hMainWnd, SW_SHOW); 475 | return true; 476 | } 477 | 478 | void MainWindow_Run() 479 | { 480 | MSG msg; 481 | while(GetMessage(&msg, NULL, 0, 0)) { 482 | if(!TranslateAccelerator(g_hMainWnd, g_hAccel, &msg)) { 483 | TranslateMessage(&msg); 484 | DispatchMessage(&msg); 485 | } 486 | } 487 | } 488 | -------------------------------------------------------------------------------- /brightmoon/mima.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kghost/th123_toolset/d6285d65576d3cb4a1a7dbfab4b211b09ece9616/brightmoon/mima.cpp -------------------------------------------------------------------------------- /brightmoon/mima.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MIMA_HPP 2 | #define MIMA_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include "stdint.h" 8 | #include "arctmp.hpp" 9 | 10 | class MimaArchive_Base 11 | { 12 | protected: 13 | struct Entry { 14 | uint32_t offset; 15 | uint32_t compsize; 16 | uint32_t origsize; 17 | uint8_t key; 18 | char name[13]; 19 | 20 | inline uint32_t GetOriginalSize() { return origsize; } 21 | inline uint32_t GetCompressedSize() { return compsize; } 22 | inline const char * GetEntryName() { return name; } 23 | 24 | bool operator==(const char *rhs) { 25 | return std::strcmp(name, rhs) == 0; 26 | } 27 | }; 28 | 29 | typedef std::list EntryList; 30 | 31 | protected: 32 | MimaArchive_Base(); 33 | virtual ~MimaArchive_Base(); 34 | 35 | protected: 36 | bool Open(const char *filename, EntryList &list); 37 | bool Extract(EntryList::iterator &it, std::ostream &os, bool (*callback)(const char *, void *), void * user); 38 | 39 | private: 40 | bool DeserializeList(std::istream &is, uint32_t list_count, uint32_t filesize, EntryList &list); 41 | static bool ValidateName(const char *name); 42 | 43 | private: 44 | std::ifstream m_file; 45 | }; 46 | 47 | typedef PBGArchiveTemplate MimaArchive; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /brightmoon/mt.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MT_HPP 2 | #define MT_HPP 3 | 4 | class RNG_MT 5 | { 6 | private: 7 | enum { 8 | N = 624, 9 | M = 397, 10 | MATRIX_A = 0x9908b0dfUL, 11 | UPPER_MASK = 0x80000000UL, 12 | LOWER_MASK = 0x7FFFFFFFUL 13 | }; 14 | 15 | private: 16 | uint32_t mt[N]; 17 | int32_t mti; 18 | 19 | public: 20 | explicit RNG_MT(uint32_t s) 21 | { 22 | init(s); 23 | } 24 | 25 | void init(uint32_t s) 26 | { 27 | mt[0] = s; 28 | for(mti = 1; mti < N; ++mti) { 29 | mt[mti] = 30 | (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti); 31 | } 32 | } 33 | 34 | uint32_t next_int32() 35 | { 36 | uint32_t y; 37 | static const uint32_t mag01[2]={0x0UL, MATRIX_A}; 38 | if (mti >= N) { 39 | int kk; 40 | if (mti == N+1) 41 | init(5489UL); 42 | 43 | for (kk=0;kk> 1) ^ mag01[y & 0x1UL]; 46 | } 47 | for (;kk> 1) ^ mag01[y & 0x1UL]; 50 | } 51 | y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); 52 | mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL]; 53 | 54 | mti = 0; 55 | } 56 | 57 | y = mt[mti++]; 58 | 59 | /* Tempering */ 60 | y ^= (y >> 11); 61 | y ^= (y << 7) & 0x9d2c5680UL; 62 | y ^= (y << 15) & 0xefc60000UL; 63 | y ^= (y >> 18); 64 | 65 | return y; 66 | } 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /brightmoon/pathext.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void PathRemoveFileSpecEx(LPSTR pszPath) 4 | { 5 | LPSTR pszLastSlash = NULL; 6 | LPSTR pszCurrent = pszPath; 7 | while(*pszCurrent) { 8 | if(*pszCurrent == '/' || *pszCurrent == '\\') 9 | pszLastSlash = pszCurrent; 10 | pszCurrent = CharNext(pszCurrent); 11 | } 12 | if(pszLastSlash) *CharNext(pszLastSlash) = 0; 13 | else *pszPath = 0; 14 | } 15 | 16 | void PathSlashToBackSlash(LPSTR pszPath) 17 | { 18 | while(*pszPath) { 19 | if(*pszPath == '/') *pszPath = '\\'; 20 | pszPath = CharNext(pszPath); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /brightmoon/pathext.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PATHEXT_HPP 2 | #define PATHEXT_HPP 3 | 4 | void PathRemoveFileSpecEx(LPSTR pszPath); 5 | void PathSlashToBackSlash(LPSTR pszPath); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /brightmoon/pbgarc.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PBGARC_HPP 2 | #define PBGARC_HPP 3 | 4 | #include "stdint.h" 5 | 6 | struct PBGArchive 7 | { 8 | virtual bool Open(const char * filename) = 0; 9 | virtual bool EnumFirst() = 0; 10 | virtual bool EnumNext() = 0; 11 | virtual const char * GetEntryName() = 0; 12 | virtual uint32_t GetOriginalSize() = 0; 13 | virtual uint32_t GetCompressedSize() = 0; 14 | virtual struct PBGArchiveEntry * GetEntry() = 0; 15 | virtual bool Extract(std::ostream &os, bool (*callback)(const char *, void *), void * user) = 0; 16 | virtual bool ExtractAll(bool (*callback)(const char *, void *), void * user) = 0; 17 | }; 18 | 19 | struct PBGArchiveEntry 20 | { 21 | virtual const char * GetEntryName() = 0; 22 | virtual uint32_t GetOriginalSize() = 0; 23 | virtual uint32_t GetCompressedSize() = 0; 24 | virtual bool Extract(std::ostream &os, bool (*callback)(const char *, void *), void * user) = 0; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /brightmoon/pbgmgr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" 5 | int * __errno() { return _errno(); } 6 | 7 | extern bool MainWindow_RegisterClass(HINSTANCE); 8 | extern bool MainWindow_Show(HINSTANCE); 9 | extern void MainWindow_Run(); 10 | 11 | int APIENTRY WinMain( 12 | HINSTANCE hInstance, 13 | HINSTANCE hPrevInstance, 14 | LPSTR lpCmdLine, 15 | int nCmdShow ) 16 | { 17 | HWND hMainWnd; 18 | if( 19 | !MainWindow_RegisterClass(hInstance) || 20 | !MainWindow_Show(hInstance)) { 21 | MessageBox(NULL, "Failed to initialize", "Brightmoon", MB_OK | MB_ICONSTOP); 22 | return -1; 23 | } 24 | 25 | MainWindow_Run(); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /brightmoon/pbgmgr.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "resource.h" 3 | 4 | LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT 5 | #pragma code_page(932) 6 | 7 | IDM_MENU MENU DISCARDABLE 8 | BEGIN 9 | POPUP "&File" 10 | BEGIN 11 | MENUITEM "&Open\tCtrl+O", ID_FILE_OPEN 12 | MENUITEM "&Close", ID_FILE_CLOSE, GRAYED 13 | MENUITEM SEPARATOR 14 | MENUITEM "&Extract\tF5", ID_FILE_EXTRACT, GRAYED 15 | MENUITEM "&Quit", ID_FILE_QUIT 16 | END 17 | POPUP "&List", GRAYED 18 | BEGIN 19 | MENUITEM "Select &All\tCtrl+A", ID_LIST_SELALL 20 | MENUITEM "&Inverse selection", ID_LIST_SELINV 21 | END 22 | END 23 | 24 | IDR_ACCEL ACCELERATORS DISCARDABLE 25 | BEGIN 26 | "A", ID_LIST_SELALL, VIRTKEY, CONTROL, NOINVERT 27 | "O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT 28 | VK_F5, ID_FILE_EXTRACT, VIRTKEY, NOINVERT 29 | END 30 | 31 | IDD_STATUS DIALOG DISCARDABLE 0, 0, 215, 138 32 | STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION 33 | CAPTION "Status" 34 | FONT 9, "MS UI Gothic" 35 | BEGIN 36 | PUSHBUTTON "Cancel",IDCANCEL,162,120,50,14 37 | EDITTEXT IDC_EDIT_STATUS,2,2,210,115, ES_MULTILINE | 38 | ES_AUTOVSCROLL | ES_READONLY | ES_WANTRETURN | 39 | WS_DISABLED | WS_VSCROLL 40 | END 41 | 42 | 1 24 "pbgmgr.xml" 43 | -------------------------------------------------------------------------------- /brightmoon/pbgmgr.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | It occured on the bright moonlight night in the summer. 10 | 11 | 12 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /brightmoon/resource.h: -------------------------------------------------------------------------------- 1 | #define IDM_MENU 101 2 | #define IDR_ACCEL 102 3 | 4 | #define ID_FILE_OPEN 1001 5 | #define ID_FILE_CLOSE 1002 6 | #define ID_FILE_EXTRACT 1003 7 | #define ID_FILE_QUIT 1004 8 | 9 | #define ID_LIST_SELALL 1101 10 | #define ID_LIST_SELINV 1102 11 | 12 | #define IDD_STATUS 10001 13 | 14 | #define IDC_EDIT_STATUS 20001 15 | -------------------------------------------------------------------------------- /brightmoon/stdint.h: -------------------------------------------------------------------------------- 1 | // ISO C9x compliant stdint.h for Microsoft Visual Studio 2 | // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 3 | // 4 | // Copyright (c) 2006-2008 Alexander Chemeris 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 16 | // 3. The name of the author may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 20 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | #ifndef _MSC_VER // [ 33 | #error "Use this header only with Microsoft Visual C++ compilers!" 34 | #endif // _MSC_VER ] 35 | 36 | #ifndef _MSC_STDINT_H_ // [ 37 | #define _MSC_STDINT_H_ 38 | 39 | #if _MSC_VER > 1000 40 | #pragma once 41 | #endif 42 | 43 | #include 44 | 45 | // For Visual Studio 6 in C++ mode wrap include with 'extern "C++" {}' 46 | // or compiler give many errors like this: 47 | // error C2733: second C linkage of overloaded function 'wmemchr' not allowed 48 | #if (_MSC_VER < 1300) && defined(__cplusplus) 49 | extern "C++" { 50 | #endif 51 | # include 52 | #if (_MSC_VER < 1300) && defined(__cplusplus) 53 | } 54 | #endif 55 | 56 | // Define _W64 macros to mark types changing their size, like intptr_t. 57 | #ifndef _W64 58 | # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 59 | # define _W64 __w64 60 | # else 61 | # define _W64 62 | # endif 63 | #endif 64 | 65 | 66 | // 7.18.1 Integer types 67 | 68 | // 7.18.1.1 Exact-width integer types 69 | typedef __int8 int8_t; 70 | typedef __int16 int16_t; 71 | typedef __int32 int32_t; 72 | typedef __int64 int64_t; 73 | typedef unsigned __int8 uint8_t; 74 | typedef unsigned __int16 uint16_t; 75 | typedef unsigned __int32 uint32_t; 76 | typedef unsigned __int64 uint64_t; 77 | 78 | // 7.18.1.2 Minimum-width integer types 79 | typedef int8_t int_least8_t; 80 | typedef int16_t int_least16_t; 81 | typedef int32_t int_least32_t; 82 | typedef int64_t int_least64_t; 83 | typedef uint8_t uint_least8_t; 84 | typedef uint16_t uint_least16_t; 85 | typedef uint32_t uint_least32_t; 86 | typedef uint64_t uint_least64_t; 87 | 88 | // 7.18.1.3 Fastest minimum-width integer types 89 | typedef int8_t int_fast8_t; 90 | typedef int16_t int_fast16_t; 91 | typedef int32_t int_fast32_t; 92 | typedef int64_t int_fast64_t; 93 | typedef uint8_t uint_fast8_t; 94 | typedef uint16_t uint_fast16_t; 95 | typedef uint32_t uint_fast32_t; 96 | typedef uint64_t uint_fast64_t; 97 | 98 | // 7.18.1.4 Integer types capable of holding object pointers 99 | #ifdef _WIN64 // [ 100 | typedef __int64 intptr_t; 101 | typedef unsigned __int64 uintptr_t; 102 | #else // _WIN64 ][ 103 | typedef _W64 int intptr_t; 104 | typedef _W64 unsigned int uintptr_t; 105 | #endif // _WIN64 ] 106 | 107 | // 7.18.1.5 Greatest-width integer types 108 | typedef int64_t intmax_t; 109 | typedef uint64_t uintmax_t; 110 | 111 | 112 | // 7.18.2 Limits of specified-width integer types 113 | 114 | #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 115 | 116 | // 7.18.2.1 Limits of exact-width integer types 117 | #define INT8_MIN ((int8_t)_I8_MIN) 118 | #define INT8_MAX _I8_MAX 119 | #define INT16_MIN ((int16_t)_I16_MIN) 120 | #define INT16_MAX _I16_MAX 121 | #define INT32_MIN ((int32_t)_I32_MIN) 122 | #define INT32_MAX _I32_MAX 123 | #define INT64_MIN ((int64_t)_I64_MIN) 124 | #define INT64_MAX _I64_MAX 125 | #define UINT8_MAX _UI8_MAX 126 | #define UINT16_MAX _UI16_MAX 127 | #define UINT32_MAX _UI32_MAX 128 | #define UINT64_MAX _UI64_MAX 129 | 130 | // 7.18.2.2 Limits of minimum-width integer types 131 | #define INT_LEAST8_MIN INT8_MIN 132 | #define INT_LEAST8_MAX INT8_MAX 133 | #define INT_LEAST16_MIN INT16_MIN 134 | #define INT_LEAST16_MAX INT16_MAX 135 | #define INT_LEAST32_MIN INT32_MIN 136 | #define INT_LEAST32_MAX INT32_MAX 137 | #define INT_LEAST64_MIN INT64_MIN 138 | #define INT_LEAST64_MAX INT64_MAX 139 | #define UINT_LEAST8_MAX UINT8_MAX 140 | #define UINT_LEAST16_MAX UINT16_MAX 141 | #define UINT_LEAST32_MAX UINT32_MAX 142 | #define UINT_LEAST64_MAX UINT64_MAX 143 | 144 | // 7.18.2.3 Limits of fastest minimum-width integer types 145 | #define INT_FAST8_MIN INT8_MIN 146 | #define INT_FAST8_MAX INT8_MAX 147 | #define INT_FAST16_MIN INT16_MIN 148 | #define INT_FAST16_MAX INT16_MAX 149 | #define INT_FAST32_MIN INT32_MIN 150 | #define INT_FAST32_MAX INT32_MAX 151 | #define INT_FAST64_MIN INT64_MIN 152 | #define INT_FAST64_MAX INT64_MAX 153 | #define UINT_FAST8_MAX UINT8_MAX 154 | #define UINT_FAST16_MAX UINT16_MAX 155 | #define UINT_FAST32_MAX UINT32_MAX 156 | #define UINT_FAST64_MAX UINT64_MAX 157 | 158 | // 7.18.2.4 Limits of integer types capable of holding object pointers 159 | #ifdef _WIN64 // [ 160 | # define INTPTR_MIN INT64_MIN 161 | # define INTPTR_MAX INT64_MAX 162 | # define UINTPTR_MAX UINT64_MAX 163 | #else // _WIN64 ][ 164 | # define INTPTR_MIN INT32_MIN 165 | # define INTPTR_MAX INT32_MAX 166 | # define UINTPTR_MAX UINT32_MAX 167 | #endif // _WIN64 ] 168 | 169 | // 7.18.2.5 Limits of greatest-width integer types 170 | #define INTMAX_MIN INT64_MIN 171 | #define INTMAX_MAX INT64_MAX 172 | #define UINTMAX_MAX UINT64_MAX 173 | 174 | // 7.18.3 Limits of other integer types 175 | 176 | #ifdef _WIN64 // [ 177 | # define PTRDIFF_MIN _I64_MIN 178 | # define PTRDIFF_MAX _I64_MAX 179 | #else // _WIN64 ][ 180 | # define PTRDIFF_MIN _I32_MIN 181 | # define PTRDIFF_MAX _I32_MAX 182 | #endif // _WIN64 ] 183 | 184 | #define SIG_ATOMIC_MIN INT_MIN 185 | #define SIG_ATOMIC_MAX INT_MAX 186 | 187 | #ifndef SIZE_MAX // [ 188 | # ifdef _WIN64 // [ 189 | # define SIZE_MAX _UI64_MAX 190 | # else // _WIN64 ][ 191 | # define SIZE_MAX _UI32_MAX 192 | # endif // _WIN64 ] 193 | #endif // SIZE_MAX ] 194 | 195 | // WCHAR_MIN and WCHAR_MAX are also defined in 196 | #ifndef WCHAR_MIN // [ 197 | # define WCHAR_MIN 0 198 | #endif // WCHAR_MIN ] 199 | #ifndef WCHAR_MAX // [ 200 | # define WCHAR_MAX _UI16_MAX 201 | #endif // WCHAR_MAX ] 202 | 203 | #define WINT_MIN 0 204 | #define WINT_MAX _UI16_MAX 205 | 206 | #endif // __STDC_LIMIT_MACROS ] 207 | 208 | 209 | // 7.18.4 Limits of other integer types 210 | 211 | #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 212 | 213 | // 7.18.4.1 Macros for minimum-width integer constants 214 | 215 | #define INT8_C(val) val##i8 216 | #define INT16_C(val) val##i16 217 | #define INT32_C(val) val##i32 218 | #define INT64_C(val) val##i64 219 | 220 | #define UINT8_C(val) val##ui8 221 | #define UINT16_C(val) val##ui16 222 | #define UINT32_C(val) val##ui32 223 | #define UINT64_C(val) val##ui64 224 | 225 | // 7.18.4.2 Macros for greatest-width integer constants 226 | #define INTMAX_C INT64_C 227 | #define UINTMAX_C UINT64_C 228 | 229 | #endif // __STDC_CONSTANT_MACROS ] 230 | 231 | 232 | #endif // _MSC_STDINT_H_ ] 233 | -------------------------------------------------------------------------------- /brightmoon/suica.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kghost/th123_toolset/d6285d65576d3cb4a1a7dbfab4b211b09ece9616/brightmoon/suica.cpp -------------------------------------------------------------------------------- /brightmoon/suica.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SUICA_HPP 2 | #define SUICA_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "stdint.h" 9 | #include "arctmp.hpp" 10 | 11 | class SuicaArchive_Base 12 | { 13 | protected: 14 | struct Entry { 15 | uint32_t offset; 16 | uint32_t size; 17 | std::string name; 18 | 19 | inline uint32_t GetOriginalSize() { return size; } 20 | inline uint32_t GetCompressedSize() { return size; } 21 | inline const char * GetEntryName() { return name.c_str(); } 22 | 23 | bool operator==(const char *rhs) { 24 | return std::strcmp(name.c_str(), rhs) == 0; 25 | } 26 | }; 27 | 28 | typedef std::list EntryList; 29 | 30 | protected: 31 | SuicaArchive_Base(); 32 | virtual ~SuicaArchive_Base(); 33 | 34 | protected: 35 | bool Open(const char *filename, EntryList &list); 36 | bool Extract(EntryList::iterator &entry, std::ostream &os, bool (*callback)(const char *, void *), void * user); 37 | 38 | private: 39 | std::ifstream m_file; 40 | }; 41 | 42 | typedef PBGArchiveTemplate SuicaArchive; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /brightmoon/thcrypter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | bool thcrypter(std::istream &in, std::ostream &out, int size, unsigned char key, unsigned char step, int block, int limit) 5 | { 6 | std::vector inblk(block); 7 | std::vector outblk(block); 8 | int addup; 9 | int i; 10 | 11 | addup = size % block; 12 | if(addup >= block / 4) addup = 0; 13 | addup += size % 2; 14 | size -= addup; 15 | 16 | while(size > 0 && limit > 0) { 17 | if(size < block) block = size; 18 | in.read(&inblk[0], block); 19 | if(in.fail()) return false; 20 | char *pin = &inblk[0]; 21 | for(int j = 0; j < 2; ++j) { 22 | char *pout = &outblk[block - j - 1]; 23 | for(int i = 0; i < (block - j + 1) / 2; ++i) { 24 | *pout = *pin++ ^ key; 25 | pout -= 2; 26 | key += step; 27 | } 28 | } 29 | out.write(&outblk[0], block); 30 | limit -= block; 31 | size -= block; 32 | } 33 | size += addup; 34 | if(size > 0) { 35 | std::vector restbuf(size); 36 | in.read(&restbuf[0], size); 37 | if(in.fail()) return false; 38 | out.write(&restbuf[0], size); 39 | } 40 | return true; 41 | } 42 | -------------------------------------------------------------------------------- /brightmoon/unerle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | bool unerle(std::istream &in, std::ostream &out) 4 | { 5 | int prev, pprev; 6 | if((pprev = prev = in.get()) != EOF) { 7 | out.put(prev); 8 | for(;(prev = in.get()) != EOF; pprev = prev) { 9 | out.put(prev); 10 | if(pprev == prev) { 11 | int count = in.get(); 12 | if(count == EOF) return false; 13 | for(int i = 0; i < count; ++i) { 14 | out.put(prev); 15 | } 16 | } 17 | } 18 | } 19 | return true; 20 | } 21 | -------------------------------------------------------------------------------- /brightmoon/unlzss.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "BitReader.hpp" 3 | 4 | #define DICT_SIZE 0x2000 5 | void unlzss(std::istream &in, std::ostream &out) 6 | { 7 | unsigned char dict[DICT_SIZE]; 8 | int dictop = 1; 9 | 10 | memset(dict, 0, DICT_SIZE); 11 | BitReader reader(in); 12 | for(;;) { 13 | int flag = reader.Read(1); 14 | if(flag) { 15 | int c = reader.Read(8); 16 | out.write((char *)&c, 1); 17 | dict[dictop] = c; 18 | dictop = (dictop + 1) % DICT_SIZE; 19 | } else { 20 | int patofs = reader.Read(13); 21 | if(!patofs) return; 22 | int patlen = reader.Read(4) + 3; 23 | for(int i = 0; i < patlen; ++i) { 24 | int c = dict[(patofs + i) % DICT_SIZE]; 25 | out.write((char *)&c, 1); 26 | dict[dictop] = c; 27 | dictop = (dictop + 1) % DICT_SIZE; 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /brightmoon/vivit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "vivit.hpp" 5 | 6 | extern void unlzss(std::istream &in, std::ostream &out); 7 | 8 | VivitArchive_Base::VivitArchive_Base() 9 | { 10 | } 11 | 12 | VivitArchive_Base::~VivitArchive_Base() 13 | { 14 | } 15 | 16 | bool VivitArchive_Base::Open(const char *filename, EntryList &list) 17 | { 18 | m_file.open(filename, std::ios_base::binary); 19 | if(m_file.fail()) return false; 20 | 21 | std::ifstream::pos_type begpos = m_file.tellg(); 22 | m_file.seekg(0, std::ios_base::end); 23 | std::ifstream::pos_type endpos = m_file.tellg(); 24 | m_file.seekg(0, std::ios_base::beg); 25 | std::ifstream::pos_type filesize = endpos - begpos; 26 | 27 | uint32_t magic; 28 | m_file.read((char *)&magic, 4); 29 | if(m_file.eof()) return false; 30 | if(magic != '\x1AGBP') return false; 31 | 32 | m_file.seekg(8, std::ios_base::beg); 33 | if(m_file.fail()) return false; 34 | 35 | uint32_t count; 36 | m_file.read((char *)&count, 4); 37 | if(m_file.eof()) return false; 38 | 39 | for(uint32_t i = 0; i < count; ++i) { 40 | Entry entry; 41 | struct { 42 | uint32_t size; 43 | uint32_t offset; 44 | uint32_t resd08; 45 | } temp; 46 | m_file.read((char *)&temp, sizeof(temp)); 47 | if(m_file.eof()) return false; 48 | std::stringstream ss; 49 | ss << "DATA" << std::setfill('0') << std::setw(4) << i; 50 | entry.origsize = temp.size; 51 | entry.offset = temp.offset; 52 | entry.resd08 = temp.resd08; 53 | entry.name = ss.str(); 54 | list.push_back(entry); 55 | } 56 | EntryList::iterator it = list.begin(); 57 | EntryList::iterator next = list.begin(); 58 | for(++next; next != list.end(); ++it, ++next) 59 | { 60 | it->compsize = next->offset - it->offset; 61 | } 62 | it->compsize = static_cast(filesize) - it->offset; 63 | return true; 64 | } 65 | 66 | 67 | bool VivitArchive_Base::Extract(EntryList::iterator &entry, std::ostream &os, bool (*callback)(const char *, void *), void * user) 68 | { 69 | if(callback) { 70 | if(!callback(entry->GetEntryName(), user)) return false; 71 | if(!callback(" extracting...", user)) return false; 72 | } 73 | m_file.seekg(entry->offset, std::ios_base::beg); 74 | unlzss(m_file, os); 75 | if(m_file.bad()) { 76 | if(callback) { 77 | if(!callback("unexpected error occured.\r\nplease restart.\r\n", user)) return false; 78 | } 79 | return false; 80 | } 81 | if(callback) { 82 | if(!callback("finished.\r\n", user)) return false; 83 | } 84 | return true; 85 | } 86 | -------------------------------------------------------------------------------- /brightmoon/vivit.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VIVIT_HPP 2 | #define VIVIT_HPP 3 | 4 | #include 5 | #include "arctmp.hpp" 6 | 7 | /* Vivit archive don't have any filenames... */ 8 | class VivitArchive_Base 9 | { 10 | protected: 11 | struct Entry { 12 | uint32_t origsize; 13 | uint32_t compsize; 14 | uint32_t offset; 15 | uint32_t resd08; /* what does this mean...? */ 16 | std::string name; 17 | 18 | inline uint32_t GetOriginalSize() { return origsize; } 19 | inline uint32_t GetCompressedSize() { return compsize; } 20 | inline const char * GetEntryName() { return name.c_str(); } 21 | 22 | bool operator==(const char *rhs) { 23 | return std::strcmp(name.c_str(), rhs) == 0; 24 | } 25 | }; 26 | 27 | typedef std::list EntryList; 28 | 29 | protected: 30 | VivitArchive_Base(); 31 | virtual ~VivitArchive_Base(); 32 | 33 | protected: 34 | bool Open(const char *filename, EntryList &list); 35 | bool Extract(EntryList::iterator &itearotr, std::ostream &os, bool (*callback)(const char *, void *), void * user); 36 | 37 | private: 38 | std::ifstream m_file; 39 | }; 40 | 41 | typedef PBGArchiveTemplate VivitArchive; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /brightmoon/xor.hpp: -------------------------------------------------------------------------------- 1 | #ifndef XOR_HPP 2 | #define XOR_HPP 3 | 4 | #include // EOF, WOULD_BLOCK 5 | #include // input_filter_tag 6 | #include // get 7 | 8 | struct xor_input_filter { 9 | typedef char char_type; 10 | typedef boost::iostreams::input_filter_tag category; 11 | 12 | xor_input_filter(int x) : x_(x) {} 13 | 14 | template 15 | int get(Source& src) 16 | { 17 | int c = boost::iostreams::get(src); 18 | return c == EOF ? EOF : c ^ x_; 19 | } 20 | 21 | int x_; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /brightmoon/yumemi.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kghost/th123_toolset/d6285d65576d3cb4a1a7dbfab4b211b09ece9616/brightmoon/yumemi.cpp -------------------------------------------------------------------------------- /brightmoon/yumemi.hpp: -------------------------------------------------------------------------------- 1 | #ifndef YUMEMI_HPP 2 | #define YUMEMI_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include "stdint.h" 8 | #include "arctmp.hpp" 9 | 10 | class YumemiArchive_Base 11 | { 12 | protected: 13 | struct Entry { 14 | uint32_t offset; 15 | uint16_t compsize; 16 | uint16_t origsize; 17 | uint8_t key; 18 | char name[13]; 19 | 20 | inline uint32_t GetOriginalSize() { return origsize; } 21 | inline uint32_t GetCompressedSize() { return compsize; } 22 | inline const char * GetEntryName() { return name; } 23 | 24 | bool operator==(const char *rhs) { 25 | return std::strcmp(name, rhs) == 0; 26 | } 27 | }; 28 | 29 | typedef std::list EntryList; 30 | 31 | protected: 32 | YumemiArchive_Base(); 33 | virtual ~YumemiArchive_Base(); 34 | 35 | protected: 36 | bool Open(const char *filename, EntryList &list); 37 | bool Extract(EntryList::iterator &it, std::ostream &os, bool (*callback)(const char *, void *), void * user); 38 | 39 | private: 40 | bool DeserializeList(std::istream &is, uint32_t list_count, uint32_t filesize, EntryList &list); 41 | static bool ValidateName(const char *name); 42 | 43 | private: 44 | std::ifstream m_file; 45 | }; 46 | 47 | typedef PBGArchiveTemplate YumemiArchive; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /brightmoon/yumemicrypt.hpp: -------------------------------------------------------------------------------- 1 | #ifndef YUMEMICRYPT_HPP 2 | #define YUMEMICRYPT_HPP 3 | 4 | #include // EOF, WOULD_BLOCK 5 | #include // input_filter_tag 6 | #include // get 7 | 8 | struct yumemicrypt_input_filter { 9 | typedef char char_type; 10 | typedef boost::iostreams::input_filter_tag category; 11 | 12 | yumemicrypt_input_filter(unsigned char x) : x_(x) {} 13 | 14 | template 15 | int get(Source& src) 16 | { 17 | int c = boost::iostreams::get(src); 18 | if(c != EOF) { 19 | c ^= x_; 20 | x_ -= c; 21 | } 22 | return c; 23 | } 24 | 25 | unsigned char x_; 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /brightmoon/yuyuko.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "yuyuko.hpp" 4 | 5 | extern void unlzss(std::istream &in, std::ostream &out); 6 | 7 | YuyukoArchive_Base::YuyukoArchive_Base() 8 | { 9 | } 10 | 11 | YuyukoArchive_Base::~YuyukoArchive_Base() 12 | { 13 | } 14 | 15 | bool YuyukoArchive_Base::Open(const char *filename, EntryList &list) 16 | { 17 | m_file.open(filename, std::ios_base::binary); 18 | if(m_file.fail()) return false; 19 | 20 | std::ifstream::pos_type begpos = m_file.tellg(); 21 | m_file.seekg(0, std::ios_base::end); 22 | std::ifstream::pos_type endpos = m_file.tellg(); 23 | m_file.seekg(0, std::ios_base::beg); 24 | std::ifstream::pos_type filesize = endpos - begpos; 25 | 26 | uint32_t magic; 27 | m_file.read((char *)&magic, 4); 28 | if(m_file.eof()) return false; 29 | if(magic != '4GBP') return false; 30 | 31 | uint32_t filecount; 32 | uint32_t listoffset; 33 | uint32_t listsize; 34 | m_file.read((char *)&filecount, 4); 35 | if(m_file.eof()) return false; 36 | m_file.read((char *)&listoffset, 4); 37 | if(m_file.eof()) return false; 38 | m_file.read((char *)&listsize, 4); 39 | if(m_file.eof()) return false; 40 | if(listoffset >= filesize) return false; 41 | 42 | m_file.seekg(listoffset, std::ios_base::beg); 43 | 44 | std::strstream listbuf; 45 | unlzss(m_file, listbuf); 46 | if(m_file.bad()) return false; 47 | 48 | std::streamsize listbufsize = listbuf.pcount(); 49 | if(listsize > listbufsize) return false; 50 | 51 | for(int i = 0; i < filecount; ++i) { 52 | Entry entry; 53 | for(;;) { 54 | char c; 55 | listbuf.read(&c, 1); 56 | if(listbuf.fail()) return false; 57 | if(!c) break; 58 | entry.name.push_back(c); 59 | } 60 | listbuf.read((char *)&entry.offset, 4); 61 | if(listbuf.fail()) return false; 62 | listbuf.read((char *)&entry.origsize, 4); 63 | if(listbuf.fail()) return false; 64 | if(entry.offset >= filesize) return false; 65 | char dummy[4]; 66 | listbuf.read(dummy, 4); // zero padding 67 | if(listbuf.fail()) return false; 68 | list.push_back(entry); 69 | } 70 | EntryList::iterator it = list.begin(); 71 | EntryList::iterator next = list.begin(); 72 | for(++next; next != list.end(); ++it, ++next) 73 | { 74 | it->compsize = next->offset - it->offset; 75 | } 76 | it->compsize = listoffset - it->offset; 77 | return true; 78 | } 79 | 80 | bool YuyukoArchive_Base::Extract(EntryList::iterator &entry, std::ostream &os, bool (*callback)(const char *, void *), void * user) 81 | { 82 | if(callback) { 83 | if(!callback(entry->GetEntryName(), user)) return false; 84 | if(!callback(" extracting...", user)) return false; 85 | } 86 | m_file.clear(); 87 | m_file.seekg(entry->offset, std::ios_base::beg); 88 | if(m_file.fail()) return false; 89 | unlzss(m_file, os); 90 | if(m_file.bad()) { 91 | if(callback) { 92 | if(!callback("unexpected error occured.\r\nplease restart.\r\n", user)) return false; 93 | } 94 | return false; 95 | } 96 | if(callback) { 97 | if(!callback("finished.\r\n", user)) return false; 98 | } 99 | return true; 100 | } 101 | -------------------------------------------------------------------------------- /brightmoon/yuyuko.hpp: -------------------------------------------------------------------------------- 1 | #ifndef YUYUKO_HPP 2 | #define YUYUKO_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "stdint.h" 9 | #include "arctmp.hpp" 10 | 11 | class YuyukoArchive_Base 12 | { 13 | protected: 14 | struct Entry { 15 | uint32_t offset; 16 | uint32_t compsize; 17 | uint32_t origsize; 18 | std::string name; 19 | 20 | inline uint32_t GetOriginalSize() { return origsize; } 21 | inline uint32_t GetCompressedSize() { return compsize; } 22 | inline const char * GetEntryName() { return name.c_str(); } 23 | 24 | bool operator==(const char *rhs) { 25 | return std::strcmp(name.c_str(), rhs) == 0; 26 | } 27 | }; 28 | 29 | typedef std::list EntryList; 30 | 31 | protected: 32 | YuyukoArchive_Base(); 33 | virtual ~YuyukoArchive_Base(); 34 | 35 | protected: 36 | bool Open(const char *filename, EntryList &list); 37 | bool Extract(EntryList::iterator &entry, std::ostream &os, bool (*callback)(const char *, void *), void * user); 38 | 39 | private: 40 | std::ifstream m_file; 41 | }; 42 | 43 | typedef PBGArchiveTemplate YuyukoArchive; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /convcv0/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : convcv0 Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this convcv0 application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your convcv0 application. 9 | 10 | 11 | convcv0.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | convcv0.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named convcv0.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /convcv0/convcv0.cpp: -------------------------------------------------------------------------------- 1 | // convcv0.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | void process_file (std::string input) 12 | { 13 | unsigned char a = 0x8b; 14 | unsigned char b = 0x71; 15 | 16 | FILE* i = fopen (input.c_str(), "rb"); 17 | std::string output = input.substr(0, input.length() - 3) + "cv0"; 18 | FILE* o = fopen (output.c_str(), "wb"); 19 | 20 | int c; 21 | while ((c = fgetc(i)) != EOF) { 22 | c ^= a; 23 | fputc(c, o); 24 | a += b; 25 | b -= 0x6b; 26 | } 27 | 28 | fclose (i); 29 | fclose (o); 30 | 31 | DeleteFile (input.c_str()); 32 | } 33 | 34 | void find_file (std::string path) 35 | { 36 | WIN32_FIND_DATA FindFileData; 37 | HANDLE hFind = FindFirstFile ((path + "*.txt").c_str(), &FindFileData); 38 | if (hFind == INVALID_HANDLE_VALUE) { 39 | int i = GetLastError(); 40 | if (i != 2) printf ("FindFirstFile file failed %s (%d)\n", path.c_str(), i); 41 | return; 42 | } 43 | 44 | do { 45 | if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { 46 | continue; 47 | } 48 | 49 | process_file (path + std::string(FindFileData.cFileName)); 50 | } while (FindNextFile(hFind, &FindFileData)); 51 | FindClose(hFind); 52 | } 53 | 54 | void find_directory (std::string path) 55 | { 56 | WIN32_FIND_DATA FindFileData; 57 | HANDLE hFind = FindFirstFile ((path + "*.*").c_str(), &FindFileData); 58 | if (hFind == INVALID_HANDLE_VALUE) { 59 | printf ("FindFirstFile dir failed %s (%d)\n", path.c_str(), GetLastError()); 60 | return; 61 | } 62 | 63 | do { 64 | if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { 65 | if (strcmp(FindFileData.cFileName, ".") == 0 || strcmp(FindFileData.cFileName, "..") == 0) 66 | continue; 67 | 68 | find_file(path + std::string(FindFileData.cFileName) + '\\'); 69 | find_directory(path + std::string(FindFileData.cFileName) + '\\'); 70 | } 71 | } while (FindNextFile(hFind, &FindFileData)); 72 | FindClose(hFind); 73 | } 74 | 75 | int _tmain(int argc, _TCHAR* argv[]) 76 | { 77 | if (argc <= 1) { 78 | printf ("Usage : %s directory\n", argv[0]); 79 | return -1; 80 | } 81 | 82 | if (!SetCurrentDirectory(argv[1])) { 83 | printf ("SetCurrentDirectory error : %d\n", GetLastError()); 84 | return -1; 85 | } 86 | 87 | find_file (std::string()); 88 | find_directory (std::string()); 89 | 90 | return 0; 91 | } 92 | -------------------------------------------------------------------------------- /convcv0/convcv0.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {26CED4FE-E49B-416B-AE84-6F40FF533CBA} 15 | convcv0 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | NotSet 22 | true 23 | 24 | 25 | Application 26 | NotSet 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | <_ProjectFileVersion>10.0.30128.1 40 | $(SolutionDir)$(Configuration)\ 41 | $(Configuration)\ 42 | true 43 | $(SolutionDir)$(Configuration)\ 44 | $(Configuration)\ 45 | false 46 | 47 | 48 | 49 | Disabled 50 | E:\boost_1_38_0;%(AdditionalIncludeDirectories) 51 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | EnableFastChecks 54 | MultiThreadedDebugDLL 55 | 56 | 57 | Level3 58 | EditAndContinue 59 | 60 | 61 | true 62 | Console 63 | MachineX86 64 | 65 | 66 | 67 | 68 | MaxSpeed 69 | true 70 | D:\boost_1_38_0;%(AdditionalIncludeDirectories) 71 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 72 | MultiThreadedDLL 73 | true 74 | 75 | 76 | Level3 77 | ProgramDatabase 78 | 79 | 80 | true 81 | Console 82 | true 83 | true 84 | MachineX86 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /convcv0/convcv0.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /convcv0/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // convcv0.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /convcv0/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /convcv0/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /convcv1/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : convcv1 Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this convcv1 application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your convcv1 application. 9 | 10 | 11 | convcv1.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | convcv1.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named convcv1.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /convcv1/convcv1.cpp: -------------------------------------------------------------------------------- 1 | // convcv1.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | void process_file (std::string input) 12 | { 13 | unsigned char a = 0x8b; 14 | unsigned char b = 0x71; 15 | 16 | FILE* i = fopen (input.c_str(), "rb"); 17 | std::string output = input.substr(0, input.length() - 3) + "cv1"; 18 | FILE* o = fopen (output.c_str(), "wb"); 19 | 20 | int c; 21 | while ((c = fgetc(i)) != EOF) { 22 | c ^= a; 23 | fputc(c, o); 24 | a += b; 25 | b -= 0x6b; 26 | } 27 | 28 | fclose (i); 29 | fclose (o); 30 | 31 | DeleteFile (input.c_str()); 32 | } 33 | 34 | void find_file (std::string path) 35 | { 36 | WIN32_FIND_DATA FindFileData; 37 | HANDLE hFind = FindFirstFile ((path + "*.tx1").c_str(), &FindFileData); 38 | if (hFind == INVALID_HANDLE_VALUE) { 39 | int i = GetLastError(); 40 | if (i != 2) printf ("FindFirstFile file failed %s (%d)\n", path.c_str(), i); 41 | return; 42 | } 43 | 44 | do { 45 | if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { 46 | continue; 47 | } 48 | 49 | process_file (path + std::string(FindFileData.cFileName)); 50 | } while (FindNextFile(hFind, &FindFileData)); 51 | FindClose(hFind); 52 | } 53 | 54 | void find_directory (std::string path) 55 | { 56 | WIN32_FIND_DATA FindFileData; 57 | HANDLE hFind = FindFirstFile ((path + "*.*").c_str(), &FindFileData); 58 | if (hFind == INVALID_HANDLE_VALUE) { 59 | printf ("FindFirstFile dir failed %s (%d)\n", path.c_str(), GetLastError()); 60 | return; 61 | } 62 | 63 | do { 64 | if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { 65 | if (strcmp(FindFileData.cFileName, ".") == 0 || strcmp(FindFileData.cFileName, "..") == 0) 66 | continue; 67 | 68 | find_file(path + std::string(FindFileData.cFileName) + '\\'); 69 | find_directory(path + std::string(FindFileData.cFileName) + '\\'); 70 | } 71 | } while (FindNextFile(hFind, &FindFileData)); 72 | FindClose(hFind); 73 | } 74 | 75 | int _tmain(int argc, _TCHAR* argv[]) 76 | { 77 | if (argc <= 1) { 78 | printf ("Usage : %s directory\n", argv[0]); 79 | return -1; 80 | } 81 | 82 | if (!SetCurrentDirectory(argv[1])) { 83 | printf ("SetCurrentDirectory error : %d\n", GetLastError()); 84 | return -1; 85 | } 86 | 87 | find_file (std::string()); 88 | find_directory (std::string()); 89 | 90 | return 0; 91 | } 92 | -------------------------------------------------------------------------------- /convcv1/convcv1.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {62E6431A-4023-4F47-B505-4F7A14F0A65B} 15 | convcv1 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | NotSet 22 | true 23 | 24 | 25 | Application 26 | NotSet 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | <_ProjectFileVersion>10.0.30128.1 40 | $(SolutionDir)$(Configuration)\ 41 | $(Configuration)\ 42 | true 43 | $(SolutionDir)$(Configuration)\ 44 | $(Configuration)\ 45 | false 46 | 47 | 48 | 49 | Disabled 50 | E:\boost_1_38_0;%(AdditionalIncludeDirectories) 51 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | EnableFastChecks 54 | MultiThreadedDebugDLL 55 | 56 | 57 | Level3 58 | EditAndContinue 59 | 60 | 61 | true 62 | Console 63 | MachineX86 64 | 65 | 66 | 67 | 68 | MaxSpeed 69 | true 70 | D:\boost_1_38_0;%(AdditionalIncludeDirectories) 71 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 72 | MultiThreadedDLL 73 | true 74 | 75 | 76 | Level3 77 | ProgramDatabase 78 | 79 | 80 | true 81 | Console 82 | true 83 | true 84 | MachineX86 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /convcv1/convcv1.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /convcv1/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // convcv1.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /convcv1/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /convcv1/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /convcv2/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | using System.Drawing.Imaging; 6 | using System.Drawing; 7 | using System.Runtime.InteropServices; 8 | 9 | namespace convcv2 10 | { 11 | class Program 12 | { 13 | // ここからCV2リーダ 14 | public class CV2Reader 15 | { 16 | private CV2Header _header; 17 | Bitmap _image; 18 | public CV2Header Header 19 | { 20 | get { return _header; } 21 | } 22 | 23 | public CV2Reader(Stream input) 24 | { 25 | if (input.Length < 17) 26 | throw new IOException("ファイルが小さすぎます"); 27 | _header = CV2Header.Deserialize(input); 28 | if (_header.Height * _header.PaddedWidth * _header.Bpp > input.Length - 17) 29 | throw new IOException("ファイルが小さすぎます"); 30 | 31 | input.Seek(17, SeekOrigin.Begin); 32 | _image = new Bitmap(_header.Width, _header.Height, _header.PixelFormat); 33 | int lineSize = _header.Width * _header.Bpp; 34 | byte[] lineBuf = new byte[_header.PaddedWidth * _header.Bpp]; 35 | for (int y = 0; y < _header.Height; ++y) 36 | { 37 | input.Read(lineBuf, 0, lineBuf.Length); 38 | BitmapData data = _image.LockBits( 39 | new Rectangle(0, y, _header.Width, 1), 40 | ImageLockMode.WriteOnly, _header.PixelFormat); 41 | Marshal.Copy(lineBuf, 0, data.Scan0, lineSize); 42 | _image.UnlockBits(data); 43 | } 44 | } 45 | 46 | public Bitmap Image 47 | { 48 | get { return _image; } 49 | } 50 | } 51 | 52 | public class CV2Header 53 | { 54 | private static Dictionary pixelFormatTable 55 | = new Dictionary(); 56 | private static Dictionary bppTable 57 | = new Dictionary(); 58 | 59 | static CV2Header() 60 | { 61 | pixelFormatTable.Add(8, PixelFormat.Format8bppIndexed); 62 | pixelFormatTable.Add(16, PixelFormat.Format16bppRgb565); 63 | pixelFormatTable.Add(24, PixelFormat.Format32bppArgb); 64 | pixelFormatTable.Add(32, PixelFormat.Format32bppArgb); 65 | 66 | bppTable.Add(8, 1); 67 | bppTable.Add(16, 2); 68 | bppTable.Add(24, 4); // はぁ? 69 | bppTable.Add(32, 4); 70 | } 71 | 72 | private int _bpp; 73 | private int _width; 74 | private int _height; 75 | int _pwidth; 76 | 77 | public int bpp 78 | { 79 | get { return _bpp; } 80 | set 81 | { 82 | if (!pixelFormatTable.ContainsKey(value)) 83 | throw new FormatException("サポートしていない色深度です。"); 84 | _bpp = value; 85 | } 86 | } 87 | 88 | public int Bpp 89 | { 90 | get { return bppTable[bpp]; } 91 | } 92 | 93 | public PixelFormat PixelFormat 94 | { 95 | get { return pixelFormatTable[bpp]; } 96 | } 97 | 98 | public int Width 99 | { 100 | get { return _width; } 101 | set { _width = value; } 102 | } 103 | 104 | public int Height 105 | { 106 | get { return _height; } 107 | set { _height = value; } 108 | } 109 | 110 | public int PaddedWidth 111 | { 112 | get { return _pwidth; } 113 | set { _pwidth = value; } 114 | } 115 | 116 | public void Serialize(Binary output) 117 | { 118 | output.WriteByte((byte)bpp); 119 | output.WriteInt32(Width); 120 | output.WriteInt32(Height); 121 | output.WriteInt32(PaddedWidth); 122 | output.WriteInt32(0); 123 | } 124 | 125 | public static CV2Header Deserialize(Stream input) 126 | { 127 | CV2Header header = new CV2Header(); 128 | Binary reader = new Binary(input); 129 | header.bpp = reader.ReadByte(); 130 | header.Width = reader.ReadInt32(); 131 | header.Height = reader.ReadInt32(); 132 | header.PaddedWidth = reader.ReadInt32(); 133 | int resd1 = reader.ReadInt32(); 134 | 135 | if (header.PaddedWidth < header.Width) 136 | throw new FormatException("ヘッダーが不正です。"); 137 | return header; 138 | } 139 | } 140 | 141 | static void ProcessCV2(string inputName) 142 | { 143 | string outputName = Path.ChangeExtension(inputName, "cv2"); 144 | try 145 | { 146 | CV2Reader cv2; 147 | using (FileStream ofs = new FileStream(outputName, FileMode.Open, FileAccess.Read)) 148 | { 149 | cv2 = new CV2Reader(ofs); 150 | if (cv2.Header.bpp == 8) 151 | { 152 | throw new Exception(inputName + " : do NOT support Palette !!"); 153 | } 154 | 155 | } 156 | using (FileStream ifs = new FileStream(inputName, FileMode.Open, FileAccess.Read)) 157 | { 158 | Bitmap image = cv2.Image; 159 | Bitmap inputImage = (Bitmap)Image.FromStream(ifs); 160 | using (FileStream ofs = new FileStream(outputName, FileMode.Create, FileAccess.Write)) 161 | { 162 | Binary ob = new Binary(ofs); 163 | cv2.Header.Serialize(ob); 164 | System.Console.WriteLine(inputName + " --> " + outputName); 165 | for (int x = 0; x < cv2.Header.Height; x++) 166 | for (int y = 0; y < cv2.Header.PaddedWidth; y++) 167 | { 168 | if (y < cv2.Header.Width) 169 | { 170 | Color c = inputImage.GetPixel(y, x); 171 | switch (cv2.Header.bpp) 172 | { 173 | case 8: 174 | throw new Exception(inputName + " : do NOT support Palette !!"); 175 | case 16: 176 | { 177 | short b = (short)((c.R>>3) << 11 | (c.G>>2) << 5 | (c.B>>3)); 178 | ob.WriteInt16(b); 179 | break; 180 | } 181 | case 24: 182 | { 183 | int b = 255<<24 | c.R << 16 | c.G << 8 | c.B; 184 | ob.WriteInt32(b); 185 | break; 186 | } 187 | case 32: 188 | { 189 | int b = c.A << 24 | c.R << 16 | c.G << 8 | c.B; 190 | ob.WriteInt32(b); 191 | break; 192 | } 193 | default: 194 | throw new Exception(inputName + " : unknown bpp !!"); 195 | } 196 | } 197 | else 198 | { 199 | switch (cv2.Header.bpp) 200 | { 201 | case 8: 202 | throw new Exception(inputName + " : do NOT support Palette !!"); 203 | case 16: 204 | ob.WriteInt16(0); 205 | break; 206 | case 24: 207 | ob.WriteInt32(0); 208 | break; 209 | case 32: 210 | ob.WriteInt32(0); 211 | break; 212 | default: 213 | throw new Exception(inputName + " : unknown bpp !!"); 214 | } 215 | } 216 | } 217 | } 218 | } 219 | File.Delete(inputName); 220 | } 221 | catch (Exception e) 222 | { 223 | System.Console.Error.Write(e.Message); 224 | } 225 | } 226 | 227 | static void ProcessCV2Directory(string dirName) 228 | { 229 | SearchOption searchOpt = SearchOption.AllDirectories; 230 | string[] files = Directory.GetFiles(dirName, "*.png", searchOpt); 231 | foreach (string fileName in files) 232 | { 233 | ProcessCV2(fileName); 234 | } 235 | } 236 | 237 | static void Main(string[] args) 238 | { 239 | if (args.Length < 1) 240 | { 241 | return; 242 | } 243 | try 244 | { 245 | FileAttributes attr = File.GetAttributes(args[0]); 246 | if ((attr & FileAttributes.Directory) != 0) 247 | { 248 | ProcessCV2Directory(args[0]); 249 | } 250 | else 251 | { 252 | ProcessCV2(args[0]); 253 | } 254 | } 255 | catch (Exception e) 256 | { 257 | System.Console.Error.Write(e.Message); 258 | } 259 | finally 260 | { 261 | System.Console.WriteLine("Press ENTER to continue..."); 262 | System.Console.ReadLine(); 263 | } 264 | } 265 | 266 | public class Binary 267 | { 268 | public Stream BaseStream = null; 269 | 270 | public Binary(Stream s) 271 | { 272 | BaseStream = s; 273 | } 274 | 275 | public void ReadBytes(byte[] buff, int offset, int count) 276 | { 277 | BaseStream.Read(buff, offset, count); 278 | } 279 | 280 | public byte[] ReadBytes(int count) 281 | { 282 | byte[] buff = new byte[count]; 283 | BaseStream.Read(buff, 0, count); 284 | return buff; 285 | } 286 | 287 | public void WriteBytes(byte[] buff) 288 | { 289 | BaseStream.Write(buff, 0, buff.Length); 290 | } 291 | 292 | public int ReadByte() 293 | { 294 | return BaseStream.ReadByte(); 295 | } 296 | 297 | public short ReadInt16() 298 | { 299 | return BitConverter.ToInt16(ReadBytesInternal(2), 0); 300 | } 301 | 302 | public int ReadInt32() 303 | { 304 | return BitConverter.ToInt32(ReadBytesInternal(4), 0); 305 | } 306 | 307 | public ushort ReadUInt16() 308 | { 309 | return BitConverter.ToUInt16(ReadBytesInternal(2), 0); 310 | } 311 | 312 | public uint ReadUInt32() 313 | { 314 | return BitConverter.ToUInt32(ReadBytesInternal(4), 0); 315 | } 316 | 317 | public float ReadSingle() 318 | { 319 | return BitConverter.ToSingle(ReadBytesInternal(4), 0); 320 | } 321 | 322 | public void WriteByte(byte x) 323 | { 324 | byte[] b = new byte[1]; 325 | b[0] = x; 326 | WriteBytesInternal(b); 327 | } 328 | 329 | public void WriteInt16(short x) 330 | { 331 | WriteBytesInternal(BitConverter.GetBytes(x)); 332 | } 333 | 334 | public void WriteInt32(int x) 335 | { 336 | WriteBytesInternal(BitConverter.GetBytes(x)); 337 | } 338 | 339 | public void WriteUInt16(ushort x) 340 | { 341 | WriteBytesInternal(BitConverter.GetBytes(x)); 342 | } 343 | 344 | public void WriteUInt32(uint x) 345 | { 346 | WriteBytesInternal(BitConverter.GetBytes(x)); 347 | } 348 | 349 | public void WriteSingle(float x) 350 | { 351 | WriteBytesInternal(BitConverter.GetBytes(x)); 352 | } 353 | 354 | private byte[] ReadBytesInternal(int count) 355 | { 356 | byte[] buff = ReadBytes(count); 357 | //Array.Reverse(buff); 358 | return buff; 359 | } 360 | 361 | private void WriteBytesInternal(byte[] buff) 362 | { 363 | //Array.Reverse(buff); 364 | WriteBytes(buff); 365 | } 366 | } 367 | } 368 | } 369 | -------------------------------------------------------------------------------- /convcv2/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("convcv2")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("convcv2")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2008")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("23bf6df0-70a0-4851-9b4f-be421e64f717")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /convcv2/convcv2.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.21022 7 | 2.0 8 | {0743A614-4ED9-433C-9AA5-CD3440DB354E} 9 | Exe 10 | Properties 11 | convcv2 12 | convcv2 13 | v3.5 14 | 512 15 | 16 | 17 | 3.5 18 | 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 53 | -------------------------------------------------------------------------------- /cv0conv/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : cv0conv Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this cv0conv application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your cv0conv application. 9 | 10 | 11 | cv0conv.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | cv0conv.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named cv0conv.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /cv0conv/cv0conv.cpp: -------------------------------------------------------------------------------- 1 | // cv0conv.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | void process_file (std::string file_name) 12 | { 13 | unsigned char a = 0x8b; 14 | unsigned char b = 0x71; 15 | 16 | FILE* i = fopen (file_name.c_str(), "rb"); 17 | file_name = file_name.substr(0, file_name.length() - 3) + "txt"; 18 | FILE* o = fopen (file_name.c_str(), "wb"); 19 | 20 | int c; 21 | while ((c = fgetc(i)) != EOF) { 22 | c ^= a; 23 | fputc(c, o); 24 | a += b; 25 | b -= 0x6b; 26 | } 27 | 28 | fclose (i); 29 | fclose (o); 30 | } 31 | 32 | void find_file (std::string path) 33 | { 34 | WIN32_FIND_DATA FindFileData; 35 | HANDLE hFind = FindFirstFile ((path + "*.cv0").c_str(), &FindFileData); 36 | if (hFind == INVALID_HANDLE_VALUE) { 37 | int i = GetLastError(); 38 | if (i != 2) printf ("FindFirstFile file failed %s (%d)\n", path.c_str(), i); 39 | return; 40 | } 41 | 42 | do { 43 | if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { 44 | continue; 45 | } 46 | 47 | process_file (path + std::string(FindFileData.cFileName)); 48 | } while (FindNextFile(hFind, &FindFileData)); 49 | FindClose(hFind); 50 | } 51 | 52 | void find_directory (std::string path) 53 | { 54 | WIN32_FIND_DATA FindFileData; 55 | HANDLE hFind = FindFirstFile ((path + "*.*").c_str(), &FindFileData); 56 | if (hFind == INVALID_HANDLE_VALUE) { 57 | printf ("FindFirstFile dir failed %s (%d)\n", path.c_str(), GetLastError()); 58 | return; 59 | } 60 | 61 | do { 62 | if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { 63 | if (strcmp(FindFileData.cFileName, ".") == 0 || strcmp(FindFileData.cFileName, "..") == 0) 64 | continue; 65 | 66 | find_file(path + std::string(FindFileData.cFileName) + '\\'); 67 | find_directory(path + std::string(FindFileData.cFileName) + '\\'); 68 | } 69 | } while (FindNextFile(hFind, &FindFileData)); 70 | FindClose(hFind); 71 | } 72 | 73 | int _tmain(int argc, _TCHAR* argv[]) 74 | { 75 | if (argc <= 1) { 76 | printf ("Usage : %s directory\n", argv[0]); 77 | return -1; 78 | } 79 | 80 | if (!SetCurrentDirectory(argv[1])) { 81 | printf ("SetCurrentDirectory error : %d\n", GetLastError()); 82 | return -1; 83 | } 84 | 85 | find_file (std::string()); 86 | find_directory (std::string()); 87 | 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /cv0conv/cv0conv.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {56A5440C-A4D6-4876-A2EA-694CB616D464} 15 | cv0conv 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | NotSet 22 | true 23 | 24 | 25 | Application 26 | NotSet 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | <_ProjectFileVersion>10.0.30128.1 40 | $(SolutionDir)$(Configuration)\ 41 | $(Configuration)\ 42 | true 43 | $(SolutionDir)$(Configuration)\ 44 | $(Configuration)\ 45 | false 46 | 47 | 48 | 49 | Disabled 50 | E:\boost_1_38_0;%(AdditionalIncludeDirectories) 51 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | EnableFastChecks 54 | MultiThreadedDebugDLL 55 | 56 | 57 | Level3 58 | EditAndContinue 59 | 60 | 61 | true 62 | Console 63 | MachineX86 64 | 65 | 66 | 67 | 68 | MaxSpeed 69 | true 70 | D:\boost_1_38_0;%(AdditionalIncludeDirectories) 71 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 72 | MultiThreadedDLL 73 | true 74 | 75 | 76 | Level3 77 | ProgramDatabase 78 | 79 | 80 | true 81 | Console 82 | true 83 | true 84 | MachineX86 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /cv0conv/cv0conv.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /cv0conv/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // cv0conv.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /cv0conv/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /cv0conv/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /cv1conv/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : cv1conv Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this cv1conv application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your cv1conv application. 9 | 10 | 11 | cv1conv.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | cv1conv.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named cv1conv.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /cv1conv/cv1conv.cpp: -------------------------------------------------------------------------------- 1 | // cv1conv.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | void process_file (std::string file_name) 12 | { 13 | unsigned char a = 0x8b; 14 | unsigned char b = 0x71; 15 | 16 | FILE* i = fopen (file_name.c_str(), "rb"); 17 | file_name = file_name.substr(0, file_name.length() - 3) + "tx1"; 18 | FILE* o = fopen (file_name.c_str(), "wb"); 19 | 20 | int c; 21 | while ((c = fgetc(i)) != EOF) { 22 | c ^= a; 23 | fputc(c, o); 24 | a += b; 25 | b -= 0x6b; 26 | } 27 | 28 | fclose (i); 29 | fclose (o); 30 | } 31 | 32 | void find_file (std::string path) 33 | { 34 | WIN32_FIND_DATA FindFileData; 35 | HANDLE hFind = FindFirstFile ((path + "*.cv1").c_str(), &FindFileData); 36 | if (hFind == INVALID_HANDLE_VALUE) { 37 | int i = GetLastError(); 38 | if (i != 2) printf ("FindFirstFile file failed %s (%d)\n", path.c_str(), i); 39 | return; 40 | } 41 | 42 | do { 43 | if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { 44 | continue; 45 | } 46 | 47 | process_file (path + std::string(FindFileData.cFileName)); 48 | } while (FindNextFile(hFind, &FindFileData)); 49 | FindClose(hFind); 50 | } 51 | 52 | void find_directory (std::string path) 53 | { 54 | WIN32_FIND_DATA FindFileData; 55 | HANDLE hFind = FindFirstFile ((path + "*.*").c_str(), &FindFileData); 56 | if (hFind == INVALID_HANDLE_VALUE) { 57 | printf ("FindFirstFile dir failed %s (%d)\n", path.c_str(), GetLastError()); 58 | return; 59 | } 60 | 61 | do { 62 | if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { 63 | if (strcmp(FindFileData.cFileName, ".") == 0 || strcmp(FindFileData.cFileName, "..") == 0) 64 | continue; 65 | 66 | find_file(path + std::string(FindFileData.cFileName) + '\\'); 67 | find_directory(path + std::string(FindFileData.cFileName) + '\\'); 68 | } 69 | } while (FindNextFile(hFind, &FindFileData)); 70 | FindClose(hFind); 71 | } 72 | 73 | int _tmain(int argc, _TCHAR* argv[]) 74 | { 75 | if (argc <= 1) { 76 | printf ("Usage : %s directory\n", argv[0]); 77 | return -1; 78 | } 79 | 80 | if (!SetCurrentDirectory(argv[1])) { 81 | printf ("SetCurrentDirectory error : %d\n", GetLastError()); 82 | return -1; 83 | } 84 | 85 | find_file (std::string()); 86 | find_directory (std::string()); 87 | 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /cv1conv/cv1conv.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {0D132E24-4084-4087-835C-E4D214AED92F} 15 | cv1conv 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | NotSet 22 | true 23 | 24 | 25 | Application 26 | NotSet 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | <_ProjectFileVersion>10.0.30128.1 40 | $(SolutionDir)$(Configuration)\ 41 | $(Configuration)\ 42 | true 43 | $(SolutionDir)$(Configuration)\ 44 | $(Configuration)\ 45 | false 46 | 47 | 48 | 49 | Disabled 50 | E:\boost_1_38_0;%(AdditionalIncludeDirectories) 51 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | EnableFastChecks 54 | MultiThreadedDebugDLL 55 | 56 | 57 | Level3 58 | EditAndContinue 59 | 60 | 61 | true 62 | Console 63 | MachineX86 64 | 65 | 66 | 67 | 68 | MaxSpeed 69 | true 70 | D:\boost_1_38_0;%(AdditionalIncludeDirectories) 71 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 72 | MultiThreadedDLL 73 | true 74 | 75 | 76 | Level3 77 | ProgramDatabase 78 | 79 | 80 | true 81 | Console 82 | true 83 | true 84 | MachineX86 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /cv1conv/cv1conv.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /cv1conv/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // cv1conv.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /cv1conv/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /cv1conv/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /cv2conv/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("cv2conv")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("cv2conv")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2008")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("5a1b078c-c4a8-4088-af65-0ede735846dd")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /cv2conv/cv2conv.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.21022 7 | 2.0 8 | {EE38F940-A7E4-4CF7-8B29-AAE727D61181} 9 | Exe 10 | Properties 11 | cv2conv 12 | cv2conv 13 | v3.5 14 | 512 15 | 16 | 17 | 3.5 18 | 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 53 | -------------------------------------------------------------------------------- /darkmoon/darkmoon.cpp: -------------------------------------------------------------------------------- 1 | // darkmoon.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "mt.hpp" 12 | 13 | class ArchiveFile { 14 | public: 15 | ArchiveFile(const std::string &name, unsigned __int32 size) 16 | { 17 | filename = name; 18 | int wlen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name.c_str(), name.size(), NULL, 0); 19 | std::vector ws(wlen); 20 | MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name.c_str(), name.size(), &ws[0], ws.size()); 21 | wlen = WideCharToMultiByte(932, 0, &ws[0], ws.size(), NULL, 0, NULL, NULL); 22 | std::vector s(wlen); 23 | WideCharToMultiByte(932, 0, &ws[0], ws.size(), &s[0], s.size(), NULL, NULL); 24 | archivename = std::string(s.begin(), s.end()); 25 | filesize = size; 26 | offset = 0; 27 | } 28 | 29 | std::string get_filename () { return filename; } 30 | std::string get_archivename () { return archivename; } 31 | unsigned __int32 get_filesize () { return filesize; } 32 | 33 | unsigned __int32 offset; 34 | private: 35 | std::string filename; 36 | std::string archivename; 37 | unsigned __int32 filesize; 38 | }; 39 | 40 | void find_file (std::list &l,std::string path) 41 | { 42 | WIN32_FIND_DATA FindFileData; 43 | HANDLE hFind = FindFirstFile ((path + "*.*").c_str(), &FindFileData); 44 | if (hFind == INVALID_HANDLE_VALUE) { 45 | printf ("FindFirstFile failed (%d) on directory %s\n", GetLastError(), path.c_str()); 46 | return; 47 | } 48 | do { 49 | if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { 50 | if (strcmp(FindFileData.cFileName, ".") == 0 || strcmp(FindFileData.cFileName, "..") == 0) 51 | continue; 52 | 53 | find_file(l, path + FindFileData.cFileName + '/'); 54 | continue; 55 | } 56 | 57 | if (FindFileData.nFileSizeHigh) { 58 | printf (TEXT("File %s too big\n"), FindFileData.cFileName); 59 | continue; 60 | } 61 | 62 | ArchiveFile a(path + FindFileData.cFileName, FindFileData.nFileSizeLow); 63 | l.push_back(a); 64 | printf (TEXT("File %s length %d\n"), a.get_filename().c_str(), a.get_filesize()); 65 | } while (FindNextFile(hFind, &FindFileData)); 66 | FindClose(hFind); 67 | } 68 | 69 | int _tmain(int argc, _TCHAR* argv[]) 70 | { 71 | if (argc <= 1) { 72 | printf ("Usage : %s directory\n", argv[0]); 73 | return -1; 74 | } 75 | 76 | int i = GetCurrentDirectory(0, NULL); 77 | 78 | boost::scoped_array dir(new (std::nothrow) TCHAR[i + 32]); 79 | if(!dir) return -1; 80 | 81 | GetCurrentDirectory(i, dir.get()); 82 | 83 | strcat(dir.get(), TEXT("/archive.dat")); 84 | 85 | if (!SetCurrentDirectory(argv[1])) { 86 | printf ("SetCurrentDirectory error : %d\n", GetLastError()); 87 | return -1; 88 | } 89 | 90 | // list files 91 | WIN32_FIND_DATA FindFileData; 92 | HANDLE hFind = FindFirstFile (TEXT("*.*"), &FindFileData); 93 | if (hFind == INVALID_HANDLE_VALUE) { 94 | printf ("FindFirstFile failed (%d)\n", GetLastError()); 95 | return -1; 96 | } 97 | 98 | std::list l; 99 | do { 100 | if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { 101 | if (strcmp(FindFileData.cFileName, ".") == 0 || strcmp(FindFileData.cFileName, "..") == 0) 102 | continue; 103 | 104 | find_file(l, std::string(FindFileData.cFileName) + '/'); 105 | continue; 106 | } 107 | 108 | if (FindFileData.nFileSizeHigh) { 109 | printf (TEXT("File %s too big\n"), FindFileData.cFileName); 110 | continue; 111 | } 112 | 113 | if (strcmp(FindFileData.cFileName, "archive.dat") == 0) 114 | continue; 115 | 116 | ArchiveFile a(std::string(FindFileData.cFileName), FindFileData.nFileSizeLow); 117 | l.push_back(a); 118 | printf (TEXT("File %s length %d\n"), a.get_filename().c_str(), a.get_filesize()); 119 | } while (FindNextFile(hFind, &FindFileData)); 120 | FindClose(hFind); 121 | 122 | // calculate header size 123 | unsigned __int32 list_size = 0; 124 | for (std::list::iterator i = l.begin(); i != l.end(); ++i) { 125 | list_size += 9 + i->get_archivename().length(); 126 | } 127 | 128 | // build header 129 | boost::scoped_array list_buf(new (std::nothrow) char[list_size]); 130 | if(!list_buf) return -1; 131 | 132 | char* p = list_buf.get(); 133 | int offset = 6 + list_size; 134 | for (std::list::iterator i = l.begin(); i != l.end(); ++i) { 135 | *reinterpret_cast(p) = offset; 136 | *reinterpret_cast(p + 4) = i->get_filesize(); 137 | i->offset = offset; 138 | offset += i->get_filesize(); 139 | int namelen = i->get_archivename().length(); 140 | *reinterpret_cast(p + 8) = namelen; 141 | memcpy(p+9, i->get_archivename().c_str(), namelen); 142 | p += 9 + namelen; 143 | } 144 | 145 | // encrypt header 146 | RNG_MT mt(list_size + 6); 147 | for(unsigned __int32 i = 0; i < list_size; ++i) 148 | list_buf[i] ^= mt.next_int32() & 0xFF; 149 | 150 | unsigned __int8 k = 0xC5, t = 0x83; 151 | for(unsigned __int32 i = 0; i < list_size; ++i) { 152 | list_buf[i] ^= k; k += t; t +=0x53; 153 | } 154 | 155 | // write header 156 | printf ("Create Archive %s\n", dir.get()); 157 | HANDLE hArchive = CreateFile (dir.get(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); 158 | if (hArchive == INVALID_HANDLE_VALUE) { 159 | printf ("CreateFile failed (%d)\n", GetLastError()); 160 | return -1; 161 | } 162 | unsigned __int16 list_count = l.size(); 163 | DWORD tmp; 164 | if (WriteFile (hArchive, &list_count, 2, &tmp, NULL) == 0) { 165 | printf ("WriteFile failed (%d)\n", GetLastError()); 166 | } 167 | if (WriteFile (hArchive, &list_size, 4, &tmp, NULL) == 0) { 168 | printf ("WriteFile failed (%d)\n", GetLastError()); 169 | } 170 | if (WriteFile (hArchive, list_buf.get(), list_size, &tmp, NULL) == 0) { 171 | printf ("WriteFile failed (%d)\n", GetLastError()); 172 | } 173 | 174 | // write files 175 | for (std::list::iterator i = l.begin(); i != l.end(); ++i) { 176 | HANDLE hFile = CreateFile (i->get_filename().c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); 177 | if (hFile == INVALID_HANDLE_VALUE) { 178 | printf ("OpenFile failed (%d)\n", GetLastError()); 179 | } 180 | 181 | boost::scoped_array file_buf(new (std::nothrow) char[i->get_filesize()]); 182 | if(!file_buf) return -1; 183 | 184 | if (ReadFile (hFile, file_buf.get(), i->get_filesize(), &tmp, NULL) == 0) { 185 | printf ("WriteFile failed (%d)\n", GetLastError()); 186 | } 187 | 188 | unsigned __int8 k = (i->offset >> 1) | 0x23; 189 | for(unsigned __int32 j = 0; j < i->get_filesize(); ++j) 190 | file_buf[j] ^= k; 191 | 192 | if (WriteFile (hArchive, file_buf.get(), i->get_filesize(), &tmp, NULL) == 0) { 193 | printf ("WriteFile failed (%d)\n", GetLastError()); 194 | } 195 | } 196 | 197 | return 0; 198 | } 199 | 200 | -------------------------------------------------------------------------------- /darkmoon/darkmoon.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {E009C72F-8F5C-475D-B3E1-3554F351FC00} 15 | darkmoon 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | NotSet 22 | true 23 | 24 | 25 | Application 26 | NotSet 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | <_ProjectFileVersion>10.0.30128.1 40 | $(SolutionDir)$(Configuration)\ 41 | $(Configuration)\ 42 | true 43 | $(SolutionDir)$(Configuration)\ 44 | $(Configuration)\ 45 | false 46 | 47 | 48 | 49 | Disabled 50 | E:\boost_1_38_0;%(AdditionalIncludeDirectories) 51 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 52 | true 53 | EnableFastChecks 54 | MultiThreadedDebugDLL 55 | Use 56 | Level3 57 | EditAndContinue 58 | 59 | 60 | true 61 | Console 62 | MachineX86 63 | 64 | 65 | 66 | 67 | MaxSpeed 68 | true 69 | D:\boost_1_38_0;%(AdditionalIncludeDirectories) 70 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 71 | MultiThreadedDLL 72 | true 73 | Use 74 | Level3 75 | ProgramDatabase 76 | 77 | 78 | true 79 | Console 80 | true 81 | true 82 | MachineX86 83 | 84 | 85 | 86 | 87 | 88 | Create 89 | Create 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /darkmoon/darkmoon.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /darkmoon/mt.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MT_HPP 2 | #define MT_HPP 3 | 4 | class RNG_MT 5 | { 6 | private: 7 | enum { 8 | N = 624, 9 | M = 397, 10 | MATRIX_A = 0x9908b0dfUL, 11 | UPPER_MASK = 0x80000000UL, 12 | LOWER_MASK = 0x7FFFFFFFUL 13 | }; 14 | 15 | private: 16 | unsigned __int32 mt[N]; 17 | __int32 mti; 18 | 19 | public: 20 | explicit RNG_MT(unsigned __int32 s) 21 | { 22 | init(s); 23 | } 24 | 25 | void init(unsigned __int32 s) 26 | { 27 | mt[0] = s; 28 | for(mti = 1; mti < N; ++mti) { 29 | mt[mti] = 30 | (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti); 31 | } 32 | } 33 | 34 | unsigned __int32 next_int32() 35 | { 36 | unsigned __int32 y; 37 | static const unsigned __int32 mag01[2]={0x0UL, MATRIX_A}; 38 | if (mti >= N) { 39 | int kk; 40 | if (mti == N+1) 41 | init(5489UL); 42 | 43 | for (kk=0;kk> 1) ^ mag01[y & 0x1UL]; 46 | } 47 | for (;kk> 1) ^ mag01[y & 0x1UL]; 50 | } 51 | y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); 52 | mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL]; 53 | 54 | mti = 0; 55 | } 56 | 57 | y = mt[mti++]; 58 | 59 | /* Tempering */ 60 | y ^= (y >> 11); 61 | y ^= (y << 7) & 0x9d2c5680UL; 62 | y ^= (y << 15) & 0xefc60000UL; 63 | y ^= (y >> 18); 64 | 65 | return y; 66 | } 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /darkmoon/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // darkmoon.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /darkmoon/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /darkmoon/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /istring/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : istring Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this istring application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your istring application. 9 | 10 | 11 | istring.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | istring.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named istring.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /istring/istring.cpp: -------------------------------------------------------------------------------- 1 | // istring.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include // For _MAX_PATH definition 7 | #include 8 | #include 9 | 10 | int mystrlen (char * s) 11 | { 12 | int i = 0; 13 | while (s[i] && !(s[i] == '\r' && s[i+1] == '\n')) i++; 14 | return i; 15 | } 16 | 17 | int _tmain(int argc, _TCHAR* argv[]) 18 | { 19 | FILE * fmod = fopen ("th123.exe", "rb+"); 20 | if (fmod == NULL) { 21 | perror ("fopen"); 22 | return -1; 23 | } 24 | 25 | FILE * fin = fopen ("strings.txt", "rb"); 26 | if (fin == NULL) { 27 | perror ("fopen"); 28 | return -1; 29 | } 30 | 31 | fseek (fin, 0, SEEK_END); 32 | long sz = ftell(fin); 33 | char * buf = (char*)malloc(sz + 1); 34 | fseek (fin, 0, SEEK_SET); 35 | fread(buf, sz, 1, fin); 36 | buf[sz] = 0; 37 | fclose (fin); 38 | 39 | int floc = 0; 40 | while (floc < sz) { 41 | int offset = 0, length = 0; 42 | for (int i = 0; i < 8; i++) { 43 | offset *= 16; 44 | if (buf[floc + i] >= 'a' && buf[floc + i] <= 'f') 45 | offset += buf[floc + i] - 'a' + 10; 46 | else if (buf[floc + i] >= '0' && buf[floc + i] <= '9') 47 | offset += buf[floc + i] - '0'; 48 | } 49 | 50 | for (int i = 0; i < 8; i++) { 51 | length *= 16; 52 | if (buf[floc + i + 9] >= 'a' && buf[floc + i + 9] <= 'f') 53 | length += buf[floc + i + 9] - 'a' + 10; 54 | else if (buf[floc + i + 9] >= '0' && buf[floc + i + 9] <= '9') 55 | length += buf[floc + i + 9] - '0'; 56 | } 57 | 58 | floc += 18; 59 | 60 | int len = mystrlen (buf + floc); 61 | 62 | char * str = (char*)malloc(len + 1); 63 | memcpy (str, buf + floc, len); 64 | str[len] = 0; 65 | floc += len; 66 | while (buf[floc] == '\r' || buf[floc] == '\n') floc++; 67 | 68 | int sz = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, -1, NULL, 0); 69 | WCHAR *o = (WCHAR*)malloc ((sz + 1)*sizeof(WCHAR)); 70 | MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, -1, o, sz); 71 | o[sz] = 0; 72 | free(str); 73 | 74 | str = (char*)malloc (length); 75 | memset(str, 0, length); 76 | WideCharToMultiByte(936, 0, o, -1, str, length, NULL, NULL); 77 | fseek(fmod, offset, SEEK_SET); 78 | if (fwrite(str, length, 1, fmod) < 0) 79 | perror ("fwrite"); 80 | free(str); 81 | free(o); 82 | } 83 | 84 | fclose (fmod); 85 | 86 | return 0; 87 | } 88 | -------------------------------------------------------------------------------- /istring/istring.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {90FF503F-4385-4E5A-BE2F-98A4F657A2BA} 15 | istring 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | Unicode 22 | true 23 | 24 | 25 | Application 26 | Unicode 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | <_ProjectFileVersion>10.0.30128.1 40 | $(SolutionDir)$(Configuration)\ 41 | $(Configuration)\ 42 | true 43 | $(SolutionDir)$(Configuration)\ 44 | $(Configuration)\ 45 | false 46 | 47 | 48 | 49 | Disabled 50 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 51 | true 52 | EnableFastChecks 53 | MultiThreadedDebugDLL 54 | 55 | 56 | Level3 57 | EditAndContinue 58 | 59 | 60 | true 61 | Console 62 | MachineX86 63 | 64 | 65 | 66 | 67 | MaxSpeed 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | MultiThreadedDLL 71 | true 72 | 73 | 74 | Level3 75 | ProgramDatabase 76 | 77 | 78 | true 79 | Console 80 | true 81 | true 82 | MachineX86 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /istring/istring.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /istring/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // istring.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /istring/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /istring/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /strings/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : strings Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this strings application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your strings application. 9 | 10 | 11 | strings.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | strings.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named strings.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /strings/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // strings.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /strings/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /strings/strings.cpp: -------------------------------------------------------------------------------- 1 | // strings.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | #include // For _MAX_PATH definition 7 | #include 8 | #include 9 | 10 | struct range { 11 | int offset; 12 | int length; 13 | }; 14 | 15 | struct range sector[] = { 16 | { 0x446000, 0x49200 }, 17 | { 0, 0 }, 18 | }; 19 | 20 | void find (FILE * fout, char *string, int offset, int length) 21 | { 22 | int start = 0, end = 0, rank = 0, first_byte = 0; 23 | unsigned char * s = (unsigned char *)string; 24 | for (int i = 0; i < length; i++) { 25 | if (first_byte) { 26 | if (s[i] >= 0x40 && s[i] <= 0xfc && s[i] != 0x7f) { 27 | if (!start) start = i - 1; 28 | rank++; 29 | first_byte = 0; 30 | continue; 31 | } else { 32 | start = 0, end = 0, rank = 0, first_byte = 0; 33 | } 34 | } 35 | 36 | if (s[i] == 0) { 37 | if (rank > 1) { 38 | char *t = (char*)malloc (i - start + 1); 39 | memcpy (t, string + start, i - start); 40 | t[i - start] = 0; 41 | 42 | int sz = MultiByteToWideChar(932, MB_PRECOMPOSED, t, -1, NULL, 0); 43 | WCHAR *o = (WCHAR*)malloc ((sz + 1)*sizeof(WCHAR)); 44 | MultiByteToWideChar(932, MB_PRECOMPOSED, t, -1, o, sz); 45 | o[sz] = 0; 46 | free(t); 47 | 48 | sz = WideCharToMultiByte(CP_ACP, 0, o, -1, NULL, 0, NULL, NULL); 49 | t = (char*)malloc (sz + 1); 50 | WideCharToMultiByte(CP_ACP, 0, o, -1, t, sz, NULL, NULL); 51 | t[sz] = 0; 52 | fprintf (fout, "%8x %8x %s\r\n", offset + start, i - start, t); 53 | free(t); 54 | free(o); 55 | } 56 | start = 0, end = 0, rank = 0, first_byte = 0; 57 | } else if (s[i] <= 0x1f || s[i] == 0x7f || s[i] == 0x80 || s[i] == 0xa0 || (s[i] >= 0xf0 && s[i] <= 0xff)) { 58 | start = 0, end = 0, rank = 0, first_byte = 0; 59 | } else if ((s[i] >= 0x81 && s[i] <= 0x9f) || (s[i] >= 0xe0 && s[i] <= 0xef)) { 60 | first_byte = s[i]; 61 | } else if (s[i] >= 0xa1 && s[i] <= 0xdf) { 62 | start = 0, end = 0, rank = 0, first_byte = 0; 63 | //if (!start) start = i; 64 | //rank++; 65 | } else { 66 | } 67 | } 68 | } 69 | 70 | int _tmain(int argc, _TCHAR* argv[]) 71 | { 72 | FILE * fin = fopen ("th123.exe", "rb"); 73 | if (fin == NULL) { 74 | perror ("fopen"); 75 | return -1; 76 | } 77 | 78 | FILE * fout = fopen ("strings.txt", "wb+"); 79 | if (fout == NULL) { 80 | perror ("fopen"); 81 | return -1; 82 | } 83 | 84 | for (int i = 0; sector[i].offset && sector[i].length; i++) { 85 | char * s = (char*)malloc (sector[i].length); 86 | fseek(fin, sector[i].offset, SEEK_SET); 87 | fread(s, sector[i].length, 1, fin); 88 | find(fout, s, sector[i].offset, sector[i].length); 89 | free(s); 90 | } 91 | 92 | fclose (fout); 93 | fclose (fin); 94 | 95 | return 0; 96 | } 97 | -------------------------------------------------------------------------------- /strings/strings.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {0D71EB93-DE1A-4FCA-A294-F38ED58CC8CC} 15 | strings 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | Unicode 22 | true 23 | 24 | 25 | Application 26 | Unicode 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | <_ProjectFileVersion>10.0.30128.1 40 | $(SolutionDir)$(Configuration)\ 41 | $(Configuration)\ 42 | true 43 | $(SolutionDir)$(Configuration)\ 44 | $(Configuration)\ 45 | false 46 | 47 | 48 | 49 | Disabled 50 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 51 | true 52 | EnableFastChecks 53 | MultiThreadedDebugDLL 54 | 55 | 56 | Level3 57 | EditAndContinue 58 | 59 | 60 | true 61 | Console 62 | MachineX86 63 | 64 | 65 | 66 | 67 | MaxSpeed 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | MultiThreadedDLL 71 | true 72 | 73 | 74 | Level3 75 | ProgramDatabase 76 | 77 | 78 | true 79 | Console 80 | true 81 | true 82 | MachineX86 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /strings/strings.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /strings/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /th123_toolkit.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "brightmoon", "brightmoon\brightmoon.vcxproj", "{424D04A8-7059-4F80-8167-8894FFB0FB77}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cv0conv", "cv0conv\cv0conv.vcxproj", "{56A5440C-A4D6-4876-A2EA-694CB616D464}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "convcv0", "convcv0\convcv0.vcxproj", "{26CED4FE-E49B-416B-AE84-6F40FF533CBA}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "convcv1", "convcv1\convcv1.vcxproj", "{62E6431A-4023-4F47-B505-4F7A14F0A65B}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "convcv2", "convcv2\convcv2.csproj", "{0743A614-4ED9-433C-9AA5-CD3440DB354E}" 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cv1conv", "cv1conv\cv1conv.vcxproj", "{0D132E24-4084-4087-835C-E4D214AED92F}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cv2conv", "cv2conv\cv2conv.csproj", "{EE38F940-A7E4-4CF7-8B29-AAE727D61181}" 17 | EndProject 18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "darkmoon", "darkmoon\darkmoon.vcxproj", "{E009C72F-8F5C-475D-B3E1-3554F351FC00}" 19 | EndProject 20 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "istring", "istring\istring.vcxproj", "{90FF503F-4385-4E5A-BE2F-98A4F657A2BA}" 21 | EndProject 22 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "strings", "strings\strings.vcxproj", "{0D71EB93-DE1A-4FCA-A294-F38ED58CC8CC}" 23 | EndProject 24 | Global 25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 26 | Debug|Any CPU = Debug|Any CPU 27 | Debug|Mixed Platforms = Debug|Mixed Platforms 28 | Debug|Win32 = Debug|Win32 29 | Release|Any CPU = Release|Any CPU 30 | Release|Mixed Platforms = Release|Mixed Platforms 31 | Release|Win32 = Release|Win32 32 | EndGlobalSection 33 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 34 | {424D04A8-7059-4F80-8167-8894FFB0FB77}.Debug|Any CPU.ActiveCfg = Debug|Win32 35 | {424D04A8-7059-4F80-8167-8894FFB0FB77}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 36 | {424D04A8-7059-4F80-8167-8894FFB0FB77}.Debug|Mixed Platforms.Build.0 = Debug|Win32 37 | {424D04A8-7059-4F80-8167-8894FFB0FB77}.Debug|Win32.ActiveCfg = Debug|Win32 38 | {424D04A8-7059-4F80-8167-8894FFB0FB77}.Debug|Win32.Build.0 = Debug|Win32 39 | {424D04A8-7059-4F80-8167-8894FFB0FB77}.Release|Any CPU.ActiveCfg = Release|Win32 40 | {424D04A8-7059-4F80-8167-8894FFB0FB77}.Release|Mixed Platforms.ActiveCfg = Release|Win32 41 | {424D04A8-7059-4F80-8167-8894FFB0FB77}.Release|Mixed Platforms.Build.0 = Release|Win32 42 | {424D04A8-7059-4F80-8167-8894FFB0FB77}.Release|Win32.ActiveCfg = Release|Win32 43 | {424D04A8-7059-4F80-8167-8894FFB0FB77}.Release|Win32.Build.0 = Release|Win32 44 | {56A5440C-A4D6-4876-A2EA-694CB616D464}.Debug|Any CPU.ActiveCfg = Debug|Win32 45 | {56A5440C-A4D6-4876-A2EA-694CB616D464}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 46 | {56A5440C-A4D6-4876-A2EA-694CB616D464}.Debug|Mixed Platforms.Build.0 = Debug|Win32 47 | {56A5440C-A4D6-4876-A2EA-694CB616D464}.Debug|Win32.ActiveCfg = Debug|Win32 48 | {56A5440C-A4D6-4876-A2EA-694CB616D464}.Debug|Win32.Build.0 = Debug|Win32 49 | {56A5440C-A4D6-4876-A2EA-694CB616D464}.Release|Any CPU.ActiveCfg = Release|Win32 50 | {56A5440C-A4D6-4876-A2EA-694CB616D464}.Release|Mixed Platforms.ActiveCfg = Release|Win32 51 | {56A5440C-A4D6-4876-A2EA-694CB616D464}.Release|Mixed Platforms.Build.0 = Release|Win32 52 | {56A5440C-A4D6-4876-A2EA-694CB616D464}.Release|Win32.ActiveCfg = Release|Win32 53 | {56A5440C-A4D6-4876-A2EA-694CB616D464}.Release|Win32.Build.0 = Release|Win32 54 | {26CED4FE-E49B-416B-AE84-6F40FF533CBA}.Debug|Any CPU.ActiveCfg = Debug|Win32 55 | {26CED4FE-E49B-416B-AE84-6F40FF533CBA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 56 | {26CED4FE-E49B-416B-AE84-6F40FF533CBA}.Debug|Mixed Platforms.Build.0 = Debug|Win32 57 | {26CED4FE-E49B-416B-AE84-6F40FF533CBA}.Debug|Win32.ActiveCfg = Debug|Win32 58 | {26CED4FE-E49B-416B-AE84-6F40FF533CBA}.Debug|Win32.Build.0 = Debug|Win32 59 | {26CED4FE-E49B-416B-AE84-6F40FF533CBA}.Release|Any CPU.ActiveCfg = Release|Win32 60 | {26CED4FE-E49B-416B-AE84-6F40FF533CBA}.Release|Mixed Platforms.ActiveCfg = Release|Win32 61 | {26CED4FE-E49B-416B-AE84-6F40FF533CBA}.Release|Mixed Platforms.Build.0 = Release|Win32 62 | {26CED4FE-E49B-416B-AE84-6F40FF533CBA}.Release|Win32.ActiveCfg = Release|Win32 63 | {26CED4FE-E49B-416B-AE84-6F40FF533CBA}.Release|Win32.Build.0 = Release|Win32 64 | {62E6431A-4023-4F47-B505-4F7A14F0A65B}.Debug|Any CPU.ActiveCfg = Debug|Win32 65 | {62E6431A-4023-4F47-B505-4F7A14F0A65B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 66 | {62E6431A-4023-4F47-B505-4F7A14F0A65B}.Debug|Mixed Platforms.Build.0 = Debug|Win32 67 | {62E6431A-4023-4F47-B505-4F7A14F0A65B}.Debug|Win32.ActiveCfg = Debug|Win32 68 | {62E6431A-4023-4F47-B505-4F7A14F0A65B}.Debug|Win32.Build.0 = Debug|Win32 69 | {62E6431A-4023-4F47-B505-4F7A14F0A65B}.Release|Any CPU.ActiveCfg = Release|Win32 70 | {62E6431A-4023-4F47-B505-4F7A14F0A65B}.Release|Mixed Platforms.ActiveCfg = Release|Win32 71 | {62E6431A-4023-4F47-B505-4F7A14F0A65B}.Release|Mixed Platforms.Build.0 = Release|Win32 72 | {62E6431A-4023-4F47-B505-4F7A14F0A65B}.Release|Win32.ActiveCfg = Release|Win32 73 | {62E6431A-4023-4F47-B505-4F7A14F0A65B}.Release|Win32.Build.0 = Release|Win32 74 | {0743A614-4ED9-433C-9AA5-CD3440DB354E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 75 | {0743A614-4ED9-433C-9AA5-CD3440DB354E}.Debug|Any CPU.Build.0 = Debug|Any CPU 76 | {0743A614-4ED9-433C-9AA5-CD3440DB354E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 77 | {0743A614-4ED9-433C-9AA5-CD3440DB354E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 78 | {0743A614-4ED9-433C-9AA5-CD3440DB354E}.Debug|Win32.ActiveCfg = Debug|Any CPU 79 | {0743A614-4ED9-433C-9AA5-CD3440DB354E}.Release|Any CPU.ActiveCfg = Release|Any CPU 80 | {0743A614-4ED9-433C-9AA5-CD3440DB354E}.Release|Any CPU.Build.0 = Release|Any CPU 81 | {0743A614-4ED9-433C-9AA5-CD3440DB354E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 82 | {0743A614-4ED9-433C-9AA5-CD3440DB354E}.Release|Mixed Platforms.Build.0 = Release|Any CPU 83 | {0743A614-4ED9-433C-9AA5-CD3440DB354E}.Release|Win32.ActiveCfg = Release|Any CPU 84 | {0D132E24-4084-4087-835C-E4D214AED92F}.Debug|Any CPU.ActiveCfg = Debug|Win32 85 | {0D132E24-4084-4087-835C-E4D214AED92F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 86 | {0D132E24-4084-4087-835C-E4D214AED92F}.Debug|Mixed Platforms.Build.0 = Debug|Win32 87 | {0D132E24-4084-4087-835C-E4D214AED92F}.Debug|Win32.ActiveCfg = Debug|Win32 88 | {0D132E24-4084-4087-835C-E4D214AED92F}.Debug|Win32.Build.0 = Debug|Win32 89 | {0D132E24-4084-4087-835C-E4D214AED92F}.Release|Any CPU.ActiveCfg = Release|Win32 90 | {0D132E24-4084-4087-835C-E4D214AED92F}.Release|Mixed Platforms.ActiveCfg = Release|Win32 91 | {0D132E24-4084-4087-835C-E4D214AED92F}.Release|Mixed Platforms.Build.0 = Release|Win32 92 | {0D132E24-4084-4087-835C-E4D214AED92F}.Release|Win32.ActiveCfg = Release|Win32 93 | {0D132E24-4084-4087-835C-E4D214AED92F}.Release|Win32.Build.0 = Release|Win32 94 | {EE38F940-A7E4-4CF7-8B29-AAE727D61181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 95 | {EE38F940-A7E4-4CF7-8B29-AAE727D61181}.Debug|Any CPU.Build.0 = Debug|Any CPU 96 | {EE38F940-A7E4-4CF7-8B29-AAE727D61181}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 97 | {EE38F940-A7E4-4CF7-8B29-AAE727D61181}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 98 | {EE38F940-A7E4-4CF7-8B29-AAE727D61181}.Debug|Win32.ActiveCfg = Debug|Any CPU 99 | {EE38F940-A7E4-4CF7-8B29-AAE727D61181}.Release|Any CPU.ActiveCfg = Release|Any CPU 100 | {EE38F940-A7E4-4CF7-8B29-AAE727D61181}.Release|Any CPU.Build.0 = Release|Any CPU 101 | {EE38F940-A7E4-4CF7-8B29-AAE727D61181}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 102 | {EE38F940-A7E4-4CF7-8B29-AAE727D61181}.Release|Mixed Platforms.Build.0 = Release|Any CPU 103 | {EE38F940-A7E4-4CF7-8B29-AAE727D61181}.Release|Win32.ActiveCfg = Release|Any CPU 104 | {E009C72F-8F5C-475D-B3E1-3554F351FC00}.Debug|Any CPU.ActiveCfg = Debug|Win32 105 | {E009C72F-8F5C-475D-B3E1-3554F351FC00}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 106 | {E009C72F-8F5C-475D-B3E1-3554F351FC00}.Debug|Mixed Platforms.Build.0 = Debug|Win32 107 | {E009C72F-8F5C-475D-B3E1-3554F351FC00}.Debug|Win32.ActiveCfg = Debug|Win32 108 | {E009C72F-8F5C-475D-B3E1-3554F351FC00}.Debug|Win32.Build.0 = Debug|Win32 109 | {E009C72F-8F5C-475D-B3E1-3554F351FC00}.Release|Any CPU.ActiveCfg = Release|Win32 110 | {E009C72F-8F5C-475D-B3E1-3554F351FC00}.Release|Mixed Platforms.ActiveCfg = Release|Win32 111 | {E009C72F-8F5C-475D-B3E1-3554F351FC00}.Release|Mixed Platforms.Build.0 = Release|Win32 112 | {E009C72F-8F5C-475D-B3E1-3554F351FC00}.Release|Win32.ActiveCfg = Release|Win32 113 | {E009C72F-8F5C-475D-B3E1-3554F351FC00}.Release|Win32.Build.0 = Release|Win32 114 | {90FF503F-4385-4E5A-BE2F-98A4F657A2BA}.Debug|Any CPU.ActiveCfg = Debug|Win32 115 | {90FF503F-4385-4E5A-BE2F-98A4F657A2BA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 116 | {90FF503F-4385-4E5A-BE2F-98A4F657A2BA}.Debug|Mixed Platforms.Build.0 = Debug|Win32 117 | {90FF503F-4385-4E5A-BE2F-98A4F657A2BA}.Debug|Win32.ActiveCfg = Debug|Win32 118 | {90FF503F-4385-4E5A-BE2F-98A4F657A2BA}.Debug|Win32.Build.0 = Debug|Win32 119 | {90FF503F-4385-4E5A-BE2F-98A4F657A2BA}.Release|Any CPU.ActiveCfg = Release|Win32 120 | {90FF503F-4385-4E5A-BE2F-98A4F657A2BA}.Release|Mixed Platforms.ActiveCfg = Release|Win32 121 | {90FF503F-4385-4E5A-BE2F-98A4F657A2BA}.Release|Mixed Platforms.Build.0 = Release|Win32 122 | {90FF503F-4385-4E5A-BE2F-98A4F657A2BA}.Release|Win32.ActiveCfg = Release|Win32 123 | {90FF503F-4385-4E5A-BE2F-98A4F657A2BA}.Release|Win32.Build.0 = Release|Win32 124 | {0D71EB93-DE1A-4FCA-A294-F38ED58CC8CC}.Debug|Any CPU.ActiveCfg = Debug|Win32 125 | {0D71EB93-DE1A-4FCA-A294-F38ED58CC8CC}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 126 | {0D71EB93-DE1A-4FCA-A294-F38ED58CC8CC}.Debug|Mixed Platforms.Build.0 = Debug|Win32 127 | {0D71EB93-DE1A-4FCA-A294-F38ED58CC8CC}.Debug|Win32.ActiveCfg = Debug|Win32 128 | {0D71EB93-DE1A-4FCA-A294-F38ED58CC8CC}.Debug|Win32.Build.0 = Debug|Win32 129 | {0D71EB93-DE1A-4FCA-A294-F38ED58CC8CC}.Release|Any CPU.ActiveCfg = Release|Win32 130 | {0D71EB93-DE1A-4FCA-A294-F38ED58CC8CC}.Release|Mixed Platforms.ActiveCfg = Release|Win32 131 | {0D71EB93-DE1A-4FCA-A294-F38ED58CC8CC}.Release|Mixed Platforms.Build.0 = Release|Win32 132 | {0D71EB93-DE1A-4FCA-A294-F38ED58CC8CC}.Release|Win32.ActiveCfg = Release|Win32 133 | {0D71EB93-DE1A-4FCA-A294-F38ED58CC8CC}.Release|Win32.Build.0 = Release|Win32 134 | EndGlobalSection 135 | GlobalSection(SolutionProperties) = preSolution 136 | HideSolutionNode = FALSE 137 | EndGlobalSection 138 | EndGlobal 139 | --------------------------------------------------------------------------------