CBenchmark() { for (dword i = 0; i < 4; i++) m_PerfData[i] = 0; m_SurfID = CreateSurface(300, 200, 256, 256 + 16); FillSurface(m_SurfID, 0xFFFFFFFF); DrawFrameRect(m_SurfID, 0, 0, 256, 256 + 16, 0xFF808080); ShowSurface(m_SurfID); KeEnableNotification(Nf_VirtualKey); KeEnableNotification(NfKe_TerminateProcess); double T = 0.0; dword FPS = 0; dword T1 = KeGetTime(); for (;;) { for (dword i = 0; i < 6; i++) DrawIter(T - 4.0 * (5 - i), 0xFFFFFFFF); T += 1.0; for (dword i = 0; i < 6; i++) DrawIter(T - 4.0 * (5 - i), 0x004070FF | (((i + 1) * 0x10) << 24)); WaitRedraw(); FPS++; dword T2 = KeGetTime(); if (T2 - T1 >= 1000) { dword AvgFPS = AddPerfData(FPS); T1 = T2; FPS = 0; ShowStat(AvgFPS); } CNotification<4> Nf; dword NfCount = KeGetNotificationCount(); for (dword i = 0; i < NfCount; i++) { Nf.Recv(); if (Nf.GetID() == Nf_VirtualKey) { if (Nf.GetByte(0) == VK_Esc) return; } else if (Nf.GetID() == NfKe_TerminateProcess) return; } } }
//------------------------------------------------------------ // rvMonsterBossBuddy::AdjustShieldState //------------------------------------------------------------ void rvMonsterBossBuddy::AdjustShieldState( bool becomeShielded ) { // only do the work for adjusting the state when it doesn't match our current state if ( !mIsShielded && becomeShielded ) { // Activate Shields! ShowSurface( "models/monsters/bossbuddy/forcefield" ); StartSound( "snd_enable_shields", SND_CHANNEL_ANY, 0, false, NULL ); gameLocal.GetLocalPlayer()->hud->HandleNamedEvent( "showBossShieldBar" ); } else if ( mIsShielded && !becomeShielded ) { // Deactivate Shields! HideSurface( "models/monsters/bossbuddy/forcefield" ); StartSound ( "snd_disable_shields", SND_CHANNEL_ANY, 0, false, NULL ); // gameLocal.GetLocalPlayer()->hud->HandleNamedEvent( "hideBossShieldBar" ); } mIsShielded = becomeShielded; }
CProcInfo() { KeWaitForSymbol(Sm_InitStage2); m_TickCount = 0; m_KernelTime = 0; m_VisualProgressIndex = 6; m_SurfaceActivated = true; m_X = 20; m_Y = 20; m_Width = 236; m_Height = m_Margin * 4 + (m_VisibleProcCount + 4) * m_FontH; char Digit = '0'; KeRequestCall(ClFont_GetTextWidth, PB(&Digit), 1, PB(&m_DigitW), 4); m_SurfaceID = CreateSurface(m_X, m_Y, m_Width, m_Height); DrawActiveBorder(); DrawRect(m_SurfaceID, 1, 1, m_Width - 2, m_Margin * 3 + m_FontH * 4 - 1, m_BGColor); OutText(m_SurfaceID, m_Margin, m_Margin + m_FontH * 0, 0xFFA020A0, "Page Usage:"); OutText(m_SurfaceID, m_Margin, m_Margin + m_FontH * 1, 0xFFA020A0, "Heap Usage:"); OutText(m_SurfaceID, m_Margin, m_Margin + m_FontH * 2, 0xFFA020A0, "Kernel Time:"); OutText(m_SurfaceID, m_Margin+4, m_Margin*2 + m_FontH * 3, 0xFF2020A0, "ID"); OutText(m_SurfaceID, m_Margin+18, m_Margin*2 + m_FontH * 3, 0xFF20A020, "Mem"); OutText(m_SurfaceID, m_Margin+52, m_Margin*2 + m_FontH * 3, 0xFFA0A020, "Nf"); OutText(m_SurfaceID, m_Margin+74, m_Margin*2 + m_FontH * 3, 0xFF20A0A0, "Usr"); OutText(m_SurfaceID, m_Margin+104, m_Margin*2 + m_FontH * 3, 0xFF20A0A0, "Krn"); OutText(m_SurfaceID, m_Margin+128, m_Margin*2 + m_FontH * 3, 0xFFA02020, "Name"); KeEnableNotification(NfKe_TimerTick); KeEnableNotification(Nf_SurfaceActivated); KeEnableNotification(NfKe_TerminateProcess); CNotification<4> N; for (;;) { KeWaitFor(1); N.Recv(); if (N.GetID() == Nf_SurfaceActivated) { dword activatedSurfaceID = N.GetDword(0); if (activatedSurfaceID == m_SurfaceID) { if (!m_SurfaceActivated) { m_SurfaceActivated = true; DrawActiveBorder(); } } else { if (m_SurfaceActivated) { m_SurfaceActivated = false; DrawActiveBorder(); } } } else if (N.GetID() == NfKe_TimerTick) { if (m_TickCount % 144 == 0) { m_ProcList.Clear(); CProcData PD; char Name[128]; dword PrevPID = 0; for (;;) { dword PID = KeGetNextProcessInfo(PrevPID, PD.m_UsedPageCount, PD.m_NotificationCount, PD.m_UserPerfData, PD.m_KernelPerfData, Name); if (PID == 0xFFFFFFFF) break; PD.m_PID = PID; PD.m_Name = CStringA(Name); m_ProcList.PushBack(PD); PrevPID = PID; } qword UserTotalG = 0; qword KernelTotalG = 0; for (dword i = 0; i < m_ProcList.Size(); i++) { qword UserTotalL = 0; qword KernelTotalL = 0; for (dword j = 0; j < 128; j++) { UserTotalL += m_ProcList[i].m_UserPerfData[j]; KernelTotalL += m_ProcList[i].m_KernelPerfData[j]; } m_ProcList[i].m_UserTotal = UserTotalL; m_ProcList[i].m_KernelTotal = KernelTotalL; UserTotalG += UserTotalL; KernelTotalG += KernelTotalL; } for (dword i = 0; i < m_ProcList.Size(); i++) { m_ProcList[i].m_UserPercent = (m_ProcList[i].m_UserTotal << 16) / UserTotalG; m_ProcList[i].m_KernelPercent = (m_ProcList[i].m_KernelTotal << 16) / KernelTotalG; } m_KernelTime = (KernelTotalG << 16) / (KernelTotalG + UserTotalG); DrawRect(m_SurfaceID, 1, m_Margin * 3 + m_FontH * 4, m_Width - 2, m_Height - (m_Margin * 3 + m_FontH * 4) - 1, m_BGColor); dword VisibleProcCount = m_ProcList.Size(); if (VisibleProcCount > m_VisibleProcCount) VisibleProcCount = m_VisibleProcCount; for (dword i = 0; i < VisibleProcCount; i++) { char CharBuf[5] = {0}; dword XOffset = m_Margin + 14; dword YOffset = m_Margin * 3 + m_FontH * (4 + i); OutDecimal(XOffset, YOffset, m_ProcList[i].m_PID, 0xFF2020A0); XOffset += 24; OutDecimal(XOffset, YOffset, m_ProcList[i].m_UsedPageCount, 0xFF20A020); XOffset += 22; OutDecimal(XOffset, YOffset, m_ProcList[i].m_NotificationCount, 0xFFA0A020); XOffset += 0; OutPercent(XOffset, YOffset, m_ProcList[i].m_UserPercent, 0xFF20A0A0); XOffset += 32; OutPercent(XOffset, YOffset, m_ProcList[i].m_KernelPercent, 0xFF20A0A0); XOffset += 36; OutText(m_SurfaceID, XOffset, YOffset, 0xFFA02020, m_ProcList[i].m_Name._ptr()); } } if (m_TickCount % 24 == 0) { dword HeapUsed; dword HeapTotal; dword PageUsed; dword PageTotal; KeGetMemInfo(HeapUsed, HeapTotal, PageUsed, PageTotal); dword PageUsage = dword((qword(PageUsed) * 0x10000) / PageTotal); dword HeapUsage = dword((qword(HeapUsed) * 0x10000) / HeapTotal); dword KernelTime = 0; dword HeapColor = 0xFF20A0A0; if (HeapUsage > 0x9999) HeapColor = 0xFFF8BF16; if (HeapUsage > 0xB333) HeapColor = 0xFFFA5914; DrawRect(m_SurfaceID, m_Margin + 74, m_Margin, 48, m_FontH * 3, m_BGColor); OutPercent(m_Margin + 74, m_Margin + m_FontH * 0, PageUsage, 0xFF20A0A0, true); OutPercent(m_Margin + 74, m_Margin + m_FontH * 1, HeapUsage, HeapColor, true); OutPercent(m_Margin + 74, m_Margin + m_FontH * 2, m_KernelTime, 0xFF20A0A0, true); dword PrevVP = m_VisualProgressIndex; m_VisualProgressIndex++; if (m_VisualProgressIndex >= 6) m_VisualProgressIndex = 0; dword C1 = 0xFFB0B8FF; dword C2 = 0xFFD0D4FF; if (m_VisualProgressIndex == 0) { C1 = 0xFFFFA393; C2 = 0xFFFFCCC4; } DrawRect(m_SurfaceID, 140 + PrevVP * 12, m_FontH + m_Margin + 4, 8, 8, m_BGColor); DrawRect(m_SurfaceID, 140 + m_VisualProgressIndex * 12, m_FontH + m_Margin + 4, 8, 8, C1); DrawRect(m_SurfaceID, 140 + m_VisualProgressIndex * 12 + 1, m_FontH + m_Margin + 4 + 1, 6, 6, C2); } if (m_TickCount == 0) { ShowSurface(m_SurfaceID); } m_TickCount++; } else if (N.GetID() == NfKe_TerminateProcess) { return; } } }