4 Commits
8 changed files with 74 additions and 26 deletions

No files matched your search

Vendored
+5 -5
View File
@@ -127,12 +127,12 @@ done
: ${INSTALL_PROGRAM_STRIP:=${INSTALL} -m 755 -s}
: ${INSTALL_MAN:=${INSTALL} -m 444}
: ${INSTALL_LIB:=${INSTALL} -m 755 -c}
PKGNAME='r2flutter' ; VERSION='0.3.2' ; VERSION_MAJOR=0; VERSION_MINOR=3; VERSION_PATCH=2; VERSION_NUMBER=00302; CONTACT_MAIL="[email protected]" ; CONTACT_NAME="pancake" ; CONTACT="pancake <[email protected]>" ;
PKGNAME='r2flutter' ; VERSION='0.3.4' ; VERSION_MAJOR=0; VERSION_MINOR=3; VERSION_PATCH=4; VERSION_NUMBER=00304; CONTACT_MAIL="[email protected]" ; CONTACT_NAME="pancake" ; CONTACT="pancake <[email protected]>" ;
}
show_usage() {
cat <<EOF2
'configure' configures r2flutter-0.3.2 to adapt to many kinds of systems.
'configure' configures r2flutter-0.3.4 to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
@@ -214,10 +214,10 @@ ocho() {
show_version() {
if [ "$QUIET" = 1 ]; then
echo "0.3.2"
echo "0.3.4"
exit 0
fi
echo "r2flutter-0.3.2 configuration script done with acr v2.2.8.
echo "r2flutter-0.3.4 configuration script done with acr v2.2.8.
The 'Free Software Foundation' message is only for autodetection.
Originally written by pancake <nopcode.org>."
exit 0
@@ -246,7 +246,7 @@ case $flag in
show_version ; ;;
-r|--r|--report)
echo "PKGNAME: r2flutter"
echo "VERSION: 0.3.2"
echo "VERSION: 0.3.4"
echo "AUTHOR: pancake"
echo "EMAIL: [email protected]"
echo "LANGS: c"
+1 -1
View File
@@ -1,5 +1,5 @@
PKGNAME r2flutter
VERSION 0.3.2
VERSION 0.3.4
CONTACT pancake ; [email protected]
LANG_C!
+2 -2
View File
@@ -1,9 +1,9 @@
#ifndef R2FLUTTER_VERSION_H
#define R2FLUTTER_VERSION_H
#define R2FLUTTER_VERSION "0.3.2"
#define R2FLUTTER_VERSION "0.3.4"
#define R2FLUTTER_VERSION_MAJOR 0
#define R2FLUTTER_VERSION_MINOR 3
#define R2FLUTTER_VERSION_PATCH 2
#define R2FLUTTER_VERSION_PATCH 4
#endif
+27 -4
View File
@@ -1,18 +1,41 @@
project(
'r2flutter',
'c',
version : '0.3.2',
meson_version : '>=0.55.0',
version : '0.3.4',
meson_version : '>=0.56.0',
default_options : ['warning_level=2', 'werror=false']
)
cc = meson.get_compiler('c')
r2 = find_program('r2', required: true)
r2_cflags_res = run_command(r2, '-H', 'R2_CFLAGS', check: true)
r2_ldflags_res = run_command(r2, '-H', 'R2_LDFLAGS', check: true)
r2_libs_res = run_command(r2, '-H', 'R2_LIBS', check: true)
r2_compile_args = r2_cflags_res.stdout().strip().split()
r2_link_args = r2_ldflags_res.stdout().strip().split() + r2_libs_res.stdout().strip().split()
# r2 -H always reports gcc style flags, msvc needs its own spelling for them
if cc.get_argument_syntax() == 'msvc'
msvc_link_args = []
foreach flag : r2_link_args
if flag.startswith('-L')
msvc_link_args += '/LIBPATH:' + flag.substring(2)
elif flag.startswith('-l')
msvc_link_args += flag.substring(2) + '.lib'
else
msvc_link_args += flag
endif
endforeach
r2_link_args = msvc_link_args
# posix names like strdup are available, just noisy without this
r2_compile_args += ['-D_CRT_SECURE_NO_WARNINGS', '-D_CRT_NONSTDC_NO_DEPRECATE']
endif
r_core_dep = declare_dependency(
compile_args: r2_cflags_res.stdout().strip().split(),
link_args: r2_ldflags_res.stdout().strip().split() + r2_libs_res.stdout().strip().split(),
compile_args: r2_compile_args,
link_args: r2_link_args,
)
r2flutter_inc = include_directories('include')
+13 -2
View File
@@ -179,13 +179,24 @@ static FILE *open_payload_temp(char **out_path) {
FILE *out = try_open_temp_path (r_file_temp ("r2flutter-dart-app-snap"), out_path);
if (!out) {
char *name = r_str_newf ("r2flutter-dart-app-snap.%" PFMT64x, (ut64)r_time_now ());
char *path = name? r_file_new (P_tmpdir, name, NULL): NULL;
char *tmpdir = r_file_tmpdir ();
char *path = (name && tmpdir)? r_file_new (tmpdir, name, NULL): NULL;
free (tmpdir);
free (name);
out = try_open_temp_path (path, out_path);
}
return out;
}
// msvc has no fseeko, but it ships an equivalent 64bit seek
static bool payload_seek(FILE *f, ut64 off) {
#if defined(_MSC_VER)
return _fseeki64 (f, (__int64)off, SEEK_SET) == 0;
#else
return fseeko (f, (off_t)off, SEEK_SET) == 0;
#endif
}
char *dart_app_extract_payload(const char *path, const DartAppEmbeddedPayload *payload) {
if (R_STR_ISEMPTY (path) || !payload || !payload->payload_size) {
return NULL;
@@ -202,7 +213,7 @@ char *dart_app_extract_payload(const char *path, const DartAppEmbeddedPayload *p
fclose (in);
return NULL;
}
bool ok = fseeko (in, (off_t)payload->payload_offset, SEEK_SET) == 0;
bool ok = payload_seek (in, payload->payload_offset);
ut64 remaining = payload->payload_size;
ut8 buf[65536];
while (ok && remaining > 0) {
+24 -10
View File
@@ -388,6 +388,7 @@ typedef struct {
// handful of clusters. Their readers are gated on this flag; everything
// else is shared.
bool legacy_format;
bool shift1_format;
bool closure_variable;
// every CID this layout defines, indexed by kind; -1 when the kind is absent
int by_kind[DART_CID_KIND_COUNT];
@@ -462,6 +463,7 @@ static ModernCidCache modern_cid_cache_init(const DartVerLayout *layout) {
.typed_data_internal_limit = dart_cid_typed_data_limit (layout),
.typed_data_stride = dart_cid_typed_data_stride (layout),
.legacy_format = modern_layout_is_legacy (layout),
.shift1_format = layout && layout->tag_style == DART_TAG_STYLE_CID_SHIFT1,
.closure_variable = layout && layout->closure_variable,
};
for (int kind = 0; kind < DART_CID_KIND_COUNT; kind++) {
@@ -980,8 +982,11 @@ static ModernFillSpec modern_get_fill_spec(const ModernCidCache *cids, int cid)
if (cids->closure_variable && modern_cid_eq (cid, cids->closure)) {
return modern_fill_spec_kind (MODERN_FILL_CLOSURE);
}
if (modern_cid_eq (cid, cids->patch_class)) {
// FullAOT PatchClass layout differs across snapshot families.
return modern_fill_spec_refs ((cids->legacy_format || cids->shift1_format)? 3: 2);
}
static const ModernFillSpecRule rules[] = {
{ DART_CID_PATCH_CLASS, MODERN_FILL_REFS, 2, -1, -1, 0, { 0 } },
{ DART_CID_TYPE_PARAMETERS, MODERN_FILL_REFS, 4, -1, -1, 0, { 0 } },
{ DART_CID_CLOSURE_DATA, MODERN_FILL_REFS, 2, -1, -1, 1, { MODERN_SCALAR_UNSIGNED } },
{ DART_CID_FFI_TRAMPOLINE_DATA, MODERN_FILL_REFS, 4, -1, -1, 2, { MODERN_SCALAR_TAGGED32, MODERN_SCALAR_UINT8 } },
@@ -1046,8 +1051,6 @@ static ModernFillSpec modern_get_fill_spec(const ModernCidCache *cids, int cid)
// than the newer format the table above encodes. Verified against the Dart
// 2.18 AOT (kFullAOT, PRODUCT) serializer in runtime/vm/app_snapshot.cc.
static const ModernFillSpecRule legacy_rules[] = {
// PatchClass::to_snapshot stops at script_ in AOT: 3 refs, no scalars.
{ DART_CID_PATCH_CLASS, MODERN_FILL_REFS, 3, -1, -1, 0, { 0 } },
// FfiTrampolineData: ReadFromTo (4) + ReadUnsigned (callback_id).
{ DART_CID_FFI_TRAMPOLINE_DATA, MODERN_FILL_REFS, 4, -1, -1, 1, { MODERN_SCALAR_UNSIGNED } },
// Type: ReadFromTo (3) + ReadUnsigned (type_class_id) + Read<uint8_t>.
@@ -1987,14 +1990,19 @@ static bool modern_resolver_read_library_fill(ModernWalk *w, ClusterStream *s, c
static bool modern_resolver_read_patch_class_fill(ModernWalk *w, ClusterStream *s, const ModernClusterMeta *meta) {
ModernRefResolver *resolver = (ModernRefResolver *)w->user;
const ModernFillSpec spec = modern_get_fill_spec (&w->cids, meta->cid);
ut64 ref = meta->start_ref;
for (ut64 j = 0; j < meta->count; j++, ref++) {
ut64 wrapped_ref = 0;
ut64 script_ref = 0;
if (!cs_read_ref_id (s, &wrapped_ref) || !cs_read_ref_id (s, &script_ref)) {
return false;
for (int k = 0; k < spec.num_refs; k++) {
ut64 rv = 0;
if (!cs_read_ref_id (s, &rv)) {
return false;
}
if (!k) {
wrapped_ref = rv;
}
}
(void)script_ref;
if (ref < resolver->refs_count) {
resolver->patch_wrapped_ref[ref] = wrapped_ref;
}
@@ -4982,12 +4990,18 @@ static bool modern_name_scan_read_library(ModernWalk *w, ClusterStream *s, const
static bool modern_name_scan_read_patch_class(ModernWalk *w, ClusterStream *s, const ModernClusterMeta *m) {
ModernNameScanWalk *u = (ModernNameScanWalk *)w->user;
const ModernFillSpec spec = modern_get_fill_spec (&w->cids, m->cid);
ut64 ref = m->start_ref;
for (ut64 j = 0; j < m->count; j++, ref++) {
ut64 wrapped_ref = 0;
ut64 script_ref = 0;
if (!cs_read_ref_id (s, &wrapped_ref) || !cs_read_ref_id (s, &script_ref)) {
return false;
for (int k = 0; k < spec.num_refs; k++) {
ut64 rv = 0;
if (!cs_read_ref_id (s, &rv)) {
return false;
}
if (!k) {
wrapped_ref = rv;
}
}
if (ref < u->refs_count) {
u->patch_wrapped_ref[ref] = wrapped_ref;
+1 -1
View File
@@ -377,7 +377,7 @@ void collect_data_names_with_r2(DartCtx *ctx, ut64 data_image_base, ut64 data_im
continue;
}
char *line, *saveptr = NULL;
for (line = strtok_r (out, "\n", &saveptr); line; line = strtok_r (NULL, "\n", &saveptr)) {
for (line = r_str_tok_r (out, "\n", &saveptr); line; line = r_str_tok_r (NULL, "\n", &saveptr)) {
if (!r_str_startswith (line, "0x")) {
continue;
}
+1 -1
View File
@@ -359,7 +359,7 @@ static void sbom_scan_pubspec_lock(RList *components, const char *path) {
bool in_packages = false;
char *current = NULL;
char *saveptr = NULL;
for (char *line = strtok_r (yaml, "\n", &saveptr); line; line = strtok_r (NULL, "\n", &saveptr)) {
for (char *line = r_str_tok_r (yaml, "\n", &saveptr); line; line = r_str_tok_r (NULL, "\n", &saveptr)) {
if (!strcmp (line, "packages:")) {
in_packages = true;
continue;