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.

101 lines
4.5 KiB

  1. // This is some text code for the CorrectFilePathsUninstall shim.
  2. #define TEST_CPC
  3. // Add this in InitializeHooks():
  4. void InitializeHooks(DWORD fdwReason)
  5. {
  6. if (fdwReason == DLL_PROCESS_ATTACH)
  7. {
  8. #ifdef TEST_CPC
  9. TestCPC();
  10. #endif
  11. INIT_HOOKS(APIHOOK_Count);
  12. #ifdef TEST_CPC
  13. #include "CorrectPathChanges.h"
  14. void TestPath(CorrectPathChangesBase & cpc, CorrectPathChangesBase & cpcu, CorrectPathChangesBase & cpca, CorrectPathChangesBase & cpcfu, const char * old)
  15. {
  16. char * strCorrectFile = CorrectPathAllocA(old);
  17. char * strCorrectFilecpc = cpc.CorrectPathAllocA(old);
  18. char * strCorrectFilecpcu = cpcu.CorrectPathAllocA(old);
  19. char * strCorrectFilecpca = cpca.CorrectPathAllocA(old);
  20. char * strCorrectFilecpcfu= cpcfu.CorrectPathAllocA(old);
  21. DPF(eDbgLevelInfo, "Test CPC(%s)\n", old);
  22. DPF(eDbgLevelInfo, "Base class CPC(%s)\n", strCorrectFilecpc);
  23. DPF(eDbgLevelInfo, "orig CPC(%s)\n", strCorrectFile);
  24. DPF(eDbgLevelInfo, "AllU class CPC(%s)\n", strCorrectFilecpca);
  25. DPF(eDbgLevelInfo, "FUser class CPC(%s)\n\n", strCorrectFilecpcfu);
  26. free(strCorrectFile);
  27. free(strCorrectFilecpc);
  28. free(strCorrectFilecpcu);
  29. free(strCorrectFilecpca);
  30. free(strCorrectFilecpcfu);
  31. }
  32. void TestCPC()
  33. {
  34. CorrectPathChangesBase cpc;
  35. CorrectPathChangesUser cpcu;
  36. CorrectPathChangesAllUser cpca;
  37. CorrectPathChangesForceUser cpcfu;
  38. cpc.AddCommandLineA( "abc;abcd" );
  39. TestPath(cpc, cpc, cpc, cpc, "abcdefg abc abcd");
  40. cpc.AddCommandLineA( NULL);
  41. cpc.AddCommandLineA( "" );
  42. cpc.AddCommandLineA( ";" );
  43. cpc.AddCommandLineA( "\"" );
  44. cpc.AddCommandLineA( "\"\":" );
  45. cpc.AddCommandLineA( "a;" );
  46. cpc.AddCommandLineA( "a;b" );
  47. cpc.AddCommandLineA( "a\";" );
  48. cpc.AddCommandLineA( "a\";" );
  49. TestPath(cpc, cpcu, cpca, cpcfu, "abcdefg abc abcd");
  50. TestPath(cpc, cpcu, cpca, cpcfu, NULL);
  51. TestPath(cpc, cpcu, cpca, cpcfu, "");
  52. TestPath(cpc, cpcu, cpca, cpcfu, "c:\\windows");
  53. TestPath(cpc, cpcu, cpca, cpcfu, "c:\\program files");
  54. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winnt\\rundll32.exe");
  55. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winnt\\write.exe");
  56. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winnt\\wordpad.exe");
  57. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\program files\\Accessories\\wordpad.exe");
  58. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winnt\\Start Menu");
  59. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winnt\\Desktop");
  60. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winnt\\Favorites");
  61. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winnt\\Profiles\\robkenny\\Start Menu");
  62. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winnt\\Profiles\\robkenny\\Desktop");
  63. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winnt\\Profiles\\robkenny\\Favorites");
  64. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winnt\\Profiles\\All Users\\Start Menu");
  65. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winnt\\Profiles\\All Users\\Desktop");
  66. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winnt\\Profiles\\All Users\\Favorites");
  67. // Case sensitivity check
  68. TestPath(cpc, cpcu, cpca, cpcfu, "c:\\winDOWS");
  69. TestPath(cpc, cpcu, cpca, cpcfu, "c:\\proGRAM FILES");
  70. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winNT\\RUNDLL32.EXE");
  71. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winNT\\WRITE.EXE");
  72. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winNT\\WORDPAD.EXE");
  73. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\proGRAM FILES\\ACCESSOries\\wordpad.exe");
  74. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winNT\\START MENU");
  75. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winNT\\DESKTOP");
  76. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winNT\\FAVORITES");
  77. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winNT\\PROFILES\\ROBKEnny\\Start Menu");
  78. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winNT\\PROFILES\\ROBKEnny\\Desktop");
  79. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winNT\\PROFILES\\ROBKEnny\\Favorites");
  80. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winNT\\PROFILES\\ALL Users\\Start Menu");
  81. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winNT\\PROFILES\\ALL Users\\Desktop");
  82. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winNT\\PROFILES\\ALL Users\\Favorites");
  83. // Multiple changes per line
  84. TestPath(cpc, cpcu, cpca, cpcfu, "d:\\winNT\\PROFILES\\ALL Users\\Desktop Hi Mom! d:\\winnt\\Profiles\\robkenny\\Favorites Number 1!");
  85. TestPath(cpc, cpcu, cpca, cpcfu, "c:\\windows c:\\windows c:\\windows c:\\windows c:\\windows c:\\windows c:\\windows ");
  86. }
  87. #endif