reading/setting of a memory location

I’m new to scripting, and hope that this can be done in AppleScript.

Given a memory location , e.g. 355303368 or 422170468.

How would I find and set the value of the byte stored in that location?

Similar to old BASIC’s PEEK or POKE.

Thank you in advance.

Even if you don’t respond, thank you to everyone who reads this for helping newbies like me.
I really appreciate the help and the site.

I could be wrong, but I don’t think that’s possible in Unix. It would be a security problem if you could do it.

In short, yes such operations exist (for other languages), but you probably do not want them unless you are writing device drivers (and no one would do that in AppleScript!).

Something like PEEK and POKE is possible in certain languages (ones that provide lower-level access, like C and company), but it is not terribly useful in modern operating systems. These days OSes use hardware enforced memory protection, configured by the kernel, to prevent programs from stomping on (or even reading from) each other’s memory regions. Besides process isolation, the kernel usually protects access to other interesting regions (like memory-mapped IO regions for things like sound and graphics hardware and other devices on peripheral busses).

Also, not every byte of the address space in a process is actually “mapped” (i.e. acessible and backed by some bit or memory or IO device). The most likely result of even a PEEK-like operation to a random address is that the offending process will be sent a SIGSEGV or SIGBUS signal, both of which (by default) cause the process crash with an optional “core dump”. Those signals are the kernel’s way of telling the process that it has “stepped out bounds”. Usually when this happens it is due to a bug in the program (thus the crash with core dump).

I have heard that there are Windows API functions act as Peek or Poke and can be used by higher level languages to speed up certain string functions by writing directly to the string’s memory locations (or to the pointer for a variable’s name).

It sounds like I’m not going to be doing that with AppleScript.

If there are, that would partly explain why there are so many Windows viruses and bots.