Fix signatures of some callback functions (#871)

* Fix signatures of callback functions

* Fix calling conventions of callback functions

* Remove now-unnecessary casts of pointers to callback functions
This commit is contained in:
Bartosz Brachaczek 2019-05-17 22:32:51 +02:00 committed by msftbot[bot]
parent fd98145af2
commit 73ad742c12
29 changed files with 52 additions and 49 deletions

View file

@ -80,7 +80,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
_outputThreadId = (DWORD)-1;
_hOutputThread = CreateThread(nullptr,
0,
(LPTHREAD_START_ROUTINE)StaticOutputThreadProc,
StaticOutputThreadProc,
this,
0,
&_outputThreadId);
@ -131,7 +131,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
CloseHandle(_piConhost.hProcess);
}
DWORD ConhostConnection::StaticOutputThreadProc(LPVOID lpParameter)
DWORD WINAPI ConhostConnection::StaticOutputThreadProc(LPVOID lpParameter)
{
ConhostConnection* const pInstance = (ConhostConnection*)lpParameter;
return pInstance->_OutputThread();

View file

@ -39,7 +39,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
PROCESS_INFORMATION _piConhost;
bool _closing;
static DWORD StaticOutputThreadProc(LPVOID lpParameter);
static DWORD WINAPI StaticOutputThreadProc(LPVOID lpParameter);
DWORD _OutputThread();
};
}

View file

@ -60,7 +60,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
_outputThreadId = (DWORD)-1;
_hOutputThread = CreateThread(nullptr,
0,
(LPTHREAD_START_ROUTINE)StaticOutputThreadProc,
StaticOutputThreadProc,
this,
0,
&_outputThreadId);
@ -222,7 +222,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
}
DWORD ConptyConnection::StaticOutputThreadProc(LPVOID lpParameter)
DWORD WINAPI ConptyConnection::StaticOutputThreadProc(LPVOID lpParameter)
{
ConptyConnection* const pInstance = (ConptyConnection*)lpParameter;
return pInstance->_OutputThread();

View file

@ -39,7 +39,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
HANDLE _hOutputThread;
PROCESS_INFORMATION _piClient;
static DWORD StaticOutputThreadProc(LPVOID lpParameter);
static DWORD WINAPI StaticOutputThreadProc(LPVOID lpParameter);
void _CreatePseudoConsole();
DWORD _OutputThread();
};

View file

@ -129,7 +129,7 @@ DoScroll:
Scrolling::s_ScrollIfNecessary(ScreenInfo);
}
void CALLBACK CursorTimerRoutineWrapper(_In_ PVOID /* lpParam */, _In_ BOOL /* TimerOrWaitFired */)
void CALLBACK CursorTimerRoutineWrapper(_In_ PVOID /* lpParam */, _In_ BOOLEAN /* TimerOrWaitFired */)
{
// Suppose the following sequence of events takes place:
//
@ -192,7 +192,7 @@ void CursorBlinker::SetCaretTimer()
bRet = CreateTimerQueueTimer(&_hCaretBlinkTimer,
_hCaretBlinkTimerQueue,
(WAITORTIMERCALLBACKFUNC)CursorTimerRoutineWrapper,
CursorTimerRoutineWrapper,
this,
dwEffectivePeriod,
dwEffectivePeriod,

View file

@ -51,7 +51,7 @@ PtySignalInputThread::~PtySignalInputThread()
// - lpParameter - A pointer to the PtySignalInputTHread instance that should be called.
// Return Value:
// - The return value of the underlying instance's _InputThread
DWORD PtySignalInputThread::StaticThreadProc(_In_ LPVOID lpParameter)
DWORD WINAPI PtySignalInputThread::StaticThreadProc(_In_ LPVOID lpParameter)
{
PtySignalInputThread* const pInstance = reinterpret_cast<PtySignalInputThread*>(lpParameter);
return pInstance->_InputThread();
@ -175,7 +175,7 @@ HRESULT PtySignalInputThread::Start() noexcept
hThread = CreateThread(nullptr,
0,
(LPTHREAD_START_ROUTINE)PtySignalInputThread::StaticThreadProc,
PtySignalInputThread::StaticThreadProc,
this,
0,
&dwThreadId);

View file

@ -25,7 +25,7 @@ namespace Microsoft::Console
[[nodiscard]]
HRESULT Start() noexcept;
static DWORD StaticThreadProc(_In_ LPVOID lpParameter);
static DWORD WINAPI StaticThreadProc(_In_ LPVOID lpParameter);
// Prevent copying and assignment.
PtySignalInputThread(const PtySignalInputThread&) = delete;

View file

@ -90,7 +90,7 @@ HRESULT VtInputThread::_HandleRunInput(_In_reads_(cch) const byte* const charBuf
// - lpParameter - A pointer to the VtInputThread instance that should be called.
// Return Value:
// - The return value of the underlying instance's _InputThread
DWORD VtInputThread::StaticVtInputThreadProc(_In_ LPVOID lpParameter)
DWORD WINAPI VtInputThread::StaticVtInputThreadProc(_In_ LPVOID lpParameter)
{
VtInputThread* const pInstance = reinterpret_cast<VtInputThread*>(lpParameter);
return pInstance->_InputThread();
@ -167,7 +167,7 @@ HRESULT VtInputThread::Start()
hThread = CreateThread(nullptr,
0,
(LPTHREAD_START_ROUTINE)VtInputThread::StaticVtInputThreadProc,
VtInputThread::StaticVtInputThreadProc,
this,
0,
&dwThreadId);

View file

@ -26,7 +26,7 @@ namespace Microsoft::Console
[[nodiscard]]
HRESULT Start();
static DWORD StaticVtInputThreadProc(_In_ LPVOID lpParameter);
static DWORD WINAPI StaticVtInputThreadProc(_In_ LPVOID lpParameter);
void DoReadInput(const bool throwOnFail);
private:

View file

@ -214,7 +214,7 @@ NTSTATUS RemoveConsole(_In_ ConsoleProcessHandle* ProcessData)
return Status;
}
DWORD ConsoleIoThread();
DWORD WINAPI ConsoleIoThread(LPVOID lpParameter);
void ConsoleCheckDebug()
{
@ -258,7 +258,7 @@ HRESULT ConsoleCreateIoThreadLegacy(_In_ HANDLE Server, const ConsoleArguments*
ServerInformation.InputAvailableEvent = ServiceLocator::LocateGlobals().hInputEvent.get();
RETURN_IF_FAILED(g.pDeviceComm->SetServerInformation(&ServerInformation));
HANDLE const hThread = CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)ConsoleIoThread, 0, 0, nullptr);
HANDLE const hThread = CreateThread(nullptr, 0, ConsoleIoThread, 0, 0, nullptr);
RETURN_HR_IF(E_HANDLE, hThread == nullptr);
LOG_IF_WIN32_BOOL_FALSE(CloseHandle(hThread)); // The thread will run on its own and close itself. Free the associated handle.
@ -638,7 +638,7 @@ NTSTATUS ConsoleAllocateConsole(PCONSOLE_API_CONNECTINFO p)
// - <none>
// Return Value:
// - This routine never returns. The process exits when no more references or clients exist.
DWORD ConsoleIoThread()
DWORD WINAPI ConsoleIoThread(LPVOID /*lpParameter*/)
{
auto& globals = ServiceLocator::LocateGlobals();

View file

@ -16,7 +16,7 @@
using namespace Microsoft::Console::Interactivity::OneCore;
DWORD ConsoleInputThreadProcOneCore(LPVOID /*lpParam*/)
DWORD WINAPI ConsoleInputThreadProcOneCore(LPVOID /*lpParam*/)
{
Globals& globals = ServiceLocator::LocateGlobals();
ConIoSrvComm * const Server = ServiceLocator::LocateInputServices<ConIoSrvComm>();
@ -108,7 +108,7 @@ HANDLE ConsoleInputThread::Start()
hThread = CreateThread(nullptr,
0,
(LPTHREAD_START_ROUTINE)ConsoleInputThreadProcOneCore,
ConsoleInputThreadProcOneCore,
_pConIoSrvComm,
0,
&dwThreadId);

View file

@ -18,7 +18,7 @@ HANDLE ConsoleInputThread::Start()
hThread = CreateThread(nullptr,
0,
(LPTHREAD_START_ROUTINE)ConsoleInputThreadProcWin32,
ConsoleInputThreadProcWin32,
nullptr,
0,
&dwThreadId);

View file

@ -15,7 +15,7 @@
#pragma hdrstop
INT_PTR FindDialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
INT_PTR CALLBACK FindDialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
// This bool is used to track which option - up or down - was used to perform the last search. That way, the next time the
@ -92,7 +92,7 @@ void DoFind()
HWND const hwnd = pWindow->GetWindowHandle();
++g.uiDialogBoxCount;
DialogBoxParamW(g.hInstance, MAKEINTRESOURCE(ID_CONSOLE_FINDDLG), hwnd, (DLGPROC)FindDialogProc, (LPARAM) nullptr);
DialogBoxParamW(g.hInstance, MAKEINTRESOURCE(ID_CONSOLE_FINDDLG), hwnd, FindDialogProc, (LPARAM) nullptr);
--g.uiDialogBoxCount;
}
}

View file

@ -937,7 +937,7 @@ BOOL HandleMouseEvent(const SCREEN_INFORMATION& ScreenInfo,
// Routine Description:
// - This routine gets called to filter input to console dialogs so that we can do the special processing that StoreKeyInfo does.
LRESULT DialogHookProc(int nCode, WPARAM /*wParam*/, LPARAM lParam)
LRESULT CALLBACK DialogHookProc(int nCode, WPARAM /*wParam*/, LPARAM lParam)
{
MSG msg = *((PMSG)lParam);
@ -979,7 +979,7 @@ NTSTATUS InitWindowsSubsystem(_Out_ HHOOK * phhook)
// We intentionally ignore the return value of SetWindowsHookEx. There are mixed LUID cases where this call will fail but in the past this call
// was special cased (for CSRSS) to always succeed. Thus, we ignore failure for app compat (as not having the hook isn't fatal).
*phhook = SetWindowsHookExW(WH_MSGFILTER, (HOOKPROC)DialogHookProc, nullptr, GetCurrentThreadId());
*phhook = SetWindowsHookExW(WH_MSGFILTER, DialogHookProc, nullptr, GetCurrentThreadId());
SetConsoleWindowOwner(ServiceLocator::LocateConsoleWindow()->GetWindowHandle(), ProcessData);
@ -995,7 +995,7 @@ NTSTATUS InitWindowsSubsystem(_Out_ HHOOK * phhook)
// (for a window)
// ----------------------------
DWORD ConsoleInputThreadProcWin32(LPVOID /*lpParameter*/)
DWORD WINAPI ConsoleInputThreadProcWin32(LPVOID /*lpParameter*/)
{
InitEnvironmentVariables();

View file

@ -25,4 +25,4 @@ BOOL HandleMouseEvent(const SCREEN_INFORMATION& ScreenInfo,
const LPARAM lParam);
VOID SetConsoleWindowOwner(const HWND hwnd, _Inout_opt_ ConsoleProcessHandle* pProcessData);
DWORD ConsoleInputThreadProcWin32(LPVOID lpParameter);
DWORD WINAPI ConsoleInputThreadProcWin32(LPVOID lpParameter);

View file

@ -42,7 +42,7 @@ void SimpleColorDoPaint(const HWND hColor, PAINTSTRUCT& ps, const int ColorId)
// Routine Description:
// - Window proc for the color buttons
LRESULT SimpleColorControlProc(const HWND hColor, const UINT wMsg, const WPARAM wParam, const LPARAM lParam)
LRESULT CALLBACK SimpleColorControlProc(const HWND hColor, const UINT wMsg, const WPARAM wParam, const LPARAM lParam)
{
PAINTSTRUCT ps;
int ColorId;

View file

@ -14,5 +14,5 @@ Author(s):
#pragma once
LRESULT SimpleColorControlProc(HWND hColor, UINT wMsg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK SimpleColorControlProc(HWND hColor, UINT wMsg, WPARAM wParam, LPARAM lParam);
void SimpleColorDoPaint(HWND hColor, PAINTSTRUCT& ps, int ColorId);

View file

@ -10,7 +10,7 @@ static int iColor;
// Routine Description:
// - Window proc for the color buttons
LRESULT ColorTableControlProc(HWND hColor, UINT wMsg, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK ColorTableControlProc(HWND hColor, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
int ColorId;

View file

@ -18,4 +18,4 @@ void ToggleV2ColorControls(__in const HWND hDlg);
INT_PTR WINAPI ColorDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
void SetOpacitySlider(__in HWND hDlg);
void PreviewOpacity(HWND hDlg, BYTE bOpacity);
LRESULT ColorTableControlProc(HWND hColor, UINT wMsg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK ColorTableControlProc(HWND hColor, UINT wMsg, WPARAM wParam, LPARAM lParam);

View file

@ -506,7 +506,7 @@ BOOL PopulatePropSheetPageArray(_Out_writes_(cPsps) PROPSHEETPAGE *pPsp, const s
pFontPage->dwSize = sizeof(PROPSHEETPAGE);
pFontPage->hInstance = ghInstance;
pFontPage->pszTemplate = MAKEINTRESOURCE(DID_FONTDLG);
pFontPage->pfnDlgProc = (DLGPROC) FontDlgProc;
pFontPage->pfnDlgProc = FontDlgProc;
pFontPage->lParam = FONT_PAGE_INDEX;
pOptionsPage->dwFlags = PSP_DEFAULT;
@ -660,7 +660,7 @@ void RegisterClasses(HINSTANCE hModule)
WNDCLASS wc;
wc.lpszClassName = TEXT("SimpleColor");
wc.hInstance = hModule;
wc.lpfnWndProc = (WNDPROC) SimpleColorControlProc;
wc.lpfnWndProc = SimpleColorControlProc;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = NULL;
wc.lpszMenuName = NULL;
@ -672,7 +672,7 @@ void RegisterClasses(HINSTANCE hModule)
wc.lpszClassName = TEXT("ColorTableColor");
wc.hInstance = hModule;
wc.lpfnWndProc = (WNDPROC) ColorTableControlProc;
wc.lpfnWndProc = ColorTableControlProc;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = NULL;
wc.lpszMenuName = NULL;
@ -683,13 +683,13 @@ void RegisterClasses(HINSTANCE hModule)
RegisterClass(&wc);
wc.lpszClassName = TEXT("WOAWinPreview");
wc.lpfnWndProc = (WNDPROC) PreviewWndProc;
wc.lpfnWndProc = PreviewWndProc;
wc.hbrBackground = (HBRUSH) (COLOR_BACKGROUND + 1);
wc.style = 0;
RegisterClass(&wc);
wc.lpszClassName = TEXT("WOAFontPreview");
wc.lpfnWndProc = (WNDPROC) FontPreviewWndProc;
wc.lpfnWndProc = FontPreviewWndProc;
wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
wc.style = 0;
RegisterClass(&wc);

View file

@ -173,13 +173,13 @@ VOID SetRegistryValues(
PCONSOLE_STATE_INFO InitStateValues(
HWND hwnd);
LRESULT FontPreviewWndProc(
LRESULT CALLBACK FontPreviewWndProc(
HWND hWnd,
UINT wMsg,
WPARAM wParam,
LPARAM lParam);
LRESULT PreviewWndProc(
LRESULT CALLBACK PreviewWndProc(
HWND hWnd,
UINT wMsg,
WPARAM wParam,

View file

@ -979,6 +979,7 @@ Return Value:
/* ----- Preview routines ----- */
LRESULT
CALLBACK
FontPreviewWndProc(
HWND hWnd,
UINT wMessage,

View file

@ -420,7 +420,7 @@ DestroyFonts(
* Is called exactly once by GDI for each font in the system. This
* routine is used to store the FONT_INFO structure.
*/
int FontEnumForV2Console(ENUMLOGFONT *pelf, NEWTEXTMETRIC *pntm, int nFontType, LPARAM lParam)
int CALLBACK FontEnumForV2Console(ENUMLOGFONT *pelf, NEWTEXTMETRIC *pntm, int nFontType, LPARAM lParam)
{
FAIL_FAST_IF(!(ShouldAllowAllMonoTTFonts()));
UINT i;
@ -546,6 +546,7 @@ int FontEnumForV2Console(ENUMLOGFONT *pelf, NEWTEXTMETRIC *pntm, int nFontType,
* routine is used to store the FONT_INFO structure.
*/
int
CALLBACK
FontEnum(
ENUMLOGFONT *pelf,
NEWTEXTMETRIC *pntm,

View file

@ -371,6 +371,7 @@ PreviewPaint(
LRESULT
CALLBACK
PreviewWndProc(
HWND hWnd,
UINT wMessage,

View file

@ -163,7 +163,7 @@ void handleWindowEvent(WINDOW_BUFFER_SIZE_RECORD windowEvent)
}
BOOL CtrlHandler( DWORD fdwCtrlType )
BOOL WINAPI CtrlHandler( DWORD fdwCtrlType )
{
switch( fdwCtrlType )
{
@ -239,7 +239,7 @@ int __cdecl wmain(int argc, wchar_t* argv[])
DWORD dwInMode = 0;
GetConsoleMode(g_hOut, &dwOutMode);
GetConsoleMode(g_hIn, &dwInMode);
SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE );
SetConsoleCtrlHandler(CtrlHandler, TRUE );
const DWORD initialInMode = dwInMode;
const DWORD initialOutMode = dwOutMode;

View file

@ -5,7 +5,7 @@
#include <windowsx.h>
#include <wil\result.h>
int FontEnumForV2Console(ENUMLOGFONT *pelf, NEWTEXTMETRIC *pntm, int nFontType, LPARAM lParam);
int CALLBACK FontEnumForV2Console(ENUMLOGFONT *pelf, NEWTEXTMETRIC *pntm, int nFontType, LPARAM lParam);
int
AddFont(
ENUMLOGFONT *pelf,
@ -56,7 +56,7 @@ SHORT TTPoints[] = {
};
int FontEnumForV2Console(ENUMLOGFONT *pelf, NEWTEXTMETRIC *pntm, int nFontType, LPARAM lParam)
int CALLBACK FontEnumForV2Console(ENUMLOGFONT *pelf, NEWTEXTMETRIC *pntm, int nFontType, LPARAM lParam)
{
UINT i;
LPCWSTR pwszFace = pelf->elfLogFont.lfFaceName;

View file

@ -149,7 +149,7 @@ void VtConsole::_spawn(const std::wstring& command)
_dwOutputThreadId = (DWORD)-1;
_hOutputThread = CreateThread(nullptr,
0,
(LPTHREAD_START_ROUTINE)StaticOutputThreadProc,
StaticOutputThreadProc,
this,
0,
&_dwOutputThreadId);
@ -335,7 +335,7 @@ void VtConsole::deactivate()
_active = false;
}
DWORD VtConsole::StaticOutputThreadProc(LPVOID lpParameter)
DWORD WINAPI VtConsole::StaticOutputThreadProc(LPVOID lpParameter)
{
VtConsole* const pInstance = (VtConsole*)lpParameter;
return pInstance->_OutputThread();

View file

@ -44,7 +44,7 @@ public:
void signalWindow(unsigned short sx, unsigned short sy);
static DWORD StaticOutputThreadProc(LPVOID lpParameter);
static DWORD WINAPI StaticOutputThreadProc(LPVOID lpParameter);
bool WriteInput(std::string& seq);

View file

@ -461,7 +461,7 @@ void SetupInput()
SetConsoleMode(hIn, dwInMode);
}
DWORD InputThread(LPVOID /*lpParameter*/)
DWORD WINAPI InputThread(LPVOID /*lpParameter*/)
{
// Because the input thread ends up owning the lifetime of the application,
// Set/restore the CP here.
@ -502,7 +502,7 @@ void CreateIOThreads()
DWORD dwInputThreadId = (DWORD) -1;
HANDLE hInputThread = CreateThread(nullptr,
0,
(LPTHREAD_START_ROUTINE)InputThread,
InputThread,
nullptr,
0,
&dwInputThreadId);
@ -510,7 +510,7 @@ void CreateIOThreads()
}
BOOL CtrlHandler( DWORD fdwCtrlType )
BOOL WINAPI CtrlHandler( DWORD fdwCtrlType )
{
switch( fdwCtrlType )
{
@ -531,7 +531,7 @@ int __cdecl wmain(int argc, WCHAR* argv[])
{
// initialize random seed:
srand((unsigned int)time(NULL));
SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE );
SetConsoleCtrlHandler(CtrlHandler, TRUE );
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
hIn = GetStdHandle(STD_INPUT_HANDLE);