Skip to content

Commit

Permalink
update 1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Majjcom committed Oct 31, 2024
1 parent d64a9e3 commit 32ec6c2
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ncmppGui/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<manifest package="site.majjcom.ncmppgui" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.3.0" android:versionCode="100300000" android:installLocation="auto">
<manifest package="site.majjcom.ncmppgui" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.3.1" android:versionCode="100300100" android:installLocation="auto">


<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Expand Down
3 changes: 2 additions & 1 deletion ncmppGui/ncmppGui.pro
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ INCLUDEPATH += $$PWD/material-ui
win32:!win32-g++: PRE_TARGETDEPS += \
$$PWD/ext/lib/libssl_static.lib \
$$PWD/ext/lib/libcrypto_static.lib
android: include(E:/Android/android-sdk-windows/android_openssl/openssl_use_armv7.pri)
android: include(E:/Android/android-sdk-windows/android_openssl/openssl_use_armv8.pri)

android: DISTFILES += \
android/AndroidManifest.xml \
Expand All @@ -74,3 +74,4 @@ android: DISTFILES += \
android/res/values/libs.xml

ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
android: include(E:/Android/android-sdk-windows/android_openssl/openssl.pri)
111 changes: 111 additions & 0 deletions ncmppGui/src/ncmdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <QUrl>
#include <QDir>

#include <cstring>

#include "ncmdump.h"
#include <sstream>
#include "openssl/aes.h"
Expand All @@ -20,10 +22,119 @@ using namespace std;
static char core_hex[] = "687A4852416D736F356B496E62617857";
static char mata_hex[] = "2331346C6A6B5F215C5D2630553C2728";

enum FileType
{
NcmCrypt = 0,
Mp3,
Flac,
None,
};

void hex2str(const char* src_, unsigned char* tgt_);
unsigned int little_int(const unsigned char* src_);
FileType getFileType(QString path_);
void decodeNcm(QString path_, QString out_path_);
int matchStr(char* item, const char* compaers[], int count);
void copyFileWithExt(QString path_, QString out_path_, FileType type_);

void ncm::ncmDump(QString path_, QString out_path_)
{
FileType ft = getFileType(path_);
switch (ft)
{
case NcmCrypt:
decodeNcm(path_, out_path_);
break;
case Mp3:
case Flac:
copyFileWithExt(path_, out_path_, ft);
break;
case None:
default:
break;
}
}

int matchStr(char* item, const char* compaers[], int count)
{
for (int i = 0; i < count; i++)
{
if (strcmp(item, compaers[i]) == 0)
{
return i;
}
}
return -1;
}

FileType getFileType(QString path_)
{
const char* checkbuffer[] = {
"CTENFDAM",
"ID3",
"fLaC",
};
int size = sizeof(checkbuffer) / sizeof(*checkbuffer);
int minl = strlen(checkbuffer[0]);
int maxl = strlen(checkbuffer[0]);

for (int i = 1; i < size; i++)
{
int tl = strlen(checkbuffer[i]);
if (tl < minl)
{
minl = tl;
}
if (tl > maxl)
{
maxl = tl;
}
}

QFile fp(path_);
fp.open(QIODevice::ReadOnly);
char* buffer = new char[maxl + 1];
memset(buffer, 0, maxl + 1);
int lenb = fp.read(buffer, minl);
int res = matchStr(buffer, (const char**)checkbuffer, size);

while (res < 0 && lenb < maxl)
{
lenb += fp.read(buffer + lenb, 1);
res = matchStr(buffer, (const char**)checkbuffer, size);
}

delete[] buffer;
fp.close();

return (FileType)res;
}

void copyFileWithExt(QString path_, QString out_path_, FileType type_)
{
QFileInfo info(path_);
QString extname = "";

switch (type_)
{
case Mp3:
extname = ".mp3";
break;
case Flac:
extname = ".flac";
break;
default:
break;
}

QString out_name = info.completeBaseName() + extname;
QDir out_dir(out_path_);
QString out_path = out_dir.filePath(out_name);

QFile::copy(path_, out_path);
}

void decodeNcm(QString path_, QString out_path_)
{
unsigned char* core_key = new unsigned char[16];
unsigned char* mata_key = new unsigned char[16];
Expand Down
17 changes: 0 additions & 17 deletions ncmppGui/ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@
<height>450</height>
</size>
</property>
<property name="font">
<font>
<family>HarmonyOS Sans SC</family>
<pointsize>11</pointsize>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="windowTitle">
<string>ncmppGui</string>
</property>
Expand Down Expand Up @@ -70,15 +62,6 @@ font: 11pt &quot;HarmonyOS Sans SC&quot;;</string>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>HarmonyOS Sans SC</family>
<pointsize>11</pointsize>
<italic>false</italic>
<bold>false</bold>
<underline>true</underline>
</font>
</property>
<property name="text">
<string>从文件夹导入ncm文件</string>
</property>
Expand Down

0 comments on commit 32ec6c2

Please sign in to comment.