feat: unp4kTools extract_memory

This commit is contained in:
xkeyC 2024-04-27 16:23:57 +08:00
parent 9bdccc3bbf
commit a7e1d8d0b7
9 changed files with 41 additions and 32 deletions

Binary file not shown.

View File

@ -223,4 +223,23 @@ class Unp4kCModel extends _$Unp4kCModel {
rsPid: _rsPid!, data: "$mode<:,:>$filePath<:,:>$outputPath\n");
}
}
static Future<Uint8List> unp4kTools(
String applicationBinaryModuleDir, List<String> args) async {
await BinaryModuleConf.extractModule(
["unp4kc"], applicationBinaryModuleDir);
final execDir = "$applicationBinaryModuleDir\\unp4kc";
final exec = "$execDir\\unp4kc.exe";
final r = await Process.run(exec, args);
if (r.exitCode != 0) {
throw Exception(
"error: ${r.exitCode} , info= ${r.stdout} , err= ${r.stderr}");
}
final eventJson = await compute(json.decode, r.stdout.toString());
if (eventJson["action"] == "data: Uint8List") {
final data = eventJson["data"];
return Uint8List.fromList((data as List).cast<int>());
}
throw Exception("error: data error");
}
}

View File

@ -6,7 +6,7 @@ part of 'unp4kc.dart';
// RiverpodGenerator
// **************************************************************************
String _$unp4kCModelHash() => r'0f1bff187bbc4e043405f60e95c08af6e1159b57';
String _$unp4kCModelHash() => r'69117c5857797683e2d080da9238bfecc5948898';
/// See also [Unp4kCModel].
@ProviderFor(Unp4kCModel)

View File

@ -7,7 +7,7 @@ part of 'home_game_login_dialog_ui_model.dart';
// **************************************************************************
String _$homeGameLoginUIModelHash() =>
r'862fac9e29e55937e1246542feac75cf55062182';
r'e8afccb7bba7c79e766e30a27f64128918a63dd7';
/// See also [HomeGameLoginUIModel].
@ProviderFor(HomeGameLoginUIModel)

View File

@ -6,7 +6,7 @@ part of 'home_ui_model.dart';
// RiverpodGenerator
// **************************************************************************
String _$homeUIModelHash() => r'415891e3528a681a9c11eed5bb78070a2a08da86';
String _$homeUIModelHash() => r'8308b6e327b7eeda64c39bcd73e9f2d9e6470437';
/// See also [HomeUIModel].
@ProviderFor(HomeUIModel)

View File

@ -18,6 +18,7 @@ import 'package:starcitizen_doctor/common/utils/log.dart';
import 'package:starcitizen_doctor/common/utils/provider.dart';
import 'package:starcitizen_doctor/data/sc_localization_data.dart';
import 'package:starcitizen_doctor/generated/no_l10n_strings.dart';
import 'package:starcitizen_doctor/provider/unp4kc.dart';
import 'package:starcitizen_doctor/ui/home/home_ui_model.dart';
import 'package:starcitizen_doctor/widgets/widgets.dart';
import 'package:url_launcher/url_launcher_string.dart';
@ -88,6 +89,17 @@ class LocalizationUIModel extends _$LocalizationUIModel {
await _loadData();
}
readEnglishInI() async {
final data = await Unp4kCModel.unp4kTools(
appGlobalState.applicationBinaryModuleDir!, [
"extract_memory",
"$_scInstallPath\\Data.p4k",
"Data\\Localization\\english\\global.ini"
]);
final iniData = String.fromCharCodes(data);
dPrint("read english ini => ${iniData.length}");
}
final Map<String, Map<String, ScLocalizationData>>
_allVersionLocalizationData = {};

View File

@ -7,7 +7,7 @@ part of 'localization_ui_model.dart';
// **************************************************************************
String _$localizationUIModelHash() =>
r'da9d0a3ae28825fd9331dd2b6db3d094cf3c0eb9';
r'a4e33b337db587ad3e766450d9bd8ac4aa7b4c49';
/// See also [LocalizationUIModel].
@ProviderFor(LocalizationUIModel)

View File

@ -16,7 +16,6 @@ final _privateConstructorUsedError = UnsupportedError(
/// @nodoc
mixin _$SettingsUIState {
dynamic get isDeviceSupportWinHello => throw _privateConstructorUsedError;
bool get isEnableToolSiteMirrors => throw _privateConstructorUsedError;
String get inputGameLaunchECore => throw _privateConstructorUsedError;
String? get customLauncherPath => throw _privateConstructorUsedError;
@ -35,8 +34,7 @@ abstract class $SettingsUIStateCopyWith<$Res> {
_$SettingsUIStateCopyWithImpl<$Res, SettingsUIState>;
@useResult
$Res call(
{dynamic isDeviceSupportWinHello,
bool isEnableToolSiteMirrors,
{bool isEnableToolSiteMirrors,
String inputGameLaunchECore,
String? customLauncherPath,
String? customGamePath,
@ -56,7 +54,6 @@ class _$SettingsUIStateCopyWithImpl<$Res, $Val extends SettingsUIState>
@pragma('vm:prefer-inline')
@override
$Res call({
Object? isDeviceSupportWinHello = freezed,
Object? isEnableToolSiteMirrors = null,
Object? inputGameLaunchECore = null,
Object? customLauncherPath = freezed,
@ -64,10 +61,6 @@ class _$SettingsUIStateCopyWithImpl<$Res, $Val extends SettingsUIState>
Object? locationCacheSize = null,
}) {
return _then(_value.copyWith(
isDeviceSupportWinHello: freezed == isDeviceSupportWinHello
? _value.isDeviceSupportWinHello
: isDeviceSupportWinHello // ignore: cast_nullable_to_non_nullable
as dynamic,
isEnableToolSiteMirrors: null == isEnableToolSiteMirrors
? _value.isEnableToolSiteMirrors
: isEnableToolSiteMirrors // ignore: cast_nullable_to_non_nullable
@ -101,8 +94,7 @@ abstract class _$$SettingsUIStateImplCopyWith<$Res>
@override
@useResult
$Res call(
{dynamic isDeviceSupportWinHello,
bool isEnableToolSiteMirrors,
{bool isEnableToolSiteMirrors,
String inputGameLaunchECore,
String? customLauncherPath,
String? customGamePath,
@ -120,7 +112,6 @@ class __$$SettingsUIStateImplCopyWithImpl<$Res>
@pragma('vm:prefer-inline')
@override
$Res call({
Object? isDeviceSupportWinHello = freezed,
Object? isEnableToolSiteMirrors = null,
Object? inputGameLaunchECore = null,
Object? customLauncherPath = freezed,
@ -128,9 +119,6 @@ class __$$SettingsUIStateImplCopyWithImpl<$Res>
Object? locationCacheSize = null,
}) {
return _then(_$SettingsUIStateImpl(
isDeviceSupportWinHello: freezed == isDeviceSupportWinHello
? _value.isDeviceSupportWinHello!
: isDeviceSupportWinHello,
isEnableToolSiteMirrors: null == isEnableToolSiteMirrors
? _value.isEnableToolSiteMirrors
: isEnableToolSiteMirrors // ignore: cast_nullable_to_non_nullable
@ -159,16 +147,12 @@ class __$$SettingsUIStateImplCopyWithImpl<$Res>
class _$SettingsUIStateImpl implements _SettingsUIState {
_$SettingsUIStateImpl(
{this.isDeviceSupportWinHello = false,
this.isEnableToolSiteMirrors = false,
{this.isEnableToolSiteMirrors = false,
this.inputGameLaunchECore = "0",
this.customLauncherPath,
this.customGamePath,
this.locationCacheSize = 0});
@override
@JsonKey()
final dynamic isDeviceSupportWinHello;
@override
@JsonKey()
final bool isEnableToolSiteMirrors;
@ -185,7 +169,7 @@ class _$SettingsUIStateImpl implements _SettingsUIState {
@override
String toString() {
return 'SettingsUIState(isDeviceSupportWinHello: $isDeviceSupportWinHello, isEnableToolSiteMirrors: $isEnableToolSiteMirrors, inputGameLaunchECore: $inputGameLaunchECore, customLauncherPath: $customLauncherPath, customGamePath: $customGamePath, locationCacheSize: $locationCacheSize)';
return 'SettingsUIState(isEnableToolSiteMirrors: $isEnableToolSiteMirrors, inputGameLaunchECore: $inputGameLaunchECore, customLauncherPath: $customLauncherPath, customGamePath: $customGamePath, locationCacheSize: $locationCacheSize)';
}
@override
@ -193,8 +177,6 @@ class _$SettingsUIStateImpl implements _SettingsUIState {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SettingsUIStateImpl &&
const DeepCollectionEquality().equals(
other.isDeviceSupportWinHello, isDeviceSupportWinHello) &&
(identical(
other.isEnableToolSiteMirrors, isEnableToolSiteMirrors) ||
other.isEnableToolSiteMirrors == isEnableToolSiteMirrors) &&
@ -211,7 +193,6 @@ class _$SettingsUIStateImpl implements _SettingsUIState {
@override
int get hashCode => Object.hash(
runtimeType,
const DeepCollectionEquality().hash(isDeviceSupportWinHello),
isEnableToolSiteMirrors,
inputGameLaunchECore,
customLauncherPath,
@ -228,15 +209,12 @@ class _$SettingsUIStateImpl implements _SettingsUIState {
abstract class _SettingsUIState implements SettingsUIState {
factory _SettingsUIState(
{final dynamic isDeviceSupportWinHello,
final bool isEnableToolSiteMirrors,
{final bool isEnableToolSiteMirrors,
final String inputGameLaunchECore,
final String? customLauncherPath,
final String? customGamePath,
final int locationCacheSize}) = _$SettingsUIStateImpl;
@override
dynamic get isDeviceSupportWinHello;
@override
bool get isEnableToolSiteMirrors;
@override

View File

@ -6,7 +6,7 @@ part of 'settings_ui_model.dart';
// RiverpodGenerator
// **************************************************************************
String _$settingsUIModelHash() => r'897176bc24ec5397cce0dd1ceea58338ac7841e0';
String _$settingsUIModelHash() => r'2be0fe230d23f84796e0a3a39dd3248c2aa90f23';
/// See also [SettingsUIModel].
@ProviderFor(SettingsUIModel)