hotspot/agent/src/os/win32/nt4internals.hpp
author never
Mon, 04 May 2009 22:06:47 -0700
changeset 2744 57f0579fbe09
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6837224: libsaproc.so on linux needs version of 6799141 Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2000-2001 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#ifndef _NT4INTERNALS_H_
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#define _NT4INTERNALS_H_
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
#include <windows.h>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
namespace NT4 {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
extern "C" {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// Data structures and constants required to be able to get necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// debugging-related information on Windows NT 4.0 through internal
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// (i.e., non-public) APIs. These are adapted from those in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// _Windows NT/2000 Native API Reference_ by Gary Nebbett, Macmillan
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// Technical Publishing, 201 West 103rd Street, Indianapolis, IN
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// 46290, 2000.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
typedef LONG NTSTATUS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
typedef LONG KPRIORITY;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
#define NTAPI __stdcall
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
#define _cdecl
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
#define NTAPI
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
typedef enum _SYSTEM_INFORMATION_CLASS {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  SystemProcessesAndThreadsInformation = 5
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
} SYSTEM_INFORMATION_CLASS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
typedef struct _UNICODE_STRING {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  USHORT Length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  USHORT MaximumLength;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  PWSTR  Buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
} UNICODE_STRING;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
typedef struct _VM_COUNTERS {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  ULONG PeakVirtualSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  ULONG VirtualSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  ULONG PageFaultCount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  ULONG PeakWorkingSetSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  ULONG WorkingSetSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  ULONG QuotaPeakPagedPoolUsage;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  ULONG QuotaPagedPoolUsage;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  ULONG QuotaPeakNonPagedPoolUsage;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  ULONG QuotaNonPagedPoolUsage;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  ULONG PagefileUsage;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  ULONG PeakPagefileUsage;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
} VM_COUNTERS, *PVM_COUNTERS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
typedef struct _IO_COUNTERS {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  LARGE_INTEGER ReadOperationCount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  LARGE_INTEGER WriteOperationCount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  LARGE_INTEGER OtherOperationCount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  LARGE_INTEGER ReadTransferCount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  LARGE_INTEGER WriteTransferCount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  LARGE_INTEGER OtherTransferCount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
} IO_COUNTERS, *PIO_COUNTERS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
typedef struct _CLIENT_ID {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  HANDLE UniqueProcess;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  HANDLE UniqueThread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
} CLIENT_ID, *PCLIENT_ID;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
typedef enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  StateInitialized,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  StateReady,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  StateRunning,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  StateStandby,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  StateTerminated,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  StateWait,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  StateTransition,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  StateUnknown
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
} THREAD_STATE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
typedef enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  Executive,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  FreePage,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  PageIn,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  PoolAllocation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  DelayExecution,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  Suspended,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  UserRequest,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  WrExecutive,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  WrFreePage,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  WrPageIn,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  WrPoolAllocation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  WrDelayExecution,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  WrSuspended,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  WrUserRequest,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  WrEventPair,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  WrQueue,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  WrLpcReceive,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  WrLpcReply,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  WrVirtualMemory,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  WrPageOut,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  WrRendezvous,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  Spare2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  Spare3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  Spare4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  Spare5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  Spare6,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  WrKernel
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
} KWAIT_REASON;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
typedef struct _SYSTEM_THREADS {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  LARGE_INTEGER KernelTime;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  LARGE_INTEGER UserTime;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  LARGE_INTEGER CreateTime;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  ULONG WaitTime;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  PVOID StartAddress;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  CLIENT_ID ClientId;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  KPRIORITY Priority;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  KPRIORITY BasePriority;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  ULONG ContextSwitchCount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  THREAD_STATE State;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  KWAIT_REASON WaitReason;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
} SYSTEM_THREADS, *PSYSTEM_THREADS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
typedef struct _SYSTEM_PROCESSES { // Information class 5
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  ULONG NextEntryDelta;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  ULONG ThreadCount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  ULONG Reserved1[6];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  LARGE_INTEGER CreateTime;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  LARGE_INTEGER UserTime;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  LARGE_INTEGER KernelTime;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  UNICODE_STRING ProcessName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  KPRIORITY BasePriority;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  ULONG ProcessId;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  ULONG InheritedFromProcessId;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  ULONG HandleCount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  ULONG Reserved2[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  ULONG PrivatePageCount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  VM_COUNTERS VmCounters;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  IO_COUNTERS IoCounters; // Windows 2000 only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  SYSTEM_THREADS Threads[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
} SYSTEM_PROCESSES, *PSYSTEM_PROCESSES;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
typedef NTSTATUS NTAPI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
ZwQuerySystemInformationFunc(IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
                             IN OUT PVOID SystemInformation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
                             IN ULONG SystemInformationLength,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
                             OUT PULONG ReturnLength OPTIONAL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
                             );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
typedef struct _DEBUG_BUFFER {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  HANDLE SectionHandle;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  PVOID  SectionBase;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  PVOID  RemoteSectionBase;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  ULONG  SectionBaseDelta;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  HANDLE EventPairHandle;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  ULONG  Unknown[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  HANDLE RemoteThreadHandle;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  ULONG  InfoClassMask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  ULONG  SizeOfInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  ULONG  AllocatedSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  ULONG  SectionSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  PVOID  ModuleInformation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  PVOID  BackTraceInformation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  PVOID  HeapInformation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  PVOID  LockInformation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  PVOID  Reserved[8];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
} DEBUG_BUFFER, *PDEBUG_BUFFER;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
typedef PDEBUG_BUFFER NTAPI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
RtlCreateQueryDebugBufferFunc(IN ULONG Size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
                              IN BOOLEAN EventPair);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
#define PDI_MODULES     0x01 // The loaded modules of the process
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
#define PDI_BACKTRACE   0x02 // The heap stack back traces
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
#define PDI_HEAPS       0x04 // The heaps of the process
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
#define PDI_HEAP_TAGS   0x08 // The heap tags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
#define PDI_HEAP_BLOCKS 0x10 // The heap blocks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
#define PDI_LOCKS       0x20 // The locks created by the process
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
typedef struct _DEBUG_MODULE_INFORMATION { // c.f. SYSTEM_MODULE_INFORMATION
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  ULONG  Reserved[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  ULONG  Base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  ULONG  Size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  ULONG  Flags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  USHORT Index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  USHORT Unknown;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  USHORT LoadCount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  USHORT ModuleNameOffset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  CHAR   ImageName[256];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
} DEBUG_MODULE_INFORMATION, *PDEBUG_MODULE_INFORMATION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
// Flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
#define LDRP_STATIC_LINK             0x00000002
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
#define LDRP_IMAGE_DLL               0x00000004
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
#define LDRP_LOAD_IN_PROGRESS        0x00001000
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
#define LDRP_UNLOAD_IN_PROGRESS      0x00002000
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
#define LDRP_ENTRY_PROCESSED         0x00004000
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
#define LDRP_ENTRY_INSERTED          0x00008000
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
#define LDRP_CURRENT_LOAD            0x00010000
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
#define LDRP_FAILED_BUILTIN_LOAD     0x00020000
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
#define LDRP_DONT_CALL_FOR_THREADS   0x00040000
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
#define LDRP_PROCESS_ATTACH_CALLED   0x00080000
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
#define LDRP_DEBUG_SYMBOLS_LOADED    0x00100000
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
#define LDRP_IMAGE_NOT_AT_BASE       0x00200000
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
#define LDRP_WX86_IGNORE_MACHINETYPE 0x00400000
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
// NOTE that this will require creating a thread in the target
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
// process, implying that we can not call this while the process is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
// suspended. May have to run this command in the child processes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
// rather than the server.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
typedef NTSTATUS NTAPI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
RtlQueryProcessDebugInformationFunc(IN ULONG ProcessId,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
                                    IN ULONG DebugInfoClassMask,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
                                    IN OUT PDEBUG_BUFFER DebugBuffer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
typedef NTSTATUS NTAPI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
RtlDestroyQueryDebugBufferFunc(IN PDEBUG_BUFFER DebugBuffer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
// Routines to load and unload NTDLL.DLL.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
HMODULE loadNTDLL();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
// Safe to call even if has not been loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
void    unloadNTDLL();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
} // extern "C"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
} // namespace NT4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
//----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
// On NT 4 only, we now use PSAPI to enumerate the loaded modules in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
// the target processes. RtlQueryProcessDebugInformation creates a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
// thread in the target process, which causes problems when we are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
// handling events like breakpoints in the debugger. The dependence on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
// an external DLL which might not be present is unfortunate, but we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
// can either redistribute this DLL (if allowed) or refuse to start on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
// NT 4 if it is not present.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
typedef struct _MODULEINFO {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    LPVOID lpBaseOfDll;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    DWORD SizeOfImage;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    LPVOID EntryPoint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
} MODULEINFO, *LPMODULEINFO;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
typedef BOOL (WINAPI EnumProcessModulesFunc)(HANDLE, HMODULE *, DWORD, LPDWORD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
typedef DWORD (WINAPI GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
typedef BOOL (WINAPI GetModuleInformationFunc)(HANDLE, HMODULE, LPMODULEINFO, DWORD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
// Routines to load and unload PSAPI.DLL.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
HMODULE loadPSAPIDLL();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
// Safe to call even if has not been loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
void    unloadPSAPIDLL();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
#endif // #defined _NT4INTERNALS_H_