Why does inside of WriteConsole_Hook
the code doesn't recognize if (ffmpeg_struct.ffmpeg_console) {
as true
?
It has been previously set true inside of CreateProcessW_Hook
function.
struct ffmpeg {
bool ffmpeg_console;
} ffmpeg_struct;
BOOL __stdcall CreateProcessW_Hook(
LPCWSTR lpApplicationName,
LPWSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory,
LPSTARTUPINFOW lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation
)
{
BOOL rt = CreateProcessW(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
if (lpCommandLine)
if(wcsstr(lpCommandLine, L"ffmpeg.exe") != NULL)
{
Sleep(100);
ffmpeg_struct.ffmpeg_console = true;
DWORD pid = lpProcessInformation->dwProcessId;
//........
}
return rt;
}
BOOL __stdcall WriteConsole_Hook(
HANDLE hConsoleOutput,
const VOID* lpBuffer,
DWORD nNumberOfCharsToWrite,
LPDWORD lpNumberOfCharsWritten,
LPVOID lpReserved
)
{
const wchar_t* string = reinterpret_cast<const wchar_t*>(lpBuffer);
if (ffmpeg_struct.ffmpeg_console) {
//....
}
return WriteConsoleW(hConsoleOutput, lpBuffer, nNumberOfCharsToWrite, lpNumberOfCharsWritten, lpReserved);
}