[Tutorial] Read / write memory

Short tutorial.
Hello , i'm not good with tutorials , but i tried xD
Maybe someone can explain better , i'm sure a lot peoples don't know how to do that.

So What is memory??
By wiki:
Memory is the faculty of the brain by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future action.

How we read / write memory??

Examples when need read / write samp memory with pointers.:
With one offset
PHP:
 // use
0AB1: call_scm_func @example params 0
PHP:
 // Read
:EXAMPLE
0AA2: 0@ = "samp.dll" // get samp.dll adr and store to 0@
0@ += 0x2AC9E0 /// samp.dll adr + pointer = full pointer
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 /// read memory to get full pointer
0@ += 0x28 // adding offset to full pointer
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 // read memory to get final results
0AD1: show_formatted_text_highpriority "%d" time 2000 0@ // here we add debug / logger  to see what we get
0AB2: 0
PHP:
 // write
:EXAMPLE
0AA2: 0@ = "samp.dll" // get samp.dll adr and store to 0@
0@ += 0x2AC9E0 /// samp.dll adr + pointer = full pointer
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 /// read mem to get full pointer
0@ += 0x28 // full pointer + offset
0A8C: write_memory 0@ size 4 value 1 virtual_protect 0  // value is what we wanna write
0AB2: 0

With two offset
PHP:
 // use
Use: 0AB1: call_scm_func @example params 0
PHP:
 // read
:EXAMPLE
0AA2: 0@ = "samp.dll" // get samp.dll adr and store to 0@
0@ += 0x2AC9E0 /// samp.dll adr + pointer = full pointer
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 /// read memory to get full pointer
0@ += 0x28 // adding offset to full pointer
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 // read memory to get adr of full pointer + offset
0@ += 0xE40 // adding offset to full pointer + offset
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 // read last time to get results
0AD1: show_formatted_text_highpriority "%d" time 2000 0@ // here we can add debug / logger  to see what we get
0AB2: 0
PHP:
 // write
:EXAMPLE
0AA2: 0@ = "samp.dll" // get samp.dll adr
0@ += 0x2AC9E0 /// samp.dll adr + pointer = full pointer
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 /// read memory to get full pointer
0@ += 0x28 // adding offset to full pointer
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 // read memory to get adr of full pointer + offset
0@ += 0xE40 // adding offset to full pointer + offset
0A8C: write_memory 0@ size 4 value 1 virtual_protect 0  // value is what we wanna write
0AB2: 0

How it should be in code?
PHP:
{$CLEO .cs}

0000: NOP

wait 10000 // wait until samp is ready

while true
wait 0

if
0AB0: 90 // Z KEY
then
    0AB1: @EXAMPLE params 0
end

end


:EXAMPLE
0AA2: 0@ = "samp.dll" // get samp.dll adr and store to 0@
0@ += 0x2AC9E0 /// samp.dll adr + pointer = full pointer
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 /// read memory to get full pointer
0@ += 0x28 // adding offset to full pointer
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 // read memory to get adr of full pointer + offset
0@ += 0xE40 // adding offset to full pointer + offset
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 // read last time to get results
0AD1: show_formatted_text_highpriority "%d" time 2000 0@ // here we can add debug / logger  to see what we get
0AB2: 0

More info about opcode 0AB1:
http://ugbase.eu/index.php?threads/tutorial-0ab1-call_scm_function.10880/
 
Last edited:
Top