[shell32.dll]

[FORMATTING]
- Format the code to a more acceptable level. This is just for my sanity while sifting through it.

svn path=/branches/shell32_new-bringup/; revision=53537
This commit is contained in:
Claudiu Mihail 2011-09-03 00:08:11 +00:00
parent 5beaebef93
commit b815342563
2 changed files with 334 additions and 272 deletions

View file

@ -101,7 +101,8 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
/* space */
argc++;
/* skip the remaining spaces */
while (*cs==0x0009 || *cs==0x0020) {
while (*cs==0x0009 || *cs==0x0020)
{
cs++;
}
if (*cs==0)
@ -131,8 +132,10 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
* This way the caller can make a single GlobalFree call to free both, as per MSDN.
*/
argv = (LPWSTR *)LocalAlloc(LMEM_FIXED, argc*sizeof(LPWSTR)+(wcslen(lpCmdline)+1)*sizeof(WCHAR));
if (!argv)
return NULL;
cmdline=(LPWSTR)(argv+argc);
wcscpy(cmdline, lpCmdline);
@ -238,14 +241,17 @@ static DWORD shgfi_get_exe_type(LPCWSTR szFullPath)
SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
ReadFile( hfile, magic, sizeof(magic), &len, NULL );
if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
{
SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
CloseHandle( hfile );
/* DLL files are not executable and should return 0 */
if (nt.FileHeader.Characteristics & IMAGE_FILE_DLL)
return 0;
if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI)
{
return IMAGE_NT_SIGNATURE |
@ -260,6 +266,7 @@ static DWORD shgfi_get_exe_type(LPCWSTR szFullPath)
SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
CloseHandle( hfile );
if (ne.ne_exetyp == 2)
return IMAGE_OS2_SIGNATURE | (ne.ne_expver << 16);
return 0;
@ -582,6 +589,7 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
GetSystemMetrics( SM_CXICON),
GetSystemMetrics( SM_CYICON),
&psfi->hIcon, 0, 1, 0);
if (ret != 0 && ret != 0xFFFFFFFF)
{
IconNotYetLoaded=FALSE;
@ -851,39 +859,49 @@ UINT_PTR WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
{
case ABM_GETSTATE:
return ABS_ALWAYSONTOP | ABS_AUTOHIDE;
case ABM_GETTASKBARPOS:
GetWindowRect(data->hWnd, &rec);
data->rc=rec;
return TRUE;
case ABM_ACTIVATE:
SetActiveWindow(data->hWnd);
return TRUE;
case ABM_GETAUTOHIDEBAR:
return 0; /* pretend there is no autohide bar */
case ABM_NEW:
/* cbSize, hWnd, and uCallbackMessage are used. All other ignored */
SetWindowPos(data->hWnd,HWND_TOP,0,0,0,0,SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);
return TRUE;
case ABM_QUERYPOS:
GetWindowRect(data->hWnd, &(data->rc));
return TRUE;
case ABM_REMOVE:
FIXME("ABM_REMOVE broken\n");
/* FIXME: this is wrong; should it be DestroyWindow instead? */
/*CloseHandle(data->hWnd);*/
return TRUE;
case ABM_SETAUTOHIDEBAR:
SetWindowPos(data->hWnd,HWND_TOP,rec.left+1000,rec.top,
width,height,SWP_SHOWWINDOW);
return TRUE;
case ABM_SETPOS:
data->uEdge=(ABE_RIGHT | ABE_LEFT);
SetWindowPos(data->hWnd,HWND_TOP,data->rc.left,data->rc.top,
width,height,SWP_SHOWWINDOW);
return TRUE;
case ABM_WINDOWPOSCHANGED:
return TRUE;
}
return FALSE;
}
@ -1076,7 +1094,9 @@ INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam
}
// We need the decimal point of the current locale to display the RAM size correctly
if( GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, szDecimalSeparator, sizeof(szDecimalSeparator) / sizeof(WCHAR)) > 0)
if (GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL,
szDecimalSeparator,
sizeof(szDecimalSeparator) / sizeof(WCHAR)) > 0)
{
UCHAR uDecimals;
UINT uIntegral;
@ -1127,11 +1147,10 @@ INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam
EndPaint(hWnd, &ps);
}
break;
}
}; break;
case WM_COMMAND:
{
switch(wParam)
{
case IDOK:
@ -1160,7 +1179,7 @@ INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam
return TRUE;
}
}
break;
}; break;
case WM_CLOSE:
EndDialog(hWnd, TRUE);

View file

@ -107,7 +107,8 @@ static void confirm_msg_move_button(HWND hDlg, INT iId, INT *xPos, INT yOffset,
HWND hButton = GetDlgItem(hDlg, iId);
RECT r;
if (bShow) {
if (bShow)
{
POINT pt;
int width;
@ -143,6 +144,7 @@ static INT_PTR ConfirmMsgBox_Paint(HWND hDlg)
DrawTextW(hdc, (LPWSTR)GetPropW(hDlg, CONFIRM_MSG_PROP), -1, &r, DT_NOPREFIX | DT_PATH_ELLIPSIS | DT_WORDBREAK);
SelectObject(hdc, hOldFont);
EndPaint(hDlg, &ps);
return TRUE;
}
@ -183,6 +185,7 @@ static INT_PTR ConfirmMsgBox_Init(HWND hDlg, LPARAM lParam)
confirm_msg_move_button(hDlg, IDNO, &xPos, yOffset, TRUE);
confirm_msg_move_button(hDlg, IDD_YESTOALL, &xPos, yOffset, info->bYesToAll);
confirm_msg_move_button(hDlg, IDYES, &xPos, yOffset, TRUE);
return TRUE;
}
@ -227,59 +230,70 @@ typedef struct
static BOOL SHELL_ConfirmIDs(int nKindOfDialog, SHELL_ConfirmIDstruc *ids)
{
ids->hIconInstance = shell32_hInstance;
switch (nKindOfDialog) {
switch (nKindOfDialog)
{
case ASK_DELETE_FILE:
ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
ids->text_resource_id = IDS_DELETEITEM_TEXT;
return TRUE;
case ASK_DELETE_FOLDER:
ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
ids->caption_resource_id = IDS_DELETEFOLDER_CAPTION;
ids->text_resource_id = IDS_DELETEITEM_TEXT;
return TRUE;
case ASK_DELETE_MULTIPLE_ITEM:
ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
ids->text_resource_id = IDS_DELETEMULTIPLE_TEXT;
return TRUE;
case ASK_TRASH_FILE:
ids->icon_resource_id = IDI_SHELL_TRASH_FILE;
ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
ids->text_resource_id = IDS_TRASHITEM_TEXT;
return TRUE;
case ASK_TRASH_FOLDER:
ids->icon_resource_id = IDI_SHELL_TRASH_FILE;
ids->caption_resource_id = IDS_DELETEFOLDER_CAPTION;
ids->text_resource_id = IDS_TRASHFOLDER_TEXT;
return TRUE;
case ASK_TRASH_MULTIPLE_ITEM:
ids->icon_resource_id = IDI_SHELL_TRASH_FILE;
ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
ids->text_resource_id = IDS_TRASHMULTIPLE_TEXT;
return TRUE;
case ASK_CANT_TRASH_ITEM:
ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
ids->text_resource_id = IDS_CANTTRASH_TEXT;
return TRUE;
case ASK_DELETE_SELECTED:
ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
ids->caption_resource_id = IDS_DELETEITEM_CAPTION;
ids->text_resource_id = IDS_DELETESELECTED_TEXT;
return TRUE;
case ASK_OVERWRITE_FILE:
ids->hIconInstance = NULL;
ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
ids->caption_resource_id = IDS_OVERWRITEFILE_CAPTION;
ids->text_resource_id = IDS_OVERWRITEFILE_TEXT;
return TRUE;
case ASK_OVERWRITE_FOLDER:
ids->hIconInstance = NULL;
ids->icon_resource_id = IDI_SHELL_CONFIRM_DELETE;
ids->caption_resource_id = IDS_OVERWRITEFILE_CAPTION;
ids->text_resource_id = IDS_OVERWRITEFOLDER_TEXT;
return TRUE;
default:
FIXME(" Unhandled nKindOfDialog %d stub\n", nKindOfDialog);
}
@ -294,6 +308,8 @@ static BOOL SHELL_ConfirmDialogW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir, FI
HICON hIcon;
int ret;
DbgPrint("[shell32, SHELL_ConfirmDialogW] Called\n");
assert(nKindOfDialog >= 0 && nKindOfDialog < 32);
if (op && (op->dwYesToAllMask & (1 << nKindOfDialog)))
return TRUE;
@ -309,8 +325,10 @@ static BOOL SHELL_ConfirmDialogW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir, FI
hIcon = LoadIconW(ids.hIconInstance, (LPWSTR)MAKEINTRESOURCE(ids.icon_resource_id));
ret = SHELL_ConfirmMsgBox(hWnd, szBuffer, szCaption, hIcon, op && op->bManyItems);
if (op) {
if (ret == IDD_YESTOALL) {
if (op)
{
if (ret == IDD_YESTOALL)
{
op->dwYesToAllMask |= (1 << nKindOfDialog);
ret = IDYES;
}
@ -648,21 +666,22 @@ static INT_PTR CALLBACK SHOperationDialog(HWND hwndDlg, UINT uMsg, WPARAM wParam
Context->op->bCancelled = TRUE;
EndDialog(hwndDlg, Context->op->bCancelled);
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == 14002)
{
Context->op->bCancelled = TRUE;
EndDialog(hwndDlg, Context->op->bCancelled);
return TRUE;
}
break;
}; break;
case WM_TIMER:
if (wParam == TIMER_ID)
{
QueueFile(Context);
KillTimer(hwndDlg, TIMER_ID);
}
break;
}; break;
case WM_FILE:
if (!QueueFile(Context))
EndDialog(hwndDlg, Context->op->bCancelled);
@ -726,6 +745,8 @@ static DWORD SHNotifyCopyFileW(LPCWSTR src, LPCWSTR dest, BOOL bFailIfExists)
BOOL ret;
DWORD attribs;
DbgPrint("[shell32, SHNotifyCopyFileW] Called\n");
TRACE("(%s %s %s)\n", debugstr_w(src), debugstr_w(dest), bFailIfExists ? "failIfExists" : "");
/* Destination file may already exist with read only attribute */
@ -733,6 +754,16 @@ static DWORD SHNotifyCopyFileW(LPCWSTR src, LPCWSTR dest, BOOL bFailIfExists)
if (IsAttrib(attribs, FILE_ATTRIBUTE_READONLY))
SetFileAttributesW(dest, attribs & ~FILE_ATTRIBUTE_READONLY);
if (GetFileAttributesW(dest) & FILE_ATTRIBUTE_READONLY)
{
SetFileAttributesW(dest, attribs & ~FILE_ATTRIBUTE_READONLY);
DbgPrint("[shell32, SHNotifyCopyFileW] Something went really WRONG...%ls, we still have FILE_ATTRIBUTE_READONLY\n", dest);
if (GetFileAttributesW(dest) & FILE_ATTRIBUTE_READONLY)
{
DbgPrint("[shell32, SHNotifyCopyFileW] STILL SHIT\n");
}
}
ret = CopyFileW(src, dest, bFailIfExists);
if (ret)
{
@ -870,6 +901,7 @@ int WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES s
ret = ERROR_CANCELLED; /* Error has been already presented to user (not really yet!) */
}
}
return ret;
}
@ -904,8 +936,8 @@ static DWORD SHFindAttrW(LPCWSTR pName, BOOL fileOnly)
continue;
dwAttr = wfd.dwFileAttributes;
break;
}
while (FindNextFileW(hFind, &wfd));
} while (FindNextFileW(hFind, &wfd));
FindClose(hFind);
}
return dwAttr;
@ -933,6 +965,7 @@ static DWORD SHNameTranslate(LPWSTR* wString, LPCWSTR* pWToFrom, BOOL more)
aSize += size;
aString += size;
} while ((size != 1) && more);
/* The two sizes might be different in the case of multibyte chars */
size = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*pWToFrom, aSize, *wString, 0);
if (*wString) /* only in the second loop */
@ -1063,14 +1096,21 @@ static void parse_wildcard_files(FILE_LIST *flList, LPCWSTR szFile, LPDWORD pdwL
for (res = TRUE; res; res = FindNextFileW(hFile, &wfd))
{
if (IsDotDir(wfd.cFileName)) continue;
if (*pdwListIndex >= flList->num_alloc) grow_list( flList );
if (IsDotDir(wfd.cFileName))
continue;
if (*pdwListIndex >= flList->num_alloc)
grow_list( flList );
szFullPath = wildcard_to_file(szFile, wfd.cFileName);
file = &flList->feFiles[(*pdwListIndex)++];
add_file_to_entry(file, szFullPath);
file->bFromWildcard = TRUE;
file->attributes = wfd.dwFileAttributes;
if (IsAttribDir(file->attributes)) flList->bAnyDirectories = TRUE;
if (IsAttribDir(file->attributes))
flList->bAnyDirectories = TRUE;
HeapFree(GetProcessHeap(), 0, szFullPath);
}
@ -1180,7 +1220,8 @@ static void copy_dir_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWST
else
lstrcpyW(szTo, szDestPath);
if (!(op->req->fFlags & FOF_NOCONFIRMATION) && PathFileExistsW(szTo)) {
if (!(op->req->fFlags & FOF_NOCONFIRMATION) && PathFileExistsW(szTo))
{
if (!SHELL_ConfirmDialogW(op->req->hwnd, ASK_OVERWRITE_FOLDER, feFrom->szFilename, op))
{
/* Vista returns an ERROR_CANCELLED even if user pressed "No" */
@ -1367,6 +1408,7 @@ static HRESULT copy_files(FILE_OPERATION *op, const FILE_LIST *flFrom, FILE_LIST
{
if (!copy_file_to_file(op, entryToCopy->szFullPath, fileDest->szFullPath))
{
DbgPrint("[shell32, copy_files] copy_file_to_file failed\n");
op->req->fAnyOperationsAborted = TRUE;
return ERROR_CANCELLED;
}
@ -1736,7 +1778,8 @@ EXTERN_C DWORD WINAPI SheGetDirW(DWORD drive, LPWSTR buffer)
char drv_path[3];
/* change current directory to the specified drive */
if (drive) {
if (drive)
{
strcpy(drv_path, "A:");
drv_path[0] += (char)drive-1;