 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Loset Cheater
Reputation: 0
Joined: 18 Apr 2015 Posts: 34
|
Posted: Wed Aug 12, 2020 5:52 pm Post subject: How do you create a System.String in mono? |
|
|
I need to use Mono.invoke on a method that accepts a String,
A string is not some random "textgoeshere", It's an object I need to create an instance of and send to the proper method,
So I need to create a new instance of the class System.String, But not sure how to do it.
I tried to allocate it myself using allocMemory, I then tried to use the System.String.ctor method to invoke it
| Code: | local test = mono_findMethod('',"String",".ctor");
local alloc = allocateMemory(100);
writeString(alloc,"testing",true)
local resda = mono_invoke_method(1, test,nil , {{type = vtPointer, value = alloc}}) |
anyways I tried both using vtString as type and using some "random string"
or whatever nothing seems to give me back a valid pointer to the instance.
ignore var names was 2am and I wanted to do final tests before bed. |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25840 Location: The netherlands
|
Posted: Wed Aug 12, 2020 10:52 pm Post subject: |
|
|
tried
| Code: |
mono_invoke_method(nil, method, classInstance, {{type = vtPointer, value = 'testing'}})
|
do you have the proper method and do you have a proper address of the class object? _________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Loset Cheater
Reputation: 0
Joined: 18 Apr 2015 Posts: 34
|
Posted: Thu Aug 13, 2020 2:54 am Post subject: |
|
|
| Code: | local stringConstructor = mono_findMethod('',"String",".ctor");
local newStr = mono_invoke_method(nil, stringConstructor,nil , {{type = vtPointer, value = "myStr"}})
print("constructor is: ", stringConstructor)
print("string PTR is:", newStr);
|
output:
| Code: |
constructor is: 140151728
string PTR is:
|
so string always comes out empty/nil, I dont have a class instance to invoke this method on because I'm trying to create a new instance by invoking the constructor, But I also tried using the class pointer as the instance.
Also could be that I don't have the right method because String class has 6 constructor overloads, I aint sure how to select a specific one between them |
|
| Back to top |
|
 |
Bloodybone Newbie cheater
Reputation: 0
Joined: 07 Dec 2016 Posts: 21 Location: Germany
|
Posted: Mon Aug 17, 2020 2:47 pm Post subject: |
|
|
Maybe try this
| Code: | local function CreateMonoString(s)
return executeCodeEx(1,1000,getAddress("mono_string_new"),{type=0,value=mono_enumDomains()[1]},{type=3,value=s})
end
local mstring = CreateMonoString("Test String")
if (targetIs64Bit()) then
print(string.format("String Instance:0x%X",mstring))
print("String Length:"..readInteger(mstring+0x10))
print("String in UTF16 Form:"..readString(mstring+0x14,readInteger(mstring+0x10)*2,true))
local s = ""
local bytesastable = readBytes(mstring+0x14,readInteger(mstring+0x10)*2,true)
for _,v in ipairs(bytesastable) do
s = string.format("%s0x%X ",s,v)
end
print("String in Byte Form:"..s)
else
print(string.format("String Instance:0x%X",mstring))
print("String Length:"..readInteger(mstring+8))
print("String in UTF16 Form:"..readString(mstring+0xC,readInteger(mstring+8)*2,true))
local s = ""
local bytesastable = readBytes(mstring+0xC,readInteger(mstring+8)*2,true)
for _,v in ipairs(bytesastable) do
s = string.format("%s0x%X ",s,v)
end
print("String in Byte Form:"..s)
end |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|