bun-memory 1.1.47 → 1.1.48
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.
- package/package.json +1 -1
- package/structs/Memory.ts +142 -86
package/package.json
CHANGED
package/structs/Memory.ts
CHANGED
|
@@ -1533,26 +1533,67 @@ class Memory {
|
|
|
1533
1533
|
}
|
|
1534
1534
|
|
|
1535
1535
|
/**
|
|
1536
|
-
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as
|
|
1536
|
+
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as a UTF-8 string.
|
|
1537
1537
|
* @param address Address of the TArray structure.
|
|
1538
|
-
* @param
|
|
1538
|
+
* @param value Optional string to write.
|
|
1539
1539
|
* @param force When writing, if true temporarily changes page protection to allow the write.
|
|
1540
|
-
* @returns
|
|
1540
|
+
* @returns The string, or this instance if writing.
|
|
1541
1541
|
* @example
|
|
1542
1542
|
* ```ts
|
|
1543
1543
|
* const rl = new Memory('RocketLeague.exe');
|
|
1544
|
-
* const
|
|
1545
|
-
* rl.
|
|
1544
|
+
* const myString = rl.tArrayChar(0x12345678n);
|
|
1545
|
+
* rl.tArrayChar(0x12345678n, 'hello');
|
|
1546
1546
|
* ```
|
|
1547
1547
|
*/
|
|
1548
|
-
public
|
|
1549
|
-
public
|
|
1550
|
-
public
|
|
1548
|
+
public tArrayChar(address: bigint): string;
|
|
1549
|
+
public tArrayChar(address: bigint, value: string, force?: boolean): this;
|
|
1550
|
+
public tArrayChar(address: bigint, value?: string, force?: boolean): string | this {
|
|
1551
|
+
const dataPtr = this.u64(address);
|
|
1552
|
+
|
|
1553
|
+
if (value === undefined) {
|
|
1554
|
+
const count = this.u32(address + 0x08n);
|
|
1555
|
+
|
|
1556
|
+
if (count === 0x00) {
|
|
1557
|
+
return '';
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
const scratch = Buffer.allocUnsafe(count - 0x01);
|
|
1561
|
+
|
|
1562
|
+
void this.read(dataPtr, scratch);
|
|
1563
|
+
|
|
1564
|
+
return scratch.toString('utf8');
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
const scratch = Buffer.from(value, 'utf8');
|
|
1568
|
+
|
|
1569
|
+
this.u32(address + 0x08n, scratch.length + 0x01, force);
|
|
1570
|
+
|
|
1571
|
+
void this.write(dataPtr, scratch, force);
|
|
1572
|
+
|
|
1573
|
+
return this;
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
/**
|
|
1577
|
+
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as a Float32Array.
|
|
1578
|
+
* @param address Address of the TArray structure.
|
|
1579
|
+
* @param values Optional Float32Array to write.
|
|
1580
|
+
* @param force When writing, if true temporarily changes page protection to allow the write.
|
|
1581
|
+
* @returns A Float32Array containing the elements, or this instance if writing.
|
|
1582
|
+
* @example
|
|
1583
|
+
* ```ts
|
|
1584
|
+
* const rl = new Memory('RocketLeague.exe');
|
|
1585
|
+
* const myArray = rl.tArrayF32(0x12345678n);
|
|
1586
|
+
* rl.tArrayF32(0x12345678n, new Float32Array([1.0, 2.0, 3.0]));
|
|
1587
|
+
* ```
|
|
1588
|
+
*/
|
|
1589
|
+
public tArrayF32(address: bigint): Float32Array;
|
|
1590
|
+
public tArrayF32(address: bigint, values: Float32Array, force?: boolean): this;
|
|
1591
|
+
public tArrayF32(address: bigint, values?: Float32Array, force?: boolean): Float32Array | this {
|
|
1551
1592
|
const dataPtr = this.u64(address);
|
|
1552
1593
|
|
|
1553
1594
|
if (values === undefined) {
|
|
1554
1595
|
const count = this.u32(address + 0x08n);
|
|
1555
|
-
const scratch = new
|
|
1596
|
+
const scratch = new Float32Array(count);
|
|
1556
1597
|
|
|
1557
1598
|
void this.read(dataPtr, scratch);
|
|
1558
1599
|
|
|
@@ -1567,26 +1608,26 @@ class Memory {
|
|
|
1567
1608
|
}
|
|
1568
1609
|
|
|
1569
1610
|
/**
|
|
1570
|
-
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as
|
|
1611
|
+
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as a Float64Array.
|
|
1571
1612
|
* @param address Address of the TArray structure.
|
|
1572
|
-
* @param values Optional
|
|
1613
|
+
* @param values Optional Float64Array to write.
|
|
1573
1614
|
* @param force When writing, if true temporarily changes page protection to allow the write.
|
|
1574
|
-
* @returns
|
|
1615
|
+
* @returns A Float64Array containing the elements, or this instance if writing.
|
|
1575
1616
|
* @example
|
|
1576
1617
|
* ```ts
|
|
1577
1618
|
* const rl = new Memory('RocketLeague.exe');
|
|
1578
|
-
* const myArray = rl.
|
|
1579
|
-
* rl.
|
|
1619
|
+
* const myArray = rl.tArrayF64(0x12345678n);
|
|
1620
|
+
* rl.tArrayF64(0x12345678n, new Float64Array([1.0, 2.0, 3.0]));
|
|
1580
1621
|
* ```
|
|
1581
1622
|
*/
|
|
1582
|
-
public
|
|
1583
|
-
public
|
|
1584
|
-
public
|
|
1623
|
+
public tArrayF64(address: bigint): Float64Array;
|
|
1624
|
+
public tArrayF64(address: bigint, values: Float64Array, force?: boolean): this;
|
|
1625
|
+
public tArrayF64(address: bigint, values?: Float64Array, force?: boolean): Float64Array | this {
|
|
1585
1626
|
const dataPtr = this.u64(address);
|
|
1586
1627
|
|
|
1587
1628
|
if (values === undefined) {
|
|
1588
1629
|
const count = this.u32(address + 0x08n);
|
|
1589
|
-
const scratch = new
|
|
1630
|
+
const scratch = new Float64Array(count);
|
|
1590
1631
|
|
|
1591
1632
|
void this.read(dataPtr, scratch);
|
|
1592
1633
|
|
|
@@ -1601,26 +1642,26 @@ class Memory {
|
|
|
1601
1642
|
}
|
|
1602
1643
|
|
|
1603
1644
|
/**
|
|
1604
|
-
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as
|
|
1645
|
+
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as an Int16Array.
|
|
1605
1646
|
* @param address Address of the TArray structure.
|
|
1606
|
-
* @param values Optional
|
|
1647
|
+
* @param values Optional Int16Array to write.
|
|
1607
1648
|
* @param force When writing, if true temporarily changes page protection to allow the write.
|
|
1608
|
-
* @returns
|
|
1649
|
+
* @returns An Int16Array containing the elements, or this instance if writing.
|
|
1609
1650
|
* @example
|
|
1610
1651
|
* ```ts
|
|
1611
1652
|
* const rl = new Memory('RocketLeague.exe');
|
|
1612
|
-
* const myArray = rl.
|
|
1613
|
-
* rl.
|
|
1653
|
+
* const myArray = rl.tArrayI16(0x12345678n);
|
|
1654
|
+
* rl.tArrayI16(0x12345678n, new Int16Array([1, 2, 3]));
|
|
1614
1655
|
* ```
|
|
1615
1656
|
*/
|
|
1616
|
-
public
|
|
1617
|
-
public
|
|
1618
|
-
public
|
|
1657
|
+
public tArrayI16(address: bigint): Int16Array;
|
|
1658
|
+
public tArrayI16(address: bigint, values: Int16Array, force?: boolean): this;
|
|
1659
|
+
public tArrayI16(address: bigint, values?: Int16Array, force?: boolean): Int16Array | this {
|
|
1619
1660
|
const dataPtr = this.u64(address);
|
|
1620
1661
|
|
|
1621
1662
|
if (values === undefined) {
|
|
1622
1663
|
const count = this.u32(address + 0x08n);
|
|
1623
|
-
const scratch = new
|
|
1664
|
+
const scratch = new Int16Array(count);
|
|
1624
1665
|
|
|
1625
1666
|
void this.read(dataPtr, scratch);
|
|
1626
1667
|
|
|
@@ -1635,26 +1676,26 @@ class Memory {
|
|
|
1635
1676
|
}
|
|
1636
1677
|
|
|
1637
1678
|
/**
|
|
1638
|
-
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as
|
|
1679
|
+
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as an Int32Array.
|
|
1639
1680
|
* @param address Address of the TArray structure.
|
|
1640
|
-
* @param values Optional
|
|
1681
|
+
* @param values Optional Int32Array to write.
|
|
1641
1682
|
* @param force When writing, if true temporarily changes page protection to allow the write.
|
|
1642
|
-
* @returns
|
|
1683
|
+
* @returns An Int32Array containing the elements, or this instance if writing.
|
|
1643
1684
|
* @example
|
|
1644
1685
|
* ```ts
|
|
1645
1686
|
* const rl = new Memory('RocketLeague.exe');
|
|
1646
|
-
* const myArray = rl.
|
|
1647
|
-
* rl.
|
|
1687
|
+
* const myArray = rl.tArrayI32(0x12345678n);
|
|
1688
|
+
* rl.tArrayI32(0x12345678n, new Int32Array([1, 2, 3]));
|
|
1648
1689
|
* ```
|
|
1649
1690
|
*/
|
|
1650
|
-
public
|
|
1651
|
-
public
|
|
1652
|
-
public
|
|
1691
|
+
public tArrayI32(address: bigint): Int32Array;
|
|
1692
|
+
public tArrayI32(address: bigint, values: Int32Array, force?: boolean): this;
|
|
1693
|
+
public tArrayI32(address: bigint, values?: Int32Array, force?: boolean): Int32Array | this {
|
|
1653
1694
|
const dataPtr = this.u64(address);
|
|
1654
1695
|
|
|
1655
1696
|
if (values === undefined) {
|
|
1656
1697
|
const count = this.u32(address + 0x08n);
|
|
1657
|
-
const scratch = new
|
|
1698
|
+
const scratch = new Int32Array(count);
|
|
1658
1699
|
|
|
1659
1700
|
void this.read(dataPtr, scratch);
|
|
1660
1701
|
|
|
@@ -1669,26 +1710,26 @@ class Memory {
|
|
|
1669
1710
|
}
|
|
1670
1711
|
|
|
1671
1712
|
/**
|
|
1672
|
-
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as a
|
|
1713
|
+
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as a BigInt64Array.
|
|
1673
1714
|
* @param address Address of the TArray structure.
|
|
1674
|
-
* @param values Optional
|
|
1715
|
+
* @param values Optional BigInt64Array to write.
|
|
1675
1716
|
* @param force When writing, if true temporarily changes page protection to allow the write.
|
|
1676
|
-
* @returns A
|
|
1717
|
+
* @returns A BigInt64Array containing the elements, or this instance if writing.
|
|
1677
1718
|
* @example
|
|
1678
1719
|
* ```ts
|
|
1679
1720
|
* const rl = new Memory('RocketLeague.exe');
|
|
1680
|
-
* const myArray = rl.
|
|
1681
|
-
* rl.
|
|
1721
|
+
* const myArray = rl.tArrayI64(0x12345678n);
|
|
1722
|
+
* rl.tArrayI64(0x12345678n, new BigInt64Array([1n, 2n, 3n]));
|
|
1682
1723
|
* ```
|
|
1683
1724
|
*/
|
|
1684
|
-
public
|
|
1685
|
-
public
|
|
1686
|
-
public
|
|
1725
|
+
public tArrayI64(address: bigint): BigInt64Array;
|
|
1726
|
+
public tArrayI64(address: bigint, values: BigInt64Array, force?: boolean): this;
|
|
1727
|
+
public tArrayI64(address: bigint, values?: BigInt64Array, force?: boolean): BigInt64Array | this {
|
|
1687
1728
|
const dataPtr = this.u64(address);
|
|
1688
1729
|
|
|
1689
1730
|
if (values === undefined) {
|
|
1690
1731
|
const count = this.u32(address + 0x08n);
|
|
1691
|
-
const scratch = new
|
|
1732
|
+
const scratch = new BigInt64Array(count);
|
|
1692
1733
|
|
|
1693
1734
|
void this.read(dataPtr, scratch);
|
|
1694
1735
|
|
|
@@ -1736,6 +1777,62 @@ class Memory {
|
|
|
1736
1777
|
return this;
|
|
1737
1778
|
}
|
|
1738
1779
|
|
|
1780
|
+
/**
|
|
1781
|
+
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as an array of raw buffers.
|
|
1782
|
+
* Useful for reading/writing arrays of structs or custom-sized elements.
|
|
1783
|
+
* @param address Address of the TArray structure.
|
|
1784
|
+
* @param dataSize Size in bytes of each element.
|
|
1785
|
+
* @param values Optional array of Buffers to write.
|
|
1786
|
+
* @param force When writing, if true temporarily changes page protection to allow the write.
|
|
1787
|
+
* @returns An array of Buffers, one per element, or this instance if writing.
|
|
1788
|
+
* @example
|
|
1789
|
+
* ```ts
|
|
1790
|
+
* const rl = new Memory('RocketLeague.exe');
|
|
1791
|
+
* const structs = rl.tArrayRaw(0x12345678n, 0x18); // Array of 0x18-byte buffers
|
|
1792
|
+
* rl.tArrayRaw(0x12345678n, [buffer1, buffer2]);
|
|
1793
|
+
* ```
|
|
1794
|
+
*/
|
|
1795
|
+
public tArrayRaw(address: bigint, dataSize: number): Buffer[];
|
|
1796
|
+
public tArrayRaw(address: bigint, values: Buffer[], force?: boolean): this;
|
|
1797
|
+
public tArrayRaw(address: bigint, dataSizeOrValues: number | Buffer[], force?: boolean): Buffer[] | this {
|
|
1798
|
+
const dataPtr = this.u64(address);
|
|
1799
|
+
|
|
1800
|
+
if (typeof dataSizeOrValues === 'number') {
|
|
1801
|
+
const dataSize = dataSizeOrValues;
|
|
1802
|
+
const count = this.u32(address + 0x08n);
|
|
1803
|
+
|
|
1804
|
+
if (count === 0) {
|
|
1805
|
+
return [];
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
const scratch = Buffer.allocUnsafe(count * dataSize);
|
|
1809
|
+
|
|
1810
|
+
void this.read(dataPtr, scratch);
|
|
1811
|
+
|
|
1812
|
+
const result: Buffer[] = new Array(count);
|
|
1813
|
+
|
|
1814
|
+
for (let i = 0; i < count; i++) {
|
|
1815
|
+
result[i] = scratch.subarray(i * dataSize, (i + 1) * dataSize);
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
return result;
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
const values = dataSizeOrValues;
|
|
1822
|
+
const dataSize = values[0].length;
|
|
1823
|
+
const scratch = Buffer.allocUnsafe(values.length * dataSize);
|
|
1824
|
+
|
|
1825
|
+
for (let i = 0; i < values.length; i++) {
|
|
1826
|
+
values[i].copy(scratch, i * dataSize);
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
this.u32(address + 0x08n, values.length, force);
|
|
1830
|
+
|
|
1831
|
+
void this.write(dataPtr, scratch, force);
|
|
1832
|
+
|
|
1833
|
+
return this;
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1739
1836
|
/**
|
|
1740
1837
|
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as a Uint16Array.
|
|
1741
1838
|
* @param address Address of the TArray structure.
|
|
@@ -1896,47 +1993,6 @@ class Memory {
|
|
|
1896
1993
|
return this.tArrayU64(address, values, force);
|
|
1897
1994
|
}
|
|
1898
1995
|
|
|
1899
|
-
/**
|
|
1900
|
-
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as a UTF-8 string.
|
|
1901
|
-
* @param address Address of the TArray structure.
|
|
1902
|
-
* @param value Optional string to write.
|
|
1903
|
-
* @param force When writing, if true temporarily changes page protection to allow the write.
|
|
1904
|
-
* @returns The string, or this instance if writing.
|
|
1905
|
-
* @example
|
|
1906
|
-
* ```ts
|
|
1907
|
-
* const rl = new Memory('RocketLeague.exe');
|
|
1908
|
-
* const myString = rl.tArrayChar(0x12345678n);
|
|
1909
|
-
* rl.tArrayChar(0x12345678n, 'hello');
|
|
1910
|
-
* ```
|
|
1911
|
-
*/
|
|
1912
|
-
public tArrayChar(address: bigint): string;
|
|
1913
|
-
public tArrayChar(address: bigint, value: string, force?: boolean): this;
|
|
1914
|
-
public tArrayChar(address: bigint, value?: string, force?: boolean): string | this {
|
|
1915
|
-
const dataPtr = this.u64(address);
|
|
1916
|
-
|
|
1917
|
-
if (value === undefined) {
|
|
1918
|
-
const count = this.u32(address + 0x08n);
|
|
1919
|
-
|
|
1920
|
-
if (count === 0x00) {
|
|
1921
|
-
return '';
|
|
1922
|
-
}
|
|
1923
|
-
|
|
1924
|
-
const scratch = Buffer.allocUnsafe(count - 0x01);
|
|
1925
|
-
|
|
1926
|
-
void this.read(dataPtr, scratch);
|
|
1927
|
-
|
|
1928
|
-
return scratch.toString('utf8');
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1931
|
-
const scratch = Buffer.from(value, 'utf8');
|
|
1932
|
-
|
|
1933
|
-
this.u32(address + 0x08n, scratch.length + 0x01, force);
|
|
1934
|
-
|
|
1935
|
-
void this.write(dataPtr, scratch, force);
|
|
1936
|
-
|
|
1937
|
-
return this;
|
|
1938
|
-
}
|
|
1939
|
-
|
|
1940
1996
|
/**
|
|
1941
1997
|
* Reads or writes a TArray (Data at 0x00, Count at 0x08, Max at 0x0c) as a UTF-16LE string.
|
|
1942
1998
|
* This is the format used by FName/FString in Unreal Engine.
|