[UTILMAN] Properly annotate some variables (#2561)

Previously the code had a mixture of 'sz', 'wsz', 'lp' and 'lpwsz' Hungarian annotation prefixes which could bring confusions about the nature of the annotated variables. From now on all of these variables have a well defined annotation. Furthermore, add a missing argument annotation to LaunchProcess().
This commit is contained in:
Bișoc George 2020-04-26 14:14:17 +02:00 committed by GitHub
parent f44cb6de96
commit e4f70e5434
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 60 additions and 60 deletions

View file

@ -43,11 +43,11 @@ INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
WCHAR wszAppPath[MAX_BUFFER]; WCHAR szAppPath[MAX_BUFFER];
/* Extract the icon resource from the executable process */ /* Extract the icon resource from the executable process */
GetModuleFileNameW(NULL, wszAppPath, _countof(wszAppPath)); GetModuleFileNameW(NULL, szAppPath, _countof(szAppPath));
Globals.hIcon = ExtractIconW(Globals.hInstance, wszAppPath, 0); Globals.hIcon = ExtractIconW(Globals.hInstance, szAppPath, 0);
/* Set the icon within the dialog's title bar */ /* Set the icon within the dialog's title bar */
if (Globals.hIcon) if (Globals.hIcon)

View file

@ -16,14 +16,14 @@
* *
* Returns the process executable ID based on the given executable name. * Returns the process executable ID based on the given executable name.
* *
* @param[in] lpProcessName * @param[in] lpszProcessName
* The name of the executable process. * The name of the executable process.
* *
* @return * @return
* Returns the ID number of the process, otherwise 0. * Returns the ID number of the process, otherwise 0.
* *
*/ */
DWORD GetProcessID(IN LPCWSTR lpProcessName) DWORD GetProcessID(IN LPCWSTR lpszProcessName)
{ {
PROCESSENTRY32W Process; PROCESSENTRY32W Process;
@ -41,7 +41,7 @@ DWORD GetProcessID(IN LPCWSTR lpProcessName)
{ {
do do
{ {
if (_wcsicmp(Process.szExeFile, lpProcessName) == 0) if (_wcsicmp(Process.szExeFile, lpszProcessName) == 0)
{ {
/* The names match, return the process ID we're interested */ /* The names match, return the process ID we're interested */
CloseHandle(hSnapshot); CloseHandle(hSnapshot);
@ -60,7 +60,7 @@ DWORD GetProcessID(IN LPCWSTR lpProcessName)
* *
* Checks if a process is running. * Checks if a process is running.
* *
* @param[in] lpProcessName * @param[in] lpszProcessName
* The name of the executable process. * The name of the executable process.
* *
* @return * @return
@ -68,13 +68,13 @@ DWORD GetProcessID(IN LPCWSTR lpProcessName)
* FALSE otherwise. * FALSE otherwise.
* *
*/ */
BOOL IsProcessRunning(IN LPCWSTR lpProcessName) BOOL IsProcessRunning(IN LPCWSTR lpszProcessName)
{ {
DWORD dwReturn, dwProcessID; DWORD dwReturn, dwProcessID;
HANDLE hProcess; HANDLE hProcess;
/* Get the process ID */ /* Get the process ID */
dwProcessID = GetProcessID(lpProcessName); dwProcessID = GetProcessID(lpszProcessName);
if (dwProcessID == 0) if (dwProcessID == 0)
{ {
return FALSE; return FALSE;
@ -114,7 +114,7 @@ BOOL IsProcessRunning(IN LPCWSTR lpProcessName)
* FALSE otherwise. * FALSE otherwise.
* *
*/ */
BOOL LaunchProcess(LPCWSTR lpProcessName) BOOL LaunchProcess(IN LPCWSTR lpszProcessName)
{ {
STARTUPINFOW si; STARTUPINFOW si;
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
@ -123,7 +123,7 @@ BOOL LaunchProcess(LPCWSTR lpProcessName)
WCHAR ExpandedCmdLine[MAX_PATH]; WCHAR ExpandedCmdLine[MAX_PATH];
/* Expand the process path string */ /* Expand the process path string */
ExpandEnvironmentStringsW(lpProcessName, ExpandedCmdLine, ARRAYSIZE(ExpandedCmdLine)); ExpandEnvironmentStringsW(lpszProcessName, ExpandedCmdLine, ARRAYSIZE(ExpandedCmdLine));
ZeroMemory(&pi, sizeof(pi)); ZeroMemory(&pi, sizeof(pi));
ZeroMemory(&si, sizeof(si)); ZeroMemory(&si, sizeof(si));
@ -181,7 +181,7 @@ BOOL LaunchProcess(LPCWSTR lpProcessName)
* *
* Closes a process. * Closes a process.
* *
* @param[in] lpProcessName * @param[in] lpszProcessName
* The name of the executable process. * The name of the executable process.
* *
* @return * @return
@ -189,13 +189,13 @@ BOOL LaunchProcess(LPCWSTR lpProcessName)
* FALSE otherwise. * FALSE otherwise.
* *
*/ */
BOOL CloseProcess(IN LPCWSTR lpProcessName) BOOL CloseProcess(IN LPCWSTR lpszProcessName)
{ {
HANDLE hProcess; HANDLE hProcess;
DWORD dwProcessID; DWORD dwProcessID;
/* Get the process ID */ /* Get the process ID */
dwProcessID = GetProcessID(lpProcessName); dwProcessID = GetProcessID(lpszProcessName);
if (dwProcessID == 0) if (dwProcessID == 0)
{ {
return FALSE; return FALSE;

View file

@ -34,7 +34,7 @@ REGISTRY_SETTINGS Settings;
* @param[in] hPredefinedKey * @param[in] hPredefinedKey
* The predefined key (e.g. HKEY_CLASSES_ROOT). * The predefined key (e.g. HKEY_CLASSES_ROOT).
* *
* @param[in] lpwszSubKey * @param[in] lpszSubKey
* The path to the sub key to be created. * The path to the sub key to be created.
* *
* @param[out] phKey * @param[out] phKey
@ -49,14 +49,14 @@ REGISTRY_SETTINGS Settings;
* *
*/ */
BOOL InitAppRegKey(IN HKEY hPredefinedKey, BOOL InitAppRegKey(IN HKEY hPredefinedKey,
IN LPCWSTR lpwszSubKey, IN LPCWSTR lpszSubKey,
OUT PHKEY phKey, OUT PHKEY phKey,
OUT LPDWORD lpdwDisposition) OUT LPDWORD lpdwDisposition)
{ {
LONG lResult; LONG lResult;
lResult = RegCreateKeyExW(hPredefinedKey, lResult = RegCreateKeyExW(hPredefinedKey,
lpwszSubKey, lpszSubKey,
0, 0,
NULL, NULL,
0, 0,
@ -66,7 +66,7 @@ BOOL InitAppRegKey(IN HKEY hPredefinedKey,
lpdwDisposition); lpdwDisposition);
if (lResult != ERROR_SUCCESS) if (lResult != ERROR_SUCCESS)
{ {
DPRINT("InitAppRegKey(): Failed to create the following key (or open the key) of path \"%S\". The error code is \"%li\".\n", lpwszSubKey, lResult); DPRINT("InitAppRegKey(): Failed to create the following key (or open the key) of path \"%S\". The error code is \"%li\".\n", lpszSubKey, lResult);
return FALSE; return FALSE;
} }
@ -81,10 +81,10 @@ BOOL InitAppRegKey(IN HKEY hPredefinedKey,
* @param[in] hKey * @param[in] hKey
* A handle to a key. * A handle to a key.
* *
* @param[in] lpwszSubKey * @param[in] lpszSubKey
* The path to a sub-key. * The path to a sub-key.
* *
* @param[in] lpwszRegValue * @param[in] lpszRegValue
* The registry value where we need to get the data from. * The registry value where we need to get the data from.
* *
* @param[out] ReturnedData * @param[out] ReturnedData
@ -101,8 +101,8 @@ BOOL InitAppRegKey(IN HKEY hPredefinedKey,
* *
*/ */
BOOL QueryAppSettings(IN HKEY hKey, BOOL QueryAppSettings(IN HKEY hKey,
IN LPCWSTR lpwszSubKey, IN LPCWSTR lpszSubKey,
IN LPCWSTR lpwszRegValue, IN LPCWSTR lpszRegValue,
OUT PVOID ReturnedData, OUT PVOID ReturnedData,
IN OUT LPDWORD lpdwSizeData) IN OUT LPDWORD lpdwSizeData)
{ {
@ -110,25 +110,25 @@ BOOL QueryAppSettings(IN HKEY hKey,
HKEY hKeyQueryValue; HKEY hKeyQueryValue;
lResult = RegOpenKeyExW(hKey, lResult = RegOpenKeyExW(hKey,
lpwszSubKey, lpszSubKey,
0, 0,
KEY_READ, KEY_READ,
&hKeyQueryValue); &hKeyQueryValue);
if (lResult != ERROR_SUCCESS) if (lResult != ERROR_SUCCESS)
{ {
DPRINT("QueryAppSettings(): Failed to open the key of path \"%S\". The error code is \"%li\".\n", lpwszSubKey, lResult); DPRINT("QueryAppSettings(): Failed to open the key of path \"%S\". The error code is \"%li\".\n", lpszSubKey, lResult);
return FALSE; return FALSE;
} }
lResult = RegQueryValueExW(hKeyQueryValue, lResult = RegQueryValueExW(hKeyQueryValue,
lpwszRegValue, lpszRegValue,
NULL, NULL,
NULL, NULL,
(LPBYTE)&ReturnedData, (LPBYTE)&ReturnedData,
lpdwSizeData); lpdwSizeData);
if (lResult != ERROR_SUCCESS) if (lResult != ERROR_SUCCESS)
{ {
DPRINT("QueryAppSettings(): Failed to query the data from value \"%S\". The error code is \"%li\".\n", lpwszRegValue, lResult); DPRINT("QueryAppSettings(): Failed to query the data from value \"%S\". The error code is \"%li\".\n", lpszRegValue, lResult);
RegCloseKey(hKeyQueryValue); RegCloseKey(hKeyQueryValue);
return FALSE; return FALSE;
} }
@ -145,7 +145,7 @@ BOOL QueryAppSettings(IN HKEY hKey,
* @param[in] hKey * @param[in] hKey
* A handle to a key. * A handle to a key.
* *
* @param[in] lpwszRegValue * @param[in] lpszRegValue
* The path to the sub key where the value needs to be created. * The path to the sub key where the value needs to be created.
* *
* @param[out] dwRegType * @param[out] dwRegType
@ -165,7 +165,7 @@ BOOL QueryAppSettings(IN HKEY hKey,
* *
*/ */
BOOL SaveAppSettings(IN HKEY hKey, BOOL SaveAppSettings(IN HKEY hKey,
IN LPCWSTR lpwszRegValue, IN LPCWSTR lpszRegValue,
IN DWORD dwRegType, IN DWORD dwRegType,
IN PVOID Data, IN PVOID Data,
IN DWORD cbSize) IN DWORD cbSize)
@ -185,14 +185,14 @@ BOOL SaveAppSettings(IN HKEY hKey,
} }
lResult = RegSetValueExW(hKeySetValue, lResult = RegSetValueExW(hKeySetValue,
lpwszRegValue, lpszRegValue,
0, 0,
dwRegType, dwRegType,
(LPBYTE)&Data, (LPBYTE)&Data,
cbSize); cbSize);
if (lResult != ERROR_SUCCESS) if (lResult != ERROR_SUCCESS)
{ {
DPRINT("SaveAppSettings(): Failed to set the \"%S\" value with data, the error code is \"%li\"!\n", lpwszRegValue, lResult); DPRINT("SaveAppSettings(): Failed to set the \"%S\" value with data, the error code is \"%li\"!\n", lpszRegValue, lResult);
RegCloseKey(hKeySetValue); RegCloseKey(hKeySetValue);
return FALSE; return FALSE;
} }

View file

@ -65,7 +65,7 @@ VOID InitUtilsList(BOOL bInitGui)
/* Add the utilities in the listbox */ /* Add the utilities in the listbox */
for (i = 0; i < _countof(EntriesList); ++i) for (i = 0; i < _countof(EntriesList); ++i)
{ {
bIsRunning = IsProcessRunning(EntriesList[i].lpProgram); bIsRunning = IsProcessRunning(EntriesList[i].lpszProgram);
EntriesList[i].bState = bIsRunning; EntriesList[i].bState = bIsRunning;
/* Load the string and append the utility's name to the format */ /* Load the string and append the utility's name to the format */
@ -99,7 +99,7 @@ BOOL DlgInitHandler(IN HWND hDlg)
INT PosX, PosY; INT PosX, PosY;
RECT rc; RECT rc;
WCHAR szAboutDlg[MAX_BUFFER]; WCHAR szAboutDlg[MAX_BUFFER];
WCHAR wszAppPath[MAX_BUFFER]; WCHAR szAppPath[MAX_BUFFER];
HMENU hSysMenu; HMENU hSysMenu;
/* Save the dialog handle */ /* Save the dialog handle */
@ -112,8 +112,8 @@ BOOL DlgInitHandler(IN HWND hDlg)
SetWindowPos(hDlg, 0, PosX, PosY, 0, 0, SWP_NOZORDER | SWP_NOSIZE); SetWindowPos(hDlg, 0, PosX, PosY, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
/* Extract the icon resource from the executable process */ /* Extract the icon resource from the executable process */
GetModuleFileNameW(NULL, wszAppPath, _countof(wszAppPath)); GetModuleFileNameW(NULL, szAppPath, _countof(szAppPath));
Globals.hIcon = ExtractIconW(Globals.hInstance, wszAppPath, 0); Globals.hIcon = ExtractIconW(Globals.hInstance, szAppPath, 0);
/* Set the icon within the dialog's title bar */ /* Set the icon within the dialog's title bar */
if (Globals.hIcon) if (Globals.hIcon)
@ -213,7 +213,7 @@ INT ListBoxRefreshContents(VOID)
for (i = 0; i < _countof(EntriesList); ++i) for (i = 0; i < _countof(EntriesList); ++i)
{ {
/* Check the utility's state */ /* Check the utility's state */
bIsRunning = IsProcessRunning(EntriesList[i].lpProgram); bIsRunning = IsProcessRunning(EntriesList[i].lpszProgram);
if (bIsRunning != EntriesList[i].bState) if (bIsRunning != EntriesList[i].bState)
{ {
/* The utility's state has changed, save it */ /* The utility's state has changed, save it */
@ -315,11 +315,11 @@ INT_PTR APIENTRY DlgProc(
} }
case IDC_START: case IDC_START:
LaunchProcess(EntriesList[Globals.iSelectedIndex].lpProgram); LaunchProcess(EntriesList[Globals.iSelectedIndex].lpszProgram);
break; break;
case IDC_STOP: case IDC_STOP:
CloseProcess(EntriesList[Globals.iSelectedIndex].lpProgram); CloseProcess(EntriesList[Globals.iSelectedIndex].lpszProgram);
break; break;
default: default:

View file

@ -44,7 +44,7 @@ typedef struct
typedef struct _UTILMAN_STATE typedef struct _UTILMAN_STATE
{ {
LPCWSTR lpProgram; LPCWSTR lpszProgram;
UINT uNameId; UINT uNameId;
WCHAR szResource[MAX_BUFFER]; WCHAR szResource[MAX_BUFFER];
BOOL bState; BOOL bState;
@ -53,15 +53,15 @@ typedef struct _UTILMAN_STATE
typedef struct _REGISTRY_SETTINGS typedef struct _REGISTRY_SETTINGS
{ {
/* Accessibility Registry settings */ /* Accessibility Registry settings */
LPCWSTR wszAppPath; LPCWSTR lpszAppPath;
DWORD dwAppType; DWORD dwAppType;
DWORD dwClientControlCode; DWORD dwClientControlCode;
LPCWSTR wszAppName; LPCWSTR lpszAppName;
LPCWSTR wszErrorOnLaunch; LPCWSTR lpszErrorOnLaunch;
BOOL bHideClient; BOOL bHideClient;
BOOL bStartWithUtilman; BOOL bStartWithUtilman;
BOOL bStartWithROS; BOOL bStartWithROS;
LPCWSTR wszHungRespondAction; LPCWSTR lpszHungRespondAction;
DWORD dwHungTimeOut; DWORD dwHungTimeOut;
/* Utility Manager Registry settings */ /* Utility Manager Registry settings */
@ -71,12 +71,12 @@ typedef struct _REGISTRY_SETTINGS
typedef struct _REGISTRY_DATA typedef struct _REGISTRY_DATA
{ {
/* On-Screen Keyboard Registry data */ /* On-Screen Keyboard Registry data */
LPCWSTR lpwsOskPath; LPCWSTR lpszOskPath;
LPCWSTR lpwszOskDisplayName; LPCWSTR lpszOskDisplayName;
/* Magnify Registry data */ /* Magnify Registry data */
LPCWSTR lpwszMagnifyPath; LPCWSTR lpszMagnifyPath;
LPCWSTR lpwszMagnifyDisplayName; LPCWSTR lpszMagnifyDisplayName;
} REGISTRY_DATA, *PREGISTRY_DATA; } REGISTRY_DATA, *PREGISTRY_DATA;
/* ENUMERATIONS ***************************************************************/ /* ENUMERATIONS ***************************************************************/
@ -97,19 +97,19 @@ VOID CheckUtilityState(BOOL bUtilState);
BOOL WINAPI UManStartDlg(VOID); BOOL WINAPI UManStartDlg(VOID);
/* process.c */ /* process.c */
DWORD GetProcessID(IN LPCWSTR lpProcessName); DWORD GetProcessID(IN LPCWSTR lpszProcessName);
BOOL IsProcessRunning(IN LPCWSTR lpProcessName); BOOL IsProcessRunning(IN LPCWSTR lpszProcessName);
BOOL LaunchProcess(LPCWSTR lpProcessName); BOOL LaunchProcess(IN LPCWSTR lpszProcessName);
BOOL CloseProcess(IN LPCWSTR lpProcessName); BOOL CloseProcess(IN LPCWSTR lpszProcessName);
/* about.c */ /* about.c */
VOID ShowAboutDlg(HWND hDlgParent); VOID ShowAboutDlg(HWND hDlgParent);
INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
/* registry.c */ /* registry.c */
BOOL InitAppRegKey(IN HKEY hPredefinedKey, IN LPCWSTR lpwszSubKey, OUT PHKEY phKey, OUT LPDWORD lpdwDisposition); BOOL InitAppRegKey(IN HKEY hPredefinedKey, IN LPCWSTR lpszSubKey, OUT PHKEY phKey, OUT LPDWORD lpdwDisposition);
BOOL QueryAppSettings(IN HKEY hKey, IN LPCWSTR lpwszSubKey, IN LPCWSTR lpwszRegValue, OUT PVOID ReturnedData, IN OUT LPDWORD lpdwSizeData); BOOL QueryAppSettings(IN HKEY hKey, IN LPCWSTR lpszSubKey, IN LPCWSTR lpszRegValue, OUT PVOID ReturnedData, IN OUT LPDWORD lpdwSizeData);
BOOL SaveAppSettings(IN HKEY hKey, IN LPCWSTR lpwszRegValue, IN DWORD dwRegType, IN PVOID Data, IN DWORD cbSize); BOOL SaveAppSettings(IN HKEY hKey, IN LPCWSTR lpszRegValue, IN DWORD dwRegType, IN PVOID Data, IN DWORD cbSize);
/* Struct variable declaration */ /* Struct variable declaration */
extern UTILMAN_GLOBALS Globals; extern UTILMAN_GLOBALS Globals;

View file

@ -38,9 +38,9 @@ INT WINAPI wWinMain(IN HINSTANCE hInstance,
IN INT nCmdShow) IN INT nCmdShow)
{ {
HMODULE hModule; HMODULE hModule;
WCHAR wszFormat[MAX_BUFFER]; WCHAR szFormat[MAX_BUFFER];
WCHAR wszFailLoad[MAX_BUFFER]; WCHAR szFailLoad[MAX_BUFFER];
WCHAR wszTitle[MAX_BUFFER]; WCHAR szTitle[MAX_BUFFER];
EXECDLGROUTINE UManStartDlg; EXECDLGROUTINE UManStartDlg;
UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(hPrevInstance);
@ -51,11 +51,11 @@ INT WINAPI wWinMain(IN HINSTANCE hInstance,
hModule = LoadLibraryW(L"UManDlg.dll"); hModule = LoadLibraryW(L"UManDlg.dll");
if (!hModule) if (!hModule)
{ {
LoadStringW(hInstance, IDS_FAIL_INIT, wszFormat, _countof(wszFormat)); LoadStringW(hInstance, IDS_FAIL_INIT, szFormat, _countof(szFormat));
LoadStringW(hInstance, IDS_FAIL_INIT_TITLE, wszTitle, _countof(wszTitle)); LoadStringW(hInstance, IDS_FAIL_INIT_TITLE, szTitle, _countof(szTitle));
StringCchPrintfW(wszFailLoad, _countof(wszFailLoad), wszFormat, GetLastError()); StringCchPrintfW(szFailLoad, _countof(szFailLoad), szFormat, GetLastError());
MessageBoxW(GetDesktopWindow(), wszFailLoad, wszTitle, MB_ICONERROR | MB_OK); MessageBoxW(GetDesktopWindow(), szFailLoad, szTitle, MB_ICONERROR | MB_OK);
return -1; return -1;
} }