⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kmodeentries.cpp

📁 WinCE5.0部分核心源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// This source code is licensed under Microsoft Shared Source License
// Version 1.0 for Windows CE.
// For a copy of the license visit http://go.microsoft.com/fwlink/?LinkId=3223.
//
#include "kernel.h"
#include <KmodeEntries.hpp>
#include <GweApiSet1.hpp>

extern "C" LPVOID pGwesHandler;

extern "C"
const
CINFO*
SwitchToProc(
	CALLSTACK*	pcstk,
	DWORD		dwAPISet
	);

extern "C"
void
SwitchBack(
	void
	);


extern "C"
void
DoMapPtr(
	void**
    );

#define MapArgPtr(P) DoMapPtr((LPVOID *)&(P))


//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
int
SC_GetSystemMetrics(
	int	nIndex
	)
{
			CALLSTACK	cstk;
			int			iRet;
	const	CINFO*		pci = SwitchToProc(&cstk,SH_WMGR);
	__try
	{
		iRet = ((GweApiSet1_t*)(pci->ppfnMethods)) -> m_pGetSystemMetrics(nIndex);
//		iRet = (*(int (*)(int))(pci->ppfnMethods[MID_GetSystemMetrics]))(nIndex);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		iRet = 0;
	}
	SwitchBack();
	return iRet;
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
ATOM
SC_RegisterClassWStub(
	const	WNDCLASSW*	lpWndClass,
	const	WCHAR*		lpszClassName,
			HANDLE		hprcWndProc
	)
{
	CALLSTACK	cstk;
	ATOM		aRet;

	//	Need to map pointers before switching to target proc.
	MapArgPtr(lpWndClass);
	MapArgPtr(lpszClassName);

	const CINFO *pci = SwitchToProc(&cstk,SH_WMGR);
	__try
	{
 		aRet = ((GweApiSet1_t*)(pci->ppfnMethods)) -> m_pRegisterClassWApiSetEntry(lpWndClass,lpszClassName,hprcWndProc);
// 		aRet = (*(ATOM (*)(CONST WNDCLASSW *, LPCWSTR, HANDLE))(pci->ppfnMethods[MID_RegisterClassWApiSetEntry]))(lpWndClass,lpszClassName,hprcWndProc);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		aRet = 0;
	}
	SwitchBack();
	return aRet;
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
UINT
SC_RegisterClipboardFormatW(
	const	WCHAR*	lpszFormat
    )
{
	CALLSTACK cstk;
	UINT uRet;

	//	Need to map pointers before switching to target proc.
	MapArgPtr(lpszFormat);

	const CINFO *pci = SwitchToProc(&cstk,SH_WMGR);
	__try
	{
		uRet = ((GweApiSet1_t*)(pci->ppfnMethods)) -> m_pRegisterClipboardFormatW(lpszFormat);
//		uRet = (*(UINT (*)(LPCWSTR))(pci->ppfnMethods[MID_RegisterClipboardFormatW]))(lpszFormat);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		uRet = 0;
	}
	SwitchBack();
	return uRet;
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
int
SC_SetBkMode(
	HDC	hdc,
	int	iBkMode
	)
{
			CALLSTACK	cstk;
			int			iRet;
	const	CINFO *pci = SwitchToProc(&cstk,SH_GDI);
	__try
		{
		iRet = ((GweApiSet2_t*)(pci->ppfnMethods)) -> m_pSetBkMode(hdc,iBkMode);
//		iRet = (*(int (*)(HDC,int))(pci->ppfnMethods[SETBKMODE]))(hdc,iBkMode);
		}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		iRet = 0;
	}
	SwitchBack();
	return iRet;
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
COLORREF
SC_SetTextColor(
	HDC			hdc,
	COLORREF	crColor
	)
{
			CALLSTACK	cstk;
			COLORREF	cRet;
	const	CINFO*		pci = SwitchToProc(&cstk,SH_GDI);
	__try
	{
		cRet = ((GweApiSet2_t*)(pci->ppfnMethods)) -> m_pSetTextColor(hdc,crColor);
//		cRet = (*(COLORREF (*)(HDC,COLORREF))(pci->ppfnMethods[SETTEXTCOLOR]))(hdc,crColor);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		cRet = 0;
	}
	SwitchBack();
	return cRet;
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
BOOL
SC_InvalidateRect(
			HWND	hwnd,
	const	RECT*	prc,
			BOOL	fErase
	)
{
	CALLSTACK	cstk;
	BOOL		bRet;

	//	Need to map pointers before switching to target proc.
	MapArgPtr(prc);

	const	CINFO*		pci = SwitchToProc(&cstk,SH_WMGR);

	__try
	{
		bRet = ((GweApiSet1_t*)(pci->ppfnMethods)) -> m_pInvalidateRect(hwnd,prc,fErase);
//		bRet = (*(BOOL (*)(HWND, LPCRECT, BOOL))(pci->ppfnMethods[MID_InvalidateRect]))(hwnd,prc,fErase);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		bRet = 0;
	}
	SwitchBack();
	return bRet;
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
BOOL
SC_TransparentImage(
	HDC			hdcDest,
	int			nXDest,
	int			nYDest,
	int			nWidthDest,
	int			nHeightDest,
	HANDLE		hImgSrc,
	int			nXSrc,
	int			nYSrc,
	int			nWidthSrc,
	int			nHeightSrc,
	COLORREF	crTransparentColor
	)
{
			CALLSTACK	cstk;
			BOOL		bRet;
	const	CINFO*		pci = SwitchToProc(&cstk,SH_GDI);
	__try
	{
		bRet  = ((GweApiSet2_t*)(pci->ppfnMethods)) -> m_pTransparentImage(
														hdcDest,
														nXDest,
														nYDest,
														nWidthDest,
														nHeightDest,
														hImgSrc,
														nXSrc,
														nYSrc,
														nWidthSrc,
														nHeightSrc,
														crTransparentColor
														);
//		bRet = (*(BOOL (*)(HDC,int,int,int,int,HANDLE,int,int,int,int,COLORREF))(pci->ppfnMethods[TRANSPARENTIMAGE]))
//			   (hdcDest, nXDest, nYDest, nWidthDest, nHeightDest, hImgSrc, nXSrc, nYSrc, nWidthSrc, nHeightSrc, crTransparentColor);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		bRet = 0;
	}
	SwitchBack();
	return bRet;
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
BOOL
SC_IsDialogMessageW(
	HWND	hDlg,
	MSG*	lpMsg
    )
{
	CALLSTACK	cstk;
	BOOL		bRet;

	//	Need to map pointers before switching to target proc.
	MapArgPtr(lpMsg);

	const	CINFO*		pci = SwitchToProc(&cstk,SH_WMGR);

	__try
	{
		bRet = ((GweApiSet1_t*)(pci->ppfnMethods)) -> m_pIsDialogMessageW(hDlg,lpMsg);
//		bRet = (*(BOOL (*)(HWND,LPMSG))(pci->ppfnMethods[MID_IsDialogMessageW]))(hDlg,lpMsg);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		bRet = 0;
	}
	SwitchBack();
	return bRet;
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
BOOL
SC_PostMessageW(
	HWND	hWnd,
	UINT	Msg,
	WPARAM	wParam,
	LPARAM	lParam
	)
{
			CALLSTACK	cstk;
			BOOL		bRet;
    const	CINFO*		pci = SwitchToProc(&cstk,SH_WMGR);
	__try
	{
		bRet = ((GweApiSet1_t*)(pci->ppfnMethods)) -> m_pPostMessageW(hWnd,Msg,wParam,lParam);
//		bRet = (*(BOOL (*)(HWND,UINT,WPARAM,LPARAM))(pci->ppfnMethods[MID_PostMessageW]))(hWnd,Msg,wParam,lParam);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		bRet = 0;
	}
	SwitchBack();
	return bRet;
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
BOOL
SC_IsWindowVisible(
	HWND	hWnd
	)
{
			CALLSTACK	cstk;
			BOOL		bRet;
	const	CINFO*		pci = SwitchToProc(&cstk,SH_WMGR);
	__try
	{
		bRet = ((GweApiSet1_t*)(pci->ppfnMethods)) -> m_pIsWindowVisible(hWnd);
//		bRet = (*(BOOL (*)(HWND))(pci->ppfnMethods[MID_IsWindowVisible]))(hWnd);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		bRet = 0;
	}
	SwitchBack();
	return bRet;
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
SHORT
SC_GetKeyState(
	int	nVirtKey
	)
{
			CALLSTACK	cstk;
			SHORT		sRet;
	const	CINFO*		pci = SwitchToProc(&cstk,SH_WMGR);
	__try
	{
		sRet = ((GweApiSet1_t*)(pci->ppfnMethods)) -> m_pGetKeyState(nVirtKey);
//		sRet = (*(SHORT (*)(int))(pci->ppfnMethods[MID_GetKeyState]))(nVirtKey);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		sRet = 0;
	}
	SwitchBack();
	return sRet;
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
HDC
SC_BeginPaint(
	HWND			hwnd,
	PAINTSTRUCT*	pps
	)
{
	CALLSTACK	cstk;
	HDC			hRet;

	//	Need to map pointers before switching to target proc.
	MapArgPtr(pps);

	const	CINFO*		pci = SwitchToProc(&cstk,SH_WMGR);

	__try
	{
		hRet = ((GweApiSet1_t*)(pci->ppfnMethods)) -> m_pBeginPaint(hwnd,pps);
//		hRet = (*(HDC (*)(HWND,LPPAINTSTRUCT))(pci->ppfnMethods[MID_BeginPaint]))(hwnd,pps);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		hRet = 0;
	}
	SwitchBack();
	return hRet;
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
BOOL
SC_EndPaint(
	HWND			hwnd,
	PAINTSTRUCT*	pps
    )
{
	CALLSTACK	cstk;
	BOOL		bRet;

	//	Need to map pointers before switching to target proc.
	MapArgPtr(pps);

	const	CINFO*		pci = SwitchToProc(&cstk,SH_WMGR);

	__try
	{
		bRet = ((GweApiSet1_t*)(pci->ppfnMethods)) -> m_pEndPaint(hwnd,pps);
//		bRet = (*(BOOL (*)(HWND,LPPAINTSTRUCT))(pci->ppfnMethods[MID_EndPaint]))(hwnd,pps);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		bRet = 0;
	}
	SwitchBack();
	return bRet;
}






//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
LRESULT
SC_DefWindowProcW(
	HWND	hwnd,
	UINT	msg,
	WPARAM	wParam,
	LPARAM	lParam
	)
{
			CALLSTACK	cstk;
			LRESULT		lRet;
	const	CINFO*		pci = SwitchToProc(&cstk,SH_WMGR);

	__try
	{
		lRet = ((GweApiSet1_t*)(pci->ppfnMethods)) -> m_pDefWindowProcW(hwnd,msg,wParam,lParam);
//		lRet = (*(LRESULT (*)(HWND, UINT, WPARAM, LPARAM))(pci->ppfnMethods[MID_DefWindowProcW]))(hwnd,msg,wParam,lParam);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		(*(void (*)(void))pGwesHandler)();
		lRet = 0;
	}
	SwitchBack();
	return lRet;
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
BOOL
SC_GetClipCursor(
	RECT*	lpRect
	)
{
	CALLSTACK	cstk;
	BOOL		bRet;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -