-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstandard.split
More file actions
9760 lines (9232 loc) · 307 KB
/
Copy pathstandard.split
File metadata and controls
9760 lines (9232 loc) · 307 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/// Attaches to one of the native processes named by the state declaration.
///
/// Each candidate is an exact host process identity. The current Windows host
/// reports executable filenames including `.exe`, so Windows candidates must
/// include that extension. Use an array for alternate executable names; the
/// provider tries them in order and attaches to one matching process.
///
/// The read-only value has type [`Process`] and is a handle to the attached game
/// process.
///
/// # Example
///
/// Read native process memory
///
/// ```splitscript
/// state "game.exe" {}
/// whileAttached {
/// let health = process.read<i32>(0x1234) else 0
/// }
/// ```
///
/// # Example
///
/// Try alternate executable names
///
/// ```splitscript
/// state ["game.exe", "game-demo.exe"] {}
/// onAttach {
/// print(process.name())
/// }
/// ```
@processType(Process)
@processes(source)
@default
@attachment(identity)
@directRead(ProcessRead)
stateProvider Native as process {}
/// Attaches to a Unity game and binds declared managed metadata schemas.
///
/// Automatic mode waits for either an IL2CPP `GameAssembly.dll` runtime or a
/// modern `mono-2.0-bdwgc.dll` runtime. It derives the supported metadata
/// layout from the loaded Unity player rather than guessing from schema names.
/// Use an explicit selector only when the target's exact metadata family is
/// known and automatic detection is inappropriate.
///
/// The read-only process value remains a native [`Process`] handle. Managed
/// images and classes declared with [`image`] are the public managed-memory
/// interface. Their reachable metadata is bound once before [`onAttach`] runs;
/// scripts do not discover runtime images, classes, field offsets, or static
/// tables themselves. The attachment-scoped [`unity`](provider@Unity) value
/// separately exposes native scene and hierarchy facilities.
///
/// A declared class name such as `PlayerController` is an immutable local
/// snapshot type. `PlayerController.Ref` is a live remote reference. Following
/// a live static or instance field is fallible and rereads replaceable object
/// pointers on every state poll. Calling `.snapshot()` reads all active fields
/// transactionally. Scalar live reads allocate no GC objects; snapshots,
/// strings, arrays, and instance-search results materialize owned values.
/// Generated binders, readers, and runtime discovery are retained only when
/// reachable from the script.
///
/// # Example
///
/// Detect the Unity backend automatically
///
/// ```splitscript
/// state Unity ["game.exe"] {}
/// ```
///
/// # Example
///
/// Read one transactional managed snapshot
///
/// ```splitscript
/// image "Assembly-CSharp" {
/// class GameManager {
/// static GameManager instance;
/// u32 score;
/// bool finished;
/// }
/// }
///
/// state Unity ["game.exe"] {
/// manager: GameManager = GameManager.instance?.snapshot()?;
/// }
/// ```
///
/// # Example
///
/// Read a managed component from the active scene hierarchy
///
/// ```splitscript
/// state Unity ["game.exe"] {
/// player = unity.scenes.active()?
/// .find("World/Player")?
/// .component<PlayerController>()?
/// .snapshot();
/// }
///
/// image "Assembly-CSharp" {
/// class PlayerController {
/// u32 score;
/// }
/// }
/// ```
@processType(Process)
@processes(source)
@attachment(identity)
@prepare(UnityProviderAuto)
@directRead(ProcessRead)
stateProvider Unity as process {
/// Provides attachment-scoped Unity engine facilities.
///
/// The value is available wherever the attached [`process`] is available.
/// Its members are discovered once before user [`onAttach`] code runs.
///
/// # Example
///
/// Track the active native Unity scene
///
/// ```splitscript
/// state Unity ["game.exe"] {
/// scene = unity.scenes.active();
/// }
/// ```
@prepare(UnityProviderContext)
context unity: UnityContext,
/// Selects a known IL2CPP metadata layout.
///
/// This bypasses Unity-version detection while retaining cooperative
/// GameAssembly and metadata discovery.
@prepare(UnityProviderIl2Cpp)
@managedBackend(il2cpp)
selector il2cpp(version: u32),
/// Selects a known modern Mono metadata layout.
///
/// This bypasses Unity-version detection while retaining cooperative Mono
/// module and metadata discovery.
@prepare(UnityProviderMono)
@managedBackend(mono)
selector mono(version: MonoVersion),
}
/// Attaches to a supported Game Boy Advance emulator.
///
/// The provider discovers emulated EWRAM and IWRAM and exposes original GBA
/// hardware addresses through the read-only value introduced by [`GBA`].
/// It owns discovery for VisualBoyAdvance and VBA-M, mGBA, NO$GBA, Mednafen,
/// supported RetroArch cores, and mGBA-based BizHawk. Declare guest addresses
/// directly instead of recreating emulator-specific `DeepPointer` mappings.
///
/// # Example
///
/// Read GBA work RAM
///
/// ```splitscript
/// state GBA {
/// room: u8 at 0x03000010
/// }
/// ```
@processType(GBAEmulator)
@attachment(GBAEmulatorDiscover)
@validate(GBAEmulatorMappingIsAvailable)
@directRead(GBAEmulatorRead)
stateProvider GBA as gba {
"visualboyadvance-m.exe",
"VisualBoyAdvance.exe",
"mGBA.exe",
"mGBA",
"NO$GBA.EXE",
"retroarch.exe",
"EmuHawk.exe",
"mednafen.exe",
}
/// Attaches to a supported PlayStation 2 emulator.
///
/// The provider discovers the emulator's main RAM mapping and exposes original
/// PS2 addresses through the read-only `ps2` value of type [`PS2Emulator`].
/// PCSX2 and 64-bit RetroArch using `pcsx2_libretro.dll` are supported.
/// Declare guest addresses directly instead of recreating emulator-specific
/// `DeepPointer` mappings.
///
/// # Example
///
/// Read PS2 memory
///
/// ```splitscript
/// state PS2 {
/// health: u16 at 0x00123456
/// }
/// ```
@processType(PS2Emulator)
@attachment(PS2EmulatorDiscover)
@validate(PS2EmulatorMappingIsAvailable)
@directRead(PS2EmulatorRead)
@readableRange(0x00100000, 0x02000000)
stateProvider PS2 as ps2 {
"pcsx2x64.exe",
"pcsx2-qt.exe",
"pcsx2x64-avx2.exe",
"pcsx2-avx2.exe",
"pcsx2.exe",
"retroarch.exe",
}
/// Attaches to a supported PlayStation emulator.
///
/// The provider discovers emulated main RAM and exposes original PlayStation
/// addresses through the read-only `ps1` value of type [`PS1Emulator`].
/// It owns discovery for ePSXe, pSX, DuckStation, Mednafen, PCSX-Redux, XEBRA,
/// and supported RetroArch cores. Declare guest addresses directly instead of
/// recreating emulator-specific `DeepPointer` mappings.
///
/// # Example
///
/// Read PlayStation memory
///
/// ```splitscript
/// state PS1 {
/// health: u16 at 0x80012346
/// }
/// ```
@processType(PS1Emulator)
@attachment(PS1EmulatorDiscover)
@validate(PS1EmulatorMappingIsAvailable)
@directRead(PS1EmulatorRead)
stateProvider PS1 as ps1 {
"ePSXe.exe",
"psxfin.exe",
"duckstation-qt-x64-ReleaseLTCG.exe",
"duckstation-nogui-x64-ReleaseLTCG.exe",
"retroarch.exe",
"pcsx-redux.main",
"XEBRA.EXE",
"mednafen.exe",
}
/// Attaches to a supported Sega Master System or Game Gear emulator.
///
/// The provider exposes original 16-bit console addresses through the read-only
/// `sms` value of type [`SMSEmulator`].
/// It owns discovery for Fusion, BlastEm, Mednafen, and supported RetroArch
/// cores. Declare guest addresses directly instead of recreating
/// emulator-specific `DeepPointer` mappings.
///
/// # Example
///
/// Read Master System work RAM
///
/// ```splitscript
/// state SMS {
/// lives: u8 at 0xc010
/// }
/// ```
@processType(SMSEmulator)
@attachment(SMSEmulatorDiscover)
@validate(SMSEmulatorMappingIsAvailable)
@directRead(SMSEmulatorRead)
stateProvider SMS as sms {
"retroarch.exe",
"Fusion.exe",
"blastem.exe",
"mednafen.exe",
}
/// Attaches to a supported Sega Genesis emulator.
///
/// The provider discovers the console's 64 KiB work RAM and exposes original
/// Genesis offsets through the read-only `genesis` value of type
/// [`GenesisEmulator`]. It normalizes the word-swapped storage used by several
/// emulators before decoding values in the console's big-endian byte order.
/// It owns discovery for Fusion, Gens, BlastEm, Sega Game Room, Sega Genesis
/// Classics, and supported RetroArch cores. Declare guest offsets directly
/// instead of recreating emulator-specific `DeepPointer` mappings or manual
/// byte-order correction.
///
/// # Example
///
/// Read Genesis work RAM
///
/// ```splitscript
/// state Genesis {
/// score: u32 at 0x1200
/// }
/// ```
@processType(GenesisEmulator)
@attachment(GenesisEmulatorDiscover)
@validate(GenesisEmulatorMappingIsAvailable)
@directRead(GenesisEmulatorRead)
stateProvider Genesis as genesis {
"retroarch.exe",
"SEGAGameRoom.exe",
"SEGAGenesisClassics.exe",
"Fusion.exe",
"gens.exe",
"blastem.exe",
}
/// Attaches to a supported Nintendo GameCube emulator.
///
/// The provider discovers the console's 24 MiB MEM1 mapping and exposes
/// original GameCube addresses through the read-only `gcn` value of type
/// [`GCNEmulator`]. Multi-byte values are decoded using the console's
/// big-endian byte order.
/// It owns discovery for Dolphin and 64-bit RetroArch using
/// `dolphin_libretro.dll`. Declare guest addresses directly instead of
/// recreating Dolphin mappings, `DeepPointer` chains, or byte swapping.
///
/// # Example
///
/// Read GameCube memory
///
/// ```splitscript
/// state GCN {
/// room: u16 at 0x80001000
/// }
/// ```
@processType(GCNEmulator)
@attachment(GCNEmulatorDiscover)
@validate(GCNEmulatorMappingIsAvailable)
@directRead(GCNEmulatorRead)
stateProvider GCN as gcn {
"Dolphin.exe",
"retroarch.exe",
}
/// Attaches to a supported Nintendo Wii emulator.
///
/// The provider discovers MEM1 and MEM2 and exposes original Wii addresses
/// through the read-only `wii` value of type [`WiiEmulator`]. Multi-byte
/// values use the console's big-endian byte order.
/// It owns discovery for Dolphin and 64-bit RetroArch using
/// `dolphin_libretro.dll`. Declare MEM1 or MEM2 guest addresses directly
/// instead of recreating Dolphin mappings, `DeepPointer` chains, or byte
/// swapping.
///
/// # Example
///
/// Read Wii memory
///
/// ```splitscript
/// state Wii {
/// room: u16 at 0x80001000
/// }
/// ```
@processType(WiiEmulator)
@attachment(WiiEmulatorDiscover)
@validate(WiiEmulatorMappingIsAvailable)
@directRead(WiiEmulatorRead)
stateProvider Wii as wii {
"Dolphin.exe",
"retroarch.exe",
}
root {
private fn dolphinCoreBase() -> async address {
if process.name() != "retroarch.exe" {
return 0
}
let executable = await process.mainModule()
if retry executable.pointerSize() != PointerSize.Bit64 {
await process.closed()
}
let core = await process.module("dolphin_libretro.dll")
return core.address
}
/// Prints a diagnostic message.
///
/// The message is forwarded to the autosplitting runtime.
///
/// # Example
///
/// Write to the runtime log
///
/// ```splitscript
/// print(42)
/// ```
@intrinsic(Print)
fn print<T: Display>(
/// The value to write to the runtime log.
message: T,
) -> None;
/// Sets a custom variable in the timer runtime.
///
/// The value is visible to layouts that display autosplitter variables.
///
/// # Example
///
/// Expose a layout variable
///
/// ```splitscript
/// setVariable("Points", 42)
/// ```
@intrinsic(TimerSetVariable)
fn setVariable<T: Display>(
/// The variable name.
name: String,
/// The displayed value. It is converted to text using the same rules
/// as string interpolation.
value: T,
) -> None;
/// Changes the autosplitter tick rate.
///
/// The value is a frequency in updates per second. SplitScript normally
/// applies 120 Hz immediately after attaching, before [`onAttach`], and 1
/// Hz during module startup and immediately after detaching, before
/// [`onDetach`]. A top-level [`tickRate`] declaration changes those
/// lifecycle-owned defaults.
///
/// This function instead changes the wait after the current update. Its
/// rate persists until another call or the next attachment transition,
/// when the corresponding declarative rate is reapplied. Use it only for a
/// genuinely temporary dynamic adjustment.
///
/// # Example
///
/// Temporarily reduce polling during module discovery
///
/// ```splitscript
/// setTickRate(30)
/// let assets = await process.module("assets.dll")
/// setTickRate(120)
/// print(`Assets loaded at {assets.address}`)
/// ```
@intrinsic(RuntimeSetTickRate)
fn setTickRate<T: Numeric>(
/// The positive, finite number of requested updates per second.
hz: T,
) -> None;
/// Continues attachment on the next runtime update.
///
/// Always suspends once. The continuation resumes on the following attached-process tick and is cancelled if that process closes first.
///
/// # Example
///
/// Resume on the next update
///
/// ```splitscript
/// await nextTick()
/// ```
@requires(attachedProcess)
@cancellation(processClose)
@availability(onAttach)
@intrinsic(NextTick)
fn nextTick() -> async None;
}
/// Coordinates lazy asynchronous values without exposing threads or background tasks.
///
/// Future combinators only make progress when their returned future is polled with
/// [`await`]. They preserve the attachment-lifetime cancellation of their inputs.
///
/// # Example
///
/// Coordinate alternative asynchronous work
///
/// ```splitscript
/// # state "game.exe" {}
/// # onAttach {
/// await future.race([nextTick(), nextTick()])
/// print("one tick operation completed")
/// # }
/// ```
namespace future {
/// Waits for the first operation that completes.
///
/// Calling this function only captures the array. Polling the returned future
/// polls the operations in array order on each runtime update, and the first
/// ready value wins. When several operations become ready during the same
/// update, the lowest array index wins. An empty array remains pending forever.
/// After completion, this combinator stops polling the other operations; an
/// operation retained elsewhere remains available through that shared handle.
///
/// # Example
///
/// Race alternate module names
///
/// ```splitscript
/// # state ["game.exe", "game-demo.exe"] {}
/// # onAttach {
/// let executable = await future.race([
/// process.module("game.exe"),
/// process.module("game-demo.exe"),
/// ])
/// # print(executable.address)
/// # }
/// ```
@requires(attachedProcess)
@cancellation(processClose)
@availability(onAttach)
@intrinsic(FutureRace)
fn race<T>(
/// Lazy operations with the same completion type.
operations: [async T],
) -> async T;
/// Waits for an operation until a duration has elapsed.
///
/// Calling this function is lazy: the deadline starts when the returned
/// future is first polled. Each runtime update polls `operation` before
/// checking the monotonic deadline, so a value that becomes ready exactly
/// at the deadline wins. A zero or negative duration permits one immediate
/// poll and then fails if the operation is still pending.
///
/// A timeout uses the ordinary [`T!`] error channel. If `operation` already
/// completes with a fallible value, its error and the timeout share that
/// single channel. The error text is intended for display, not for
/// programmatic classification. Once this wrapper times out, it no longer
/// polls `operation`; a future handle stored elsewhere remains valid and
/// may still be awaited independently.
///
/// # Example
///
/// Bound module discovery
///
/// ```splitscript
/// # state "game.exe" {}
/// # onAttach {
/// let executable = await future.timeout(
/// process.module("game.exe"),
/// Duration.fromSeconds(5),
/// ) else {
/// print("the game module was not discovered in time")
/// await process.closed()
/// }
/// # print(executable.address)
/// # }
/// ```
@requires(attachedProcess)
@cancellation(processClose)
@availability(onAttach)
@intrinsic(FutureTimeout)
fn timeout<T>(
/// The lazy operation to poll.
operation: async T,
/// The maximum time for which the operation may remain pending.
duration: Duration,
) -> async T!;
}
/// Reads metadata about the autosplitting runtime host.
///
/// These values describe the system running the autosplitting runtime, not necessarily the
/// architecture of the attached game process.
///
/// # Example
///
/// Inspect the host platform
///
/// ```splitscript
/// let hostOs = runtime.operatingSystem() else "unknown"
/// let hostArchitecture = runtime.architecture() else "unknown"
/// print(`Running on {hostOs} ({hostArchitecture})`)
/// ```
namespace runtime {
/// Returns the runtime host's operating-system name.
///
/// Common values are `windows`, `linux`, and `macos`. The result remains a
/// string so new host operating systems do not require a language update.
///
/// # Example
///
/// Select platform-specific metadata handling
///
/// ```splitscript
/// let hostOs = runtime.operatingSystem() else "unknown"
/// ```
@intrinsic(RuntimeOperatingSystem)
fn operatingSystem() -> String!;
/// Returns the runtime host's architecture name.
///
/// Common values include `x86`, `x86_64`, `arm`, and `aarch64`. This is the
/// runtime architecture rather than a guarantee about the attached process.
///
/// # Example
///
/// Report the host architecture
///
/// ```splitscript
/// let hostArchitecture = runtime.architecture() else "unknown"
/// ```
@intrinsic(RuntimeArchitecture)
fn architecture() -> String!;
}
/// Selects either the current or previous values of the script's declared settings.
///
/// The compiler supplies [`settings`] and [`oldSettings`]; copying either value is
/// allocation-free because the value only identifies one of the two snapshots.
///
/// # Example
///
/// Look up a boolean setting by its stable host key
///
/// ```splitscript
/// # state "game.exe" {}
/// # settings { "Split boss" => splitBoss key "split-boss": true }
/// # whileAttached {
/// if settings.enabled("split-boss") {
/// print("Boss splitting is enabled")
/// }
/// # }
/// ```
@representation(scalar, i32)
@valueUsage(localVariable, globalVariable)
intrinsic type SettingsView {
/// Returns a declared boolean setting selected by its stable host-map key.
///
/// String literals are checked against the declared boolean keys and are
/// completed by editor tooling. When a declaration has a statically visible
/// source name, a literal lookup is warned and can be rewritten directly to
/// `settings.name` or `oldSettings.name`. Computed unknown keys, and computed
/// keys belonging to non-boolean settings, return false. The lookup reads
/// the already-refreshed settings snapshot and does not query the host or
/// allocate.
///
/// # Example
///
/// Select a data-driven split
///
/// ```splitscript
/// let missionKey = "42"
/// let shouldSplit = settings.enabled(missionKey)
/// ```
@intrinsic(SettingsEnabled)
fn enabled(
/// The exact string key declared with `key "..."`, or the setting's
/// source identifier when it has no explicit key.
key: String,
) -> bool;
/// Reports whether a value setting declares the stable host key.
///
/// This distinguishes a known disabled boolean from an unknown key.
/// Literal keys are checked and completed against boolean, choice, and
/// file declarations. A literal naming a declared value is always true and
/// is warned with a semantics-preserving rewrite; use a typed member to read
/// that setting's value instead. Computed strings may still be unknown at
/// runtime. Headings are visual structure rather than values and are not
/// included.
///
/// # Example
///
/// Advance a data cursor even when its known split is disabled
///
/// ```splitscript
/// # state "game.exe" {}
/// # onAttach {
/// # let checkpointKey = "checkpoint"
/// # let checkpointIndex = 0
/// if settings.contains(checkpointKey) {
/// checkpointIndex += 1
/// }
/// # }
/// ```
@intrinsic(SettingsContains)
fn contains(
/// The exact stable host-map key.
key: String,
) -> bool;
}
/// Accesses the attached game process.
///
/// Process operations discover modules, read memory, follow pointers, and scan signatures.
/// Inside [`selectProcess`], this same value refers to the temporary same-name
/// candidate being inspected. Returning `true` promotes that candidate;
/// returning `false` or propagating an error detaches it before provider setup.
///
/// # Example
///
/// Read the matched process identity
///
/// ```splitscript
/// let executableName = process.name()
/// ```
@representation(scalar, i64)
@valueUsage(localVariable, globalVariable)
@capabilities(MemoryReader)
intrinsic type Process {
/// Native addresses are represented by the language's wide address value.
type Address = address;
/// Returns the configured process name that matched during attachment.
///
/// This is the exact candidate written in the state declaration, not a
/// filesystem path. It lets attachment discovery distinguish executable
/// variants without granting file access. Same-name candidates therefore
/// have the same value; use [`Process.path`] or another stable probe inside
/// [`selectProcess`] when they must be distinguished.
///
/// # Example
///
/// Distinguish executable variants
///
/// ```splitscript
/// let executable = process.name()
/// ```
@requires(attachedProcess)
@intrinsic(ProcessName)
fn name() -> String;
/// Returns the executable's host-provided filesystem path.
///
/// The returned value is an absolute path in the runtime's portable,
/// read-only filesystem namespace. Windows paths map by drive, so
/// `C:\Games\game.exe` becomes `/mnt/c/Games/game.exe`. Linux and macOS
/// paths gain the `/mnt` prefix, so `/opt/game/game` becomes
/// `/mnt/opt/game/game`. It can be passed directly to [`File.readAllBytes`]
/// or [`File.readAllText`]. The path is also available while inspecting a
/// candidate in [`selectProcess`].
///
/// # Example
///
/// Inspect the attached executable path
///
/// ```splitscript
/// let executablePath = process.path() else "Unavailable"
/// ```
@requires(attachedProcess)
@intrinsic(ProcessPath)
fn path() -> String!;
/// Waits for the main executable module.
///
/// The module name comes from the exact process candidate that matched
/// during attachment. This is useful for version probes based on the main
/// module's address or mapped size without repeating executable names.
///
/// # Example
///
/// Inspect the main module
///
/// ```splitscript
/// let executable = await process.mainModule()
/// ```
@requires(attachedProcess)
@cancellation(processClose)
@availability(onAttach)
@intrinsic(ProcessMainModule)
fn mainModule() -> async Module;
/// Ignores the current attachment until the process closes.
///
/// This suspension never closes or detaches the process itself and never
/// completes normally. When the process closes, the automatic process
/// lifetime boundary cancels the surrounding [`onAttach`] or
/// [`whileAttached`] invocation before it can resume.
///
/// # Example
///
/// Ignore an unsupported build
///
/// ```splitscript
/// # state "game.exe" {}
/// # onAttach {
/// # let unsupported = true
/// if unsupported {
/// await process.closed()
/// }
/// # }
/// ```
@requires(attachedProcess)
@cancellation(processClose)
@availability(onAttach)
@intrinsic(ProcessClosed)
fn closed() -> async Never;
/// Waits for a process module.
///
/// Suspends the surrounding attachment lifecycle invocation until both
/// module address and size are available.
///
/// # Example
///
/// Wait for a module
///
/// ```splitscript
/// let gameAssembly = await process.module("GameAssembly.dll")
/// ```
@requires(attachedProcess)
@cancellation(processClose)
@availability(onAttach)
@intrinsic(ProcessModule)
fn module(
/// The exact module name.
@literal(string)
name: String,
) -> async Module;
/// Returns a module only when it is already loaded.
///
/// Unlike [`module`], this probe is synchronous and does not wait for a
/// missing optional module to appear. It is useful for selecting layouts
/// that depend on optional platform or mod-loader modules.
///
/// # Example
///
/// Detect an optional Steam module
///
/// ```splitscript
/// # state "game.exe" {}
/// # onAttach {
/// let steam = process.loadedModule("steam_api.dll") else return
/// # print(steam.address)
/// # }
/// ```
@mustUse("the optional loaded module is otherwise discarded")
@requires(attachedProcess)
@intrinsic(ProcessLoadedModule)
fn loadedModule(
/// The exact module name.
name: String,
) -> Module?;
/// Searches mapped memory ranges cooperatively.
///
/// A bounded batch of host memory-range metadata is inspected per update.
/// This does not read the contents of those ranges. When one complete
/// snapshot contains no match, the operation refreshes the mapped ranges
/// and keeps waiting. It completes only after finding the requested size
/// and permissions; closing the attached process cancels it.
///
/// # Example
///
/// Find a readable and writable emulator mapping
///
/// ```splitscript
/// let mapping = await process.findMemoryRange(0x48000, MemoryRangeAccess.ReadWrite)
/// ```
@requires(attachedProcess)
@cancellation(processClose)
@availability(onAttach)
@intrinsic(ProcessFindMemoryRange)
fn findMemoryRange(
/// The exact mapped byte length.
size: u64,
/// Permissions that the range must provide.
access: MemoryRangeAccess,
) -> async MemoryRange;
/// Collects a snapshot of the process's mapped memory ranges.
///
/// The returned GC-owned snapshot is ordered by the host's range index and
/// remains usable after later host mapping changes.
///
/// # Example
///
/// Inspect readable executable mappings
///
/// ```splitscript
/// let ranges = process.memoryRanges()
/// for range in ranges {
/// if range.readable && range.executable {
/// debug print(`executable mapping at {range.address}`)
/// }
/// }
/// ```
@mustUse("the collected memory-range snapshot is otherwise discarded")
@requires(attachedProcess)
@intrinsic(ProcessMemoryRanges)
fn memoryRanges() -> [MemoryRange];
/// Reads a fixed-layout value from process memory.
///
/// The expected [`MemoryReadable`] type selects a fixed-size primitive,
/// integer-represented [`enum`], [`struct`], or fixed-array layout. A
/// synchronous read returns [`T!`]; [`retry`] polls until a value is
/// available and yields `T`. Use an explicit type argument such as
/// `process.read<i32>` when context cannot determine the type. Unknown enum
/// discriminants fail the complete read.
///
/// # Example
///
/// Read a typed value
///
/// ```splitscript
/// # state "game.exe" {}
/// # onAttach {
/// # let player: address = 0x1000
/// let health = process.read<i32>(player.offset(0x20)) else 0
/// # print(health)
/// # }
/// ```
///
/// # Example
///
/// Infer the memory layout from an expected type
///
/// ```splitscript
/// # state "game.exe" {}
/// # onAttach {
/// # let player: address = 0x1000
/// let level: u32 = process.read(player.offset(0x24)) else 0
/// # print(level)
/// # }
/// ```
@requires(attachedProcess)
@intrinsic(ProcessRead)
fn read<T: MemoryReadable>(
/// The target address to read.
address: address,
) -> T!;
/// Follows a pointer path.
///
/// Each signed offset is applied with wrapping address arithmetic before
/// reading the next pointer at the attached executable's automatically
/// detected native width. A failed or null pointer read returns an error;
/// use retry in onAttach to wait for success.
///
/// # Example
///
/// Follow a pointer path
///
/// ```splitscript
/// # state "game.exe" {}
/// # onAttach {
/// # let module = await process.mainModule()
/// let player = retry process.follow(module.address, [0x100, 0x20])
/// # print(player)
/// # }
/// ```
@requires(attachedProcess)
@intrinsic(ProcessFollow)
fn follow(
/// The initial address.
base: address,
/// Signed pointer offsets to follow.
offsets: [i64],
) -> address!;
/// Scans a process-memory range.
///
/// Suspends until the signature is found in the requested range. Large
/// ranges are scanned cooperatively across ticks so the autosplitter keeps
/// yielding to the host.
///
/// # Example
///
/// Scan a memory range
///
/// ```splitscript
/// # state "game.exe" {}
/// # onAttach {
/// # let module = await process.mainModule()
/// let marker = await process.scan(module.address, module.size, sig"48 8B ?? 89")
/// # print(marker)
/// # }
/// ```
@requires(attachedProcess)
@cancellation(processClose)
@availability(onAttach)
@intrinsic(ProcessScan)
fn scan(
/// The beginning of the range.
address: address,
/// The number of bytes to scan.
size: u64,
/// The compiled signature pattern.
signature: Signature,
) -> async address;
/// Scans one complete pass over a process-memory range.
///
/// Unlike [`Process.scan`], this operation does not begin another pass when
/// the signature is absent. It returns [`Some`] with the first matching
/// address, or [`None`] after the entire requested range has been exhausted.
/// The pass remains cooperative across ticks, skips windows that cannot be
/// read, and is cancelled automatically when the process closes.
///
/// Use this when absence is meaningful, such as rejecting an unsupported
/// executable. Use [`Process.scan`] when the signature may appear later and
/// the operation should keep waiting.
///
/// # Example
///
/// Reject an executable without the expected marker
///
/// ```splitscript
/// # state "game.exe" {}
/// # onAttach {
/// # let module = await process.mainModule()
/// let marker = await process.scanOnce(
/// module.address,
/// module.size,
/// sig"48 8B ?? 89",
/// )
/// match marker {
/// Some(address) => print(`marker at {address}`),