From 571fc8cc99bfe33d362dfb7598eccb23a6bd1caf Mon Sep 17 00:00:00 2001 From: Benjamin DELPY Date: Wed, 14 Jul 2021 17:37:12 +0200 Subject: [PATCH] [fix] mimikatz as DLL, new console is not mandatory --- mimikatz/mimikatz.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/mimikatz/mimikatz.c b/mimikatz/mimikatz.c index 8eeee25..06c50c7 100644 --- a/mimikatz/mimikatz.c +++ b/mimikatz/mimikatz.c @@ -260,24 +260,23 @@ void CALLBACK mimikatz_dll(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int n { int argc = 0; wchar_t ** argv; - if(AllocConsole()) - { + + AllocConsole(); #pragma warning(push) #pragma warning(disable:4996) - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); - freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); + freopen("CONIN$", "r", stdin); #pragma warning(pop) - if(lpszCmdLine && lstrlenW(lpszCmdLine)) + if(lpszCmdLine && lstrlenW(lpszCmdLine)) + { + if(argv = CommandLineToArgvW(lpszCmdLine, &argc)) { - if(argv = CommandLineToArgvW(lpszCmdLine, &argc)) - { - wmain(argc, argv); - LocalFree(argv); - } + wmain(argc, argv); + LocalFree(argv); } - else wmain(0, NULL); } + else wmain(0, NULL); } #endif