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.

486 lines
13 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Low-level debugging service interface implementations.
  4. //
  5. // Copyright (C) Microsoft Corporation, 2000-2002.
  6. //
  7. //----------------------------------------------------------------------------
  8. #ifndef __DBGSVC_HPP__
  9. #define __DBGSVC_HPP__
  10. //----------------------------------------------------------------------------
  11. //
  12. // UserDebugServices.
  13. //
  14. //----------------------------------------------------------------------------
  15. class UserDebugServices
  16. : public IUserDebugServices,
  17. public DbgRpcClientObject
  18. {
  19. public:
  20. UserDebugServices(void);
  21. virtual ~UserDebugServices(void);
  22. // IUnknown.
  23. STDMETHOD(QueryInterface)(
  24. THIS_
  25. IN REFIID InterfaceId,
  26. OUT PVOID* Interface
  27. );
  28. STDMETHOD_(ULONG, AddRef)(
  29. THIS
  30. );
  31. STDMETHOD_(ULONG, Release)(
  32. THIS
  33. );
  34. // IUserDebugServices.
  35. STDMETHOD(Initialize)(
  36. THIS_
  37. OUT PULONG Flags
  38. );
  39. STDMETHOD(Uninitialize)(
  40. THIS_
  41. IN BOOL Global
  42. );
  43. // DbgRpcClientObject.
  44. virtual HRESULT RpcInitialize(PSTR ClientIdentity, PSTR TransIdentity,
  45. PVOID* Interface);
  46. virtual void RpcFinalize(void);
  47. virtual void RpcUninitialize(void);
  48. // UserDebugServices.
  49. ULONG m_Refs;
  50. BOOL m_Initialized;
  51. char m_ClientIdentity[DBGRPC_MAX_IDENTITY];
  52. char m_TransIdentity[DBGRPC_MAX_IDENTITY];
  53. };
  54. //----------------------------------------------------------------------------
  55. //
  56. // LiveUserDebugServices.
  57. //
  58. //----------------------------------------------------------------------------
  59. class LiveUserDebugServices
  60. : public UserDebugServices
  61. {
  62. public:
  63. LiveUserDebugServices(BOOL Remote);
  64. virtual ~LiveUserDebugServices(void);
  65. // IUserDebugServices.
  66. STDMETHOD(Initialize)(
  67. THIS_
  68. OUT PULONG Flags
  69. );
  70. STDMETHOD(Uninitialize)(
  71. THIS_
  72. IN BOOL Global
  73. );
  74. STDMETHOD(GetTargetInfo)(
  75. THIS_
  76. OUT PULONG MachineType,
  77. OUT PULONG NumberProcessors,
  78. OUT PULONG PlatformId,
  79. OUT PULONG BuildNumber,
  80. OUT PULONG CheckedBuild,
  81. OUT PSTR CsdString,
  82. IN ULONG CsdStringSize,
  83. OUT PSTR BuildString,
  84. IN ULONG BuildStringSize,
  85. OUT PULONG ProductType,
  86. OUT PULONG SuiteMask
  87. );
  88. STDMETHOD(GetConnectionInfo)(
  89. THIS_
  90. OUT OPTIONAL PSTR MachineName,
  91. IN ULONG MachineNameSize,
  92. OUT OPTIONAL PSTR ClientIdentity,
  93. IN ULONG ClientIdentitySize,
  94. OUT OPTIONAL PSTR TransportIdentity,
  95. IN ULONG TransportIdentitySize
  96. );
  97. STDMETHOD(GetProcessorId)(
  98. THIS_
  99. OUT PVOID Buffer,
  100. IN ULONG BufferSize,
  101. OUT PULONG BufferUsed
  102. );
  103. STDMETHOD(GetGenericProcessorFeatures)(
  104. THIS_
  105. OUT OPTIONAL /* size_is(FeaturesSize) */ PULONG64 Features,
  106. IN ULONG FeaturesSize,
  107. OUT OPTIONAL PULONG Used
  108. );
  109. STDMETHOD(GetSpecificProcessorFeatures)(
  110. THIS_
  111. OUT OPTIONAL /* size_is(FeaturesSize) */ PULONG64 Features,
  112. IN ULONG FeaturesSize,
  113. OUT OPTIONAL PULONG Used
  114. );
  115. STDMETHOD(GetFileVersionInformationA)(
  116. THIS_
  117. IN PCWSTR File,
  118. IN PCSTR Item,
  119. OUT OPTIONAL PVOID Buffer,
  120. IN ULONG BufferSize,
  121. OUT OPTIONAL PULONG VerInfoSize
  122. );
  123. STDMETHOD(GetProcessIds)(
  124. THIS_
  125. OUT OPTIONAL /* size_is(Count) */ PULONG Ids,
  126. IN ULONG Count,
  127. OUT OPTIONAL PULONG ActualCount
  128. );
  129. STDMETHOD(GetProcessIdByExecutableNameW)(
  130. THIS_
  131. IN PCWSTR ExeName,
  132. IN ULONG Flags,
  133. OUT PULONG Id
  134. );
  135. STDMETHOD(GetProcessDescriptionW)(
  136. THIS_
  137. IN ULONG ProcessId,
  138. IN ULONG Flags,
  139. OUT OPTIONAL PWSTR ExeName,
  140. IN ULONG ExeNameSize,
  141. OUT OPTIONAL PULONG ActualExeNameSize,
  142. OUT OPTIONAL PWSTR Description,
  143. IN ULONG DescriptionSize,
  144. OUT OPTIONAL PULONG ActualDescriptionSize
  145. );
  146. STDMETHOD(GetProcessInfo)(
  147. THIS_
  148. IN ULONG ProcessId,
  149. IN ULONG Flags,
  150. OUT OPTIONAL PULONG64 Handle,
  151. OUT OPTIONAL /* size_is(InfoCount) */ PUSER_THREAD_INFO Threads,
  152. IN ULONG InfoCount,
  153. OUT OPTIONAL PULONG ThreadCount
  154. );
  155. STDMETHOD(AttachProcess)(
  156. THIS_
  157. IN ULONG ProcessId,
  158. IN ULONG AttachFlags,
  159. OUT PULONG64 ProcessHandle,
  160. OUT PULONG ProcessOptions
  161. );
  162. STDMETHOD(DetachProcess)(
  163. THIS_
  164. IN ULONG ProcessId
  165. );
  166. STDMETHOD(CreateProcessW)(
  167. THIS_
  168. IN PWSTR CommandLine,
  169. IN ULONG CreateFlags,
  170. IN BOOL InheritHandles,
  171. IN OPTIONAL PWSTR CurrentDir,
  172. OUT PULONG ProcessId,
  173. OUT PULONG ThreadId,
  174. OUT PULONG64 ProcessHandle,
  175. OUT PULONG64 ThreadHandle
  176. );
  177. STDMETHOD(TerminateProcess)(
  178. THIS_
  179. IN ULONG64 Process,
  180. IN ULONG ExitCode
  181. );
  182. STDMETHOD(AbandonProcess)(
  183. THIS_
  184. IN ULONG64 Process
  185. );
  186. STDMETHOD(GetProcessExitCode)(
  187. THIS_
  188. IN ULONG64 Process,
  189. OUT PULONG ExitCode
  190. );
  191. STDMETHOD(CloseHandle)(
  192. THIS_
  193. IN ULONG64 Handle
  194. );
  195. STDMETHOD(SetProcessOptions)(
  196. THIS_
  197. IN ULONG64 Process,
  198. IN ULONG Options
  199. );
  200. STDMETHOD(SetDebugObjectOptions)(
  201. THIS_
  202. IN ULONG64 DebugObject,
  203. IN ULONG Options
  204. );
  205. STDMETHOD(GetProcessDebugObject)(
  206. THIS_
  207. IN ULONG64 Process,
  208. OUT PULONG64 DebugObject
  209. );
  210. STDMETHOD(DuplicateHandle)(
  211. THIS_
  212. IN ULONG64 InProcess,
  213. IN ULONG64 InHandle,
  214. IN ULONG64 OutProcess,
  215. IN ULONG DesiredAccess,
  216. IN ULONG Inherit,
  217. IN ULONG Options,
  218. OUT PULONG64 OutHandle
  219. );
  220. STDMETHOD(ReadVirtual)(
  221. THIS_
  222. IN ULONG64 Process,
  223. IN ULONG64 Offset,
  224. OUT PVOID Buffer,
  225. IN ULONG BufferSize,
  226. OUT OPTIONAL PULONG BytesRead
  227. );
  228. STDMETHOD(WriteVirtual)(
  229. THIS_
  230. IN ULONG64 Process,
  231. IN ULONG64 Offset,
  232. IN PVOID Buffer,
  233. IN ULONG BufferSize,
  234. OUT OPTIONAL PULONG BytesWritten
  235. );
  236. STDMETHOD(QueryVirtual)(
  237. THIS_
  238. IN ULONG64 Process,
  239. IN ULONG64 Offset,
  240. OUT PVOID Buffer,
  241. IN ULONG BufferSize,
  242. OUT OPTIONAL PULONG BufferUsed
  243. );
  244. STDMETHOD(ProtectVirtual)(
  245. THIS_
  246. IN ULONG64 Process,
  247. IN ULONG64 Offset,
  248. IN ULONG64 Size,
  249. IN ULONG NewProtect,
  250. OUT PULONG OldProtect
  251. );
  252. STDMETHOD(AllocVirtual)(
  253. THIS_
  254. IN ULONG64 Process,
  255. IN ULONG64 Offset,
  256. IN ULONG64 Size,
  257. IN ULONG Type,
  258. IN ULONG Protect,
  259. OUT PULONG64 AllocOffset
  260. );
  261. STDMETHOD(FreeVirtual)(
  262. THIS_
  263. IN ULONG64 Process,
  264. IN ULONG64 Offset,
  265. IN ULONG64 Size,
  266. IN ULONG Type
  267. );
  268. STDMETHOD(ReadHandleData)(
  269. THIS_
  270. IN ULONG64 Process,
  271. IN ULONG64 Handle,
  272. IN ULONG DataType,
  273. OUT OPTIONAL PVOID Buffer,
  274. IN ULONG BufferSize,
  275. OUT OPTIONAL PULONG DataSize
  276. );
  277. STDMETHOD(SuspendThreads)(
  278. THIS_
  279. IN ULONG Count,
  280. IN /* size_is(Count) */ PULONG64 Threads,
  281. OUT OPTIONAL /* size_is(Count) */ PULONG SuspendCounts
  282. );
  283. STDMETHOD(ResumeThreads)(
  284. THIS_
  285. IN ULONG Count,
  286. IN /* size_is(Count) */ PULONG64 Threads,
  287. OUT OPTIONAL /* size_is(Count) */ PULONG SuspendCounts
  288. );
  289. STDMETHOD(GetThreadStartAddress)(
  290. THIS_
  291. IN ULONG64 Thread,
  292. OUT PULONG64 Offset
  293. );
  294. STDMETHOD(GetContext)(
  295. THIS_
  296. IN ULONG64 Thread,
  297. IN ULONG Flags,
  298. IN ULONG FlagsOffset,
  299. OUT PVOID Context,
  300. IN ULONG ContextSize,
  301. OUT OPTIONAL PULONG ContextUsed
  302. );
  303. STDMETHOD(SetContext)(
  304. THIS_
  305. IN ULONG64 Thread,
  306. IN PVOID Context,
  307. IN ULONG ContextSize,
  308. OUT OPTIONAL PULONG ContextUsed
  309. );
  310. STDMETHOD(GetProcessDataOffset)(
  311. THIS_
  312. IN ULONG64 Process,
  313. OUT PULONG64 Offset
  314. );
  315. STDMETHOD(GetThreadDataOffset)(
  316. THIS_
  317. IN ULONG64 Thread,
  318. OUT PULONG64 Offset
  319. );
  320. STDMETHOD(DescribeSelector)(
  321. THIS_
  322. IN ULONG64 Thread,
  323. IN ULONG Selector,
  324. OUT PVOID Buffer,
  325. IN ULONG BufferSize,
  326. OUT OPTIONAL PULONG BufferUsed
  327. );
  328. STDMETHOD(GetCurrentTimeDateN)(
  329. THIS_
  330. OUT PULONG64 TimeDate
  331. );
  332. STDMETHOD(GetCurrentSystemUpTimeN)(
  333. THIS_
  334. OUT PULONG64 UpTime
  335. );
  336. STDMETHOD(GetProcessUpTimeN)(
  337. THIS_
  338. IN ULONG64 Process,
  339. OUT PULONG64 UpTime
  340. );
  341. STDMETHOD(GetProcessTimes)(
  342. THIS_
  343. IN ULONG64 Process,
  344. OUT PULONG64 Create,
  345. OUT PULONG64 Exit,
  346. OUT PULONG64 Kernel,
  347. OUT PULONG64 User
  348. );
  349. STDMETHOD(GetThreadTimes)(
  350. THIS_
  351. IN ULONG64 Thread,
  352. OUT PULONG64 Create,
  353. OUT PULONG64 Exit,
  354. OUT PULONG64 Kernel,
  355. OUT PULONG64 User
  356. );
  357. STDMETHOD(RequestBreakIn)(
  358. THIS_
  359. IN ULONG64 Process
  360. );
  361. STDMETHOD(WaitForEvent)(
  362. THIS_
  363. IN ULONG Timeout,
  364. OUT PVOID Buffer,
  365. IN ULONG BufferSize,
  366. OUT OPTIONAL PULONG BufferUsed
  367. );
  368. STDMETHOD(ContinueEvent)(
  369. THIS_
  370. IN ULONG ContinueStatus
  371. );
  372. STDMETHOD(InsertCodeBreakpoint)(
  373. THIS_
  374. IN ULONG64 Process,
  375. IN ULONG64 Offset,
  376. IN ULONG MachineType,
  377. OUT PVOID Storage,
  378. IN ULONG StorageSize
  379. );
  380. STDMETHOD(RemoveCodeBreakpoint)(
  381. THIS_
  382. IN ULONG64 Process,
  383. IN ULONG64 Offset,
  384. IN ULONG MachineType,
  385. IN PVOID Storage,
  386. IN ULONG StorageSize
  387. );
  388. STDMETHOD(InsertDataBreakpoint)(
  389. THIS_
  390. IN ULONG64 Process,
  391. IN ULONG64 Thread,
  392. IN ULONG64 Offset,
  393. IN ULONG AccessLength,
  394. IN ULONG AccessType,
  395. IN ULONG MachineType
  396. );
  397. STDMETHOD(RemoveDataBreakpoint)(
  398. THIS_
  399. IN ULONG64 Process,
  400. IN ULONG64 Thread,
  401. IN ULONG64 Offset,
  402. IN ULONG AccessLength,
  403. IN ULONG AccessType,
  404. IN ULONG MachineType
  405. );
  406. STDMETHOD(GetLastDataBreakpointHit)(
  407. THIS_
  408. IN ULONG64 Process,
  409. IN ULONG64 Thread,
  410. OUT PULONG64 Address,
  411. OUT PULONG AccessType
  412. );
  413. STDMETHOD(GetFunctionTableListHead)(
  414. THIS_
  415. IN ULONG64 Process,
  416. OUT PULONG64 Offset
  417. );
  418. STDMETHOD(GetOutOfProcessFunctionTableW)(
  419. THIS_
  420. IN ULONG64 Process,
  421. IN PWSTR Dll,
  422. IN ULONG64 LoadedDllHandle,
  423. IN ULONG64 Table,
  424. IN OPTIONAL PVOID Buffer,
  425. IN ULONG BufferSize,
  426. OUT OPTIONAL PULONG TableSize,
  427. OUT OPTIONAL PULONG64 UsedDllHandle
  428. );
  429. STDMETHOD(GetUnloadedModuleListHead)(
  430. THIS_
  431. IN ULONG64 Process,
  432. OUT PULONG64 Offset
  433. );
  434. STDMETHOD(LoadLibrary)(
  435. THIS_
  436. IN PWSTR Path,
  437. OUT PULONG64 Handle
  438. );
  439. STDMETHOD(FreeLibrary)(
  440. THIS_
  441. IN ULONG64 Handle
  442. );
  443. // LiveUserDebugServices.
  444. ULONG m_ContextSize;
  445. ULONG m_SysProcInfoSize;
  446. BOOL m_Remote;
  447. ULONG m_EventProcessId;
  448. ULONG m_EventThreadId;
  449. ULONG m_PlatformId;
  450. BOOL m_Win95;
  451. HANDLE m_DebugObject;
  452. BOOL m_UseDebugObject;
  453. HRESULT SysGetProcessOptions(HANDLE Process, PULONG Options);
  454. HRESULT OpenDebugActiveProcess(ULONG ProcessId, HANDLE Process);
  455. HRESULT CreateDebugActiveProcess(ULONG ProcessId, HANDLE Process,
  456. ULONG AttachFlags);
  457. };
  458. // This global instance is intended for direct use only
  459. // by routines which need a temporary local service instance.
  460. extern LiveUserDebugServices g_LiveUserDebugServices;
  461. #define SERVER_SERVICES(Server) \
  462. ((Server) != 0 ? (PUSER_DEBUG_SERVICES)(Server) : &g_LiveUserDebugServices)
  463. // A client of the services can watch this variable to
  464. // see if any instance has received an Uninitialize request.
  465. extern ULONG g_UserServicesUninitialized;
  466. #endif // #ifndef __DBGSVC_HPP__