├── .gitignore
├── .gitmodules
├── .idea
└── .idea.EfsTools
│ ├── .idea
│ ├── .gitignore
│ ├── encodings.xml
│ ├── indexLayout.xml
│ ├── misc.xml
│ ├── vagrant.xml
│ └── vcs.xml
│ └── riderModule.iml
├── .vs
└── config
│ └── applicationhost.config
├── .vscode
├── launch.json
└── tasks.json
├── Changelog.txt
├── EfsTools.sln
├── EfsTools
├── App.config
├── Attributes
│ ├── AttributesAttribute.cs
│ ├── ConvertEndianAttribute.cs
│ ├── EfsFileAttribute.cs
│ ├── IgnoreItemAttribute.cs
│ ├── LineEndingAttribute.cs
│ ├── NvItemIdAttribute.cs
│ ├── RequiredAttribute.cs
│ └── SubscriptionAttribute.cs
├── CommandLineOptions
│ ├── EfsCreateDirectoryOptions.cs
│ ├── EfsDeleteDirectoryOptions.cs
│ ├── EfsDeleteFileOptions.cs
│ ├── EfsDownloadDirectoryOptions.cs
│ ├── EfsFixFileNamesOptions.cs
│ ├── EfsListDirectoryOptions.cs
│ ├── EfsReadFileOptions.cs
│ ├── EfsRenameFileOptions.cs
│ ├── EfsUploadDirectoryOptions.cs
│ ├── EfsWriteFileOptions.cs
│ ├── ExtractMbnOptions.cs
│ ├── GetEfsInfoOptions.cs
│ ├── GetLogsOptions.cs
│ ├── GetModemConfigOptions.cs
│ ├── GetTargetInfoOptions.cs
│ ├── Helper
│ │ └── HelpTextLocalizer.cs
│ ├── SetModemConfigOptions.cs
│ └── StartWebDavServerOptions.cs
├── CommandLineOptionsLocalization.cs
├── EfsTools.cs
├── EfsTools.csproj
├── EfsTools.csproj.user
├── EfsToolsConfigurationSection.cs
├── Items
│ ├── Base
│ │ ├── ItemBase.cs
│ │ ├── ItemsBase.cs
│ │ ├── LteBandsConfigBase.cs
│ │ ├── MultiLineStringsItemBase.cs
│ │ ├── OneValueItemBase.cs
│ │ └── WindowsMultiLineStringsItemBase.cs
│ ├── Data
│ │ └── Data.cs
│ ├── Efs
│ │ └── Efs.cs
│ ├── ItemsBinarySerializer.cs
│ ├── ItemsFactory.cs
│ ├── ItemsJsonSerializer.cs
│ └── Nv
│ │ └── Nv.cs
├── Layouts
│ ├── DateTimeLayoutRule.cs
│ ├── ILayoutRule.cs
│ ├── ILayoutRuleWithParameters.cs
│ ├── Layout.cs
│ └── TextLayoutRule.cs
├── LogLevel.cs
├── Logger.cs
├── Mbn
│ ├── ConfigurationType.cs
│ ├── ItemHeader.cs
│ ├── ItemType.cs
│ ├── MbnExtractor.cs
│ └── McfgHeader.cs
├── Program.cs
├── Properties
│ ├── PublishProfiles
│ │ └── FolderProfile.pubxml
│ └── launchSettings.json
├── Qualcomm
│ ├── HdlcSerial.cs
│ ├── QcdmCommands
│ │ ├── Attributes
│ │ │ ├── QcdmCommandAttribute.cs
│ │ │ ├── QcdmMinResponseLengthAttribute.cs
│ │ │ └── QcdmSubSystemCommandAttribute.cs
│ │ ├── Base
│ │ │ ├── EventId.cs
│ │ │ ├── LogId.cs
│ │ │ └── MessageId.cs
│ │ ├── IQcdmCommandRequest.cs
│ │ ├── IQcdmCommandResponse.cs
│ │ ├── QcdmCommand.cs
│ │ ├── QcdmCommandResponseFactory.cs
│ │ ├── QcdmDiagServCommand.cs
│ │ ├── QcdmEfsCommand.cs
│ │ ├── QcdmEfsErrors.cs
│ │ ├── QcdmPhoneMode.cs
│ │ ├── QcdmRuimConfigType.cs
│ │ ├── QcdmSubSystem.cs
│ │ ├── Requests
│ │ │ ├── BaseCommandRequest.cs
│ │ │ ├── BaseSubSystemCommandRequest.cs
│ │ │ ├── CallManager
│ │ │ │ └── CallManagerStateInfoCommandRequest.cs
│ │ │ ├── DiagServ
│ │ │ │ ├── GetDebugMessageAllocationCountRequest.cs
│ │ │ │ ├── GetDebugMessageDroppedCountRequest.cs
│ │ │ │ ├── GetEventAllocationCountRequest.cs
│ │ │ │ ├── GetEventDroppedCountRequest.cs
│ │ │ │ ├── GetLogAllocationCountRequest.cs
│ │ │ │ └── GetLogDroppedCountRequest.cs
│ │ │ ├── DiagVersionCommandRequest.cs
│ │ │ ├── Efs
│ │ │ │ ├── EfsAccessCommandRequest.cs
│ │ │ │ ├── EfsCloseDirectoryCommandRequest.cs
│ │ │ │ ├── EfsCloseFileCommandRequest.cs
│ │ │ │ ├── EfsDeviceInfoCommandRequest.cs
│ │ │ │ ├── EfsFStatFileCommandRequest.cs
│ │ │ │ ├── EfsHelloCommandRequest.cs
│ │ │ │ ├── EfsMakeDirectoryCommandRequest.cs
│ │ │ │ ├── EfsOpenDirectoryCommandRequest.cs
│ │ │ │ ├── EfsOpenFileCommandRequest.cs
│ │ │ │ ├── EfsPutItemFileCommandRequest.cs
│ │ │ │ ├── EfsQueryCommandRequest.cs
│ │ │ │ ├── EfsReadDirectoryCommandRequest.cs
│ │ │ │ ├── EfsReadFileCommandRequest.cs
│ │ │ │ ├── EfsRemoveDirectoryCommandRequest.cs
│ │ │ │ ├── EfsRenameFileCommandRequest.cs
│ │ │ │ ├── EfsStatFileCommandRequest.cs
│ │ │ │ ├── EfsSyncNoWaitCommandRequest.cs
│ │ │ │ ├── EfsUnlinkFileCommandRequest.cs
│ │ │ │ └── EfsWriteFileCommandRequest.cs
│ │ │ ├── EventMaskGetCommandRequest.cs
│ │ │ ├── EventMaskSetCommandRequest.cs
│ │ │ ├── EventReportCommandRequest.cs
│ │ │ ├── ExtMessageConfigCommandRequest.cs
│ │ │ ├── ExtentedBuildIdCommandRequest.cs
│ │ │ ├── Gsm
│ │ │ │ └── GsmVersionCommandRequest.cs
│ │ │ ├── GuidCommandRequest.cs
│ │ │ ├── LogCommandRequest.cs
│ │ │ ├── LogConfigCommandRequest.cs
│ │ │ ├── LogMaskCommandRequest.cs
│ │ │ ├── Nv
│ │ │ │ ├── NvReadCommandRequest.cs
│ │ │ │ └── NvWriteCommandRequest.cs
│ │ │ ├── PasswordCommandRequest.cs
│ │ │ ├── SpcCommandRequest.cs
│ │ │ ├── TimeCommandRequest.cs
│ │ │ └── VersionCommandRequest.cs
│ │ └── Responses
│ │ │ ├── BadCommandResponse.cs
│ │ │ ├── BadParamCommandResponse.cs
│ │ │ ├── BaseCommandResponse.cs
│ │ │ ├── BaseSubSystemCommandResponse.cs
│ │ │ ├── CallManager
│ │ │ └── CallManagerStateInfoCommandResponse.cs
│ │ │ ├── DiagServ
│ │ │ ├── GetDebugMessageAllocationCountResponse.cs
│ │ │ ├── GetDebugMessageDroppedCountResponse.cs
│ │ │ ├── GetEventAllocationCountResponse.cs
│ │ │ ├── GetEventDroppedCountResponse.cs
│ │ │ ├── GetLogAllocationCountResponse.cs
│ │ │ └── GetLogDroppedCountResponse.cs
│ │ │ ├── DiagVersionCommandResponse.cs
│ │ │ ├── Efs
│ │ │ ├── EfsAccessCommandResponse.cs
│ │ │ ├── EfsCloseDirectoryCommandResponse.cs
│ │ │ ├── EfsCloseFileCommandResponse.cs
│ │ │ ├── EfsDeviceInfoResponse.cs
│ │ │ ├── EfsFStatFileCommandResponse.cs
│ │ │ ├── EfsHelloCommandResponse.cs
│ │ │ ├── EfsMakeDirectoryCommandResponse.cs
│ │ │ ├── EfsOpenDirectoryCommandResponse.cs
│ │ │ ├── EfsOpenFileCommandResponse.cs
│ │ │ ├── EfsPutItemFileCommandResponse.cs
│ │ │ ├── EfsQueryCommandResponse.cs
│ │ │ ├── EfsReadDirectoryCommandResponse.cs
│ │ │ ├── EfsReadFileCommandResponse.cs
│ │ │ ├── EfsRemoveDirectoryCommandResponse.cs
│ │ │ ├── EfsRenameFileCommandResponse.cs
│ │ │ ├── EfsStatFileCommandResponse.cs
│ │ │ ├── EfsSyncNoWaitCommandResponse.cs
│ │ │ ├── EfsUnlinkFileCommandResponse.cs
│ │ │ └── EfsWriteFileCommandResponse.cs
│ │ │ ├── EventMaskGetCommandResponse.cs
│ │ │ ├── EventMaskSetCommandResponse.cs
│ │ │ ├── EventReportCommandResponse.cs
│ │ │ ├── ExtMessageConfigCommandResponse.cs
│ │ │ ├── ExtMsgCommandResponse.cs
│ │ │ ├── ExtentedBuildIdCommandResponse.cs
│ │ │ ├── Gsm
│ │ │ └── GsmVersionCommandResponse.cs
│ │ │ ├── GuidCommandResponse.cs
│ │ │ ├── Int32BaseSubSystemCommandResponse.cs
│ │ │ ├── LogCommandResponse.cs
│ │ │ ├── LogConfigCommandResponse.cs
│ │ │ ├── LogMaskCommandResponse.cs
│ │ │ ├── MaxResponse.cs
│ │ │ ├── MsgCommandResponse.cs
│ │ │ ├── Nv
│ │ │ ├── NvReadCommandResponse.cs
│ │ │ └── NvWriteCommandResponse.cs
│ │ │ ├── PasswordCommandResponse.cs
│ │ │ ├── SpcCommandResponse.cs
│ │ │ ├── TimeCommandResponse.cs
│ │ │ └── VersionCommandResponse.cs
│ ├── QcdmManager.cs
│ └── QcdmManagers
│ │ ├── QcdmCallManager.cs
│ │ ├── QcdmDiagServManager.cs
│ │ ├── QcdmEfsDirectory.cs
│ │ ├── QcdmEfsFileStream.cs
│ │ ├── QcdmEfsManager.cs
│ │ ├── QcdmGsmManager.cs
│ │ └── QcdmNvManager.cs
├── Resourses
│ ├── Strings.Designer.cs
│ ├── Strings.en.resx
│ ├── Strings.resx
│ └── Strings.ru.resx
├── Utils
│ ├── BitsUtils.cs
│ ├── Crc16.cs
│ ├── DateTimeUtils.cs
│ ├── EfsFileAttributeUtils.cs
│ ├── EndianConverter.cs
│ ├── EnumUtils.cs
│ ├── FileUtils.cs
│ ├── HdlcEncoder.cs
│ ├── IgnoreItemAttributeUtils.cs
│ ├── LoggerStream.cs
│ ├── NvItemIdAttributeUtils.cs
│ ├── NvItemUtils.cs
│ ├── PathUtils.cs
│ ├── QcdmCommandUtils.cs
│ ├── QcdmManagerItemWriteStreamAdapter.cs
│ ├── QcdmManagerNvWriteStreamAdapter.cs
│ ├── QcdmManagerStreamAdapter.cs
│ ├── QcdmSubSystemCommandUtils.cs
│ ├── QualcommSerialPortUtils.cs
│ ├── StreamUtils.cs
│ ├── StringUtils.cs
│ └── SubscriptionAttributeUtils.cs
└── WebDAV
│ ├── EfsFileManager.cs
│ ├── EfsStore.cs
│ ├── EfsStoreCollection.cs
│ ├── EfsStoreItem.cs
│ └── EfsStoreLockingManager.cs
├── License.RU.md
├── License.md
└── README.md
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "libs/nwebdav"]
2 | path = libs/nwebdav
3 | url = https://github.com/JohnBel/nwebdav.git
4 |
--------------------------------------------------------------------------------
/.idea/.idea.EfsTools/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Rider ignored files
5 | /projectSettingsUpdater.xml
6 | /contentModel.xml
7 | /modules.xml
8 | /.idea.EfsTools.iml
9 | # Datasource local storage ignored files
10 | /dataSources/
11 | /dataSources.local.xml
12 | # Editor-based HTTP Client requests
13 | /httpRequests/
14 |
--------------------------------------------------------------------------------
/.idea/.idea.EfsTools/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/.idea.EfsTools/.idea/indexLayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/.idea.EfsTools/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/.idea.EfsTools/.idea/vagrant.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/.idea.EfsTools/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/.idea.EfsTools/riderModule.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceFolder}/EfsTools/bin/Debug/netcoreapp3.1/EfsTools.dll",
14 | "args": [],
15 | "cwd": "${workspaceFolder}/EfsTools",
16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17 | "console": "internalConsole",
18 | "stopAtEntry": false
19 | },
20 | {
21 | "name": ".NET Core Attach",
22 | "type": "coreclr",
23 | "request": "attach",
24 | "processId": "${command:pickProcess}"
25 | }
26 | ]
27 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=733558
3 | // for the documentation about the tasks.json format
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "label": "Build",
8 | "type": "shell",
9 | "command": "msbuild",
10 | "args": [
11 | // Ask msbuild to generate full paths for file names.
12 | "/property:GenerateFullPaths=true",
13 | "/t:build",
14 | // Do not generate summary otherwise it leads to duplicate errors in Problems panel
15 | "/consoleloggerparameters:NoSummary;Encoding=UTF-8;Verbosity=diagnostic",
16 | "-maxCpuCount:4"
17 | ],
18 | "group": "build",
19 | "presentation": {
20 | // Reveal the output only if unrecognized errors occur.
21 | "reveal": "silent"
22 | },
23 | // Use the standard MS compiler pattern to detect errors, warnings and infos
24 | "problemMatcher": "$msCompile"
25 | }
26 | ]
27 | }
--------------------------------------------------------------------------------
/Changelog.txt:
--------------------------------------------------------------------------------
1 | 0.14
2 | Исправлена ошибка BadCommand на современных утройствах
3 | Добавлена команда запуска WebDAV сервера
4 |
5 | 0.13
6 | Импортированы из QXDM классы конфигурации (команды getModemConfig и setModemConfig)
7 | Реализовано автоматическое определение COM-порта в Linux и OSX
8 |
9 | 0.12
10 | Переход на DotNetCore 3.1 для возможности запуска на Linux и OSX
11 |
12 | 0.11
13 | Добавлена поддержка подписок (указания SIM карты) в командах getModemConfig и setModemConfig
14 |
15 | 0.10
16 | Добавлена возможность захвата логов и сообщений
17 |
18 | 0.9
19 | Добавлена детализация настроек кодеков AMR
20 |
21 | 0.8
22 | Добавлен параметр itemNames в команде getModemConfig
23 | Добавлена расшифровка диапазонов LTE
24 | Увеличен список поддерживаемых полей NV
25 |
26 | 0.7
27 | Исправлено окрытие JSON файлов
28 | Добавлена возможность задания формата имени выходных файлов (поддержка ${date}, ${time}, ${longdate}, ${shortdate} из NLog)
29 |
30 | 0.6
31 | Добавлена поддержка автоматического поиска COM-порта (port="Auto")
32 | Добавлена поддержка распаковки MBN файлов
33 |
34 | 0.5
35 | Исправлена ошибка установка значений некоторых параметров в конфигурации модема
36 | Расширен список "известных" классов кофигурации
37 |
38 | 0.4
39 | Исправлена ошибка удаления каталога EFS в устройстве
40 | Добавлена возможность генерации и применения настроек модема в формате JSON.
41 |
42 | 0.3
43 | Добавлен флаг указания типа файла по умолчанию при выгрузке директории
44 |
45 | 0.2
46 | Исправлена запись файлов
47 |
48 | 0.1
49 | Первая тестовая версия
--------------------------------------------------------------------------------
/EfsTools.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30204.135
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EfsTools", "EfsTools\EfsTools.csproj", "{AFDECBE3-B1B0-43FC-9496-567F86E89B23}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NWebDav.Server", "libs\nwebdav\NWebDav.Server\NWebDav.Server.csproj", "{1D38471E-A05F-4711-8E13-B648FAF0BD5C}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NWebDav.Server.HttpListener", "libs\nwebdav\NWebDav.Server.HttpListener\NWebDav.Server.HttpListener.csproj", "{BCEAC943-9629-4D14-A326-2DF1FCF5516A}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {AFDECBE3-B1B0-43FC-9496-567F86E89B23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {AFDECBE3-B1B0-43FC-9496-567F86E89B23}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {AFDECBE3-B1B0-43FC-9496-567F86E89B23}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {AFDECBE3-B1B0-43FC-9496-567F86E89B23}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {1D38471E-A05F-4711-8E13-B648FAF0BD5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {1D38471E-A05F-4711-8E13-B648FAF0BD5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {1D38471E-A05F-4711-8E13-B648FAF0BD5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {1D38471E-A05F-4711-8E13-B648FAF0BD5C}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {BCEAC943-9629-4D14-A326-2DF1FCF5516A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {BCEAC943-9629-4D14-A326-2DF1FCF5516A}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {BCEAC943-9629-4D14-A326-2DF1FCF5516A}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {BCEAC943-9629-4D14-A326-2DF1FCF5516A}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | GlobalSection(ExtensibilityGlobals) = postSolution
35 | SolutionGuid = {409EE3AB-FEB5-48C7-883A-94486D3DAD78}
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/EfsTools/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/EfsTools/Attributes/AttributesAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Attributes
4 | {
5 | public class AttributesAttribute : Attribute
6 | {
7 | public AttributesAttribute(int attributes)
8 | {
9 | Attributes = attributes;
10 | }
11 |
12 | public int Attributes { get; }
13 | }
14 | }
--------------------------------------------------------------------------------
/EfsTools/Attributes/ConvertEndianAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Attributes
4 | {
5 | public class ConvertEndianAttribute : Attribute
6 | {
7 | }
8 | }
--------------------------------------------------------------------------------
/EfsTools/Attributes/EfsFileAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Attributes
4 | {
5 | public class EfsFileAttribute : Attribute
6 | {
7 | public EfsFileAttribute(string path, bool isItemFile, int permissions)
8 | {
9 | Path = path;
10 | IsItemFile = isItemFile;
11 | Permissions = permissions;
12 | }
13 |
14 | public string Path { get; }
15 | public bool IsItemFile { get; }
16 | public int Permissions { get; }
17 | }
18 | }
--------------------------------------------------------------------------------
/EfsTools/Attributes/IgnoreItemAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Attributes
4 | {
5 | public class IgnoreItemAttribute : Attribute
6 | {
7 | }
8 | }
--------------------------------------------------------------------------------
/EfsTools/Attributes/LineEndingAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Attributes
4 | {
5 | public enum LineEnding
6 | {
7 | Windows,
8 | Linux,
9 | MacOs
10 | }
11 |
12 | public class LineEndingAttribute : Attribute
13 | {
14 | public LineEndingAttribute(LineEnding lineEnding, bool needLastEndLine)
15 | {
16 | LineEnding = lineEnding;
17 | NeedLastEndLine = needLastEndLine;
18 | }
19 |
20 | public LineEnding LineEnding
21 | {
22 | get;
23 | }
24 |
25 | public bool NeedLastEndLine
26 | {
27 | get;
28 | }
29 |
30 | public string LineEndingString
31 | {
32 | get
33 | {
34 | string result;
35 | switch (LineEnding)
36 | {
37 | case LineEnding.Windows:
38 | result = "\r\n";
39 | break;
40 | case LineEnding.Linux:
41 | result = "\n";
42 | break;
43 | case LineEnding.MacOs:
44 | result = "\r";
45 | break;
46 | default:
47 | result = string.Empty;
48 | break;
49 | }
50 |
51 | return result;
52 | }
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/EfsTools/Attributes/NvItemIdAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Attributes
4 | {
5 | public class NvItemIdAttribute : Attribute
6 | {
7 | public NvItemIdAttribute(int id)
8 | {
9 | Id = id;
10 | }
11 |
12 | public int Id { get; }
13 | }
14 | }
--------------------------------------------------------------------------------
/EfsTools/Attributes/RequiredAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Attributes
4 | {
5 | public class RequiredAttribute : Attribute
6 | {
7 | }
8 | }
--------------------------------------------------------------------------------
/EfsTools/Attributes/SubscriptionAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Attributes
4 | {
5 | public class SubscriptionAttribute : Attribute
6 | {
7 | }
8 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/EfsCreateDirectoryOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 |
3 | namespace EfsTools.CommandLineOptions
4 | {
5 | [Verb("createDirectory", HelpText = "Create EFS directory")]
6 | internal class EfsCreateDirectoryOptions
7 | {
8 | [Option('p', "path", Required = true, HelpText = "Directory path")]
9 | public string Path { get; set; }
10 |
11 | [Option('n', "noRecursive", Required = false, HelpText = "Don't create all parent directories",
12 | Default = false)]
13 | public bool NoRecursive { get; set; }
14 | }
15 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/EfsDeleteDirectoryOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 |
3 | namespace EfsTools.CommandLineOptions
4 | {
5 | [Verb("deleteDirectory", HelpText = "Delete EFS directory")]
6 | internal class EfsDeleteDirectoryOptions
7 | {
8 | [Option('p', "path", Required = true, HelpText = "Directory path")]
9 | public string Path { get; set; }
10 |
11 | [Option('n', "noRecursive", Required = false, HelpText = "Don't delete all children directories",
12 | Default = false)]
13 | public bool NoRecursive { get; set; }
14 | }
15 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/EfsDeleteFileOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 |
3 | namespace EfsTools.CommandLineOptions
4 | {
5 | [Verb("deleteFile", HelpText = "Delete EFS file")]
6 | internal class EfsDeleteFileOptions
7 | {
8 | [Option('p', "path", Required = true, HelpText = "File path")]
9 | public string Path { get; set; }
10 | }
11 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/EfsDownloadDirectoryOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 | using EfsTools.Layouts;
3 |
4 | namespace EfsTools.CommandLineOptions
5 | {
6 | [Verb("downloadDirectory", HelpText = "Download EFS directory to computer")]
7 | internal class EfsDownloadDirectoryOptions
8 | {
9 | private Layout _outComputerPathLayout;
10 |
11 | [Option('i', "inEfsPath", Required = true, HelpText = "EFS directory path")]
12 | public string InEfsPath { get; set; }
13 |
14 | [Option('o', "outComputerPath", Required = true, HelpText = "Output directory path in computer")]
15 | public string OutComputerPath
16 | {
17 | get => _outComputerPathLayout?.Render();
18 | set => _outComputerPathLayout = Layout.Parse(value);
19 | }
20 |
21 | [Option('n', "noExtraData", Required = false, HelpText = "Don't save extra data in file name", Default = false)]
22 | public bool NoExtraData { get; set; }
23 |
24 | [Option('v', "processNvItems", Required = false, HelpText = "Process NV items", Default = false)]
25 | public bool ProcessNvItems { get; set; }
26 | }
27 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/EfsFixFileNamesOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 |
3 | namespace EfsTools.CommandLineOptions
4 | {
5 | [Verb("fixFileNames", HelpText = "Fix invalid file names")]
6 | internal class EfsFixFileNamesOptions
7 | {
8 | [Option('p', "efsPath", Required = true, HelpText = "EFS directory path")]
9 | public string EfsPath { get; set; }
10 | }
11 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/EfsListDirectoryOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 |
3 | namespace EfsTools.CommandLineOptions
4 | {
5 | [Verb("listDirectory", HelpText = "List EFS directory")]
6 | internal class EfsListDirectoryOptions
7 | {
8 | [Option('p', "path", Required = true, HelpText = "Directory path")]
9 | public string Path { get; set; }
10 |
11 | [Option('r', "recursive", Required = false, HelpText = "List all parent directories", Default = false)]
12 | public bool Recursive { get; set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/EfsReadFileOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 | using EfsTools.Layouts;
3 |
4 | namespace EfsTools.CommandLineOptions
5 | {
6 | [Verb("readFile", HelpText = "Read EFS file")]
7 | internal class EfsReadFileOptions
8 | {
9 | private Layout _outComputerFilePathLayout;
10 |
11 | [Option('i', "inEfsFilePath", Required = true, HelpText = "EFS file path")]
12 | public string InEfsFilePath { get; set; }
13 |
14 | [Option('o', "outComputerFilePath", Required = true, HelpText = "Output file path in computer")]
15 | public string OutComputerFilePath
16 | {
17 | get => _outComputerFilePathLayout?.Render();
18 | set => _outComputerFilePathLayout = Layout.Parse(value);
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/EfsRenameFileOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 |
3 | namespace EfsTools.CommandLineOptions
4 | {
5 | [Verb("renameFile", HelpText = "Rename (move) EFS file")]
6 | internal class EfsRenameFileOptions
7 | {
8 | [Option('p', "efsFilePath", Required = true, HelpText = "EFS file path")]
9 | public string EfsFilePath { get; set; }
10 |
11 | [Option('n', "efsNewFilePath", Required = true, HelpText = "New EFS file path")]
12 | public string NewEfsFilePath { get; set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/EfsUploadDirectoryOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 | using EfsTools.Layouts;
3 |
4 | namespace EfsTools.CommandLineOptions
5 | {
6 | [Verb("uploadDirectory", HelpText = "Upload directory from computer to EFS")]
7 | internal class EfsUploadDirectoryOptions
8 | {
9 | private Layout _inComputerPathLayout;
10 |
11 | [Option('i', "inComputerPath", Required = true, HelpText = "Input directory or MBN file path in computer ")]
12 | public string InComputerPath
13 | {
14 | get => _inComputerPathLayout?.Render();
15 | set => _inComputerPathLayout = Layout.Parse(value);
16 | }
17 |
18 | [Option('o', "outEfsPath", Required = true, HelpText = "EFS directory path")]
19 | public string OutEfsPath { get; set; }
20 |
21 | [Option('t', "createItemFilesAsDefault", Required = false, HelpText = "Create item file as default",
22 | Default = false)]
23 | public bool CreateItemFilesAsDefault { get; set; }
24 |
25 | [Option('v', "processNvItems", Required = false, HelpText = "Process NV items", Default = false)]
26 | public bool ProcessNvItems { get; set; }
27 | }
28 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/EfsWriteFileOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 | using EfsTools.Layouts;
3 |
4 | namespace EfsTools.CommandLineOptions
5 | {
6 | [Verb("writeFile", HelpText = "Write EFS file")]
7 | internal class EfsWriteFileOptions
8 | {
9 | private Layout _inComputerFilePathLayout;
10 |
11 | [Option('i', "inComputerFilePath", Required = true, HelpText = "Computer file path")]
12 | public string InComputerFilePath
13 | {
14 | get => _inComputerFilePathLayout?.Render();
15 | set => _inComputerFilePathLayout = Layout.Parse(value);
16 | }
17 |
18 | [Option('o', "outEfsFilePath", Required = true, HelpText = "Output EFS path")]
19 | public string OutEfsFilePath { get; set; }
20 |
21 | [Option('n', "dontCreate", Required = false, HelpText = "Don't create EFS file if its not exist",
22 | Default = false)]
23 | public bool DontCreateEfsFile { get; set; }
24 |
25 | [Option('t', "item", Required = false, HelpText = "Create Item file", Default = false)]
26 | public bool IsItemFile { get; set; }
27 | }
28 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/ExtractMbnOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 | using EfsTools.Layouts;
3 |
4 | namespace EfsTools.CommandLineOptions
5 | {
6 | [Verb("extractMbn", HelpText = "Extract 'Modem configuration BiNary' file to computer")]
7 | internal class ExtractMbnOptions
8 | {
9 | private Layout _outputComputerDirectoryPathLayout;
10 |
11 | [Option('i', "inputMbnFilePath", Required = true, HelpText = "Input MBN file path")]
12 | public string InputMbnFilePath { get; set; }
13 |
14 | [Option('p', "outputComputerDirectoryPath", Required = true, HelpText = "Output directory path in computer")]
15 | public string OutputComputerDirectoryPath
16 | {
17 | get => _outputComputerDirectoryPathLayout?.Render();
18 | set => _outputComputerDirectoryPathLayout = Layout.Parse(value);
19 | }
20 |
21 | [Option('n', "noExtraData", Required = false, HelpText = "Don't save extra data in file name", Default = false)]
22 | public bool NoExtraData { get; set; }
23 | }
24 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/GetEfsInfoOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 |
3 | namespace EfsTools.CommandLineOptions
4 | {
5 | [Verb("efsInfo", HelpText = "Get EFS information")]
6 | internal class GetEfsInfoOptions
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/GetLogsOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 |
3 | namespace EfsTools.CommandLineOptions
4 | {
5 | [Verb("getLog", HelpText = "Get log")]
6 | internal class GetLogsOptions
7 | {
8 | [Option('m', "messageMask", Required = false, HelpText = "Message packets mask")]
9 | public string MessageMask { get; set; }
10 |
11 | [Option('l', "logMask", Required = false, HelpText = "Log packets mask")]
12 | public string LogMask { get; set; }
13 |
14 | [Option('v', "verbose", Required = false, HelpText = "Verbose output")]
15 | public bool Verbose { get; set; }
16 |
17 |
18 | /*[Option('e', "eventMask", Required = false, HelpText = "Event reports mask")]
19 | public string EventMask { get; set; }
20 |
21 | [Option('f', "fileName", Required = false, HelpText = "File name")]
22 | public string FileName { get; set; }
23 |
24 | [Option('a', "layout", Required = false, HelpText = "Log layout")]
25 | public string Layout { get; set; }
26 |
27 | [Option('c', "logConfigFile", Required = false, HelpText = "NLog config file")]
28 | public string LogConfigFile { get; set; }*/
29 | }
30 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/GetModemConfigOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 | using EfsTools.Layouts;
3 |
4 | namespace EfsTools.CommandLineOptions
5 | {
6 | [Verb("getModemConfig", HelpText = "Get modem configuration")]
7 | internal class GetModemConfigOptions
8 | {
9 | private Layout _outComputerFilePathLayout;
10 |
11 | [Option('p', "outComputerFilePath", Required = true, HelpText = "Output file path in computer")]
12 | public string OutComputerFilePath
13 | {
14 | get => _outComputerFilePathLayout?.Render();
15 | set => _outComputerFilePathLayout = Layout.Parse(value);
16 | }
17 |
18 | [Option('i', "inputComputerFilePath", Required = false,
19 | HelpText = "Input directory or MBN file path in computer")]
20 | public string InComputerFilePath { get; set; }
21 |
22 | [Option('m', "itemNames", Required = false, HelpText = "Load only this items")]
23 | public string ItemNames { get; set; }
24 |
25 | [Option('s', "subscriptionIndex", Required = false,
26 | HelpText = "Subscription index. 0 - first SIM, 1 - second SIM", Default = 0)]
27 | public int SubscriptionIndex { get; set; }
28 |
29 | [Option('v', "verbose", Required = false, HelpText = "Verbose output", Default = false)]
30 | public bool Verbose { get; set; }
31 | }
32 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/GetTargetInfoOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 |
3 | namespace EfsTools.CommandLineOptions
4 | {
5 | [Verb("targetInfo", HelpText = "Get target info")]
6 | internal class GetTargetInfoOptions
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/Helper/HelpTextLocalizer.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Reflection;
3 | using CommandLine;
4 | using EfsTools.Resourses;
5 |
6 | namespace EfsTools.CommandLineOptions.Helper
7 | {
8 | internal static class HelpTextLocalizer
9 | {
10 | static HelpTextLocalizer()
11 | {
12 | Localize();
13 | }
14 |
15 | public static void Localize()
16 | {
17 | try
18 | {
19 | var assembly = Assembly.GetExecutingAssembly();
20 | foreach (var type in assembly.GetTypes())
21 | {
22 | if (!type.IsAbstract && !type.IsEnum)
23 | {
24 | if (type.GetCustomAttributes(typeof(VerbAttribute), true).FirstOrDefault() is VerbAttribute
25 | attribute1)
26 | {
27 | var helpText = GetLocalizedString(attribute1.HelpText);
28 | attribute1.HelpText = helpText;
29 | }
30 |
31 | if (type.GetCustomAttributes(typeof(OptionAttribute), true).FirstOrDefault() is OptionAttribute
32 | attribute2)
33 | {
34 | var helpText = GetLocalizedString(attribute2.HelpText);
35 | attribute2.HelpText = helpText;
36 | }
37 | }
38 | }
39 | }
40 | catch
41 | {
42 | }
43 | }
44 |
45 | private static string GetLocalizedString(string str)
46 | {
47 | string res;
48 | switch (str)
49 | {
50 | case "Create EFS directory":
51 | res = Strings.CreateEFSDirectory;
52 | break;
53 | case "Directory path":
54 | res = Strings.DirectoryPath;
55 | break;
56 | case "Don't create all parent directories":
57 | res = Strings.DontCreateAllParentDirectories;
58 | break;
59 |
60 | default:
61 | res = str;
62 | break;
63 | }
64 |
65 | return res;
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/SetModemConfigOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 | using EfsTools.Layouts;
3 |
4 | namespace EfsTools.CommandLineOptions
5 | {
6 | [Verb("setModemConfig", HelpText = "Set modem configuration")]
7 | internal class SetModemConfigOptions
8 | {
9 | private Layout _outComputerFilePathLayout;
10 |
11 | [Option('p', "inputComputerFilePath", Required = true, HelpText = "Input file path in computer")]
12 | public string InComputerFilePath { get; set; }
13 |
14 | [Option('o', "outComputerFilePath", Required = false, HelpText = "Output directory path in computer")]
15 | public string OutComputerFilePath
16 | {
17 | get => _outComputerFilePathLayout?.Render();
18 | set => _outComputerFilePathLayout = Layout.Parse(value);
19 | }
20 |
21 | [Option('s', "subscriptionIndex", Required = false,
22 | HelpText = "Subscription index. 0 - first SIM, 1 - second SIM", Default = 0)]
23 | public int SubscriptionIndex { get; set; }
24 |
25 | [Option('v', "verbose", Required = false, HelpText = "Verbose output", Default = false)]
26 | public bool Verbose { get; set; }
27 | }
28 | }
--------------------------------------------------------------------------------
/EfsTools/CommandLineOptions/StartWebDavServerOptions.cs:
--------------------------------------------------------------------------------
1 | using CommandLine;
2 |
3 | namespace EfsTools.CommandLineOptions
4 | {
5 | [Verb("webDavServer", HelpText = "Start WebDAV server")]
6 | internal class StartWebDavServerOptions
7 | {
8 | [Option('p', "port", Required = true, HelpText = "Port number")]
9 | public int Port { get; set; }
10 |
11 | [Option('l', "logLevel", Required = false, HelpText = "Log level (Info, Warning, Error)", Default = global::EfsTools.LogLevel.Info)]
12 | public LogLevel LogLevel { get; set; }
13 |
14 | [Option('r', "readOnly", Required = false, HelpText = "ReadOnly", Default = 1)]
15 | public int ReadOnly { get; set; }
16 | }
17 | }
--------------------------------------------------------------------------------
/EfsTools/EfsTools.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Exe
4 | netcoreapp3.1;net5.0
5 | latest
6 | EfsTools
7 | EFS Tools Application
8 | 0.14.0.14
9 | Copyright (c) JohnBel 2021 (http://johnbel.github.io/)
10 | JohnBel
11 | disable
12 | http://johnbel.github.io/
13 | JohnBel
14 | EFS,EfsTools
15 | https://github.com/JohnBel/EfsTools
16 | GitHub
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | True
35 | True
36 | Strings.resx
37 |
38 |
39 |
40 |
41 | ResXFileCodeGenerator
42 |
43 |
44 | ResXFileCodeGenerator
45 | Strings.Designer.cs
46 |
47 |
48 | ResXFileCodeGenerator
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/EfsTools/EfsTools.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <_LastSelectedProfileId>C:\Projects\Tmp\EfsTools\EfsTools\Properties\PublishProfiles\FolderProfile.pubxml
9 | net5.0
10 |
11 |
--------------------------------------------------------------------------------
/EfsTools/EfsToolsConfigurationSection.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Configuration;
2 |
3 | namespace EfsTools
4 | {
5 | internal class EfsToolsConfigurationSection
6 | {
7 | private readonly IConfigurationSection _configurationSection;
8 |
9 | public EfsToolsConfigurationSection(IConfigurationRoot configurationRoot)
10 | {
11 | _configurationSection = configurationRoot == null ? null : configurationRoot.GetSection("efstool");
12 | }
13 |
14 | public string Port
15 | {
16 | get => GetValue("port", "Auto");
17 | set => SetValue("port", value);
18 | }
19 |
20 | public int Baudrate
21 | {
22 | get => int.Parse(GetValue("baudrate", "38400"));
23 | set => SetValue("baudrate", $"{value}");
24 | }
25 |
26 | public string Password
27 | {
28 | get => GetValue("password", "00000000");
29 | set => SetValue("password", value);
30 | }
31 |
32 | public string Spc
33 | {
34 | get => GetValue("spc", "000000");
35 | set => SetValue("spc", value);
36 | }
37 |
38 | public bool HdlcSendControlChar
39 | {
40 | get => bool.Parse(GetValue("hdlcSendControlChar", "False"));
41 | set => SetValue("hdlcSendControlChar", $"{value}");
42 | }
43 | public bool IgnoreUnsupportedCommands
44 | {
45 | get => bool.Parse(GetValue("ignoreUnsupportedCommands", "False"));
46 | set => SetValue("ignoreUnsupportedCommands", $"{value}");
47 | }
48 |
49 | private string GetValue(string name, string defaultValue)
50 | {
51 | if (_configurationSection != null)
52 | {
53 | var val = _configurationSection.GetSection(name);
54 | if (val != null)
55 | {
56 | return val.Value;
57 | }
58 | }
59 |
60 | return defaultValue;
61 | }
62 |
63 | private void SetValue(string name, string value)
64 | {
65 | if (_configurationSection != null)
66 | {
67 | var val = _configurationSection.GetSection(name);
68 | if (val != null)
69 | {
70 | val.Value = value;
71 | }
72 | }
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/EfsTools/Items/Base/ItemBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using BinarySerialization;
3 | using EfsTools.Items.Base;
4 | using EfsTools.Attributes;
5 | namespace EfsTools.Items.Base
6 | {
7 | [Serializable]
8 | public class ItemBase
9 | {
10 | }
11 | }
--------------------------------------------------------------------------------
/EfsTools/Items/Base/MultiLineStringsItemBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using BinarySerialization;
4 | using EfsTools.Items.Base;
5 | using EfsTools.Attributes;
6 | using EfsTools.Utils;
7 | using Newtonsoft.Json;
8 |
9 | namespace EfsTools.Items.Base
10 | {
11 | [Serializable]
12 | public class MultiLineStringsItemBase : ItemBase, IBinarySerializable
13 | {
14 | [Ignore]
15 | public string[] Values
16 | {
17 | get; set;
18 | }
19 |
20 |
21 | public void Serialize(Stream stream, Endianness endianness, BinarySerializationContext serializationContext)
22 | {
23 | if (Values != null)
24 | {
25 | using var writer = new StreamWriter(stream);
26 | var txt = StringUtils.GetString(Values, LineEnding.Linux);
27 | writer.Write(txt);
28 | writer.Flush();
29 | writer.Close();
30 | }
31 | }
32 |
33 | public void Deserialize(Stream stream, Endianness endianness, BinarySerializationContext serializationContext)
34 | {
35 | using var reader = new StreamReader(stream);
36 | var txt = reader.ReadToEnd();
37 | Values = StringUtils.GetStringLines(txt,LineEnding.Linux);
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/EfsTools/Items/Base/OneValueItemBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using BinarySerialization;
3 |
4 | namespace EfsTools.Items.Base
5 | {
6 | [Serializable]
7 |
8 | public class OneValueItemBase : ItemBase
9 | {
10 | [FieldOffset(0)]
11 | public T Value
12 | {
13 | get; set;
14 | }
15 | }
16 |
17 | public class BoolItemBase : OneValueItemBase { }
18 | public class ByteItemBase : OneValueItemBase { }
19 | public class SByteItemBase : OneValueItemBase { }
20 | public class Int16ItemBase : OneValueItemBase { }
21 | public class UInt16ItemBase : OneValueItemBase { }
22 | public class Int32ItemBase : OneValueItemBase { }
23 | public class UInt32ItemBase : OneValueItemBase { }
24 | public class Int64ItemBase : OneValueItemBase { }
25 | public class UInt64ItemBase : OneValueItemBase { }
26 | public class StringItemBase : OneValueItemBase { }
27 | }
--------------------------------------------------------------------------------
/EfsTools/Items/Base/WindowsMultiLineStringsItemBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using BinarySerialization;
4 | using EfsTools.Items.Base;
5 | using EfsTools.Attributes;
6 | using EfsTools.Utils;
7 | using Newtonsoft.Json;
8 |
9 | namespace EfsTools.Items.Base
10 | {
11 | [Serializable]
12 | public class WindowsMultiLineStringsItemBase : ItemBase, IBinarySerializable
13 | {
14 | [Ignore]
15 | public string[] Values
16 | {
17 | get; set;
18 | }
19 |
20 |
21 | public void Serialize(Stream stream, Endianness endianness, BinarySerializationContext serializationContext)
22 | {
23 | if (Values != null)
24 | {
25 | using var writer = new StreamWriter(stream);
26 | var txt = StringUtils.GetString(Values, LineEnding.Windows);
27 | writer.Write(txt);
28 | writer.Flush();
29 | writer.Close();
30 | }
31 | }
32 |
33 | public void Deserialize(Stream stream, Endianness endianness, BinarySerializationContext serializationContext)
34 | {
35 | using var reader = new StreamReader(stream);
36 | var txt = reader.ReadToEnd();
37 | Values = StringUtils.GetStringLines(txt, LineEnding.Windows);
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/EfsTools/Items/ItemsBinarySerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using BinarySerialization;
5 | using EfsTools.Items.Base;
6 | using EfsTools.Attributes;
7 |
8 | namespace EfsTools.Items
9 | {
10 | internal class ItemsBinarySerializerException : Exception
11 | {
12 | public ItemsBinarySerializerException(string message)
13 | : base(message)
14 | {
15 | }
16 | }
17 |
18 | public static class ItemsBinarySerializer
19 | {
20 | private static BinarySerializer _binarySerializer;
21 |
22 | private static BinarySerializer BinarySerializer
23 | {
24 | get
25 | {
26 | if (_binarySerializer == null)
27 | {
28 | _binarySerializer = new BinarySerializer();
29 |
30 | if (Debugger.IsAttached)
31 | {
32 | _binarySerializer.MemberSerializing += (object sender, MemberSerializingEventArgs e)
33 | => Debugger.Log(0, "info", $"StartSerialization: t: {e.Context.ParentType.Name}, m: {e.MemberName}, offset: {e.Offset}\n");
34 | _binarySerializer.MemberSerialized += (object sender, MemberSerializedEventArgs e)
35 | => Debugger.Log(0, "info", $"EndSerialization: t: {e.Context.ParentType.Name}, m: {e.MemberName}, v: {e.Value}, offset: {e.Offset}\n");
36 | _binarySerializer.MemberDeserializing += (object sender, MemberSerializingEventArgs e)
37 | => Debugger.Log(0, "info", $"StartDeserialization: t: {e.Context.ParentType.Name}, m: {e.MemberName}, offset: {e.Offset}\n");
38 | _binarySerializer.MemberDeserialized += (object sender, MemberSerializedEventArgs e)
39 | => Debugger.Log(0, "info", $"EndDeserialization: t: {e.Context.ParentType.Name}, m: {e.MemberName}, v: {e.Value}, offset: {e.Offset}\n");
40 |
41 | }
42 | }
43 | return _binarySerializer;
44 | }
45 | }
46 |
47 | public static long SizeOf(T obj)
48 | {
49 | if (obj != null)
50 | {
51 | return BinarySerializer.SizeOf(obj);
52 | }
53 | return 0;
54 | }
55 |
56 | public static long SizeOf(Type type)
57 | {
58 | var obj = Activator.CreateInstance(type);
59 | return BinarySerializer.SizeOf(obj);
60 | }
61 | public static void Serialize(T obj, Stream stream)
62 | {
63 | if (obj != null)
64 | {
65 | BinarySerializer.Serialize(stream, obj);
66 | }
67 | }
68 |
69 | public static T Deserialize(Stream stream)
70 | {
71 | var obj = Deserialize(stream, typeof(T));
72 | return (T) obj;
73 | }
74 |
75 | public static object Deserialize(Stream stream, Type type)
76 | {
77 | try
78 | {
79 | var obj = BinarySerializer.Deserialize(stream, type);
80 | return obj;
81 | }
82 | catch // (Exception e)
83 | {
84 | return null;
85 | }
86 |
87 | }
88 | }
89 | }
--------------------------------------------------------------------------------
/EfsTools/Items/ItemsJsonSerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using Newtonsoft.Json;
5 | using Newtonsoft.Json.Linq;
6 |
7 | namespace EfsTools.Items
8 | {
9 | internal class ItemsJsonSerializerException : Exception
10 | {
11 | public ItemsJsonSerializerException(string message)
12 | : base(message)
13 | {
14 | }
15 | }
16 |
17 | public static class ItemsJsonSerializer
18 | {
19 | public static void SerializeItems(Dictionary items, TextWriter writer)
20 | {
21 | var str = JsonConvert.SerializeObject(items, Formatting.Indented);
22 | writer.Write(str);
23 | }
24 |
25 | public static void DeserializeItems(Dictionary items, TextReader reader)
26 | {
27 | using (var jsonReader = new JsonTextReader(reader))
28 | {
29 | var serializer = JsonSerializer.CreateDefault();
30 |
31 | var jsonObj = (JObject) serializer.Deserialize(jsonReader, typeof(JObject));
32 | if (jsonObj != null)
33 | {
34 | foreach (var jsonItem in jsonObj)
35 | {
36 | var type = jsonItem.Key;
37 | if (items.TryGetValue(type, out var item))
38 | {
39 | var data = jsonItem.Value;
40 | DeserializeItem(item, data);
41 | }
42 | }
43 | }
44 | }
45 | }
46 |
47 | private static void DeserializeItem(object item, JToken data)
48 | {
49 | if (item != null)
50 | {
51 | var itemType = item.GetType();
52 | var json = data.ToString();
53 | //var sourceItem = data.Values();
54 | foreach (JProperty it in data)
55 | {
56 | SetProperty(item, it);
57 | }
58 | }
59 | }
60 |
61 | private static void SetProperty(object obj, JProperty jProperty)
62 | {
63 | var type = obj.GetType();
64 | var propInfo = type.GetProperty(jProperty.Name);
65 | if (propInfo != null)
66 | {
67 | var propType = propInfo.PropertyType;
68 | if (propType != null)
69 | {
70 | var val = ConvertTo(jProperty.Value, propType);
71 | propInfo.SetValue(obj, val);
72 | }
73 | }
74 | }
75 |
76 | private static object ConvertTo(JToken value, Type type)
77 | {
78 | object result = value.ToObject(type);
79 | /*if (value.HasValues)
80 | {
81 | result = result;
82 | }*/
83 | return result;
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/EfsTools/Layouts/DateTimeLayoutRule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace EfsTools.Layouts
5 | {
6 | internal class DateTimeLayoutRule : ILayoutRuleWithParameters
7 | {
8 | private readonly string _format;
9 |
10 | private readonly bool _useUtc;
11 |
12 | public DateTimeLayoutRule(Dictionary parameters)
13 | {
14 | Parameters = parameters;
15 | _useUtc = false;
16 | _format = "yyyy-MM-dd HH:mm:ss";
17 | if (parameters != null)
18 | {
19 | if (parameters.TryGetValue("universalTime", out var val))
20 | {
21 | val = val.ToLowerInvariant();
22 | _useUtc = val == "true";
23 | }
24 |
25 | if (parameters.TryGetValue("format", out var val2))
26 | {
27 | _format = val2;
28 | }
29 | }
30 | }
31 |
32 | public Dictionary Parameters
33 | {
34 | get;
35 | }
36 |
37 | public string Render()
38 | {
39 | var now = _useUtc ? DateTime.UtcNow : DateTime.Now;
40 | if (string.IsNullOrEmpty(_format))
41 | {
42 | return now.ToLongDateString();
43 | }
44 |
45 | var str = now.ToString(_format);
46 | return str;
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/EfsTools/Layouts/ILayoutRule.cs:
--------------------------------------------------------------------------------
1 | namespace EfsTools.Layouts
2 | {
3 | internal interface ILayoutRule
4 | {
5 | string Render();
6 | }
7 | }
--------------------------------------------------------------------------------
/EfsTools/Layouts/ILayoutRuleWithParameters.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace EfsTools.Layouts
4 | {
5 | internal interface ILayoutRuleWithParameters : ILayoutRule
6 | {
7 | Dictionary Parameters { get; }
8 | }
9 | }
--------------------------------------------------------------------------------
/EfsTools/Layouts/TextLayoutRule.cs:
--------------------------------------------------------------------------------
1 | namespace EfsTools.Layouts
2 | {
3 | internal class TextLayoutRule : ILayoutRule
4 | {
5 | private readonly string _text;
6 |
7 | public TextLayoutRule(string text)
8 | {
9 | _text = text;
10 | }
11 |
12 | public string Render()
13 | {
14 | return _text;
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/EfsTools/LogLevel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools
4 | {
5 | public enum LogLevel
6 | {
7 | Info,
8 | Warning,
9 | Error
10 | }
11 | }
--------------------------------------------------------------------------------
/EfsTools/Logger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools
4 | {
5 | internal class Logger
6 | {
7 | public void LogInfo(string format, params object[] args)
8 | {
9 | //var oldColor = Console.ForegroundColor;
10 | //Console.ForegroundColor = ConsoleColor.Green;
11 | Console.WriteLine(format, args);
12 | //Console.ForegroundColor = oldColor;
13 | }
14 |
15 | public void LogWarning(string format, params object[] args)
16 | {
17 | var oldColor = Console.ForegroundColor;
18 | Console.ForegroundColor = ConsoleColor.Yellow;
19 | Console.WriteLine(format, args);
20 | Console.ForegroundColor = oldColor;
21 | }
22 |
23 | public void LogError(string format, params object[] args)
24 | {
25 | var oldColor = Console.ForegroundColor;
26 | Console.ForegroundColor = ConsoleColor.Red;
27 | Console.WriteLine(format, args);
28 | Console.ForegroundColor = oldColor;
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/EfsTools/Mbn/ConfigurationType.cs:
--------------------------------------------------------------------------------
1 | namespace EfsTools.Mbn
2 | {
3 | internal enum ConfigurationType : ushort
4 | {
5 | Hw = 0,
6 | Sw = 1
7 | }
8 | }
--------------------------------------------------------------------------------
/EfsTools/Mbn/ItemHeader.cs:
--------------------------------------------------------------------------------
1 | namespace EfsTools.Mbn
2 | {
3 | internal class ItemHeader
4 | {
5 | public uint Length { get; set; }
6 | public byte Attributes { get; set; }
7 | public ItemType Type { get; set; }
8 | public ushort Reserved { get; set; }
9 | }
10 | }
--------------------------------------------------------------------------------
/EfsTools/Mbn/ItemType.cs:
--------------------------------------------------------------------------------
1 | namespace EfsTools.Mbn
2 | {
3 | internal enum ItemType : byte
4 | {
5 | Nv = 1,
6 | NvFile = 2,
7 | File = 4
8 | }
9 | }
--------------------------------------------------------------------------------
/EfsTools/Mbn/McfgHeader.cs:
--------------------------------------------------------------------------------
1 | namespace EfsTools.Mbn
2 | {
3 | internal class McfgHeader
4 | {
5 | public string Magic { get; set; }
6 | public ushort FormatType { get; set; }
7 | public ConfigurationType ConfigurationType { get; set; }
8 | public uint ItemsCount { get; set; }
9 | public ushort CarrierIndex { get; set; }
10 | public ushort Reserved { get; set; }
11 | public uint Version { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/EfsTools/Properties/PublishProfiles/FolderProfile.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | Release
8 | Any CPU
9 | bin\Release\net5.0\publish\
10 | FileSystem
11 | net5.0
12 | false
13 |
14 |
--------------------------------------------------------------------------------
/EfsTools/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "EfsTools": {
4 | "commandName": "Project",
5 | "commandLineArgs": "webDavServer -p 8888 -r 0"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/HdlcSerial.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Utils;
3 | using RJCP.IO.Ports;
4 |
5 | namespace EfsTools.Qualcomm
6 | {
7 | internal class HdlcSerial : IDisposable
8 | {
9 | private readonly SerialPortStream _port;
10 |
11 | private readonly byte[] _readBuffer = new byte[1048576];
12 |
13 | private readonly bool _sendControlChar;
14 |
15 | public HdlcSerial(string port, int baudrate, int timeout, bool sendControlChar)
16 | {
17 | _port = new SerialPortStream(port, baudrate)
18 | {
19 | ReadTimeout = timeout,
20 | ReadBufferSize = _readBuffer.Length
21 | };
22 | _sendControlChar = sendControlChar;
23 | }
24 |
25 | public bool IsOpen => _port.IsOpen;
26 | public string PortName => _port.PortName;
27 |
28 | public bool SendControlChar => _sendControlChar;
29 |
30 | public void Dispose()
31 | {
32 | _port?.Dispose();
33 | }
34 |
35 | public void Open()
36 | {
37 | _port.Open();
38 | }
39 |
40 | public void Close()
41 | {
42 | _port.Close();
43 | }
44 |
45 | private void WriteRaw(byte[] data)
46 | {
47 | _port.Write(data, 0, data.Length);
48 | }
49 |
50 | public void Write(byte[] data)
51 | {
52 | var encoded = HdlcEncoder.Encode(data, _sendControlChar);
53 | WriteRaw(encoded);
54 | }
55 |
56 | private int ReadRaw(byte[] buffer)
57 | {
58 | return _port.Read(buffer, 0, buffer.Length);
59 | }
60 |
61 | public byte[] Read()
62 | {
63 | var read = ReadRaw(_readBuffer);
64 | var decoded = HdlcEncoder.Decode(_readBuffer, read);
65 | return decoded;
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Attributes/QcdmCommandAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Attributes
4 | {
5 | internal class QcdmCommandAttribute : Attribute
6 | {
7 | public QcdmCommandAttribute(QcdmCommand command)
8 | {
9 | Command = command;
10 | }
11 |
12 | public QcdmCommand Command { get; }
13 | }
14 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Attributes/QcdmMinResponseLengthAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Attributes
4 | {
5 | internal class QcdmMinResponseLengthAttribute : Attribute
6 | {
7 | public QcdmMinResponseLengthAttribute(int minResponseLength)
8 | {
9 | MinResponseLength = minResponseLength;
10 | }
11 |
12 | public int MinResponseLength { get; }
13 | }
14 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Attributes/QcdmSubSystemCommandAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Attributes
4 | {
5 | internal class QcdmSubSystemCommandAttribute : Attribute
6 | {
7 | public QcdmSubSystemCommandAttribute(QcdmSubSystem subSystem, ushort command)
8 | {
9 | SubSystem = subSystem;
10 | Command = command;
11 | }
12 |
13 | public QcdmSubSystem SubSystem { get; }
14 | public ushort Command { get; }
15 | }
16 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/IQcdmCommandRequest.cs:
--------------------------------------------------------------------------------
1 | namespace EfsTools.Qualcomm.QcdmCommands
2 | {
3 | internal interface IQcdmCommandRequest
4 | {
5 | QcdmCommand Command { get; }
6 | byte[] GetData();
7 | }
8 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/IQcdmCommandResponse.cs:
--------------------------------------------------------------------------------
1 | namespace EfsTools.Qualcomm.QcdmCommands
2 | {
3 | internal interface IQcdmCommandResponse
4 | {
5 | QcdmCommand Command { get; }
6 | }
7 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/QcdmDiagServCommand.cs:
--------------------------------------------------------------------------------
1 | namespace EfsTools.Qualcomm.QcdmCommands
2 | {
3 | internal enum QcdmDiagServCommand : byte
4 | {
5 | GetLogDroppedCount = 53,
6 | GetEventDroppedCount = 55,
7 | GetDebugMessageDroppedCount = 57,
8 | GetLogAllocationCount = 58,
9 | GetEventAllocationCount = 59,
10 | GetDebugMessageAllocationCount = 60
11 | }
12 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/QcdmPhoneMode.cs:
--------------------------------------------------------------------------------
1 | namespace EfsTools.Qualcomm.QcdmCommands
2 | {
3 | internal enum QcdmPhoneMode : byte
4 | {
5 | OfflineA = 0x00,
6 | OfflineD = 0x01,
7 | Reset = 0x02,
8 | Ftm = 0x03,
9 | Online = 0x04,
10 | Lpm = 0x05,
11 | PowerOff = 0x06
12 | }
13 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/QcdmRuimConfigType.cs:
--------------------------------------------------------------------------------
1 | namespace EfsTools.Qualcomm.QcdmCommands
2 | {
3 | internal enum QcdmRuimConfigType : byte
4 | {
5 | Ruim = 0x00,
6 | Nv = 0x01,
7 | Pref = 0x02,
8 | Gsm1x = 0x03
9 | }
10 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/BaseCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
5 | {
6 | internal abstract class BaseCommandRequest : IQcdmCommandRequest
7 | {
8 | public BaseCommandRequest()
9 | {
10 | InitializeCommand();
11 | }
12 |
13 | public QcdmCommand Command { get; private set; } = QcdmCommand.Max;
14 |
15 | public virtual byte[] GetData()
16 | {
17 | return new[]
18 | {
19 | (byte) Command
20 | };
21 | }
22 |
23 | private void InitializeCommand()
24 | {
25 | var type = GetType();
26 | if (Command == QcdmCommand.Max &&
27 | type.GetCustomAttributes(typeof(QcdmCommandAttribute), true).FirstOrDefault() is QcdmCommandAttribute
28 | attribute)
29 | {
30 | Command = attribute.Command;
31 | }
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/BaseSubSystemCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
6 | {
7 | internal class BaseSubSystemCommandRequest : BaseCommandRequest
8 | {
9 | public BaseSubSystemCommandRequest()
10 | {
11 | Initialize();
12 | }
13 |
14 | public QcdmSubSystem SubSystem { get; private set; } = QcdmSubSystem.Legacy;
15 |
16 | public ushort SubSystemCommand { get; private set; }
17 |
18 | public override byte[] GetData()
19 | {
20 | var cmd = BitConverter.GetBytes(SubSystemCommand);
21 | var data = new[]
22 | {
23 | (byte) Command, (byte) SubSystem, cmd[0], cmd[1]
24 | };
25 | return data;
26 | }
27 |
28 | private void Initialize()
29 | {
30 | var type = GetType();
31 | if (SubSystem == QcdmSubSystem.Legacy &&
32 | type.GetCustomAttributes(typeof(QcdmSubSystemCommandAttribute), true).FirstOrDefault() is
33 | QcdmSubSystemCommandAttribute attribute)
34 | {
35 | SubSystem = attribute.SubSystem;
36 | SubSystemCommand = attribute.Command;
37 | }
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/CallManager/CallManagerStateInfoCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.CallManager
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.CallManager, 0)]
7 | internal class CallManagerStateInfoCommandRequest : BaseSubSystemCommandRequest
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/DiagServ/GetDebugMessageAllocationCountRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.DiagServ
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.DiagServ, (ushort) QcdmDiagServCommand.GetDebugMessageAllocationCount)]
7 | internal class GetDebugMessageAllocationCountRequest : BaseSubSystemCommandRequest
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/DiagServ/GetDebugMessageDroppedCountRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.DiagServ
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.DiagServ, (ushort) QcdmDiagServCommand.GetDebugMessageDroppedCount)]
7 | internal class GetDebugMessageDroppedCountRequest : BaseSubSystemCommandRequest
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/DiagServ/GetEventAllocationCountRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.DiagServ
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.DiagServ, (ushort) QcdmDiagServCommand.GetEventAllocationCount)]
7 | internal class GetEventAllocationCountRequest : BaseSubSystemCommandRequest
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/DiagServ/GetEventDroppedCountRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.DiagServ
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.DiagServ, (ushort) QcdmDiagServCommand.GetEventDroppedCount)]
7 | internal class GetEventDroppedCountRequest : BaseSubSystemCommandRequest
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/DiagServ/GetLogAllocationCountRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.DiagServ
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.DiagServ, (ushort) QcdmDiagServCommand.GetLogAllocationCount)]
7 | internal class GetLogAllocationCountRequest : BaseSubSystemCommandRequest
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/DiagServ/GetLogDroppedCountRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.DiagServ
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.DiagServ, (ushort) QcdmDiagServCommand.GetLogDroppedCount)]
7 | internal class GetLogDroppedCountRequest : BaseSubSystemCommandRequest
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/DiagVersionCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
4 | {
5 | [QcdmCommand(QcdmCommand.DiagVersion)]
6 | internal class DiagVersionCommandRequest : BaseCommandRequest
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsAccessCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
6 | {
7 | [QcdmCommand(QcdmCommand.SubsysCmd)]
8 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsAccess)]
9 | internal class EfsAccessCommandRequest : BaseSubSystemCommandRequest
10 | {
11 | private readonly string _path;
12 | private readonly byte _permitionBites;
13 |
14 | public EfsAccessCommandRequest(string path, byte permitionBites)
15 | {
16 | _path = path;
17 | _permitionBites = permitionBites;
18 | }
19 |
20 | public override byte[] GetData()
21 | {
22 | var data = new byte[6 + _path.Length];
23 | data[4] = _permitionBites;
24 | Array.Copy(base.GetData(), 0, data, 0, 4);
25 | Array.Copy(Encoding.ASCII.GetBytes(_path), 0, data, 5, _path.Length);
26 | data[5 + _path.Length] = 0;
27 | return data;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsCloseDirectoryCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsCloseDir)]
8 | internal class EfsCloseDirectoryCommandRequest : BaseSubSystemCommandRequest
9 | {
10 | private readonly int _directory;
11 |
12 | public EfsCloseDirectoryCommandRequest(int dir)
13 | {
14 | _directory = dir;
15 | }
16 |
17 | public override byte[] GetData()
18 | {
19 | var data = new byte[8];
20 | Array.Copy(base.GetData(), 0, data, 0, 4);
21 | Array.Copy(BitConverter.GetBytes(_directory), 0, data, 4, 4);
22 | return data;
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsCloseFileCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsClose)]
8 | internal class EfsCloseFileCommandRequest : BaseSubSystemCommandRequest
9 | {
10 | private readonly int _file;
11 |
12 | public EfsCloseFileCommandRequest(int file)
13 | {
14 | _file = file;
15 | }
16 |
17 | public override byte[] GetData()
18 | {
19 | var data = new byte[8];
20 | Array.Copy(base.GetData(), 0, data, 0, 4);
21 | Array.Copy(BitConverter.GetBytes(_file), 0, data, 4, 4);
22 | return data;
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsDeviceInfoCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsDevInfo)]
7 | internal class EfsDeviceInfoCommandRequest : BaseSubSystemCommandRequest
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsFStatFileCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsFstat)]
8 | internal class EfsFStatFileCommandRequest : BaseSubSystemCommandRequest
9 | {
10 | private readonly int _file;
11 |
12 | public EfsFStatFileCommandRequest(int file)
13 | {
14 | _file = file;
15 | }
16 |
17 | public override byte[] GetData()
18 | {
19 | var data = new byte[8];
20 | Array.Copy(base.GetData(), 0, data, 0, 4);
21 | Array.Copy(BitConverter.GetBytes(_file), 0, data, 4, 4);
22 | return data;
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsHelloCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsHello)]
8 | internal class EfsHelloCommandRequest : BaseSubSystemCommandRequest
9 | {
10 | private const uint EfsDefaultWindowSize = 0x100000;
11 | private const uint EfsDefaultWindowByteSize = 0x100000;
12 | private const uint EfsVersion = 0x0001;
13 | private const uint EfsMinVersion = 0x0001;
14 | private const uint EfsMaxVersion = 0x0001;
15 |
16 | public override byte[] GetData()
17 | {
18 | var data = new byte[44];
19 | Array.Copy(base.GetData(), 0, data, 0, 4);
20 | Array.Copy(BitConverter.GetBytes(EfsDefaultWindowSize), 0, data, 4, 4);
21 | Array.Copy(BitConverter.GetBytes(EfsDefaultWindowByteSize), 0, data, 8, 4);
22 | Array.Copy(BitConverter.GetBytes(EfsDefaultWindowSize), 0, data, 12, 4);
23 | Array.Copy(BitConverter.GetBytes(EfsDefaultWindowByteSize), 0, data, 16, 4);
24 | Array.Copy(BitConverter.GetBytes(EfsDefaultWindowSize), 0, data, 20, 4);
25 | Array.Copy(BitConverter.GetBytes(EfsDefaultWindowByteSize), 0, data, 24, 4);
26 | Array.Copy(BitConverter.GetBytes(EfsVersion), 0, data, 28, 4);
27 | Array.Copy(BitConverter.GetBytes(EfsMinVersion), 0, data, 32, 4);
28 | Array.Copy(BitConverter.GetBytes(EfsMaxVersion), 0, data, 36, 4);
29 | data[40] = 0xFF;
30 | data[41] = 0xFF;
31 | data[42] = 0xFF;
32 | data[43] = 0xFF;
33 | return data;
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsMakeDirectoryCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
6 | {
7 | [QcdmCommand(QcdmCommand.SubsysCmd)]
8 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsMkdir)]
9 | internal class EfsMakeDirectoryCommandRequest : BaseSubSystemCommandRequest
10 | {
11 | private readonly ushort _mode;
12 | private readonly string _name;
13 |
14 | public EfsMakeDirectoryCommandRequest(ushort mode, string name)
15 | {
16 | _mode = mode;
17 | _name = name;
18 | }
19 |
20 | public override byte[] GetData()
21 | {
22 | var data = new byte[7 + _name.Length];
23 | Array.Copy(base.GetData(), 0, data, 0, 4);
24 | Array.Copy(BitConverter.GetBytes(_mode), 0, data, 4, 2);
25 | Array.Copy(Encoding.ASCII.GetBytes(_name), 0, data, 6, _name.Length);
26 | data[6 + _name.Length] = 0;
27 | return data;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsOpenDirectoryCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
6 | {
7 | [QcdmCommand(QcdmCommand.SubsysCmd)]
8 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsOpenDir)]
9 | internal class EfsOpenDirectoryCommandRequest : BaseSubSystemCommandRequest
10 | {
11 | private readonly string _fileName;
12 |
13 | public EfsOpenDirectoryCommandRequest(string fileName)
14 | {
15 | _fileName = fileName;
16 | }
17 |
18 | public override byte[] GetData()
19 | {
20 | var data = new byte[5 + _fileName.Length];
21 | Array.Copy(base.GetData(), 0, data, 0, 4);
22 | Array.Copy(Encoding.ASCII.GetBytes(_fileName), 0, data, 4, _fileName.Length);
23 | data[4 + _fileName.Length] = 0;
24 | return data;
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsOpenFileCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
6 | {
7 | [Flags]
8 | internal enum EfsFileFlag
9 | {
10 | Readonly = 00000, // open for reading only
11 | Writeonly = 00001, // open for writing only
12 | ReadWrite = 00002, // open for reading and writing
13 | AccessMode = 00003,
14 | Create = 00100, // create and open file
15 | Exclude = 00200, // open and truncate
16 | Truncate = 01000, // open only if file doesn't already exist
17 | Append = 02000, // writes done at eof
18 | NoDelay = 04000, //
19 | Sync = 010000, //
20 | FaSync = 020000, //
21 | Direct = 040000, //
22 | LargeFile = 0100000, //
23 | Directory = 0200000, //
24 | NoFollow = 0400000, //
25 | ItemFile = 01000000, //
26 | AutoDir = 02000000
27 | }
28 |
29 |
30 | [QcdmCommand(QcdmCommand.SubsysCmd)]
31 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsOpen)]
32 | internal class EfsOpenFileCommandRequest : BaseSubSystemCommandRequest
33 | {
34 | private readonly string _fileName;
35 | private readonly EfsFileFlag _flags;
36 | private readonly int _permission;
37 |
38 | public EfsOpenFileCommandRequest(string fileName, EfsFileFlag flags, int permission)
39 | {
40 | _fileName = fileName;
41 | _flags = flags;
42 | _permission = permission;
43 | }
44 |
45 | public override byte[] GetData()
46 | {
47 | var data = new byte[13 + _fileName.Length];
48 | Array.Copy(base.GetData(), 0, data, 0, 4);
49 | Array.Copy(BitConverter.GetBytes((int) _flags), 0, data, 4, 4);
50 | Array.Copy(BitConverter.GetBytes(_permission), 0, data, 8, 4);
51 | Array.Copy(Encoding.ASCII.GetBytes(_fileName), 0, data, 12, _fileName.Length);
52 | data[12 + _fileName.Length] = 0;
53 | return data;
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsPutItemFileCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
6 | {
7 | [QcdmCommand(QcdmCommand.SubsysCmd)]
8 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsPut)]
9 | internal class EfsPutItemFileCommandRequest : BaseSubSystemCommandRequest
10 | {
11 | private readonly byte[] _data;
12 |
13 | private readonly string _fileName;
14 | private readonly EfsFileFlag _flags;
15 | private readonly int _permission;
16 |
17 | public EfsPutItemFileCommandRequest(string fileName, EfsFileFlag flags, int permission, byte[] data)
18 | {
19 | _fileName = fileName;
20 | _flags = flags;
21 | _permission = permission;
22 | _data = data;
23 | }
24 |
25 | public override byte[] GetData()
26 | {
27 | var data = new byte[25 + _fileName.Length + _data.Length];
28 | var i = 0;
29 | Array.Copy(base.GetData(), 0, data, i, 4);
30 | i += 4;
31 | Array.Copy(BitConverter.GetBytes(_data.Length), 0, data, i, 2);
32 | i += 4;
33 |
34 | Array.Copy(BitConverter.GetBytes((int) _flags), 0, data, i, 4);
35 | i += 4;
36 | Array.Copy(BitConverter.GetBytes(_permission), 0, data, i, 4);
37 | i += 2;
38 |
39 |
40 | Array.Copy(_data, 0, data, i, _data.Length);
41 | i += _data.Length;
42 |
43 | Array.Copy(Encoding.ASCII.GetBytes(_fileName), 0, data, i, _fileName.Length);
44 | i += _fileName.Length;
45 |
46 |
47 | data[i] = 0;
48 | return data;
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsQueryCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsQuery)]
7 | internal class EfsQueryCommandRequest : BaseSubSystemCommandRequest
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsReadDirectoryCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsReadDir)]
8 | internal class EfsReadDirectoryCommandRequest : BaseSubSystemCommandRequest
9 | {
10 | private readonly int _directory;
11 | private readonly int _sequenceNumber;
12 |
13 | public EfsReadDirectoryCommandRequest(int dir, int sequenceNumber)
14 | {
15 | _directory = dir;
16 | _sequenceNumber = sequenceNumber;
17 | }
18 |
19 | public override byte[] GetData()
20 | {
21 | var data = new byte[12];
22 | Array.Copy(base.GetData(), 0, data, 0, 4);
23 | Array.Copy(BitConverter.GetBytes(_directory), 0, data, 4, 4);
24 | Array.Copy(BitConverter.GetBytes(_sequenceNumber), 0, data, 8, 4);
25 | return data;
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsReadFileCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsRead)]
8 | internal class EfsReadFileCommandRequest : BaseSubSystemCommandRequest
9 | {
10 | private readonly int _file;
11 | private readonly uint _offset;
12 | private readonly uint _size;
13 |
14 | public EfsReadFileCommandRequest(int file, uint size, uint offset)
15 | {
16 | _file = file;
17 | _size = size;
18 | _offset = offset;
19 | }
20 |
21 | public override byte[] GetData()
22 | {
23 | var data = new byte[16];
24 | Array.Copy(base.GetData(), 0, data, 0, 4);
25 | Array.Copy(BitConverter.GetBytes(_file), 0, data, 4, 4);
26 | Array.Copy(BitConverter.GetBytes(_size), 0, data, 8, 4);
27 | Array.Copy(BitConverter.GetBytes(_offset), 0, data, 12, 4);
28 | return data;
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsRemoveDirectoryCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
6 | {
7 | [QcdmCommand(QcdmCommand.SubsysCmd)]
8 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsRmdir)]
9 | internal class EfsRemoveDirectoryCommandRequest : BaseSubSystemCommandRequest
10 | {
11 | private readonly string _name;
12 |
13 | public EfsRemoveDirectoryCommandRequest(string name)
14 | {
15 | _name = name;
16 | }
17 |
18 | public override byte[] GetData()
19 | {
20 | var data = new byte[5 + _name.Length];
21 | Array.Copy(base.GetData(), 0, data, 0, 4);
22 | Array.Copy(Encoding.ASCII.GetBytes(_name), 0, data, 4, _name.Length);
23 | data[4 + _name.Length] = 0;
24 | return data;
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsRenameFileCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
6 | {
7 | [QcdmCommand(QcdmCommand.SubsysCmd)]
8 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsRename)]
9 | internal class EfsRenameFileCommandRequest : BaseSubSystemCommandRequest
10 | {
11 | private readonly string _newPath;
12 |
13 | private readonly string _path;
14 |
15 | public EfsRenameFileCommandRequest(string path, string newPath)
16 | {
17 | _path = path;
18 | _newPath = newPath;
19 | }
20 |
21 | public override byte[] GetData()
22 | {
23 | var data = new byte[6 + _path.Length + _newPath.Length];
24 | Array.Copy(base.GetData(), 0, data, 0, 4);
25 | Array.Copy(Encoding.ASCII.GetBytes(_path), 0, data, 4, _path.Length);
26 | data[4 + _path.Length] = 0;
27 | Array.Copy(Encoding.ASCII.GetBytes(_newPath), 0, data, 5 + _path.Length, _newPath.Length);
28 | data[5 + _path.Length + _newPath.Length] = 0;
29 | return data;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsStatFileCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
6 | {
7 | [QcdmCommand(QcdmCommand.SubsysCmd)]
8 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsStat)]
9 | internal class EfsStatFileCommandRequest : BaseSubSystemCommandRequest
10 | {
11 | private readonly string _fileName;
12 |
13 | public EfsStatFileCommandRequest(string fileName)
14 | {
15 | _fileName = fileName;
16 | }
17 |
18 | public override byte[] GetData()
19 | {
20 | var data = new byte[5 + _fileName.Length];
21 | Array.Copy(base.GetData(), 0, data, 0, 4);
22 | Array.Copy(Encoding.ASCII.GetBytes(_fileName), 0, data, 4, _fileName.Length);
23 | data[4 + _fileName.Length] = 0;
24 | return data;
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsSyncNoWaitCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
6 | {
7 | [QcdmCommand(QcdmCommand.SubsysCmd)]
8 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsSyncNoWait)]
9 | internal class EfsSyncNoWaitCommandRequest : BaseSubSystemCommandRequest
10 | {
11 | private readonly string _path;
12 | private readonly ushort _sequence;
13 |
14 | public EfsSyncNoWaitCommandRequest(string path, ushort sequence)
15 | {
16 | _path = path;
17 | _sequence = sequence;
18 | }
19 |
20 | public override byte[] GetData()
21 | {
22 | var data = new byte[7 + _path.Length];
23 | Array.Copy(base.GetData(), 0, data, 0, 4);
24 | Array.Copy(BitConverter.GetBytes(_sequence), 0, data, 4, 2);
25 | Array.Copy(Encoding.ASCII.GetBytes(_path), 0, data, 6, _path.Length);
26 | data[6 + _path.Length] = 0;
27 | return data;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsUnlinkFileCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
6 | {
7 | [QcdmCommand(QcdmCommand.SubsysCmd)]
8 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsUnlink)]
9 | internal class EfsUnlinkFileCommandRequest : BaseSubSystemCommandRequest
10 | {
11 | private readonly string _path;
12 |
13 | public EfsUnlinkFileCommandRequest(string path)
14 | {
15 | _path = path;
16 | }
17 |
18 | public override byte[] GetData()
19 | {
20 | var data = new byte[5 + _path.Length];
21 | Array.Copy(base.GetData(), 0, data, 0, 4);
22 | Array.Copy(Encoding.ASCII.GetBytes(_path), 0, data, 4, _path.Length);
23 | data[4 + _path.Length] = 0;
24 | return data;
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Efs/EfsWriteFileCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsWrite)]
8 | internal class EfsWriteFileCommandRequest : BaseSubSystemCommandRequest
9 | {
10 | private readonly byte[] _data;
11 | private readonly int _dataCount;
12 | private readonly int _dataOffset;
13 |
14 | private readonly int _file;
15 | private readonly uint _offset;
16 |
17 | public EfsWriteFileCommandRequest(int file, uint offset, byte[] data, int dataOffset, int dataCount)
18 | {
19 | _file = file;
20 | _offset = offset;
21 | _data = data;
22 | _dataOffset = dataOffset;
23 | _dataCount = dataCount;
24 | }
25 |
26 | public override byte[] GetData()
27 | {
28 | var data = new byte[12 + _dataCount];
29 | Array.Copy(base.GetData(), 0, data, 0, 4);
30 | Array.Copy(BitConverter.GetBytes(_file), 0, data, 4, 4);
31 | Array.Copy(BitConverter.GetBytes(_offset), 0, data, 8, 4);
32 | Array.Copy(_data, _dataOffset, data, 12, _dataCount);
33 | return data;
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/EventMaskGetCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
4 | {
5 | [QcdmCommand(QcdmCommand.EventMaskGet)]
6 |
7 | // C:\Projects\Tmp\QualcommModem\msm8626\adsp_proc\core\services\diag\LSM\common\src\diagdiag_v.h
8 | //typedef PACK(struct)
9 | //{
10 | //byte opaque_header; /*!< -- Header for the diagnostic packet */
11 | //}
12 | //diagpkt_header_type;
13 |
14 | //typedef struct {
15 | //diagpkt_header_type header;
16 | //uint8 pad;
17 | //uint16 reserved;
18 | //uint16 numbits; /* number of bits in the mask */
19 | //unsigned char mask[1]; /* size of this field = (numbits + 7)/8 */
20 | //} event_mask_set_req_type;
21 | internal class EventMaskGetCommandRequest : BaseCommandRequest
22 | {
23 | public override byte[] GetData()
24 | {
25 | var data = new byte[4];
26 | data[0] = (byte) Command;
27 | data[1] = 0;
28 | data[2] = 0;
29 | data[3] = 0;
30 | return data;
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/EventMaskSetCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 | using EfsTools.Qualcomm.QcdmCommands.Base;
3 | using EfsTools.Utils;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
6 | {
7 | [QcdmCommand(QcdmCommand.EventMaskSet)]
8 |
9 | // C:\Projects\Tmp\QualcommModem\msm8626\adsp_proc\core\services\diag\LSM\common\src\diagdiag_v.h
10 | //typedef PACK(struct)
11 | //{
12 | //byte opaque_header; /*!< -- Header for the diagnostic packet */
13 | //}
14 | //diagpkt_header_type;
15 |
16 | //typedef struct {
17 | //diagpkt_header_type header;
18 | //uint8 pad;
19 | //uint16 reserved;
20 | //uint16 numbits; /* number of bits in the mask */
21 | //unsigned char mask[1]; /* size of this field = (numbits + 7)/8 */
22 | //} event_mask_set_req_type;
23 | internal class EventMaskSetCommandRequest : BaseCommandRequest
24 | {
25 | private readonly EventId[] _enableEvents;
26 |
27 | public EventMaskSetCommandRequest(EventId[] enableEvents)
28 | {
29 | _enableEvents = enableEvents;
30 | }
31 |
32 | public int MaxMaskBitsCount => 0x0C86;
33 |
34 | public override byte[] GetData()
35 | {
36 | var maskLength = (MaxMaskBitsCount + 7) / 8;
37 | var data = new byte[6 + maskLength];
38 | data[0] = (byte) Command;
39 | data[1] = 0;
40 | data[2] = 0;
41 | data[3] = 0;
42 | data[4] = (byte) (MaxMaskBitsCount & 0xFF);
43 | data[5] = (byte) ((MaxMaskBitsCount >> 8) & 0xFF);
44 | foreach (var enableEvent in _enableEvents)
45 | {
46 | BitsUtils.SetBitAsBool(data, 6, (int) enableEvent, true);
47 | }
48 |
49 | return data;
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/EventReportCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
4 | {
5 | [QcdmCommand(QcdmCommand.EventReport)]
6 | internal class EventReportCommandRequest : BaseCommandRequest
7 | {
8 | private readonly bool _enable;
9 |
10 | public EventReportCommandRequest(bool enable)
11 | {
12 | _enable = enable;
13 | }
14 |
15 | public override byte[] GetData()
16 | {
17 | var data = new byte[2];
18 | data[0] = (byte) Command;
19 | data[1] = _enable ? (byte) 1 : (byte) 0;
20 | return data;
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/ExtMessageConfigCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 | using EfsTools.Qualcomm.QcdmCommands.Base;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
5 | {
6 | internal enum ExtMessageConfigOperation
7 | {
8 | Disable = 0,
9 | RetrieveIdRanges = 1,
10 | RetrieveValidMask = 2,
11 | SetMask = 4
12 | }
13 |
14 | [QcdmCommand(QcdmCommand.ExtMsgConfig)]
15 | internal class ExtMessageConfigCommandRequest : BaseCommandRequest
16 | {
17 | private readonly MessageId[] _enabledMessageIds;
18 | private readonly int _end;
19 | private readonly ExtMessageConfigOperation _operation;
20 | private readonly int _start;
21 |
22 | public ExtMessageConfigCommandRequest(ExtMessageConfigOperation operation, int start, int end,
23 | MessageId[] enabledMessageIds)
24 | {
25 | _operation = operation;
26 | _start = start;
27 | _end = end;
28 | _enabledMessageIds = enabledMessageIds;
29 | }
30 |
31 | public override byte[] GetData()
32 | {
33 | byte[] data = null;
34 | switch (_operation)
35 | {
36 | case ExtMessageConfigOperation.Disable:
37 | case ExtMessageConfigOperation.RetrieveIdRanges:
38 | data = GetMaskData();
39 | break;
40 | case ExtMessageConfigOperation.RetrieveValidMask:
41 | data = GetRetrieveValidMaskData();
42 | break;
43 | case ExtMessageConfigOperation.SetMask:
44 | data = GetSetMaskData();
45 | break;
46 | }
47 |
48 | return data;
49 | }
50 |
51 | private byte[] GetSetMaskData()
52 | {
53 | var messagesLength = _end - _start + 1;
54 | var data = new byte[messagesLength * 4 + 11];
55 | data[0] = (byte) Command;
56 | data[1] = (byte) _operation;
57 | data[2] = (byte) (_start & 0xFF);
58 | data[3] = (byte) ((_start >> 8) & 0xFF);
59 | data[4] = (byte) (_end & 0xFF);
60 | data[5] = (byte) ((_end >> 8) & 0xFF);
61 | data[6] = 0;
62 | data[7] = 0;
63 |
64 | foreach (var enabledMessage in _enabledMessageIds)
65 | {
66 | var ind = (int) enabledMessage - _start;
67 | var index = ind * 4 + 8;
68 | data[index] = 0xFF;
69 | data[index + 1] = 0xFF;
70 | data[index + 2] = 0xFF;
71 | data[index + 3] = 0xFF;
72 | }
73 |
74 | return data;
75 | }
76 |
77 | private byte[] GetMaskData()
78 | {
79 | var data = new byte[2];
80 | data[0] = (byte) Command;
81 | data[1] = (byte) _operation;
82 | return data;
83 | }
84 |
85 | private byte[] GetRetrieveValidMaskData()
86 | {
87 | var data = new byte[6];
88 | data[0] = (byte) Command;
89 | data[1] = (byte) _operation;
90 | data[2] = (byte) (_start & 0xFF);
91 | data[3] = (byte) ((_start >> 8) & 0xFF);
92 | data[4] = (byte) (_end & 0xFF);
93 | data[5] = (byte) ((_end >> 8) & 0xFF);
94 | return data;
95 | }
96 | }
97 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/ExtentedBuildIdCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
4 | {
5 | [QcdmCommand(QcdmCommand.ExtBuildId)]
6 | internal class ExtentedBuildIdCommandRequest : BaseCommandRequest
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Gsm/GsmVersionCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Gsm
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.Gsm, 0)]
7 | internal class GsmVersionCommandRequest : BaseSubSystemCommandRequest
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/GuidCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
4 | {
5 | [QcdmCommand(QcdmCommand.GetGuid)]
6 | internal class GuidCommandRequest : BaseCommandRequest
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/LogCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
4 | {
5 | [QcdmCommand(QcdmCommand.Log)]
6 | internal class LogCommandRequest : BaseCommandRequest
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/LogConfigCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 | using EfsTools.Qualcomm.QcdmCommands.Base;
5 | using EfsTools.Utils;
6 |
7 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
8 | {
9 | internal enum LogConfigOperation
10 | {
11 | Disable = 0,
12 | RetrieveIdRanges = 1,
13 | RetrieveValidMask = 2,
14 | SetMask = 3,
15 | GetLMask = 4
16 | }
17 |
18 | [QcdmCommand(QcdmCommand.LogConfig)]
19 | internal class LogConfigCommandRequest : BaseCommandRequest
20 | {
21 | private readonly HashSet _enabledLogIds;
22 | private readonly LogConfigOperation _operation;
23 | private readonly Tuple _range;
24 | private readonly int _scope;
25 |
26 | public LogConfigCommandRequest(LogConfigOperation operation, int scope, Tuple range,
27 | LogId[] enabledLogIds)
28 | {
29 | _operation = operation;
30 | _scope = scope;
31 | _enabledLogIds = enabledLogIds == null ? new HashSet() : new HashSet(enabledLogIds);
32 | _range = range;
33 | }
34 |
35 | public override byte[] GetData()
36 | {
37 | byte[] result = null;
38 | switch (_operation)
39 | {
40 | case LogConfigOperation.Disable:
41 | case LogConfigOperation.RetrieveIdRanges:
42 | case LogConfigOperation.RetrieveValidMask:
43 | case LogConfigOperation.GetLMask:
44 | result = GetCommandData();
45 | break;
46 | case LogConfigOperation.SetMask:
47 | result = GetSetMaskData();
48 | break;
49 | default:
50 | result = GetCommandData();
51 | break;
52 | }
53 |
54 | return result;
55 | }
56 |
57 | private byte[] GetSetMaskData()
58 | {
59 | var size = ((int) _range.Item2 - (int) _range.Item1) / 8 + 16;
60 | var scopeDelta = _scope * 0x1000;
61 | var begin = (int) _range.Item1 < scopeDelta ? _range.Item1 : _range.Item1 - scopeDelta;
62 | var end = (int) _range.Item2 < scopeDelta ? _range.Item2 : _range.Item2 - scopeDelta;
63 | var data = new byte[size];
64 | data[0] = (byte) Command;
65 | data[1] = 0;
66 | data[2] = 0;
67 | data[3] = 0;
68 | data[4] = (byte) ((int) _operation & 0xFF);
69 | data[5] = 0;
70 | data[6] = 0;
71 | data[7] = 0;
72 | data[8] = (byte) (_scope & 0xFF);
73 | data[9] = 0;
74 | data[10] = (byte) ((int) begin & 0xFF);
75 | data[11] = (byte) (((int) begin >> 8) & 0xFF);
76 | data[12] = (byte) ((int) end & 0xFF);
77 | data[13] = (byte) (((int) end >> 8) & 0xFF);
78 | data[14] = 0;
79 | data[15] = 0;
80 |
81 | if (_enabledLogIds.Count > 0)
82 | {
83 | for (var id = begin; id <= end; ++id)
84 | {
85 | if (_enabledLogIds.Contains(id + scopeDelta))
86 | {
87 | BitsUtils.SetBitAsBool(data, 16, (int) id, true);
88 | }
89 | }
90 | }
91 |
92 | return data;
93 | }
94 |
95 | private byte[] GetCommandData()
96 | {
97 | var data = new byte[8];
98 | data[0] = (byte) Command;
99 | data[1] = 0;
100 | data[2] = 0;
101 | data[3] = 0;
102 | data[4] = (byte) ((int) _operation & 0xFF);
103 | data[5] = 0;
104 | data[6] = 0;
105 | data[7] = 0;
106 | return data;
107 | }
108 | }
109 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/LogMaskCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 | using EfsTools.Qualcomm.QcdmCommands.Base;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
5 | {
6 | [QcdmCommand(QcdmCommand.Logmask)]
7 | internal class LogMaskCommandRequest : BaseCommandRequest
8 | {
9 | private readonly LogId[] _enabledLogIds;
10 |
11 | public LogMaskCommandRequest(LogId[] enabledLogIds)
12 | {
13 | _enabledLogIds = enabledLogIds;
14 | }
15 |
16 | public override byte[] GetData()
17 | {
18 | /*var maskLength = (MaxMaskBitsCount + 7) / 8;
19 | var data = new byte[6 + maskLength];
20 | data[0] = (byte) Command;
21 | data[1] = 0;
22 | data[2] = 0;
23 | data[3] = 0;
24 | data[4] = (byte)(MaxMaskBitsCount & 0xFF);
25 | data[5] = (byte)((MaxMaskBitsCount >> 8) & 0xFF);
26 | foreach (var enableEvent in _enableEvents)
27 | {
28 | BitsUtils.SetBitAsBool(data, 6, (int) enableEvent, true);
29 | }
30 | return data;*/
31 | return null;
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Nv/NvReadCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Nv
5 | {
6 | [QcdmCommand(QcdmCommand.NvRead)]
7 | internal class NvReadCommandRequest : BaseCommandRequest
8 | {
9 | private readonly ushort _itemId;
10 |
11 | public NvReadCommandRequest(ushort itemId)
12 | {
13 | _itemId = itemId;
14 | }
15 |
16 | public override byte[] GetData()
17 | {
18 | var data = new byte[131];
19 | data[0] = (byte) Command;
20 | Array.Copy(BitConverter.GetBytes(_itemId), 0, data, 1, 2);
21 | return data;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/Nv/NvWriteCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Requests.Nv
5 | {
6 | [QcdmCommand(QcdmCommand.NvWrite)]
7 | internal class NvWriteCommandRequest : BaseCommandRequest
8 | {
9 | private readonly byte[] _data;
10 |
11 | private readonly ushort _itemId;
12 |
13 | public NvWriteCommandRequest(ushort itemId, byte[] data)
14 | {
15 | _itemId = itemId;
16 | _data = data;
17 | }
18 |
19 | public override byte[] GetData()
20 | {
21 | var size = 3 + _data.Length;
22 | var data = new byte[size];
23 | data[0] = (byte) Command;
24 | Array.Copy(BitConverter.GetBytes(_itemId), 0, data, 1, 2);
25 | Array.Copy(_data, 0, data, 3, _data.Length);
26 | return data;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/PasswordCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
6 | {
7 | [QcdmCommand(QcdmCommand.Password)]
8 | internal class PasswordCommandRequest : BaseCommandRequest
9 | {
10 | private readonly byte[] _password;
11 |
12 | public PasswordCommandRequest(string password)
13 | {
14 | _password = Encoding.ASCII.GetBytes(password);
15 | }
16 |
17 | public override byte[] GetData()
18 | {
19 | var data = new byte[9];
20 | data[0] = (byte) Command;
21 | var len = Math.Min(_password.Length, 8);
22 | Array.Copy(_password, 0, data, 1, len);
23 | return data;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/SpcCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
6 | {
7 | [QcdmCommand(QcdmCommand.Spc)]
8 | internal class SpcCommandRequest : BaseCommandRequest
9 | {
10 | private readonly byte[] _spc;
11 |
12 | public SpcCommandRequest(string spc)
13 | {
14 | _spc = Encoding.ASCII.GetBytes(spc);
15 | }
16 |
17 | public override byte[] GetData()
18 | {
19 | var data = new byte[7];
20 | data[0] = (byte) Command;
21 | var len = Math.Min(_spc.Length, 6);
22 | Array.Copy(_spc, 0, data, 1, len);
23 | return data;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/TimeCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
4 | {
5 | [QcdmCommand(QcdmCommand.Time)]
6 | internal class TimeCommandRequest : BaseCommandRequest
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Requests/VersionCommandRequest.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Requests
4 | {
5 | [QcdmCommand(QcdmCommand.Version)]
6 | internal class VersionCommandRequest : BaseCommandRequest
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/BadCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
4 | {
5 | [QcdmCommand(QcdmCommand.BadCmd)]
6 | [QcdmMinResponseLength(0)]
7 | internal class BadCommandResponse : BaseCommandResponse
8 | {
9 | private BadCommandResponse()
10 | {
11 | }
12 |
13 | public static BadCommandResponse Parse(byte[] data)
14 | {
15 | var result = new BadCommandResponse();
16 | return result;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/BadParamCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
4 | {
5 | [QcdmCommand(QcdmCommand.BadParm)]
6 | [QcdmMinResponseLength(0)]
7 | internal class BadParamCommandResponse : BaseCommandResponse
8 | {
9 | private BadParamCommandResponse()
10 | {
11 | }
12 |
13 | public static BadParamCommandResponse Parse(byte[] data)
14 | {
15 | var result = new BadParamCommandResponse();
16 | return result;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/BaseCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 | using EfsTools.Resourses;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
6 | {
7 | internal class BaseCommandResponse : IQcdmCommandResponse
8 | {
9 | public BaseCommandResponse()
10 | {
11 | Initialize();
12 | }
13 |
14 | public int MinResponseLength { get; private set; }
15 |
16 | public QcdmCommand Command { get; private set; } = QcdmCommand.Max;
17 |
18 | private void Initialize()
19 | {
20 | var type = GetType();
21 | if (Command == QcdmCommand.Max &&
22 | type.GetCustomAttributes(typeof(QcdmCommandAttribute), true).FirstOrDefault() is QcdmCommandAttribute
23 | attribute)
24 | {
25 | Command = attribute.Command;
26 | }
27 |
28 | if (MinResponseLength == 0 &&
29 | type.GetCustomAttributes(typeof(QcdmMinResponseLengthAttribute), true).FirstOrDefault() is
30 | QcdmMinResponseLengthAttribute attribute2)
31 | {
32 | MinResponseLength = attribute2.MinResponseLength;
33 | }
34 | }
35 |
36 | public virtual void CheckResponse(byte[] data)
37 | {
38 | if (data.Length < MinResponseLength)
39 | {
40 | throw new QcdmManagerException(Strings.QcdmInvalidResponseLength);
41 | }
42 |
43 | var command = (QcdmCommand) data[0];
44 | if (command != Command)
45 | {
46 | throw new QcdmManagerException(Strings.QcdmInvalidResponseCommand);
47 | }
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/BaseSubSystemCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 | using EfsTools.Resourses;
5 |
6 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
7 | {
8 | internal class BaseSubSystemCommandResponse : BaseCommandResponse, IQcdmCommandResponse
9 | {
10 | public BaseSubSystemCommandResponse()
11 | {
12 | Initialize();
13 | }
14 |
15 | public QcdmSubSystem SubSystem { get; private set; } = QcdmSubSystem.Legacy;
16 |
17 | public ushort SubSystemCommand { get; private set; }
18 |
19 | private void Initialize()
20 | {
21 | var type = GetType();
22 | if (SubSystem == QcdmSubSystem.Legacy &&
23 | type.GetCustomAttributes(typeof(QcdmSubSystemCommandAttribute), true).FirstOrDefault() is
24 | QcdmSubSystemCommandAttribute attribute)
25 | {
26 | SubSystem = attribute.SubSystem;
27 | SubSystemCommand = attribute.Command;
28 | }
29 | }
30 |
31 | public override void CheckResponse(byte[] data)
32 | {
33 | if (data.Length < MinResponseLength)
34 | {
35 | throw new QcdmManagerException(Strings.QcdmInvalidResponseLength);
36 | }
37 |
38 | var command = (QcdmCommand) data[0];
39 | if (command != Command)
40 | {
41 | throw new QcdmManagerException(Strings.QcdmInvalidResponseCommand);
42 | }
43 |
44 | var subSystem = (QcdmSubSystem) data[1];
45 | if (subSystem != SubSystem)
46 | {
47 | throw new QcdmManagerException(Strings.QcdmInvalidResponseCommand);
48 | }
49 |
50 | var subSystemCommand = BitConverter.ToUInt16(data, 2);
51 | if (subSystemCommand != SubSystemCommand)
52 | {
53 | throw new QcdmManagerException(Strings.QcdmInvalidResponseCommand);
54 | }
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/CallManager/CallManagerStateInfoCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.CallManager
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.CallManager, 0)]
8 | [QcdmMinResponseLength(6)]
9 | internal class CallManagerStateInfoCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private CallManagerStateInfoCommandResponse()
12 | {
13 | }
14 |
15 | public ushort CallState { get; private set; }
16 |
17 | public static CallManagerStateInfoCommandResponse Parse(byte[] data)
18 | {
19 | var result = new CallManagerStateInfoCommandResponse();
20 | result.CheckResponse(data);
21 | result.CallState = BitConverter.ToUInt16(data, 4);
22 | return result;
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/DiagServ/GetDebugMessageAllocationCountResponse.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.DiagServ
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.DiagServ, (ushort) QcdmDiagServCommand.GetDebugMessageAllocationCount)]
7 | [QcdmMinResponseLength(8)]
8 | internal class
9 | GetDebugMessageAllocationCountResponse : Int32BaseSubSystemCommandResponse<
10 | GetDebugMessageAllocationCountResponse>
11 | {
12 | }
13 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/DiagServ/GetDebugMessageDroppedCountResponse.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.DiagServ
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.DiagServ, (ushort) QcdmDiagServCommand.GetDebugMessageDroppedCount)]
7 | [QcdmMinResponseLength(8)]
8 | internal class
9 | GetDebugMessageDroppedCountResponse : Int32BaseSubSystemCommandResponse
10 | {
11 | }
12 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/DiagServ/GetEventAllocationCountResponse.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.DiagServ
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.DiagServ, (ushort) QcdmDiagServCommand.GetEventAllocationCount)]
7 | [QcdmMinResponseLength(8)]
8 | internal class GetEventAllocationCountResponse : Int32BaseSubSystemCommandResponse
9 | {
10 | }
11 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/DiagServ/GetEventDroppedCountResponse.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.DiagServ
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.DiagServ, (ushort) QcdmDiagServCommand.GetEventDroppedCount)]
7 | [QcdmMinResponseLength(8)]
8 | internal class GetEventDroppedCountResponse : Int32BaseSubSystemCommandResponse
9 | {
10 | }
11 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/DiagServ/GetLogAllocationCountResponse.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.DiagServ
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.DiagServ, (ushort) QcdmDiagServCommand.GetLogAllocationCount)]
7 | [QcdmMinResponseLength(8)]
8 | internal class GetLogAllocationCountResponse : Int32BaseSubSystemCommandResponse
9 | {
10 | }
11 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/DiagServ/GetLogDroppedCountResponse.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.DiagServ
4 | {
5 | [QcdmCommand(QcdmCommand.SubsysCmd)]
6 | [QcdmSubSystemCommand(QcdmSubSystem.DiagServ, (ushort) QcdmDiagServCommand.GetLogDroppedCount)]
7 | [QcdmMinResponseLength(8)]
8 | internal class GetLogDroppedCountResponse : Int32BaseSubSystemCommandResponse
9 | {
10 | }
11 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/DiagVersionCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
5 | {
6 | [QcdmCommand(QcdmCommand.DiagVersion)]
7 | [QcdmMinResponseLength(3)]
8 | internal class DiagVersionCommandResponse : BaseCommandResponse
9 | {
10 | private DiagVersionCommandResponse()
11 | {
12 | }
13 |
14 | public ushort Version { get; private set; }
15 |
16 | public static DiagVersionCommandResponse Parse(byte[] data)
17 | {
18 | var result = new DiagVersionCommandResponse();
19 | result.CheckResponse(data);
20 |
21 | result.Version = BitConverter.ToUInt16(data, 1);
22 | return result;
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsAccessCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsAccess)]
8 | [QcdmMinResponseLength(8)]
9 | internal class EfsAccessCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private EfsAccessCommandResponse()
12 | {
13 | }
14 |
15 | public QcdmEfsErrors Error { get; private set; }
16 |
17 | public static EfsAccessCommandResponse Parse(byte[] data)
18 | {
19 | var result = new EfsAccessCommandResponse();
20 | result.CheckResponse(data);
21 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 4);
22 | result.Error = error;
23 | return result;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsCloseDirectoryCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsCloseDir)]
8 | [QcdmMinResponseLength(8)]
9 | internal class EfsCloseDirectoryCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private EfsCloseDirectoryCommandResponse()
12 | {
13 | }
14 |
15 | public QcdmEfsErrors Error { get; private set; }
16 |
17 | public static EfsCloseDirectoryCommandResponse Parse(byte[] data)
18 | {
19 | var result = new EfsCloseDirectoryCommandResponse();
20 | result.CheckResponse(data);
21 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 4);
22 | result.Error = error;
23 | return result;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsCloseFileCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsClose)]
8 | [QcdmMinResponseLength(8)]
9 | internal class EfsCloseFileCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private EfsCloseFileCommandResponse()
12 | {
13 | }
14 |
15 | public QcdmEfsErrors Error { get; private set; }
16 |
17 | public static EfsCloseFileCommandResponse Parse(byte[] data)
18 | {
19 | var result = new EfsCloseFileCommandResponse();
20 | result.CheckResponse(data);
21 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 4);
22 | result.Error = error;
23 | return result;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsDeviceInfoResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
6 | {
7 | internal class EfsDeviceInfo
8 | {
9 | public EfsDeviceInfo(
10 | int totalNumberOfBlocks,
11 | int pagesPerBlock,
12 | int pageSize,
13 | int totalPageSize,
14 | int makerId,
15 | int deviceId,
16 | byte deviceType,
17 | string name
18 | )
19 | {
20 | TotalNumberOfBlocks = totalNumberOfBlocks;
21 | PagesPerBlock = pagesPerBlock;
22 | PageSize = pageSize;
23 | TotalPageSize = totalPageSize;
24 | MakerId = makerId;
25 | DeviceId = deviceId;
26 | DeviceType = deviceType;
27 | Name = name;
28 | }
29 |
30 | public int TotalNumberOfBlocks { get; }
31 | public int PagesPerBlock { get; }
32 | public int PageSize { get; }
33 | public int TotalPageSize { get; }
34 | public int MakerId { get; }
35 | public int DeviceId { get; }
36 | public byte DeviceType { get; }
37 | public string Name { get; }
38 | }
39 |
40 | [QcdmCommand(QcdmCommand.SubsysCmd)]
41 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsDevInfo)]
42 | [QcdmMinResponseLength(41)]
43 | internal class EfsDeviceInfoResponse : BaseSubSystemCommandResponse
44 | {
45 | private EfsDeviceInfoResponse()
46 | {
47 | }
48 |
49 | public QcdmEfsErrors Error { get; private set; }
50 | public EfsDeviceInfo DeviceInfo { get; private set; }
51 |
52 | public static EfsDeviceInfoResponse Parse(byte[] data)
53 | {
54 | var result = new EfsDeviceInfoResponse();
55 | result.CheckResponse(data);
56 |
57 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 4);
58 | result.Error = error;
59 | var totalNumberOfBlocks = BitConverter.ToInt32(data, 8);
60 | var pagesPerBlock = BitConverter.ToInt32(data, 16);
61 | var pageSize = BitConverter.ToInt32(data, 24);
62 | var totalPageSize = BitConverter.ToInt32(data, 28);
63 | var makerId = BitConverter.ToInt32(data, 32);
64 | var deviceId = BitConverter.ToInt32(data, 36);
65 | var deviceType = data[40];
66 | var nameLength = data.Length - 42;
67 | if (nameLength < 0)
68 | {
69 | nameLength = 0;
70 | }
71 |
72 | var name = Encoding.ASCII.GetString(data, 41, nameLength);
73 |
74 |
75 | result.DeviceInfo = new EfsDeviceInfo(totalNumberOfBlocks, pagesPerBlock, pageSize, totalPageSize,
76 | makerId, deviceId, deviceType, name);
77 | return result;
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsFStatFileCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsFstat)]
8 | [QcdmMinResponseLength(32)]
9 | internal class EfsFStatFileCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private EfsFStatFileCommandResponse()
12 | {
13 | }
14 |
15 | public FileStat Stat { get; private set; }
16 |
17 | public static EfsFStatFileCommandResponse Parse(byte[] data)
18 | {
19 | var result = new EfsFStatFileCommandResponse();
20 | result.CheckResponse(data);
21 |
22 | var mode = BitConverter.ToInt32(data, 8);
23 | var size = BitConverter.ToInt32(data, 12);
24 | var linkCount = BitConverter.ToInt32(data, 16);
25 | var atime = BitConverter.ToInt32(data, 20);
26 | var mtime = BitConverter.ToInt32(data, 24);
27 | var ctime = BitConverter.ToInt32(data, 28);
28 | result.Stat = new FileStat(mode, size, linkCount, atime, mtime, ctime);
29 | return result;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsHelloCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | internal class HelloInfo
7 | {
8 | public HelloInfo(
9 | int targetPacketWindowSize,
10 | int targetPacketWindowByteSize,
11 | int hostPacketWindowSize,
12 | int hostPacketWindowByteSize,
13 | int dirIteratorWindowSize,
14 | int dirIteratorWindowByteSize,
15 | int version,
16 | int minVersion,
17 | int maxVersion,
18 | int featureBits
19 | )
20 | {
21 | TargetPacketWindowSize = targetPacketWindowSize;
22 | TargetPacketWindowByteSize = targetPacketWindowByteSize;
23 | HostPacketWindowSize = hostPacketWindowSize;
24 | HostPacketWindowByteSize = hostPacketWindowByteSize;
25 | DirIteratorWindowSize = dirIteratorWindowSize;
26 | DirIteratorWindowByteSize = dirIteratorWindowByteSize;
27 | Version = version;
28 | MinVersion = minVersion;
29 | MaxVersion = maxVersion;
30 | FeatureBits = featureBits;
31 | }
32 |
33 | public int TargetPacketWindowSize { get; }
34 | public int TargetPacketWindowByteSize { get; }
35 | public int HostPacketWindowSize { get; }
36 | public int HostPacketWindowByteSize { get; }
37 | public int DirIteratorWindowSize { get; }
38 | public int DirIteratorWindowByteSize { get; }
39 | public int Version { get; }
40 | public int MinVersion { get; }
41 | public int MaxVersion { get; }
42 | public int FeatureBits { get; }
43 | }
44 |
45 | [QcdmCommand(QcdmCommand.SubsysCmd)]
46 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsHello)]
47 | [QcdmMinResponseLength(44)]
48 | internal class EfsHelloCommandResponse : BaseSubSystemCommandResponse
49 | {
50 | private EfsHelloCommandResponse()
51 | {
52 | }
53 |
54 | public HelloInfo Info { get; private set; }
55 |
56 | public static EfsHelloCommandResponse Parse(byte[] data)
57 | {
58 | var result = new EfsHelloCommandResponse();
59 | result.CheckResponse(data);
60 |
61 | var targetPacketWindowSize = BitConverter.ToInt32(data, 4);
62 | var targetPacketWindowByteSize = BitConverter.ToInt32(data, 8);
63 | var hostPacketWindowSize = BitConverter.ToInt32(data, 12);
64 | var hostPacketWindowByteSize = BitConverter.ToInt32(data, 16);
65 | var dirIteratorWindowSize = BitConverter.ToInt32(data, 20);
66 | var dirIteratorWindowByteSize = BitConverter.ToInt32(data, 24);
67 | var version = BitConverter.ToInt32(data, 28);
68 | var minVersion = BitConverter.ToInt32(data, 32);
69 | var maxVersion = BitConverter.ToInt32(data, 36);
70 | var featureBits = BitConverter.ToInt32(data, 40);
71 | result.Info = new HelloInfo(targetPacketWindowSize, targetPacketWindowByteSize, hostPacketWindowSize,
72 | hostPacketWindowByteSize, dirIteratorWindowSize, dirIteratorWindowByteSize,
73 | version, minVersion, maxVersion, featureBits);
74 | return result;
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsMakeDirectoryCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsMkdir)]
8 | [QcdmMinResponseLength(8)]
9 | internal class EfsMakeDirectoryCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private EfsMakeDirectoryCommandResponse()
12 | {
13 | }
14 |
15 | public QcdmEfsErrors Error { get; private set; }
16 |
17 | public static EfsMakeDirectoryCommandResponse Parse(byte[] data)
18 | {
19 | var result = new EfsMakeDirectoryCommandResponse();
20 | result.CheckResponse(data);
21 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 4);
22 | result.Error = error;
23 | return result;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsOpenDirectoryCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsOpenDir)]
8 | [QcdmMinResponseLength(12)]
9 | internal class EfsOpenDirectoryCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private EfsOpenDirectoryCommandResponse()
12 | {
13 | }
14 |
15 | public int Directory { get; private set; }
16 | public bool IsError { get; private set; }
17 | public QcdmEfsErrors Error { get; private set; }
18 |
19 | public static EfsOpenDirectoryCommandResponse Parse(byte[] data)
20 | {
21 | var result = new EfsOpenDirectoryCommandResponse();
22 | result.CheckResponse(data);
23 |
24 | var dir = BitConverter.ToInt32(data, 4);
25 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 8);
26 | result.IsError = dir < 0;
27 | result.Error = error;
28 | result.Directory = dir;
29 | return result;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsOpenFileCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsOpen)]
8 | [QcdmMinResponseLength(12)]
9 | internal class EfsOpenFileCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private EfsOpenFileCommandResponse()
12 | {
13 | }
14 |
15 | public int File { get; private set; }
16 | public bool IsError { get; private set; }
17 | public QcdmEfsErrors Error { get; private set; }
18 |
19 | public static EfsOpenFileCommandResponse Parse(byte[] data)
20 | {
21 | var result = new EfsOpenFileCommandResponse();
22 | result.CheckResponse(data);
23 |
24 | var file = BitConverter.ToInt32(data, 4);
25 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 8);
26 | result.IsError = file < 0;
27 | result.Error = error;
28 | result.File = file;
29 | return result;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsPutItemFileCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsPut)]
8 | [QcdmMinResponseLength(10)]
9 | internal class EfsPutItemFileCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private EfsPutItemFileCommandResponse()
12 | {
13 | }
14 |
15 | public short Permissions { get; private set; }
16 | public int BytesWritten { get; private set; }
17 | public QcdmEfsErrors Error { get; private set; }
18 |
19 | public static EfsPutItemFileCommandResponse Parse(byte[] data)
20 | {
21 | var result = new EfsPutItemFileCommandResponse();
22 | result.CheckResponse(data);
23 | result.Permissions = BitConverter.ToInt16(data, 4);
24 | result.Error = (QcdmEfsErrors) BitConverter.ToInt16(data, 6);
25 | result.BytesWritten = BitConverter.ToInt16(data, 8);
26 | return result;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsQueryCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | internal class QueryInfo
7 | {
8 | public QueryInfo(
9 | int maxFilenameLength,
10 | int mapPathnameLength,
11 | int maxSymlinkDepth,
12 | int maxFileSize,
13 | int maxDirectories,
14 | int maxMounts
15 | )
16 | {
17 | MaxFilenameLength = maxFilenameLength;
18 | MapPathnameLength = mapPathnameLength;
19 | MaxSymlinkDepth = maxSymlinkDepth;
20 | MaxFileSize = maxFileSize;
21 | MaxDirectories = maxDirectories;
22 | MaxMounts = maxMounts;
23 | }
24 |
25 | public int MaxFilenameLength { get; }
26 | public int MapPathnameLength { get; }
27 | public int MaxSymlinkDepth { get; }
28 | public int MaxFileSize { get; }
29 | public int MaxDirectories { get; }
30 | public int MaxMounts { get; }
31 | }
32 |
33 | [QcdmCommand(QcdmCommand.SubsysCmd)]
34 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsQuery)]
35 | [QcdmMinResponseLength(28)]
36 | internal class EfsQueryCommandResponse : BaseSubSystemCommandResponse
37 | {
38 | private EfsQueryCommandResponse()
39 | {
40 | }
41 |
42 | public QueryInfo Info { get; private set; }
43 |
44 | public static EfsQueryCommandResponse Parse(byte[] data)
45 | {
46 | var result = new EfsQueryCommandResponse();
47 | result.CheckResponse(data);
48 |
49 | var maxFilenameLength = BitConverter.ToInt32(data, 4);
50 | var mapPathnameLength = BitConverter.ToInt32(data, 8);
51 | var maxSymlinkDepth = BitConverter.ToInt32(data, 12);
52 | var maxFileSize = BitConverter.ToInt32(data, 16);
53 | var maxDirectories = BitConverter.ToInt32(data, 20);
54 | var maxMounts = BitConverter.ToInt32(data, 24);
55 | result.Info = new QueryInfo(maxFilenameLength, mapPathnameLength, maxSymlinkDepth, maxFileSize,
56 | maxDirectories, maxMounts);
57 | return result;
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsReadDirectoryCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
6 | {
7 | internal enum DirectoryEntryType
8 | {
9 | File = 0,
10 | Directory = 1,
11 | Link = 2,
12 | Immovable = 3,
13 | ItemFile = 15
14 | }
15 |
16 | internal class DirectoryEntry
17 | {
18 | public DirectoryEntry(
19 | string name,
20 | DirectoryEntryType entryType,
21 | int mode,
22 | int size,
23 | int atime,
24 | int mtime,
25 | int ctime
26 | )
27 | {
28 | Name = name;
29 | EntryType = entryType;
30 | Mode = mode;
31 | Size = size;
32 | AccessTime = atime;
33 | ModifyTime = mtime;
34 | CreateTime = ctime;
35 | }
36 |
37 | public string Name { get; }
38 | public DirectoryEntryType EntryType { get; }
39 | public int Mode { get; }
40 | public int Size { get; }
41 | public int AccessTime { get; }
42 | public int ModifyTime { get; }
43 | public int CreateTime { get; }
44 | }
45 |
46 | [QcdmCommand(QcdmCommand.SubsysCmd)]
47 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsReadDir)]
48 | [QcdmMinResponseLength(40)]
49 | internal class EfsReadDirectoryCommandResponse : BaseSubSystemCommandResponse
50 | {
51 | private EfsReadDirectoryCommandResponse()
52 | {
53 | }
54 |
55 | public int Directory { get; private set; }
56 | public int SequenceNumber { get; private set; }
57 | public DirectoryEntry DirectoryEntry { get; private set; }
58 | public QcdmEfsErrors Error { get; private set; }
59 |
60 | public static EfsReadDirectoryCommandResponse Parse(byte[] data)
61 | {
62 | var result = new EfsReadDirectoryCommandResponse();
63 | result.CheckResponse(data);
64 |
65 | result.Directory = BitConverter.ToInt32(data, 4);
66 | result.SequenceNumber = BitConverter.ToInt32(data, 8);
67 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 12);
68 | result.Error = error;
69 |
70 | var entryType = (DirectoryEntryType) BitConverter.ToInt32(data, 16);
71 | var mode = BitConverter.ToInt32(data, 20);
72 | var size = BitConverter.ToInt32(data, 24);
73 | var atime = BitConverter.ToInt32(data, 28);
74 | var mtime = BitConverter.ToInt32(data, 32);
75 | var ctime = BitConverter.ToInt32(data, 36);
76 | var nameLength = data.Length - 41;
77 | if (nameLength < 0)
78 | {
79 | nameLength = 0;
80 | }
81 |
82 | var name = Encoding.ASCII.GetString(data, 40, nameLength);
83 | result.DirectoryEntry = new DirectoryEntry(name, entryType, mode, size, atime, mtime, ctime);
84 | return result;
85 | }
86 | }
87 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsReadFileCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 | using EfsTools.Resourses;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
6 | {
7 | [QcdmCommand(QcdmCommand.SubsysCmd)]
8 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsRead)]
9 | [QcdmMinResponseLength(20)]
10 | internal class EfsReadFileCommandResponse : BaseSubSystemCommandResponse
11 | {
12 | private EfsReadFileCommandResponse()
13 | {
14 | }
15 |
16 | public byte[] Data { get; private set; }
17 | public QcdmEfsErrors Error { get; private set; }
18 |
19 | public static EfsReadFileCommandResponse Parse(byte[] data)
20 | {
21 | var result = new EfsReadFileCommandResponse();
22 | result.CheckResponse(data);
23 |
24 | //var file = BitConverter.ToInt32(data, 4);
25 | //var offset = BitConverter.ToUInt32(data, 8); ;
26 | var bytesRead = BitConverter.ToInt32(data, 12);
27 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 16);
28 | result.Error = error;
29 |
30 | if (data.Length < 20 + bytesRead)
31 | {
32 | throw new QcdmManagerException(Strings.QcdmInvalidResponseLength);
33 | }
34 |
35 | var buf = new byte[bytesRead];
36 | Array.Copy(data, 20, buf, 0, bytesRead);
37 | result.Data = buf;
38 | return result;
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsRemoveDirectoryCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsRmdir)]
8 | [QcdmMinResponseLength(8)]
9 | internal class EfsRemoveDirectoryCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private EfsRemoveDirectoryCommandResponse()
12 | {
13 | }
14 |
15 | public QcdmEfsErrors Error { get; private set; }
16 |
17 | public static EfsRemoveDirectoryCommandResponse Parse(byte[] data)
18 | {
19 | var result = new EfsRemoveDirectoryCommandResponse();
20 | result.CheckResponse(data);
21 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 4);
22 | result.Error = error;
23 | return result;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsRenameFileCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsRename)]
8 | [QcdmMinResponseLength(8)]
9 | internal class EfsRenameFileCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private EfsRenameFileCommandResponse()
12 | {
13 | }
14 |
15 | public QcdmEfsErrors Error { get; private set; }
16 |
17 | public static EfsRenameFileCommandResponse Parse(byte[] data)
18 | {
19 | var result = new EfsRenameFileCommandResponse();
20 | result.CheckResponse(data);
21 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 4);
22 | result.Error = error;
23 | return result;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsStatFileCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | internal class FileStat
7 | {
8 | public FileStat(
9 | int mode,
10 | int size,
11 | int linkCount,
12 | int atime,
13 | int mtime,
14 | int ctime
15 | )
16 | {
17 | Mode = mode;
18 | Size = size;
19 | LinkCount = linkCount;
20 | AccessTime = atime;
21 | ModifyTime = mtime;
22 | CreateTime = ctime;
23 | }
24 |
25 | public int Mode { get; }
26 | public int Size { get; }
27 | public int LinkCount { get; }
28 | public int AccessTime { get; }
29 | public int ModifyTime { get; }
30 | public int CreateTime { get; }
31 | }
32 |
33 | [QcdmCommand(QcdmCommand.SubsysCmd)]
34 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsStat)]
35 | [QcdmMinResponseLength(32)]
36 | internal class EfsStatFileCommandResponse : BaseSubSystemCommandResponse
37 | {
38 | private EfsStatFileCommandResponse()
39 | {
40 | }
41 |
42 | public FileStat Stat { get; private set; }
43 |
44 | public static EfsStatFileCommandResponse Parse(byte[] data)
45 | {
46 | var result = new EfsStatFileCommandResponse();
47 | result.CheckResponse(data);
48 |
49 | var mode = BitConverter.ToInt32(data, 8);
50 | var size = BitConverter.ToInt32(data, 12);
51 | var linkCount = BitConverter.ToInt32(data, 16);
52 | var atime = BitConverter.ToInt32(data, 20);
53 | var mtime = BitConverter.ToInt32(data, 24);
54 | var ctime = BitConverter.ToInt32(data, 28);
55 | result.Stat = new FileStat(mode, size, linkCount, atime, mtime, ctime);
56 | return result;
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsSyncNoWaitCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsSyncNoWait)]
8 | [QcdmMinResponseLength(14)]
9 | internal class EfsSyncNoWaitCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private EfsSyncNoWaitCommandResponse()
12 | {
13 | }
14 |
15 | public ushort Sequence { get; private set; }
16 | public uint Token { get; private set; }
17 | public QcdmEfsErrors Error { get; private set; }
18 |
19 | public static EfsSyncNoWaitCommandResponse Parse(byte[] data)
20 | {
21 | var result = new EfsSyncNoWaitCommandResponse();
22 | result.CheckResponse(data);
23 |
24 | result.Sequence = BitConverter.ToUInt16(data, 4);
25 | result.Token = BitConverter.ToUInt32(data, 6);
26 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 10);
27 | result.Error = error;
28 | return result;
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsUnlinkFileCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsUnlink)]
8 | [QcdmMinResponseLength(8)]
9 | internal class EfsUnlinkFileCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private EfsUnlinkFileCommandResponse()
12 | {
13 | }
14 |
15 | public QcdmEfsErrors Error { get; private set; }
16 |
17 | public static EfsUnlinkFileCommandResponse Parse(byte[] data)
18 | {
19 | var result = new EfsUnlinkFileCommandResponse();
20 | result.CheckResponse(data);
21 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 4);
22 | result.Error = error;
23 | return result;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Efs/EfsWriteFileCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Efs
5 | {
6 | [QcdmCommand(QcdmCommand.SubsysCmd)]
7 | [QcdmSubSystemCommand(QcdmSubSystem.Efs, (ushort) QcdmEfsCommand.EfsWrite)]
8 | [QcdmMinResponseLength(20)]
9 | internal class EfsWriteFileCommandResponse : BaseSubSystemCommandResponse
10 | {
11 | private EfsWriteFileCommandResponse()
12 | {
13 | }
14 |
15 | public int BytesWritten { get; private set; }
16 | public QcdmEfsErrors Error { get; private set; }
17 |
18 | public static EfsWriteFileCommandResponse Parse(byte[] data)
19 | {
20 | var result = new EfsWriteFileCommandResponse();
21 | result.CheckResponse(data);
22 |
23 | //var file = BitConverter.ToInt32(data, 4);
24 | //var offset = BitConverter.ToUInt32(data, 8); ;
25 | result.BytesWritten = BitConverter.ToInt32(data, 12);
26 | var error = (QcdmEfsErrors) BitConverter.ToInt32(data, 16);
27 | result.Error = error;
28 |
29 | return result;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/EventMaskGetCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 | using EfsTools.Qualcomm.QcdmCommands.Base;
4 | using EfsTools.Resourses;
5 |
6 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
7 | {
8 | [QcdmCommand(QcdmCommand.EventMaskGet)]
9 | [QcdmMinResponseLength(10)]
10 | internal class EventMaskGetCommandResponse : BaseCommandResponse
11 | {
12 | private EventMaskGetCommandResponse()
13 | {
14 | }
15 |
16 | public bool IsError { get; private set; }
17 |
18 | public EventId[] Events { get; private set; }
19 |
20 | public static EventMaskGetCommandResponse Parse(byte[] data)
21 | {
22 | var result = new EventMaskGetCommandResponse();
23 | result.CheckResponse(data);
24 | var status = data[1];
25 | result.IsError = status != 0;
26 | if (!result.IsError)
27 | {
28 | if (data.Length < 8)
29 | {
30 | throw new QcdmManagerException(Strings.QcdmInvalidResponseCommand);
31 | }
32 |
33 | var count = (data.Length - 8) / 2;
34 | var pos = 8;
35 | var events = new EventId[count];
36 | for (var i = 0; i < count; ++i)
37 | {
38 | events[i] = (EventId) BitConverter.ToUInt16(data, pos);
39 | pos += 2;
40 | }
41 |
42 | result.Events = events;
43 | }
44 |
45 | return result;
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/EventMaskSetCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 | using EfsTools.Qualcomm.QcdmCommands.Base;
4 | using EfsTools.Resourses;
5 | using EfsTools.Utils;
6 |
7 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
8 | {
9 | //typedef struct {
10 | // diagpkt_header_type header;
11 | // uint8 error_code;
12 | // uint16 reserved;
13 | // uint16 numbits; /* number of bits in the mask */
14 | // unsigned char mask[1]; /* size of this field = (numbits + 7)/8 */
15 | // } event_mask_set_rsp_type;
16 |
17 | [QcdmCommand(QcdmCommand.EventMaskSet)]
18 | [QcdmMinResponseLength(10)]
19 | internal class EventMaskSetCommandResponse : BaseCommandResponse
20 | {
21 | private EventMaskSetCommandResponse()
22 | {
23 | }
24 |
25 | public bool IsError { get; private set; }
26 |
27 | public EventId[] EnabledEvents { get; private set; }
28 |
29 | public static EventMaskSetCommandResponse Parse(byte[] data)
30 | {
31 | var result = new EventMaskSetCommandResponse();
32 | result.CheckResponse(data);
33 | var status = data[1];
34 | result.IsError = status != 0;
35 | if (!result.IsError)
36 | {
37 | var numBits = data[4] + (data[5] << 8);
38 | var maskLength = (numBits + 7) / 8;
39 | if (data.Length < maskLength + 6)
40 | {
41 | throw new QcdmManagerException(Strings.QcdmInvalidResponseCommand);
42 | }
43 |
44 | var enabledEvents = new List();
45 | for (var i = 0; i < numBits; ++i)
46 | {
47 | if (BitsUtils.GetBitAsBool(data, 6, i))
48 | {
49 | enabledEvents.Add((EventId) i);
50 | }
51 | }
52 |
53 | result.EnabledEvents = enabledEvents.ToArray();
54 | }
55 |
56 | return result;
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/ExtMsgCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 | using EfsTools.Qualcomm.QcdmCommands.Base;
5 | using EfsTools.Utils;
6 |
7 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
8 | {
9 | //typedef struct
10 | //{
11 | // uint8 cmd_code; /*!< Command code */
12 | // uint8 ts_type; /*!< Time stamp type */
13 | // uint8 num_args; /*!< Number of arguments in message */
14 | // uint8 drop_cnt; /*!< number of messages dropped since last successful message */
15 | // qword ts; /*!< Time stamp */
16 | //}
17 | //msg_hdr_type;
18 |
19 | //typedef struct
20 | //{
21 | // uint16 line; /*!< Line number in source file */
22 | // uint16 ss_id; /*!< Subsystem ID */
23 | // uint32 ss_mask; /*!< Subsystem Mask */
24 | //}
25 | //msg_desc_type;
26 |
27 | //typedef struct
28 | //{
29 | // msg_hdr_type hdr; /*!< Header */
30 | // msg_desc_type desc; /*!< line number, SSID, mask */
31 | // uint32 args[1]; /*!< Array of long args, specified by
32 | // 'hdr.num_args' */
33 | // /*!< followed by NULL terminated format and file strings */
34 | //}
35 | //msg_ext_type;
36 |
37 | [QcdmCommand(QcdmCommand.ExtMsg)]
38 | [QcdmMinResponseLength(20)]
39 | internal class ExtMsgCommandResponse : BaseCommandResponse
40 | {
41 | private ExtMsgCommandResponse()
42 | {
43 | }
44 |
45 | public string Message { get; private set; }
46 | public string Source { get; private set; }
47 |
48 | public ushort Line { get; private set; }
49 |
50 | public ushort SubSystemId { get; private set; }
51 |
52 | public byte DropCount { get; private set; }
53 | public MessageId MessageId { get; private set; }
54 | public DateTime Time { get; private set; }
55 |
56 | public uint Level { get; private set; }
57 |
58 | public static ExtMsgCommandResponse Parse(byte[] data)
59 | {
60 | var result = new ExtMsgCommandResponse();
61 | result.CheckResponse(data);
62 | var tsType = data[1];
63 | var numArgs = data[2];
64 | result.DropCount = data[3];
65 | var ts = BitConverter.ToInt64(data, 4);
66 | result.Time = DateTimeUtils.DateTimeFromQualcommTs(ts);
67 | result.Line = BitConverter.ToUInt16(data, 8);
68 | result.SubSystemId = BitConverter.ToUInt16(data, 10);
69 | var subSystemMask = BitConverter.ToUInt32(data, 12);
70 | var args = new uint[numArgs];
71 | result.Level = (uint) (data[12] + (data[13] << 8));
72 | var messageId = data[14] + (data[15] << 8);
73 | result.MessageId = (MessageId) messageId;
74 | var flags = BitConverter.ToUInt32(data, 16);
75 | var index = 20;
76 | for (var i = 0; i < numArgs; ++i)
77 | {
78 | args[i] = BitConverter.ToUInt32(data, index);
79 | index += 4;
80 | }
81 |
82 | var str = Encoding.ASCII.GetString(data, index, data.Length - index);
83 | var parts = str.Split('\0');
84 | if (parts.Length > 1)
85 | {
86 | result.Message = parts[0].Trim();
87 | }
88 |
89 | if (parts.Length > 2)
90 | {
91 | result.Source = parts[1].Trim();
92 | }
93 |
94 | return result;
95 | }
96 | }
97 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/ExtentedBuildIdCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
6 | {
7 | internal class ExtentedBuildId
8 | {
9 | public ExtentedBuildId(
10 | uint msm,
11 | uint model,
12 | string softwareId,
13 | ushort modelName
14 | )
15 | {
16 | Msm = msm;
17 | MobileModelId = model;
18 | MobileSoftwareId = softwareId;
19 | MobileModelName = modelName;
20 | }
21 |
22 | public uint Msm { get; }
23 | public uint MobileModelId { get; }
24 | public string MobileSoftwareId { get; }
25 | public ushort MobileModelName { get; }
26 | }
27 |
28 | [QcdmCommand(QcdmCommand.ExtBuildId)]
29 | [QcdmMinResponseLength(14)]
30 | internal class ExtentedBuildIdCommandResponse : BaseCommandResponse
31 | {
32 | private ExtentedBuildIdCommandResponse()
33 | {
34 | }
35 |
36 | public ExtentedBuildId BuildId { get; private set; }
37 |
38 | public static ExtentedBuildIdCommandResponse Parse(byte[] data)
39 | {
40 | var result = new ExtentedBuildIdCommandResponse();
41 | result.CheckResponse(data);
42 |
43 | var msm = BitConverter.ToUInt32(data, 4);
44 | var model = BitConverter.ToUInt32(data, 8);
45 | if (data.Length > 70)
46 | {
47 | var softwareId = Encoding.ASCII.GetString(data, 12, 57);
48 | var modelName = BitConverter.ToUInt16(data, 69);
49 | result.BuildId = new ExtentedBuildId(msm, model, softwareId, modelName);
50 | }
51 | else
52 | {
53 | result.BuildId = new ExtentedBuildId(msm, model, string.Empty, (UInt16)0);
54 | }
55 | return result;
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Gsm/GsmVersionCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Gsm
5 | {
6 | internal class GsmVersion
7 | {
8 | public GsmVersion(ushort vDspVersion,
9 | ushort mdspVersionRom,
10 | ushort mdspVersionRam)
11 | {
12 | VocorerDspVersion = vDspVersion;
13 | MdspVersionRom = mdspVersionRom;
14 | MdspVersionRam = mdspVersionRam;
15 | }
16 |
17 | public ushort VocorerDspVersion { get; }
18 | public ushort MdspVersionRom { get; }
19 | public ushort MdspVersionRam { get; }
20 | }
21 |
22 | [QcdmCommand(QcdmCommand.SubsysCmd)]
23 | [QcdmSubSystemCommand(QcdmSubSystem.Gsm, 0)]
24 | [QcdmMinResponseLength(10)]
25 | internal class GsmVersionCommandResponse : BaseSubSystemCommandResponse
26 | {
27 | private GsmVersionCommandResponse()
28 | {
29 | }
30 |
31 | public GsmVersion Version { get; private set; }
32 |
33 | public static GsmVersionCommandResponse Parse(byte[] data)
34 | {
35 | var result = new GsmVersionCommandResponse();
36 | result.CheckResponse(data);
37 |
38 | var vDspVersion = BitConverter.ToUInt16(data, 4);
39 | var mdspVersionRom = BitConverter.ToUInt16(data, 6);
40 | var mdspVersionRam = BitConverter.ToUInt16(data, 8);
41 | result.Version = new GsmVersion(vDspVersion, mdspVersionRom, mdspVersionRam);
42 |
43 | return result;
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/GuidCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
5 | {
6 | [QcdmCommand(QcdmCommand.GetGuid)]
7 | [QcdmMinResponseLength(17)]
8 | internal class GuidCommandResponse : BaseCommandResponse
9 | {
10 | private GuidCommandResponse()
11 | {
12 | }
13 |
14 | public Guid Guid { get; private set; }
15 |
16 | public static GuidCommandResponse Parse(byte[] data)
17 | {
18 | var result = new GuidCommandResponse();
19 | result.CheckResponse(data);
20 |
21 | var buf = new byte[data.Length - 1];
22 | Array.Copy(data, 1, buf, 0, buf.Length);
23 | result.Guid = new Guid(buf);
24 | return result;
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Int32BaseSubSystemCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.DiagServ
4 | {
5 | internal class Int32BaseSubSystemCommandResponse : BaseSubSystemCommandResponse
6 | {
7 | public int Value { get; private set; }
8 |
9 | public static TChildClass Parse(byte[] data)
10 | {
11 | dynamic result = Activator.CreateInstance(typeof(TChildClass));
12 | if (result != null)
13 | {
14 | result.CheckResponse(data);
15 | result.Value = BitConverter.ToInt32(data, 4);
16 | }
17 | return result;
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/LogCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 | using EfsTools.Qualcomm.QcdmCommands.Base;
5 | using EfsTools.Utils;
6 |
7 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
8 | {
9 | //typedef struct
10 | //{
11 | // uint8 cmd_code;
12 | // uint8 more; /* Indicates how many log entries, not including the one
13 | // returned with this packet, are queued up in the Mobile
14 | // Station. If DIAG_DIAGVER >= 8, this should be set to 0 */
15 | // uint16 len; /* Indicates the length, in bytes, of the following log entry */
16 | // uint8 log[1]; /* Contains the log entry data. */
17 | //}
18 | //diag_log_rsp_type;
19 |
20 | [QcdmCommand(QcdmCommand.Log)]
21 | [QcdmMinResponseLength(32)]
22 | internal class LogCommandResponse : BaseCommandResponse
23 | {
24 | private LogCommandResponse()
25 | {
26 | }
27 |
28 | public LogId LogId { get; private set; }
29 | public string Message { get; private set; }
30 |
31 | public string Source { get; private set; }
32 |
33 | public DateTime Time { get; private set; }
34 |
35 | public static LogCommandResponse Parse(byte[] data)
36 | {
37 | var result = new LogCommandResponse();
38 | result.CheckResponse(data);
39 | var more = data[1];
40 | var length = data[2] + (data[3] << 8);
41 | var logId = data[6] + (data[7] << 8);
42 | result.LogId = (LogId) logId;
43 |
44 | var ts = BitConverter.ToInt64(data, 8);
45 | result.Time = DateTimeUtils.DateTimeFromQualcommTs(ts);
46 |
47 | var str = Encoding.ASCII.GetString(data, 32, data.Length - 32);
48 | ;
49 | var parts = str.Split('\0');
50 | if (parts.Length == 1)
51 | {
52 | result.Message = parts[0].Trim();
53 | }
54 | else if (parts.Length > 1)
55 | {
56 | result.Message = parts[1].Trim();
57 | result.Source = parts[0].Trim();
58 | }
59 |
60 | return result;
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/LogConfigCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
4 | using EfsTools.Qualcomm.QcdmCommands.Base;
5 | using EfsTools.Qualcomm.QcdmCommands.Requests;
6 | using EfsTools.Resourses;
7 | using EfsTools.Utils;
8 |
9 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
10 | {
11 | [QcdmCommand(QcdmCommand.LogConfig)]
12 | [QcdmMinResponseLength(10)]
13 | internal class LogConfigCommandResponse : BaseCommandResponse
14 | {
15 | private LogConfigCommandResponse()
16 | {
17 | }
18 |
19 | public bool IsError { get; private set; }
20 |
21 | private LogConfigOperation Operation { get; set; }
22 | private int Scope { get; set; }
23 |
24 | public LogId[] LogIds { get; private set; }
25 |
26 | public static LogConfigCommandResponse Parse(byte[] data)
27 | {
28 | var result = new LogConfigCommandResponse();
29 | result.CheckResponse(data);
30 | var status = data[8];
31 | result.IsError = status != 0;
32 | result.Operation = (LogConfigOperation) data[4];
33 | switch (result.Operation)
34 | {
35 | case LogConfigOperation.Disable:
36 | case LogConfigOperation.RetrieveIdRanges:
37 | case LogConfigOperation.RetrieveValidMask:
38 | case LogConfigOperation.GetLMask:
39 | ParseData(result, data);
40 | break;
41 | case LogConfigOperation.SetMask:
42 | ParseSetMask(result, data);
43 | break;
44 | }
45 |
46 | return result;
47 | }
48 |
49 | private static void ParseSetMask(LogConfigCommandResponse result, byte[] data)
50 | {
51 | result.Scope = data[12];
52 | var numBits = data[16] + (data[17] << 8);
53 | var maskLength = (numBits + 7) / 8;
54 | if (data.Length < maskLength + 16)
55 | {
56 | //throw new QcdmManagerException(Strings.QcdmInvalidResponseCommand);
57 | return;
58 | }
59 |
60 | var scopeDelta = result.Scope * 0x1000;
61 | var enabledLogs = new List();
62 | for (var i = 0; i < numBits; ++i)
63 | {
64 | if (BitsUtils.GetBitAsBool(data, 20, i))
65 | {
66 | var v = i + scopeDelta;
67 | enabledLogs.Add((LogId) v);
68 | }
69 | }
70 |
71 | result.LogIds = enabledLogs.ToArray();
72 | }
73 |
74 | private static LogConfigCommandResponse ParseData(LogConfigCommandResponse result, byte[] data)
75 | {
76 | var pos = 14;
77 | var count = (data.Length - pos) / 2;
78 | var logIds = new LogId[count];
79 | for (var i = 0; i < count; ++i)
80 | {
81 | logIds[i] = (LogId) BitConverter.ToUInt16(data, pos);
82 | pos += 2;
83 | }
84 |
85 | result.LogIds = logIds;
86 | return result;
87 | }
88 | }
89 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/LogMaskCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
4 | {
5 | [QcdmCommand(QcdmCommand.Logmask)]
6 | [QcdmMinResponseLength(2)]
7 | internal class LogMaskCommandResponse : BaseCommandResponse, IQcdmCommandResponse
8 | {
9 | private LogMaskCommandResponse()
10 | {
11 | }
12 |
13 | public bool IsError { get; private set; }
14 |
15 | public static LogMaskCommandResponse Parse(byte[] data)
16 | {
17 | var result = new LogMaskCommandResponse();
18 | result.CheckResponse(data);
19 | var status = data[1];
20 | result.IsError = status == 0;
21 | return result;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/MaxResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
5 | {
6 | [QcdmCommand(QcdmCommand.Max)]
7 | [QcdmMinResponseLength(2)]
8 | internal class MaxResponse : BaseCommandResponse, IQcdmCommandResponse
9 | {
10 | private MaxResponse()
11 | {
12 | }
13 |
14 | //public bool IsError { get; private set; }
15 |
16 | public static MaxResponse Parse(byte[] data)
17 | {
18 | var result = new MaxResponse();
19 | result.CheckResponse(data);
20 | var str = Encoding.ASCII.GetString(data, 2, data.Length - 2);
21 | return result;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/MsgCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 | using EfsTools.Qualcomm.QcdmCommands.Base;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
6 | {
7 | [QcdmCommand(QcdmCommand.Msg)]
8 | [QcdmMinResponseLength(16)]
9 | internal class MsgCommandResponse : BaseCommandResponse
10 | {
11 | private MsgCommandResponse()
12 | {
13 | }
14 |
15 | public string Log { get; private set; }
16 |
17 | public MessageId MessageId { get; private set; }
18 |
19 | public static MsgCommandResponse Parse(byte[] data)
20 | {
21 | var result = new MsgCommandResponse();
22 | result.CheckResponse(data);
23 | if (data.Length > 16)
24 | {
25 | var messageId = data[14] + (data[15] << 8);
26 | result.MessageId = (MessageId) messageId;
27 |
28 | result.Log = Encoding.ASCII.GetString(data, 16, data.Length - 16);
29 | }
30 |
31 | return result;
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Nv/NvReadCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Nv
5 | {
6 | [QcdmCommand(QcdmCommand.NvRead)]
7 | [QcdmMinResponseLength(133)]
8 | internal class NvReadCommandResponse : BaseCommandResponse, IQcdmCommandResponse
9 | {
10 | private NvReadCommandResponse()
11 | {
12 | }
13 |
14 | public ushort ItemId { get; private set; }
15 | public byte[] Data { get; private set; }
16 |
17 | public static NvReadCommandResponse Parse(byte[] data)
18 | {
19 | var result = new NvReadCommandResponse();
20 | result.CheckResponse(data);
21 |
22 | result.ItemId = BitConverter.ToUInt16(data, 1);
23 | result.Data = new byte[128];
24 | Array.Copy(data, 3, result.Data, 0, 128);
25 | return result;
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/Nv/NvWriteCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses.Nv
5 | {
6 | [QcdmCommand(QcdmCommand.NvWrite)]
7 | [QcdmMinResponseLength(3)]
8 | internal class NvWriteCommandResponse : BaseCommandResponse, IQcdmCommandResponse
9 | {
10 | private NvWriteCommandResponse()
11 | {
12 | }
13 |
14 | public ushort Code { get; private set; }
15 |
16 | public static NvWriteCommandResponse Parse(byte[] data)
17 | {
18 | var result = new NvWriteCommandResponse();
19 | result.CheckResponse(data);
20 | result.Code = BitConverter.ToUInt16(data, 1);
21 | return result;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/PasswordCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
4 | {
5 | [QcdmCommand(QcdmCommand.Password)]
6 | [QcdmMinResponseLength(2)]
7 | internal class PasswordCommandResponse : BaseCommandResponse, IQcdmCommandResponse
8 | {
9 | private PasswordCommandResponse()
10 | {
11 | }
12 |
13 | public bool IsError { get; private set; }
14 |
15 | public static PasswordCommandResponse Parse(byte[] data)
16 | {
17 | var result = new PasswordCommandResponse();
18 | result.CheckResponse(data);
19 | var status = data[1];
20 | result.IsError = status == 0;
21 | return result;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/SpcCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
2 |
3 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
4 | {
5 | [QcdmCommand(QcdmCommand.Spc)]
6 | [QcdmMinResponseLength(2)]
7 | internal class SpcCommandResponse : BaseCommandResponse
8 | {
9 | private SpcCommandResponse()
10 | {
11 | }
12 |
13 | public bool IsError { get; private set; }
14 |
15 | public static SpcCommandResponse Parse(byte[] data)
16 | {
17 | var result = new SpcCommandResponse();
18 | result.CheckResponse(data);
19 | var status = data[1];
20 | result.IsError = status == 0;
21 | return result;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/TimeCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 | using EfsTools.Utils;
4 |
5 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
6 | {
7 | [QcdmCommand(QcdmCommand.Time)]
8 | [QcdmMinResponseLength(9)]
9 | internal class TimeCommandResponse : BaseCommandResponse
10 | {
11 | private TimeCommandResponse()
12 | {
13 | }
14 |
15 | public DateTime Time { get; private set; }
16 |
17 | public static TimeCommandResponse Parse(byte[] data)
18 | {
19 | var result = new TimeCommandResponse();
20 | result.CheckResponse(data);
21 |
22 | var time = BitConverter.ToInt64(data, 1);
23 | result.Time = DateTimeUtils.DateTimeFromQualcommTs(time);
24 | return result;
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmCommands/Responses/VersionCommandResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using EfsTools.Qualcomm.QcdmCommands.Attributes;
3 |
4 | namespace EfsTools.Qualcomm.QcdmCommands.Responses
5 | {
6 | internal class QcdmVersion
7 | {
8 | public QcdmVersion(
9 | string cDate, string cTime, string rDate, string rTime,
10 | string verDir, byte scm, byte caiRev, byte model,
11 | byte firmwareRev, byte slotCycleIndex,
12 | byte hwVersionMajor, byte hwVersionMinor
13 | )
14 | {
15 | CompilationDate = cDate;
16 | CompilationTime = cTime;
17 | ReleaseDate = rDate;
18 | ReleaseTime = rTime;
19 | VersionDirectory = verDir;
20 | StationClassMask = scm;
21 | MobileCaiRevision = caiRev;
22 | MobileModel = model;
23 | MobileFirmwareRevision = firmwareRev;
24 | SlotCycleIndex = slotCycleIndex;
25 | HwVersionMajor = hwVersionMajor;
26 | HwVersionMinor = hwVersionMinor;
27 | }
28 |
29 | public string CompilationDate { get; }
30 | public string CompilationTime { get; }
31 | public string ReleaseDate { get; }
32 | public string ReleaseTime { get; }
33 | public string VersionDirectory { get; }
34 | public byte StationClassMask { get; }
35 | public byte MobileCaiRevision { get; }
36 | public byte MobileModel { get; }
37 | public byte MobileFirmwareRevision { get; }
38 | public byte SlotCycleIndex { get; }
39 | public byte HwVersionMajor { get; }
40 | public byte HwVersionMinor { get; }
41 | }
42 |
43 | [QcdmCommand(QcdmCommand.Version)]
44 | [QcdmMinResponseLength(55)]
45 | internal class VersionCommandResponse : BaseCommandResponse, IQcdmCommandResponse
46 | {
47 | private VersionCommandResponse()
48 | {
49 | }
50 |
51 | public QcdmVersion Version { get; private set; }
52 |
53 | public static VersionCommandResponse Parse(byte[] data)
54 | {
55 | var result = new VersionCommandResponse();
56 | result.CheckResponse(data);
57 | var encoding = Encoding.ASCII;
58 | var cDate = encoding.GetString(data, 1, 11);
59 | var cTime = encoding.GetString(data, 12, 8);
60 | var rDate = encoding.GetString(data, 20, 11);
61 | var rTime = encoding.GetString(data, 32, 8);
62 | var verDir = encoding.GetString(data, 40, 8);
63 | var scm = data[48];
64 | var caiRev = data[49];
65 | var model = data[50];
66 | var firmwareRev = data[51];
67 | var slotCycleIndex = data[52];
68 | var hwVersionMajor = data[53];
69 | var hwVersionMinor = data[54];
70 | result.Version = new QcdmVersion(cDate, cTime, rDate, rTime, verDir, scm, caiRev, model, firmwareRev,
71 | slotCycleIndex, hwVersionMajor, hwVersionMinor);
72 | return result;
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmManagers/QcdmCallManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Requests.CallManager;
3 | using EfsTools.Qualcomm.QcdmCommands.Responses.CallManager;
4 |
5 | namespace EfsTools.Qualcomm.QcdmManagers
6 | {
7 | internal class QcdmCallManager
8 | {
9 | private readonly WeakReference _manager;
10 |
11 | public QcdmCallManager(QcdmManager manager)
12 | {
13 | _manager = new WeakReference(manager);
14 | }
15 |
16 | public ushort CallState
17 | {
18 | get
19 | {
20 | if (_manager.TryGetTarget(out var manager))
21 | {
22 | if (manager.IsOpen)
23 | {
24 | var request = new CallManagerStateInfoCommandRequest();
25 | var response = manager.ExecuteQcdmCommandRequest(request);
26 | if (response != null)
27 | {
28 | return response.CallState;
29 | }
30 | }
31 | }
32 |
33 | return 0;
34 | }
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmManagers/QcdmGsmManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EfsTools.Qualcomm.QcdmCommands.Requests.Gsm;
3 | using EfsTools.Qualcomm.QcdmCommands.Responses.Gsm;
4 |
5 | namespace EfsTools.Qualcomm.QcdmManagers
6 | {
7 | internal class QcdmGsmManager
8 | {
9 | private readonly WeakReference _manager;
10 |
11 | public QcdmGsmManager(QcdmManager manager)
12 | {
13 | _manager = new WeakReference(manager);
14 | }
15 |
16 | //GsmVersion
17 | public GsmVersion Version
18 | {
19 | get
20 | {
21 | if (_manager.TryGetTarget(out var manager))
22 | {
23 | if (manager.IsOpen)
24 | {
25 | var request = new GsmVersionCommandRequest();
26 | var response = manager.ExecuteQcdmCommandRequest(request);
27 | if (response != null)
28 | {
29 | return response.Version;
30 | }
31 | }
32 | }
33 |
34 | return null;
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/EfsTools/Qualcomm/QcdmManagers/QcdmNvManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Items;
4 | using EfsTools.Qualcomm.QcdmCommands.Requests.Nv;
5 | using EfsTools.Qualcomm.QcdmCommands.Responses.Nv;
6 |
7 | namespace EfsTools.Qualcomm.QcdmManagers
8 | {
9 | internal class QcdmNvManager
10 | {
11 | private readonly WeakReference _manager;
12 |
13 | public QcdmNvManager(QcdmManager manager)
14 | {
15 | _manager = new WeakReference(manager);
16 | }
17 |
18 | public byte[] Read(ushort itemId)
19 | {
20 | if (_manager.TryGetTarget(out var manager))
21 | {
22 | if (manager.IsOpen)
23 | {
24 | var request = new NvReadCommandRequest(itemId);
25 | var response = manager.ExecuteQcdmCommandRequest(request);
26 | if (response != null)
27 | {
28 | var size = ItemsFactory.SizeOfNvItem(itemId);
29 | if (size > 0)
30 | {
31 | size = Math.Min(response.Data.LongLength, size);
32 | var data = new byte[size];
33 | Array.Copy(response.Data, 0, data, 0, size);
34 | return data;
35 | }
36 |
37 | return response.Data;
38 | }
39 | }
40 | }
41 |
42 | return new byte[0];
43 | }
44 |
45 | public void Write(ushort itemId, byte[] data)
46 | {
47 | if (_manager.TryGetTarget(out var manager))
48 | {
49 | if (manager.IsOpen)
50 | {
51 | var request = new NvWriteCommandRequest(itemId, data);
52 | var response = manager.ExecuteQcdmCommandRequest(request);
53 | }
54 | }
55 | }
56 |
57 | public string ReadString(ushort itemId)
58 | {
59 | var bytes = Read(itemId);
60 | return Encoding.ASCII.GetString(bytes);
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/Crc16.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Utils
4 | {
5 | internal class Crc16
6 | {
7 | internal static readonly ushort[] _table =
8 | {
9 | 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF, 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C,
10 | 0xDBE5, 0xE97E, 0xF8F7, 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E, 0x9CC9, 0x8D40,
11 | 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876, 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434,
12 | 0x55BD, 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5, 0x3183, 0x200A, 0x1291, 0x0318,
13 | 0x77A7, 0x662E, 0x54B5, 0x453C, 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974, 0x4204,
14 | 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB, 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1,
15 | 0xAB7A, 0xBAF3, 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A, 0xDECD, 0xCF44, 0xFDDF,
16 | 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72, 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
17 | 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1, 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3,
18 | 0x242A, 0x16B1, 0x0738, 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70, 0x8408, 0x9581,
19 | 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7, 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76,
20 | 0x7CFF, 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036, 0x18C1, 0x0948, 0x3BD3, 0x2A5A,
21 | 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E, 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5, 0x2942,
22 | 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD, 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226,
23 | 0xD0BD, 0xC134, 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C, 0xC60C, 0xD785, 0xE51E,
24 | 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3, 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
25 | 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232, 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1,
26 | 0x0D68, 0x3FF3, 0x2E7A, 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1, 0x6B46, 0x7ACF,
27 | 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9, 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9,
28 | 0x8330, 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
29 | };
30 |
31 | public ushort ComputeChecksum(byte[] bytes)
32 | {
33 | var crc = 0xFFFF;
34 | for (var i = 0; i < bytes.Length; ++i)
35 | {
36 | crc = ((crc >> 8) ^ _table[(crc ^ bytes[i]) & 0xFF]) & 0xFFFF;
37 | }
38 |
39 | crc = ~crc;
40 | crc = ((crc >> 8) & 0xFF) | (crc << 8);
41 | return (ushort) crc;
42 | }
43 |
44 | public byte[] ComputeChecksumBytes(byte[] bytes)
45 | {
46 | var crc = ComputeChecksum(bytes);
47 | return BitConverter.GetBytes(crc);
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/DateTimeUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EfsTools.Utils
4 | {
5 | internal static class DateTimeUtils
6 | {
7 | private static readonly DateTime QualcommEpoch = new DateTime(1980, 1, 6, 0, 0, 0, DateTimeKind.Utc);
8 |
9 | public static DateTime DateTimeFromQualcommTs(long ts)
10 | {
11 | var time = ts >> 16;
12 | time *= 5;
13 | time /= 4;
14 | var timeSpan = new TimeSpan(time * 10000);
15 | var dateTime = QualcommEpoch + timeSpan;
16 | return dateTime;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/EfsFileAttributeUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Reflection;
4 | using EfsTools.Attributes;
5 |
6 | namespace EfsTools.Utils
7 | {
8 | public static class EfsFileAttributeUtils
9 | {
10 | public static EfsFileAttribute Get(Type type)
11 | {
12 | return (EfsFileAttribute) type.GetCustomAttributes(typeof(EfsFileAttribute)).FirstOrDefault();
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/EndianConverter.cs:
--------------------------------------------------------------------------------
1 | namespace EfsTools.Utils
2 | {
3 | internal static class EndianConverter
4 | {
5 | public static short Convert(short val)
6 | {
7 | var tmp = (ushort) val;
8 | var v1 = (tmp & 0xFF) << 8;
9 | var v2 = (tmp & 0xFF00) >> 8;
10 | var v = v1 | v2;
11 | return (short) v;
12 | }
13 |
14 | public static int Convert(int val)
15 | {
16 | var tmp = (uint) val;
17 | var v1 = (tmp & 0xFF) << 24;
18 | var v2 = (tmp & 0xFF00) << 8;
19 | var v3 = (tmp & 0xFF0000) >> 8;
20 | var v4 = (tmp & 0xFF000000) >> 24;
21 | var v = v1 | v2 | v3 | v4;
22 | return (int) v;
23 | }
24 |
25 | public static long Convert(long val)
26 | {
27 | var tmp = (ulong) val;
28 | var v1 = (tmp & 0xFF) << 56;
29 | var v2 = (tmp & 0xFF00) << 40;
30 | var v3 = (tmp & 0xFF0000) << 24;
31 | var v4 = (tmp & 0xFF000000) << 8;
32 | var v5 = (tmp & 0xFF00000000) >> 8;
33 | var v6 = (tmp & 0xFF0000000000) >> 24;
34 | var v7 = (tmp & 0xFF000000000000) >> 40;
35 | var v8 = (tmp & 0xFF00000000000000) >> 56;
36 | var v = v1 | v2 | v3 | v4 | v5 | v6 | v7 | v8;
37 | return (long) v;
38 | }
39 |
40 | public static ushort Convert(ushort val)
41 | {
42 | var tmp = val;
43 | var v1 = (tmp & 0xFF) << 8;
44 | var v2 = (tmp & 0xFF00) >> 8;
45 | var v = v1 | v2;
46 | return (ushort) v;
47 | }
48 |
49 | public static uint Convert(uint val)
50 | {
51 | var tmp = val;
52 | var v1 = (tmp & 0xFF) << 24;
53 | var v2 = (tmp & 0xFF00) << 8;
54 | var v3 = (tmp & 0xFF0000) >> 8;
55 | var v4 = (tmp & 0xFF000000) >> 24;
56 | var v = v1 | v2 | v3 | v4;
57 | return v;
58 | }
59 |
60 | public static ulong Convert(ulong val)
61 | {
62 | var tmp = val;
63 | var v1 = (tmp & 0xFF) << 56;
64 | var v2 = (tmp & 0xFF00) << 40;
65 | var v3 = (tmp & 0xFF0000) << 24;
66 | var v4 = (tmp & 0xFF000000) << 8;
67 | var v5 = (tmp & 0xFF00000000) >> 8;
68 | var v6 = (tmp & 0xFF0000000000) >> 24;
69 | var v7 = (tmp & 0xFF000000000000) >> 40;
70 | var v8 = (tmp & 0xFF00000000000000) >> 56;
71 | var v = v1 | v2 | v3 | v4 | v5 | v6 | v7 | v8;
72 | return v;
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/EnumUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 |
4 | namespace EfsTools.Utils
5 | {
6 | internal static class EnumUtils
7 | {
8 | public static byte ParseEnumByte(Type enumType, string val, Logger logger = null)
9 | {
10 | try
11 | {
12 | if (string.IsNullOrEmpty(val))
13 | {
14 | return 0;
15 | }
16 |
17 | if (val.StartsWith("0x") && byte.TryParse(val.Substring(2),
18 | NumberStyles.HexNumber, CultureInfo.InvariantCulture.NumberFormat, out var b))
19 | {
20 | return b;
21 | }
22 | if (val.Length <= 4 && byte.TryParse(val, out var b1))
23 | {
24 | return b1;
25 | }
26 | if (val.Length == 1)
27 | {
28 | return (byte)val[0];
29 | }
30 |
31 | return (byte) Enum.Parse(enumType, val, true);
32 | }
33 | catch (Exception ex)
34 | {
35 | if (logger != null)
36 | {
37 | logger.LogError(ex.Message);
38 | }
39 |
40 | return 0;
41 | }
42 | }
43 |
44 | public static ushort ParseEnumUShort(Type enumType, string val, Logger logger = null)
45 | {
46 | try
47 | {
48 | if (string.IsNullOrEmpty(val))
49 | {
50 | return 0;
51 | }
52 |
53 | if (val.StartsWith("0x") && ushort.TryParse(val.Substring(2),
54 | NumberStyles.HexNumber, CultureInfo.InvariantCulture.NumberFormat, out var b))
55 | {
56 | return b;
57 | }
58 |
59 | if (val.Length < 6 && ushort.TryParse(val, out var b1))
60 | {
61 | return b1;
62 | }
63 |
64 | return (ushort) Enum.Parse(enumType, val, true);
65 | }
66 | catch (Exception ex)
67 | {
68 | if (logger != null)
69 | {
70 | logger.LogError(ex.Message);
71 | }
72 |
73 | return 0;
74 | }
75 | }
76 |
77 | public static int ParseEnumInt(Type enumType, string val, Logger logger = null)
78 | {
79 | try
80 | {
81 | if (string.IsNullOrEmpty(val))
82 | {
83 | return 0;
84 | }
85 |
86 | if (val.StartsWith("0x") && int.TryParse(val.Substring(2),
87 | NumberStyles.HexNumber, CultureInfo.InvariantCulture.NumberFormat, out var b))
88 | {
89 | return b;
90 | }
91 |
92 | if (val.Length < 10 && int.TryParse(val, out var b1))
93 | {
94 | return b1;
95 | }
96 |
97 | return (int) Enum.Parse(enumType, val, true);
98 | }
99 | catch (Exception ex)
100 | {
101 | if (logger != null)
102 | {
103 | logger.LogError(ex.Message);
104 | }
105 |
106 | return 0;
107 | }
108 | }
109 | }
110 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/IgnoreItemAttributeUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Reflection;
4 | using EfsTools.Attributes;
5 |
6 | namespace EfsTools.Utils
7 | {
8 | public static class IgnoreItemAttributeUtils
9 | {
10 | public static IgnoreItemAttribute Get(Type type)
11 | {
12 | return (IgnoreItemAttribute) type.GetCustomAttributes(typeof(IgnoreItemAttribute)).FirstOrDefault();
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/LoggerStream.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text;
4 |
5 | namespace EfsTools.Utils
6 | {
7 | internal sealed class LoggerStream : Stream, IDisposable
8 | {
9 | private readonly Logger _logger;
10 | private readonly MemoryStream _stream;
11 | private bool _closed;
12 |
13 | public LoggerStream(Logger logger)
14 | {
15 | _logger = logger;
16 | _stream = new MemoryStream();
17 | _closed = false;
18 | }
19 |
20 | public override bool CanRead => _stream.CanRead;
21 | public override bool CanSeek => _stream.CanSeek;
22 | public override bool CanWrite => _stream.CanWrite;
23 | public override long Length => _stream.Length;
24 |
25 | public override long Position
26 | {
27 | get => _stream.Position;
28 | set => _stream.Position = value;
29 | }
30 |
31 | public new void Dispose()
32 | {
33 | _stream?.Dispose();
34 | base.Dispose();
35 | }
36 |
37 | public override void Close()
38 | {
39 | WriteLog();
40 | _stream.Close();
41 | }
42 |
43 | public override void Flush()
44 | {
45 | _stream.Flush();
46 | WriteLog();
47 | }
48 |
49 | private void WriteLog()
50 | {
51 | if (!_closed)
52 | {
53 | var buf = _stream.GetBuffer();
54 | var data = new byte[_stream.Position];
55 | Array.Copy(buf, 0, data, 0, _stream.Position);
56 | var str = Encoding.ASCII.GetString(data);
57 | _logger.LogInfo(str);
58 | _closed = true;
59 | }
60 | }
61 |
62 | public override long Seek(long offset, SeekOrigin origin)
63 | {
64 | return _stream.Seek(offset, origin);
65 | }
66 |
67 | public override void SetLength(long value)
68 | {
69 | _stream.SetLength(value);
70 | }
71 |
72 | public override int Read(byte[] buffer, int offset, int count)
73 | {
74 | return _stream.Read(buffer, offset, count);
75 | }
76 |
77 | public override void Write(byte[] buffer, int offset, int count)
78 | {
79 | _stream.Write(buffer, offset, count);
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/NvItemIdAttributeUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Reflection;
4 | using EfsTools.Attributes;
5 |
6 | namespace EfsTools.Utils
7 | {
8 | public static class NvItemIdAttributeUtils
9 | {
10 | public static NvItemIdAttribute Get(Type type)
11 | {
12 | return (NvItemIdAttribute) type.GetCustomAttributes(typeof(NvItemIdAttribute)).FirstOrDefault();
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/QcdmCommandUtils.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using EfsTools.Qualcomm.QcdmCommands;
3 |
4 | namespace EfsTools.Utils
5 | {
6 | internal static class QcdmCommandUtils
7 | {
8 | public static string ToString(QcdmCommand command, byte[] data)
9 | {
10 | var sb = new StringBuilder();
11 | if (data == null)
12 | {
13 | sb.Append(" null");
14 | }
15 | else
16 | {
17 | if (data.Length > 3 && command == QcdmCommand.SubsysCmd)
18 | {
19 | var text = QcdmSubSystemCommandUtils.ToString(data);
20 | sb.Append(text);
21 | }
22 | else
23 | {
24 | sb.Append(command);
25 | }
26 |
27 | sb.Append(ToString(data));
28 | }
29 |
30 | return sb.ToString();
31 | }
32 |
33 | public static string ToString(byte[] data)
34 | {
35 | var sb = new StringBuilder();
36 | if (data == null)
37 | {
38 | sb.Append(" null");
39 | }
40 | else
41 | {
42 | sb.Append(" [");
43 | var addComma = false;
44 | foreach (var b in data)
45 | {
46 | if (addComma)
47 | {
48 | sb.Append(", ");
49 | }
50 |
51 | addComma = true;
52 | sb.AppendFormat("{0:X2}", b);
53 | }
54 |
55 | sb.Append("]");
56 | }
57 |
58 | return sb.ToString();
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/QcdmManagerItemWriteStreamAdapter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using EfsTools.Qualcomm;
4 | using EfsTools.Qualcomm.QcdmCommands.Requests.Efs;
5 |
6 | namespace EfsTools.Utils
7 | {
8 | internal sealed class QcdmManagerItemWriteStreamAdapter : Stream, IDisposable
9 | {
10 | private readonly QcdmManager _manager;
11 | private readonly string _path;
12 | private readonly int _permission;
13 | private readonly MemoryStream _stream;
14 | private bool _closed;
15 |
16 | public QcdmManagerItemWriteStreamAdapter(QcdmManager manager, string path, int permission)
17 | {
18 | _manager = manager;
19 | _stream = new MemoryStream();
20 | _path = path;
21 | _permission = permission;
22 | _closed = false;
23 | }
24 |
25 | public override bool CanRead => _stream.CanRead;
26 | public override bool CanSeek => _stream.CanSeek;
27 | public override bool CanWrite => _stream.CanWrite;
28 | public override long Length => _stream.Length;
29 |
30 | public override long Position
31 | {
32 | get => _stream.Position;
33 | set => _stream.Position = value;
34 | }
35 |
36 | public new void Dispose()
37 | {
38 | try
39 | {
40 | WriteItemFile();
41 | _stream?.Dispose();
42 | base.Dispose();
43 | }
44 | catch
45 | {
46 | }
47 | }
48 |
49 | public override void Close()
50 | {
51 | WriteItemFile();
52 | _stream.Close();
53 | }
54 |
55 | public override void Flush()
56 | {
57 | _stream.Flush();
58 | WriteItemFile();
59 | }
60 |
61 | private void WriteItemFile()
62 | {
63 | if (!_closed)
64 | {
65 | var flags = EfsFileFlag.Writeonly | EfsFileFlag.Truncate | EfsFileFlag.Create | EfsFileFlag.ItemFile;
66 | var buf = _stream.GetBuffer();
67 | var data = new byte[_stream.Position];
68 | Array.Copy(buf, 0, data, 0, _stream.Position);
69 | _manager.Efs.PutItemFile(_path, flags, _permission, data);
70 | _closed = true;
71 | }
72 | }
73 |
74 | public override long Seek(long offset, SeekOrigin origin)
75 | {
76 | return _stream.Seek(offset, origin);
77 | }
78 |
79 | public override void SetLength(long value)
80 | {
81 | _stream.SetLength(value);
82 | }
83 |
84 | public override int Read(byte[] buffer, int offset, int count)
85 | {
86 | return _stream.Read(buffer, offset, count);
87 | }
88 |
89 | public override void Write(byte[] buffer, int offset, int count)
90 | {
91 | _stream.Write(buffer, offset, count);
92 | }
93 | }
94 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/QcdmManagerNvWriteStreamAdapter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using EfsTools.Qualcomm;
4 |
5 | namespace EfsTools.Utils
6 | {
7 | internal sealed class QcdmManagerNvWriteStreamAdapter : Stream, IDisposable
8 | {
9 | private readonly ushort _id;
10 |
11 | private readonly QcdmManager _manager;
12 | private readonly MemoryStream _stream;
13 | private bool _closed;
14 |
15 | public QcdmManagerNvWriteStreamAdapter(QcdmManager manager, ushort id)
16 | {
17 | _manager = manager;
18 | _stream = new MemoryStream();
19 | _id = id;
20 | _closed = false;
21 | }
22 |
23 | public override bool CanRead => _stream.CanRead;
24 | public override bool CanSeek => _stream.CanSeek;
25 | public override bool CanWrite => _stream.CanWrite;
26 | public override long Length => _stream.Length;
27 |
28 | public override long Position
29 | {
30 | get => _stream.Position;
31 | set => _stream.Position = value;
32 | }
33 |
34 | public new void Dispose()
35 | {
36 | try
37 | {
38 | WriteNv();
39 | _stream?.Dispose();
40 | base.Dispose();
41 | }
42 | catch
43 | {
44 | }
45 | }
46 |
47 | public override void Close()
48 | {
49 | WriteNv();
50 | _stream.Close();
51 | }
52 |
53 | public override void Flush()
54 | {
55 | _stream.Flush();
56 | WriteNv();
57 | }
58 |
59 | private void WriteNv()
60 | {
61 | if (!_closed)
62 | {
63 | var buf = _stream.GetBuffer();
64 | var data = new byte[_stream.Position];
65 | Array.Copy(buf, 0, data, 0, _stream.Position);
66 | _manager.Nv.Write(_id, data);
67 | _closed = true;
68 | }
69 | }
70 |
71 | public override long Seek(long offset, SeekOrigin origin)
72 | {
73 | return _stream.Seek(offset, origin);
74 | }
75 |
76 | public override void SetLength(long value)
77 | {
78 | _stream.SetLength(value);
79 | }
80 |
81 | public override int Read(byte[] buffer, int offset, int count)
82 | {
83 | return _stream.Read(buffer, offset, count);
84 | }
85 |
86 | public override void Write(byte[] buffer, int offset, int count)
87 | {
88 | _stream.Write(buffer, offset, count);
89 | }
90 | }
91 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/QcdmManagerStreamAdapter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using EfsTools.Qualcomm;
4 | using EfsTools.Qualcomm.QcdmManagers;
5 |
6 | namespace EfsTools.Utils
7 | {
8 | internal sealed class QcdmManagerStreamAdapter : Stream, IDisposable
9 | {
10 | private readonly QcdmManager _manager;
11 | private readonly QcdmEfsFileStream _stream;
12 |
13 | public QcdmManagerStreamAdapter(QcdmManager manager, QcdmEfsFileStream stream)
14 | {
15 | _manager = manager;
16 | _stream = stream;
17 | }
18 |
19 | public override bool CanRead => _stream.CanRead;
20 | public override bool CanSeek => _stream.CanSeek;
21 | public override bool CanWrite => _stream.CanWrite;
22 | public override long Length => _stream.Length;
23 |
24 | public override long Position
25 | {
26 | get => _stream.Position;
27 | set => _stream.Position = value;
28 | }
29 |
30 | public new void Dispose()
31 | {
32 | _stream?.Dispose();
33 | _manager?.Dispose();
34 | base.Dispose();
35 | }
36 |
37 | public override void Close()
38 | {
39 | _stream.Close();
40 | if (_manager != null)
41 | {
42 | _manager.Close();
43 | }
44 | }
45 |
46 | public override void Flush()
47 | {
48 | _stream.Flush();
49 | }
50 |
51 | public override long Seek(long offset, SeekOrigin origin)
52 | {
53 | return _stream.Seek(offset, origin);
54 | }
55 |
56 | public override void SetLength(long value)
57 | {
58 | _stream.SetLength(value);
59 | }
60 |
61 | public override int Read(byte[] buffer, int offset, int count)
62 | {
63 | return _stream.Read(buffer, offset, count);
64 | }
65 |
66 | public override void Write(byte[] buffer, int offset, int count)
67 | {
68 | _stream.Write(buffer, offset, count);
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/QcdmSubSystemCommandUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using EfsTools.Qualcomm.QcdmCommands;
4 |
5 | namespace EfsTools.Utils
6 | {
7 | internal static class QcdmSubSystemCommandUtils
8 | {
9 | public static string ToString(byte[] data)
10 | {
11 | var sb = new StringBuilder();
12 | sb.Append("SubSystem.");
13 | var subCommand = (QcdmSubSystem) data[1];
14 | var subSubCommand = BitConverter.ToUInt16(data, 2);
15 | sb.Append(subCommand);
16 | sb.Append("(");
17 | switch (subCommand)
18 | {
19 | case QcdmSubSystem.DiagServ:
20 | {
21 | var diagServSubCommand = (QcdmDiagServCommand) subSubCommand;
22 | sb.AppendFormat("{0}", diagServSubCommand);
23 | }
24 | break;
25 | case QcdmSubSystem.Efs:
26 | {
27 | var efsSubCommand = (QcdmEfsCommand) subSubCommand;
28 | sb.AppendFormat("{0}", efsSubCommand);
29 | }
30 | break;
31 | default:
32 | sb.AppendFormat("{0}", subSubCommand);
33 | break;
34 | }
35 |
36 | sb.Append(")");
37 | return sb.ToString();
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/QualcommSerialPortUtils.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Runtime.InteropServices;
3 | using EfsTools.Qualcomm;
4 | using Microsoft.Win32;
5 |
6 | namespace EfsTools.Utils
7 | {
8 | internal static class QualcommSerialPortUtils
9 | {
10 | public static bool IsQualcommPort(string port, int baudrate, bool hdlcSendControlChar, bool ignoreUnsupportedCommands, Logger logger)
11 | {
12 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
13 | {
14 | return IsWindowsQualcommPort(port);
15 | }
16 |
17 | return CheckQualcommPort(port, baudrate, hdlcSendControlChar, ignoreUnsupportedCommands, logger);
18 | }
19 |
20 | private static bool IsWindowsQualcommPort(string port)
21 | {
22 | var qualcommPorts = InitializeQualcommPorts();
23 | return qualcommPorts.Contains(port);
24 | }
25 |
26 | private static bool CheckQualcommPort(string port, int baudrate, bool _hdlcSendControlChar, bool ignoreUnsupportedCommands, Logger logger)
27 | {
28 | try
29 | {
30 | using (var manager = new QcdmManager(port, baudrate, 500, _hdlcSendControlChar, ignoreUnsupportedCommands, logger))
31 | {
32 | manager.Open();
33 | var version = manager.Version;
34 | manager.Close();
35 | return true;
36 | }
37 | }
38 | catch
39 | {
40 | }
41 | return false;
42 | }
43 |
44 | private static HashSet InitializeQualcommPorts()
45 | {
46 | try
47 | {
48 | var qualcommPorts = new HashSet();
49 | using (var portsKey =
50 | Registry.LocalMachine.OpenSubKey(
51 | "SYSTEM\\CurrentControlSet\\Control\\Class\\{4d36e978-e325-11ce-bfc1-08002be10318}", false))
52 | {
53 | if (portsKey != null)
54 | {
55 | foreach (var keyName in portsKey.GetSubKeyNames())
56 | {
57 | if (keyName != "Properties")
58 | {
59 | ProcessRegistryKey(portsKey, keyName, qualcommPorts);
60 | }
61 | }
62 | }
63 | }
64 | return qualcommPorts;
65 | }
66 | catch
67 | {
68 | return new HashSet();
69 | }
70 | }
71 |
72 | private static void ProcessRegistryKey(RegistryKey portsKey, string keyName, HashSet qualcommPorts)
73 | {
74 | try
75 | {
76 | using (var portKey = portsKey.OpenSubKey(keyName, false))
77 | {
78 | if (portKey != null)
79 | {
80 | var assignedPortForQcDevice =
81 | portKey.GetValue("AssignedPortForQCDevice", string.Empty).ToString();
82 | if (!string.IsNullOrEmpty(assignedPortForQcDevice))
83 | {
84 | qualcommPorts.Add(assignedPortForQcDevice);
85 | }
86 | }
87 |
88 | // "Qualcomm HS-USB"
89 | }
90 | }
91 | catch
92 | {
93 | // ignored
94 | }
95 | }
96 | }
97 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/StreamUtils.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace EfsTools.Utils
4 | {
5 | internal static class StreamUtils
6 | {
7 | public static void CopyWithSeek(Stream source, Stream dest)
8 | {
9 | var buf = new byte[1024];
10 | while (source.Position < source.Length)
11 | {
12 | var read = source.Read(buf, 0, buf.Length);
13 | if (read == 0)
14 | {
15 | break;
16 | }
17 |
18 | dest.Write(buf, 0, read);
19 | }
20 | }
21 |
22 | public static void Copy(Stream source, Stream dest)
23 | {
24 | var buf = new byte[4 * 1024];
25 | var read = source.Read(buf, 0, buf.Length);
26 | while (read > 0)
27 | {
28 | dest.Write(buf, 0, read);
29 | read = source.Read(buf, 0, buf.Length);
30 | }
31 | }
32 |
33 |
34 | public static Stream CreateLoggerStream(Logger logger)
35 | {
36 | return new LoggerStream(logger);
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/EfsTools/Utils/SubscriptionAttributeUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using EfsTools.Attributes;
4 |
5 | namespace EfsTools.Utils
6 | {
7 | internal static class SubscriptionAttributeUtils
8 | {
9 | public static SubscriptionAttribute Get(Type type)
10 | {
11 | return (SubscriptionAttribute) type.GetCustomAttributes(typeof(SubscriptionAttribute), true)
12 | .FirstOrDefault();
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/License.RU.md:
--------------------------------------------------------------------------------
1 | Лицензия MIT (MIT)
2 |
3 | Copyright (c) 2018-2020 JohnBel
4 |
5 | Данная лицензия разрешает, безвозмездно, лицам, получившим копию данного программного обеспечения и сопутствующей документации (в дальнейшем именуемыми "Программное Обеспечение"), использовать Программное Обеспечение без ограничений, включая неограниченное право на использование, копирование, изменение, объединение, публикацию, распространение, сублицензирование и/или продажу копий Программного Обеспечения, также как и лицам, которым предоставляется данное Программное Обеспечение, при соблюдении следующих условий:
6 |
7 | Вышеупомянутый копирайт и данные условия должны быть включены во все копии или значимые части данного Программного Обеспечения.
8 |
9 | ДАННОЕ ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ ПРЕДОСТАВЛЯЕТСЯ «КАК ЕСТЬ», БЕЗ ЛЮБОГО ВИДА ГАРАНТИЙ, ЯВНО ВЫРАЖЕННЫХ ИЛИ ПОДРАЗУМЕВАЕМЫХ, ВКЛЮЧАЯ, НО НЕ ОГРАНИЧИВАЯСЬ ГАРАНТИЯМИ ТОВАРНОЙ ПРИГОДНОСТИ, СООТВЕТСТВИЯ ПО ЕГО КОНКРЕТНОМУ НАЗНАЧЕНИЮ И НЕНАРУШЕНИЯ ПРАВ. НИ В КАКОМ СЛУЧАЕ АВТОРЫ ИЛИ ПРАВООБЛАДАТЕЛИ НЕ НЕСУТ ОТВЕТСТВЕННОСТИ ПО ИСКАМ О ВОЗМЕЩЕНИИ УЩЕРБА, УБЫТКОВ ИЛИ ДРУГИХ ТРЕБОВАНИЙ ПО ДЕЙСТВУЮЩИМ КОНТРАКТАМ, ДЕЛИКТАМ ИЛИ ИНОМУ, ВОЗНИКШИМ ИЗ, ИМЕЮЩИМ ПРИЧИНОЙ ИЛИ СВЯЗАННЫМ С ПРОГРАММНЫМ ОБЕСПЕЧЕНИЕМ ИЛИ ИСПОЛЬЗОВАНИЕМ ПРОГРАММНОГО ОБЕСПЕЧЕНИЯ ИЛИ ИНЫМИ ДЕЙСТВИЯМИ С ПРОГРАММНЫМ ОБЕСПЕЧЕНИЕМ.
--------------------------------------------------------------------------------
/License.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2018-2020 JohnBel
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------