📄 gpttest.cpp
字号:
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//
// Copyright (C) 2004-2006, Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
//
// GPT TUX DLL
//
// Module: GPTTest.cpp
// Contains the shell processing function.
//
////////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <Devload.h>
#include <ceddk.h>
#include "main.h"
#include "globals.h"
#include "csp.h"
#include "gpt.h"
//-----------------------------------------------------------------------------
// External Functions
//-----------------------------------------------------------------------------
// External Variables
//-----------------------------------------------------------------------------
// Defines
#define GPT_ZONE_ERROR 1
//-----------------------------------------------------------------------------
// Types
//-----------------------------------------------------------------------------
// Global Variables
HANDLE hGpt = NULL;
PCSP_GPT_REGS g_pGPT;
//fix the bug of "hardcoded number"
static int GPTx = 3; //[2,6] for GPT2 to GPT6, default is 3
//-----------------------------------------------------------------------------
// Local Variables
//-----------------------------------------------------------------------------
// Local Functions
static BOOL InitializeTests(void);
static VOID FinishTests(void);
////////////////////////////////////////////////////////////////////////////////
// DllMain
// Main entry point of the DLL. Called when the DLL is loaded or unloaded.
//
// Parameters:
// hInstance Module instance of the DLL.
// dwReason Reason for the function call.
// lpReserved Reserved for future use.
//
// Return value:
// TRUE if successful, FALSE to indicate an error condition.
BOOL WINAPI DllMain(HANDLE hInstance, ULONG dwReason, LPVOID lpReserved)
{
// Any initialization code goes here.
return TRUE;
}
////////////////////////////////////////////////////////////////////////////////
// Debug
// Printf-like wrapping around OutputDebugString.
//
// Parameters:
// szFormat Formatting string (as in printf).
// ... Additional arguments.
//
// Return value:
// None.
void Debug(LPCTSTR szFormat, ...)
{
static TCHAR szHeader[] = TEXT("GPT: ");
TCHAR szBuffer[1024];
va_list pArgs;
va_start(pArgs, szFormat);
lstrcpy(szBuffer, szHeader);
wvsprintf(
szBuffer + countof(szHeader) - 1,
szFormat,
pArgs);
va_end(pArgs);
_tcscat(szBuffer, TEXT("\r\n"));
OutputDebugString(szBuffer);
}
////////////////////////////////////////////////////////////////////////////////
// Command Line: (NULL), 2, 3, 4, 5, 6 or ?
//
static BOOL ProcessCmdLine(LPCTSTR cmdline)
{
if (cmdline)
{
if (0<=_tcsicmp(cmdline,L"2") && 0>=_tcsicmp(cmdline,L"6") )
{
GPTx = _ttoi(cmdline);
return TRUE;
}
else if (0==_tcsicmp(cmdline,L"?"))
{
g_pKato->Log(LOG_FAIL, TEXT( "usage: s tux -o -d gpttest.dll tux_parameters -c \"dll_parameters\"" ));
g_pKato->Log(LOG_FAIL, TEXT( "Tux parameters: please refer to s tux -?" ));
g_pKato->Log(LOG_FAIL, TEXT( "DLL parameters: [#] [?]" ));
g_pKato->Log(LOG_FAIL, TEXT( "\t-n\tGPT number required, can be 2,3,4,5,6 (default is 3)"));
g_pKato->Log(LOG_FAIL, TEXT( "\t-?\tThis help message\n" ));
}
else
{
g_pKato->Log(LOG_FAIL, TEXT("FAIL: Invalid Command option\n"));
g_pKato->Log(LOG_FAIL, TEXT("use -c \"?\" to see command line detail\n"));
}
}
return FALSE;
}
////////////////////////////////////////////////////////////////////////////////
// ShellProc
// Processes messages from the TUX shell.
//
// Parameters:
// uMsg Message code.
// spParam Additional message-dependent data.
//
// Return value:
// Depends on the message.
SHELLPROCAPI ShellProc(UINT uMsg, SPPARAM spParam)
{
LPSPS_BEGIN_TEST pBT;
LPSPS_END_TEST pET;
LPTSTR lpszCmdLine =NULL;
BOOL fRtn= TRUE;
switch (uMsg)
{
case SPM_LOAD_DLL:
// Sent once to the DLL immediately after it is loaded. The spParam
// parameter will contain a pointer to a SPS_LOAD_DLL structure. The
// DLL should set the fUnicode member of this structure to TRUE if the
// DLL is built with the UNICODE flag set. If you set this flag, Tux
// will ensure that all strings passed to your DLL will be in UNICODE
// format, and all strings within your function table will be processed
// by Tux as UNICODE. The DLL may return SPR_FAIL to prevent the DLL
// from continuing to load.
Debug(TEXT("ShellProc(SPM_LOAD_DLL, ...) called"));
// If we are UNICODE, then tell Tux this by setting the following flag.
#ifdef UNICODE
((LPSPS_LOAD_DLL)spParam)->fUnicode = TRUE;
#endif // UNICODE
g_pKato = (CKato*)KatoGetDefaultObject();
break;
case SPM_UNLOAD_DLL:
// Sent once to the DLL immediately before it is unloaded.
Debug(TEXT("ShellProc(SPM_UNLOAD_DLL, ...) called"));
//--------------------------------------
// Added To Framework Program
//--------------------------------------
FinishTests();
break;
case SPM_SHELL_INFO:
// Sent once to the DLL immediately after SPM_LOAD_DLL to give the DLL
// some useful information about its parent shell and environment. The
// spParam parameter will contain a pointer to a SPS_SHELL_INFO
// structure. The pointer to the structure may be stored for later use
// as it will remain valid for the life of this Tux Dll. The DLL may
// return SPR_FAIL to prevent the DLL from continuing to load.
Debug(TEXT("ShellProc(SPM_SHELL_INFO, ...) called"));
// Store a pointer to our shell info for later use.
g_pShellInfo = (LPSPS_SHELL_INFO)spParam;
// handle command line parsing
if( g_pShellInfo->szDllCmdLine && g_pShellInfo->szDllCmdLine[0] )
{
lpszCmdLine = new TCHAR[ (_tcslen(g_pShellInfo->szDllCmdLine)+1) ];
if( NULL == lpszCmdLine )
{
g_pKato->Log( LOG_FAIL, TEXT("FAIL in : Couldn't set test options"));
return SPR_FAIL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -