Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
2.9 KiB

  1. #define UNICODE 1
  2. #include "shellprv.h"
  3. #pragma hdrstop
  4. const WCHAR szCommdlgHelp[] = L"commdlg_help";
  5. UINT wBrowseHelp = WM_USER; /* Set to an unused value */
  6. const CHAR szGetOpenFileName[] = "GetOpenFileNameW";
  7. /* the defines below should be in windows.h */
  8. /* Dialog window class */
  9. #define WC_DIALOG (MAKEINTATOM(0x8002))
  10. /* cbWndExtra bytes needed by dialog manager for dialog classes */
  11. #define DLGWINDOWEXTRA 30
  12. /* Get/SetWindowWord/Long offsets for use with WC_DIALOG windows */
  13. #define DWL_MSGRESULT 0
  14. #define DWL_DLGPROC 4
  15. #define DWL_USER 8
  16. /* For Long File Name support */
  17. #define MAX_EXTENSION 64
  18. typedef struct {
  19. LPWSTR lpszExe;
  20. LPWSTR lpszPath;
  21. LPWSTR lpszName;
  22. } FINDEXE_PARAMS, FAR *LPFINDEXE_PARAMS;
  23. typedef INT (APIENTRY *LPFNGETOPENFILENAME)(LPOPENFILENAME);
  24. VOID APIENTRY
  25. CheckEscapesW(LPWSTR szFile, DWORD cch)
  26. {
  27. LPWSTR szT;
  28. WCHAR *p, *pT;
  29. for (p = szFile; *p; p++) {
  30. switch (*p) {
  31. case WCHAR_SPACE:
  32. case WCHAR_COMMA:
  33. case WCHAR_SEMICOLON:
  34. case WCHAR_HAT:
  35. case WCHAR_QUOTE:
  36. {
  37. // this path contains an annoying character
  38. if (cch < (wcslen(szFile) + 2)) {
  39. return;
  40. }
  41. szT = (LPWSTR)LocalAlloc(LPTR, cch * sizeof(WCHAR));
  42. if (!szT) {
  43. return;
  44. }
  45. StringCchCopy(szT, cch, szFile); // ok to truncate, we checked size above
  46. p = szFile;
  47. *p++ = WCHAR_QUOTE;
  48. for (pT = szT; *pT; ) {
  49. *p++ = *pT++;
  50. }
  51. *p++ = WCHAR_QUOTE;
  52. *p = WCHAR_NULL;
  53. LocalFree(szT);
  54. return;
  55. }
  56. }
  57. }
  58. }
  59. VOID APIENTRY
  60. CheckEscapesA(LPSTR lpFileA, DWORD cch)
  61. {
  62. if (lpFileA && *lpFileA) {
  63. LPWSTR lpFileW;
  64. lpFileW = (LPWSTR)LocalAlloc(LPTR, (cch * sizeof(WCHAR)));
  65. if (!lpFileW) {
  66. return;
  67. }
  68. SHAnsiToUnicode(lpFileA, lpFileW, cch);
  69. CheckEscapesW(lpFileW, cch);
  70. try {
  71. SHUnicodeToAnsi(lpFileW, lpFileA, cch);
  72. } except(EXCEPTION_EXECUTE_HANDLER) {
  73. LocalFree(lpFileW);
  74. return;
  75. }
  76. LocalFree(lpFileW);
  77. }
  78. return;
  79. }
  80. //----------------------------------------------------------------------------
  81. // FindExeDlgProc was mistakenly exported in the original NT SHELL32.DLL when
  82. // it didn't need to be (dlgproc's, like wndproc's don't need to be exported
  83. // in the 32-bit world). In order to maintain loadability of some app
  84. // which might have linked to it, we stub it here. If some app ended up really
  85. // using it, then we'll look into a specific fix for that app.
  86. //
  87. // -BobDay
  88. //
  89. BOOL_PTR WINAPI FindExeDlgProc( HWND hDlg, UINT wMsg, WPARAM wParam, LONG lParam )
  90. {
  91. return FALSE;
  92. }