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.

124 lines
3.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: wvtfile.cpp
  8. //
  9. // Contents: performance suite
  10. //
  11. // History: 04-Dec-1997 pberkman created
  12. //
  13. //--------------------------------------------------------------------------
  14. #include "global.hxx"
  15. DWORD WINAPI TestWVTFile(ThreadData *psData)
  16. {
  17. COleDateTime tStart;
  18. COleDateTime tEnd;
  19. DWORD i;
  20. char szFile[MAX_PATH];
  21. HRESULT hr;
  22. BOOL fFind;
  23. HANDLE hFind;
  24. WIN32_FIND_DATA sFindData;
  25. WCHAR *pwszLastSlash;
  26. WCHAR wszDir[MAX_PATH];
  27. WCHAR wszFile[MAX_PATH];
  28. DWORD dwDirLen;
  29. WINTRUST_DATA sWTD;
  30. WINTRUST_FILE_INFO sWTFI;
  31. hFind = INVALID_HANDLE_VALUE;
  32. psData->dwTotalProcessed = 0;
  33. printf("\n WVT_FILE");
  34. if (pwszLastSlash = wcsrchr(pwszInFile, L'\\'))
  35. {
  36. *pwszLastSlash = NULL;
  37. wcscpy(&wszDir[0], pwszInFile);
  38. wcscat(&wszDir[0], L"\\");
  39. *pwszLastSlash = L'\\';
  40. dwDirLen = wcslen(&wszDir[0]);
  41. }
  42. else
  43. {
  44. wszDir[0] = NULL;
  45. dwDirLen = 0;
  46. }
  47. memset(&sWTD, 0x00, sizeof(WINTRUST_DATA));
  48. sWTD.cbStruct = sizeof(WINTRUST_DATA);
  49. sWTD.dwUIChoice = WTD_UI_NONE;
  50. sWTD.dwUnionChoice = WTD_CHOICE_FILE;
  51. sWTD.pFile = &sWTFI;
  52. memset(&sWTFI, 0x00, sizeof(WINTRUST_FILE_INFO));
  53. sWTFI.cbStruct = sizeof(WINTRUST_FILE_INFO);
  54. tStart = COleDateTime::GetCurrentTime();
  55. for (i = 0; i < cPasses; i++)
  56. {
  57. szFile[0] = NULL;
  58. WideCharToMultiByte(0, 0, pwszInFile, -1, &szFile[0], MAX_PATH, NULL, NULL);
  59. if ((hFind = FindFirstFile(&szFile[0], &sFindData)) == INVALID_HANDLE_VALUE)
  60. {
  61. goto FileFindError;
  62. }
  63. fFind = TRUE;
  64. while (fFind)
  65. {
  66. if (!(sFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
  67. {
  68. if (dwDirLen > 0)
  69. {
  70. wcscpy(&wszFile[0], &wszDir[0]);
  71. }
  72. wszFile[dwDirLen] = NULL;
  73. MultiByteToWideChar(0, 0, &sFindData.cFileName[0], -1, &wszFile[dwDirLen], MAX_PATH * sizeof(WCHAR));
  74. sWTFI.pcwszFilePath = &wszFile[0];
  75. hr = WinVerifyTrust(NULL, &gAuthCode, &sWTD);
  76. if (fVerbose)
  77. {
  78. printf("\n WVT return: 0x%08.8lX - %s", hr, &sFindData.cFileName[0]);
  79. }
  80. psData->dwTotalProcessed++;
  81. }
  82. fFind = FindNextFile(hFind, &sFindData);
  83. }
  84. if (hFind != INVALID_HANDLE_VALUE)
  85. {
  86. FindClose(hFind);
  87. }
  88. }
  89. ErrorReturn:
  90. tEnd = COleDateTime::GetCurrentTime();
  91. psData->tsTotal = tEnd - tStart;
  92. return(0);
  93. TRACE_ERROR_EX(DBG_SS_APP, FileFindError);
  94. }