This is the AMP version of this page.
If you want to load the real page instead, click this text.

Help! Can't create a string

libModz

Platinian On Fire
I used to create strings in the previous version of the game I'm modding using this method...



private unsafe string CreateString(sbyte* value)
{
return null;
}




But in the latest update they seem to have removed it so now all the createstring methods have multiple parameters. Like

CreateString(char* value)
CreateString(sbyte* value, int startIndex, int length)
 
Last edited:
 
I'm also having the same problem. These are the only CreateString available and idk which one to use

// RVA: 0x23A09D4 Offset: 0x23A09D4 VA: 0x23A09D4
private string CreateString(sbyte* value, int startIndex, int length) { }

// RVA: 0x23A23C4 Offset: 0x23A23C4 VA: 0x23A23C4
private string CreateString(char* value, int startIndex, int length) { }

// RVA: 0x23A23D4 Offset: 0x23A23D4 VA: 0x23A23D4
private string CreateString(char[] val, int startIndex, int length) { }

// RVA: 0x2397244 Offset: 0x2397244 VA: 0x2397244
private string CreateString(char[] val) { }

// RVA: 0x23A23E4 Offset: 0x23A23E4 VA: 0x23A23E4
private string CreateString(char c, int count) { }

// RVA: 0x23A23F0 Offset: 0x23A23F0 VA: 0x23A23F0
private string CreateString(sbyte* value, int startIndex, int length, Encoding enc) { }

// RVA: 0x23A2418 Offset: 0x23A2418 VA: 0x23A2418
private string CreateString(ReadOnlySpan<char> value) { }
 
Use the first one...

private string CreateString(sbyte* value, int startIndex, int length) { }
 
Solution, use this method and struct...

C#:
private string CreateString(sbyte* value, int startIndex, int length) { }

1) Create a new file in your includes folder called something like mono.h or string.h then paste this code inside...

C++:
typedef struct _monoString
{
    void *klass;
    void *monitor;
    int length;
    char chars[1];

    int getLength()
    {
        return length;
    }

    char *getChars()
    {
        return chars;
    }
} monoString;

monoString *CreateString(const char *str)
{
    monoString *(*CreateString)(void *instance, const char *str, int start, int length) = (monoString * (*)(void *, const char *, int, int)) getAbsoluteAddress(0xOFFSET); //offset here
    int length = (int)strlen(str);
    return CreateString(NULL, str, 0, length);
}

2) Now you can use it like in these examples...
C++:
monoString *(*old_Test)(void *instance);
monoString *Test(void *instance) {
    if(instance!=nullptr) {
        return CreateString("Test");
    }
    return old_Test(instance);
}


C++:
void (*old_Update)(void *instance);
void Update(void *instance) {
    if(instance!=nullptr) {
        set_NickName(instance, (CreateString("Test")));
    }
    old_Update(instance);
}
 
Made a typo in struct, here it is fixed...

C++:
typedef struct _monoString
{
    void *klass;
    void *monitor;
    int length;
    char chars[1];

    int getLength()
    {
        return length;
    }

    char *getChars()
    {
        return chars;
    }
} monoString;

monoString *CreateString(const char *str)
{
    monoString *(*CreateString)(void *instance, const char *str, int start, int length) = (monoString * (*)(void *, const char *, int, int)) getAbsoluteAddress("libil2cpp.so", 0xOFFSET); //offset here
    int length = (int)strlen(str);
    return CreateString(NULL, str, 0, length);
}