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.

1193 lines
24 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. instaler.h
  5. Abstract:
  6. Main include file for the INSTALER application.
  7. Author:
  8. Steve Wood (stevewo) 09-Aug-1994
  9. Revision History:
  10. --*/
  11. #ifdef RC_INVOKED
  12. #include <windows.h>
  13. #define FILEBMP 500
  14. #define DIRBMP 501
  15. #else
  16. #include <nt.h>
  17. #include <ntrtl.h>
  18. #include <nturtl.h>
  19. #include <windows.h>
  20. #include <vdmdbg.h>
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include "errormsg.h"
  25. //
  26. // Data structures and entry points in ERROR.C
  27. //
  28. #define TRACE_ENABLED 1
  29. #if TRACE_ENABLED
  30. extern ULONG EnabledTraceEvents;
  31. #define DBG_MASK_DBGEVENT 0x00000001
  32. #define DBG_MASK_INTERNALERROR 0x00000002
  33. #define DBG_MASK_MEMORYERROR 0x00000004
  34. #define DBG_MASK_CREATEEVENT 0x00000008
  35. VOID
  36. TraceDisplay(
  37. const char *FormatString,
  38. ...
  39. );
  40. #define DbgEvent( m, x ) if (EnabledTraceEvents & (DBG_MASK_##m)) TraceDisplay x
  41. #define TestDbgEvent( m ) (EnabledTraceEvents & (DBG_MASK_##m))
  42. #else
  43. #define DbgEvent( m, x )
  44. #define TestDbgEvent( m ) (FALSE)
  45. #endif
  46. VOID
  47. CDECL
  48. DeclareError(
  49. UINT ErrorCode,
  50. UINT SupplementalErrorCode,
  51. ...
  52. );
  53. UINT
  54. CDECL
  55. AskUser(
  56. UINT MessageBoxFlags,
  57. UINT MessageId,
  58. UINT NumberOfArguments,
  59. ...
  60. );
  61. //
  62. // Data structures and entry points in EVENT.C
  63. //
  64. VOID
  65. CDECL
  66. LogEvent(
  67. UINT MessageId,
  68. UINT NumberOfArguments,
  69. ...
  70. );
  71. //
  72. // Data structures and entry points in PROCESS.C
  73. //
  74. #define HANDLE_TYPE_FILE 0
  75. #define HANDLE_TYPE_KEY 1
  76. #define HANDLE_TYPE_NONE 2
  77. typedef struct _OPENHANDLE_INFO {
  78. LIST_ENTRY Entry;
  79. HANDLE Handle;
  80. BOOLEAN Inherit;
  81. BOOLEAN RootDirectory;
  82. USHORT Type;
  83. USHORT LengthOfName;
  84. PWSTR Name;
  85. //
  86. // Union for handlers that need to store state in a handle during
  87. // use.
  88. //
  89. union {
  90. PWSTR QueryName;
  91. };
  92. } OPENHANDLE_INFO, *POPENHANDLE_INFO;
  93. typedef struct _PROCESS_INFO {
  94. LIST_ENTRY Entry;
  95. LIST_ENTRY ThreadListHead;
  96. LIST_ENTRY BreakpointListHead;
  97. LIST_ENTRY OpenHandleListHead;
  98. DWORD Id;
  99. HANDLE Handle;
  100. PROCESS_BASIC_INFORMATION ProcessInformation;
  101. WCHAR ImageFileName[ 32 ];
  102. } PROCESS_INFO, *PPROCESS_INFO;
  103. typedef struct _THREAD_INFO {
  104. LIST_ENTRY Entry;
  105. LIST_ENTRY BreakpointListHead;
  106. DWORD Id;
  107. HANDLE Handle;
  108. PVOID StartAddress;
  109. ULONG ModuleIndexCurrentlyIn;
  110. BOOLEAN SingleStepExpected;
  111. struct _BREAKPOINT_INFO *BreakpointToStepOver;
  112. } THREAD_INFO, *PTHREAD_INFO;
  113. LIST_ENTRY ProcessListHead;
  114. BOOLEAN
  115. AddProcess(
  116. LPDEBUG_EVENT DebugEvent,
  117. PPROCESS_INFO *ReturnedProcess
  118. );
  119. BOOLEAN
  120. DeleteProcess(
  121. PPROCESS_INFO Process
  122. );
  123. BOOLEAN
  124. AddThread(
  125. LPDEBUG_EVENT DebugEvent,
  126. PPROCESS_INFO Process,
  127. PTHREAD_INFO *ReturnedThread
  128. );
  129. BOOLEAN
  130. DeleteThread(
  131. PPROCESS_INFO Process,
  132. PTHREAD_INFO Thread
  133. );
  134. PPROCESS_INFO
  135. FindProcessById(
  136. ULONG Id
  137. );
  138. BOOLEAN
  139. FindProcessAndThreadForEvent(
  140. LPDEBUG_EVENT DebugEvent,
  141. PPROCESS_INFO *ReturnedProcess,
  142. PTHREAD_INFO *ReturnedThread
  143. );
  144. BOOLEAN
  145. HandleThreadsForSingleStep(
  146. PPROCESS_INFO Process,
  147. PTHREAD_INFO ThreadToSingleStep,
  148. BOOLEAN SuspendThreads
  149. );
  150. BOOLEAN
  151. ReadMemory(
  152. PPROCESS_INFO Process,
  153. PVOID Address,
  154. PVOID DataRead,
  155. ULONG BytesToRead,
  156. PCHAR Reason
  157. );
  158. BOOLEAN
  159. WriteMemory(
  160. PPROCESS_INFO Process,
  161. PVOID Address,
  162. PVOID DataToWrite,
  163. ULONG BytesToWrite,
  164. PCHAR Reason
  165. );
  166. PVOID
  167. AllocMem(
  168. ULONG Size
  169. );
  170. VOID
  171. FreeMem(
  172. PVOID *p
  173. );
  174. //
  175. // Data structures and entry points in MACHINE.C
  176. //
  177. PVOID BreakpointInstruction;
  178. ULONG SizeofBreakpointInstruction;
  179. PVOID
  180. GetAddressForEntryPointBreakpoint(
  181. PVOID EntryPointAddress,
  182. DWORD NumberOfFunctionTableEntries OPTIONAL,
  183. PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionTableEntries OPTIONAL
  184. );
  185. BOOLEAN
  186. SkipOverHardcodedBreakpoint(
  187. PPROCESS_INFO Process,
  188. PTHREAD_INFO Thread,
  189. PVOID BreakpointAddress
  190. );
  191. BOOLEAN
  192. ExtractProcedureParameters(
  193. PPROCESS_INFO Process,
  194. PTHREAD_INFO Thread,
  195. PULONG ReturnAddress,
  196. ULONG SizeOfParameters,
  197. PULONG Parameters
  198. );
  199. BOOLEAN
  200. ExtractProcedureReturnValue(
  201. PPROCESS_INFO Process,
  202. PTHREAD_INFO Thread,
  203. PVOID ReturnValue,
  204. ULONG SizeOfReturnValue
  205. );
  206. BOOLEAN
  207. SetProcedureReturnValue(
  208. PPROCESS_INFO Process,
  209. PTHREAD_INFO Thread,
  210. PVOID ReturnValue,
  211. ULONG SizeOfReturnValue
  212. );
  213. BOOLEAN
  214. ForceReturnToCaller(
  215. PPROCESS_INFO Process,
  216. PTHREAD_INFO Thread,
  217. ULONG SizeOfParameters,
  218. PVOID ReturnAddress,
  219. PVOID ReturnValue,
  220. ULONG SizeOfReturnValue
  221. );
  222. BOOLEAN
  223. UndoReturnAddressBreakpoint(
  224. PPROCESS_INFO Process,
  225. PTHREAD_INFO Thread
  226. );
  227. BOOLEAN
  228. BeginSingleStepBreakpoint(
  229. PPROCESS_INFO Process,
  230. PTHREAD_INFO Thread
  231. );
  232. BOOLEAN
  233. EndSingleStepBreakpoint(
  234. PPROCESS_INFO Process,
  235. PTHREAD_INFO Thread
  236. );
  237. typedef enum _API_ACTION {
  238. QueryPath,
  239. OpenPath,
  240. RenamePath,
  241. DeletePath,
  242. SetValue,
  243. DeleteValue,
  244. WriteIniValue,
  245. WriteIniSection
  246. } API_ACTION;
  247. typedef struct _API_SAVED_CALL_STATE {
  248. LIST_ENTRY Entry;
  249. API_ACTION Action;
  250. ULONG Type;
  251. PWSTR FullName;
  252. PVOID Reference;
  253. union {
  254. struct {
  255. BOOLEAN InheritHandle;
  256. BOOLEAN WriteAccessRequested;
  257. PHANDLE ResultHandleAddress;
  258. } PathOpen;
  259. struct {
  260. PWSTR NewName;
  261. BOOLEAN ReplaceIfExists;
  262. } PathRename;
  263. struct {
  264. PWSTR SectionName;
  265. PWSTR VariableName;
  266. PWSTR VariableValue;
  267. } SetIniValue;
  268. struct {
  269. PWSTR SectionName;
  270. PWSTR SectionValue;
  271. } SetIniSection;
  272. };
  273. } API_SAVED_CALL_STATE, *PAPI_SAVED_CALL_STATE;
  274. BOOLEAN
  275. CreateSavedCallState(
  276. PPROCESS_INFO Process,
  277. PAPI_SAVED_CALL_STATE SavedCallState,
  278. API_ACTION Action,
  279. ULONG Type,
  280. PWSTR FullName,
  281. ...
  282. );
  283. VOID
  284. FreeSavedCallState(
  285. PAPI_SAVED_CALL_STATE CallState
  286. );
  287. //
  288. // Data structures and entry points in HANDLER.C
  289. //
  290. typedef struct _CREATEFILE_PARAMETERS {
  291. PHANDLE FileHandle;
  292. ACCESS_MASK DesiredAccess;
  293. POBJECT_ATTRIBUTES ObjectAttributes;
  294. PIO_STATUS_BLOCK IoStatusBlock;
  295. PLARGE_INTEGER AllocationSize;
  296. ULONG FileAttributes;
  297. ULONG ShareAccess;
  298. ULONG CreateDisposition;
  299. ULONG CreateOptions;
  300. } CREATEFILE_PARAMETERS, *PCREATEFILE_PARAMETERS;
  301. typedef struct _OPENFILE_PARAMETERS {
  302. PHANDLE FileHandle;
  303. ACCESS_MASK DesiredAccess;
  304. POBJECT_ATTRIBUTES ObjectAttributes;
  305. PIO_STATUS_BLOCK IoStatusBlock;
  306. ULONG ShareAccess;
  307. ULONG OpenOptions;
  308. } OPENFILE_PARAMETERS, *POPENFILE_PARAMETERS;
  309. typedef struct _DELETEFILE_PARAMETERS {
  310. POBJECT_ATTRIBUTES ObjectAttributes;
  311. } DELETEFILE_PARAMETERS, *PDELETEFILE_PARAMETERS;
  312. typedef struct _SETINFORMATIONFILE_PARAMETERS {
  313. HANDLE FileHandle;
  314. PIO_STATUS_BLOCK IoStatusBlock;
  315. PVOID FileInformation;
  316. ULONG Length;
  317. FILE_INFORMATION_CLASS FileInformationClass;
  318. } SETINFORMATIONFILE_PARAMETERS, *PSETINFORMATIONFILE_PARAMETERS;
  319. typedef struct _QUERYATTRIBUTESFILE_PARAMETERS {
  320. POBJECT_ATTRIBUTES ObjectAttributes;
  321. PFILE_BASIC_INFORMATION FileInformation;
  322. } QUERYATTRIBUTESFILE_PARAMETERS, *PQUERYATTRIBUTESFILE_PARAMETERS;
  323. typedef struct _QUERYDIRECTORYFILE_PARAMETERS {
  324. HANDLE FileHandle;
  325. HANDLE Event;
  326. PIO_APC_ROUTINE ApcRoutine;
  327. PVOID ApcContext;
  328. PIO_STATUS_BLOCK IoStatusBlock;
  329. PVOID FileInformation;
  330. ULONG Length;
  331. FILE_INFORMATION_CLASS FileInformationClass;
  332. BOOLEAN ReturnSingleEntry;
  333. PUNICODE_STRING FileName;
  334. BOOLEAN RestartScan;
  335. } QUERYDIRECTORYFILE_PARAMETERS, *PQUERYDIRECTORYFILE_PARAMETERS;
  336. typedef struct _CREATEKEY_PARAMETERS {
  337. PHANDLE KeyHandle;
  338. ACCESS_MASK DesiredAccess;
  339. POBJECT_ATTRIBUTES ObjectAttributes;
  340. ULONG TitleIndex;
  341. PUNICODE_STRING Class;
  342. ULONG CreateOptions;
  343. PULONG Disposition;
  344. } CREATEKEY_PARAMETERS, *PCREATEKEY_PARAMETERS;
  345. typedef struct _OPENKEY_PARAMETERS {
  346. PHANDLE KeyHandle;
  347. ACCESS_MASK DesiredAccess;
  348. POBJECT_ATTRIBUTES ObjectAttributes;
  349. } OPENKEY_PARAMETERS, *POPENKEY_PARAMETERS;
  350. typedef struct _DELETEKEY_PARAMETERS {
  351. HANDLE KeyHandle;
  352. } DELETEKEY_PARAMETERS, *PDELETEKEY_PARAMETERS;
  353. typedef struct _SETVALUEKEY_PARAMETERS {
  354. HANDLE KeyHandle;
  355. PUNICODE_STRING ValueName;
  356. ULONG TitleIndex;
  357. ULONG Type;
  358. PVOID Data;
  359. ULONG DataLength;
  360. } SETVALUEKEY_PARAMETERS, *PSETVALUEKEY_PARAMETERS;
  361. typedef struct _DELETEVALUEKEY_PARAMETERS {
  362. HANDLE KeyHandle;
  363. PUNICODE_STRING ValueName;
  364. } DELETEVALUEKEY_PARAMETERS, *PDELETEVALUEKEY_PARAMETERS;
  365. typedef struct _CLOSEHANDLE_PARAMETERS {
  366. HANDLE Handle;
  367. } CLOSEHANDLE_PARAMETERS, *PCLOSEHANDLE_PARAMETERS;
  368. typedef struct _GETVERSIONEXW_PARAMETERS {
  369. LPOSVERSIONINFOA lpVersionInformation;
  370. } GETVERSIONEXW_PARAMETERS, *PGETVERSIONEXW_PARAMETERS;
  371. typedef struct _SETCURRENTDIRECTORYA_PARAMETERS {
  372. LPSTR lpPathName;
  373. } SETCURRENTDIRECTORYA_PARAMETERS, *PSETCURRENTDIRECTORYA_PARAMETERS;
  374. typedef struct _SETCURRENTDIRECTORYW_PARAMETERS {
  375. PWSTR lpPathName;
  376. } SETCURRENTDIRECTORYW_PARAMETERS, *PSETCURRENTDIRECTORYW_PARAMETERS;
  377. typedef struct _WRITEPRIVATEPROFILESTRINGA_PARAMETERS {
  378. LPCSTR lpAppName;
  379. LPCSTR lpKeyName;
  380. LPCSTR lpString;
  381. LPCSTR lpFileName;
  382. } WRITEPRIVATEPROFILESTRINGA_PARAMETERS, *PWRITEPRIVATEPROFILESTRINGA_PARAMETERS;
  383. typedef struct _WRITEPRIVATEPROFILESTRINGW_PARAMETERS {
  384. LPCWSTR lpAppName;
  385. LPCWSTR lpKeyName;
  386. LPCWSTR lpString;
  387. LPCWSTR lpFileName;
  388. } WRITEPRIVATEPROFILESTRINGW_PARAMETERS, *PWRITEPRIVATEPROFILESTRINGW_PARAMETERS;
  389. typedef struct _WRITEPRIVATEPROFILESECTIONA_PARAMETERS {
  390. LPCSTR lpAppName;
  391. LPCSTR lpString;
  392. LPCSTR lpFileName;
  393. } WRITEPRIVATEPROFILESECTIONA_PARAMETERS, *PWRITEPRIVATEPROFILESECTIONA_PARAMETERS;
  394. typedef struct _WRITEPRIVATEPROFILESECTIONW_PARAMETERS {
  395. LPCWSTR lpAppName;
  396. LPCWSTR lpString;
  397. LPCWSTR lpFileName;
  398. } WRITEPRIVATEPROFILESECTIONW_PARAMETERS, *PWRITEPRIVATEPROFILESECTIONW_PARAMETERS;
  399. typedef struct _REGCONNECTREGISTRYW_PARAMETERS {
  400. LPWSTR lpMachineName;
  401. HKEY hKey;
  402. PHKEY phkResult;
  403. } REGCONNECTREGISTRYW_PARAMETERS, *PREGCONNECTREGISTRYW_PARAMETERS;
  404. typedef struct _EXITWINDOWSEX_PARAMETERS {
  405. DWORD uFlags;
  406. DWORD dwReserved;
  407. } EXITWINDOWSEX_PARAMETERS, *PEXITWINDOWSEX_PARAMETERS;
  408. typedef struct _API_SAVED_PARAMETERS {
  409. API_SAVED_CALL_STATE SavedCallState;
  410. union {
  411. CREATEFILE_PARAMETERS CreateFile;
  412. OPENFILE_PARAMETERS OpenFile;
  413. DELETEFILE_PARAMETERS DeleteFile;
  414. SETINFORMATIONFILE_PARAMETERS SetInformationFile;
  415. QUERYATTRIBUTESFILE_PARAMETERS QueryAttributesFile;
  416. QUERYDIRECTORYFILE_PARAMETERS QueryDirectoryFile;
  417. CREATEKEY_PARAMETERS CreateKey;
  418. OPENKEY_PARAMETERS OpenKey;
  419. DELETEKEY_PARAMETERS DeleteKey;
  420. SETVALUEKEY_PARAMETERS SetValueKey;
  421. DELETEVALUEKEY_PARAMETERS DeleteValueKey;
  422. CLOSEHANDLE_PARAMETERS CloseHandle;
  423. GETVERSIONEXW_PARAMETERS GetVersionExW;
  424. SETCURRENTDIRECTORYA_PARAMETERS SetCurrentDirectoryA;
  425. SETCURRENTDIRECTORYW_PARAMETERS SetCurrentDirectoryW;
  426. WRITEPRIVATEPROFILESTRINGA_PARAMETERS WritePrivateProfileStringA;
  427. WRITEPRIVATEPROFILESTRINGW_PARAMETERS WritePrivateProfileStringW;
  428. WRITEPRIVATEPROFILESECTIONA_PARAMETERS WritePrivateProfileSectionA;
  429. WRITEPRIVATEPROFILESECTIONW_PARAMETERS WritePrivateProfileSectionW;
  430. REGCONNECTREGISTRYW_PARAMETERS RegConnectRegistryW;
  431. EXITWINDOWSEX_PARAMETERS ExitWindowsEx;
  432. } InputParameters;
  433. PVOID ReturnAddress;
  434. union {
  435. UCHAR ReturnedByte;
  436. USHORT ReturnedShort;
  437. ULONG ReturnedLong;
  438. ULONGLONG ReturnedQuad;
  439. BOOL ReturnedBool;
  440. } ReturnValue;
  441. BOOLEAN ReturnValueValid;
  442. //
  443. // Union for handlers that need to store state between entry and
  444. // exit, without the overhead of allocating an API_SAVED_CALL_STATE
  445. //
  446. union {
  447. BOOLEAN AbortCall;
  448. PWSTR CurrentDirectory;
  449. };
  450. } API_SAVED_PARAMETERS, *PAPI_SAVED_PARAMETERS;
  451. BOOLEAN
  452. NtCreateFileHandler(
  453. PPROCESS_INFO Process,
  454. PTHREAD_INFO Thread,
  455. PAPI_SAVED_PARAMETERS Parameters
  456. );
  457. BOOLEAN
  458. NtOpenFileHandler(
  459. PPROCESS_INFO Process,
  460. PTHREAD_INFO Thread,
  461. PAPI_SAVED_PARAMETERS Parameters
  462. );
  463. BOOLEAN
  464. NtDeleteFileHandler(
  465. PPROCESS_INFO Process,
  466. PTHREAD_INFO Thread,
  467. PAPI_SAVED_PARAMETERS Parameters
  468. );
  469. BOOLEAN
  470. NtSetInformationFileHandler(
  471. PPROCESS_INFO Process,
  472. PTHREAD_INFO Thread,
  473. PAPI_SAVED_PARAMETERS Parameters
  474. );
  475. BOOLEAN
  476. NtQueryAttributesFileHandler(
  477. PPROCESS_INFO Process,
  478. PTHREAD_INFO Thread,
  479. PAPI_SAVED_PARAMETERS Parameters
  480. );
  481. BOOLEAN
  482. NtQueryDirectoryFileHandler(
  483. PPROCESS_INFO Process,
  484. PTHREAD_INFO Thread,
  485. PAPI_SAVED_PARAMETERS Parameters
  486. );
  487. BOOLEAN
  488. NtCreateKeyHandler(
  489. PPROCESS_INFO Process,
  490. PTHREAD_INFO Thread,
  491. PAPI_SAVED_PARAMETERS Parameters
  492. );
  493. BOOLEAN
  494. NtOpenKeyHandler(
  495. PPROCESS_INFO Process,
  496. PTHREAD_INFO Thread,
  497. PAPI_SAVED_PARAMETERS Parameters
  498. );
  499. BOOLEAN
  500. NtDeleteKeyHandler(
  501. PPROCESS_INFO Process,
  502. PTHREAD_INFO Thread,
  503. PAPI_SAVED_PARAMETERS Parameters
  504. );
  505. BOOLEAN
  506. NtSetValueKeyHandler(
  507. PPROCESS_INFO Process,
  508. PTHREAD_INFO Thread,
  509. PAPI_SAVED_PARAMETERS Parameters
  510. );
  511. BOOLEAN
  512. NtDeleteValueKeyHandler(
  513. PPROCESS_INFO Process,
  514. PTHREAD_INFO Thread,
  515. PAPI_SAVED_PARAMETERS Parameters
  516. );
  517. BOOLEAN
  518. NtCloseHandleHandler(
  519. PPROCESS_INFO Process,
  520. PTHREAD_INFO Thread,
  521. PAPI_SAVED_PARAMETERS Parameters
  522. );
  523. BOOLEAN
  524. GetVersionHandler(
  525. PPROCESS_INFO Process,
  526. PTHREAD_INFO Thread,
  527. PAPI_SAVED_PARAMETERS Parameters
  528. );
  529. BOOLEAN
  530. GetVersionExWHandler(
  531. PPROCESS_INFO Process,
  532. PTHREAD_INFO Thread,
  533. PAPI_SAVED_PARAMETERS Parameters
  534. );
  535. BOOLEAN
  536. SetCurrentDirectoryAHandler(
  537. PPROCESS_INFO Process,
  538. PTHREAD_INFO Thread,
  539. PAPI_SAVED_PARAMETERS Parameters
  540. );
  541. BOOLEAN
  542. SetCurrentDirectoryWHandler(
  543. PPROCESS_INFO Process,
  544. PTHREAD_INFO Thread,
  545. PAPI_SAVED_PARAMETERS Parameters
  546. );
  547. BOOLEAN
  548. WritePrivateProfileStringAHandler(
  549. PPROCESS_INFO Process,
  550. PTHREAD_INFO Thread,
  551. PAPI_SAVED_PARAMETERS Parameters
  552. );
  553. BOOLEAN
  554. WritePrivateProfileStringWHandler(
  555. PPROCESS_INFO Process,
  556. PTHREAD_INFO Thread,
  557. PAPI_SAVED_PARAMETERS Parameters
  558. );
  559. BOOLEAN
  560. WritePrivateProfileSectionAHandler(
  561. PPROCESS_INFO Process,
  562. PTHREAD_INFO Thread,
  563. PAPI_SAVED_PARAMETERS Parameters
  564. );
  565. BOOLEAN
  566. WritePrivateProfileSectionWHandler(
  567. PPROCESS_INFO Process,
  568. PTHREAD_INFO Thread,
  569. PAPI_SAVED_PARAMETERS Parameters
  570. );
  571. BOOLEAN
  572. RegConnectRegistryWHandler(
  573. PPROCESS_INFO Process,
  574. PTHREAD_INFO Thread,
  575. PAPI_SAVED_PARAMETERS Parameters
  576. );
  577. BOOLEAN
  578. ExitWindowsExHandler(
  579. PPROCESS_INFO Process,
  580. PTHREAD_INFO Thread,
  581. PAPI_SAVED_PARAMETERS Parameters
  582. );
  583. //
  584. // Data structures and entry points in DEBUG.C
  585. //
  586. CRITICAL_SECTION BreakTable;
  587. typedef struct _BREAKPOINT_INFO {
  588. LIST_ENTRY Entry;
  589. PVOID Address;
  590. UCHAR ApiIndex;
  591. PWSTR ModuleName;
  592. LPSTR ProcedureName;
  593. BOOLEAN SavedInstructionValid;
  594. BOOLEAN SavedParametersValid;
  595. union {
  596. UCHAR Byte;
  597. USHORT Short;
  598. ULONG Long;
  599. ULONGLONG LongLong;
  600. } SavedInstruction;
  601. API_SAVED_PARAMETERS SavedParameters;
  602. } BREAKPOINT_INFO, *PBREAKPOINT_INFO;
  603. VOID
  604. DebugEventLoop( VOID );
  605. BOOLEAN
  606. InstallBreakpoint(
  607. PPROCESS_INFO Process,
  608. PBREAKPOINT_INFO Breakpoint
  609. );
  610. BOOLEAN
  611. RemoveBreakpoint(
  612. PPROCESS_INFO Process,
  613. PBREAKPOINT_INFO Breakpoint
  614. );
  615. BOOLEAN
  616. HandleBreakpoint(
  617. PPROCESS_INFO Process,
  618. PTHREAD_INFO Thread,
  619. PBREAKPOINT_INFO Breakpoint
  620. );
  621. BOOLEAN
  622. CreateBreakpoint(
  623. PVOID Address,
  624. PPROCESS_INFO Process,
  625. PTHREAD_INFO Thread,
  626. UCHAR ApiIndex,
  627. PVOID SavedParameters,
  628. PBREAKPOINT_INFO *Breakpoint
  629. );
  630. BOOLEAN
  631. DestroyBreakpoint(
  632. PVOID Address,
  633. PPROCESS_INFO Process,
  634. PTHREAD_INFO Thread
  635. );
  636. PBREAKPOINT_INFO
  637. FindBreakpoint(
  638. PVOID Address,
  639. PPROCESS_INFO Process,
  640. PTHREAD_INFO Thread
  641. );
  642. VOID
  643. SuspendAllButThisThread(
  644. PPROCESS_INFO Process,
  645. PTHREAD_INFO Thread
  646. );
  647. VOID
  648. ResumeAllButThisThread(
  649. PPROCESS_INFO Process,
  650. PTHREAD_INFO Thread
  651. );
  652. //
  653. // Data structures and entry points in HANDLEDB.C
  654. //
  655. POPENHANDLE_INFO
  656. FindOpenHandle(
  657. PPROCESS_INFO Process,
  658. HANDLE Handle,
  659. ULONG Type
  660. );
  661. BOOLEAN
  662. AddOpenHandle(
  663. PPROCESS_INFO Process,
  664. HANDLE Handle,
  665. ULONG Type,
  666. PWSTR Name,
  667. BOOLEAN InheritHandle
  668. );
  669. BOOLEAN
  670. DeleteOpenHandle(
  671. PPROCESS_INFO Process,
  672. HANDLE Handle,
  673. ULONG Type
  674. );
  675. VOID
  676. InheritHandles(
  677. PPROCESS_INFO Process
  678. );
  679. //
  680. // Data structures and entry points in FILE.C
  681. //
  682. typedef struct _FILE_REFERENCE {
  683. LIST_ENTRY Entry;
  684. PWSTR Name;
  685. ULONG PrefixLength;
  686. BOOLEAN WriteAccess;
  687. BOOLEAN Deleted;
  688. BOOLEAN Created;
  689. BOOLEAN AttributesModified;
  690. BOOLEAN DateModified;
  691. BOOLEAN ContentsModified;
  692. BOOLEAN DirectoryFile;
  693. USHORT BackupFileUniqueId;
  694. DWORD BackupFileAttributes;
  695. FILETIME BackupLastWriteTime;
  696. ULARGE_INTEGER BackupFileSize;
  697. } FILE_REFERENCE, *PFILE_REFERENCE;
  698. BOOLEAN
  699. CreateFileReference(
  700. PWSTR Name,
  701. BOOLEAN WriteAccess,
  702. PFILE_REFERENCE *ReturnedReference
  703. );
  704. BOOLEAN
  705. CompleteFileReference(
  706. PFILE_REFERENCE p,
  707. BOOLEAN CallSuccessful,
  708. BOOLEAN Delete,
  709. PFILE_REFERENCE RenameReference
  710. );
  711. BOOLEAN
  712. DestroyFileReference(
  713. PFILE_REFERENCE p
  714. );
  715. BOOLEAN
  716. IsNewFileSameAsBackup(
  717. PFILE_REFERENCE p
  718. );
  719. PFILE_REFERENCE
  720. FindFileReference(
  721. PWSTR Name
  722. );
  723. VOID
  724. DumpFileReferenceList(
  725. FILE *LogFile
  726. );
  727. //
  728. // Data structures and entry points in KEY.C
  729. //
  730. typedef struct _KEY_REFERENCE {
  731. LIST_ENTRY Entry;
  732. PWSTR Name;
  733. ULONG PrefixLength;
  734. BOOLEAN WriteAccess;
  735. BOOLEAN Deleted;
  736. BOOLEAN Created;
  737. PKEY_FULL_INFORMATION BackupKeyInfo;
  738. LIST_ENTRY ValueReferencesListHead;
  739. } KEY_REFERENCE, *PKEY_REFERENCE;
  740. typedef struct _VALUE_REFERENCE {
  741. LIST_ENTRY Entry;
  742. PWSTR Name;
  743. BOOLEAN Modified;
  744. BOOLEAN Deleted;
  745. BOOLEAN Created;
  746. PKEY_VALUE_PARTIAL_INFORMATION Value;
  747. KEY_VALUE_PARTIAL_INFORMATION OriginalValue;
  748. } VALUE_REFERENCE, *PVALUE_REFERENCE;
  749. BOOLEAN
  750. CreateKeyReference(
  751. PWSTR Name,
  752. BOOLEAN WriteAccess,
  753. PKEY_REFERENCE *ReturnedReference
  754. );
  755. BOOLEAN
  756. CompleteKeyReference(
  757. PKEY_REFERENCE p,
  758. BOOLEAN CallSuccessful,
  759. BOOLEAN Delete
  760. );
  761. BOOLEAN
  762. DestroyKeyReference(
  763. PKEY_REFERENCE p
  764. );
  765. PKEY_REFERENCE
  766. FindKeyReference(
  767. PWSTR Name
  768. );
  769. VOID
  770. MarkKeyDeleted(
  771. PKEY_REFERENCE KeyReference
  772. );
  773. BOOLEAN
  774. CreateValueReference(
  775. PPROCESS_INFO Process,
  776. PKEY_REFERENCE KeyReference,
  777. PWSTR Name,
  778. ULONG TitleIndex,
  779. ULONG Type,
  780. PVOID Data,
  781. ULONG DataLength,
  782. PVALUE_REFERENCE *ReturnedValueReference
  783. );
  784. PVALUE_REFERENCE
  785. FindValueReference(
  786. PKEY_REFERENCE KeyReference,
  787. PWSTR Name
  788. );
  789. BOOLEAN
  790. DestroyValueReference(
  791. PVALUE_REFERENCE p
  792. );
  793. VOID
  794. DumpKeyReferenceList(
  795. FILE *LogFile
  796. );
  797. //
  798. // Data structures and entry points in INI.C
  799. //
  800. typedef struct _INI_FILE_REFERENCE {
  801. LIST_ENTRY Entry;
  802. PWSTR Name;
  803. ULONG PrefixLength;
  804. BOOLEAN Created;
  805. FILETIME BackupLastWriteTime;
  806. LIST_ENTRY SectionReferencesListHead;
  807. } INI_FILE_REFERENCE, *PINI_FILE_REFERENCE;
  808. typedef struct _INI_SECTION_REFERENCE {
  809. LIST_ENTRY Entry;
  810. PWSTR Name;
  811. BOOLEAN Deleted;
  812. BOOLEAN Created;
  813. LIST_ENTRY VariableReferencesListHead;
  814. } INI_SECTION_REFERENCE, *PINI_SECTION_REFERENCE;
  815. typedef struct _INI_VARIABLE_REFERENCE {
  816. LIST_ENTRY Entry;
  817. PWSTR Name;
  818. BOOLEAN Modified;
  819. BOOLEAN Deleted;
  820. BOOLEAN Created;
  821. PWSTR OriginalValue;
  822. PWSTR Value;
  823. } INI_VARIABLE_REFERENCE, *PINI_VARIABLE_REFERENCE;
  824. BOOLEAN
  825. CreateIniFileReference(
  826. PWSTR Name,
  827. PINI_FILE_REFERENCE *ReturnedReference
  828. );
  829. BOOLEAN
  830. DestroyIniFileReference(
  831. PINI_FILE_REFERENCE p
  832. );
  833. BOOLEAN
  834. DestroyIniSectionReference(
  835. PINI_SECTION_REFERENCE p1
  836. );
  837. BOOLEAN
  838. DestroyIniVariableReference(
  839. PINI_VARIABLE_REFERENCE p2
  840. );
  841. PINI_FILE_REFERENCE
  842. FindIniFileReference(
  843. PWSTR Name
  844. );
  845. PINI_SECTION_REFERENCE
  846. FindIniSectionReference(
  847. PINI_FILE_REFERENCE p,
  848. PWSTR Name,
  849. BOOLEAN CreateOkay
  850. );
  851. PINI_VARIABLE_REFERENCE
  852. FindIniVariableReference(
  853. PINI_SECTION_REFERENCE p1,
  854. PWSTR Name,
  855. BOOLEAN CreateOkay
  856. );
  857. VOID
  858. DumpIniFileReferenceList(
  859. FILE *LogFile
  860. );
  861. //
  862. // Data structures and entry points in NAMEDB.C
  863. //
  864. PWSTR
  865. AddName(
  866. PUNICODE_STRING Name
  867. );
  868. VOID
  869. DumpNameDataBase(
  870. FILE *LogFile
  871. );
  872. BOOLEAN
  873. IncrementOpenCount(
  874. PWSTR Name,
  875. BOOLEAN CallSuccessful
  876. );
  877. ULONG
  878. QueryOpenCount(
  879. PWSTR Name,
  880. BOOLEAN CallSuccessful
  881. );
  882. //
  883. // Data structures and entry points in INIT.C
  884. //
  885. HMODULE InstalerModuleHandle;
  886. HANDLE AppHeap;
  887. UNICODE_STRING WindowsDirectory;
  888. ULONG StartProcessTickCount;
  889. FILE *InstalerLogFile;
  890. BOOLEAN AskUserOnce;
  891. BOOLEAN DefaultGetVersionToWin95;
  892. BOOLEAN FailAllScansOfRootDirectories;
  893. LIST_ENTRY FileReferenceListHead;
  894. ULONG NumberOfFileReferences;
  895. LIST_ENTRY KeyReferenceListHead;
  896. ULONG NumberOfKeyReferences;
  897. LIST_ENTRY IniReferenceListHead;
  898. ULONG NumberOfIniReferences;
  899. #define NTDLL_MODULE_INDEX 0
  900. #define KERNEL32_MODULE_INDEX 1
  901. #define ADVAPI32_MODULE_INDEX 2
  902. #define USER32_MODULE_INDEX 3
  903. #define MAXIMUM_MODULE_INDEX 4
  904. typedef struct _MODULE_INFO {
  905. PWSTR ModuleName;
  906. HMODULE ModuleHandle;
  907. } MODULE_INFO, *PMODULE_INFO;
  908. MODULE_INFO ModuleInfo[ MAXIMUM_MODULE_INDEX ];
  909. typedef BOOLEAN (*PAPI_HANDLER)(
  910. PPROCESS_INFO Process,
  911. PTHREAD_INFO Thread,
  912. PAPI_SAVED_PARAMETERS Parameters
  913. );
  914. typedef struct _API_INFO {
  915. ULONG ModuleIndex;
  916. LPSTR EntryPointName; // Exported names are ANSI only
  917. PVOID EntryPointAddress;
  918. PAPI_HANDLER EntryPointHandler;
  919. ULONG SizeOfParameters;
  920. ULONG SizeOfReturnValue;
  921. } API_INFO, *PAPI_INFO;
  922. #define NTCREATEFILE_INDEX 0
  923. #define NTOPENFILE_INDEX 1
  924. #define NTDELETEFILE_INDEX 2
  925. #define NTSETINFORMATIONFILE_INDEX 3
  926. #define NTQUERYATTRIBUTESFILE_INDEX 4
  927. #define NTQUERYDIRECTORYFILE_INDEX 5
  928. #define NTCREATEKEY_INDEX 6
  929. #define NTOPENKEY_INDEX 7
  930. #define NTDELETEKEY_INDEX 8
  931. #define NTSETVALUEKEY_INDEX 9
  932. #define NTDELETEVALUEKEY_INDEX 10
  933. #define NTCLOSEHANDLE_INDEX 11
  934. #define GETVERSION_INDEX 12
  935. #define GETVERSIONEXW_INDEX 13
  936. #define SETCURRENTDIRECTORYA_INDEX 14
  937. #define SETCURRENTDIRECTORYW_INDEX 15
  938. #define WRITEPRIVATEPROFILESTRINGA_INDEX 16
  939. #define WRITEPRIVATEPROFILESTRINGW_INDEX 17
  940. #define WRITEPRIVATEPROFILESECTIONA_INDEX 18
  941. #define WRITEPRIVATEPROFILESECTIONW_INDEX 19
  942. #define GETPRIVATEPROFILESTRINGA_INDEX 20
  943. #define GETPRIVATEPROFILESTRINGW_INDEX 21
  944. #define GETPRIVATEPROFILESECTIONA_INDEX 22
  945. #define GETPRIVATEPROFILESECTIONW_INDEX 23
  946. #define REGCONNECTREGISTRYW_INDEX 24
  947. #define EXITWINDOWSEX_INDEX 25
  948. #define MAXIMUM_API_INDEX 26
  949. API_INFO ApiInfo[ MAXIMUM_API_INDEX ];
  950. typedef struct _DRIVE_LETTER_INFO {
  951. WCHAR DriveLetter;
  952. BOOLEAN DriveLetterValid;
  953. UNICODE_STRING NtLinkTarget;
  954. } DRIVE_LETTER_INFO, *PDRIVE_LETTER_INFO;
  955. UNICODE_STRING UNCPrefix;
  956. UNICODE_STRING DriveLetterPrefix;
  957. UNICODE_STRING AltDriveLetterPrefix;
  958. DRIVE_LETTER_INFO DriveLetters[ 32 ];
  959. BOOLEAN
  960. InitializeInstaler(
  961. int argc,
  962. char *argv[]
  963. );
  964. PVOID
  965. LookupEntryPointInIAT(
  966. HMODULE ModuleHandle,
  967. PCHAR EntryPointName
  968. );
  969. BOOLEAN
  970. IsDriveLetterPath(
  971. PUNICODE_STRING Path
  972. );
  973. PVOID TemporaryBuffer;
  974. ULONG TemporaryBufferLength;
  975. ULONG TemporaryBufferLengthGrowth;
  976. ULONG TemporaryBufferMaximumLength;
  977. VOID
  978. TrimTemporaryBuffer( VOID );
  979. BOOLEAN
  980. GrowTemporaryBuffer(
  981. ULONG NeededSize
  982. );
  983. ULONG
  984. FillTemporaryBuffer(
  985. PPROCESS_INFO Process,
  986. PVOID Address,
  987. BOOLEAN Unicode,
  988. BOOLEAN DoubleNullTermination
  989. );
  990. #include "instutil.h"
  991. #include "iml.h"
  992. PINSTALLATION_MODIFICATION_LOGFILE pImlNew;
  993. #endif // defined( RC_INVOKED )