@cheatron/native 1.2.0 → 1.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.
package/dist/process.d.ts CHANGED
@@ -2,59 +2,35 @@ import { Thread } from './thread';
2
2
  import { ThreadCreationFlags, MemoryFreeType, type SecurityAttributes, type MemoryBasicInformation, type HANDLE, type LPVOID, type SIZE_T } from '@cheatron/native-bindings';
3
3
  import { Handle } from './handle';
4
4
  import { Pattern } from './pattern';
5
+ import { ScanResult } from './scan-result';
5
6
  /**
6
7
  * Represents a process handle
7
8
  */
8
9
  export declare class Process extends Handle {
9
10
  protected _pid: number;
11
+ readonly memory: ProcessMemory;
10
12
  constructor(handle: HANDLE, pid?: number, autoClose?: boolean);
11
13
  static open(pid: number, access?: number): Process;
12
- readMemory(address: LPVOID, size: number): Buffer;
13
- read: (address: LPVOID, size: number) => Buffer;
14
- writeMemory(address: LPVOID, buffer: Buffer): void;
15
- write: (address: LPVOID, buffer: Buffer) => void;
16
14
  createThread(startAddress: LPVOID, parameter?: LPVOID | null, stackSize?: SIZE_T, flags?: ThreadCreationFlags | number, attributes?: SecurityAttributes | LPVOID | null): Thread;
17
- virtualQuery(address: LPVOID): MemoryBasicInformation;
18
- query: (address: LPVOID) => MemoryBasicInformation;
19
15
  /**
20
- * Allocates memory in the process.
16
+ * Finds pattern matches in a specific memory range.
17
+ * Configure limit on the Pattern: `.limit(1)` for first match only.
21
18
  */
22
- alloc(size: SIZE_T, address?: LPVOID | null, allocationType?: number, protection?: number): LPVOID;
19
+ private findPatternInRangeGenerator;
20
+ findPatternInRange(signature: string | Pattern, start: bigint, size: number, module?: import('./module').Module): ScanResult;
23
21
  /**
24
- * Frees memory in the process.
22
+ * Finds pattern matches in all committed readable memory of the process.
23
+ * Configure limit and protect filter on the Pattern object.
25
24
  */
26
- free(address: LPVOID, size?: SIZE_T, freeType?: MemoryFreeType | number): boolean;
25
+ private findPatternGenerator;
26
+ findPattern(signature: string | Pattern): ScanResult;
27
27
  /**
28
- * Finds a pattern in a specific memory range
29
- * @param signature Pattern string (e.g. "55 8B EC ?? 56")
30
- * @param start Start address
31
- * @param size Scan size
28
+ * Finds pattern matches across specified modules (default: all static modules).
29
+ * Each entry in the result is tagged with its source module.
30
+ * Configure limit and protect filter on the Pattern object.
32
31
  */
33
- findPatternInRange(signature: string | Pattern, start: bigint, size: number): bigint | null;
34
- /**
35
- * Finds all matches of a pattern in a specific memory range
36
- */
37
- findAllPatternsInRange(signature: string | Pattern, start: bigint, size: number, limit?: number): bigint[];
38
- /**
39
- * Finds a pattern in all committed and readable memory of the process
40
- */
41
- findPattern(signature: string | Pattern): bigint | null;
42
- /**
43
- * Finds all matches of a pattern in all committed and readable memory
44
- */
45
- findAllPatterns(signature: string | Pattern, limit?: number): bigint[];
46
- /**
47
- * Scans specific loaded modules for a given pattern.
48
- * Finds the first pattern match across the specified (or default) modules.
49
- * @param signature Pattern string (e.g. "55 8B EC ?? 56") or Pattern object
50
- * @param moduleNames Array of module names (e.g. ['kernel32.dll', 'msvcrt.dll'])
51
- * @returns The first matched address, or null if not found
52
- */
53
- findPatternFromModules(signature: string | Pattern, moduleNames?: string[]): bigint | null;
54
- /**
55
- * Finds all matches of a pattern across specified modules
56
- */
57
- findAllPatternsFromModules(signature: string | Pattern, moduleNames?: string[], limit?: number): bigint[];
32
+ private findPatternFromModulesGenerator;
33
+ findPatternFromModules(signature: string | Pattern, moduleNames?: string[]): ScanResult;
58
34
  static current(): CurrentProcess;
59
35
  get pid(): number;
60
36
  }
@@ -62,11 +38,67 @@ export declare class Process extends Handle {
62
38
  * Represents the current process (singleton)
63
39
  */
64
40
  export declare class CurrentProcess extends Process {
41
+ readonly memory: CurrentProcessMemory;
65
42
  constructor();
66
43
  createThread(startAddress: LPVOID, parameter?: LPVOID | null, stackSize?: SIZE_T, flags?: ThreadCreationFlags | number, attributes?: SecurityAttributes | LPVOID | null): Thread;
67
- alloc(size: SIZE_T, address?: LPVOID | null, allocationType?: number, protection?: number): LPVOID;
68
- free(address: LPVOID, size?: SIZE_T, freeType?: MemoryFreeType | number): boolean;
69
44
  close(): void;
70
45
  }
71
46
  export declare const currentProcess: CurrentProcess;
47
+ /**
48
+ * Manages memory operations for a given process handle.
49
+ */
50
+ export declare class ProcessMemory {
51
+ readonly process: Process;
52
+ constructor(process: Process);
53
+ read(address: LPVOID, size: number): Buffer;
54
+ readMemory: (address: LPVOID, size: number) => Buffer;
55
+ write(address: LPVOID, buffer: Buffer): void;
56
+ writeMemory: (address: LPVOID, buffer: Buffer) => void;
57
+ readInt8(address: LPVOID): number;
58
+ writeInt8(address: LPVOID, value: number): void;
59
+ readUInt8(address: LPVOID): number;
60
+ writeUInt8(address: LPVOID, value: number): void;
61
+ readInt16(address: LPVOID): number;
62
+ writeInt16(address: LPVOID, value: number): void;
63
+ readUInt16(address: LPVOID): number;
64
+ writeUInt16(address: LPVOID, value: number): void;
65
+ readInt32(address: LPVOID): number;
66
+ writeInt32(address: LPVOID, value: number): void;
67
+ readUInt32(address: LPVOID): number;
68
+ writeUInt32(address: LPVOID, value: number): void;
69
+ readInt64(address: LPVOID): bigint;
70
+ writeInt64(address: LPVOID, value: bigint): void;
71
+ readUInt64(address: LPVOID): bigint;
72
+ writeUInt64(address: LPVOID, value: bigint): void;
73
+ readFloat(address: LPVOID): number;
74
+ writeFloat(address: LPVOID, value: number): void;
75
+ readDouble(address: LPVOID): number;
76
+ writeDouble(address: LPVOID, value: number): void;
77
+ readString(address: LPVOID, length: number, encoding?: BufferEncoding): string;
78
+ writeString(address: LPVOID, value: string, encoding?: BufferEncoding): void;
79
+ query(address: LPVOID): MemoryBasicInformation;
80
+ virtualQuery: (address: LPVOID) => MemoryBasicInformation;
81
+ /**
82
+ * Allocates memory in the process.
83
+ */
84
+ alloc(size: SIZE_T, address?: LPVOID | null, allocationType?: number, protection?: number): LPVOID;
85
+ /**
86
+ * Frees memory in the process.
87
+ */
88
+ free(address: LPVOID, size?: SIZE_T, freeType?: MemoryFreeType | number): boolean;
89
+ /**
90
+ * Changes the memory protection of a region of memory.
91
+ */
92
+ protect(address: LPVOID, size: SIZE_T, newProtect: number): number | null;
93
+ }
94
+ /**
95
+ * Optimizes memory operations natively for the current running process.
96
+ */
97
+ export declare class CurrentProcessMemory extends ProcessMemory {
98
+ alloc(size: SIZE_T, address?: LPVOID | null, allocationType?: number, protection?: number): LPVOID;
99
+ free(address: LPVOID, size?: SIZE_T, freeType?: MemoryFreeType | number): boolean;
100
+ protect(address: LPVOID, size: SIZE_T | number, newProtect: number): number | null;
101
+ query(address: LPVOID): MemoryBasicInformation;
102
+ virtualQuery: (address: LPVOID) => MemoryBasicInformation;
103
+ }
72
104
  //# sourceMappingURL=process.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAIL,mBAAmB,EAKnB,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,MAAM,EACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC;;GAEG;AACH,qBAAa,OAAQ,SAAQ,MAAM;IACjC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,GAAE,OAAc;IAKnE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,MAAiC,GAAG,OAAO;IAU5E,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAmBjD,IAAI,YAnBgB,MAAM,QAAQ,MAAM,KAAG,MAAM,CAmB1B;IAEv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