diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 10cc551..bc94e0d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -33,6 +33,7 @@ body: label: App version description: Specify the version of APK Installer you're using. options: + - "0.0.3" - "0.0.2" - "0.0.1" - type: dropdown diff --git a/APKInstaller/AAPTForNet/AAPTool.cs b/APKInstaller/AAPTForNet/AAPTool.cs index 4fef6a0..2c4efc2 100644 --- a/APKInstaller/AAPTForNet/AAPTool.cs +++ b/APKInstaller/AAPTForNet/AAPTool.cs @@ -163,12 +163,7 @@ public async Task DecompileAsync(StorageFile file) if (file.FileType.Equals(".apk", StringComparison.OrdinalIgnoreCase)) { - if (!HasDumpOverride ? !file.Path.StartsWith(LocalPath, StringComparison.OrdinalIgnoreCase) - : !(file.Path.StartsWith(LocalPath, StringComparison.OrdinalIgnoreCase) - || await file.GetBasicPropertiesAsync().AsTask().ContinueWith(x => x.Result.Size) > 500 * 1024 * 1024)) - { - file = await CreateTempApk(file).ConfigureAwait(false); - } + file = await PrefixStorageFile(file).ConfigureAwait(false); apkList.Add(file.Path); } else @@ -248,8 +243,15 @@ public async Task DecompileAsync(StorageFile file) return baseApk; } - private static async Task CreateTempApk(StorageFile sourceFile) + protected virtual async Task PrefixStorageFile(StorageFile sourceFile) { + if (HasDumpOverride ? sourceFile.Path.StartsWith(LocalPath, StringComparison.OrdinalIgnoreCase) + || await sourceFile.GetBasicPropertiesAsync().AsTask().ContinueWith(x => x.Result.Size) > 500 * 1024 * 1024 + : sourceFile.Path.StartsWith(LocalPath, StringComparison.OrdinalIgnoreCase)) + { + return sourceFile; + } + if (!Directory.Exists(TempPath)) { _ = Directory.CreateDirectory(TempPath); diff --git a/APKInstaller/APKInstaller.Metadata/ServerManager.cpp b/APKInstaller/APKInstaller.Metadata/ServerManager.cpp index f4997be..8df2dbb 100644 --- a/APKInstaller/APKInstaller.Metadata/ServerManager.cpp +++ b/APKInstaller/APKInstaller.Metadata/ServerManager.cpp @@ -5,6 +5,7 @@ #include "sddl.h" #include "winrt/Windows.ApplicationModel.h" +using namespace std::chrono; using namespace Windows::ApplicationModel; namespace winrt::APKInstaller::Metadata::implementation @@ -24,7 +25,7 @@ namespace winrt::APKInstaller::Metadata::implementation m_serverManagerDestructedEvent.remove(token); } - unsigned int ServerManager::RunProcess(hstring filename, hstring command, IVector errorOutput, IVector standardOutput) + unsigned int ServerManager::RunProcess(hstring filename, hstring command, IVector errorOutput, IVector standardOutput) const { const hstring commandLine = BuildCommandLine(filename, command); @@ -108,7 +109,7 @@ namespace winrt::APKInstaller::Metadata::implementation return _exitCode; } - IAsyncOperation ServerManager::RunProcessAsync(hstring filename, hstring command, IVector errorOutput, IVector standardOutput) + IAsyncOperation ServerManager::RunProcessAsync(hstring filename, hstring command, IVector errorOutput, IVector standardOutput) const { const hstring commandLine = BuildCommandLine(filename, command); @@ -176,7 +177,7 @@ namespace winrt::APKInstaller::Metadata::implementation ReadFromPipe(parentOutputPipeHandle, standardOutput, encode); ReadFromPipe(parentErrorPipeHandle, errorOutput, encode); - if (co_await resume_on_signal(processInfo.hProcess, std::chrono::seconds(5))) + if (co_await resume_on_signal(processInfo.hProcess, seconds(5))) { TerminateProcess(processInfo.hProcess, (UINT)-1); } @@ -192,7 +193,7 @@ namespace winrt::APKInstaller::Metadata::implementation co_return _exitCode; } - IAsyncOperation ServerManager::DumpAsync(hstring filename, hstring command, DumpDelegate callback, IVector output, int encode) + IAsyncOperation ServerManager::DumpAsync(hstring filename, hstring command, DumpDelegate callback, IVector output, int encode) const { const hstring commandLine = BuildCommandLine(filename, command); @@ -267,7 +268,7 @@ namespace winrt::APKInstaller::Metadata::implementation ReadFromPipe(parentErrorPipeHandle, output, encode); end: - if (co_await resume_on_signal(processInfo.hProcess, std::chrono::seconds(5))) + if (co_await resume_on_signal(processInfo.hProcess, seconds(5))) { TerminateProcess(processInfo.hProcess, (UINT)-1); } @@ -285,7 +286,7 @@ namespace winrt::APKInstaller::Metadata::implementation bool ServerManager::EnableLoopback() const { - std::vector list = std::vector(); + vector list = vector(); HINSTANCE firewallAPI = LoadLibrary(L"FirewallAPI.dll"); if (!firewallAPI) { return false; } @@ -342,7 +343,7 @@ namespace winrt::APKInstaller::Metadata::implementation const INET_FIREWALL_APP_CONTAINER cur = arrayValue[i]; if (cur.packageFullName) { - std::wstring packageFullName = cur.packageFullName; + wstring packageFullName = cur.packageFullName; if (packageFullName.compare(fullName) == 0) { ConvertSidToStringSid(cur.appContainerSid, ¤tSid); @@ -366,7 +367,7 @@ namespace winrt::APKInstaller::Metadata::implementation if (currentSid) { - for (std::wstring left : list) + for (wstring left : list) { if (left.compare(currentSid) == 0) { @@ -381,11 +382,11 @@ namespace winrt::APKInstaller::Metadata::implementation if (NetworkIsolationSetAppContainerConfig) { - std::vector arr; + vector arr; DWORD count = 0; list.push_back(currentSid); - for (std::wstring app : list) + for (wstring app : list) { SID_AND_ATTRIBUTES sid{}; sid.Attributes = 0; diff --git a/APKInstaller/APKInstaller.Metadata/ServerManager.h b/APKInstaller/APKInstaller.Metadata/ServerManager.h index 65613ea..0472709 100644 --- a/APKInstaller/APKInstaller.Metadata/ServerManager.h +++ b/APKInstaller/APKInstaller.Metadata/ServerManager.h @@ -2,6 +2,7 @@ #include "ServerManager.g.h" +using namespace std; using namespace winrt; using namespace Windows::Foundation; using namespace Windows::Foundation::Collections; @@ -18,13 +19,12 @@ namespace winrt::APKInstaller::Metadata::implementation event_token ServerManagerDestructed(EventHandler const& handler); void ServerManagerDestructed(event_token const& token); - unsigned int RunProcess(hstring filename, hstring command, IVector errorOutput, IVector standardOutput); - IAsyncOperation RunProcessAsync(hstring filename, hstring command, IVector errorOutput, IVector standardOutput); - IAsyncOperation DumpAsync(hstring filename, hstring command, DumpDelegate callback, IVector output, int encode); + unsigned int RunProcess(hstring filename, hstring command, IVector errorOutput, IVector standardOutput) const; + IAsyncOperation RunProcessAsync(hstring filename, hstring command, IVector errorOutput, IVector standardOutput) const; + IAsyncOperation DumpAsync(hstring filename, hstring command, DumpDelegate callback, IVector output, int encode) const; bool EnableLoopback() const; private: - const DWORD defaultBufferSize = 1024; event> m_serverManagerDestructedEvent; static void CreatePipeWithSecurityAttributes(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, int nSize) @@ -89,7 +89,7 @@ namespace winrt::APKInstaller::Metadata::implementation } } - inline const hstring BuildCommandLine(const hstring fileName, const hstring command) + static const hstring BuildCommandLine(const hstring fileName, const hstring command) { // Construct a StringBuilder with the appropriate command line // to pass to CreateProcess. If the filename isn't already @@ -100,15 +100,15 @@ namespace winrt::APKInstaller::Metadata::implementation return fileNameIsQuoted ? fileName + ' ' + command : '"' + fileName + L"\" " + command; } - inline void ReadFromPipe(const HANDLE hPipeRead, const IVector output, const UINT encode) const + static void ReadFromPipe(const HANDLE hPipeRead, const IVector output, const UINT encode) { - const DWORD bufferLen = defaultBufferSize; + const DWORD bufferLen = 1024; char* buffer = new char[bufferLen]; memset(buffer, '\0', bufferLen); DWORD recLen = 0; if (output) { - std::wstringstream line = {}; + wstringstream line = {}; do { if (!ReadFile(hPipeRead, buffer, bufferLen, &recLen, NULL)) @@ -188,7 +188,7 @@ namespace winrt::APKInstaller::Metadata::implementation delete[] buffer; } - inline IAsyncAction ProcessCallback(DumpDelegate callback, hstring line, int index, bool& terminated) const + static IAsyncAction ProcessCallback(DumpDelegate callback, hstring line, int index, bool& terminated) { co_await resume_background(); try @@ -201,15 +201,15 @@ namespace winrt::APKInstaller::Metadata::implementation catch (...) {} } - inline bool ReadFromPipe(const HANDLE hPipeRead, DumpDelegate callback, const IVector output, const UINT encode) const + static const bool ReadFromPipe(const HANDLE hPipeRead, DumpDelegate callback, const IVector output, const UINT encode) { - const DWORD bufferLen = defaultBufferSize; + const DWORD bufferLen = 1024; char* buffer = new char[bufferLen]; memset(buffer, '\0', bufferLen); bool terminated = false; DWORD recLen = 0; int index = 0; - std::wstringstream line = {}; + wstringstream line = {}; do { if (!ReadFile(hPipeRead, buffer, bufferLen, &recLen, NULL)) diff --git a/APKInstaller/APKInstaller.Package/APKInstaller.Package.wapproj b/APKInstaller/APKInstaller.Package/APKInstaller.Package.wapproj index 6720a01..9bb3f73 100644 --- a/APKInstaller/APKInstaller.Package/APKInstaller.Package.wapproj +++ b/APKInstaller/APKInstaller.Package/APKInstaller.Package.wapproj @@ -50,6 +50,13 @@ $(NoWarn);NU1702 ..\APKInstaller\APKInstaller.csproj True + False + SHA256 + False + True + x86|x64|arm|arm64 + 0 + Never @@ -63,5 +70,8 @@ + + + \ No newline at end of file diff --git a/APKInstaller/APKInstaller.Package/Package.appxmanifest b/APKInstaller/APKInstaller.Package/Package.appxmanifest index 307cd5f..29b6d84 100644 --- a/APKInstaller/APKInstaller.Package/Package.appxmanifest +++ b/APKInstaller/APKInstaller.Package/Package.appxmanifest @@ -11,7 +11,7 @@ + Version="0.0.3.0" /> APK 安装程序 - UWP @@ -98,37 +98,6 @@ StorageItems - - - - - - - - - - - - - - - - - - - - + Version="0.0.3.0" /> diff --git a/APKInstaller/APKInstaller/Properties/AssemblyInfo.cs b/APKInstaller/APKInstaller/Properties/AssemblyInfo.cs index 8afa8d5..81c626c 100644 --- a/APKInstaller/APKInstaller/Properties/AssemblyInfo.cs +++ b/APKInstaller/APKInstaller/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("APKInstaller")] -[assembly: AssemblyCopyright("Copyright © 2017 - 2023 PavingBase. All rights reserved.")] +[assembly: AssemblyCopyright("Copyright © 2017 - 2024 PavingBase. All rights reserved.")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -23,6 +23,6 @@ //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.0.2.0")] -[assembly: AssemblyFileVersion("0.0.2.0")] +[assembly: AssemblyVersion("0.0.3.0")] +[assembly: AssemblyFileVersion("0.0.3.0")] [assembly: ComVisible(false)] \ No newline at end of file