BL Coding Anyone found a way to output to the developper console ?

  • 主题发起人 Kasper_OmsK
  • 开始时间

正在查看此主题的用户

Kasper_OmsK

Hi there,

I've been fiddling around with the games c# assemblies today and still didn't find a way to log something directly to the dev console (using the developper mod).

I've found the wrapper methods around Imgui funcitons and managed to display arbitrary debug windows. (TallWorlds.Engine.Imgui)

I've found how to add custom console commands (by adding the attribute [CommandLineFunctionality.CommandLineArgumentFunction])

And I did find the MBDebug class which seems promising but I'm unable to find any method that display something the console.
MBDebug.ConsolePrint(), WriteDebugLineOnScreen(), Print() etc do not do anything for some reasons.
I've also checked if they log to the standard output Console by calling AllocConsole but no...

Thanks in advance and sorry for my english, I'm really tired lol.
 
He means the actual developer console.

@Kasper_OmsK the developer console is enabled via Rgl.dll, maybe the answer lies in there?
Indeed, seems like a good idea...I saw the dll at first but I ignored it because I'm not great at reading assembly code.
Then I totally forgot about it...
Thanks anyway, I'll be looking in there
 
点赞 0
I've looked into this a bit more and I'm not quite sure if it's possible. Adding your own command is pretty trivial and could be useful for some mods, but using the RGL console for debugging seems like a lost cause - as of now.

By doing this, you can add your own commands;
插入代码块:
[CommandLineFunctionality.CommandLineArgumentFunction("print_message", "debug")]
public static string DebugMessage(List<string> strings)
{
     return string.Join(" ", strings);
}

Thus you could for example type "debug.print_message Hello World" and it would print "Hello World" to the console. You can also execute actual code in there - and whatever string you return will be shown in the console.

The CommandLineFunctionality class has a method called CallFunction() which I hoped was what we needed but sadly it's not. It simply makes it so you can call a command-line function you've added and returns the string. It will not make the message show up in the RGL console.

We'd probably have to dig into Rgl.dll to figure out how and if we can do this, but that file seems to be obfuscated and I'm not too experienced in reverse engineering such so I'll just leave it at this.

Maybe someone with some more experience and know-how could figure this out :xf-smile:
 
点赞 0
I've looked into this a bit more and I'm not quite sure if it's possible. Adding your own command is pretty trivial and could be useful for some mods, but using the RGL console for debugging seems like a lost cause - as of now.

By doing this, you can add your own commands;
插入代码块:
[CommandLineFunctionality.CommandLineArgumentFunction("print_message", "debug")]
public static string DebugMessage(List<string> strings)
{
     return string.Join(" ", strings);
}

Thus you could for example type "debug.print_message Hello World" and it would print "Hello World" to the console. You can also execute actual code in there - and whatever string you return will be shown in the console.

The CommandLineFunctionality class has a method called CallFunction() which I hoped was what we needed but sadly it's not. It simply makes it so you can call a command-line function you've added and returns the string. It will not make the message show up in the RGL console.

We'd probably have to dig into Rgl.dll to figure out how and if we can do this, but that file seems to be obfuscated and I'm not too experienced in reverse engineering such so I'll just leave it at this.

Maybe someone with some more experience and know-how could figure this out :xf-smile:

I've dig into rgl.dll and FairyTale.Library.dll. (The former uses fonctions and methods from the latter)
I'm pretty sure I found the function that output to the console, sadly, it is not exported so you can't import it into another codebase. (At least not without modifying the dll (and still then i'm not conviced it's possible, but I'm no way near an expert in that domain so anyone feel free to correct me))

To expand on what you said about using CommandLineFunctionality, I also thought of "hacking" this system to output strings to the console.
I found that rgl.dll defines an ExecuteCommand() function. And it is exported from the dll. So you could create a commandLineFunc that only returns the string you give it as parameters, import ExecuteCommand() from rgl.dll, and invoke that command whenever you want to output something. That's kind of hacky but it should work.
The thing though, is that ExecuteCommand() uses a custom string type (rglString if I remember correctly) to identify a command. So it's not as simple as just importing it, you'd have to somehow create a "rglString" in c#, which I'm not really sure how one would achieve.

That being said, I agree it does not seem like the effort is worthwhile. For now, calling AllocConsole() and just using Console.Writeline() is sufficient.

PS : If anyone wants to dig further into that, I could give them the adresses of the above mentionned functions/method I found interesting.
I don't know them off the top of my head, but if anyone is interested, feel free to ask.
 
最后编辑:
点赞 0
后退
顶部 底部