0

I'm writing a pin tool (Windows, x64, PIN 3.18), and it starts like this:

int main(int argc, char *argv[]) {
    std::cerr << "Initializing..." << std::endl;

This is how I'm calling the tool: C:\pin\intel64\bin\pin -t C:\pin\source\tools\MyPinTool\x64\Release\MyPinTool.dll -- mspaint.exe

Nothing is ever printed to stderr. fprintf(stderr, ...) also prints nothing. stdout seems to behave in the same way. The tool itself works, and if I instead fprintf to a file, that works as well. It doesn't seem to me like I'm deviating from the docs examples.

I also searched in the docs for stuff related to output with no luck.

Why is nothing getting printed?

1 Answer 1

0

The pintool is a DLL which is injected into the target process and runs in its context. Since mspaint is a GUI program, it does not have a console to which print output could go. You have the following options:

  1. Change mspaint.exe subsystem to console so that a console window is allocated on startup.
  2. Call AllocConsole() in your pintool and set up stdout/stderr to go there (not sure about the details here).
  3. Use an explicitly opened log file for output instead of stderr.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.