Now that you know how to trace Media Foundation and analyze those traces to figure out what Media Foundation is doing, the next step is to figure out what your own code is doing. That means adding traces for MFTrace to your code. The simplest way to add traces is to use the OutputDebugString function. OutputDebugString takes a single string as input:void WINAPI OutputDebugString(
__in_opt LPCTSTR lpOutputString
);
Usually this function sends this string to a debugger. But when MFTrace traces a process, it hooks this function and adds the string to its log. To make the OutputDebugString look more like printf, we can write a small wrapper which formats strings:#include <windows.h>
#include <strsafe.h>void CDECL Trace(PCSTR pszFormat, ...)
{
CHAR szTrace[1024]; va_list args;
va_start(args, pszFormat);
(void) StringCchVPrintfA(szTrace, ARRAYSIZE(szTrace), pszFormat, args);Read more: Media Foundation Team Blog
__in_opt LPCTSTR lpOutputString
);
Usually this function sends this string to a debugger. But when MFTrace traces a process, it hooks this function and adds the string to its log. To make the OutputDebugString look more like printf, we can write a small wrapper which formats strings:#include <windows.h>
#include <strsafe.h>void CDECL Trace(PCSTR pszFormat, ...)
{
CHAR szTrace[1024]; va_list args;
va_start(args, pszFormat);
(void) StringCchVPrintfA(szTrace, ARRAYSIZE(szTrace), pszFormat, args);Read more: Media Foundation Team Blog
0 comments:
Post a Comment