Source code of Windows XP (NT5)
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.

544 lines
17 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. octest.h
  5. Abstract:
  6. Contains include directives and structures common for all the modules
  7. for the component's setup DLL.
  8. Author:
  9. Bogdan Andreiu (bogdana) 10-Feb-1997
  10. Jason Allor (jasonall) 24-Feb-1998 (took over the project)
  11. Revision History:
  12. 10-Feb-1997 bogdana
  13. First draft: include directives, structure and common function headers.
  14. 20_Feb-1997 bogdana
  15. Added three multistring processing functions.
  16. 19-Mar-1997 bogdana
  17. Renamed some functions.
  18. --*/
  19. #ifndef _OCTEST_H
  20. #define _OCTEST_H
  21. #include <windows.h>
  22. #include <malloc.h>
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <time.h>
  26. #include <stddef.h>
  27. #include <string.h>
  28. #include <wtypes.h>
  29. #include <string.h>
  30. #include <tchar.h>
  31. #include <setupapi.h>
  32. #include <ocmanage.h>
  33. #include <crtdbg.h>
  34. #include <regstr.h>
  35. #include <winuser.h>
  36. #include <ntlog.h>
  37. #include <commctrl.h>
  38. #include <richedit.h>
  39. #include <winreg.h>
  40. #include "hcttools.h"
  41. #include "logutils.h"
  42. #include "resource.h"
  43. #include "msg.h"
  44. //=====================================================================
  45. // #defines
  46. //=====================================================================
  47. //
  48. // These are used for the functions in ntlog.dll
  49. //
  50. #define PASS TLS_PASS
  51. #define FAIL TLS_SEV1
  52. #define TLS_CUSTOM 0x00008000
  53. #define PASS_VARIATION TLS_PASS | TL_VARIATION
  54. #define FAIL_VARIATION TLS_SEV1 | TL_VARIATION
  55. #define WARN_VARIATION TLS_WARN | TL_VARIATION
  56. #define BLOCK_VARIATION TLS_BLOCK | TL_VARIATION
  57. #define ABORT_VARIATION TLS_ABORT | TL_VARIATION
  58. #define LOG_VARIATION TLS_CUSTOM | TL_VARIATION
  59. //
  60. // Defining the EXPORT qualifier
  61. //
  62. #define EXPORT __declspec (dllexport)
  63. #define MAX_MSG_LEN 256 // String length
  64. #define MAX_OC_FUNCTIONS 20 // Number of OC functions
  65. #define TICK_TIME 3 // Size of the time slot
  66. #define NO_STEPS_FINAL 7 // Num steps component will report in final stage
  67. #define MAX_PRIVATE_DATA_SIZE 64 // Maximum size of stored private data
  68. #define MAX_PRIVATE_VALUES 8 // Maximum number of values to be tested
  69. #define MAX_STRINGS_FOR_PRIVATE_DATA 8 // Dimension of the table to choose the strings from
  70. #define MAX_MULTI_STRINGS_FOR_PRIVATE_DATA 6 // Dimension of the table to choose the multi-strings from
  71. #define MAX_WIZPAGE_TYPES 7 // Number pages types
  72. #define MAX_WIZARD_PAGES 5 // Number of pages returned by a component
  73. #define NODES_VISITED_LENGTH 5000
  74. #define ONE_HUNDRED_GIG 0x4876E800
  75. #define OCP_TEST_PRIVATE_BASE OC_PRIVATE_BASE
  76. #define OCP_CHECK_NEEDS OC_PRIVATE_BASE + 1
  77. //#define DEBUG
  78. //=====================================================================
  79. // structure definitions
  80. //=====================================================================
  81. //
  82. // A structure needed for printing the OC functions
  83. //
  84. typedef struct _OCText
  85. {
  86. UINT uiOCFunction;
  87. PTSTR tszOCText;
  88. } OCTEXT, *POCTEXT;
  89. //
  90. // The table used for printing OC function names
  91. //
  92. static const OCTEXT octFunctionNames[] =
  93. {
  94. {OC_PREINITIALIZE, TEXT("OC_PREINITIALIZE")},
  95. {OC_INIT_COMPONENT, TEXT("OC_INIT_COMPONENT")},
  96. {OC_SET_LANGUAGE, TEXT("OC_SET_LANGUAGE")},
  97. {OC_QUERY_IMAGE, TEXT("OC_QUERY_IMAGE")},
  98. {OC_REQUEST_PAGES, TEXT("OC_REQUEST_PAGES")},
  99. {OC_QUERY_CHANGE_SEL_STATE, TEXT("OC_QUERY_CHANGE_SEL_STATE")},
  100. {OC_CALC_DISK_SPACE, TEXT("OC_CALC_DISK_SPACE")},
  101. {OC_QUEUE_FILE_OPS, TEXT("OC_QUEUE_FILE_OPS")},
  102. {OC_NOTIFICATION_FROM_QUEUE, TEXT("OC_NOTIFICATION_FROM_QUEUE")},
  103. {OC_QUERY_STEP_COUNT, TEXT("OC_QUERY_STEP_COUNT")},
  104. {OC_COMPLETE_INSTALLATION, TEXT("OC_COMPLETE_INSTALLATION")},
  105. {OC_CLEANUP, TEXT("OC_CLEANUP")},
  106. {OC_QUERY_STATE, TEXT("OC_QUERY_STATE")},
  107. {OC_NEED_MEDIA, TEXT("OC_NEED_MEDIA")},
  108. {OC_ABOUT_TO_COMMIT_QUEUE, TEXT("OC_ABOUT_TO_COMMIT_QUEUE")},
  109. {OC_QUERY_SKIP_PAGE, TEXT("OC_QUERY_SKIP_PAGE")},
  110. {OC_WIZARD_CREATED, TEXT("OC_WIZARD_CREATED")},
  111. {OC_FILE_BUSY, TEXT("OC_FILE_BUSY")},
  112. {OCP_TEST_PRIVATE_BASE, TEXT("OCP_TEST_PRIVATE_BASE")},
  113. {OCP_CHECK_NEEDS, TEXT("OCP_CHECK_NEEDS")}
  114. };
  115. //
  116. // Data structures
  117. //
  118. typedef struct _COMPONENT_DATA
  119. {
  120. struct _COMPONENT_DATA *Next;
  121. //
  122. // Name of the component
  123. //
  124. LPCTSTR tszComponentId;
  125. //
  126. // Open inf handle to per-component inf for this component.
  127. //
  128. HINF hinfMyInfHandle;
  129. //
  130. // Operation flags from the SETUP_DATA structure we get at init time
  131. //
  132. DWORDLONG dwlFlags;
  133. //
  134. // Language ID we're supposed to use.
  135. //
  136. LANGID LanguageId;
  137. //
  138. // These things will not typically be per-component
  139. // since the DLL gets loaded multiple times within the
  140. // context of one suite/master OC inf.
  141. //
  142. // But just in case and for completeness, we include them here.
  143. //
  144. TCHAR tszSourcePath[MAX_PATH];
  145. TCHAR tszUnattendFile[MAX_PATH];
  146. OCMANAGER_ROUTINES ocrHelperRoutines;
  147. UINT uiFunctionToAV;
  148. BOOL bAccessViolation;
  149. } COMPONENT_DATA, *PCOMPONENT_DATA;
  150. typedef struct _PRIVATE_DATA
  151. {
  152. TCHAR tszName[MAX_MSG_LEN]; // The name of the data value
  153. UINT uiType; // The data type REG_DWORD, REG_SZ,
  154. // REG_MULTI_SZ, REG_BINARY
  155. UINT uiSize; // The size of the data
  156. PVOID pvBuffer; // The buffer to hold the data
  157. PBYTE pbBuffer;
  158. } PRIVATE_DATA, *PPRIVATE_DATA;
  159. typedef struct _MYWIZPAGE
  160. {
  161. //
  162. // Number of pages of this type
  163. //
  164. UINT uiCount;
  165. //
  166. // The page's index within the same type
  167. //
  168. UINT uiOrdinal;
  169. //
  170. // The page's type
  171. //
  172. WizardPagesType wpType;
  173. //
  174. // The string that identifies the component queryed
  175. //
  176. TCHAR tszComponentId[MAX_PATH];
  177. } MYWIZPAGE, *PMYWIZPAGE;
  178. typedef struct _COMPLIST
  179. {
  180. struct _COMPLIST *Next;
  181. TCHAR tszSubcomponentId[MAX_PATH];
  182. } COMPLIST, *PCOMPLIST; // nd, *pnd
  183. typedef struct _SUBCOMP
  184. {
  185. struct _SUBCOMP *Next;
  186. TCHAR tszSubcomponentId[MAX_PATH]; // Name of this subcomponent
  187. TCHAR tszComponentId[MAX_PATH]; // Name of master component
  188. TCHAR tszParentId[MAX_PATH]; // Name of this subcomp's parent
  189. BOOL bMarked; // Used to mark this node
  190. UINT uiModeToBeOn[4];
  191. int nNumMode;
  192. PCOMPLIST pclNeeds;
  193. PCOMPLIST pclExclude;
  194. PCOMPLIST pclChildren;
  195. } SUBCOMP, *PSUBCOMP; // sc, *psc
  196. typedef struct _CHECK_NEEDS
  197. {
  198. PCOMPLIST pclNeeds;
  199. PTCHAR tszNodesVisited;
  200. BOOL bResult;
  201. } CHECK_NEEDS, *PCHECK_NEEDS; // cn, *pcn
  202. /* This structure is used to pass parameters into the dialogbox */
  203. typedef struct _ReturnOrAV
  204. {
  205. TCHAR *tszComponent;
  206. TCHAR *tszSubComponent;
  207. TCHAR tszAPICall[256];
  208. BOOL bOverride;
  209. INT iReturnValue;
  210. } ReturnOrAV, *PReturnOrAV;
  211. // Some security stuff
  212. // From NT security FAQ
  213. struct UNI_STRING{
  214. USHORT len;
  215. USHORT maxlen;
  216. WCHAR *buff;
  217. };
  218. static HANDLE fh;
  219. // End of security stuff
  220. //=====================================================================
  221. // Global variables
  222. //=====================================================================
  223. HINSTANCE g_hDllInstance; // File log handle and dll instance handle
  224. PCOMPONENT_DATA g_pcdComponents; // linked list of components
  225. BOOL g_bUsePrivateFunctions; // Flag to allow/disallow the use of private functions
  226. WizardPagesType g_wpCurrentPageType; // Current wizard page type
  227. UINT g_uiCurrentPage; // Index of currend page
  228. OCMANAGER_ROUTINES g_ocrHelperRoutines; // Helper routines
  229. UINT g_auiPageNumberTable[MAX_WIZPAGE_TYPES];
  230. static PSUBCOMP g_pscHead;
  231. //
  232. // The "witness" file queue : all the files queued "with" the
  233. // OCManager (as a response at OC_QUEUE_FILE_OPS) will be also
  234. // queued here.
  235. // Finally, we will perform a SetupScanFileQueue to determine
  236. // if all the file operations are done.
  237. //
  238. HSPFILEQ g_FileQueue;
  239. //
  240. // We have to set the OC Manager Routines first time
  241. // The first call to TestPrivateData must set all the values first.
  242. // All the subsequent calls will query the values and reset
  243. // one of them randomly.
  244. //
  245. static BOOL g_bFirstTime;
  246. //
  247. // If TRUE, allow the user to select initial values for the component.
  248. // If FALSE, default to preselected initial values
  249. //
  250. static BOOL g_bTestExtended;
  251. static BOOL g_bAccessViolation;
  252. static int g_nTestDialog;
  253. static BOOL g_bNoWizPage;
  254. static BOOL g_bCrashUnicode;
  255. static BOOL g_bInvalidBitmap;
  256. static int nStepsFinal;
  257. static BOOL g_bHugeSize;
  258. static BOOL g_bCloseInf;
  259. static BOOL g_bNoNeedMedia;
  260. static BOOL g_bCleanReg;
  261. static UINT g_uiFunctionToAV;
  262. HINF hInfGlobal;
  263. static BOOL g_bNoLangSupport;
  264. static BOOL g_bReboot;
  265. //=====================================================================
  266. // Function Prototypes for octest.c
  267. //=====================================================================
  268. BOOL CALLBACK ChooseVersionDlgProc(IN HWND hwnd,
  269. IN UINT uiMsg,
  270. IN WPARAM wParam,
  271. IN LPARAM lParam);
  272. BOOL CALLBACK ChooseSubcomponentDlgProc(IN HWND hwnd,
  273. IN UINT uiMsg,
  274. IN WPARAM wParam,
  275. IN LPARAM lParam);
  276. VOID ChooseVersionEx(IN LPCVOID lpcvComponentId,
  277. IN OUT PSETUP_INIT_COMPONENT psicInitComponent);
  278. EXPORT DWORD ComponentSetupProc(IN LPCVOID lpcvComponentId,
  279. IN LPCVOID lpcvSubcomponentId,
  280. IN UINT uiFunction,
  281. IN UINT uiParam1,
  282. IN PVOID pvParam2);
  283. DWORD RunOcPreinitialize(IN LPCVOID lpcvComponentId,
  284. IN LPCVOID lpcvSubcomponentId,
  285. IN UINT uiParam1);
  286. DWORD RunOcInitComponent(IN LPCVOID lpcvComponentId,
  287. IN LPCVOID lpcvSubcomponentId,
  288. IN PVOID pvParam2);
  289. DWORD RunOcQueryState(IN LPCVOID lpcvComponentId,
  290. IN LPCVOID lpcvSubcomponentId);
  291. DWORD RunOcSetLanguage(IN LPCVOID lpcvComponentId,
  292. IN LPCVOID lpcvSubcomponentId,
  293. IN UINT uiParam1);
  294. DWORD RunOcQueryImage(IN LPCVOID lpcvComponentId,
  295. IN LPCVOID lpcvSubcomponentId,
  296. IN PVOID pvParam2);
  297. DWORD RunOcRequestPages(IN LPCVOID lpcvComponentId,
  298. IN UINT uiParam1,
  299. IN PVOID pvParam2);
  300. DWORD RunOcQueryChangeSelState(IN LPCVOID lpcvComponentId,
  301. IN LPCVOID lpcvSubcomponentId,
  302. IN UINT uiParam1);
  303. DWORD RunOcCalcDiskSpace(IN LPCVOID lpcvComponentId,
  304. IN LPCVOID lpcvSubcomponentId,
  305. IN UINT uiParam1,
  306. IN PVOID pvParam2);
  307. DWORD RunOcQueueFileOps(IN LPCVOID lpcvComponentId,
  308. IN LPCVOID lpcvSubcomponentId,
  309. IN PVOID pvParam2);
  310. DWORD RunOcNeedMedia(IN LPCVOID lpcvComponentId,
  311. IN UINT uiParam1,
  312. IN PVOID pvParam2);
  313. DWORD RunOcQueryStepCount(IN LPCVOID lpcvComponentId);
  314. DWORD RunOcCompleteInstallation(IN LPCVOID lpcvComponentId,
  315. IN LPCVOID lpcvSubcomponentId);
  316. DWORD RunOcCleanup(IN LPCVOID lpcvComponentId);
  317. DWORD RunTestOcPrivateBase(IN LPCVOID lpcvSubcomponentId,
  318. IN UINT uiParam1,
  319. IN PVOID pvParam2);
  320. DWORD TestHelperRoutines(IN LPCVOID lpcvComponentId,
  321. IN OCMANAGER_ROUTINES OCManagerRoutines);
  322. DWORD TestPrivateFunction(IN LPCVOID lpcvComponentId,
  323. IN OCMANAGER_ROUTINES OCManagerRoutines);
  324. VOID TestPrivateData(IN OCMANAGER_ROUTINES OCManagerRoutines);
  325. VOID CheckPrivateValues(IN OCMANAGER_ROUTINES OCManagerRoutines,
  326. IN PRIVATE_DATA *aPrivateDataTable);
  327. BOOL SetAValue(IN OCMANAGER_ROUTINES OCManagerRoutines,
  328. IN UINT uiIndex,
  329. IN OUT PRIVATE_DATA *aPrivateDataTable);
  330. DWORD ChooseSubcomponentInitialState(IN LPCVOID lpcvComponentId,
  331. IN LPCVOID lpcvSubcomponentId);
  332. PCOMPONENT_DATA AddNewComponent(IN LPCTSTR tszComponentId);
  333. PCOMPONENT_DATA LocateComponent(IN LPCTSTR tszComponentId);
  334. VOID RemoveComponent(IN LPCTSTR tszComponentId);
  335. VOID CleanUpTest();
  336. BOOL CreateSubcomponentInformationList(IN HINF hinf);
  337. VOID FreeSubcomponentInformationList();
  338. VOID ClearSubcomponentInformationMarks();
  339. PSUBCOMP FindSubcomponentInformationNode(IN PTCHAR tszComponentId,
  340. IN PTCHAR tszSubcomponentId);
  341. VOID CheckNeedsDependencies();
  342. VOID CheckExcludeDependencies();
  343. VOID CheckParentDependencies();
  344. BOOL CheckNeedsDependenciesOfSubcomponent(IN OCMANAGER_ROUTINES ocrHelper,
  345. IN PSUBCOMP pscSubcomponent,
  346. IN PSUBCOMP pscWhoNeedsMe,
  347. IN OUT PTCHAR tszNodesVisited);
  348. BOOL CheckLocalNeedsDependencies(IN OCMANAGER_ROUTINES ocrHelper,
  349. IN PSUBCOMP pscSubcomponent,
  350. IN PCOMPLIST pclNeeds,
  351. IN OUT PTCHAR tszNodesVisited);
  352. BOOL AlreadyVisitedNode(IN PTCHAR tszSubcomponentId,
  353. IN PTCHAR tszNodesVisited);
  354. PTCHAR GetComponent(IN PTCHAR tszSubcomponentId,
  355. IN OUT PTCHAR tszComponentId);
  356. VOID ParseCommandLine();
  357. VOID testAV(BOOL);
  358. BOOL TestReturnValueAndAV(IN LPCVOID lpcvComponentId,
  359. IN LPCVOID lpcvSubcomponentId,
  360. IN UINT uiFunction,
  361. IN UINT uiParam1,
  362. IN PVOID pvParam2,
  363. IN OUT PReturnOrAV raValue);
  364. BOOL BeginTest();
  365. BOOL CALLBACK ChooseReturnOrAVDlgProc(IN HWND hwnd,
  366. IN UINT uiMsg,
  367. IN WPARAM wParam,
  368. IN LPARAM lParam);
  369. void causeAV(IN UINT uiFunction);
  370. BOOL CALLBACK CauseAVDlgProc(IN HWND hwnd,
  371. IN UINT uiMsg,
  372. IN WPARAM wParam,
  373. IN LPARAM lParam);
  374. UINT GetOCFunctionName(IN PTCHAR tszFunctionName);
  375. void SetGlobalsFromINF(HINF infHandle);
  376. void causeAVPerComponent(IN UINT uiFunction, IN LPCVOID lpcvComponentId);
  377. void SetDefaultMode(PCOMPONENT_DATA pcdComponentData);
  378. //=====================================================================
  379. // Function Prototypes for utils.c
  380. //=====================================================================
  381. VOID LogOCFunction(IN LPCVOID lpcvComponentId,
  382. IN LPCVOID lpcvSubcomponentId,
  383. IN UINT uiFunction,
  384. IN UINT uiParam1,
  385. IN PVOID pvParam2);
  386. BOOL QueryButtonCheck(IN HWND hwndDlg,
  387. IN INT iCtrlID);
  388. VOID PrintSpaceOnDrives(IN HDSKSPC DiskSpace);
  389. VOID MultiStringToString(IN PTSTR tszMultiStr,
  390. OUT PTSTR tszStr);
  391. INT MultiStringSize(IN PTSTR tszMultiStr);
  392. VOID CopyMultiString(OUT PTSTR tszMultiStrDestination,
  393. IN PTSTR tszMultiStrSource);
  394. VOID InitGlobals();
  395. //=====================================================================
  396. // Function Prototypes for wizpage.c
  397. //=====================================================================
  398. DWORD DoPageRequest(IN LPCTSTR tszComponentId,
  399. IN WizardPagesType wpWhichOnes,
  400. IN OUT PSETUP_REQUEST_PAGES psrpSetupPages,
  401. IN OCMANAGER_ROUTINES ocrOcManagerHelperRoutines);
  402. VOID PrintModeInString(OUT PTCHAR tszString,
  403. IN UINT uiSetupMode);
  404. INT ButtonIdFromSetupMode(IN DWORD dwSetupMode);
  405. DWORD SetupModeFromButtonId(IN INT iButtonId);
  406. BOOL CALLBACK WizPageDlgProc(IN HWND hwnd,
  407. IN UINT uiMsg,
  408. IN WPARAM wParam,
  409. IN LPARAM lParam);
  410. #endif // _OCTEST_H