ReactOS 0.4.15-dev-7788-g1ad9096
general.c File Reference
#include "precomp.h"
#include <winnls.h>
#include <powrprof.h>
#include <buildno.h>
Include dependency graph for general.c:

Go to the source code of this file.

Classes

struct  _IMGINFO
 

Macros

#define ANIM_STEP   2
 
#define ANIM_TIME   50
 
#define ID_SYSUPTIME_UPDATE_TIMER   1
 

Typedefs

typedef struct _IMGINFO IMGINFO
 
typedef struct _IMGINFOPIMGINFO
 
typedef ULONGLONG(WINAPIPFGETTICKCOUNT64) (VOID)
 

Functions

VOID ShowLastWin32Error (HWND hWndOwner)
 
static VOID InitLogo (HWND hwndDlg)
 
LRESULT CALLBACK RosImageProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID SetRegTextData (HWND hwnd, HKEY hKey, LPTSTR Value, UINT uID)
 
static INT SetProcNameString (HWND hwnd, HKEY hKey, LPTSTR Value, UINT uID1, UINT uID2)
 
static VOID MakeFloatValueString (DOUBLE *dFloatValue, LPTSTR szOutput, LPTSTR szAppend)
 
static BOOL SetProcSpeed (HWND hwnd, HKEY hKey, LPTSTR Value, UINT uID)
 
static VOID GetSystemInformation (HWND hwnd)
 
static VOID GetSystemVersion (HWND hwnd)
 
static ULONGLONG GetTickCountQPC (VOID)
 An equivalent of GetTickCount64, implemented using QueryPerformanceCounter.
 
static VOID GetSystemUptime (HWND hwndDlg)
 
static VOID InitSystemUptime (HWND hwndDlg)
 
INT_PTR CALLBACK GeneralPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static PIMGINFO pImgInfo
 
static const BLENDFUNCTION BlendFunc = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA}
 
static HMODULE hKernel32Vista = NULL
 
static PFGETTICKCOUNT64 pGetTickCount64 = NULL
 
static WCHAR szUptimeFormat [64]
 

Macro Definition Documentation

◆ ANIM_STEP

#define ANIM_STEP   2

Definition at line 18 of file general.c.

◆ ANIM_TIME

#define ANIM_TIME   50

Definition at line 19 of file general.c.

◆ ID_SYSUPTIME_UPDATE_TIMER

#define ID_SYSUPTIME_UPDATE_TIMER   1

Definition at line 20 of file general.c.

Typedef Documentation

◆ IMGINFO

◆ PFGETTICKCOUNT64

typedef ULONGLONG(WINAPI * PFGETTICKCOUNT64) (VOID)

Definition at line 31 of file general.c.

◆ PIMGINFO

Function Documentation

◆ GeneralPageProc()

INT_PTR CALLBACK GeneralPageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 691 of file general.c.

692{
695
696 switch (uMsg)
697 {
698 case WM_INITDIALOG:
699 {
701 if (pImgInfo == NULL)
702 {
703 EndDialog(hwndDlg, 0);
704 return FALSE;
705 }
706
707 InitLogo(hwndDlg);
709 GetSystemInformation(hwndDlg);
710 GetSystemVersion(hwndDlg);
711 InitSystemUptime(hwndDlg);
712 break;
713 }
714
715 case WM_DESTROY:
716 {
718
719 if (hKernel32Vista)
720 {
722 }
723
725 break;
726 }
727
728 case WM_TIMER:
729 {
731 {
732 /* Update system uptime */
733 GetSystemUptime(hwndDlg);
734 }
735
736 break;
737 }
738
739 case WM_COMMAND:
740 {
741 if (LOWORD(wParam) == IDC_LICENCE)
742 {
744
745 return TRUE;
746 }
747 break;
748 }
749
750 case WM_DRAWITEM:
751 {
753
754 if (lpDrawItem->CtlID == IDC_ROSIMG)
755 {
756 HDC hdcMem;
757 LONG left;
758
759 /* Position image in centre of dialog */
760 left = (lpDrawItem->rcItem.right - pImgInfo->cxSource) / 2;
761
762 hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
763 if (hdcMem != NULL)
764 {
766 BitBlt(lpDrawItem->hDC,
767 left,
768 lpDrawItem->rcItem.top,
769 lpDrawItem->rcItem.right - lpDrawItem->rcItem.left,
770 lpDrawItem->rcItem.bottom - lpDrawItem->rcItem.top,
771 hdcMem,
772 0,
773 0,
774 SRCCOPY);
776 }
777 }
778 return TRUE;
779 }
780
781 case WM_NOTIFY:
782 {
783 NMHDR *nmhdr = (NMHDR *)lParam;
784
785 if (nmhdr->idFrom == IDC_ROSHOMEPAGE_LINK && nmhdr->code == NM_CLICK)
786 {
787 PNMLINK nml = (PNMLINK)nmhdr;
788
789 ShellExecuteW(hwndDlg, L"open", nml->item.szUrl, NULL, NULL, SW_SHOWNORMAL);
790 }
791 break;
792 }
793
794 }
795
796 return FALSE;
797}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HINSTANCE hApplet
Definition: access.c:17
static HMODULE hKernel32Vista
Definition: general.c:35
#define ID_SYSUPTIME_UPDATE_TIMER
Definition: general.c:20
static VOID GetSystemUptime(HWND hwndDlg)
Definition: general.c:626
static PIMGINFO pImgInfo
Definition: general.c:33
static VOID GetSystemInformation(HWND hwnd)
Definition: general.c:456
LRESULT CALLBACK RosImageProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: general.c:144
static VOID GetSystemVersion(HWND hwnd)
Definition: general.c:576
static VOID InitSystemUptime(HWND hwndDlg)
Definition: general.c:661
static VOID InitLogo(HWND hwndDlg)
Definition: general.c:65
INT_PTR CALLBACK LicenceDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: licence.c:68
#define IDD_LICENCE
Definition: resource.h:225
#define IDC_LICENCE
Definition: resource.h:79
#define IDC_ROSIMG
Definition: resource.h:80
#define IDC_ROSHOMEPAGE_LINK
Definition: resource.h:81
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define FreeLibrary(x)
Definition: compat.h:748
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:49
GLint left
Definition: glext.h:7726
static HDC
Definition: imagelist.c:92
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
long LONG
Definition: pedump.c:60
struct tagNMLINK * PNMLINK
#define NM_CLICK
Definition: commctrl.h:130
#define WM_NOTIFY
Definition: richedit.h:61
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2379
INT cxSource
Definition: userinit.h:50
HBITMAP hBitmap
Definition: userinit.h:49
WCHAR szUrl[L_MAX_URL_LENGTH]
Definition: commctrl.h:4757
UINT_PTR idFrom
Definition: winuser.h:3158
UINT code
Definition: winuser.h:3159
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_WNDPROC
Definition: treelist.c:66
HDC hdcMem
Definition: welcome.c:104
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
BOOL WINAPI DeleteDC(_In_ HDC)
#define SW_SHOWNORMAL
Definition: winuser.h:770
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_DRAWITEM
Definition: winuser.h:1645
#define WM_TIMER
Definition: winuser.h:1742
#define WM_DESTROY
Definition: winuser.h:1609
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DialogBox
Definition: winuser.h:5761
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

◆ GetSystemInformation()

static VOID GetSystemInformation ( HWND  hwnd)
static

Definition at line 456 of file general.c.

457{
458 HKEY hKey;
459 TCHAR SysKey[] = _T("HARDWARE\\DESCRIPTION\\System");
460 TCHAR ProcKey[] = _T("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
461 MEMORYSTATUSEX MemStat;
462 TCHAR Buf[32];
463 WCHAR SMBiosName[96];
464 INT CurMachineLine = IDC_MACHINELINE1;
465
466 /*
467 * Get hardware device name or motherboard name
468 * using information from raw SMBIOS data
469 */
470 if (GetSystemName(SMBiosName, _countof(SMBiosName)))
471 {
472 SetDlgItemText(hwnd, CurMachineLine, SMBiosName);
473 CurMachineLine++;
474 }
475 else
476 {
477 /* If SMBIOS is not available, use System Identifier */
479 {
480 SetRegTextData(hwnd, hKey, _T("Identifier"), CurMachineLine);
481 CurMachineLine++;
483 }
484 }
485 /*
486 * Get Processor information
487 * although undocumented, this information is being pulled
488 * directly out of the registry instead of via setupapi as it
489 * contains all the info we need, and should remain static
490 */
492 {
493 INT PrevMachineLine;
494
495 SetRegTextData(hwnd, hKey, _T("VendorIdentifier"), CurMachineLine);
496 CurMachineLine++;
497
498 PrevMachineLine = CurMachineLine;
499 CurMachineLine += SetProcNameString(hwnd,
500 hKey,
501 _T("ProcessorNameString"),
502 CurMachineLine,
503 CurMachineLine + 1);
504
505 if (CurMachineLine == PrevMachineLine)
506 {
507 /* TODO: Try obtaining CPU name from WMI (i.e. CIM_Processor) */
508
509 /* Brand String is not available, use Identifier instead */
510 CurMachineLine += SetProcNameString(hwnd,
511 hKey,
512 _T("Identifier"),
513 CurMachineLine,
514 CurMachineLine + 1);
515 }
516
517 if (SetProcSpeed(hwnd, hKey, _T("~MHz"), CurMachineLine))
518 CurMachineLine++;
520 }
521
522 /* Get total physical RAM */
523 MemStat.dwLength = sizeof(MemStat);
524
525 if (GlobalMemoryStatusEx(&MemStat))
526 {
527 TCHAR szStr[32];
528 double dTotalPhys;
529
530 if (MemStat.ullTotalPhys > 1024 * 1024 * 1024)
531 {
532 UINT i = 0;
533 static const UINT uStrId[] = { IDS_GIGABYTE, IDS_TERABYTE, IDS_PETABYTE};
534
535 // We're dealing with GBs or more
536 MemStat.ullTotalPhys /= 1024 * 1024;
537
538 if (MemStat.ullTotalPhys > 1024 * 1024)
539 {
540 // We're dealing with TBs or more
541 MemStat.ullTotalPhys /= 1024;
542 i++;
543
544 if (MemStat.ullTotalPhys > 1024 * 1024)
545 {
546 // We're dealing with PBs or more
547 MemStat.ullTotalPhys /= 1024;
548 i++;
549
550 dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
551 }
552 else
553 {
554 dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
555 }
556 }
557 else
558 {
559 dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
560 }
561
562 LoadString(hApplet, uStrId[i], szStr, sizeof(szStr) / sizeof(TCHAR));
563 MakeFloatValueString(&dTotalPhys, Buf, szStr);
564 }
565 else
566 {
567 // We're dealing with MBs, don't show any decimals
568 LoadString(hApplet, IDS_MEGABYTE, szStr, sizeof(szStr) / sizeof(TCHAR));
569 wsprintf(Buf, _T("%u %s"), (UINT)MemStat.ullTotalPhys / 1024 / 1024, szStr);
570 }
571
572 SetDlgItemText(hwnd, CurMachineLine, Buf);
573 }
574}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
static VOID MakeFloatValueString(DOUBLE *dFloatValue, LPTSTR szOutput, LPTSTR szAppend)
Definition: general.c:397
static VOID SetRegTextData(HWND hwnd, HKEY hKey, LPTSTR Value, UINT uID)
Definition: general.c:313
static INT SetProcNameString(HWND hwnd, HKEY hKey, LPTSTR Value, UINT uID1, UINT uID2)
Definition: general.c:333
static BOOL SetProcSpeed(HWND hwnd, HKEY hKey, LPTSTR Value, UINT uID)
Definition: general.c:415
BOOL GetSystemName(PWSTR pBuf, SIZE_T cchBuf)
Definition: smbios.c:490
#define IDS_TERABYTE
Definition: resource.h:22
#define IDC_MACHINELINE1
Definition: resource.h:73
#define IDS_MEGABYTE
Definition: resource.h:20
#define IDS_PETABYTE
Definition: resource.h:23
#define IDS_GIGABYTE
Definition: resource.h:21
FxAutoRegKey hKey
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOL NTAPI GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
Definition: heapmem.c:1272
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
unsigned int UINT
Definition: ndis.h:50
#define KEY_READ
Definition: nt_native.h:1023
#define _countof(array)
Definition: sndvol32.h:68
int32_t INT
Definition: typedefs.h:58
#define _T(x)
Definition: vfdio.h:22
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegOpenKeyEx
Definition: winreg.h:520
#define wsprintf
Definition: winuser.h:5865
#define LoadString
Definition: winuser.h:5819
#define SetDlgItemText
Definition: winuser.h:5849
char TCHAR
Definition: xmlstorage.h:189
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by GeneralPageProc().

◆ GetSystemUptime()

static VOID GetSystemUptime ( HWND  hwndDlg)
static

Definition at line 626 of file general.c.

627{
628 HWND hUptimeLabel;
629 ULONGLONG cMilliseconds;
630 ULONG cSeconds;
631 WCHAR szBuf[64];
632
633 hUptimeLabel = GetDlgItem(hwndDlg, IDC_UPTIME);
634 if (!hUptimeLabel)
635 {
636 return;
637 }
638
639 if (pGetTickCount64)
640 {
641 cMilliseconds = pGetTickCount64();
642 }
643 else
644 {
645 cMilliseconds = GetTickCountQPC();
646 }
647
648 cSeconds = cMilliseconds / 1000;
650 cSeconds / (60*60*24), // Days
651 (cSeconds / (60*60)) % 24, // Hours
652 (cSeconds / 60) % 60, // Minutes
653 cSeconds % 60); // Seconds
654
655 SetWindowTextW(hUptimeLabel, szBuf);
656
657 /* Set update timer (reset timeout if the timer exists) */
658 SetTimer(hwndDlg, ID_SYSUPTIME_UPDATE_TIMER, 1000 - (cMilliseconds % 1000), NULL);
659}
static PFGETTICKCOUNT64 pGetTickCount64
Definition: general.c:36
static ULONGLONG GetTickCountQPC(VOID)
An equivalent of GetTickCount64, implemented using QueryPerformanceCounter.
Definition: general.c:616
static WCHAR szUptimeFormat[64]
Definition: general.c:37
#define IDC_UPTIME
Definition: resource.h:83
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)

Referenced by GeneralPageProc(), and InitSystemUptime().

◆ GetSystemVersion()

static VOID GetSystemVersion ( HWND  hwnd)
static

Definition at line 576 of file general.c.

577{
578 HWND hRosVersion;
579 SIZE_T lenStr, lenVersion;
580 PCWSTR pwszVersion = L" " TEXT(KERNEL_VERSION_RC);
581 PWSTR pwszStr;
582
583 lenVersion = wcslen(pwszVersion);
584 if (lenVersion == 0)
585 {
586 return;
587 }
588
589 hRosVersion = GetDlgItem(hwnd, IDC_ROSVERSION);
590 if (!hRosVersion)
591 {
592 return;
593 }
594 lenStr = GetWindowTextLengthW(hRosVersion);
595 lenStr += lenVersion + 1;
596 pwszStr = HeapAlloc(GetProcessHeap(), 0, lenStr * sizeof(WCHAR));
597 if (!pwszStr)
598 {
599 return;
600 }
601 GetWindowText(hRosVersion, pwszStr, lenStr);
602
603 StringCchCatW(pwszStr, lenStr, pwszVersion);
604 SetWindowText(hRosVersion, pwszStr);
605
606 HeapFree(GetProcessHeap(), 0, pwszStr);
607}
#define IDC_ROSVERSION
Definition: resource.h:82
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define TEXT(s)
Definition: k32.h:26
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define GetWindowText
Definition: winuser.h:5798
#define SetWindowText
Definition: winuser.h:5857

Referenced by DECLARE_INTERFACE_(), and GeneralPageProc().

◆ GetTickCountQPC()

static ULONGLONG GetTickCountQPC ( VOID  )
static

An equivalent of GetTickCount64, implemented using QueryPerformanceCounter.

Returns
The number of milliseconds that have elapsed since the system was started.

Definition at line 616 of file general.c.

617{
619
622
623 return (Counter.QuadPart * 1000) / Frequency.QuadPart;
624}
BOOL WINAPI QueryPerformanceFrequency(OUT PLARGE_INTEGER lpFrequency)
Definition: perfcnt.c:45
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
Definition: perfcnt.c:23
static LARGE_INTEGER Frequency
Definition: clock.c:41
static LARGE_INTEGER Counter
Definition: clock.c:43
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by GetSystemUptime().

◆ InitLogo()

static VOID InitLogo ( HWND  hwndDlg)
static

Definition at line 65 of file general.c.

66{
67 BITMAP logoBitmap;
68 BITMAP maskBitmap;
70 HDC hDC, hDCLogo, hDCMask;
71 HBITMAP hMask = NULL, hLogo = NULL;
72 HBITMAP hAlphaLogo = NULL;
73 COLORREF *pBits;
75
76 hDC = GetDC(hwndDlg);
77 hDCLogo = CreateCompatibleDC(NULL);
78 hDCMask = CreateCompatibleDC(NULL);
79
80 if (hDC == NULL || hDCLogo == NULL || hDCMask == NULL)
81 goto Cleanup;
82
83 ZeroMemory(pImgInfo, sizeof(*pImgInfo));
84 ZeroMemory(&bmpi, sizeof(bmpi));
85
88
89 if (hLogo == NULL || hMask == NULL)
90 goto Cleanup;
91
92 GetObject(hLogo, sizeof(logoBitmap), &logoBitmap);
93 GetObject(hMask, sizeof(maskBitmap), &maskBitmap);
94
95 if (logoBitmap.bmHeight != maskBitmap.bmHeight || logoBitmap.bmWidth != maskBitmap.bmWidth)
96 goto Cleanup;
97
99 bmpi.bmiHeader.biWidth = logoBitmap.bmWidth;
100 bmpi.bmiHeader.biHeight = logoBitmap.bmHeight;
104 bmpi.bmiHeader.biSizeImage = 4 * logoBitmap.bmWidth * logoBitmap.bmHeight;
105
106 /* Create a premultiplied bitmap */
107 hAlphaLogo = CreateDIBSection(hDC, &bmpi, DIB_RGB_COLORS, (PVOID*)&pBits, 0, 0);
108 if (!hAlphaLogo)
109 goto Cleanup;
110
111 SelectObject(hDCLogo, hLogo);
112 SelectObject(hDCMask, hMask);
113
114 for (line = logoBitmap.bmHeight - 1; line >= 0; line--)
115 {
116 for (column = 0; column < logoBitmap.bmWidth; column++)
117 {
118 COLORREF alpha = GetPixel(hDCMask, column, line) & 0xFF;
119 COLORREF Color = GetPixel(hDCLogo, column, line);
120 DWORD r, g, b;
121
122 r = GetRValue(Color) * alpha / 255;
123 g = GetGValue(Color) * alpha / 255;
124 b = GetBValue(Color) * alpha / 255;
125
126 *pBits++ = b | (g << 8) | (r << 16) | (alpha << 24);
127 }
128 }
129
130 pImgInfo->hBitmap = hAlphaLogo;
131 pImgInfo->cxSource = logoBitmap.bmWidth;
132 pImgInfo->cySource = logoBitmap.bmHeight;
133 pImgInfo->iBits = logoBitmap.bmBitsPixel;
134 pImgInfo->iPlanes = logoBitmap.bmPlanes;
135
136Cleanup:
137 if (hMask != NULL) DeleteObject(hMask);
138 if (hLogo != NULL) DeleteObject(hLogo);
139 if (hDCMask != NULL) DeleteDC(hDCMask);
140 if (hDCLogo != NULL) DeleteDC(hDCLogo);
141 if (hDC != NULL) ReleaseDC(hwndDlg, hDC);
142}
static HDC hDC
Definition: 3dtext.c:33
#define IDB_ROSMASK
Definition: resource.h:7
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
#define IDB_ROSBMP
Definition: resource.h:14
static const WCHAR Cleanup[]
Definition: register.c:80
#define BI_RGB
Definition: precomp.h:47
#define GetBValue(quad)
Definition: precomp.h:66
#define GetGValue(quad)
Definition: precomp.h:65
#define GetRValue(quad)
Definition: precomp.h:64
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean g
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
BITMAPINFO bmpi
Definition: alphablend.c:68
static HBITMAP
Definition: button.c:44
Definition: bl.h:1331
INT iPlanes
Definition: userinit.h:52
INT iBits
Definition: userinit.h:53
INT cySource
Definition: userinit.h:51
Definition: parser.c:49
USHORT biBitCount
Definition: precomp.h:37
ULONG biCompression
Definition: precomp.h:38
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define ZeroMemory
Definition: winbase.h:1712
DWORD COLORREF
Definition: windef.h:300
#define DIB_RGB_COLORS
Definition: wingdi.h:367
struct tagBITMAPINFO BITMAPINFO
#define GetObject
Definition: wingdi.h:4468
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define IMAGE_BITMAP
Definition: winuser.h:211
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2203
HDC WINAPI GetDC(_In_opt_ HWND)
#define LR_DEFAULTCOLOR
Definition: winuser.h:1087
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by GeneralPageProc().

◆ InitSystemUptime()

static VOID InitSystemUptime ( HWND  hwndDlg)
static

Definition at line 661 of file general.c.

662{
664
665 /* Load time format string */
667 {
668 return;
669 }
670
671 /* Load required DLLs */
672 hKernel32 = GetModuleHandleW(L"kernel32.dll");
673 if (hKernel32)
674 {
676 if (!pGetTickCount64)
677 {
678 hKernel32Vista = LoadLibraryW(L"kernel32_vista.dll");
679 if (hKernel32Vista)
680 {
682 }
683 }
684 }
685
686 /* Show system uptime and set update timer */
687 GetSystemUptime(hwndDlg);
688}
ULONGLONG(WINAPI * PFGETTICKCOUNT64)(VOID)
Definition: general.c:31
#define IDS_UPTIME_FORMAT
Definition: resource.h:65
#define GetProcAddress(x, y)
Definition: compat.h:753
#define LoadLibraryW(x)
Definition: compat.h:747
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HANDLE hKernel32
Definition: locale.c:13
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)

Referenced by GeneralPageProc().

◆ MakeFloatValueString()

static VOID MakeFloatValueString ( DOUBLE dFloatValue,
LPTSTR  szOutput,
LPTSTR  szAppend 
)
static

Definition at line 397 of file general.c.

398{
399 TCHAR szDecimalSeparator[4];
400
401 /* Get the decimal separator for the current locale */
402 if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, szDecimalSeparator, sizeof(szDecimalSeparator) / sizeof(TCHAR)) > 0)
403 {
404 UCHAR uDecimals;
405 UINT uIntegral;
406
407 /* Show the value with two decimals */
408 uIntegral = (UINT)*dFloatValue;
409 uDecimals = (UCHAR)((UINT)(*dFloatValue * 100) - uIntegral * 100);
410
411 wsprintf(szOutput, _T("%u%s%02u %s"), uIntegral, szDecimalSeparator, uDecimals, szAppend);
412 }
413}
#define LOCALE_USER_DEFAULT
#define LOCALE_SDECIMAL
Definition: winnls.h:42
#define GetLocaleInfo
Definition: winnls.h:1186
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by GetSystemInformation(), and SetProcSpeed().

◆ RosImageProc()

LRESULT CALLBACK RosImageProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 144 of file general.c.

145{
146 static UINT timerid = 0, top = 0, offset;
147 static HBITMAP hCreditsBitmap;
148
149 switch (uMsg)
150 {
151 case WM_LBUTTONDBLCLK:
152 if (wParam & (MK_CONTROL | MK_SHIFT))
153 {
154 if (timerid == 0)
155 {
156 HDC hDC;
157 HDC hCreditsDC = NULL, hLogoDC = NULL;
158 HFONT hFont = NULL;
159 NONCLIENTMETRICS ncm;
160 RECT rcCredits;
161 TCHAR szCredits[2048];
162 INT iDevsHeight;
163
164 hDC = GetDC(NULL);
165 if (hDC == NULL)
166 goto Cleanup;
167
168 top = 0;
169 offset = 0;
170
171 hCreditsDC = CreateCompatibleDC(hDC);
172 hLogoDC = CreateCompatibleDC(hCreditsDC);
173
174 if (hCreditsDC == NULL || hLogoDC == NULL)
175 goto Cleanup;
176
177 SetRect(&rcCredits, 0, 0, 0, 0);
178
179 ncm.cbSize = sizeof(NONCLIENTMETRICS);
180 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0);
181
182 hFont = CreateFontIndirect(&ncm.lfMessageFont);
183 if (!hFont)
184 goto Cleanup;
185 SelectObject(hCreditsDC, hFont);
186
187 LoadString(hApplet, IDS_DEVS, szCredits, sizeof(szCredits) / sizeof(TCHAR));
188 DrawText(hCreditsDC, szCredits, -1, &rcCredits, DT_CALCRECT);
189
190 iDevsHeight = rcCredits.bottom - rcCredits.top;
191
192 hCreditsBitmap = CreateBitmap(pImgInfo->cxSource, (2 * pImgInfo->cySource) + iDevsHeight + 1, pImgInfo->iPlanes, pImgInfo->iBits, NULL);
193 if (!hCreditsBitmap)
194 goto Cleanup;
195
196 SelectObject(hLogoDC, pImgInfo->hBitmap);
197 SelectObject(hCreditsDC, hCreditsBitmap);
198
200
201 SetRect(&rcCredits, 0, 0, pImgInfo->cxSource, (2 * pImgInfo->cySource) + iDevsHeight + 1);
202 FillRect(hCreditsDC, &rcCredits, GetSysColorBrush(COLOR_3DFACE));
203
204 SetRect(&rcCredits, 0, offset, pImgInfo->cxSource, offset + iDevsHeight + 1);
205 SetBkMode(hCreditsDC, TRANSPARENT);
206
207 OffsetRect(&rcCredits, 1, 1);
209 DrawText(hCreditsDC, szCredits, -1, &rcCredits, DT_CENTER);
210
211 OffsetRect(&rcCredits, -1, -1);
213 DrawText(hCreditsDC, szCredits, -1, &rcCredits, DT_CENTER);
214
215 offset += iDevsHeight;
216
217 AlphaBlend(hCreditsDC, 0, 0, pImgInfo->cxSource, pImgInfo->cySource, hLogoDC, 0, 0, pImgInfo->cxSource, pImgInfo->cySource, BlendFunc);
219
220 timerid = SetTimer(hwnd, 1, ANIM_TIME, NULL);
221
222Cleanup:
223 if (hFont != NULL) DeleteObject(hFont);
224 if (hLogoDC != NULL) DeleteDC(hLogoDC);
225 if (hCreditsDC != NULL) DeleteDC(hCreditsDC);
226 if (hDC != NULL) ReleaseDC(NULL, hDC);
227 }
228 }
229 break;
230 case WM_LBUTTONDOWN:
231 if (timerid)
232 {
233 RECT rcCredits;
234 HDC hDC = GetDC(hwnd);
235 if (hDC != NULL)
236 {
237 GetClientRect(hwnd, &rcCredits);
238 SetRect(&rcCredits, 0, 0, rcCredits.right, pImgInfo->cySource);
241 }
242 KillTimer(hwnd, timerid);
243 if (hCreditsBitmap != NULL)
244 DeleteObject(hCreditsBitmap);
245
247 top = 0;
248 timerid = 0;
249 }
250 break;
251 case WM_TIMER:
252 top += ANIM_STEP;
253
254 if (top > offset)
255 {
256 RECT rcCredits;
257 HDC hDC = GetDC(hwnd);
258 if (hDC != NULL)
259 {
260 GetClientRect(hwnd, &rcCredits);
261 SetRect(&rcCredits, 0, 0, rcCredits.right, pImgInfo->cySource);
264 }
265 KillTimer(hwnd, timerid);
266 if (hCreditsBitmap != NULL)
267 DeleteObject(hCreditsBitmap);
268
269 top = 0;
270 timerid = 0;
271 }
272
274 break;
275 case WM_PAINT:
276 {
278 HDC hdcMem, hdc;
279 LONG left;
280
281 hdc = wParam != 0 ? (HDC)wParam : BeginPaint(hwnd, &PS);
282
283 GetClientRect(hwnd, &PS.rcPaint);
284
285 /* Position image in center of dialog */
286 left = (PS.rcPaint.right - pImgInfo->cxSource) / 2;
288
289 if (hdcMem != NULL)
290 {
291 if(timerid != 0)
292 {
293 SelectObject(hdcMem, hCreditsBitmap);
294 BitBlt(hdc, left, PS.rcPaint.top, PS.rcPaint.right - PS.rcPaint.left, PS.rcPaint.top + pImgInfo->cySource, hdcMem, 0, top, SRCCOPY);
295 }
296 else
297 {
300 }
301
303 }
304
305 if (wParam == 0)
306 EndPaint(hwnd,&PS);
307 break;
308 }
309 }
310 return TRUE;
311}
HFONT hFont
Definition: main.c:53
#define ANIM_TIME
Definition: general.c:19
static const BLENDFUNCTION BlendFunc
Definition: general.c:34
#define ANIM_STEP
Definition: general.c:18
#define IDS_DEVS
Definition: resource.h:230
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLintptr offset
Definition: glext.h:5920
@ PS
HDC hdc
Definition: main.c:9
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define AlphaBlend
Definition: misc.c:293
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
#define TRANSPARENT
Definition: wingdi.h:950
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
#define CreateFontIndirect
Definition: wingdi.h:4444
#define WM_PAINT
Definition: winuser.h:1620
DWORD WINAPI GetSysColor(_In_ int)
#define MK_SHIFT
Definition: winuser.h:2369
#define DT_CENTER
Definition: winuser.h:527
#define COLOR_WINDOWTEXT
Definition: winuser.h:921
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1778
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
#define DrawText
Definition: winuser.h:5771
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define MK_CONTROL
Definition: winuser.h:2370
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define COLOR_BTNSHADOW
Definition: winuser.h:930
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define DT_CALCRECT
Definition: winuser.h:526
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define SystemParametersInfo
Definition: winuser.h:5858
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define COLOR_3DFACE
Definition: winuser.h:929

Referenced by GeneralPageProc().

◆ SetProcNameString()

static INT SetProcNameString ( HWND  hwnd,
HKEY  hKey,
LPTSTR  Value,
UINT  uID1,
UINT  uID2 
)
static

Definition at line 333 of file general.c.

334{
335 LPTSTR lpBuf = NULL;
336 DWORD BufSize = 0;
337 DWORD Type;
338 INT Ret = 0;
339 TCHAR szBuf[31];
340 TCHAR* szLastSpace;
341 INT LastSpace = 0;
342
344 {
345 lpBuf = HeapAlloc(GetProcessHeap(), 0, BufSize);
346
347 if (!lpBuf)
348 return 0;
349
351 {
352 if (BufSize > ((30 + 1) * sizeof(TCHAR)))
353 {
354 /* Wrap the Processor Name String like XP does: *
355 * - Take the first 30 characters and look for the last space. *
356 * Then wrap the string after this space. *
357 * - If no space is found, wrap the string after character 30. *
358 * *
359 * For example the Processor Name String of a Pentium 4 is right-aligned. *
360 * With this wrapping the first line looks centered. */
361
362 _tcsncpy(szBuf, lpBuf, 30);
363 szBuf[30] = 0;
364 szLastSpace = _tcsrchr(szBuf, ' ');
365
366 if (szLastSpace == 0)
367 {
368 LastSpace = 30;
369 }
370 else
371 {
372 LastSpace = (szLastSpace - szBuf);
373 szBuf[LastSpace] = 0;
374 }
375
376 _tcsncpy(szBuf, lpBuf, LastSpace);
377
378 SetDlgItemText(hwnd, uID1, szBuf);
379 SetDlgItemText(hwnd, uID2, lpBuf+LastSpace+1);
380
381 /* Return the number of used lines */
382 Ret = 2;
383 }
384 else
385 {
386 SetDlgItemText(hwnd, uID1, lpBuf);
387 Ret = 1;
388 }
389 }
390
391 HeapFree(GetProcessHeap(), 0, lpBuf);
392 }
393
394 return Ret;
395}
#define BufSize
Definition: FsRtlTunnel.c:28
Type
Definition: Type.h:7
#define _tcsncpy
Definition: tchar.h:1410
#define _tcsrchr
Definition: utility.h:116
BYTE * PBYTE
Definition: pedump.c:66
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define RegQueryValueEx
Definition: winreg.h:524
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by GetSystemInformation().

◆ SetProcSpeed()

static BOOL SetProcSpeed ( HWND  hwnd,
HKEY  hKey,
LPTSTR  Value,
UINT  uID 
)
static

Definition at line 415 of file general.c.

416{
417 TCHAR szBuf[64], szHz[16];
418 DWORD BufSize = sizeof(DWORD);
419 DWORD Type = REG_SZ;
421
422 ZeroMemory(&ppi, sizeof(ppi));
423
425 NULL,
426 0,
427 (PVOID)&ppi,
428 sizeof(ppi)) == STATUS_SUCCESS &&
429 ppi.CurrentMhz != 0) || RegQueryValueEx(hKey, Value, NULL, &Type, (PBYTE)&ppi.CurrentMhz, &BufSize) == ERROR_SUCCESS)
430 {
431 if (ppi.CurrentMhz < 1000)
432 {
433 if (!LoadString(hApplet, IDS_MEGAHERTZ, szHz, _countof(szHz)))
434 {
435 return FALSE;
436 }
437 StringCchPrintf(szBuf, _countof(szBuf), _T("%lu %s"), ppi.CurrentMhz, szHz);
438 }
439 else
440 {
441 double flt = ppi.CurrentMhz / 1000.0;
442 if (!LoadString(hApplet, IDS_GIGAHERTZ, szHz, _countof(szHz)))
443 {
444 return FALSE;
445 }
446 MakeFloatValueString(&flt, szBuf, szHz);
447 }
448
449 SetDlgItemText(hwnd, uID, szBuf);
450 return TRUE;
451 }
452
453 return FALSE;
454}
#define IDS_MEGAHERTZ
Definition: resource.h:62
#define IDS_GIGAHERTZ
Definition: resource.h:63
#define REG_SZ
Definition: layer.c:22
#define DWORD
Definition: nt_native.h:44
@ ProcessorInformation
Definition: ntpoapi.h:78
NTSTATUS WINAPI CallNtPowerInformation(POWER_INFORMATION_LEVEL InformationLevel, PVOID lpInputBuffer, ULONG nInputBufferSize, PVOID lpOutputBuffer, ULONG nOutputBufferSize)
Definition: powrprof.c:59
#define STATUS_SUCCESS
Definition: shellext.h:65
#define StringCchPrintf
Definition: strsafe.h:517

Referenced by GetSystemInformation().

◆ SetRegTextData()

static VOID SetRegTextData ( HWND  hwnd,
HKEY  hKey,
LPTSTR  Value,
UINT  uID 
)
static

Definition at line 313 of file general.c.

314{
315 LPTSTR lpBuf = NULL;
316 DWORD BufSize = 0;
317 DWORD Type;
318
320 {
321 lpBuf = HeapAlloc(GetProcessHeap(), 0, BufSize);
322
323 if (!lpBuf)
324 return;
325
327 SetDlgItemText(hwnd, uID, lpBuf);
328
329 HeapFree(GetProcessHeap(), 0, lpBuf);
330 }
331}

Referenced by GetSystemInformation().

◆ ShowLastWin32Error()

VOID ShowLastWin32Error ( HWND  hWndOwner)

Definition at line 39 of file general.c.

40{
41 LPTSTR lpMsg;
42 DWORD LastError;
43
44 LastError = GetLastError();
45 if (LastError == ERROR_SUCCESS)
46 return;
47
51 NULL,
52 LastError,
54 (LPTSTR)&lpMsg,
55 0, NULL))
56 {
57 return;
58 }
59
60 MessageBox(hWndOwner, lpMsg, NULL, MB_OK | MB_ICONERROR);
61 LocalFree(lpMsg);
62}
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50
#define FormatMessage
Definition: winbase.h:3730
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:420
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:419
#define MB_ICONERROR
Definition: winuser.h:787
#define MB_OK
Definition: winuser.h:790
#define MessageBox
Definition: winuser.h:5822

Variable Documentation

◆ BlendFunc

◆ hKernel32Vista

HMODULE hKernel32Vista = NULL
static

Definition at line 35 of file general.c.

Referenced by GeneralPageProc(), and InitSystemUptime().

◆ pGetTickCount64

PFGETTICKCOUNT64 pGetTickCount64 = NULL
static

Definition at line 36 of file general.c.

Referenced by GetSeconds(), GetSystemUptime(), and InitSystemUptime().

◆ pImgInfo

PIMGINFO pImgInfo
static

Definition at line 33 of file general.c.

Referenced by GeneralPageProc(), InitLogo(), and RosImageProc().

◆ szUptimeFormat

WCHAR szUptimeFormat[64]
static

Definition at line 37 of file general.c.

Referenced by GetSystemUptime(), and InitSystemUptime().