diff --git a/ncmppGui/android/build.gradle b/ncmppGui/android/build.gradle index 171fe0b..3359342 100644 --- a/ncmppGui/android/build.gradle +++ b/ncmppGui/android/build.gradle @@ -1,17 +1,17 @@ buildscript { repositories { google() - jcenter() + maven { url 'https://maven.aliyun.com/repository/jcenter' } } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:7.4.2' } } repositories { google() - jcenter() + maven { url 'https://maven.aliyun.com/repository/jcenter' } } apply plugin: 'com.android.application' @@ -36,7 +36,7 @@ android { compileSdkVersion androidCompileSdkVersion.toInteger() - buildToolsVersion '28.0.3' + buildToolsVersion '31.0.0' sourceSets { main { diff --git a/ncmppGui/android/gradle/wrapper/gradle-wrapper.properties b/ncmppGui/android/gradle/wrapper/gradle-wrapper.properties index 4b7e1f3..84a0b92 100644 --- a/ncmppGui/android/gradle/wrapper/gradle-wrapper.properties +++ b/ncmppGui/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/ncmppGui/src/mainwindow.cpp b/ncmppGui/src/mainwindow.cpp index a72eadb..68f29bc 100644 --- a/ncmppGui/src/mainwindow.cpp +++ b/ncmppGui/src/mainwindow.cpp @@ -2,7 +2,6 @@ #include "ui_mainwindow.h" #include -#include "ncmdump.h" #include "getpath.h" @@ -39,7 +38,11 @@ void MainWindow::fileButtonClicked() get_home_path(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks +#ifdef Q_OS_ANDROID + | QFileDialog::DontUseNativeDialog +#endif ); + if (get.length() != 0) { ui->outDir_lineEdit->setText(get); @@ -100,6 +103,9 @@ void MainWindow::importButtonClicked() this, QStringLiteral("选择ncm文件所在的目录"), get_home_path() +#ifdef Q_OS_ANDROID + ,QFileDialog::ShowDirsOnly | QFileDialog::DontUseNativeDialog +#endif ); QDir root_dir(path); diff --git a/ncmppGui/src/ncmdump.cpp b/ncmppGui/src/ncmdump.cpp index faa2262..9bcd82b 100644 --- a/ncmppGui/src/ncmdump.cpp +++ b/ncmppGui/src/ncmdump.cpp @@ -1,16 +1,14 @@  #include +#include #include +#include #include +#include #include #include "ncmdump.h" -#ifndef Q_OS_ANDROID -#include -#endif #include -#include -#include #include "openssl/aes.h" #include "rapidjson/document.h" #include "base64.h" @@ -25,7 +23,7 @@ static char mata_hex[] = "2331346C6A6B5F215C5D2630553C2728"; void hex2str(const char* src_, unsigned char* tgt_); unsigned int little_int(const unsigned char* src_); -void ncm::ncmDump(string path_, string out_path_) +void ncm::ncmDump(QString path_, QString out_path_) { unsigned char* core_key = new unsigned char[16]; unsigned char* mata_key = new unsigned char[16]; @@ -34,18 +32,9 @@ void ncm::ncmDump(string path_, string out_path_) hex2str(core_hex, core_key); hex2str(mata_hex, mata_key); -#ifdef Q_OS_ANDROID - ifstream fp; - fp.open(path_, ios::in | ios::binary); - fp.seekg(10, ios::cur); // 8 + 2 -#else - using filesystem::path; - - ifstream fp; - path raw_path = filesystem::u8path(path_); - fp.open(raw_path, ios::in | ios::binary); - fp.seekg(10, ios::cur); // 8 + 2 -#endif + QFile fp(path_); + fp.open(QIODevice::ReadOnly); + fp.seek(fp.pos() + 10); // 8 + 2 unsigned char* key_len_bin = new unsigned char[4]; fp.read((char*)key_len_bin, 4); @@ -145,32 +134,28 @@ void ncm::ncmDump(string path_, string out_path_) rapidjson::Document& dom = *pdom; dom.Parse(mata_str.c_str(), mata_str.length()); - fp.seekg(9, ios::cur); // 4 + 5 + fp.seek(fp.pos() + 9); // 4 + 5 mata_len_bin = new unsigned char[4]; fp.read((char*)mata_len_bin, 4); mata_len = little_int(mata_len_bin); delete[] mata_len_bin; - fp.seekg(mata_len, ios::cur); + fp.seek(fp.pos() + mata_len); string extname = '.' + string(dom["format"].GetString()); -#ifdef Q_OS_ANDROID - QFileInfo info(QString::fromUtf8(path_.c_str())); + QFileInfo info(path_); QString out_name = info.baseName() + extname.c_str(); - QDir out_p(out_path_.c_str()); - string tgt = out_p.absoluteFilePath(out_name).toUtf8().toStdString(); -#else - path tgt = filesystem::u8path(out_path_) / filesystem::u8path(raw_path.stem().u8string() + extname); -#endif + QDir out_p(out_path_); + QString tgt = out_p.absoluteFilePath(out_name); delete pdom; - ofstream of; - of.open(tgt, ios::out | ios::binary); + QFile of(tgt); + of.open(QIODevice::WriteOnly); unsigned char* buff = new unsigned char[0x8000]; - fp.read((char*)buff, 0x8000); - unsigned int buff_len = (unsigned int)fp.gcount(); + + unsigned int buff_len = (unsigned int)fp.read((char*)buff, 0x8000); while (buff_len) { for (unsigned int i = 1; i <= buff_len; i++) @@ -179,8 +164,7 @@ void ncm::ncmDump(string path_, string out_path_) buff[i - 1] ^= key_box[(key_box[j] + key_box[(key_box[j] + j) & 0xff]) & 0xff]; } of.write((char*)buff, buff_len); - fp.read((char*)buff, 0x8000); - buff_len = (unsigned int)fp.gcount(); + buff_len = (unsigned int)fp.read((char*)buff, 0x8000); } of.close(); fp.close(); diff --git a/ncmppGui/src/ncmdump.h b/ncmppGui/src/ncmdump.h index 3ac6535..584d7e2 100644 --- a/ncmppGui/src/ncmdump.h +++ b/ncmppGui/src/ncmdump.h @@ -1,8 +1,8 @@ #pragma once -#include +#include namespace ncm { - void ncmDump(std::string path, std::string outPath); + void ncmDump(QString path, QString outPath); } diff --git a/ncmppGui/src/unlocker.cpp b/ncmppGui/src/unlocker.cpp index 29e645b..d6efa7b 100644 --- a/ncmppGui/src/unlocker.cpp +++ b/ncmppGui/src/unlocker.cpp @@ -20,9 +20,7 @@ void Unlocker::run() { using std::string; QString file = this->list_obj->getNextFile(); - string src = file.toUtf8().toStdString(); - string tgt = this->out_dir.toUtf8().toStdString(); - ncm::ncmDump(src, tgt); + ncm::ncmDump(file, this->out_dir); emit this->unlocked(i + 1, count); } this->exit();