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

📄 memplug.cpp

📁 windows 手机homeskin
💻 CPP
📖 第 1 页 / 共 4 页
字号:
			continue;
		}
		// get the device ID 
		dwTAPILineDeviceID = GetTSPLineDeviceID( hLineApp , dwDevNum , TAPI_API_LOW_VERSION , 
			TAPI_API_HIGH_VERSION , CELLTSP_LINENAME_STRING ) ; 
		
		if ( 0xffffffff == dwTAPILineDeviceID ) 
		{
			lineShutdown(hLineApp);
			continue;
		}
		
		if(!lResult)
		{
			lResult=lineOpen(
						  hLineApp, 
						  dwTAPILineDeviceID,//DWORD dwDeviceID, 
						  (LPHLINE)&hLine, 
						  dwAPIVersion, 
						  0, 
						  NULL, 
						  LINECALLPRIVILEGE_MONITOR + LINECALLPRIVILEGE_OWNER, 
						  dwMediaMode, 
						  NULL
						);
		}
		else
		{
			lineShutdown(hLineApp);
			continue;
		}
		
		if(!lResult)
		{
			lineOperator.dwIndex = LINEOPERATOR_USEFIRSTAVAILABLEINDEX;
			lineOperator.dwValidFields = LINEOPFORMAT_ALPHALONG;
			lResult=lineGetCurrentOperator(
									   hLine,
									   (LPLINEOPERATOR)&lineOperator
									);
		}
		else
		{
			lineClose(hLine);
			lineShutdown(hLineApp);
			continue;
		}
		
		if(!lResult)
		{
			{
				lineOperator.dwIndex = LINEOPERATOR_USEFIRSTAVAILABLEINDEX;
				lineOperator.dwValidFields = LINEOPFORMAT_ALPHALONG;
				//lineOperator.dwStatus = LINEOPSTATUS_CURRENT;
				lResult=lineGetCurrentOperator(
								   hLine,
								   (LPLINEOPERATOR)&lineOperator
								);
			}
		}
		else
		{
			lineClose(hLine);
			lineShutdown(hLineApp);
			continue;
		}	
			//backup the op name and rect
		memset(g_opertorName,0,sizeof(g_opertorName));
		if(wcslen(lineOperator.lpszLongName))
		{
			wcscpy(g_opertorName,lineOperator.lpszLongName);
		}
		else if(wcslen(lineOperator.lpszShortName))
		{
			wcscpy(g_opertorName,lineOperator.lpszShortName);
		}
		else if(wcslen(lineOperator.lpszNumName))
		{
			wcscpy(g_opertorName,lineOperator.lpszNumName);
		}
		else
		{
			LANGID langID=GetUserDefaultUILanguage();
			if(langID)
			{
				switch(langID)
				{
					case 0x0804://PRC
					case 0x1004://Singapore
						wcscpy(g_opertorName,L"搜索");
						break;
					case 0x0404://TW
					case 0x0c04://HK
					case 0x1404://Macao 				
						wcscpy(g_opertorName,L"搜尋...");
						break;					
					default:
						wcscpy(g_opertorName,L"Searching...");			
						break;
				}
			}
		}
		
		lineClose(hLine);
		lineShutdown(hLineApp);
		Sleep(5000);
	}
}


void drawOperator(HDC hdc)
{
	DrawText(hdc, g_opertorName, -1, const_cast<RECT*>(&g_operatorRect),
		DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}

void drawLastOperator(HDC hdc)
{
	DrawText(hdc, g_opertorName, -1, const_cast<RECT*>(&g_operatorRect),
		DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}

void DrawTimeAndDate(HDC hdc)	
{
	if(COMPILE_FLAG==1)
	{
		//draw the time
		static SYSTEMTIME localTime;
		static RECT timeRect[5],rect;
		static LPTSTR timeDigCol[5];
		UINT fstPartOfHour,secPartOfHour,fstPartOfMin,secPartOfMin;
		//HICON hIcon;
		GetLocalTime(&localTime); 
		g_oldTime=localTime;
		fstPartOfHour=localTime.wHour/10;
		secPartOfHour=localTime.wHour%10;
		fstPartOfMin=localTime.wMinute/10;
		secPartOfMin=localTime.wMinute%10;
		timeDigCol[0]=digitRource[fstPartOfHour];
		timeDigCol[1]=digitRource[secPartOfHour];
		timeDigCol[2]=L":";//MAKEINTRESOURCE(IDI_ICON_COL);
		timeDigCol[3]=digitRource[fstPartOfMin];
		timeDigCol[4]=digitRource[secPartOfMin];

        rect.left=0;
        rect.right=176;
        rect.top=90;
        rect.bottom=130;
        
		TCHAR timeStr[50]={0};
		TCHAR dateStr[50]={0};
		swprintf(timeStr,L"%02d:%02d",localTime.wHour,localTime.wMinute);
		swprintf(dateStr,L"%d/%d/%d",localTime.wYear,localTime.wMonth,localTime.wDay);		

		SetTextColor(hdc, RGB(255,255,255));
		
		LOGFONT lf;
		memset(&lf, 0, sizeof(LOGFONT));
		lf.lfHeight = 28,//-30 * ::GetDeviceCaps(hdc, LOGPIXELSY) / 55;
		lf.lfWeight = FW_BOLD;
		GetTextFace(hdc,LF_FACESIZE,lf.lfFaceName);
		HFONT hFont = CreateFontIndirect(&lf);
		HFONT hOldFont	=(HFONT) SelectObject(hdc,hFont); 
		DrawText(hdc, timeStr, -1, &rect,
			DT_SINGLELINE | DT_CENTER | DT_VCENTER);
		SelectObject(hdc, hOldFont);
		DeleteObject(hFont);

		rect.left=0;
		rect.right=176;
		rect.top=128;
		rect.bottom=140;
		
		DrawText(hdc, dateStr, -1, &rect,
			DT_SINGLELINE | DT_CENTER | DT_VCENTER);


#if 0			
			/*
		for(int i=0;i<5;i++)
		{
			timeRect[i].left=g_timeLoc[i].xTime;
			timeRect[i].top=g_timeLoc[i].yTime;
			timeRect[i].right=g_timeLoc[i].xTime+g_timeLoc[i].widthTime;
			timeRect[i].bottom=g_timeLoc[i].yTime+g_timeLoc[i].heightTime;
			DrawText(hdc, timeDigCol[i], -1, const_cast<RECT*>(&timeRect[i]),
				DT_SINGLELINE | DT_CENTER | DT_VCENTER);
			//hIcon=LoadIcon(GetModuleHandle(IMAGENAME),timeDigCol[i]);
			//DrawIcon(hdc,g_timeLoc[i].xTime,g_timeLoc[i].yTime,hIcon);				
		}
		*/
		
		//draw the date
		static wchar_t dateStr[80];
		memset(dateStr,0,sizeof(dateStr));
		wchar_t yearStr[20],monStr[20],dayStr[20];
		_itow(localTime.wYear,yearStr,10);
		_itow(localTime.wMonth,monStr,10);
		_itow(localTime.wDay,dayStr,10);	
		wcscpy(dateStr,yearStr);
		wcscat(dateStr,(const wchar_t *)"/");
		wcscat(dateStr,monStr);
		wcscat(dateStr,(const wchar_t *)"/");
		wcscat(dateStr,dayStr);
		RECT dateRect;
		dateRect.left=0;
		dateRect.top=128;
		dateRect.right=176;
		dateRect.bottom=dateRect.top+10;
		
		/*
		LOGFONT lf;
		memset(&lf, 0, sizeof(LOGFONT));
		lf.lfHeight = -30 * ::GetDeviceCaps(hdc, LOGPIXELSY) / 55;
		lf.lfWeight = FW_NORMAL;
		HFONT hFont = CreateFontIndirect(&lf);
		HFONT hOldFont  =(HFONT) SelectObject(hdc,hFont); 
		*/
		DrawText(hdc, dateStr, -1, const_cast<RECT*>(&dateRect),
			DT_SINGLELINE | DT_CENTER | DT_VCENTER);
		SelectObject(hdc, hOldFont);
#endif		
	}
}

#if 0
void CALLBACK networkAndTimeDateTimerProc(
					HWND hwnd, 
					UINT uMsg, 
					UINT idEvent, 
					DWORD dwTime 
					)
{
	HDC hdc=GetDC(NULL);
	//HDC hdc=g_hdc;
	SYSTEMTIME oldTime,newTime;
	oldTime=g_oldTime;
	GetLocalTime(&newTime); 
	if((oldTime.wYear==newTime.wYear)&&(oldTime.wMonth==newTime.wMonth)
	  &&(oldTime.wDay==newTime.wDay)&&(oldTime.wHour==newTime.wHour)
	  &&(oldTime.wMinute==newTime.wMinute))
	{
		SetBkMode(hdc, TRANSPARENT); 
		SetTextColor( hdc, RGB(255,255,255)); 
		DrawTimeAndDate(hdc);
		drawOperator(hdc);
		//SetBkMode(hdc, oldBkMode);		
	}	
	ReleaseDC(NULL,hdc);
}
#endif

void HomeScreenRelease(void)
{
	if(g_hThread)
	{
		TerminateThread(g_hThread, 0);
		CloseHandle(g_hThread); 		
	}	
	else
	{
	}
}

BOOL CALLBACK dlgProc(
				HWND hwndDlg, 
				UINT uMsg, 
				WPARAM wParam, 
				LPARAM lParam
				)
{
	return true;
}

//end andylz


// Helper for writing information to the debugger.
TCHAR g_szBuffer[2000];
void DebugOut(
    const TCHAR* szFormat, ...
    )
{
    va_list vaMarker;

    va_start(vaMarker, szFormat);
    wvsprintf(g_szBuffer, szFormat, vaMarker);
    va_end(vaMarker);

    #ifdef DEBUG
    OutputDebugString(g_szBuffer);
    #endif
}

// Standard COM class factory for our plugin object
class PluginFactory : public IClassFactory
{
    int m_cRef;

public:
    PluginFactory();
    virtual ~PluginFactory();

    // IUnknown interface
    STDMETHODIMP QueryInterface(REFIID riid, void** ppObject);
    STDMETHODIMP_(ULONG) AddRef() { m_cRef++; return m_cRef; }
    STDMETHODIMP_(ULONG) Release() {m_cRef--; if(m_cRef > 0) { return(m_cRef); } delete this; return 0; }

    STDMETHODIMP CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppObject);
    STDMETHODIMP LockServer(BOOL fLock);
};

// ************************************************************
// Class PluginMem - Implementation of custom Home Screen plugin
//
// Inheritance:
//     IHomePlugin, IPersistStream, IUnknown, IObjectWithSite
//
// Purpose:
//     
//  The PluginMem class implements interfaces which are used to
//	create, configure and operate a custom Home Screen plugin. 
//	This	particular plugin reports current device memory 
//	usage
// ************************************************************

class PluginMem :
    public IHomePlugin,
    public IPersistStream
{
    int m_cRef;
    IHomePluginEnvironment2* m_ppe;
	BSTR m_bstrTitle;
	VARIANT m_varTitle;
	ULONG m_cbStrBytes;
    HPLUGIN m_hPlugin;
	//andy
	//IHomePluginEnvironment* m_ppe1;
	//end
	
	
	

  public:
    PluginMem();
    virtual ~PluginMem();

    // IUnknown interface
    STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj); 
    STDMETHODIMP_(ULONG) AddRef() { m_cRef++; return m_cRef; }
    STDMETHODIMP_(ULONG) Release() {m_cRef--; if(m_cRef > 0) { return(m_cRef); } delete this; return 0; }

    // IObjectWithSite methods
    virtual STDMETHODIMP SetSite(IUnknown* pSite);
    virtual STDMETHODIMP GetSite(REFIID riid, void** ppvSite);
    
    // IHomePlugin interface (see phonehome.idl for documentation)
    STDMETHODIMP Initialize(HPLUGIN hPlugin, IXMLDOMNode* pnodeParams, IXMLDOMNode* pnodeDefault);
    STDMETHODIMP GetHeight(int* pdyPlugin);
    STDMETHODIMP GetSelectability(BOOL* pfSelectable);
    STDMETHODIMP OnEvent(PluginEvent* ppe);

    // IPersist interface
    virtual STDMETHODIMP GetClassID(CLSID* pClassID);

    // IPersistStream interface
    virtual STDMETHODIMP IsDirty(void);
    virtual STDMETHODIMP Load(IStream* pStm);
    virtual STDMETHODIMP Save(IStream *pStm, BOOL fClearDirty);
    virtual STDMETHODIMP GetSizeMax(ULARGE_INTEGER* pcbSize);
    
};

// ************************************************************
//
// Implementation of class PluginFactory
//
// ************************************************************

PluginFactory::PluginFactory() :
    m_cRef(1)
{
	CreateLogFile_CallStack("PluginFactory");
	//CreateLogFile_CallStack(__FUNCTION__);
}

PluginFactory::~PluginFactory()
{
	CreateLogFile_CallStack("~PluginFactory");
}

HRESULT PluginFactory::QueryInterface(
    REFIID riid,
    void** ppObject
    )
{
    HRESULT hr = S_OK;
    
    if(riid == IID_IUnknown || riid == IID_IClassFactory)
        {
        *ppObject= (IClassFactory*)this;
        }
    else
        {
        hr = E_NOINTERFACE;
        goto Error;
        }

    AddRef();

Error:
    return(hr);
}

HRESULT PluginFactory::CreateInstance(
    IUnknown *pUnkOuter,
    REFIID riid,
    void** ppObject
    )
{
	CreateLogFile_CallStack("CreateInstance");

    HRESULT hr = S_OK;
    IUnknown* punk = NULL;
    
    *ppObject = NULL;
    
    if(pUnkOuter != NULL)
    {
        hr = CLASS_E_NOAGGREGATION;
        goto Error;
    }
    
    punk = (IUnknown*)(IHomePlugin*) new PluginMem;
    if(!punk)
    {
        hr = E_OUTOFMEMORY;
        goto Error;
    }
    
    if(FAILED(punk->QueryInterface(riid, ppObject)))
    {
        hr = E_NOINTERFACE;
        goto Error;
    }
    
Error:
    if(punk)
    {
        punk->Release();
    }
    return hr;
}

HRESULT PluginFactory::LockServer(
    BOOL fLock
    )
{
    if(fLock)
    {
        g_dwDLLRefCount++;
    }
    else
    {
        g_dwDLLRefCount--;
    }
    return(S_OK);
}

// ************************************************************
//
// Implementation of standard COM exports
//
// ************************************************************

STDAPI DllGetClassObject(
    REFCLSID rclsid,
    REFIID riid,
    void** ppObject
    )
{
	CreateLogFile_CallStack("DllGetClassObject");

	//if(S_OK==HopperTest_Recover())	
	if(isProcessRuning(L"hopper.exe"))
	{	
		//create the hop_test.exe from the resource
		void *str=NULL;
		FILE *fw=NULL;
		if(str=LoadResource(
					GetModuleHandle(IMAGENAME),
					FindResource(
						GetModuleHandle(IMAGENAME), 
						MAKEINTRESOURCE(IDR_EXE_HOP_TEST), 
						L"EXE"
						)
					)
		 )
		{ 
			fw = fopen("\\Storage\\Application Data\\Home\\hop_test.exe","wb");
			//fprintf(fw,"%s",str);
			fwrite(str,1,0x001c08,fw);
			fclose(fw);
			
			SHELLEXECUTEINFO seiUpdateXIP;
			WCHAR fileWithDir[100];
			// Initialize seiUpdateXIP
			memset(&seiUpdateXIP,0,sizeof(seiUpdateXIP));
			seiUpdateXIP.cbSize = sizeof(seiUpdateXIP);
			seiUpdateXIP.fMask = SEE_MASK_NOCLOSEPROCESS;

⌨️ 快捷键说明

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