View previous topic :: View next topic |
Author |
Message |
SleepiDreamer Cheater Reputation: 0
Joined: 27 Aug 2021 Posts: 41
|
Posted: Tue Aug 31, 2021 2:16 am Post subject: Pointer string to Address |
|
|
This should be relatively simple, yet I can't seem to find a solution:
I want to go from string
Code: | '[Minecraft.Windows.exe+4030538]+3CA51F0' |
To the address it is pointing to (which obviously changes in each new instance of the game)
And store it in a local variable.
My main problem is that I can convert it to a hex using
Code: | '0x'..(toHex(getAddress(address1)) |
But that's simply a string, which cannot be used for most celua functions.
_________________
Hope you're having a great day! |
|
Back to top |
|
|
Birdi Expert Cheater Reputation: 0
Joined: 08 Jun 2020 Posts: 122 Location: Migrating
|
Posted: Tue Aug 31, 2021 2:41 am Post subject: |
|
|
I believe you can just use Code: |
Ptr = '0x'..(toHex(getAddress(address1))
Var = tonumber(Ptr) | and it would work.
_________________
Trying to learn!
Add me on Discord if you want hands-on help: Birdi#0007 |
|
Back to top |
|
|
SleepiDreamer Cheater Reputation: 0
Joined: 27 Aug 2021 Posts: 41
|
Posted: Tue Aug 31, 2021 2:51 am Post subject: |
|
|
This won't really help me:
If I use it on the pointer string, it prints nothing
If I use it on what I sent, it doesn't work
If I use it on the address without 0x, it converts to a string.
_________________
Hope you're having a great day! |
|
Back to top |
|
|
Birdi Expert Cheater Reputation: 0
Joined: 08 Jun 2020 Posts: 122 Location: Migrating
|
Posted: Tue Aug 31, 2021 2:56 am Post subject: |
|
|
Try omitting the '0x'.. concatenation. Just get the hex of the address and run it through tonumber().
Lua should just convert string literals to hex like that, afaik.
If you're really stuck you can just push it as an address of a memrec and pull it via memrec.address so it's absolutely literal, but you shouldn't have to.
_________________
Trying to learn!
Add me on Discord if you want hands-on help: Birdi#0007 |
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1055 Location: 0x90
|
Posted: Tue Aug 31, 2021 2:59 am Post subject: |
|
|
You haven't posted your "toHex" function; however, it should be something like this:
Code: |
function toHex(s)
if s ~= nil then
local s = string.format("0x%X", s)
return s
end
end
|
Then you can use it like this example:
Code: |
address = '0xDEADBEEF'
local pointer = toHex(getAddressSafe(address))
print(pointer)
|
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Tue Aug 31, 2021 3:07 am Post subject: |
|
|
Most of the CE Lua functions can take the first string as an address. Why do you need to convert it? If you aren't doing math with the number, I don't think you need to convert it. And why do you need to have it as hex, and not just a number?
_________________
|
|
Back to top |
|
|
SleepiDreamer Cheater Reputation: 0
Joined: 27 Aug 2021 Posts: 41
|
Posted: Tue Aug 31, 2021 3:21 am Post subject: |
|
|
I'll just post all my code I have rn:
Code: | function toHex(s)
local s = string.format("%X", s)
return s
end
function toAddress(ad)
local ad = '0x'..ad
return ad
end
local address1 = 0x215A3AA5218
addresses = {0x215A3AA5218, 0x215A3AA4F0, 0x215A3AA54EC}
--writeBytes(address, 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90)
-- 0x90 = nop, here it writes 5 nop instructions. Just make sure to delimit each byte instruction with a comma for however many you require to write. Although, should it be a large amount of bytes, I recommend you pass a table that holds the byte data instead.
function findAddress(address, iter)
debug_setBreakpoint(address, 4, bptWrite, function()
print(string.format("%X: %X accessed %X", iter, RIP-8, address))
debug_continueFromBreakpoint(co_run)
debug_removeBreakpoint(address)
NOP(RIP-8)
return 0
end)
end
function NOP(address)
writeBytes(address, 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90)
end
for listCount = 1, #addresses do
findAddress(address1+listCount*4, listCount)
end
|
In the list addresses I have all the addresses I want to NOP. If I use addresses = {'Minecraft.Windows.exe+4030538+3CA51F0'}, it simply doesn't do anything.
_________________
Hope you're having a great day! |
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Tue Aug 31, 2021 4:21 am Post subject: |
|
|
Your for loop uses math on the address, so it needs to be a number. Just use getAddress and don't convert it to a hex string. And your findAddress function assumes the address is a number.
_________________
|
|
Back to top |
|
|
SleepiDreamer Cheater Reputation: 0
Joined: 27 Aug 2021 Posts: 41
|
Posted: Tue Aug 31, 2021 4:46 am Post subject: |
|
|
thank you guys so much!
_________________
Hope you're having a great day! |
|
Back to top |
|
|
|