| OLD | NEW |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 304 |
| 305 // This is a partial definition of the TEB, as we do not currently use many | 305 // This is a partial definition of the TEB, as we do not currently use many |
| 306 // fields of it. See http://www.nirsoft.net/kernel_struct/vista/TEB.html. | 306 // fields of it. See http://www.nirsoft.net/kernel_struct/vista/TEB.html. |
| 307 template <class Traits> | 307 template <class Traits> |
| 308 struct TEB { | 308 struct TEB { |
| 309 NT_TIB<Traits> NtTib; | 309 NT_TIB<Traits> NtTib; |
| 310 typename Traits::Pointer EnvironmentPointer; | 310 typename Traits::Pointer EnvironmentPointer; |
| 311 CLIENT_ID<Traits> ClientId; | 311 CLIENT_ID<Traits> ClientId; |
| 312 }; | 312 }; |
| 313 | 313 |
| 314 // See https://msdn.microsoft.com/en-us/library/gg750724.aspx for the base | 314 // See https://msdn.microsoft.com/en-us/library/gg750724.aspx. |
| 315 // structure, and | |
| 316 // http://processhacker.sourceforge.net/doc/struct___s_y_s_t_e_m___e_x_t_e_n_d_e
_d___t_h_r_e_a_d___i_n_f_o_r_m_a_t_i_o_n.html | |
| 317 // for the extension part. | |
| 318 template <class Traits> | 315 template <class Traits> |
| 319 struct SYSTEM_EXTENDED_THREAD_INFORMATION { | 316 struct SYSTEM_THREAD_INFORMATION { |
| 320 LARGE_INTEGER KernelTime; | |
| 321 LARGE_INTEGER UserTime; | |
| 322 LARGE_INTEGER CreateTime; | |
| 323 union { | 317 union { |
| 324 ULONG WaitTime; | 318 struct { |
| 325 typename Traits::Pad padding_for_x64_0; | 319 LARGE_INTEGER KernelTime; |
| 320 LARGE_INTEGER UserTime; |
| 321 LARGE_INTEGER CreateTime; |
| 322 union { |
| 323 ULONG WaitTime; |
| 324 typename Traits::Pad padding_for_x64_0; |
| 325 }; |
| 326 typename Traits::Pointer StartAddress; |
| 327 CLIENT_ID<Traits> ClientId; |
| 328 LONG Priority; |
| 329 LONG BasePriority; |
| 330 ULONG ContextSwitches; |
| 331 ULONG ThreadState; |
| 332 union { |
| 333 ULONG WaitReason; |
| 334 typename Traits::Pad padding_for_x64_1; |
| 335 }; |
| 336 }; |
| 337 LARGE_INTEGER alignment_for_x86[8]; |
| 326 }; | 338 }; |
| 327 typename Traits::Pointer StartAddress; | 339 }; |
| 328 CLIENT_ID<Traits> ClientId; | 340 |
| 329 LONG Priority; | 341 // There's an extra field in the x64 VM_COUNTERS (or maybe it's VM_COUNTERS_EX, |
| 330 LONG BasePriority; | 342 // it's not clear), so we just make separate specializations for 32/64. |
| 331 ULONG ContextSwitches; | 343 template <class Traits> |
| 332 ULONG ThreadState; | 344 class VM_COUNTERS {}; |
| 345 |
| 346 template <> |
| 347 class VM_COUNTERS<internal::Traits32> { |
| 348 SIZE_T PeakVirtualSize; |
| 349 SIZE_T VirtualSize; |
| 350 ULONG PageFaultCount; |
| 351 SIZE_T PeakWorkingSetSize; |
| 352 SIZE_T WorkingSetSize; |
| 353 SIZE_T QuotaPeakPagedPoolUsage; |
| 354 SIZE_T QuotaPagedPoolUsage; |
| 355 SIZE_T QuotaPeakNonPagedPoolUsage; |
| 356 SIZE_T QuotaNonPagedPoolUsage; |
| 357 SIZE_T PagefileUsage; |
| 358 SIZE_T PeakPagefileUsage; |
| 359 }; |
| 360 |
| 361 template <> |
| 362 class VM_COUNTERS<internal::Traits64> { |
| 363 SIZE_T PeakVirtualSize; |
| 364 SIZE_T VirtualSize; |
| 333 union { | 365 union { |
| 334 ULONG WaitReason; | 366 ULONG PageFaultCount; |
| 335 typename Traits::Pad padding_for_x64_1; | 367 internal::Traits64::Pad padding_for_x64; |
| 336 }; | 368 }; |
| 337 typename Traits::Pointer StackBase; // These don't appear to be correct. | 369 SIZE_T PeakWorkingSetSize; |
| 338 typename Traits::Pointer StackLimit; | 370 SIZE_T WorkingSetSize; |
| 339 typename Traits::Pointer Win32StartAddress; | 371 SIZE_T QuotaPeakPagedPoolUsage; |
| 340 typename Traits::Pointer TebBase; | 372 SIZE_T QuotaPagedPoolUsage; |
| 341 typename Traits::Pointer Reserved; | 373 SIZE_T QuotaPeakNonPagedPoolUsage; |
| 342 typename Traits::Pointer Reserved2; | 374 SIZE_T QuotaNonPagedPoolUsage; |
| 343 typename Traits::Pointer Reserved3; | 375 SIZE_T PagefileUsage; |
| 376 SIZE_T PeakPagefileUsage; |
| 377 SIZE_T PrivateUsage; |
| 344 }; | 378 }; |
| 345 | 379 |
| 346 // See http://undocumented.ntinternals.net/source/usermode/undocumented%20functi
ons/system%20information/structures/system_process_information.html | 380 // See http://undocumented.ntinternals.net/source/usermode/undocumented%20functi
ons/system%20information/structures/system_process_information.html |
| 347 template <class Traits> | 381 template <class Traits> |
| 348 struct SYSTEM_PROCESS_INFORMATION { | 382 struct SYSTEM_PROCESS_INFORMATION { |
| 349 ULONG NextEntryOffset; | 383 ULONG NextEntryOffset; |
| 350 ULONG NumberOfThreads; | 384 ULONG NumberOfThreads; |
| 351 LARGE_INTEGER Reserved[3]; | 385 LARGE_INTEGER WorkingSetPrivateSize; |
| 386 ULONG HardFaultCount; |
| 387 ULONG NumberOfThreadsHighWatermark; |
| 388 ULONGLONG CycleTime; |
| 352 LARGE_INTEGER CreateTime; | 389 LARGE_INTEGER CreateTime; |
| 353 LARGE_INTEGER UserTime; | 390 LARGE_INTEGER UserTime; |
| 354 LARGE_INTEGER KernelTime; | 391 LARGE_INTEGER KernelTime; |
| 355 UNICODE_STRING<Traits> ImageName; | 392 UNICODE_STRING<Traits> ImageName; |
| 356 union { | 393 union { |
| 357 LONG BasePriority; | 394 LONG BasePriority; |
| 358 typename Traits::Pad padding_for_x64_0; | 395 typename Traits::Pad padding_for_x64_0; |
| 359 }; | 396 }; |
| 360 union { | 397 union { |
| 361 DWORD UniqueProcessId; | 398 DWORD UniqueProcessId; |
| 362 typename Traits::Pad padding_for_x64_1; | 399 typename Traits::Pad padding_for_x64_1; |
| 363 }; | 400 }; |
| 364 union { | 401 union { |
| 365 DWORD InheritedFromUniqueProcessId; | 402 DWORD InheritedFromUniqueProcessId; |
| 366 typename Traits::Pad padding_for_x64_2; | 403 typename Traits::Pad padding_for_x64_2; |
| 367 }; | 404 }; |
| 368 ULONG HandleCount; | 405 ULONG HandleCount; |
| 369 ULONG Reserved2[3]; | 406 ULONG SessionId; |
| 370 SIZE_T PeakVirtualSize; | 407 typename Traits::Pointer UniqueProcessKey; |
| 371 SIZE_T VirtualSize; | |
| 372 union { | 408 union { |
| 373 ULONG PageFaultCount; | 409 VM_COUNTERS<Traits> VirtualMemoryCounters; |
| 374 typename Traits::Pad padding_for_x64_3; | 410 LARGE_INTEGER alignment_for_x86[6]; |
| 375 }; | 411 }; |
| 376 SIZE_T PeakWorkingSetSize; | 412 IO_COUNTERS IoCounters; |
| 377 SIZE_T WorkingSetSize; | 413 SYSTEM_THREAD_INFORMATION<Traits> Threads[1]; |
| 378 SIZE_T QuotaPeakPagedPoolUsage; | 414 }; |
| 379 SIZE_T QuotaPagedPoolUsage; | 415 |
| 380 SIZE_T QuotaPeakNonPagedPoolUsage; | 416 // http://undocumented.ntinternals.net/source/usermode/structures/thread_basic_i
nformation.html |
| 381 SIZE_T QuotaNonPagedPoolUsage; | 417 template <class Traits> |
| 382 SIZE_T PagefileUsage; | 418 struct THREAD_BASIC_INFORMATION { |
| 383 SIZE_T PeakPagefileUsage; | 419 union { |
| 384 SIZE_T PrivatePageCount; | 420 NTSTATUS ExitStatus; |
| 385 LARGE_INTEGER ReadOperationCount; | 421 typename Traits::Pad padding_for_x64_0; |
| 386 LARGE_INTEGER WriteOperationCount; | 422 }; |
| 387 LARGE_INTEGER OtherOperationCount; | 423 typename Traits::Pointer TebBaseAddress; |
| 388 LARGE_INTEGER ReadTransferCount; | 424 CLIENT_ID<Traits> ClientId; |
| 389 LARGE_INTEGER WriteTransferCount; | 425 typename Traits::Pointer AffinityMask; |
| 390 LARGE_INTEGER OtherTransferCount; | 426 ULONG Priority; |
| 391 SYSTEM_EXTENDED_THREAD_INFORMATION<Traits> Threads[1]; | 427 LONG BasePriority; |
| 392 }; | 428 }; |
| 393 | 429 |
| 394 #pragma pack(pop) | 430 #pragma pack(pop) |
| 395 | 431 |
| 396 //! \} | 432 //! \} |
| 397 | 433 |
| 398 } // namespace process_types | 434 } // namespace process_types |
| 399 } // namespace crashpad | 435 } // namespace crashpad |
| 400 | 436 |
| 401 #endif // CRASHPAD_UTIL_WIN_PROCESS_STRUCTS_H_ | 437 #endif // CRASHPAD_UTIL_WIN_PROCESS_STRUCTS_H_ |
| OLD | NEW |