Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hope to have command to save log, not only GUI #2961

Closed
RachelWealth opened this issue Oct 16, 2022 · 8 comments
Closed

hope to have command to save log, not only GUI #2961

RachelWealth opened this issue Oct 16, 2022 · 8 comments
Labels
enhancement The issue requests an enhancement to an existing feature. feature The issue requests a new feature. good first issue The issue has a limited scope and is good for new developers.

Comments

@RachelWealth
Copy link

Feature type

Other

Describe the feature

As command can help for third-party programme transfer

@RachelWealth RachelWealth added the feature The issue requests a new feature. label Oct 16, 2022
@utkonos
Copy link

utkonos commented Oct 27, 2022

Yes, this would be a very helpful feature! Log control commands:

logsave [arg1]
this would save the log to a text file with a timestamp filename like the GUI does. If the optional arg1 is provided, that string is used as the filename or path to save to.

logredir [arg1]
this would enable log redirection to a timestamp filename like the above. if the optional arg1 is provided, that string would be used as the filename or path for the redirected log data.

logredirstop
stops log redirection

The first one would be the must have, and the second and third are nice to haves.

@ElvisBlue
Copy link

Well this cound be implement by writing a plugin. x64dbg provide _plugin_registercommand API to add your custom command.

@mrexodia
Copy link
Member

mrexodia commented Oct 28, 2022 via email

@utkonos
Copy link

utkonos commented Oct 28, 2022

why do you need this functionality?

The use case here is in a script. At the end of the script, it would be very useful to be able to run logsave right before ret. Another location would be in error handling also just before a ret and after a msg.

The two nice to haves: logredir and logredirstop would have a similar purpose: in scripts. One could start and stop logging during certain parts of the script where logging to a file would be useful such as during a trace or when gathering network indicators or other other specific parts of a script.

It might be easier to have a command that appends to a custom log file…

Yes, having logsave and/or the other two is just an idea for how to solve the use case. I would be happy with any feature that could solve the use case.

@torusrxxx torusrxxx added enhancement The issue requests an enhancement to an existing feature. good first issue The issue has a limited scope and is good for new developers. labels Nov 26, 2022
@torusrxxx
Copy link
Member

The log redirection and saving doesn't have an external API yet, mostly because it is handled by GUI, not DBG.

@utkonos
Copy link

utkonos commented Dec 4, 2022

I asked ChatGPT to write this plugin. Does this look correct?

#include <cstdio>
#include <cstring>

#include "x64dbg.h"

// Plugin information
const char* plugin_name = "Log to File";
const char* plugin_version = "1.0.0";

// Console command to enable logging to a file
void cmd_logtofile(int argc, char* argv[])
{
    // Check if the correct number of arguments was provided
    if (argc != 2)
    {
        dputs("Usage: logtofile [filename]");
        return;
    }

    // Get the filename from the command arguments
    const char* filename = argv[1];

    // Open the file for writing
    FILE* file = fopen(filename, "w");
    if (!file)
    {
        dprintf("Failed to open file %s for writing\n", filename);
        return;
    }

    // Enable logging to the file
    GuiSetLogFile(file);
    dprintf("Logging enabled to file %s\n", filename);
}

// Initialize the plugin
extern "C" __declspec(dllexport) bool pluginit(PLUG_INITSTRUCT* initStruct)
{
    // Register the console command
    plugin_registercommand(plugin_name, "logtofile", cmd_logtofile);

    // Return success
    return true;
}

// Plugin cleanup
extern "C" __declspec(dllexport) bool plugstop()
{
    // Return success
    return true;
}

// Plugin information
extern "C" __declspec(dllexport) char* plugin_info()
{
    // Format the plugin information string
    static char info[256];
    sprintf_s(info, "%s v%s by %s", plugin_name, plugin_version, "Assistant");

    // Return the plugin information
    return info;
}

@Bluefissure
Copy link
Contributor

I asked ChatGPT to write this plugin. Does this look correct?
...

There's no GuiSetLogFile API exposed in the plugin SDK, ChatGPT is easily getting illusion to make something looks good but actually doesn't work.

I think the main issue is to provide a signal of saveSlot() just like clearLog().

It doesn't look to be very hard to do, @mrexodia is there a new contributing doc? I found the one from readme and wiki is returning 404. Or can I follow the compile instructions in wiki pages (which is still VS2013 and QT5.6.3)?

@mrexodia
Copy link
Member

Thanks for the heads-up, I moved the contributing document to the .github folder, but clearly forgot to update the links. The compile guide on the wiki is still correct and we indeed use VS2013 and Qt 5.6.3. This is definitely a point of friction and I plan to switch to cmkr soon, to at least allow people with newer VS/Qt versions to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue requests an enhancement to an existing feature. feature The issue requests a new feature. good first issue The issue has a limited scope and is good for new developers.
Projects
None yet
Development

No branches or pull requests

6 participants