This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Getting fprintf() to work. At all.

Greetings -

The (custom) device I'm working on has multiple possible serial interfaces. I thought "Hey, I've written entire operating systems before, I should just intercept "open()" and then exploit stdio and have it do my evil bidding!". Mostly on account of retarget.c allows _write() to be re-swizzled.

Except it would appear that something like

FILE *some_other_way_of_chatting;
some_other_way_of_chatting = fdopen(my_fake_file_descriptor, "rw");

doesn't produce a (FILE *) object that gets routed through _write(). Which makes things rather pointless.

I did find dprintf() and I may do something with it, but I'd really like to use stdio. Because I'm weird that way.

Related