Coding

 Reply to this postStart new topic

Displaying Text Using Memory

Deji
post Feb 21 2010, 05:01 PM
Post #1


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Displaying Text Using Memory


This is quite an old trick, but let's explain it as well as possible...


First of all, you must have Sanny Builder's "Case Converting" setting set to "As Is". As so...




SANNY
:DisplayText
0A9F: 2@ = current_thread_pointer
000A: 2@ += 0x10
0A8D: 2@ = read_memory 2@ size 4 virtual_protect 0
000E: 2@ -= @TextMemory
000A: 2@ += 4
0AA5: call 0x588BE0 num_params 4 pop 4 0 0 0 2@
0A93: end_custom_thread

:TextMemory
0605: NOP "Press Ctrl + Yes to bribe cops to leave you alone for a while."
0000: NOP


Here is our code in full.

Now lemme explain it.


0605 is a nopcode.. Which can be simply used to store text in the games memory without performing any action.

So now we can use the memory to display the text. However.. we need to find the right address...

0A9F gets the address of the current thread. We can use this to get the address of other threads, too.

SANNY
000E: 2@ -= @TextMemory


This is the only thing you may have to change. Change it to point to the thread in which your text is stored...


SANNY
000A: 2@ += 4


This is pretty important. It adds 4 bytes to the pointer... Skipping the opcode.

Opcode = 4 bytes.

So that's what we need to skip to get to the string, eh?


SANNY
0AA5: call 0x588BE0 num_params 4 pop 4 0 0 0 2@


0x588BE0 is the address to display a text box in San Andreas with the 1.0 .exe.

2@ is the variable we've used to store our text. So a text box will appear with our entered text.


We can use all the normal gxt and fxt symbols/tricks within the string, such as ~r~ for red text.



Go test.


You can also plain hex strings in your memory thread to avoid having to skip the opcode:

SANNY
:TextMemory
hex
  "This is my hex string" 00
end


00 is our terminator here. Just like the 0000: opcode was last time.




--------------------
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members: