frida-fs 5.2.0 → 5.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +73 -27
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16,7 +16,8 @@ import process from "process";
16
16
  import stream from "stream";
17
17
  const getWindowsApi = memoize(_getWindowsApi);
18
18
  const getPosixApi = memoize(_getPosixApi);
19
- const { platform, pointerSize } = Process;
19
+ const platform = Process.platform;
20
+ const pointerSize = Process.pointerSize;
20
21
  const isWindows = platform === "windows";
21
22
  const S_IFMT = 0xf000;
22
23
  const S_IFREG = 0x8000;
@@ -96,7 +97,7 @@ const constants = {
96
97
  ...universalConstants,
97
98
  ...platformConstants[platform]
98
99
  };
99
- const INVALID_HANDLE_VALUE = ptr(-1);
100
+ const INVALID_HANDLE_VALUE = -1;
100
101
  const GENERIC_READ = 0x80000000;
101
102
  const GENERIC_WRITE = 0x40000000;
102
103
  const FILE_SHARE_READ = 0x1;
@@ -536,6 +537,24 @@ const statFields = new Set([
536
537
  "ctime",
537
538
  "birthtime",
538
539
  ]);
540
+ const statSpecGenericLinux32 = {
541
+ size: 88,
542
+ fields: {
543
+ "dev": [0, "U64"],
544
+ "mode": [16, "U32"],
545
+ "nlink": [20, "U32"],
546
+ "ino": [12, "U32"],
547
+ "uid": [24, "U32"],
548
+ "gid": [28, "U32"],
549
+ "rdev": [32, "U64"],
550
+ "atime": [56, readTimespec32],
551
+ "mtime": [64, readTimespec32],
552
+ "ctime": [72, readTimespec32],
553
+ "size": [44, "S32"],
554
+ "blocks": [52, "S32"],
555
+ "blksize": [48, "S32"],
556
+ }
557
+ };
539
558
  const statSpecs = {
540
559
  "windows": {
541
560
  size: 36,
@@ -594,25 +613,45 @@ const statSpecs = {
594
613
  "blksize": [112, "S32"],
595
614
  }
596
615
  },
597
- "linux-32": {
598
- size: 88,
616
+ "linux-ia32": statSpecGenericLinux32,
617
+ "linux-ia32-stat64": {
618
+ size: 96,
599
619
  fields: {
600
620
  "dev": [0, "U64"],
601
621
  "mode": [16, "U32"],
602
622
  "nlink": [20, "U32"],
603
- "ino": [12, "U32"],
623
+ "ino": [88, "U64"],
604
624
  "uid": [24, "U32"],
605
625
  "gid": [28, "U32"],
606
626
  "rdev": [32, "U64"],
607
- "atime": [56, readTimespec32],
608
- "mtime": [64, readTimespec32],
609
- "ctime": [72, readTimespec32],
610
- "size": [44, "S32"],
611
- "blocks": [52, "S32"],
612
- "blksize": [48, "S32"],
613
- }
627
+ "atime": [64, readTimespec32],
628
+ "mtime": [72, readTimespec32],
629
+ "ctime": [80, readTimespec32],
630
+ "size": [44, "S64"],
631
+ "blocks": [56, "S64"],
632
+ "blksize": [52, "S32"],
633
+ },
614
634
  },
615
- "linux-32-stat64": {
635
+ "linux-x64": {
636
+ size: 144,
637
+ fields: {
638
+ "dev": [0, "U64"],
639
+ "mode": [24, "U32"],
640
+ "nlink": [16, "U64"],
641
+ "ino": [8, "U64"],
642
+ "uid": [28, "U32"],
643
+ "gid": [32, "U32"],
644
+ "rdev": [40, "U64"],
645
+ "atime": [72, readTimespec64],
646
+ "mtime": [88, readTimespec64],
647
+ "ctime": [104, readTimespec64],
648
+ "size": [48, "S64"],
649
+ "blocks": [64, "S64"],
650
+ "blksize": [56, "S64"],
651
+ },
652
+ },
653
+ "linux-arm": statSpecGenericLinux32,
654
+ "linux-arm-stat64": {
616
655
  size: 104,
617
656
  fields: {
618
657
  "dev": [0, "U64"],
@@ -630,22 +669,22 @@ const statSpecs = {
630
669
  "blksize": [56, "S32"],
631
670
  }
632
671
  },
633
- "linux-64": {
634
- size: 144,
672
+ "linux-arm64": {
673
+ size: 128,
635
674
  fields: {
636
675
  "dev": [0, "U64"],
637
- "mode": [24, "U32"],
638
- "nlink": [16, "U64"],
676
+ "mode": [16, "U32"],
677
+ "nlink": [20, "U32"],
639
678
  "ino": [8, "U64"],
640
- "uid": [28, "U32"],
641
- "gid": [32, "U32"],
642
- "rdev": [40, "U64"],
679
+ "uid": [24, "U32"],
680
+ "gid": [28, "U32"],
681
+ "rdev": [32, "U64"],
643
682
  "atime": [72, readTimespec64],
644
683
  "mtime": [88, readTimespec64],
645
684
  "ctime": [104, readTimespec64],
646
685
  "size": [48, "S64"],
647
686
  "blocks": [64, "S64"],
648
- "blksize": [56, "S64"],
687
+ "blksize": [56, "S32"],
649
688
  },
650
689
  },
651
690
  };
@@ -661,14 +700,19 @@ function getStatSpec() {
661
700
  else {
662
701
  const api = getPosixApi();
663
702
  const stat64Impl = api.stat64 ?? api.__xstat64;
664
- let platformId = `${platform}-${pointerSize * 8}`;
665
- if (platformId === "linux-32") {
666
- if (stat64Impl !== undefined)
703
+ let platformId;
704
+ if (platform === "darwin") {
705
+ platformId = `darwin-${pointerSize * 8}`;
706
+ }
707
+ else {
708
+ platformId = `${platform}-${Process.arch}`;
709
+ if (pointerSize === 4 && stat64Impl !== undefined) {
667
710
  platformId += "-stat64";
711
+ }
668
712
  }
669
713
  statSpec = statSpecs[platformId];
670
714
  if (statSpec === undefined)
671
- throw new Error("Current OS is not yet supported; please open a PR");
715
+ throw new Error("Current OS/arch combo is not yet supported; please open a PR");
672
716
  statSpec._stat = stat64Impl ?? api.stat;
673
717
  statSpec._lstat = api.lstat64 ?? api.__lxstat64 ?? api.lstat;
674
718
  }
@@ -849,12 +893,12 @@ function callbackify(original) {
849
893
  });
850
894
  };
851
895
  }
852
- const SF = SystemFunction;
853
- const NF = NativeFunction;
854
896
  const ssizeType = (pointerSize === 8) ? "int64" : "int32";
855
897
  const sizeType = "u" + ssizeType;
856
898
  const offsetType = (platform === "darwin" || pointerSize === 8) ? "int64" : "int32";
857
899
  function _getWindowsApi() {
900
+ const SF = SystemFunction;
901
+ const NF = NativeFunction;
858
902
  return makeApi([
859
903
  ["CreateFileW", SF, "pointer", ["pointer", "uint", "uint", "pointer", "uint", "uint", "pointer"]],
860
904
  ["DeleteFileW", SF, "uint", ["pointer"]],
@@ -871,6 +915,8 @@ function _getWindowsApi() {
871
915
  ]);
872
916
  }
873
917
  function _getPosixApi() {
918
+ const SF = SystemFunction;
919
+ const NF = NativeFunction;
874
920
  return makeApi([
875
921
  ["open", SF, "int", ["pointer", "int", "...", "int"]],
876
922
  ["close", NF, "int", ["int"]],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frida-fs",
3
- "version": "5.2.0",
3
+ "version": "5.2.2",
4
4
  "description": "Create a stream from a filesystem resource",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",