make correct use of tchar.h in taskmgr and build it as unicode by default

svn path=/trunk/; revision=14976
This commit is contained in:
Thomas Bluemel 2005-05-04 19:29:28 +00:00
parent 587ddda1d5
commit 68b564e30a
6 changed files with 65 additions and 60 deletions

View file

@ -6,7 +6,7 @@
#ifdef _UNICODE #ifdef _UNICODE
#define __TEXT(q) L##q #define __T(q) L##q
#ifndef _TCHAR_DEFINED #ifndef _TCHAR_DEFINED
#ifndef RC_INVOKED #ifndef RC_INVOKED
@ -203,7 +203,7 @@
#else #else
#define __TEXT(q) q #define __T(q) q
#ifndef _TCHAR_DEFINED #ifndef _TCHAR_DEFINED
#ifndef RC_INVOKED #ifndef RC_INVOKED
@ -403,8 +403,8 @@
#define _TEXT(x) __TEXT(x) #define _TEXT(x) __T(x)
#define _T(x) __TEXT(x) #define _T(x) __T(x)
#endif /* _TCHAR_H_ */ #endif /* _TCHAR_H_ */

View file

@ -69,11 +69,11 @@ static DWORD get_selected_pid(void)
return dwProcessId; return dwProcessId;
} }
static int list_channel_CB(HANDLE hProcess, void* addr, char* buffer, void* user) static int list_channel_CB(HANDLE hProcess, void* addr, TCHAR* buffer, void* user)
{ {
int j; int j;
char val[2]; TCHAR val[2];
LVITEMA lvi; LVITEM lvi;
int index; int index;
HWND hChannelLV = (HWND)user; HWND hChannelLV = (HWND)user;
@ -85,10 +85,10 @@ static int list_channel_CB(HANDLE hProcess, void* addr, char* buffer, void*
index = ListView_InsertItem(hChannelLV, &lvi); index = ListView_InsertItem(hChannelLV, &lvi);
if (index == -1) return 0; if (index == -1) return 0;
val[1] = '\0'; val[1] = TEXT('\0');
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
val[0] = (buffer[0] & (1 << j)) ? 'x' : ' '; val[0] = (buffer[0] & (1 << j)) ? TEXT('x') : TEXT(' ');
ListView_SetItemText(hChannelLV, index, j + 1, val); ListView_SetItemText(hChannelLV, index, j + 1, val);
} }
return 1; return 1;
@ -96,7 +96,7 @@ static int list_channel_CB(HANDLE hProcess, void* addr, char* buffer, void*
struct cce_user struct cce_user
{ {
const char* name; /* channel to look for */ LPCTSTR name; /* channel to look for */
unsigned value, mask; /* how to change channel */ unsigned value, mask; /* how to change channel */
unsigned done; /* number of successful changes */ unsigned done; /* number of successful changes */
unsigned notdone; /* number of unsuccessful changes */ unsigned notdone; /* number of unsuccessful changes */
@ -107,11 +107,11 @@ struct cce_user
* *
* Callback used for changing a given channel attributes * Callback used for changing a given channel attributes
*/ */
static int change_channel_CB(HANDLE hProcess, void* addr, char* buffer, void* pmt) static int change_channel_CB(HANDLE hProcess, void* addr, TCHAR* buffer, void* pmt)
{ {
struct cce_user* user = (struct cce_user*)pmt; struct cce_user* user = (struct cce_user*)pmt;
if (!user->name || !strcmp(buffer + 1, user->name)) if (!user->name || !_tcscmp(buffer + 1, user->name))
{ {
buffer[0] = (buffer[0] & ~user->mask) | (user->value & user->mask); buffer[0] = (buffer[0] & ~user->mask) | (user->value & user->mask);
if (WriteProcessMemory(hProcess, addr, buffer, 1, NULL)) if (WriteProcessMemory(hProcess, addr, buffer, 1, NULL))
@ -222,7 +222,7 @@ struct dll_option_layout
int nb_channels; int nb_channels;
}; };
typedef int (*EnumChannelCB)(HANDLE, void*, char*, void*); typedef int (*EnumChannelCB)(HANDLE, void*, TCHAR*, void*);
/****************************************************************** /******************************************************************
* enum_channel * enum_channel
@ -235,15 +235,15 @@ static int enum_channel(HANDLE hProcess, EnumChannelCB ce, void* user, unsigned
struct dll_option_layout dol; struct dll_option_layout dol;
int i, j, ret = 1; int i, j, ret = 1;
void* buf_addr; void* buf_addr;
char buffer[32]; TCHAR buffer[32];
void* addr; void* addr;
const char** cache = NULL; const TCHAR** cache = NULL;
unsigned num_cache, used_cache; unsigned num_cache, used_cache;
addr = get_symbol(hProcess, "first_dll", "libwine.so"); addr = get_symbol(hProcess, "first_dll", "libwine.so");
if (!addr) return -1; if (!addr) return -1;
if (unique) if (unique)
cache = HeapAlloc(GetProcessHeap(), 0, (num_cache = 32) * sizeof(char*)); cache = HeapAlloc(GetProcessHeap(), 0, (num_cache = 32) * sizeof(TCHAR*));
else else
num_cache = 0; num_cache = 0;
used_cache = 0; used_cache = 0;
@ -265,12 +265,12 @@ static int enum_channel(HANDLE hProcess, EnumChannelCB ce, void* user, unsigned
* them again * them again
*/ */
for (j = 0; j < used_cache; j++) for (j = 0; j < used_cache; j++)
if (!strcmp(cache[j], buffer + 1)) break; if (!_tcscmp(cache[j], buffer + 1)) break;
if (j != used_cache) continue; if (j != used_cache) continue;
if (used_cache == num_cache) if (used_cache == num_cache)
cache = HeapReAlloc(GetProcessHeap(), 0, cache, (num_cache *= 2) * sizeof(char*)); cache = HeapReAlloc(GetProcessHeap(), 0, cache, (num_cache *= 2) * sizeof(TCHAR*));
cache[used_cache++] = strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(buffer + 1) + 1), cache[used_cache++] = _tcscpy(HeapAlloc(GetProcessHeap(), 0, (_tcslen(buffer + 1) + 1) * sizeof(TCHAR)),
buffer + 1); buffer + 1);
} }
ret = ce(hProcess, buf_addr, buffer, user); ret = ce(hProcess, buf_addr, buffer, user);
} }
@ -278,7 +278,7 @@ static int enum_channel(HANDLE hProcess, EnumChannelCB ce, void* user, unsigned
} }
if (unique) if (unique)
{ {
for (j = 0; j < used_cache; j++) HeapFree(GetProcessHeap(), 0, (char*)cache[j]); for (j = 0; j < used_cache; j++) HeapFree(GetProcessHeap(), 0, (TCHAR*)cache[j]);
HeapFree(GetProcessHeap(), 0, cache); HeapFree(GetProcessHeap(), 0, cache);
} }
return 0; return 0;
@ -365,13 +365,13 @@ static void DebugChannels_OnNotify(HWND hDlg, LPARAM lParam)
ListView_GetItemText(hChannelLV, lhti.iItem, 0, name, sizeof(name) / sizeof(name[0])); ListView_GetItemText(hChannelLV, lhti.iItem, 0, name, sizeof(name) / sizeof(name[0]));
ListView_GetItemText(hChannelLV, lhti.iItem, lhti.iSubItem, val, sizeof(val) / sizeof(val[0])); ListView_GetItemText(hChannelLV, lhti.iItem, lhti.iSubItem, val, sizeof(val) / sizeof(val[0]));
user.name = name; user.name = name;
user.value = (val[0] == 'x') ? 0 : bitmask; user.value = (val[0] == TEXT('x')) ? 0 : bitmask;
user.mask = bitmask; user.mask = bitmask;
user.done = user.notdone = 0; user.done = user.notdone = 0;
enum_channel(hProcess, change_channel_CB, &user, FALSE); enum_channel(hProcess, change_channel_CB, &user, FALSE);
if (user.done) if (user.done)
{ {
val[0] ^= ('x' ^ ' '); val[0] ^= (TEXT('x') ^ TEXT(' '));
ListView_SetItemText(hChannelLV, lhti.iItem, lhti.iSubItem, val); ListView_SetItemText(hChannelLV, lhti.iItem, lhti.iSubItem, val);
} }
if (user.notdone) if (user.notdone)

View file

@ -16,7 +16,7 @@ TARGET_INSTALLDIR = system32
TARGET_PCH = precomp.h TARGET_PCH = precomp.h
TARGET_CFLAGS = -Werror -Wall -DDBG -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__USE_W32API TARGET_CFLAGS = -Werror -Wall -DDBG -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__USE_W32API -DUNICODE -D_UNICODE
TARGET_SDKLIBS = ntdll.a kernel32.a user32.a gdi32.a comctl32.a TARGET_SDKLIBS = ntdll.a kernel32.a user32.a gdi32.a comctl32.a

View file

@ -355,11 +355,11 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
CommitChargeTotal = PerfDataGetCommitChargeTotalK(); CommitChargeTotal = PerfDataGetCommitChargeTotalK();
CommitChargeLimit = PerfDataGetCommitChargeLimitK(); CommitChargeLimit = PerfDataGetCommitChargeLimitK();
CommitChargePeak = PerfDataGetCommitChargePeakK(); CommitChargePeak = PerfDataGetCommitChargePeakK();
_ultoa(CommitChargeTotal, Text, 10); _ultot(CommitChargeTotal, Text, 10);
SetWindowText(hPerformancePageCommitChargeTotalEdit, Text); SetWindowText(hPerformancePageCommitChargeTotalEdit, Text);
_ultoa(CommitChargeLimit, Text, 10); _ultot(CommitChargeLimit, Text, 10);
SetWindowText(hPerformancePageCommitChargeLimitEdit, Text); SetWindowText(hPerformancePageCommitChargeLimitEdit, Text);
_ultoa(CommitChargePeak, Text, 10); _ultot(CommitChargePeak, Text, 10);
SetWindowText(hPerformancePageCommitChargePeakEdit, Text); SetWindowText(hPerformancePageCommitChargePeakEdit, Text);
wsprintf(Text, szMemUsage, CommitChargeTotal, CommitChargeLimit); wsprintf(Text, szMemUsage, CommitChargeTotal, CommitChargeLimit);
SendMessage(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text); SendMessage(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text);
@ -370,11 +370,11 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
KernelMemoryTotal = PerfDataGetKernelMemoryTotalK(); KernelMemoryTotal = PerfDataGetKernelMemoryTotalK();
KernelMemoryPaged = PerfDataGetKernelMemoryPagedK(); KernelMemoryPaged = PerfDataGetKernelMemoryPagedK();
KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK(); KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK();
_ultoa(KernelMemoryTotal, Text, 10); _ultot(KernelMemoryTotal, Text, 10);
SetWindowText(hPerformancePageKernelMemoryTotalEdit, Text); SetWindowText(hPerformancePageKernelMemoryTotalEdit, Text);
_ultoa(KernelMemoryPaged, Text, 10); _ultot(KernelMemoryPaged, Text, 10);
SetWindowText(hPerformancePageKernelMemoryPagedEdit, Text); SetWindowText(hPerformancePageKernelMemoryPagedEdit, Text);
_ultoa(KernelMemoryNonPaged, Text, 10); _ultot(KernelMemoryNonPaged, Text, 10);
SetWindowText(hPerformancePageKernelMemoryNonPagedEdit, Text); SetWindowText(hPerformancePageKernelMemoryNonPagedEdit, Text);
/* /*
@ -383,11 +383,11 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK(); PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK(); PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK(); PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK();
_ultoa(PhysicalMemoryTotal, Text, 10); _ultot(PhysicalMemoryTotal, Text, 10);
SetWindowText(hPerformancePagePhysicalMemoryTotalEdit, Text); SetWindowText(hPerformancePagePhysicalMemoryTotalEdit, Text);
_ultoa(PhysicalMemoryAvailable, Text, 10); _ultot(PhysicalMemoryAvailable, Text, 10);
SetWindowText(hPerformancePagePhysicalMemoryAvailableEdit, Text); SetWindowText(hPerformancePagePhysicalMemoryAvailableEdit, Text);
_ultoa(PhysicalMemorySystemCache, Text, 10); _ultot(PhysicalMemorySystemCache, Text, 10);
SetWindowText(hPerformancePagePhysicalMemorySystemCacheEdit, Text); SetWindowText(hPerformancePagePhysicalMemorySystemCacheEdit, Text);
/* /*
@ -396,11 +396,11 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
TotalHandles = PerfDataGetSystemHandleCount(); TotalHandles = PerfDataGetSystemHandleCount();
TotalThreads = PerfDataGetTotalThreadCount(); TotalThreads = PerfDataGetTotalThreadCount();
TotalProcesses = PerfDataGetProcessCount(); TotalProcesses = PerfDataGetProcessCount();
_ultoa(TotalHandles, Text, 10); _ultot(TotalHandles, Text, 10);
SetWindowText(hPerformancePageTotalsHandleCountEdit, Text); SetWindowText(hPerformancePageTotalsHandleCountEdit, Text);
_ultoa(TotalThreads, Text, 10); _ultot(TotalThreads, Text, 10);
SetWindowText(hPerformancePageTotalsThreadCountEdit, Text); SetWindowText(hPerformancePageTotalsThreadCountEdit, Text);
_ultoa(TotalProcesses, Text, 10); _ultot(TotalProcesses, Text, 10);
SetWindowText(hPerformancePageTotalsProcessCountEdit, Text); SetWindowText(hPerformancePageTotalsProcessCountEdit, Text);
/* /*

View file

@ -27,38 +27,43 @@ void TaskManager_OnFileNew(void)
{ {
HMODULE hShell32; HMODULE hShell32;
RUNFILEDLG RunFileDlg; RUNFILEDLG RunFileDlg;
OSVERSIONINFO versionInfo; TCHAR szTitle[40];
WCHAR wTitle[40]; TCHAR szText[256];
WCHAR wText[256];
TCHAR szTemp[256];
char szTitle[40];
char szText[256];
/* Load language string from resource file */ /* Load language strings from resource file */
LoadString(hInst, IDS_CREATENEWTASK, szTemp, 40); LoadString(hInst, IDS_CREATENEWTASK, szTitle, sizeof(szTitle) / sizeof(szTitle[0]));
strcpy(szTitle,szTemp); LoadString(hInst, IDS_CREATENEWTASK_DESC, szText, sizeof(szText) / sizeof(szText[0]));
LoadString(hInst, IDS_CREATENEWTASK_DESC, szTemp, 256);
strcpy(szText,szTemp);
hShell32 = LoadLibrary(_T("SHELL32.DLL")); hShell32 = LoadLibrary(_T("SHELL32.DLL"));
RunFileDlg = (RUNFILEDLG)(FARPROC)GetProcAddress(hShell32, (char*)((long)0x3D)); RunFileDlg = (RUNFILEDLG)(FARPROC)GetProcAddress(hShell32, (LPCSTR)0x3D);
/* Show "Run..." dialog */ /* Show "Run..." dialog */
if (RunFileDlg) if (RunFileDlg)
{ {
versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); #ifndef UNICODE
GetVersionEx(&versionInfo); if (GetVersion() < 0x80000000)
if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
{ {
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szTitle, -1, wTitle, 40); WCHAR wTitle[40];
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szText, -1, wText, 256); WCHAR wText[256];
RunFileDlg(hMainWnd, 0, NULL, (LPCSTR)wTitle, (LPCSTR)wText, RFF_CALCDIRECTORY);
/* RunFileDlg is always unicode on NT systems, convert the ansi
strings to unicode */
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szTitle, -1, wTitle, sizeof(szTitle) / sizeof(szTitle[0]));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szText, -1, wText, sizeof(szText) / sizeof(szText[0]));
RunFileDlg(hMainWnd, 0, NULL, wTitle, wText, RFF_CALCDIRECTORY);
} }
else else
RunFileDlg(hMainWnd, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY); {
/* RunFileDlg is ansi on win 9x systems */
RunFileDlg(hMainWnd, 0, NULL, (LPCWSTR)szTitle, (LPCWSTR)szText, RFF_CALCDIRECTORY);
}
#else
/* NOTE - don't check whether running on win 9x or NT, let's just
assume that a unicode build only runs on NT */
RunFileDlg(hMainWnd, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY);
#endif
} }
FreeLibrary(hShell32); FreeLibrary(hShell32);

View file

@ -36,9 +36,9 @@ void TaskManager_OnFileNew(void);
typedef void (WINAPI *RUNFILEDLG)( typedef void (WINAPI *RUNFILEDLG)(
HWND hwndOwner, HWND hwndOwner,
HICON hIcon, HICON hIcon,
LPCSTR lpstrDirectory, LPCWSTR lpstrDirectory,
LPCSTR lpstrTitle, LPCWSTR lpstrTitle,
LPCSTR lpstrDescription, LPCWSTR lpstrDescription,
UINT uFlags); UINT uFlags);
/* /*