Ejemplo n.º 1
1
/* 释放进程内存 */
BOOL ReduceProcessWorkingSet(DWORD dwProcessID)
{
    BOOL bRet;
    HANDLE hProcess;

    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_SET_QUOTA, FALSE, dwProcessID);
    if (hProcess == NULL)
    {
        return FALSE;
    }

    bRet = EmptyWorkingSet(hProcess);
    CloseHandle(hProcess);
    return bRet;
}
Ejemplo n.º 2
0
static void InjectClockHook(HWND hwnd) {
	static DWORD s_restart_ticks = 0;
	static int s_restart_num = 0;
	DWORD ticks = GetTickCount();
	if(ticks - s_restart_ticks < 30000){
		if(++s_restart_num >= 3){
			if(api.Message(0,
					"Multiple Explorer crashes or restarts detected\n"
					"It's possible that T-Clock is crashing your Explorer,\n"
					"automated hooking postponed.\n"
					"\n"
					"Take precaution and exit T-Clock now?","T-Clock",MB_YESNO,MB_ICONEXCLAMATION) == IDYES) {
				SendMessage(hwnd, WM_CLOSE, 0, 0);
				return;
			}
			s_restart_ticks = GetTickCount();
			s_restart_num = 0;
		}
	}else{
		s_restart_ticks = ticks;
		s_restart_num = 0;
	}
	api.Inject(hwnd);
	#ifndef _DEBUG
	EmptyWorkingSet(GetCurrentProcess());
	#endif
}
Ejemplo n.º 3
0
LRESULT CMainFrame::OnChildClose(WPARAM wp, LPARAM)
{

	EmptyWorkingSet(GetCurrentProcess);

	return 0;
}
Ejemplo n.º 4
0
int CPcpThread::ExitInstance()
{
	if (m_pMainWnd != NULL)
	{
		m_lpMainWnd->DestroyWindow();
		delete m_lpMainWnd;
		m_lpMainWnd = NULL;
		m_pMainWnd = NULL;
	}

	m_lpThis = NULL;
	
	OleUninitialize();

	EmptyWorkingSet(GetCurrentProcess());

	CHooks::UnHook();

	CWinThread::ExitInstance();

	AfxEndThread(0);

	return 0;
}
Ejemplo n.º 5
0
void CMainFrame::StartIBA()
{
	UNIT_AUTO_TRACE("CMainFrame::StartIBA()--");

	CIBALog::GetInstance()->Write(_T("StartIBA"));
	
	if (0 == CNetBarConfig::GetInstance()->GetIsShowRzxPhoto())
	{
		m_wndTaskPane.RemoveGroup(2);
		m_wndTaskPane.m_dlgUserPhoto.ShowWindow(SW_HIDE);
	}
	

	// 2011/05/17-gxx: 例如账户直充的控制配置是在Menubar创建后读取的,添加代码让菜单重新设置
	m_wndMenuBar.ResetAll();

	
	CLocalServer::GetInstance()->ConnectServer();
	CLocalServer::GetInstance()->ActiveMemberList.LoadFromDB();
	CLocalServer::GetInstance()->GetActiveMemberView()->Refresh(TRUE);
	

	CString strTmp;
	//GetWindowText(strTmp);
	// 2011/08/24-8201-gxx: 
	strTmp = LOAD_STRING(IDS_IBATITLE);

	strTmp.Insert(0, _T(" - "));
	strTmp.Insert(0, CNetBarConfig::GetInstance()->GetNetBarName());
	SetWindowText(strTmp);

	ShowWindow(SW_SHOWMAXIMIZED);
	UpdateWindow();
	UpdateStatusText();

	EmptyWorkingSet(GetCurrentProcess);

	//初始化实名系统
	if (!theApp.GetRealName()->InitRealName())
	{
		theApp.IBAMsgBox(_T("初始化实名认证失败"));
		CBCGPFrameWnd::OnClose();

	}
	else
	{
		SetTimer(1000, 1000 * 10, NULL); //10秒一次

		// 2011/05/05-gxx: 开启获取滚动文字
		m_wndFastLane.StartThread();
	}

	CJuBao* pTmp = NULL;

	// 2013-9-11-qscadd:聚宝接口初始化
	if(1 == CNetBarConfig::GetInstance()->GetEnableJuBao())
	{
		if(!m_pJuBao)
		{
			m_pJuBao = new CJuBao;
		}
		if(!m_pJuBao->RegCallBackFunc())
		{
			AfxMessageBox(_T("聚宝注册初始化失败!"));
			IBA_LOG0(_T("注册聚宝回调函数失败!"));
		}
		if(!m_pJuBao->InitInterface("testxzg001","610","sntestxzg001"))
		{
			AfxMessageBox(_T("聚宝初始化失败!"));
			IBA_LOG0(_T("聚宝初始化失败!"));
		}
		pTmp = GetJubaoInf();
	}

	if (CNetBarConfig::GetInstance()->GetEnableID2Reader())
	{
		HANDLE hMutex = ::CreateMutex(NULL, FALSE, _T("_ID2READER_ALLOW_MUTEX_"));
		if(hMutex == NULL)
			return;

		if(GetLastError() != ERROR_ALREADY_EXISTS)
		{
			WinExec(".\\IBABin\\ID2Reader.exe", SW_HIDE);
		}
		else
		{
			CloseHandle(hMutex);
		}
	}
	else
	{
		// 空白照片删除 QSC 2013-5-7 10:46:16
		//m_wndTaskPane.RemoveGroup(2);
		//m_wndTaskPane.m_dlgUserPhoto.ShowWindow(SW_HIDE);
	}
}
Ejemplo n.º 6
0
//============================================== This Code Assumes...	===========================
//-----------------------------------------+++--> 12pm = Noon <--> However (See Below for Details):
void OnTimerAlarm(HWND hwnd, time_t time)   // 12am = Midnight --------------------------+++-->
{
	union {
		struct {
			char fname[MAX_PATH];
			int repeat;
			SYSTEMTIME st;
		} s;
		dlgmsg_t msg;
	} u;
	#define fname_u1 u.s.fname
	#define repeat_u1 u.s.repeat
	#define st_u1 u.s.st
	#define msg_u2 u.msg
	Schedule* schedule = timetable_begin_;
	if(!schedule)
		return;
	
	if(time >= schedule->time) {
		for(; schedule && time >= schedule->time; schedule=timetable_begin_) {
			TimetableQueue(schedule, 0);
			if(schedule->id & SCHEDID_START_FLAG_) {
				switch(schedule->id) {
				case SCHEDID_CHIME:
					if(schedule->data & ALRM_BLINK)
						PostMessage(g_hwndClock, CLOCKM_BLINK, TRUE, 0);
					api.GetStr("", "JihouFile", fname_u1, sizeof(fname_u1), "");
					if(fname_u1[0]) {
						if(schedule->data & ALRM_CHIMEHR) { // chime hour
							GetLocalTime(&st_u1); // faster than localtime(&time)
							repeat_u1 = st_u1.wHour;
							if(repeat_u1 == 0)
								repeat_u1 = 12;
							else if(repeat_u1 > 12)
								repeat_u1 -= 12;
							--repeat_u1;
						} else {
							repeat_u1 = 0;
						}
						PlayFile(hwnd, fname_u1, repeat_u1);
					}
					schedule->time += 3600;
					break;
				case SCHEDID_UPDATE:
					if(!api.GetInt(NULL, UPDATE_RELEASE, 1)) {
						schedule->time = 0;
						break;
					}
					schedule->time += 86400;
					schedule->time -= schedule->data;
					schedule->data = 0;
					if(time > schedule->time)
						schedule->time = time + 86400;
					api.SetInt64(NULL, UPDATE_TIMESTAMP, schedule->time);
					api.ShellExecute(NULL, "misc\\Options", "-unotify", NULL, SW_HIDE);
					break;
#				ifdef WIN2K_COMPAT
				case SCHEDID_WIN2K:
					SetDesktopIconTextBk(1);
					schedule->time += schedule->data;
					break;
#				endif // WIN2K_COMPAT
				default:
					schedule->time = 0;
				}
			} else {
				ltoa(schedule->id+1, (g_alarmkey+ALARMKEY_OFFSET), 10);
				
				if(schedule->data & ALRM_BLINK)
					PostMessage(g_hwndClock,CLOCKM_BLINK,FALSE,0);
				if(schedule->data & ALRM_DIALOG) { // From BounceWindow.c
					AlarmGetMSG(&msg_u2);
					ReleaseTheHound(hwnd, msg_u2.name, msg_u2.message, msg_u2.settings);
				}
				api.GetStr(g_alarmkey, "File", fname_u1, sizeof(fname_u1), "");
				if(fname_u1[0]) {
					if(schedule->data & ALRM_REPEAT) {
						repeat_u1 = api.GetInt(g_alarmkey, "Times", 1) - 1;
						if(repeat_u1 < 0)
							repeat_u1 = -1;
					}else if(schedule->data & ALRM_CHIMEHR) { // chime hour
						GetLocalTime(&st_u1); // faster than localtime(&time)
						repeat_u1 = st_u1.wHour;
						if(repeat_u1 == 0)
							repeat_u1 = 12;
						else if(repeat_u1 > 12)
							repeat_u1 -= 12;
						--repeat_u1;
					}else
						repeat_u1 = 0;
					PlayFile(hwnd, fname_u1, repeat_u1);
				}
				if(schedule->data & ALRM_ONESHOT) {
					api.SetInt(g_alarmkey, "Alarm", 0);
					schedule->time = 0;
				} else {
					schedule->time = AlarmNextTimestamp();
				}
			}
			if(!schedule->time) {
				free(schedule);
			} else {
				TimetableQueue(schedule, 1);
			}
		}
		#ifndef _DEBUG
		if(IsPlaying()) {
			EmptyWorkingSet(GetCurrentProcess());
		}
		#endif
	}
}
Ejemplo n.º 7
0
/*--------------------------------------------------------
   window procedure of subclassed property sheet
---------------------------------------------------------*/
LRESULT CALLBACK SubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	LRESULT l;
  switch(message) {

	case WM_SHOWWINDOW: // adjust the window position
	  SetMyDialgPos(hwnd);
	  return FALSE; // Returning FALSE Allows it to Maintain Caret Focus
 }
	
	// default
	l = CallWindowProc(oldWndProc, hwnd, message, wParam, lParam);
	
	switch(message)
	{
		case WM_COMMAND:
		{
			WORD id;
			id = LOWORD(wParam);
			// close the window by "OK" or "Cancel"
			if(id == IDOK || id == IDCANCEL)
			{
				// MyHelp(hwnd, -1);
				startpage = (int)SendMessage(
					(HWND)SendMessage(hwnd, PSM_GETTABCONTROL, 0, 0), TCM_GETCURSEL, 0, 0);
				if(startpage < 0) startpage = 0;
				DestroyWindow(hwnd);
				g_hwndSheet = NULL;
			}
			// apply settings
			if(id == IDOK || id == 0x3021)
			{
				if(g_bApplyClock)
				{
					SendMessage(g_hwndClock, CLOCKM_REFRESHCLOCK, 0, 0);
					g_bApplyClock = FALSE;
				}
				if(g_bApplyClear)
				{
					SendMessage(g_hwndClock, CLOCKM_REFRESHCLEARTASKBAR, 0, 0);
					g_bApplyClear = FALSE;
				}
				if(g_bApplyTaskbar)
				{
					SendMessage(g_hwndClock, CLOCKM_REFRESHTASKBAR, 0, 0);
					g_bApplyTaskbar = FALSE;
				}
			}
			if(id == IDOK || id == IDCANCEL)
			{
						if(g_hDlgTimer && IsWindow(g_hDlgTimer))
							PostMessage(g_hDlgTimer, WM_CLOSE, 0, 0);
						if(g_hDlgCalender && IsWindow(g_hDlgCalender))
							PostMessage(g_hDlgCalender, WM_CLOSE, 0, 0);
			}
			EmptyWorkingSet(GetCurrentProcess());
			break;
		}
		// close by "x" button
		case WM_SYSCOMMAND:
		{
			if((wParam & 0xfff0) == SC_CLOSE)
				PostMessage(hwnd, WM_COMMAND, IDCANCEL, 0);
			break;
		}
	}
	return l;
}