File: fpdtype.pas

package info (click to toggle)
lazarus 2.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 214,460 kB
  • sloc: pascal: 1,862,622; xml: 265,709; cpp: 56,595; sh: 3,008; java: 609; makefile: 535; perl: 297; sql: 222; ansic: 137
file content (488 lines) | stat: -rw-r--r-- 13,059 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
{ $Id $ }
{
 ---------------------------------------------------------------------------
 fpdtype.pas  -  FP standalone debugger - Type definitions
 ---------------------------------------------------------------------------

 This unit contains types/consts not yet part of the RTL.
 It also contains some experimental types for mixing win32 and win64

 ---------------------------------------------------------------------------

 @created(Mon Apr 10th WET 2006)
 @lastmod($Date: 2013-05-24 20:30:06 +0200 (Fr, 24 Mai 2013) $)
 @author(Marc Weustink <marc@@dommelstein.nl>)

 *****************************************************************************
  This file is part of the Lazarus Project

  See the file COPYING.modifiedLGPL.txt, included in this distribution,
  for details about the license.
 *****************************************************************************
}
unit FPDType;

{$mode objfpc}{$H+}
{$ALIGN ON}

// Additional bit types, not all in RTL

interface

uses
  Windows;

const
  FACILITY_DEBUGGER                                  = $001;
  FACILITY_RPC_RUNTIME                               = $002;
  FACILITY_RPC_STUBS                                 = $003;
  FACILITY_IO_ERROR_CODE                             = $004;
  FACILITY_TERMINAL_SERVER                           = $00A;
  FACILITY_USB_ERROR_CODE                            = $010;
  FACILITY_HID_ERROR_CODE                            = $011;
  FACILITY_FIREWIRE_ERROR_CODE                       = $012;
  FACILITY_CLUSTER_ERROR_CODE                        = $013;
  FACILITY_ACPI_ERROR_CODE                           = $014;
  FACILITY_SXS_ERROR_CODE                            = $015;

  STATUS_SEVERITY_SUCCESS                            = $0;
  STATUS_SEVERITY_INFORMATIONAL                      = $1;
  STATUS_SEVERITY_WARNING                            = $2;
  STATUS_SEVERITY_ERROR                              = $3;

  STATUS_FLOAT_MULTIPLE_FAULTS = $C00002B4;
  STATUS_FLOAT_MULTIPLE_TRAPS = $C00002B5;
  STATUS_REG_NAT_CONSUMPTION = $C00002C9;
  STATUS_SXS_EARLY_DEACTIVATION = $C015000F;
  STATUS_SXS_INVALID_DEACTIVATION = $C0150010;


//type
//  DWORD64 = QWORD;
//  ULONGLONG = QWORD;
//  LONGLONG = int64;
  //QWORD = type cardinal;

{.$if declared(THREAD_SUSPEND_RESUME)}
{.$else}
const
  THREAD_TERMINATE               = $0001;
  THREAD_SUSPEND_RESUME          = $0002;
  THREAD_GET_CONTEXT             = $0008;
  THREAD_SET_CONTEXT             = $0010;
  THREAD_SET_INFORMATION         = $0020;
  THREAD_QUERY_INFORMATION       = $0040;
  THREAD_SET_THREAD_TOKEN        = $0080;
  THREAD_IMPERSONATE             = $0100;
  THREAD_DIRECT_IMPERSONATION    = $0200;

  THREAD_ALL_ACCESS              = STANDARD_RIGHTS_REQUIRED or SYNCHRONIZE or $3FF;
{.$endif}

{$if declared(EXCEPTION_READ_FAULT)}
{$else}
const
  EXCEPTION_READ_FAULT    = 0; // Access violation was caused by a read
  EXCEPTION_WRITE_FAULT   = 1; // Access violation was caused by a write
  EXCEPTION_EXECUTE_FAULT = 8; // Access violation was caused by an instruction fetch
{$endif}

{$if declared(TExceptionRecord32)}
{$else}
type
  TExceptionRecord32 = record
    ExceptionCode : DWORD;
    ExceptionFlags : DWORD;
    ExceptionRecord : DWORD;
    ExceptionAddress : DWORD;
    NumberParameters : DWORD;
    ExceptionInformation : array[0..(EXCEPTION_MAXIMUM_PARAMETERS)-1] of DWORD;
  end;
  PExceptionRecord32 = ^TExceptionRecord32;
{$endif}

{$if declared(TExceptionDebugInfo32)}
{$else}
type
  TExceptionDebugInfo32 = record
    ExceptionRecord : TExceptionRecord32;
    dwFirstChance : DWORD;
  end;
  PExceptionDebugInfo32 = ^TExceptionDebugInfo32;
{$endif}

{$if declared(TExceptionRecord64)}
{$else}
type
  TExceptionRecord64 = record
    ExceptionCode: DWORD;
    ExceptionFlags: DWORD;
    ExceptionRecord: DWORD64;
    ExceptionAddress: DWORD64;
    NumberParameters: DWORD;
    __unusedAlignment: DWORD;
    ExceptionInformation: array[0..EXCEPTION_MAXIMUM_PARAMETERS - 1] of DWORD64;
  end;
  PExceptionRecord64 = ^TExceptionRecord64;
{$endif}

{$if declared(TExceptionDebugInfo64)}
{$else}
type
  TExceptionDebugInfo64 = record
    ExceptionRecord : TExceptionRecord64;
    dwFirstChance : DWORD;
  end;
  PExceptionDebugInfo64 = ^TExceptionDebugInfo64;
{$endif}



(*
  PContext64 = QWORD;
  PExceptionPointers64 = QWORD;
  _EXCEPTION_POINTERS64 = record
    ExceptionRecord : PExceptionRecord64;
    ContextRecord : PContext64;
  end;
  TExceptionPointers64 = _EXCEPTION_POINTERS64;
  EXCEPTION_POINTERS64 = _EXCEPTION_POINTERS64;
*)
//  PExceptionDebugInfo64 = QWORD;
(*
  PExceptionDebugInfo64 = ^_EXCEPTION_DEBUG_INFO64;
  _EXCEPTION_DEBUG_INFO64 = record
    ExceptionRecord: TExceptionRecord64;
    dwFirstChance: DWORD;
  end;
  TExceptionDebugInfo64 = _EXCEPTION_DEBUG_INFO64;
  EXCEPTION_DEBUG_INFO64 = _EXCEPTION_DEBUG_INFO64;
*)
(*
  PCreateThreadDebugInfo64 = QWORD;
  _CREATE_THREAD_DEBUG_INFO64 = record
    hThread: QWORD;
    lpThreadLocalBase: QWORD;
    lpStartAddress: QWORD;
  end;
  TCreateThreadDebugInfo = _CREATE_THREAD_DEBUG_INFO;
  CREATE_THREAD_DEBUG_INFO = _CREATE_THREAD_DEBUG_INFO;

  PCreateProcessDebugInfo = QWORD;
  _CREATE_PROCESS_DEBUG_INFO = record
    hFile: THandle;
    hProcess: THandle;
    hThread: THandle;
    lpBaseOfImage: Pointer;
    dwDebugInfoFileOffset: DWORD;
    nDebugInfoSize: DWORD;
    lpThreadLocalBase: Pointer;
    lpStartAddress: TFNThreadStartRoutine;
    lpImageName: Pointer;
    fUnicode: Word;
  end;
  TCreateProcessDebugInfo = _CREATE_PROCESS_DEBUG_INFO;
  CREATE_PROCESS_DEBUG_INFO = _CREATE_PROCESS_DEBUG_INFO;

  PExitThreadDebugInfo64 = QWORD;
  PExitProcessDebugInfo64 = QWORD;

  PLoadDLLDebugInfo64 = QWORD;
  _LOAD_DLL_DEBUG_INFO64 = record
    hFile: QWORD;
    lpBaseOfDll: QWORD;
    dwDebugInfoFileOffset: DWORD;
    nDebugInfoSize: DWORD;
    lpImageName: Pointer;
    fUnicode: Word;
  end;
  {$EXTERNALSYM _LOAD_DLL_DEBUG_INFO}
  TLoadDLLDebugInfo = _LOAD_DLL_DEBUG_INFO;
  LOAD_DLL_DEBUG_INFO = _LOAD_DLL_DEBUG_INFO;
  {$EXTERNALSYM LOAD_DLL_DEBUG_INFO}

  PUnloadDLLDebugInfo = ^TUnloadDLLDebugInfo;
  _UNLOAD_DLL_DEBUG_INFO = record
    lpBaseOfDll: Pointer;
  end;
  {$EXTERNALSYM _UNLOAD_DLL_DEBUG_INFO}
  TUnloadDLLDebugInfo = _UNLOAD_DLL_DEBUG_INFO;
  UNLOAD_DLL_DEBUG_INFO = _UNLOAD_DLL_DEBUG_INFO;
  {$EXTERNALSYM UNLOAD_DLL_DEBUG_INFO}

  POutputDebugStringInfo = ^TOutputDebugStringInfo;
  _OUTPUT_DEBUG_STRING_INFO = record
    lpDebugStringData: LPSTR;
    fUnicode: Word;
    nDebugStringLength: Word;
  end;
  {$EXTERNALSYM _OUTPUT_DEBUG_STRING_INFO}
  TOutputDebugStringInfo = _OUTPUT_DEBUG_STRING_INFO;
  OUTPUT_DEBUG_STRING_INFO = _OUTPUT_DEBUG_STRING_INFO;
  {$EXTERNALSYM OUTPUT_DEBUG_STRING_INFO}

  PRIPInfo64 = QWORD;
*)

(*
  PDebugEvent64 = ^TDebugEvent64;
  _DEBUG_EVENT64 = record
    dwDebugEventCode: DWORD;
    dwProcessId: DWORD;
    dwThreadId: DWORD;
    case Integer of
      0: (Exception: TExceptionDebugInfo);
      1: (CreateThread: TCreateThreadDebugInfo);
      2: (CreateProcessInfo: TCreateProcessDebugInfo);
      3: (ExitThread: TExitThreadDebugInfo);
      4: (ExitProcess: TExitProcessDebugInfo);
      5: (LoadDll: TLoadDLLDebugInfo);
      6: (UnloadDll: TUnloadDLLDebugInfo);
      7: (DebugString: TOutputDebugStringInfo);
      8: (RipInfo: TRIPInfo);
      9: (Exception64: TExceptionDebugInfo64);
  end;
  TDebugEvent64 = _DEBUG_EVENT64;
  DEBUG_EVENT64 = _DEBUG_EVENT64;
*)

{$ifdef __dont_use__}
const

  CONTEXT_AMD64 =  $100000;

// MWE: added _AMD64 postfix to distinguish between i386 and amd64

  CONTEXT_CONTROL_AMD64         = (CONTEXT_AMD64 or $00000001);
  CONTEXT_INTEGER_AMD64         = (CONTEXT_AMD64 or $00000002);
  CONTEXT_SEGMENTS_AMD64        = (CONTEXT_AMD64 or $00000004);
  CONTEXT_FLOATING_POINT_AMD64  = (CONTEXT_AMD64 or $00000008);
  CONTEXT_DEBUG_REGISTERS_AMD64 = (CONTEXT_AMD64 or $00000010);

  CONTEXT_FULL_AMD64            = (CONTEXT_CONTROL_AMD64 or CONTEXT_INTEGER_AMD64 or CONTEXT_FLOATING_POINT_AMD64);
  CONTEXT_ALL_AMD64             = (CONTEXT_CONTROL_AMD64 or CONTEXT_INTEGER_AMD64 or CONTEXT_SEGMENTS_AMD64 or CONTEXT_FLOATING_POINT_AMD64 or CONTEXT_DEBUG_REGISTERS_AMD64);

  CONTEXT_EXCEPTION_ACTIVE_AMD64    = $08000000;
  CONTEXT_SERVICE_ACTIVE_AMD64      = $10000000;
  CONTEXT_EXCEPTION_REQUEST_AMD64   = $40000000;
  CONTEXT_EXCEPTION_REPORTING_AMD64 = $80000000;



//
// Define initial MxCsr and FpCsr control.
//

//#define INITIAL_MXCSR 0x1f80            // initial MXCSR value
//#define INITIAL_FPCSR 0x027f            // initial FPCSR value

//
// Define 128-bit 16-byte aligned xmm register type.
//

//typedef struct DECLSPEC_ALIGN(16) _M128A {
type
  _M128A = record
    Low: ULONGLONG;
    High: LONGLONG;
  end;
  M128A = _M128A;
  TM128A = _M128A;
  PM128A = TM128A;

//
// Format of data for 32-bit fxsave/fxrstor instructions.
//

//typedef struct _XMM_SAVE_AREA32 {
type
  _XMM_SAVE_AREA32 = record
    ControlWord: WORD;
    StatusWord: WORD;
    TagWord: BYTE;
    Reserved1: BYTE;
    ErrorOpcode: WORD;
    ErrorOffset: DWORD;
    ErrorSelector: WORD;
    Reserved2: WORD;
    DataOffset: DWORD;
    DataSelector: WORD;
    Reserved3: WORD;
    MxCsr: DWORD;
    MxCsr_Mask: DWORD;
    FloatRegisters: array[0..7] of M128A;
    XmmRegisters: array[0..16] of M128A;
    Reserved4: array[0..95] of BYTE;
  end;
  XMM_SAVE_AREA32 = _XMM_SAVE_AREA32;
  TXmmSaveArea = XMM_SAVE_AREA32;
  PXmmSaveArea = ^TXmmSaveArea;

const
  LEGACY_SAVE_AREA_LENGTH = sizeof(XMM_SAVE_AREA32);

//
// Context Frame
//
//  This frame has a several purposes: 1) it is used as an argument to
//  NtContinue, 2) is is used to constuct a call frame for APC delivery,
//  and 3) it is used in the user level thread creation routines.
//
//
// The flags field within this record controls the contents of a CONTEXT
// record.
//
// If the context record is used as an input parameter, then for each
// portion of the context record controlled by a flag whose value is
// set, it is assumed that that portion of the context record contains
// valid context. If the context record is being used to modify a threads
// context, then only that portion of the threads context is modified.
//
// If the context record is used as an output parameter to capture the
// context of a thread, then only those portions of the thread's context
// corresponding to set flags will be returned.
//
// CONTEXT_CONTROL specifies SegSs, Rsp, SegCs, Rip, and EFlags.
//
// CONTEXT_INTEGER specifies Rax, Rcx, Rdx, Rbx, Rbp, Rsi, Rdi, and R8-R15.
//
// CONTEXT_SEGMENTS specifies SegDs, SegEs, SegFs, and SegGs.
//
// CONTEXT_DEBUG_REGISTERS specifies Dr0-Dr3 and Dr6-Dr7.
//
// CONTEXT_MMX_REGISTERS specifies the floating point and extended registers
//     Mm0/St0-Mm7/St7 and Xmm0-Xmm15).
//

//typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
type
  _CONTEXTAMD64 = record

    //
    // Register parameter home addresses.
    //
    // N.B. These fields are for convience - they could be used to extend the
    //      context record in the future.
    //

    P1Home: DWORD64;
    P2Home: DWORD64;
    P3Home: DWORD64;
    P4Home: DWORD64;
    P5Home: DWORD64;
    P6Home: DWORD64;

    //
    // Control flags.
    //

    ContextFlags: DWORD;
    MxCsr: DWORD;

    //
    // Segment Registers and processor flags.
    //

    SegCs: WORD;
    SegDs: WORD;
    SegEs: WORD;
    SegFs: WORD;
    SegGs: WORD;
    SegSs: WORD;
    EFlags: DWORD;

    //
    // Debug registers
    //

    Dr0: DWORD64;
    Dr1: DWORD64;
    Dr2: DWORD64;
    Dr3: DWORD64;
    Dr6: DWORD64;
    Dr7: DWORD64;

    //
    // Integer registers.
    //

    Rax: DWORD64;
    Rcx: DWORD64;
    Rdx: DWORD64;
    Rbx: DWORD64;
    Rsp: DWORD64;
    Rbp: DWORD64;
    Rsi: DWORD64;
    Rdi: DWORD64;
    R8: DWORD64;
    R9: DWORD64;
    R10: DWORD64;
    R11: DWORD64;
    R12: DWORD64;
    R13: DWORD64;
    R14: DWORD64;
    R15: DWORD64;

    //
    // Program counter.
    //

    Rip: DWORD64;

    //
    // Floating point state.
    //

    FltSave: XMM_SAVE_AREA32; // MWE: only translated the FltSave part of the union
(*
    union  {
        XMM_SAVE_AREA32 FltSave;
        struct {
            M128A Header[2];
            M128A Legacy[8];
            M128A Xmm0;
            M128A Xmm1;
            M128A Xmm2;
            M128A Xmm3;
            M128A Xmm4;
            M128A Xmm5;
            M128A Xmm6;
            M128A Xmm7;
            M128A Xmm8;
            M128A Xmm9;
            M128A Xmm10;
            M128A Xmm11;
            M128A Xmm12;
            M128A Xmm13;
            M128A Xmm14;
            M128A Xmm15;
        };
    };
*)

    //
    // Vector registers.
    //

    VectorRegister: array[0..25] of M128A;
    VectorControl: DWORD64;

    //
    // Special debug control registers.
    //

    DebugControl: DWORD64;
    LastBranchToRip: DWORD64;
    LastBranchFromRip: DWORD64;
    LastExceptionToRip: DWORD64;
    LastExceptionFromRip: DWORD64;
  end;
  CONTEXTAMD64 = _CONTEXTAMD64;
  TContextAMD64 = _CONTEXTAMD64;
  PContextAMD64 = ^TContextAMD64;
  
{$endif}

implementation

end.